@ariakit/react-core 0.3.9 → 0.3.11
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/CHANGELOG.md +67 -0
- package/cjs/__chunks/{WK7AZPHS.cjs → 2GETDAIQ.cjs} +4 -4
- package/cjs/__chunks/{OT6DC3ML.cjs → 36QK2QLE.cjs} +2 -2
- package/cjs/__chunks/{PFQ3IPWT.cjs → 3RUODFRU.cjs} +16 -1
- package/cjs/__chunks/{UBME4GBY.cjs → 63WKH5OP.cjs} +2 -2
- package/cjs/__chunks/{S6WUBPBB.cjs → 65LGW5LY.cjs} +4 -2
- package/cjs/__chunks/{KIGOGBFU.cjs → 7EEAHTIW.cjs} +2 -2
- package/cjs/__chunks/{3KZQJDTV.cjs → APFV5PTX.cjs} +2 -2
- package/cjs/__chunks/{VIETWH5C.cjs → BKU5STIE.cjs} +2 -2
- package/cjs/__chunks/{HHZJ6KYW.cjs → IAYTETYN.cjs} +2 -2
- package/cjs/__chunks/{WABPFCL3.cjs → NVHGMKAE.cjs} +7 -5
- package/cjs/__chunks/{CZOBQEIO.cjs → RM2WCNSU.cjs} +16 -22
- package/cjs/__chunks/{GF6NWLKX.cjs → WWU35JDJ.cjs} +6 -2
- package/cjs/__chunks/{UUTXBBHD.cjs → XAYQLYTN.cjs} +2 -2
- package/cjs/checkbox/checkbox-check.d.cts +6 -3
- package/cjs/checkbox/checkbox-check.d.ts +6 -3
- package/cjs/collection/collection-renderer.d.cts +0 -1
- package/cjs/collection/collection-renderer.d.ts +0 -1
- package/cjs/combobox/combobox-disclosure.cjs +3 -4
- package/cjs/combobox/combobox-item.cjs +5 -3
- package/cjs/combobox/combobox-item.d.cts +13 -1
- package/cjs/combobox/combobox-item.d.ts +13 -1
- package/cjs/combobox/combobox-popover.cjs +39 -10
- package/cjs/combobox/combobox-popover.d.cts +1 -1
- package/cjs/combobox/combobox-popover.d.ts +1 -1
- package/cjs/combobox/combobox.cjs +18 -6
- package/cjs/combobox/combobox.d.cts +26 -1
- package/cjs/combobox/combobox.d.ts +26 -1
- package/cjs/composite/composite-hover.d.cts +10 -1
- package/cjs/composite/composite-hover.d.ts +10 -1
- package/cjs/composite/composite-item.cjs +2 -2
- package/cjs/composite/composite-overflow-disclosure.cjs +2 -2
- package/cjs/composite/composite-overflow.cjs +4 -4
- package/cjs/composite/composite-renderer.d.cts +0 -1
- package/cjs/composite/composite-renderer.d.ts +0 -1
- package/cjs/composite/composite.cjs +2 -2
- package/cjs/dialog/dialog.cjs +3 -3
- package/cjs/form/form-radio.cjs +3 -3
- package/cjs/hovercard/hovercard.cjs +5 -5
- package/cjs/menu/menu-bar.cjs +3 -3
- package/cjs/menu/menu-item-check.d.cts +14 -0
- package/cjs/menu/menu-item-check.d.ts +14 -0
- package/cjs/menu/menu-item-checkbox.cjs +3 -3
- package/cjs/menu/menu-item-radio.cjs +5 -5
- package/cjs/menu/menu-item.cjs +3 -3
- package/cjs/menu/menu-item.d.cts +8 -1
- package/cjs/menu/menu-item.d.ts +8 -1
- package/cjs/menu/menu-list.cjs +3 -3
- package/cjs/menu/menu-store.d.cts +2 -0
- package/cjs/menu/menu-store.d.ts +2 -0
- package/cjs/menu/menu.cjs +43 -15
- package/cjs/menubar/menubar.cjs +3 -3
- package/cjs/popover/popover.cjs +4 -4
- package/cjs/popover/popover.d.cts +2 -0
- package/cjs/popover/popover.d.ts +2 -0
- package/cjs/portal/portal.cjs +2 -2
- package/cjs/radio/radio-group.cjs +2 -2
- package/cjs/radio/radio.cjs +3 -3
- package/cjs/select/select-item.cjs +2 -2
- package/cjs/select/select-list.cjs +3 -3
- package/cjs/select/select-popover.cjs +8 -8
- package/cjs/tab/tab-list.cjs +2 -2
- package/cjs/tab/tab-provider.cjs +2 -2
- package/cjs/tab/tab-store.cjs +2 -2
- package/cjs/tab/tab.cjs +2 -2
- package/cjs/toolbar/toolbar-container.cjs +3 -3
- package/cjs/toolbar/toolbar-input.cjs +3 -3
- package/cjs/toolbar/toolbar-item.cjs +3 -3
- package/cjs/toolbar/toolbar.cjs +2 -2
- package/cjs/tooltip/tooltip.cjs +6 -6
- package/esm/__chunks/{FHDXHZLB.js → 57KNUQTI.js} +16 -22
- package/esm/__chunks/{UV2O3GRQ.js → 7D63S66W.js} +1 -1
- package/esm/__chunks/{TZJDOU75.js → 7R5VX7DV.js} +1 -1
- package/esm/__chunks/{6HKEBMMA.js → 7SHHFY4P.js} +1 -1
- package/esm/__chunks/{BJR5BFSV.js → CVFC2LN3.js} +1 -1
- package/esm/__chunks/{DHHIMTTV.js → DENCHBDS.js} +1 -1
- package/esm/__chunks/{E3XM3D67.js → JPXNJYSO.js} +4 -2
- package/esm/__chunks/{K5VQ2XTM.js → LZUSNDXA.js} +6 -2
- package/esm/__chunks/{PFM7J2TR.js → PDVJHECS.js} +1 -1
- package/esm/__chunks/{YGCD7HIZ.js → R2WNOXYG.js} +16 -1
- package/esm/__chunks/{2WETNHXU.js → SXPADS2D.js} +5 -3
- package/esm/__chunks/{2ECHI3ER.js → W2TTCKOE.js} +1 -1
- package/esm/__chunks/{HQ7YVNMA.js → WEU2EOWJ.js} +2 -2
- package/esm/checkbox/checkbox-check.d.ts +6 -3
- package/esm/collection/collection-renderer.d.ts +0 -1
- package/esm/combobox/combobox-disclosure.js +3 -4
- package/esm/combobox/combobox-item.d.ts +13 -1
- package/esm/combobox/combobox-item.js +4 -2
- package/esm/combobox/combobox-popover.d.ts +1 -1
- package/esm/combobox/combobox-popover.js +38 -9
- package/esm/combobox/combobox.d.ts +26 -1
- package/esm/combobox/combobox.js +17 -5
- package/esm/composite/composite-hover.d.ts +10 -1
- package/esm/composite/composite-item.js +1 -1
- package/esm/composite/composite-overflow-disclosure.js +1 -1
- package/esm/composite/composite-overflow.js +3 -3
- package/esm/composite/composite-renderer.d.ts +0 -1
- package/esm/composite/composite.js +1 -1
- package/esm/dialog/dialog.js +2 -2
- package/esm/form/form-radio.js +2 -2
- package/esm/hovercard/hovercard.js +4 -4
- package/esm/menu/menu-bar.js +2 -2
- package/esm/menu/menu-item-check.d.ts +14 -0
- package/esm/menu/menu-item-checkbox.js +2 -2
- package/esm/menu/menu-item-radio.js +3 -3
- package/esm/menu/menu-item.d.ts +8 -1
- package/esm/menu/menu-item.js +2 -2
- package/esm/menu/menu-list.js +2 -2
- package/esm/menu/menu-store.d.ts +2 -0
- package/esm/menu/menu.js +41 -13
- package/esm/menubar/menubar.js +2 -2
- package/esm/popover/popover.d.ts +2 -0
- package/esm/popover/popover.js +3 -3
- package/esm/portal/portal.js +1 -1
- package/esm/radio/radio-group.js +1 -1
- package/esm/radio/radio.js +2 -2
- package/esm/select/select-item.js +1 -1
- package/esm/select/select-list.js +2 -2
- package/esm/select/select-popover.js +5 -5
- package/esm/tab/tab-list.js +1 -1
- package/esm/tab/tab-provider.js +1 -1
- package/esm/tab/tab-store.js +1 -1
- package/esm/tab/tab.js +1 -1
- package/esm/toolbar/toolbar-container.js +2 -2
- package/esm/toolbar/toolbar-input.js +2 -2
- package/esm/toolbar/toolbar-item.js +2 -2
- package/esm/toolbar/toolbar.js +1 -1
- package/esm/tooltip/tooltip.js +4 -4
- package/package.json +2 -2
package/cjs/tooltip/tooltip.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _2GETDAIQcjs = require('../__chunks/2GETDAIQ.cjs');
|
|
5
5
|
require('../__chunks/KXQOQQ5B.cjs');
|
|
6
|
-
require('../__chunks/
|
|
6
|
+
require('../__chunks/NVHGMKAE.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _36QK2QLEcjs = require('../__chunks/36QK2QLE.cjs');
|
|
10
10
|
require('../__chunks/RTT4XR27.cjs');
|
|
11
11
|
require('../__chunks/NKR65BKC.cjs');
|
|
12
12
|
require('../__chunks/PZL34OVO.cjs');
|
|
@@ -23,7 +23,7 @@ require('../__chunks/5GTNIPQ6.cjs');
|
|
|
23
23
|
require('../__chunks/V24PR4PW.cjs');
|
|
24
24
|
require('../__chunks/7566TIRW.cjs');
|
|
25
25
|
require('../__chunks/J3OG6T3B.cjs');
|
|
26
|
-
require('../__chunks/
|
|
26
|
+
require('../__chunks/65LGW5LY.cjs');
|
|
27
27
|
require('../__chunks/XB3G2EO2.cjs');
|
|
28
28
|
require('../__chunks/CVD2AZE2.cjs');
|
|
29
29
|
require('../__chunks/2BIO7R5N.cjs');
|
|
@@ -94,7 +94,7 @@ var useTooltip = _RNZNGEL4cjs.createHook.call(void 0,
|
|
|
94
94
|
(state) => state.type === "description" ? "tooltip" : "none"
|
|
95
95
|
);
|
|
96
96
|
props = _AV6KTKLEcjs.__spreadValues.call(void 0, { role }, props);
|
|
97
|
-
props =
|
|
97
|
+
props = _2GETDAIQcjs.useHovercard.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
98
98
|
store,
|
|
99
99
|
portal,
|
|
100
100
|
gutter,
|
|
@@ -123,7 +123,7 @@ var useTooltip = _RNZNGEL4cjs.createHook.call(void 0,
|
|
|
123
123
|
return props;
|
|
124
124
|
}
|
|
125
125
|
);
|
|
126
|
-
var Tooltip =
|
|
126
|
+
var Tooltip = _36QK2QLEcjs.createDialogComponent.call(void 0,
|
|
127
127
|
_RNZNGEL4cjs.createComponent.call(void 0, (props) => {
|
|
128
128
|
const htmlProps = useTooltip(props);
|
|
129
129
|
return _RNZNGEL4cjs.createElement.call(void 0, "div", htmlProps);
|
|
@@ -48,43 +48,32 @@ function isGrid(items) {
|
|
|
48
48
|
return items.some((item) => !!item.rowId);
|
|
49
49
|
}
|
|
50
50
|
function isPrintableKey(event) {
|
|
51
|
+
const target = event.target;
|
|
52
|
+
if (target && !isTextField(target))
|
|
53
|
+
return false;
|
|
51
54
|
return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
|
|
52
55
|
}
|
|
53
56
|
function isModifierKey(event) {
|
|
54
57
|
return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
|
|
55
58
|
}
|
|
56
|
-
function canProxyKeyboardEvent(event, state) {
|
|
57
|
-
if (!isSelfTarget(event))
|
|
58
|
-
return false;
|
|
59
|
-
if (isModifierKey(event))
|
|
60
|
-
return false;
|
|
61
|
-
const target = event.target;
|
|
62
|
-
if (!target)
|
|
63
|
-
return true;
|
|
64
|
-
if (isTextField(target)) {
|
|
65
|
-
if (isPrintableKey(event))
|
|
66
|
-
return false;
|
|
67
|
-
const grid = isGrid(state.renderedItems);
|
|
68
|
-
const focusingInputOnly = state.activeId === null;
|
|
69
|
-
const allowHorizontalNavigationOnItems = grid && !focusingInputOnly;
|
|
70
|
-
const isHomeOrEnd = event.key === "Home" || event.key === "End";
|
|
71
|
-
if (!allowHorizontalNavigationOnItems && isHomeOrEnd)
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
return !event.isPropagationStopped();
|
|
75
|
-
}
|
|
76
59
|
function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
|
|
77
60
|
return useEvent((event) => {
|
|
78
61
|
var _a;
|
|
79
62
|
onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
|
|
80
63
|
if (event.defaultPrevented)
|
|
81
64
|
return;
|
|
65
|
+
if (event.isPropagationStopped())
|
|
66
|
+
return;
|
|
67
|
+
if (!isSelfTarget(event))
|
|
68
|
+
return;
|
|
69
|
+
if (isModifierKey(event))
|
|
70
|
+
return;
|
|
71
|
+
if (isPrintableKey(event))
|
|
72
|
+
return;
|
|
82
73
|
const state = store.getState();
|
|
83
74
|
const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
|
|
84
75
|
if (!activeElement)
|
|
85
76
|
return;
|
|
86
|
-
if (!canProxyKeyboardEvent(event, state))
|
|
87
|
-
return;
|
|
88
77
|
const _b = event, { view } = _b, eventInit = __objRest(_b, ["view"]);
|
|
89
78
|
const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
|
|
90
79
|
if (activeElement !== previousElement) {
|
|
@@ -269,6 +258,8 @@ var useComposite = createHook(
|
|
|
269
258
|
}
|
|
270
259
|
} else if (activeElement) {
|
|
271
260
|
fireBlurEvent(activeElement, event);
|
|
261
|
+
} else if (previousElement) {
|
|
262
|
+
fireBlurEvent(previousElement, event);
|
|
272
263
|
}
|
|
273
264
|
event.stopPropagation();
|
|
274
265
|
} else {
|
|
@@ -296,6 +287,9 @@ var useComposite = createHook(
|
|
|
296
287
|
const isVertical = orientation !== "horizontal";
|
|
297
288
|
const isHorizontal = orientation !== "vertical";
|
|
298
289
|
const grid = isGrid(renderedItems);
|
|
290
|
+
const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
|
|
291
|
+
if (isHorizontalKey && isTextField(event.currentTarget))
|
|
292
|
+
return;
|
|
299
293
|
const up = () => {
|
|
300
294
|
if (grid) {
|
|
301
295
|
const item = items && findFirstEnabledItemInTheLastRow(items);
|
|
@@ -133,9 +133,10 @@ var usePortal = createHook(
|
|
|
133
133
|
if (!isFocusEventOutside(event))
|
|
134
134
|
return;
|
|
135
135
|
const focusing = event.type === "focusin";
|
|
136
|
-
if (focusing)
|
|
137
|
-
return restoreFocusIn(portalNode);
|
|
138
136
|
cancelAnimationFrame(raf);
|
|
137
|
+
if (focusing) {
|
|
138
|
+
return restoreFocusIn(portalNode);
|
|
139
|
+
}
|
|
139
140
|
raf = requestAnimationFrame(() => {
|
|
140
141
|
disableFocusIn(portalNode, true);
|
|
141
142
|
});
|
|
@@ -143,6 +144,7 @@ var usePortal = createHook(
|
|
|
143
144
|
portalNode.addEventListener("focusin", onFocus, true);
|
|
144
145
|
portalNode.addEventListener("focusout", onFocus, true);
|
|
145
146
|
return () => {
|
|
147
|
+
cancelAnimationFrame(raf);
|
|
146
148
|
portalNode.removeEventListener("focusin", onFocus, true);
|
|
147
149
|
portalNode.removeEventListener("focusout", onFocus, true);
|
|
148
150
|
};
|
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
useStore,
|
|
7
7
|
useStoreProps
|
|
8
8
|
} from "./4OZYHFMH.js";
|
|
9
|
+
import {
|
|
10
|
+
useUpdateEffect
|
|
11
|
+
} from "./6O5OEQGF.js";
|
|
9
12
|
import {
|
|
10
13
|
__spreadProps,
|
|
11
14
|
__spreadValues
|
|
@@ -18,8 +21,9 @@ function useTabStoreProps(store, update, props) {
|
|
|
18
21
|
store = useCompositeStoreProps(store, update, props);
|
|
19
22
|
useStoreProps(store, props, "selectedId", "setSelectedId");
|
|
20
23
|
useStoreProps(store, props, "selectOnMove");
|
|
21
|
-
const [panels] = useStore(() => store.panels, {});
|
|
22
|
-
|
|
24
|
+
const [panels, updatePanels] = useStore(() => store.panels, {});
|
|
25
|
+
useUpdateEffect(updatePanels, [store, updatePanels]);
|
|
26
|
+
return useMemo(() => __spreadProps(__spreadValues({}, store), { panels }), [store, panels]);
|
|
23
27
|
}
|
|
24
28
|
function useTabStore(props = {}) {
|
|
25
29
|
const [store, update] = useStore(Core.createTabStore, props);
|
|
@@ -220,7 +220,7 @@ var useCompositeItem = createHook(
|
|
|
220
220
|
return;
|
|
221
221
|
if (isEditableElement(event.currentTarget))
|
|
222
222
|
return;
|
|
223
|
-
if (!baseElement2)
|
|
223
|
+
if (!(baseElement2 == null ? void 0 : baseElement2.isConnected))
|
|
224
224
|
return;
|
|
225
225
|
hasFocusedComposite.current = true;
|
|
226
226
|
const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
|
|
@@ -259,18 +259,33 @@ var useCompositeItem = createHook(
|
|
|
259
259
|
const isGrid = !!(item == null ? void 0 : item.rowId);
|
|
260
260
|
const isVertical = state.orientation !== "horizontal";
|
|
261
261
|
const isHorizontal = state.orientation !== "vertical";
|
|
262
|
+
const canHomeEnd = () => {
|
|
263
|
+
if (isGrid)
|
|
264
|
+
return true;
|
|
265
|
+
if (isHorizontal)
|
|
266
|
+
return true;
|
|
267
|
+
if (!state.baseElement)
|
|
268
|
+
return true;
|
|
269
|
+
if (!isTextField(state.baseElement))
|
|
270
|
+
return true;
|
|
271
|
+
return false;
|
|
272
|
+
};
|
|
262
273
|
const keyMap = {
|
|
263
274
|
ArrowUp: (isGrid || isVertical) && store.up,
|
|
264
275
|
ArrowRight: (isGrid || isHorizontal) && store.next,
|
|
265
276
|
ArrowDown: (isGrid || isVertical) && store.down,
|
|
266
277
|
ArrowLeft: (isGrid || isHorizontal) && store.previous,
|
|
267
278
|
Home: () => {
|
|
279
|
+
if (!canHomeEnd())
|
|
280
|
+
return;
|
|
268
281
|
if (!isGrid || event.ctrlKey) {
|
|
269
282
|
return store == null ? void 0 : store.first();
|
|
270
283
|
}
|
|
271
284
|
return store == null ? void 0 : store.previous(-1);
|
|
272
285
|
},
|
|
273
286
|
End: () => {
|
|
287
|
+
if (!canHomeEnd())
|
|
288
|
+
return;
|
|
274
289
|
if (!isGrid || event.ctrlKey) {
|
|
275
290
|
return store == null ? void 0 : store.last();
|
|
276
291
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createDialogComponent,
|
|
4
4
|
useDialog
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./PDVJHECS.js";
|
|
6
6
|
import {
|
|
7
7
|
PopoverScopedContextProvider,
|
|
8
8
|
usePopoverProviderContext
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
autoUpdate,
|
|
33
33
|
computePosition,
|
|
34
34
|
flip,
|
|
35
|
+
limitShift,
|
|
35
36
|
offset,
|
|
36
37
|
shift,
|
|
37
38
|
size
|
|
@@ -112,7 +113,8 @@ function getShiftMiddleware(props) {
|
|
|
112
113
|
return shift({
|
|
113
114
|
mainAxis: props.slide,
|
|
114
115
|
crossAxis: props.overlap,
|
|
115
|
-
padding: props.overflowPadding
|
|
116
|
+
padding: props.overflowPadding,
|
|
117
|
+
limiter: limitShift()
|
|
116
118
|
});
|
|
117
119
|
}
|
|
118
120
|
function getSizeMiddleware(props) {
|
|
@@ -227,7 +229,7 @@ var usePopover = createHook(
|
|
|
227
229
|
const middleware = [
|
|
228
230
|
getOffsetMiddleware(arrowElement, { gutter, shift: shift2 }),
|
|
229
231
|
getFlipMiddleware({ flip: flip2, overflowPadding }),
|
|
230
|
-
getShiftMiddleware({ slide, overlap, overflowPadding }),
|
|
232
|
+
getShiftMiddleware({ slide, shift: shift2, overlap, overflowPadding }),
|
|
231
233
|
getArrowMiddleware(arrowElement, { arrowPadding }),
|
|
232
234
|
getSizeMiddleware({
|
|
233
235
|
sameWidth,
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./YMV43K4F.js";
|
|
7
7
|
import {
|
|
8
8
|
usePopover
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./SXPADS2D.js";
|
|
10
10
|
import {
|
|
11
11
|
createDialogComponent
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./PDVJHECS.js";
|
|
13
13
|
import {
|
|
14
14
|
HovercardScopedContextProvider,
|
|
15
15
|
useHovercardProviderContext
|
|
@@ -28,9 +28,12 @@ export interface CheckboxCheckOptions<T extends As = "span"> extends Options<T>
|
|
|
28
28
|
*/
|
|
29
29
|
store?: CheckboxStore;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* Determines if the check mark should be displayed. This value is
|
|
32
|
+
* automatically derived from the
|
|
33
|
+
* [`store`](https://ariakit.org/reference/checkbox-check#store) prop or the
|
|
34
|
+
* parent [`Checkbox`](https://ariakit.org/reference/checkbox) component.
|
|
35
|
+
*
|
|
36
|
+
* Manually setting this prop will supersede the derived value.
|
|
34
37
|
*/
|
|
35
38
|
checked?: boolean;
|
|
36
39
|
}
|
|
@@ -62,7 +62,6 @@ export declare function useCollectionRenderer<T extends Item = any>({ store, ite
|
|
|
62
62
|
id?: string | undefined;
|
|
63
63
|
lang?: string | undefined;
|
|
64
64
|
nonce?: string | undefined;
|
|
65
|
-
placeholder?: string | undefined;
|
|
66
65
|
slot?: string | undefined;
|
|
67
66
|
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
68
67
|
style?: CSSProperties | undefined;
|
|
@@ -75,13 +75,12 @@ var useComboboxDisclosure = createHook(
|
|
|
75
75
|
const { baseElement } = store.getState();
|
|
76
76
|
store.setDisclosureElement(baseElement);
|
|
77
77
|
});
|
|
78
|
-
const
|
|
79
|
-
(state) => state.open ? "Hide popup" : "Show popup"
|
|
80
|
-
);
|
|
78
|
+
const open = store.useState("open");
|
|
81
79
|
props = __spreadProps(__spreadValues({
|
|
82
80
|
children,
|
|
83
81
|
tabIndex: -1,
|
|
84
|
-
"aria-label":
|
|
82
|
+
"aria-label": open ? "Hide popup" : "Show popup",
|
|
83
|
+
"aria-expanded": open
|
|
85
84
|
}, props), {
|
|
86
85
|
onMouseDown,
|
|
87
86
|
onClick
|
|
@@ -56,6 +56,11 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
|
|
|
56
56
|
* [`setValueOnClick`](https://ariakit.org/reference/combobox-item#setvalueonclick)
|
|
57
57
|
* is set to `true`, this will be the value of the combobox input when the
|
|
58
58
|
* user clicks on this item.
|
|
59
|
+
* - If
|
|
60
|
+
* [`selectValueOnClick`](https://ariakit.org/reference/combobox-item#selectvalueonclick)
|
|
61
|
+
* is set to `true`, this will be the value of the
|
|
62
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
63
|
+
* state.
|
|
59
64
|
* - If the
|
|
60
65
|
* [`autoComplete`](https://ariakit.org/reference/combobox#autocomplete)
|
|
61
66
|
* prop on the [`Combobox`](https://ariakit.org/reference/combobox)
|
|
@@ -88,7 +93,12 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
|
|
|
88
93
|
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
89
94
|
* state using this item's
|
|
90
95
|
* [`value`](https://ariakit.org/reference/combobox-item#value) when the item
|
|
91
|
-
* is clicked.
|
|
96
|
+
* is clicked. If a callback is provided, it will only be invoked if the item
|
|
97
|
+
* has a value.
|
|
98
|
+
*
|
|
99
|
+
* Live examples:
|
|
100
|
+
* - [Submenu with
|
|
101
|
+
* Combobox](https://ariakit.org/examples/menu-nested-combobox)
|
|
92
102
|
* @default true
|
|
93
103
|
*/
|
|
94
104
|
selectValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
@@ -102,6 +112,8 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
|
|
|
102
112
|
*
|
|
103
113
|
* Live examples:
|
|
104
114
|
* - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
|
|
115
|
+
* - [Submenu with
|
|
116
|
+
* Combobox](https://ariakit.org/examples/menu-nested-combobox)
|
|
105
117
|
*/
|
|
106
118
|
setValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
107
119
|
/**
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "../__chunks/W76OTZCC.js";
|
|
10
10
|
import {
|
|
11
11
|
useCompositeItem
|
|
12
|
-
} from "../__chunks/
|
|
12
|
+
} from "../__chunks/R2WNOXYG.js";
|
|
13
13
|
import "../__chunks/NWCBQ4CV.js";
|
|
14
14
|
import "../__chunks/UH3I23HL.js";
|
|
15
15
|
import "../__chunks/6QXBPV75.js";
|
|
@@ -151,7 +151,9 @@ var useComboboxItem = createHook(
|
|
|
151
151
|
(state) => isSelected(state.selectedValue, value)
|
|
152
152
|
);
|
|
153
153
|
if (multiSelectable && selected != null) {
|
|
154
|
-
props
|
|
154
|
+
props = __spreadValues({
|
|
155
|
+
"aria-selected": selected
|
|
156
|
+
}, props);
|
|
155
157
|
}
|
|
156
158
|
props = useWrapElement(
|
|
157
159
|
props,
|
|
@@ -35,6 +35,6 @@ export declare const useComboboxPopover: import("../utils/types.js").Hook<Combob
|
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
export declare const ComboboxPopover: import("../utils/types.js").Component<ComboboxPopoverOptions<"div">>;
|
|
38
|
-
export interface ComboboxPopoverOptions<T extends As = "div"> extends ComboboxListOptions<T>, Omit<PopoverOptions<T>, "store"
|
|
38
|
+
export interface ComboboxPopoverOptions<T extends As = "div"> extends ComboboxListOptions<T>, Omit<PopoverOptions<T>, "store"> {
|
|
39
39
|
}
|
|
40
40
|
export type ComboboxPopoverProps<T extends As = "div"> = Props<ComboboxPopoverOptions<T>>;
|
|
@@ -9,10 +9,10 @@ import "../__chunks/IB7YUKH5.js";
|
|
|
9
9
|
import "../__chunks/4UUKJZ4V.js";
|
|
10
10
|
import {
|
|
11
11
|
usePopover
|
|
12
|
-
} from "../__chunks/
|
|
12
|
+
} from "../__chunks/SXPADS2D.js";
|
|
13
13
|
import {
|
|
14
14
|
createDialogComponent
|
|
15
|
-
} from "../__chunks/
|
|
15
|
+
} from "../__chunks/PDVJHECS.js";
|
|
16
16
|
import "../__chunks/57VLL43X.js";
|
|
17
17
|
import "../__chunks/CLF4PQ7T.js";
|
|
18
18
|
import "../__chunks/BULCTPRV.js";
|
|
@@ -29,7 +29,7 @@ import "../__chunks/72E5EPFF.js";
|
|
|
29
29
|
import "../__chunks/X6WIMZJE.js";
|
|
30
30
|
import "../__chunks/HPP6CWMY.js";
|
|
31
31
|
import "../__chunks/UYRJLDVS.js";
|
|
32
|
-
import "../__chunks/
|
|
32
|
+
import "../__chunks/JPXNJYSO.js";
|
|
33
33
|
import "../__chunks/CHKJ74UC.js";
|
|
34
34
|
import "../__chunks/7452U3HH.js";
|
|
35
35
|
import "../__chunks/XPF5GU3Q.js";
|
|
@@ -58,13 +58,13 @@ import {
|
|
|
58
58
|
} from "../__chunks/4R3V3JGP.js";
|
|
59
59
|
|
|
60
60
|
// src/combobox/combobox-popover.tsx
|
|
61
|
-
import { matches } from "@ariakit/core/utils/dom";
|
|
61
|
+
import { getDocument, matches } from "@ariakit/core/utils/dom";
|
|
62
62
|
import { invariant } from "@ariakit/core/utils/misc";
|
|
63
63
|
function isController(target, ...ids) {
|
|
64
64
|
if (!target)
|
|
65
65
|
return false;
|
|
66
66
|
if ("id" in target) {
|
|
67
|
-
const selector = ids.filter(Boolean).map((id) => `[aria-controls
|
|
67
|
+
const selector = ids.filter(Boolean).map((id) => `[aria-controls~="${id}"]`).join(", ");
|
|
68
68
|
if (!selector)
|
|
69
69
|
return false;
|
|
70
70
|
return matches(target, selector);
|
|
@@ -75,11 +75,13 @@ var useComboboxPopover = createHook(
|
|
|
75
75
|
(_a) => {
|
|
76
76
|
var _b = _a, {
|
|
77
77
|
store,
|
|
78
|
+
modal,
|
|
78
79
|
tabIndex,
|
|
79
80
|
alwaysVisible,
|
|
80
81
|
hideOnInteractOutside = true
|
|
81
82
|
} = _b, props = __objRest(_b, [
|
|
82
83
|
"store",
|
|
84
|
+
"modal",
|
|
83
85
|
"tabIndex",
|
|
84
86
|
"alwaysVisible",
|
|
85
87
|
"hideOnInteractOutside"
|
|
@@ -94,20 +96,47 @@ var useComboboxPopover = createHook(
|
|
|
94
96
|
props = useComboboxList(__spreadValues({ store, alwaysVisible }, props));
|
|
95
97
|
props = usePopover(__spreadProps(__spreadValues({
|
|
96
98
|
store,
|
|
99
|
+
modal,
|
|
97
100
|
alwaysVisible,
|
|
101
|
+
backdrop: false,
|
|
98
102
|
autoFocusOnShow: false,
|
|
99
103
|
autoFocusOnHide: false,
|
|
100
104
|
finalFocus: baseElement,
|
|
101
105
|
preserveTabOrderAnchor: null
|
|
102
106
|
}, props), {
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
modal
|
|
107
|
+
// When the combobox popover is modal, we make sure to include the
|
|
108
|
+
// combobox input and all the combobox controls (cancel, disclosure) in
|
|
109
|
+
// the list of persistent elements so they make part of the modal context,
|
|
110
|
+
// allowing users to tab through them.
|
|
111
|
+
getPersistentElements() {
|
|
112
|
+
var _a2;
|
|
113
|
+
const elements = ((_a2 = props.getPersistentElements) == null ? void 0 : _a2.call(props)) || [];
|
|
114
|
+
if (!modal)
|
|
115
|
+
return elements;
|
|
116
|
+
if (!store)
|
|
117
|
+
return elements;
|
|
118
|
+
const { contentElement, baseElement: baseElement2 } = store.getState();
|
|
119
|
+
if (!baseElement2)
|
|
120
|
+
return elements;
|
|
121
|
+
const doc = getDocument(baseElement2);
|
|
122
|
+
const selectors = [];
|
|
123
|
+
if (contentElement == null ? void 0 : contentElement.id) {
|
|
124
|
+
selectors.push(`[aria-controls~="${contentElement.id}"]`);
|
|
125
|
+
}
|
|
126
|
+
if (baseElement2 == null ? void 0 : baseElement2.id) {
|
|
127
|
+
selectors.push(`[aria-controls~="${baseElement2.id}"]`);
|
|
128
|
+
}
|
|
129
|
+
if (!selectors.length)
|
|
130
|
+
return [...elements, baseElement2];
|
|
131
|
+
const selector = selectors.join(",");
|
|
132
|
+
const controlElements = doc.querySelectorAll(selector);
|
|
133
|
+
return [...elements, ...controlElements];
|
|
134
|
+
},
|
|
106
135
|
// Make sure we don't hide the popover when the user interacts with the
|
|
107
136
|
// combobox cancel or the combobox disclosure buttons. They will have the
|
|
108
137
|
// aria-controls attribute pointing to either the combobox input or the
|
|
109
138
|
// combobox popover elements.
|
|
110
|
-
hideOnInteractOutside
|
|
139
|
+
hideOnInteractOutside(event) {
|
|
111
140
|
var _a2, _b2;
|
|
112
141
|
const state = store == null ? void 0 : store.getState();
|
|
113
142
|
const contentId = (_a2 = state == null ? void 0 : state.contentElement) == null ? void 0 : _a2.id;
|
|
@@ -3,7 +3,7 @@ import type { BooleanOrCallback, StringWithValue } from "@ariakit/core/utils/typ
|
|
|
3
3
|
import type { CompositeOptions } from "../composite/composite.js";
|
|
4
4
|
import type { PopoverAnchorOptions } from "../popover/popover-anchor.js";
|
|
5
5
|
import type { As, Props } from "../utils/types.js";
|
|
6
|
-
import type { ComboboxStore } from "./combobox-store.js";
|
|
6
|
+
import type { ComboboxStore, ComboboxStoreState } from "./combobox-store.js";
|
|
7
7
|
/**
|
|
8
8
|
* Returns props to create a `Combobox` component.
|
|
9
9
|
* @see https://ariakit.org/components/combobox
|
|
@@ -70,6 +70,31 @@ export interface ComboboxOptions<T extends As = "input"> extends CompositeOption
|
|
|
70
70
|
* @default false
|
|
71
71
|
*/
|
|
72
72
|
autoSelect?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Function that takes the currently rendered items and returns the id of the
|
|
75
|
+
* item to be auto selected when the
|
|
76
|
+
* [`autoSelect`](https://ariakit.org/reference/combobox#autoselect) prop is
|
|
77
|
+
* `true`.
|
|
78
|
+
*
|
|
79
|
+
* By default, the first enabled item is auto selected. This function is handy
|
|
80
|
+
* if you prefer a different item to be auto selected.
|
|
81
|
+
* @example
|
|
82
|
+
* ```jsx
|
|
83
|
+
* <Combobox
|
|
84
|
+
* autoSelect
|
|
85
|
+
* getAutoSelectId={(items) => {
|
|
86
|
+
* // Auto select the first enabled item with a value
|
|
87
|
+
* const item = items.find((item) => {
|
|
88
|
+
* if (item.disabled) return false;
|
|
89
|
+
* if (!item.value) return false;
|
|
90
|
+
* return true;
|
|
91
|
+
* });
|
|
92
|
+
* return item?.id;
|
|
93
|
+
* }}
|
|
94
|
+
* />
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
getAutoSelectId?: (renderedItems: ComboboxStoreState["renderedItems"]) => string | null | undefined;
|
|
73
98
|
/**
|
|
74
99
|
* Whether the items will be filtered based on
|
|
75
100
|
* [`value`](https://ariakit.org/reference/combobox-provider#value) and
|