@vonage/vivid 3.39.0 → 3.41.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 (182) hide show
  1. package/accordion/index.js +2 -2
  2. package/accordion-item/index.js +2 -2
  3. package/alert/index.js +7 -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 +9 -5
  8. package/breadcrumb/index.js +1 -1
  9. package/breadcrumb-item/index.js +3 -3
  10. package/button/index.js +5 -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 +9 -7
  16. package/custom-elements.json +809 -5
  17. package/data-grid/index.js +3 -2
  18. package/date-picker/index.js +11 -9
  19. package/date-range-picker/index.js +11 -9
  20. package/dialog/index.js +10 -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 +6 -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 +60 -55
  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 +2 -0
  43. package/lib/components.d.ts +2 -0
  44. package/lib/dialog/dialog.d.ts +4 -0
  45. package/lib/dialog/locale.d.ts +3 -0
  46. package/lib/enums.d.ts +2 -1
  47. package/lib/menu/menu.d.ts +1 -0
  48. package/lib/number-field/locale.d.ts +4 -0
  49. package/lib/number-field/number-field.d.ts +4 -2
  50. package/lib/progress/progress.d.ts +1 -0
  51. package/lib/progress-ring/progress-ring.d.ts +1 -0
  52. package/lib/radio/radio.d.ts +1 -0
  53. package/lib/selectable-box/definition.d.ts +3 -0
  54. package/lib/selectable-box/selectable-box.d.ts +12 -0
  55. package/lib/selectable-box/selectable-box.template.d.ts +4 -0
  56. package/lib/slider/definition.d.ts +1 -0
  57. package/lib/slider/slider.d.ts +5 -0
  58. package/lib/split-button/locale.d.ts +3 -0
  59. package/lib/split-button/split-button.d.ts +3 -1
  60. package/lib/text-area/text-area.d.ts +3 -0
  61. package/lib/text-field/text-field.d.ts +5 -2
  62. package/listbox/index.js +5 -4
  63. package/locales/en-GB.js +21 -0
  64. package/locales/en-US.js +21 -0
  65. package/locales/ja-JP.js +21 -0
  66. package/locales/zh-CN.js +21 -0
  67. package/menu/index.js +9 -8
  68. package/menu-item/index.js +3 -3
  69. package/nav/index.js +1 -1
  70. package/nav-disclosure/index.js +3 -3
  71. package/nav-item/index.js +3 -3
  72. package/note/index.js +2 -2
  73. package/number-field/index.js +8 -6
  74. package/option/index.js +3 -3
  75. package/package.json +1 -1
  76. package/pagination/index.js +6 -5
  77. package/popup/index.js +7 -6
  78. package/progress/index.js +1 -1
  79. package/progress-ring/index.js +1 -1
  80. package/radio/index.js +2 -2
  81. package/radio-group/index.js +2 -2
  82. package/select/index.js +10 -8
  83. package/selectable-box/index.js +23 -0
  84. package/shared/Reflector.js +65 -0
  85. package/shared/date-picker/calendar/segment.d.ts +21 -0
  86. package/shared/date-picker/date-picker-base.d.ts +1 -0
  87. package/shared/definition.js +3 -3
  88. package/shared/definition10.js +89 -227
  89. package/shared/definition11.js +151 -29
  90. package/shared/definition12.js +37 -766
  91. package/shared/definition13.js +747 -106
  92. package/shared/definition14.js +122 -192
  93. package/shared/definition15.js +156 -664
  94. package/shared/definition16.js +576 -1123
  95. package/shared/definition17.js +1278 -143
  96. package/shared/definition18.js +64 -298
  97. package/shared/definition19.js +358 -211
  98. package/shared/definition2.js +2 -2
  99. package/shared/definition20.js +259 -67
  100. package/shared/definition21.js +66 -58
  101. package/shared/definition22.js +43 -84
  102. package/shared/definition23.js +76 -2352
  103. package/shared/definition24.js +2362 -45
  104. package/shared/definition25.js +63 -27
  105. package/shared/definition26.js +24 -51
  106. package/shared/definition27.js +36 -813
  107. package/shared/definition28.js +837 -49
  108. package/shared/definition29.js +52 -89
  109. package/shared/definition3.js +1 -1
  110. package/shared/definition30.js +88 -24
  111. package/shared/definition31.js +25 -12
  112. package/shared/definition32.js +12 -52
  113. package/shared/definition33.js +28 -487
  114. package/shared/definition34.js +442 -197
  115. package/shared/definition35.js +260 -185
  116. package/shared/definition36.js +188 -69
  117. package/shared/definition37.js +72 -52
  118. package/shared/definition38.js +65 -421
  119. package/shared/definition39.js +435 -35
  120. package/shared/definition4.js +44 -16
  121. package/shared/definition40.js +32 -680
  122. package/shared/definition41.js +661 -77
  123. package/shared/definition42.js +103 -555
  124. package/shared/definition43.js +76 -103
  125. package/shared/definition44.js +522 -87
  126. package/shared/definition45.js +133 -22
  127. package/shared/definition46.js +131 -58
  128. package/shared/definition47.js +16 -501
  129. package/shared/definition48.js +69 -23
  130. package/shared/definition49.js +477 -108
  131. package/shared/definition5.js +160 -44
  132. package/shared/definition50.js +25 -271
  133. package/shared/definition51.js +103 -122
  134. package/shared/definition52.js +277 -122
  135. package/shared/definition53.js +274 -103
  136. package/shared/definition54.js +126 -71
  137. package/shared/definition55.js +128 -294
  138. package/shared/definition56.js +91 -13
  139. package/shared/definition57.js +298 -39
  140. package/shared/definition58.js +11 -175
  141. package/shared/definition59.js +47 -0
  142. package/shared/definition6.js +43 -33
  143. package/shared/definition60.js +181 -0
  144. package/shared/definition7.js +39 -105
  145. package/shared/definition8.js +122 -38
  146. package/shared/definition9.js +56 -89
  147. package/shared/enums.js +72 -0
  148. package/shared/icon.js +2 -2
  149. package/shared/index2.js +28 -1
  150. package/shared/key-codes.js +1 -1
  151. package/shared/key-codes2.js +9 -0
  152. package/shared/listbox.js +3 -8
  153. package/shared/localization/Locale.d.ts +12 -0
  154. package/shared/patterns/form-elements/form-elements.d.ts +6 -6
  155. package/shared/presentationDate.js +196 -143
  156. package/shared/radio.js +7 -0
  157. package/shared/text-field.js +1 -1
  158. package/shared/utils/Reflector.d.ts +8 -0
  159. package/shared/utils/randomId.d.ts +1 -0
  160. package/side-drawer/index.js +1 -1
  161. package/slider/index.js +3 -3
  162. package/split-button/index.js +6 -3
  163. package/style.css +889 -722
  164. package/styles/core/all.css +1 -1
  165. package/styles/core/theme.css +1 -1
  166. package/styles/core/typography.css +1 -1
  167. package/styles/tokens/theme-dark.css +4 -4
  168. package/styles/tokens/theme-light.css +4 -4
  169. package/styles/tokens/vivid-2-compat.css +1 -1
  170. package/switch/index.js +3 -3
  171. package/tab/index.js +3 -3
  172. package/tab-panel/index.js +1 -1
  173. package/tabs/index.js +5 -5
  174. package/tag/index.js +3 -3
  175. package/tag-group/index.js +1 -1
  176. package/text-area/index.js +4 -3
  177. package/text-field/index.js +4 -3
  178. package/toggletip/index.js +8 -7
  179. package/tooltip/index.js +8 -7
  180. package/tree-item/index.js +3 -3
  181. package/tree-view/index.js +1 -1
  182. package/vivid.api.json +392 -0
@@ -1,15 +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 './definition57.js';
5
- import { I as Icon } from './icon.js';
6
- import { w as when } from './when.js';
7
- import { s as slotted } from './slotted.js';
8
- import { c as classNames } from './class-names.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';
8
+ import './affix.js';
9
+ import { e as errorText, f as formElements } from './index2.js';
9
10
 
10
- 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}";
11
-
12
- const styles = "/**\n * Do not edit directly\n * Generated on Tue, 17 Oct 2023 15:27:52 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
+ };
13
25
 
14
26
  var __defProp = Object.defineProperty;
15
27
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -22,241 +34,376 @@ var __decorateClass = (decorators, target, key, kind) => {
22
34
  __defProp(target, key, result);
23
35
  return result;
24
36
  };
25
- const isDialogSupported = Boolean(HTMLDialogElement && HTMLDialogElement.prototype.showModal);
26
- let dialogPolyfill;
27
- (async () => {
28
- if (!isDialogSupported) {
29
- delete window.HTMLDialogElement;
30
- dialogPolyfill = await import('./dialog-polyfill.esm.js');
31
- }
32
- })();
33
- 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 {
34
42
  constructor() {
35
43
  super(...arguments);
36
- this.open = false;
37
- this.fullWidthBody = false;
38
- this.ariaLabelledBy = null;
39
- this.ariaLabel = null;
40
- this.ariaDescribedBy = null;
41
- this.#modal = false;
42
- this.#handleScrimClick = (event) => {
43
- 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)) {
44
51
  return;
45
52
  }
46
- const rect = this.#dialog.getBoundingClientRect();
47
- const clickedInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
48
- this.open = clickedInDialog;
53
+ super.setFormValue(value, state);
49
54
  };
50
- this.#handleInternalFormSubmit = (event) => {
51
- 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 });
52
143
  return;
53
144
  }
54
- this.open = false;
55
- };
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();
56
162
  }
57
- #modal;
58
- set returnValue(value) {
59
- this.#dialog.returnValue = value;
163
+ /**
164
+ * @internal
165
+ */
166
+ nameChanged(previous, next) {
167
+ super.nameChanged(previous, next);
168
+ this.#updateFormValue();
60
169
  }
61
- get returnValue() {
62
- 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
+ }
63
179
  }
64
- get modal() {
65
- 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
+ }
66
188
  }
67
- #dialogElement;
68
- get #dialog() {
69
- if (!this.#dialogElement) {
70
- this.#dialogElement = this.shadowRoot.querySelector("dialog");
71
- if (this.#dialogElement) {
72
- this.#dialogElement.open = this.open;
73
- if (dialogPolyfill) {
74
- dialogPolyfill.registerDialog(this.#dialogElement);
75
- }
76
- }
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);
77
194
  }
78
- return this.#dialogElement;
195
+ const [start, end] = candidates.sort(compareDateStr);
196
+ return { start, end };
79
197
  }
80
- openChanged(oldValue, newValue) {
81
- if (oldValue === void 0) {
82
- 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);
83
233
  }
84
- if (!newValue) {
85
- 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();
86
251
  } else {
87
- if (this.#dialog) {
88
- this.#dialog.open = true;
89
- }
252
+ this.#updateValues({ start: date });
90
253
  }
91
254
  }
92
- #handleScrimClick;
93
- #handleInternalFormSubmit;
94
- close() {
95
- if (this.#dialog.open) {
96
- this.#dialog.close();
97
- 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;
98
280
  }
99
- this.open = false;
100
- this.#handleModal(false);
101
281
  }
102
- #handleModal(show) {
103
- this.#modal = show;
104
- this.#dialog.toggleAttribute("aria-modal", show);
105
- this.#dialog.classList.toggle("modal", show);
282
+ /**
283
+ * @internal
284
+ */
285
+ _onDateMouseEnter(date) {
286
+ this._hoverDate = date;
106
287
  }
107
- show() {
108
- this.#dialog.show();
109
- this.open = true;
288
+ /**
289
+ * @internal
290
+ */
291
+ _onDateMouseLeave() {
292
+ this._hoverDate = void 0;
110
293
  }
111
- showModal() {
112
- this.#handleModal(true);
113
- this.#dialog.showModal();
114
- 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;
115
312
  }
116
- connectedCallback() {
117
- super.connectedCallback();
118
- this.#dialog.addEventListener("mousedown", this.#handleScrimClick);
119
- 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
+ }
120
329
  }
121
- disconnectedCallback() {
122
- super.disconnectedCallback();
123
- this.#dialog.removeEventListener("mousedown", this.#handleScrimClick);
124
- this.#dialog.removeEventListener("submit", this.#handleInternalFormSubmit);
330
+ /**
331
+ * @internal
332
+ */
333
+ _onClearClick() {
334
+ this.#updateValues({ start: "", end: "" });
335
+ super._onClearClick();
125
336
  }
126
- }
127
- __decorateClass([
128
- attr({ mode: "boolean" })
129
- ], Dialog.prototype, "open", 2);
130
- __decorateClass([
131
- attr
132
- ], Dialog.prototype, "icon", 2);
133
- __decorateClass([
134
- attr({ attribute: "icon-placement" })
135
- ], Dialog.prototype, "iconPlacement", 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
+ };
136
360
  __decorateClass([
137
- attr
138
- ], Dialog.prototype, "subtitle", 2);
361
+ attr({ mode: "fromView", attribute: "start" })
362
+ ], DateRangePicker.prototype, "initialStart", 2);
139
363
  __decorateClass([
140
- attr
141
- ], Dialog.prototype, "headline", 2);
364
+ attr({ mode: "fromView", attribute: "end" })
365
+ ], DateRangePicker.prototype, "initialEnd", 2);
142
366
  __decorateClass([
143
- attr({ attribute: "full-width-body", mode: "boolean" })
144
- ], Dialog.prototype, "fullWidthBody", 2);
367
+ observable
368
+ ], DateRangePicker.prototype, "start", 2);
145
369
  __decorateClass([
146
- attr({ attribute: "aria-labelledby" })
147
- ], Dialog.prototype, "ariaLabelledBy", 2);
370
+ observable
371
+ ], DateRangePicker.prototype, "end", 2);
148
372
  __decorateClass([
149
- attr({ attribute: "aria-label" })
150
- ], Dialog.prototype, "ariaLabel", 2);
373
+ attr({ attribute: "current-start" })
374
+ ], DateRangePicker.prototype, "currentStart", 2);
151
375
  __decorateClass([
152
- attr({ attribute: "aria-describedby" })
153
- ], Dialog.prototype, "ariaDescribedBy", 2);
376
+ attr({ attribute: "current-end" })
377
+ ], DateRangePicker.prototype, "currentEnd", 2);
154
378
  __decorateClass([
155
379
  observable
156
- ], Dialog.prototype, "bodySlottedContent", 2);
380
+ ], DateRangePicker.prototype, "_numCalendars", 2);
157
381
  __decorateClass([
158
382
  observable
159
- ], Dialog.prototype, "footerSlottedContent", 2);
383
+ ], DateRangePicker.prototype, "_hoverDate", 2);
160
384
  __decorateClass([
161
- observable
162
- ], Dialog.prototype, "actionItemsSlottedContent", 2);
385
+ volatile
386
+ ], DateRangePicker.prototype, "_calendarButtonLabel", 1);
387
+ DateRangePicker = __decorateClass([
388
+ errorText,
389
+ formElements
390
+ ], DateRangePicker);
163
391
 
164
- const getClasses = ({
165
- iconPlacement,
166
- bodySlottedContent,
167
- footerSlottedContent,
168
- actionItemsSlottedContent
169
- }) => classNames(
170
- "base",
171
- [`icon-placement-${iconPlacement}`, Boolean(iconPlacement)],
172
- ["hide-body", !bodySlottedContent?.length],
173
- [
174
- "hide-footer",
175
- !(footerSlottedContent?.length || actionItemsSlottedContent?.length)
176
- ]
177
- );
178
- function icon(iconTag) {
179
- return html`
180
- <${iconTag} class="icon" name="${(x) => x.icon}"></${iconTag}>
181
- `;
182
- }
183
- function headline() {
184
- return html`
185
- <div class="headline">
186
- ${(x) => x.headline}
187
- </div>
188
- `;
189
- }
190
- function subtitle() {
191
- return html`
192
- <div class="subtitle">
193
- ${(x) => x.subtitle}
194
- </div>
195
- `;
196
- }
197
- function renderDismissButton(buttonTag) {
198
- return html`
199
- <${buttonTag}
200
- size="condensed"
201
- class="dismiss-button"
202
- icon="close-line"
203
- @click="${(x) => {
204
- x.open = false;
205
- }}">
206
- </${buttonTag}>`;
207
- }
208
- function handleEscapeKey(dialog, event) {
209
- if (event.key === "Escape" && dialog.modal) {
210
- dialog.open = false;
211
- }
212
- return true;
213
- }
214
- const DialogTemplate = (context) => {
215
- const elevationTag = context.tagFor(Elevation);
216
- const iconTag = context.tagFor(Icon);
217
- const buttonTag = context.tagFor(Button);
218
- return html`
219
- <${elevationTag} dp="8">
220
- <dialog class="${getClasses}"
221
- @keydown="${(x, c) => handleEscapeKey(x, c.event)}"
222
- returnValue="${(x) => x.returnValue}"
223
- aria-labelledby="${(x) => x.ariaLabelledBy}"
224
- aria-label="${(x) => x.ariaLabel}"
225
- aria-describedby="${(x) => x.ariaDescribedBy}"
226
- >
227
- <slot name="main">
228
- <div class="main-wrapper">
229
- <div class="header ${(x) => x.subtitle ? "border" : ""}">
230
- <slot name="graphic">
231
- ${when((x) => x.icon, icon(iconTag))}
232
- </slot>
233
- ${when((x) => x.headline, headline())}
234
- ${when((x) => x.subtitle, subtitle())}
235
- ${renderDismissButton(buttonTag)}
236
- </div>
237
- <div class="body ${(x) => x.fullWidthBody ? "full-width" : ""}" >
238
- <slot name="body" ${slotted("bodySlottedContent")}></slot>
239
- </div>
240
- <div class="footer">
241
- <div>
242
- <slot name="footer" ${slotted("footerSlottedContent")}></slot>
243
- </div>
244
- <div class="actions">
245
- <slot name="action-items" ${slotted("actionItemsSlottedContent")}></slot>
246
- </div>
247
- </div>
248
- </div>
249
- </slot>
250
- </dialog>
251
- </${elevationTag}>`;
252
- };
253
-
254
- const dialogDefinition = Dialog.compose({
255
- baseName: "dialog",
256
- template: DialogTemplate,
257
- styles: isDialogSupported ? [styles] : [styles, dialogPolyfillStyles]
392
+ const dateRangePickerDefinition = DateRangePicker.compose({
393
+ baseName: "date-range-picker",
394
+ template: DatePickerBaseTemplate,
395
+ styles
258
396
  });
259
- const dialogRegistries = [dialogDefinition(), ...iconRegistries, ...buttonRegistries, ...elevationRegistries];
260
- const registerDialog = registerFactory(dialogRegistries);
397
+ const dateRangePickerRegistries = [
398
+ dateRangePickerDefinition(),
399
+ ...buttonRegistries,
400
+ ...popupRegistries,
401
+ ...textFieldRegistries,
402
+ ...focusRegistries,
403
+ ...dividerRegistries
404
+ ];
405
+ const registerDateRangePicker = registerFactory(
406
+ dateRangePickerRegistries
407
+ );
261
408
 
262
- export { dialogRegistries as a, dialogDefinition as d, registerDialog as r };
409
+ export { dateRangePickerRegistries as a, dateRangePickerDefinition as d, registerDateRangePicker as r };
@@ -1,6 +1,6 @@
1
1
  import { F as FoundationElement, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
2
  import { A as AccordionItem$1, b as accordionItemRegistries } from './definition.js';
3
- import { b as keyEnd, c as keyHome, d as keyArrowDown, e as keyArrowUp } from './key-codes.js';
3
+ import { d as keyEnd, g as keyHome, f as keyArrowDown, e as keyArrowUp } from './key-codes.js';
4
4
  import { w as wrapInBounds } from './numbers.js';
5
5
  import { s as slotted, e as elements } from './slotted.js';
6
6
  import { c as classNames } from './class-names.js';
@@ -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 Tue, 17 Oct 2023 15:27:52 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 Wed, 22 Nov 2023 16:09:43 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() {