@govtechsg/sgds-web-component 1.1.0-rc.0 → 1.1.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 (79) hide show
  1. package/base/dropdown-element.cjs.js +0 -1
  2. package/base/dropdown-element.cjs.js.map +1 -1
  3. package/base/dropdown-element.d.ts +1 -2
  4. package/base/dropdown-element.js +0 -1
  5. package/base/dropdown-element.js.map +1 -1
  6. package/components/ActionCard/index.umd.js +3 -1
  7. package/components/ActionCard/index.umd.js.map +1 -1
  8. package/components/Button/index.umd.js +3 -1
  9. package/components/Button/index.umd.js.map +1 -1
  10. package/components/Checkbox/index.umd.js +3 -1
  11. package/components/Checkbox/index.umd.js.map +1 -1
  12. package/components/ComboBox/index.umd.js +43 -26
  13. package/components/ComboBox/index.umd.js.map +1 -1
  14. package/components/Datepicker/datepicker-calendar.cjs.js +29 -14
  15. package/components/Datepicker/datepicker-calendar.cjs.js.map +1 -1
  16. package/components/Datepicker/datepicker-calendar.js +29 -14
  17. package/components/Datepicker/datepicker-calendar.js.map +1 -1
  18. package/components/Datepicker/datepicker-header.cjs.js +35 -17
  19. package/components/Datepicker/datepicker-header.cjs.js.map +1 -1
  20. package/components/Datepicker/datepicker-header.d.ts +2 -0
  21. package/components/Datepicker/datepicker-header.js +35 -18
  22. package/components/Datepicker/datepicker-header.js.map +1 -1
  23. package/components/Datepicker/datepicker-input.cjs.js +150 -0
  24. package/components/Datepicker/datepicker-input.cjs.js.map +1 -0
  25. package/components/Datepicker/datepicker-input.d.ts +24 -0
  26. package/components/Datepicker/datepicker-input.js +141 -0
  27. package/components/Datepicker/datepicker-input.js.map +1 -0
  28. package/components/Datepicker/index.js.map +1 -1
  29. package/components/Datepicker/index.umd.js +16655 -7545
  30. package/components/Datepicker/index.umd.js.map +1 -1
  31. package/components/Datepicker/sgds-datepicker.cjs.js +207 -150
  32. package/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
  33. package/components/Datepicker/sgds-datepicker.cjs2.js +1 -1
  34. package/components/Datepicker/sgds-datepicker.d.ts +38 -13
  35. package/components/Datepicker/sgds-datepicker.js +209 -152
  36. package/components/Datepicker/sgds-datepicker.js.map +1 -1
  37. package/components/Datepicker/sgds-datepicker2.js +1 -1
  38. package/components/Dropdown/index.umd.js +8 -3
  39. package/components/Dropdown/index.umd.js.map +1 -1
  40. package/components/Dropdown/sgds-dropdown.cjs.js +5 -1
  41. package/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
  42. package/components/Dropdown/sgds-dropdown.d.ts +4 -3
  43. package/components/Dropdown/sgds-dropdown.js +5 -1
  44. package/components/Dropdown/sgds-dropdown.js.map +1 -1
  45. package/components/FileUpload/index.umd.js +3 -1
  46. package/components/FileUpload/index.umd.js.map +1 -1
  47. package/components/Input/index.umd.js +43 -25
  48. package/components/Input/index.umd.js.map +1 -1
  49. package/components/Input/sgds-input.cjs.js +40 -24
  50. package/components/Input/sgds-input.cjs.js.map +1 -1
  51. package/components/Input/sgds-input.d.ts +15 -9
  52. package/components/Input/sgds-input.js +40 -24
  53. package/components/Input/sgds-input.js.map +1 -1
  54. package/components/Mainnav/index.umd.js +0 -1
  55. package/components/Mainnav/index.umd.js.map +1 -1
  56. package/components/QuantityToggle/index.umd.js +3 -1
  57. package/components/QuantityToggle/index.umd.js.map +1 -1
  58. package/components/Radio/index.umd.js +3 -1
  59. package/components/Radio/index.umd.js.map +1 -1
  60. package/components/Textarea/index.umd.js +3 -1
  61. package/components/Textarea/index.umd.js.map +1 -1
  62. package/components/index.umd.js +9905 -791
  63. package/components/index.umd.js.map +1 -1
  64. package/index.umd.js +9905 -791
  65. package/index.umd.js.map +1 -1
  66. package/package.json +2 -2
  67. package/react/datepicker/index.cjs.js +1 -2
  68. package/react/datepicker/index.cjs.js.map +1 -1
  69. package/react/datepicker/index.js +1 -2
  70. package/react/datepicker/index.js.map +1 -1
  71. package/utils/form.cjs.js +3 -1
  72. package/utils/form.cjs.js.map +1 -1
  73. package/utils/form.js +3 -1
  74. package/utils/form.js.map +1 -1
  75. package/utils/time.cjs.js +18 -4
  76. package/utils/time.cjs.js.map +1 -1
  77. package/utils/time.d.ts +17 -0
  78. package/utils/time.js +18 -4
  79. package/utils/time.js.map +1 -1
@@ -4,20 +4,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var scopedElements = require('@open-wc/scoped-elements');
7
+ var dateFns = require('date-fns');
7
8
  var lit = require('lit');
8
9
  var decorators_js = require('lit/decorators.js');
9
10
  var live_js = require('lit/directives/live.js');
10
11
  var ref_js = require('lit/directives/ref.js');
11
12
  var dropdownElement = require('../../base/dropdown-element.cjs.js');
12
13
  var watch = require('../../utils/watch.cjs.js');
13
- var sgdsInput = require('../Input/sgds-input.cjs.js');
14
14
  var datepickerCalendar = require('./datepicker-calendar.cjs.js');
15
15
  var datepickerHeader = require('./datepicker-header.cjs.js');
16
+ var datepickerInput = require('./datepicker-input.cjs.js');
16
17
  var sgdsDatepicker = require('./sgds-datepicker.cjs2.js');
17
18
  var time = require('../../utils/time.cjs.js');
19
+ var classMap_js = require('lit/directives/class-map.js');
18
20
 
19
21
  /**
20
- * @summary The `DatePicker` Component is built using `Dropdown`, `Input` and `Button` components. By default, the Calendar points to current date and input has no value. The input is a read-only and users can only pick dates using the Calendar.
22
+ * @summary The `DatePicker` Component is built using `Dropdown`, `Input` and `Button` components. By default, the Calendar points to today's date and input has no value. Users can either pick dates from the calendar or type dates through the input
21
23
  *
22
24
  * @event sgds-change-date - Emitted when the state of datepicker's input changes during first load, close button reset click & date click. Date values can be accessed via event.target.value
23
25
  *
@@ -38,56 +40,70 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
38
40
  /**@internal */
39
41
  static get scopedElements() {
40
42
  return {
41
- "sgds-input": sgdsInput.SgdsInput,
43
+ "sgds-datepicker-input": datepickerInput.DatepickerInput,
42
44
  "sgds-datepicker-calendar": datepickerCalendar.DatepickerCalendar,
43
45
  "sgds-datepicker-header": datepickerHeader.DatepickerHeader
44
46
  };
45
47
  }
48
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
49
+ reportValidity() {
50
+ return this._internals.reportValidity();
51
+ }
46
52
  constructor() {
47
53
  super();
48
54
  /** When true, adds required attribute to input element */
49
55
  this.required = false;
50
56
  /** When true, adds disabled attribute to input and button element */
51
57
  this.disabled = false;
58
+ /** The initial value of DatePicker on first load for single & range mode as array of string. eg.'["22/12/2023"]' for single & '["22/12/2023","25/12/2023"]' for range respectively */
59
+ this.initialValue = [];
52
60
  /** Date format reflected on input */
53
61
  this.dateFormat = "DD/MM/YYYY";
62
+ /** ISO date string to set the lowest allowable date value. e.g. "2016-05-19T12:00:00.000Z" */
63
+ this.minDate = "";
64
+ /** ISO date string to set the highest allowable date value. e.g. "2016-05-19T12:00:00.000Z" */
65
+ this.maxDate = "";
54
66
  /** Changes DatePicker to single date selection or range date selection */
55
67
  this.mode = "single";
56
- /** @internal */
68
+ /**Feedback text for error state when date input is invalid */
69
+ this.invalidFeedback = "Please enter a valid date";
70
+ /** The datepicker input's label */
71
+ this.label = "";
72
+ /** The datepicker input's hint text below the label */
73
+ this.hintText = "";
74
+ /** Controls auto-flipping of menu */
75
+ this.noFlip = false;
76
+ /** The drop position of menu relative to the toggle button */
77
+ this.drop = "down";
78
+ this.value = "";
57
79
  this.view = "days";
58
- /** @internal */
59
80
  this.selectedDateRange = [];
60
- /** @internal */
61
- this.displayDate = new Date();
62
- /** @internal */
63
- this.focusedDate = new Date();
64
81
  this.focusedTabIndex = 3;
65
82
  this._makeInputValueString = (startDate, endDate, dateFormat) => {
66
83
  if (!startDate && !endDate)
67
- return "";
68
- const formatDate = (date) => {
69
- if (!(date instanceof Date) || isNaN(date.getTime())) {
70
- return ""; // Return an empty string if the date is not a valid Date object
84
+ return this.value;
85
+ const formatDate = (date) => dateFns.format(date, time.DATE_PATTERNS[dateFormat].fnsPattern);
86
+ switch (this.mode) {
87
+ case "single": {
88
+ if (startDate) {
89
+ this.value = formatDate(startDate);
90
+ }
91
+ break;
92
+ }
93
+ case "range": {
94
+ if (startDate && endDate) {
95
+ this.value = `${formatDate(startDate)} - ${formatDate(endDate)}`;
96
+ }
97
+ if (startDate && !endDate) {
98
+ this.value = `${formatDate(startDate)} - ${this.dateFormat.toLowerCase()}`;
99
+ }
100
+ break;
71
101
  }
72
- const month = date.getMonth() + 1;
73
- const day = date.getDate();
74
- const separator = "/";
75
- const formattedMonth = month > 9 ? month.toString() : `0${month}`;
76
- const formattedDay = day > 9 ? day.toString() : `0${day}`;
77
- return dateFormat === "YYYY/MM/DD"
78
- ? `${date.getFullYear()}${separator}${formattedMonth}${separator}${formattedDay}`
79
- : dateFormat === "DD/MM/YYYY"
80
- ? `${formattedDay}${separator}${formattedMonth}${separator}${date.getFullYear()}`
81
- : `${formattedMonth}${separator}${formattedDay}${separator}${date.getFullYear()}`;
82
- };
83
- if (startDate && endDate) {
84
- return `${formatDate(startDate)} - ${formatDate(endDate)}`;
85
- }
86
- if (startDate) {
87
- return formatDate(startDate);
88
102
  }
89
- return "";
103
+ return this.value;
90
104
  };
105
+ this._internals = this.attachInternals();
106
+ /**@internal */
91
107
  this.modifierOpt = [
92
108
  {
93
109
  name: "offset",
@@ -97,83 +113,47 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
97
113
  }
98
114
  ];
99
115
  }
100
- connectedCallback() {
116
+ async connectedCallback() {
101
117
  super.connectedCallback();
102
118
  this.addEventListener("sgds-view", this._handleViewChanged);
103
119
  this.addEventListener("sgds-change-calendar", this._handleDateChanged);
104
120
  this.addEventListener("sgds-update-focus", this._handleFocusDateChanged);
105
121
  this.addEventListener("sgds-selectmonth", this._handleSelectMonth);
106
122
  this.addEventListener("sgds-selectyear", this._handleSelectYear);
107
- this.addEventListener("sgds-selectdates", this._handleSelectDates);
123
+ this.addEventListener("sgds-selectdates", this._handleSelectDatesAndClose);
124
+ this.addEventListener("sgds-selectdates-input", this._handleSelectDatesInput);
125
+ this.addEventListener("sgds-empty-input", this._handleEmptyInput);
108
126
  this.addEventListener("keydown", this._handleTab);
109
127
  this.addEventListener("sgds-hide", this._handleCloseMenu);
128
+ this.initialDisplayDate = this.displayDate || new Date();
110
129
  if (this.initialValue && this.initialValue.length > 0) {
111
130
  // Validate initialValue against the dateFormat regex
112
131
  const dateFormatRegex = new RegExp(this._getDateFormatRegex());
113
- const startDateString = this.initialValue[0];
114
- if (!dateFormatRegex.test(startDateString)) {
115
- // Handle invalid date format in initialValue
116
- console.error("Invalid date format in initialValue:", startDateString);
117
- return;
132
+ // const startDateString = this.initialValue[0];
133
+ const invalidDates = this.initialValue.filter(v => !dateFormatRegex.test(v));
134
+ if (invalidDates.length > 0) {
135
+ return console.error("Invalid date format in initialValue:", invalidDates);
118
136
  }
119
- const startDate = this._parseDateStringToDate(startDateString);
120
- if (this.mode === "single" && startDate) {
121
- // Single mode
122
- this.selectedDateRange = [startDate];
123
- this.displayDate = startDate;
124
- }
125
- else if (this.mode === "range" && this.initialValue.length === 2) {
126
- // Range mode
127
- const endDateString = this.initialValue[1];
128
- if (!dateFormatRegex.test(endDateString)) {
129
- // Handle invalid date format in initialValue
130
- console.error("Invalid date format in initialValue:", endDateString);
131
- return;
132
- }
133
- const endDate = this._parseDateStringToDate(endDateString);
134
- if (startDate && endDate) {
135
- this.selectedDateRange = [startDate, endDate];
136
- this.selectedDateRange = time.sortAscDates(this.selectedDateRange);
137
- // this.selectedDateRange.sort((a, b) => a.getTime() - b.getTime());
138
- this.displayDate = startDate;
139
- }
137
+ else {
138
+ const initialSelectedDates = this.initialValue.map(v => time.setTimeToNoon(dateFns.parse(v, time.DATE_PATTERNS[this.dateFormat].fnsPattern, new Date())));
139
+ this._handleSelectDates(initialSelectedDates);
140
140
  }
141
141
  }
142
- if (this.selectedDateRange && this.selectedDateRange.length > 0) {
143
- // Get the formattedDate value for the selected dates
144
- const formattedDate = this._makeInputValueString(this.selectedDateRange[0], this.selectedDateRange[1], this.dateFormat);
145
- this.value = formattedDate;
146
- }
147
142
  else {
148
- // If selectedDateRange is empty, emit sgds-change-date event with an empty string
149
- this.value = "";
143
+ this.displayDate = this.initialDisplayDate;
150
144
  }
151
145
  }
152
146
  async firstUpdated() {
153
147
  super.firstUpdated();
154
148
  if (this.menuIsOpen) {
155
- const input = await this.dropdownRef;
149
+ const input = await this.datepickerInputAsync;
156
150
  this.showMenu();
157
151
  const cal = await this.calendar;
158
152
  cal.focusOnCalendar(input);
159
153
  }
160
- }
161
- _parseDateStringToDate(dateString) {
162
- let year, month, day;
163
- switch (this.dateFormat) {
164
- case "MM/DD/YYYY":
165
- [month, day, year] = dateString.split("/");
166
- break;
167
- case "DD/MM/YYYY":
168
- [day, month, year] = dateString.split("/");
169
- break;
170
- case "YYYY/MM/DD":
171
- [year, month, day] = dateString.split("/");
172
- break;
173
- default:
174
- return null;
175
- }
176
- return new Date(`${year}-${month}-${day}`);
154
+ const shadowInput = await this.datepickerInput.shadowInput;
155
+ this._manageInternalsDefault(shadowInput);
156
+ this._internals.setValidity(shadowInput.validity, shadowInput.validationMessage, shadowInput);
177
157
  }
178
158
  /** @internal */
179
159
  _getDateFormatRegex() {
@@ -191,6 +171,9 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
191
171
  .replace("/", "\\/"));
192
172
  }
193
173
  _handleTab(event) {
174
+ if (!this.menuIsOpen) {
175
+ return;
176
+ }
194
177
  const tabIndexArray = Array(4);
195
178
  if (event.shiftKey && event.key === "Tab") {
196
179
  event.preventDefault();
@@ -203,10 +186,11 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
203
186
  }
204
187
  _handleValueChange() {
205
188
  this.emit("sgds-change-date");
189
+ this._setInternalFormValue(this.value);
206
190
  }
207
191
  async _handleCloseMenu() {
208
192
  if (this.selectedDateRange.length === 0) {
209
- this.displayDate = new Date();
193
+ this.displayDate = this.initialDisplayDate;
210
194
  }
211
195
  else {
212
196
  const selectedDatesLength = this.selectedDateRange.length;
@@ -215,28 +199,34 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
215
199
  calendar._updateFocusedDate();
216
200
  }
217
201
  }
218
- _handleSelectDates(event) {
219
- const newSelectedDates = event.detail;
202
+ _handleSelectDatesInput(event) {
203
+ this._handleSelectDates(event.detail);
204
+ this._manageInternalsDefault(this._shadowInput);
205
+ }
206
+ async _handleSelectDates(newSelectedDates) {
207
+ newSelectedDates.sort((a, b) => a.getTime() - b.getTime());
220
208
  this.displayDate = newSelectedDates[0];
221
209
  this.focusedDate = newSelectedDates[0];
222
- if (this.mode === "range") {
223
- // Sort the newSelectedDates array in ascending order
224
- newSelectedDates.sort((a, b) => a.getTime() - b.getTime());
225
- this.selectedDateRange = newSelectedDates;
226
- if (this.selectedDateRange.length === 2) {
227
- this.hideMenu();
228
- }
229
- }
230
- else if (this.mode === "single") {
231
- this.selectedDateRange = [newSelectedDates[0]];
232
- if (this.selectedDateRange.length === 1) {
233
- this.hideMenu();
234
- }
235
- }
210
+ this.selectedDateRange = newSelectedDates;
236
211
  // Get the formattedDate value for the selected dates
237
212
  const formattedDate = this._makeInputValueString(this.selectedDateRange[0], this.selectedDateRange[1], this.dateFormat);
238
213
  // Set formattedDate value as the new value for sgds-input
239
214
  this.value = formattedDate;
215
+ const input = await this.datepickerInputAsync;
216
+ input.updateMaskValue();
217
+ }
218
+ get _shadowInput() {
219
+ return this.datepickerInput.shadowRoot.querySelector("input");
220
+ }
221
+ _handleSelectDatesAndClose(event) {
222
+ this._handleSelectDates(event.detail);
223
+ if (this.mode === "range" && this.selectedDateRange.length === 2) {
224
+ this.hideMenu();
225
+ }
226
+ else if (this.mode === "single" && this.selectedDateRange.length === 1) {
227
+ this.hideMenu();
228
+ }
229
+ this._manageInternalsValid();
240
230
  }
241
231
  /** update latest view state from datepicker-header */
242
232
  _handleViewChanged(event) {
@@ -254,31 +244,51 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
254
244
  _handleSelectYear(event) {
255
245
  this.displayDate = event.detail;
256
246
  }
257
- _handleButtonResetClick() {
258
- this.displayDate = new Date();
247
+ async _handleInvalidInput() {
248
+ this.selectedDateRange = [];
249
+ this.displayDate = this.initialDisplayDate;
250
+ this._manageInternalsBadInput();
251
+ }
252
+ async _handleButtonResetClick() {
253
+ this.displayDate = this.initialDisplayDate;
259
254
  this.selectedDateRange = [];
260
255
  this.value = "";
261
256
  this.view = "days";
262
257
  this.hideMenu();
258
+ const input = await this.datepickerInputAsync;
259
+ input.setInvalid(false);
260
+ input.destroyInputMask();
261
+ await input.applyInputMask();
262
+ this._manageInternalsRequired();
263
+ }
264
+ async _handleEmptyInput() {
265
+ this._manageInternalsRequired();
266
+ }
267
+ _manageInternalsRequired() {
268
+ this.required
269
+ ? this._internals.setValidity({
270
+ valueMissing: true
271
+ }, "Please fill in this field", this._shadowInput)
272
+ : this._internals.setValidity({});
273
+ }
274
+ _manageInternalsBadInput() {
275
+ this._internals.setValidity({
276
+ badInput: true
277
+ }, "The chosen date(s) are invalid", this._shadowInput);
278
+ }
279
+ _manageInternalsValid() {
280
+ this._internals.setValidity({});
281
+ }
282
+ _manageInternalsDefault(inputEl) {
283
+ this._internals.setValidity(inputEl.validity, inputEl.validationMessage, inputEl);
284
+ }
285
+ _setInternalFormValue(value) {
286
+ this._internals.setFormValue(value);
287
+ }
288
+ async _handleInputMaskChange(e) {
289
+ this.value = e.detail;
263
290
  }
264
291
  render() {
265
- let formattedDate = "";
266
- if (this.mode === "single") {
267
- formattedDate = this._makeInputValueString(this.selectedDateRange[0], undefined, this.dateFormat);
268
- }
269
- else if (this.mode === "range") {
270
- formattedDate = this._makeInputValueString(this.selectedDateRange[0], this.selectedDateRange[1], this.dateFormat);
271
- }
272
- const getPlaceholder = () => {
273
- const validDateFormats = ["MM/DD/YYYY", "DD/MM/YYYY", "YYYY/MM/DD"];
274
- if (this.mode === "range" && validDateFormats.includes(this.dateFormat)) {
275
- return `${this.dateFormat.toLowerCase()} - ${this.dateFormat.toLowerCase()}`;
276
- }
277
- else if (this.mode === "single" && validDateFormats.includes(this.dateFormat)) {
278
- return this.dateFormat.toLowerCase();
279
- }
280
- return "";
281
- };
282
292
  const svgEl = lit.html `
283
293
  <svg
284
294
  xmlns="http://www.w3.org/2000/svg"
@@ -292,37 +302,62 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
292
302
  d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"
293
303
  />
294
304
  </svg>
295
- `;
296
- const svgIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar" viewBox="0 0 16 16">
297
- <path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/>
298
- </svg>
299
305
  `;
300
306
  return lit.html `
301
307
  <div>
302
- <sgds-input
303
- id="myInput"
304
- icon=${svgIcon}
305
- .value=${live_js.live(formattedDate)}
306
- inputClasses="rounded-0 rounded-start"
307
- placeholder="${getPlaceholder()}"
308
- aria-expanded="${this.menuIsOpen}"
309
- ${ref_js.ref(this.myDropdown)}
310
- @click=${() => this.toggleMenu()}
311
- readonly
308
+ <sgds-datepicker-input
309
+ .value=${live_js.live(this.value)}
312
310
  ?required=${this.required}
313
311
  ?disabled=${this.disabled}
314
- role="combobox"
315
- aria-haspopup="dialog"
316
- aria-controls=${this.dropdownMenuId}
317
- ></sgds-input>
318
- <button
319
- ?disabled=${this.disabled}
320
- class="btn sgds rounded-0 d-flex align-items-center"
321
- aria-label="reset the datepicker"
322
- @click=${() => this._handleButtonResetClick()}
312
+ placeholder=""
313
+ ${ref_js.ref(this.myDropdown)}
314
+ mode=${this.mode}
315
+ dateFormat=${this.dateFormat}
316
+ invalidFeedback=${this.invalidFeedback}
317
+ @sgds-mask-input-change=${this._handleInputMaskChange}
318
+ @sgds-invalid-input=${this._handleInvalidInput}
319
+ minDate=${this.minDate}
320
+ maxDate=${this.maxDate}
321
+ label=${this.label}
322
+ hintText=${this.hintText}
323
+ name=${this.name}
323
324
  >
324
- ${svgEl}
325
- </button>
325
+ <button
326
+ slot="calendar-btn"
327
+ class=${classMap_js.classMap({
328
+ "sgds btn rounded-0 border btn-outline-dark": true
329
+ })}
330
+ aria-expanded="${this.menuIsOpen}"
331
+ aria-haspopup="dialog"
332
+ aria-controls=${this.dropdownMenuId}
333
+ @click=${() => this.toggleMenu()}
334
+ aria-label=${this.menuIsOpen ? "Close Calendar" : "Open Calendar"}
335
+ ?disabled=${this.disabled}
336
+ >
337
+ <svg
338
+ xmlns="http://www.w3.org/2000/svg"
339
+ width="16"
340
+ height="16"
341
+ fill="currentColor"
342
+ class="bi bi-calendar"
343
+ viewBox="0 0 16 16"
344
+ >
345
+ <path
346
+ d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5M1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4z"
347
+ />
348
+ </svg>
349
+ </button>
350
+ <button
351
+ slot="reset-btn"
352
+ ?disabled=${this.disabled}
353
+ class="btn sgds rounded-0 reset-btn"
354
+ @click=${() => this._handleButtonResetClick()}
355
+ aria-label="Reset Datepicker"
356
+ >
357
+ ${svgEl}
358
+ </button>
359
+ </sgds-datepicker-input>
360
+
326
361
  <ul
327
362
  id=${this.dropdownMenuId}
328
363
  class="sgds datepicker dropdown-menu"
@@ -353,9 +388,13 @@ class SgdsDatepicker extends scopedElements.ScopedElementsMixin(dropdownElement.
353
388
  }
354
389
  }
355
390
  SgdsDatepicker.styles = [dropdownElement.DropdownElement.styles, sgdsDatepicker["default"]];
391
+ SgdsDatepicker.formAssociated = true;
356
392
  tslib.__decorate([
357
393
  decorators_js.property({ type: Boolean, reflect: true })
358
394
  ], SgdsDatepicker.prototype, "required", void 0);
395
+ tslib.__decorate([
396
+ decorators_js.property({ reflect: true })
397
+ ], SgdsDatepicker.prototype, "name", void 0);
359
398
  tslib.__decorate([
360
399
  decorators_js.property({ type: Boolean, reflect: true })
361
400
  ], SgdsDatepicker.prototype, "disabled", void 0);
@@ -374,6 +413,24 @@ tslib.__decorate([
374
413
  tslib.__decorate([
375
414
  decorators_js.property({ type: String, reflect: true })
376
415
  ], SgdsDatepicker.prototype, "mode", void 0);
416
+ tslib.__decorate([
417
+ decorators_js.property({ type: String, reflect: true })
418
+ ], SgdsDatepicker.prototype, "invalidFeedback", void 0);
419
+ tslib.__decorate([
420
+ decorators_js.property({ reflect: true })
421
+ ], SgdsDatepicker.prototype, "label", void 0);
422
+ tslib.__decorate([
423
+ decorators_js.property({ reflect: true })
424
+ ], SgdsDatepicker.prototype, "hintText", void 0);
425
+ tslib.__decorate([
426
+ decorators_js.property({ type: Boolean, reflect: true, state: false })
427
+ ], SgdsDatepicker.prototype, "noFlip", void 0);
428
+ tslib.__decorate([
429
+ decorators_js.property({ type: String, reflect: true, state: false })
430
+ ], SgdsDatepicker.prototype, "drop", void 0);
431
+ tslib.__decorate([
432
+ decorators_js.property({ attribute: false })
433
+ ], SgdsDatepicker.prototype, "displayDate", void 0);
377
434
  tslib.__decorate([
378
435
  decorators_js.state()
379
436
  ], SgdsDatepicker.prototype, "value", void 0);
@@ -383,21 +440,21 @@ tslib.__decorate([
383
440
  tslib.__decorate([
384
441
  decorators_js.state()
385
442
  ], SgdsDatepicker.prototype, "selectedDateRange", void 0);
386
- tslib.__decorate([
387
- decorators_js.state()
388
- ], SgdsDatepicker.prototype, "displayDate", void 0);
389
443
  tslib.__decorate([
390
444
  decorators_js.state()
391
445
  ], SgdsDatepicker.prototype, "focusedDate", void 0);
392
446
  tslib.__decorate([
393
447
  decorators_js.state()
394
448
  ], SgdsDatepicker.prototype, "focusedTabIndex", void 0);
395
- tslib.__decorate([
396
- decorators_js.queryAsync("sgds-input")
397
- ], SgdsDatepicker.prototype, "dropdownRef", void 0);
398
449
  tslib.__decorate([
399
450
  decorators_js.queryAsync("sgds-datepicker-calendar")
400
451
  ], SgdsDatepicker.prototype, "calendar", void 0);
452
+ tslib.__decorate([
453
+ decorators_js.queryAsync("sgds-datepicker-input")
454
+ ], SgdsDatepicker.prototype, "datepickerInputAsync", void 0);
455
+ tslib.__decorate([
456
+ decorators_js.query("sgds-datepicker-input")
457
+ ], SgdsDatepicker.prototype, "datepickerInput", void 0);
401
458
  tslib.__decorate([
402
459
  watch.watch("value")
403
460
  ], SgdsDatepicker.prototype, "_handleValueChange", null);