@limetech/lime-elements 37.55.4 → 37.55.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/lime-elements.cjs.js +1 -1
  3. package/dist/cjs/limel-callout.cjs.entry.js +1 -1
  4. package/dist/cjs/limel-callout.cjs.entry.js.map +1 -1
  5. package/dist/cjs/limel-color-picker.cjs.entry.js.map +1 -1
  6. package/dist/cjs/limel-dynamic-label_4.cjs.entry.js +2 -2
  7. package/dist/cjs/limel-dynamic-label_4.cjs.entry.js.map +1 -1
  8. package/dist/cjs/limel-form.cjs.entry.js +2 -2
  9. package/dist/cjs/limel-form.cjs.entry.js.map +1 -1
  10. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +6 -6
  11. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
  12. package/dist/cjs/limel-snackbar.cjs.entry.js +92 -523
  13. package/dist/cjs/limel-snackbar.cjs.entry.js.map +1 -1
  14. package/dist/cjs/loader.cjs.js +1 -1
  15. package/dist/collection/components/callout/callout.helpers.js +1 -1
  16. package/dist/collection/components/callout/callout.helpers.js.map +1 -1
  17. package/dist/collection/components/color-picker/color-picker.js +0 -1
  18. package/dist/collection/components/color-picker/color-picker.js.map +1 -1
  19. package/dist/collection/components/form/widgets/code-editor.js +2 -2
  20. package/dist/collection/components/form/widgets/code-editor.js.map +1 -1
  21. package/dist/collection/components/list/list-renderer.js +2 -2
  22. package/dist/collection/components/list/list-renderer.js.map +1 -1
  23. package/dist/collection/components/snackbar/container.js +50 -0
  24. package/dist/collection/components/snackbar/container.js.map +1 -0
  25. package/dist/collection/components/snackbar/snackbar.css +37 -51
  26. package/dist/collection/components/snackbar/snackbar.js +66 -40
  27. package/dist/collection/components/snackbar/snackbar.js.map +1 -1
  28. package/dist/collection/index.js.map +1 -1
  29. package/dist/esm/lime-elements.js +1 -1
  30. package/dist/esm/limel-callout.entry.js +1 -1
  31. package/dist/esm/limel-callout.entry.js.map +1 -1
  32. package/dist/esm/limel-color-picker.entry.js.map +1 -1
  33. package/dist/esm/limel-dynamic-label_4.entry.js +2 -2
  34. package/dist/esm/limel-dynamic-label_4.entry.js.map +1 -1
  35. package/dist/esm/limel-form.entry.js +2 -2
  36. package/dist/esm/limel-form.entry.js.map +1 -1
  37. package/dist/esm/limel-prosemirror-adapter.entry.js +6 -6
  38. package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
  39. package/dist/esm/limel-snackbar.entry.js +92 -523
  40. package/dist/esm/limel-snackbar.entry.js.map +1 -1
  41. package/dist/esm/loader.js +1 -1
  42. package/dist/lime-elements/lime-elements.esm.js +1 -1
  43. package/dist/lime-elements/lime-elements.esm.js.map +1 -1
  44. package/dist/lime-elements/p-47f7d74f.entry.js.map +1 -1
  45. package/dist/lime-elements/p-48652dbe.entry.js.map +1 -1
  46. package/dist/lime-elements/p-50303eb1.entry.js.map +1 -1
  47. package/dist/lime-elements/{p-ed214c35.entry.js → p-a82054c2.entry.js} +2 -2
  48. package/dist/lime-elements/p-a82054c2.entry.js.map +1 -0
  49. package/dist/lime-elements/p-c66da652.entry.js +2 -0
  50. package/dist/lime-elements/p-c66da652.entry.js.map +1 -0
  51. package/dist/lime-elements/p-e7fc1c16.entry.js +2 -0
  52. package/dist/lime-elements/p-e7fc1c16.entry.js.map +1 -0
  53. package/dist/types/components/list/list-renderer.d.ts +1 -1
  54. package/dist/types/components/snackbar/snackbar.d.ts +9 -7
  55. package/dist/types/components.d.ts +2 -4
  56. package/dist/types/index.d.ts +7 -0
  57. package/package.json +14 -11
  58. package/dist/lime-elements/p-480884e6.entry.js +0 -90
  59. package/dist/lime-elements/p-480884e6.entry.js.map +0 -1
  60. package/dist/lime-elements/p-9a895330.entry.js +0 -2
  61. package/dist/lime-elements/p-9a895330.entry.js.map +0 -1
  62. package/dist/lime-elements/p-ed214c35.entry.js.map +0 -1
@@ -1,572 +1,141 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-6156b4fd.js';
2
2
  import { t as translate } from './translations-8927471e.js';
3
- import { _ as __extends, a as __assign, M as MDCFoundation, b as MDCComponent } from './component-8b6ce3e9.js';
4
- import { c as closest } from './ponyfill-30263d5e.js';
3
+ import { c as createRandomString } from './random-string-812b1c35.js';
5
4
 
6
5
  /**
7
- * @license
8
- * Copyright 2018 Google Inc.
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
- * THE SOFTWARE.
6
+ * Container to keep track of all snackbar elements that gets added to the page.
7
+ * When an element gets added or removed, the container will emit a
8
+ * `changeOffset` event on all elements in the container, letting them know
9
+ * the new offset to where they should position themselves.
27
10
  */
28
- var cssClasses = {
29
- CLOSING: 'mdc-snackbar--closing',
30
- OPEN: 'mdc-snackbar--open',
31
- OPENING: 'mdc-snackbar--opening',
32
- };
33
- var strings = {
34
- ACTION_SELECTOR: '.mdc-snackbar__action',
35
- ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text',
36
- CLOSED_EVENT: 'MDCSnackbar:closed',
37
- CLOSING_EVENT: 'MDCSnackbar:closing',
38
- DISMISS_SELECTOR: '.mdc-snackbar__dismiss',
39
- LABEL_SELECTOR: '.mdc-snackbar__label',
40
- OPENED_EVENT: 'MDCSnackbar:opened',
41
- OPENING_EVENT: 'MDCSnackbar:opening',
42
- REASON_ACTION: 'action',
43
- REASON_DISMISS: 'dismiss',
44
- SURFACE_SELECTOR: '.mdc-snackbar__surface',
45
- };
46
- var numbers = {
47
- DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
48
- INDETERMINATE: -1,
49
- MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,
50
- MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,
51
- // These variables need to be kept in sync with the values in _variables.scss.
52
- SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75,
53
- SNACKBAR_ANIMATION_OPEN_TIME_MS: 150,
54
- /**
55
- * Number of milliseconds to wait between temporarily clearing the label text
56
- * in the DOM and subsequently restoring it. This is necessary to force IE 11
57
- * to pick up the `aria-live` content change and announce it to the user.
58
- */
59
- ARIA_LIVE_DELAY_MS: 1000,
60
- };
61
-
62
- /**
63
- * @license
64
- * Copyright 2018 Google Inc.
65
- *
66
- * Permission is hereby granted, free of charge, to any person obtaining a copy
67
- * of this software and associated documentation files (the "Software"), to deal
68
- * in the Software without restriction, including without limitation the rights
69
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
70
- * copies of the Software, and to permit persons to whom the Software is
71
- * furnished to do so, subject to the following conditions:
72
- *
73
- * The above copyright notice and this permission notice shall be included in
74
- * all copies or substantial portions of the Software.
75
- *
76
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
78
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
79
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
80
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
81
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
82
- * THE SOFTWARE.
83
- */
84
- var ARIA_LIVE_DELAY_MS = numbers.ARIA_LIVE_DELAY_MS;
85
- var ARIA_LIVE_LABEL_TEXT_ATTR = strings.ARIA_LIVE_LABEL_TEXT_ATTR;
86
- function announce(ariaEl, labelEl) {
87
- if (labelEl === void 0) { labelEl = ariaEl; }
88
- var priority = ariaEl.getAttribute('aria-live');
89
- // Trim text to ignore ` ` (see below).
90
- // textContent is only null if the node is a document, DOCTYPE, or notation.
91
- var labelText = labelEl.textContent.trim();
92
- if (!labelText || !priority) {
93
- return;
94
- }
95
- // Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice.
96
- ariaEl.setAttribute('aria-live', 'off');
97
- // Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers.
98
- // `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars
99
- // sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first.
100
- // Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event,
101
- // so screen readers won't announce the second message unless we first clear `textContent`.
102
- //
103
- // We have to clear the label text two different ways to make it work in all browsers and screen readers:
104
- //
105
- // 1. `textContent = ''` is required for IE11 + JAWS
106
- // 2. `innerHTML = ' '` is required for Chrome + JAWS and NVDA
107
- //
108
- // All other browser/screen reader combinations support both methods.
109
- //
110
- // The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed.
111
- // N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change.
112
- //
113
- // This technique has been tested in:
114
- //
115
- // * JAWS 2019:
116
- // - Chrome 70
117
- // - Firefox 60 (ESR)
118
- // - IE 11
119
- // * NVDA 2018:
120
- // - Chrome 70
121
- // - Firefox 60 (ESR)
122
- // - IE 11
123
- // * ChromeVox 53
124
- labelEl.textContent = '';
125
- labelEl.innerHTML = '<span style="display: inline-block; width: 0; height: 1px;">&nbsp;</span>';
126
- // Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element.
127
- // CSS generated content is normally announced by screen readers
128
- // (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
129
- // however, `aria-live` is turned off, so this DOM update will be ignored by screen readers.
130
- labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText);
131
- setTimeout(function () {
132
- // Allow screen readers to announce changes to the DOM again.
133
- ariaEl.setAttribute('aria-live', priority);
134
- // Remove the message from the ::before pseudo-element.
135
- labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR);
136
- // Restore the original label text, which will be announced by screen readers.
137
- labelEl.textContent = labelText;
138
- }, ARIA_LIVE_DELAY_MS);
139
- }
140
-
141
- /**
142
- * @license
143
- * Copyright 2018 Google Inc.
144
- *
145
- * Permission is hereby granted, free of charge, to any person obtaining a copy
146
- * of this software and associated documentation files (the "Software"), to deal
147
- * in the Software without restriction, including without limitation the rights
148
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
149
- * copies of the Software, and to permit persons to whom the Software is
150
- * furnished to do so, subject to the following conditions:
151
- *
152
- * The above copyright notice and this permission notice shall be included in
153
- * all copies or substantial portions of the Software.
154
- *
155
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
156
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
157
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
158
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
159
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
160
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
161
- * THE SOFTWARE.
162
- */
163
- var OPENING = cssClasses.OPENING, OPEN = cssClasses.OPEN, CLOSING = cssClasses.CLOSING;
164
- var REASON_ACTION = strings.REASON_ACTION, REASON_DISMISS = strings.REASON_DISMISS;
165
- var MDCSnackbarFoundation = /** @class */ (function (_super) {
166
- __extends(MDCSnackbarFoundation, _super);
167
- function MDCSnackbarFoundation(adapter) {
168
- var _this = _super.call(this, __assign(__assign({}, MDCSnackbarFoundation.defaultAdapter), adapter)) || this;
169
- _this.opened = false;
170
- _this.animationFrame = 0;
171
- _this.animationTimer = 0;
172
- _this.autoDismissTimer = 0;
173
- _this.autoDismissTimeoutMs = numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS;
174
- _this.closeOnEscape = true;
175
- return _this;
176
- }
177
- Object.defineProperty(MDCSnackbarFoundation, "cssClasses", {
178
- get: function () {
179
- return cssClasses;
180
- },
181
- enumerable: false,
182
- configurable: true
183
- });
184
- Object.defineProperty(MDCSnackbarFoundation, "strings", {
185
- get: function () {
186
- return strings;
187
- },
188
- enumerable: false,
189
- configurable: true
190
- });
191
- Object.defineProperty(MDCSnackbarFoundation, "numbers", {
192
- get: function () {
193
- return numbers;
194
- },
195
- enumerable: false,
196
- configurable: true
197
- });
198
- Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", {
199
- get: function () {
200
- return {
201
- addClass: function () { return undefined; },
202
- announce: function () { return undefined; },
203
- notifyClosed: function () { return undefined; },
204
- notifyClosing: function () { return undefined; },
205
- notifyOpened: function () { return undefined; },
206
- notifyOpening: function () { return undefined; },
207
- removeClass: function () { return undefined; },
208
- };
209
- },
210
- enumerable: false,
211
- configurable: true
212
- });
213
- MDCSnackbarFoundation.prototype.destroy = function () {
214
- this.clearAutoDismissTimer();
215
- cancelAnimationFrame(this.animationFrame);
216
- this.animationFrame = 0;
217
- clearTimeout(this.animationTimer);
218
- this.animationTimer = 0;
219
- this.adapter.removeClass(OPENING);
220
- this.adapter.removeClass(OPEN);
221
- this.adapter.removeClass(CLOSING);
222
- };
223
- MDCSnackbarFoundation.prototype.open = function () {
224
- var _this = this;
225
- this.clearAutoDismissTimer();
226
- this.opened = true;
227
- this.adapter.notifyOpening();
228
- this.adapter.removeClass(CLOSING);
229
- this.adapter.addClass(OPENING);
230
- this.adapter.announce();
231
- // Wait a frame once display is no longer "none", to establish basis for animation
232
- this.runNextAnimationFrame(function () {
233
- _this.adapter.addClass(OPEN);
234
- _this.animationTimer = setTimeout(function () {
235
- var timeoutMs = _this.getTimeoutMs();
236
- _this.handleAnimationTimerEnd();
237
- _this.adapter.notifyOpened();
238
- if (timeoutMs !== numbers.INDETERMINATE) {
239
- _this.autoDismissTimer = setTimeout(function () {
240
- _this.close(REASON_DISMISS);
241
- }, timeoutMs);
242
- }
243
- }, numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);
244
- });
245
- };
246
- /**
247
- * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
248
- * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
249
- * client-specific values may also be used if desired.
250
- */
251
- MDCSnackbarFoundation.prototype.close = function (reason) {
252
- var _this = this;
253
- if (reason === void 0) { reason = ''; }
254
- if (!this.opened) {
255
- // Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed
256
- return;
257
- }
258
- cancelAnimationFrame(this.animationFrame);
259
- this.animationFrame = 0;
260
- this.clearAutoDismissTimer();
261
- this.opened = false;
262
- this.adapter.notifyClosing(reason);
263
- this.adapter.addClass(cssClasses.CLOSING);
264
- this.adapter.removeClass(cssClasses.OPEN);
265
- this.adapter.removeClass(cssClasses.OPENING);
266
- clearTimeout(this.animationTimer);
267
- this.animationTimer = setTimeout(function () {
268
- _this.handleAnimationTimerEnd();
269
- _this.adapter.notifyClosed(reason);
270
- }, numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS);
271
- };
272
- MDCSnackbarFoundation.prototype.isOpen = function () {
273
- return this.opened;
274
- };
275
- MDCSnackbarFoundation.prototype.getTimeoutMs = function () {
276
- return this.autoDismissTimeoutMs;
277
- };
278
- MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) {
279
- // Use shorter variable names to make the code more readable
280
- var minValue = numbers.MIN_AUTO_DISMISS_TIMEOUT_MS;
281
- var maxValue = numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
282
- var indeterminateValue = numbers.INDETERMINATE;
283
- if (timeoutMs === numbers.INDETERMINATE || (timeoutMs <= maxValue && timeoutMs >= minValue)) {
284
- this.autoDismissTimeoutMs = timeoutMs;
285
- }
286
- else {
287
- throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
288
- }
289
- };
290
- MDCSnackbarFoundation.prototype.getCloseOnEscape = function () {
291
- return this.closeOnEscape;
292
- };
293
- MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) {
294
- this.closeOnEscape = closeOnEscape;
295
- };
296
- MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) {
297
- var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27;
298
- if (isEscapeKey && this.getCloseOnEscape()) {
299
- this.close(REASON_DISMISS);
300
- }
301
- };
302
- MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) {
303
- this.close(REASON_ACTION);
304
- };
305
- MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) {
306
- this.close(REASON_DISMISS);
307
- };
308
- MDCSnackbarFoundation.prototype.clearAutoDismissTimer = function () {
309
- clearTimeout(this.autoDismissTimer);
310
- this.autoDismissTimer = 0;
311
- };
312
- MDCSnackbarFoundation.prototype.handleAnimationTimerEnd = function () {
313
- this.animationTimer = 0;
314
- this.adapter.removeClass(cssClasses.OPENING);
315
- this.adapter.removeClass(cssClasses.CLOSING);
316
- };
317
- /**
318
- * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
319
- */
320
- MDCSnackbarFoundation.prototype.runNextAnimationFrame = function (callback) {
321
- var _this = this;
322
- cancelAnimationFrame(this.animationFrame);
323
- this.animationFrame = requestAnimationFrame(function () {
324
- _this.animationFrame = 0;
325
- clearTimeout(_this.animationTimer);
326
- _this.animationTimer = setTimeout(callback, 0);
327
- });
328
- };
329
- return MDCSnackbarFoundation;
330
- }(MDCFoundation));
331
-
332
- /**
333
- * @license
334
- * Copyright 2018 Google Inc.
335
- *
336
- * Permission is hereby granted, free of charge, to any person obtaining a copy
337
- * of this software and associated documentation files (the "Software"), to deal
338
- * in the Software without restriction, including without limitation the rights
339
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
340
- * copies of the Software, and to permit persons to whom the Software is
341
- * furnished to do so, subject to the following conditions:
342
- *
343
- * The above copyright notice and this permission notice shall be included in
344
- * all copies or substantial portions of the Software.
345
- *
346
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
347
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
348
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
349
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
350
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
351
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
352
- * THE SOFTWARE.
353
- */
354
- var SURFACE_SELECTOR = strings.SURFACE_SELECTOR, LABEL_SELECTOR = strings.LABEL_SELECTOR, ACTION_SELECTOR = strings.ACTION_SELECTOR, DISMISS_SELECTOR = strings.DISMISS_SELECTOR, OPENING_EVENT = strings.OPENING_EVENT, OPENED_EVENT = strings.OPENED_EVENT, CLOSING_EVENT = strings.CLOSING_EVENT, CLOSED_EVENT = strings.CLOSED_EVENT;
355
- var MDCSnackbar = /** @class */ (function (_super) {
356
- __extends(MDCSnackbar, _super);
357
- function MDCSnackbar() {
358
- return _super !== null && _super.apply(this, arguments) || this;
359
- }
360
- MDCSnackbar.attachTo = function (root) {
361
- return new MDCSnackbar(root);
362
- };
363
- MDCSnackbar.prototype.initialize = function (announcerFactory) {
364
- if (announcerFactory === void 0) { announcerFactory = function () { return announce; }; }
365
- this.announce = announcerFactory();
366
- };
367
- MDCSnackbar.prototype.initialSyncWithDOM = function () {
368
- var _this = this;
369
- this.surfaceEl = this.root.querySelector(SURFACE_SELECTOR);
370
- this.labelEl = this.root.querySelector(LABEL_SELECTOR);
371
- this.actionEl = this.root.querySelector(ACTION_SELECTOR);
372
- this.handleKeyDown = function (evt) {
373
- _this.foundation.handleKeyDown(evt);
374
- };
375
- this.handleSurfaceClick = function (evt) {
376
- var target = evt.target;
377
- if (_this.isActionButton(target)) {
378
- _this.foundation.handleActionButtonClick(evt);
379
- }
380
- else if (_this.isActionIcon(target)) {
381
- _this.foundation.handleActionIconClick(evt);
382
- }
383
- };
384
- this.registerKeyDownHandler(this.handleKeyDown);
385
- this.registerSurfaceClickHandler(this.handleSurfaceClick);
386
- };
387
- MDCSnackbar.prototype.destroy = function () {
388
- _super.prototype.destroy.call(this);
389
- this.deregisterKeyDownHandler(this.handleKeyDown);
390
- this.deregisterSurfaceClickHandler(this.handleSurfaceClick);
391
- };
392
- MDCSnackbar.prototype.open = function () {
393
- this.foundation.open();
394
- };
395
- /**
396
- * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
397
- * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
398
- * client-specific values may also be used if desired.
399
- */
400
- MDCSnackbar.prototype.close = function (reason) {
401
- if (reason === void 0) { reason = ''; }
402
- this.foundation.close(reason);
403
- };
404
- MDCSnackbar.prototype.getDefaultFoundation = function () {
405
- var _this = this;
406
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
407
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
408
- var adapter = {
409
- addClass: function (className) {
410
- _this.root.classList.add(className);
411
- },
412
- announce: function () {
413
- _this.announce(_this.labelEl);
414
- },
415
- notifyClosed: function (reason) { return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {}); },
416
- notifyClosing: function (reason) { return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {}); },
417
- notifyOpened: function () { return _this.emit(OPENED_EVENT, {}); },
418
- notifyOpening: function () { return _this.emit(OPENING_EVENT, {}); },
419
- removeClass: function (className) { return _this.root.classList.remove(className); },
420
- };
421
- return new MDCSnackbarFoundation(adapter);
422
- };
423
- Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", {
424
- get: function () {
425
- return this.foundation.getTimeoutMs();
426
- },
427
- set: function (timeoutMs) {
428
- this.foundation.setTimeoutMs(timeoutMs);
429
- },
430
- enumerable: false,
431
- configurable: true
432
- });
433
- Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", {
434
- get: function () {
435
- return this.foundation.getCloseOnEscape();
436
- },
437
- set: function (closeOnEscape) {
438
- this.foundation.setCloseOnEscape(closeOnEscape);
439
- },
440
- enumerable: false,
441
- configurable: true
442
- });
443
- Object.defineProperty(MDCSnackbar.prototype, "isOpen", {
444
- get: function () {
445
- return this.foundation.isOpen();
446
- },
447
- enumerable: false,
448
- configurable: true
449
- });
450
- Object.defineProperty(MDCSnackbar.prototype, "labelText", {
451
- get: function () {
452
- // This property only returns null if the node is a document, DOCTYPE,
453
- // or notation. On Element nodes, it always returns a string.
454
- return this.labelEl.textContent;
455
- },
456
- set: function (labelText) {
457
- this.labelEl.textContent = labelText;
458
- },
459
- enumerable: false,
460
- configurable: true
461
- });
462
- Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", {
463
- get: function () {
464
- return this.actionEl.textContent;
465
- },
466
- set: function (actionButtonText) {
467
- this.actionEl.textContent = actionButtonText;
468
- },
469
- enumerable: false,
470
- configurable: true
11
+ class SnackbarContainer {
12
+ constructor() {
13
+ this.snackbarElements = [];
14
+ }
15
+ /**
16
+ * Add a new element to the container
17
+ *
18
+ * @param snackbar - element to add
19
+ */
20
+ add(snackbar) {
21
+ const popover = this.getPopover(snackbar);
22
+ // Stencil does not seem to recognise the existance of showPopover
23
+ // @ts-ignore
24
+ popover === null || popover === void 0 ? void 0 : popover.showPopover();
25
+ this.snackbarElements = [snackbar, ...this.snackbarElements];
26
+ this.emitOffsets();
27
+ }
28
+ /**
29
+ * Remove an element from the container
30
+ *
31
+ * @param snackbar - element to remove
32
+ */
33
+ remove(snackbar) {
34
+ const popover = this.getPopover(snackbar);
35
+ // Stencil does not seem to recognise the existance of hidePopover
36
+ // @ts-ignore
37
+ popover === null || popover === void 0 ? void 0 : popover.hidePopover();
38
+ this.snackbarElements = this.snackbarElements.filter((item) => item !== snackbar);
39
+ this.emitOffsets();
40
+ }
41
+ emitOffsets() {
42
+ let offset = 0;
43
+ this.snackbarElements.forEach((snackbar) => {
44
+ snackbar.dispatchEvent(new CustomEvent('changeOffset', {
45
+ detail: offset,
46
+ }));
47
+ offset += this.getPopover(snackbar).getBoundingClientRect().height;
471
48
  });
472
- MDCSnackbar.prototype.registerKeyDownHandler = function (handler) {
473
- this.listen('keydown', handler);
474
- };
475
- MDCSnackbar.prototype.deregisterKeyDownHandler = function (handler) {
476
- this.unlisten('keydown', handler);
477
- };
478
- MDCSnackbar.prototype.registerSurfaceClickHandler = function (handler) {
479
- this.surfaceEl.addEventListener('click', handler);
480
- };
481
- MDCSnackbar.prototype.deregisterSurfaceClickHandler = function (handler) {
482
- this.surfaceEl.removeEventListener('click', handler);
483
- };
484
- MDCSnackbar.prototype.isActionButton = function (target) {
485
- return Boolean(closest(target, ACTION_SELECTOR));
486
- };
487
- MDCSnackbar.prototype.isActionIcon = function (target) {
488
- return Boolean(closest(target, DISMISS_SELECTOR));
489
- };
490
- return MDCSnackbar;
491
- }(MDCComponent));
49
+ }
50
+ getPopover(snackbar) {
51
+ return snackbar.shadowRoot.querySelector('[popover]');
52
+ }
53
+ }
492
54
 
493
- const snackbarCss = "*{box-sizing:border-box}.mdc-snackbar{top:var(--snackbar-top, auto);right:var(--snackbar-right, 0);bottom:var(--snackbar-bottom, 0);left:var(--snackbar-left, 0);display:none;position:fixed;z-index:8;padding:0.75rem;align-items:center;justify-content:center}.mdc-snackbar--opening,.mdc-snackbar--open,.mdc-snackbar--closing{display:flex}.mdc-snackbar--open .mdc-snackbar__label,.mdc-snackbar--open .mdc-snackbar__actions{visibility:visible}.mdc-snackbar--open .mdc-snackbar__surface{transform:scale(1);opacity:1}.mdc-snackbar__surface{transition:opacity 0.2s cubic-bezier(0, 0, 0.2, 1), transform 0.2s cubic-bezier(0, 0, 0.2, 1);padding:0.5rem;display:flex;align-items:center;justify-content:flex-start;gap:0.25rem;min-height:3.25rem;min-width:unset;max-width:42rem;transform:scale(0.8);opacity:0;border-radius:0.75rem;background-color:rgb(var(--contrast-1400));box-shadow:var(--shadow-depth-8), var(--shadow-depth-16)}.mdc-snackbar__label{visibility:hidden;color:rgb(var(--contrast-100));-webkit-font-smoothing:antialiased;font-size:0.8125rem;font-weight:400;padding:0 0.25rem;width:100%;flex-grow:1}.mdc-snackbar__actions{visibility:hidden;display:flex;flex-shrink:0;align-items:center;box-sizing:border-box;gap:0.5rem}.dismiss,.mdc-snackbar__actions{--lime-elevated-surface-background-color:rgb(\n var(--contrast-1300)\n )}.dismiss{--mdc-theme-on-surface:rgb(var(--contrast-100));--icon-background-color:var(--lime-elevated-surface-background-color);--fill-color:var(--mdc-theme-primary);--track-color:rgb(var(--contrast-800), 0.2);position:absolute;top:-0.9rem;left:-0.9rem;transform:scale(0.8);display:flex;align-items:center;justify-content:center}.dismiss limel-icon-button.mdc-snackbar__dismiss{transform:scale(0.8);margin:0;padding:0}.dismiss svg{position:absolute;transform:rotate(90deg);fill:transparent;stroke-dasharray:100;stroke-linecap:round}.mdc-snackbar--open .dismiss svg{animation:timeout var(--snackbar-timeout) linear forwards}@keyframes timeout{0%{stroke-width:4;stroke-dashoffset:0;opacity:1}100%{stroke-width:1;stroke-dashoffset:-100;opacity:0.7}}";
55
+ const snackbarCss = "*{box-sizing:border-box}aside{background:none;border:none;inset:unset;overflow:visible;padding:0.5rem 0.5rem 0 0.5rem;right:0;width:var(--limel-snackbar-width, 21rem);top:calc(var(--snackbar-distance-to-top-edge) + env(safe-area-inset-top, 0));transition:opacity var(--limel-snackbar-opacity-transition-speed, 0.2s) ease, top var(--limel-snackbar-top-transition-speed, 0.46s) cubic-bezier(1, 0.09, 0, 0.89), transform var(--limel-snackbar-top-transition-speed, 0.46s) ease;transform:translate3d(0, 0, 0);opacity:1}aside.is-closing{transform:translate3d(2rem, 0, 0);opacity:0;--limel-snackbar-top-transition-speed:0.2s;--limel-snackbar-opacity-transition-speed:0.2s}.surface{overflow:hidden;padding:0.5rem;display:flex;align-items:center;justify-content:flex-start;gap:0.25rem;min-height:3.25rem;border-radius:0.75rem;background-color:rgb(var(--contrast-1400));box-shadow:var(--shadow-depth-8), var(--shadow-depth-16)}.label{color:rgb(var(--contrast-100));-webkit-font-smoothing:antialiased;font-size:0.8125rem;font-weight:400;padding:0 0.25rem;width:100%;flex-grow:1}.actions{display:flex;flex-shrink:0;align-items:center;box-sizing:border-box;gap:0.5rem}.dismiss,.actions{--lime-elevated-surface-background-color:rgb(\n var(--contrast-1300)\n )}.dismiss{--mdc-theme-on-surface:rgb(var(--contrast-100));--icon-background-color:var(--lime-elevated-surface-background-color);--fill-color:var(--mdc-theme-primary);--track-color:rgb(var(--contrast-800), 0.2);transition:opacity 0.1s ease, transform 0.1s ease;position:absolute;top:-0.375rem;left:-0.375rem;transform:scale(0.7);display:flex;align-items:center;justify-content:center}.dismiss svg{position:absolute;transform:rotate(90deg);fill:transparent;stroke-dasharray:100;stroke-linecap:round}aside:popover-open .dismiss svg{animation:timeout var(--snackbar-timeout) linear forwards}.dismiss .is-closing{transform:scale(0.5);opacity:0}.dismiss-button{transform:scale(0.8);margin:0;padding:0}@keyframes timeout{0%{stroke-width:4;stroke-dashoffset:0;opacity:1}100%{stroke-width:1;stroke-dashoffset:-100;opacity:0.7}}";
494
56
 
57
+ const container = new SnackbarContainer();
58
+ const hideAnimationDuration = 300;
495
59
  const Snackbar = class {
496
60
  constructor(hostRef) {
497
61
  registerInstance(this, hostRef);
498
62
  this.action = createEvent(this, "action", 7);
499
63
  this.hide = createEvent(this, "hide", 7);
64
+ this.close = () => {
65
+ if (!this.open) {
66
+ return false;
67
+ }
68
+ this.closing = true;
69
+ if (this.timeoutId) {
70
+ clearTimeout(this.timeoutId);
71
+ this.timeoutId = undefined;
72
+ }
73
+ setTimeout(() => {
74
+ this.open = false;
75
+ container.remove(this.host);
76
+ this.hide.emit();
77
+ this.offset = 0;
78
+ }, hideAnimationDuration);
79
+ };
80
+ this.handleClickAction = () => {
81
+ this.action.emit();
82
+ };
500
83
  this.message = undefined;
501
84
  this.timeout = 5000;
502
85
  this.actionText = undefined;
503
86
  this.dismissible = true;
504
87
  this.multiline = undefined;
505
88
  this.language = 'en';
506
- this.handleMdcClosing = this.handleMdcClosing.bind(this);
507
- }
508
- connectedCallback() {
509
- this.initialize();
510
- }
511
- componentDidLoad() {
512
- this.initialize();
89
+ this.offset = 0;
90
+ this.open = false;
91
+ this.closing = true;
92
+ this.snackbarId = createRandomString();
513
93
  }
514
- initialize() {
515
- const element = this.host.shadowRoot.querySelector('.mdc-snackbar');
516
- if (!element) {
517
- return;
518
- }
519
- this.mdcSnackbar = new MDCSnackbar(element);
520
- this.mdcSnackbar.listen('MDCSnackbar:closing', this.handleMdcClosing);
521
- }
522
- disconnectedCallback() {
523
- this.mdcSnackbar.unlisten('MDCSnackbar:closing', this.handleMdcClosing);
524
- this.mdcSnackbar.destroy();
94
+ onChangeIndex(event) {
95
+ event.stopPropagation();
96
+ this.offset = event.detail;
525
97
  }
526
98
  /**
527
99
  * Show the snackbar
528
100
  */
529
101
  async show() {
102
+ if (this.open) {
103
+ return;
104
+ }
105
+ this.open = true;
106
+ this.closing = false;
107
+ container.add(this.host);
530
108
  if (this.timeout) {
531
- this.mdcSnackbar.timeoutMs = this.timeout;
109
+ this.timeoutId = window.setTimeout(this.close, Math.max(this.timeout - hideAnimationDuration, 0));
532
110
  }
533
- this.mdcSnackbar.labelText = this.message;
534
- this.mdcSnackbar.open();
535
111
  }
536
112
  render() {
537
- return (h("aside", { class: `
538
- mdc-snackbar
539
- ${this.multiline ? 'mdc-snackbar--stacked' : ''}
540
- `, style: {
113
+ return (h("aside", { popover: "manual", style: {
541
114
  '--snackbar-timeout': `${this.timeout}ms`,
542
- } }, h("div", { class: "mdc-snackbar__surface", role: "status", "aria-relevant": "additions" }, h("div", { class: "mdc-snackbar__label", "aria-atomic": "false" }), this.renderActions(this.actionText), this.renderDismissButton(this.dismissible))));
543
- }
544
- handleMdcClosing(event) {
545
- if (event.detail.reason === 'action') {
546
- this.action.emit();
547
- }
548
- else {
549
- this.hide.emit();
550
- }
115
+ '--snackbar-distance-to-top-edge': `${this.offset}px`,
116
+ }, class: {
117
+ open: this.open,
118
+ 'is-closing': this.closing,
119
+ }, id: this.snackbarId, role: this.open ? 'status' : undefined, "aria-relevant": this.open ? 'additions' : undefined }, h("div", { class: "surface", "aria-atomic": "false" }, h("div", { class: "label" }, this.message), this.renderActions(this.actionText), this.renderDismissButton(this.dismissible))));
551
120
  }
552
121
  renderActions(actionText) {
553
122
  if (!actionText) {
554
123
  return;
555
124
  }
556
- return (h("div", { class: "mdc-snackbar__actions", "aria-atomic": "true" }, this.renderActionButton(actionText)));
125
+ return (h("div", { class: "actions", "aria-atomic": "true" }, this.renderActionButton(actionText)));
557
126
  }
558
127
  renderActionButton(actionText) {
559
128
  if (!actionText) {
560
129
  return;
561
130
  }
562
- return (h("limel-button", { class: "mdc-button mdc-snackbar__action", label: actionText }));
131
+ return (h("limel-button", { label: actionText, onClick: this.handleClickAction }));
563
132
  }
564
133
  renderDismissButton(dismissible) {
565
134
  if (!dismissible) {
566
135
  return;
567
136
  }
568
137
  const label = translate.get('snackbar.dismiss', this.language);
569
- return (h("div", { class: "dismiss" }, this.renderTimeoutVisualization(), h("limel-icon-button", { class: "mdc-icon-button mdc-snackbar__dismiss", icon: "multiply", label: label })));
138
+ return (h("div", { class: "dismiss" }, this.renderTimeoutVisualization(), h("limel-icon-button", { class: "dismiss-button", icon: "multiply", label: label, onClick: this.close, "aria-controls": this.snackbarId })));
570
139
  }
571
140
  renderTimeoutVisualization() {
572
141
  return (h("svg", { width: "36", height: "36", viewBox: "0 0 36 36" }, h("circle", { r: "18", cx: "18", cy: "18", fill: "var(--track-color)" }), h("path", { class: "track", d: "M 18,18 m -16,0 a 16,16 0 1,0 32,0 a 16,16 0 1,0 -32,0", stroke: "var(--fill-color)" })));