@ariakit/core 0.1.4 → 0.1.5
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 +10 -0
- package/cjs/__chunks/{QYB6XH64.cjs → 27ZAGOYG.cjs} +17 -13
- package/cjs/__chunks/6455U47T.cjs +37 -0
- package/cjs/__chunks/{ZPOXPO2L.cjs → 6SPJEESB.cjs} +33 -21
- package/cjs/__chunks/{2YFRPUZP.cjs → DBHIHK7C.cjs} +6 -6
- package/cjs/__chunks/{W5IHD6VG.cjs → EUJ6NNA6.cjs} +56 -43
- package/cjs/__chunks/{4DQ3OTE7.cjs → FXEBKN6G.cjs} +22 -17
- package/cjs/__chunks/{ZJEEK57E.cjs → HEFJPUYD.cjs} +2 -2
- package/cjs/__chunks/LBTLD2RB.cjs +58 -0
- package/cjs/__chunks/{QNEPGQLL.cjs → M6ZA7XUP.cjs} +6 -2
- package/cjs/__chunks/{HLVPXX7H.cjs → SDBF6KIY.cjs} +107 -107
- package/cjs/__chunks/{OFNGELMA.cjs → ZNW4LSWU.cjs} +8 -6
- package/cjs/checkbox/checkbox-store.cjs +14 -10
- package/cjs/collection/collection-store.cjs +6 -5
- package/cjs/combobox/combobox-store.cjs +49 -48
- package/cjs/composite/composite-overflow-store.cjs +7 -6
- package/cjs/composite/composite-store.cjs +7 -6
- package/cjs/dialog/dialog-store.cjs +6 -5
- package/cjs/disclosure/disclosure-store.cjs +5 -4
- package/cjs/disclosure/disclosure-store.d.ts +8 -0
- package/cjs/form/form-store.cjs +38 -35
- package/cjs/hovercard/hovercard-store.cjs +8 -7
- package/cjs/index.cjs +3 -1
- package/cjs/menu/menu-bar-store.cjs +17 -13
- package/cjs/menu/menu-store.cjs +41 -43
- package/cjs/popover/popover-store.cjs +7 -6
- package/cjs/radio/radio-store.cjs +25 -24
- package/cjs/select/select-store.cjs +42 -42
- package/cjs/tab/tab-store.cjs +29 -28
- package/cjs/tab/tab-store.d.ts +9 -0
- package/cjs/toolbar/toolbar-store.cjs +17 -13
- package/cjs/tooltip/tooltip-store.cjs +24 -25
- package/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/cjs/utils/array.cjs +1 -0
- package/cjs/utils/dom.cjs +3 -2
- package/cjs/utils/events.cjs +14 -9
- package/cjs/utils/focus.cjs +24 -14
- package/cjs/utils/misc.cjs +3 -2
- package/cjs/utils/platform.cjs +4 -3
- package/cjs/utils/store.cjs +4 -3
- package/esm/__chunks/4BKCJXBM.js +37 -0
- package/esm/__chunks/AHZW5LR4.js +58 -0
- package/esm/__chunks/{NA5BK7DD.js → BOKMNDR7.js} +22 -10
- package/esm/__chunks/{6PEWNRTN.js → CUW3E24J.js} +100 -100
- package/esm/__chunks/{WFGVC6LE.js → EWHSN7GO.js} +17 -12
- package/esm/__chunks/{4T5RHRE5.js → MNNKHNLW.js} +1 -1
- package/esm/__chunks/{UVCATTRC.js → N6JW4ITM.js} +7 -5
- package/esm/__chunks/{RMD7SNCC.js → NWU4GBZ6.js} +5 -1
- package/esm/__chunks/{X7MJ3FB5.js → R6VHFWTV.js} +49 -36
- package/esm/__chunks/{DXA3K2FY.js → TFBCK4JB.js} +1 -1
- package/esm/__chunks/{IOAGNCXX.js → ZV2GEGPL.js} +14 -10
- package/esm/checkbox/checkbox-store.js +11 -7
- package/esm/collection/collection-store.js +5 -4
- package/esm/combobox/combobox-store.js +34 -33
- package/esm/composite/composite-overflow-store.js +6 -5
- package/esm/composite/composite-store.js +6 -5
- package/esm/dialog/dialog-store.js +5 -4
- package/esm/disclosure/disclosure-store.d.ts +8 -0
- package/esm/disclosure/disclosure-store.js +4 -3
- package/esm/form/form-store.js +24 -21
- package/esm/hovercard/hovercard-store.js +7 -6
- package/esm/index.js +2 -0
- package/esm/menu/menu-bar-store.js +15 -11
- package/esm/menu/menu-store.js +31 -33
- package/esm/popover/popover-store.js +6 -5
- package/esm/radio/radio-store.js +22 -21
- package/esm/select/select-store.js +29 -29
- package/esm/tab/tab-store.d.ts +9 -0
- package/esm/tab/tab-store.js +23 -22
- package/esm/toolbar/toolbar-store.js +15 -11
- package/esm/tooltip/tooltip-store.js +20 -21
- package/esm/tsconfig.build.tsbuildinfo +1 -1
- package/esm/utils/array.js +1 -0
- package/esm/utils/dom.js +2 -1
- package/esm/utils/events.js +10 -5
- package/esm/utils/focus.js +14 -4
- package/esm/utils/misc.js +2 -1
- package/esm/utils/platform.js +3 -2
- package/esm/utils/store.js +3 -2
- package/package.json +1 -1
- package/cjs/__chunks/DQHU5K4Q.cjs +0 -57
- package/esm/__chunks/6HMPWUDT.js +0 -57
package/cjs/utils/platform.cjs
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('../__chunks/
|
|
7
|
+
var _DBHIHK7Ccjs = require('../__chunks/DBHIHK7C.cjs');
|
|
8
|
+
require('../__chunks/ZNW4LSWU.cjs');
|
|
9
|
+
require('../__chunks/6455U47T.cjs');
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
exports.isApple =
|
|
16
|
+
exports.isApple = _DBHIHK7Ccjs.isApple; exports.isFirefox = _DBHIHK7Ccjs.isFirefox; exports.isMac = _DBHIHK7Ccjs.isMac; exports.isSafari = _DBHIHK7Ccjs.isSafari; exports.isTouchDevice = _DBHIHK7Ccjs.isTouchDevice;
|
package/cjs/utils/store.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
4
|
+
var _6SPJEESBcjs = require('../__chunks/6SPJEESB.cjs');
|
|
5
|
+
require('../__chunks/M6ZA7XUP.cjs');
|
|
6
|
+
require('../__chunks/6455U47T.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
exports.createStore =
|
|
10
|
+
exports.createStore = _6SPJEESBcjs.createStore; exports.mergeStore = _6SPJEESBcjs.mergeStore;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
__spreadValues,
|
|
35
|
+
__spreadProps,
|
|
36
|
+
__objRest
|
|
37
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPopoverStore
|
|
3
|
+
} from "./CUW3E24J.js";
|
|
4
|
+
import {
|
|
5
|
+
createStore
|
|
6
|
+
} from "./BOKMNDR7.js";
|
|
7
|
+
import {
|
|
8
|
+
defaultValue
|
|
9
|
+
} from "./NWU4GBZ6.js";
|
|
10
|
+
import {
|
|
11
|
+
__spreadProps,
|
|
12
|
+
__spreadValues
|
|
13
|
+
} from "./4BKCJXBM.js";
|
|
14
|
+
|
|
15
|
+
// src/hovercard/hovercard-store.ts
|
|
16
|
+
function createHovercardStore(props = {}) {
|
|
17
|
+
var _a;
|
|
18
|
+
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
19
|
+
const timeout = defaultValue(props.timeout, syncState == null ? void 0 : syncState.timeout, 500);
|
|
20
|
+
const popover = createPopoverStore(__spreadProps(__spreadValues({}, props), {
|
|
21
|
+
placement: defaultValue(
|
|
22
|
+
props.placement,
|
|
23
|
+
syncState == null ? void 0 : syncState.placement,
|
|
24
|
+
"bottom"
|
|
25
|
+
)
|
|
26
|
+
}));
|
|
27
|
+
const initialState = __spreadProps(__spreadValues({}, popover.getState()), {
|
|
28
|
+
timeout,
|
|
29
|
+
showTimeout: defaultValue(
|
|
30
|
+
props.showTimeout,
|
|
31
|
+
syncState == null ? void 0 : syncState.showTimeout,
|
|
32
|
+
timeout
|
|
33
|
+
),
|
|
34
|
+
hideTimeout: defaultValue(
|
|
35
|
+
props.hideTimeout,
|
|
36
|
+
syncState == null ? void 0 : syncState.hideTimeout,
|
|
37
|
+
timeout
|
|
38
|
+
),
|
|
39
|
+
autoFocusOnShow: defaultValue(syncState == null ? void 0 : syncState.autoFocusOnShow, false)
|
|
40
|
+
});
|
|
41
|
+
const hovercard = createStore(initialState, popover, props.store);
|
|
42
|
+
hovercard.setup(
|
|
43
|
+
() => hovercard.sync(
|
|
44
|
+
(state) => {
|
|
45
|
+
hovercard.setState("showTimeout", (value) => value != null ? value : state.timeout);
|
|
46
|
+
hovercard.setState("hideTimeout", (value) => value != null ? value : state.timeout);
|
|
47
|
+
},
|
|
48
|
+
["timeout"]
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
return __spreadProps(__spreadValues(__spreadValues({}, popover), hovercard), {
|
|
52
|
+
setAutoFocusOnShow: (value) => hovercard.setState("autoFocusOnShow", value)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
createHovercardStore
|
|
58
|
+
};
|
|
@@ -6,7 +6,11 @@ import {
|
|
|
6
6
|
noop,
|
|
7
7
|
omit,
|
|
8
8
|
pick
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./NWU4GBZ6.js";
|
|
10
|
+
import {
|
|
11
|
+
__spreadProps,
|
|
12
|
+
__spreadValues
|
|
13
|
+
} from "./4BKCJXBM.js";
|
|
10
14
|
|
|
11
15
|
// src/utils/store.ts
|
|
12
16
|
function createStore(initialState, ...stores) {
|
|
@@ -34,18 +38,22 @@ function createStore(initialState, ...stores) {
|
|
|
34
38
|
const desyncs = getKeys(state).map(
|
|
35
39
|
(key) => chain(
|
|
36
40
|
...stores.map((store) => {
|
|
37
|
-
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
|
|
38
43
|
if (!storeState)
|
|
39
44
|
return;
|
|
40
45
|
if (!hasOwnProperty(storeState, key))
|
|
41
46
|
return;
|
|
42
|
-
return store
|
|
47
|
+
return (_b = store == null ? void 0 : store.sync) == null ? void 0 : _b.call(store, (state2) => setState(key, state2[key]), [key]);
|
|
43
48
|
})
|
|
44
49
|
)
|
|
45
50
|
);
|
|
46
51
|
const teardowns = [];
|
|
47
52
|
setups.forEach((setup2) => teardowns.push(setup2()));
|
|
48
|
-
const cleanups = stores.map((store) =>
|
|
53
|
+
const cleanups = stores.map((store) => {
|
|
54
|
+
var _a;
|
|
55
|
+
return (_a = store == null ? void 0 : store.init) == null ? void 0 : _a.call(store);
|
|
56
|
+
});
|
|
49
57
|
return chain(...desyncs, ...teardowns, ...cleanups, () => {
|
|
50
58
|
initialized = false;
|
|
51
59
|
});
|
|
@@ -55,7 +63,8 @@ function createStore(initialState, ...stores) {
|
|
|
55
63
|
set.add(listener);
|
|
56
64
|
listenerKeys.set(listener, keys);
|
|
57
65
|
return () => {
|
|
58
|
-
|
|
66
|
+
var _a;
|
|
67
|
+
(_a = disposables.get(listener)) == null ? void 0 : _a();
|
|
59
68
|
disposables.delete(listener);
|
|
60
69
|
listenerKeys.delete(listener);
|
|
61
70
|
set.delete(listener);
|
|
@@ -80,19 +89,21 @@ function createStore(initialState, ...stores) {
|
|
|
80
89
|
if (nextValue === state[key])
|
|
81
90
|
return;
|
|
82
91
|
stores.forEach((store) => {
|
|
83
|
-
|
|
92
|
+
var _a;
|
|
93
|
+
(_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
|
|
84
94
|
});
|
|
85
95
|
const prevState = state;
|
|
86
|
-
state = {
|
|
96
|
+
state = __spreadProps(__spreadValues({}, state), { [key]: nextValue });
|
|
87
97
|
const thisUpdate = Symbol();
|
|
88
98
|
lastUpdate = thisUpdate;
|
|
89
99
|
updating = true;
|
|
90
100
|
updatedKeys.add(key);
|
|
91
101
|
const run = (listener, prev, uKeys) => {
|
|
102
|
+
var _a;
|
|
92
103
|
const keys = listenerKeys.get(listener);
|
|
93
104
|
const updated = (k) => uKeys ? uKeys.has(k) : k === key;
|
|
94
105
|
if (!keys || keys.some(updated)) {
|
|
95
|
-
disposables.get(listener)
|
|
106
|
+
(_a = disposables.get(listener)) == null ? void 0 : _a();
|
|
96
107
|
disposables.set(listener, listener(state, prev));
|
|
97
108
|
}
|
|
98
109
|
};
|
|
@@ -128,10 +139,11 @@ function createStore(initialState, ...stores) {
|
|
|
128
139
|
}
|
|
129
140
|
function mergeStore(...stores) {
|
|
130
141
|
const initialState = stores.reduce((state, store2) => {
|
|
131
|
-
|
|
142
|
+
var _a;
|
|
143
|
+
const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
|
|
132
144
|
if (!nextState)
|
|
133
145
|
return state;
|
|
134
|
-
return {
|
|
146
|
+
return __spreadValues(__spreadValues({}, state), nextState);
|
|
135
147
|
}, {});
|
|
136
148
|
const store = createStore(initialState, ...stores);
|
|
137
149
|
return store;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDialogStore
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./MNNKHNLW.js";
|
|
4
4
|
import {
|
|
5
5
|
createStore,
|
|
6
6
|
mergeStore
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./BOKMNDR7.js";
|
|
8
8
|
import {
|
|
9
9
|
defaultValue
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./NWU4GBZ6.js";
|
|
11
|
+
import {
|
|
12
|
+
__objRest,
|
|
13
|
+
__spreadProps,
|
|
14
|
+
__spreadValues
|
|
15
|
+
} from "./4BKCJXBM.js";
|
|
11
16
|
|
|
12
17
|
// ../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
13
18
|
function getAlignment(placement) {
|
|
@@ -123,13 +128,9 @@ var computePosition = async (reference, floating, config) => {
|
|
|
123
128
|
});
|
|
124
129
|
x = nextX != null ? nextX : x;
|
|
125
130
|
y = nextY != null ? nextY : y;
|
|
126
|
-
middlewareData = {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
...middlewareData[name],
|
|
130
|
-
...data
|
|
131
|
-
}
|
|
132
|
-
};
|
|
131
|
+
middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
|
|
132
|
+
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
|
|
133
|
+
});
|
|
133
134
|
if (reset && resetCount <= 50) {
|
|
134
135
|
resetCount++;
|
|
135
136
|
if (typeof reset === "object") {
|
|
@@ -161,13 +162,12 @@ var computePosition = async (reference, floating, config) => {
|
|
|
161
162
|
};
|
|
162
163
|
};
|
|
163
164
|
function expandPaddingObject(padding) {
|
|
164
|
-
return {
|
|
165
|
+
return __spreadValues({
|
|
165
166
|
top: 0,
|
|
166
167
|
right: 0,
|
|
167
168
|
bottom: 0,
|
|
168
|
-
left: 0
|
|
169
|
-
|
|
170
|
-
};
|
|
169
|
+
left: 0
|
|
170
|
+
}, padding);
|
|
171
171
|
}
|
|
172
172
|
function getSideObjectFromPadding(padding) {
|
|
173
173
|
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
@@ -178,13 +178,12 @@ function getSideObjectFromPadding(padding) {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
function rectToClientRect(rect) {
|
|
181
|
-
return {
|
|
182
|
-
...rect,
|
|
181
|
+
return __spreadProps(__spreadValues({}, rect), {
|
|
183
182
|
top: rect.y,
|
|
184
183
|
left: rect.x,
|
|
185
184
|
right: rect.x + rect.width,
|
|
186
185
|
bottom: rect.y + rect.height
|
|
187
|
-
};
|
|
186
|
+
});
|
|
188
187
|
}
|
|
189
188
|
async function detectOverflow(state, options) {
|
|
190
189
|
var _await$platform$isEle;
|
|
@@ -215,11 +214,10 @@ async function detectOverflow(state, options) {
|
|
|
215
214
|
rootBoundary,
|
|
216
215
|
strategy
|
|
217
216
|
}));
|
|
218
|
-
const rect = elementContext === "floating" ? {
|
|
219
|
-
...rects.floating,
|
|
217
|
+
const rect = elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
|
|
220
218
|
x,
|
|
221
219
|
y
|
|
222
|
-
} : rects.reference;
|
|
220
|
+
}) : rects.reference;
|
|
223
221
|
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
224
222
|
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
225
223
|
x: 1,
|
|
@@ -381,15 +379,21 @@ var flip = function(options) {
|
|
|
381
379
|
platform: platform2,
|
|
382
380
|
elements
|
|
383
381
|
} = state;
|
|
384
|
-
const {
|
|
382
|
+
const _a = options, {
|
|
385
383
|
mainAxis: checkMainAxis = true,
|
|
386
384
|
crossAxis: checkCrossAxis = true,
|
|
387
385
|
fallbackPlacements: specifiedFallbackPlacements,
|
|
388
386
|
fallbackStrategy = "bestFit",
|
|
389
387
|
fallbackAxisSideDirection = "none",
|
|
390
|
-
flipAlignment = true
|
|
391
|
-
|
|
392
|
-
|
|
388
|
+
flipAlignment = true
|
|
389
|
+
} = _a, detectOverflowOptions = __objRest(_a, [
|
|
390
|
+
"mainAxis",
|
|
391
|
+
"crossAxis",
|
|
392
|
+
"fallbackPlacements",
|
|
393
|
+
"fallbackStrategy",
|
|
394
|
+
"fallbackAxisSideDirection",
|
|
395
|
+
"flipAlignment"
|
|
396
|
+
]);
|
|
393
397
|
const side = getSide(placement);
|
|
394
398
|
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
395
399
|
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
@@ -479,12 +483,11 @@ async function convertValueToCoords(state, value) {
|
|
|
479
483
|
mainAxis: rawValue,
|
|
480
484
|
crossAxis: 0,
|
|
481
485
|
alignmentAxis: null
|
|
482
|
-
} : {
|
|
486
|
+
} : __spreadValues({
|
|
483
487
|
mainAxis: 0,
|
|
484
488
|
crossAxis: 0,
|
|
485
|
-
alignmentAxis: null
|
|
486
|
-
|
|
487
|
-
};
|
|
489
|
+
alignmentAxis: null
|
|
490
|
+
}, rawValue);
|
|
488
491
|
if (alignment && typeof alignmentAxis === "number") {
|
|
489
492
|
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
490
493
|
}
|
|
@@ -533,7 +536,7 @@ var shift = function(options) {
|
|
|
533
536
|
y,
|
|
534
537
|
placement
|
|
535
538
|
} = state;
|
|
536
|
-
const {
|
|
539
|
+
const _a = options, {
|
|
537
540
|
mainAxis: checkMainAxis = true,
|
|
538
541
|
crossAxis: checkCrossAxis = false,
|
|
539
542
|
limiter = {
|
|
@@ -547,9 +550,12 @@ var shift = function(options) {
|
|
|
547
550
|
y: y2
|
|
548
551
|
};
|
|
549
552
|
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
+
}
|
|
554
|
+
} = _a, detectOverflowOptions = __objRest(_a, [
|
|
555
|
+
"mainAxis",
|
|
556
|
+
"crossAxis",
|
|
557
|
+
"limiter"
|
|
558
|
+
]);
|
|
553
559
|
const coords = {
|
|
554
560
|
x,
|
|
555
561
|
y
|
|
@@ -573,18 +579,16 @@ var shift = function(options) {
|
|
|
573
579
|
const max3 = crossAxisCoord - overflow[maxSide];
|
|
574
580
|
crossAxisCoord = within(min3, crossAxisCoord, max3);
|
|
575
581
|
}
|
|
576
|
-
const limitedCoords = limiter.fn({
|
|
577
|
-
...state,
|
|
582
|
+
const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, state), {
|
|
578
583
|
[mainAxis]: mainAxisCoord,
|
|
579
584
|
[crossAxis]: crossAxisCoord
|
|
580
|
-
});
|
|
581
|
-
return {
|
|
582
|
-
...limitedCoords,
|
|
585
|
+
}));
|
|
586
|
+
return __spreadProps(__spreadValues({}, limitedCoords), {
|
|
583
587
|
data: {
|
|
584
588
|
x: limitedCoords.x - x,
|
|
585
589
|
y: limitedCoords.y - y
|
|
586
590
|
}
|
|
587
|
-
};
|
|
591
|
+
});
|
|
588
592
|
}
|
|
589
593
|
};
|
|
590
594
|
};
|
|
@@ -602,11 +606,12 @@ var size = function(options) {
|
|
|
602
606
|
platform: platform2,
|
|
603
607
|
elements
|
|
604
608
|
} = state;
|
|
605
|
-
const {
|
|
609
|
+
const _a = options, {
|
|
606
610
|
apply = () => {
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
|
|
611
|
+
}
|
|
612
|
+
} = _a, detectOverflowOptions = __objRest(_a, [
|
|
613
|
+
"apply"
|
|
614
|
+
]);
|
|
610
615
|
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
611
616
|
const side = getSide(placement);
|
|
612
617
|
const alignment = getAlignment(placement);
|
|
@@ -648,11 +653,10 @@ var size = function(options) {
|
|
|
648
653
|
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
649
654
|
}
|
|
650
655
|
}
|
|
651
|
-
await apply({
|
|
652
|
-
...state,
|
|
656
|
+
await apply(__spreadProps(__spreadValues({}, state), {
|
|
653
657
|
availableWidth,
|
|
654
658
|
availableHeight
|
|
655
|
-
});
|
|
659
|
+
}));
|
|
656
660
|
const nextDimensions = await platform2.getDimensions(elements.floating);
|
|
657
661
|
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
658
662
|
return {
|
|
@@ -1001,9 +1005,7 @@ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy)
|
|
|
1001
1005
|
} else if (isElement(clippingAncestor)) {
|
|
1002
1006
|
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1003
1007
|
} else {
|
|
1004
|
-
const mutableRect = {
|
|
1005
|
-
...clippingAncestor
|
|
1006
|
-
};
|
|
1008
|
+
const mutableRect = __spreadValues({}, clippingAncestor);
|
|
1007
1009
|
if (isClientRectVisualViewportBased()) {
|
|
1008
1010
|
var _win$visualViewport, _win$visualViewport2;
|
|
1009
1011
|
const win = getWindow(element);
|
|
@@ -1151,11 +1153,10 @@ var platform = {
|
|
|
1151
1153
|
const getDimensionsFn = this.getDimensions;
|
|
1152
1154
|
return {
|
|
1153
1155
|
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1154
|
-
floating: {
|
|
1156
|
+
floating: __spreadValues({
|
|
1155
1157
|
x: 0,
|
|
1156
|
-
y: 0
|
|
1157
|
-
|
|
1158
|
-
}
|
|
1158
|
+
y: 0
|
|
1159
|
+
}, await getDimensionsFn(floating))
|
|
1159
1160
|
};
|
|
1160
1161
|
},
|
|
1161
1162
|
getClientRects: (element) => Array.from(element.getClientRects()),
|
|
@@ -1219,18 +1220,15 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1219
1220
|
}
|
|
1220
1221
|
var computePosition2 = (reference, floating, options) => {
|
|
1221
1222
|
const cache = /* @__PURE__ */ new Map();
|
|
1222
|
-
const mergedOptions = {
|
|
1223
|
-
platform
|
|
1224
|
-
|
|
1225
|
-
}
|
|
1226
|
-
const platformWithCache = {
|
|
1227
|
-
...mergedOptions.platform,
|
|
1223
|
+
const mergedOptions = __spreadValues({
|
|
1224
|
+
platform
|
|
1225
|
+
}, options);
|
|
1226
|
+
const platformWithCache = __spreadProps(__spreadValues({}, mergedOptions.platform), {
|
|
1228
1227
|
_c: cache
|
|
1229
|
-
};
|
|
1230
|
-
return computePosition(reference, floating, {
|
|
1231
|
-
...mergedOptions,
|
|
1232
|
-
platform: platformWithCache
|
|
1233
1228
|
});
|
|
1229
|
+
return computePosition(reference, floating, __spreadProps(__spreadValues({}, mergedOptions), {
|
|
1230
|
+
platform: platformWithCache
|
|
1231
|
+
}));
|
|
1234
1232
|
};
|
|
1235
1233
|
|
|
1236
1234
|
// src/popover/popover-store.ts
|
|
@@ -1249,7 +1247,7 @@ function createDOMRect(x = 0, y = 0, width = 0, height = 0) {
|
|
|
1249
1247
|
bottom: y + height,
|
|
1250
1248
|
left: x
|
|
1251
1249
|
};
|
|
1252
|
-
return {
|
|
1250
|
+
return __spreadProps(__spreadValues({}, rect), { toJSON: () => rect });
|
|
1253
1251
|
}
|
|
1254
1252
|
function getDOMRect(anchorRect) {
|
|
1255
1253
|
if (!anchorRect)
|
|
@@ -1263,7 +1261,7 @@ function getAnchorElement(anchorElement, getAnchorRect) {
|
|
|
1263
1261
|
contextElement,
|
|
1264
1262
|
getBoundingClientRect: () => {
|
|
1265
1263
|
const anchor = anchorElement;
|
|
1266
|
-
const anchorRect = getAnchorRect
|
|
1264
|
+
const anchorRect = getAnchorRect == null ? void 0 : getAnchorRect(anchor);
|
|
1267
1265
|
if (anchorRect || !anchor) {
|
|
1268
1266
|
return getDOMRect(anchorRect);
|
|
1269
1267
|
}
|
|
@@ -1274,15 +1272,19 @@ function getAnchorElement(anchorElement, getAnchorRect) {
|
|
|
1274
1272
|
function isValidPlacement(flip2) {
|
|
1275
1273
|
return /^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(flip2);
|
|
1276
1274
|
}
|
|
1277
|
-
function createPopoverStore({
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
} =
|
|
1275
|
+
function createPopoverStore(_a = {}) {
|
|
1276
|
+
var _b = _a, {
|
|
1277
|
+
getAnchorRect,
|
|
1278
|
+
renderCallback,
|
|
1279
|
+
popover: otherPopover
|
|
1280
|
+
} = _b, props = __objRest(_b, [
|
|
1281
|
+
"getAnchorRect",
|
|
1282
|
+
"renderCallback",
|
|
1283
|
+
"popover"
|
|
1284
|
+
]);
|
|
1283
1285
|
const store = mergeStore(
|
|
1284
1286
|
props.store,
|
|
1285
|
-
otherPopover
|
|
1287
|
+
otherPopover == null ? void 0 : otherPopover.omit(
|
|
1286
1288
|
"arrowElement",
|
|
1287
1289
|
"anchorElement",
|
|
1288
1290
|
"contentElement",
|
|
@@ -1290,36 +1292,35 @@ function createPopoverStore({
|
|
|
1290
1292
|
"disclosureElement"
|
|
1291
1293
|
)
|
|
1292
1294
|
);
|
|
1293
|
-
const syncState = store
|
|
1295
|
+
const syncState = store == null ? void 0 : store.getState();
|
|
1294
1296
|
const rendered = createStore({ rendered: [] });
|
|
1295
|
-
const dialog = createDialogStore({
|
|
1297
|
+
const dialog = createDialogStore(__spreadProps(__spreadValues({}, props), { store }));
|
|
1296
1298
|
const placement = defaultValue(
|
|
1297
1299
|
props.placement,
|
|
1298
|
-
syncState
|
|
1300
|
+
syncState == null ? void 0 : syncState.placement,
|
|
1299
1301
|
"bottom"
|
|
1300
1302
|
);
|
|
1301
|
-
const initialState = {
|
|
1302
|
-
...dialog.getState(),
|
|
1303
|
+
const initialState = __spreadProps(__spreadValues({}, dialog.getState()), {
|
|
1303
1304
|
placement,
|
|
1304
1305
|
currentPlacement: placement,
|
|
1305
|
-
fixed: defaultValue(props.fixed, syncState
|
|
1306
|
-
gutter: defaultValue(props.gutter, syncState
|
|
1307
|
-
flip: defaultValue(props.flip, syncState
|
|
1308
|
-
shift: defaultValue(props.shift, syncState
|
|
1309
|
-
slide: defaultValue(props.slide, syncState
|
|
1310
|
-
overlap: defaultValue(props.overlap, syncState
|
|
1311
|
-
sameWidth: defaultValue(props.sameWidth, syncState
|
|
1312
|
-
fitViewport: defaultValue(props.fitViewport, syncState
|
|
1313
|
-
arrowPadding: defaultValue(props.arrowPadding, syncState
|
|
1306
|
+
fixed: defaultValue(props.fixed, syncState == null ? void 0 : syncState.fixed, false),
|
|
1307
|
+
gutter: defaultValue(props.gutter, syncState == null ? void 0 : syncState.gutter),
|
|
1308
|
+
flip: defaultValue(props.flip, syncState == null ? void 0 : syncState.flip, true),
|
|
1309
|
+
shift: defaultValue(props.shift, syncState == null ? void 0 : syncState.shift, 0),
|
|
1310
|
+
slide: defaultValue(props.slide, syncState == null ? void 0 : syncState.slide, true),
|
|
1311
|
+
overlap: defaultValue(props.overlap, syncState == null ? void 0 : syncState.overlap, false),
|
|
1312
|
+
sameWidth: defaultValue(props.sameWidth, syncState == null ? void 0 : syncState.sameWidth, false),
|
|
1313
|
+
fitViewport: defaultValue(props.fitViewport, syncState == null ? void 0 : syncState.fitViewport, false),
|
|
1314
|
+
arrowPadding: defaultValue(props.arrowPadding, syncState == null ? void 0 : syncState.arrowPadding, 4),
|
|
1314
1315
|
overflowPadding: defaultValue(
|
|
1315
1316
|
props.overflowPadding,
|
|
1316
|
-
syncState
|
|
1317
|
+
syncState == null ? void 0 : syncState.overflowPadding,
|
|
1317
1318
|
8
|
|
1318
1319
|
),
|
|
1319
|
-
anchorElement: defaultValue(syncState
|
|
1320
|
-
popoverElement: defaultValue(syncState
|
|
1321
|
-
arrowElement: defaultValue(syncState
|
|
1322
|
-
};
|
|
1320
|
+
anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
|
|
1321
|
+
popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
|
|
1322
|
+
arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null)
|
|
1323
|
+
});
|
|
1323
1324
|
const popover = createStore(initialState, dialog, store);
|
|
1324
1325
|
const setCurrentPlacement = (placement2) => {
|
|
1325
1326
|
popover.setState("currentPlacement", placement2);
|
|
@@ -1328,7 +1329,8 @@ function createPopoverStore({
|
|
|
1328
1329
|
() => rendered.sync(
|
|
1329
1330
|
() => popover.syncBatch(
|
|
1330
1331
|
(state) => {
|
|
1331
|
-
|
|
1332
|
+
var _a2;
|
|
1333
|
+
if (!((_a2 = state.contentElement) == null ? void 0 : _a2.isConnected))
|
|
1332
1334
|
return;
|
|
1333
1335
|
const popover2 = state.popoverElement;
|
|
1334
1336
|
if (!popover2)
|
|
@@ -1346,8 +1348,9 @@ function createPopoverStore({
|
|
|
1346
1348
|
const middleware = [
|
|
1347
1349
|
// https://floating-ui.com/docs/offset
|
|
1348
1350
|
middlewares.offset(({ placement: placement2 }) => {
|
|
1349
|
-
|
|
1350
|
-
const
|
|
1351
|
+
var _a3;
|
|
1352
|
+
const arrowOffset = ((arrow2 == null ? void 0 : arrow2.clientHeight) || 0) / 2;
|
|
1353
|
+
const finalGutter = typeof state.gutter === "number" ? state.gutter + arrowOffset : (_a3 = state.gutter) != null ? _a3 : arrowOffset;
|
|
1351
1354
|
const hasAlignment = !!placement2.split("-")[1];
|
|
1352
1355
|
return {
|
|
1353
1356
|
crossAxis: !hasAlignment ? state.shift : void 0,
|
|
@@ -1445,11 +1448,10 @@ function createPopoverStore({
|
|
|
1445
1448
|
});
|
|
1446
1449
|
};
|
|
1447
1450
|
if (renderCallback) {
|
|
1448
|
-
return renderCallback({
|
|
1449
|
-
...state,
|
|
1451
|
+
return renderCallback(__spreadProps(__spreadValues({}, state), {
|
|
1450
1452
|
setPlacement: setCurrentPlacement,
|
|
1451
1453
|
defaultRenderCallback
|
|
1452
|
-
});
|
|
1454
|
+
}));
|
|
1453
1455
|
}
|
|
1454
1456
|
return defaultRenderCallback();
|
|
1455
1457
|
},
|
|
@@ -1474,16 +1476,14 @@ function createPopoverStore({
|
|
|
1474
1476
|
)
|
|
1475
1477
|
)
|
|
1476
1478
|
);
|
|
1477
|
-
return {
|
|
1478
|
-
...dialog,
|
|
1479
|
-
...popover,
|
|
1479
|
+
return __spreadProps(__spreadValues(__spreadValues({}, dialog), popover), {
|
|
1480
1480
|
setAnchorElement: (element) => popover.setState("anchorElement", element),
|
|
1481
1481
|
setPopoverElement: (element) => popover.setState("popoverElement", element),
|
|
1482
1482
|
setArrowElement: (element) => popover.setState("arrowElement", element),
|
|
1483
1483
|
render: () => rendered.setState("rendered", []),
|
|
1484
1484
|
getAnchorRect,
|
|
1485
1485
|
renderCallback
|
|
1486
|
-
};
|
|
1486
|
+
});
|
|
1487
1487
|
}
|
|
1488
1488
|
|
|
1489
1489
|
export {
|