@tabworthy/components 0.7.0 → 0.7.2
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/README.md +17 -15
- package/dist/cjs/tabworthy-dates-calendar_2.cjs.entry.js +1 -1
- package/dist/cjs/tabworthy-dates.cjs.entry.js +11 -8
- package/dist/cjs/tabworthy-times.cjs.entry.js +3 -3
- package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +11 -8
- package/dist/collection/components/tabworthy-modal/tabworthy-dates-modal.js +1 -1
- package/dist/collection/components/tabworthy-times/tabworthy-times.js +3 -3
- package/dist/components/tabworthy-dates-modal2.js +1 -1
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/tabworthy-dates-calendar_2.entry.js +1 -1
- package/dist/esm/tabworthy-dates.entry.js +11 -8
- package/dist/esm/tabworthy-times.entry.js +3 -3
- package/dist/tabworthy-components/{p-e030bef8.entry.js → p-8f394704.entry.js} +1 -1
- package/dist/tabworthy-components/p-9e745371.entry.js +1 -0
- package/dist/tabworthy-components/{p-c49e980d.entry.js → p-fa681444.entry.js} +1 -1
- package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
- package/dist/themes/dark.css +1 -1
- package/dist/themes/light.css +1 -1
- package/package.json +2 -5
- package/dist/tabworthy-components/p-a261cea6.entry.js +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>
|
|
2
|
+
<h1>TabworthyDates and TabworthyTimes components</h1>
|
|
3
3
|
|
|
4
4
|
<p>
|
|
5
5
|
<video controls autoplay>
|
|
@@ -8,20 +8,30 @@
|
|
|
8
8
|
</video>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
<p><strong>A human-friendly and fully accessible datepicker and datetimepicker with partial
|
|
11
|
+
<p><strong>A human-friendly and fully accessible datepicker and datetimepicker with partial support for natural language input. </strong></p>
|
|
12
|
+
|
|
13
|
+
<p>Now as a standard Web Component written in Typescript with 100% test coverage!</p>
|
|
12
14
|
<p>Try typing "tomorrow" or "in 10 days"!</p>
|
|
13
15
|
<p>Datepicker is forked from the excellent <a href="https://github.com/fymmot/inclusive-dates"><code>fymmot/inclusive-dates</code></a></p>
|
|
14
16
|
|
|
15
17
|
<div>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<img alt="Github docs action status" src="https://github.com/tabworthy/tabworthy-components/actions/workflows/docs.yml/badge.svg" />
|
|
20
|
-
-->
|
|
18
|
+
<img alt="Github test action status" src="https://github.com/tabworthy/tabworthy-components/actions/workflows/test.yml/badge.svg" />
|
|
19
|
+
<img alt="Github docs action status" src="https://github.com/tabworthy/tabworthy-components/actions/workflows/docs.yml/badge.svg" />
|
|
20
|
+
<img alt="Codecov coverage" src="https://codecov.io/gh/tabworthy/tabworthy-components/branch/main/graph/badge.svg" />
|
|
21
21
|
<img alt="NPM version" src="https://img.shields.io/npm/v/@tabworthy/components?color=informational">
|
|
22
22
|
</div>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
+
### Documentation & [Demo](https://tabworthy.github.io/tabworthy-components)
|
|
26
|
+
|
|
27
|
+
All components are documented in Storybook, which also serves as a demo. You can find it here:
|
|
28
|
+
**https://tabworthy.github.io/tabworthy-components/**
|
|
29
|
+
|
|
30
|
+
If you just interested in API documentation for components without the demo, you can find it here:
|
|
31
|
+
|
|
32
|
+
* [TabworthyDates](https://github.com/tabworthy/tabworthy-components/tree/main/src/components/tabworthy-dates)
|
|
33
|
+
* [TabworthyTimes](https://github.com/tabworthy/tabworthy-components/tree/main/src/components/tabworthy-times)
|
|
34
|
+
|
|
25
35
|
### Features
|
|
26
36
|
|
|
27
37
|
#### Natural language input
|
|
@@ -59,11 +69,3 @@ Semantic markup with no built-in styles.
|
|
|
59
69
|
#### 100% Test Coverage
|
|
60
70
|
|
|
61
71
|
Quality assured by means of unit tests.
|
|
62
|
-
|
|
63
|
-
### Documentation & Demo
|
|
64
|
-
|
|
65
|
-
<!--
|
|
66
|
-
TODO: publish storybook and link here
|
|
67
|
-
-->
|
|
68
|
-
|
|
69
|
-
**https://github.io/tabworthy-components/**
|
|
@@ -886,7 +886,7 @@ const InclusiveDatesModal = class {
|
|
|
886
886
|
}
|
|
887
887
|
}
|
|
888
888
|
render() {
|
|
889
|
-
return (index.h(index.Host, { key: '
|
|
889
|
+
return (index.h(index.Host, { key: 'e5e440df97f5b2f51f742892ca591aff3a3e51a9', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (index.h("div", { key: 'f3b5f92b0f3b8eb54f665a14fcaa1616d59b182b', part: "body", onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, index.h("focus-trap", { key: 'f94c02a8db391d671adc08ac1742dc6fabca72d3' }, index.h("div", { key: '888259505b6a2416674523d6a6924272b676daad', part: "content" }, index.h("slot", { key: 'e4e141ecae238f68fdde53baca66f478ebb93f88' }))))), this.inline && (index.h("div", { key: 'f2e7fb2614274d5dc7d03f10a0ee760363438435', part: "content" }, index.h("slot", { key: 'f845ef9c46b146ac916c90bb2fcec1f357aee5ee' })))));
|
|
890
890
|
}
|
|
891
891
|
};
|
|
892
892
|
InclusiveDatesModal.style = tabworthyDatesModalCss();
|
|
@@ -10826,12 +10826,15 @@ const TabworthyDates = class {
|
|
|
10826
10826
|
this.selectDate.emit(this.internalValue);
|
|
10827
10827
|
}
|
|
10828
10828
|
announceDateChange(newValue) {
|
|
10829
|
+
const newValueInIsoFormat = Array.isArray(newValue)
|
|
10830
|
+
? newValue.map((date) => moment.hooks(date, this.format).toISOString())
|
|
10831
|
+
: moment.hooks(newValue, this.format).toISOString();
|
|
10829
10832
|
let content = "";
|
|
10830
|
-
if (Array.isArray(
|
|
10831
|
-
if (
|
|
10833
|
+
if (Array.isArray(newValueInIsoFormat)) {
|
|
10834
|
+
if (newValueInIsoFormat.length === 1) {
|
|
10832
10835
|
content += `${this.datesLabels.startDate} `;
|
|
10833
10836
|
}
|
|
10834
|
-
|
|
10837
|
+
newValueInIsoFormat.forEach((value, index) => (content += `${index === 1 ? ` ${this.datesLabels.to} ` : ""}${Intl.DateTimeFormat(this.locale, {
|
|
10835
10838
|
weekday: "long",
|
|
10836
10839
|
day: "numeric",
|
|
10837
10840
|
month: "long",
|
|
@@ -10844,7 +10847,7 @@ const TabworthyDates = class {
|
|
|
10844
10847
|
day: "numeric",
|
|
10845
10848
|
month: "long",
|
|
10846
10849
|
year: "numeric"
|
|
10847
|
-
}).format(utils.removeTimezoneOffset(new Date(
|
|
10850
|
+
}).format(utils.removeTimezoneOffset(new Date(newValueInIsoFormat)));
|
|
10848
10851
|
if (content.length === 0)
|
|
10849
10852
|
return;
|
|
10850
10853
|
content += ` ${this.datesLabels.selected}`;
|
|
@@ -10892,7 +10895,7 @@ const TabworthyDates = class {
|
|
|
10892
10895
|
}
|
|
10893
10896
|
render() {
|
|
10894
10897
|
var _a;
|
|
10895
|
-
return (index$1.h(index$1.Host, { key: '
|
|
10898
|
+
return (index$1.h(index$1.Host, { key: '6fd878d7a0073344895525a82533925fcd24c372' }, index$1.h("label", { key: '550382a2ea99201b465fa9fd9ee90a917c5ff7e6', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), index$1.h("br", { key: 'fd6fb69543f81bef9a15157b94a25a5fa107ef70' }), index$1.h("div", { key: 'fcc9c10276e35f28435829eea17dfed27373f55c', class: this.getClassName("input-container") }, index$1.h("input", { key: '24da8c1582dc66f65a0eb6c6ab380b28bbf1c5ca', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: this.getClassName("input"), ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (index$1.h("button", { key: '54cd337b5ddd3ea6aa6ecd59a8fadf2cb5b61026', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index$1.h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), index$1.h("tabworthy-dates-modal", { key: 'cd8bd92d251d3c2566c9da9f8039ccc2ab74750f', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
10896
10899
|
if (!this.pickerRef)
|
|
10897
10900
|
return;
|
|
10898
10901
|
this.pickerRef.modalIsOpen = true;
|
|
@@ -10900,11 +10903,11 @@ const TabworthyDates = class {
|
|
|
10900
10903
|
if (!this.pickerRef)
|
|
10901
10904
|
return;
|
|
10902
10905
|
this.pickerRef.modalIsOpen = false;
|
|
10903
|
-
}, inline: this.inline }, index$1.h("tabworthy-dates-calendar", { key: '
|
|
10906
|
+
}, inline: this.inline }, index$1.h("tabworthy-dates-calendar", { key: '929272a053e0109e34d4b2d8456064fc14093912', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), labels: this.datesCalendarLabels ? this.datesCalendarLabels : undefined, 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, showKeyboardHint: this.showKeyboardHint, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline })), this.showQuickButtons &&
|
|
10904
10907
|
((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
10905
|
-
this.chronoSupportedLocale && (index$1.h("div", { key: '
|
|
10908
|
+
this.chronoSupportedLocale && (index$1.h("div", { key: 'aead258880c9531e3fb72111f1fd47ebfa35931a', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
|
|
10906
10909
|
return (index$1.h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
|
|
10907
|
-
}))), this.errorState && (index$1.h("div", { key: '
|
|
10910
|
+
}))), this.errorState && (index$1.h("div", { key: '193fe31b36da600e9f222f2576c3bee2d4e0a427', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
10908
10911
|
}
|
|
10909
10912
|
get el() { return index$1.getElement(this); }
|
|
10910
10913
|
static get watchers() { return {
|
|
@@ -6,7 +6,7 @@ var utils = require('./utils-y5Vtky2t.js');
|
|
|
6
6
|
|
|
7
7
|
const defaultLabels = {
|
|
8
8
|
selected: "selected",
|
|
9
|
-
openCalendar: "
|
|
9
|
+
openCalendar: "Choose time",
|
|
10
10
|
calendar: "date and time picker",
|
|
11
11
|
invalidDateError: "We could not find a matching date",
|
|
12
12
|
minDateError: `Please fill in a date after `,
|
|
@@ -228,7 +228,7 @@ const InclusiveTimes = class {
|
|
|
228
228
|
}
|
|
229
229
|
render() {
|
|
230
230
|
var _a;
|
|
231
|
-
return (index.h(index.Host, { key: '
|
|
231
|
+
return (index.h(index.Host, { key: 'e049ca8df298088e704f6baf200bab775a486c22', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, index.h("label", { key: '241ac63dc3d804457e3e5e14c3d7818b9592c581', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: 'f18e007c9ec383f75ea34d29c9ee03216ee86bf4', class: this.getClassName("input-container") }, index.h("input", { key: '99da2013aa8b86f717e8a6e9f94f86cf15062721', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: this.getClassName("input"), 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 && (index.h("button", { key: 'c122ddd762f648f63c7b3d942b7bde858bbfdca9', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: 'b5aacee01555fb5b2503421555b280a71ddabba5', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
232
232
|
if (this.pickerRef) {
|
|
233
233
|
this.pickerRef.modalIsOpen = true;
|
|
234
234
|
}
|
|
@@ -236,7 +236,7 @@ const InclusiveTimes = class {
|
|
|
236
236
|
if (this.pickerRef) {
|
|
237
237
|
this.pickerRef.modalIsOpen = false;
|
|
238
238
|
}
|
|
239
|
-
}, inline: this.inline }, index.h("div", { key: '
|
|
239
|
+
}, inline: this.inline }, index.h("div", { key: '4d9b8dc721d56ea3e9123151058a149c5dfbb109', class: this.getClassName("picker-container") }, index.h("tabworthy-dates-calendar", { key: '5f6f874feb06b72e0d0774bfe26ba3005c285033', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), 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, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline }, index.h("div", { key: '7cd02c57b4af45caaaa6da7899697d4ea6f35e60', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: '56f2cb3676b2001252ec4960f6ec4931fa451d29', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: '300a3c17e2fd25aa37ca75cb287e28dfb41f3ccd', hours: this.selectedHours, minutes: this.selectedMinutes, use12HourFormat: this.use12HourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange }))))), this.errorState && (index.h("div", { key: '96803190678fb12f4ed5f4ad5a28a29ab98c0c66', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
240
240
|
}
|
|
241
241
|
get el() { return index.getElement(this); }
|
|
242
242
|
static get watchers() { return {
|
|
@@ -353,12 +353,15 @@ export class TabworthyDates {
|
|
|
353
353
|
this.selectDate.emit(this.internalValue);
|
|
354
354
|
}
|
|
355
355
|
announceDateChange(newValue) {
|
|
356
|
+
const newValueInIsoFormat = Array.isArray(newValue)
|
|
357
|
+
? newValue.map((date) => moment(date, this.format).toISOString())
|
|
358
|
+
: moment(newValue, this.format).toISOString();
|
|
356
359
|
let content = "";
|
|
357
|
-
if (Array.isArray(
|
|
358
|
-
if (
|
|
360
|
+
if (Array.isArray(newValueInIsoFormat)) {
|
|
361
|
+
if (newValueInIsoFormat.length === 1) {
|
|
359
362
|
content += `${this.datesLabels.startDate} `;
|
|
360
363
|
}
|
|
361
|
-
|
|
364
|
+
newValueInIsoFormat.forEach((value, index) => (content += `${index === 1 ? ` ${this.datesLabels.to} ` : ""}${Intl.DateTimeFormat(this.locale, {
|
|
362
365
|
weekday: "long",
|
|
363
366
|
day: "numeric",
|
|
364
367
|
month: "long",
|
|
@@ -371,7 +374,7 @@ export class TabworthyDates {
|
|
|
371
374
|
day: "numeric",
|
|
372
375
|
month: "long",
|
|
373
376
|
year: "numeric"
|
|
374
|
-
}).format(removeTimezoneOffset(new Date(
|
|
377
|
+
}).format(removeTimezoneOffset(new Date(newValueInIsoFormat)));
|
|
375
378
|
if (content.length === 0)
|
|
376
379
|
return;
|
|
377
380
|
content += ` ${this.datesLabels.selected}`;
|
|
@@ -419,7 +422,7 @@ export class TabworthyDates {
|
|
|
419
422
|
}
|
|
420
423
|
render() {
|
|
421
424
|
var _a;
|
|
422
|
-
return (h(Host, { key: '
|
|
425
|
+
return (h(Host, { key: '6fd878d7a0073344895525a82533925fcd24c372' }, h("label", { key: '550382a2ea99201b465fa9fd9ee90a917c5ff7e6', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", { key: 'fd6fb69543f81bef9a15157b94a25a5fa107ef70' }), h("div", { key: 'fcc9c10276e35f28435829eea17dfed27373f55c', class: this.getClassName("input-container") }, h("input", { key: '24da8c1582dc66f65a0eb6c6ab380b28bbf1c5ca', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: this.getClassName("input"), ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: '54cd337b5ddd3ea6aa6ecd59a8fadf2cb5b61026', type: "button", ref: (r) => (this.calendarButtonRef = r), onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: 'cd8bd92d251d3c2566c9da9f8039ccc2ab74750f', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
423
426
|
if (!this.pickerRef)
|
|
424
427
|
return;
|
|
425
428
|
this.pickerRef.modalIsOpen = true;
|
|
@@ -427,11 +430,11 @@ export class TabworthyDates {
|
|
|
427
430
|
if (!this.pickerRef)
|
|
428
431
|
return;
|
|
429
432
|
this.pickerRef.modalIsOpen = false;
|
|
430
|
-
}, inline: this.inline }, h("tabworthy-dates-calendar", { key: '
|
|
433
|
+
}, inline: this.inline }, h("tabworthy-dates-calendar", { key: '929272a053e0109e34d4b2d8456064fc14093912', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), labels: this.datesCalendarLabels ? this.datesCalendarLabels : undefined, 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, showKeyboardHint: this.showKeyboardHint, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline })), this.showQuickButtons &&
|
|
431
434
|
((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
432
|
-
this.chronoSupportedLocale && (h("div", { key: '
|
|
435
|
+
this.chronoSupportedLocale && (h("div", { key: 'aead258880c9531e3fb72111f1fd47ebfa35931a', class: this.getClassName("quick-group"), role: "group", "aria-label": "Quick selection" }, this.quickButtons.map((buttonText) => {
|
|
433
436
|
return (h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
|
|
434
|
-
}))), this.errorState && (h("div", { key: '
|
|
437
|
+
}))), this.errorState && (h("div", { key: '193fe31b36da600e9f222f2576c3bee2d4e0a427', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
435
438
|
}
|
|
436
439
|
static get is() { return "tabworthy-dates"; }
|
|
437
440
|
static get encapsulation() { return "scoped"; }
|
|
@@ -49,7 +49,7 @@ export class InclusiveDatesModal {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
render() {
|
|
52
|
-
return (h(Host, { key: '
|
|
52
|
+
return (h(Host, { key: 'e5e440df97f5b2f51f742892ca591aff3a3e51a9', showing: this.showing, ref: (r) => r && (this.el = r) }, !this.inline && this.showing && (h("div", { key: 'f3b5f92b0f3b8eb54f665a14fcaa1616d59b182b', part: "body", onKeyDown: this.onKeyDown, role: "dialog", tabindex: -1, "aria-hidden": !this.showing, "aria-label": this.label, "aria-modal": this.showing }, h("focus-trap", { key: 'f94c02a8db391d671adc08ac1742dc6fabca72d3' }, h("div", { key: '888259505b6a2416674523d6a6924272b676daad', part: "content" }, h("slot", { key: 'e4e141ecae238f68fdde53baca66f478ebb93f88' }))))), this.inline && (h("div", { key: 'f2e7fb2614274d5dc7d03f10a0ee760363438435', part: "content" }, h("slot", { key: 'f845ef9c46b146ac916c90bb2fcec1f357aee5ee' })))));
|
|
53
53
|
}
|
|
54
54
|
static get is() { return "tabworthy-dates-modal"; }
|
|
55
55
|
static get encapsulation() { return "shadow"; }
|
|
@@ -3,7 +3,7 @@ import moment from "moment";
|
|
|
3
3
|
import { getISODateString, removeTimezoneOffset } from "../../../../shared/utils/utils";
|
|
4
4
|
const defaultLabels = {
|
|
5
5
|
selected: "selected",
|
|
6
|
-
openCalendar: "
|
|
6
|
+
openCalendar: "Choose time",
|
|
7
7
|
calendar: "date and time picker",
|
|
8
8
|
invalidDateError: "We could not find a matching date",
|
|
9
9
|
minDateError: `Please fill in a date after `,
|
|
@@ -221,7 +221,7 @@ export class InclusiveTimes {
|
|
|
221
221
|
}
|
|
222
222
|
render() {
|
|
223
223
|
var _a;
|
|
224
|
-
return (h(Host, { key: '
|
|
224
|
+
return (h(Host, { key: 'e049ca8df298088e704f6baf200bab775a486c22', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, h("label", { key: '241ac63dc3d804457e3e5e14c3d7818b9592c581', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), h("div", { key: 'f18e007c9ec383f75ea34d29c9ee03216ee86bf4', class: this.getClassName("input-container") }, h("input", { key: '99da2013aa8b86f717e8a6e9f94f86cf15062721', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: this.getClassName("input"), 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: 'c122ddd762f648f63c7b3d942b7bde858bbfdca9', type: "button", ref: (r) => (this.calendarButtonRef = r), 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: 'b5aacee01555fb5b2503421555b280a71ddabba5', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
225
225
|
if (this.pickerRef) {
|
|
226
226
|
this.pickerRef.modalIsOpen = true;
|
|
227
227
|
}
|
|
@@ -229,7 +229,7 @@ export class InclusiveTimes {
|
|
|
229
229
|
if (this.pickerRef) {
|
|
230
230
|
this.pickerRef.modalIsOpen = false;
|
|
231
231
|
}
|
|
232
|
-
}, inline: this.inline }, h("div", { key: '
|
|
232
|
+
}, inline: this.inline }, h("div", { key: '4d9b8dc721d56ea3e9123151058a149c5dfbb109', class: this.getClassName("picker-container") }, h("tabworthy-dates-calendar", { key: '5f6f874feb06b72e0d0774bfe26ba3005c285033', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), 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, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline }, h("div", { key: '7cd02c57b4af45caaaa6da7899697d4ea6f35e60', slot: "after-calendar", class: this.getClassName("time-section") }, h("hr", { key: '56f2cb3676b2001252ec4960f6ec4931fa451d29', class: this.getClassName("divider") }), h("tabworthy-times-picker", { key: '300a3c17e2fd25aa37ca75cb287e28dfb41f3ccd', hours: this.selectedHours, minutes: this.selectedMinutes, use12HourFormat: this.use12HourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange }))))), this.errorState && (h("div", { key: '96803190678fb12f4ed5f4ad5a28a29ab98c0c66', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
233
233
|
}
|
|
234
234
|
static get is() { return "tabworthy-times"; }
|
|
235
235
|
static get encapsulation() { return "scoped"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as n,Host as s,transformTag as a}from"@stencil/core/internal/client";function o(t,e,i,n=20,s=0){let a=[];if(s>=n)return a;const r=t=>{const a=t.assignedNodes().filter((t=>1===t.nodeType));return a.length>0?o(a[0].parentElement,e,i,n,s+1):[]},h=Array.from(t.children||[]);for(const t of h)e(t)||(i(t)&&a.push(t),null!=t.shadowRoot?a.push(...o(t.shadowRoot,e,i,n,s+1)):"SLOT"===t.tagName?a.push(...r(t)):a.push(...o(t,e,i,n,s+1)));return a}function r(t){return t.hasAttribute("hidden")||t.hasAttribute("aria-hidden")&&"false"!==t.getAttribute("aria-hidden")||"none"===t.style.display||"0"===t.style.opacity||"hidden"===t.style.visibility||"collapse"===t.style.visibility}function h(t){return"-1"!==t.getAttribute("tabindex")&&!r(t)&&!function(t){return t.hasAttribute("disabled")||t.hasAttribute("aria-disabled")&&"false"!==t.getAttribute("aria-disabled")}(t)&&(t.hasAttribute("tabindex")||(t instanceof HTMLAnchorElement||t instanceof HTMLAreaElement)&&t.hasAttribute("href")||t instanceof HTMLButtonElement||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLIFrameElement)}const c=new Map,d=document.createElement("template");d.innerHTML='\n\t<div id="start"></div>\n\t<div id="backup"></div>\n\t<slot></slot>\n\t<div id="end"></div>\n';class u extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const t=this.attachShadow({mode:"open"});t.appendChild(d.content.cloneNode(!0)),this.$backup=t.querySelector("#backup"),this.$start=t.querySelector("#start"),this.$end=t.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(t){t?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return o(this,r,h)}trapFocus(t){if(this.inactive)return;let e=this.getFocusableElements();e.length>0?(t?e[e.length-1].focus():e[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(t){!function(t,e,i){const n=c.get(i);null!=n&&window.clearTimeout(n),c.set(i,window.setTimeout((()=>{t(),c.delete(i)}),0))}((()=>{this.focused!==t&&(this._focused=t,this.render())}),0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",u);var
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as n,Host as s,transformTag as a}from"@stencil/core/internal/client";function o(t,e,i,n=20,s=0){let a=[];if(s>=n)return a;const r=t=>{const a=t.assignedNodes().filter((t=>1===t.nodeType));return a.length>0?o(a[0].parentElement,e,i,n,s+1):[]},h=Array.from(t.children||[]);for(const t of h)e(t)||(i(t)&&a.push(t),null!=t.shadowRoot?a.push(...o(t.shadowRoot,e,i,n,s+1)):"SLOT"===t.tagName?a.push(...r(t)):a.push(...o(t,e,i,n,s+1)));return a}function r(t){return t.hasAttribute("hidden")||t.hasAttribute("aria-hidden")&&"false"!==t.getAttribute("aria-hidden")||"none"===t.style.display||"0"===t.style.opacity||"hidden"===t.style.visibility||"collapse"===t.style.visibility}function h(t){return"-1"!==t.getAttribute("tabindex")&&!r(t)&&!function(t){return t.hasAttribute("disabled")||t.hasAttribute("aria-disabled")&&"false"!==t.getAttribute("aria-disabled")}(t)&&(t.hasAttribute("tabindex")||(t instanceof HTMLAnchorElement||t instanceof HTMLAreaElement)&&t.hasAttribute("href")||t instanceof HTMLButtonElement||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLIFrameElement)}const c=new Map,d=document.createElement("template");d.innerHTML='\n\t<div id="start"></div>\n\t<div id="backup"></div>\n\t<slot></slot>\n\t<div id="end"></div>\n';class u extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const t=this.attachShadow({mode:"open"});t.appendChild(d.content.cloneNode(!0)),this.$backup=t.querySelector("#backup"),this.$start=t.querySelector("#start"),this.$end=t.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(t){t?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return o(this,r,h)}trapFocus(t){if(this.inactive)return;let e=this.getFocusableElements();e.length>0?(t?e[e.length-1].focus():e[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(t){!function(t,e,i){const n=c.get(i);null!=n&&window.clearTimeout(n),c.set(i,window.setTimeout((()=>{t(),c.delete(i)}),0))}((()=>{this.focused!==t&&(this._focused=t,this.render())}),0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",u);var f=new WeakMap,l=new WeakMap,b={},p=0,m=function(t){return t&&(t.host||m(t.parentNode))},v=function(t,e,i){void 0===i&&(i="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),s=function(t){return"undefined"==typeof document?null:(Array.isArray(t)?t[0]:t).ownerDocument.body}(t);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live]"))),function(t,e,i,n){var s=function(t,e){return e.map((function(e){if(t.contains(e))return e;var i=m(e);return i&&t.contains(i)?i:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)})).filter((function(t){return Boolean(t)}))}(e,Array.isArray(t)?t:[t]);b[i]||(b[i]=new WeakMap);var a=b[i],o=[],r=new Set,h=new Set(s),c=function(t){t&&!r.has(t)&&(r.add(t),c(t.parentNode))};s.forEach(c);var d=function(t){t&&!h.has(t)&&Array.prototype.forEach.call(t.children,(function(t){if(r.has(t))d(t);else{var e=t.getAttribute(n),s=null!==e&&"false"!==e,h=(f.get(t)||0)+1,c=(a.get(t)||0)+1;f.set(t,h),a.set(t,c),o.push(t),1===h&&s&&l.set(t,!0),1===c&&t.setAttribute(i,"true"),s||t.setAttribute(n,"true")}}))};return d(e),r.clear(),p++,function(){o.forEach((function(t){var e=f.get(t)-1,s=a.get(t)-1;f.set(t,e),a.set(t,s),e||(l.has(t)||t.removeAttribute(n),l.delete(t)),s||t.removeAttribute(i)})),--p||(f=new WeakMap,f=new WeakMap,l=new WeakMap,b={})}}(n,s,i,"aria-hidden")):function(){return null}};const y=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.opened=i(this,"opened",7),this.closed=i(this,"closed",7),this.inline=!1,this.closing=!1,this.showing=this.inline||!1,this.onKeyDown=t=>{"Escape"===t.code&&this.close()}}async open(){this.inline||(this.showing=!0,this.undo=v(this.el),this.opened.emit(void 0))}async close(){this.inline||(this.showing=!1,this.closed.emit(void 0),this.undo(),this.triggerElement&&this.triggerElement.focus())}async getState(){return this.showing}async setTriggerElement(t){this.triggerElement=t}handleClick(t){this.showing&&!this.el.contains(t.target)&&this.close()}render(){return n(s,{key:"e5e440df97f5b2f51f742892ca591aff3a3e51a9",showing:this.showing,ref:t=>t&&(this.el=t)},!this.inline&&this.showing&&n("div",{key:"f3b5f92b0f3b8eb54f665a14fcaa1616d59b182b",part:"body",onKeyDown:this.onKeyDown,role:"dialog",tabindex:-1,"aria-hidden":!this.showing,"aria-label":this.label,"aria-modal":this.showing},n("focus-trap",{key:"f94c02a8db391d671adc08ac1742dc6fabca72d3"},n("div",{key:"888259505b6a2416674523d6a6924272b676daad",part:"content"},n("slot",{key:"e4e141ecae238f68fdde53baca66f478ebb93f88"})))),this.inline&&n("div",{key:"f2e7fb2614274d5dc7d03f10a0ee760363438435",part:"content"},n("slot",{key:"f845ef9c46b146ac916c90bb2fcec1f357aee5ee"})))}static get style(){return":host::part(body){position:absolute;width:-moz-fit-content;width:fit-content;z-index:1200;margin-top:0.5rem}:host::part(backdrop){}:host::part(content){}"}},[257,"tabworthy-dates-modal",{label:[1],inline:[4],closing:[32],showing:[32],open:[64],close:[64],getState:[64],setTriggerElement:[64]},[[10,"click","handleClick"]]]);function w(){"undefined"!=typeof customElements&&["tabworthy-dates-modal"].forEach((t=>{"tabworthy-dates-modal"===t&&(customElements.get(a(t))||customElements.define(a(t),y))}))}export{y as I,w as d}
|