@ariakit/core 0.3.2 → 0.3.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 +20 -0
- package/cjs/__chunks/{4L3HCXJY.cjs → 25WWT2VO.cjs} +17 -16
- package/cjs/__chunks/{EXM2AW52.cjs → FTB5CXVB.cjs} +3 -1
- package/cjs/__chunks/{EIRIJC7T.cjs → G5EW4WED.cjs} +8 -7
- package/cjs/__chunks/{RCYVACJO.cjs → LMT335NJ.cjs} +9 -4
- package/cjs/__chunks/LUOEAZGU.cjs +42 -0
- package/cjs/__chunks/{4OD4ZFRG.cjs → M44E4T5A.cjs} +30 -29
- package/cjs/__chunks/{GHET3DES.cjs → MLPOXRDT.cjs} +4 -3
- package/cjs/__chunks/{7GWXP6CQ.cjs → OASSVCYR.cjs} +43 -29
- package/cjs/__chunks/{AIHTEA5D.cjs → ROX3MRGO.cjs} +18 -17
- package/cjs/__chunks/{GDZQUFNP.cjs → ULSPM3Y3.cjs} +3 -1
- package/cjs/__chunks/{72I2GWXF.cjs → WYXAWBLE.cjs} +2 -1
- package/cjs/__chunks/{52LQV3SV.cjs → YXSGST3H.cjs} +23 -23
- package/cjs/checkbox/checkbox-store.cjs +9 -8
- package/cjs/checkbox/checkbox-store.d.cts +41 -0
- package/cjs/collection/collection-store.cjs +8 -7
- package/cjs/collection/collection-store.d.cts +65 -0
- package/cjs/combobox/combobox-store.cjs +37 -36
- package/cjs/combobox/combobox-store.d.cts +77 -0
- package/cjs/composite/composite-overflow-store.cjs +9 -8
- package/cjs/composite/composite-overflow-store.d.cts +10 -0
- package/cjs/composite/composite-store.cjs +10 -9
- package/cjs/composite/composite-store.d.cts +206 -0
- package/cjs/dialog/dialog-store.cjs +8 -7
- package/cjs/dialog/dialog-store.d.cts +10 -0
- package/cjs/disclosure/disclosure-store.cjs +7 -6
- package/cjs/disclosure/disclosure-store.d.cts +125 -0
- package/cjs/disclosure/disclosure-store.d.ts +1 -0
- package/cjs/form/form-store.cjs +30 -29
- package/cjs/form/form-store.d.cts +236 -0
- package/cjs/form/types.cjs +1 -1
- package/cjs/form/types.d.cts +38 -0
- package/cjs/hovercard/hovercard-store.cjs +10 -9
- package/cjs/hovercard/hovercard-store.d.cts +46 -0
- package/cjs/index.cjs +2 -1
- package/cjs/index.d.cts +2 -0
- package/cjs/menu/menu-bar-store.cjs +12 -11
- package/cjs/menu/menu-bar-store.d.cts +10 -0
- package/cjs/menu/menu-store.cjs +35 -34
- package/cjs/menu/menu-store.d.cts +78 -0
- package/cjs/popover/popover-store.cjs +9 -8
- package/cjs/popover/popover-store.d.cts +69 -0
- package/cjs/radio/radio-store.cjs +16 -15
- package/cjs/radio/radio-store.d.cts +36 -0
- package/cjs/select/select-store.cjs +37 -36
- package/cjs/select/select-store.d.cts +93 -0
- package/cjs/tab/tab-store.cjs +28 -27
- package/cjs/tab/tab-store.d.cts +87 -0
- package/cjs/toolbar/toolbar-store.cjs +12 -11
- package/cjs/toolbar/toolbar-store.d.cts +21 -0
- package/cjs/tooltip/tooltip-store.cjs +17 -16
- package/cjs/tooltip/tooltip-store.d.cts +29 -0
- package/cjs/utils/array.cjs +5 -4
- package/cjs/utils/array.d.cts +29 -0
- package/cjs/utils/dom.cjs +5 -4
- package/cjs/utils/dom.d.cts +105 -0
- package/cjs/utils/events.cjs +10 -9
- package/cjs/utils/events.d.cts +70 -0
- package/cjs/utils/focus.cjs +17 -16
- package/cjs/utils/focus.d.cts +117 -0
- package/cjs/utils/misc.cjs +7 -4
- package/cjs/utils/misc.d.cts +124 -0
- package/cjs/utils/misc.d.ts +7 -0
- package/cjs/utils/platform.cjs +6 -5
- package/cjs/utils/platform.d.cts +20 -0
- package/cjs/utils/store.cjs +6 -5
- package/cjs/utils/store.d.cts +71 -0
- package/cjs/utils/types.cjs +1 -1
- package/cjs/utils/types.d.cts +74 -0
- package/esm/__chunks/{PNRLI7OV.js → 2SMRF6AD.js} +1 -0
- package/esm/__chunks/{UCFCIHEU.js → 5UJPJ37G.js} +2 -1
- package/esm/__chunks/{5XEKIOCW.js → 7PRQYBBV.js} +2 -0
- package/esm/__chunks/{WVTCK5PV.js → D23ES3Z4.js} +6 -1
- package/esm/__chunks/{BL2LUIIN.js → FGW7QUD2.js} +6 -5
- package/esm/__chunks/{DEGIJZ7N.js → GME4NYXR.js} +28 -14
- package/esm/__chunks/{BE4I5ZDQ.js → I7YGHQ4Z.js} +2 -1
- package/esm/__chunks/{A2JA3CYE.js → LWQU4J4N.js} +5 -4
- package/esm/__chunks/{O35LWD4W.js → NIF7E7VE.js} +2 -0
- package/esm/__chunks/{STQCKYT6.js → Q332EHXG.js} +5 -4
- package/esm/__chunks/{OZ4NH3RO.js → TEJLMP2M.js} +8 -8
- package/esm/__chunks/{LTJQMYBN.js → VEWADM34.js} +5 -4
- package/esm/checkbox/checkbox-store.js +4 -3
- package/esm/collection/collection-store.js +6 -5
- package/esm/combobox/combobox-store.js +12 -11
- package/esm/composite/composite-overflow-store.js +7 -6
- package/esm/composite/composite-store.js +8 -7
- package/esm/dialog/dialog-store.js +6 -5
- package/esm/disclosure/disclosure-store.d.ts +1 -0
- package/esm/disclosure/disclosure-store.js +5 -4
- package/esm/form/form-store.js +6 -5
- package/esm/form/types.js +1 -0
- package/esm/hovercard/hovercard-store.js +8 -7
- package/esm/index.js +2 -1
- package/esm/menu/menu-bar-store.js +8 -7
- package/esm/menu/menu-store.js +12 -11
- package/esm/popover/popover-store.js +7 -6
- package/esm/radio/radio-store.js +8 -7
- package/esm/select/select-store.js +11 -10
- package/esm/tab/tab-store.js +8 -7
- package/esm/toolbar/toolbar-store.js +8 -7
- package/esm/tooltip/tooltip-store.js +8 -7
- package/esm/utils/array.js +3 -2
- package/esm/utils/dom.js +3 -2
- package/esm/utils/events.js +4 -3
- package/esm/utils/focus.js +3 -2
- package/esm/utils/misc.d.ts +7 -0
- package/esm/utils/misc.js +5 -2
- package/esm/utils/platform.js +4 -3
- package/esm/utils/store.js +4 -3
- package/esm/utils/types.js +1 -0
- package/package.json +109 -28
- package/cjs/__chunks/ZRCUNIY2.cjs +0 -41
- package/cjs/tsconfig.build.tsbuildinfo +0 -1
- package/esm/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
|
-
var _4OD4ZFRGcjs = require('../__chunks/4OD4ZFRG.cjs');
|
|
4
|
-
require('../__chunks/4L3HCXJY.cjs');
|
|
5
|
-
require('../__chunks/7GWXP6CQ.cjs');
|
|
6
3
|
|
|
4
|
+
var _M44E4T5Acjs = require('../__chunks/M44E4T5A.cjs');
|
|
5
|
+
require('../__chunks/25WWT2VO.cjs');
|
|
6
|
+
require('../__chunks/OASSVCYR.cjs');
|
|
7
7
|
|
|
8
|
-
var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
|
|
9
|
-
require('../__chunks/EXM2AW52.cjs');
|
|
10
|
-
require('../__chunks/GDZQUFNP.cjs');
|
|
11
8
|
|
|
9
|
+
var _LMT335NJcjs = require('../__chunks/LMT335NJ.cjs');
|
|
10
|
+
require('../__chunks/FTB5CXVB.cjs');
|
|
11
|
+
require('../__chunks/ULSPM3Y3.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.cjs');
|
|
15
16
|
|
|
16
17
|
// src/toolbar/toolbar-store.ts
|
|
17
18
|
function createToolbarStore(props = {}) {
|
|
18
19
|
var _a;
|
|
19
20
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
20
|
-
return
|
|
21
|
-
orientation:
|
|
21
|
+
return _M44E4T5Acjs.createCompositeStore.call(void 0, _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
22
|
+
orientation: _LMT335NJcjs.defaultValue.call(void 0,
|
|
22
23
|
props.orientation,
|
|
23
24
|
syncState == null ? void 0 : syncState.orientation,
|
|
24
25
|
"horizontal"
|
|
25
26
|
),
|
|
26
|
-
focusLoop:
|
|
27
|
+
focusLoop: _LMT335NJcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
|
|
27
28
|
}));
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CompositeStore, CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreProps, CompositeStoreState } from "../composite/composite-store.js";
|
|
2
|
+
import type { StoreOptions } from "../utils/store.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a toolbar store.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createToolbarStore(props?: ToolbarStoreProps): ToolbarStore;
|
|
7
|
+
export interface ToolbarStoreState extends CompositeStoreState {
|
|
8
|
+
/**
|
|
9
|
+
* @default "horizontal"
|
|
10
|
+
*/
|
|
11
|
+
orientation: CompositeStoreState["orientation"];
|
|
12
|
+
/**
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
focusLoop: CompositeStoreState["focusLoop"];
|
|
16
|
+
}
|
|
17
|
+
export type ToolbarStoreFunctions = CompositeStoreFunctions;
|
|
18
|
+
export interface ToolbarStoreOptions extends StoreOptions<ToolbarStoreState, "orientation" | "focusLoop">, CompositeStoreOptions {
|
|
19
|
+
}
|
|
20
|
+
export type ToolbarStore = CompositeStore;
|
|
21
|
+
export type ToolbarStoreProps = CompositeStoreProps;
|
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
|
-
var _ZRCUNIY2cjs = require('../__chunks/ZRCUNIY2.cjs');
|
|
4
|
-
require('../__chunks/AIHTEA5D.cjs');
|
|
5
|
-
require('../__chunks/GHET3DES.cjs');
|
|
6
|
-
require('../__chunks/52LQV3SV.cjs');
|
|
7
3
|
|
|
4
|
+
var _LUOEAZGUcjs = require('../__chunks/LUOEAZGU.cjs');
|
|
5
|
+
require('../__chunks/ROX3MRGO.cjs');
|
|
6
|
+
require('../__chunks/MLPOXRDT.cjs');
|
|
7
|
+
require('../__chunks/YXSGST3H.cjs');
|
|
8
8
|
|
|
9
|
-
var _7GWXP6CQcjs = require('../__chunks/7GWXP6CQ.cjs');
|
|
10
9
|
|
|
10
|
+
var _OASSVCYRcjs = require('../__chunks/OASSVCYR.cjs');
|
|
11
11
|
|
|
12
|
-
var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
|
|
13
12
|
|
|
13
|
+
var _LMT335NJcjs = require('../__chunks/LMT335NJ.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.cjs');
|
|
17
18
|
|
|
18
19
|
// src/tooltip/tooltip-store.ts
|
|
19
20
|
function createTooltipStore(props = {}) {
|
|
20
21
|
var _a;
|
|
21
22
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
22
|
-
const hovercard =
|
|
23
|
-
placement:
|
|
23
|
+
const hovercard = _LUOEAZGUcjs.createHovercardStore.call(void 0, _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
24
|
+
placement: _LMT335NJcjs.defaultValue.call(void 0,
|
|
24
25
|
props.placement,
|
|
25
26
|
syncState == null ? void 0 : syncState.placement,
|
|
26
27
|
"top"
|
|
27
28
|
),
|
|
28
|
-
hideTimeout:
|
|
29
|
+
hideTimeout: _LMT335NJcjs.defaultValue.call(void 0, props.hideTimeout, syncState == null ? void 0 : syncState.hideTimeout, 0)
|
|
29
30
|
}));
|
|
30
|
-
const initialState =
|
|
31
|
-
type:
|
|
32
|
-
skipTimeout:
|
|
31
|
+
const initialState = _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, hovercard.getState()), {
|
|
32
|
+
type: _LMT335NJcjs.defaultValue.call(void 0, props.type, syncState == null ? void 0 : syncState.type, "description"),
|
|
33
|
+
skipTimeout: _LMT335NJcjs.defaultValue.call(void 0, props.skipTimeout, syncState == null ? void 0 : syncState.skipTimeout, 300)
|
|
33
34
|
});
|
|
34
|
-
const tooltip =
|
|
35
|
-
return
|
|
35
|
+
const tooltip = _OASSVCYRcjs.createStore.call(void 0, initialState, hovercard, props.store);
|
|
36
|
+
return _WYXAWBLEcjs.__spreadValues.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, hovercard), tooltip);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
|
|
2
|
+
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a tooltip store.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createTooltipStore(props?: TooltipStoreProps): TooltipStore;
|
|
7
|
+
export interface TooltipStoreState extends HovercardStoreState {
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether the tooltip is being used as a label or a description
|
|
10
|
+
* for the anchor element.
|
|
11
|
+
* @default "description"
|
|
12
|
+
*/
|
|
13
|
+
type: "label" | "description";
|
|
14
|
+
/**
|
|
15
|
+
* The amount of time after a tooltip is hidden while all tooltips on the
|
|
16
|
+
* page can be shown immediately, without waiting for the show timeout.
|
|
17
|
+
* @default 300
|
|
18
|
+
*/
|
|
19
|
+
skipTimeout: number;
|
|
20
|
+
/** @default "top" */
|
|
21
|
+
placement: HovercardStoreState["placement"];
|
|
22
|
+
/** @default 0 */
|
|
23
|
+
hideTimeout?: HovercardStoreState["hideTimeout"];
|
|
24
|
+
}
|
|
25
|
+
export type TooltipStoreFunctions = HovercardStoreFunctions;
|
|
26
|
+
export interface TooltipStoreOptions extends StoreOptions<TooltipStoreState, "type" | "placement" | "timeout" | "showTimeout" | "hideTimeout" | "skipTimeout">, HovercardStoreOptions {
|
|
27
|
+
}
|
|
28
|
+
export type TooltipStoreProps = TooltipStoreOptions & StoreProps<TooltipStoreState>;
|
|
29
|
+
export type TooltipStore = TooltipStoreFunctions & Store<TooltipStoreState>;
|
package/cjs/utils/array.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var _GDZQUFNPcjs = require('../__chunks/GDZQUFNP.cjs');
|
|
7
|
-
require('../__chunks/72I2GWXF.cjs');
|
|
8
6
|
|
|
7
|
+
var _ULSPM3Y3cjs = require('../__chunks/ULSPM3Y3.cjs');
|
|
8
|
+
require('../__chunks/WYXAWBLE.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
exports.addItemToArray = _ULSPM3Y3cjs.addItemToArray; exports.flatten2DArray = _ULSPM3Y3cjs.flatten2DArray; exports.reverseArray = _ULSPM3Y3cjs.reverseArray; exports.toArray = _ULSPM3Y3cjs.toArray;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms `arg` into an array if it's not already.
|
|
3
|
+
* @example
|
|
4
|
+
* toArray("a"); // ["a"]
|
|
5
|
+
* toArray(["a"]); // ["a"]
|
|
6
|
+
*/
|
|
7
|
+
export declare function toArray<T>(arg: T): T extends readonly any[] ? T : T[];
|
|
8
|
+
/**
|
|
9
|
+
* Immutably adds an index to an array.
|
|
10
|
+
* @example
|
|
11
|
+
* addItemToArray(["a", "b", "d"], "c", 2); // ["a", "b", "c", "d"]
|
|
12
|
+
* @returns {Array} A new array with the item in the passed array index.
|
|
13
|
+
*/
|
|
14
|
+
export declare function addItemToArray<T extends any[]>(array: T, item: T[number], index?: number): T;
|
|
15
|
+
/**
|
|
16
|
+
* Flattens a 2D array into a one-dimensional array.
|
|
17
|
+
* @example
|
|
18
|
+
* flatten2DArray([["a"], ["b"], ["c"]]); // ["a", "b", "c"]
|
|
19
|
+
*
|
|
20
|
+
* @returns {Array} A one-dimensional array.
|
|
21
|
+
*/
|
|
22
|
+
export declare function flatten2DArray<T>(array: T[][]): T[];
|
|
23
|
+
/**
|
|
24
|
+
* Immutably reverses an array.
|
|
25
|
+
* @example
|
|
26
|
+
* reverseArray(["a", "b", "c"]); // ["c", "b", "a"]
|
|
27
|
+
* @returns {Array} Reversed array.
|
|
28
|
+
*/
|
|
29
|
+
export declare function reverseArray<T>(array: T[]): T[];
|
package/cjs/utils/dom.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var _EXM2AW52cjs = require('../__chunks/EXM2AW52.cjs');
|
|
20
|
-
require('../__chunks/72I2GWXF.cjs');
|
|
21
19
|
|
|
20
|
+
var _FTB5CXVBcjs = require('../__chunks/FTB5CXVB.cjs');
|
|
21
|
+
require('../__chunks/WYXAWBLE.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -36,4 +36,5 @@ require('../__chunks/72I2GWXF.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
exports.canUseDOM = _FTB5CXVBcjs.canUseDOM; exports.closest = _FTB5CXVBcjs.closest; exports.contains = _FTB5CXVBcjs.contains; exports.getActiveElement = _FTB5CXVBcjs.getActiveElement; exports.getDocument = _FTB5CXVBcjs.getDocument; exports.getPopupItemRole = _FTB5CXVBcjs.getPopupItemRole; exports.getPopupRole = _FTB5CXVBcjs.getPopupRole; exports.getScrollingElement = _FTB5CXVBcjs.getScrollingElement; exports.getTextboxSelection = _FTB5CXVBcjs.getTextboxSelection; exports.getWindow = _FTB5CXVBcjs.getWindow; exports.isButton = _FTB5CXVBcjs.isButton; exports.isFrame = _FTB5CXVBcjs.isFrame; exports.isPartiallyHidden = _FTB5CXVBcjs.isPartiallyHidden; exports.isTextField = _FTB5CXVBcjs.isTextField; exports.isVisible = _FTB5CXVBcjs.isVisible; exports.matches = _FTB5CXVBcjs.matches; exports.scrollIntoViewIfNeeded = _FTB5CXVBcjs.scrollIntoViewIfNeeded;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { AriaHasPopup, AriaRole } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* It's `true` if it is running in a browser environment or `false` if it is not
|
|
4
|
+
* (SSR).
|
|
5
|
+
* @example
|
|
6
|
+
* const title = canUseDOM ? document.title : "";
|
|
7
|
+
*/
|
|
8
|
+
export declare const canUseDOM: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns `element.ownerDocument || document`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDocument(node?: Node | null): Document;
|
|
13
|
+
/**
|
|
14
|
+
* Returns `element.ownerDocument.defaultView || window`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getWindow(node?: Node | null): Window;
|
|
17
|
+
/**
|
|
18
|
+
* Returns `element.ownerDocument.activeElement`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getActiveElement(node?: Node | null, activeDescendant?: boolean): HTMLElement | null;
|
|
21
|
+
/**
|
|
22
|
+
* Similar to `Element.prototype.contains`, but a little bit faster when
|
|
23
|
+
* `element` is the same as `child`.
|
|
24
|
+
* @example
|
|
25
|
+
* contains(
|
|
26
|
+
* document.getElementById("parent"),
|
|
27
|
+
* document.getElementById("child")
|
|
28
|
+
* );
|
|
29
|
+
*/
|
|
30
|
+
export declare function contains(parent: Node, child: Node): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether `element` is a frame element.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isFrame(element: Element): element is HTMLIFrameElement;
|
|
35
|
+
/**
|
|
36
|
+
* Checks whether `element` is a native HTML button element.
|
|
37
|
+
* @example
|
|
38
|
+
* isButton(document.querySelector("button")); // true
|
|
39
|
+
* isButton(document.querySelector("input[type='button']")); // true
|
|
40
|
+
* isButton(document.querySelector("div")); // false
|
|
41
|
+
* isButton(document.querySelector("input[type='text']")); // false
|
|
42
|
+
* isButton(document.querySelector("div[role='button']")); // false
|
|
43
|
+
*/
|
|
44
|
+
export declare function isButton(element: {
|
|
45
|
+
tagName: string;
|
|
46
|
+
type?: string;
|
|
47
|
+
}): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Ponyfill for `Element.prototype.matches`
|
|
50
|
+
*
|
|
51
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
|
|
52
|
+
*/
|
|
53
|
+
export declare function matches(element: Element, selectors: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if the element is visible or not.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isVisible(element: Element): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Ponyfill for `Element.prototype.closest`
|
|
60
|
+
* @example
|
|
61
|
+
* closest(document.getElementById("id"), "div");
|
|
62
|
+
* // same as
|
|
63
|
+
* document.getElementById("id").closest("div");
|
|
64
|
+
*/
|
|
65
|
+
export declare function closest<K extends keyof HTMLElementTagNameMap>(element: Element, selectors: K): HTMLElementTagNameMap[K];
|
|
66
|
+
export declare function closest<K extends keyof SVGElementTagNameMap>(element: Element, selectors: K): SVGElementTagNameMap[K];
|
|
67
|
+
export declare function closest<T extends Element = Element>(element: Element, selectors: string): T | null;
|
|
68
|
+
/**
|
|
69
|
+
* Check whether the given element is a text field, where text field is defined
|
|
70
|
+
* by the ability to select within the input.
|
|
71
|
+
* @example
|
|
72
|
+
* isTextField(document.querySelector("div")); // false
|
|
73
|
+
* isTextField(document.querySelector("input")); // true
|
|
74
|
+
* isTextField(document.querySelector("input[type='button']")); // false
|
|
75
|
+
* isTextField(document.querySelector("textarea")); // true
|
|
76
|
+
*/
|
|
77
|
+
export declare function isTextField(element: Element): element is HTMLInputElement | HTMLTextAreaElement;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the element's role attribute, if it has one.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getPopupRole(element?: Element | null, fallback?: AriaHasPopup): AriaHasPopup;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the item role attribute based on the popup's role.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getPopupItemRole(element?: Element | null, fallback?: AriaRole): string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Returns the start and end offsets of the selection in the element.
|
|
88
|
+
*/
|
|
89
|
+
export declare function getTextboxSelection(element: HTMLElement): {
|
|
90
|
+
start: number;
|
|
91
|
+
end: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Calls `element.scrollIntoView()` if the element is hidden or partly hidden in
|
|
95
|
+
* the viewport.
|
|
96
|
+
*/
|
|
97
|
+
export declare function scrollIntoViewIfNeeded(element: Element, arg?: boolean | ScrollIntoViewOptions): void;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the scrolling container element of a given element.
|
|
100
|
+
*/
|
|
101
|
+
export declare function getScrollingElement(element?: Element | null): HTMLElement | Element | null;
|
|
102
|
+
/**
|
|
103
|
+
* Determines whether an element is hidden or partially hidden in the viewport.
|
|
104
|
+
*/
|
|
105
|
+
export declare function isPartiallyHidden(element: Element): boolean;
|
package/cjs/utils/events.cjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
|
-
var _EIRIJC7Tcjs = require('../__chunks/EIRIJC7T.cjs');
|
|
4
3
|
|
|
4
|
+
var _G5EW4WEDcjs = require('../__chunks/G5EW4WED.cjs');
|
|
5
5
|
|
|
6
|
-
var _EXM2AW52cjs = require('../__chunks/EXM2AW52.cjs');
|
|
7
6
|
|
|
7
|
+
var _FTB5CXVBcjs = require('../__chunks/FTB5CXVB.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.cjs');
|
|
11
12
|
|
|
12
13
|
// src/utils/events.ts
|
|
13
14
|
function isPortalEvent(event) {
|
|
14
15
|
return Boolean(
|
|
15
|
-
event.currentTarget && !
|
|
16
|
+
event.currentTarget && !_FTB5CXVBcjs.contains.call(void 0, event.currentTarget, event.target)
|
|
16
17
|
);
|
|
17
18
|
}
|
|
18
19
|
function isSelfTarget(event) {
|
|
@@ -22,7 +23,7 @@ function isOpeningInNewTab(event) {
|
|
|
22
23
|
const element = event.currentTarget;
|
|
23
24
|
if (!element)
|
|
24
25
|
return false;
|
|
25
|
-
const isAppleDevice =
|
|
26
|
+
const isAppleDevice = _G5EW4WEDcjs.isApple.call(void 0, );
|
|
26
27
|
if (isAppleDevice && !event.metaKey)
|
|
27
28
|
return false;
|
|
28
29
|
if (!isAppleDevice && !event.ctrlKey)
|
|
@@ -58,14 +59,14 @@ function fireEvent(element, type, eventInit) {
|
|
|
58
59
|
function fireBlurEvent(element, eventInit) {
|
|
59
60
|
const event = new FocusEvent("blur", eventInit);
|
|
60
61
|
const defaultAllowed = element.dispatchEvent(event);
|
|
61
|
-
const bubbleInit =
|
|
62
|
+
const bubbleInit = _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, eventInit), { bubbles: true });
|
|
62
63
|
element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
|
|
63
64
|
return defaultAllowed;
|
|
64
65
|
}
|
|
65
66
|
function fireFocusEvent(element, eventInit) {
|
|
66
67
|
const event = new FocusEvent("focus", eventInit);
|
|
67
68
|
const defaultAllowed = element.dispatchEvent(event);
|
|
68
|
-
const bubbleInit =
|
|
69
|
+
const bubbleInit = _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, eventInit), { bubbles: true });
|
|
69
70
|
element.dispatchEvent(new FocusEvent("focusin", bubbleInit));
|
|
70
71
|
return defaultAllowed;
|
|
71
72
|
}
|
|
@@ -80,7 +81,7 @@ function fireClickEvent(element, eventInit) {
|
|
|
80
81
|
function isFocusEventOutside(event, container) {
|
|
81
82
|
const containerElement = container || event.currentTarget;
|
|
82
83
|
const relatedTarget = event.relatedTarget;
|
|
83
|
-
return !relatedTarget || !
|
|
84
|
+
return !relatedTarget || !_FTB5CXVBcjs.contains.call(void 0, containerElement, relatedTarget);
|
|
84
85
|
}
|
|
85
86
|
function queueBeforeEvent(element, type, callback) {
|
|
86
87
|
const raf = requestAnimationFrame(() => {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` if `event` has been fired within a React Portal element.
|
|
3
|
+
*/
|
|
4
|
+
export declare function isPortalEvent(event: Pick<Event, "currentTarget" | "target">): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` if `event.target` and `event.currentTarget` are the same.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSelfTarget(event: Pick<Event, "target" | "currentTarget">): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether the user event is triggering a page navigation in a new tab.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isOpeningInNewTab(event: Pick<MouseEvent, "currentTarget" | "metaKey" | "ctrlKey">): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether the user event is triggering a download.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isDownloading(event: Pick<MouseEvent, "altKey" | "currentTarget">): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Creates and dispatches an event.
|
|
19
|
+
* @example
|
|
20
|
+
* fireEvent(document.getElementById("id"), "blur", {
|
|
21
|
+
* bubbles: true,
|
|
22
|
+
* cancelable: true,
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
25
|
+
export declare function fireEvent(element: Element, type: string, eventInit?: EventInit): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Creates and dispatches a blur event.
|
|
28
|
+
* @example
|
|
29
|
+
* fireBlurEvent(document.getElementById("id"));
|
|
30
|
+
*/
|
|
31
|
+
export declare function fireBlurEvent(element: Element, eventInit?: FocusEventInit): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Creates and dispatches a focus event.
|
|
34
|
+
* @example
|
|
35
|
+
* fireFocusEvent(document.getElementById("id"));
|
|
36
|
+
*/
|
|
37
|
+
export declare function fireFocusEvent(element: Element, eventInit?: FocusEventInit): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Creates and dispatches a keyboard event.
|
|
40
|
+
* @example
|
|
41
|
+
* fireKeyboardEvent(document.getElementById("id"), "keydown", {
|
|
42
|
+
* key: "ArrowDown",
|
|
43
|
+
* shiftKey: true,
|
|
44
|
+
* });
|
|
45
|
+
*/
|
|
46
|
+
export declare function fireKeyboardEvent(element: Element, type: string, eventInit?: KeyboardEventInit): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Creates and dispatches a click event.
|
|
49
|
+
* @example
|
|
50
|
+
* fireClickEvent(document.getElementById("id"));
|
|
51
|
+
*/
|
|
52
|
+
export declare function fireClickEvent(element: Element, eventInit?: PointerEventInit): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Checks whether the focus/blur event is happening from/to outside of the
|
|
55
|
+
* container element.
|
|
56
|
+
* @example
|
|
57
|
+
* const element = document.getElementById("id");
|
|
58
|
+
* element.addEventListener("blur", (event) => {
|
|
59
|
+
* if (isFocusEventOutside(event)) {
|
|
60
|
+
* // ...
|
|
61
|
+
* }
|
|
62
|
+
* });
|
|
63
|
+
*/
|
|
64
|
+
export declare function isFocusEventOutside(event: Pick<FocusEvent, "currentTarget" | "relatedTarget">, container?: Element | null): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Runs a callback on the next animation frame, but before a certain event.
|
|
67
|
+
*/
|
|
68
|
+
export declare function queueBeforeEvent(element: Element, type: string, callback: () => void): number;
|
|
69
|
+
export declare function addGlobalEventListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
|
|
70
|
+
export declare function addGlobalEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
|
package/cjs/utils/focus.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _EXM2AW52cjs = require('../__chunks/EXM2AW52.cjs');
|
|
9
8
|
|
|
9
|
+
var _FTB5CXVBcjs = require('../__chunks/FTB5CXVB.cjs');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.cjs');
|
|
12
13
|
|
|
13
14
|
// src/utils/focus.ts
|
|
14
15
|
var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
|
|
@@ -17,11 +18,11 @@ function hasNegativeTabIndex(element) {
|
|
|
17
18
|
return tabIndex < 0;
|
|
18
19
|
}
|
|
19
20
|
function isFocusable(element) {
|
|
20
|
-
if (!
|
|
21
|
+
if (!_FTB5CXVBcjs.matches.call(void 0, element, selector))
|
|
21
22
|
return false;
|
|
22
|
-
if (!
|
|
23
|
+
if (!_FTB5CXVBcjs.isVisible.call(void 0, element))
|
|
23
24
|
return false;
|
|
24
|
-
if (
|
|
25
|
+
if (_FTB5CXVBcjs.closest.call(void 0, element, "[inert]"))
|
|
25
26
|
return false;
|
|
26
27
|
return true;
|
|
27
28
|
}
|
|
@@ -43,7 +44,7 @@ function isTabbable(element) {
|
|
|
43
44
|
return true;
|
|
44
45
|
if (!("length" in radioGroup))
|
|
45
46
|
return true;
|
|
46
|
-
const activeElement =
|
|
47
|
+
const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, element);
|
|
47
48
|
if (!activeElement)
|
|
48
49
|
return true;
|
|
49
50
|
if (activeElement === element)
|
|
@@ -65,7 +66,7 @@ function getAllFocusableIn(container, includeContainer) {
|
|
|
65
66
|
}
|
|
66
67
|
const focusableElements = elements.filter(isFocusable);
|
|
67
68
|
focusableElements.forEach((element, i) => {
|
|
68
|
-
if (
|
|
69
|
+
if (_FTB5CXVBcjs.isFrame.call(void 0, element) && element.contentDocument) {
|
|
69
70
|
const frameBody = element.contentDocument.body;
|
|
70
71
|
focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody));
|
|
71
72
|
}
|
|
@@ -91,7 +92,7 @@ function getAllTabbableIn(container, includeContainer, fallbackToFocusable) {
|
|
|
91
92
|
tabbableElements.unshift(container);
|
|
92
93
|
}
|
|
93
94
|
tabbableElements.forEach((element, i) => {
|
|
94
|
-
if (
|
|
95
|
+
if (_FTB5CXVBcjs.isFrame.call(void 0, element) && element.contentDocument) {
|
|
95
96
|
const frameBody = element.contentDocument.body;
|
|
96
97
|
const allFrameTabbable = getAllTabbableIn(
|
|
97
98
|
frameBody,
|
|
@@ -132,7 +133,7 @@ function getLastTabbable(fallbackToFocusable) {
|
|
|
132
133
|
return getLastTabbableIn(document.body, false, fallbackToFocusable);
|
|
133
134
|
}
|
|
134
135
|
function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) {
|
|
135
|
-
const activeElement =
|
|
136
|
+
const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, container);
|
|
136
137
|
const allFocusable = getAllFocusableIn(container, includeContainer);
|
|
137
138
|
const activeIndex = allFocusable.indexOf(activeElement);
|
|
138
139
|
const nextFocusableElements = allFocusable.slice(activeIndex + 1);
|
|
@@ -147,7 +148,7 @@ function getNextTabbable(fallbackToFirst, fallbackToFocusable) {
|
|
|
147
148
|
);
|
|
148
149
|
}
|
|
149
150
|
function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) {
|
|
150
|
-
const activeElement =
|
|
151
|
+
const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, container);
|
|
151
152
|
const allFocusable = getAllFocusableIn(container, includeContainer).reverse();
|
|
152
153
|
const activeIndex = allFocusable.indexOf(activeElement);
|
|
153
154
|
const previousFocusableElements = allFocusable.slice(activeIndex + 1);
|
|
@@ -163,12 +164,12 @@ function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) {
|
|
|
163
164
|
}
|
|
164
165
|
function getClosestFocusable(element) {
|
|
165
166
|
while (element && !isFocusable(element)) {
|
|
166
|
-
element =
|
|
167
|
+
element = _FTB5CXVBcjs.closest.call(void 0, element, selector);
|
|
167
168
|
}
|
|
168
169
|
return element || null;
|
|
169
170
|
}
|
|
170
171
|
function hasFocus(element) {
|
|
171
|
-
const activeElement =
|
|
172
|
+
const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, element);
|
|
172
173
|
if (!activeElement)
|
|
173
174
|
return false;
|
|
174
175
|
if (activeElement === element)
|
|
@@ -179,10 +180,10 @@ function hasFocus(element) {
|
|
|
179
180
|
return activeDescendant === element.id;
|
|
180
181
|
}
|
|
181
182
|
function hasFocusWithin(element) {
|
|
182
|
-
const activeElement =
|
|
183
|
+
const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, element);
|
|
183
184
|
if (!activeElement)
|
|
184
185
|
return false;
|
|
185
|
-
if (
|
|
186
|
+
if (_FTB5CXVBcjs.contains.call(void 0, element, activeElement))
|
|
186
187
|
return true;
|
|
187
188
|
const activeDescendant = activeElement.getAttribute("aria-activedescendant");
|
|
188
189
|
if (!activeDescendant)
|
|
@@ -229,7 +230,7 @@ function focusIntoView(element, options) {
|
|
|
229
230
|
element.focus();
|
|
230
231
|
} else {
|
|
231
232
|
element.focus({ preventScroll: true });
|
|
232
|
-
element.scrollIntoView(
|
|
233
|
+
element.scrollIntoView(_WYXAWBLEcjs.__spreadValues.call(void 0, { block: "nearest", inline: "nearest" }, options));
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
|