@kirana-ui/react 0.2.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 (148) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/llms.txt +1800 -187
  3. package/package.json +48 -3
  4. package/skills/kirana-ui-primitives/SKILL.md +53 -12
  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/alert-dialog.d.ts +2 -2
  9. package/src/autocomplete.d.ts +2 -2
  10. package/src/autosize.d.ts +1 -1
  11. package/src/avatar.d.ts +28 -7
  12. package/src/avatar.js +22 -9
  13. package/src/avatar.js.map +1 -1
  14. package/src/button.d.ts +5 -2
  15. package/src/button.js +4 -1
  16. package/src/button.js.map +1 -1
  17. package/src/calendar.d.ts +23 -8
  18. package/src/calendar.js +50 -13
  19. package/src/calendar.js.map +1 -1
  20. package/src/carousel.d.ts +6 -3
  21. package/src/carousel.js +1 -1
  22. package/src/carousel.js.map +1 -1
  23. package/src/checkbox-group-context.d.ts +4 -0
  24. package/src/checkbox-group-context.js +7 -0
  25. package/src/checkbox-group-context.js.map +1 -0
  26. package/src/checkbox-group.d.ts +15 -0
  27. package/src/checkbox-group.js +30 -0
  28. package/src/checkbox-group.js.map +1 -0
  29. package/src/checkbox.d.ts +7 -2
  30. package/src/checkbox.js +9 -3
  31. package/src/checkbox.js.map +1 -1
  32. package/src/collapsible.d.ts +1 -1
  33. package/src/color-picker.d.ts +61 -0
  34. package/src/color-picker.js +119 -0
  35. package/src/color-picker.js.map +1 -0
  36. package/src/combobox.d.ts +54 -5
  37. package/src/combobox.js +49 -8
  38. package/src/combobox.js.map +1 -1
  39. package/src/command.d.ts +4 -4
  40. package/src/command.js +2 -1
  41. package/src/command.js.map +1 -1
  42. package/src/date-field.d.ts +2 -2
  43. package/src/date-field.js +3 -2
  44. package/src/date-field.js.map +1 -1
  45. package/src/date-picker.d.ts +33 -11
  46. package/src/date-picker.js +22 -5
  47. package/src/date-picker.js.map +1 -1
  48. package/src/dialog.d.ts +11 -6
  49. package/src/dialog.js +27 -8
  50. package/src/dialog.js.map +1 -1
  51. package/src/direction.d.ts +1 -1
  52. package/src/direction.js +1 -1
  53. package/src/editable.d.ts +32 -0
  54. package/src/editable.js +63 -0
  55. package/src/editable.js.map +1 -0
  56. package/src/field.d.ts +1 -1
  57. package/src/fieldset.d.ts +1 -1
  58. package/src/file-upload.d.ts +54 -0
  59. package/src/file-upload.js +96 -0
  60. package/src/file-upload.js.map +1 -0
  61. package/src/form.d.ts +1 -1
  62. package/src/hover-popup.d.ts +1 -1
  63. package/src/hover-popup.js +1 -1
  64. package/src/index.d.ts +28 -7
  65. package/src/index.js +12 -1
  66. package/src/input.d.ts +1 -1
  67. package/src/input.js +1 -1
  68. package/src/label.d.ts +1 -1
  69. package/src/listbox.d.ts +1 -1
  70. package/src/listbox.js +1 -1
  71. package/src/menu.d.ts +5 -5
  72. package/src/menu.js +14 -9
  73. package/src/menu.js.map +1 -1
  74. package/src/menubar.d.ts +2 -2
  75. package/src/menubar.js +4 -2
  76. package/src/menubar.js.map +1 -1
  77. package/src/message-scroller.d.ts +1 -1
  78. package/src/navigation-menu.d.ts +5 -5
  79. package/src/navigation-menu.js +14 -4
  80. package/src/navigation-menu.js.map +1 -1
  81. package/src/number-field.d.ts +11 -2
  82. package/src/number-field.js +20 -3
  83. package/src/number-field.js.map +1 -1
  84. package/src/otp.d.ts +3 -2
  85. package/src/otp.js +10 -2
  86. package/src/otp.js.map +1 -1
  87. package/src/pagination.d.ts +1 -1
  88. package/src/password-input.d.ts +23 -0
  89. package/src/password-input.js +40 -0
  90. package/src/password-input.js.map +1 -0
  91. package/src/popover.d.ts +12 -4
  92. package/src/popover.js +14 -1
  93. package/src/popover.js.map +1 -1
  94. package/src/qr-code.d.ts +1 -1
  95. package/src/radio-group.d.ts +4 -2
  96. package/src/radio-group.js +6 -3
  97. package/src/radio-group.js.map +1 -1
  98. package/src/rating.d.ts +28 -0
  99. package/src/rating.js +59 -0
  100. package/src/rating.js.map +1 -0
  101. package/src/resizable.d.ts +1 -1
  102. package/src/resizable.js +1 -1
  103. package/src/runtime.d.ts +18 -8
  104. package/src/runtime.js +24 -5
  105. package/src/runtime.js.map +1 -1
  106. package/src/scroll-area.d.ts +1 -1
  107. package/src/scroll-area.js +1 -1
  108. package/src/select.d.ts +17 -6
  109. package/src/select.js +6 -3
  110. package/src/select.js.map +1 -1
  111. package/src/separator.d.ts +1 -1
  112. package/src/slider.d.ts +2 -2
  113. package/src/slider.js +3 -2
  114. package/src/slider.js.map +1 -1
  115. package/src/steps.d.ts +51 -0
  116. package/src/steps.js +69 -0
  117. package/src/steps.js.map +1 -0
  118. package/src/switch.d.ts +2 -1
  119. package/src/switch.js +1 -1
  120. package/src/switch.js.map +1 -1
  121. package/src/tabs.d.ts +2 -2
  122. package/src/tabs.js +4 -3
  123. package/src/tabs.js.map +1 -1
  124. package/src/tags-input.d.ts +47 -0
  125. package/src/tags-input.js +92 -0
  126. package/src/tags-input.js.map +1 -0
  127. package/src/time-field.d.ts +32 -0
  128. package/src/time-field.js +67 -0
  129. package/src/time-field.js.map +1 -0
  130. package/src/toast.d.ts +1 -1
  131. package/src/toggle-group.d.ts +2 -2
  132. package/src/toggle-group.js +4 -3
  133. package/src/toggle-group.js.map +1 -1
  134. package/src/toggle.d.ts +1 -1
  135. package/src/toggle.js +1 -1
  136. package/src/toolbar.d.ts +14 -6
  137. package/src/toolbar.js +19 -9
  138. package/src/toolbar.js.map +1 -1
  139. package/src/tour.d.ts +61 -0
  140. package/src/tour.js +68 -0
  141. package/src/tour.js.map +1 -0
  142. package/src/tree.d.ts +45 -0
  143. package/src/tree.js +93 -0
  144. package/src/tree.js.map +1 -0
  145. package/src/use-render.d.ts +1 -1
  146. package/src/use-render.js +1 -1
  147. package/src/use-render.js.map +1 -1
  148. package/src/value-bar.d.ts +1 -1
package/src/tabs.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, useMemo } from "react";
4
+ import { defined, within } from "@kirana-ui/core";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { createTabs } from "@kirana-ui/core/tabs";
7
7
  // src/tabs.tsx
@@ -30,11 +30,12 @@ function Root({ value, defaultValue, onValueChange, orientation, id, ...rest })
30
30
  })
31
31
  });
32
32
  }
33
- function List({ activateOnFocus, loop, ...props }) {
33
+ function List({ activateOnFocus, loop, loopFocus, ...props }) {
34
34
  const controller = useTabs("List");
35
35
  controller.listOptions.set(defined({
36
36
  activateOnFocus,
37
- loop
37
+ loop,
38
+ loopFocus
38
39
  }));
39
40
  return usePart(controller.list, "div", props);
40
41
  }
package/src/tabs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","names":[],"sources":["../../../../packages/react/src/tabs.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createTabs } from \"@kirana-ui/core/tabs\"\nimport type { Tabs as Controller, TabsListOptions, TabsProps } from \"@kirana-ui/core/tabs\"\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 {\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[\"tabs\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useTabs(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Tabs.${part}> must be inside <Tabs.Root>`)\n return controller\n}\n\n/** `Value` is what tells a tab from the others: the type of `value`. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<TabsProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n orientation,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createTabs<Value>, { direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n orientation,\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 ListProps = PartComponentProps<\"div\", StateOf<Parts[\"list\"]>, TabsListOptions>\n\nfunction List({ activateOnFocus, loop, ...props }: ListProps): ReactElement {\n const controller = useTabs(\"List\")\n // Read when a key is pressed, so written while rendering: nothing re-renders for it.\n controller.listOptions.set(defined({ activateOnFocus, loop }))\n return usePart(controller.list, \"div\", props)\n}\n\nexport type TabProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"tab\"]>,\n {\n /** What the tabs' value is while this tab is the active one. */\n value: unknown\n /** Disables this tab: it cannot be chosen. */\n disabled?: boolean\n }\n>\n\nfunction Tab({ value, disabled, ...props }: TabProps): ReactElement {\n const controller = useTabs(\"Tab\")\n const options = useOptions({ disabled })\n const part = useMemo(\n () => controller.tab(value, () => defined(options.get())),\n [controller, value, options]\n )\n return usePart(part, \"button\", props)\n}\n\nexport type IndicatorProps = PartComponentProps<\"span\", StateOf<Parts[\"indicator\"]>>\n\nconst Indicator = (props: IndicatorProps) => usePart(useTabs(\"Indicator\").indicator, \"span\", props)\n\nexport type PanelProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"panel\"]>,\n {\n /** The value of the tab this is the panel of. */\n value: unknown\n /** Keeps the panel in the page, `hidden`, while its tab is not the active one. */\n keepMounted?: boolean\n }\n>\n\nfunction Panel({ value, keepMounted, ...props }: PanelProps): ReactElement | null {\n const controller = useTabs(\"Panel\")\n const panel = useMemo(() => controller.panel(value), [controller, value])\n useMount(panel)\n const mounted = useSignal(panel.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={panel.part} tag=\"div\" {...props} />\n}\n\nexport const Tabs = /* @__PURE__ */ parts(\"Tabs\", { Root, List, Tab, Indicator, Panel })\n"],"mappings":";;;;;;;AAsBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,QAAQ,MAA0B;CACzC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,SAAS,KAAK,6BAA6B;CAC5E,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,aACA,IACA,GAAG,QAC8B;CACjC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,YAAmB,EAAE,UAAU,CAAC;CACtD,MAAM,aAAyB,cAAc,QAAQ;EACnD;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;AAIA,SAAS,KAAK,EAAE,iBAAiB,MAAM,GAAG,SAAkC;CAC1E,MAAM,aAAa,QAAQ,MAAM;CAEjC,WAAW,YAAY,IAAI,QAAQ;EAAE;EAAiB;CAAK,CAAC,CAAC;CAC7D,OAAO,QAAQ,WAAW,MAAM,OAAO,KAAK;AAC9C;AAaA,SAAS,IAAI,EAAE,OAAO,UAAU,GAAG,SAAiC;CAClE,MAAM,aAAa,QAAQ,KAAK;CAChC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,OAAO,cACL,WAAW,IAAI,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACxD;EAAC;EAAY;EAAO;CAAO,CAC7B;CACA,OAAO,QAAQ,MAAM,UAAU,KAAK;AACtC;AAIA,MAAM,aAAa,UAA0B,QAAQ,QAAQ,WAAW,CAAC,CAAC,WAAW,QAAQ,KAAK;AAalG,SAAS,MAAM,EAAE,OAAO,aAAa,GAAG,SAA0C;CAChF,MAAM,aAAa,QAAQ,OAAO;CAClC,MAAM,QAAQ,cAAc,WAAW,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CACxE,SAAS,KAAK;CAEd,IAAI,CADY,UAAU,MAAM,OACrB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,MAAM;EAAM,KAAI;EAAM,GAAI;CAAQ,CAAA;AAC5D;AAEA,MAAa,OAAuB,sBAAM,QAAQ;CAAE;CAAM;CAAM;CAAK;CAAW;AAAM,CAAC"}
1
+ {"version":3,"file":"tabs.js","names":[],"sources":["../../../../packages/react/src/tabs.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createTabs } from \"@kirana-ui/core/tabs\"\nimport type { Tabs as Controller, TabsListOptions, TabsProps } from \"@kirana-ui/core/tabs\"\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 {\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[\"tabs\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useTabs(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Tabs.${part}> must be inside <Tabs.Root>`)\n return controller\n}\n\n/** `Value` is what tells a tab from the others: the type of `value`. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<TabsProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n orientation,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createTabs<Value>, { direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n orientation,\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 ListProps = PartComponentProps<\"div\", StateOf<Parts[\"list\"]>, TabsListOptions>\n\nfunction List({ activateOnFocus, loop, loopFocus, ...props }: ListProps): ReactElement {\n const controller = useTabs(\"List\")\n // Read when a key is pressed, so written while rendering: nothing re-renders for it.\n controller.listOptions.set(defined({ activateOnFocus, loop, loopFocus }))\n return usePart(controller.list, \"div\", props)\n}\n\nexport type TabProps = PartComponentProps<\n \"button\",\n StateOf<Parts[\"tab\"]>,\n {\n /** What the tabs' value is while this tab is the active one. */\n value: unknown\n /** Disables this tab: it cannot be chosen. */\n disabled?: boolean\n }\n>\n\nfunction Tab({ value, disabled, ...props }: TabProps): ReactElement {\n const controller = useTabs(\"Tab\")\n const options = useOptions({ disabled })\n const part = useMemo(\n () => controller.tab(value, () => defined(options.get())),\n [controller, value, options]\n )\n return usePart(part, \"button\", props)\n}\n\nexport type IndicatorProps = PartComponentProps<\"span\", StateOf<Parts[\"indicator\"]>>\n\nconst Indicator = (props: IndicatorProps) => usePart(useTabs(\"Indicator\").indicator, \"span\", props)\n\nexport type PanelProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"panel\"]>,\n {\n /** The value of the tab this is the panel of. */\n value: unknown\n /** Keeps the panel in the page, `hidden`, while its tab is not the active one. */\n keepMounted?: boolean\n }\n>\n\nfunction Panel({ value, keepMounted, ...props }: PanelProps): ReactElement | null {\n const controller = useTabs(\"Panel\")\n const panel = useMemo(() => controller.panel(value), [controller, value])\n useMount(panel)\n const mounted = useSignal(panel.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={panel.part} tag=\"div\" {...props} />\n}\n\nexport const Tabs = /* @__PURE__ */ parts(\"Tabs\", { Root, List, Tab, Indicator, Panel })\n"],"mappings":";;;;;;;AAsBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,QAAQ,MAA0B;CACzC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,SAAS,KAAK,6BAA6B;CAC5E,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,aACA,IACA,GAAG,QAC8B;CACjC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,YAAmB,EAAE,UAAU,CAAC;CACtD,MAAM,aAAyB,cAAc,QAAQ;EACnD;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;AAIA,SAAS,KAAK,EAAE,iBAAiB,MAAM,WAAW,GAAG,SAAkC;CACrF,MAAM,aAAa,QAAQ,MAAM;CAEjC,WAAW,YAAY,IAAI,QAAQ;EAAE;EAAiB;EAAM;CAAU,CAAC,CAAC;CACxE,OAAO,QAAQ,WAAW,MAAM,OAAO,KAAK;AAC9C;AAaA,SAAS,IAAI,EAAE,OAAO,UAAU,GAAG,SAAiC;CAClE,MAAM,aAAa,QAAQ,KAAK;CAChC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,OAAO,cACL,WAAW,IAAI,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACxD;EAAC;EAAY;EAAO;CAAO,CAC7B;CACA,OAAO,QAAQ,MAAM,UAAU,KAAK;AACtC;AAIA,MAAM,aAAa,UAA0B,QAAQ,QAAQ,WAAW,CAAC,CAAC,WAAW,QAAQ,KAAK;AAalG,SAAS,MAAM,EAAE,OAAO,aAAa,GAAG,SAA0C;CAChF,MAAM,aAAa,QAAQ,OAAO;CAClC,MAAM,QAAQ,cAAc,WAAW,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CACxE,SAAS,KAAK;CAEd,IAAI,CADY,UAAU,MAAM,OACrB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,MAAM;EAAM,KAAI;EAAM,GAAI;CAAQ,CAAA;AAC5D;AAEA,MAAa,OAAuB,sBAAM,QAAQ;CAAE;CAAM;CAAM;CAAK;CAAW;AAAM,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { TagsInputEntry, TagsInputProps } from "@kirana-ui/core/tags-input";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["tagsInput"];
7
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<TagsInputProps, "id"> & {
8
+ id?: string;
9
+ }>;
10
+ declare function Root({ value, defaultValue, onValueChange, onValueInvalid, validate, max, allowDuplicates, delimiter, addOnBlur, addOnPaste, editable, disabled, readOnly, required, name, form, id, ...rest }: RootProps): ReactElement;
11
+ export type ListProps = PartComponentProps<"div", StateOf<Parts["list"]>>;
12
+ declare const List: (props: ListProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
13
+ export interface ItemsProps {
14
+ /** Draws one tag, once for each. */
15
+ children: (entry: TagsInputEntry) => ReactNode;
16
+ }
17
+ /** Draws its child once for each tag, kept by the tag's key. */
18
+ declare function Items({ children }: ItemsProps): ReactElement;
19
+ export type ItemProps = PartComponentProps<"span", StateOf<Parts["item"]>, {
20
+ /** The tag it is, as `Items` gave it. */
21
+ entry: TagsInputEntry;
22
+ }>;
23
+ declare function Item({ entry, ...props }: ItemProps): ReactElement;
24
+ export type ItemTextProps = PartComponentProps<"span", StateOf<Parts["itemText"]>>;
25
+ /** Says the tag's text unless it is given children. */
26
+ declare function ItemText(props: ItemTextProps): ReactElement;
27
+ export type ItemInputProps = PartComponentProps<"input", StateOf<Parts["itemInput"]>>;
28
+ declare const ItemInput: (props: ItemInputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
29
+ export type ItemRemoveProps = PartComponentProps<"button", StateOf<Parts["itemRemove"]>>;
30
+ declare const ItemRemove: (props: ItemRemoveProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
31
+ export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
32
+ declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
33
+ export type ClearProps = PartComponentProps<"button", StateOf<Parts["clear"]>>;
34
+ declare const Clear: (props: ClearProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
35
+ export declare const TagsInput: {
36
+ readonly Root: typeof Root;
37
+ readonly List: typeof List;
38
+ readonly Items: typeof Items;
39
+ readonly Item: typeof Item;
40
+ readonly ItemText: typeof ItemText;
41
+ readonly ItemInput: typeof ItemInput;
42
+ readonly ItemRemove: typeof ItemRemove;
43
+ readonly Input: typeof Input;
44
+ readonly Clear: typeof Clear;
45
+ };
46
+ export {};
47
+ //# sourceMappingURL=tags-input.d.ts.map
@@ -0,0 +1,92 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { FieldContext } from "./field-context.js";
3
+ import { PartElement, parts, useController, usePart, useSignal } from "./runtime.js";
4
+ import { Fragment, createContext, useContext } from "react";
5
+ import { within } from "@kirana-ui/core";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ import { createTagsInput } from "@kirana-ui/core/tags-input";
8
+ // src/tags-input.tsx
9
+ const Context = createContext(null);
10
+ const ItemContext = createContext(null);
11
+ function useTagsInput(part) {
12
+ const controller = useContext(Context);
13
+ if (!controller) throw new Error(`<TagsInput.${part}> must be inside <TagsInput.Root>`);
14
+ return controller;
15
+ }
16
+ function useEntry(part) {
17
+ const entry = useContext(ItemContext);
18
+ if (!entry) throw new Error(`<TagsInput.${part}> must be inside <TagsInput.Item>`);
19
+ return entry;
20
+ }
21
+ function Root({ value, defaultValue, onValueChange, onValueInvalid, validate, max, allowDuplicates, delimiter, addOnBlur, addOnPaste, editable, disabled, readOnly, required, name, form, id, ...rest }) {
22
+ const field = useContext(FieldContext) ?? void 0;
23
+ const direction = useContext(DirectionContext) ?? void 0;
24
+ const create = within(createTagsInput, {
25
+ field,
26
+ direction
27
+ });
28
+ const controller = useController(create, {
29
+ value,
30
+ defaultValue,
31
+ onValueChange,
32
+ onValueInvalid,
33
+ validate,
34
+ max,
35
+ allowDuplicates,
36
+ delimiter,
37
+ addOnBlur,
38
+ addOnPaste,
39
+ editable,
40
+ disabled,
41
+ readOnly,
42
+ required,
43
+ name,
44
+ form,
45
+ id
46
+ });
47
+ return /* @__PURE__ */ jsx(Context.Provider, {
48
+ value: controller,
49
+ children: usePart(controller.root, "div", rest, void 0, (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [content, /* @__PURE__ */ jsx(PartElement, {
50
+ of: controller.hiddenInput,
51
+ tag: "input"
52
+ })] }))
53
+ });
54
+ }
55
+ const List = (props) => usePart(useTagsInput("List").list, "div", props);
56
+ /** Draws its child once for each tag, kept by the tag's key. */
57
+ function Items({ children }) {
58
+ const entries = useSignal(useTagsInput("Items").entries);
59
+ return /* @__PURE__ */ jsx(Fragment$1, { children: entries.map((entry) => /* @__PURE__ */ jsx(Fragment, { children: children(entry) }, entry.key)) });
60
+ }
61
+ function Item({ entry, ...props }) {
62
+ return /* @__PURE__ */ jsx(ItemContext.Provider, {
63
+ value: entry,
64
+ children: usePart(useTagsInput("Item").item(entry.key), "span", props)
65
+ });
66
+ }
67
+ /** Says the tag's text unless it is given children. */
68
+ function ItemText(props) {
69
+ const entry = useEntry("ItemText");
70
+ return usePart(useTagsInput("ItemText").itemText(entry.key), "span", {
71
+ ...props,
72
+ children: props.children ?? entry.value
73
+ });
74
+ }
75
+ const ItemInput = (props) => usePart(useTagsInput("ItemInput").itemInput(useEntry("ItemInput").key), "input", props);
76
+ const ItemRemove = (props) => usePart(useTagsInput("ItemRemove").itemRemove(useEntry("ItemRemove").key), "button", props);
77
+ const Input = (props) => usePart(useTagsInput("Input").input, "input", props);
78
+ const Clear = (props) => usePart(useTagsInput("Clear").clear, "button", props);
79
+ const TagsInput = /* @__PURE__ */ parts("TagsInput", {
80
+ Root,
81
+ List,
82
+ Items,
83
+ Item,
84
+ ItemText,
85
+ ItemInput,
86
+ ItemRemove,
87
+ Input,
88
+ Clear
89
+ });
90
+ export { TagsInput };
91
+
92
+ //# sourceMappingURL=tags-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tags-input.js","names":[],"sources":["../../../../packages/react/src/tags-input.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createTagsInput } from \"@kirana-ui/core/tags-input\"\nimport type {\n TagsInput as Controller,\n TagsInputEntry,\n TagsInputProps,\n} from \"@kirana-ui/core/tags-input\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport { PartElement, parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"tagsInput\"]\n\nconst Context = createContext<Controller | null>(null)\n// The tag an item is, for the parts inside it.\nconst ItemContext = createContext<TagsInputEntry | null>(null)\n\nfunction useTagsInput(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<TagsInput.${part}> must be inside <TagsInput.Root>`)\n return controller\n}\n\nfunction useEntry(part: string): TagsInputEntry {\n const entry = useContext(ItemContext)\n if (!entry) throw new Error(`<TagsInput.${part}> must be inside <TagsInput.Item>`)\n return entry\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<TagsInputProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n onValueInvalid,\n validate,\n max,\n allowDuplicates,\n delimiter,\n addOnBlur,\n addOnPaste,\n editable,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createTagsInput, { field, direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n onValueInvalid,\n validate,\n max,\n allowDuplicates,\n delimiter,\n addOnBlur,\n addOnPaste,\n editable,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n })\n return (\n <Context.Provider value={controller}>\n {usePart(controller.root, \"div\", rest, undefined, (content) => (\n // The first of the inputs a form reads is the element's last child; the rest follow it.\n <>\n {content}\n <PartElement of={controller.hiddenInput} tag=\"input\" />\n </>\n ))}\n </Context.Provider>\n )\n}\n\nexport type ListProps = PartComponentProps<\"div\", StateOf<Parts[\"list\"]>>\n\nconst List = (props: ListProps) => usePart(useTagsInput(\"List\").list, \"div\", props)\n\nexport interface ItemsProps {\n /** Draws one tag, once for each. */\n children: (entry: TagsInputEntry) => ReactNode\n}\n\n/** Draws its child once for each tag, kept by the tag's key. */\nfunction Items({ children }: ItemsProps): ReactElement {\n const entries = useSignal(useTagsInput(\"Items\").entries)\n return (\n <>\n {entries.map((entry) => (\n <Fragment key={entry.key}>{children(entry)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"item\"]>,\n {\n /** The tag it is, as `Items` gave it. */\n entry: TagsInputEntry\n }\n>\n\nfunction Item({ entry, ...props }: ItemProps): ReactElement {\n return (\n <ItemContext.Provider value={entry}>\n {usePart(useTagsInput(\"Item\").item(entry.key), \"span\", props)}\n </ItemContext.Provider>\n )\n}\n\nexport type ItemTextProps = PartComponentProps<\"span\", StateOf<Parts[\"itemText\"]>>\n\n/** Says the tag's text unless it is given children. */\nfunction ItemText(props: ItemTextProps): ReactElement {\n const entry = useEntry(\"ItemText\")\n return usePart(useTagsInput(\"ItemText\").itemText(entry.key), \"span\", {\n ...props,\n children: props.children ?? entry.value,\n })\n}\n\nexport type ItemInputProps = PartComponentProps<\"input\", StateOf<Parts[\"itemInput\"]>>\n\nconst ItemInput = (props: ItemInputProps) =>\n usePart(useTagsInput(\"ItemInput\").itemInput(useEntry(\"ItemInput\").key), \"input\", props)\n\nexport type ItemRemoveProps = PartComponentProps<\"button\", StateOf<Parts[\"itemRemove\"]>>\n\nconst ItemRemove = (props: ItemRemoveProps) =>\n usePart(useTagsInput(\"ItemRemove\").itemRemove(useEntry(\"ItemRemove\").key), \"button\", props)\n\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\nconst Input = (props: InputProps) => usePart(useTagsInput(\"Input\").input, \"input\", props)\n\nexport type ClearProps = PartComponentProps<\"button\", StateOf<Parts[\"clear\"]>>\n\nconst Clear = (props: ClearProps) => usePart(useTagsInput(\"Clear\").clear, \"button\", props)\n\nexport const TagsInput = /* @__PURE__ */ parts(\"TagsInput\", {\n Root,\n List,\n Items,\n Item,\n ItemText,\n ItemInput,\n ItemRemove,\n Input,\n Clear,\n})\n"],"mappings":";;;;;;;;AAmBA,MAAM,UAAU,cAAiC,IAAI;AAErD,MAAM,cAAc,cAAqC,IAAI;AAE7D,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAEA,SAAS,SAAS,MAA8B;CAC9C,MAAM,QAAQ,WAAW,WAAW;CACpC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACjF,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,gBACA,UACA,KACA,iBACA,WACA,WACA,YACA,UACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,iBAAiB;EAAE;EAAO;CAAU,CAAC;CAC3D,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACtB,UAAA,QAAQ,WAAW,MAAM,OAAO,MAAM,KAAA,IAAY,YAEjD,qBAAA,YAAA,EAAA,UAAA,CACG,SACD,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAa,KAAI;EAAS,CAAA,CACtD,EAAA,CAAA,CACH;CACe,CAAA;AAEtB;AAIA,MAAM,QAAQ,UAAqB,QAAQ,aAAa,MAAM,CAAC,CAAC,MAAM,OAAO,KAAK;;AAQlF,SAAS,MAAM,EAAE,YAAsC;CACrD,MAAM,UAAU,UAAU,aAAa,OAAO,CAAC,CAAC,OAAO;CACvD,OACE,oBAAA,YAAA,EAAA,UACG,QAAQ,KAAK,UACZ,oBAAC,UAAD,EAAA,UAA2B,SAAS,KAAK,EAAY,GAAtC,MAAM,GAAgC,CACtD,EACD,CAAA;AAEN;AAWA,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC1B,UAAA,QAAQ,aAAa,MAAM,CAAC,CAAC,KAAK,MAAM,GAAG,GAAG,QAAQ,KAAK;CACxC,CAAA;AAE1B;;AAKA,SAAS,SAAS,OAAoC;CACpD,MAAM,QAAQ,SAAS,UAAU;CACjC,OAAO,QAAQ,aAAa,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,QAAQ;EACnE,GAAG;EACH,UAAU,MAAM,YAAY,MAAM;CACpC,CAAC;AACH;AAIA,MAAM,aAAa,UACjB,QAAQ,aAAa,WAAW,CAAC,CAAC,UAAU,SAAS,WAAW,CAAC,CAAC,GAAG,GAAG,SAAS,KAAK;AAIxF,MAAM,cAAc,UAClB,QAAQ,aAAa,YAAY,CAAC,CAAC,WAAW,SAAS,YAAY,CAAC,CAAC,GAAG,GAAG,UAAU,KAAK;AAI5F,MAAM,SAAS,UAAsB,QAAQ,aAAa,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAIxF,MAAM,SAAS,UAAsB,QAAQ,aAAa,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;AAEzF,MAAa,YAA4B,sBAAM,aAAa;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { TimeFieldProps, TimeFieldSegment } from "@kirana-ui/core/time-field";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["timeField"];
7
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<TimeFieldProps, "id"> & {
8
+ id?: string;
9
+ }>;
10
+ declare function Root({ value, defaultValue, onValueChange, granularity, hourCycle, locale, min, max, placeholders, disabled, readOnly, required, name, form, id, ...rest }: RootProps): ReactElement;
11
+ export interface SegmentsProps {
12
+ /** Draws one piece of the time, once for each: a part that is typed, or what stands between two. */
13
+ children: (segment: TimeFieldSegment) => ReactNode;
14
+ }
15
+ /** Draws its child once for each piece of the time, in the locale's order. */
16
+ declare function Segments({ children }: SegmentsProps): import("react").JSX.Element;
17
+ export type SegmentProps = PartComponentProps<"span", StateOf<Parts["segment"]>, {
18
+ /** The piece it is: an entry `TimeField.Segments` gave. */
19
+ segment: TimeFieldSegment;
20
+ }>;
21
+ /** One piece: a part that is typed, or what stands between two. It writes its own text. */
22
+ declare function Segment({ segment, ...props }: SegmentProps): ReactElement;
23
+ export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
24
+ declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
25
+ export declare const TimeField: {
26
+ readonly Root: typeof Root;
27
+ readonly Segments: typeof Segments;
28
+ readonly Segment: typeof Segment;
29
+ readonly Input: typeof Input;
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=time-field.d.ts.map
@@ -0,0 +1,67 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { FieldContext } from "./field-context.js";
3
+ import { parts, useController, usePart, useSignal } from "./runtime.js";
4
+ import { Fragment, createContext, useContext } from "react";
5
+ import { within } from "@kirana-ui/core";
6
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
7
+ import { createTimeField } from "@kirana-ui/core/time-field";
8
+ // src/time-field.tsx
9
+ const Context = createContext(null);
10
+ function useTimeField(part) {
11
+ const controller = useContext(Context);
12
+ if (!controller) throw new Error(`<TimeField.${part}> must be inside <TimeField.Root>`);
13
+ return controller;
14
+ }
15
+ function Root({ value, defaultValue, onValueChange, granularity, hourCycle, locale, min, max, placeholders, disabled, readOnly, required, name, form, id, ...rest }) {
16
+ const direction = useContext(DirectionContext) ?? void 0;
17
+ const field = useContext(FieldContext) ?? void 0;
18
+ const controller = useController(within(createTimeField, {
19
+ direction,
20
+ field
21
+ }), {
22
+ value,
23
+ defaultValue,
24
+ onValueChange,
25
+ granularity,
26
+ hourCycle,
27
+ locale,
28
+ min,
29
+ max,
30
+ placeholders,
31
+ disabled,
32
+ readOnly,
33
+ required,
34
+ name,
35
+ form,
36
+ id
37
+ });
38
+ return /* @__PURE__ */ jsx(Context.Provider, {
39
+ value: controller,
40
+ children: usePart(controller.root, "div", rest)
41
+ });
42
+ }
43
+ /** Draws its child once for each piece of the time, in the locale's order. */
44
+ function Segments({ children }) {
45
+ const segments = useSignal(useTimeField("Segments").segments);
46
+ return /* @__PURE__ */ jsx(Fragment$1, { children: segments.map((segment) => /* @__PURE__ */ jsx(Fragment, { children: children(segment) }, `${segment.index}-${segment.type}`)) });
47
+ }
48
+ /** One piece: a part that is typed, or what stands between two. It writes its own text. */
49
+ function Segment({ segment, ...props }) {
50
+ const { part, text } = useTimeField("Segment").segment(segment);
51
+ const shown = useSignal(text);
52
+ return usePart(part, "span", {
53
+ ...props,
54
+ suppressContentEditableWarning: true,
55
+ children: shown
56
+ });
57
+ }
58
+ const Input = (props) => usePart(useTimeField("Input").input, "input", props);
59
+ const TimeField = /* @__PURE__ */ parts("TimeField", {
60
+ Root,
61
+ Segments,
62
+ Segment,
63
+ Input
64
+ });
65
+ export { TimeField };
66
+
67
+ //# sourceMappingURL=time-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-field.js","names":[],"sources":["../../../../packages/react/src/time-field.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createTimeField } from \"@kirana-ui/core/time-field\"\nimport type {\n TimeField as Controller,\n TimeFieldProps,\n TimeFieldSegment,\n} from \"@kirana-ui/core/time-field\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport { parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"timeField\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useTimeField(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<TimeField.${part}> must be inside <TimeField.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<TimeFieldProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n granularity,\n hourCycle,\n locale,\n min,\n max,\n placeholders,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<TimeFieldProps, Controller>(\n within(createTimeField, { direction, field }),\n {\n value,\n defaultValue,\n onValueChange,\n granularity,\n hourCycle,\n locale,\n min,\n max,\n placeholders,\n disabled,\n readOnly,\n required,\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 interface SegmentsProps {\n /** Draws one piece of the time, once for each: a part that is typed, or what stands between two. */\n children: (segment: TimeFieldSegment) => ReactNode\n}\n\n/** Draws its child once for each piece of the time, in the locale's order. */\nfunction Segments({ children }: SegmentsProps) {\n const segments = useSignal(useTimeField(\"Segments\").segments)\n return (\n <>\n {segments.map((segment) => (\n <Fragment key={`${segment.index}-${segment.type}`}>{children(segment)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type SegmentProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"segment\"]>,\n {\n /** The piece it is: an entry `TimeField.Segments` gave. */\n segment: TimeFieldSegment\n }\n>\n\n/** One piece: a part that is typed, or what stands between two. It writes its own text. */\nfunction Segment({ segment, ...props }: SegmentProps): ReactElement {\n const { part, text } = useTimeField(\"Segment\").segment(segment)\n const shown = useSignal(text)\n // Its text is the field's to write: the browser never edits it, whatever React fears.\n return usePart(part, \"span\", { ...props, suppressContentEditableWarning: true, children: shown })\n}\n\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\nconst Input = (props: InputProps) => usePart(useTimeField(\"Input\").input, \"input\", props)\n\nexport const TimeField = /* @__PURE__ */ parts(\"TimeField\", { Root, Segments, Segment, Input })\n"],"mappings":";;;;;;;;AAmBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,aACA,WACA,QACA,KACA,KACA,cACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cACjB,OAAO,iBAAiB;EAAE;EAAW;CAAM,CAAC,GAC5C;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;;AAQA,SAAS,SAAS,EAAE,YAA2B;CAC7C,MAAM,WAAW,UAAU,aAAa,UAAU,CAAC,CAAC,QAAQ;CAC5D,OACE,oBAAA,YAAA,EAAA,UACG,SAAS,KAAK,YACb,oBAAC,UAAD,EAAA,UAAoD,SAAS,OAAO,EAAY,GAAjE,GAAG,QAAQ,MAAM,GAAG,QAAQ,MAAqC,CACjF,EACD,CAAA;AAEN;;AAYA,SAAS,QAAQ,EAAE,SAAS,GAAG,SAAqC;CAClE,MAAM,EAAE,MAAM,SAAS,aAAa,SAAS,CAAC,CAAC,QAAQ,OAAO;CAC9D,MAAM,QAAQ,UAAU,IAAI;CAE5B,OAAO,QAAQ,MAAM,QAAQ;EAAE,GAAG;EAAO,gCAAgC;EAAM,UAAU;CAAM,CAAC;AAClG;AAIA,MAAM,SAAS,UAAsB,QAAQ,aAAa,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAExF,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAM;CAAU;CAAS;AAAM,CAAC"}
package/src/toast.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 * as Core from "@kirana-ui/core/toast";
5
5
  import { ToasterOptions } from "@kirana-ui/core/toast";
6
6
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
@@ -1,10 +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 { ToggleGroupProps as ToggleGroupProps$1 } from "@kirana-ui/core/toggle-group";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  /** `Value` is what tells a toggle from the others: the type of `value`'s entries. */
7
7
  export type ToggleGroupProps<Value = unknown> = PartComponentProps<"div", StateOf<Vocabulary["toggleGroup"]["root"]>, ToggleGroupProps$1<Value>>;
8
8
  /** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
9
- export declare const ToggleGroup: <Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, ...rest }: ToggleGroupProps<Value>) => ReactElement;
9
+ export declare const ToggleGroup: <Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, ...rest }: ToggleGroupProps<Value>) => ReactElement;
10
10
  //# sourceMappingURL=toggle-group.d.ts.map
@@ -1,13 +1,13 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { component, useController, usePart } from "./runtime.js";
3
3
  import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.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 { createToggleGroup } from "@kirana-ui/core/toggle-group";
8
8
  // src/toggle-group.tsx
9
9
  /** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
10
- const ToggleGroup = /* @__PURE__ */ component("ToggleGroup", function ToggleGroup({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, ...rest }) {
10
+ const ToggleGroup = /* @__PURE__ */ component("ToggleGroup", function ToggleGroup({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, ...rest }) {
11
11
  const direction = useContext(DirectionContext) ?? void 0;
12
12
  const toolbar = useContext(ToolbarContext) ?? void 0;
13
13
  const controller = useController(within(createToggleGroup, {
@@ -20,7 +20,8 @@ const ToggleGroup = /* @__PURE__ */ component("ToggleGroup", function ToggleGrou
20
20
  multiple,
21
21
  disabled,
22
22
  orientation,
23
- loop
23
+ loop,
24
+ loopFocus
24
25
  });
25
26
  return /* @__PURE__ */ jsx(ToggleGroupContext.Provider, {
26
27
  value: controller,
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-group.js","names":[],"sources":["../../../../packages/react/src/toggle-group.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createToggleGroup } from \"@kirana-ui/core/toggle-group\"\nimport type {\n ToggleGroup as Controller,\n ToggleGroupProps as CoreProps,\n} from \"@kirana-ui/core/toggle-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\n/** `Value` is what tells a toggle from the others: the type of `value`'s entries. */\nexport type ToggleGroupProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"toggleGroup\"][\"root\"]>,\n CoreProps<Value>\n>\n\n/** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */\nexport const ToggleGroup = /* @__PURE__ */ component(\"ToggleGroup\", function ToggleGroup<\n Value = unknown,\n>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, ...rest }: ToggleGroupProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const toolbar = useContext(ToolbarContext) ?? undefined\n const controller: Controller = useController<CoreProps<Value>, Controller<Value>>(\n within(createToggleGroup<Value>, { direction, toolbar }),\n { value, defaultValue, onValueChange, multiple, disabled, orientation, loop }\n )\n return (\n <ToggleGroupContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n )\n})\n"],"mappings":";;;;;;;;;AAwBA,MAAa,cAA8B,0BAAU,eAAe,SAAS,YAE3E,EAAE,OAAO,cAAc,eAAe,UAAU,UAAU,aAAa,MAAM,GAAG,QAA+C;CAC/H,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,UAAU,WAAW,cAAc,KAAK,KAAA;CAC9C,MAAM,aAAyB,cAC7B,OAAO,mBAA0B;EAAE;EAAW;CAAQ,CAAC,GACvD;EAAE;EAAO;EAAc;EAAe;EAAU;EAAU;EAAa;CAAK,CAC9E;CACA,OACE,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACV,CAAA;AAEjC,CAAC"}
1
+ {"version":3,"file":"toggle-group.js","names":[],"sources":["../../../../packages/react/src/toggle-group.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createToggleGroup } from \"@kirana-ui/core/toggle-group\"\nimport type {\n ToggleGroup as Controller,\n ToggleGroupProps as CoreProps,\n} from \"@kirana-ui/core/toggle-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\n/** `Value` is what tells a toggle from the others: the type of `value`'s entries. */\nexport type ToggleGroupProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"toggleGroup\"][\"root\"]>,\n CoreProps<Value>\n>\n\n/** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */\nexport const ToggleGroup = /* @__PURE__ */ component(\"ToggleGroup\", function ToggleGroup<\n Value = unknown,\n>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, ...rest }: ToggleGroupProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const toolbar = useContext(ToolbarContext) ?? undefined\n const controller: Controller = useController<CoreProps<Value>, Controller<Value>>(\n within(createToggleGroup<Value>, { direction, toolbar }),\n { value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus }\n )\n return (\n <ToggleGroupContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n )\n})\n"],"mappings":";;;;;;;;;AAwBA,MAAa,cAA8B,0BAAU,eAAe,SAAS,YAE3E,EAAE,OAAO,cAAc,eAAe,UAAU,UAAU,aAAa,MAAM,WAAW,GAAG,QAA+C;CAC1I,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,UAAU,WAAW,cAAc,KAAK,KAAA;CAC9C,MAAM,aAAyB,cAC7B,OAAO,mBAA0B;EAAE;EAAW;CAAQ,CAAC,GACvD;EAAE;EAAO;EAAc;EAAe;EAAU;EAAU;EAAa;EAAM;CAAU,CACzF;CACA,OACE,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACV,CAAA;AAEjC,CAAC"}
package/src/toggle.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 { ToggleProps as ToggleProps$1 } from "@kirana-ui/core/toggle";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  export type ToggleProps = PartComponentProps<"button", StateOf<Vocabulary["toggle"]["root"]>, ToggleProps$1>;
package/src/toggle.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { component, useController, usePart } from "./runtime.js";
2
2
  import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
3
- import { within } from "@kirana-ui/core";
4
3
  import { useContext } from "react";
4
+ import { within } from "@kirana-ui/core";
5
5
  import { createToggle } from "@kirana-ui/core/toggle";
6
6
  // src/toggle.tsx
7
7
  /** Inside a `<ToggleGroup>`, `value` makes it one of the group's toggles. */
package/src/toolbar.d.ts CHANGED
@@ -1,23 +1,31 @@
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 { ToolbarProps } from "@kirana-ui/core/toolbar";
5
5
  import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
6
  type Parts = Vocabulary["toolbar"];
7
7
  export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, ToolbarProps>;
8
- declare function Root({ orientation, loop, disabled, ...rest }: RootProps): ReactElement;
8
+ declare function Root({ orientation, loop, loopFocus, disabled, ...rest }: RootProps): ReactElement;
9
9
  /** What an item of the toolbar takes of its own. */
10
10
  export interface ItemOptions {
11
11
  /** Disables this control. */
12
12
  disabled?: boolean;
13
13
  }
14
- export type ButtonProps = PartComponentProps<"button", StateOf<Parts["button"]>, ItemOptions>;
15
- export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>, ItemOptions>;
14
+ /** What a button or an input of the toolbar takes of its own. */
15
+ export interface ControlOptions extends ItemOptions {
16
+ /**
17
+ * Keeps it focusable while disabled, as Base UI's: the arrows still reach it, and a press does
18
+ * nothing. Default `true`; with `false` it is disabled the element's own way.
19
+ */
20
+ focusableWhenDisabled?: boolean;
21
+ }
22
+ export type ButtonProps = PartComponentProps<"button", StateOf<Parts["button"]>, ControlOptions>;
23
+ export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>, ControlOptions>;
16
24
  export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, ItemOptions>;
17
25
  /** @deprecated The item's own: `ButtonProps`, `InputProps` or `GroupProps`. */
18
26
  export type ItemProps = PartComponentProps<"div", StateOf<Parts["group"]>, ItemOptions>;
19
- declare function Button({ disabled, ...props }: ButtonProps): ReactElement;
20
- declare function Input({ disabled, ...props }: InputProps): ReactElement;
27
+ declare function Button({ disabled, focusableWhenDisabled, ...props }: ButtonProps): ReactElement;
28
+ declare function Input({ disabled, focusableWhenDisabled, ...props }: InputProps): ReactElement;
21
29
  declare function Group({ disabled, ...props }: GroupProps): ReactElement;
22
30
  export type LinkProps = PartComponentProps<"a", StateOf<Parts["link"]>>;
23
31
  declare function Link(props: LinkProps): ReactElement;
package/src/toolbar.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { parts, useController, useOptions, usePart } from "./runtime.js";
3
3
  import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
4
- import { defined, within } from "@kirana-ui/core";
5
4
  import { useContext, useMemo } from "react";
5
+ import { defined, within } from "@kirana-ui/core";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { createToolbar } from "@kirana-ui/core/toolbar";
8
8
  // src/toolbar.tsx
@@ -11,11 +11,12 @@ function useToolbar(part) {
11
11
  if (!controller) throw new Error(`<Toolbar.${part}> must be inside <Toolbar.Root>`);
12
12
  return controller;
13
13
  }
14
- function Root({ orientation, loop, disabled, ...rest }) {
14
+ function Root({ orientation, loop, loopFocus, disabled, ...rest }) {
15
15
  const direction = useContext(DirectionContext) ?? void 0;
16
16
  const controller = useController(within(createToolbar, { direction }), {
17
17
  orientation,
18
18
  loop,
19
+ loopFocus,
19
20
  disabled
20
21
  });
21
22
  return /* @__PURE__ */ jsx(ToolbarContext.Provider, {
@@ -26,23 +27,32 @@ function Root({ orientation, loop, disabled, ...rest }) {
26
27
  })
27
28
  });
28
29
  }
29
- function useItem(name, disabled) {
30
+ function useItem(name, { disabled, focusableWhenDisabled }) {
30
31
  const controller = useToolbar(name);
31
- const options = useOptions({ disabled });
32
+ const options = useOptions({
33
+ disabled,
34
+ focusableWhenDisabled
35
+ });
32
36
  return useMemo(() => controller[name](() => defined(options.get())), [
33
37
  controller,
34
38
  name,
35
39
  options
36
40
  ]);
37
41
  }
38
- function Button({ disabled, ...props }) {
39
- return usePart(useItem("button", disabled), "button", props);
42
+ function Button({ disabled, focusableWhenDisabled, ...props }) {
43
+ return usePart(useItem("button", {
44
+ disabled,
45
+ focusableWhenDisabled
46
+ }), "button", props);
40
47
  }
41
- function Input({ disabled, ...props }) {
42
- return usePart(useItem("input", disabled), "input", props);
48
+ function Input({ disabled, focusableWhenDisabled, ...props }) {
49
+ return usePart(useItem("input", {
50
+ disabled,
51
+ focusableWhenDisabled
52
+ }), "input", props);
43
53
  }
44
54
  function Group({ disabled, ...props }) {
45
- return usePart(useItem("group", disabled), "div", props);
55
+ return usePart(useItem("group", { disabled }), "div", props);
46
56
  }
47
57
  function Link(props) {
48
58
  const controller = useToolbar("Link");
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar.js","names":[],"sources":["../../../../packages/react/src/toolbar.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { Part, StateOf } from \"@kirana-ui/core\"\nimport { createToolbar } from \"@kirana-ui/core/toolbar\"\nimport type { Toolbar as Controller, ToolbarProps } from \"@kirana-ui/core/toolbar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\ntype Parts = Vocabulary[\"toolbar\"]\n\nfunction useToolbar(part: string): Controller {\n const controller = useContext(ToolbarContext)\n if (!controller) throw new Error(`<Toolbar.${part}> must be inside <Toolbar.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"div\", StateOf<Parts[\"root\"]>, ToolbarProps>\n\nfunction Root({ orientation, loop, disabled, ...rest }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<ToolbarProps, Controller>(within(createToolbar, { direction }), {\n orientation,\n loop,\n disabled,\n })\n return (\n <ToolbarContext.Provider value={controller}>\n {/* A toggle group around the toolbar is not the group of the toolbar's toggles. */}\n <ToggleGroupContext.Provider value={null}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n </ToolbarContext.Provider>\n )\n}\n\n/** What an item of the toolbar takes of its own. */\nexport interface ItemOptions {\n /** Disables this control. */\n disabled?: boolean\n}\n\nexport type ButtonProps = PartComponentProps<\"button\", StateOf<Parts[\"button\"]>, ItemOptions>\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>, ItemOptions>\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n/** @deprecated The item's own: `ButtonProps`, `InputProps` or `GroupProps`. */\nexport type ItemProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n\nfunction useItem(name: \"button\" | \"input\" | \"group\", disabled: boolean | undefined): Part {\n const controller = useToolbar(name)\n const options = useOptions({ disabled })\n return useMemo(() => controller[name](() => defined(options.get())), [controller, name, options])\n}\n\nfunction Button({ disabled, ...props }: ButtonProps): ReactElement {\n return usePart(useItem(\"button\", disabled), \"button\", props)\n}\n\nfunction Input({ disabled, ...props }: InputProps): ReactElement {\n return usePart(useItem(\"input\", disabled), \"input\", props)\n}\n\nfunction Group({ disabled, ...props }: GroupProps): ReactElement {\n return usePart(useItem(\"group\", disabled), \"div\", props)\n}\n\nexport type LinkProps = PartComponentProps<\"a\", StateOf<Parts[\"link\"]>>\n\nfunction Link(props: LinkProps): ReactElement {\n const controller = useToolbar(\"Link\")\n const part = useMemo(() => controller.link(), [controller])\n return usePart(part, \"a\", props)\n}\n\nexport type SeparatorProps = PartComponentProps<\"div\", StateOf<Parts[\"separator\"]>>\n\nconst Separator = (props: SeparatorProps) =>\n usePart(useToolbar(\"Separator\").separator, \"div\", props)\n\nexport const Toolbar = /* @__PURE__ */ parts(\"Toolbar\", {\n Root,\n Button,\n Link,\n Input,\n Group,\n Separator,\n})\n"],"mappings":";;;;;;;;AAeA,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,cAAc;CAC5C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,aAAa,MAAM,UAAU,GAAG,QAAiC;CAC/E,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cAAwC,OAAO,eAAe,EAAE,UAAU,CAAC,GAAG;EAC/F;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAE9B,UAAA,oBAAC,mBAAmB,UAApB;GAA6B,OAAO;GACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;EACV,CAAA;CACN,CAAA;AAE7B;AAcA,SAAS,QAAQ,MAAoC,UAAqC;CACxF,MAAM,aAAa,WAAW,IAAI;CAClC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,OAAO,cAAc,WAAW,KAAK,OAAO,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG;EAAC;EAAY;EAAM;CAAO,CAAC;AAClG;AAEA,SAAS,OAAO,EAAE,UAAU,GAAG,SAAoC;CACjE,OAAO,QAAQ,QAAQ,UAAU,QAAQ,GAAG,UAAU,KAAK;AAC7D;AAEA,SAAS,MAAM,EAAE,UAAU,GAAG,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,SAAS,QAAQ,GAAG,SAAS,KAAK;AAC3D;AAEA,SAAS,MAAM,EAAE,UAAU,GAAG,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,SAAS,QAAQ,GAAG,OAAO,KAAK;AACzD;AAIA,SAAS,KAAK,OAAgC;CAC5C,MAAM,aAAa,WAAW,MAAM;CACpC,MAAM,OAAO,cAAc,WAAW,KAAK,GAAG,CAAC,UAAU,CAAC;CAC1D,OAAO,QAAQ,MAAM,KAAK,KAAK;AACjC;AAIA,MAAM,aAAa,UACjB,QAAQ,WAAW,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;AAEzD,MAAa,UAA0B,sBAAM,WAAW;CACtD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"toolbar.js","names":[],"sources":["../../../../packages/react/src/toolbar.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { Part, StateOf } from \"@kirana-ui/core\"\nimport { createToolbar } from \"@kirana-ui/core/toolbar\"\nimport type { Toolbar as Controller, ToolbarProps } from \"@kirana-ui/core/toolbar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { parts, useController, useOptions, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\ntype Parts = Vocabulary[\"toolbar\"]\n\nfunction useToolbar(part: string): Controller {\n const controller = useContext(ToolbarContext)\n if (!controller) throw new Error(`<Toolbar.${part}> must be inside <Toolbar.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"div\", StateOf<Parts[\"root\"]>, ToolbarProps>\n\nfunction Root({ orientation, loop, loopFocus, disabled, ...rest }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<ToolbarProps, Controller>(within(createToolbar, { direction }), {\n orientation,\n loop,\n loopFocus,\n disabled,\n })\n return (\n <ToolbarContext.Provider value={controller}>\n {/* A toggle group around the toolbar is not the group of the toolbar's toggles. */}\n <ToggleGroupContext.Provider value={null}>\n {usePart(controller.root, \"div\", rest)}\n </ToggleGroupContext.Provider>\n </ToolbarContext.Provider>\n )\n}\n\n/** What an item of the toolbar takes of its own. */\nexport interface ItemOptions {\n /** Disables this control. */\n disabled?: boolean\n}\n\n/** What a button or an input of the toolbar takes of its own. */\nexport interface ControlOptions extends ItemOptions {\n /**\n * Keeps it focusable while disabled, as Base UI's: the arrows still reach it, and a press does\n * nothing. Default `true`; with `false` it is disabled the element's own way.\n */\n focusableWhenDisabled?: boolean\n}\n\nexport type ButtonProps = PartComponentProps<\"button\", StateOf<Parts[\"button\"]>, ControlOptions>\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>, ControlOptions>\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n/** @deprecated The item's own: `ButtonProps`, `InputProps` or `GroupProps`. */\nexport type ItemProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, ItemOptions>\n\nfunction useItem(\n name: \"button\" | \"input\" | \"group\",\n { disabled, focusableWhenDisabled }: ControlOptions\n): Part {\n const controller = useToolbar(name)\n const options = useOptions({ disabled, focusableWhenDisabled })\n return useMemo(() => controller[name](() => defined(options.get())), [controller, name, options])\n}\n\nfunction Button({ disabled, focusableWhenDisabled, ...props }: ButtonProps): ReactElement {\n return usePart(useItem(\"button\", { disabled, focusableWhenDisabled }), \"button\", props)\n}\n\nfunction Input({ disabled, focusableWhenDisabled, ...props }: InputProps): ReactElement {\n return usePart(useItem(\"input\", { disabled, focusableWhenDisabled }), \"input\", props)\n}\n\nfunction Group({ disabled, ...props }: GroupProps): ReactElement {\n return usePart(useItem(\"group\", { disabled }), \"div\", props)\n}\n\nexport type LinkProps = PartComponentProps<\"a\", StateOf<Parts[\"link\"]>>\n\nfunction Link(props: LinkProps): ReactElement {\n const controller = useToolbar(\"Link\")\n const part = useMemo(() => controller.link(), [controller])\n return usePart(part, \"a\", props)\n}\n\nexport type SeparatorProps = PartComponentProps<\"div\", StateOf<Parts[\"separator\"]>>\n\nconst Separator = (props: SeparatorProps) =>\n usePart(useToolbar(\"Separator\").separator, \"div\", props)\n\nexport const Toolbar = /* @__PURE__ */ parts(\"Toolbar\", {\n Root,\n Button,\n Link,\n Input,\n Group,\n Separator,\n})\n"],"mappings":";;;;;;;;AAeA,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,cAAc;CAC5C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,aAAa,MAAM,WAAW,UAAU,GAAG,QAAiC;CAC1F,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cAAwC,OAAO,eAAe,EAAE,UAAU,CAAC,GAAG;EAC/F;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAE9B,UAAA,oBAAC,mBAAmB,UAApB;GAA6B,OAAO;GACjC,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;EACV,CAAA;CACN,CAAA;AAE7B;AAuBA,SAAS,QACP,MACA,EAAE,UAAU,yBACN;CACN,MAAM,aAAa,WAAW,IAAI;CAClC,MAAM,UAAU,WAAW;EAAE;EAAU;CAAsB,CAAC;CAC9D,OAAO,cAAc,WAAW,KAAK,OAAO,QAAQ,QAAQ,IAAI,CAAC,CAAC,GAAG;EAAC;EAAY;EAAM;CAAO,CAAC;AAClG;AAEA,SAAS,OAAO,EAAE,UAAU,uBAAuB,GAAG,SAAoC;CACxF,OAAO,QAAQ,QAAQ,UAAU;EAAE;EAAU;CAAsB,CAAC,GAAG,UAAU,KAAK;AACxF;AAEA,SAAS,MAAM,EAAE,UAAU,uBAAuB,GAAG,SAAmC;CACtF,OAAO,QAAQ,QAAQ,SAAS;EAAE;EAAU;CAAsB,CAAC,GAAG,SAAS,KAAK;AACtF;AAEA,SAAS,MAAM,EAAE,UAAU,GAAG,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GAAG,OAAO,KAAK;AAC7D;AAIA,SAAS,KAAK,OAAgC;CAC5C,MAAM,aAAa,WAAW,MAAM;CACpC,MAAM,OAAO,cAAc,WAAW,KAAK,GAAG,CAAC,UAAU,CAAC;CAC1D,OAAO,QAAQ,MAAM,KAAK,KAAK;AACjC;AAIA,MAAM,aAAa,UACjB,QAAQ,WAAW,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;AAEzD,MAAa,UAA0B,sBAAM,WAAW;CACtD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
package/src/tour.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { PartComponentProps, PortalProps, PositionerOptions } from "./runtime.js";
2
+ import { ReactElement, ReactNode } from "react";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { TourProps, TourStep } from "@kirana-ui/core/tour";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["tour"];
7
+ /** `Step` is what each step is: a `TourStep` with whatever the page draws it from. */
8
+ export type RootProps<Step extends TourStep = TourStep> = Omit<TourProps<Step>, "id"> & {
9
+ id?: string;
10
+ children?: ReactNode;
11
+ };
12
+ declare function Root<Step extends TourStep = TourStep>({ children, ...props }: RootProps<Step>): ReactElement;
13
+ declare function Portal({ children }: PortalProps): ReactElement | null;
14
+ export type SpotlightProps = PartComponentProps<"div", StateOf<Parts["spotlight"]>>;
15
+ declare const Spotlight: (props: SpotlightProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
16
+ export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
17
+ declare function Positioner(props: PositionerProps): ReactElement;
18
+ /** What the popup's `children` is told of the step it shows, to draw it. */
19
+ export interface TourShownStep<Step extends TourStep = TourStep> {
20
+ /** The step shown, as the page gave it; `undefined` while none is. */
21
+ step: Step | undefined;
22
+ /** Its index, from 0. */
23
+ index: number;
24
+ /** Its place, from 1: the "2" of "2 of 5". */
25
+ current: number;
26
+ /** How many steps there are: the "5" of "2 of 5". */
27
+ total: number;
28
+ }
29
+ export type PopupProps<Step extends TourStep = TourStep> = PartComponentProps<"div", StateOf<Parts["popup"]>, {
30
+ /** What the popup holds, or a function given the step shown that draws it. */
31
+ children?: ReactNode | ((shown: TourShownStep<Step>) => ReactNode);
32
+ }>;
33
+ /** The step: its children, or what a function of the step shown draws. */
34
+ declare function Popup<Step extends TourStep = TourStep>({ children, ...props }: PopupProps<Step>): ReactElement;
35
+ export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
36
+ export type TitleProps = PartComponentProps<"h2", StateOf<Parts["title"]>>;
37
+ export type DescriptionProps = PartComponentProps<"p", StateOf<Parts["description"]>>;
38
+ export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
39
+ export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
40
+ export type CloseProps = PartComponentProps<"button", StateOf<Parts["close"]>>;
41
+ declare const Arrow: (props: ArrowProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
42
+ declare const Title: (props: TitleProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
43
+ declare const Description: (props: DescriptionProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
44
+ declare const Previous: (props: PreviousProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
45
+ declare const Next: (props: NextProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
46
+ declare const Close: (props: CloseProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
47
+ export declare const Tour: {
48
+ readonly Root: typeof Root;
49
+ readonly Portal: typeof Portal;
50
+ readonly Spotlight: typeof Spotlight;
51
+ readonly Positioner: typeof Positioner;
52
+ readonly Popup: typeof Popup;
53
+ readonly Arrow: typeof Arrow;
54
+ readonly Title: typeof Title;
55
+ readonly Description: typeof Description;
56
+ readonly Previous: typeof Previous;
57
+ readonly Next: typeof Next;
58
+ readonly Close: typeof Close;
59
+ };
60
+ export type { PortalProps };
61
+ //# sourceMappingURL=tour.d.ts.map