@kirana-ui/react 0.1.0 → 0.2.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 (172) hide show
  1. package/llms.txt +3216 -0
  2. package/package.json +124 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +142 -0
  4. package/src/accordion.d.ts +26 -15
  5. package/src/accordion.js +12 -11
  6. package/src/accordion.js.map +1 -1
  7. package/src/agent.d.ts +1 -0
  8. package/src/agent.js +1 -0
  9. package/src/alert-dialog.d.ts +3 -2
  10. package/src/autocomplete.d.ts +3 -0
  11. package/src/autocomplete.js +1 -0
  12. package/src/autosize.d.ts +12 -0
  13. package/src/autosize.js +12 -0
  14. package/src/autosize.js.map +1 -0
  15. package/src/avatar.d.ts +12 -8
  16. package/src/avatar.js +19 -10
  17. package/src/avatar.js.map +1 -1
  18. package/src/button.d.ts +4 -2
  19. package/src/button.js +3 -3
  20. package/src/button.js.map +1 -1
  21. package/src/calendar.d.ts +65 -0
  22. package/src/calendar.js +89 -0
  23. package/src/calendar.js.map +1 -0
  24. package/src/carousel.d.ts +36 -0
  25. package/src/carousel.js +52 -0
  26. package/src/carousel.js.map +1 -0
  27. package/src/checkbox.d.ts +10 -7
  28. package/src/checkbox.js +19 -12
  29. package/src/checkbox.js.map +1 -1
  30. package/src/collapsible.d.ts +12 -8
  31. package/src/collapsible.js +8 -7
  32. package/src/collapsible.js.map +1 -1
  33. package/src/combobox.d.ts +119 -0
  34. package/src/combobox.js +177 -0
  35. package/src/combobox.js.map +1 -0
  36. package/src/command.d.ts +53 -0
  37. package/src/command.js +95 -0
  38. package/src/command.js.map +1 -0
  39. package/src/context-menu.d.ts +3 -0
  40. package/src/context-menu.js +1 -0
  41. package/src/date-field.d.ts +37 -0
  42. package/src/date-field.js +64 -0
  43. package/src/date-field.js.map +1 -0
  44. package/src/date-picker.d.ts +44 -0
  45. package/src/date-picker.js +62 -0
  46. package/src/date-picker.js.map +1 -0
  47. package/src/dialog.d.ts +54 -27
  48. package/src/dialog.js +23 -6
  49. package/src/dialog.js.map +1 -1
  50. package/src/direction.d.ts +1 -0
  51. package/src/direction.js +1 -1
  52. package/src/direction.js.map +1 -1
  53. package/src/drawer.d.ts +3 -0
  54. package/src/drawer.js +1 -0
  55. package/src/element.d.ts +12 -0
  56. package/src/element.js +20 -0
  57. package/src/element.js.map +1 -0
  58. package/src/field.d.ts +24 -16
  59. package/src/field.js +11 -9
  60. package/src/field.js.map +1 -1
  61. package/src/fieldset.d.ts +10 -5
  62. package/src/fieldset.js +4 -5
  63. package/src/fieldset.js.map +1 -1
  64. package/src/form.d.ts +5 -2
  65. package/src/form.js +6 -6
  66. package/src/form.js.map +1 -1
  67. package/src/hover-card.d.ts +16 -10
  68. package/src/hover-card.js +1 -1
  69. package/src/hover-card.js.map +1 -1
  70. package/src/hover-popup.d.ts +26 -12
  71. package/src/hover-popup.js +12 -12
  72. package/src/hover-popup.js.map +1 -1
  73. package/src/index.d.ts +37 -3
  74. package/src/index.js +26 -2
  75. package/src/input.d.ts +12 -0
  76. package/src/input.js +21 -0
  77. package/src/input.js.map +1 -0
  78. package/src/label.d.ts +8 -0
  79. package/src/label.js +14 -0
  80. package/src/label.js.map +1 -0
  81. package/src/listbox.d.ts +36 -0
  82. package/src/listbox.js +88 -0
  83. package/src/listbox.js.map +1 -0
  84. package/src/menu.d.ts +107 -0
  85. package/src/menu.js +206 -0
  86. package/src/menu.js.map +1 -0
  87. package/src/menubar-context.d.ts +4 -0
  88. package/src/menubar-context.js +7 -0
  89. package/src/menubar-context.js.map +1 -0
  90. package/src/menubar.d.ts +11 -0
  91. package/src/menubar.js +25 -0
  92. package/src/menubar.js.map +1 -0
  93. package/src/message-scroller.d.ts +24 -0
  94. package/src/message-scroller.js +35 -0
  95. package/src/message-scroller.js.map +1 -0
  96. package/src/meter.d.ts +18 -9
  97. package/src/meter.js +1 -1
  98. package/src/meter.js.map +1 -1
  99. package/src/navigation-menu.d.ts +58 -0
  100. package/src/navigation-menu.js +106 -0
  101. package/src/navigation-menu.js.map +1 -0
  102. package/src/number-field.d.ts +28 -0
  103. package/src/number-field.js +58 -0
  104. package/src/number-field.js.map +1 -0
  105. package/src/otp.d.ts +35 -0
  106. package/src/otp.js +64 -0
  107. package/src/otp.js.map +1 -0
  108. package/src/pagination.d.ts +37 -0
  109. package/src/pagination.js +50 -0
  110. package/src/pagination.js.map +1 -0
  111. package/src/popover.d.ts +32 -22
  112. package/src/popover.js +10 -14
  113. package/src/popover.js.map +1 -1
  114. package/src/progress.d.ts +18 -9
  115. package/src/progress.js +1 -1
  116. package/src/progress.js.map +1 -1
  117. package/src/qr-code.d.ts +21 -0
  118. package/src/qr-code.js +32 -0
  119. package/src/qr-code.js.map +1 -0
  120. package/src/radio-group.d.ts +17 -11
  121. package/src/radio-group.js +20 -22
  122. package/src/radio-group.js.map +1 -1
  123. package/src/resizable.d.ts +24 -0
  124. package/src/resizable.js +51 -0
  125. package/src/resizable.js.map +1 -0
  126. package/src/runtime.d.ts +114 -13
  127. package/src/runtime.js +205 -24
  128. package/src/runtime.js.map +1 -1
  129. package/src/scroll-area.d.ts +36 -0
  130. package/src/scroll-area.js +64 -0
  131. package/src/scroll-area.js.map +1 -0
  132. package/src/select.d.ts +79 -31
  133. package/src/select.js +86 -23
  134. package/src/select.js.map +1 -1
  135. package/src/separator.d.ts +4 -2
  136. package/src/separator.js +3 -3
  137. package/src/separator.js.map +1 -1
  138. package/src/slider.d.ts +35 -20
  139. package/src/slider.js +20 -19
  140. package/src/slider.js.map +1 -1
  141. package/src/switch.d.ts +10 -6
  142. package/src/switch.js +12 -9
  143. package/src/switch.js.map +1 -1
  144. package/src/tabs.d.ts +22 -14
  145. package/src/tabs.js +7 -8
  146. package/src/tabs.js.map +1 -1
  147. package/src/testing.d.ts +1 -0
  148. package/src/testing.js +1 -0
  149. package/src/toast.d.ts +68 -0
  150. package/src/toast.js +107 -0
  151. package/src/toast.js.map +1 -0
  152. package/src/toggle-group.d.ts +10 -0
  153. package/src/toggle-group.js +32 -0
  154. package/src/toggle-group.js.map +1 -0
  155. package/src/toggle.d.ts +5 -2
  156. package/src/toggle.js +15 -5
  157. package/src/toggle.js.map +1 -1
  158. package/src/toolbar-context.d.ts +7 -0
  159. package/src/toolbar-context.js +9 -0
  160. package/src/toolbar-context.js.map +1 -0
  161. package/src/toolbar.d.ts +35 -0
  162. package/src/toolbar.js +63 -0
  163. package/src/toolbar.js.map +1 -0
  164. package/src/tooltip.d.ts +16 -10
  165. package/src/tooltip.js +1 -1
  166. package/src/tooltip.js.map +1 -1
  167. package/src/use-render.d.ts +38 -0
  168. package/src/use-render.js +50 -0
  169. package/src/use-render.js.map +1 -0
  170. package/src/value-bar.d.ts +19 -11
  171. package/src/value-bar.js +8 -5
  172. package/src/value-bar.js.map +1 -1
package/src/tabs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
- import { useController, useOptions, usePart, useSignal } from "./runtime.js";
2
+ import { PartElement, parts, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
3
3
  import { defined, within } from "@kirana-ui/core";
4
- import { createContext, useContext, useEffect, useMemo } from "react";
4
+ import { createContext, useContext, useMemo } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { createTabs } from "@kirana-ui/core/tabs";
7
7
  // src/tabs.tsx
@@ -24,13 +24,12 @@ function Root({ value, defaultValue, onValueChange, orientation, id, ...rest })
24
24
  return /* @__PURE__ */ jsx(Context.Provider, {
25
25
  value: controller,
26
26
  children: /* @__PURE__ */ jsx(PartElement, {
27
- part: controller.root,
27
+ of: controller.root,
28
28
  tag: "div",
29
29
  ...rest
30
30
  })
31
31
  });
32
32
  }
33
- const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
34
33
  function List({ activateOnFocus, loop, ...props }) {
35
34
  const controller = useTabs("List");
36
35
  controller.listOptions.set(defined({
@@ -53,21 +52,21 @@ const Indicator = (props) => usePart(useTabs("Indicator").indicator, "span", pro
53
52
  function Panel({ value, keepMounted, ...props }) {
54
53
  const controller = useTabs("Panel");
55
54
  const panel = useMemo(() => controller.panel(value), [controller, value]);
56
- useEffect(() => panel.mount(), [panel]);
55
+ useMount(panel);
57
56
  if (!useSignal(panel.mounted) && !keepMounted) return null;
58
57
  return /* @__PURE__ */ jsx(PartElement, {
59
- part: panel.part,
58
+ of: panel.part,
60
59
  tag: "div",
61
60
  ...props
62
61
  });
63
62
  }
64
- const Tabs = {
63
+ const Tabs = /* @__PURE__ */ parts("Tabs", {
65
64
  Root,
66
65
  List,
67
66
  Tab,
68
67
  Indicator,
69
68
  Panel
70
- };
69
+ });
71
70
  export { Tabs };
72
71
 
73
72
  //# sourceMappingURL=tabs.js.map
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 { Part } from \"@kirana-ui/core\"\nimport { createTabs } from \"@kirana-ui/core/tabs\"\nimport type { Tabs as Controller, TabsListOptions, TabsProps } from \"@kirana-ui/core/tabs\"\nimport { createContext, useContext, useEffect, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { useController, useOptions, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\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\nexport type RootProps<Value> = Omit<TabsProps<Value>, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root<Value>({\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 = useController(create, {\n value: value as Value | null | undefined,\n defaultValue: defaultValue as Value | null | undefined,\n onValueChange,\n orientation,\n id,\n }) as unknown as Controller\n return (\n <Context.Provider value={controller}>\n <PartElement part={controller.root} tag=\"div\" {...rest} />\n </Context.Provider>\n )\n}\n\nconst PartElement = ({ part, tag, ...props }: PartComponentProps & { part: Part; tag: string }) =>\n usePart(part, tag, props)\n\nexport type ListProps = PartComponentProps & 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 interface TabProps extends PartComponentProps {\n value: unknown\n disabled?: boolean\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\nconst Indicator = (props: PartComponentProps) =>\n usePart(useTabs(\"Indicator\").indicator, \"span\", props)\n\nexport interface PanelProps extends PartComponentProps {\n value: unknown\n /** Keeps the panel in the page, `hidden`, while its tab is not the active one. */\n keepMounted?: boolean\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 useEffect(() => panel.mount(), [panel])\n const mounted = useSignal(panel.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement part={panel.part} tag=\"div\" {...props} />\n}\n\nexport const Tabs = { Root, List, Tab, Indicator, Panel }\n"],"mappings":";;;;;;;AAWA,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;AAIA,SAAS,KAAY,EACnB,OACA,cACA,eACA,aACA,IACA,GAAG,QAC8B;CACjC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,YAAmB,EAAE,UAAU,CAAC;CACtD,MAAM,aAAa,cAAc,QAAQ;EAChC;EACO;EACd;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,MAAM,WAAW;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CACzC,CAAA;AAEtB;AAEA,MAAM,eAAe,EAAE,MAAM,KAAK,GAAG,YACnC,QAAQ,MAAM,KAAK,KAAK;AAI1B,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;AAOA,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;AAEA,MAAM,aAAa,UACjB,QAAQ,QAAQ,WAAW,CAAC,CAAC,WAAW,QAAQ,KAAK;AAQvD,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,gBAAgB,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC;CAEtC,IAAI,CADY,UAAU,MAAM,OACrB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,MAAM,MAAM;EAAM,KAAI;EAAM,GAAI;CAAQ,CAAA;AAC9D;AAEA,MAAa,OAAO;CAAE;CAAM;CAAM;CAAK;CAAW;AAAM"}
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"}
@@ -0,0 +1 @@
1
+ export * from "@kirana-ui/core/testing";
package/src/testing.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@kirana-ui/core/testing";
package/src/toast.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
3
+ import { ReactElement, ReactNode } from "react";
4
+ import * as Core from "@kirana-ui/core/toast";
5
+ import { ToasterOptions } from "@kirana-ui/core/toast";
6
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
7
+ /** What a toast's title, description and action's label may be here: anything React draws. */
8
+ export type ToastContent = ReactNode;
9
+ export type ToastActionOptions<Content = ReactNode> = Core.ToastActionOptions<Content>;
10
+ export type ToastOptions<Content = ReactNode> = Core.ToastOptions<Content>;
11
+ export type ToastRecord<Content = ReactNode> = Core.ToastRecord<Content>;
12
+ export type ToastState<Content = ReactNode> = Core.ToastState<Content>;
13
+ export type Toaster<Content = ReactNode> = Core.Toaster<Content>;
14
+ /**
15
+ * The toasts of a page, made once, in a module: `toaster.add({ title })` from anywhere. A
16
+ * title, a description and an action's label are anything React draws, unless `Content` says
17
+ * otherwise.
18
+ */
19
+ export declare const createToaster: <Content = ReactNode>(options?: Core.ToasterOptions) => Toaster<Content>;
20
+ type Parts = Vocabulary["toast"];
21
+ type ToastProps = Core.ToastProps<ReactNode>;
22
+ export type ViewportProps = PartComponentProps<"div", StateOf<Parts["viewport"]>, Omit<ToastProps, "id"> & {
23
+ id?: string;
24
+ }>;
25
+ /** Where a toaster's toasts are drawn. Always in the page: put it once, near the root. */
26
+ declare function Viewport({ toaster, label, hotkey, swipeDirection, id, ...rest }: ViewportProps): ReactElement;
27
+ export interface ListProps {
28
+ /** Draws one toast, once for each, the newest first: a `Toast.Root` given it as `toast`. */
29
+ children: (toast: ToastRecord) => ReactNode;
30
+ }
31
+ /** Draws its child once for each toast, the newest first. */
32
+ declare function List({ children }: ListProps): ReactElement;
33
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, {
34
+ /** The toast it draws: the one `Toast.List` gave its child. */
35
+ toast: ToastRecord;
36
+ }>;
37
+ declare function Root({ toast, ...props }: RootProps): ReactElement;
38
+ export type ContentProps = PartComponentProps<"div", StateOf<Parts["content"]>>;
39
+ export type TitleProps = PartComponentProps<"div", StateOf<Parts["title"]>>;
40
+ export type DescriptionProps = PartComponentProps<"div", StateOf<Parts["description"]>>;
41
+ export type CloseProps = PartComponentProps<"button", StateOf<Parts["close"]>>;
42
+ export type ActionProps = PartComponentProps<"button", StateOf<Parts["action"]>>;
43
+ declare const Content: (props: ContentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
44
+ /**
45
+ * The toast's title: the caller's children when it has any, what the toast was added with
46
+ * otherwise, and nothing in the page when there is neither.
47
+ */
48
+ declare function Title(props: TitleProps): ReactElement | null;
49
+ /** The toast's description, unless it is given children of its own. */
50
+ declare function Description(props: DescriptionProps): ReactElement | null;
51
+ declare const Close: (props: CloseProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
52
+ /**
53
+ * The toast's action, its label unless it is given children of its own. A press tells the
54
+ * action (`onAction`), then closes the toast unless the action called `details.cancel()`.
55
+ */
56
+ declare function Action(props: ActionProps): ReactElement | null;
57
+ export declare const Toast: {
58
+ readonly Viewport: typeof Viewport;
59
+ readonly List: typeof List;
60
+ readonly Root: typeof Root;
61
+ readonly Content: typeof Content;
62
+ readonly Title: typeof Title;
63
+ readonly Description: typeof Description;
64
+ readonly Close: typeof Close;
65
+ readonly Action: typeof Action;
66
+ };
67
+ export type { ToasterOptions };
68
+ //# sourceMappingURL=toast.d.ts.map
package/src/toast.js ADDED
@@ -0,0 +1,107 @@
1
+ import { parts, useController, usePart, useSignal } from "./runtime.js";
2
+ import { Fragment, createContext, useContext } from "react";
3
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
4
+ import { createToast, createToaster as createToaster$1 } from "@kirana-ui/core/toast";
5
+ // src/toast.tsx
6
+ /**
7
+ * The toasts of a page, made once, in a module: `toaster.add({ title })` from anywhere. A
8
+ * title, a description and an action's label are anything React draws, unless `Content` says
9
+ * otherwise.
10
+ */
11
+ const createToaster = createToaster$1;
12
+ const Context = createContext(null);
13
+ const ToastContext = createContext(null);
14
+ function useToast(part) {
15
+ const controller = useContext(Context);
16
+ if (!controller) throw new Error(`<Toast.${part}> must be inside <Toast.Viewport>`);
17
+ return controller;
18
+ }
19
+ function useParts(part) {
20
+ const made = useContext(ToastContext);
21
+ if (!made) throw new Error(`<Toast.${part}> must be inside <Toast.Root>`);
22
+ return made;
23
+ }
24
+ /** Where a toaster's toasts are drawn. Always in the page: put it once, near the root. */
25
+ function Viewport({ toaster, label, hotkey, swipeDirection, id, ...rest }) {
26
+ const controller = useController(createToast, {
27
+ toaster,
28
+ label,
29
+ hotkey,
30
+ swipeDirection,
31
+ id
32
+ });
33
+ return /* @__PURE__ */ jsx(Context.Provider, {
34
+ value: controller,
35
+ children: usePart(controller.viewport, "div", rest)
36
+ });
37
+ }
38
+ /** Draws its child once for each toast, the newest first. */
39
+ function List({ children }) {
40
+ const toasts = useSignal(useToast("List").toasts);
41
+ return /* @__PURE__ */ jsx(Fragment$1, { children: toasts.map((toast) => /* @__PURE__ */ jsx(Fragment, { children: children(toast) }, toast.id)) });
42
+ }
43
+ function Root({ toast, ...props }) {
44
+ const made = useToast("Root").toast(toast.id);
45
+ return /* @__PURE__ */ jsx(ToastContext.Provider, {
46
+ value: made,
47
+ children: usePart(made.root, "div", props)
48
+ });
49
+ }
50
+ const Content = (props) => usePart(useParts("Content").content, "div", props);
51
+ /** A part that says something of the toast's, and what the toast was added with for it to say. */
52
+ function useSaid(name, part) {
53
+ const made = useParts(name);
54
+ const toast = useSignal(made.record);
55
+ return {
56
+ part: made[part],
57
+ said: part === "action" ? toast?.action?.label : toast?.[part]
58
+ };
59
+ }
60
+ const unlessSilent = (element, children, render) => children == null && !render ? null : element;
61
+ /**
62
+ * The toast's title: the caller's children when it has any, what the toast was added with
63
+ * otherwise, and nothing in the page when there is neither.
64
+ */
65
+ function Title(props) {
66
+ const { part, said } = useSaid("Title", "title");
67
+ const children = props.children ?? said;
68
+ return unlessSilent(usePart(part, "div", {
69
+ ...props,
70
+ children
71
+ }), children, props.render);
72
+ }
73
+ /** The toast's description, unless it is given children of its own. */
74
+ function Description(props) {
75
+ const { part, said } = useSaid("Description", "description");
76
+ const children = props.children ?? said;
77
+ return unlessSilent(usePart(part, "div", {
78
+ ...props,
79
+ children
80
+ }), children, props.render);
81
+ }
82
+ const Close = (props) => usePart(useParts("Close").close, "button", props);
83
+ /**
84
+ * The toast's action, its label unless it is given children of its own. A press tells the
85
+ * action (`onAction`), then closes the toast unless the action called `details.cancel()`.
86
+ */
87
+ function Action(props) {
88
+ const { part, said } = useSaid("Action", "action");
89
+ const children = props.children ?? said;
90
+ return unlessSilent(usePart(part, "button", {
91
+ ...props,
92
+ children
93
+ }), children, props.render);
94
+ }
95
+ const Toast = /* @__PURE__ */ parts("Toast", {
96
+ Viewport,
97
+ List,
98
+ Root,
99
+ Content,
100
+ Title,
101
+ Description,
102
+ Close,
103
+ Action
104
+ });
105
+ export { Toast, createToaster };
106
+
107
+ //# sourceMappingURL=toast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.js","names":["createCoreToaster"],"sources":["../../../../packages/react/src/toast.tsx"],"sourcesContent":["import type { Part, StateOf } from \"@kirana-ui/core\"\nimport { createToast, createToaster as createCoreToaster } from \"@kirana-ui/core/toast\"\nimport type * as Core from \"@kirana-ui/core/toast\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\n/** What a toast's title, description and action's label may be here: anything React draws. */\nexport type ToastContent = ReactNode\nexport type ToastActionOptions<Content = ReactNode> = Core.ToastActionOptions<Content>\nexport type ToastOptions<Content = ReactNode> = Core.ToastOptions<Content>\nexport type ToastRecord<Content = ReactNode> = Core.ToastRecord<Content>\nexport type ToastState<Content = ReactNode> = Core.ToastState<Content>\nexport type Toaster<Content = ReactNode> = Core.Toaster<Content>\nexport type { ToasterOptions } from \"@kirana-ui/core/toast\"\n\n/**\n * The toasts of a page, made once, in a module: `toaster.add({ title })` from anywhere. A\n * title, a description and an action's label are anything React draws, unless `Content` says\n * otherwise.\n */\nexport const createToaster: <Content = ReactNode>(\n options?: Core.ToasterOptions\n) => Toaster<Content> = createCoreToaster\n\ntype Parts = Vocabulary[\"toast\"]\n\ntype Controller = Core.Toast<ReactNode>\ntype ToastParts = Core.ToastParts<ReactNode>\ntype ToastProps = Core.ToastProps<ReactNode>\n\nconst Context = createContext<Controller | null>(null)\nconst ToastContext = createContext<ToastParts | null>(null)\n\nfunction useToast(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Toast.${part}> must be inside <Toast.Viewport>`)\n return controller\n}\n\nfunction useParts(part: string): ToastParts {\n const made = useContext(ToastContext)\n if (!made) throw new Error(`<Toast.${part}> must be inside <Toast.Root>`)\n return made\n}\n\nexport type ViewportProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"viewport\"]>,\n Omit<ToastProps, \"id\"> & { id?: string }\n>\n\n/** Where a toaster's toasts are drawn. Always in the page: put it once, near the root. */\nfunction Viewport({\n toaster,\n label,\n hotkey,\n swipeDirection,\n id,\n ...rest\n}: ViewportProps): ReactElement {\n const controller = useController<ToastProps, Controller>(createToast, {\n toaster,\n label,\n hotkey,\n swipeDirection,\n id,\n })\n return (\n <Context.Provider value={controller}>\n {usePart(controller.viewport, \"div\", rest)}\n </Context.Provider>\n )\n}\n\nexport interface ListProps {\n /** Draws one toast, once for each, the newest first: a `Toast.Root` given it as `toast`. */\n children: (toast: ToastRecord) => ReactNode\n}\n\n/** Draws its child once for each toast, the newest first. */\nfunction List({ children }: ListProps): ReactElement {\n const toasts = useSignal(useToast(\"List\").toasts)\n return (\n <>\n {toasts.map((toast) => (\n <Fragment key={toast.id}>{children(toast)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n {\n /** The toast it draws: the one `Toast.List` gave its child. */\n toast: ToastRecord\n }\n>\n\nfunction Root({ toast, ...props }: RootProps): ReactElement {\n const made = useToast(\"Root\").toast(toast.id)\n return (\n <ToastContext.Provider value={made}>{usePart(made.root, \"div\", props)}</ToastContext.Provider>\n )\n}\n\nexport type ContentProps = PartComponentProps<\"div\", StateOf<Parts[\"content\"]>>\nexport type TitleProps = PartComponentProps<\"div\", StateOf<Parts[\"title\"]>>\nexport type DescriptionProps = PartComponentProps<\"div\", StateOf<Parts[\"description\"]>>\nexport type CloseProps = PartComponentProps<\"button\", StateOf<Parts[\"close\"]>>\nexport type ActionProps = PartComponentProps<\"button\", StateOf<Parts[\"action\"]>>\n\nconst Content = (props: ContentProps) => usePart(useParts(\"Content\").content, \"div\", props)\n\n/** A part that says something of the toast's, and what the toast was added with for it to say. */\nfunction useSaid(\n name: string,\n part: \"title\" | \"description\" | \"action\"\n): { part: Part; said: ReactNode } {\n const made = useParts(name)\n const toast = useSignal(made.record)\n return { part: made[part], said: part === \"action\" ? toast?.action?.label : toast?.[part] }\n}\n\n// A `render` draws what it likes; without one, an element with nothing to say is not drawn.\nconst unlessSilent = (element: ReactElement, children: ReactNode, render: unknown) =>\n children == null && !render ? null : element\n\n/**\n * The toast's title: the caller's children when it has any, what the toast was added with\n * otherwise, and nothing in the page when there is neither.\n */\nfunction Title(props: TitleProps): ReactElement | null {\n const { part, said } = useSaid(\"Title\", \"title\")\n const children = props.children ?? said\n return unlessSilent(usePart(part, \"div\", { ...props, children }), children, props.render)\n}\n\n/** The toast's description, unless it is given children of its own. */\nfunction Description(props: DescriptionProps): ReactElement | null {\n const { part, said } = useSaid(\"Description\", \"description\")\n const children = props.children ?? said\n return unlessSilent(usePart(part, \"div\", { ...props, children }), children, props.render)\n}\n\nconst Close = (props: CloseProps) => usePart(useParts(\"Close\").close, \"button\", props)\n\n/**\n * The toast's action, its label unless it is given children of its own. A press tells the\n * action (`onAction`), then closes the toast unless the action called `details.cancel()`.\n */\nfunction Action(props: ActionProps): ReactElement | null {\n const { part, said } = useSaid(\"Action\", \"action\")\n const children = props.children ?? said\n return unlessSilent(usePart(part, \"button\", { ...props, children }), children, props.render)\n}\n\nexport const Toast = /* @__PURE__ */ parts(\"Toast\", {\n Viewport,\n List,\n Root,\n Content,\n Title,\n Description,\n Close,\n Action,\n})\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,gBAEWA;AAQxB,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,eAAe,cAAiC,IAAI;AAE1D,SAAS,SAAS,MAA0B;CAC1C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,UAAU,KAAK,kCAAkC;CAClF,OAAO;AACT;AAEA,SAAS,SAAS,MAA0B;CAC1C,MAAM,OAAO,WAAW,YAAY;CACpC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,UAAU,KAAK,8BAA8B;CACxE,OAAO;AACT;;AASA,SAAS,SAAS,EAChB,SACA,OACA,QACA,gBACA,IACA,GAAG,QAC2B;CAC9B,MAAM,aAAa,cAAsC,aAAa;EACpE;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACtB,UAAA,QAAQ,WAAW,UAAU,OAAO,IAAI;CACzB,CAAA;AAEtB;;AAQA,SAAS,KAAK,EAAE,YAAqC;CACnD,MAAM,SAAS,UAAU,SAAS,MAAM,CAAC,CAAC,MAAM;CAChD,OACE,oBAAA,YAAA,EAAA,UACG,OAAO,KAAK,UACX,oBAAC,UAAD,EAAA,UAA0B,SAAS,KAAK,EAAY,GAArC,MAAM,EAA+B,CACrD,EACD,CAAA;AAEN;AAWA,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,MAAM,MAAM,EAAE;CAC5C,OACE,oBAAC,aAAa,UAAd;EAAuB,OAAO;EAAO,UAAA,QAAQ,KAAK,MAAM,OAAO,KAAK;CAAyB,CAAA;AAEjG;AAQA,MAAM,WAAW,UAAwB,QAAQ,SAAS,SAAS,CAAC,CAAC,SAAS,OAAO,KAAK;;AAG1F,SAAS,QACP,MACA,MACiC;CACjC,MAAM,OAAO,SAAS,IAAI;CAC1B,MAAM,QAAQ,UAAU,KAAK,MAAM;CACnC,OAAO;EAAE,MAAM,KAAK;EAAO,MAAM,SAAS,WAAW,OAAO,QAAQ,QAAQ,QAAQ;CAAM;AAC5F;AAGA,MAAM,gBAAgB,SAAuB,UAAqB,WAChE,YAAY,QAAQ,CAAC,SAAS,OAAO;;;;;AAMvC,SAAS,MAAM,OAAwC;CACrD,MAAM,EAAE,MAAM,SAAS,QAAQ,SAAS,OAAO;CAC/C,MAAM,WAAW,MAAM,YAAY;CACnC,OAAO,aAAa,QAAQ,MAAM,OAAO;EAAE,GAAG;EAAO;CAAS,CAAC,GAAG,UAAU,MAAM,MAAM;AAC1F;;AAGA,SAAS,YAAY,OAA8C;CACjE,MAAM,EAAE,MAAM,SAAS,QAAQ,eAAe,aAAa;CAC3D,MAAM,WAAW,MAAM,YAAY;CACnC,OAAO,aAAa,QAAQ,MAAM,OAAO;EAAE,GAAG;EAAO;CAAS,CAAC,GAAG,UAAU,MAAM,MAAM;AAC1F;AAEA,MAAM,SAAS,UAAsB,QAAQ,SAAS,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;;;;;AAMrF,SAAS,OAAO,OAAyC;CACvD,MAAM,EAAE,MAAM,SAAS,QAAQ,UAAU,QAAQ;CACjD,MAAM,WAAW,MAAM,YAAY;CACnC,OAAO,aAAa,QAAQ,MAAM,UAAU;EAAE,GAAG;EAAO;CAAS,CAAC,GAAG,UAAU,MAAM,MAAM;AAC7F;AAEA,MAAa,QAAwB,sBAAM,SAAS;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
3
+ import { ReactElement } from "react";
4
+ import { ToggleGroupProps as ToggleGroupProps$1 } from "@kirana-ui/core/toggle-group";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ /** `Value` is what tells a toggle from the others: the type of `value`'s entries. */
7
+ export type ToggleGroupProps<Value = unknown> = PartComponentProps<"div", StateOf<Vocabulary["toggleGroup"]["root"]>, ToggleGroupProps$1<Value>>;
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;
10
+ //# sourceMappingURL=toggle-group.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { component, useController, usePart } from "./runtime.js";
3
+ import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
4
+ import { within } from "@kirana-ui/core";
5
+ import { useContext } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { createToggleGroup } from "@kirana-ui/core/toggle-group";
8
+ // src/toggle-group.tsx
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 }) {
11
+ const direction = useContext(DirectionContext) ?? void 0;
12
+ const toolbar = useContext(ToolbarContext) ?? void 0;
13
+ const controller = useController(within(createToggleGroup, {
14
+ direction,
15
+ toolbar
16
+ }), {
17
+ value,
18
+ defaultValue,
19
+ onValueChange,
20
+ multiple,
21
+ disabled,
22
+ orientation,
23
+ loop
24
+ });
25
+ return /* @__PURE__ */ jsx(ToggleGroupContext.Provider, {
26
+ value: controller,
27
+ children: usePart(controller.root, "div", rest)
28
+ });
29
+ });
30
+ export { ToggleGroup };
31
+
32
+ //# sourceMappingURL=toggle-group.js.map
@@ -0,0 +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"}
package/src/toggle.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
2
3
  import { ReactElement } from "react";
3
4
  import { ToggleProps as ToggleProps$1 } from "@kirana-ui/core/toggle";
4
- export type ToggleProps = ToggleProps$1 & PartComponentProps;
5
- export declare function Toggle({ pressed, defaultPressed, onPressedChange, disabled, ...rest }: ToggleProps): ReactElement;
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ export type ToggleProps = PartComponentProps<"button", StateOf<Vocabulary["toggle"]["root"]>, ToggleProps$1>;
7
+ /** Inside a `<ToggleGroup>`, `value` makes it one of the group's toggles. */
8
+ export declare const Toggle: ({ pressed, defaultPressed, onPressedChange, disabled, value, ...rest }: ToggleProps) => ReactElement;
6
9
  //# sourceMappingURL=toggle.d.ts.map
package/src/toggle.js CHANGED
@@ -1,15 +1,25 @@
1
- import { useController, usePart } from "./runtime.js";
1
+ import { component, useController, usePart } from "./runtime.js";
2
+ import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
3
+ import { within } from "@kirana-ui/core";
4
+ import { useContext } from "react";
2
5
  import { createToggle } from "@kirana-ui/core/toggle";
3
6
  // src/toggle.tsx
4
- function Toggle({ pressed, defaultPressed, onPressedChange, disabled, ...rest }) {
5
- const controller = useController(createToggle, {
7
+ /** Inside a `<ToggleGroup>`, `value` makes it one of the group's toggles. */
8
+ const Toggle = /* @__PURE__ */ component("Toggle", function Toggle({ pressed, defaultPressed, onPressedChange, disabled, value, ...rest }) {
9
+ const group = useContext(ToggleGroupContext) ?? void 0;
10
+ const toolbar = useContext(ToolbarContext) ?? void 0;
11
+ const controller = useController(within(createToggle, {
12
+ group,
13
+ toolbar
14
+ }), {
6
15
  pressed,
7
16
  defaultPressed,
8
17
  onPressedChange,
9
- disabled
18
+ disabled,
19
+ value
10
20
  });
11
21
  return usePart(controller.root, "button", rest);
12
- }
22
+ });
13
23
  export { Toggle };
14
24
 
15
25
  //# sourceMappingURL=toggle.js.map
package/src/toggle.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"toggle.js","names":[],"sources":["../../../../packages/react/src/toggle.tsx"],"sourcesContent":["import { createToggle } from \"@kirana-ui/core/toggle\"\nimport type { ToggleProps as CoreProps } from \"@kirana-ui/core/toggle\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type ToggleProps = CoreProps & PartComponentProps\n\nexport function Toggle({\n pressed,\n defaultPressed,\n onPressedChange,\n disabled,\n ...rest\n}: ToggleProps): ReactElement {\n const controller = useController(createToggle, {\n pressed,\n defaultPressed,\n onPressedChange,\n disabled,\n })\n return usePart(controller.root, \"button\", rest)\n}\n"],"mappings":";;;AASA,SAAgB,OAAO,EACrB,SACA,gBACA,iBACA,UACA,GAAG,QACyB;CAC5B,MAAM,aAAa,cAAc,cAAc;EAC7C;EACA;EACA;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW,MAAM,UAAU,IAAI;AAChD"}
1
+ {"version":3,"file":"toggle.js","names":[],"sources":["../../../../packages/react/src/toggle.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createToggle } from \"@kirana-ui/core/toggle\"\nimport type { Toggle as Controller, ToggleProps as CoreProps } from \"@kirana-ui/core/toggle\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { ToggleGroupContext, ToolbarContext } from \"./toolbar-context.ts\"\n\nexport type ToggleProps = PartComponentProps<\n \"button\",\n StateOf<Vocabulary[\"toggle\"][\"root\"]>,\n CoreProps\n>\n\n/** Inside a `<ToggleGroup>`, `value` makes it one of the group's toggles. */\nexport const Toggle = /* @__PURE__ */ component(\n \"Toggle\",\n function Toggle({\n pressed,\n defaultPressed,\n onPressedChange,\n disabled,\n value,\n ...rest\n }: ToggleProps): ReactElement {\n const group = useContext(ToggleGroupContext) ?? undefined\n const toolbar = useContext(ToolbarContext) ?? undefined\n const controller = useController<CoreProps, Controller>(\n within(createToggle, { group, toolbar }),\n {\n pressed,\n defaultPressed,\n onPressedChange,\n disabled,\n value,\n }\n )\n return usePart(controller.root, \"button\", rest)\n }\n)\n"],"mappings":";;;;;;;AAmBA,MAAa,SAAyB,0BACpC,UACA,SAAS,OAAO,EACd,SACA,gBACA,iBACA,UACA,OACA,GAAG,QACyB;CAC5B,MAAM,QAAQ,WAAW,kBAAkB,KAAK,KAAA;CAChD,MAAM,UAAU,WAAW,cAAc,KAAK,KAAA;CAC9C,MAAM,aAAa,cACjB,OAAO,cAAc;EAAE;EAAO;CAAQ,CAAC,GACvC;EACE;EACA;EACA;EACA;EACA;CACF,CACF;CACA,OAAO,QAAQ,WAAW,MAAM,UAAU,IAAI;AAChD,CACF"}
@@ -0,0 +1,7 @@
1
+ import { Toolbar } from "@kirana-ui/core/toolbar";
2
+ import { ToggleGroup } from "@kirana-ui/core/toggle-group";
3
+ /** The toolbar a control is an item of, if it is in one. */
4
+ export declare const ToolbarContext: import("react").Context<Toolbar | null>;
5
+ /** The group a toggle is one of the toggles of, if it is in one. */
6
+ export declare const ToggleGroupContext: import("react").Context<ToggleGroup<unknown> | null>;
7
+ //# sourceMappingURL=toolbar-context.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { createContext } from "react";
2
+ // src/toolbar-context.ts
3
+ /** The toolbar a control is an item of, if it is in one. */
4
+ const ToolbarContext = createContext(null);
5
+ /** The group a toggle is one of the toggles of, if it is in one. */
6
+ const ToggleGroupContext = createContext(null);
7
+ export { ToggleGroupContext, ToolbarContext };
8
+
9
+ //# sourceMappingURL=toolbar-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbar-context.js","names":[],"sources":["../../../../packages/react/src/toolbar-context.ts"],"sourcesContent":["import type { ToggleGroup } from \"@kirana-ui/core/toggle-group\"\nimport type { Toolbar } from \"@kirana-ui/core/toolbar\"\nimport { createContext } from \"react\"\n\n/** The toolbar a control is an item of, if it is in one. */\nexport const ToolbarContext = createContext<Toolbar | null>(null)\n/** The group a toggle is one of the toggles of, if it is in one. */\nexport const ToggleGroupContext = createContext<ToggleGroup | null>(null)\n"],"mappings":";;;AAKA,MAAa,iBAAiB,cAA8B,IAAI;;AAEhE,MAAa,qBAAqB,cAAkC,IAAI"}
@@ -0,0 +1,35 @@
1
+ import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
3
+ import { ReactElement } from "react";
4
+ import { ToolbarProps } from "@kirana-ui/core/toolbar";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["toolbar"];
7
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, ToolbarProps>;
8
+ declare function Root({ orientation, loop, disabled, ...rest }: RootProps): ReactElement;
9
+ /** What an item of the toolbar takes of its own. */
10
+ export interface ItemOptions {
11
+ /** Disables this control. */
12
+ disabled?: boolean;
13
+ }
14
+ export type ButtonProps = PartComponentProps<"button", StateOf<Parts["button"]>, ItemOptions>;
15
+ export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>, ItemOptions>;
16
+ export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, ItemOptions>;
17
+ /** @deprecated The item's own: `ButtonProps`, `InputProps` or `GroupProps`. */
18
+ 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;
21
+ declare function Group({ disabled, ...props }: GroupProps): ReactElement;
22
+ export type LinkProps = PartComponentProps<"a", StateOf<Parts["link"]>>;
23
+ declare function Link(props: LinkProps): ReactElement;
24
+ export type SeparatorProps = PartComponentProps<"div", StateOf<Parts["separator"]>>;
25
+ declare const Separator: (props: SeparatorProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
26
+ export declare const Toolbar: {
27
+ readonly Root: typeof Root;
28
+ readonly Button: typeof Button;
29
+ readonly Link: typeof Link;
30
+ readonly Input: typeof Input;
31
+ readonly Group: typeof Group;
32
+ readonly Separator: typeof Separator;
33
+ };
34
+ export {};
35
+ //# sourceMappingURL=toolbar.d.ts.map
package/src/toolbar.js ADDED
@@ -0,0 +1,63 @@
1
+ import { DirectionContext } from "./direction-context.js";
2
+ import { parts, useController, useOptions, usePart } from "./runtime.js";
3
+ import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
4
+ import { defined, within } from "@kirana-ui/core";
5
+ import { useContext, useMemo } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { createToolbar } from "@kirana-ui/core/toolbar";
8
+ // src/toolbar.tsx
9
+ function useToolbar(part) {
10
+ const controller = useContext(ToolbarContext);
11
+ if (!controller) throw new Error(`<Toolbar.${part}> must be inside <Toolbar.Root>`);
12
+ return controller;
13
+ }
14
+ function Root({ orientation, loop, disabled, ...rest }) {
15
+ const direction = useContext(DirectionContext) ?? void 0;
16
+ const controller = useController(within(createToolbar, { direction }), {
17
+ orientation,
18
+ loop,
19
+ disabled
20
+ });
21
+ return /* @__PURE__ */ jsx(ToolbarContext.Provider, {
22
+ value: controller,
23
+ children: /* @__PURE__ */ jsx(ToggleGroupContext.Provider, {
24
+ value: null,
25
+ children: usePart(controller.root, "div", rest)
26
+ })
27
+ });
28
+ }
29
+ function useItem(name, disabled) {
30
+ const controller = useToolbar(name);
31
+ const options = useOptions({ disabled });
32
+ return useMemo(() => controller[name](() => defined(options.get())), [
33
+ controller,
34
+ name,
35
+ options
36
+ ]);
37
+ }
38
+ function Button({ disabled, ...props }) {
39
+ return usePart(useItem("button", disabled), "button", props);
40
+ }
41
+ function Input({ disabled, ...props }) {
42
+ return usePart(useItem("input", disabled), "input", props);
43
+ }
44
+ function Group({ disabled, ...props }) {
45
+ return usePart(useItem("group", disabled), "div", props);
46
+ }
47
+ function Link(props) {
48
+ const controller = useToolbar("Link");
49
+ const part = useMemo(() => controller.link(), [controller]);
50
+ return usePart(part, "a", props);
51
+ }
52
+ const Separator = (props) => usePart(useToolbar("Separator").separator, "div", props);
53
+ const Toolbar = /* @__PURE__ */ parts("Toolbar", {
54
+ Root,
55
+ Button,
56
+ Link,
57
+ Input,
58
+ Group,
59
+ Separator
60
+ });
61
+ export { Toolbar };
62
+
63
+ //# sourceMappingURL=toolbar.js.map
@@ -0,0 +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"}
package/src/tooltip.d.ts CHANGED
@@ -1,13 +1,19 @@
1
- import { PositionerProps, RootProps } from "./hover-popup.js";
2
- import { PartComponentProps } from "./runtime.js";
1
+ import { RootProps, TriggerOptions } from "./hover-popup.js";
2
+ import { PartComponentProps, PortalProps, PositionerOptions } from "./runtime.js";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
5
+ type Parts = Vocabulary["tooltip"];
6
+ export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>, TriggerOptions>;
7
+ export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
8
+ export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
9
+ export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
3
10
  export declare const Tooltip: {
4
- Root: ({ children, ...props }: RootProps) => import("react").ReactElement;
5
- Trigger: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
6
- Portal: ({ children }: {
7
- children?: import("react").ReactNode;
8
- }) => import("react").ReactElement | null;
9
- Positioner: ({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps) => import("react").ReactElement;
10
- Popup: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
11
- Arrow: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
11
+ Root: (props: RootProps) => import("react").ReactElement;
12
+ Trigger: (props: TriggerProps) => import("react").ReactElement;
13
+ Portal: (props: PortalProps) => import("react").ReactElement | null;
14
+ Positioner: (props: PositionerProps) => import("react").ReactElement;
15
+ Popup: (props: PopupProps) => import("react").ReactElement;
16
+ Arrow: (props: ArrowProps) => import("react").ReactElement;
12
17
  };
18
+ export type { PortalProps, RootProps };
13
19
  //# sourceMappingURL=tooltip.d.ts.map
package/src/tooltip.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { hoverPopup } from "./hover-popup.js";
2
2
  import { createTooltip } from "@kirana-ui/core/tooltip";
3
3
  // src/tooltip.tsx
4
- const Tooltip = hoverPopup("Tooltip", createTooltip, "button");
4
+ const Tooltip = /* @__PURE__ */ hoverPopup("Tooltip", createTooltip, "button");
5
5
  export { Tooltip };
6
6
 
7
7
  //# sourceMappingURL=tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","names":[],"sources":["../../../../packages/react/src/tooltip.tsx"],"sourcesContent":["import { createTooltip } from \"@kirana-ui/core/tooltip\"\n\nimport { hoverPopup } from \"./hover-popup.tsx\"\n\nexport const Tooltip = hoverPopup(\"Tooltip\", createTooltip, \"button\")\n"],"mappings":";;;AAIA,MAAa,UAAU,WAAW,WAAW,eAAe,QAAQ"}
1
+ {"version":3,"file":"tooltip.js","names":[],"sources":["../../../../packages/react/src/tooltip.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createTooltip } from \"@kirana-ui/core/tooltip\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\n\nimport { hoverPopup } from \"./hover-popup.tsx\"\nimport type { TriggerOptions } from \"./hover-popup.tsx\"\nimport type { PartComponentProps, PositionerOptions } from \"./runtime.tsx\"\n\nexport type { PortalProps, RootProps } from \"./hover-popup.tsx\"\n\ntype Parts = Vocabulary[\"tooltip\"]\n\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>, TriggerOptions>\nexport type PositionerProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"positioner\"]>,\n PositionerOptions\n>\nexport type PopupProps = PartComponentProps<\"div\", StateOf<Parts[\"popup\"]>>\nexport type ArrowProps = PartComponentProps<\"div\", StateOf<Parts[\"arrow\"]>>\n\nexport const Tooltip = /* @__PURE__ */ hoverPopup<{\n Trigger: TriggerProps\n Positioner: PositionerProps\n Popup: PopupProps\n Arrow: ArrowProps\n}>(\"Tooltip\", createTooltip, \"button\")\n"],"mappings":";;;AAqBA,MAAa,UAA0B,2BAKpC,WAAW,eAAe,QAAQ"}
@@ -0,0 +1,38 @@
1
+ import { RenderProp } from "./runtime.js";
2
+ import { ReactElement, Ref } from "react";
3
+ /** What `useRender` takes. */
4
+ export interface UseRenderOptions<State extends Record<string, unknown>> {
5
+ /**
6
+ * What its caller asked the element to be drawn as: an element, whose own props lie over
7
+ * `props`, or a function given the props and the state.
8
+ */
9
+ render?: RenderProp<State> | undefined;
10
+ /** The element drawn when there is no `render`: a `div` unless said. */
11
+ defaultTagName?: string | undefined;
12
+ /** The element's props: the component's own and its caller's, already merged (`mergeProps`). */
13
+ props?: Record<string, unknown> | undefined;
14
+ /**
15
+ * The component's state. A function `render` is given it, and it is written on the element
16
+ * as `data-*` attributes, under `props`: `true` is present and empty, `false`, `null` and
17
+ * `undefined` are absent, anything else is its text, and `isActive` is `data-is-active`.
18
+ */
19
+ state?: State | undefined;
20
+ /** A ref of the component's own, given the element beside `props.ref` and the `render` element's. */
21
+ ref?: Ref<HTMLElement> | undefined;
22
+ }
23
+ /**
24
+ * Gives a plain element of one's own (a badge, a breadcrumb's link) the `render` prop a part
25
+ * takes, by a part's rule: `props` lie under the `render` element's own props, classes join,
26
+ * styles are merged property by property, both handlers of an event run (`props`' first), the
27
+ * `render` element's own children are drawn when it has any, and every ref gets the element.
28
+ */
29
+ export declare function useRender<State extends Record<string, unknown> = Record<string, never>>({ render, defaultTagName, props, state, ref }: UseRenderOptions<State>): ReactElement;
30
+ /**
31
+ * Several sets of props as one, for a component's own props and its caller's: a later set
32
+ * wins an attribute it gives (one it leaves `undefined` stays), classes join, styles are
33
+ * merged property by property, and the handlers of an event run in order, until one calls
34
+ * `event.preventKiranaHandler()`, which stops those after it.
35
+ */
36
+ export declare function mergeProps(...props: readonly (Record<string, unknown> | undefined)[]): Record<string, unknown>;
37
+ export type { RenderProp };
38
+ //# sourceMappingURL=use-render.d.ts.map