@ariakit/core 0.4.7 → 0.4.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 +5 -0
- package/cjs/__chunks/{M2NNCFIJ.cjs → 3QF3ODTR.cjs} +31 -50
- package/cjs/__chunks/{LPDHSEHU.cjs → 7CES7GVE.cjs} +4 -8
- package/cjs/__chunks/{Q2WCPTYS.cjs → 7WYII4AN.cjs} +6 -12
- package/cjs/__chunks/{EEDWPDM2.cjs → BTUHABP4.cjs} +16 -30
- package/cjs/__chunks/{3COGJMN3.cjs → CCI5VM7E.cjs} +24 -30
- package/cjs/__chunks/{MB5TLEVH.cjs → H6ZQSQQL.cjs} +16 -16
- package/cjs/__chunks/{D7M2PCAQ.cjs → KCEXELK7.cjs} +6 -7
- package/cjs/__chunks/{DIYYVJDK.cjs → N667HVED.cjs} +2 -2
- package/cjs/__chunks/{LBFF2BBK.cjs → PW36G76L.cjs} +25 -29
- package/cjs/__chunks/{LAYUSNGM.cjs → QLWAGBAQ.cjs} +20 -22
- package/cjs/__chunks/{5BQ2XS3R.cjs → VJAE2Y4T.cjs} +10 -10
- package/cjs/__chunks/XIZWLBI2.cjs +42 -0
- package/cjs/checkbox/checkbox-store.cjs +7 -7
- package/cjs/collection/collection-store.cjs +6 -6
- package/cjs/combobox/combobox-store.cjs +50 -56
- package/cjs/composite/composite-overflow-store.cjs +7 -7
- package/cjs/composite/composite-store.cjs +7 -7
- package/cjs/dialog/dialog-store.cjs +6 -6
- package/cjs/disclosure/disclosure-store.cjs +5 -5
- package/cjs/form/form-store.cjs +32 -36
- package/cjs/hovercard/hovercard-store.cjs +8 -8
- package/cjs/index.cjs +1 -1
- package/cjs/menu/menu-bar-store.cjs +8 -8
- package/cjs/menu/menu-store.cjs +37 -42
- package/cjs/menubar/menubar-store.cjs +8 -8
- package/cjs/popover/popover-store.cjs +7 -7
- package/cjs/radio/radio-store.cjs +13 -13
- package/cjs/select/select-store.cjs +49 -62
- package/cjs/tab/tab-store.cjs +49 -61
- package/cjs/tag/tag-store.cjs +23 -27
- package/cjs/toolbar/toolbar-store.cjs +9 -9
- package/cjs/tooltip/tooltip-store.cjs +15 -15
- package/cjs/utils/array.cjs +1 -1
- package/cjs/utils/dom.cjs +3 -3
- package/cjs/utils/events.cjs +22 -36
- package/cjs/utils/focus.cjs +34 -58
- package/cjs/utils/misc.cjs +3 -3
- package/cjs/utils/misc.d.cts +1 -1
- package/cjs/utils/misc.d.ts +1 -1
- package/cjs/utils/platform.cjs +4 -4
- package/cjs/utils/store.cjs +4 -4
- package/cjs/utils/undo.cjs +3 -3
- package/esm/__chunks/{SAZZJI72.js → 3UYWTADI.js} +4 -4
- package/esm/__chunks/{I2WJ7JBQ.js → 6DHTHWXD.js} +10 -16
- package/esm/__chunks/{KDSZSVV5.js → 6E4KKOSB.js} +5 -7
- package/esm/__chunks/{EKIWAN6A.js → 7LM4Q2XB.js} +4 -8
- package/esm/__chunks/{VH2P7HEP.js → D7EIQZAU.js} +8 -12
- package/esm/__chunks/{E4HA32QI.js → EACLTACN.js} +4 -4
- package/esm/__chunks/{KLPDXTDE.js → EQQLU3CG.js} +21 -40
- package/esm/__chunks/{I2NJJ3XW.js → HWOIWM4O.js} +6 -12
- package/esm/__chunks/{22HHDS5F.js → PBFD2E7P.js} +15 -29
- package/esm/__chunks/{RCLYDUHE.js → PIWLWQMB.js} +4 -4
- package/esm/__chunks/{CLSHHUGK.js → US4USQPI.js} +2 -3
- package/esm/__chunks/{NWACXGIN.js → YOHCVXJB.js} +1 -1
- package/esm/checkbox/checkbox-store.js +3 -3
- package/esm/collection/collection-store.js +5 -5
- package/esm/combobox/combobox-store.js +16 -22
- package/esm/composite/composite-overflow-store.js +6 -6
- package/esm/composite/composite-store.js +6 -6
- package/esm/dialog/dialog-store.js +5 -5
- package/esm/disclosure/disclosure-store.js +4 -4
- package/esm/form/form-store.js +9 -13
- package/esm/hovercard/hovercard-store.js +7 -7
- package/esm/index.js +1 -1
- package/esm/menu/menu-bar-store.js +7 -7
- package/esm/menu/menu-store.js +15 -20
- package/esm/menubar/menubar-store.js +7 -7
- package/esm/popover/popover-store.js +6 -6
- package/esm/radio/radio-store.js +6 -6
- package/esm/select/select-store.js +22 -35
- package/esm/tab/tab-store.js +18 -30
- package/esm/tag/tag-store.js +11 -15
- package/esm/toolbar/toolbar-store.js +6 -6
- package/esm/tooltip/tooltip-store.js +7 -7
- package/esm/utils/array.js +1 -1
- package/esm/utils/dom.js +2 -2
- package/esm/utils/events.js +17 -31
- package/esm/utils/focus.js +26 -50
- package/esm/utils/misc.d.ts +1 -1
- package/esm/utils/misc.js +2 -2
- package/esm/utils/platform.js +3 -3
- package/esm/utils/store.js +3 -3
- package/esm/utils/undo.js +2 -2
- package/package.json +1 -1
- package/readme.md +18 -0
- package/cjs/__chunks/XVL5HZ27.cjs +0 -42
- /package/cjs/__chunks/{AV6KTKLE.cjs → 3IVNQNIV.cjs} +0 -0
- /package/esm/__chunks/{4R3V3JGP.js → 3YLGPPWQ.js} +0 -0
package/esm/utils/focus.js
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
getActiveElement,
|
|
5
5
|
isFrame,
|
|
6
6
|
isVisible
|
|
7
|
-
} from "../__chunks/
|
|
7
|
+
} from "../__chunks/HWOIWM4O.js";
|
|
8
8
|
import {
|
|
9
9
|
__spreadValues
|
|
10
|
-
} from "../__chunks/
|
|
10
|
+
} from "../__chunks/3YLGPPWQ.js";
|
|
11
11
|
|
|
12
12
|
// src/utils/focus.ts
|
|
13
13
|
var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
|
|
@@ -16,43 +16,27 @@ function hasNegativeTabIndex(element) {
|
|
|
16
16
|
return tabIndex < 0;
|
|
17
17
|
}
|
|
18
18
|
function isFocusable(element) {
|
|
19
|
-
if (!element.matches(selector))
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
return false;
|
|
23
|
-
if (element.closest("[inert]"))
|
|
24
|
-
return false;
|
|
19
|
+
if (!element.matches(selector)) return false;
|
|
20
|
+
if (!isVisible(element)) return false;
|
|
21
|
+
if (element.closest("[inert]")) return false;
|
|
25
22
|
return true;
|
|
26
23
|
}
|
|
27
24
|
function isTabbable(element) {
|
|
28
|
-
if (!isFocusable(element))
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
if (!element.form)
|
|
35
|
-
return true;
|
|
36
|
-
if (element.checked)
|
|
37
|
-
return true;
|
|
38
|
-
if (element.type !== "radio")
|
|
39
|
-
return true;
|
|
25
|
+
if (!isFocusable(element)) return false;
|
|
26
|
+
if (hasNegativeTabIndex(element)) return false;
|
|
27
|
+
if (!("form" in element)) return true;
|
|
28
|
+
if (!element.form) return true;
|
|
29
|
+
if (element.checked) return true;
|
|
30
|
+
if (element.type !== "radio") return true;
|
|
40
31
|
const radioGroup = element.form.elements.namedItem(element.name);
|
|
41
|
-
if (!radioGroup)
|
|
42
|
-
|
|
43
|
-
if (!("length" in radioGroup))
|
|
44
|
-
return true;
|
|
32
|
+
if (!radioGroup) return true;
|
|
33
|
+
if (!("length" in radioGroup)) return true;
|
|
45
34
|
const activeElement = getActiveElement(element);
|
|
46
|
-
if (!activeElement)
|
|
47
|
-
|
|
48
|
-
if (activeElement
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
return true;
|
|
52
|
-
if (activeElement.form !== element.form)
|
|
53
|
-
return true;
|
|
54
|
-
if (activeElement.name !== element.name)
|
|
55
|
-
return true;
|
|
35
|
+
if (!activeElement) return true;
|
|
36
|
+
if (activeElement === element) return true;
|
|
37
|
+
if (!("form" in activeElement)) return true;
|
|
38
|
+
if (activeElement.form !== element.form) return true;
|
|
39
|
+
if (activeElement.name !== element.name) return true;
|
|
56
40
|
return false;
|
|
57
41
|
}
|
|
58
42
|
function getAllFocusableIn(container, includeContainer) {
|
|
@@ -168,28 +152,20 @@ function getClosestFocusable(element) {
|
|
|
168
152
|
}
|
|
169
153
|
function hasFocus(element) {
|
|
170
154
|
const activeElement = getActiveElement(element);
|
|
171
|
-
if (!activeElement)
|
|
172
|
-
|
|
173
|
-
if (activeElement === element)
|
|
174
|
-
return true;
|
|
155
|
+
if (!activeElement) return false;
|
|
156
|
+
if (activeElement === element) return true;
|
|
175
157
|
const activeDescendant = activeElement.getAttribute("aria-activedescendant");
|
|
176
|
-
if (!activeDescendant)
|
|
177
|
-
return false;
|
|
158
|
+
if (!activeDescendant) return false;
|
|
178
159
|
return activeDescendant === element.id;
|
|
179
160
|
}
|
|
180
161
|
function hasFocusWithin(element) {
|
|
181
162
|
const activeElement = getActiveElement(element);
|
|
182
|
-
if (!activeElement)
|
|
183
|
-
|
|
184
|
-
if (contains(element, activeElement))
|
|
185
|
-
return true;
|
|
163
|
+
if (!activeElement) return false;
|
|
164
|
+
if (contains(element, activeElement)) return true;
|
|
186
165
|
const activeDescendant = activeElement.getAttribute("aria-activedescendant");
|
|
187
|
-
if (!activeDescendant)
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
return false;
|
|
191
|
-
if (activeDescendant === element.id)
|
|
192
|
-
return true;
|
|
166
|
+
if (!activeDescendant) return false;
|
|
167
|
+
if (!("id" in element)) return false;
|
|
168
|
+
if (activeDescendant === element.id) return true;
|
|
193
169
|
return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
|
|
194
170
|
}
|
|
195
171
|
function focusIfNeeded(element) {
|
package/esm/utils/misc.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export declare function invariant(condition: any, message?: string | boolean): a
|
|
|
99
99
|
/**
|
|
100
100
|
* Similar to `Object.keys` but returns a type-safe array of keys.
|
|
101
101
|
*/
|
|
102
|
-
export declare function getKeys<T extends object>(obj: T):
|
|
102
|
+
export declare function getKeys<T extends object>(obj: T): Array<keyof T>;
|
|
103
103
|
/**
|
|
104
104
|
* Checks whether a boolean event prop (e.g., hideOnInteractOutside) was
|
|
105
105
|
* intentionally set to false, either with a boolean value or a callback that
|
package/esm/utils/misc.js
CHANGED
package/esm/utils/platform.js
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
isMac,
|
|
6
6
|
isSafari,
|
|
7
7
|
isTouchDevice
|
|
8
|
-
} from "../__chunks/
|
|
9
|
-
import "../__chunks/
|
|
10
|
-
import "../__chunks/
|
|
8
|
+
} from "../__chunks/US4USQPI.js";
|
|
9
|
+
import "../__chunks/HWOIWM4O.js";
|
|
10
|
+
import "../__chunks/3YLGPPWQ.js";
|
|
11
11
|
export {
|
|
12
12
|
isApple,
|
|
13
13
|
isFirefox,
|
package/esm/utils/store.js
CHANGED
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
subscribe,
|
|
11
11
|
sync,
|
|
12
12
|
throwOnConflictingProps
|
|
13
|
-
} from "../__chunks/
|
|
14
|
-
import "../__chunks/
|
|
15
|
-
import "../__chunks/
|
|
13
|
+
} from "../__chunks/EQQLU3CG.js";
|
|
14
|
+
import "../__chunks/PBFD2E7P.js";
|
|
15
|
+
import "../__chunks/3YLGPPWQ.js";
|
|
16
16
|
export {
|
|
17
17
|
batch,
|
|
18
18
|
createStore,
|
package/esm/utils/undo.js
CHANGED
package/package.json
CHANGED
package/readme.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Ariakit Core
|
|
2
|
+
|
|
3
|
+
**Important:** This package is an internal dependency of Ariakit and does not follow semantic versioning, meaning breaking changes may occur in patch and minor versions. You probably want to use [`@ariakit/react`](https://npmjs.org/package/@ariakit/react) instead.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm i @ariakit/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Core Team
|
|
12
|
+
|
|
13
|
+
- [Diego Haz](https://x.com/diegohaz)
|
|
14
|
+
- [Ben Rodri](https://x.com/benrodrs)
|
|
15
|
+
|
|
16
|
+
## Contributing
|
|
17
|
+
|
|
18
|
+
Follow the instructions on the [contributing guide](https://github.com/ariakit/ariakit/blob/main/contributing.md).
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _MB5TLEVHcjs = require('./MB5TLEVH.cjs');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _M2NNCFIJcjs = require('./M2NNCFIJ.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _EEDWPDM2cjs = require('./EEDWPDM2.cjs');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _AV6KTKLEcjs = require('./AV6KTKLE.cjs');
|
|
15
|
-
|
|
16
|
-
// src/hovercard/hovercard-store.ts
|
|
17
|
-
function createHovercardStore(props = {}) {
|
|
18
|
-
var _a;
|
|
19
|
-
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
20
|
-
const popover = _MB5TLEVHcjs.createPopoverStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
21
|
-
placement: _EEDWPDM2cjs.defaultValue.call(void 0,
|
|
22
|
-
props.placement,
|
|
23
|
-
syncState == null ? void 0 : syncState.placement,
|
|
24
|
-
"bottom"
|
|
25
|
-
)
|
|
26
|
-
}));
|
|
27
|
-
const timeout = _EEDWPDM2cjs.defaultValue.call(void 0, props.timeout, syncState == null ? void 0 : syncState.timeout, 500);
|
|
28
|
-
const initialState = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, popover.getState()), {
|
|
29
|
-
timeout,
|
|
30
|
-
showTimeout: _EEDWPDM2cjs.defaultValue.call(void 0, props.showTimeout, syncState == null ? void 0 : syncState.showTimeout),
|
|
31
|
-
hideTimeout: _EEDWPDM2cjs.defaultValue.call(void 0, props.hideTimeout, syncState == null ? void 0 : syncState.hideTimeout),
|
|
32
|
-
autoFocusOnShow: _EEDWPDM2cjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.autoFocusOnShow, false)
|
|
33
|
-
});
|
|
34
|
-
const hovercard = _M2NNCFIJcjs.createStore.call(void 0, initialState, popover, props.store);
|
|
35
|
-
return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, popover), hovercard), {
|
|
36
|
-
setAutoFocusOnShow: (value) => hovercard.setState("autoFocusOnShow", value)
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
exports.createHovercardStore = createHovercardStore;
|
|
File without changes
|
|
File without changes
|