@primitiv-ui/react 0.1.0 → 0.1.2

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 (207) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +2 -1
  3. package/src/AccessibleIcon/AccessibleIcon.tsx +6 -2
  4. package/src/AccessibleIcon/__tests__/AccessibleIcon.test.tsx +1 -1
  5. package/src/AccessibleIcon/types.ts +4 -0
  6. package/src/Accordion/Accordion.tsx +34 -12
  7. package/src/Accordion/AccordionContext.ts +1 -1
  8. package/src/Accordion/__tests__/Accordion.reading-direction.test.tsx +1 -1
  9. package/src/Accordion/hooks/useAccordionItem.ts +1 -1
  10. package/src/Accordion/hooks/useAccordionRoot.ts +1 -1
  11. package/src/Accordion/hooks/useAccordionTrigger.ts +2 -2
  12. package/src/Accordion/index.ts +2 -1
  13. package/src/Accordion/types.ts +55 -13
  14. package/src/Alert/Alert.tsx +9 -2
  15. package/src/Alert/__tests__/Alert.test.tsx +1 -1
  16. package/src/Alert/types.ts +1 -0
  17. package/src/Avatar/Avatar.tsx +20 -7
  18. package/src/Avatar/AvatarContext.ts +12 -6
  19. package/src/Breadcrumb/Breadcrumb.tsx +32 -10
  20. package/src/Button/Button.tsx +5 -2
  21. package/src/Button/types.ts +4 -0
  22. package/src/Carousel/Carousel.tsx +30 -14
  23. package/src/Carousel/CarouselContext.ts +7 -3
  24. package/src/Carousel/__tests__/Carousel.asChild.test.tsx +1 -1
  25. package/src/Carousel/__tests__/Carousel.auto-play.test.tsx +1 -1
  26. package/src/Carousel/__tests__/Carousel.basic-rendering.test.tsx +1 -1
  27. package/src/Carousel/__tests__/Carousel.controlled-state.test.tsx +1 -1
  28. package/src/Carousel/__tests__/Carousel.error-handling.test.tsx +1 -1
  29. package/src/Carousel/__tests__/Carousel.ids.test.tsx +1 -1
  30. package/src/Carousel/__tests__/Carousel.imperative-api.test.tsx +2 -2
  31. package/src/Carousel/__tests__/Carousel.indicators.test.tsx +1 -1
  32. package/src/Carousel/__tests__/Carousel.intersection-observer.test.tsx +2 -2
  33. package/src/Carousel/__tests__/Carousel.keyboard-navigation.test.tsx +1 -1
  34. package/src/Carousel/__tests__/Carousel.play-pause.test.tsx +1 -1
  35. package/src/Carousel/__tests__/Carousel.prev-next.test.tsx +1 -1
  36. package/src/Carousel/__tests__/Carousel.reduced-motion.test.tsx +1 -1
  37. package/src/Carousel/__tests__/Carousel.refresh-progress.test.tsx +2 -2
  38. package/src/Carousel/__tests__/Carousel.scroll-snap-change.test.tsx +1 -1
  39. package/src/Carousel/__tests__/Carousel.scroll-sync.test.tsx +1 -1
  40. package/src/Carousel/__tests__/Carousel.slides-per-move.test.tsx +1 -1
  41. package/src/Carousel/__tests__/Carousel.slides-per-page.test.tsx +1 -1
  42. package/src/Carousel/__tests__/Carousel.touch-interaction.test.tsx +1 -1
  43. package/src/Carousel/__tests__/Carousel.transition-modes.test.tsx +1 -1
  44. package/src/Carousel/__tests__/Carousel.translations.test.tsx +1 -1
  45. package/src/Carousel/__tests__/Carousel.uncontrolled-state.test.tsx +1 -1
  46. package/src/Carousel/types.ts +8 -0
  47. package/src/Checkbox/Checkbox.tsx +11 -6
  48. package/src/Checkbox/CheckboxContext.ts +1 -1
  49. package/src/Checkbox/hooks/useCheckboxRoot.ts +1 -1
  50. package/src/Checkbox/index.ts +1 -0
  51. package/src/Checkbox/types.ts +30 -3
  52. package/src/CheckboxCard/CheckboxCard.tsx +13 -11
  53. package/src/CheckboxCard/CheckboxCardContext.ts +19 -6
  54. package/src/CheckboxCard/hooks/useCheckboxCardRoot.ts +2 -2
  55. package/src/CheckboxCard/types.ts +21 -5
  56. package/src/Collapsible/Collapsible.tsx +37 -21
  57. package/src/Collapsible/CollapsibleContext.ts +1 -1
  58. package/src/Collapsible/hooks/useCollapsibleRoot.ts +1 -1
  59. package/src/Collapsible/hooks/useCollapsibleTrigger.ts +1 -1
  60. package/src/Collapsible/index.ts +1 -0
  61. package/src/Collapsible/types.ts +45 -12
  62. package/src/ContextMenu/ContextMenu.tsx +60 -34
  63. package/src/ContextMenu/ContextMenuContext.ts +2 -2
  64. package/src/ContextMenu/ContextMenuSubContext.ts +1 -1
  65. package/src/ContextMenu/__tests__/ContextMenu.reading-direction.test.tsx +1 -1
  66. package/src/ContextMenu/index.ts +2 -1
  67. package/src/ContextMenu/types.ts +160 -17
  68. package/src/DirectionProvider/DirectionProvider.tsx +7 -1
  69. package/src/DirectionProvider/__tests__/DirectionProvider.test.tsx +1 -1
  70. package/src/DirectionProvider/types.ts +1 -0
  71. package/src/Divider/Divider.tsx +4 -1
  72. package/src/Divider/__tests__/Divider.test.tsx +1 -1
  73. package/src/Divider/index.ts +2 -1
  74. package/src/Divider/types.ts +5 -0
  75. package/src/Dropdown/Dropdown.tsx +60 -34
  76. package/src/Dropdown/DropdownContext.ts +2 -2
  77. package/src/Dropdown/DropdownSubContext.ts +1 -1
  78. package/src/Dropdown/__tests__/Dropdown.reading-direction.test.tsx +1 -1
  79. package/src/Dropdown/hooks/useDropdownContent.ts +1 -1
  80. package/src/Dropdown/hooks/useDropdownItem.ts +1 -1
  81. package/src/Dropdown/hooks/useDropdownRoot.ts +2 -2
  82. package/src/Dropdown/hooks/useDropdownTrigger.ts +1 -1
  83. package/src/Dropdown/index.ts +2 -1
  84. package/src/Dropdown/types.ts +153 -25
  85. package/src/EmptyState/EmptyState.tsx +34 -20
  86. package/src/EmptyState/__tests__/EmptyState.Actions.test.tsx +1 -1
  87. package/src/EmptyState/__tests__/EmptyState.Description.test.tsx +1 -1
  88. package/src/EmptyState/__tests__/EmptyState.Media.test.tsx +1 -1
  89. package/src/EmptyState/__tests__/EmptyState.Root.test.tsx +1 -1
  90. package/src/EmptyState/__tests__/EmptyState.Title.test.tsx +1 -1
  91. package/src/EmptyState/types.ts +2 -1
  92. package/src/Field/Field.tsx +24 -10
  93. package/src/Field/FieldContext.ts +1 -1
  94. package/src/Field/types.ts +4 -0
  95. package/src/Fieldset/Fieldset.tsx +26 -10
  96. package/src/Fieldset/types.ts +2 -0
  97. package/src/Input/Input.tsx +6 -3
  98. package/src/Input/__tests__/Input.field-integration.test.tsx +1 -1
  99. package/src/Input/types.ts +4 -0
  100. package/src/InputGroup/InputGroup.tsx +15 -8
  101. package/src/InputGroup/types.ts +9 -0
  102. package/src/MillerColumns/MillerColumns.tsx +28 -8
  103. package/src/MillerColumns/MillerColumnsContext.ts +1 -1
  104. package/src/MillerColumns/hooks/useMillerColumnsItem.ts +2 -2
  105. package/src/MillerColumns/hooks/useMillerColumnsRoot.ts +0 -0
  106. package/src/MillerColumns/index.ts +1 -1
  107. package/src/MillerColumns/types.ts +67 -14
  108. package/src/MillerColumns/useMillerColumnsSelection.ts +1 -1
  109. package/src/Modal/Modal.tsx +25 -11
  110. package/src/Modal/ModalContext.ts +14 -7
  111. package/src/Modal/hooks/useModalRoot.ts +1 -1
  112. package/src/Modal/hooks/useModalTrigger.ts +2 -2
  113. package/src/Modal/types.ts +51 -2
  114. package/src/Portal/Portal.tsx +3 -1
  115. package/src/Portal/types.ts +4 -0
  116. package/src/Progress/Progress.tsx +12 -7
  117. package/src/Progress/ProgressContext.ts +18 -6
  118. package/src/RadioCard/RadioCard.tsx +17 -11
  119. package/src/RadioCard/RadioCardContext.ts +17 -5
  120. package/src/RadioCard/RadioCardItemContext.ts +18 -5
  121. package/src/RadioCard/__tests__/RadioCard.reading-direction.test.tsx +1 -1
  122. package/src/RadioCard/hooks/useRadioCardRoot.ts +1 -1
  123. package/src/RadioCard/types.ts +24 -3
  124. package/src/RadioGroup/RadioGroup.tsx +17 -11
  125. package/src/RadioGroup/RadioGroupContext.ts +1 -1
  126. package/src/RadioGroup/RadioGroupItemContext.ts +1 -1
  127. package/src/RadioGroup/__tests__/RadioGroup.reading-direction.test.tsx +1 -1
  128. package/src/RadioGroup/hooks/useRadioGroupRoot.ts +1 -1
  129. package/src/RadioGroup/index.ts +1 -0
  130. package/src/RadioGroup/types.ts +34 -3
  131. package/src/Select/Select.tsx +23 -8
  132. package/src/Select/__tests__/Select.field-integration.test.tsx +1 -1
  133. package/src/Select/index.ts +1 -1
  134. package/src/Select/types.ts +18 -3
  135. package/src/SkipNav/SkipNav.tsx +7 -2
  136. package/src/SkipNav/__tests__/SkipNav.ids.test.tsx +1 -1
  137. package/src/Slider/Slider.tsx +26 -11
  138. package/src/Slider/SliderContext.ts +13 -6
  139. package/src/Slider/__tests__/Slider.reading-direction.test.tsx +1 -1
  140. package/src/Slider/hooks/useSliderRoot.ts +1 -1
  141. package/src/Slider/types.ts +12 -3
  142. package/src/Status/Status.tsx +9 -2
  143. package/src/Status/__tests__/Status.test.tsx +1 -1
  144. package/src/Status/types.ts +4 -0
  145. package/src/Switch/Switch.tsx +16 -6
  146. package/src/Switch/SwitchContext.ts +13 -5
  147. package/src/Switch/hooks/useSwitchRoot.ts +1 -1
  148. package/src/Switch/types.ts +24 -3
  149. package/src/Table/Table.tsx +51 -25
  150. package/src/Table/__tests__/Table.Body.test.tsx +1 -1
  151. package/src/Table/__tests__/Table.Caption.test.tsx +1 -1
  152. package/src/Table/__tests__/Table.Cell.test.tsx +1 -1
  153. package/src/Table/__tests__/Table.Footer.test.tsx +1 -1
  154. package/src/Table/__tests__/Table.Head.test.tsx +1 -1
  155. package/src/Table/__tests__/Table.Header.test.tsx +1 -1
  156. package/src/Table/__tests__/Table.Root.test.tsx +1 -1
  157. package/src/Table/__tests__/Table.Row.test.tsx +1 -1
  158. package/src/Table/__tests__/Table.ScrollArea.test.tsx +1 -1
  159. package/src/Table/index.ts +2 -1
  160. package/src/Tabs/Tabs.tsx +30 -10
  161. package/src/Tabs/TabsContext.ts +15 -7
  162. package/src/Tabs/__tests__/Tabs.asChild.test.tsx +1 -1
  163. package/src/Tabs/__tests__/Tabs.basic-rendering.test.tsx +1 -1
  164. package/src/Tabs/__tests__/Tabs.change-event-callbacks.test.tsx +1 -1
  165. package/src/Tabs/__tests__/Tabs.controlled-state.test.tsx +1 -1
  166. package/src/Tabs/__tests__/Tabs.error-handling.test.tsx +1 -1
  167. package/src/Tabs/__tests__/Tabs.imperative-api.test.tsx +1 -1
  168. package/src/Tabs/__tests__/Tabs.keyboard-interaction.test.tsx +1 -1
  169. package/src/Tabs/__tests__/Tabs.lazy-mount.test.tsx +1 -1
  170. package/src/Tabs/__tests__/Tabs.mouse-interaction.test.tsx +1 -1
  171. package/src/Tabs/__tests__/Tabs.reading-direction.test.tsx +1 -1
  172. package/src/Tabs/__tests__/Tabs.uncontrolled-state.test.tsx +1 -1
  173. package/src/Tabs/hooks/useTabsContent.ts +1 -1
  174. package/src/Tabs/hooks/useTabsRoot.ts +1 -1
  175. package/src/Tabs/hooks/useTabsTrigger.ts +1 -1
  176. package/src/Tabs/types.ts +35 -1
  177. package/src/Tabs/utils.ts +1 -1
  178. package/src/Textarea/Textarea.tsx +6 -3
  179. package/src/Textarea/__tests__/Textarea.field-integration.test.tsx +1 -1
  180. package/src/Textarea/types.ts +4 -0
  181. package/src/Toggle/Toggle.tsx +11 -4
  182. package/src/Toggle/types.ts +7 -3
  183. package/src/ToggleGroup/ToggleGroup.tsx +23 -13
  184. package/src/ToggleGroup/ToggleGroupContext.ts +1 -1
  185. package/src/ToggleGroup/__tests__/ToggleGroup.reading-direction.test.tsx +1 -1
  186. package/src/ToggleGroup/hooks/useToggleGroupRoot.ts +1 -1
  187. package/src/ToggleGroup/types.ts +45 -5
  188. package/src/Tooltip/Tooltip.tsx +46 -15
  189. package/src/Tooltip/TooltipContext.ts +1 -1
  190. package/src/Tooltip/hooks/useTooltipContent.ts +1 -1
  191. package/src/Tooltip/hooks/useTooltipRoot.ts +1 -1
  192. package/src/Tooltip/hooks/useTooltipTrigger.ts +1 -1
  193. package/src/Tooltip/index.ts +1 -0
  194. package/src/Tooltip/types.ts +50 -2
  195. package/src/Tree/Tree.tsx +58 -12
  196. package/src/Tree/TreeContext.ts +1 -1
  197. package/src/Tree/__tests__/Tree.selection-path.test.tsx +2 -2
  198. package/src/Tree/hooks/useTreeItemKeyboard.ts +1 -1
  199. package/src/Tree/hooks/useTreeRoot.ts +1 -1
  200. package/src/Tree/index.ts +1 -1
  201. package/src/Tree/types.ts +39 -7
  202. package/src/VisuallyHidden/VisuallyHidden.tsx +4 -2
  203. package/src/VisuallyHidden/__tests__/VisuallyHidden.test.tsx +1 -1
  204. package/src/VisuallyHidden/types.ts +4 -0
  205. package/src/index.ts +39 -38
  206. package/src/types.ts +1 -0
  207. package/src/utils/createStrictContext.ts +9 -5
@@ -1,9 +1,13 @@
1
1
  import { ComponentProps, ReactNode, Ref } from "react";
2
2
 
3
3
  import { CheckedState } from "../Checkbox/types";
4
- import { Direction } from "../DirectionProvider";
4
+ import { Direction } from "../DirectionProvider/index.ts";
5
5
 
6
- type ContextMenuRootBaseProps = {
6
+ /**
7
+ * Shared base for both {@link ContextMenuRootProps} variants — `children`
8
+ * plus the reading-direction control.
9
+ */
10
+ export type ContextMenuRootBaseProps = {
7
11
  children?: ReactNode;
8
12
  /**
9
13
  * Reading direction for the menu. Affects which arrow key opens / closes
@@ -14,22 +18,43 @@ type ContextMenuRootBaseProps = {
14
18
  dir?: Direction;
15
19
  };
16
20
 
17
- type ContextMenuRootUncontrolledProps = ContextMenuRootBaseProps & {
21
+ /**
22
+ * Uncontrolled variant of {@link ContextMenuRootProps}: the component owns
23
+ * the open state. Pass `defaultOpen` (or omit it); `onOpenChange` is
24
+ * optional and `open` is forbidden.
25
+ */
26
+ export type ContextMenuRootUncontrolledProps = ContextMenuRootBaseProps & {
18
27
  defaultOpen?: boolean;
19
28
  open?: never;
20
29
  onOpenChange?: (open: boolean) => void;
21
30
  };
22
31
 
23
- type ContextMenuRootControlledProps = ContextMenuRootBaseProps & {
32
+ /**
33
+ * Controlled variant of {@link ContextMenuRootProps}: the parent owns the
34
+ * open state. Pass `open` and `onOpenChange` together; `defaultOpen` is
35
+ * forbidden.
36
+ */
37
+ export type ContextMenuRootControlledProps = ContextMenuRootBaseProps & {
24
38
  defaultOpen?: never;
25
39
  open: boolean;
26
40
  onOpenChange: (open: boolean) => void;
27
41
  };
28
42
 
43
+ /**
44
+ * Props for {@link ContextMenu.Root} — the open-state owner and
45
+ * direction provider. A discriminated union of the uncontrolled
46
+ * ({@link ContextMenuRootUncontrolledProps}) and controlled
47
+ * ({@link ContextMenuRootControlledProps}) variants.
48
+ */
29
49
  export type ContextMenuRootProps =
30
50
  | ContextMenuRootUncontrolledProps
31
51
  | ContextMenuRootControlledProps;
32
52
 
53
+ /**
54
+ * Props for {@link ContextMenu.Trigger} — the `<span>` whose right-click
55
+ * (context menu) gesture opens the menu. Supports `asChild` to merge
56
+ * onto a custom element and `disabled` to suppress the gesture.
57
+ */
33
58
  export type ContextMenuTriggerProps = ComponentProps<"span"> & {
34
59
  children?: ReactNode;
35
60
  ref?: Ref<HTMLSpanElement>;
@@ -37,6 +62,11 @@ export type ContextMenuTriggerProps = ComponentProps<"span"> & {
37
62
  disabled?: boolean;
38
63
  };
39
64
 
65
+ /**
66
+ * Props for {@link ContextMenu.Content} — the `<menu>` popover holding the
67
+ * menu items. The managed `role`, `popover`, and `id` attributes are
68
+ * omitted; `asChild` merges the props onto a custom element.
69
+ */
40
70
  export type ContextMenuContentProps = Omit<
41
71
  ComponentProps<"menu">,
42
72
  "role" | "popover" | "id"
@@ -46,6 +76,11 @@ export type ContextMenuContentProps = Omit<
46
76
  asChild?: boolean;
47
77
  };
48
78
 
79
+ /**
80
+ * Props for {@link ContextMenu.Item} — a selectable `<li>` menu item. The
81
+ * managed `role`, `tabIndex`, and `onSelect` are omitted from the host
82
+ * props; `disabled` skips activation and `onSelect` fires on activation.
83
+ */
49
84
  export type ContextMenuItemProps = Omit<
50
85
  ComponentProps<"li">,
51
86
  "role" | "tabIndex" | "onSelect"
@@ -62,25 +97,46 @@ export type ContextMenuItemProps = Omit<
62
97
  onSelect?: (event: Event) => void;
63
98
  };
64
99
 
100
+ /**
101
+ * Props for {@link ContextMenu.Separator} — a non-interactive `<li>`
102
+ * divider between groups of items. The managed `role` is omitted;
103
+ * `asChild` merges the props onto a custom element.
104
+ */
65
105
  export type ContextMenuSeparatorProps = Omit<ComponentProps<"li">, "role"> & {
66
106
  children?: ReactNode;
67
107
  ref?: Ref<HTMLLIElement>;
68
108
  asChild?: boolean;
69
109
  };
70
110
 
111
+ /**
112
+ * Props for {@link ContextMenu.Group} — an `<li>` that groups related
113
+ * items, optionally labelled by a {@link ContextMenu.Label}. The managed
114
+ * `role` is omitted; `asChild` merges the props onto a custom element.
115
+ */
71
116
  export type ContextMenuGroupProps = Omit<ComponentProps<"li">, "role"> & {
72
117
  children?: ReactNode;
73
118
  ref?: Ref<HTMLLIElement>;
74
119
  asChild?: boolean;
75
120
  };
76
121
 
122
+ /**
123
+ * Props for {@link ContextMenu.Label} — a non-interactive `<li>` caption
124
+ * for a {@link ContextMenu.Group}. Supports `asChild` to merge the props
125
+ * onto a custom element.
126
+ */
77
127
  export type ContextMenuLabelProps = ComponentProps<"li"> & {
78
128
  children?: ReactNode;
79
129
  ref?: Ref<HTMLLIElement>;
80
130
  asChild?: boolean;
81
131
  };
82
132
 
83
- type ContextMenuCheckboxItemBaseProps = Omit<
133
+ /**
134
+ * Shared base for both {@link ContextMenuCheckboxItemProps} variants —
135
+ * the `<li>` host props plus `children`, `ref`, `asChild`, `disabled`,
136
+ * and `onSelect`. The managed `role`, `tabIndex`, `aria-checked`,
137
+ * `defaultChecked`, and `onSelect` host attributes are omitted.
138
+ */
139
+ export type ContextMenuCheckboxItemBaseProps = Omit<
84
140
  ComponentProps<"li">,
85
141
  "role" | "tabIndex" | "aria-checked" | "defaultChecked" | "onSelect"
86
142
  > & {
@@ -95,24 +151,47 @@ type ContextMenuCheckboxItemBaseProps = Omit<
95
151
  onSelect?: (event: Event) => void;
96
152
  };
97
153
 
98
- type ContextMenuCheckboxItemUncontrolledProps =
154
+ /**
155
+ * Uncontrolled variant of {@link ContextMenuCheckboxItemProps}: the
156
+ * component owns the checked state. Pass `defaultChecked` (or omit it);
157
+ * `onCheckedChange` is optional and the controlled `checked` prop is
158
+ * forbidden.
159
+ */
160
+ export type ContextMenuCheckboxItemUncontrolledProps =
99
161
  ContextMenuCheckboxItemBaseProps & {
100
162
  defaultChecked?: CheckedState;
101
163
  checked?: never;
102
164
  onCheckedChange?: (checked: boolean) => void;
103
165
  };
104
166
 
105
- type ContextMenuCheckboxItemControlledProps =
167
+ /**
168
+ * Controlled variant of {@link ContextMenuCheckboxItemProps}: the parent
169
+ * owns the checked state. Pass `checked` and `onCheckedChange` together;
170
+ * `defaultChecked` is forbidden.
171
+ */
172
+ export type ContextMenuCheckboxItemControlledProps =
106
173
  ContextMenuCheckboxItemBaseProps & {
107
174
  defaultChecked?: never;
108
175
  checked: CheckedState;
109
176
  onCheckedChange: (checked: boolean) => void;
110
177
  };
111
178
 
179
+ /**
180
+ * Props for {@link ContextMenu.CheckboxItem} — a toggleable menu item. A
181
+ * discriminated union of the uncontrolled
182
+ * ({@link ContextMenuCheckboxItemUncontrolledProps}) and controlled
183
+ * ({@link ContextMenuCheckboxItemControlledProps}) variants.
184
+ */
112
185
  export type ContextMenuCheckboxItemProps =
113
186
  | ContextMenuCheckboxItemUncontrolledProps
114
187
  | ContextMenuCheckboxItemControlledProps;
115
188
 
189
+ /**
190
+ * Props for {@link ContextMenu.ItemIndicator} — the `<span>` that renders
191
+ * inside a checkbox or radio item to show its checked state. Set
192
+ * `forceMount` to render even when unchecked; `asChild` merges the props
193
+ * onto a custom element.
194
+ */
116
195
  export type ContextMenuItemIndicatorProps = ComponentProps<"span"> & {
117
196
  children?: ReactNode;
118
197
  ref?: Ref<HTMLSpanElement>;
@@ -124,29 +203,61 @@ export type ContextMenuItemIndicatorProps = ComponentProps<"span"> & {
124
203
  forceMount?: boolean;
125
204
  };
126
205
 
127
- type ContextMenuRadioGroupBaseProps = Omit<ComponentProps<"li">, "role"> & {
206
+ /**
207
+ * Shared base for both {@link ContextMenuRadioGroupProps} variants — the
208
+ * `<li>` host props plus `children`, `ref`, and `asChild`. The managed
209
+ * `role` host attribute is omitted.
210
+ */
211
+ export type ContextMenuRadioGroupBaseProps = Omit<
212
+ ComponentProps<"li">,
213
+ "role"
214
+ > & {
128
215
  children?: ReactNode;
129
216
  ref?: Ref<HTMLLIElement>;
130
217
  asChild?: boolean;
131
218
  };
132
219
 
133
- type ContextMenuRadioGroupUncontrolledProps =
220
+ /**
221
+ * Uncontrolled variant of {@link ContextMenuRadioGroupProps}: the
222
+ * component owns the selected-value state. Pass `defaultValue` (or omit
223
+ * it); `onValueChange` is optional and the controlled `value` prop is
224
+ * forbidden.
225
+ */
226
+ export type ContextMenuRadioGroupUncontrolledProps =
134
227
  ContextMenuRadioGroupBaseProps & {
135
228
  defaultValue?: string;
136
229
  value?: never;
137
230
  onValueChange?: (value: string) => void;
138
231
  };
139
232
 
140
- type ContextMenuRadioGroupControlledProps = ContextMenuRadioGroupBaseProps & {
141
- defaultValue?: never;
142
- value: string;
143
- onValueChange: (value: string) => void;
144
- };
233
+ /**
234
+ * Controlled variant of {@link ContextMenuRadioGroupProps}: the parent
235
+ * owns the selected-value state. Pass `value` and `onValueChange`
236
+ * together; `defaultValue` is forbidden.
237
+ */
238
+ export type ContextMenuRadioGroupControlledProps =
239
+ ContextMenuRadioGroupBaseProps & {
240
+ defaultValue?: never;
241
+ value: string;
242
+ onValueChange: (value: string) => void;
243
+ };
145
244
 
245
+ /**
246
+ * Props for {@link ContextMenu.RadioGroup} — the container that tracks
247
+ * which {@link ContextMenu.RadioItem} is selected. A discriminated union
248
+ * of the uncontrolled ({@link ContextMenuRadioGroupUncontrolledProps})
249
+ * and controlled ({@link ContextMenuRadioGroupControlledProps}) variants.
250
+ */
146
251
  export type ContextMenuRadioGroupProps =
147
252
  | ContextMenuRadioGroupUncontrolledProps
148
253
  | ContextMenuRadioGroupControlledProps;
149
254
 
255
+ /**
256
+ * Props for {@link ContextMenu.RadioItem} — a mutually-exclusive choice
257
+ * within a {@link ContextMenu.RadioGroup}, identified by its required
258
+ * `value`. The managed `role`, `tabIndex`, `aria-checked`, and `onSelect`
259
+ * host attributes are omitted.
260
+ */
150
261
  export type ContextMenuRadioItemProps = Omit<
151
262
  ComponentProps<"li">,
152
263
  "role" | "tabIndex" | "aria-checked" | "onSelect"
@@ -159,26 +270,52 @@ export type ContextMenuRadioItemProps = Omit<
159
270
  onSelect?: (event: Event) => void;
160
271
  };
161
272
 
162
- type ContextMenuSubBaseProps = {
273
+ /**
274
+ * Shared base for both {@link ContextMenuSubProps} variants — just the
275
+ * `children` of the submenu.
276
+ */
277
+ export type ContextMenuSubBaseProps = {
163
278
  children?: ReactNode;
164
279
  };
165
280
 
166
- type ContextMenuSubUncontrolledProps = ContextMenuSubBaseProps & {
281
+ /**
282
+ * Uncontrolled variant of {@link ContextMenuSubProps}: the component owns
283
+ * the submenu open state. Pass `defaultOpen` (or omit it); `onOpenChange`
284
+ * is optional and the controlled `open` prop is forbidden.
285
+ */
286
+ export type ContextMenuSubUncontrolledProps = ContextMenuSubBaseProps & {
167
287
  defaultOpen?: boolean;
168
288
  open?: never;
169
289
  onOpenChange?: (open: boolean) => void;
170
290
  };
171
291
 
172
- type ContextMenuSubControlledProps = ContextMenuSubBaseProps & {
292
+ /**
293
+ * Controlled variant of {@link ContextMenuSubProps}: the parent owns the
294
+ * submenu open state. Pass `open` and `onOpenChange` together;
295
+ * `defaultOpen` is forbidden.
296
+ */
297
+ export type ContextMenuSubControlledProps = ContextMenuSubBaseProps & {
173
298
  defaultOpen?: never;
174
299
  open: boolean;
175
300
  onOpenChange: (open: boolean) => void;
176
301
  };
177
302
 
303
+ /**
304
+ * Props for {@link ContextMenu.Sub} — a nested submenu's open-state
305
+ * owner. A discriminated union of the uncontrolled
306
+ * ({@link ContextMenuSubUncontrolledProps}) and controlled
307
+ * ({@link ContextMenuSubControlledProps}) variants.
308
+ */
178
309
  export type ContextMenuSubProps =
179
310
  | ContextMenuSubUncontrolledProps
180
311
  | ContextMenuSubControlledProps;
181
312
 
313
+ /**
314
+ * Props for {@link ContextMenu.SubTrigger} — the `<li>` that opens its
315
+ * parent {@link ContextMenu.Sub} on hover or arrow key. The managed
316
+ * `role`, `tabIndex`, `aria-haspopup`, `aria-expanded`, and
317
+ * `aria-controls` host attributes are omitted; `disabled` suppresses it.
318
+ */
182
319
  export type ContextMenuSubTriggerProps = Omit<
183
320
  ComponentProps<"li">,
184
321
  "role" | "tabIndex" | "aria-haspopup" | "aria-expanded" | "aria-controls"
@@ -189,6 +326,12 @@ export type ContextMenuSubTriggerProps = Omit<
189
326
  disabled?: boolean;
190
327
  };
191
328
 
329
+ /**
330
+ * Props for {@link ContextMenu.SubContent} — the `<menu>` popover for a
331
+ * nested submenu's items. The managed `role`, `popover`, and `id`
332
+ * attributes are omitted; `asChild` merges the props onto a custom
333
+ * element.
334
+ */
192
335
  export type ContextMenuSubContentProps = Omit<
193
336
  ComponentProps<"menu">,
194
337
  "role" | "popover" | "id"
@@ -1,3 +1,5 @@
1
+ import type { ReactElement } from "react";
2
+
1
3
  import { DirectionContext } from "./DirectionContext";
2
4
  import { DirectionProviderProps } from "./types";
3
5
 
@@ -20,7 +22,10 @@ import { DirectionProviderProps } from "./types";
20
22
  * </DirectionProvider>
21
23
  * ```
22
24
  */
23
- export function DirectionProvider({ dir, children }: DirectionProviderProps) {
25
+ export function DirectionProvider({
26
+ dir,
27
+ children,
28
+ }: DirectionProviderProps): ReactElement {
24
29
  return (
25
30
  <DirectionContext.Provider value={dir}>
26
31
  {children}
@@ -28,4 +33,5 @@ export function DirectionProvider({ dir, children }: DirectionProviderProps) {
28
33
  );
29
34
  }
30
35
 
36
+ /** @internal */
31
37
  DirectionProvider.displayName = "DirectionProvider";
@@ -1,6 +1,6 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
 
3
- import { DirectionProvider, useDirection } from "..";
3
+ import { DirectionProvider, useDirection } from "../index.ts";
4
4
 
5
5
  function DirectionProbe() {
6
6
  return <span data-testid="probe">{useDirection()}</span>;
@@ -3,6 +3,7 @@ import { ReactNode } from "react";
3
3
  /** A reading direction — left-to-right or right-to-left. */
4
4
  export type Direction = "ltr" | "rtl";
5
5
 
6
+ /** Props for {@link DirectionProvider} — the `dir` broadcast to descendants. */
6
7
  export type DirectionProviderProps = {
7
8
  /** The reading direction broadcast to every descendant. */
8
9
  dir: Direction;
@@ -1,3 +1,5 @@
1
+ import type { ReactElement } from "react";
2
+
1
3
  import { DividerProps } from "./types";
2
4
 
3
5
  /**
@@ -43,7 +45,7 @@ export function Divider({
43
45
  orientation = "horizontal",
44
46
  className = "",
45
47
  ...rest
46
- }: DividerProps) {
48
+ }: DividerProps): ReactElement {
47
49
  return (
48
50
  <span
49
51
  role="separator"
@@ -54,4 +56,5 @@ export function Divider({
54
56
  );
55
57
  }
56
58
 
59
+ /** @internal */
57
60
  Divider.displayName = "Divider";
@@ -1,4 +1,4 @@
1
- import { Divider } from "..";
1
+ import { Divider } from "../index.ts";
2
2
  import { render, screen } from "@testing-library/react";
3
3
 
4
4
  describe("Divider component", () => {
@@ -1 +1,2 @@
1
- export * from './Divider';
1
+ export * from "./Divider";
2
+ export * from "./types";
@@ -1,5 +1,10 @@
1
1
  import { ComponentProps } from "react";
2
2
 
3
+ /**
4
+ * Props for the {@link Divider} component. Extends the native `<span>` props
5
+ * with an optional `orientation`.
6
+ */
3
7
  export type DividerProps = ComponentProps<"span"> & {
8
+ /** Axis the separator runs along. Defaults to `"horizontal"`. */
4
9
  orientation?: "horizontal" | "vertical";
5
10
  };