wj-elements 0.0.11 → 0.0.13
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/dist/localize-20081fd1.js +55 -0
- package/dist/router-links-26e4a166.js +204 -0
- package/dist/style.css +2243 -2
- package/dist/wj-animation.js +35 -23
- package/dist/wj-aside.js +22 -16
- package/dist/wj-avatar.js +49 -30
- package/dist/wj-badge.js +22 -18
- package/dist/wj-breadcrumb.js +102 -50
- package/dist/wj-breadcrumbs.js +36 -19
- package/dist/wj-button-group.js +36 -22
- package/dist/wj-button.js +104 -39
- package/dist/wj-card-content.js +18 -14
- package/dist/wj-card-controls.js +18 -14
- package/dist/wj-card-header.js +20 -14
- package/dist/wj-card-subtitle.js +19 -15
- package/dist/wj-card-title.js +18 -14
- package/dist/wj-card.js +20 -14
- package/dist/wj-carousel-item.js +22 -16
- package/dist/wj-carousel.js +169 -92
- package/dist/wj-checkbox.js +46 -24
- package/dist/wj-chip.js +39 -21
- package/dist/wj-col.js +31 -17
- package/dist/wj-color-picker.js +877 -509
- package/dist/wj-container.js +20 -16
- package/dist/wj-copy-button.js +112 -64
- package/dist/wj-dialog.js +68 -42
- package/dist/wj-divider.js +20 -14
- package/dist/wj-dropdown.js +29 -17
- package/dist/wj-element.js +415 -241
- package/dist/wj-fetchAndParseCSS.js +49 -32
- package/dist/wj-file-upload-item.js +64 -38
- package/dist/wj-file-upload.js +237 -137
- package/dist/wj-footer.js +18 -14
- package/dist/wj-form.js +18 -14
- package/dist/wj-format-digital.js +40 -25
- package/dist/wj-grid.js +20 -16
- package/dist/wj-header.js +22 -16
- package/dist/wj-icon-picker.js +122 -68
- package/dist/wj-icon.js +144 -64
- package/dist/wj-img-comparer.js +72 -41
- package/dist/wj-img.js +31 -19
- package/dist/wj-infinite-scroll.js +90 -52
- package/dist/wj-input-file.js +50 -27
- package/dist/wj-input.js +169 -70
- package/dist/wj-item.js +34 -17
- package/dist/wj-label.js +21 -19
- package/dist/wj-list.js +20 -15
- package/dist/wj-main.js +18 -14
- package/dist/wj-masonry.js +140 -83
- package/dist/wj-master.js +492 -350
- package/dist/wj-menu-button.js +19 -15
- package/dist/wj-menu-item.js +150 -64
- package/dist/wj-menu-label.js +21 -17
- package/dist/wj-menu.js +24 -18
- package/dist/wj-popup.js +1140 -712
- package/dist/wj-progress-bar.js +100 -40
- package/dist/wj-radio-group.js +38 -25
- package/dist/wj-radio.js +46 -22
- package/dist/wj-rate.js +121 -71
- package/dist/wj-relative-time.js +48 -24
- package/dist/wj-route.js +11 -8
- package/dist/wj-router-link.js +22 -17
- package/dist/wj-router-outlet.js +135 -71
- package/dist/wj-routerx.js +1124 -641
- package/dist/wj-row.js +21 -19
- package/dist/wj-slider.js +97 -55
- package/dist/wj-split-view.js +81 -43
- package/dist/wj-store.js +195 -110
- package/dist/wj-textarea.js +86 -37
- package/dist/wj-thumbnail.js +19 -15
- package/dist/wj-toast.js +87 -34
- package/dist/wj-toggle.js +42 -24
- package/dist/wj-toolbar-action.js +27 -16
- package/dist/wj-toolbar.js +26 -19
- package/dist/wj-tooltip.js +40 -24
- package/dist/wj-visually-hidden.js +18 -14
- package/package.json +1 -1
- package/dist/localize-762a9f0f.js +0 -43
- package/dist/router-links-e0087f84.js +0 -146
package/dist/wj-popup.js
CHANGED
|
@@ -1,900 +1,1278 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import WJElement, { event } from "./wj-element.js";
|
|
5
8
|
import "./wj-store.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const min = Math.min;
|
|
10
|
+
const max = Math.max;
|
|
11
|
+
const round = Math.round;
|
|
12
|
+
const floor = Math.floor;
|
|
13
|
+
const createCoords = (v) => ({
|
|
14
|
+
x: v,
|
|
15
|
+
y: v
|
|
16
|
+
});
|
|
17
|
+
const oppositeSideMap = {
|
|
10
18
|
left: "right",
|
|
11
19
|
right: "left",
|
|
12
20
|
bottom: "top",
|
|
13
21
|
top: "bottom"
|
|
14
|
-
}
|
|
22
|
+
};
|
|
23
|
+
const oppositeAlignmentMap = {
|
|
15
24
|
start: "end",
|
|
16
25
|
end: "start"
|
|
17
26
|
};
|
|
18
|
-
function
|
|
19
|
-
return
|
|
27
|
+
function clamp(start, value, end) {
|
|
28
|
+
return max(start, min(value, end));
|
|
20
29
|
}
|
|
21
|
-
function
|
|
22
|
-
return typeof
|
|
30
|
+
function evaluate(value, param) {
|
|
31
|
+
return typeof value === "function" ? value(param) : value;
|
|
23
32
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
33
|
+
function getSide(placement) {
|
|
34
|
+
return placement.split("-")[0];
|
|
26
35
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
36
|
+
function getAlignment(placement) {
|
|
37
|
+
return placement.split("-")[1];
|
|
29
38
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
39
|
+
function getOppositeAxis(axis) {
|
|
40
|
+
return axis === "x" ? "y" : "x";
|
|
32
41
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
42
|
+
function getAxisLength(axis) {
|
|
43
|
+
return axis === "y" ? "height" : "width";
|
|
35
44
|
}
|
|
36
|
-
function
|
|
37
|
-
return ["top", "bottom"].includes(
|
|
45
|
+
function getSideAxis(placement) {
|
|
46
|
+
return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
|
|
38
47
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
48
|
+
function getAlignmentAxis(placement) {
|
|
49
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
41
50
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
52
|
+
if (rtl === void 0) {
|
|
53
|
+
rtl = false;
|
|
54
|
+
}
|
|
55
|
+
const alignment = getAlignment(placement);
|
|
56
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
57
|
+
const length = getAxisLength(alignmentAxis);
|
|
58
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
59
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
60
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
61
|
+
}
|
|
62
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
47
63
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
return [
|
|
64
|
+
function getExpandedPlacements(placement) {
|
|
65
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
66
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
51
67
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
68
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
69
|
+
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
54
70
|
}
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
|
|
71
|
+
function getSideList(side, isStart, rtl) {
|
|
72
|
+
const lr = ["left", "right"];
|
|
73
|
+
const rl = ["right", "left"];
|
|
74
|
+
const tb = ["top", "bottom"];
|
|
75
|
+
const bt = ["bottom", "top"];
|
|
76
|
+
switch (side) {
|
|
58
77
|
case "top":
|
|
59
78
|
case "bottom":
|
|
60
|
-
|
|
79
|
+
if (rtl)
|
|
80
|
+
return isStart ? rl : lr;
|
|
81
|
+
return isStart ? lr : rl;
|
|
61
82
|
case "left":
|
|
62
83
|
case "right":
|
|
63
|
-
return
|
|
84
|
+
return isStart ? tb : bt;
|
|
64
85
|
default:
|
|
65
86
|
return [];
|
|
66
87
|
}
|
|
67
88
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
let
|
|
71
|
-
|
|
89
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
90
|
+
const alignment = getAlignment(placement);
|
|
91
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
92
|
+
if (alignment) {
|
|
93
|
+
list = list.map((side) => side + "-" + alignment);
|
|
94
|
+
if (flipAlignment) {
|
|
95
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return list;
|
|
72
99
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
100
|
+
function getOppositePlacement(placement) {
|
|
101
|
+
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
75
102
|
}
|
|
76
|
-
function
|
|
103
|
+
function expandPaddingObject(padding) {
|
|
77
104
|
return {
|
|
78
105
|
top: 0,
|
|
79
106
|
right: 0,
|
|
80
107
|
bottom: 0,
|
|
81
108
|
left: 0,
|
|
82
|
-
...
|
|
109
|
+
...padding
|
|
83
110
|
};
|
|
84
111
|
}
|
|
85
|
-
function
|
|
86
|
-
return typeof
|
|
87
|
-
top:
|
|
88
|
-
right:
|
|
89
|
-
bottom:
|
|
90
|
-
left:
|
|
112
|
+
function getPaddingObject(padding) {
|
|
113
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
114
|
+
top: padding,
|
|
115
|
+
right: padding,
|
|
116
|
+
bottom: padding,
|
|
117
|
+
left: padding
|
|
91
118
|
};
|
|
92
119
|
}
|
|
93
|
-
function
|
|
120
|
+
function rectToClientRect(rect) {
|
|
94
121
|
return {
|
|
95
|
-
...
|
|
96
|
-
top:
|
|
97
|
-
left:
|
|
98
|
-
right:
|
|
99
|
-
bottom:
|
|
122
|
+
...rect,
|
|
123
|
+
top: rect.y,
|
|
124
|
+
left: rect.x,
|
|
125
|
+
right: rect.x + rect.width,
|
|
126
|
+
bottom: rect.y + rect.height
|
|
100
127
|
};
|
|
101
128
|
}
|
|
102
|
-
function
|
|
129
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
103
130
|
let {
|
|
104
|
-
reference
|
|
105
|
-
floating
|
|
106
|
-
} =
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
reference,
|
|
132
|
+
floating
|
|
133
|
+
} = _ref;
|
|
134
|
+
const sideAxis = getSideAxis(placement);
|
|
135
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
136
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
137
|
+
const side = getSide(placement);
|
|
138
|
+
const isVertical = sideAxis === "y";
|
|
139
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
140
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
141
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
142
|
+
let coords;
|
|
143
|
+
switch (side) {
|
|
110
144
|
case "top":
|
|
111
|
-
|
|
112
|
-
x:
|
|
113
|
-
y:
|
|
145
|
+
coords = {
|
|
146
|
+
x: commonX,
|
|
147
|
+
y: reference.y - floating.height
|
|
114
148
|
};
|
|
115
149
|
break;
|
|
116
150
|
case "bottom":
|
|
117
|
-
|
|
118
|
-
x:
|
|
119
|
-
y:
|
|
151
|
+
coords = {
|
|
152
|
+
x: commonX,
|
|
153
|
+
y: reference.y + reference.height
|
|
120
154
|
};
|
|
121
155
|
break;
|
|
122
156
|
case "right":
|
|
123
|
-
|
|
124
|
-
x:
|
|
125
|
-
y:
|
|
157
|
+
coords = {
|
|
158
|
+
x: reference.x + reference.width,
|
|
159
|
+
y: commonY
|
|
126
160
|
};
|
|
127
161
|
break;
|
|
128
162
|
case "left":
|
|
129
|
-
|
|
130
|
-
x:
|
|
131
|
-
y:
|
|
163
|
+
coords = {
|
|
164
|
+
x: reference.x - floating.width,
|
|
165
|
+
y: commonY
|
|
132
166
|
};
|
|
133
167
|
break;
|
|
134
168
|
default:
|
|
135
|
-
|
|
136
|
-
x:
|
|
137
|
-
y:
|
|
169
|
+
coords = {
|
|
170
|
+
x: reference.x,
|
|
171
|
+
y: reference.y
|
|
138
172
|
};
|
|
139
173
|
}
|
|
140
|
-
switch (
|
|
174
|
+
switch (getAlignment(placement)) {
|
|
141
175
|
case "start":
|
|
142
|
-
|
|
176
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
143
177
|
break;
|
|
144
178
|
case "end":
|
|
145
|
-
|
|
179
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
146
180
|
break;
|
|
147
181
|
}
|
|
148
|
-
return
|
|
182
|
+
return coords;
|
|
149
183
|
}
|
|
150
|
-
const
|
|
184
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
151
185
|
const {
|
|
152
|
-
placement
|
|
153
|
-
strategy
|
|
154
|
-
middleware
|
|
155
|
-
platform:
|
|
156
|
-
} =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
186
|
+
placement = "bottom",
|
|
187
|
+
strategy = "absolute",
|
|
188
|
+
middleware = [],
|
|
189
|
+
platform: platform2
|
|
190
|
+
} = config;
|
|
191
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
192
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
193
|
+
let rects = await platform2.getElementRects({
|
|
194
|
+
reference,
|
|
195
|
+
floating,
|
|
196
|
+
strategy
|
|
197
|
+
});
|
|
198
|
+
let {
|
|
199
|
+
x,
|
|
200
|
+
y
|
|
201
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
202
|
+
let statefulPlacement = placement;
|
|
203
|
+
let middlewareData = {};
|
|
204
|
+
let resetCount = 0;
|
|
205
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
206
|
+
const {
|
|
207
|
+
name,
|
|
208
|
+
fn
|
|
209
|
+
} = validMiddleware[i];
|
|
166
210
|
const {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
211
|
+
x: nextX,
|
|
212
|
+
y: nextY,
|
|
213
|
+
data,
|
|
214
|
+
reset
|
|
215
|
+
} = await fn({
|
|
216
|
+
x,
|
|
171
217
|
y,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
placement: p,
|
|
179
|
-
strategy: i,
|
|
180
|
-
middlewareData: f,
|
|
181
|
-
rects: a,
|
|
182
|
-
platform: r,
|
|
218
|
+
initialPlacement: placement,
|
|
219
|
+
placement: statefulPlacement,
|
|
220
|
+
strategy,
|
|
221
|
+
middlewareData,
|
|
222
|
+
rects,
|
|
223
|
+
platform: platform2,
|
|
183
224
|
elements: {
|
|
184
|
-
reference
|
|
185
|
-
floating
|
|
225
|
+
reference,
|
|
226
|
+
floating
|
|
186
227
|
}
|
|
187
228
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
229
|
+
x = nextX != null ? nextX : x;
|
|
230
|
+
y = nextY != null ? nextY : y;
|
|
231
|
+
middlewareData = {
|
|
232
|
+
...middlewareData,
|
|
233
|
+
[name]: {
|
|
234
|
+
...middlewareData[name],
|
|
235
|
+
...data
|
|
193
236
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
237
|
+
};
|
|
238
|
+
if (reset && resetCount <= 50) {
|
|
239
|
+
resetCount++;
|
|
240
|
+
if (typeof reset === "object") {
|
|
241
|
+
if (reset.placement) {
|
|
242
|
+
statefulPlacement = reset.placement;
|
|
243
|
+
}
|
|
244
|
+
if (reset.rects) {
|
|
245
|
+
rects = reset.rects === true ? await platform2.getElementRects({
|
|
246
|
+
reference,
|
|
247
|
+
floating,
|
|
248
|
+
strategy
|
|
249
|
+
}) : reset.rects;
|
|
250
|
+
}
|
|
251
|
+
({
|
|
252
|
+
x,
|
|
253
|
+
y
|
|
254
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
255
|
+
}
|
|
256
|
+
i = -1;
|
|
203
257
|
continue;
|
|
204
258
|
}
|
|
205
259
|
}
|
|
206
260
|
return {
|
|
207
|
-
x
|
|
208
|
-
y
|
|
209
|
-
placement:
|
|
210
|
-
strategy
|
|
211
|
-
middlewareData
|
|
261
|
+
x,
|
|
262
|
+
y,
|
|
263
|
+
placement: statefulPlacement,
|
|
264
|
+
strategy,
|
|
265
|
+
middlewareData
|
|
212
266
|
};
|
|
213
267
|
};
|
|
214
|
-
async function
|
|
215
|
-
var
|
|
216
|
-
|
|
268
|
+
async function detectOverflow(state, options) {
|
|
269
|
+
var _await$platform$isEle;
|
|
270
|
+
if (options === void 0) {
|
|
271
|
+
options = {};
|
|
272
|
+
}
|
|
217
273
|
const {
|
|
218
|
-
x
|
|
219
|
-
y
|
|
220
|
-
platform:
|
|
221
|
-
rects
|
|
222
|
-
elements
|
|
223
|
-
strategy
|
|
224
|
-
} =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
274
|
+
x,
|
|
275
|
+
y,
|
|
276
|
+
platform: platform2,
|
|
277
|
+
rects,
|
|
278
|
+
elements,
|
|
279
|
+
strategy
|
|
280
|
+
} = state;
|
|
281
|
+
const {
|
|
282
|
+
boundary = "clippingAncestors",
|
|
283
|
+
rootBoundary = "viewport",
|
|
284
|
+
elementContext = "floating",
|
|
285
|
+
altBoundary = false,
|
|
286
|
+
padding = 0
|
|
287
|
+
} = evaluate(options, state);
|
|
288
|
+
const paddingObject = getPaddingObject(padding);
|
|
289
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
290
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
291
|
+
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
292
|
+
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
293
|
+
boundary,
|
|
294
|
+
rootBoundary,
|
|
295
|
+
strategy
|
|
296
|
+
}));
|
|
297
|
+
const rect = elementContext === "floating" ? {
|
|
298
|
+
...rects.floating,
|
|
299
|
+
x,
|
|
300
|
+
y
|
|
301
|
+
} : rects.reference;
|
|
302
|
+
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
303
|
+
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
240
304
|
x: 1,
|
|
241
305
|
y: 1
|
|
242
306
|
} : {
|
|
243
307
|
x: 1,
|
|
244
308
|
y: 1
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
309
|
+
};
|
|
310
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
311
|
+
rect,
|
|
312
|
+
offsetParent,
|
|
313
|
+
strategy
|
|
314
|
+
}) : rect);
|
|
250
315
|
return {
|
|
251
|
-
top: (
|
|
252
|
-
bottom: (
|
|
253
|
-
left: (
|
|
254
|
-
right: (
|
|
316
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
317
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
318
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
319
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
255
320
|
};
|
|
256
321
|
}
|
|
257
|
-
const
|
|
322
|
+
const arrow = (options) => ({
|
|
258
323
|
name: "arrow",
|
|
259
|
-
options
|
|
260
|
-
async fn(
|
|
324
|
+
options,
|
|
325
|
+
async fn(state) {
|
|
326
|
+
const {
|
|
327
|
+
x,
|
|
328
|
+
y,
|
|
329
|
+
placement,
|
|
330
|
+
rects,
|
|
331
|
+
platform: platform2,
|
|
332
|
+
elements,
|
|
333
|
+
middlewareData
|
|
334
|
+
} = state;
|
|
261
335
|
const {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
platform: r,
|
|
267
|
-
elements: l,
|
|
268
|
-
middlewareData: c
|
|
269
|
-
} = e, {
|
|
270
|
-
element: a,
|
|
271
|
-
padding: d = 0
|
|
272
|
-
} = K(t, e) || {};
|
|
273
|
-
if (a == null)
|
|
336
|
+
element,
|
|
337
|
+
padding = 0
|
|
338
|
+
} = evaluate(options, state) || {};
|
|
339
|
+
if (element == null) {
|
|
274
340
|
return {};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const
|
|
341
|
+
}
|
|
342
|
+
const paddingObject = getPaddingObject(padding);
|
|
343
|
+
const coords = {
|
|
344
|
+
x,
|
|
345
|
+
y
|
|
346
|
+
};
|
|
347
|
+
const axis = getAlignmentAxis(placement);
|
|
348
|
+
const length = getAxisLength(axis);
|
|
349
|
+
const arrowDimensions = await platform2.getDimensions(element);
|
|
350
|
+
const isYAxis = axis === "y";
|
|
351
|
+
const minProp = isYAxis ? "top" : "left";
|
|
352
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
353
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
354
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
355
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
356
|
+
const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
|
357
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
358
|
+
if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
|
359
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
360
|
+
}
|
|
361
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
362
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
363
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
364
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
365
|
+
const min$1 = minPadding;
|
|
366
|
+
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
367
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
368
|
+
const offset2 = clamp(min$1, center, max2);
|
|
369
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
370
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
282
371
|
return {
|
|
283
|
-
[
|
|
372
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
284
373
|
data: {
|
|
285
|
-
[
|
|
286
|
-
centerOffset:
|
|
287
|
-
...
|
|
288
|
-
alignmentOffset
|
|
374
|
+
[axis]: offset2,
|
|
375
|
+
centerOffset: center - offset2 - alignmentOffset,
|
|
376
|
+
...shouldAddOffset && {
|
|
377
|
+
alignmentOffset
|
|
289
378
|
}
|
|
290
379
|
},
|
|
291
|
-
reset:
|
|
380
|
+
reset: shouldAddOffset
|
|
292
381
|
};
|
|
293
382
|
}
|
|
294
|
-
})
|
|
295
|
-
|
|
383
|
+
});
|
|
384
|
+
const flip = function(options) {
|
|
385
|
+
if (options === void 0) {
|
|
386
|
+
options = {};
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
296
389
|
name: "flip",
|
|
297
|
-
options
|
|
298
|
-
async fn(
|
|
299
|
-
var
|
|
390
|
+
options,
|
|
391
|
+
async fn(state) {
|
|
392
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
300
393
|
const {
|
|
301
|
-
placement
|
|
302
|
-
middlewareData
|
|
303
|
-
rects
|
|
304
|
-
initialPlacement
|
|
305
|
-
platform:
|
|
306
|
-
elements
|
|
307
|
-
} =
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
394
|
+
placement,
|
|
395
|
+
middlewareData,
|
|
396
|
+
rects,
|
|
397
|
+
initialPlacement,
|
|
398
|
+
platform: platform2,
|
|
399
|
+
elements
|
|
400
|
+
} = state;
|
|
401
|
+
const {
|
|
402
|
+
mainAxis: checkMainAxis = true,
|
|
403
|
+
crossAxis: checkCrossAxis = true,
|
|
404
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
405
|
+
fallbackStrategy = "bestFit",
|
|
406
|
+
fallbackAxisSideDirection = "none",
|
|
407
|
+
flipAlignment = true,
|
|
408
|
+
...detectOverflowOptions
|
|
409
|
+
} = evaluate(options, state);
|
|
410
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
317
411
|
return {};
|
|
318
|
-
const g = V(i), v = V(l) === l, y = await (c.isRTL == null ? void 0 : c.isRTL(a.floating)), A = p || (v || !m ? [tt(l)] : Ht(l));
|
|
319
|
-
!p && h !== "none" && A.push(...Ft(l, m, h, y));
|
|
320
|
-
const x = [l, ...A], b = await wt(e, w), E = [];
|
|
321
|
-
let P = ((o = s.flip) == null ? void 0 : o.overflows) || [];
|
|
322
|
-
if (d && E.push(b[g]), u) {
|
|
323
|
-
const L = Wt(i, r, y);
|
|
324
|
-
E.push(b[L[0]], b[L[1]]);
|
|
325
412
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
413
|
+
const side = getSide(placement);
|
|
414
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
415
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
416
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
417
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
|
|
418
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
419
|
+
}
|
|
420
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
421
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
422
|
+
const overflows = [];
|
|
423
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
424
|
+
if (checkMainAxis) {
|
|
425
|
+
overflows.push(overflow[side]);
|
|
426
|
+
}
|
|
427
|
+
if (checkCrossAxis) {
|
|
428
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
429
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
430
|
+
}
|
|
431
|
+
overflowsData = [...overflowsData, {
|
|
432
|
+
placement,
|
|
433
|
+
overflows
|
|
434
|
+
}];
|
|
435
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
436
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
437
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
438
|
+
const nextPlacement = placements[nextIndex];
|
|
439
|
+
if (nextPlacement) {
|
|
333
440
|
return {
|
|
334
441
|
data: {
|
|
335
|
-
index:
|
|
336
|
-
overflows:
|
|
442
|
+
index: nextIndex,
|
|
443
|
+
overflows: overflowsData
|
|
337
444
|
},
|
|
338
445
|
reset: {
|
|
339
|
-
placement:
|
|
446
|
+
placement: nextPlacement
|
|
340
447
|
}
|
|
341
448
|
};
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
449
|
+
}
|
|
450
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
451
|
+
if (!resetPlacement) {
|
|
452
|
+
switch (fallbackStrategy) {
|
|
345
453
|
case "bestFit": {
|
|
346
|
-
var
|
|
347
|
-
const
|
|
348
|
-
|
|
454
|
+
var _overflowsData$map$so;
|
|
455
|
+
const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
|
|
456
|
+
if (placement2) {
|
|
457
|
+
resetPlacement = placement2;
|
|
458
|
+
}
|
|
349
459
|
break;
|
|
350
460
|
}
|
|
351
461
|
case "initialPlacement":
|
|
352
|
-
|
|
462
|
+
resetPlacement = initialPlacement;
|
|
353
463
|
break;
|
|
354
464
|
}
|
|
355
|
-
|
|
465
|
+
}
|
|
466
|
+
if (placement !== resetPlacement) {
|
|
356
467
|
return {
|
|
357
468
|
reset: {
|
|
358
|
-
placement:
|
|
469
|
+
placement: resetPlacement
|
|
359
470
|
}
|
|
360
471
|
};
|
|
472
|
+
}
|
|
361
473
|
}
|
|
362
474
|
return {};
|
|
363
475
|
}
|
|
364
476
|
};
|
|
365
477
|
};
|
|
366
|
-
async function
|
|
478
|
+
async function convertValueToCoords(state, options) {
|
|
367
479
|
const {
|
|
368
|
-
placement
|
|
369
|
-
platform:
|
|
370
|
-
elements
|
|
371
|
-
} =
|
|
480
|
+
placement,
|
|
481
|
+
platform: platform2,
|
|
482
|
+
elements
|
|
483
|
+
} = state;
|
|
484
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
485
|
+
const side = getSide(placement);
|
|
486
|
+
const alignment = getAlignment(placement);
|
|
487
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
488
|
+
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
|
|
489
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
490
|
+
const rawValue = evaluate(options, state);
|
|
372
491
|
let {
|
|
373
|
-
mainAxis
|
|
374
|
-
crossAxis
|
|
375
|
-
alignmentAxis
|
|
376
|
-
} = typeof
|
|
377
|
-
mainAxis:
|
|
492
|
+
mainAxis,
|
|
493
|
+
crossAxis,
|
|
494
|
+
alignmentAxis
|
|
495
|
+
} = typeof rawValue === "number" ? {
|
|
496
|
+
mainAxis: rawValue,
|
|
378
497
|
crossAxis: 0,
|
|
379
498
|
alignmentAxis: null
|
|
380
499
|
} : {
|
|
381
500
|
mainAxis: 0,
|
|
382
501
|
crossAxis: 0,
|
|
383
502
|
alignmentAxis: null,
|
|
384
|
-
...
|
|
503
|
+
...rawValue
|
|
385
504
|
};
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
505
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
506
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
507
|
+
}
|
|
508
|
+
return isVertical ? {
|
|
509
|
+
x: crossAxis * crossAxisMulti,
|
|
510
|
+
y: mainAxis * mainAxisMulti
|
|
389
511
|
} : {
|
|
390
|
-
x:
|
|
391
|
-
y:
|
|
512
|
+
x: mainAxis * mainAxisMulti,
|
|
513
|
+
y: crossAxis * crossAxisMulti
|
|
392
514
|
};
|
|
393
515
|
}
|
|
394
|
-
const
|
|
395
|
-
|
|
516
|
+
const offset = function(options) {
|
|
517
|
+
if (options === void 0) {
|
|
518
|
+
options = 0;
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
396
521
|
name: "offset",
|
|
397
|
-
options
|
|
398
|
-
async fn(
|
|
522
|
+
options,
|
|
523
|
+
async fn(state) {
|
|
399
524
|
const {
|
|
400
|
-
x
|
|
401
|
-
y
|
|
402
|
-
} =
|
|
525
|
+
x,
|
|
526
|
+
y
|
|
527
|
+
} = state;
|
|
528
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
403
529
|
return {
|
|
404
|
-
x:
|
|
405
|
-
y:
|
|
406
|
-
data:
|
|
530
|
+
x: x + diffCoords.x,
|
|
531
|
+
y: y + diffCoords.y,
|
|
532
|
+
data: diffCoords
|
|
407
533
|
};
|
|
408
534
|
}
|
|
409
535
|
};
|
|
410
|
-
}
|
|
411
|
-
|
|
536
|
+
};
|
|
537
|
+
const size = function(options) {
|
|
538
|
+
if (options === void 0) {
|
|
539
|
+
options = {};
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
412
542
|
name: "size",
|
|
413
|
-
options
|
|
414
|
-
async fn(
|
|
543
|
+
options,
|
|
544
|
+
async fn(state) {
|
|
545
|
+
const {
|
|
546
|
+
placement,
|
|
547
|
+
rects,
|
|
548
|
+
platform: platform2,
|
|
549
|
+
elements
|
|
550
|
+
} = state;
|
|
415
551
|
const {
|
|
416
|
-
|
|
417
|
-
rects: o,
|
|
418
|
-
platform: i,
|
|
419
|
-
elements: s
|
|
420
|
-
} = e, {
|
|
421
|
-
apply: r = () => {
|
|
552
|
+
apply = () => {
|
|
422
553
|
},
|
|
423
|
-
...
|
|
424
|
-
} =
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
554
|
+
...detectOverflowOptions
|
|
555
|
+
} = evaluate(options, state);
|
|
556
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
557
|
+
const side = getSide(placement);
|
|
558
|
+
const alignment = getAlignment(placement);
|
|
559
|
+
const isYAxis = getSideAxis(placement) === "y";
|
|
560
|
+
const {
|
|
561
|
+
width,
|
|
562
|
+
height
|
|
563
|
+
} = rects.floating;
|
|
564
|
+
let heightSide;
|
|
565
|
+
let widthSide;
|
|
566
|
+
if (side === "top" || side === "bottom") {
|
|
567
|
+
heightSide = side;
|
|
568
|
+
widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
435
569
|
} else {
|
|
436
|
-
|
|
437
|
-
|
|
570
|
+
widthSide = side;
|
|
571
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
438
572
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
573
|
+
const overflowAvailableHeight = height - overflow[heightSide];
|
|
574
|
+
const overflowAvailableWidth = width - overflow[widthSide];
|
|
575
|
+
const noShift = !state.middlewareData.shift;
|
|
576
|
+
let availableHeight = overflowAvailableHeight;
|
|
577
|
+
let availableWidth = overflowAvailableWidth;
|
|
578
|
+
if (isYAxis) {
|
|
579
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
580
|
+
availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
|
|
581
|
+
} else {
|
|
582
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
583
|
+
availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
|
|
442
584
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
585
|
+
if (noShift && !alignment) {
|
|
586
|
+
const xMin = max(overflow.left, 0);
|
|
587
|
+
const xMax = max(overflow.right, 0);
|
|
588
|
+
const yMin = max(overflow.top, 0);
|
|
589
|
+
const yMax = max(overflow.bottom, 0);
|
|
590
|
+
if (isYAxis) {
|
|
591
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
592
|
+
} else {
|
|
593
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
452
594
|
}
|
|
453
|
-
}
|
|
595
|
+
}
|
|
596
|
+
await apply({
|
|
597
|
+
...state,
|
|
598
|
+
availableWidth,
|
|
599
|
+
availableHeight
|
|
600
|
+
});
|
|
601
|
+
const nextDimensions = await platform2.getDimensions(elements.floating);
|
|
602
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
603
|
+
return {
|
|
604
|
+
reset: {
|
|
605
|
+
rects: true
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
return {};
|
|
454
610
|
}
|
|
455
611
|
};
|
|
456
612
|
};
|
|
457
|
-
function
|
|
458
|
-
|
|
613
|
+
function getNodeName(node) {
|
|
614
|
+
if (isNode(node)) {
|
|
615
|
+
return (node.nodeName || "").toLowerCase();
|
|
616
|
+
}
|
|
617
|
+
return "#document";
|
|
459
618
|
}
|
|
460
|
-
function
|
|
461
|
-
var
|
|
462
|
-
return (
|
|
619
|
+
function getWindow(node) {
|
|
620
|
+
var _node$ownerDocument;
|
|
621
|
+
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
463
622
|
}
|
|
464
|
-
function
|
|
465
|
-
var
|
|
466
|
-
return (
|
|
623
|
+
function getDocumentElement(node) {
|
|
624
|
+
var _ref;
|
|
625
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
467
626
|
}
|
|
468
|
-
function
|
|
469
|
-
return
|
|
627
|
+
function isNode(value) {
|
|
628
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
470
629
|
}
|
|
471
|
-
function
|
|
472
|
-
return
|
|
630
|
+
function isElement(value) {
|
|
631
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
473
632
|
}
|
|
474
|
-
function
|
|
475
|
-
return
|
|
633
|
+
function isHTMLElement(value) {
|
|
634
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
476
635
|
}
|
|
477
|
-
function
|
|
478
|
-
|
|
636
|
+
function isShadowRoot(value) {
|
|
637
|
+
if (typeof ShadowRoot === "undefined") {
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
479
641
|
}
|
|
480
|
-
function
|
|
642
|
+
function isOverflowElement(element) {
|
|
481
643
|
const {
|
|
482
|
-
overflow
|
|
483
|
-
overflowX
|
|
484
|
-
overflowY
|
|
485
|
-
display
|
|
486
|
-
} =
|
|
487
|
-
return /auto|scroll|overlay|hidden|clip/.test(
|
|
488
|
-
}
|
|
489
|
-
function
|
|
490
|
-
return ["table", "td", "th"].includes(
|
|
491
|
-
}
|
|
492
|
-
function
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
644
|
+
overflow,
|
|
645
|
+
overflowX,
|
|
646
|
+
overflowY,
|
|
647
|
+
display
|
|
648
|
+
} = getComputedStyle(element);
|
|
649
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
|
|
650
|
+
}
|
|
651
|
+
function isTableElement(element) {
|
|
652
|
+
return ["table", "td", "th"].includes(getNodeName(element));
|
|
653
|
+
}
|
|
654
|
+
function isContainingBlock(element) {
|
|
655
|
+
const webkit = isWebKit();
|
|
656
|
+
const css = getComputedStyle(element);
|
|
657
|
+
return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
|
|
658
|
+
}
|
|
659
|
+
function getContainingBlock(element) {
|
|
660
|
+
let currentNode = getParentNode(element);
|
|
661
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
662
|
+
if (isContainingBlock(currentNode)) {
|
|
663
|
+
return currentNode;
|
|
664
|
+
} else {
|
|
665
|
+
currentNode = getParentNode(currentNode);
|
|
666
|
+
}
|
|
502
667
|
}
|
|
503
668
|
return null;
|
|
504
669
|
}
|
|
505
|
-
function
|
|
506
|
-
|
|
670
|
+
function isWebKit() {
|
|
671
|
+
if (typeof CSS === "undefined" || !CSS.supports)
|
|
672
|
+
return false;
|
|
673
|
+
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
507
674
|
}
|
|
508
|
-
function
|
|
509
|
-
return ["html", "body", "#document"].includes(
|
|
675
|
+
function isLastTraversableNode(node) {
|
|
676
|
+
return ["html", "body", "#document"].includes(getNodeName(node));
|
|
510
677
|
}
|
|
511
|
-
function
|
|
512
|
-
return
|
|
678
|
+
function getComputedStyle(element) {
|
|
679
|
+
return getWindow(element).getComputedStyle(element);
|
|
513
680
|
}
|
|
514
|
-
function
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
681
|
+
function getNodeScroll(element) {
|
|
682
|
+
if (isElement(element)) {
|
|
683
|
+
return {
|
|
684
|
+
scrollLeft: element.scrollLeft,
|
|
685
|
+
scrollTop: element.scrollTop
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
scrollLeft: element.pageXOffset,
|
|
690
|
+
scrollTop: element.pageYOffset
|
|
521
691
|
};
|
|
522
692
|
}
|
|
523
|
-
function
|
|
524
|
-
if (
|
|
525
|
-
return
|
|
526
|
-
|
|
693
|
+
function getParentNode(node) {
|
|
694
|
+
if (getNodeName(node) === "html") {
|
|
695
|
+
return node;
|
|
696
|
+
}
|
|
697
|
+
const result = (
|
|
527
698
|
// Step into the shadow DOM of the parent of a slotted node.
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
699
|
+
node.assignedSlot || // DOM Element detected.
|
|
700
|
+
node.parentNode || // ShadowRoot detected.
|
|
701
|
+
isShadowRoot(node) && node.host || // Fallback.
|
|
702
|
+
getDocumentElement(node)
|
|
532
703
|
);
|
|
533
|
-
return
|
|
534
|
-
}
|
|
535
|
-
function
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return
|
|
544
|
-
}
|
|
545
|
-
function
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
704
|
+
return isShadowRoot(result) ? result.host : result;
|
|
705
|
+
}
|
|
706
|
+
function getNearestOverflowAncestor(node) {
|
|
707
|
+
const parentNode = getParentNode(node);
|
|
708
|
+
if (isLastTraversableNode(parentNode)) {
|
|
709
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
710
|
+
}
|
|
711
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
712
|
+
return parentNode;
|
|
713
|
+
}
|
|
714
|
+
return getNearestOverflowAncestor(parentNode);
|
|
715
|
+
}
|
|
716
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
717
|
+
var _node$ownerDocument2;
|
|
718
|
+
if (list === void 0) {
|
|
719
|
+
list = [];
|
|
720
|
+
}
|
|
721
|
+
if (traverseIframes === void 0) {
|
|
722
|
+
traverseIframes = true;
|
|
723
|
+
}
|
|
724
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
725
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
726
|
+
const win = getWindow(scrollableAncestor);
|
|
727
|
+
if (isBody) {
|
|
728
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
|
|
729
|
+
}
|
|
730
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
731
|
+
}
|
|
732
|
+
function getCssDimensions(element) {
|
|
733
|
+
const css = getComputedStyle(element);
|
|
734
|
+
let width = parseFloat(css.width) || 0;
|
|
735
|
+
let height = parseFloat(css.height) || 0;
|
|
736
|
+
const hasOffset = isHTMLElement(element);
|
|
737
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
738
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
739
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
740
|
+
if (shouldFallback) {
|
|
741
|
+
width = offsetWidth;
|
|
742
|
+
height = offsetHeight;
|
|
743
|
+
}
|
|
744
|
+
return {
|
|
745
|
+
width,
|
|
746
|
+
height,
|
|
747
|
+
$: shouldFallback
|
|
553
748
|
};
|
|
554
749
|
}
|
|
555
|
-
function
|
|
556
|
-
return
|
|
557
|
-
}
|
|
558
|
-
function
|
|
559
|
-
const
|
|
560
|
-
if (!
|
|
561
|
-
return
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
750
|
+
function unwrapElement(element) {
|
|
751
|
+
return !isElement(element) ? element.contextElement : element;
|
|
752
|
+
}
|
|
753
|
+
function getScale(element) {
|
|
754
|
+
const domElement = unwrapElement(element);
|
|
755
|
+
if (!isHTMLElement(domElement)) {
|
|
756
|
+
return createCoords(1);
|
|
757
|
+
}
|
|
758
|
+
const rect = domElement.getBoundingClientRect();
|
|
759
|
+
const {
|
|
760
|
+
width,
|
|
761
|
+
height,
|
|
762
|
+
$
|
|
763
|
+
} = getCssDimensions(domElement);
|
|
764
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
765
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
766
|
+
if (!x || !Number.isFinite(x)) {
|
|
767
|
+
x = 1;
|
|
768
|
+
}
|
|
769
|
+
if (!y || !Number.isFinite(y)) {
|
|
770
|
+
y = 1;
|
|
771
|
+
}
|
|
772
|
+
return {
|
|
773
|
+
x,
|
|
774
|
+
y
|
|
571
775
|
};
|
|
572
776
|
}
|
|
573
|
-
const
|
|
574
|
-
function
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
777
|
+
const noOffsets = /* @__PURE__ */ createCoords(0);
|
|
778
|
+
function getVisualOffsets(element) {
|
|
779
|
+
const win = getWindow(element);
|
|
780
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
781
|
+
return noOffsets;
|
|
782
|
+
}
|
|
783
|
+
return {
|
|
784
|
+
x: win.visualViewport.offsetLeft,
|
|
785
|
+
y: win.visualViewport.offsetTop
|
|
579
786
|
};
|
|
580
787
|
}
|
|
581
|
-
function
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
if (
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
788
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
789
|
+
if (isFixed === void 0) {
|
|
790
|
+
isFixed = false;
|
|
791
|
+
}
|
|
792
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
return isFixed;
|
|
796
|
+
}
|
|
797
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
798
|
+
if (includeScale === void 0) {
|
|
799
|
+
includeScale = false;
|
|
800
|
+
}
|
|
801
|
+
if (isFixedStrategy === void 0) {
|
|
802
|
+
isFixedStrategy = false;
|
|
803
|
+
}
|
|
804
|
+
const clientRect = element.getBoundingClientRect();
|
|
805
|
+
const domElement = unwrapElement(element);
|
|
806
|
+
let scale = createCoords(1);
|
|
807
|
+
if (includeScale) {
|
|
808
|
+
if (offsetParent) {
|
|
809
|
+
if (isElement(offsetParent)) {
|
|
810
|
+
scale = getScale(offsetParent);
|
|
811
|
+
}
|
|
812
|
+
} else {
|
|
813
|
+
scale = getScale(element);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
817
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
818
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
819
|
+
let width = clientRect.width / scale.x;
|
|
820
|
+
let height = clientRect.height / scale.y;
|
|
821
|
+
if (domElement) {
|
|
822
|
+
const win = getWindow(domElement);
|
|
823
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
824
|
+
let currentIFrame = win.frameElement;
|
|
825
|
+
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
826
|
+
const iframeScale = getScale(currentIFrame);
|
|
827
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
828
|
+
const css = getComputedStyle(currentIFrame);
|
|
829
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
830
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
831
|
+
x *= iframeScale.x;
|
|
832
|
+
y *= iframeScale.y;
|
|
833
|
+
width *= iframeScale.x;
|
|
834
|
+
height *= iframeScale.y;
|
|
835
|
+
x += left;
|
|
836
|
+
y += top;
|
|
837
|
+
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return rectToClientRect({
|
|
841
|
+
width,
|
|
842
|
+
height,
|
|
843
|
+
x,
|
|
844
|
+
y
|
|
604
845
|
});
|
|
605
846
|
}
|
|
606
|
-
function
|
|
847
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
607
848
|
let {
|
|
608
|
-
rect
|
|
609
|
-
offsetParent
|
|
610
|
-
strategy
|
|
611
|
-
} =
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
849
|
+
rect,
|
|
850
|
+
offsetParent,
|
|
851
|
+
strategy
|
|
852
|
+
} = _ref;
|
|
853
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
854
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
855
|
+
if (offsetParent === documentElement) {
|
|
856
|
+
return rect;
|
|
857
|
+
}
|
|
858
|
+
let scroll = {
|
|
616
859
|
scrollLeft: 0,
|
|
617
860
|
scrollTop: 0
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
861
|
+
};
|
|
862
|
+
let scale = createCoords(1);
|
|
863
|
+
const offsets = createCoords(0);
|
|
864
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
|
865
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
866
|
+
scroll = getNodeScroll(offsetParent);
|
|
867
|
+
}
|
|
868
|
+
if (isHTMLElement(offsetParent)) {
|
|
869
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
870
|
+
scale = getScale(offsetParent);
|
|
871
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
872
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
873
|
+
}
|
|
623
874
|
}
|
|
624
875
|
return {
|
|
625
|
-
width:
|
|
626
|
-
height:
|
|
627
|
-
x:
|
|
628
|
-
y:
|
|
876
|
+
width: rect.width * scale.x,
|
|
877
|
+
height: rect.height * scale.y,
|
|
878
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
879
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
629
880
|
};
|
|
630
881
|
}
|
|
631
|
-
function
|
|
632
|
-
return Array.from(
|
|
633
|
-
}
|
|
634
|
-
function
|
|
635
|
-
return
|
|
636
|
-
}
|
|
637
|
-
function
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
882
|
+
function getClientRects(element) {
|
|
883
|
+
return Array.from(element.getClientRects());
|
|
884
|
+
}
|
|
885
|
+
function getWindowScrollBarX(element) {
|
|
886
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
887
|
+
}
|
|
888
|
+
function getDocumentRect(element) {
|
|
889
|
+
const html = getDocumentElement(element);
|
|
890
|
+
const scroll = getNodeScroll(element);
|
|
891
|
+
const body = element.ownerDocument.body;
|
|
892
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
893
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
894
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
895
|
+
const y = -scroll.scrollTop;
|
|
896
|
+
if (getComputedStyle(body).direction === "rtl") {
|
|
897
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
898
|
+
}
|
|
899
|
+
return {
|
|
900
|
+
width,
|
|
901
|
+
height,
|
|
902
|
+
x,
|
|
903
|
+
y
|
|
646
904
|
};
|
|
647
905
|
}
|
|
648
|
-
function
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
906
|
+
function getViewportRect(element, strategy) {
|
|
907
|
+
const win = getWindow(element);
|
|
908
|
+
const html = getDocumentElement(element);
|
|
909
|
+
const visualViewport = win.visualViewport;
|
|
910
|
+
let width = html.clientWidth;
|
|
911
|
+
let height = html.clientHeight;
|
|
912
|
+
let x = 0;
|
|
913
|
+
let y = 0;
|
|
914
|
+
if (visualViewport) {
|
|
915
|
+
width = visualViewport.width;
|
|
916
|
+
height = visualViewport.height;
|
|
917
|
+
const visualViewportBased = isWebKit();
|
|
918
|
+
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
919
|
+
x = visualViewport.offsetLeft;
|
|
920
|
+
y = visualViewport.offsetTop;
|
|
921
|
+
}
|
|
655
922
|
}
|
|
656
923
|
return {
|
|
657
|
-
width
|
|
658
|
-
height
|
|
659
|
-
x
|
|
660
|
-
y
|
|
924
|
+
width,
|
|
925
|
+
height,
|
|
926
|
+
x,
|
|
927
|
+
y
|
|
661
928
|
};
|
|
662
929
|
}
|
|
663
|
-
function
|
|
664
|
-
const
|
|
930
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
931
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
932
|
+
const top = clientRect.top + element.clientTop;
|
|
933
|
+
const left = clientRect.left + element.clientLeft;
|
|
934
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
935
|
+
const width = element.clientWidth * scale.x;
|
|
936
|
+
const height = element.clientHeight * scale.y;
|
|
937
|
+
const x = left * scale.x;
|
|
938
|
+
const y = top * scale.y;
|
|
665
939
|
return {
|
|
666
|
-
width
|
|
667
|
-
height
|
|
668
|
-
x
|
|
669
|
-
y
|
|
940
|
+
width,
|
|
941
|
+
height,
|
|
942
|
+
x,
|
|
943
|
+
y
|
|
670
944
|
};
|
|
671
945
|
}
|
|
672
|
-
function
|
|
673
|
-
let
|
|
674
|
-
if (
|
|
675
|
-
|
|
676
|
-
else if (
|
|
677
|
-
|
|
678
|
-
else if (
|
|
679
|
-
|
|
680
|
-
else {
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
...
|
|
684
|
-
x:
|
|
685
|
-
y:
|
|
946
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
947
|
+
let rect;
|
|
948
|
+
if (clippingAncestor === "viewport") {
|
|
949
|
+
rect = getViewportRect(element, strategy);
|
|
950
|
+
} else if (clippingAncestor === "document") {
|
|
951
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
952
|
+
} else if (isElement(clippingAncestor)) {
|
|
953
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
954
|
+
} else {
|
|
955
|
+
const visualOffsets = getVisualOffsets(element);
|
|
956
|
+
rect = {
|
|
957
|
+
...clippingAncestor,
|
|
958
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
959
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
686
960
|
};
|
|
687
961
|
}
|
|
688
|
-
return
|
|
962
|
+
return rectToClientRect(rect);
|
|
689
963
|
}
|
|
690
|
-
function
|
|
691
|
-
const
|
|
692
|
-
|
|
964
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
965
|
+
const parentNode = getParentNode(element);
|
|
966
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
693
970
|
}
|
|
694
|
-
function
|
|
695
|
-
const
|
|
696
|
-
if (
|
|
697
|
-
return
|
|
698
|
-
let o = J(t, [], !1).filter((l) => H(l) && j(l) !== "body"), i = null;
|
|
699
|
-
const s = T(t).position === "fixed";
|
|
700
|
-
let r = s ? I(t) : t;
|
|
701
|
-
for (; H(r) && !ot(r); ) {
|
|
702
|
-
const l = T(r), c = lt(r);
|
|
703
|
-
!c && l.position === "fixed" && (i = null), (s ? !c && !i : !c && l.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || G(r) && !c && Et(t, r)) ? o = o.filter((d) => d !== r) : i = l, r = I(r);
|
|
971
|
+
function getClippingElementAncestors(element, cache) {
|
|
972
|
+
const cachedResult = cache.get(element);
|
|
973
|
+
if (cachedResult) {
|
|
974
|
+
return cachedResult;
|
|
704
975
|
}
|
|
705
|
-
|
|
976
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
977
|
+
let currentContainingBlockComputedStyle = null;
|
|
978
|
+
const elementIsFixed = getComputedStyle(element).position === "fixed";
|
|
979
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
980
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
981
|
+
const computedStyle = getComputedStyle(currentNode);
|
|
982
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
983
|
+
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
984
|
+
currentContainingBlockComputedStyle = null;
|
|
985
|
+
}
|
|
986
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
987
|
+
if (shouldDropCurrentNode) {
|
|
988
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
989
|
+
} else {
|
|
990
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
991
|
+
}
|
|
992
|
+
currentNode = getParentNode(currentNode);
|
|
993
|
+
}
|
|
994
|
+
cache.set(element, result);
|
|
995
|
+
return result;
|
|
706
996
|
}
|
|
707
|
-
function
|
|
997
|
+
function getClippingRect(_ref) {
|
|
708
998
|
let {
|
|
709
|
-
element
|
|
710
|
-
boundary
|
|
711
|
-
rootBoundary
|
|
712
|
-
strategy
|
|
713
|
-
} =
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
999
|
+
element,
|
|
1000
|
+
boundary,
|
|
1001
|
+
rootBoundary,
|
|
1002
|
+
strategy
|
|
1003
|
+
} = _ref;
|
|
1004
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1005
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1006
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1007
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1008
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1009
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1010
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1011
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1012
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1013
|
+
return accRect;
|
|
1014
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
718
1015
|
return {
|
|
719
|
-
width:
|
|
720
|
-
height:
|
|
721
|
-
x:
|
|
722
|
-
y:
|
|
1016
|
+
width: clippingRect.right - clippingRect.left,
|
|
1017
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1018
|
+
x: clippingRect.left,
|
|
1019
|
+
y: clippingRect.top
|
|
723
1020
|
};
|
|
724
1021
|
}
|
|
725
|
-
function
|
|
726
|
-
return
|
|
1022
|
+
function getDimensions(element) {
|
|
1023
|
+
return getCssDimensions(element);
|
|
727
1024
|
}
|
|
728
|
-
function
|
|
729
|
-
const
|
|
730
|
-
|
|
1025
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1026
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1027
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1028
|
+
const isFixed = strategy === "fixed";
|
|
1029
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1030
|
+
let scroll = {
|
|
731
1031
|
scrollLeft: 0,
|
|
732
1032
|
scrollTop: 0
|
|
733
1033
|
};
|
|
734
|
-
const
|
|
735
|
-
if (
|
|
736
|
-
if ((
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
1034
|
+
const offsets = createCoords(0);
|
|
1035
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1036
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1037
|
+
scroll = getNodeScroll(offsetParent);
|
|
1038
|
+
}
|
|
1039
|
+
if (isOffsetParentAnElement) {
|
|
1040
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1041
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1042
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1043
|
+
} else if (documentElement) {
|
|
1044
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
741
1047
|
return {
|
|
742
|
-
x:
|
|
743
|
-
y:
|
|
744
|
-
width:
|
|
745
|
-
height:
|
|
1048
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1049
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1050
|
+
width: rect.width,
|
|
1051
|
+
height: rect.height
|
|
746
1052
|
};
|
|
747
1053
|
}
|
|
748
|
-
function
|
|
749
|
-
|
|
1054
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1055
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
|
|
1056
|
+
return null;
|
|
1057
|
+
}
|
|
1058
|
+
if (polyfill) {
|
|
1059
|
+
return polyfill(element);
|
|
1060
|
+
}
|
|
1061
|
+
return element.offsetParent;
|
|
750
1062
|
}
|
|
751
|
-
function
|
|
752
|
-
const
|
|
753
|
-
if (!
|
|
754
|
-
return
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
1063
|
+
function getOffsetParent(element, polyfill) {
|
|
1064
|
+
const window2 = getWindow(element);
|
|
1065
|
+
if (!isHTMLElement(element)) {
|
|
1066
|
+
return window2;
|
|
1067
|
+
}
|
|
1068
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1069
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
|
|
1070
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1071
|
+
}
|
|
1072
|
+
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
|
|
1073
|
+
return window2;
|
|
1074
|
+
}
|
|
1075
|
+
return offsetParent || getContainingBlock(element) || window2;
|
|
759
1076
|
}
|
|
760
|
-
const
|
|
1077
|
+
const getElementRects = async function(_ref) {
|
|
761
1078
|
let {
|
|
762
|
-
reference
|
|
763
|
-
floating
|
|
764
|
-
strategy
|
|
765
|
-
} =
|
|
766
|
-
const
|
|
1079
|
+
reference,
|
|
1080
|
+
floating,
|
|
1081
|
+
strategy
|
|
1082
|
+
} = _ref;
|
|
1083
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1084
|
+
const getDimensionsFn = this.getDimensions;
|
|
767
1085
|
return {
|
|
768
|
-
reference:
|
|
1086
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
769
1087
|
floating: {
|
|
770
1088
|
x: 0,
|
|
771
1089
|
y: 0,
|
|
772
|
-
...await
|
|
1090
|
+
...await getDimensionsFn(floating)
|
|
773
1091
|
}
|
|
774
1092
|
};
|
|
775
1093
|
};
|
|
776
|
-
function
|
|
777
|
-
return
|
|
778
|
-
}
|
|
779
|
-
const
|
|
780
|
-
convertOffsetParentRelativeRectToViewportRelativeRect
|
|
781
|
-
getDocumentElement
|
|
782
|
-
getClippingRect
|
|
783
|
-
getOffsetParent
|
|
784
|
-
getElementRects
|
|
785
|
-
getClientRects
|
|
786
|
-
getDimensions
|
|
787
|
-
getScale
|
|
788
|
-
isElement
|
|
789
|
-
isRTL
|
|
1094
|
+
function isRTL(element) {
|
|
1095
|
+
return getComputedStyle(element).direction === "rtl";
|
|
1096
|
+
}
|
|
1097
|
+
const platform = {
|
|
1098
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1099
|
+
getDocumentElement,
|
|
1100
|
+
getClippingRect,
|
|
1101
|
+
getOffsetParent,
|
|
1102
|
+
getElementRects,
|
|
1103
|
+
getClientRects,
|
|
1104
|
+
getDimensions,
|
|
1105
|
+
getScale,
|
|
1106
|
+
isElement,
|
|
1107
|
+
isRTL
|
|
790
1108
|
};
|
|
791
|
-
function
|
|
792
|
-
let
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1109
|
+
function observeMove(element, onMove) {
|
|
1110
|
+
let io = null;
|
|
1111
|
+
let timeoutId;
|
|
1112
|
+
const root = getDocumentElement(element);
|
|
1113
|
+
function cleanup() {
|
|
1114
|
+
clearTimeout(timeoutId);
|
|
1115
|
+
io && io.disconnect();
|
|
1116
|
+
io = null;
|
|
1117
|
+
}
|
|
1118
|
+
function refresh(skip, threshold) {
|
|
1119
|
+
if (skip === void 0) {
|
|
1120
|
+
skip = false;
|
|
1121
|
+
}
|
|
1122
|
+
if (threshold === void 0) {
|
|
1123
|
+
threshold = 1;
|
|
1124
|
+
}
|
|
1125
|
+
cleanup();
|
|
799
1126
|
const {
|
|
800
|
-
left
|
|
801
|
-
top
|
|
802
|
-
width
|
|
803
|
-
height
|
|
804
|
-
} =
|
|
805
|
-
if (
|
|
1127
|
+
left,
|
|
1128
|
+
top,
|
|
1129
|
+
width,
|
|
1130
|
+
height
|
|
1131
|
+
} = element.getBoundingClientRect();
|
|
1132
|
+
if (!skip) {
|
|
1133
|
+
onMove();
|
|
1134
|
+
}
|
|
1135
|
+
if (!width || !height) {
|
|
806
1136
|
return;
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1137
|
+
}
|
|
1138
|
+
const insetTop = floor(top);
|
|
1139
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1140
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1141
|
+
const insetLeft = floor(left);
|
|
1142
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1143
|
+
const options = {
|
|
1144
|
+
rootMargin,
|
|
1145
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
810
1146
|
};
|
|
811
|
-
let
|
|
812
|
-
function
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
815
|
-
if (!
|
|
816
|
-
return
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
1147
|
+
let isFirstUpdate = true;
|
|
1148
|
+
function handleObserve(entries) {
|
|
1149
|
+
const ratio = entries[0].intersectionRatio;
|
|
1150
|
+
if (ratio !== threshold) {
|
|
1151
|
+
if (!isFirstUpdate) {
|
|
1152
|
+
return refresh();
|
|
1153
|
+
}
|
|
1154
|
+
if (!ratio) {
|
|
1155
|
+
timeoutId = setTimeout(() => {
|
|
1156
|
+
refresh(false, 1e-7);
|
|
1157
|
+
}, 100);
|
|
1158
|
+
} else {
|
|
1159
|
+
refresh(false, ratio);
|
|
1160
|
+
}
|
|
820
1161
|
}
|
|
821
|
-
|
|
1162
|
+
isFirstUpdate = false;
|
|
822
1163
|
}
|
|
823
1164
|
try {
|
|
824
|
-
|
|
825
|
-
...
|
|
1165
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1166
|
+
...options,
|
|
826
1167
|
// Handle <iframe>s
|
|
827
|
-
root:
|
|
1168
|
+
root: root.ownerDocument
|
|
828
1169
|
});
|
|
829
|
-
} catch {
|
|
830
|
-
|
|
1170
|
+
} catch (e) {
|
|
1171
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
831
1172
|
}
|
|
832
|
-
|
|
1173
|
+
io.observe(element);
|
|
833
1174
|
}
|
|
834
|
-
|
|
1175
|
+
refresh(true);
|
|
1176
|
+
return cleanup;
|
|
835
1177
|
}
|
|
836
|
-
function
|
|
837
|
-
|
|
1178
|
+
function autoUpdate(reference, floating, update, options) {
|
|
1179
|
+
if (options === void 0) {
|
|
1180
|
+
options = {};
|
|
1181
|
+
}
|
|
838
1182
|
const {
|
|
839
|
-
ancestorScroll
|
|
840
|
-
ancestorResize
|
|
841
|
-
elementResize
|
|
842
|
-
layoutShift
|
|
843
|
-
animationFrame
|
|
844
|
-
} =
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1183
|
+
ancestorScroll = true,
|
|
1184
|
+
ancestorResize = true,
|
|
1185
|
+
elementResize = typeof ResizeObserver === "function",
|
|
1186
|
+
layoutShift = typeof IntersectionObserver === "function",
|
|
1187
|
+
animationFrame = false
|
|
1188
|
+
} = options;
|
|
1189
|
+
const referenceEl = unwrapElement(reference);
|
|
1190
|
+
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
|
|
1191
|
+
ancestors.forEach((ancestor) => {
|
|
1192
|
+
ancestorScroll && ancestor.addEventListener("scroll", update, {
|
|
1193
|
+
passive: true
|
|
1194
|
+
});
|
|
1195
|
+
ancestorResize && ancestor.addEventListener("resize", update);
|
|
849
1196
|
});
|
|
850
|
-
const
|
|
851
|
-
let
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
1197
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1198
|
+
let reobserveFrame = -1;
|
|
1199
|
+
let resizeObserver = null;
|
|
1200
|
+
if (elementResize) {
|
|
1201
|
+
resizeObserver = new ResizeObserver((_ref) => {
|
|
1202
|
+
let [firstEntry] = _ref;
|
|
1203
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1204
|
+
resizeObserver.unobserve(floating);
|
|
1205
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1206
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1207
|
+
resizeObserver && resizeObserver.observe(floating);
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
update();
|
|
1211
|
+
});
|
|
1212
|
+
if (referenceEl && !animationFrame) {
|
|
1213
|
+
resizeObserver.observe(referenceEl);
|
|
1214
|
+
}
|
|
1215
|
+
resizeObserver.observe(floating);
|
|
1216
|
+
}
|
|
1217
|
+
let frameId;
|
|
1218
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1219
|
+
if (animationFrame) {
|
|
1220
|
+
frameLoop();
|
|
1221
|
+
}
|
|
1222
|
+
function frameLoop() {
|
|
1223
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
1224
|
+
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1225
|
+
update();
|
|
1226
|
+
}
|
|
1227
|
+
prevRefRect = nextRefRect;
|
|
1228
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
1229
|
+
}
|
|
1230
|
+
update();
|
|
1231
|
+
return () => {
|
|
1232
|
+
ancestors.forEach((ancestor) => {
|
|
1233
|
+
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
1234
|
+
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
1235
|
+
});
|
|
1236
|
+
cleanupIo && cleanupIo();
|
|
1237
|
+
resizeObserver && resizeObserver.disconnect();
|
|
1238
|
+
resizeObserver = null;
|
|
1239
|
+
if (animationFrame) {
|
|
1240
|
+
cancelAnimationFrame(frameId);
|
|
1241
|
+
}
|
|
868
1242
|
};
|
|
869
1243
|
}
|
|
870
|
-
const
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
1244
|
+
const computePosition = (reference, floating, options) => {
|
|
1245
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1246
|
+
const mergedOptions = {
|
|
1247
|
+
platform,
|
|
1248
|
+
...options
|
|
1249
|
+
};
|
|
1250
|
+
const platformWithCache = {
|
|
1251
|
+
...mergedOptions.platform,
|
|
1252
|
+
_c: cache
|
|
877
1253
|
};
|
|
878
|
-
return
|
|
879
|
-
...
|
|
880
|
-
platform:
|
|
1254
|
+
return computePosition$1(reference, floating, {
|
|
1255
|
+
...mergedOptions,
|
|
1256
|
+
platform: platformWithCache
|
|
881
1257
|
});
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
class
|
|
1258
|
+
};
|
|
1259
|
+
const styles = "/*\n[ WJ Popup ]\n*/\n:host {\n --wj-popup-top: auto;\n --wj-popup-left: auto;\n display: flex;\n}\n\n.native-popup {\n position: absolute;\n isolation: isolate;\n z-index: 999;\n left: var(--wj-popup-left);\n top: var(--wj-popup-top);\n}\n\n.native-popup:not(.popup-active) {\n display: none;\n}";
|
|
1260
|
+
class Popup extends WJElement {
|
|
885
1261
|
constructor() {
|
|
886
1262
|
super();
|
|
887
|
-
|
|
888
|
-
this._manual =
|
|
1263
|
+
__publicField(this, "className", "Popup");
|
|
1264
|
+
this._manual = false;
|
|
889
1265
|
}
|
|
890
|
-
set manual(
|
|
891
|
-
this._manual =
|
|
1266
|
+
set manual(value) {
|
|
1267
|
+
this._manual = value;
|
|
892
1268
|
}
|
|
893
1269
|
get manual() {
|
|
894
|
-
|
|
1270
|
+
if (this.hasAttribute("manual"))
|
|
1271
|
+
this._manual = true;
|
|
1272
|
+
return this._manual;
|
|
895
1273
|
}
|
|
896
1274
|
static get cssStyleSheet() {
|
|
897
|
-
return
|
|
1275
|
+
return styles;
|
|
898
1276
|
}
|
|
899
1277
|
static get observedAttributes() {
|
|
900
1278
|
return ["active"];
|
|
@@ -902,98 +1280,148 @@ class fe extends Tt {
|
|
|
902
1280
|
setupAttributes() {
|
|
903
1281
|
this.isShadowRoot = "open";
|
|
904
1282
|
}
|
|
905
|
-
attributeChangedCallback(
|
|
906
|
-
|
|
1283
|
+
attributeChangedCallback(name, old, newName) {
|
|
1284
|
+
if (name === "active") {
|
|
1285
|
+
if (this.hasAttribute(name)) {
|
|
1286
|
+
this.show();
|
|
1287
|
+
} else {
|
|
1288
|
+
this.hide();
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
907
1291
|
}
|
|
908
|
-
draw(
|
|
909
|
-
let
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1292
|
+
draw(context, store, params) {
|
|
1293
|
+
let fragment = document.createDocumentFragment();
|
|
1294
|
+
let slotAnchor = document.createElement("slot");
|
|
1295
|
+
slotAnchor.setAttribute("name", "anchor");
|
|
1296
|
+
let slotArrow = document.createElement("slot");
|
|
1297
|
+
slotArrow.setAttribute("name", "arrow");
|
|
1298
|
+
let native = document.createElement("div");
|
|
1299
|
+
native.setAttribute("part", "native");
|
|
1300
|
+
native.classList.add("native-popup");
|
|
1301
|
+
let slot = document.createElement("slot");
|
|
1302
|
+
native.appendChild(slot);
|
|
1303
|
+
native.appendChild(slotArrow);
|
|
1304
|
+
fragment.appendChild(slotAnchor);
|
|
1305
|
+
fragment.appendChild(native);
|
|
1306
|
+
this.slotAnchor = slotAnchor;
|
|
1307
|
+
this.slotArrow = slotArrow;
|
|
1308
|
+
this.native = native;
|
|
1309
|
+
return fragment;
|
|
917
1310
|
}
|
|
918
|
-
afterDraw(
|
|
1311
|
+
afterDraw(context, store, params) {
|
|
919
1312
|
this.setAnchor();
|
|
920
1313
|
}
|
|
921
1314
|
setAnchor() {
|
|
922
|
-
if (this.slotAnchor && typeof this.anchor
|
|
923
|
-
const
|
|
924
|
-
this.anchorEl =
|
|
925
|
-
} else
|
|
926
|
-
this.
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1315
|
+
if (this.slotAnchor && typeof this.anchor === "string") {
|
|
1316
|
+
const root = this.getRootNode();
|
|
1317
|
+
this.anchorEl = root.getElementById(this.anchor);
|
|
1318
|
+
} else if (this.slotAnchor instanceof HTMLSlotElement) {
|
|
1319
|
+
this.anchorEl = this.slotAnchor.assignedElements({ flatten: true })[0];
|
|
1320
|
+
}
|
|
1321
|
+
event.addListener(this.anchorEl, "click", null, (e) => {
|
|
1322
|
+
if (this.hasAttribute("disabled"))
|
|
1323
|
+
return;
|
|
1324
|
+
this.showHide();
|
|
1325
|
+
}, { stopPropagation: true });
|
|
1326
|
+
document.addEventListener("click", (e) => {
|
|
1327
|
+
let clickToHost = e.composedPath().some((el) => el === this);
|
|
1328
|
+
if (!clickToHost) {
|
|
1329
|
+
if (this.hasAttribute("active"))
|
|
1330
|
+
this.removeAttribute("active");
|
|
1331
|
+
}
|
|
931
1332
|
});
|
|
932
1333
|
}
|
|
933
1334
|
showHide() {
|
|
934
|
-
this.hasAttribute("active")
|
|
1335
|
+
if (this.hasAttribute("active")) {
|
|
1336
|
+
this.removeAttribute("active");
|
|
1337
|
+
} else {
|
|
1338
|
+
this.setAttribute("active", "");
|
|
1339
|
+
}
|
|
935
1340
|
}
|
|
936
1341
|
reposition() {
|
|
937
|
-
const
|
|
938
|
-
this.offsetCalc = +this.offset || 0
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1342
|
+
const middleware = [];
|
|
1343
|
+
this.offsetCalc = +this.offset || 0;
|
|
1344
|
+
if (this.slotArrow instanceof HTMLSlotElement) {
|
|
1345
|
+
this.arrow = this.slotArrow.assignedElements({ flatten: true })[0];
|
|
1346
|
+
if (this.arrow) {
|
|
1347
|
+
middleware.push(
|
|
1348
|
+
arrow({
|
|
1349
|
+
element: this.arrow
|
|
1350
|
+
})
|
|
1351
|
+
);
|
|
1352
|
+
this.offsetCalc = Math.sqrt(2 * this.arrow.offsetWidth ** 2) / 2 + +this.offset;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
middleware.push(
|
|
1356
|
+
offset(this.offsetCalc)
|
|
1357
|
+
);
|
|
1358
|
+
middleware.push(
|
|
1359
|
+
flip()
|
|
1360
|
+
);
|
|
1361
|
+
if (this.hasAttribute("size")) {
|
|
1362
|
+
middleware.push(
|
|
1363
|
+
size({
|
|
1364
|
+
apply({ availableWidth, availableHeight, elements }) {
|
|
1365
|
+
Object.assign(elements.floating.style, {
|
|
1366
|
+
width: `${elements.reference.offsetWidth}px`
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
})
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
computePosition(this.anchorEl, this.native, {
|
|
955
1373
|
placement: this.placement || "bottom",
|
|
956
1374
|
strategy: "fixed",
|
|
957
|
-
middleware
|
|
958
|
-
}).then(({ x
|
|
959
|
-
|
|
960
|
-
|
|
1375
|
+
middleware
|
|
1376
|
+
}).then(({ x, y, middlewareData, placement, strategy }) => {
|
|
1377
|
+
this.native.style.setProperty("--wj-popup-left", x + "px");
|
|
1378
|
+
this.native.style.setProperty("--wj-popup-top", y + "px");
|
|
1379
|
+
this.native.style.position = strategy;
|
|
1380
|
+
if (this.arrow) {
|
|
1381
|
+
const side = this.placement.split("-")[0];
|
|
1382
|
+
const staticSide = {
|
|
961
1383
|
top: "bottom",
|
|
962
1384
|
right: "left",
|
|
963
1385
|
bottom: "top",
|
|
964
1386
|
left: "right"
|
|
965
|
-
}[
|
|
966
|
-
if (
|
|
967
|
-
const { x:
|
|
1387
|
+
}[side];
|
|
1388
|
+
if (middlewareData.arrow) {
|
|
1389
|
+
const { x: x2, y: y2 } = middlewareData.arrow;
|
|
968
1390
|
Object.assign(this.arrow.style, {
|
|
969
|
-
left:
|
|
970
|
-
top:
|
|
971
|
-
[
|
|
1391
|
+
left: x2 != null ? `${x2}px` : "",
|
|
1392
|
+
top: y2 != null ? `${y2}px` : "",
|
|
1393
|
+
[staticSide]: `${-this.arrow.offsetWidth / 2}px`
|
|
972
1394
|
});
|
|
973
1395
|
}
|
|
974
1396
|
}
|
|
975
|
-
})
|
|
1397
|
+
});
|
|
1398
|
+
event.dispatchCustomEvent(this, "wj-popup:reposition", {
|
|
976
1399
|
data: { top: "bottom", right: "left", bottom: "top", left: "right" },
|
|
977
1400
|
context: this,
|
|
978
1401
|
event: this
|
|
979
1402
|
});
|
|
980
1403
|
}
|
|
981
1404
|
show() {
|
|
982
|
-
|
|
1405
|
+
event.dispatchCustomEvent(this, "wj-popup:show");
|
|
1406
|
+
this.native.classList.add("popup-active");
|
|
1407
|
+
this.cleanup = autoUpdate(this.anchorEl, this.native, () => {
|
|
983
1408
|
this.reposition();
|
|
984
1409
|
});
|
|
985
1410
|
}
|
|
986
1411
|
hide() {
|
|
987
|
-
|
|
1412
|
+
event.dispatchCustomEvent(this, "wj-popup:hide");
|
|
1413
|
+
this.native.classList.remove("popup-active");
|
|
1414
|
+
this.cleanup();
|
|
1415
|
+
this.cleanup = void 0;
|
|
988
1416
|
}
|
|
989
1417
|
onHide() {
|
|
990
1418
|
this.removeAttribute("active");
|
|
991
1419
|
}
|
|
992
1420
|
disconnectedCallback() {
|
|
993
|
-
|
|
1421
|
+
event.removeElement(this.anchorEl);
|
|
994
1422
|
}
|
|
995
1423
|
}
|
|
996
|
-
customElements.get("wj-popup") || window.customElements.define("wj-popup",
|
|
1424
|
+
customElements.get("wj-popup") || window.customElements.define("wj-popup", Popup);
|
|
997
1425
|
export {
|
|
998
|
-
|
|
1426
|
+
Popup
|
|
999
1427
|
};
|