tfy-web-components 0.0.34 → 0.0.35
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/README.md +49 -58
- package/dist/Button-C77b7jpW.js +284 -0
- package/dist/Button-C77b7jpW.js.map +1 -0
- package/dist/CompositeItem-BGwD51jI.js +33 -0
- package/dist/CompositeItem-BGwD51jI.js.map +1 -0
- package/dist/CompositeList-D4xmSZ5V.js +291 -0
- package/dist/CompositeList-D4xmSZ5V.js.map +1 -0
- package/dist/CompositeRoot-BxrPc7F6.js +351 -0
- package/dist/CompositeRoot-BxrPc7F6.js.map +1 -0
- package/dist/DirectionContext-Pb9yafF5.js +11 -0
- package/dist/DirectionContext-Pb9yafF5.js.map +1 -0
- package/dist/FieldItemContext-DRVgx-D1.js +13 -0
- package/dist/FieldItemContext-DRVgx-D1.js.map +1 -0
- package/dist/{Input-BvwIpntS.js → Input-Dhmo6L2n.js} +100 -78
- package/dist/Input-Dhmo6L2n.js.map +1 -0
- package/dist/Modal-C4MUy9GD.js +696 -0
- package/dist/Modal-C4MUy9GD.js.map +1 -0
- package/dist/{MonacoEditorCore-xfpJ6z-E.js → MonacoEditorCore-n-df5f7I.js} +2 -2
- package/dist/{MonacoEditorCore-xfpJ6z-E.js.map → MonacoEditorCore-n-df5f7I.js.map} +1 -1
- package/dist/Popover-eC_vX5By.js +1074 -0
- package/dist/Popover-eC_vX5By.js.map +1 -0
- package/dist/ToolbarRootContext-B_HxjkNI.js +11 -0
- package/dist/ToolbarRootContext-B_HxjkNI.js.map +1 -0
- package/dist/Tooltip-BuGLP-PU.js +4096 -0
- package/dist/Tooltip-BuGLP-PU.js.map +1 -0
- package/dist/classNames-B1XpQHle.js +44 -0
- package/dist/classNames-B1XpQHle.js.map +1 -0
- package/dist/components/atoms/Accordion.d.ts +19 -37
- package/dist/components/atoms/Accordion.es.js +847 -78
- package/dist/components/atoms/Accordion.es.js.map +1 -1
- package/dist/components/atoms/AudioPlayer.es.js +9 -9
- package/dist/components/atoms/AudioPlayer.es.js.map +1 -1
- package/dist/components/atoms/Avatar.d.ts +42 -9
- package/dist/components/atoms/Avatar.es.js +491 -36
- package/dist/components/atoms/Avatar.es.js.map +1 -1
- package/dist/components/atoms/Badge.d.ts +40 -35
- package/dist/components/atoms/Badge.es.js +163 -53
- package/dist/components/atoms/Badge.es.js.map +1 -1
- package/dist/components/atoms/Button.d.ts +37 -16
- package/dist/components/atoms/Button.es.js +16 -221
- package/dist/components/atoms/Button.es.js.map +1 -1
- package/dist/components/atoms/ButtonGroup.d.ts +53 -0
- package/dist/components/atoms/ButtonGroup.es.js +349 -0
- package/dist/components/atoms/ButtonGroup.es.js.map +1 -0
- package/dist/components/atoms/IconButton.d.ts +23 -9
- package/dist/components/atoms/IconButton.es.js +82 -16
- package/dist/components/atoms/IconButton.es.js.map +1 -1
- package/dist/components/atoms/IconProvider.d.ts +1 -1
- package/dist/components/atoms/IconProvider.es.js +48 -7
- package/dist/components/atoms/IconProvider.es.js.map +1 -1
- package/dist/components/atoms/Modal.d.ts +27 -3
- package/dist/components/atoms/Modal.es.js +15 -16
- package/dist/components/atoms/Modal.es.js.map +1 -1
- package/dist/components/atoms/Notification.d.ts +1 -1
- package/dist/components/atoms/Notification.es.js +26 -3
- package/dist/components/atoms/Notification.es.js.map +1 -1
- package/dist/components/atoms/OutlinedRadio.d.ts +6 -2
- package/dist/components/atoms/OutlinedRadio.es.js +12 -25
- package/dist/components/atoms/OutlinedRadio.es.js.map +1 -1
- package/dist/components/atoms/Progress.d.ts +48 -0
- package/dist/components/atoms/Progress.es.js +279 -0
- package/dist/components/atoms/Progress.es.js.map +1 -0
- package/dist/components/atoms/Skeleton.d.ts +9 -3
- package/dist/components/atoms/Skeleton.es.js +33 -3
- package/dist/components/atoms/Skeleton.es.js.map +1 -1
- package/dist/components/atoms/Spinner.d.ts +15 -4
- package/dist/components/atoms/Spinner.es.js +86 -22
- package/dist/components/atoms/Spinner.es.js.map +1 -1
- package/dist/components/atoms/Switch.d.ts +19 -7
- package/dist/components/atoms/Switch.es.js +288 -50
- package/dist/components/atoms/Switch.es.js.map +1 -1
- package/dist/components/atoms/TabButton.d.ts +17 -3
- package/dist/components/atoms/TabButton.es.js +647 -25
- package/dist/components/atoms/TabButton.es.js.map +1 -1
- package/dist/components/atoms/TabPanel.es.js +1 -1
- package/dist/components/atoms/Tag.d.ts +43 -0
- package/dist/components/atoms/Tag.es.js +219 -0
- package/dist/components/atoms/Tag.es.js.map +1 -0
- package/dist/components/atoms/Tooltip.d.ts +36 -14
- package/dist/components/atoms/Tooltip.es.js +7 -114
- package/dist/components/atoms/Tooltip.es.js.map +1 -1
- package/dist/components/molecules/Alert.d.ts +1 -1
- package/dist/components/molecules/Alert.es.js +13 -9
- package/dist/components/molecules/Alert.es.js.map +1 -1
- package/dist/components/molecules/CopyField.d.ts +2 -2
- package/dist/components/molecules/CopyField.es.js +3 -4
- package/dist/components/molecules/CopyField.es.js.map +1 -1
- package/dist/components/molecules/CustomDrawer.d.ts +5 -4
- package/dist/components/molecules/CustomDrawer.es.js +141 -82
- package/dist/components/molecules/CustomDrawer.es.js.map +1 -1
- package/dist/components/molecules/Dialog.d.ts +16 -8
- package/dist/components/molecules/Dialog.es.js +33 -31
- package/dist/components/molecules/Dialog.es.js.map +1 -1
- package/dist/components/molecules/ImagesPreview.es.js +15 -11
- package/dist/components/molecules/ImagesPreview.es.js.map +1 -1
- package/dist/components/molecules/Input.d.ts +1 -1
- package/dist/components/molecules/Input.es.js +3 -5
- package/dist/components/molecules/Input.es.js.map +1 -1
- package/dist/components/molecules/Markdown/ExpandableMarkdown.d.ts +8 -8
- package/dist/components/molecules/Markdown/components.d.ts +12 -11
- package/dist/components/molecules/Markdown.es.js +26 -49
- package/dist/components/molecules/Markdown.es.js.map +1 -1
- package/dist/components/molecules/Notify.d.ts +30 -1
- package/dist/components/molecules/Notify.es.js +91 -36
- package/dist/components/molecules/Notify.es.js.map +1 -1
- package/dist/components/molecules/SimpleCodeEditor.es.js +32 -19
- package/dist/components/molecules/SimpleCodeEditor.es.js.map +1 -1
- package/dist/components/molecules/ToggleButton.d.ts +3 -2
- package/dist/components/molecules/ToggleButton.es.js +155 -57
- package/dist/components/molecules/ToggleButton.es.js.map +1 -1
- package/dist/components/molecules/agent-chat/UserMessage.es.js +2 -2
- package/dist/components/molecules/agent-chat/UserMessage.es.js.map +1 -1
- package/dist/components/molecules/agent-chat/UserMessageEdit.es.js +5 -5
- package/dist/components/molecules/agent-chat/UserMessageEdit.es.js.map +1 -1
- package/dist/components/molecules/agent-chat/index.d.ts +0 -6
- package/dist/components/molecules/agent-chat.es.js +76 -407
- package/dist/components/molecules/agent-chat.es.js.map +1 -1
- package/dist/components/molecules/monacoEditorCore/MonacoEditorCore.d.ts +0 -1
- package/dist/components/theme/colors.d.ts +17 -53
- package/dist/components/theme/colors.es.js +384 -180
- package/dist/components/theme/colors.es.js.map +1 -1
- package/dist/components/theme/theme.d.ts +14 -11
- package/dist/components/theme/theme.es.js +3 -64
- package/dist/components/theme/theme.es.js.map +1 -1
- package/dist/components/theme/useTheme.es.js +1 -4
- package/dist/components/theme/useTheme.es.js.map +1 -1
- package/dist/composite-CrCQWAKA.js +108 -0
- package/dist/composite-CrCQWAKA.js.map +1 -0
- package/dist/composite-DCpXNxz9.js +66 -0
- package/dist/composite-DCpXNxz9.js.map +1 -0
- package/dist/conversions-CbWPvHRE.js +14 -0
- package/dist/conversions-CbWPvHRE.js.map +1 -0
- package/dist/error-FX4R42W-.js +6 -0
- package/dist/error-FX4R42W-.js.map +1 -0
- package/dist/fonts.css +7 -0
- package/dist/hooks/useContainerDimensions.d.ts +1 -1
- package/dist/index-B806bfA-.js +257 -0
- package/dist/index-B806bfA-.js.map +1 -0
- package/dist/index-DSVg79g-.js +45 -0
- package/dist/index-DSVg79g-.js.map +1 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.es.js +56 -9
- package/dist/index.es.js.map +1 -1
- package/dist/inertValue-IJM5NA30.js +11 -0
- package/dist/inertValue-IJM5NA30.js.map +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/markdown.css +13 -14
- package/dist/new-components/atoms/Checkbox.d.ts +6 -0
- package/dist/new-components/atoms/Checkbox.es.js +423 -0
- package/dist/new-components/atoms/Checkbox.es.js.map +1 -0
- package/dist/new-components/atoms/Chip.d.ts +38 -0
- package/dist/new-components/atoms/Chip.es.js +269 -0
- package/dist/new-components/atoms/Chip.es.js.map +1 -0
- package/dist/new-components/atoms/Popover.d.ts +87 -0
- package/dist/new-components/atoms/Popover.es.js +21 -0
- package/dist/new-components/atoms/Popover.es.js.map +1 -0
- package/dist/new-components/atoms/Radio.d.ts +14 -0
- package/dist/new-components/atoms/Radio.es.js +536 -0
- package/dist/new-components/atoms/Radio.es.js.map +1 -0
- package/dist/new-components/atoms/SegmentedControl.d.ts +28 -0
- package/dist/new-components/atoms/SegmentedControl.es.js +326 -0
- package/dist/new-components/atoms/SegmentedControl.es.js.map +1 -0
- package/dist/new-components/atoms/Slider.d.ts +8 -0
- package/dist/new-components/atoms/Slider.es.js +1415 -0
- package/dist/new-components/atoms/Slider.es.js.map +1 -0
- package/dist/new-components/atoms/Toggletip.d.ts +43 -0
- package/dist/new-components/atoms/Toggletip.es.js +216 -0
- package/dist/new-components/atoms/Toggletip.es.js.map +1 -0
- package/dist/new-components/atoms/stories/ThemeComparison.d.ts +8 -0
- package/dist/shadowDom-Bq4g0Qeu.js +52 -0
- package/dist/shadowDom-Bq4g0Qeu.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/theme.css +9 -154
- package/dist/tokens.css +1136 -0
- package/dist/useAnimationFrame-DwhymJoW.js +108 -0
- package/dist/useAnimationFrame-DwhymJoW.js.map +1 -0
- package/dist/useAriaLabelledBy-B6n92QBS.js +49 -0
- package/dist/useAriaLabelledBy-B6n92QBS.js.map +1 -0
- package/dist/useBaseUiId-Ch7ujXpo.js +281 -0
- package/dist/useBaseUiId-Ch7ujXpo.js.map +1 -0
- package/dist/useButton-PUBhT4Vo.js +235 -0
- package/dist/useButton-PUBhT4Vo.js.map +1 -0
- package/dist/useControlled-BSyYkg5C.js +65 -0
- package/dist/useControlled-BSyYkg5C.js.map +1 -0
- package/dist/useIsoLayoutEffect-e9VA-ICd.js +499 -0
- package/dist/useIsoLayoutEffect-e9VA-ICd.js.map +1 -0
- package/dist/useLabelableId-DCLzrdD-.js +241 -0
- package/dist/useLabelableId-DCLzrdD-.js.map +1 -0
- package/dist/useOpenInteractionType-DGWLoAqp.js +1086 -0
- package/dist/useOpenInteractionType-DGWLoAqp.js.map +1 -0
- package/dist/usePopupHandleStore-BdS-xYID.js +2372 -0
- package/dist/usePopupHandleStore-BdS-xYID.js.map +1 -0
- package/dist/useTimeout-BXf1hDIL.js +46 -0
- package/dist/useTimeout-BXf1hDIL.js.map +1 -0
- package/dist/useTransitionStatus-C9gg_XJ-.js +202 -0
- package/dist/useTransitionStatus-C9gg_XJ-.js.map +1 -0
- package/dist/useValueAsRef-BfFRcMg6.js +28 -0
- package/dist/useValueAsRef-BfFRcMg6.js.map +1 -0
- package/dist/utils/classNames.d.ts +3 -2
- package/dist/visuallyHidden-B6H2X3_Y.js +26 -0
- package/dist/visuallyHidden-B6H2X3_Y.js.map +1 -0
- package/dist/vite-env.d.ts +18 -0
- package/package.json +30 -22
- package/dist/Input-BvwIpntS.js.map +0 -1
- package/dist/Notification-BT4CZ69U.js +0 -39
- package/dist/Notification-BT4CZ69U.js.map +0 -1
- package/dist/RootFontSizeContext-7vgn7Y_k.js +0 -22
- package/dist/RootFontSizeContext-7vgn7Y_k.js.map +0 -1
- package/dist/classNames-Dy-RXSjS.js +0 -9
- package/dist/classNames-Dy-RXSjS.js.map +0 -1
- package/dist/components/molecules/DropdownMenu.d.ts +0 -18
- package/dist/components/molecules/DropdownMenu.es.js +0 -104
- package/dist/components/molecules/DropdownMenu.es.js.map +0 -1
- package/dist/components/molecules/ThumbsFeedback.d.ts +0 -13
- package/dist/components/molecules/ThumbsFeedback.es.js +0 -98
- package/dist/components/molecules/ThumbsFeedback.es.js.map +0 -1
- package/dist/components/molecules/agent-chat/SandboxToolCall.d.ts +0 -15
- package/dist/components/molecules/agent-chat/ToolCallCard.d.ts +0 -26
- package/dist/components/molecules/agent-chat/ToolCallContentBlock.d.ts +0 -17
- package/dist/components/theme/lightColorPlugin.d.ts +0 -1
- package/dist/components/theme/lightColorPlugin.es.js +0 -92
- package/dist/components/theme/lightColorPlugin.es.js.map +0 -1
- package/dist/tailwindPreset.d.ts +0 -144
- package/dist/tailwindPreset.es.js +0 -100
- package/dist/tailwindPreset.es.js.map +0 -1
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { u as useIsoLayoutEffect, a as useStableCallback, e as useRefWithInit } from "./useIsoLayoutEffect-e9VA-ICd.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
const CompositeListContext = /* @__PURE__ */ React.createContext({
|
|
5
|
+
register: () => {
|
|
6
|
+
},
|
|
7
|
+
unregister: () => {
|
|
8
|
+
},
|
|
9
|
+
subscribeMapChange: () => () => {
|
|
10
|
+
},
|
|
11
|
+
nextIndexRef: {
|
|
12
|
+
current: 0
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (process.env.NODE_ENV !== "production") CompositeListContext.displayName = "CompositeListContext";
|
|
16
|
+
function useCompositeListContext() {
|
|
17
|
+
return React.useContext(CompositeListContext);
|
|
18
|
+
}
|
|
19
|
+
function useCompositeListItem(params = {}) {
|
|
20
|
+
const {
|
|
21
|
+
guess,
|
|
22
|
+
label,
|
|
23
|
+
metadata,
|
|
24
|
+
textRef,
|
|
25
|
+
index: externalIndex
|
|
26
|
+
} = params;
|
|
27
|
+
const {
|
|
28
|
+
register,
|
|
29
|
+
unregister,
|
|
30
|
+
subscribeMapChange,
|
|
31
|
+
nextIndexRef
|
|
32
|
+
} = useCompositeListContext();
|
|
33
|
+
const indexRef = React.useRef(-1);
|
|
34
|
+
const [internalIndex, setInternalIndex] = React.useState(externalIndex == null && guess ? () => {
|
|
35
|
+
if (indexRef.current === -1) {
|
|
36
|
+
const newIndex = nextIndexRef.current;
|
|
37
|
+
nextIndexRef.current += 1;
|
|
38
|
+
indexRef.current = newIndex;
|
|
39
|
+
}
|
|
40
|
+
return indexRef.current;
|
|
41
|
+
} : -1);
|
|
42
|
+
const index = externalIndex ?? internalIndex;
|
|
43
|
+
const componentRef = React.useRef(null);
|
|
44
|
+
const ref = React.useCallback((node) => {
|
|
45
|
+
const previousNode = componentRef.current;
|
|
46
|
+
if (previousNode) {
|
|
47
|
+
unregister(previousNode);
|
|
48
|
+
}
|
|
49
|
+
componentRef.current = node;
|
|
50
|
+
if (node) {
|
|
51
|
+
register(node, {
|
|
52
|
+
metadata: metadata ?? null,
|
|
53
|
+
index: externalIndex ?? null,
|
|
54
|
+
label,
|
|
55
|
+
textRef
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}, [externalIndex, register, unregister, metadata, label, textRef]);
|
|
59
|
+
useIsoLayoutEffect(() => {
|
|
60
|
+
if (externalIndex != null) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
return subscribeMapChange((map) => {
|
|
64
|
+
var _a;
|
|
65
|
+
const i = componentRef.current ? (_a = map.get(componentRef.current)) == null ? void 0 : _a.index : null;
|
|
66
|
+
if (i != null) {
|
|
67
|
+
setInternalIndex(i);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}, [externalIndex, subscribeMapChange]);
|
|
71
|
+
return {
|
|
72
|
+
ref,
|
|
73
|
+
index
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function CompositeList(props) {
|
|
77
|
+
const {
|
|
78
|
+
children,
|
|
79
|
+
elementsRef,
|
|
80
|
+
labelsRef,
|
|
81
|
+
onMapChange: onMapChangeProp
|
|
82
|
+
} = props;
|
|
83
|
+
const onMapChange = useStableCallback(onMapChangeProp);
|
|
84
|
+
const [, setMapTick] = React.useState(0);
|
|
85
|
+
const listeners = useRefWithInit(createListeners).current;
|
|
86
|
+
const map = useRefWithInit(createMap).current;
|
|
87
|
+
const nextIndexRef = React.useRef(0);
|
|
88
|
+
const isDirtyRef = React.useRef(true);
|
|
89
|
+
const itemsRef = React.useRef(null);
|
|
90
|
+
const mutationObserverRef = React.useRef(null);
|
|
91
|
+
const scheduleMapUpdate = useStableCallback(() => {
|
|
92
|
+
if (isDirtyRef.current) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
isDirtyRef.current = true;
|
|
96
|
+
setMapTick((tick) => tick + 1);
|
|
97
|
+
});
|
|
98
|
+
const register = useStableCallback((node, registration) => {
|
|
99
|
+
map.set(node, registration);
|
|
100
|
+
scheduleMapUpdate();
|
|
101
|
+
});
|
|
102
|
+
const unregister = useStableCallback((node) => {
|
|
103
|
+
map.delete(node);
|
|
104
|
+
scheduleMapUpdate();
|
|
105
|
+
});
|
|
106
|
+
const syncRefs = useStableCallback((items) => {
|
|
107
|
+
const nextMap = /* @__PURE__ */ new Map();
|
|
108
|
+
elementsRef.current.length = 0;
|
|
109
|
+
if (labelsRef) {
|
|
110
|
+
labelsRef.current.length = 0;
|
|
111
|
+
}
|
|
112
|
+
items.forEach((item) => {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
nextMap.set(item.element, {
|
|
115
|
+
...item.registration.metadata ?? {},
|
|
116
|
+
index: item.index
|
|
117
|
+
});
|
|
118
|
+
elementsRef.current[item.index] = item.element;
|
|
119
|
+
if (labelsRef) {
|
|
120
|
+
labelsRef.current[item.index] = item.registration.label !== void 0 ? item.registration.label : ((_b = (_a = item.registration.textRef) == null ? void 0 : _a.current) == null ? void 0 : _b.textContent) ?? item.element.textContent;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
nextIndexRef.current = elementsRef.current.length;
|
|
124
|
+
return nextMap;
|
|
125
|
+
});
|
|
126
|
+
function observe(sortedNodes) {
|
|
127
|
+
var _a;
|
|
128
|
+
(_a = mutationObserverRef.current) == null ? void 0 : _a.disconnect();
|
|
129
|
+
mutationObserverRef.current = null;
|
|
130
|
+
if (typeof MutationObserver !== "function" || sortedNodes.length < 2) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const mutationObserver = new MutationObserver((entries) => {
|
|
134
|
+
if (!hasMovedNode(entries)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let previousConnectedNode = null;
|
|
138
|
+
for (const node of sortedNodes) {
|
|
139
|
+
if (!node.isConnected) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (previousConnectedNode && sortByDocumentPosition(previousConnectedNode, node) > 0) {
|
|
143
|
+
mutationObserver.disconnect();
|
|
144
|
+
scheduleMapUpdate();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
previousConnectedNode = node;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
mutationObserverRef.current = mutationObserver;
|
|
151
|
+
const roots = /* @__PURE__ */ new Set();
|
|
152
|
+
for (let i = 1; i < sortedNodes.length; i += 1) {
|
|
153
|
+
const root = getCommonAncestor(sortedNodes[i - 1], sortedNodes[i]);
|
|
154
|
+
if (root) {
|
|
155
|
+
roots.add(root);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
roots.forEach((root) => mutationObserver.observe(root, {
|
|
159
|
+
childList: true
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
const flush = useStableCallback(() => {
|
|
163
|
+
const [items, automaticNodes] = getCompositeListSnapshot(map);
|
|
164
|
+
const nextMap = syncRefs(items);
|
|
165
|
+
const previousItems = itemsRef.current;
|
|
166
|
+
const changed = !previousItems || previousItems.length !== items.length || items.some((item, index) => {
|
|
167
|
+
const previousItem = previousItems[index];
|
|
168
|
+
return item.index !== previousItem.index || item.element !== previousItem.element || item.registration.index !== previousItem.registration.index || item.registration.metadata !== previousItem.registration.metadata;
|
|
169
|
+
});
|
|
170
|
+
observe(automaticNodes);
|
|
171
|
+
itemsRef.current = items;
|
|
172
|
+
isDirtyRef.current = false;
|
|
173
|
+
if (!changed) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
listeners.forEach((listener) => listener(nextMap));
|
|
177
|
+
onMapChange(nextMap);
|
|
178
|
+
});
|
|
179
|
+
useIsoLayoutEffect(() => {
|
|
180
|
+
if (!isDirtyRef.current && itemsRef.current) {
|
|
181
|
+
syncRefs(itemsRef.current);
|
|
182
|
+
}
|
|
183
|
+
return () => {
|
|
184
|
+
elementsRef.current = [];
|
|
185
|
+
if (labelsRef) {
|
|
186
|
+
labelsRef.current = [];
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}, [elementsRef, labelsRef, syncRefs]);
|
|
190
|
+
useIsoLayoutEffect(() => {
|
|
191
|
+
if (isDirtyRef.current) {
|
|
192
|
+
flush();
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
useIsoLayoutEffect(() => {
|
|
196
|
+
return () => {
|
|
197
|
+
var _a;
|
|
198
|
+
(_a = mutationObserverRef.current) == null ? void 0 : _a.disconnect();
|
|
199
|
+
isDirtyRef.current = true;
|
|
200
|
+
};
|
|
201
|
+
}, []);
|
|
202
|
+
const subscribeMapChange = useStableCallback((fn) => {
|
|
203
|
+
listeners.add(fn);
|
|
204
|
+
return () => {
|
|
205
|
+
listeners.delete(fn);
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
const contextValue = React.useMemo(() => ({
|
|
209
|
+
register,
|
|
210
|
+
unregister,
|
|
211
|
+
subscribeMapChange,
|
|
212
|
+
nextIndexRef
|
|
213
|
+
}), [register, unregister, subscribeMapChange, nextIndexRef]);
|
|
214
|
+
return /* @__PURE__ */ jsx(CompositeListContext.Provider, {
|
|
215
|
+
value: contextValue,
|
|
216
|
+
children
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function createMap() {
|
|
220
|
+
return /* @__PURE__ */ new Map();
|
|
221
|
+
}
|
|
222
|
+
function createListeners() {
|
|
223
|
+
return /* @__PURE__ */ new Set();
|
|
224
|
+
}
|
|
225
|
+
function getCompositeListSnapshot(map) {
|
|
226
|
+
const reservedIndices = /* @__PURE__ */ new Set();
|
|
227
|
+
const items = [];
|
|
228
|
+
const automaticItems = [];
|
|
229
|
+
map.forEach((registration, node) => {
|
|
230
|
+
if (!node.isConnected) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const index = registration.index;
|
|
234
|
+
const item = {
|
|
235
|
+
index: index ?? -1,
|
|
236
|
+
element: node,
|
|
237
|
+
registration
|
|
238
|
+
};
|
|
239
|
+
if (index === null) {
|
|
240
|
+
automaticItems.push(item);
|
|
241
|
+
} else if (index >= 0) {
|
|
242
|
+
reservedIndices.add(index);
|
|
243
|
+
items.push(item);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
let nextAutomaticIndex = 0;
|
|
247
|
+
automaticItems.sort((a, b) => sortByDocumentPosition(a.element, b.element));
|
|
248
|
+
automaticItems.forEach((item) => {
|
|
249
|
+
while (reservedIndices.has(nextAutomaticIndex)) {
|
|
250
|
+
nextAutomaticIndex += 1;
|
|
251
|
+
}
|
|
252
|
+
item.index = nextAutomaticIndex;
|
|
253
|
+
items.push(item);
|
|
254
|
+
nextAutomaticIndex += 1;
|
|
255
|
+
});
|
|
256
|
+
if (reservedIndices.size > 0) {
|
|
257
|
+
items.sort((a, b) => a.index - b.index);
|
|
258
|
+
}
|
|
259
|
+
return [items, automaticItems.map((item) => item.element)];
|
|
260
|
+
}
|
|
261
|
+
function getCommonAncestor(firstNode, lastNode) {
|
|
262
|
+
let ancestor = firstNode.parentElement;
|
|
263
|
+
while (ancestor && !ancestor.contains(lastNode)) {
|
|
264
|
+
ancestor = ancestor.parentElement;
|
|
265
|
+
}
|
|
266
|
+
return ancestor;
|
|
267
|
+
}
|
|
268
|
+
function hasMovedNode(entries) {
|
|
269
|
+
for (const entry of entries) {
|
|
270
|
+
for (let i = 0; i < entry.removedNodes.length; i += 1) {
|
|
271
|
+
if (entry.removedNodes[i].isConnected) {
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
function sortByDocumentPosition(a, b) {
|
|
279
|
+
if (a.nextElementSibling === b) {
|
|
280
|
+
return -1;
|
|
281
|
+
}
|
|
282
|
+
if (b.nextElementSibling === a) {
|
|
283
|
+
return 1;
|
|
284
|
+
}
|
|
285
|
+
return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
286
|
+
}
|
|
287
|
+
export {
|
|
288
|
+
CompositeList as C,
|
|
289
|
+
useCompositeListItem as u
|
|
290
|
+
};
|
|
291
|
+
//# sourceMappingURL=CompositeList-D4xmSZ5V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositeList-D4xmSZ5V.js","sources":["../node_modules/@base-ui/react/internals/composite/list/CompositeListContext.mjs","../node_modules/@base-ui/react/internals/composite/list/useCompositeListItem.mjs","../node_modules/@base-ui/react/internals/composite/list/CompositeList.mjs"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nexport const CompositeListContext = /*#__PURE__*/React.createContext({\n register: () => {},\n unregister: () => {},\n subscribeMapChange: () => () => {},\n nextIndexRef: {\n current: 0\n }\n});\nif (process.env.NODE_ENV !== \"production\") CompositeListContext.displayName = \"CompositeListContext\";\nexport function useCompositeListContext() {\n return React.useContext(CompositeListContext);\n}","'use client';\n\nimport * as React from 'react';\nimport { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';\nimport { useCompositeListContext } from \"./CompositeListContext.mjs\";\n/**\n * Used to register a list item and its index (DOM position) in the `CompositeList`.\n */\nexport function useCompositeListItem(params = {}) {\n const {\n guess,\n label,\n metadata,\n textRef,\n index: externalIndex\n } = params;\n const {\n register,\n unregister,\n subscribeMapChange,\n nextIndexRef\n } = useCompositeListContext();\n\n // Guess the index from the render order. This avoids a re-render after mount for\n // flat lists rendered in DOM order; when the guess is wrong (grouped or out-of-order\n // rendering), the commit flush corrects it before paint.\n const indexRef = React.useRef(-1);\n const [internalIndex, setInternalIndex] = React.useState(externalIndex == null && guess ? () => {\n if (indexRef.current === -1) {\n const newIndex = nextIndexRef.current;\n nextIndexRef.current += 1;\n indexRef.current = newIndex;\n }\n return indexRef.current;\n } : -1);\n const index = externalIndex ?? internalIndex;\n const componentRef = React.useRef(null);\n\n // Deliberately identity-sensitive: nested items sharing one DOM node rely on ref attachment\n // order to decide which registration wins, and republishing from an effect instead would let\n // an inner item's later update silently take ownership from the outer one.\n const ref = React.useCallback(node => {\n const previousNode = componentRef.current;\n if (previousNode) {\n unregister(previousNode);\n }\n componentRef.current = node;\n if (node) {\n register(node, {\n metadata: metadata ?? null,\n index: externalIndex ?? null,\n label,\n textRef\n });\n }\n }, [externalIndex, register, unregister, metadata, label, textRef]);\n useIsoLayoutEffect(() => {\n if (externalIndex != null) {\n return undefined;\n }\n return subscribeMapChange(map => {\n const i = componentRef.current ? map.get(componentRef.current)?.index : null;\n if (i != null) {\n setInternalIndex(i);\n }\n });\n }, [externalIndex, subscribeMapChange]);\n return {\n ref,\n index\n };\n}","/* eslint-disable no-bitwise */\n'use client';\n\nimport * as React from 'react';\nimport { useRefWithInit } from '@base-ui/utils/useRefWithInit';\nimport { useStableCallback } from '@base-ui/utils/useStableCallback';\nimport { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';\nimport { CompositeListContext } from \"./CompositeListContext.mjs\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Provides context for a list of items in a composite component.\n */\nexport function CompositeList(props) {\n const {\n children,\n elementsRef,\n labelsRef,\n onMapChange: onMapChangeProp\n } = props;\n const onMapChange = useStableCallback(onMapChangeProp);\n const [, setMapTick] = React.useState(0);\n const listeners = useRefWithInit(createListeners).current;\n const map = useRefWithInit(createMap).current;\n const nextIndexRef = React.useRef(0);\n const isDirtyRef = React.useRef(true);\n const itemsRef = React.useRef(null);\n const mutationObserverRef = React.useRef(null);\n\n // Item effects can run without their parent rendering. Schedule one synchronous\n // parent update for the whole commit so refs are rebuilt before paint and while\n // the originating React event is still inside `act()` in tests.\n const scheduleMapUpdate = useStableCallback(() => {\n if (isDirtyRef.current) {\n return;\n }\n isDirtyRef.current = true;\n setMapTick(tick => tick + 1);\n });\n const register = useStableCallback((node, registration) => {\n map.set(node, registration);\n scheduleMapUpdate();\n });\n const unregister = useStableCallback(node => {\n map.delete(node);\n scheduleMapUpdate();\n });\n const syncRefs = useStableCallback(items => {\n const nextMap = new Map();\n elementsRef.current.length = 0;\n if (labelsRef) {\n labelsRef.current.length = 0;\n }\n items.forEach(item => {\n nextMap.set(item.element, {\n ...(item.registration.metadata ?? {}),\n index: item.index\n });\n elementsRef.current[item.index] = item.element;\n if (labelsRef) {\n labelsRef.current[item.index] = item.registration.label !== undefined ? item.registration.label : item.registration.textRef?.current?.textContent ?? item.element.textContent;\n }\n });\n nextIndexRef.current = elementsRef.current.length;\n return nextMap;\n });\n function observe(sortedNodes) {\n mutationObserverRef.current?.disconnect();\n mutationObserverRef.current = null;\n\n // A single item can't reorder.\n if (typeof MutationObserver !== 'function' || sortedNodes.length < 2) {\n return;\n }\n const mutationObserver = new MutationObserver(entries => {\n // Only verify the order after a move: a node that was removed and later\n // re-added within the same batch. Additions and removals alone can't\n // change the relative order of the remaining items, and items that mount\n // or unmount re-sort through `register`/`unregister`.\n if (!hasMovedNode(entries)) {\n return;\n }\n let previousConnectedNode = null;\n\n // If any connected node now appears before the previous connected node,\n // wrappers/items moved and the index map needs to be rebuilt.\n for (const node of sortedNodes) {\n if (!node.isConnected) {\n continue;\n }\n if (previousConnectedNode && sortByDocumentPosition(previousConnectedNode, node) > 0) {\n mutationObserver.disconnect();\n scheduleMapUpdate();\n return;\n }\n previousConnectedNode = node;\n }\n });\n mutationObserverRef.current = mutationObserver;\n\n // A reorder that changes item indexes must invert at least one adjacent pair\n // from the previous sorted order. Observing each pair's common parent catches\n // both direct item moves and ancestor wrapper moves at the boundary.\n const roots = new Set();\n for (let i = 1; i < sortedNodes.length; i += 1) {\n const root = getCommonAncestor(sortedNodes[i - 1], sortedNodes[i]);\n if (root) {\n roots.add(root);\n }\n }\n roots.forEach(root => mutationObserver.observe(root, {\n childList: true\n }));\n }\n const flush = useStableCallback(() => {\n const [items, automaticNodes] = getCompositeListSnapshot(map);\n const nextMap = syncRefs(items);\n const previousItems = itemsRef.current;\n const changed = !previousItems || previousItems.length !== items.length || items.some((item, index) => {\n const previousItem = previousItems[index];\n return item.index !== previousItem.index || item.element !== previousItem.element || item.registration.index !== previousItem.registration.index || item.registration.metadata !== previousItem.registration.metadata;\n });\n observe(automaticNodes);\n itemsRef.current = items;\n isDirtyRef.current = false;\n if (!changed) {\n return;\n }\n listeners.forEach(listener => listener(nextMap));\n onMapChange(nextMap);\n });\n useIsoLayoutEffect(() => {\n // Re-copy the last committed snapshot when the ref objects change or Strict Mode replays\n // effects without reattaching callback refs.\n if (!isDirtyRef.current && itemsRef.current) {\n syncRefs(itemsRef.current);\n }\n return () => {\n elementsRef.current = [];\n if (labelsRef) {\n labelsRef.current = [];\n }\n };\n }, [elementsRef, labelsRef, syncRefs]);\n useIsoLayoutEffect(() => {\n if (isDirtyRef.current) {\n flush();\n }\n });\n useIsoLayoutEffect(() => {\n return () => {\n mutationObserverRef.current?.disconnect();\n // React 18 Strict Mode replays effects without replaying callback refs.\n // Mark the retained map dirty so the replay rebuilds refs and observation.\n isDirtyRef.current = true;\n };\n }, []);\n const subscribeMapChange = useStableCallback(fn => {\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n });\n const contextValue = React.useMemo(() => ({\n register,\n unregister,\n subscribeMapChange,\n nextIndexRef\n }), [register, unregister, subscribeMapChange, nextIndexRef]);\n return /*#__PURE__*/_jsx(CompositeListContext.Provider, {\n value: contextValue,\n children: children\n });\n}\nfunction createMap() {\n return new Map();\n}\nfunction createListeners() {\n return new Set();\n}\nfunction getCompositeListSnapshot(map) {\n const reservedIndices = new Set();\n const items = [];\n const automaticItems = [];\n map.forEach((registration, node) => {\n if (!node.isConnected) {\n return;\n }\n const index = registration.index;\n const item = {\n index: index ?? -1,\n element: node,\n registration\n };\n if (index === null) {\n automaticItems.push(item);\n } else if (index >= 0) {\n reservedIndices.add(index);\n items.push(item);\n }\n });\n let nextAutomaticIndex = 0;\n automaticItems.sort((a, b) => sortByDocumentPosition(a.element, b.element));\n automaticItems.forEach(item => {\n while (reservedIndices.has(nextAutomaticIndex)) {\n nextAutomaticIndex += 1;\n }\n item.index = nextAutomaticIndex;\n items.push(item);\n nextAutomaticIndex += 1;\n });\n if (reservedIndices.size > 0) {\n items.sort((a, b) => a.index - b.index);\n }\n return [items, automaticItems.map(item => item.element)];\n}\nfunction getCommonAncestor(firstNode, lastNode) {\n let ancestor = firstNode.parentElement;\n\n // The `parentElement` walk cannot cross shadow boundaries, so the native\n // `contains` is sufficient here.\n while (ancestor && !ancestor.contains(lastNode)) {\n ancestor = ancestor.parentElement;\n }\n return ancestor;\n}\nfunction hasMovedNode(entries) {\n for (const entry of entries) {\n for (let i = 0; i < entry.removedNodes.length; i += 1) {\n if (entry.removedNodes[i].isConnected) {\n return true;\n }\n }\n }\n return false;\n}\nfunction sortByDocumentPosition(a, b) {\n // Adjacent siblings are the common case for lists that are already in order, and\n // `compareDocumentPosition` scans siblings from the parent's first child, so sorting\n // a long flat list would otherwise be quadratic.\n if (a.nextElementSibling === b) {\n return -1;\n }\n if (b.nextElementSibling === a) {\n return 1;\n }\n // `DOCUMENT_POSITION_CONTAINED_BY` is always reported alongside `FOLLOWING`, and `CONTAINS`\n // alongside `PRECEDING`, so testing `FOLLOWING` alone orders siblings and nested items alike.\n return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;\n}"],"names":["_jsx"],"mappings":";;;AAGO,MAAM,uBAAoC,sBAAM,cAAc;AAAA,EACnE,UAAU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A,EACtB;AACA,SAAO;AACT;AACA,SAAS,aAAa,SAAS;AAC7B,aAAW,SAAS,SAAS;AAC3B,aAAS,IAAI,GAAG,IAAI,MAAM,aAAa,QAAQ,KAAK,GAAG;AACrD,UAAI,MAAM,aAAa,CAAC,EAAE,aAAa;AACrC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AACA,SAAS,uBAAuB,GAAG,GAAG;AAIpC,MAAI,EAAE,uBAAuB,GAAG;AAC9B,WAAO;AAAA,EACT;AACA,MAAI,EAAE,uBAAuB,GAAG;AAC9B,WAAO;AAAA,EACT;AAGA,SAAO,EAAE,wBAAwB,CAAC,IAAI,KAAK,8BAA8B,KAAK;AAChF;","x_google_ignoreList":[0,1,2]}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { c as useMergedRefs, a as useStableCallback, u as useIsoLayoutEffect, E as EMPTY_ARRAY, b as useRenderElement, d as EMPTY_OBJECT } from "./useIsoLayoutEffect-e9VA-ICd.js";
|
|
3
|
+
import { u as useCompositeRootContext, C as CompositeRootContext } from "./useButton-PUBhT4Vo.js";
|
|
4
|
+
import { u as useCompositeListItem, C as CompositeList } from "./CompositeList-D4xmSZ5V.js";
|
|
5
|
+
import { s as scrollIntoViewIfNeeded, C as COMPOSITE_KEYS, i as isNativeInput, H as HOME, E as END, b as ARROW_DOWN, d as ARROW_UP, M as MODIFIER_KEYS, A as ARROW_LEFT, c as ARROW_RIGHT } from "./composite-CrCQWAKA.js";
|
|
6
|
+
import { a as isListIndexDisabled, f as findNonDisabledListIndex, b as isIndexOutOfListBounds, g as getMinListIndex, c as getMaxListIndex } from "./composite-DCpXNxz9.js";
|
|
7
|
+
import { g as getTarget } from "./shadowDom-Bq4g0Qeu.js";
|
|
8
|
+
import { u as useDirection } from "./DirectionContext-Pb9yafF5.js";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
const ACTIVE_COMPOSITE_ITEM = "data-composite-item-active";
|
|
11
|
+
function useCompositeItem(params = {}) {
|
|
12
|
+
const {
|
|
13
|
+
highlightItemOnHover,
|
|
14
|
+
highlightedIndex,
|
|
15
|
+
onHighlightedIndexChange
|
|
16
|
+
} = useCompositeRootContext();
|
|
17
|
+
const {
|
|
18
|
+
ref,
|
|
19
|
+
index
|
|
20
|
+
} = useCompositeListItem(params);
|
|
21
|
+
const isHighlighted = highlightedIndex === index;
|
|
22
|
+
const itemRef = React.useRef(null);
|
|
23
|
+
const mergedRef = useMergedRefs(ref, itemRef);
|
|
24
|
+
const compositeProps = {
|
|
25
|
+
tabIndex: isHighlighted ? 0 : -1,
|
|
26
|
+
onFocus() {
|
|
27
|
+
onHighlightedIndexChange(index);
|
|
28
|
+
},
|
|
29
|
+
onMouseMove() {
|
|
30
|
+
const item = itemRef.current;
|
|
31
|
+
if (!highlightItemOnHover || !item) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const disabled = item.hasAttribute("disabled") || item.ariaDisabled === "true";
|
|
35
|
+
if (!isHighlighted && !disabled) {
|
|
36
|
+
item.focus();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
compositeProps,
|
|
42
|
+
compositeRef: mergedRef,
|
|
43
|
+
index
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function isElementDisabled(element) {
|
|
47
|
+
return element == null || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true";
|
|
48
|
+
}
|
|
49
|
+
function useCompositeRoot(params) {
|
|
50
|
+
const {
|
|
51
|
+
loopFocus = true,
|
|
52
|
+
orientation = "both",
|
|
53
|
+
grid,
|
|
54
|
+
onLoop,
|
|
55
|
+
direction,
|
|
56
|
+
highlightedIndex: externalHighlightedIndex,
|
|
57
|
+
onHighlightedIndexChange: externalSetHighlightedIndex,
|
|
58
|
+
rootRef: externalRef,
|
|
59
|
+
enableHomeAndEndKeys = false,
|
|
60
|
+
stopEventPropagation,
|
|
61
|
+
disabledIndices,
|
|
62
|
+
modifierKeys = EMPTY_ARRAY
|
|
63
|
+
} = params;
|
|
64
|
+
const [internalHighlightedIndex, internalSetHighlightedIndex] = React.useState(0);
|
|
65
|
+
const isGrid = grid != null;
|
|
66
|
+
const rootRef = React.useRef(null);
|
|
67
|
+
const mergedRef = useMergedRefs(rootRef, externalRef);
|
|
68
|
+
const elementsRef = React.useRef([]);
|
|
69
|
+
const hasSetDefaultIndexRef = React.useRef(false);
|
|
70
|
+
const highlightedElementRef = React.useRef(null);
|
|
71
|
+
const highlightedIndex = externalHighlightedIndex ?? internalHighlightedIndex;
|
|
72
|
+
const onHighlightedIndexChange = useStableCallback((index, shouldScrollIntoView = false) => {
|
|
73
|
+
highlightedElementRef.current = elementsRef.current[index] ?? null;
|
|
74
|
+
(externalSetHighlightedIndex ?? internalSetHighlightedIndex)(index);
|
|
75
|
+
if (shouldScrollIntoView) {
|
|
76
|
+
const newActiveItem = elementsRef.current[index];
|
|
77
|
+
scrollIntoViewIfNeeded(rootRef.current, newActiveItem, direction, orientation);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const onMapChange = useStableCallback((map) => {
|
|
81
|
+
var _a;
|
|
82
|
+
if (map.size === 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (hasSetDefaultIndexRef.current) {
|
|
86
|
+
const elements = elementsRef.current;
|
|
87
|
+
const nextIndex = elements.indexOf(highlightedElementRef.current);
|
|
88
|
+
if (nextIndex === -1) {
|
|
89
|
+
const replacement = elements[highlightedIndex];
|
|
90
|
+
if (!replacement || isListIndexDisabled(elements, highlightedIndex, disabledIndices)) {
|
|
91
|
+
onHighlightedIndexChange(getFallbackIndex(elements, disabledIndices));
|
|
92
|
+
} else {
|
|
93
|
+
highlightedElementRef.current = replacement;
|
|
94
|
+
}
|
|
95
|
+
} else if (nextIndex !== highlightedIndex) {
|
|
96
|
+
onHighlightedIndexChange(nextIndex);
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
hasSetDefaultIndexRef.current = true;
|
|
101
|
+
const sortedElements = Array.from(map.keys());
|
|
102
|
+
const activeItem = sortedElements.find((compositeElement) => compositeElement == null ? void 0 : compositeElement.hasAttribute(ACTIVE_COMPOSITE_ITEM)) ?? null;
|
|
103
|
+
const activeIndex = activeItem ? ((_a = map.get(activeItem)) == null ? void 0 : _a.index) ?? -1 : -1;
|
|
104
|
+
if (activeIndex !== -1) {
|
|
105
|
+
onHighlightedIndexChange(activeIndex);
|
|
106
|
+
} else if (isListIndexDisabled(sortedElements, highlightedIndex, disabledIndices)) {
|
|
107
|
+
const firstEnabledIndex = findNonDisabledListIndex(sortedElements, {
|
|
108
|
+
disabledIndices
|
|
109
|
+
});
|
|
110
|
+
if (!isIndexOutOfListBounds(sortedElements, firstEnabledIndex)) {
|
|
111
|
+
onHighlightedIndexChange(firstEnabledIndex);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
scrollIntoViewIfNeeded(rootRef.current, activeItem, direction, orientation);
|
|
115
|
+
});
|
|
116
|
+
useIsoLayoutEffect(() => {
|
|
117
|
+
if (disabledIndices == null || externalHighlightedIndex != null || !hasSetDefaultIndexRef.current) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const elements = elementsRef.current;
|
|
121
|
+
if (isListIndexDisabled(elements, highlightedIndex, disabledIndices)) {
|
|
122
|
+
const firstEnabledIndex = findNonDisabledListIndex(elements, {
|
|
123
|
+
disabledIndices
|
|
124
|
+
});
|
|
125
|
+
if (!isIndexOutOfListBounds(elements, firstEnabledIndex)) {
|
|
126
|
+
onHighlightedIndexChange(firstEnabledIndex);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [disabledIndices, externalHighlightedIndex, highlightedIndex, elementsRef, onHighlightedIndexChange]);
|
|
130
|
+
const wrappedOnLoop = useStableCallback((event, prevIndex, nextIndex) => {
|
|
131
|
+
if (!onLoop) {
|
|
132
|
+
return nextIndex;
|
|
133
|
+
}
|
|
134
|
+
return onLoop(event, prevIndex, nextIndex, elementsRef);
|
|
135
|
+
});
|
|
136
|
+
const onKeyDown = useStableCallback((event) => {
|
|
137
|
+
const isHomeOrEnd = event.key === HOME || event.key === END;
|
|
138
|
+
if (!COMPOSITE_KEYS.has(event.key) || !enableHomeAndEndKeys && isHomeOrEnd) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (isModifierKeySet(event, modifierKeys)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const element = rootRef.current;
|
|
145
|
+
if (!element) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const isRtl = direction === "rtl";
|
|
149
|
+
const horizontalForwardKey = isRtl ? ARROW_LEFT : ARROW_RIGHT;
|
|
150
|
+
const horizontalBackwardKey = isRtl ? ARROW_RIGHT : ARROW_LEFT;
|
|
151
|
+
const forwardKey = orientation === "vertical" ? ARROW_DOWN : horizontalForwardKey;
|
|
152
|
+
const backwardKey = orientation === "vertical" ? ARROW_UP : horizontalBackwardKey;
|
|
153
|
+
const target = getTarget(event.nativeEvent);
|
|
154
|
+
if (target != null && isNativeInput(target) && !isElementDisabled(target)) {
|
|
155
|
+
const selectionStart = target.selectionStart;
|
|
156
|
+
const selectionEnd = target.selectionEnd;
|
|
157
|
+
const textContent = target.value;
|
|
158
|
+
if (selectionStart == null || event.shiftKey || selectionStart !== selectionEnd) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (event.key !== backwardKey && selectionStart < textContent.length) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (event.key !== forwardKey && selectionStart > 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
let nextIndex = highlightedIndex;
|
|
169
|
+
const minIndex = getMinListIndex(elementsRef, disabledIndices);
|
|
170
|
+
const maxIndex = getMaxListIndex(elementsRef, disabledIndices);
|
|
171
|
+
if (grid != null) {
|
|
172
|
+
nextIndex = grid({
|
|
173
|
+
disabledIndices,
|
|
174
|
+
elementsRef,
|
|
175
|
+
event,
|
|
176
|
+
highlightedIndex,
|
|
177
|
+
loopFocus,
|
|
178
|
+
maxIndex,
|
|
179
|
+
minIndex,
|
|
180
|
+
onLoop: wrappedOnLoop,
|
|
181
|
+
orientation,
|
|
182
|
+
rtl: isRtl
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const isForwardKey = orientation !== "vertical" && event.key === horizontalForwardKey || orientation !== "horizontal" && event.key === ARROW_DOWN;
|
|
186
|
+
const isBackwardKey = orientation !== "vertical" && event.key === horizontalBackwardKey || orientation !== "horizontal" && event.key === ARROW_UP;
|
|
187
|
+
if (enableHomeAndEndKeys) {
|
|
188
|
+
if (event.key === HOME) {
|
|
189
|
+
nextIndex = minIndex;
|
|
190
|
+
} else if (event.key === END) {
|
|
191
|
+
nextIndex = maxIndex;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (nextIndex === highlightedIndex && (isForwardKey || isBackwardKey)) {
|
|
195
|
+
if (loopFocus && nextIndex === maxIndex && isForwardKey) {
|
|
196
|
+
nextIndex = minIndex;
|
|
197
|
+
if (onLoop) {
|
|
198
|
+
nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
|
|
199
|
+
}
|
|
200
|
+
} else if (loopFocus && nextIndex === minIndex && isBackwardKey) {
|
|
201
|
+
nextIndex = maxIndex;
|
|
202
|
+
if (onLoop) {
|
|
203
|
+
nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
nextIndex = findNonDisabledListIndex(elementsRef.current, {
|
|
207
|
+
startingIndex: nextIndex,
|
|
208
|
+
decrement: isBackwardKey,
|
|
209
|
+
disabledIndices
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (nextIndex !== highlightedIndex && !isIndexOutOfListBounds(elementsRef.current, nextIndex)) {
|
|
214
|
+
if (stopEventPropagation) {
|
|
215
|
+
event.stopPropagation();
|
|
216
|
+
}
|
|
217
|
+
if (isGrid || isHomeOrEnd || isForwardKey || isBackwardKey) {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
}
|
|
220
|
+
onHighlightedIndexChange(nextIndex, true);
|
|
221
|
+
queueMicrotask(() => {
|
|
222
|
+
var _a;
|
|
223
|
+
(_a = elementsRef.current[nextIndex]) == null ? void 0 : _a.focus();
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
const props = {
|
|
228
|
+
ref: mergedRef,
|
|
229
|
+
onFocus(event) {
|
|
230
|
+
const element = rootRef.current;
|
|
231
|
+
const target = getTarget(event.nativeEvent);
|
|
232
|
+
if (!element || target == null || !isNativeInput(target)) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
target.setSelectionRange(0, target.value.length);
|
|
236
|
+
},
|
|
237
|
+
onKeyDown
|
|
238
|
+
};
|
|
239
|
+
return {
|
|
240
|
+
props,
|
|
241
|
+
highlightedIndex,
|
|
242
|
+
onHighlightedIndexChange,
|
|
243
|
+
elementsRef,
|
|
244
|
+
onMapChange,
|
|
245
|
+
relayKeyboardEvent: onKeyDown
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function getFallbackIndex(elements, disabledIndices) {
|
|
249
|
+
let fallbackIndex = -1;
|
|
250
|
+
for (let index = 0; index < elements.length; index += 1) {
|
|
251
|
+
const element = elements[index];
|
|
252
|
+
if (!element || isListIndexDisabled(elements, index, disabledIndices)) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (element.hasAttribute(ACTIVE_COMPOSITE_ITEM)) {
|
|
256
|
+
return index;
|
|
257
|
+
}
|
|
258
|
+
if (fallbackIndex === -1) {
|
|
259
|
+
fallbackIndex = index;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return Math.max(fallbackIndex, 0);
|
|
263
|
+
}
|
|
264
|
+
function isModifierKeySet(event, ignoredModifierKeys) {
|
|
265
|
+
for (const key of MODIFIER_KEYS) {
|
|
266
|
+
if (ignoredModifierKeys.includes(key)) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (event.getModifierState(key)) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
function CompositeRoot(componentProps) {
|
|
276
|
+
const {
|
|
277
|
+
render,
|
|
278
|
+
className,
|
|
279
|
+
style,
|
|
280
|
+
refs = EMPTY_ARRAY,
|
|
281
|
+
props = EMPTY_ARRAY,
|
|
282
|
+
state = EMPTY_OBJECT,
|
|
283
|
+
stateAttributesMapping,
|
|
284
|
+
highlightedIndex: highlightedIndexProp,
|
|
285
|
+
onHighlightedIndexChange: onHighlightedIndexChangeProp,
|
|
286
|
+
orientation,
|
|
287
|
+
grid,
|
|
288
|
+
loopFocus,
|
|
289
|
+
onLoop,
|
|
290
|
+
enableHomeAndEndKeys,
|
|
291
|
+
onMapChange: onMapChangeProp,
|
|
292
|
+
stopEventPropagation = true,
|
|
293
|
+
rootRef,
|
|
294
|
+
disabledIndices,
|
|
295
|
+
modifierKeys,
|
|
296
|
+
highlightItemOnHover = false,
|
|
297
|
+
tag = "div",
|
|
298
|
+
...elementProps
|
|
299
|
+
} = componentProps;
|
|
300
|
+
const direction = useDirection();
|
|
301
|
+
const {
|
|
302
|
+
props: defaultProps,
|
|
303
|
+
highlightedIndex,
|
|
304
|
+
onHighlightedIndexChange,
|
|
305
|
+
elementsRef,
|
|
306
|
+
onMapChange: onMapChangeUnwrapped,
|
|
307
|
+
relayKeyboardEvent
|
|
308
|
+
} = useCompositeRoot({
|
|
309
|
+
grid,
|
|
310
|
+
loopFocus,
|
|
311
|
+
onLoop,
|
|
312
|
+
orientation,
|
|
313
|
+
highlightedIndex: highlightedIndexProp,
|
|
314
|
+
onHighlightedIndexChange: onHighlightedIndexChangeProp,
|
|
315
|
+
rootRef,
|
|
316
|
+
stopEventPropagation,
|
|
317
|
+
enableHomeAndEndKeys,
|
|
318
|
+
direction,
|
|
319
|
+
disabledIndices,
|
|
320
|
+
modifierKeys
|
|
321
|
+
});
|
|
322
|
+
const element = useRenderElement(tag, componentProps, {
|
|
323
|
+
state,
|
|
324
|
+
ref: refs,
|
|
325
|
+
props: [defaultProps, ...props, elementProps],
|
|
326
|
+
stateAttributesMapping
|
|
327
|
+
});
|
|
328
|
+
const contextValue = React.useMemo(() => ({
|
|
329
|
+
highlightedIndex,
|
|
330
|
+
onHighlightedIndexChange,
|
|
331
|
+
highlightItemOnHover,
|
|
332
|
+
relayKeyboardEvent
|
|
333
|
+
}), [highlightedIndex, onHighlightedIndexChange, highlightItemOnHover, relayKeyboardEvent]);
|
|
334
|
+
return /* @__PURE__ */ jsx(CompositeRootContext.Provider, {
|
|
335
|
+
value: contextValue,
|
|
336
|
+
children: /* @__PURE__ */ jsx(CompositeList, {
|
|
337
|
+
elementsRef,
|
|
338
|
+
onMapChange: (newMap) => {
|
|
339
|
+
onMapChangeProp == null ? void 0 : onMapChangeProp(newMap);
|
|
340
|
+
onMapChangeUnwrapped(newMap);
|
|
341
|
+
},
|
|
342
|
+
children: element
|
|
343
|
+
})
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
export {
|
|
347
|
+
ACTIVE_COMPOSITE_ITEM as A,
|
|
348
|
+
CompositeRoot as C,
|
|
349
|
+
useCompositeItem as u
|
|
350
|
+
};
|
|
351
|
+
//# sourceMappingURL=CompositeRoot-BxrPc7F6.js.map
|