@skf-design-system/ui-components 1.0.2-beta.1 → 1.0.2-beta.3
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 +7 -1
- package/dist/components/accordion/accordion-item.component.js +49 -38
- package/dist/components/accordion/accordion.component.d.ts +1 -1
- package/dist/components/accordion/accordion.component.js +10 -10
- package/dist/components/breadcrumb/breadcrumb-item.d.ts +2 -2
- package/dist/components/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/components/card/card.component.js +3 -3
- package/dist/components/card/card.styles.js +29 -13
- package/dist/components/{date-picker/datepicker.calendar.component.d.ts → datepicker/datepicker-calendar.component.d.ts} +4 -1
- package/dist/components/{date-picker/datepicker.calendar.component.js → datepicker/datepicker-calendar.component.js} +7 -7
- package/dist/components/datepicker/datepicker-calendar.d.ts +8 -0
- package/dist/components/datepicker/datepicker-calendar.js +6 -0
- package/dist/components/{date-picker/datepicker.component.d.ts → datepicker/datepicker-popup.component.d.ts} +5 -20
- package/dist/components/{date-picker/datepicker.component.js → datepicker/datepicker-popup.component.js} +12 -12
- package/dist/components/datepicker/datepicker-popup.d.ts +8 -0
- package/dist/components/{date-picker/datepicker.helpers.d.ts → datepicker/datepicker-popup.helpers.d.ts} +3 -3
- package/dist/components/datepicker/datepicker-popup.helpers.js +83 -0
- package/dist/components/datepicker/datepicker-popup.js +6 -0
- package/dist/components/{date-picker/datepicker.styles.js → datepicker/datepicker-popup.styles.js} +3 -3
- package/dist/components/{date-picker-input/datepicker-input.component.d.ts → datepicker/datepicker.component.d.ts} +17 -12
- package/dist/components/{date-picker-input/datepicker-input.component.js → datepicker/datepicker.component.js} +110 -97
- package/dist/components/datepicker/datepicker.d.ts +8 -0
- package/dist/components/datepicker/datepicker.js +6 -0
- package/dist/components/dialog/dialog.component.js +1 -1
- package/dist/components/dialog/dialog.d.ts +2 -2
- package/dist/components/drawer/drawer.d.ts +2 -2
- package/dist/components/header/header.d.ts +2 -2
- package/dist/components/heading/heading.component.js +36 -22
- package/dist/components/input/input.component.js +26 -26
- package/dist/components/menu/menu-item.d.ts +2 -2
- package/dist/components/menu/menu.d.ts +2 -2
- package/dist/components/nav/nav-item.component.d.ts +2 -2
- package/dist/components/nav/nav.d.ts +2 -2
- package/dist/components/popover/popover.component.js +1 -1
- package/dist/components/popover/popover.d.ts +2 -2
- package/dist/components/progress/progress.d.ts +2 -2
- package/dist/components/progress/progress.styles.js +8 -6
- package/dist/components/segmented-button/segmented-button-item.d.ts +2 -2
- package/dist/components/segmented-button/segmented-button.d.ts +2 -2
- package/dist/components/select/select-option-group.d.ts +2 -2
- package/dist/components/select/select-option.component.d.ts +2 -2
- package/dist/components/select/select-option.component.js +1 -1
- package/dist/components/select/select.component.d.ts +2 -2
- package/dist/components/select/select.component.js +2 -2
- package/dist/components/select/select.controllers.js +11 -14
- package/dist/components/stepper/stepper-item.component.js +47 -47
- package/dist/components/stepper/stepper-item.d.ts +2 -2
- package/dist/components/stepper/stepper.d.ts +2 -2
- package/dist/components/switch/switch.d.ts +2 -2
- package/dist/components/{tab-panel → tabs}/tab-panel.d.ts +2 -2
- package/dist/components/{tab → tabs}/tab.component.d.ts +2 -2
- package/dist/components/{tab → tabs}/tab.d.ts +2 -2
- package/dist/components/{tab-group/tab-group.component.d.ts → tabs/tabs.component.d.ts} +3 -4
- package/dist/components/{tab-group/tab-group.component.js → tabs/tabs.component.js} +35 -36
- package/dist/components/tabs/tabs.d.ts +8 -0
- package/dist/components/tabs/tabs.js +6 -0
- package/dist/components/{tab-group/tab-group.styles.js → tabs/tabs.styles.js} +16 -16
- package/dist/components/tag/tag.component.d.ts +1 -1
- package/dist/components/tag/tag.component.js +23 -40
- package/dist/components/tag/tag.d.ts +2 -2
- package/dist/components/tag/tag.styles.js +63 -50
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/custom-elements.json +60 -93
- package/dist/index.d.ts +6 -5
- package/dist/index.js +96 -93
- package/dist/internal/base-classes/popover/popover.base.js +1 -1
- package/dist/internal/components/skf-element.d.ts +1 -3
- package/dist/internal/components/skf-element.js +4 -9
- package/dist/styles/global-alt.css +1 -0
- package/dist/styles/global.css +1 -1
- package/dist/types/jsx/custom-element-jsx.d.ts +78 -39
- package/dist/types/vue/index.d.ts +78 -39
- package/dist/vscode.html-custom-data.json +97 -11
- package/dist/web-types.json +196 -45
- package/package.json +9 -15
- package/dist/components/accordion/accordion-item.test.d.ts +0 -1
- package/dist/components/accordion/accordion.test.d.ts +0 -1
- package/dist/components/checkbox/checkbox.test.d.ts +0 -1
- package/dist/components/date-picker/datepicker.d.ts +0 -10
- package/dist/components/date-picker/datepicker.helpers.js +0 -76
- package/dist/components/date-picker/datepicker.js +0 -8
- package/dist/components/date-picker-input/datepicker-input.d.ts +0 -8
- package/dist/components/date-picker-input/datepicker-input.js +0 -6
- package/dist/components/input/input.test.d.ts +0 -1
- package/dist/components/radio/radio.test.d.ts +0 -1
- package/dist/components/switch/switch.test.d.ts +0 -1
- package/dist/components/tab-group/tab-group.d.ts +0 -8
- package/dist/components/tab-group/tab-group.js +0 -6
- package/dist/internal/playwright/index.d.ts +0 -1
- /package/dist/components/{date-picker/datepicker.calendar.styles.d.ts → datepicker/datepicker-calendar.styles.d.ts} +0 -0
- /package/dist/components/{date-picker/datepicker.calendar.styles.js → datepicker/datepicker-calendar.styles.js} +0 -0
- /package/dist/components/{date-picker/datepicker.styles.d.ts → datepicker/datepicker-popup.styles.d.ts} +0 -0
- /package/dist/components/{date-picker-input/datepicker-input.helpers.d.ts → datepicker/datepicker.helpers.d.ts} +0 -0
- /package/dist/components/{date-picker-input/datepicker-input.helpers.js → datepicker/datepicker.helpers.js} +0 -0
- /package/dist/components/{date-picker-input/datepicker-input.styles.d.ts → datepicker/datepicker.styles.d.ts} +0 -0
- /package/dist/components/{date-picker-input/datepicker-input.styles.js → datepicker/datepicker.styles.js} +0 -0
- /package/dist/components/select/{select.stories.icons.d.ts → stories/select.stories.icons.d.ts} +0 -0
- /package/dist/components/{tab-panel → tabs}/tab-panel.component.d.ts +0 -0
- /package/dist/components/{tab-panel → tabs}/tab-panel.component.js +0 -0
- /package/dist/components/{tab-panel → tabs}/tab-panel.js +0 -0
- /package/dist/components/{tab-panel → tabs}/tab-panel.styles.d.ts +0 -0
- /package/dist/components/{tab-panel → tabs}/tab-panel.styles.js +0 -0
- /package/dist/components/{tab → tabs}/tab.component.js +0 -0
- /package/dist/components/{tab → tabs}/tab.js +0 -0
- /package/dist/components/{tab → tabs}/tab.styles.d.ts +0 -0
- /package/dist/components/{tab → tabs}/tab.styles.js +0 -0
- /package/dist/components/{tab-group/tab-group.styles.d.ts → tabs/tabs.styles.d.ts} +0 -0
package/README.md
CHANGED
@@ -87,10 +87,16 @@ How you get started using our components is of course a bit different depending
|
|
87
87
|
|
88
88
|
In order for our components to work as intended you need to import our global styles where appropiate e.g. App.tsx.
|
89
89
|
|
90
|
-
```
|
90
|
+
```ts
|
91
91
|
import '@skf-design-system/ui-components/styles/global.css';
|
92
92
|
```
|
93
93
|
|
94
|
+
If you want to handle the loading of the SKF fonts yourself, you can use the alternative global css file:
|
95
|
+
|
96
|
+
```ts
|
97
|
+
import '@skf-design-system/ui-components/styles/global-alt.css';
|
98
|
+
```
|
99
|
+
|
94
100
|
### Angular
|
95
101
|
|
96
102
|
In order for our components to get the correct styling you need add our global styling to your project. In angular you can do that in the angular.json like this:
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import "../icon/icon.js";
|
2
|
-
import { SkfElement as
|
3
|
-
import { componentStyles as
|
4
|
-
import { property as
|
5
|
-
import { classMap as
|
6
|
-
import { ifDefined as
|
7
|
-
import { literal as
|
2
|
+
import { SkfElement as p } from "../../internal/components/skf-element.js";
|
3
|
+
import { componentStyles as m } from "../../styles/component.styles.js";
|
4
|
+
import { property as i } from "lit/decorators.js";
|
5
|
+
import { classMap as h } from "lit/directives/class-map.js";
|
6
|
+
import { ifDefined as u } from "lit/directives/if-defined.js";
|
7
|
+
import { literal as r, html as f } from "lit/static-html.js";
|
8
8
|
import { styles as _ } from "./accordion-item.styles.js";
|
9
|
-
var
|
10
|
-
for (var
|
11
|
-
(
|
12
|
-
return
|
9
|
+
var g = Object.defineProperty, s = (d, e, c, y) => {
|
10
|
+
for (var a = void 0, o = d.length - 1, l; o >= 0; o--)
|
11
|
+
(l = d[o]) && (a = l(e, c, a) || a);
|
12
|
+
return a && g(e, c, a), a;
|
13
13
|
};
|
14
|
-
const n = class n extends
|
14
|
+
const n = class n extends p {
|
15
15
|
constructor() {
|
16
16
|
super(...arguments), this.animated = !1, this.expanded = !1, this.headingAs = "h2", this.small = !1, this.truncate = !1, this._toggle = () => {
|
17
17
|
this.dispatchEvent(
|
@@ -32,27 +32,38 @@ const n = class n extends l {
|
|
32
32
|
this.expanded = !0;
|
33
33
|
}
|
34
34
|
render() {
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
let e;
|
36
|
+
switch (!0) {
|
37
|
+
case this.headingAs === "h3":
|
38
|
+
e = r`h3`;
|
39
|
+
break;
|
40
|
+
case this.headingAs === "h4":
|
41
|
+
e = r`h4`;
|
42
|
+
break;
|
43
|
+
default:
|
44
|
+
e = r`h2`;
|
45
|
+
break;
|
46
|
+
}
|
47
|
+
return f`
|
48
|
+
<div class=${h({
|
38
49
|
"accordion-item": !0,
|
39
50
|
"accordion-item--animated": this.animated,
|
40
51
|
"accordion-item--expanded": this.expanded,
|
41
52
|
"accordion-item--small": this.small,
|
42
53
|
"accordion-item--truncate": this.truncate
|
43
54
|
})}>
|
44
|
-
<${
|
55
|
+
<${e} class="accordion-item__heading">
|
45
56
|
<button
|
46
57
|
@click=${this._toggle}
|
47
58
|
aria-controls="main"
|
48
|
-
aria-expanded=${
|
59
|
+
aria-expanded=${u(this.expanded ? "true" : "false")}
|
49
60
|
class="accordion-item__btn"
|
50
61
|
type="button"
|
51
62
|
>
|
52
63
|
<span class="accordion-item__label">${this.heading}</span>
|
53
64
|
<skf-icon class="accordion-item__icon" name=${this.expanded ? "caretUp" : "caretDown"}></skf-icon>
|
54
65
|
</button>
|
55
|
-
</${
|
66
|
+
</${e}>
|
56
67
|
<div class="accordion-item__body">
|
57
68
|
<div class="accordion-item__main" data-testid="main" id="main">
|
58
69
|
<slot></slot>
|
@@ -62,26 +73,26 @@ const n = class n extends l {
|
|
62
73
|
`;
|
63
74
|
}
|
64
75
|
};
|
65
|
-
n.styles = [
|
66
|
-
let
|
67
|
-
|
68
|
-
|
69
|
-
],
|
70
|
-
|
71
|
-
|
72
|
-
],
|
73
|
-
|
74
|
-
|
75
|
-
],
|
76
|
-
|
77
|
-
|
78
|
-
],
|
79
|
-
|
80
|
-
|
81
|
-
],
|
82
|
-
|
83
|
-
|
84
|
-
],
|
76
|
+
n.styles = [m, _];
|
77
|
+
let t = n;
|
78
|
+
s([
|
79
|
+
i({ type: Boolean, reflect: !0 })
|
80
|
+
], t.prototype, "animated");
|
81
|
+
s([
|
82
|
+
i({ type: Boolean, reflect: !0 })
|
83
|
+
], t.prototype, "expanded");
|
84
|
+
s([
|
85
|
+
i()
|
86
|
+
], t.prototype, "heading");
|
87
|
+
s([
|
88
|
+
i({ attribute: "heading-as" })
|
89
|
+
], t.prototype, "headingAs");
|
90
|
+
s([
|
91
|
+
i({ type: Boolean, reflect: !0 })
|
92
|
+
], t.prototype, "small");
|
93
|
+
s([
|
94
|
+
i({ type: Boolean, reflect: !0 })
|
95
|
+
], t.prototype, "truncate");
|
85
96
|
export {
|
86
|
-
|
97
|
+
t as SkfAccordionItem
|
87
98
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { SkfElement } from '../../internal/components/skf-element.js';
|
2
2
|
import { type CSSResultGroup, type PropertyValues } from 'lit';
|
3
|
-
import type { SkfAccordionItemHeadingType } from './accordion-item.js';
|
3
|
+
import type { SkfAccordionItemHeadingType } from './accordion-item.component.js';
|
4
4
|
/**
|
5
5
|
* The `<skf-accordion>` component consists of one or more `<skf-accordion-item>` item(s) working together
|
6
6
|
*
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { SkfElement as p } from "../../internal/components/skf-element.js";
|
2
|
-
import { componentStyles as
|
3
|
-
import { html as
|
2
|
+
import { componentStyles as m } from "../../styles/component.styles.js";
|
3
|
+
import { html as f } from "lit";
|
4
4
|
import { property as a, queryAssignedNodes as d } from "lit/decorators.js";
|
5
5
|
import { classMap as c } from "lit/directives/class-map.js";
|
6
6
|
import { styles as g } from "./accordion.styles.js";
|
7
|
-
var y = Object.defineProperty, s = (u, t, i,
|
8
|
-
for (var r = void 0,
|
9
|
-
(h = u[
|
7
|
+
var y = Object.defineProperty, s = (u, t, i, o) => {
|
8
|
+
for (var r = void 0, l = u.length - 1, h; l >= 0; l--)
|
9
|
+
(h = u[l]) && (r = h(t, i, r) || r);
|
10
10
|
return r && y(t, i, r), r;
|
11
11
|
};
|
12
12
|
const n = class n extends p {
|
@@ -27,15 +27,15 @@ const n = class n extends p {
|
|
27
27
|
_onChildToggle(t) {
|
28
28
|
if (this.multiple || t.defaultPrevented) return;
|
29
29
|
const i = t.target;
|
30
|
-
this.items.length && this.items.forEach((
|
31
|
-
|
30
|
+
this.items.length && this.items.forEach((o) => {
|
31
|
+
o !== i && o.hasAttribute("expanded") && o.setClose();
|
32
32
|
});
|
33
33
|
}
|
34
34
|
render() {
|
35
|
-
return
|
35
|
+
return f`
|
36
36
|
<div class=${c({ "accordion--gap": this.gap })}>
|
37
37
|
<slot
|
38
|
-
@skf-
|
38
|
+
@skf-accordion-item-toggle=${(t) => {
|
39
39
|
this._onChildToggle(t);
|
40
40
|
}}
|
41
41
|
@slotchange=${this._setItemAttributes}
|
@@ -44,7 +44,7 @@ const n = class n extends p {
|
|
44
44
|
`;
|
45
45
|
}
|
46
46
|
};
|
47
|
-
n.styles = [g,
|
47
|
+
n.styles = [g, m];
|
48
48
|
let e = n;
|
49
49
|
s([
|
50
50
|
a({ type: Boolean, reflect: !0 })
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { SkfBreadcrumbItem } from './breadcrumb-item.component';
|
2
|
-
export * from './breadcrumb-item.component';
|
1
|
+
import { SkfBreadcrumbItem } from './breadcrumb-item.component.js';
|
2
|
+
export * from './breadcrumb-item.component.js';
|
3
3
|
export default SkfBreadcrumbItem;
|
4
4
|
declare global {
|
5
5
|
interface HTMLElementTagNameMap {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { SkfBreadcrumb } from './breadcrumb.component';
|
2
|
-
export * from './breadcrumb.component';
|
1
|
+
import { SkfBreadcrumb } from './breadcrumb.component.js';
|
2
|
+
export * from './breadcrumb.component.js';
|
3
3
|
export default SkfBreadcrumb;
|
4
4
|
declare global {
|
5
5
|
interface HTMLElementTagNameMap {
|
@@ -13,16 +13,16 @@ const n = class n extends f {
|
|
13
13
|
super(...arguments), this.noBorder = !1, this.noPadding = !1, this.stretch = !1;
|
14
14
|
}
|
15
15
|
render() {
|
16
|
-
return d`<slot></slot>`;
|
16
|
+
return d`<slot id="root"></slot>`;
|
17
17
|
}
|
18
18
|
};
|
19
19
|
n.styles = [m, u];
|
20
20
|
let e = n;
|
21
21
|
s([
|
22
|
-
o({ type: Boolean, attribute: "no-border"
|
22
|
+
o({ type: Boolean, reflect: !0, attribute: "no-border" })
|
23
23
|
], e.prototype, "noBorder");
|
24
24
|
s([
|
25
|
-
o({ type: Boolean, attribute: "no-padding"
|
25
|
+
o({ type: Boolean, reflect: !0, attribute: "no-padding" })
|
26
26
|
], e.prototype, "noPadding");
|
27
27
|
s([
|
28
28
|
o({ type: Boolean, reflect: !0 })
|
@@ -1,33 +1,49 @@
|
|
1
1
|
import { css as r } from "lit";
|
2
|
-
const
|
2
|
+
const a = r`
|
3
3
|
@layer components {
|
4
4
|
@layer base {
|
5
5
|
:host {
|
6
|
+
contain: layout;
|
7
|
+
}
|
8
|
+
|
9
|
+
#root {
|
10
|
+
--_skf-card-border-color: var(--skf-border-color-tertiary);
|
11
|
+
--_skf-card-padding: var(--skf-spacing-100);
|
12
|
+
--_skf-card-shadow: var(--skf-shadow-md);
|
13
|
+
|
6
14
|
background-color: var(--skf-bg-color-neutral-1);
|
7
|
-
border: var(--skf-border-width-sm) solid
|
8
|
-
var(--_skf-card-border-color, var(--skf-border-color-tertiary));
|
15
|
+
border: var(--skf-border-width-sm) solid var(--_skf-card-border-color);
|
9
16
|
border-radius: var(--skf-border-radius-sm);
|
10
|
-
box-shadow: var(--
|
11
|
-
|
12
|
-
padding: var(--_skf-card-padding
|
17
|
+
box-shadow: var(--_skf-card-shadow);
|
18
|
+
display: block;
|
19
|
+
padding: var(--_skf-card-padding);
|
13
20
|
}
|
14
21
|
}
|
15
22
|
|
16
23
|
@layer mods {
|
17
|
-
:host([stretch]) {
|
18
|
-
block-size: 100%;
|
19
|
-
}
|
20
|
-
|
21
24
|
:host([no-border]) {
|
22
|
-
|
25
|
+
#root {
|
26
|
+
--_skf-card-border-color: transparent;
|
27
|
+
--_skf-card-shadow: none;
|
28
|
+
}
|
23
29
|
}
|
24
30
|
|
25
31
|
:host([no-padding]) {
|
26
|
-
|
32
|
+
#root {
|
33
|
+
--_skf-card-padding: 0;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
:host([stretch]) {
|
38
|
+
block-size: 100%;
|
39
|
+
|
40
|
+
#root {
|
41
|
+
block-size: inherit;
|
42
|
+
}
|
27
43
|
}
|
28
44
|
}
|
29
45
|
}
|
30
46
|
`;
|
31
47
|
export {
|
32
|
-
|
48
|
+
a as styles
|
33
49
|
};
|
@@ -6,7 +6,10 @@ interface DateParts {
|
|
6
6
|
month?: number;
|
7
7
|
day?: number;
|
8
8
|
}
|
9
|
-
|
9
|
+
/**
|
10
|
+
* @tagname skf-datepicker-calendar
|
11
|
+
*/
|
12
|
+
export declare class SkfDatepickerCalendar extends SkfElement {
|
10
13
|
static styles: CSSResultGroup;
|
11
14
|
/** @internal */
|
12
15
|
_secondCalendarOffset: number;
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { dateFormatter as y } from "../date-picker-input/datepicker-input.helpers.js";
|
2
|
-
import { compareDates as $ } from "./datepicker.helpers.js";
|
3
1
|
import { SkfElement as O } from "../../internal/components/skf-element.js";
|
4
2
|
import { watch as R } from "../../internal/helpers/watch.js";
|
5
3
|
import { Temporal as m } from "@js-temporal/polyfill";
|
@@ -7,11 +5,13 @@ import { componentStyles as C } from "../../styles/component.styles.js";
|
|
7
5
|
import { html as p } from "lit";
|
8
6
|
import { property as g, state as M } from "lit/decorators.js";
|
9
7
|
import { repeat as w } from "lit/directives/repeat.js";
|
10
|
-
import { styles as F } from "./datepicker
|
11
|
-
|
12
|
-
|
8
|
+
import { styles as F } from "./datepicker-calendar.styles.js";
|
9
|
+
import { compareDates as $ } from "./datepicker-popup.helpers.js";
|
10
|
+
import { dateFormatter as y } from "./datepicker.helpers.js";
|
11
|
+
var P = Object.defineProperty, A = Object.getOwnPropertyDescriptor, d = (D, t, e, a) => {
|
12
|
+
for (var s = a > 1 ? void 0 : a ? A(t, e) : t, i = D.length - 1, h; i >= 0; i--)
|
13
13
|
(h = D[i]) && (s = (a ? h(t, e, s) : h(s)) || s);
|
14
|
-
return a && s &&
|
14
|
+
return a && s && P(t, e, s), s;
|
15
15
|
};
|
16
16
|
const E = class E extends O {
|
17
17
|
constructor() {
|
@@ -411,5 +411,5 @@ d([
|
|
411
411
|
R("date")
|
412
412
|
], o.prototype, "handleDateChange", 1);
|
413
413
|
export {
|
414
|
-
o as
|
414
|
+
o as SkfDatepickerCalendar
|
415
415
|
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { SkfDatepickerCalendar } from './datepicker-calendar.component.js';
|
2
|
+
export * from './datepicker-calendar.component.js';
|
3
|
+
export default SkfDatepickerCalendar;
|
4
|
+
declare global {
|
5
|
+
interface HTMLElementTagNameMap {
|
6
|
+
'skf-datepicker-calendar': SkfDatepickerCalendar;
|
7
|
+
}
|
8
|
+
}
|
@@ -1,27 +1,12 @@
|
|
1
|
-
import '../button/button';
|
1
|
+
import '../button/button.js';
|
2
2
|
import { SkfElement } from '../../internal/components/skf-element.js';
|
3
3
|
import { type CSSResultGroup } from 'lit';
|
4
|
-
import './datepicker';
|
5
|
-
export interface
|
4
|
+
import './datepicker-calendar.js';
|
5
|
+
export interface SkfDatepickerPopupDateRange {
|
6
6
|
start: Date | null;
|
7
7
|
end: Date | null;
|
8
8
|
}
|
9
|
-
|
10
|
-
* A date picker component that allows users to select a date or a range of dates.
|
11
|
-
*
|
12
|
-
* @element skf-datepicker
|
13
|
-
* @fires selected-date-changed - When a date is selected
|
14
|
-
* @fires selected-date-range-changed - When a range of dates is selected
|
15
|
-
*
|
16
|
-
* @prop {string} date - The date to display in the date picker
|
17
|
-
* @prop {boolean} range - If true, the date picker will allow the selection of a range of dates
|
18
|
-
* @prop {string} locale - The locale to use for formatting the date
|
19
|
-
*
|
20
|
-
* @slot - Default hint content placed inside the date picker
|
21
|
-
*
|
22
|
-
* @cssprop --max-width - The maximum width of the date picker
|
23
|
-
*/
|
24
|
-
export declare class SkfDatePicker extends SkfElement {
|
9
|
+
export declare class SkfDatepickerPopup extends SkfElement {
|
25
10
|
static styles: CSSResultGroup;
|
26
11
|
locale: string;
|
27
12
|
date: string;
|
@@ -40,7 +25,7 @@ export declare class SkfDatePicker extends SkfElement {
|
|
40
25
|
* Latest selectable date. (yyyy-mm-dd format)
|
41
26
|
*/
|
42
27
|
selectableTo?: string;
|
43
|
-
selectedDateRange:
|
28
|
+
selectedDateRange: SkfDatepickerPopupDateRange;
|
44
29
|
/** @internal */
|
45
30
|
private _date?;
|
46
31
|
/** @internal */
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import "../button/button.js";
|
2
|
-
import {
|
3
|
-
import { SkfElement as R } from "../../internal/components/skf-element.js";
|
2
|
+
import { SkfElement as v } from "../../internal/components/skf-element.js";
|
4
3
|
import { watch as p } from "../../internal/helpers/watch.js";
|
5
|
-
import { componentStyles as
|
4
|
+
import { componentStyles as R } from "../../styles/component.styles.js";
|
6
5
|
import { html as D } from "lit";
|
7
6
|
import { property as o, state as m } from "lit/decorators.js";
|
8
|
-
import "./datepicker.js";
|
9
|
-
import { getDateParts as g, assertISODate as
|
10
|
-
import { styles as
|
7
|
+
import "./datepicker-calendar.js";
|
8
|
+
import { getDateParts as g, assertISODate as S, earliestDate as $, latestDate as T, compareDates as c, doAnimate as b } from "./datepicker-popup.helpers.js";
|
9
|
+
import { styles as C } from "./datepicker-popup.styles.js";
|
10
|
+
import { dateFormatter as l, is as k } from "./datepicker.helpers.js";
|
11
11
|
var F = Object.defineProperty, E = Object.getOwnPropertyDescriptor, n = (w, e, t, a) => {
|
12
12
|
for (var s = a > 1 ? void 0 : a ? E(e, t) : e, r = w.length - 1, d; r >= 0; r--)
|
13
13
|
(d = w[r]) && (s = (a ? d(e, t, s) : d(s)) || s);
|
14
14
|
return a && s && F(e, t, s), s;
|
15
15
|
};
|
16
|
-
const y = class y extends
|
16
|
+
const y = class y extends v {
|
17
17
|
constructor() {
|
18
18
|
super(...arguments), this.locale = "en-CA", this.date = (/* @__PURE__ */ new Date()).toLocaleDateString(this.locale), this.id = "", this.range = !1, this.selectedDate = void 0, this.selectedDateRange = {
|
19
19
|
start: null,
|
@@ -96,8 +96,8 @@ const y = class y extends R {
|
|
96
96
|
this.style.setProperty("--max-width", this.range ? "43em" : "21em");
|
97
97
|
}
|
98
98
|
_handleDateChange() {
|
99
|
-
console.log("%cdate changed", "color:red", this.date), this.date = this.date &&
|
100
|
-
|
99
|
+
console.log("%cdate changed", "color:red", this.date), this.date = this.date && S(this.date) ? this.date : l(/* @__PURE__ */ new Date()), this.date = $(
|
100
|
+
T(this.date, this.selectableFrom ?? this.date),
|
101
101
|
this.selectableTo ?? this.date
|
102
102
|
), this._date = new Date(this.date), this._datePlusOneMonth = new Date(this._date.getFullYear(), this._date.getMonth() + 1, 1);
|
103
103
|
}
|
@@ -113,7 +113,7 @@ const y = class y extends R {
|
|
113
113
|
gotoDate(e) {
|
114
114
|
if (e instanceof Date)
|
115
115
|
this.date = l(e);
|
116
|
-
else if (
|
116
|
+
else if (k(e).dateISO())
|
117
117
|
this.date = e;
|
118
118
|
else
|
119
119
|
throw new Error("Invalid date format");
|
@@ -209,7 +209,7 @@ const y = class y extends R {
|
|
209
209
|
)) : Promise.resolve();
|
210
210
|
}
|
211
211
|
};
|
212
|
-
y.styles = [
|
212
|
+
y.styles = [R, C];
|
213
213
|
let i = y;
|
214
214
|
n([
|
215
215
|
o({ reflect: !0 })
|
@@ -257,5 +257,5 @@ n([
|
|
257
257
|
p("selectedDate")
|
258
258
|
], i.prototype, "_handleSelectedDateChange", 1);
|
259
259
|
export {
|
260
|
-
i as
|
260
|
+
i as SkfDatepickerPopup
|
261
261
|
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { SkfDatepickerPopup } from './datepicker-popup.component.js';
|
2
|
+
export * from './datepicker-popup.component.js';
|
3
|
+
export default SkfDatepickerPopup;
|
4
|
+
declare global {
|
5
|
+
interface HTMLElementTagNameMap {
|
6
|
+
'skf-datepicker-popup': SkfDatepickerPopup;
|
7
|
+
}
|
8
|
+
}
|
@@ -22,12 +22,12 @@ export declare function getDateParts(date?: undefined | string | Date | Temporal
|
|
22
22
|
*/
|
23
23
|
export declare function compareDates(dateOne: Temporal.PlainDate | string, dateTwo: Temporal.PlainDate | string, granularity?: 'days' | 'months' | 'years'): 0 | 1 | -1;
|
24
24
|
/**
|
25
|
-
* @param dateOne - first date to compare as string
|
26
|
-
* @param dateTwo - second date to compare as string
|
25
|
+
* @param dateOne - first date to compare as string (accepts Date and Temporal.PlainDate too)
|
26
|
+
* @param dateTwo - second date to compare as string (accepts Date and Temporal.PlainDate too)
|
27
27
|
* @param unit - the unit to compare the dates by [days, months, years]
|
28
28
|
* @returns the difference between the two dates in the specified unit
|
29
29
|
*/
|
30
|
-
export declare function timeBetween(dateOne: Temporal.PlainDate | string, dateTwo: Temporal.PlainDate | string, unit?: 'days' | 'months' | 'years'): number;
|
30
|
+
export declare function timeBetween(dateOne: Temporal.PlainDate | Date | string, dateTwo: Temporal.PlainDate | Date | string, unit?: 'days' | 'months' | 'years'): number;
|
31
31
|
/**
|
32
32
|
* @param dates - a list of dates to compare
|
33
33
|
* @returns - the earliest date of the list
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { Temporal as a } from "@js-temporal/polyfill";
|
2
|
+
import { is as c } from "./datepicker.helpers.js";
|
3
|
+
function I(t, n, i) {
|
4
|
+
const s = (o) => Array.isArray(o) ? o : [o], r = s(t);
|
5
|
+
n = s(n);
|
6
|
+
const l = [];
|
7
|
+
for (const o of r) {
|
8
|
+
const { promise: e, resolve: m, reject: p } = Promise.withResolvers(), f = o.animate(n, {
|
9
|
+
fill: "forwards",
|
10
|
+
duration: 300,
|
11
|
+
iterations: 1,
|
12
|
+
...i
|
13
|
+
});
|
14
|
+
f.onfinish = () => m("finished"), f.oncancel = () => p("canceled"), l.push(e);
|
15
|
+
}
|
16
|
+
return Promise.allSettled(l);
|
17
|
+
}
|
18
|
+
function P(t = a.Now.plainDateISO()) {
|
19
|
+
return t ?? (t = a.Now.plainDateISO()), t instanceof Date && (t = a.PlainDate.from(t.toISOString())), typeof t == "string" && (t = a.PlainDate.from(g(t, !0))), {
|
20
|
+
year: t.year,
|
21
|
+
month: t.month - 1,
|
22
|
+
// new Date is 0 based
|
23
|
+
day: t.day
|
24
|
+
};
|
25
|
+
}
|
26
|
+
function v(t, n, i = "days") {
|
27
|
+
console.assert(c(t, n).plainISO(), "Invalid dates passed to compareDates()"), typeof t == "string" && (t = a.PlainDate.from(t)), typeof n == "string" && (n = a.PlainDate.from(n)), console.assert(
|
28
|
+
c(t, n).plain(),
|
29
|
+
`Invalid date was sent to helper function compareDates(). Got ${JSON.stringify(t)} and ${JSON.stringify(n)} passed in`
|
30
|
+
);
|
31
|
+
const s = u(t, n, i);
|
32
|
+
return r(s);
|
33
|
+
function r(l) {
|
34
|
+
return Math.max(-1, Math.min(l, 1));
|
35
|
+
}
|
36
|
+
}
|
37
|
+
function u(t, n, i = "days") {
|
38
|
+
if (t = s(t), n = s(n), console.assert(
|
39
|
+
t instanceof a.PlainDate && n instanceof a.PlainDate,
|
40
|
+
`Invalid date was sent to helper function timeBetween(). Got ${JSON.stringify(t)} and ${JSON.stringify(n)} passed in`
|
41
|
+
), i === "months")
|
42
|
+
return n.until(t, { largestUnit: "months" }).months;
|
43
|
+
if (i === "years")
|
44
|
+
return n.until(t, { largestUnit: "years" }).years;
|
45
|
+
return n.until(t, { largestUnit: "days" }).days;
|
46
|
+
function s(r) {
|
47
|
+
return r instanceof Date ? a.PlainDate.from(r.toISOString().split("T")[0]) : typeof r == "string" ? a.PlainDate.from(r.includes("T") ? r.split("T")[0] : r) : r;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
function D(...t) {
|
51
|
+
if (t.length === 0)
|
52
|
+
throw new Error("At least one date must be provided");
|
53
|
+
const n = (e) => e instanceof Date, i = t.map((e) => n(e) ? e : new Date(e));
|
54
|
+
if (i.length === 1)
|
55
|
+
return i[0].toISOString().split("T")[0];
|
56
|
+
const [s, ...r] = i, l = D(...r), o = new Date(l);
|
57
|
+
return s < o ? s.toISOString().split("T")[0] : o.toISOString().split("T")[0];
|
58
|
+
}
|
59
|
+
function S(...t) {
|
60
|
+
if (t.length === 0)
|
61
|
+
throw new Error("At least one date must be provided");
|
62
|
+
const n = (e) => e instanceof Date, i = t.map((e) => n(e) ? e : new Date(e));
|
63
|
+
if (i.length === 1)
|
64
|
+
return i[0].toISOString().split("T")[0];
|
65
|
+
const [s, ...r] = i, l = S(...r), o = new Date(l);
|
66
|
+
return s > o ? s.toISOString().split("T")[0] : o.toISOString().split("T")[0];
|
67
|
+
}
|
68
|
+
function g(t, n = !1) {
|
69
|
+
t instanceof Date && (t = a.PlainDate.from(t.toISOString().split("T")[0])), typeof t != "string" && (t = t.toString());
|
70
|
+
const i = /^\d{4}-\d{2}-\d{2}$/;
|
71
|
+
if (!i.test(t) && n)
|
72
|
+
throw new Error(`Invalid date format. Got ${t} passed in.`);
|
73
|
+
return i.test(t) ? t : "";
|
74
|
+
}
|
75
|
+
export {
|
76
|
+
g as assertISODate,
|
77
|
+
v as compareDates,
|
78
|
+
I as doAnimate,
|
79
|
+
D as earliestDate,
|
80
|
+
P as getDateParts,
|
81
|
+
S as latestDate,
|
82
|
+
u as timeBetween
|
83
|
+
};
|
package/dist/components/{date-picker/datepicker.styles.js → datepicker/datepicker-popup.styles.js}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { css as r } from "lit";
|
2
|
-
const
|
2
|
+
const e = r`
|
3
3
|
@layer components {
|
4
4
|
:host {
|
5
5
|
--max-width: 21em;
|
@@ -8,7 +8,7 @@ const a = r`
|
|
8
8
|
background-color: var(--skf-bg-color-neutral-1);
|
9
9
|
border: solid 1px var(--skf-border-color-primary);
|
10
10
|
border-radius: 3px;
|
11
|
-
box-shadow: 0 0 10px
|
11
|
+
box-shadow: 0 0 10px rgb(0 0 0 / 30%);
|
12
12
|
box-sizing: border-box;
|
13
13
|
display: block;
|
14
14
|
font-family: Helvetica, sans-serif;
|
@@ -83,5 +83,5 @@ const a = r`
|
|
83
83
|
}
|
84
84
|
`;
|
85
85
|
export {
|
86
|
-
|
86
|
+
e as styles
|
87
87
|
};
|