@kirana-ui/web 0.2.0 → 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 (72) hide show
  1. package/llms.txt +248 -74
  2. package/package.json +6 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +29 -8
  4. package/src/alert-dialog.d.ts +2 -2
  5. package/src/alert-dialog.js +6 -2
  6. package/src/alert-dialog.js.map +1 -1
  7. package/src/around.d.ts +21 -4
  8. package/src/around.js +34 -12
  9. package/src/around.js.map +1 -1
  10. package/src/autocomplete.d.ts +6 -3
  11. package/src/autocomplete.js +8 -4
  12. package/src/autocomplete.js.map +1 -1
  13. package/src/avatar.d.ts +11 -5
  14. package/src/avatar.js +39 -10
  15. package/src/avatar.js.map +1 -1
  16. package/src/calendar.d.ts +9 -5
  17. package/src/calendar.js +21 -9
  18. package/src/calendar.js.map +1 -1
  19. package/src/checkbox-group.d.ts +22 -0
  20. package/src/checkbox-group.js +36 -0
  21. package/src/checkbox-group.js.map +1 -0
  22. package/src/checkbox.d.ts +4 -2
  23. package/src/checkbox.js +10 -4
  24. package/src/checkbox.js.map +1 -1
  25. package/src/combobox.d.ts +17 -4
  26. package/src/combobox.js +43 -6
  27. package/src/combobox.js.map +1 -1
  28. package/src/command.d.ts +1 -1
  29. package/src/command.js +2 -1
  30. package/src/command.js.map +1 -1
  31. package/src/context-menu.d.ts +2 -1
  32. package/src/context-menu.js.map +1 -1
  33. package/src/date-picker.d.ts +7 -4
  34. package/src/date-picker.js +12 -3
  35. package/src/date-picker.js.map +1 -1
  36. package/src/dates.d.ts +5 -2
  37. package/src/dates.js +50 -15
  38. package/src/dates.js.map +1 -1
  39. package/src/dialog.d.ts +2 -2
  40. package/src/dialog.js +6 -2
  41. package/src/dialog.js.map +1 -1
  42. package/src/hover-card.d.ts +2 -1
  43. package/src/hover-card.js.map +1 -1
  44. package/src/index.d.ts +7 -3
  45. package/src/index.js +1 -0
  46. package/src/menu.d.ts +2 -1
  47. package/src/menu.js.map +1 -1
  48. package/src/navigation-menu.d.ts +2 -1
  49. package/src/navigation-menu.js.map +1 -1
  50. package/src/number-field.d.ts +5 -2
  51. package/src/number-field.js +23 -3
  52. package/src/number-field.js.map +1 -1
  53. package/src/otp.d.ts +1 -1
  54. package/src/otp.js +2 -1
  55. package/src/otp.js.map +1 -1
  56. package/src/popover.d.ts +8 -7
  57. package/src/popover.js +33 -5
  58. package/src/popover.js.map +1 -1
  59. package/src/radio-group.d.ts +2 -1
  60. package/src/radio-group.js +9 -2
  61. package/src/radio-group.js.map +1 -1
  62. package/src/runtime.d.ts +7 -2
  63. package/src/runtime.js +7 -4
  64. package/src/runtime.js.map +1 -1
  65. package/src/select.d.ts +3 -2
  66. package/src/select.js +2 -1
  67. package/src/select.js.map +1 -1
  68. package/src/slider.d.ts +2 -2
  69. package/src/slider.js +3 -2
  70. package/src/slider.js.map +1 -1
  71. package/src/tooltip.d.ts +2 -1
  72. package/src/tooltip.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirana-ui/web",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",
@@ -59,6 +59,10 @@
59
59
  "types": "./src/checkbox.d.ts",
60
60
  "default": "./src/checkbox.js"
61
61
  },
62
+ "./checkbox-group": {
63
+ "types": "./src/checkbox-group.d.ts",
64
+ "default": "./src/checkbox-group.js"
65
+ },
62
66
  "./collapsible": {
63
67
  "types": "./src/collapsible.d.ts",
64
68
  "default": "./src/collapsible.js"
@@ -218,7 +222,7 @@
218
222
  "./package.json": "./package.json"
219
223
  },
220
224
  "dependencies": {
221
- "@kirana-ui/core": "0.2.0"
225
+ "@kirana-ui/core": "0.3.0"
222
226
  },
223
227
  "homepage": "https://ui.kirana.style",
224
228
  "repository": {
@@ -33,10 +33,16 @@ from one core. The package for a framework is all a project installs.
33
33
  A popup that is placed against its trigger (a popover, a menu, a select, a combobox, a
34
34
  tooltip, a hover card) is `Portal > Positioner > Popup`: the `Positioner` takes `side`
35
35
  (also `inline-start` and `inline-end`, which turn with the reading direction, and which
36
- `data-side` then says), `align`, `sideOffset`, `alignOffset`, `collisionPadding`, and
36
+ `data-side` then says), `align`, `sideOffset` and `alignOffset` (a number, or a function
37
+ of the anchor's and the positioner's sizes), `collisionPadding` (a number, or one a side),
38
+ `collisionBoundary`, `collisionAvoidance`, `sticky`, `arrowPadding`, `positionMethod`, and
37
39
  `anchor` for another element than its trigger to be placed against (an element, the
38
- framework's own ref to one, or a function that gives one). A dialog, an alert dialog and a
39
- drawer have no positioner: `Portal > Backdrop` and `Popup`, placed by the design.
40
+ framework's own ref to one, or a function that gives one). A popup that holds an `Arrow`
41
+ is given `position: relative`, so the arrow is placed in it through its entrance and
42
+ after. A popover may have a `Backdrop` in its portal, is `modal` (`true`: the page is
43
+ inert and does not scroll; `"trap-focus"`: only Tab is kept inside), and its trigger's
44
+ `openOnHover` lets the pointer open it too. A dialog, an alert dialog and a drawer have
45
+ no positioner: `Portal > Backdrop` and `Popup`, placed by the design.
40
46
  3. Style by attributes and variables, never by guessing class names:
41
47
  - a boolean state is present or absent: `[data-open]`, never `[data-open="true"]`;
42
48
  - an entrance starts from `[data-starting-style]`, an exit ends at
@@ -55,8 +61,8 @@ from one core. The package for a framework is all a project installs.
55
61
  Per framework: React takes `render` for another element; Vue takes `as` / `as-child`, binds
56
62
  with `v-model:value` and names props in kebab case; Svelte takes a `child` snippet and
57
63
  `bind:value`; Solid takes `as` and `render`; Angular's parts are directives on your own
58
- elements (`<button kuiDialogTrigger>`), bound with `[(value)]`, with `[kuiId]` for an id, and
59
- a part that comes and goes is structural (`*kuiDialogPortal`, `*kuiTabsPanel`: the list is in
64
+ elements (`<button kpDialogTrigger>`), bound with `[(value)]`, with `[kpId]` for an id, and
65
+ a part that comes and goes is structural (`*kpDialogPortal`, `*kpTabsPanel`: the list is in
60
66
  `llms.txt`); custom elements name each part with `kui-part` inside `<kui-dialog>`.
61
67
 
62
68
  Composing a part with another element: with React's `render={<a … />}` and Vue's `as-child`
@@ -72,9 +78,24 @@ the text a part writes (`Meter.Value`, `Select.Value`) stay inside it on React a
72
78
  `props().children` on Solid, and are given to a Svelte `child` snippet to render
73
79
  (`{ props, state, input }`, `{ props, state, text }`). A handler given to a part is typed
74
80
  with `preventKiranaHandler()` (`PartEvent`, exported by each package). For an element of the
75
- design system's own that takes `render` or `as-child`, use `useRender` and `mergeProps` from
76
- `@kirana-ui/react/use-render`, or `Primitive` from `@kirana-ui/vue/primitive`; never write
77
- another merge.
81
+ design system's own composed as a part is, use `useRender` and `mergeProps` from
82
+ `@kirana-ui/react/use-render`, `Primitive` from `@kirana-ui/vue/primitive`, or `Primitive`
83
+ and `mergeProps` from `@kirana-ui/solid/primitive` and `@kirana-ui/svelte/primitive` (Solid's
84
+ `as` and `render`, Svelte's `as` and `child`, a `state` written as `data-*`); never write
85
+ another merge. On Angular such an element is a directive of your own with host bindings, and
86
+ custom elements need nothing: the page writes its own element.
87
+
88
+ A design system on Angular hosts each primitive in a directive of its own
89
+ (`hostDirectives: [{ directive: KpDialog, inputs: [...], outputs: [...] }]`), exposing what
90
+ its callers set; gives the primitive the rest with `hostInputs(KpTooltip, { delay: () => 0 })`
91
+ in its constructor (each value a function read like a signal, so `computed` values follow;
92
+ an input the element binds wins), never a subclass of the primitive; draws a structural part
93
+ (`kpDialogPortal`) in a component's template around `<ng-content />` (a part given to it finds
94
+ its root where it is written); and names its own directives as it likes, `kui…` included:
95
+ the primitives are `kp…` so that no design system's selector is theirs (two directives with
96
+ one selector both match, silently, and a component whose selector is its host's recurses).
97
+ Tooltips need no provider on any
98
+ framework: a design system passes `delay` on its own tooltip root (`hostInputs` on Angular).
78
99
 
79
100
  ## When something is wrong
80
101
 
@@ -1,8 +1,8 @@
1
1
  import { As, ElementOf, Tag } from "./runtime.js";
2
2
  import { AlertDialogProps } from "@kirana-ui/core/alert-dialog";
3
3
  /**
4
- * `<kui-alert-dialog>`: a dialog that asks, with the dialog's parts. A press outside does not
5
- * close it. `open`, `default-open`; it tells `open-change`.
4
+ * `<kui-alert-dialog>`: a dialog that asks, with the dialog's parts, its `viewport` too. A
5
+ * press outside does not close it. `open`, `default-open`; it tells `open-change`.
6
6
  */
7
7
  export declare const tag: Tag<{
8
8
  id: string;
@@ -2,8 +2,8 @@ import { defineElement } from "./runtime.js";
2
2
  import { createAlertDialog } from "@kirana-ui/core/alert-dialog";
3
3
  // src/alert-dialog.ts
4
4
  /**
5
- * `<kui-alert-dialog>`: a dialog that asks, with the dialog's parts. A press outside does not
6
- * close it. `open`, `default-open`; it tells `open-change`.
5
+ * `<kui-alert-dialog>`: a dialog that asks, with the dialog's parts, its `viewport` too. A
6
+ * press outside does not close it. `open`, `default-open`; it tells `open-change`.
7
7
  */
8
8
  const tag = defineElement({
9
9
  tag: "kui-alert-dialog",
@@ -22,6 +22,10 @@ const tag = defineElement({
22
22
  mounted: controller.mounted,
23
23
  part: controller.backdrop
24
24
  }),
25
+ viewport: (controller) => ({
26
+ mounted: controller.mounted,
27
+ part: controller.viewport
28
+ }),
25
29
  popup: (controller) => ({
26
30
  mounted: controller.mounted,
27
31
  part: controller.popup
@@ -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. A press outside does not\n * 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 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,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 { 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"}
package/src/around.d.ts CHANGED
@@ -19,13 +19,30 @@ export declare const valueOf: (element: HTMLElement | null) => string;
19
19
  export declare function ownValue(element: HTMLElement | null): string;
20
20
  /** What is made once for an element and shared by the parts inside it: an item, a group. */
21
21
  export declare function once<Made extends object>(kept: WeakMap<HTMLElement, Made>, element: HTMLElement | null, make: (element: HTMLElement) => Made): Made | undefined;
22
+ /**
23
+ * What a component with a positioner takes as a property of its custom element, for what an
24
+ * attribute cannot say: a function, an element, an object.
25
+ */
26
+ export interface Placed {
27
+ /**
28
+ * Its positioner's options that no attribute can say (`sideOffset` as a function,
29
+ * `collisionBoundary` as an element or a rectangle, `collisionPadding` a side,
30
+ * `collisionAvoidance`, `anchor` as an element). A `kui-` attribute on the positioner comes
31
+ * before the same option here. Read when the popup comes into the page, and when one of the
32
+ * positioner's attributes changes.
33
+ */
34
+ positioning?: Partial<PositionOptions> | undefined;
35
+ }
22
36
  /**
23
37
  * Where a positioner goes, as its own attributes say: `kui-side`, `kui-align`,
24
- * `kui-side-offset`, `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`, the id of
25
- * the element the popup is placed against when that is not its trigger. Written before the
26
- * part is put on, so the first placement reads them.
38
+ * `kui-side-offset`, `kui-align-offset`, `kui-collision-padding`, `kui-sticky`,
39
+ * `kui-arrow-padding`, `kui-position-method`, and two that name an element by its id:
40
+ * `kui-anchor`, what the popup is placed against when that is not its trigger, and
41
+ * `kui-collision-boundary`, what it is held inside. What no attribute can say is the
42
+ * `positioning` property of its custom element (`host`). Written before the part is put on,
43
+ * so the first placement reads them.
27
44
  */
28
- export declare function place(positioning: Signal<Partial<PositionOptions>>, element: HTMLElement, more?: Record<string, unknown>): void;
45
+ export declare function place(positioning: Signal<Partial<PositionOptions>>, element: HTMLElement, host?: (HTMLElement & Placed) | null): void;
29
46
  /**
30
47
  * A positioner as a part: the one place a component draws one. Its attributes are read
31
48
  * before it is put on, and again when one of them changes: a popup that is open follows.
package/src/around.js CHANGED
@@ -1,5 +1,5 @@
1
- import { controllerAround } from "./runtime.js";
2
- import { computed } from "@kirana-ui/core";
1
+ import { controllerAround, ownerOf } from "./runtime.js";
2
+ import { computed, effect } from "@kirana-ui/core";
3
3
  // src/around.ts
4
4
  /** The field a control is in, if it is in one. */
5
5
  const fieldAround = (host) => controllerAround(host, "kui-field");
@@ -38,44 +38,66 @@ const PLACING = [
38
38
  "kui-side-offset",
39
39
  "kui-align-offset",
40
40
  "kui-collision-padding",
41
+ "kui-collision-boundary",
42
+ "kui-sticky",
43
+ "kui-arrow-padding",
44
+ "kui-position-method",
41
45
  "kui-anchor"
42
46
  ];
43
47
  /**
44
48
  * Where a positioner goes, as its own attributes say: `kui-side`, `kui-align`,
45
- * `kui-side-offset`, `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`, the id of
46
- * the element the popup is placed against when that is not its trigger. Written before the
47
- * part is put on, so the first placement reads them.
49
+ * `kui-side-offset`, `kui-align-offset`, `kui-collision-padding`, `kui-sticky`,
50
+ * `kui-arrow-padding`, `kui-position-method`, and two that name an element by its id:
51
+ * `kui-anchor`, what the popup is placed against when that is not its trigger, and
52
+ * `kui-collision-boundary`, what it is held inside. What no attribute can say is the
53
+ * `positioning` property of its custom element (`host`). Written before the part is put on,
54
+ * so the first placement reads them.
48
55
  */
49
- function place(positioning, element, more = {}) {
56
+ function place(positioning, element, host) {
50
57
  const against = element.getAttribute("kui-anchor");
58
+ const within = element.getAttribute("kui-collision-boundary");
59
+ const sticky = element.getAttribute("kui-sticky");
51
60
  const asked = {
52
61
  side: element.getAttribute("kui-side") ?? void 0,
53
62
  align: element.getAttribute("kui-align") ?? void 0,
54
63
  sideOffset: number(element.getAttribute("kui-side-offset")),
55
64
  alignOffset: number(element.getAttribute("kui-align-offset")),
56
65
  collisionPadding: number(element.getAttribute("kui-collision-padding")),
57
- anchor: against === null ? void 0 : () => element.ownerDocument.getElementById(against),
58
- ...more
66
+ collisionBoundary: within === null || within === "clipping-ancestors" ? void 0 : element.ownerDocument.getElementById(within) ?? void 0,
67
+ sticky: sticky === null ? void 0 : sticky !== "false",
68
+ arrowPadding: number(element.getAttribute("kui-arrow-padding")),
69
+ positionMethod: element.getAttribute("kui-position-method") ?? void 0,
70
+ anchor: against === null ? void 0 : () => element.ownerDocument.getElementById(against)
59
71
  };
60
72
  for (const key of Object.keys(asked)) if (asked[key] === void 0) delete asked[key];
61
- positioning.set(asked);
73
+ positioning.set({
74
+ ...host?.positioning,
75
+ ...asked
76
+ });
62
77
  }
63
78
  /**
64
79
  * A positioner as a part: the one place a component draws one. Its attributes are read
65
80
  * before it is put on, and again when one of them changes: a popup that is open follows.
66
81
  */
67
82
  function positioner(controller, element) {
68
- place(controller.positioning, element);
83
+ const host = ownerOf(element);
84
+ place(controller.positioning, element, host);
69
85
  return {
70
86
  mounted: controller.mounted,
71
87
  part: controller.positioner,
72
88
  mount() {
73
- const observer = new MutationObserver(() => place(controller.positioning, element));
89
+ const observer = new MutationObserver(() => place(controller.positioning, element, host));
74
90
  observer.observe(element, {
75
91
  attributes: true,
76
92
  attributeFilter: PLACING
77
93
  });
78
- return () => observer.disconnect();
94
+ const stop = effect(() => {
95
+ if (controller.mounted.get()) place(controller.positioning, element, host);
96
+ });
97
+ return () => {
98
+ stop();
99
+ observer.disconnect();
100
+ };
79
101
  }
80
102
  };
81
103
  }
package/src/around.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"around.js","names":[],"sources":["../../../../packages/web/src/around.ts"],"sourcesContent":["import { computed } 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 } 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-anchor\",\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`, and `kui-anchor`, the id of\n * the element the popup is placed against when that is not its trigger. Written before the\n * part is put on, so the first placement reads them.\n */\nexport function place(\n positioning: Signal<Partial<PositionOptions>>,\n element: HTMLElement,\n more: Record<string, unknown> = {}\n): void {\n const against = element.getAttribute(\"kui-anchor\")\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 // 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 ...more,\n }\n for (const key of Object.keys(asked)) if (asked[key] === undefined) delete asked[key]\n positioning.set(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 place(controller.positioning, element)\n return {\n mounted: controller.mounted,\n part: controller.positioner,\n mount() {\n const observer = new MutationObserver(() => place(controller.positioning, element))\n observer.observe(element, { attributes: true, attributeFilter: PLACING })\n return () => observer.disconnect()\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,cAAc,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACjE,GAAI,QAAQ,aAAa,WAAW,IAAI,EAAE,OAAO,QAAQ,aAAa,WAAW,EAAG,IAAI,CAAC;AAC3F;;AAGA,MAAa,WAAW,YACtB,SAAS,aAAa,WAAW,KAAK;AAExC,IAAI,QAAQ;AACZ,MAAM,wBAAQ,IAAI,QAA6B;;;;;AAM/C,SAAgB,SAAS,SAAqC;CAC5D,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,OAAO,MAAM,IAAI,OAAO;CAC5B,IAAI,CAAC,MAAM,MAAM,IAAI,SAAU,OAAO,WAAW,EAAE,OAAQ;CAC3D,OAAO;AACT;;AAGA,SAAgB,KACd,MACA,SACA,MACkB;CAClB,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,IAAI,OAAO,KAAK,IAAI,OAAO;CAC3B,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,aAAa,WAAW,IAAI,EAAE,OAAO,QAAQ,aAAa,WAAW,EAAG,IAAI,CAAC;CACzF,GAAI,OAAO,KAAA,IAAY,CAAC,IAAI,EAAE,GAAG;AACnC"}
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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AG;AACnC"}
@@ -1,11 +1,14 @@
1
1
  import { ElementOf, Tag } from "./runtime.js";
2
+ import { Placed } from "./around.js";
2
3
  import { AutocompleteProps } from "@kirana-ui/core/autocomplete";
3
4
  import { Combobox } from "@kirana-ui/core/combobox";
4
5
  /**
5
6
  * `<kui-autocomplete>`: a combobox whose text is the value, with a combobox's parts: the
6
7
  * list only suggests. `value`, `default-value`, `open`, `default-open`, `mode`,
7
- * `open-on-input-click`, `auto-highlight`, `disabled`, `required`, `name`, `form`; `filter` as a property; it
8
- * tells `value-change` and `open-change`.
8
+ * `open-on-input-click`, `auto-highlight`, `disabled`, `read-only`, `required`, `name`, `form`;
9
+ * `filter` and `items` as properties (with `items`, the suggestions are a
10
+ * `<template kui-each="collection">`, as a combobox's); it tells `value-change` and
11
+ * `open-change`.
9
12
  */
10
13
  export declare const tag: Tag<AutocompleteProps, Combobox<string>>;
11
14
  declare global {
@@ -13,7 +16,7 @@ declare global {
13
16
  "kui-autocomplete": ElementOf<typeof tag, {
14
17
  "value-change": ["onValueChange", "value"];
15
18
  "open-change": ["onOpenChange", "open"];
16
- }>;
19
+ }> & Placed;
17
20
  }
18
21
  }
19
22
  //# sourceMappingURL=autocomplete.d.ts.map
@@ -1,13 +1,15 @@
1
1
  import { fieldAround } from "./around.js";
2
- import { PARTS } from "./combobox.js";
2
+ import { LISTS, PARTS } from "./combobox.js";
3
3
  import { defineElement } from "./runtime.js";
4
4
  import { createAutocomplete } from "@kirana-ui/core/autocomplete";
5
5
  // src/autocomplete.ts
6
6
  /**
7
7
  * `<kui-autocomplete>`: a combobox whose text is the value, with a combobox's parts: the
8
8
  * list only suggests. `value`, `default-value`, `open`, `default-open`, `mode`,
9
- * `open-on-input-click`, `auto-highlight`, `disabled`, `required`, `name`, `form`; `filter` as a property; it
10
- * tells `value-change` and `open-change`.
9
+ * `open-on-input-click`, `auto-highlight`, `disabled`, `read-only`, `required`, `name`, `form`;
10
+ * `filter` and `items` as properties (with `items`, the suggestions are a
11
+ * `<template kui-each="collection">`, as a combobox's); it tells `value-change` and
12
+ * `open-change`.
11
13
  */
12
14
  const tag = defineElement({
13
15
  tag: "kui-autocomplete",
@@ -20,11 +22,12 @@ const tag = defineElement({
20
22
  "open-on-input-click": "boolean",
21
23
  "auto-highlight": "boolean",
22
24
  disabled: "boolean",
25
+ "read-only": "boolean",
23
26
  required: "boolean",
24
27
  name: "string",
25
28
  form: "string"
26
29
  },
27
- properties: ["filter"],
30
+ properties: ["filter", "items"],
28
31
  create: (props, host) => createAutocomplete(props, { field: fieldAround(host) }),
29
32
  changes: {
30
33
  onValueChange: {
@@ -36,6 +39,7 @@ const tag = defineElement({
36
39
  prop: "open"
37
40
  }
38
41
  },
42
+ lists: { collection: LISTS.collection },
39
43
  parts: PARTS
40
44
  });
41
45
  export { tag };
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.js","names":[],"sources":["../../../../packages/web/src/autocomplete.ts"],"sourcesContent":["import { createAutocomplete } from \"@kirana-ui/core/autocomplete\"\nimport type { AutocompleteProps } from \"@kirana-ui/core/autocomplete\"\nimport type { Combobox } from \"@kirana-ui/core/combobox\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { PARTS } from \"./combobox.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-autocomplete>`: a combobox whose text is the value, with a combobox's parts: the\n * list only suggests. `value`, `default-value`, `open`, `default-open`, `mode`,\n * `open-on-input-click`, `auto-highlight`, `disabled`, `required`, `name`, `form`; `filter` as a property; it\n * tells `value-change` and `open-change`.\n */\nexport const tag = defineElement<AutocompleteProps, Combobox<string>>({\n tag: \"kui-autocomplete\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n open: \"boolean\",\n \"default-open\": \"boolean\",\n mode: \"string\",\n \"open-on-input-click\": \"boolean\",\n \"auto-highlight\": \"boolean\",\n disabled: \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"filter\"],\n create: (props, host) =>\n createAutocomplete(props, { field: fieldAround(host) }) as Combobox<string>,\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onOpenChange: { event: \"open-change\", prop: \"open\" },\n },\n parts: PARTS,\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-autocomplete\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; \"open-change\": [\"onOpenChange\", \"open\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,MAAM,cAAmD;CACpE,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,MAAM;EACN,uBAAuB;EACvB,kBAAkB;EAClB,UAAU;EACV,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,QAAQ;CACrB,SAAS,OAAO,SACd,mBAAmB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CACxD,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,cAAc;GAAE,OAAO;GAAe,MAAM;EAAO;CACrD;CACA,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"autocomplete.js","names":[],"sources":["../../../../packages/web/src/autocomplete.ts"],"sourcesContent":["import { createAutocomplete } from \"@kirana-ui/core/autocomplete\"\nimport type { AutocompleteProps } from \"@kirana-ui/core/autocomplete\"\nimport type { Combobox } from \"@kirana-ui/core/combobox\"\n\nimport { fieldAround } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { LISTS, PARTS } from \"./combobox.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-autocomplete>`: a combobox whose text is the value, with a combobox's parts: the\n * list only suggests. `value`, `default-value`, `open`, `default-open`, `mode`,\n * `open-on-input-click`, `auto-highlight`, `disabled`, `read-only`, `required`, `name`, `form`;\n * `filter` and `items` as properties (with `items`, the suggestions are a\n * `<template kui-each=\"collection\">`, as a combobox's); it tells `value-change` and\n * `open-change`.\n */\nexport const tag = defineElement<AutocompleteProps, Combobox<string>>({\n tag: \"kui-autocomplete\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n open: \"boolean\",\n \"default-open\": \"boolean\",\n mode: \"string\",\n \"open-on-input-click\": \"boolean\",\n \"auto-highlight\": \"boolean\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"filter\", \"items\"],\n create: (props, host) =>\n createAutocomplete(props, { field: fieldAround(host) }) as Combobox<string>,\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onOpenChange: { event: \"open-change\", prop: \"open\" },\n },\n lists: { collection: LISTS.collection },\n parts: PARTS,\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-autocomplete\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; \"open-change\": [\"onOpenChange\", \"open\"] }\n > &\n Placed\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,MAAM,cAAmD;CACpE,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,gBAAgB;EAChB,MAAM;EACN,uBAAuB;EACvB,kBAAkB;EAClB,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,UAAU,OAAO;CAC9B,SAAS,OAAO,SACd,mBAAmB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CACxD,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,cAAc;GAAE,OAAO;GAAe,MAAM;EAAO;CACrD;CACA,OAAO,EAAE,YAAY,MAAM,WAAW;CACtC,OAAO;AACT,CAAC"}
package/src/avatar.d.ts CHANGED
@@ -1,19 +1,25 @@
1
1
  import { ElementOf, Tag } from "./runtime.js";
2
- import { Avatar } from "@kirana-ui/core/avatar";
2
+ import { Avatar, AvatarImageProps } from "@kirana-ui/core/avatar";
3
3
  /**
4
4
  * `<kui-avatar>` around `kui-part="root"`, an `image` (an `<img>`, in the page once the
5
- * picture has loaded) and a `fallback`, in the page until then. `src`: the picture's address,
6
- * on the component, since the image is not in the page to be given one.
5
+ * picture has loaded) and a `fallback`, in the page until then; `kui-delay="600"` on the
6
+ * fallback waits that many milliseconds first. `src`: the picture's address, on the component,
7
+ * since the image is not in the page to be given one. With `kui-keep-mounted` the image stays
8
+ * in the page, as Base UI's `keepMounted` image: its own `src` is the address, it loads the
9
+ * picture itself, and it is `aria-hidden` until it has (`data-loading`, `data-error`). It
10
+ * tells `loading-status-change` (`detail.status`) as the picture loads.
7
11
  */
8
12
  export declare const tag: Tag<{
9
13
  id: string;
10
14
  src?: string;
11
- }, Avatar & {
15
+ } & AvatarImageProps, Avatar & {
12
16
  mount(): () => void;
13
17
  }>;
14
18
  declare global {
15
19
  interface HTMLElementTagNameMap {
16
- "kui-avatar": ElementOf<typeof tag>;
20
+ "kui-avatar": ElementOf<typeof tag, {
21
+ "loading-status-change": ["onLoadingStatusChange", "status"];
22
+ }>;
17
23
  }
18
24
  }
19
25
  //# sourceMappingURL=avatar.d.ts.map
package/src/avatar.js CHANGED
@@ -2,35 +2,64 @@ import { defineElement } from "./runtime.js";
2
2
  import { computed, effect } from "@kirana-ui/core";
3
3
  import { createAvatar } from "@kirana-ui/core/avatar";
4
4
  // src/avatar.ts
5
+ const fallbacks = /* @__PURE__ */ new WeakMap();
5
6
  /**
6
7
  * `<kui-avatar>` around `kui-part="root"`, an `image` (an `<img>`, in the page once the
7
- * picture has loaded) and a `fallback`, in the page until then. `src`: the picture's address,
8
- * on the component, since the image is not in the page to be given one.
8
+ * picture has loaded) and a `fallback`, in the page until then; `kui-delay="600"` on the
9
+ * fallback waits that many milliseconds first. `src`: the picture's address, on the component,
10
+ * since the image is not in the page to be given one. With `kui-keep-mounted` the image stays
11
+ * in the page, as Base UI's `keepMounted` image: its own `src` is the address, it loads the
12
+ * picture itself, and it is `aria-hidden` until it has (`data-loading`, `data-error`). It
13
+ * tells `loading-status-change` (`detail.status`) as the picture loads.
9
14
  */
10
15
  const tag = defineElement({
11
16
  tag: "kui-avatar",
12
17
  props: { src: "string" },
13
18
  create(props) {
14
19
  const avatar = createAvatar(props);
20
+ const report = avatar.statusReport(() => props.peek().onLoadingStatusChange);
15
21
  return {
16
22
  ...avatar,
17
23
  mount() {
18
- const stops = [effect(() => avatar.source.set(props.get().src)), avatar.mount()];
24
+ let given = false;
25
+ const stops = [
26
+ effect(() => {
27
+ const { src } = props.get();
28
+ if (src === void 0 && !given) return;
29
+ given = src !== void 0;
30
+ avatar.source.set(src);
31
+ }),
32
+ avatar.mount(),
33
+ report.mount()
34
+ ];
19
35
  return () => stops.forEach((stop) => stop());
20
36
  }
21
37
  };
22
38
  },
23
- changes: {},
39
+ changes: { onLoadingStatusChange: {
40
+ event: "loading-status-change",
41
+ prop: "status",
42
+ hold: false
43
+ } },
24
44
  parts: {
25
45
  root: (controller) => controller.root,
26
- image: (controller) => ({
46
+ image: (controller, element) => element.hasAttribute("kui-keep-mounted") ? controller.keptImage : {
27
47
  part: controller.image,
28
48
  mounted: computed(() => controller.status.get() === "loaded")
29
- }),
30
- fallback: (controller) => ({
31
- part: controller.fallback,
32
- mounted: computed(() => controller.status.get() !== "loaded")
33
- })
49
+ },
50
+ fallback(controller, element) {
51
+ let presence = fallbacks.get(element);
52
+ if (!presence) {
53
+ const delay = Number(element.getAttribute("kui-delay")) || 0;
54
+ presence = controller.fallbackPresence({ delay });
55
+ fallbacks.set(element, presence);
56
+ }
57
+ return {
58
+ part: controller.fallback,
59
+ mounted: presence.shown,
60
+ mount: presence.mount
61
+ };
62
+ }
34
63
  }
35
64
  });
36
65
  export { tag };
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 } from \"@kirana-ui/core/avatar\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\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. `src`: the picture's address,\n * on the component, since the image is not in the page to be given one.\n */\nexport const tag = defineElement<{ id: string; src?: string }, Avatar & { mount(): () => void }>({\n tag: \"kui-avatar\",\n props: { src: \"string\" },\n create(props) {\n const avatar = createAvatar(props)\n return {\n ...avatar,\n mount() {\n const stops = [effect(() => avatar.source.set(props.get().src)), avatar.mount()]\n return () => stops.forEach((stop) => stop())\n },\n }\n },\n changes: {},\n parts: {\n root: (controller) => controller.root,\n image: (controller) => ({\n part: controller.image,\n mounted: computed(() => controller.status.get() === \"loaded\"),\n }),\n fallback: (controller) => ({\n part: controller.fallback,\n mounted: computed(() => controller.status.get() !== \"loaded\"),\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-avatar\": ElementOf<typeof tag>\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,MAAM,cAA8E;CAC/F,KAAK;CACL,OAAO,EAAE,KAAK,SAAS;CACvB,OAAO,OAAO;EACZ,MAAM,SAAS,aAAa,KAAK;EACjC,OAAO;GACL,GAAG;GACH,QAAQ;IACN,MAAM,QAAQ,CAAC,aAAa,OAAO,OAAO,IAAI,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC;IAC/E,aAAa,MAAM,SAAS,SAAS,KAAK,CAAC;GAC7C;EACF;CACF;CACA,SAAS,CAAC;CACV,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,gBAAgB;GACtB,MAAM,WAAW;GACjB,SAAS,eAAe,WAAW,OAAO,IAAI,MAAM,QAAQ;EAC9D;EACA,WAAW,gBAAgB;GACzB,MAAM,WAAW;GACjB,SAAS,eAAe,WAAW,OAAO,IAAI,MAAM,QAAQ;EAC9D;CACF;AACF,CAAC"}
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"}
package/src/calendar.d.ts CHANGED
@@ -5,12 +5,16 @@ import { Calendar, CalendarProps } from "@kirana-ui/core/calendar";
5
5
  * (it says the month) and a `grid` table. The table's head row holds a
6
6
  * `<template kui-each="weekdays">` with a `head-cell` (`{short}`, `{narrow}`, `{long}`); its
7
7
  * body a `<template kui-each="weeks">` with a row, which holds a `<template kui-each="days">`
8
- * with a `cell` and its `day` button (`{date}`, `{label}`). `value` and `default-value` (a
9
- * day as `2026-03-14`; several with commas between), `mode`, `default-focused-value`,
10
- * `locale`, `calendar-system`, `min`, `max`, `disabled`, `read-only`, `fixed-weeks`;
11
- * `isDateUnavailable` as a property; it tells `value-change` and `month-change`.
8
+ * with a `cell` and its `day` button (`{date}`, `{label}`). With several `months`, a
9
+ * `<template kui-each="months">` (`{index}`, `{month}`, `{title}`) holds each month's
10
+ * `heading` and `grid`. An `<input kui-part="input">` submits the value under `name`.
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`,
13
+ * `month`, `default-month`, `default-focused-value`, `locale`, `calendar-system`, `min`,
14
+ * `max`, `disabled`, `read-only`, `fixed-weeks`, `name`, `form`; `isDateUnavailable` as a
15
+ * property; it tells `value-change` and `month-change`.
12
16
  */
13
- export declare const tag: Tag<CalendarProps, Calendar>;
17
+ export declare const tag: Tag<CalendarProps<import("@kirana-ui/core/calendar").CalendarMode>, Calendar>;
14
18
  declare global {
15
19
  interface HTMLElementTagNameMap {
16
20
  "kui-calendar": ElementOf<typeof tag, {
package/src/calendar.js CHANGED
@@ -9,10 +9,14 @@ const { parts, lists } = calendarParts((controller) => controller);
9
9
  * (it says the month) and a `grid` table. The table's head row holds a
10
10
  * `<template kui-each="weekdays">` with a `head-cell` (`{short}`, `{narrow}`, `{long}`); its
11
11
  * body a `<template kui-each="weeks">` with a row, which holds a `<template kui-each="days">`
12
- * with a `cell` and its `day` button (`{date}`, `{label}`). `value` and `default-value` (a
13
- * day as `2026-03-14`; several with commas between), `mode`, `default-focused-value`,
14
- * `locale`, `calendar-system`, `min`, `max`, `disabled`, `read-only`, `fixed-weeks`;
15
- * `isDateUnavailable` as a property; it tells `value-change` and `month-change`.
12
+ * with a `cell` and its `day` button (`{date}`, `{label}`). With several `months`, a
13
+ * `<template kui-each="months">` (`{index}`, `{month}`, `{title}`) holds each month's
14
+ * `heading` and `grid`. An `<input kui-part="input">` submits the value under `name`.
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`,
17
+ * `month`, `default-month`, `default-focused-value`, `locale`, `calendar-system`, `min`,
18
+ * `max`, `disabled`, `read-only`, `fixed-weeks`, `name`, `form`; `isDateUnavailable` as a
19
+ * property; it tells `value-change` and `month-change`.
16
20
  */
17
21
  const tag = defineElement({
18
22
  tag: "kui-calendar",
@@ -20,6 +24,12 @@ const tag = defineElement({
20
24
  value: "string",
21
25
  "default-value": "string",
22
26
  mode: "string",
27
+ "min-days": "number",
28
+ "max-days": "number",
29
+ months: "number",
30
+ "paged-navigation": "boolean",
31
+ month: "string",
32
+ "default-month": "string",
23
33
  "default-focused-value": "string",
24
34
  locale: "string",
25
35
  "calendar-system": "string",
@@ -27,15 +37,17 @@ const tag = defineElement({
27
37
  max: "string",
28
38
  disabled: "boolean",
29
39
  "read-only": "boolean",
30
- "fixed-weeks": "boolean"
40
+ "fixed-weeks": "boolean",
41
+ name: "string",
42
+ form: "string"
31
43
  },
32
44
  properties: ["isDateUnavailable"],
33
45
  create: (props) => createCalendar(computed(() => {
34
46
  const own = props.get();
35
47
  return {
36
48
  ...own,
37
- value: days(own.value),
38
- defaultValue: days(own.defaultValue)
49
+ value: days(own.value, own.mode),
50
+ defaultValue: days(own.defaultValue, own.mode)
39
51
  };
40
52
  })),
41
53
  changes: {
@@ -45,13 +57,13 @@ const tag = defineElement({
45
57
  },
46
58
  onMonthChange: {
47
59
  event: "month-change",
48
- prop: "month",
49
- hold: false
60
+ prop: "month"
50
61
  }
51
62
  },
52
63
  lists,
53
64
  parts: {
54
65
  root: (controller) => controller.root,
66
+ input: (controller) => controller.input,
55
67
  ...parts
56
68
  }
57
69
  });