@tabworthy/components 0.12.4 → 0.13.1

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 (44) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/tabworthy-components.cjs.js +1 -1
  3. package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +35 -17
  4. package/dist/cjs/tabworthy-dates.cjs.entry.js +58 -10
  5. package/dist/cjs/tabworthy-times-picker.cjs.entry.js +82 -10
  6. package/dist/cjs/tabworthy-times.cjs.entry.js +147 -6
  7. package/dist/cjs/{utils-y5Vtky2t.js → utils-DGbdK8VF.js} +29 -8
  8. package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +78 -10
  9. package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.js +35 -17
  10. package/dist/collection/components/tabworthy-times/tabworthy-times.js +167 -5
  11. package/dist/collection/components/tabworthy-times-picker/tabworthy-times-picker.js +128 -10
  12. package/dist/components/p-BzY8iIVW.js +1 -0
  13. package/dist/components/p-C_uZGgcG.js +1 -0
  14. package/dist/components/tabworthy-dates-calendar.js +1 -1
  15. package/dist/components/tabworthy-dates.js +1 -1
  16. package/dist/components/tabworthy-times-picker.js +1 -1
  17. package/dist/components/tabworthy-times.js +1 -1
  18. package/dist/esm/loader.js +1 -1
  19. package/dist/esm/tabworthy-components.js +1 -1
  20. package/dist/esm/tabworthy-dates-calendar_2.entry.js +35 -17
  21. package/dist/esm/tabworthy-dates.entry.js +58 -10
  22. package/dist/esm/tabworthy-times-picker.entry.js +82 -10
  23. package/dist/esm/tabworthy-times.entry.js +147 -6
  24. package/dist/esm/{utils-BVHu5CWV.js → utils-CoFOnMSw.js} +29 -9
  25. package/dist/shared/utils/utils.js +28 -8
  26. package/dist/tabworthy-components/p-4eedf24e.entry.js +1 -0
  27. package/dist/tabworthy-components/p-69334c34.entry.js +1 -0
  28. package/dist/tabworthy-components/p-7cd6ccc1.entry.js +1 -0
  29. package/dist/tabworthy-components/{p-BVHu5CWV.js → p-CoFOnMSw.js} +1 -1
  30. package/dist/tabworthy-components/p-b6a5d970.entry.js +1 -0
  31. package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
  32. package/dist/themes/light.css +1 -1
  33. package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +7 -0
  34. package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +13 -1
  35. package/dist/types/components/tabworthy-times-picker/tabworthy-times-picker.d.ts +15 -0
  36. package/dist/types/components.d.ts +14 -4
  37. package/dist/types/home/runner/work/tabworthy-components/tabworthy-components/.stencil/shared/utils/utils.d.ts +6 -0
  38. package/package.json +1 -1
  39. package/dist/components/p-BTQaxOHo.js +0 -1
  40. package/dist/components/p-DAc3jaFB.js +0 -1
  41. package/dist/tabworthy-components/p-1743bf7a.entry.js +0 -1
  42. package/dist/tabworthy-components/p-28192b55.entry.js +0 -1
  43. package/dist/tabworthy-components/p-3b548ae1.entry.js +0 -1
  44. package/dist/tabworthy-components/p-626a5c0b.entry.js +0 -1
@@ -36,6 +36,8 @@ const TabworthyTimesPicker = class {
36
36
  this.period = this.hours >= 12 ? "PM" : "AM";
37
37
  this.handleHourChange = (e) => {
38
38
  const value = parseInt(e.target.value, 10);
39
+ if (isNaN(value))
40
+ return;
39
41
  if (this.useTwelveHourFormat) {
40
42
  // Convert to 24-hour format based on period
41
43
  if (this.period === "AM") {
@@ -51,7 +53,10 @@ const TabworthyTimesPicker = class {
51
53
  this.emitTimeChange();
52
54
  };
53
55
  this.handleMinuteChange = (e) => {
54
- this.internalMinutes = parseInt(e.target.value, 10);
56
+ const value = parseInt(e.target.value, 10);
57
+ if (isNaN(value))
58
+ return;
59
+ this.internalMinutes = value;
55
60
  this.emitTimeChange();
56
61
  };
57
62
  this.handlePeriodChange = (period) => {
@@ -111,7 +116,10 @@ const TabworthyTimesPicker = class {
111
116
  this.emitTimeChange();
112
117
  };
113
118
  this.handleSecondChange = (e) => {
114
- this.internalSeconds = parseInt(e.target.value, 10);
119
+ const value = parseInt(e.target.value, 10);
120
+ if (isNaN(value))
121
+ return;
122
+ this.internalSeconds = value;
115
123
  this.emitTimeChange();
116
124
  };
117
125
  this.handleSecondIncrement = () => {
@@ -163,6 +171,7 @@ const TabworthyTimesPicker = class {
163
171
  }
164
172
  }
165
173
  emitTimeChange() {
174
+ this.clampToBounds();
166
175
  this.timeChanged.emit({
167
176
  hours: this.get24HourValue(),
168
177
  minutes: this.internalMinutes,
@@ -170,6 +179,69 @@ const TabworthyTimesPicker = class {
170
179
  period: this.useTwelveHourFormat ? this.period : undefined
171
180
  });
172
181
  }
182
+ clampToBounds() {
183
+ var _a, _b;
184
+ const h = this.get24HourValue();
185
+ const m = this.internalMinutes;
186
+ const s = this.internalSeconds;
187
+ if (this.minTime) {
188
+ const minS = (_a = this.minTime.seconds) !== null && _a !== void 0 ? _a : 0;
189
+ if (h < this.minTime.hours ||
190
+ (h === this.minTime.hours && m < this.minTime.minutes) ||
191
+ (h === this.minTime.hours && m === this.minTime.minutes && s < minS)) {
192
+ this.setInternal24Hours(this.minTime.hours);
193
+ this.internalMinutes = this.minTime.minutes;
194
+ this.internalSeconds = minS;
195
+ }
196
+ }
197
+ if (this.maxTime) {
198
+ const maxS = (_b = this.maxTime.seconds) !== null && _b !== void 0 ? _b : 59;
199
+ const curH = this.get24HourValue();
200
+ const curM = this.internalMinutes;
201
+ const curS = this.internalSeconds;
202
+ if (curH > this.maxTime.hours ||
203
+ (curH === this.maxTime.hours && curM > this.maxTime.minutes) ||
204
+ (curH === this.maxTime.hours &&
205
+ curM === this.maxTime.minutes &&
206
+ curS > maxS)) {
207
+ this.setInternal24Hours(this.maxTime.hours);
208
+ this.internalMinutes = this.maxTime.minutes;
209
+ this.internalSeconds = maxS;
210
+ }
211
+ }
212
+ }
213
+ setInternal24Hours(h24) {
214
+ this.internalHours = h24;
215
+ this.period = h24 >= 12 ? "PM" : "AM";
216
+ }
217
+ isAtMinHour() {
218
+ return !!this.minTime && this.get24HourValue() <= this.minTime.hours;
219
+ }
220
+ isAtMaxHour() {
221
+ return !!this.maxTime && this.get24HourValue() >= this.maxTime.hours;
222
+ }
223
+ isAtMinMinute() {
224
+ return (this.isAtMinHour() &&
225
+ !!this.minTime &&
226
+ this.internalMinutes <= this.minTime.minutes);
227
+ }
228
+ isAtMaxMinute() {
229
+ return (this.isAtMaxHour() &&
230
+ !!this.maxTime &&
231
+ this.internalMinutes >= this.maxTime.minutes);
232
+ }
233
+ isAtMinSecond() {
234
+ var _a;
235
+ return (this.isAtMinMinute() &&
236
+ !!this.minTime &&
237
+ this.internalSeconds <= ((_a = this.minTime.seconds) !== null && _a !== void 0 ? _a : 0));
238
+ }
239
+ isAtMaxSecond() {
240
+ var _a;
241
+ return (this.isAtMaxMinute() &&
242
+ !!this.maxTime &&
243
+ this.internalSeconds >= ((_a = this.maxTime.seconds) !== null && _a !== void 0 ? _a : 59));
244
+ }
173
245
  padZero(num) {
174
246
  return num.toString().padStart(2, "0");
175
247
  }
@@ -177,22 +249,22 @@ const TabworthyTimesPicker = class {
177
249
  const displayHours = this.getDisplayHours();
178
250
  const maxHours = this.useTwelveHourFormat ? 12 : 23;
179
251
  const minHours = this.useTwelveHourFormat ? 1 : 0;
180
- return (h(Host, { key: '878156f105b2fb61aae67f866c1c436f038d1671', class: this.elementClassName, "aria-label": this.labels.timePicker }, h("div", { key: '7b6265d1de95da5423d0d7fcfc6da5e283b64650', class: `${this.elementClassName}__container` }, h("div", { key: '6e64ffa764916fb2bad7b88c30eed4ce3de141ed', class: `${this.elementClassName}__field` }, h("label", { key: '0b9f82f319299fc3f177ec131f3bcb2d911cae6c', htmlFor: `${this.elementClassName}-hours`, class: {
252
+ return (h(Host, { key: '190cabad78886b1902d70c42c6c5b1f4ee90e5fe', class: this.elementClassName, "aria-label": this.labels.timePicker }, h("div", { key: '98b3d39baf501aeb9894949e807a365e26253fbc', class: `${this.elementClassName}__container` }, h("div", { key: '6697b77b177164a36297f911572d89beaa01cf23', class: `${this.elementClassName}__field` }, h("label", { key: '43f6e821b49f19041422741840439081f819f71c', htmlFor: `${this.elementClassName}-hours`, class: {
181
253
  [`${this.elementClassName}__label`]: true,
182
254
  [`${this.elementClassName}__label--sr-only`]: this.labelsSrOnly
183
- } }, this.labels.hours), h("div", { key: '0b7c4a24255319fe373aacf275583a6ccf1415ea', class: `${this.elementClassName}__control` }, h("button", { key: '24aff5877ad7cb189a6a9118f45e912ee2f97bec', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--increment`, onClick: this.handleHourIncrement, disabled: this.disabled, "aria-label": this.labels.incrementHours }, h("svg", { key: '681c818b4e10bc442aca0795024153dda43e6e27', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '0f86f34c93f99536623d793429bae7109aa29996', points: "18 15 12 9 6 15" }))), h("input", { key: '26043b87943641bdab9322413a36e0019980ef87', id: `${this.elementClassName}-hours`, type: "number", class: `${this.elementClassName}__input`, value: this.padZero(displayHours), min: minHours, max: maxHours, onInput: this.handleHourChange, disabled: this.disabled, "aria-label": this.labels.hours }), h("button", { key: 'd9617f2300e5457bd6480136d33905b35a2c2aba', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--decrement`, onClick: this.handleHourDecrement, disabled: this.disabled, "aria-label": this.labels.decrementHours }, h("svg", { key: '468f599326f2a01c873e963ef30904e66dead729', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '0c54d3e34df989d2514dc95c3e660d94bda4819d', points: "6 9 12 15 18 9" }))))), h("div", { key: '0435c24eb991f0746f1388d440e175d20ba4230a', class: `${this.elementClassName}__separator` }, ":"), h("div", { key: '1dfb26b32d394101e9a85845d7cb2588c7c2fc63', class: `${this.elementClassName}__field` }, h("label", { key: '06e3318c7cd7cd56bc9b1f2616520af38e22501e', htmlFor: `${this.elementClassName}-minutes`, class: {
255
+ } }, this.labels.hours), h("div", { key: 'a0e177ded2a849c22e41dbca95bad0888f7f956c', class: `${this.elementClassName}__control` }, h("button", { key: 'b12c268cc84f11ee078ba9285ae6d9cc605761e4', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--increment`, onClick: this.handleHourIncrement, disabled: this.disabled || this.isAtMaxHour(), "aria-label": this.labels.incrementHours }, h("svg", { key: '598eff59b528ec28a0e5b34924e77a4f632ba6ca', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '279b80304fc77a2fd74e26a2aba89f12155f9334', points: "18 15 12 9 6 15" }))), h("input", { key: '93f17e7c848d40bd513ad7af9f29d39586391573', id: `${this.elementClassName}-hours`, type: "number", class: `${this.elementClassName}__input`, value: this.padZero(displayHours), min: minHours, max: maxHours, onInput: this.handleHourChange, disabled: this.disabled, "aria-label": this.labels.hours }), h("button", { key: 'ba8f6463ee850c6349cad839eb851c67e0cb4d1e', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--decrement`, onClick: this.handleHourDecrement, disabled: this.disabled || this.isAtMinHour(), "aria-label": this.labels.decrementHours }, h("svg", { key: '21e585fbd6a9aa2b957e817ec55ab2ec01cf2fc4', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '742b64bddf3873a7bea1c10ed93b9b1e99588ede', points: "6 9 12 15 18 9" }))))), h("div", { key: 'f81f40c465cc84a5d02b9904631d3d24e33150e3', class: `${this.elementClassName}__separator` }, ":"), h("div", { key: 'd028bae721c1c9c2cc7290cd19f7050a901f4a4e', class: `${this.elementClassName}__field` }, h("label", { key: '3c88a3fa04ed2a65f72c48ded459e19d580f9c36', htmlFor: `${this.elementClassName}-minutes`, class: {
184
256
  [`${this.elementClassName}__label`]: true,
185
257
  [`${this.elementClassName}__label--sr-only`]: this.labelsSrOnly
186
- } }, this.labels.minutes), h("div", { key: '933a0911a02b79fbcd573e0f0ed942fe1f23b7e8', class: `${this.elementClassName}__control` }, h("button", { key: 'e3a124aab9297ae89ed8deafdc1f2e4066ede58b', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--increment`, onClick: this.handleMinuteIncrement, disabled: this.disabled, "aria-label": this.labels.incrementMinutes }, h("svg", { key: 'cb33d7fd82b3e9e0293a83c80d0f4c750e381e03', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: 'd4fe518f8a5872da32e7093c0e5e6e7f168f7bfe', points: "18 15 12 9 6 15" }))), h("input", { key: '74bb5772b8c12697148e68fbf203184e097bfe40', id: `${this.elementClassName}-minutes`, type: "number", class: `${this.elementClassName}__input`, value: this.padZero(this.internalMinutes), min: 0, max: 59, onInput: this.handleMinuteChange, disabled: this.disabled, "aria-label": this.labels.minutes }), h("button", { key: 'c93e42de64a96a379405942fd7bcd2e4c9430c77', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--decrement`, onClick: this.handleMinuteDecrement, disabled: this.disabled, "aria-label": this.labels.decrementMinutes }, h("svg", { key: '0d9eb6746bf467c2275447ec8d6a63f8b17f63a4', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: 'beb0425b60d2277477c6ffb5b72ce89ccd7bed20', points: "6 9 12 15 18 9" }))))), this.showSeconds && [
187
- h("div", { key: 'b686b7c464e70764bb8dcbec246c72bee6fa51b6', class: `${this.elementClassName}__separator` }, ":"),
188
- h("div", { key: '9dadc9f5a410e40775bd5b28144ee62971448680', class: `${this.elementClassName}__field` }, h("label", { key: '233e50d7ddf4ea413ee652d20b917081485dbf93', htmlFor: `${this.elementClassName}-seconds`, class: {
258
+ } }, this.labels.minutes), h("div", { key: 'dbd89633addd003b2e42414b587d03a6e65e9239', class: `${this.elementClassName}__control` }, h("button", { key: 'b113074a58889691dd5452a6353b691336f5ae14', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--increment`, onClick: this.handleMinuteIncrement, disabled: this.disabled || this.isAtMaxMinute(), "aria-label": this.labels.incrementMinutes }, h("svg", { key: '0d724c0e5110dd29ab4cedc005595d4e57fd3d06', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: 'dbc89190f6fe10bb8c8074252b83ab3397112de4', points: "18 15 12 9 6 15" }))), h("input", { key: '65a9a61218d443676a8a2d03d4922b2303a484c5', id: `${this.elementClassName}-minutes`, type: "number", class: `${this.elementClassName}__input`, value: this.padZero(this.internalMinutes), min: 0, max: 59, onInput: this.handleMinuteChange, disabled: this.disabled, "aria-label": this.labels.minutes }), h("button", { key: '3f72a62add15d9288b421b84e791ba40b9acf569', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--decrement`, onClick: this.handleMinuteDecrement, disabled: this.disabled || this.isAtMinMinute(), "aria-label": this.labels.decrementMinutes }, h("svg", { key: '04eef7d1d332459e5191962c411aa9c83ace8b84', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '56045b19ec716a82f21406b647762ba0efcd8170', points: "6 9 12 15 18 9" }))))), this.showSeconds && [
259
+ h("div", { key: '9c2619ccebd147e626e10a21fb1a5fa1268128f3', class: `${this.elementClassName}__separator` }, ":"),
260
+ h("div", { key: 'dea8135d47a06d9624b480aa6123350a0899ca02', class: `${this.elementClassName}__field` }, h("label", { key: 'afaa88b59df63091088620ff2a49bf8472f4401f', htmlFor: `${this.elementClassName}-seconds`, class: {
189
261
  [`${this.elementClassName}__label`]: true,
190
262
  [`${this.elementClassName}__label--sr-only`]: this.labelsSrOnly
191
- } }, this.labels.seconds), h("div", { key: 'df35e6750eeef49671e6a5f233e00a253459554d', class: `${this.elementClassName}__control` }, h("button", { key: '521ba9fa8eb10dbf5981c4bab9687479f7888ac9', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--increment`, onClick: this.handleSecondIncrement, disabled: this.disabled, "aria-label": this.labels.incrementSeconds }, h("svg", { key: '84d4ac4697aaf7c9042e301b629a254e4ceffc6a', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '2af46da2a6c4c994ae67c44edb0b4180a6125336', points: "18 15 12 9 6 15" }))), h("input", { key: 'bee75b6dd68f723482c295af51250a94df35ab30', id: `${this.elementClassName}-seconds`, type: "number", class: `${this.elementClassName}__input`, value: this.padZero(this.internalSeconds), min: 0, max: 59, onInput: this.handleSecondChange, disabled: this.disabled, "aria-label": this.labels.seconds }), h("button", { key: 'fe1288605003497b92e739f4cec01f160e5a161a', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--decrement`, onClick: this.handleSecondDecrement, disabled: this.disabled, "aria-label": this.labels.decrementSeconds }, h("svg", { key: 'ca3a8aa73620bc12095f4c6c9bdfd2c33901a6ff', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '3b68faee709705c929791e9cc7f9e24738f035a1', points: "6 9 12 15 18 9" })))))
192
- ], this.useTwelveHourFormat && (h("div", { key: '13f65cc5b94a8c498fd233bc72cbd3c9977c7541', class: `${this.elementClassName}__period` }, h("button", { key: '3d854b9b5aee10039b38af52513f12cf68e4c657', type: "button", class: {
263
+ } }, this.labels.seconds), h("div", { key: 'c2ed4d63a95a65bdc26926932e705744bbe776c5', class: `${this.elementClassName}__control` }, h("button", { key: '40d510ae7008802ce09ec98c9912f2f91cdb2db7', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--increment`, onClick: this.handleSecondIncrement, disabled: this.disabled || this.isAtMaxSecond(), "aria-label": this.labels.incrementSeconds }, h("svg", { key: 'fd3324d15759c7f2a752b6a32303c8eaddb0e588', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '5e2dad75d96a521f56f616bc2b88e4baa6c0eb50', points: "18 15 12 9 6 15" }))), h("input", { key: 'b1b517bb8147a45632388f432ae0e3595467ebce', id: `${this.elementClassName}-seconds`, type: "number", class: `${this.elementClassName}__input`, value: this.padZero(this.internalSeconds), min: 0, max: 59, onInput: this.handleSecondChange, disabled: this.disabled, "aria-label": this.labels.seconds }), h("button", { key: '7b82e86f2da4bd5c0f65c95cbcb26252e357625d', type: "button", class: `${this.elementClassName}__button ${this.elementClassName}__button--decrement`, onClick: this.handleSecondDecrement, disabled: this.disabled || this.isAtMinSecond(), "aria-label": this.labels.decrementSeconds }, h("svg", { key: 'c3b5ae33c5475b448c1a5e7fe3bb4748318441fb', fill: "none", height: "16", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", stroke: "currentColor", viewBox: "0 0 24 24", width: "16" }, h("polyline", { key: '3bb717320e078f5fa36912f15995ed604d9f702b', points: "6 9 12 15 18 9" })))))
264
+ ], this.useTwelveHourFormat && (h("div", { key: 'ec583890c2f7d97c6a6196f3556dfd76c8209227', class: `${this.elementClassName}__period` }, h("button", { key: 'e99d9b41ded6b138660f2777f60991bf3af12182', type: "button", class: {
193
265
  [`${this.elementClassName}__period-button`]: true,
194
266
  [`${this.elementClassName}__period-button--active`]: this.period === "AM"
195
- }, onClick: () => this.handlePeriodChange("AM"), disabled: this.disabled, "aria-label": this.labels.am, "aria-pressed": this.period === "AM" }, this.labels.am), h("button", { key: 'de12f50f898625cbd5b6afb65e2f396441ab5cf0', type: "button", class: {
267
+ }, onClick: () => this.handlePeriodChange("AM"), disabled: this.disabled, "aria-label": this.labels.am, "aria-pressed": this.period === "AM" }, this.labels.am), h("button", { key: '3a3cbc3b47b0218694db2c8909da97ea50e521f2', type: "button", class: {
196
268
  [`${this.elementClassName}__period-button`]: true,
197
269
  [`${this.elementClassName}__period-button--active`]: this.period === "PM"
198
270
  }, onClick: () => this.handlePeriodChange("PM"), disabled: this.disabled, "aria-label": this.labels.pm, "aria-pressed": this.period === "PM" }, this.labels.pm))))));
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CwtZ_Lud.js';
2
2
  import { g as getDefaultExportFromCjs, d as dayjs, c as customParseFormat } from './customParseFormat-DkyM-7xr.js';
3
- import { g as getISODateString, r as removeTimezoneOffset } from './utils-BVHu5CWV.js';
3
+ import { g as getISODateString, r as removeTimezoneOffset } from './utils-CoFOnMSw.js';
4
4
 
5
5
  var localizedFormat$2 = {exports: {}};
6
6
 
@@ -40,6 +40,7 @@ const TabworthyTimes = class {
40
40
  registerInstance(this, hostRef);
41
41
  this.selectDateTime = createEvent(this, "selectDateTime", 7);
42
42
  this.changeYear = createEvent(this, "changeYear", 7);
43
+ this.errorChange = createEvent(this, "errorChange", 7);
43
44
  this.componentReady = createEvent(this, "componentReady", 7);
44
45
  // Enable or disable range mode
45
46
  this.range = false;
@@ -101,6 +102,8 @@ const TabworthyTimes = class {
101
102
  if (this.range && dates.length === 2) {
102
103
  const startDate = removeTimezoneOffset(new Date(dates[0]));
103
104
  const endDate = removeTimezoneOffset(new Date(dates[1]));
105
+ if (!this.isDateValid(startDate) || !this.isDateValid(endDate))
106
+ return;
104
107
  this.updateValue([startDate, endDate]);
105
108
  // Update calendar with selected dates
106
109
  if (this.pickerRef) {
@@ -109,9 +112,14 @@ const TabworthyTimes = class {
109
112
  }
110
113
  else {
111
114
  const date = removeTimezoneOffset(new Date(dates[0]));
115
+ if (!this.isDateValid(date))
116
+ return;
117
+ // Clamp time to boundary constraints when selecting a boundary day
118
+ this.clampTimeToBounds(date);
112
119
  this.updateValue(date);
113
- // Update calendar with selected date
120
+ // Reset then set calendar value so re-clicking the same date still emits
114
121
  if (this.pickerRef) {
122
+ this.pickerRef.value = undefined;
115
123
  this.pickerRef.value = date;
116
124
  }
117
125
  }
@@ -167,6 +175,25 @@ const TabworthyTimes = class {
167
175
  parsed = dayjs(value);
168
176
  }
169
177
  if (parsed.isValid()) {
178
+ // Check minDate/maxDate bounds (supports both date-only and datetime strings)
179
+ if (this.minDate && parsed.isBefore(dayjs(this.minDate))) {
180
+ this.errorState = true;
181
+ this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
182
+ this.emitErrorChange("minDate", this.errorMessage);
183
+ return;
184
+ }
185
+ if (this.maxDate && parsed.isAfter(dayjs(this.maxDate))) {
186
+ this.errorState = true;
187
+ this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
188
+ this.emitErrorChange("maxDate", this.errorMessage);
189
+ return;
190
+ }
191
+ if (this.disableDate(parsed.toDate())) {
192
+ this.errorState = true;
193
+ this.errorMessage = this.timesLabels.disabledDateError;
194
+ this.emitErrorChange("disabledDate", this.errorMessage);
195
+ return;
196
+ }
170
197
  this.errorState = false;
171
198
  this.selectedHours = parsed.hour();
172
199
  this.selectedMinutes = parsed.minute();
@@ -177,9 +204,99 @@ const TabworthyTimes = class {
177
204
  // Set error state for invalid/garbage input
178
205
  this.errorState = true;
179
206
  this.errorMessage = this.timesLabels.invalidDateError;
207
+ this.emitErrorChange("invalid", this.errorMessage);
180
208
  }
181
209
  };
182
210
  }
211
+ emitErrorChange(reason, message) {
212
+ this.errorChange.emit({ reason, message });
213
+ }
214
+ formatBoundaryDate(dateString) {
215
+ const parsed = dayjs(dateString);
216
+ if (!parsed.isValid())
217
+ return dateString;
218
+ const hasTime = dateString.includes("T") || dateString.includes(" ");
219
+ if (!hasTime) {
220
+ return Intl.DateTimeFormat(this.locale, {
221
+ day: "numeric",
222
+ month: "short",
223
+ year: "numeric"
224
+ }).format(parsed.toDate());
225
+ }
226
+ const options = Object.assign({ day: "numeric", month: "short", year: "numeric", hour: "numeric", minute: "numeric" }, (this.showSeconds ? { second: "numeric" } : {}));
227
+ return Intl.DateTimeFormat(this.locale, options).format(parsed.toDate());
228
+ }
229
+ getEffectiveMinTime() {
230
+ if (!this.minDate || !this.selectedDate)
231
+ return undefined;
232
+ const min = dayjs(this.minDate);
233
+ const sel = dayjs(this.selectedDate);
234
+ if (!min.isValid() || !sel.isSame(min, "day"))
235
+ return undefined;
236
+ return {
237
+ hours: min.hour(),
238
+ minutes: min.minute(),
239
+ seconds: min.second()
240
+ };
241
+ }
242
+ getEffectiveMaxTime() {
243
+ if (!this.maxDate || !this.selectedDate)
244
+ return undefined;
245
+ const max = dayjs(this.maxDate);
246
+ const sel = dayjs(this.selectedDate);
247
+ if (!max.isValid() || !sel.isSame(max, "day"))
248
+ return undefined;
249
+ return {
250
+ hours: max.hour(),
251
+ minutes: max.minute(),
252
+ seconds: max.second()
253
+ };
254
+ }
255
+ isDateOutOfBounds() {
256
+ if (!this.selectedDate)
257
+ return false;
258
+ const sel = dayjs(this.selectedDate);
259
+ if (this.minDate && sel.isBefore(dayjs(this.minDate), "day"))
260
+ return true;
261
+ if (this.maxDate && sel.isAfter(dayjs(this.maxDate), "day"))
262
+ return true;
263
+ return false;
264
+ }
265
+ /**
266
+ * When selecting a date on a boundary day, adjust the time to the first
267
+ * available time if the current selection falls outside the allowed range.
268
+ */
269
+ clampTimeToBounds(date) {
270
+ const sel = dayjs(date);
271
+ if (this.minDate) {
272
+ const min = dayjs(this.minDate);
273
+ if (min.isValid() && sel.isSame(min, "day")) {
274
+ const curTotal = this.selectedHours * 3600 +
275
+ this.selectedMinutes * 60 +
276
+ this.selectedSeconds;
277
+ const minTotal = min.hour() * 3600 + min.minute() * 60 + min.second();
278
+ if (curTotal < minTotal) {
279
+ this.selectedHours = min.hour();
280
+ this.selectedMinutes = min.minute();
281
+ this.selectedSeconds = min.second();
282
+ }
283
+ }
284
+ }
285
+ if (this.maxDate) {
286
+ const max = dayjs(this.maxDate);
287
+ if (max.isValid() && sel.isSame(max, "day")) {
288
+ const curTotal = this.selectedHours * 3600 +
289
+ this.selectedMinutes * 60 +
290
+ this.selectedSeconds;
291
+ const maxTotal = max.hour() * 3600 + max.minute() * 60 + max.second();
292
+ if (curTotal > maxTotal) {
293
+ this.selectedHours = max.hour();
294
+ this.selectedMinutes = max.minute();
295
+ this.selectedSeconds = max.second();
296
+ }
297
+ }
298
+ }
299
+ }
183
300
  shouldInputFormat() {
184
301
  if (typeof this.inputShouldFormat === "string") {
185
302
  return this.inputShouldFormat === "true";
@@ -252,6 +369,30 @@ const TabworthyTimes = class {
252
369
  this.formatInput();
253
370
  }
254
371
  }
372
+ isDateValid(date) {
373
+ const parsed = dayjs(date);
374
+ if (!parsed.isValid())
375
+ return false;
376
+ if (this.minDate && parsed.isBefore(dayjs(this.minDate), "day")) {
377
+ this.errorState = true;
378
+ this.errorMessage = `${this.timesLabels.minDateError} ${this.formatBoundaryDate(this.minDate)}`;
379
+ this.emitErrorChange("minDate", this.errorMessage);
380
+ return false;
381
+ }
382
+ if (this.maxDate && parsed.isAfter(dayjs(this.maxDate), "day")) {
383
+ this.errorState = true;
384
+ this.errorMessage = `${this.timesLabels.maxDateError} ${this.formatBoundaryDate(this.maxDate)}`;
385
+ this.emitErrorChange("maxDate", this.errorMessage);
386
+ return false;
387
+ }
388
+ if (this.disableDate(date)) {
389
+ this.errorState = true;
390
+ this.errorMessage = this.timesLabels.disabledDateError;
391
+ this.emitErrorChange("disabledDate", this.errorMessage);
392
+ return false;
393
+ }
394
+ return true;
395
+ }
255
396
  formatInput() {
256
397
  if (!this.internalValue)
257
398
  return;
@@ -292,12 +433,12 @@ const TabworthyTimes = class {
292
433
  }
293
434
  render() {
294
435
  var _a;
295
- return (h(Host, { key: 'e07a561aa76dedbf8f8e28c491b3aac19f45c472', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '24e11901760a8c7f989f3d33df9cd58af899a8dc', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '17c4a53c621b66e62f857d49b4b8f4b52d51183d', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: '7dd776e464533c7bb6c842a0332f0d667f52c7cc', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
436
+ return (h(Host, { key: '6c3049b02eda2e976f14616027cfb3fd1a0b0100', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: 'eb9ecc8c81d04338a5935ad414c6cd544a01bb58', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: '8906972aec0b8c7b24cc3f2d07212c3f6c2d8f56', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'bca908ac7aa2710569fa86be5c7c6643d7f73574', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
296
437
  [this.getClassName("input")]: true,
297
438
  [this.inputClass]: !!this.inputClass
298
- }, placeholder: this.placeholder, disabled: this.disabledState || this.disableFreeformInput, value: (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.toString(), onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: '0e84b4e3ae7f5abe1a59e939cccc227bf34ab992', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
439
+ }, placeholder: this.placeholder, disabled: this.disabledState || this.disableFreeformInput, value: (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.toString(), onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: 'c0d27ab5207fb62606e017bea14c93bc44daebb9', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState, "aria-label": this.calendarButtonContent
299
440
  ? this.timesLabels.openCalendar
300
- : undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: 'baebeeeda4200bf13fe8f023bb39e2c13fc58b0b', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
441
+ : undefined }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '1e6761504cd55a9fd380902861aeec0e7e655d47', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
301
442
  if (this.pickerRef) {
302
443
  this.pickerRef.modalIsOpen = true;
303
444
  }
@@ -305,7 +446,7 @@ const TabworthyTimes = class {
305
446
  if (this.pickerRef) {
306
447
  this.pickerRef.modalIsOpen = false;
307
448
  }
308
- }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '0fc94282af5f36ae9214e967dab2acac911bca14', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '4b0ef9c95058398d759fe913b22a84d5f22bd383', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), onRequestClose: () => { var _a; return (_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close(); }, labels: this.datesCalendarLabels, ref: (el) => (this.pickerRef = el), startDate: this.startDate, firstDayOfWeek: this.firstDayOfWeek, showHiddenTitle: true, disabled: this.disabledState, showMonthStepper: this.showMonthStepper, showYearStepper: this.showYearStepper, showClearButton: this.showClearButton, showCloseButton: this.showCloseButton, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline, value: this.value ? this.toDate(this.value) : undefined, nextMonthButtonContent: this.nextMonthButtonContent, nextYearButtonContent: this.nextYearButtonContent, previousMonthButtonContent: this.previousMonthButtonContent, previousYearButtonContent: this.previousYearButtonContent, todayButtonContent: this.todayButtonContent, clearButtonContent: this.clearButtonContent, closeButtonContent: this.closeButtonContent }, h("div", { key: 'b766d90c7bb4732c6ae26cadeb610a6e0c10a597', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: 'f98fc31d11a3bdd999a5dc0cc15bf1921f349b9b', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: 'cfe86bb9291d1a14d37ab7240ec2f2f7f9bece4d', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (h("div", { key: '1c2d4b6469266b894402512612a71721acf28f7e', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
449
+ }, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '14966bd22b73a14fcb54bf118543e6aedf6e291f', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: 'aef55f7ee2cb19eb68bf8db51dd3e111e4f0dbff', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), onRequestClose: () => { var _a; return (_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close(); }, labels: this.datesCalendarLabels, ref: (el) => (this.pickerRef = el), startDate: this.startDate, firstDayOfWeek: this.firstDayOfWeek, showHiddenTitle: true, disabled: this.disabledState, showMonthStepper: this.showMonthStepper, showYearStepper: this.showYearStepper, showClearButton: this.showClearButton, showCloseButton: this.showCloseButton, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline, value: this.value ? this.toDate(this.value) : undefined, nextMonthButtonContent: this.nextMonthButtonContent, nextYearButtonContent: this.nextYearButtonContent, previousMonthButtonContent: this.previousMonthButtonContent, previousYearButtonContent: this.previousYearButtonContent, todayButtonContent: this.todayButtonContent, clearButtonContent: this.clearButtonContent, closeButtonContent: this.closeButtonContent }, h("div", { key: 'f89b6d83e9ef68bd98eb6e08ea3aec00c2b6dd86', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '2ae84e5817c25641ab56ff096f164355524abfdf', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '55bfe07297efd0c60d47d6049572f502311abf15', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState || this.isDateOutOfBounds(), onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels, minTime: this.getEffectiveMinTime(), maxTime: this.getEffectiveMaxTime() }))))), this.errorState && (h("div", { key: '97dbda7bc8725c8964a627e37e9236e9bf699ee0', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
309
450
  }
310
451
  get el() { return getElement(this); }
311
452
  static get watchers() { return {
@@ -136,6 +136,17 @@ function removeTimezoneOffset(date) {
136
136
  newDate.setMinutes(newDate.getMinutes() + newDate.getTimezoneOffset());
137
137
  return newDate;
138
138
  }
139
+ /**
140
+ * Parse a date boundary string to a local Date.
141
+ * Date-only strings ("YYYY-MM-DD") are parsed as UTC by JS, so we apply removeTimezoneOffset.
142
+ * Datetime strings (containing "T" or space+time) are already parsed as local time.
143
+ */
144
+ function parseDateString(dateString) {
145
+ const hasTime = dateString.includes("T") ||
146
+ /\d{4}-\d{2}-\d{2}\s\d{2}:/.test(dateString);
147
+ const parsed = new Date(dateString);
148
+ return hasTime ? parsed : removeTimezoneOffset(parsed);
149
+ }
139
150
  function subDays(date, days) {
140
151
  const newDate = new Date(date);
141
152
  newDate.setDate(newDate.getDate() - days);
@@ -143,7 +154,7 @@ function subDays(date, days) {
143
154
  }
144
155
  function dateIsWithinLowerBounds(date, minDate) {
145
156
  if (minDate) {
146
- const min = removeTimezoneOffset(new Date(minDate));
157
+ const min = parseDateString(minDate);
147
158
  return date >= min || isSameDay(min, date);
148
159
  }
149
160
  else
@@ -151,7 +162,7 @@ function dateIsWithinLowerBounds(date, minDate) {
151
162
  }
152
163
  function dateIsWithinUpperBounds(date, maxDate) {
153
164
  if (maxDate) {
154
- const max = removeTimezoneOffset(new Date(maxDate));
165
+ const max = parseDateString(maxDate);
155
166
  return date <= max || isSameDay(date, max);
156
167
  }
157
168
  else
@@ -162,12 +173,21 @@ function dateIsWithinBounds(date, minDate, maxDate) {
162
173
  dateIsWithinUpperBounds(date, maxDate));
163
174
  }
164
175
  function monthIsDisabled(month, year, minDate, maxDate) {
165
- const firstDate = new Date(year, month, 1);
166
- firstDate.setDate(firstDate.getDate() - 1);
167
- const lastDate = new Date(year, month + 1, 0);
168
- lastDate.setDate(firstDate.getDate() + 1);
169
- return (!dateIsWithinBounds(firstDate, minDate, maxDate) &&
170
- !dateIsWithinBounds(lastDate, minDate, maxDate));
176
+ if (minDate) {
177
+ const min = parseDateString(minDate);
178
+ const minYear = min.getFullYear();
179
+ const minMonth = min.getMonth();
180
+ if (year < minYear || (year === minYear && month < minMonth))
181
+ return true;
182
+ }
183
+ if (maxDate) {
184
+ const max = parseDateString(maxDate);
185
+ const maxYear = max.getFullYear();
186
+ const maxMonth = max.getMonth();
187
+ if (year > maxYear || (year === maxYear && month > maxMonth))
188
+ return true;
189
+ }
190
+ return false;
171
191
  }
172
192
  function isValidISODate(dateString) {
173
193
  var isoFormat = /^\d{4}-\d{2}-\d{2}$/;
@@ -185,4 +205,4 @@ function extractDates(text) {
185
205
  return matches === null || matches === void 0 ? void 0 : matches.slice(0, 2);
186
206
  }
187
207
 
188
- export { getNextMonth as a, getNextYear as b, getPreviousMonth as c, getPreviousYear as d, dateIsWithinBounds as e, getPreviousDay as f, getISODateString as g, getNextDay as h, addDays as i, getFirstOfMonth as j, getLastOfMonth as k, getWeekDays as l, getDaysOfMonth as m, dateIsWithinLowerBounds as n, dateIsWithinUpperBounds as o, getYear as p, getMonth as q, removeTimezoneOffset as r, subDays as s, monthIsDisabled as t, getMonths as u, isSameDay as v, isDateInRange as w, extractDates as x, isValidISODate as y };
208
+ export { getNextMonth as a, getNextYear as b, getPreviousMonth as c, getPreviousYear as d, dateIsWithinBounds as e, getPreviousDay as f, getISODateString as g, getNextDay as h, addDays as i, getFirstOfMonth as j, getLastOfMonth as k, getWeekDays as l, monthIsDisabled as m, getDaysOfMonth as n, dateIsWithinLowerBounds as o, parseDateString as p, dateIsWithinUpperBounds as q, removeTimezoneOffset as r, subDays as s, getYear as t, getMonth as u, getMonths as v, isSameDay as w, isDateInRange as x, extractDates as y, isValidISODate as z };
@@ -136,6 +136,17 @@ export function removeTimezoneOffset(date) {
136
136
  newDate.setMinutes(newDate.getMinutes() + newDate.getTimezoneOffset());
137
137
  return newDate;
138
138
  }
139
+ /**
140
+ * Parse a date boundary string to a local Date.
141
+ * Date-only strings ("YYYY-MM-DD") are parsed as UTC by JS, so we apply removeTimezoneOffset.
142
+ * Datetime strings (containing "T" or space+time) are already parsed as local time.
143
+ */
144
+ export function parseDateString(dateString) {
145
+ const hasTime = dateString.includes("T") ||
146
+ /\d{4}-\d{2}-\d{2}\s\d{2}:/.test(dateString);
147
+ const parsed = new Date(dateString);
148
+ return hasTime ? parsed : removeTimezoneOffset(parsed);
149
+ }
139
150
  export function subDays(date, days) {
140
151
  const newDate = new Date(date);
141
152
  newDate.setDate(newDate.getDate() - days);
@@ -143,7 +154,7 @@ export function subDays(date, days) {
143
154
  }
144
155
  export function dateIsWithinLowerBounds(date, minDate) {
145
156
  if (minDate) {
146
- const min = removeTimezoneOffset(new Date(minDate));
157
+ const min = parseDateString(minDate);
147
158
  return date >= min || isSameDay(min, date);
148
159
  }
149
160
  else
@@ -151,7 +162,7 @@ export function dateIsWithinLowerBounds(date, minDate) {
151
162
  }
152
163
  export function dateIsWithinUpperBounds(date, maxDate) {
153
164
  if (maxDate) {
154
- const max = removeTimezoneOffset(new Date(maxDate));
165
+ const max = parseDateString(maxDate);
155
166
  return date <= max || isSameDay(date, max);
156
167
  }
157
168
  else
@@ -162,12 +173,21 @@ export function dateIsWithinBounds(date, minDate, maxDate) {
162
173
  dateIsWithinUpperBounds(date, maxDate));
163
174
  }
164
175
  export function monthIsDisabled(month, year, minDate, maxDate) {
165
- const firstDate = new Date(year, month, 1);
166
- firstDate.setDate(firstDate.getDate() - 1);
167
- const lastDate = new Date(year, month + 1, 0);
168
- lastDate.setDate(firstDate.getDate() + 1);
169
- return (!dateIsWithinBounds(firstDate, minDate, maxDate) &&
170
- !dateIsWithinBounds(lastDate, minDate, maxDate));
176
+ if (minDate) {
177
+ const min = parseDateString(minDate);
178
+ const minYear = min.getFullYear();
179
+ const minMonth = min.getMonth();
180
+ if (year < minYear || (year === minYear && month < minMonth))
181
+ return true;
182
+ }
183
+ if (maxDate) {
184
+ const max = parseDateString(maxDate);
185
+ const maxYear = max.getFullYear();
186
+ const maxMonth = max.getMonth();
187
+ if (year > maxYear || (year === maxYear && month > maxMonth))
188
+ return true;
189
+ }
190
+ return false;
171
191
  }
172
192
  export function isValidISODate(dateString) {
173
193
  var isoFormat = /^\d{4}-\d{2}-\d{2}$/;