@skf-design-system/ui-components 1.0.0-beta.7 → 1.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert/alert.component.d.ts +2 -2
- package/dist/components/alert/alert.component.js +34 -34
- package/dist/components/breadcrumb/breadcrumb.component.d.ts +29 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +8 -0
- package/dist/components/breadcrumb/breadcrumb.styles.d.ts +1 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.component.d.ts +25 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.d.ts +8 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.styles.d.ts +1 -0
- package/dist/components/button/button.component.d.ts +6 -4
- package/dist/components/button/button.component.js +87 -70
- package/dist/components/button/button.styles.js +64 -45
- package/dist/components/checkbox/checkbox.component.d.ts +3 -1
- package/dist/components/checkbox/checkbox.component.js +71 -58
- package/dist/components/date-picker/datepicker.calendar.component.d.ts +72 -0
- package/dist/components/date-picker/datepicker.calendar.component.js +382 -0
- package/dist/components/date-picker/datepicker.calendar.styles.d.ts +1 -0
- package/dist/components/date-picker/datepicker.calendar.styles.js +192 -0
- package/dist/components/date-picker/datepicker.component.d.ts +74 -0
- package/dist/components/date-picker/datepicker.component.js +241 -0
- package/dist/components/date-picker/datepicker.d.ts +10 -0
- package/dist/components/date-picker/datepicker.helpers.d.ts +40 -0
- package/dist/components/date-picker/datepicker.helpers.js +69 -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 +99 -0
- package/dist/components/date-picker-input/datepicker-input.component.d.ts +107 -0
- package/dist/components/date-picker-input/datepicker-input.component.js +397 -0
- package/dist/components/date-picker-input/datepicker-input.d.ts +8 -0
- package/dist/components/date-picker-input/datepicker-input.helpers.d.ts +4 -0
- package/dist/components/date-picker-input/datepicker-input.helpers.js +29 -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 +22 -0
- package/dist/components/dialog/dialog.component.d.ts +0 -1
- package/dist/components/dialog/dialog.component.js +2 -4
- package/dist/components/icon/icon.component.d.ts +1 -4
- package/dist/components/icon/icon.component.js +28 -19
- package/dist/components/icon/icon.styles.js +53 -47
- package/dist/components/input/input.component.d.ts +1 -0
- package/dist/components/input/input.component.js +87 -80
- package/dist/components/link/link.component.d.ts +1 -0
- package/dist/components/link/link.component.js +21 -21
- package/dist/components/menu/menu.component.d.ts +24 -0
- package/dist/components/menu/menu.component.js +18 -0
- package/dist/components/menu/menu.d.ts +8 -0
- package/dist/components/menu/menu.js +6 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +11 -0
- package/dist/components/menu-item/menu-item.component.d.ts +25 -0
- package/dist/components/menu-item/menu-item.component.js +13 -0
- package/dist/components/menu-item/menu-item.d.ts +8 -0
- package/dist/components/menu-item/menu-item.js +6 -0
- package/dist/components/menu-item/menu-item.styles.d.ts +1 -0
- package/dist/components/menu-item/menu-item.styles.js +19 -0
- package/dist/components/popover/popover.component.d.ts +29 -0
- package/dist/components/popover/popover.component.js +37 -0
- package/dist/components/popover/popover.d.ts +8 -0
- package/dist/components/popover/popover.js +6 -0
- package/dist/components/popover/popover.styles.d.ts +1 -0
- package/dist/components/popover/popover.styles.js +12 -0
- package/dist/components/select/select.component.d.ts +8 -10
- package/dist/components/select/select.component.js +115 -118
- package/dist/components/select/select.controllers.d.ts +0 -25
- package/dist/components/select/select.controllers.js +35 -95
- package/dist/components/stepper/stepper.component.d.ts +38 -0
- package/dist/components/stepper/stepper.component.js +91 -0
- package/dist/components/stepper/stepper.d.ts +8 -0
- package/dist/components/stepper/stepper.helpers.d.ts +16 -0
- package/dist/components/stepper/stepper.helpers.js +18 -0
- package/dist/components/stepper/stepper.js +6 -0
- package/dist/components/stepper/stepper.styles.d.ts +1 -0
- package/dist/components/stepper/stepper.styles.js +15 -0
- package/dist/components/stepper-item/stepper-item.component.d.ts +47 -0
- package/dist/components/stepper-item/stepper-item.component.js +113 -0
- package/dist/components/stepper-item/stepper-item.d.ts +8 -0
- package/dist/components/stepper-item/stepper-item.js +6 -0
- package/dist/components/stepper-item/stepper-item.styles.d.ts +1 -0
- package/dist/components/stepper-item/stepper-item.styles.js +98 -0
- package/dist/components/toast/toast.component.d.ts +7 -4
- package/dist/components/toast/toast.component.js +24 -20
- package/dist/components/toast/toast.singleton.d.ts +2 -7
- package/dist/components/toast/toast.singleton.js +25 -25
- package/dist/components/toast-item/toast-item.component.js +15 -15
- package/dist/components/toast-item/toast-item.styles.js +13 -11
- package/dist/components/tooltip/tooltip.component.d.ts +24 -0
- package/dist/components/tooltip/tooltip.component.js +18 -0
- package/dist/components/tooltip/tooltip.d.ts +8 -0
- package/dist/components/tooltip/tooltip.js +6 -0
- package/dist/components/tooltip/tooltip.styles.d.ts +1 -0
- package/dist/components/tooltip/tooltip.styles.js +12 -0
- package/dist/custom-elements.json +3278 -1321
- package/dist/index.d.ts +8 -0
- package/dist/index.js +78 -54
- package/dist/internal/base-classes/popover/popover.base.d.ts +29 -0
- package/dist/internal/base-classes/popover/popover.base.js +116 -0
- package/dist/internal/base-classes/popover/popover.styles.d.ts +1 -0
- package/dist/internal/base-classes/popover/popover.styles.js +29 -0
- package/dist/internal/controllers/popover.controller.d.ts +17 -0
- package/dist/internal/controllers/popover.controller.js +44 -0
- package/dist/internal/helpers/dateFormatter.d.ts +2 -0
- package/dist/internal/helpers/hintSeverity.d.ts +1 -1
- package/dist/internal/helpers/utilityTypes.d.ts +22 -0
- package/dist/react/index.d.ts +11 -2
- package/dist/react/index.js +11 -2
- package/dist/react/skf-breadcrumb/index.d.ts +9 -0
- package/dist/react/skf-breadcrumb/index.js +17 -0
- package/dist/react/skf-breadcrumb-item/index.d.ts +3 -0
- package/dist/react/skf-breadcrumb-item/index.js +13 -0
- package/dist/react/skf-datepicker/index.d.ts +12 -0
- package/dist/react/skf-datepicker/index.js +18 -0
- package/dist/react/skf-menu/index.d.ts +12 -0
- package/dist/react/skf-menu/index.js +18 -0
- package/dist/react/skf-menu-item/index.d.ts +27 -0
- package/dist/react/skf-menu-item/index.js +23 -0
- package/dist/react/skf-popover/index.d.ts +12 -0
- package/dist/react/skf-popover/index.js +18 -0
- package/dist/react/skf-stepper/index.d.ts +9 -0
- package/dist/react/skf-stepper/index.js +17 -0
- package/dist/react/skf-stepper-item/index.d.ts +9 -0
- package/dist/react/skf-stepper-item/index.js +17 -0
- package/dist/react/skf-tooltip/index.d.ts +12 -0
- package/dist/react/skf-tooltip/index.js +18 -0
- package/dist/types/jsx/custom-element-jsx.d.ts +628 -155
- package/dist/types/vue/index.d.ts +369 -74
- package/dist/vscode.html-custom-data.json +761 -391
- package/dist/web-types.json +936 -293
- package/package.json +34 -33
@@ -0,0 +1,99 @@
|
|
1
|
+
import { css as o } from "lit";
|
2
|
+
const e = o`
|
3
|
+
@layer components {
|
4
|
+
:host {
|
5
|
+
--black: #323232;
|
6
|
+
--call-to-action-color: #007bff;
|
7
|
+
--selected-bg: var(--call-to-action-color); /* hsl(218deg 87% 45%); */
|
8
|
+
--selected-fg: #fff;
|
9
|
+
--in-range-bg: #def;
|
10
|
+
--today: #eee;
|
11
|
+
--today-fg: var(--black);
|
12
|
+
--title-fg: var(--black);
|
13
|
+
--other-month-fg: #999;
|
14
|
+
--hover-bg: #def;
|
15
|
+
--border-color: #ddd;
|
16
|
+
--button-control-fg: #333;
|
17
|
+
--button-control-fg-hover: var(--call-to-action-color);
|
18
|
+
--weekday-fg: var(--black);
|
19
|
+
--calendar-padding: 16px;
|
20
|
+
--max-width: 21em;
|
21
|
+
--day-outline: transparent;
|
22
|
+
|
23
|
+
background-color: #fff;
|
24
|
+
border: solid 1px gray;
|
25
|
+
border-radius: 3px;
|
26
|
+
box-shadow: 0 0 10px rgba(0 0 0 / 30%);
|
27
|
+
box-sizing: border-box;
|
28
|
+
display: block;
|
29
|
+
font-family: Helvetica, sans-serif;
|
30
|
+
font-size: 0.7rem;
|
31
|
+
max-width: var(--max-width);
|
32
|
+
position: relative;
|
33
|
+
}
|
34
|
+
|
35
|
+
.triangle {
|
36
|
+
border: 10px solid transparent;
|
37
|
+
border-bottom-color: #fff;
|
38
|
+
border-top: 0;
|
39
|
+
display: block;
|
40
|
+
height: 0;
|
41
|
+
left: 50%;
|
42
|
+
margin-left: -10px;
|
43
|
+
position: absolute;
|
44
|
+
top: -10px;
|
45
|
+
width: 0;
|
46
|
+
}
|
47
|
+
|
48
|
+
:host([hidden]) {
|
49
|
+
display: none !important;
|
50
|
+
}
|
51
|
+
|
52
|
+
.calendar-container {
|
53
|
+
display: flex;
|
54
|
+
flex-direction: row;
|
55
|
+
gap: var(--calendar-padding);
|
56
|
+
justify-content: space-between;
|
57
|
+
overflow: hidden;
|
58
|
+
padding: var(--calendar-padding);
|
59
|
+
}
|
60
|
+
|
61
|
+
.today {
|
62
|
+
border-top: 1px solid var(--border-color);
|
63
|
+
margin-bottom: 0.5rem;
|
64
|
+
margin-top: -1rem;
|
65
|
+
padding-top: 0.5rem;
|
66
|
+
text-align: center;
|
67
|
+
|
68
|
+
button {
|
69
|
+
background-color: #333;
|
70
|
+
border-radius: 4px;
|
71
|
+
color: white;
|
72
|
+
padding-inline: 0.7em;
|
73
|
+
transition: background-color 0.2s;
|
74
|
+
|
75
|
+
&[disabled] {
|
76
|
+
opacity: 0.5;
|
77
|
+
pointer-events: none;
|
78
|
+
}
|
79
|
+
|
80
|
+
&:hover {
|
81
|
+
background-color: var(--call-to-action-color);
|
82
|
+
}
|
83
|
+
|
84
|
+
&:active {
|
85
|
+
background-color: lch(from var(--call-to-action-color) calc(l - 5) c h);
|
86
|
+
}
|
87
|
+
|
88
|
+
&:focus-visible {
|
89
|
+
border-radius: 0.2em;
|
90
|
+
outline: 2px solid #469;
|
91
|
+
outline-offset: 2px;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
`;
|
97
|
+
export {
|
98
|
+
e as styles
|
99
|
+
};
|
@@ -0,0 +1,107 @@
|
|
1
|
+
import { FormBase } from '../../internal/components/formBase.js';
|
2
|
+
import { PopoverController } from '../../internal/controllers/popover.controller.js';
|
3
|
+
import type { FormFieldBaseProps } from '../../internal/types/formField.js';
|
4
|
+
import { type CSSResultGroup } from 'lit';
|
5
|
+
import '../date-picker/datepicker.js';
|
6
|
+
import type { SkfDatePicker, SkfDatePickerDateRange } from '../date-picker/datepicker.js';
|
7
|
+
export declare class SkfDatePickerInput extends FormBase {
|
8
|
+
/** @internal */
|
9
|
+
static styles: CSSResultGroup;
|
10
|
+
/** @inernal */
|
11
|
+
focusTomeoutId: ReturnType<typeof setTimeout> | undefined;
|
12
|
+
/** @internal */
|
13
|
+
private customError;
|
14
|
+
/** @internal */
|
15
|
+
popoverController: PopoverController;
|
16
|
+
/** If defined, forces component to invalid state until removed. Its value is used as hint text. */
|
17
|
+
set customInvalid(value: string | undefined);
|
18
|
+
get customInvalid(): string | undefined;
|
19
|
+
id: string;
|
20
|
+
/** If defined, sets the input's label. Alternatively, you can use the `label` attribute. */
|
21
|
+
label?: string;
|
22
|
+
/** If true, hides the label visually */
|
23
|
+
hideLabel?: boolean;
|
24
|
+
/** If defined, displays informational text below the field */
|
25
|
+
hint?: string;
|
26
|
+
/**
|
27
|
+
* A comma-separated list of dates (yyyy-mm-dd format) that are not selectable.
|
28
|
+
*/
|
29
|
+
invalidDates?: string;
|
30
|
+
/** If defined, adds name to the input-element */
|
31
|
+
name?: string;
|
32
|
+
placeholder: string;
|
33
|
+
range: boolean;
|
34
|
+
/** If true, makes the element not mutable, meaning the user can not edit the control */
|
35
|
+
readonly?: boolean;
|
36
|
+
/** If defined, renders an alternative A11y text for the asterisk */
|
37
|
+
requiredLabel?: string;
|
38
|
+
/**
|
39
|
+
* Earliest selectable date. (yyyy-mm-dd format)
|
40
|
+
*/
|
41
|
+
selectableFrom?: string;
|
42
|
+
/**
|
43
|
+
* Latest selectable date. (yyyy-mm-dd format)
|
44
|
+
*/
|
45
|
+
selectableTo?: string;
|
46
|
+
/**
|
47
|
+
* If defined, displays provided severity state
|
48
|
+
* @type { "alert" | "success" | "info" | "warning" }
|
49
|
+
*/
|
50
|
+
severity?: FormFieldBaseProps['severity'];
|
51
|
+
/** Sets validation start */
|
52
|
+
validateOn: 'input' | 'change' | 'submit';
|
53
|
+
/** The current value of the input field */
|
54
|
+
value?: string;
|
55
|
+
private _init_date?;
|
56
|
+
/** @internal */
|
57
|
+
/** true if the internal state is invalid */
|
58
|
+
invalid: boolean;
|
59
|
+
/** @internal */
|
60
|
+
selectedRangeDates: SkfDatePickerDateRange;
|
61
|
+
/** @internal */
|
62
|
+
private showClearbutton;
|
63
|
+
/** @internal */
|
64
|
+
$popover: HTMLElement;
|
65
|
+
/** @internal */
|
66
|
+
$anchor: HTMLDivElement;
|
67
|
+
/** @internal */
|
68
|
+
$input: HTMLInputElement;
|
69
|
+
/** @internal */
|
70
|
+
$input_range_end: HTMLInputElement;
|
71
|
+
/** @internal */
|
72
|
+
$datepicker: SkfDatePicker;
|
73
|
+
/** @internal */
|
74
|
+
_defaultSlot: Node[];
|
75
|
+
constructor();
|
76
|
+
connectedCallback(): void;
|
77
|
+
_handleSelectedDate: (e: CustomEvent<{
|
78
|
+
date: Date;
|
79
|
+
id: number;
|
80
|
+
}>) => void;
|
81
|
+
protected firstUpdated(): void;
|
82
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
83
|
+
private _handleDateSelected;
|
84
|
+
private _handleFocus;
|
85
|
+
/** @internal */
|
86
|
+
_handleBlur: (event: FocusEvent) => void;
|
87
|
+
/** @internal */
|
88
|
+
private _handleClose;
|
89
|
+
/** @internal */
|
90
|
+
private clearInput;
|
91
|
+
_handleValueChange(): void;
|
92
|
+
/**
|
93
|
+
* Clears the input field
|
94
|
+
*/
|
95
|
+
clear: () => void;
|
96
|
+
/** @internal although called on input its only triggered once value is valid date */
|
97
|
+
_handleInput: (event: Event) => void;
|
98
|
+
/** @internal */
|
99
|
+
_toggleClearButton: (show?: boolean) => void;
|
100
|
+
/** @internal */
|
101
|
+
private _animatePopover;
|
102
|
+
/** @internal consider sharing this functionality with input */
|
103
|
+
validateInput(): void;
|
104
|
+
/** @internal */
|
105
|
+
reposition: () => Promise<void>;
|
106
|
+
render(): import("lit").TemplateResult<1>;
|
107
|
+
}
|
@@ -0,0 +1,397 @@
|
|
1
|
+
import { dateFormatter as v, isPopoverOpen as S, debounce as E, isDate as $ } from "./datepicker-input.helpers.js";
|
2
|
+
import { computePosition as C, flip as I, offset as M } from "@floating-ui/dom";
|
3
|
+
import { FormBase as O } from "../../internal/components/formBase.js";
|
4
|
+
import { PopoverController as T } from "../../internal/controllers/popover.controller.js";
|
5
|
+
import { hintSeverity as B } from "../../internal/helpers/hintSeverity.js";
|
6
|
+
import { watch as P } from "../../internal/helpers/watch.js";
|
7
|
+
import { Asterisk as x } from "../../internal/templates/asterisk.js";
|
8
|
+
import { Temporal as F } from "@js-temporal/polyfill";
|
9
|
+
import q from "../../styles/component.styles.js";
|
10
|
+
import { html as m, nothing as g } from "lit";
|
11
|
+
import { property as d, state as b, query as y, queryAssignedNodes as R } from "lit/decorators.js";
|
12
|
+
import { ifDefined as u } from "lit/directives/if-defined.js";
|
13
|
+
import { live as k } from "lit/directives/live.js";
|
14
|
+
import "../date-picker/datepicker.js";
|
15
|
+
import { styles as j } from "./datepicker-input.styles.js";
|
16
|
+
var L = Object.defineProperty, V = Object.getOwnPropertyDescriptor, n = (D, t, e, a) => {
|
17
|
+
for (var l = a > 1 ? void 0 : a ? V(t, e) : t, o = D.length - 1, h; o >= 0; o--)
|
18
|
+
(h = D[o]) && (l = (a ? h(t, e, l) : h(l)) || l);
|
19
|
+
return a && l && L(t, e, l), l;
|
20
|
+
};
|
21
|
+
const _ = class _ extends O {
|
22
|
+
constructor() {
|
23
|
+
super(), this.popoverController = new T(this), this.id = "skf-datepicker-input", this.placeholder = "Select date", this.range = !1, this.validateOn = "change", this.invalid = !1, this.selectedRangeDates = { start: null, end: null }, this.showClearbutton = !1, this._handleSelectedDate = (t) => {
|
24
|
+
console.log("selected-date-changed event fired", this.value || "no value", t.detail), this.pristine = !1, this._internals.setFormValue(this.value ?? ""), this.validateInput();
|
25
|
+
}, this._handleDateSelected = (t) => {
|
26
|
+
if (this.range && "start" in t.detail.date && "end" in t.detail.date) {
|
27
|
+
const e = t.detail.date.start, a = t.detail.date.end;
|
28
|
+
this.value = `${v(e)},${v(a)}`, this.selectedRangeDates = { start: e, end: a };
|
29
|
+
} else !this.range && t.detail.date instanceof Date && (this.value = v(t.detail.date), this._animatePopover({ el: this.$popover, show: !1 }).then(() => {
|
30
|
+
this.$popover.hidePopover();
|
31
|
+
}));
|
32
|
+
}, this._handleFocus = () => {
|
33
|
+
if (S(this.$popover)) return;
|
34
|
+
E(() => {
|
35
|
+
this.$popover.showPopover(), this._animatePopover({ show: !0 });
|
36
|
+
}, 200)();
|
37
|
+
}, this._handleBlur = (t) => {
|
38
|
+
const e = t.target;
|
39
|
+
if (!e.name.endsWith("-end") && !this.range) return;
|
40
|
+
if ($(e.value) && this.$datepicker.emit("selected-date-changed", {
|
41
|
+
detail: { date: new Date(e.value) }
|
42
|
+
}), e.name.endsWith("-end") || !this.range) {
|
43
|
+
const l = t.relatedTarget;
|
44
|
+
a(this, l);
|
45
|
+
}
|
46
|
+
function a(l, o) {
|
47
|
+
var h, c;
|
48
|
+
if (o && !l.contains(o)) {
|
49
|
+
console.log("Tab out detected");
|
50
|
+
const r = (h = l.$popover.childNodes[1].shadowRoot) == null ? void 0 : h.querySelector("skf-datepicker-calendar"), p = (c = r == null ? void 0 : r.shadowRoot) == null ? void 0 : c.querySelector("button");
|
51
|
+
p == null || p.focus();
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}, this._handleClose = () => {
|
55
|
+
this.$anchor.blur();
|
56
|
+
}, this.clearInput = () => {
|
57
|
+
this.value = "", this.$datepicker.clearSelection();
|
58
|
+
}, this.clear = () => {
|
59
|
+
this.clearInput(), this._toggleClearButton(!1);
|
60
|
+
}, this._handleInput = (t) => {
|
61
|
+
const e = t.target;
|
62
|
+
e.setCustomValidity(this.customError ?? ""), this.focusTomeoutId && clearTimeout(this.focusTomeoutId), this.$datepicker.date = e.value, this.range ? (this.$datepicker.selectedDateRange = {
|
63
|
+
start: $(this.$input.value) ? new Date(this.$input.value) : null,
|
64
|
+
end: $(this.$input_range_end.value) ? new Date(this.$input_range_end.value) : null
|
65
|
+
}, $(this.$input.value) && (this.focusTomeoutId = setTimeout(() => {
|
66
|
+
this.$input_range_end.focus();
|
67
|
+
}, 2e3))) : this.$datepicker.selectedDate = new Date(e.value), this.validateOn === "input" && (this._pristine = !1, this.validateInput());
|
68
|
+
}, this._toggleClearButton = (t = !1) => {
|
69
|
+
this.showClearbutton = t;
|
70
|
+
}, this.reposition = async () => {
|
71
|
+
const { x: t, y: e } = await C(this.$anchor, this.$popover, {
|
72
|
+
placement: "bottom-start",
|
73
|
+
middleware: [I(), M(0)],
|
74
|
+
strategy: "fixed"
|
75
|
+
});
|
76
|
+
Object.assign(this.$popover.style, {
|
77
|
+
left: `${String(t)}px`,
|
78
|
+
top: `${String(e)}px`
|
79
|
+
});
|
80
|
+
}, this.addEventListener("skf-datepicker-selected", this._handleDateSelected), this.addEventListener("reset", () => {
|
81
|
+
this.clearInput(), this.validateInput();
|
82
|
+
});
|
83
|
+
}
|
84
|
+
set customInvalid(t) {
|
85
|
+
this.customError = t || "";
|
86
|
+
}
|
87
|
+
get customInvalid() {
|
88
|
+
return this.customError;
|
89
|
+
}
|
90
|
+
connectedCallback() {
|
91
|
+
var t;
|
92
|
+
super.connectedCallback(), this._init_date = (t = this.value) == null ? void 0 : t.split(",")[0], this.addEventListener("selected-date-changed", this._handleSelectedDate);
|
93
|
+
}
|
94
|
+
firstUpdated() {
|
95
|
+
var t;
|
96
|
+
this.$datepicker.date = this._init_date ? F.PlainDate.from(this._init_date).toString() : F.Now.plainDateISO().toString(), this.range ? this.$datepicker.selectedDateRange = {
|
97
|
+
start: this._init_date ? new Date(this._init_date) : null,
|
98
|
+
end: (t = this.value) != null && t.split(",")[1] ? new Date(this.value.split(",")[1]) : null
|
99
|
+
} : this.$datepicker.selectedDate = this._init_date ? new Date(this._init_date) : void 0, this.validateInput();
|
100
|
+
}
|
101
|
+
attributeChangedCallback(t, e, a) {
|
102
|
+
if (super.attributeChangedCallback(t, e, a), t === "custom-invalid")
|
103
|
+
if (typeof a == "string") {
|
104
|
+
const o = this.withFallback(a);
|
105
|
+
this._pristine = !1, this._internals.setValidity({ customError: !0 }, o), this.invalid = !0, this.hint = o, this.checkValidity();
|
106
|
+
} else
|
107
|
+
this._internals.setValidity({}), this.validateInput();
|
108
|
+
}
|
109
|
+
_handleValueChange() {
|
110
|
+
var t, e, a, l, o, h, c, i;
|
111
|
+
(t = this.value) != null && t.trim() || this.$datepicker.clearSelection(), this._internals.setFormValue(this.value ?? ""), this.validateInput(), this._pristine = !1, this.$input.value = v((e = this.value) == null ? void 0 : e.split(",")[0]), this.range ? (this.$datepicker.selectedDateRange = {
|
112
|
+
start: (o = this.value) != null && o.split(",")[0] ? new Date(this.value.split(",")[0]) : null,
|
113
|
+
end: (h = this.value) != null && h.split(",")[1] ? new Date(this.value.split(",")[1]) : null
|
114
|
+
}, this.$input_range_end.value = v((c = this.value) == null ? void 0 : c.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();
|
115
|
+
}
|
116
|
+
/** @internal */
|
117
|
+
async _animatePopover({ el: t = this.$popover, show: e }) {
|
118
|
+
return e && (t.style.opacity = "0", t.style.transform = "scaleY(0.5)"), new Promise((a) => {
|
119
|
+
const l = [
|
120
|
+
{ opacity: 0, transform: "scaleY(0.5)" },
|
121
|
+
{ opacity: 1, transform: "scaleY(1)" }
|
122
|
+
], o = e ? l : l.reverse();
|
123
|
+
setTimeout(
|
124
|
+
() => {
|
125
|
+
t.style.transformOrigin = "top";
|
126
|
+
const h = this.$popover.animate(o, {
|
127
|
+
duration: 100,
|
128
|
+
easing: "linear",
|
129
|
+
fill: "both"
|
130
|
+
});
|
131
|
+
h.onfinish = () => {
|
132
|
+
a();
|
133
|
+
};
|
134
|
+
},
|
135
|
+
e ? 0 : 50
|
136
|
+
);
|
137
|
+
});
|
138
|
+
}
|
139
|
+
/** @internal consider sharing this functionality with input */
|
140
|
+
validateInput() {
|
141
|
+
if (this._internals.validity.customError) return;
|
142
|
+
let e = JSON.parse(JSON.stringify(this._internals.validity)), a = {};
|
143
|
+
if (this.selectableFrom) {
|
144
|
+
const { validityFragment: i, errorMessageFragment: r } = l(this);
|
145
|
+
e = { ...e, ...i }, a = { ...a, ...r };
|
146
|
+
}
|
147
|
+
if (this.selectableTo) {
|
148
|
+
const { validityFragment: i, errorMessageFragment: r } = o(this);
|
149
|
+
e = { ...e, ...i }, a = { ...a, ...r };
|
150
|
+
}
|
151
|
+
if (this.range) {
|
152
|
+
const { validityFragment: i, errorMessageFragment: r } = h(this);
|
153
|
+
e = { ...e, ...i }, a = { ...a, ...r };
|
154
|
+
}
|
155
|
+
if (this.required) {
|
156
|
+
const { validityFragment: i, errorMessageFragment: r } = c(this);
|
157
|
+
e = { ...e, ...i }, a = { ...a, ...r };
|
158
|
+
}
|
159
|
+
if (e.valid = !Object.values(e).some((i) => i), this.invalid = !1, e.valid)
|
160
|
+
this._internals.setValidity({ customError: this._internals.validity.customError });
|
161
|
+
else {
|
162
|
+
this.invalid = !this._pristine && !e.valid;
|
163
|
+
let i;
|
164
|
+
for (i in e) {
|
165
|
+
const r = `data-${i.toString()}`;
|
166
|
+
if (e[i]) {
|
167
|
+
this.validationError = i.toString();
|
168
|
+
const p = this.hasAttribute(r) ? this.getAttribute(r) : a[i];
|
169
|
+
this._internals.setValidity(
|
170
|
+
{ [this.validationError]: !0, customError: this._internals.validity.customError },
|
171
|
+
this.withFallback(p)
|
172
|
+
), this.invalid && this.customErrorDisplay && this.checkValidity();
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
function l(i) {
|
177
|
+
const r = { validityFragment: {}, errorMessageFragment: {} };
|
178
|
+
if (!i.selectableFrom) return r;
|
179
|
+
const p = new Date(i.selectableFrom);
|
180
|
+
if (new Date(i.$input.value) < p) {
|
181
|
+
const f = i.getAttribute("data-rangeunderflow") ?? "Date is out of range";
|
182
|
+
return {
|
183
|
+
validityFragment: { rangeUnderflow: !0, valid: !1 },
|
184
|
+
errorMessageFragment: { rangeUnderflow: f }
|
185
|
+
};
|
186
|
+
}
|
187
|
+
return r;
|
188
|
+
}
|
189
|
+
function o(i) {
|
190
|
+
const r = { validityFragment: {}, errorMessageFragment: {} };
|
191
|
+
if (!i.selectableTo) return r;
|
192
|
+
const p = new Date(i.selectableTo);
|
193
|
+
if (new Date(i.$input.value) > p) {
|
194
|
+
const f = i.getAttribute("data-rangeoverflow") ?? "Date is out of range";
|
195
|
+
return {
|
196
|
+
validityFragment: { rangeOverflow: !0, valid: !1 },
|
197
|
+
errorMessageFragment: { rangeOverflow: f }
|
198
|
+
};
|
199
|
+
}
|
200
|
+
return r;
|
201
|
+
}
|
202
|
+
function h(i) {
|
203
|
+
const r = { validityFragment: {}, errorMessageFragment: {} }, p = new Date(i.$input.value);
|
204
|
+
if (new Date(i.$input_range_end.value) < p) {
|
205
|
+
const f = i.getAttribute("data-rangeunderflow") ?? "Date is out of range";
|
206
|
+
return {
|
207
|
+
validityFragment: { rangeUnderflow: !0, valid: !1 },
|
208
|
+
errorMessageFragment: { rangeUnderflow: f }
|
209
|
+
};
|
210
|
+
}
|
211
|
+
return r;
|
212
|
+
}
|
213
|
+
function c(i) {
|
214
|
+
const r = { validityFragment: {}, errorMessageFragment: {} };
|
215
|
+
return !i.$input.value || i.range && !i.$input_range_end.value ? {
|
216
|
+
validityFragment: { valueMissing: !0, valid: !1 },
|
217
|
+
errorMessageFragment: { valueMissing: "This field is required" }
|
218
|
+
} : r;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
render() {
|
222
|
+
var e, a, l, o, h, c, i, r;
|
223
|
+
const t = (this._defaultSlot.length === 0 || !((a = (e = this._defaultSlot[0]) == null ? void 0 : e.textContent) != null && a.trim())) && !this.label;
|
224
|
+
return m`
|
225
|
+
<div
|
226
|
+
id="root"
|
227
|
+
@mouseenter=${() => {
|
228
|
+
this.value && this._toggleClearButton(!0);
|
229
|
+
}}
|
230
|
+
@mouseleave=${() => {
|
231
|
+
this._toggleClearButton(!1);
|
232
|
+
}}
|
233
|
+
>
|
234
|
+
<label>
|
235
|
+
<div class=${this.hideLabel ? "visually-hidden" : ""} ?hidden=${t} id="label">
|
236
|
+
<slot>${this.label}</slot>
|
237
|
+
${this.required ? x(this.requiredLabel) : null}
|
238
|
+
</div>
|
239
|
+
<div id="input">
|
240
|
+
<div id="affix">
|
241
|
+
<input
|
242
|
+
?disabled=${this.disabled}
|
243
|
+
?readonly=${this.readonly}
|
244
|
+
.value=${k(
|
245
|
+
this.range ? v((l = this.value) == null ? void 0 : l.split(",")[0]) : v(this.value)
|
246
|
+
)}
|
247
|
+
@blur=${this._handleBlur}
|
248
|
+
@click=${this._handleFocus}
|
249
|
+
@focus=${this._handleFocus}
|
250
|
+
@input=${this._handleInput}
|
251
|
+
aria-describedby=${u((o = this.hint) != null && o.trim() ? "hint" : g)}
|
252
|
+
aria-errormessage=${u((h = this.hint) != null && h.trim() ? "hint" : g)}
|
253
|
+
aria-invalid=${!!this.invalid}
|
254
|
+
autocomplete="off"
|
255
|
+
data-testid="field-input"
|
256
|
+
inputmode=${u(this.inputMode)}
|
257
|
+
name=${u(this.name)}
|
258
|
+
placeholder=${u(this.placeholder)}
|
259
|
+
type="date"
|
260
|
+
/>
|
261
|
+
</div>
|
262
|
+
${this.range ? m`<div style="align-content:center">→</div>
|
263
|
+
<input
|
264
|
+
?disabled=${this.disabled}
|
265
|
+
?readonly=${this.readonly}
|
266
|
+
.value=${k(v((c = this.value) == null ? void 0 : c.split(",")[1]))}
|
267
|
+
@blur=${this._handleBlur}
|
268
|
+
@click=${this._handleFocus}
|
269
|
+
@focus=${this._handleFocus}
|
270
|
+
@input=${this._handleInput}
|
271
|
+
aria-describedby=${u((i = this.hint) != null && i.trim() ? "hint" : g)}
|
272
|
+
aria-errormessage=${u((r = this.hint) != null && r.trim() ? "hint" : g)}
|
273
|
+
aria-invalid=${!!this.invalid}
|
274
|
+
autocomplete="off"
|
275
|
+
data-testid="field-input-range-end"
|
276
|
+
inputmode=${u(this.inputMode)}
|
277
|
+
name=${u(String(this.name) + "-end")}
|
278
|
+
placeholder=${u(this.placeholder)}
|
279
|
+
type="date"
|
280
|
+
/>` : g}
|
281
|
+
${this.showClearbutton ? m`<button class="password skf-icon-host" type="button" @click=${this.clear}>
|
282
|
+
<skf-icon name="close" size="sm"></skf-icon>
|
283
|
+
</button>` : m`
|
284
|
+
<button class="password skf-icon-host" type="button">
|
285
|
+
<skf-icon name="calendarMonth" size="sm"></skf-icon>
|
286
|
+
</button>
|
287
|
+
`}
|
288
|
+
</div>
|
289
|
+
</label>
|
290
|
+
${this.hint && m`
|
291
|
+
<skf-hint
|
292
|
+
aria-live=${this.invalid ? "assertive" : "polite"}
|
293
|
+
id="hint"
|
294
|
+
severity=${u(B(this.severity, this.invalid))}
|
295
|
+
>${this.customInvalid ? this.customInvalid : this.hint}
|
296
|
+
</skf-hint>
|
297
|
+
`}
|
298
|
+
</div>
|
299
|
+
|
300
|
+
<div id="popover" popover @close=${this._handleClose}>
|
301
|
+
<skf-datepicker
|
302
|
+
?range=${this.range}
|
303
|
+
id=${this.id}
|
304
|
+
invalid-dates=${u(this.invalidDates)}
|
305
|
+
selectable-from=${u(this.selectableFrom)}
|
306
|
+
selectable-to=${u(this.selectableTo)}
|
307
|
+
></skf-datepicker>
|
308
|
+
</div>
|
309
|
+
`;
|
310
|
+
}
|
311
|
+
};
|
312
|
+
_.styles = [q, j];
|
313
|
+
let s = _;
|
314
|
+
n([
|
315
|
+
d({ attribute: "custom-invalid", reflect: !0 })
|
316
|
+
], s.prototype, "customInvalid", 1);
|
317
|
+
n([
|
318
|
+
d({ type: String })
|
319
|
+
], s.prototype, "id", 2);
|
320
|
+
n([
|
321
|
+
d()
|
322
|
+
], s.prototype, "label", 2);
|
323
|
+
n([
|
324
|
+
d({ type: Boolean, attribute: "hide-label" })
|
325
|
+
], s.prototype, "hideLabel", 2);
|
326
|
+
n([
|
327
|
+
d()
|
328
|
+
], s.prototype, "hint", 2);
|
329
|
+
n([
|
330
|
+
d({ attribute: "invalid-dates" })
|
331
|
+
], s.prototype, "invalidDates", 2);
|
332
|
+
n([
|
333
|
+
d({ reflect: !0 })
|
334
|
+
], s.prototype, "name", 2);
|
335
|
+
n([
|
336
|
+
d()
|
337
|
+
], s.prototype, "placeholder", 2);
|
338
|
+
n([
|
339
|
+
d({ type: Boolean })
|
340
|
+
], s.prototype, "range", 2);
|
341
|
+
n([
|
342
|
+
d({ type: Boolean })
|
343
|
+
], s.prototype, "readonly", 2);
|
344
|
+
n([
|
345
|
+
d({ attribute: "required-label" })
|
346
|
+
], s.prototype, "requiredLabel", 2);
|
347
|
+
n([
|
348
|
+
d({ attribute: "selectable-from" })
|
349
|
+
], s.prototype, "selectableFrom", 2);
|
350
|
+
n([
|
351
|
+
d({ attribute: "selectable-to" })
|
352
|
+
], s.prototype, "selectableTo", 2);
|
353
|
+
n([
|
354
|
+
d({ reflect: !0 })
|
355
|
+
], s.prototype, "severity", 2);
|
356
|
+
n([
|
357
|
+
d({ type: String, attribute: "validate-on" })
|
358
|
+
], s.prototype, "validateOn", 2);
|
359
|
+
n([
|
360
|
+
d()
|
361
|
+
], s.prototype, "value", 2);
|
362
|
+
n([
|
363
|
+
b()
|
364
|
+
], s.prototype, "_init_date", 2);
|
365
|
+
n([
|
366
|
+
d({ type: Boolean, reflect: !0 })
|
367
|
+
], s.prototype, "invalid", 2);
|
368
|
+
n([
|
369
|
+
b()
|
370
|
+
], s.prototype, "selectedRangeDates", 2);
|
371
|
+
n([
|
372
|
+
b()
|
373
|
+
], s.prototype, "showClearbutton", 2);
|
374
|
+
n([
|
375
|
+
y("#popover")
|
376
|
+
], s.prototype, "$popover", 2);
|
377
|
+
n([
|
378
|
+
y("#input")
|
379
|
+
], s.prototype, "$anchor", 2);
|
380
|
+
n([
|
381
|
+
y('input[data-testid="field-input"]')
|
382
|
+
], s.prototype, "$input", 2);
|
383
|
+
n([
|
384
|
+
y('input[data-testid="field-input-range-end"]')
|
385
|
+
], s.prototype, "$input_range_end", 2);
|
386
|
+
n([
|
387
|
+
y("skf-datepicker")
|
388
|
+
], s.prototype, "$datepicker", 2);
|
389
|
+
n([
|
390
|
+
R({ flatten: !0 })
|
391
|
+
], s.prototype, "_defaultSlot", 2);
|
392
|
+
n([
|
393
|
+
P("value", { waitUntilFirstUpdate: !0, afterUpdate: !0 })
|
394
|
+
], s.prototype, "_handleValueChange", 1);
|
395
|
+
export {
|
396
|
+
s as SkfDatePickerInput
|
397
|
+
};
|
@@ -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,4 @@
|
|
1
|
+
export declare function dateFormatter(date?: string | Date | null, locale?: string): string;
|
2
|
+
export declare function isPopoverOpen(element: HTMLElement): boolean;
|
3
|
+
export declare function debounce<T extends (...args: unknown[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
|
4
|
+
export declare const isDate: (date?: Date | string | null) => boolean;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
function r(e, n = "en-CA") {
|
2
|
+
return e ? (typeof e == "string" && (e = new Date(e)), e.toLocaleDateString(n)) : "";
|
3
|
+
}
|
4
|
+
function i(e) {
|
5
|
+
return console.dir("element", e), e.matches(":popover-open");
|
6
|
+
}
|
7
|
+
let o = null;
|
8
|
+
function c(e, n) {
|
9
|
+
return (...t) => {
|
10
|
+
console.log("Debounced function called"), o && (clearTimeout(o), console.log("Existing timer cleared")), o = setTimeout(() => {
|
11
|
+
console.log("Function executed after delay"), e(...t);
|
12
|
+
}, n);
|
13
|
+
};
|
14
|
+
}
|
15
|
+
const l = (e) => {
|
16
|
+
if (!e) return !1;
|
17
|
+
if (typeof e != "string")
|
18
|
+
return e instanceof Date && !isNaN(e.valueOf());
|
19
|
+
{
|
20
|
+
const n = new Date(e);
|
21
|
+
return !isNaN(n);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
export {
|
25
|
+
r as dateFormatter,
|
26
|
+
c as debounce,
|
27
|
+
l as isDate,
|
28
|
+
i as isPopoverOpen
|
29
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult[];
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import o from "../../styles/form-field.styles.js";
|
2
|
+
import { visuallyHidden as e } from "../../styles/util.styles.js";
|
3
|
+
import { css as r } from "lit";
|
4
|
+
const l = [
|
5
|
+
e,
|
6
|
+
o,
|
7
|
+
r`
|
8
|
+
@layer components {
|
9
|
+
#popover {
|
10
|
+
border: none;
|
11
|
+
overflow: visible;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
input::-webkit-calendar-picker-indicator {
|
16
|
+
display: none;
|
17
|
+
}
|
18
|
+
`
|
19
|
+
];
|
20
|
+
export {
|
21
|
+
l as styles
|
22
|
+
};
|
@@ -16,7 +16,6 @@ import { type CSSResultGroup } from 'lit';
|
|
16
16
|
* @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
|
17
17
|
*
|
18
18
|
* @slot - The dialog component's content
|
19
|
-
* @slot heading - The dialog component's heading
|
20
19
|
* @slot footer - The dialog component's buttons goes here
|
21
20
|
*
|
22
21
|
* @event skf-dialog-open - Fires when the dialog is opened (after transitioned in)
|