@sondor-technology/sondor-components 1.0.1-develop.13 → 1.0.1-develop.14

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.
Files changed (226) hide show
  1. package/dist/components/alert/alert.constants.d.ts +3 -0
  2. package/dist/components/alert/alert.constants.d.ts.map +1 -0
  3. package/dist/components/alert/alert.constants.js +2 -0
  4. package/dist/components/alert/alert.constants.js.map +1 -0
  5. package/dist/components/alert/alert.d.ts +4 -3
  6. package/dist/components/alert/alert.d.ts.map +1 -1
  7. package/dist/components/alert/alert.js +21 -11
  8. package/dist/components/alert/alert.js.map +1 -0
  9. package/dist/components/badge/badge.constants.d.ts +3 -0
  10. package/dist/components/badge/badge.constants.d.ts.map +1 -0
  11. package/dist/components/badge/badge.constants.js +2 -0
  12. package/dist/components/badge/badge.constants.js.map +1 -0
  13. package/dist/components/badge/badge.d.ts +1 -1
  14. package/dist/components/badge/badge.d.ts.map +1 -1
  15. package/dist/components/badge/badge.js +3 -2
  16. package/dist/components/badge/badge.js.map +1 -0
  17. package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
  18. package/dist/components/breadcrumb/breadcrumb.js +2 -1
  19. package/dist/components/breadcrumb/breadcrumb.js.map +1 -0
  20. package/dist/components/button/button.constants.d.ts +7 -0
  21. package/dist/components/button/button.constants.d.ts.map +1 -0
  22. package/dist/components/button/button.constants.js +4 -0
  23. package/dist/components/button/button.constants.js.map +1 -0
  24. package/dist/components/button/button.d.ts +8 -4
  25. package/dist/components/button/button.d.ts.map +1 -1
  26. package/dist/components/button/button.js +181 -137
  27. package/dist/components/button/button.js.map +1 -0
  28. package/dist/components/button-group/button-group.d.ts +1 -0
  29. package/dist/components/button-group/button-group.d.ts.map +1 -1
  30. package/dist/components/button-group/button-group.js +17 -21
  31. package/dist/components/button-group/button-group.js.map +1 -0
  32. package/dist/components/checkbox/checkbox.constants.d.ts +3 -0
  33. package/dist/components/checkbox/checkbox.constants.d.ts.map +1 -0
  34. package/dist/components/checkbox/checkbox.constants.js +2 -0
  35. package/dist/components/checkbox/checkbox.constants.js.map +1 -0
  36. package/dist/components/checkbox/checkbox.d.ts +5 -1
  37. package/dist/components/checkbox/checkbox.d.ts.map +1 -1
  38. package/dist/components/checkbox/checkbox.js +21 -5
  39. package/dist/components/checkbox/checkbox.js.map +1 -0
  40. package/dist/components/code-block/code-block.d.ts +7 -7
  41. package/dist/components/code-block/code-block.d.ts.map +1 -1
  42. package/dist/components/code-block/code-block.js +130 -66
  43. package/dist/components/code-block/code-block.js.map +1 -0
  44. package/dist/components/content-card/content-card.d.ts.map +1 -1
  45. package/dist/components/content-card/content-card.js +10 -15
  46. package/dist/components/content-card/content-card.js.map +1 -0
  47. package/dist/components/divider/divider.constants.d.ts +5 -0
  48. package/dist/components/divider/divider.constants.d.ts.map +1 -0
  49. package/dist/components/divider/divider.constants.js +3 -0
  50. package/dist/components/divider/divider.constants.js.map +1 -0
  51. package/dist/components/divider/divider.d.ts +4 -2
  52. package/dist/components/divider/divider.d.ts.map +1 -1
  53. package/dist/components/divider/divider.js +18 -9
  54. package/dist/components/divider/divider.js.map +1 -0
  55. package/dist/components/drawer/drawer.d.ts +7 -4
  56. package/dist/components/drawer/drawer.d.ts.map +1 -1
  57. package/dist/components/drawer/drawer.js +73 -30
  58. package/dist/components/drawer/drawer.js.map +1 -0
  59. package/dist/components/field/field.d.ts +2 -2
  60. package/dist/components/field/field.d.ts.map +1 -1
  61. package/dist/components/field/field.js +8 -9
  62. package/dist/components/field/field.js.map +1 -0
  63. package/dist/components/footer/footer.d.ts +8 -1
  64. package/dist/components/footer/footer.d.ts.map +1 -1
  65. package/dist/components/footer/footer.js +42 -12
  66. package/dist/components/footer/footer.js.map +1 -0
  67. package/dist/components/form/form-step.js +1 -0
  68. package/dist/components/form/form-step.js.map +1 -0
  69. package/dist/components/form/form.d.ts +3 -0
  70. package/dist/components/form/form.d.ts.map +1 -1
  71. package/dist/components/form/form.js +109 -69
  72. package/dist/components/form/form.js.map +1 -0
  73. package/dist/components/grid/grid-row.d.ts +3 -3
  74. package/dist/components/grid/grid-row.d.ts.map +1 -1
  75. package/dist/components/grid/grid-row.js +36 -22
  76. package/dist/components/grid/grid-row.js.map +1 -0
  77. package/dist/components/grid/grid.d.ts +2 -2
  78. package/dist/components/grid/grid.d.ts.map +1 -1
  79. package/dist/components/grid/grid.js +5 -2
  80. package/dist/components/grid/grid.js.map +1 -0
  81. package/dist/components/icon/icon-paths.d.ts +161 -86
  82. package/dist/components/icon/icon-paths.d.ts.map +1 -1
  83. package/dist/components/icon/icon-paths.js +176 -106
  84. package/dist/components/icon/icon-paths.js.map +1 -0
  85. package/dist/components/icon/icon.d.ts +1 -1
  86. package/dist/components/icon/icon.d.ts.map +1 -1
  87. package/dist/components/icon/icon.js +6 -5
  88. package/dist/components/icon/icon.js.map +1 -0
  89. package/dist/components/input/input.d.ts +9 -0
  90. package/dist/components/input/input.d.ts.map +1 -1
  91. package/dist/components/input/input.js +30 -37
  92. package/dist/components/input/input.js.map +1 -0
  93. package/dist/components/link/link.d.ts +6 -6
  94. package/dist/components/link/link.d.ts.map +1 -1
  95. package/dist/components/link/link.js +42 -19
  96. package/dist/components/link/link.js.map +1 -0
  97. package/dist/components/metadata/metadata.d.ts +3 -3
  98. package/dist/components/metadata/metadata.d.ts.map +1 -1
  99. package/dist/components/metadata/metadata.js +23 -20
  100. package/dist/components/metadata/metadata.js.map +1 -0
  101. package/dist/components/modal/modal.d.ts +4 -16
  102. package/dist/components/modal/modal.d.ts.map +1 -1
  103. package/dist/components/modal/modal.js +99 -62
  104. package/dist/components/modal/modal.js.map +1 -0
  105. package/dist/components/page-layout/page-layout.d.ts +4 -3
  106. package/dist/components/page-layout/page-layout.d.ts.map +1 -1
  107. package/dist/components/page-layout/page-layout.js +95 -68
  108. package/dist/components/page-layout/page-layout.js.map +1 -0
  109. package/dist/components/radio/radio.d.ts +8 -0
  110. package/dist/components/radio/radio.d.ts.map +1 -1
  111. package/dist/components/radio/radio.js +8 -12
  112. package/dist/components/radio/radio.js.map +1 -0
  113. package/dist/components/radio-group/radio-group.d.ts +6 -1
  114. package/dist/components/radio-group/radio-group.d.ts.map +1 -1
  115. package/dist/components/radio-group/radio-group.js +44 -18
  116. package/dist/components/radio-group/radio-group.js.map +1 -0
  117. package/dist/components/router/router.d.ts +5 -7
  118. package/dist/components/router/router.d.ts.map +1 -1
  119. package/dist/components/router/router.js +54 -38
  120. package/dist/components/router/router.js.map +1 -0
  121. package/dist/components/select/select.d.ts +1 -3
  122. package/dist/components/select/select.d.ts.map +1 -1
  123. package/dist/components/select/select.js +14 -5
  124. package/dist/components/select/select.js.map +1 -0
  125. package/dist/components/skeleton/skeleton.d.ts +3 -2
  126. package/dist/components/skeleton/skeleton.d.ts.map +1 -1
  127. package/dist/components/skeleton/skeleton.js +10 -13
  128. package/dist/components/skeleton/skeleton.js.map +1 -0
  129. package/dist/components/switch/switch.d.ts +12 -0
  130. package/dist/components/switch/switch.d.ts.map +1 -1
  131. package/dist/components/switch/switch.js +28 -22
  132. package/dist/components/switch/switch.js.map +1 -0
  133. package/dist/components/table/data-table.d.ts +3 -25
  134. package/dist/components/table/data-table.d.ts.map +1 -1
  135. package/dist/components/table/data-table.js +211 -146
  136. package/dist/components/table/data-table.js.map +1 -0
  137. package/dist/components/table/table.d.ts +3 -3
  138. package/dist/components/table/table.d.ts.map +1 -1
  139. package/dist/components/table/table.js +39 -20
  140. package/dist/components/table/table.js.map +1 -0
  141. package/dist/components/tabs/tab-panel.d.ts +3 -1
  142. package/dist/components/tabs/tab-panel.d.ts.map +1 -1
  143. package/dist/components/tabs/tab-panel.js +21 -11
  144. package/dist/components/tabs/tab-panel.js.map +1 -0
  145. package/dist/components/tabs/tab.d.ts +5 -1
  146. package/dist/components/tabs/tab.d.ts.map +1 -1
  147. package/dist/components/tabs/tab.js +46 -28
  148. package/dist/components/tabs/tab.js.map +1 -0
  149. package/dist/components/tabs/tabs.d.ts +4 -0
  150. package/dist/components/tabs/tabs.d.ts.map +1 -1
  151. package/dist/components/tabs/tabs.js +76 -13
  152. package/dist/components/tabs/tabs.js.map +1 -0
  153. package/dist/components/textarea/textarea.d.ts +13 -0
  154. package/dist/components/textarea/textarea.d.ts.map +1 -1
  155. package/dist/components/textarea/textarea.js +59 -13
  156. package/dist/components/textarea/textarea.js.map +1 -0
  157. package/dist/components/theme-toggle/theme-toggle.constants.d.ts +3 -0
  158. package/dist/components/theme-toggle/theme-toggle.constants.d.ts.map +1 -0
  159. package/dist/components/theme-toggle/theme-toggle.constants.js +2 -0
  160. package/dist/components/theme-toggle/theme-toggle.constants.js.map +1 -0
  161. package/dist/components/theme-toggle/theme-toggle.d.ts +3 -2
  162. package/dist/components/theme-toggle/theme-toggle.d.ts.map +1 -1
  163. package/dist/components/theme-toggle/theme-toggle.js +46 -19
  164. package/dist/components/theme-toggle/theme-toggle.js.map +1 -0
  165. package/dist/components/vertical-nav/vertical-nav-group.d.ts +5 -2
  166. package/dist/components/vertical-nav/vertical-nav-group.d.ts.map +1 -1
  167. package/dist/components/vertical-nav/vertical-nav-group.js +50 -14
  168. package/dist/components/vertical-nav/vertical-nav-group.js.map +1 -0
  169. package/dist/components/vertical-nav/vertical-nav-item.d.ts +3 -2
  170. package/dist/components/vertical-nav/vertical-nav-item.d.ts.map +1 -1
  171. package/dist/components/vertical-nav/vertical-nav-item.js +30 -8
  172. package/dist/components/vertical-nav/vertical-nav-item.js.map +1 -0
  173. package/dist/styles/index.css +48 -17
  174. package/dist/styles/reset.js +1 -0
  175. package/dist/styles/reset.js.map +1 -0
  176. package/package.json +2 -1
  177. package/src/components/alert/alert.constants.ts +2 -0
  178. package/src/components/alert/alert.ts +24 -15
  179. package/src/components/badge/badge.constants.ts +2 -0
  180. package/src/components/badge/badge.ts +3 -4
  181. package/src/components/breadcrumb/breadcrumb.ts +2 -2
  182. package/src/components/button/button.constants.ts +8 -0
  183. package/src/components/button/button.ts +184 -144
  184. package/src/components/button-group/button-group.ts +18 -22
  185. package/src/components/checkbox/checkbox.constants.ts +2 -0
  186. package/src/components/checkbox/checkbox.ts +33 -18
  187. package/src/components/code-block/code-block.ts +151 -84
  188. package/src/components/content-card/content-card.ts +10 -16
  189. package/src/components/divider/divider.constants.ts +5 -0
  190. package/src/components/divider/divider.ts +22 -11
  191. package/src/components/drawer/drawer.ts +79 -34
  192. package/src/components/field/field.ts +9 -11
  193. package/src/components/footer/footer.ts +43 -12
  194. package/src/components/form/form.ts +121 -84
  195. package/src/components/grid/grid-row.ts +45 -32
  196. package/src/components/grid/grid.ts +7 -4
  197. package/src/components/icon/icon-paths.ts +175 -106
  198. package/src/components/icon/icon.ts +6 -6
  199. package/src/components/input/input.ts +32 -42
  200. package/src/components/link/link.ts +45 -21
  201. package/src/components/metadata/metadata.ts +26 -24
  202. package/src/components/modal/modal.ts +108 -74
  203. package/src/components/page-layout/page-layout.ts +97 -72
  204. package/src/components/radio/radio.ts +8 -13
  205. package/src/components/radio-group/radio-group.ts +45 -21
  206. package/src/components/router/router.ts +73 -50
  207. package/src/components/select/select.ts +18 -19
  208. package/src/components/skeleton/skeleton.ts +14 -14
  209. package/src/components/switch/switch.ts +31 -25
  210. package/src/components/table/data-table.ts +248 -177
  211. package/src/components/table/table.ts +52 -29
  212. package/src/components/tabs/tab-panel.ts +25 -13
  213. package/src/components/tabs/tab.ts +58 -33
  214. package/src/components/tabs/tabs.ts +77 -15
  215. package/src/components/textarea/textarea.ts +63 -15
  216. package/src/components/theme-toggle/theme-toggle.constants.ts +2 -0
  217. package/src/components/theme-toggle/theme-toggle.ts +47 -22
  218. package/src/components/vertical-nav/vertical-nav-group.ts +57 -18
  219. package/src/components/vertical-nav/vertical-nav-item.ts +35 -12
  220. package/src/styles/globals.css +27 -4
  221. package/src/styles/theme.css +38 -32
  222. package/tsconfig.json +2 -1
  223. package/dist/components/card/card.d.ts +0 -11
  224. package/dist/components/card/card.d.ts.map +0 -1
  225. package/dist/components/card/card.js +0 -54
  226. 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 = "primary";
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: String, reflect: true}) color: ButtonColor = "primary";
18
- @property({ type: Boolean, reflect: true }) active = false;
19
- @property({ type: String, attribute: 'aria-label' }) ariaLabel: string | null = null;
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
- 2. Semantic Color Overrides (Swaps the active palette)
32
+ VARIANT: SOLID (Filled background, contrasting text)
47
33
  ========================================================== */
48
- :host([color="error"]) {
49
- --_palette-base: var(--st-color-error);
50
- --_palette-hover: color-mix(in srgb, var(--st-color-error), black 15%);
51
- --_palette-surface: var(--st-color-error-bg);
52
- --_palette-surface-hover: color-mix(in srgb, var(--st-color-error-bg), black 10%);
53
- --_palette-text-on-base: var(--st-white); /* Force white text */
54
- --_palette-text-on-surface: var(--st-color-error);
55
- }
56
-
57
- :host([color="success"]) {
58
- --_palette-base: var(--st-color-success);
59
- --_palette-hover: color-mix(in srgb, var(--st-color-success), black 15%);
60
- --_palette-surface: var(--st-color-success-bg);
61
- --_palette-surface-hover: color-mix(in srgb, var(--st-color-success-bg), black 10%);
62
- --_palette-text-on-base: var(--st-white);
63
- --_palette-text-on-surface: var(--st-color-success);
64
- }
65
-
66
- :host([color="warning"]) {
67
- --_palette-base: var(--st-color-warning);
68
- --_palette-hover: color-mix(in srgb, var(--st-color-warning), black 15%);
69
- --_palette-surface: var(--st-color-warning-bg);
70
- --_palette-surface-hover: color-mix(in srgb, var(--st-color-warning-bg), black 10%);
71
- --_palette-text-on-base: var(--st-gray-900); /* Amber needs dark text for contrast */
72
- --_palette-text-on-surface: var(--st-color-warning);
73
- }
74
-
75
- :host([color="info"]) {
76
- --_palette-base: var(--st-color-info);
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
- 3. Visual Variants (Consumes the active palette)
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
- /* Base (Primary / Solid) */
89
- :host {
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
- /* Secondary Variant */
97
- :host([variant="secondary"]) {
98
- --_btn-bg: var(--_palette-surface);
99
- --_btn-bg-hover: var(--_palette-surface-hover);
100
- --_btn-text: var(--_palette-text-on-surface);
101
- --_btn-border: transparent;
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
- /* Outline Variant */
105
- :host([variant="outline"]) {
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
- 4. Size Variants
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(--_btn-bg);
139
- color: var(--_btn-text);
140
- border: 1px solid var(--_btn-border);
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
- padding: 0.5rem 1rem;
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
- border-color: transparent;
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: 2px solid var(--st-color-primary);
192
- outline-offset: 2px;
193
- z-index: 1; /* Pulls the focused button forward if it's in a button group */
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]) button {
203
+ :host([disabled]) .btn {
210
204
  opacity: 0.5;
211
205
  cursor: not-allowed;
212
206
  }
213
207
 
214
- :host([loading]) button {
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 href="${this.href}" target="${this.target}" class="btn" color="${this.color}" aria-label=${this.ariaLabel || nothing}
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 class="btn" ?disabled=${this.disabled || this.loading}>
253
- ${this.loading
254
- ? html`
255
- <svg class="spinner" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
256
- <path
257
- opacity="0.2"
258
- fill-rule="evenodd"
259
- clip-rule="evenodd"
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 hiding the left border of adjacent default buttons */
41
- ::slotted(st-button[color="default"]:not(:first-child)) {
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. Prevent Primary buttons from overlapping at all, use box-shadow for the divider */
46
- ::slotted(st-button[color="primary"]:not(:first-child)) {
47
- --btn-divider: inset 1px 0 0 0 rgba(255, 255, 255, 0.3);
48
- margin-left: 0; /* Override any inherited negative margins */
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,2 @@
1
+ export const checkboxSizes = ["sm", "md", "lg"] as const;
2
+ export type CheckboxSize = (typeof checkboxSizes)[number];
@@ -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: "sm" | "md" | "lg" = "md";
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('focusout', () => {
31
+ this.addEventListener("focusout", () => {
31
32
  this.invalid = !this.checkValidity();
32
33
  });
33
34
 
34
- this.addEventListener('invalid', () => {
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 (changedProperties.has("checked") || changedProperties.has("value") || changedProperties.has("errorMessage")) {
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 = this.errorMessage || this._inputEl.validationMessage || "Please check this box if you want to proceed.";
168
- this._internals.setValidity(
169
- {valueMissing: true},
170
- message,
171
- this._inputEl,
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 = this.errorMessage || this._inputEl.validationMessage || "Please check this box if you want to proceed.";
187
- this._internals.setValidity(
188
- {valueMissing: true},
189
- message,
190
- this._inputEl,
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
+ }