@sondor-technology/sondor-components 1.0.1-develop.13 → 1.0.1-develop.15
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.constants.d.ts +3 -0
- package/dist/components/alert/alert.constants.d.ts.map +1 -0
- package/dist/components/alert/alert.constants.js +2 -0
- package/dist/components/alert/alert.constants.js.map +1 -0
- package/dist/components/alert/alert.d.ts +4 -3
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +21 -11
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/badge/badge.constants.d.ts +3 -0
- package/dist/components/badge/badge.constants.d.ts.map +1 -0
- package/dist/components/badge/badge.constants.js +2 -0
- package/dist/components/badge/badge.constants.js.map +1 -0
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/badge.js +3 -2
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +2 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/components/button/button.constants.d.ts +7 -0
- package/dist/components/button/button.constants.d.ts.map +1 -0
- package/dist/components/button/button.constants.js +4 -0
- package/dist/components/button/button.constants.js.map +1 -0
- package/dist/components/button/button.d.ts +8 -4
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +181 -137
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button-group/button-group.d.ts +1 -0
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/button-group.js +17 -21
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +36 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +439 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/checkbox/checkbox.constants.d.ts +3 -0
- package/dist/components/checkbox/checkbox.constants.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.constants.js +2 -0
- package/dist/components/checkbox/checkbox.constants.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +5 -1
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/checkbox.js +21 -5
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/code-block/code-block.d.ts +7 -7
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/code-block.js +130 -66
- package/dist/components/code-block/code-block.js.map +1 -0
- package/dist/components/content-card/content-card.d.ts.map +1 -1
- package/dist/components/content-card/content-card.js +10 -15
- package/dist/components/content-card/content-card.js.map +1 -0
- package/dist/components/cron-builder/cron-builder.d.ts +34 -0
- package/dist/components/cron-builder/cron-builder.d.ts.map +1 -0
- package/dist/components/cron-builder/cron-builder.js +456 -0
- package/dist/components/cron-builder/cron-builder.js.map +1 -0
- package/dist/components/divider/divider.constants.d.ts +5 -0
- package/dist/components/divider/divider.constants.d.ts.map +1 -0
- package/dist/components/divider/divider.constants.js +3 -0
- package/dist/components/divider/divider.constants.js.map +1 -0
- package/dist/components/divider/divider.d.ts +4 -2
- package/dist/components/divider/divider.d.ts.map +1 -1
- package/dist/components/divider/divider.js +18 -9
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +7 -4
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/drawer.js +73 -30
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/field/field.d.ts +2 -2
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/field.js +8 -9
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/footer/footer.d.ts +8 -1
- package/dist/components/footer/footer.d.ts.map +1 -1
- package/dist/components/footer/footer.js +42 -12
- package/dist/components/footer/footer.js.map +1 -0
- package/dist/components/form/form-step.js +1 -0
- package/dist/components/form/form-step.js.map +1 -0
- package/dist/components/form/form.d.ts +3 -0
- package/dist/components/form/form.d.ts.map +1 -1
- package/dist/components/form/form.js +109 -69
- package/dist/components/form/form.js.map +1 -0
- package/dist/components/grid/grid-row.d.ts +3 -3
- package/dist/components/grid/grid-row.d.ts.map +1 -1
- package/dist/components/grid/grid-row.js +36 -22
- package/dist/components/grid/grid-row.js.map +1 -0
- package/dist/components/grid/grid.d.ts +2 -2
- package/dist/components/grid/grid.d.ts.map +1 -1
- package/dist/components/grid/grid.js +5 -2
- package/dist/components/grid/grid.js.map +1 -0
- package/dist/components/icon/icon-paths.d.ts +161 -86
- package/dist/components/icon/icon-paths.d.ts.map +1 -1
- package/dist/components/icon/icon-paths.js +176 -106
- package/dist/components/icon/icon-paths.js.map +1 -0
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +6 -5
- package/dist/components/icon/icon.js.map +1 -0
- package/dist/components/input/input.d.ts +10 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +59 -43
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/link/link.d.ts +6 -6
- package/dist/components/link/link.d.ts.map +1 -1
- package/dist/components/link/link.js +42 -19
- package/dist/components/link/link.js.map +1 -0
- package/dist/components/metadata/metadata.d.ts +3 -3
- package/dist/components/metadata/metadata.d.ts.map +1 -1
- package/dist/components/metadata/metadata.js +23 -20
- package/dist/components/metadata/metadata.js.map +1 -0
- package/dist/components/modal/modal.d.ts +4 -16
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/modal/modal.js +99 -62
- package/dist/components/modal/modal.js.map +1 -0
- package/dist/components/page-layout/page-layout.d.ts +4 -3
- package/dist/components/page-layout/page-layout.d.ts.map +1 -1
- package/dist/components/page-layout/page-layout.js +95 -68
- package/dist/components/page-layout/page-layout.js.map +1 -0
- package/dist/components/pin-input/pin-input.d.ts +33 -0
- package/dist/components/pin-input/pin-input.d.ts.map +1 -0
- package/dist/components/pin-input/pin-input.js +253 -0
- package/dist/components/pin-input/pin-input.js.map +1 -0
- package/dist/components/popover/popover.d.ts +26 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +196 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/radio/radio.d.ts +8 -0
- package/dist/components/radio/radio.d.ts.map +1 -1
- package/dist/components/radio/radio.js +8 -12
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +6 -1
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group/radio-group.js +44 -18
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/router/router.d.ts +5 -7
- package/dist/components/router/router.d.ts.map +1 -1
- package/dist/components/router/router.js +54 -38
- package/dist/components/router/router.js.map +1 -0
- package/dist/components/select/select.d.ts +5 -4
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +40 -9
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +3 -2
- package/dist/components/skeleton/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton.js +10 -13
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/switch/switch.d.ts +12 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/switch/switch.js +28 -22
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/data-table.d.ts +3 -25
- package/dist/components/table/data-table.d.ts.map +1 -1
- package/dist/components/table/data-table.js +211 -146
- package/dist/components/table/data-table.js.map +1 -0
- package/dist/components/table/table.d.ts +3 -3
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +39 -20
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/tab-panel.d.ts +3 -1
- package/dist/components/tabs/tab-panel.d.ts.map +1 -1
- package/dist/components/tabs/tab-panel.js +21 -11
- package/dist/components/tabs/tab-panel.js.map +1 -0
- package/dist/components/tabs/tab.d.ts +5 -1
- package/dist/components/tabs/tab.d.ts.map +1 -1
- package/dist/components/tabs/tab.js +46 -28
- package/dist/components/tabs/tab.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +4 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tabs/tabs.js +76 -13
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +13 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -1
- package/dist/components/textarea/textarea.js +59 -13
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.constants.d.ts +3 -0
- package/dist/components/theme-toggle/theme-toggle.constants.d.ts.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.constants.js +2 -0
- package/dist/components/theme-toggle/theme-toggle.constants.js.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.d.ts +3 -2
- package/dist/components/theme-toggle/theme-toggle.d.ts.map +1 -1
- package/dist/components/theme-toggle/theme-toggle.js +46 -19
- package/dist/components/theme-toggle/theme-toggle.js.map +1 -0
- package/dist/components/time-picker/time-picker.d.ts +38 -0
- package/dist/components/time-picker/time-picker.d.ts.map +1 -0
- package/dist/components/time-picker/time-picker.js +280 -0
- package/dist/components/time-picker/time-picker.js.map +1 -0
- package/dist/components/toggle-group/toggle-button.d.ts +23 -0
- package/dist/components/toggle-group/toggle-button.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-button.js +115 -0
- package/dist/components/toggle-group/toggle-button.js.map +1 -0
- package/dist/components/toggle-group/toggle-group.d.ts +32 -0
- package/dist/components/toggle-group/toggle-group.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-group.js +150 -0
- package/dist/components/toggle-group/toggle-group.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +33 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +293 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/components/vertical-nav/vertical-nav-group.d.ts +5 -2
- package/dist/components/vertical-nav/vertical-nav-group.d.ts.map +1 -1
- package/dist/components/vertical-nav/vertical-nav-group.js +50 -14
- package/dist/components/vertical-nav/vertical-nav-group.js.map +1 -0
- package/dist/components/vertical-nav/vertical-nav-item.d.ts +3 -2
- package/dist/components/vertical-nav/vertical-nav-item.d.ts.map +1 -1
- package/dist/components/vertical-nav/vertical-nav-item.js +30 -8
- package/dist/components/vertical-nav/vertical-nav-item.js.map +1 -0
- package/dist/styles/index.css +49 -17
- package/dist/styles/reset.js +1 -0
- package/dist/styles/reset.js.map +1 -0
- package/package.json +30 -1
- package/src/components/alert/alert.constants.ts +2 -0
- package/src/components/alert/alert.ts +24 -15
- package/src/components/badge/badge.constants.ts +2 -0
- package/src/components/badge/badge.ts +3 -4
- package/src/components/breadcrumb/breadcrumb.ts +2 -2
- package/src/components/button/button.constants.ts +8 -0
- package/src/components/button/button.ts +184 -144
- package/src/components/button-group/button-group.ts +18 -22
- package/src/components/calendar/calendar.ts +444 -0
- package/src/components/checkbox/checkbox.constants.ts +2 -0
- package/src/components/checkbox/checkbox.ts +33 -18
- package/src/components/code-block/code-block.ts +151 -84
- package/src/components/content-card/content-card.ts +10 -16
- package/src/components/cron-builder/cron-builder.ts +452 -0
- package/src/components/divider/divider.constants.ts +5 -0
- package/src/components/divider/divider.ts +22 -11
- package/src/components/drawer/drawer.ts +79 -34
- package/src/components/field/field.ts +9 -11
- package/src/components/footer/footer.ts +43 -12
- package/src/components/form/form.ts +121 -84
- package/src/components/grid/grid-row.ts +45 -32
- package/src/components/grid/grid.ts +7 -4
- package/src/components/icon/icon-paths.ts +175 -106
- package/src/components/icon/icon.ts +6 -6
- package/src/components/input/input.ts +59 -45
- package/src/components/link/link.ts +45 -21
- package/src/components/metadata/metadata.ts +26 -24
- package/src/components/modal/modal.ts +108 -74
- package/src/components/page-layout/page-layout.ts +97 -72
- package/src/components/pin-input/pin-input.ts +249 -0
- package/src/components/popover/popover.ts +192 -0
- package/src/components/radio/radio.ts +8 -13
- package/src/components/radio-group/radio-group.ts +45 -21
- package/src/components/router/router.ts +73 -50
- package/src/components/select/select.ts +41 -80
- package/src/components/skeleton/skeleton.ts +14 -14
- package/src/components/switch/switch.ts +31 -25
- package/src/components/table/data-table.ts +248 -177
- package/src/components/table/table.ts +52 -29
- package/src/components/tabs/tab-panel.ts +25 -13
- package/src/components/tabs/tab.ts +58 -33
- package/src/components/tabs/tabs.ts +77 -15
- package/src/components/textarea/textarea.ts +63 -15
- package/src/components/theme-toggle/theme-toggle.constants.ts +2 -0
- package/src/components/theme-toggle/theme-toggle.ts +47 -22
- package/src/components/time-picker/time-picker.ts +272 -0
- package/src/components/toggle-group/toggle-button.ts +104 -0
- package/src/components/toggle-group/toggle-group.ts +148 -0
- package/src/components/tooltip/tooltip.ts +286 -0
- package/src/components/vertical-nav/vertical-nav-group.ts +57 -18
- package/src/components/vertical-nav/vertical-nav-item.ts +35 -12
- package/src/styles/globals.css +27 -4
- package/src/styles/theme.css +40 -32
- package/tsconfig.json +2 -1
- package/dist/components/card/card.d.ts +0 -11
- package/dist/components/card/card.d.ts.map +0 -1
- package/dist/components/card/card.js +0 -54
- package/src/components/card/card.ts +0 -53
|
@@ -12,10 +12,6 @@ export class StButtonGroup extends LitElement {
|
|
|
12
12
|
align-items: center;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.group {
|
|
16
|
-
display: inline-flex;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
15
|
/* 1. Flatten all corners by default */
|
|
20
16
|
::slotted(st-button) {
|
|
21
17
|
--btn-radius-tl: 0px;
|
|
@@ -37,32 +33,32 @@ export class StButtonGroup extends LitElement {
|
|
|
37
33
|
--btn-radius-br: var(--st-radius-md, 0.5rem);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
/* 4. Collapse borders by
|
|
41
|
-
::slotted(st-button
|
|
36
|
+
/* 4. Collapse borders by pulling adjacent buttons left */
|
|
37
|
+
::slotted(st-button:not(:first-child)) {
|
|
42
38
|
margin-left: -1px;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
/* 5.
|
|
46
|
-
::slotted(st-button
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/* 6. Pull active/hovered default buttons forward so their full border shows */
|
|
52
|
-
::slotted(st-button[color="default"]:hover),
|
|
53
|
-
::slotted(st-button[color="default"]:focus-within),
|
|
54
|
-
::slotted(st-button[color="default"]:active) {
|
|
41
|
+
/* 5. Pull active/hovered buttons forward so their full border shows */
|
|
42
|
+
::slotted(st-button:hover),
|
|
43
|
+
::slotted(st-button:focus-within),
|
|
44
|
+
::slotted(st-button:active),
|
|
45
|
+
::slotted(st-button[active]) {
|
|
55
46
|
z-index: 1;
|
|
56
47
|
}
|
|
57
48
|
`,
|
|
58
49
|
];
|
|
59
50
|
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
super.connectedCallback();
|
|
53
|
+
// Automatically apply the semantic role to the host if the developer omits it.
|
|
54
|
+
// This allows them to just write: <st-button-group aria-label="Pagination">
|
|
55
|
+
if (!this.hasAttribute("role")) {
|
|
56
|
+
this.setAttribute("role", "group");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
60
|
render() {
|
|
61
|
-
return html
|
|
62
|
-
<div class="group" role="group" aria-label="button group">
|
|
63
|
-
<slot></slot>
|
|
64
|
-
</div>
|
|
65
|
-
`;
|
|
61
|
+
return html`<slot></slot>`;
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
64
|
|
|
@@ -70,4 +66,4 @@ declare global {
|
|
|
70
66
|
interface HTMLElementTagNameMap {
|
|
71
67
|
"st-button-group": StButtonGroup;
|
|
72
68
|
}
|
|
73
|
-
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import {LitElement, html, css, PropertyValues} from "lit";
|
|
2
|
+
import {customElement, property, state} from "lit/decorators.js";
|
|
3
|
+
import {resetStyles} from "../../styles/reset.js";
|
|
4
|
+
import "../select/select.js"; // Ensure this path matches your project structure
|
|
5
|
+
|
|
6
|
+
const MONTH_NAMES = [
|
|
7
|
+
"January",
|
|
8
|
+
"February",
|
|
9
|
+
"March",
|
|
10
|
+
"April",
|
|
11
|
+
"May",
|
|
12
|
+
"June",
|
|
13
|
+
"July",
|
|
14
|
+
"August",
|
|
15
|
+
"September",
|
|
16
|
+
"October",
|
|
17
|
+
"November",
|
|
18
|
+
"December",
|
|
19
|
+
];
|
|
20
|
+
const DAY_NAMES = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
21
|
+
|
|
22
|
+
const parseIsoLocal = (iso: string): Date | null => {
|
|
23
|
+
if (!iso) return null;
|
|
24
|
+
const [y, m, d] = iso.split(/\D/).map(Number);
|
|
25
|
+
if (!y || !m || !d) return null;
|
|
26
|
+
return new Date(y, m - 1, d);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const formatIsoLocal = (date: Date): string => {
|
|
30
|
+
const pad = (n: number) => n.toString().padStart(2, "0");
|
|
31
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
@customElement("st-calendar")
|
|
35
|
+
export class StCalendar extends LitElement {
|
|
36
|
+
static formAssociated = true;
|
|
37
|
+
private _internals: ElementInternals;
|
|
38
|
+
|
|
39
|
+
@property({type: String, reflect: true}) name = "";
|
|
40
|
+
@property({type: String}) value = "";
|
|
41
|
+
@property({type: String}) min = "";
|
|
42
|
+
@property({type: String}) max = "";
|
|
43
|
+
|
|
44
|
+
@property({type: Boolean, reflect: true}) disabled = false;
|
|
45
|
+
@property({type: Boolean, reflect: true}) required = false;
|
|
46
|
+
@property({type: Boolean, reflect: true}) invalid = false;
|
|
47
|
+
|
|
48
|
+
@state() private _viewMonth = new Date().getMonth();
|
|
49
|
+
@state() private _viewYear = new Date().getFullYear();
|
|
50
|
+
|
|
51
|
+
private _defaultValue = "";
|
|
52
|
+
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
this._internals = this.attachInternals();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static styles = [
|
|
59
|
+
resetStyles,
|
|
60
|
+
css`
|
|
61
|
+
:host {
|
|
62
|
+
display: inline-block;
|
|
63
|
+
width: 320px;
|
|
64
|
+
background-color: var(--st-color-surface);
|
|
65
|
+
border: 1px solid var(--st-color-border);
|
|
66
|
+
border-radius: var(--st-radius-md);
|
|
67
|
+
padding: var(--st-spacing-md);
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([disabled]) {
|
|
72
|
+
opacity: 0.5;
|
|
73
|
+
pointer-events: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([invalid]) {
|
|
77
|
+
border-color: var(--st-color-error, #dc2626);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.header {
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: space-between;
|
|
84
|
+
margin-bottom: var(--st-spacing-md);
|
|
85
|
+
gap: var(--st-spacing-xs);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.header-controls {
|
|
89
|
+
display: flex;
|
|
90
|
+
gap: var(--st-spacing-xs);
|
|
91
|
+
flex: 1;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Shape the custom selects to fit side-by-side in the header */
|
|
96
|
+
.header-controls st-select:first-child {
|
|
97
|
+
width: 120px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.header-controls st-select:last-child {
|
|
101
|
+
width: 90px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.nav-button {
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
width: 32px;
|
|
109
|
+
height: 42px; /* Matches the 42px min-height of your st-select combobox */
|
|
110
|
+
border: none;
|
|
111
|
+
background: transparent;
|
|
112
|
+
border-radius: var(--st-radius-sm);
|
|
113
|
+
color: var(--st-color-text-muted);
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
transition: background-color 0.2s;
|
|
116
|
+
flex-shrink: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.nav-button:hover {
|
|
120
|
+
background-color: var(--st-color-surface-hover, #f1f5f9);
|
|
121
|
+
color: var(--st-color-text);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.nav-button svg {
|
|
125
|
+
width: 20px;
|
|
126
|
+
height: 20px;
|
|
127
|
+
fill: none;
|
|
128
|
+
stroke: currentColor;
|
|
129
|
+
stroke-width: 2;
|
|
130
|
+
stroke-linecap: round;
|
|
131
|
+
stroke-linejoin: round;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.grid {
|
|
135
|
+
display: grid;
|
|
136
|
+
grid-template-columns: repeat(7, 1fr);
|
|
137
|
+
gap: 4px;
|
|
138
|
+
text-align: center;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.grid-row {
|
|
142
|
+
display: contents;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.day-name {
|
|
146
|
+
font-size: var(--st-font-size-xs);
|
|
147
|
+
font-weight: var(--st-font-weight-semibold);
|
|
148
|
+
color: var(--st-color-text-muted);
|
|
149
|
+
padding-bottom: var(--st-spacing-xs);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.day {
|
|
153
|
+
aspect-ratio: 1;
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
border: none;
|
|
158
|
+
background: transparent;
|
|
159
|
+
border-radius: 50%;
|
|
160
|
+
color: var(--st-color-text);
|
|
161
|
+
font-size: var(--st-font-size-sm);
|
|
162
|
+
cursor: pointer;
|
|
163
|
+
transition: all 0.2s ease;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.day:hover:not(:disabled):not(.empty) {
|
|
167
|
+
background-color: var(--st-color-surface-hover, #f1f5f9);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.day:focus-visible {
|
|
171
|
+
outline: 2px solid var(--st-color-primary);
|
|
172
|
+
outline-offset: -2px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.day:disabled {
|
|
176
|
+
color: var(--st-color-text-muted);
|
|
177
|
+
opacity: 0.3;
|
|
178
|
+
cursor: not-allowed;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.day.empty {
|
|
182
|
+
cursor: default;
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.day[aria-current="date"] {
|
|
187
|
+
font-weight: var(--st-font-weight-bold);
|
|
188
|
+
color: var(--st-color-primary);
|
|
189
|
+
background-color: var(--st-color-primary-light, #eff6ff);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.day[aria-selected="true"] {
|
|
193
|
+
background-color: var(--st-color-primary);
|
|
194
|
+
color: var(--st-color-on-primary, var(--st-color-bg, #ffffff));
|
|
195
|
+
font-weight: var(--st-font-weight-bold);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.day[aria-selected="true"]:hover {
|
|
199
|
+
background-color: var(--st-color-primary-dark, #1d4ed8);
|
|
200
|
+
}
|
|
201
|
+
`,
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
override firstUpdated(changedProperties: PropertyValues) {
|
|
205
|
+
super.firstUpdated(changedProperties);
|
|
206
|
+
this._defaultValue = this.value;
|
|
207
|
+
|
|
208
|
+
if (this.value) {
|
|
209
|
+
const initDate = parseIsoLocal(this.value);
|
|
210
|
+
if (initDate) {
|
|
211
|
+
this._viewMonth = initDate.getMonth();
|
|
212
|
+
this._viewYear = initDate.getFullYear();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
override updated(changedProperties: PropertyValues) {
|
|
218
|
+
super.updated(changedProperties);
|
|
219
|
+
|
|
220
|
+
if (changedProperties.has("value")) {
|
|
221
|
+
this._internals.setFormValue(this.value || null);
|
|
222
|
+
this._syncValidity();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private get _yearRange(): number[] {
|
|
227
|
+
const currentYear = new Date().getFullYear();
|
|
228
|
+
let minYear = currentYear - 50;
|
|
229
|
+
let maxYear = currentYear + 50;
|
|
230
|
+
|
|
231
|
+
if (this.min) {
|
|
232
|
+
const minDate = parseIsoLocal(this.min);
|
|
233
|
+
if (minDate) minYear = minDate.getFullYear();
|
|
234
|
+
}
|
|
235
|
+
if (this.max) {
|
|
236
|
+
const maxDate = parseIsoLocal(this.max);
|
|
237
|
+
if (maxDate) maxYear = maxDate.getFullYear();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const years = [];
|
|
241
|
+
for (let y = minYear; y <= maxYear; y++) {
|
|
242
|
+
years.push(y);
|
|
243
|
+
}
|
|
244
|
+
return years;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private _syncValidity() {
|
|
248
|
+
this.invalid = false;
|
|
249
|
+
|
|
250
|
+
if (this.required && !this.value) {
|
|
251
|
+
this._internals.setValidity({valueMissing: true}, "Please select a date.");
|
|
252
|
+
this.invalid = true;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (this.value) {
|
|
257
|
+
const minDate = parseIsoLocal(this.min);
|
|
258
|
+
const maxDate = parseIsoLocal(this.max);
|
|
259
|
+
const valDate = parseIsoLocal(this.value);
|
|
260
|
+
|
|
261
|
+
if (valDate && minDate && valDate < minDate) {
|
|
262
|
+
this._internals.setValidity({rangeUnderflow: true}, `Date must be after ${this.min}.`);
|
|
263
|
+
this.invalid = true;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (valDate && maxDate && valDate > maxDate) {
|
|
267
|
+
this._internals.setValidity({rangeOverflow: true}, `Date must be before ${this.max}.`);
|
|
268
|
+
this.invalid = true;
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
this._internals.setValidity({});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
formResetCallback() {
|
|
277
|
+
this.value = this._defaultValue;
|
|
278
|
+
if (this.value) {
|
|
279
|
+
const initDate = parseIsoLocal(this.value);
|
|
280
|
+
if (initDate) {
|
|
281
|
+
this._viewMonth = initDate.getMonth();
|
|
282
|
+
this._viewYear = initDate.getFullYear();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public checkValidity() {
|
|
288
|
+
return this._internals.checkValidity();
|
|
289
|
+
}
|
|
290
|
+
public reportValidity() {
|
|
291
|
+
return this._internals.reportValidity();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private _prevMonth() {
|
|
295
|
+
if (this._viewMonth === 0) {
|
|
296
|
+
this._viewMonth = 11;
|
|
297
|
+
this._viewYear--;
|
|
298
|
+
} else {
|
|
299
|
+
this._viewMonth--;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private _nextMonth() {
|
|
304
|
+
if (this._viewMonth === 11) {
|
|
305
|
+
this._viewMonth = 0;
|
|
306
|
+
this._viewYear++;
|
|
307
|
+
} else {
|
|
308
|
+
this._viewMonth++;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private _selectDate(day: number) {
|
|
313
|
+
const selected = new Date(this._viewYear, this._viewMonth, day);
|
|
314
|
+
this.value = formatIsoLocal(selected);
|
|
315
|
+
|
|
316
|
+
this.dispatchEvent(new Event("change", {bubbles: true, composed: true}));
|
|
317
|
+
this.dispatchEvent(new Event("input", {bubbles: true, composed: true}));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private _isDateDisabled(year: number, month: number, day: number): boolean {
|
|
321
|
+
if (this.disabled) return true;
|
|
322
|
+
|
|
323
|
+
const date = new Date(year, month, day);
|
|
324
|
+
const minDate = parseIsoLocal(this.min);
|
|
325
|
+
const maxDate = parseIsoLocal(this.max);
|
|
326
|
+
|
|
327
|
+
if (minDate && date < minDate) return true;
|
|
328
|
+
if (maxDate && date > maxDate) return true;
|
|
329
|
+
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
render() {
|
|
334
|
+
const today = new Date();
|
|
335
|
+
const isToday = (day: number) =>
|
|
336
|
+
today.getDate() === day &&
|
|
337
|
+
today.getMonth() === this._viewMonth &&
|
|
338
|
+
today.getFullYear() === this._viewYear;
|
|
339
|
+
|
|
340
|
+
const selectedDate = parseIsoLocal(this.value);
|
|
341
|
+
const isSelected = (day: number) =>
|
|
342
|
+
selectedDate !== null &&
|
|
343
|
+
selectedDate.getDate() === day &&
|
|
344
|
+
selectedDate.getMonth() === this._viewMonth &&
|
|
345
|
+
selectedDate.getFullYear() === this._viewYear;
|
|
346
|
+
|
|
347
|
+
const firstDayOfMonth = new Date(this._viewYear, this._viewMonth, 1).getDay();
|
|
348
|
+
const daysInMonth = new Date(this._viewYear, this._viewMonth + 1, 0).getDate();
|
|
349
|
+
|
|
350
|
+
const blanks = Array.from({length: firstDayOfMonth}, (_, i) => i);
|
|
351
|
+
const days = Array.from({length: daysInMonth}, (_, i) => i + 1);
|
|
352
|
+
|
|
353
|
+
const allCells = [
|
|
354
|
+
...blanks.map(() => html`<div class="day empty" role="gridcell"></div>`),
|
|
355
|
+
...days.map((day) => {
|
|
356
|
+
const disabled = this._isDateDisabled(this._viewYear, this._viewMonth, day);
|
|
357
|
+
return html`
|
|
358
|
+
<button
|
|
359
|
+
class="day"
|
|
360
|
+
role="gridcell"
|
|
361
|
+
type="button"
|
|
362
|
+
?disabled=${disabled}
|
|
363
|
+
aria-label=${`${MONTH_NAMES[this._viewMonth]} ${day}, ${this._viewYear}`}
|
|
364
|
+
aria-current=${isToday(day) ? "date" : "false"}
|
|
365
|
+
aria-selected=${isSelected(day) ? "true" : "false"}
|
|
366
|
+
@click=${() => this._selectDate(day)}
|
|
367
|
+
>
|
|
368
|
+
${day}
|
|
369
|
+
</button>
|
|
370
|
+
`;
|
|
371
|
+
}),
|
|
372
|
+
];
|
|
373
|
+
|
|
374
|
+
const weeks = [];
|
|
375
|
+
for (let i = 0; i < allCells.length; i += 7) {
|
|
376
|
+
weeks.push(allCells.slice(i, i + 7));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// 🚀 FIX: Generate the option array objects as required by your st-select API
|
|
380
|
+
const monthOptions = MONTH_NAMES.map((name, i) => ({label: name, value: String(i)}));
|
|
381
|
+
const yearOptions = this._yearRange.map((year) => ({label: String(year), value: String(year)}));
|
|
382
|
+
|
|
383
|
+
return html`
|
|
384
|
+
<div class="header">
|
|
385
|
+
<button
|
|
386
|
+
class="nav-button"
|
|
387
|
+
type="button"
|
|
388
|
+
aria-label="Previous Month"
|
|
389
|
+
@click=${this._prevMonth}
|
|
390
|
+
?disabled=${this.disabled}
|
|
391
|
+
>
|
|
392
|
+
<svg viewBox="0 0 24 24"><path d="M15 18l-6-6 6-6"></path></svg>
|
|
393
|
+
</button>
|
|
394
|
+
|
|
395
|
+
<div class="header-controls">
|
|
396
|
+
<st-select
|
|
397
|
+
label="Month"
|
|
398
|
+
hide-label
|
|
399
|
+
.options=${monthOptions}
|
|
400
|
+
.value=${String(this._viewMonth)}
|
|
401
|
+
?disabled=${this.disabled}
|
|
402
|
+
@change=${(e: any) => (this._viewMonth = Number(e.target.value))}
|
|
403
|
+
></st-select>
|
|
404
|
+
|
|
405
|
+
<st-select
|
|
406
|
+
label="Year"
|
|
407
|
+
hide-label
|
|
408
|
+
.options=${yearOptions}
|
|
409
|
+
.value=${String(this._viewYear)}
|
|
410
|
+
?disabled=${this.disabled}
|
|
411
|
+
@change=${(e: any) => (this._viewYear = Number(e.target.value))}
|
|
412
|
+
></st-select>
|
|
413
|
+
</div>
|
|
414
|
+
|
|
415
|
+
<button
|
|
416
|
+
class="nav-button"
|
|
417
|
+
type="button"
|
|
418
|
+
aria-label="Next Month"
|
|
419
|
+
@click=${this._nextMonth}
|
|
420
|
+
?disabled=${this.disabled}
|
|
421
|
+
>
|
|
422
|
+
<svg viewBox="0 0 24 24"><path d="M9 18l6-6-6-6"></path></svg>
|
|
423
|
+
</button>
|
|
424
|
+
</div>
|
|
425
|
+
|
|
426
|
+
<div class="grid" role="grid" aria-label="Calendar">
|
|
427
|
+
<div class="grid-row" role="row">
|
|
428
|
+
${DAY_NAMES.map(
|
|
429
|
+
(name) => html`
|
|
430
|
+
<div class="day-name" role="columnheader" aria-label=${name}>${name}</div>
|
|
431
|
+
`,
|
|
432
|
+
)}
|
|
433
|
+
</div>
|
|
434
|
+
${weeks.map((week) => html` <div class="grid-row" role="row">${week}</div> `)}
|
|
435
|
+
</div>
|
|
436
|
+
`;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
declare global {
|
|
441
|
+
interface HTMLElementTagNameMap {
|
|
442
|
+
"st-calendar": StCalendar;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {LitElement, html, css, PropertyValues} from "lit";
|
|
2
2
|
import {customElement, property, query} from "lit/decorators.js";
|
|
3
3
|
import {resetStyles} from "../../styles/reset.js";
|
|
4
|
+
import {CheckboxSize} from "./checkbox.constants.js";
|
|
4
5
|
|
|
5
6
|
@customElement("st-checkbox")
|
|
6
7
|
export class StCheckbox extends LitElement {
|
|
@@ -9,7 +10,7 @@ export class StCheckbox extends LitElement {
|
|
|
9
10
|
|
|
10
11
|
@query("input") private _inputEl!: HTMLInputElement;
|
|
11
12
|
|
|
12
|
-
@property({type: String, reflect: true}) size:
|
|
13
|
+
@property({type: String, reflect: true}) size: CheckboxSize = "md";
|
|
13
14
|
@property({type: String, reflect: true}) name = "";
|
|
14
15
|
@property({type: String}) value = "on";
|
|
15
16
|
|
|
@@ -27,11 +28,11 @@ export class StCheckbox extends LitElement {
|
|
|
27
28
|
super();
|
|
28
29
|
this._internals = this.attachInternals();
|
|
29
30
|
|
|
30
|
-
this.addEventListener(
|
|
31
|
+
this.addEventListener("focusout", () => {
|
|
31
32
|
this.invalid = !this.checkValidity();
|
|
32
33
|
});
|
|
33
34
|
|
|
34
|
-
this.addEventListener(
|
|
35
|
+
this.addEventListener("invalid", () => {
|
|
35
36
|
this.invalid = !this.checkValidity();
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -150,7 +151,11 @@ export class StCheckbox extends LitElement {
|
|
|
150
151
|
override updated(changedProperties: PropertyValues<this>) {
|
|
151
152
|
super.updated(changedProperties);
|
|
152
153
|
|
|
153
|
-
if (
|
|
154
|
+
if (
|
|
155
|
+
changedProperties.has("checked") ||
|
|
156
|
+
changedProperties.has("value") ||
|
|
157
|
+
changedProperties.has("errorMessage")
|
|
158
|
+
) {
|
|
154
159
|
this._internals.setFormValue(this.checked ? this.value : null);
|
|
155
160
|
this._syncValidity();
|
|
156
161
|
}
|
|
@@ -164,12 +169,11 @@ export class StCheckbox extends LitElement {
|
|
|
164
169
|
if (!this._inputEl) return;
|
|
165
170
|
|
|
166
171
|
if (this.required && !this.checked) {
|
|
167
|
-
const message =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
);
|
|
172
|
+
const message =
|
|
173
|
+
this.errorMessage ||
|
|
174
|
+
this._inputEl.validationMessage ||
|
|
175
|
+
"Please check this box if you want to proceed.";
|
|
176
|
+
this._internals.setValidity({valueMissing: true}, message, this._inputEl);
|
|
173
177
|
} else {
|
|
174
178
|
this._internals.setValidity(
|
|
175
179
|
this._inputEl.validity,
|
|
@@ -183,12 +187,11 @@ export class StCheckbox extends LitElement {
|
|
|
183
187
|
if (!this._inputEl) return true;
|
|
184
188
|
|
|
185
189
|
if (this.required && !this.checked) {
|
|
186
|
-
const message =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
);
|
|
190
|
+
const message =
|
|
191
|
+
this.errorMessage ||
|
|
192
|
+
this._inputEl.validationMessage ||
|
|
193
|
+
"Please check this box if you want to proceed.";
|
|
194
|
+
this._internals.setValidity({valueMissing: true}, message, this._inputEl);
|
|
192
195
|
this.invalid = true;
|
|
193
196
|
return false;
|
|
194
197
|
}
|
|
@@ -206,6 +209,18 @@ export class StCheckbox extends LitElement {
|
|
|
206
209
|
return isValid;
|
|
207
210
|
}
|
|
208
211
|
|
|
212
|
+
public get validity(): ValidityState {
|
|
213
|
+
return this._internals.validity;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public get validationMessage(): string {
|
|
217
|
+
return this._internals.validationMessage;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public get willValidate(): boolean {
|
|
221
|
+
return this._internals.willValidate;
|
|
222
|
+
}
|
|
223
|
+
|
|
209
224
|
formResetCallback() {
|
|
210
225
|
this.checked = false;
|
|
211
226
|
this.indeterminate = false;
|
|
@@ -224,7 +239,7 @@ export class StCheckbox extends LitElement {
|
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
this.checked = this._inputEl.checked;
|
|
227
|
-
|
|
242
|
+
|
|
228
243
|
if (this.checkValidity()) {
|
|
229
244
|
this.invalid = false;
|
|
230
245
|
}
|
|
@@ -263,4 +278,4 @@ declare global {
|
|
|
263
278
|
interface HTMLElementTagNameMap {
|
|
264
279
|
"st-checkbox": StCheckbox;
|
|
265
280
|
}
|
|
266
|
-
}
|
|
281
|
+
}
|