{"package":{"manifest":{"format":2,"sdk":"2.0","name":"Quick list","summary":"A checklist that remembers what you have done.","icon":"LuSquareCheck","theme":"harbor","data":{"scope":"device","collections":{"items":{"fields":{"title":{"type":"string","maxLength":200},"done":{"type":"boolean"},"note":{"type":"string","optional":true,"maxLength":1000}}}}},"permissions":{}},"files":{"index.html":"<main class=\"n-app\">\n  <header class=\"n-header\">\n    <div>\n      <h1>Quick list</h1>\n      <p class=\"n-small\" id=\"count\" aria-live=\"polite\"></p>\n    </div>\n  </header>\n  <div id=\"hero\"></div>\n  <div id=\"add\"></div>\n  <div id=\"list-host\"></div>\n</main>","style.css":".n-header h1 + .n-small { margin: 4px 0 0; }\n.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }\n.row-title { font-weight: 600; overflow-wrap: anywhere; }\n.is-done .row-title { text-decoration: line-through; color: var(--nerd-muted); font-weight: 400; }\n.row-note { font-style: italic; }","app.js":"(async function () {\n  \"use strict\";\n  var ui = nerd.ui, h = ui.h;\n  var ctx = await nerd.ready();\n  var readOnly = ctx.data.readOnly;\n  var countEl = document.getElementById(\"count\");\n  var heroHost = document.getElementById(\"hero\");\n  var addHost = document.getElementById(\"add\");\n  var listHost = document.getElementById(\"list-host\");\n\n  var progress = ui.meter({ value: 0, max: 1, label: \"Done\", tone: \"success\" });\n  var hero = ui.hero({ kicker: \"Checklist\", title: \"Ready when you are\", sub: \"Tap a circle to check an item off.\" }, progress);\n  heroHost.appendChild(hero);\n\n  var quick = ui.quickAdd(addHost, {\n    collection: \"items\",\n    label: \"New item\",\n    placeholder: \"Add an item and press Enter\",\n    parse: function (text) { return { title: text, done: false }; },\n    onAdd: function () { nerd.draft.set(null).catch(function () {}); },\n  });\n\n  // Keep the unfinished entry if the viewer leaves and comes back.\n  var draft = await nerd.draft.get();\n  if (draft && draft.title) quick.input.value = draft.title;\n  quick.input.addEventListener(\"input\", function () {\n    nerd.draft.set({ title: quick.input.value }).catch(function () {});\n  });\n\n  function toggle(item) {\n    nerd.data.update(\"items\", item.id, { done: !item.done }).catch(function (err) {\n      ui.toast(ui.explain(err));\n    });\n  }\n\n  function row(item) {\n    var ring = h(\"span\", { class: \"n-check-ring\", \"aria-hidden\": \"true\" }, item.done ? ui.icon(\"LuCheck\", { size: 14 }) : null);\n    return h(\"li\", { class: \"n-item\" + (item.done ? \" is-done\" : \"\") },\n      h(\"button\", {\n        type: \"button\",\n        class: \"n-check-btn\",\n        \"aria-pressed\": String(!!item.done),\n        \"aria-label\": (item.done ? \"Mark not done: \" : \"Mark done: \") + item.title,\n        disabled: readOnly,\n        onclick: function () { toggle(item); },\n      },\n        ring,\n        h(\"span\", { class: \"row-text\" },\n          h(\"span\", { class: \"row-title\" }, item.title),\n          item.note ? h(\"span\", { class: \"n-small row-note\" }, item.note) : null)),\n      readOnly ? null : h(\"div\", { class: \"n-item-actions\" },\n        h(\"button\", {\n          type: \"button\",\n          class: \"n-icon-btn\",\n          \"aria-label\": \"Remove \" + item.title,\n          onclick: function () { ui.removeWithUndo(\"items\", item.id, item.title).catch(function () {}); },\n        }, ui.icon(\"LuTrash2\"))));\n  }\n\n  var itemsList = h(\"div\");\n  var panel = ui.panel({ title: \"Items\", count: 0 }, itemsList);\n  listHost.appendChild(panel);\n  ui.list(itemsList, {\n    collection: \"items\",\n    query: { order: [\"done\", \"createdAt\"] },\n    render: row,\n    empty: {\n      icon: \"LuListChecks\",\n      title: \"Nothing here yet\",\n      text: readOnly ? \"No items on this list yet.\" : \"Add your first item above and press Enter.\",\n      action: readOnly ? null : { label: \"Add an item\", run: function () { quick.input.focus(); } },\n    },\n  });\n\n  nerd.data.observe(function (snap) {\n    var items = snap.items || [];\n    var done = items.filter(function (i) { return i.done; }).length;\n    var left = items.length - done;\n    countEl.textContent = items.length ? (left ? left + \" of \" + items.length + \" left\" : \"All done\") : \"\";\n    heroHost.hidden = !items.length;\n    if (items.length) {\n      var titleEl = hero.querySelector(\".n-hero-title\");\n      if (titleEl) titleEl.textContent = left ? left + (left === 1 ? \" item left\" : \" items left\") : \"Everything checked off\";\n      progress.update({ value: done, max: items.length, label: done + \" of \" + items.length + \" done\", tone: left === 0 ? \"success\" : \"accent\" });\n    }\n    var countBadge = panel.querySelector(\".n-panel-count\");\n    if (countBadge) countBadge.textContent = String(items.length);\n  }, function (err) {\n    ui.toast(ui.explain(err));\n  });\n\n  if (ctx.preview) ui.toast(\"Preview: changes here are test data.\");\n})();"}},"sampleData":{"items":[{"title":"Read the build guide","done":true},{"title":"Sketch the first screen","done":false,"note":"Phone width first."},{"title":"Ship it","done":false}]},"summary":"A checklist that remembers what you have done.","verification":"Example only."}