@kirana-ui/react 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/llms.txt +1507 -121
  3. package/package.json +44 -3
  4. package/skills/kirana-ui-primitives/SKILL.md +24 -4
  5. package/src/accordion.d.ts +2 -2
  6. package/src/accordion.js +3 -2
  7. package/src/accordion.js.map +1 -1
  8. package/src/autosize.d.ts +1 -1
  9. package/src/avatar.d.ts +2 -2
  10. package/src/avatar.js +3 -3
  11. package/src/avatar.js.map +1 -1
  12. package/src/button.d.ts +5 -2
  13. package/src/button.js +4 -1
  14. package/src/button.js.map +1 -1
  15. package/src/calendar.d.ts +6 -6
  16. package/src/calendar.js +13 -5
  17. package/src/calendar.js.map +1 -1
  18. package/src/carousel.d.ts +6 -3
  19. package/src/carousel.js +1 -1
  20. package/src/carousel.js.map +1 -1
  21. package/src/checkbox-group.d.ts +2 -1
  22. package/src/checkbox-group.js +1 -1
  23. package/src/checkbox-group.js.map +1 -1
  24. package/src/checkbox.d.ts +6 -1
  25. package/src/checkbox.js +1 -1
  26. package/src/checkbox.js.map +1 -1
  27. package/src/collapsible.d.ts +1 -1
  28. package/src/color-picker.d.ts +61 -0
  29. package/src/color-picker.js +119 -0
  30. package/src/color-picker.js.map +1 -0
  31. package/src/combobox.d.ts +13 -4
  32. package/src/combobox.js +13 -5
  33. package/src/combobox.js.map +1 -1
  34. package/src/command.d.ts +3 -3
  35. package/src/command.js.map +1 -1
  36. package/src/date-field.d.ts +2 -2
  37. package/src/date-field.js +3 -2
  38. package/src/date-field.js.map +1 -1
  39. package/src/date-picker.d.ts +29 -8
  40. package/src/date-picker.js +21 -5
  41. package/src/date-picker.js.map +1 -1
  42. package/src/dialog.d.ts +6 -6
  43. package/src/dialog.js +22 -7
  44. package/src/dialog.js.map +1 -1
  45. package/src/direction.d.ts +1 -1
  46. package/src/direction.js +1 -1
  47. package/src/editable.d.ts +32 -0
  48. package/src/editable.js +63 -0
  49. package/src/editable.js.map +1 -0
  50. package/src/field.d.ts +1 -1
  51. package/src/fieldset.d.ts +1 -1
  52. package/src/file-upload.d.ts +54 -0
  53. package/src/file-upload.js +96 -0
  54. package/src/file-upload.js.map +1 -0
  55. package/src/form.d.ts +1 -1
  56. package/src/hover-popup.d.ts +1 -1
  57. package/src/hover-popup.js +1 -1
  58. package/src/index.d.ts +26 -8
  59. package/src/index.js +11 -1
  60. package/src/input.d.ts +1 -1
  61. package/src/input.js +1 -1
  62. package/src/label.d.ts +1 -1
  63. package/src/listbox.d.ts +1 -1
  64. package/src/listbox.js +1 -1
  65. package/src/menu.d.ts +5 -5
  66. package/src/menu.js +14 -9
  67. package/src/menu.js.map +1 -1
  68. package/src/menubar.d.ts +2 -2
  69. package/src/menubar.js +4 -2
  70. package/src/menubar.js.map +1 -1
  71. package/src/message-scroller.d.ts +1 -1
  72. package/src/navigation-menu.d.ts +5 -5
  73. package/src/navigation-menu.js +14 -4
  74. package/src/navigation-menu.js.map +1 -1
  75. package/src/number-field.d.ts +2 -1
  76. package/src/number-field.js +1 -1
  77. package/src/number-field.js.map +1 -1
  78. package/src/otp.d.ts +3 -2
  79. package/src/otp.js +9 -2
  80. package/src/otp.js.map +1 -1
  81. package/src/pagination.d.ts +1 -1
  82. package/src/password-input.d.ts +23 -0
  83. package/src/password-input.js +40 -0
  84. package/src/password-input.js.map +1 -0
  85. package/src/popover.d.ts +1 -1
  86. package/src/popover.js +1 -1
  87. package/src/qr-code.d.ts +1 -1
  88. package/src/radio-group.d.ts +1 -1
  89. package/src/radio-group.js +1 -1
  90. package/src/rating.d.ts +28 -0
  91. package/src/rating.js +59 -0
  92. package/src/rating.js.map +1 -0
  93. package/src/resizable.d.ts +1 -1
  94. package/src/resizable.js +1 -1
  95. package/src/runtime.d.ts +10 -3
  96. package/src/runtime.js +18 -4
  97. package/src/runtime.js.map +1 -1
  98. package/src/scroll-area.d.ts +1 -1
  99. package/src/scroll-area.js +1 -1
  100. package/src/select.d.ts +17 -6
  101. package/src/select.js +6 -3
  102. package/src/select.js.map +1 -1
  103. package/src/separator.d.ts +1 -1
  104. package/src/slider.d.ts +1 -1
  105. package/src/slider.js +1 -1
  106. package/src/steps.d.ts +51 -0
  107. package/src/steps.js +69 -0
  108. package/src/steps.js.map +1 -0
  109. package/src/switch.d.ts +2 -1
  110. package/src/switch.js +1 -1
  111. package/src/switch.js.map +1 -1
  112. package/src/tabs.d.ts +2 -2
  113. package/src/tabs.js +4 -3
  114. package/src/tabs.js.map +1 -1
  115. package/src/tags-input.d.ts +47 -0
  116. package/src/tags-input.js +92 -0
  117. package/src/tags-input.js.map +1 -0
  118. package/src/time-field.d.ts +32 -0
  119. package/src/time-field.js +67 -0
  120. package/src/time-field.js.map +1 -0
  121. package/src/toast.d.ts +1 -1
  122. package/src/toggle-group.d.ts +2 -2
  123. package/src/toggle-group.js +4 -3
  124. package/src/toggle-group.js.map +1 -1
  125. package/src/toggle.d.ts +1 -1
  126. package/src/toggle.js +1 -1
  127. package/src/toolbar.d.ts +14 -6
  128. package/src/toolbar.js +19 -9
  129. package/src/toolbar.js.map +1 -1
  130. package/src/tour.d.ts +61 -0
  131. package/src/tour.js +68 -0
  132. package/src/tour.js.map +1 -0
  133. package/src/tree.d.ts +45 -0
  134. package/src/tree.js +93 -0
  135. package/src/tree.js.map +1 -0
  136. package/src/use-render.js +1 -1
  137. package/src/value-bar.d.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirana-ui/react",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Kirana UI Primitives for React",
5
5
  "license": "MIT",
6
6
  "author": "The Kirana authors",
@@ -139,6 +139,46 @@
139
139
  "types": "./src/pagination.d.ts",
140
140
  "default": "./src/pagination.js"
141
141
  },
142
+ "./rating": {
143
+ "types": "./src/rating.d.ts",
144
+ "default": "./src/rating.js"
145
+ },
146
+ "./steps": {
147
+ "types": "./src/steps.d.ts",
148
+ "default": "./src/steps.js"
149
+ },
150
+ "./editable": {
151
+ "types": "./src/editable.d.ts",
152
+ "default": "./src/editable.js"
153
+ },
154
+ "./password-input": {
155
+ "types": "./src/password-input.d.ts",
156
+ "default": "./src/password-input.js"
157
+ },
158
+ "./tags-input": {
159
+ "types": "./src/tags-input.d.ts",
160
+ "default": "./src/tags-input.js"
161
+ },
162
+ "./file-upload": {
163
+ "types": "./src/file-upload.d.ts",
164
+ "default": "./src/file-upload.js"
165
+ },
166
+ "./time-field": {
167
+ "types": "./src/time-field.d.ts",
168
+ "default": "./src/time-field.js"
169
+ },
170
+ "./tree": {
171
+ "types": "./src/tree.d.ts",
172
+ "default": "./src/tree.js"
173
+ },
174
+ "./color-picker": {
175
+ "types": "./src/color-picker.d.ts",
176
+ "default": "./src/color-picker.js"
177
+ },
178
+ "./tour": {
179
+ "types": "./src/tour.d.ts",
180
+ "default": "./src/tour.js"
181
+ },
142
182
  "./date-picker": {
143
183
  "types": "./src/date-picker.d.ts",
144
184
  "default": "./src/date-picker.js"
@@ -230,7 +270,7 @@
230
270
  "./package.json": "./package.json"
231
271
  },
232
272
  "dependencies": {
233
- "@kirana-ui/core": "0.3.0"
273
+ "@kirana-ui/core": "0.4.0"
234
274
  },
235
275
  "peerDependencies": {
236
276
  "react": "^18.0.0 || ^19.0.0",
@@ -254,6 +294,7 @@
254
294
  "REFERENCE.md",
255
295
  "llms.txt",
256
296
  "skills",
257
- "LICENSE"
297
+ "LICENSE",
298
+ "CHANGELOG.md"
258
299
  ]
259
300
  }
@@ -52,15 +52,17 @@ from one core. The package for a framework is all a project installs.
52
52
  4. A value is controlled when given (`value` + `onValueChange`) and the component's own
53
53
  otherwise (`defaultValue`). A callback beside a value the component holds is
54
54
  `(value, details)`, and `details.cancel()` keeps the value as it was. A callback that
55
- reports something that happened (`onComplete`, `onClearErrors`, `onMonthChange`) takes only
56
- that.
55
+ reports something that happened (`onClearErrors`, `onMonthChange`) takes only that. The
56
+ names are Base UI's: `loopFocus`, `disablePointerDismissal`, a multiple Select's or
57
+ Combobox's list in `value`, One-Time Code's `validationType` and `onValueComplete`, a
58
+ toast's `timeout`; the older names still work and are marked deprecated.
57
59
  5. A control with a `name` is submitted with its form and follows the form's reset. Wrap it
58
60
  in `Field` for a label, a description and validation. `readOnly` and `keepMounted` are
59
61
  props of the parts `llms.txt` lists them for, and of no others.
60
62
 
61
63
  Per framework: React takes `render` for another element; Vue takes `as` / `as-child`, binds
62
64
  with `v-model:value` and names props in kebab case; Svelte takes a `child` snippet and
63
- `bind:value`; Solid takes `as` and `render`; Angular's parts are directives on your own
65
+ `bind:value`; Solid (2, with `@solidjs/web`) takes `as` and `render`; Angular's parts are directives on your own
64
66
  elements (`<button kpDialogTrigger>`), bound with `[(value)]`, with `[kpId]` for an id, and
65
67
  a part that comes and goes is structural (`*kpDialogPortal`, `*kpTabsPanel`: the list is in
66
68
  `llms.txt`); custom elements name each part with `kui-part` inside `<kui-dialog>`.
@@ -136,7 +138,25 @@ component's ref, kind, label, state and actions), `act({ steps: [{ ref, action,
136
138
  through the component's own handlers: its callback runs with `details.source === "agent"`
137
139
  and may cancel. Give every control an accessible name (a `<label>`, `aria-label`): it is how
138
140
  an agent finds it. Mark a destructive control `data-agent-confirm="what it does"`, private
139
- regions `data-agent-hidden`, secrets `data-agent-secret`. `allow(action)` is the policy,
141
+ regions `data-agent-hidden`, secrets `data-agent-secret` (whatever is inside is listed with its
142
+ name and its actions, never its value, its choices or whether it is checked). A bridge given a
143
+ `root` also reads what was opened from inside it (a dialog, a menu, a select's list), by the
144
+ `aria-controls` of what opened it. A step names its control by ref, by its label, by words of
145
+ the label, by the text of its row or by one of its choices; a name two controls answer to
146
+ fails with both. `subscribe((changed, changes) => …)` says of each change its `key`, `value`,
147
+ `previous`, `source` and `reason`; `record()` keeps a person's changes in `history()` beside
148
+ the agent's, each with its `source` and a sentence (`text`), and `undoSource("agent")` takes
149
+ back only the agent's. `stage({ steps })` shows a suggestion in the controls and gives
150
+ `revert()` and `keep()`. `act` takes a `signal`; `timeout` bounds a wait for `allow` or
151
+ `confirm`. A component of your own is read through `kinds` (`AgentKind`: a selector, `read`,
152
+ `perform`). A slider's `setValue` fails with what the slider holds when
153
+ its range or step does not hold the value asked for, and so does a spin button's (a Date or
154
+ Time Field's part, typed as a person types it). The thumbs of a range named by their group
155
+ are told apart by their place (`"Price, 1 of 2"`). A list of several values (a listbox, a
156
+ select with `multiple`, a tree) says `values` and takes a list in `setValue`; a closed
157
+ select's are known once its list has been read. A tree is one component: its shown nodes
158
+ are its `items` (with `level` below the top and `open` for a branch), and `setValue`,
159
+ `open` and `close` take a node's name. `allow(action)` is the policy,
140
160
  asked for every step; `confirm(action)` is a person's answer, asked for a step on something
141
161
  marked `data-agent-confirm`, and without it such a step fails with "Needs a person" whatever
142
162
  `allow` says. Never write `confirm: () => true`: open a dialog and resolve with what the
@@ -1,6 +1,6 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { AccordionProps } from "@kirana-ui/core/accordion";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  type Parts = Vocabulary["accordion"];
@@ -8,7 +8,7 @@ type Parts = Vocabulary["accordion"];
8
8
  export type RootProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<AccordionProps<Value>, "id"> & {
9
9
  id?: string;
10
10
  }>;
11
- declare function Root<Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, id, ...rest }: RootProps<Value>): ReactElement;
11
+ declare function Root<Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, id, ...rest }: RootProps<Value>): ReactElement;
12
12
  export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, {
13
13
  /**
14
14
  * What tells this item from the others: it is in the accordion's `value` while the item is
package/src/accordion.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { PartElement, parts, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
3
- import { defined, within } from "@kirana-ui/core";
4
3
  import { createContext, useContext, useId, useMemo } from "react";
4
+ import { defined, within } from "@kirana-ui/core";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { createAccordion } from "@kirana-ui/core/accordion";
7
7
  // src/accordion.tsx
@@ -17,7 +17,7 @@ function useItem(part) {
17
17
  if (!item) throw new Error(`<Accordion.${part}> must be inside <Accordion.Item>`);
18
18
  return item;
19
19
  }
20
- function Root({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, id, ...rest }) {
20
+ function Root({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, id, ...rest }) {
21
21
  const direction = useContext(DirectionContext) ?? void 0;
22
22
  const create = within(createAccordion, { direction });
23
23
  const controller = useController(create, {
@@ -28,6 +28,7 @@ function Root({ value, defaultValue, onValueChange, multiple, disabled, orientat
28
28
  disabled,
29
29
  orientation,
30
30
  loop,
31
+ loopFocus,
31
32
  id
32
33
  });
33
34
  return /* @__PURE__ */ jsx(Context.Provider, {
@@ -1 +1 @@
1
- {"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/react/src/accordion.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type {\n AccordionItem,\n AccordionProps,\n Accordion as Controller,\n} from \"@kirana-ui/core/accordion\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport {\n PartElement,\n parts,\n useController,\n useMount,\n useOptions,\n usePart,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"accordion\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<AccordionItem | null>(null)\n\nfunction useAccordion(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Accordion.${part}> must be inside <Accordion.Root>`)\n return controller\n}\n\nfunction useItem(part: string): AccordionItem {\n const item = useContext(ItemContext)\n if (!item) throw new Error(`<Accordion.${part}> must be inside <Accordion.Item>`)\n return item\n}\n\n/** `Value` is what tells an item from the others: the type of `value`'s entries. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<AccordionProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createAccordion<Value>, { direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"div\" {...rest} />\n </Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n {\n /**\n * What tells this item from the others: it is in the accordion's `value` while the item is\n * open. An item that is given none makes its own.\n */\n value?: unknown\n /** Disables this item: it cannot be opened or closed. */\n disabled?: boolean\n }\n>\n\nfunction Item({ value, disabled, ...rest }: ItemProps): ReactElement {\n const controller = useAccordion(\"Item\")\n const options = useOptions({ disabled })\n const generated = useId()\n const key = value === undefined ? generated : value\n const item = useMemo(\n () => controller.item(key, () => defined(options.get())),\n [controller, key, options]\n )\n useMount(item)\n return (\n <ItemContext.Provider value={item}>\n <PartElement of={item.root} tag=\"div\" {...rest} />\n </ItemContext.Provider>\n )\n}\n\nexport type HeaderProps = PartComponentProps<\"h3\", StateOf<Parts[\"header\"]>>\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\n\nconst Header = (props: HeaderProps) => usePart(useItem(\"Header\").header, \"h3\", props)\nconst Trigger = (props: TriggerProps) => usePart(useItem(\"Trigger\").trigger, \"button\", props)\n\nexport type PanelProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"panel\"]>,\n {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean\n }\n>\n\nfunction Panel({ keepMounted, ...props }: PanelProps): ReactElement | null {\n const item = useItem(\"Panel\")\n const mounted = useSignal(item.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={item.panel} tag=\"div\" {...props} />\n}\n\nexport const Accordion = /* @__PURE__ */ parts(\"Accordion\", { Root, Item, Header, Trigger, Panel })\n"],"mappings":";;;;;;;AA0BA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAoC,IAAI;AAE5D,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAEA,SAAS,QAAQ,MAA6B;CAC5C,MAAM,OAAO,WAAW,WAAW;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CAChF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,aACA,MACA,IACA,GAAG,QAC8B;CACjC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,iBAAwB,EAAE,UAAU,CAAC;CAC3D,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CACvC,CAAA;AAEtB;AAgBA,SAAS,KAAK,EAAE,OAAO,UAAU,GAAG,QAAiC;CACnE,MAAM,aAAa,aAAa,MAAM;CACtC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,UAAU,KAAA,IAAY,YAAY;CAC9C,MAAM,OAAO,cACL,WAAW,KAAK,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACvD;EAAC;EAAY;EAAK;CAAO,CAC3B;CACA,SAAS,IAAI;CACb,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,aAAD;GAAa,IAAI,KAAK;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CAC7B,CAAA;AAE1B;AAKA,MAAM,UAAU,UAAuB,QAAQ,QAAQ,QAAQ,CAAC,CAAC,QAAQ,MAAM,KAAK;AACpF,MAAM,WAAW,UAAwB,QAAQ,QAAQ,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AAW5F,SAAS,MAAM,EAAE,aAAa,GAAG,SAA0C;CACzE,MAAM,OAAO,QAAQ,OAAO;CAE5B,IAAI,CADY,UAAU,KAAK,OACpB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,KAAK;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAC5D;AAEA,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAM;CAAM;CAAQ;CAAS;AAAM,CAAC"}
1
+ {"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/react/src/accordion.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type {\n AccordionItem,\n AccordionProps,\n Accordion as Controller,\n} from \"@kirana-ui/core/accordion\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport {\n PartElement,\n parts,\n useController,\n useMount,\n useOptions,\n usePart,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"accordion\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<AccordionItem | null>(null)\n\nfunction useAccordion(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Accordion.${part}> must be inside <Accordion.Root>`)\n return controller\n}\n\nfunction useItem(part: string): AccordionItem {\n const item = useContext(ItemContext)\n if (!item) throw new Error(`<Accordion.${part}> must be inside <Accordion.Item>`)\n return item\n}\n\n/** `Value` is what tells an item from the others: the type of `value`'s entries. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<AccordionProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n loopFocus,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createAccordion<Value>, { direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n loopFocus,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"div\" {...rest} />\n </Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n {\n /**\n * What tells this item from the others: it is in the accordion's `value` while the item is\n * open. An item that is given none makes its own.\n */\n value?: unknown\n /** Disables this item: it cannot be opened or closed. */\n disabled?: boolean\n }\n>\n\nfunction Item({ value, disabled, ...rest }: ItemProps): ReactElement {\n const controller = useAccordion(\"Item\")\n const options = useOptions({ disabled })\n const generated = useId()\n const key = value === undefined ? generated : value\n const item = useMemo(\n () => controller.item(key, () => defined(options.get())),\n [controller, key, options]\n )\n useMount(item)\n return (\n <ItemContext.Provider value={item}>\n <PartElement of={item.root} tag=\"div\" {...rest} />\n </ItemContext.Provider>\n )\n}\n\nexport type HeaderProps = PartComponentProps<\"h3\", StateOf<Parts[\"header\"]>>\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\n\nconst Header = (props: HeaderProps) => usePart(useItem(\"Header\").header, \"h3\", props)\nconst Trigger = (props: TriggerProps) => usePart(useItem(\"Trigger\").trigger, \"button\", props)\n\nexport type PanelProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"panel\"]>,\n {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean\n }\n>\n\nfunction Panel({ keepMounted, ...props }: PanelProps): ReactElement | null {\n const item = useItem(\"Panel\")\n const mounted = useSignal(item.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={item.panel} tag=\"div\" {...props} />\n}\n\nexport const Accordion = /* @__PURE__ */ parts(\"Accordion\", { Root, Item, Header, Trigger, Panel })\n"],"mappings":";;;;;;;AA0BA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAoC,IAAI;AAE5D,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAEA,SAAS,QAAQ,MAA6B;CAC5C,MAAM,OAAO,WAAW,WAAW;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CAChF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,aACA,MACA,WACA,IACA,GAAG,QAC8B;CACjC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,iBAAwB,EAAE,UAAU,CAAC;CAC3D,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CACvC,CAAA;AAEtB;AAgBA,SAAS,KAAK,EAAE,OAAO,UAAU,GAAG,QAAiC;CACnE,MAAM,aAAa,aAAa,MAAM;CACtC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,UAAU,KAAA,IAAY,YAAY;CAC9C,MAAM,OAAO,cACL,WAAW,KAAK,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACvD;EAAC;EAAY;EAAK;CAAO,CAC3B;CACA,SAAS,IAAI;CACb,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,aAAD;GAAa,IAAI,KAAK;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CAC7B,CAAA;AAE1B;AAKA,MAAM,UAAU,UAAuB,QAAQ,QAAQ,QAAQ,CAAC,CAAC,QAAQ,MAAM,KAAK;AACpF,MAAM,WAAW,UAAwB,QAAQ,QAAQ,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AAW5F,SAAS,MAAM,EAAE,aAAa,GAAG,SAA0C;CACzE,MAAM,OAAO,QAAQ,OAAO;CAE5B,IAAI,CADY,UAAU,KAAK,OACpB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,KAAK;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAC5D;AAEA,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAM;CAAM;CAAQ;CAAS;AAAM,CAAC"}
package/src/autosize.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
5
5
  export type TextareaProps = PartComponentProps<"textarea", StateOf<Vocabulary["autosize"]["textarea"]>>;
6
6
  /** A `<textarea>` as tall as its text. It takes what a `<textarea>` takes. */
package/src/avatar.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
- import { ReactElement } from "react";
4
2
  import { AvatarFallbackProps, AvatarImageProps } from "@kirana-ui/core/avatar";
3
+ import { ReactElement } from "react";
4
+ import { StateOf } from "@kirana-ui/core";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  type Parts = Vocabulary["avatar"];
7
7
  export type RootProps = PartComponentProps<"span", StateOf<Parts["root"]>>;
package/src/avatar.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PartElement, parts, useController, useIsomorphicLayoutEffect, useMount, useSignal } from "./runtime.js";
2
+ import { createAvatar } from "@kirana-ui/core/avatar";
2
3
  import { createContext, useContext, useRef, useState } from "react";
3
4
  import { jsx } from "react/jsx-runtime";
4
- import { createAvatar } from "@kirana-ui/core/avatar";
5
5
  // src/avatar.tsx
6
6
  const Context = createContext(null);
7
7
  function useAvatar(part) {
@@ -28,14 +28,14 @@ function Image({ src, onLoadingStatusChange, keepMounted, ...props }) {
28
28
  told.current = onLoadingStatusChange;
29
29
  const [report] = useState(() => controller.statusReport(() => told.current));
30
30
  useMount(report);
31
- const status = useSignal(controller.status);
31
+ const mounted = useSignal(controller.imageMounted);
32
32
  if (keepMounted) return /* @__PURE__ */ jsx(PartElement, {
33
33
  of: controller.keptImage,
34
34
  tag: "img",
35
35
  src,
36
36
  ...props
37
37
  });
38
- if (status !== "loaded") return null;
38
+ if (!mounted) return null;
39
39
  return /* @__PURE__ */ jsx(PartElement, {
40
40
  of: controller.image,
41
41
  tag: "img",
package/src/avatar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/react/src/avatar.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type {\n AvatarFallbackProps,\n AvatarImageProps,\n Avatar as Controller,\n} from \"@kirana-ui/core/avatar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useRef, useState } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport {\n PartElement,\n parts,\n useController,\n useIsomorphicLayoutEffect,\n useMount,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"avatar\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useAvatar(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Avatar.${part}> must be inside <Avatar.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"span\", StateOf<Parts[\"root\"]>>\n\nfunction Root(props: RootProps): ReactElement {\n const controller = useController(createAvatar, {})\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"span\" {...props} />\n </Context.Provider>\n )\n}\n\nexport type ImageProps = PartComponentProps<\n \"img\",\n StateOf<Parts[\"image\"]>,\n {\n /**\n * Called each time the picture's loading status changes: `loading` once it has an address,\n * then `loaded` or `error`; `idle` again when its address is taken away. The root says the\n * same in `data-image-loading-status`.\n */\n onLoadingStatusChange?: AvatarImageProps[\"onLoadingStatusChange\"]\n /**\n * Keeps the element in the page while the picture loads, as Base UI's: it loads the\n * picture itself (`loading=\"lazy\"` works), and until it has loaded it is `aria-hidden`,\n * with `data-loading` or `data-error` for the design to hide or fade it by. Default:\n * `false`, the element is drawn once the picture has loaded.\n */\n keepMounted?: boolean\n }\n>\n\n/** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */\nfunction Image({\n src,\n onLoadingStatusChange,\n keepMounted,\n ...props\n}: ImageProps): ReactElement | null {\n const controller = useAvatar(\"Image\")\n // After the render commits, never during it: the load it starts changes the status, which\n // other parts are drawn from, and React forbids updating them mid-render.\n useIsomorphicLayoutEffect(() => controller.source.set(src), [controller, src])\n const told = useRef(onLoadingStatusChange)\n told.current = onLoadingStatusChange\n const [report] = useState(() => controller.statusReport(() => told.current))\n useMount(report)\n const status = useSignal(controller.status)\n if (keepMounted) return <PartElement of={controller.keptImage} tag=\"img\" src={src} {...props} />\n if (status !== \"loaded\") return null\n return <PartElement of={controller.image} tag=\"img\" {...props} />\n}\n\nexport type FallbackProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"fallback\"]>,\n {\n /**\n * How long to wait before showing, in milliseconds, so a picture that loads sooner never\n * lets the fallback be seen. Read once. Default: `0`, at once.\n */\n delay?: AvatarFallbackProps[\"delay\"]\n }\n>\n\n/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */\nfunction Fallback({ delay, ...props }: FallbackProps): ReactElement | null {\n const controller = useAvatar(\"Fallback\")\n const [presence] = useState(() => controller.fallbackPresence({ delay }))\n useMount(presence)\n const shown = useSignal(presence.shown)\n if (!shown) return null\n return <PartElement of={controller.fallback} tag=\"span\" {...props} />\n}\n\nexport const Avatar = /* @__PURE__ */ parts(\"Avatar\", { Root, Image, Fallback })\n"],"mappings":";;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,UAAU,MAA0B;CAC3C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,WAAW,KAAK,+BAA+B;CAChF,OAAO;AACT;AAIA,SAAS,KAAK,OAAgC;CAC5C,MAAM,aAAa,cAAc,cAAc,CAAC,CAAC;CACjD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAO,GAAI;EAAQ,CAAA;CACzC,CAAA;AAEtB;;AAuBA,SAAS,MAAM,EACb,KACA,uBACA,aACA,GAAG,SAC+B;CAClC,MAAM,aAAa,UAAU,OAAO;CAGpC,gCAAgC,WAAW,OAAO,IAAI,GAAG,GAAG,CAAC,YAAY,GAAG,CAAC;CAC7E,MAAM,OAAO,OAAO,qBAAqB;CACzC,KAAK,UAAU;CACf,MAAM,CAAC,UAAU,eAAe,WAAW,mBAAmB,KAAK,OAAO,CAAC;CAC3E,SAAS,MAAM;CACf,MAAM,SAAS,UAAU,WAAW,MAAM;CAC1C,IAAI,aAAa,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAW,KAAI;EAAW;EAAK,GAAI;CAAQ,CAAA;CAC/F,IAAI,WAAW,UAAU,OAAO;CAChC,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAClE;;AAeA,SAAS,SAAS,EAAE,OAAO,GAAG,SAA6C;CACzE,MAAM,aAAa,UAAU,UAAU;CACvC,MAAM,CAAC,YAAY,eAAe,WAAW,iBAAiB,EAAE,MAAM,CAAC,CAAC;CACxE,SAAS,QAAQ;CAEjB,IAAI,CADU,UAAU,SAAS,KACxB,GAAG,OAAO;CACnB,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAU,KAAI;EAAO,GAAI;CAAQ,CAAA;AACtE;AAEA,MAAa,SAAyB,sBAAM,UAAU;CAAE;CAAM;CAAO;AAAS,CAAC"}
1
+ {"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/react/src/avatar.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type {\n AvatarFallbackProps,\n AvatarImageProps,\n Avatar as Controller,\n} from \"@kirana-ui/core/avatar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useRef, useState } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport {\n PartElement,\n parts,\n useController,\n useIsomorphicLayoutEffect,\n useMount,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"avatar\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useAvatar(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Avatar.${part}> must be inside <Avatar.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"span\", StateOf<Parts[\"root\"]>>\n\nfunction Root(props: RootProps): ReactElement {\n const controller = useController(createAvatar, {})\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"span\" {...props} />\n </Context.Provider>\n )\n}\n\nexport type ImageProps = PartComponentProps<\n \"img\",\n StateOf<Parts[\"image\"]>,\n {\n /**\n * Called each time the picture's loading status changes: `loading` once it has an address,\n * then `loaded` or `error`; `idle` again when its address is taken away. The root says the\n * same in `data-image-loading-status`.\n */\n onLoadingStatusChange?: AvatarImageProps[\"onLoadingStatusChange\"]\n /**\n * Keeps the element in the page while the picture loads, as Base UI's: it loads the\n * picture itself (`loading=\"lazy\"` works), and until it has loaded it is `aria-hidden`,\n * with `data-loading` or `data-error` for the design to hide or fade it by. Default:\n * `false`, the element is drawn once the picture has loaded.\n */\n keepMounted?: boolean\n }\n>\n\n/** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */\nfunction Image({\n src,\n onLoadingStatusChange,\n keepMounted,\n ...props\n}: ImageProps): ReactElement | null {\n const controller = useAvatar(\"Image\")\n // After the render commits, never during it: the load it starts changes the status, which\n // other parts are drawn from, and React forbids updating them mid-render.\n useIsomorphicLayoutEffect(() => controller.source.set(src), [controller, src])\n const told = useRef(onLoadingStatusChange)\n told.current = onLoadingStatusChange\n const [report] = useState(() => controller.statusReport(() => told.current))\n useMount(report)\n const mounted = useSignal(controller.imageMounted)\n if (keepMounted) return <PartElement of={controller.keptImage} tag=\"img\" src={src} {...props} />\n // From when it has loaded, and through its exit.\n if (!mounted) return null\n return <PartElement of={controller.image} tag=\"img\" {...props} />\n}\n\nexport type FallbackProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"fallback\"]>,\n {\n /**\n * How long to wait before showing, in milliseconds, so a picture that loads sooner never\n * lets the fallback be seen. Read once. Default: `0`, at once.\n */\n delay?: AvatarFallbackProps[\"delay\"]\n }\n>\n\n/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */\nfunction Fallback({ delay, ...props }: FallbackProps): ReactElement | null {\n const controller = useAvatar(\"Fallback\")\n const [presence] = useState(() => controller.fallbackPresence({ delay }))\n useMount(presence)\n const shown = useSignal(presence.shown)\n if (!shown) return null\n return <PartElement of={controller.fallback} tag=\"span\" {...props} />\n}\n\nexport const Avatar = /* @__PURE__ */ parts(\"Avatar\", { Root, Image, Fallback })\n"],"mappings":";;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,UAAU,MAA0B;CAC3C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,WAAW,KAAK,+BAA+B;CAChF,OAAO;AACT;AAIA,SAAS,KAAK,OAAgC;CAC5C,MAAM,aAAa,cAAc,cAAc,CAAC,CAAC;CACjD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAO,GAAI;EAAQ,CAAA;CACzC,CAAA;AAEtB;;AAuBA,SAAS,MAAM,EACb,KACA,uBACA,aACA,GAAG,SAC+B;CAClC,MAAM,aAAa,UAAU,OAAO;CAGpC,gCAAgC,WAAW,OAAO,IAAI,GAAG,GAAG,CAAC,YAAY,GAAG,CAAC;CAC7E,MAAM,OAAO,OAAO,qBAAqB;CACzC,KAAK,UAAU;CACf,MAAM,CAAC,UAAU,eAAe,WAAW,mBAAmB,KAAK,OAAO,CAAC;CAC3E,SAAS,MAAM;CACf,MAAM,UAAU,UAAU,WAAW,YAAY;CACjD,IAAI,aAAa,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAW,KAAI;EAAW;EAAK,GAAI;CAAQ,CAAA;CAE/F,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAClE;;AAeA,SAAS,SAAS,EAAE,OAAO,GAAG,SAA6C;CACzE,MAAM,aAAa,UAAU,UAAU;CACvC,MAAM,CAAC,YAAY,eAAe,WAAW,iBAAiB,EAAE,MAAM,CAAC,CAAC;CACxE,SAAS,QAAQ;CAEjB,IAAI,CADU,UAAU,SAAS,KACxB,GAAG,OAAO;CACnB,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAU,KAAI;EAAO,GAAI;CAAQ,CAAA;AACtE;AAEA,MAAa,SAAyB,sBAAM,UAAU;CAAE;CAAM;CAAO;AAAS,CAAC"}
package/src/button.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { ButtonProps as ButtonProps$1 } from "@kirana-ui/core/button";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  export type ButtonProps = PartComponentProps<"button", StateOf<Vocabulary["button"]["root"]>, ButtonProps$1>;
7
- /** A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one. */
7
+ /**
8
+ * A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one; a
9
+ * link that navigates (`render={<a href="/x" />}`) stays a link.
10
+ */
8
11
  export declare const Button: ({ disabled, focusableWhenDisabled, nativeButton, ...rest }: ButtonProps) => ReactElement;
9
12
  //# sourceMappingURL=button.d.ts.map
package/src/button.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import { component, useController, usePart } from "./runtime.js";
2
2
  import { createButton } from "@kirana-ui/core/button";
3
3
  // src/button.tsx
4
- /** A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one. */
4
+ /**
5
+ * A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one; a
6
+ * link that navigates (`render={<a href="/x" />}`) stays a link.
7
+ */
5
8
  const Button = /* @__PURE__ */ component("Button", function Button({ disabled, focusableWhenDisabled, nativeButton, ...rest }) {
6
9
  const controller = useController(createButton, {
7
10
  disabled,
package/src/button.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/react/src/button.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport type { ReactElement } from \"react\"\n\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type ButtonProps = PartComponentProps<\n \"button\",\n StateOf<Vocabulary[\"button\"][\"root\"]>,\n CoreProps\n>\n\n/** A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one. */\nexport const Button = /* @__PURE__ */ component(\n \"Button\",\n function Button({\n disabled,\n focusableWhenDisabled,\n nativeButton,\n ...rest\n }: ButtonProps): ReactElement {\n const controller = useController(createButton, {\n disabled,\n focusableWhenDisabled,\n nativeButton,\n })\n return usePart(controller.root, \"button\", rest)\n }\n)\n"],"mappings":";;;;AAgBA,MAAa,SAAyB,0BACpC,UACA,SAAS,OAAO,EACd,UACA,uBACA,cACA,GAAG,QACyB;CAC5B,MAAM,aAAa,cAAc,cAAc;EAC7C;EACA;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW,MAAM,UAAU,IAAI;AAChD,CACF"}
1
+ {"version":3,"file":"button.js","names":[],"sources":["../../../../packages/react/src/button.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport type { ReactElement } from \"react\"\n\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type ButtonProps = PartComponentProps<\n \"button\",\n StateOf<Vocabulary[\"button\"][\"root\"]>,\n CoreProps\n>\n\n/**\n * A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one; a\n * link that navigates (`render={<a href=\"/x\" />}`) stays a link.\n */\nexport const Button = /* @__PURE__ */ component(\n \"Button\",\n function Button({\n disabled,\n focusableWhenDisabled,\n nativeButton,\n ...rest\n }: ButtonProps): ReactElement {\n const controller = useController(createButton, {\n disabled,\n focusableWhenDisabled,\n nativeButton,\n })\n return usePart(controller.root, \"button\", rest)\n }\n)\n"],"mappings":";;;;;;;AAmBA,MAAa,SAAyB,0BACpC,UACA,SAAS,OAAO,EACd,UACA,uBACA,cACA,GAAG,QACyB;CAC5B,MAAM,aAAa,cAAc,cAAc;EAC7C;EACA;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW,MAAM,UAAU,IAAI;AAChD,CACF"}
package/src/calendar.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement, ReactNode } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { Calendar as Calendar$1, CalendarDay, CalendarMode, CalendarMonth, CalendarProps, CalendarWeekday } from "@kirana-ui/core/calendar";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  type Parts = Vocabulary["calendar"];
@@ -13,7 +13,7 @@ declare const Context: import("react").Context<Calendar$1 | null>;
13
13
  export type RootProps<Mode extends CalendarMode = "single"> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CalendarProps<Mode>, "id"> & {
14
14
  id?: string;
15
15
  }>;
16
- declare function Root<Mode extends CalendarMode = "single">({ value, defaultValue, onValueChange, mode, minDays, maxDays, months, pagedNavigation, month, defaultMonth, onMonthChange, defaultFocusedValue, locale, calendarSystem, min, max, isDateUnavailable, disabled, readOnly, fixedWeeks, name, form, id, ...rest }: RootProps<Mode>): ReactElement;
16
+ declare function Root<Mode extends CalendarMode = "single">({ value, defaultValue, onValueChange, mode, required, minDays, maxDays, months, pagedNavigation, month, defaultMonth, onMonthChange, defaultFocusedValue, locale, calendarSystem, min, max, isDateUnavailable, disabled, readOnly, fixedWeeks, name, form, id, ...rest }: RootProps<Mode>): ReactElement;
17
17
  export type HeadingProps = PartComponentProps<"div", StateOf<Parts["heading"]>>;
18
18
  /** Names the month shown, unless it is given something else to say. */
19
19
  declare function Heading({ children, ...props }: HeadingProps): ReactElement;
@@ -50,15 +50,15 @@ export type HeadCellProps = PartComponentProps<"th", StateOf<Parts["headCell"]>,
50
50
  }>;
51
51
  declare function HeadCell({ weekday, ...props }: HeadCellProps): ReactElement;
52
52
  export type CellProps = PartComponentProps<"td", StateOf<Parts["cell"]>, {
53
- /** The day it holds, as `Calendar.Weeks` gave it: `day.date`. */
53
+ /** The day it holds, as `Calendar.Weeks` gave it: `day.date`. A `Day` inside takes it too. */
54
54
  date: string;
55
55
  }>;
56
56
  declare function Cell({ date, ...props }: CellProps): ReactElement;
57
57
  export type DayProps = PartComponentProps<"button", StateOf<Parts["day"]>, {
58
- /** The day it is the button of, as `Calendar.Weeks` gave it: `day.date`. */
59
- date: string;
58
+ /** The day it is the button of. Left out, the `Calendar.Cell`'s it is inside. */
59
+ date?: string;
60
60
  }>;
61
- declare function Day({ date, ...props }: DayProps): ReactElement;
61
+ declare function Day({ date: given, ...props }: DayProps): ReactElement;
62
62
  export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
63
63
  /** The hidden input the value is submitted by, when the root has a `name`. */
64
64
  declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
package/src/calendar.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { parts, useController, usePart, useSignal } from "./runtime.js";
3
- import { within } from "@kirana-ui/core";
4
3
  import { Fragment, createContext, useContext, useMemo } from "react";
5
- import { createCalendar } from "@kirana-ui/core/calendar";
4
+ import { within } from "@kirana-ui/core";
6
5
  import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
6
+ import { createCalendar } from "@kirana-ui/core/calendar";
7
7
  // src/calendar.tsx
8
8
  /**
9
9
  * The calendar its parts are inside. Exported for a component that is made of one (a date picker
@@ -12,18 +12,20 @@ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
12
12
  const Context = createContext(null);
13
13
  /** The place of the month its parts are drawn in, inside `Calendar.Months`. */
14
14
  const MonthContext = createContext(void 0);
15
+ const CellContext = createContext(void 0);
15
16
  function useCalendar(part) {
16
17
  const controller = useContext(Context);
17
18
  if (!controller) throw new Error(`<Calendar.${part}> must be inside <Calendar.Root>`);
18
19
  return controller;
19
20
  }
20
- function Root({ value, defaultValue, onValueChange, mode, minDays, maxDays, months, pagedNavigation, month, defaultMonth, onMonthChange, defaultFocusedValue, locale, calendarSystem, min, max, isDateUnavailable, disabled, readOnly, fixedWeeks, name, form, id, ...rest }) {
21
+ function Root({ value, defaultValue, onValueChange, mode, required, minDays, maxDays, months, pagedNavigation, month, defaultMonth, onMonthChange, defaultFocusedValue, locale, calendarSystem, min, max, isDateUnavailable, disabled, readOnly, fixedWeeks, name, form, id, ...rest }) {
21
22
  const direction = useContext(DirectionContext) ?? void 0;
22
23
  const controller = useController(within(createCalendar, { direction }), {
23
24
  value,
24
25
  defaultValue,
25
26
  onValueChange,
26
27
  mode,
28
+ required,
27
29
  minDays,
28
30
  maxDays,
29
31
  months,
@@ -91,10 +93,16 @@ function HeadCell({ weekday, ...props }) {
91
93
  }
92
94
  function Cell({ date, ...props }) {
93
95
  const index = useContext(MonthContext);
94
- return usePart(useCalendar("Cell").cell(date, index), "td", props);
96
+ return /* @__PURE__ */ jsx(CellContext.Provider, {
97
+ value: date,
98
+ children: usePart(useCalendar("Cell").cell(date, index), "td", props)
99
+ });
95
100
  }
96
- function Day({ date, ...props }) {
101
+ function Day({ date: given, ...props }) {
97
102
  const index = useContext(MonthContext);
103
+ const cell = useContext(CellContext);
104
+ const date = given ?? cell;
105
+ if (date === void 0) throw new Error("<Calendar.Day> needs a date or a <Calendar.Cell> around it");
98
106
  return usePart(useCalendar("Day").day(date, index), "button", props);
99
107
  }
100
108
  /** The hidden input the value is submitted by, when the root has a `name`. */
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/react/src/calendar.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCalendar } from \"@kirana-ui/core/calendar\"\nimport type {\n Calendar as Controller,\n CalendarDay,\n CalendarMode,\n CalendarMonth,\n CalendarProps,\n CalendarValue,\n CalendarWeekday,\n} from \"@kirana-ui/core/calendar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"calendar\"]\n\n/**\n * The calendar its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the calendar's parts).\n */\nconst Context = createContext<Controller | null>(null)\n/** For a component made of this one's parts: a date picker. */\nexport { Context as CalendarContext }\n\n/** The place of the month its parts are drawn in, inside `Calendar.Months`. */\nconst MonthContext = createContext<number | undefined>(undefined)\n\nfunction useCalendar(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Calendar.${part}> must be inside <Calendar.Root>`)\n return controller\n}\n\n/** `value` and `onValueChange` are typed by `mode`: a day, a range, or a list of days. */\nexport type RootProps<Mode extends CalendarMode = \"single\"> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<CalendarProps<Mode>, \"id\"> & { id?: string }\n>\n\nfunction Root<Mode extends CalendarMode = \"single\">({\n value,\n defaultValue,\n onValueChange,\n mode,\n minDays,\n maxDays,\n months,\n pagedNavigation,\n month,\n defaultMonth,\n onMonthChange,\n defaultFocusedValue,\n locale,\n calendarSystem,\n min,\n max,\n isDateUnavailable,\n disabled,\n readOnly,\n fixedWeeks,\n name,\n form,\n id,\n ...rest\n}: RootProps<Mode>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CalendarProps, Controller>(\n within(createCalendar, { direction }),\n {\n // The core holds any mode's value; the caller's is its mode's.\n value: value as CalendarValue | undefined,\n defaultValue: defaultValue as CalendarValue | undefined,\n onValueChange: onValueChange as CalendarProps[\"onValueChange\"],\n mode,\n minDays,\n maxDays,\n months,\n pagedNavigation,\n month,\n defaultMonth,\n onMonthChange,\n defaultFocusedValue,\n locale,\n calendarSystem,\n min,\n max,\n isDateUnavailable,\n disabled,\n readOnly,\n fixedWeeks,\n name,\n form,\n id,\n }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type HeadingProps = PartComponentProps<\"div\", StateOf<Parts[\"heading\"]>>\n\n/** The month a part is drawn in: the one `Calendar.Months` gave, or the first. */\nconst useMonth = (part: string) => useCalendar(part).monthAt(useContext(MonthContext) ?? 0)\n\n/** Names the month shown, unless it is given something else to say. */\nfunction Heading({ children, ...props }: HeadingProps): ReactElement {\n const month = useMonth(\"Heading\")\n const title = useSignal(month.title)\n return usePart(month.heading, \"div\", { ...props, children: children ?? title })\n}\n\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\n\nconst Previous = (props: PreviousProps) =>\n usePart(useCalendar(\"Previous\").previous, \"button\", props)\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\n\nconst Next = (props: NextProps) => usePart(useCalendar(\"Next\").next, \"button\", props)\nexport type GridProps = PartComponentProps<\"table\", StateOf<Parts[\"grid\"]>>\n\nconst Grid = (props: GridProps) => usePart(useMonth(\"Grid\").grid, \"table\", props)\n\nexport interface MonthsProps {\n /** Draws one month, once for each shown: its heading and its grid. */\n children: (month: CalendarMonth) => ReactNode\n}\n\n/**\n * Draws its child once for each month shown (`months` on the root), side by side: the parts\n * inside each are that month's. Left out for one month.\n */\nfunction Months({ children }: MonthsProps) {\n const months = useSignal(useCalendar(\"Months\").months)\n return (\n <>\n {months.map((month) => (\n <MonthContext.Provider key={month.index} value={month.index}>\n {children(month)}\n </MonthContext.Provider>\n ))}\n </>\n )\n}\n\nexport interface WeekdaysProps {\n /** Draws one day of the week, once for each: its heading cell. */\n children: (weekday: CalendarWeekday) => ReactNode\n}\n\n/** Draws its child once for each day of the week, in the locale's order. */\nfunction Weekdays({ children }: WeekdaysProps) {\n const weekdays = useSignal(useCalendar(\"Weekdays\").weekdays)\n return (\n <>\n {weekdays.map((weekday) => (\n <Fragment key={weekday.index}>{children(weekday)}</Fragment>\n ))}\n </>\n )\n}\n\nexport interface WeeksProps {\n /** Draws one week, once for each of the month shown: a row of its days. */\n children: (week: readonly CalendarDay[]) => ReactNode\n}\n\n/** Draws its child once for each week of the month shown. */\nfunction Weeks({ children }: WeeksProps) {\n const weeks = useSignal(useMonth(\"Weeks\").weeks)\n return (\n <>\n {weeks.map((week) => (\n <Fragment key={week[0]!.date}>{children(week)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type HeadCellProps = PartComponentProps<\n \"th\",\n StateOf<Parts[\"headCell\"]>,\n {\n /** The day of the week it heads: an entry `Calendar.Weekdays` gave. */\n weekday: CalendarWeekday\n }\n>\n\nfunction HeadCell({ weekday, ...props }: HeadCellProps): ReactElement {\n const controller = useCalendar(\"HeadCell\")\n const part = useMemo(() => controller.headCell(weekday), [controller, weekday])\n return usePart(part, \"th\", props)\n}\n\nexport type CellProps = PartComponentProps<\n \"td\",\n StateOf<Parts[\"cell\"]>,\n {\n /** The day it holds, as `Calendar.Weeks` gave it: `day.date`. */\n date: string\n }\n>\n\nfunction Cell({ date, ...props }: CellProps): ReactElement {\n const index = useContext(MonthContext)\n return usePart(useCalendar(\"Cell\").cell(date, index), \"td\", props)\n}\n\nexport type DayProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"day\"]>,\n {\n /** The day it is the button of, as `Calendar.Weeks` gave it: `day.date`. */\n date: string\n }\n>\n\nfunction Day({ date, ...props }: DayProps): ReactElement {\n const index = useContext(MonthContext)\n return usePart(useCalendar(\"Day\").day(date, index), \"button\", props)\n}\n\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\n/** The hidden input the value is submitted by, when the root has a `name`. */\nconst Input = (props: InputProps) => usePart(useCalendar(\"Input\").input, \"input\", props)\n\nexport const Calendar = /* @__PURE__ */ parts(\"Calendar\", {\n Root,\n Heading,\n Previous,\n Next,\n Months,\n Grid,\n Weekdays,\n HeadCell,\n Weeks,\n Cell,\n Day,\n Input,\n})\n"],"mappings":"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"}
1
+ {"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/react/src/calendar.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCalendar } from \"@kirana-ui/core/calendar\"\nimport type {\n Calendar as Controller,\n CalendarDay,\n CalendarMode,\n CalendarMonth,\n CalendarProps,\n CalendarValue,\n CalendarWeekday,\n} from \"@kirana-ui/core/calendar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"calendar\"]\n\n/**\n * The calendar its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the calendar's parts).\n */\nconst Context = createContext<Controller | null>(null)\n/** For a component made of this one's parts: a date picker. */\nexport { Context as CalendarContext }\n\n/** The place of the month its parts are drawn in, inside `Calendar.Months`. */\nconst MonthContext = createContext<number | undefined>(undefined)\n// The day a cell holds, for the day button inside it.\nconst CellContext = createContext<string | undefined>(undefined)\n\nfunction useCalendar(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Calendar.${part}> must be inside <Calendar.Root>`)\n return controller\n}\n\n/** `value` and `onValueChange` are typed by `mode`: a day, a range, or a list of days. */\nexport type RootProps<Mode extends CalendarMode = \"single\"> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<CalendarProps<Mode>, \"id\"> & { id?: string }\n>\n\nfunction Root<Mode extends CalendarMode = \"single\">({\n value,\n defaultValue,\n onValueChange,\n mode,\n required,\n minDays,\n maxDays,\n months,\n pagedNavigation,\n month,\n defaultMonth,\n onMonthChange,\n defaultFocusedValue,\n locale,\n calendarSystem,\n min,\n max,\n isDateUnavailable,\n disabled,\n readOnly,\n fixedWeeks,\n name,\n form,\n id,\n ...rest\n}: RootProps<Mode>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CalendarProps, Controller>(\n within(createCalendar, { direction }),\n {\n // The core holds any mode's value; the caller's is its mode's.\n value: value as CalendarValue | undefined,\n defaultValue: defaultValue as CalendarValue | undefined,\n onValueChange: onValueChange as CalendarProps[\"onValueChange\"],\n mode,\n required,\n minDays,\n maxDays,\n months,\n pagedNavigation,\n month,\n defaultMonth,\n onMonthChange,\n defaultFocusedValue,\n locale,\n calendarSystem,\n min,\n max,\n isDateUnavailable,\n disabled,\n readOnly,\n fixedWeeks,\n name,\n form,\n id,\n }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type HeadingProps = PartComponentProps<\"div\", StateOf<Parts[\"heading\"]>>\n\n/** The month a part is drawn in: the one `Calendar.Months` gave, or the first. */\nconst useMonth = (part: string) => useCalendar(part).monthAt(useContext(MonthContext) ?? 0)\n\n/** Names the month shown, unless it is given something else to say. */\nfunction Heading({ children, ...props }: HeadingProps): ReactElement {\n const month = useMonth(\"Heading\")\n const title = useSignal(month.title)\n return usePart(month.heading, \"div\", { ...props, children: children ?? title })\n}\n\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\n\nconst Previous = (props: PreviousProps) =>\n usePart(useCalendar(\"Previous\").previous, \"button\", props)\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\n\nconst Next = (props: NextProps) => usePart(useCalendar(\"Next\").next, \"button\", props)\nexport type GridProps = PartComponentProps<\"table\", StateOf<Parts[\"grid\"]>>\n\nconst Grid = (props: GridProps) => usePart(useMonth(\"Grid\").grid, \"table\", props)\n\nexport interface MonthsProps {\n /** Draws one month, once for each shown: its heading and its grid. */\n children: (month: CalendarMonth) => ReactNode\n}\n\n/**\n * Draws its child once for each month shown (`months` on the root), side by side: the parts\n * inside each are that month's. Left out for one month.\n */\nfunction Months({ children }: MonthsProps) {\n const months = useSignal(useCalendar(\"Months\").months)\n return (\n <>\n {months.map((month) => (\n <MonthContext.Provider key={month.index} value={month.index}>\n {children(month)}\n </MonthContext.Provider>\n ))}\n </>\n )\n}\n\nexport interface WeekdaysProps {\n /** Draws one day of the week, once for each: its heading cell. */\n children: (weekday: CalendarWeekday) => ReactNode\n}\n\n/** Draws its child once for each day of the week, in the locale's order. */\nfunction Weekdays({ children }: WeekdaysProps) {\n const weekdays = useSignal(useCalendar(\"Weekdays\").weekdays)\n return (\n <>\n {weekdays.map((weekday) => (\n <Fragment key={weekday.index}>{children(weekday)}</Fragment>\n ))}\n </>\n )\n}\n\nexport interface WeeksProps {\n /** Draws one week, once for each of the month shown: a row of its days. */\n children: (week: readonly CalendarDay[]) => ReactNode\n}\n\n/** Draws its child once for each week of the month shown. */\nfunction Weeks({ children }: WeeksProps) {\n const weeks = useSignal(useMonth(\"Weeks\").weeks)\n return (\n <>\n {weeks.map((week) => (\n <Fragment key={week[0]!.date}>{children(week)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type HeadCellProps = PartComponentProps<\n \"th\",\n StateOf<Parts[\"headCell\"]>,\n {\n /** The day of the week it heads: an entry `Calendar.Weekdays` gave. */\n weekday: CalendarWeekday\n }\n>\n\nfunction HeadCell({ weekday, ...props }: HeadCellProps): ReactElement {\n const controller = useCalendar(\"HeadCell\")\n const part = useMemo(() => controller.headCell(weekday), [controller, weekday])\n return usePart(part, \"th\", props)\n}\n\nexport type CellProps = PartComponentProps<\n \"td\",\n StateOf<Parts[\"cell\"]>,\n {\n /** The day it holds, as `Calendar.Weeks` gave it: `day.date`. A `Day` inside takes it too. */\n date: string\n }\n>\n\nfunction Cell({ date, ...props }: CellProps): ReactElement {\n const index = useContext(MonthContext)\n return (\n <CellContext.Provider value={date}>\n {usePart(useCalendar(\"Cell\").cell(date, index), \"td\", props)}\n </CellContext.Provider>\n )\n}\n\nexport type DayProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"day\"]>,\n {\n /** The day it is the button of. Left out, the `Calendar.Cell`'s it is inside. */\n date?: string\n }\n>\n\nfunction Day({ date: given, ...props }: DayProps): ReactElement {\n const index = useContext(MonthContext)\n const cell = useContext(CellContext)\n const date = given ?? cell\n if (date === undefined)\n throw new Error(\"<Calendar.Day> needs a date or a <Calendar.Cell> around it\")\n return usePart(useCalendar(\"Day\").day(date, index), \"button\", props)\n}\n\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\n/** The hidden input the value is submitted by, when the root has a `name`. */\nconst Input = (props: InputProps) => usePart(useCalendar(\"Input\").input, \"input\", props)\n\nexport const Calendar = /* @__PURE__ */ parts(\"Calendar\", {\n Root,\n Heading,\n Previous,\n Next,\n Months,\n Grid,\n Weekdays,\n HeadCell,\n Weeks,\n Cell,\n Day,\n Input,\n})\n"],"mappings":"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"}
package/src/carousel.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { CarouselProps } from "@kirana-ui/core/carousel";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  type Parts = Vocabulary["carousel"];
@@ -11,8 +11,11 @@ declare function Root({ index, defaultIndex, onIndexChange, orientation, loop, i
11
11
  export type ViewportProps = PartComponentProps<"div", StateOf<Parts["viewport"]>>;
12
12
  declare const Viewport: (props: ViewportProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
13
13
  export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, {
14
- /** Its place among the slides, from 0. */
15
- index: number;
14
+ /**
15
+ * Its place among the slides, from 0. Left out, its place in the page, once it is there:
16
+ * give it on a page a server draws, which cannot count them.
17
+ */
18
+ index?: number;
16
19
  }>;
17
20
  declare function Item({ index, ...props }: ItemProps): ReactElement;
18
21
  export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
package/src/carousel.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { parts, useController, usePart } from "./runtime.js";
3
- import { within } from "@kirana-ui/core";
4
3
  import { createContext, useContext, useMemo } from "react";
4
+ import { within } from "@kirana-ui/core";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { createCarousel } from "@kirana-ui/core/carousel";
7
7
  // src/carousel.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/react/src/carousel.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { Carousel as Controller, CarouselProps } from \"@kirana-ui/core/carousel\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"carousel\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useCarousel(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Carousel.${part}> must be inside <Carousel.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<CarouselProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n index,\n defaultIndex,\n onIndexChange,\n orientation,\n loop,\n id,\n ...rest\n}: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CarouselProps, Controller>(\n within(createCarousel, { direction }),\n { index, defaultIndex, onIndexChange, orientation, loop, id }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type ViewportProps = PartComponentProps<\"div\", StateOf<Parts[\"viewport\"]>>\n\nconst Viewport = (props: ViewportProps) => usePart(useCarousel(\"Viewport\").viewport, \"div\", props)\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n {\n /** Its place among the slides, from 0. */\n index: number\n }\n>\n\nfunction Item({ index, ...props }: ItemProps): ReactElement {\n const controller = useCarousel(\"Item\")\n const part = useMemo(() => controller.item(index), [controller, index])\n return usePart(part, \"div\", props)\n}\n\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\n\nconst Previous = (props: PreviousProps) =>\n usePart(useCarousel(\"Previous\").previous, \"button\", props)\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\n\nconst Next = (props: NextProps) => usePart(useCarousel(\"Next\").next, \"button\", props)\n\nexport type IndicatorProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** The slide it goes to, from 0. */\n index: number\n }\n>\n\nfunction Indicator({ index, ...props }: IndicatorProps): ReactElement {\n const controller = useCarousel(\"Indicator\")\n const part = useMemo(() => controller.indicator(index), [controller, index])\n return usePart(part, \"button\", props)\n}\n\nexport const Carousel = /* @__PURE__ */ parts(\"Carousel\", {\n Root,\n Viewport,\n Item,\n Previous,\n Next,\n Indicator,\n})\n"],"mappings":";;;;;;;AAcA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,aAAa,KAAK,iCAAiC;CACpF,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,aACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,gBAAgB,EAAE,UAAU,CAAC,GACpC;EAAE;EAAO;EAAc;EAAe;EAAa;EAAM;CAAG,CAC9D;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAIA,MAAM,YAAY,UAAyB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AAWjG,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,MAAM,aAAa,YAAY,MAAM;CACrC,MAAM,OAAO,cAAc,WAAW,KAAK,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CACtE,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAIA,MAAM,YAAY,UAChB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAG3D,MAAM,QAAQ,UAAqB,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAWpF,SAAS,UAAU,EAAE,OAAO,GAAG,SAAuC;CACpE,MAAM,aAAa,YAAY,WAAW;CAC1C,MAAM,OAAO,cAAc,WAAW,UAAU,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CAC3E,OAAO,QAAQ,MAAM,UAAU,KAAK;AACtC;AAEA,MAAa,WAA2B,sBAAM,YAAY;CACxD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/react/src/carousel.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { Carousel as Controller, CarouselProps } from \"@kirana-ui/core/carousel\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"carousel\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useCarousel(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Carousel.${part}> must be inside <Carousel.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<CarouselProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n index,\n defaultIndex,\n onIndexChange,\n orientation,\n loop,\n id,\n ...rest\n}: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CarouselProps, Controller>(\n within(createCarousel, { direction }),\n { index, defaultIndex, onIndexChange, orientation, loop, id }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type ViewportProps = PartComponentProps<\"div\", StateOf<Parts[\"viewport\"]>>\n\nconst Viewport = (props: ViewportProps) => usePart(useCarousel(\"Viewport\").viewport, \"div\", props)\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n {\n /**\n * Its place among the slides, from 0. Left out, its place in the page, once it is there:\n * give it on a page a server draws, which cannot count them.\n */\n index?: number\n }\n>\n\nfunction Item({ index, ...props }: ItemProps): ReactElement {\n const controller = useCarousel(\"Item\")\n const part = useMemo(() => controller.item(index), [controller, index])\n return usePart(part, \"div\", props)\n}\n\nexport type PreviousProps = PartComponentProps<\"button\", StateOf<Parts[\"previous\"]>>\n\nconst Previous = (props: PreviousProps) =>\n usePart(useCarousel(\"Previous\").previous, \"button\", props)\nexport type NextProps = PartComponentProps<\"button\", StateOf<Parts[\"next\"]>>\n\nconst Next = (props: NextProps) => usePart(useCarousel(\"Next\").next, \"button\", props)\n\nexport type IndicatorProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** The slide it goes to, from 0. */\n index: number\n }\n>\n\nfunction Indicator({ index, ...props }: IndicatorProps): ReactElement {\n const controller = useCarousel(\"Indicator\")\n const part = useMemo(() => controller.indicator(index), [controller, index])\n return usePart(part, \"button\", props)\n}\n\nexport const Carousel = /* @__PURE__ */ parts(\"Carousel\", {\n Root,\n Viewport,\n Item,\n Previous,\n Next,\n Indicator,\n})\n"],"mappings":";;;;;;;AAcA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,aAAa,KAAK,iCAAiC;CACpF,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,aACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cACjB,OAAO,gBAAgB,EAAE,UAAU,CAAC,GACpC;EAAE;EAAO;EAAc;EAAe;EAAa;EAAM;CAAG,CAC9D;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAIA,MAAM,YAAY,UAAyB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AAcjG,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,MAAM,aAAa,YAAY,MAAM;CACrC,MAAM,OAAO,cAAc,WAAW,KAAK,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CACtE,OAAO,QAAQ,MAAM,OAAO,KAAK;AACnC;AAIA,MAAM,YAAY,UAChB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,UAAU,KAAK;AAG3D,MAAM,QAAQ,UAAqB,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,UAAU,KAAK;AAWpF,SAAS,UAAU,EAAE,OAAO,GAAG,SAAuC;CACpE,MAAM,aAAa,YAAY,WAAW;CAC1C,MAAM,OAAO,cAAc,WAAW,UAAU,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CAC3E,OAAO,QAAQ,MAAM,UAAU,KAAK;AACtC;AAEA,MAAa,WAA2B,sBAAM,YAAY;CACxD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { CheckboxGroupProps as CheckboxGroupProps$1 } from "@kirana-ui/core/checkbox-group";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  export type CheckboxGroupProps = PartComponentProps<"div", StateOf<Vocabulary["checkboxGroup"]["root"]>, Omit<CheckboxGroupProps$1, "id"> & {
7
+ /** The group's own id, and what its boxes' elements are named from (`<id>-0`, `<id>-1` …, by their place in `allValues`), which a parent box's `aria-controls` names. Inside a `Field`, the group takes the field's id instead. */
7
8
  id?: string;
8
9
  }>;
9
10
  /**
@@ -1,8 +1,8 @@
1
1
  import { CheckboxGroupContext } from "./checkbox-group-context.js";
2
2
  import { FieldContext } from "./field-context.js";
3
3
  import { component, useController, usePart } from "./runtime.js";
4
- import { within } from "@kirana-ui/core";
5
4
  import { useContext } from "react";
5
+ import { within } from "@kirana-ui/core";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { createCheckboxGroup } from "@kirana-ui/core/checkbox-group";
8
8
  // src/checkbox-group.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-group.js","names":[],"sources":["../../../../packages/react/src/checkbox-group.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCheckboxGroup } from \"@kirana-ui/core/checkbox-group\"\nimport type {\n CheckboxGroup as Controller,\n CheckboxGroupProps as CoreProps,\n} from \"@kirana-ui/core/checkbox-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { CheckboxGroupContext } from \"./checkbox-group-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type CheckboxGroupProps = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"checkboxGroup\"][\"root\"]>,\n Omit<CoreProps, \"id\"> & { id?: string }\n>\n\n/**\n * Checkboxes that hold one list of values. Each `<Checkbox.Root value>` inside it is checked\n * while the list has its value; with `allValues`, a `<Checkbox.Root parent>` stands for them all.\n */\nexport const CheckboxGroup = /* @__PURE__ */ component(\n \"CheckboxGroup\",\n function CheckboxGroup({\n value,\n defaultValue,\n onValueChange,\n allValues,\n disabled,\n id,\n ...rest\n }: CheckboxGroupProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<CoreProps, Controller>(\n within(createCheckboxGroup, { field }),\n {\n value,\n defaultValue,\n onValueChange,\n allValues,\n disabled,\n id,\n }\n )\n return (\n <CheckboxGroupContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </CheckboxGroupContext.Provider>\n )\n }\n)\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAa,gBAAgC,0BAC3C,iBACA,SAAS,cAAc,EACrB,OACA,cACA,eACA,WACA,UACA,IACA,GAAG,QACgC;CACnC,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cACjB,OAAO,qBAAqB,EAAE,MAAM,CAAC,GACrC;EACE;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,OACE,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO;EACnC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACR,CAAA;AAEnC,CACF"}
1
+ {"version":3,"file":"checkbox-group.js","names":[],"sources":["../../../../packages/react/src/checkbox-group.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createCheckboxGroup } from \"@kirana-ui/core/checkbox-group\"\nimport type {\n CheckboxGroup as Controller,\n CheckboxGroupProps as CoreProps,\n} from \"@kirana-ui/core/checkbox-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { CheckboxGroupContext } from \"./checkbox-group-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type CheckboxGroupProps = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"checkboxGroup\"][\"root\"]>,\n Omit<CoreProps, \"id\"> & {\n /** The group's own id, and what its boxes' elements are named from (`<id>-0`, `<id>-1` …, by their place in `allValues`), which a parent box's `aria-controls` names. Inside a `Field`, the group takes the field's id instead. */\n id?: string\n }\n>\n\n/**\n * Checkboxes that hold one list of values. Each `<Checkbox.Root value>` inside it is checked\n * while the list has its value; with `allValues`, a `<Checkbox.Root parent>` stands for them all.\n */\nexport const CheckboxGroup = /* @__PURE__ */ component(\n \"CheckboxGroup\",\n function CheckboxGroup({\n value,\n defaultValue,\n onValueChange,\n allValues,\n disabled,\n id,\n ...rest\n }: CheckboxGroupProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<CoreProps, Controller>(\n within(createCheckboxGroup, { field }),\n {\n value,\n defaultValue,\n onValueChange,\n allValues,\n disabled,\n id,\n }\n )\n return (\n <CheckboxGroupContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </CheckboxGroupContext.Provider>\n )\n }\n)\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAa,gBAAgC,0BAC3C,iBACA,SAAS,cAAc,EACrB,OACA,cACA,eACA,WACA,UACA,IACA,GAAG,QACgC;CACnC,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cACjB,OAAO,qBAAqB,EAAE,MAAM,CAAC,GACrC;EACE;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,OACE,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO;EACnC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACR,CAAA;AAEnC,CACF"}
package/src/checkbox.d.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
- import { StateOf } from "@kirana-ui/core";
3
2
  import { ReactElement } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
4
  import { CheckboxProps } from "@kirana-ui/core/checkbox";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  type Parts = Vocabulary["checkbox"];
7
7
  export type RootProps = PartComponentProps<"span", StateOf<Parts["root"]>, Omit<CheckboxProps, "id"> & {
8
+ /** The id of the box's hidden native checkbox, not of the box: a `<label for>` names it. Inside a `Field`, that input takes the field's id instead. */
8
9
  id?: string;
9
10
  }>;
10
11
  declare function Root({ checked, defaultChecked, onCheckedChange, indeterminate, parent, disabled, readOnly, required, name, form, value, id, ...rest }: RootProps): ReactElement;
12
+ /**
13
+ * A dash while mixed and a tick while checked, from the part's state: `<Checkbox.Indicator
14
+ * render={(props, state) => <span {...props}>{state.indeterminate ? "–" : "✓"}</span>} />`.
15
+ */
11
16
  export type IndicatorProps = PartComponentProps<"span", StateOf<Parts["indicator"]>, {
12
17
  /** Keeps the mark in the page while the box is unchecked. */
13
18
  keepMounted?: boolean;
package/src/checkbox.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { CheckboxGroupContext } from "./checkbox-group-context.js";
2
2
  import { FieldContext } from "./field-context.js";
3
3
  import { PartElement, parts, useController, usePart, useSignal } from "./runtime.js";
4
- import { within } from "@kirana-ui/core";
5
4
  import { createContext, useContext } from "react";
5
+ import { within } from "@kirana-ui/core";
6
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { createCheckbox } from "@kirana-ui/core/checkbox";
8
8
  // src/checkbox.tsx