@tabworthy/components 0.11.3 → 0.12.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.
- package/dist/cjs/customParseFormat-l09KVyWD.js +45 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/tabworthy-components.cjs.js +1 -1
- package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +8 -8
- package/dist/cjs/tabworthy-dates.cjs.entry.js +50 -22
- package/dist/cjs/tabworthy-times-picker.cjs.entry.js +8 -8
- package/dist/cjs/tabworthy-times.cjs.entry.js +52 -26
- package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +70 -17
- package/dist/collection/components/tabworthy-dates-calendar/tabworthy-dates-calendar.js +1 -1
- package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +3 -3
- package/dist/collection/components/tabworthy-times/tabworthy-times.js +35 -25
- package/dist/collection/components/tabworthy-times-picker/tabworthy-times-picker.js +8 -8
- package/dist/components/{p-B6lbpNd2.js → p-BTQaxOHo.js} +1 -1
- package/dist/components/{p-CIQgnOXj.js → p-CMIEIvTW.js} +1 -1
- package/dist/components/p-DkyM-7xr.js +1 -0
- package/dist/components/{p-CGo5md1l.js → p-M03P4DAz.js} +1 -1
- package/dist/components/tabworthy-dates-calendar.js +1 -1
- package/dist/components/tabworthy-dates-modal.js +1 -1
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times-picker.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/customParseFormat-DkyM-7xr.js +41 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tabworthy-components.js +1 -1
- package/dist/esm/tabworthy-dates-calendar_2.entry.js +7 -7
- package/dist/esm/tabworthy-dates.entry.js +49 -21
- package/dist/esm/tabworthy-times-picker.entry.js +8 -8
- package/dist/esm/tabworthy-times.entry.js +52 -26
- package/dist/tabworthy-components/{p-60793499.entry.js → p-1743bf7a.entry.js} +1 -1
- package/dist/tabworthy-components/p-744ffef9.entry.js +1 -0
- package/dist/tabworthy-components/p-DkyM-7xr.js +1 -0
- package/dist/tabworthy-components/p-bc07c40b.entry.js +1 -0
- package/dist/tabworthy-components/{p-f1688c61.entry.js → p-df93e5d4.entry.js} +1 -1
- package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
- package/dist/themes/light.css +1 -1
- package/dist/types/components/tabworthy-dates/tabworthy-dates.d.ts +3 -0
- package/dist/types/components/tabworthy-dates-calendar/tabworthy-dates-calendar.d.ts +1 -1
- package/dist/types/components/tabworthy-modal/tabworthy-dates-modal.d.ts +1 -1
- package/dist/types/components/tabworthy-times/tabworthy-times.d.ts +1 -1
- package/dist/types/components.d.ts +9 -0
- package/package.json +2 -3
- package/dist/cjs/moment-CdViwxPQ.js +0 -5681
- package/dist/components/p-Mki5YqAR.js +0 -8
- package/dist/esm/moment-Mki5YqAR.js +0 -5679
- package/dist/tabworthy-components/p-Mki5YqAR.js +0 -8
- package/dist/tabworthy-components/p-d4a7458b.entry.js +0 -1
- package/dist/tabworthy-components/p-ea7b79b0.entry.js +0 -1
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CwtZ_Lud.js';
|
|
2
|
-
import {
|
|
2
|
+
import { g as getDefaultExportFromCjs, d as dayjs, c as customParseFormat } from './customParseFormat-DkyM-7xr.js';
|
|
3
3
|
import { g as getISODateString, r as removeTimezoneOffset } from './utils-BVHu5CWV.js';
|
|
4
4
|
|
|
5
|
+
var localizedFormat$2 = {exports: {}};
|
|
6
|
+
|
|
7
|
+
var localizedFormat$1 = localizedFormat$2.exports;
|
|
8
|
+
|
|
9
|
+
var hasRequiredLocalizedFormat;
|
|
10
|
+
|
|
11
|
+
function requireLocalizedFormat () {
|
|
12
|
+
if (hasRequiredLocalizedFormat) return localizedFormat$2.exports;
|
|
13
|
+
hasRequiredLocalizedFormat = 1;
|
|
14
|
+
(function (module, exports) {
|
|
15
|
+
!function(e,t){module.exports=t();}(localizedFormat$1,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,o,n){var r=o.prototype,i=r.format;n.en.formats=e,r.format=function(t){ void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var o=this.$locale().formats,n=function(t,o){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||o[r]||e[r]||o[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,o){return t||o.slice(1)}))}))}(t,void 0===o?{}:o);return i.call(this,n)};}}));
|
|
16
|
+
} (localizedFormat$2));
|
|
17
|
+
return localizedFormat$2.exports;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var localizedFormatExports = requireLocalizedFormat();
|
|
21
|
+
var localizedFormat = /*@__PURE__*/getDefaultExportFromCjs(localizedFormatExports);
|
|
22
|
+
|
|
23
|
+
dayjs.extend(customParseFormat);
|
|
24
|
+
dayjs.extend(localizedFormat);
|
|
5
25
|
const defaultLabels = {
|
|
6
26
|
selected: "selected",
|
|
7
27
|
openCalendar: "Choose time",
|
|
@@ -13,9 +33,10 @@ const defaultLabels = {
|
|
|
13
33
|
disabledDateError: `Please choose an available date`,
|
|
14
34
|
to: "to",
|
|
15
35
|
startDate: "Start date",
|
|
36
|
+
yearSelect: "Select year",
|
|
16
37
|
timeLabel: "Time"
|
|
17
38
|
};
|
|
18
|
-
const
|
|
39
|
+
const TabworthyTimes = class {
|
|
19
40
|
constructor(hostRef) {
|
|
20
41
|
registerInstance(this, hostRef);
|
|
21
42
|
this.selectDateTime = createEvent(this, "selectDateTime", 7);
|
|
@@ -129,11 +150,16 @@ const InclusiveTimes = class {
|
|
|
129
150
|
};
|
|
130
151
|
this.handleInputChange = (event) => {
|
|
131
152
|
const value = event.target.value;
|
|
132
|
-
// Try to parse the input value
|
|
133
|
-
|
|
153
|
+
// Try to parse the input value using the component's format first (strict mode)
|
|
154
|
+
// This prevents dayjs from misinterpreting date formats (e.g., DD/MM/YYYY as MM/DD/YYYY)
|
|
155
|
+
let parsed = dayjs(value, this.format, true);
|
|
156
|
+
// Fall back to loose parsing if strict format doesn't match
|
|
157
|
+
if (!parsed.isValid()) {
|
|
158
|
+
parsed = dayjs(value);
|
|
159
|
+
}
|
|
134
160
|
if (parsed.isValid()) {
|
|
135
|
-
this.selectedHours = parsed.
|
|
136
|
-
this.selectedMinutes = parsed.
|
|
161
|
+
this.selectedHours = parsed.hour();
|
|
162
|
+
this.selectedMinutes = parsed.minute();
|
|
137
163
|
this.updateValue(parsed.toDate());
|
|
138
164
|
}
|
|
139
165
|
};
|
|
@@ -166,12 +192,12 @@ const InclusiveTimes = class {
|
|
|
166
192
|
// Parse the first datetime value to set time picker
|
|
167
193
|
const firstValue = Array.isArray(this.value) ? this.value[0] : this.value;
|
|
168
194
|
if (firstValue) {
|
|
169
|
-
const parsed =
|
|
195
|
+
const parsed = dayjs(firstValue, this.format);
|
|
170
196
|
if (parsed.isValid()) {
|
|
171
197
|
this.selectedDate = parsed.toDate();
|
|
172
|
-
this.selectedHours = parsed.
|
|
173
|
-
this.selectedMinutes = parsed.
|
|
174
|
-
this.selectedSeconds = parsed.
|
|
198
|
+
this.selectedHours = parsed.hour();
|
|
199
|
+
this.selectedMinutes = parsed.minute();
|
|
200
|
+
this.selectedSeconds = parsed.second();
|
|
175
201
|
}
|
|
176
202
|
}
|
|
177
203
|
}
|
|
@@ -183,10 +209,10 @@ const InclusiveTimes = class {
|
|
|
183
209
|
if (Array.isArray(date)) {
|
|
184
210
|
// Range mode
|
|
185
211
|
const formattedDates = date.map((d) => {
|
|
186
|
-
const m =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
const m = dayjs(d)
|
|
213
|
+
.hour(this.selectedHours)
|
|
214
|
+
.minute(this.selectedMinutes)
|
|
215
|
+
.second(this.selectedSeconds);
|
|
190
216
|
return m.format(this.format);
|
|
191
217
|
});
|
|
192
218
|
this.internalValue = formattedDates;
|
|
@@ -195,10 +221,10 @@ const InclusiveTimes = class {
|
|
|
195
221
|
}
|
|
196
222
|
else {
|
|
197
223
|
// Single date mode
|
|
198
|
-
const m =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
224
|
+
const m = dayjs(date)
|
|
225
|
+
.hour(this.selectedHours)
|
|
226
|
+
.minute(this.selectedMinutes)
|
|
227
|
+
.second(this.selectedSeconds);
|
|
202
228
|
const formatted = m.format(this.format);
|
|
203
229
|
this.internalValue = formatted;
|
|
204
230
|
this.value = formatted;
|
|
@@ -216,13 +242,13 @@ const InclusiveTimes = class {
|
|
|
216
242
|
if (Array.isArray(this.internalValue)) {
|
|
217
243
|
// Format range
|
|
218
244
|
const formatted = this.internalValue
|
|
219
|
-
.map((v) =>
|
|
245
|
+
.map((v) => dayjs(v, this.format).format("lll"))
|
|
220
246
|
.join(` ${this.timesLabels.to} `);
|
|
221
247
|
this.inputRef.value = formatted;
|
|
222
248
|
}
|
|
223
249
|
else {
|
|
224
250
|
// Format single datetime
|
|
225
|
-
this.inputRef.value =
|
|
251
|
+
this.inputRef.value = dayjs(this.internalValue, this.format).format("lll");
|
|
226
252
|
}
|
|
227
253
|
}
|
|
228
254
|
getClassName(suffix) {
|
|
@@ -232,8 +258,8 @@ const InclusiveTimes = class {
|
|
|
232
258
|
if (!dateString)
|
|
233
259
|
return null;
|
|
234
260
|
const date = Array.isArray(dateString)
|
|
235
|
-
? dateString.map((d) =>
|
|
236
|
-
:
|
|
261
|
+
? dateString.map((d) => dayjs(d, this.format).toDate())
|
|
262
|
+
: dayjs(dateString, this.format).toDate();
|
|
237
263
|
return date;
|
|
238
264
|
}
|
|
239
265
|
async clearValue() {
|
|
@@ -250,10 +276,10 @@ const InclusiveTimes = class {
|
|
|
250
276
|
}
|
|
251
277
|
render() {
|
|
252
278
|
var _a;
|
|
253
|
-
return (h(Host, { key: '
|
|
279
|
+
return (h(Host, { key: '16801875a7a022afd2db87e489ff69133e27773d', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: 'f0aa269a9677dbda54d31ea0fa32e69f6ef19114', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: 'a3fa49e1735adb2e32d0dbd4b5fe21d1b1e9ba9c', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'dab0c8ff6a9f941b1e3c8a801b2e0de8262beda2', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
|
|
254
280
|
[this.getClassName("input")]: true,
|
|
255
281
|
[this.inputClass]: !!this.inputClass
|
|
256
|
-
}, 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: '
|
|
282
|
+
}, 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: 'c072cedad6d4567b3688e434a7173441b4a11026', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '4a4e37ff7f76d51389153b52d281fdc1a8f861d5', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
257
283
|
if (this.pickerRef) {
|
|
258
284
|
this.pickerRef.modalIsOpen = true;
|
|
259
285
|
}
|
|
@@ -261,7 +287,7 @@ const InclusiveTimes = class {
|
|
|
261
287
|
if (this.pickerRef) {
|
|
262
288
|
this.pickerRef.modalIsOpen = false;
|
|
263
289
|
}
|
|
264
|
-
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '
|
|
290
|
+
}, inline: this.inline, appendTo: this.appendTo }, h("div", { key: '9b03ffb9df5a041d802647d66af53eafec187c7f', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '0caab550470b253542d93e29ddadcde85fe7caad', 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 }, h("div", { key: '655aa9bb049f76dba44f18684fec6550ab8aac22', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: 'b695207bda87835f57240f72bea88dc57470c170', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: 'f17bf595f1df723dc04d87ef86a5f5a6152b506a', 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: '8bf64ca388076cd5f1ad73b763993dbc7736b08c', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
265
291
|
}
|
|
266
292
|
get el() { return getElement(this); }
|
|
267
293
|
static get watchers() { return {
|
|
@@ -277,4 +303,4 @@ const InclusiveTimes = class {
|
|
|
277
303
|
}; }
|
|
278
304
|
};
|
|
279
305
|
|
|
280
|
-
export {
|
|
306
|
+
export { TabworthyTimes as tabworthy_times };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as e,h as s,H as i,g as h}from"./p-CwtZ_Lud.js";const a={hours:"Hours",minutes:"Minutes",seconds:"Seconds",am:"AM",pm:"PM",timePicker:"Time picker",incrementHours:"Increment hours",decrementHours:"Decrement hours",incrementMinutes:"Increment minutes",decrementMinutes:"Decrement minutes",incrementSeconds:"Increment seconds",decrementSeconds:"Decrement seconds"},n=class{constructor(s){t(this,s),this.timeChanged=e(this,"timeChanged",7),this.hours=12,this.minutes=0,this.seconds=0,this.useTwelveHourFormat=!1,this.showSeconds=!1,this.labels=a,this.labelsSrOnly=!0,this.disabled=!1,this.elementClassName="tabworthy-times-picker",this.internalHours=this.hours,this.internalMinutes=this.minutes,this.internalSeconds=this.seconds,this.period=this.hours>=12?"PM":"AM",this.handleHourChange=t=>{const e=parseInt(t.target.value,10);this.internalHours=this.useTwelveHourFormat?"AM"===this.period?12===e?0:e:12===e?12:e+12:e,this.emitTimeChange()},this.handleMinuteChange=t=>{this.internalMinutes=parseInt(t.target.value,10),this.emitTimeChange()},this.handlePeriodChange=t=>{if(this.period===t||!this.useTwelveHourFormat)return;this.period=t;const e=this.getDisplayHours();this.internalHours="AM"===t?12===e?0:e:12===e?12:e+12,this.emitTimeChange()},this.handleHourIncrement=()=>{if(this.useTwelveHourFormat){const t=this.getDisplayHours(),e=12===t?1:t+1;this.internalHours="AM"===this.period?12===e?0:e:12===e?12:e+12}else this.internalHours=(this.internalHours+1)%24;this.emitTimeChange()},this.handleHourDecrement=()=>{if(this.useTwelveHourFormat){const t=this.getDisplayHours(),e=1===t?12:t-1;this.internalHours="AM"===this.period?12===e?0:e:12===e?12:e+12}else this.internalHours=0===this.internalHours?23:this.internalHours-1;this.emitTimeChange()},this.handleMinuteIncrement=()=>{this.internalMinutes=(this.internalMinutes+1)%60,this.emitTimeChange()},this.handleMinuteDecrement=()=>{this.internalMinutes=0===this.internalMinutes?59:this.internalMinutes-1,this.emitTimeChange()},this.handleSecondChange=t=>{this.internalSeconds=parseInt(t.target.value,10),this.emitTimeChange()},this.handleSecondIncrement=()=>{this.internalSeconds=(this.internalSeconds+1)%60,this.emitTimeChange()},this.handleSecondDecrement=()=>{this.internalSeconds=0===this.internalSeconds?59:this.internalSeconds-1,this.emitTimeChange()}}watchHours(t){this.internalHours=t,this.period=t>=12?"PM":"AM"}watchMinutes(t){this.internalMinutes=t}watchSeconds(t){this.internalSeconds=t}componentWillLoad(){this.internalHours=this.hours,this.internalMinutes=this.minutes,this.internalSeconds=this.seconds,this.period=this.hours>=12?"PM":"AM"}getDisplayHours(){return this.useTwelveHourFormat?0===this.internalHours?12:this.internalHours>12?this.internalHours-12:this.internalHours:this.internalHours}get24HourValue(){if(!this.useTwelveHourFormat)return this.internalHours;const t=this.getDisplayHours();return"AM"===this.period?12===t?0:t:12===t?12:t+12}emitTimeChange(){this.timeChanged.emit({hours:this.get24HourValue(),minutes:this.internalMinutes,seconds:this.showSeconds?this.internalSeconds:void 0,period:this.useTwelveHourFormat?this.period:void 0})}padZero(t){return t.toString().padStart(2,"0")}render(){const t=this.getDisplayHours(),e=this.useTwelveHourFormat?12:23,h=this.useTwelveHourFormat?1:0;return s(i,{key:"372c9246a2607ae7553b61ba7445086000193ed1",class:this.elementClassName,"aria-label":this.labels.timePicker},s("div",{key:"fc8ea016f0c0cef3496024285fada802395011ac",class:`${this.elementClassName}__container`},s("div",{key:"235d60b72a515d2b935a736bef6768b057714a53",class:`${this.elementClassName}__field`},s("label",{key:"9f9c5cfee7fb8a44d9b4902809805b5aa2568f18",htmlFor:`${this.elementClassName}-hours`,class:{[`${this.elementClassName}__label`]:!0,[`${this.elementClassName}__label--sr-only`]:this.labelsSrOnly}},this.labels.hours),s("div",{key:"c5e369d24840f55c994d8a546bcca3569e2619ef",class:`${this.elementClassName}__control`},s("button",{key:"51f6278e8af5d4ec0b6ad11e2e1b90ec642adb08",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--increment`,onClick:this.handleHourIncrement,disabled:this.disabled,"aria-label":this.labels.incrementHours},s("svg",{key:"2bd03474f449be514d4a83e00606d476120d7bae",fill:"none",height:"16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",stroke:"currentColor",viewBox:"0 0 24 24",width:"16"},s("polyline",{key:"c50112d7748c97e93e4fa0a567ef2a74609e295b",points:"18 15 12 9 6 15"}))),s("input",{key:"a157d44b72d46e6e67b91ac8d00caa5f8df046e7",id:`${this.elementClassName}-hours`,type:"number",class:`${this.elementClassName}__input`,value:this.padZero(t),min:h,max:e,onInput:this.handleHourChange,disabled:this.disabled,"aria-label":this.labels.hours}),s("button",{key:"63a18713421f84b35b8a9bcef4c10213086bab8e",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--decrement`,onClick:this.handleHourDecrement,disabled:this.disabled,"aria-label":this.labels.decrementHours},s("svg",{key:"3e6c61c533b9ae91d1f35d424c54602b5bd1252c",fill:"none",height:"16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",stroke:"currentColor",viewBox:"0 0 24 24",width:"16"},s("polyline",{key:"cfe2fe7edfc882bd03ffbb1c7a282b73afac42ac",points:"6 9 12 15 18 9"}))))),s("div",{key:"e1956c2fa548d3e011ec7a9f88f837e8482280b2",class:`${this.elementClassName}__separator`},":"),s("div",{key:"6e8292b63371a4a37fb6afca9a3668e87d583fde",class:`${this.elementClassName}__field`},s("label",{key:"876283ccffdce8688ac400d4c46d7f99735da14a",htmlFor:`${this.elementClassName}-minutes`,class:{[`${this.elementClassName}__label`]:!0,[`${this.elementClassName}__label--sr-only`]:this.labelsSrOnly}},this.labels.minutes),s("div",{key:"afdfa8c592b9b90c62fd1fb77a2494977f4edcd2",class:`${this.elementClassName}__control`},s("button",{key:"06d2051e46aa19299ce8a59fe0d474d26f905ed9",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--increment`,onClick:this.handleMinuteIncrement,disabled:this.disabled,"aria-label":this.labels.incrementMinutes},s("svg",{key:"28e6fda7aeb3246e639c0e5e76853576815c1fd1",fill:"none",height:"16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",stroke:"currentColor",viewBox:"0 0 24 24",width:"16"},s("polyline",{key:"43df9c8fcfc53ff8ebbd0879abd4d1ebc056b9ba",points:"18 15 12 9 6 15"}))),s("input",{key:"6b2eb0ac1dbe34304f349b4780e0ae9553cf955d",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}),s("button",{key:"65e5c108a5cd0451512a1d6c717d1176092e7efb",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--decrement`,onClick:this.handleMinuteDecrement,disabled:this.disabled,"aria-label":this.labels.decrementMinutes},s("svg",{key:"fb53625bccc3aef8447e70bf7c7b00bc7df03830",fill:"none",height:"16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",stroke:"currentColor",viewBox:"0 0 24 24",width:"16"},s("polyline",{key:"ee6274f6d2035243412e992ceec7ae7aecf8793f",points:"6 9 12 15 18 9"}))))),this.showSeconds&&[s("div",{key:"3ee853ccf77f36e4937736a1451eaaaf4aae1ba9",class:`${this.elementClassName}__separator`},":"),s("div",{key:"ea499addc6e546945a9b9c835793c3f7485f1410",class:`${this.elementClassName}__field`},s("label",{key:"b63a52658e5ddd90615668be5dc2e457e8217cd9",htmlFor:`${this.elementClassName}-seconds`,class:{[`${this.elementClassName}__label`]:!0,[`${this.elementClassName}__label--sr-only`]:this.labelsSrOnly}},this.labels.seconds),s("div",{key:"b812f8b2f952f7da2bfd20b4e8daf0f346dfd10e",class:`${this.elementClassName}__control`},s("button",{key:"a62b3ef2176f5ffd75ee32335c86e65d549f2ba4",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--increment`,onClick:this.handleSecondIncrement,disabled:this.disabled,"aria-label":this.labels.incrementSeconds},s("svg",{key:"d12fd6645379007b36692b1a2de07d8dd33687a4",fill:"none",height:"16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",stroke:"currentColor",viewBox:"0 0 24 24",width:"16"},s("polyline",{key:"ef1d5818d98c0c35d7b6317f6ee952d13b0c1d33",points:"18 15 12 9 6 15"}))),s("input",{key:"68b25324d43824686b933ad9f83d58eb4d71bb0d",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}),s("button",{key:"fa0fa372e836f05964a5ccb60ed1e8a235e24d8b",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--decrement`,onClick:this.handleSecondDecrement,disabled:this.disabled,"aria-label":this.labels.decrementSeconds},s("svg",{key:"2af2b80fe0853cc908e4eeccbfa4b99c758df941",fill:"none",height:"16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",stroke:"currentColor",viewBox:"0 0 24 24",width:"16"},s("polyline",{key:"b4c2c5729a9c0fd129371a17e23026f975dd296a",points:"6 9 12 15 18 9"})))))],this.useTwelveHourFormat&&s("div",{key:"6ad19983d00af5cca81dc8753791116e07f98cd1",class:`${this.elementClassName}__period`},s("button",{key:"05817e47857832d21380a425ccf149f9d10a328a",type:"button",class:{[`${this.elementClassName}__period-button`]:!0,[`${this.elementClassName}__period-button--active`]:"AM"===this.period},onClick:()=>this.handlePeriodChange("AM"),disabled:this.disabled,"aria-label":this.labels.am,"aria-pressed":"AM"===this.period},this.labels.am),s("button",{key:"7cff09015ab14acb9d40bd8a5d2f249f84d763b8",type:"button",class:{[`${this.elementClassName}__period-button`]:!0,[`${this.elementClassName}__period-button--active`]:"PM"===this.period},onClick:()=>this.handlePeriodChange("PM"),disabled:this.disabled,"aria-label":this.labels.pm,"aria-pressed":"PM"===this.period},this.labels.pm))))}get el(){return h(this)}static get watchers(){return{hours:[{watchHours:0}],minutes:[{watchMinutes:0}],seconds:[{watchSeconds:0}]}}};export{n as tabworthy_times_picker}
|
|
1
|
+
import{r as t,c as e,h as s,H as i,g as h}from"./p-CwtZ_Lud.js";const a={hours:"Hours",minutes:"Minutes",seconds:"Seconds",am:"AM",pm:"PM",timePicker:"Time picker",incrementHours:"Increment hours",decrementHours:"Decrement hours",incrementMinutes:"Increment minutes",decrementMinutes:"Decrement minutes",incrementSeconds:"Increment seconds",decrementSeconds:"Decrement seconds"},n=class{constructor(s){t(this,s),this.timeChanged=e(this,"timeChanged",7),this.hours=12,this.minutes=0,this.seconds=0,this.useTwelveHourFormat=!1,this.showSeconds=!1,this.labels=a,this.labelsSrOnly=!0,this.disabled=!1,this.elementClassName="tabworthy-times-picker",this.internalHours=this.hours,this.internalMinutes=this.minutes,this.internalSeconds=this.seconds,this.period=this.hours>=12?"PM":"AM",this.handleHourChange=t=>{const e=parseInt(t.target.value,10);this.internalHours=this.useTwelveHourFormat?"AM"===this.period?12===e?0:e:12===e?12:e+12:e,this.emitTimeChange()},this.handleMinuteChange=t=>{this.internalMinutes=parseInt(t.target.value,10),this.emitTimeChange()},this.handlePeriodChange=t=>{if(this.period===t||!this.useTwelveHourFormat)return;this.period=t;const e=this.getDisplayHours();this.internalHours="AM"===t?12===e?0:e:12===e?12:e+12,this.emitTimeChange()},this.handleHourIncrement=()=>{if(this.useTwelveHourFormat){const t=this.getDisplayHours(),e=12===t?1:t+1;this.internalHours="AM"===this.period?12===e?0:e:12===e?12:e+12}else this.internalHours=(this.internalHours+1)%24;this.emitTimeChange()},this.handleHourDecrement=()=>{if(this.useTwelveHourFormat){const t=this.getDisplayHours(),e=1===t?12:t-1;this.internalHours="AM"===this.period?12===e?0:e:12===e?12:e+12}else this.internalHours=0===this.internalHours?23:this.internalHours-1;this.emitTimeChange()},this.handleMinuteIncrement=()=>{this.internalMinutes=(this.internalMinutes+1)%60,this.emitTimeChange()},this.handleMinuteDecrement=()=>{this.internalMinutes=0===this.internalMinutes?59:this.internalMinutes-1,this.emitTimeChange()},this.handleSecondChange=t=>{this.internalSeconds=parseInt(t.target.value,10),this.emitTimeChange()},this.handleSecondIncrement=()=>{this.internalSeconds=(this.internalSeconds+1)%60,this.emitTimeChange()},this.handleSecondDecrement=()=>{this.internalSeconds=0===this.internalSeconds?59:this.internalSeconds-1,this.emitTimeChange()}}watchHours(t){this.internalHours=t,this.period=t>=12?"PM":"AM"}watchMinutes(t){this.internalMinutes=t}watchSeconds(t){this.internalSeconds=t}componentWillLoad(){this.internalHours=this.hours,this.internalMinutes=this.minutes,this.internalSeconds=this.seconds,this.period=this.hours>=12?"PM":"AM"}getDisplayHours(){return this.useTwelveHourFormat?0===this.internalHours?12:this.internalHours>12?this.internalHours-12:this.internalHours:this.internalHours}get24HourValue(){if(!this.useTwelveHourFormat)return this.internalHours;const t=this.getDisplayHours();return"AM"===this.period?12===t?0:t:12===t?12:t+12}emitTimeChange(){this.timeChanged.emit({hours:this.get24HourValue(),minutes:this.internalMinutes,seconds:this.showSeconds?this.internalSeconds:void 0,period:this.useTwelveHourFormat?this.period:void 0})}padZero(t){return t.toString().padStart(2,"0")}render(){const t=this.getDisplayHours(),e=this.useTwelveHourFormat?12:23,h=this.useTwelveHourFormat?1:0;return s(i,{key:"878156f105b2fb61aae67f866c1c436f038d1671",class:this.elementClassName,"aria-label":this.labels.timePicker},s("div",{key:"7b6265d1de95da5423d0d7fcfc6da5e283b64650",class:`${this.elementClassName}__container`},s("div",{key:"6e64ffa764916fb2bad7b88c30eed4ce3de141ed",class:`${this.elementClassName}__field`},s("label",{key:"0b9f82f319299fc3f177ec131f3bcb2d911cae6c",htmlFor:`${this.elementClassName}-hours`,class:{[`${this.elementClassName}__label`]:!0,[`${this.elementClassName}__label--sr-only`]:this.labelsSrOnly}},this.labels.hours),s("div",{key:"0b7c4a24255319fe373aacf275583a6ccf1415ea",class:`${this.elementClassName}__control`},s("button",{key:"24aff5877ad7cb189a6a9118f45e912ee2f97bec",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--increment`,onClick:this.handleHourIncrement,disabled:this.disabled,"aria-label":this.labels.incrementHours},s("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"},s("polyline",{key:"0f86f34c93f99536623d793429bae7109aa29996",points:"18 15 12 9 6 15"}))),s("input",{key:"26043b87943641bdab9322413a36e0019980ef87",id:`${this.elementClassName}-hours`,type:"number",class:`${this.elementClassName}__input`,value:this.padZero(t),min:h,max:e,onInput:this.handleHourChange,disabled:this.disabled,"aria-label":this.labels.hours}),s("button",{key:"d9617f2300e5457bd6480136d33905b35a2c2aba",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--decrement`,onClick:this.handleHourDecrement,disabled:this.disabled,"aria-label":this.labels.decrementHours},s("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"},s("polyline",{key:"0c54d3e34df989d2514dc95c3e660d94bda4819d",points:"6 9 12 15 18 9"}))))),s("div",{key:"0435c24eb991f0746f1388d440e175d20ba4230a",class:`${this.elementClassName}__separator`},":"),s("div",{key:"1dfb26b32d394101e9a85845d7cb2588c7c2fc63",class:`${this.elementClassName}__field`},s("label",{key:"06e3318c7cd7cd56bc9b1f2616520af38e22501e",htmlFor:`${this.elementClassName}-minutes`,class:{[`${this.elementClassName}__label`]:!0,[`${this.elementClassName}__label--sr-only`]:this.labelsSrOnly}},this.labels.minutes),s("div",{key:"933a0911a02b79fbcd573e0f0ed942fe1f23b7e8",class:`${this.elementClassName}__control`},s("button",{key:"e3a124aab9297ae89ed8deafdc1f2e4066ede58b",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--increment`,onClick:this.handleMinuteIncrement,disabled:this.disabled,"aria-label":this.labels.incrementMinutes},s("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"},s("polyline",{key:"d4fe518f8a5872da32e7093c0e5e6e7f168f7bfe",points:"18 15 12 9 6 15"}))),s("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}),s("button",{key:"c93e42de64a96a379405942fd7bcd2e4c9430c77",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--decrement`,onClick:this.handleMinuteDecrement,disabled:this.disabled,"aria-label":this.labels.decrementMinutes},s("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"},s("polyline",{key:"beb0425b60d2277477c6ffb5b72ce89ccd7bed20",points:"6 9 12 15 18 9"}))))),this.showSeconds&&[s("div",{key:"b686b7c464e70764bb8dcbec246c72bee6fa51b6",class:`${this.elementClassName}__separator`},":"),s("div",{key:"9dadc9f5a410e40775bd5b28144ee62971448680",class:`${this.elementClassName}__field`},s("label",{key:"233e50d7ddf4ea413ee652d20b917081485dbf93",htmlFor:`${this.elementClassName}-seconds`,class:{[`${this.elementClassName}__label`]:!0,[`${this.elementClassName}__label--sr-only`]:this.labelsSrOnly}},this.labels.seconds),s("div",{key:"df35e6750eeef49671e6a5f233e00a253459554d",class:`${this.elementClassName}__control`},s("button",{key:"521ba9fa8eb10dbf5981c4bab9687479f7888ac9",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--increment`,onClick:this.handleSecondIncrement,disabled:this.disabled,"aria-label":this.labels.incrementSeconds},s("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"},s("polyline",{key:"2af46da2a6c4c994ae67c44edb0b4180a6125336",points:"18 15 12 9 6 15"}))),s("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}),s("button",{key:"fe1288605003497b92e739f4cec01f160e5a161a",type:"button",class:`${this.elementClassName}__button ${this.elementClassName}__button--decrement`,onClick:this.handleSecondDecrement,disabled:this.disabled,"aria-label":this.labels.decrementSeconds},s("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"},s("polyline",{key:"3b68faee709705c929791e9cc7f9e24738f035a1",points:"6 9 12 15 18 9"})))))],this.useTwelveHourFormat&&s("div",{key:"13f65cc5b94a8c498fd233bc72cbd3c9977c7541",class:`${this.elementClassName}__period`},s("button",{key:"3d854b9b5aee10039b38af52513f12cf68e4c657",type:"button",class:{[`${this.elementClassName}__period-button`]:!0,[`${this.elementClassName}__period-button--active`]:"AM"===this.period},onClick:()=>this.handlePeriodChange("AM"),disabled:this.disabled,"aria-label":this.labels.am,"aria-pressed":"AM"===this.period},this.labels.am),s("button",{key:"de12f50f898625cbd5b6afb65e2f396441ab5cf0",type:"button",class:{[`${this.elementClassName}__period-button`]:!0,[`${this.elementClassName}__period-button--active`]:"PM"===this.period},onClick:()=>this.handlePeriodChange("PM"),disabled:this.disabled,"aria-label":this.labels.pm,"aria-pressed":"PM"===this.period},this.labels.pm))))}get el(){return h(this)}static get watchers(){return{hours:[{watchHours:0}],minutes:[{watchMinutes:0}],seconds:[{watchSeconds:0}]}}};export{n as tabworthy_times_picker}
|