mtrl 0.2.5 → 0.2.7

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 (196) hide show
  1. package/index.ts +18 -0
  2. package/package.json +1 -1
  3. package/src/components/badge/_styles.scss +123 -115
  4. package/src/components/badge/api.ts +57 -59
  5. package/src/components/badge/badge.ts +16 -2
  6. package/src/components/badge/config.ts +65 -11
  7. package/src/components/badge/constants.ts +22 -12
  8. package/src/components/badge/features.ts +44 -40
  9. package/src/components/badge/types.ts +42 -30
  10. package/src/components/bottom-app-bar/_styles.scss +103 -0
  11. package/src/components/bottom-app-bar/bottom-app-bar.ts +196 -0
  12. package/src/components/bottom-app-bar/config.ts +73 -0
  13. package/src/components/bottom-app-bar/index.ts +11 -0
  14. package/src/components/bottom-app-bar/types.ts +108 -0
  15. package/src/components/button/_styles.scss +0 -66
  16. package/src/components/button/api.ts +5 -0
  17. package/src/components/button/button.ts +0 -2
  18. package/src/components/button/config.ts +5 -0
  19. package/src/components/button/constants.ts +0 -6
  20. package/src/components/button/index.ts +2 -2
  21. package/src/components/button/types.ts +7 -7
  22. package/src/components/card/_styles.scss +67 -25
  23. package/src/components/card/api.ts +54 -3
  24. package/src/components/card/card.ts +25 -6
  25. package/src/components/card/config.ts +189 -22
  26. package/src/components/card/constants.ts +20 -19
  27. package/src/components/card/content.ts +299 -2
  28. package/src/components/card/features.ts +158 -4
  29. package/src/components/card/index.ts +31 -9
  30. package/src/components/card/types.ts +166 -15
  31. package/src/components/checkbox/_styles.scss +0 -2
  32. package/src/components/chip/chip.ts +1 -9
  33. package/src/components/chip/constants.ts +0 -10
  34. package/src/components/chip/index.ts +1 -1
  35. package/src/components/chip/types.ts +1 -4
  36. package/src/components/datepicker/_styles.scss +358 -0
  37. package/src/components/datepicker/api.ts +272 -0
  38. package/src/components/datepicker/config.ts +144 -0
  39. package/src/components/datepicker/constants.ts +98 -0
  40. package/src/components/datepicker/datepicker.ts +346 -0
  41. package/src/components/datepicker/index.ts +9 -0
  42. package/src/components/datepicker/render.ts +452 -0
  43. package/src/components/datepicker/types.ts +268 -0
  44. package/src/components/datepicker/utils.ts +290 -0
  45. package/src/components/dialog/_styles.scss +174 -128
  46. package/src/components/dialog/api.ts +48 -13
  47. package/src/components/dialog/config.ts +9 -5
  48. package/src/components/dialog/dialog.ts +6 -3
  49. package/src/components/dialog/features.ts +290 -130
  50. package/src/components/dialog/types.ts +7 -4
  51. package/src/components/divider/_styles.scss +57 -0
  52. package/src/components/divider/config.ts +81 -0
  53. package/src/components/divider/divider.ts +37 -0
  54. package/src/components/divider/features.ts +207 -0
  55. package/src/components/divider/index.ts +5 -0
  56. package/src/components/divider/types.ts +55 -0
  57. package/src/components/extended-fab/_styles.scss +267 -0
  58. package/src/components/extended-fab/api.ts +141 -0
  59. package/src/components/extended-fab/config.ts +108 -0
  60. package/src/components/extended-fab/constants.ts +36 -0
  61. package/src/components/extended-fab/extended-fab.ts +125 -0
  62. package/src/components/extended-fab/index.ts +4 -0
  63. package/src/components/extended-fab/types.ts +287 -0
  64. package/src/components/fab/_styles.scss +225 -0
  65. package/src/components/fab/api.ts +97 -0
  66. package/src/components/fab/config.ts +94 -0
  67. package/src/components/fab/constants.ts +41 -0
  68. package/src/components/fab/fab.ts +67 -0
  69. package/src/components/fab/index.ts +4 -0
  70. package/src/components/fab/types.ts +234 -0
  71. package/src/components/navigation/_styles.scss +1 -0
  72. package/src/components/navigation/api.ts +78 -50
  73. package/src/components/navigation/features/items.ts +280 -0
  74. package/src/components/navigation/nav-item.ts +72 -23
  75. package/src/components/navigation/navigation.ts +54 -2
  76. package/src/components/navigation/types.ts +210 -188
  77. package/src/components/progress/_styles.scss +0 -65
  78. package/src/components/progress/config.ts +1 -2
  79. package/src/components/progress/constants.ts +0 -14
  80. package/src/components/progress/index.ts +1 -1
  81. package/src/components/progress/progress.ts +1 -4
  82. package/src/components/progress/types.ts +1 -4
  83. package/src/components/radios/_styles.scss +0 -45
  84. package/src/components/radios/api.ts +85 -60
  85. package/src/components/radios/config.ts +1 -2
  86. package/src/components/radios/constants.ts +0 -9
  87. package/src/components/radios/index.ts +1 -1
  88. package/src/components/radios/radio.ts +34 -11
  89. package/src/components/radios/radios.ts +2 -1
  90. package/src/components/radios/types.ts +1 -7
  91. package/src/components/search/_styles.scss +306 -0
  92. package/src/components/search/api.ts +203 -0
  93. package/src/components/search/config.ts +87 -0
  94. package/src/components/search/constants.ts +21 -0
  95. package/src/components/search/features/index.ts +4 -0
  96. package/src/components/search/features/search.ts +718 -0
  97. package/src/components/search/features/states.ts +165 -0
  98. package/src/components/search/features/structure.ts +198 -0
  99. package/src/components/search/index.ts +10 -0
  100. package/src/components/search/search.ts +52 -0
  101. package/src/components/search/types.ts +163 -0
  102. package/src/components/segmented-button/_styles.scss +117 -0
  103. package/src/components/segmented-button/config.ts +67 -0
  104. package/src/components/segmented-button/constants.ts +42 -0
  105. package/src/components/segmented-button/index.ts +4 -0
  106. package/src/components/segmented-button/segment.ts +155 -0
  107. package/src/components/segmented-button/segmented-button.ts +250 -0
  108. package/src/components/segmented-button/types.ts +219 -0
  109. package/src/components/slider/_styles.scss +221 -168
  110. package/src/components/slider/accessibility.md +59 -0
  111. package/src/components/slider/api.ts +41 -120
  112. package/src/components/slider/config.ts +51 -49
  113. package/src/components/slider/features/handlers.ts +495 -0
  114. package/src/components/slider/features/index.ts +1 -2
  115. package/src/components/slider/features/slider.ts +66 -84
  116. package/src/components/slider/features/states.ts +195 -0
  117. package/src/components/slider/features/structure.ts +141 -184
  118. package/src/components/slider/features/ui.ts +150 -201
  119. package/src/components/slider/index.ts +2 -11
  120. package/src/components/slider/slider.ts +9 -12
  121. package/src/components/slider/types.ts +39 -24
  122. package/src/components/switch/_styles.scss +0 -2
  123. package/src/components/tabs/_styles.scss +346 -154
  124. package/src/components/tabs/api.ts +178 -400
  125. package/src/components/tabs/config.ts +46 -52
  126. package/src/components/tabs/constants.ts +85 -8
  127. package/src/components/tabs/features.ts +403 -0
  128. package/src/components/tabs/index.ts +60 -3
  129. package/src/components/tabs/indicator.ts +285 -0
  130. package/src/components/tabs/responsive.ts +144 -0
  131. package/src/components/tabs/scroll-indicators.ts +149 -0
  132. package/src/components/tabs/state.ts +186 -0
  133. package/src/components/tabs/tab-api.ts +258 -0
  134. package/src/components/tabs/tab.ts +255 -0
  135. package/src/components/tabs/tabs.ts +50 -31
  136. package/src/components/tabs/types.ts +332 -128
  137. package/src/components/tabs/utils.ts +107 -0
  138. package/src/components/textfield/_styles.scss +0 -98
  139. package/src/components/textfield/config.ts +2 -3
  140. package/src/components/textfield/constants.ts +0 -14
  141. package/src/components/textfield/index.ts +2 -2
  142. package/src/components/textfield/textfield.ts +0 -2
  143. package/src/components/textfield/types.ts +1 -4
  144. package/src/components/timepicker/README.md +277 -0
  145. package/src/components/timepicker/_styles.scss +451 -0
  146. package/src/components/timepicker/api.ts +632 -0
  147. package/src/components/timepicker/clockdial.ts +482 -0
  148. package/src/components/timepicker/config.ts +130 -0
  149. package/src/components/timepicker/constants.ts +138 -0
  150. package/src/components/timepicker/index.ts +8 -0
  151. package/src/components/timepicker/render.ts +613 -0
  152. package/src/components/timepicker/timepicker.ts +117 -0
  153. package/src/components/timepicker/types.ts +336 -0
  154. package/src/components/timepicker/utils.ts +241 -0
  155. package/src/components/top-app-bar/_styles.scss +225 -0
  156. package/src/components/top-app-bar/config.ts +83 -0
  157. package/src/components/top-app-bar/index.ts +11 -0
  158. package/src/components/top-app-bar/top-app-bar.ts +316 -0
  159. package/src/components/top-app-bar/types.ts +140 -0
  160. package/src/core/build/_ripple.scss +6 -6
  161. package/src/core/build/ripple.ts +72 -95
  162. package/src/core/compose/component.ts +1 -1
  163. package/src/core/compose/features/badge.ts +79 -0
  164. package/src/core/compose/features/icon.ts +3 -1
  165. package/src/core/compose/features/index.ts +3 -1
  166. package/src/core/compose/features/ripple.ts +4 -1
  167. package/src/core/compose/features/textlabel.ts +26 -2
  168. package/src/core/dom/create.ts +5 -0
  169. package/src/index.ts +9 -0
  170. package/src/styles/abstract/_theme.scss +115 -3
  171. package/src/styles/themes/_autumn.scss +21 -0
  172. package/src/styles/themes/_base-theme.scss +61 -0
  173. package/src/styles/themes/_baseline.scss +58 -0
  174. package/src/styles/themes/_bluekhaki.scss +125 -0
  175. package/src/styles/themes/_brownbeige.scss +125 -0
  176. package/src/styles/themes/_browngreen.scss +125 -0
  177. package/src/styles/themes/_forest.scss +6 -0
  178. package/src/styles/themes/_greenbeige.scss +125 -0
  179. package/src/styles/themes/_material.scss +125 -0
  180. package/src/styles/themes/_ocean.scss +6 -0
  181. package/src/styles/themes/_sageivory.scss +125 -0
  182. package/src/styles/themes/_spring.scss +6 -0
  183. package/src/styles/themes/_summer.scss +5 -0
  184. package/src/styles/themes/_sunset.scss +5 -0
  185. package/src/styles/themes/_tealcaramel.scss +125 -0
  186. package/src/styles/themes/_winter.scss +6 -0
  187. package/src/components/card/actions.ts +0 -48
  188. package/src/components/card/header.ts +0 -88
  189. package/src/components/card/media.ts +0 -52
  190. package/src/components/navigation/features/items.js +0 -192
  191. package/src/components/slider/features/appearance.ts +0 -94
  192. package/src/components/slider/features/disabled.ts +0 -43
  193. package/src/components/slider/features/events.ts +0 -164
  194. package/src/components/slider/features/interactions.ts +0 -261
  195. package/src/components/slider/features/keyboard.ts +0 -112
  196. package/src/core/collection/adapters/mongodb.js +0 -232
@@ -35,6 +35,9 @@
35
35
  --#{$prefix}-sys-color-outline: #727970;
36
36
  --#{$prefix}-sys-color-outline-variant: #C1C9BE;
37
37
 
38
+ // Include status colors for light theme
39
+ @include status-colors-light();
40
+
38
41
  &[data-theme-mode="dark"] {
39
42
  // Key colors
40
43
  --#{$prefix}-sys-color-primary: #79DC80;
@@ -67,5 +70,8 @@
67
70
 
68
71
  --#{$prefix}-sys-color-outline: #8B9388;
69
72
  --#{$prefix}-sys-color-outline-variant: #424940;
73
+
74
+ // Include status colors for dark theme
75
+ @include status-colors-dark();
70
76
  }
71
77
  }
@@ -41,6 +41,9 @@
41
41
  --#{$prefix}-sys-color-outline: #827568;
42
42
  --#{$prefix}-sys-color-outline-variant: #D5C8B9;
43
43
 
44
+ // Include status colors for light theme
45
+ @include status-colors-light();
46
+
44
47
  &[data-theme-mode="dark"] {
45
48
  // Key colors - darker but still vibrant
46
49
  --#{$prefix}-sys-color-primary: #9ECAFF;
@@ -78,5 +81,7 @@
78
81
 
79
82
  --#{$prefix}-sys-color-outline: #9E8F80;
80
83
  --#{$prefix}-sys-color-outline-variant: #50453B;
84
+ // Include status colors for dark theme
85
+ @include status-colors-dark();
81
86
  }
82
87
  }
@@ -35,6 +35,9 @@
35
35
  --#{$prefix}-sys-color-outline: #85736D;
36
36
  --#{$prefix}-sys-color-outline-variant: #D8C2BB;
37
37
 
38
+ // Include status colors for light theme
39
+ @include status-colors-light();
40
+
38
41
  &[data-theme-mode="dark"] {
39
42
  --#{$prefix}-sys-color-primary: #FFB686;
40
43
  --#{$prefix}-sys-color-on-primary: #5C2800;
@@ -51,5 +54,7 @@
51
54
  --#{$prefix}-sys-color-surface-container: #2B1714;
52
55
 
53
56
  --#{$prefix}-sys-color-outline: #B89784;
57
+ // Include status colors for dark theme
58
+ @include status-colors-dark();
54
59
  }
55
60
  }
@@ -0,0 +1,125 @@
1
+ // src/styles/themes/_tealcaramel.scss
2
+ @use '../abstract/base' as *;
3
+ @use 'base-theme' as *;
4
+
5
+ @include create-theme('tealcaramel') {
6
+ // Key colors based on teal and caramel combination
7
+ --#{$prefix}-sys-color-primary: #2B4D56; // Teal as primary
8
+ --#{$prefix}-sys-color-primary-rgb: 0, 105, 92;
9
+ --#{$prefix}-sys-color-on-primary: #FFFFFF;
10
+ --#{$prefix}-sys-color-on-primary-rgb: 255, 255, 255;
11
+ --#{$prefix}-sys-color-primary-container: #B2DFDB;
12
+ --#{$prefix}-sys-color-primary-container-rgb: 178, 223, 219;
13
+ --#{$prefix}-sys-color-on-primary-container: #002A25;
14
+ --#{$prefix}-sys-color-on-primary-container-rgb: 0, 42, 37;
15
+
16
+ --#{$prefix}-sys-color-secondary: #9A6433; // Caramel as secondary
17
+ --#{$prefix}-sys-color-secondary-rgb: 198, 124, 78;
18
+ --#{$prefix}-sys-color-on-secondary: #FFFFFF;
19
+ --#{$prefix}-sys-color-on-secondary-rgb: 255, 255, 255;
20
+ --#{$prefix}-sys-color-secondary-container: #FFD8C2;
21
+ --#{$prefix}-sys-color-secondary-container-rgb: 255, 216, 194;
22
+ --#{$prefix}-sys-color-on-secondary-container: #3E2715;
23
+ --#{$prefix}-sys-color-on-secondary-container-rgb: 62, 39, 21;
24
+
25
+ --#{$prefix}-sys-color-tertiary: #4A7C6E; // Muted teal as tertiary
26
+ --#{$prefix}-sys-color-tertiary-rgb: 74, 124, 110;
27
+ --#{$prefix}-sys-color-on-tertiary: #FFFFFF;
28
+ --#{$prefix}-sys-color-on-tertiary-rgb: 255, 255, 255;
29
+ --#{$prefix}-sys-color-tertiary-container: #CCE6DF;
30
+ --#{$prefix}-sys-color-tertiary-container-rgb: 204, 230, 223;
31
+ --#{$prefix}-sys-color-on-tertiary-container: #0E3029;
32
+ --#{$prefix}-sys-color-on-tertiary-container-rgb: 14, 48, 41;
33
+
34
+ // Neutral colors with subtle teal undertones
35
+ --#{$prefix}-sys-color-surface: #F9FCFC;
36
+ --#{$prefix}-sys-color-surface-rgb: 249, 252, 252;
37
+ --#{$prefix}-sys-color-surface-dim: #E5ECEB;
38
+ --#{$prefix}-sys-color-surface-dim-rgb: 229, 236, 235;
39
+ --#{$prefix}-sys-color-surface-bright: #F9FCFC;
40
+ --#{$prefix}-sys-color-surface-bright-rgb: 249, 252, 252;
41
+ --#{$prefix}-sys-color-surface-container-lowest: #FFFFFF;
42
+ --#{$prefix}-sys-color-surface-container-lowest-rgb: 255, 255, 255;
43
+ --#{$prefix}-sys-color-surface-container-low: #F3F7F6;
44
+ --#{$prefix}-sys-color-surface-container-low-rgb: 243, 247, 246;
45
+ --#{$prefix}-sys-color-surface-container: #EDF2F1;
46
+ --#{$prefix}-sys-color-surface-container-rgb: 237, 242, 241;
47
+ --#{$prefix}-sys-color-surface-container-high: #E7ECEB;
48
+ --#{$prefix}-sys-color-surface-container-high-rgb: 231, 236, 235;
49
+ --#{$prefix}-sys-color-surface-container-highest: #E1E6E5;
50
+ --#{$prefix}-sys-color-surface-container-highest-rgb: 225, 230, 229;
51
+
52
+ --#{$prefix}-sys-color-on-surface: #191D1C;
53
+ --#{$prefix}-sys-color-on-surface-rgb: 25, 29, 28;
54
+ --#{$prefix}-sys-color-on-surface-variant: #404847;
55
+ --#{$prefix}-sys-color-on-surface-variant-rgb: 64, 72, 71;
56
+
57
+ --#{$prefix}-sys-color-outline: #6E7978;
58
+ --#{$prefix}-sys-color-outline-rgb: 110, 121, 120;
59
+ --#{$prefix}-sys-color-outline-variant: #C1CCCB;
60
+ --#{$prefix}-sys-color-outline-variant-rgb: 193, 204, 203;
61
+
62
+ // Include status colors for light theme
63
+ @include status-colors-light();
64
+
65
+ &[data-theme-mode="dark"] {
66
+ // Key colors for dark mode
67
+ --#{$prefix}-sys-color-primary: #85CFC6; // Lighter teal
68
+ --#{$prefix}-sys-color-primary-rgb: 133, 207, 198;
69
+ --#{$prefix}-sys-color-on-primary: #003E36;
70
+ --#{$prefix}-sys-color-on-primary-rgb: 0, 62, 54;
71
+ --#{$prefix}-sys-color-primary-container: #005349;
72
+ --#{$prefix}-sys-color-primary-container-rgb: 0, 83, 73;
73
+ --#{$prefix}-sys-color-on-primary-container: #B2DFDB;
74
+ --#{$prefix}-sys-color-on-primary-container-rgb: 178, 223, 219;
75
+
76
+ --#{$prefix}-sys-color-secondary: #FFB68D; // Lighter caramel
77
+ --#{$prefix}-sys-color-secondary-rgb: 255, 182, 141;
78
+ --#{$prefix}-sys-color-on-secondary: #5D3726;
79
+ --#{$prefix}-sys-color-on-secondary-rgb: 93, 55, 38;
80
+ --#{$prefix}-sys-color-secondary-container: #7D4F3A;
81
+ --#{$prefix}-sys-color-secondary-container-rgb: 125, 79, 58;
82
+ --#{$prefix}-sys-color-on-secondary-container: #FFD8C2;
83
+ --#{$prefix}-sys-color-on-secondary-container-rgb: 255, 216, 194;
84
+
85
+ --#{$prefix}-sys-color-tertiary: #A0CCC2; // Lighter muted teal
86
+ --#{$prefix}-sys-color-tertiary-rgb: 160, 204, 194;
87
+ --#{$prefix}-sys-color-on-tertiary: #1A463E;
88
+ --#{$prefix}-sys-color-on-tertiary-rgb: 26, 70, 62;
89
+ --#{$prefix}-sys-color-tertiary-container: #315C53;
90
+ --#{$prefix}-sys-color-tertiary-container-rgb: 49, 92, 83;
91
+ --#{$prefix}-sys-color-on-tertiary-container: #CCE6DF;
92
+ --#{$prefix}-sys-color-on-tertiary-container-rgb: 204, 230, 223;
93
+
94
+ // Neutral colors for dark mode
95
+ --#{$prefix}-sys-color-surface: #191D1C;
96
+ --#{$prefix}-sys-color-surface-rgb: 25, 29, 28;
97
+ --#{$prefix}-sys-color-surface-dim: #121615;
98
+ --#{$prefix}-sys-color-surface-dim-rgb: 18, 22, 21;
99
+ --#{$prefix}-sys-color-surface-bright: #363B3A;
100
+ --#{$prefix}-sys-color-surface-bright-rgb: 54, 59, 58;
101
+ --#{$prefix}-sys-color-surface-container-lowest: #0E1211;
102
+ --#{$prefix}-sys-color-surface-container-lowest-rgb: 14, 18, 17;
103
+ --#{$prefix}-sys-color-surface-container-low: #191D1C;
104
+ --#{$prefix}-sys-color-surface-container-low-rgb: 25, 29, 28;
105
+ --#{$prefix}-sys-color-surface-container: #1E2221;
106
+ --#{$prefix}-sys-color-surface-container-rgb: 30, 34, 33;
107
+ --#{$prefix}-sys-color-surface-container-high: #282C2B;
108
+ --#{$prefix}-sys-color-surface-container-high-rgb: 40, 44, 43;
109
+ --#{$prefix}-sys-color-surface-container-highest: #333736;
110
+ --#{$prefix}-sys-color-surface-container-highest-rgb: 51, 55, 54;
111
+
112
+ --#{$prefix}-sys-color-on-surface: #E1E3E3;
113
+ --#{$prefix}-sys-color-on-surface-rgb: 225, 227, 227;
114
+ --#{$prefix}-sys-color-on-surface-variant: #C1CCCB;
115
+ --#{$prefix}-sys-color-on-surface-variant-rgb: 193, 204, 203;
116
+
117
+ --#{$prefix}-sys-color-outline: #8B9695;
118
+ --#{$prefix}-sys-color-outline-rgb: 139, 150, 149;
119
+ --#{$prefix}-sys-color-outline-variant: #404847;
120
+ --#{$prefix}-sys-color-outline-variant-rgb: 64, 72, 71;
121
+
122
+ // Include status colors for dark theme
123
+ @include status-colors-dark();
124
+ }
125
+ }
@@ -35,6 +35,9 @@
35
35
  --#{$prefix}-sys-color-outline: #70787D;
36
36
  --#{$prefix}-sys-color-outline-variant: #C0C8CC;
37
37
 
38
+ // Include status colors for light theme
39
+ @include status-colors-light();
40
+
38
41
  &[data-theme-mode="dark"] {
39
42
  // Key colors
40
43
  --#{$prefix}-sys-color-primary: #73D0EE;
@@ -67,5 +70,8 @@
67
70
 
68
71
  --#{$prefix}-sys-color-outline: #8A9297;
69
72
  --#{$prefix}-sys-color-outline-variant: #40484C;
73
+
74
+ // Include status colors for dark theme
75
+ @include status-colors-dark();
70
76
  }
71
77
  }
@@ -1,48 +0,0 @@
1
- // src/components/card/actions.ts
2
- import { PREFIX } from '../../core/config';
3
- import { pipe } from '../../core/compose';
4
- import { createBase, withElement } from '../../core/compose/component';
5
- import { CardActionsConfig } from './types';
6
-
7
- /**
8
- * Creates a card actions component
9
- * @param {CardActionsConfig} config - Actions configuration
10
- * @returns {HTMLElement} Card actions element
11
- */
12
- export const createCardActions = (config: CardActionsConfig = {}): HTMLElement => {
13
- const baseConfig = {
14
- ...config,
15
- componentName: 'card-actions',
16
- prefix: PREFIX
17
- };
18
-
19
- try {
20
- const actions = pipe(
21
- createBase,
22
- withElement({
23
- tag: 'div',
24
- componentName: 'card-actions',
25
- className: [
26
- config.class,
27
- config.fullBleed ? `${PREFIX}-card-actions--full-bleed` : null,
28
- config.vertical ? `${PREFIX}-card-actions--vertical` : null,
29
- config.align ? `${PREFIX}-card-actions--${config.align}` : null
30
- ]
31
- })
32
- )(baseConfig);
33
-
34
- // Add action elements if provided
35
- if (Array.isArray(config.actions)) {
36
- config.actions.forEach(action => {
37
- if (action instanceof HTMLElement) {
38
- actions.element.appendChild(action);
39
- }
40
- });
41
- }
42
-
43
- return actions.element;
44
- } catch (error) {
45
- console.error('Card actions creation error:', error instanceof Error ? error.message : String(error));
46
- throw new Error(`Failed to create card actions: ${error instanceof Error ? error.message : String(error)}`);
47
- }
48
- };
@@ -1,88 +0,0 @@
1
- // src/components/card/header.ts
2
- import { PREFIX } from '../../core/config';
3
- import { pipe } from '../../core/compose';
4
- import { createBase, withElement } from '../../core/compose/component';
5
- import { createElement } from '../../core/dom/create';
6
- import { CardHeaderConfig } from './types';
7
-
8
- /**
9
- * Creates a card header component
10
- * @param {CardHeaderConfig} config - Header configuration
11
- * @returns {HTMLElement} Card header element
12
- */
13
- export const createCardHeader = (config: CardHeaderConfig = {}): HTMLElement => {
14
- const baseConfig = {
15
- ...config,
16
- componentName: 'card-header',
17
- prefix: PREFIX
18
- };
19
-
20
- try {
21
- const header = pipe(
22
- createBase,
23
- withElement({
24
- tag: 'div',
25
- componentName: 'card-header',
26
- className: config.class
27
- })
28
- )(baseConfig);
29
-
30
- // Create text container
31
- const textContainer = createElement({
32
- tag: 'div',
33
- className: `${PREFIX}-card-header-text`,
34
- container: header.element
35
- });
36
-
37
- // Add title if provided
38
- if (config.title) {
39
- createElement({
40
- tag: 'h3',
41
- className: `${PREFIX}-card-header-title`,
42
- text: config.title,
43
- container: textContainer
44
- });
45
- }
46
-
47
- // Add subtitle if provided
48
- if (config.subtitle) {
49
- createElement({
50
- tag: 'h4',
51
- className: `${PREFIX}-card-header-subtitle`,
52
- text: config.subtitle,
53
- container: textContainer
54
- });
55
- }
56
-
57
- // Add avatar if provided
58
- if (config.avatar) {
59
- const avatarElement = typeof config.avatar === 'string'
60
- ? createElement({
61
- tag: 'div',
62
- className: `${PREFIX}-card-header-avatar`,
63
- html: config.avatar
64
- })
65
- : config.avatar;
66
-
67
- header.element.insertBefore(avatarElement, header.element.firstChild);
68
- }
69
-
70
- // Add action if provided
71
- if (config.action) {
72
- const actionElement = typeof config.action === 'string'
73
- ? createElement({
74
- tag: 'div',
75
- className: `${PREFIX}-card-header-action`,
76
- html: config.action
77
- })
78
- : config.action;
79
-
80
- header.element.appendChild(actionElement);
81
- }
82
-
83
- return header.element;
84
- } catch (error) {
85
- console.error('Card header creation error:', error instanceof Error ? error.message : String(error));
86
- throw new Error(`Failed to create card header: ${error instanceof Error ? error.message : String(error)}`);
87
- }
88
- };
@@ -1,52 +0,0 @@
1
- // src/components/card/media.ts
2
- import { PREFIX } from '../../core/config';
3
- import { pipe } from '../../core/compose';
4
- import { createBase, withElement } from '../../core/compose/component';
5
- import { CardMediaConfig } from './types';
6
-
7
- /**
8
- * Creates a card media component
9
- * @param {CardMediaConfig} config - Media configuration
10
- * @returns {HTMLElement} Card media element
11
- */
12
- export const createCardMedia = (config: CardMediaConfig = {}): HTMLElement => {
13
- const baseConfig = {
14
- ...config,
15
- componentName: 'card-media',
16
- prefix: PREFIX
17
- };
18
-
19
- try {
20
- const media = pipe(
21
- createBase,
22
- withElement({
23
- tag: 'div',
24
- componentName: 'card-media',
25
- className: [
26
- config.class,
27
- config.aspectRatio ? `${PREFIX}-card-media--${config.aspectRatio.replace(':', '-')}` : null,
28
- config.contain ? `${PREFIX}-card-media--contain` : null
29
- ]
30
- })
31
- )(baseConfig);
32
-
33
- // If custom element is provided, use it
34
- if (config.element instanceof HTMLElement) {
35
- media.element.appendChild(config.element);
36
- }
37
-
38
- // Otherwise create an image if src is provided
39
- else if (config.src) {
40
- const img = document.createElement('img');
41
- img.src = config.src;
42
- if (config.alt) img.alt = config.alt;
43
- img.className = `${PREFIX}-card-media-img`;
44
- media.element.appendChild(img);
45
- }
46
-
47
- return media.element;
48
- } catch (error) {
49
- console.error('Card media creation error:', error instanceof Error ? error.message : String(error));
50
- throw new Error(`Failed to create card media: ${error instanceof Error ? error.message : String(error)}`);
51
- }
52
- };
@@ -1,192 +0,0 @@
1
- // src/components/navigation/features/items.js
2
- import { createNavItem, getAllNestedItems } from '../nav-item'
3
-
4
- export const withNavItems = (config) => (component) => {
5
- const items = new Map()
6
- let activeItem = null
7
-
8
- /**
9
- * Recursively stores items in the items Map
10
- * @param {Object} itemConfig - Item configuration
11
- * @param {HTMLElement} item - Created item element
12
- */
13
- const storeItem = (itemConfig, item) => {
14
- items.set(itemConfig.id, { element: item, config: itemConfig })
15
-
16
- if (itemConfig.items?.length) {
17
- itemConfig.items.forEach(nestedConfig => {
18
- const container = item.closest(`.${config.prefix}-nav-item-container`)
19
- const nestedContainer = container.querySelector(`.${config.prefix}-nav-nested-container`)
20
- const nestedItem = nestedContainer.querySelector(`[data-id="${nestedConfig.id}"]`)
21
- storeItem(nestedConfig, nestedItem)
22
- })
23
- }
24
- }
25
-
26
- // Create initial items
27
- if (config.items) {
28
- config.items.forEach(itemConfig => {
29
- const item = createNavItem(itemConfig, component.element, config.prefix)
30
- storeItem(itemConfig, item)
31
-
32
- if (itemConfig.active) {
33
- activeItem = { element: item, config: itemConfig }
34
- item.classList.add(`${config.prefix}-nav-item--active`)
35
- item.setAttribute('aria-selected', 'true')
36
- }
37
- })
38
- }
39
-
40
- // Handle item clicks
41
- component.element.addEventListener('click', (event) => {
42
- const item = event.target.closest(`.${config.prefix}-nav-item`)
43
- if (!item || item.disabled || item.getAttribute('aria-haspopup') === 'true') return
44
-
45
- const id = item.dataset.id
46
- const itemData = items.get(id)
47
- if (!itemData) return
48
-
49
- // Store previous item before updating
50
- const previousItem = activeItem
51
-
52
- // Update active state
53
- if (activeItem) {
54
- activeItem.element.classList.remove(`${config.prefix}-nav-item--active`)
55
- activeItem.element.setAttribute('aria-selected', 'false')
56
- }
57
-
58
- item.classList.add(`${config.prefix}-nav-item--active`)
59
- item.setAttribute('aria-selected', 'true')
60
- activeItem = itemData
61
-
62
- // Emit change event with item data
63
- component.emit('change', {
64
- id,
65
- item: itemData,
66
- previousItem,
67
- path: getItemPath(id)
68
- })
69
- })
70
-
71
- /**
72
- * Gets the path to an item (parent IDs)
73
- * @param {string} id - Item ID to get path for
74
- * @returns {Array<string>} Array of parent item IDs
75
- */
76
- const getItemPath = (id) => {
77
- const path = []
78
- let currentItem = items.get(id)
79
-
80
- while (currentItem) {
81
- const parentContainer = currentItem.element.closest(`.${config.prefix}-nav-nested-container`)
82
- if (!parentContainer) break
83
-
84
- const parentItem = parentContainer.previousElementSibling
85
- if (!parentItem) break
86
-
87
- const parentId = parentItem.dataset.id
88
- if (!parentId) break
89
-
90
- path.unshift(parentId)
91
- currentItem = items.get(parentId)
92
- }
93
-
94
- return path
95
- }
96
-
97
- // Clean up when component is destroyed
98
- if (component.lifecycle) {
99
- const originalDestroy = component.lifecycle.destroy
100
- component.lifecycle.destroy = () => {
101
- items.clear()
102
- originalDestroy?.()
103
- }
104
- }
105
-
106
- return {
107
- ...component,
108
- items,
109
-
110
- addItem (itemConfig) {
111
- if (items.has(itemConfig.id)) return this
112
-
113
- const item = createNavItem(itemConfig, component.element, config.prefix)
114
- storeItem(itemConfig, item)
115
-
116
- if (itemConfig.active) {
117
- this.setActive(itemConfig.id)
118
- }
119
-
120
- component.emit('itemAdded', {
121
- id: itemConfig.id,
122
- item: { element: item, config: itemConfig }
123
- })
124
- return this
125
- },
126
-
127
- removeItem (id) {
128
- const item = items.get(id)
129
- if (!item) return this
130
-
131
- // Remove all nested items first
132
- const nestedItems = getAllNestedItems(item.element, config.prefix)
133
- nestedItems.forEach(nestedItem => {
134
- const nestedId = nestedItem.dataset.id
135
- if (nestedId) items.delete(nestedId)
136
- })
137
-
138
- if (activeItem?.config.id === id) {
139
- activeItem = null
140
- }
141
-
142
- // Remove the entire item container
143
- const container = item.element.closest(`.${config.prefix}-nav-item-container`)
144
- container?.remove()
145
- items.delete(id)
146
-
147
- component.emit('itemRemoved', { id, item })
148
- return this
149
- },
150
-
151
- getItem: (id) => items.get(id),
152
- getAllItems: () => Array.from(items.values()),
153
- getActive: () => activeItem,
154
- getItemPath: (id) => getItemPath(id),
155
-
156
- setActive (id) {
157
- const item = items.get(id)
158
- if (!item || item.config.disabled) return this
159
-
160
- if (activeItem) {
161
- activeItem.element.classList.remove(`${config.prefix}-nav-item--active`)
162
- activeItem.element.setAttribute('aria-selected', 'false')
163
- }
164
-
165
- item.element.classList.add(`${config.prefix}-nav-item--active`)
166
- item.element.setAttribute('aria-selected', 'true')
167
- activeItem = item
168
-
169
- // Ensure all parent items are expanded
170
- const path = getItemPath(id)
171
- path.forEach(parentId => {
172
- const parentItem = items.get(parentId)
173
- if (parentItem) {
174
- const parentButton = parentItem.element
175
- const nestedContainer = parentButton.closest(`.${config.prefix}-nav-item-container`)
176
- .querySelector(`.${config.prefix}-nav-nested-container`)
177
-
178
- parentButton.setAttribute('aria-expanded', 'true')
179
- nestedContainer.hidden = false
180
- }
181
- })
182
-
183
- component.emit('activeChanged', {
184
- id,
185
- item,
186
- previousItem: activeItem,
187
- path: getItemPath(id)
188
- })
189
- return this
190
- }
191
- }
192
- }
@@ -1,94 +0,0 @@
1
- // src/components/slider/features/appearance.ts
2
- import { SLIDER_COLORS, SLIDER_SIZES } from '../constants';
3
- import { SliderConfig } from '../types';
4
-
5
- /**
6
- * Add appearance management features to slider component
7
- * @param config Slider configuration
8
- * @returns Component enhancer with appearance features
9
- */
10
- export const withAppearance = (config: SliderConfig) => component => {
11
- return {
12
- ...component,
13
- appearance: {
14
- /**
15
- * Sets slider color
16
- * @param color Color variant
17
- */
18
- setColor(color: keyof typeof SLIDER_COLORS | SLIDER_COLORS) {
19
- // Remove existing color classes
20
- Object.values(SLIDER_COLORS).forEach(colorName => {
21
- component.element.classList.remove(`${component.getClass('slider')}--${colorName}`);
22
- });
23
-
24
- // Add new color class if not primary (default)
25
- if (color !== SLIDER_COLORS.PRIMARY) {
26
- component.element.classList.add(`${component.getClass('slider')}--${color}`);
27
- }
28
- },
29
-
30
- /**
31
- * Gets slider color
32
- * @returns Current color name
33
- */
34
- getColor() {
35
- // Find which color class is active
36
- const colorClass = Object.values(SLIDER_COLORS).find(colorName =>
37
- component.element.classList.contains(`${component.getClass('slider')}--${colorName}`)
38
- );
39
-
40
- return colorClass || SLIDER_COLORS.PRIMARY;
41
- },
42
-
43
- /**
44
- * Sets slider size
45
- * @param size Size variant
46
- */
47
- setSize(size: keyof typeof SLIDER_SIZES | SLIDER_SIZES) {
48
- // Remove existing size classes
49
- Object.values(SLIDER_SIZES).forEach(sizeName => {
50
- component.element.classList.remove(`${component.getClass('slider')}--${sizeName}`);
51
- });
52
-
53
- // Add new size class if not medium (default)
54
- if (size !== SLIDER_SIZES.MEDIUM) {
55
- component.element.classList.add(`${component.getClass('slider')}--${size}`);
56
- }
57
- },
58
-
59
- /**
60
- * Gets slider size
61
- * @returns Current size name
62
- */
63
- getSize() {
64
- // Find which size class is active
65
- const sizeClass = Object.values(SLIDER_SIZES).find(sizeName =>
66
- component.element.classList.contains(`${component.getClass('slider')}--${sizeName}`)
67
- );
68
-
69
- return sizeClass || SLIDER_SIZES.MEDIUM;
70
- },
71
-
72
- /**
73
- * Shows or hides tick marks
74
- * @param show Whether to show ticks
75
- */
76
- showTicks(show: boolean) {
77
- config.ticks = show;
78
-
79
- // Regenerate ticks if slider is initialized
80
- if (component.slider) {
81
- component.slider.regenerateTicks();
82
- }
83
- },
84
-
85
- /**
86
- * Shows or hides current value bubble while dragging
87
- * @param show Whether to show value bubble
88
- */
89
- showCurrentValue(show: boolean) {
90
- config.showValue = show;
91
- }
92
- }
93
- };
94
- };