@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
@@ -1,15 +1,16 @@
1
- import { once, place, valueOf } from "./around.js";
1
+ import { once, ownValue, positioner } from "./around.js";
2
2
  import { defineElement, partAround } from "./runtime.js";
3
3
  import { computed } from "@kirana-ui/core";
4
4
  import { createNavigationMenu } from "@kirana-ui/core/navigation-menu";
5
5
  // src/navigation-menu.ts
6
6
  const NOTHING = computed(() => ({}));
7
7
  const items = /* @__PURE__ */ new WeakMap();
8
- const itemOf = (controller, element) => once(items, partAround(element, "item"), (item) => controller.item(valueOf(item)));
8
+ const itemOf = (controller, element) => once(items, partAround(element, "item"), (item) => controller.item(item.getAttribute("kui-value") ?? ownValue(item)));
9
9
  /**
10
- * `<kui-navigation-menu>` around a `kui-part="root"` nav with its `list`. An `item` with a
11
- * `kui-value` has a `trigger` (with an `icon` if it has one) and a `content`, which is drawn
12
- * in the menu's one `viewport` while its item is open; a `link` is a link (`kui-active`,
10
+ * `<kui-navigation-menu>` around a `kui-part="root"` nav with its `list`. An `item` has a
11
+ * `trigger` (with an `icon` if it has one) and a `content`, which is drawn in the menu's one
12
+ * `viewport` while its item is open; its `kui-value` tells it from the others, and an item
13
+ * that is given none makes its own. A `link` is a link (`kui-active`,
13
14
  * `kui-close-on-click="false"`). The viewport is in a `portal` with a `positioner` around
14
15
  * the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,
15
16
  * `delay`, `close-delay`, `orientation`; it tells `value-change`.
@@ -32,7 +33,6 @@ const tag = defineElement({
32
33
  root: (controller) => controller.root,
33
34
  list: (controller) => controller.list,
34
35
  item(controller, element) {
35
- if (!element.hasAttribute("kui-value")) return void 0;
36
36
  const item = itemOf(controller, element);
37
37
  return {
38
38
  part: {
@@ -56,13 +56,7 @@ const tag = defineElement({
56
56
  ...element.hasAttribute("kui-active") ? { active: true } : {},
57
57
  ...element.hasAttribute("kui-close-on-click") ? { closeOnClick: element.getAttribute("kui-close-on-click") !== "false" } : {}
58
58
  })),
59
- positioner(controller, element) {
60
- place(controller.positioning, element);
61
- return {
62
- mounted: controller.mounted,
63
- part: controller.positioner
64
- };
65
- },
59
+ positioner,
66
60
  popup: (controller) => controller.popup,
67
61
  viewport: (controller) => controller.viewport,
68
62
  arrow: (controller) => controller.arrow,
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/web/src/navigation-menu.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\n\nimport { once, place, valueOf } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\n\nconst NOTHING = computed(() => ({}))\nconst items = new WeakMap<HTMLElement, NavigationMenuItem>()\nconst itemOf = (controller: NavigationMenu<string>, element: HTMLElement) =>\n once(items, partAround(element, \"item\"), (item) => controller.item(valueOf(item)))\n\n/**\n * `<kui-navigation-menu>` around a `kui-part=\"root\"` nav with its `list`. An `item` with a\n * `kui-value` has a `trigger` (with an `icon` if it has one) and a `content`, which is drawn\n * in the menu's one `viewport` while its item is open; a `link` is a link (`kui-active`,\n * `kui-close-on-click=\"false\"`). The viewport is in a `portal` with a `positioner` around\n * the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,\n * `delay`, `close-delay`, `orientation`; it tells `value-change`.\n */\nexport const tag = defineElement<NavigationMenuProps<string>, NavigationMenu<string>>({\n tag: \"kui-navigation-menu\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n delay: \"number\",\n \"close-delay\": \"number\",\n orientation: \"string\",\n },\n create: (props) => createNavigationMenu<string>(props),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n list: (controller) => controller.list,\n // An item with no value holds a link: it is the page's own element, and no part.\n item(controller, element) {\n if (!element.hasAttribute(\"kui-value\")) return undefined\n const item = itemOf(controller, element)!\n return { part: { props: NOTHING, attach: () => () => {} }, mount: () => item.mount() }\n },\n trigger: (controller, element) => itemOf(controller, element)?.trigger,\n icon: (controller, element) => itemOf(controller, element)?.icon,\n content(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.content, mounted: item.mounted, into: controller.viewportElement }\n },\n link: (controller, element) =>\n controller.link(() => ({\n ...(element.hasAttribute(\"kui-active\") ? { active: true } : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n })),\n positioner(controller, element) {\n place(controller.positioning, element)\n return { mounted: controller.mounted, part: controller.positioner }\n },\n popup: (controller) => controller.popup,\n viewport: (controller) => controller.viewport,\n arrow: (controller) => controller.arrow,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n },\n})\n"],"mappings":";;;;;AAWA,MAAM,UAAU,gBAAgB,CAAC,EAAE;AACnC,MAAM,wBAAQ,IAAI,QAAyC;AAC3D,MAAM,UAAU,YAAoC,YAClD,KAAK,OAAO,WAAW,SAAS,MAAM,IAAI,SAAS,WAAW,KAAK,QAAQ,IAAI,CAAC,CAAC;;;;;;;;;AAUnF,MAAa,MAAM,cAAmE;CACpF,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,OAAO;EACP,eAAe;EACf,aAAa;CACf;CACA,SAAS,UAAU,qBAA6B,KAAK;CACrD,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,eAAe,WAAW;EAEjC,KAAK,YAAY,SAAS;GACxB,IAAI,CAAC,QAAQ,aAAa,WAAW,GAAG,OAAO,KAAA;GAC/C,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO;IAAE,MAAM;KAAE,OAAO;KAAS,oBAAoB,CAAC;IAAE;IAAG,aAAa,KAAK,MAAM;GAAE;EACvF;EACA,UAAU,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC/D,OAAO,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC5D,QAAQ,YAAY,SAAS;GAC3B,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAS,SAAS,KAAK;IAAS,MAAM,WAAW;GAAgB;EAC/F;EACA,OAAO,YAAY,YACjB,WAAW,YAAY;GACrB,GAAI,QAAQ,aAAa,YAAY,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;GAC7D,GAAI,QAAQ,aAAa,oBAAoB,IACzC,EAAE,cAAc,QAAQ,aAAa,oBAAoB,MAAM,QAAQ,IACvE,CAAC;EACP,EAAE;EACJ,WAAW,YAAY,SAAS;GAC9B,MAAM,WAAW,aAAa,OAAO;GACrC,OAAO;IAAE,SAAS,WAAW;IAAS,MAAM,WAAW;GAAW;EACpE;EACA,QAAQ,eAAe,WAAW;EAClC,WAAW,eAAe,WAAW;EACrC,QAAQ,eAAe,WAAW;EAClC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;CACtF;AACF,CAAC"}
1
+ {"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/web/src/navigation-menu.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\n\nimport { once, ownValue, positioner } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst NOTHING = computed(() => ({}))\nconst items = new WeakMap<HTMLElement, NavigationMenuItem>()\nconst itemOf = (controller: NavigationMenu<string>, element: HTMLElement) =>\n once(items, partAround(element, \"item\"), (item) =>\n controller.item(item.getAttribute(\"kui-value\") ?? ownValue(item))\n )\n\n/**\n * `<kui-navigation-menu>` around a `kui-part=\"root\"` nav with its `list`. An `item` has a\n * `trigger` (with an `icon` if it has one) and a `content`, which is drawn in the menu's one\n * `viewport` while its item is open; its `kui-value` tells it from the others, and an item\n * that is given none makes its own. A `link` is a link (`kui-active`,\n * `kui-close-on-click=\"false\"`). The viewport is in a `portal` with a `positioner` around\n * the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,\n * `delay`, `close-delay`, `orientation`; it tells `value-change`.\n */\nexport const tag = defineElement<NavigationMenuProps<string>, NavigationMenu<string>>({\n tag: \"kui-navigation-menu\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n delay: \"number\",\n \"close-delay\": \"number\",\n orientation: \"string\",\n },\n create: (props) => createNavigationMenu<string>(props),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n list: (controller) => controller.list,\n // The item's own element takes nothing: it is where the item is in the page.\n item(controller, element) {\n const item = itemOf(controller, element)!\n return { part: { props: NOTHING, attach: () => () => {} }, mount: () => item.mount() }\n },\n trigger: (controller, element) => itemOf(controller, element)?.trigger,\n icon: (controller, element) => itemOf(controller, element)?.icon,\n content(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.content, mounted: item.mounted, into: controller.viewportElement }\n },\n link: (controller, element) =>\n controller.link(() => ({\n ...(element.hasAttribute(\"kui-active\") ? { active: true } : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n })),\n positioner,\n popup: (controller) => controller.popup,\n viewport: (controller) => controller.viewport,\n arrow: (controller) => controller.arrow,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-navigation-menu\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }> &\n Placed\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,UAAU,gBAAgB,CAAC,EAAE;AACnC,MAAM,wBAAQ,IAAI,QAAyC;AAC3D,MAAM,UAAU,YAAoC,YAClD,KAAK,OAAO,WAAW,SAAS,MAAM,IAAI,SACxC,WAAW,KAAK,KAAK,aAAa,WAAW,KAAK,SAAS,IAAI,CAAC,CAClE;;;;;;;;;;AAWF,MAAa,MAAM,cAAmE;CACpF,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,OAAO;EACP,eAAe;EACf,aAAa;CACf;CACA,SAAS,UAAU,qBAA6B,KAAK;CACrD,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,eAAe,WAAW;EAEjC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO;IAAE,MAAM;KAAE,OAAO;KAAS,oBAAoB,CAAC;IAAE;IAAG,aAAa,KAAK,MAAM;GAAE;EACvF;EACA,UAAU,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC/D,OAAO,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC5D,QAAQ,YAAY,SAAS;GAC3B,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAS,SAAS,KAAK;IAAS,MAAM,WAAW;GAAgB;EAC/F;EACA,OAAO,YAAY,YACjB,WAAW,YAAY;GACrB,GAAI,QAAQ,aAAa,YAAY,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;GAC7D,GAAI,QAAQ,aAAa,oBAAoB,IACzC,EAAE,cAAc,QAAQ,aAAa,oBAAoB,MAAM,QAAQ,IACvE,CAAC;EACP,EAAE;EACJ;EACA,QAAQ,eAAe,WAAW;EAClC,WAAW,eAAe,WAAW;EACrC,QAAQ,eAAe,WAAW;EAClC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;CACtF;AACF,CAAC"}
@@ -1,9 +1,24 @@
1
+ import { As, ElementOf, Tag } from "./runtime.js";
2
+ import { NumberFieldProps } from "@kirana-ui/core/number-field";
1
3
  /**
2
4
  * `<kui-number-field>` around `kui-part="root"`, a `group`, an `input`, and `increment` and
3
- * `decrement` buttons. With a name, the root draws the hidden input a form reads. `value`,
4
- * `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
5
+ * `decrement` buttons. With a name, the root draws the hidden input a form reads. A
6
+ * `scrub-area` (a label, as a rule) is pressed and dragged to change the number, with
7
+ * `kui-direction="vertical"`, `kui-pixel-sensitivity` and `kui-teleport-distance` on it; a
8
+ * `scrub-area-cursor` inside it is drawn at the end of the page while the pointer is locked.
9
+ * `value`, `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
5
10
  * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`
6
11
  * as a property; it tells `value-change` and `value-committed`.
7
12
  */
8
- export declare const tag: string;
13
+ export declare const tag: Tag<{
14
+ id: string;
15
+ }, import("@kirana-ui/core/number-field").NumberField>;
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ "kui-number-field": ElementOf<As<typeof tag, NumberFieldProps>, {
19
+ "value-change": ["onValueChange", "value"];
20
+ "value-committed": ["onValueCommitted", "value"];
21
+ }>;
22
+ }
23
+ }
9
24
  //# sourceMappingURL=number-field.d.ts.map
@@ -1,11 +1,16 @@
1
1
  import { fieldAround } from "./around.js";
2
2
  import { defineElement } from "./runtime.js";
3
+ import { signal } from "@kirana-ui/core";
3
4
  import { createNumberField } from "@kirana-ui/core/number-field";
4
5
  // src/number-field.ts
6
+ const number = (text) => text === null ? void 0 : Number(text);
5
7
  /**
6
8
  * `<kui-number-field>` around `kui-part="root"`, a `group`, an `input`, and `increment` and
7
- * `decrement` buttons. With a name, the root draws the hidden input a form reads. `value`,
8
- * `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
9
+ * `decrement` buttons. With a name, the root draws the hidden input a form reads. A
10
+ * `scrub-area` (a label, as a rule) is pressed and dragged to change the number, with
11
+ * `kui-direction="vertical"`, `kui-pixel-sensitivity` and `kui-teleport-distance` on it; a
12
+ * `scrub-area-cursor` inside it is drawn at the end of the page while the pointer is locked.
13
+ * `value`, `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
9
14
  * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`
10
15
  * as a property; it tells `value-change` and `value-committed`.
11
16
  */
@@ -49,7 +54,22 @@ const tag = defineElement({
49
54
  group: (controller) => controller.group,
50
55
  input: (controller) => controller.input,
51
56
  increment: (controller) => controller.increment,
52
- decrement: (controller) => controller.decrement
57
+ decrement: (controller) => controller.decrement,
58
+ "scrub-area"(controller, element) {
59
+ const direction = element.getAttribute("kui-direction");
60
+ const pixelSensitivity = number(element.getAttribute("kui-pixel-sensitivity"));
61
+ const teleportDistance = number(element.getAttribute("kui-teleport-distance"));
62
+ controller.scrub.set({
63
+ ...direction === "vertical" || direction === "horizontal" ? { direction } : {},
64
+ ...pixelSensitivity === void 0 ? {} : { pixelSensitivity },
65
+ ...teleportDistance === void 0 ? {} : { teleportDistance }
66
+ });
67
+ return controller.scrubArea;
68
+ },
69
+ "scrub-area-cursor": (controller, element) => ({
70
+ ...controller.scrubAreaCursor,
71
+ into: signal(element.ownerDocument.body)
72
+ })
53
73
  }
54
74
  });
55
75
  export { tag };
@@ -1 +1 @@
1
- {"version":3,"file":"number-field.js","names":[],"sources":["../../../../packages/web/src/number-field.ts"],"sourcesContent":["import { createNumberField } from \"@kirana-ui/core/number-field\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\n\n/**\n * `<kui-number-field>` around `kui-part=\"root\"`, a `group`, an `input`, and `increment` and\n * `decrement` buttons. With a name, the root draws the hidden input a form reads. `value`,\n * `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,\n * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`\n * as a property; it tells `value-change` and `value-committed`.\n */\nexport const tag = defineElement({\n tag: \"kui-number-field\",\n props: {\n value: \"number\",\n \"default-value\": \"number\",\n min: \"number\",\n max: \"number\",\n step: \"number\",\n \"small-step\": \"number\",\n \"large-step\": \"number\",\n \"snap-on-step\": \"boolean\",\n \"allow-wheel-scrub\": \"boolean\",\n locale: \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"format\"],\n create: (props, host) => createNumberField(props, { field: fieldAround(host) }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValueCommitted: { event: \"value-committed\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) =>\n controller.named.peek()\n ? { part: controller.root, inner: controller.hidden }\n : controller.root,\n group: (controller) => controller.group,\n input: (controller) => controller.input,\n increment: (controller) => controller.increment,\n decrement: (controller) => controller.decrement,\n },\n})\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,KAAK;EACL,KAAK;EACL,MAAM;EACN,cAAc;EACd,cAAc;EACd,gBAAgB;EAChB,qBAAqB;EACrB,QAAQ;EACR,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,QAAQ;CACrB,SAAS,OAAO,SAAS,kBAAkB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CAC9E,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,kBAAkB;GAAE,OAAO;GAAmB,MAAM;GAAS,MAAM;EAAM;CAC3E;CACA,OAAO;EACL,OAAO,eACL,WAAW,MAAM,KAAK,IAClB;GAAE,MAAM,WAAW;GAAM,OAAO,WAAW;EAAO,IAClD,WAAW;EACjB,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,YAAY,eAAe,WAAW;CACxC;AACF,CAAC"}
1
+ {"version":3,"file":"number-field.js","names":[],"sources":["../../../../packages/web/src/number-field.ts"],"sourcesContent":["import { signal } from \"@kirana-ui/core\"\nimport { createNumberField } from \"@kirana-ui/core/number-field\"\nimport type { NumberFieldProps } from \"@kirana-ui/core/number-field\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\nconst number = (text: string | null) => (text === null ? undefined : Number(text))\n\n/**\n * `<kui-number-field>` around `kui-part=\"root\"`, a `group`, an `input`, and `increment` and\n * `decrement` buttons. With a name, the root draws the hidden input a form reads. A\n * `scrub-area` (a label, as a rule) is pressed and dragged to change the number, with\n * `kui-direction=\"vertical\"`, `kui-pixel-sensitivity` and `kui-teleport-distance` on it; a\n * `scrub-area-cursor` inside it is drawn at the end of the page while the pointer is locked.\n * `value`, `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,\n * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`\n * as a property; it tells `value-change` and `value-committed`.\n */\nexport const tag = defineElement({\n tag: \"kui-number-field\",\n props: {\n value: \"number\",\n \"default-value\": \"number\",\n min: \"number\",\n max: \"number\",\n step: \"number\",\n \"small-step\": \"number\",\n \"large-step\": \"number\",\n \"snap-on-step\": \"boolean\",\n \"allow-wheel-scrub\": \"boolean\",\n locale: \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"format\"],\n create: (props, host) => createNumberField(props, { field: fieldAround(host) }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValueCommitted: { event: \"value-committed\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) =>\n controller.named.peek()\n ? { part: controller.root, inner: controller.hidden }\n : controller.root,\n group: (controller) => controller.group,\n input: (controller) => controller.input,\n increment: (controller) => controller.increment,\n decrement: (controller) => controller.decrement,\n \"scrub-area\"(controller, element) {\n const direction = element.getAttribute(\"kui-direction\")\n const pixelSensitivity = number(element.getAttribute(\"kui-pixel-sensitivity\"))\n const teleportDistance = number(element.getAttribute(\"kui-teleport-distance\"))\n controller.scrub.set({\n ...(direction === \"vertical\" || direction === \"horizontal\" ? { direction } : {}),\n ...(pixelSensitivity === undefined ? {} : { pixelSensitivity }),\n ...(teleportDistance === undefined ? {} : { teleportDistance }),\n })\n return controller.scrubArea\n },\n // Not where it was written: at the end of the page, over everything.\n \"scrub-area-cursor\": (controller, element) => ({\n ...controller.scrubAreaCursor,\n into: signal(element.ownerDocument.body),\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-number-field\": ElementOf<\n As<typeof tag, NumberFieldProps>,\n {\n \"value-change\": [\"onValueChange\", \"value\"]\n \"value-committed\": [\"onValueCommitted\", \"value\"]\n }\n >\n }\n}\n"],"mappings":";;;;;AAQA,MAAM,UAAU,SAAyB,SAAS,OAAO,KAAA,IAAY,OAAO,IAAI;;;;;;;;;;;AAYhF,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,KAAK;EACL,KAAK;EACL,MAAM;EACN,cAAc;EACd,cAAc;EACd,gBAAgB;EAChB,qBAAqB;EACrB,QAAQ;EACR,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,QAAQ;CACrB,SAAS,OAAO,SAAS,kBAAkB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CAC9E,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,kBAAkB;GAAE,OAAO;GAAmB,MAAM;GAAS,MAAM;EAAM;CAC3E;CACA,OAAO;EACL,OAAO,eACL,WAAW,MAAM,KAAK,IAClB;GAAE,MAAM,WAAW;GAAM,OAAO,WAAW;EAAO,IAClD,WAAW;EACjB,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,YAAY,eAAe,WAAW;EACtC,aAAa,YAAY,SAAS;GAChC,MAAM,YAAY,QAAQ,aAAa,eAAe;GACtD,MAAM,mBAAmB,OAAO,QAAQ,aAAa,uBAAuB,CAAC;GAC7E,MAAM,mBAAmB,OAAO,QAAQ,aAAa,uBAAuB,CAAC;GAC7E,WAAW,MAAM,IAAI;IACnB,GAAI,cAAc,cAAc,cAAc,eAAe,EAAE,UAAU,IAAI,CAAC;IAC9E,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;IAC7D,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;GAC/D,CAAC;GACD,OAAO,WAAW;EACpB;EAEA,sBAAsB,YAAY,aAAa;GAC7C,GAAG,WAAW;GACd,MAAM,OAAO,QAAQ,cAAc,IAAI;EACzC;CACF;AACF,CAAC"}
package/src/otp.d.ts CHANGED
@@ -1,9 +1,19 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { Otp, OtpProps } from "@kirana-ui/core/otp";
1
3
  /**
2
4
  * `<kui-otp>` around `kui-part="root"`, the one `input` that is typed in, and a `slot` for
3
5
  * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in
4
6
  * the page while the next character goes there. Slots may be in `group`s with a `separator`
5
- * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells
7
+ * between. `length`, `value`, `default-value`, `mode`, `pattern`, `disabled`, `name`, `form`; it tells
6
8
  * `value-change` and `complete`.
7
9
  */
8
- export declare const tag: string;
10
+ export declare const tag: Tag<OtpProps, Otp>;
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ "kui-otp": ElementOf<typeof tag, {
14
+ "value-change": ["onValueChange", "value"];
15
+ complete: ["onComplete", "value"];
16
+ }>;
17
+ }
18
+ }
9
19
  //# sourceMappingURL=otp.d.ts.map
package/src/otp.js CHANGED
@@ -7,7 +7,7 @@ const indexOf = (element) => Number(element?.getAttribute("kui-index") ?? 0);
7
7
  * `<kui-otp>` around `kui-part="root"`, the one `input` that is typed in, and a `slot` for
8
8
  * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in
9
9
  * the page while the next character goes there. Slots may be in `group`s with a `separator`
10
- * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells
10
+ * between. `length`, `value`, `default-value`, `mode`, `pattern`, `disabled`, `name`, `form`; it tells
11
11
  * `value-change` and `complete`.
12
12
  */
13
13
  const tag = defineElement({
@@ -17,6 +17,7 @@ const tag = defineElement({
17
17
  value: "string",
18
18
  "default-value": "string",
19
19
  mode: "string",
20
+ pattern: "string",
20
21
  disabled: "boolean",
21
22
  name: "string",
22
23
  form: "string"
package/src/otp.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement | null) => Number(element?.getAttribute(\"kui-index\") ?? 0)\n\n/**\n * `<kui-otp>` around `kui-part=\"root\"`, the one `input` that is typed in, and a `slot` for\n * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in\n * the page while the next character goes there. Slots may be in `group`s with a `separator`\n * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells\n * `value-change` and `complete`.\n */\nexport const tag = defineElement<OtpProps, Otp>({\n tag: \"kui-otp\",\n props: {\n length: \"number\",\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n disabled: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props) => createOtp(props),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onComplete: { event: \"complete\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n group: (controller) => controller.group,\n separator: (controller) => controller.separator,\n slot(controller, element) {\n const slot = controller.slot(indexOf(element))\n return {\n part: slot.part,\n // Its character comes before what the page wrote in it: a caret.\n mount() {\n const text = element.ownerDocument.createTextNode(\"\")\n element.prepend(text)\n const stop = effect(() => void (text.data = slot.char.get()))\n return () => {\n stop()\n text.remove()\n }\n },\n }\n },\n caret: (controller, element) => ({\n part: controller.caretPart,\n mounted: controller.slot(indexOf(partAround(element, \"slot\"))).caret,\n }),\n },\n})\n"],"mappings":";;;;AAMA,MAAM,WAAW,YAAgC,OAAO,SAAS,aAAa,WAAW,KAAK,CAAC;;;;;;;;AAS/F,MAAa,MAAM,cAA6B;CAC9C,KAAK;CACL,OAAO;EACL,QAAQ;EACR,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,UAAU,UAAU,KAAK;CAClC,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,YAAY;GAAE,OAAO;GAAY,MAAM;GAAS,MAAM;EAAM;CAC9D;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,WAAW,KAAK,QAAQ,OAAO,CAAC;GAC7C,OAAO;IACL,MAAM,KAAK;IAEX,QAAQ;KACN,MAAM,OAAO,QAAQ,cAAc,eAAe,EAAE;KACpD,QAAQ,QAAQ,IAAI;KACpB,MAAM,OAAO,aAAa,MAAM,KAAK,OAAO,KAAK,KAAK,IAAI,EAAE;KAC5D,aAAa;MACX,KAAK;MACL,KAAK,OAAO;KACd;IACF;GACF;EACF;EACA,QAAQ,YAAY,aAAa;GAC/B,MAAM,WAAW;GACjB,SAAS,WAAW,KAAK,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC,CAAC,CAAC;EACjE;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement | null) => Number(element?.getAttribute(\"kui-index\") ?? 0)\n\n/**\n * `<kui-otp>` around `kui-part=\"root\"`, the one `input` that is typed in, and a `slot` for\n * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in\n * the page while the next character goes there. Slots may be in `group`s with a `separator`\n * between. `length`, `value`, `default-value`, `mode`, `pattern`, `disabled`, `name`, `form`; it tells\n * `value-change` and `complete`.\n */\nexport const tag = defineElement<OtpProps, Otp>({\n tag: \"kui-otp\",\n props: {\n length: \"number\",\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n pattern: \"string\",\n disabled: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props) => createOtp(props),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onComplete: { event: \"complete\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n group: (controller) => controller.group,\n separator: (controller) => controller.separator,\n slot(controller, element) {\n const slot = controller.slot(indexOf(element))\n return {\n part: slot.part,\n // Its character comes before what the page wrote in it: a caret.\n mount() {\n const text = element.ownerDocument.createTextNode(\"\")\n element.prepend(text)\n const stop = effect(() => void (text.data = slot.char.get()))\n return () => {\n stop()\n text.remove()\n }\n },\n }\n },\n caret: (controller, element) => ({\n part: controller.caretPart,\n mounted: controller.slot(indexOf(partAround(element, \"slot\"))).caret,\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-otp\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; complete: [\"onComplete\", \"value\"] }\n >\n }\n}\n"],"mappings":";;;;AAOA,MAAM,WAAW,YAAgC,OAAO,SAAS,aAAa,WAAW,KAAK,CAAC;;;;;;;;AAS/F,MAAa,MAAM,cAA6B;CAC9C,KAAK;CACL,OAAO;EACL,QAAQ;EACR,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,SAAS;EACT,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,UAAU,UAAU,KAAK;CAClC,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,YAAY;GAAE,OAAO;GAAY,MAAM;GAAS,MAAM;EAAM;CAC9D;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,WAAW,KAAK,QAAQ,OAAO,CAAC;GAC7C,OAAO;IACL,MAAM,KAAK;IAEX,QAAQ;KACN,MAAM,OAAO,QAAQ,cAAc,eAAe,EAAE;KACpD,QAAQ,QAAQ,IAAI;KACpB,MAAM,OAAO,aAAa,MAAM,KAAK,OAAO,KAAK,KAAK,IAAI,EAAE;KAC5D,aAAa;MACX,KAAK;MACL,KAAK,OAAO;KACd;IACF;GACF;EACF;EACA,QAAQ,YAAY,aAAa;GAC/B,MAAM,WAAW;GACjB,SAAS,WAAW,KAAK,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC,CAAC,CAAC;EACjE;CACF;AACF,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { Pagination, PaginationProps } from "@kirana-ui/core/pagination";
1
3
  /**
2
4
  * `<kui-pagination>` around a `kui-part="root"` nav with `previous` and `next` buttons and,
3
5
  * between them, a `<template kui-each="items">` holding an `item` button for a page
@@ -5,5 +7,12 @@
5
7
  * (`kui-when="ellipsis"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,
6
8
  * `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.
7
9
  */
8
- export declare const tag: string;
10
+ export declare const tag: Tag<PaginationProps, Pagination>;
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ "kui-pagination": ElementOf<typeof tag, {
14
+ "page-change": ["onPageChange", "page"];
15
+ }>;
16
+ }
17
+ }
9
18
  //# sourceMappingURL=pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/web/src/pagination.ts"],"sourcesContent":["import { createPagination } from \"@kirana-ui/core/pagination\"\nimport type { Pagination, PaginationEntry, PaginationProps } from \"@kirana-ui/core/pagination\"\n\nimport { defineElement, entryAround } from \"./runtime.ts\"\n\n/**\n * `<kui-pagination>` around a `kui-part=\"root\"` nav with `previous` and `next` buttons and,\n * between them, a `<template kui-each=\"items\">` holding an `item` button for a page\n * (`kui-when=\"page\"`; `{page}` is its number) and an `ellipsis` for a gap\n * (`kui-when=\"ellipsis\"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,\n * `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.\n */\nexport const tag = defineElement<PaginationProps, Pagination>({\n tag: \"kui-pagination\",\n props: {\n page: \"number\",\n \"default-page\": \"number\",\n count: \"number\",\n \"page-size\": \"number\",\n \"sibling-count\": \"number\",\n \"boundary-count\": \"number\",\n disabled: \"boolean\",\n },\n create: (props) => createPagination(props),\n changes: { onPageChange: { event: \"page-change\", prop: \"page\" } },\n lists: {\n items: (controller) => ({\n entries: controller.entries,\n key: (entry: PaginationEntry) => entry.key,\n type: (entry: PaginationEntry) => entry.type,\n }),\n },\n parts: {\n root: (controller) => controller.root,\n previous: (controller) => controller.previous,\n next: (controller) => controller.next,\n ellipsis: (controller) => controller.ellipsis,\n item(controller, element) {\n const entry = entryAround<PaginationEntry>(element)\n return entry?.type === \"page\" ? controller.item(entry.page) : undefined\n },\n },\n})\n"],"mappings":";;;;;;;;;;AAYA,MAAa,MAAM,cAA2C;CAC5D,KAAK;CACL,OAAO;EACL,MAAM;EACN,gBAAgB;EAChB,OAAO;EACP,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,UAAU;CACZ;CACA,SAAS,UAAU,iBAAiB,KAAK;CACzC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO,EACL,QAAQ,gBAAgB;EACtB,SAAS,WAAW;EACpB,MAAM,UAA2B,MAAM;EACvC,OAAO,UAA2B,MAAM;CAC1C,GACF;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,KAAK,YAAY,SAAS;GACxB,MAAM,QAAQ,YAA6B,OAAO;GAClD,OAAO,OAAO,SAAS,SAAS,WAAW,KAAK,MAAM,IAAI,IAAI,KAAA;EAChE;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"pagination.js","names":[],"sources":["../../../../packages/web/src/pagination.ts"],"sourcesContent":["import { createPagination } from \"@kirana-ui/core/pagination\"\nimport type { Pagination, PaginationEntry, PaginationProps } from \"@kirana-ui/core/pagination\"\n\nimport { defineElement, entryAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-pagination>` around a `kui-part=\"root\"` nav with `previous` and `next` buttons and,\n * between them, a `<template kui-each=\"items\">` holding an `item` button for a page\n * (`kui-when=\"page\"`; `{page}` is its number) and an `ellipsis` for a gap\n * (`kui-when=\"ellipsis\"`; `{key}` is `start` or `end`). `page`, `default-page`, `count`,\n * `page-size`, `sibling-count`, `boundary-count`, `disabled`; it tells `page-change`.\n */\nexport const tag = defineElement<PaginationProps, Pagination>({\n tag: \"kui-pagination\",\n props: {\n page: \"number\",\n \"default-page\": \"number\",\n count: \"number\",\n \"page-size\": \"number\",\n \"sibling-count\": \"number\",\n \"boundary-count\": \"number\",\n disabled: \"boolean\",\n },\n create: (props) => createPagination(props),\n changes: { onPageChange: { event: \"page-change\", prop: \"page\" } },\n lists: {\n items: (controller) => ({\n entries: controller.entries,\n key: (entry: PaginationEntry) => entry.key,\n type: (entry: PaginationEntry) => entry.type,\n }),\n },\n parts: {\n root: (controller) => controller.root,\n previous: (controller) => controller.previous,\n next: (controller) => controller.next,\n ellipsis: (controller) => controller.ellipsis,\n item(controller, element) {\n const entry = entryAround<PaginationEntry>(element)\n return entry?.type === \"page\" ? controller.item(entry.page) : undefined\n },\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-pagination\": ElementOf<typeof tag, { \"page-change\": [\"onPageChange\", \"page\"] }>\n }\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,MAAM,cAA2C;CAC5D,KAAK;CACL,OAAO;EACL,MAAM;EACN,gBAAgB;EAChB,OAAO;EACP,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,UAAU;CACZ;CACA,SAAS,UAAU,iBAAiB,KAAK;CACzC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO,EACL,QAAQ,gBAAgB;EACtB,SAAS,WAAW;EACpB,MAAM,UAA2B,MAAM;EACvC,OAAO,UAA2B,MAAM;CAC1C,GACF;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,OAAO,eAAe,WAAW;EACjC,WAAW,eAAe,WAAW;EACrC,KAAK,YAAY,SAAS;GACxB,MAAM,QAAQ,YAA6B,OAAO;GAClD,OAAO,OAAO,SAAS,SAAS,WAAW,KAAK,MAAM,IAAI,IAAI,KAAA;EAChE;CACF;AACF,CAAC"}
package/src/popover.d.ts CHANGED
@@ -1,8 +1,21 @@
1
+ import { As, ElementOf, Tag } from "./runtime.js";
2
+ import { Placed } from "./around.js";
3
+ import { Popover, PopoverProps } from "@kirana-ui/core/popover";
1
4
  /**
2
5
  * `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
3
6
  * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
4
- * `kui-align-offset`, `kui-collision-padding`) around the `popup`, which may hold a `title`,
5
- * a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
7
+ * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is
8
+ * placed against, when that is not the trigger) around the `popup`, which may hold an `arrow`,
9
+ * a `title`, a `description` and a `close` button; the portal may hold a `backdrop` too. The
10
+ * trigger takes `kui-open-on-hover`, with `kui-delay` and `kui-close-delay`. `open`,
11
+ * `default-open`, `modal` (there, or `"trap-focus"`); it tells `open-change`.
6
12
  */
7
- export declare const tag: string;
13
+ export declare const tag: Tag<PopoverProps, Popover>;
14
+ declare global {
15
+ interface HTMLElementTagNameMap {
16
+ "kui-popover": ElementOf<As<typeof tag, PopoverProps>, {
17
+ "open-change": ["onOpenChange", "open"];
18
+ }> & Placed;
19
+ }
20
+ }
8
21
  //# sourceMappingURL=popover.d.ts.map
package/src/popover.js CHANGED
@@ -1,34 +1,57 @@
1
- import { place } from "./around.js";
1
+ import { positioner } from "./around.js";
2
2
  import { defineElement } from "./runtime.js";
3
+ import { computed } from "@kirana-ui/core";
3
4
  import { createPopover } from "@kirana-ui/core/popover";
4
5
  // src/popover.ts
6
+ const number = (text) => text === null ? void 0 : Number(text);
7
+ /** `modal` as its attribute writes it: there or not, `"false"`, or `"trap-focus"`. */
8
+ const modalOf = (given) => given === "trap-focus" ? given : given !== void 0 && given !== false && given !== "false";
5
9
  /**
6
10
  * `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
7
11
  * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
8
- * `kui-align-offset`, `kui-collision-padding`) around the `popup`, which may hold a `title`,
9
- * a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
12
+ * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is
13
+ * placed against, when that is not the trigger) around the `popup`, which may hold an `arrow`,
14
+ * a `title`, a `description` and a `close` button; the portal may hold a `backdrop` too. The
15
+ * trigger takes `kui-open-on-hover`, with `kui-delay` and `kui-close-delay`. `open`,
16
+ * `default-open`, `modal` (there, or `"trap-focus"`); it tells `open-change`.
10
17
  */
11
18
  const tag = defineElement({
12
19
  tag: "kui-popover",
13
20
  props: {
14
21
  open: "boolean",
15
- "default-open": "boolean"
22
+ "default-open": "boolean",
23
+ modal: "string"
16
24
  },
17
- create: (props) => createPopover(props),
25
+ create: (props) => createPopover(computed(() => {
26
+ const own = props.get();
27
+ return {
28
+ ...own,
29
+ modal: modalOf(own.modal)
30
+ };
31
+ })),
18
32
  changes: { onOpenChange: {
19
33
  event: "open-change",
20
34
  prop: "open"
21
35
  } },
22
36
  parts: {
23
- trigger: (controller) => controller.trigger,
24
- positioner(controller, element) {
25
- place(controller.positioning, element);
26
- return {
27
- mounted: controller.mounted,
28
- part: controller.positioner
29
- };
37
+ trigger(controller, element) {
38
+ const delay = number(element.getAttribute("kui-delay"));
39
+ const closeDelay = number(element.getAttribute("kui-close-delay"));
40
+ const hover = element.getAttribute("kui-open-on-hover");
41
+ controller.hovering.set({
42
+ ...hover === null ? {} : { openOnHover: hover !== "false" },
43
+ ...delay === void 0 ? {} : { delay },
44
+ ...closeDelay === void 0 ? {} : { closeDelay }
45
+ });
46
+ return controller.trigger;
30
47
  },
48
+ backdrop: (controller) => ({
49
+ mounted: controller.mounted,
50
+ part: controller.backdrop
51
+ }),
52
+ positioner,
31
53
  popup: (controller) => controller.popup,
54
+ arrow: (controller) => controller.arrow,
32
55
  title: (controller) => controller.title,
33
56
  description: (controller) => controller.description,
34
57
  close: (controller) => controller.close
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/web/src/popover.ts"],"sourcesContent":["import { createPopover } from \"@kirana-ui/core/popover\"\n\nimport { place } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\n\n/**\n * `<kui-popover>` around a `kui-part=\"trigger\"` button and a `portal`, drawn at the end of the\n * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,\n * `kui-align-offset`, `kui-collision-padding`) around the `popup`, which may hold a `title`,\n * a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-popover\",\n props: { open: \"boolean\", \"default-open\": \"boolean\" },\n create: (props) => createPopover(props),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger: (controller) => controller.trigger,\n positioner(controller, element) {\n place(controller.positioning, element)\n return { mounted: controller.mounted, part: controller.positioner }\n },\n popup: (controller) => controller.popup,\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller) => controller.close,\n },\n})\n"],"mappings":";;;;;;;;;;AAWA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,MAAM;EAAW,gBAAgB;CAAU;CACpD,SAAS,UAAU,cAAc,KAAK;CACtC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,UAAU,eAAe,WAAW;EACpC,WAAW,YAAY,SAAS;GAC9B,MAAM,WAAW,aAAa,OAAO;GACrC,OAAO;IAAE,SAAS,WAAW;IAAS,MAAM,WAAW;GAAW;EACpE;EACA,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
1
+ {"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/web/src/popover.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover, PopoverProps } from \"@kirana-ui/core/popover\"\n\nimport { positioner } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\nconst number = (text: string | null) => (text === null ? undefined : Number(text))\n\n/** `modal` as its attribute writes it: there or not, `\"false\"`, or `\"trap-focus\"`. */\nconst modalOf = (given: unknown): PopoverProps[\"modal\"] =>\n given === \"trap-focus\" ? given : given !== undefined && given !== false && given !== \"false\"\n\n/**\n * `<kui-popover>` around a `kui-part=\"trigger\"` button and a `portal`, drawn at the end of the\n * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,\n * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is\n * placed against, when that is not the trigger) around the `popup`, which may hold an `arrow`,\n * a `title`, a `description` and a `close` button; the portal may hold a `backdrop` too. The\n * trigger takes `kui-open-on-hover`, with `kui-delay` and `kui-close-delay`. `open`,\n * `default-open`, `modal` (there, or `\"trap-focus\"`); it tells `open-change`.\n */\nexport const tag = defineElement<PopoverProps, Popover>({\n tag: \"kui-popover\",\n props: { open: \"boolean\", \"default-open\": \"boolean\", modal: \"string\" },\n create: (props) =>\n createPopover(\n computed(() => {\n const own = props.get()\n return { ...own, modal: modalOf(own.modal) }\n })\n ),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger(controller, element) {\n const delay = number(element.getAttribute(\"kui-delay\"))\n const closeDelay = number(element.getAttribute(\"kui-close-delay\"))\n const hover = element.getAttribute(\"kui-open-on-hover\")\n controller.hovering.set({\n ...(hover === null ? {} : { openOnHover: hover !== \"false\" }),\n ...(delay === undefined ? {} : { delay }),\n ...(closeDelay === undefined ? {} : { closeDelay }),\n })\n return controller.trigger\n },\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n positioner,\n popup: (controller) => controller.popup,\n arrow: (controller) => controller.arrow,\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-popover\": ElementOf<\n As<typeof tag, PopoverProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n > &\n Placed\n }\n}\n"],"mappings":";;;;;AASA,MAAM,UAAU,SAAyB,SAAS,OAAO,KAAA,IAAY,OAAO,IAAI;;AAGhF,MAAM,WAAW,UACf,UAAU,eAAe,QAAQ,UAAU,KAAA,KAAa,UAAU,SAAS,UAAU;;;;;;;;;;AAWvF,MAAa,MAAM,cAAqC;CACtD,KAAK;CACL,OAAO;EAAE,MAAM;EAAW,gBAAgB;EAAW,OAAO;CAAS;CACrE,SAAS,UACP,cACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,QAAQ,IAAI,KAAK;EAAE;CAC7C,CAAC,CACH;CACF,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,QAAQ,YAAY,SAAS;GAC3B,MAAM,QAAQ,OAAO,QAAQ,aAAa,WAAW,CAAC;GACtD,MAAM,aAAa,OAAO,QAAQ,aAAa,iBAAiB,CAAC;GACjE,MAAM,QAAQ,QAAQ,aAAa,mBAAmB;GACtD,WAAW,SAAS,IAAI;IACtB,GAAI,UAAU,OAAO,CAAC,IAAI,EAAE,aAAa,UAAU,QAAQ;IAC3D,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;IACvC,GAAI,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW;GACnD,CAAC;GACD,OAAO,WAAW;EACpB;EACA,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF;EACA,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
package/src/progress.d.ts CHANGED
@@ -1,7 +1,16 @@
1
+ import { As, ElementOf, Tag } from "./runtime.js";
2
+ import { ProgressProps } from "@kirana-ui/core/progress";
1
3
  /**
2
4
  * `<kui-progress>` around `kui-part="root"`, a `label`, a `track` with its `indicator`, and a
3
5
  * `value`, which says the value as it is written unless the page gave it something to say.
4
6
  * `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.
5
7
  */
6
- export declare const tag: string;
8
+ export declare const tag: Tag<{
9
+ id: string;
10
+ }, import("@kirana-ui/core/meter").ValueBar>;
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ "kui-progress": ElementOf<As<typeof tag, ProgressProps>>;
14
+ }
15
+ }
7
16
  //# sourceMappingURL=progress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/web/src/progress.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createProgress } from \"@kirana-ui/core/progress\"\n\nimport { defineElement } from \"./runtime.ts\"\n\n/**\n * `<kui-progress>` around `kui-part=\"root\"`, a `label`, a `track` with its `indicator`, and a\n * `value`, which says the value as it is written unless the page gave it something to say.\n * `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.\n */\nexport const tag = defineElement({\n tag: \"kui-progress\",\n props: { value: \"number\", min: \"number\", max: \"number\", locale: \"string\" },\n properties: [\"format\", \"getAriaValueText\"],\n create: (props) =>\n createProgress(\n computed(() => {\n const own = props.get() as { id: string; value?: number | null }\n return { ...own, value: own.value ?? null }\n }) as never\n ),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n label: (controller) => controller.label,\n track: (controller) => controller.track,\n indicator: (controller) => controller.indicator,\n value: (controller) => ({ part: controller.value, text: controller.text }),\n },\n})\n"],"mappings":";;;;;;;;;AAUA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,KAAK;EAAU,KAAK;EAAU,QAAQ;CAAS;CACzE,YAAY,CAAC,UAAU,kBAAkB;CACzC,SAAS,UACP,eACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,IAAI,SAAS;EAAK;CAC5C,CAAC,CACH;CACF,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,QAAQ,gBAAgB;GAAE,MAAM,WAAW;GAAO,MAAM,WAAW;EAAK;CAC1E;AACF,CAAC"}
1
+ {"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/web/src/progress.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createProgress } from \"@kirana-ui/core/progress\"\nimport type { ProgressProps } from \"@kirana-ui/core/progress\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-progress>` around `kui-part=\"root\"`, a `label`, a `track` with its `indicator`, and a\n * `value`, which says the value as it is written unless the page gave it something to say.\n * `value` (left out: not known yet), `min`, `max`, `locale`; `format` and `getAriaValueText` as properties.\n */\nexport const tag = defineElement({\n tag: \"kui-progress\",\n props: { value: \"number\", min: \"number\", max: \"number\", locale: \"string\" },\n properties: [\"format\", \"getAriaValueText\"],\n create: (props) =>\n createProgress(\n computed(() => {\n const own = props.get() as { id: string; value?: number | null }\n return { ...own, value: own.value ?? null }\n }) as never\n ),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n label: (controller) => controller.label,\n track: (controller) => controller.track,\n indicator: (controller) => controller.indicator,\n value: (controller) => ({ part: controller.value, text: controller.text }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-progress\": ElementOf<As<typeof tag, ProgressProps>>\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,KAAK;EAAU,KAAK;EAAU,QAAQ;CAAS;CACzE,YAAY,CAAC,UAAU,kBAAkB;CACzC,SAAS,UACP,eACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,IAAI,SAAS;EAAK;CAC5C,CAAC,CACH;CACF,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,QAAQ,gBAAgB;GAAE,MAAM,WAAW;GAAO,MAAM,WAAW;EAAK;CAC1E;AACF,CAAC"}
package/src/qr-code.d.ts CHANGED
@@ -1,6 +1,13 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { QrCode, QrCodeProps } from "@kirana-ui/core/qr-code";
1
3
  /**
2
4
  * `<kui-qr-code>` around `kui-part="root"`, a `frame` (an `<svg>`) and its `pattern` (a
3
5
  * `<path>`). `value`, `correction`.
4
6
  */
5
- export declare const tag: string;
7
+ export declare const tag: Tag<QrCodeProps, QrCode>;
8
+ declare global {
9
+ interface HTMLElementTagNameMap {
10
+ "kui-qr-code": ElementOf<typeof tag>;
11
+ }
12
+ }
6
13
  //# sourceMappingURL=qr-code.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/web/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode, QrCodeProps } from \"@kirana-ui/core/qr-code\"\n\nimport { defineElement } from \"./runtime.ts\"\n\n/**\n * `<kui-qr-code>` around `kui-part=\"root\"`, a `frame` (an `<svg>`) and its `pattern` (a\n * `<path>`). `value`, `correction`.\n */\nexport const tag = defineElement<QrCodeProps, QrCode>({\n tag: \"kui-qr-code\",\n props: { value: \"string\", correction: \"string\" },\n create: (props) => createQrCode(props),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n frame: (controller) => controller.frame,\n pattern: (controller) => controller.pattern,\n },\n})\n"],"mappings":";;;;;;;AASA,MAAa,MAAM,cAAmC;CACpD,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,YAAY;CAAS;CAC/C,SAAS,UAAU,aAAa,KAAK;CACrC,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,UAAU,eAAe,WAAW;CACtC;AACF,CAAC"}
1
+ {"version":3,"file":"qr-code.js","names":[],"sources":["../../../../packages/web/src/qr-code.ts"],"sourcesContent":["import { createQrCode } from \"@kirana-ui/core/qr-code\"\nimport type { QrCode, QrCodeProps } from \"@kirana-ui/core/qr-code\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-qr-code>` around `kui-part=\"root\"`, a `frame` (an `<svg>`) and its `pattern` (a\n * `<path>`). `value`, `correction`.\n */\nexport const tag = defineElement<QrCodeProps, QrCode>({\n tag: \"kui-qr-code\",\n props: { value: \"string\", correction: \"string\" },\n create: (props) => createQrCode(props),\n changes: {},\n parts: {\n root: (controller) => controller.root,\n frame: (controller) => controller.frame,\n pattern: (controller) => controller.pattern,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-qr-code\": ElementOf<typeof tag>\n }\n}\n"],"mappings":";;;;;;;AAUA,MAAa,MAAM,cAAmC;CACpD,KAAK;CACL,OAAO;EAAE,OAAO;EAAU,YAAY;CAAS;CAC/C,SAAS,UAAU,aAAa,KAAK;CACrC,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,UAAU,eAAe,WAAW;CACtC;AACF,CAAC"}
@@ -1,8 +1,18 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { RadioGroupProps } from "@kirana-ui/core/radio-group";
1
3
  /**
2
4
  * `<kui-radio-group>` around `kui-part="root"` and an `item` button for each `value`, with an
3
5
  * `indicator` inside that is in the page while its item is the chosen one. An item draws the
4
- * hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,
6
+ * hidden native radio a form and a label reach; an item's `kui-id` is that radio's id, which a
7
+ * `<label for>` names. `value`, `default-value`, `disabled`,
5
8
  * `read-only`, `required`, `name`, `form`; it tells `value-change`.
6
9
  */
7
- export declare const tag: string;
10
+ export declare const tag: Tag<RadioGroupProps<string>, import("@kirana-ui/core/radio-group").RadioGroup<string>>;
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ "kui-radio-group": ElementOf<typeof tag, {
14
+ "value-change": ["onValueChange", "value"];
15
+ }>;
16
+ }
17
+ }
8
18
  //# sourceMappingURL=radio-group.d.ts.map
@@ -3,11 +3,18 @@ import { defineElement, partAround } from "./runtime.js";
3
3
  import { createRadioGroup } from "@kirana-ui/core/radio-group";
4
4
  // src/radio-group.ts
5
5
  const valueOf = (element) => partAround(element, "item")?.getAttribute("kui-value") ?? "";
6
- const options = (element) => () => partAround(element, "item")?.hasAttribute("kui-disabled") ? { disabled: true } : {};
6
+ const options = (element) => () => {
7
+ const item = partAround(element, "item");
8
+ return {
9
+ disabled: item?.hasAttribute("kui-disabled") || void 0,
10
+ id: item?.getAttribute("kui-id") ?? void 0
11
+ };
12
+ };
7
13
  /**
8
14
  * `<kui-radio-group>` around `kui-part="root"` and an `item` button for each `value`, with an
9
15
  * `indicator` inside that is in the page while its item is the chosen one. An item draws the
10
- * hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,
16
+ * hidden native radio a form and a label reach; an item's `kui-id` is that radio's id, which a
17
+ * `<label for>` names. `value`, `default-value`, `disabled`,
11
18
  * `read-only`, `required`, `name`, `form`; it tells `value-change`.
12
19
  */
13
20
  const tag = defineElement({
@@ -1 +1 @@
1
- {"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/web/src/radio-group.ts"],"sourcesContent":["import { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroupProps } from \"@kirana-ui/core/radio-group\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\n\nconst valueOf = (element: HTMLElement) =>\n partAround(element, \"item\")?.getAttribute(\"kui-value\") ?? \"\"\nconst options = (element: HTMLElement) => () =>\n partAround(element, \"item\")?.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}\n\n/**\n * `<kui-radio-group>` around `kui-part=\"root\"` and an `item` button for each `value`, with an\n * `indicator` inside that is in the page while its item is the chosen one. An item draws the\n * hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,\n * `read-only`, `required`, `name`, `form`; it tells `value-change`.\n */\nexport const tag = defineElement<\n RadioGroupProps<string>,\n ReturnType<typeof createRadioGroup<string>>\n>({\n tag: \"kui-radio-group\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props, host) => createRadioGroup<string>(props, { field: fieldAround(host) }),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n item: (controller, element) => ({\n part: controller.item(valueOf(element), options(element)),\n inner: controller.itemInput(valueOf(element), options(element)),\n }),\n indicator: (controller, element) => controller.indicator(valueOf(element)),\n },\n})\n"],"mappings":";;;;AAMA,MAAM,WAAW,YACf,WAAW,SAAS,MAAM,CAAC,EAAE,aAAa,WAAW,KAAK;AAC5D,MAAM,WAAW,kBACf,WAAW,SAAS,MAAM,CAAC,EAAE,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;;;;;;;AAQpF,MAAa,MAAM,cAGjB;CACA,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,OAAO,SAAS,iBAAyB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CACrF,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,YAAY,aAAa;GAC9B,MAAM,WAAW,KAAK,QAAQ,OAAO,GAAG,QAAQ,OAAO,CAAC;GACxD,OAAO,WAAW,UAAU,QAAQ,OAAO,GAAG,QAAQ,OAAO,CAAC;EAChE;EACA,YAAY,YAAY,YAAY,WAAW,UAAU,QAAQ,OAAO,CAAC;CAC3E;AACF,CAAC"}
1
+ {"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/web/src/radio-group.ts"],"sourcesContent":["import { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroupProps } from \"@kirana-ui/core/radio-group\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst valueOf = (element: HTMLElement) =>\n partAround(element, \"item\")?.getAttribute(\"kui-value\") ?? \"\"\nconst options = (element: HTMLElement) => () => {\n const item = partAround(element, \"item\")\n return {\n disabled: item?.hasAttribute(\"kui-disabled\") || undefined,\n // The id of the item's native radio: a `<label for>` names it.\n id: item?.getAttribute(\"kui-id\") ?? undefined,\n }\n}\n\n/**\n * `<kui-radio-group>` around `kui-part=\"root\"` and an `item` button for each `value`, with an\n * `indicator` inside that is in the page while its item is the chosen one. An item draws the\n * hidden native radio a form and a label reach; an item's `kui-id` is that radio's id, which a\n * `<label for>` names. `value`, `default-value`, `disabled`,\n * `read-only`, `required`, `name`, `form`; it tells `value-change`.\n */\nexport const tag = defineElement<\n RadioGroupProps<string>,\n ReturnType<typeof createRadioGroup<string>>\n>({\n tag: \"kui-radio-group\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props, host) => createRadioGroup<string>(props, { field: fieldAround(host) }),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n item: (controller, element) => ({\n part: controller.item(valueOf(element), options(element)),\n inner: controller.itemInput(valueOf(element), options(element)),\n }),\n indicator: (controller, element) => controller.indicator(valueOf(element)),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-radio-group\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }>\n }\n}\n"],"mappings":";;;;AAOA,MAAM,WAAW,YACf,WAAW,SAAS,MAAM,CAAC,EAAE,aAAa,WAAW,KAAK;AAC5D,MAAM,WAAW,kBAA+B;CAC9C,MAAM,OAAO,WAAW,SAAS,MAAM;CACvC,OAAO;EACL,UAAU,MAAM,aAAa,cAAc,KAAK,KAAA;EAEhD,IAAI,MAAM,aAAa,QAAQ,KAAK,KAAA;CACtC;AACF;;;;;;;;AASA,MAAa,MAAM,cAGjB;CACA,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,OAAO,SAAS,iBAAyB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CACrF,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,YAAY,aAAa;GAC9B,MAAM,WAAW,KAAK,QAAQ,OAAO,GAAG,QAAQ,OAAO,CAAC;GACxD,OAAO,WAAW,UAAU,QAAQ,OAAO,GAAG,QAAQ,OAAO,CAAC;EAChE;EACA,YAAY,YAAY,YAAY,WAAW,UAAU,QAAQ,OAAO,CAAC;CAC3E;AACF,CAAC"}
@@ -1,7 +1,16 @@
1
+ import { ElementOf, Tag } from "./runtime.js";
2
+ import { Resizable, ResizableProps } from "@kirana-ui/core/resizable";
1
3
  /**
2
4
  * `<kui-resizable>` around `kui-part="group"`, its `panel`s (`kui-default-size`,
3
5
  * `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two
4
6
  * (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.
5
7
  */
6
- export declare const tag: string;
8
+ export declare const tag: Tag<ResizableProps, Resizable>;
9
+ declare global {
10
+ interface HTMLElementTagNameMap {
11
+ "kui-resizable": ElementOf<typeof tag, {
12
+ "sizes-change": ["onSizesChange", "sizes"];
13
+ }>;
14
+ }
15
+ }
7
16
  //# sourceMappingURL=resizable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/web/src/resizable.ts"],"sourcesContent":["import { createResizable } from \"@kirana-ui/core/resizable\"\nimport type { Resizable, ResizableProps } from \"@kirana-ui/core/resizable\"\n\nimport { defineElement } from \"./runtime.ts\"\n\nconst number = (element: HTMLElement, name: string) => {\n const text = element.getAttribute(name)\n return text === null\n ? {}\n : { [name.slice(4).replace(/-./g, (at) => at[1]!.toUpperCase())]: +text }\n}\n\n/**\n * `<kui-resizable>` around `kui-part=\"group\"`, its `panel`s (`kui-default-size`,\n * `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two\n * (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.\n */\nexport const tag = defineElement<ResizableProps, Resizable>({\n tag: \"kui-resizable\",\n props: { orientation: \"string\", \"keyboard-step\": \"number\", disabled: \"boolean\" },\n create: (props) => createResizable(props),\n changes: { onSizesChange: { event: \"sizes-change\", prop: \"sizes\", hold: false } },\n parts: {\n group: (controller) => controller.group,\n panel: (controller, element) =>\n controller.panel(() => ({\n ...number(element, \"kui-default-size\"),\n ...number(element, \"kui-min-size\"),\n ...number(element, \"kui-max-size\"),\n })),\n handle: (controller, element) =>\n controller.handle(() => (element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {})),\n },\n})\n"],"mappings":";;;AAKA,MAAM,UAAU,SAAsB,SAAiB;CACrD,MAAM,OAAO,QAAQ,aAAa,IAAI;CACtC,OAAO,SAAS,OACZ,CAAC,IACD,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,QAAQ,OAAO,GAAG,EAAE,CAAE,YAAY,CAAC,IAAI,CAAC,KAAK;AAC5E;;;;;;AAOA,MAAa,MAAM,cAAyC;CAC1D,KAAK;CACL,OAAO;EAAE,aAAa;EAAU,iBAAiB;EAAU,UAAU;CAAU;CAC/E,SAAS,UAAU,gBAAgB,KAAK;CACxC,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;EAAS,MAAM;CAAM,EAAE;CAChF,OAAO;EACL,QAAQ,eAAe,WAAW;EAClC,QAAQ,YAAY,YAClB,WAAW,aAAa;GACtB,GAAG,OAAO,SAAS,kBAAkB;GACrC,GAAG,OAAO,SAAS,cAAc;GACjC,GAAG,OAAO,SAAS,cAAc;EACnC,EAAE;EACJ,SAAS,YAAY,YACnB,WAAW,aAAc,QAAQ,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,CAAE;CAC5F;AACF,CAAC"}
1
+ {"version":3,"file":"resizable.js","names":[],"sources":["../../../../packages/web/src/resizable.ts"],"sourcesContent":["import { createResizable } from \"@kirana-ui/core/resizable\"\nimport type { Resizable, ResizableProps } from \"@kirana-ui/core/resizable\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst number = (element: HTMLElement, name: string) => {\n const text = element.getAttribute(name)\n return text === null\n ? {}\n : { [name.slice(4).replace(/-./g, (at) => at[1]!.toUpperCase())]: +text }\n}\n\n/**\n * `<kui-resizable>` around `kui-part=\"group\"`, its `panel`s (`kui-default-size`,\n * `kui-min-size`, `kui-max-size`, in shares of a hundred) and a `handle` between two\n * (`kui-disabled`). `orientation`, `keyboard-step`, `disabled`; it tells `sizes-change`.\n */\nexport const tag = defineElement<ResizableProps, Resizable>({\n tag: \"kui-resizable\",\n props: { orientation: \"string\", \"keyboard-step\": \"number\", disabled: \"boolean\" },\n create: (props) => createResizable(props),\n changes: { onSizesChange: { event: \"sizes-change\", prop: \"sizes\", hold: false } },\n parts: {\n group: (controller) => controller.group,\n panel: (controller, element) =>\n controller.panel(() => ({\n ...number(element, \"kui-default-size\"),\n ...number(element, \"kui-min-size\"),\n ...number(element, \"kui-max-size\"),\n })),\n handle: (controller, element) =>\n controller.handle(() => (element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {})),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-resizable\": ElementOf<typeof tag, { \"sizes-change\": [\"onSizesChange\", \"sizes\"] }>\n }\n}\n"],"mappings":";;;AAMA,MAAM,UAAU,SAAsB,SAAiB;CACrD,MAAM,OAAO,QAAQ,aAAa,IAAI;CACtC,OAAO,SAAS,OACZ,CAAC,IACD,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,QAAQ,OAAO,GAAG,EAAE,CAAE,YAAY,CAAC,IAAI,CAAC,KAAK;AAC5E;;;;;;AAOA,MAAa,MAAM,cAAyC;CAC1D,KAAK;CACL,OAAO;EAAE,aAAa;EAAU,iBAAiB;EAAU,UAAU;CAAU;CAC/E,SAAS,UAAU,gBAAgB,KAAK;CACxC,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;EAAS,MAAM;CAAM,EAAE;CAChF,OAAO;EACL,QAAQ,eAAe,WAAW;EAClC,QAAQ,YAAY,YAClB,WAAW,aAAa;GACtB,GAAG,OAAO,SAAS,kBAAkB;GACrC,GAAG,OAAO,SAAS,cAAc;GACjC,GAAG,OAAO,SAAS,cAAc;EACnC,EAAE;EACJ,SAAS,YAAY,YACnB,WAAW,aAAc,QAAQ,aAAa,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,CAAE;CAC5F;AACF,CAAC"}
package/src/runtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Part, ReadonlySignal } from "@kirana-ui/core";
1
+ import { ChangeDetails, Part, ReadonlySignal } from "@kirana-ui/core";
2
2
  /**
3
3
  * A component as a custom element, for a page with no framework.
4
4
  *
@@ -45,8 +45,11 @@ export interface Each<Entry = any> {
45
45
  */
46
46
  values?(entry: Entry): Record<string, unknown>;
47
47
  }
48
- /** The entry an element was stamped for, or the nearest around it: a part reads its own. */
49
- export declare function entryAround<Entry>(element: Node): Entry | undefined;
48
+ /**
49
+ * The entry an element was stamped for, or the nearest around it: a part reads its own. With
50
+ * `which`, the nearest that is of that list (a day's month, around its week).
51
+ */
52
+ export declare function entryAround<Entry>(element: Node, which?: (entry: unknown) => boolean): Entry | undefined;
50
53
  export interface ElementSpec<Props extends {
51
54
  id: string;
52
55
  }, Controller> {
@@ -86,6 +89,41 @@ export interface ElementSpec<Props extends {
86
89
  /** Each part by its `kui-part` name. */
87
90
  parts: Record<string, (controller: Controller, element: HTMLElement) => Part | Drawn | undefined>;
88
91
  }
92
+ declare const DEFINED: unique symbol;
93
+ /**
94
+ * A custom element's name as `defineElement` gives it. For TypeScript it also says what the
95
+ * element was defined from, which `ElementOf` reads back; in the page it is the name alone.
96
+ */
97
+ export type Tag<Props = unknown, Controller = unknown> = string & {
98
+ readonly [DEFINED]?: readonly [Props, Controller];
99
+ };
100
+ /**
101
+ * What a component tells: an event whose `detail` holds the value under its prop's name
102
+ * (`detail.open`, `detail.values`) and why it changed (`detail.details.reason`).
103
+ * `preventDefault()` keeps the value as it was.
104
+ */
105
+ export type Told<Prop extends string, Value> = CustomEvent<{ readonly [Name in Prop]: Value; } & {
106
+ readonly details: ChangeDetails;
107
+ }>;
108
+ /** A tag with its props said, where `defineElement` was left to work them out. */
109
+ export type As<Defined, Props> = Defined extends Tag<unknown, infer Controller> ? Tag<Props, Controller> : never;
110
+ type Callback<Props, Name> = Name extends keyof Props ? Extract<Props[Name], (...given: never[]) => unknown> : never;
111
+ interface Listens<Events> {
112
+ addEventListener<Type extends keyof Events>(type: Type, listener: (this: HTMLElement, event: Events[Type]) => void, options?: boolean | AddEventListenerOptions): void;
113
+ removeEventListener<Type extends keyof Events>(type: Type, listener: (this: HTMLElement, event: Events[Type]) => void, options?: boolean | EventListenerOptions): void;
114
+ }
115
+ /**
116
+ * A component's custom element as TypeScript knows it, from its `tag`: its props as properties
117
+ * (`element.open = true`), its controller once it has begun, and its events with their
118
+ * `detail`. `Changes` names each event with the callback it tells and the prop it holds
119
+ * (`{ "open-change": ["onOpenChange", "open"] }`), as the element's `changes` do; `More` is
120
+ * for events its parts tell from their own elements, which reach it too.
121
+ */
122
+ export type ElementOf<Defined, Changes = {}, More = {}> = Defined extends Tag<infer Props, infer Controller> ? Listens<{ readonly [Event in keyof Changes]: Changes[Event] extends readonly [infer Name, infer Prop extends string] ? Told<Prop, Parameters<Callback<Props, Name>>[0]> : never; } & More> & { -readonly [Name in keyof Props as Name extends "id" | `on${Capitalize<string>}` ? never : Name]?: Props[Name]; } & {
123
+ controller?: Controller;
124
+ } & HTMLElement : never;
125
+ /** The component a part belongs to: the nearest around it, or the one that moved it to the page's end. */
126
+ export declare function ownerOf(element: Element): HTMLElement | null;
89
127
  /**
90
128
  * The controller of the component around a custom element: the field a control is in, the
91
129
  * group a toggle is one of. Through a portal too: what was moved to the page's end is still
@@ -119,6 +157,6 @@ export declare function partProps<Props>(element: HTMLElement, kinds: Record<str
119
157
  */
120
158
  export declare function defineElement<Props extends {
121
159
  id: string;
122
- }, Controller extends object>(spec: ElementSpec<Props, Controller>): string;
160
+ }, Controller extends object>(spec: ElementSpec<Props, Controller>): Tag<Props, Controller>;
123
161
  export {};
124
162
  //# sourceMappingURL=runtime.d.ts.map