@vonage/vivid 3.0.0-next.43 → 3.0.0-next.46

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/popup/index.js CHANGED
@@ -1,2119 +1,25 @@
1
1
  import '../shared/index2.js';
2
2
  import '../button/index.js';
3
- import { F as FoundationElement, c as __classPrivateFieldGet, i as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, d as designSystem } from '../shared/index.js';
4
- import { s as speciesConstructor$1, f as functionApply } from '../shared/icon.js';
5
- import { o as objectCreate } from '../shared/web.dom-collections.iterator.js';
6
- import '../shared/es.object.assign.js';
7
- import { j as anObject$3, e as fails$5, g as global$3, v as functionCall, f as functionUncurryThis, Q as shared$1, y as internalState, _ as _export, w as wellKnownSymbol$2, u as defineBuiltIn$1, K as createNonEnumerableProperty$1, x as isObject$1, c as classofRaw, B as requireObjectCoercible$2, R as toIntegerOrInfinity$1, S as toPropertyKey$1, o as objectDefineProperty, J as createPropertyDescriptor$1, A as lengthOfArrayLike$1, T as toAbsoluteIndex$1, i as isCallable$1, U as toLength$1, z as getMethod$1 } from '../shared/export.js';
8
- import { t as toString$3 } from '../shared/to-string.js';
9
- import { a as keyEscape } from '../shared/form-associated.js';
10
- import { s as styleInject } from '../shared/style-inject.es.js';
11
- import { w as when } from '../shared/when.js';
12
- import { r as ref } from '../shared/ref.js';
13
- import { c as classNames } from '../shared/class-names.js';
3
+ import '../shared/index.js';
4
+ export { v as vividPopup } from '../shared/index3.js';
5
+ import '../shared/style-inject.es.js';
6
+ import '../shared/class-names.js';
14
7
  import '../icon/index.js';
8
+ import '../shared/icon.js';
9
+ import '../shared/export.js';
15
10
  import '../shared/iterators.js';
11
+ import '../shared/to-string.js';
16
12
  import '../shared/_has.js';
13
+ import '../shared/when.js';
17
14
  import '../focus/index.js';
18
15
  import '../shared/focus.js';
16
+ import '../shared/web.dom-collections.iterator.js';
17
+ import '../shared/object-keys.js';
19
18
  import '../shared/affix.js';
20
19
  import '../shared/button.js';
21
20
  import '../shared/apply-mixins.js';
21
+ import '../shared/form-associated.js';
22
22
  import '../shared/aria-global.js';
23
+ import '../shared/ref.js';
23
24
  import '../shared/focus2.js';
24
- import '../shared/object-keys.js';
25
-
26
- var anObject$2 = anObject$3;
27
-
28
- // `RegExp.prototype.flags` getter implementation
29
- // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
30
- var regexpFlags$1 = function () {
31
- var that = anObject$2(this);
32
- var result = '';
33
- if (that.hasIndices) result += 'd';
34
- if (that.global) result += 'g';
35
- if (that.ignoreCase) result += 'i';
36
- if (that.multiline) result += 'm';
37
- if (that.dotAll) result += 's';
38
- if (that.unicode) result += 'u';
39
- if (that.sticky) result += 'y';
40
- return result;
41
- };
42
-
43
- var fails$4 = fails$5;
44
- var global$2 = global$3;
45
-
46
- // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
47
- var $RegExp$2 = global$2.RegExp;
48
-
49
- var UNSUPPORTED_Y$2 = fails$4(function () {
50
- var re = $RegExp$2('a', 'y');
51
- re.lastIndex = 2;
52
- return re.exec('abcd') != null;
53
- });
54
-
55
- // UC Browser bug
56
- // https://github.com/zloirock/core-js/issues/1008
57
- var MISSED_STICKY = UNSUPPORTED_Y$2 || fails$4(function () {
58
- return !$RegExp$2('a', 'y').sticky;
59
- });
60
-
61
- var BROKEN_CARET = UNSUPPORTED_Y$2 || fails$4(function () {
62
- // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
63
- var re = $RegExp$2('^r', 'gy');
64
- re.lastIndex = 2;
65
- return re.exec('str') != null;
66
- });
67
-
68
- var regexpStickyHelpers = {
69
- BROKEN_CARET: BROKEN_CARET,
70
- MISSED_STICKY: MISSED_STICKY,
71
- UNSUPPORTED_Y: UNSUPPORTED_Y$2
72
- };
73
-
74
- var fails$3 = fails$5;
75
- var global$1 = global$3;
76
-
77
- // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
78
- var $RegExp$1 = global$1.RegExp;
79
-
80
- var regexpUnsupportedDotAll = fails$3(function () {
81
- var re = $RegExp$1('.', 's');
82
- return !(re.dotAll && re.exec('\n') && re.flags === 's');
83
- });
84
-
85
- var fails$2 = fails$5;
86
- var global = global$3;
87
-
88
- // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
89
- var $RegExp = global.RegExp;
90
-
91
- var regexpUnsupportedNcg = fails$2(function () {
92
- var re = $RegExp('(?<a>b)', 'g');
93
- return re.exec('b').groups.a !== 'b' ||
94
- 'b'.replace(re, '$<a>c') !== 'bc';
95
- });
96
-
97
- /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
98
- /* eslint-disable regexp/no-useless-quantifier -- testing */
99
- var call$2 = functionCall;
100
- var uncurryThis$3 = functionUncurryThis;
101
- var toString$2 = toString$3;
102
- var regexpFlags = regexpFlags$1;
103
- var stickyHelpers$1 = regexpStickyHelpers;
104
- var shared = shared$1.exports;
105
- var create = objectCreate;
106
- var getInternalState = internalState.get;
107
- var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
108
- var UNSUPPORTED_NCG = regexpUnsupportedNcg;
109
-
110
- var nativeReplace = shared('native-string-replace', String.prototype.replace);
111
- var nativeExec = RegExp.prototype.exec;
112
- var patchedExec = nativeExec;
113
- var charAt$2 = uncurryThis$3(''.charAt);
114
- var indexOf = uncurryThis$3(''.indexOf);
115
- var replace = uncurryThis$3(''.replace);
116
- var stringSlice$2 = uncurryThis$3(''.slice);
117
-
118
- var UPDATES_LAST_INDEX_WRONG = (function () {
119
- var re1 = /a/;
120
- var re2 = /b*/g;
121
- call$2(nativeExec, re1, 'a');
122
- call$2(nativeExec, re2, 'a');
123
- return re1.lastIndex !== 0 || re2.lastIndex !== 0;
124
- })();
125
-
126
- var UNSUPPORTED_Y$1 = stickyHelpers$1.BROKEN_CARET;
127
-
128
- // nonparticipating capturing group, copied from es5-shim's String#split patch.
129
- var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
130
-
131
- var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
132
-
133
- if (PATCH) {
134
- patchedExec = function exec(string) {
135
- var re = this;
136
- var state = getInternalState(re);
137
- var str = toString$2(string);
138
- var raw = state.raw;
139
- var result, reCopy, lastIndex, match, i, object, group;
140
-
141
- if (raw) {
142
- raw.lastIndex = re.lastIndex;
143
- result = call$2(patchedExec, raw, str);
144
- re.lastIndex = raw.lastIndex;
145
- return result;
146
- }
147
-
148
- var groups = state.groups;
149
- var sticky = UNSUPPORTED_Y$1 && re.sticky;
150
- var flags = call$2(regexpFlags, re);
151
- var source = re.source;
152
- var charsAdded = 0;
153
- var strCopy = str;
154
-
155
- if (sticky) {
156
- flags = replace(flags, 'y', '');
157
- if (indexOf(flags, 'g') === -1) {
158
- flags += 'g';
159
- }
160
-
161
- strCopy = stringSlice$2(str, re.lastIndex);
162
- // Support anchored sticky behavior.
163
- if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) {
164
- source = '(?: ' + source + ')';
165
- strCopy = ' ' + strCopy;
166
- charsAdded++;
167
- }
168
- // ^(? + rx + ) is needed, in combination with some str slicing, to
169
- // simulate the 'y' flag.
170
- reCopy = new RegExp('^(?:' + source + ')', flags);
171
- }
172
-
173
- if (NPCG_INCLUDED) {
174
- reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
175
- }
176
- if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
177
-
178
- match = call$2(nativeExec, sticky ? reCopy : re, strCopy);
179
-
180
- if (sticky) {
181
- if (match) {
182
- match.input = stringSlice$2(match.input, charsAdded);
183
- match[0] = stringSlice$2(match[0], charsAdded);
184
- match.index = re.lastIndex;
185
- re.lastIndex += match[0].length;
186
- } else re.lastIndex = 0;
187
- } else if (UPDATES_LAST_INDEX_WRONG && match) {
188
- re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
189
- }
190
- if (NPCG_INCLUDED && match && match.length > 1) {
191
- // Fix browsers whose `exec` methods don't consistently return `undefined`
192
- // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
193
- call$2(nativeReplace, match[0], reCopy, function () {
194
- for (i = 1; i < arguments.length - 2; i++) {
195
- if (arguments[i] === undefined) match[i] = undefined;
196
- }
197
- });
198
- }
199
-
200
- if (match && groups) {
201
- match.groups = object = create(null);
202
- for (i = 0; i < groups.length; i++) {
203
- group = groups[i];
204
- object[group[0]] = match[group[1]];
205
- }
206
- }
207
-
208
- return match;
209
- };
210
- }
211
-
212
- var regexpExec$3 = patchedExec;
213
-
214
- var $ = _export;
215
- var exec$1 = regexpExec$3;
216
-
217
- // `RegExp.prototype.exec` method
218
- // https://tc39.es/ecma262/#sec-regexp.prototype.exec
219
- $({ target: 'RegExp', proto: true, forced: /./.exec !== exec$1 }, {
220
- exec: exec$1
221
- });
222
-
223
- // TODO: Remove from `core-js@4` since it's moved to entry points
224
-
225
- var uncurryThis$2 = functionUncurryThis;
226
- var defineBuiltIn = defineBuiltIn$1;
227
- var regexpExec$2 = regexpExec$3;
228
- var fails$1 = fails$5;
229
- var wellKnownSymbol$1 = wellKnownSymbol$2;
230
- var createNonEnumerableProperty = createNonEnumerableProperty$1;
231
-
232
- var SPECIES = wellKnownSymbol$1('species');
233
- var RegExpPrototype = RegExp.prototype;
234
-
235
- var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
236
- var SYMBOL = wellKnownSymbol$1(KEY);
237
-
238
- var DELEGATES_TO_SYMBOL = !fails$1(function () {
239
- // String methods call symbol-named RegEp methods
240
- var O = {};
241
- O[SYMBOL] = function () { return 7; };
242
- return ''[KEY](O) != 7;
243
- });
244
-
245
- var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$1(function () {
246
- // Symbol-named RegExp methods call .exec
247
- var execCalled = false;
248
- var re = /a/;
249
-
250
- if (KEY === 'split') {
251
- // We can't use real regex here since it causes deoptimization
252
- // and serious performance degradation in V8
253
- // https://github.com/zloirock/core-js/issues/306
254
- re = {};
255
- // RegExp[@@split] doesn't call the regex's exec method, but first creates
256
- // a new one. We need to return the patched regex when creating the new one.
257
- re.constructor = {};
258
- re.constructor[SPECIES] = function () { return re; };
259
- re.flags = '';
260
- re[SYMBOL] = /./[SYMBOL];
261
- }
262
-
263
- re.exec = function () { execCalled = true; return null; };
264
-
265
- re[SYMBOL]('');
266
- return !execCalled;
267
- });
268
-
269
- if (
270
- !DELEGATES_TO_SYMBOL ||
271
- !DELEGATES_TO_EXEC ||
272
- FORCED
273
- ) {
274
- var uncurriedNativeRegExpMethod = uncurryThis$2(/./[SYMBOL]);
275
- var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
276
- var uncurriedNativeMethod = uncurryThis$2(nativeMethod);
277
- var $exec = regexp.exec;
278
- if ($exec === regexpExec$2 || $exec === RegExpPrototype.exec) {
279
- if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
280
- // The native String method already delegates to @@method (this
281
- // polyfilled function), leasing to infinite recursion.
282
- // We avoid it by directly calling the native @@method method.
283
- return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) };
284
- }
285
- return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) };
286
- }
287
- return { done: false };
288
- });
289
-
290
- defineBuiltIn(String.prototype, KEY, methods[0]);
291
- defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]);
292
- }
293
-
294
- if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
295
- };
296
-
297
- var isObject = isObject$1;
298
- var classof$1 = classofRaw;
299
- var wellKnownSymbol = wellKnownSymbol$2;
300
-
301
- var MATCH = wellKnownSymbol('match');
302
-
303
- // `IsRegExp` abstract operation
304
- // https://tc39.es/ecma262/#sec-isregexp
305
- var isRegexp = function (it) {
306
- var isRegExp;
307
- return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof$1(it) == 'RegExp');
308
- };
309
-
310
- var uncurryThis$1 = functionUncurryThis;
311
- var toIntegerOrInfinity = toIntegerOrInfinity$1;
312
- var toString$1 = toString$3;
313
- var requireObjectCoercible$1 = requireObjectCoercible$2;
314
-
315
- var charAt$1 = uncurryThis$1(''.charAt);
316
- var charCodeAt = uncurryThis$1(''.charCodeAt);
317
- var stringSlice$1 = uncurryThis$1(''.slice);
318
-
319
- var createMethod = function (CONVERT_TO_STRING) {
320
- return function ($this, pos) {
321
- var S = toString$1(requireObjectCoercible$1($this));
322
- var position = toIntegerOrInfinity(pos);
323
- var size = S.length;
324
- var first, second;
325
- if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
326
- first = charCodeAt(S, position);
327
- return first < 0xD800 || first > 0xDBFF || position + 1 === size
328
- || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
329
- ? CONVERT_TO_STRING
330
- ? charAt$1(S, position)
331
- : first
332
- : CONVERT_TO_STRING
333
- ? stringSlice$1(S, position, position + 2)
334
- : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
335
- };
336
- };
337
-
338
- var stringMultibyte = {
339
- // `String.prototype.codePointAt` method
340
- // https://tc39.es/ecma262/#sec-string.prototype.codepointat
341
- codeAt: createMethod(false),
342
- // `String.prototype.at` method
343
- // https://github.com/mathiasbynens/String.prototype.at
344
- charAt: createMethod(true)
345
- };
346
-
347
- var charAt = stringMultibyte.charAt;
348
-
349
- // `AdvanceStringIndex` abstract operation
350
- // https://tc39.es/ecma262/#sec-advancestringindex
351
- var advanceStringIndex$1 = function (S, index, unicode) {
352
- return index + (unicode ? charAt(S, index).length : 1);
353
- };
354
-
355
- var toPropertyKey = toPropertyKey$1;
356
- var definePropertyModule = objectDefineProperty;
357
- var createPropertyDescriptor = createPropertyDescriptor$1;
358
-
359
- var createProperty$1 = function (object, key, value) {
360
- var propertyKey = toPropertyKey(key);
361
- if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
362
- else object[propertyKey] = value;
363
- };
364
-
365
- var toAbsoluteIndex = toAbsoluteIndex$1;
366
- var lengthOfArrayLike = lengthOfArrayLike$1;
367
- var createProperty = createProperty$1;
368
-
369
- var $Array = Array;
370
- var max$2 = Math.max;
371
-
372
- var arraySliceSimple = function (O, start, end) {
373
- var length = lengthOfArrayLike(O);
374
- var k = toAbsoluteIndex(start, length);
375
- var fin = toAbsoluteIndex(end === undefined ? length : end, length);
376
- var result = $Array(max$2(fin - k, 0));
377
- for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
378
- result.length = n;
379
- return result;
380
- };
381
-
382
- var call$1 = functionCall;
383
- var anObject$1 = anObject$3;
384
- var isCallable = isCallable$1;
385
- var classof = classofRaw;
386
- var regexpExec$1 = regexpExec$3;
387
-
388
- var $TypeError = TypeError;
389
-
390
- // `RegExpExec` abstract operation
391
- // https://tc39.es/ecma262/#sec-regexpexec
392
- var regexpExecAbstract = function (R, S) {
393
- var exec = R.exec;
394
- if (isCallable(exec)) {
395
- var result = call$1(exec, R, S);
396
- if (result !== null) anObject$1(result);
397
- return result;
398
- }
399
- if (classof(R) === 'RegExp') return call$1(regexpExec$1, R, S);
400
- throw $TypeError('RegExp#exec called on incompatible receiver');
401
- };
402
-
403
- var apply = functionApply;
404
- var call = functionCall;
405
- var uncurryThis = functionUncurryThis;
406
- var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
407
- var isRegExp = isRegexp;
408
- var anObject = anObject$3;
409
- var requireObjectCoercible = requireObjectCoercible$2;
410
- var speciesConstructor = speciesConstructor$1;
411
- var advanceStringIndex = advanceStringIndex$1;
412
- var toLength = toLength$1;
413
- var toString = toString$3;
414
- var getMethod = getMethod$1;
415
- var arraySlice = arraySliceSimple;
416
- var callRegExpExec = regexpExecAbstract;
417
- var regexpExec = regexpExec$3;
418
- var stickyHelpers = regexpStickyHelpers;
419
- var fails = fails$5;
420
-
421
- var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
422
- var MAX_UINT32 = 0xFFFFFFFF;
423
- var min$2 = Math.min;
424
- var $push = [].push;
425
- var exec = uncurryThis(/./.exec);
426
- var push = uncurryThis($push);
427
- var stringSlice = uncurryThis(''.slice);
428
-
429
- // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
430
- // Weex JS has frozen built-in prototypes, so use try / catch wrapper
431
- var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
432
- // eslint-disable-next-line regexp/no-empty-group -- required for testing
433
- var re = /(?:)/;
434
- var originalExec = re.exec;
435
- re.exec = function () { return originalExec.apply(this, arguments); };
436
- var result = 'ab'.split(re);
437
- return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
438
- });
439
-
440
- // @@split logic
441
- fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
442
- var internalSplit;
443
- if (
444
- 'abbc'.split(/(b)*/)[1] == 'c' ||
445
- // eslint-disable-next-line regexp/no-empty-group -- required for testing
446
- 'test'.split(/(?:)/, -1).length != 4 ||
447
- 'ab'.split(/(?:ab)*/).length != 2 ||
448
- '.'.split(/(.?)(.?)/).length != 4 ||
449
- // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
450
- '.'.split(/()()/).length > 1 ||
451
- ''.split(/.?/).length
452
- ) {
453
- // based on es5-shim implementation, need to rework it
454
- internalSplit = function (separator, limit) {
455
- var string = toString(requireObjectCoercible(this));
456
- var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
457
- if (lim === 0) return [];
458
- if (separator === undefined) return [string];
459
- // If `separator` is not a regex, use native split
460
- if (!isRegExp(separator)) {
461
- return call(nativeSplit, string, separator, lim);
462
- }
463
- var output = [];
464
- var flags = (separator.ignoreCase ? 'i' : '') +
465
- (separator.multiline ? 'm' : '') +
466
- (separator.unicode ? 'u' : '') +
467
- (separator.sticky ? 'y' : '');
468
- var lastLastIndex = 0;
469
- // Make `global` and avoid `lastIndex` issues by working with a copy
470
- var separatorCopy = new RegExp(separator.source, flags + 'g');
471
- var match, lastIndex, lastLength;
472
- while (match = call(regexpExec, separatorCopy, string)) {
473
- lastIndex = separatorCopy.lastIndex;
474
- if (lastIndex > lastLastIndex) {
475
- push(output, stringSlice(string, lastLastIndex, match.index));
476
- if (match.length > 1 && match.index < string.length) apply($push, output, arraySlice(match, 1));
477
- lastLength = match[0].length;
478
- lastLastIndex = lastIndex;
479
- if (output.length >= lim) break;
480
- }
481
- if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
482
- }
483
- if (lastLastIndex === string.length) {
484
- if (lastLength || !exec(separatorCopy, '')) push(output, '');
485
- } else push(output, stringSlice(string, lastLastIndex));
486
- return output.length > lim ? arraySlice(output, 0, lim) : output;
487
- };
488
- // Chakra, V8
489
- } else if ('0'.split(undefined, 0).length) {
490
- internalSplit = function (separator, limit) {
491
- return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit);
492
- };
493
- } else internalSplit = nativeSplit;
494
-
495
- return [
496
- // `String.prototype.split` method
497
- // https://tc39.es/ecma262/#sec-string.prototype.split
498
- function split(separator, limit) {
499
- var O = requireObjectCoercible(this);
500
- var splitter = separator == undefined ? undefined : getMethod(separator, SPLIT);
501
- return splitter
502
- ? call(splitter, separator, O, limit)
503
- : call(internalSplit, toString(O), separator, limit);
504
- },
505
- // `RegExp.prototype[@@split]` method
506
- // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
507
- //
508
- // NOTE: This cannot be properly polyfilled in engines that don't support
509
- // the 'y' flag.
510
- function (string, limit) {
511
- var rx = anObject(this);
512
- var S = toString(string);
513
- var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
514
-
515
- if (res.done) return res.value;
516
-
517
- var C = speciesConstructor(rx, RegExp);
518
-
519
- var unicodeMatching = rx.unicode;
520
- var flags = (rx.ignoreCase ? 'i' : '') +
521
- (rx.multiline ? 'm' : '') +
522
- (rx.unicode ? 'u' : '') +
523
- (UNSUPPORTED_Y ? 'g' : 'y');
524
-
525
- // ^(? + rx + ) is needed, in combination with some S slicing, to
526
- // simulate the 'y' flag.
527
- var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
528
- var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
529
- if (lim === 0) return [];
530
- if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
531
- var p = 0;
532
- var q = 0;
533
- var A = [];
534
- while (q < S.length) {
535
- splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
536
- var z = callRegExpExec(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S);
537
- var e;
538
- if (
539
- z === null ||
540
- (e = min$2(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p
541
- ) {
542
- q = advanceStringIndex(S, q, unicodeMatching);
543
- } else {
544
- push(A, stringSlice(S, p, q));
545
- if (A.length === lim) return A;
546
- for (var i = 1; i <= z.length - 1; i++) {
547
- push(A, z[i]);
548
- if (A.length === lim) return A;
549
- }
550
- q = p = e;
551
- }
552
- }
553
- push(A, stringSlice(S, p));
554
- return A;
555
- }
556
- ];
557
- }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
558
-
559
- function getSide(placement) {
560
- return placement.split('-')[0];
561
- }
562
-
563
- function getAlignment(placement) {
564
- return placement.split('-')[1];
565
- }
566
-
567
- function getMainAxisFromPlacement(placement) {
568
- return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
569
- }
570
-
571
- function getLengthFromAxis(axis) {
572
- return axis === 'y' ? 'height' : 'width';
573
- }
574
-
575
- function computeCoordsFromPlacement(_ref, placement, rtl) {
576
- let {
577
- reference,
578
- floating
579
- } = _ref;
580
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
581
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
582
- const mainAxis = getMainAxisFromPlacement(placement);
583
- const length = getLengthFromAxis(mainAxis);
584
- const commonAlign = reference[length] / 2 - floating[length] / 2;
585
- const side = getSide(placement);
586
- const isVertical = mainAxis === 'x';
587
- let coords;
588
-
589
- switch (side) {
590
- case 'top':
591
- coords = {
592
- x: commonX,
593
- y: reference.y - floating.height
594
- };
595
- break;
596
-
597
- case 'bottom':
598
- coords = {
599
- x: commonX,
600
- y: reference.y + reference.height
601
- };
602
- break;
603
-
604
- case 'right':
605
- coords = {
606
- x: reference.x + reference.width,
607
- y: commonY
608
- };
609
- break;
610
-
611
- case 'left':
612
- coords = {
613
- x: reference.x - floating.width,
614
- y: commonY
615
- };
616
- break;
617
-
618
- default:
619
- coords = {
620
- x: reference.x,
621
- y: reference.y
622
- };
623
- }
624
-
625
- switch (getAlignment(placement)) {
626
- case 'start':
627
- coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
628
- break;
629
-
630
- case 'end':
631
- coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
632
- break;
633
- }
634
-
635
- return coords;
636
- }
637
-
638
- /**
639
- * Computes the `x` and `y` coordinates that will place the floating element
640
- * next to a reference element when it is given a certain positioning strategy.
641
- *
642
- * This export does not have any `platform` interface logic. You will need to
643
- * write one for the platform you are using Floating UI with.
644
- */
645
-
646
- const computePosition$1 = async (reference, floating, config) => {
647
- const {
648
- placement = 'bottom',
649
- strategy = 'absolute',
650
- middleware = [],
651
- platform
652
- } = config;
653
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
654
-
655
- {
656
- if (platform == null) {
657
- console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
658
- }
659
-
660
- if (middleware.filter(_ref => {
661
- let {
662
- name
663
- } = _ref;
664
- return name === 'autoPlacement' || name === 'flip';
665
- }).length > 1) {
666
- throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement`', 'middleware detected. This will lead to an infinite loop. Ensure only', 'one of either has been passed to the `middleware` array.'].join(' '));
667
- }
668
- }
669
-
670
- let rects = await platform.getElementRects({
671
- reference,
672
- floating,
673
- strategy
674
- });
675
- let {
676
- x,
677
- y
678
- } = computeCoordsFromPlacement(rects, placement, rtl);
679
- let statefulPlacement = placement;
680
- let middlewareData = {};
681
- let _debug_loop_count_ = 0;
682
-
683
- for (let i = 0; i < middleware.length; i++) {
684
- {
685
- _debug_loop_count_++;
686
-
687
- if (_debug_loop_count_ > 100) {
688
- throw new Error(['Floating UI: The middleware lifecycle appears to be', 'running in an infinite loop. This is usually caused by a `reset`', 'continually being returned without a break condition.'].join(' '));
689
- }
690
- }
691
-
692
- const {
693
- name,
694
- fn
695
- } = middleware[i];
696
- const {
697
- x: nextX,
698
- y: nextY,
699
- data,
700
- reset
701
- } = await fn({
702
- x,
703
- y,
704
- initialPlacement: placement,
705
- placement: statefulPlacement,
706
- strategy,
707
- middlewareData,
708
- rects,
709
- platform,
710
- elements: {
711
- reference,
712
- floating
713
- }
714
- });
715
- x = nextX != null ? nextX : x;
716
- y = nextY != null ? nextY : y;
717
- middlewareData = { ...middlewareData,
718
- [name]: { ...middlewareData[name],
719
- ...data
720
- }
721
- };
722
-
723
- if (reset) {
724
- if (typeof reset === 'object') {
725
- if (reset.placement) {
726
- statefulPlacement = reset.placement;
727
- }
728
-
729
- if (reset.rects) {
730
- rects = reset.rects === true ? await platform.getElementRects({
731
- reference,
732
- floating,
733
- strategy
734
- }) : reset.rects;
735
- }
736
-
737
- ({
738
- x,
739
- y
740
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
741
- }
742
-
743
- i = -1;
744
- continue;
745
- }
746
- }
747
-
748
- return {
749
- x,
750
- y,
751
- placement: statefulPlacement,
752
- strategy,
753
- middlewareData
754
- };
755
- };
756
-
757
- function expandPaddingObject(padding) {
758
- return {
759
- top: 0,
760
- right: 0,
761
- bottom: 0,
762
- left: 0,
763
- ...padding
764
- };
765
- }
766
-
767
- function getSideObjectFromPadding(padding) {
768
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
769
- top: padding,
770
- right: padding,
771
- bottom: padding,
772
- left: padding
773
- };
774
- }
775
-
776
- function rectToClientRect(rect) {
777
- return { ...rect,
778
- top: rect.y,
779
- left: rect.x,
780
- right: rect.x + rect.width,
781
- bottom: rect.y + rect.height
782
- };
783
- }
784
-
785
- /**
786
- * Resolves with an object of overflow side offsets that determine how much the
787
- * element is overflowing a given clipping boundary.
788
- * - positive = overflowing the boundary by that number of pixels
789
- * - negative = how many pixels left before it will overflow
790
- * - 0 = lies flush with the boundary
791
- * @see https://floating-ui.com/docs/detectOverflow
792
- */
793
- async function detectOverflow(middlewareArguments, options) {
794
- var _await$platform$isEle;
795
-
796
- if (options === void 0) {
797
- options = {};
798
- }
799
-
800
- const {
801
- x,
802
- y,
803
- platform,
804
- rects,
805
- elements,
806
- strategy
807
- } = middlewareArguments;
808
- const {
809
- boundary = 'clippingAncestors',
810
- rootBoundary = 'viewport',
811
- elementContext = 'floating',
812
- altBoundary = false,
813
- padding = 0
814
- } = options;
815
- const paddingObject = getSideObjectFromPadding(padding);
816
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
817
- const element = elements[altBoundary ? altContext : elementContext];
818
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
819
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
820
- boundary,
821
- rootBoundary,
822
- strategy
823
- }));
824
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
825
- rect: elementContext === 'floating' ? { ...rects.floating,
826
- x,
827
- y
828
- } : rects.reference,
829
- offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
830
- strategy
831
- }) : rects[elementContext]);
832
- return {
833
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
834
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
835
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
836
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
837
- };
838
- }
839
-
840
- const min$1 = Math.min;
841
- const max$1 = Math.max;
842
-
843
- function within(min$1$1, value, max$1$1) {
844
- return max$1(min$1$1, min$1(value, max$1$1));
845
- }
846
-
847
- /**
848
- * Positions an inner element of the floating element such that it is centered
849
- * to the reference element.
850
- * @see https://floating-ui.com/docs/arrow
851
- */
852
- const arrow = options => ({
853
- name: 'arrow',
854
- options,
855
-
856
- async fn(middlewareArguments) {
857
- // Since `element` is required, we don't Partial<> the type
858
- const {
859
- element,
860
- padding = 0
861
- } = options != null ? options : {};
862
- const {
863
- x,
864
- y,
865
- placement,
866
- rects,
867
- platform
868
- } = middlewareArguments;
869
-
870
- if (element == null) {
871
- {
872
- console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
873
- }
874
-
875
- return {};
876
- }
877
-
878
- const paddingObject = getSideObjectFromPadding(padding);
879
- const coords = {
880
- x,
881
- y
882
- };
883
- const axis = getMainAxisFromPlacement(placement);
884
- const alignment = getAlignment(placement);
885
- const length = getLengthFromAxis(axis);
886
- const arrowDimensions = await platform.getDimensions(element);
887
- const minProp = axis === 'y' ? 'top' : 'left';
888
- const maxProp = axis === 'y' ? 'bottom' : 'right';
889
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
890
- const startDiff = coords[axis] - rects.reference[axis];
891
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
892
- let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
893
-
894
- if (clientSize === 0) {
895
- clientSize = rects.floating[length];
896
- }
897
-
898
- const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
899
- // point is outside the floating element's bounds
900
-
901
- const min = paddingObject[minProp];
902
- const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
903
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
904
- const offset = within(min, center, max); // Make sure that arrow points at the reference
905
-
906
- const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
907
- const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
908
- const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
909
- return {
910
- [axis]: coords[axis] - alignmentOffset,
911
- data: {
912
- [axis]: offset,
913
- centerOffset: center - offset
914
- }
915
- };
916
- }
917
-
918
- });
919
-
920
- const hash$1 = {
921
- left: 'right',
922
- right: 'left',
923
- bottom: 'top',
924
- top: 'bottom'
925
- };
926
- function getOppositePlacement(placement) {
927
- return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
928
- }
929
-
930
- function getAlignmentSides(placement, rects, rtl) {
931
- if (rtl === void 0) {
932
- rtl = false;
933
- }
934
-
935
- const alignment = getAlignment(placement);
936
- const mainAxis = getMainAxisFromPlacement(placement);
937
- const length = getLengthFromAxis(mainAxis);
938
- let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
939
-
940
- if (rects.reference[length] > rects.floating[length]) {
941
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
942
- }
943
-
944
- return {
945
- main: mainAlignmentSide,
946
- cross: getOppositePlacement(mainAlignmentSide)
947
- };
948
- }
949
-
950
- const hash = {
951
- start: 'end',
952
- end: 'start'
953
- };
954
- function getOppositeAlignmentPlacement(placement) {
955
- return placement.replace(/start|end/g, matched => hash[matched]);
956
- }
957
-
958
- const sides = ['top', 'right', 'bottom', 'left'];
959
-
960
- function getExpandedPlacements(placement) {
961
- const oppositePlacement = getOppositePlacement(placement);
962
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
963
- }
964
-
965
- /**
966
- * Changes the placement of the floating element to one that will fit if the
967
- * initially specified `placement` does not.
968
- * @see https://floating-ui.com/docs/flip
969
- */
970
- const flip = function (options) {
971
- if (options === void 0) {
972
- options = {};
973
- }
974
-
975
- return {
976
- name: 'flip',
977
- options,
978
-
979
- async fn(middlewareArguments) {
980
- var _middlewareData$flip;
981
-
982
- const {
983
- placement,
984
- middlewareData,
985
- rects,
986
- initialPlacement,
987
- platform,
988
- elements
989
- } = middlewareArguments;
990
- const {
991
- mainAxis: checkMainAxis = true,
992
- crossAxis: checkCrossAxis = true,
993
- fallbackPlacements: specifiedFallbackPlacements,
994
- fallbackStrategy = 'bestFit',
995
- flipAlignment = true,
996
- ...detectOverflowOptions
997
- } = options;
998
- const side = getSide(placement);
999
- const isBasePlacement = side === initialPlacement;
1000
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1001
- const placements = [initialPlacement, ...fallbackPlacements];
1002
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
1003
- const overflows = [];
1004
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1005
-
1006
- if (checkMainAxis) {
1007
- overflows.push(overflow[side]);
1008
- }
1009
-
1010
- if (checkCrossAxis) {
1011
- const {
1012
- main,
1013
- cross
1014
- } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1015
- overflows.push(overflow[main], overflow[cross]);
1016
- }
1017
-
1018
- overflowsData = [...overflowsData, {
1019
- placement,
1020
- overflows
1021
- }]; // One or more sides is overflowing
1022
-
1023
- if (!overflows.every(side => side <= 0)) {
1024
- var _middlewareData$flip$, _middlewareData$flip2;
1025
-
1026
- const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
1027
- const nextPlacement = placements[nextIndex];
1028
-
1029
- if (nextPlacement) {
1030
- // Try next placement and re-run the lifecycle
1031
- return {
1032
- data: {
1033
- index: nextIndex,
1034
- overflows: overflowsData
1035
- },
1036
- reset: {
1037
- placement: nextPlacement
1038
- }
1039
- };
1040
- }
1041
-
1042
- let resetPlacement = 'bottom';
1043
-
1044
- switch (fallbackStrategy) {
1045
- case 'bestFit':
1046
- {
1047
- var _overflowsData$map$so;
1048
-
1049
- const placement = (_overflowsData$map$so = overflowsData.map(d => [d, 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].placement;
1050
-
1051
- if (placement) {
1052
- resetPlacement = placement;
1053
- }
1054
-
1055
- break;
1056
- }
1057
-
1058
- case 'initialPlacement':
1059
- resetPlacement = initialPlacement;
1060
- break;
1061
- }
1062
-
1063
- if (placement !== resetPlacement) {
1064
- return {
1065
- reset: {
1066
- placement: resetPlacement
1067
- }
1068
- };
1069
- }
1070
- }
1071
-
1072
- return {};
1073
- }
1074
-
1075
- };
1076
- };
1077
-
1078
- function getSideOffsets(overflow, rect) {
1079
- return {
1080
- top: overflow.top - rect.height,
1081
- right: overflow.right - rect.width,
1082
- bottom: overflow.bottom - rect.height,
1083
- left: overflow.left - rect.width
1084
- };
1085
- }
1086
-
1087
- function isAnySideFullyClipped(overflow) {
1088
- return sides.some(side => overflow[side] >= 0);
1089
- }
1090
-
1091
- /**
1092
- * Provides data to hide the floating element in applicable situations, such as
1093
- * when it is not in the same clipping context as the reference element.
1094
- * @see https://floating-ui.com/docs/hide
1095
- */
1096
- const hide = function (_temp) {
1097
- let {
1098
- strategy = 'referenceHidden',
1099
- ...detectOverflowOptions
1100
- } = _temp === void 0 ? {} : _temp;
1101
- return {
1102
- name: 'hide',
1103
-
1104
- async fn(middlewareArguments) {
1105
- const {
1106
- rects
1107
- } = middlewareArguments;
1108
-
1109
- switch (strategy) {
1110
- case 'referenceHidden':
1111
- {
1112
- const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
1113
- elementContext: 'reference'
1114
- });
1115
- const offsets = getSideOffsets(overflow, rects.reference);
1116
- return {
1117
- data: {
1118
- referenceHiddenOffsets: offsets,
1119
- referenceHidden: isAnySideFullyClipped(offsets)
1120
- }
1121
- };
1122
- }
1123
-
1124
- case 'escaped':
1125
- {
1126
- const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
1127
- altBoundary: true
1128
- });
1129
- const offsets = getSideOffsets(overflow, rects.floating);
1130
- return {
1131
- data: {
1132
- escapedOffsets: offsets,
1133
- escaped: isAnySideFullyClipped(offsets)
1134
- }
1135
- };
1136
- }
1137
-
1138
- default:
1139
- {
1140
- return {};
1141
- }
1142
- }
1143
- }
1144
-
1145
- };
1146
- };
1147
-
1148
- async function convertValueToCoords(middlewareArguments, value) {
1149
- const {
1150
- placement,
1151
- platform,
1152
- elements
1153
- } = middlewareArguments;
1154
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1155
- const side = getSide(placement);
1156
- const alignment = getAlignment(placement);
1157
- const isVertical = getMainAxisFromPlacement(placement) === 'x';
1158
- const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1159
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
1160
- const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
1161
-
1162
- let {
1163
- mainAxis,
1164
- crossAxis,
1165
- alignmentAxis
1166
- } = typeof rawValue === 'number' ? {
1167
- mainAxis: rawValue,
1168
- crossAxis: 0,
1169
- alignmentAxis: null
1170
- } : {
1171
- mainAxis: 0,
1172
- crossAxis: 0,
1173
- alignmentAxis: null,
1174
- ...rawValue
1175
- };
1176
-
1177
- if (alignment && typeof alignmentAxis === 'number') {
1178
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1179
- }
1180
-
1181
- return isVertical ? {
1182
- x: crossAxis * crossAxisMulti,
1183
- y: mainAxis * mainAxisMulti
1184
- } : {
1185
- x: mainAxis * mainAxisMulti,
1186
- y: crossAxis * crossAxisMulti
1187
- };
1188
- }
1189
- /**
1190
- * Displaces the floating element from its reference element.
1191
- * @see https://floating-ui.com/docs/offset
1192
- */
1193
-
1194
- const offset = function (value) {
1195
- if (value === void 0) {
1196
- value = 0;
1197
- }
1198
-
1199
- return {
1200
- name: 'offset',
1201
- options: value,
1202
-
1203
- async fn(middlewareArguments) {
1204
- const {
1205
- x,
1206
- y
1207
- } = middlewareArguments;
1208
- const diffCoords = await convertValueToCoords(middlewareArguments, value);
1209
- return {
1210
- x: x + diffCoords.x,
1211
- y: y + diffCoords.y,
1212
- data: diffCoords
1213
- };
1214
- }
1215
-
1216
- };
1217
- };
1218
-
1219
- /**
1220
- * Provides improved positioning for inline reference elements that can span
1221
- * over multiple lines, such as hyperlinks or range selections.
1222
- * @see https://floating-ui.com/docs/inline
1223
- */
1224
- const inline = function (options) {
1225
- if (options === void 0) {
1226
- options = {};
1227
- }
1228
-
1229
- return {
1230
- name: 'inline',
1231
- options,
1232
-
1233
- async fn(middlewareArguments) {
1234
- var _await$platform$getCl;
1235
-
1236
- const {
1237
- placement,
1238
- elements,
1239
- rects,
1240
- platform,
1241
- strategy
1242
- } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
1243
- // ClientRect's bounds, despite the event listener being triggered. A
1244
- // padding of 2 seems to handle this issue.
1245
-
1246
- const {
1247
- padding = 2,
1248
- x,
1249
- y
1250
- } = options;
1251
- const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1252
- rect: rects.reference,
1253
- offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
1254
- strategy
1255
- }) : rects.reference);
1256
- const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
1257
- const paddingObject = getSideObjectFromPadding(padding);
1258
-
1259
- function getBoundingClientRect() {
1260
- // There are two rects and they are disjoined
1261
- if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
1262
- var _clientRects$find;
1263
-
1264
- // Find the first rect in which the point is fully inside
1265
- return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
1266
- } // There are 2 or more connected rects
1267
-
1268
-
1269
- if (clientRects.length >= 2) {
1270
- if (getMainAxisFromPlacement(placement) === 'x') {
1271
- const firstRect = clientRects[0];
1272
- const lastRect = clientRects[clientRects.length - 1];
1273
- const isTop = getSide(placement) === 'top';
1274
- const top = firstRect.top;
1275
- const bottom = lastRect.bottom;
1276
- const left = isTop ? firstRect.left : lastRect.left;
1277
- const right = isTop ? firstRect.right : lastRect.right;
1278
- const width = right - left;
1279
- const height = bottom - top;
1280
- return {
1281
- top,
1282
- bottom,
1283
- left,
1284
- right,
1285
- width,
1286
- height,
1287
- x: left,
1288
- y: top
1289
- };
1290
- }
1291
-
1292
- const isLeftSide = getSide(placement) === 'left';
1293
- const maxRight = max$1(...clientRects.map(rect => rect.right));
1294
- const minLeft = min$1(...clientRects.map(rect => rect.left));
1295
- const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
1296
- const top = measureRects[0].top;
1297
- const bottom = measureRects[measureRects.length - 1].bottom;
1298
- const left = minLeft;
1299
- const right = maxRight;
1300
- const width = right - left;
1301
- const height = bottom - top;
1302
- return {
1303
- top,
1304
- bottom,
1305
- left,
1306
- right,
1307
- width,
1308
- height,
1309
- x: left,
1310
- y: top
1311
- };
1312
- }
1313
-
1314
- return fallback;
1315
- }
1316
-
1317
- const resetRects = await platform.getElementRects({
1318
- reference: {
1319
- getBoundingClientRect
1320
- },
1321
- floating: elements.floating,
1322
- strategy
1323
- });
1324
-
1325
- if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
1326
- return {
1327
- reset: {
1328
- rects: resetRects
1329
- }
1330
- };
1331
- }
1332
-
1333
- return {};
1334
- }
1335
-
1336
- };
1337
- };
1338
-
1339
- function isWindow(value) {
1340
- return value && value.document && value.location && value.alert && value.setInterval;
1341
- }
1342
- function getWindow(node) {
1343
- if (node == null) {
1344
- return window;
1345
- }
1346
-
1347
- if (!isWindow(node)) {
1348
- const ownerDocument = node.ownerDocument;
1349
- return ownerDocument ? ownerDocument.defaultView || window : window;
1350
- }
1351
-
1352
- return node;
1353
- }
1354
-
1355
- function getComputedStyle$1(element) {
1356
- return getWindow(element).getComputedStyle(element);
1357
- }
1358
-
1359
- function getNodeName(node) {
1360
- return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
1361
- }
1362
-
1363
- function getUAString() {
1364
- const uaData = navigator.userAgentData;
1365
-
1366
- if (uaData != null && uaData.brands) {
1367
- return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
1368
- }
1369
-
1370
- return navigator.userAgent;
1371
- }
1372
-
1373
- function isHTMLElement(value) {
1374
- return value instanceof getWindow(value).HTMLElement;
1375
- }
1376
- function isElement(value) {
1377
- return value instanceof getWindow(value).Element;
1378
- }
1379
- function isNode(value) {
1380
- return value instanceof getWindow(value).Node;
1381
- }
1382
- function isShadowRoot(node) {
1383
- // Browsers without `ShadowRoot` support
1384
- if (typeof ShadowRoot === 'undefined') {
1385
- return false;
1386
- }
1387
-
1388
- const OwnElement = getWindow(node).ShadowRoot;
1389
- return node instanceof OwnElement || node instanceof ShadowRoot;
1390
- }
1391
- function isOverflowElement(element) {
1392
- // Firefox wants us to check `-x` and `-y` variations as well
1393
- const {
1394
- overflow,
1395
- overflowX,
1396
- overflowY
1397
- } = getComputedStyle$1(element);
1398
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1399
- }
1400
- function isTableElement(element) {
1401
- return ['table', 'td', 'th'].includes(getNodeName(element));
1402
- }
1403
- function isContainingBlock(element) {
1404
- // TODO: Try and use feature detection here instead
1405
- const isFirefox = /firefox/i.test(getUAString());
1406
- const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
1407
- // create a containing block.
1408
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1409
-
1410
- return css.transform !== 'none' || css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)
1411
- css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
1412
- }
1413
- function isLayoutViewport() {
1414
- // Not Safari
1415
- return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
1416
- // • Always-visible scrollbar or not
1417
- // • Width of <html>, etc.
1418
- // const vV = win.visualViewport;
1419
- // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
1420
- }
1421
-
1422
- const min = Math.min;
1423
- const max = Math.max;
1424
- const round = Math.round;
1425
-
1426
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1427
- var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
1428
-
1429
- if (includeScale === void 0) {
1430
- includeScale = false;
1431
- }
1432
-
1433
- if (isFixedStrategy === void 0) {
1434
- isFixedStrategy = false;
1435
- }
1436
-
1437
- const clientRect = element.getBoundingClientRect();
1438
- let scaleX = 1;
1439
- let scaleY = 1;
1440
-
1441
- if (includeScale && isHTMLElement(element)) {
1442
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1443
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1444
- }
1445
-
1446
- const win = isElement(element) ? getWindow(element) : window;
1447
- const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1448
- const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
1449
- const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
1450
- const width = clientRect.width / scaleX;
1451
- const height = clientRect.height / scaleY;
1452
- return {
1453
- width,
1454
- height,
1455
- top: y,
1456
- right: x + width,
1457
- bottom: y + height,
1458
- left: x,
1459
- x,
1460
- y
1461
- };
1462
- }
1463
-
1464
- function getDocumentElement(node) {
1465
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
1466
- }
1467
-
1468
- function getNodeScroll(element) {
1469
- if (isElement(element)) {
1470
- return {
1471
- scrollLeft: element.scrollLeft,
1472
- scrollTop: element.scrollTop
1473
- };
1474
- }
1475
-
1476
- return {
1477
- scrollLeft: element.pageXOffset,
1478
- scrollTop: element.pageYOffset
1479
- };
1480
- }
1481
-
1482
- function getWindowScrollBarX(element) {
1483
- // If <html> has a CSS width greater than the viewport, then this will be
1484
- // incorrect for RTL.
1485
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1486
- }
1487
-
1488
- function isScaled(element) {
1489
- const rect = getBoundingClientRect(element);
1490
- return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
1491
- }
1492
-
1493
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1494
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1495
- const documentElement = getDocumentElement(offsetParent);
1496
- const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
1497
- isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
1498
- let scroll = {
1499
- scrollLeft: 0,
1500
- scrollTop: 0
1501
- };
1502
- const offsets = {
1503
- x: 0,
1504
- y: 0
1505
- };
1506
-
1507
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1508
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1509
- scroll = getNodeScroll(offsetParent);
1510
- }
1511
-
1512
- if (isHTMLElement(offsetParent)) {
1513
- const offsetRect = getBoundingClientRect(offsetParent, true);
1514
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1515
- offsets.y = offsetRect.y + offsetParent.clientTop;
1516
- } else if (documentElement) {
1517
- offsets.x = getWindowScrollBarX(documentElement);
1518
- }
1519
- }
1520
-
1521
- return {
1522
- x: rect.left + scroll.scrollLeft - offsets.x,
1523
- y: rect.top + scroll.scrollTop - offsets.y,
1524
- width: rect.width,
1525
- height: rect.height
1526
- };
1527
- }
1528
-
1529
- function getParentNode(node) {
1530
- if (getNodeName(node) === 'html') {
1531
- return node;
1532
- }
1533
-
1534
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1535
- // @ts-ignore
1536
- node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1537
- node.parentNode || ( // DOM Element detected
1538
- isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
1539
- getDocumentElement(node) // fallback
1540
-
1541
- );
1542
- }
1543
-
1544
- function getTrueOffsetParent(element) {
1545
- if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1546
- return null;
1547
- }
1548
-
1549
- return element.offsetParent;
1550
- }
1551
-
1552
- function getContainingBlock(element) {
1553
- let currentNode = getParentNode(element);
1554
-
1555
- if (isShadowRoot(currentNode)) {
1556
- currentNode = currentNode.host;
1557
- }
1558
-
1559
- while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
1560
- if (isContainingBlock(currentNode)) {
1561
- return currentNode;
1562
- } else {
1563
- currentNode = currentNode.parentNode;
1564
- }
1565
- }
1566
-
1567
- return null;
1568
- } // Gets the closest ancestor positioned element. Handles some edge cases,
1569
- // such as table ancestors and cross browser bugs.
1570
-
1571
-
1572
- function getOffsetParent(element) {
1573
- const window = getWindow(element);
1574
- let offsetParent = getTrueOffsetParent(element);
1575
-
1576
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1577
- offsetParent = getTrueOffsetParent(offsetParent);
1578
- }
1579
-
1580
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1581
- return window;
1582
- }
1583
-
1584
- return offsetParent || getContainingBlock(element) || window;
1585
- }
1586
-
1587
- function getDimensions(element) {
1588
- if (isHTMLElement(element)) {
1589
- return {
1590
- width: element.offsetWidth,
1591
- height: element.offsetHeight
1592
- };
1593
- }
1594
-
1595
- const rect = getBoundingClientRect(element);
1596
- return {
1597
- width: rect.width,
1598
- height: rect.height
1599
- };
1600
- }
1601
-
1602
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1603
- let {
1604
- rect,
1605
- offsetParent,
1606
- strategy
1607
- } = _ref;
1608
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1609
- const documentElement = getDocumentElement(offsetParent);
1610
-
1611
- if (offsetParent === documentElement) {
1612
- return rect;
1613
- }
1614
-
1615
- let scroll = {
1616
- scrollLeft: 0,
1617
- scrollTop: 0
1618
- };
1619
- const offsets = {
1620
- x: 0,
1621
- y: 0
1622
- };
1623
-
1624
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1625
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1626
- scroll = getNodeScroll(offsetParent);
1627
- }
1628
-
1629
- if (isHTMLElement(offsetParent)) {
1630
- const offsetRect = getBoundingClientRect(offsetParent, true);
1631
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1632
- offsets.y = offsetRect.y + offsetParent.clientTop;
1633
- } // This doesn't appear to be need to be negated.
1634
- // else if (documentElement) {
1635
- // offsets.x = getWindowScrollBarX(documentElement);
1636
- // }
1637
-
1638
- }
1639
-
1640
- return { ...rect,
1641
- x: rect.x - scroll.scrollLeft + offsets.x,
1642
- y: rect.y - scroll.scrollTop + offsets.y
1643
- };
1644
- }
1645
-
1646
- function getViewportRect(element, strategy) {
1647
- const win = getWindow(element);
1648
- const html = getDocumentElement(element);
1649
- const visualViewport = win.visualViewport;
1650
- let width = html.clientWidth;
1651
- let height = html.clientHeight;
1652
- let x = 0;
1653
- let y = 0;
1654
-
1655
- if (visualViewport) {
1656
- width = visualViewport.width;
1657
- height = visualViewport.height;
1658
- const layoutViewport = isLayoutViewport();
1659
-
1660
- if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1661
- x = visualViewport.offsetLeft;
1662
- y = visualViewport.offsetTop;
1663
- }
1664
- }
1665
-
1666
- return {
1667
- width,
1668
- height,
1669
- x,
1670
- y
1671
- };
1672
- }
1673
-
1674
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1675
-
1676
- function getDocumentRect(element) {
1677
- var _element$ownerDocumen;
1678
-
1679
- const html = getDocumentElement(element);
1680
- const scroll = getNodeScroll(element);
1681
- const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1682
- const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1683
- const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1684
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1685
- const y = -scroll.scrollTop;
1686
-
1687
- if (getComputedStyle$1(body || html).direction === 'rtl') {
1688
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1689
- }
1690
-
1691
- return {
1692
- width,
1693
- height,
1694
- x,
1695
- y
1696
- };
1697
- }
1698
-
1699
- function getNearestOverflowAncestor(node) {
1700
- const parentNode = getParentNode(node);
1701
-
1702
- if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1703
- // @ts-ignore assume body is always available
1704
- return node.ownerDocument.body;
1705
- }
1706
-
1707
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1708
- return parentNode;
1709
- }
1710
-
1711
- return getNearestOverflowAncestor(parentNode);
1712
- }
1713
-
1714
- function getOverflowAncestors(node, list) {
1715
- var _node$ownerDocument;
1716
-
1717
- if (list === void 0) {
1718
- list = [];
1719
- }
1720
-
1721
- const scrollableAncestor = getNearestOverflowAncestor(node);
1722
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1723
- const win = getWindow(scrollableAncestor);
1724
- const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1725
- const updatedList = list.concat(target);
1726
- return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1727
- updatedList.concat(getOverflowAncestors(target));
1728
- }
1729
-
1730
- function contains(parent, child) {
1731
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1732
-
1733
- if (parent.contains(child)) {
1734
- return true;
1735
- } // then fallback to custom implementation with Shadow DOM support
1736
- else if (rootNode && isShadowRoot(rootNode)) {
1737
- let next = child;
1738
-
1739
- do {
1740
- // use `===` replace node.isSameNode()
1741
- if (next && parent === next) {
1742
- return true;
1743
- } // @ts-ignore: need a better way to handle this...
1744
-
1745
-
1746
- next = next.parentNode || next.host;
1747
- } while (next);
1748
- }
1749
-
1750
- return false;
1751
- }
1752
-
1753
- function getInnerBoundingClientRect(element, strategy) {
1754
- const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1755
- const top = clientRect.top + element.clientTop;
1756
- const left = clientRect.left + element.clientLeft;
1757
- return {
1758
- top,
1759
- left,
1760
- x: left,
1761
- y: top,
1762
- right: left + element.clientWidth,
1763
- bottom: top + element.clientHeight,
1764
- width: element.clientWidth,
1765
- height: element.clientHeight
1766
- };
1767
- }
1768
-
1769
- function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1770
- if (clippingParent === 'viewport') {
1771
- return rectToClientRect(getViewportRect(element, strategy));
1772
- }
1773
-
1774
- if (isElement(clippingParent)) {
1775
- return getInnerBoundingClientRect(clippingParent, strategy);
1776
- }
1777
-
1778
- return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1779
- } // A "clipping ancestor" is an overflowable container with the characteristic of
1780
- // clipping (or hiding) overflowing elements with a position different from
1781
- // `initial`
1782
-
1783
-
1784
- function getClippingAncestors(element) {
1785
- const clippingAncestors = getOverflowAncestors(element);
1786
- const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1787
- const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1788
-
1789
- if (!isElement(clipperElement)) {
1790
- return [];
1791
- } // @ts-ignore isElement check ensures we return Array<Element>
1792
-
1793
-
1794
- return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1795
- } // Gets the maximum area that the element is visible in due to any number of
1796
- // clipping ancestors
1797
-
1798
-
1799
- function getClippingRect(_ref) {
1800
- let {
1801
- element,
1802
- boundary,
1803
- rootBoundary,
1804
- strategy
1805
- } = _ref;
1806
- const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1807
- const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1808
- const firstClippingAncestor = clippingAncestors[0];
1809
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1810
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1811
- accRect.top = max(rect.top, accRect.top);
1812
- accRect.right = min(rect.right, accRect.right);
1813
- accRect.bottom = min(rect.bottom, accRect.bottom);
1814
- accRect.left = max(rect.left, accRect.left);
1815
- return accRect;
1816
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1817
- return {
1818
- width: clippingRect.right - clippingRect.left,
1819
- height: clippingRect.bottom - clippingRect.top,
1820
- x: clippingRect.left,
1821
- y: clippingRect.top
1822
- };
1823
- }
1824
-
1825
- const platform = {
1826
- getClippingRect,
1827
- convertOffsetParentRelativeRectToViewportRelativeRect,
1828
- isElement,
1829
- getDimensions,
1830
- getOffsetParent,
1831
- getDocumentElement,
1832
- getElementRects: _ref => {
1833
- let {
1834
- reference,
1835
- floating,
1836
- strategy
1837
- } = _ref;
1838
- return {
1839
- reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1840
- floating: { ...getDimensions(floating),
1841
- x: 0,
1842
- y: 0
1843
- }
1844
- };
1845
- },
1846
- getClientRects: element => Array.from(element.getClientRects()),
1847
- isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1848
- };
1849
-
1850
- /**
1851
- * Automatically updates the position of the floating element when necessary.
1852
- * @see https://floating-ui.com/docs/autoUpdate
1853
- */
1854
- function autoUpdate(reference, floating, update, options) {
1855
- if (options === void 0) {
1856
- options = {};
1857
- }
1858
-
1859
- const {
1860
- ancestorScroll: _ancestorScroll = true,
1861
- ancestorResize: _ancestorResize = true,
1862
- elementResize = true,
1863
- animationFrame = false
1864
- } = options;
1865
- const ancestorScroll = _ancestorScroll && !animationFrame;
1866
- const ancestorResize = _ancestorResize && !animationFrame;
1867
- const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1868
- ancestors.forEach(ancestor => {
1869
- ancestorScroll && ancestor.addEventListener('scroll', update, {
1870
- passive: true
1871
- });
1872
- ancestorResize && ancestor.addEventListener('resize', update);
1873
- });
1874
- let observer = null;
1875
-
1876
- if (elementResize) {
1877
- observer = new ResizeObserver(update);
1878
- isElement(reference) && !animationFrame && observer.observe(reference);
1879
- observer.observe(floating);
1880
- }
1881
-
1882
- let frameId;
1883
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1884
-
1885
- if (animationFrame) {
1886
- frameLoop();
1887
- }
1888
-
1889
- function frameLoop() {
1890
- const nextRefRect = getBoundingClientRect(reference);
1891
-
1892
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1893
- update();
1894
- }
1895
-
1896
- prevRefRect = nextRefRect;
1897
- frameId = requestAnimationFrame(frameLoop);
1898
- }
1899
-
1900
- if (!elementResize) {
1901
- update();
1902
- }
1903
-
1904
- return () => {
1905
- var _observer;
1906
-
1907
- ancestors.forEach(ancestor => {
1908
- ancestorScroll && ancestor.removeEventListener('scroll', update);
1909
- ancestorResize && ancestor.removeEventListener('resize', update);
1910
- });
1911
- (_observer = observer) == null ? void 0 : _observer.disconnect();
1912
- observer = null;
1913
-
1914
- if (animationFrame) {
1915
- cancelAnimationFrame(frameId);
1916
- }
1917
- };
1918
- }
1919
-
1920
- /**
1921
- * Computes the `x` and `y` coordinates that will place the floating element
1922
- * next to a reference element when it is given a certain CSS positioning
1923
- * strategy.
1924
- */
1925
-
1926
- const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1927
- platform,
1928
- ...options
1929
- });
1930
-
1931
- var _Popup_instances, _Popup_arrowPosition_get, _Popup_padding_get, _Popup_distance_get, _Popup_strategy_get, _Popup_middleware_get, _Popup_cleanup, _Popup_anchorEl, _Popup_assignPopupPosition, _Popup_assignArrowPosition, _Popup_getAnchorById, _Popup_handleKeydown;
1932
- class Popup extends FoundationElement {
1933
- constructor() {
1934
- super();
1935
-
1936
- _Popup_instances.add(this);
1937
-
1938
- _Popup_cleanup.set(this, void 0);
1939
-
1940
- _Popup_anchorEl.set(this, void 0);
1941
-
1942
- this.open = false;
1943
- this.dismissible = false;
1944
- this.arrow = false;
1945
- this.alternate = false;
1946
- this.placement = 'left';
1947
- }
1948
-
1949
- disconnectedCallback() {
1950
- var _a, _b;
1951
-
1952
- super.disconnectedCallback();
1953
- (_a = __classPrivateFieldGet(this, _Popup_anchorEl, "f")) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', e => __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_handleKeydown).call(this, e));
1954
- (_b = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
1955
- }
1956
-
1957
- attributeChangedCallback(name, oldValue, newValue) {
1958
- var _a, _b;
1959
-
1960
- super.attributeChangedCallback(name, oldValue, newValue);
1961
-
1962
- switch (name) {
1963
- case 'anchor':
1964
- {
1965
- __classPrivateFieldSet(this, _Popup_anchorEl, __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_getAnchorById).call(this), "f");
1966
-
1967
- (_a = __classPrivateFieldGet(this, _Popup_anchorEl, "f")) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', e => __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_handleKeydown).call(this, e));
1968
- break;
1969
- }
1970
- }
1971
-
1972
- if (__classPrivateFieldGet(this, _Popup_anchorEl, "f") && this.popupEl) {
1973
- __classPrivateFieldSet(this, _Popup_cleanup, autoUpdate(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, () => this.updatePosition()), "f");
1974
- } else {
1975
- (_b = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
1976
- }
1977
- }
1978
-
1979
- async updatePosition() {
1980
- if (!this.open || !__classPrivateFieldGet(this, _Popup_anchorEl, "f")) {
1981
- return;
1982
- }
1983
-
1984
- const positionData = await computePosition(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, {
1985
- placement: this.placement,
1986
- strategy: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_strategy_get),
1987
- middleware: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_middleware_get)
1988
- });
1989
-
1990
- __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignPopupPosition).call(this, positionData);
1991
-
1992
- if (this.arrow) {
1993
- __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignArrowPosition).call(this, positionData);
1994
- }
1995
- }
1996
-
1997
- }
1998
- _Popup_cleanup = new WeakMap(), _Popup_anchorEl = new WeakMap(), _Popup_instances = new WeakSet(), _Popup_arrowPosition_get = function _Popup_arrowPosition_get() {
1999
- return {
2000
- top: 'bottom',
2001
- right: 'left',
2002
- bottom: 'top',
2003
- left: 'right'
2004
- };
2005
- }, _Popup_padding_get = function _Popup_padding_get() {
2006
- return 0;
2007
- }, _Popup_distance_get = function _Popup_distance_get() {
2008
- return 12;
2009
- }, _Popup_strategy_get = function _Popup_strategy_get() {
2010
- return 'fixed';
2011
- }, _Popup_middleware_get = function _Popup_middleware_get() {
2012
- const middleware = [flip(), hide(), inline()];
2013
-
2014
- if (this.arrow) {
2015
- middleware.push(arrow({
2016
- element: this.arrowEl,
2017
- padding: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_padding_get)
2018
- }), offset(__classPrivateFieldGet(this, _Popup_instances, "a", _Popup_distance_get)));
2019
- }
2020
-
2021
- return middleware;
2022
- }, _Popup_assignPopupPosition = function _Popup_assignPopupPosition(data) {
2023
- const {
2024
- x: popupX,
2025
- y: popupY
2026
- } = data;
2027
- const {
2028
- referenceHidden
2029
- } = data.middlewareData.hide;
2030
- Object.assign(this.popupEl.style, {
2031
- left: `${popupX}px`,
2032
- top: `${popupY}px`,
2033
- visibility: referenceHidden ? 'hidden' : 'visible'
2034
- });
2035
- }, _Popup_assignArrowPosition = function _Popup_assignArrowPosition(data) {
2036
- const {
2037
- x: arrowX,
2038
- y: arrowY
2039
- } = data.middlewareData.arrow;
2040
-
2041
- const side = __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_arrowPosition_get)[data.placement.split('-')[0]];
2042
-
2043
- Object.assign(this.arrowEl.style, {
2044
- left: `${arrowX}px`,
2045
- top: `${arrowY}px`,
2046
- right: '',
2047
- bottom: '',
2048
- [side]: '-4px'
2049
- });
2050
- }, _Popup_getAnchorById = function _Popup_getAnchorById() {
2051
- return document.getElementById(this.anchor);
2052
- }, _Popup_handleKeydown = function _Popup_handleKeydown({
2053
- key
2054
- }) {
2055
- if (key === keyEscape) {
2056
- this.open = false;
2057
- }
2058
- };
2059
-
2060
- __decorate([attr({
2061
- mode: 'boolean'
2062
- }), __metadata("design:type", Object)], Popup.prototype, "open", void 0);
2063
-
2064
- __decorate([attr({
2065
- mode: 'boolean'
2066
- }), __metadata("design:type", Object)], Popup.prototype, "dismissible", void 0);
2067
-
2068
- __decorate([attr({
2069
- mode: 'boolean'
2070
- }), __metadata("design:type", Object)], Popup.prototype, "arrow", void 0);
2071
-
2072
- __decorate([attr({
2073
- mode: 'boolean'
2074
- }), __metadata("design:type", Object)], Popup.prototype, "alternate", void 0);
2075
-
2076
- __decorate([attr({
2077
- mode: 'fromView'
2078
- }), __metadata("design:type", String)], Popup.prototype, "placement", void 0);
2079
-
2080
- __decorate([attr, __metadata("design:type", String)], Popup.prototype, "anchor", void 0);
2081
-
2082
- var css_248z = ".control {\n background-color: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n inline-size: -moz-fit-content;\n inline-size: fit-content;\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n position: fixed;\n border-radius: 6px;\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-on-canvas); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background-color: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 4px;\n margin-inline-end: 4px;\n}";
2083
- styleInject(css_248z);
2084
-
2085
- let _ = t => t,
2086
- _t,
2087
- _t2,
2088
- _t3;
2089
-
2090
- const getClasses = ({
2091
- open,
2092
- dismissible,
2093
- alternate
2094
- }) => classNames('control', ['open', Boolean(open)], ['dismissible', Boolean(dismissible)], ['alternate', Boolean(alternate)]);
2095
-
2096
- const popupTemplate = () => html(_t || (_t = _`
2097
- <vwc-elevation>
2098
- <!--the popup-wrapper is needed for alternating the inside of the popup nd not its shadow-->
2099
- <div class="popup-wrapper" ${0}>
2100
- <div class="${0}" aria-hidden="${0}"
2101
- part="${0}">
2102
- <div class="popup-content">
2103
- <slot></slot>
2104
- ${0}
2105
- </div>
2106
- ${0}
2107
- </div>
2108
- </div>
2109
- </vwc-elevation>`), ref('popupEl'), getClasses, x => x.open ? 'false' : 'true', x => x.alternate ? 'vvd-theme-alternate' : '', when(x => x.dismissible, html(_t2 || (_t2 = _`<vwc-button density="condensed" @click="${0}"
2110
- class="dismissible-button" icon="close-small-solid" shape="pill"></vwc-button>`), x => x.open = false)), when(x => x.arrow, html(_t3 || (_t3 = _`<div class="arrow" ${0}></div>`), ref('arrowEl'))));
2111
-
2112
- const vividPopup = Popup.compose({
2113
- baseName: 'popup',
2114
- template: popupTemplate,
2115
- styles: css_248z
2116
- });
2117
- designSystem.register(vividPopup());
2118
-
2119
- export { vividPopup };
25
+ import '../shared/es.object.assign.js';