@primitiv-ui/react 0.1.1 → 0.1.3
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/Tooltip/types.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode } from "react";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Context published by {@link Tooltip.Provider} — the shared open / skip
|
|
5
|
+
* delays and the group-wide open coordination callbacks used to suppress
|
|
6
|
+
* the open delay while another tooltip in the group is already showing.
|
|
7
|
+
*/
|
|
3
8
|
export type TooltipProviderContextValue = {
|
|
4
9
|
delayDuration: number;
|
|
5
10
|
skipDelayDuration: number;
|
|
@@ -8,6 +13,11 @@ export type TooltipProviderContextValue = {
|
|
|
8
13
|
onCloseGlobally: () => void;
|
|
9
14
|
};
|
|
10
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Context published by {@link Tooltip.Root} to its descendants — the live
|
|
18
|
+
* `open` state, the content `id` for ARIA wiring, and the timing callbacks
|
|
19
|
+
* the trigger and content use to open / close with the correct delays.
|
|
20
|
+
*/
|
|
11
21
|
export type TooltipContextValue = {
|
|
12
22
|
open: boolean;
|
|
13
23
|
contentId: string;
|
|
@@ -19,46 +29,84 @@ export type TooltipContextValue = {
|
|
|
19
29
|
cancelGrace: () => void;
|
|
20
30
|
};
|
|
21
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Props for {@link Tooltip.Provider} — sets the `delayDuration` and
|
|
34
|
+
* `skipDelayDuration` shared by every tooltip in the subtree.
|
|
35
|
+
*/
|
|
22
36
|
export type TooltipProviderProps = {
|
|
23
37
|
children?: ReactNode;
|
|
24
38
|
delayDuration?: number;
|
|
25
39
|
skipDelayDuration?: number;
|
|
26
40
|
};
|
|
27
41
|
|
|
28
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Uncontrolled variant of {@link TooltipRootProps}: the component owns the
|
|
44
|
+
* open state. Pass `defaultOpen` (or omit it); `onOpenChange` is optional
|
|
45
|
+
* and `open` is forbidden.
|
|
46
|
+
*/
|
|
47
|
+
export type UncontrolledTooltipRootProps = {
|
|
29
48
|
defaultOpen?: boolean;
|
|
30
49
|
open?: never;
|
|
31
50
|
onOpenChange?: (open: boolean) => void;
|
|
32
51
|
};
|
|
33
52
|
|
|
34
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Controlled variant of {@link TooltipRootProps}: the parent owns the open
|
|
55
|
+
* state. Pass `open` (with an optional `onOpenChange`); `defaultOpen` is
|
|
56
|
+
* forbidden.
|
|
57
|
+
*/
|
|
58
|
+
export type ControlledTooltipRootProps = {
|
|
35
59
|
open: boolean;
|
|
36
60
|
onOpenChange?: (open: boolean) => void;
|
|
37
61
|
defaultOpen?: never;
|
|
38
62
|
};
|
|
39
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Props for {@link Tooltip.Root}. Combines the per-tooltip timing /
|
|
66
|
+
* hoverable-content options with one of the two state modes
|
|
67
|
+
* ({@link UncontrolledTooltipRootProps} | {@link ControlledTooltipRootProps}),
|
|
68
|
+
* so TypeScript accepts exactly one mode.
|
|
69
|
+
*/
|
|
40
70
|
export type TooltipRootProps = {
|
|
41
71
|
children?: ReactNode;
|
|
42
72
|
delayDuration?: number;
|
|
43
73
|
disableHoverableContent?: boolean;
|
|
44
74
|
} & (UncontrolledTooltipRootProps | ControlledTooltipRootProps);
|
|
45
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Props for {@link Tooltip.Trigger} — all native `<button>` attributes plus
|
|
78
|
+
* the `asChild` escape hatch.
|
|
79
|
+
*/
|
|
46
80
|
export type TooltipTriggerProps = ComponentProps<"button"> & {
|
|
47
81
|
asChild?: boolean;
|
|
48
82
|
};
|
|
49
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Props for {@link Tooltip.Portal} — the `container` to render the content
|
|
86
|
+
* into (defaults to `document.body`) and `forceMount` to keep the content
|
|
87
|
+
* in the DOM while closed for exit animations.
|
|
88
|
+
*/
|
|
50
89
|
export type TooltipPortalProps = {
|
|
51
90
|
children?: ReactNode;
|
|
52
91
|
container?: HTMLElement;
|
|
53
92
|
forceMount?: boolean;
|
|
54
93
|
};
|
|
55
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Props for {@link Tooltip.Content} — all native `<div>` attributes plus
|
|
97
|
+
* `forceMount` and the dismissal callbacks fired on Escape
|
|
98
|
+
* (`onEscapeKeyDown`) and outside pointer-down (`onPointerDownOutside`).
|
|
99
|
+
*/
|
|
56
100
|
export type TooltipContentProps = ComponentProps<"div"> & {
|
|
57
101
|
forceMount?: boolean;
|
|
58
102
|
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
59
103
|
onPointerDownOutside?: (event: PointerEvent) => void;
|
|
60
104
|
};
|
|
61
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Props for {@link Tooltip.Arrow} — all native `<span>` attributes plus the
|
|
108
|
+
* `asChild` escape hatch.
|
|
109
|
+
*/
|
|
62
110
|
export type TooltipArrowProps = ComponentProps<"span"> & {
|
|
63
111
|
asChild?: boolean;
|
|
64
112
|
};
|
package/src/Tree/Tree.tsx
CHANGED
|
@@ -116,6 +116,7 @@ export function TreeRoot(props: TreeRootProps): ReactElement {
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/** @internal */
|
|
119
120
|
TreeRoot.displayName = "TreeRoot";
|
|
120
121
|
|
|
121
122
|
/**
|
|
@@ -201,6 +202,7 @@ export function TreeItem({
|
|
|
201
202
|
);
|
|
202
203
|
}
|
|
203
204
|
|
|
205
|
+
/** @internal */
|
|
204
206
|
TreeItem.displayName = "TreeItem";
|
|
205
207
|
|
|
206
208
|
/**
|
|
@@ -301,6 +303,7 @@ export function TreeBranch({
|
|
|
301
303
|
);
|
|
302
304
|
}
|
|
303
305
|
|
|
306
|
+
/** @internal */
|
|
304
307
|
TreeBranch.displayName = "TreeBranch";
|
|
305
308
|
|
|
306
309
|
/**
|
|
@@ -349,6 +352,7 @@ export function TreeBranchControl({
|
|
|
349
352
|
);
|
|
350
353
|
}
|
|
351
354
|
|
|
355
|
+
/** @internal */
|
|
352
356
|
TreeBranchControl.displayName = "TreeBranchControl";
|
|
353
357
|
|
|
354
358
|
/**
|
|
@@ -385,6 +389,7 @@ export function TreeBranchContent({
|
|
|
385
389
|
);
|
|
386
390
|
}
|
|
387
391
|
|
|
392
|
+
/** @internal */
|
|
388
393
|
TreeBranchContent.displayName = "TreeBranchContent";
|
|
389
394
|
|
|
390
395
|
/**
|
|
@@ -430,6 +435,7 @@ export function TreeBranchIndicator({
|
|
|
430
435
|
);
|
|
431
436
|
}
|
|
432
437
|
|
|
438
|
+
/** @internal */
|
|
433
439
|
TreeBranchIndicator.displayName = "TreeBranchIndicator";
|
|
434
440
|
|
|
435
441
|
/**
|
|
@@ -545,9 +551,14 @@ export function TreeSelectionPath({
|
|
|
545
551
|
);
|
|
546
552
|
}
|
|
547
553
|
|
|
554
|
+
/** @internal */
|
|
548
555
|
TreeSelectionPath.displayName = "TreeSelectionPath";
|
|
549
556
|
|
|
550
|
-
|
|
557
|
+
/**
|
|
558
|
+
* The shape of the exported `Tree` value — callable as `Tree.Root` and
|
|
559
|
+
* carrying every sub-component as a static property.
|
|
560
|
+
*/
|
|
561
|
+
export type TreeCompound = typeof TreeRoot & {
|
|
551
562
|
Root: typeof TreeRoot;
|
|
552
563
|
Item: typeof TreeItem;
|
|
553
564
|
Branch: typeof TreeBranch;
|
|
@@ -557,6 +568,39 @@ type TreeCompound = typeof TreeRoot & {
|
|
|
557
568
|
SelectionPath: typeof TreeSelectionPath;
|
|
558
569
|
};
|
|
559
570
|
|
|
571
|
+
/**
|
|
572
|
+
* Headless, accessible **Tree** — a compound component implementing the
|
|
573
|
+
* WAI-ARIA tree view pattern (`role="tree"` / `treeitem` / `group`) with
|
|
574
|
+
* roving tabindex, single or multiple selection, and expandable branches,
|
|
575
|
+
* with zero styles.
|
|
576
|
+
*
|
|
577
|
+
* `Tree` is both callable (an alias of {@link TreeRoot | `Tree.Root`}) and
|
|
578
|
+
* carries its sub-components as static properties:
|
|
579
|
+
*
|
|
580
|
+
* - {@link TreeRoot | `Tree.Root`} — state owner, context provider, `role="tree"`.
|
|
581
|
+
* - {@link TreeItem | `Tree.Item`} — a leaf `role="treeitem"`.
|
|
582
|
+
* - {@link TreeBranch | `Tree.Branch`} — an expandable `role="treeitem"` with children.
|
|
583
|
+
* - {@link TreeBranchControl | `Tree.BranchControl`} — the branch's selectable / toggling control.
|
|
584
|
+
* - {@link TreeBranchContent | `Tree.BranchContent`} — the collapsible `role="group"` of child nodes.
|
|
585
|
+
* - {@link TreeBranchIndicator | `Tree.BranchIndicator`} — expand/collapse affordance.
|
|
586
|
+
* - {@link TreeSelectionPath | `Tree.SelectionPath`} — breadcrumb of the selected node's ancestry.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```tsx
|
|
590
|
+
* import { Tree } from "@primitiv-ui/react";
|
|
591
|
+
*
|
|
592
|
+
* <Tree.Root>
|
|
593
|
+
* <Tree.Branch value="src">
|
|
594
|
+
* <Tree.BranchControl>
|
|
595
|
+
* src <Tree.BranchIndicator />
|
|
596
|
+
* </Tree.BranchControl>
|
|
597
|
+
* <Tree.BranchContent>
|
|
598
|
+
* <Tree.Item value="index">index.ts</Tree.Item>
|
|
599
|
+
* </Tree.BranchContent>
|
|
600
|
+
* </Tree.Branch>
|
|
601
|
+
* </Tree.Root>;
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
560
604
|
const TreeCompound: TreeCompound = Object.assign(TreeRoot, {
|
|
561
605
|
Root: TreeRoot,
|
|
562
606
|
Item: TreeItem,
|
|
@@ -567,6 +611,7 @@ const TreeCompound: TreeCompound = Object.assign(TreeRoot, {
|
|
|
567
611
|
SelectionPath: TreeSelectionPath,
|
|
568
612
|
});
|
|
569
613
|
|
|
614
|
+
/** @internal */
|
|
570
615
|
TreeCompound.displayName = "Tree";
|
|
571
616
|
|
|
572
617
|
export { TreeCompound as Tree };
|
package/src/Tree/index.ts
CHANGED
package/src/Tree/types.ts
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import type { ComponentProps, ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** Mode-independent props shared by every `Tree.Root` variant. */
|
|
4
|
+
export type TreeRootBaseProps = ComponentProps<"div"> & {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
};
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
/** Uncontrolled expansion — initial expanded branches via `defaultExpandedValues`. */
|
|
9
|
+
export type TreeRootUncontrolledExpansionProps = {
|
|
8
10
|
/** Branch values expanded on first render when uncontrolled. */
|
|
9
11
|
defaultExpandedValues?: string[];
|
|
10
12
|
expandedValues?: never;
|
|
11
13
|
onExpandedChange?: (values: string[]) => void;
|
|
12
14
|
};
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
/** Controlled expansion — the expanded set is owned by the consumer. */
|
|
17
|
+
export type TreeRootControlledExpansionProps = {
|
|
15
18
|
defaultExpandedValues?: never;
|
|
16
19
|
/** The set of expanded branch values, owned by the consumer. */
|
|
17
20
|
expandedValues: string[];
|
|
18
21
|
onExpandedChange: (values: string[]) => void;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
/** Single-selection mode, uncontrolled — initial value via `defaultSelectedValue`. */
|
|
25
|
+
export type TreeRootSingleUncontrolledSelectionProps = {
|
|
22
26
|
selectionMode?: "single";
|
|
23
27
|
/** The value selected on first render when uncontrolled. */
|
|
24
28
|
defaultSelectedValue?: string | null;
|
|
@@ -29,7 +33,8 @@ type TreeRootSingleUncontrolledSelectionProps = {
|
|
|
29
33
|
onSelectedValuesChange?: never;
|
|
30
34
|
};
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
/** Single-selection mode, controlled — the selected value is owned by the consumer. */
|
|
37
|
+
export type TreeRootSingleControlledSelectionProps = {
|
|
33
38
|
selectionMode?: "single";
|
|
34
39
|
defaultSelectedValue?: never;
|
|
35
40
|
/** The selected value, owned by the consumer. */
|
|
@@ -40,7 +45,8 @@ type TreeRootSingleControlledSelectionProps = {
|
|
|
40
45
|
onSelectedValuesChange?: never;
|
|
41
46
|
};
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
/** Multiple-selection mode, uncontrolled — initial values via `defaultSelectedValues`. */
|
|
49
|
+
export type TreeRootMultipleUncontrolledSelectionProps = {
|
|
44
50
|
selectionMode: "multiple";
|
|
45
51
|
/** The values selected on first render when uncontrolled. */
|
|
46
52
|
defaultSelectedValues?: string[];
|
|
@@ -51,7 +57,8 @@ type TreeRootMultipleUncontrolledSelectionProps = {
|
|
|
51
57
|
onSelectedValueChange?: never;
|
|
52
58
|
};
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
/** Multiple-selection mode, controlled — the selected values are owned by the consumer. */
|
|
61
|
+
export type TreeRootMultipleControlledSelectionProps = {
|
|
55
62
|
selectionMode: "multiple";
|
|
56
63
|
defaultSelectedValues?: never;
|
|
57
64
|
/** The selected values, owned by the consumer. */
|
|
@@ -62,6 +69,12 @@ type TreeRootMultipleControlledSelectionProps = {
|
|
|
62
69
|
onSelectedValueChange?: never;
|
|
63
70
|
};
|
|
64
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Props for `Tree.Root`. Combines the shared {@link TreeRootBaseProps} with
|
|
74
|
+
* one expansion arm (controlled / uncontrolled) and one selection arm
|
|
75
|
+
* (single / multiple, controlled / uncontrolled), so the relevant
|
|
76
|
+
* `value` / `defaultValue` / `onChange` shape is enforced per mode.
|
|
77
|
+
*/
|
|
65
78
|
export type TreeRootProps = TreeRootBaseProps &
|
|
66
79
|
(TreeRootUncontrolledExpansionProps | TreeRootControlledExpansionProps) &
|
|
67
80
|
(
|
|
@@ -71,6 +84,7 @@ export type TreeRootProps = TreeRootBaseProps &
|
|
|
71
84
|
| TreeRootMultipleControlledSelectionProps
|
|
72
85
|
);
|
|
73
86
|
|
|
87
|
+
/** Props for `Tree.Item` — a selectable, focusable leaf treeitem. */
|
|
74
88
|
export type TreeItemProps = ComponentProps<"div"> & {
|
|
75
89
|
/** Stable identifier for this item, unique within the tree. */
|
|
76
90
|
value: string;
|
|
@@ -88,6 +102,7 @@ export type TreeItemProps = ComponentProps<"div"> & {
|
|
|
88
102
|
children: ReactNode;
|
|
89
103
|
};
|
|
90
104
|
|
|
105
|
+
/** Props for `Tree.Branch` — an expandable treeitem with nested children. */
|
|
91
106
|
export type TreeBranchProps = Omit<ComponentProps<"div">, "ref"> & {
|
|
92
107
|
/** Stable identifier for this branch, unique within the tree. */
|
|
93
108
|
value: string;
|
|
@@ -106,12 +121,14 @@ export type TreeBranchProps = Omit<ComponentProps<"div">, "ref"> & {
|
|
|
106
121
|
children: ReactNode;
|
|
107
122
|
};
|
|
108
123
|
|
|
124
|
+
/** Props for `Tree.BranchControl` — the branch's selectable, toggling control row. */
|
|
109
125
|
export type TreeBranchControlProps = ComponentProps<"div"> & {
|
|
110
126
|
/** Render the control as the supplied child element instead of `<div>`. */
|
|
111
127
|
asChild?: boolean;
|
|
112
128
|
children: ReactNode;
|
|
113
129
|
};
|
|
114
130
|
|
|
131
|
+
/** Props for `Tree.BranchContent` — the collapsible group of a branch's child nodes. */
|
|
115
132
|
export type TreeBranchContentProps = ComponentProps<"div"> & {
|
|
116
133
|
children: ReactNode;
|
|
117
134
|
/**
|
|
@@ -122,6 +139,7 @@ export type TreeBranchContentProps = ComponentProps<"div"> & {
|
|
|
122
139
|
forceMount?: boolean;
|
|
123
140
|
};
|
|
124
141
|
|
|
142
|
+
/** Props for `Tree.BranchIndicator` — the expand/collapse affordance. */
|
|
125
143
|
export type TreeBranchIndicatorProps = ComponentProps<"span"> & {
|
|
126
144
|
/** Render as the supplied child element instead of `<span>`. */
|
|
127
145
|
asChild?: boolean;
|
|
@@ -133,6 +151,10 @@ export type TreeSelectionPathRenderProps = {
|
|
|
133
151
|
paths: TreePathSegment[][];
|
|
134
152
|
};
|
|
135
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Props for `Tree.SelectionPath` — a breadcrumb of the selected node's
|
|
156
|
+
* root-to-leaf ancestry, with an optional render-prop for custom layout.
|
|
157
|
+
*/
|
|
136
158
|
export type TreeSelectionPathProps = Omit<ComponentProps<"div">, "children"> & {
|
|
137
159
|
/**
|
|
138
160
|
* Either standard React children (ignored — the subcomponent does its
|
|
@@ -147,6 +169,7 @@ export type TreeSelectionPathProps = Omit<ComponentProps<"div">, "children"> & {
|
|
|
147
169
|
separator?: ReactNode;
|
|
148
170
|
};
|
|
149
171
|
|
|
172
|
+
/** Per-level context — the nesting depth and enclosing branch value, shared down each subtree. */
|
|
150
173
|
export type TreeLevelContextValue = {
|
|
151
174
|
/** Zero-based nesting depth — `0` for items directly inside `Tree.Root`. */
|
|
152
175
|
depth: number;
|
|
@@ -154,6 +177,7 @@ export type TreeLevelContextValue = {
|
|
|
154
177
|
parentValue: string | null;
|
|
155
178
|
};
|
|
156
179
|
|
|
180
|
+
/** Registry entry for one tree node — its value, element, and structural metadata. */
|
|
157
181
|
export type TreeNodeMeta = {
|
|
158
182
|
value: string;
|
|
159
183
|
element: HTMLElement;
|
|
@@ -177,14 +201,21 @@ export type TreePathSegment = {
|
|
|
177
201
|
depth: number;
|
|
178
202
|
};
|
|
179
203
|
|
|
204
|
+
/** Whether the tree allows one selected node (`"single"`) or many (`"multiple"`). */
|
|
180
205
|
export type SelectionMode = "single" | "multiple";
|
|
181
206
|
|
|
207
|
+
/** Keyboard/pointer modifiers that influence a selection gesture. */
|
|
182
208
|
export type TreeSelectModifiers = {
|
|
183
209
|
meta: boolean;
|
|
184
210
|
ctrl: boolean;
|
|
185
211
|
shift: boolean;
|
|
186
212
|
};
|
|
187
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Context shared from `Tree.Root` to every descendant — selection and
|
|
216
|
+
* expansion state, the node registry, roving-tabindex bookkeeping, and the
|
|
217
|
+
* path resolver.
|
|
218
|
+
*/
|
|
188
219
|
export type TreeContextValue = {
|
|
189
220
|
/** Stable id shared across the tree, used to derive ARIA wiring ids. */
|
|
190
221
|
rootId: string;
|
|
@@ -215,6 +246,7 @@ export type TreeContextValue = {
|
|
|
215
246
|
selectedOrder: readonly string[];
|
|
216
247
|
};
|
|
217
248
|
|
|
249
|
+
/** Context a branch shares with its own control and content — its value, expanded/disabled state, and control id. */
|
|
218
250
|
export type TreeItemContextValue = {
|
|
219
251
|
value: string;
|
|
220
252
|
expanded: boolean;
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type PossibleRef<T> = Ref<T> | undefined;
|
|
|
8
8
|
|
|
9
9
|
export type AnyProps = Record<string, unknown>;
|
|
10
10
|
|
|
11
|
+
/** A heading level, `1`–`6`, mapped to an `<h1>`–`<h6>` element. */
|
|
11
12
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
12
13
|
|
|
13
14
|
export type HeadingTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|