@kirana-ui/react 0.1.1 → 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 (161) hide show
  1. package/llms.txt +1601 -223
  2. package/package.json +14 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +142 -0
  4. package/src/accordion.d.ts +26 -15
  5. package/src/accordion.js +11 -10
  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 -2
  11. package/src/autosize.d.ts +5 -2
  12. package/src/autosize.js +2 -2
  13. package/src/autosize.js.map +1 -1
  14. package/src/avatar.d.ts +12 -8
  15. package/src/avatar.js +18 -9
  16. package/src/avatar.js.map +1 -1
  17. package/src/button.d.ts +4 -2
  18. package/src/button.js +3 -3
  19. package/src/button.js.map +1 -1
  20. package/src/calendar.d.ts +49 -28
  21. package/src/calendar.js +7 -3
  22. package/src/calendar.js.map +1 -1
  23. package/src/carousel.d.ts +25 -15
  24. package/src/carousel.js +3 -3
  25. package/src/carousel.js.map +1 -1
  26. package/src/checkbox.d.ts +10 -7
  27. package/src/checkbox.js +18 -12
  28. package/src/checkbox.js.map +1 -1
  29. package/src/collapsible.d.ts +12 -8
  30. package/src/collapsible.js +8 -7
  31. package/src/collapsible.js.map +1 -1
  32. package/src/combobox.d.ts +88 -60
  33. package/src/combobox.js +44 -31
  34. package/src/combobox.js.map +1 -1
  35. package/src/command.d.ts +30 -21
  36. package/src/command.js +14 -7
  37. package/src/command.js.map +1 -1
  38. package/src/context-menu.d.ts +3 -2
  39. package/src/date-field.d.ts +25 -13
  40. package/src/date-field.js +7 -3
  41. package/src/date-field.js.map +1 -1
  42. package/src/date-picker.d.ts +31 -40
  43. package/src/date-picker.js +3 -3
  44. package/src/date-picker.js.map +1 -1
  45. package/src/dialog.d.ts +45 -35
  46. package/src/dialog.js +12 -8
  47. package/src/dialog.js.map +1 -1
  48. package/src/direction.d.ts +1 -0
  49. package/src/direction.js.map +1 -1
  50. package/src/drawer.d.ts +3 -2
  51. package/src/element.d.ts +12 -0
  52. package/src/element.js +20 -0
  53. package/src/element.js.map +1 -0
  54. package/src/field.d.ts +24 -16
  55. package/src/field.js +9 -7
  56. package/src/field.js.map +1 -1
  57. package/src/fieldset.d.ts +10 -5
  58. package/src/fieldset.js +4 -5
  59. package/src/fieldset.js.map +1 -1
  60. package/src/form.d.ts +5 -2
  61. package/src/form.js +6 -6
  62. package/src/form.js.map +1 -1
  63. package/src/hover-card.d.ts +16 -10
  64. package/src/hover-card.js +1 -1
  65. package/src/hover-card.js.map +1 -1
  66. package/src/hover-popup.d.ts +24 -14
  67. package/src/hover-popup.js +5 -13
  68. package/src/hover-popup.js.map +1 -1
  69. package/src/index.d.ts +13 -3
  70. package/src/input.d.ts +4 -2
  71. package/src/input.js +3 -3
  72. package/src/input.js.map +1 -1
  73. package/src/label.d.ts +4 -1
  74. package/src/label.js +3 -3
  75. package/src/label.js.map +1 -1
  76. package/src/listbox.d.ts +23 -15
  77. package/src/listbox.js +4 -5
  78. package/src/listbox.js.map +1 -1
  79. package/src/menu.d.ts +83 -65
  80. package/src/menu.js +10 -18
  81. package/src/menu.js.map +1 -1
  82. package/src/menubar.d.ts +5 -3
  83. package/src/menubar.js +3 -3
  84. package/src/menubar.js.map +1 -1
  85. package/src/message-scroller.d.ts +15 -9
  86. package/src/message-scroller.js +3 -3
  87. package/src/message-scroller.js.map +1 -1
  88. package/src/meter.d.ts +18 -9
  89. package/src/meter.js +1 -1
  90. package/src/meter.js.map +1 -1
  91. package/src/navigation-menu.d.ts +50 -40
  92. package/src/navigation-menu.js +15 -24
  93. package/src/navigation-menu.js.map +1 -1
  94. package/src/number-field.d.ts +19 -12
  95. package/src/number-field.js +6 -10
  96. package/src/number-field.js.map +1 -1
  97. package/src/otp.d.ts +24 -15
  98. package/src/otp.js +7 -13
  99. package/src/otp.js.map +1 -1
  100. package/src/pagination.d.ts +26 -16
  101. package/src/pagination.js +3 -3
  102. package/src/pagination.js.map +1 -1
  103. package/src/popover.d.ts +30 -21
  104. package/src/popover.js +9 -13
  105. package/src/popover.js.map +1 -1
  106. package/src/progress.d.ts +18 -9
  107. package/src/progress.js +1 -1
  108. package/src/progress.js.map +1 -1
  109. package/src/qr-code.d.ts +12 -7
  110. package/src/qr-code.js +3 -3
  111. package/src/qr-code.js.map +1 -1
  112. package/src/radio-group.d.ts +17 -11
  113. package/src/radio-group.js +16 -19
  114. package/src/radio-group.js.map +1 -1
  115. package/src/resizable.d.ts +13 -8
  116. package/src/resizable.js +3 -3
  117. package/src/resizable.js.map +1 -1
  118. package/src/runtime.d.ts +89 -15
  119. package/src/runtime.js +112 -19
  120. package/src/runtime.js.map +1 -1
  121. package/src/scroll-area.d.ts +26 -15
  122. package/src/scroll-area.js +9 -6
  123. package/src/scroll-area.js.map +1 -1
  124. package/src/select.d.ts +65 -45
  125. package/src/select.js +40 -35
  126. package/src/select.js.map +1 -1
  127. package/src/separator.d.ts +4 -2
  128. package/src/separator.js +3 -3
  129. package/src/separator.js.map +1 -1
  130. package/src/slider.d.ts +35 -20
  131. package/src/slider.js +17 -18
  132. package/src/slider.js.map +1 -1
  133. package/src/switch.d.ts +10 -6
  134. package/src/switch.js +11 -9
  135. package/src/switch.js.map +1 -1
  136. package/src/tabs.d.ts +22 -14
  137. package/src/tabs.js +5 -6
  138. package/src/tabs.js.map +1 -1
  139. package/src/testing.d.ts +1 -0
  140. package/src/testing.js +1 -0
  141. package/src/toast.d.ts +59 -23
  142. package/src/toast.js +59 -13
  143. package/src/toast.js.map +1 -1
  144. package/src/toggle-group.d.ts +5 -2
  145. package/src/toggle-group.js +3 -3
  146. package/src/toggle-group.js.map +1 -1
  147. package/src/toggle.d.ts +4 -2
  148. package/src/toggle.js +3 -3
  149. package/src/toggle.js.map +1 -1
  150. package/src/toolbar.d.ts +26 -11
  151. package/src/toolbar.js +23 -13
  152. package/src/toolbar.js.map +1 -1
  153. package/src/tooltip.d.ts +16 -10
  154. package/src/tooltip.js +1 -1
  155. package/src/tooltip.js.map +1 -1
  156. package/src/use-render.d.ts +38 -0
  157. package/src/use-render.js +50 -0
  158. package/src/use-render.js.map +1 -0
  159. package/src/value-bar.d.ts +19 -11
  160. package/src/value-bar.js +8 -5
  161. package/src/value-bar.js.map +1 -1
package/src/menu.d.ts CHANGED
@@ -1,89 +1,107 @@
1
- import { PartComponentProps } from "./runtime.js";
2
- import { PositionOptions } from "@kirana-ui/core";
1
+ import { PartComponentProps, PortalProps, PositionerOptions } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
3
3
  import { ReactElement, ReactNode } from "react";
4
4
  import { MenuCheckboxItemProps, MenuItemOptions, MenuProps, MenuRadioGroupProps } from "@kirana-ui/core/menu";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["menu"];
5
7
  export type RootProps = Omit<MenuProps, "id"> & {
6
8
  id?: string;
7
9
  children?: ReactNode;
8
10
  };
11
+ export type SubmenuRootProps = RootProps;
9
12
  declare function Root({ children, ...props }: RootProps): ReactElement;
10
13
  /** A menu for an area of the page, opened at the pointer. Its trigger is the area. */
11
14
  declare function ContextRoot({ children, ...props }: RootProps): ReactElement;
15
+ export type ContextTriggerProps = PartComponentProps<"div", StateOf<Vocabulary["contextMenu"]["trigger"]>>;
12
16
  /** The area a secondary press, or a long press on a touch screen, opens the menu in. */
13
- declare const ContextTrigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
17
+ declare const ContextTrigger: (props: ContextTriggerProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
14
18
  /** A menu that one of this menu's items opens. Its trigger is `<Menu.SubmenuTrigger>`. */
15
- declare function SubmenuRoot({ children, ...props }: RootProps): ReactElement;
16
- declare function Portal({ children }: {
17
- children?: ReactNode;
18
- }): ReactElement | null;
19
- export type PositionerProps = PartComponentProps & Partial<PositionOptions>;
20
- declare function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
21
- declare const Trigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
22
- declare const SubmenuTrigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
23
- declare const Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
24
- declare const Arrow: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
25
- declare const Separator: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
26
- export type ItemProps = PartComponentProps & MenuItemOptions;
19
+ declare function SubmenuRoot({ children, ...props }: SubmenuRootProps): ReactElement;
20
+ declare function Portal({ children }: PortalProps): ReactElement | null;
21
+ export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
22
+ declare function Positioner(props: PositionerProps): ReactElement;
23
+ export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>>;
24
+ export type SubmenuTriggerProps = PartComponentProps<"div", StateOf<Parts["submenuTrigger"]>>;
25
+ export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
26
+ export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
27
+ export type SeparatorProps = PartComponentProps<"div", StateOf<Parts["separator"]>>;
28
+ declare const Trigger: (props: TriggerProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
29
+ declare const SubmenuTrigger: (props: SubmenuTriggerProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
30
+ declare const Popup: (props: PopupProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
31
+ declare const Arrow: (props: ArrowProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
32
+ declare const Separator: (props: SeparatorProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
33
+ export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, MenuItemOptions>;
27
34
  declare function Item({ disabled, label, closeOnClick, ...props }: ItemProps): ReactElement;
35
+ export type LinkItemProps = PartComponentProps<"a", StateOf<Parts["linkItem"]>, MenuItemOptions>;
28
36
  /** An item that is a link: `href` and the rest go to its `<a>`. */
29
- declare function LinkItem({ disabled, label, closeOnClick, ...props }: ItemProps): ReactElement;
30
- declare function Group({ id, ...props }: PartComponentProps & {
37
+ declare function LinkItem({ disabled, label, closeOnClick, ...props }: LinkItemProps): ReactElement;
38
+ export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, {
31
39
  id?: string;
32
- }): ReactElement;
40
+ }>;
41
+ declare function Group({ id, ...props }: GroupProps): ReactElement;
42
+ export type GroupLabelProps = PartComponentProps<"div", StateOf<Parts["groupLabel"]>>;
33
43
  /** Names the group it is in. With no group around it, it is plain text. */
34
- declare function GroupLabel(props: PartComponentProps): ReactElement;
35
- export type CheckboxItemProps = PartComponentProps & MenuCheckboxItemProps;
44
+ declare function GroupLabel(props: GroupLabelProps): ReactElement;
45
+ export type CheckboxItemProps = PartComponentProps<"div", StateOf<Parts["checkboxItem"]>, MenuCheckboxItemProps>;
36
46
  declare function CheckboxItem({ checked, defaultChecked, onCheckedChange, disabled, label, closeOnClick, ...props }: CheckboxItemProps): ReactElement;
37
- export interface IndicatorProps extends PartComponentProps {
47
+ /** What an item's mark takes of its own. */
48
+ export interface IndicatorOptions {
49
+ /** Keeps the mark in the page while its item is not checked. */
38
50
  keepMounted?: boolean;
39
51
  }
40
- declare function CheckboxItemIndicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null;
41
- export type RadioGroupProps = PartComponentProps & MenuRadioGroupProps;
42
- declare function RadioGroup({ value, defaultValue, onValueChange, disabled, ...props }: RadioGroupProps): ReactElement;
43
- export type RadioItemProps = PartComponentProps & MenuItemOptions & {
52
+ export type CheckboxItemIndicatorProps = PartComponentProps<"span", StateOf<Parts["checkboxItemIndicator"]>, IndicatorOptions>;
53
+ export type RadioItemIndicatorProps = PartComponentProps<"span", StateOf<Parts["radioItemIndicator"]>, IndicatorOptions>;
54
+ /** @deprecated The mark's own: `CheckboxItemIndicatorProps` or `RadioItemIndicatorProps`. */
55
+ export type IndicatorProps = CheckboxItemIndicatorProps;
56
+ declare function CheckboxItemIndicator({ keepMounted, ...props }: CheckboxItemIndicatorProps): ReactElement | null;
57
+ /** `Value` is what tells a radio item from the others: the type of `value`. */
58
+ export type RadioGroupProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["radioGroup"]>, MenuRadioGroupProps<Value>>;
59
+ declare function RadioGroup<Value = unknown>({ value, defaultValue, onValueChange, disabled, ...props }: RadioGroupProps<Value>): ReactElement;
60
+ export type RadioItemProps = PartComponentProps<"div", StateOf<Parts["radioItem"]>, MenuItemOptions & {
61
+ /** What the radio group's value is while this item is the chosen one. */
44
62
  value: unknown;
45
- };
46
- declare function RadioItem({ value, disabled, label, closeOnClick, ...props }: RadioItemProps): import("react").JSX.Element;
47
- declare function RadioItemIndicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null;
63
+ }>;
64
+ declare function RadioItem({ value, disabled, label, closeOnClick, ...props }: RadioItemProps): ReactElement;
65
+ declare function RadioItemIndicator({ keepMounted, ...props }: RadioItemIndicatorProps): ReactElement | null;
48
66
  export declare const Menu: {
49
- Root: typeof Root;
50
- Trigger: typeof Trigger;
51
- Portal: typeof Portal;
52
- Positioner: typeof Positioner;
53
- Popup: typeof Popup;
54
- Arrow: typeof Arrow;
55
- Item: typeof Item;
56
- LinkItem: typeof LinkItem;
57
- Group: typeof Group;
58
- GroupLabel: typeof GroupLabel;
59
- Separator: typeof Separator;
60
- CheckboxItem: typeof CheckboxItem;
61
- CheckboxItemIndicator: typeof CheckboxItemIndicator;
62
- RadioGroup: typeof RadioGroup;
63
- RadioItem: typeof RadioItem;
64
- RadioItemIndicator: typeof RadioItemIndicator;
65
- SubmenuRoot: typeof SubmenuRoot;
66
- SubmenuTrigger: typeof SubmenuTrigger;
67
+ readonly Root: typeof Root;
68
+ readonly Trigger: typeof Trigger;
69
+ readonly Portal: typeof Portal;
70
+ readonly Positioner: typeof Positioner;
71
+ readonly Popup: typeof Popup;
72
+ readonly Arrow: typeof Arrow;
73
+ readonly Item: typeof Item;
74
+ readonly LinkItem: typeof LinkItem;
75
+ readonly Group: typeof Group;
76
+ readonly GroupLabel: typeof GroupLabel;
77
+ readonly Separator: typeof Separator;
78
+ readonly CheckboxItem: typeof CheckboxItem;
79
+ readonly CheckboxItemIndicator: typeof CheckboxItemIndicator;
80
+ readonly RadioGroup: typeof RadioGroup;
81
+ readonly RadioItem: typeof RadioItem;
82
+ readonly RadioItemIndicator: typeof RadioItemIndicator;
83
+ readonly SubmenuRoot: typeof SubmenuRoot;
84
+ readonly SubmenuTrigger: typeof SubmenuTrigger;
67
85
  };
68
86
  export declare const ContextMenu: {
69
- Portal: typeof Portal;
70
- Positioner: typeof Positioner;
71
- Popup: typeof Popup;
72
- Arrow: typeof Arrow;
73
- Item: typeof Item;
74
- LinkItem: typeof LinkItem;
75
- Group: typeof Group;
76
- GroupLabel: typeof GroupLabel;
77
- Separator: typeof Separator;
78
- CheckboxItem: typeof CheckboxItem;
79
- CheckboxItemIndicator: typeof CheckboxItemIndicator;
80
- RadioGroup: typeof RadioGroup;
81
- RadioItem: typeof RadioItem;
82
- RadioItemIndicator: typeof RadioItemIndicator;
83
- SubmenuRoot: typeof SubmenuRoot;
84
- SubmenuTrigger: typeof SubmenuTrigger;
85
- Root: typeof ContextRoot;
86
- Trigger: typeof ContextTrigger;
87
+ readonly Portal: typeof Portal;
88
+ readonly Positioner: typeof Positioner;
89
+ readonly Popup: typeof Popup;
90
+ readonly Arrow: typeof Arrow;
91
+ readonly Item: typeof Item;
92
+ readonly LinkItem: typeof LinkItem;
93
+ readonly Group: typeof Group;
94
+ readonly GroupLabel: typeof GroupLabel;
95
+ readonly Separator: typeof Separator;
96
+ readonly CheckboxItem: typeof CheckboxItem;
97
+ readonly CheckboxItemIndicator: typeof CheckboxItemIndicator;
98
+ readonly RadioGroup: typeof RadioGroup;
99
+ readonly RadioItem: typeof RadioItem;
100
+ readonly RadioItemIndicator: typeof RadioItemIndicator;
101
+ readonly SubmenuRoot: typeof SubmenuRoot;
102
+ readonly SubmenuTrigger: typeof SubmenuTrigger;
103
+ readonly Root: typeof ContextRoot;
104
+ readonly Trigger: typeof ContextTrigger;
87
105
  };
88
- export {};
106
+ export type { PortalProps };
89
107
  //# sourceMappingURL=menu.d.ts.map
package/src/menu.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { MenubarContext } from "./menubar-context.js";
3
- import { Portal as Portal$1, useController, useOptions, usePart, useSignal } from "./runtime.js";
3
+ import { PartElement, Portal as Portal$1, parts, useController, useOptions, usePart, usePositioning, useSignal } from "./runtime.js";
4
4
  import { defined, within } from "@kirana-ui/core";
5
5
  import { createContext, useContext, useId, useMemo } from "react";
6
6
  import { jsx } from "react/jsx-runtime";
@@ -63,18 +63,10 @@ function SubmenuRoot({ children, ...props }) {
63
63
  function Portal({ children }) {
64
64
  return useSignal(useMenu("Portal").mounted) ? /* @__PURE__ */ jsx(Portal$1, { children }) : null;
65
65
  }
66
- function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }) {
66
+ function Positioner(props) {
67
67
  const controller = useMenu("Positioner");
68
- controller.positioning.set(defined({
69
- side,
70
- align,
71
- sideOffset,
72
- alignOffset,
73
- collisionPadding
74
- }));
75
- return usePart(controller.positioner, "div", props);
76
- }
77
- const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
68
+ return usePart(controller.positioner, "div", usePositioning(controller.positioning, props));
69
+ }
78
70
  const Trigger = (props) => usePart(useMenu("Trigger").trigger, "button", props);
79
71
  const SubmenuTrigger = (props) => usePart(useMenu("SubmenuTrigger").trigger, "div", props);
80
72
  const Popup = (props) => usePart(useMenu("Popup").popup, "div", props);
@@ -138,7 +130,7 @@ function CheckboxItem({ checked, defaultChecked, onCheckedChange, disabled, labe
138
130
  function CheckboxItemIndicator({ keepMounted, ...props }) {
139
131
  const item = inside(CheckboxContext, "CheckboxItemIndicator", "CheckboxItem");
140
132
  return useSignal(item.checked) || keepMounted ? /* @__PURE__ */ jsx(PartElement, {
141
- part: item.indicator,
133
+ of: item.indicator,
142
134
  tag: "span",
143
135
  ...props
144
136
  }) : null;
@@ -179,12 +171,12 @@ function RadioItemIndicator({ keepMounted, ...props }) {
179
171
  const checked = useSignal(group.checked(value));
180
172
  const part = useMemo(() => group.indicator(value), [group, value]);
181
173
  return checked || keepMounted ? /* @__PURE__ */ jsx(PartElement, {
182
- part,
174
+ of: part,
183
175
  tag: "span",
184
176
  ...props
185
177
  }) : null;
186
178
  }
187
- const Menu = {
179
+ const Menu = /* @__PURE__ */ parts("Menu", {
188
180
  Root,
189
181
  Trigger,
190
182
  Portal,
@@ -203,12 +195,12 @@ const Menu = {
203
195
  RadioItemIndicator,
204
196
  SubmenuRoot,
205
197
  SubmenuTrigger
206
- };
207
- const ContextMenu = {
198
+ });
199
+ const ContextMenu = /* @__PURE__ */ parts("ContextMenu", {
208
200
  ...Menu,
209
201
  Root: ContextRoot,
210
202
  Trigger: ContextTrigger
211
- };
203
+ });
212
204
  export { ContextMenu, Menu };
213
205
 
214
206
  //# sourceMappingURL=menu.js.map
package/src/menu.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/menu.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { Part, PositionOptions } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu as Controller,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuItemOptions,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { MenubarContext } from \"./menubar-context.ts\"\nimport { Portal as BodyPortal, useController, useOptions, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\nconst GroupContext = createContext<MenuGroup | null>(null)\nconst CheckboxContext = createContext<MenuCheckboxItem | null>(null)\nconst RadioGroupContext = createContext<MenuRadioGroup | null>(null)\nconst RadioItemContext = createContext<unknown>(undefined)\n\nfunction useMenu(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Menu.${part}> must be inside <Menu.Root>`)\n return controller\n}\n\nfunction inside<T>(context: React.Context<T | null>, part: string, parent: string): T {\n const found = useContext(context)\n if (!found) throw new Error(`<Menu.${part}> must be inside <Menu.${parent}>`)\n return found\n}\n\nexport type RootProps = Omit<MenuProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction provided(controller: Controller, children: ReactNode): ReactElement {\n return (\n <Context.Provider value={controller}>\n {/* A group around a submenu is not a group of the submenu's own items; nor is a menu\n written inside a bar's menu one of the bar's. */}\n <MenubarContext.Provider value={null}>\n <GroupContext.Provider value={null}>{children}</GroupContext.Provider>\n </MenubarContext.Provider>\n </Context.Provider>\n )\n}\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const menubar = useContext(MenubarContext) ?? undefined\n return provided(useController(within(createMenu, { direction, menubar }), props), children)\n}\n\n/** A menu for an area of the page, opened at the pointer. Its trigger is the area. */\nfunction ContextRoot({ children, ...props }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n return provided(useController(within(createMenu, { direction, context: true }), props), children)\n}\n\n/** The area a secondary press, or a long press on a touch screen, opens the menu in. */\nconst ContextTrigger = (props: PartComponentProps) => usePart(useMenu(\"Trigger\").area, \"div\", props)\n\n/** A menu that one of this menu's items opens. Its trigger is `<Menu.SubmenuTrigger>`. */\nfunction SubmenuRoot({ children, ...props }: RootProps): ReactElement {\n const parent = useMenu(\"SubmenuRoot\")\n const direction = useContext(DirectionContext) ?? undefined\n return provided(useController(within(createMenu, { parent, direction }), props), children)\n}\n\nfunction Portal({ children }: { children?: ReactNode }): ReactElement | null {\n const mounted = useSignal(useMenu(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type PositionerProps = PartComponentProps & Partial<PositionOptions>\n\nfunction Positioner({\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n ...props\n}: PositionerProps) {\n const controller = useMenu(\"Positioner\")\n controller.positioning.set(defined({ side, align, sideOffset, alignOffset, collisionPadding }))\n return usePart(controller.positioner, \"div\", props)\n}\n\nconst PartElement = ({ part, tag, ...props }: PartComponentProps & { part: Part; tag: string }) =>\n usePart(part, tag, props)\n\nconst Trigger = (props: PartComponentProps) => usePart(useMenu(\"Trigger\").trigger, \"button\", props)\nconst SubmenuTrigger = (props: PartComponentProps) =>\n usePart(useMenu(\"SubmenuTrigger\").trigger, \"div\", props)\nconst Popup = (props: PartComponentProps) => usePart(useMenu(\"Popup\").popup, \"div\", props)\nconst Arrow = (props: PartComponentProps) => usePart(useMenu(\"Arrow\").arrow, \"div\", props)\nconst Separator = (props: PartComponentProps) =>\n usePart(useMenu(\"Separator\").separator, \"div\", props)\n\nexport type ItemProps = PartComponentProps & MenuItemOptions\n\nfunction Item({ disabled, label, closeOnClick, ...props }: ItemProps): ReactElement {\n const controller = useMenu(\"Item\")\n const options = useOptions({ disabled, label, closeOnClick })\n const part = useMemo(() => controller.item(() => defined(options.get())), [controller, options])\n return usePart(part, \"div\", props)\n}\n\n/** An item that is a link: `href` and the rest go to its `<a>`. */\nfunction LinkItem({ disabled, label, closeOnClick, ...props }: ItemProps): ReactElement {\n const controller = useMenu(\"LinkItem\")\n const options = useOptions({ disabled, label, closeOnClick })\n const part = useMemo(() => controller.item(() => defined(options.get())), [controller, options])\n return usePart(part, \"a\", props)\n}\n\nfunction Group({ id, ...props }: PartComponentProps & { id?: string }): ReactElement {\n const controller = useMenu(\"Group\")\n const generated = useId()\n const group = useMemo(() => controller.group(id ?? generated), [controller, id, generated])\n return (\n <GroupContext.Provider value={group}>{usePart(group.root, \"div\", props)}</GroupContext.Provider>\n )\n}\n\n/** Names the group it is in. With no group around it, it is plain text. */\nfunction GroupLabel(props: PartComponentProps): ReactElement {\n const controller = useMenu(\"GroupLabel\")\n const group = useContext(GroupContext)\n return usePart(group ? group.label : controller.label, \"div\", props)\n}\n\nexport type CheckboxItemProps = PartComponentProps & MenuCheckboxItemProps\n\nfunction CheckboxItem({\n checked,\n defaultChecked,\n onCheckedChange,\n disabled,\n label,\n closeOnClick,\n ...props\n}: CheckboxItemProps): ReactElement {\n const controller = useMenu(\"CheckboxItem\")\n const item = useController(controller.checkboxItem, {\n checked,\n defaultChecked,\n onCheckedChange,\n disabled,\n label,\n closeOnClick,\n })\n return (\n <CheckboxContext.Provider value={item}>\n {usePart(item.part, \"div\", props)}\n </CheckboxContext.Provider>\n )\n}\n\nexport interface IndicatorProps extends PartComponentProps {\n keepMounted?: boolean\n}\n\nfunction CheckboxItemIndicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const item = inside(CheckboxContext, \"CheckboxItemIndicator\", \"CheckboxItem\")\n const checked = useSignal(item.checked)\n return checked || keepMounted ? <PartElement part={item.indicator} tag=\"span\" {...props} /> : null\n}\n\nexport type RadioGroupProps = PartComponentProps & MenuRadioGroupProps\n\nfunction RadioGroup({\n value,\n defaultValue,\n onValueChange,\n disabled,\n ...props\n}: RadioGroupProps): ReactElement {\n const controller = useMenu(\"RadioGroup\")\n const group = useController<MenuRadioGroupProps, MenuRadioGroup>(controller.radioGroup, {\n value,\n defaultValue,\n onValueChange,\n disabled,\n })\n return (\n <RadioGroupContext.Provider value={group}>\n {usePart(group.root, \"div\", props)}\n </RadioGroupContext.Provider>\n )\n}\n\nexport type RadioItemProps = PartComponentProps & MenuItemOptions & { value: unknown }\n\nfunction RadioItem({ value, disabled, label, closeOnClick, ...props }: RadioItemProps) {\n const group = inside(RadioGroupContext, \"RadioItem\", \"RadioGroup\")\n const options = useOptions({ disabled, label, closeOnClick })\n const part = useMemo(\n () => group.item(value, () => defined(options.get())),\n [group, value, options]\n )\n return (\n <RadioItemContext.Provider value={value}>\n {usePart(part, \"div\", props)}\n </RadioItemContext.Provider>\n )\n}\n\nfunction RadioItemIndicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const group = inside(RadioGroupContext, \"RadioItemIndicator\", \"RadioGroup\")\n const value = useContext(RadioItemContext)\n const checked = useSignal(group.checked(value))\n const part = useMemo(() => group.indicator(value), [group, value])\n return checked || keepMounted ? <PartElement part={part} tag=\"span\" {...props} /> : null\n}\n\nexport const Menu = {\n Root,\n Trigger,\n Portal,\n Positioner,\n Popup,\n Arrow,\n Item,\n LinkItem,\n Group,\n GroupLabel,\n Separator,\n CheckboxItem,\n CheckboxItemIndicator,\n RadioGroup,\n RadioItem,\n RadioItemIndicator,\n SubmenuRoot,\n SubmenuTrigger,\n}\n\nexport const ContextMenu = { ...Menu, Root: ContextRoot, Trigger: ContextTrigger }\n"],"mappings":";;;;;;;;AAqBA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,eAAe,cAAgC,IAAI;AACzD,MAAM,kBAAkB,cAAuC,IAAI;AACnE,MAAM,oBAAoB,cAAqC,IAAI;AACnE,MAAM,mBAAmB,cAAuB,KAAA,CAAS;AAEzD,SAAS,QAAQ,MAA0B;CACzC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,SAAS,KAAK,6BAA6B;CAC5E,OAAO;AACT;AAEA,SAAS,OAAU,SAAkC,MAAc,QAAmB;CACpF,MAAM,QAAQ,WAAW,OAAO;CAChC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,SAAS,KAAK,yBAAyB,OAAO,EAAE;CAC5E,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AAa,CAAC;CAC5D,MAAM,OAAO,cACL,MAAM,KAAK,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACpD;EAAC;EAAO;EAAO;CAAO,CACxB;CACA,OACE,oBAAC,iBAAiB,UAAlB;EAAkC;EAC/B,UAAA,QAAQ,MAAM,OAAO,KAAK;CACF,CAAA;AAE/B;AAEA,SAAS,mBAAmB,EAAE,aAAa,GAAG,SAA8C;CAC1F,MAAM,QAAQ,OAAO,mBAAmB,sBAAsB,YAAY;CAC1E,MAAM,QAAQ,WAAW,gBAAgB;CACzC,MAAM,UAAU,UAAU,MAAM,QAAQ,KAAK,CAAC;CAC9C,MAAM,OAAO,cAAc,MAAM,UAAU,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;CACjE,OAAO,WAAW,cAAc,oBAAC,aAAD;EAAmB;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA,IAAI;AACtF;AAEA,MAAa,OAAO;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,cAAc;CAAE,GAAG;CAAM,MAAM;CAAa,SAAS;AAAe"}
1
+ {"version":3,"file":"menu.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/menu.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu as Controller,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuItemOptions,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { MenubarContext } from \"./menubar-context.ts\"\nimport {\n Portal as BodyPortal,\n PartElement,\n parts,\n useController,\n useOptions,\n usePart,\n usePositioning,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps, PortalProps, PositionerOptions } from \"./runtime.tsx\"\n\nexport type { PortalProps }\n\ntype Parts = Vocabulary[\"menu\"]\n\nconst Context = createContext<Controller | null>(null)\nconst GroupContext = createContext<MenuGroup | null>(null)\nconst CheckboxContext = createContext<MenuCheckboxItem | null>(null)\nconst RadioGroupContext = createContext<MenuRadioGroup | null>(null)\nconst RadioItemContext = createContext<unknown>(undefined)\n\nfunction useMenu(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Menu.${part}> must be inside <Menu.Root>`)\n return controller\n}\n\nfunction inside<T>(context: React.Context<T | null>, part: string, parent: string): T {\n const found = useContext(context)\n if (!found) throw new Error(`<Menu.${part}> must be inside <Menu.${parent}>`)\n return found\n}\n\nexport type RootProps = Omit<MenuProps, \"id\"> & { id?: string; children?: ReactNode }\nexport type SubmenuRootProps = RootProps\n\nfunction provided(controller: Controller, children: ReactNode): ReactElement {\n return (\n <Context.Provider value={controller}>\n {/* A group around a submenu is not a group of the submenu's own items; nor is a menu\n written inside a bar's menu one of the bar's. */}\n <MenubarContext.Provider value={null}>\n <GroupContext.Provider value={null}>{children}</GroupContext.Provider>\n </MenubarContext.Provider>\n </Context.Provider>\n )\n}\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const menubar = useContext(MenubarContext) ?? undefined\n return provided(useController(within(createMenu, { direction, menubar }), props), children)\n}\n\n/** A menu for an area of the page, opened at the pointer. Its trigger is the area. */\nfunction ContextRoot({ children, ...props }: RootProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n return provided(useController(within(createMenu, { direction, context: true }), props), children)\n}\n\nexport type ContextTriggerProps = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"contextMenu\"][\"trigger\"]>\n>\n\n/** The area a secondary press, or a long press on a touch screen, opens the menu in. */\nconst ContextTrigger = (props: ContextTriggerProps) =>\n usePart(useMenu(\"Trigger\").area, \"div\", props)\n\n/** A menu that one of this menu's items opens. Its trigger is `<Menu.SubmenuTrigger>`. */\nfunction SubmenuRoot({ children, ...props }: SubmenuRootProps): ReactElement {\n const parent = useMenu(\"SubmenuRoot\")\n const direction = useContext(DirectionContext) ?? undefined\n return provided(useController(within(createMenu, { parent, direction }), props), children)\n}\n\nfunction Portal({ children }: PortalProps): ReactElement | null {\n const mounted = useSignal(useMenu(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type PositionerProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"positioner\"]>,\n PositionerOptions\n>\n\nfunction Positioner(props: PositionerProps): ReactElement {\n const controller = useMenu(\"Positioner\")\n return usePart(controller.positioner, \"div\", usePositioning(controller.positioning, props))\n}\n\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\nexport type SubmenuTriggerProps = PartComponentProps<\"div\", StateOf<Parts[\"submenuTrigger\"]>>\nexport type PopupProps = PartComponentProps<\"div\", StateOf<Parts[\"popup\"]>>\nexport type ArrowProps = PartComponentProps<\"div\", StateOf<Parts[\"arrow\"]>>\nexport type SeparatorProps = PartComponentProps<\"div\", StateOf<Parts[\"separator\"]>>\n\nconst Trigger = (props: TriggerProps) => usePart(useMenu(\"Trigger\").trigger, \"button\", props)\nconst SubmenuTrigger = (props: SubmenuTriggerProps) =>\n usePart(useMenu(\"SubmenuTrigger\").trigger, \"div\", props)\nconst Popup = (props: PopupProps) => usePart(useMenu(\"Popup\").popup, \"div\", props)\nconst Arrow = (props: ArrowProps) => usePart(useMenu(\"Arrow\").arrow, \"div\", props)\nconst Separator = (props: SeparatorProps) => usePart(useMenu(\"Separator\").separator, \"div\", props)\n\nexport type ItemProps = PartComponentProps<\"div\", StateOf<Parts[\"item\"]>, MenuItemOptions>\n\nfunction Item({ disabled, label, closeOnClick, ...props }: ItemProps): ReactElement {\n const controller = useMenu(\"Item\")\n const options = useOptions({ disabled, label, closeOnClick })\n const part = useMemo(() => controller.item(() => defined(options.get())), [controller, options])\n return usePart(part, \"div\", props)\n}\n\nexport type LinkItemProps = PartComponentProps<\"a\", StateOf<Parts[\"linkItem\"]>, MenuItemOptions>\n\n/** An item that is a link: `href` and the rest go to its `<a>`. */\nfunction LinkItem({ disabled, label, closeOnClick, ...props }: LinkItemProps): ReactElement {\n const controller = useMenu(\"LinkItem\")\n const options = useOptions({ disabled, label, closeOnClick })\n const part = useMemo(() => controller.item(() => defined(options.get())), [controller, options])\n return usePart(part, \"a\", props)\n}\n\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, { id?: string }>\n\nfunction Group({ id, ...props }: GroupProps): ReactElement {\n const controller = useMenu(\"Group\")\n const generated = useId()\n const group = useMemo(() => controller.group(id ?? generated), [controller, id, generated])\n return (\n <GroupContext.Provider value={group}>{usePart(group.root, \"div\", props)}</GroupContext.Provider>\n )\n}\n\nexport type GroupLabelProps = PartComponentProps<\"div\", StateOf<Parts[\"groupLabel\"]>>\n\n/** Names the group it is in. With no group around it, it is plain text. */\nfunction GroupLabel(props: GroupLabelProps): ReactElement {\n const controller = useMenu(\"GroupLabel\")\n const group = useContext(GroupContext)\n return usePart(group ? group.label : controller.label, \"div\", props)\n}\n\nexport type CheckboxItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"checkboxItem\"]>,\n MenuCheckboxItemProps\n>\n\nfunction CheckboxItem({\n checked,\n defaultChecked,\n onCheckedChange,\n disabled,\n label,\n closeOnClick,\n ...props\n}: CheckboxItemProps): ReactElement {\n const controller = useMenu(\"CheckboxItem\")\n const item = useController(controller.checkboxItem, {\n checked,\n defaultChecked,\n onCheckedChange,\n disabled,\n label,\n closeOnClick,\n })\n return (\n <CheckboxContext.Provider value={item}>\n {usePart(item.part, \"div\", props)}\n </CheckboxContext.Provider>\n )\n}\n\n/** What an item's mark takes of its own. */\nexport interface IndicatorOptions {\n /** Keeps the mark in the page while its item is not checked. */\n keepMounted?: boolean\n}\n\nexport type CheckboxItemIndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"checkboxItemIndicator\"]>,\n IndicatorOptions\n>\nexport type RadioItemIndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"radioItemIndicator\"]>,\n IndicatorOptions\n>\n/** @deprecated The mark's own: `CheckboxItemIndicatorProps` or `RadioItemIndicatorProps`. */\nexport type IndicatorProps = CheckboxItemIndicatorProps\n\nfunction CheckboxItemIndicator({\n keepMounted,\n ...props\n}: CheckboxItemIndicatorProps): ReactElement | null {\n const item = inside(CheckboxContext, \"CheckboxItemIndicator\", \"CheckboxItem\")\n const checked = useSignal(item.checked)\n return checked || keepMounted ? <PartElement of={item.indicator} tag=\"span\" {...props} /> : null\n}\n\n/** `Value` is what tells a radio item from the others: the type of `value`. */\nexport type RadioGroupProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"radioGroup\"]>,\n MenuRadioGroupProps<Value>\n>\n\nfunction RadioGroup<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n disabled,\n ...props\n}: RadioGroupProps<Value>): ReactElement {\n const controller = useMenu(\"RadioGroup\")\n const group: MenuRadioGroup = useController<MenuRadioGroupProps<Value>, MenuRadioGroup<Value>>(\n controller.radioGroup,\n { value, defaultValue, onValueChange, disabled }\n )\n return (\n <RadioGroupContext.Provider value={group}>\n {usePart(group.root, \"div\", props)}\n </RadioGroupContext.Provider>\n )\n}\n\nexport type RadioItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"radioItem\"]>,\n MenuItemOptions & {\n /** What the radio group's value is while this item is the chosen one. */\n value: unknown\n }\n>\n\nfunction RadioItem({\n value,\n disabled,\n label,\n closeOnClick,\n ...props\n}: RadioItemProps): ReactElement {\n const group = inside(RadioGroupContext, \"RadioItem\", \"RadioGroup\")\n const options = useOptions({ disabled, label, closeOnClick })\n const part = useMemo(\n () => group.item(value, () => defined(options.get())),\n [group, value, options]\n )\n return (\n <RadioItemContext.Provider value={value}>\n {usePart(part, \"div\", props)}\n </RadioItemContext.Provider>\n )\n}\n\nfunction RadioItemIndicator({\n keepMounted,\n ...props\n}: RadioItemIndicatorProps): ReactElement | null {\n const group = inside(RadioGroupContext, \"RadioItemIndicator\", \"RadioGroup\")\n const value = useContext(RadioItemContext)\n const checked = useSignal(group.checked(value))\n const part = useMemo(() => group.indicator(value), [group, value])\n return checked || keepMounted ? <PartElement of={part} tag=\"span\" {...props} /> : null\n}\n\nexport const Menu = /* @__PURE__ */ parts(\"Menu\", {\n Root,\n Trigger,\n Portal,\n Positioner,\n Popup,\n Arrow,\n Item,\n LinkItem,\n Group,\n GroupLabel,\n Separator,\n CheckboxItem,\n CheckboxItemIndicator,\n RadioGroup,\n RadioItem,\n RadioItemIndicator,\n SubmenuRoot,\n SubmenuTrigger,\n})\n\nexport const ContextMenu = /* @__PURE__ */ parts(\"ContextMenu\", {\n ...Menu,\n Root: ContextRoot,\n Trigger: ContextTrigger,\n})\n"],"mappings":";;;;;;;;AAmCA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,eAAe,cAAgC,IAAI;AACzD,MAAM,kBAAkB,cAAuC,IAAI;AACnE,MAAM,oBAAoB,cAAqC,IAAI;AACnE,MAAM,mBAAmB,cAAuB,KAAA,CAAS;AAEzD,SAAS,QAAQ,MAA0B;CACzC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,SAAS,KAAK,6BAA6B;CAC5E,OAAO;AACT;AAEA,SAAS,OAAU,SAAkC,MAAc,QAAmB;CACpF,MAAM,QAAQ,WAAW,OAAO;CAChC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,SAAS,KAAK,yBAAyB,OAAO,EAAE;CAC5E,OAAO;AACT;AAKA,SAAS,SAAS,YAAwB,UAAmC;CAC3E,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAGvB,UAAA,oBAAC,e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AM,QAAQ,OAAO,mBAAmB,sBAAsB,YAAY;CAC1E,MAAM,QAAQ,WAAW,gBAAgB;CACzC,MAAM,UAAU,UAAU,MAAM,QAAQ,KAAK,CAAC;CAC9C,MAAM,OAAO,cAAc,MAAM,UAAU,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;CACjE,OAAO,WAAW,cAAc,oBAAC,aAAD;EAAa,IAAI;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA,IAAI;AACpF;AAEA,MAAa,OAAuB,sBAAM,QAAQ;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,cAA8B,sBAAM,eAAe;CAC9D,GAAG;CACH,MAAM;CACN,SAAS;AACX,CAAC"}
package/src/menubar.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
2
3
  import { ReactElement } from "react";
3
4
  import { MenubarProps as MenubarProps$1 } from "@kirana-ui/core/menubar";
4
- export type MenubarProps = Omit<MenubarProps$1, "id"> & {
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ export type MenubarProps = PartComponentProps<"div", StateOf<Vocabulary["menubar"]["root"]>, Omit<MenubarProps$1, "id"> & {
5
7
  id?: string;
6
- } & PartComponentProps;
8
+ }>;
7
9
  /** A row of menus that work as one. Each `<Menu.Root>` inside it is one of its items. */
8
- export declare function Menubar({ loop, disabled, orientation, id, ...rest }: MenubarProps): ReactElement;
10
+ export declare const Menubar: ({ loop, disabled, orientation, id, ...rest }: MenubarProps) => ReactElement;
9
11
  //# sourceMappingURL=menubar.d.ts.map
package/src/menubar.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { DirectionContext } from "./direction-context.js";
2
2
  import { MenubarContext } from "./menubar-context.js";
3
- import { useController, usePart } from "./runtime.js";
3
+ import { component, useController, usePart } from "./runtime.js";
4
4
  import { within } from "@kirana-ui/core";
5
5
  import { useContext } from "react";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { createMenubar } from "@kirana-ui/core/menubar";
8
8
  // src/menubar.tsx
9
9
  /** A row of menus that work as one. Each `<Menu.Root>` inside it is one of its items. */
10
- function Menubar({ loop, disabled, orientation, id, ...rest }) {
10
+ const Menubar = /* @__PURE__ */ component("Menubar", function Menubar({ loop, disabled, orientation, id, ...rest }) {
11
11
  const direction = useContext(DirectionContext) ?? void 0;
12
12
  const controller = useController(within(createMenubar, { direction }), {
13
13
  loop,
@@ -19,7 +19,7 @@ function Menubar({ loop, disabled, orientation, id, ...rest }) {
19
19
  value: controller,
20
20
  children: usePart(controller.root, "div", rest)
21
21
  });
22
- }
22
+ });
23
23
  export { Menubar };
24
24
 
25
25
  //# sourceMappingURL=menubar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"menubar.js","names":[],"sources":["../../../../packages/react/src/menubar.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createMenubar } from \"@kirana-ui/core/menubar\"\nimport type { Menubar as Controller, MenubarProps as CoreProps } from \"@kirana-ui/core/menubar\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { MenubarContext } from \"./menubar-context.ts\"\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type MenubarProps = Omit<CoreProps, \"id\"> & { id?: string } & PartComponentProps\n\n/** A row of menus that work as one. Each `<Menu.Root>` inside it is one of its items. */\nexport function Menubar({ loop, disabled, orientation, id, ...rest }: MenubarProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CoreProps, Controller>(within(createMenubar, { direction }), {\n loop,\n orientation,\n disabled,\n id,\n })\n return (\n <MenubarContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </MenubarContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,QAAQ,EAAE,MAAM,UAAU,aAAa,IAAI,GAAG,QAAoC;CAChG,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cAAqC,OAAO,eAAe,EAAE,UAAU,CAAC,GAAG;EAC5F;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAC7B,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACd,CAAA;AAE7B"}
1
+ {"version":3,"file":"menubar.js","names":[],"sources":["../../../../packages/react/src/menubar.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createMenubar } from \"@kirana-ui/core/menubar\"\nimport type { Menubar as Controller, MenubarProps as CoreProps } from \"@kirana-ui/core/menubar\"\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 { MenubarContext } from \"./menubar-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type MenubarProps = PartComponentProps<\n \"div\",\n StateOf<Vocabulary[\"menubar\"][\"root\"]>,\n Omit<CoreProps, \"id\"> & { id?: string }\n>\n\n/** A row of menus that work as one. Each `<Menu.Root>` inside it is one of its items. */\nexport const Menubar = /* @__PURE__ */ component(\n \"Menubar\",\n function Menubar({ loop, disabled, orientation, id, ...rest }: MenubarProps): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const controller = useController<CoreProps, Controller>(within(createMenubar, { direction }), {\n loop,\n orientation,\n disabled,\n id,\n })\n return (\n <MenubarContext.Provider value={controller}>\n {usePart(controller.root, \"div\", rest)}\n </MenubarContext.Provider>\n )\n }\n)\n"],"mappings":";;;;;;;;;AAoBA,MAAa,UAA0B,0BACrC,WACA,SAAS,QAAQ,EAAE,MAAM,UAAU,aAAa,IAAI,GAAG,QAAoC;CACzF,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,aAAa,cAAqC,OAAO,eAAe,EAAE,UAAU,CAAC,GAAG;EAC5F;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAC7B,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CACd,CAAA;AAE7B,CACF"}
@@ -1,18 +1,24 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
2
3
  import { ReactElement } from "react";
3
4
  import { MessageScrollerProps } from "@kirana-ui/core/message-scroller";
4
- export type RootProps = Omit<MessageScrollerProps, "id"> & {
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["messageScroller"];
7
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<MessageScrollerProps, "id"> & {
5
8
  id?: string;
6
- } & PartComponentProps;
9
+ }>;
7
10
  declare function Root({ initial, threshold, onAtBottomChange, id, ...rest }: RootProps): ReactElement;
8
- declare const Viewport: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
9
- declare const Content: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
10
- declare const Button: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
11
+ export type ViewportProps = PartComponentProps<"div", StateOf<Parts["viewport"]>>;
12
+ declare const Viewport: (props: ViewportProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
13
+ export type ContentProps = PartComponentProps<"div", StateOf<Parts["content"]>>;
14
+ declare const Content: (props: ContentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
15
+ export type ButtonProps = PartComponentProps<"button", StateOf<Parts["button"]>>;
16
+ declare const Button: (props: ButtonProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
11
17
  export declare const MessageScroller: {
12
- Root: typeof Root;
13
- Viewport: typeof Viewport;
14
- Content: typeof Content;
15
- Button: typeof Button;
18
+ readonly Root: typeof Root;
19
+ readonly Viewport: typeof Viewport;
20
+ readonly Content: typeof Content;
21
+ readonly Button: typeof Button;
16
22
  };
17
23
  export {};
18
24
  //# sourceMappingURL=message-scroller.d.ts.map
@@ -1,4 +1,4 @@
1
- import { useController, usePart } from "./runtime.js";
1
+ import { parts, useController, usePart } from "./runtime.js";
2
2
  import { createContext, useContext } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { createMessageScroller } from "@kirana-ui/core/message-scroller";
@@ -24,12 +24,12 @@ function Root({ initial, threshold, onAtBottomChange, id, ...rest }) {
24
24
  const Viewport = (props) => usePart(useScroller("Viewport").viewport, "div", props);
25
25
  const Content = (props) => usePart(useScroller("Content").content, "div", props);
26
26
  const Button = (props) => usePart(useScroller("Button").button, "button", props);
27
- const MessageScroller = {
27
+ const MessageScroller = /* @__PURE__ */ parts("MessageScroller", {
28
28
  Root,
29
29
  Viewport,
30
30
  Content,
31
31
  Button
32
- };
32
+ });
33
33
  export { MessageScroller };
34
34
 
35
35
  //# sourceMappingURL=message-scroller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-scroller.js","names":[],"sources":["../../../../packages/react/src/message-scroller.tsx"],"sourcesContent":["import { createMessageScroller } from \"@kirana-ui/core/message-scroller\"\nimport type {\n MessageScroller as Controller,\n MessageScrollerProps,\n} from \"@kirana-ui/core/message-scroller\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useScroller(part: string): Controller {\n const controller = useContext(Context)\n if (!controller)\n throw new Error(`<MessageScroller.${part}> must be inside <MessageScroller.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<MessageScrollerProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({ initial, threshold, onAtBottomChange, id, ...rest }: RootProps): ReactElement {\n const controller = useController<MessageScrollerProps, Controller>(createMessageScroller, {\n initial,\n threshold,\n onAtBottomChange,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nconst Viewport = (props: PartComponentProps) =>\n usePart(useScroller(\"Viewport\").viewport, \"div\", props)\nconst Content = (props: PartComponentProps) => usePart(useScroller(\"Content\").content, \"div\", props)\nconst Button = (props: PartComponentProps) => usePart(useScroller(\"Button\").button, \"button\", props)\n\nexport const MessageScroller = { Root, Viewport, Content, Button }\n"],"mappings":";;;;;AAWA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,oBAAoB,KAAK,wCAAwC;CACnF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,SAAS,WAAW,kBAAkB,IAAI,GAAG,QAAiC;CAC5F,MAAM,aAAa,cAAgD,uBAAuB;EACxF;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAEA,MAAM,YAAY,UAChB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AACxD,MAAM,WAAW,UAA8B,QAAQ,YAAY,SAAS,CAAC,CAAC,SAAS,OAAO,KAAK;AACnG,MAAM,UAAU,UAA8B,QAAQ,YAAY,QAAQ,CAAC,CAAC,QAAQ,UAAU,KAAK;AAEnG,MAAa,kBAAkB;CAAE;CAAM;CAAU;CAAS;AAAO"}
1
+ {"version":3,"file":"message-scroller.js","names":[],"sources":["../../../../packages/react/src/message-scroller.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createMessageScroller } from \"@kirana-ui/core/message-scroller\"\nimport type {\n MessageScroller as Controller,\n MessageScrollerProps,\n} from \"@kirana-ui/core/message-scroller\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"messageScroller\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useScroller(part: string): Controller {\n const controller = useContext(Context)\n if (!controller)\n throw new Error(`<MessageScroller.${part}> must be inside <MessageScroller.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<MessageScrollerProps, \"id\"> & { id?: string }\n>\n\nfunction Root({ initial, threshold, onAtBottomChange, id, ...rest }: RootProps): ReactElement {\n const controller = useController<MessageScrollerProps, Controller>(createMessageScroller, {\n initial,\n threshold,\n onAtBottomChange,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type ViewportProps = PartComponentProps<\"div\", StateOf<Parts[\"viewport\"]>>\n\nconst Viewport = (props: ViewportProps) => usePart(useScroller(\"Viewport\").viewport, \"div\", props)\nexport type ContentProps = PartComponentProps<\"div\", StateOf<Parts[\"content\"]>>\n\nconst Content = (props: ContentProps) => usePart(useScroller(\"Content\").content, \"div\", props)\nexport type ButtonProps = PartComponentProps<\"button\", StateOf<Parts[\"button\"]>>\n\nconst Button = (props: ButtonProps) => usePart(useScroller(\"Button\").button, \"button\", props)\n\nexport const MessageScroller = /* @__PURE__ */ parts(\"MessageScroller\", {\n Root,\n Viewport,\n Content,\n Button,\n})\n"],"mappings":";;;;;AAeA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,oBAAoB,KAAK,wCAAwC;CACnF,OAAO;AACT;AAQA,SAAS,KAAK,EAAE,SAAS,WAAW,kBAAkB,IAAI,GAAG,QAAiC;CAC5F,MAAM,aAAa,cAAgD,uBAAuB;EACxF;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAIA,MAAM,YAAY,UAAyB,QAAQ,YAAY,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AAGjG,MAAM,WAAW,UAAwB,QAAQ,YAAY,SAAS,CAAC,CAAC,SAAS,OAAO,KAAK;AAG7F,MAAM,UAAU,UAAuB,QAAQ,YAAY,QAAQ,CAAC,CAAC,QAAQ,UAAU,KAAK;AAE5F,MAAa,kBAAkC,sBAAM,mBAAmB;CACtE;CACA;CACA;CACA;AACF,CAAC"}
package/src/meter.d.ts CHANGED
@@ -1,13 +1,22 @@
1
1
  import { PartComponentProps } from "./runtime.js";
2
+ import { ValueOptions } from "./value-bar.js";
3
+ import { StateOf } from "@kirana-ui/core";
4
+ import { MeterProps } from "@kirana-ui/core/meter";
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["meter"];
7
+ export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<MeterProps, "id"> & {
8
+ id?: string;
9
+ }>;
10
+ export type TrackProps = PartComponentProps<"div", StateOf<Parts["track"]>>;
11
+ export type IndicatorProps = PartComponentProps<"div", StateOf<Parts["indicator"]>>;
12
+ export type ValueProps = PartComponentProps<"span", StateOf<Parts["value"]>, ValueOptions>;
13
+ export type LabelProps = PartComponentProps<"span", StateOf<Parts["label"]>>;
2
14
  export declare const Meter: {
3
- Root: ({ value, min, max, format, locale, getAriaValueText, id, ...rest }: Omit<import("@kirana-ui/core/meter").MeterProps, "id"> & {
4
- id?: string;
5
- } & PartComponentProps<undefined>) => import("react").ReactElement;
6
- Track: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
7
- Indicator: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
8
- Value: ({ children, ...props }: Omit<PartComponentProps<undefined>, "children"> & {
9
- children?: ((text: string | undefined) => import("react").ReactNode) | undefined;
10
- }) => import("react").ReactElement;
11
- Label: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
15
+ Root: (props: RootProps) => import("react").ReactElement;
16
+ Track: (props: TrackProps) => import("react").ReactElement;
17
+ Indicator: (props: IndicatorProps) => import("react").ReactElement;
18
+ Value: (props: ValueProps) => import("react").ReactElement;
19
+ Label: (props: LabelProps) => import("react").ReactElement;
12
20
  };
21
+ export {};
13
22
  //# sourceMappingURL=meter.d.ts.map
package/src/meter.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { valueBar } from "./value-bar.js";
2
2
  import { createMeter } from "@kirana-ui/core/meter";
3
3
  // src/meter.tsx
4
- const Meter = valueBar("Meter", createMeter);
4
+ const Meter = /* @__PURE__ */ valueBar("Meter", createMeter);
5
5
  export { Meter };
6
6
 
7
7
  //# sourceMappingURL=meter.js.map
package/src/meter.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"meter.js","names":[],"sources":["../../../../packages/react/src/meter.tsx"],"sourcesContent":["import { createMeter } from \"@kirana-ui/core/meter\"\n\nimport { valueBar } from \"./value-bar.tsx\"\n\nexport const Meter = valueBar(\"Meter\", createMeter)\n"],"mappings":";;;AAIA,MAAa,QAAQ,SAAS,SAAS,WAAW"}
1
+ {"version":3,"file":"meter.js","names":[],"sources":["../../../../packages/react/src/meter.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createMeter } from \"@kirana-ui/core/meter\"\nimport type { MeterProps } from \"@kirana-ui/core/meter\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\n\nimport type { PartComponentProps } from \"./runtime.tsx\"\nimport { valueBar } from \"./value-bar.tsx\"\nimport type { ValueOptions } from \"./value-bar.tsx\"\n\ntype Parts = Vocabulary[\"meter\"]\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<MeterProps, \"id\"> & { id?: string }\n>\nexport type TrackProps = PartComponentProps<\"div\", StateOf<Parts[\"track\"]>>\nexport type IndicatorProps = PartComponentProps<\"div\", StateOf<Parts[\"indicator\"]>>\nexport type ValueProps = PartComponentProps<\"span\", StateOf<Parts[\"value\"]>, ValueOptions>\nexport type LabelProps = PartComponentProps<\"span\", StateOf<Parts[\"label\"]>>\n\nexport const Meter = /* @__PURE__ */ valueBar<\n MeterProps,\n {\n Root: RootProps\n Track: TrackProps\n Indicator: IndicatorProps\n Value: ValueProps\n Label: LabelProps\n }\n>(\"Meter\", createMeter)\n"],"mappings":";;;AAqBA,MAAa,QAAwB,yBASnC,SAAS,WAAW"}
@@ -1,48 +1,58 @@
1
- import { PartComponentProps } from "./runtime.js";
2
- import { PositionOptions } from "@kirana-ui/core";
3
- import { ReactElement, ReactNode } from "react";
1
+ import { PartComponentProps, PortalProps, PositionerOptions } from "./runtime.js";
2
+ import { StateOf } from "@kirana-ui/core";
3
+ import { ReactElement } from "react";
4
4
  import { NavigationMenuLinkOptions, NavigationMenuProps } from "@kirana-ui/core/navigation-menu";
5
- export type RootProps<Value> = Omit<NavigationMenuProps<Value>, "id"> & {
5
+ import { Vocabulary } from "@kirana-ui/core/vocabulary";
6
+ type Parts = Vocabulary["navigationMenu"];
7
+ /** `Value` is what tells an item from the others: the type of `value`. */
8
+ export type RootProps<Value = unknown> = PartComponentProps<"nav", StateOf<Parts["root"]>, Omit<NavigationMenuProps<Value>, "id"> & {
6
9
  id?: string;
7
- } & PartComponentProps;
8
- declare function Root<Value>({ value, defaultValue, onValueChange, delay, closeDelay, orientation, id, ...rest }: RootProps<Value>): ReactElement;
9
- declare const List: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
10
- export interface ItemProps {
11
- /** What tells this item from the others. Not needed for an item that is only a link. */
10
+ }>;
11
+ declare function Root<Value = unknown>({ value, defaultValue, onValueChange, delay, closeDelay, orientation, id, ...rest }: RootProps<Value>): ReactElement;
12
+ export type ListProps = PartComponentProps<"ul", StateOf<Parts["list"]>>;
13
+ declare const List: (props: ListProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
14
+ export type ItemProps = PartComponentProps<"li", StateOf<Parts["item"]>, {
15
+ /**
16
+ * What tells this item from the others: the menu's `value` while its content is shown. An
17
+ * item that is given none makes its own.
18
+ */
12
19
  value?: unknown;
13
- children?: ReactNode;
14
- [attribute: string]: unknown;
15
- }
16
- declare function Item({ value, children, ...rest }: ItemProps): ReactElement;
17
- declare const Trigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
18
- declare const Icon: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
20
+ }>;
21
+ declare function Item({ value, ...props }: ItemProps): ReactElement;
22
+ export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>>;
23
+ export type IconProps = PartComponentProps<"span", StateOf<Parts["icon"]>>;
24
+ declare const Trigger: (props: TriggerProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
25
+ declare const Icon: (props: IconProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
26
+ export type ContentProps = PartComponentProps<"div", StateOf<Parts["content"]>>;
19
27
  /** An item's content: drawn in `<NavigationMenu.Viewport>`, while it is shown. */
20
- declare function Content(props: PartComponentProps): ReactElement | null;
21
- export type LinkProps = PartComponentProps & NavigationMenuLinkOptions;
28
+ declare function Content(props: ContentProps): ReactElement | null;
29
+ export type LinkProps = PartComponentProps<"a", StateOf<Parts["link"]>, NavigationMenuLinkOptions>;
22
30
  declare function Link({ active, closeOnClick, ...props }: LinkProps): ReactElement;
23
- declare function Portal({ children }: {
24
- children?: ReactNode;
25
- }): ReactElement | null;
26
- export type PositionerProps = PartComponentProps & Partial<PositionOptions>;
27
- declare function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
28
- declare const Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
29
- declare const Viewport: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
30
- declare const Arrow: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
31
- declare const Backdrop: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
31
+ declare function Portal({ children }: PortalProps): ReactElement | null;
32
+ export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
33
+ declare function Positioner(props: PositionerProps): ReactElement;
34
+ export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
35
+ export type ViewportProps = PartComponentProps<"div", StateOf<Parts["viewport"]>>;
36
+ export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
37
+ export type BackdropProps = PartComponentProps<"div", StateOf<Parts["backdrop"]>>;
38
+ declare const Popup: (props: PopupProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
39
+ declare const Viewport: (props: ViewportProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
40
+ declare const Arrow: (props: ArrowProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
41
+ declare const Backdrop: (props: BackdropProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
32
42
  export declare const NavigationMenu: {
33
- Root: typeof Root;
34
- List: typeof List;
35
- Item: typeof Item;
36
- Trigger: typeof Trigger;
37
- Icon: typeof Icon;
38
- Content: typeof Content;
39
- Link: typeof Link;
40
- Portal: typeof Portal;
41
- Positioner: typeof Positioner;
42
- Popup: typeof Popup;
43
- Viewport: typeof Viewport;
44
- Arrow: typeof Arrow;
45
- Backdrop: typeof Backdrop;
43
+ readonly Root: typeof Root;
44
+ readonly List: typeof List;
45
+ readonly Item: typeof Item;
46
+ readonly Trigger: typeof Trigger;
47
+ readonly Icon: typeof Icon;
48
+ readonly Content: typeof Content;
49
+ readonly Link: typeof Link;
50
+ readonly Portal: typeof Portal;
51
+ readonly Positioner: typeof Positioner;
52
+ readonly Popup: typeof Popup;
53
+ readonly Viewport: typeof Viewport;
54
+ readonly Arrow: typeof Arrow;
55
+ readonly Backdrop: typeof Backdrop;
46
56
  };
47
- export {};
57
+ export type { PortalProps };
48
58
  //# sourceMappingURL=navigation-menu.d.ts.map