@getflip/swirl-components 0.49.2 → 0.50.0
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/components.json +109 -1
- package/dist/cjs/{floating-ui.dom.esm-35943202.js → floating-ui.dom.esm-39236b6a.js} +130 -117
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-autocomplete.cjs.entry.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-icon-lock-person.cjs.entry.js +23 -0
- package/dist/cjs/swirl-icon-unlock-person.cjs.entry.js +23 -0
- package/dist/cjs/swirl-popover.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tooltip.cjs.entry.js +1 -1
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/swirl-icon/icons/swirl-icon-lock-person.js +52 -0
- package/dist/collection/components/swirl-icon/icons/swirl-icon-unlock-person.js +52 -0
- package/dist/components/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/components/floating-ui.dom.esm.js +130 -117
- package/dist/components/swirl-icon-lock-person.d.ts +11 -0
- package/dist/components/swirl-icon-lock-person.js +40 -0
- package/dist/components/swirl-icon-unlock-person.d.ts +11 -0
- package/dist/components/swirl-icon-unlock-person.js +40 -0
- package/dist/esm/{floating-ui.dom.esm-b9f28f6d.js → floating-ui.dom.esm-ac7cc24e.js} +130 -117
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-autocomplete.entry.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-icon-lock-person.entry.js +19 -0
- package/dist/esm/swirl-icon-unlock-person.entry.js +19 -0
- package/dist/esm/swirl-popover.entry.js +1 -1
- package/dist/esm/swirl-tooltip.entry.js +1 -1
- package/dist/swirl-components/{p-b76df929.entry.js → p-063afb09.entry.js} +1 -1
- package/dist/swirl-components/p-3c9f6731.entry.js +1 -0
- package/dist/swirl-components/p-530a0003.entry.js +1 -0
- package/dist/swirl-components/{p-5526e2c9.entry.js → p-dc67a056.entry.js} +1 -1
- package/dist/swirl-components/{p-13376409.entry.js → p-dec381b9.entry.js} +1 -1
- package/dist/swirl-components/p-ecb8b7f5.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-icon/icons/swirl-icon-lock-person.d.ts +5 -0
- package/dist/types/components/swirl-icon/icons/swirl-icon-unlock-person.d.ts +5 -0
- package/dist/types/components.d.ts +30 -0
- package/package.json +3 -3
- package/vscode-data.json +26 -0
- package/dist/swirl-components/p-6526bf3e.js +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Fragment } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as classnames } from './index2.js';
|
|
3
|
+
|
|
4
|
+
const swirlIconCss = ":host{display:inline-flex}";
|
|
5
|
+
|
|
6
|
+
const SwirlIconUnlockPerson$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
this.__attachShadow();
|
|
11
|
+
this.size = 24;
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
const viewBoxSize = this.size === 20 ? 24 : this.size;
|
|
15
|
+
const className = classnames("swirl-icon", `swirl-icon--size-${this.size}`);
|
|
16
|
+
return (h("svg", { class: className, fill: "none", height: this.size, part: "icon", viewBox: `0 0 ${viewBoxSize} ${viewBoxSize}`, width: this.size, xmlns: "http://www.w3.org/2000/svg" }, this.size === 16 && (h(Fragment, null, h("path", { d: "M3.99733 13.3339V6.66724H11.9973V7.3339C12.464 7.3339 12.9107 7.40057 13.3307 7.52724V6.66724C13.3307 5.9339 12.7307 5.3339 11.9973 5.3339H3.99733C3.264 5.3339 2.664 5.9339 2.664 6.66724V13.3339C2.664 14.0672 3.264 14.6672 3.99733 14.6672H8.17067C7.89067 14.2672 7.67067 13.8139 7.524 13.3339H3.99733ZM9.99733 5.3339H5.99733Z", fill: "currentColor" }), h("path", { d: "M11.9973 8.66724C10.1573 8.66724 8.664 10.1606 8.664 12.0006C8.664 13.8406 10.1573 15.3339 11.9973 15.3339C13.8373 15.3339 15.3307 13.8406 15.3307 12.0006C15.3307 10.1606 13.8373 8.66724 11.9973 8.66724ZM11.9973 10.0006C12.5507 10.0006 12.9973 10.4472 12.9973 11.0006C12.9973 11.5539 12.5507 12.0006 11.9973 12.0006C11.444 12.0006 10.9973 11.5539 10.9973 11.0006C10.9973 10.4472 11.444 10.0006 11.9973 10.0006ZM11.9973 14.0006C11.3107 14.0006 10.704 13.6539 10.344 13.1206C10.8307 12.8406 11.3907 12.6672 11.9973 12.6672C12.604 12.6672 13.164 12.8406 13.6507 13.1206C13.2907 13.6539 12.684 14.0006 11.9973 14.0006Z", fill: "currentColor" }), h("path", { d: "M11.3307 5.3339V4.00057C11.3307 2.16057 9.83734 0.667236 7.99734 0.667236C6.15734 0.667236 4.664 2.16057 4.664 4.00057H5.99734C5.99734 2.8939 6.89067 2.00057 7.99734 2.00057C9.104 2.00057 9.99734 2.8939 9.99734 4.00057L9.99733 5.3339L11.3307 5.3339Z", fill: "currentColor" }))), (this.size === 20 || this.size === 24) && (h(Fragment, null, h("path", { d: "M5.99597 20.0007V10.0007H17.996V11.0007C18.696 11.0007 19.366 11.1007 19.996 11.2907V10.0007C19.996 8.90073 19.096 8.00073 17.996 8.00073H5.99597C4.89597 8.00073 3.99597 8.90073 3.99597 10.0007V20.0007C3.99597 21.1007 4.89597 22.0007 5.99597 22.0007H12.256C11.836 21.4007 11.506 20.7207 11.286 20.0007H5.99597ZM14.996 8.00073H8.99597Z", fill: "currentColor" }), h("path", { d: "M17.996 13.0007C15.236 13.0007 12.996 15.2407 12.996 18.0007C12.996 20.7607 15.236 23.0007 17.996 23.0007C20.756 23.0007 22.996 20.7607 22.996 18.0007C22.996 15.2407 20.756 13.0007 17.996 13.0007ZM17.996 15.0007C18.826 15.0007 19.496 15.6707 19.496 16.5007C19.496 17.3307 18.826 18.0007 17.996 18.0007C17.166 18.0007 16.496 17.3307 16.496 16.5007C16.496 15.6707 17.166 15.0007 17.996 15.0007ZM17.996 21.0007C16.966 21.0007 16.056 20.4807 15.516 19.6807C16.246 19.2607 17.086 19.0007 17.996 19.0007C18.906 19.0007 19.746 19.2607 20.476 19.6807C19.936 20.4807 19.026 21.0007 17.996 21.0007Z", fill: "currentColor" }), h("path", { d: "M16.996 8.00073V6.00073C16.996 3.24073 14.756 1.00073 11.996 1.00073C9.23597 1.00073 6.99597 3.24073 6.99597 6.00073H8.99597C8.99597 4.34073 10.336 3.00073 11.996 3.00073C13.656 3.00073 14.996 4.34073 14.996 6.00073L14.996 8.00073L16.996 8.00073Z", fill: "currentColor" }))), this.size === 28 && (h(Fragment, null, h("path", { d: "M6.99532 23.3341V11.6675H20.9953V12.8341C21.812 12.8341 22.5937 12.9508 23.3287 13.1725V11.6675C23.3287 10.3841 22.2787 9.33415 20.9953 9.33415H6.99532C5.71199 9.33415 4.66199 10.3841 4.66199 11.6675V23.3341C4.66199 24.6175 5.71199 25.6675 6.99532 25.6675H14.2987C13.8087 24.9675 13.4237 24.1741 13.167 23.3341H6.99532ZM17.4953 9.33415H10.4953Z", fill: "currentColor" }), h("path", { d: "M20.9953 15.1675C17.7753 15.1675 15.162 17.7808 15.162 21.0008C15.162 24.2208 17.7753 26.8341 20.9953 26.8341C24.2153 26.8341 26.8287 24.2208 26.8287 21.0008C26.8287 17.7808 24.2153 15.1675 20.9953 15.1675ZM20.9953 17.5008C21.9637 17.5008 22.7453 18.2825 22.7453 19.2508C22.7453 20.2191 21.9637 21.0008 20.9953 21.0008C20.027 21.0008 19.2453 20.2191 19.2453 19.2508C19.2453 18.2825 20.027 17.5008 20.9953 17.5008ZM20.9953 24.5008C19.7937 24.5008 18.732 23.8941 18.102 22.9608C18.9537 22.4708 19.9337 22.1675 20.9953 22.1675C22.057 22.1675 23.037 22.4708 23.8887 22.9608C23.2587 23.8941 22.197 24.5008 20.9953 24.5008Z", fill: "currentColor" }), h("path", { d: "M19.8287 9.33415V7.00081C19.8287 3.78081 17.2153 1.16748 13.9953 1.16748C10.7753 1.16748 8.16199 3.78081 8.16199 7.00081H10.4953C10.4953 5.06415 12.0587 3.50081 13.9953 3.50081C15.932 3.50081 17.4953 5.06415 17.4953 7.00081L17.4953 9.33415L19.8287 9.33415Z", fill: "currentColor" })))));
|
|
17
|
+
}
|
|
18
|
+
static get style() { return swirlIconCss; }
|
|
19
|
+
}, [1, "swirl-icon-unlock-person", {
|
|
20
|
+
"size": [2]
|
|
21
|
+
}]);
|
|
22
|
+
function defineCustomElement$1() {
|
|
23
|
+
if (typeof customElements === "undefined") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const components = ["swirl-icon-unlock-person"];
|
|
27
|
+
components.forEach(tagName => { switch (tagName) {
|
|
28
|
+
case "swirl-icon-unlock-person":
|
|
29
|
+
if (!customElements.get(tagName)) {
|
|
30
|
+
customElements.define(tagName, SwirlIconUnlockPerson$1);
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
} });
|
|
34
|
+
}
|
|
35
|
+
defineCustomElement$1();
|
|
36
|
+
|
|
37
|
+
const SwirlIconUnlockPerson = SwirlIconUnlockPerson$1;
|
|
38
|
+
const defineCustomElement = defineCustomElement$1;
|
|
39
|
+
|
|
40
|
+
export { SwirlIconUnlockPerson, defineCustomElement };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
function getSide(placement) {
|
|
2
|
-
return placement.split('-')[0];
|
|
3
|
-
}
|
|
4
|
-
|
|
5
1
|
function getAlignment(placement) {
|
|
6
2
|
return placement.split('-')[1];
|
|
7
3
|
}
|
|
8
4
|
|
|
9
|
-
function getMainAxisFromPlacement(placement) {
|
|
10
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
5
|
function getLengthFromAxis(axis) {
|
|
14
6
|
return axis === 'y' ? 'height' : 'width';
|
|
15
7
|
}
|
|
16
8
|
|
|
9
|
+
function getSide(placement) {
|
|
10
|
+
return placement.split('-')[0];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getMainAxisFromPlacement(placement) {
|
|
14
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
18
18
|
let {
|
|
19
19
|
reference,
|
|
@@ -27,7 +27,6 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
27
27
|
const side = getSide(placement);
|
|
28
28
|
const isVertical = mainAxis === 'x';
|
|
29
29
|
let coords;
|
|
30
|
-
|
|
31
30
|
switch (side) {
|
|
32
31
|
case 'top':
|
|
33
32
|
coords = {
|
|
@@ -35,45 +34,38 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
35
34
|
y: reference.y - floating.height
|
|
36
35
|
};
|
|
37
36
|
break;
|
|
38
|
-
|
|
39
37
|
case 'bottom':
|
|
40
38
|
coords = {
|
|
41
39
|
x: commonX,
|
|
42
40
|
y: reference.y + reference.height
|
|
43
41
|
};
|
|
44
42
|
break;
|
|
45
|
-
|
|
46
43
|
case 'right':
|
|
47
44
|
coords = {
|
|
48
45
|
x: reference.x + reference.width,
|
|
49
46
|
y: commonY
|
|
50
47
|
};
|
|
51
48
|
break;
|
|
52
|
-
|
|
53
49
|
case 'left':
|
|
54
50
|
coords = {
|
|
55
51
|
x: reference.x - floating.width,
|
|
56
52
|
y: commonY
|
|
57
53
|
};
|
|
58
54
|
break;
|
|
59
|
-
|
|
60
55
|
default:
|
|
61
56
|
coords = {
|
|
62
57
|
x: reference.x,
|
|
63
58
|
y: reference.y
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
|
-
|
|
67
61
|
switch (getAlignment(placement)) {
|
|
68
62
|
case 'start':
|
|
69
63
|
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
70
64
|
break;
|
|
71
|
-
|
|
72
65
|
case 'end':
|
|
73
66
|
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
74
67
|
break;
|
|
75
68
|
}
|
|
76
|
-
|
|
77
69
|
return coords;
|
|
78
70
|
}
|
|
79
71
|
|
|
@@ -84,7 +76,6 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
84
76
|
* This export does not have any `platform` interface logic. You will need to
|
|
85
77
|
* write one for the platform you are using Floating UI with.
|
|
86
78
|
*/
|
|
87
|
-
|
|
88
79
|
const computePosition$1 = async (reference, floating, config) => {
|
|
89
80
|
const {
|
|
90
81
|
placement = 'bottom',
|
|
@@ -92,8 +83,8 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
92
83
|
middleware = [],
|
|
93
84
|
platform
|
|
94
85
|
} = config;
|
|
86
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
95
87
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
96
|
-
|
|
97
88
|
let rects = await platform.getElementRects({
|
|
98
89
|
reference,
|
|
99
90
|
floating,
|
|
@@ -106,12 +97,11 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
106
97
|
let statefulPlacement = placement;
|
|
107
98
|
let middlewareData = {};
|
|
108
99
|
let resetCount = 0;
|
|
109
|
-
|
|
110
|
-
for (let i = 0; i < middleware.length; i++) {
|
|
100
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
111
101
|
const {
|
|
112
102
|
name,
|
|
113
103
|
fn
|
|
114
|
-
} =
|
|
104
|
+
} = validMiddleware[i];
|
|
115
105
|
const {
|
|
116
106
|
x: nextX,
|
|
117
107
|
y: nextY,
|
|
@@ -133,20 +123,19 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
133
123
|
});
|
|
134
124
|
x = nextX != null ? nextX : x;
|
|
135
125
|
y = nextY != null ? nextY : y;
|
|
136
|
-
middlewareData = {
|
|
137
|
-
|
|
126
|
+
middlewareData = {
|
|
127
|
+
...middlewareData,
|
|
128
|
+
[name]: {
|
|
129
|
+
...middlewareData[name],
|
|
138
130
|
...data
|
|
139
131
|
}
|
|
140
132
|
};
|
|
141
|
-
|
|
142
133
|
if (reset && resetCount <= 50) {
|
|
143
134
|
resetCount++;
|
|
144
|
-
|
|
145
135
|
if (typeof reset === 'object') {
|
|
146
136
|
if (reset.placement) {
|
|
147
137
|
statefulPlacement = reset.placement;
|
|
148
138
|
}
|
|
149
|
-
|
|
150
139
|
if (reset.rects) {
|
|
151
140
|
rects = reset.rects === true ? await platform.getElementRects({
|
|
152
141
|
reference,
|
|
@@ -154,18 +143,15 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
154
143
|
strategy
|
|
155
144
|
}) : reset.rects;
|
|
156
145
|
}
|
|
157
|
-
|
|
158
146
|
({
|
|
159
147
|
x,
|
|
160
148
|
y
|
|
161
149
|
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
162
150
|
}
|
|
163
|
-
|
|
164
151
|
i = -1;
|
|
165
152
|
continue;
|
|
166
153
|
}
|
|
167
154
|
}
|
|
168
|
-
|
|
169
155
|
return {
|
|
170
156
|
x,
|
|
171
157
|
y,
|
|
@@ -195,7 +181,8 @@ function getSideObjectFromPadding(padding) {
|
|
|
195
181
|
}
|
|
196
182
|
|
|
197
183
|
function rectToClientRect(rect) {
|
|
198
|
-
return {
|
|
184
|
+
return {
|
|
185
|
+
...rect,
|
|
199
186
|
top: rect.y,
|
|
200
187
|
left: rect.x,
|
|
201
188
|
right: rect.x + rect.width,
|
|
@@ -205,19 +192,17 @@ function rectToClientRect(rect) {
|
|
|
205
192
|
|
|
206
193
|
/**
|
|
207
194
|
* Resolves with an object of overflow side offsets that determine how much the
|
|
208
|
-
* element is overflowing a given clipping boundary.
|
|
195
|
+
* element is overflowing a given clipping boundary on each side.
|
|
209
196
|
* - positive = overflowing the boundary by that number of pixels
|
|
210
197
|
* - negative = how many pixels left before it will overflow
|
|
211
198
|
* - 0 = lies flush with the boundary
|
|
212
199
|
* @see https://floating-ui.com/docs/detectOverflow
|
|
213
200
|
*/
|
|
214
|
-
async function detectOverflow(
|
|
201
|
+
async function detectOverflow(state, options) {
|
|
215
202
|
var _await$platform$isEle;
|
|
216
|
-
|
|
217
203
|
if (options === void 0) {
|
|
218
204
|
options = {};
|
|
219
205
|
}
|
|
220
|
-
|
|
221
206
|
const {
|
|
222
207
|
x,
|
|
223
208
|
y,
|
|
@@ -225,7 +210,7 @@ async function detectOverflow(middlewareArguments, options) {
|
|
|
225
210
|
rects,
|
|
226
211
|
elements,
|
|
227
212
|
strategy
|
|
228
|
-
} =
|
|
213
|
+
} = state;
|
|
229
214
|
const {
|
|
230
215
|
boundary = 'clippingAncestors',
|
|
231
216
|
rootBoundary = 'viewport',
|
|
@@ -242,19 +227,29 @@ async function detectOverflow(middlewareArguments, options) {
|
|
|
242
227
|
rootBoundary,
|
|
243
228
|
strategy
|
|
244
229
|
}));
|
|
230
|
+
const rect = elementContext === 'floating' ? {
|
|
231
|
+
...rects.floating,
|
|
232
|
+
x,
|
|
233
|
+
y
|
|
234
|
+
} : rects.reference;
|
|
235
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
236
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
237
|
+
x: 1,
|
|
238
|
+
y: 1
|
|
239
|
+
} : {
|
|
240
|
+
x: 1,
|
|
241
|
+
y: 1
|
|
242
|
+
};
|
|
245
243
|
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
246
|
-
rect
|
|
247
|
-
|
|
248
|
-
y
|
|
249
|
-
} : rects.reference,
|
|
250
|
-
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
244
|
+
rect,
|
|
245
|
+
offsetParent,
|
|
251
246
|
strategy
|
|
252
|
-
}) :
|
|
247
|
+
}) : rect);
|
|
253
248
|
return {
|
|
254
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
255
|
-
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
256
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
257
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
249
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
250
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
251
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
252
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
258
253
|
};
|
|
259
254
|
}
|
|
260
255
|
|
|
@@ -265,42 +260,39 @@ function within(min$1$1, value, max$1$1) {
|
|
|
265
260
|
return max$1(min$1$1, min$1(value, max$1$1));
|
|
266
261
|
}
|
|
267
262
|
|
|
268
|
-
const
|
|
263
|
+
const oppositeSideMap = {
|
|
269
264
|
left: 'right',
|
|
270
265
|
right: 'left',
|
|
271
266
|
bottom: 'top',
|
|
272
267
|
top: 'bottom'
|
|
273
268
|
};
|
|
274
269
|
function getOppositePlacement(placement) {
|
|
275
|
-
return placement.replace(/left|right|bottom|top/g,
|
|
270
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
276
271
|
}
|
|
277
272
|
|
|
278
273
|
function getAlignmentSides(placement, rects, rtl) {
|
|
279
274
|
if (rtl === void 0) {
|
|
280
275
|
rtl = false;
|
|
281
276
|
}
|
|
282
|
-
|
|
283
277
|
const alignment = getAlignment(placement);
|
|
284
278
|
const mainAxis = getMainAxisFromPlacement(placement);
|
|
285
279
|
const length = getLengthFromAxis(mainAxis);
|
|
286
280
|
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
287
|
-
|
|
288
281
|
if (rects.reference[length] > rects.floating[length]) {
|
|
289
282
|
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
290
283
|
}
|
|
291
|
-
|
|
292
284
|
return {
|
|
293
285
|
main: mainAlignmentSide,
|
|
294
286
|
cross: getOppositePlacement(mainAlignmentSide)
|
|
295
287
|
};
|
|
296
288
|
}
|
|
297
289
|
|
|
298
|
-
const
|
|
290
|
+
const oppositeAlignmentMap = {
|
|
299
291
|
start: 'end',
|
|
300
292
|
end: 'start'
|
|
301
293
|
};
|
|
302
294
|
function getOppositeAlignmentPlacement(placement) {
|
|
303
|
-
return placement.replace(/start|end/g,
|
|
295
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
304
296
|
}
|
|
305
297
|
|
|
306
298
|
function getExpandedPlacements(placement) {
|
|
@@ -308,23 +300,50 @@ function getExpandedPlacements(placement) {
|
|
|
308
300
|
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
309
301
|
}
|
|
310
302
|
|
|
303
|
+
function getSideList(side, isStart, rtl) {
|
|
304
|
+
const lr = ['left', 'right'];
|
|
305
|
+
const rl = ['right', 'left'];
|
|
306
|
+
const tb = ['top', 'bottom'];
|
|
307
|
+
const bt = ['bottom', 'top'];
|
|
308
|
+
switch (side) {
|
|
309
|
+
case 'top':
|
|
310
|
+
case 'bottom':
|
|
311
|
+
if (rtl) return isStart ? rl : lr;
|
|
312
|
+
return isStart ? lr : rl;
|
|
313
|
+
case 'left':
|
|
314
|
+
case 'right':
|
|
315
|
+
return isStart ? tb : bt;
|
|
316
|
+
default:
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
321
|
+
const alignment = getAlignment(placement);
|
|
322
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
323
|
+
if (alignment) {
|
|
324
|
+
list = list.map(side => side + "-" + alignment);
|
|
325
|
+
if (flipAlignment) {
|
|
326
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return list;
|
|
330
|
+
}
|
|
331
|
+
|
|
311
332
|
/**
|
|
312
|
-
*
|
|
313
|
-
*
|
|
333
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
334
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
335
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
314
336
|
* @see https://floating-ui.com/docs/flip
|
|
315
337
|
*/
|
|
316
338
|
const flip = function (options) {
|
|
317
339
|
if (options === void 0) {
|
|
318
340
|
options = {};
|
|
319
341
|
}
|
|
320
|
-
|
|
321
342
|
return {
|
|
322
343
|
name: 'flip',
|
|
323
344
|
options,
|
|
324
|
-
|
|
325
|
-
async fn(middlewareArguments) {
|
|
345
|
+
async fn(state) {
|
|
326
346
|
var _middlewareData$flip;
|
|
327
|
-
|
|
328
347
|
const {
|
|
329
348
|
placement,
|
|
330
349
|
middlewareData,
|
|
@@ -332,48 +351,49 @@ const flip = function (options) {
|
|
|
332
351
|
initialPlacement,
|
|
333
352
|
platform,
|
|
334
353
|
elements
|
|
335
|
-
} =
|
|
354
|
+
} = state;
|
|
336
355
|
const {
|
|
337
356
|
mainAxis: checkMainAxis = true,
|
|
338
357
|
crossAxis: checkCrossAxis = true,
|
|
339
358
|
fallbackPlacements: specifiedFallbackPlacements,
|
|
340
359
|
fallbackStrategy = 'bestFit',
|
|
360
|
+
fallbackAxisSideDirection = 'none',
|
|
341
361
|
flipAlignment = true,
|
|
342
362
|
...detectOverflowOptions
|
|
343
363
|
} = options;
|
|
344
364
|
const side = getSide(placement);
|
|
345
|
-
const isBasePlacement =
|
|
365
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
366
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
346
367
|
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
368
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
369
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
370
|
+
}
|
|
347
371
|
const placements = [initialPlacement, ...fallbackPlacements];
|
|
348
|
-
const overflow = await detectOverflow(
|
|
372
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
349
373
|
const overflows = [];
|
|
350
374
|
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
351
|
-
|
|
352
375
|
if (checkMainAxis) {
|
|
353
376
|
overflows.push(overflow[side]);
|
|
354
377
|
}
|
|
355
|
-
|
|
356
378
|
if (checkCrossAxis) {
|
|
357
379
|
const {
|
|
358
380
|
main,
|
|
359
381
|
cross
|
|
360
|
-
} = getAlignmentSides(placement, rects,
|
|
382
|
+
} = getAlignmentSides(placement, rects, rtl);
|
|
361
383
|
overflows.push(overflow[main], overflow[cross]);
|
|
362
384
|
}
|
|
363
|
-
|
|
364
385
|
overflowsData = [...overflowsData, {
|
|
365
386
|
placement,
|
|
366
387
|
overflows
|
|
367
|
-
}];
|
|
388
|
+
}];
|
|
368
389
|
|
|
390
|
+
// One or more sides is overflowing.
|
|
369
391
|
if (!overflows.every(side => side <= 0)) {
|
|
370
|
-
var _middlewareData$
|
|
371
|
-
|
|
372
|
-
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
|
|
392
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
393
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
373
394
|
const nextPlacement = placements[nextIndex];
|
|
374
|
-
|
|
375
395
|
if (nextPlacement) {
|
|
376
|
-
// Try next placement and re-run the lifecycle
|
|
396
|
+
// Try next placement and re-run the lifecycle.
|
|
377
397
|
return {
|
|
378
398
|
data: {
|
|
379
399
|
index: nextIndex,
|
|
@@ -385,27 +405,27 @@ const flip = function (options) {
|
|
|
385
405
|
};
|
|
386
406
|
}
|
|
387
407
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
408
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
409
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
410
|
+
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;
|
|
411
|
+
|
|
412
|
+
// Otherwise fallback.
|
|
413
|
+
if (!resetPlacement) {
|
|
414
|
+
switch (fallbackStrategy) {
|
|
415
|
+
case 'bestFit':
|
|
416
|
+
{
|
|
417
|
+
var _overflowsData$map$so;
|
|
418
|
+
const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
|
|
419
|
+
if (placement) {
|
|
420
|
+
resetPlacement = placement;
|
|
421
|
+
}
|
|
422
|
+
break;
|
|
399
423
|
}
|
|
400
|
-
|
|
424
|
+
case 'initialPlacement':
|
|
425
|
+
resetPlacement = initialPlacement;
|
|
401
426
|
break;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
case 'initialPlacement':
|
|
405
|
-
resetPlacement = initialPlacement;
|
|
406
|
-
break;
|
|
427
|
+
}
|
|
407
428
|
}
|
|
408
|
-
|
|
409
429
|
if (placement !== resetPlacement) {
|
|
410
430
|
return {
|
|
411
431
|
reset: {
|
|
@@ -414,27 +434,26 @@ const flip = function (options) {
|
|
|
414
434
|
};
|
|
415
435
|
}
|
|
416
436
|
}
|
|
417
|
-
|
|
418
437
|
return {};
|
|
419
438
|
}
|
|
420
|
-
|
|
421
439
|
};
|
|
422
440
|
};
|
|
423
441
|
|
|
424
|
-
async function convertValueToCoords(
|
|
442
|
+
async function convertValueToCoords(state, value) {
|
|
425
443
|
const {
|
|
426
444
|
placement,
|
|
427
445
|
platform,
|
|
428
446
|
elements
|
|
429
|
-
} =
|
|
447
|
+
} = state;
|
|
430
448
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
431
449
|
const side = getSide(placement);
|
|
432
450
|
const alignment = getAlignment(placement);
|
|
433
451
|
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
434
452
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
435
453
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
436
|
-
const rawValue = typeof value === 'function' ? value(
|
|
454
|
+
const rawValue = typeof value === 'function' ? value(state) : value;
|
|
437
455
|
|
|
456
|
+
// eslint-disable-next-line prefer-const
|
|
438
457
|
let {
|
|
439
458
|
mainAxis,
|
|
440
459
|
crossAxis,
|
|
@@ -449,11 +468,9 @@ async function convertValueToCoords(middlewareArguments, value) {
|
|
|
449
468
|
alignmentAxis: null,
|
|
450
469
|
...rawValue
|
|
451
470
|
};
|
|
452
|
-
|
|
453
471
|
if (alignment && typeof alignmentAxis === 'number') {
|
|
454
472
|
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
455
473
|
}
|
|
456
|
-
|
|
457
474
|
return isVertical ? {
|
|
458
475
|
x: crossAxis * crossAxisMulti,
|
|
459
476
|
y: mainAxis * mainAxisMulti
|
|
@@ -462,33 +479,33 @@ async function convertValueToCoords(middlewareArguments, value) {
|
|
|
462
479
|
y: crossAxis * crossAxisMulti
|
|
463
480
|
};
|
|
464
481
|
}
|
|
482
|
+
|
|
465
483
|
/**
|
|
466
|
-
*
|
|
484
|
+
* Modifies the placement by translating the floating element along the
|
|
485
|
+
* specified axes.
|
|
486
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
487
|
+
* object may be passed.
|
|
467
488
|
* @see https://floating-ui.com/docs/offset
|
|
468
489
|
*/
|
|
469
|
-
|
|
470
490
|
const offset = function (value) {
|
|
471
491
|
if (value === void 0) {
|
|
472
492
|
value = 0;
|
|
473
493
|
}
|
|
474
|
-
|
|
475
494
|
return {
|
|
476
495
|
name: 'offset',
|
|
477
496
|
options: value,
|
|
478
|
-
|
|
479
|
-
async fn(middlewareArguments) {
|
|
497
|
+
async fn(state) {
|
|
480
498
|
const {
|
|
481
499
|
x,
|
|
482
500
|
y
|
|
483
|
-
} =
|
|
484
|
-
const diffCoords = await convertValueToCoords(
|
|
501
|
+
} = state;
|
|
502
|
+
const diffCoords = await convertValueToCoords(state, value);
|
|
485
503
|
return {
|
|
486
504
|
x: x + diffCoords.x,
|
|
487
505
|
y: y + diffCoords.y,
|
|
488
506
|
data: diffCoords
|
|
489
507
|
};
|
|
490
508
|
}
|
|
491
|
-
|
|
492
509
|
};
|
|
493
510
|
};
|
|
494
511
|
|
|
@@ -497,25 +514,23 @@ function getCrossAxis(axis) {
|
|
|
497
514
|
}
|
|
498
515
|
|
|
499
516
|
/**
|
|
500
|
-
*
|
|
501
|
-
*
|
|
517
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
518
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
502
519
|
* @see https://floating-ui.com/docs/shift
|
|
503
520
|
*/
|
|
504
521
|
const shift = function (options) {
|
|
505
522
|
if (options === void 0) {
|
|
506
523
|
options = {};
|
|
507
524
|
}
|
|
508
|
-
|
|
509
525
|
return {
|
|
510
526
|
name: 'shift',
|
|
511
527
|
options,
|
|
512
|
-
|
|
513
|
-
async fn(middlewareArguments) {
|
|
528
|
+
async fn(state) {
|
|
514
529
|
const {
|
|
515
530
|
x,
|
|
516
531
|
y,
|
|
517
532
|
placement
|
|
518
|
-
} =
|
|
533
|
+
} = state;
|
|
519
534
|
const {
|
|
520
535
|
mainAxis: checkMainAxis = true,
|
|
521
536
|
crossAxis: checkCrossAxis = false,
|
|
@@ -537,12 +552,11 @@ const shift = function (options) {
|
|
|
537
552
|
x,
|
|
538
553
|
y
|
|
539
554
|
};
|
|
540
|
-
const overflow = await detectOverflow(
|
|
555
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
541
556
|
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
542
557
|
const crossAxis = getCrossAxis(mainAxis);
|
|
543
558
|
let mainAxisCoord = coords[mainAxis];
|
|
544
559
|
let crossAxisCoord = coords[crossAxis];
|
|
545
|
-
|
|
546
560
|
if (checkMainAxis) {
|
|
547
561
|
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
548
562
|
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
@@ -550,7 +564,6 @@ const shift = function (options) {
|
|
|
550
564
|
const max = mainAxisCoord - overflow[maxSide];
|
|
551
565
|
mainAxisCoord = within(min, mainAxisCoord, max);
|
|
552
566
|
}
|
|
553
|
-
|
|
554
567
|
if (checkCrossAxis) {
|
|
555
568
|
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
556
569
|
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
@@ -558,19 +571,19 @@ const shift = function (options) {
|
|
|
558
571
|
const max = crossAxisCoord - overflow[maxSide];
|
|
559
572
|
crossAxisCoord = within(min, crossAxisCoord, max);
|
|
560
573
|
}
|
|
561
|
-
|
|
562
|
-
|
|
574
|
+
const limitedCoords = limiter.fn({
|
|
575
|
+
...state,
|
|
563
576
|
[mainAxis]: mainAxisCoord,
|
|
564
577
|
[crossAxis]: crossAxisCoord
|
|
565
578
|
});
|
|
566
|
-
return {
|
|
579
|
+
return {
|
|
580
|
+
...limitedCoords,
|
|
567
581
|
data: {
|
|
568
582
|
x: limitedCoords.x - x,
|
|
569
583
|
y: limitedCoords.y - y
|
|
570
584
|
}
|
|
571
585
|
};
|
|
572
586
|
}
|
|
573
|
-
|
|
574
587
|
};
|
|
575
588
|
};
|
|
576
589
|
|