@vonage/vivid 3.36.0 → 3.38.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 (168) hide show
  1. package/accordion/index.js +3 -4
  2. package/accordion-item/index.js +3 -2
  3. package/alert/index.js +5 -4
  4. package/avatar/index.js +1 -1
  5. package/badge/index.js +2 -1
  6. package/banner/index.js +4 -3
  7. package/breadcrumb/index.js +0 -1
  8. package/breadcrumb-item/index.js +3 -2
  9. package/button/index.js +4 -3
  10. package/card/index.js +2 -3
  11. package/checkbox/index.js +3 -4
  12. package/combobox/index.js +7 -8
  13. package/custom-elements.json +386 -758
  14. package/data-grid/index.js +2 -3
  15. package/date-picker/index.js +10 -9
  16. package/date-range-picker/index.js +36 -0
  17. package/dialog/index.js +6 -7
  18. package/divider/index.js +1 -1
  19. package/elevation/index.js +1 -1
  20. package/empty-state/index.js +2 -3
  21. package/fab/index.js +4 -3
  22. package/file-picker/index.js +6 -4
  23. package/focus/index.js +1 -1
  24. package/header/index.js +2 -2
  25. package/icon/index.js +1 -1
  26. package/index.js +44 -42
  27. package/layout/index.js +1 -1
  28. package/lib/components.d.ts +1 -0
  29. package/lib/date-picker/date-picker.d.ts +5 -15
  30. package/lib/date-range-picker/date-range-picker.d.ts +16 -0
  31. package/lib/date-range-picker/definition.d.ts +3 -0
  32. package/lib/file-picker/file-picker.d.ts +8 -5
  33. package/lib/file-picker/file-picker.form-associated.d.ts +10 -0
  34. package/lib/file-picker/locale.d.ts +6 -0
  35. package/lib/number-field/number-field.d.ts +6 -2
  36. package/lib/tag-group/tag-group.d.ts +1 -0
  37. package/lib/tree-item/tree-item.template.d.ts +1 -1
  38. package/listbox/index.js +4 -5
  39. package/locales/en-GB.js +27 -3
  40. package/locales/en-US.js +27 -3
  41. package/locales/ja-JP.js +25 -1
  42. package/locales/zh-CN.js +25 -1
  43. package/menu/index.js +8 -9
  44. package/menu-item/index.js +4 -5
  45. package/nav/index.js +1 -1
  46. package/nav-disclosure/index.js +4 -3
  47. package/nav-item/index.js +4 -3
  48. package/note/index.js +3 -2
  49. package/number-field/index.js +6 -5
  50. package/option/index.js +4 -3
  51. package/package.json +1 -1
  52. package/pagination/index.js +5 -5
  53. package/popup/index.js +6 -5
  54. package/progress/index.js +1 -1
  55. package/progress-ring/index.js +1 -1
  56. package/radio/index.js +2 -2
  57. package/radio-group/index.js +2 -3
  58. package/select/index.js +8 -9
  59. package/shared/affix.js +5 -1
  60. package/shared/apply-mixins.js +1 -1
  61. package/shared/children.js +2 -2
  62. package/shared/date-picker/calendar/dateRange.d.ts +5 -0
  63. package/shared/date-picker/calendar/presentationDateRange.d.ts +5 -0
  64. package/shared/date-picker/date-picker-base.d.ts +20 -0
  65. package/shared/date-picker/date-picker-base.form-associated.d.ts +10 -0
  66. package/shared/date-picker/date-picker-base.template.d.ts +4 -0
  67. package/{lib → shared}/date-picker/locale.d.ts +6 -0
  68. package/shared/definition.js +5 -5
  69. package/shared/definition10.js +9 -14
  70. package/shared/definition11.js +1 -1
  71. package/shared/definition12.js +1 -1
  72. package/shared/definition13.js +3 -3
  73. package/shared/definition14.js +3 -3
  74. package/shared/definition15.js +5 -5
  75. package/shared/definition16.js +4 -5
  76. package/shared/definition17.js +59 -6016
  77. package/shared/definition18.js +350 -213
  78. package/shared/definition19.js +251 -67
  79. package/shared/definition2.js +2 -3
  80. package/shared/definition20.js +66 -58
  81. package/shared/definition21.js +43 -83
  82. package/shared/definition22.js +75 -2298
  83. package/shared/definition23.js +2361 -45
  84. package/shared/definition24.js +63 -27
  85. package/shared/definition25.js +24 -51
  86. package/shared/definition26.js +36 -806
  87. package/shared/definition27.js +820 -49
  88. package/shared/definition28.js +52 -89
  89. package/shared/definition29.js +88 -24
  90. package/shared/definition3.js +1 -1
  91. package/shared/definition30.js +25 -12
  92. package/shared/definition31.js +12 -53
  93. package/shared/definition32.js +29 -441
  94. package/shared/definition33.js +427 -197
  95. package/shared/definition34.js +260 -174
  96. package/shared/definition35.js +187 -69
  97. package/shared/definition36.js +68 -55
  98. package/shared/definition37.js +61 -422
  99. package/shared/definition38.js +435 -35
  100. package/shared/definition39.js +30 -679
  101. package/shared/definition4.js +3 -3
  102. package/shared/definition40.js +661 -77
  103. package/shared/definition41.js +77 -557
  104. package/shared/definition42.js +559 -106
  105. package/shared/definition43.js +105 -136
  106. package/shared/definition44.js +153 -17
  107. package/shared/definition45.js +16 -79
  108. package/shared/definition46.js +53 -475
  109. package/shared/definition47.js +506 -20
  110. package/shared/definition48.js +22 -121
  111. package/shared/definition49.js +115 -262
  112. package/shared/definition5.js +2 -2
  113. package/shared/definition50.js +248 -120
  114. package/shared/definition51.js +139 -123
  115. package/shared/definition52.js +84 -74
  116. package/shared/definition53.js +114 -70
  117. package/shared/definition54.js +81 -292
  118. package/shared/definition55.js +302 -13
  119. package/shared/definition56.js +11 -41
  120. package/shared/definition57.js +20 -154
  121. package/shared/definition58.js +181 -0
  122. package/shared/definition6.js +5 -5
  123. package/shared/definition7.js +4 -4
  124. package/shared/definition8.js +3 -3
  125. package/shared/definition9.js +1 -2
  126. package/shared/index.js +1 -1
  127. package/shared/index2.js +1 -1
  128. package/shared/listbox.js +1 -1
  129. package/shared/localization/Locale.d.ts +3 -1
  130. package/shared/localized.js +9 -0
  131. package/shared/patterns/affix.d.ts +3 -1
  132. package/shared/presentationDate.js +6133 -0
  133. package/shared/ref.js +1 -1
  134. package/shared/slotted.js +73 -3
  135. package/shared/text-anchor.template.js +4 -4
  136. package/shared/text-field.js +1 -1
  137. package/side-drawer/index.js +1 -1
  138. package/slider/index.js +2 -2
  139. package/split-button/index.js +4 -3
  140. package/style.css +265 -197
  141. package/styles/core/all.css +44 -13
  142. package/styles/core/theme.css +1 -1
  143. package/styles/core/typography.css +44 -13
  144. package/styles/tokens/theme-dark.css +4 -4
  145. package/styles/tokens/theme-light.css +4 -4
  146. package/styles/tokens/vivid-2-compat.css +1 -1
  147. package/switch/index.js +4 -3
  148. package/tab/index.js +4 -3
  149. package/tab-panel/index.js +1 -1
  150. package/tabs/index.js +6 -7
  151. package/tag/index.js +4 -3
  152. package/tag-group/index.js +1 -1
  153. package/text-anchor/index.js +1 -0
  154. package/text-area/index.js +4 -3
  155. package/text-field/index.js +4 -5
  156. package/toggletip/index.js +7 -6
  157. package/tooltip/index.js +7 -6
  158. package/tree-item/index.js +4 -5
  159. package/tree-view/index.js +1 -2
  160. package/vivid.api.json +105 -0
  161. package/lib/date-picker/date-picker.template.d.ts +0 -4
  162. package/shared/node-observation.js +0 -74
  163. /package/{lib → shared}/date-picker/calendar/calendarGrid.d.ts +0 -0
  164. /package/{lib → shared}/date-picker/calendar/dateStr.d.ts +0 -0
  165. /package/{lib → shared}/date-picker/calendar/month.d.ts +0 -0
  166. /package/{lib → shared}/date-picker/calendar/monthPickerGrid.d.ts +0 -0
  167. /package/{lib → shared}/date-picker/calendar/presentationDate.d.ts +0 -0
  168. /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 Wed, 13 Sep 2023 10:58:27 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,366 @@ 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
+ formResetCallback() {
334
+ this.#updateValues({ start: this.initialStart, end: this.initialEnd });
335
+ super.formResetCallback();
336
+ }
337
+ get _calendarButtonLabel() {
338
+ if (this.start && this.end) {
339
+ return this.locale.datePicker.changeDatesLabel(
340
+ formatPresentationDateRange(
341
+ {
342
+ start: this.start,
343
+ end: this.end
344
+ },
345
+ this.locale.datePicker
346
+ )
347
+ );
348
+ } else {
349
+ return this.locale.datePicker.chooseDatesLabel;
350
+ }
351
+ }
352
+ };
139
353
  __decorateClass([
140
- attr
141
- ], Dialog.prototype, "headline", 2);
354
+ attr({ mode: "fromView", attribute: "start" })
355
+ ], DateRangePicker.prototype, "initialStart", 2);
142
356
  __decorateClass([
143
- attr({ attribute: "full-width-body", mode: "boolean" })
144
- ], Dialog.prototype, "fullWidthBody", 2);
357
+ attr({ mode: "fromView", attribute: "end" })
358
+ ], DateRangePicker.prototype, "initialEnd", 2);
145
359
  __decorateClass([
146
- attr({ attribute: "aria-labelledby" })
147
- ], Dialog.prototype, "ariaLabelledBy", 2);
360
+ observable
361
+ ], DateRangePicker.prototype, "start", 2);
148
362
  __decorateClass([
149
- attr({ attribute: "aria-label" })
150
- ], Dialog.prototype, "ariaLabel", 2);
363
+ observable
364
+ ], DateRangePicker.prototype, "end", 2);
151
365
  __decorateClass([
152
- attr({ attribute: "aria-describedby" })
153
- ], Dialog.prototype, "ariaDescribedBy", 2);
366
+ attr({ attribute: "current-start" })
367
+ ], DateRangePicker.prototype, "currentStart", 2);
154
368
  __decorateClass([
155
- observable
156
- ], Dialog.prototype, "bodySlottedContent", 2);
369
+ attr({ attribute: "current-end" })
370
+ ], DateRangePicker.prototype, "currentEnd", 2);
157
371
  __decorateClass([
158
372
  observable
159
- ], Dialog.prototype, "footerSlottedContent", 2);
373
+ ], DateRangePicker.prototype, "_hoverDate", 2);
160
374
  __decorateClass([
161
- observable
162
- ], Dialog.prototype, "actionItemsSlottedContent", 2);
375
+ volatile
376
+ ], DateRangePicker.prototype, "_calendarButtonLabel", 1);
377
+ DateRangePicker = __decorateClass([
378
+ errorText,
379
+ formElements
380
+ ], DateRangePicker);
163
381
 
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]
382
+ const dateRangePickerDefinition = DateRangePicker.compose({
383
+ baseName: "date-range-picker",
384
+ template: DatePickerBaseTemplate,
385
+ styles
258
386
  });
259
- const dialogRegistries = [dialogDefinition(), ...iconRegistries, ...buttonRegistries, ...elevationRegistries];
260
- const registerDialog = registerFactory(dialogRegistries);
387
+ const dateRangePickerRegistries = [
388
+ dateRangePickerDefinition(),
389
+ ...buttonRegistries,
390
+ ...popupRegistries,
391
+ ...textFieldRegistries,
392
+ ...focusRegistries,
393
+ ...dividerRegistries
394
+ ];
395
+ const registerDateRangePicker = registerFactory(
396
+ dateRangePickerRegistries
397
+ );
261
398
 
262
- export { dialogRegistries as a, dialogDefinition as d, registerDialog as r };
399
+ export { dateRangePickerRegistries as a, dateRangePickerDefinition as d, registerDateRangePicker as r };