@ariakit/core 0.4.4 → 0.4.6
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 +17 -0
- package/cjs/__chunks/{Y7KNI5NS.cjs → 3HYNC3XA.cjs} +5 -5
- package/cjs/__chunks/{FFZYCAXA.cjs → 4W3OYRR3.cjs} +2 -2
- package/cjs/__chunks/{SU2BSHGB.cjs → B4AKUC4S.cjs} +2 -2
- package/cjs/__chunks/{7DU6YMLQ.cjs → D7M2PCAQ.cjs} +6 -6
- package/cjs/__chunks/LPDHSEHU.cjs +71 -0
- package/cjs/__chunks/{UKR6TQI3.cjs → Q2WCPTYS.cjs} +37 -39
- package/cjs/checkbox/checkbox-store.d.cts +2 -2
- package/cjs/checkbox/checkbox-store.d.ts +2 -2
- package/cjs/collection/collection-store.cjs +3 -3
- package/cjs/collection/collection-store.d.cts +2 -2
- package/cjs/collection/collection-store.d.ts +2 -2
- package/cjs/combobox/combobox-store.cjs +50 -22
- package/cjs/combobox/combobox-store.d.cts +20 -9
- package/cjs/combobox/combobox-store.d.ts +20 -9
- package/cjs/composite/composite-overflow-store.d.cts +2 -2
- package/cjs/composite/composite-overflow-store.d.ts +2 -2
- package/cjs/composite/composite-store.cjs +5 -5
- package/cjs/composite/composite-store.d.cts +3 -3
- package/cjs/composite/composite-store.d.ts +3 -3
- package/cjs/dialog/dialog-store.d.cts +2 -2
- package/cjs/dialog/dialog-store.d.ts +2 -2
- package/cjs/disclosure/disclosure-store.d.cts +2 -2
- package/cjs/disclosure/disclosure-store.d.ts +2 -2
- package/cjs/form/form-store.cjs +3 -3
- package/cjs/form/form-store.d.cts +4 -4
- package/cjs/form/form-store.d.ts +4 -4
- package/cjs/form/types.d.cts +3 -3
- package/cjs/form/types.d.ts +3 -3
- package/cjs/hovercard/hovercard-store.d.cts +3 -3
- package/cjs/hovercard/hovercard-store.d.ts +3 -3
- package/cjs/menu/menu-bar-store.cjs +6 -6
- package/cjs/menu/menu-bar-store.d.cts +2 -2
- package/cjs/menu/menu-bar-store.d.ts +2 -2
- package/cjs/menu/menu-store.cjs +7 -7
- package/cjs/menu/menu-store.d.cts +6 -6
- package/cjs/menu/menu-store.d.ts +6 -6
- package/cjs/menubar/menubar-store.cjs +6 -6
- package/cjs/menubar/menubar-store.d.cts +2 -2
- package/cjs/menubar/menubar-store.d.ts +2 -2
- package/cjs/popover/popover-store.d.cts +3 -3
- package/cjs/popover/popover-store.d.ts +3 -3
- package/cjs/radio/radio-store.cjs +5 -5
- package/cjs/radio/radio-store.d.cts +3 -3
- package/cjs/radio/radio-store.d.ts +3 -3
- package/cjs/select/select-store.cjs +21 -11
- package/cjs/select/select-store.d.cts +17 -9
- package/cjs/select/select-store.d.ts +17 -9
- package/cjs/tab/tab-store.cjs +46 -13
- package/cjs/tab/tab-store.d.cts +7 -6
- package/cjs/tab/tab-store.d.ts +7 -6
- package/cjs/tag/tag-store.cjs +90 -0
- package/cjs/tag/tag-store.d.cts +80 -0
- package/cjs/tag/tag-store.d.ts +80 -0
- package/cjs/toolbar/toolbar-store.cjs +5 -5
- package/cjs/toolbar/toolbar-store.d.cts +2 -2
- package/cjs/toolbar/toolbar-store.d.ts +2 -2
- package/cjs/tooltip/tooltip-store.d.cts +2 -2
- package/cjs/tooltip/tooltip-store.d.ts +2 -2
- package/cjs/utils/dom.cjs +2 -2
- package/cjs/utils/dom.d.cts +15 -22
- package/cjs/utils/dom.d.ts +15 -22
- package/cjs/utils/events.cjs +32 -16
- package/cjs/utils/events.d.cts +7 -1
- package/cjs/utils/events.d.ts +7 -1
- package/cjs/utils/focus.cjs +13 -15
- package/cjs/utils/focus.d.cts +1 -1
- package/cjs/utils/focus.d.ts +1 -1
- package/cjs/utils/misc.d.cts +1 -1
- package/cjs/utils/misc.d.ts +1 -1
- package/cjs/utils/platform.cjs +3 -3
- package/cjs/utils/store.d.cts +3 -3
- package/cjs/utils/store.d.ts +3 -3
- package/cjs/utils/undo.cjs +10 -0
- package/cjs/utils/undo.d.cts +19 -0
- package/cjs/utils/undo.d.ts +19 -0
- package/esm/__chunks/{VDNATJW2.js → CLSHHUGK.js} +1 -1
- package/esm/__chunks/EKIWAN6A.js +71 -0
- package/esm/__chunks/{URUD7X4C.js → EQPTKGFA.js} +1 -1
- package/esm/__chunks/{RRSZHCH6.js → I2NJJ3XW.js} +39 -41
- package/esm/__chunks/{PXYVPXSS.js → P3MTNH46.js} +1 -1
- package/esm/__chunks/{2H5K47H4.js → PBSSD2DM.js} +5 -5
- package/esm/checkbox/checkbox-store.d.ts +2 -2
- package/esm/collection/collection-store.d.ts +2 -2
- package/esm/collection/collection-store.js +2 -2
- package/esm/combobox/combobox-store.d.ts +20 -9
- package/esm/combobox/combobox-store.js +52 -24
- package/esm/composite/composite-overflow-store.d.ts +2 -2
- package/esm/composite/composite-store.d.ts +3 -3
- package/esm/composite/composite-store.js +4 -4
- package/esm/dialog/dialog-store.d.ts +2 -2
- package/esm/disclosure/disclosure-store.d.ts +2 -2
- package/esm/form/form-store.d.ts +4 -4
- package/esm/form/form-store.js +2 -2
- package/esm/form/types.d.ts +3 -3
- package/esm/hovercard/hovercard-store.d.ts +3 -3
- package/esm/menu/menu-bar-store.d.ts +2 -2
- package/esm/menu/menu-bar-store.js +5 -5
- package/esm/menu/menu-store.d.ts +6 -6
- package/esm/menu/menu-store.js +6 -6
- package/esm/menubar/menubar-store.d.ts +2 -2
- package/esm/menubar/menubar-store.js +5 -5
- package/esm/popover/popover-store.d.ts +3 -3
- package/esm/radio/radio-store.d.ts +3 -3
- package/esm/radio/radio-store.js +4 -4
- package/esm/select/select-store.d.ts +17 -9
- package/esm/select/select-store.js +20 -10
- package/esm/tab/tab-store.d.ts +7 -6
- package/esm/tab/tab-store.js +44 -11
- package/esm/tag/tag-store.d.ts +80 -0
- package/esm/tag/tag-store.js +90 -0
- package/esm/toolbar/toolbar-store.d.ts +2 -2
- package/esm/toolbar/toolbar-store.js +4 -4
- package/esm/tooltip/tooltip-store.d.ts +2 -2
- package/esm/utils/dom.d.ts +15 -22
- package/esm/utils/dom.js +5 -5
- package/esm/utils/events.d.ts +7 -1
- package/esm/utils/events.js +28 -12
- package/esm/utils/focus.d.ts +1 -1
- package/esm/utils/focus.js +5 -7
- package/esm/utils/misc.d.ts +1 -1
- package/esm/utils/platform.js +2 -2
- package/esm/utils/store.d.ts +3 -3
- package/esm/utils/undo.d.ts +19 -0
- package/esm/utils/undo.js +10 -0
- package/package.json +15 -1
- package/tag/tag-store/package.json +8 -0
- package/utils/undo/package.json +8 -0
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 _D7M2PCAQcjs = require('../__chunks/D7M2PCAQ.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _Q2WCPTYScjs = require('../__chunks/Q2WCPTYS.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 && !_Q2WCPTYScjs.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 = _D7M2PCAQcjs.isApple.call(void 0, );
|
|
27
27
|
if (isAppleDevice && !event.metaKey)
|
|
28
28
|
return false;
|
|
29
29
|
if (!isAppleDevice && !event.ctrlKey)
|
|
@@ -81,22 +81,37 @@ 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 || !_Q2WCPTYScjs.contains.call(void 0, containerElement, relatedTarget);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
const
|
|
88
|
-
|
|
86
|
+
function getInputType(event) {
|
|
87
|
+
const nativeEvent = "nativeEvent" in event ? event.nativeEvent : event;
|
|
88
|
+
if (!nativeEvent)
|
|
89
|
+
return;
|
|
90
|
+
if (!("inputType" in nativeEvent))
|
|
91
|
+
return;
|
|
92
|
+
if (typeof nativeEvent.inputType !== "string")
|
|
93
|
+
return;
|
|
94
|
+
return nativeEvent.inputType;
|
|
95
|
+
}
|
|
96
|
+
function queueBeforeEvent(element, type, callback, timeout) {
|
|
97
|
+
const createTimer = (callback2) => {
|
|
98
|
+
if (timeout) {
|
|
99
|
+
const timerId2 = setTimeout(callback2, timeout);
|
|
100
|
+
return () => clearTimeout(timerId2);
|
|
101
|
+
}
|
|
102
|
+
const timerId = requestAnimationFrame(callback2);
|
|
103
|
+
return () => cancelAnimationFrame(timerId);
|
|
104
|
+
};
|
|
105
|
+
const cancelTimer = createTimer(() => {
|
|
106
|
+
element.removeEventListener(type, callSync, true);
|
|
89
107
|
callback();
|
|
90
108
|
});
|
|
91
|
-
const
|
|
92
|
-
|
|
109
|
+
const callSync = () => {
|
|
110
|
+
cancelTimer();
|
|
93
111
|
callback();
|
|
94
112
|
};
|
|
95
|
-
element.addEventListener(type,
|
|
96
|
-
|
|
97
|
-
capture: true
|
|
98
|
-
});
|
|
99
|
-
return raf;
|
|
113
|
+
element.addEventListener(type, callSync, { once: true, capture: true });
|
|
114
|
+
return cancelTimer;
|
|
100
115
|
}
|
|
101
116
|
function addGlobalEventListener(type, listener, options, scope = window) {
|
|
102
117
|
const children = [];
|
|
@@ -129,4 +144,5 @@ function addGlobalEventListener(type, listener, options, scope = window) {
|
|
|
129
144
|
|
|
130
145
|
|
|
131
146
|
|
|
132
|
-
|
|
147
|
+
|
|
148
|
+
exports.addGlobalEventListener = addGlobalEventListener; exports.fireBlurEvent = fireBlurEvent; exports.fireClickEvent = fireClickEvent; exports.fireEvent = fireEvent; exports.fireFocusEvent = fireFocusEvent; exports.fireKeyboardEvent = fireKeyboardEvent; exports.getInputType = getInputType; exports.isDownloading = isDownloading; exports.isFocusEventOutside = isFocusEventOutside; exports.isOpeningInNewTab = isOpeningInNewTab; exports.isPortalEvent = isPortalEvent; exports.isSelfTarget = isSelfTarget; exports.queueBeforeEvent = queueBeforeEvent;
|
package/cjs/utils/events.d.cts
CHANGED
|
@@ -62,9 +62,15 @@ export declare function fireClickEvent(element: Element, eventInit?: PointerEven
|
|
|
62
62
|
* });
|
|
63
63
|
*/
|
|
64
64
|
export declare function isFocusEventOutside(event: Pick<FocusEvent, "currentTarget" | "relatedTarget">, container?: Element | null): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the `inputType` property of the event, if available.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getInputType(event: Event | {
|
|
69
|
+
nativeEvent: Event;
|
|
70
|
+
}): string | undefined;
|
|
65
71
|
/**
|
|
66
72
|
* Runs a callback on the next animation frame, but before a certain event.
|
|
67
73
|
*/
|
|
68
|
-
export declare function queueBeforeEvent(element: Element, type: string, callback: () => void):
|
|
74
|
+
export declare function queueBeforeEvent(element: Element, type: string, callback: () => void, timeout?: number): () => void;
|
|
69
75
|
export declare function addGlobalEventListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
|
|
70
76
|
export declare function addGlobalEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
|
package/cjs/utils/events.d.ts
CHANGED
|
@@ -62,9 +62,15 @@ export declare function fireClickEvent(element: Element, eventInit?: PointerEven
|
|
|
62
62
|
* });
|
|
63
63
|
*/
|
|
64
64
|
export declare function isFocusEventOutside(event: Pick<FocusEvent, "currentTarget" | "relatedTarget">, container?: Element | null): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the `inputType` property of the event, if available.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getInputType(event: Event | {
|
|
69
|
+
nativeEvent: Event;
|
|
70
|
+
}): string | undefined;
|
|
65
71
|
/**
|
|
66
72
|
* Runs a callback on the next animation frame, but before a certain event.
|
|
67
73
|
*/
|
|
68
|
-
export declare function queueBeforeEvent(element: Element, type: string, callback: () => void):
|
|
74
|
+
export declare function queueBeforeEvent(element: Element, type: string, callback: () => void, timeout?: number): () => void;
|
|
69
75
|
export declare function addGlobalEventListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
|
|
70
76
|
export declare function addGlobalEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
|
package/cjs/utils/focus.cjs
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _UKR6TQI3cjs = require('../__chunks/UKR6TQI3.cjs');
|
|
7
|
+
var _Q2WCPTYScjs = require('../__chunks/Q2WCPTYS.cjs');
|
|
10
8
|
|
|
11
9
|
|
|
12
10
|
var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
|
|
@@ -18,11 +16,11 @@ function hasNegativeTabIndex(element) {
|
|
|
18
16
|
return tabIndex < 0;
|
|
19
17
|
}
|
|
20
18
|
function isFocusable(element) {
|
|
21
|
-
if (!
|
|
19
|
+
if (!element.matches(selector))
|
|
22
20
|
return false;
|
|
23
|
-
if (!
|
|
21
|
+
if (!_Q2WCPTYScjs.isVisible.call(void 0, element))
|
|
24
22
|
return false;
|
|
25
|
-
if (
|
|
23
|
+
if (element.closest("[inert]"))
|
|
26
24
|
return false;
|
|
27
25
|
return true;
|
|
28
26
|
}
|
|
@@ -44,7 +42,7 @@ function isTabbable(element) {
|
|
|
44
42
|
return true;
|
|
45
43
|
if (!("length" in radioGroup))
|
|
46
44
|
return true;
|
|
47
|
-
const activeElement =
|
|
45
|
+
const activeElement = _Q2WCPTYScjs.getActiveElement.call(void 0, element);
|
|
48
46
|
if (!activeElement)
|
|
49
47
|
return true;
|
|
50
48
|
if (activeElement === element)
|
|
@@ -66,7 +64,7 @@ function getAllFocusableIn(container, includeContainer) {
|
|
|
66
64
|
}
|
|
67
65
|
const focusableElements = elements.filter(isFocusable);
|
|
68
66
|
focusableElements.forEach((element, i) => {
|
|
69
|
-
if (
|
|
67
|
+
if (_Q2WCPTYScjs.isFrame.call(void 0, element) && element.contentDocument) {
|
|
70
68
|
const frameBody = element.contentDocument.body;
|
|
71
69
|
focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody));
|
|
72
70
|
}
|
|
@@ -92,7 +90,7 @@ function getAllTabbableIn(container, includeContainer, fallbackToFocusable) {
|
|
|
92
90
|
tabbableElements.unshift(container);
|
|
93
91
|
}
|
|
94
92
|
tabbableElements.forEach((element, i) => {
|
|
95
|
-
if (
|
|
93
|
+
if (_Q2WCPTYScjs.isFrame.call(void 0, element) && element.contentDocument) {
|
|
96
94
|
const frameBody = element.contentDocument.body;
|
|
97
95
|
const allFrameTabbable = getAllTabbableIn(
|
|
98
96
|
frameBody,
|
|
@@ -133,7 +131,7 @@ function getLastTabbable(fallbackToFocusable) {
|
|
|
133
131
|
return getLastTabbableIn(document.body, false, fallbackToFocusable);
|
|
134
132
|
}
|
|
135
133
|
function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) {
|
|
136
|
-
const activeElement =
|
|
134
|
+
const activeElement = _Q2WCPTYScjs.getActiveElement.call(void 0, container);
|
|
137
135
|
const allFocusable = getAllFocusableIn(container, includeContainer);
|
|
138
136
|
const activeIndex = allFocusable.indexOf(activeElement);
|
|
139
137
|
const nextFocusableElements = allFocusable.slice(activeIndex + 1);
|
|
@@ -148,7 +146,7 @@ function getNextTabbable(fallbackToFirst, fallbackToFocusable) {
|
|
|
148
146
|
);
|
|
149
147
|
}
|
|
150
148
|
function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) {
|
|
151
|
-
const activeElement =
|
|
149
|
+
const activeElement = _Q2WCPTYScjs.getActiveElement.call(void 0, container);
|
|
152
150
|
const allFocusable = getAllFocusableIn(container, includeContainer).reverse();
|
|
153
151
|
const activeIndex = allFocusable.indexOf(activeElement);
|
|
154
152
|
const previousFocusableElements = allFocusable.slice(activeIndex + 1);
|
|
@@ -164,12 +162,12 @@ function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) {
|
|
|
164
162
|
}
|
|
165
163
|
function getClosestFocusable(element) {
|
|
166
164
|
while (element && !isFocusable(element)) {
|
|
167
|
-
element =
|
|
165
|
+
element = element.closest(selector);
|
|
168
166
|
}
|
|
169
167
|
return element || null;
|
|
170
168
|
}
|
|
171
169
|
function hasFocus(element) {
|
|
172
|
-
const activeElement =
|
|
170
|
+
const activeElement = _Q2WCPTYScjs.getActiveElement.call(void 0, element);
|
|
173
171
|
if (!activeElement)
|
|
174
172
|
return false;
|
|
175
173
|
if (activeElement === element)
|
|
@@ -180,10 +178,10 @@ function hasFocus(element) {
|
|
|
180
178
|
return activeDescendant === element.id;
|
|
181
179
|
}
|
|
182
180
|
function hasFocusWithin(element) {
|
|
183
|
-
const activeElement =
|
|
181
|
+
const activeElement = _Q2WCPTYScjs.getActiveElement.call(void 0, element);
|
|
184
182
|
if (!activeElement)
|
|
185
183
|
return false;
|
|
186
|
-
if (
|
|
184
|
+
if (_Q2WCPTYScjs.contains.call(void 0, element, activeElement))
|
|
187
185
|
return true;
|
|
188
186
|
const activeDescendant = activeElement.getAttribute("aria-activedescendant");
|
|
189
187
|
if (!activeDescendant)
|
package/cjs/utils/focus.d.cts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* isFocusable(document.querySelector("input[hidden]")); // false
|
|
7
7
|
* isFocusable(document.querySelector("input:disabled")); // false
|
|
8
8
|
*/
|
|
9
|
-
export declare function isFocusable(element: Element):
|
|
9
|
+
export declare function isFocusable(element: Element): boolean;
|
|
10
10
|
/**
|
|
11
11
|
* Checks whether `element` is tabbable or not.
|
|
12
12
|
* @example
|
package/cjs/utils/focus.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* isFocusable(document.querySelector("input[hidden]")); // false
|
|
7
7
|
* isFocusable(document.querySelector("input:disabled")); // false
|
|
8
8
|
*/
|
|
9
|
-
export declare function isFocusable(element: Element):
|
|
9
|
+
export declare function isFocusable(element: Element): boolean;
|
|
10
10
|
/**
|
|
11
11
|
* Checks whether `element` is tabbable or not.
|
|
12
12
|
* @example
|
package/cjs/utils/misc.d.cts
CHANGED
package/cjs/utils/misc.d.ts
CHANGED
package/cjs/utils/platform.cjs
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('../__chunks/
|
|
8
|
+
var _D7M2PCAQcjs = require('../__chunks/D7M2PCAQ.cjs');
|
|
9
|
+
require('../__chunks/Q2WCPTYS.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 = _D7M2PCAQcjs.isApple; exports.isFirefox = _D7M2PCAQcjs.isFirefox; exports.isMac = _D7M2PCAQcjs.isMac; exports.isSafari = _D7M2PCAQcjs.isSafari; exports.isTouchDevice = _D7M2PCAQcjs.isTouchDevice;
|
package/cjs/utils/store.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyObject, SetStateAction } from "./types.
|
|
1
|
+
import type { AnyObject, SetStateAction } from "./types.ts";
|
|
2
2
|
type Listener<S> = (state: S, prevState: S) => void | (() => void);
|
|
3
3
|
type Sync<S, K extends keyof S> = (keys: K[] | null, listener: Listener<Pick<S, K>>) => () => void;
|
|
4
4
|
type StoreSetup = (callback: () => void | (() => void)) => () => void;
|
|
@@ -43,7 +43,7 @@ export type StoreOptions<S extends State, K extends keyof S> = Partial<Pick<S, K
|
|
|
43
43
|
* Props that can be passed to a store creator function.
|
|
44
44
|
* @template S State type.
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export interface StoreProps<S extends State = State> {
|
|
47
47
|
/**
|
|
48
48
|
* Another store object that will be kept in sync with the original store.
|
|
49
49
|
*
|
|
@@ -51,7 +51,7 @@ export type StoreProps<S extends State = State> = {
|
|
|
51
51
|
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
52
52
|
*/
|
|
53
53
|
store?: Store<Partial<S>>;
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
/**
|
|
56
56
|
* Extracts the state type from a store type.
|
|
57
57
|
* @template T Store type.
|
package/cjs/utils/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyObject, SetStateAction } from "./types.
|
|
1
|
+
import type { AnyObject, SetStateAction } from "./types.ts";
|
|
2
2
|
type Listener<S> = (state: S, prevState: S) => void | (() => void);
|
|
3
3
|
type Sync<S, K extends keyof S> = (keys: K[] | null, listener: Listener<Pick<S, K>>) => () => void;
|
|
4
4
|
type StoreSetup = (callback: () => void | (() => void)) => () => void;
|
|
@@ -43,7 +43,7 @@ export type StoreOptions<S extends State, K extends keyof S> = Partial<Pick<S, K
|
|
|
43
43
|
* Props that can be passed to a store creator function.
|
|
44
44
|
* @template S State type.
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export interface StoreProps<S extends State = State> {
|
|
47
47
|
/**
|
|
48
48
|
* Another store object that will be kept in sync with the original store.
|
|
49
49
|
*
|
|
@@ -51,7 +51,7 @@ export type StoreProps<S extends State = State> = {
|
|
|
51
51
|
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
52
52
|
*/
|
|
53
53
|
store?: Store<Partial<S>>;
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
/**
|
|
56
56
|
* Extracts the state type from a store type.
|
|
57
57
|
* @template T Store type.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _LPDHSEHUcjs = require('../__chunks/LPDHSEHU.cjs');
|
|
6
|
+
require('../__chunks/AV6KTKLE.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.UndoManager = _LPDHSEHUcjs.UndoManager; exports.createUndoManager = _LPDHSEHUcjs.createUndoManager;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type Callback = void | (() => Callback | Promise<Callback>);
|
|
2
|
+
interface CreateUndoManagerOptions {
|
|
3
|
+
limit?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const UndoManager: {
|
|
6
|
+
canUndo: () => boolean;
|
|
7
|
+
canRedo: () => boolean;
|
|
8
|
+
undo: () => Promise<void>;
|
|
9
|
+
redo: () => Promise<void>;
|
|
10
|
+
execute: (callback: Callback, group?: string) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare function createUndoManager({ limit, }?: CreateUndoManagerOptions): {
|
|
13
|
+
canUndo: () => boolean;
|
|
14
|
+
canRedo: () => boolean;
|
|
15
|
+
undo: () => Promise<void>;
|
|
16
|
+
redo: () => Promise<void>;
|
|
17
|
+
execute: (callback: Callback, group?: string) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type Callback = void | (() => Callback | Promise<Callback>);
|
|
2
|
+
interface CreateUndoManagerOptions {
|
|
3
|
+
limit?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const UndoManager: {
|
|
6
|
+
canUndo: () => boolean;
|
|
7
|
+
canRedo: () => boolean;
|
|
8
|
+
undo: () => Promise<void>;
|
|
9
|
+
redo: () => Promise<void>;
|
|
10
|
+
execute: (callback: Callback, group?: string) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare function createUndoManager({ limit, }?: CreateUndoManagerOptions): {
|
|
13
|
+
canUndo: () => boolean;
|
|
14
|
+
canRedo: () => boolean;
|
|
15
|
+
undo: () => Promise<void>;
|
|
16
|
+
redo: () => Promise<void>;
|
|
17
|
+
execute: (callback: Callback, group?: string) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/utils/undo.ts
|
|
4
|
+
function createUndoCallback(callback) {
|
|
5
|
+
return async () => {
|
|
6
|
+
const redo = await (callback == null ? void 0 : callback());
|
|
7
|
+
return createUndoCallback(async () => {
|
|
8
|
+
await (redo == null ? void 0 : redo());
|
|
9
|
+
return callback;
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
var UndoManager = createUndoManager();
|
|
14
|
+
function createUndoManager({
|
|
15
|
+
limit = 100
|
|
16
|
+
} = {}) {
|
|
17
|
+
const undoStack = [];
|
|
18
|
+
let redoStack = [];
|
|
19
|
+
let currentGroup = null;
|
|
20
|
+
const canUndo = () => undoStack.length > 0;
|
|
21
|
+
const canRedo = () => redoStack.length > 0;
|
|
22
|
+
const undo = async () => {
|
|
23
|
+
var _a;
|
|
24
|
+
if (!canUndo())
|
|
25
|
+
return;
|
|
26
|
+
currentGroup = null;
|
|
27
|
+
redoStack.push(await ((_a = undoStack.pop()) == null ? void 0 : _a()));
|
|
28
|
+
};
|
|
29
|
+
const redo = async () => {
|
|
30
|
+
var _a;
|
|
31
|
+
if (!canRedo())
|
|
32
|
+
return;
|
|
33
|
+
currentGroup = null;
|
|
34
|
+
undoStack.push(await ((_a = redoStack.pop()) == null ? void 0 : _a()));
|
|
35
|
+
};
|
|
36
|
+
const execute = async (callback, group) => {
|
|
37
|
+
if (!callback)
|
|
38
|
+
return;
|
|
39
|
+
while (undoStack.length > limit) {
|
|
40
|
+
undoStack.shift();
|
|
41
|
+
}
|
|
42
|
+
const sameGroup = group === currentGroup;
|
|
43
|
+
currentGroup = group != null ? group : null;
|
|
44
|
+
const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
|
|
45
|
+
const undoCallback = await callback();
|
|
46
|
+
if (!undoCallback)
|
|
47
|
+
return;
|
|
48
|
+
redoStack = [];
|
|
49
|
+
const currentUndo = undoStack[nextIndex];
|
|
50
|
+
undoStack[nextIndex] = createUndoCallback(async () => {
|
|
51
|
+
await (undoCallback == null ? void 0 : undoCallback());
|
|
52
|
+
const currentRedo = await (currentUndo == null ? void 0 : currentUndo());
|
|
53
|
+
return async () => {
|
|
54
|
+
await (currentRedo == null ? void 0 : currentRedo());
|
|
55
|
+
await (callback == null ? void 0 : callback());
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
canUndo,
|
|
61
|
+
canRedo,
|
|
62
|
+
undo,
|
|
63
|
+
redo,
|
|
64
|
+
execute
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
UndoManager,
|
|
70
|
+
createUndoManager
|
|
71
|
+
};
|
|
@@ -57,29 +57,13 @@ var buttonInputTypes = [
|
|
|
57
57
|
"reset",
|
|
58
58
|
"submit"
|
|
59
59
|
];
|
|
60
|
-
function matches(element, selectors) {
|
|
61
|
-
if ("matches" in element) {
|
|
62
|
-
return element.matches(selectors);
|
|
63
|
-
}
|
|
64
|
-
if ("msMatchesSelector" in element) {
|
|
65
|
-
return element.msMatchesSelector(selectors);
|
|
66
|
-
}
|
|
67
|
-
return element.webkitMatchesSelector(selectors);
|
|
68
|
-
}
|
|
69
60
|
function isVisible(element) {
|
|
61
|
+
if (typeof element.checkVisibility === "function") {
|
|
62
|
+
return element.checkVisibility();
|
|
63
|
+
}
|
|
70
64
|
const htmlElement = element;
|
|
71
65
|
return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
|
|
72
66
|
}
|
|
73
|
-
function closest(element, selectors) {
|
|
74
|
-
if ("closest" in element)
|
|
75
|
-
return element.closest(selectors);
|
|
76
|
-
do {
|
|
77
|
-
if (matches(element, selectors))
|
|
78
|
-
return element;
|
|
79
|
-
element = element.parentElement || element.parentNode;
|
|
80
|
-
} while (element !== null && element.nodeType === 1);
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
67
|
function isTextField(element) {
|
|
84
68
|
try {
|
|
85
69
|
const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
|
|
@@ -89,26 +73,19 @@ function isTextField(element) {
|
|
|
89
73
|
return false;
|
|
90
74
|
}
|
|
91
75
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
const role = element == null ? void 0 : element.getAttribute("role");
|
|
95
|
-
if (role && allowedPopupRoles.indexOf(role) !== -1) {
|
|
96
|
-
return role;
|
|
97
|
-
}
|
|
98
|
-
return fallback;
|
|
76
|
+
function isTextbox(element) {
|
|
77
|
+
return element.isContentEditable || isTextField(element);
|
|
99
78
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const key = popupRole;
|
|
111
|
-
return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback;
|
|
79
|
+
function getTextboxValue(element) {
|
|
80
|
+
if (isTextField(element)) {
|
|
81
|
+
return element.value;
|
|
82
|
+
}
|
|
83
|
+
if (element.isContentEditable) {
|
|
84
|
+
const range = getDocument(element).createRange();
|
|
85
|
+
range.selectNodeContents(element);
|
|
86
|
+
return range.toString();
|
|
87
|
+
}
|
|
88
|
+
return "";
|
|
112
89
|
}
|
|
113
90
|
function getTextboxSelection(element) {
|
|
114
91
|
let start = 0;
|
|
@@ -130,6 +107,27 @@ function getTextboxSelection(element) {
|
|
|
130
107
|
}
|
|
131
108
|
return { start, end };
|
|
132
109
|
}
|
|
110
|
+
function getPopupRole(element, fallback) {
|
|
111
|
+
const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
|
|
112
|
+
const role = element == null ? void 0 : element.getAttribute("role");
|
|
113
|
+
if (role && allowedPopupRoles.indexOf(role) !== -1) {
|
|
114
|
+
return role;
|
|
115
|
+
}
|
|
116
|
+
return fallback;
|
|
117
|
+
}
|
|
118
|
+
function getPopupItemRole(element, fallback) {
|
|
119
|
+
var _a;
|
|
120
|
+
const itemRoleByPopupRole = {
|
|
121
|
+
menu: "menuitem",
|
|
122
|
+
listbox: "option",
|
|
123
|
+
tree: "treeitem"
|
|
124
|
+
};
|
|
125
|
+
const popupRole = getPopupRole(element);
|
|
126
|
+
if (!popupRole)
|
|
127
|
+
return fallback;
|
|
128
|
+
const key = popupRole;
|
|
129
|
+
return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback;
|
|
130
|
+
}
|
|
133
131
|
function scrollIntoViewIfNeeded(element, arg) {
|
|
134
132
|
if (isPartiallyHidden(element) && "scrollIntoView" in element) {
|
|
135
133
|
element.scrollIntoView(arg);
|
|
@@ -182,13 +180,13 @@ export {
|
|
|
182
180
|
contains,
|
|
183
181
|
isFrame,
|
|
184
182
|
isButton,
|
|
185
|
-
matches,
|
|
186
183
|
isVisible,
|
|
187
|
-
closest,
|
|
188
184
|
isTextField,
|
|
185
|
+
isTextbox,
|
|
186
|
+
getTextboxValue,
|
|
187
|
+
getTextboxSelection,
|
|
189
188
|
getPopupRole,
|
|
190
189
|
getPopupItemRole,
|
|
191
|
-
getTextboxSelection,
|
|
192
190
|
scrollIntoViewIfNeeded,
|
|
193
191
|
getScrollingElement,
|
|
194
192
|
isPartiallyHidden,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createCollectionStore
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./EQPTKGFA.js";
|
|
5
|
+
import {
|
|
6
|
+
flatten2DArray,
|
|
7
|
+
reverseArray
|
|
8
|
+
} from "./7PRQYBBV.js";
|
|
5
9
|
import {
|
|
6
10
|
createStore,
|
|
7
11
|
setup,
|
|
@@ -10,10 +14,6 @@ import {
|
|
|
10
14
|
import {
|
|
11
15
|
defaultValue
|
|
12
16
|
} from "./22HHDS5F.js";
|
|
13
|
-
import {
|
|
14
|
-
flatten2DArray,
|
|
15
|
-
reverseArray
|
|
16
|
-
} from "./7PRQYBBV.js";
|
|
17
17
|
import {
|
|
18
18
|
__spreadProps,
|
|
19
19
|
__spreadValues
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Store, StoreOptions, StoreProps } from "../utils/store.
|
|
2
|
-
import type { PickRequired, SetState, ToPrimitive } from "../utils/types.
|
|
1
|
+
import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
|
|
2
|
+
import type { PickRequired, SetState, ToPrimitive } from "../utils/types.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a checkbox store.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Store, StoreOptions, StoreProps } from "../utils/store.
|
|
2
|
-
import type { BivariantCallback } from "../utils/types.
|
|
1
|
+
import type { Store, StoreOptions, StoreProps } from "../utils/store.ts";
|
|
2
|
+
import type { BivariantCallback } from "../utils/types.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a collection store.
|
|
5
5
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createCollectionStore
|
|
4
|
-
} from "../__chunks/
|
|
4
|
+
} from "../__chunks/EQPTKGFA.js";
|
|
5
5
|
import "../__chunks/R676XYVY.js";
|
|
6
6
|
import "../__chunks/22HHDS5F.js";
|
|
7
|
-
import "../__chunks/
|
|
7
|
+
import "../__chunks/I2NJJ3XW.js";
|
|
8
8
|
import "../__chunks/4R3V3JGP.js";
|
|
9
9
|
export {
|
|
10
10
|
createCollectionStore
|