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.
- package/demo/build.ts +349 -0
- package/demo/index.html +110 -0
- package/demo/main.js +448 -0
- package/demo/styles.css +239 -0
- package/index.ts +18 -0
- package/package.json +14 -3
- package/server.ts +86 -0
- package/src/components/badge/api.ts +70 -63
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +66 -13
- package/src/components/badge/features.ts +51 -42
- package/src/components/badge/index.ts +27 -2
- package/src/components/badge/types.ts +62 -30
- package/src/components/bottom-app-bar/bottom-app-bar.ts +154 -0
- package/src/components/bottom-app-bar/config.ts +29 -0
- package/src/components/bottom-app-bar/index.ts +17 -0
- package/src/components/bottom-app-bar/types.ts +114 -0
- package/src/components/button/api.ts +5 -0
- package/src/components/button/button.ts +0 -1
- package/src/components/button/config.ts +6 -2
- package/src/components/button/index.ts +10 -2
- package/src/components/button/types.ts +20 -2
- package/src/components/card/card.ts +13 -25
- package/src/components/card/config.ts +83 -30
- package/src/components/card/content.ts +8 -10
- package/src/components/card/features.ts +4 -3
- package/src/components/card/index.ts +29 -2
- package/src/components/card/types.ts +33 -22
- package/src/components/checkbox/config.ts +3 -4
- package/src/components/checkbox/index.ts +1 -2
- package/src/components/checkbox/types.ts +12 -3
- package/src/components/chip/api.ts +170 -221
- package/src/components/chip/chip.ts +34 -302
- package/src/components/chip/config.ts +1 -2
- package/src/components/chip/index.ts +10 -2
- package/src/components/chip/types.ts +224 -35
- package/src/components/datepicker/api.ts +265 -0
- package/src/components/datepicker/config.ts +141 -0
- package/src/components/datepicker/datepicker.ts +341 -0
- package/src/components/datepicker/index.ts +12 -0
- package/src/components/datepicker/render.ts +450 -0
- package/src/components/datepicker/types.ts +397 -0
- package/src/components/datepicker/utils.ts +289 -0
- package/src/components/dialog/api.ts +55 -21
- package/src/components/dialog/config.ts +12 -9
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +345 -151
- package/src/components/dialog/index.ts +38 -8
- package/src/components/dialog/types.ts +40 -14
- package/src/components/divider/config.ts +81 -0
- package/src/components/divider/divider.ts +37 -0
- package/src/components/divider/features.ts +207 -0
- package/src/components/divider/index.ts +9 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +112 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +9 -0
- package/src/components/extended-fab/types.ts +304 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +93 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +9 -0
- package/src/components/fab/types.ts +251 -0
- package/src/components/list/config.ts +4 -5
- package/src/components/list/features.ts +6 -7
- package/src/components/list/index.ts +7 -9
- package/src/components/list/list-item.ts +12 -13
- package/src/components/list/types.ts +50 -5
- package/src/components/list/utils.ts +30 -3
- package/src/components/menu/features/items-manager.ts +9 -9
- package/src/components/menu/features/positioning.ts +7 -7
- package/src/components/menu/features/visibility.ts +7 -7
- package/src/components/menu/index.ts +7 -9
- package/src/components/menu/menu-item.ts +6 -6
- package/src/components/menu/menu.ts +22 -0
- package/src/components/menu/types.ts +29 -10
- package/src/components/menu/utils.ts +67 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/config.ts +22 -10
- package/src/components/navigation/features/items.ts +284 -0
- package/src/components/navigation/index.ts +0 -6
- package/src/components/navigation/nav-item.ts +70 -33
- package/src/components/navigation/navigation.ts +53 -3
- package/src/components/navigation/types.ts +117 -70
- package/src/components/progress/api.ts +2 -3
- package/src/components/progress/config.ts +2 -3
- package/src/components/progress/index.ts +0 -1
- package/src/components/progress/progress.ts +1 -2
- package/src/components/progress/types.ts +186 -33
- package/src/components/radios/config.ts +1 -1
- package/src/components/radios/index.ts +0 -1
- package/src/components/radios/types.ts +0 -7
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +86 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +717 -0
- package/src/components/search/features/states.ts +169 -0
- package/src/components/search/features/structure.ts +197 -0
- package/src/components/search/index.ts +7 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +175 -0
- package/src/components/segmented-button/config.ts +80 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +154 -0
- package/src/components/segmented-button/segmented-button.ts +249 -0
- package/src/components/segmented-button/types.ts +254 -0
- package/src/components/slider/accessibility.md +5 -5
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -47
- package/src/components/slider/features/handlers.ts +495 -0
- package/src/components/slider/features/index.ts +1 -2
- package/src/components/slider/features/slider.ts +66 -84
- package/src/components/slider/features/states.ts +195 -0
- package/src/components/slider/features/structure.ts +136 -206
- package/src/components/slider/features/ui.ts +145 -206
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +67 -26
- package/src/components/snackbar/config.ts +2 -3
- package/src/components/snackbar/constants.ts +0 -32
- package/src/components/snackbar/index.ts +0 -1
- package/src/components/snackbar/position.ts +9 -1
- package/src/components/snackbar/types.ts +122 -46
- package/src/components/switch/config.ts +2 -3
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/types.ts +3 -2
- package/src/components/tabs/config.ts +3 -4
- package/src/components/tabs/features.ts +4 -2
- package/src/components/tabs/index.ts +0 -15
- package/src/components/tabs/indicator.ts +73 -13
- package/src/components/tabs/tab-api.ts +12 -4
- package/src/components/tabs/tab.ts +18 -6
- package/src/components/tabs/types.ts +23 -5
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/index.ts +0 -1
- package/src/components/textfield/types.ts +17 -3
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +228 -0
- package/src/components/timepicker/index.ts +3 -0
- package/src/components/timepicker/render.ts +613 -0
- package/src/components/timepicker/timepicker.ts +117 -0
- package/src/components/timepicker/types.ts +336 -0
- package/src/components/timepicker/utils.ts +241 -0
- package/src/components/tooltip/api.ts +1 -1
- package/src/components/tooltip/config.ts +27 -6
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/types.ts +13 -3
- package/src/components/top-app-bar/config.ts +83 -0
- package/src/components/top-app-bar/index.ts +11 -0
- package/src/components/top-app-bar/top-app-bar.ts +316 -0
- package/src/components/top-app-bar/types.ts +140 -0
- package/src/core/build/_ripple.scss +6 -6
- package/src/core/build/ripple.ts +72 -95
- package/src/core/compose/features/icon.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +23 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +9 -1
- package/src/styles/components/_badge.scss +182 -0
- package/src/styles/components/_bottom-app-bar.scss +103 -0
- package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -10
- package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -2
- package/src/styles/components/_datepicker.scss +358 -0
- package/src/styles/components/_dialog.scss +259 -0
- package/src/styles/components/_divider.scss +57 -0
- package/src/styles/components/_extended-fab.scss +267 -0
- package/src/styles/components/_fab.scss +225 -0
- package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +1 -0
- package/src/styles/components/_search.scss +306 -0
- package/src/styles/components/_segmented-button.scss +117 -0
- package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +83 -24
- package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -2
- package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +95 -33
- package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
- package/src/styles/components/_timepicker.scss +451 -0
- package/src/styles/components/_top-app-bar.scss +225 -0
- package/src/styles/main.scss +98 -49
- package/src/styles/themes/_autumn.scss +21 -0
- package/src/styles/themes/_base-theme.scss +61 -0
- package/src/styles/themes/_baseline.scss +58 -0
- package/src/styles/themes/_bluekhaki.scss +125 -0
- package/src/styles/themes/_brownbeige.scss +125 -0
- package/src/styles/themes/_browngreen.scss +125 -0
- package/src/styles/themes/_forest.scss +6 -0
- package/src/styles/themes/_greenbeige.scss +125 -0
- package/src/styles/themes/_material.scss +125 -0
- package/src/styles/themes/_ocean.scss +6 -0
- package/src/styles/themes/_sageivory.scss +125 -0
- package/src/styles/themes/_spring.scss +6 -0
- package/src/styles/themes/_summer.scss +5 -0
- package/src/styles/themes/_sunset.scss +5 -0
- package/src/styles/themes/_tealcaramel.scss +125 -0
- package/src/styles/themes/_winter.scss +6 -0
- package/src/components/badge/_styles.scss +0 -174
- package/src/components/badge/constants.ts +0 -30
- package/src/components/button/constants.ts +0 -11
- package/src/components/card/constants.ts +0 -84
- package/src/components/dialog/_styles.scss +0 -213
- package/src/components/dialog/constants.ts +0 -32
- package/src/components/menu/constants.ts +0 -154
- package/src/components/navigation/constants.ts +0 -200
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/progress/constants.ts +0 -29
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -68
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -396
- package/src/components/slider/features/keyboard.ts +0 -233
- package/src/components/switch/constants.ts +0 -80
- package/src/components/tabs/constants.ts +0 -89
- package/src/core/collection/adapters/mongodb.js +0 -232
- /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
- /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
- /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
- /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
- /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
- /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
- /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
- /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
- /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
- /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
- /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/components/radios/types.ts
|
|
2
|
-
import { RADIO_DIRECTIONS } from './constants';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Configuration for a radio option in the Radios component
|
|
@@ -58,12 +57,6 @@ export interface RadiosConfig {
|
|
|
58
57
|
*/
|
|
59
58
|
disabled?: boolean;
|
|
60
59
|
|
|
61
|
-
/**
|
|
62
|
-
* Group layout direction
|
|
63
|
-
* @default 'vertical'
|
|
64
|
-
*/
|
|
65
|
-
direction?: keyof typeof RADIO_DIRECTIONS | string;
|
|
66
|
-
|
|
67
60
|
/**
|
|
68
61
|
* Whether to enable ripple effect
|
|
69
62
|
* @default true
|
|
@@ -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,86 @@
|
|
|
1
|
+
// src/components/search/config.ts
|
|
2
|
+
import {
|
|
3
|
+
createComponentConfig,
|
|
4
|
+
createElementConfig
|
|
5
|
+
} from '../../core/config/component-config';
|
|
6
|
+
import { SearchConfig } from './types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Default configuration for the Search component
|
|
10
|
+
*/
|
|
11
|
+
export const defaultConfig: SearchConfig = {
|
|
12
|
+
variant: 'bar',
|
|
13
|
+
disabled: false,
|
|
14
|
+
placeholder: 'Search',
|
|
15
|
+
value: '',
|
|
16
|
+
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>',
|
|
17
|
+
showClearButton: true,
|
|
18
|
+
minWidth: 360,
|
|
19
|
+
maxWidth: 720,
|
|
20
|
+
fullWidth: false,
|
|
21
|
+
showDividers: true
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates the base configuration for Search component
|
|
26
|
+
* @param {SearchConfig} config - User provided configuration
|
|
27
|
+
* @returns {SearchConfig} Complete configuration with defaults applied
|
|
28
|
+
*/
|
|
29
|
+
export const createBaseConfig = (config: SearchConfig = {}): SearchConfig =>
|
|
30
|
+
createComponentConfig(defaultConfig, config, 'search') as SearchConfig;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generates element configuration for the Search component
|
|
34
|
+
* @param {SearchConfig} config - Search configuration
|
|
35
|
+
* @returns {Object} Element configuration object for withElement
|
|
36
|
+
*/
|
|
37
|
+
export const getElementConfig = (config: SearchConfig) =>
|
|
38
|
+
createElementConfig(config, {
|
|
39
|
+
tag: 'div',
|
|
40
|
+
attrs: {
|
|
41
|
+
role: 'search',
|
|
42
|
+
'aria-disabled': config.disabled === true ? 'true' : 'false'
|
|
43
|
+
},
|
|
44
|
+
className: config.class
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates API configuration for the Search component
|
|
49
|
+
* @param {Object} comp - Component with search features
|
|
50
|
+
* @returns {Object} API configuration object
|
|
51
|
+
*/
|
|
52
|
+
export const getApiConfig = (comp) => ({
|
|
53
|
+
search: {
|
|
54
|
+
setValue: (v, t) => comp.search?.setValue(v, t),
|
|
55
|
+
getValue: () => comp.search?.getValue() ?? '',
|
|
56
|
+
setPlaceholder: (p) => comp.search?.setPlaceholder(p),
|
|
57
|
+
getPlaceholder: () => comp.search?.getPlaceholder() ?? '',
|
|
58
|
+
focus: () => comp.search?.focus(),
|
|
59
|
+
blur: () => comp.search?.blur(),
|
|
60
|
+
expand: () => comp.search?.expand(),
|
|
61
|
+
collapse: () => comp.search?.collapse(),
|
|
62
|
+
clear: () => comp.search?.clear(),
|
|
63
|
+
submit: () => comp.search?.submit(),
|
|
64
|
+
setSuggestions: (s) => comp.search?.setSuggestions(s),
|
|
65
|
+
showSuggestions: (s) => comp.search?.showSuggestions(s)
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
enable: () => comp.disabled?.enable?.(),
|
|
69
|
+
disable: () => comp.disabled?.disable?.(),
|
|
70
|
+
isDisabled: () => comp.disabled?.isDisabled?.() ?? false
|
|
71
|
+
},
|
|
72
|
+
appearance: {
|
|
73
|
+
setLeadingIcon: (i) => comp.icons?.setLeadingIcon?.(i),
|
|
74
|
+
setTrailingIcon: (i) => comp.icons?.setTrailingIcon?.(i),
|
|
75
|
+
setTrailingIcon2: (i) => comp.icons?.setTrailingIcon2?.(i),
|
|
76
|
+
setAvatar: (a) => comp.icons?.setAvatar?.(a),
|
|
77
|
+
showClearButton: (s) => comp.icons?.showClearButton?.(s)
|
|
78
|
+
},
|
|
79
|
+
events: {
|
|
80
|
+
on: (e, h) => comp.on?.(e, h),
|
|
81
|
+
off: (e, h) => comp.off?.(e, h)
|
|
82
|
+
},
|
|
83
|
+
lifecycle: {
|
|
84
|
+
destroy: () => comp.lifecycle?.destroy?.()
|
|
85
|
+
}
|
|
86
|
+
});
|