@vonage/vivid 3.0.0-next.72 → 3.0.0-next.73

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