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
@@ -0,0 +1,306 @@
1
+ // src/components/search/_styles.scss
2
+ @use '../../styles/abstract/base' as base;
3
+ @use '../../styles/abstract/variables' as v;
4
+ @use '../../styles/abstract/functions' as f;
5
+ @use '../../styles/abstract/mixins' as m;
6
+ @use '../../styles/abstract/theme' as t;
7
+
8
+ $component: '#{base.$prefix}-search';
9
+
10
+ .#{$component} {
11
+ // Base styles
12
+ position: relative;
13
+ display: flex;
14
+ flex-direction: column;
15
+ width: 100%;
16
+ max-width: 720px;
17
+ min-width: 360px;
18
+ background-color: transparent;
19
+ transition: background-color 0.2s ease;
20
+ z-index: 1;
21
+
22
+ // Container
23
+ &-container {
24
+ position: relative;
25
+ display: flex;
26
+ align-items: center;
27
+ height: 56px;
28
+ padding: 0 16px;
29
+ border-radius: v.shape('pill');
30
+ background-color: t.color('surface-container-high');
31
+ transition: background-color 0.2s ease;
32
+ overflow: hidden;
33
+
34
+ .#{$component}--disabled & {
35
+ opacity: 0.38;
36
+ pointer-events: none;
37
+ }
38
+ }
39
+
40
+ // Leading Icon
41
+ &-leading-icon {
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ min-width: 24px;
46
+ height: 24px;
47
+ margin-right: 16px;
48
+ color: t.color('on-surface');
49
+ cursor: pointer;
50
+ flex-shrink: 0;
51
+
52
+ svg {
53
+ width: 24px;
54
+ height: 24px;
55
+ }
56
+
57
+ &:focus {
58
+ outline: none;
59
+ }
60
+
61
+ &:focus-visible {
62
+ outline: 2px solid t.color('outline');
63
+ border-radius: 50%;
64
+ }
65
+ }
66
+
67
+ // Input wrapper
68
+ &-input-wrapper {
69
+ flex: 1;
70
+ min-width: 0;
71
+ height: 100%;
72
+ display: flex;
73
+ align-items: center;
74
+ }
75
+
76
+ // Input field
77
+ &-input {
78
+ width: 100%;
79
+ height: 100%;
80
+ min-height: 36px;
81
+ border: none;
82
+ background: transparent;
83
+ font-size: 16px;
84
+ color: t.color('on-surface');
85
+ padding: 8px 0;
86
+ box-sizing: border-box;
87
+ outline: none;
88
+
89
+ &::placeholder {
90
+ color: t.color('on-surface-variant');
91
+ }
92
+
93
+ .#{$component}--disabled & {
94
+ cursor: not-allowed;
95
+ }
96
+ }
97
+
98
+ // Clear button
99
+ &-clear-button {
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: center;
103
+ min-width: 24px;
104
+ height: 24px;
105
+ margin-left: 16px;
106
+ color: t.color('on-surface-variant');
107
+ cursor: pointer;
108
+ flex-shrink: 0;
109
+ opacity: 1;
110
+ visibility: visible;
111
+ transition: opacity 0.2s ease, visibility 0s;
112
+
113
+ svg {
114
+ width: 20px;
115
+ height: 20px;
116
+ }
117
+
118
+ &--hidden {
119
+ opacity: 0;
120
+ visibility: hidden;
121
+ transition: opacity 0.2s ease, visibility 0s 0.2s;
122
+ }
123
+
124
+ &:focus {
125
+ outline: none;
126
+ }
127
+
128
+ &:focus-visible {
129
+ outline: 2px solid t.color('outline');
130
+ border-radius: 50%;
131
+ }
132
+ }
133
+
134
+ // Trailing icons
135
+ &-trailing-icon {
136
+ display: flex;
137
+ align-items: center;
138
+ justify-content: center;
139
+ min-width: 24px;
140
+ height: 24px;
141
+ margin-left: 16px;
142
+ color: t.color('on-surface-variant');
143
+ cursor: pointer;
144
+ flex-shrink: 0;
145
+
146
+ svg {
147
+ width: 24px;
148
+ height: 24px;
149
+ }
150
+
151
+ &:focus {
152
+ outline: none;
153
+ }
154
+
155
+ &:focus-visible {
156
+ outline: 2px solid t.color('outline');
157
+ border-radius: 50%;
158
+ }
159
+ }
160
+
161
+ // Avatar
162
+ &-avatar {
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: center;
166
+ margin-left: 16px;
167
+ min-width: 30px;
168
+ height: 30px;
169
+ flex-shrink: 0;
170
+ border-radius: 50%;
171
+ overflow: hidden;
172
+
173
+ img {
174
+ width: 100%;
175
+ height: 100%;
176
+ object-fit: cover;
177
+ }
178
+ }
179
+
180
+ // Search variants
181
+ &--bar {
182
+ border-radius: v.shape('pill');
183
+ overflow: hidden;
184
+ transition: max-width 0.3s ease, width 0.3s ease;
185
+ }
186
+
187
+ &--view {
188
+ border-radius: 0;
189
+ max-width: 100%;
190
+ width: 100%;
191
+
192
+ .#{$component}-container {
193
+ border-radius: 0;
194
+ }
195
+
196
+ // For docked view mode
197
+ @include m.breakpoint-up('md') {
198
+ border-radius: v.shape('extra-large');
199
+
200
+ .#{$component}-container {
201
+ border-radius: v.shape('extra-large') v.shape('extra-large') 0 0;
202
+ height: 56px;
203
+ }
204
+ }
205
+ }
206
+
207
+ // Divider
208
+ &-divider {
209
+ display: block;
210
+ width: 100%;
211
+ height: 1px;
212
+ background-color: t.color('outline');
213
+ opacity: 0.5;
214
+ }
215
+
216
+ // Suggestions container
217
+ &-suggestions-container {
218
+ display: none;
219
+ background-color: t.color('surface-container-high');
220
+ max-height: 400px;
221
+ overflow-y: auto;
222
+ border-bottom-left-radius: v.shape('medium');
223
+ border-bottom-right-radius: v.shape('medium');
224
+
225
+ &--visible {
226
+ display: block;
227
+ }
228
+
229
+ // For docked view mode
230
+ @include m.breakpoint-up('md') {
231
+ border-radius: 0 0 v.shape('extra-large') v.shape('extra-large');
232
+ }
233
+ }
234
+
235
+ // Suggestions list
236
+ &-suggestions-list {
237
+ list-style: none;
238
+ padding: 8px 0;
239
+ margin: 0;
240
+ }
241
+
242
+ // Suggestion item
243
+ &-suggestion-item {
244
+ display: flex;
245
+ align-items: center;
246
+ padding: 12px 16px;
247
+ min-height: 48px;
248
+ font-size: 16px;
249
+ color: t.color('on-surface');
250
+ cursor: pointer;
251
+ transition: background-color 0.15s ease;
252
+
253
+ &:hover, &:focus {
254
+ background-color: t.alpha('on-surface', 0.05);
255
+ }
256
+
257
+ &:focus {
258
+ outline: none;
259
+ }
260
+
261
+ // Highlight matched text
262
+ strong {
263
+ font-weight: 600;
264
+ color: t.color('on-surface');
265
+ }
266
+ }
267
+
268
+ // Suggestion item icon
269
+ &-suggestion-icon {
270
+ display: flex;
271
+ align-items: center;
272
+ justify-content: center;
273
+ width: 24px;
274
+ height: 24px;
275
+ margin-right: 16px;
276
+ color: t.color('on-surface-variant');
277
+
278
+ svg {
279
+ width: 20px;
280
+ height: 20px;
281
+ }
282
+ }
283
+
284
+ // Suggestion item text
285
+ &-suggestion-text {
286
+ flex: 1;
287
+ }
288
+
289
+ // Focus state
290
+ &--focused {
291
+ .#{$component}-container {
292
+ // No additional styles needed for focus in MD3
293
+ }
294
+ }
295
+
296
+ // Full width
297
+ &--fullwidth {
298
+ max-width: 100%;
299
+ }
300
+
301
+ // Expanded state (transitioning from bar to view)
302
+ &--expanded {
303
+ max-width: 100%;
304
+ width: 100%;
305
+ }
306
+ }
@@ -0,0 +1,203 @@
1
+ // src/components/search/api.ts
2
+ import { SearchComponent, SearchEvent } from './types';
3
+ import { SEARCH_COLORS, SEARCH_SIZES, SEARCH_EVENTS } from './constants';
4
+
5
+ /**
6
+ * API options interface - structured by feature area
7
+ */
8
+ interface ApiOptions {
9
+ search: {
10
+ setValue: (value: string, triggerEvent?: boolean) => any;
11
+ getValue: () => string;
12
+ setPlaceholder: (text: string) => any;
13
+ getPlaceholder: () => string;
14
+ focus: () => any;
15
+ blur: () => any;
16
+ expand: () => any;
17
+ collapse: () => any;
18
+ clear: () => any;
19
+ submit: () => any;
20
+ setSuggestions: (suggestions: any[]) => any;
21
+ showSuggestions: (show: boolean) => any;
22
+ };
23
+ disabled: {
24
+ enable: () => void;
25
+ disable: () => void;
26
+ isDisabled: () => boolean;
27
+ };
28
+ appearance: {
29
+ setColor: (color: string) => void;
30
+ getColor: () => string;
31
+ setSize: (size: string) => void;
32
+ getSize: () => string;
33
+ };
34
+ icons: {
35
+ setLeadingIcon: (iconHtml: string) => void;
36
+ setTrailingIcon: (iconHtml: string) => void;
37
+ setTrailingIcon2: (iconHtml: string) => void;
38
+ setAvatar: (avatarHtml: string) => void;
39
+ showClearButton: (show: boolean) => void;
40
+ };
41
+ events: {
42
+ on: (event: string, handler: Function) => void;
43
+ off: (event: string, handler: Function) => void;
44
+ };
45
+ lifecycle: {
46
+ destroy: () => void;
47
+ };
48
+ }
49
+
50
+ /**
51
+ * Enhances a search component with a streamlined API
52
+ * @param {ApiOptions} options - API configuration options
53
+ * @returns {Function} Higher-order function that adds API methods to component
54
+ * @internal This is an internal utility for the Search component
55
+ */
56
+ export const withAPI = (options: ApiOptions) =>
57
+ (component: { element: HTMLElement }): SearchComponent => {
58
+ return {
59
+ ...component as any,
60
+
61
+ // Element access
62
+ element: component.element,
63
+
64
+ // Value management
65
+ setValue(value: string, triggerEvent: boolean = true) {
66
+ options.search.setValue(value, triggerEvent);
67
+ return this;
68
+ },
69
+
70
+ getValue() {
71
+ return options.search.getValue();
72
+ },
73
+
74
+ // Placeholder management
75
+ setPlaceholder(text: string) {
76
+ options.search.setPlaceholder(text);
77
+ return this;
78
+ },
79
+
80
+ getPlaceholder() {
81
+ return options.search.getPlaceholder();
82
+ },
83
+
84
+ // Icon management
85
+ setLeadingIcon(iconHtml: string) {
86
+ options.icons.setLeadingIcon(iconHtml);
87
+ return this;
88
+ },
89
+
90
+ setTrailingIcon(iconHtml: string) {
91
+ options.icons.setTrailingIcon(iconHtml);
92
+ return this;
93
+ },
94
+
95
+ setTrailingIcon2(iconHtml: string) {
96
+ options.icons.setTrailingIcon2(iconHtml);
97
+ return this;
98
+ },
99
+
100
+ setAvatar(avatarHtml: string) {
101
+ options.icons.setAvatar(avatarHtml);
102
+ return this;
103
+ },
104
+
105
+ // Controls
106
+ showClearButton(show: boolean) {
107
+ options.icons.showClearButton(show);
108
+ return this;
109
+ },
110
+
111
+ setSuggestions(suggestions) {
112
+ options.search.setSuggestions(suggestions);
113
+ return this;
114
+ },
115
+
116
+ showSuggestions(show: boolean) {
117
+ options.search.showSuggestions(show);
118
+ return this;
119
+ },
120
+
121
+ focus() {
122
+ options.search.focus();
123
+ return this;
124
+ },
125
+
126
+ blur() {
127
+ options.search.blur();
128
+ return this;
129
+ },
130
+
131
+ expand() {
132
+ options.search.expand();
133
+ return this;
134
+ },
135
+
136
+ collapse() {
137
+ options.search.collapse();
138
+ return this;
139
+ },
140
+
141
+ clear() {
142
+ options.search.clear();
143
+ return this;
144
+ },
145
+
146
+ submit() {
147
+ options.search.submit();
148
+ return this;
149
+ },
150
+
151
+ // State management
152
+ enable() {
153
+ options.disabled.enable();
154
+ return this;
155
+ },
156
+
157
+ disable() {
158
+ options.disabled.disable();
159
+ return this;
160
+ },
161
+
162
+ isDisabled() {
163
+ return options.disabled.isDisabled();
164
+ },
165
+
166
+ // Appearance management
167
+ setColor(color: keyof typeof SEARCH_COLORS | typeof SEARCH_COLORS[keyof typeof SEARCH_COLORS]) {
168
+ options.appearance.setColor(color);
169
+ return this;
170
+ },
171
+
172
+ getColor() {
173
+ return options.appearance.getColor();
174
+ },
175
+
176
+ setSize(size: keyof typeof SEARCH_SIZES | typeof SEARCH_SIZES[keyof typeof SEARCH_SIZES]) {
177
+ options.appearance.setSize(size);
178
+ return this;
179
+ },
180
+
181
+ getSize() {
182
+ return options.appearance.getSize();
183
+ },
184
+
185
+ // Event management
186
+ on(event: keyof typeof SEARCH_EVENTS | typeof SEARCH_EVENTS[keyof typeof SEARCH_EVENTS], handler: (event: SearchEvent) => void) {
187
+ options.events.on(event, handler);
188
+ return this;
189
+ },
190
+
191
+ off(event: keyof typeof SEARCH_EVENTS | typeof SEARCH_EVENTS[keyof typeof SEARCH_EVENTS], handler: (event: SearchEvent) => void) {
192
+ options.events.off(event, handler);
193
+ return this;
194
+ },
195
+
196
+ // Lifecycle management
197
+ destroy() {
198
+ if (options.lifecycle?.destroy) {
199
+ options.lifecycle.destroy();
200
+ }
201
+ }
202
+ };
203
+ };
@@ -0,0 +1,87 @@
1
+ // src/components/search/config.ts
2
+ import {
3
+ createComponentConfig,
4
+ createElementConfig
5
+ } from '../../core/config/component-config';
6
+ import { SearchConfig } from './types';
7
+ import { SEARCH_VARIANTS } from './constants';
8
+
9
+ /**
10
+ * Default configuration for the Search component
11
+ */
12
+ export const defaultConfig: SearchConfig = {
13
+ variant: SEARCH_VARIANTS.BAR,
14
+ disabled: false,
15
+ placeholder: 'Search',
16
+ value: '',
17
+ leadingIcon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
18
+ showClearButton: true,
19
+ minWidth: 360,
20
+ maxWidth: 720,
21
+ fullWidth: false,
22
+ showDividers: true
23
+ };
24
+
25
+ /**
26
+ * Creates the base configuration for Search component
27
+ * @param {SearchConfig} config - User provided configuration
28
+ * @returns {SearchConfig} Complete configuration with defaults applied
29
+ */
30
+ export const createBaseConfig = (config: SearchConfig = {}): SearchConfig =>
31
+ createComponentConfig(defaultConfig, config, 'search') as SearchConfig;
32
+
33
+ /**
34
+ * Generates element configuration for the Search component
35
+ * @param {SearchConfig} config - Search configuration
36
+ * @returns {Object} Element configuration object for withElement
37
+ */
38
+ export const getElementConfig = (config: SearchConfig) =>
39
+ createElementConfig(config, {
40
+ tag: 'div',
41
+ attrs: {
42
+ role: 'search',
43
+ 'aria-disabled': config.disabled === true ? 'true' : 'false'
44
+ },
45
+ className: config.class
46
+ });
47
+
48
+ /**
49
+ * Creates API configuration for the Search component
50
+ * @param {Object} comp - Component with search features
51
+ * @returns {Object} API configuration object
52
+ */
53
+ export const getApiConfig = (comp) => ({
54
+ search: {
55
+ setValue: (v, t) => comp.search?.setValue(v, t),
56
+ getValue: () => comp.search?.getValue() ?? '',
57
+ setPlaceholder: (p) => comp.search?.setPlaceholder(p),
58
+ getPlaceholder: () => comp.search?.getPlaceholder() ?? '',
59
+ focus: () => comp.search?.focus(),
60
+ blur: () => comp.search?.blur(),
61
+ expand: () => comp.search?.expand(),
62
+ collapse: () => comp.search?.collapse(),
63
+ clear: () => comp.search?.clear(),
64
+ submit: () => comp.search?.submit(),
65
+ setSuggestions: (s) => comp.search?.setSuggestions(s),
66
+ showSuggestions: (s) => comp.search?.showSuggestions(s)
67
+ },
68
+ disabled: {
69
+ enable: () => comp.disabled?.enable?.(),
70
+ disable: () => comp.disabled?.disable?.(),
71
+ isDisabled: () => comp.disabled?.isDisabled?.() ?? false
72
+ },
73
+ appearance: {
74
+ setLeadingIcon: (i) => comp.icons?.setLeadingIcon?.(i),
75
+ setTrailingIcon: (i) => comp.icons?.setTrailingIcon?.(i),
76
+ setTrailingIcon2: (i) => comp.icons?.setTrailingIcon2?.(i),
77
+ setAvatar: (a) => comp.icons?.setAvatar?.(a),
78
+ showClearButton: (s) => comp.icons?.showClearButton?.(s)
79
+ },
80
+ events: {
81
+ on: (e, h) => comp.on?.(e, h),
82
+ off: (e, h) => comp.off?.(e, h)
83
+ },
84
+ lifecycle: {
85
+ destroy: () => comp.lifecycle?.destroy?.()
86
+ }
87
+ });
@@ -0,0 +1,21 @@
1
+ // src/components/search/constants.ts
2
+
3
+ /**
4
+ * Available search component variants
5
+ */
6
+ export const SEARCH_VARIANTS = {
7
+ BAR: 'bar',
8
+ VIEW: 'view'
9
+ } as const;
10
+
11
+ /**
12
+ * Available search component events
13
+ */
14
+ export const SEARCH_EVENTS = {
15
+ FOCUS: 'focus',
16
+ BLUR: 'blur',
17
+ INPUT: 'input',
18
+ SUBMIT: 'submit',
19
+ CLEAR: 'clear',
20
+ ICON_CLICK: 'iconClick'
21
+ } as const;
@@ -0,0 +1,4 @@
1
+ // src/components/search/features/index.ts
2
+ export { withStructure } from './structure';
3
+ export { withStates } from './states';
4
+ export { withSearch } from './search';