@ariakit/react-core 0.4.3 → 0.4.5
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 +58 -0
- package/cjs/__chunks/{7DQ2LBH2.cjs → 3HMQOCLF.cjs} +23 -5
- package/cjs/__chunks/{AJF5DT5A.cjs → AY5J25V7.cjs} +2 -2
- package/cjs/__chunks/{HFNM6QV4.cjs → DAOFDKV2.cjs} +1 -1
- package/cjs/__chunks/{GYHP7IYG.cjs → DFXPO2ED.cjs} +2 -2
- package/cjs/__chunks/{3C4RFBCG.cjs → EYZZO5IT.cjs} +1 -1
- package/cjs/__chunks/{3MKOUH5M.cjs → GZ2NNSLV.cjs} +4 -4
- package/cjs/__chunks/ISJGSS4S.cjs +16 -0
- package/cjs/__chunks/{A356CGND.cjs → JDCTLYQ4.cjs} +1 -1
- package/cjs/__chunks/{T5BWR4CB.cjs → KDTFHBKU.cjs} +2 -2
- package/cjs/__chunks/{NZSB7HSZ.cjs → LY4LCJM6.cjs} +2 -2
- package/cjs/__chunks/{DCTXNU2X.cjs → N43E53E6.cjs} +3 -3
- package/cjs/__chunks/{IHFGURUM.cjs → NRPEUNJB.cjs} +2 -2
- package/cjs/__chunks/PVLZGFP6.cjs +34 -0
- package/cjs/__chunks/{CWS5RZSU.cjs → QJDA4LG6.cjs} +28 -17
- package/cjs/__chunks/{NDVZ37O3.cjs → RG6U7KAS.cjs} +22 -4
- package/cjs/__chunks/YWAHOWYE.cjs +25 -0
- package/cjs/__chunks/{3XXW4Y4D.cjs → Z2VL7JHX.cjs} +2 -2
- package/cjs/checkbox/checkbox-check.cjs +2 -2
- package/cjs/collection/collection-renderer.d.cts +0 -2
- package/cjs/collection/collection-renderer.d.ts +0 -2
- package/cjs/combobox/combobox-cancel.cjs +4 -4
- package/cjs/combobox/combobox-disclosure.cjs +4 -4
- package/cjs/combobox/combobox-item-check.cjs +2 -2
- package/cjs/combobox/combobox-item.cjs +19 -9
- package/cjs/combobox/combobox-item.d.cts +22 -12
- package/cjs/combobox/combobox-item.d.ts +22 -12
- package/cjs/combobox/combobox-popover.cjs +41 -16
- package/cjs/combobox/combobox-provider.cjs +3 -2
- package/cjs/combobox/combobox-store.cjs +6 -2
- package/cjs/combobox/combobox-store.d.cts +12 -4
- package/cjs/combobox/combobox-store.d.ts +12 -4
- package/cjs/combobox/combobox-value.cjs +32 -0
- package/cjs/combobox/combobox-value.d.cts +41 -0
- package/cjs/combobox/combobox-value.d.ts +41 -0
- package/cjs/combobox/combobox.cjs +79 -32
- package/cjs/combobox/combobox.d.cts +20 -0
- package/cjs/combobox/combobox.d.ts +20 -0
- package/cjs/composite/composite-input.cjs +91 -6
- package/cjs/composite/composite-input.d.cts +2 -0
- package/cjs/composite/composite-input.d.ts +2 -0
- package/cjs/composite/composite-item.cjs +3 -3
- package/cjs/composite/composite-overflow-disclosure.cjs +3 -3
- package/cjs/composite/composite-overflow.cjs +12 -12
- package/cjs/composite/composite-renderer.d.cts +0 -2
- package/cjs/composite/composite-renderer.d.ts +0 -2
- package/cjs/dialog/dialog-backdrop.cjs +3 -3
- package/cjs/dialog/dialog-dismiss.cjs +2 -2
- package/cjs/dialog/dialog.cjs +11 -11
- package/cjs/dialog/dialog.d.cts +4 -0
- package/cjs/dialog/dialog.d.ts +4 -0
- package/cjs/dialog/utils/disable-tree.cjs +3 -3
- package/cjs/dialog/utils/use-prevent-body-scroll.cjs +3 -3
- package/cjs/form/form-checkbox.cjs +1 -1
- package/cjs/form/form-push.cjs +1 -1
- package/cjs/form/form-radio.cjs +4 -4
- package/cjs/hovercard/hovercard-disclosure.cjs +1 -1
- package/cjs/hovercard/hovercard-dismiss.cjs +4 -4
- package/cjs/hovercard/hovercard.cjs +13 -13
- package/cjs/menu/menu-button-arrow.cjs +2 -2
- package/cjs/menu/menu-dismiss.cjs +4 -4
- package/cjs/menu/menu-item-check.cjs +2 -2
- package/cjs/menu/menu-item-checkbox.cjs +4 -4
- package/cjs/menu/menu-item-radio.cjs +7 -7
- package/cjs/menu/menu-item.cjs +4 -4
- package/cjs/menu/menu.cjs +14 -14
- package/cjs/popover/popover-disclosure-arrow.cjs +2 -2
- package/cjs/popover/popover-dismiss.cjs +3 -3
- package/cjs/popover/popover.cjs +12 -12
- package/cjs/radio/radio.cjs +4 -4
- package/cjs/select/select-arrow.cjs +3 -3
- package/cjs/select/select-item-check.cjs +2 -2
- package/cjs/select/select-item.cjs +4 -4
- package/cjs/select/select-popover.cjs +13 -13
- package/cjs/select/select-value.d.cts +8 -7
- package/cjs/select/select-value.d.ts +8 -7
- package/cjs/select/select.cjs +4 -4
- package/cjs/tab/tab-panel.cjs +2 -2
- package/cjs/tab/tab.cjs +7 -7
- package/cjs/tag/tag-context.cjs +25 -0
- package/cjs/tag/tag-context.d.cts +21 -0
- package/cjs/tag/tag-context.d.ts +21 -0
- package/cjs/tag/tag-input.cjs +191 -0
- package/cjs/tag/tag-input.d.cts +122 -0
- package/cjs/tag/tag-input.d.ts +122 -0
- package/cjs/tag/tag-list-label.cjs +56 -0
- package/cjs/tag/tag-list-label.d.cts +55 -0
- package/cjs/tag/tag-list-label.d.ts +55 -0
- package/cjs/tag/tag-list.cjs +141 -0
- package/cjs/tag/tag-list.d.cts +58 -0
- package/cjs/tag/tag-list.d.ts +58 -0
- package/cjs/tag/tag-provider.cjs +26 -0
- package/cjs/tag/tag-provider.d.cts +29 -0
- package/cjs/tag/tag-provider.d.ts +29 -0
- package/cjs/tag/tag-remove.cjs +119 -0
- package/cjs/tag/tag-remove.d.cts +67 -0
- package/cjs/tag/tag-remove.d.ts +67 -0
- package/cjs/tag/tag-store.cjs +15 -0
- package/cjs/tag/tag-store.d.cts +49 -0
- package/cjs/tag/tag-store.d.ts +49 -0
- package/cjs/tag/tag-value.cjs +29 -0
- package/cjs/tag/tag-value.d.cts +41 -0
- package/cjs/tag/tag-value.d.ts +41 -0
- package/cjs/tag/tag-values.cjs +29 -0
- package/cjs/tag/tag-values.d.cts +52 -0
- package/cjs/tag/tag-values.d.ts +52 -0
- package/cjs/tag/tag.cjs +130 -0
- package/cjs/tag/tag.d.cts +74 -0
- package/cjs/tag/tag.d.ts +74 -0
- package/cjs/tag/utils.cjs +8 -0
- package/cjs/tag/utils.d.cts +1 -0
- package/cjs/tag/utils.d.ts +1 -0
- package/cjs/toolbar/toolbar-container.cjs +4 -4
- package/cjs/toolbar/toolbar-input.cjs +4 -8
- package/cjs/toolbar/toolbar-input.d.cts +3 -2
- package/cjs/toolbar/toolbar-input.d.ts +3 -2
- package/cjs/toolbar/toolbar-item.cjs +4 -4
- package/cjs/tooltip/tooltip.cjs +14 -14
- package/combobox/combobox-value/package.json +8 -0
- package/esm/__chunks/{LABIXQLW.js → 44PDY2W5.js} +1 -1
- package/esm/__chunks/{FYNSL2D5.js → 5H3YXAUC.js} +1 -1
- package/esm/__chunks/{6VDNHSLX.js → 65LF6MEO.js} +2 -2
- package/esm/__chunks/{X3V2DT2U.js → 6YVAEELE.js} +1 -1
- package/esm/__chunks/{JCOBPKEI.js → BY6P32UK.js} +1 -1
- package/esm/__chunks/{ZFEEEZVE.js → DLLQM6DZ.js} +22 -4
- package/esm/__chunks/{NN4HLGKS.js → F2RFUFO2.js} +1 -1
- package/esm/__chunks/{NQ4PTILT.js → FGHVVLPU.js} +29 -18
- package/esm/__chunks/{2VWKZYYT.js → H5N72W37.js} +1 -1
- package/esm/__chunks/L7IM35RU.js +16 -0
- package/esm/__chunks/{HW63KLP5.js → M354SEUF.js} +1 -1
- package/esm/__chunks/{RAKW656I.js → Q4PZFBSW.js} +1 -1
- package/esm/__chunks/QNNHZL3W.js +25 -0
- package/esm/__chunks/{C5HA76JU.js → QZJOXZKA.js} +1 -1
- package/esm/__chunks/{XK6CE2M5.js → UKDZLPKH.js} +1 -1
- package/esm/__chunks/{ONUY4D7O.js → VGORKDMQ.js} +26 -8
- package/esm/__chunks/WYDDZRWN.js +34 -0
- package/esm/checkbox/checkbox-check.js +1 -1
- package/esm/collection/collection-renderer.d.ts +0 -2
- package/esm/combobox/combobox-cancel.js +4 -4
- package/esm/combobox/combobox-disclosure.js +4 -4
- package/esm/combobox/combobox-item-check.js +1 -1
- package/esm/combobox/combobox-item.d.ts +22 -12
- package/esm/combobox/combobox-item.js +19 -9
- package/esm/combobox/combobox-popover.js +40 -15
- package/esm/combobox/combobox-provider.js +2 -1
- package/esm/combobox/combobox-store.d.ts +12 -4
- package/esm/combobox/combobox-store.js +5 -1
- package/esm/combobox/combobox-value.d.ts +41 -0
- package/esm/combobox/combobox-value.js +32 -0
- package/esm/combobox/combobox.d.ts +20 -0
- package/esm/combobox/combobox.js +80 -33
- package/esm/composite/composite-input.d.ts +2 -0
- package/esm/composite/composite-input.js +92 -7
- package/esm/composite/composite-item.js +2 -2
- package/esm/composite/composite-overflow-disclosure.js +2 -2
- package/esm/composite/composite-overflow.js +11 -11
- package/esm/composite/composite-renderer.d.ts +0 -2
- package/esm/dialog/dialog-backdrop.js +2 -2
- package/esm/dialog/dialog-dismiss.js +1 -1
- package/esm/dialog/dialog.d.ts +4 -0
- package/esm/dialog/dialog.js +10 -10
- package/esm/dialog/utils/disable-tree.js +2 -2
- package/esm/dialog/utils/use-prevent-body-scroll.js +2 -2
- package/esm/form/form-checkbox.js +1 -1
- package/esm/form/form-push.js +1 -1
- package/esm/form/form-radio.js +3 -3
- package/esm/hovercard/hovercard-disclosure.js +1 -1
- package/esm/hovercard/hovercard-dismiss.js +3 -3
- package/esm/hovercard/hovercard.js +12 -12
- package/esm/menu/menu-button-arrow.js +1 -1
- package/esm/menu/menu-dismiss.js +3 -3
- package/esm/menu/menu-item-check.js +1 -1
- package/esm/menu/menu-item-checkbox.js +3 -3
- package/esm/menu/menu-item-radio.js +5 -5
- package/esm/menu/menu-item.js +3 -3
- package/esm/menu/menu.js +12 -12
- package/esm/popover/popover-disclosure-arrow.js +1 -1
- package/esm/popover/popover-dismiss.js +2 -2
- package/esm/popover/popover.js +11 -11
- package/esm/radio/radio.js +3 -3
- package/esm/select/select-arrow.js +2 -2
- package/esm/select/select-item-check.js +1 -1
- package/esm/select/select-item.js +4 -4
- package/esm/select/select-popover.js +11 -11
- package/esm/select/select-value.d.ts +8 -7
- package/esm/select/select.js +3 -3
- package/esm/tab/tab-panel.js +3 -3
- package/esm/tab/tab.js +5 -5
- package/esm/tag/tag-context.d.ts +21 -0
- package/esm/tag/tag-context.js +25 -0
- package/esm/tag/tag-input.d.ts +122 -0
- package/esm/tag/tag-input.js +191 -0
- package/esm/tag/tag-list-label.d.ts +55 -0
- package/esm/tag/tag-list-label.js +56 -0
- package/esm/tag/tag-list.d.ts +58 -0
- package/esm/tag/tag-list.js +141 -0
- package/esm/tag/tag-provider.d.ts +29 -0
- package/esm/tag/tag-provider.js +26 -0
- package/esm/tag/tag-remove.d.ts +67 -0
- package/esm/tag/tag-remove.js +119 -0
- package/esm/tag/tag-store.d.ts +49 -0
- package/esm/tag/tag-store.js +15 -0
- package/esm/tag/tag-value.d.ts +41 -0
- package/esm/tag/tag-value.js +29 -0
- package/esm/tag/tag-values.d.ts +52 -0
- package/esm/tag/tag-values.js +29 -0
- package/esm/tag/tag.d.ts +74 -0
- package/esm/tag/tag.js +130 -0
- package/esm/tag/utils.d.ts +1 -0
- package/esm/tag/utils.js +8 -0
- package/esm/toolbar/toolbar-container.js +3 -3
- package/esm/toolbar/toolbar-input.d.ts +3 -2
- package/esm/toolbar/toolbar-input.js +3 -7
- package/esm/toolbar/toolbar-item.js +3 -3
- package/esm/tooltip/tooltip.js +12 -12
- package/package.json +86 -2
- package/tag/tag/package.json +8 -0
- package/tag/tag-context/package.json +8 -0
- package/tag/tag-input/package.json +8 -0
- package/tag/tag-list/package.json +8 -0
- package/tag/tag-list-label/package.json +8 -0
- package/tag/tag-provider/package.json +8 -0
- package/tag/tag-remove/package.json +8 -0
- package/tag/tag-store/package.json +8 -0
- package/tag/tag-value/package.json +8 -0
- package/tag/tag-values/package.json +8 -0
- package/tag/utils/package.json +8 -0
- package/cjs/__chunks/WGZQRLXV.cjs +0 -84
- package/esm/__chunks/RPGNBKKU.js +0 -84
- package/cjs/__chunks/{37BRXQN7.cjs → BX2QEIBH.cjs} +3 -3
- package/cjs/__chunks/{PVYTX5U5.cjs → SL55T4ZB.cjs} +2 -2
- package/cjs/__chunks/{TSEXNK3K.cjs → VR6GCLOV.cjs} +2 -2
- package/esm/__chunks/{PTPUIM7N.js → 3TEK3C5Q.js} +3 -3
- package/esm/__chunks/{U2L67A6K.js → BC72XE6E.js} +3 -3
- package/esm/__chunks/{GOXKZAQI.js → CMFBAHKI.js} +3 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useCompositeStoreProps
|
|
4
|
+
} from "./ZR5N62ZV.js";
|
|
5
|
+
import {
|
|
6
|
+
useStore,
|
|
7
|
+
useStoreProps
|
|
8
|
+
} from "./PWUXK5IM.js";
|
|
9
|
+
|
|
10
|
+
// src/tag/tag-store.ts
|
|
11
|
+
import * as Core from "@ariakit/core/tag/tag-store";
|
|
12
|
+
function useTagStoreProps(store, update, props) {
|
|
13
|
+
useStoreProps(store, props, "value", "setValue");
|
|
14
|
+
useStoreProps(store, props, "values", "setValues");
|
|
15
|
+
return useCompositeStoreProps(store, update, props);
|
|
16
|
+
}
|
|
17
|
+
function useTagStore(props = {}) {
|
|
18
|
+
const [store, update] = useStore(Core.createTagStore, props);
|
|
19
|
+
return useTagStoreProps(store, update, props);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
useTagStoreProps,
|
|
24
|
+
useTagStore
|
|
25
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useCommand
|
|
4
|
-
} from "./PJ7ERAIM.js";
|
|
5
2
|
import {
|
|
6
3
|
useCollectionItem
|
|
7
4
|
} from "./IFMAUEA7.js";
|
|
5
|
+
import {
|
|
6
|
+
useCommand
|
|
7
|
+
} from "./PJ7ERAIM.js";
|
|
8
8
|
import {
|
|
9
9
|
focusSilently,
|
|
10
10
|
getEnabledItem,
|
|
11
|
-
isItem
|
|
11
|
+
isItem,
|
|
12
|
+
selectTextField
|
|
12
13
|
} from "./3IEDWLST.js";
|
|
13
14
|
import {
|
|
14
15
|
CompositeItemContext,
|
|
@@ -42,8 +43,11 @@ import {
|
|
|
42
43
|
import { useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
43
44
|
import {
|
|
44
45
|
getScrollingElement,
|
|
46
|
+
getTextboxSelection,
|
|
47
|
+
getTextboxValue,
|
|
45
48
|
isButton,
|
|
46
|
-
isTextField
|
|
49
|
+
isTextField,
|
|
50
|
+
isTextbox
|
|
47
51
|
} from "@ariakit/core/utils/dom";
|
|
48
52
|
import { isPortalEvent, isSelfTarget } from "@ariakit/core/utils/events";
|
|
49
53
|
import {
|
|
@@ -53,9 +57,7 @@ import {
|
|
|
53
57
|
import { jsx } from "react/jsx-runtime";
|
|
54
58
|
var TagName = "button";
|
|
55
59
|
function isEditableElement(element) {
|
|
56
|
-
if (element
|
|
57
|
-
return true;
|
|
58
|
-
if (isTextField(element))
|
|
60
|
+
if (isTextbox(element))
|
|
59
61
|
return true;
|
|
60
62
|
return element.tagName === "INPUT" && !isButton(element);
|
|
61
63
|
}
|
|
@@ -217,6 +219,9 @@ var useCompositeItem = createHook(
|
|
|
217
219
|
return;
|
|
218
220
|
const { virtualFocus: virtualFocus2, baseElement: baseElement2 } = store.getState();
|
|
219
221
|
store.setActiveId(id);
|
|
222
|
+
if (isTextbox(event.currentTarget)) {
|
|
223
|
+
selectTextField(event.currentTarget);
|
|
224
|
+
}
|
|
220
225
|
if (!virtualFocus2)
|
|
221
226
|
return;
|
|
222
227
|
if (!isSelfTarget(event))
|
|
@@ -303,6 +308,19 @@ var useCompositeItem = createHook(
|
|
|
303
308
|
};
|
|
304
309
|
const action = keyMap[event.key];
|
|
305
310
|
if (action) {
|
|
311
|
+
if (isTextbox(currentTarget)) {
|
|
312
|
+
const selection = getTextboxSelection(currentTarget);
|
|
313
|
+
const isLeft = isHorizontal && event.key === "ArrowLeft";
|
|
314
|
+
const isRight = isHorizontal && event.key === "ArrowRight";
|
|
315
|
+
const isUp = isVertical && event.key === "ArrowUp";
|
|
316
|
+
const isDown = isVertical && event.key === "ArrowDown";
|
|
317
|
+
if (isRight || isDown) {
|
|
318
|
+
const { length: valueLength } = getTextboxValue(currentTarget);
|
|
319
|
+
if (selection.end !== valueLength)
|
|
320
|
+
return;
|
|
321
|
+
} else if ((isLeft || isUp) && selection.start !== 0)
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
306
324
|
const nextId = action();
|
|
307
325
|
if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
|
|
308
326
|
if (!moveOnKeyPressProp(event))
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
CompositeContextProvider,
|
|
4
|
+
CompositeScopedContextProvider
|
|
5
|
+
} from "./QFI3MCMR.js";
|
|
6
|
+
import {
|
|
7
|
+
createStoreContext
|
|
8
|
+
} from "./GUCZNEAD.js";
|
|
9
|
+
|
|
10
|
+
// src/tag/tag-context.tsx
|
|
11
|
+
import { createContext } from "react";
|
|
12
|
+
var TagValueContext = createContext(null);
|
|
13
|
+
var TagRemoveIdContext = createContext(
|
|
14
|
+
null
|
|
15
|
+
);
|
|
16
|
+
var ctx = createStoreContext(
|
|
17
|
+
[CompositeContextProvider],
|
|
18
|
+
[CompositeScopedContextProvider]
|
|
19
|
+
);
|
|
20
|
+
var useTagContext = ctx.useContext;
|
|
21
|
+
var useTagScopedContext = ctx.useScopedContext;
|
|
22
|
+
var useTagProviderContext = ctx.useProviderContext;
|
|
23
|
+
var TagContextProvider = ctx.ContextProvider;
|
|
24
|
+
var TagScopedContextProvider = ctx.ScopedContextProvider;
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
TagValueContext,
|
|
28
|
+
TagRemoveIdContext,
|
|
29
|
+
useTagContext,
|
|
30
|
+
useTagScopedContext,
|
|
31
|
+
useTagProviderContext,
|
|
32
|
+
TagContextProvider,
|
|
33
|
+
TagScopedContextProvider
|
|
34
|
+
};
|
|
@@ -296,9 +296,7 @@ export declare function useCollectionRenderer<T extends Item = any>({ store, ite
|
|
|
296
296
|
onPointerCancel?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
297
297
|
onPointerCancelCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
298
298
|
onPointerEnter?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
299
|
-
onPointerEnterCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
300
299
|
onPointerLeave?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
301
|
-
onPointerLeaveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
302
300
|
onPointerOver?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
303
301
|
onPointerOverCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
304
302
|
onPointerOut?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useComboboxProviderContext
|
|
4
|
+
} from "../__chunks/N4X7J4OQ.js";
|
|
2
5
|
import {
|
|
3
6
|
useButton
|
|
4
7
|
} from "../__chunks/CKAOM5LG.js";
|
|
5
8
|
import "../__chunks/PJ7ERAIM.js";
|
|
6
|
-
import {
|
|
7
|
-
useComboboxProviderContext
|
|
8
|
-
} from "../__chunks/N4X7J4OQ.js";
|
|
9
9
|
import "../__chunks/QFI3MCMR.js";
|
|
10
10
|
import "../__chunks/6LTHW2TQ.js";
|
|
11
11
|
import "../__chunks/5B3U64HV.js";
|
|
@@ -44,7 +44,7 @@ var children = /* @__PURE__ */ jsxs(
|
|
|
44
44
|
stroke: "currentColor",
|
|
45
45
|
strokeLinecap: "round",
|
|
46
46
|
strokeLinejoin: "round",
|
|
47
|
-
strokeWidth:
|
|
47
|
+
strokeWidth: 1.5,
|
|
48
48
|
width: "1em",
|
|
49
49
|
height: "1em",
|
|
50
50
|
pointerEvents: "none",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useComboboxProviderContext
|
|
4
|
+
} from "../__chunks/N4X7J4OQ.js";
|
|
2
5
|
import {
|
|
3
6
|
useDialogDisclosure
|
|
4
7
|
} from "../__chunks/LTYBQEWX.js";
|
|
5
8
|
import "../__chunks/R6SM2O47.js";
|
|
6
9
|
import "../__chunks/CKAOM5LG.js";
|
|
7
10
|
import "../__chunks/PJ7ERAIM.js";
|
|
8
|
-
import {
|
|
9
|
-
useComboboxProviderContext
|
|
10
|
-
} from "../__chunks/N4X7J4OQ.js";
|
|
11
11
|
import "../__chunks/QFI3MCMR.js";
|
|
12
12
|
import "../__chunks/6LTHW2TQ.js";
|
|
13
13
|
import "../__chunks/5B3U64HV.js";
|
|
@@ -43,7 +43,7 @@ var children = /* @__PURE__ */ jsx(
|
|
|
43
43
|
stroke: "currentColor",
|
|
44
44
|
strokeLinecap: "round",
|
|
45
45
|
strokeLinejoin: "round",
|
|
46
|
-
strokeWidth:
|
|
46
|
+
strokeWidth: 1.5,
|
|
47
47
|
viewBox: "0 0 16 16",
|
|
48
48
|
height: "1em",
|
|
49
49
|
width: "1em",
|
|
@@ -93,6 +93,20 @@ export interface ComboboxItemOptions<T extends ElementType = TagName> extends Co
|
|
|
93
93
|
* - [Command Menu](https://ariakit.org/examples/dialog-combobox-command-menu)
|
|
94
94
|
*/
|
|
95
95
|
hideOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
96
|
+
/**
|
|
97
|
+
* Whether to set the combobox
|
|
98
|
+
* [`value`](https://ariakit.org/reference/combobox-provider#value) state
|
|
99
|
+
* using this item's
|
|
100
|
+
* [`value`](https://ariakit.org/reference/combobox-item#value) when the item
|
|
101
|
+
* is clicked. The default is `true`, unless the combobox is
|
|
102
|
+
* [multi-selectable](https://ariakit.org/examples/combobox-multiple).
|
|
103
|
+
*
|
|
104
|
+
* Live examples:
|
|
105
|
+
* - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
|
|
106
|
+
* - [Submenu with
|
|
107
|
+
* Combobox](https://ariakit.org/examples/menu-nested-combobox)
|
|
108
|
+
*/
|
|
109
|
+
setValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
96
110
|
/**
|
|
97
111
|
* Whether to set the
|
|
98
112
|
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
@@ -108,19 +122,15 @@ export interface ComboboxItemOptions<T extends ElementType = TagName> extends Co
|
|
|
108
122
|
*/
|
|
109
123
|
selectValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
110
124
|
/**
|
|
111
|
-
* Whether to
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* [`
|
|
115
|
-
*
|
|
116
|
-
* [
|
|
117
|
-
*
|
|
118
|
-
* Live examples:
|
|
119
|
-
* - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
|
|
120
|
-
* - [Submenu with
|
|
121
|
-
* Combobox](https://ariakit.org/examples/menu-nested-combobox)
|
|
125
|
+
* Whether to reset the the combobox input value when this item is selected or
|
|
126
|
+
* unselected by click. This prop is set to `true` by default if
|
|
127
|
+
* the combobox supports multiple selections. In other words, if the
|
|
128
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
129
|
+
* or
|
|
130
|
+
* [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
|
|
131
|
+
* props are arrays.
|
|
122
132
|
*/
|
|
123
|
-
|
|
133
|
+
resetValueOnSelect?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
124
134
|
/**
|
|
125
135
|
* @default false
|
|
126
136
|
*/
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useCompositeHover
|
|
4
4
|
} from "../__chunks/VXKKJNIF.js";
|
|
5
|
-
import {
|
|
6
|
-
useCompositeItem
|
|
7
|
-
} from "../__chunks/ONUY4D7O.js";
|
|
8
|
-
import "../__chunks/PJ7ERAIM.js";
|
|
9
5
|
import {
|
|
10
6
|
ComboboxItemCheckedContext,
|
|
11
7
|
ComboboxItemValueContext,
|
|
12
8
|
ComboboxListRoleContext,
|
|
13
9
|
useComboboxScopedContext
|
|
14
10
|
} from "../__chunks/N4X7J4OQ.js";
|
|
11
|
+
import {
|
|
12
|
+
useCompositeItem
|
|
13
|
+
} from "../__chunks/VGORKDMQ.js";
|
|
15
14
|
import "../__chunks/IFMAUEA7.js";
|
|
15
|
+
import "../__chunks/PJ7ERAIM.js";
|
|
16
16
|
import "../__chunks/3IEDWLST.js";
|
|
17
17
|
import "../__chunks/QFI3MCMR.js";
|
|
18
18
|
import "../__chunks/6LTHW2TQ.js";
|
|
@@ -74,8 +74,9 @@ var useComboboxItem = createHook(
|
|
|
74
74
|
store,
|
|
75
75
|
value,
|
|
76
76
|
hideOnClick,
|
|
77
|
-
selectValueOnClick = true,
|
|
78
77
|
setValueOnClick,
|
|
78
|
+
selectValueOnClick = true,
|
|
79
|
+
resetValueOnSelect,
|
|
79
80
|
focusOnHover = false,
|
|
80
81
|
moveOnKeyPress = true,
|
|
81
82
|
getItem: getItemProp
|
|
@@ -83,12 +84,14 @@ var useComboboxItem = createHook(
|
|
|
83
84
|
"store",
|
|
84
85
|
"value",
|
|
85
86
|
"hideOnClick",
|
|
86
|
-
"selectValueOnClick",
|
|
87
87
|
"setValueOnClick",
|
|
88
|
+
"selectValueOnClick",
|
|
89
|
+
"resetValueOnSelect",
|
|
88
90
|
"focusOnHover",
|
|
89
91
|
"moveOnKeyPress",
|
|
90
92
|
"getItem"
|
|
91
93
|
]);
|
|
94
|
+
var _a2;
|
|
92
95
|
const context = useComboboxScopedContext();
|
|
93
96
|
store = store || context;
|
|
94
97
|
invariant(
|
|
@@ -108,11 +111,18 @@ var useComboboxItem = createHook(
|
|
|
108
111
|
const multiSelectable = store.useState(
|
|
109
112
|
(state) => Array.isArray(state.selectedValue)
|
|
110
113
|
);
|
|
114
|
+
const selected = store.useState(
|
|
115
|
+
(state) => isSelected(state.selectedValue, value)
|
|
116
|
+
);
|
|
117
|
+
const resetValueOnSelectState = store.useState("resetValueOnSelect");
|
|
111
118
|
setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
|
|
112
119
|
hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
|
|
113
120
|
const onClickProp = props.onClick;
|
|
114
121
|
const setValueOnClickProp = useBooleanEvent(setValueOnClick);
|
|
115
122
|
const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
|
|
123
|
+
const resetValueOnSelectProp = useBooleanEvent(
|
|
124
|
+
(_a2 = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a2 : multiSelectable
|
|
125
|
+
);
|
|
116
126
|
const hideOnClickProp = useBooleanEvent(hideOnClick);
|
|
117
127
|
const onClick = useEvent((event) => {
|
|
118
128
|
onClickProp == null ? void 0 : onClickProp(event);
|
|
@@ -124,6 +134,9 @@ var useComboboxItem = createHook(
|
|
|
124
134
|
return;
|
|
125
135
|
if (value != null) {
|
|
126
136
|
if (selectValueOnClickProp(event)) {
|
|
137
|
+
if (resetValueOnSelectProp(event)) {
|
|
138
|
+
store == null ? void 0 : store.resetValue();
|
|
139
|
+
}
|
|
127
140
|
store == null ? void 0 : store.setSelectedValue((prevValue) => {
|
|
128
141
|
if (!Array.isArray(prevValue))
|
|
129
142
|
return value;
|
|
@@ -159,9 +172,6 @@ var useComboboxItem = createHook(
|
|
|
159
172
|
}
|
|
160
173
|
}
|
|
161
174
|
});
|
|
162
|
-
const selected = store.useState(
|
|
163
|
-
(state) => isSelected(state.selectedValue, value)
|
|
164
|
-
);
|
|
165
175
|
if (multiSelectable && selected != null) {
|
|
166
176
|
props = __spreadValues({
|
|
167
177
|
"aria-selected": selected
|
|
@@ -9,32 +9,32 @@ import "../__chunks/QFI3MCMR.js";
|
|
|
9
9
|
import "../__chunks/6LTHW2TQ.js";
|
|
10
10
|
import {
|
|
11
11
|
usePopover
|
|
12
|
-
} from "../__chunks/
|
|
12
|
+
} from "../__chunks/6YVAEELE.js";
|
|
13
13
|
import {
|
|
14
14
|
createDialogComponent
|
|
15
|
-
} from "../__chunks/
|
|
16
|
-
import "../__chunks/
|
|
17
|
-
import "../__chunks/6GXEOXGT.js";
|
|
18
|
-
import "../__chunks/PTPUIM7N.js";
|
|
19
|
-
import "../__chunks/4ZRXV5C7.js";
|
|
20
|
-
import "../__chunks/U2L67A6K.js";
|
|
21
|
-
import "../__chunks/4KKLZMKS.js";
|
|
15
|
+
} from "../__chunks/FGHVVLPU.js";
|
|
16
|
+
import "../__chunks/CMFBAHKI.js";
|
|
22
17
|
import "../__chunks/HSFE2URL.js";
|
|
23
18
|
import "../__chunks/H2NVVTJB.js";
|
|
19
|
+
import "../__chunks/6GXEOXGT.js";
|
|
24
20
|
import "../__chunks/YNKDLCEK.js";
|
|
21
|
+
import "../__chunks/3TEK3C5Q.js";
|
|
22
|
+
import "../__chunks/4ZRXV5C7.js";
|
|
23
|
+
import "../__chunks/677M2CI3.js";
|
|
25
24
|
import "../__chunks/MKDDWKFK.js";
|
|
26
25
|
import "../__chunks/5QL6BP6J.js";
|
|
27
26
|
import "../__chunks/OOBDFMJL.js";
|
|
27
|
+
import "../__chunks/BC72XE6E.js";
|
|
28
28
|
import "../__chunks/53CQGCDZ.js";
|
|
29
|
-
import "../__chunks/
|
|
29
|
+
import "../__chunks/4KKLZMKS.js";
|
|
30
30
|
import "../__chunks/UHSH3H5I.js";
|
|
31
31
|
import "../__chunks/UYRJLDVS.js";
|
|
32
|
+
import "../__chunks/XPF5GU3Q.js";
|
|
32
33
|
import "../__chunks/JPQNKTGF.js";
|
|
33
34
|
import "../__chunks/LQTCWTYB.js";
|
|
34
35
|
import "../__chunks/7452U3HH.js";
|
|
35
|
-
import "../__chunks/XPF5GU3Q.js";
|
|
36
|
-
import "../__chunks/4MFOHMLS.js";
|
|
37
36
|
import "../__chunks/KCMTTTFR.js";
|
|
37
|
+
import "../__chunks/4MFOHMLS.js";
|
|
38
38
|
import "../__chunks/5B3U64HV.js";
|
|
39
39
|
import "../__chunks/IWHI6Y45.js";
|
|
40
40
|
import "../__chunks/RG6J4TID.js";
|
|
@@ -48,7 +48,9 @@ import {
|
|
|
48
48
|
} from "../__chunks/GUCZNEAD.js";
|
|
49
49
|
import "../__chunks/2KACNUKS.js";
|
|
50
50
|
import "../__chunks/ZIX5D53S.js";
|
|
51
|
-
import
|
|
51
|
+
import {
|
|
52
|
+
useStoreState
|
|
53
|
+
} from "../__chunks/PWUXK5IM.js";
|
|
52
54
|
import "../__chunks/WOWUAP42.js";
|
|
53
55
|
import "../__chunks/XM66DUTO.js";
|
|
54
56
|
import {
|
|
@@ -58,8 +60,9 @@ import {
|
|
|
58
60
|
} from "../__chunks/4R3V3JGP.js";
|
|
59
61
|
|
|
60
62
|
// src/combobox/combobox-popover.tsx
|
|
63
|
+
import { useRef } from "react";
|
|
61
64
|
import { getDocument, matches } from "@ariakit/core/utils/dom";
|
|
62
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
65
|
+
import { invariant, isFalsyBooleanCallback } from "@ariakit/core/utils/misc";
|
|
63
66
|
var TagName = "div";
|
|
64
67
|
function isController(target, ...ids) {
|
|
65
68
|
if (!target)
|
|
@@ -79,12 +82,14 @@ var useComboboxPopover = createHook(
|
|
|
79
82
|
modal,
|
|
80
83
|
tabIndex,
|
|
81
84
|
alwaysVisible,
|
|
85
|
+
autoFocusOnHide = true,
|
|
82
86
|
hideOnInteractOutside = true
|
|
83
87
|
} = _b, props = __objRest(_b, [
|
|
84
88
|
"store",
|
|
85
89
|
"modal",
|
|
86
90
|
"tabIndex",
|
|
87
91
|
"alwaysVisible",
|
|
92
|
+
"autoFocusOnHide",
|
|
88
93
|
"hideOnInteractOutside"
|
|
89
94
|
]);
|
|
90
95
|
const context = useComboboxProviderContext();
|
|
@@ -94,6 +99,11 @@ var useComboboxPopover = createHook(
|
|
|
94
99
|
process.env.NODE_ENV !== "production" && "ComboboxPopover must receive a `store` prop or be wrapped in a ComboboxProvider component."
|
|
95
100
|
);
|
|
96
101
|
const baseElement = store.useState("baseElement");
|
|
102
|
+
const hiddenByClickOutsideRef = useRef(false);
|
|
103
|
+
const treeSnapshotKey = useStoreState(
|
|
104
|
+
store.tag,
|
|
105
|
+
(state) => state == null ? void 0 : state.renderedItems.length
|
|
106
|
+
);
|
|
97
107
|
props = useComboboxList(__spreadValues({ store, alwaysVisible }, props));
|
|
98
108
|
props = usePopover(__spreadProps(__spreadValues({
|
|
99
109
|
store,
|
|
@@ -101,9 +111,9 @@ var useComboboxPopover = createHook(
|
|
|
101
111
|
alwaysVisible,
|
|
102
112
|
backdrop: false,
|
|
103
113
|
autoFocusOnShow: false,
|
|
104
|
-
autoFocusOnHide: false,
|
|
105
114
|
finalFocus: baseElement,
|
|
106
|
-
preserveTabOrderAnchor: null
|
|
115
|
+
preserveTabOrderAnchor: null,
|
|
116
|
+
unstable_treeSnapshotKey: treeSnapshotKey
|
|
107
117
|
}, props), {
|
|
108
118
|
// When the combobox popover is modal, we make sure to include the
|
|
109
119
|
// combobox input and all the combobox controls (cancel, disclosure) in
|
|
@@ -133,6 +143,18 @@ var useComboboxPopover = createHook(
|
|
|
133
143
|
const controlElements = doc.querySelectorAll(selector);
|
|
134
144
|
return [...elements, ...controlElements];
|
|
135
145
|
},
|
|
146
|
+
// The combobox popover should focus on the combobox input when it hides,
|
|
147
|
+
// unless the event was triggered by a click outside the popover, in which
|
|
148
|
+
// case the input shouldn't be re-focused.
|
|
149
|
+
autoFocusOnHide(element) {
|
|
150
|
+
if (isFalsyBooleanCallback(autoFocusOnHide, element))
|
|
151
|
+
return false;
|
|
152
|
+
if (hiddenByClickOutsideRef.current) {
|
|
153
|
+
hiddenByClickOutsideRef.current = false;
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
},
|
|
136
158
|
// Make sure we don't hide the popover when the user interacts with the
|
|
137
159
|
// combobox cancel or the combobox disclosure buttons. They will have the
|
|
138
160
|
// aria-controls attribute pointing to either the combobox input or the
|
|
@@ -145,6 +167,9 @@ var useComboboxPopover = createHook(
|
|
|
145
167
|
if (isController(event.target, contentId, baseId))
|
|
146
168
|
return false;
|
|
147
169
|
const result = typeof hideOnInteractOutside === "function" ? hideOnInteractOutside(event) : hideOnInteractOutside;
|
|
170
|
+
if (result) {
|
|
171
|
+
hiddenByClickOutsideRef.current = event.type === "click";
|
|
172
|
+
}
|
|
148
173
|
return result;
|
|
149
174
|
}
|
|
150
175
|
}));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useComboboxStore
|
|
4
|
-
} from "../__chunks/
|
|
4
|
+
} from "../__chunks/DLLQM6DZ.js";
|
|
5
5
|
import {
|
|
6
6
|
ComboboxContextProvider
|
|
7
7
|
} from "../__chunks/N4X7J4OQ.js";
|
|
8
|
+
import "../__chunks/WYDDZRWN.js";
|
|
8
9
|
import "../__chunks/ZR5N62ZV.js";
|
|
9
10
|
import "../__chunks/LGWSZOP2.js";
|
|
10
11
|
import "../__chunks/QFI3MCMR.js";
|
|
@@ -2,9 +2,12 @@ import * as Core from "@ariakit/core/combobox/combobox-store";
|
|
|
2
2
|
import type { PickRequired } from "@ariakit/core/utils/types";
|
|
3
3
|
import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
4
4
|
import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
|
|
5
|
+
import type { TagStore } from "../tag/tag-store.js";
|
|
5
6
|
import type { Store } from "../utils/store.js";
|
|
6
7
|
export declare function useComboboxStoreProps<T extends Core.ComboboxStore>(store: T, update: () => void, props: ComboboxStoreProps): T & {
|
|
7
8
|
disclosure: import("../disclosure/disclosure-store.js").DisclosureStore | null | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
tag: TagStore | null | undefined;
|
|
8
11
|
};
|
|
9
12
|
/**
|
|
10
13
|
* Creates a combobox store to control the state of
|
|
@@ -31,9 +34,9 @@ export interface ComboboxStoreItem extends Core.ComboboxStoreItem {
|
|
|
31
34
|
}
|
|
32
35
|
export interface ComboboxStoreState<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Core.ComboboxStoreState<T>, CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
|
|
33
36
|
}
|
|
34
|
-
export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreFunctions<T>, "disclosure">, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
|
|
37
|
+
export interface ComboboxStoreFunctions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Pick<ComboboxStoreOptions<T>, "tag">, Omit<Core.ComboboxStoreFunctions<T>, "tag" | "disclosure">, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
|
|
35
38
|
}
|
|
36
|
-
export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreOptions<T>, "disclosure">, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
|
|
39
|
+
export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends Omit<Core.ComboboxStoreOptions<T>, "tag" | "disclosure">, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
|
|
37
40
|
/**
|
|
38
41
|
* A callback that gets called when the
|
|
39
42
|
* [`value`](https://ariakit.org/reference/combobox-provider#value) state
|
|
@@ -61,8 +64,13 @@ export interface ComboboxStoreOptions<T extends ComboboxStoreSelectedValue = Com
|
|
|
61
64
|
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
62
65
|
*/
|
|
63
66
|
setSelectedValue?: (value: ComboboxStoreState<T>["selectedValue"]) => void;
|
|
67
|
+
/**
|
|
68
|
+
* A reference to a [tag store](https://ariakit.org/apis/use-tag-store). It's
|
|
69
|
+
* automatically set when rendering a combobox within a tag list.
|
|
70
|
+
*/
|
|
71
|
+
tag?: TagStore | null;
|
|
64
72
|
}
|
|
65
|
-
export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, Omit<Core.ComboboxStoreProps<T>, "disclosure"> {
|
|
73
|
+
export interface ComboboxStoreProps<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreOptions<T>, Omit<Core.ComboboxStoreProps<T>, "tag" | "disclosure"> {
|
|
66
74
|
}
|
|
67
|
-
export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Omit<Store<Core.ComboboxStore<T>>, "disclosure"> {
|
|
75
|
+
export interface ComboboxStore<T extends ComboboxStoreSelectedValue = ComboboxStoreSelectedValue> extends ComboboxStoreFunctions<T>, Omit<Store<Core.ComboboxStore<T>>, "tag" | "disclosure"> {
|
|
68
76
|
}
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useComboboxStore,
|
|
4
4
|
useComboboxStoreProps
|
|
5
|
-
} from "../__chunks/
|
|
5
|
+
} from "../__chunks/DLLQM6DZ.js";
|
|
6
|
+
import "../__chunks/WYDDZRWN.js";
|
|
6
7
|
import "../__chunks/ZR5N62ZV.js";
|
|
7
8
|
import "../__chunks/LGWSZOP2.js";
|
|
9
|
+
import "../__chunks/QFI3MCMR.js";
|
|
10
|
+
import "../__chunks/6LTHW2TQ.js";
|
|
11
|
+
import "../__chunks/GUCZNEAD.js";
|
|
8
12
|
import "../__chunks/JNGHG5BN.js";
|
|
9
13
|
import "../__chunks/2KACNUKS.js";
|
|
10
14
|
import "../__chunks/ZIX5D53S.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ComboboxStore, ComboboxStoreState } from "./combobox-store.js";
|
|
3
|
+
/**
|
|
4
|
+
* Renders the current
|
|
5
|
+
* [`value`](https://ariakit.org/reference/use-combobox-store#value) state in
|
|
6
|
+
* the [combobox store](https://ariakit.org/reference/use-combobox-store).
|
|
7
|
+
*
|
|
8
|
+
* As a value component, it doesn't render any DOM elements and therefore
|
|
9
|
+
* doesn't accept HTML props.
|
|
10
|
+
*
|
|
11
|
+
* It takes a
|
|
12
|
+
* [`children`](https://ariakit.org/reference/combobox-value#children) function
|
|
13
|
+
* that gets called with the current value as an argument. This can be used as
|
|
14
|
+
* an uncontrolled API to render the combobox value in a custom way.
|
|
15
|
+
* @see https://ariakit.org/components/combobox
|
|
16
|
+
* @example
|
|
17
|
+
* ```jsx {3-5}
|
|
18
|
+
* <ComboboxProvider>
|
|
19
|
+
* <Combobox />
|
|
20
|
+
* <ComboboxValue>
|
|
21
|
+
* {(value) => `Current value: ${value}`}
|
|
22
|
+
* </ComboboxValue>
|
|
23
|
+
* </ComboboxProvider>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function ComboboxValue({ store, children }?: ComboboxValueProps): ReactNode;
|
|
27
|
+
export interface ComboboxValueProps {
|
|
28
|
+
/**
|
|
29
|
+
* Object returned by the
|
|
30
|
+
* [`useComboboxStore`](https://ariakit.org/reference/use-combobox-store)
|
|
31
|
+
* hook. If not provided, the closest
|
|
32
|
+
* [`ComboboxProvider`](https://ariakit.org/reference/combobox-provider)
|
|
33
|
+
* component's context will be used.
|
|
34
|
+
*/
|
|
35
|
+
store?: ComboboxStore;
|
|
36
|
+
/**
|
|
37
|
+
* A function that gets called with the current value as an argument. It can
|
|
38
|
+
* be used to render the combobox value in a custom way.
|
|
39
|
+
*/
|
|
40
|
+
children?: (value: ComboboxStoreState["value"]) => ReactNode;
|
|
41
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useComboboxContext
|
|
4
|
+
} from "../__chunks/N4X7J4OQ.js";
|
|
5
|
+
import "../__chunks/QFI3MCMR.js";
|
|
6
|
+
import "../__chunks/6LTHW2TQ.js";
|
|
7
|
+
import "../__chunks/5B3U64HV.js";
|
|
8
|
+
import "../__chunks/IWHI6Y45.js";
|
|
9
|
+
import "../__chunks/RG6J4TID.js";
|
|
10
|
+
import "../__chunks/GUCZNEAD.js";
|
|
11
|
+
import "../__chunks/WOWUAP42.js";
|
|
12
|
+
import "../__chunks/XM66DUTO.js";
|
|
13
|
+
import "../__chunks/4R3V3JGP.js";
|
|
14
|
+
|
|
15
|
+
// src/combobox/combobox-value.tsx
|
|
16
|
+
import { invariant } from "@ariakit/core/utils/misc";
|
|
17
|
+
function ComboboxValue({ store, children } = {}) {
|
|
18
|
+
const context = useComboboxContext();
|
|
19
|
+
store = store || context;
|
|
20
|
+
invariant(
|
|
21
|
+
store,
|
|
22
|
+
process.env.NODE_ENV !== "production" && "ComboboxValue must receive a `store` prop or be wrapped in a ComboboxProvider component."
|
|
23
|
+
);
|
|
24
|
+
const value = store.useState("value");
|
|
25
|
+
if (children) {
|
|
26
|
+
return children(value);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
ComboboxValue
|
|
32
|
+
};
|