@kirana-ui/web 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/llms.txt +3174 -0
  2. package/package.json +14 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +163 -0
  4. package/src/accordion.d.ts +18 -3
  5. package/src/accordion.js +5 -4
  6. package/src/accordion.js.map +1 -1
  7. package/src/agent.d.ts +1 -0
  8. package/src/agent.js +1 -0
  9. package/src/alert-dialog.d.ts +14 -3
  10. package/src/alert-dialog.js +6 -2
  11. package/src/alert-dialog.js.map +1 -1
  12. package/src/around.d.ts +37 -4
  13. package/src/around.js +72 -8
  14. package/src/around.js.map +1 -1
  15. package/src/autocomplete.d.ts +17 -3
  16. package/src/autocomplete.js +9 -4
  17. package/src/autocomplete.js.map +1 -1
  18. package/src/autosize.d.ts +10 -1
  19. package/src/autosize.js.map +1 -1
  20. package/src/avatar.d.ts +21 -3
  21. package/src/avatar.js +39 -10
  22. package/src/avatar.js.map +1 -1
  23. package/src/button.d.ts +10 -1
  24. package/src/button.js.map +1 -1
  25. package/src/calendar.d.ts +19 -5
  26. package/src/calendar.js +21 -9
  27. package/src/calendar.js.map +1 -1
  28. package/src/carousel.d.ts +10 -1
  29. package/src/carousel.js.map +1 -1
  30. package/src/checkbox-group.d.ts +22 -0
  31. package/src/checkbox-group.js +36 -0
  32. package/src/checkbox-group.js.map +1 -0
  33. package/src/checkbox.d.ts +16 -3
  34. package/src/checkbox.js +10 -4
  35. package/src/checkbox.js.map +1 -1
  36. package/src/collapsible.d.ts +10 -1
  37. package/src/collapsible.js.map +1 -1
  38. package/src/combobox.d.ts +37 -7
  39. package/src/combobox.js +52 -16
  40. package/src/combobox.js.map +1 -1
  41. package/src/command.d.ts +12 -2
  42. package/src/command.js +2 -1
  43. package/src/command.js.map +1 -1
  44. package/src/context-menu.d.ts +13 -1
  45. package/src/context-menu.js.map +1 -1
  46. package/src/date-field.d.ts +10 -1
  47. package/src/date-field.js.map +1 -1
  48. package/src/date-picker.d.ts +19 -4
  49. package/src/date-picker.js +14 -11
  50. package/src/date-picker.js.map +1 -1
  51. package/src/dates.d.ts +5 -2
  52. package/src/dates.js +50 -15
  53. package/src/dates.js.map +1 -1
  54. package/src/dialog.d.ts +14 -3
  55. package/src/dialog.js +6 -2
  56. package/src/dialog.js.map +1 -1
  57. package/src/drawer.d.ts +17 -1
  58. package/src/drawer.js.map +1 -1
  59. package/src/field.d.ts +8 -1
  60. package/src/field.js.map +1 -1
  61. package/src/fieldset.d.ts +10 -1
  62. package/src/fieldset.js.map +1 -1
  63. package/src/form.d.ts +13 -1
  64. package/src/form.js.map +1 -1
  65. package/src/hover-card.d.ts +10 -1
  66. package/src/hover-card.js.map +1 -1
  67. package/src/hover-popup.d.ts +2 -1
  68. package/src/hover-popup.js +2 -8
  69. package/src/hover-popup.js.map +1 -1
  70. package/src/index.d.ts +60 -1
  71. package/src/index.js +1 -0
  72. package/src/input.d.ts +12 -1
  73. package/src/input.js.map +1 -1
  74. package/src/label.d.ts +9 -1
  75. package/src/label.js.map +1 -1
  76. package/src/listbox.d.ts +15 -1
  77. package/src/listbox.js.map +1 -1
  78. package/src/menu.d.ts +15 -4
  79. package/src/menu.js +2 -8
  80. package/src/menu.js.map +1 -1
  81. package/src/menubar.d.ts +10 -1
  82. package/src/menubar.js.map +1 -1
  83. package/src/message-scroller.d.ts +10 -1
  84. package/src/message-scroller.js.map +1 -1
  85. package/src/meter.d.ts +10 -1
  86. package/src/meter.js.map +1 -1
  87. package/src/navigation-menu.d.ts +15 -4
  88. package/src/navigation-menu.js +7 -13
  89. package/src/navigation-menu.js.map +1 -1
  90. package/src/number-field.d.ts +18 -3
  91. package/src/number-field.js +23 -3
  92. package/src/number-field.js.map +1 -1
  93. package/src/otp.d.ts +12 -2
  94. package/src/otp.js +2 -1
  95. package/src/otp.js.map +1 -1
  96. package/src/pagination.d.ts +10 -1
  97. package/src/pagination.js.map +1 -1
  98. package/src/popover.d.ts +16 -3
  99. package/src/popover.js +35 -12
  100. package/src/popover.js.map +1 -1
  101. package/src/progress.d.ts +10 -1
  102. package/src/progress.js.map +1 -1
  103. package/src/qr-code.d.ts +8 -1
  104. package/src/qr-code.js.map +1 -1
  105. package/src/radio-group.d.ts +12 -2
  106. package/src/radio-group.js +9 -2
  107. package/src/radio-group.js.map +1 -1
  108. package/src/resizable.d.ts +10 -1
  109. package/src/resizable.js.map +1 -1
  110. package/src/runtime.d.ts +42 -4
  111. package/src/runtime.js +35 -7
  112. package/src/runtime.js.map +1 -1
  113. package/src/scroll-area.d.ts +13 -2
  114. package/src/scroll-area.js +3 -1
  115. package/src/scroll-area.js.map +1 -1
  116. package/src/select.d.ts +26 -5
  117. package/src/select.js +36 -11
  118. package/src/select.js.map +1 -1
  119. package/src/separator.d.ts +10 -1
  120. package/src/separator.js.map +1 -1
  121. package/src/slider.d.ts +20 -5
  122. package/src/slider.js +9 -8
  123. package/src/slider.js.map +1 -1
  124. package/src/switch.d.ts +12 -1
  125. package/src/switch.js.map +1 -1
  126. package/src/tabs.d.ts +10 -1
  127. package/src/tabs.js.map +1 -1
  128. package/src/testing.d.ts +1 -0
  129. package/src/testing.js +1 -0
  130. package/src/toast.d.ts +20 -7
  131. package/src/toast.js +28 -7
  132. package/src/toast.js.map +1 -1
  133. package/src/toggle-group.d.ts +16 -1
  134. package/src/toggle-group.js.map +1 -1
  135. package/src/toggle.d.ts +12 -1
  136. package/src/toggle.js.map +1 -1
  137. package/src/toolbar.d.ts +10 -1
  138. package/src/toolbar.js.map +1 -1
  139. package/src/tooltip.d.ts +10 -1
  140. package/src/tooltip.js.map +1 -1
package/src/runtime.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import { bind, effect, sameProps, signal } from "@kirana-ui/core";
2
2
  // src/runtime.ts
3
3
  const ENTRY = /* @__PURE__ */ new WeakMap();
4
- /** The entry an element was stamped for, or the nearest around it: a part reads its own. */
5
- function entryAround(element) {
6
- for (let each = element; each; each = each.parentNode) if (ENTRY.has(each)) return ENTRY.get(each);
4
+ /**
5
+ * The entry an element was stamped for, or the nearest around it: a part reads its own. With
6
+ * `which`, the nearest that is of that list (a day's month, around its week).
7
+ */
8
+ function entryAround(element, which) {
9
+ for (let each = element; each; each = each.parentNode) if (ENTRY.has(each) && (!which || which(ENTRY.get(each)))) return ENTRY.get(each);
7
10
  }
8
11
  /** `{name}` in a text, for each name there is a value for; another brace is the page's own. */
9
12
  const fill = (text, values) => text.replace(/\{([A-Za-z_][\w-]*)\}/g, (whole, name) => name in values ? String(values[name] ?? "") : whole);
@@ -45,14 +48,34 @@ function hostAround(host, tags) {
45
48
  function partAround(element, name) {
46
49
  return element.closest(`[kui-part="${name}"]`);
47
50
  }
51
+ let settling;
52
+ /**
53
+ * A page's markup is drawn before its components begin, so a part's style (a slider thumb's
54
+ * place) reaches an element the browser has already styled, and a design's `transition` on it
55
+ * would run as the page begins: each thumb gliding to where it was all along. A framework's
56
+ * element has its style before it is first drawn; here what the first style started is ended
57
+ * before the page is drawn again, once for all the parts of a pass.
58
+ */
59
+ function settle(element) {
60
+ if (typeof element.getAnimations !== "function") return;
61
+ if (!settling) {
62
+ const written = settling = [];
63
+ queueMicrotask(() => {
64
+ settling = void 0;
65
+ for (const each of written) for (const animation of each.getAnimations()) if (animation instanceof CSSTransition) animation.cancel();
66
+ });
67
+ }
68
+ settling.push(element);
69
+ }
48
70
  /**
49
71
  * Puts a part on an element, and takes it off whole: what the part wrote is gone with it. A
50
72
  * framework draws a new element each time a part comes back; here the same element is the
51
73
  * part again, and must not still say what it said before (`data-closed`, `aria-controls`).
52
74
  */
53
- function put(element, part) {
75
+ function put(element, part, drawn = false) {
54
76
  const before = new Map(Array.from(element.attributes, (each) => [each.name, each.value]));
55
77
  const unbind = bind(element, part);
78
+ if (drawn && part.props.peek().style) settle(element);
56
79
  return () => {
57
80
  unbind();
58
81
  for (const { name } of Array.from(element.attributes)) if (!before.has(name) && name !== "class") element.removeAttribute(name);
@@ -138,6 +161,7 @@ function defineElement(spec) {
138
161
  #held = /* @__PURE__ */ new Map();
139
162
  #stops = [];
140
163
  #leaving = false;
164
+ #first = false;
141
165
  #watch = () => {};
142
166
  connectedCallback() {
143
167
  this.#leaving = false;
@@ -186,7 +210,9 @@ function defineElement(spec) {
186
210
  subtree: true
187
211
  });
188
212
  this.#stops.push(() => observer.disconnect());
213
+ this.#first = true;
189
214
  for (const each of Array.from(this.children)) if (drawable(each)) this.#scan(each);
215
+ this.#first = false;
190
216
  const inner = spec.inner?.(this.controller);
191
217
  if (inner) {
192
218
  const input = this.ownerDocument.createElement("input");
@@ -359,11 +385,13 @@ function defineElement(spec) {
359
385
  stops.push(effect(() => void (element.textContent = text.get() ?? "")), () => void (element.textContent = ""));
360
386
  }
361
387
  const mounted = element.hasAttribute("kui-keep-mounted") ? void 0 : drawn.mounted;
362
- if (!mounted) return void stops.push(put(element, drawn.part));
388
+ const first = this.#first;
389
+ if (!mounted) return void stops.push(put(element, drawn.part, first));
363
390
  const home = this.ownerDocument.createComment("");
364
391
  let unbind;
365
392
  stops.push(effect(() => {
366
393
  const elsewhere = drawn.into?.get();
394
+ const own = first && !elsewhere && !held.parked && !unbind;
367
395
  if (mounted.get() && (!drawn.into || elsewhere)) {
368
396
  if (elsewhere) {
369
397
  if (!held.parked && element.parentNode) element.replaceWith(home);
@@ -373,7 +401,7 @@ function defineElement(spec) {
373
401
  held.parked = false;
374
402
  home.replaceWith(element);
375
403
  }
376
- unbind ??= put(element, drawn.part);
404
+ unbind ??= put(element, drawn.part, own);
377
405
  } else {
378
406
  unbind?.();
379
407
  unbind = void 0;
@@ -447,6 +475,6 @@ function defineElement(spec) {
447
475
  customElements.define(spec.tag, KuiElement);
448
476
  return spec.tag;
449
477
  }
450
- export { controllerAround, defineElement, entryAround, hostAround, partAround, partProps };
478
+ export { controllerAround, defineElement, entryAround, hostAround, ownerOf, partAround, partProps };
451
479
 
452
480
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/web/src/runtime.ts"],"sourcesContent":["import { bind, effect, sameProps, signal } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Part, ReadonlySignal, Signal } from \"@kirana-ui/core\"\n\n/**\n * A component as a custom element, for a page with no framework.\n *\n * The custom element (`<kui-dialog>`) holds the component and draws nothing: it takes no room\n * (`display: contents`) and no attribute of the component's. Its parts are the page's own\n * elements, named by `kui-part` (`<button kui-part=\"trigger\">`), the root among them. So a\n * trigger is a real button and a switch a real button, and the page is the page the other\n * adapters draw: nothing is wrapped, and there is no shadow root for a design to reach into.\n *\n * A part that is in the page only some of the time (a closed panel, a popup) is taken out of\n * the page while it is not, and put back where it was; `kui-keep-mounted` keeps it.\n */\n\n/** What a part's name gives: the part, and what comes with it. */\nexport interface Drawn {\n readonly part: Part\n /** In the page only while this holds. */\n readonly mounted?: ReadonlySignal<boolean> | undefined\n /** Runs while the part is the component's. Returns the stop. */\n mount?(): () => void\n /** A hidden native input the part draws itself, as its last child. */\n readonly inner?: Part | undefined\n /**\n * Where the part is drawn while it is mounted, when that is not where it was written: a\n * navigation menu's content, in the menu's one viewport. Out of the page while there is none.\n */\n readonly into?: ReadonlySignal<HTMLElement | undefined> | undefined\n /** What the part's element says, when the page gave it nothing to say. */\n readonly text?: ReadonlySignal<string | undefined> | undefined\n}\n\ntype Kind = \"boolean\" | \"string\" | \"number\"\n\n/** A list a component draws from a `<template kui-each>`. */\nexport interface Each<Entry = any> {\n readonly entries: ReadonlySignal<readonly Entry[]> | readonly Entry[]\n /** What an entry is known by from one drawing to the next. */\n key(entry: Entry): string | number\n /**\n * Which of the template's elements an entry is drawn with, when they differ: the ones\n * whose `kui-when` says so (a page, an ellipsis). Elements without `kui-when` are for all.\n */\n type?(entry: Entry): string\n /**\n * What `{name}` stands for in the template's text and attributes\n * (`data-testid=\"row-{id}\"`). Left out: the entry's own fields.\n */\n values?(entry: Entry): Record<string, unknown>\n}\n\nconst ENTRY = new WeakMap<Node, unknown>()\n\n/** The entry an element was stamped for, or the nearest around it: a part reads its own. */\nexport function entryAround<Entry>(element: Node): Entry | undefined {\n for (let each: Node | null = element; each; each = each.parentNode) {\n if (ENTRY.has(each)) return ENTRY.get(each) as Entry\n }\n return undefined\n}\n\n/** `{name}` in a text, for each name there is a value for; another brace is the page's own. */\nconst fill = (text: string, values: Record<string, unknown>) =>\n text.replace(/\\{([A-Za-z_][\\w-]*)\\}/g, (whole, name: string) =>\n name in values ? String(values[name] ?? \"\") : whole\n )\n\ninterface Row {\n entry: unknown\n nodes: ChildNode[]\n /** Where a `{name}` was written: read again when the entry changes. */\n written: (readonly [Attr | Text, string])[]\n}\n\nexport interface ElementSpec<Props extends { id: string }, Controller> {\n /** The custom element's name: `kui-dialog`. */\n tag: string\n /** Its props by attribute name, each with how an attribute's text is read. */\n props: Record<string, Kind>\n /** Props that are only properties: a function, an object. By their names as properties. */\n properties?: readonly string[] | undefined\n /**\n * What the component draws a list of, by name: a calendar's weeks, a toast for each\n * message. The page writes one of an entry as a `<template kui-each=\"name\">` where the\n * list goes, and the element stamps it for each entry, keyed, so an entry that stays keeps\n * its elements. `around` is the entry of the list this one is written in (a week, for its\n * days).\n */\n lists?: Record<string, (controller: Controller, around: unknown) => Each | undefined>\n /**\n * The hidden native input a form reads, for a component with no part to hold it: drawn as\n * the element's last child, while `mounted` (a select with a name).\n */\n inner?(controller: Controller): { part: Part; mounted?: ReadonlySignal<boolean> | undefined }\n /** `host` is the custom element: what is around it (a field, a group) is found from it. */\n create(props: ReadonlySignal<Props>, host: HTMLElement): Controller\n /**\n * Its change callbacks: the event each is told as, and the prop the element then holds\n * (`open`). The event is cancelable: `preventDefault()` keeps the value as it was.\n */\n changes: Record<string, { event: string; prop: string; hold?: boolean }>\n /** Each part by its `kui-part` name. */\n parts: Record<string, (controller: Controller, element: HTMLElement) => Part | Drawn | undefined>\n}\n\nconst camel = (name: string) =>\n name.replace(/-([a-z])/g, (_all, letter: string) => letter.toUpperCase())\nconst hosts = new Set<string>()\nconst OWNER = Symbol(\"kui-owner\")\nlet made = 0\n\ntype Owned = HTMLElement & { [OWNER]?: HTMLElement }\n\n/**\n * Whether an element is a component's: one that was defined, or a `kui-` one that is yet to\n * be (its entry is imported later). What is inside it is its own from the start, and not a\n * part of the component around it that happens to have a part of the same name.\n */\nconst ours = (element: Element) =>\n hosts.has(element.localName) || element.localName.startsWith(\"kui-\")\n\n/** The component a part belongs to: the nearest around it, or the one that moved it to the page's end. */\nfunction ownerOf(element: Element): HTMLElement | null {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n if (ours(each)) return each as HTMLElement\n const moved = (each as Owned)[OWNER]\n if (moved) return moved\n }\n return null\n}\n\n/**\n * The controller of the component around a custom element: the field a control is in, the\n * group a toggle is one of. Through a portal too: what was moved to the page's end is still\n * inside what it was written in.\n */\nexport function controllerAround<Controller>(host: Element, tag: string): Controller | undefined {\n return hostAround(host, [tag])?.controller as Controller | undefined\n}\n\n/** The nearest component around a custom element that is one of `tags`: which, and its controller. */\nexport function hostAround(\n host: Element,\n tags: readonly string[]\n): { tag: string; controller: unknown } | undefined {\n for (let each: Element | null = ownerOf(host); each; each = ownerOf(each)) {\n if (tags.includes(each.localName))\n return { tag: each.localName, controller: (each as { controller?: unknown }).controller }\n }\n return undefined\n}\n\n/** The nearest element around `element` (or itself) that is the part called `name`. */\nexport function partAround(element: Element, name: string): HTMLElement | null {\n return element.closest<HTMLElement>(`[kui-part=\"${name}\"]`)\n}\n\n/**\n * Puts a part on an element, and takes it off whole: what the part wrote is gone with it. A\n * framework draws a new element each time a part comes back; here the same element is the\n * part again, and must not still say what it said before (`data-closed`, `aria-controls`).\n */\nfunction put(element: HTMLElement, part: Part): () => void {\n const before = new Map(Array.from(element.attributes, (each) => [each.name, each.value]))\n const unbind = bind(element, part)\n return () => {\n unbind()\n for (const { name } of Array.from(element.attributes)) {\n // Its classes are the page's own, whatever was added to them since.\n if (!before.has(name) && name !== \"class\") element.removeAttribute(name)\n }\n for (const [name, value] of before) {\n if (name !== \"class\" && element.getAttribute(name) !== value)\n element.setAttribute(name, value)\n }\n }\n}\n\n/**\n * The props of something inside a component that has props of its own (a menu's checkbox\n * item, its radio group), read from its element's `kui-` attributes: `kui-checked`,\n * `kui-default-value`. What it tells is told from that element, and may be refused; a value\n * its element was given is held there, and one the page writes later is followed.\n */\nexport function partProps<Props>(\n element: HTMLElement,\n kinds: Record<string, Kind>,\n changes: Record<string, { event: string; prop: string }>\n): { props: ReadonlySignal<Props>; mount(): () => void } {\n const attribute = (name: string) => `kui-${name}`\n const told: Record<string, unknown> = {}\n const all = () => {\n const next: Record<string, unknown> = { ...told }\n for (const [name, kind] of Object.entries(kinds)) {\n const text = element.getAttribute(attribute(name))\n if (text !== null) next[camel(name)] = read(kind, text)\n }\n return next as Props\n }\n const source = signal<Props>({} as Props, sameProps as (a: Props, b: Props) => boolean)\n for (const [callback, { event, prop }] of Object.entries(changes)) {\n told[callback] = (value: unknown, details?: ChangeDetails) => {\n const heard = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!element.dispatchEvent(heard)) return details?.cancel()\n const held = attribute(prop.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`))\n if (element.hasAttribute(held)) element.setAttribute(held, String(value))\n source.set(all())\n }\n }\n source.set(all())\n return {\n props: source,\n mount() {\n const observer = new MutationObserver(() => source.set(all()))\n observer.observe(element, {\n attributes: true,\n attributeFilter: Object.keys(kinds).map(attribute),\n })\n return () => observer.disconnect()\n },\n }\n}\n\nfunction read(kind: Kind, text: string | null): unknown {\n if (kind === \"boolean\") return text !== null && text !== \"false\"\n if (text === null) return undefined\n return kind === \"number\" ? Number(text) : text\n}\n\n// Components written inside one that has not begun: its element is not defined yet (its\n// entry is imported later), or it waits itself. They begin when it has.\nconst waiting = new Set<{ begin(): void }>()\n\n/** Whether a component around `element` has yet to begin: what is inside it reads it. */\nfunction early(element: Element): boolean {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n // Moved to the page's end by a component that had begun: on from that one.\n const moved = (each as Owned)[OWNER]\n if (moved) return early(moved)\n if (ours(each) && !(each as { controller?: unknown }).controller) return true\n }\n return false\n}\n\n/** What can be a part: an element of the page, one of a drawing (`<svg>`, `<path>`) too. */\nconst drawable = (node: Node): node is HTMLElement => node instanceof Element\n\ninterface Held {\n stop(): void\n /** Taken out of the page by the component itself: still its part. */\n parked: boolean\n}\n\n/**\n * Defines a component's custom element, and gives its name (for\n * `customElements.whenDefined`). Where there are no custom elements (a server) it defines\n * nothing.\n */\nexport function defineElement<Props extends { id: string }, Controller extends object>(\n spec: ElementSpec<Props, Controller>\n): string {\n if (typeof customElements === \"undefined\" || customElements.get(spec.tag)) return spec.tag\n hosts.add(spec.tag)\n const names = Object.keys(spec.props)\n\n class KuiElement extends HTMLElement {\n static observedAttributes = names\n controller?: Controller\n #props?: Signal<Props> | undefined\n // Set as properties before the element was upgraded, or before it joined the page.\n #given: Record<string, unknown> = {}\n #held = new Map<HTMLElement, Held>()\n #stops: (() => void)[] = []\n #leaving = false\n #watch: (element: HTMLElement) => void = () => {}\n\n connectedCallback() {\n this.#leaving = false\n this.begin()\n }\n\n /** Begins, unless a component around it has not: then it waits for that one. */\n begin() {\n if (this.controller || !this.isConnected) return\n if (early(this)) return void waiting.add(this)\n waiting.delete(this)\n // It holds its parts and draws nothing: no box of its own between them and the page.\n if (!this.style.display) this.style.display = \"contents\"\n const initial: Record<string, unknown> = {\n id: this.getAttribute(\"kui-id\") || `kui-${++made}`,\n }\n for (const name of names) {\n const text = this.getAttribute(name)\n // An attribute that is not there says nothing: the component's own default holds.\n if (text !== null) initial[camel(name)] = read(spec.props[name]!, text)\n }\n Object.assign(initial, this.#given)\n for (const [callback, { event, prop, hold }] of Object.entries(spec.changes)) {\n initial[callback] = (value: unknown, details?: ChangeDetails) => {\n const told = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!this.dispatchEvent(told)) return details?.cancel()\n // A value that was given is held by the element from then on, as `<details open>`\n // holds its own: it follows what happens to it.\n if (hold !== false && this.given(prop) !== undefined) this.give(prop, value)\n }\n }\n this.#props = signal(initial as Props, sameProps as (a: Props, b: Props) => boolean)\n this.controller = spec.create(this.#props, this)\n const unmount = (this.controller as { mount?(): () => void }).mount?.()\n if (unmount) this.#stops.push(unmount)\n // Parts that come and go: a page that draws its rows later, a list that changes.\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of record.removedNodes) {\n if (drawable(node)) this.#release(node)\n }\n for (const node of record.addedNodes) if (drawable(node)) this.#scan(node)\n }\n })\n observer.observe(this, { childList: true, subtree: true })\n this.#watch = (element) => observer.observe(element, { childList: true, subtree: true })\n this.#stops.push(() => observer.disconnect())\n // A copy: a part that is not in the page yet is taken out as it is met.\n for (const each of Array.from(this.children)) if (drawable(each)) this.#scan(each)\n const inner = spec.inner?.(this.controller)\n if (inner) {\n const input = this.ownerDocument.createElement(\"input\")\n let unbind: (() => void) | undefined\n const drawn = effect(() => {\n const wanted = inner.mounted?.get() ?? true\n if (wanted && !unbind) {\n this.append(input)\n unbind = bind(input, inner.part)\n } else if (!wanted && unbind) {\n unbind()\n unbind = undefined\n input.remove()\n }\n })\n this.#stops.push(() => {\n drawn()\n unbind?.()\n input.remove()\n })\n }\n for (const each of Array.from(waiting)) each.begin()\n }\n\n disconnectedCallback() {\n // Moved, it comes straight back: only an element that has left is taken apart.\n this.#leaving = true\n queueMicrotask(() => {\n if (!this.#leaving || this.isConnected) return\n waiting.delete(this)\n for (const held of this.#held.values()) held.stop()\n this.#held.clear()\n for (const stop of this.#stops.splice(0).reverse()) stop()\n delete this.controller\n this.#props = undefined\n })\n }\n\n attributeChangedCallback(name: string, _before: string | null, text: string | null) {\n this.give(camel(name), read(spec.props[name]!, text))\n }\n\n /** A prop as it was last given: by an attribute, or as a property. */\n given(prop: string): unknown {\n return this.#props ? (this.#props.peek() as Record<string, unknown>)[prop] : this.#given[prop]\n }\n\n give(prop: string, value: unknown) {\n if (!this.#props) return void (this.#given[prop] = value)\n if (!Object.is((this.#props.peek() as Record<string, unknown>)[prop], value))\n this.#props.set({ ...this.#props.peek(), [prop]: value })\n }\n\n /** Takes the parts in a subtree, in the page's order: one that leaves takes its own with it. */\n #scan(element: HTMLElement) {\n if (!element.isConnected) return\n if (element instanceof HTMLTemplateElement) {\n if (element.hasAttribute(\"kui-each\") && ownerOf(element) === this) this.#each(element)\n return\n }\n if (element.hasAttribute(\"kui-part\")) this.#adopt(element)\n for (const each of Array.from(element.children)) if (drawable(each)) this.#scan(each)\n }\n\n /** Draws a list from its template: a copy for each entry, where the template was. */\n #each(template: HTMLTemplateElement) {\n const list = spec.lists?.[template.getAttribute(\"kui-each\")!]?.(\n this.controller!,\n entryAround(template)\n )\n if (!list) return\n // The template leaves the page for a mark: what is drawn is the page a framework draws.\n const mark = this.ownerDocument.createComment(\"\")\n if (ENTRY.has(template)) ENTRY.set(mark, ENTRY.get(template))\n template.replaceWith(mark)\n const rows = new Map<string | number, Row>()\n const stamp = (entry: unknown): Row => {\n const type = list.type?.(entry)\n const copy = template.content.cloneNode(true) as DocumentFragment\n for (const node of Array.from(copy.childNodes)) {\n const blank = node.nodeType === Node.TEXT_NODE && !node.textContent!.trim()\n const other =\n node instanceof Element &&\n node.hasAttribute(\"kui-when\") &&\n node.getAttribute(\"kui-when\") !== type\n if (blank || other || node.nodeType === Node.COMMENT_NODE) node.remove()\n }\n const written: (readonly [Attr | Text, string])[] = []\n const walker = this.ownerDocument.createTreeWalker(\n copy,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT\n )\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n // A list written in this one is filled when it is drawn, for its own entries.\n if (node instanceof Text) {\n if (node.data.includes(\"{\")) written.push([node, node.data])\n } else if (!(node instanceof HTMLTemplateElement)) {\n for (const attribute of Array.from((node as Element).attributes))\n if (attribute.value.includes(\"{\")) written.push([attribute, attribute.value])\n }\n }\n const nodes = Array.from(copy.childNodes)\n for (const node of nodes) ENTRY.set(node, entry)\n return { entry, nodes, written }\n }\n const write = (row: Row) => {\n const values =\n list.values?.(row.entry) ?? (row.entry as Record<string, unknown> | undefined) ?? {}\n for (const [node, text] of row.written) {\n const next = fill(text, values)\n if (node instanceof Text) {\n if (node.data !== next) node.data = next\n } else if (node.value !== next) node.value = next\n }\n }\n const draw = () => {\n const { entries } = list\n const next = \"get\" in entries ? entries.get() : entries\n const parent = mark.parentNode\n if (!parent) return\n const kept = new Set<string | number>()\n const fresh: Row[] = []\n const ordered = next.map((entry) => {\n const key = list.key(entry)\n kept.add(key)\n let row = rows.get(key)\n if (!row) {\n rows.set(key, (row = stamp(entry)))\n fresh.push(row)\n write(row)\n } else if (row.entry !== entry) {\n row.entry = entry\n for (const node of row.nodes) ENTRY.set(node, entry)\n write(row)\n }\n return row\n })\n for (const [key, row] of rows) {\n if (kept.has(key)) continue\n rows.delete(key)\n for (const node of row.nodes) node.remove()\n }\n // From the end: a copy that is where it belongs is not moved, and keeps focus.\n let before: ChildNode = mark\n for (const row of ordered.reverse()) {\n for (const node of row.nodes.toReversed()) {\n if (node.nextSibling !== before || node.parentNode !== parent)\n parent.insertBefore(node, before)\n before = node\n }\n }\n for (const row of fresh) for (const node of row.nodes) if (drawable(node)) this.#scan(node)\n }\n const stop = effect(draw)\n this.#stops.push(() => {\n stop()\n for (const row of rows.values()) for (const node of row.nodes) node.remove()\n rows.clear()\n mark.replaceWith(template)\n })\n }\n\n #adopt(element: HTMLElement) {\n if (this.#held.has(element) || ownerOf(element) !== this || !this.controller) return\n const name = element.getAttribute(\"kui-part\")!\n if (name === \"portal\") return this.#portal(element)\n const given = spec.parts[name]?.(this.controller, element)\n if (!given) return\n const drawn: Drawn = \"attach\" in given ? { part: given } : given\n const stops: (() => void)[] = []\n const held: Held = {\n parked: false,\n stop: () => {\n for (const stop of stops.splice(0).reverse()) stop()\n },\n }\n this.#held.set(element, held)\n const unmount = drawn.mount?.()\n if (unmount) stops.push(unmount)\n if (drawn.inner) {\n // One a server wrote there is taken over.\n const last = element.lastElementChild\n const taken = last instanceof HTMLInputElement && last.type === \"hidden\" ? last : undefined\n const input = taken ?? this.ownerDocument.createElement(\"input\")\n if (!taken) element.append(input)\n stops.push(bind(input, drawn.inner), () => {\n if (!taken) input.remove()\n })\n }\n if (drawn.text && element.childNodes.length === 0) {\n const { text } = drawn\n // Taken off, the element says nothing again: put back on (a popup opened a second\n // time), the text is the part's to write still, and not taken for the page's.\n stops.push(\n effect(() => void (element.textContent = text.get() ?? \"\")),\n () => void (element.textContent = \"\")\n )\n }\n const mounted = element.hasAttribute(\"kui-keep-mounted\") ? undefined : drawn.mounted\n if (!mounted) return void stops.push(put(element, drawn.part))\n // In the page only while it is mounted: out of it otherwise, its place kept by a mark.\n const home = this.ownerDocument.createComment(\"\")\n let unbind: (() => void) | undefined\n stops.push(\n effect(() => {\n const elsewhere = drawn.into?.get()\n if (mounted.get() && (!drawn.into || elsewhere)) {\n if (elsewhere) {\n // Its place where it was written is kept by the mark all the while.\n if (!held.parked && element.parentNode) element.replaceWith(home)\n held.parked = true\n if (element.parentNode !== elsewhere) elsewhere.append(element)\n } else if (held.parked) {\n held.parked = false\n home.replaceWith(element)\n }\n unbind ??= put(element, drawn.part)\n } else {\n unbind?.()\n unbind = undefined\n if (!held.parked && element.parentNode) {\n held.parked = true\n element.replaceWith(home)\n } else if (drawn.into) element.remove()\n }\n }),\n () => {\n unbind?.()\n if (held.parked) home.replaceWith(element)\n }\n )\n }\n\n /** What is inside is drawn at the end of the page while the component is mounted. */\n #portal(element: HTMLElement) {\n const mounted = (this.controller as { mounted?: ReadonlySignal<boolean> }).mounted\n if (!mounted) return\n ;(element as Owned)[OWNER] = this\n const home = this.ownerDocument.createComment(\"\")\n const held: Held = { parked: false, stop: () => {} }\n this.#held.set(element, held)\n this.#watch(element)\n const body = this.ownerDocument.body\n const stop = effect(() => {\n if (mounted.get()) {\n if (element.parentNode === body) return\n // Its place in the page is kept by a mark, for when the component leaves.\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n held.parked = false\n element.setAttribute(\"data-kirana-portal\", \"\")\n body.append(element)\n this.#scan(element)\n } else if (!held.parked) {\n held.parked = true\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n else element.remove()\n }\n })\n held.stop = () => {\n stop()\n element.removeAttribute(\"data-kirana-portal\")\n if (home.parentNode) home.replaceWith(element)\n else element.remove()\n }\n }\n\n #release(element: HTMLElement) {\n // Moved to the page's end by its own portal, or put back: still this component's.\n if (element.isConnected) return\n for (const [each, held] of this.#held) {\n if (each !== element && !element.contains(each)) continue\n // Taken out by the component itself: it is still the component's, to be put back.\n if (each === element && held.parked) continue\n held.stop()\n this.#held.delete(each)\n }\n }\n }\n\n // Each prop as a property too: `element.open = true`, and what the element holds read back.\n for (const name of [...names, ...(spec.properties ?? [])]) {\n const prop = camel(name)\n Object.defineProperty(KuiElement.prototype, prop, {\n configurable: true,\n get(this: KuiElement) {\n const state = (this.controller as Record<string, unknown> | undefined)?.[prop] as\n | ReadonlySignal<unknown>\n | undefined\n return typeof state?.peek === \"function\" ? state.peek() : this.given(prop)\n },\n set(this: KuiElement, value: unknown) {\n this.give(prop, value)\n },\n })\n }\n customElements.define(spec.tag, KuiElement)\n return spec.tag\n}\n"],"mappings":";;AAqDA,MAAM,wBAAQ,IAAI,QAAuB;;AAGzC,SAAgB,YAAmB,SAAkC;CACnE,KAAK,IAAI,OAAoB,SAAS,MAAM,OAAO,KAAK,YACtD,IAAI,MAAM,IAAI,IAAI,GAAG,OAAO,MAAM,IAAI,IAAI;AAG9C;;AAGA,MAAM,QAAQ,MAAc,WAC1B,KAAK,QAAQ,2BAA2B,OAAO,SAC7C,QAAQ,SAAS,OAAO,OAAO,SAAS,EAAE,IAAI,KAChD;AAwCF,MAAM,SAAS,SACb,KAAK,QAAQ,cAAc,MAAM,WAAmB,OAAO,YAAY,CAAC;AAC1E,MAAM,w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,GAAG;EACzD,MAAM,OAAO,MAAM,IAAI;EACvB,OAAO,eAAe,WAAW,WAAW,MAAM;GAChD,cAAc;GACd,MAAsB;IACpB,MAAM,QAAS,KAAK,aAAqD;IAGzE,OAAO,OAAO,OAAO,SAAS,aAAa,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI;GAC3E;GACA,IAAsB,OAAgB;IACpC,KAAK,KAAK,MAAM,KAAK;GACvB;EACF,CAAC;CACH;CACA,eAAe,OAAO,KAAK,KAAK,UAAU;CAC1C,OAAO,KAAK;AACd"}
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../../../../packages/web/src/runtime.ts"],"sourcesContent":["import { bind, effect, sameProps, signal } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Part, ReadonlySignal, Signal } from \"@kirana-ui/core\"\n\n/**\n * A component as a custom element, for a page with no framework.\n *\n * The custom element (`<kui-dialog>`) holds the component and draws nothing: it takes no room\n * (`display: contents`) and no attribute of the component's. Its parts are the page's own\n * elements, named by `kui-part` (`<button kui-part=\"trigger\">`), the root among them. So a\n * trigger is a real button and a switch a real button, and the page is the page the other\n * adapters draw: nothing is wrapped, and there is no shadow root for a design to reach into.\n *\n * A part that is in the page only some of the time (a closed panel, a popup) is taken out of\n * the page while it is not, and put back where it was; `kui-keep-mounted` keeps it.\n */\n\n/** What a part's name gives: the part, and what comes with it. */\nexport interface Drawn {\n readonly part: Part\n /** In the page only while this holds. */\n readonly mounted?: ReadonlySignal<boolean> | undefined\n /** Runs while the part is the component's. Returns the stop. */\n mount?(): () => void\n /** A hidden native input the part draws itself, as its last child. */\n readonly inner?: Part | undefined\n /**\n * Where the part is drawn while it is mounted, when that is not where it was written: a\n * navigation menu's content, in the menu's one viewport. Out of the page while there is none.\n */\n readonly into?: ReadonlySignal<HTMLElement | undefined> | undefined\n /** What the part's element says, when the page gave it nothing to say. */\n readonly text?: ReadonlySignal<string | undefined> | undefined\n}\n\ntype Kind = \"boolean\" | \"string\" | \"number\"\n\n/** A list a component draws from a `<template kui-each>`. */\nexport interface Each<Entry = any> {\n readonly entries: ReadonlySignal<readonly Entry[]> | readonly Entry[]\n /** What an entry is known by from one drawing to the next. */\n key(entry: Entry): string | number\n /**\n * Which of the template's elements an entry is drawn with, when they differ: the ones\n * whose `kui-when` says so (a page, an ellipsis). Elements without `kui-when` are for all.\n */\n type?(entry: Entry): string\n /**\n * What `{name}` stands for in the template's text and attributes\n * (`data-testid=\"row-{id}\"`). Left out: the entry's own fields.\n */\n values?(entry: Entry): Record<string, unknown>\n}\n\nconst ENTRY = new WeakMap<Node, unknown>()\n\n/**\n * The entry an element was stamped for, or the nearest around it: a part reads its own. With\n * `which`, the nearest that is of that list (a day's month, around its week).\n */\nexport function entryAround<Entry>(\n element: Node,\n which?: (entry: unknown) => boolean\n): Entry | undefined {\n for (let each: Node | null = element; each; each = each.parentNode) {\n if (ENTRY.has(each) && (!which || which(ENTRY.get(each)))) return ENTRY.get(each) as Entry\n }\n return undefined\n}\n\n/** `{name}` in a text, for each name there is a value for; another brace is the page's own. */\nconst fill = (text: string, values: Record<string, unknown>) =>\n text.replace(/\\{([A-Za-z_][\\w-]*)\\}/g, (whole, name: string) =>\n name in values ? String(values[name] ?? \"\") : whole\n )\n\ninterface Row {\n entry: unknown\n nodes: ChildNode[]\n /** Where a `{name}` was written: read again when the entry changes. */\n written: (readonly [Attr | Text, string])[]\n}\n\nexport interface ElementSpec<Props extends { id: string }, Controller> {\n /** The custom element's name: `kui-dialog`. */\n tag: string\n /** Its props by attribute name, each with how an attribute's text is read. */\n props: Record<string, Kind>\n /** Props that are only properties: a function, an object. By their names as properties. */\n properties?: readonly string[] | undefined\n /**\n * What the component draws a list of, by name: a calendar's weeks, a toast for each\n * message. The page writes one of an entry as a `<template kui-each=\"name\">` where the\n * list goes, and the element stamps it for each entry, keyed, so an entry that stays keeps\n * its elements. `around` is the entry of the list this one is written in (a week, for its\n * days).\n */\n lists?: Record<string, (controller: Controller, around: unknown) => Each | undefined>\n /**\n * The hidden native input a form reads, for a component with no part to hold it: drawn as\n * the element's last child, while `mounted` (a select with a name).\n */\n inner?(controller: Controller): { part: Part; mounted?: ReadonlySignal<boolean> | undefined }\n /** `host` is the custom element: what is around it (a field, a group) is found from it. */\n create(props: ReadonlySignal<Props>, host: HTMLElement): Controller\n /**\n * Its change callbacks: the event each is told as, and the prop the element then holds\n * (`open`). The event is cancelable: `preventDefault()` keeps the value as it was.\n */\n changes: Record<string, { event: string; prop: string; hold?: boolean }>\n /** Each part by its `kui-part` name. */\n parts: Record<string, (controller: Controller, element: HTMLElement) => Part | Drawn | undefined>\n}\n\ndeclare const DEFINED: unique symbol\n\n/**\n * A custom element's name as `defineElement` gives it. For TypeScript it also says what the\n * element was defined from, which `ElementOf` reads back; in the page it is the name alone.\n */\nexport type Tag<Props = unknown, Controller = unknown> = string & {\n readonly [DEFINED]?: readonly [Props, Controller]\n}\n\n/**\n * What a component tells: an event whose `detail` holds the value under its prop's name\n * (`detail.open`, `detail.values`) and why it changed (`detail.details.reason`).\n * `preventDefault()` keeps the value as it was.\n */\nexport type Told<Prop extends string, Value> = CustomEvent<\n { readonly [Name in Prop]: Value } & { readonly details: ChangeDetails }\n>\n\n/** A tag with its props said, where `defineElement` was left to work them out. */\nexport type As<Defined, Props> =\n Defined extends Tag<unknown, infer Controller> ? Tag<Props, Controller> : never\n\ntype Callback<Props, Name> = Name extends keyof Props\n ? Extract<Props[Name], (...given: never[]) => unknown>\n : never\n\ninterface Listens<Events> {\n addEventListener<Type extends keyof Events>(\n type: Type,\n listener: (this: HTMLElement, event: Events[Type]) => void,\n options?: boolean | AddEventListenerOptions\n ): void\n removeEventListener<Type extends keyof Events>(\n type: Type,\n listener: (this: HTMLElement, event: Events[Type]) => void,\n options?: boolean | EventListenerOptions\n ): void\n}\n\n/**\n * A component's custom element as TypeScript knows it, from its `tag`: its props as properties\n * (`element.open = true`), its controller once it has begun, and its events with their\n * `detail`. `Changes` names each event with the callback it tells and the prop it holds\n * (`{ \"open-change\": [\"onOpenChange\", \"open\"] }`), as the element's `changes` do; `More` is\n * for events its parts tell from their own elements, which reach it too.\n */\nexport type ElementOf<Defined, Changes = {}, More = {}> =\n Defined extends Tag<infer Props, infer Controller>\n ? Listens<\n {\n readonly [Event in keyof Changes]: Changes[Event] extends readonly [\n infer Name,\n infer Prop extends string,\n ]\n ? Told<Prop, Parameters<Callback<Props, Name>>[0]>\n : never\n } & More\n > & {\n -readonly [\n Name in keyof Props as Name extends \"id\" | `on${Capitalize<string>}` ? never : Name\n ]?: Props[Name]\n } & { controller?: Controller } & HTMLElement\n : never\n\nconst camel = (name: string) =>\n name.replace(/-([a-z])/g, (_all, letter: string) => letter.toUpperCase())\nconst hosts = new Set<string>()\nconst OWNER = Symbol(\"kui-owner\")\nlet made = 0\n\ntype Owned = HTMLElement & { [OWNER]?: HTMLElement }\n\n/**\n * Whether an element is a component's: one that was defined, or a `kui-` one that is yet to\n * be (its entry is imported later). What is inside it is its own from the start, and not a\n * part of the component around it that happens to have a part of the same name.\n */\nconst ours = (element: Element) =>\n hosts.has(element.localName) || element.localName.startsWith(\"kui-\")\n\n/** The component a part belongs to: the nearest around it, or the one that moved it to the page's end. */\nexport function ownerOf(element: Element): HTMLElement | null {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n if (ours(each)) return each as HTMLElement\n const moved = (each as Owned)[OWNER]\n if (moved) return moved\n }\n return null\n}\n\n/**\n * The controller of the component around a custom element: the field a control is in, the\n * group a toggle is one of. Through a portal too: what was moved to the page's end is still\n * inside what it was written in.\n */\nexport function controllerAround<Controller>(host: Element, tag: string): Controller | undefined {\n return hostAround(host, [tag])?.controller as Controller | undefined\n}\n\n/** The nearest component around a custom element that is one of `tags`: which, and its controller. */\nexport function hostAround(\n host: Element,\n tags: readonly string[]\n): { tag: string; controller: unknown } | undefined {\n for (let each: Element | null = ownerOf(host); each; each = ownerOf(each)) {\n if (tags.includes(each.localName))\n return { tag: each.localName, controller: (each as { controller?: unknown }).controller }\n }\n return undefined\n}\n\n/** The nearest element around `element` (or itself) that is the part called `name`. */\nexport function partAround(element: Element, name: string): HTMLElement | null {\n return element.closest<HTMLElement>(`[kui-part=\"${name}\"]`)\n}\n\n// Elements the page had drawn before their part gave them a style of its own.\nlet settling: HTMLElement[] | undefined\n\n/**\n * A page's markup is drawn before its components begin, so a part's style (a slider thumb's\n * place) reaches an element the browser has already styled, and a design's `transition` on it\n * would run as the page begins: each thumb gliding to where it was all along. A framework's\n * element has its style before it is first drawn; here what the first style started is ended\n * before the page is drawn again, once for all the parts of a pass.\n */\nfunction settle(element: HTMLElement): void {\n if (typeof element.getAnimations !== \"function\") return\n if (!settling) {\n const written: HTMLElement[] = (settling = [])\n queueMicrotask(() => {\n settling = undefined\n for (const each of written) {\n for (const animation of each.getAnimations()) {\n if (animation instanceof CSSTransition) animation.cancel()\n }\n }\n })\n }\n settling.push(element)\n}\n\n/**\n * Puts a part on an element, and takes it off whole: what the part wrote is gone with it. A\n * framework draws a new element each time a part comes back; here the same element is the\n * part again, and must not still say what it said before (`data-closed`, `aria-controls`).\n */\nfunction put(element: HTMLElement, part: Part, drawn = false): () => void {\n const before = new Map(Array.from(element.attributes, (each) => [each.name, each.value]))\n const unbind = bind(element, part)\n if (drawn && part.props.peek().style) settle(element)\n return () => {\n unbind()\n for (const { name } of Array.from(element.attributes)) {\n // Its classes are the page's own, whatever was added to them since.\n if (!before.has(name) && name !== \"class\") element.removeAttribute(name)\n }\n for (const [name, value] of before) {\n if (name !== \"class\" && element.getAttribute(name) !== value)\n element.setAttribute(name, value)\n }\n }\n}\n\n/**\n * The props of something inside a component that has props of its own (a menu's checkbox\n * item, its radio group), read from its element's `kui-` attributes: `kui-checked`,\n * `kui-default-value`. What it tells is told from that element, and may be refused; a value\n * its element was given is held there, and one the page writes later is followed.\n */\nexport function partProps<Props>(\n element: HTMLElement,\n kinds: Record<string, Kind>,\n changes: Record<string, { event: string; prop: string }>\n): { props: ReadonlySignal<Props>; mount(): () => void } {\n const attribute = (name: string) => `kui-${name}`\n const told: Record<string, unknown> = {}\n const all = () => {\n const next: Record<string, unknown> = { ...told }\n for (const [name, kind] of Object.entries(kinds)) {\n const text = element.getAttribute(attribute(name))\n if (text !== null) next[camel(name)] = read(kind, text)\n }\n return next as Props\n }\n const source = signal<Props>({} as Props, sameProps as (a: Props, b: Props) => boolean)\n for (const [callback, { event, prop }] of Object.entries(changes)) {\n told[callback] = (value: unknown, details?: ChangeDetails) => {\n const heard = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!element.dispatchEvent(heard)) return details?.cancel()\n const held = attribute(prop.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`))\n if (element.hasAttribute(held)) element.setAttribute(held, String(value))\n source.set(all())\n }\n }\n source.set(all())\n return {\n props: source,\n mount() {\n const observer = new MutationObserver(() => source.set(all()))\n observer.observe(element, {\n attributes: true,\n attributeFilter: Object.keys(kinds).map(attribute),\n })\n return () => observer.disconnect()\n },\n }\n}\n\nfunction read(kind: Kind, text: string | null): unknown {\n if (kind === \"boolean\") return text !== null && text !== \"false\"\n if (text === null) return undefined\n return kind === \"number\" ? Number(text) : text\n}\n\n// Components written inside one that has not begun: its element is not defined yet (its\n// entry is imported later), or it waits itself. They begin when it has.\nconst waiting = new Set<{ begin(): void }>()\n\n/** Whether a component around `element` has yet to begin: what is inside it reads it. */\nfunction early(element: Element): boolean {\n for (let each: Element | null = element.parentElement; each; each = each.parentElement) {\n // Moved to the page's end by a component that had begun: on from that one.\n const moved = (each as Owned)[OWNER]\n if (moved) return early(moved)\n if (ours(each) && !(each as { controller?: unknown }).controller) return true\n }\n return false\n}\n\n/** What can be a part: an element of the page, one of a drawing (`<svg>`, `<path>`) too. */\nconst drawable = (node: Node): node is HTMLElement => node instanceof Element\n\ninterface Held {\n stop(): void\n /** Taken out of the page by the component itself: still its part. */\n parked: boolean\n}\n\n/**\n * Defines a component's custom element, and gives its name (for\n * `customElements.whenDefined`). Where there are no custom elements (a server) it defines\n * nothing.\n */\nexport function defineElement<Props extends { id: string }, Controller extends object>(\n spec: ElementSpec<Props, Controller>\n): Tag<Props, Controller> {\n if (typeof customElements === \"undefined\" || customElements.get(spec.tag)) return spec.tag\n hosts.add(spec.tag)\n const names = Object.keys(spec.props)\n\n class KuiElement extends HTMLElement {\n static observedAttributes = names\n controller?: Controller\n #props?: Signal<Props> | undefined\n // Set as properties before the element was upgraded, or before it joined the page.\n #given: Record<string, unknown> = {}\n #held = new Map<HTMLElement, Held>()\n #stops: (() => void)[] = []\n #leaving = false\n // While the parts the page wrote are first taken: they were drawn before they were parts.\n #first = false\n #watch: (element: HTMLElement) => void = () => {}\n\n connectedCallback() {\n this.#leaving = false\n this.begin()\n }\n\n /** Begins, unless a component around it has not: then it waits for that one. */\n begin() {\n if (this.controller || !this.isConnected) return\n if (early(this)) return void waiting.add(this)\n waiting.delete(this)\n // It holds its parts and draws nothing: no box of its own between them and the page.\n if (!this.style.display) this.style.display = \"contents\"\n const initial: Record<string, unknown> = {\n id: this.getAttribute(\"kui-id\") || `kui-${++made}`,\n }\n for (const name of names) {\n const text = this.getAttribute(name)\n // An attribute that is not there says nothing: the component's own default holds.\n if (text !== null) initial[camel(name)] = read(spec.props[name]!, text)\n }\n Object.assign(initial, this.#given)\n for (const [callback, { event, prop, hold }] of Object.entries(spec.changes)) {\n initial[callback] = (value: unknown, details?: ChangeDetails) => {\n const told = new CustomEvent(event, {\n detail: { [prop]: value, details },\n bubbles: true,\n cancelable: true,\n })\n if (!this.dispatchEvent(told)) return details?.cancel()\n // A value that was given is held by the element from then on, as `<details open>`\n // holds its own: it follows what happens to it.\n if (hold !== false && this.given(prop) !== undefined) this.give(prop, value)\n }\n }\n this.#props = signal(initial as Props, sameProps as (a: Props, b: Props) => boolean)\n this.controller = spec.create(this.#props, this)\n const unmount = (this.controller as { mount?(): () => void }).mount?.()\n if (unmount) this.#stops.push(unmount)\n // Parts that come and go: a page that draws its rows later, a list that changes.\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of record.removedNodes) {\n if (drawable(node)) this.#release(node)\n }\n for (const node of record.addedNodes) if (drawable(node)) this.#scan(node)\n }\n })\n observer.observe(this, { childList: true, subtree: true })\n this.#watch = (element) => observer.observe(element, { childList: true, subtree: true })\n this.#stops.push(() => observer.disconnect())\n // A copy: a part that is not in the page yet is taken out as it is met.\n this.#first = true\n for (const each of Array.from(this.children)) if (drawable(each)) this.#scan(each)\n this.#first = false\n const inner = spec.inner?.(this.controller)\n if (inner) {\n const input = this.ownerDocument.createElement(\"input\")\n let unbind: (() => void) | undefined\n const drawn = effect(() => {\n const wanted = inner.mounted?.get() ?? true\n if (wanted && !unbind) {\n this.append(input)\n unbind = bind(input, inner.part)\n } else if (!wanted && unbind) {\n unbind()\n unbind = undefined\n input.remove()\n }\n })\n this.#stops.push(() => {\n drawn()\n unbind?.()\n input.remove()\n })\n }\n for (const each of Array.from(waiting)) each.begin()\n }\n\n disconnectedCallback() {\n // Moved, it comes straight back: only an element that has left is taken apart.\n this.#leaving = true\n queueMicrotask(() => {\n if (!this.#leaving || this.isConnected) return\n waiting.delete(this)\n for (const held of this.#held.values()) held.stop()\n this.#held.clear()\n for (const stop of this.#stops.splice(0).reverse()) stop()\n delete this.controller\n this.#props = undefined\n })\n }\n\n attributeChangedCallback(name: string, _before: string | null, text: string | null) {\n this.give(camel(name), read(spec.props[name]!, text))\n }\n\n /** A prop as it was last given: by an attribute, or as a property. */\n given(prop: string): unknown {\n return this.#props ? (this.#props.peek() as Record<string, unknown>)[prop] : this.#given[prop]\n }\n\n give(prop: string, value: unknown) {\n if (!this.#props) return void (this.#given[prop] = value)\n if (!Object.is((this.#props.peek() as Record<string, unknown>)[prop], value))\n this.#props.set({ ...this.#props.peek(), [prop]: value })\n }\n\n /** Takes the parts in a subtree, in the page's order: one that leaves takes its own with it. */\n #scan(element: HTMLElement) {\n if (!element.isConnected) return\n if (element instanceof HTMLTemplateElement) {\n if (element.hasAttribute(\"kui-each\") && ownerOf(element) === this) this.#each(element)\n return\n }\n if (element.hasAttribute(\"kui-part\")) this.#adopt(element)\n for (const each of Array.from(element.children)) if (drawable(each)) this.#scan(each)\n }\n\n /** Draws a list from its template: a copy for each entry, where the template was. */\n #each(template: HTMLTemplateElement) {\n const list = spec.lists?.[template.getAttribute(\"kui-each\")!]?.(\n this.controller!,\n entryAround(template)\n )\n if (!list) return\n // The template leaves the page for a mark: what is drawn is the page a framework draws.\n const mark = this.ownerDocument.createComment(\"\")\n if (ENTRY.has(template)) ENTRY.set(mark, ENTRY.get(template))\n template.replaceWith(mark)\n const rows = new Map<string | number, Row>()\n const stamp = (entry: unknown): Row => {\n const type = list.type?.(entry)\n const copy = template.content.cloneNode(true) as DocumentFragment\n for (const node of Array.from(copy.childNodes)) {\n const blank = node.nodeType === Node.TEXT_NODE && !node.textContent!.trim()\n const other =\n node instanceof Element &&\n node.hasAttribute(\"kui-when\") &&\n node.getAttribute(\"kui-when\") !== type\n if (blank || other || node.nodeType === Node.COMMENT_NODE) node.remove()\n }\n const written: (readonly [Attr | Text, string])[] = []\n const walker = this.ownerDocument.createTreeWalker(\n copy,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT\n )\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n // A list written in this one is filled when it is drawn, for its own entries.\n if (node instanceof Text) {\n if (node.data.includes(\"{\")) written.push([node, node.data])\n } else if (!(node instanceof HTMLTemplateElement)) {\n for (const attribute of Array.from((node as Element).attributes))\n if (attribute.value.includes(\"{\")) written.push([attribute, attribute.value])\n }\n }\n const nodes = Array.from(copy.childNodes)\n for (const node of nodes) ENTRY.set(node, entry)\n return { entry, nodes, written }\n }\n const write = (row: Row) => {\n const values =\n list.values?.(row.entry) ?? (row.entry as Record<string, unknown> | undefined) ?? {}\n for (const [node, text] of row.written) {\n const next = fill(text, values)\n if (node instanceof Text) {\n if (node.data !== next) node.data = next\n } else if (node.value !== next) node.value = next\n }\n }\n const draw = () => {\n const { entries } = list\n const next = \"get\" in entries ? entries.get() : entries\n const parent = mark.parentNode\n if (!parent) return\n const kept = new Set<string | number>()\n const fresh: Row[] = []\n const ordered = next.map((entry) => {\n const key = list.key(entry)\n kept.add(key)\n let row = rows.get(key)\n if (!row) {\n rows.set(key, (row = stamp(entry)))\n fresh.push(row)\n write(row)\n } else if (row.entry !== entry) {\n row.entry = entry\n for (const node of row.nodes) ENTRY.set(node, entry)\n write(row)\n }\n return row\n })\n for (const [key, row] of rows) {\n if (kept.has(key)) continue\n rows.delete(key)\n for (const node of row.nodes) node.remove()\n }\n // From the end: a copy that is where it belongs is not moved, and keeps focus.\n let before: ChildNode = mark\n for (const row of ordered.reverse()) {\n for (const node of row.nodes.toReversed()) {\n if (node.nextSibling !== before || node.parentNode !== parent)\n parent.insertBefore(node, before)\n before = node\n }\n }\n for (const row of fresh) for (const node of row.nodes) if (drawable(node)) this.#scan(node)\n }\n const stop = effect(draw)\n this.#stops.push(() => {\n stop()\n for (const row of rows.values()) for (const node of row.nodes) node.remove()\n rows.clear()\n mark.replaceWith(template)\n })\n }\n\n #adopt(element: HTMLElement) {\n if (this.#held.has(element) || ownerOf(element) !== this || !this.controller) return\n const name = element.getAttribute(\"kui-part\")!\n if (name === \"portal\") return this.#portal(element)\n const given = spec.parts[name]?.(this.controller, element)\n if (!given) return\n const drawn: Drawn = \"attach\" in given ? { part: given } : given\n const stops: (() => void)[] = []\n const held: Held = {\n parked: false,\n stop: () => {\n for (const stop of stops.splice(0).reverse()) stop()\n },\n }\n this.#held.set(element, held)\n const unmount = drawn.mount?.()\n if (unmount) stops.push(unmount)\n if (drawn.inner) {\n // One a server wrote there is taken over.\n const last = element.lastElementChild\n const taken = last instanceof HTMLInputElement && last.type === \"hidden\" ? last : undefined\n const input = taken ?? this.ownerDocument.createElement(\"input\")\n if (!taken) element.append(input)\n stops.push(bind(input, drawn.inner), () => {\n if (!taken) input.remove()\n })\n }\n if (drawn.text && element.childNodes.length === 0) {\n const { text } = drawn\n // Taken off, the element says nothing again: put back on (a popup opened a second\n // time), the text is the part's to write still, and not taken for the page's.\n stops.push(\n effect(() => void (element.textContent = text.get() ?? \"\")),\n () => void (element.textContent = \"\")\n )\n }\n const mounted = element.hasAttribute(\"kui-keep-mounted\") ? undefined : drawn.mounted\n const first = this.#first\n if (!mounted) return void stops.push(put(element, drawn.part, first))\n // In the page only while it is mounted: out of it otherwise, its place kept by a mark.\n const home = this.ownerDocument.createComment(\"\")\n let unbind: (() => void) | undefined\n stops.push(\n effect(() => {\n const elsewhere = drawn.into?.get()\n // Still where the page drew it: not moved, and never yet taken out.\n const own = first && !elsewhere && !held.parked && !unbind\n if (mounted.get() && (!drawn.into || elsewhere)) {\n if (elsewhere) {\n // Its place where it was written is kept by the mark all the while.\n if (!held.parked && element.parentNode) element.replaceWith(home)\n held.parked = true\n if (element.parentNode !== elsewhere) elsewhere.append(element)\n } else if (held.parked) {\n held.parked = false\n home.replaceWith(element)\n }\n unbind ??= put(element, drawn.part, own)\n } else {\n unbind?.()\n unbind = undefined\n if (!held.parked && element.parentNode) {\n held.parked = true\n element.replaceWith(home)\n } else if (drawn.into) element.remove()\n }\n }),\n () => {\n unbind?.()\n if (held.parked) home.replaceWith(element)\n }\n )\n }\n\n /** What is inside is drawn at the end of the page while the component is mounted. */\n #portal(element: HTMLElement) {\n const mounted = (this.controller as { mounted?: ReadonlySignal<boolean> }).mounted\n if (!mounted) return\n ;(element as Owned)[OWNER] = this\n const home = this.ownerDocument.createComment(\"\")\n const held: Held = { parked: false, stop: () => {} }\n this.#held.set(element, held)\n this.#watch(element)\n const body = this.ownerDocument.body\n const stop = effect(() => {\n if (mounted.get()) {\n if (element.parentNode === body) return\n // Its place in the page is kept by a mark, for when the component leaves.\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n held.parked = false\n element.setAttribute(\"data-kirana-portal\", \"\")\n body.append(element)\n this.#scan(element)\n } else if (!held.parked) {\n held.parked = true\n if (!home.parentNode && element.parentNode) element.replaceWith(home)\n else element.remove()\n }\n })\n held.stop = () => {\n stop()\n element.removeAttribute(\"data-kirana-portal\")\n if (home.parentNode) home.replaceWith(element)\n else element.remove()\n }\n }\n\n #release(element: HTMLElement) {\n // Moved to the page's end by its own portal, or put back: still this component's.\n if (element.isConnected) return\n for (const [each, held] of this.#held) {\n if (each !== element && !element.contains(each)) continue\n // Taken out by the component itself: it is still the component's, to be put back.\n if (each === element && held.parked) continue\n held.stop()\n this.#held.delete(each)\n }\n }\n }\n\n // Each prop as a property too: `element.open = true`, and what the element holds read back.\n for (const name of [...names, ...(spec.properties ?? [])]) {\n const prop = camel(name)\n Object.defineProperty(KuiElement.prototype, prop, {\n configurable: true,\n get(this: KuiElement) {\n const state = (this.controller as Record<string, unknown> | undefined)?.[prop] as\n | ReadonlySignal<unknown>\n | undefined\n return typeof state?.peek === \"function\" ? state.peek() : this.given(prop)\n },\n set(this: KuiElement, value: unknown) {\n this.give(prop, value)\n },\n })\n }\n customElements.define(spec.tag, KuiElement)\n return spec.tag\n}\n"],"mappings":";;AAqDA,MAAM,wBAAQ,IAAI,QAAuB;;;;;AAMzC,SAAgB,YACd,SACA,OACmB;CACnB,KAAK,IAAI,OAAoB,SAAS,MAAM,OAAO,KAAK,YACtD,IAAI,MAAM,IAAI,IAAI,MAAM,CAAC,SAAS,MAAM,MAAM,IAAI,IAAI,CAAC,IAAI,OAAO,MAAM,IAAI,IAAI;AAGpF;;AAGA,MAAM,QAAQ,MAAc,WAC1B,KAAK,QAAQ,2BAA2B,OAAO,SAC7C,QAAQ,SAAS,OAAO,OAAO,SAAS,EAAE,IAAI,KAChD;AAyGF,MAAM,SAAS,SACb,KAAK,QAAQ,cAAc,MAAM,WAAmB,OAAO,YAAY,CAAC;AAC1E,MAAM,wBAAQ,IAAI,IAAY;AAC9B,MAAM,QAAQ,OAAO,WAAW;AAChC,IAAI,OAAO;;;;;;AASX,MAAM,QAAQ,YACZ,MAAM,IAAI,QAAQ,SAAS,KAAK,QAAQ,UAAU,WAAW,MAAM;;AAG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I,KAAK,YAAY,KAAK,YAAY,OAAO;SACxC,QAAQ,OAAO;GACtB;EACF;EAEA,SAAS,SAAsB;GAE7B,IAAI,QAAQ,aAAa;GACzB,KAAK,MAAM,CAAC,MAAM,SAAS,KAAK,OAAO;IACrC,IAAI,SAAS,WAAW,CAAC,QAAQ,SAAS,IAAI,GAAG;IAEjD,IAAI,SAAS,WAAW,KAAK,QAAQ;IACrC,KAAK,KAAK;IACV,KAAK,MAAM,OAAO,IAAI;GACxB;EACF;CACF;CAGA,KAAK,MAAM,QAAQ,CAAC,GAAG,OAAO,GAAI,KAAK,cAAc,CAAC,CAAE,GAAG;EACzD,MAAM,OAAO,MAAM,IAAI;EACvB,OAAO,eAAe,WAAW,WAAW,MAAM;GAChD,cAAc;GACd,MAAsB;IACpB,MAAM,QAAS,KAAK,aAAqD;IAGzE,OAAO,OAAO,OAAO,SAAS,aAAa,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI;GAC3E;GACA,IAAsB,OAAgB;IACpC,KAAK,KAAK,MAAM,KAAK;GACvB;EACF,CAAC;CACH;CACA,eAAe,OAAO,KAAK,KAAK,UAAU;CAC1C,OAAO,KAAK;AACd"}
@@ -1,7 +1,18 @@
1
+ import { As, ElementOf, Tag } from "./runtime.js";
2
+ import { ScrollAreaProps } from "@kirana-ui/core/scroll-area";
1
3
  /**
2
4
  * `<kui-scroll-area>` around `kui-part="root"`, a `viewport` with its `content`, a `scrollbar`
3
5
  * for each way (`kui-orientation="horizontal"` for the one across) with its `thumb`, and a
4
- * `corner`. A scrollbar is in the page while there is something to scroll its way.
6
+ * `corner`. A scrollbar is in the page while there is something to scroll its way. The
7
+ * library places the scrollbars and the corner against the root; the page gives a scrollbar
8
+ * its thickness and draws it.
5
9
  */
6
- export declare const tag: string;
10
+ export declare const tag: Tag<{
11
+ id: string;
12
+ }, import("@kirana-ui/core/scroll-area").ScrollArea>;
13
+ declare global {
14
+ interface HTMLElementTagNameMap {
15
+ "kui-scroll-area": ElementOf<As<typeof tag, ScrollAreaProps>>;
16
+ }
17
+ }
7
18
  //# sourceMappingURL=scroll-area.d.ts.map
@@ -5,7 +5,9 @@ const way = (element) => element?.getAttribute("kui-orientation") === "horizonta
5
5
  /**
6
6
  * `<kui-scroll-area>` around `kui-part="root"`, a `viewport` with its `content`, a `scrollbar`
7
7
  * for each way (`kui-orientation="horizontal"` for the one across) with its `thumb`, and a
8
- * `corner`. A scrollbar is in the page while there is something to scroll its way.
8
+ * `corner`. A scrollbar is in the page while there is something to scroll its way. The
9
+ * library places the scrollbars and the corner against the root; the page gives a scrollbar
10
+ * its thickness and draws it.
9
11
  */
10
12
  const tag = defineElement({
11
13
  tag: "kui-scroll-area",
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-area.js","names":[],"sources":["../../../../packages/web/src/scroll-area.ts"],"sourcesContent":["import type { Orientation } from \"@kirana-ui/core\"\nimport { createScrollArea } from \"@kirana-ui/core/scroll-area\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\n\nconst way = (element: HTMLElement | null): Orientation =>\n element?.getAttribute(\"kui-orientation\") === \"horizontal\" ? \"horizontal\" : \"vertical\"\n\n/**\n * `<kui-scroll-area>` around `kui-part=\"root\"`, a `viewport` with its `content`, a `scrollbar`\n * for each way (`kui-orientation=\"horizontal\"` for the one across) with its `thumb`, and a\n * `corner`. A scrollbar is in the page while there is something to scroll its way.\n */\nexport const tag = defineElement({\n tag: \"kui-scroll-area\",\n props: {},\n create: (props) => createScrollArea(props as never),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n viewport: (controller) => controller.viewport,\n content: (controller) => controller.content,\n scrollbar(controller, element) {\n const bar = controller.scrollbar(way(element))\n return { part: bar.part, mounted: bar.shown }\n },\n thumb: (controller, element) =>\n controller.scrollbar(way(partAround(element, \"scrollbar\"))).thumb,\n corner: (controller) => ({ part: controller.corner.part, mounted: controller.corner.shown }),\n },\n})\n"],"mappings":";;;AAKA,MAAM,OAAO,YACX,SAAS,aAAa,iBAAiB,MAAM,eAAe,eAAe;;;;;;AAO7E,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO,CAAC;CACR,SAAS,UAAU,iBAAiB,KAAc;CAClD,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,UAAU,eAAe,WAAW;EACpC,UAAU,YAAY,SAAS;GAC7B,MAAM,MAAM,WAAW,UAAU,IAAI,OAAO,CAAC;GAC7C,OAAO;IAAE,MAAM,IAAI;IAAM,SAAS,IAAI;GAAM;EAC9C;EACA,QAAQ,YAAY,YAClB,WAAW,UAAU,IAAI,WAAW,SAAS,WAAW,CAAC,CAAC,CAAC,CAAC;EAC9D,SAAS,gBAAgB;GAAE,MAAM,WAAW,OAAO;GAAM,SAAS,WAAW,OAAO;EAAM;CAC5F;AACF,CAAC"}
1
+ {"version":3,"file":"scroll-area.js","names":[],"sources":["../../../../packages/web/src/scroll-area.ts"],"sourcesContent":["import type { Orientation } from \"@kirana-ui/core\"\nimport { createScrollArea } from \"@kirana-ui/core/scroll-area\"\nimport type { ScrollAreaProps } from \"@kirana-ui/core/scroll-area\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\nconst way = (element: HTMLElement | null): Orientation =>\n element?.getAttribute(\"kui-orientation\") === \"horizontal\" ? \"horizontal\" : \"vertical\"\n\n/**\n * `<kui-scroll-area>` around `kui-part=\"root\"`, a `viewport` with its `content`, a `scrollbar`\n * for each way (`kui-orientation=\"horizontal\"` for the one across) with its `thumb`, and a\n * `corner`. A scrollbar is in the page while there is something to scroll its way. The\n * library places the scrollbars and the corner against the root; the page gives a scrollbar\n * its thickness and draws it.\n */\nexport const tag = defineElement({\n tag: \"kui-scroll-area\",\n props: {},\n create: (props) => createScrollArea(props as never),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n viewport: (controller) => controller.viewport,\n content: (controller) => controller.content,\n scrollbar(controller, element) {\n const bar = controller.scrollbar(way(element))\n return { part: bar.part, mounted: bar.shown }\n },\n thumb: (controller, element) =>\n controller.scrollbar(way(partAround(element, \"scrollbar\"))).thumb,\n corner: (controller) => ({ part: controller.corner.part, mounted: controller.corner.shown }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-scroll-area\": ElementOf<As<typeof tag, ScrollAreaProps>>\n }\n}\n"],"mappings":";;;AAOA,MAAM,OAAO,YACX,SAAS,aAAa,iBAAiB,MAAM,eAAe,eAAe;;;;;;;;AAS7E,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO,CAAC;CACR,SAAS,UAAU,iBAAiB,KAAc;CAClD,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,UAAU,eAAe,WAAW;EACpC,UAAU,YAAY,SAAS;GAC7B,MAAM,MAAM,WAAW,UAAU,IAAI,OAAO,CAAC;GAC7C,OAAO;IAAE,MAAM,IAAI;IAAM,SAAS,IAAI;GAAM;EAC9C;EACA,QAAQ,YAAY,YAClB,WAAW,UAAU,IAAI,WAAW,SAAS,WAAW,CAAC,CAAC,CAAC,CAAC;EAC9D,SAAS,gBAAgB;GAAE,MAAM,WAAW,OAAO;GAAM,SAAS,WAAW,OAAO;EAAM;CAC5F;AACF,CAAC"}
package/src/select.d.ts CHANGED
@@ -1,13 +1,34 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { Placed } from "./around.js";
3
+ import { Select, SelectProps } from "@kirana-ui/core/select";
4
+ type Props = Omit<SelectProps<string>, "values" | "defaultValues"> & {
5
+ values?: string | readonly string[];
6
+ defaultValues?: string | readonly string[];
7
+ };
1
8
  /**
2
9
  * `<kui-select>` around a `kui-part="trigger"` button holding a `value` (it says the chosen
3
- * item's text, or its `kui-placeholder`), and a `portal` with a `positioner` (its `kui-side`
10
+ * item's text, or its `kui-placeholder`; with `multiple`, the chosen items' texts with commas
11
+ * between), and a `portal` with a `positioner` (its `kui-side`
4
12
  * and the like, and `kui-align-item-with-trigger`) around the `popup`. The popup holds an
5
13
  * `item` for each `kui-value` (`kui-disabled`, `kui-label`), each with an `item-text` and an
6
14
  * `item-indicator`; items may be in a `group` with a `group-label`, with `separator`s
7
15
  * between, and in a `list` between a `scroll-up-arrow` and a `scroll-down-arrow`. With a name
8
- * it draws the hidden input a form reads. `value`, `default-value`, `open`, `default-open`,
9
- * `disabled`, `required`, `name`, `form`; `items` as a property; it tells `value-change` and
10
- * `open-change`.
16
+ * it draws the hidden input a form reads. A `value` part that holds something says what the
17
+ * page wrote there: a `<template kui-each="values">` in it is drawn for each chosen value
18
+ * (`{value}`, `{label}`), in the items' order. `value`, `default-value`, `open`,
19
+ * `default-open`, `disabled`, `read-only`, `required`, `multiple`, `values` and `default-values` (with
20
+ * commas between), `name`, `form`; `items` as a property; it tells `value-change`,
21
+ * `values-change` and `open-change`.
11
22
  */
12
- export declare const tag: string;
23
+ export declare const tag: Tag<Props, Select<string>>;
24
+ declare global {
25
+ interface HTMLElementTagNameMap {
26
+ "kui-select": ElementOf<typeof tag, {
27
+ "value-change": ["onValueChange", "value"];
28
+ "values-change": ["onValuesChange", "values"];
29
+ "open-change": ["onOpenChange", "open"];
30
+ }> & Placed;
31
+ }
32
+ }
33
+ export {};
13
34
  //# sourceMappingURL=select.d.ts.map
package/src/select.js CHANGED
@@ -1,4 +1,4 @@
1
- import { MARK, fieldAround, itemOptions, once, place, valueOf } from "./around.js";
1
+ import { MARK, fieldAround, itemOptions, list, once, positioner, valueOf } from "./around.js";
2
2
  import { defineElement, partAround } from "./runtime.js";
3
3
  import { computed } from "@kirana-ui/core";
4
4
  import { createSelect } from "@kirana-ui/core/select";
@@ -12,14 +12,18 @@ const arrow = (drawn) => ({
12
12
  });
13
13
  /**
14
14
  * `<kui-select>` around a `kui-part="trigger"` button holding a `value` (it says the chosen
15
- * item's text, or its `kui-placeholder`), and a `portal` with a `positioner` (its `kui-side`
15
+ * item's text, or its `kui-placeholder`; with `multiple`, the chosen items' texts with commas
16
+ * between), and a `portal` with a `positioner` (its `kui-side`
16
17
  * and the like, and `kui-align-item-with-trigger`) around the `popup`. The popup holds an
17
18
  * `item` for each `kui-value` (`kui-disabled`, `kui-label`), each with an `item-text` and an
18
19
  * `item-indicator`; items may be in a `group` with a `group-label`, with `separator`s
19
20
  * between, and in a `list` between a `scroll-up-arrow` and a `scroll-down-arrow`. With a name
20
- * it draws the hidden input a form reads. `value`, `default-value`, `open`, `default-open`,
21
- * `disabled`, `required`, `name`, `form`; `items` as a property; it tells `value-change` and
22
- * `open-change`.
21
+ * it draws the hidden input a form reads. A `value` part that holds something says what the
22
+ * page wrote there: a `<template kui-each="values">` in it is drawn for each chosen value
23
+ * (`{value}`, `{label}`), in the items' order. `value`, `default-value`, `open`,
24
+ * `default-open`, `disabled`, `read-only`, `required`, `multiple`, `values` and `default-values` (with
25
+ * commas between), `name`, `form`; `items` as a property; it tells `value-change`,
26
+ * `values-change` and `open-change`.
23
27
  */
24
28
  const tag = defineElement({
25
29
  tag: "kui-select",
@@ -29,12 +33,33 @@ const tag = defineElement({
29
33
  open: "boolean",
30
34
  "default-open": "boolean",
31
35
  disabled: "boolean",
36
+ "read-only": "boolean",
32
37
  required: "boolean",
38
+ multiple: "boolean",
39
+ values: "string",
40
+ "default-values": "string",
33
41
  name: "string",
34
42
  form: "string"
35
43
  },
36
44
  properties: ["items"],
37
- create: (props, host) => createSelect(props, { field: fieldAround(host) }),
45
+ create: (props, host) => createSelect(computed(() => {
46
+ const own = props.get();
47
+ return {
48
+ ...own,
49
+ values: list(own.values),
50
+ defaultValues: list(own.defaultValues)
51
+ };
52
+ }), { field: fieldAround(host) }),
53
+ lists: { values: (controller) => ({
54
+ entries: computed(() => {
55
+ const { values, labels } = controller.shown.get();
56
+ return values.map((value, at) => ({
57
+ value,
58
+ label: labels[at] ?? value
59
+ }));
60
+ }),
61
+ key: (chosen) => chosen.value
62
+ }) },
38
63
  inner: (controller) => ({
39
64
  part: controller.input,
40
65
  mounted: controller.named
@@ -44,6 +69,10 @@ const tag = defineElement({
44
69
  event: "value-change",
45
70
  prop: "value"
46
71
  },
72
+ onValuesChange: {
73
+ event: "values-change",
74
+ prop: "values"
75
+ },
47
76
  onOpenChange: {
48
77
  event: "open-change",
49
78
  prop: "open"
@@ -57,11 +86,7 @@ const tag = defineElement({
57
86
  }),
58
87
  positioner(controller, element) {
59
88
  controller.alignItemWithTrigger.set(element.hasAttribute("kui-align-item-with-trigger"));
60
- place(controller.positioning, element);
61
- return {
62
- mounted: controller.mounted,
63
- part: controller.positioner
64
- };
89
+ return positioner(controller, element);
65
90
  },
66
91
  popup: (controller) => controller.popup,
67
92
  list: (controller) => controller.list,
package/src/select.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","names":[],"sources":["../../../../packages/web/src/select.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createSelect } from \"@kirana-ui/core/select\"\nimport type { Select, SelectGroup, SelectProps, SelectScrollArrow } from \"@kirana-ui/core/select\"\n\nimport { fieldAround, itemOptions, MARK, once, place, valueOf } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { Drawn } from \"./runtime.ts\"\n\nconst groups = new WeakMap<HTMLElement, SelectGroup>()\nlet made = 0\n\nconst arrow = (drawn: SelectScrollArrow): Drawn => ({\n part: drawn.part,\n mounted: drawn.mounted,\n mount: () => drawn.mount(),\n})\n\n/**\n * `<kui-select>` around a `kui-part=\"trigger\"` button holding a `value` (it says the chosen\n * item's text, or its `kui-placeholder`), and a `portal` with a `positioner` (its `kui-side`\n * and the like, and `kui-align-item-with-trigger`) around the `popup`. The popup holds an\n * `item` for each `kui-value` (`kui-disabled`, `kui-label`), each with an `item-text` and an\n * `item-indicator`; items may be in a `group` with a `group-label`, with `separator`s\n * between, and in a `list` between a `scroll-up-arrow` and a `scroll-down-arrow`. With a name\n * it draws the hidden input a form reads. `value`, `default-value`, `open`, `default-open`,\n * `disabled`, `required`, `name`, `form`; `items` as a property; it tells `value-change` and\n * `open-change`.\n */\nexport const tag = defineElement<SelectProps<string>, Select<string>>({\n tag: \"kui-select\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n open: \"boolean\",\n \"default-open\": \"boolean\",\n disabled: \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"items\"],\n create: (props, host) => createSelect<string>(props, { field: fieldAround(host) }),\n inner: (controller) => ({ part: controller.input, mounted: controller.named }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onOpenChange: { event: \"open-change\", prop: \"open\" },\n },\n parts: {\n trigger: (controller) => controller.trigger,\n value: (controller, element) => ({\n part: controller.valuePart,\n text: computed(\n () => controller.label.get() ?? element.getAttribute(\"kui-placeholder\") ?? undefined\n ),\n }),\n positioner(controller, element) {\n controller.alignItemWithTrigger.set(element.hasAttribute(\"kui-align-item-with-trigger\"))\n place(controller.positioning, element)\n return { mounted: controller.mounted, part: controller.positioner }\n },\n popup: (controller) => controller.popup,\n list: (controller) => controller.list,\n \"scroll-up-arrow\": (controller) => arrow(controller.scrollArrow(\"up\")),\n \"scroll-down-arrow\": (controller) => arrow(controller.scrollArrow(\"down\")),\n group: (controller, element) =>\n once(groups, element, (group) =>\n controller.group(group.getAttribute(\"kui-id\") ?? `kui-select-group-${++made}`)\n )?.root,\n // Outside a group it is plain text, and names nothing.\n \"group-label\": (controller, element) =>\n groups.get(partAround(element, \"group\")!)?.label ?? controller.groupLabel,\n separator: (controller) => controller.separator,\n item: (controller, element) => controller.item(valueOf(element), itemOptions(element)),\n \"item-text\": (controller, element) => controller.itemText(valueOf(partAround(element, \"item\"))),\n \"item-indicator\": (controller, element) => ({\n part: MARK,\n mounted: controller.selected(valueOf(partAround(element, \"item\"))),\n }),\n },\n})\n"],"mappings":";;;;;AAQA,MAAM,yBAAS,IAAI,QAAkC;AACrD,IAAI,OAAO;AAEX,MAAM,SAAS,WAAqC;CAClD,MAAM,MAAM;CACZ,SAAS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,GAAG,YAAY,OAAO,CAAC;EACrF,cAAc,YAAY,YAAY,WAAW,SAAS,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC;EAC9F,mBAAmB,YAAY,aAAa;GAC1C,MAAM;GACN,SAAS,WAAW,SAAS,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC;EACnE;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"select.js","names":[],"sources":["../../../../packages/web/src/select.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createSelect } from \"@kirana-ui/core/select\"\nimport type { Select, SelectGroup, SelectProps, SelectScrollArrow } from \"@kirana-ui/core/select\"\n\nimport { fieldAround, itemOptions, list, MARK, once, positioner, valueOf } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { Drawn, Each, ElementOf } from \"./runtime.ts\"\n\ntype Props = Omit<SelectProps<string>, \"values\" | \"defaultValues\"> & {\n values?: string | readonly string[]\n defaultValues?: string | readonly string[]\n}\n\nconst groups = new WeakMap<HTMLElement, SelectGroup>()\nlet made = 0\n\nconst arrow = (drawn: SelectScrollArrow): Drawn => ({\n part: drawn.part,\n mounted: drawn.mounted,\n mount: () => drawn.mount(),\n})\n\n/**\n * `<kui-select>` around a `kui-part=\"trigger\"` button holding a `value` (it says the chosen\n * item's text, or its `kui-placeholder`; with `multiple`, the chosen items' texts with commas\n * between), and a `portal` with a `positioner` (its `kui-side`\n * and the like, and `kui-align-item-with-trigger`) around the `popup`. The popup holds an\n * `item` for each `kui-value` (`kui-disabled`, `kui-label`), each with an `item-text` and an\n * `item-indicator`; items may be in a `group` with a `group-label`, with `separator`s\n * between, and in a `list` between a `scroll-up-arrow` and a `scroll-down-arrow`. With a name\n * it draws the hidden input a form reads. A `value` part that holds something says what the\n * page wrote there: a `<template kui-each=\"values\">` in it is drawn for each chosen value\n * (`{value}`, `{label}`), in the items' order. `value`, `default-value`, `open`,\n * `default-open`, `disabled`, `read-only`, `required`, `multiple`, `values` and `default-values` (with\n * commas between), `name`, `form`; `items` as a property; it tells `value-change`,\n * `values-change` and `open-change`.\n */\nexport const tag = defineElement<Props, Select<string>>({\n tag: \"kui-select\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n open: \"boolean\",\n \"default-open\": \"boolean\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n multiple: \"boolean\",\n values: \"string\",\n \"default-values\": \"string\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"items\"],\n create: (props, host) =>\n createSelect<string>(\n computed(() => {\n const own = props.get()\n return { ...own, values: list(own.values), defaultValues: list(own.defaultValues) }\n }),\n { field: fieldAround(host) }\n ),\n lists: {\n values: (controller): Each<{ value: string; label: string }> => ({\n entries: computed(() => {\n const { values, labels } = controller.shown.get()\n return values.map((value, at) => ({ value, label: labels[at] ?? value }))\n }),\n key: (chosen) => chosen.value,\n }),\n },\n inner: (controller) => ({ part: controller.input, mounted: controller.named }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValuesChange: { event: \"values-change\", prop: \"values\" },\n onOpenChange: { event: \"open-change\", prop: \"open\" },\n },\n parts: {\n trigger: (controller) => controller.trigger,\n value: (controller, element) => ({\n part: controller.valuePart,\n text: computed(\n () => controller.label.get() ?? element.getAttribute(\"kui-placeholder\") ?? undefined\n ),\n }),\n positioner(controller, element) {\n controller.alignItemWithTrigger.set(element.hasAttribute(\"kui-align-item-with-trigger\"))\n return positioner(controller, element)\n },\n popup: (controller) => controller.popup,\n list: (controller) => controller.list,\n \"scroll-up-arrow\": (controller) => arrow(controller.scrollArrow(\"up\")),\n \"scroll-down-arrow\": (controller) => arrow(controller.scrollArrow(\"down\")),\n group: (controller, element) =>\n once(groups, element, (group) =>\n controller.group(group.getAttribute(\"kui-id\") ?? `kui-select-group-${++made}`)\n )?.root,\n // Outside a group it is plain text, and names nothing.\n \"group-label\": (controller, element) =>\n groups.get(partAround(element, \"group\")!)?.label ?? controller.groupLabel,\n separator: (controller) => controller.separator,\n item: (controller, element) => controller.item(valueOf(element), itemOptions(element)),\n \"item-text\": (controller, element) => controller.itemText(valueOf(partAround(element, \"item\"))),\n \"item-indicator\": (controller, element) => ({\n part: MARK,\n mounted: controller.selected(valueOf(partAround(element, \"item\"))),\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-select\": ElementOf<\n typeof tag,\n {\n \"value-change\": [\"onValueChange\", \"value\"]\n \"values-change\": [\"onValuesChange\", \"values\"]\n \"open-change\": [\"onOpenChange\", \"open\"]\n }\n > &\n Placed\n }\n}\n"],"mappings":";;;;;AAcA,MAAM,yBAAS,IAAI,QAAkC;AACrD,IAAI,OAAO;AAEX,MAAM,SAAS,WAAqC;CAClD,MAAM,MAAM;CACZ,SAAS,MAAM;CACf,aAAa,MAAM,MAAM;AAC3B;;;;;;;;;;;;;;;;AAiBA,MAAa,MAAM,cAAqC;CACtD,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,UAAU;EACV,aAAa;EACb,UAAU;EACV,UAAU;EACV,QAAQ;EACR,kBAAkB;EAClB,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,OAAO;CACpB,SAAS,OAAO,SACd,aACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,QAAQ,KAAK,IAAI,MAAM;GAAG,eAAe,KAAK,IAAI,aAAa;EAAE;CACpF,CAAC,GACD,EAAE,OAAO,YAAY,IAAI,EAAE,CAC7B;CACF,OAAO,EACL,SAAS,gBAAwD;EAC/D,SAAS,eAAe;GACtB,MAAM,EAAE,QAAQ,WAAW,WAAW,MAAM,IAAI;GAChD,OAAO,OAAO,KAAK,OAAO,QAAQ;IAAE;IAAO,OAAO,OAAO,OAAO;GAAM,EAAE;EAC1E,CAAC;EACD,MAAM,WAAW,OAAO;CAC1B,GACF;CACA,QAAQ,gBAAgB;EAAE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ator>` around `kui-part="root"`. `orientation`. */
2
- export declare const tag: string;
4
+ export declare const tag: Tag<{
5
+ id: string;
6
+ }, import("@kirana-ui/core/separator").Separator>;
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "kui-separator": ElementOf<As<typeof tag, SeparatorProps>>;
10
+ }
11
+ }
3
12
  //# sourceMappingURL=separator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"separator.js","names":[],"sources":["../../../../packages/web/src/separator.ts"],"sourcesContent":["import { createSeparator } from \"@kirana-ui/core/separator\"\n\nimport { defineElement } from \"./runtime.ts\"\n\n/** `<kui-separator>` around `kui-part=\"root\"`. `orientation`. */\nexport const tag = defineElement({\n tag: \"kui-separator\",\n props: { orientation: \"string\" },\n create: (props) => createSeparator(props as never),\n changes: {},\n parts: { root: (controller) => controller.root },\n})\n"],"mappings":";;;;AAKA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO,EAAE,aAAa,SAAS;CAC/B,SAAS,UAAU,gBAAgB,KAAc;CACjD,SAAS,CAAC;CACV,OAAO,EAAE,OAAO,eAAe,WAAW,KAAK;AACjD,CAAC"}
1
+ {"version":3,"file":"separator.js","names":[],"sources":["../../../../packages/web/src/separator.ts"],"sourcesContent":["import { createSeparator } from \"@kirana-ui/core/separator\"\nimport type { SeparatorProps } from \"@kirana-ui/core/separator\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/** `<kui-separator>` around `kui-part=\"root\"`. `orientation`. */\nexport const tag = defineElement({\n tag: \"kui-separator\",\n props: { orientation: \"string\" },\n create: (props) => createSeparator(props as never),\n changes: {},\n parts: { root: (controller) => controller.root },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-separator\": ElementOf<As<typeof tag, SeparatorProps>>\n }\n}\n"],"mappings":";;;;AAOA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO,EAAE,aAAa,SAAS;CAC/B,SAAS,UAAU,gBAAgB,KAAc;CACjD,SAAS,CAAC;CACV,OAAO,EAAE,OAAO,eAAe,WAAW,KAAK;AACjD,CAAC"}
package/src/slider.d.ts CHANGED
@@ -1,10 +1,25 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { Slider, SliderProps } from "@kirana-ui/core/slider";
3
+ type Props = Omit<SliderProps, "value" | "defaultValue"> & {
4
+ value?: string | number | number[];
5
+ defaultValue?: string | number | number[];
6
+ };
1
7
  /**
2
8
  * `<kui-slider>` around `kui-part="root"`, a `value` (which says the value as it is written),
3
- * a `control` with its `track`, `indicator` and a `thumb` for each value (`kui-index` for the
4
- * second of a range). A thumb draws the hidden input a form reads. `value` and
9
+ * a `control` with its `track`, `indicator` and a `thumb` for each value, in the values'
10
+ * order (or each with its `kui-index`). A thumb draws the hidden input a form reads. `value` and
5
11
  * `default-value` (a range with a comma), `min`, `max`, `step`, `large-step`,
6
- * `min-steps-between-values`, `thumb-alignment`, `orientation`, `disabled`, `name`, `form`,
7
- * `locale`; it tells `value-change` and `value-committed`.
12
+ * `min-steps-between-values`, `thumb-alignment`, `orientation`, `disabled`, `read-only`,
13
+ * `name`, `form`, `locale`; it tells `value-change` and `value-committed`.
8
14
  */
9
- export declare const tag: string;
15
+ export declare const tag: Tag<Props, Slider>;
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ "kui-slider": ElementOf<typeof tag, {
19
+ "value-change": ["onValueChange", "value"];
20
+ "value-committed": ["onValueCommitted", "value"];
21
+ }>;
22
+ }
23
+ }
24
+ export {};
10
25
  //# sourceMappingURL=slider.d.ts.map
package/src/slider.js CHANGED
@@ -1,18 +1,18 @@
1
- import { fieldAround } from "./around.js";
1
+ import { fieldAround, ownValue } from "./around.js";
2
2
  import { defineElement } from "./runtime.js";
3
3
  import { computed } from "@kirana-ui/core";
4
4
  import { createSlider } from "@kirana-ui/core/slider";
5
5
  // src/slider.ts
6
6
  /** A value as an attribute writes it: `"40"`, or for a range `"20,80"`. */
7
7
  const read = (given) => typeof given === "string" ? given.includes(",") ? given.split(",").map(Number) : Number(given) : given;
8
- const indexOf = (element) => Number(element.getAttribute("kui-index") ?? 0);
8
+ const at = (element) => element.hasAttribute("kui-index") ? Number(element.getAttribute("kui-index")) : ownValue(element);
9
9
  /**
10
10
  * `<kui-slider>` around `kui-part="root"`, a `value` (which says the value as it is written),
11
- * a `control` with its `track`, `indicator` and a `thumb` for each value (`kui-index` for the
12
- * second of a range). A thumb draws the hidden input a form reads. `value` and
11
+ * a `control` with its `track`, `indicator` and a `thumb` for each value, in the values'
12
+ * order (or each with its `kui-index`). A thumb draws the hidden input a form reads. `value` and
13
13
  * `default-value` (a range with a comma), `min`, `max`, `step`, `large-step`,
14
- * `min-steps-between-values`, `thumb-alignment`, `orientation`, `disabled`, `name`, `form`,
15
- * `locale`; it tells `value-change` and `value-committed`.
14
+ * `min-steps-between-values`, `thumb-alignment`, `orientation`, `disabled`, `read-only`,
15
+ * `name`, `form`, `locale`; it tells `value-change` and `value-committed`.
16
16
  */
17
17
  const tag = defineElement({
18
18
  tag: "kui-slider",
@@ -27,6 +27,7 @@ const tag = defineElement({
27
27
  "thumb-alignment": "string",
28
28
  orientation: "string",
29
29
  disabled: "boolean",
30
+ "read-only": "boolean",
30
31
  name: "string",
31
32
  form: "string",
32
33
  locale: "string"
@@ -61,8 +62,8 @@ const tag = defineElement({
61
62
  track: (controller) => controller.track,
62
63
  indicator: (controller) => controller.indicator,
63
64
  thumb: (controller, element) => ({
64
- part: controller.thumb(indexOf(element)),
65
- inner: controller.thumbInput(indexOf(element))
65
+ part: controller.thumb(at(element)),
66
+ inner: controller.thumbInput(at(element))
66
67
  })
67
68
  }
68
69
  });