@basic-ui/core 0.0.60 → 0.0.62
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/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts.map +1 -1
- package/build/esm/Accordion/AccordionBody.js +6 -26
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts.map +1 -1
- package/build/esm/Accordion/AccordionHeader.js +21 -69
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts.map +1 -1
- package/build/esm/Accordion/AccordionItem.js +31 -18
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +0 -8
- package/build/esm/Accordion/context.d.ts.map +1 -1
- package/build/esm/Accordion/context.js +0 -11
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/scopeQuery.d.ts +1 -0
- package/build/esm/Accordion/scopeQuery.d.ts.map +1 -1
- package/build/esm/Accordion/scopeQuery.js +3 -0
- package/build/esm/Accordion/scopeQuery.js.map +1 -1
- package/build/esm/Collapsible/Collapsible.d.ts +13 -0
- package/build/esm/Collapsible/Collapsible.d.ts.map +1 -0
- package/build/esm/Collapsible/Collapsible.js +53 -0
- package/build/esm/Collapsible/Collapsible.js.map +1 -0
- package/build/esm/Collapsible/CollapsiblePanel.d.ts +10 -0
- package/build/esm/Collapsible/CollapsiblePanel.d.ts.map +1 -0
- package/build/esm/Collapsible/CollapsiblePanel.js +85 -0
- package/build/esm/Collapsible/CollapsiblePanel.js.map +1 -0
- package/build/esm/Collapsible/CollapsibleTrigger.d.ts +11 -0
- package/build/esm/Collapsible/CollapsibleTrigger.d.ts.map +1 -0
- package/build/esm/Collapsible/CollapsibleTrigger.js +51 -0
- package/build/esm/Collapsible/CollapsibleTrigger.js.map +1 -0
- package/build/esm/Collapsible/context.d.ts +16 -0
- package/build/esm/Collapsible/context.d.ts.map +1 -0
- package/build/esm/Collapsible/context.js +11 -0
- package/build/esm/Collapsible/context.js.map +1 -0
- package/build/esm/Collapsible/index.d.ts +4 -0
- package/build/esm/Collapsible/index.d.ts.map +1 -0
- package/build/esm/Collapsible/index.js +4 -0
- package/build/esm/Collapsible/index.js.map +1 -0
- package/build/esm/Menu/Menu.d.ts +3 -2
- package/build/esm/Menu/Menu.d.ts.map +1 -1
- package/build/esm/Menu/Menu.js +64 -4
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts.map +1 -1
- package/build/esm/Menu/MenuButton.js +85 -8
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts.map +1 -1
- package/build/esm/Menu/MenuItem.js +16 -4
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts.map +1 -1
- package/build/esm/Menu/MenuList.js +47 -12
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts.map +1 -1
- package/build/esm/Menu/MenuPopover.js +12 -1
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/MenuSubmenuTrigger.d.ts +8 -0
- package/build/esm/Menu/MenuSubmenuTrigger.d.ts.map +1 -0
- package/build/esm/Menu/MenuSubmenuTrigger.js +131 -0
- package/build/esm/Menu/MenuSubmenuTrigger.js.map +1 -0
- package/build/esm/Menu/context.d.ts +13 -3
- package/build/esm/Menu/context.d.ts.map +1 -1
- package/build/esm/Menu/context.js +1 -0
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Menu/index.d.ts +3 -0
- package/build/esm/Menu/index.d.ts.map +1 -1
- package/build/esm/Menu/index.js +2 -0
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/Menu/scope.d.ts +1 -0
- package/build/esm/Menu/scope.d.ts.map +1 -1
- package/build/esm/Menu/scope.js +2 -1
- package/build/esm/Menu/scope.js.map +1 -1
- package/build/esm/MenuBar/MenuBar.d.ts +11 -0
- package/build/esm/MenuBar/MenuBar.d.ts.map +1 -0
- package/build/esm/MenuBar/MenuBar.js +153 -0
- package/build/esm/MenuBar/MenuBar.js.map +1 -0
- package/build/esm/MenuBar/context.d.ts +29 -0
- package/build/esm/MenuBar/context.d.ts.map +1 -0
- package/build/esm/MenuBar/context.js +7 -0
- package/build/esm/MenuBar/context.js.map +1 -0
- package/build/esm/MenuBar/index.d.ts +2 -0
- package/build/esm/MenuBar/index.d.ts.map +1 -0
- package/build/esm/MenuBar/index.js +2 -0
- package/build/esm/MenuBar/index.js.map +1 -0
- package/build/esm/Slider/Slider.d.ts +47 -1
- package/build/esm/Slider/Slider.d.ts.map +1 -1
- package/build/esm/Slider/Slider.js +91 -5
- package/build/esm/Slider/Slider.js.map +1 -1
- package/build/esm/ToggleGroup/ToggleGroup.d.ts +40 -0
- package/build/esm/ToggleGroup/ToggleGroup.d.ts.map +1 -0
- package/build/esm/ToggleGroup/ToggleGroup.js +113 -0
- package/build/esm/ToggleGroup/ToggleGroup.js.map +1 -0
- package/build/esm/ToggleGroup/ToggleGroupContext.d.ts +10 -0
- package/build/esm/ToggleGroup/ToggleGroupContext.d.ts.map +1 -0
- package/build/esm/ToggleGroup/ToggleGroupContext.js +6 -0
- package/build/esm/ToggleGroup/ToggleGroupContext.js.map +1 -0
- package/build/esm/ToggleGroup/index.d.ts +3 -0
- package/build/esm/ToggleGroup/index.d.ts.map +1 -0
- package/build/esm/ToggleGroup/index.js +3 -0
- package/build/esm/ToggleGroup/index.js.map +1 -0
- package/build/esm/Tree/Tree.d.ts +3 -0
- package/build/esm/Tree/Tree.d.ts.map +1 -0
- package/build/esm/Tree/Tree.js +730 -0
- package/build/esm/Tree/Tree.js.map +1 -0
- package/build/esm/Tree/TreeHeader.d.ts +3 -0
- package/build/esm/Tree/TreeHeader.d.ts.map +1 -0
- package/build/esm/Tree/TreeHeader.js +5 -0
- package/build/esm/Tree/TreeHeader.js.map +1 -0
- package/build/esm/Tree/TreeItem.d.ts +3 -0
- package/build/esm/Tree/TreeItem.d.ts.map +1 -0
- package/build/esm/Tree/TreeItem.js +5 -0
- package/build/esm/Tree/TreeItem.js.map +1 -0
- package/build/esm/Tree/TreeItemContent.d.ts +3 -0
- package/build/esm/Tree/TreeItemContent.d.ts.map +1 -0
- package/build/esm/Tree/TreeItemContent.js +69 -0
- package/build/esm/Tree/TreeItemContent.js.map +1 -0
- package/build/esm/Tree/TreeSection.d.ts +3 -0
- package/build/esm/Tree/TreeSection.d.ts.map +1 -0
- package/build/esm/Tree/TreeSection.js +5 -0
- package/build/esm/Tree/TreeSection.js.map +1 -0
- package/build/esm/Tree/collection.d.ts +18 -0
- package/build/esm/Tree/collection.d.ts.map +1 -0
- package/build/esm/Tree/collection.js +252 -0
- package/build/esm/Tree/collection.js.map +1 -0
- package/build/esm/Tree/context.d.ts +3 -0
- package/build/esm/Tree/context.d.ts.map +1 -0
- package/build/esm/Tree/context.js +3 -0
- package/build/esm/Tree/context.js.map +1 -0
- package/build/esm/Tree/index.d.ts +8 -0
- package/build/esm/Tree/index.d.ts.map +1 -0
- package/build/esm/Tree/index.js +7 -0
- package/build/esm/Tree/index.js.map +1 -0
- package/build/esm/Tree/types.d.ts +128 -0
- package/build/esm/Tree/types.d.ts.map +1 -0
- package/build/esm/Tree/types.js +2 -0
- package/build/esm/Tree/types.js.map +1 -0
- package/build/esm/hooks/index.d.ts +1 -0
- package/build/esm/hooks/index.d.ts.map +1 -1
- package/build/esm/hooks/index.js +1 -0
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useTransitionStatus.d.ts +7 -0
- package/build/esm/hooks/useTransitionStatus.d.ts.map +1 -0
- package/build/esm/hooks/useTransitionStatus.js +48 -0
- package/build/esm/hooks/useTransitionStatus.js.map +1 -0
- package/build/esm/index.d.ts +5 -0
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +5 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/toggle/Toggle.d.ts +28 -0
- package/build/esm/toggle/Toggle.d.ts.map +1 -0
- package/build/esm/toggle/Toggle.js +55 -0
- package/build/esm/toggle/Toggle.js.map +1 -0
- package/build/esm/toggle/index.d.ts +2 -0
- package/build/esm/toggle/index.d.ts.map +1 -0
- package/build/esm/toggle/index.js +2 -0
- package/build/esm/toggle/index.js.map +1 -0
- package/build/esm/utils/assign-ref.d.ts +3 -3
- package/build/esm/utils/assign-ref.d.ts.map +1 -1
- package/build/esm/utils/assign-ref.js +1 -1
- package/build/esm/utils/assign-ref.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
- package/src/Accordion/AccordionBody.tsx +6 -35
- package/src/Accordion/AccordionHeader.tsx +29 -103
- package/src/Accordion/AccordionItem.tsx +40 -29
- package/src/Accordion/context.ts +0 -18
- package/src/Accordion/scopeQuery.ts +4 -0
- package/src/Collapsible/Collapsible.story.tsx +153 -0
- package/src/Collapsible/Collapsible.tsx +79 -0
- package/src/Collapsible/CollapsiblePanel.tsx +103 -0
- package/src/Collapsible/CollapsibleTrigger.tsx +60 -0
- package/src/Collapsible/context.ts +28 -0
- package/src/Collapsible/index.ts +3 -0
- package/src/Menu/Menu.story.tsx +70 -1
- package/src/Menu/Menu.tsx +141 -65
- package/src/Menu/MenuButton.tsx +115 -9
- package/src/Menu/MenuItem.tsx +20 -3
- package/src/Menu/MenuList.tsx +50 -13
- package/src/Menu/MenuPopover.tsx +12 -2
- package/src/Menu/MenuSubmenuTrigger.tsx +167 -0
- package/src/Menu/context.ts +20 -10
- package/src/Menu/index.ts +3 -0
- package/src/Menu/scope.ts +4 -1
- package/src/Menu/styles.css +57 -22
- package/src/MenuBar/MenuBar.story.tsx +92 -0
- package/src/MenuBar/MenuBar.tsx +236 -0
- package/src/MenuBar/context.ts +46 -0
- package/src/MenuBar/index.ts +1 -0
- package/src/MenuBar/styles.css +78 -0
- package/src/Slider/Slider.story.tsx +1 -1
- package/src/Slider/Slider.tsx +145 -8
- package/src/Toggle/Toggle.story.tsx +42 -0
- package/src/Toggle/Toggle.tsx +95 -0
- package/src/Toggle/index.ts +1 -0
- package/src/Toggle/styles.css +39 -0
- package/src/ToggleGroup/ToggleGroup.story.tsx +86 -0
- package/src/ToggleGroup/ToggleGroup.tsx +185 -0
- package/src/ToggleGroup/ToggleGroupContext.ts +17 -0
- package/src/ToggleGroup/index.ts +2 -0
- package/src/ToggleGroup/styles.css +66 -0
- package/src/Tree/Tree.story.tsx +221 -0
- package/src/Tree/Tree.tsx +1081 -0
- package/src/Tree/TreeHeader.tsx +9 -0
- package/src/Tree/TreeItem.tsx +9 -0
- package/src/Tree/TreeItemContent.tsx +91 -0
- package/src/Tree/TreeSection.tsx +9 -0
- package/src/Tree/collection.tsx +371 -0
- package/src/Tree/context.ts +6 -0
- package/src/Tree/index.ts +7 -0
- package/src/Tree/styles.css +135 -0
- package/src/Tree/types.ts +161 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useTransitionStatus.ts +65 -0
- package/src/index.ts +5 -0
- package/src/utils/assign-ref.ts +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/Tree/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,qBAAqB,4DACsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","TreeItemRenderContext"],"sources":["../../../src/Tree/context.ts"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { TreeItemRenderContextValue } from './types';\n\nexport const TreeItemRenderContext =\n createContext<TreeItemRenderContextValue | null>(null);\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,OAAO;AAIrC,OAAO,MAAMC,qBAAqB,gBAChCD,aAAa,CAAoC,IAAI,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tree/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,mBAAmB,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Tree/index.ts"],"sourcesContent":["export * from './collection';\nexport * from './Tree';\nexport * from './TreeHeader';\nexport * from './TreeItem';\nexport * from './TreeItemContent';\nexport * from './TreeSection';\nexport type * from './types';\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,QAAQ;AACtB,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,cAAc,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type TreeKey = string | number;
|
|
3
|
+
export type TreeSelectionMode = 'none' | 'single' | 'multiple';
|
|
4
|
+
export type TreeSelectionBehavior = 'toggle' | 'replace';
|
|
5
|
+
export type TreeDisabledBehavior = 'all' | 'selection';
|
|
6
|
+
export type TreeSelection = Iterable<TreeKey> | 'all';
|
|
7
|
+
export type TreeExpandedKeys = Iterable<TreeKey> | 'all';
|
|
8
|
+
export interface TreeProps extends Omit<HTMLAttributes<HTMLDivElement>, 'autoFocus' | 'onChange' | 'onSelect'> {
|
|
9
|
+
as?: ElementType<any>;
|
|
10
|
+
innerAs?: ElementType<any>;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
selectionMode?: TreeSelectionMode;
|
|
13
|
+
selectionBehavior?: TreeSelectionBehavior;
|
|
14
|
+
selectedKeys?: TreeSelection;
|
|
15
|
+
defaultSelectedKeys?: TreeSelection;
|
|
16
|
+
onSelectionChange?: (keys: Set<TreeKey>) => void;
|
|
17
|
+
disallowEmptySelection?: boolean;
|
|
18
|
+
disabledKeys?: Iterable<TreeKey>;
|
|
19
|
+
disabledBehavior?: TreeDisabledBehavior;
|
|
20
|
+
expandedKeys?: TreeExpandedKeys;
|
|
21
|
+
defaultExpandedKeys?: TreeExpandedKeys;
|
|
22
|
+
onExpandedChange?: (keys: Set<TreeKey>) => void;
|
|
23
|
+
autoFocus?: boolean | 'first' | 'last';
|
|
24
|
+
onAction?: (key: TreeKey) => void;
|
|
25
|
+
keyboardNavigationBehavior?: 'arrow' | 'tab';
|
|
26
|
+
escapeKeyBehavior?: 'clearSelection' | 'none';
|
|
27
|
+
shouldFocusWrap?: boolean;
|
|
28
|
+
disallowTypeAhead?: boolean;
|
|
29
|
+
disallowSelectAll?: boolean;
|
|
30
|
+
direction?: 'ltr' | 'rtl';
|
|
31
|
+
renderEmptyState?: () => ReactNode;
|
|
32
|
+
renderLoadingState?: (item: ParsedTreeItem) => ReactNode;
|
|
33
|
+
renderedRowIndices?: Iterable<number>;
|
|
34
|
+
onVisibleRowsChange?: (rows: TreeVisibleRow[]) => void;
|
|
35
|
+
onFocusedKeyChange?: (key: TreeKey | null, rowIndex: number | null) => void;
|
|
36
|
+
renderRow?: (row: TreeVisibleRow, defaultRow: ReactElement, state: TreeRenderState) => ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export interface TreeItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'title' | 'onSelect'> {
|
|
39
|
+
id?: TreeKey;
|
|
40
|
+
title?: ReactNode;
|
|
41
|
+
textValue?: string;
|
|
42
|
+
isDisabled?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
hasChildItems?: boolean;
|
|
45
|
+
isLoading?: boolean;
|
|
46
|
+
onAction?: () => void;
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
export interface TreeItemContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
50
|
+
as?: ElementType<any>;
|
|
51
|
+
innerAs?: ElementType<any>;
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
export interface TreeSectionProps extends HTMLAttributes<HTMLDivElement> {
|
|
55
|
+
as?: ElementType<any>;
|
|
56
|
+
innerAs?: ElementType<any>;
|
|
57
|
+
children?: ReactNode;
|
|
58
|
+
}
|
|
59
|
+
export interface TreeHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
60
|
+
as?: ElementType<any>;
|
|
61
|
+
innerAs?: ElementType<any>;
|
|
62
|
+
children?: ReactNode;
|
|
63
|
+
}
|
|
64
|
+
export interface ParsedTreeItem {
|
|
65
|
+
type: 'item';
|
|
66
|
+
key: TreeKey;
|
|
67
|
+
keyString: string;
|
|
68
|
+
level: number;
|
|
69
|
+
index: number;
|
|
70
|
+
posInSet: number;
|
|
71
|
+
setSize: number;
|
|
72
|
+
parentKey: TreeKey | null;
|
|
73
|
+
content: ReactNode;
|
|
74
|
+
textValue: string;
|
|
75
|
+
disabled: boolean;
|
|
76
|
+
hasChildItems: boolean;
|
|
77
|
+
childItems: ParsedTreeItem[];
|
|
78
|
+
props: TreeItemProps;
|
|
79
|
+
}
|
|
80
|
+
export interface ParsedTreeSection {
|
|
81
|
+
type: 'section';
|
|
82
|
+
key: string;
|
|
83
|
+
header: ReactNode;
|
|
84
|
+
headerProps: TreeHeaderProps;
|
|
85
|
+
sectionProps: TreeSectionProps;
|
|
86
|
+
items: ParsedTreeItem[];
|
|
87
|
+
}
|
|
88
|
+
export type ParsedTreeNode = ParsedTreeItem | ParsedTreeSection;
|
|
89
|
+
export interface TreeVisibleItemRow {
|
|
90
|
+
type: 'item';
|
|
91
|
+
key: TreeKey;
|
|
92
|
+
item: ParsedTreeItem;
|
|
93
|
+
}
|
|
94
|
+
export interface TreeVisibleSectionRow {
|
|
95
|
+
type: 'section';
|
|
96
|
+
key: string;
|
|
97
|
+
section: ParsedTreeSection;
|
|
98
|
+
}
|
|
99
|
+
export interface TreeVisibleLoadingRow {
|
|
100
|
+
type: 'loading';
|
|
101
|
+
key: string;
|
|
102
|
+
item: ParsedTreeItem;
|
|
103
|
+
level: number;
|
|
104
|
+
}
|
|
105
|
+
export type TreeVisibleRow = TreeVisibleItemRow | TreeVisibleSectionRow | TreeVisibleLoadingRow;
|
|
106
|
+
export interface TreeRenderState {
|
|
107
|
+
allItems: ParsedTreeItem[];
|
|
108
|
+
visibleItems: ParsedTreeItem[];
|
|
109
|
+
visibleRows: TreeVisibleRow[];
|
|
110
|
+
focusedKey: TreeKey | null;
|
|
111
|
+
expandedKeys: Set<TreeKey>;
|
|
112
|
+
selectedKeys: Set<TreeKey>;
|
|
113
|
+
selectionMode: TreeSelectionMode;
|
|
114
|
+
selectionBehavior: TreeSelectionBehavior;
|
|
115
|
+
}
|
|
116
|
+
export interface TreeItemRenderContextValue {
|
|
117
|
+
item: ParsedTreeItem;
|
|
118
|
+
rowId: string;
|
|
119
|
+
isExpanded: boolean;
|
|
120
|
+
isSelected: boolean;
|
|
121
|
+
isDisabled: boolean;
|
|
122
|
+
canSelect: boolean;
|
|
123
|
+
selectionMode: TreeSelectionMode;
|
|
124
|
+
selectionBehavior: TreeSelectionBehavior;
|
|
125
|
+
toggleExpanded: (event: MouseEvent<any> | KeyboardEvent<any>) => void;
|
|
126
|
+
toggleSelection: (event: MouseEvent<any> | KeyboardEvent<any>) => void;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Tree/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,UAAU,EACV,YAAY,EACZ,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACtC,MAAM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C,cAAc,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IACtE,eAAe,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CACxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/Tree/types.ts"],"sourcesContent":["import type {\n ElementType,\n HTMLAttributes,\n KeyboardEvent,\n MouseEvent,\n ReactElement,\n ReactNode,\n} from 'react';\n\nexport type TreeKey = string | number;\nexport type TreeSelectionMode = 'none' | 'single' | 'multiple';\nexport type TreeSelectionBehavior = 'toggle' | 'replace';\nexport type TreeDisabledBehavior = 'all' | 'selection';\nexport type TreeSelection = Iterable<TreeKey> | 'all';\nexport type TreeExpandedKeys = Iterable<TreeKey> | 'all';\n\nexport interface TreeProps\n extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'autoFocus' | 'onChange' | 'onSelect'\n > {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n selectionMode?: TreeSelectionMode;\n selectionBehavior?: TreeSelectionBehavior;\n selectedKeys?: TreeSelection;\n defaultSelectedKeys?: TreeSelection;\n onSelectionChange?: (keys: Set<TreeKey>) => void;\n disallowEmptySelection?: boolean;\n disabledKeys?: Iterable<TreeKey>;\n disabledBehavior?: TreeDisabledBehavior;\n expandedKeys?: TreeExpandedKeys;\n defaultExpandedKeys?: TreeExpandedKeys;\n onExpandedChange?: (keys: Set<TreeKey>) => void;\n autoFocus?: boolean | 'first' | 'last';\n onAction?: (key: TreeKey) => void;\n keyboardNavigationBehavior?: 'arrow' | 'tab';\n escapeKeyBehavior?: 'clearSelection' | 'none';\n shouldFocusWrap?: boolean;\n disallowTypeAhead?: boolean;\n disallowSelectAll?: boolean;\n direction?: 'ltr' | 'rtl';\n renderEmptyState?: () => ReactNode;\n renderLoadingState?: (item: ParsedTreeItem) => ReactNode;\n renderedRowIndices?: Iterable<number>;\n onVisibleRowsChange?: (rows: TreeVisibleRow[]) => void;\n onFocusedKeyChange?: (key: TreeKey | null, rowIndex: number | null) => void;\n renderRow?: (\n row: TreeVisibleRow,\n defaultRow: ReactElement,\n state: TreeRenderState\n ) => ReactNode;\n}\n\nexport interface TreeItemProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'title' | 'onSelect'> {\n id?: TreeKey;\n title?: ReactNode;\n textValue?: string;\n isDisabled?: boolean;\n disabled?: boolean;\n hasChildItems?: boolean;\n isLoading?: boolean;\n onAction?: () => void;\n children?: ReactNode;\n}\n\nexport interface TreeItemContentProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport interface TreeSectionProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport interface TreeHeaderProps extends HTMLAttributes<HTMLDivElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport interface ParsedTreeItem {\n type: 'item';\n key: TreeKey;\n keyString: string;\n level: number;\n index: number;\n posInSet: number;\n setSize: number;\n parentKey: TreeKey | null;\n content: ReactNode;\n textValue: string;\n disabled: boolean;\n hasChildItems: boolean;\n childItems: ParsedTreeItem[];\n props: TreeItemProps;\n}\n\nexport interface ParsedTreeSection {\n type: 'section';\n key: string;\n header: ReactNode;\n headerProps: TreeHeaderProps;\n sectionProps: TreeSectionProps;\n items: ParsedTreeItem[];\n}\n\nexport type ParsedTreeNode = ParsedTreeItem | ParsedTreeSection;\n\nexport interface TreeVisibleItemRow {\n type: 'item';\n key: TreeKey;\n item: ParsedTreeItem;\n}\n\nexport interface TreeVisibleSectionRow {\n type: 'section';\n key: string;\n section: ParsedTreeSection;\n}\n\nexport interface TreeVisibleLoadingRow {\n type: 'loading';\n key: string;\n item: ParsedTreeItem;\n level: number;\n}\n\nexport type TreeVisibleRow =\n | TreeVisibleItemRow\n | TreeVisibleSectionRow\n | TreeVisibleLoadingRow;\n\nexport interface TreeRenderState {\n allItems: ParsedTreeItem[];\n visibleItems: ParsedTreeItem[];\n visibleRows: TreeVisibleRow[];\n focusedKey: TreeKey | null;\n expandedKeys: Set<TreeKey>;\n selectedKeys: Set<TreeKey>;\n selectionMode: TreeSelectionMode;\n selectionBehavior: TreeSelectionBehavior;\n}\n\nexport interface TreeItemRenderContextValue {\n item: ParsedTreeItem;\n rowId: string;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n canSelect: boolean;\n selectionMode: TreeSelectionMode;\n selectionBehavior: TreeSelectionBehavior;\n toggleExpanded: (event: MouseEvent<any> | KeyboardEvent<any>) => void;\n toggleSelection: (event: MouseEvent<any> | KeyboardEvent<any>) => void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
|
package/build/esm/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from './useAutoFocus';\nexport * from './useControlledState';\nexport * from './useChildrenCounter';\nexport * from './useFocusReturn';\nexport * from './useFocusState';\nexport * from './useOnClickOutside';\nexport * from './useOnKeyDown';\nexport * from './useReducerMachine';\nexport * from './useRemoveBodyScroll';\nexport * from './useThrottle';\nexport * from './useMeasure';\nexport * from './useGestureHandlers';\nexport * from './useScope';\n"],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,iBAAiB;AAC/B,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export * from './useAutoFocus';\nexport * from './useControlledState';\nexport * from './useChildrenCounter';\nexport * from './useFocusReturn';\nexport * from './useFocusState';\nexport * from './useOnClickOutside';\nexport * from './useOnKeyDown';\nexport * from './useReducerMachine';\nexport * from './useRemoveBodyScroll';\nexport * from './useThrottle';\nexport * from './useMeasure';\nexport * from './useGestureHandlers';\nexport * from './useScope';\nexport * from './useTransitionStatus';\n"],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,iBAAiB;AAC/B,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,YAAY;AAC1B,cAAc,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type TransitionStatus = 'starting' | 'ending' | 'idle' | undefined;
|
|
2
|
+
export declare function useTransitionStatus(open: boolean, enableIdleState?: boolean, deferEndingState?: boolean): {
|
|
3
|
+
mounted: boolean;
|
|
4
|
+
setMounted: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
5
|
+
transitionStatus: TransitionStatus;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useTransitionStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTransitionStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTransitionStatus.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAE1E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,EACb,eAAe,GAAE,OAAe,EAChC,gBAAgB,GAAE,OAAe;;;;EAyDlC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useState, useLayoutEffect } from 'react';
|
|
2
|
+
export function useTransitionStatus(open) {
|
|
3
|
+
let enableIdleState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
4
|
+
let deferEndingState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
5
|
+
const [transitionStatus, setTransitionStatus] = useState(open && enableIdleState ? 'idle' : undefined);
|
|
6
|
+
const [mounted, setMounted] = useState(open);
|
|
7
|
+
if (open && !mounted) {
|
|
8
|
+
setMounted(true);
|
|
9
|
+
setTransitionStatus('starting');
|
|
10
|
+
}
|
|
11
|
+
if (!open && mounted && transitionStatus !== 'ending' && !deferEndingState) {
|
|
12
|
+
setTransitionStatus('ending');
|
|
13
|
+
}
|
|
14
|
+
if (!open && !mounted && transitionStatus === 'ending') {
|
|
15
|
+
setTransitionStatus(undefined);
|
|
16
|
+
}
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
if (!open && mounted && transitionStatus !== 'ending' && deferEndingState) {
|
|
19
|
+
const frame = requestAnimationFrame(() => {
|
|
20
|
+
setTransitionStatus('ending');
|
|
21
|
+
});
|
|
22
|
+
return () => cancelAnimationFrame(frame);
|
|
23
|
+
}
|
|
24
|
+
}, [open, mounted, transitionStatus, deferEndingState]);
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
if (!open || enableIdleState) return;
|
|
27
|
+
const frame = requestAnimationFrame(() => {
|
|
28
|
+
setTransitionStatus(undefined);
|
|
29
|
+
});
|
|
30
|
+
return () => cancelAnimationFrame(frame);
|
|
31
|
+
}, [enableIdleState, open]);
|
|
32
|
+
useLayoutEffect(() => {
|
|
33
|
+
if (!open || !enableIdleState) return;
|
|
34
|
+
if (open && mounted && transitionStatus !== 'idle') {
|
|
35
|
+
setTransitionStatus('starting');
|
|
36
|
+
}
|
|
37
|
+
const frame = requestAnimationFrame(() => {
|
|
38
|
+
setTransitionStatus('idle');
|
|
39
|
+
});
|
|
40
|
+
return () => cancelAnimationFrame(frame);
|
|
41
|
+
}, [enableIdleState, open, mounted, transitionStatus]);
|
|
42
|
+
return {
|
|
43
|
+
mounted,
|
|
44
|
+
setMounted,
|
|
45
|
+
transitionStatus
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=useTransitionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTransitionStatus.js","names":["useState","useLayoutEffect","useTransitionStatus","open","enableIdleState","arguments","length","undefined","deferEndingState","transitionStatus","setTransitionStatus","mounted","setMounted","frame","requestAnimationFrame","cancelAnimationFrame"],"sources":["../../../src/hooks/useTransitionStatus.ts"],"sourcesContent":["import { useState, useLayoutEffect } from 'react';\n\nexport type TransitionStatus = 'starting' | 'ending' | 'idle' | undefined;\n\nexport function useTransitionStatus(\n open: boolean,\n enableIdleState: boolean = false,\n deferEndingState: boolean = false\n) {\n const [transitionStatus, setTransitionStatus] = useState<TransitionStatus>(\n open && enableIdleState ? 'idle' : undefined\n );\n const [mounted, setMounted] = useState(open);\n\n if (open && !mounted) {\n setMounted(true);\n setTransitionStatus('starting');\n }\n\n if (!open && mounted && transitionStatus !== 'ending' && !deferEndingState) {\n setTransitionStatus('ending');\n }\n\n if (!open && !mounted && transitionStatus === 'ending') {\n setTransitionStatus(undefined);\n }\n\n useLayoutEffect(() => {\n if (!open && mounted && transitionStatus !== 'ending' && deferEndingState) {\n const frame = requestAnimationFrame(() => {\n setTransitionStatus('ending');\n });\n return () => cancelAnimationFrame(frame);\n }\n }, [open, mounted, transitionStatus, deferEndingState]);\n\n useLayoutEffect(() => {\n if (!open || enableIdleState) return;\n\n const frame = requestAnimationFrame(() => {\n setTransitionStatus(undefined);\n });\n return () => cancelAnimationFrame(frame);\n }, [enableIdleState, open]);\n\n useLayoutEffect(() => {\n if (!open || !enableIdleState) return;\n\n if (open && mounted && transitionStatus !== 'idle') {\n setTransitionStatus('starting');\n }\n\n const frame = requestAnimationFrame(() => {\n setTransitionStatus('idle');\n });\n\n return () => cancelAnimationFrame(frame);\n }, [enableIdleState, open, mounted, transitionStatus]);\n\n return {\n mounted,\n setMounted,\n transitionStatus,\n };\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,eAAe,QAAQ,OAAO;AAIjD,OAAO,SAASC,mBAAmBA,CACjCC,IAAa,EAGb;EAAA,IAFAC,eAAwB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG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,KAAK,CAAC;EAC1C,CAAC,EAAE,CAACT,eAAe,EAAED,IAAI,CAAC,CAAC;EAE3BF,eAAe,CAAC,MAAM;IACpB,IAAI,CAACE,IAAI,IAAI,CAACC,eAAe,EAAE;IAE/B,IAAID,IAAI,IAAIQ,OAAO,IAAIF,gBAAgB,KAAK,MAAM,EAAE;MAClDC,mBAAmB,CAAC,UAAU,CAAC;IACjC;IAEA,MAAMG,KAAK,GAAGC,qBAAqB,CAAC,MAAM;MACxCJ,mBAAmB,CAAC,MAAM,CAAC;IAC7B,CAAC,CAAC;IAEF,OAAO,MAAMK,oBAAoB,CAACF,KAAK,CAAC;EAC1C,CAAC,EAAE,CAACT,eAAe,EAAED,IAAI,EAAEQ,OAAO,EAAEF,gBAAgB,CAAC,CAAC;EAEtD,OAAO;IACLE,OAAO;IACPC,UAAU;IACVH;EACF,CAAC;AACH","ignoreList":[]}
|
package/build/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './Accordion';
|
|
2
|
+
export * from './Collapsible';
|
|
2
3
|
export * from './CheckBox';
|
|
3
4
|
export * from './ComboBox';
|
|
4
5
|
export * from './FocusLock';
|
|
5
6
|
export * from './Menu';
|
|
7
|
+
export * from './MenuBar';
|
|
6
8
|
export * from './Modal';
|
|
7
9
|
export * from './Popper';
|
|
8
10
|
export * from './Portal';
|
|
@@ -10,7 +12,10 @@ export * from './RadioButton';
|
|
|
10
12
|
export * from './Slider';
|
|
11
13
|
export * from './Spinner';
|
|
12
14
|
export * from './Tabs';
|
|
15
|
+
export * from './Toggle';
|
|
16
|
+
export * from './ToggleGroup';
|
|
13
17
|
export * from './Tooltip';
|
|
18
|
+
export * from './Tree';
|
|
14
19
|
export * from './utils';
|
|
15
20
|
export * from './hooks';
|
|
16
21
|
//# sourceMappingURL=index.d.ts.map
|
package/build/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AAGvB,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC"}
|
package/build/esm/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Components
|
|
2
2
|
export * from './Accordion';
|
|
3
|
+
export * from './Collapsible';
|
|
3
4
|
export * from './CheckBox';
|
|
4
5
|
export * from './ComboBox';
|
|
5
6
|
export * from './FocusLock';
|
|
6
7
|
export * from './Menu';
|
|
8
|
+
export * from './MenuBar';
|
|
7
9
|
export * from './Modal';
|
|
8
10
|
export * from './Popper';
|
|
9
11
|
export * from './Portal';
|
|
@@ -11,7 +13,10 @@ export * from './RadioButton';
|
|
|
11
13
|
export * from './Slider';
|
|
12
14
|
export * from './Spinner';
|
|
13
15
|
export * from './Tabs';
|
|
16
|
+
export * from './Toggle';
|
|
17
|
+
export * from './ToggleGroup';
|
|
14
18
|
export * from './Tooltip';
|
|
19
|
+
export * from './Tree';
|
|
15
20
|
|
|
16
21
|
// General React utilities
|
|
17
22
|
export * from './utils';
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["// Components\nexport * from './Accordion';\nexport * from './CheckBox';\nexport * from './ComboBox';\nexport * from './FocusLock';\nexport * from './Menu';\nexport * from './Modal';\nexport * from './Popper';\nexport * from './Portal';\nexport * from './RadioButton';\nexport * from './Slider';\nexport * from './Spinner';\nexport * from './Tabs';\nexport * from './Tooltip';\n\n// General React utilities\nexport * from './utils';\n\n// Hooks\nexport * from './hooks';\n"],"mappings":"AAAA;AACA,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,WAAW;;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["// Components\nexport * from './Accordion';\nexport * from './Collapsible';\nexport * from './CheckBox';\nexport * from './ComboBox';\nexport * from './FocusLock';\nexport * from './Menu';\nexport * from './MenuBar';\nexport * from './Modal';\nexport * from './Popper';\nexport * from './Portal';\nexport * from './RadioButton';\nexport * from './Slider';\nexport * from './Spinner';\nexport * from './Tabs';\nexport * from './Toggle';\nexport * from './ToggleGroup';\nexport * from './Tooltip';\nexport * from './Tree';\n\n// General React utilities\nexport * from './utils';\n\n// Hooks\nexport * from './hooks';\n"],"mappings":"AAAA;AACA,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,QAAQ;AACtB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,QAAQ;;AAEtB;AACA,cAAc,SAAS;;AAEvB;AACA,cAAc,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ElementType, ReactNode, ButtonHTMLAttributes } from 'react';
|
|
2
|
+
export interface ToggleProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
as?: ElementType<any>;
|
|
4
|
+
innerAs?: ElementType<any>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Whether the toggle button is currently pressed.
|
|
8
|
+
* This is the controlled counterpart of `defaultPressed`.
|
|
9
|
+
*/
|
|
10
|
+
pressed?: boolean | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the toggle button is currently pressed.
|
|
13
|
+
* This is the uncontrolled counterpart of `pressed`.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
defaultPressed?: boolean | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Callback fired when the pressed state is changed.
|
|
19
|
+
*/
|
|
20
|
+
onPressedChange?: ((pressed: boolean) => void) | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* A unique string that identifies the toggle when used
|
|
23
|
+
* inside a toggle group.
|
|
24
|
+
*/
|
|
25
|
+
value?: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare const Toggle: import("react").ForwardRefExoticComponent<ToggleProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
28
|
+
//# sourceMappingURL=Toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../../../src/Toggle/Toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAK1E,MAAM,WAAW,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC1E,EAAE,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3D;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,MAAM,2GA+DlB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { forwardRef, useId, useState, Fragment } from 'react';
|
|
2
|
+
import { useToggleGroupContext } from '../ToggleGroup/ToggleGroupContext';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export const Toggle = /*#__PURE__*/forwardRef(function Toggle(props, forwardedRef) {
|
|
5
|
+
const {
|
|
6
|
+
as: Comp = 'button',
|
|
7
|
+
innerAs,
|
|
8
|
+
defaultPressed = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
onPressedChange: onPressedChangeProp,
|
|
11
|
+
pressed: pressedProp,
|
|
12
|
+
value: valueProp,
|
|
13
|
+
onClick: onClickProp,
|
|
14
|
+
...otherProps
|
|
15
|
+
} = props;
|
|
16
|
+
const useIdValue = useId();
|
|
17
|
+
const value = valueProp || useIdValue;
|
|
18
|
+
const groupContext = useToggleGroupContext();
|
|
19
|
+
const groupValue = groupContext?.value ?? [];
|
|
20
|
+
const isControlled = pressedProp !== undefined;
|
|
21
|
+
const [pressedState, setPressedState] = useState(defaultPressed);
|
|
22
|
+
const isDisabled = disabled || groupContext?.disabled || false;
|
|
23
|
+
|
|
24
|
+
// When in a group, the pressed state is derived from the group's value array
|
|
25
|
+
// When not in a group, use the passed pressed prop if controlled, otherwise internal state
|
|
26
|
+
const pressed = groupContext ? groupValue.includes(value) : isControlled ? pressedProp : pressedState;
|
|
27
|
+
const handleClick = e => {
|
|
28
|
+
onClickProp?.(e);
|
|
29
|
+
if (isDisabled) return;
|
|
30
|
+
const nextPressed = !pressed;
|
|
31
|
+
onPressedChangeProp?.(nextPressed);
|
|
32
|
+
if (groupContext) {
|
|
33
|
+
groupContext.onValueChange?.(value, nextPressed);
|
|
34
|
+
} else if (!isControlled) {
|
|
35
|
+
setPressedState(nextPressed);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
39
|
+
...(Comp !== Fragment ? {
|
|
40
|
+
as: innerAs,
|
|
41
|
+
ref: forwardedRef
|
|
42
|
+
} : {
|
|
43
|
+
ref: forwardedRef
|
|
44
|
+
}),
|
|
45
|
+
type: "button",
|
|
46
|
+
disabled: isDisabled,
|
|
47
|
+
"aria-pressed": pressed,
|
|
48
|
+
onClick: handleClick,
|
|
49
|
+
"data-toggle": "",
|
|
50
|
+
"data-pressed": pressed ? '' : undefined,
|
|
51
|
+
"data-disabled": isDisabled ? '' : undefined,
|
|
52
|
+
...otherProps
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=Toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.js","names":["forwardRef","useId","useState","Fragment","useToggleGroupContext","jsx","_jsx","Toggle","props","forwardedRef","as","Comp","innerAs","defaultPressed","disabled","onPressedChange","onPressedChangeProp","pressed","pressedProp","value","valueProp","onClick","onClickProp","otherProps","useIdValue","groupContext","groupValue","isControlled","undefined","pressedState","setPressedState","isDisabled","includes","handleClick","e","nextPressed","onValueChange","ref","type"],"sources":["../../../src/Toggle/Toggle.tsx"],"sourcesContent":["import type { ElementType, ReactNode, ButtonHTMLAttributes } from 'react';\nimport { forwardRef, useId, useState, Fragment } from 'react';\n\nimport { useToggleGroupContext } from '../ToggleGroup/ToggleGroupContext';\n\nexport interface ToggleProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n /**\n * Whether the toggle button is currently pressed.\n * This is the controlled counterpart of `defaultPressed`.\n */\n pressed?: boolean | undefined;\n /**\n * Whether the toggle button is currently pressed.\n * This is the uncontrolled counterpart of `pressed`.\n * @default false\n */\n defaultPressed?: boolean | undefined;\n /**\n * Callback fired when the pressed state is changed.\n */\n onPressedChange?: ((pressed: boolean) => void) | undefined;\n /**\n * A unique string that identifies the toggle when used\n * inside a toggle group.\n */\n value?: string | undefined;\n}\n\nexport const Toggle = forwardRef<HTMLButtonElement, ToggleProps>(\n function Toggle(props, forwardedRef) {\n const {\n as: Comp = 'button',\n innerAs,\n defaultPressed = false,\n disabled = false,\n onPressedChange: onPressedChangeProp,\n pressed: pressedProp,\n value: valueProp,\n onClick: onClickProp,\n ...otherProps\n } = props;\n\n const useIdValue = useId();\n const value = valueProp || useIdValue;\n const groupContext = useToggleGroupContext();\n const groupValue = groupContext?.value ?? [];\n const isControlled = pressedProp !== undefined;\n const [pressedState, setPressedState] = useState(defaultPressed);\n\n const isDisabled = disabled || groupContext?.disabled || false;\n\n // When in a group, the pressed state is derived from the group's value array\n // When not in a group, use the passed pressed prop if controlled, otherwise internal state\n const pressed = groupContext\n ? groupValue.includes(value)\n : isControlled\n ? pressedProp\n : pressedState;\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClickProp?.(e);\n\n if (isDisabled) return;\n\n const nextPressed = !pressed;\n\n onPressedChangeProp?.(nextPressed);\n\n if (groupContext) {\n groupContext.onValueChange?.(value, nextPressed);\n } else if (!isControlled) {\n setPressedState(nextPressed);\n }\n };\n\n return (\n <Comp\n {...(Comp !== Fragment\n ? { as: innerAs, ref: forwardedRef }\n : { ref: forwardedRef })}\n type=\"button\"\n disabled={isDisabled}\n aria-pressed={pressed}\n onClick={handleClick}\n data-toggle=\"\"\n data-pressed={pressed ? '' : undefined}\n data-disabled={isDisabled ? '' : undefined}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":"AACA,SAASA,UAAU,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,OAAO;AAE7D,SAASC,qBAAqB,QAAQ,mCAAmC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA4B1E,OAAO,MAAMC,MAAM,gBAAGP,UAAU,CAC9B,SAASO,MAAMA,CAACC,KAAK,EAAEC,YAAY,EAAE;EACnC,MAAM;IACJC,EAAE,EAAEC,IAAI,GAAG,QAAQ;IACnBC,OAAO;IACPC,cAAc,GAAG,KAAK;IACtBC,QAAQ,GAAG,KAAK;IAChBC,eAAe,EAAEC,mBAAmB;IACpCC,OAAO,EAAEC,WAAW;IACpBC,KAAK,EAAEC,SAAS;IAChBC,OAAO,EAAEC,WAAW;IACpB,GAAGC;EACL,CAAC,GAAGf,KAAK;EAET,MAAMgB,UAAU,GAAGvB,KAAK,CAAC,CAAC;EAC1B,MAAMkB,KAAK,GAAGC,SAAS,IAAII,UAAU;EACrC,MAAMC,YAAY,GAAGrB,qBAAqB,CAAC,CAAC;EAC5C,MAAMsB,UAAU,GAAGD,YAAY,EAAEN,KAAK,IAAI,EAAE;EAC5C,MAAMQ,YAAY,GAAGT,WAAW,KAAKU,SAAS;EAC9C,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAG5B,QAAQ,CAACW,cAAc,CAAC;EAEhE,MAAMkB,UAAU,GAAGjB,QAAQ,IAAIW,YAAY,EAAEX,QAAQ,IAAI,KAAK;;EAE9D;EACA;EACA,MAAMG,OAAO,GAAGQ,YAAY,GACxBC,UAAU,CAACM,QAAQ,CAACb,KAAK,CAAC,GAC1BQ,YAAY,GACVT,WAAW,GACXW,YAAY;EAElB,MAAMI,WAAW,GAAIC,CAAsC,IAAK;IAC9DZ,WAAW,GAAGY,CAAC,CAAC;IAEhB,IAAIH,UAAU,EAAE;IAEhB,MAAMI,WAAW,GAAG,CAAClB,OAAO;IAE5BD,mBAAmB,GAAGmB,WAAW,CAAC;IAElC,IAAIV,YAAY,EAAE;MAChBA,YAAY,CAACW,aAAa,GAAGjB,KAAK,EAAEgB,WAAW,CAAC;IAClD,CAAC,MAAM,IAAI,CAACR,YAAY,EAAE;MACxBG,eAAe,CAACK,WAAW,CAAC;IAC9B;EACF,CAAC;EAED,oBACE7B,IAAA,CAACK,IAAI;IAAA,IACEA,IAAI,KAAKR,QAAQ,GAClB;MAAEO,EAAE,EAAEE,OAAO;MAAEyB,GAAG,EAAE5B;IAAa,CAAC,GAClC;MAAE4B,GAAG,EAAE5B;IAAa,CAAC;IACzB6B,IAAI,EAAC,QAAQ;IACbxB,QAAQ,EAAEiB,UAAW;IACrB,gBAAcd,OAAQ;IACtBI,OAAO,EAAEY,WAAY;IACrB,eAAY,EAAE;IACd,gBAAchB,OAAO,GAAG,EAAE,GAAGW,SAAU;IACvC,iBAAeG,UAAU,GAAG,EAAE,GAAGH,SAAU;IAAA,GACvCL;EAAU,CACf,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Toggle/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Toggle/index.ts"],"sourcesContent":["export * from './Toggle';\n"],"mappings":"AAAA,cAAc,UAAU","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function assignRef<T>(ref:
|
|
3
|
-
export declare function assignMultipleRefs<T>(...refs: (
|
|
1
|
+
import type { RefObject, RefCallback } from 'react';
|
|
2
|
+
export declare function assignRef<T>(ref: RefObject<T> | RefCallback<T> | null | undefined, value: T): void;
|
|
3
|
+
export declare function assignMultipleRefs<T>(...refs: (RefObject<T> | RefCallback<T> | null | undefined)[]): RefCallback<T>;
|
|
4
4
|
//# sourceMappingURL=assign-ref.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assign-ref.d.ts","sourceRoot":"","sources":["../../../src/utils/assign-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"assign-ref.d.ts","sourceRoot":"","sources":["../../../src/utils/assign-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpD,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EACrD,KAAK,EAAE,CAAC,QAYT;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC5D,WAAW,CAAC,CAAC,CAAC,CAMhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assign-ref.js","names":["assignRef","ref","value","current","
|
|
1
|
+
{"version":3,"file":"assign-ref.js","names":["assignRef","ref","value","current","Error","assignMultipleRefs","_len","arguments","length","refs","Array","_key","node","forEach"],"sources":["../../../src/utils/assign-ref.ts"],"sourcesContent":["import type { RefObject, RefCallback } from 'react';\n\nexport function assignRef<T>(\n ref: RefObject<T> | RefCallback<T> | null | undefined,\n value: T\n) {\n if (ref == null) return;\n if (typeof ref === 'function') {\n ref(value);\n } else {\n try {\n ref.current = value;\n } catch {\n throw new Error(`Cannot assign value \"${value}\" to ref \"${ref}\"`);\n }\n }\n}\n\nexport function assignMultipleRefs<T>(\n ...refs: (RefObject<T> | RefCallback<T> | null | undefined)[]\n): RefCallback<T> {\n return (node: T | null) => {\n refs.forEach((ref) => {\n assignRef(ref, node);\n });\n };\n}\n"],"mappings":"AAEA,OAAO,SAASA,SAASA,CACvBC,GAAqD,EACrDC,KAAQ,EACR;EACA,IAAID,GAAG,IAAI,IAAI,EAAE;EACjB,IAAI,OAAOA,GAAG,KAAK,UAAU,EAAE;IAC7BA,GAAG,CAACC,KAAK,CAAC;EACZ,CAAC,MAAM;IACL,IAAI;MACFD,GAAG,CAACE,OAAO,GAAGD,KAAK;IACrB,CAAC,CAAC,MAAM;MACN,MAAM,IAAIE,KAAK,CAAC,wBAAwBF,KAAK,aAAaD,GAAG,GAAG,CAAC;IACnE;EACF;AACF;AAEA,OAAO,SAASI,kBAAkBA,CAAA,EAEhB;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADbC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAEP,OAAQC,IAAc,IAAK;IACzBH,IAAI,CAACI,OAAO,CAAEZ,GAAG,IAAK;MACpBD,SAAS,CAACC,GAAG,EAAEW,IAAI,CAAC;IACtB,CAAC,CAAC;EACJ,CAAC;AACH","ignoreList":[]}
|