@sondor-technology/sondor-components 1.0.5 → 1.0.6
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/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/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 +107 -67
- 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.js +1 -0
- package/dist/components/icon/icon-paths.js.map +1 -0
- package/dist/components/icon/icon.js +1 -0
- package/dist/components/icon/icon.js.map +1 -0
- package/dist/components/input/input.d.ts +9 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +30 -37
- 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/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 +1 -3
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +14 -5
- 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/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 +48 -17
- package/dist/styles/reset.js +1 -0
- package/dist/styles/reset.js.map +1 -0
- package/package.json +2 -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/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/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 +120 -83
- package/src/components/grid/grid-row.ts +45 -32
- package/src/components/grid/grid.ts +7 -4
- package/src/components/input/input.ts +32 -42
- 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/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 +18 -19
- 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/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 +38 -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
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import {LitElement, html, css, nothing} from "lit";
|
|
2
2
|
import {customElement, property} from "lit/decorators.js";
|
|
3
3
|
import {resetStyles} from "../../styles/reset.js";
|
|
4
|
-
|
|
5
|
-
export type ButtonVariant = "primary" | "secondary" | "outline";
|
|
6
|
-
export type ButtonSize = "sm" | "md" | "lg";
|
|
7
|
-
export type ButtonColor = "primary" | "error" | "success" | "warning" | "info";
|
|
4
|
+
import {ButtonColor, ButtonSize, ButtonVariant} from "./button.constants.js";
|
|
8
5
|
|
|
9
6
|
@customElement("st-button")
|
|
10
7
|
export class StButton extends LitElement {
|
|
@@ -12,210 +9,206 @@ export class StButton extends LitElement {
|
|
|
12
9
|
@property({type: String}) target: "_blank" | "_self" = "_self";
|
|
13
10
|
@property({type: Boolean, reflect: true}) disabled = false;
|
|
14
11
|
@property({type: Boolean, reflect: true}) loading = false;
|
|
15
|
-
@property({type: String, reflect: true}) variant: ButtonVariant = "
|
|
12
|
+
@property({type: String, reflect: true}) variant: ButtonVariant = "solid";
|
|
13
|
+
@property({type: String, reflect: true}) color: ButtonColor = "default";
|
|
16
14
|
@property({type: String, reflect: true}) size: ButtonSize = "md";
|
|
17
|
-
@property({type:
|
|
18
|
-
@property({
|
|
19
|
-
@property({
|
|
15
|
+
@property({type: Boolean, reflect: true}) active = false;
|
|
16
|
+
@property({type: String, attribute: "aria-label"}) ariaLabel: string | null = null;
|
|
17
|
+
@property({type: String, reflect: true}) type: "button" | "submit" | "reset" = "button";
|
|
18
|
+
@property({type: Boolean, reflect: true}) block = false;
|
|
20
19
|
|
|
21
20
|
static styles = [
|
|
22
21
|
resetStyles,
|
|
23
22
|
css`
|
|
24
23
|
:host {
|
|
25
|
-
/* ==========================================================
|
|
26
|
-
1. Base Palette (Defaults to Primary Theme)
|
|
27
|
-
========================================================== */
|
|
28
|
-
--_palette-base: var(--st-color-primary);
|
|
29
|
-
--_palette-hover: var(--st-color-primary-hover);
|
|
30
|
-
--_palette-surface: var(--st-color-surface);
|
|
31
|
-
--_palette-surface-hover: var(--st-color-border);
|
|
32
|
-
|
|
33
|
-
--_palette-text-on-base: var(--st-color-surface);
|
|
34
|
-
--_palette-text-on-surface: var(--st-color-text);
|
|
35
|
-
|
|
36
|
-
/* Sizing Tokens */
|
|
37
24
|
--_btn-padding: var(--st-spacing-sm) var(--st-spacing-md);
|
|
38
25
|
--_btn-font-size: var(--st-font-size-sm);
|
|
39
26
|
--_btn-radius: 4px;
|
|
40
27
|
--_btn-gap: var(--st-spacing-sm);
|
|
41
|
-
|
|
42
28
|
display: inline-block;
|
|
43
29
|
}
|
|
44
30
|
|
|
45
31
|
/* ==========================================================
|
|
46
|
-
|
|
32
|
+
VARIANT: SOLID (Filled background, contrasting text)
|
|
47
33
|
========================================================== */
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
--
|
|
51
|
-
--
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
--
|
|
60
|
-
--
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
--
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
:host([color="warning"]) {
|
|
67
|
-
--
|
|
68
|
-
--
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
--
|
|
72
|
-
--
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:host([
|
|
76
|
-
|
|
77
|
-
--_palette-hover: color-mix(in srgb, var(--st-color-info), black 15%);
|
|
78
|
-
--_palette-surface: var(--st-color-info-bg);
|
|
79
|
-
--_palette-surface-hover: color-mix(in srgb, var(--st-color-info-bg), black 10%);
|
|
80
|
-
--_palette-text-on-base: var(--st-white);
|
|
81
|
-
--_palette-text-on-surface: var(--st-color-info);
|
|
34
|
+
/* 'default' consumes surface-hover and text, which naturally invert */
|
|
35
|
+
:host([variant="solid"][color="default"]) {
|
|
36
|
+
--_bg: var(--st-color-surface-hover);
|
|
37
|
+
--_text: var(--st-color-text);
|
|
38
|
+
}
|
|
39
|
+
/* Semantic colors use the semantic token for bg, and the global app bg (white/dark gray) for text */
|
|
40
|
+
:host([variant="solid"][color="primary"]) {
|
|
41
|
+
--_bg: var(--st-color-primary);
|
|
42
|
+
--_text: var(--st-color-bg);
|
|
43
|
+
}
|
|
44
|
+
:host([variant="solid"][color="error"]) {
|
|
45
|
+
--_bg: var(--st-color-error);
|
|
46
|
+
--_text: var(--st-color-bg);
|
|
47
|
+
}
|
|
48
|
+
:host([variant="solid"][color="success"]) {
|
|
49
|
+
--_bg: var(--st-color-success);
|
|
50
|
+
--_text: var(--st-color-bg);
|
|
51
|
+
}
|
|
52
|
+
:host([variant="solid"][color="warning"]) {
|
|
53
|
+
--_bg: var(--st-color-warning);
|
|
54
|
+
--_text: var(--st-color-bg);
|
|
55
|
+
}
|
|
56
|
+
:host([variant="solid"][color="info"]) {
|
|
57
|
+
--_bg: var(--st-color-info);
|
|
58
|
+
--_text: var(--st-color-bg);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([variant="solid"]) .btn:hover {
|
|
62
|
+
filter: brightness(var(--st-hover-brightness, 0.9));
|
|
82
63
|
}
|
|
83
64
|
|
|
84
65
|
/* ==========================================================
|
|
85
|
-
|
|
66
|
+
VARIANT: OUTLINE (Transparent bg, semantic text/border)
|
|
86
67
|
========================================================== */
|
|
68
|
+
:host([variant="outline"]) {
|
|
69
|
+
--_bg: transparent;
|
|
70
|
+
}
|
|
71
|
+
:host([variant="outline"][color="default"]) {
|
|
72
|
+
--_border: var(--st-gray-500, #71717a);
|
|
73
|
+
--_text: var(--st-color-text);
|
|
74
|
+
}
|
|
75
|
+
:host([variant="outline"][color="primary"]) {
|
|
76
|
+
--_border: var(--st-color-primary-text);
|
|
77
|
+
--_text: var(--st-color-primary-text);
|
|
78
|
+
}
|
|
79
|
+
:host([variant="outline"][color="error"]) {
|
|
80
|
+
--_border: var(--st-color-error-text);
|
|
81
|
+
--_text: var(--st-color-error-text);
|
|
82
|
+
}
|
|
83
|
+
:host([variant="outline"][color="success"]) {
|
|
84
|
+
--_border: var(--st-color-success);
|
|
85
|
+
--_text: var(--st-color-success);
|
|
86
|
+
}
|
|
87
|
+
:host([variant="outline"][color="warning"]) {
|
|
88
|
+
--_border: var(--st-color-warning);
|
|
89
|
+
--_text: var(--st-color-warning);
|
|
90
|
+
}
|
|
91
|
+
:host([variant="outline"][color="info"]) {
|
|
92
|
+
--_border: var(--st-color-info-text);
|
|
93
|
+
--_text: var(--st-color-info-text);
|
|
94
|
+
}
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
--_btn-bg: var(--_palette-base);
|
|
91
|
-
--_btn-bg-hover: var(--_palette-hover);
|
|
92
|
-
--_btn-text: var(--_palette-text-on-base);
|
|
93
|
-
--_btn-border: transparent;
|
|
96
|
+
:host([variant="outline"]) .btn:hover {
|
|
97
|
+
background-color: var(--st-color-surface-hover);
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
/*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
--
|
|
101
|
-
--
|
|
100
|
+
/* ==========================================================
|
|
101
|
+
VARIANT: SECONDARY (Soft background, semantic text)
|
|
102
|
+
========================================================== */
|
|
103
|
+
:host([variant="secondary"][color="default"]) {
|
|
104
|
+
--_bg: var(--st-color-surface);
|
|
105
|
+
--_text: var(--st-color-text);
|
|
106
|
+
}
|
|
107
|
+
:host([variant="secondary"][color="primary"]) {
|
|
108
|
+
--_bg: var(--st-color-primary-bg);
|
|
109
|
+
--_text: var(--st-color-primary-text);
|
|
110
|
+
}
|
|
111
|
+
:host([variant="secondary"][color="error"]) {
|
|
112
|
+
--_bg: var(--st-color-error-bg);
|
|
113
|
+
--_text: var(--st-color-error-text);
|
|
114
|
+
}
|
|
115
|
+
:host([variant="secondary"][color="success"]) {
|
|
116
|
+
--_bg: var(--st-color-success-bg);
|
|
117
|
+
--_text: var(--st-color-success);
|
|
118
|
+
}
|
|
119
|
+
:host([variant="secondary"][color="warning"]) {
|
|
120
|
+
--_bg: var(--st-color-warning-bg);
|
|
121
|
+
--_text: var(--st-color-warning);
|
|
122
|
+
}
|
|
123
|
+
:host([variant="secondary"][color="info"]) {
|
|
124
|
+
--_bg: var(--st-color-info-bg);
|
|
125
|
+
--_text: var(--st-color-info-text);
|
|
102
126
|
}
|
|
103
127
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
--_btn-bg: transparent;
|
|
107
|
-
--_btn-bg-hover: var(--_palette-surface);
|
|
108
|
-
--_btn-text: var(--_palette-base);
|
|
109
|
-
--_btn-border: var(--_palette-base);
|
|
128
|
+
:host([variant="secondary"]) .btn:hover {
|
|
129
|
+
filter: brightness(var(--st-hover-brightness, 0.9));
|
|
110
130
|
}
|
|
111
131
|
|
|
112
132
|
/* ==========================================================
|
|
113
|
-
|
|
133
|
+
LAYOUT, SIZE & BASE APPLICATION
|
|
114
134
|
========================================================== */
|
|
135
|
+
:host([block]) {
|
|
136
|
+
display: block;
|
|
137
|
+
width: 100%;
|
|
138
|
+
}
|
|
139
|
+
:host([block]) .btn {
|
|
140
|
+
width: 100%;
|
|
141
|
+
}
|
|
142
|
+
|
|
115
143
|
:host([size="sm"]) {
|
|
116
144
|
--_btn-padding: var(--st-spacing-xs) var(--st-spacing-sm);
|
|
117
145
|
--_btn-font-size: var(--st-font-size-xs);
|
|
118
146
|
--_btn-radius: 2px;
|
|
119
147
|
--_btn-gap: var(--st-spacing-xs);
|
|
120
148
|
}
|
|
121
|
-
|
|
122
149
|
:host([size="lg"]) {
|
|
123
150
|
--_btn-padding: var(--st-spacing-md) var(--st-spacing-lg);
|
|
124
151
|
--_btn-font-size: var(--st-font-size-base);
|
|
125
152
|
--_btn-radius: 6px;
|
|
126
|
-
--_btn-gap: var(--st-spacing-sm);
|
|
127
153
|
}
|
|
128
154
|
|
|
129
|
-
/* ==========================================================
|
|
130
|
-
5. Base Button Rules
|
|
131
|
-
========================================================== */
|
|
132
155
|
.btn {
|
|
133
156
|
display: inline-flex;
|
|
134
157
|
align-items: center;
|
|
135
158
|
justify-content: center;
|
|
136
159
|
gap: var(--_btn-gap);
|
|
137
160
|
|
|
138
|
-
background-color: var(--
|
|
139
|
-
color: var(--
|
|
140
|
-
border: 1px solid var(--
|
|
161
|
+
background-color: var(--_bg);
|
|
162
|
+
color: var(--_text);
|
|
163
|
+
border: 1px solid var(--_border, transparent);
|
|
164
|
+
|
|
141
165
|
padding: var(--_btn-padding);
|
|
142
166
|
font-size: var(--_btn-font-size);
|
|
143
|
-
border-radius: var(--_btn-radius);
|
|
144
167
|
line-height: 1;
|
|
145
168
|
|
|
146
169
|
cursor: pointer;
|
|
147
|
-
font-weight: var(--st-font-weight-medium);
|
|
170
|
+
font-weight: var(--st-font-weight-medium, 500);
|
|
148
171
|
transition: all 0.2s ease;
|
|
149
|
-
|
|
172
|
+
text-decoration: none;
|
|
150
173
|
|
|
151
|
-
/* 1. Split the border radius into 4 independent corners */
|
|
152
174
|
border-radius: var(--btn-radius-tl, var(--st-radius-md, 0.5rem))
|
|
153
175
|
var(--btn-radius-tr, var(--st-radius-md, 0.5rem))
|
|
154
176
|
var(--btn-radius-br, var(--st-radius-md, 0.5rem))
|
|
155
177
|
var(--btn-radius-bl, var(--st-radius-md, 0.5rem));
|
|
156
|
-
|
|
157
|
-
/* 2. Add a hook for the group wrapper to inject a divider line */
|
|
158
|
-
box-shadow: var(--btn-divider, none);
|
|
159
|
-
|
|
160
|
-
font-weight: 500;
|
|
161
|
-
text-decoration: none;
|
|
162
|
-
border: 1px solid transparent;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.btn:hover {
|
|
166
|
-
color: var(--_btn-text);
|
|
167
|
-
background-color: var(--_btn-bg-hover);
|
|
168
178
|
}
|
|
169
179
|
|
|
170
|
-
/* ==========================================================
|
|
171
|
-
Logical Active States (Selected/Toggled)
|
|
172
|
-
========================================================== */
|
|
173
180
|
:host([active]) .btn {
|
|
174
181
|
filter: brightness(0.9);
|
|
175
182
|
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.2);
|
|
176
|
-
|
|
177
|
-
color: var(--_btn-text);
|
|
178
|
-
background-color: var(--_btn-bg-hover);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
:host([active]) .btn[color="primary"] {
|
|
182
|
-
filter: brightness(0.85);
|
|
183
|
-
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2); /* Inset shadow gives a pressed look */
|
|
183
|
+
background-color: var(--_bg); /* Retain base background */
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
/* ==========================================================
|
|
187
|
-
Focus State (Accessibility)
|
|
188
|
-
========================================================== */
|
|
189
|
-
/* focus-visible ensures this only shows for keyboard navigation, not mouse clicks */
|
|
190
186
|
.btn:focus-visible {
|
|
191
|
-
outline:
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
outline: none;
|
|
188
|
+
box-shadow:
|
|
189
|
+
0 0 0 2px var(--st-color-bg, #ffffff),
|
|
190
|
+
0 0 0 4px var(--st-color-primary);
|
|
191
|
+
z-index: 1;
|
|
194
192
|
}
|
|
195
193
|
|
|
196
|
-
/* ==========================================================
|
|
197
|
-
Physical Active State (Mouse down)
|
|
198
|
-
========================================================== */
|
|
199
194
|
.btn:active {
|
|
200
195
|
transform: scale(0.98);
|
|
201
196
|
}
|
|
202
197
|
|
|
203
|
-
/* Disabled & Loading */
|
|
204
198
|
:host([disabled]),
|
|
205
199
|
:host([loading]) {
|
|
206
200
|
pointer-events: none;
|
|
207
201
|
}
|
|
208
202
|
|
|
209
|
-
:host([disabled])
|
|
203
|
+
:host([disabled]) .btn {
|
|
210
204
|
opacity: 0.5;
|
|
211
205
|
cursor: not-allowed;
|
|
212
206
|
}
|
|
213
207
|
|
|
214
|
-
:host([loading])
|
|
208
|
+
:host([loading]) .btn {
|
|
215
209
|
opacity: 0.8;
|
|
216
210
|
}
|
|
217
211
|
|
|
218
|
-
/* Icons & Spinner */
|
|
219
212
|
::slotted(svg),
|
|
220
213
|
svg.spinner {
|
|
221
214
|
width: 1.25em;
|
|
@@ -239,39 +232,86 @@ export class StButton extends LitElement {
|
|
|
239
232
|
`,
|
|
240
233
|
];
|
|
241
234
|
|
|
235
|
+
disconnectedCallback() {
|
|
236
|
+
super.disconnectedCallback();
|
|
237
|
+
this.removeEventListener("click", this._handleClick);
|
|
238
|
+
}
|
|
239
|
+
|
|
242
240
|
render() {
|
|
243
241
|
const content = html`<slot></slot>`;
|
|
244
242
|
|
|
245
243
|
if (this.href) {
|
|
246
|
-
return html`<a
|
|
244
|
+
return html`<a
|
|
245
|
+
href="${this.href}"
|
|
246
|
+
target="${this.target}"
|
|
247
|
+
class="btn"
|
|
248
|
+
aria-label=${this.ariaLabel || nothing}
|
|
247
249
|
>${content}</a
|
|
248
250
|
>`;
|
|
249
251
|
}
|
|
250
252
|
|
|
253
|
+
// ADDED: Passing this.type to the native button element
|
|
251
254
|
return html`
|
|
252
|
-
<button
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
d="M12 19C15.866 19 19 15.866 19 12C19 8.13401 15.866 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"
|
|
261
|
-
fill="currentColor"
|
|
262
|
-
/>
|
|
263
|
-
<path
|
|
264
|
-
d="M2 12C2 6.47715 6.47715 2 12 2V5C8.13401 5 5 8.13401 5 12H2Z"
|
|
265
|
-
fill="currentColor"
|
|
266
|
-
/>
|
|
267
|
-
</svg>
|
|
268
|
-
`
|
|
269
|
-
: html`<slot name="prefix"></slot>`}
|
|
255
|
+
<button
|
|
256
|
+
class="btn"
|
|
257
|
+
type="${this.type}"
|
|
258
|
+
?disabled=${this.disabled || this.loading}
|
|
259
|
+
@click="${this._handleClick}"
|
|
260
|
+
>
|
|
261
|
+
${this.renderLoadingSpinner()}
|
|
262
|
+
${this.renderPrefixSlot()}
|
|
270
263
|
${content}
|
|
271
264
|
<slot name="suffix"></slot>
|
|
272
265
|
</button>
|
|
273
266
|
`;
|
|
274
267
|
}
|
|
268
|
+
|
|
269
|
+
private renderLoadingSpinner() {
|
|
270
|
+
if (!this.loading) {
|
|
271
|
+
return html``;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return html`<svg class="spinner" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
275
|
+
<path
|
|
276
|
+
opacity="0.2"
|
|
277
|
+
fill-rule="evenodd"
|
|
278
|
+
clip-rule="evenodd"
|
|
279
|
+
d="M12 19C15.866 19 19 15.866 19 12C19 8.13401 15.866 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"
|
|
280
|
+
fill="currentColor"
|
|
281
|
+
/>
|
|
282
|
+
<path d="M2 12C2 6.47715 6.47715 2 12 2V5C8.13401 5 5 8.13401 5 12H2Z" fill="currentColor" />
|
|
283
|
+
</svg>`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private renderPrefixSlot() {
|
|
287
|
+
if (this.loading) {
|
|
288
|
+
return html``;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return html`<slot name="prefix"></slot>`;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private _handleClick(e: MouseEvent) {
|
|
295
|
+
if (this.disabled || this.loading) {
|
|
296
|
+
e.preventDefault();
|
|
297
|
+
e.stopPropagation();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (this.type === "submit") {
|
|
302
|
+
const form = this.closest("form");
|
|
303
|
+
if (form) {
|
|
304
|
+
e.preventDefault(); // Prevent duplicate events
|
|
305
|
+
form.requestSubmit(); // Natively triggers the form's submit event and validation
|
|
306
|
+
}
|
|
307
|
+
} else if (this.type === "reset") {
|
|
308
|
+
const form = this.closest("form");
|
|
309
|
+
if (form) {
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
form.reset();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
275
315
|
}
|
|
276
316
|
|
|
277
317
|
declare global {
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|