@kirana-ui/web 0.3.0 → 0.4.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 (104) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/llms.txt +1378 -97
  3. package/package.json +44 -3
  4. package/skills/kirana-ui-primitives/SKILL.md +24 -4
  5. package/src/accordion.d.ts +1 -1
  6. package/src/accordion.js +2 -1
  7. package/src/accordion.js.map +1 -1
  8. package/src/alert-dialog.js +3 -2
  9. package/src/alert-dialog.js.map +1 -1
  10. package/src/around.d.ts +7 -0
  11. package/src/around.js +13 -2
  12. package/src/around.js.map +1 -1
  13. package/src/autocomplete.d.ts +1 -1
  14. package/src/avatar.js +2 -2
  15. package/src/avatar.js.map +1 -1
  16. package/src/button.d.ts +2 -1
  17. package/src/button.js +2 -1
  18. package/src/button.js.map +1 -1
  19. package/src/calendar.d.ts +1 -1
  20. package/src/calendar.js +2 -1
  21. package/src/calendar.js.map +1 -1
  22. package/src/carousel.d.ts +1 -1
  23. package/src/carousel.js +4 -2
  24. package/src/carousel.js.map +1 -1
  25. package/src/color-picker.d.ts +28 -0
  26. package/src/color-picker.js +81 -0
  27. package/src/color-picker.js.map +1 -0
  28. package/src/combobox.d.ts +11 -4
  29. package/src/combobox.js +37 -12
  30. package/src/combobox.js.map +1 -1
  31. package/src/command.d.ts +2 -2
  32. package/src/command.js +4 -4
  33. package/src/command.js.map +1 -1
  34. package/src/date-field.d.ts +2 -2
  35. package/src/date-field.js +3 -3
  36. package/src/date-field.js.map +1 -1
  37. package/src/date-picker.d.ts +7 -4
  38. package/src/date-picker.js +37 -7
  39. package/src/date-picker.js.map +1 -1
  40. package/src/dates.d.ts +6 -3
  41. package/src/dates.js +8 -5
  42. package/src/dates.js.map +1 -1
  43. package/src/dialog.d.ts +3 -2
  44. package/src/dialog.js +8 -4
  45. package/src/dialog.js.map +1 -1
  46. package/src/drawer.d.ts +2 -1
  47. package/src/drawer.js +7 -3
  48. package/src/drawer.js.map +1 -1
  49. package/src/editable.d.ts +21 -0
  50. package/src/editable.js +56 -0
  51. package/src/editable.js.map +1 -0
  52. package/src/file-upload.d.ts +23 -0
  53. package/src/file-upload.js +98 -0
  54. package/src/file-upload.js.map +1 -0
  55. package/src/index.d.ts +27 -9
  56. package/src/index.js +10 -0
  57. package/src/menu.d.ts +2 -2
  58. package/src/menu.js +19 -10
  59. package/src/menu.js.map +1 -1
  60. package/src/menubar.d.ts +2 -2
  61. package/src/menubar.js +5 -3
  62. package/src/menubar.js.map +1 -1
  63. package/src/navigation-menu.d.ts +2 -2
  64. package/src/navigation-menu.js +10 -6
  65. package/src/navigation-menu.js.map +1 -1
  66. package/src/otp.d.ts +4 -2
  67. package/src/otp.js +23 -4
  68. package/src/otp.js.map +1 -1
  69. package/src/password-input.d.ts +20 -0
  70. package/src/password-input.js +39 -0
  71. package/src/password-input.js.map +1 -0
  72. package/src/rating.d.ts +18 -0
  73. package/src/rating.js +54 -0
  74. package/src/rating.js.map +1 -0
  75. package/src/runtime.d.ts +2 -2
  76. package/src/runtime.js +1 -1
  77. package/src/runtime.js.map +1 -1
  78. package/src/select.d.ts +10 -3
  79. package/src/select.js +32 -10
  80. package/src/select.js.map +1 -1
  81. package/src/steps.d.ts +17 -0
  82. package/src/steps.js +47 -0
  83. package/src/steps.js.map +1 -0
  84. package/src/tags-input.d.ts +35 -0
  85. package/src/tags-input.js +96 -0
  86. package/src/tags-input.js.map +1 -0
  87. package/src/time-field.d.ts +18 -0
  88. package/src/time-field.js +54 -0
  89. package/src/time-field.js.map +1 -0
  90. package/src/toast.d.ts +4 -3
  91. package/src/toast.js +6 -4
  92. package/src/toast.js.map +1 -1
  93. package/src/toggle-group.d.ts +1 -1
  94. package/src/toggle-group.js +2 -1
  95. package/src/toggle-group.js.map +1 -1
  96. package/src/toolbar.d.ts +0 -6
  97. package/src/toolbar.js +14 -3
  98. package/src/toolbar.js.map +1 -1
  99. package/src/tour.d.ts +27 -0
  100. package/src/tour.js +62 -0
  101. package/src/tour.js.map +1 -0
  102. package/src/tree.d.ts +29 -0
  103. package/src/tree.js +99 -0
  104. package/src/tree.js.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirana-ui/web",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Kirana UI Primitives as custom elements, for a page with no framework",
5
5
  "license": "MIT",
6
6
  "author": "The Kirana authors",
@@ -67,6 +67,10 @@
67
67
  "types": "./src/collapsible.d.ts",
68
68
  "default": "./src/collapsible.js"
69
69
  },
70
+ "./color-picker": {
71
+ "types": "./src/color-picker.d.ts",
72
+ "default": "./src/color-picker.js"
73
+ },
70
74
  "./combobox": {
71
75
  "types": "./src/combobox.d.ts",
72
76
  "default": "./src/combobox.js"
@@ -95,6 +99,10 @@
95
99
  "types": "./src/drawer.d.ts",
96
100
  "default": "./src/drawer.js"
97
101
  },
102
+ "./editable": {
103
+ "types": "./src/editable.d.ts",
104
+ "default": "./src/editable.js"
105
+ },
98
106
  "./field": {
99
107
  "types": "./src/field.d.ts",
100
108
  "default": "./src/field.js"
@@ -103,6 +111,10 @@
103
111
  "types": "./src/fieldset.d.ts",
104
112
  "default": "./src/fieldset.js"
105
113
  },
114
+ "./file-upload": {
115
+ "types": "./src/file-upload.d.ts",
116
+ "default": "./src/file-upload.js"
117
+ },
106
118
  "./form": {
107
119
  "types": "./src/form.d.ts",
108
120
  "default": "./src/form.js"
@@ -155,6 +167,10 @@
155
167
  "types": "./src/pagination.d.ts",
156
168
  "default": "./src/pagination.js"
157
169
  },
170
+ "./password-input": {
171
+ "types": "./src/password-input.d.ts",
172
+ "default": "./src/password-input.js"
173
+ },
158
174
  "./popover": {
159
175
  "types": "./src/popover.d.ts",
160
176
  "default": "./src/popover.js"
@@ -171,6 +187,10 @@
171
187
  "types": "./src/radio-group.d.ts",
172
188
  "default": "./src/radio-group.js"
173
189
  },
190
+ "./rating": {
191
+ "types": "./src/rating.d.ts",
192
+ "default": "./src/rating.js"
193
+ },
174
194
  "./resizable": {
175
195
  "types": "./src/resizable.d.ts",
176
196
  "default": "./src/resizable.js"
@@ -191,6 +211,10 @@
191
211
  "types": "./src/slider.d.ts",
192
212
  "default": "./src/slider.js"
193
213
  },
214
+ "./steps": {
215
+ "types": "./src/steps.d.ts",
216
+ "default": "./src/steps.js"
217
+ },
194
218
  "./switch": {
195
219
  "types": "./src/switch.d.ts",
196
220
  "default": "./src/switch.js"
@@ -199,6 +223,14 @@
199
223
  "types": "./src/tabs.d.ts",
200
224
  "default": "./src/tabs.js"
201
225
  },
226
+ "./tags-input": {
227
+ "types": "./src/tags-input.d.ts",
228
+ "default": "./src/tags-input.js"
229
+ },
230
+ "./time-field": {
231
+ "types": "./src/time-field.d.ts",
232
+ "default": "./src/time-field.js"
233
+ },
202
234
  "./toast": {
203
235
  "types": "./src/toast.d.ts",
204
236
  "default": "./src/toast.js"
@@ -219,10 +251,18 @@
219
251
  "types": "./src/tooltip.d.ts",
220
252
  "default": "./src/tooltip.js"
221
253
  },
254
+ "./tour": {
255
+ "types": "./src/tour.d.ts",
256
+ "default": "./src/tour.js"
257
+ },
258
+ "./tree": {
259
+ "types": "./src/tree.d.ts",
260
+ "default": "./src/tree.js"
261
+ },
222
262
  "./package.json": "./package.json"
223
263
  },
224
264
  "dependencies": {
225
- "@kirana-ui/core": "0.3.0"
265
+ "@kirana-ui/core": "0.4.0"
226
266
  },
227
267
  "homepage": "https://ui.kirana.style",
228
268
  "repository": {
@@ -242,6 +282,7 @@
242
282
  "REFERENCE.md",
243
283
  "llms.txt",
244
284
  "skills",
245
- "LICENSE"
285
+ "LICENSE",
286
+ "CHANGELOG.md"
246
287
  ]
247
288
  }
@@ -52,15 +52,17 @@ from one core. The package for a framework is all a project installs.
52
52
  4. A value is controlled when given (`value` + `onValueChange`) and the component's own
53
53
  otherwise (`defaultValue`). A callback beside a value the component holds is
54
54
  `(value, details)`, and `details.cancel()` keeps the value as it was. A callback that
55
- reports something that happened (`onComplete`, `onClearErrors`, `onMonthChange`) takes only
56
- that.
55
+ reports something that happened (`onClearErrors`, `onMonthChange`) takes only that. The
56
+ names are Base UI's: `loopFocus`, `disablePointerDismissal`, a multiple Select's or
57
+ Combobox's list in `value`, One-Time Code's `validationType` and `onValueComplete`, a
58
+ toast's `timeout`; the older names still work and are marked deprecated.
57
59
  5. A control with a `name` is submitted with its form and follows the form's reset. Wrap it
58
60
  in `Field` for a label, a description and validation. `readOnly` and `keepMounted` are
59
61
  props of the parts `llms.txt` lists them for, and of no others.
60
62
 
61
63
  Per framework: React takes `render` for another element; Vue takes `as` / `as-child`, binds
62
64
  with `v-model:value` and names props in kebab case; Svelte takes a `child` snippet and
63
- `bind:value`; Solid takes `as` and `render`; Angular's parts are directives on your own
65
+ `bind:value`; Solid (2, with `@solidjs/web`) takes `as` and `render`; Angular's parts are directives on your own
64
66
  elements (`<button kpDialogTrigger>`), bound with `[(value)]`, with `[kpId]` for an id, and
65
67
  a part that comes and goes is structural (`*kpDialogPortal`, `*kpTabsPanel`: the list is in
66
68
  `llms.txt`); custom elements name each part with `kui-part` inside `<kui-dialog>`.
@@ -136,7 +138,25 @@ component's ref, kind, label, state and actions), `act({ steps: [{ ref, action,
136
138
  through the component's own handlers: its callback runs with `details.source === "agent"`
137
139
  and may cancel. Give every control an accessible name (a `<label>`, `aria-label`): it is how
138
140
  an agent finds it. Mark a destructive control `data-agent-confirm="what it does"`, private
139
- regions `data-agent-hidden`, secrets `data-agent-secret`. `allow(action)` is the policy,
141
+ regions `data-agent-hidden`, secrets `data-agent-secret` (whatever is inside is listed with its
142
+ name and its actions, never its value, its choices or whether it is checked). A bridge given a
143
+ `root` also reads what was opened from inside it (a dialog, a menu, a select's list), by the
144
+ `aria-controls` of what opened it. A step names its control by ref, by its label, by words of
145
+ the label, by the text of its row or by one of its choices; a name two controls answer to
146
+ fails with both. `subscribe((changed, changes) => …)` says of each change its `key`, `value`,
147
+ `previous`, `source` and `reason`; `record()` keeps a person's changes in `history()` beside
148
+ the agent's, each with its `source` and a sentence (`text`), and `undoSource("agent")` takes
149
+ back only the agent's. `stage({ steps })` shows a suggestion in the controls and gives
150
+ `revert()` and `keep()`. `act` takes a `signal`; `timeout` bounds a wait for `allow` or
151
+ `confirm`. A component of your own is read through `kinds` (`AgentKind`: a selector, `read`,
152
+ `perform`). A slider's `setValue` fails with what the slider holds when
153
+ its range or step does not hold the value asked for, and so does a spin button's (a Date or
154
+ Time Field's part, typed as a person types it). The thumbs of a range named by their group
155
+ are told apart by their place (`"Price, 1 of 2"`). A list of several values (a listbox, a
156
+ select with `multiple`, a tree) says `values` and takes a list in `setValue`; a closed
157
+ select's are known once its list has been read. A tree is one component: its shown nodes
158
+ are its `items` (with `level` below the top and `open` for a branch), and `setValue`,
159
+ `open` and `close` take a node's name. `allow(action)` is the policy,
140
160
  asked for every step; `confirm(action)` is a person's answer, asked for a step on something
141
161
  marked `data-agent-confirm`, and without it such a step fails with "Needs a person" whatever
142
162
  `allow` says. Never write `confirm: () => true`: open a dialog and resolve with what the
@@ -5,7 +5,7 @@ import { Accordion, AccordionProps } from "@kirana-ui/core/accordion";
5
5
  * `trigger` button and a `panel` that is in the page while its item is open. An item's
6
6
  * `kui-value` tells it from the others; an item that is given none makes its own.
7
7
  * `value` and `default-value` (the open items, with commas between), `multiple`, `disabled`,
8
- * `orientation`, `loop`; it tells `value-change`.
8
+ * `orientation`, `loop-focus` (`loop` is its older name); it tells `value-change`.
9
9
  */
10
10
  export declare const tag: Tag<Omit<AccordionProps<string>, "defaultValue" | "value"> & {
11
11
  value?: string | readonly string[];
package/src/accordion.js CHANGED
@@ -19,7 +19,7 @@ function itemOf(controller, element) {
19
19
  * `trigger` button and a `panel` that is in the page while its item is open. An item's
20
20
  * `kui-value` tells it from the others; an item that is given none makes its own.
21
21
  * `value` and `default-value` (the open items, with commas between), `multiple`, `disabled`,
22
- * `orientation`, `loop`; it tells `value-change`.
22
+ * `orientation`, `loop-focus` (`loop` is its older name); it tells `value-change`.
23
23
  */
24
24
  const tag = defineElement({
25
25
  tag: "kui-accordion",
@@ -29,6 +29,7 @@ const tag = defineElement({
29
29
  multiple: "boolean",
30
30
  disabled: "boolean",
31
31
  orientation: "string",
32
+ "loop-focus": "boolean",
32
33
  loop: "boolean"
33
34
  },
34
35
  create: (props) => createAccordion(computed(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/web/src/accordion.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type { Accordion, AccordionItem, AccordionProps } from \"@kirana-ui/core/accordion\"\n\nimport { list, ownValue } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n// An item's parts share the item: made when the first of them is met.\nconst items = new WeakMap<HTMLElement, AccordionItem>()\n\nfunction itemOf(controller: Accordion<string>, element: HTMLElement): AccordionItem | undefined {\n const around = partAround(element, \"item\")\n if (!around) return undefined\n let item = items.get(around)\n if (!item) {\n item = controller.item(around.getAttribute(\"kui-value\") ?? ownValue(around), () =>\n around.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}\n )\n items.set(around, item)\n }\n return item\n}\n\ntype Props = Omit<AccordionProps<string>, \"value\" | \"defaultValue\"> & {\n value?: string | readonly string[]\n defaultValue?: string | readonly string[]\n}\n\n/**\n * `<kui-accordion>` around `kui-part=\"root\"` and its `item`s, each with a `header`, a\n * `trigger` button and a `panel` that is in the page while its item is open. An item's\n * `kui-value` tells it from the others; an item that is given none makes its own.\n * `value` and `default-value` (the open items, with commas between), `multiple`, `disabled`,\n * `orientation`, `loop`; it tells `value-change`.\n */\nexport const tag = defineElement<Props & { id: string }, Accordion<string>>({\n tag: \"kui-accordion\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n multiple: \"boolean\",\n disabled: \"boolean\",\n orientation: \"string\",\n loop: \"boolean\",\n },\n create: (props) =>\n createAccordion<string>(\n computed(() => {\n const own = props.get()\n return { ...own, value: list(own.value), defaultValue: list(own.defaultValue) }\n })\n ),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n item(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.root, mount: () => item.mount() }\n },\n header: (controller, element) => itemOf(controller, element)?.header,\n trigger: (controller, element) => itemOf(controller, element)?.trigger,\n panel(controller, element) {\n const item = itemOf(controller, element)\n return item && { mounted: item.mounted, part: item.panel }\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-accordion\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }>\n }\n}\n"],"mappings":";;;;;AASA,MAAM,wBAAQ,IAAI,QAAoC;AAEtD,SAAS,OAAO,YAA+B,SAAiD;CAC9F,MAAM,SAAS,WAAW,SAAS,MAAM;CACzC,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,IAAI,OAAO,MAAM,IAAI,MAAM;CAC3B,IAAI,CAAC,MAAM;EACT,OAAO,WAAW,KAAK,OAAO,aAAa,WAAW,KAAK,SAAS,MAAM,SACxE,OAAO,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,CAC9D;EACA,MAAM,IAAI,QAAQ,IAAI;CACxB;CACA,OAAO;AACT;;;;;;;;AAcA,MAAa,MAAM,cAAyD;CAC1E,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV,aAAa;EACb,MAAM;CACR;CACA,SAAS,UACP,gBACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,KAAK,IAAI,KAAK;GAAG,cAAc,KAAK,IAAI,YAAY;EAAE;CAChF,CAAC,CACH;CACF,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAM,aAAa,KAAK,MAAM;GAAE;EAC9D;EACA,SAAS,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC9D,UAAU,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC/D,MAAM,YAAY,SAAS;GACzB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,SAAS,KAAK;IAAS,MAAM,KAAK;GAAM;EAC3D;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/web/src/accordion.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type { Accordion, AccordionItem, AccordionProps } from \"@kirana-ui/core/accordion\"\n\nimport { list, ownValue } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n// An item's parts share the item: made when the first of them is met.\nconst items = new WeakMap<HTMLElement, AccordionItem>()\n\nfunction itemOf(controller: Accordion<string>, element: HTMLElement): AccordionItem | undefined {\n const around = partAround(element, \"item\")\n if (!around) return undefined\n let item = items.get(around)\n if (!item) {\n item = controller.item(around.getAttribute(\"kui-value\") ?? ownValue(around), () =>\n around.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}\n )\n items.set(around, item)\n }\n return item\n}\n\ntype Props = Omit<AccordionProps<string>, \"value\" | \"defaultValue\"> & {\n value?: string | readonly string[]\n defaultValue?: string | readonly string[]\n}\n\n/**\n * `<kui-accordion>` around `kui-part=\"root\"` and its `item`s, each with a `header`, a\n * `trigger` button and a `panel` that is in the page while its item is open. An item's\n * `kui-value` tells it from the others; an item that is given none makes its own.\n * `value` and `default-value` (the open items, with commas between), `multiple`, `disabled`,\n * `orientation`, `loop-focus` (`loop` is its older name); it tells `value-change`.\n */\nexport const tag = defineElement<Props & { id: string }, Accordion<string>>({\n tag: \"kui-accordion\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n multiple: \"boolean\",\n disabled: \"boolean\",\n orientation: \"string\",\n \"loop-focus\": \"boolean\",\n loop: \"boolean\",\n },\n create: (props) =>\n createAccordion<string>(\n computed(() => {\n const own = props.get()\n return { ...own, value: list(own.value), defaultValue: list(own.defaultValue) }\n })\n ),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n item(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.root, mount: () => item.mount() }\n },\n header: (controller, element) => itemOf(controller, element)?.header,\n trigger: (controller, element) => itemOf(controller, element)?.trigger,\n panel(controller, element) {\n const item = itemOf(controller, element)\n return item && { mounted: item.mounted, part: item.panel }\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-accordion\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }>\n }\n}\n"],"mappings":";;;;;AASA,MAAM,wBAAQ,IAAI,QAAoC;AAEtD,SAAS,OAAO,YAA+B,SAAiD;CAC9F,MAAM,SAAS,WAAW,SAAS,MAAM;CACzC,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,IAAI,OAAO,MAAM,IAAI,MAAM;CAC3B,IAAI,CAAC,MAAM;EACT,OAAO,WAAW,KAAK,OAAO,aAAa,WAAW,KAAK,SAAS,MAAM,SACxE,OAAO,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,CAC9D;EACA,MAAM,IAAI,QAAQ,IAAI;CACxB;CACA,OAAO;AACT;;;;;;;;AAcA,MAAa,MAAM,cAAyD;CAC1E,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV,aAAa;EACb,cAAc;EACd,MAAM;CACR;CACA,SAAS,UACP,gBACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,KAAK,IAAI,KAAK;GAAG,cAAc,KAAK,IAAI,YAAY;EAAE;CAChF,CAAC,CACH;CACF,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAM,aAAa,KAAK,MAAM;GAAE;EAC9D;EACA,SAAS,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC9D,UAAU,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC/D,MAAM,YAAY,SAAS;GACzB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,SAAS,KAAK;IAAS,MAAM,KAAK;GAAM;EAC3D;CACF;AACF,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { ownDisabled } from "./around.js";
1
2
  import { defineElement } from "./runtime.js";
2
3
  import { createAlertDialog } from "@kirana-ui/core/alert-dialog";
3
4
  // src/alert-dialog.ts
@@ -17,7 +18,7 @@ const tag = defineElement({
17
18
  prop: "open"
18
19
  } },
19
20
  parts: {
20
- trigger: (controller) => controller.trigger,
21
+ trigger: (controller, element) => ownDisabled(element, controller.triggerPart),
21
22
  backdrop: (controller) => ({
22
23
  mounted: controller.mounted,
23
24
  part: controller.backdrop
@@ -32,7 +33,7 @@ const tag = defineElement({
32
33
  }),
33
34
  title: (controller) => controller.title,
34
35
  description: (controller) => controller.description,
35
- close: (controller) => controller.close
36
+ close: (controller, element) => ownDisabled(element, controller.closePart)
36
37
  }
37
38
  });
38
39
  export { tag };
@@ -1 +1 @@
1
- {"version":3,"file":"alert-dialog.js","names":[],"sources":["../../../../packages/web/src/alert-dialog.ts"],"sourcesContent":["import { createAlertDialog } from \"@kirana-ui/core/alert-dialog\"\nimport type { AlertDialogProps } from \"@kirana-ui/core/alert-dialog\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-alert-dialog>`: a dialog that asks, with the dialog's parts, its `viewport` too. A\n * press outside does not close it. `open`, `default-open`; it tells `open-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-alert-dialog\",\n props: { open: \"boolean\", \"default-open\": \"boolean\" },\n create: (props) => createAlertDialog(props),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger: (controller) => controller.trigger,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n viewport: (controller) => ({ mounted: controller.mounted, part: controller.viewport }),\n popup: (controller) => ({ mounted: controller.mounted, part: controller.popup }),\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller) => controller.close,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-alert-dialog\": ElementOf<\n As<typeof tag, AlertDialogProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n >\n }\n}\n"],"mappings":";;;;;;;AAUA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,MAAM;EAAW,gBAAgB;CAAU;CACpD,SAAS,UAAU,kBAAkB,KAAK;CAC1C,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,UAAU,eAAe,WAAW;EACpC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF,QAAQ,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAM;EAC9E,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
1
+ {"version":3,"file":"alert-dialog.js","names":[],"sources":["../../../../packages/web/src/alert-dialog.ts"],"sourcesContent":["import { createAlertDialog } from \"@kirana-ui/core/alert-dialog\"\nimport type { AlertDialogProps } from \"@kirana-ui/core/alert-dialog\"\n\nimport { ownDisabled } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-alert-dialog>`: a dialog that asks, with the dialog's parts, its `viewport` too. A\n * press outside does not close it. `open`, `default-open`; it tells `open-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-alert-dialog\",\n props: { open: \"boolean\", \"default-open\": \"boolean\" },\n create: (props) => createAlertDialog(props),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger: (controller, element) => ownDisabled(element, controller.triggerPart),\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n viewport: (controller) => ({ mounted: controller.mounted, part: controller.viewport }),\n popup: (controller) => ({ mounted: controller.mounted, part: controller.popup }),\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller, element) => ownDisabled(element, controller.closePart),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-alert-dialog\": ElementOf<\n As<typeof tag, AlertDialogProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,MAAM;EAAW,gBAAgB;CAAU;CACpD,SAAS,UAAU,kBAAkB,KAAK;CAC1C,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,UAAU,YAAY,YAAY,YAAY,SAAS,WAAW,WAAW;EAC7E,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF,QAAQ,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAM;EAC9E,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,YAAY,YAAY,YAAY,SAAS,WAAW,SAAS;CAC3E;AACF,CAAC"}
package/src/around.d.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  import { Drawn } from "./runtime.js";
2
2
  import { Part, PositionOptions, ReadonlySignal, Signal } from "@kirana-ui/core";
3
3
  import { Field } from "@kirana-ui/core/field";
4
+ /**
5
+ * A button that takes a `kui-disabled` of its own (a dialog's trigger or close, a navigation
6
+ * menu's trigger): its part made with options read from the element, and followed.
7
+ */
8
+ export declare function ownDisabled(element: HTMLElement, make: (options: () => {
9
+ disabled?: boolean | undefined;
10
+ }) => Part): Drawn;
4
11
  /** The field a control is in, if it is in one. */
5
12
  export declare const fieldAround: (host: HTMLElement) => Field | undefined;
6
13
  /** Several values, as an attribute writes them: `default-value="a,b"`. */
package/src/around.js CHANGED
@@ -1,6 +1,17 @@
1
- import { controllerAround, ownerOf } from "./runtime.js";
1
+ import { controllerAround, ownerOf, partProps } from "./runtime.js";
2
2
  import { computed, effect } from "@kirana-ui/core";
3
3
  // src/around.ts
4
+ /**
5
+ * A button that takes a `kui-disabled` of its own (a dialog's trigger or close, a navigation
6
+ * menu's trigger): its part made with options read from the element, and followed.
7
+ */
8
+ function ownDisabled(element, make) {
9
+ const own = partProps(element, { disabled: "boolean" }, {});
10
+ return {
11
+ part: make(() => own.props.get()),
12
+ mount: own.mount
13
+ };
14
+ }
4
15
  /** The field a control is in, if it is in one. */
5
16
  const fieldAround = (host) => controllerAround(host, "kui-field");
6
17
  /** Several values, as an attribute writes them: `default-value="a,b"`. */
@@ -112,6 +123,6 @@ const itemOptions = (element, id) => () => ({
112
123
  ...element.hasAttribute("kui-label") ? { label: element.getAttribute("kui-label") } : {},
113
124
  ...id === void 0 ? {} : { id }
114
125
  });
115
- export { MARK, fieldAround, itemOptions, list, once, options, ownValue, place, positioner, valueOf };
126
+ export { MARK, fieldAround, itemOptions, list, once, options, ownDisabled, ownValue, place, positioner, valueOf };
116
127
 
117
128
  //# sourceMappingURL=around.js.map
package/src/around.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"around.js","names":[],"sources":["../../../../packages/web/src/around.ts"],"sourcesContent":["import { computed, effect } from \"@kirana-ui/core\"\nimport type { Part, PositionOptions, ReadonlySignal, Signal } from \"@kirana-ui/core\"\nimport type { Field } from \"@kirana-ui/core/field\"\n\nimport { controllerAround, ownerOf } from \"./runtime.ts\"\nimport type { Drawn } from \"./runtime.ts\"\n\n/** The field a control is in, if it is in one. */\nexport const fieldAround = (host: HTMLElement): Field | undefined =>\n controllerAround<Field>(host, \"kui-field\")\n\n/** Several values, as an attribute writes them: `default-value=\"a,b\"`. */\nexport const list = (given: unknown): string[] | undefined =>\n typeof given === \"string\" ? given.split(\",\").filter(Boolean) : (given as string[] | undefined)\n\n/** A part's own options: `kui-disabled`, and its text when it is not what is typed (`kui-label`). */\nexport const options = (element: HTMLElement) => () => ({\n ...(element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}),\n ...(element.hasAttribute(\"kui-label\") ? { label: element.getAttribute(\"kui-label\")! } : {}),\n})\n\n/** The value an element is the part for: `kui-value`. */\nexport const valueOf = (element: HTMLElement | null): string =>\n element?.getAttribute(\"kui-value\") ?? \"\"\n\nlet named = 0\nconst names = new WeakMap<HTMLElement, string>()\n\n/**\n * The value of an element that was given none: a name of its own, the same each time it is\n * asked for. An item with no `kui-value`, a thumb with no `kui-index`.\n */\nexport function ownValue(element: HTMLElement | null): string {\n if (!element) return \"\"\n let name = names.get(element)\n if (!name) names.set(element, (name = `kui-own-${++named}`))\n return name\n}\n\n/** What is made once for an element and shared by the parts inside it: an item, a group. */\nexport function once<Made extends object>(\n kept: WeakMap<HTMLElement, Made>,\n element: HTMLElement | null,\n make: (element: HTMLElement) => Made\n): Made | undefined {\n if (!element) return undefined\n let made = kept.get(element)\n if (!made) kept.set(element, (made = make(element)))\n return made\n}\n\nconst number = (text: string | null) => (text === null ? undefined : Number(text))\n\nconst PLACING = [\n \"kui-side\",\n \"kui-align\",\n \"kui-side-offset\",\n \"kui-align-offset\",\n \"kui-collision-padding\",\n \"kui-collision-boundary\",\n \"kui-sticky\",\n \"kui-arrow-padding\",\n \"kui-position-method\",\n \"kui-anchor\",\n]\n\n/**\n * What a component with a positioner takes as a property of its custom element, for what an\n * attribute cannot say: a function, an element, an object.\n */\nexport interface Placed {\n /**\n * Its positioner's options that no attribute can say (`sideOffset` as a function,\n * `collisionBoundary` as an element or a rectangle, `collisionPadding` a side,\n * `collisionAvoidance`, `anchor` as an element). A `kui-` attribute on the positioner comes\n * before the same option here. Read when the popup comes into the page, and when one of the\n * positioner's attributes changes.\n */\n positioning?: Partial<PositionOptions> | undefined\n}\n\n/**\n * Where a positioner goes, as its own attributes say: `kui-side`, `kui-align`,\n * `kui-side-offset`, `kui-align-offset`, `kui-collision-padding`, `kui-sticky`,\n * `kui-arrow-padding`, `kui-position-method`, and two that name an element by its id:\n * `kui-anchor`, what the popup is placed against when that is not its trigger, and\n * `kui-collision-boundary`, what it is held inside. What no attribute can say is the\n * `positioning` property of its custom element (`host`). Written before the part is put on,\n * so the first placement reads them.\n */\nexport function place(\n positioning: Signal<Partial<PositionOptions>>,\n element: HTMLElement,\n host?: (HTMLElement & Placed) | null\n): void {\n const against = element.getAttribute(\"kui-anchor\")\n const within = element.getAttribute(\"kui-collision-boundary\")\n const sticky = element.getAttribute(\"kui-sticky\")\n const asked: Record<string, unknown> = {\n side: element.getAttribute(\"kui-side\") ?? undefined,\n align: element.getAttribute(\"kui-align\") ?? undefined,\n sideOffset: number(element.getAttribute(\"kui-side-offset\")),\n alignOffset: number(element.getAttribute(\"kui-align-offset\")),\n collisionPadding: number(element.getAttribute(\"kui-collision-padding\")),\n // Found now: a boundary is what is in the page as the popup comes into it.\n collisionBoundary:\n within === null || within === \"clipping-ancestors\"\n ? undefined\n : (element.ownerDocument.getElementById(within) ?? undefined),\n sticky: sticky === null ? undefined : sticky !== \"false\",\n arrowPadding: number(element.getAttribute(\"kui-arrow-padding\")),\n positionMethod: element.getAttribute(\"kui-position-method\") ?? undefined,\n // Looked for each time the popup is placed: the element may come into the page later.\n anchor: against === null ? undefined : () => element.ownerDocument.getElementById(against),\n }\n for (const key of Object.keys(asked)) if (asked[key] === undefined) delete asked[key]\n positioning.set({ ...host?.positioning, ...asked } as Partial<PositionOptions>)\n}\n\n/**\n * A positioner as a part: the one place a component draws one. Its attributes are read\n * before it is put on, and again when one of them changes: a popup that is open follows.\n */\nexport function positioner(\n controller: {\n positioning: Signal<Partial<PositionOptions>>\n mounted: ReadonlySignal<boolean>\n positioner: Part\n },\n element: HTMLElement\n): Drawn {\n // Found while the positioner is where the page wrote it: it is out of the page while closed.\n const host = ownerOf(element)\n place(controller.positioning, element, host)\n return {\n mounted: controller.mounted,\n part: controller.positioner,\n mount() {\n const observer = new MutationObserver(() => place(controller.positioning, element, host))\n observer.observe(element, { attributes: true, attributeFilter: PLACING })\n // Read again as the popup comes into the page: the property may have been set since.\n const stop = effect(() => {\n if (controller.mounted.get()) place(controller.positioning, element, host)\n })\n return () => {\n stop()\n observer.disconnect()\n }\n },\n }\n}\n\n/** A mark an item shows while it is chosen: nothing a screen reader says. */\nexport const MARK: Part = {\n props: computed(() => ({ \"aria-hidden\": \"true\" })),\n attach: () => () => {},\n}\n\n/** An item's options in a list that is filtered or typed through: with `kui-label`, and an id. */\nexport const itemOptions = (element: HTMLElement, id?: string) => () => ({\n ...(element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}),\n ...(element.hasAttribute(\"kui-label\") ? { label: element.getAttribute(\"kui-label\")! } : {}),\n ...(id === undefined ? {} : { id }),\n})\n"],"mappings":";;;;AAQA,MAAa,eAAe,SAC1B,iBAAwB,MAAM,WAAW;;AAG3C,MAAa,QAAQ,UACnB,OAAO,UAAU,WAAW,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,IAAK;;AAGlE,MAAa,WAAW,mBAAgC;CACtD,GAAI,QAAQ,aAAa,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ts"],"sourcesContent":["import { computed, effect } from \"@kirana-ui/core\"\nimport type { Part, PositionOptions, ReadonlySignal, Signal } from \"@kirana-ui/core\"\nimport type { Field } from \"@kirana-ui/core/field\"\n\nimport { controllerAround, ownerOf, partProps } from \"./runtime.ts\"\nimport type { Drawn } from \"./runtime.ts\"\n\n/**\n * A button that takes a `kui-disabled` of its own (a dialog's trigger or close, a navigation\n * menu's trigger): its part made with options read from the element, and followed.\n */\nexport function ownDisabled(\n element: HTMLElement,\n make: (options: () => { disabled?: boolean | undefined }) => Part\n): Drawn {\n const own = partProps<{ disabled?: boolean }>(element, { disabled: \"boolean\" }, {})\n return { part: make(() => own.props.get()), mount: own.mount }\n}\n\n/** The field a control is in, if it is in one. */\nexport const fieldAround = (host: HTMLElement): Field | undefined =>\n controllerAround<Field>(host, \"kui-field\")\n\n/** Several values, as an attribute writes them: `default-value=\"a,b\"`. */\nexport const list = (given: unknown): string[] | undefined =>\n typeof given === \"string\" ? given.split(\",\").filter(Boolean) : (given as string[] | undefined)\n\n/** A part's own options: `kui-disabled`, and its text when it is not what is typed (`kui-label`). */\nexport const options = (element: HTMLElement) => () => ({\n ...(element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}),\n ...(element.hasAttribute(\"kui-label\") ? { label: element.getAttribute(\"kui-label\")! } : {}),\n})\n\n/** The value an element is the part for: `kui-value`. */\nexport const valueOf = (element: HTMLElement | null): string =>\n element?.getAttribute(\"kui-value\") ?? \"\"\n\nlet named = 0\nconst names = new WeakMap<HTMLElement, string>()\n\n/**\n * The value of an element that was given none: a name of its own, the same each time it is\n * asked for. An item with no `kui-value`, a thumb with no `kui-index`.\n */\nexport function ownValue(element: HTMLElement | null): string {\n if (!element) return \"\"\n let name = names.get(element)\n if (!name) names.set(element, (name = `kui-own-${++named}`))\n return name\n}\n\n/** What is made once for an element and shared by the parts inside it: an item, a group. */\nexport function once<Made extends object>(\n kept: WeakMap<HTMLElement, Made>,\n element: HTMLElement | null,\n make: (element: HTMLElement) => Made\n): Made | undefined {\n if (!element) return undefined\n let made = kept.get(element)\n if (!made) kept.set(element, (made = make(element)))\n return made\n}\n\nconst number = (text: string | null) => (text === null ? undefined : Number(text))\n\nconst PLACING = [\n \"kui-side\",\n \"kui-align\",\n \"kui-side-offset\",\n \"kui-align-offset\",\n \"kui-collision-padding\",\n \"kui-collision-boundary\",\n \"kui-sticky\",\n \"kui-arrow-padding\",\n \"kui-position-method\",\n \"kui-anchor\",\n]\n\n/**\n * What a component with a positioner takes as a property of its custom element, for what an\n * attribute cannot say: a function, an element, an object.\n */\nexport interface Placed {\n /**\n * Its positioner's options that no attribute can say (`sideOffset` as a function,\n * `collisionBoundary` as an element or a rectangle, `collisionPadding` a side,\n * `collisionAvoidance`, `anchor` as an element). A `kui-` attribute on the positioner comes\n * before the same option here. Read when the popup comes into the page, and when one of the\n * positioner's attributes changes.\n */\n positioning?: Partial<PositionOptions> | undefined\n}\n\n/**\n * Where a positioner goes, as its own attributes say: `kui-side`, `kui-align`,\n * `kui-side-offset`, `kui-align-offset`, `kui-collision-padding`, `kui-sticky`,\n * `kui-arrow-padding`, `kui-position-method`, and two that name an element by its id:\n * `kui-anchor`, what the popup is placed against when that is not its trigger, and\n * `kui-collision-boundary`, what it is held inside. What no attribute can say is the\n * `positioning` property of its custom element (`host`). Written before the part is put on,\n * so the first placement reads them.\n */\nexport function place(\n positioning: Signal<Partial<PositionOptions>>,\n element: HTMLElement,\n host?: (HTMLElement & Placed) | null\n): void {\n const against = element.getAttribute(\"kui-anchor\")\n const within = element.getAttribute(\"kui-collision-boundary\")\n const sticky = element.getAttribute(\"kui-sticky\")\n const asked: Record<string, unknown> = {\n side: element.getAttribute(\"kui-side\") ?? undefined,\n align: element.getAttribute(\"kui-align\") ?? undefined,\n sideOffset: number(element.getAttribute(\"kui-side-offset\")),\n alignOffset: number(element.getAttribute(\"kui-align-offset\")),\n collisionPadding: number(element.getAttribute(\"kui-collision-padding\")),\n // Found now: a boundary is what is in the page as the popup comes into it.\n collisionBoundary:\n within === null || within === \"clipping-ancestors\"\n ? undefined\n : (element.ownerDocument.getElementById(within) ?? undefined),\n sticky: sticky === null ? undefined : sticky !== \"false\",\n arrowPadding: number(element.getAttribute(\"kui-arrow-padding\")),\n positionMethod: element.getAttribute(\"kui-position-method\") ?? undefined,\n // Looked for each time the popup is placed: the element may come into the page later.\n anchor: against === null ? undefined : () => element.ownerDocument.getElementById(against),\n }\n for (const key of Object.keys(asked)) if (asked[key] === undefined) delete asked[key]\n positioning.set({ ...host?.positioning, ...asked } as Partial<PositionOptions>)\n}\n\n/**\n * A positioner as a part: the one place a component draws one. Its attributes are read\n * before it is put on, and again when one of them changes: a popup that is open follows.\n */\nexport function positioner(\n controller: {\n positioning: Signal<Partial<PositionOptions>>\n mounted: ReadonlySignal<boolean>\n positioner: Part\n },\n element: HTMLElement\n): Drawn {\n // Found while the positioner is where the page wrote it: it is out of the page while closed.\n const host = ownerOf(element)\n place(controller.positioning, element, host)\n return {\n mounted: controller.mounted,\n part: controller.positioner,\n mount() {\n const observer = new MutationObserver(() => place(controller.positioning, element, host))\n observer.observe(element, { attributes: true, attributeFilter: PLACING })\n // Read again as the popup comes into the page: the property may have been set since.\n const stop = effect(() => {\n if (controller.mounted.get()) place(controller.positioning, element, host)\n })\n return () => {\n stop()\n observer.disconnect()\n }\n },\n }\n}\n\n/** A mark an item shows while it is chosen: nothing a screen reader says. */\nexport const MARK: Part = {\n props: computed(() => ({ \"aria-hidden\": \"true\" })),\n attach: () => () => {},\n}\n\n/** An item's options in a list that is filtered or typed through: with `kui-label`, and an id. */\nexport const itemOptions = (element: HTMLElement, id?: string) => () => ({\n ...(element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}),\n ...(element.hasAttribute(\"kui-label\") ? { label: element.getAttribute(\"kui-label\")! } : {}),\n ...(id === undefined ? {} : { id }),\n})\n"],"mappings":";;;;;;;AAWA,SAAgB,YACd,SACA,MACO;CACP,MAAM,MAAM,UAAkC,SAAS,EAAE,UAAU,U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vB;;AAGA,MAAa,eAAe,SAAsB,cAAuB;CACvE,GAAI,QAAQ,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACjE,GAAI,QAAQ,aAAa,WAAW,IAAI,EAAE,OAAO,QAAQ,aAAa,WAAW,EAAG,IAAI,CAAC;CACzF,GAAI,OAAO,KAAA,IAAY,CAAC,IAAI,EAAE,GAAG;AACnC"}
@@ -1,7 +1,7 @@
1
1
  import { ElementOf, Tag } from "./runtime.js";
2
2
  import { Placed } from "./around.js";
3
- import { AutocompleteProps } from "@kirana-ui/core/autocomplete";
4
3
  import { Combobox } from "@kirana-ui/core/combobox";
4
+ import { AutocompleteProps } from "@kirana-ui/core/autocomplete";
5
5
  /**
6
6
  * `<kui-autocomplete>`: a combobox whose text is the value, with a combobox's parts: the
7
7
  * list only suggests. `value`, `default-value`, `open`, `default-open`, `mode`,
package/src/avatar.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineElement } from "./runtime.js";
2
- import { computed, effect } from "@kirana-ui/core";
2
+ import { effect } from "@kirana-ui/core";
3
3
  import { createAvatar } from "@kirana-ui/core/avatar";
4
4
  // src/avatar.ts
5
5
  const fallbacks = /* @__PURE__ */ new WeakMap();
@@ -45,7 +45,7 @@ const tag = defineElement({
45
45
  root: (controller) => controller.root,
46
46
  image: (controller, element) => element.hasAttribute("kui-keep-mounted") ? controller.keptImage : {
47
47
  part: controller.image,
48
- mounted: computed(() => controller.status.get() === "loaded")
48
+ mounted: controller.imageMounted
49
49
  },
50
50
  fallback(controller, element) {
51
51
  let presence = fallbacks.get(element);
package/src/avatar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/web/src/avatar.ts"],"sourcesContent":["import { computed, effect } from \"@kirana-ui/core\"\nimport { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type { Avatar, AvatarFallbackPresence, AvatarImageProps } from \"@kirana-ui/core/avatar\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n// One presence per fallback element: its delay is counted once.\nconst fallbacks = new WeakMap<HTMLElement, AvatarFallbackPresence>()\n\n/**\n * `<kui-avatar>` around `kui-part=\"root\"`, an `image` (an `<img>`, in the page once the\n * picture has loaded) and a `fallback`, in the page until then; `kui-delay=\"600\"` on the\n * fallback waits that many milliseconds first. `src`: the picture's address, on the component,\n * since the image is not in the page to be given one. With `kui-keep-mounted` the image stays\n * in the page, as Base UI's `keepMounted` image: its own `src` is the address, it loads the\n * picture itself, and it is `aria-hidden` until it has (`data-loading`, `data-error`). It\n * tells `loading-status-change` (`detail.status`) as the picture loads.\n */\nexport const tag = defineElement<\n { id: string; src?: string } & AvatarImageProps,\n Avatar & { mount(): () => void }\n>({\n tag: \"kui-avatar\",\n props: { src: \"string\" },\n create(props) {\n const avatar = createAvatar(props)\n const report = avatar.statusReport(() => props.peek().onLoadingStatusChange)\n return {\n ...avatar,\n mount() {\n // An image kept in the page says its own address: a component given none leaves it.\n let given = false\n const stops = [\n effect(() => {\n const { src } = props.get()\n if (src === undefined && !given) return\n given = src !== undefined\n avatar.source.set(src)\n }),\n avatar.mount(),\n report.mount(),\n ]\n return () => stops.forEach((stop) => stop())\n },\n }\n },\n changes: {\n onLoadingStatusChange: { event: \"loading-status-change\", prop: \"status\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n image: (controller, element) =>\n element.hasAttribute(\"kui-keep-mounted\")\n ? controller.keptImage\n : { part: controller.image, mounted: computed(() => controller.status.get() === \"loaded\") },\n fallback(controller, element) {\n let presence = fallbacks.get(element)\n if (!presence) {\n const delay = Number(element.getAttribute(\"kui-delay\")) || 0\n presence = controller.fallbackPresence({ delay })\n fallbacks.set(element, presence)\n }\n return { part: controller.fallback, mounted: presence.shown, mount: presence.mount }\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-avatar\": ElementOf<\n typeof tag,\n { \"loading-status-change\": [\"onLoadingStatusChange\", \"status\"] }\n >\n }\n}\n"],"mappings":";;;;AAQA,MAAM,4BAAY,IAAI,QAA6C;;;;;;;;;;AAWnE,MAAa,MAAM,cAGjB;CACA,KAAK;CACL,OAAO,EAAE,KAAK,SAAS;CACvB,OAAO,OAAO;EACZ,MAAM,SAAS,aAAa,KAAK;EACjC,MAAM,SAAS,OAAO,mBAAmB,MAAM,KAAK,CAAC,CAAC,qBAAqB;EAC3E,OAAO;GACL,GAAG;GACH,QAAQ;IAEN,IAAI,QAAQ;IACZ,MAAM,QAAQ;KACZ,aAAa;MACX,MAAM,EAAE,QAAQ,MAAM,IAAI;MAC1B,IAAI,QAAQ,KAAA,KAAa,CAAC,OAAO;MACjC,QAAQ,QAAQ,KAAA;MAChB,OAAO,OAAO,IAAI,GAAG;KACvB,CAAC;KACD,OAAO,MAAM;KACb,OAAO,MAAM;IACf;IACA,aAAa,MAAM,SAAS,SAAS,KAAK,CAAC;GAC7C;EACF;CACF;CACA,SAAS,EACP,uBAAuB;EAAE,OAAO;EAAyB,MAAM;EAAU,MAAM;CAAM,EACvF;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,YAAY,YAClB,QAAQ,aAAa,kBAAkB,IACnC,WAAW,YACX;GAAE,MAAM,WAAW;GAAO,SAAS,eAAe,WAAW,OAAO,IAAI,MAAM,QAAQ;EAAE;EAC9F,SAAS,YAAY,SAAS;GAC5B,IAAI,WAAW,UAAU,IAAI,OAAO;GACpC,IAAI,CAAC,UAAU;IACb,MAAM,QAAQ,OAAO,QAAQ,aAAa,WAAW,CAAC,KAAK;IAC3D,WAAW,WAAW,iBAAiB,EAAE,MAAM,CAAC;IAChD,UAAU,IAAI,SAAS,QAAQ;GACjC;GACA,OAAO;IAAE,MAAM,WAAW;IAAU,SAAS,SAAS;IAAO,OAAO,SAAS;GAAM;EACrF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/web/src/avatar.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type { Avatar, AvatarFallbackPresence, AvatarImageProps } from \"@kirana-ui/core/avatar\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n// One presence per fallback element: its delay is counted once.\nconst fallbacks = new WeakMap<HTMLElement, AvatarFallbackPresence>()\n\n/**\n * `<kui-avatar>` around `kui-part=\"root\"`, an `image` (an `<img>`, in the page once the\n * picture has loaded) and a `fallback`, in the page until then; `kui-delay=\"600\"` on the\n * fallback waits that many milliseconds first. `src`: the picture's address, on the component,\n * since the image is not in the page to be given one. With `kui-keep-mounted` the image stays\n * in the page, as Base UI's `keepMounted` image: its own `src` is the address, it loads the\n * picture itself, and it is `aria-hidden` until it has (`data-loading`, `data-error`). It\n * tells `loading-status-change` (`detail.status`) as the picture loads.\n */\nexport const tag = defineElement<\n { id: string; src?: string } & AvatarImageProps,\n Avatar & { mount(): () => void }\n>({\n tag: \"kui-avatar\",\n props: { src: \"string\" },\n create(props) {\n const avatar = createAvatar(props)\n const report = avatar.statusReport(() => props.peek().onLoadingStatusChange)\n return {\n ...avatar,\n mount() {\n // An image kept in the page says its own address: a component given none leaves it.\n let given = false\n const stops = [\n effect(() => {\n const { src } = props.get()\n if (src === undefined && !given) return\n given = src !== undefined\n avatar.source.set(src)\n }),\n avatar.mount(),\n report.mount(),\n ]\n return () => stops.forEach((stop) => stop())\n },\n }\n },\n changes: {\n onLoadingStatusChange: { event: \"loading-status-change\", prop: \"status\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n image: (controller, element) =>\n element.hasAttribute(\"kui-keep-mounted\")\n ? controller.keptImage\n : { part: controller.image, mounted: controller.imageMounted },\n fallback(controller, element) {\n let presence = fallbacks.get(element)\n if (!presence) {\n const delay = Number(element.getAttribute(\"kui-delay\")) || 0\n presence = controller.fallbackPresence({ delay })\n fallbacks.set(element, presence)\n }\n return { part: controller.fallback, mounted: presence.shown, mount: presence.mount }\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-avatar\": ElementOf<\n typeof tag,\n { \"loading-status-change\": [\"onLoadingStatusChange\", \"status\"] }\n >\n }\n}\n"],"mappings":";;;;AAQA,MAAM,4BAAY,IAAI,QAA6C;;;;;;;;;;AAWnE,MAAa,MAAM,cAGjB;CACA,KAAK;CACL,OAAO,EAAE,KAAK,SAAS;CACvB,OAAO,OAAO;EACZ,MAAM,SAAS,aAAa,KAAK;EACjC,MAAM,SAAS,OAAO,mBAAmB,MAAM,KAAK,CAAC,CAAC,qBAAqB;EAC3E,OAAO;GACL,GAAG;GACH,QAAQ;IAEN,IAAI,QAAQ;IACZ,MAAM,QAAQ;KACZ,aAAa;MACX,MAAM,EAAE,QAAQ,MAAM,IAAI;MAC1B,IAAI,QAAQ,KAAA,KAAa,CAAC,OAAO;MACjC,QAAQ,QAAQ,KAAA;MAChB,OAAO,OAAO,IAAI,GAAG;KACvB,CAAC;KACD,OAAO,MAAM;KACb,OAAO,MAAM;IACf;IACA,aAAa,MAAM,SAAS,SAAS,KAAK,CAAC;GAC7C;EACF;CACF;CACA,SAAS,EACP,uBAAuB;EAAE,OAAO;EAAyB,MAAM;EAAU,MAAM;CAAM,EACvF;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,YAAY,YAClB,QAAQ,aAAa,kBAAkB,IACnC,WAAW,YACX;GAAE,MAAM,WAAW;GAAO,SAAS,WAAW;EAAa;EACjE,SAAS,YAAY,SAAS;GAC5B,IAAI,WAAW,UAAU,IAAI,OAAO;GACpC,IAAI,CAAC,UAAU;IACb,MAAM,QAAQ,OAAO,QAAQ,aAAa,WAAW,CAAC,KAAK;IAC3D,WAAW,WAAW,iBAAiB,EAAE,MAAM,CAAC;IAChD,UAAU,IAAI,SAAS,QAAQ;GACjC;GACA,OAAO;IAAE,MAAM,WAAW;IAAU,SAAS,SAAS;IAAO,OAAO,SAAS;GAAM;EACrF;CACF;AACF,CAAC"}
package/src/button.d.ts CHANGED
@@ -2,7 +2,8 @@ import { As, ElementOf, Tag } from "./runtime.js";
2
2
  import { ButtonProps } from "@kirana-ui/core/button";
3
3
  /**
4
4
  * `<kui-button>` around a `kui-part="root"` button, or with `native-button="false"` another
5
- * element that acts as one. `disabled`, `focusable-when-disabled`, `native-button`.
5
+ * element that acts as one; on a link that navigates (`<a href>`), it stays a link. `disabled`,
6
+ * `focusable-when-disabled`, `native-button`.
6
7
  */
7
8
  export declare const tag: Tag<{
8
9
  id: string;
package/src/button.js CHANGED
@@ -3,7 +3,8 @@ import { createButton } from "@kirana-ui/core/button";
3
3
  // src/button.ts
4
4
  /**
5
5
  * `<kui-button>` around a `kui-part="root"` button, or with `native-button="false"` another
6
- * element that acts as one. `disabled`, `focusable-when-disabled`, `native-button`.
6
+ * element that acts as one; on a link that navigates (`<a href>`), it stays a link. `disabled`,
7
+ * `focusable-when-disabled`, `native-button`.
7
8
  */
8
9
  const tag = defineElement({
9
10
  tag: "kui-button",
package/src/button.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/web/src/button.ts"],"sourcesContent":["import { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps } from \"@kirana-ui/core/button\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-button>` around a `kui-part=\"root\"` button, or with `native-button=\"false\"` another\n * element that acts as one. `disabled`, `focusable-when-disabled`, `native-button`.\n */\nexport const tag = defineElement({\n tag: \"kui-button\",\n props: { disabled: \"boolean\", \"focusable-when-disabled\": \"boolean\", \"native-button\": \"boolean\" },\n create: (props) => createButton(props as never),\n changes: {},\n parts: { root: (controller) => controller.root },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-button\": ElementOf<As<typeof tag, ButtonProps>>\n }\n}\n"],"mappings":";;;;;;;AAUA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,UAAU;EAAW,2BAA2B;EAAW,iBAAiB;CAAU;CAC/F,SAAS,UAAU,aAAa,KAAc;CAC9C,SAAS,CAAC;CACV,OAAO,EAAE,OAAO,eAAe,WAAW,KAAK;AACjD,CAAC"}
1
+ {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/web/src/button.ts"],"sourcesContent":["import { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps } from \"@kirana-ui/core/button\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-button>` around a `kui-part=\"root\"` button, or with `native-button=\"false\"` another\n * element that acts as one; on a link that navigates (`<a href>`), it stays a link. `disabled`,\n * `focusable-when-disabled`, `native-button`.\n */\nexport const tag = defineElement({\n tag: \"kui-button\",\n props: { disabled: \"boolean\", \"focusable-when-disabled\": \"boolean\", \"native-button\": \"boolean\" },\n create: (props) => createButton(props as never),\n changes: {},\n parts: { root: (controller) => controller.root },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-button\": ElementOf<As<typeof tag, ButtonProps>>\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,UAAU;EAAW,2BAA2B;EAAW,iBAAiB;CAAU;CAC/F,SAAS,UAAU,aAAa,KAAc;CAC9C,SAAS,CAAC;CACV,OAAO,EAAE,OAAO,eAAe,WAAW,KAAK;AACjD,CAAC"}
package/src/calendar.d.ts CHANGED
@@ -9,7 +9,7 @@ import { Calendar, CalendarProps } from "@kirana-ui/core/calendar";
9
9
  * `<template kui-each="months">` (`{index}`, `{month}`, `{title}`) holds each month's
10
10
  * `heading` and `grid`. An `<input kui-part="input">` submits the value under `name`.
11
11
  * `value` and `default-value` (a day as `2026-03-14`; a range's first and last, or a list's
12
- * days, with commas between), `mode`, `min-days`, `max-days`, `months`, `paged-navigation`,
12
+ * days, with commas between), `mode`, `required`, `min-days`, `max-days`, `months`, `paged-navigation`,
13
13
  * `month`, `default-month`, `default-focused-value`, `locale`, `calendar-system`, `min`,
14
14
  * `max`, `disabled`, `read-only`, `fixed-weeks`, `name`, `form`; `isDateUnavailable` as a
15
15
  * property; it tells `value-change` and `month-change`.
package/src/calendar.js CHANGED
@@ -13,7 +13,7 @@ const { parts, lists } = calendarParts((controller) => controller);
13
13
  * `<template kui-each="months">` (`{index}`, `{month}`, `{title}`) holds each month's
14
14
  * `heading` and `grid`. An `<input kui-part="input">` submits the value under `name`.
15
15
  * `value` and `default-value` (a day as `2026-03-14`; a range's first and last, or a list's
16
- * days, with commas between), `mode`, `min-days`, `max-days`, `months`, `paged-navigation`,
16
+ * days, with commas between), `mode`, `required`, `min-days`, `max-days`, `months`, `paged-navigation`,
17
17
  * `month`, `default-month`, `default-focused-value`, `locale`, `calendar-system`, `min`,
18
18
  * `max`, `disabled`, `read-only`, `fixed-weeks`, `name`, `form`; `isDateUnavailable` as a
19
19
  * property; it tells `value-change` and `month-change`.
@@ -24,6 +24,7 @@ const tag = defineElement({
24
24
  value: "string",
25
25
  "default-value": "string",
26
26
  mode: "string",
27
+ required: "boolean",
27
28
  "min-days": "number",
28
29
  "max-days": "number",
29
30
  months: "number",
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/web/src/calendar.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createCalendar } from \"@kirana-ui/core/calendar\"\nimport type { Calendar, CalendarProps } from \"@kirana-ui/core/calendar\"\n\nimport { calendarParts, days } from \"./dates.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst { parts, lists } = calendarParts<Calendar>((controller) => controller)\n\n/**\n * `<kui-calendar>` around `kui-part=\"root\"`, with `previous` and `next` buttons, a `heading`\n * (it says the month) and a `grid` table. The table's head row holds a\n * `<template kui-each=\"weekdays\">` with a `head-cell` (`{short}`, `{narrow}`, `{long}`); its\n * body a `<template kui-each=\"weeks\">` with a row, which holds a `<template kui-each=\"days\">`\n * with a `cell` and its `day` button (`{date}`, `{label}`). With several `months`, a\n * `<template kui-each=\"months\">` (`{index}`, `{month}`, `{title}`) holds each month's\n * `heading` and `grid`. An `<input kui-part=\"input\">` submits the value under `name`.\n * `value` and `default-value` (a day as `2026-03-14`; a range's first and last, or a list's\n * days, with commas between), `mode`, `min-days`, `max-days`, `months`, `paged-navigation`,\n * `month`, `default-month`, `default-focused-value`, `locale`, `calendar-system`, `min`,\n * `max`, `disabled`, `read-only`, `fixed-weeks`, `name`, `form`; `isDateUnavailable` as a\n * property; it tells `value-change` and `month-change`.\n */\nexport const tag = defineElement<CalendarProps, Calendar>({\n tag: \"kui-calendar\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n \"min-days\": \"number\",\n \"max-days\": \"number\",\n months: \"number\",\n \"paged-navigation\": \"boolean\",\n month: \"string\",\n \"default-month\": \"string\",\n \"default-focused-value\": \"string\",\n locale: \"string\",\n \"calendar-system\": \"string\",\n min: \"string\",\n max: \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n \"fixed-weeks\": \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"isDateUnavailable\"],\n create: (props) =>\n createCalendar(\n computed(() => {\n const own = props.get()\n return {\n ...own,\n value: days(own.value, own.mode),\n defaultValue: days(own.defaultValue, own.mode),\n } as CalendarProps\n })\n ),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onMonthChange: { event: \"month-change\", prop: \"month\" },\n },\n lists,\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n ...parts,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-calendar\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; \"month-change\": [\"onMonthChange\", \"month\"] }\n >\n }\n}\n"],"mappings":";;;;;AAQA,MAAM,EAAE,OAAO,UAAU,eAAyB,eAAe,UAAU;;;;;;;;;;;;;;;AAgB3E,MAAa,MAAM,cAAuC;CACxD,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,YAAY;EACZ,YAAY;EACZ,QAAQ;EACR,oBAAoB;EACpB,OAAO;EACP,iBAAiB;EACjB,yBAAyB;EACzB,QAAQ;EACR,mBAAmB;EACnB,KAAK;EACL,KAAK;EACL,UAAU;EACV,aAAa;EACb,eAAe;EACf,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,mBAAmB;CAChC,SAAS,UACP,eACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GACL,GAAG;GACH,OAAO,KAAK,IAAI,OAAO,IAAI,IAAI;GAC/B,cAAc,KAAK,IAAI,cAAc,IAAI,IAAI;EAC/C;CACF,CAAC,CACH;CACF,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;CACxD;CACA;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,GAAG;CACL;AACF,CAAC"}
1
+ {"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/web/src/calendar.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createCalendar } from \"@kirana-ui/core/calendar\"\nimport type { Calendar, CalendarProps } from \"@kirana-ui/core/calendar\"\n\nimport { calendarParts, days } from \"./dates.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst { parts, lists } = calendarParts<Calendar>((controller) => controller)\n\n/**\n * `<kui-calendar>` around `kui-part=\"root\"`, with `previous` and `next` buttons, a `heading`\n * (it says the month) and a `grid` table. The table's head row holds a\n * `<template kui-each=\"weekdays\">` with a `head-cell` (`{short}`, `{narrow}`, `{long}`); its\n * body a `<template kui-each=\"weeks\">` with a row, which holds a `<template kui-each=\"days\">`\n * with a `cell` and its `day` button (`{date}`, `{label}`). With several `months`, a\n * `<template kui-each=\"months\">` (`{index}`, `{month}`, `{title}`) holds each month's\n * `heading` and `grid`. An `<input kui-part=\"input\">` submits the value under `name`.\n * `value` and `default-value` (a day as `2026-03-14`; a range's first and last, or a list's\n * days, with commas between), `mode`, `required`, `min-days`, `max-days`, `months`, `paged-navigation`,\n * `month`, `default-month`, `default-focused-value`, `locale`, `calendar-system`, `min`,\n * `max`, `disabled`, `read-only`, `fixed-weeks`, `name`, `form`; `isDateUnavailable` as a\n * property; it tells `value-change` and `month-change`.\n */\nexport const tag = defineElement<CalendarProps, Calendar>({\n tag: \"kui-calendar\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n required: \"boolean\",\n \"min-days\": \"number\",\n \"max-days\": \"number\",\n months: \"number\",\n \"paged-navigation\": \"boolean\",\n month: \"string\",\n \"default-month\": \"string\",\n \"default-focused-value\": \"string\",\n locale: \"string\",\n \"calendar-system\": \"string\",\n min: \"string\",\n max: \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n \"fixed-weeks\": \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"isDateUnavailable\"],\n create: (props) =>\n createCalendar(\n computed(() => {\n const own = props.get()\n return {\n ...own,\n value: days(own.value, own.mode),\n defaultValue: days(own.defaultValue, own.mode),\n } as CalendarProps\n })\n ),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onMonthChange: { event: \"month-change\", prop: \"month\" },\n },\n lists,\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n ...parts,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-calendar\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; \"month-change\": [\"onMonthChange\", \"month\"] }\n >\n }\n}\n"],"mappings":";;;;;AAQA,MAAM,EAAE,OAAO,UAAU,eAAyB,eAAe,UAAU;;;;;;;;;;;;;;;AAgB3E,MAAa,MAAM,cAAuC;CACxD,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,QAAQ;EACR,oBAAoB;EACpB,OAAO;EACP,iBAAiB;EACjB,yBAAyB;EACzB,QAAQ;EACR,mBAAmB;EACnB,KAAK;EACL,KAAK;EACL,UAAU;EACV,aAAa;EACb,eAAe;EACf,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,mBAAmB;CAChC,SAAS,UACP,eACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GACL,GAAG;GACH,OAAO,KAAK,IAAI,OAAO,IAAI,IAAI;GAC/B,cAAc,KAAK,IAAI,cAAc,IAAI,IAAI;EAC/C;CACF,CAAC,CACH;CACF,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;CACxD;CACA;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,GAAG;CACL;AACF,CAAC"}
package/src/carousel.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ElementOf, Tag } from "./runtime.js";
2
2
  import { Carousel, CarouselProps } from "@kirana-ui/core/carousel";
3
3
  /**
4
4
  * `<kui-carousel>` around `kui-part="root"`, a `viewport` with an `item` for each slide
5
- * (`kui-index`, from 0), `previous` and `next` buttons, and an `indicator` button for a slide
5
+ * (`kui-index`, from 0, or its place in the page when it has none), `previous` and `next` buttons, and an `indicator` button for a slide
6
6
  * (`kui-index`). `index`, `default-index`, `orientation`, `loop`; it tells `index-change`.
7
7
  */
8
8
  export declare const tag: Tag<CarouselProps, Carousel>;
package/src/carousel.js CHANGED
@@ -1,10 +1,12 @@
1
+ import { once } from "./around.js";
1
2
  import { defineElement } from "./runtime.js";
2
3
  import { createCarousel } from "@kirana-ui/core/carousel";
3
4
  // src/carousel.ts
4
5
  const indexOf = (element) => Number(element.getAttribute("kui-index") ?? 0);
6
+ const slides = /* @__PURE__ */ new WeakMap();
5
7
  /**
6
8
  * `<kui-carousel>` around `kui-part="root"`, a `viewport` with an `item` for each slide
7
- * (`kui-index`, from 0), `previous` and `next` buttons, and an `indicator` button for a slide
9
+ * (`kui-index`, from 0, or its place in the page when it has none), `previous` and `next` buttons, and an `indicator` button for a slide
8
10
  * (`kui-index`). `index`, `default-index`, `orientation`, `loop`; it tells `index-change`.
9
11
  */
10
12
  const tag = defineElement({
@@ -23,7 +25,7 @@ const tag = defineElement({
23
25
  parts: {
24
26
  root: (controller) => controller.root,
25
27
  viewport: (controller) => controller.viewport,
26
- item: (controller, element) => controller.item(indexOf(element)),
28
+ item: (controller, element) => once(slides, element, () => controller.item(element.hasAttribute("kui-index") ? indexOf(element) : void 0)),
27
29
  previous: (controller) => controller.previous,
28
30
  next: (controller) => controller.next,
29
31
  indicator: (controller, element) => controller.indicator(indexOf(element))
@@ -1 +1 @@
1
- {"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/web/src/carousel.ts"],"sourcesContent":["import { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { Carousel, CarouselProps } from \"@kirana-ui/core/carousel\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement) => Number(element.getAttribute(\"kui-index\") ?? 0)\n\n/**\n * `<kui-carousel>` around `kui-part=\"root\"`, a `viewport` with an `item` for each slide\n * (`kui-index`, from 0), `previous` and `next` buttons, and an `indicator` button for a slide\n * (`kui-index`). `index`, `default-index`, `orientation`, `loop`; it tells `index-change`.\n */\nexport const tag = defineElement<CarouselProps, Carousel>({\n tag: \"kui-carousel\",\n props: { index: \"number\", \"default-index\": \"number\", orientation: \"string\", loop: \"boolean\" },\n create: (props) => createCarousel(props),\n changes: { onIndexChange: { event: \"index-change\", prop: \"index\" } },\n parts: {\n root: (controller) => controller.root,\n viewport: (controller) => controller.viewport,\n item: (controller, element) => controller.item(indexOf(element)),\n previous: (controller) => controller.previous,\n next: (controller) => controller.next,\n indicator: (controller, element) => controller.indicator(indexOf(element)),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-carousel\": ElementOf<typeof tag, { \"index-change\": [\"onIndexChange\", \"index\"] }>\n }\n}\n"],"mappings":";;;AAMA,MAAM,WAAW,YAAyB,OAAO,QAAQ,aAAa,WAAW,KAAK,CAAC;;;;;;AAOvF,MAAa,MAAM,cAAuC;CACxD,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,iBAAiB;EAAU,aAAa;EAAU,MAAM;CAAU;CAC5F,SAAS,UAAU,eAAe,KAAK;CACvC,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,OAAO,YAAY,YAAY,WAAW,KAAK,QAAQ,OAAO,CAAC;EAC/D,WAAW,eAAe,WAAW;EACrC,OAAO,eAAe,WAAW;EACjC,YAAY,YAAY,YAAY,WAAW,UAAU,QAAQ,OAAO,CAAC;CAC3E;AACF,CAAC"}
1
+ {"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/web/src/carousel.ts"],"sourcesContent":["import type { Part } from \"@kirana-ui/core\"\nimport { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { Carousel, CarouselProps } from \"@kirana-ui/core/carousel\"\n\nimport { once } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement) => Number(element.getAttribute(\"kui-index\") ?? 0)\nconst slides = new WeakMap<HTMLElement, Part>()\n\n/**\n * `<kui-carousel>` around `kui-part=\"root\"`, a `viewport` with an `item` for each slide\n * (`kui-index`, from 0, or its place in the page when it has none), `previous` and `next` buttons, and an `indicator` button for a slide\n * (`kui-index`). `index`, `default-index`, `orientation`, `loop`; it tells `index-change`.\n */\nexport const tag = defineElement<CarouselProps, Carousel>({\n tag: \"kui-carousel\",\n props: { index: \"number\", \"default-index\": \"number\", orientation: \"string\", loop: \"boolean\" },\n create: (props) => createCarousel(props),\n changes: { onIndexChange: { event: \"index-change\", prop: \"index\" } },\n parts: {\n root: (controller) => controller.root,\n viewport: (controller) => controller.viewport,\n // A slide with no `kui-index` is counted from the page, and made once for its element.\n item: (controller, element) =>\n once(slides, element, () =>\n controller.item(element.hasAttribute(\"kui-index\") ? indexOf(element) : undefined)\n ),\n previous: (controller) => controller.previous,\n next: (controller) => controller.next,\n indicator: (controller, element) => controller.indicator(indexOf(element)),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-carousel\": ElementOf<typeof tag, { \"index-change\": [\"onIndexChange\", \"index\"] }>\n }\n}\n"],"mappings":";;;;AAQA,MAAM,WAAW,YAAyB,OAAO,QAAQ,aAAa,WAAW,KAAK,CAAC;AACvF,MAAM,yBAAS,IAAI,QAA2B;;;;;;AAO9C,MAAa,MAAM,cAAuC;CACxD,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,iBAAiB;EAAU,aAAa;EAAU,MAAM;CAAU;CAC5F,SAAS,UAAU,eAAe,KAAK;CACvC,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EAErC,OAAO,YAAY,YACjB,KAAK,QAAQ,eACX,WAAW,KAAK,QAAQ,aAAa,WAAW,IAAI,QAAQ,OAAO,IAAI,KAAA,CAAS,CAClF;EACF,WAAW,eAAe,WAAW;EACrC,OAAO,eAAe,WAAW;EACjC,YAAY,YAAY,YAAY,WAAW,UAAU,QAAQ,OAAO,CAAC;CAC3E;AACF,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { ColorPicker, ColorPickerProps } from "@kirana-ui/core/color-picker";
3
+ /**
4
+ * `<kui-color-picker>` around `kui-part="root"`, which holds an `area` with its `area-thumb`,
5
+ * a `channel-slider` for each channel it moves (`kui-channel`: `hue` or `alpha`, and
6
+ * `kui-orientation`) holding its `channel-slider-track` and `channel-slider-thumb`, a
7
+ * `channel-input` for each channel typed in (`kui-channel`: `hex`, `red`, `green`, `blue`,
8
+ * `hue`, `saturation`, `lightness`, `alpha`), `swatch`es, `swatch-trigger` buttons for presets
9
+ * (`kui-value`), an `eye-dropper-trigger`, a `value-text` that says the colour and a
10
+ * `format-trigger` that says its format, each unless the page wrote something. The root draws
11
+ * the hidden input a form reads, as its last child. `value`, `default-value`, `format`,
12
+ * `default-format`, `alpha`, `thumb-alignment`, `disabled`, `read-only`, `required`, `name`,
13
+ * `form`; `getAriaValueText` as a property. It tells `value-change`, `value-committed` and
14
+ * `format-change`.
15
+ */
16
+ export declare const tag: Tag<ColorPickerProps & {
17
+ id: string;
18
+ }, ColorPicker>;
19
+ declare global {
20
+ interface HTMLElementTagNameMap {
21
+ "kui-color-picker": ElementOf<typeof tag, {
22
+ "value-change": ["onValueChange", "value"];
23
+ "value-committed": ["onValueCommitted", "value"];
24
+ "format-change": ["onFormatChange", "format"];
25
+ }>;
26
+ }
27
+ }
28
+ //# sourceMappingURL=color-picker.d.ts.map