@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,19 +1,27 @@
1
- import { a as attr, F as FoundationElement, o as observable, h as html, r as registerFactory } from './index.js';
2
- import { a as iconRegistries } from './definition25.js';
3
- import { B as Button, a as buttonRegistries } from './definition10.js';
4
- import { E as Elevation, e as elevationRegistries } from './definition58.js';
1
+ import { a as attr, o as observable, v as volatile, r as registerFactory } from './index.js';
2
+ import { a as buttonRegistries } from './definition11.js';
3
+ import { p as popupRegistries } from './definition60.js';
4
+ import { a as textFieldRegistries } from './definition53.js';
5
+ import { f as focusRegistries } from './definition58.js';
6
+ import { a as dividerRegistries } from './definition21.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';
5
8
  import './affix.js';
6
- import './index2.js';
7
- import { L as Localized } from './localized.js';
8
- import { a as applyMixins } from './apply-mixins.js';
9
- import { I as Icon } from './icon.js';
10
- import { w as when } from './when.js';
11
- import { s as slotted } from './slotted.js';
12
- import { c as classNames } from './class-names.js';
9
+ import { e as errorText, f as formElements } from './index2.js';
13
10
 
14
- const dialogPolyfillStyles = "dialog {\n position: absolute;\n left: 0; right: 0;\n width: -moz-fit-content;\n width: -webkit-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: -webkit-fit-content;\n height: fit-content;\n margin: auto;\n border: solid;\n padding: 1em;\n background: white;\n color: black;\n display: block;\n}\n\ndialog:not([open]) {\n display: none;\n}\n\ndialog + .backdrop {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n background: rgba(0,0,0,0.1);\n}\n\n._dialog_overlay {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n}\n\ndialog.fixed {\n position: fixed;\n top: 50%;\n transform: translate(0, -50%);\n}";
15
-
16
- const styles = "/**\n * Do not edit directly\n * Generated on Wed, 01 Nov 2023 12:16:28 GMT\n */\n.base {\n box-sizing: border-box;\n padding: 0;\n border: none;\n background-color: transparent;\n border-radius: 6px;\n color: var(--vvd-color-canvas-text);\n max-block-size: var(--dialog-max-block-size, calc(100vh - 64px));\n max-inline-size: var(--dialog-max-inline-size, var(--_dialog-default-max-inline-size));\n min-inline-size: var(--dialog-min-inline-size, 280px);\n}\n@media not all and (min-width: 600px) {\n .base {\n --_dialog-default-max-inline-size: 90vw;\n }\n}\n@media (min-width: 600px) {\n .base {\n --_dialog-default-max-inline-size: 560px;\n }\n}\n.base:not(.modal) {\n z-index: var(--dialog-z-index, 1);\n}\n.base.modal {\n position: fixed;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);\n}\n.base.modal::backdrop {\n background-color: var(--vvd-color-canvas-text, currentColor);\n opacity: 0.5;\n}\n\n.main-wrapper {\n display: flex;\n box-sizing: border-box;\n flex-direction: column;\n gap: 24px;\n padding-block: 24px;\n}\n.main-wrapper > * {\n box-sizing: border-box;\n}\n\n.header {\n display: grid;\n align-items: flex-start;\n justify-content: space-between;\n inline-size: 100%;\n padding-inline: 24px;\n}\n.base:not(.icon-placement-side) .header {\n grid-template-columns: 1fr auto;\n grid-template-rows: auto auto auto;\n}\n.base:not(.icon-placement-side) .header .icon {\n font-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8));\n grid-column: 1/2;\n grid-row: 1/2;\n line-height: 1;\n margin-block-end: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16));\n}\n.base.icon-placement-side .header {\n grid-template-columns: auto 1fr auto;\n grid-template-rows: auto auto;\n}\n.base.icon-placement-side .header .icon {\n font-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 12));\n}\n.base.icon-placement-side .header ::slotted(*),\n.base.icon-placement-side .header .icon {\n grid-column: 1/2;\n grid-row: 1/-1;\n margin-inline-end: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)) / 2);\n}\n.header.border {\n position: relative;\n}\n.header.border::after {\n position: absolute;\n bottom: -24px;\n left: 0;\n background-color: var(--vvd-color-neutral-200);\n block-size: 1px;\n content: \"\";\n inline-size: 100%;\n}\n.base.hide-body .header.border::after {\n content: none;\n}\n\n.body:not(.full-width) {\n padding-inline: 24px;\n}\n.hide-body .body {\n display: none;\n}\n\n.footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 24px;\n padding-inline: 24px;\n}\n.hide-footer .footer {\n display: none;\n}\n.footer .actions {\n display: flex;\n align-self: flex-end;\n gap: 8px;\n}\n\n.dismiss-button {\n flex-shrink: 0;\n grid-column: -2/-1;\n grid-row: 1/-1;\n margin-block-start: -8px;\n margin-inline-end: -8px;\n margin-inline-start: 4px;\n}\n\n.headline {\n font: var(--vvd-typography-heading-4);\n}\n\n.subtitle {\n font: var(--vvd-typography-base);\n}\n\nslot[name=main] {\n display: block;\n overflow: hidden auto;\n max-width: inherit;\n max-height: inherit;\n border-radius: inherit;\n}";
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
+ };
17
25
 
18
26
  var __defProp = Object.defineProperty;
19
27
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,245 +34,379 @@ var __decorateClass = (decorators, target, key, kind) => {
26
34
  __defProp(target, key, result);
27
35
  return result;
28
36
  };
29
- const isDialogSupported = Boolean(HTMLDialogElement && HTMLDialogElement.prototype.showModal);
30
- let dialogPolyfill;
31
- (async () => {
32
- if (!isDialogSupported) {
33
- delete window.HTMLDialogElement;
34
- dialogPolyfill = await import('./dialog-polyfill.esm.js');
35
- }
36
- })();
37
- class Dialog extends FoundationElement {
37
+ const isFormAssociatedTryingToSetFormValue = (value) => typeof value === "string";
38
+ function isDefined(value) {
39
+ return !!value;
40
+ }
41
+ let DateRangePicker = class extends DatePickerBase {
38
42
  constructor() {
39
43
  super(...arguments);
40
- this.open = false;
41
- this.fullWidthBody = false;
42
- this.ariaLabelledBy = null;
43
- this.ariaLabel = null;
44
- this.ariaDescribedBy = null;
45
- this.dismissButtonAriaLabel = null;
46
- this.#modal = false;
47
- this.#handleScrimClick = (event) => {
48
- if (event.target !== this.#dialog) {
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)) {
49
51
  return;
50
52
  }
51
- const rect = this.#dialog.getBoundingClientRect();
52
- const clickedInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
53
- this.open = clickedInDialog;
53
+ super.setFormValue(value, state);
54
54
  };
55
- this.#handleInternalFormSubmit = (event) => {
56
- if (event.target.method !== "dialog") {
55
+ this._numCalendars = 2;
56
+ /**
57
+ * @internal
58
+ */
59
+ this._hideDatesOutsideMonth = true;
60
+ /**
61
+ * @internal
62
+ */
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;
117
+ }
118
+ /**
119
+ * @internal
120
+ */
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 });
57
143
  return;
58
144
  }
59
- this.open = false;
60
- };
145
+ this._presentationValue = formatPresentationDateRange(
146
+ {
147
+ start: this.start,
148
+ end: this.end
149
+ },
150
+ this.locale.datePicker
151
+ );
152
+ this.value = formatRange(this.start, this.end);
153
+ } else {
154
+ this.value = "";
155
+ this._presentationValue = "";
156
+ }
157
+ const dateToEnsureVisibilityOf = this.start || this.end;
158
+ if (dateToEnsureVisibilityOf) {
159
+ this._adjustSelectedMonthToEnsureVisibilityOf(dateToEnsureVisibilityOf);
160
+ }
161
+ this.#updateFormValue();
61
162
  }
62
- #modal;
63
- set returnValue(value) {
64
- this.#dialog.returnValue = value;
163
+ /**
164
+ * @internal
165
+ */
166
+ nameChanged(previous, next) {
167
+ super.nameChanged(previous, next);
168
+ this.#updateFormValue();
65
169
  }
66
- get returnValue() {
67
- return this.#dialog?.returnValue;
170
+ #updateFormValue() {
171
+ if (!this.name || !this.start || !this.end) {
172
+ this.setFormValue(null);
173
+ } 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
+ }
68
179
  }
69
- get modal() {
70
- return this.#modal;
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
+ }
71
188
  }
72
- #dialogElement;
73
- get #dialog() {
74
- if (!this.#dialogElement) {
75
- this.#dialogElement = this.shadowRoot.querySelector("dialog");
76
- if (this.#dialogElement) {
77
- this.#dialogElement.open = this.open;
78
- if (dialogPolyfill) {
79
- dialogPolyfill.registerDialog(this.#dialogElement);
80
- }
81
- }
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);
82
194
  }
83
- return this.#dialogElement;
195
+ const [start, end] = candidates.sort(compareDateStr);
196
+ return { start, end };
84
197
  }
85
- openChanged(oldValue, newValue) {
86
- if (oldValue === void 0) {
87
- return;
198
+ /**
199
+ * @internal
200
+ */
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;
225
+ }
226
+ /**
227
+ * @internal
228
+ */
229
+ _getSelectedDates() {
230
+ const dates = [];
231
+ if (this.start) {
232
+ dates.push(this.start);
88
233
  }
89
- if (!newValue) {
90
- this.close();
234
+ if (this.end) {
235
+ dates.push(this.end);
236
+ }
237
+ return dates;
238
+ }
239
+ /**
240
+ * @internal
241
+ */
242
+ _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();
91
251
  } else {
92
- if (this.#dialog) {
93
- this.#dialog.open = true;
94
- }
252
+ this.#updateValues({ start: date });
95
253
  }
96
254
  }
97
- #handleScrimClick;
98
- #handleInternalFormSubmit;
99
- close() {
100
- if (this.#dialog.open) {
101
- this.#dialog.close();
102
- this.$emit("close", this.returnValue, { bubbles: false });
255
+ /**
256
+ * @internal
257
+ */
258
+ get _textFieldPlaceholder() {
259
+ return formatRange(
260
+ this.locale.datePicker.dateFormatPlaceholder,
261
+ this.locale.datePicker.dateFormatPlaceholder
262
+ );
263
+ }
264
+ /**
265
+ * @internal
266
+ */
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;
103
280
  }
104
- this.open = false;
105
- this.#handleModal(false);
106
281
  }
107
- #handleModal(show) {
108
- this.#modal = show;
109
- this.#dialog.toggleAttribute("aria-modal", show);
110
- this.#dialog.classList.toggle("modal", show);
282
+ /**
283
+ * @internal
284
+ */
285
+ _onDateMouseEnter(date) {
286
+ this._hoverDate = date;
111
287
  }
112
- show() {
113
- this.#dialog.show();
114
- this.open = true;
288
+ /**
289
+ * @internal
290
+ */
291
+ _onDateMouseLeave() {
292
+ this._hoverDate = void 0;
115
293
  }
116
- showModal() {
117
- this.#handleModal(true);
118
- this.#dialog.showModal();
119
- this.open = true;
294
+ /**
295
+ * @internal
296
+ */
297
+ _getCustomValidationError() {
298
+ 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
+ );
310
+ }
311
+ return null;
120
312
  }
121
- connectedCallback() {
122
- super.connectedCallback();
123
- this.#dialog.addEventListener("mousedown", this.#handleScrimClick);
124
- this.#dialog.addEventListener("submit", this.#handleInternalFormSubmit);
313
+ /**
314
+ * @internal
315
+ */
316
+ _isPresentationValueInvalid() {
317
+ if (this._presentationValue === "") {
318
+ return false;
319
+ }
320
+ try {
321
+ parsePresentationDateRange(
322
+ this._presentationValue,
323
+ this.locale.datePicker
324
+ );
325
+ return false;
326
+ } catch (_) {
327
+ return true;
328
+ }
125
329
  }
126
- disconnectedCallback() {
127
- super.disconnectedCallback();
128
- this.#dialog.removeEventListener("mousedown", this.#handleScrimClick);
129
- this.#dialog.removeEventListener("submit", this.#handleInternalFormSubmit);
330
+ /**
331
+ * @internal
332
+ */
333
+ _onClearClick() {
334
+ this.#updateValues({ start: "", end: "" });
335
+ super._onClearClick();
130
336
  }
131
- }
132
- __decorateClass([
133
- attr({ mode: "boolean" })
134
- ], Dialog.prototype, "open", 2);
135
- __decorateClass([
136
- attr
137
- ], Dialog.prototype, "icon", 2);
138
- __decorateClass([
139
- attr({ attribute: "icon-placement" })
140
- ], Dialog.prototype, "iconPlacement", 2);
141
- __decorateClass([
142
- attr
143
- ], Dialog.prototype, "subtitle", 2);
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([
145
- attr
146
- ], Dialog.prototype, "headline", 2);
361
+ attr({ mode: "fromView", attribute: "start" })
362
+ ], DateRangePicker.prototype, "initialStart", 2);
147
363
  __decorateClass([
148
- attr({ attribute: "full-width-body", mode: "boolean" })
149
- ], Dialog.prototype, "fullWidthBody", 2);
364
+ attr({ mode: "fromView", attribute: "end" })
365
+ ], DateRangePicker.prototype, "initialEnd", 2);
150
366
  __decorateClass([
151
- attr({ attribute: "aria-labelledby" })
152
- ], Dialog.prototype, "ariaLabelledBy", 2);
367
+ observable
368
+ ], DateRangePicker.prototype, "start", 2);
153
369
  __decorateClass([
154
- attr({ attribute: "aria-label" })
155
- ], Dialog.prototype, "ariaLabel", 2);
370
+ observable
371
+ ], DateRangePicker.prototype, "end", 2);
156
372
  __decorateClass([
157
- attr({ attribute: "aria-describedby" })
158
- ], Dialog.prototype, "ariaDescribedBy", 2);
373
+ attr({ attribute: "current-start" })
374
+ ], DateRangePicker.prototype, "currentStart", 2);
159
375
  __decorateClass([
160
- attr({ attribute: "dismiss-button-aria-label" })
161
- ], Dialog.prototype, "dismissButtonAriaLabel", 2);
376
+ attr({ attribute: "current-end" })
377
+ ], DateRangePicker.prototype, "currentEnd", 2);
162
378
  __decorateClass([
163
379
  observable
164
- ], Dialog.prototype, "bodySlottedContent", 2);
380
+ ], DateRangePicker.prototype, "_numCalendars", 2);
165
381
  __decorateClass([
166
382
  observable
167
- ], Dialog.prototype, "footerSlottedContent", 2);
383
+ ], DateRangePicker.prototype, "_hoverDate", 2);
168
384
  __decorateClass([
169
- observable
170
- ], Dialog.prototype, "actionItemsSlottedContent", 2);
171
- applyMixins(Dialog, Localized);
385
+ volatile
386
+ ], DateRangePicker.prototype, "_calendarButtonLabel", 1);
387
+ DateRangePicker = __decorateClass([
388
+ errorText,
389
+ formElements
390
+ ], DateRangePicker);
172
391
 
173
- const getClasses = ({
174
- iconPlacement,
175
- bodySlottedContent,
176
- footerSlottedContent,
177
- actionItemsSlottedContent
178
- }) => classNames(
179
- "base",
180
- [`icon-placement-${iconPlacement}`, Boolean(iconPlacement)],
181
- ["hide-body", !bodySlottedContent?.length],
182
- [
183
- "hide-footer",
184
- !(footerSlottedContent?.length || actionItemsSlottedContent?.length)
185
- ]
186
- );
187
- function icon(iconTag) {
188
- return html`
189
- <${iconTag} class="icon" name="${(x) => x.icon}"></${iconTag}>
190
- `;
191
- }
192
- function headline() {
193
- return html`
194
- <div class="headline">
195
- ${(x) => x.headline}
196
- </div>
197
- `;
198
- }
199
- function subtitle() {
200
- return html`
201
- <div class="subtitle">
202
- ${(x) => x.subtitle}
203
- </div>
204
- `;
205
- }
206
- function renderDismissButton(buttonTag) {
207
- return html`
208
- <${buttonTag}
209
- aria-label="${(x) => x.dismissButtonAriaLabel || x.locale.dialog.dismissButtonLabel}"
210
- size="condensed"
211
- class="dismiss-button"
212
- icon="close-line"
213
- @click="${(x) => x.open = false}"
214
- ></${buttonTag}>`;
215
- }
216
- function handleEscapeKey(dialog, event) {
217
- if (event.key === "Escape" && dialog.modal) {
218
- dialog.open = false;
392
+ const dateRangePickerDefinition = DateRangePicker.compose({
393
+ baseName: "date-range-picker",
394
+ template: DatePickerBaseTemplate,
395
+ styles,
396
+ shadowOptions: {
397
+ delegatesFocus: true
219
398
  }
220
- return true;
221
- }
222
- const DialogTemplate = (context) => {
223
- const elevationTag = context.tagFor(Elevation);
224
- const iconTag = context.tagFor(Icon);
225
- const buttonTag = context.tagFor(Button);
226
- return html`
227
- <${elevationTag} dp="8">
228
- <dialog class="${getClasses}"
229
- @keydown="${(x, c) => handleEscapeKey(x, c.event)}"
230
- returnValue="${(x) => x.returnValue}"
231
- aria-labelledby="${(x) => x.ariaLabelledBy}"
232
- aria-label="${(x) => x.ariaLabel}"
233
- aria-describedby="${(x) => x.ariaDescribedBy}"
234
- >
235
- <slot name="main">
236
- <div class="main-wrapper">
237
- <div class="header ${(x) => x.subtitle ? "border" : ""}">
238
- <slot name="graphic">
239
- ${when((x) => x.icon, icon(iconTag))}
240
- </slot>
241
- ${when((x) => x.headline, headline())}
242
- ${when((x) => x.subtitle, subtitle())}
243
- ${renderDismissButton(buttonTag)}
244
- </div>
245
- <div class="body ${(x) => x.fullWidthBody ? "full-width" : ""}" >
246
- <slot name="body" ${slotted("bodySlottedContent")}></slot>
247
- </div>
248
- <div class="footer">
249
- <div>
250
- <slot name="footer" ${slotted("footerSlottedContent")}></slot>
251
- </div>
252
- <div class="actions">
253
- <slot name="action-items" ${slotted("actionItemsSlottedContent")}></slot>
254
- </div>
255
- </div>
256
- </div>
257
- </slot>
258
- </dialog>
259
- </${elevationTag}>`;
260
- };
261
-
262
- const dialogDefinition = Dialog.compose({
263
- baseName: "dialog",
264
- template: DialogTemplate,
265
- styles: isDialogSupported ? [styles] : [styles, dialogPolyfillStyles]
266
399
  });
267
- const dialogRegistries = [dialogDefinition(), ...iconRegistries, ...buttonRegistries, ...elevationRegistries];
268
- const registerDialog = registerFactory(dialogRegistries);
400
+ const dateRangePickerRegistries = [
401
+ dateRangePickerDefinition(),
402
+ ...buttonRegistries,
403
+ ...popupRegistries,
404
+ ...textFieldRegistries,
405
+ ...focusRegistries,
406
+ ...dividerRegistries
407
+ ];
408
+ const registerDateRangePicker = registerFactory(
409
+ dateRangePickerRegistries
410
+ );
269
411
 
270
- export { dialogRegistries as a, dialogDefinition as d, registerDialog as r };
412
+ export { dateRangePickerRegistries as a, dateRangePickerDefinition as d, registerDateRangePicker as r };
@@ -186,7 +186,7 @@ __decorate([
186
186
  observable
187
187
  ], Accordion$1.prototype, "accordionItems", void 0);
188
188
 
189
- const styles = "/**\n * Do not edit directly\n * Generated on Wed, 01 Nov 2023 12:16:28 GMT\n */\n.base {\n display: flex;\n box-sizing: border-box;\n flex-direction: column;\n}\n\n::slotted(:not(:only-of-type)) {\n border-bottom: 1px solid var(--vvd-color-neutral-200);\n}";
189
+ const styles = "/**\n * Do not edit directly\n * Generated on Thu, 30 Nov 2023 11:42:28 GMT\n */\n.base {\n display: flex;\n box-sizing: border-box;\n flex-direction: column;\n}\n\n::slotted(:not(:only-of-type)) {\n border-bottom: 1px solid var(--vvd-color-neutral-200);\n}";
190
190
 
191
191
  class Accordion extends Accordion$1 {
192
192
  constructor() {