mtrl 0.3.1 → 0.3.3
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/.env +15 -0
- package/CONTRIBUTING.md +62 -23
- package/DOCS.md +3 -3
- package/README.md +43 -20
- package/TESTING.md +128 -18
- package/dist/index.js +14865 -0
- package/git-user-stats.js +545 -0
- package/index.ts +9 -67
- package/package.json +8 -3
- package/src/components/badge/api.ts +15 -1
- package/src/components/badge/badge.ts +43 -4
- package/src/components/badge/config.ts +40 -8
- package/src/components/badge/index.ts +64 -3
- package/src/components/badge/types.ts +175 -33
- package/src/components/button/api.ts +63 -1
- package/src/components/button/button.ts +39 -3
- package/src/components/button/config.ts +21 -4
- package/src/components/button/index.ts +26 -1
- package/src/components/button/types.ts +7 -1
- package/src/components/card/api.ts +78 -9
- package/src/components/card/card.ts +58 -3
- package/src/components/card/config.ts +41 -11
- package/src/components/card/features.ts +39 -12
- package/src/components/card/index.ts +84 -19
- package/src/components/card/types.ts +218 -29
- package/src/components/carousel/carousel.ts +92 -28
- package/src/components/carousel/constants.ts +107 -21
- package/src/components/carousel/index.ts +31 -13
- package/src/components/checkbox/checkbox.ts +83 -16
- package/src/components/checkbox/index.ts +43 -1
- package/src/components/checkbox/types.ts +219 -32
- package/src/components/chips/api.ts +194 -0
- package/src/components/{chip → chips/chip}/api.ts +42 -2
- package/src/components/chips/chip/chip.ts +131 -0
- package/src/components/{chip → chips/chip}/config.ts +3 -3
- package/src/components/chips/chip/index.ts +3 -0
- package/src/components/chips/chips.md +481 -0
- package/src/components/chips/chips.ts +75 -0
- package/src/components/chips/config.ts +109 -0
- package/src/components/chips/constants.ts +61 -0
- package/src/components/chips/features/chip-items.ts +33 -0
- package/src/components/chips/features/container.ts +77 -0
- package/src/components/chips/features/controller.ts +448 -0
- package/src/components/chips/features/index.ts +5 -0
- package/src/components/chips/features/label.ts +108 -0
- package/src/components/chips/index.ts +11 -0
- package/src/components/chips/schema.ts +61 -0
- package/src/components/{chip → chips}/types.ts +203 -92
- package/src/components/dialog/dialog.ts +99 -16
- package/src/components/dialog/index.ts +97 -1
- package/src/components/dialog/types.ts +375 -69
- package/src/components/divider/config.ts +90 -6
- package/src/components/divider/divider.ts +32 -2
- package/src/components/divider/features.ts +26 -0
- package/src/components/divider/index.ts +30 -0
- package/src/components/divider/types.ts +86 -9
- package/src/components/extended-fab/api.ts +53 -1
- package/src/components/extended-fab/config.ts +29 -1
- package/src/components/extended-fab/extended-fab.ts +28 -0
- package/src/components/extended-fab/index.ts +36 -0
- package/src/components/extended-fab/types.ts +458 -13
- package/src/components/fab/api.ts +42 -2
- package/src/components/fab/config.ts +29 -1
- package/src/components/fab/fab.ts +16 -2
- package/src/components/fab/index.ts +35 -0
- package/src/components/fab/types.ts +374 -10
- package/src/components/list/api.ts +12 -2
- package/src/components/list/config.ts +21 -0
- package/src/components/list/features.ts +6 -0
- package/src/components/list/index.ts +56 -1
- package/src/components/list/list-item.ts +46 -2
- package/src/components/list/list.ts +73 -2
- package/src/components/list/types.ts +172 -0
- package/src/components/list/utils.ts +26 -2
- package/src/components/menu/api.ts +217 -20
- package/src/components/menu/config.ts +27 -0
- package/src/components/menu/features/visibility.ts +55 -6
- package/src/components/menu/index.ts +64 -0
- package/src/components/menu/menu-item.ts +46 -3
- package/src/components/menu/menu.ts +77 -1
- package/src/components/menu/types.ts +404 -39
- package/src/components/navigation/nav-item.ts +13 -2
- package/src/components/sheet/config.ts +1 -2
- package/src/components/sheet/features/gestures.ts +1 -1
- package/src/components/sheet/features/position.ts +1 -2
- package/src/components/sheet/features/state.ts +1 -1
- package/src/components/sheet/index.ts +10 -2
- package/src/components/sheet/sheet.ts +1 -2
- package/src/components/sheet/types.ts +29 -1
- package/src/components/slider/api.ts +1 -1
- package/src/components/slider/config.ts +1 -1
- package/src/components/slider/features/controller.ts +1 -1
- package/src/components/slider/features/handlers.ts +1 -1
- package/src/components/slider/features/states.ts +1 -1
- package/src/components/slider/index.ts +12 -5
- package/src/components/slider/schema.ts +1 -1
- package/src/components/slider/types.ts +31 -0
- package/src/components/tabs/tab-api.ts +1 -1
- package/src/components/tabs/types.ts +1 -1
- package/src/components/tooltip/api.ts +6 -2
- package/src/components/tooltip/config.ts +9 -28
- package/src/components/tooltip/index.ts +10 -1
- package/src/components/tooltip/types.ts +38 -3
- package/src/core/dom/create.ts +57 -51
- package/src/index.ts +129 -31
- package/src/styles/abstract/_mixins.scss +23 -9
- package/src/styles/abstract/_variables.scss +14 -4
- package/src/styles/components/_card.scss +1 -1
- package/src/styles/components/_chip.scss +323 -113
- package/src/styles/components/_tabs.scss +1 -1
- package/src/styles/themes/_autumn.scss +3 -0
- package/CLAUDE.md +0 -33
- package/src/components/checkbox/constants.ts +0 -37
- package/src/components/chip/chip-set.ts +0 -225
- package/src/components/chip/chip.ts +0 -118
- package/src/components/chip/constants.ts +0 -28
- package/src/components/chip/index.ts +0 -12
- package/src/components/list/constants.ts +0 -116
- package/src/components/sheet/constants.ts +0 -20
- package/src/components/slider/constants.ts +0 -32
- package/src/components/tooltip/constants.ts +0 -27
- package/test/components/badge.test.ts +0 -545
- package/test/components/bottom-app-bar.test.ts +0 -303
- package/test/components/button.test.ts +0 -233
- package/test/components/card.test.ts +0 -560
- package/test/components/carousel.test.ts +0 -951
- package/test/components/checkbox.test.ts +0 -462
- package/test/components/chip.test.ts +0 -692
- package/test/components/datepicker.test.ts +0 -1124
- package/test/components/dialog.test.ts +0 -990
- package/test/components/divider.test.ts +0 -412
- package/test/components/extended-fab.test.ts +0 -672
- package/test/components/fab.test.ts +0 -561
- package/test/components/list.test.ts +0 -365
- package/test/components/menu.test.ts +0 -718
- package/test/components/navigation.test.ts +0 -186
- package/test/components/progress.test.ts +0 -567
- package/test/components/radios.test.ts +0 -699
- package/test/components/search.test.ts +0 -1135
- package/test/components/segmented-button.test.ts +0 -732
- package/test/components/sheet.test.ts +0 -641
- package/test/components/slider.test.ts +0 -1220
- package/test/components/snackbar.test.ts +0 -461
- package/test/components/switch.test.ts +0 -452
- package/test/components/tabs.test.ts +0 -1369
- package/test/components/textfield.test.ts +0 -400
- package/test/components/timepicker.test.ts +0 -592
- package/test/components/tooltip.test.ts +0 -630
- package/test/components/top-app-bar.test.ts +0 -566
- package/test/core/dom.attributes.test.ts +0 -148
- package/test/core/dom.classes.test.ts +0 -152
- package/test/core/dom.events.test.ts +0 -243
- package/test/core/emitter.test.ts +0 -141
- package/test/core/ripple.test.ts +0 -99
- package/test/core/state.store.test.ts +0 -189
- package/test/core/utils.normalize.test.ts +0 -61
- package/test/core/utils.object.test.ts +0 -120
- package/test/setup.js +0 -371
- package/test/setup.ts +0 -451
- package/tsconfig.json +0 -22
- package/typedoc.json +0 -28
- package/typedoc.simple.json +0 -14
|
@@ -1,111 +1,323 @@
|
|
|
1
1
|
// src/components/extended-fab/types.ts
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Extended FAB variants
|
|
4
|
+
* Extended FAB variants following Material Design 3 guidelines
|
|
5
|
+
*
|
|
6
|
+
* Material Design 3 offers different color variants for the Extended FAB
|
|
7
|
+
* to match visual hierarchy and application color schemes.
|
|
8
|
+
*
|
|
5
9
|
* @category Components
|
|
10
|
+
* @remarks
|
|
11
|
+
* - primary: Uses the primary color, highest emphasis (default)
|
|
12
|
+
* - secondary: Uses the secondary color, medium emphasis
|
|
13
|
+
* - tertiary: Uses the tertiary color, lower emphasis
|
|
14
|
+
* - surface: Uses the surface color with an outline, lowest emphasis
|
|
6
15
|
*/
|
|
7
16
|
export type ExtendedFabVariant = 'primary' | 'secondary' | 'tertiary' | 'surface';
|
|
8
17
|
|
|
9
18
|
/**
|
|
10
19
|
* Extended FAB width behavior
|
|
20
|
+
*
|
|
21
|
+
* Controls how the Extended FAB's width is calculated.
|
|
22
|
+
*
|
|
11
23
|
* @category Components
|
|
24
|
+
* @remarks
|
|
25
|
+
* - fixed: Maintains a constant width regardless of content (default)
|
|
26
|
+
* - fluid: Adjusts width based on content length
|
|
12
27
|
*/
|
|
13
28
|
export type ExtendedFabWidth = 'fixed' | 'fluid';
|
|
14
29
|
|
|
15
30
|
/**
|
|
16
|
-
* Extended FAB position
|
|
31
|
+
* Extended FAB position on the screen
|
|
32
|
+
*
|
|
33
|
+
* Predefined positions for the Extended FAB when used as a floating element.
|
|
34
|
+
* These positions automatically apply appropriate margins and positioning.
|
|
35
|
+
*
|
|
17
36
|
* @category Components
|
|
37
|
+
* @remarks
|
|
38
|
+
* Common patterns:
|
|
39
|
+
* - bottom-right: Most common position for primary actions
|
|
40
|
+
* - bottom-left: Alternative position on left-to-right interfaces
|
|
41
|
+
* - top-right: Used for actions related to top content
|
|
42
|
+
* - top-left: Less common but available for special layouts
|
|
18
43
|
*/
|
|
19
44
|
export type ExtendedFabPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
20
45
|
|
|
21
46
|
/**
|
|
22
47
|
* Configuration interface for the Extended FAB component
|
|
48
|
+
*
|
|
49
|
+
* Comprehensive options for creating and customizing an Extended Floating Action Button
|
|
50
|
+
* according to Material Design 3 guidelines.
|
|
51
|
+
*
|
|
23
52
|
* @category Components
|
|
53
|
+
* @see https://m3.material.io/components/extended-fab/overview
|
|
24
54
|
*/
|
|
25
55
|
export interface ExtendedFabConfig {
|
|
26
56
|
/**
|
|
27
57
|
* Extended FAB variant that determines visual styling
|
|
58
|
+
*
|
|
59
|
+
* The color variant affects the Extended FAB's background color, text color, and elevation.
|
|
60
|
+
*
|
|
28
61
|
* @default 'primary'
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // Create a tertiary Extended FAB
|
|
66
|
+
* createExtendedFab({ variant: 'tertiary', text: 'Archive' })
|
|
67
|
+
* ```
|
|
29
68
|
*/
|
|
30
69
|
variant?: ExtendedFabVariant | string;
|
|
31
70
|
|
|
32
71
|
/**
|
|
33
72
|
* Whether the Extended FAB is initially disabled
|
|
73
|
+
*
|
|
74
|
+
* When disabled, the Extended FAB will have a visually muted appearance
|
|
75
|
+
* and won't respond to user interactions.
|
|
76
|
+
*
|
|
34
77
|
* @default false
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Create a disabled Extended FAB
|
|
82
|
+
* const fab = createExtendedFab({ text: 'Submit', disabled: true });
|
|
83
|
+
*
|
|
84
|
+
* // Later enable it when form is valid
|
|
85
|
+
* validateForm().then(isValid => {
|
|
86
|
+
* if (isValid) fab.enable();
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
35
89
|
*/
|
|
36
90
|
disabled?: boolean;
|
|
37
91
|
|
|
38
92
|
/**
|
|
39
93
|
* Extended FAB icon HTML content
|
|
40
|
-
*
|
|
94
|
+
*
|
|
95
|
+
* The icon content can be any valid HTML, but typically contains an SVG icon
|
|
96
|
+
* or a Material Icons ligature. Icons should be 24x24dp following Material guidelines.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Using an SVG icon
|
|
101
|
+
* createExtendedFab({
|
|
102
|
+
* text: 'Add',
|
|
103
|
+
* icon: '<svg width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>'
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* // Using a Material Icons ligature
|
|
107
|
+
* createExtendedFab({
|
|
108
|
+
* text: 'Add',
|
|
109
|
+
* icon: '<span class="material-icons">add</span>'
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
41
112
|
*/
|
|
42
113
|
icon?: string;
|
|
43
114
|
|
|
44
115
|
/**
|
|
45
116
|
* Icon size in pixels or other CSS units
|
|
46
|
-
*
|
|
117
|
+
*
|
|
118
|
+
* Allows customizing the icon size beyond the default 24px size.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* // Create an Extended FAB with larger icon
|
|
123
|
+
* createExtendedFab({
|
|
124
|
+
* text: 'Edit',
|
|
125
|
+
* icon: '<svg>...</svg>',
|
|
126
|
+
* iconSize: '32px'
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
47
129
|
*/
|
|
48
130
|
iconSize?: string;
|
|
49
131
|
|
|
50
132
|
/**
|
|
51
133
|
* Position of the icon relative to the text
|
|
134
|
+
*
|
|
135
|
+
* Controls whether the icon appears before or after the text label.
|
|
136
|
+
* Material Design 3 guidelines typically recommend the icon at the start position.
|
|
137
|
+
*
|
|
52
138
|
* @default 'start'
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Create an Extended FAB with icon after text
|
|
143
|
+
* createExtendedFab({
|
|
144
|
+
* text: 'Next',
|
|
145
|
+
* icon: '<span class="material-icons">arrow_forward</span>',
|
|
146
|
+
* iconPosition: 'end'
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
53
149
|
*/
|
|
54
150
|
iconPosition?: 'start' | 'end';
|
|
55
151
|
|
|
56
152
|
/**
|
|
57
153
|
* Text label for the Extended FAB
|
|
58
|
-
*
|
|
154
|
+
*
|
|
155
|
+
* The text should be short, typically one or two words describing the primary action.
|
|
156
|
+
* Material Design guidelines recommend action verbs that clearly describe the action.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* // Good text labels for Extended FABs
|
|
161
|
+
* createExtendedFab({ text: 'Create' });
|
|
162
|
+
* createExtendedFab({ text: 'Add Task' });
|
|
163
|
+
* createExtendedFab({ text: 'Submit' });
|
|
164
|
+
* ```
|
|
59
165
|
*/
|
|
60
166
|
text?: string;
|
|
61
167
|
|
|
62
168
|
/**
|
|
63
169
|
* Additional CSS classes to add to the Extended FAB
|
|
64
|
-
*
|
|
170
|
+
*
|
|
171
|
+
* Custom classes for styling or identifying the Extended FAB.
|
|
172
|
+
* These classes will be applied in addition to the component's built-in classes.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* createExtendedFab({
|
|
177
|
+
* text: 'Create',
|
|
178
|
+
* class: 'home-page-fab custom-shadow'
|
|
179
|
+
* });
|
|
180
|
+
* ```
|
|
65
181
|
*/
|
|
66
182
|
class?: string;
|
|
67
183
|
|
|
68
184
|
/**
|
|
69
185
|
* Button value attribute
|
|
186
|
+
*
|
|
187
|
+
* Sets the HTML value attribute of the button element, useful when using
|
|
188
|
+
* the Extended FAB in a form context.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* createExtendedFab({
|
|
193
|
+
* text: 'Submit',
|
|
194
|
+
* type: 'submit',
|
|
195
|
+
* value: 'form-submitted'
|
|
196
|
+
* });
|
|
197
|
+
* ```
|
|
70
198
|
*/
|
|
71
199
|
value?: string;
|
|
72
200
|
|
|
73
201
|
/**
|
|
74
202
|
* Position of the Extended FAB on the screen
|
|
75
|
-
*
|
|
203
|
+
*
|
|
204
|
+
* Configures the Extended FAB for floating positioning on the screen.
|
|
205
|
+
* Applies appropriate CSS classes to position the Extended FAB in one of the corners.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* // Position in the bottom-right corner (common for primary actions)
|
|
210
|
+
* createExtendedFab({
|
|
211
|
+
* text: 'Create',
|
|
212
|
+
* position: 'bottom-right'
|
|
213
|
+
* });
|
|
214
|
+
*
|
|
215
|
+
* // Position in the top-left corner
|
|
216
|
+
* createExtendedFab({
|
|
217
|
+
* text: 'Go back',
|
|
218
|
+
* position: 'top-left'
|
|
219
|
+
* });
|
|
220
|
+
* ```
|
|
76
221
|
*/
|
|
77
222
|
position?: ExtendedFabPosition | string;
|
|
78
223
|
|
|
79
224
|
/**
|
|
80
225
|
* Button type attribute
|
|
226
|
+
*
|
|
227
|
+
* Sets the HTML type attribute of the button element.
|
|
228
|
+
*
|
|
81
229
|
* @default 'button'
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* // Use as a form submit button
|
|
234
|
+
* createExtendedFab({
|
|
235
|
+
* text: 'Submit',
|
|
236
|
+
* type: 'submit'
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
82
239
|
*/
|
|
83
240
|
type?: 'button' | 'submit' | 'reset';
|
|
84
241
|
|
|
85
242
|
/**
|
|
86
243
|
* Accessible label for screen readers
|
|
244
|
+
*
|
|
245
|
+
* Sets the aria-label attribute for accessibility. Especially important
|
|
246
|
+
* if the Extended FAB doesn't include text content.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* createExtendedFab({
|
|
251
|
+
* text: 'Create',
|
|
252
|
+
* icon: '<svg>...</svg>',
|
|
253
|
+
* ariaLabel: 'Create new document'
|
|
254
|
+
* });
|
|
255
|
+
* ```
|
|
87
256
|
*/
|
|
88
257
|
ariaLabel?: string;
|
|
89
258
|
|
|
90
259
|
/**
|
|
91
260
|
* Whether to enable ripple effect
|
|
261
|
+
*
|
|
262
|
+
* The ripple effect provides visual feedback when the user interacts
|
|
263
|
+
* with the Extended FAB. Follows Material Design interaction patterns.
|
|
264
|
+
*
|
|
92
265
|
* @default true
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* // Disable the ripple effect
|
|
270
|
+
* createExtendedFab({
|
|
271
|
+
* text: 'Create',
|
|
272
|
+
* ripple: false
|
|
273
|
+
* });
|
|
274
|
+
* ```
|
|
93
275
|
*/
|
|
94
276
|
ripple?: boolean;
|
|
95
277
|
|
|
96
278
|
/**
|
|
97
279
|
* Component prefix for class names
|
|
280
|
+
*
|
|
281
|
+
* The prefix used for BEM-style class names.
|
|
282
|
+
*
|
|
98
283
|
* @default 'mtrl'
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* // Use a custom prefix for class names
|
|
288
|
+
* createExtendedFab({
|
|
289
|
+
* text: 'Create',
|
|
290
|
+
* prefix: 'app'
|
|
291
|
+
* });
|
|
292
|
+
* // Results in classes like: 'app-extended-fab app-extended-fab--primary'
|
|
293
|
+
* ```
|
|
99
294
|
*/
|
|
100
295
|
prefix?: string;
|
|
101
296
|
|
|
102
297
|
/**
|
|
103
298
|
* Component name used in class generation
|
|
299
|
+
*
|
|
300
|
+
* @internal
|
|
104
301
|
*/
|
|
105
302
|
componentName?: string;
|
|
106
303
|
|
|
107
304
|
/**
|
|
108
305
|
* Ripple effect configuration
|
|
306
|
+
*
|
|
307
|
+
* Fine-grained control over the ripple effect appearance and behavior.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* // Customize ripple effect
|
|
312
|
+
* createExtendedFab({
|
|
313
|
+
* text: 'Create',
|
|
314
|
+
* rippleConfig: {
|
|
315
|
+
* duration: 400,
|
|
316
|
+
* timing: 'ease-out',
|
|
317
|
+
* opacity: ['0.5', '0']
|
|
318
|
+
* }
|
|
319
|
+
* });
|
|
320
|
+
* ```
|
|
109
321
|
*/
|
|
110
322
|
rippleConfig?: {
|
|
111
323
|
/** Duration of the ripple animation in milliseconds */
|
|
@@ -118,32 +330,84 @@ export interface ExtendedFabConfig {
|
|
|
118
330
|
|
|
119
331
|
/**
|
|
120
332
|
* Whether to show the Extended FAB with an entrance animation
|
|
333
|
+
*
|
|
334
|
+
* When true, the Extended FAB will animate into view when added to the DOM.
|
|
335
|
+
*
|
|
121
336
|
* @default false
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* // Create an animated entrance Extended FAB
|
|
341
|
+
* createExtendedFab({
|
|
342
|
+
* text: 'Create',
|
|
343
|
+
* animate: true
|
|
344
|
+
* });
|
|
345
|
+
* ```
|
|
122
346
|
*/
|
|
123
347
|
animate?: boolean;
|
|
124
348
|
|
|
125
349
|
/**
|
|
126
350
|
* Width behavior of the Extended FAB
|
|
351
|
+
*
|
|
352
|
+
* Controls how the Extended FAB's width is calculated:
|
|
353
|
+
* - 'fixed': Maintains a constant width regardless of content (default)
|
|
354
|
+
* - 'fluid': Adjusts width based on content length
|
|
355
|
+
*
|
|
127
356
|
* @default 'fixed'
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* // Create an Extended FAB that adjusts width based on text length
|
|
361
|
+
* createExtendedFab({
|
|
362
|
+
* text: 'Add to favorites',
|
|
363
|
+
* width: 'fluid'
|
|
364
|
+
* });
|
|
365
|
+
* ```
|
|
128
366
|
*/
|
|
129
367
|
width?: ExtendedFabWidth | string;
|
|
130
368
|
|
|
131
369
|
/**
|
|
132
370
|
* Whether the Extended FAB should collapse to a standard FAB on scroll
|
|
371
|
+
*
|
|
372
|
+
* When true, the Extended FAB will automatically shrink to a circular FAB
|
|
373
|
+
* (hiding the text) when the user scrolls down, and expand back to the Extended FAB
|
|
374
|
+
* when scrolling up.
|
|
375
|
+
*
|
|
133
376
|
* @default false
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* // Create a collapsible Extended FAB
|
|
381
|
+
* createExtendedFab({
|
|
382
|
+
* text: 'Create',
|
|
383
|
+
* icon: '<svg>...</svg>',
|
|
384
|
+
* collapseOnScroll: true
|
|
385
|
+
* });
|
|
386
|
+
* ```
|
|
134
387
|
*/
|
|
135
388
|
collapseOnScroll?: boolean;
|
|
136
389
|
}
|
|
137
390
|
|
|
138
391
|
/**
|
|
139
392
|
* Extended FAB component interface
|
|
393
|
+
*
|
|
394
|
+
* Provides methods for interacting with and manipulating an Extended Floating Action Button.
|
|
395
|
+
*
|
|
140
396
|
* @category Components
|
|
141
397
|
*/
|
|
142
398
|
export interface ExtendedFabComponent {
|
|
143
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* The Extended FAB's DOM element
|
|
401
|
+
*
|
|
402
|
+
* Direct access to the underlying button element for DOM manipulation.
|
|
403
|
+
*/
|
|
144
404
|
element: HTMLButtonElement;
|
|
145
405
|
|
|
146
|
-
/**
|
|
406
|
+
/**
|
|
407
|
+
* API for managing Extended FAB icons
|
|
408
|
+
*
|
|
409
|
+
* Access to low-level icon methods and elements.
|
|
410
|
+
*/
|
|
147
411
|
icon: {
|
|
148
412
|
/** Sets the icon HTML content */
|
|
149
413
|
setIcon: (html: string) => any;
|
|
@@ -153,7 +417,11 @@ export interface ExtendedFabComponent {
|
|
|
153
417
|
getElement: () => HTMLElement | null;
|
|
154
418
|
};
|
|
155
419
|
|
|
156
|
-
/**
|
|
420
|
+
/**
|
|
421
|
+
* API for managing text content
|
|
422
|
+
*
|
|
423
|
+
* Access to low-level text methods and elements.
|
|
424
|
+
*/
|
|
157
425
|
text: {
|
|
158
426
|
/** Sets the text content */
|
|
159
427
|
setText: (text: string) => any;
|
|
@@ -163,7 +431,11 @@ export interface ExtendedFabComponent {
|
|
|
163
431
|
getElement: () => HTMLElement | null;
|
|
164
432
|
};
|
|
165
433
|
|
|
166
|
-
/**
|
|
434
|
+
/**
|
|
435
|
+
* API for managing disabled state
|
|
436
|
+
*
|
|
437
|
+
* Access to low-level disabled state methods.
|
|
438
|
+
*/
|
|
167
439
|
disabled: {
|
|
168
440
|
/** Enables the Extended FAB */
|
|
169
441
|
enable: () => void;
|
|
@@ -173,7 +445,11 @@ export interface ExtendedFabComponent {
|
|
|
173
445
|
isDisabled: () => boolean;
|
|
174
446
|
};
|
|
175
447
|
|
|
176
|
-
/**
|
|
448
|
+
/**
|
|
449
|
+
* API for managing component lifecycle
|
|
450
|
+
*
|
|
451
|
+
* Access to low-level lifecycle methods.
|
|
452
|
+
*/
|
|
177
453
|
lifecycle: {
|
|
178
454
|
/** Destroys the component and cleans up resources */
|
|
179
455
|
destroy: () => void;
|
|
@@ -181,124 +457,293 @@ export interface ExtendedFabComponent {
|
|
|
181
457
|
|
|
182
458
|
/**
|
|
183
459
|
* Gets a class name with the component's prefix
|
|
460
|
+
*
|
|
184
461
|
* @param name - Base class name
|
|
185
462
|
* @returns Prefixed class name
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* const fab = createExtendedFab({ text: 'Create' });
|
|
467
|
+
* const className = fab.getClass('icon'); // Returns 'mtrl-extended-fab__icon'
|
|
468
|
+
* ```
|
|
186
469
|
*/
|
|
187
470
|
getClass: (name: string) => string;
|
|
188
471
|
|
|
189
472
|
/**
|
|
190
473
|
* Gets the Extended FAB's value attribute
|
|
474
|
+
*
|
|
191
475
|
* @returns Extended FAB value
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```typescript
|
|
479
|
+
* const fab = createExtendedFab({ text: 'Submit', value: 'form-data' });
|
|
480
|
+
* const value = fab.getValue(); // Returns 'form-data'
|
|
481
|
+
* ```
|
|
192
482
|
*/
|
|
193
483
|
getValue: () => string;
|
|
194
484
|
|
|
195
485
|
/**
|
|
196
486
|
* Sets the Extended FAB's value attribute
|
|
487
|
+
*
|
|
197
488
|
* @param value - New value
|
|
198
489
|
* @returns The Extended FAB component for chaining
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* const fab = createExtendedFab({ text: 'Submit' });
|
|
494
|
+
* fab.setValue('completed');
|
|
495
|
+
* ```
|
|
199
496
|
*/
|
|
200
497
|
setValue: (value: string) => ExtendedFabComponent;
|
|
201
498
|
|
|
202
499
|
/**
|
|
203
500
|
* Enables the Extended FAB (removes disabled attribute)
|
|
501
|
+
*
|
|
502
|
+
* Makes the Extended FAB interactive and visually enabled.
|
|
503
|
+
*
|
|
204
504
|
* @returns The Extended FAB component for chaining
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* // Enable a previously disabled Extended FAB
|
|
509
|
+
* fab.enable();
|
|
510
|
+
* ```
|
|
205
511
|
*/
|
|
206
512
|
enable: () => ExtendedFabComponent;
|
|
207
513
|
|
|
208
514
|
/**
|
|
209
515
|
* Disables the Extended FAB (adds disabled attribute)
|
|
516
|
+
*
|
|
517
|
+
* Makes the Extended FAB non-interactive and visually disabled.
|
|
518
|
+
*
|
|
210
519
|
* @returns The Extended FAB component for chaining
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* // Disable the Extended FAB during an async operation
|
|
524
|
+
* fab.disable();
|
|
525
|
+
* await saveData();
|
|
526
|
+
* fab.enable();
|
|
527
|
+
* ```
|
|
211
528
|
*/
|
|
212
529
|
disable: () => ExtendedFabComponent;
|
|
213
530
|
|
|
214
531
|
/**
|
|
215
532
|
* Sets the Extended FAB's icon
|
|
533
|
+
*
|
|
216
534
|
* @param icon - Icon HTML content
|
|
217
535
|
* @returns The Extended FAB component for chaining
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```typescript
|
|
539
|
+
* // Change the icon dynamically
|
|
540
|
+
* fab.setIcon('<svg>...</svg>');
|
|
541
|
+
*
|
|
542
|
+
* // Change to a Material Icons ligature
|
|
543
|
+
* fab.setIcon('<span class="material-icons">edit</span>');
|
|
544
|
+
* ```
|
|
218
545
|
*/
|
|
219
546
|
setIcon: (icon: string) => ExtendedFabComponent;
|
|
220
547
|
|
|
221
548
|
/**
|
|
222
549
|
* Gets the Extended FAB's icon HTML content
|
|
550
|
+
*
|
|
223
551
|
* @returns Icon HTML
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* const iconHtml = fab.getIcon();
|
|
556
|
+
* ```
|
|
224
557
|
*/
|
|
225
558
|
getIcon: () => string;
|
|
226
559
|
|
|
227
560
|
/**
|
|
228
561
|
* Sets the Extended FAB's text content
|
|
562
|
+
*
|
|
229
563
|
* @param text - Text content
|
|
230
564
|
* @returns The Extended FAB component for chaining
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* // Change text dynamically based on state
|
|
569
|
+
* if (isEditing) {
|
|
570
|
+
* fab.setText('Save');
|
|
571
|
+
* } else {
|
|
572
|
+
* fab.setText('Edit');
|
|
573
|
+
* }
|
|
574
|
+
* ```
|
|
231
575
|
*/
|
|
232
576
|
setText: (text: string) => ExtendedFabComponent;
|
|
233
577
|
|
|
234
578
|
/**
|
|
235
579
|
* Gets the Extended FAB's text content
|
|
580
|
+
*
|
|
236
581
|
* @returns Text content
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```typescript
|
|
585
|
+
* const currentText = fab.getText();
|
|
586
|
+
* ```
|
|
237
587
|
*/
|
|
238
588
|
getText: () => string;
|
|
239
589
|
|
|
240
590
|
/**
|
|
241
591
|
* Sets the Extended FAB's position
|
|
592
|
+
*
|
|
593
|
+
* Positions the Extended FAB in one of the four corners of the viewport.
|
|
594
|
+
*
|
|
242
595
|
* @param position - Position value ('top-right', 'bottom-left', etc.)
|
|
243
596
|
* @returns The Extended FAB component for chaining
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```typescript
|
|
600
|
+
* // Move the Extended FAB to the bottom-left corner
|
|
601
|
+
* fab.setPosition('bottom-left');
|
|
602
|
+
* ```
|
|
244
603
|
*/
|
|
245
604
|
setPosition: (position: string) => ExtendedFabComponent;
|
|
246
605
|
|
|
247
606
|
/**
|
|
248
607
|
* Gets the current position of the Extended FAB
|
|
249
|
-
*
|
|
608
|
+
*
|
|
609
|
+
* @returns Current position or null if not positioned
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* const position = fab.getPosition(); // Returns 'bottom-right', 'top-left', etc.
|
|
614
|
+
* ```
|
|
250
615
|
*/
|
|
251
616
|
getPosition: () => string | null;
|
|
252
617
|
|
|
253
618
|
/**
|
|
254
619
|
* Lowers the Extended FAB (useful for pressed state)
|
|
620
|
+
*
|
|
621
|
+
* Visually lowers the Extended FAB by reducing its elevation,
|
|
622
|
+
* typically used to indicate a pressed or active state.
|
|
623
|
+
*
|
|
255
624
|
* @returns The Extended FAB component for chaining
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* // Visually lower the Extended FAB when a long operation starts
|
|
629
|
+
* fab.lower();
|
|
630
|
+
* await longOperation();
|
|
631
|
+
* fab.raise();
|
|
632
|
+
* ```
|
|
256
633
|
*/
|
|
257
634
|
lower: () => ExtendedFabComponent;
|
|
258
635
|
|
|
259
636
|
/**
|
|
260
637
|
* Raises the Extended FAB back to its default elevation
|
|
638
|
+
*
|
|
639
|
+
* Restores the default elevation after it has been lowered.
|
|
640
|
+
*
|
|
261
641
|
* @returns The Extended FAB component for chaining
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* // Restore normal elevation
|
|
646
|
+
* fab.raise();
|
|
647
|
+
* ```
|
|
262
648
|
*/
|
|
263
649
|
raise: () => ExtendedFabComponent;
|
|
264
650
|
|
|
265
651
|
/**
|
|
266
652
|
* Collapses the Extended FAB into a standard FAB
|
|
653
|
+
*
|
|
654
|
+
* Hides the text label, showing only the icon in a circular container.
|
|
655
|
+
* Useful for saving space or to emphasize other content.
|
|
656
|
+
*
|
|
267
657
|
* @returns The Extended FAB component for chaining
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* ```typescript
|
|
661
|
+
* // Collapse the Extended FAB programmatically
|
|
662
|
+
* fab.collapse();
|
|
663
|
+
* ```
|
|
268
664
|
*/
|
|
269
665
|
collapse: () => ExtendedFabComponent;
|
|
270
666
|
|
|
271
667
|
/**
|
|
272
668
|
* Expands a collapsed Extended FAB back to its full size
|
|
669
|
+
*
|
|
670
|
+
* Shows the text label alongside the icon.
|
|
671
|
+
*
|
|
273
672
|
* @returns The Extended FAB component for chaining
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* ```typescript
|
|
676
|
+
* // Expand the Extended FAB programmatically
|
|
677
|
+
* fab.expand();
|
|
678
|
+
* ```
|
|
274
679
|
*/
|
|
275
680
|
expand: () => ExtendedFabComponent;
|
|
276
681
|
|
|
277
682
|
/**
|
|
278
683
|
* Destroys the Extended FAB component and cleans up resources
|
|
684
|
+
*
|
|
685
|
+
* Removes event listeners and prepares the component for garbage collection.
|
|
686
|
+
* Call this method when the Extended FAB is no longer needed.
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```typescript
|
|
690
|
+
* // Clean up when the component is no longer needed
|
|
691
|
+
* fab.destroy();
|
|
692
|
+
* ```
|
|
279
693
|
*/
|
|
280
694
|
destroy: () => void;
|
|
281
695
|
|
|
282
696
|
/**
|
|
283
697
|
* Adds an event listener to the Extended FAB
|
|
698
|
+
*
|
|
284
699
|
* @param event - Event name ('click', 'focus', etc.)
|
|
285
700
|
* @param handler - Event handler function
|
|
286
701
|
* @returns The Extended FAB component for chaining
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* // Add click handler
|
|
706
|
+
* fab.on('click', () => {
|
|
707
|
+
* console.log('Extended FAB clicked');
|
|
708
|
+
* });
|
|
709
|
+
*
|
|
710
|
+
* // Add custom event handler for collapse
|
|
711
|
+
* fab.on('collapse', () => {
|
|
712
|
+
* console.log('Extended FAB collapsed');
|
|
713
|
+
* });
|
|
714
|
+
* ```
|
|
287
715
|
*/
|
|
288
716
|
on: (event: string, handler: Function) => ExtendedFabComponent;
|
|
289
717
|
|
|
290
718
|
/**
|
|
291
719
|
* Removes an event listener from the Extended FAB
|
|
720
|
+
*
|
|
292
721
|
* @param event - Event name
|
|
293
722
|
* @param handler - Event handler function
|
|
294
723
|
* @returns The Extended FAB component for chaining
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* // Remove a previously added event handler
|
|
728
|
+
* const handler = () => console.log('Clicked');
|
|
729
|
+
* fab.on('click', handler);
|
|
730
|
+
* // Later...
|
|
731
|
+
* fab.off('click', handler);
|
|
732
|
+
* ```
|
|
295
733
|
*/
|
|
296
734
|
off: (event: string, handler: Function) => ExtendedFabComponent;
|
|
297
735
|
|
|
298
736
|
/**
|
|
299
737
|
* Adds CSS classes to the Extended FAB element
|
|
738
|
+
*
|
|
300
739
|
* @param classes - One or more class names to add
|
|
301
740
|
* @returns The Extended FAB component for chaining
|
|
741
|
+
*
|
|
742
|
+
* @example
|
|
743
|
+
* ```typescript
|
|
744
|
+
* // Add multiple classes
|
|
745
|
+
* fab.addClass('highlight', 'pulse-animation');
|
|
746
|
+
* ```
|
|
302
747
|
*/
|
|
303
748
|
addClass: (...classes: string[]) => ExtendedFabComponent;
|
|
304
749
|
}
|