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,9 +1,49 @@
|
|
|
1
1
|
// src/components/navigation/types.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Navigation variants following Material Design 3
|
|
5
|
+
* @category Components
|
|
6
|
+
*/
|
|
7
|
+
export type NavVariant = 'rail' | 'drawer' | 'bar' | 'modal' | 'standard';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Navigation positions
|
|
11
|
+
* @category Components
|
|
12
|
+
*/
|
|
13
|
+
export type NavPosition = 'left' | 'right' | 'top' | 'bottom';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Navigation behaviors
|
|
17
|
+
* @category Components
|
|
18
|
+
*/
|
|
19
|
+
export type NavBehavior = 'fixed' | 'dismissible' | 'modal';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Navigation item state
|
|
23
|
+
* @category Components
|
|
24
|
+
*/
|
|
25
|
+
export type NavItemState = 'active' | 'disabled' | 'expanded' | 'collapsed' | 'hovered' | 'focused' | 'pressed';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Navigation element class names
|
|
29
|
+
* Used internally to maintain consistent class names
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export const NavClass = {
|
|
33
|
+
ITEM: 'nav-item',
|
|
34
|
+
ITEM_CONTAINER: 'nav-item-container',
|
|
35
|
+
ICON: 'nav-item-icon',
|
|
36
|
+
LABEL: 'nav-item-label',
|
|
37
|
+
BADGE: 'nav-item-badge',
|
|
38
|
+
DIVIDER: 'nav-divider',
|
|
39
|
+
SCRIM: 'nav-scrim',
|
|
40
|
+
GROUP: 'nav-group',
|
|
41
|
+
GROUP_TITLE: 'nav-group-title',
|
|
42
|
+
SUBTITLE: 'nav-subtitle',
|
|
43
|
+
NESTED_CONTAINER: 'nav-nested-container',
|
|
44
|
+
NESTED_ITEM: 'nav-nested-item',
|
|
45
|
+
EXPAND_ICON: 'nav-expand-icon'
|
|
46
|
+
} as const;
|
|
7
47
|
|
|
8
48
|
/**
|
|
9
49
|
* Navigation item configuration
|
|
@@ -12,13 +52,13 @@ export interface NavItemConfig {
|
|
|
12
52
|
/** Unique identifier for the item */
|
|
13
53
|
id: string;
|
|
14
54
|
|
|
15
|
-
/** HTML content
|
|
16
|
-
icon
|
|
55
|
+
/** Icon HTML content */
|
|
56
|
+
icon?: string;
|
|
17
57
|
|
|
18
|
-
/** Text label
|
|
19
|
-
label
|
|
58
|
+
/** Text label */
|
|
59
|
+
label?: string;
|
|
20
60
|
|
|
21
|
-
/**
|
|
61
|
+
/** Badge text */
|
|
22
62
|
badge?: string;
|
|
23
63
|
|
|
24
64
|
/** Whether the item is disabled */
|
|
@@ -27,17 +67,17 @@ export interface NavItemConfig {
|
|
|
27
67
|
/** Whether the item is active */
|
|
28
68
|
active?: boolean;
|
|
29
69
|
|
|
30
|
-
/**
|
|
70
|
+
/** Whether nested items are expanded */
|
|
71
|
+
expanded?: boolean;
|
|
72
|
+
|
|
73
|
+
/** Subtitle text (for drawer items) */
|
|
31
74
|
subtitle?: string;
|
|
32
75
|
|
|
33
|
-
/** ID
|
|
76
|
+
/** Group ID this item belongs to */
|
|
34
77
|
groupId?: string;
|
|
35
78
|
|
|
36
79
|
/** Nested navigation items */
|
|
37
80
|
items?: NavItemConfig[];
|
|
38
|
-
|
|
39
|
-
/** Whether nested items are expanded */
|
|
40
|
-
expanded?: boolean;
|
|
41
81
|
}
|
|
42
82
|
|
|
43
83
|
/**
|
|
@@ -55,10 +95,10 @@ export interface NavGroupConfig {
|
|
|
55
95
|
}
|
|
56
96
|
|
|
57
97
|
/**
|
|
58
|
-
*
|
|
98
|
+
* Navigation item data
|
|
59
99
|
*/
|
|
60
100
|
export interface NavItemData {
|
|
61
|
-
/** DOM element
|
|
101
|
+
/** The item's DOM element */
|
|
62
102
|
element: HTMLElement;
|
|
63
103
|
|
|
64
104
|
/** Item configuration */
|
|
@@ -69,14 +109,14 @@ export interface NavItemData {
|
|
|
69
109
|
* Navigation change event data
|
|
70
110
|
*/
|
|
71
111
|
export interface NavChangeEvent {
|
|
72
|
-
/** ID of the
|
|
112
|
+
/** ID of the selected item */
|
|
73
113
|
id: string;
|
|
74
114
|
|
|
75
|
-
/**
|
|
115
|
+
/** Selected item data */
|
|
76
116
|
item: NavItemData;
|
|
77
117
|
|
|
78
|
-
/** Previously
|
|
79
|
-
previousItem
|
|
118
|
+
/** Previously selected item data */
|
|
119
|
+
previousItem?: NavItemData | null;
|
|
80
120
|
|
|
81
121
|
/** Path of parent item IDs */
|
|
82
122
|
path: string[];
|
|
@@ -87,15 +127,15 @@ export interface NavChangeEvent {
|
|
|
87
127
|
*/
|
|
88
128
|
export interface NavigationConfig {
|
|
89
129
|
/** Navigation variant */
|
|
90
|
-
variant?:
|
|
130
|
+
variant?: NavVariant | string;
|
|
91
131
|
|
|
92
132
|
/** Navigation position */
|
|
93
|
-
position?:
|
|
133
|
+
position?: NavPosition | string;
|
|
94
134
|
|
|
95
135
|
/** Navigation behavior */
|
|
96
|
-
behavior?:
|
|
136
|
+
behavior?: NavBehavior | string;
|
|
97
137
|
|
|
98
|
-
/**
|
|
138
|
+
/** Navigation items */
|
|
99
139
|
items?: NavItemConfig[];
|
|
100
140
|
|
|
101
141
|
/** Navigation groups */
|
|
@@ -104,22 +144,22 @@ export interface NavigationConfig {
|
|
|
104
144
|
/** Whether the navigation is disabled */
|
|
105
145
|
disabled?: boolean;
|
|
106
146
|
|
|
107
|
-
/** Whether
|
|
147
|
+
/** Whether the navigation is expanded (for drawer) */
|
|
108
148
|
expanded?: boolean;
|
|
109
149
|
|
|
110
|
-
/** Whether to show labels */
|
|
150
|
+
/** Whether to show item labels */
|
|
111
151
|
showLabels?: boolean;
|
|
112
152
|
|
|
113
|
-
/** Whether
|
|
153
|
+
/** Whether to enable background scrim (for modal drawer) */
|
|
114
154
|
scrimEnabled?: boolean;
|
|
115
155
|
|
|
116
|
-
/** ARIA label for accessibility */
|
|
117
|
-
ariaLabel?: string;
|
|
118
|
-
|
|
119
156
|
/** Additional CSS classes */
|
|
120
157
|
class?: string;
|
|
121
158
|
|
|
122
|
-
/**
|
|
159
|
+
/** Accessibility label */
|
|
160
|
+
ariaLabel?: string;
|
|
161
|
+
|
|
162
|
+
/** Component prefix for class names */
|
|
123
163
|
prefix?: string;
|
|
124
164
|
|
|
125
165
|
/** Component name */
|
|
@@ -130,83 +170,90 @@ export interface NavigationConfig {
|
|
|
130
170
|
* Navigation component interface
|
|
131
171
|
*/
|
|
132
172
|
export interface NavigationComponent {
|
|
133
|
-
/** The
|
|
173
|
+
/** The navigation's DOM element */
|
|
134
174
|
element: HTMLElement;
|
|
135
175
|
|
|
136
|
-
/** Map of
|
|
176
|
+
/** Map of navigation items */
|
|
137
177
|
items: Map<string, NavItemData>;
|
|
138
178
|
|
|
139
|
-
/** Adds a
|
|
140
|
-
addItem: (
|
|
179
|
+
/** Adds a navigation item */
|
|
180
|
+
addItem: (config: NavItemConfig) => NavigationComponent;
|
|
141
181
|
|
|
142
|
-
/** Removes a navigation item
|
|
182
|
+
/** Removes a navigation item */
|
|
143
183
|
removeItem: (id: string) => NavigationComponent;
|
|
144
184
|
|
|
145
|
-
/**
|
|
185
|
+
/** Gets a navigation item by ID */
|
|
146
186
|
getItem: (id: string) => NavItemData | undefined;
|
|
147
187
|
|
|
148
|
-
/**
|
|
188
|
+
/** Gets all navigation items */
|
|
149
189
|
getAllItems: () => NavItemData[];
|
|
150
190
|
|
|
151
|
-
/** Gets the
|
|
191
|
+
/** Gets the active navigation item */
|
|
152
192
|
getActive: () => NavItemData | null;
|
|
153
193
|
|
|
154
194
|
/** Gets the path to an item (parent IDs) */
|
|
155
195
|
getItemPath: (id: string) => string[];
|
|
156
196
|
|
|
157
|
-
/** Sets
|
|
197
|
+
/** Sets the active navigation item */
|
|
158
198
|
setActive: (id: string) => NavigationComponent;
|
|
159
199
|
|
|
160
|
-
/** Adds event listener */
|
|
161
|
-
on: (event: string, handler: Function) => NavigationComponent;
|
|
162
|
-
|
|
163
|
-
/** Removes event listener */
|
|
164
|
-
off: (event: string, handler: Function) => NavigationComponent;
|
|
165
|
-
|
|
166
200
|
/** Enables the navigation */
|
|
167
201
|
enable: () => NavigationComponent;
|
|
168
202
|
|
|
169
203
|
/** Disables the navigation */
|
|
170
204
|
disable: () => NavigationComponent;
|
|
171
205
|
|
|
172
|
-
/**
|
|
206
|
+
/** Expands the navigation (for drawer) */
|
|
207
|
+
expand: () => NavigationComponent;
|
|
208
|
+
|
|
209
|
+
/** Collapses the navigation (for drawer) */
|
|
210
|
+
collapse: () => NavigationComponent;
|
|
211
|
+
|
|
212
|
+
/** Checks if the navigation is expanded */
|
|
213
|
+
isExpanded: () => boolean;
|
|
214
|
+
|
|
215
|
+
/** Toggles the navigation expansion state */
|
|
216
|
+
toggle: () => NavigationComponent;
|
|
217
|
+
|
|
218
|
+
/** Adds an event listener */
|
|
219
|
+
on: (event: string, handler: Function) => NavigationComponent;
|
|
220
|
+
|
|
221
|
+
/** Removes an event listener */
|
|
222
|
+
off: (event: string, handler: Function) => NavigationComponent;
|
|
223
|
+
|
|
224
|
+
/** Destroys the navigation component */
|
|
173
225
|
destroy: () => void;
|
|
174
226
|
}
|
|
175
227
|
|
|
176
|
-
/**
|
|
177
|
-
* API options interface
|
|
178
|
-
*/
|
|
179
|
-
export interface ApiOptions {
|
|
180
|
-
disabled: {
|
|
181
|
-
enable: () => any;
|
|
182
|
-
disable: () => any;
|
|
183
|
-
};
|
|
184
|
-
lifecycle: {
|
|
185
|
-
destroy: () => void;
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
228
|
/**
|
|
190
229
|
* Base component interface
|
|
191
230
|
*/
|
|
192
231
|
export interface BaseComponent {
|
|
193
232
|
element: HTMLElement;
|
|
233
|
+
prefix?: string;
|
|
234
|
+
items?: Map<string, NavItemData>;
|
|
194
235
|
emit?: (event: string, data: any) => void;
|
|
195
236
|
on?: (event: string, handler: Function) => any;
|
|
196
237
|
off?: (event: string, handler: Function) => any;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
getAllItems?: () => NavItemData[];
|
|
201
|
-
getActive?: () => NavItemData | null;
|
|
202
|
-
getItemPath?: (id: string) => string[];
|
|
203
|
-
setActive?: (id: string) => any;
|
|
238
|
+
lifecycle?: {
|
|
239
|
+
destroy: () => void;
|
|
240
|
+
};
|
|
204
241
|
disabled?: {
|
|
205
242
|
enable: () => any;
|
|
206
243
|
disable: () => any;
|
|
207
244
|
};
|
|
208
|
-
|
|
245
|
+
[key: string]: any;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* API options interface
|
|
250
|
+
*/
|
|
251
|
+
export interface ApiOptions {
|
|
252
|
+
disabled: {
|
|
253
|
+
enable: () => void;
|
|
254
|
+
disable: () => void;
|
|
255
|
+
};
|
|
256
|
+
lifecycle: {
|
|
209
257
|
destroy: () => void;
|
|
210
258
|
};
|
|
211
|
-
[key: string]: any;
|
|
212
259
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/components/progress/api.ts
|
|
2
2
|
|
|
3
3
|
import { ProgressComponent } from './types';
|
|
4
|
-
import { PROGRESS_EVENTS } from './constants';
|
|
5
4
|
|
|
6
5
|
interface ApiOptions {
|
|
7
6
|
value: {
|
|
@@ -80,7 +79,7 @@ export const withAPI = (options: ApiOptions) =>
|
|
|
80
79
|
component.labelElement.textContent = formatter(value, options.value.getMax());
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
component.emit(
|
|
82
|
+
component.emit('valueChange', { value });
|
|
84
83
|
return this;
|
|
85
84
|
},
|
|
86
85
|
|
|
@@ -163,7 +162,7 @@ export const withAPI = (options: ApiOptions) =>
|
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
if (wasIndeterminate !== indeterminate) {
|
|
166
|
-
component.emit(
|
|
165
|
+
component.emit('stateChange', { indeterminate });
|
|
167
166
|
}
|
|
168
167
|
|
|
169
168
|
return this;
|
|
@@ -5,13 +5,12 @@ import {
|
|
|
5
5
|
BaseComponentConfig
|
|
6
6
|
} from '../../core/config/component-config';
|
|
7
7
|
import { ProgressConfig } from './types';
|
|
8
|
-
import { PROGRESS_VARIANTS } from './constants';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Default configuration for the Progress component
|
|
12
11
|
*/
|
|
13
12
|
export const defaultConfig: ProgressConfig = {
|
|
14
|
-
variant:
|
|
13
|
+
variant: 'linear',
|
|
15
14
|
value: 0,
|
|
16
15
|
max: 100,
|
|
17
16
|
buffer: 0,
|
|
@@ -52,7 +51,7 @@ export const getElementConfig = (config: ProgressConfig) => {
|
|
|
52
51
|
attrs['aria-disabled'] = 'true';
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
const isCircular = config.variant ===
|
|
54
|
+
const isCircular = config.variant === 'circular';
|
|
56
55
|
|
|
57
56
|
return createElementConfig(config, {
|
|
58
57
|
tag: 'div',
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from '../../core/compose/features';
|
|
12
12
|
import { withAPI } from './api';
|
|
13
13
|
import { ProgressConfig, ProgressComponent } from './types';
|
|
14
|
-
import { PROGRESS_VARIANTS, PROGRESS_EVENTS } from './constants';
|
|
15
14
|
import { createBaseConfig, getElementConfig, getApiConfig } from './config';
|
|
16
15
|
|
|
17
16
|
// Helper functions
|
|
@@ -104,7 +103,7 @@ const createProgress = (config: ProgressConfig = {}): ProgressComponent => {
|
|
|
104
103
|
// Add DOM structure based on variant
|
|
105
104
|
(component) => {
|
|
106
105
|
const baseClass = component.getClass('progress');
|
|
107
|
-
const isCircular = baseConfig.variant ===
|
|
106
|
+
const isCircular = baseConfig.variant === 'circular';
|
|
108
107
|
|
|
109
108
|
if (isCircular) {
|
|
110
109
|
const { track, indicator, svg } = createCircularProgressDOM(baseClass);
|
|
@@ -1,102 +1,255 @@
|
|
|
1
1
|
// src/components/progress/types.ts
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Progress variant types
|
|
5
|
+
* @category Components
|
|
6
|
+
*/
|
|
7
|
+
export type ProgressVariant = 'linear' | 'circular';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Progress component event types
|
|
11
|
+
* @category Components
|
|
12
|
+
*/
|
|
13
|
+
export type ProgressEvent = 'change' | 'complete';
|
|
14
|
+
|
|
15
|
+
// /**
|
|
16
|
+
// * Progress variants object for internal reference
|
|
17
|
+
// * @internal
|
|
18
|
+
// */
|
|
19
|
+
// export const PROGRESS_VARIANTS: Record<string, ProgressVariant> = {
|
|
20
|
+
// LINEAR: 'linear',
|
|
21
|
+
// CIRCULAR: 'circular'
|
|
22
|
+
// };
|
|
23
|
+
|
|
24
|
+
// /**
|
|
25
|
+
// * Progress events object for internal reference
|
|
26
|
+
// * @internal
|
|
27
|
+
// */
|
|
28
|
+
// export const PROGRESS_EVENTS: Record<string, ProgressEvent> = {
|
|
29
|
+
// CHANGE: 'change',
|
|
30
|
+
// COMPLETE: 'complete'
|
|
31
|
+
// };
|
|
3
32
|
|
|
4
33
|
/**
|
|
5
34
|
* Configuration interface for the Progress component
|
|
35
|
+
* @category Components
|
|
6
36
|
*/
|
|
7
37
|
export interface ProgressConfig {
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Progress variant that determines visual style
|
|
40
|
+
* @default 'linear'
|
|
41
|
+
*/
|
|
42
|
+
variant?: ProgressVariant | string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Initial progress value (0-100)
|
|
46
|
+
* @default 0
|
|
47
|
+
*/
|
|
12
48
|
value?: number;
|
|
13
49
|
|
|
14
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Whether the progress indicator is initially disabled
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
15
54
|
disabled?: boolean;
|
|
16
55
|
|
|
17
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Maximum value
|
|
58
|
+
* @default 100
|
|
59
|
+
*/
|
|
18
60
|
max?: number;
|
|
19
61
|
|
|
20
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Buffer value for linear progress with buffer (like video loading)
|
|
64
|
+
* @default 0
|
|
65
|
+
*/
|
|
21
66
|
buffer?: number;
|
|
22
67
|
|
|
23
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Additional CSS classes to add to the progress component
|
|
70
|
+
* @example 'page-loader main-progress'
|
|
71
|
+
*/
|
|
24
72
|
class?: string;
|
|
25
73
|
|
|
26
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Whether to show text label with percentage
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
27
78
|
showLabel?: boolean;
|
|
28
79
|
|
|
29
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Whether progress is indeterminate (shows animation without specific value)
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
30
84
|
indeterminate?: boolean;
|
|
31
85
|
|
|
32
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Custom label formatter function
|
|
88
|
+
* @example (value, max) => `${Math.round((value/max) * 100)}%`
|
|
89
|
+
*/
|
|
33
90
|
labelFormatter?: (value: number, max: number) => string;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Component prefix for class names
|
|
94
|
+
* @default 'mtrl'
|
|
95
|
+
*/
|
|
96
|
+
prefix?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Component name used in class generation
|
|
100
|
+
* @default 'progress'
|
|
101
|
+
*/
|
|
102
|
+
componentName?: string;
|
|
34
103
|
}
|
|
35
104
|
|
|
36
105
|
/**
|
|
37
106
|
* Progress component interface
|
|
107
|
+
* @category Components
|
|
38
108
|
*/
|
|
39
109
|
export interface ProgressComponent {
|
|
40
|
-
/** The component's root element */
|
|
110
|
+
/** The component's root DOM element */
|
|
41
111
|
element: HTMLElement;
|
|
42
112
|
|
|
43
|
-
/** The track element */
|
|
113
|
+
/** The track element (background) */
|
|
44
114
|
trackElement: HTMLElement;
|
|
45
115
|
|
|
46
|
-
/** The indicator element */
|
|
116
|
+
/** The indicator element (filled part) */
|
|
47
117
|
indicatorElement: HTMLElement;
|
|
48
118
|
|
|
49
|
-
/** The buffer element
|
|
119
|
+
/** The buffer element for linear variant (pre-loaded state) */
|
|
50
120
|
bufferElement?: HTMLElement;
|
|
51
121
|
|
|
52
|
-
/** The label element
|
|
122
|
+
/** The label element if showLabel is enabled */
|
|
53
123
|
labelElement?: HTMLElement;
|
|
54
124
|
|
|
55
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Gets a class name with the component's prefix
|
|
127
|
+
* @param name - Base class name
|
|
128
|
+
* @returns Prefixed class name
|
|
129
|
+
*/
|
|
130
|
+
getClass: (name: string) => string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Sets the current progress value
|
|
134
|
+
* @param value - Progress value (between 0 and max)
|
|
135
|
+
* @returns The progress component for chaining
|
|
136
|
+
*/
|
|
56
137
|
setValue: (value: number) => ProgressComponent;
|
|
57
138
|
|
|
58
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Gets the current progress value
|
|
141
|
+
* @returns Current progress value
|
|
142
|
+
*/
|
|
59
143
|
getValue: () => number;
|
|
60
144
|
|
|
61
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* Sets the buffer value (for linear variant with buffer indicators)
|
|
147
|
+
* @param value - Buffer value (between 0 and max)
|
|
148
|
+
* @returns The progress component for chaining
|
|
149
|
+
*/
|
|
62
150
|
setBuffer: (value: number) => ProgressComponent;
|
|
63
151
|
|
|
64
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Gets the current buffer value
|
|
154
|
+
* @returns Current buffer value
|
|
155
|
+
*/
|
|
65
156
|
getBuffer: () => number;
|
|
66
157
|
|
|
67
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Enables the progress component
|
|
160
|
+
* @returns The progress component for chaining
|
|
161
|
+
*/
|
|
68
162
|
enable: () => ProgressComponent;
|
|
69
163
|
|
|
70
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Disables the progress component
|
|
166
|
+
* @returns The progress component for chaining
|
|
167
|
+
*/
|
|
71
168
|
disable: () => ProgressComponent;
|
|
72
169
|
|
|
73
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Checks if the component is disabled
|
|
172
|
+
* @returns Whether the component is disabled
|
|
173
|
+
*/
|
|
74
174
|
isDisabled: () => boolean;
|
|
75
175
|
|
|
76
|
-
/**
|
|
176
|
+
/**
|
|
177
|
+
* Shows the label element
|
|
178
|
+
* @returns The progress component for chaining
|
|
179
|
+
*/
|
|
77
180
|
showLabel: () => ProgressComponent;
|
|
78
181
|
|
|
79
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* Hides the label element
|
|
184
|
+
* @returns The progress component for chaining
|
|
185
|
+
*/
|
|
80
186
|
hideLabel: () => ProgressComponent;
|
|
81
187
|
|
|
82
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* Sets a custom formatter for the label
|
|
190
|
+
* @param formatter - Function that formats the label text
|
|
191
|
+
* @returns The progress component for chaining
|
|
192
|
+
*/
|
|
83
193
|
setLabelFormatter: (formatter: (value: number, max: number) => string) => ProgressComponent;
|
|
84
194
|
|
|
85
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* Sets the indeterminate state
|
|
197
|
+
* @param indeterminate - Whether progress is indeterminate
|
|
198
|
+
* @returns The progress component for chaining
|
|
199
|
+
*/
|
|
86
200
|
setIndeterminate: (indeterminate: boolean) => ProgressComponent;
|
|
87
201
|
|
|
88
|
-
/**
|
|
202
|
+
/**
|
|
203
|
+
* Checks if the component is in indeterminate state
|
|
204
|
+
* @returns Whether the component is indeterminate
|
|
205
|
+
*/
|
|
89
206
|
isIndeterminate: () => boolean;
|
|
90
207
|
|
|
91
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* Adds an event listener to the progress
|
|
210
|
+
* @param event - Event name ('change', 'complete')
|
|
211
|
+
* @param handler - Event handler function
|
|
212
|
+
* @returns The progress component for chaining
|
|
213
|
+
*/
|
|
92
214
|
on: (event: string, handler: Function) => ProgressComponent;
|
|
93
215
|
|
|
94
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* Removes an event listener from the progress
|
|
218
|
+
* @param event - Event name
|
|
219
|
+
* @param handler - Event handler function
|
|
220
|
+
* @returns The progress component for chaining
|
|
221
|
+
*/
|
|
95
222
|
off: (event: string, handler: Function) => ProgressComponent;
|
|
96
223
|
|
|
97
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Destroys the progress component and cleans up resources
|
|
226
|
+
*/
|
|
98
227
|
destroy: () => void;
|
|
99
228
|
|
|
100
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* Adds CSS classes to the progress element
|
|
231
|
+
* @param classes - One or more class names to add
|
|
232
|
+
* @returns The progress component for chaining
|
|
233
|
+
*/
|
|
101
234
|
addClass: (...classes: string[]) => ProgressComponent;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* API for managing disabled state
|
|
238
|
+
*/
|
|
239
|
+
disabled: {
|
|
240
|
+
/** Enables the progress */
|
|
241
|
+
enable: () => void;
|
|
242
|
+
/** Disables the progress */
|
|
243
|
+
disable: () => void;
|
|
244
|
+
/** Checks if the progress is disabled */
|
|
245
|
+
isDisabled: () => boolean;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* API for managing component lifecycle
|
|
250
|
+
*/
|
|
251
|
+
lifecycle: {
|
|
252
|
+
/** Destroys the component and cleans up resources */
|
|
253
|
+
destroy: () => void;
|
|
254
|
+
};
|
|
102
255
|
}
|