@vonage/vivid 3.37.0 → 3.39.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 (157) hide show
  1. package/accordion/index.js +2 -2
  2. package/accordion-item/index.js +2 -2
  3. package/alert/index.js +4 -4
  4. package/avatar/index.js +1 -1
  5. package/badge/index.js +1 -1
  6. package/banner/index.js +3 -3
  7. package/breadcrumb-item/index.js +2 -2
  8. package/button/index.js +3 -3
  9. package/card/index.js +2 -2
  10. package/checkbox/index.js +2 -2
  11. package/combobox/index.js +6 -6
  12. package/custom-elements.json +4199 -3875
  13. package/data-grid/index.js +1 -1
  14. package/date-picker/index.js +9 -7
  15. package/date-range-picker/index.js +36 -0
  16. package/dialog/index.js +5 -5
  17. package/divider/index.js +1 -1
  18. package/elevation/index.js +1 -1
  19. package/empty-state/index.js +2 -2
  20. package/fab/index.js +3 -3
  21. package/file-picker/index.js +5 -4
  22. package/focus/index.js +1 -1
  23. package/header/index.js +2 -2
  24. package/icon/index.js +1 -1
  25. package/index.js +43 -40
  26. package/layout/index.js +1 -1
  27. package/lib/components.d.ts +1 -0
  28. package/lib/date-picker/date-picker.d.ts +4 -14
  29. package/lib/date-range-picker/date-range-picker.d.ts +15 -0
  30. package/lib/date-range-picker/definition.d.ts +3 -0
  31. package/lib/file-picker/file-picker.d.ts +8 -5
  32. package/lib/file-picker/file-picker.form-associated.d.ts +10 -0
  33. package/lib/file-picker/locale.d.ts +6 -0
  34. package/lib/menu-item/menu-item.d.ts +6 -0
  35. package/lib/tag-group/tag-group.d.ts +1 -0
  36. package/listbox/index.js +4 -4
  37. package/locales/en-GB.js +27 -3
  38. package/locales/en-US.js +27 -3
  39. package/locales/ja-JP.js +25 -1
  40. package/locales/zh-CN.js +25 -1
  41. package/menu/index.js +7 -7
  42. package/menu-item/index.js +3 -3
  43. package/nav/index.js +1 -1
  44. package/nav-disclosure/index.js +3 -3
  45. package/nav-item/index.js +3 -3
  46. package/note/index.js +2 -2
  47. package/number-field/index.js +5 -5
  48. package/option/index.js +3 -3
  49. package/package.json +1 -1
  50. package/pagination/index.js +4 -4
  51. package/popup/index.js +5 -5
  52. package/progress/index.js +1 -1
  53. package/progress-ring/index.js +1 -1
  54. package/radio/index.js +2 -2
  55. package/radio-group/index.js +1 -1
  56. package/select/index.js +7 -7
  57. package/shared/date-picker/calendar/dateRange.d.ts +5 -0
  58. package/shared/date-picker/calendar/presentationDateRange.d.ts +5 -0
  59. package/shared/date-picker/date-picker-base.d.ts +19 -0
  60. package/shared/date-picker/date-picker-base.form-associated.d.ts +10 -0
  61. package/shared/date-picker/date-picker-base.template.d.ts +4 -0
  62. package/{lib → shared}/date-picker/locale.d.ts +6 -0
  63. package/shared/definition.js +4 -4
  64. package/shared/definition10.js +9 -14
  65. package/shared/definition11.js +1 -1
  66. package/shared/definition12.js +1 -1
  67. package/shared/definition13.js +3 -3
  68. package/shared/definition14.js +3 -3
  69. package/shared/definition15.js +5 -5
  70. package/shared/definition16.js +3 -3
  71. package/shared/definition17.js +44 -6055
  72. package/shared/definition18.js +353 -213
  73. package/shared/definition19.js +251 -67
  74. package/shared/definition2.js +1 -1
  75. package/shared/definition20.js +66 -58
  76. package/shared/definition21.js +43 -84
  77. package/shared/definition22.js +75 -2298
  78. package/shared/definition23.js +2361 -45
  79. package/shared/definition24.js +63 -27
  80. package/shared/definition25.js +24 -51
  81. package/shared/definition26.js +36 -805
  82. package/shared/definition27.js +828 -49
  83. package/shared/definition28.js +52 -89
  84. package/shared/definition29.js +88 -24
  85. package/shared/definition3.js +1 -1
  86. package/shared/definition30.js +25 -12
  87. package/shared/definition31.js +12 -53
  88. package/shared/definition32.js +28 -487
  89. package/shared/definition33.js +427 -197
  90. package/shared/definition34.js +260 -174
  91. package/shared/definition35.js +187 -69
  92. package/shared/definition36.js +68 -55
  93. package/shared/definition37.js +61 -421
  94. package/shared/definition38.js +435 -35
  95. package/shared/definition39.js +30 -679
  96. package/shared/definition4.js +3 -3
  97. package/shared/definition40.js +661 -77
  98. package/shared/definition41.js +77 -557
  99. package/shared/definition42.js +559 -106
  100. package/shared/definition43.js +105 -136
  101. package/shared/definition44.js +153 -17
  102. package/shared/definition45.js +16 -79
  103. package/shared/definition46.js +53 -475
  104. package/shared/definition47.js +506 -20
  105. package/shared/definition48.js +22 -121
  106. package/shared/definition49.js +115 -262
  107. package/shared/definition5.js +2 -2
  108. package/shared/definition50.js +248 -120
  109. package/shared/definition51.js +139 -123
  110. package/shared/definition52.js +84 -74
  111. package/shared/definition53.js +114 -69
  112. package/shared/definition54.js +81 -292
  113. package/shared/definition55.js +302 -13
  114. package/shared/definition56.js +11 -41
  115. package/shared/definition57.js +20 -154
  116. package/shared/definition58.js +181 -0
  117. package/shared/definition6.js +2 -2
  118. package/shared/definition7.js +2 -2
  119. package/shared/definition8.js +3 -3
  120. package/shared/index2.js +1 -1
  121. package/shared/listbox.js +1 -1
  122. package/shared/localization/Locale.d.ts +3 -1
  123. package/shared/localized.js +9 -0
  124. package/shared/presentationDate.js +6133 -0
  125. package/shared/text-anchor.template.js +4 -4
  126. package/shared/text-field.js +1 -1
  127. package/side-drawer/index.js +1 -1
  128. package/slider/index.js +2 -2
  129. package/split-button/index.js +3 -3
  130. package/style.css +246 -183
  131. package/styles/core/all.css +1 -1
  132. package/styles/core/theme.css +1 -1
  133. package/styles/core/typography.css +1 -1
  134. package/styles/tokens/theme-dark.css +4 -4
  135. package/styles/tokens/theme-light.css +4 -4
  136. package/styles/tokens/vivid-2-compat.css +1 -1
  137. package/switch/index.js +3 -3
  138. package/tab/index.js +3 -3
  139. package/tab-panel/index.js +1 -1
  140. package/tabs/index.js +5 -5
  141. package/tag/index.js +3 -3
  142. package/tag-group/index.js +1 -1
  143. package/text-area/index.js +3 -3
  144. package/text-field/index.js +3 -3
  145. package/toggletip/index.js +6 -6
  146. package/tooltip/index.js +6 -6
  147. package/tree-item/index.js +3 -3
  148. package/tree-view/index.js +1 -1
  149. package/vivid.api.json +105 -0
  150. package/lib/date-picker/date-picker.form-associated.d.ts +0 -11
  151. package/lib/date-picker/date-picker.template.d.ts +0 -4
  152. /package/{lib → shared}/date-picker/calendar/calendarGrid.d.ts +0 -0
  153. /package/{lib → shared}/date-picker/calendar/dateStr.d.ts +0 -0
  154. /package/{lib → shared}/date-picker/calendar/month.d.ts +0 -0
  155. /package/{lib → shared}/date-picker/calendar/monthPickerGrid.d.ts +0 -0
  156. /package/{lib → shared}/date-picker/calendar/presentationDate.d.ts +0 -0
  157. /package/{lib → shared}/date-picker/calendar/year.d.ts +0 -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 './definition24.js';
3
- import { B as Button, a as buttonRegistries } from './definition10.js';
4
- import { E as Elevation, e as elevationRegistries } from './definition56.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 './definition10.js';
3
+ import { p as popupRegistries } from './definition58.js';
4
+ import { a as textFieldRegistries } from './definition51.js';
5
+ import { f as focusRegistries } from './definition56.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, m as monthOfDate, 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, 26 Sep 2023 13:00:58 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,369 @@ 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
+ /**
56
+ * @internal
57
+ */
58
+ this._textFieldSize = "30";
59
+ }
60
+ /**
61
+ * @internal
62
+ */
63
+ initialStartChanged() {
64
+ if (!this.dirtyValue) {
65
+ this.start = this.initialStart;
66
+ this.dirtyValue = false;
67
+ }
68
+ }
69
+ /**
70
+ * @internal
71
+ */
72
+ initialEndChanged() {
73
+ if (!this.dirtyValue) {
74
+ this.end = this.initialEnd;
75
+ this.dirtyValue = false;
76
+ }
77
+ }
78
+ #isInternalValueUpdate;
79
+ /**
80
+ * @internal
81
+ */
82
+ startChanged() {
83
+ if (this.start && !isValidDateStr(this.start)) {
84
+ this.start = "";
85
+ return;
86
+ }
87
+ this.currentStart = this.start;
88
+ this.dirtyValue = true;
89
+ if (!this.#isInternalValueUpdate) {
90
+ this.#handleChangedValues();
91
+ }
92
+ }
93
+ /**
94
+ * @internal
95
+ */
96
+ endChanged() {
97
+ if (this.end && !isValidDateStr(this.end)) {
98
+ this.end = "";
99
+ return;
100
+ }
101
+ this.currentEnd = this.end;
102
+ this.dirtyValue = true;
103
+ if (!this.#isInternalValueUpdate) {
104
+ this.#handleChangedValues();
105
+ }
106
+ }
107
+ /**
108
+ * @internal
109
+ */
110
+ currentStartChanged() {
111
+ this.start = this.currentStart;
112
+ }
113
+ /**
114
+ * @internal
115
+ */
116
+ currentEndChanged() {
117
+ this.end = this.currentEnd;
118
+ }
119
+ #updateValues(range) {
120
+ this.#isInternalValueUpdate = true;
121
+ if (range.start !== void 0) {
122
+ this.start = range.start;
123
+ this.$emit("input:start");
124
+ }
125
+ if (range.end !== void 0) {
126
+ this.end = range.end;
127
+ this.$emit("input:end");
128
+ }
129
+ this.#isInternalValueUpdate = false;
130
+ this.$emit("input");
131
+ this.$emit("change");
132
+ this.#handleChangedValues();
133
+ }
134
+ #handleChangedValues() {
135
+ if (this.start && this.end) {
136
+ if (compareDateStr(this.start, this.end) > 0) {
137
+ this.#updateValues({ start: this.end, end: this.start });
52
138
  return;
53
139
  }
54
- this.open = false;
55
- };
140
+ this._presentationValue = formatPresentationDateRange(
141
+ {
142
+ start: this.start,
143
+ end: this.end
144
+ },
145
+ this.locale.datePicker
146
+ );
147
+ this.value = formatRange(this.start, this.end);
148
+ } else {
149
+ this.value = "";
150
+ this._presentationValue = "";
151
+ }
152
+ if (this.start) {
153
+ this._selectedMonth = monthOfDate(this.start);
154
+ } else if (this.end) {
155
+ this._selectedMonth = monthOfDate(this.end);
156
+ }
157
+ this.#updateFormValue();
158
+ }
159
+ /**
160
+ * @internal
161
+ */
162
+ nameChanged(previous, next) {
163
+ super.nameChanged(previous, next);
164
+ this.#updateFormValue();
56
165
  }
57
- #modal;
58
- set returnValue(value) {
59
- this.#dialog.returnValue = value;
166
+ #updateFormValue() {
167
+ if (!this.name || !this.start || !this.end) {
168
+ this.setFormValue(null);
169
+ } else {
170
+ const formData = new FormData();
171
+ formData.append(this.name, this.start);
172
+ formData.append(this.name, this.end);
173
+ this.setFormValue(formData);
174
+ }
175
+ }
176
+ connectedCallback() {
177
+ super.connectedCallback();
178
+ if (!this.start) {
179
+ this.start = this.initialStart;
180
+ }
181
+ if (!this.end) {
182
+ this.end = this.initialEnd;
183
+ }
60
184
  }
61
- get returnValue() {
62
- return this.#dialog?.returnValue;
185
+ #getVisibleRange() {
186
+ const candidates = [this.start, this.end].filter(isDefined);
187
+ const isPartialRange = candidates.length === 1;
188
+ if (this._hoverDate && isPartialRange) {
189
+ candidates.push(this._hoverDate);
190
+ }
191
+ const [start, end] = candidates.sort(compareDateStr);
192
+ return { start, end };
63
193
  }
64
- get modal() {
65
- return this.#modal;
194
+ /**
195
+ * @internal
196
+ */
197
+ _isDateAriaSelected(date) {
198
+ return date === this.start || date === this.end;
66
199
  }
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
- }
200
+ /**
201
+ * @internal
202
+ */
203
+ _isDateInSelectedRange(date) {
204
+ const { start, end } = this.#getVisibleRange();
205
+ if (start && end) {
206
+ return compareDateStr(date, start) >= 0 && compareDateStr(date, end) <= 0;
77
207
  }
78
- return this.#dialogElement;
208
+ return false;
79
209
  }
80
- openChanged(oldValue, newValue) {
81
- if (oldValue === void 0) {
82
- return;
210
+ /**
211
+ * @internal
212
+ */
213
+ _isDateRangeStart(date) {
214
+ return date === this.#getVisibleRange().start;
215
+ }
216
+ /**
217
+ * @internal
218
+ */
219
+ _isDateRangeEnd(date) {
220
+ return date === this.#getVisibleRange().end;
221
+ }
222
+ /**
223
+ * @internal
224
+ */
225
+ _getSelectedDates() {
226
+ const dates = [];
227
+ if (this.start) {
228
+ dates.push(this.start);
229
+ }
230
+ if (this.end) {
231
+ dates.push(this.end);
83
232
  }
84
- if (!newValue) {
85
- this.close();
233
+ return dates;
234
+ }
235
+ /**
236
+ * @internal
237
+ */
238
+ _onDateClick(date) {
239
+ if (this.start && this.end) {
240
+ this.#updateValues({ start: date, end: "" });
241
+ } else if (this.start) {
242
+ this.#updateValues({ end: date });
243
+ this._closePopup();
244
+ } else if (this.end) {
245
+ this.#updateValues({ start: date });
246
+ this._closePopup();
86
247
  } else {
87
- if (this.#dialog) {
88
- this.#dialog.open = true;
89
- }
248
+ this.#updateValues({ start: date });
90
249
  }
91
250
  }
92
- #handleScrimClick;
93
- #handleInternalFormSubmit;
94
- close() {
95
- if (this.#dialog.open) {
96
- this.#dialog.close();
97
- this.$emit("close", this.returnValue, { bubbles: false });
251
+ /**
252
+ * @internal
253
+ */
254
+ get _textFieldPlaceholder() {
255
+ return formatRange(
256
+ this.locale.datePicker.dateFormatPlaceholder,
257
+ this.locale.datePicker.dateFormatPlaceholder
258
+ );
259
+ }
260
+ /**
261
+ * @internal
262
+ */
263
+ _onTextFieldChange() {
264
+ if (this._presentationValue === "") {
265
+ this.#updateValues({ start: "", end: "" });
266
+ return;
267
+ }
268
+ try {
269
+ const { start, end } = parsePresentationDateRange(
270
+ this._presentationValue,
271
+ this.locale.datePicker
272
+ );
273
+ this.#updateValues({ start, end });
274
+ } catch (_) {
275
+ return;
98
276
  }
99
- this.open = false;
100
- this.#handleModal(false);
101
277
  }
102
- #handleModal(show) {
103
- this.#modal = show;
104
- this.#dialog.toggleAttribute("aria-modal", show);
105
- this.#dialog.classList.toggle("modal", show);
278
+ /**
279
+ * @internal
280
+ */
281
+ _onDateMouseEnter(date) {
282
+ this._hoverDate = date;
106
283
  }
107
- show() {
108
- this.#dialog.show();
109
- this.open = true;
284
+ /**
285
+ * @internal
286
+ */
287
+ _onDateMouseLeave() {
288
+ this._hoverDate = void 0;
110
289
  }
111
- showModal() {
112
- this.#handleModal(true);
113
- this.#dialog.showModal();
114
- this.open = true;
290
+ /**
291
+ * @internal
292
+ */
293
+ _getCustomValidationError() {
294
+ if (this._isPresentationValueInvalid()) {
295
+ return this.locale.datePicker.invalidDateRangeError;
296
+ }
297
+ if (this.min && this.start && compareDateStr(this.start, this.min) < 0) {
298
+ return this.locale.datePicker.startDateAfterMinDateError(
299
+ formatPresentationDate(this.min, this.locale.datePicker)
300
+ );
301
+ }
302
+ if (this.max && this.end && compareDateStr(this.end, this.max) > 0) {
303
+ return this.locale.datePicker.endDateBeforeMaxDateError(
304
+ formatPresentationDate(this.max, this.locale.datePicker)
305
+ );
306
+ }
307
+ return null;
115
308
  }
116
- connectedCallback() {
117
- super.connectedCallback();
118
- this.#dialog.addEventListener("click", this.#handleScrimClick);
119
- this.#dialog.addEventListener("submit", this.#handleInternalFormSubmit);
309
+ /**
310
+ * @internal
311
+ */
312
+ _isPresentationValueInvalid() {
313
+ if (this._presentationValue === "") {
314
+ return false;
315
+ }
316
+ try {
317
+ parsePresentationDateRange(
318
+ this._presentationValue,
319
+ this.locale.datePicker
320
+ );
321
+ return false;
322
+ } catch (_) {
323
+ return true;
324
+ }
120
325
  }
121
- disconnectedCallback() {
122
- super.disconnectedCallback();
123
- this.#dialog.removeEventListener("click", this.#handleScrimClick);
124
- this.#dialog.removeEventListener("submit", this.#handleInternalFormSubmit);
326
+ /**
327
+ * @internal
328
+ */
329
+ _onClearClick() {
330
+ this.#updateValues({ start: "", end: "" });
331
+ super._onClearClick();
125
332
  }
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);
136
- __decorateClass([
137
- attr
138
- ], Dialog.prototype, "subtitle", 2);
333
+ /**
334
+ * @internal
335
+ */
336
+ formResetCallback() {
337
+ this.#updateValues({ start: this.initialStart, end: this.initialEnd });
338
+ super.formResetCallback();
339
+ }
340
+ get _calendarButtonLabel() {
341
+ if (this.start && this.end) {
342
+ return this.locale.datePicker.changeDatesLabel(
343
+ formatPresentationDateRange(
344
+ {
345
+ start: this.start,
346
+ end: this.end
347
+ },
348
+ this.locale.datePicker
349
+ )
350
+ );
351
+ } else {
352
+ return this.locale.datePicker.chooseDatesLabel;
353
+ }
354
+ }
355
+ };
139
356
  __decorateClass([
140
- attr
141
- ], Dialog.prototype, "headline", 2);
357
+ attr({ mode: "fromView", attribute: "start" })
358
+ ], DateRangePicker.prototype, "initialStart", 2);
142
359
  __decorateClass([
143
- attr({ attribute: "full-width-body", mode: "boolean" })
144
- ], Dialog.prototype, "fullWidthBody", 2);
360
+ attr({ mode: "fromView", attribute: "end" })
361
+ ], DateRangePicker.prototype, "initialEnd", 2);
145
362
  __decorateClass([
146
- attr({ attribute: "aria-labelledby" })
147
- ], Dialog.prototype, "ariaLabelledBy", 2);
363
+ observable
364
+ ], DateRangePicker.prototype, "start", 2);
148
365
  __decorateClass([
149
- attr({ attribute: "aria-label" })
150
- ], Dialog.prototype, "ariaLabel", 2);
366
+ observable
367
+ ], DateRangePicker.prototype, "end", 2);
151
368
  __decorateClass([
152
- attr({ attribute: "aria-describedby" })
153
- ], Dialog.prototype, "ariaDescribedBy", 2);
369
+ attr({ attribute: "current-start" })
370
+ ], DateRangePicker.prototype, "currentStart", 2);
154
371
  __decorateClass([
155
- observable
156
- ], Dialog.prototype, "bodySlottedContent", 2);
372
+ attr({ attribute: "current-end" })
373
+ ], DateRangePicker.prototype, "currentEnd", 2);
157
374
  __decorateClass([
158
375
  observable
159
- ], Dialog.prototype, "footerSlottedContent", 2);
376
+ ], DateRangePicker.prototype, "_hoverDate", 2);
160
377
  __decorateClass([
161
- observable
162
- ], Dialog.prototype, "actionItemsSlottedContent", 2);
378
+ volatile
379
+ ], DateRangePicker.prototype, "_calendarButtonLabel", 1);
380
+ DateRangePicker = __decorateClass([
381
+ errorText,
382
+ formElements
383
+ ], DateRangePicker);
163
384
 
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]
385
+ const dateRangePickerDefinition = DateRangePicker.compose({
386
+ baseName: "date-range-picker",
387
+ template: DatePickerBaseTemplate,
388
+ styles
258
389
  });
259
- const dialogRegistries = [dialogDefinition(), ...iconRegistries, ...buttonRegistries, ...elevationRegistries];
260
- const registerDialog = registerFactory(dialogRegistries);
390
+ const dateRangePickerRegistries = [
391
+ dateRangePickerDefinition(),
392
+ ...buttonRegistries,
393
+ ...popupRegistries,
394
+ ...textFieldRegistries,
395
+ ...focusRegistries,
396
+ ...dividerRegistries
397
+ ];
398
+ const registerDateRangePicker = registerFactory(
399
+ dateRangePickerRegistries
400
+ );
261
401
 
262
- export { dialogRegistries as a, dialogDefinition as d, registerDialog as r };
402
+ export { dateRangePickerRegistries as a, dateRangePickerDefinition as d, registerDateRangePicker as r };