@ariakit/react-core 0.4.2 → 0.4.4
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 +52 -0
- package/cjs/__chunks/{2ZW7KXDM.cjs → 4XVTH6OR.cjs} +2 -2
- package/cjs/__chunks/{33HTKI7L.cjs → 54YZYOPA.cjs} +2 -2
- package/cjs/__chunks/{DCTXNU2X.cjs → COWKMNMZ.cjs} +3 -3
- package/cjs/__chunks/{HFNM6QV4.cjs → DAOFDKV2.cjs} +1 -1
- package/cjs/__chunks/{3C4RFBCG.cjs → EYZZO5IT.cjs} +1 -1
- package/cjs/__chunks/{3MKOUH5M.cjs → HPNCFYQJ.cjs} +4 -4
- 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/{LEU3BIGC.cjs → QUHFOHHT.cjs} +36 -3
- package/cjs/__chunks/{OGH323OW.cjs → YO7LLGVA.cjs} +2 -2
- package/cjs/__chunks/{RKBJS357.cjs → YOQXFS4U.cjs} +11 -6
- package/cjs/__chunks/{3XXW4Y4D.cjs → Z2VL7JHX.cjs} +2 -2
- package/cjs/__chunks/{CWS5RZSU.cjs → ZTAE5B6W.cjs} +9 -1
- package/cjs/checkbox/checkbox-check.cjs +2 -2
- package/cjs/collection/collection-renderer.d.cts +3 -3
- package/cjs/collection/collection-renderer.d.ts +3 -3
- package/cjs/combobox/combobox-cancel.cjs +2 -2
- package/cjs/combobox/combobox-disclosure.cjs +2 -2
- package/cjs/combobox/combobox-item-check.cjs +2 -2
- package/cjs/combobox/combobox-item.cjs +4 -4
- package/cjs/combobox/combobox-popover.cjs +23 -5
- package/cjs/combobox/combobox-row.cjs +2 -2
- package/cjs/combobox/combobox.cjs +14 -11
- 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 +2 -2
- package/cjs/composite/composite-overflow-disclosure.cjs +2 -2
- package/cjs/composite/composite-overflow.cjs +3 -3
- package/cjs/composite/composite-renderer.d.cts +3 -3
- package/cjs/composite/composite-renderer.d.ts +3 -3
- package/cjs/dialog/dialog-dismiss.cjs +2 -2
- package/cjs/dialog/dialog.cjs +2 -2
- package/cjs/form/form-radio.cjs +3 -3
- package/cjs/hovercard/hovercard-disclosure.cjs +1 -1
- package/cjs/hovercard/hovercard-dismiss.cjs +4 -4
- package/cjs/hovercard/hovercard.cjs +4 -4
- 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 +3 -3
- package/cjs/menu/menu-item-radio.cjs +5 -5
- package/cjs/menu/menu-item.cjs +3 -3
- package/cjs/menu/menu.cjs +5 -5
- package/cjs/popover/popover-disclosure-arrow.cjs +2 -2
- package/cjs/popover/popover-dismiss.cjs +3 -3
- package/cjs/popover/popover.cjs +3 -3
- package/cjs/radio/radio.cjs +3 -3
- 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 +4 -4
- package/cjs/select/select.cjs +4 -4
- package/cjs/tab/tab-panel.cjs +3 -13
- package/cjs/tab/tab-provider.cjs +7 -2
- package/cjs/tab/tab-store.cjs +7 -2
- package/cjs/tab/tab-store.d.cts +22 -7
- package/cjs/tab/tab-store.d.ts +22 -7
- package/cjs/tab/tab.cjs +12 -9
- package/cjs/toolbar/toolbar-container.cjs +3 -3
- package/cjs/toolbar/toolbar-input.cjs +3 -7
- package/cjs/toolbar/toolbar-input.d.cts +3 -2
- package/cjs/toolbar/toolbar-input.d.ts +3 -2
- package/cjs/toolbar/toolbar-item.cjs +3 -3
- package/cjs/tooltip/tooltip.cjs +5 -5
- package/cjs/utils/misc.d.cts +5 -3
- package/cjs/utils/misc.d.ts +5 -3
- package/cjs/utils/types.d.cts +3 -1
- package/cjs/utils/types.d.ts +3 -1
- package/esm/__chunks/{LABIXQLW.js → 44PDY2W5.js} +1 -1
- package/esm/__chunks/{FYNSL2D5.js → 5H3YXAUC.js} +1 -1
- package/esm/__chunks/{DGR3GYOB.js → APFOINTZ.js} +12 -7
- package/esm/__chunks/{JCOBPKEI.js → BY6P32UK.js} +1 -1
- package/esm/__chunks/{QDVOJENT.js → DSUHLHLE.js} +1 -1
- package/esm/__chunks/{NN4HLGKS.js → F2RFUFO2.js} +1 -1
- package/esm/__chunks/{2VWKZYYT.js → H5N72W37.js} +1 -1
- package/esm/__chunks/{NQ4PTILT.js → IOUGWXY5.js} +9 -1
- package/esm/__chunks/{X3V2DT2U.js → LTYEFENI.js} +1 -1
- package/esm/__chunks/{H4YBNKTY.js → NFPDVAAW.js} +1 -1
- package/esm/__chunks/{DCFMDHRW.js → NHVUMSP7.js} +1 -1
- package/esm/__chunks/{RAKW656I.js → Q4PZFBSW.js} +1 -1
- package/esm/__chunks/{VGL3CETR.js → R33ISPJY.js} +37 -4
- package/esm/__chunks/{6VDNHSLX.js → XEJ23EM6.js} +2 -2
- package/esm/checkbox/checkbox-check.js +1 -1
- package/esm/collection/collection-renderer.d.ts +3 -3
- package/esm/combobox/combobox-cancel.js +2 -2
- package/esm/combobox/combobox-disclosure.js +2 -2
- package/esm/combobox/combobox-item-check.js +1 -1
- package/esm/combobox/combobox-item.js +4 -4
- package/esm/combobox/combobox-popover.js +22 -4
- package/esm/combobox/combobox-row.js +3 -3
- package/esm/combobox/combobox.d.ts +20 -0
- package/esm/combobox/combobox.js +14 -11
- package/esm/composite/composite-input.d.ts +2 -0
- package/esm/composite/composite-input.js +92 -7
- package/esm/composite/composite-item.js +1 -1
- package/esm/composite/composite-overflow-disclosure.js +1 -1
- package/esm/composite/composite-overflow.js +2 -2
- package/esm/composite/composite-renderer.d.ts +3 -3
- package/esm/dialog/dialog-dismiss.js +1 -1
- package/esm/dialog/dialog.js +1 -1
- package/esm/form/form-radio.js +2 -2
- package/esm/hovercard/hovercard-disclosure.js +1 -1
- package/esm/hovercard/hovercard-dismiss.js +3 -3
- package/esm/hovercard/hovercard.js +3 -3
- 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 +2 -2
- package/esm/menu/menu-item-radio.js +3 -3
- package/esm/menu/menu-item.js +2 -2
- package/esm/menu/menu.js +3 -3
- package/esm/popover/popover-disclosure-arrow.js +1 -1
- package/esm/popover/popover-dismiss.js +2 -2
- package/esm/popover/popover.js +2 -2
- package/esm/radio/radio.js +2 -2
- 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 +2 -2
- package/esm/select/select.js +3 -3
- package/esm/tab/tab-panel.js +4 -14
- package/esm/tab/tab-provider.js +6 -1
- package/esm/tab/tab-store.d.ts +22 -7
- package/esm/tab/tab-store.js +6 -1
- package/esm/tab/tab.js +10 -7
- package/esm/toolbar/toolbar-container.js +2 -2
- package/esm/toolbar/toolbar-input.d.ts +3 -2
- package/esm/toolbar/toolbar-input.js +2 -6
- package/esm/toolbar/toolbar-item.js +2 -2
- package/esm/tooltip/tooltip.js +3 -3
- package/esm/utils/misc.d.ts +5 -3
- package/esm/utils/types.d.ts +3 -1
- package/package.json +2 -2
- package/cjs/__chunks/WGZQRLXV.cjs +0 -84
- package/esm/__chunks/RPGNBKKU.js +0 -84
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ElementType } from "react";
|
|
2
|
-
import type { CompositeInputOptions } from "../composite/composite-input.js";
|
|
3
2
|
import type { Props } from "../utils/types.js";
|
|
4
3
|
import type { ToolbarItemOptions } from "./toolbar-item.js";
|
|
5
4
|
declare const TagName = "input";
|
|
@@ -7,6 +6,7 @@ type TagName = typeof TagName;
|
|
|
7
6
|
/**
|
|
8
7
|
* Returns props to create a `ToolbarInput` component.
|
|
9
8
|
* @see https://ariakit.org/components/toolbar
|
|
9
|
+
* @deprecated Use `useToolbarItem` instead.
|
|
10
10
|
* @example
|
|
11
11
|
* ```jsx
|
|
12
12
|
* const store = useToolbarStore();
|
|
@@ -21,6 +21,7 @@ export declare const useToolbarInput: import("../utils/types.js").Hook<"input",
|
|
|
21
21
|
* Renders a text input as a toolbar item, maintaining arrow key navigation on
|
|
22
22
|
* the toolbar.
|
|
23
23
|
* @see https://ariakit.org/components/toolbar
|
|
24
|
+
* @deprecated Use `<ToolbarItem render={<input />}>` instead.
|
|
24
25
|
* @example
|
|
25
26
|
* ```jsx {2}
|
|
26
27
|
* <Toolbar>
|
|
@@ -29,7 +30,7 @@ export declare const useToolbarInput: import("../utils/types.js").Hook<"input",
|
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
32
|
export declare const ToolbarInput: (props: ToolbarInputProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
32
|
-
export interface ToolbarInputOptions<T extends ElementType = TagName> extends ToolbarItemOptions<T
|
|
33
|
+
export interface ToolbarInputOptions<T extends ElementType = TagName> extends ToolbarItemOptions<T> {
|
|
33
34
|
}
|
|
34
35
|
export type ToolbarInputProps<T extends ElementType = TagName> = Props<T, ToolbarInputOptions<T>>;
|
|
35
36
|
export {};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('../__chunks/
|
|
5
|
+
var _YO7LLGVAcjs = require('../__chunks/YO7LLGVA.cjs');
|
|
6
|
+
require('../__chunks/QUHFOHHT.cjs');
|
|
7
7
|
require('../__chunks/U4NXCMZ3.cjs');
|
|
8
8
|
require('../__chunks/HD5AHCRI.cjs');
|
|
9
9
|
require('../__chunks/6ZZYUFPW.cjs');
|
|
@@ -20,4 +20,4 @@ require('../__chunks/AV6KTKLE.cjs');
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
exports.ToolbarItem =
|
|
23
|
+
exports.ToolbarItem = _YO7LLGVAcjs.ToolbarItem; exports.useToolbarItem = _YO7LLGVAcjs.useToolbarItem;
|
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 _HPNCFYQJcjs = require('../__chunks/HPNCFYQJ.cjs');
|
|
5
5
|
require('../__chunks/KXQOQQ5B.cjs');
|
|
6
|
-
require('../__chunks/
|
|
6
|
+
require('../__chunks/COWKMNMZ.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _ZTAE5B6Wcjs = require('../__chunks/ZTAE5B6W.cjs');
|
|
10
10
|
require('../__chunks/TSEXNK3K.cjs');
|
|
11
11
|
require('../__chunks/JF225FQ5.cjs');
|
|
12
12
|
require('../__chunks/37BRXQN7.cjs');
|
|
@@ -95,7 +95,7 @@ var useTooltip = _NGD3IQDBcjs.createHook.call(void 0,
|
|
|
95
95
|
(state) => state.type === "description" ? "tooltip" : "none"
|
|
96
96
|
);
|
|
97
97
|
props = _AV6KTKLEcjs.__spreadValues.call(void 0, { role }, props);
|
|
98
|
-
props =
|
|
98
|
+
props = _HPNCFYQJcjs.useHovercard.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
99
99
|
store,
|
|
100
100
|
portal,
|
|
101
101
|
gutter,
|
|
@@ -124,7 +124,7 @@ var useTooltip = _NGD3IQDBcjs.createHook.call(void 0,
|
|
|
124
124
|
return props;
|
|
125
125
|
}
|
|
126
126
|
);
|
|
127
|
-
var Tooltip =
|
|
127
|
+
var Tooltip = _ZTAE5B6Wcjs.createDialogComponent.call(void 0,
|
|
128
128
|
_NGD3IQDBcjs.forwardRef.call(void 0, function Tooltip2(props) {
|
|
129
129
|
const htmlProps = useTooltip(props);
|
|
130
130
|
return _NGD3IQDBcjs.createElement.call(void 0, TagName, htmlProps);
|
package/cjs/utils/misc.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, MutableRefObject, ReactElement,
|
|
1
|
+
import type { HTMLAttributes, MutableRefObject, ReactElement, Ref, RefCallback } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Sets both a function and object React ref.
|
|
4
4
|
*/
|
|
@@ -6,11 +6,13 @@ export declare function setRef<T>(ref: RefCallback<T> | MutableRefObject<T> | nu
|
|
|
6
6
|
/**
|
|
7
7
|
* Checks if an element is a valid React element with a ref.
|
|
8
8
|
*/
|
|
9
|
-
export declare function isValidElementWithRef<P>(element: unknown): element is ReactElement<P> &
|
|
9
|
+
export declare function isValidElementWithRef<P>(element: unknown): element is ReactElement<P> & {
|
|
10
|
+
ref?: Ref<any>;
|
|
11
|
+
};
|
|
10
12
|
/**
|
|
11
13
|
* Gets the ref property from a React element.
|
|
12
14
|
*/
|
|
13
|
-
export declare function getRefProperty(element: unknown):
|
|
15
|
+
export declare function getRefProperty(element: unknown): Ref<any> | undefined;
|
|
14
16
|
/**
|
|
15
17
|
* Merges two sets of props.
|
|
16
18
|
*/
|
package/cjs/utils/misc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, MutableRefObject, ReactElement,
|
|
1
|
+
import type { HTMLAttributes, MutableRefObject, ReactElement, Ref, RefCallback } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Sets both a function and object React ref.
|
|
4
4
|
*/
|
|
@@ -6,11 +6,13 @@ export declare function setRef<T>(ref: RefCallback<T> | MutableRefObject<T> | nu
|
|
|
6
6
|
/**
|
|
7
7
|
* Checks if an element is a valid React element with a ref.
|
|
8
8
|
*/
|
|
9
|
-
export declare function isValidElementWithRef<P>(element: unknown): element is ReactElement<P> &
|
|
9
|
+
export declare function isValidElementWithRef<P>(element: unknown): element is ReactElement<P> & {
|
|
10
|
+
ref?: Ref<any>;
|
|
11
|
+
};
|
|
10
12
|
/**
|
|
11
13
|
* Gets the ref property from a React element.
|
|
12
14
|
*/
|
|
13
|
-
export declare function getRefProperty(element: unknown):
|
|
15
|
+
export declare function getRefProperty(element: unknown): Ref<any> | undefined;
|
|
14
16
|
/**
|
|
15
17
|
* Merges two sets of props.
|
|
16
18
|
*/
|
package/cjs/utils/types.d.cts
CHANGED
|
@@ -6,7 +6,9 @@ import type { AnyObject, EmptyObject } from "@ariakit/core/utils/types";
|
|
|
6
6
|
* @example
|
|
7
7
|
* const children: RenderProp = (props) => <div {...props} />;
|
|
8
8
|
*/
|
|
9
|
-
export type RenderProp<P = React.HTMLAttributes<any> &
|
|
9
|
+
export type RenderProp<P = React.HTMLAttributes<any> & {
|
|
10
|
+
ref?: React.Ref<any>;
|
|
11
|
+
}> = (props: P) => React.ReactNode;
|
|
10
12
|
/**
|
|
11
13
|
* The `wrapElement` prop.
|
|
12
14
|
*/
|
package/cjs/utils/types.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import type { AnyObject, EmptyObject } from "@ariakit/core/utils/types";
|
|
|
6
6
|
* @example
|
|
7
7
|
* const children: RenderProp = (props) => <div {...props} />;
|
|
8
8
|
*/
|
|
9
|
-
export type RenderProp<P = React.HTMLAttributes<any> &
|
|
9
|
+
export type RenderProp<P = React.HTMLAttributes<any> & {
|
|
10
|
+
ref?: React.Ref<any>;
|
|
11
|
+
}> = (props: P) => React.ReactNode;
|
|
10
12
|
/**
|
|
11
13
|
* The `wrapElement` prop.
|
|
12
14
|
*/
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useComboboxContext
|
|
4
|
+
} from "./N4X7J4OQ.js";
|
|
5
|
+
import {
|
|
6
|
+
useSelectContext
|
|
7
|
+
} from "./SYZHUNAU.js";
|
|
2
8
|
import {
|
|
3
9
|
useCompositeStoreProps
|
|
4
10
|
} from "./ZR5N62ZV.js";
|
|
5
|
-
import {
|
|
6
|
-
useCompositeContext
|
|
7
|
-
} from "./QFI3MCMR.js";
|
|
8
11
|
import {
|
|
9
12
|
useStore,
|
|
10
13
|
useStoreProps
|
|
@@ -21,7 +24,7 @@ import {
|
|
|
21
24
|
import { useMemo } from "react";
|
|
22
25
|
import * as Core from "@ariakit/core/tab/tab-store";
|
|
23
26
|
function useTabStoreProps(store, update, props) {
|
|
24
|
-
useUpdateEffect(update, [props.composite]);
|
|
27
|
+
useUpdateEffect(update, [props.composite, props.combobox]);
|
|
25
28
|
store = useCompositeStoreProps(store, update, props);
|
|
26
29
|
useStoreProps(store, props, "selectedId", "setSelectedId");
|
|
27
30
|
useStoreProps(store, props, "selectOnMove");
|
|
@@ -29,13 +32,15 @@ function useTabStoreProps(store, update, props) {
|
|
|
29
32
|
useUpdateEffect(updatePanels, [store, updatePanels]);
|
|
30
33
|
return Object.assign(
|
|
31
34
|
useMemo(() => __spreadProps(__spreadValues({}, store), { panels }), [store, panels]),
|
|
32
|
-
{ composite: props.composite }
|
|
35
|
+
{ composite: props.composite, combobox: props.combobox }
|
|
33
36
|
);
|
|
34
37
|
}
|
|
35
38
|
function useTabStore(props = {}) {
|
|
36
|
-
const
|
|
39
|
+
const combobox = useComboboxContext();
|
|
40
|
+
const composite = useSelectContext() || combobox;
|
|
37
41
|
props = __spreadProps(__spreadValues({}, props), {
|
|
38
|
-
composite: props.composite !== void 0 ? props.composite : composite
|
|
42
|
+
composite: props.composite !== void 0 ? props.composite : composite,
|
|
43
|
+
combobox: props.combobox !== void 0 ? props.combobox : combobox
|
|
39
44
|
});
|
|
40
45
|
const [store, update] = useStore(Core.createTabStore, props);
|
|
41
46
|
return useTabStoreProps(store, update, props);
|
|
@@ -44,7 +44,7 @@ var usePopoverDisclosureArrow = createHook(function usePopoverDisclosureArrow2(_
|
|
|
44
44
|
stroke: "currentColor",
|
|
45
45
|
strokeLinecap: "round",
|
|
46
46
|
strokeLinejoin: "round",
|
|
47
|
-
strokeWidth:
|
|
47
|
+
strokeWidth: 1.5,
|
|
48
48
|
viewBox: "0 0 16 16",
|
|
49
49
|
height: "1em",
|
|
50
50
|
width: "1em",
|
|
@@ -390,6 +390,7 @@ var useDialog = createHook(function useDialog2(_a) {
|
|
|
390
390
|
},
|
|
391
391
|
[store, finalFocus, autoFocusOnHideProp]
|
|
392
392
|
);
|
|
393
|
+
const focusedOnHideRef = useRef(false);
|
|
393
394
|
useSafeLayoutEffect(() => {
|
|
394
395
|
if (open)
|
|
395
396
|
return;
|
|
@@ -398,6 +399,7 @@ var useDialog = createHook(function useDialog2(_a) {
|
|
|
398
399
|
if (!mayAutoFocusOnHide)
|
|
399
400
|
return;
|
|
400
401
|
const dialog = ref.current;
|
|
402
|
+
focusedOnHideRef.current = true;
|
|
401
403
|
focusOnHide(dialog);
|
|
402
404
|
}, [open, hasOpened, domReady, mayAutoFocusOnHide, focusOnHide]);
|
|
403
405
|
useEffect(() => {
|
|
@@ -406,7 +408,13 @@ var useDialog = createHook(function useDialog2(_a) {
|
|
|
406
408
|
if (!mayAutoFocusOnHide)
|
|
407
409
|
return;
|
|
408
410
|
const dialog = ref.current;
|
|
409
|
-
return () =>
|
|
411
|
+
return () => {
|
|
412
|
+
if (focusedOnHideRef.current) {
|
|
413
|
+
focusedOnHideRef.current = false;
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
focusOnHide(dialog);
|
|
417
|
+
};
|
|
410
418
|
}, [hasOpened, mayAutoFocusOnHide, focusOnHide]);
|
|
411
419
|
const hideOnEscapeProp = useBooleanEvent(hideOnEscape);
|
|
412
420
|
useEffect(() => {
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
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,
|
|
@@ -41,7 +42,9 @@ import {
|
|
|
41
42
|
// src/composite/composite-item.tsx
|
|
42
43
|
import { useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
43
44
|
import {
|
|
45
|
+
getDocument,
|
|
44
46
|
getScrollingElement,
|
|
47
|
+
getTextboxSelection,
|
|
45
48
|
isButton,
|
|
46
49
|
isTextField
|
|
47
50
|
} from "@ariakit/core/utils/dom";
|
|
@@ -52,6 +55,9 @@ import {
|
|
|
52
55
|
} from "@ariakit/core/utils/misc";
|
|
53
56
|
import { jsx } from "react/jsx-runtime";
|
|
54
57
|
var TagName = "button";
|
|
58
|
+
function isTextbox(element) {
|
|
59
|
+
return element.isContentEditable || isTextField(element);
|
|
60
|
+
}
|
|
55
61
|
function isEditableElement(element) {
|
|
56
62
|
if (element.isContentEditable)
|
|
57
63
|
return true;
|
|
@@ -59,6 +65,16 @@ function isEditableElement(element) {
|
|
|
59
65
|
return true;
|
|
60
66
|
return element.tagName === "INPUT" && !isButton(element);
|
|
61
67
|
}
|
|
68
|
+
function getValueLength(element) {
|
|
69
|
+
if (isTextField(element)) {
|
|
70
|
+
return element.value.length;
|
|
71
|
+
} else if (element.isContentEditable) {
|
|
72
|
+
const range = getDocument(element).createRange();
|
|
73
|
+
range.selectNodeContents(element);
|
|
74
|
+
return range.toString().length;
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
62
78
|
function getNextPageOffset(scrollingElement, pageUp = false) {
|
|
63
79
|
const height = scrollingElement.clientHeight;
|
|
64
80
|
const { top } = scrollingElement.getBoundingClientRect();
|
|
@@ -213,11 +229,12 @@ var useCompositeItem = createHook(
|
|
|
213
229
|
return;
|
|
214
230
|
if (!store)
|
|
215
231
|
return;
|
|
216
|
-
const { activeId, virtualFocus: virtualFocus2, baseElement: baseElement2 } = store.getState();
|
|
217
232
|
if (targetIsAnotherItem(event, store))
|
|
218
233
|
return;
|
|
219
|
-
|
|
220
|
-
|
|
234
|
+
const { virtualFocus: virtualFocus2, baseElement: baseElement2 } = store.getState();
|
|
235
|
+
store.setActiveId(id);
|
|
236
|
+
if (isTextbox(event.currentTarget)) {
|
|
237
|
+
selectTextField(event.currentTarget);
|
|
221
238
|
}
|
|
222
239
|
if (!virtualFocus2)
|
|
223
240
|
return;
|
|
@@ -305,6 +322,22 @@ var useCompositeItem = createHook(
|
|
|
305
322
|
};
|
|
306
323
|
const action = keyMap[event.key];
|
|
307
324
|
if (action) {
|
|
325
|
+
if (isTextbox(currentTarget)) {
|
|
326
|
+
const selection = getTextboxSelection(currentTarget);
|
|
327
|
+
const isLeft = isHorizontal && event.key === "ArrowLeft";
|
|
328
|
+
const isRight = isHorizontal && event.key === "ArrowRight";
|
|
329
|
+
const isUp = isVertical && event.key === "ArrowUp";
|
|
330
|
+
const isDown = isVertical && event.key === "ArrowDown";
|
|
331
|
+
if (isRight || isDown) {
|
|
332
|
+
if (selection.end !== getValueLength(currentTarget)) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
} else if (isLeft || isUp) {
|
|
336
|
+
if (selection.start !== 0) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
308
341
|
const nextId = action();
|
|
309
342
|
if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
|
|
310
343
|
if (!moveOnKeyPressProp(event))
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./YMV43K4F.js";
|
|
7
7
|
import {
|
|
8
8
|
usePopover
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./LTYEFENI.js";
|
|
10
10
|
import {
|
|
11
11
|
createDialogComponent
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./IOUGWXY5.js";
|
|
13
13
|
import {
|
|
14
14
|
HovercardScopedContextProvider,
|
|
15
15
|
useHovercardProviderContext
|
|
@@ -49,7 +49,9 @@ declare function getItem<T extends Item = any>(items: Items<T>, index: number):
|
|
|
49
49
|
export declare function useCollectionRenderer<T extends Item = any>({ store, items: itemsProp, initialItems, gap, itemSize, estimatedItemSize, overscan: overscanProp, orientation: orientationProp, padding, paddingStart, paddingEnd, persistentIndices, renderOnScroll, renderOnResize, children: renderItem, ...props }: CollectionRendererProps<T>): {
|
|
50
50
|
children: ReactNode[];
|
|
51
51
|
wrapElement?: import("../utils/types.js").WrapElement | undefined;
|
|
52
|
-
render?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("../utils/types.js").RenderProp<import("react").HTMLAttributes<any> &
|
|
52
|
+
render?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("../utils/types.js").RenderProp<import("react").HTMLAttributes<any> & {
|
|
53
|
+
ref?: import("react").Ref<any> | undefined;
|
|
54
|
+
}> | undefined;
|
|
53
55
|
ref?: ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined;
|
|
54
56
|
defaultChecked?: boolean | undefined;
|
|
55
57
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
@@ -294,9 +296,7 @@ export declare function useCollectionRenderer<T extends Item = any>({ store, ite
|
|
|
294
296
|
onPointerCancel?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
295
297
|
onPointerCancelCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
296
298
|
onPointerEnter?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
297
|
-
onPointerEnterCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
298
299
|
onPointerLeave?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
299
|
-
onPointerLeaveCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
300
300
|
onPointerOver?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
301
301
|
onPointerOverCapture?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
302
302
|
onPointerOut?: import("react").PointerEventHandler<HTMLDivElement> | undefined;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useButton
|
|
4
4
|
} from "../__chunks/CKAOM5LG.js";
|
|
5
|
+
import "../__chunks/PJ7ERAIM.js";
|
|
5
6
|
import {
|
|
6
7
|
useComboboxProviderContext
|
|
7
8
|
} from "../__chunks/N4X7J4OQ.js";
|
|
8
|
-
import "../__chunks/PJ7ERAIM.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",
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
} from "../__chunks/LTYBQEWX.js";
|
|
5
5
|
import "../__chunks/R6SM2O47.js";
|
|
6
6
|
import "../__chunks/CKAOM5LG.js";
|
|
7
|
+
import "../__chunks/PJ7ERAIM.js";
|
|
7
8
|
import {
|
|
8
9
|
useComboboxProviderContext
|
|
9
10
|
} from "../__chunks/N4X7J4OQ.js";
|
|
10
|
-
import "../__chunks/PJ7ERAIM.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",
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useCompositeHover
|
|
4
4
|
} from "../__chunks/VXKKJNIF.js";
|
|
5
|
+
import {
|
|
6
|
+
useCompositeItem
|
|
7
|
+
} from "../__chunks/R33ISPJY.js";
|
|
8
|
+
import "../__chunks/PJ7ERAIM.js";
|
|
5
9
|
import {
|
|
6
10
|
ComboboxItemCheckedContext,
|
|
7
11
|
ComboboxItemValueContext,
|
|
8
12
|
ComboboxListRoleContext,
|
|
9
13
|
useComboboxScopedContext
|
|
10
14
|
} from "../__chunks/N4X7J4OQ.js";
|
|
11
|
-
import {
|
|
12
|
-
useCompositeItem
|
|
13
|
-
} from "../__chunks/VGL3CETR.js";
|
|
14
|
-
import "../__chunks/PJ7ERAIM.js";
|
|
15
15
|
import "../__chunks/IFMAUEA7.js";
|
|
16
16
|
import "../__chunks/3IEDWLST.js";
|
|
17
17
|
import "../__chunks/QFI3MCMR.js";
|
|
@@ -9,10 +9,10 @@ import "../__chunks/QFI3MCMR.js";
|
|
|
9
9
|
import "../__chunks/6LTHW2TQ.js";
|
|
10
10
|
import {
|
|
11
11
|
usePopover
|
|
12
|
-
} from "../__chunks/
|
|
12
|
+
} from "../__chunks/LTYEFENI.js";
|
|
13
13
|
import {
|
|
14
14
|
createDialogComponent
|
|
15
|
-
} from "../__chunks/
|
|
15
|
+
} from "../__chunks/IOUGWXY5.js";
|
|
16
16
|
import "../__chunks/GOXKZAQI.js";
|
|
17
17
|
import "../__chunks/6GXEOXGT.js";
|
|
18
18
|
import "../__chunks/PTPUIM7N.js";
|
|
@@ -58,8 +58,9 @@ import {
|
|
|
58
58
|
} from "../__chunks/4R3V3JGP.js";
|
|
59
59
|
|
|
60
60
|
// src/combobox/combobox-popover.tsx
|
|
61
|
+
import { useRef } from "react";
|
|
61
62
|
import { getDocument, matches } from "@ariakit/core/utils/dom";
|
|
62
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
63
|
+
import { invariant, isFalsyBooleanCallback } from "@ariakit/core/utils/misc";
|
|
63
64
|
var TagName = "div";
|
|
64
65
|
function isController(target, ...ids) {
|
|
65
66
|
if (!target)
|
|
@@ -79,12 +80,14 @@ var useComboboxPopover = createHook(
|
|
|
79
80
|
modal,
|
|
80
81
|
tabIndex,
|
|
81
82
|
alwaysVisible,
|
|
83
|
+
autoFocusOnHide = true,
|
|
82
84
|
hideOnInteractOutside = true
|
|
83
85
|
} = _b, props = __objRest(_b, [
|
|
84
86
|
"store",
|
|
85
87
|
"modal",
|
|
86
88
|
"tabIndex",
|
|
87
89
|
"alwaysVisible",
|
|
90
|
+
"autoFocusOnHide",
|
|
88
91
|
"hideOnInteractOutside"
|
|
89
92
|
]);
|
|
90
93
|
const context = useComboboxProviderContext();
|
|
@@ -94,6 +97,7 @@ var useComboboxPopover = createHook(
|
|
|
94
97
|
process.env.NODE_ENV !== "production" && "ComboboxPopover must receive a `store` prop or be wrapped in a ComboboxProvider component."
|
|
95
98
|
);
|
|
96
99
|
const baseElement = store.useState("baseElement");
|
|
100
|
+
const hiddenByClickOutsideRef = useRef(false);
|
|
97
101
|
props = useComboboxList(__spreadValues({ store, alwaysVisible }, props));
|
|
98
102
|
props = usePopover(__spreadProps(__spreadValues({
|
|
99
103
|
store,
|
|
@@ -101,7 +105,6 @@ var useComboboxPopover = createHook(
|
|
|
101
105
|
alwaysVisible,
|
|
102
106
|
backdrop: false,
|
|
103
107
|
autoFocusOnShow: false,
|
|
104
|
-
autoFocusOnHide: false,
|
|
105
108
|
finalFocus: baseElement,
|
|
106
109
|
preserveTabOrderAnchor: null
|
|
107
110
|
}, props), {
|
|
@@ -133,6 +136,18 @@ var useComboboxPopover = createHook(
|
|
|
133
136
|
const controlElements = doc.querySelectorAll(selector);
|
|
134
137
|
return [...elements, ...controlElements];
|
|
135
138
|
},
|
|
139
|
+
// The combobox popover should focus on the combobox input when it hides,
|
|
140
|
+
// unless the event was triggered by a click outside the popover, in which
|
|
141
|
+
// case the input shouldn't be re-focused.
|
|
142
|
+
autoFocusOnHide(element) {
|
|
143
|
+
if (isFalsyBooleanCallback(autoFocusOnHide, element))
|
|
144
|
+
return false;
|
|
145
|
+
if (hiddenByClickOutsideRef.current) {
|
|
146
|
+
hiddenByClickOutsideRef.current = false;
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
},
|
|
136
151
|
// Make sure we don't hide the popover when the user interacts with the
|
|
137
152
|
// combobox cancel or the combobox disclosure buttons. They will have the
|
|
138
153
|
// aria-controls attribute pointing to either the combobox input or the
|
|
@@ -145,6 +160,9 @@ var useComboboxPopover = createHook(
|
|
|
145
160
|
if (isController(event.target, contentId, baseId))
|
|
146
161
|
return false;
|
|
147
162
|
const result = typeof hideOnInteractOutside === "function" ? hideOnInteractOutside(event) : hideOnInteractOutside;
|
|
163
|
+
if (result) {
|
|
164
|
+
hiddenByClickOutsideRef.current = event.type === "click";
|
|
165
|
+
}
|
|
148
166
|
return result;
|
|
149
167
|
}
|
|
150
168
|
}));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useComboboxScopedContext
|
|
4
|
-
} from "../__chunks/N4X7J4OQ.js";
|
|
5
2
|
import {
|
|
6
3
|
useCompositeRow
|
|
7
4
|
} from "../__chunks/TZ7AP4RP.js";
|
|
5
|
+
import {
|
|
6
|
+
useComboboxScopedContext
|
|
7
|
+
} from "../__chunks/N4X7J4OQ.js";
|
|
8
8
|
import "../__chunks/QFI3MCMR.js";
|
|
9
9
|
import "../__chunks/6LTHW2TQ.js";
|
|
10
10
|
import "../__chunks/5B3U64HV.js";
|