mtrl 0.3.1 → 0.3.2
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 +8 -8
- 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/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/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/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,105 +1,307 @@
|
|
|
1
1
|
// src/components/fab/types.ts
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* FAB variants
|
|
4
|
+
* FAB variants following Material Design 3 guidelines
|
|
5
|
+
*
|
|
6
|
+
* Material Design 3 offers different color variants for the 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 FabVariant = 'primary' | 'secondary' | 'tertiary' | 'surface';
|
|
8
17
|
|
|
9
18
|
/**
|
|
10
19
|
* FAB size variants
|
|
20
|
+
*
|
|
21
|
+
* Material Design 3 defines multiple size options for FABs to accommodate
|
|
22
|
+
* different use cases and screen sizes.
|
|
23
|
+
*
|
|
11
24
|
* @category Components
|
|
25
|
+
* @remarks
|
|
26
|
+
* - small: 40px diameter, for compact interfaces or secondary actions
|
|
27
|
+
* - default: 56px diameter, for standard primary actions (default)
|
|
28
|
+
* - large: 96px diameter, for emphasis or touch-focused interfaces
|
|
12
29
|
*/
|
|
13
30
|
export type FabSize = 'small' | 'default' | 'large';
|
|
14
31
|
|
|
15
32
|
/**
|
|
16
33
|
* FAB position options
|
|
34
|
+
*
|
|
35
|
+
* Predefined positions for the FAB when used as a floating element.
|
|
36
|
+
* These positions automatically apply appropriate margins and positioning.
|
|
37
|
+
*
|
|
17
38
|
* @category Components
|
|
39
|
+
* @remarks
|
|
40
|
+
* Common patterns:
|
|
41
|
+
* - bottom-right: Most common position for primary actions
|
|
42
|
+
* - bottom-left: Alternative position on left-to-right interfaces
|
|
43
|
+
* - top-right: Used for actions related to top content
|
|
44
|
+
* - top-left: Less common but available for special layouts
|
|
18
45
|
*/
|
|
19
46
|
export type FabPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
20
47
|
|
|
21
48
|
/**
|
|
22
49
|
* Configuration interface for the FAB component
|
|
50
|
+
*
|
|
51
|
+
* Comprehensive options for creating and customizing a Floating Action Button
|
|
52
|
+
* according to Material Design 3 guidelines.
|
|
53
|
+
*
|
|
23
54
|
* @category Components
|
|
55
|
+
* @see https://m3.material.io/components/floating-action-button/overview
|
|
24
56
|
*/
|
|
25
57
|
export interface FabConfig {
|
|
26
58
|
/**
|
|
27
59
|
* FAB variant that determines visual styling
|
|
60
|
+
*
|
|
61
|
+
* The color variant affects the FAB's background color, icon color, and elevation.
|
|
62
|
+
*
|
|
28
63
|
* @default 'primary'
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* // Create a tertiary FAB
|
|
68
|
+
* createFab({ variant: 'tertiary', icon: '<svg>...</svg>' })
|
|
69
|
+
* ```
|
|
29
70
|
*/
|
|
30
71
|
variant?: FabVariant | string;
|
|
31
72
|
|
|
32
73
|
/**
|
|
33
74
|
* FAB size variant
|
|
75
|
+
*
|
|
76
|
+
* Controls the diameter of the FAB and the appropriate icon size.
|
|
77
|
+
*
|
|
34
78
|
* @default 'default'
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* // Create a small FAB for a secondary action
|
|
83
|
+
* createFab({ size: 'small', icon: '<svg>...</svg>' })
|
|
84
|
+
*
|
|
85
|
+
* // Create a large FAB for emphasis
|
|
86
|
+
* createFab({ size: 'large', icon: '<svg>...</svg>' })
|
|
87
|
+
* ```
|
|
35
88
|
*/
|
|
36
89
|
size?: FabSize | string;
|
|
37
90
|
|
|
38
91
|
/**
|
|
39
92
|
* Whether the FAB is initially disabled
|
|
93
|
+
*
|
|
94
|
+
* When disabled, the FAB will have a visually muted appearance
|
|
95
|
+
* and won't respond to user interactions.
|
|
96
|
+
*
|
|
40
97
|
* @default false
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* // Create a disabled FAB
|
|
102
|
+
* const fab = createFab({
|
|
103
|
+
* icon: '<svg>...</svg>',
|
|
104
|
+
* disabled: true
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Later enable it when content is ready
|
|
108
|
+
* loadContent().then(() => {
|
|
109
|
+
* fab.enable();
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
41
112
|
*/
|
|
42
113
|
disabled?: boolean;
|
|
43
114
|
|
|
44
115
|
/**
|
|
45
116
|
* FAB icon HTML content
|
|
46
|
-
*
|
|
117
|
+
*
|
|
118
|
+
* The icon content can be any valid HTML, but typically contains an SVG icon
|
|
119
|
+
* or a Material Icons ligature. Icons should follow Material Design sizing guidelines
|
|
120
|
+
* (24x24dp for most sizes, scaled appropriately for small or large variants).
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // Using an SVG icon
|
|
125
|
+
* createFab({
|
|
126
|
+
* icon: '<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>'
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* // Using a Material Icons ligature
|
|
130
|
+
* createFab({
|
|
131
|
+
* icon: '<span class="material-icons">add</span>'
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
47
134
|
*/
|
|
48
135
|
icon?: string;
|
|
49
136
|
|
|
50
137
|
/**
|
|
51
138
|
* Icon size in pixels or other CSS units
|
|
52
|
-
*
|
|
139
|
+
*
|
|
140
|
+
* Allows customizing the icon size beyond the default size for the selected FAB size.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* // Create a FAB with a larger icon
|
|
145
|
+
* createFab({
|
|
146
|
+
* icon: '<svg>...</svg>',
|
|
147
|
+
* iconSize: '32px'
|
|
148
|
+
* });
|
|
149
|
+
* ```
|
|
53
150
|
*/
|
|
54
151
|
iconSize?: string;
|
|
55
152
|
|
|
56
153
|
/**
|
|
57
154
|
* Additional CSS classes to add to the FAB
|
|
58
|
-
*
|
|
155
|
+
*
|
|
156
|
+
* Custom classes for styling or identifying the FAB.
|
|
157
|
+
* These classes will be applied in addition to the component's built-in classes.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* createFab({
|
|
162
|
+
* icon: '<svg>...</svg>',
|
|
163
|
+
* class: 'home-fab pulse-animation'
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
59
166
|
*/
|
|
60
167
|
class?: string;
|
|
61
168
|
|
|
62
169
|
/**
|
|
63
170
|
* Button value attribute
|
|
171
|
+
*
|
|
172
|
+
* Sets the HTML value attribute of the button element, useful when using
|
|
173
|
+
* the FAB in a form context.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* createFab({
|
|
178
|
+
* icon: '<svg>...</svg>',
|
|
179
|
+
* type: 'submit',
|
|
180
|
+
* value: 'form-submitted'
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
64
183
|
*/
|
|
65
184
|
value?: string;
|
|
66
185
|
|
|
67
186
|
/**
|
|
68
187
|
* Position of the FAB on the screen
|
|
69
|
-
*
|
|
188
|
+
*
|
|
189
|
+
* Configures the FAB for floating positioning on the screen.
|
|
190
|
+
* Applies appropriate CSS classes to position the FAB in one of the corners.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* // Position in the bottom-right corner (common for primary actions)
|
|
195
|
+
* createFab({
|
|
196
|
+
* icon: '<svg>...</svg>',
|
|
197
|
+
* position: 'bottom-right'
|
|
198
|
+
* });
|
|
199
|
+
*
|
|
200
|
+
* // Position in the top-left corner
|
|
201
|
+
* createFab({
|
|
202
|
+
* icon: '<svg>...</svg>',
|
|
203
|
+
* position: 'top-left'
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
70
206
|
*/
|
|
71
207
|
position?: FabPosition | string;
|
|
72
208
|
|
|
73
209
|
/**
|
|
74
210
|
* Button type attribute
|
|
211
|
+
*
|
|
212
|
+
* Sets the HTML type attribute of the button element.
|
|
213
|
+
*
|
|
75
214
|
* @default 'button'
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* // Use as a form submit button
|
|
219
|
+
* createFab({
|
|
220
|
+
* icon: '<svg>...</svg>',
|
|
221
|
+
* type: 'submit'
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
76
224
|
*/
|
|
77
225
|
type?: 'button' | 'submit' | 'reset';
|
|
78
226
|
|
|
79
227
|
/**
|
|
80
228
|
* Accessible label for screen readers
|
|
229
|
+
*
|
|
230
|
+
* Sets the aria-label attribute for accessibility. Required for FABs since
|
|
231
|
+
* they typically contain only an icon without visible text.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* createFab({
|
|
236
|
+
* icon: '<svg>...</svg>',
|
|
237
|
+
* ariaLabel: 'Add new item'
|
|
238
|
+
* });
|
|
239
|
+
* ```
|
|
81
240
|
*/
|
|
82
241
|
ariaLabel?: string;
|
|
83
242
|
|
|
84
243
|
/**
|
|
85
244
|
* Whether to enable ripple effect
|
|
245
|
+
*
|
|
246
|
+
* The ripple effect provides visual feedback when the user interacts
|
|
247
|
+
* with the FAB. Follows Material Design interaction patterns.
|
|
248
|
+
*
|
|
86
249
|
* @default true
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* // Disable the ripple effect
|
|
254
|
+
* createFab({
|
|
255
|
+
* icon: '<svg>...</svg>',
|
|
256
|
+
* ripple: false
|
|
257
|
+
* });
|
|
258
|
+
* ```
|
|
87
259
|
*/
|
|
88
260
|
ripple?: boolean;
|
|
89
261
|
|
|
90
262
|
/**
|
|
91
263
|
* Component prefix for class names
|
|
264
|
+
*
|
|
265
|
+
* The prefix used for BEM-style class names.
|
|
266
|
+
*
|
|
92
267
|
* @default 'mtrl'
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* // Use a custom prefix for class names
|
|
272
|
+
* createFab({
|
|
273
|
+
* icon: '<svg>...</svg>',
|
|
274
|
+
* prefix: 'app'
|
|
275
|
+
* });
|
|
276
|
+
* // Results in classes like: 'app-fab app-fab--primary'
|
|
277
|
+
* ```
|
|
93
278
|
*/
|
|
94
279
|
prefix?: string;
|
|
95
280
|
|
|
96
281
|
/**
|
|
97
282
|
* Component name used in class generation
|
|
283
|
+
*
|
|
284
|
+
* @internal
|
|
98
285
|
*/
|
|
99
286
|
componentName?: string;
|
|
100
287
|
|
|
101
288
|
/**
|
|
102
289
|
* Ripple effect configuration
|
|
290
|
+
*
|
|
291
|
+
* Fine-grained control over the ripple effect appearance and behavior.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* // Customize ripple effect
|
|
296
|
+
* createFab({
|
|
297
|
+
* icon: '<svg>...</svg>',
|
|
298
|
+
* rippleConfig: {
|
|
299
|
+
* duration: 400,
|
|
300
|
+
* timing: 'ease-out',
|
|
301
|
+
* opacity: ['0.5', '0']
|
|
302
|
+
* }
|
|
303
|
+
* });
|
|
304
|
+
* ```
|
|
103
305
|
*/
|
|
104
306
|
rippleConfig?: {
|
|
105
307
|
/** Duration of the ripple animation in milliseconds */
|
|
@@ -112,20 +314,43 @@ export interface FabConfig {
|
|
|
112
314
|
|
|
113
315
|
/**
|
|
114
316
|
* Whether to show the FAB with an entrance animation
|
|
317
|
+
*
|
|
318
|
+
* When true, the FAB will animate into view when added to the DOM.
|
|
319
|
+
*
|
|
115
320
|
* @default false
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* // Create an animated entrance FAB
|
|
325
|
+
* createFab({
|
|
326
|
+
* icon: '<svg>...</svg>',
|
|
327
|
+
* animate: true
|
|
328
|
+
* });
|
|
329
|
+
* ```
|
|
116
330
|
*/
|
|
117
331
|
animate?: boolean;
|
|
118
332
|
}
|
|
119
333
|
|
|
120
334
|
/**
|
|
121
335
|
* FAB component interface
|
|
336
|
+
*
|
|
337
|
+
* Provides methods for interacting with and manipulating a Floating Action Button.
|
|
338
|
+
*
|
|
122
339
|
* @category Components
|
|
123
340
|
*/
|
|
124
341
|
export interface FabComponent {
|
|
125
|
-
/**
|
|
342
|
+
/**
|
|
343
|
+
* The FAB's DOM element
|
|
344
|
+
*
|
|
345
|
+
* Direct access to the underlying button element for DOM manipulation.
|
|
346
|
+
*/
|
|
126
347
|
element: HTMLButtonElement;
|
|
127
348
|
|
|
128
|
-
/**
|
|
349
|
+
/**
|
|
350
|
+
* API for managing FAB icons
|
|
351
|
+
*
|
|
352
|
+
* Access to low-level icon methods and elements.
|
|
353
|
+
*/
|
|
129
354
|
icon: {
|
|
130
355
|
/** Sets the icon HTML content */
|
|
131
356
|
setIcon: (html: string) => any;
|
|
@@ -135,7 +360,11 @@ export interface FabComponent {
|
|
|
135
360
|
getElement: () => HTMLElement | null;
|
|
136
361
|
};
|
|
137
362
|
|
|
138
|
-
/**
|
|
363
|
+
/**
|
|
364
|
+
* API for managing disabled state
|
|
365
|
+
*
|
|
366
|
+
* Access to low-level disabled state methods.
|
|
367
|
+
*/
|
|
139
368
|
disabled: {
|
|
140
369
|
/** Enables the FAB */
|
|
141
370
|
enable: () => void;
|
|
@@ -145,7 +374,11 @@ export interface FabComponent {
|
|
|
145
374
|
isDisabled: () => boolean;
|
|
146
375
|
};
|
|
147
376
|
|
|
148
|
-
/**
|
|
377
|
+
/**
|
|
378
|
+
* API for managing component lifecycle
|
|
379
|
+
*
|
|
380
|
+
* Access to low-level lifecycle methods.
|
|
381
|
+
*/
|
|
149
382
|
lifecycle: {
|
|
150
383
|
/** Destroys the component and cleans up resources */
|
|
151
384
|
destroy: () => void;
|
|
@@ -153,99 +386,230 @@ export interface FabComponent {
|
|
|
153
386
|
|
|
154
387
|
/**
|
|
155
388
|
* Gets a class name with the component's prefix
|
|
389
|
+
*
|
|
156
390
|
* @param name - Base class name
|
|
157
391
|
* @returns Prefixed class name
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* const fab = createFab({ icon: '<svg>...</svg>' });
|
|
396
|
+
* const className = fab.getClass('icon'); // Returns 'mtrl-fab__icon'
|
|
397
|
+
* ```
|
|
158
398
|
*/
|
|
159
399
|
getClass: (name: string) => string;
|
|
160
400
|
|
|
161
401
|
/**
|
|
162
402
|
* Gets the FAB's value attribute
|
|
403
|
+
*
|
|
163
404
|
* @returns FAB value
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const fab = createFab({
|
|
409
|
+
* icon: '<svg>...</svg>',
|
|
410
|
+
* value: 'action-button'
|
|
411
|
+
* });
|
|
412
|
+
* const value = fab.getValue(); // Returns 'action-button'
|
|
413
|
+
* ```
|
|
164
414
|
*/
|
|
165
415
|
getValue: () => string;
|
|
166
416
|
|
|
167
417
|
/**
|
|
168
418
|
* Sets the FAB's value attribute
|
|
419
|
+
*
|
|
169
420
|
* @param value - New value
|
|
170
421
|
* @returns The FAB component for chaining
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```typescript
|
|
425
|
+
* const fab = createFab({ icon: '<svg>...</svg>' });
|
|
426
|
+
* fab.setValue('complete');
|
|
427
|
+
* ```
|
|
171
428
|
*/
|
|
172
429
|
setValue: (value: string) => FabComponent;
|
|
173
430
|
|
|
174
431
|
/**
|
|
175
432
|
* Enables the FAB (removes disabled attribute)
|
|
433
|
+
*
|
|
434
|
+
* Makes the FAB interactive and visually enabled.
|
|
435
|
+
*
|
|
176
436
|
* @returns The FAB component for chaining
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* ```typescript
|
|
440
|
+
* // Enable a previously disabled FAB
|
|
441
|
+
* fab.enable();
|
|
442
|
+
* ```
|
|
177
443
|
*/
|
|
178
444
|
enable: () => FabComponent;
|
|
179
445
|
|
|
180
446
|
/**
|
|
181
447
|
* Disables the FAB (adds disabled attribute)
|
|
448
|
+
*
|
|
449
|
+
* Makes the FAB non-interactive and visually disabled.
|
|
450
|
+
*
|
|
182
451
|
* @returns The FAB component for chaining
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* // Disable the FAB during an async operation
|
|
456
|
+
* fab.disable();
|
|
457
|
+
* await saveData();
|
|
458
|
+
* fab.enable();
|
|
459
|
+
* ```
|
|
183
460
|
*/
|
|
184
461
|
disable: () => FabComponent;
|
|
185
462
|
|
|
186
463
|
/**
|
|
187
464
|
* Sets the FAB's icon
|
|
465
|
+
*
|
|
188
466
|
* @param icon - Icon HTML content
|
|
189
467
|
* @returns The FAB component for chaining
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* // Change the icon dynamically
|
|
472
|
+
* fab.setIcon('<svg>...</svg>');
|
|
473
|
+
*
|
|
474
|
+
* // Change to a Material Icons ligature
|
|
475
|
+
* fab.setIcon('<span class="material-icons">edit</span>');
|
|
476
|
+
* ```
|
|
190
477
|
*/
|
|
191
478
|
setIcon: (icon: string) => FabComponent;
|
|
192
479
|
|
|
193
480
|
/**
|
|
194
481
|
* Gets the FAB's icon HTML content
|
|
482
|
+
*
|
|
195
483
|
* @returns Icon HTML
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* const iconHtml = fab.getIcon();
|
|
488
|
+
* ```
|
|
196
489
|
*/
|
|
197
490
|
getIcon: () => string;
|
|
198
491
|
|
|
199
492
|
/**
|
|
200
493
|
* Sets the FAB's position
|
|
494
|
+
*
|
|
495
|
+
* Positions the FAB in one of the four corners of the viewport.
|
|
496
|
+
*
|
|
201
497
|
* @param position - Position value ('top-right', 'bottom-left', etc.)
|
|
202
498
|
* @returns The FAB component for chaining
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```typescript
|
|
502
|
+
* // Move the FAB to the bottom-left corner
|
|
503
|
+
* fab.setPosition('bottom-left');
|
|
504
|
+
* ```
|
|
203
505
|
*/
|
|
204
506
|
setPosition: (position: string) => FabComponent;
|
|
205
507
|
|
|
206
508
|
/**
|
|
207
509
|
* Gets the current position of the FAB
|
|
208
|
-
*
|
|
510
|
+
*
|
|
511
|
+
* @returns Current position or null if not positioned
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* const position = fab.getPosition(); // Returns 'bottom-right', 'top-left', etc.
|
|
516
|
+
* ```
|
|
209
517
|
*/
|
|
210
518
|
getPosition: () => string | null;
|
|
211
519
|
|
|
212
520
|
/**
|
|
213
521
|
* Lowers the FAB (useful for pressed state)
|
|
522
|
+
*
|
|
523
|
+
* Visually lowers the FAB by reducing its elevation,
|
|
524
|
+
* typically used to indicate a pressed or active state.
|
|
525
|
+
*
|
|
214
526
|
* @returns The FAB component for chaining
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```typescript
|
|
530
|
+
* // Visually lower the FAB when a long operation starts
|
|
531
|
+
* fab.lower();
|
|
532
|
+
* await longOperation();
|
|
533
|
+
* fab.raise();
|
|
534
|
+
* ```
|
|
215
535
|
*/
|
|
216
536
|
lower: () => FabComponent;
|
|
217
537
|
|
|
218
538
|
/**
|
|
219
539
|
* Raises the FAB back to its default elevation
|
|
540
|
+
*
|
|
541
|
+
* Restores the default elevation after it has been lowered.
|
|
542
|
+
*
|
|
220
543
|
* @returns The FAB component for chaining
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```typescript
|
|
547
|
+
* // Restore normal elevation
|
|
548
|
+
* fab.raise();
|
|
549
|
+
* ```
|
|
221
550
|
*/
|
|
222
551
|
raise: () => FabComponent;
|
|
223
552
|
|
|
224
553
|
/**
|
|
225
554
|
* Destroys the FAB component and cleans up resources
|
|
555
|
+
*
|
|
556
|
+
* Removes event listeners and prepares the component for garbage collection.
|
|
557
|
+
* Call this method when the FAB is no longer needed.
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* ```typescript
|
|
561
|
+
* // Clean up when the component is no longer needed
|
|
562
|
+
* fab.destroy();
|
|
563
|
+
* ```
|
|
226
564
|
*/
|
|
227
565
|
destroy: () => void;
|
|
228
566
|
|
|
229
567
|
/**
|
|
230
568
|
* Adds an event listener to the FAB
|
|
569
|
+
*
|
|
231
570
|
* @param event - Event name ('click', 'focus', etc.)
|
|
232
571
|
* @param handler - Event handler function
|
|
233
572
|
* @returns The FAB component for chaining
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```typescript
|
|
576
|
+
* // Add click handler
|
|
577
|
+
* fab.on('click', () => {
|
|
578
|
+
* console.log('FAB clicked');
|
|
579
|
+
* });
|
|
580
|
+
* ```
|
|
234
581
|
*/
|
|
235
582
|
on: (event: string, handler: Function) => FabComponent;
|
|
236
583
|
|
|
237
584
|
/**
|
|
238
585
|
* Removes an event listener from the FAB
|
|
586
|
+
*
|
|
239
587
|
* @param event - Event name
|
|
240
588
|
* @param handler - Event handler function
|
|
241
589
|
* @returns The FAB component for chaining
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* // Remove a previously added event handler
|
|
594
|
+
* const handler = () => console.log('Clicked');
|
|
595
|
+
* fab.on('click', handler);
|
|
596
|
+
* // Later...
|
|
597
|
+
* fab.off('click', handler);
|
|
598
|
+
* ```
|
|
242
599
|
*/
|
|
243
600
|
off: (event: string, handler: Function) => FabComponent;
|
|
244
601
|
|
|
245
602
|
/**
|
|
246
603
|
* Adds CSS classes to the FAB element
|
|
604
|
+
*
|
|
247
605
|
* @param classes - One or more class names to add
|
|
248
606
|
* @returns The FAB component for chaining
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```typescript
|
|
610
|
+
* // Add multiple classes
|
|
611
|
+
* fab.addClass('highlight', 'pulse-animation');
|
|
612
|
+
* ```
|
|
249
613
|
*/
|
|
250
614
|
addClass: (...classes: string[]) => FabComponent;
|
|
251
615
|
}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { BaseComponent, ListComponent, ListItemConfig } from './types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* API options interface
|
|
5
|
+
* API options interface for List component
|
|
6
|
+
*
|
|
7
|
+
* @category Components
|
|
8
|
+
* @internal
|
|
6
9
|
*/
|
|
7
10
|
interface ApiOptions {
|
|
8
11
|
disabled: {
|
|
@@ -15,9 +18,16 @@ interface ApiOptions {
|
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
|
-
* Enhances list component with API methods
|
|
21
|
+
* Enhances list component with public API methods
|
|
22
|
+
*
|
|
23
|
+
* Higher-order function that adds the complete public API to the List component,
|
|
24
|
+
* exposing methods for managing items, selection, events, and component state.
|
|
25
|
+
*
|
|
19
26
|
* @param {ApiOptions} options - API configuration
|
|
20
27
|
* @returns {Function} Higher-order function that adds API methods to component
|
|
28
|
+
*
|
|
29
|
+
* @category Components
|
|
30
|
+
* @internal
|
|
21
31
|
*/
|
|
22
32
|
export const withAPI = ({ disabled, lifecycle }: ApiOptions) =>
|
|
23
33
|
(component: BaseComponent): ListComponent => ({
|
|
@@ -8,6 +8,12 @@ import { ListConfig, BaseComponent } from './types';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Default configuration for the List component
|
|
11
|
+
*
|
|
12
|
+
* Provides reasonable defaults for creating lists according
|
|
13
|
+
* to Material Design 3 guidelines.
|
|
14
|
+
*
|
|
15
|
+
* @category Components
|
|
16
|
+
* @internal
|
|
11
17
|
*/
|
|
12
18
|
export const defaultConfig: ListConfig = {
|
|
13
19
|
type: 'default',
|
|
@@ -17,16 +23,31 @@ export const defaultConfig: ListConfig = {
|
|
|
17
23
|
|
|
18
24
|
/**
|
|
19
25
|
* Creates the base configuration for List component
|
|
26
|
+
*
|
|
27
|
+
* Merges user-provided configuration with default values and ensures
|
|
28
|
+
* all required properties have values.
|
|
29
|
+
*
|
|
20
30
|
* @param {ListConfig} config - User provided configuration
|
|
21
31
|
* @returns {ListConfig} Complete configuration with defaults applied
|
|
32
|
+
*
|
|
33
|
+
* @category Components
|
|
34
|
+
* @internal
|
|
22
35
|
*/
|
|
23
36
|
export const createBaseConfig = (config: ListConfig = {}): ListConfig =>
|
|
24
37
|
createComponentConfig(defaultConfig, config, 'list') as ListConfig;
|
|
25
38
|
|
|
26
39
|
/**
|
|
27
40
|
* Generates element configuration for the List component
|
|
41
|
+
*
|
|
42
|
+
* Transforms the user-friendly ListConfig into the internal format required
|
|
43
|
+
* by the withElement function, setting appropriate attributes for accessibility
|
|
44
|
+
* and proper DOM structure.
|
|
45
|
+
*
|
|
28
46
|
* @param {ListConfig} config - List configuration
|
|
29
47
|
* @returns {Object} Element configuration object for withElement
|
|
48
|
+
*
|
|
49
|
+
* @category Components
|
|
50
|
+
* @internal
|
|
30
51
|
*/
|
|
31
52
|
export const getElementConfig = (config: ListConfig) =>
|
|
32
53
|
createElementConfig(config, {
|
|
@@ -11,8 +11,14 @@ import createListItem from './list-item';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Enhances component with list content and functionality
|
|
14
|
+
*
|
|
15
|
+
* Higher-order function that adds list content rendering, selection management,
|
|
16
|
+
* keyboard navigation, and item management capabilities to a component.
|
|
17
|
+
*
|
|
14
18
|
* @param {ListConfig} config - List configuration
|
|
15
19
|
* @returns {Function} Higher-order function that adds list features to component
|
|
20
|
+
*
|
|
21
|
+
* @internal This is an internal implementation detail for the List component
|
|
16
22
|
*/
|
|
17
23
|
export const withListContent = (config: ListConfig) =>
|
|
18
24
|
(component: BaseComponent): BaseComponent => {
|