@vonage/vivid 3.40.0 → 3.42.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 (161) hide show
  1. package/accordion/index.js +2 -2
  2. package/accordion-item/index.js +2 -2
  3. package/alert/index.js +6 -5
  4. package/audio-player/index.js +33 -0
  5. package/avatar/index.js +2 -2
  6. package/badge/index.js +2 -2
  7. package/banner/index.js +8 -5
  8. package/breadcrumb/index.js +1 -1
  9. package/breadcrumb-item/index.js +3 -3
  10. package/button/index.js +4 -4
  11. package/calendar/index.js +1 -1
  12. package/calendar-event/index.js +1 -1
  13. package/card/index.js +4 -3
  14. package/checkbox/index.js +3 -3
  15. package/combobox/index.js +8 -8
  16. package/custom-elements.json +438 -41
  17. package/data-grid/index.js +2 -2
  18. package/date-picker/index.js +9 -9
  19. package/date-range-picker/index.js +8 -8
  20. package/dialog/index.js +6 -6
  21. package/divider/index.js +1 -1
  22. package/elevation/index.js +1 -1
  23. package/empty-state/index.js +2 -2
  24. package/fab/index.js +3 -3
  25. package/file-picker/index.js +5 -5
  26. package/focus/index.js +1 -1
  27. package/header/index.js +2 -2
  28. package/icon/index.js +1 -1
  29. package/index.js +57 -56
  30. package/layout/index.js +1 -1
  31. package/lib/alert/alert.d.ts +3 -1
  32. package/lib/alert/locale.d.ts +3 -0
  33. package/lib/audio-player/audio-player.d.ts +17 -0
  34. package/lib/audio-player/audio-player.template.d.ts +4 -0
  35. package/lib/audio-player/definition.d.ts +4 -0
  36. package/lib/audio-player/locale.d.ts +5 -0
  37. package/lib/banner/banner.d.ts +3 -1
  38. package/lib/banner/locale.d.ts +3 -0
  39. package/lib/card/card.d.ts +3 -0
  40. package/lib/card/card.template.d.ts +1 -1
  41. package/lib/card/definition.d.ts +1 -0
  42. package/lib/checkbox/checkbox.d.ts +1 -0
  43. package/lib/components.d.ts +1 -0
  44. package/lib/enums.d.ts +2 -1
  45. package/lib/selectable-box/selectable-box.d.ts +2 -2
  46. package/lib/split-button/locale.d.ts +3 -0
  47. package/lib/split-button/split-button.d.ts +4 -2
  48. package/listbox/index.js +4 -4
  49. package/locales/en-GB.js +14 -0
  50. package/locales/en-US.js +14 -0
  51. package/locales/ja-JP.js +14 -0
  52. package/locales/zh-CN.js +14 -0
  53. package/menu/index.js +8 -8
  54. package/menu-item/index.js +3 -3
  55. package/nav/index.js +1 -1
  56. package/nav-disclosure/index.js +3 -3
  57. package/nav-item/index.js +3 -3
  58. package/note/index.js +2 -2
  59. package/number-field/index.js +6 -6
  60. package/option/index.js +3 -3
  61. package/package.json +1 -1
  62. package/pagination/index.js +5 -5
  63. package/popup/index.js +6 -6
  64. package/progress/index.js +1 -1
  65. package/progress-ring/index.js +1 -1
  66. package/radio/index.js +2 -2
  67. package/radio-group/index.js +2 -2
  68. package/select/index.js +8 -8
  69. package/selectable-box/index.js +5 -5
  70. package/shared/definition.js +3 -3
  71. package/shared/definition10.js +90 -159
  72. package/shared/definition11.js +151 -29
  73. package/shared/definition12.js +37 -766
  74. package/shared/definition13.js +747 -106
  75. package/shared/definition14.js +121 -198
  76. package/shared/definition15.js +167 -664
  77. package/shared/definition16.js +576 -1137
  78. package/shared/definition17.js +1278 -143
  79. package/shared/definition18.js +68 -306
  80. package/shared/definition19.js +359 -217
  81. package/shared/definition2.js +1 -1
  82. package/shared/definition20.js +259 -67
  83. package/shared/definition21.js +66 -58
  84. package/shared/definition22.js +43 -84
  85. package/shared/definition23.js +76 -2353
  86. package/shared/definition24.js +2362 -45
  87. package/shared/definition25.js +63 -27
  88. package/shared/definition26.js +24 -51
  89. package/shared/definition27.js +36 -822
  90. package/shared/definition28.js +837 -49
  91. package/shared/definition29.js +52 -89
  92. package/shared/definition3.js +1 -1
  93. package/shared/definition30.js +88 -24
  94. package/shared/definition31.js +25 -12
  95. package/shared/definition32.js +12 -52
  96. package/shared/definition33.js +28 -502
  97. package/shared/definition34.js +442 -197
  98. package/shared/definition35.js +260 -186
  99. package/shared/definition36.js +186 -75
  100. package/shared/definition37.js +70 -54
  101. package/shared/definition38.js +65 -421
  102. package/shared/definition39.js +437 -38
  103. package/shared/definition4.js +43 -16
  104. package/shared/definition40.js +32 -680
  105. package/shared/definition41.js +654 -105
  106. package/shared/definition42.js +117 -78
  107. package/shared/definition43.js +74 -567
  108. package/shared/definition44.js +567 -98
  109. package/shared/definition45.js +110 -135
  110. package/shared/definition46.js +153 -17
  111. package/shared/definition47.js +16 -79
  112. package/shared/definition48.js +53 -475
  113. package/shared/definition49.js +502 -25
  114. package/shared/definition5.js +160 -44
  115. package/shared/definition50.js +22 -121
  116. package/shared/definition51.js +113 -271
  117. package/shared/definition52.js +249 -243
  118. package/shared/definition53.js +270 -109
  119. package/shared/definition54.js +84 -74
  120. package/shared/definition55.js +114 -69
  121. package/shared/definition56.js +81 -292
  122. package/shared/definition57.js +302 -13
  123. package/shared/definition58.js +11 -41
  124. package/shared/definition59.js +20 -154
  125. package/shared/definition6.js +43 -33
  126. package/shared/definition60.js +181 -0
  127. package/shared/definition7.js +39 -106
  128. package/shared/definition8.js +122 -38
  129. package/shared/definition9.js +56 -89
  130. package/shared/enums.js +1 -0
  131. package/shared/icon.js +2 -2
  132. package/shared/index.js +1 -1
  133. package/shared/index2.js +1 -1
  134. package/shared/listbox.js +1 -1
  135. package/shared/localization/Locale.d.ts +8 -0
  136. package/shared/patterns/form-elements/form-elements.d.ts +6 -6
  137. package/shared/presentationDate.js +10 -8
  138. package/shared/text-field.js +1 -1
  139. package/side-drawer/index.js +1 -1
  140. package/slider/index.js +3 -3
  141. package/split-button/index.js +6 -3
  142. package/style.css +329 -242
  143. package/styles/core/all.css +31 -25
  144. package/styles/core/theme.css +1 -1
  145. package/styles/core/typography.css +31 -25
  146. package/styles/tokens/theme-dark.css +4 -4
  147. package/styles/tokens/theme-light.css +4 -4
  148. package/styles/tokens/vivid-2-compat.css +1 -1
  149. package/switch/index.js +3 -3
  150. package/tab/index.js +3 -3
  151. package/tab-panel/index.js +1 -1
  152. package/tabs/index.js +5 -5
  153. package/tag/index.js +3 -3
  154. package/tag-group/index.js +1 -1
  155. package/text-area/index.js +3 -3
  156. package/text-field/index.js +3 -3
  157. package/toggletip/index.js +7 -7
  158. package/tooltip/index.js +7 -7
  159. package/tree-item/index.js +3 -3
  160. package/tree-view/index.js +1 -1
  161. package/vivid.api.json +270 -1
@@ -1,28 +1,13 @@
1
- import { a as attr, o as observable, v as volatile, r as registerFactory } from './index.js';
2
- import { a as buttonRegistries } from './definition10.js';
3
- import { p as popupRegistries } from './definition59.js';
4
- import { a as textFieldRegistries } from './definition52.js';
5
- import { f as focusRegistries } from './definition57.js';
6
- import { a as dividerRegistries } from './definition20.js';
7
- import { f as formatPresentationDate, p as parsePresentationDate, D as DatePickerBase, i as isValidDateStr, c as compareDateStr, a as DatePickerBaseTemplate, s as styles } from './presentationDate.js';
1
+ import { v as volatile, r as registerFactory } from './index.js';
2
+ import { p as popupRegistries } from './definition60.js';
3
+ import { f as focusRegistries } from './definition58.js';
4
+ import { a as buttonRegistries } from './definition11.js';
5
+ import { a as textFieldRegistries } from './definition53.js';
6
+ import { a as dividerRegistries } from './definition21.js';
7
+ import { D as DatePickerBase, i as isValidDateStr, f as formatPresentationDate, p as parsePresentationDate, a as DatePickerBaseTemplate, s as styles } from './presentationDate.js';
8
8
  import './affix.js';
9
9
  import { e as errorText, f as formElements } from './index2.js';
10
10
 
11
- const formatRange = (from, to) => {
12
- return `${from} – ${to}`;
13
- };
14
- const formatPresentationDateRange = (dateRange, locale) => {
15
- return formatRange(formatPresentationDate(dateRange.start, locale), formatPresentationDate(dateRange.end, locale));
16
- };
17
- const parsePresentationDateRange = (presentationDateRange, locale) => {
18
- const fragments = presentationDateRange.trim().split(/[\s—–-]+/);
19
- if (fragments.length !== 2) {
20
- throw new Error(`Invalid date range: ${presentationDateRange}`);
21
- }
22
- const [start, end] = fragments.map((fragment) => parsePresentationDate(fragment, locale));
23
- return { start, end };
24
- };
25
-
26
11
  var __defProp = Object.defineProperty;
27
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
28
13
  var __decorateClass = (decorators, target, key, kind) => {
@@ -34,279 +19,104 @@ var __decorateClass = (decorators, target, key, kind) => {
34
19
  __defProp(target, key, result);
35
20
  return result;
36
21
  };
37
- const isFormAssociatedTryingToSetFormValue = (value) => typeof value === "string";
38
- function isDefined(value) {
39
- return !!value;
40
- }
41
- let DateRangePicker = class extends DatePickerBase {
22
+ let DatePicker = class extends DatePickerBase {
42
23
  constructor() {
43
- super(...arguments);
44
- this.initialStart = "";
45
- this.initialEnd = "";
46
- this.#isInternalValueUpdate = false;
47
- this.start = "";
48
- this.end = "";
49
- this.setFormValue = (value, state) => {
50
- if (isFormAssociatedTryingToSetFormValue(value)) {
51
- return;
52
- }
53
- super.setFormValue(value, state);
54
- };
55
- this._numCalendars = 2;
56
- /**
57
- * @internal
58
- */
59
- this._hideDatesOutsideMonth = true;
24
+ super();
60
25
  /**
61
26
  * @internal
62
27
  */
63
- this._textFieldSize = "30";
64
- }
65
- /**
66
- * @internal
67
- */
68
- initialStartChanged() {
69
- if (!this.dirtyValue) {
70
- this.start = this.initialStart;
71
- this.dirtyValue = false;
72
- }
73
- }
74
- /**
75
- * @internal
76
- */
77
- initialEndChanged() {
78
- if (!this.dirtyValue) {
79
- this.end = this.initialEnd;
80
- this.dirtyValue = false;
81
- }
82
- }
83
- #isInternalValueUpdate;
84
- /**
85
- * @internal
86
- */
87
- startChanged() {
88
- if (this.start && !isValidDateStr(this.start)) {
89
- this.start = "";
90
- return;
91
- }
92
- this.currentStart = this.start;
93
- this.dirtyValue = true;
94
- if (!this.#isInternalValueUpdate) {
95
- this.#handleChangedValues();
96
- }
97
- }
98
- /**
99
- * @internal
100
- */
101
- endChanged() {
102
- if (this.end && !isValidDateStr(this.end)) {
103
- this.end = "";
104
- return;
105
- }
106
- this.currentEnd = this.end;
107
- this.dirtyValue = true;
108
- if (!this.#isInternalValueUpdate) {
109
- this.#handleChangedValues();
110
- }
111
- }
112
- /**
113
- * @internal
114
- */
115
- currentStartChanged() {
116
- this.start = this.currentStart;
28
+ this._textFieldSize = "20";
29
+ this.proxy.type = "date";
117
30
  }
118
31
  /**
119
32
  * @internal
120
33
  */
121
- currentEndChanged() {
122
- this.end = this.currentEnd;
123
- }
124
- #updateValues(range) {
125
- this.#isInternalValueUpdate = true;
126
- if (range.start !== void 0) {
127
- this.start = range.start;
128
- this.$emit("input:start");
129
- }
130
- if (range.end !== void 0) {
131
- this.end = range.end;
132
- this.$emit("input:end");
133
- }
134
- this.#isInternalValueUpdate = false;
135
- this.$emit("input");
136
- this.$emit("change");
137
- this.#handleChangedValues();
138
- }
139
- #handleChangedValues() {
140
- if (this.start && this.end) {
141
- if (compareDateStr(this.start, this.end) > 0) {
142
- this.#updateValues({ start: this.end, end: this.start });
34
+ valueChanged(previous, next) {
35
+ super.valueChanged(previous, next);
36
+ if (this.value) {
37
+ if (!isValidDateStr(this.value)) {
38
+ this.value = "";
143
39
  return;
144
40
  }
145
- this._presentationValue = formatPresentationDateRange(
146
- {
147
- start: this.start,
148
- end: this.end
149
- },
41
+ this._presentationValue = formatPresentationDate(
42
+ this.value,
150
43
  this.locale.datePicker
151
44
  );
152
- this.value = formatRange(this.start, this.end);
45
+ this._adjustSelectedMonthToEnsureVisibilityOf(this.value);
153
46
  } else {
154
- this.value = "";
155
47
  this._presentationValue = "";
156
48
  }
157
- const dateToEnsureVisibilityOf = this.start || this.end;
158
- if (dateToEnsureVisibilityOf) {
159
- this._adjustSelectedMonthToEnsureVisibilityOf(dateToEnsureVisibilityOf);
160
- }
161
- this.#updateFormValue();
162
49
  }
163
- /**
164
- * @internal
165
- */
166
- nameChanged(previous, next) {
167
- super.nameChanged(previous, next);
168
- this.#updateFormValue();
50
+ #updateValueDueToUserInteraction(newValue) {
51
+ this.value = newValue;
52
+ this.$emit("change");
53
+ this.$emit("input");
169
54
  }
170
- #updateFormValue() {
171
- if (!this.name || !this.start || !this.end) {
172
- this.setFormValue(null);
55
+ get _calendarButtonLabel() {
56
+ if (this.value) {
57
+ return this.locale.datePicker.changeDateLabel(formatPresentationDate(this.value, this.locale.datePicker));
173
58
  } else {
174
- const formData = new FormData();
175
- formData.append(this.name, this.start);
176
- formData.append(this.name, this.end);
177
- this.setFormValue(formData);
178
- }
179
- }
180
- connectedCallback() {
181
- super.connectedCallback();
182
- if (!this.start) {
183
- this.start = this.initialStart;
184
- }
185
- if (!this.end) {
186
- this.end = this.initialEnd;
187
- }
188
- }
189
- #getVisibleRange() {
190
- const candidates = [this.start, this.end].filter(isDefined);
191
- const isPartialRange = candidates.length === 1;
192
- if (this._hoverDate && isPartialRange) {
193
- candidates.push(this._hoverDate);
59
+ return this.locale.datePicker.chooseDateLabel;
194
60
  }
195
- const [start, end] = candidates.sort(compareDateStr);
196
- return { start, end };
197
61
  }
198
62
  /**
199
63
  * @internal
200
64
  */
201
- _isDateAriaSelected(date) {
202
- return date === this.start || date === this.end;
203
- }
204
- /**
205
- * @internal
206
- */
207
- _isDateInSelectedRange(date) {
208
- const { start, end } = this.#getVisibleRange();
209
- if (start && end) {
210
- return compareDateStr(date, start) >= 0 && compareDateStr(date, end) <= 0;
211
- }
212
- return false;
213
- }
214
- /**
215
- * @internal
216
- */
217
- _isDateRangeStart(date) {
218
- return date === this.#getVisibleRange().start;
219
- }
220
- /**
221
- * @internal
222
- */
223
- _isDateRangeEnd(date) {
224
- return date === this.#getVisibleRange().end;
65
+ get _textFieldPlaceholder() {
66
+ return this.locale.datePicker.dateFormatPlaceholder;
225
67
  }
226
68
  /**
227
69
  * @internal
228
70
  */
229
- _getSelectedDates() {
230
- const dates = [];
231
- if (this.start) {
232
- dates.push(this.start);
71
+ _onTextFieldChange() {
72
+ if (this._presentationValue === "") {
73
+ this.#updateValueDueToUserInteraction("");
74
+ return;
233
75
  }
234
- if (this.end) {
235
- dates.push(this.end);
76
+ try {
77
+ this.#updateValueDueToUserInteraction(
78
+ parsePresentationDate(this._presentationValue, this.locale.datePicker)
79
+ );
80
+ } catch (_) {
81
+ return;
236
82
  }
237
- return dates;
238
83
  }
239
84
  /**
85
+ * Handle selecting a date from the calendar.
240
86
  * @internal
241
87
  */
242
88
  _onDateClick(date) {
243
- if (this.start && this.end) {
244
- this.#updateValues({ start: date, end: "" });
245
- } else if (this.start) {
246
- this.#updateValues({ end: date });
247
- this._closePopup();
248
- } else if (this.end) {
249
- this.#updateValues({ start: date });
250
- this._closePopup();
251
- } else {
252
- this.#updateValues({ start: date });
253
- }
89
+ this.#updateValueDueToUserInteraction(date);
90
+ this._closePopup();
254
91
  }
255
92
  /**
256
93
  * @internal
257
94
  */
258
- get _textFieldPlaceholder() {
259
- return formatRange(
260
- this.locale.datePicker.dateFormatPlaceholder,
261
- this.locale.datePicker.dateFormatPlaceholder
262
- );
95
+ _isDateSelected(date) {
96
+ return date === this.value;
263
97
  }
264
98
  /**
265
99
  * @internal
266
100
  */
267
- _onTextFieldChange() {
268
- if (this._presentationValue === "") {
269
- this.#updateValues({ start: "", end: "" });
270
- return;
271
- }
272
- try {
273
- const { start, end } = parsePresentationDateRange(
274
- this._presentationValue,
275
- this.locale.datePicker
276
- );
277
- this.#updateValues({ start, end });
278
- } catch (_) {
279
- return;
280
- }
281
- }
282
- /**
283
- * @internal
284
- */
285
- _onDateMouseEnter(date) {
286
- this._hoverDate = date;
101
+ _isDateAriaSelected(date) {
102
+ return this._isDateSelected(date);
287
103
  }
288
104
  /**
289
105
  * @internal
290
106
  */
291
- _onDateMouseLeave() {
292
- this._hoverDate = void 0;
107
+ _getSelectedDates() {
108
+ const dates = [];
109
+ if (this.value) {
110
+ dates.push(this.value);
111
+ }
112
+ return dates;
293
113
  }
294
114
  /**
295
115
  * @internal
296
116
  */
297
117
  _getCustomValidationError() {
298
118
  if (this._isPresentationValueInvalid()) {
299
- return this.locale.datePicker.invalidDateRangeError;
300
- }
301
- if (this.min && this.start && compareDateStr(this.start, this.min) < 0) {
302
- return this.locale.datePicker.startDateAfterMinDateError(
303
- formatPresentationDate(this.min, this.locale.datePicker)
304
- );
305
- }
306
- if (this.max && this.end && compareDateStr(this.end, this.max) > 0) {
307
- return this.locale.datePicker.endDateBeforeMaxDateError(
308
- formatPresentationDate(this.max, this.locale.datePicker)
309
- );
119
+ return this.locale.datePicker.invalidDateError;
310
120
  }
311
121
  return null;
312
122
  }
@@ -318,10 +128,7 @@ let DateRangePicker = class extends DatePickerBase {
318
128
  return false;
319
129
  }
320
130
  try {
321
- parsePresentationDateRange(
322
- this._presentationValue,
323
- this.locale.datePicker
324
- );
131
+ parsePresentationDate(this._presentationValue, this.locale.datePicker);
325
132
  return false;
326
133
  } catch (_) {
327
134
  return true;
@@ -331,79 +138,34 @@ let DateRangePicker = class extends DatePickerBase {
331
138
  * @internal
332
139
  */
333
140
  _onClearClick() {
334
- this.#updateValues({ start: "", end: "" });
141
+ this.#updateValueDueToUserInteraction("");
335
142
  super._onClearClick();
336
143
  }
337
- /**
338
- * @internal
339
- */
340
- formResetCallback() {
341
- this.#updateValues({ start: this.initialStart, end: this.initialEnd });
342
- super.formResetCallback();
343
- }
344
- get _calendarButtonLabel() {
345
- if (this.start && this.end) {
346
- return this.locale.datePicker.changeDatesLabel(
347
- formatPresentationDateRange(
348
- {
349
- start: this.start,
350
- end: this.end
351
- },
352
- this.locale.datePicker
353
- )
354
- );
355
- } else {
356
- return this.locale.datePicker.chooseDatesLabel;
357
- }
358
- }
359
144
  };
360
- __decorateClass([
361
- attr({ mode: "fromView", attribute: "start" })
362
- ], DateRangePicker.prototype, "initialStart", 2);
363
- __decorateClass([
364
- attr({ mode: "fromView", attribute: "end" })
365
- ], DateRangePicker.prototype, "initialEnd", 2);
366
- __decorateClass([
367
- observable
368
- ], DateRangePicker.prototype, "start", 2);
369
- __decorateClass([
370
- observable
371
- ], DateRangePicker.prototype, "end", 2);
372
- __decorateClass([
373
- attr({ attribute: "current-start" })
374
- ], DateRangePicker.prototype, "currentStart", 2);
375
- __decorateClass([
376
- attr({ attribute: "current-end" })
377
- ], DateRangePicker.prototype, "currentEnd", 2);
378
- __decorateClass([
379
- observable
380
- ], DateRangePicker.prototype, "_numCalendars", 2);
381
- __decorateClass([
382
- observable
383
- ], DateRangePicker.prototype, "_hoverDate", 2);
384
145
  __decorateClass([
385
146
  volatile
386
- ], DateRangePicker.prototype, "_calendarButtonLabel", 1);
387
- DateRangePicker = __decorateClass([
147
+ ], DatePicker.prototype, "_calendarButtonLabel", 1);
148
+ DatePicker = __decorateClass([
388
149
  errorText,
389
150
  formElements
390
- ], DateRangePicker);
151
+ ], DatePicker);
391
152
 
392
- const dateRangePickerDefinition = DateRangePicker.compose({
393
- baseName: "date-range-picker",
153
+ const datePickerDefinition = DatePicker.compose({
154
+ baseName: "date-picker",
394
155
  template: DatePickerBaseTemplate,
395
- styles
156
+ styles,
157
+ shadowOptions: {
158
+ delegatesFocus: true
159
+ }
396
160
  });
397
- const dateRangePickerRegistries = [
398
- dateRangePickerDefinition(),
161
+ const datePickerRegistries = [
162
+ datePickerDefinition(),
399
163
  ...buttonRegistries,
400
164
  ...popupRegistries,
401
165
  ...textFieldRegistries,
402
166
  ...focusRegistries,
403
167
  ...dividerRegistries
404
168
  ];
405
- const registerDateRangePicker = registerFactory(
406
- dateRangePickerRegistries
407
- );
169
+ const registerDatePicker = registerFactory(datePickerRegistries);
408
170
 
409
- export { dateRangePickerRegistries as a, dateRangePickerDefinition as d, registerDateRangePicker as r };
171
+ export { datePickerRegistries as a, datePickerDefinition as d, registerDatePicker as r };