mtrl 0.2.1 → 0.2.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/.typedocignore +11 -0
- package/DOCS.md +153 -0
- package/index.ts +18 -3
- package/package.json +7 -2
- package/src/components/badge/_styles.scss +174 -0
- package/src/components/badge/api.ts +292 -0
- package/src/components/badge/badge.ts +52 -0
- package/src/components/badge/config.ts +68 -0
- package/src/components/badge/constants.ts +30 -0
- package/src/components/badge/features.ts +185 -0
- package/src/components/badge/index.ts +4 -0
- package/src/components/badge/types.ts +105 -0
- package/src/components/button/types.ts +174 -29
- package/src/components/card/constants.ts +14 -0
- package/src/components/carousel/_styles.scss +645 -0
- package/src/components/carousel/api.ts +147 -0
- package/src/components/carousel/carousel.ts +178 -0
- package/src/components/carousel/config.ts +91 -0
- package/src/components/carousel/constants.ts +95 -0
- package/src/components/carousel/features/drag.ts +388 -0
- package/src/components/carousel/features/index.ts +8 -0
- package/src/components/carousel/features/slides.ts +682 -0
- package/src/components/carousel/index.ts +38 -0
- package/src/components/carousel/types.ts +327 -0
- package/src/components/chip/_styles.scss +83 -140
- package/src/components/chip/api.ts +231 -102
- package/src/components/chip/chip.ts +356 -44
- package/src/components/chip/constants.ts +3 -3
- package/src/components/chip/index.ts +3 -3
- package/src/components/dialog/_styles.scss +213 -0
- package/src/components/dialog/api.ts +283 -0
- package/src/components/dialog/config.ts +113 -0
- package/src/components/dialog/constants.ts +32 -0
- package/src/components/dialog/dialog.ts +56 -0
- package/src/components/dialog/features.ts +713 -0
- package/src/components/dialog/index.ts +15 -0
- package/src/components/dialog/types.ts +221 -0
- package/src/components/progress/_styles.scss +13 -1
- package/src/components/progress/api.ts +2 -2
- package/src/components/progress/progress.ts +2 -2
- package/src/components/progress/types.ts +3 -0
- package/src/components/radios/_styles.scss +232 -0
- package/src/components/radios/api.ts +100 -0
- package/src/components/radios/config.ts +60 -0
- package/src/components/radios/constants.ts +28 -0
- package/src/components/radios/index.ts +4 -0
- package/src/components/radios/radio.ts +269 -0
- package/src/components/radios/radios.ts +42 -0
- package/src/components/radios/types.ts +232 -0
- package/src/components/sheet/_styles.scss +236 -0
- package/src/components/sheet/api.ts +96 -0
- package/src/components/sheet/config.ts +66 -0
- package/src/components/sheet/constants.ts +20 -0
- package/src/components/sheet/features/content.ts +51 -0
- package/src/components/sheet/features/gestures.ts +177 -0
- package/src/components/sheet/features/index.ts +6 -0
- package/src/components/sheet/features/position.ts +42 -0
- package/src/components/sheet/features/state.ts +116 -0
- package/src/components/sheet/features/title.ts +86 -0
- package/src/components/sheet/index.ts +4 -0
- package/src/components/sheet/sheet.ts +57 -0
- package/src/components/sheet/types.ts +266 -0
- package/src/components/slider/_styles.scss +518 -0
- package/src/components/slider/api.ts +336 -0
- package/src/components/slider/config.ts +145 -0
- package/src/components/slider/constants.ts +28 -0
- package/src/components/slider/features/appearance.ts +140 -0
- package/src/components/slider/features/disabled.ts +43 -0
- package/src/components/slider/features/events.ts +164 -0
- package/src/components/slider/features/index.ts +5 -0
- package/src/components/slider/features/interactions.ts +256 -0
- package/src/components/slider/features/keyboard.ts +114 -0
- package/src/components/slider/features/slider.ts +336 -0
- package/src/components/slider/features/structure.ts +264 -0
- package/src/components/slider/features/ui.ts +518 -0
- package/src/components/slider/index.ts +9 -0
- package/src/components/slider/slider.ts +58 -0
- package/src/components/slider/types.ts +166 -0
- package/src/components/tabs/_styles.scss +224 -0
- package/src/components/tabs/api.ts +443 -0
- package/src/components/tabs/config.ts +80 -0
- package/src/components/tabs/constants.ts +12 -0
- package/src/components/tabs/index.ts +4 -0
- package/src/components/tabs/tabs.ts +52 -0
- package/src/components/tabs/types.ts +247 -0
- package/src/components/textfield/_styles.scss +97 -4
- package/src/components/tooltip/_styles.scss +241 -0
- package/src/components/tooltip/api.ts +411 -0
- package/src/components/tooltip/config.ts +78 -0
- package/src/components/tooltip/constants.ts +27 -0
- package/src/components/tooltip/index.ts +4 -0
- package/src/components/tooltip/tooltip.ts +60 -0
- package/src/components/tooltip/types.ts +178 -0
- package/src/index.ts +9 -1
- package/src/styles/abstract/_variables.scss +24 -0
- package/tsconfig.json +22 -0
- package/typedoc.json +28 -0
- package/typedoc.simple.json +14 -0
|
@@ -1,118 +1,263 @@
|
|
|
1
|
+
// src/components/button/types.ts
|
|
2
|
+
import { BUTTON_VARIANTS, BUTTON_SIZES } from './constants';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Configuration interface for the Button component
|
|
6
|
+
* @category Components
|
|
3
7
|
*/
|
|
4
8
|
export interface ButtonConfig {
|
|
5
|
-
/**
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Button variant that determines visual styling
|
|
11
|
+
* @default 'filled'
|
|
12
|
+
*/
|
|
13
|
+
variant?: keyof typeof BUTTON_VARIANTS | string;
|
|
7
14
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Button size
|
|
17
|
+
* @default 'medium'
|
|
18
|
+
*/
|
|
19
|
+
size?: keyof typeof BUTTON_SIZES | string;
|
|
10
20
|
|
|
11
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Whether the button is initially disabled
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
12
25
|
disabled?: boolean;
|
|
13
26
|
|
|
14
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Initial button text content
|
|
29
|
+
* @example 'Submit'
|
|
30
|
+
*/
|
|
15
31
|
text?: string;
|
|
16
32
|
|
|
17
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Initial button icon HTML content
|
|
35
|
+
* @example '<svg>...</svg>'
|
|
36
|
+
*/
|
|
18
37
|
icon?: string;
|
|
19
38
|
|
|
20
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Icon size in pixels or other CSS units
|
|
41
|
+
* @example '18px'
|
|
42
|
+
*/
|
|
21
43
|
iconSize?: string;
|
|
22
44
|
|
|
23
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Additional CSS classes to add to the button
|
|
47
|
+
* @example 'form-submit header-action'
|
|
48
|
+
*/
|
|
24
49
|
class?: string;
|
|
25
50
|
|
|
26
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Button value attribute
|
|
53
|
+
*/
|
|
27
54
|
value?: string;
|
|
28
55
|
|
|
29
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Button type attribute
|
|
58
|
+
* @default 'button'
|
|
59
|
+
*/
|
|
30
60
|
type?: 'button' | 'submit' | 'reset';
|
|
31
61
|
|
|
32
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Whether to enable ripple effect
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
33
66
|
ripple?: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Component prefix for class names
|
|
70
|
+
* @default 'mtrl'
|
|
71
|
+
*/
|
|
72
|
+
prefix?: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Component name used in class generation
|
|
76
|
+
*/
|
|
77
|
+
componentName?: string;
|
|
34
78
|
|
|
35
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Ripple effect configuration
|
|
81
|
+
*/
|
|
36
82
|
rippleConfig?: {
|
|
83
|
+
/** Duration of the ripple animation in milliseconds */
|
|
37
84
|
duration?: number;
|
|
85
|
+
/** Timing function for the ripple animation */
|
|
38
86
|
timing?: string;
|
|
87
|
+
/** Opacity values for ripple start and end [start, end] */
|
|
39
88
|
opacity?: [string, string];
|
|
40
89
|
};
|
|
41
90
|
}
|
|
42
91
|
|
|
43
92
|
/**
|
|
44
|
-
* Icon API interface
|
|
93
|
+
* Icon API interface for managing button icons
|
|
94
|
+
* @category Components
|
|
45
95
|
*/
|
|
46
96
|
export interface IconAPI {
|
|
97
|
+
/**
|
|
98
|
+
* Sets the icon HTML content
|
|
99
|
+
* @param html - HTML string for the icon
|
|
100
|
+
* @returns The icon API for chaining
|
|
101
|
+
*/
|
|
47
102
|
setIcon: (html: string) => IconAPI;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Gets the current icon HTML content
|
|
106
|
+
* @returns HTML string for the icon
|
|
107
|
+
*/
|
|
48
108
|
getIcon: () => string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Gets the icon DOM element
|
|
112
|
+
* @returns The icon element or null if not present
|
|
113
|
+
*/
|
|
49
114
|
getElement: () => HTMLElement | null;
|
|
50
115
|
}
|
|
51
116
|
|
|
52
117
|
/**
|
|
53
|
-
* Text API interface
|
|
118
|
+
* Text API interface for managing button text
|
|
119
|
+
* @category Components
|
|
54
120
|
*/
|
|
55
121
|
export interface TextAPI {
|
|
122
|
+
/**
|
|
123
|
+
* Sets the text content
|
|
124
|
+
* @param content - Text content
|
|
125
|
+
* @returns The text API for chaining
|
|
126
|
+
*/
|
|
56
127
|
setText: (content: string) => TextAPI;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Gets the current text content
|
|
131
|
+
* @returns Button text content
|
|
132
|
+
*/
|
|
57
133
|
getText: () => string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Gets the text DOM element
|
|
137
|
+
* @returns The text element or null if not present
|
|
138
|
+
*/
|
|
58
139
|
getElement: () => HTMLElement | null;
|
|
59
140
|
}
|
|
60
141
|
|
|
61
142
|
/**
|
|
62
143
|
* Button component interface
|
|
144
|
+
* @category Components
|
|
63
145
|
*/
|
|
64
146
|
export interface ButtonComponent {
|
|
147
|
+
/** The button's DOM element */
|
|
65
148
|
element: HTMLButtonElement;
|
|
149
|
+
|
|
150
|
+
/** API for managing button text */
|
|
66
151
|
text: TextAPI;
|
|
152
|
+
|
|
153
|
+
/** API for managing button icons */
|
|
67
154
|
icon: IconAPI;
|
|
155
|
+
|
|
156
|
+
/** API for managing disabled state */
|
|
68
157
|
disabled: {
|
|
158
|
+
/** Enables the button */
|
|
69
159
|
enable: () => void;
|
|
160
|
+
/** Disables the button */
|
|
70
161
|
disable: () => void;
|
|
162
|
+
/** Checks if the button is disabled */
|
|
71
163
|
isDisabled: () => boolean;
|
|
72
164
|
};
|
|
165
|
+
|
|
166
|
+
/** API for managing component lifecycle */
|
|
73
167
|
lifecycle: {
|
|
168
|
+
/** Destroys the component and cleans up resources */
|
|
74
169
|
destroy: () => void;
|
|
75
170
|
};
|
|
76
171
|
|
|
77
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* Gets a class name with the component's prefix
|
|
174
|
+
* @param name - Base class name
|
|
175
|
+
* @returns Prefixed class name
|
|
176
|
+
*/
|
|
78
177
|
getClass: (name: string) => string;
|
|
79
178
|
|
|
80
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Gets the button's value attribute
|
|
181
|
+
* @returns Button value
|
|
182
|
+
*/
|
|
81
183
|
getValue: () => string;
|
|
82
184
|
|
|
83
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* Sets the button's value attribute
|
|
187
|
+
* @param value - New value
|
|
188
|
+
* @returns The button component for chaining
|
|
189
|
+
*/
|
|
84
190
|
setValue: (value: string) => ButtonComponent;
|
|
85
191
|
|
|
86
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* Enables the button (removes disabled attribute)
|
|
194
|
+
* @returns The button component for chaining
|
|
195
|
+
*/
|
|
87
196
|
enable: () => ButtonComponent;
|
|
88
197
|
|
|
89
|
-
/**
|
|
198
|
+
/**
|
|
199
|
+
* Disables the button (adds disabled attribute)
|
|
200
|
+
* @returns The button component for chaining
|
|
201
|
+
*/
|
|
90
202
|
disable: () => ButtonComponent;
|
|
91
203
|
|
|
92
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* Sets the button's text content
|
|
206
|
+
* @param content - Text content
|
|
207
|
+
* @returns The button component for chaining
|
|
208
|
+
*/
|
|
93
209
|
setText: (content: string) => ButtonComponent;
|
|
94
210
|
|
|
95
|
-
/**
|
|
211
|
+
/**
|
|
212
|
+
* Gets the button's text content
|
|
213
|
+
* @returns Button text content
|
|
214
|
+
*/
|
|
96
215
|
getText: () => string;
|
|
97
216
|
|
|
98
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Sets the button's icon
|
|
219
|
+
* @param icon - Icon HTML content
|
|
220
|
+
* @returns The button component for chaining
|
|
221
|
+
*/
|
|
99
222
|
setIcon: (icon: string) => ButtonComponent;
|
|
100
223
|
|
|
101
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Gets the button's icon HTML content
|
|
226
|
+
* @returns Icon HTML
|
|
227
|
+
*/
|
|
102
228
|
getIcon: () => string;
|
|
103
229
|
|
|
104
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* Destroys the button component and cleans up resources
|
|
232
|
+
*/
|
|
105
233
|
destroy: () => void;
|
|
106
234
|
|
|
107
|
-
/**
|
|
235
|
+
/**
|
|
236
|
+
* Updates the button's circular style based on content
|
|
237
|
+
* Internal method used when changing content
|
|
238
|
+
*/
|
|
108
239
|
updateCircularStyle: () => void;
|
|
109
240
|
|
|
110
|
-
/**
|
|
241
|
+
/**
|
|
242
|
+
* Adds an event listener to the button
|
|
243
|
+
* @param event - Event name ('click', 'focus', etc.)
|
|
244
|
+
* @param handler - Event handler function
|
|
245
|
+
* @returns The button component for chaining
|
|
246
|
+
*/
|
|
111
247
|
on: (event: string, handler: Function) => ButtonComponent;
|
|
112
248
|
|
|
113
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* Removes an event listener from the button
|
|
251
|
+
* @param event - Event name
|
|
252
|
+
* @param handler - Event handler function
|
|
253
|
+
* @returns The button component for chaining
|
|
254
|
+
*/
|
|
114
255
|
off: (event: string, handler: Function) => ButtonComponent;
|
|
115
256
|
|
|
116
|
-
/**
|
|
257
|
+
/**
|
|
258
|
+
* Adds CSS classes to the button element
|
|
259
|
+
* @param classes - One or more class names to add
|
|
260
|
+
* @returns The button component for chaining
|
|
261
|
+
*/
|
|
117
262
|
addClass: (...classes: string[]) => ButtonComponent;
|
|
118
263
|
}
|
|
@@ -21,6 +21,20 @@ export const CARD_ELEVATIONS = {
|
|
|
21
21
|
DRAGGED: CardElevation.DRAGGED
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
// Default width values following MD3 principles
|
|
25
|
+
export const CARD_WIDTHS = {
|
|
26
|
+
// Mobile-optimized default (MD3 recommends 344dp for small screens)
|
|
27
|
+
DEFAULT: '344px',
|
|
28
|
+
// Percentage-based responsive options
|
|
29
|
+
FULL: '100%',
|
|
30
|
+
HALF: '50%',
|
|
31
|
+
// Fixed widths for different breakpoints
|
|
32
|
+
SMALL: '344px',
|
|
33
|
+
MEDIUM: '480px',
|
|
34
|
+
LARGE: '624px'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
24
38
|
/**
|
|
25
39
|
* Validation schema for card configuration
|
|
26
40
|
*/
|