mtrl 0.2.6 → 0.2.8

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/demo/build.ts +349 -0
  2. package/demo/index.html +110 -0
  3. package/demo/main.js +448 -0
  4. package/demo/styles.css +239 -0
  5. package/index.ts +18 -0
  6. package/package.json +14 -3
  7. package/server.ts +86 -0
  8. package/src/components/badge/api.ts +70 -63
  9. package/src/components/badge/badge.ts +16 -2
  10. package/src/components/badge/config.ts +66 -13
  11. package/src/components/badge/features.ts +51 -42
  12. package/src/components/badge/index.ts +27 -2
  13. package/src/components/badge/types.ts +62 -30
  14. package/src/components/bottom-app-bar/bottom-app-bar.ts +154 -0
  15. package/src/components/bottom-app-bar/config.ts +29 -0
  16. package/src/components/bottom-app-bar/index.ts +17 -0
  17. package/src/components/bottom-app-bar/types.ts +114 -0
  18. package/src/components/button/api.ts +5 -0
  19. package/src/components/button/button.ts +0 -1
  20. package/src/components/button/config.ts +6 -2
  21. package/src/components/button/index.ts +10 -2
  22. package/src/components/button/types.ts +20 -2
  23. package/src/components/card/card.ts +13 -25
  24. package/src/components/card/config.ts +83 -30
  25. package/src/components/card/content.ts +8 -10
  26. package/src/components/card/features.ts +4 -3
  27. package/src/components/card/index.ts +29 -2
  28. package/src/components/card/types.ts +33 -22
  29. package/src/components/checkbox/config.ts +3 -4
  30. package/src/components/checkbox/index.ts +1 -2
  31. package/src/components/checkbox/types.ts +12 -3
  32. package/src/components/chip/api.ts +170 -221
  33. package/src/components/chip/chip.ts +34 -302
  34. package/src/components/chip/config.ts +1 -2
  35. package/src/components/chip/index.ts +10 -2
  36. package/src/components/chip/types.ts +224 -35
  37. package/src/components/datepicker/api.ts +265 -0
  38. package/src/components/datepicker/config.ts +141 -0
  39. package/src/components/datepicker/datepicker.ts +341 -0
  40. package/src/components/datepicker/index.ts +12 -0
  41. package/src/components/datepicker/render.ts +450 -0
  42. package/src/components/datepicker/types.ts +397 -0
  43. package/src/components/datepicker/utils.ts +289 -0
  44. package/src/components/dialog/api.ts +55 -21
  45. package/src/components/dialog/config.ts +12 -9
  46. package/src/components/dialog/dialog.ts +6 -3
  47. package/src/components/dialog/features.ts +345 -151
  48. package/src/components/dialog/index.ts +38 -8
  49. package/src/components/dialog/types.ts +40 -14
  50. package/src/components/divider/config.ts +81 -0
  51. package/src/components/divider/divider.ts +37 -0
  52. package/src/components/divider/features.ts +207 -0
  53. package/src/components/divider/index.ts +9 -0
  54. package/src/components/divider/types.ts +55 -0
  55. package/src/components/extended-fab/api.ts +141 -0
  56. package/src/components/extended-fab/config.ts +112 -0
  57. package/src/components/extended-fab/extended-fab.ts +125 -0
  58. package/src/components/extended-fab/index.ts +9 -0
  59. package/src/components/extended-fab/types.ts +304 -0
  60. package/src/components/fab/api.ts +97 -0
  61. package/src/components/fab/config.ts +93 -0
  62. package/src/components/fab/fab.ts +67 -0
  63. package/src/components/fab/index.ts +9 -0
  64. package/src/components/fab/types.ts +251 -0
  65. package/src/components/list/config.ts +4 -5
  66. package/src/components/list/features.ts +6 -7
  67. package/src/components/list/index.ts +7 -9
  68. package/src/components/list/list-item.ts +12 -13
  69. package/src/components/list/types.ts +50 -5
  70. package/src/components/list/utils.ts +30 -3
  71. package/src/components/menu/features/items-manager.ts +9 -9
  72. package/src/components/menu/features/positioning.ts +7 -7
  73. package/src/components/menu/features/visibility.ts +7 -7
  74. package/src/components/menu/index.ts +7 -9
  75. package/src/components/menu/menu-item.ts +6 -6
  76. package/src/components/menu/menu.ts +22 -0
  77. package/src/components/menu/types.ts +29 -10
  78. package/src/components/menu/utils.ts +67 -0
  79. package/src/components/navigation/api.ts +78 -50
  80. package/src/components/navigation/config.ts +22 -10
  81. package/src/components/navigation/features/items.ts +284 -0
  82. package/src/components/navigation/index.ts +0 -6
  83. package/src/components/navigation/nav-item.ts +70 -33
  84. package/src/components/navigation/navigation.ts +53 -3
  85. package/src/components/navigation/types.ts +117 -70
  86. package/src/components/progress/api.ts +2 -3
  87. package/src/components/progress/config.ts +2 -3
  88. package/src/components/progress/index.ts +0 -1
  89. package/src/components/progress/progress.ts +1 -2
  90. package/src/components/progress/types.ts +186 -33
  91. package/src/components/radios/config.ts +1 -1
  92. package/src/components/radios/index.ts +0 -1
  93. package/src/components/radios/types.ts +0 -7
  94. package/src/components/search/api.ts +203 -0
  95. package/src/components/search/config.ts +86 -0
  96. package/src/components/search/features/index.ts +4 -0
  97. package/src/components/search/features/search.ts +717 -0
  98. package/src/components/search/features/states.ts +169 -0
  99. package/src/components/search/features/structure.ts +197 -0
  100. package/src/components/search/index.ts +7 -0
  101. package/src/components/search/search.ts +52 -0
  102. package/src/components/search/types.ts +175 -0
  103. package/src/components/segmented-button/config.ts +80 -0
  104. package/src/components/segmented-button/index.ts +4 -0
  105. package/src/components/segmented-button/segment.ts +154 -0
  106. package/src/components/segmented-button/segmented-button.ts +249 -0
  107. package/src/components/segmented-button/types.ts +254 -0
  108. package/src/components/slider/accessibility.md +5 -5
  109. package/src/components/slider/api.ts +41 -120
  110. package/src/components/slider/config.ts +51 -47
  111. package/src/components/slider/features/handlers.ts +495 -0
  112. package/src/components/slider/features/index.ts +1 -2
  113. package/src/components/slider/features/slider.ts +66 -84
  114. package/src/components/slider/features/states.ts +195 -0
  115. package/src/components/slider/features/structure.ts +136 -206
  116. package/src/components/slider/features/ui.ts +145 -206
  117. package/src/components/slider/index.ts +2 -11
  118. package/src/components/slider/slider.ts +9 -12
  119. package/src/components/slider/types.ts +67 -26
  120. package/src/components/snackbar/config.ts +2 -3
  121. package/src/components/snackbar/constants.ts +0 -32
  122. package/src/components/snackbar/index.ts +0 -1
  123. package/src/components/snackbar/position.ts +9 -1
  124. package/src/components/snackbar/types.ts +122 -46
  125. package/src/components/switch/config.ts +2 -3
  126. package/src/components/switch/index.ts +0 -1
  127. package/src/components/switch/types.ts +3 -2
  128. package/src/components/tabs/config.ts +3 -4
  129. package/src/components/tabs/features.ts +4 -2
  130. package/src/components/tabs/index.ts +0 -15
  131. package/src/components/tabs/indicator.ts +73 -13
  132. package/src/components/tabs/tab-api.ts +12 -4
  133. package/src/components/tabs/tab.ts +18 -6
  134. package/src/components/tabs/types.ts +23 -5
  135. package/src/components/textfield/config.ts +2 -3
  136. package/src/components/textfield/index.ts +0 -1
  137. package/src/components/textfield/types.ts +17 -3
  138. package/src/components/timepicker/README.md +277 -0
  139. package/src/components/timepicker/api.ts +632 -0
  140. package/src/components/timepicker/clockdial.ts +482 -0
  141. package/src/components/timepicker/config.ts +228 -0
  142. package/src/components/timepicker/index.ts +3 -0
  143. package/src/components/timepicker/render.ts +613 -0
  144. package/src/components/timepicker/timepicker.ts +117 -0
  145. package/src/components/timepicker/types.ts +336 -0
  146. package/src/components/timepicker/utils.ts +241 -0
  147. package/src/components/tooltip/api.ts +1 -1
  148. package/src/components/tooltip/config.ts +27 -6
  149. package/src/components/tooltip/index.ts +0 -1
  150. package/src/components/tooltip/types.ts +13 -3
  151. package/src/components/top-app-bar/config.ts +83 -0
  152. package/src/components/top-app-bar/index.ts +11 -0
  153. package/src/components/top-app-bar/top-app-bar.ts +316 -0
  154. package/src/components/top-app-bar/types.ts +140 -0
  155. package/src/core/build/_ripple.scss +6 -6
  156. package/src/core/build/ripple.ts +72 -95
  157. package/src/core/compose/features/icon.ts +3 -1
  158. package/src/core/compose/features/ripple.ts +4 -1
  159. package/src/core/compose/features/textlabel.ts +23 -2
  160. package/src/core/dom/create.ts +5 -0
  161. package/src/index.ts +9 -0
  162. package/src/styles/abstract/_theme.scss +9 -1
  163. package/src/styles/components/_badge.scss +182 -0
  164. package/src/styles/components/_bottom-app-bar.scss +103 -0
  165. package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -10
  166. package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -2
  167. package/src/styles/components/_datepicker.scss +358 -0
  168. package/src/styles/components/_dialog.scss +259 -0
  169. package/src/styles/components/_divider.scss +57 -0
  170. package/src/styles/components/_extended-fab.scss +267 -0
  171. package/src/styles/components/_fab.scss +225 -0
  172. package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +1 -0
  173. package/src/styles/components/_search.scss +306 -0
  174. package/src/styles/components/_segmented-button.scss +117 -0
  175. package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +83 -24
  176. package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -2
  177. package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +95 -33
  178. package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
  179. package/src/styles/components/_timepicker.scss +451 -0
  180. package/src/styles/components/_top-app-bar.scss +225 -0
  181. package/src/styles/main.scss +98 -49
  182. package/src/styles/themes/_autumn.scss +21 -0
  183. package/src/styles/themes/_base-theme.scss +61 -0
  184. package/src/styles/themes/_baseline.scss +58 -0
  185. package/src/styles/themes/_bluekhaki.scss +125 -0
  186. package/src/styles/themes/_brownbeige.scss +125 -0
  187. package/src/styles/themes/_browngreen.scss +125 -0
  188. package/src/styles/themes/_forest.scss +6 -0
  189. package/src/styles/themes/_greenbeige.scss +125 -0
  190. package/src/styles/themes/_material.scss +125 -0
  191. package/src/styles/themes/_ocean.scss +6 -0
  192. package/src/styles/themes/_sageivory.scss +125 -0
  193. package/src/styles/themes/_spring.scss +6 -0
  194. package/src/styles/themes/_summer.scss +5 -0
  195. package/src/styles/themes/_sunset.scss +5 -0
  196. package/src/styles/themes/_tealcaramel.scss +125 -0
  197. package/src/styles/themes/_winter.scss +6 -0
  198. package/src/components/badge/_styles.scss +0 -174
  199. package/src/components/badge/constants.ts +0 -30
  200. package/src/components/button/constants.ts +0 -11
  201. package/src/components/card/constants.ts +0 -84
  202. package/src/components/dialog/_styles.scss +0 -213
  203. package/src/components/dialog/constants.ts +0 -32
  204. package/src/components/menu/constants.ts +0 -154
  205. package/src/components/navigation/constants.ts +0 -200
  206. package/src/components/navigation/features/items.js +0 -192
  207. package/src/components/progress/constants.ts +0 -29
  208. package/src/components/slider/features/appearance.ts +0 -94
  209. package/src/components/slider/features/disabled.ts +0 -68
  210. package/src/components/slider/features/events.ts +0 -164
  211. package/src/components/slider/features/interactions.ts +0 -396
  212. package/src/components/slider/features/keyboard.ts +0 -233
  213. package/src/components/switch/constants.ts +0 -80
  214. package/src/components/tabs/constants.ts +0 -89
  215. package/src/core/collection/adapters/mongodb.js +0 -232
  216. /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
  217. /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
  218. /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
  219. /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
  220. /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
  221. /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
  222. /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
  223. /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
  224. /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
  225. /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
  226. /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
@@ -1,32 +0,0 @@
1
- // src/components/dialog/constants.ts
2
-
3
- export const DIALOG_SIZES = {
4
- SMALL: 'small',
5
- MEDIUM: 'medium',
6
- LARGE: 'large',
7
- FULLWIDTH: 'fullwidth',
8
- FULLSCREEN: 'fullscreen'
9
- };
10
-
11
- export const DIALOG_ANIMATIONS = {
12
- SCALE: 'scale',
13
- SLIDE_UP: 'slide-up',
14
- SLIDE_DOWN: 'slide-down',
15
- FADE: 'fade'
16
- };
17
-
18
- export const DIALOG_FOOTER_ALIGNMENTS = {
19
- RIGHT: 'right',
20
- LEFT: 'left',
21
- CENTER: 'center',
22
- SPACE_BETWEEN: 'space-between'
23
- };
24
-
25
- export const DIALOG_EVENTS = {
26
- OPEN: 'open',
27
- CLOSE: 'close',
28
- BEFORE_OPEN: 'beforeopen',
29
- BEFORE_CLOSE: 'beforeclose',
30
- AFTER_OPEN: 'afteropen',
31
- AFTER_CLOSE: 'afterclose'
32
- };
@@ -1,154 +0,0 @@
1
- // src/components/menu/constants.ts
2
-
3
- /**
4
- * Menu alignment options
5
- */
6
- export const MENU_ALIGN = {
7
- LEFT: 'left',
8
- RIGHT: 'right',
9
- CENTER: 'center'
10
- } as const;
11
-
12
- /**
13
- * Menu vertical alignment options
14
- */
15
- export const MENU_VERTICAL_ALIGN = {
16
- TOP: 'top',
17
- BOTTOM: 'bottom',
18
- MIDDLE: 'middle'
19
- } as const;
20
-
21
- /**
22
- * Menu item types
23
- */
24
- export const MENU_ITEM_TYPES = {
25
- ITEM: 'item',
26
- DIVIDER: 'divider'
27
- } as const;
28
-
29
- /**
30
- * Menu events
31
- */
32
- export const MENU_EVENTS = {
33
- SELECT: 'select',
34
- OPEN: 'open',
35
- CLOSE: 'close',
36
- SUBMENU_OPEN: 'submenuOpen',
37
- SUBMENU_CLOSE: 'submenuClose'
38
- } as const;
39
-
40
- /**
41
- * Menu states
42
- */
43
- export const MENU_STATES = {
44
- VISIBLE: 'visible',
45
- HIDDEN: 'hidden',
46
- DISABLED: 'disabled'
47
- } as const;
48
-
49
- /**
50
- * Menu element classes
51
- */
52
- export const MENU_CLASSES = {
53
- ROOT: 'menu',
54
- ITEM: 'menu-item',
55
- ITEM_CONTAINER: 'menu-item-container',
56
- LIST: 'menu-list',
57
- DIVIDER: 'menu-divider',
58
- SUBMENU: 'menu--submenu'
59
- } as const;
60
-
61
- /**
62
- * Menu positioning schema
63
- * Used for validation in component creation
64
- */
65
- export const MENU_POSITION_SCHEMA = {
66
- type: 'object',
67
- properties: {
68
- align: {
69
- type: 'string',
70
- enum: Object.values(MENU_ALIGN),
71
- optional: true,
72
- default: MENU_ALIGN.LEFT
73
- },
74
- vAlign: {
75
- type: 'string',
76
- enum: Object.values(MENU_VERTICAL_ALIGN),
77
- optional: true,
78
- default: MENU_VERTICAL_ALIGN.BOTTOM
79
- },
80
- offsetX: {
81
- type: 'number',
82
- optional: true,
83
- default: 0
84
- },
85
- offsetY: {
86
- type: 'number',
87
- optional: true,
88
- default: 0
89
- }
90
- }
91
- } as const;
92
-
93
- /**
94
- * Validation schema for menu configuration
95
- */
96
- export const MENU_SCHEMA = {
97
- type: 'object',
98
- properties: {
99
- items: {
100
- type: 'array',
101
- optional: true,
102
- default: []
103
- },
104
- class: {
105
- type: 'string',
106
- optional: true
107
- },
108
- stayOpenOnSelect: {
109
- type: 'boolean',
110
- optional: true,
111
- default: false
112
- },
113
- openingButton: {
114
- optional: true
115
- }
116
- }
117
- } as const;
118
-
119
- /**
120
- * Menu item schema
121
- */
122
- export const MENU_ITEM_SCHEMA = {
123
- type: 'object',
124
- properties: {
125
- name: {
126
- type: 'string',
127
- required: true
128
- },
129
- text: {
130
- type: 'string',
131
- required: true
132
- },
133
- type: {
134
- type: 'string',
135
- enum: Object.values(MENU_ITEM_TYPES),
136
- optional: true,
137
- default: MENU_ITEM_TYPES.ITEM
138
- },
139
- disabled: {
140
- type: 'boolean',
141
- optional: true,
142
- default: false
143
- },
144
- class: {
145
- type: 'string',
146
- optional: true
147
- },
148
- items: {
149
- type: 'array',
150
- optional: true,
151
- description: 'Submenu items'
152
- }
153
- }
154
- } as const;
@@ -1,200 +0,0 @@
1
- // src/components/navigation/constants.ts
2
-
3
- /**
4
- * Navigation variants following Material Design 3
5
- */
6
- export const NAV_VARIANTS = {
7
- RAIL: 'rail', // Vertical slim navigation
8
- DRAWER: 'drawer', // Expandable side navigation
9
- BAR: 'bar', // Bottom or top navigation bar
10
- DRAWER_MODAL: 'modal', // Modal drawer overlay
11
- DRAWER_STANDARD: 'standard' // Standard permanent drawer
12
- } as const;
13
-
14
- /**
15
- * Navigation positions
16
- */
17
- export const NAV_POSITIONS = {
18
- LEFT: 'left',
19
- RIGHT: 'right',
20
- TOP: 'top',
21
- BOTTOM: 'bottom'
22
- } as const;
23
-
24
- /**
25
- * Navigation behaviors
26
- */
27
- export const NAV_BEHAVIORS = {
28
- FIXED: 'fixed', // Always visible
29
- DISMISSIBLE: 'dismissible', // Can be dismissed/hidden
30
- MODAL: 'modal' // Overlays content with scrim
31
- } as const;
32
-
33
- /**
34
- * Navigation state classes
35
- */
36
- export const NAV_STATES = {
37
- ACTIVE: 'active', // Currently selected item
38
- DISABLED: 'disabled', // Disabled state
39
- EXPANDED: 'expanded', // Drawer expanded state
40
- COLLAPSED: 'collapsed', // Drawer collapsed state
41
- HOVERED: 'hovered', // Hover state
42
- FOCUSED: 'focused', // Keyboard focus state
43
- PRESSED: 'pressed' // Press/click state
44
- } as const;
45
-
46
- /**
47
- * Navigation element classes
48
- */
49
- export const NAV_CLASSES = {
50
- ROOT: 'nav',
51
- ITEM: 'nav-item',
52
- ITEM_CONTAINER: 'nav-item-container',
53
- ICON: 'nav-item-icon',
54
- LABEL: 'nav-item-label',
55
- BADGE: 'nav-item-badge',
56
- DIVIDER: 'nav-divider',
57
- SCRIM: 'nav-scrim',
58
- GROUP: 'nav-group',
59
- GROUP_TITLE: 'nav-group-title',
60
- SUBTITLE: 'nav-subtitle',
61
- NESTED_CONTAINER: 'nav-nested-container',
62
- NESTED_ITEM: 'nav-nested-item',
63
- EXPAND_ICON: 'nav-expand-icon'
64
- } as const;
65
-
66
- /**
67
- * Validation schema for navigation configuration
68
- */
69
- export const NAV_SCHEMA = {
70
- type: 'object',
71
- properties: {
72
- variant: {
73
- type: 'string',
74
- enum: Object.values(NAV_VARIANTS),
75
- optional: true,
76
- default: NAV_VARIANTS.RAIL
77
- },
78
- position: {
79
- type: 'string',
80
- enum: Object.values(NAV_POSITIONS),
81
- optional: true,
82
- default: NAV_POSITIONS.LEFT
83
- },
84
- behavior: {
85
- type: 'string',
86
- enum: Object.values(NAV_BEHAVIORS),
87
- optional: true,
88
- default: NAV_BEHAVIORS.FIXED
89
- },
90
- items: {
91
- type: 'array',
92
- optional: true,
93
- default: []
94
- },
95
- groups: {
96
- type: 'array',
97
- optional: true
98
- },
99
- disabled: {
100
- type: 'boolean',
101
- optional: true
102
- },
103
- expanded: {
104
- type: 'boolean',
105
- optional: true
106
- },
107
- showLabels: {
108
- type: 'boolean',
109
- optional: true,
110
- default: true
111
- },
112
- scrimEnabled: {
113
- type: 'boolean',
114
- optional: true,
115
- default: false
116
- },
117
- class: {
118
- type: 'string',
119
- optional: true
120
- }
121
- }
122
- } as const;
123
-
124
- /**
125
- * Navigation item states
126
- */
127
- export const NAV_ITEM_STATES = {
128
- EXPANDED: 'expanded',
129
- COLLAPSED: 'collapsed'
130
- } as const;
131
-
132
- /**
133
- * Navigation item schema
134
- * Enhanced with support for nested items
135
- */
136
- export const NAV_ITEM_SCHEMA = {
137
- type: 'object',
138
- properties: {
139
- id: {
140
- type: 'string',
141
- required: true
142
- },
143
- icon: {
144
- type: 'string',
145
- required: true
146
- },
147
- label: {
148
- type: 'string',
149
- required: true
150
- },
151
- badge: {
152
- type: 'string',
153
- optional: true
154
- },
155
- disabled: {
156
- type: 'boolean',
157
- optional: true
158
- },
159
- subtitle: {
160
- type: 'string',
161
- optional: true
162
- },
163
- groupId: {
164
- type: 'string',
165
- optional: true
166
- },
167
- items: {
168
- type: 'array',
169
- optional: true,
170
- description: 'Nested navigation items'
171
- },
172
- expanded: {
173
- type: 'boolean',
174
- optional: true,
175
- default: false
176
- }
177
- }
178
- } as const;
179
-
180
- /**
181
- * Navigation group schema
182
- */
183
- export const NAV_GROUP_SCHEMA = {
184
- type: 'object',
185
- properties: {
186
- id: {
187
- type: 'string',
188
- required: true
189
- },
190
- title: {
191
- type: 'string',
192
- required: true
193
- },
194
- expanded: {
195
- type: 'boolean',
196
- optional: true,
197
- default: true
198
- }
199
- }
200
- } as const;
@@ -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,29 +0,0 @@
1
- // src/components/progress/constants.ts
2
-
3
- /**
4
- * Progress component variants
5
- */
6
- export const PROGRESS_VARIANTS = {
7
- /** Standard linear progress bar */
8
- LINEAR: 'linear',
9
-
10
- /** Circular progress indicator */
11
- CIRCULAR: 'circular',
12
-
13
- /** Progress with known value */
14
- DETERMINATE: 'determinate',
15
-
16
- /** Indeterminate progress animation */
17
- INDETERMINATE: 'indeterminate'
18
- } as const;
19
-
20
- /**
21
- * Progress component events
22
- */
23
- export const PROGRESS_EVENTS = {
24
- /** Fired when value changes */
25
- VALUE_CHANGE: 'valueChange',
26
-
27
- /** Fired when component becomes determinate/indeterminate */
28
- STATE_CHANGE: 'stateChange'
29
- } as const;
@@ -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
- };