@ariakit/core 0.3.5 → 0.3.7
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 +18 -0
- package/cjs/__chunks/{FJSZTIOU.cjs → 46BH65MC.cjs} +4 -6
- package/cjs/__chunks/{FTB5CXVB.cjs → 5F4DVUNS.cjs} +7 -1
- package/cjs/__chunks/{AR2VJ37F.cjs → 6WBY3ZZM.cjs} +6 -6
- package/cjs/__chunks/{HOEZKRUM.cjs → 7ZUFMSXJ.cjs} +7 -7
- package/cjs/__chunks/{F5YZIIEA.cjs → GXIZMD53.cjs} +8 -2
- package/cjs/__chunks/{MYTMMWXI.cjs → GZDVJEID.cjs} +2 -2
- package/cjs/__chunks/{FFY2GSOG.cjs → JLC5A6WF.cjs} +8 -8
- package/cjs/__chunks/{F6Q5QSXF.cjs → MEHGRTJ3.cjs} +11 -11
- package/cjs/__chunks/{XVR5QRC3.cjs → PD7XZBXC.cjs} +4 -4
- package/cjs/__chunks/{G5EW4WED.cjs → YIUPKKEK.cjs} +6 -6
- package/cjs/checkbox/checkbox-store.cjs +3 -3
- package/cjs/collection/collection-store.cjs +4 -4
- package/cjs/collection/collection-store.d.cts +6 -4
- package/cjs/collection/collection-store.d.ts +6 -4
- package/cjs/combobox/combobox-store.cjs +48 -26
- package/cjs/combobox/combobox-store.d.cts +69 -21
- package/cjs/combobox/combobox-store.d.ts +69 -21
- package/cjs/composite/composite-overflow-store.cjs +5 -5
- package/cjs/composite/composite-store.cjs +5 -5
- package/cjs/composite/composite-store.d.cts +6 -8
- package/cjs/composite/composite-store.d.ts +6 -8
- package/cjs/dialog/dialog-store.cjs +4 -4
- package/cjs/disclosure/disclosure-store.cjs +3 -3
- package/cjs/disclosure/disclosure-store.d.cts +2 -0
- package/cjs/disclosure/disclosure-store.d.ts +2 -0
- package/cjs/form/form-store.cjs +8 -8
- package/cjs/hovercard/hovercard-store.cjs +6 -6
- package/cjs/hovercard/hovercard-store.d.cts +6 -0
- package/cjs/hovercard/hovercard-store.d.ts +6 -0
- package/cjs/menu/menu-bar-store.cjs +6 -6
- package/cjs/menu/menu-store.cjs +19 -19
- package/cjs/menubar/menubar-store.cjs +6 -6
- package/cjs/menubar/menubar-store.d.cts +12 -6
- package/cjs/menubar/menubar-store.d.ts +12 -6
- package/cjs/popover/popover-store.cjs +5 -5
- package/cjs/popover/popover-store.d.cts +3 -0
- package/cjs/popover/popover-store.d.ts +3 -0
- package/cjs/radio/radio-store.cjs +6 -6
- package/cjs/select/select-store.cjs +19 -19
- package/cjs/select/select-store.d.cts +28 -18
- package/cjs/select/select-store.d.ts +28 -18
- package/cjs/tab/tab-store.cjs +16 -16
- package/cjs/toolbar/toolbar-store.cjs +5 -5
- package/cjs/tooltip/tooltip-store.cjs +7 -7
- package/cjs/utils/dom.cjs +4 -2
- package/cjs/utils/dom.d.cts +9 -0
- package/cjs/utils/dom.d.ts +9 -0
- package/cjs/utils/events.cjs +5 -5
- package/cjs/utils/focus.cjs +13 -13
- package/cjs/utils/platform.cjs +3 -3
- package/cjs/utils/store.cjs +2 -2
- package/cjs/utils/store.d.cts +3 -0
- package/cjs/utils/store.d.ts +3 -0
- package/esm/__chunks/{6LSGADQM.js → ANO6WJO4.js} +8 -2
- package/esm/__chunks/{EIFVU736.js → BXH3I7ML.js} +2 -2
- package/esm/__chunks/{6EMNXRG3.js → CCU5UHQ2.js} +2 -2
- package/esm/__chunks/{DREIYIMP.js → CL47ZAPY.js} +1 -1
- package/esm/__chunks/{NIF7E7VE.js → DLOEKDPY.js} +7 -1
- package/esm/__chunks/{PCA5ARZU.js → DYD4YNLE.js} +1 -1
- package/esm/__chunks/{HJS6GJT4.js → E7OQVGGY.js} +4 -6
- package/esm/__chunks/{5UJPJ37G.js → MHPO2BXA.js} +1 -1
- package/esm/__chunks/{5BWT4GY2.js → OGMLJYDV.js} +2 -2
- package/esm/__chunks/{MRBDYBGO.js → WY3EMTH6.js} +2 -2
- package/esm/checkbox/checkbox-store.js +1 -1
- package/esm/collection/collection-store.d.ts +6 -4
- package/esm/collection/collection-store.js +3 -3
- package/esm/combobox/combobox-store.d.ts +69 -21
- package/esm/combobox/combobox-store.js +35 -13
- package/esm/composite/composite-overflow-store.js +4 -4
- package/esm/composite/composite-store.d.ts +6 -8
- package/esm/composite/composite-store.js +4 -4
- package/esm/dialog/dialog-store.js +3 -3
- package/esm/disclosure/disclosure-store.d.ts +2 -0
- package/esm/disclosure/disclosure-store.js +2 -2
- package/esm/form/form-store.js +3 -3
- package/esm/hovercard/hovercard-store.d.ts +6 -0
- package/esm/hovercard/hovercard-store.js +5 -5
- package/esm/menu/menu-bar-store.js +5 -5
- package/esm/menu/menu-store.js +8 -8
- package/esm/menubar/menubar-store.d.ts +12 -6
- package/esm/menubar/menubar-store.js +5 -5
- package/esm/popover/popover-store.d.ts +3 -0
- package/esm/popover/popover-store.js +4 -4
- package/esm/radio/radio-store.js +4 -4
- package/esm/select/select-store.d.ts +28 -18
- package/esm/select/select-store.js +7 -7
- package/esm/tab/tab-store.js +4 -4
- package/esm/toolbar/toolbar-store.js +4 -4
- package/esm/tooltip/tooltip-store.js +5 -5
- package/esm/utils/dom.d.ts +9 -0
- package/esm/utils/dom.js +5 -3
- package/esm/utils/events.js +2 -2
- package/esm/utils/focus.js +1 -1
- package/esm/utils/platform.js +2 -2
- package/esm/utils/store.d.ts +3 -0
- package/esm/utils/store.js +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
6
|
-
require('../__chunks/
|
|
7
|
-
require('../__chunks/
|
|
4
|
+
var _PD7XZBXCcjs = require('../__chunks/PD7XZBXC.cjs');
|
|
5
|
+
require('../__chunks/7ZUFMSXJ.cjs');
|
|
6
|
+
require('../__chunks/GZDVJEID.cjs');
|
|
7
|
+
require('../__chunks/MEHGRTJ3.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _46BH65MCcjs = require('../__chunks/46BH65MC.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _3UT5FE6Kcjs = require('../__chunks/3UT5FE6K.cjs');
|
|
@@ -20,7 +20,7 @@ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
|
|
|
20
20
|
function createTooltipStore(props = {}) {
|
|
21
21
|
var _a;
|
|
22
22
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
23
|
-
const hovercard =
|
|
23
|
+
const hovercard = _PD7XZBXCcjs.createHovercardStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
24
24
|
placement: _3UT5FE6Kcjs.defaultValue.call(void 0,
|
|
25
25
|
props.placement,
|
|
26
26
|
syncState == null ? void 0 : syncState.placement,
|
|
@@ -32,7 +32,7 @@ function createTooltipStore(props = {}) {
|
|
|
32
32
|
type: _3UT5FE6Kcjs.defaultValue.call(void 0, props.type, syncState == null ? void 0 : syncState.type, "description"),
|
|
33
33
|
skipTimeout: _3UT5FE6Kcjs.defaultValue.call(void 0, props.skipTimeout, syncState == null ? void 0 : syncState.skipTimeout, 300)
|
|
34
34
|
});
|
|
35
|
-
const tooltip =
|
|
35
|
+
const tooltip = _46BH65MCcjs.createStore.call(void 0, initialState, hovercard, props.store);
|
|
36
36
|
return _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, hovercard), tooltip);
|
|
37
37
|
}
|
|
38
38
|
|
package/cjs/utils/dom.cjs
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
var _5F4DVUNScjs = require('../__chunks/5F4DVUNS.cjs');
|
|
21
22
|
require('../__chunks/AV6KTKLE.cjs');
|
|
22
23
|
|
|
23
24
|
|
|
@@ -37,4 +38,5 @@ require('../__chunks/AV6KTKLE.cjs');
|
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
|
|
42
|
+
exports.canUseDOM = _5F4DVUNScjs.canUseDOM; exports.closest = _5F4DVUNScjs.closest; exports.contains = _5F4DVUNScjs.contains; exports.getActiveElement = _5F4DVUNScjs.getActiveElement; exports.getDocument = _5F4DVUNScjs.getDocument; exports.getPopupItemRole = _5F4DVUNScjs.getPopupItemRole; exports.getPopupRole = _5F4DVUNScjs.getPopupRole; exports.getScrollingElement = _5F4DVUNScjs.getScrollingElement; exports.getTextboxSelection = _5F4DVUNScjs.getTextboxSelection; exports.getWindow = _5F4DVUNScjs.getWindow; exports.isButton = _5F4DVUNScjs.isButton; exports.isFrame = _5F4DVUNScjs.isFrame; exports.isPartiallyHidden = _5F4DVUNScjs.isPartiallyHidden; exports.isTextField = _5F4DVUNScjs.isTextField; exports.isVisible = _5F4DVUNScjs.isVisible; exports.matches = _5F4DVUNScjs.matches; exports.scrollIntoViewIfNeeded = _5F4DVUNScjs.scrollIntoViewIfNeeded; exports.setSelectionRange = _5F4DVUNScjs.setSelectionRange;
|
package/cjs/utils/dom.d.cts
CHANGED
|
@@ -103,3 +103,12 @@ export declare function getScrollingElement(element?: Element | null): HTMLEleme
|
|
|
103
103
|
* Determines whether an element is hidden or partially hidden in the viewport.
|
|
104
104
|
*/
|
|
105
105
|
export declare function isPartiallyHidden(element: Element): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* SelectionRange only works on a few types of input.
|
|
108
|
+
* Calling `setSelectionRange` on a unsupported input type may throw an error on certain browsers.
|
|
109
|
+
* To avoid it, we check if its type supports SelectionRange first.
|
|
110
|
+
* It will be a noop to non-supported types until we find a workaround.
|
|
111
|
+
*
|
|
112
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
|
|
113
|
+
*/
|
|
114
|
+
export declare function setSelectionRange(element: HTMLInputElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
|
package/cjs/utils/dom.d.ts
CHANGED
|
@@ -103,3 +103,12 @@ export declare function getScrollingElement(element?: Element | null): HTMLEleme
|
|
|
103
103
|
* Determines whether an element is hidden or partially hidden in the viewport.
|
|
104
104
|
*/
|
|
105
105
|
export declare function isPartiallyHidden(element: Element): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* SelectionRange only works on a few types of input.
|
|
108
|
+
* Calling `setSelectionRange` on a unsupported input type may throw an error on certain browsers.
|
|
109
|
+
* To avoid it, we check if its type supports SelectionRange first.
|
|
110
|
+
* It will be a noop to non-supported types until we find a workaround.
|
|
111
|
+
*
|
|
112
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
|
|
113
|
+
*/
|
|
114
|
+
export declare function setSelectionRange(element: HTMLInputElement, ...args: Parameters<typeof HTMLInputElement.prototype.setSelectionRange>): void;
|
package/cjs/utils/events.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _YIUPKKEKcjs = require('../__chunks/YIUPKKEK.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _5F4DVUNScjs = require('../__chunks/5F4DVUNS.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
|
|
|
13
13
|
// src/utils/events.ts
|
|
14
14
|
function isPortalEvent(event) {
|
|
15
15
|
return Boolean(
|
|
16
|
-
event.currentTarget && !
|
|
16
|
+
event.currentTarget && !_5F4DVUNScjs.contains.call(void 0, event.currentTarget, event.target)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
function isSelfTarget(event) {
|
|
@@ -23,7 +23,7 @@ function isOpeningInNewTab(event) {
|
|
|
23
23
|
const element = event.currentTarget;
|
|
24
24
|
if (!element)
|
|
25
25
|
return false;
|
|
26
|
-
const isAppleDevice =
|
|
26
|
+
const isAppleDevice = _YIUPKKEKcjs.isApple.call(void 0, );
|
|
27
27
|
if (isAppleDevice && !event.metaKey)
|
|
28
28
|
return false;
|
|
29
29
|
if (!isAppleDevice && !event.ctrlKey)
|
|
@@ -81,7 +81,7 @@ function fireClickEvent(element, eventInit) {
|
|
|
81
81
|
function isFocusEventOutside(event, container) {
|
|
82
82
|
const containerElement = container || event.currentTarget;
|
|
83
83
|
const relatedTarget = event.relatedTarget;
|
|
84
|
-
return !relatedTarget || !
|
|
84
|
+
return !relatedTarget || !_5F4DVUNScjs.contains.call(void 0, containerElement, relatedTarget);
|
|
85
85
|
}
|
|
86
86
|
function queueBeforeEvent(element, type, callback) {
|
|
87
87
|
const raf = requestAnimationFrame(() => {
|
package/cjs/utils/focus.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _5F4DVUNScjs = require('../__chunks/5F4DVUNS.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
|
|
@@ -18,11 +18,11 @@ function hasNegativeTabIndex(element) {
|
|
|
18
18
|
return tabIndex < 0;
|
|
19
19
|
}
|
|
20
20
|
function isFocusable(element) {
|
|
21
|
-
if (!
|
|
21
|
+
if (!_5F4DVUNScjs.matches.call(void 0, element, selector))
|
|
22
22
|
return false;
|
|
23
|
-
if (!
|
|
23
|
+
if (!_5F4DVUNScjs.isVisible.call(void 0, element))
|
|
24
24
|
return false;
|
|
25
|
-
if (
|
|
25
|
+
if (_5F4DVUNScjs.closest.call(void 0, element, "[inert]"))
|
|
26
26
|
return false;
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
@@ -44,7 +44,7 @@ function isTabbable(element) {
|
|
|
44
44
|
return true;
|
|
45
45
|
if (!("length" in radioGroup))
|
|
46
46
|
return true;
|
|
47
|
-
const activeElement =
|
|
47
|
+
const activeElement = _5F4DVUNScjs.getActiveElement.call(void 0, element);
|
|
48
48
|
if (!activeElement)
|
|
49
49
|
return true;
|
|
50
50
|
if (activeElement === element)
|
|
@@ -66,7 +66,7 @@ function getAllFocusableIn(container, includeContainer) {
|
|
|
66
66
|
}
|
|
67
67
|
const focusableElements = elements.filter(isFocusable);
|
|
68
68
|
focusableElements.forEach((element, i) => {
|
|
69
|
-
if (
|
|
69
|
+
if (_5F4DVUNScjs.isFrame.call(void 0, element) && element.contentDocument) {
|
|
70
70
|
const frameBody = element.contentDocument.body;
|
|
71
71
|
focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody));
|
|
72
72
|
}
|
|
@@ -92,7 +92,7 @@ function getAllTabbableIn(container, includeContainer, fallbackToFocusable) {
|
|
|
92
92
|
tabbableElements.unshift(container);
|
|
93
93
|
}
|
|
94
94
|
tabbableElements.forEach((element, i) => {
|
|
95
|
-
if (
|
|
95
|
+
if (_5F4DVUNScjs.isFrame.call(void 0, element) && element.contentDocument) {
|
|
96
96
|
const frameBody = element.contentDocument.body;
|
|
97
97
|
const allFrameTabbable = getAllTabbableIn(
|
|
98
98
|
frameBody,
|
|
@@ -133,7 +133,7 @@ function getLastTabbable(fallbackToFocusable) {
|
|
|
133
133
|
return getLastTabbableIn(document.body, false, fallbackToFocusable);
|
|
134
134
|
}
|
|
135
135
|
function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) {
|
|
136
|
-
const activeElement =
|
|
136
|
+
const activeElement = _5F4DVUNScjs.getActiveElement.call(void 0, container);
|
|
137
137
|
const allFocusable = getAllFocusableIn(container, includeContainer);
|
|
138
138
|
const activeIndex = allFocusable.indexOf(activeElement);
|
|
139
139
|
const nextFocusableElements = allFocusable.slice(activeIndex + 1);
|
|
@@ -148,7 +148,7 @@ function getNextTabbable(fallbackToFirst, fallbackToFocusable) {
|
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) {
|
|
151
|
-
const activeElement =
|
|
151
|
+
const activeElement = _5F4DVUNScjs.getActiveElement.call(void 0, container);
|
|
152
152
|
const allFocusable = getAllFocusableIn(container, includeContainer).reverse();
|
|
153
153
|
const activeIndex = allFocusable.indexOf(activeElement);
|
|
154
154
|
const previousFocusableElements = allFocusable.slice(activeIndex + 1);
|
|
@@ -164,12 +164,12 @@ function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) {
|
|
|
164
164
|
}
|
|
165
165
|
function getClosestFocusable(element) {
|
|
166
166
|
while (element && !isFocusable(element)) {
|
|
167
|
-
element =
|
|
167
|
+
element = _5F4DVUNScjs.closest.call(void 0, element, selector);
|
|
168
168
|
}
|
|
169
169
|
return element || null;
|
|
170
170
|
}
|
|
171
171
|
function hasFocus(element) {
|
|
172
|
-
const activeElement =
|
|
172
|
+
const activeElement = _5F4DVUNScjs.getActiveElement.call(void 0, element);
|
|
173
173
|
if (!activeElement)
|
|
174
174
|
return false;
|
|
175
175
|
if (activeElement === element)
|
|
@@ -180,10 +180,10 @@ function hasFocus(element) {
|
|
|
180
180
|
return activeDescendant === element.id;
|
|
181
181
|
}
|
|
182
182
|
function hasFocusWithin(element) {
|
|
183
|
-
const activeElement =
|
|
183
|
+
const activeElement = _5F4DVUNScjs.getActiveElement.call(void 0, element);
|
|
184
184
|
if (!activeElement)
|
|
185
185
|
return false;
|
|
186
|
-
if (
|
|
186
|
+
if (_5F4DVUNScjs.contains.call(void 0, element, activeElement))
|
|
187
187
|
return true;
|
|
188
188
|
const activeDescendant = activeElement.getAttribute("aria-activedescendant");
|
|
189
189
|
if (!activeDescendant)
|
package/cjs/utils/platform.cjs
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('../__chunks/
|
|
8
|
+
var _YIUPKKEKcjs = require('../__chunks/YIUPKKEK.cjs');
|
|
9
|
+
require('../__chunks/5F4DVUNS.cjs');
|
|
10
10
|
require('../__chunks/AV6KTKLE.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
@@ -14,4 +14,4 @@ require('../__chunks/AV6KTKLE.cjs');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
exports.isApple =
|
|
17
|
+
exports.isApple = _YIUPKKEKcjs.isApple; exports.isFirefox = _YIUPKKEKcjs.isFirefox; exports.isMac = _YIUPKKEKcjs.isMac; exports.isSafari = _YIUPKKEKcjs.isSafari; exports.isTouchDevice = _YIUPKKEKcjs.isTouchDevice;
|
package/cjs/utils/store.cjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _46BH65MCcjs = require('../__chunks/46BH65MC.cjs');
|
|
14
14
|
require('../__chunks/3UT5FE6K.cjs');
|
|
15
15
|
require('../__chunks/AV6KTKLE.cjs');
|
|
16
16
|
|
|
@@ -24,4 +24,4 @@ require('../__chunks/AV6KTKLE.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
exports.batch =
|
|
27
|
+
exports.batch = _46BH65MCcjs.batch; exports.createStore = _46BH65MCcjs.createStore; exports.init = _46BH65MCcjs.init; exports.mergeStore = _46BH65MCcjs.mergeStore; exports.omit = _46BH65MCcjs.omit; exports.pick = _46BH65MCcjs.pick; exports.setup = _46BH65MCcjs.setup; exports.subscribe = _46BH65MCcjs.subscribe; exports.sync = _46BH65MCcjs.sync; exports.throwOnConflictingProps = _46BH65MCcjs.throwOnConflictingProps;
|
package/cjs/utils/store.d.cts
CHANGED
|
@@ -46,6 +46,9 @@ export type StoreOptions<S extends State, K extends keyof S> = Partial<Pick<S, K
|
|
|
46
46
|
export type StoreProps<S extends State = State> = {
|
|
47
47
|
/**
|
|
48
48
|
* Another store object that will be kept in sync with the original store.
|
|
49
|
+
*
|
|
50
|
+
* Live examples:
|
|
51
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
49
52
|
*/
|
|
50
53
|
store?: Store<Partial<S>>;
|
|
51
54
|
};
|
package/cjs/utils/store.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ export type StoreOptions<S extends State, K extends keyof S> = Partial<Pick<S, K
|
|
|
46
46
|
export type StoreProps<S extends State = State> = {
|
|
47
47
|
/**
|
|
48
48
|
* Another store object that will be kept in sync with the original store.
|
|
49
|
+
*
|
|
50
|
+
* Live examples:
|
|
51
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
49
52
|
*/
|
|
50
53
|
store?: Store<Partial<S>>;
|
|
51
54
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createCompositeStore
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./OGMLJYDV.js";
|
|
5
|
+
import {
|
|
6
|
+
createStore
|
|
7
|
+
} from "./E7OQVGGY.js";
|
|
5
8
|
import {
|
|
6
9
|
defaultValue
|
|
7
10
|
} from "./I2VQ3XGR.js";
|
|
@@ -14,7 +17,7 @@ import {
|
|
|
14
17
|
function createMenubarStore(props = {}) {
|
|
15
18
|
var _a;
|
|
16
19
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
17
|
-
|
|
20
|
+
const composite = createCompositeStore(__spreadProps(__spreadValues({}, props), {
|
|
18
21
|
orientation: defaultValue(
|
|
19
22
|
props.orientation,
|
|
20
23
|
syncState == null ? void 0 : syncState.orientation,
|
|
@@ -22,6 +25,9 @@ function createMenubarStore(props = {}) {
|
|
|
22
25
|
),
|
|
23
26
|
focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
|
|
24
27
|
}));
|
|
28
|
+
const initialState = __spreadValues({}, composite.getState());
|
|
29
|
+
const menubar = createStore(initialState, composite, props.store);
|
|
30
|
+
return __spreadValues(__spreadValues({}, composite), menubar);
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export {
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
createStore,
|
|
5
5
|
setup,
|
|
6
6
|
throwOnConflictingProps
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./E7OQVGGY.js";
|
|
8
8
|
import {
|
|
9
9
|
chain,
|
|
10
10
|
defaultValue
|
|
11
11
|
} from "./I2VQ3XGR.js";
|
|
12
12
|
import {
|
|
13
13
|
getDocument
|
|
14
|
-
} from "./
|
|
14
|
+
} from "./DLOEKDPY.js";
|
|
15
15
|
import {
|
|
16
16
|
__spreadProps,
|
|
17
17
|
__spreadValues
|
|
@@ -169,6 +169,11 @@ function isPartiallyHidden(element) {
|
|
|
169
169
|
const right = elementRect.right > scrollerRight;
|
|
170
170
|
return top || left || bottom || right;
|
|
171
171
|
}
|
|
172
|
+
function setSelectionRange(element, ...args) {
|
|
173
|
+
if (/text|search|password|tel|url/i.test(element.type)) {
|
|
174
|
+
element.setSelectionRange(...args);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
172
177
|
|
|
173
178
|
export {
|
|
174
179
|
canUseDOM,
|
|
@@ -187,5 +192,6 @@ export {
|
|
|
187
192
|
getTextboxSelection,
|
|
188
193
|
scrollIntoViewIfNeeded,
|
|
189
194
|
getScrollingElement,
|
|
190
|
-
isPartiallyHidden
|
|
195
|
+
isPartiallyHidden,
|
|
196
|
+
setSelectionRange
|
|
191
197
|
};
|
|
@@ -50,17 +50,15 @@ function createStore(initialState, ...stores) {
|
|
|
50
50
|
return;
|
|
51
51
|
if (!hasOwnProperty(storeState, key))
|
|
52
52
|
return;
|
|
53
|
-
return sync(
|
|
54
|
-
|
|
55
|
-
[key],
|
|
56
|
-
(state2) => setState(
|
|
53
|
+
return sync(store, [key], (state2) => {
|
|
54
|
+
setState(
|
|
57
55
|
key,
|
|
58
56
|
state2[key],
|
|
59
57
|
// @ts-expect-error - Not public API. This is just to prevent
|
|
60
58
|
// infinite loops.
|
|
61
59
|
true
|
|
62
|
-
)
|
|
63
|
-
);
|
|
60
|
+
);
|
|
61
|
+
});
|
|
64
62
|
})
|
|
65
63
|
)
|
|
66
64
|
);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createCollectionStore
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./CCU5UHQ2.js";
|
|
5
5
|
import {
|
|
6
6
|
createStore,
|
|
7
7
|
setup,
|
|
8
8
|
sync
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./E7OQVGGY.js";
|
|
10
10
|
import {
|
|
11
11
|
defaultValue
|
|
12
12
|
} from "./I2VQ3XGR.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createDialogStore
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./CL47ZAPY.js";
|
|
5
5
|
import {
|
|
6
6
|
createStore,
|
|
7
7
|
mergeStore,
|
|
8
8
|
omit,
|
|
9
9
|
throwOnConflictingProps
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./E7OQVGGY.js";
|
|
11
11
|
import {
|
|
12
12
|
defaultValue
|
|
13
13
|
} from "./I2VQ3XGR.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
2
2
|
import type { BivariantCallback } from "../utils/types.js";
|
|
3
|
-
|
|
3
|
+
interface Item {
|
|
4
4
|
id: string;
|
|
5
5
|
element?: HTMLElement | null;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
/**
|
|
8
8
|
* Creates a collection store.
|
|
9
9
|
*/
|
|
@@ -60,6 +60,8 @@ export interface CollectionStoreOptions<T extends Item = Item> extends StoreOpti
|
|
|
60
60
|
*/
|
|
61
61
|
defaultItems?: CollectionStoreState<T>["items"];
|
|
62
62
|
}
|
|
63
|
-
export
|
|
64
|
-
|
|
63
|
+
export interface CollectionStoreProps<T extends Item = Item> extends CollectionStoreOptions<T>, StoreProps<CollectionStoreState<T>> {
|
|
64
|
+
}
|
|
65
|
+
export interface CollectionStore<T extends Item = Item> extends CollectionStoreFunctions<T>, Store<CollectionStoreState<T>> {
|
|
66
|
+
}
|
|
65
67
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createCollectionStore
|
|
4
|
-
} from "../__chunks/
|
|
5
|
-
import "../__chunks/
|
|
4
|
+
} from "../__chunks/CCU5UHQ2.js";
|
|
5
|
+
import "../__chunks/E7OQVGGY.js";
|
|
6
6
|
import "../__chunks/I2VQ3XGR.js";
|
|
7
|
-
import "../__chunks/
|
|
7
|
+
import "../__chunks/DLOEKDPY.js";
|
|
8
8
|
import "../__chunks/4R3V3JGP.js";
|
|
9
9
|
export {
|
|
10
10
|
createCollectionStore
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
2
2
|
import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
|
|
3
3
|
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
4
|
-
import type { SetState } from "../utils/types.js";
|
|
5
|
-
type
|
|
4
|
+
import type { PickRequired, SetState } from "../utils/types.js";
|
|
5
|
+
type Value = string | string[];
|
|
6
|
+
type MutableValue<T extends Value = Value> = T extends string ? string : T;
|
|
7
|
+
interface Item extends CompositeStoreItem {
|
|
6
8
|
value?: string;
|
|
7
|
-
}
|
|
9
|
+
}
|
|
8
10
|
/**
|
|
9
11
|
* Creates a combobox store.
|
|
10
12
|
*/
|
|
13
|
+
export declare function createComboboxStore<T extends Value = Value>(props: PickRequired<ComboboxStoreProps<T>, "selectedValue" | "defaultSelectedValue">): ComboboxStore<T>;
|
|
11
14
|
export declare function createComboboxStore(props?: ComboboxStoreProps): ComboboxStore;
|
|
12
15
|
export type ComboboxStoreItem = Item;
|
|
13
|
-
export
|
|
16
|
+
export type ComboboxStoreSelectedValue = Value;
|
|
17
|
+
export interface ComboboxStoreState<T extends Value = Value> extends CompositeStoreState<Item>, PopoverStoreState {
|
|
14
18
|
/**
|
|
15
19
|
* @default true
|
|
16
20
|
*/
|
|
17
21
|
includesBaseElement: boolean;
|
|
18
22
|
/**
|
|
19
|
-
* The input value.
|
|
23
|
+
* The combobox input value.
|
|
20
24
|
*
|
|
21
25
|
* Live examples:
|
|
22
|
-
* - [
|
|
26
|
+
* - [Combobox with integrated
|
|
27
|
+
* filter](https://ariakit.org/examples/combobox-filtering-integrated)
|
|
23
28
|
* - [Combobox with links](https://ariakit.org/examples/combobox-links)
|
|
24
29
|
* - [Combobox filtering](https://ariakit.org/examples/combobox-filtering)
|
|
25
30
|
* - [Multi-selectable
|
|
@@ -33,45 +38,88 @@ export interface ComboboxStoreState extends CompositeStoreState<Item>, PopoverSt
|
|
|
33
38
|
*/
|
|
34
39
|
activeValue: string | undefined;
|
|
35
40
|
/**
|
|
36
|
-
*
|
|
41
|
+
* The value(s) of the currently selected item(s). This can be a string or an
|
|
42
|
+
* array of strings. If it's an array, the combobox is considered
|
|
43
|
+
* [multi-selectable](https://ariakit.org/examples/combobox-multiple).
|
|
44
|
+
*
|
|
45
|
+
* Live examples:
|
|
46
|
+
* - [Multi-selectable
|
|
47
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
48
|
+
*/
|
|
49
|
+
selectedValue: MutableValue<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to reset the value when the combobox popover closes. This prop is
|
|
52
|
+
* automatically set to `true` by default if the combobox supports multiple
|
|
53
|
+
* selections. In other words, if the
|
|
54
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
55
|
+
* or
|
|
56
|
+
* [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
|
|
57
|
+
* props are arrays.
|
|
37
58
|
*
|
|
38
59
|
* Live examples:
|
|
39
60
|
* - [Multi-selectable
|
|
40
61
|
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
41
|
-
*
|
|
62
|
+
* - [Menu with Combobox](https://ariakit.org/examples/menu-combobox)
|
|
63
|
+
* - [Select with Combobox](https://ariakit.org/examples/select-combobox)
|
|
42
64
|
*/
|
|
43
65
|
resetValueOnHide: boolean;
|
|
44
|
-
}
|
|
45
|
-
export interface ComboboxStoreFunctions extends CompositeStoreFunctions<Item>, PopoverStoreFunctions {
|
|
46
66
|
/**
|
|
47
|
-
*
|
|
67
|
+
* Whether to reset the value when an item is selected. This prop is
|
|
68
|
+
* automatically set to `true` by default if the combobox supports multiple
|
|
69
|
+
* selections. In other words, if the
|
|
70
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
71
|
+
* or
|
|
72
|
+
* [`defaultSelectedValue`](https://ariakit.org/reference/combobox-provider#defaultselectedvalue)
|
|
73
|
+
* props are arrays.
|
|
48
74
|
*
|
|
49
75
|
* Live examples:
|
|
50
76
|
* - [Multi-selectable
|
|
51
77
|
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
78
|
+
*/
|
|
79
|
+
resetValueOnSelect: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface ComboboxStoreFunctions<T extends Value = Value> extends CompositeStoreFunctions<Item>, PopoverStoreFunctions {
|
|
82
|
+
/**
|
|
83
|
+
* Sets the [`value`](https://ariakit.org/reference/combobox-provider#value)
|
|
84
|
+
* state.
|
|
85
|
+
*
|
|
86
|
+
* Live examples:
|
|
52
87
|
* - [Textarea with inline
|
|
53
88
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
54
89
|
* @example
|
|
55
90
|
* store.setValue("Hello world");
|
|
56
91
|
* store.setValue((value) => value + "!");
|
|
57
92
|
*/
|
|
58
|
-
setValue: SetState<ComboboxStoreState["value"]>;
|
|
93
|
+
setValue: SetState<ComboboxStoreState<T>["value"]>;
|
|
94
|
+
/**
|
|
95
|
+
* Sets the
|
|
96
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
97
|
+
* state.
|
|
98
|
+
*/
|
|
99
|
+
setSelectedValue: SetState<ComboboxStoreState<T>["selectedValue"]>;
|
|
59
100
|
}
|
|
60
|
-
export interface ComboboxStoreOptions extends StoreOptions<ComboboxStoreState
|
|
101
|
+
export interface ComboboxStoreOptions<T extends Value = Value> extends StoreOptions<ComboboxStoreState<T>, "includesBaseElement" | "value" | "selectedValue" | "resetValueOnHide" | "resetValueOnSelect">, CompositeStoreOptions<Item>, PopoverStoreOptions {
|
|
61
102
|
/**
|
|
62
103
|
* @default null
|
|
63
104
|
*/
|
|
64
105
|
defaultActiveId?: CompositeStoreOptions<Item>["activeId"];
|
|
65
106
|
/**
|
|
66
|
-
* The
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
107
|
+
* The initial value of the combobox input.
|
|
108
|
+
* @default ""
|
|
109
|
+
*/
|
|
110
|
+
defaultValue?: ComboboxStoreState<T>["value"];
|
|
111
|
+
/**
|
|
112
|
+
* The initial value of the
|
|
113
|
+
* [`selectedValue`](https://ariakit.org/reference/combobox-provider#selectedvalue)
|
|
114
|
+
* state. This can be a string or an array of strings. If it's an array, the
|
|
115
|
+
* combobox is considered
|
|
116
|
+
* [multi-selectable](https://ariakit.org/examples/combobox-multiple).
|
|
71
117
|
* @default ""
|
|
72
118
|
*/
|
|
73
|
-
|
|
119
|
+
defaultSelectedValue?: ComboboxStoreState<T>["selectedValue"];
|
|
120
|
+
}
|
|
121
|
+
export interface ComboboxStoreProps<T extends Value = Value> extends ComboboxStoreOptions<T>, StoreProps<ComboboxStoreState<T>> {
|
|
122
|
+
}
|
|
123
|
+
export interface ComboboxStore<T extends Value = Value> extends ComboboxStoreFunctions<T>, Store<ComboboxStoreState<T>> {
|
|
74
124
|
}
|
|
75
|
-
export type ComboboxStoreProps = ComboboxStoreOptions & StoreProps<ComboboxStoreState>;
|
|
76
|
-
export type ComboboxStore = ComboboxStoreFunctions & Store<ComboboxStoreState>;
|
|
77
125
|
export {};
|