@vonage/vivid 4.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/appearance-ui/index.cjs +1 -2
  2. package/appearance-ui/index.js +1 -2
  3. package/custom-elements.json +435 -41
  4. package/index.cjs +1 -0
  5. package/index.js +1 -1
  6. package/lib/button/button.d.ts +1 -0
  7. package/lib/dialog/dialog.d.ts +1 -0
  8. package/lib/empty-state/definition.d.ts +1 -0
  9. package/lib/empty-state/empty-state.d.ts +5 -0
  10. package/lib/enums.d.ts +4 -0
  11. package/lib/popup/popup.d.ts +5 -0
  12. package/lib/range-slider/range-slider.d.ts +2 -0
  13. package/lib/slider/slider.d.ts +5 -0
  14. package/lib/slider/slider.template.d.ts +2 -2
  15. package/lib/switch/switch.d.ts +1 -1
  16. package/package.json +1 -1
  17. package/shared/affix.cjs +1 -2
  18. package/shared/affix.js +1 -2
  19. package/shared/anchored.cjs +1 -2
  20. package/shared/anchored.js +1 -2
  21. package/shared/calendar-event.cjs +1 -2
  22. package/shared/calendar-event.js +1 -2
  23. package/shared/definition.cjs +2 -3
  24. package/shared/definition.js +2 -3
  25. package/shared/definition11.cjs +29 -13
  26. package/shared/definition11.js +29 -14
  27. package/shared/definition12.cjs +1 -1
  28. package/shared/definition12.js +1 -1
  29. package/shared/definition13.cjs +1 -2
  30. package/shared/definition13.js +1 -2
  31. package/shared/definition14.cjs +1 -2
  32. package/shared/definition14.js +1 -2
  33. package/shared/definition15.cjs +1 -2
  34. package/shared/definition15.js +1 -2
  35. package/shared/definition16.cjs +1 -2
  36. package/shared/definition16.js +1 -2
  37. package/shared/definition17.cjs +4 -8
  38. package/shared/definition17.js +4 -8
  39. package/shared/definition18.cjs +14 -22
  40. package/shared/definition18.js +14 -22
  41. package/shared/definition19.cjs +29 -50
  42. package/shared/definition19.js +29 -50
  43. package/shared/definition20.cjs +1 -2
  44. package/shared/definition20.js +1 -2
  45. package/shared/definition21.cjs +68 -32
  46. package/shared/definition21.js +68 -32
  47. package/shared/definition23.cjs +19 -5
  48. package/shared/definition23.js +20 -6
  49. package/shared/definition24.cjs +2 -3
  50. package/shared/definition24.js +2 -3
  51. package/shared/definition25.cjs +23 -48
  52. package/shared/definition25.js +23 -48
  53. package/shared/definition26.cjs +1 -2
  54. package/shared/definition26.js +1 -2
  55. package/shared/definition28.cjs +1 -2
  56. package/shared/definition28.js +1 -2
  57. package/shared/definition29.cjs +19 -39
  58. package/shared/definition29.js +19 -39
  59. package/shared/definition3.cjs +1 -2
  60. package/shared/definition3.js +1 -2
  61. package/shared/definition30.cjs +1 -1
  62. package/shared/definition30.js +1 -1
  63. package/shared/definition31.cjs +1 -2
  64. package/shared/definition31.js +1 -2
  65. package/shared/definition34.cjs +1 -2
  66. package/shared/definition34.js +1 -2
  67. package/shared/definition35.cjs +14 -26
  68. package/shared/definition35.js +14 -26
  69. package/shared/definition36.cjs +1 -2
  70. package/shared/definition36.js +1 -2
  71. package/shared/definition37.cjs +8 -16
  72. package/shared/definition37.js +8 -16
  73. package/shared/definition38.cjs +1 -2
  74. package/shared/definition38.js +1 -2
  75. package/shared/definition39.cjs +1 -2
  76. package/shared/definition39.js +1 -2
  77. package/shared/definition4.cjs +7 -13
  78. package/shared/definition4.js +7 -13
  79. package/shared/definition40.cjs +1 -2
  80. package/shared/definition40.js +1 -2
  81. package/shared/definition42.cjs +172 -106
  82. package/shared/definition42.js +172 -106
  83. package/shared/definition43.cjs +7 -6
  84. package/shared/definition43.js +5 -4
  85. package/shared/definition44.cjs +4 -8
  86. package/shared/definition44.js +4 -8
  87. package/shared/definition45.cjs +1 -2
  88. package/shared/definition45.js +1 -2
  89. package/shared/definition46.cjs +96 -12
  90. package/shared/definition46.js +97 -13
  91. package/shared/definition47.cjs +1 -2
  92. package/shared/definition47.js +1 -2
  93. package/shared/definition48.cjs +2 -3
  94. package/shared/definition48.js +2 -3
  95. package/shared/definition5.cjs +1 -2
  96. package/shared/definition5.js +1 -2
  97. package/shared/definition50.cjs +1 -2
  98. package/shared/definition50.js +1 -2
  99. package/shared/definition51.cjs +5 -10
  100. package/shared/definition51.js +5 -10
  101. package/shared/definition52.cjs +1 -2
  102. package/shared/definition52.js +1 -2
  103. package/shared/definition53.cjs +1 -2
  104. package/shared/definition53.js +1 -2
  105. package/shared/definition54.cjs +9 -21
  106. package/shared/definition54.js +9 -21
  107. package/shared/definition55.cjs +24 -43
  108. package/shared/definition55.js +24 -43
  109. package/shared/definition56.cjs +24 -39
  110. package/shared/definition56.js +24 -39
  111. package/shared/definition57.cjs +22 -45
  112. package/shared/definition57.js +22 -45
  113. package/shared/definition58.cjs +18 -37
  114. package/shared/definition58.js +18 -37
  115. package/shared/definition59.cjs +1 -2
  116. package/shared/definition59.js +1 -2
  117. package/shared/definition6.cjs +1 -2
  118. package/shared/definition6.js +1 -2
  119. package/shared/definition62.cjs +1 -2
  120. package/shared/definition62.js +1 -2
  121. package/shared/definition63.cjs +156 -4
  122. package/shared/definition63.js +157 -6
  123. package/shared/definition7.cjs +1 -2
  124. package/shared/definition7.js +1 -2
  125. package/shared/definition8.cjs +1 -2
  126. package/shared/definition8.js +1 -2
  127. package/shared/definition9.cjs +1 -2
  128. package/shared/definition9.js +1 -2
  129. package/shared/enums.cjs +6 -0
  130. package/shared/enums.js +6 -1
  131. package/shared/icon.cjs +2 -3
  132. package/shared/icon.js +2 -3
  133. package/shared/index2.cjs +3 -6
  134. package/shared/index2.js +3 -6
  135. package/shared/listbox.cjs +1 -2
  136. package/shared/listbox.js +1 -2
  137. package/shared/patterns/anchored.d.ts +4 -4
  138. package/shared/patterns/chevron.d.ts +2 -0
  139. package/shared/presentationDate.cjs +2 -3
  140. package/shared/presentationDate.js +2 -3
  141. package/shared/radio.cjs +1 -2
  142. package/shared/radio.js +1 -2
  143. package/shared/slider.template.cjs +27 -4
  144. package/shared/slider.template.js +27 -4
  145. package/shared/text-anchor.cjs +1 -2
  146. package/shared/text-anchor.js +1 -2
  147. package/shared/video-player.cjs +4 -8
  148. package/shared/video-player.js +4 -8
  149. package/styles/core/all.css +1 -1
  150. package/styles/core/theme.css +1 -1
  151. package/styles/core/typography.css +1 -1
  152. package/styles/tokens/theme-dark.css +4 -4
  153. package/styles/tokens/theme-light.css +4 -4
  154. package/styles/tokens/vivid-2-compat.css +1 -1
  155. package/vivid.api.json +3228 -1108
@@ -29,38 +29,23 @@ const parsePresentationDateRange = (presentationDateRange, locale) => {
29
29
 
30
30
  var __defProp = Object.defineProperty;
31
31
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
32
+ var __typeError = (msg) => {
33
+ throw TypeError(msg);
34
+ };
32
35
  var __decorateClass = (decorators, target, key, kind) => {
33
36
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
34
37
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
35
38
  if (decorator = decorators[i])
36
39
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
37
- if (kind && result)
38
- __defProp(target, key, result);
40
+ if (kind && result) __defProp(target, key, result);
39
41
  return result;
40
42
  };
41
- var __accessCheck = (obj, member, msg) => {
42
- if (!member.has(obj))
43
- throw TypeError("Cannot " + msg);
44
- };
45
- var __privateGet = (obj, member, getter) => {
46
- __accessCheck(obj, member, "read from private field");
47
- return member.get(obj);
48
- };
49
- var __privateAdd = (obj, member, value) => {
50
- if (member.has(obj))
51
- throw TypeError("Cannot add the same private member more than once");
52
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
53
- };
54
- var __privateSet = (obj, member, value, setter) => {
55
- __accessCheck(obj, member, "write to private field");
56
- member.set(obj, value);
57
- return value;
58
- };
59
- var __privateMethod = (obj, member, method) => {
60
- __accessCheck(obj, member, "access private method");
61
- return method;
62
- };
63
- var _isInternalValueUpdate, _updateValues, updateValues_fn, _handleChangedValues, handleChangedValues_fn, _updateFormValue, updateFormValue_fn, _getVisibleRange, getVisibleRange_fn;
43
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
44
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), member.get(obj));
45
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
46
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
47
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
48
+ var _isInternalValueUpdate, _DateRangePicker_instances, updateValues_fn, handleChangedValues_fn, updateFormValue_fn, getVisibleRange_fn;
64
49
  const isFormAssociatedTryingToSetFormValue = (value) => typeof value === "string";
65
50
  function isDefined(value) {
66
51
  return !!value;
@@ -68,10 +53,7 @@ function isDefined(value) {
68
53
  let DateRangePicker = class extends DatePickerBase {
69
54
  constructor() {
70
55
  super(...arguments);
71
- __privateAdd(this, _updateValues);
72
- __privateAdd(this, _handleChangedValues);
73
- __privateAdd(this, _updateFormValue);
74
- __privateAdd(this, _getVisibleRange);
56
+ __privateAdd(this, _DateRangePicker_instances);
75
57
  this.initialStart = "";
76
58
  this.initialEnd = "";
77
59
  __privateAdd(this, _isInternalValueUpdate, false);
@@ -122,7 +104,7 @@ let DateRangePicker = class extends DatePickerBase {
122
104
  this.currentStart = this.start;
123
105
  this.dirtyValue = true;
124
106
  if (!__privateGet(this, _isInternalValueUpdate)) {
125
- __privateMethod(this, _handleChangedValues, handleChangedValues_fn).call(this);
107
+ __privateMethod(this, _DateRangePicker_instances, handleChangedValues_fn).call(this);
126
108
  }
127
109
  }
128
110
  /**
@@ -136,7 +118,7 @@ let DateRangePicker = class extends DatePickerBase {
136
118
  this.currentEnd = this.end;
137
119
  this.dirtyValue = true;
138
120
  if (!__privateGet(this, _isInternalValueUpdate)) {
139
- __privateMethod(this, _handleChangedValues, handleChangedValues_fn).call(this);
121
+ __privateMethod(this, _DateRangePicker_instances, handleChangedValues_fn).call(this);
140
122
  }
141
123
  }
142
124
  /**
@@ -156,7 +138,7 @@ let DateRangePicker = class extends DatePickerBase {
156
138
  */
157
139
  nameChanged(previous, next) {
158
140
  super.nameChanged(previous, next);
159
- __privateMethod(this, _updateFormValue, updateFormValue_fn).call(this);
141
+ __privateMethod(this, _DateRangePicker_instances, updateFormValue_fn).call(this);
160
142
  }
161
143
  connectedCallback() {
162
144
  super.connectedCallback();
@@ -177,7 +159,7 @@ let DateRangePicker = class extends DatePickerBase {
177
159
  * @internal
178
160
  */
179
161
  _isDateInSelectedRange(date) {
180
- const { start, end } = __privateMethod(this, _getVisibleRange, getVisibleRange_fn).call(this);
162
+ const { start, end } = __privateMethod(this, _DateRangePicker_instances, getVisibleRange_fn).call(this);
181
163
  if (start && end) {
182
164
  return compareDateStr(date, start) >= 0 && compareDateStr(date, end) <= 0;
183
165
  }
@@ -187,13 +169,13 @@ let DateRangePicker = class extends DatePickerBase {
187
169
  * @internal
188
170
  */
189
171
  _isDateRangeStart(date) {
190
- return date === __privateMethod(this, _getVisibleRange, getVisibleRange_fn).call(this).start;
172
+ return date === __privateMethod(this, _DateRangePicker_instances, getVisibleRange_fn).call(this).start;
191
173
  }
192
174
  /**
193
175
  * @internal
194
176
  */
195
177
  _isDateRangeEnd(date) {
196
- return date === __privateMethod(this, _getVisibleRange, getVisibleRange_fn).call(this).end;
178
+ return date === __privateMethod(this, _DateRangePicker_instances, getVisibleRange_fn).call(this).end;
197
179
  }
198
180
  /**
199
181
  * @internal
@@ -213,15 +195,15 @@ let DateRangePicker = class extends DatePickerBase {
213
195
  */
214
196
  _onDateClick(date) {
215
197
  if (this.start && this.end) {
216
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start: date, end: "" });
198
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start: date, end: "" });
217
199
  } else if (this.start) {
218
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { end: date });
200
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { end: date });
219
201
  this._closePopup();
220
202
  } else if (this.end) {
221
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start: date });
203
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start: date });
222
204
  this._closePopup();
223
205
  } else {
224
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start: date });
206
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start: date });
225
207
  }
226
208
  }
227
209
  /**
@@ -238,7 +220,7 @@ let DateRangePicker = class extends DatePickerBase {
238
220
  */
239
221
  _onTextFieldChange() {
240
222
  if (this._presentationValue === "") {
241
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start: "", end: "" });
223
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start: "", end: "" });
242
224
  return;
243
225
  }
244
226
  try {
@@ -246,7 +228,7 @@ let DateRangePicker = class extends DatePickerBase {
246
228
  this._presentationValue,
247
229
  this.locale.datePicker
248
230
  );
249
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start, end });
231
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start, end });
250
232
  } catch (_) {
251
233
  return;
252
234
  }
@@ -303,14 +285,14 @@ let DateRangePicker = class extends DatePickerBase {
303
285
  * @internal
304
286
  */
305
287
  _onClearClick() {
306
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start: "", end: "" });
288
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start: "", end: "" });
307
289
  super._onClearClick();
308
290
  }
309
291
  /**
310
292
  * @internal
311
293
  */
312
294
  formResetCallback() {
313
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start: this.initialStart, end: this.initialEnd });
295
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start: this.initialStart, end: this.initialEnd });
314
296
  super.formResetCallback();
315
297
  }
316
298
  get _calendarButtonLabel() {
@@ -330,7 +312,7 @@ let DateRangePicker = class extends DatePickerBase {
330
312
  }
331
313
  };
332
314
  _isInternalValueUpdate = new WeakMap();
333
- _updateValues = new WeakSet();
315
+ _DateRangePicker_instances = new WeakSet();
334
316
  updateValues_fn = function(range) {
335
317
  __privateSet(this, _isInternalValueUpdate, true);
336
318
  if (range.start !== void 0) {
@@ -344,13 +326,12 @@ updateValues_fn = function(range) {
344
326
  __privateSet(this, _isInternalValueUpdate, false);
345
327
  this.$emit("input");
346
328
  this.$emit("change");
347
- __privateMethod(this, _handleChangedValues, handleChangedValues_fn).call(this);
329
+ __privateMethod(this, _DateRangePicker_instances, handleChangedValues_fn).call(this);
348
330
  };
349
- _handleChangedValues = new WeakSet();
350
331
  handleChangedValues_fn = function() {
351
332
  if (this.start && this.end) {
352
333
  if (compareDateStr(this.start, this.end) > 0) {
353
- __privateMethod(this, _updateValues, updateValues_fn).call(this, { start: this.end, end: this.start });
334
+ __privateMethod(this, _DateRangePicker_instances, updateValues_fn).call(this, { start: this.end, end: this.start });
354
335
  return;
355
336
  }
356
337
  this._presentationValue = formatPresentationDateRange(
@@ -369,9 +350,8 @@ handleChangedValues_fn = function() {
369
350
  if (dateToEnsureVisibilityOf) {
370
351
  this._adjustSelectedMonthToEnsureVisibilityOf(dateToEnsureVisibilityOf);
371
352
  }
372
- __privateMethod(this, _updateFormValue, updateFormValue_fn).call(this);
353
+ __privateMethod(this, _DateRangePicker_instances, updateFormValue_fn).call(this);
373
354
  };
374
- _updateFormValue = new WeakSet();
375
355
  updateFormValue_fn = function() {
376
356
  if (!this.name || !this.start || !this.end) {
377
357
  this.setFormValue(null);
@@ -382,7 +362,6 @@ updateFormValue_fn = function() {
382
362
  this.setFormValue(formData);
383
363
  }
384
364
  };
385
- _getVisibleRange = new WeakSet();
386
365
  getVisibleRange_fn = function() {
387
366
  const candidates = [this.start, this.end].filter(isDefined);
388
367
  const isPartialRange = candidates.length === 1;
@@ -21,8 +21,7 @@ var __decorateClass = (decorators, target, key, kind) => {
21
21
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
22
  if (decorator = decorators[i])
23
23
  result = (decorator(target, key, result) ) || result;
24
- if (result)
25
- __defProp(target, key, result);
24
+ if (result) __defProp(target, key, result);
26
25
  return result;
27
26
  };
28
27
  class DialPad extends index.FoundationElement {
@@ -19,8 +19,7 @@ var __decorateClass = (decorators, target, key, kind) => {
19
19
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
20
20
  if (decorator = decorators[i])
21
21
  result = (decorator(target, key, result) ) || result;
22
- if (result)
23
- __defProp(target, key, result);
22
+ if (result) __defProp(target, key, result);
24
23
  return result;
25
24
  };
26
25
  class DialPad extends FoundationElement {
@@ -23,8 +23,7 @@ var __decorateClass = (decorators, target, key, kind) => {
23
23
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
24
24
  if (decorator = decorators[i])
25
25
  result = (decorator(target, key, result) ) || result;
26
- if (result)
27
- __defProp(target, key, result);
26
+ if (result) __defProp(target, key, result);
28
27
  return result;
29
28
  };
30
29
  const isDialogSupported = Boolean(
@@ -45,7 +44,8 @@ class Dialog extends index.FoundationElement {
45
44
  this.ariaLabel = null;
46
45
  this.dismissButtonAriaLabel = null;
47
46
  this.noLightDismiss = false;
48
- this.#modal = false;
47
+ this.modal = false;
48
+ this._openedAsModal = false;
49
49
  this.#handleScrimClick = (event) => {
50
50
  if (event.target !== this.#dialog || this.noLightDismiss) {
51
51
  return;
@@ -61,19 +61,26 @@ class Dialog extends index.FoundationElement {
61
61
  this.open = false;
62
62
  };
63
63
  }
64
- #modal;
64
+ /**
65
+ * @internal
66
+ */
67
+ modalChanged(_, newValue) {
68
+ if (this.open) {
69
+ this._openedAsModal = newValue;
70
+ if (this.$fastController.isConnected) {
71
+ this.#closeDialog();
72
+ this.#showDialog();
73
+ }
74
+ }
75
+ }
65
76
  set returnValue(value) {
66
- this.#dialog.returnValue = value;
77
+ if (this.#dialog) {
78
+ this.#dialog.returnValue = value;
79
+ }
67
80
  }
68
81
  get returnValue() {
69
82
  return this.#dialog?.returnValue;
70
83
  }
71
- /**
72
- * @internal
73
- */
74
- get modal() {
75
- return this.#modal;
76
- }
77
84
  #dialogElement;
78
85
  get #dialog() {
79
86
  if (!this.#dialogElement) {
@@ -81,7 +88,6 @@ class Dialog extends index.FoundationElement {
81
88
  "dialog"
82
89
  );
83
90
  if (this.#dialogElement) {
84
- this.#dialogElement.open = this.open;
85
91
  if (dialogPolyfill) {
86
92
  dialogPolyfill.registerDialog(this.#dialogElement);
87
93
  }
@@ -97,44 +103,66 @@ class Dialog extends index.FoundationElement {
97
103
  return;
98
104
  }
99
105
  if (!newValue) {
100
- this.close();
106
+ this._openedAsModal = false;
107
+ if (this.$fastController.isConnected) {
108
+ this.#closeDialog();
109
+ }
110
+ this.$emit("close", this.returnValue, { bubbles: false });
101
111
  } else {
102
- if (this.#dialog) {
103
- this.#dialog.open = true;
112
+ this._openedAsModal = this._openedAsModal || this.modal;
113
+ if (this.$fastController.isConnected) {
114
+ this.#showDialog();
104
115
  }
116
+ this.$emit("open", void 0, { bubbles: false });
105
117
  }
106
118
  }
107
119
  #handleScrimClick;
108
120
  #handleInternalFormSubmit;
109
121
  close() {
110
- if (this.#dialog.open) {
111
- this.#dialog.close();
112
- this.$emit("close", this.returnValue, { bubbles: false });
113
- }
114
122
  this.open = false;
115
- this.#handleModal(false);
116
- }
117
- #handleModal(show) {
118
- this.#modal = show;
119
- this.#dialog.toggleAttribute("aria-modal", show);
120
- this.#dialog.classList.toggle("modal", show);
121
123
  }
122
124
  show() {
123
- this.#dialog.show();
125
+ if (this._openedAsModal && !this.modal) {
126
+ throw new DOMException(
127
+ "Failed to execute 'show' on 'Dialog': The dialog is already open as a modal dialog, and therefore cannot be opened as a non-modal dialog.",
128
+ "InvalidStateError"
129
+ );
130
+ }
124
131
  this.open = true;
125
132
  }
126
133
  showModal() {
127
- this.#handleModal(true);
128
- this.#dialog.showModal();
134
+ if (this.open && !this._openedAsModal) {
135
+ throw new DOMException(
136
+ "Failed to execute 'showModal' on 'Dialog': The dialog is already open as a non-modal dialog, and therefore cannot be opened as a modal dialog.",
137
+ "InvalidStateError"
138
+ );
139
+ }
140
+ this._openedAsModal = true;
129
141
  this.open = true;
130
142
  }
143
+ #closeDialog() {
144
+ this.#dialog.close();
145
+ }
146
+ #showDialog() {
147
+ if (this._openedAsModal) {
148
+ this.#dialog.showModal();
149
+ } else {
150
+ this.#dialog.show();
151
+ }
152
+ }
131
153
  connectedCallback() {
132
154
  super.connectedCallback();
155
+ if (this.open) {
156
+ this.#showDialog();
157
+ }
133
158
  this.#dialog.addEventListener("mousedown", this.#handleScrimClick);
134
159
  this.#dialog.addEventListener("submit", this.#handleInternalFormSubmit);
135
160
  }
136
161
  disconnectedCallback() {
137
162
  super.disconnectedCallback();
163
+ if (this.open) {
164
+ this.#closeDialog();
165
+ }
138
166
  this.#dialog.removeEventListener("mousedown", this.#handleScrimClick);
139
167
  this.#dialog.removeEventListener("submit", this.#handleInternalFormSubmit);
140
168
  }
@@ -166,6 +194,12 @@ __decorateClass([
166
194
  __decorateClass([
167
195
  index.attr({ attribute: "no-light-dismiss", mode: "boolean" })
168
196
  ], Dialog.prototype, "noLightDismiss");
197
+ __decorateClass([
198
+ index.attr({ mode: "boolean" })
199
+ ], Dialog.prototype, "modal");
200
+ __decorateClass([
201
+ index.observable
202
+ ], Dialog.prototype, "_openedAsModal");
169
203
  __decorateClass([
170
204
  index.observable
171
205
  ], Dialog.prototype, "bodySlottedContent");
@@ -181,7 +215,8 @@ const getClasses = ({
181
215
  iconPlacement,
182
216
  bodySlottedContent,
183
217
  footerSlottedContent,
184
- actionItemsSlottedContent
218
+ actionItemsSlottedContent,
219
+ _openedAsModal
185
220
  }) => classNames.classNames(
186
221
  "base",
187
222
  [`icon-placement-${iconPlacement}`, Boolean(iconPlacement)],
@@ -189,7 +224,8 @@ const getClasses = ({
189
224
  [
190
225
  "hide-footer",
191
226
  !(footerSlottedContent?.length || actionItemsSlottedContent?.length)
192
- ]
227
+ ],
228
+ ["modal", _openedAsModal]
193
229
  );
194
230
  function icon(iconTag) {
195
231
  return index.html`
@@ -213,7 +249,7 @@ function renderDismissButton(buttonTag) {
213
249
  ></${buttonTag}>`;
214
250
  }
215
251
  function handleEscapeKey(dialog, event) {
216
- if (event.key === "Escape" && dialog.modal) {
252
+ if (event.key === "Escape" && dialog._openedAsModal) {
217
253
  dialog.open = false;
218
254
  }
219
255
  return true;
@@ -227,8 +263,8 @@ const DialogTemplate = (context) => {
227
263
  <dialog class="${getClasses}"
228
264
  @keydown="${(x, c) => handleEscapeKey(x, c.event)}"
229
265
  @cancel="${(_, c) => c.event.preventDefault()}"
230
- returnValue="${(x) => x.returnValue}"
231
266
  aria-label="${(x) => x.ariaLabel}"
267
+ ?aria-modal="${(x) => x._openedAsModal}"
232
268
  >
233
269
  <slot name="main">
234
270
  <div class="main-wrapper">
@@ -21,8 +21,7 @@ var __decorateClass = (decorators, target, key, kind) => {
21
21
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
22
  if (decorator = decorators[i])
23
23
  result = (decorator(target, key, result) ) || result;
24
- if (result)
25
- __defProp(target, key, result);
24
+ if (result) __defProp(target, key, result);
26
25
  return result;
27
26
  };
28
27
  const isDialogSupported = Boolean(
@@ -43,7 +42,8 @@ class Dialog extends FoundationElement {
43
42
  this.ariaLabel = null;
44
43
  this.dismissButtonAriaLabel = null;
45
44
  this.noLightDismiss = false;
46
- this.#modal = false;
45
+ this.modal = false;
46
+ this._openedAsModal = false;
47
47
  this.#handleScrimClick = (event) => {
48
48
  if (event.target !== this.#dialog || this.noLightDismiss) {
49
49
  return;
@@ -59,19 +59,26 @@ class Dialog extends FoundationElement {
59
59
  this.open = false;
60
60
  };
61
61
  }
62
- #modal;
62
+ /**
63
+ * @internal
64
+ */
65
+ modalChanged(_, newValue) {
66
+ if (this.open) {
67
+ this._openedAsModal = newValue;
68
+ if (this.$fastController.isConnected) {
69
+ this.#closeDialog();
70
+ this.#showDialog();
71
+ }
72
+ }
73
+ }
63
74
  set returnValue(value) {
64
- this.#dialog.returnValue = value;
75
+ if (this.#dialog) {
76
+ this.#dialog.returnValue = value;
77
+ }
65
78
  }
66
79
  get returnValue() {
67
80
  return this.#dialog?.returnValue;
68
81
  }
69
- /**
70
- * @internal
71
- */
72
- get modal() {
73
- return this.#modal;
74
- }
75
82
  #dialogElement;
76
83
  get #dialog() {
77
84
  if (!this.#dialogElement) {
@@ -79,7 +86,6 @@ class Dialog extends FoundationElement {
79
86
  "dialog"
80
87
  );
81
88
  if (this.#dialogElement) {
82
- this.#dialogElement.open = this.open;
83
89
  if (dialogPolyfill) {
84
90
  dialogPolyfill.registerDialog(this.#dialogElement);
85
91
  }
@@ -95,44 +101,66 @@ class Dialog extends FoundationElement {
95
101
  return;
96
102
  }
97
103
  if (!newValue) {
98
- this.close();
104
+ this._openedAsModal = false;
105
+ if (this.$fastController.isConnected) {
106
+ this.#closeDialog();
107
+ }
108
+ this.$emit("close", this.returnValue, { bubbles: false });
99
109
  } else {
100
- if (this.#dialog) {
101
- this.#dialog.open = true;
110
+ this._openedAsModal = this._openedAsModal || this.modal;
111
+ if (this.$fastController.isConnected) {
112
+ this.#showDialog();
102
113
  }
114
+ this.$emit("open", void 0, { bubbles: false });
103
115
  }
104
116
  }
105
117
  #handleScrimClick;
106
118
  #handleInternalFormSubmit;
107
119
  close() {
108
- if (this.#dialog.open) {
109
- this.#dialog.close();
110
- this.$emit("close", this.returnValue, { bubbles: false });
111
- }
112
120
  this.open = false;
113
- this.#handleModal(false);
114
- }
115
- #handleModal(show) {
116
- this.#modal = show;
117
- this.#dialog.toggleAttribute("aria-modal", show);
118
- this.#dialog.classList.toggle("modal", show);
119
121
  }
120
122
  show() {
121
- this.#dialog.show();
123
+ if (this._openedAsModal && !this.modal) {
124
+ throw new DOMException(
125
+ "Failed to execute 'show' on 'Dialog': The dialog is already open as a modal dialog, and therefore cannot be opened as a non-modal dialog.",
126
+ "InvalidStateError"
127
+ );
128
+ }
122
129
  this.open = true;
123
130
  }
124
131
  showModal() {
125
- this.#handleModal(true);
126
- this.#dialog.showModal();
132
+ if (this.open && !this._openedAsModal) {
133
+ throw new DOMException(
134
+ "Failed to execute 'showModal' on 'Dialog': The dialog is already open as a non-modal dialog, and therefore cannot be opened as a modal dialog.",
135
+ "InvalidStateError"
136
+ );
137
+ }
138
+ this._openedAsModal = true;
127
139
  this.open = true;
128
140
  }
141
+ #closeDialog() {
142
+ this.#dialog.close();
143
+ }
144
+ #showDialog() {
145
+ if (this._openedAsModal) {
146
+ this.#dialog.showModal();
147
+ } else {
148
+ this.#dialog.show();
149
+ }
150
+ }
129
151
  connectedCallback() {
130
152
  super.connectedCallback();
153
+ if (this.open) {
154
+ this.#showDialog();
155
+ }
131
156
  this.#dialog.addEventListener("mousedown", this.#handleScrimClick);
132
157
  this.#dialog.addEventListener("submit", this.#handleInternalFormSubmit);
133
158
  }
134
159
  disconnectedCallback() {
135
160
  super.disconnectedCallback();
161
+ if (this.open) {
162
+ this.#closeDialog();
163
+ }
136
164
  this.#dialog.removeEventListener("mousedown", this.#handleScrimClick);
137
165
  this.#dialog.removeEventListener("submit", this.#handleInternalFormSubmit);
138
166
  }
@@ -164,6 +192,12 @@ __decorateClass([
164
192
  __decorateClass([
165
193
  attr({ attribute: "no-light-dismiss", mode: "boolean" })
166
194
  ], Dialog.prototype, "noLightDismiss");
195
+ __decorateClass([
196
+ attr({ mode: "boolean" })
197
+ ], Dialog.prototype, "modal");
198
+ __decorateClass([
199
+ observable
200
+ ], Dialog.prototype, "_openedAsModal");
167
201
  __decorateClass([
168
202
  observable
169
203
  ], Dialog.prototype, "bodySlottedContent");
@@ -179,7 +213,8 @@ const getClasses = ({
179
213
  iconPlacement,
180
214
  bodySlottedContent,
181
215
  footerSlottedContent,
182
- actionItemsSlottedContent
216
+ actionItemsSlottedContent,
217
+ _openedAsModal
183
218
  }) => classNames(
184
219
  "base",
185
220
  [`icon-placement-${iconPlacement}`, Boolean(iconPlacement)],
@@ -187,7 +222,8 @@ const getClasses = ({
187
222
  [
188
223
  "hide-footer",
189
224
  !(footerSlottedContent?.length || actionItemsSlottedContent?.length)
190
- ]
225
+ ],
226
+ ["modal", _openedAsModal]
191
227
  );
192
228
  function icon(iconTag) {
193
229
  return html`
@@ -211,7 +247,7 @@ function renderDismissButton(buttonTag) {
211
247
  ></${buttonTag}>`;
212
248
  }
213
249
  function handleEscapeKey(dialog, event) {
214
- if (event.key === "Escape" && dialog.modal) {
250
+ if (event.key === "Escape" && dialog._openedAsModal) {
215
251
  dialog.open = false;
216
252
  }
217
253
  return true;
@@ -225,8 +261,8 @@ const DialogTemplate = (context) => {
225
261
  <dialog class="${getClasses}"
226
262
  @keydown="${(x, c) => handleEscapeKey(x, c.event)}"
227
263
  @cancel="${(_, c) => c.event.preventDefault()}"
228
- returnValue="${(x) => x.returnValue}"
229
264
  aria-label="${(x) => x.ariaLabel}"
265
+ ?aria-modal="${(x) => x._openedAsModal}"
230
266
  >
231
267
  <slot name="main">
232
268
  <div class="main-wrapper">
@@ -7,7 +7,7 @@ const when = require('./when.cjs');
7
7
  const slotted = require('./slotted.cjs');
8
8
  const classNames = require('./class-names.cjs');
9
9
 
10
- const styles = ":host{display:block}.base{display:flex;box-sizing:border-box;flex-direction:column;align-items:center;justify-content:center;block-size:100%;gap:24px}.icon-container{display:flex;align-items:center;justify-content:center;border-radius:50%;background-color:var(--vvd-color-neutral-100);block-size:120px;inline-size:120px}.content{display:flex;flex-direction:column;font:var(--vvd-typography-base);gap:8px;text-align:center}header{font:var(--vvd-typography-base-bold)}.actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px}.base.no-actions .actions{display:none}";
10
+ const styles = ":host{display:block}.base{--_empty-state-icon-container: 120px;--_empty-state-icon-background: var(--_connotation-color-faint);--_empty-state-icon-font-size: 52px;display:flex;box-sizing:border-box;flex-direction:column;align-items:center;justify-content:center;block-size:100%;gap:24px}.base.connotation-cta{--_connotation-color-firm-all: var(--vvd-empty-state-cta-firm-all, var(--vvd-color-cta-600));--_connotation-color-dim: var(--vvd-empty-state-cta-dim, var(--vvd-color-cta-200));--_connotation-color-faint: var(--vvd-empty-state-cta-faint, var(--vvd-color-cta-50))}.base.connotation-success{--_connotation-color-firm-all: var(--vvd-empty-state-success-firm-all, var(--vvd-color-success-600));--_connotation-color-dim: var(--vvd-empty-state-success-dim, var(--vvd-color-success-200));--_connotation-color-faint: var(--vvd-empty-state-success-faint, var(--vvd-color-success-50))}.base.connotation-alert{--_connotation-color-firm-all: var(--vvd-empty-state-alert-firm-all, var(--vvd-color-alert-600));--_connotation-color-dim: var(--vvd-empty-state-alert-dim, var(--vvd-color-alert-200));--_connotation-color-faint: var(--vvd-empty-state-alert-faint, var(--vvd-color-alert-50))}.base.connotation-warning{--_connotation-color-firm-all: var(--vvd-empty-state-warning-firm-all, var(--vvd-color-warning-600));--_connotation-color-dim: var(--vvd-empty-state-warning-dim, var(--vvd-color-warning-200));--_connotation-color-faint: var(--vvd-empty-state-warning-faint, var(--vvd-color-warning-50))}.base.connotation-information{--_connotation-color-firm-all: var(--vvd-empty-state-information-firm-all, var(--vvd-color-information-600));--_connotation-color-dim: var(--vvd-empty-state-information-dim, var(--vvd-color-information-200));--_connotation-color-faint: var(--vvd-empty-state-information-faint, var(--vvd-color-information-50))}.base.connotation-announcement{--_connotation-color-firm-all: var(--vvd-empty-state-announcement-firm-all, var(--vvd-color-announcement-600));--_connotation-color-dim: var(--vvd-empty-state-announcement-dim, var(--vvd-color-announcement-200));--_connotation-color-faint: var(--vvd-empty-state-announcement-faint, var(--vvd-color-announcement-50))}.base:not(.connotation-cta,.connotation-success,.connotation-alert,.connotation-warning,.connotation-information,.connotation-announcement){--_connotation-color-firm-all: var(--vvd-empty-state-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-dim: var(--vvd-empty-state-accent-dim, var(--vvd-color-neutral-200));--_connotation-color-faint: var(--vvd-empty-state-accent-faint, var(--vvd-color-neutral-50))}.icon-container{display:flex;align-items:center;justify-content:center;border-radius:50%;background-color:var(--_empty-state-icon-background);block-size:var(--_empty-state-icon-container);font-size:var(--_empty-state-icon-font-size);inline-size:var(--_empty-state-icon-container)}.icon-decoration-outlined .icon-container{--_empty-state-icon-background: transparent;--_empty-state-icon-font-size: 40px;box-shadow:inset 0 0 0 21px var(--_connotation-color-faint)}.icon-container .icon{color:var(--_connotation-color-firm-all)}.icon-decoration-outlined .icon-container .icon{padding:19px;border:1px solid var(--_connotation-color-dim);border-radius:inherit}.content{display:flex;flex-direction:column;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);gap:8px;text-align:center}header{color:var(--_connotation-color-firm-all);font:var(--vvd-typography-base-extended-bold)}.actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px}.base.no-actions .actions{display:none}";
11
11
 
12
12
  var __defProp = Object.defineProperty;
13
13
  var __decorateClass = (decorators, target, key, kind) => {
@@ -15,23 +15,37 @@ var __decorateClass = (decorators, target, key, kind) => {
15
15
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
16
16
  if (decorator = decorators[i])
17
17
  result = (decorator(target, key, result) ) || result;
18
- if (result)
19
- __defProp(target, key, result);
18
+ if (result) __defProp(target, key, result);
20
19
  return result;
21
20
  };
22
21
  class EmptyState extends index.FoundationElement {
23
22
  }
23
+ __decorateClass([
24
+ index.attr
25
+ ], EmptyState.prototype, "connotation");
24
26
  __decorateClass([
25
27
  index.attr
26
28
  ], EmptyState.prototype, "headline");
27
29
  __decorateClass([
28
30
  index.attr
29
31
  ], EmptyState.prototype, "icon");
32
+ __decorateClass([
33
+ index.attr({ attribute: "icon-decoration" })
34
+ ], EmptyState.prototype, "iconDecoration");
30
35
  __decorateClass([
31
36
  index.observable
32
37
  ], EmptyState.prototype, "slottedActionItems");
33
38
 
34
- const getClasses = (x) => classNames.classNames("base", ["no-actions", x.slottedActionItems?.length === 0]);
39
+ const getClasses = ({
40
+ connotation,
41
+ iconDecoration,
42
+ slottedActionItems
43
+ }) => classNames.classNames(
44
+ "base",
45
+ [`connotation-${connotation}`, Boolean(connotation)],
46
+ [`icon-decoration-${iconDecoration}`, Boolean(iconDecoration)],
47
+ ["no-actions", slottedActionItems?.length === 0]
48
+ );
35
49
  const EmptyStateTemplate = (context) => {
36
50
  const iconTag = context.tagFor(icon.Icon);
37
51
  return index.html` <div class="${getClasses}">
@@ -39,7 +53,7 @@ const EmptyStateTemplate = (context) => {
39
53
  ${when.when(
40
54
  (x) => x.icon,
41
55
  index.html`<div class="icon-container">
42
- <${iconTag} class="icon" name="${(x) => x.icon}" size="5"></${iconTag}>
56
+ <${iconTag} class="icon" name="${(x) => x.icon}"></${iconTag}>
43
57
  </div>`
44
58
  )}
45
59
  </slot>