@skf-design-system/ui-components 1.0.0-alpha.38 → 1.0.0-alpha.39
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 +18 -0
- package/dist/components/alert/alert.component.d.ts +3 -2
- package/dist/components/alert/alert.component.js +39 -33
- package/dist/components/breadcrumb/breadcrumb-item.component.js +11 -12
- package/dist/components/button/button.component.js +32 -36
- package/dist/components/button/button.styles.js +3 -3
- package/dist/components/checkbox/checkbox.component.d.ts +6 -5
- package/dist/components/checkbox/checkbox.component.js +67 -69
- package/dist/components/checkbox/checkbox.styles.js +1 -1
- package/dist/components/datepicker/datepicker-calendar.component.d.ts +1 -0
- package/dist/components/datepicker/datepicker-calendar.component.js +107 -116
- package/dist/components/datepicker/datepicker-popup.component.d.ts +4 -0
- package/dist/components/datepicker/datepicker-popup.component.js +112 -100
- package/dist/components/datepicker/datepicker-popup.helpers.js +1 -1
- package/dist/components/datepicker/datepicker.component.d.ts +4 -2
- package/dist/components/datepicker/datepicker.component.js +159 -160
- package/dist/components/dialog/dialog.component.d.ts +3 -2
- package/dist/components/dialog/dialog.component.js +48 -48
- package/dist/components/divider/divider.component.d.ts +3 -0
- package/dist/components/divider/divider.component.js +43 -22
- package/dist/components/divider/divider.styles.js +9 -9
- package/dist/components/drawer/drawer.component.d.ts +12 -4
- package/dist/components/drawer/drawer.component.js +84 -61
- package/dist/components/drawer/drawer.styles.js +47 -40
- package/dist/components/header/header.component.d.ts +4 -2
- package/dist/components/header/header.component.js +64 -57
- package/dist/components/header/header.styles.js +2 -2
- package/dist/components/icon/icon.component.js +26 -16
- package/dist/components/icon/icon.styles.js +4 -4
- package/dist/components/input/input.component.d.ts +11 -10
- package/dist/components/input/input.component.js +115 -111
- package/dist/components/input/input.controllers.d.ts +0 -1
- package/dist/components/input/input.controllers.js +14 -19
- package/dist/components/link/link.component.d.ts +1 -0
- package/dist/components/link/link.component.js +86 -74
- package/dist/components/link/link.styles.js +7 -3
- package/dist/components/loader/loader.component.d.ts +0 -2
- package/dist/components/loader/loader.component.js +27 -30
- package/dist/components/loader/loader.styles.js +1 -1
- package/dist/components/menu/menu-item.styles.js +8 -7
- package/dist/components/menu/menu.component.d.ts +5 -2
- package/dist/components/menu/menu.component.js +7 -7
- package/dist/components/nav/nav.component.d.ts +3 -0
- package/dist/components/nav/nav.component.js +38 -33
- package/dist/components/popover/popover.component.d.ts +6 -7
- package/dist/components/popover/popover.component.js +23 -31
- package/dist/components/progress/progress.styles.js +3 -3
- package/dist/components/radio/radio.component.d.ts +4 -2
- package/dist/components/radio/radio.component.js +96 -91
- package/dist/components/radio/radio.styles.js +1 -1
- package/dist/components/segmented-button/segmented-button-item.component.js +1 -1
- package/dist/components/segmented-button/segmented-button-item.styles.js +1 -1
- package/dist/components/segmented-button/segmented-button.component.js +22 -24
- package/dist/components/select/select-option.component.d.ts +2 -1
- package/dist/components/select/select-option.component.js +31 -36
- package/dist/components/select/select.component.d.ts +20 -10
- package/dist/components/select/select.component.js +139 -104
- package/dist/components/select/select.controllers.js +14 -17
- package/dist/components/select/select.styles.js +8 -3
- package/dist/components/stepper/stepper-item.component.d.ts +1 -1
- package/dist/components/stepper/stepper-item.component.js +26 -23
- package/dist/components/stepper/stepper-item.styles.js +4 -4
- package/dist/components/stepper/stepper.component.js +2 -3
- package/dist/components/stepper/stepper.helpers.js +6 -7
- package/dist/components/switch/switch.component.d.ts +4 -2
- package/dist/components/switch/switch.component.js +64 -58
- package/dist/components/switch/switch.styles.js +1 -1
- package/dist/components/tabs/tab-panel.component.d.ts +1 -1
- package/dist/components/tabs/tab-panel.component.js +19 -16
- package/dist/components/tabs/tab.component.d.ts +1 -1
- package/dist/components/tabs/tab.component.js +17 -14
- package/dist/components/tabs/tab.styles.js +2 -2
- package/dist/components/tabs/tabs.component.js +6 -6
- package/dist/components/tag/tag.component.d.ts +9 -6
- package/dist/components/tag/tag.component.js +78 -72
- package/dist/components/tag/tag.styles.js +5 -0
- package/dist/components/textarea/textarea.component.d.ts +4 -2
- package/dist/components/textarea/textarea.component.js +101 -95
- package/dist/components/toast/toast-item.styles.js +13 -10
- package/dist/components/toast/toast.singleton.js +6 -7
- package/dist/components/tooltip/tooltip.component.d.ts +7 -4
- package/dist/components/tooltip/tooltip.component.js +22 -14
- package/dist/custom-elements.json +835 -422
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -20
- package/dist/internal/base-classes/popover/popover.base.d.ts +28 -8
- package/dist/internal/base-classes/popover/popover.base.js +78 -74
- package/dist/internal/components/formBase.d.ts +1 -0
- package/dist/internal/components/formBase.js +11 -19
- package/dist/internal/controllers/popover.controller.d.ts +2 -0
- package/dist/internal/controllers/popover.controller.js +11 -14
- package/dist/internal/helpers/stateMap.js +3 -3
- package/dist/internal/helpers/uuid.d.ts +8 -10
- package/dist/internal/helpers/uuid.js +4 -11
- package/dist/internal/helpers/watch.d.ts +1 -1
- package/dist/internal/templates/asterisk.d.ts +1 -1
- package/dist/internal/templates/asterisk.js +4 -4
- package/dist/internal/types.d.ts +4 -0
- package/dist/styles/global-alt.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.js +27 -0
- package/dist/translations/es.d.ts +3 -0
- package/dist/translations/es.js +27 -0
- package/dist/translations/index.d.ts +4 -0
- package/dist/translations/pt.d.ts +3 -0
- package/dist/translations/pt.js +27 -0
- package/dist/translations/sv.d.ts +3 -0
- package/dist/translations/sv.js +27 -0
- package/dist/types/jsx/custom-element-jsx.d.ts +1840 -858
- package/dist/types/vue/index.d.ts +69 -64
- package/dist/utilities/localize.d.ts +28 -0
- package/dist/utilities/localize.js +13 -0
- package/dist/vscode.html-custom-data.json +75 -83
- package/dist/web-types.json +229 -190
- package/package.json +29 -35
- package/custom-elements.json +0 -25490
@@ -1,61 +1,63 @@
|
|
1
|
+
var S = (o) => {
|
2
|
+
throw TypeError(o);
|
3
|
+
};
|
4
|
+
var P = (o, l, e) => l.has(o) || S("Cannot " + e);
|
5
|
+
var D = (o, l, e) => (P(o, l, "read from private field"), e ? e.call(o) : l.get(o)), E = (o, l, e) => l.has(o) ? S("Cannot add the same private member more than once") : l instanceof WeakSet ? l.add(o) : l.set(o, e), C = (o, l, e, t) => (P(o, l, "write to private field"), t ? t.call(o, e) : l.set(o, e), e);
|
1
6
|
import "../icon/icon.js";
|
2
|
-
import { computePosition as
|
3
|
-
import { FormBase as
|
7
|
+
import { computePosition as T, flip as B, offset as x } from "@floating-ui/dom";
|
8
|
+
import { FormBase as R } from "../../internal/components/formBase.js";
|
4
9
|
import "../../internal/components/hint/hint.js";
|
5
|
-
import { PopoverController as
|
6
|
-
import { hintSeverity as
|
7
|
-
import { watch as
|
8
|
-
import { Asterisk as
|
9
|
-
import { Temporal as
|
10
|
-
import { componentStyles as
|
11
|
-
import {
|
12
|
-
import {
|
10
|
+
import { PopoverController as A } from "../../internal/controllers/popover.controller.js";
|
11
|
+
import { hintSeverity as L } from "../../internal/helpers/hintSeverity.js";
|
12
|
+
import { watch as j } from "../../internal/helpers/watch.js";
|
13
|
+
import { Asterisk as V } from "../../internal/templates/asterisk.js";
|
14
|
+
import { Temporal as I } from "@js-temporal/polyfill";
|
15
|
+
import { componentStyles as q } from "../../styles/component.styles.js";
|
16
|
+
import { LocalizeController as U } from "../../utilities/localize.js";
|
17
|
+
import { nothing as f, html as b } from "lit";
|
18
|
+
import { property as d, state as k, query as $, queryAssignedNodes as N } from "lit/decorators.js";
|
13
19
|
import { ifDefined as u } from "lit/directives/if-defined.js";
|
14
|
-
import { live as
|
20
|
+
import { live as O } from "lit/directives/live.js";
|
15
21
|
import "./datepicker-popup.js";
|
16
|
-
import { dateFormatter as v, is as
|
17
|
-
import { styles as
|
18
|
-
var
|
19
|
-
for (var
|
20
|
-
(
|
21
|
-
return
|
22
|
-
};
|
23
|
-
const
|
22
|
+
import { dateFormatter as v, is as m, isPopoverOpen as Y, debounce as z } from "./datepicker.helpers.js";
|
23
|
+
import { styles as W } from "./datepicker.styles.js";
|
24
|
+
var H = Object.defineProperty, K = Object.getOwnPropertyDescriptor, r = (o, l, e, t) => {
|
25
|
+
for (var i = t > 1 ? void 0 : t ? K(l, e) : l, h = o.length - 1, p; h >= 0; h--)
|
26
|
+
(p = o[h]) && (i = (t ? p(l, e, i) : p(i)) || i);
|
27
|
+
return t && i && H(l, e, i), i;
|
28
|
+
}, g;
|
29
|
+
const w = class w extends R {
|
24
30
|
constructor() {
|
25
|
-
super()
|
31
|
+
super();
|
32
|
+
E(this, g);
|
33
|
+
C(this, g, new U(this)), this.popoverController = new A(this), this.id = "skf-datepicker-input", this.lang = "en", 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 = () => {
|
26
34
|
this.pristine = !1, this._internals.setFormValue(this.value ?? ""), this.validateInput();
|
27
35
|
}, this._handleDateSelected = (e) => {
|
28
36
|
if (this.range && "start" in e.detail.date && "end" in e.detail.date) {
|
29
|
-
const t = e.detail.date.start,
|
30
|
-
this.value = `${v(t)},${v(
|
37
|
+
const t = e.detail.date.start, i = e.detail.date.end;
|
38
|
+
this.value = `${v(t)},${v(i)}`, this.selectedRangeDates = { start: t, end: i };
|
31
39
|
} else !this.range && e.detail.date instanceof Date && (this.value = v(e.detail.date), this._animatePopover({ el: this.$popover, show: !1 }).then(() => {
|
32
40
|
this.$popover.hidePopover();
|
33
41
|
}));
|
34
42
|
}, this._handleKeyboardEvents = (e) => {
|
35
|
-
var a, o;
|
36
43
|
const t = e.target.closest("input");
|
37
44
|
if (t) {
|
38
45
|
if ((t.selectionStart ?? 0) < t.value.length && /[[0-9-]/.test(e.key)) {
|
39
|
-
const
|
46
|
+
const i = t.selectionStart ?? 0, p = t.value.split("").slice(0, i);
|
40
47
|
t.value = p.join("");
|
41
48
|
}
|
42
|
-
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")) {
|
43
|
-
e.preventDefault();
|
44
|
-
const d = (a = this.$popover.childNodes[1].shadowRoot) == null ? void 0 : a.querySelector("skf-datepicker-calendar"), p = (o = d == null ? void 0 : d.shadowRoot) == null ? void 0 : o.querySelector("button");
|
45
|
-
p == null || p.focus();
|
46
|
-
}
|
47
|
-
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")
|
49
|
+
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") && (e.preventDefault(), this.$popover.childNodes[1].shadowRoot?.querySelector("skf-datepicker-calendar")?.shadowRoot?.querySelector("button")?.focus()), (t.value.length === 4 || t.value.length === 7) && /[[0-9]/.test(e.key) && (t.value = `${t.value}-${e.key}`, e.preventDefault()), e.key === "Escape")
|
48
50
|
if (t.blur(), this.$popover.hidePopover(), this.range) {
|
49
|
-
const
|
50
|
-
if (!
|
51
|
+
const i = this.$input.value, h = this.$input_range_end.value;
|
52
|
+
if (!m(i, h).date()) return;
|
51
53
|
this.$datepickerPopup.selectedDateRange = {
|
52
|
-
start: new Date(
|
53
|
-
end: new Date(
|
54
|
+
start: new Date(i),
|
55
|
+
end: new Date(h)
|
54
56
|
}, this.$datepickerPopup.emit("selected-date-changed", {
|
55
|
-
detail: { date: new Date(
|
57
|
+
detail: { date: new Date(i) }
|
56
58
|
});
|
57
59
|
} else {
|
58
|
-
if (!t.value || !
|
60
|
+
if (!t.value || !m(t.value).date()) return;
|
59
61
|
this.$datepickerPopup.emit("selected-date-changed", {
|
60
62
|
detail: { date: new Date(t.value) }
|
61
63
|
});
|
@@ -71,15 +73,15 @@ const _ = class _ extends C {
|
|
71
73
|
}, this.clearInput = () => {
|
72
74
|
this.value = "", this.$datepickerPopup.clearSelection();
|
73
75
|
}, this._handleInput = (e) => {
|
74
|
-
const t = e.target,
|
75
|
-
if (t.value =
|
76
|
+
const t = e.target, i = String(t.value).replace(/[^0-9-]/g, "");
|
77
|
+
if (t.value = i, t.setCustomValidity(this.customError ?? ""), !!m(t.value).ISO()) {
|
76
78
|
if (this.focusTimeoutId && clearTimeout(this.focusTimeoutId), this.$datepickerPopup.date = t.value, this.range) {
|
77
79
|
this.$datepickerPopup.selectedDateRange = {
|
78
|
-
start:
|
79
|
-
end:
|
80
|
+
start: m(this.$input.value).ISO() ? new Date(this.$input.value) : null,
|
81
|
+
end: m(this.$input_range_end.value).ISO() ? new Date(this.$input_range_end.value) : null
|
80
82
|
};
|
81
|
-
const
|
82
|
-
this.value =
|
83
|
+
const h = Object.values(this.$datepickerPopup.selectedDateRange).filter(Boolean).map((p) => new Date(p).toLocaleDateString("en-CA")).join();
|
84
|
+
this.value = h, m(this.$input.value).ISO() && (this.focusTimeoutId = setTimeout(() => {
|
83
85
|
this.$input_range_end.focus();
|
84
86
|
}, 200));
|
85
87
|
} else
|
@@ -91,9 +93,9 @@ const _ = class _ extends C {
|
|
91
93
|
}, this._toggleClearButton = (e = !1) => {
|
92
94
|
this.showClearbutton = e;
|
93
95
|
}, this.reposition = async () => {
|
94
|
-
const { x: e, y: t } = await
|
96
|
+
const { x: e, y: t } = await T(this.$anchor, this.$popover, {
|
95
97
|
placement: "bottom-start",
|
96
|
-
middleware: [
|
98
|
+
middleware: [B(), x(0)],
|
97
99
|
strategy: "fixed"
|
98
100
|
});
|
99
101
|
Object.assign(this.$popover.style, {
|
@@ -111,37 +113,34 @@ const _ = class _ extends C {
|
|
111
113
|
return this.customError;
|
112
114
|
}
|
113
115
|
connectedCallback() {
|
114
|
-
|
115
|
-
super.connectedCallback(), this._init_date = (e = this.value) == null ? void 0 : e.split(",")[0], this.addEventListener("selected-date-changed", this._handleSelectedDate);
|
116
|
+
super.connectedCallback(), this._init_date = this.value?.split(",")[0], this.addEventListener("selected-date-changed", this._handleSelectedDate);
|
116
117
|
}
|
117
118
|
disconnectedCallback() {
|
118
119
|
super.disconnectedCallback(), this.abortController.abort();
|
119
120
|
}
|
120
121
|
firstUpdated() {
|
121
|
-
|
122
|
-
this.$datepickerPopup.date = this._init_date ? w.PlainDate.from(this._init_date).toString() : w.Now.plainDateISO().toString(), this.range ? this.$datepickerPopup.selectedDateRange = {
|
122
|
+
this.$datepickerPopup.date = this._init_date ? I.PlainDate.from(this._init_date).toString() : I.Now.plainDateISO().toString(), this.range ? this.$datepickerPopup.selectedDateRange = {
|
123
123
|
start: this._init_date ? new Date(this._init_date) : null,
|
124
|
-
end:
|
124
|
+
end: this.value?.split(",")[1] ? new Date(this.value.split(",")[1]) : null
|
125
125
|
} : this.$datepickerPopup.selectedDate = this._init_date ? new Date(this._init_date) : void 0, this.hint && !this.hasAttribute("hint") && this.setAttribute("hint", this.hint), this.validateInput();
|
126
126
|
}
|
127
|
-
attributeChangedCallback(e, t,
|
128
|
-
if (super.attributeChangedCallback(e, t,
|
129
|
-
if (typeof
|
130
|
-
const
|
131
|
-
this._pristine = !1, this._internals.setValidity({ customError: !0 },
|
127
|
+
attributeChangedCallback(e, t, i) {
|
128
|
+
if (super.attributeChangedCallback(e, t, i), e === "custom-invalid")
|
129
|
+
if (typeof i == "string") {
|
130
|
+
const p = this.withFallback(i);
|
131
|
+
this._pristine = !1, this._internals.setValidity({ customError: !0 }, p), this.invalid = !0, this.hint = p, this.checkValidity();
|
132
132
|
} else
|
133
133
|
this._internals.setValidity({}), this.validateInput();
|
134
134
|
}
|
135
135
|
_handleValueChange() {
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
}, this.$input_range_end.value = v((p = this.value) == null ? void 0 : p.split(",")[1]), this.$datepickerPopup.date = ((i = this.value) == null ? void 0 : i.split(",")[0]) ?? "") : (this.$datepickerPopup.selectedDate = (a = this.value) != null && a.split(",")[0] ? new Date(this.value.split(",")[0]) : void 0, this.$datepickerPopup.date = ((o = this.value) == null ? void 0 : o.split(",")[0]) ?? ""), this.validateInput();
|
136
|
+
this.value?.trim() || this.$datepickerPopup.clearSelection(), this._internals.setFormValue(this.value ?? ""), this.validateInput(), this._pristine = !1, this.$input.value = v(this.value?.split(",")[0]), this.range ? (this.$datepickerPopup.selectedDateRange = {
|
137
|
+
start: this.value?.split(",")[0] ? new Date(this.value.split(",")[0]) : null,
|
138
|
+
end: this.value?.split(",")[1] ? new Date(this.value.split(",")[1]) : null
|
139
|
+
}, this.$input_range_end.value = v(this.value?.split(",")[1]), this.$datepickerPopup.date = this.value?.split(",")[0] ?? "") : (this.$datepickerPopup.selectedDate = this.value?.split(",")[0] ? new Date(this.value.split(",")[0]) : void 0, this.$datepickerPopup.date = this.value?.split(",")[0] ?? ""), this.validateInput();
|
141
140
|
}
|
142
141
|
showPopover() {
|
143
|
-
if (
|
144
|
-
|
142
|
+
if (Y(this.$popover)) return;
|
143
|
+
z(() => {
|
145
144
|
this.$popover.showPopover(), this._animatePopover({ show: !0 });
|
146
145
|
}, 200)(), this.addEventListener("focusout", this.hidePopover.bind(this), {
|
147
146
|
once: !0,
|
@@ -149,8 +148,7 @@ const _ = class _ extends C {
|
|
149
148
|
});
|
150
149
|
}
|
151
150
|
hidePopover() {
|
152
|
-
|
153
|
-
this.removeEventListener("focusout", this.hidePopover.bind(this)), ((t = document.activeElement) == null ? void 0 : t.closest("skf-datepicker-input")) !== this && this.$popover.hidePopover();
|
151
|
+
this.removeEventListener("focusout", this.hidePopover.bind(this)), document.activeElement?.closest("skf-datepicker-input") !== this && this.$popover.hidePopover();
|
154
152
|
}
|
155
153
|
/**
|
156
154
|
* Clears the input field
|
@@ -160,21 +158,21 @@ const _ = class _ extends C {
|
|
160
158
|
}
|
161
159
|
/** @internal */
|
162
160
|
async _animatePopover({ el: e = this.$popover, show: t }) {
|
163
|
-
return t && (e.style.opacity = "0", e.style.transform = "scaleY(0.5)"), new Promise((
|
164
|
-
const
|
161
|
+
return t && (e.style.opacity = "0", e.style.transform = "scaleY(0.5)"), new Promise((i) => {
|
162
|
+
const h = [
|
165
163
|
{ opacity: 0, transform: "scaleY(0.5)" },
|
166
164
|
{ opacity: 1, transform: "scaleY(1)" }
|
167
|
-
],
|
165
|
+
], p = t ? h : h.reverse();
|
168
166
|
setTimeout(
|
169
167
|
() => {
|
170
168
|
e.style.transformOrigin = "top";
|
171
|
-
const
|
169
|
+
const _ = this.$popover.animate(p, {
|
172
170
|
duration: 100,
|
173
171
|
easing: "linear",
|
174
172
|
fill: "both"
|
175
173
|
});
|
176
|
-
|
177
|
-
|
174
|
+
_.onfinish = () => {
|
175
|
+
i();
|
178
176
|
};
|
179
177
|
},
|
180
178
|
t ? 0 : 50
|
@@ -184,33 +182,33 @@ const _ = class _ extends C {
|
|
184
182
|
/** @internal consider sharing this functionality with input */
|
185
183
|
validateInput() {
|
186
184
|
if (this._internals.validity.customError) return;
|
187
|
-
let t = JSON.parse(JSON.stringify(this._internals.validity)),
|
185
|
+
let t = JSON.parse(JSON.stringify(this._internals.validity)), i = {};
|
188
186
|
if (this.selectableFrom) {
|
189
|
-
const { validityFragment:
|
190
|
-
t = { ...t, ...
|
187
|
+
const { validityFragment: a, errorMessageFragment: n } = h(this);
|
188
|
+
t = { ...t, ...a }, i = { ...i, ...n };
|
191
189
|
}
|
192
190
|
if (this.selectableTo) {
|
193
|
-
const { validityFragment:
|
194
|
-
t = { ...t, ...
|
191
|
+
const { validityFragment: a, errorMessageFragment: n } = p(this);
|
192
|
+
t = { ...t, ...a }, i = { ...i, ...n };
|
195
193
|
}
|
196
194
|
if (this.range) {
|
197
|
-
const { validityFragment:
|
198
|
-
t = { ...t, ...
|
195
|
+
const { validityFragment: a, errorMessageFragment: n } = _(this);
|
196
|
+
t = { ...t, ...a }, i = { ...i, ...n };
|
199
197
|
}
|
200
198
|
if (this.required) {
|
201
|
-
const { validityFragment:
|
202
|
-
t = { ...t, ...
|
199
|
+
const { validityFragment: a, errorMessageFragment: n } = M(this);
|
200
|
+
t = { ...t, ...a }, i = { ...i, ...n };
|
203
201
|
}
|
204
|
-
if (t.valid = !Object.values(t).some((
|
202
|
+
if (t.valid = !Object.values(t).some((a) => a), this.invalid = !1, t.valid)
|
205
203
|
this._internals.setValidity({ customError: this._internals.validity.customError }), this.hint = this.getAttribute("hint") ?? "";
|
206
204
|
else {
|
207
205
|
this.invalid = !this._pristine && !t.valid;
|
208
|
-
let
|
209
|
-
for (
|
210
|
-
const
|
211
|
-
if (t[
|
212
|
-
this.validationError =
|
213
|
-
const c = this.hasAttribute(
|
206
|
+
let a;
|
207
|
+
for (a in t) {
|
208
|
+
const n = `data-${a.toString()}`;
|
209
|
+
if (t[a]) {
|
210
|
+
this.validationError = a.toString();
|
211
|
+
const c = this.hasAttribute(n) ? this.getAttribute(n) : i[a];
|
214
212
|
this._internals.setValidity(
|
215
213
|
{ [this.validationError]: !0, customError: this._internals.validity.customError },
|
216
214
|
this.withFallback(c)
|
@@ -218,55 +216,54 @@ const _ = class _ extends C {
|
|
218
216
|
}
|
219
217
|
}
|
220
218
|
}
|
221
|
-
function
|
222
|
-
const
|
223
|
-
if (!
|
224
|
-
const c = new Date(
|
225
|
-
if (new Date(
|
226
|
-
const
|
219
|
+
function h(a) {
|
220
|
+
const n = { validityFragment: {}, errorMessageFragment: {} };
|
221
|
+
if (!a.selectableFrom) return n;
|
222
|
+
const c = new Date(a.selectableFrom);
|
223
|
+
if (new Date(a.$input.value) < c) {
|
224
|
+
const y = a.getAttribute("data-rangeunderflow") ?? `Date is out of range. Earliest selectable date is ${a.selectableFrom}.`;
|
227
225
|
return {
|
228
226
|
validityFragment: { rangeUnderflow: !0, valid: !1 },
|
229
|
-
errorMessageFragment: { rangeUnderflow:
|
227
|
+
errorMessageFragment: { rangeUnderflow: y }
|
230
228
|
};
|
231
229
|
}
|
232
|
-
return
|
230
|
+
return n;
|
233
231
|
}
|
234
|
-
function
|
235
|
-
const
|
236
|
-
if (!
|
237
|
-
const c = new Date(
|
238
|
-
if (new Date(
|
239
|
-
const
|
232
|
+
function p(a) {
|
233
|
+
const n = { validityFragment: {}, errorMessageFragment: {} };
|
234
|
+
if (!a.selectableTo) return n;
|
235
|
+
const c = new Date(a.selectableTo);
|
236
|
+
if (new Date(a.$input.value) > c) {
|
237
|
+
const y = a.getAttribute("data-rangeoverflow") ?? `Date is out of range. Latest selectable date is ${a.selectableTo}.`;
|
240
238
|
return {
|
241
239
|
validityFragment: { rangeOverflow: !0, valid: !1 },
|
242
|
-
errorMessageFragment: { rangeOverflow:
|
240
|
+
errorMessageFragment: { rangeOverflow: y }
|
243
241
|
};
|
244
242
|
}
|
245
|
-
return
|
243
|
+
return n;
|
246
244
|
}
|
247
|
-
function
|
248
|
-
const
|
249
|
-
if (new Date(
|
250
|
-
const
|
245
|
+
function _(a) {
|
246
|
+
const n = { validityFragment: {}, errorMessageFragment: {} }, c = new Date(a.$input.value);
|
247
|
+
if (new Date(a.$input_range_end.value) < c) {
|
248
|
+
const y = a.getAttribute("data-rangeunderflow") ?? "End date cannot be before start date";
|
251
249
|
return {
|
252
250
|
validityFragment: { rangeUnderflow: !0, valid: !1 },
|
253
|
-
errorMessageFragment: { rangeUnderflow:
|
251
|
+
errorMessageFragment: { rangeUnderflow: y }
|
254
252
|
};
|
255
253
|
}
|
256
|
-
return
|
254
|
+
return n;
|
257
255
|
}
|
258
|
-
function
|
259
|
-
const
|
260
|
-
return !
|
256
|
+
function M(a) {
|
257
|
+
const n = { validityFragment: {}, errorMessageFragment: {} };
|
258
|
+
return !a.$input.value || a.range && !a.$input_range_end.value ? {
|
261
259
|
validityFragment: { valueMissing: !0, valid: !1 },
|
262
260
|
errorMessageFragment: { valueMissing: "This field is required" }
|
263
|
-
} :
|
261
|
+
} : n;
|
264
262
|
}
|
265
263
|
}
|
266
264
|
render() {
|
267
|
-
|
268
|
-
|
269
|
-
return y`
|
265
|
+
const e = (this._defaultSlot.length === 0 || !this._defaultSlot[0]?.textContent?.trim()) && !this.label;
|
266
|
+
return b`
|
270
267
|
<div
|
271
268
|
id="root"
|
272
269
|
@mouseenter=${() => {
|
@@ -279,22 +276,22 @@ const _ = class _ extends C {
|
|
279
276
|
<label>
|
280
277
|
<div class=${this.hideLabel ? "visually-hidden" : ""} ?hidden=${e} id="label">
|
281
278
|
<slot>${this.label}</slot>
|
282
|
-
${this.required ?
|
279
|
+
${this.required ? V(D(this, g).term("required")) : f}
|
283
280
|
</div>
|
284
281
|
<div id="input">
|
285
282
|
<input
|
286
283
|
?disabled=${this.disabled}
|
287
284
|
?readonly=${this.readonly}
|
288
|
-
.value=${
|
289
|
-
this.range ? v(
|
285
|
+
.value=${O(
|
286
|
+
this.range ? v(this.value?.split(",")[0]) : v(this.value)
|
290
287
|
)}
|
291
288
|
@blur=${this._handleBlur}
|
292
289
|
@click=${this._handleFocus}
|
293
290
|
@focus=${this._handleFocus}
|
294
291
|
@input=${this._handleInput}
|
295
292
|
@keydown=${this._handleKeyboardEvents}
|
296
|
-
aria-describedby=${u(
|
297
|
-
aria-errormessage=${u(
|
293
|
+
aria-describedby=${u(this.hint?.trim() ? "hint" : f)}
|
294
|
+
aria-errormessage=${u(this.hint?.trim() ? "hint" : f)}
|
298
295
|
aria-invalid=${!!this.invalid}
|
299
296
|
autocomplete="off"
|
300
297
|
data-testid="field-input"
|
@@ -304,19 +301,19 @@ const _ = class _ extends C {
|
|
304
301
|
placeholder=${u(this.placeholder)}
|
305
302
|
type="text"
|
306
303
|
/>
|
307
|
-
${this.range ?
|
304
|
+
${this.range ? b`
|
308
305
|
<skf-icon name="arrowRight"></skf-icon>
|
309
306
|
<input
|
310
307
|
?disabled=${this.disabled}
|
311
308
|
?readonly=${this.readonly}
|
312
|
-
.value=${
|
309
|
+
.value=${O(v(this.value?.split(",")[1]))}
|
313
310
|
@blur=${this._handleBlur}
|
314
311
|
@click=${this._handleFocus}
|
315
312
|
@focus=${this._handleFocus}
|
316
313
|
@input=${this._handleInput}
|
317
314
|
@keydown=${this._handleKeyboardEvents}
|
318
|
-
aria-describedby=${u(
|
319
|
-
aria-errormessage=${u(
|
315
|
+
aria-describedby=${u(this.hint?.trim() ? "hint" : f)}
|
316
|
+
aria-errormessage=${u(this.hint?.trim() ? "hint" : f)}
|
320
317
|
aria-invalid=${!!this.invalid}
|
321
318
|
autocomplete="off"
|
322
319
|
data-testid="field-input-range-end"
|
@@ -326,28 +323,29 @@ const _ = class _ extends C {
|
|
326
323
|
placeholder=${u(this.placeholder)}
|
327
324
|
type="text"
|
328
325
|
/>
|
329
|
-
` :
|
330
|
-
${this.showClearbutton ?
|
326
|
+
` : f}
|
327
|
+
${this.showClearbutton ? b`
|
331
328
|
<button
|
329
|
+
aria-label=${D(this, g).term("close")}
|
332
330
|
class="password skf-icon-host"
|
333
331
|
type="button"
|
334
332
|
@click=${this.clear.bind(this)}
|
335
333
|
>
|
336
334
|
<skf-icon name="close" size="sm"></skf-icon>
|
337
335
|
</button>
|
338
|
-
` :
|
336
|
+
` : b`
|
339
337
|
<button class="password skf-icon-host" type="button">
|
340
338
|
<skf-icon name="calendarMonth" size="sm"></skf-icon>
|
341
339
|
</button>
|
342
340
|
`}
|
343
341
|
</div>
|
344
342
|
</label>
|
345
|
-
${this.hint &&
|
343
|
+
${this.hint && b`
|
346
344
|
<skf-hint
|
347
345
|
?disabled=${this.disabled}
|
348
346
|
aria-live=${this.invalid ? "assertive" : "polite"}
|
349
347
|
id="hint"
|
350
|
-
severity=${u(
|
348
|
+
severity=${u(L(this.invalid, this.severity))}
|
351
349
|
>${this.customInvalid ?? this.hint}
|
352
350
|
</skf-hint>
|
353
351
|
`}
|
@@ -358,6 +356,7 @@ const _ = class _ extends C {
|
|
358
356
|
?range=${this.range}
|
359
357
|
id=${this.id}
|
360
358
|
invalid-dates=${u(this.invalidDates)}
|
359
|
+
lang=${this.lang}
|
361
360
|
selectable-from=${u(this.selectableFrom)}
|
362
361
|
selectable-to=${u(this.selectableTo)}
|
363
362
|
></skf-datepicker-popup>
|
@@ -365,91 +364,91 @@ const _ = class _ extends C {
|
|
365
364
|
`;
|
366
365
|
}
|
367
366
|
};
|
368
|
-
|
369
|
-
let s =
|
367
|
+
g = new WeakMap(), w.styles = [q, W];
|
368
|
+
let s = w;
|
370
369
|
r([
|
371
|
-
|
370
|
+
d({ attribute: "custom-invalid", reflect: !0 })
|
372
371
|
], s.prototype, "customInvalid", 1);
|
373
372
|
r([
|
374
|
-
|
373
|
+
d({ type: String })
|
375
374
|
], s.prototype, "id", 2);
|
376
375
|
r([
|
377
|
-
|
376
|
+
d()
|
378
377
|
], s.prototype, "label", 2);
|
379
378
|
r([
|
380
|
-
|
379
|
+
d({ type: String })
|
380
|
+
], s.prototype, "lang", 2);
|
381
|
+
r([
|
382
|
+
d({ type: Boolean, attribute: "hide-label" })
|
381
383
|
], s.prototype, "hideLabel", 2);
|
382
384
|
r([
|
383
|
-
|
385
|
+
d()
|
384
386
|
], s.prototype, "hint", 2);
|
385
387
|
r([
|
386
|
-
|
388
|
+
d({ attribute: "invalid-dates" })
|
387
389
|
], s.prototype, "invalidDates", 2);
|
388
390
|
r([
|
389
|
-
|
391
|
+
d({ reflect: !0 })
|
390
392
|
], s.prototype, "name", 2);
|
391
393
|
r([
|
392
|
-
|
394
|
+
d()
|
393
395
|
], s.prototype, "placeholder", 2);
|
394
396
|
r([
|
395
|
-
|
397
|
+
d({ type: Boolean })
|
396
398
|
], s.prototype, "range", 2);
|
397
399
|
r([
|
398
|
-
|
400
|
+
d({ type: Boolean })
|
399
401
|
], s.prototype, "readonly", 2);
|
400
402
|
r([
|
401
|
-
|
402
|
-
], s.prototype, "requiredLabel", 2);
|
403
|
-
r([
|
404
|
-
h({ attribute: "selectable-from" })
|
403
|
+
d({ attribute: "selectable-from" })
|
405
404
|
], s.prototype, "selectableFrom", 2);
|
406
405
|
r([
|
407
|
-
|
406
|
+
d({ attribute: "selectable-to" })
|
408
407
|
], s.prototype, "selectableTo", 2);
|
409
408
|
r([
|
410
|
-
|
409
|
+
d({ reflect: !0 })
|
411
410
|
], s.prototype, "severity", 2);
|
412
411
|
r([
|
413
|
-
|
412
|
+
d({ reflect: !0 })
|
414
413
|
], s.prototype, "size", 2);
|
415
414
|
r([
|
416
|
-
|
415
|
+
d({ type: String, attribute: "validate-on" })
|
417
416
|
], s.prototype, "validateOn", 2);
|
418
417
|
r([
|
419
|
-
|
418
|
+
d()
|
420
419
|
], s.prototype, "value", 2);
|
421
420
|
r([
|
422
|
-
|
421
|
+
k()
|
423
422
|
], s.prototype, "_init_date", 2);
|
424
423
|
r([
|
425
|
-
|
424
|
+
d({ type: Boolean, reflect: !0 })
|
426
425
|
], s.prototype, "invalid", 2);
|
427
426
|
r([
|
428
|
-
|
427
|
+
k()
|
429
428
|
], s.prototype, "selectedRangeDates", 2);
|
430
429
|
r([
|
431
|
-
|
430
|
+
k()
|
432
431
|
], s.prototype, "showClearbutton", 2);
|
433
432
|
r([
|
434
|
-
|
433
|
+
$("#popover")
|
435
434
|
], s.prototype, "$popover", 2);
|
436
435
|
r([
|
437
|
-
|
436
|
+
$("#input")
|
438
437
|
], s.prototype, "$anchor", 2);
|
439
438
|
r([
|
440
|
-
|
439
|
+
$('input[data-testid="field-input"]')
|
441
440
|
], s.prototype, "$input", 2);
|
442
441
|
r([
|
443
|
-
|
442
|
+
$('input[data-testid="field-input-range-end"]')
|
444
443
|
], s.prototype, "$input_range_end", 2);
|
445
444
|
r([
|
446
|
-
|
445
|
+
$("skf-datepicker-popup")
|
447
446
|
], s.prototype, "$datepickerPopup", 2);
|
448
447
|
r([
|
449
|
-
|
448
|
+
N({ flatten: !0 })
|
450
449
|
], s.prototype, "_defaultSlot", 2);
|
451
450
|
r([
|
452
|
-
|
451
|
+
j("value", { waitUntilFirstUpdate: !0, afterUpdate: !0 })
|
453
452
|
], s.prototype, "_handleValueChange", 1);
|
454
453
|
export {
|
455
454
|
s as SkfDatepicker
|
@@ -2,6 +2,7 @@ import '../button/button.js';
|
|
2
2
|
import '../heading/heading.js';
|
3
3
|
import '../icon/icon.js';
|
4
4
|
import { SkfElement } from '../../internal/components/skf-element';
|
5
|
+
import { type Language } from '../../utilities/localize.js';
|
5
6
|
import { type CSSResultGroup } from 'lit';
|
6
7
|
/**
|
7
8
|
* 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)
|
@@ -23,12 +24,12 @@ import { type CSSResultGroup } from 'lit';
|
|
23
24
|
export declare class SkfDialog extends SkfElement {
|
24
25
|
#private;
|
25
26
|
static styles: CSSResultGroup;
|
26
|
-
/** If defined, sets the aria-label for the close button */
|
27
|
-
closeButtonAriaLabel?: string;
|
28
27
|
/** Title for the modal/dialog */
|
29
28
|
heading?: string;
|
30
29
|
/** If true, makes the dialog stretch edge to edge on screen */
|
31
30
|
fullscreen: boolean;
|
31
|
+
/** Sets the internal language of the component */
|
32
|
+
lang: Language;
|
32
33
|
/** If true, removes the close button */
|
33
34
|
noCloseButton?: boolean | undefined;
|
34
35
|
/** If defined, removes the inner padding */
|