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,6 +1,6 @@
|
|
|
1
|
-
// src/components/dialog/api.ts
|
|
2
|
-
import { DialogComponent, DialogEvent, DialogButton, DialogConfirmOptions } from './types';
|
|
3
|
-
import {
|
|
1
|
+
// src/components/dialog/api.ts (partial update)
|
|
2
|
+
import { DialogComponent, DialogEvent, DialogButton, DialogConfirmOptions, DialogFooterAlignment, DialogSize, DialogEventType } from './types';
|
|
3
|
+
import { removeClass } from '../../core/dom/classes';
|
|
4
4
|
|
|
5
5
|
interface ApiOptions {
|
|
6
6
|
visibility: {
|
|
@@ -24,14 +24,18 @@ interface ApiOptions {
|
|
|
24
24
|
addButton: (button: DialogButton) => void;
|
|
25
25
|
removeButton: (indexOrText: number | string) => void;
|
|
26
26
|
getButtons: () => DialogButton[];
|
|
27
|
-
setFooterAlignment: (alignment:
|
|
27
|
+
setFooterAlignment: (alignment: DialogFooterAlignment | string) => void;
|
|
28
28
|
};
|
|
29
29
|
focus: {
|
|
30
30
|
trapFocus: () => void;
|
|
31
31
|
releaseFocus: () => void;
|
|
32
32
|
};
|
|
33
33
|
size: {
|
|
34
|
-
setSize: (size:
|
|
34
|
+
setSize: (size: DialogSize | string) => void;
|
|
35
|
+
};
|
|
36
|
+
dividers: {
|
|
37
|
+
toggleHeaderDivider: (show: boolean) => void;
|
|
38
|
+
toggleFooterDivider: (show: boolean) => void;
|
|
35
39
|
};
|
|
36
40
|
events: {
|
|
37
41
|
on: (event: string, handler: Function) => void;
|
|
@@ -46,6 +50,7 @@ interface ApiOptions {
|
|
|
46
50
|
interface ComponentWithElements {
|
|
47
51
|
element: HTMLElement;
|
|
48
52
|
overlay: HTMLElement;
|
|
53
|
+
getClass: (name: string) => string;
|
|
49
54
|
confirm?: (options: DialogConfirmOptions) => Promise<boolean>;
|
|
50
55
|
}
|
|
51
56
|
|
|
@@ -130,7 +135,7 @@ export const withAPI = (options: ApiOptions) =>
|
|
|
130
135
|
getSubtitle() {
|
|
131
136
|
return options.content.getSubtitle();
|
|
132
137
|
},
|
|
133
|
-
|
|
138
|
+
|
|
134
139
|
/**
|
|
135
140
|
* Sets dialog content
|
|
136
141
|
* @param {string} content - Content HTML
|
|
@@ -182,17 +187,35 @@ export const withAPI = (options: ApiOptions) =>
|
|
|
182
187
|
* @param {string} alignment - Footer alignment
|
|
183
188
|
* @returns {DialogComponent} Dialog component instance for chaining
|
|
184
189
|
*/
|
|
185
|
-
setFooterAlignment(alignment:
|
|
190
|
+
setFooterAlignment(alignment: DialogFooterAlignment | string) {
|
|
186
191
|
options.buttons.setFooterAlignment(alignment);
|
|
187
192
|
return this;
|
|
188
193
|
},
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Shows or hides the divider
|
|
197
|
+
* @param {boolean} show - Whether to show the divider
|
|
198
|
+
* @returns {DialogComponent} Dialog component instance for chaining
|
|
199
|
+
*/
|
|
200
|
+
toggleDivider(show: boolean) {
|
|
201
|
+
options.divider.toggleDivider(show);
|
|
202
|
+
return this;
|
|
203
|
+
},
|
|
189
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Checks if the dialog has a divider
|
|
207
|
+
* @returns {boolean} True if the dialog has a divider
|
|
208
|
+
*/
|
|
209
|
+
hasDivider() {
|
|
210
|
+
return options.divider.hasDivider();
|
|
211
|
+
},
|
|
212
|
+
|
|
190
213
|
/**
|
|
191
214
|
* Sets dialog size
|
|
192
215
|
* @param {string} size - Size variant
|
|
193
216
|
* @returns {DialogComponent} Dialog component instance for chaining
|
|
194
217
|
*/
|
|
195
|
-
setSize(size:
|
|
218
|
+
setSize(size: DialogSize | string) {
|
|
196
219
|
options.size.setSize(size);
|
|
197
220
|
return this;
|
|
198
221
|
},
|
|
@@ -203,7 +226,7 @@ export const withAPI = (options: ApiOptions) =>
|
|
|
203
226
|
* @param {Function} handler - Event handler
|
|
204
227
|
* @returns {DialogComponent} Dialog component instance for chaining
|
|
205
228
|
*/
|
|
206
|
-
on(event:
|
|
229
|
+
on(event: DialogEventType | string, handler: (event: DialogEvent) => void) {
|
|
207
230
|
options.events.on(event, handler);
|
|
208
231
|
return this;
|
|
209
232
|
},
|
|
@@ -214,7 +237,7 @@ export const withAPI = (options: ApiOptions) =>
|
|
|
214
237
|
* @param {Function} handler - Event handler
|
|
215
238
|
* @returns {DialogComponent} Dialog component instance for chaining
|
|
216
239
|
*/
|
|
217
|
-
off(event:
|
|
240
|
+
off(event: DialogEventType | string, handler: (event: DialogEvent) => void) {
|
|
218
241
|
options.events.off(event, handler);
|
|
219
242
|
return this;
|
|
220
243
|
},
|
|
@@ -261,20 +284,31 @@ export const withAPI = (options: ApiOptions) =>
|
|
|
261
284
|
* Destroys the dialog and removes it from DOM
|
|
262
285
|
*/
|
|
263
286
|
destroy() {
|
|
264
|
-
// Close the dialog first
|
|
287
|
+
// Close the dialog first if it's open
|
|
288
|
+
console.log('destroy', this.isOpen());
|
|
265
289
|
if (this.isOpen()) {
|
|
266
|
-
this.close()
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
setTimeout(() => {
|
|
271
|
-
options.lifecycle.destroy();
|
|
290
|
+
// We'll handle removal directly rather than calling this.close()
|
|
291
|
+
// to avoid animation delay in critical cleanup
|
|
292
|
+
const dialogVisibleClass = `${component.getClass('dialog')}--visible`;
|
|
293
|
+
const overlayVisibleClass = `${component.getClass('dialog-overlay')}--visible`;
|
|
272
294
|
|
|
273
|
-
// Remove
|
|
274
|
-
|
|
275
|
-
|
|
295
|
+
// Remove visibility classes using core utilities
|
|
296
|
+
removeClass(component.element, dialogVisibleClass);
|
|
297
|
+
removeClass(component.overlay, overlayVisibleClass);
|
|
298
|
+
|
|
299
|
+
// Call any cleanup needed
|
|
300
|
+
if (options.focus && options.focus.releaseFocus) {
|
|
301
|
+
options.focus.releaseFocus();
|
|
276
302
|
}
|
|
277
|
-
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Call lifecycle destroy
|
|
306
|
+
options.lifecycle.destroy();
|
|
307
|
+
|
|
308
|
+
// Immediately remove from DOM
|
|
309
|
+
if (component.overlay && component.overlay.parentNode) {
|
|
310
|
+
component.overlay.parentNode.removeChild(component.overlay);
|
|
311
|
+
}
|
|
278
312
|
},
|
|
279
313
|
|
|
280
314
|
// Pass through element references
|
|
@@ -4,15 +4,14 @@ import {
|
|
|
4
4
|
createElementConfig
|
|
5
5
|
} from '../../core/config/component-config';
|
|
6
6
|
import { DialogConfig } from './types';
|
|
7
|
-
import { DIALOG_SIZES, DIALOG_ANIMATIONS, DIALOG_FOOTER_ALIGNMENTS } from './constants';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Default configuration for the Dialog component
|
|
11
10
|
*/
|
|
12
11
|
export const defaultConfig: DialogConfig = {
|
|
13
|
-
size:
|
|
14
|
-
animation:
|
|
15
|
-
footerAlignment:
|
|
12
|
+
size: 'medium',
|
|
13
|
+
animation: 'scale',
|
|
14
|
+
footerAlignment: 'right',
|
|
16
15
|
open: false,
|
|
17
16
|
closeButton: true,
|
|
18
17
|
closeOnOverlayClick: true,
|
|
@@ -20,8 +19,7 @@ export const defaultConfig: DialogConfig = {
|
|
|
20
19
|
modal: true,
|
|
21
20
|
autofocus: true,
|
|
22
21
|
trapFocus: true,
|
|
23
|
-
|
|
24
|
-
footerDivider: false,
|
|
22
|
+
divider: false, // Default to no divider
|
|
25
23
|
animationDuration: 150,
|
|
26
24
|
buttons: []
|
|
27
25
|
};
|
|
@@ -100,10 +98,15 @@ export const getApiConfig = (comp) => ({
|
|
|
100
98
|
size: {
|
|
101
99
|
setSize: (size) => comp.size.setSize(size)
|
|
102
100
|
},
|
|
101
|
+
divider: {
|
|
102
|
+
toggleDivider: (show) => comp.divider.toggleDivider(show),
|
|
103
|
+
hasDivider: () => comp.divider.hasDivider()
|
|
104
|
+
},
|
|
103
105
|
events: {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
// Use the direct component methods from withEvents()
|
|
107
|
+
on: (event, handler) => comp.on(event, handler),
|
|
108
|
+
off: (event, handler) => comp.off(event, handler),
|
|
109
|
+
trigger: (event, data) => comp.emit(event, data)
|
|
107
110
|
},
|
|
108
111
|
lifecycle: {
|
|
109
112
|
destroy: () => comp.lifecycle.destroy()
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
withContent,
|
|
9
9
|
withButtons,
|
|
10
10
|
withSize,
|
|
11
|
-
withConfirm
|
|
11
|
+
withConfirm,
|
|
12
|
+
withDivider // Simplified to single divider feature
|
|
12
13
|
} from './features';
|
|
13
14
|
import { withAPI } from './api';
|
|
14
15
|
import { DialogConfig, DialogComponent } from './types';
|
|
@@ -23,15 +24,17 @@ const createDialog = (config: DialogConfig = {}): DialogComponent => {
|
|
|
23
24
|
const baseConfig = createBaseConfig(config);
|
|
24
25
|
|
|
25
26
|
try {
|
|
27
|
+
// Maintain original order but setup event-based communication
|
|
26
28
|
const dialog = pipe(
|
|
27
29
|
createBase,
|
|
28
30
|
withEvents(),
|
|
29
31
|
withElement(getElementConfig(baseConfig)),
|
|
30
|
-
withStructure(baseConfig),
|
|
31
|
-
withVisibility(),
|
|
32
|
+
withStructure(baseConfig), // Keep structure first to create overlay
|
|
33
|
+
withVisibility(), // Then add visibility features
|
|
32
34
|
withContent(),
|
|
33
35
|
withButtons(),
|
|
34
36
|
withSize(),
|
|
37
|
+
withDivider(), // Simplified divider feature
|
|
35
38
|
withConfirm(),
|
|
36
39
|
withLifecycle(),
|
|
37
40
|
comp => withAPI(getApiConfig(comp))(comp)
|