@primitiv-ui/react 0.1.1 → 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.
- package/LICENSE +21 -0
- package/package.json +2 -1
- package/src/AccessibleIcon/AccessibleIcon.tsx +1 -0
- package/src/AccessibleIcon/types.ts +4 -0
- package/src/Accordion/Accordion.tsx +23 -0
- package/src/Accordion/index.ts +2 -1
- package/src/Accordion/types.ts +55 -13
- package/src/Alert/Alert.tsx +1 -0
- package/src/Alert/types.ts +1 -0
- package/src/Avatar/Avatar.tsx +8 -4
- package/src/Avatar/AvatarContext.ts +2 -0
- package/src/Breadcrumb/Breadcrumb.tsx +15 -7
- package/src/Button/Button.tsx +1 -0
- package/src/Button/types.ts +4 -0
- package/src/Carousel/Carousel.tsx +9 -0
- package/src/Carousel/CarouselContext.ts +5 -2
- package/src/Carousel/types.ts +8 -0
- package/src/Checkbox/Checkbox.tsx +7 -3
- package/src/Checkbox/index.ts +1 -0
- package/src/Checkbox/types.ts +30 -3
- package/src/CheckboxCard/CheckboxCard.tsx +9 -8
- package/src/CheckboxCard/CheckboxCardContext.ts +9 -1
- package/src/CheckboxCard/hooks/useCheckboxCardRoot.ts +1 -1
- package/src/CheckboxCard/types.ts +21 -5
- package/src/Collapsible/Collapsible.tsx +15 -0
- package/src/Collapsible/index.ts +1 -0
- package/src/Collapsible/types.ts +45 -12
- package/src/ContextMenu/ContextMenu.tsx +40 -15
- package/src/ContextMenu/index.ts +2 -1
- package/src/ContextMenu/types.ts +159 -16
- package/src/DirectionProvider/DirectionProvider.tsx +1 -0
- package/src/DirectionProvider/types.ts +1 -0
- package/src/Divider/Divider.tsx +1 -0
- package/src/Divider/index.ts +2 -1
- package/src/Divider/types.ts +5 -0
- package/src/Dropdown/Dropdown.tsx +40 -15
- package/src/Dropdown/index.ts +2 -1
- package/src/Dropdown/types.ts +152 -24
- package/src/EmptyState/EmptyState.tsx +26 -14
- package/src/EmptyState/types.ts +2 -1
- package/src/Field/Field.tsx +14 -5
- package/src/Field/types.ts +4 -0
- package/src/Fieldset/Fieldset.tsx +17 -10
- package/src/Fieldset/types.ts +2 -0
- package/src/Input/Input.tsx +1 -0
- package/src/Input/types.ts +4 -0
- package/src/InputGroup/InputGroup.tsx +9 -4
- package/src/InputGroup/types.ts +9 -0
- package/src/MillerColumns/MillerColumns.tsx +19 -0
- package/src/MillerColumns/index.ts +1 -1
- package/src/MillerColumns/types.ts +67 -14
- package/src/Modal/Modal.tsx +1 -0
- package/src/Modal/ModalContext.ts +5 -2
- package/src/Modal/types.ts +51 -2
- package/src/Portal/Portal.tsx +1 -0
- package/src/Portal/types.ts +4 -0
- package/src/Progress/Progress.tsx +7 -3
- package/src/Progress/ProgressContext.ts +7 -0
- package/src/RadioCard/RadioCard.tsx +9 -4
- package/src/RadioCard/RadioCardContext.ts +7 -0
- package/src/RadioCard/RadioCardItemContext.ts +8 -0
- package/src/RadioCard/types.ts +24 -3
- package/src/RadioGroup/RadioGroup.tsx +9 -4
- package/src/RadioGroup/index.ts +1 -0
- package/src/RadioGroup/types.ts +34 -3
- package/src/Select/Select.tsx +16 -5
- package/src/Select/index.ts +1 -1
- package/src/Select/types.ts +18 -3
- package/src/Slider/Slider.tsx +10 -5
- package/src/Slider/SliderContext.ts +3 -0
- package/src/Slider/types.ts +12 -3
- package/src/Status/Status.tsx +1 -0
- package/src/Status/types.ts +4 -0
- package/src/Switch/Switch.tsx +8 -3
- package/src/Switch/SwitchContext.ts +4 -0
- package/src/Switch/types.ts +24 -3
- package/src/Table/Table.tsx +44 -24
- package/src/Table/index.ts +2 -1
- package/src/Tabs/Tabs.tsx +7 -2
- package/src/Tabs/TabsContext.ts +7 -2
- package/src/Tabs/types.ts +35 -1
- package/src/Textarea/Textarea.tsx +1 -0
- package/src/Textarea/types.ts +4 -0
- package/src/Toggle/Toggle.tsx +1 -0
- package/src/Toggle/types.ts +7 -3
- package/src/ToggleGroup/ToggleGroup.tsx +9 -3
- package/src/ToggleGroup/types.ts +45 -5
- package/src/Tooltip/Tooltip.tsx +25 -7
- package/src/Tooltip/index.ts +1 -0
- package/src/Tooltip/types.ts +50 -2
- package/src/Tree/Tree.tsx +46 -1
- package/src/Tree/index.ts +1 -1
- package/src/Tree/types.ts +39 -7
- package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
- package/src/VisuallyHidden/types.ts +4 -0
- package/src/index.ts +1 -0
- package/src/types.ts +1 -0
package/src/Table/Table.tsx
CHANGED
|
@@ -42,11 +42,12 @@ import {
|
|
|
42
42
|
* </Table.Root>
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
function
|
|
45
|
+
export function TableRoot({ children, ...rest }: TableRootProps): ReactElement {
|
|
46
46
|
return <table {...rest}>{children}</table>;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
/** @internal */
|
|
50
|
+
TableRoot.displayName = "Table";
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* Groups header rows inside a `<thead>` element.
|
|
@@ -65,10 +66,11 @@ Table.displayName = "Table";
|
|
|
65
66
|
* </Table.Head>
|
|
66
67
|
* ```
|
|
67
68
|
*/
|
|
68
|
-
function TableHead({ children, ...rest }: TableHeadProps): ReactElement {
|
|
69
|
+
export function TableHead({ children, ...rest }: TableHeadProps): ReactElement {
|
|
69
70
|
return <thead {...rest}>{children}</thead>;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
/** @internal */
|
|
72
74
|
TableHead.displayName = "TableHead";
|
|
73
75
|
|
|
74
76
|
/**
|
|
@@ -89,10 +91,11 @@ TableHead.displayName = "TableHead";
|
|
|
89
91
|
* </Table.Body>
|
|
90
92
|
* ```
|
|
91
93
|
*/
|
|
92
|
-
function TableBody({ children, ...rest }: TableBodyProps): ReactElement {
|
|
94
|
+
export function TableBody({ children, ...rest }: TableBodyProps): ReactElement {
|
|
93
95
|
return <tbody {...rest}>{children}</tbody>;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
/** @internal */
|
|
96
99
|
TableBody.displayName = "TableBody";
|
|
97
100
|
|
|
98
101
|
/**
|
|
@@ -112,10 +115,14 @@ TableBody.displayName = "TableBody";
|
|
|
112
115
|
* </Table.Footer>
|
|
113
116
|
* ```
|
|
114
117
|
*/
|
|
115
|
-
function TableFooter({
|
|
118
|
+
export function TableFooter({
|
|
119
|
+
children,
|
|
120
|
+
...rest
|
|
121
|
+
}: TableFooterProps): ReactElement {
|
|
116
122
|
return <tfoot {...rest}>{children}</tfoot>;
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
/** @internal */
|
|
119
126
|
TableFooter.displayName = "TableFooter";
|
|
120
127
|
|
|
121
128
|
/**
|
|
@@ -134,10 +141,11 @@ TableFooter.displayName = "TableFooter";
|
|
|
134
141
|
* </Table.Row>
|
|
135
142
|
* ```
|
|
136
143
|
*/
|
|
137
|
-
function TableRow({ children, ...rest }: TableRowProps): ReactElement {
|
|
144
|
+
export function TableRow({ children, ...rest }: TableRowProps): ReactElement {
|
|
138
145
|
return <tr {...rest}>{children}</tr>;
|
|
139
146
|
}
|
|
140
147
|
|
|
148
|
+
/** @internal */
|
|
141
149
|
TableRow.displayName = "TableRow";
|
|
142
150
|
|
|
143
151
|
/**
|
|
@@ -168,10 +176,14 @@ TableRow.displayName = "TableRow";
|
|
|
168
176
|
* <Table.Header scope="row">Alice</Table.Header>
|
|
169
177
|
* ```
|
|
170
178
|
*/
|
|
171
|
-
function TableHeader({
|
|
179
|
+
export function TableHeader({
|
|
180
|
+
children,
|
|
181
|
+
...rest
|
|
182
|
+
}: TableHeaderProps): ReactElement {
|
|
172
183
|
return <th {...rest}>{children}</th>;
|
|
173
184
|
}
|
|
174
185
|
|
|
186
|
+
/** @internal */
|
|
175
187
|
TableHeader.displayName = "TableHeader";
|
|
176
188
|
|
|
177
189
|
/**
|
|
@@ -190,10 +202,11 @@ TableHeader.displayName = "TableHeader";
|
|
|
190
202
|
* <Table.Cell colSpan={2}>Full-width note</Table.Cell>
|
|
191
203
|
* ```
|
|
192
204
|
*/
|
|
193
|
-
function TableCell({ children, ...rest }: TableCellProps): ReactElement {
|
|
205
|
+
export function TableCell({ children, ...rest }: TableCellProps): ReactElement {
|
|
194
206
|
return <td {...rest}>{children}</td>;
|
|
195
207
|
}
|
|
196
208
|
|
|
209
|
+
/** @internal */
|
|
197
210
|
TableCell.displayName = "TableCell";
|
|
198
211
|
|
|
199
212
|
/**
|
|
@@ -224,7 +237,7 @@ TableCell.displayName = "TableCell";
|
|
|
224
237
|
* </Table.ScrollArea>
|
|
225
238
|
* ```
|
|
226
239
|
*/
|
|
227
|
-
function TableScrollArea({
|
|
240
|
+
export function TableScrollArea({
|
|
228
241
|
children,
|
|
229
242
|
style,
|
|
230
243
|
...rest
|
|
@@ -244,6 +257,7 @@ function TableScrollArea({
|
|
|
244
257
|
);
|
|
245
258
|
}
|
|
246
259
|
|
|
260
|
+
/** @internal */
|
|
247
261
|
TableScrollArea.displayName = "TableScrollArea";
|
|
248
262
|
|
|
249
263
|
/**
|
|
@@ -279,7 +293,7 @@ TableScrollArea.displayName = "TableScrollArea";
|
|
|
279
293
|
* </Table.Root>
|
|
280
294
|
* ```
|
|
281
295
|
*/
|
|
282
|
-
function TableCaption({
|
|
296
|
+
export function TableCaption({
|
|
283
297
|
children,
|
|
284
298
|
captionSide = "bottom",
|
|
285
299
|
...rest
|
|
@@ -291,10 +305,15 @@ function TableCaption({
|
|
|
291
305
|
);
|
|
292
306
|
}
|
|
293
307
|
|
|
308
|
+
/** @internal */
|
|
294
309
|
TableCaption.displayName = "TableCaption";
|
|
295
310
|
|
|
296
|
-
|
|
297
|
-
|
|
311
|
+
/**
|
|
312
|
+
* The shape of the exported `Table` value — callable as `Table.Root` and
|
|
313
|
+
* carrying every sub-component as a static property.
|
|
314
|
+
*/
|
|
315
|
+
export type TableCompound = typeof TableRoot & {
|
|
316
|
+
Root: typeof TableRoot;
|
|
298
317
|
Head: typeof TableHead;
|
|
299
318
|
Body: typeof TableBody;
|
|
300
319
|
Footer: typeof TableFooter;
|
|
@@ -305,18 +324,6 @@ type TableCompound = typeof Table & {
|
|
|
305
324
|
Caption: typeof TableCaption;
|
|
306
325
|
};
|
|
307
326
|
|
|
308
|
-
const TableCompound: TableCompound = Object.assign(Table, {
|
|
309
|
-
Root: Table,
|
|
310
|
-
Head: TableHead,
|
|
311
|
-
Body: TableBody,
|
|
312
|
-
Footer: TableFooter,
|
|
313
|
-
Row: TableRow,
|
|
314
|
-
Header: TableHeader,
|
|
315
|
-
Cell: TableCell,
|
|
316
|
-
ScrollArea: TableScrollArea,
|
|
317
|
-
Caption: TableCaption,
|
|
318
|
-
});
|
|
319
|
-
|
|
320
327
|
/**
|
|
321
328
|
* Headless, accessible **Table** — a compound component wrapping standard
|
|
322
329
|
* HTML table elements with zero styles.
|
|
@@ -381,6 +388,19 @@ const TableCompound: TableCompound = Object.assign(Table, {
|
|
|
381
388
|
* @see {@link TableCaption} for caption placement and why it beats `aria-label`.
|
|
382
389
|
* @see {@link TableScrollArea} for the horizontal-scroll style caveat.
|
|
383
390
|
*/
|
|
391
|
+
const TableCompound: TableCompound = Object.assign(TableRoot, {
|
|
392
|
+
Root: TableRoot,
|
|
393
|
+
Head: TableHead,
|
|
394
|
+
Body: TableBody,
|
|
395
|
+
Footer: TableFooter,
|
|
396
|
+
Row: TableRow,
|
|
397
|
+
Header: TableHeader,
|
|
398
|
+
Cell: TableCell,
|
|
399
|
+
ScrollArea: TableScrollArea,
|
|
400
|
+
Caption: TableCaption,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
/** @internal */
|
|
384
404
|
TableCompound.displayName = "Table";
|
|
385
405
|
|
|
386
406
|
export { TableCompound as Table };
|
package/src/Table/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Table";
|
|
2
|
+
export * from "./types";
|
package/src/Tabs/Tabs.tsx
CHANGED
|
@@ -102,7 +102,7 @@ import type {
|
|
|
102
102
|
* <button onClick={() => ref.current?.setActiveTab("two")}>Go to two</button>
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
const TabsRoot: ForwardRefExoticComponent<
|
|
105
|
+
export const TabsRoot: ForwardRefExoticComponent<
|
|
106
106
|
PropsWithoutRef<TabsRootProps> & RefAttributes<TabsImperativeApi>
|
|
107
107
|
> = forwardRef<TabsImperativeApi, TabsRootProps>(function TabsRoot(
|
|
108
108
|
{
|
|
@@ -196,6 +196,7 @@ export function TabsList({
|
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/** @internal */
|
|
199
200
|
TabsList.displayName = "TabsList";
|
|
200
201
|
|
|
201
202
|
/**
|
|
@@ -316,6 +317,7 @@ export function TabsTrigger<T extends HTMLElement = HTMLButtonElement>({
|
|
|
316
317
|
);
|
|
317
318
|
}
|
|
318
319
|
|
|
320
|
+
/** @internal */
|
|
319
321
|
TabsTrigger.displayName = "TabsTrigger";
|
|
320
322
|
|
|
321
323
|
/**
|
|
@@ -381,9 +383,12 @@ export function TabsContent({
|
|
|
381
383
|
);
|
|
382
384
|
}
|
|
383
385
|
|
|
386
|
+
/** @internal */
|
|
384
387
|
TabsContent.displayName = "TabsContent";
|
|
385
388
|
|
|
386
|
-
|
|
389
|
+
/** Type of the {@link Tabs} compound: the callable `Tabs.Root` component
|
|
390
|
+
* augmented with its sub-components as static properties. */
|
|
391
|
+
export type TabsCompound = typeof TabsRoot & {
|
|
387
392
|
Root: typeof TabsRoot;
|
|
388
393
|
List: typeof TabsList;
|
|
389
394
|
Trigger: typeof TabsTrigger;
|
package/src/Tabs/TabsContext.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "react";
|
|
1
|
+
import type { Context, Provider } from "react";
|
|
2
2
|
import { createStrictContext } from "../utils/index.ts";
|
|
3
3
|
|
|
4
4
|
import { TabsContextValue } from "./types";
|
|
@@ -8,9 +8,14 @@ const tabsContextPair = createStrictContext<TabsContextValue>(
|
|
|
8
8
|
"TabsContext",
|
|
9
9
|
);
|
|
10
10
|
|
|
11
|
+
/** Strict React context carrying the {@link TabsContextValue} from `Tabs.Root`
|
|
12
|
+
* to its descendants. `null` when read outside a `Tabs.Root`. */
|
|
11
13
|
export const TabsContext: Context<TabsContextValue | null> = tabsContextPair[0];
|
|
14
|
+
/** Reads the {@link TabsContextValue}; throws when used outside a `Tabs.Root`. */
|
|
12
15
|
export const useTabsContext: () => TabsContextValue = tabsContextPair[1];
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
/** Provider component for {@link TabsContext}, used by `Tabs.Root` to supply the
|
|
18
|
+
* {@link TabsContextValue} to its descendants. */
|
|
19
|
+
const TabsProvider: Provider<TabsContextValue | null> = TabsContext.Provider;
|
|
15
20
|
|
|
16
21
|
export { TabsProvider };
|
package/src/Tabs/types.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { ComponentProps, Ref } from "react";
|
|
2
2
|
|
|
3
|
+
/** Layout axis of the tab list. `"horizontal"` arranges triggers in a row and
|
|
4
|
+
* binds ArrowLeft/ArrowRight; `"vertical"` stacks them and binds
|
|
5
|
+
* ArrowUp/ArrowDown. */
|
|
3
6
|
export type TabsOrientation = "horizontal" | "vertical";
|
|
4
7
|
|
|
8
|
+
/** Reading direction of the tab list. In `"rtl"` the horizontal arrow keys are
|
|
9
|
+
* mirrored so navigation follows the visual order. */
|
|
5
10
|
export type TabsReadingDirection = "ltr" | "rtl";
|
|
6
11
|
|
|
12
|
+
/** When a focused trigger becomes active. `"automatic"` activates a tab as soon
|
|
13
|
+
* as it receives focus via the arrow keys; `"manual"` requires Enter/Space. */
|
|
7
14
|
export type TabsActivationMode = "automatic" | "manual";
|
|
8
15
|
|
|
9
16
|
/**
|
|
@@ -17,22 +24,34 @@ export type TabsActivationMode = "automatic" | "manual";
|
|
|
17
24
|
*/
|
|
18
25
|
export type TabMetadata = { index: number; name: string };
|
|
19
26
|
|
|
27
|
+
/** Props common to both controlled and uncontrolled `Tabs.Root` usage. */
|
|
20
28
|
export type BaseTabsRootProps = {
|
|
29
|
+
/** Fired on every user-driven activation with the activated tab's metadata. */
|
|
21
30
|
onChange?: ({ index, name }: TabMetadata) => void;
|
|
22
31
|
};
|
|
23
32
|
|
|
33
|
+
/** Uncontrolled `Tabs.Root` props: the component owns the active tab, seeded by
|
|
34
|
+
* an optional `defaultValue`. Mutually exclusive with the controlled props. */
|
|
24
35
|
export type UncontrolledTabsRootProps = {
|
|
36
|
+
/** Value of the tab active on first render. */
|
|
25
37
|
defaultValue?: string;
|
|
26
38
|
value?: never;
|
|
27
39
|
onValueChange?: never;
|
|
28
40
|
};
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
/** Controlled `Tabs.Root` props: the caller owns the active tab via `value` and
|
|
43
|
+
* is notified of activation requests through `onValueChange`. */
|
|
44
|
+
export type ControlledTabsRootProps = {
|
|
45
|
+
/** Value of the currently active tab. */
|
|
31
46
|
value: string;
|
|
47
|
+
/** Called with the requested value when the user activates a tab. */
|
|
32
48
|
onValueChange: (value: string) => void;
|
|
33
49
|
defaultValue?: never;
|
|
34
50
|
};
|
|
35
51
|
|
|
52
|
+
/** Props for `Tabs.Root` — the state owner and context provider. Extends the
|
|
53
|
+
* native `<div>` props (minus `onChange`) and resolves to either the
|
|
54
|
+
* controlled or uncontrolled prop shape. */
|
|
36
55
|
export type TabsRootProps = Omit<ComponentProps<"div">, "onChange"> & {
|
|
37
56
|
orientation?: TabsOrientation;
|
|
38
57
|
dir?: TabsReadingDirection;
|
|
@@ -46,6 +65,9 @@ export type TabsRootProps = Omit<ComponentProps<"div">, "onChange"> & {
|
|
|
46
65
|
} & BaseTabsRootProps &
|
|
47
66
|
(UncontrolledTabsRootProps | ControlledTabsRootProps);
|
|
48
67
|
|
|
68
|
+
/** The value shared by `Tabs.Root` with its descendants through context:
|
|
69
|
+
* resolved configuration, the active tab and its setter, and the registry of
|
|
70
|
+
* triggers used for roving focus and keyboard navigation. */
|
|
49
71
|
export type TabsContextValue = {
|
|
50
72
|
orientation: TabsOrientation;
|
|
51
73
|
dir: TabsReadingDirection;
|
|
@@ -67,6 +89,9 @@ export type TabsContextValue = {
|
|
|
67
89
|
focusTrigger: (value: string) => void;
|
|
68
90
|
};
|
|
69
91
|
|
|
92
|
+
/** Props for `Tabs.List` — the `role="tablist"` container. Requires exactly one
|
|
93
|
+
* accessible name source: either an inline `label` or an `ariaLabelledBy` id
|
|
94
|
+
* referencing existing label text. */
|
|
70
95
|
export type TabsListProps = Omit<
|
|
71
96
|
ComponentProps<"div">,
|
|
72
97
|
"label" | "aria-labelledby"
|
|
@@ -75,6 +100,10 @@ export type TabsListProps = Omit<
|
|
|
75
100
|
| { label: string; ariaLabelledBy?: never }
|
|
76
101
|
| { label?: never; ariaLabelledBy: string }
|
|
77
102
|
);
|
|
103
|
+
/** Props for `Tabs.Trigger` — an individual `role="tab"` button. Identified by
|
|
104
|
+
* its required `value`, which links it to the `Tabs.Content` of the same value.
|
|
105
|
+
* The element type defaults to `HTMLButtonElement` and can be overridden via
|
|
106
|
+
* `asChild` and the `ref` type parameter. */
|
|
78
107
|
export type TabsTriggerProps<T extends HTMLElement = HTMLButtonElement> = Omit<
|
|
79
108
|
ComponentProps<"button">,
|
|
80
109
|
"ref"
|
|
@@ -90,10 +119,15 @@ export type TabsTriggerProps<T extends HTMLElement = HTMLButtonElement> = Omit<
|
|
|
90
119
|
ref?: Ref<T>;
|
|
91
120
|
};
|
|
92
121
|
|
|
122
|
+
/** Props for `Tabs.Content` — a `role="tabpanel"`. Its required `value` links
|
|
123
|
+
* it to the `Tabs.Trigger` of the same value. */
|
|
93
124
|
export type TabsContentProps = ComponentProps<"div"> & {
|
|
125
|
+
/** Value of the trigger this panel belongs to. */
|
|
94
126
|
value: string;
|
|
95
127
|
};
|
|
96
128
|
|
|
129
|
+
/** Imperative handle exposed on the `Tabs.Root` ref for programmatic control. */
|
|
97
130
|
export type TabsImperativeApi = {
|
|
131
|
+
/** Activate the tab with the given value. */
|
|
98
132
|
setActiveTab: (value: string) => void;
|
|
99
133
|
};
|
package/src/Textarea/types.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, Ref } from "react";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Props for {@link Textarea} — all native `<textarea>` attributes plus the
|
|
5
|
+
* `asChild` escape hatch and a typed `ref`.
|
|
6
|
+
*/
|
|
3
7
|
export type TextareaProps = ComponentProps<"textarea"> & {
|
|
4
8
|
asChild?: boolean;
|
|
5
9
|
ref?: Ref<HTMLTextAreaElement>;
|
package/src/Toggle/Toggle.tsx
CHANGED
package/src/Toggle/types.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, ReactNode, Ref } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** Uncontrolled `Toggle` props: seed with `defaultPressed`; `pressed`/`onPressedChange` are disallowed. */
|
|
4
|
+
export type UncontrolledToggleProps = {
|
|
4
5
|
defaultPressed?: boolean;
|
|
5
6
|
pressed?: never;
|
|
6
7
|
onPressedChange?: never;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
/** Controlled `Toggle` props: drive with `pressed` and `onPressedChange`; `defaultPressed` is disallowed. */
|
|
11
|
+
export type ControlledToggleProps = {
|
|
10
12
|
pressed: boolean;
|
|
11
13
|
onPressedChange: (pressed: boolean) => void;
|
|
12
14
|
defaultPressed?: never;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
/** Props common to both `Toggle` modes: `disabled`, `asChild`, `children`, `ref`, and the native `<button>` attributes (minus `type`). */
|
|
18
|
+
export type ToggleBaseProps = {
|
|
16
19
|
disabled?: boolean;
|
|
17
20
|
asChild?: boolean;
|
|
18
21
|
children?: ReactNode;
|
|
19
22
|
ref?: Ref<HTMLButtonElement>;
|
|
20
23
|
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type">;
|
|
21
24
|
|
|
25
|
+
/** Props for the `Toggle` button — base props combined with the controlled/uncontrolled discriminated union. */
|
|
22
26
|
export type ToggleProps = ToggleBaseProps &
|
|
23
27
|
(UncontrolledToggleProps | ControlledToggleProps);
|
|
@@ -63,7 +63,7 @@ import { ToggleGroupItemProps, ToggleGroupRootProps } from "./types";
|
|
|
63
63
|
* </ToggleGroup.Root>
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
function ToggleGroupRoot({
|
|
66
|
+
export function ToggleGroupRoot({
|
|
67
67
|
type,
|
|
68
68
|
defaultValue,
|
|
69
69
|
value: controlledValue,
|
|
@@ -139,6 +139,7 @@ function ToggleGroupRoot({
|
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
/** @internal */
|
|
142
143
|
ToggleGroupRoot.displayName = "ToggleGroupRoot";
|
|
143
144
|
|
|
144
145
|
/**
|
|
@@ -168,7 +169,7 @@ ToggleGroupRoot.displayName = "ToggleGroupRoot";
|
|
|
168
169
|
*
|
|
169
170
|
* @throws if rendered outside a `ToggleGroup.Root`.
|
|
170
171
|
*/
|
|
171
|
-
function ToggleGroupItem({
|
|
172
|
+
export function ToggleGroupItem({
|
|
172
173
|
value,
|
|
173
174
|
disabled,
|
|
174
175
|
asChild = false,
|
|
@@ -251,9 +252,14 @@ function ToggleGroupItem({
|
|
|
251
252
|
);
|
|
252
253
|
}
|
|
253
254
|
|
|
255
|
+
/** @internal */
|
|
254
256
|
ToggleGroupItem.displayName = "ToggleGroupItem";
|
|
255
257
|
|
|
256
|
-
|
|
258
|
+
/**
|
|
259
|
+
* The shape of the exported `ToggleGroup` value — callable as
|
|
260
|
+
* `ToggleGroup.Root` and carrying `Root` and `Item` as static properties.
|
|
261
|
+
*/
|
|
262
|
+
export type TToggleGroupCompound = typeof ToggleGroupRoot & {
|
|
257
263
|
Root: typeof ToggleGroupRoot;
|
|
258
264
|
Item: typeof ToggleGroupItem;
|
|
259
265
|
};
|
package/src/ToggleGroup/types.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { HTMLAttributes, ButtonHTMLAttributes, ReactNode, Ref } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Mode-independent props shared by every `ToggleGroup.Root` variant —
|
|
5
|
+
* orientation, direction, `asChild`, children, and the ref. Combined with
|
|
6
|
+
* a mode-specific arm to form {@link ToggleGroupRootProps}.
|
|
7
|
+
*/
|
|
8
|
+
export type ToggleGroupRootBaseProps = Omit<
|
|
9
|
+
HTMLAttributes<HTMLDivElement>,
|
|
10
|
+
"dir"
|
|
11
|
+
> & {
|
|
4
12
|
orientation?: "horizontal" | "vertical";
|
|
5
13
|
dir?: "ltr" | "rtl";
|
|
6
14
|
asChild?: boolean;
|
|
@@ -8,34 +16,56 @@ type ToggleGroupRootBaseProps = Omit<HTMLAttributes<HTMLDivElement>, "dir"> & {
|
|
|
8
16
|
ref?: Ref<HTMLDivElement>;
|
|
9
17
|
};
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Single-selection mode, uncontrolled — at most one item pressed, with the
|
|
21
|
+
* initial value supplied via `defaultValue`.
|
|
22
|
+
*/
|
|
23
|
+
export type SingleUncontrolledProps = {
|
|
12
24
|
type: "single";
|
|
13
25
|
defaultValue?: string;
|
|
14
26
|
value?: never;
|
|
15
27
|
onValueChange?: never;
|
|
16
28
|
};
|
|
17
29
|
|
|
18
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Single-selection mode, controlled — the pressed value is owned by the
|
|
32
|
+
* caller via `value` / `onValueChange`.
|
|
33
|
+
*/
|
|
34
|
+
export type SingleControlledProps = {
|
|
19
35
|
type: "single";
|
|
20
36
|
value: string | undefined;
|
|
21
37
|
onValueChange: (value: string | undefined) => void;
|
|
22
38
|
defaultValue?: never;
|
|
23
39
|
};
|
|
24
40
|
|
|
25
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Multiple-selection mode, uncontrolled — items toggle independently, with
|
|
43
|
+
* the initial set supplied via `defaultValue`.
|
|
44
|
+
*/
|
|
45
|
+
export type MultipleUncontrolledProps = {
|
|
26
46
|
type: "multiple";
|
|
27
47
|
defaultValue?: string[];
|
|
28
48
|
value?: never;
|
|
29
49
|
onValueChange?: never;
|
|
30
50
|
};
|
|
31
51
|
|
|
32
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Multiple-selection mode, controlled — the set of pressed values is owned
|
|
54
|
+
* by the caller via `value` / `onValueChange`.
|
|
55
|
+
*/
|
|
56
|
+
export type MultipleControlledProps = {
|
|
33
57
|
type: "multiple";
|
|
34
58
|
value: string[];
|
|
35
59
|
onValueChange: (value: string[]) => void;
|
|
36
60
|
defaultValue?: never;
|
|
37
61
|
};
|
|
38
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Props for `ToggleGroup.Root`. Combines the shared
|
|
65
|
+
* {@link ToggleGroupRootBaseProps} with one mode-specific arm — single or
|
|
66
|
+
* multiple, controlled or uncontrolled — so the `value` / `defaultValue` /
|
|
67
|
+
* `onValueChange` shape is enforced per `type`.
|
|
68
|
+
*/
|
|
39
69
|
export type ToggleGroupRootProps = ToggleGroupRootBaseProps &
|
|
40
70
|
(
|
|
41
71
|
| SingleUncontrolledProps
|
|
@@ -44,6 +74,11 @@ export type ToggleGroupRootProps = ToggleGroupRootBaseProps &
|
|
|
44
74
|
| MultipleControlledProps
|
|
45
75
|
);
|
|
46
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Props for `ToggleGroup.Item` — a pressable toggle button. `value`
|
|
79
|
+
* identifies the item within the group; `asChild` merges the behaviour
|
|
80
|
+
* onto a custom child element.
|
|
81
|
+
*/
|
|
47
82
|
export type ToggleGroupItemProps = Omit<
|
|
48
83
|
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
49
84
|
"type"
|
|
@@ -54,6 +89,11 @@ export type ToggleGroupItemProps = Omit<
|
|
|
54
89
|
ref?: Ref<HTMLButtonElement>;
|
|
55
90
|
};
|
|
56
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Context shared from `ToggleGroup.Root` to its items — the pressed
|
|
94
|
+
* values, the toggle action, item registration for roving tabindex, and
|
|
95
|
+
* the resolved orientation / direction.
|
|
96
|
+
*/
|
|
57
97
|
export type ToggleGroupContextValue = {
|
|
58
98
|
value: string[];
|
|
59
99
|
toggle: (itemValue: string) => void;
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -35,7 +35,7 @@ import type {
|
|
|
35
35
|
* </Tooltip.Provider>
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
function TooltipProviderComponent({
|
|
38
|
+
export function TooltipProviderComponent({
|
|
39
39
|
children,
|
|
40
40
|
delayDuration = 700,
|
|
41
41
|
skipDelayDuration = 300,
|
|
@@ -51,6 +51,7 @@ function TooltipProviderComponent({
|
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** @internal */
|
|
54
55
|
TooltipProviderComponent.displayName = "TooltipProvider";
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -70,7 +71,7 @@ TooltipProviderComponent.displayName = "TooltipProvider";
|
|
|
70
71
|
* </Tooltip.Root>
|
|
71
72
|
* ```
|
|
72
73
|
*/
|
|
73
|
-
function TooltipRoot({
|
|
74
|
+
export function TooltipRoot({
|
|
74
75
|
children,
|
|
75
76
|
defaultOpen,
|
|
76
77
|
open,
|
|
@@ -89,6 +90,7 @@ function TooltipRoot({
|
|
|
89
90
|
return <TooltipProvider value={contextValue}>{children}</TooltipProvider>;
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
/** @internal */
|
|
92
94
|
TooltipRoot.displayName = "TooltipRoot";
|
|
93
95
|
|
|
94
96
|
/**
|
|
@@ -109,7 +111,7 @@ TooltipRoot.displayName = "TooltipRoot";
|
|
|
109
111
|
* </Tooltip.Trigger>
|
|
110
112
|
* ```
|
|
111
113
|
*/
|
|
112
|
-
function TooltipTrigger({
|
|
114
|
+
export function TooltipTrigger({
|
|
113
115
|
ref,
|
|
114
116
|
asChild = false,
|
|
115
117
|
onPointerEnter,
|
|
@@ -136,6 +138,7 @@ function TooltipTrigger({
|
|
|
136
138
|
return <button ref={ref} type={type ?? "button"} {...getTriggerProps()} />;
|
|
137
139
|
}
|
|
138
140
|
|
|
141
|
+
/** @internal */
|
|
139
142
|
TooltipTrigger.displayName = "TooltipTrigger";
|
|
140
143
|
|
|
141
144
|
/**
|
|
@@ -154,7 +157,7 @@ TooltipTrigger.displayName = "TooltipTrigger";
|
|
|
154
157
|
* </Tooltip.Portal>
|
|
155
158
|
* ```
|
|
156
159
|
*/
|
|
157
|
-
function TooltipPortal({
|
|
160
|
+
export function TooltipPortal({
|
|
158
161
|
children,
|
|
159
162
|
container,
|
|
160
163
|
forceMount,
|
|
@@ -166,6 +169,7 @@ function TooltipPortal({
|
|
|
166
169
|
return <Portal container={container}>{children}</Portal>;
|
|
167
170
|
}
|
|
168
171
|
|
|
172
|
+
/** @internal */
|
|
169
173
|
TooltipPortal.displayName = "TooltipPortal";
|
|
170
174
|
|
|
171
175
|
/**
|
|
@@ -196,7 +200,7 @@ TooltipPortal.displayName = "TooltipPortal";
|
|
|
196
200
|
* </Tooltip.Content>
|
|
197
201
|
* ```
|
|
198
202
|
*/
|
|
199
|
-
function TooltipContent({
|
|
203
|
+
export function TooltipContent({
|
|
200
204
|
ref,
|
|
201
205
|
forceMount,
|
|
202
206
|
onEscapeKeyDown,
|
|
@@ -219,6 +223,7 @@ function TooltipContent({
|
|
|
219
223
|
return <div ref={composeRefs(internalRef, ref)} {...getContentProps()} />;
|
|
220
224
|
}
|
|
221
225
|
|
|
226
|
+
/** @internal */
|
|
222
227
|
TooltipContent.displayName = "TooltipContent";
|
|
223
228
|
|
|
224
229
|
/**
|
|
@@ -236,7 +241,7 @@ TooltipContent.displayName = "TooltipContent";
|
|
|
236
241
|
* </Tooltip.Content>
|
|
237
242
|
* ```
|
|
238
243
|
*/
|
|
239
|
-
function TooltipArrow({
|
|
244
|
+
export function TooltipArrow({
|
|
240
245
|
ref,
|
|
241
246
|
asChild = false,
|
|
242
247
|
...rest
|
|
@@ -248,9 +253,11 @@ function TooltipArrow({
|
|
|
248
253
|
return <span ref={ref} {...rest} />;
|
|
249
254
|
}
|
|
250
255
|
|
|
256
|
+
/** @internal */
|
|
251
257
|
TooltipArrow.displayName = "TooltipArrow";
|
|
252
258
|
|
|
253
|
-
|
|
259
|
+
/** Type of the {@link Tooltip} compound: the root callable plus its attached sub-components. */
|
|
260
|
+
export type TooltipCompound = typeof TooltipRoot & {
|
|
254
261
|
Provider: typeof TooltipProviderComponent;
|
|
255
262
|
Root: typeof TooltipRoot;
|
|
256
263
|
Trigger: typeof TooltipTrigger;
|
|
@@ -259,6 +266,16 @@ type TooltipCompound = typeof TooltipRoot & {
|
|
|
259
266
|
Arrow: typeof TooltipArrow;
|
|
260
267
|
};
|
|
261
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Headless, accessible **Tooltip** — a compound component implementing the
|
|
271
|
+
* [WAI-ARIA tooltip pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/):
|
|
272
|
+
* a deferred, hoverable label anchored to a trigger, with a shared
|
|
273
|
+
* {@link Tooltip.Provider} governing open / skip delays across a group. Zero
|
|
274
|
+
* styles ship.
|
|
275
|
+
*
|
|
276
|
+
* The default export is the `Root`; sub-components are attached as static
|
|
277
|
+
* properties (`Tooltip.Provider`, `Tooltip.Trigger`, `Tooltip.Content`, …).
|
|
278
|
+
*/
|
|
262
279
|
const TooltipCompound: TooltipCompound = Object.assign(TooltipRoot, {
|
|
263
280
|
Provider: TooltipProviderComponent,
|
|
264
281
|
Root: TooltipRoot,
|
|
@@ -268,6 +285,7 @@ const TooltipCompound: TooltipCompound = Object.assign(TooltipRoot, {
|
|
|
268
285
|
Arrow: TooltipArrow,
|
|
269
286
|
});
|
|
270
287
|
|
|
288
|
+
/** @internal */
|
|
271
289
|
TooltipCompound.displayName = "Tooltip";
|
|
272
290
|
|
|
273
291
|
export { TooltipCompound as Tooltip };
|
package/src/Tooltip/index.ts
CHANGED