@ariakit/core 0.4.6 → 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 +9 -0
- package/cjs/__chunks/{B4LYZ4EM.cjs → 3QF3ODTR.cjs} +44 -61
- 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/{4W3OYRR3.cjs → CCI5VM7E.cjs} +24 -30
- package/cjs/__chunks/{5JEQEZFR.cjs → H6ZQSQQL.cjs} +16 -16
- package/cjs/__chunks/{D7M2PCAQ.cjs → KCEXELK7.cjs} +6 -7
- package/cjs/__chunks/{LTLFSC4X.cjs → N667HVED.cjs} +2 -2
- package/cjs/__chunks/{3HYNC3XA.cjs → PW36G76L.cjs} +25 -29
- package/cjs/__chunks/{AETQC2AR.cjs → QLWAGBAQ.cjs} +20 -22
- package/cjs/__chunks/{B4AKUC4S.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/combobox/combobox-store.d.cts +2 -0
- package/cjs/combobox/combobox-store.d.ts +2 -0
- package/cjs/composite/composite-overflow-store.cjs +7 -7
- package/cjs/composite/composite-store.cjs +7 -7
- package/cjs/composite/composite-store.d.cts +5 -1
- package/cjs/composite/composite-store.d.ts +5 -1
- 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/select/select-store.d.cts +2 -0
- package/cjs/select/select-store.d.ts +2 -0
- package/cjs/tab/tab-store.cjs +49 -61
- package/cjs/tab/tab-store.d.cts +10 -4
- package/cjs/tab/tab-store.d.ts +10 -4
- 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 +25 -37
- package/cjs/utils/focus.cjs +41 -61
- 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/{MFZZDIHG.js → 3UYWTADI.js} +4 -4
- package/esm/__chunks/{EQPTKGFA.js → 6DHTHWXD.js} +10 -16
- package/esm/__chunks/{WCKXDMU7.js → 6E4KKOSB.js} +5 -7
- package/esm/__chunks/{EKIWAN6A.js → 7LM4Q2XB.js} +4 -8
- package/esm/__chunks/{PBSSD2DM.js → D7EIQZAU.js} +8 -12
- package/esm/__chunks/{BRS7GKWU.js → EACLTACN.js} +4 -4
- package/esm/__chunks/{R676XYVY.js → EQQLU3CG.js} +34 -51
- package/esm/__chunks/{I2NJJ3XW.js → HWOIWM4O.js} +6 -12
- package/esm/__chunks/{22HHDS5F.js → PBFD2E7P.js} +15 -29
- package/esm/__chunks/{P3MTNH46.js → PIWLWQMB.js} +4 -4
- package/esm/__chunks/{CLSHHUGK.js → US4USQPI.js} +2 -3
- package/esm/__chunks/{5RJNXXU2.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.d.ts +2 -0
- package/esm/combobox/combobox-store.js +16 -22
- package/esm/composite/composite-overflow-store.js +6 -6
- package/esm/composite/composite-store.d.ts +5 -1
- 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.d.ts +2 -0
- package/esm/select/select-store.js +22 -35
- package/esm/tab/tab-store.d.ts +10 -4
- 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 +20 -32
- package/esm/utils/focus.js +33 -53
- 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 +2 -2
- package/readme.md +18 -0
- package/.eslintignore +0 -6
- package/cjs/__chunks/UEZLSKZ4.cjs +0 -42
- /package/cjs/__chunks/{AV6KTKLE.cjs → 3IVNQNIV.cjs} +0 -0
- /package/esm/__chunks/{4R3V3JGP.js → 3YLGPPWQ.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ariakit/core
|
|
2
2
|
|
|
3
|
+
## 0.4.8
|
|
4
|
+
|
|
5
|
+
- Added a README file to the package.
|
|
6
|
+
- Improved JSDocs.
|
|
7
|
+
|
|
8
|
+
## 0.4.7
|
|
9
|
+
|
|
10
|
+
- Improved JSDocs.
|
|
11
|
+
|
|
3
12
|
## 0.4.6
|
|
4
13
|
|
|
5
14
|
- Ensured [Combobox](https://ariakit.org/components/combobox) uses roving tabindex to manage focus on mobile Safari.
|
|
@@ -8,23 +8,23 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _BTUHABP4cjs = require('./BTUHABP4.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _3IVNQNIVcjs = require('./3IVNQNIV.cjs');
|
|
16
16
|
|
|
17
17
|
// src/utils/store.ts
|
|
18
18
|
function getInternal(store, key) {
|
|
19
19
|
const internals = store.__unstableInternals;
|
|
20
|
-
|
|
20
|
+
_BTUHABP4cjs.invariant.call(void 0, internals, "Invalid store");
|
|
21
21
|
return internals[key];
|
|
22
22
|
}
|
|
23
23
|
function createStore(initialState, ...stores) {
|
|
24
24
|
let state = initialState;
|
|
25
25
|
let prevStateBatch = state;
|
|
26
26
|
let lastUpdate = Symbol();
|
|
27
|
-
let destroy =
|
|
27
|
+
let destroy = _BTUHABP4cjs.noop;
|
|
28
28
|
const instances = /* @__PURE__ */ new Set();
|
|
29
29
|
const updatedKeys = /* @__PURE__ */ new Set();
|
|
30
30
|
const setups = /* @__PURE__ */ new Set();
|
|
@@ -42,21 +42,17 @@ function createStore(initialState, ...stores) {
|
|
|
42
42
|
instances.add(instance);
|
|
43
43
|
const maybeDestroy = () => {
|
|
44
44
|
instances.delete(instance);
|
|
45
|
-
if (instances.size)
|
|
46
|
-
return;
|
|
45
|
+
if (instances.size) return;
|
|
47
46
|
destroy();
|
|
48
47
|
};
|
|
49
|
-
if (initialized)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
(key) => _EEDWPDM2cjs.chain.call(void 0,
|
|
48
|
+
if (initialized) return maybeDestroy;
|
|
49
|
+
const desyncs = _BTUHABP4cjs.getKeys.call(void 0, state).map(
|
|
50
|
+
(key) => _BTUHABP4cjs.chain.call(void 0,
|
|
53
51
|
...stores.map((store) => {
|
|
54
52
|
var _a;
|
|
55
53
|
const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
|
|
56
|
-
if (!storeState)
|
|
57
|
-
|
|
58
|
-
if (!_EEDWPDM2cjs.hasOwnProperty.call(void 0, storeState, key))
|
|
59
|
-
return;
|
|
54
|
+
if (!storeState) return;
|
|
55
|
+
if (!_BTUHABP4cjs.hasOwnProperty.call(void 0, storeState, key)) return;
|
|
60
56
|
return sync(store, [key], (state2) => {
|
|
61
57
|
setState(
|
|
62
58
|
key,
|
|
@@ -70,9 +66,11 @@ function createStore(initialState, ...stores) {
|
|
|
70
66
|
)
|
|
71
67
|
);
|
|
72
68
|
const teardowns = [];
|
|
73
|
-
|
|
69
|
+
for (const setup2 of setups) {
|
|
70
|
+
teardowns.push(setup2());
|
|
71
|
+
}
|
|
74
72
|
const cleanups = stores.map(init);
|
|
75
|
-
destroy =
|
|
73
|
+
destroy = _BTUHABP4cjs.chain.call(void 0, ...desyncs, ...teardowns, ...cleanups);
|
|
76
74
|
return maybeDestroy;
|
|
77
75
|
};
|
|
78
76
|
const sub = (keys, listener, set = listeners) => {
|
|
@@ -95,45 +93,42 @@ function createStore(initialState, ...stores) {
|
|
|
95
93
|
disposables.set(listener, listener(state, prevStateBatch));
|
|
96
94
|
return sub(keys, listener, batchListeners);
|
|
97
95
|
};
|
|
98
|
-
const storePick = (keys) => createStore(
|
|
99
|
-
const storeOmit = (keys) => createStore(
|
|
96
|
+
const storePick = (keys) => createStore(_BTUHABP4cjs.pick.call(void 0, state, keys), finalStore);
|
|
97
|
+
const storeOmit = (keys) => createStore(_BTUHABP4cjs.omit.call(void 0, state, keys), finalStore);
|
|
100
98
|
const getState = () => state;
|
|
101
99
|
const setState = (key, value, fromStores = false) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const nextValue =
|
|
105
|
-
if (nextValue === state[key])
|
|
106
|
-
return;
|
|
100
|
+
var _a;
|
|
101
|
+
if (!_BTUHABP4cjs.hasOwnProperty.call(void 0, state, key)) return;
|
|
102
|
+
const nextValue = _BTUHABP4cjs.applyState.call(void 0, value, state[key]);
|
|
103
|
+
if (nextValue === state[key]) return;
|
|
107
104
|
if (!fromStores) {
|
|
108
|
-
|
|
109
|
-
var _a;
|
|
105
|
+
for (const store of stores) {
|
|
110
106
|
(_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
|
|
111
|
-
}
|
|
107
|
+
}
|
|
112
108
|
}
|
|
113
109
|
const prevState = state;
|
|
114
|
-
state =
|
|
110
|
+
state = _3IVNQNIVcjs.__spreadProps.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, {}, state), { [key]: nextValue });
|
|
115
111
|
const thisUpdate = Symbol();
|
|
116
112
|
lastUpdate = thisUpdate;
|
|
117
113
|
updatedKeys.add(key);
|
|
118
114
|
const run = (listener, prev, uKeys) => {
|
|
119
|
-
var
|
|
115
|
+
var _a2;
|
|
120
116
|
const keys = listenerKeys.get(listener);
|
|
121
117
|
const updated = (k) => uKeys ? uKeys.has(k) : k === key;
|
|
122
118
|
if (!keys || keys.some(updated)) {
|
|
123
|
-
(
|
|
119
|
+
(_a2 = disposables.get(listener)) == null ? void 0 : _a2();
|
|
124
120
|
disposables.set(listener, listener(state, prev));
|
|
125
121
|
}
|
|
126
122
|
};
|
|
127
|
-
|
|
123
|
+
for (const listener of listeners) {
|
|
128
124
|
run(listener, prevState);
|
|
129
|
-
}
|
|
125
|
+
}
|
|
130
126
|
queueMicrotask(() => {
|
|
131
|
-
if (lastUpdate !== thisUpdate)
|
|
132
|
-
return;
|
|
127
|
+
if (lastUpdate !== thisUpdate) return;
|
|
133
128
|
const snapshot = state;
|
|
134
|
-
|
|
129
|
+
for (const listener of batchListeners) {
|
|
135
130
|
run(listener, prevStateBatch, updatedKeys);
|
|
136
|
-
}
|
|
131
|
+
}
|
|
137
132
|
prevStateBatch = snapshot;
|
|
138
133
|
updatedKeys.clear();
|
|
139
134
|
});
|
|
@@ -154,69 +149,57 @@ function createStore(initialState, ...stores) {
|
|
|
154
149
|
return finalStore;
|
|
155
150
|
}
|
|
156
151
|
function setup(store, ...args) {
|
|
157
|
-
if (!store)
|
|
158
|
-
return;
|
|
152
|
+
if (!store) return;
|
|
159
153
|
return getInternal(store, "setup")(...args);
|
|
160
154
|
}
|
|
161
155
|
function init(store, ...args) {
|
|
162
|
-
if (!store)
|
|
163
|
-
return;
|
|
156
|
+
if (!store) return;
|
|
164
157
|
return getInternal(store, "init")(...args);
|
|
165
158
|
}
|
|
166
159
|
function subscribe(store, ...args) {
|
|
167
|
-
if (!store)
|
|
168
|
-
return;
|
|
160
|
+
if (!store) return;
|
|
169
161
|
return getInternal(store, "subscribe")(...args);
|
|
170
162
|
}
|
|
171
163
|
function sync(store, ...args) {
|
|
172
|
-
if (!store)
|
|
173
|
-
return;
|
|
164
|
+
if (!store) return;
|
|
174
165
|
return getInternal(store, "sync")(...args);
|
|
175
166
|
}
|
|
176
167
|
function batch(store, ...args) {
|
|
177
|
-
if (!store)
|
|
178
|
-
return;
|
|
168
|
+
if (!store) return;
|
|
179
169
|
return getInternal(store, "batch")(...args);
|
|
180
170
|
}
|
|
181
171
|
function omit2(store, ...args) {
|
|
182
|
-
if (!store)
|
|
183
|
-
return;
|
|
172
|
+
if (!store) return;
|
|
184
173
|
return getInternal(store, "omit")(...args);
|
|
185
174
|
}
|
|
186
175
|
function pick2(store, ...args) {
|
|
187
|
-
if (!store)
|
|
188
|
-
return;
|
|
176
|
+
if (!store) return;
|
|
189
177
|
return getInternal(store, "pick")(...args);
|
|
190
178
|
}
|
|
191
179
|
function mergeStore(...stores) {
|
|
192
180
|
const initialState = stores.reduce((state, store2) => {
|
|
193
181
|
var _a;
|
|
194
182
|
const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
|
|
195
|
-
if (!nextState)
|
|
196
|
-
|
|
197
|
-
return _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, state), nextState);
|
|
183
|
+
if (!nextState) return state;
|
|
184
|
+
return Object.assign(state, nextState);
|
|
198
185
|
}, {});
|
|
199
186
|
const store = createStore(initialState, ...stores);
|
|
200
187
|
return store;
|
|
201
188
|
}
|
|
202
189
|
function throwOnConflictingProps(props, store) {
|
|
203
|
-
if (process.env.NODE_ENV === "production")
|
|
204
|
-
|
|
205
|
-
if (!store)
|
|
206
|
-
return;
|
|
190
|
+
if (process.env.NODE_ENV === "production") return;
|
|
191
|
+
if (!store) return;
|
|
207
192
|
const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
|
|
208
193
|
var _a;
|
|
209
194
|
const stateKey = key.replace("default", "");
|
|
210
195
|
return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
|
|
211
196
|
});
|
|
212
|
-
if (!defaultKeys.length)
|
|
213
|
-
return;
|
|
197
|
+
if (!defaultKeys.length) return;
|
|
214
198
|
const storeState = store.getState();
|
|
215
199
|
const conflictingProps = defaultKeys.filter(
|
|
216
|
-
(key) =>
|
|
200
|
+
(key) => _BTUHABP4cjs.hasOwnProperty.call(void 0, storeState, key)
|
|
217
201
|
);
|
|
218
|
-
if (!conflictingProps.length)
|
|
219
|
-
return;
|
|
202
|
+
if (!conflictingProps.length) return;
|
|
220
203
|
throw new Error(
|
|
221
204
|
`Passing a store prop in conjunction with a default state is not supported.
|
|
222
205
|
|
|
@@ -21,21 +21,18 @@ function createUndoManager({
|
|
|
21
21
|
const canRedo = () => redoStack.length > 0;
|
|
22
22
|
const undo = async () => {
|
|
23
23
|
var _a;
|
|
24
|
-
if (!canUndo())
|
|
25
|
-
return;
|
|
24
|
+
if (!canUndo()) return;
|
|
26
25
|
currentGroup = null;
|
|
27
26
|
redoStack.push(await ((_a = undoStack.pop()) == null ? void 0 : _a()));
|
|
28
27
|
};
|
|
29
28
|
const redo = async () => {
|
|
30
29
|
var _a;
|
|
31
|
-
if (!canRedo())
|
|
32
|
-
return;
|
|
30
|
+
if (!canRedo()) return;
|
|
33
31
|
currentGroup = null;
|
|
34
32
|
undoStack.push(await ((_a = redoStack.pop()) == null ? void 0 : _a()));
|
|
35
33
|
};
|
|
36
34
|
const execute = async (callback, group) => {
|
|
37
|
-
if (!callback)
|
|
38
|
-
return;
|
|
35
|
+
if (!callback) return;
|
|
39
36
|
while (undoStack.length > limit) {
|
|
40
37
|
undoStack.shift();
|
|
41
38
|
}
|
|
@@ -43,8 +40,7 @@ function createUndoManager({
|
|
|
43
40
|
currentGroup = group != null ? group : null;
|
|
44
41
|
const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
|
|
45
42
|
const undoCallback = await callback();
|
|
46
|
-
if (!undoCallback)
|
|
47
|
-
return;
|
|
43
|
+
if (!undoCallback) return;
|
|
48
44
|
redoStack = [];
|
|
49
45
|
const currentUndo = undoStack[nextIndex];
|
|
50
46
|
undoStack[nextIndex] = createUndoCallback(async () => {
|
|
@@ -42,8 +42,7 @@ function isFrame(element) {
|
|
|
42
42
|
}
|
|
43
43
|
function isButton(element) {
|
|
44
44
|
const tagName = element.tagName.toLowerCase();
|
|
45
|
-
if (tagName === "button")
|
|
46
|
-
return true;
|
|
45
|
+
if (tagName === "button") return true;
|
|
47
46
|
if (tagName === "input" && element.type) {
|
|
48
47
|
return buttonInputTypes.indexOf(element.type) !== -1;
|
|
49
48
|
}
|
|
@@ -123,8 +122,7 @@ function getPopupItemRole(element, fallback) {
|
|
|
123
122
|
tree: "treeitem"
|
|
124
123
|
};
|
|
125
124
|
const popupRole = getPopupRole(element);
|
|
126
|
-
if (!popupRole)
|
|
127
|
-
return fallback;
|
|
125
|
+
if (!popupRole) return fallback;
|
|
128
126
|
const key = popupRole;
|
|
129
127
|
return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback;
|
|
130
128
|
}
|
|
@@ -134,26 +132,22 @@ function scrollIntoViewIfNeeded(element, arg) {
|
|
|
134
132
|
}
|
|
135
133
|
}
|
|
136
134
|
function getScrollingElement(element) {
|
|
137
|
-
if (!element)
|
|
138
|
-
return null;
|
|
135
|
+
if (!element) return null;
|
|
139
136
|
if (element.clientHeight && element.scrollHeight > element.clientHeight) {
|
|
140
137
|
const { overflowY } = getComputedStyle(element);
|
|
141
138
|
const isScrollable = overflowY !== "visible" && overflowY !== "hidden";
|
|
142
|
-
if (isScrollable)
|
|
143
|
-
return element;
|
|
139
|
+
if (isScrollable) return element;
|
|
144
140
|
} else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
|
|
145
141
|
const { overflowX } = getComputedStyle(element);
|
|
146
142
|
const isScrollable = overflowX !== "visible" && overflowX !== "hidden";
|
|
147
|
-
if (isScrollable)
|
|
148
|
-
return element;
|
|
143
|
+
if (isScrollable) return element;
|
|
149
144
|
}
|
|
150
145
|
return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
|
|
151
146
|
}
|
|
152
147
|
function isPartiallyHidden(element) {
|
|
153
148
|
const elementRect = element.getBoundingClientRect();
|
|
154
149
|
const scroller = getScrollingElement(element);
|
|
155
|
-
if (!scroller)
|
|
156
|
-
return false;
|
|
150
|
+
if (!scroller) return false;
|
|
157
151
|
const scrollerRect = scroller.getBoundingClientRect();
|
|
158
152
|
const isHTML = scroller.tagName === "HTML";
|
|
159
153
|
const scrollerTop = isHTML ? scrollerRect.top + scroller.scrollTop : scrollerRect.top;
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _3IVNQNIVcjs = require('./3IVNQNIV.cjs');
|
|
5
5
|
|
|
6
6
|
// src/utils/misc.ts
|
|
7
7
|
function noop(..._) {
|
|
8
8
|
}
|
|
9
9
|
function shallowEqual(a, b) {
|
|
10
|
-
if (a === b)
|
|
11
|
-
|
|
12
|
-
if (!
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
return false;
|
|
16
|
-
if (typeof a !== "object")
|
|
17
|
-
return false;
|
|
18
|
-
if (typeof b !== "object")
|
|
19
|
-
return false;
|
|
10
|
+
if (a === b) return true;
|
|
11
|
+
if (!a) return false;
|
|
12
|
+
if (!b) return false;
|
|
13
|
+
if (typeof a !== "object") return false;
|
|
14
|
+
if (typeof b !== "object") return false;
|
|
20
15
|
const aKeys = Object.keys(a);
|
|
21
16
|
const bKeys = Object.keys(b);
|
|
22
17
|
const { length } = aKeys;
|
|
23
|
-
if (bKeys.length !== length)
|
|
24
|
-
return false;
|
|
18
|
+
if (bKeys.length !== length) return false;
|
|
25
19
|
for (const key of aKeys) {
|
|
26
20
|
if (a[key] !== b[key]) {
|
|
27
21
|
return false;
|
|
@@ -46,14 +40,10 @@ function isObject(arg) {
|
|
|
46
40
|
return typeof arg === "object" && arg != null;
|
|
47
41
|
}
|
|
48
42
|
function isEmpty(arg) {
|
|
49
|
-
if (Array.isArray(arg))
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
if (arg == null)
|
|
54
|
-
return true;
|
|
55
|
-
if (arg === "")
|
|
56
|
-
return true;
|
|
43
|
+
if (Array.isArray(arg)) return !arg.length;
|
|
44
|
+
if (isObject(arg)) return !Object.keys(arg).length;
|
|
45
|
+
if (arg == null) return true;
|
|
46
|
+
if (arg === "") return true;
|
|
57
47
|
return false;
|
|
58
48
|
}
|
|
59
49
|
function isInteger(arg) {
|
|
@@ -84,7 +74,7 @@ function normalizeString(str) {
|
|
|
84
74
|
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
85
75
|
}
|
|
86
76
|
function omit(object, keys) {
|
|
87
|
-
const result =
|
|
77
|
+
const result = _3IVNQNIVcjs.__spreadValues.call(void 0, {}, object);
|
|
88
78
|
for (const key of keys) {
|
|
89
79
|
if (hasOwnProperty(result, key)) {
|
|
90
80
|
delete result[key];
|
|
@@ -115,10 +105,8 @@ function afterPaint(cb = noop) {
|
|
|
115
105
|
return () => cancelAnimationFrame(raf);
|
|
116
106
|
}
|
|
117
107
|
function invariant(condition, message) {
|
|
118
|
-
if (condition)
|
|
119
|
-
|
|
120
|
-
if (typeof message !== "string")
|
|
121
|
-
throw new Error("Invariant failed");
|
|
108
|
+
if (condition) return;
|
|
109
|
+
if (typeof message !== "string") throw new Error("Invariant failed");
|
|
122
110
|
throw new Error(message);
|
|
123
111
|
}
|
|
124
112
|
function getKeys(obj) {
|
|
@@ -126,8 +114,7 @@ function getKeys(obj) {
|
|
|
126
114
|
}
|
|
127
115
|
function isFalsyBooleanCallback(booleanOrCallback, ...args) {
|
|
128
116
|
const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
|
|
129
|
-
if (result == null)
|
|
130
|
-
return false;
|
|
117
|
+
if (result == null) return false;
|
|
131
118
|
return !result;
|
|
132
119
|
}
|
|
133
120
|
function disabledFromProps(props) {
|
|
@@ -144,8 +131,7 @@ function removeUndefinedValues(obj) {
|
|
|
144
131
|
}
|
|
145
132
|
function defaultValue(...values) {
|
|
146
133
|
for (const value of values) {
|
|
147
|
-
if (value !== void 0)
|
|
148
|
-
return value;
|
|
134
|
+
if (value !== void 0) return value;
|
|
149
135
|
}
|
|
150
136
|
return void 0;
|
|
151
137
|
}
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _3QF3ODTRcjs = require('./3QF3ODTR.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _BTUHABP4cjs = require('./BTUHABP4.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _7WYII4ANcjs = require('./7WYII4AN.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _3IVNQNIVcjs = require('./3IVNQNIV.cjs');
|
|
20
20
|
|
|
21
21
|
// src/collection/collection-store.ts
|
|
22
22
|
function isElementPreceding(a, b) {
|
|
@@ -30,10 +30,8 @@ function sortBasedOnDOMPosition(items) {
|
|
|
30
30
|
pairs.sort(([indexA, a], [indexB, b]) => {
|
|
31
31
|
const elementA = a.element;
|
|
32
32
|
const elementB = b.element;
|
|
33
|
-
if (elementA === elementB)
|
|
34
|
-
|
|
35
|
-
if (!elementA || !elementB)
|
|
36
|
-
return 0;
|
|
33
|
+
if (elementA === elementB) return 0;
|
|
34
|
+
if (!elementA || !elementB) return 0;
|
|
37
35
|
if (isElementPreceding(elementA, elementB)) {
|
|
38
36
|
if (indexA > indexB) {
|
|
39
37
|
isOrderDifferent = true;
|
|
@@ -62,16 +60,16 @@ function getCommonParent(items) {
|
|
|
62
60
|
}
|
|
63
61
|
parentElement = parentElement.parentElement;
|
|
64
62
|
}
|
|
65
|
-
return
|
|
63
|
+
return _7WYII4ANcjs.getDocument.call(void 0, parentElement).body;
|
|
66
64
|
}
|
|
67
65
|
function getPrivateStore(store) {
|
|
68
66
|
return store == null ? void 0 : store.__unstablePrivateStore;
|
|
69
67
|
}
|
|
70
68
|
function createCollectionStore(props = {}) {
|
|
71
69
|
var _a;
|
|
72
|
-
|
|
70
|
+
_3QF3ODTRcjs.throwOnConflictingProps.call(void 0, props, props.store);
|
|
73
71
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
74
|
-
const items =
|
|
72
|
+
const items = _BTUHABP4cjs.defaultValue.call(void 0,
|
|
75
73
|
props.items,
|
|
76
74
|
syncState == null ? void 0 : syncState.items,
|
|
77
75
|
props.defaultItems,
|
|
@@ -80,32 +78,31 @@ function createCollectionStore(props = {}) {
|
|
|
80
78
|
const itemsMap = new Map(items.map((item) => [item.id, item]));
|
|
81
79
|
const initialState = {
|
|
82
80
|
items,
|
|
83
|
-
renderedItems:
|
|
81
|
+
renderedItems: _BTUHABP4cjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.renderedItems, [])
|
|
84
82
|
};
|
|
85
83
|
const syncPrivateStore = getPrivateStore(props.store);
|
|
86
|
-
const privateStore =
|
|
84
|
+
const privateStore = _3QF3ODTRcjs.createStore.call(void 0,
|
|
87
85
|
{ items, renderedItems: initialState.renderedItems },
|
|
88
86
|
syncPrivateStore
|
|
89
87
|
);
|
|
90
|
-
const collection =
|
|
88
|
+
const collection = _3QF3ODTRcjs.createStore.call(void 0, initialState, props.store);
|
|
91
89
|
const sortItems = (renderedItems) => {
|
|
92
90
|
const sortedItems = sortBasedOnDOMPosition(renderedItems);
|
|
93
91
|
privateStore.setState("renderedItems", sortedItems);
|
|
94
92
|
collection.setState("renderedItems", sortedItems);
|
|
95
93
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return
|
|
94
|
+
_3QF3ODTRcjs.setup.call(void 0, collection, () => _3QF3ODTRcjs.init.call(void 0, privateStore));
|
|
95
|
+
_3QF3ODTRcjs.setup.call(void 0, privateStore, () => {
|
|
96
|
+
return _3QF3ODTRcjs.batch.call(void 0, privateStore, ["items"], (state) => {
|
|
99
97
|
collection.setState("items", state.items);
|
|
100
98
|
});
|
|
101
99
|
});
|
|
102
|
-
|
|
103
|
-
return
|
|
100
|
+
_3QF3ODTRcjs.setup.call(void 0, privateStore, () => {
|
|
101
|
+
return _3QF3ODTRcjs.batch.call(void 0, privateStore, ["renderedItems"], (state) => {
|
|
104
102
|
let firstRun = true;
|
|
105
103
|
let raf = requestAnimationFrame(() => {
|
|
106
104
|
const { renderedItems } = collection.getState();
|
|
107
|
-
if (state.renderedItems === renderedItems)
|
|
108
|
-
return;
|
|
105
|
+
if (state.renderedItems === renderedItems) return;
|
|
109
106
|
sortItems(state.renderedItems);
|
|
110
107
|
});
|
|
111
108
|
if (typeof IntersectionObserver !== "function") {
|
|
@@ -122,8 +119,7 @@ function createCollectionStore(props = {}) {
|
|
|
122
119
|
const root = getCommonParent(state.renderedItems);
|
|
123
120
|
const observer = new IntersectionObserver(ioCallback, { root });
|
|
124
121
|
for (const item of state.renderedItems) {
|
|
125
|
-
if (!item.element)
|
|
126
|
-
continue;
|
|
122
|
+
if (!item.element) continue;
|
|
127
123
|
observer.observe(item.element);
|
|
128
124
|
}
|
|
129
125
|
return () => {
|
|
@@ -139,7 +135,7 @@ function createCollectionStore(props = {}) {
|
|
|
139
135
|
const nextItems = items2.slice();
|
|
140
136
|
if (index !== -1) {
|
|
141
137
|
prevItem = items2[index];
|
|
142
|
-
const nextItem =
|
|
138
|
+
const nextItem = _3IVNQNIVcjs.__spreadValues.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, {}, prevItem), item);
|
|
143
139
|
nextItems[index] = nextItem;
|
|
144
140
|
itemsMap.set(item.id, nextItem);
|
|
145
141
|
} else {
|
|
@@ -157,8 +153,7 @@ function createCollectionStore(props = {}) {
|
|
|
157
153
|
return items2.filter(({ id }) => id !== item.id);
|
|
158
154
|
}
|
|
159
155
|
const index = items2.findIndex(({ id }) => id === item.id);
|
|
160
|
-
if (index === -1)
|
|
161
|
-
return items2;
|
|
156
|
+
if (index === -1) return items2;
|
|
162
157
|
const nextItems = items2.slice();
|
|
163
158
|
nextItems[index] = prevItem;
|
|
164
159
|
itemsMap.set(item.id, prevItem);
|
|
@@ -172,9 +167,9 @@ function createCollectionStore(props = {}) {
|
|
|
172
167
|
(getItems) => privateStore.setState("items", getItems),
|
|
173
168
|
true
|
|
174
169
|
);
|
|
175
|
-
return
|
|
170
|
+
return _3IVNQNIVcjs.__spreadProps.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, {}, collection), {
|
|
176
171
|
registerItem,
|
|
177
|
-
renderItem: (item) =>
|
|
172
|
+
renderItem: (item) => _BTUHABP4cjs.chain.call(void 0,
|
|
178
173
|
registerItem(item),
|
|
179
174
|
mergeItem(
|
|
180
175
|
item,
|
|
@@ -182,8 +177,7 @@ function createCollectionStore(props = {}) {
|
|
|
182
177
|
)
|
|
183
178
|
),
|
|
184
179
|
item: (id) => {
|
|
185
|
-
if (!id)
|
|
186
|
-
return null;
|
|
180
|
+
if (!id) return null;
|
|
187
181
|
let item = itemsMap.get(id);
|
|
188
182
|
if (!item) {
|
|
189
183
|
const { items: items2 } = collection.getState();
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _N667HVEDcjs = require('./N667HVED.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _3QF3ODTRcjs = require('./3QF3ODTR.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _BTUHABP4cjs = require('./BTUHABP4.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _3IVNQNIVcjs = require('./3IVNQNIV.cjs');
|
|
19
19
|
|
|
20
20
|
// src/popover/popover-store.ts
|
|
21
21
|
function createPopoverStore(_a = {}) {
|
|
22
22
|
var _b = _a, {
|
|
23
23
|
popover: otherPopover
|
|
24
|
-
} = _b, props =
|
|
24
|
+
} = _b, props = _3IVNQNIVcjs.__objRest.call(void 0, _b, [
|
|
25
25
|
"popover"
|
|
26
26
|
]);
|
|
27
|
-
const store =
|
|
27
|
+
const store = _3QF3ODTRcjs.mergeStore.call(void 0,
|
|
28
28
|
props.store,
|
|
29
|
-
|
|
29
|
+
_3QF3ODTRcjs.omit.call(void 0, otherPopover, [
|
|
30
30
|
"arrowElement",
|
|
31
31
|
"anchorElement",
|
|
32
32
|
"contentElement",
|
|
@@ -34,24 +34,24 @@ function createPopoverStore(_a = {}) {
|
|
|
34
34
|
"disclosureElement"
|
|
35
35
|
])
|
|
36
36
|
);
|
|
37
|
-
|
|
37
|
+
_3QF3ODTRcjs.throwOnConflictingProps.call(void 0, props, store);
|
|
38
38
|
const syncState = store == null ? void 0 : store.getState();
|
|
39
|
-
const dialog =
|
|
40
|
-
const placement =
|
|
39
|
+
const dialog = _N667HVEDcjs.createDialogStore.call(void 0, _3IVNQNIVcjs.__spreadProps.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, {}, props), { store }));
|
|
40
|
+
const placement = _BTUHABP4cjs.defaultValue.call(void 0,
|
|
41
41
|
props.placement,
|
|
42
42
|
syncState == null ? void 0 : syncState.placement,
|
|
43
43
|
"bottom"
|
|
44
44
|
);
|
|
45
|
-
const initialState =
|
|
45
|
+
const initialState = _3IVNQNIVcjs.__spreadProps.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, {}, dialog.getState()), {
|
|
46
46
|
placement,
|
|
47
47
|
currentPlacement: placement,
|
|
48
|
-
anchorElement:
|
|
49
|
-
popoverElement:
|
|
50
|
-
arrowElement:
|
|
48
|
+
anchorElement: _BTUHABP4cjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.anchorElement, null),
|
|
49
|
+
popoverElement: _BTUHABP4cjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.popoverElement, null),
|
|
50
|
+
arrowElement: _BTUHABP4cjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.arrowElement, null),
|
|
51
51
|
rendered: Symbol("rendered")
|
|
52
52
|
});
|
|
53
|
-
const popover =
|
|
54
|
-
return
|
|
53
|
+
const popover = _3QF3ODTRcjs.createStore.call(void 0, initialState, dialog, store);
|
|
54
|
+
return _3IVNQNIVcjs.__spreadProps.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, _3IVNQNIVcjs.__spreadValues.call(void 0, {}, dialog), popover), {
|
|
55
55
|
setAnchorElement: (element) => popover.setState("anchorElement", element),
|
|
56
56
|
setPopoverElement: (element) => popover.setState("popoverElement", element),
|
|
57
57
|
setArrowElement: (element) => popover.setState("arrowElement", element),
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _7WYII4ANcjs = require('./7WYII4AN.cjs');
|
|
5
5
|
|
|
6
6
|
// src/utils/platform.ts
|
|
7
7
|
function isTouchDevice() {
|
|
8
|
-
return
|
|
8
|
+
return _7WYII4ANcjs.canUseDOM && !!navigator.maxTouchPoints;
|
|
9
9
|
}
|
|
10
10
|
function isApple() {
|
|
11
|
-
if (!
|
|
12
|
-
return false;
|
|
11
|
+
if (!_7WYII4ANcjs.canUseDOM) return false;
|
|
13
12
|
return /mac|iphone|ipad|ipod/i.test(navigator.platform);
|
|
14
13
|
}
|
|
15
14
|
function isSafari() {
|
|
16
|
-
return
|
|
15
|
+
return _7WYII4ANcjs.canUseDOM && isApple() && /apple/i.test(navigator.vendor);
|
|
17
16
|
}
|
|
18
17
|
function isFirefox() {
|
|
19
|
-
return
|
|
18
|
+
return _7WYII4ANcjs.canUseDOM && /firefox\//i.test(navigator.userAgent);
|
|
20
19
|
}
|
|
21
20
|
function isMac() {
|
|
22
|
-
return
|
|
21
|
+
return _7WYII4ANcjs.canUseDOM && navigator.platform.startsWith("Mac") && !isTouchDevice();
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
|