@ariakit/react-core 0.3.6 → 0.3.8
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 +41 -0
- package/cjs/__chunks/{VEG6PRAG.cjs → 3WCBE6SU.cjs} +3 -1
- package/cjs/__chunks/{45RPYV4J.cjs → EQ4A5RPW.cjs} +2 -2
- package/cjs/__chunks/{CILQPSH2.cjs → FA25CV2I.cjs} +2 -2
- package/cjs/__chunks/{RRW7YVFR.cjs → IPYAEPOT.cjs} +17 -6
- package/cjs/__chunks/{AYDXWQBF.cjs → L3WS5HGI.cjs} +2 -0
- package/cjs/__chunks/{QU2266CJ.cjs → WH4I6OSN.cjs} +12 -4
- package/cjs/__chunks/{LVOI2KVN.cjs → XGKLTARH.cjs} +2 -2
- package/cjs/__chunks/{4GLXDOKG.cjs → YAPOM5RT.cjs} +2 -2
- package/cjs/checkbox/checkbox-provider.cjs +2 -2
- package/cjs/combobox/combobox-cancel.cjs +2 -2
- package/cjs/combobox/combobox-context.cjs +4 -2
- package/cjs/combobox/combobox-context.d.cts +6 -5
- package/cjs/combobox/combobox-context.d.ts +6 -5
- package/cjs/combobox/combobox-disclosure.cjs +2 -2
- package/cjs/combobox/combobox-item-check.cjs +50 -0
- package/cjs/combobox/combobox-item-check.d.cts +60 -0
- package/cjs/combobox/combobox-item-check.d.ts +60 -0
- package/cjs/combobox/combobox-item-value.cjs +3 -3
- package/cjs/combobox/combobox-item.cjs +47 -10
- package/cjs/combobox/combobox-item.d.cts +31 -13
- package/cjs/combobox/combobox-item.d.ts +31 -13
- package/cjs/combobox/combobox-label.cjs +55 -0
- package/cjs/combobox/combobox-label.d.cts +42 -0
- package/cjs/combobox/combobox-label.d.ts +42 -0
- package/cjs/combobox/combobox-list.cjs +3 -3
- package/cjs/combobox/combobox-popover.cjs +7 -7
- package/cjs/combobox/combobox-provider.cjs +4 -4
- package/cjs/combobox/combobox-provider.d.cts +8 -4
- package/cjs/combobox/combobox-provider.d.ts +8 -4
- package/cjs/combobox/combobox-row.cjs +2 -2
- package/cjs/combobox/combobox-separator.cjs +2 -2
- package/cjs/combobox/combobox-store.cjs +2 -2
- package/cjs/combobox/combobox-store.d.cts +28 -9
- package/cjs/combobox/combobox-store.d.ts +28 -9
- package/cjs/combobox/combobox.cjs +28 -14
- package/cjs/combobox/combobox.d.cts +2 -1
- package/cjs/combobox/combobox.d.ts +2 -1
- package/cjs/composite/composite-hover.cjs +2 -2
- package/cjs/composite/composite-hover.d.cts +9 -0
- package/cjs/composite/composite-hover.d.ts +9 -0
- package/cjs/composite/composite-item.d.cts +3 -0
- package/cjs/composite/composite-item.d.ts +3 -0
- package/cjs/composite/composite-overflow.cjs +2 -2
- package/cjs/disclosure/disclosure-content.d.cts +3 -1
- package/cjs/disclosure/disclosure-content.d.ts +3 -1
- package/cjs/disclosure/disclosure.d.cts +3 -0
- package/cjs/disclosure/disclosure.d.ts +3 -0
- package/cjs/focusable/focusable.d.cts +2 -1
- package/cjs/focusable/focusable.d.ts +2 -1
- package/cjs/form/form-checkbox.cjs +1 -1
- package/cjs/hovercard/hovercard-anchor.d.cts +3 -0
- package/cjs/hovercard/hovercard-anchor.d.ts +3 -0
- package/cjs/hovercard/hovercard.cjs +3 -3
- package/cjs/menu/menu-button.cjs +33 -21
- package/cjs/menu/menu-item-checkbox.cjs +4 -4
- package/cjs/menu/menu-item-radio.cjs +3 -3
- package/cjs/menu/menu-item.cjs +3 -3
- package/cjs/menu/menu-provider.cjs +3 -3
- package/cjs/menu/menu-store.cjs +3 -3
- package/cjs/menu/menu-store.d.cts +7 -55
- package/cjs/menu/menu-store.d.ts +7 -55
- package/cjs/menu/menu.cjs +3 -3
- package/cjs/popover/popover.cjs +2 -2
- package/cjs/popover/popover.d.cts +4 -0
- package/cjs/popover/popover.d.ts +4 -0
- package/cjs/portal/portal.d.cts +5 -1
- package/cjs/portal/portal.d.ts +5 -1
- package/cjs/select/select-item.cjs +5 -5
- package/cjs/select/select-label.cjs +1 -1
- package/cjs/select/select-popover.cjs +2 -2
- package/cjs/select/select-provider.cjs +3 -3
- package/cjs/select/select-store.cjs +3 -3
- package/cjs/select/select-store.d.cts +1 -7
- package/cjs/select/select-store.d.ts +1 -7
- package/cjs/tooltip/tooltip.cjs +3 -3
- package/combobox/combobox-item-check/package.json +8 -0
- package/combobox/combobox-label/package.json +8 -0
- package/esm/__chunks/{KFUKDUTY.js → 4AMOOZBQ.js} +10 -2
- package/esm/__chunks/{PHTJ3BCW.js → 7HYEBVZE.js} +1 -1
- package/esm/__chunks/{YGJUONJM.js → BONLQCKO.js} +1 -1
- package/esm/__chunks/{BRO2JF5P.js → G6ONQ5EH.js} +20 -9
- package/esm/__chunks/{W3TC4TID.js → JRUYDVPB.js} +1 -1
- package/esm/__chunks/{NE6JAKK6.js → P3UZS6BC.js} +1 -1
- package/esm/__chunks/{MTC2KUZZ.js → W76OTZCC.js} +3 -1
- package/esm/__chunks/{24AKC2LC.js → ZETMAOTK.js} +2 -0
- package/esm/checkbox/checkbox-provider.js +3 -3
- package/esm/combobox/combobox-cancel.js +1 -1
- package/esm/combobox/combobox-context.d.ts +6 -5
- package/esm/combobox/combobox-context.js +3 -1
- package/esm/combobox/combobox-disclosure.js +1 -1
- package/esm/combobox/combobox-item-check.d.ts +60 -0
- package/esm/combobox/combobox-item-check.js +50 -0
- package/esm/combobox/combobox-item-value.js +1 -1
- package/esm/combobox/combobox-item.d.ts +31 -13
- package/esm/combobox/combobox-item.js +45 -8
- package/esm/combobox/combobox-label.d.ts +42 -0
- package/esm/combobox/combobox-label.js +55 -0
- package/esm/combobox/combobox-list.js +2 -2
- package/esm/combobox/combobox-popover.js +3 -3
- package/esm/combobox/combobox-provider.d.ts +8 -4
- package/esm/combobox/combobox-provider.js +2 -2
- package/esm/combobox/combobox-row.js +1 -1
- package/esm/combobox/combobox-separator.js +1 -1
- package/esm/combobox/combobox-store.d.ts +28 -9
- package/esm/combobox/combobox-store.js +1 -1
- package/esm/combobox/combobox.d.ts +2 -1
- package/esm/combobox/combobox.js +28 -14
- package/esm/composite/composite-hover.d.ts +9 -0
- package/esm/composite/composite-hover.js +1 -1
- package/esm/composite/composite-item.d.ts +3 -0
- package/esm/composite/composite-overflow.js +1 -1
- package/esm/disclosure/disclosure-content.d.ts +3 -1
- package/esm/disclosure/disclosure.d.ts +3 -0
- package/esm/focusable/focusable.d.ts +2 -1
- package/esm/form/form-checkbox.js +1 -1
- package/esm/hovercard/hovercard-anchor.d.ts +3 -0
- package/esm/hovercard/hovercard.js +2 -2
- package/esm/menu/menu-button.js +33 -21
- package/esm/menu/menu-item-checkbox.js +3 -3
- package/esm/menu/menu-item-radio.js +2 -2
- package/esm/menu/menu-item.js +2 -2
- package/esm/menu/menu-provider.js +2 -2
- package/esm/menu/menu-store.d.ts +7 -55
- package/esm/menu/menu-store.js +2 -2
- package/esm/menu/menu.js +2 -2
- package/esm/popover/popover.d.ts +4 -0
- package/esm/popover/popover.js +1 -1
- package/esm/portal/portal.d.ts +5 -1
- package/esm/select/select-item.js +4 -4
- package/esm/select/select-label.js +2 -2
- package/esm/select/select-popover.js +1 -1
- package/esm/select/select-provider.js +2 -2
- package/esm/select/select-store.d.ts +1 -7
- package/esm/select/select-store.js +2 -2
- package/esm/tooltip/tooltip.js +2 -2
- package/package.json +16 -2
- package/cjs/collection/collection-context.d.cts +0 -34
- package/cjs/collection/collection-context.d.ts +0 -34
- package/cjs/composite/utils.d.cts +0 -69
- package/cjs/composite/utils.d.ts +0 -69
- package/cjs/tab/tab-store.d.cts +0 -74
- package/cjs/tab/tab-store.d.ts +0 -74
- package/esm/collection/collection-context.d.ts +0 -34
- package/esm/composite/utils.d.ts +0 -69
- package/esm/tab/tab-store.d.ts +0 -74
- package/cjs/__chunks/{ISGOCBDC.cjs → RIZYIKBE.cjs} +1 -1
- package/esm/__chunks/{KB2HXEVC.js → WBQC3LL4.js} +1 -1
|
@@ -12,9 +12,10 @@ import type { ComboboxStore } from "./combobox-store.js";
|
|
|
12
12
|
* // Use the store...
|
|
13
13
|
* }
|
|
14
14
|
*/
|
|
15
|
-
export declare const useComboboxContext: () => ComboboxStore | undefined;
|
|
16
|
-
export declare const useComboboxScopedContext: (onlyScoped?: boolean) => ComboboxStore | undefined;
|
|
17
|
-
export declare const useComboboxProviderContext: () => ComboboxStore | undefined;
|
|
18
|
-
export declare const ComboboxContextProvider: (props: import("react").ProviderProps<ComboboxStore | undefined>) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export declare const ComboboxScopedContextProvider: (props: import("react").ProviderProps<ComboboxStore | undefined>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const useComboboxContext: () => ComboboxStore<string | string[]> | undefined;
|
|
16
|
+
export declare const useComboboxScopedContext: (onlyScoped?: boolean) => ComboboxStore<string | string[]> | undefined;
|
|
17
|
+
export declare const useComboboxProviderContext: () => ComboboxStore<string | string[]> | undefined;
|
|
18
|
+
export declare const ComboboxContextProvider: (props: import("react").ProviderProps<ComboboxStore<string | string[]> | undefined>) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const ComboboxScopedContextProvider: (props: import("react").ProviderProps<ComboboxStore<string | string[]> | undefined>) => import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export declare const ComboboxItemValueContext: import("react").Context<string | undefined>;
|
|
21
|
+
export declare const ComboboxItemCheckedContext: import("react").Context<boolean>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
ComboboxContextProvider,
|
|
4
|
+
ComboboxItemCheckedContext,
|
|
4
5
|
ComboboxItemValueContext,
|
|
5
6
|
ComboboxScopedContextProvider,
|
|
6
7
|
useComboboxContext,
|
|
7
8
|
useComboboxProviderContext,
|
|
8
9
|
useComboboxScopedContext
|
|
9
|
-
} from "../__chunks/
|
|
10
|
+
} from "../__chunks/W76OTZCC.js";
|
|
10
11
|
import "../__chunks/IB7YUKH5.js";
|
|
11
12
|
import "../__chunks/4UUKJZ4V.js";
|
|
12
13
|
import "../__chunks/7H5KSHHF.js";
|
|
@@ -18,6 +19,7 @@ import "../__chunks/XM66DUTO.js";
|
|
|
18
19
|
import "../__chunks/4R3V3JGP.js";
|
|
19
20
|
export {
|
|
20
21
|
ComboboxContextProvider,
|
|
22
|
+
ComboboxItemCheckedContext,
|
|
21
23
|
ComboboxItemValueContext,
|
|
22
24
|
ComboboxScopedContextProvider,
|
|
23
25
|
useComboboxContext,
|
|
@@ -6,7 +6,7 @@ import "../__chunks/BHEJ6NUH.js";
|
|
|
6
6
|
import "../__chunks/VDNZBO4W.js";
|
|
7
7
|
import {
|
|
8
8
|
useComboboxProviderContext
|
|
9
|
-
} from "../__chunks/
|
|
9
|
+
} from "../__chunks/W76OTZCC.js";
|
|
10
10
|
import "../__chunks/NWCBQ4CV.js";
|
|
11
11
|
import "../__chunks/IB7YUKH5.js";
|
|
12
12
|
import "../__chunks/4UUKJZ4V.js";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CheckboxCheckOptions } from "../checkbox/checkbox-check.jsx";
|
|
2
|
+
import type { As, Props } from "../utils/types.js";
|
|
3
|
+
import type { ComboboxStore } from "./combobox-store.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns props to create a `ComboboxItemCheck` component. This hook must be
|
|
6
|
+
* used in a component that's wrapped with `ComboboxItem` or the `checked` prop
|
|
7
|
+
* must be explicitly passed to the component.
|
|
8
|
+
* @see https://ariakit.org/components/combobox
|
|
9
|
+
* @example
|
|
10
|
+
* ```jsx
|
|
11
|
+
* const props = useComboboxItemCheck({ checked: true });
|
|
12
|
+
* <Role {...props} />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const useComboboxItemCheck: import("../utils/types.js").Hook<ComboboxItemCheckOptions<"span">>;
|
|
16
|
+
/**
|
|
17
|
+
* Renders a checkmark inside a
|
|
18
|
+
* [`ComboboxItem`](https://ariakit.org/reference/combobox-item) component. This
|
|
19
|
+
* component must be wrapped with
|
|
20
|
+
* [`ComboboxItem`](https://ariakit.org/reference/combobox-item) or the
|
|
21
|
+
* [`checked`](https://ariakit.org/reference/combobox-item-check#checked) prop
|
|
22
|
+
* must be explicitly passed to the component.
|
|
23
|
+
* @see https://ariakit.org/components/combobox
|
|
24
|
+
* @example
|
|
25
|
+
* ```jsx {5,9}
|
|
26
|
+
* <ComboboxProvider>
|
|
27
|
+
* <Combobox />
|
|
28
|
+
* <ComboboxPopover>
|
|
29
|
+
* <ComboboxItem value="Apple">
|
|
30
|
+
* <ComboboxItemCheck />
|
|
31
|
+
* Apple
|
|
32
|
+
* </ComboboxItem>
|
|
33
|
+
* <ComboboxItem value="Orange">
|
|
34
|
+
* <ComboboxItemCheck />
|
|
35
|
+
* Orange
|
|
36
|
+
* </ComboboxItem>
|
|
37
|
+
* </ComboboxPopover>
|
|
38
|
+
* </ComboboxProvider>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const ComboboxItemCheck: import("../utils/types.js").Component<ComboboxItemCheckOptions<"span">>;
|
|
42
|
+
export interface ComboboxItemCheckOptions<T extends As = "span"> extends CheckboxCheckOptions<T> {
|
|
43
|
+
/**
|
|
44
|
+
* Object returned by the
|
|
45
|
+
* [`useComboboxStore`](https://ariakit.org/reference/use-combobox-store)
|
|
46
|
+
* hook. If not provided, the parent
|
|
47
|
+
* [`ComboboxList`](https://ariakit.org/reference/combobox-list) or
|
|
48
|
+
* [`ComboboxPopover`](https://ariakit.org/reference/combobox-popover)
|
|
49
|
+
* components' context will be used.
|
|
50
|
+
*/
|
|
51
|
+
store?: ComboboxStore;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the check mark should be shown. This value is automatically
|
|
54
|
+
* inferred from the parent
|
|
55
|
+
* [`ComboboxItem`](https://ariakit.org/reference/combobox-item) component.
|
|
56
|
+
* Manually setting this prop will override the inferred value.
|
|
57
|
+
*/
|
|
58
|
+
checked?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export type ComboboxItemCheckProps<T extends As = "span"> = Props<ComboboxItemCheckOptions<T>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useCheckboxCheck
|
|
4
|
+
} from "../__chunks/MW2F7SEA.js";
|
|
5
|
+
import "../__chunks/6XBVQI3K.js";
|
|
6
|
+
import {
|
|
7
|
+
ComboboxItemCheckedContext
|
|
8
|
+
} from "../__chunks/W76OTZCC.js";
|
|
9
|
+
import "../__chunks/IB7YUKH5.js";
|
|
10
|
+
import "../__chunks/4UUKJZ4V.js";
|
|
11
|
+
import "../__chunks/7H5KSHHF.js";
|
|
12
|
+
import "../__chunks/G6BJYYBK.js";
|
|
13
|
+
import "../__chunks/OAYFXAQ2.js";
|
|
14
|
+
import {
|
|
15
|
+
createComponent,
|
|
16
|
+
createElement,
|
|
17
|
+
createHook
|
|
18
|
+
} from "../__chunks/3ORBWXWF.js";
|
|
19
|
+
import "../__chunks/6O5OEQGF.js";
|
|
20
|
+
import "../__chunks/XM66DUTO.js";
|
|
21
|
+
import {
|
|
22
|
+
__objRest,
|
|
23
|
+
__spreadProps,
|
|
24
|
+
__spreadValues
|
|
25
|
+
} from "../__chunks/4R3V3JGP.js";
|
|
26
|
+
|
|
27
|
+
// src/combobox/combobox-item-check.ts
|
|
28
|
+
import { useContext } from "react";
|
|
29
|
+
var useComboboxItemCheck = createHook(
|
|
30
|
+
(_a) => {
|
|
31
|
+
var _b = _a, { store, checked } = _b, props = __objRest(_b, ["store", "checked"]);
|
|
32
|
+
const context = useContext(ComboboxItemCheckedContext);
|
|
33
|
+
checked = checked != null ? checked : context;
|
|
34
|
+
props = useCheckboxCheck(__spreadProps(__spreadValues({}, props), { checked }));
|
|
35
|
+
return props;
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
var ComboboxItemCheck = createComponent(
|
|
39
|
+
(props) => {
|
|
40
|
+
const htmlProps = useComboboxItemCheck(props);
|
|
41
|
+
return createElement("span", htmlProps);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
if (process.env.NODE_ENV !== "production") {
|
|
45
|
+
ComboboxItemCheck.displayName = "ComboboxItemCheck";
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
ComboboxItemCheck,
|
|
49
|
+
useComboboxItemCheck
|
|
50
|
+
};
|
|
@@ -52,15 +52,15 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
|
|
|
52
52
|
store?: ComboboxStore;
|
|
53
53
|
/**
|
|
54
54
|
* The value of the item. This will be rendered as the children by default.
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
55
|
+
* - If
|
|
56
|
+
* [`setValueOnClick`](https://ariakit.org/reference/combobox-item#setvalueonclick)
|
|
57
|
+
* is set to `true`, this will be the value of the combobox input when the
|
|
58
|
+
* user clicks on this item.
|
|
59
|
+
* - If the
|
|
60
|
+
* [`autoComplete`](https://ariakit.org/reference/combobox#autocomplete)
|
|
61
|
+
* prop on the [`Combobox`](https://ariakit.org/reference/combobox)
|
|
62
|
+
* component is set to `both` or `inline`, this will be the value of the
|
|
63
|
+
* combobox input when the combobox loses focus.
|
|
64
64
|
*
|
|
65
65
|
* Live examples:
|
|
66
66
|
* - [Animated Combobox](https://ariakit.org/examples/combobox-animated)
|
|
@@ -73,18 +73,36 @@ export interface ComboboxItemOptions<T extends As = "div"> extends CompositeItem
|
|
|
73
73
|
*/
|
|
74
74
|
value?: string;
|
|
75
75
|
/**
|
|
76
|
-
* Whether to hide the combobox when this item is clicked.
|
|
76
|
+
* Whether to hide the combobox when this item is clicked. By default, the
|
|
77
|
+
* combobox will be hidden when the user clicks on an item with a
|
|
78
|
+
* [`value`](https://ariakit.org/reference/combobox-item#value) prop, unless
|
|
79
|
+
* the combobox is
|
|
80
|
+
* [multi-selectable](https://ariakit.org/examples/combobox-multiple).
|
|
77
81
|
*
|
|
78
82
|
* Live examples:
|
|
79
83
|
* - [Combobox with links](https://ariakit.org/examples/combobox-links)
|
|
80
|
-
* @default true
|
|
81
84
|
*/
|
|
82
85
|
hideOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
83
86
|
/**
|
|
84
|
-
* Whether to set the
|
|
85
|
-
*
|
|
87
|
+
* Whether to set the
|
|
88
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
89
|
+
* state using this item's
|
|
90
|
+
* [`value`](https://ariakit.org/reference/combobox-item#value) when the item
|
|
91
|
+
* is clicked.
|
|
86
92
|
* @default true
|
|
87
93
|
*/
|
|
94
|
+
selectValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
95
|
+
/**
|
|
96
|
+
* Whether to set the combobox
|
|
97
|
+
* [`value`](https://ariakit.org/reference/combobox-provider#value) state
|
|
98
|
+
* using this item's
|
|
99
|
+
* [`value`](https://ariakit.org/reference/combobox-item#value) when the item
|
|
100
|
+
* is clicked. The default is `true`, unless the combobox is
|
|
101
|
+
* [multi-selectable](https://ariakit.org/examples/combobox-multiple).
|
|
102
|
+
*
|
|
103
|
+
* Live examples:
|
|
104
|
+
* - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
|
|
105
|
+
*/
|
|
88
106
|
setValueOnClick?: BooleanOrCallback<MouseEvent<HTMLElement>>;
|
|
89
107
|
/**
|
|
90
108
|
* @default false
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useCompositeHover
|
|
4
|
-
} from "../__chunks/
|
|
4
|
+
} from "../__chunks/G6ONQ5EH.js";
|
|
5
5
|
import {
|
|
6
|
+
ComboboxItemCheckedContext,
|
|
6
7
|
ComboboxItemValueContext,
|
|
7
8
|
useComboboxScopedContext
|
|
8
|
-
} from "../__chunks/
|
|
9
|
+
} from "../__chunks/W76OTZCC.js";
|
|
9
10
|
import {
|
|
10
11
|
useCompositeItem
|
|
11
12
|
} from "../__chunks/5PEPOQU7.js";
|
|
@@ -44,13 +45,24 @@ import { isDownloading, isOpeningInNewTab } from "@ariakit/core/utils/events";
|
|
|
44
45
|
import { hasFocus } from "@ariakit/core/utils/focus";
|
|
45
46
|
import { invariant } from "@ariakit/core/utils/misc";
|
|
46
47
|
import { jsx } from "react/jsx-runtime";
|
|
48
|
+
function isSelected(storeValue, itemValue) {
|
|
49
|
+
if (itemValue == null)
|
|
50
|
+
return;
|
|
51
|
+
if (storeValue == null)
|
|
52
|
+
return false;
|
|
53
|
+
if (Array.isArray(storeValue)) {
|
|
54
|
+
return storeValue.includes(itemValue);
|
|
55
|
+
}
|
|
56
|
+
return storeValue === itemValue;
|
|
57
|
+
}
|
|
47
58
|
var useComboboxItem = createHook(
|
|
48
59
|
(_a) => {
|
|
49
60
|
var _b = _a, {
|
|
50
61
|
store,
|
|
51
62
|
value,
|
|
52
|
-
hideOnClick
|
|
53
|
-
|
|
63
|
+
hideOnClick,
|
|
64
|
+
selectValueOnClick = true,
|
|
65
|
+
setValueOnClick,
|
|
54
66
|
focusOnHover = false,
|
|
55
67
|
moveOnKeyPress = true,
|
|
56
68
|
getItem: getItemProp
|
|
@@ -58,6 +70,7 @@ var useComboboxItem = createHook(
|
|
|
58
70
|
"store",
|
|
59
71
|
"value",
|
|
60
72
|
"hideOnClick",
|
|
73
|
+
"selectValueOnClick",
|
|
61
74
|
"setValueOnClick",
|
|
62
75
|
"focusOnHover",
|
|
63
76
|
"moveOnKeyPress",
|
|
@@ -79,8 +92,14 @@ var useComboboxItem = createHook(
|
|
|
79
92
|
},
|
|
80
93
|
[value, getItemProp]
|
|
81
94
|
);
|
|
95
|
+
const multiSelectable = store.useState(
|
|
96
|
+
(state) => Array.isArray(state.selectedValue)
|
|
97
|
+
);
|
|
98
|
+
setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
|
|
99
|
+
hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
|
|
82
100
|
const onClickProp = props.onClick;
|
|
83
101
|
const setValueOnClickProp = useBooleanEvent(setValueOnClick);
|
|
102
|
+
const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
|
|
84
103
|
const hideOnClickProp = useBooleanEvent(hideOnClick);
|
|
85
104
|
const onClick = useEvent((event) => {
|
|
86
105
|
onClickProp == null ? void 0 : onClickProp(event);
|
|
@@ -90,8 +109,20 @@ var useComboboxItem = createHook(
|
|
|
90
109
|
return;
|
|
91
110
|
if (isOpeningInNewTab(event))
|
|
92
111
|
return;
|
|
93
|
-
if (value != null
|
|
94
|
-
|
|
112
|
+
if (value != null) {
|
|
113
|
+
if (selectValueOnClickProp(event)) {
|
|
114
|
+
store == null ? void 0 : store.setSelectedValue((prevValue) => {
|
|
115
|
+
if (!Array.isArray(prevValue))
|
|
116
|
+
return value;
|
|
117
|
+
if (prevValue.includes(value)) {
|
|
118
|
+
return prevValue.filter((v) => v !== value);
|
|
119
|
+
}
|
|
120
|
+
return [...prevValue, value];
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (setValueOnClickProp(event)) {
|
|
124
|
+
store == null ? void 0 : store.setValue(value);
|
|
125
|
+
}
|
|
95
126
|
}
|
|
96
127
|
if (hideOnClickProp(event)) {
|
|
97
128
|
store == null ? void 0 : store.move(null);
|
|
@@ -116,10 +147,16 @@ var useComboboxItem = createHook(
|
|
|
116
147
|
}
|
|
117
148
|
}
|
|
118
149
|
});
|
|
150
|
+
const selected = store.useState(
|
|
151
|
+
(state) => isSelected(state.selectedValue, value)
|
|
152
|
+
);
|
|
153
|
+
if (multiSelectable && selected != null) {
|
|
154
|
+
props["aria-selected"] = selected;
|
|
155
|
+
}
|
|
119
156
|
props = useWrapElement(
|
|
120
157
|
props,
|
|
121
|
-
(element) => /* @__PURE__ */ jsx(ComboboxItemValueContext.Provider, { value, children: element }),
|
|
122
|
-
[value]
|
|
158
|
+
(element) => /* @__PURE__ */ jsx(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ jsx(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
|
|
159
|
+
[value, selected]
|
|
123
160
|
);
|
|
124
161
|
const contentElement = store.useState("contentElement");
|
|
125
162
|
props = __spreadProps(__spreadValues({
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { As, Options, Props } from "../utils/types.js";
|
|
2
|
+
import type { ComboboxStore } from "./combobox-store.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns props to create a `ComboboxLabel` component.
|
|
5
|
+
* @see https://ariakit.org/components/combobox
|
|
6
|
+
* @example
|
|
7
|
+
* ```jsx
|
|
8
|
+
* const store = useComboboxStore();
|
|
9
|
+
* const props = useComboboxLabel({ store });
|
|
10
|
+
* <Role {...props}>Favorite fruit</Role>
|
|
11
|
+
* <Combobox store={store} />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const useComboboxLabel: import("../utils/types.js").Hook<ComboboxLabelOptions<"label">>;
|
|
15
|
+
/**
|
|
16
|
+
* Renders a label for the [`Combobox`](https://ariakit.org/reference/combobox)
|
|
17
|
+
* component.
|
|
18
|
+
* @see https://ariakit.org/components/combobox
|
|
19
|
+
* @example
|
|
20
|
+
* ```jsx {2}
|
|
21
|
+
* <ComboboxProvider>
|
|
22
|
+
* <ComboboxLabel>Favorite fruit</ComboboxLabel>
|
|
23
|
+
* <Combobox />
|
|
24
|
+
* <ComboboxPopover>
|
|
25
|
+
* <ComboboxItem value="Apple" />
|
|
26
|
+
* <ComboboxItem value="Orange" />
|
|
27
|
+
* </ComboboxPopover>
|
|
28
|
+
* </ComboboxProvider>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const ComboboxLabel: import("../utils/types.js").Component<ComboboxLabelOptions<"label">>;
|
|
32
|
+
export interface ComboboxLabelOptions<T extends As = "label"> extends Options<T> {
|
|
33
|
+
/**
|
|
34
|
+
* Object returned by the
|
|
35
|
+
* [`useComboboxStore`](https://ariakit.org/reference/use-combobox-store)
|
|
36
|
+
* hook. If not provided, the closest
|
|
37
|
+
* [`ComboboxProvider`](https://ariakit.org/reference/combobox-provider)
|
|
38
|
+
* component's context will be used.
|
|
39
|
+
*/
|
|
40
|
+
store?: ComboboxStore;
|
|
41
|
+
}
|
|
42
|
+
export type ComboboxLabelProps<T extends As = "label"> = Props<ComboboxLabelOptions<T>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useComboboxProviderContext
|
|
4
|
+
} from "../__chunks/W76OTZCC.js";
|
|
5
|
+
import "../__chunks/IB7YUKH5.js";
|
|
6
|
+
import "../__chunks/4UUKJZ4V.js";
|
|
7
|
+
import "../__chunks/7H5KSHHF.js";
|
|
8
|
+
import "../__chunks/G6BJYYBK.js";
|
|
9
|
+
import "../__chunks/OAYFXAQ2.js";
|
|
10
|
+
import {
|
|
11
|
+
createElement,
|
|
12
|
+
createHook,
|
|
13
|
+
createMemoComponent
|
|
14
|
+
} from "../__chunks/3ORBWXWF.js";
|
|
15
|
+
import "../__chunks/6O5OEQGF.js";
|
|
16
|
+
import "../__chunks/XM66DUTO.js";
|
|
17
|
+
import {
|
|
18
|
+
__objRest,
|
|
19
|
+
__spreadValues
|
|
20
|
+
} from "../__chunks/4R3V3JGP.js";
|
|
21
|
+
|
|
22
|
+
// src/combobox/combobox-label.ts
|
|
23
|
+
import { invariant } from "@ariakit/core/utils/misc";
|
|
24
|
+
var useComboboxLabel = createHook(
|
|
25
|
+
(_a) => {
|
|
26
|
+
var _b = _a, { store } = _b, props = __objRest(_b, ["store"]);
|
|
27
|
+
const context = useComboboxProviderContext();
|
|
28
|
+
store = store || context;
|
|
29
|
+
invariant(
|
|
30
|
+
store,
|
|
31
|
+
process.env.NODE_ENV !== "production" && "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
|
|
32
|
+
);
|
|
33
|
+
const comboboxId = store.useState((state) => {
|
|
34
|
+
var _a2;
|
|
35
|
+
return (_a2 = state.baseElement) == null ? void 0 : _a2.id;
|
|
36
|
+
});
|
|
37
|
+
props = __spreadValues({
|
|
38
|
+
htmlFor: comboboxId
|
|
39
|
+
}, props);
|
|
40
|
+
return props;
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
var ComboboxLabel = createMemoComponent(
|
|
44
|
+
(props) => {
|
|
45
|
+
const htmlProps = useComboboxLabel(props);
|
|
46
|
+
return createElement("label", htmlProps);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
if (process.env.NODE_ENV !== "production") {
|
|
50
|
+
ComboboxLabel.displayName = "ComboboxLabel";
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
ComboboxLabel,
|
|
54
|
+
useComboboxLabel
|
|
55
|
+
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ComboboxList,
|
|
4
4
|
useComboboxList
|
|
5
|
-
} from "../__chunks/
|
|
6
|
-
import "../__chunks/
|
|
5
|
+
} from "../__chunks/4AMOOZBQ.js";
|
|
6
|
+
import "../__chunks/W76OTZCC.js";
|
|
7
7
|
import "../__chunks/IB7YUKH5.js";
|
|
8
8
|
import "../__chunks/4UUKJZ4V.js";
|
|
9
9
|
import "../__chunks/A7CE3X6M.js";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useComboboxList
|
|
4
|
-
} from "../__chunks/
|
|
4
|
+
} from "../__chunks/4AMOOZBQ.js";
|
|
5
5
|
import {
|
|
6
6
|
useComboboxProviderContext
|
|
7
|
-
} from "../__chunks/
|
|
7
|
+
} from "../__chunks/W76OTZCC.js";
|
|
8
8
|
import "../__chunks/IB7YUKH5.js";
|
|
9
9
|
import "../__chunks/4UUKJZ4V.js";
|
|
10
10
|
import {
|
|
11
11
|
usePopover
|
|
12
|
-
} from "../__chunks/
|
|
12
|
+
} from "../__chunks/WBQC3LL4.js";
|
|
13
13
|
import {
|
|
14
14
|
createDialogComponent
|
|
15
15
|
} from "../__chunks/U7WGY7YX.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import type {
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { PickRequired } from "@ariakit/core/utils/types";
|
|
3
|
+
import type { ComboboxStoreProps, ComboboxStoreSelectedValue } from "./combobox-store.js";
|
|
4
|
+
type Value = ComboboxStoreSelectedValue;
|
|
3
5
|
/**
|
|
4
6
|
* Provides a combobox store to Combobox components.
|
|
5
7
|
* @see https://ariakit.org/components/combobox
|
|
@@ -15,7 +17,9 @@ import type { ComboboxStoreProps } from "./combobox-store.js";
|
|
|
15
17
|
* </ComboboxProvider>
|
|
16
18
|
* ```
|
|
17
19
|
*/
|
|
18
|
-
export declare function ComboboxProvider(props
|
|
19
|
-
export
|
|
20
|
+
export declare function ComboboxProvider<T extends Value = Value>(props: PickRequired<ComboboxProviderProps<T>, "selectedValue" | "defaultSelectedValue">): ReactElement;
|
|
21
|
+
export declare function ComboboxProvider(props?: ComboboxProviderProps): ReactElement;
|
|
22
|
+
export interface ComboboxProviderProps<T extends Value = Value> extends ComboboxStoreProps<T> {
|
|
20
23
|
children?: ReactNode;
|
|
21
24
|
}
|
|
25
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useComboboxStore
|
|
4
|
-
} from "../__chunks/
|
|
4
|
+
} from "../__chunks/ZETMAOTK.js";
|
|
5
5
|
import {
|
|
6
6
|
ComboboxContextProvider
|
|
7
|
-
} from "../__chunks/
|
|
7
|
+
} from "../__chunks/W76OTZCC.js";
|
|
8
8
|
import "../__chunks/ELWRSPQ7.js";
|
|
9
9
|
import "../__chunks/5A2VZUUV.js";
|
|
10
10
|
import "../__chunks/IB7YUKH5.js";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as Core from "@ariakit/core/combobox/combobox-store";
|
|
2
|
+
import type { PickRequired } from "@ariakit/core/utils/types";
|
|
2
3
|
import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
3
4
|
import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
|
|
4
5
|
import type { Store } from "../utils/store.js";
|
|
6
|
+
type Value = Core.ComboboxStoreSelectedValue;
|
|
5
7
|
export declare function useComboboxStoreProps<T extends Core.ComboboxStore>(store: T, update: () => void, props: ComboboxStoreProps): T;
|
|
6
8
|
/**
|
|
7
9
|
* Creates a combobox store.
|
|
@@ -17,27 +19,44 @@ export declare function useComboboxStoreProps<T extends Core.ComboboxStore>(stor
|
|
|
17
19
|
* </ComboboxPopover>
|
|
18
20
|
* ```
|
|
19
21
|
*/
|
|
22
|
+
export declare function useComboboxStore<T extends Value = Value>(props: PickRequired<ComboboxStoreProps<T>, "selectedValue" | "defaultSelectedValue">): ComboboxStore<T>;
|
|
20
23
|
export declare function useComboboxStore(props?: ComboboxStoreProps): ComboboxStore;
|
|
21
24
|
export type ComboboxStoreItem = Core.ComboboxStoreItem;
|
|
22
|
-
export
|
|
25
|
+
export type ComboboxStoreSelectedValue = Core.ComboboxStoreSelectedValue;
|
|
26
|
+
export interface ComboboxStoreState<T extends Value = Value> extends Core.ComboboxStoreState<T>, CompositeStoreState<ComboboxStoreItem>, PopoverStoreState {
|
|
23
27
|
}
|
|
24
|
-
export interface ComboboxStoreFunctions extends Core.ComboboxStoreFunctions
|
|
28
|
+
export interface ComboboxStoreFunctions<T extends Value = Value> extends Core.ComboboxStoreFunctions<T>, CompositeStoreFunctions<ComboboxStoreItem>, PopoverStoreFunctions {
|
|
25
29
|
}
|
|
26
|
-
export interface ComboboxStoreOptions extends Core.ComboboxStoreOptions
|
|
30
|
+
export interface ComboboxStoreOptions<T extends Value = Value> extends Core.ComboboxStoreOptions<T>, CompositeStoreOptions<ComboboxStoreItem>, PopoverStoreOptions {
|
|
27
31
|
/**
|
|
28
|
-
* A callback that gets called when the
|
|
32
|
+
* A callback that gets called when the
|
|
33
|
+
* [`value`](https://ariakit.org/reference/combobox-provider#value) state
|
|
34
|
+
* changes.
|
|
29
35
|
*
|
|
30
36
|
* Live examples:
|
|
31
|
-
* - [Combobox
|
|
37
|
+
* - [Combobox with integrated
|
|
38
|
+
* filter](https://ariakit.org/examples/combobox-filtering-integrated)
|
|
32
39
|
* - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
|
|
33
40
|
* - [Combobox with links](https://ariakit.org/examples/combobox-links)
|
|
34
41
|
* - [Multi-selectable
|
|
35
42
|
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
36
43
|
* - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
|
|
37
44
|
* - [Select with Combobox](https://ariakit.org/examples/select-combobox)
|
|
38
|
-
* @param value The new value.
|
|
39
45
|
*/
|
|
40
|
-
setValue?: (value: ComboboxStoreState["value"]) => void;
|
|
46
|
+
setValue?: (value: ComboboxStoreState<T>["value"]) => void;
|
|
47
|
+
/**
|
|
48
|
+
* A callback that gets called when the
|
|
49
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
50
|
+
* state changes.
|
|
51
|
+
*
|
|
52
|
+
* Live examples:
|
|
53
|
+
* - [Multi-selectable
|
|
54
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
55
|
+
*/
|
|
56
|
+
setSelectedValue?: (value: ComboboxStoreState<T>["selectedValue"]) => void;
|
|
57
|
+
}
|
|
58
|
+
export interface ComboboxStoreProps<T extends Value = Value> extends ComboboxStoreOptions<T>, Core.ComboboxStoreProps<T> {
|
|
59
|
+
}
|
|
60
|
+
export interface ComboboxStore<T extends Value = Value> extends ComboboxStoreFunctions<T>, Store<Core.ComboboxStore<T>> {
|
|
41
61
|
}
|
|
42
|
-
export
|
|
43
|
-
export type ComboboxStore = ComboboxStoreFunctions & Store<Core.ComboboxStore>;
|
|
62
|
+
export {};
|
|
@@ -59,7 +59,8 @@ export interface ComboboxOptions<T extends As = "input"> extends CompositeOption
|
|
|
59
59
|
* popup opens, but the input value doesn't change.
|
|
60
60
|
*
|
|
61
61
|
* Live examples:
|
|
62
|
-
* - [
|
|
62
|
+
* - [Combobox with integrated
|
|
63
|
+
* filter](https://ariakit.org/examples/combobox-filtering-integrated)
|
|
63
64
|
* - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
|
|
64
65
|
* - [Combobox with links](https://ariakit.org/examples/combobox-links)
|
|
65
66
|
* - [Textarea with inline
|