@skf-design-system/ui-components 1.0.1-beta.0 → 1.0.2-beta.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/README.md +1 -18
- package/dist/components/accordion/accordion.component.d.ts +4 -4
- package/dist/components/accordion/accordion.component.js +8 -8
- package/dist/components/alert/alert.component.d.ts +8 -9
- package/dist/components/alert/alert.component.js +14 -14
- package/dist/components/breadcrumb/breadcrumb.component.d.ts +1 -1
- package/dist/components/button/button.component.d.ts +3 -3
- package/dist/components/button/button.component.js +59 -55
- package/dist/components/card/card.component.js +18 -30
- package/dist/components/card/card.styles.js +25 -28
- package/dist/components/checkbox/checkbox.component.d.ts +9 -7
- package/dist/components/checkbox/checkbox.component.js +71 -58
- package/dist/components/collapse/collapse.component.js +1 -1
- package/dist/components/date-picker/datepicker.calendar.component.d.ts +77 -0
- package/dist/components/date-picker/datepicker.calendar.component.js +415 -0
- package/dist/components/date-picker/datepicker.calendar.styles.d.ts +1 -0
- package/dist/components/date-picker/datepicker.calendar.styles.js +202 -0
- package/dist/components/date-picker/datepicker.component.d.ts +79 -0
- package/dist/components/date-picker/datepicker.component.js +261 -0
- package/dist/components/date-picker/datepicker.d.ts +10 -0
- package/dist/components/date-picker/datepicker.helpers.d.ts +41 -0
- package/dist/components/date-picker/datepicker.helpers.js +76 -0
- package/dist/components/date-picker/datepicker.js +8 -0
- package/dist/components/date-picker/datepicker.styles.d.ts +1 -0
- package/dist/components/date-picker/datepicker.styles.js +87 -0
- package/dist/components/date-picker-input/datepicker-input.component.d.ts +115 -0
- package/dist/components/date-picker-input/datepicker-input.component.js +441 -0
- package/dist/components/date-picker-input/datepicker-input.d.ts +8 -0
- package/dist/components/date-picker-input/datepicker-input.helpers.d.ts +38 -0
- package/dist/components/date-picker-input/datepicker-input.helpers.js +31 -0
- package/dist/components/date-picker-input/datepicker-input.js +6 -0
- package/dist/components/date-picker-input/datepicker-input.styles.d.ts +1 -0
- package/dist/components/date-picker-input/datepicker-input.styles.js +18 -0
- package/dist/components/dialog/dialog.component.d.ts +18 -28
- package/dist/components/dialog/dialog.component.js +94 -84
- package/dist/components/divider/divider.component.d.ts +4 -8
- package/dist/components/divider/divider.component.js +24 -46
- package/dist/components/divider/divider.styles.js +34 -30
- package/dist/components/drawer/drawer.component.d.ts +57 -0
- package/dist/components/drawer/drawer.component.js +124 -0
- package/dist/components/drawer/drawer.d.ts +8 -0
- package/dist/components/drawer/drawer.js +6 -0
- package/dist/components/drawer/drawer.styles.d.ts +1 -0
- package/dist/components/drawer/drawer.styles.js +71 -0
- package/dist/components/header/header.component.d.ts +45 -0
- package/dist/components/header/header.component.js +110 -0
- package/dist/components/header/header.d.ts +8 -0
- package/dist/components/header/header.js +6 -0
- package/dist/components/header/header.styles.d.ts +1 -0
- package/dist/components/header/header.styles.js +68 -0
- package/dist/components/heading/heading.component.d.ts +6 -12
- package/dist/components/heading/heading.component.js +17 -17
- package/dist/components/heading/heading.styles.d.ts +1 -2
- package/dist/components/heading/heading.styles.js +1 -1
- package/dist/components/icon/icon.component.d.ts +1 -1
- package/dist/components/icon/icon.component.js +19 -19
- package/dist/components/input/input.component.d.ts +3 -2
- package/dist/components/input/input.component.js +89 -82
- package/dist/components/input/input.controllers.d.ts +20 -6
- package/dist/components/input/input.controllers.js +14 -10
- package/dist/components/link/link.component.js +29 -28
- package/dist/components/link/link.styles.js +24 -20
- package/dist/components/loader/loader.component.js +19 -19
- package/dist/components/logo/logo.component.js +6 -6
- package/dist/components/menu/menu.component.d.ts +4 -5
- package/dist/components/menu/menu.component.js +1 -1
- package/dist/components/nav/nav.component.d.ts +17 -0
- package/dist/components/nav/nav.component.js +34 -0
- package/dist/components/nav/nav.d.ts +8 -0
- package/dist/components/nav/nav.js +6 -0
- package/dist/components/nav/nav.styles.d.ts +1 -0
- package/dist/components/nav/nav.styles.js +17 -0
- package/dist/components/nav-item/nav-item.component.d.ts +20 -0
- package/dist/components/nav-item/nav-item.component.js +38 -0
- package/dist/components/nav-item/nav-item.d.ts +8 -0
- package/dist/components/nav-item/nav-item.js +6 -0
- package/dist/components/nav-item/nav-item.styles.d.ts +1 -0
- package/dist/components/nav-item/nav-item.styles.js +39 -0
- package/dist/components/popover/popover.component.d.ts +5 -6
- package/dist/components/popover/popover.component.js +24 -24
- package/dist/components/progress/progress.component.js +7 -7
- package/dist/components/radio/radio.component.d.ts +10 -6
- package/dist/components/radio/radio.component.js +14 -14
- package/dist/components/radio/radio.styles.d.ts +1 -2
- package/dist/components/radio/radio.styles.js +1 -1
- package/dist/components/segmented-button/segmented-button.component.d.ts +32 -0
- package/dist/components/segmented-button/segmented-button.d.ts +8 -0
- package/dist/components/segmented-button/segmented-button.styles.d.ts +1 -0
- package/dist/components/segmented-button-item/segmented-button-item.component.d.ts +36 -0
- package/dist/components/segmented-button-item/segmented-button-item.d.ts +8 -0
- package/dist/components/segmented-button-item/segmented-button-item.styles.d.ts +1 -0
- package/dist/components/select/select.component.js +2 -2
- package/dist/components/select/select.controllers.d.ts +20 -9
- package/dist/components/select/select.controllers.js +27 -22
- package/dist/components/select-option/select-option.controllers.d.ts +11 -5
- package/dist/components/select-option-group/select-option-group.component.js +9 -9
- package/dist/components/stepper/stepper.component.d.ts +2 -1
- package/dist/components/stepper/stepper.component.js +9 -9
- package/dist/components/stepper/stepper.helpers.js +5 -5
- package/dist/components/stepper-item/stepper-item.component.js +25 -25
- package/dist/components/switch/switch.component.d.ts +7 -6
- package/dist/components/switch/switch.component.js +7 -7
- package/dist/components/tab/tab.component.js +4 -4
- package/dist/components/tab-panel/tab-panel.component.js +12 -12
- package/dist/components/tag/tag.component.d.ts +4 -2
- package/dist/components/tag/tag.component.js +14 -14
- package/dist/components/textarea/textarea.component.js +10 -10
- package/dist/components/toast/toast.component.d.ts +1 -1
- package/dist/components/toast/toast.component.js +13 -13
- package/dist/components/toast-wrapper/toast-wrapper.component.js +10 -10
- package/dist/components/tooltip/tooltip.component.d.ts +5 -6
- package/dist/components/tooltip/tooltip.component.js +11 -11
- package/dist/custom-elements.json +3702 -2190
- package/dist/index.d.ts +6 -0
- package/dist/index.js +84 -66
- package/dist/internal/base-classes/popover/popover.base.d.ts +17 -7
- package/dist/internal/base-classes/popover/popover.base.js +119 -75
- package/dist/internal/base-classes/popover/popover.styles.js +14 -1
- package/dist/internal/components/hint/hint.component.js +13 -13
- package/dist/internal/controllers/elementOverflowController.d.ts +13 -0
- package/dist/internal/controllers/popover.controller.d.ts +12 -6
- package/dist/internal/controllers/popover.controller.js +9 -14
- package/dist/internal/helpers/dateFormatter.d.ts +2 -0
- package/dist/internal/helpers/utilityTypes.d.ts +22 -0
- package/dist/internal/helpers/uuid.d.ts +15 -0
- package/dist/internal/helpers/uuid.js +14 -0
- package/dist/internal/storybook/styles.d.ts +1 -0
- package/dist/styles/form-field.styles.js +11 -6
- package/dist/styles/global.css +1 -1
- package/dist/types/jsx/custom-element-jsx.d.ts +663 -1240
- package/dist/types/vue/index.d.ts +453 -255
- package/dist/vscode.html-custom-data.json +821 -503
- package/dist/web-types.json +1005 -633
- package/package.json +43 -52
- package/dist/react/index.d.ts +0 -35
- package/dist/react/index.js +0 -35
- package/dist/react/skf-accordion/index.d.ts +0 -3
- package/dist/react/skf-accordion/index.js +0 -13
- package/dist/react/skf-alert/index.d.ts +0 -9
- package/dist/react/skf-alert/index.js +0 -17
- package/dist/react/skf-breadcrumb/index.d.ts +0 -9
- package/dist/react/skf-breadcrumb/index.js +0 -17
- package/dist/react/skf-breadcrumb-item/index.d.ts +0 -3
- package/dist/react/skf-breadcrumb-item/index.js +0 -13
- package/dist/react/skf-button/index.d.ts +0 -9
- package/dist/react/skf-button/index.js +0 -17
- package/dist/react/skf-card/index.d.ts +0 -3
- package/dist/react/skf-card/index.js +0 -13
- package/dist/react/skf-checkbox/index.d.ts +0 -9
- package/dist/react/skf-checkbox/index.js +0 -17
- package/dist/react/skf-collapse/index.d.ts +0 -9
- package/dist/react/skf-collapse/index.js +0 -17
- package/dist/react/skf-dialog/index.d.ts +0 -15
- package/dist/react/skf-dialog/index.js +0 -19
- package/dist/react/skf-divider/index.d.ts +0 -3
- package/dist/react/skf-divider/index.js +0 -13
- package/dist/react/skf-heading/index.d.ts +0 -3
- package/dist/react/skf-heading/index.js +0 -13
- package/dist/react/skf-icon/index.d.ts +0 -3
- package/dist/react/skf-icon/index.js +0 -13
- package/dist/react/skf-input/index.d.ts +0 -12
- package/dist/react/skf-input/index.js +0 -18
- package/dist/react/skf-link/index.d.ts +0 -3
- package/dist/react/skf-link/index.js +0 -13
- package/dist/react/skf-loader/index.d.ts +0 -3
- package/dist/react/skf-loader/index.js +0 -13
- package/dist/react/skf-logo/index.d.ts +0 -3
- package/dist/react/skf-logo/index.js +0 -13
- package/dist/react/skf-menu/index.d.ts +0 -12
- package/dist/react/skf-menu/index.js +0 -18
- package/dist/react/skf-menu-item/index.d.ts +0 -27
- package/dist/react/skf-menu-item/index.js +0 -23
- package/dist/react/skf-popover/index.d.ts +0 -12
- package/dist/react/skf-popover/index.js +0 -18
- package/dist/react/skf-progress/index.d.ts +0 -3
- package/dist/react/skf-progress/index.js +0 -13
- package/dist/react/skf-radio/index.d.ts +0 -9
- package/dist/react/skf-radio/index.js +0 -17
- package/dist/react/skf-select/index.d.ts +0 -21
- package/dist/react/skf-select/index.js +0 -21
- package/dist/react/skf-select-option/index.d.ts +0 -9
- package/dist/react/skf-select-option/index.js +0 -17
- package/dist/react/skf-select-option-group/index.d.ts +0 -3
- package/dist/react/skf-select-option-group/index.js +0 -13
- package/dist/react/skf-stepper/index.d.ts +0 -9
- package/dist/react/skf-stepper/index.js +0 -17
- package/dist/react/skf-stepper-item/index.d.ts +0 -9
- package/dist/react/skf-stepper-item/index.js +0 -17
- package/dist/react/skf-switch/index.d.ts +0 -3
- package/dist/react/skf-switch/index.js +0 -13
- package/dist/react/skf-tab/index.d.ts +0 -12
- package/dist/react/skf-tab/index.js +0 -18
- package/dist/react/skf-tab-group/index.d.ts +0 -3
- package/dist/react/skf-tab-group/index.js +0 -13
- package/dist/react/skf-tab-panel/index.d.ts +0 -3
- package/dist/react/skf-tab-panel/index.js +0 -13
- package/dist/react/skf-tag/index.d.ts +0 -3
- package/dist/react/skf-tag/index.js +0 -13
- package/dist/react/skf-textarea/index.d.ts +0 -12
- package/dist/react/skf-textarea/index.js +0 -18
- package/dist/react/skf-toast/index.d.ts +0 -3
- package/dist/react/skf-toast/index.js +0 -13
- package/dist/react/skf-toast-wrapper/index.d.ts +0 -3
- package/dist/react/skf-toast-wrapper/index.js +0 -13
- package/dist/react/skf-tooltip/index.d.ts +0 -12
- package/dist/react/skf-tooltip/index.js +0 -18
@@ -0,0 +1,441 @@
|
|
1
|
+
import { dateFormatter as v, is as f, isPopoverOpen as S, debounce as E } from "./datepicker-input.helpers.js";
|
2
|
+
import "../icon/icon.js";
|
3
|
+
import { computePosition as C, flip as I, offset as O } from "@floating-ui/dom";
|
4
|
+
import { FormBase as M } from "../../internal/components/formBase.js";
|
5
|
+
import { PopoverController as P } from "../../internal/controllers/popover.controller.js";
|
6
|
+
import { hintSeverity as T } from "../../internal/helpers/hintSeverity.js";
|
7
|
+
import { watch as B } from "../../internal/helpers/watch.js";
|
8
|
+
import { Asterisk as x } from "../../internal/templates/asterisk.js";
|
9
|
+
import { Temporal as w } from "@js-temporal/polyfill";
|
10
|
+
import L from "../../styles/component.styles.js";
|
11
|
+
import { nothing as g, html as y } from "lit";
|
12
|
+
import { property as h, state as $, query as b, queryAssignedNodes as R } from "lit/decorators.js";
|
13
|
+
import { ifDefined as p } from "lit/directives/if-defined.js";
|
14
|
+
import { live as F } from "lit/directives/live.js";
|
15
|
+
import "../date-picker/datepicker.js";
|
16
|
+
import { styles as A } from "./datepicker-input.styles.js";
|
17
|
+
var j = Object.defineProperty, q = Object.getOwnPropertyDescriptor, r = (D, e, t, a) => {
|
18
|
+
for (var l = a > 1 ? void 0 : a ? q(e, t) : e, n = D.length - 1, d; n >= 0; n--)
|
19
|
+
(d = D[n]) && (l = (a ? d(e, t, l) : d(l)) || l);
|
20
|
+
return a && l && j(e, t, l), l;
|
21
|
+
};
|
22
|
+
const _ = class _ extends M {
|
23
|
+
constructor() {
|
24
|
+
super(), this.popoverController = new P(this), this.id = "skf-datepicker-input", this.placeholder = "YYYY-MM-DD", this.range = !1, this.size = "md", this.validateOn = "change", this.invalid = !1, this.selectedRangeDates = { start: null, end: null }, this.showClearbutton = !1, this.abortController = new AbortController(), this.abortSignal = this.abortController.signal, this._handleSelectedDate = () => {
|
25
|
+
this.pristine = !1, this._internals.setFormValue(this.value ?? ""), this.validateInput();
|
26
|
+
}, this._handleDateSelected = (e) => {
|
27
|
+
if (this.range && "start" in e.detail.date && "end" in e.detail.date) {
|
28
|
+
const t = e.detail.date.start, a = e.detail.date.end;
|
29
|
+
this.value = `${v(t)},${v(a)}`, this.selectedRangeDates = { start: t, end: a };
|
30
|
+
} else !this.range && e.detail.date instanceof Date && (this.value = v(e.detail.date), this._animatePopover({ el: this.$popover, show: !1 }).then(() => {
|
31
|
+
this.$popover.hidePopover();
|
32
|
+
}));
|
33
|
+
}, this._handleKeyboardEvents = (e) => {
|
34
|
+
var a, l;
|
35
|
+
const t = e.target.closest("input");
|
36
|
+
if (t) {
|
37
|
+
if ((t.selectionStart ?? 0) < t.value.length && /[[0-9-]/.test(e.key)) {
|
38
|
+
const n = t.selectionStart ?? 0, u = t.value.split("").slice(0, n);
|
39
|
+
t.value = u.join("");
|
40
|
+
}
|
41
|
+
if (t.name.endsWith("-end") && (e.key === "Backspace" && t.value.length === 0 || t.selectionStart === 0 && e.key === "ArrowLeft") && (e.preventDefault(), this.$input.focus()), e.key === "Tab" && !e.shiftKey && t.name.endsWith("-end")) {
|
42
|
+
e.preventDefault();
|
43
|
+
const d = (a = this.$popover.childNodes[1].shadowRoot) == null ? void 0 : a.querySelector("skf-datepicker-calendar"), u = (l = d == null ? void 0 : d.shadowRoot) == null ? void 0 : l.querySelector("button");
|
44
|
+
u == null || u.focus();
|
45
|
+
}
|
46
|
+
if ((t.value.length === 4 || t.value.length === 7) && /[[0-9]/.test(e.key) && (t.value = `${t.value}-${e.key}`, e.preventDefault()), e.key === "Escape")
|
47
|
+
if (t.blur(), this.$popover.hidePopover(), this.range) {
|
48
|
+
const n = this.$input.value, d = this.$input_range_end.value;
|
49
|
+
if (!f(n, d).date()) return;
|
50
|
+
this.$datepicker.selectedDateRange = {
|
51
|
+
start: new Date(n),
|
52
|
+
end: new Date(d)
|
53
|
+
}, this.$datepicker.emit("selected-date-changed", {
|
54
|
+
detail: { date: new Date(n) }
|
55
|
+
});
|
56
|
+
} else {
|
57
|
+
if (!t.value || !f(t.value).date()) return;
|
58
|
+
this.$datepicker.emit("selected-date-changed", {
|
59
|
+
detail: { date: new Date(t.value) }
|
60
|
+
});
|
61
|
+
}
|
62
|
+
e.key === "Enter" && (t.blur(), this.$popover.hidePopover());
|
63
|
+
}
|
64
|
+
}, this._handleFocus = () => {
|
65
|
+
this.showPopover();
|
66
|
+
}, this.showPopover = () => {
|
67
|
+
if (S(this.$popover)) return;
|
68
|
+
E(() => {
|
69
|
+
this.$popover.showPopover(), this._animatePopover({ show: !0 });
|
70
|
+
}, 200)(), this.addEventListener("focusout", this.hidePopover, { once: !0, signal: this.abortSignal });
|
71
|
+
}, this.hidePopover = () => {
|
72
|
+
var t;
|
73
|
+
this.removeEventListener("focusout", this.hidePopover), ((t = document.activeElement) == null ? void 0 : t.closest("skf-datepicker-input")) !== this && this.$popover.hidePopover();
|
74
|
+
}, this._handleBlur = (e) => {
|
75
|
+
!e.target.name.endsWith("-end") && this.range;
|
76
|
+
}, this._handleClose = () => {
|
77
|
+
this.$anchor.blur();
|
78
|
+
}, this.clearInput = () => {
|
79
|
+
this.value = "", this.$datepicker.clearSelection();
|
80
|
+
}, this.clear = () => {
|
81
|
+
this.clearInput(), this._toggleClearButton(!1);
|
82
|
+
}, this._handleInput = (e) => {
|
83
|
+
const t = e.target, a = String(t.value).replace(/[^0-9-]/g, "");
|
84
|
+
if (t.value = a, t.setCustomValidity(this.customError ?? ""), !!f(t.value).ISO()) {
|
85
|
+
if (this.focusTimeoutId && clearTimeout(this.focusTimeoutId), this.$datepicker.date = t.value, this.range) {
|
86
|
+
this.$datepicker.selectedDateRange = {
|
87
|
+
start: f(this.$input.value).ISO() ? new Date(this.$input.value) : null,
|
88
|
+
end: f(this.$input_range_end.value).ISO() ? new Date(this.$input_range_end.value) : null
|
89
|
+
};
|
90
|
+
const l = Object.values(this.$datepicker.selectedDateRange).filter(Boolean).map((n) => new Date(n).toLocaleDateString("en-CA")).join();
|
91
|
+
this.value = l, f(this.$input.value).ISO() && (this.focusTimeoutId = setTimeout(() => {
|
92
|
+
this.$input_range_end.focus();
|
93
|
+
}, 200));
|
94
|
+
} else
|
95
|
+
this.$datepicker.selectedDate = new Date(t.value), this.$datepicker.emit("selected-date-changed", {
|
96
|
+
detail: { date: new Date(t.value) }
|
97
|
+
});
|
98
|
+
this.validateOn === "input" && (this._pristine = !1, this.validateInput());
|
99
|
+
}
|
100
|
+
}, this._toggleClearButton = (e = !1) => {
|
101
|
+
this.showClearbutton = e;
|
102
|
+
}, this.reposition = async () => {
|
103
|
+
const { x: e, y: t } = await C(this.$anchor, this.$popover, {
|
104
|
+
placement: "bottom-start",
|
105
|
+
middleware: [I(), O(0)],
|
106
|
+
strategy: "fixed"
|
107
|
+
});
|
108
|
+
Object.assign(this.$popover.style, {
|
109
|
+
left: `${String(e)}px`,
|
110
|
+
top: `${String(t)}px`
|
111
|
+
});
|
112
|
+
}, this.addEventListener("skf-datepicker-selected", this._handleDateSelected), this.addEventListener("reset", () => {
|
113
|
+
this.clearInput(), this.validateInput();
|
114
|
+
});
|
115
|
+
}
|
116
|
+
set customInvalid(e) {
|
117
|
+
this.customError = e ?? "";
|
118
|
+
}
|
119
|
+
get customInvalid() {
|
120
|
+
return this.customError;
|
121
|
+
}
|
122
|
+
connectedCallback() {
|
123
|
+
var e;
|
124
|
+
super.connectedCallback(), this._init_date = (e = this.value) == null ? void 0 : e.split(",")[0], this.addEventListener("selected-date-changed", this._handleSelectedDate);
|
125
|
+
}
|
126
|
+
disconnectedCallback() {
|
127
|
+
super.disconnectedCallback(), this.abortController.abort();
|
128
|
+
}
|
129
|
+
firstUpdated() {
|
130
|
+
var e;
|
131
|
+
this.$datepicker.date = this._init_date ? w.PlainDate.from(this._init_date).toString() : w.Now.plainDateISO().toString(), this.range ? this.$datepicker.selectedDateRange = {
|
132
|
+
start: this._init_date ? new Date(this._init_date) : null,
|
133
|
+
end: (e = this.value) != null && e.split(",")[1] ? new Date(this.value.split(",")[1]) : null
|
134
|
+
} : this.$datepicker.selectedDate = this._init_date ? new Date(this._init_date) : void 0, this.hint && !this.hasAttribute("hint") && this.setAttribute("hint", this.hint), this.validateInput();
|
135
|
+
}
|
136
|
+
attributeChangedCallback(e, t, a) {
|
137
|
+
if (super.attributeChangedCallback(e, t, a), e === "custom-invalid")
|
138
|
+
if (typeof a == "string") {
|
139
|
+
const n = this.withFallback(a);
|
140
|
+
this._pristine = !1, this._internals.setValidity({ customError: !0 }, n), this.invalid = !0, this.hint = n, this.checkValidity();
|
141
|
+
} else
|
142
|
+
this._internals.setValidity({}), this.validateInput();
|
143
|
+
}
|
144
|
+
_handleValueChange() {
|
145
|
+
var e, t, a, l, n, d, u, i;
|
146
|
+
(e = this.value) != null && e.trim() || this.$datepicker.clearSelection(), this._internals.setFormValue(this.value ?? ""), this.validateInput(), this._pristine = !1, this.$input.value = v((t = this.value) == null ? void 0 : t.split(",")[0]), this.range ? (this.$datepicker.selectedDateRange = {
|
147
|
+
start: (n = this.value) != null && n.split(",")[0] ? new Date(this.value.split(",")[0]) : null,
|
148
|
+
end: (d = this.value) != null && d.split(",")[1] ? new Date(this.value.split(",")[1]) : null
|
149
|
+
}, this.$input_range_end.value = v((u = this.value) == null ? void 0 : u.split(",")[1]), this.$datepicker.date = ((i = this.value) == null ? void 0 : i.split(",")[0]) ?? "") : (this.$datepicker.selectedDate = (a = this.value) != null && a.split(",")[0] ? new Date(this.value.split(",")[0]) : void 0, this.$datepicker.date = ((l = this.value) == null ? void 0 : l.split(",")[0]) ?? ""), this.validateInput();
|
150
|
+
}
|
151
|
+
/** @internal */
|
152
|
+
async _animatePopover({ el: e = this.$popover, show: t }) {
|
153
|
+
return t && (e.style.opacity = "0", e.style.transform = "scaleY(0.5)"), new Promise((a) => {
|
154
|
+
const l = [
|
155
|
+
{ opacity: 0, transform: "scaleY(0.5)" },
|
156
|
+
{ opacity: 1, transform: "scaleY(1)" }
|
157
|
+
], n = t ? l : l.reverse();
|
158
|
+
setTimeout(
|
159
|
+
() => {
|
160
|
+
e.style.transformOrigin = "top";
|
161
|
+
const d = this.$popover.animate(n, {
|
162
|
+
duration: 100,
|
163
|
+
easing: "linear",
|
164
|
+
fill: "both"
|
165
|
+
});
|
166
|
+
d.onfinish = () => {
|
167
|
+
a();
|
168
|
+
};
|
169
|
+
},
|
170
|
+
t ? 0 : 50
|
171
|
+
);
|
172
|
+
});
|
173
|
+
}
|
174
|
+
/** @internal consider sharing this functionality with input */
|
175
|
+
validateInput() {
|
176
|
+
if (this._internals.validity.customError) return;
|
177
|
+
let t = JSON.parse(JSON.stringify(this._internals.validity)), a = {};
|
178
|
+
if (this.selectableFrom) {
|
179
|
+
const { validityFragment: i, errorMessageFragment: o } = l(this);
|
180
|
+
t = { ...t, ...i }, a = { ...a, ...o };
|
181
|
+
}
|
182
|
+
if (this.selectableTo) {
|
183
|
+
const { validityFragment: i, errorMessageFragment: o } = n(this);
|
184
|
+
t = { ...t, ...i }, a = { ...a, ...o };
|
185
|
+
}
|
186
|
+
if (this.range) {
|
187
|
+
const { validityFragment: i, errorMessageFragment: o } = d(this);
|
188
|
+
t = { ...t, ...i }, a = { ...a, ...o };
|
189
|
+
}
|
190
|
+
if (this.required) {
|
191
|
+
const { validityFragment: i, errorMessageFragment: o } = u(this);
|
192
|
+
t = { ...t, ...i }, a = { ...a, ...o };
|
193
|
+
}
|
194
|
+
if (t.valid = !Object.values(t).some((i) => i), this.invalid = !1, t.valid)
|
195
|
+
this._internals.setValidity({ customError: this._internals.validity.customError }), this.hint = this.getAttribute("hint") ?? "";
|
196
|
+
else {
|
197
|
+
this.invalid = !this._pristine && !t.valid;
|
198
|
+
let i;
|
199
|
+
for (i in t) {
|
200
|
+
const o = `data-${i.toString()}`;
|
201
|
+
if (t[i]) {
|
202
|
+
this.validationError = i.toString();
|
203
|
+
const c = this.hasAttribute(o) ? this.getAttribute(o) : a[i];
|
204
|
+
this._internals.setValidity(
|
205
|
+
{ [this.validationError]: !0, customError: this._internals.validity.customError },
|
206
|
+
this.withFallback(c)
|
207
|
+
), c && !this._pristine && (this.hint = c), this.invalid && this.customErrorDisplay && this.checkValidity();
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
function l(i) {
|
212
|
+
const o = { validityFragment: {}, errorMessageFragment: {} };
|
213
|
+
if (!i.selectableFrom) return o;
|
214
|
+
const c = new Date(i.selectableFrom);
|
215
|
+
if (new Date(i.$input.value) < c) {
|
216
|
+
const m = i.getAttribute("data-rangeunderflow") ?? `Date is out of range. Earliest selectable date is ${i.selectableFrom}.`;
|
217
|
+
return {
|
218
|
+
validityFragment: { rangeUnderflow: !0, valid: !1 },
|
219
|
+
errorMessageFragment: { rangeUnderflow: m }
|
220
|
+
};
|
221
|
+
}
|
222
|
+
return o;
|
223
|
+
}
|
224
|
+
function n(i) {
|
225
|
+
const o = { validityFragment: {}, errorMessageFragment: {} };
|
226
|
+
if (!i.selectableTo) return o;
|
227
|
+
const c = new Date(i.selectableTo);
|
228
|
+
if (new Date(i.$input.value) > c) {
|
229
|
+
const m = i.getAttribute("data-rangeoverflow") ?? `Date is out of range. Latest selectable date is ${i.selectableTo}.`;
|
230
|
+
return {
|
231
|
+
validityFragment: { rangeOverflow: !0, valid: !1 },
|
232
|
+
errorMessageFragment: { rangeOverflow: m }
|
233
|
+
};
|
234
|
+
}
|
235
|
+
return o;
|
236
|
+
}
|
237
|
+
function d(i) {
|
238
|
+
const o = { validityFragment: {}, errorMessageFragment: {} }, c = new Date(i.$input.value);
|
239
|
+
if (new Date(i.$input_range_end.value) < c) {
|
240
|
+
const m = i.getAttribute("data-rangeunderflow") ?? "End date cannot be before start date";
|
241
|
+
return {
|
242
|
+
validityFragment: { rangeUnderflow: !0, valid: !1 },
|
243
|
+
errorMessageFragment: { rangeUnderflow: m }
|
244
|
+
};
|
245
|
+
}
|
246
|
+
return o;
|
247
|
+
}
|
248
|
+
function u(i) {
|
249
|
+
const o = { validityFragment: {}, errorMessageFragment: {} };
|
250
|
+
return !i.$input.value || i.range && !i.$input_range_end.value ? {
|
251
|
+
validityFragment: { valueMissing: !0, valid: !1 },
|
252
|
+
errorMessageFragment: { valueMissing: "This field is required" }
|
253
|
+
} : o;
|
254
|
+
}
|
255
|
+
}
|
256
|
+
render() {
|
257
|
+
var t, a, l, n, d, u, i, o;
|
258
|
+
const e = (this._defaultSlot.length === 0 || !((a = (t = this._defaultSlot[0]) == null ? void 0 : t.textContent) != null && a.trim())) && !this.label;
|
259
|
+
return y`
|
260
|
+
<div
|
261
|
+
id="root"
|
262
|
+
@mouseenter=${() => {
|
263
|
+
this.value && this._toggleClearButton(!0);
|
264
|
+
}}
|
265
|
+
@mouseleave=${() => {
|
266
|
+
this._toggleClearButton(!1);
|
267
|
+
}}
|
268
|
+
>
|
269
|
+
<label>
|
270
|
+
<div class=${this.hideLabel ? "visually-hidden" : ""} ?hidden=${e} id="label">
|
271
|
+
<slot>${this.label}</slot>
|
272
|
+
${this.required ? x(this.requiredLabel) : null}
|
273
|
+
</div>
|
274
|
+
<div id="input">
|
275
|
+
<input
|
276
|
+
?disabled=${this.disabled}
|
277
|
+
?readonly=${this.readonly}
|
278
|
+
.value=${F(
|
279
|
+
this.range ? v((l = this.value) == null ? void 0 : l.split(",")[0]) : v(this.value)
|
280
|
+
)}
|
281
|
+
@blur=${this._handleBlur}
|
282
|
+
@click=${this._handleFocus}
|
283
|
+
@focus=${this._handleFocus}
|
284
|
+
@input=${this._handleInput}
|
285
|
+
@keydown=${this._handleKeyboardEvents}
|
286
|
+
aria-describedby=${p((n = this.hint) != null && n.trim() ? "hint" : g)}
|
287
|
+
aria-errormessage=${p((d = this.hint) != null && d.trim() ? "hint" : g)}
|
288
|
+
aria-invalid=${!!this.invalid}
|
289
|
+
autocomplete="off"
|
290
|
+
data-testid="field-input"
|
291
|
+
inputmode=${p(this.inputMode)}
|
292
|
+
maxlength="10"
|
293
|
+
name=${this.name ?? "calendar"}
|
294
|
+
placeholder=${p(this.placeholder)}
|
295
|
+
type="text"
|
296
|
+
/>
|
297
|
+
${this.range ? y`
|
298
|
+
<skf-icon name="arrowRight"></skf-icon>
|
299
|
+
<input
|
300
|
+
?disabled=${this.disabled}
|
301
|
+
?readonly=${this.readonly}
|
302
|
+
.value=${F(v((u = this.value) == null ? void 0 : u.split(",")[1]))}
|
303
|
+
@blur=${this._handleBlur}
|
304
|
+
@click=${this._handleFocus}
|
305
|
+
@focus=${this._handleFocus}
|
306
|
+
@input=${this._handleInput}
|
307
|
+
@keydown=${this._handleKeyboardEvents}
|
308
|
+
aria-describedby=${p((i = this.hint) != null && i.trim() ? "hint" : g)}
|
309
|
+
aria-errormessage=${p((o = this.hint) != null && o.trim() ? "hint" : g)}
|
310
|
+
aria-invalid=${!!this.invalid}
|
311
|
+
autocomplete="off"
|
312
|
+
data-testid="field-input-range-end"
|
313
|
+
inputmode=${p(this.inputMode)}
|
314
|
+
maxlength="10"
|
315
|
+
name=${(this.name ?? "calendar") + "-end"}
|
316
|
+
placeholder=${p(this.placeholder)}
|
317
|
+
type="text"
|
318
|
+
/>
|
319
|
+
` : g}
|
320
|
+
${this.showClearbutton ? y`
|
321
|
+
<button class="password skf-icon-host" type="button" @click=${this.clear}>
|
322
|
+
<skf-icon name="close" size="sm"></skf-icon>
|
323
|
+
</button>
|
324
|
+
` : y`
|
325
|
+
<button class="password skf-icon-host" type="button">
|
326
|
+
<skf-icon name="calendarMonth" size="sm"></skf-icon>
|
327
|
+
</button>
|
328
|
+
`}
|
329
|
+
</div>
|
330
|
+
</label>
|
331
|
+
${this.hint && y`
|
332
|
+
<skf-hint
|
333
|
+
aria-live=${this.invalid ? "assertive" : "polite"}
|
334
|
+
id="hint"
|
335
|
+
severity=${p(T(this.severity, this.invalid))}
|
336
|
+
>${this.customInvalid ?? this.hint}
|
337
|
+
</skf-hint>
|
338
|
+
`}
|
339
|
+
</div>
|
340
|
+
|
341
|
+
<div id="popover" popover @close=${this._handleClose}>
|
342
|
+
<skf-datepicker
|
343
|
+
?range=${this.range}
|
344
|
+
id=${this.id}
|
345
|
+
invalid-dates=${p(this.invalidDates)}
|
346
|
+
selectable-from=${p(this.selectableFrom)}
|
347
|
+
selectable-to=${p(this.selectableTo)}
|
348
|
+
></skf-datepicker>
|
349
|
+
</div>
|
350
|
+
`;
|
351
|
+
}
|
352
|
+
};
|
353
|
+
_.styles = [L, A];
|
354
|
+
let s = _;
|
355
|
+
r([
|
356
|
+
h({ attribute: "custom-invalid", reflect: !0 })
|
357
|
+
], s.prototype, "customInvalid", 1);
|
358
|
+
r([
|
359
|
+
h({ type: String })
|
360
|
+
], s.prototype, "id", 2);
|
361
|
+
r([
|
362
|
+
h()
|
363
|
+
], s.prototype, "label", 2);
|
364
|
+
r([
|
365
|
+
h({ type: Boolean, attribute: "hide-label" })
|
366
|
+
], s.prototype, "hideLabel", 2);
|
367
|
+
r([
|
368
|
+
h()
|
369
|
+
], s.prototype, "hint", 2);
|
370
|
+
r([
|
371
|
+
h({ attribute: "invalid-dates" })
|
372
|
+
], s.prototype, "invalidDates", 2);
|
373
|
+
r([
|
374
|
+
h({ reflect: !0 })
|
375
|
+
], s.prototype, "name", 2);
|
376
|
+
r([
|
377
|
+
h()
|
378
|
+
], s.prototype, "placeholder", 2);
|
379
|
+
r([
|
380
|
+
h({ type: Boolean })
|
381
|
+
], s.prototype, "range", 2);
|
382
|
+
r([
|
383
|
+
h({ type: Boolean })
|
384
|
+
], s.prototype, "readonly", 2);
|
385
|
+
r([
|
386
|
+
h({ attribute: "required-label" })
|
387
|
+
], s.prototype, "requiredLabel", 2);
|
388
|
+
r([
|
389
|
+
h({ attribute: "selectable-from" })
|
390
|
+
], s.prototype, "selectableFrom", 2);
|
391
|
+
r([
|
392
|
+
h({ attribute: "selectable-to" })
|
393
|
+
], s.prototype, "selectableTo", 2);
|
394
|
+
r([
|
395
|
+
h({ reflect: !0 })
|
396
|
+
], s.prototype, "severity", 2);
|
397
|
+
r([
|
398
|
+
h({ reflect: !0 })
|
399
|
+
], s.prototype, "size", 2);
|
400
|
+
r([
|
401
|
+
h({ type: String, attribute: "validate-on" })
|
402
|
+
], s.prototype, "validateOn", 2);
|
403
|
+
r([
|
404
|
+
h()
|
405
|
+
], s.prototype, "value", 2);
|
406
|
+
r([
|
407
|
+
$()
|
408
|
+
], s.prototype, "_init_date", 2);
|
409
|
+
r([
|
410
|
+
h({ type: Boolean, reflect: !0 })
|
411
|
+
], s.prototype, "invalid", 2);
|
412
|
+
r([
|
413
|
+
$()
|
414
|
+
], s.prototype, "selectedRangeDates", 2);
|
415
|
+
r([
|
416
|
+
$()
|
417
|
+
], s.prototype, "showClearbutton", 2);
|
418
|
+
r([
|
419
|
+
b("#popover")
|
420
|
+
], s.prototype, "$popover", 2);
|
421
|
+
r([
|
422
|
+
b("#input")
|
423
|
+
], s.prototype, "$anchor", 2);
|
424
|
+
r([
|
425
|
+
b('input[data-testid="field-input"]')
|
426
|
+
], s.prototype, "$input", 2);
|
427
|
+
r([
|
428
|
+
b('input[data-testid="field-input-range-end"]')
|
429
|
+
], s.prototype, "$input_range_end", 2);
|
430
|
+
r([
|
431
|
+
b("skf-datepicker")
|
432
|
+
], s.prototype, "$datepicker", 2);
|
433
|
+
r([
|
434
|
+
R({ flatten: !0 })
|
435
|
+
], s.prototype, "_defaultSlot", 2);
|
436
|
+
r([
|
437
|
+
B("value", { waitUntilFirstUpdate: !0, afterUpdate: !0 })
|
438
|
+
], s.prototype, "_handleValueChange", 1);
|
439
|
+
export {
|
440
|
+
s as SkfDatePickerInput
|
441
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { SkfDatePickerInput } from './datepicker-input.component.js';
|
2
|
+
export * from './datepicker-input.component.js';
|
3
|
+
export default SkfDatePickerInput;
|
4
|
+
declare global {
|
5
|
+
interface HTMLElementTagNameMap {
|
6
|
+
'skf-datepicker-input': SkfDatePickerInput;
|
7
|
+
}
|
8
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
2
|
+
/**
|
3
|
+
* @param date - a date to format, defaults to yyyy-mm-dd
|
4
|
+
* @param locale
|
5
|
+
* @returns - a formatted date string
|
6
|
+
*/
|
7
|
+
export declare function dateFormatter(date?: string | Date | null, locale?: string): string;
|
8
|
+
/**
|
9
|
+
* Questionable if this really works
|
10
|
+
*
|
11
|
+
* @param element - a popover element to check if it is open
|
12
|
+
* @returns - true if the popover is open, false otherwise
|
13
|
+
*/
|
14
|
+
export declare const isPopoverOpen: (element: HTMLElement) => boolean;
|
15
|
+
/**
|
16
|
+
* @param func - a function to debounce
|
17
|
+
* @param delay - the delay in milliseconds to debounce the function
|
18
|
+
* @returns - a debounced function
|
19
|
+
*/
|
20
|
+
export declare function debounce<T extends (...args: unknown[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
|
21
|
+
/**
|
22
|
+
* Returns true if all given dates matches a least one of the given types.
|
23
|
+
*
|
24
|
+
* @param assertDate - dates to check if they match one valid date
|
25
|
+
* @returns - true if the date is a valid date, false otherwise
|
26
|
+
*
|
27
|
+
* @example - is('2021-01-01', new Date(), Temporal.PlainDate.from('2021-01-01')).dateISOPlainDate; // true
|
28
|
+
* @example - is('2021-01-01', new Date(), Temporal.PlainDate.from('2021-01-01')).dateISO; // false
|
29
|
+
*/
|
30
|
+
export declare const is: (...assertDates: (Date | Temporal.PlainDate | string | null)[]) => {
|
31
|
+
date: () => boolean;
|
32
|
+
ISO: () => boolean;
|
33
|
+
plain: () => boolean;
|
34
|
+
dateISO: () => boolean;
|
35
|
+
datePlain: () => boolean;
|
36
|
+
dateISOPlain: () => boolean;
|
37
|
+
plainISO: () => boolean;
|
38
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Temporal as u } from "@js-temporal/polyfill";
|
2
|
+
function l(n, e = "en-CA") {
|
3
|
+
return n ? (typeof n == "string" && (n = new Date(n)), n.toLocaleDateString(e)) : "";
|
4
|
+
}
|
5
|
+
const p = (n) => n.matches(":popover-open");
|
6
|
+
let i = null;
|
7
|
+
function a(n, e) {
|
8
|
+
return (...o) => {
|
9
|
+
i && clearTimeout(i), i = setTimeout(() => {
|
10
|
+
n(...o);
|
11
|
+
}, e);
|
12
|
+
};
|
13
|
+
}
|
14
|
+
const f = (...n) => {
|
15
|
+
const e = () => n.some((t) => t instanceof Date && !isNaN(t.valueOf())), o = () => n.some((t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}$/.test(t)), r = () => n.some((t) => t instanceof u.PlainDate);
|
16
|
+
return {
|
17
|
+
date: e,
|
18
|
+
ISO: o,
|
19
|
+
plain: r,
|
20
|
+
dateISO: () => e() || o(),
|
21
|
+
datePlain: () => e() || r(),
|
22
|
+
dateISOPlain: () => e() || o() || r(),
|
23
|
+
plainISO: () => r() || o()
|
24
|
+
};
|
25
|
+
};
|
26
|
+
export {
|
27
|
+
l as dateFormatter,
|
28
|
+
a as debounce,
|
29
|
+
f as is,
|
30
|
+
p as isPopoverOpen
|
31
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult[];
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import o from "../../styles/form-field.styles.js";
|
2
|
+
import { visuallyHidden as r } from "../../styles/util.styles.js";
|
3
|
+
import { css as e } from "lit";
|
4
|
+
const m = [
|
5
|
+
r,
|
6
|
+
o,
|
7
|
+
e`
|
8
|
+
@layer components {
|
9
|
+
#popover {
|
10
|
+
border: none;
|
11
|
+
overflow: visible;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
`
|
15
|
+
];
|
16
|
+
export {
|
17
|
+
m as styles
|
18
|
+
};
|
@@ -4,23 +4,16 @@ import '../icon/icon.js';
|
|
4
4
|
import { SkfElement } from '../../internal/components/skf-element';
|
5
5
|
import { type CSSResultGroup } from 'lit';
|
6
6
|
/**
|
7
|
-
*
|
7
|
+
* The `<skf-dialog>` is a component that open up a dialog of type modal with the content provided. (MDN refrains from opening the dialog using the `open` attribute, however skf-dialog does not have that limitation)
|
8
8
|
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* TBD: Should we disable scrolling on the page behind the dialog? Maybe only if it is modal?
|
12
|
-
*/
|
13
|
-
/**
|
14
|
-
* The `<skf-dialog>` is a component that open up a dialog with the content provided
|
15
|
-
*
|
16
|
-
* @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
|
9
|
+
* @documentation See [zeroheight](https://zeroheight.com/853e936c9/p/329940-dialogmodal) for design principles
|
17
10
|
*
|
18
11
|
* @slot - The dialog component's content
|
19
12
|
* @slot footer - The dialog component's buttons goes here
|
20
13
|
*
|
21
|
-
* @event skf-dialog-
|
22
|
-
* @event skf-dialog-
|
23
|
-
* @event
|
14
|
+
* @event skf-dialog-opened - Fires when the dialog is opened (after transitioned in)
|
15
|
+
* @event skf-dialog-closing - Fires when the dialog is closed (before transitioned out)
|
16
|
+
* @event skf-dialog-closed - Fires when the dialog is closed (after transitioned out)
|
24
17
|
*
|
25
18
|
* @cssproperty --skf-dialog-height - A custom height for the Dialog. Pass valid CSS **block-size** values
|
26
19
|
* @cssproperty --skf-dialog-width - A custom width for the Dialog Pass valid CSS **inline-size** values
|
@@ -40,35 +33,32 @@ export declare class SkfDialog extends SkfElement {
|
|
40
33
|
noCloseButton?: boolean | undefined;
|
41
34
|
/** If defined, removes the inner padding */
|
42
35
|
noPadding: boolean;
|
43
|
-
|
44
|
-
|
36
|
+
/** If true, indicates that the dialog is active and is available for interaction */
|
37
|
+
open: boolean;
|
38
|
+
/** @internal */
|
45
39
|
onClose?: ((event: Event) => void) | null;
|
46
40
|
/** @internal */
|
47
|
-
|
41
|
+
renderFoot: boolean;
|
42
|
+
/** @internal */
|
43
|
+
$dialog?: HTMLDialogElement;
|
48
44
|
/** @internal */
|
49
45
|
footerEls?: HTMLElement[];
|
46
|
+
handleOpenChange(): void;
|
47
|
+
protected firstUpdated(): void;
|
50
48
|
/** @internal */
|
51
|
-
|
49
|
+
_handleBackdropClick: (event: MouseEvent) => void;
|
52
50
|
/** @internal */
|
53
|
-
|
54
|
-
protected firstUpdated(): void;
|
55
|
-
handleOpenChange(): void;
|
51
|
+
_handleClose: (event: Event) => void;
|
56
52
|
/** @internal */
|
57
|
-
|
53
|
+
_handleKeyDown: (event: KeyboardEvent) => void;
|
58
54
|
/** @internal */
|
59
55
|
_transition(): {
|
60
56
|
entry: () => Promise<unknown>;
|
61
57
|
exit: () => Promise<unknown>;
|
62
58
|
};
|
63
|
-
/** @internal */
|
64
|
-
_handleBackdropClick: (event: MouseEvent) => void;
|
65
|
-
/** @internal */
|
66
|
-
_handleClose: (event: Event) => void;
|
67
|
-
/** @internal */
|
68
|
-
get _isModal(): boolean;
|
69
59
|
/** Method that opens the dialog in modal state */
|
70
|
-
showModal
|
60
|
+
showModal(): Promise<boolean>;
|
71
61
|
/** Method that closes the dialog */
|
72
|
-
close
|
62
|
+
close(): Promise<boolean | undefined>;
|
73
63
|
render(): import("lit").TemplateResult<1>;
|
74
64
|
}
|