mtrl 0.2.2 → 0.2.4

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.
Files changed (97) hide show
  1. package/.typedocignore +11 -0
  2. package/DOCS.md +153 -0
  3. package/index.ts +18 -3
  4. package/package.json +7 -2
  5. package/src/components/badge/_styles.scss +174 -0
  6. package/src/components/badge/api.ts +292 -0
  7. package/src/components/badge/badge.ts +52 -0
  8. package/src/components/badge/config.ts +68 -0
  9. package/src/components/badge/constants.ts +30 -0
  10. package/src/components/badge/features.ts +185 -0
  11. package/src/components/badge/index.ts +4 -0
  12. package/src/components/badge/types.ts +105 -0
  13. package/src/components/button/types.ts +174 -29
  14. package/src/components/carousel/_styles.scss +645 -0
  15. package/src/components/carousel/api.ts +147 -0
  16. package/src/components/carousel/carousel.ts +178 -0
  17. package/src/components/carousel/config.ts +91 -0
  18. package/src/components/carousel/constants.ts +95 -0
  19. package/src/components/carousel/features/drag.ts +388 -0
  20. package/src/components/carousel/features/index.ts +8 -0
  21. package/src/components/carousel/features/slides.ts +682 -0
  22. package/src/components/carousel/index.ts +38 -0
  23. package/src/components/carousel/types.ts +327 -0
  24. package/src/components/dialog/_styles.scss +213 -0
  25. package/src/components/dialog/api.ts +283 -0
  26. package/src/components/dialog/config.ts +113 -0
  27. package/src/components/dialog/constants.ts +32 -0
  28. package/src/components/dialog/dialog.ts +56 -0
  29. package/src/components/dialog/features.ts +713 -0
  30. package/src/components/dialog/index.ts +15 -0
  31. package/src/components/dialog/types.ts +221 -0
  32. package/src/components/progress/_styles.scss +13 -1
  33. package/src/components/progress/api.ts +2 -2
  34. package/src/components/progress/progress.ts +2 -2
  35. package/src/components/progress/types.ts +3 -0
  36. package/src/components/radios/_styles.scss +232 -0
  37. package/src/components/radios/api.ts +100 -0
  38. package/src/components/radios/config.ts +60 -0
  39. package/src/components/radios/constants.ts +28 -0
  40. package/src/components/radios/index.ts +4 -0
  41. package/src/components/radios/radio.ts +269 -0
  42. package/src/components/radios/radios.ts +42 -0
  43. package/src/components/radios/types.ts +232 -0
  44. package/src/components/sheet/_styles.scss +236 -0
  45. package/src/components/sheet/api.ts +96 -0
  46. package/src/components/sheet/config.ts +66 -0
  47. package/src/components/sheet/constants.ts +20 -0
  48. package/src/components/sheet/features/content.ts +51 -0
  49. package/src/components/sheet/features/gestures.ts +177 -0
  50. package/src/components/sheet/features/index.ts +6 -0
  51. package/src/components/sheet/features/position.ts +42 -0
  52. package/src/components/sheet/features/state.ts +116 -0
  53. package/src/components/sheet/features/title.ts +86 -0
  54. package/src/components/sheet/index.ts +4 -0
  55. package/src/components/sheet/sheet.ts +57 -0
  56. package/src/components/sheet/types.ts +266 -0
  57. package/src/components/slider/_styles.scss +518 -0
  58. package/src/components/slider/api.ts +336 -0
  59. package/src/components/slider/config.ts +145 -0
  60. package/src/components/slider/constants.ts +28 -0
  61. package/src/components/slider/features/appearance.ts +140 -0
  62. package/src/components/slider/features/disabled.ts +43 -0
  63. package/src/components/slider/features/events.ts +164 -0
  64. package/src/components/slider/features/index.ts +5 -0
  65. package/src/components/slider/features/interactions.ts +256 -0
  66. package/src/components/slider/features/keyboard.ts +114 -0
  67. package/src/components/slider/features/slider.ts +336 -0
  68. package/src/components/slider/features/structure.ts +264 -0
  69. package/src/components/slider/features/ui.ts +518 -0
  70. package/src/components/slider/index.ts +9 -0
  71. package/src/components/slider/slider.ts +58 -0
  72. package/src/components/slider/types.ts +166 -0
  73. package/src/components/tabs/_styles.scss +224 -0
  74. package/src/components/tabs/api.ts +443 -0
  75. package/src/components/tabs/config.ts +80 -0
  76. package/src/components/tabs/constants.ts +12 -0
  77. package/src/components/tabs/index.ts +4 -0
  78. package/src/components/tabs/tabs.ts +52 -0
  79. package/src/components/tabs/types.ts +247 -0
  80. package/src/components/textfield/_styles.scss +97 -4
  81. package/src/components/tooltip/_styles.scss +241 -0
  82. package/src/components/tooltip/api.ts +411 -0
  83. package/src/components/tooltip/config.ts +78 -0
  84. package/src/components/tooltip/constants.ts +27 -0
  85. package/src/components/tooltip/index.ts +4 -0
  86. package/src/components/tooltip/tooltip.ts +60 -0
  87. package/src/components/tooltip/types.ts +178 -0
  88. package/src/core/build/_ripple.scss +79 -0
  89. package/src/core/build/constants.ts +48 -0
  90. package/src/core/build/icon.ts +137 -0
  91. package/src/core/build/ripple.ts +216 -0
  92. package/src/core/build/text.ts +91 -0
  93. package/src/index.ts +9 -1
  94. package/src/styles/abstract/_variables.scss +24 -12
  95. package/tsconfig.json +22 -0
  96. package/typedoc.json +28 -0
  97. package/typedoc.simple.json +14 -0
@@ -0,0 +1,38 @@
1
+ // src/components/carousel/index.ts
2
+ /**
3
+ * Carousel Component - Material Design 3 compatible carousel implementation
4
+ *
5
+ * This module exports a carousel component with four layout types:
6
+ * - Multi-browse: For browsing many visual items at once (photos, event feeds)
7
+ * - Uncontained: For highly customized or text-heavy carousels (traditional behavior)
8
+ * - Hero: For spotlighting very large visual items (featured content)
9
+ * - Full-screen: For immersive vertical-scrolling experiences
10
+ *
11
+ * And two scroll behaviors:
12
+ * - Default: Standard scrolling without snapping, recommended for uncontained layouts
13
+ * - Snap: Items snap to carousel layout, recommended for multi-browse, hero, and full-screen layouts
14
+ *
15
+ * @module Carousel
16
+ */
17
+
18
+ // Main factory function
19
+ export { default } from './carousel';
20
+
21
+ // Constants for use with the carousel
22
+ export {
23
+ CAROUSEL_LAYOUTS,
24
+ CAROUSEL_SCROLL_BEHAVIORS,
25
+ CAROUSEL_TRANSITIONS,
26
+ CAROUSEL_EVENTS,
27
+ CAROUSEL_DEFAULTS,
28
+ CAROUSEL_ITEM_SIZES
29
+ } from './constants';
30
+
31
+ // TypeScript interfaces for proper type checking
32
+ export {
33
+ CarouselConfig,
34
+ CarouselComponent,
35
+ CarouselSlide,
36
+ CarouselLayout,
37
+ CarouselScrollBehavior
38
+ } from './types';
@@ -0,0 +1,327 @@
1
+ // src/components/carousel/types.ts
2
+
3
+ /**
4
+ * Material Design 3 Carousel Layout Types
5
+ * @category Components
6
+ */
7
+ export type CarouselLayout =
8
+ /** Best for browsing many visual items at once (photos, event feeds) */
9
+ | 'multi-browse'
10
+ /** For highly customized or text-heavy carousels (traditional behavior) */
11
+ | 'uncontained'
12
+ /** For spotlighting very large visual items (featured content) */
13
+ | 'hero'
14
+ /** For immersive vertical-scrolling experiences */
15
+ | 'full-screen';
16
+
17
+ /**
18
+ * Carousel Scrolling Behaviors
19
+ * @category Components
20
+ */
21
+ export type CarouselScrollBehavior =
22
+ /** Standard scrolling without snapping, recommended for uncontained layouts */
23
+ | 'default'
24
+ /** Items snap to carousel layout, recommended for multi-browse, hero, and full-screen layouts */
25
+ | 'snap';
26
+
27
+ /**
28
+ * Slide data interface
29
+ * @category Components
30
+ */
31
+ export interface CarouselSlide {
32
+ /** Image URL for the slide */
33
+ image: string;
34
+
35
+ /** Optional title text for the slide */
36
+ title?: string;
37
+
38
+ /** Optional accent color in hexadecimal or RGB format */
39
+ accent?: string;
40
+
41
+ /** Optional description text */
42
+ description?: string;
43
+
44
+ /** Optional action button text */
45
+ buttonText?: string;
46
+
47
+ /** Optional action button URL */
48
+ buttonUrl?: string;
49
+
50
+ /** Optional size designation for the item, will be auto-calculated if not provided */
51
+ size?: 'large' | 'medium' | 'small';
52
+ }
53
+
54
+ /**
55
+ * Configuration interface for the Carousel component
56
+ * @category Components
57
+ */
58
+ export interface CarouselConfig {
59
+ /**
60
+ * Initial slide index to display
61
+ * @default 0
62
+ */
63
+ initialSlide?: number;
64
+
65
+ /**
66
+ * Whether to loop the carousel
67
+ * @default true
68
+ */
69
+ loop?: boolean;
70
+
71
+ /**
72
+ * Transition effect for slide changes
73
+ * @default 'slide'
74
+ */
75
+ transition?: 'slide' | 'fade' | 'none';
76
+
77
+ /**
78
+ * Transition duration in milliseconds
79
+ * @default 300
80
+ */
81
+ transitionDuration?: number;
82
+
83
+ /**
84
+ * Slides configuration for the carousel
85
+ * @example [{ image: 'image1.jpg', title: 'Title', accent: '#E6E1E5' }]
86
+ */
87
+ slides?: CarouselSlide[];
88
+
89
+ /**
90
+ * Border radius for slides in pixels
91
+ * @default 16
92
+ */
93
+ borderRadius?: number;
94
+
95
+ /**
96
+ * Gap between slides in pixels
97
+ * @default 8
98
+ */
99
+ gap?: number;
100
+
101
+ /**
102
+ * Additional CSS classes to add to the carousel
103
+ * @example 'hero-carousel featured-carousel'
104
+ */
105
+ class?: string;
106
+
107
+ /**
108
+ * Component prefix for class names
109
+ * @default 'carousel'
110
+ */
111
+ prefix?: string;
112
+
113
+ /**
114
+ * Component name used in class generation
115
+ * @default 'carousel'
116
+ */
117
+ componentName?: string;
118
+
119
+ /**
120
+ * Callback for "Show all" action when present
121
+ */
122
+ onShowAll?: () => void;
123
+
124
+ /**
125
+ * Whether to show a "Show all" link at the end
126
+ * MD3 recommends adding this for accessibility on vertical scrolling pages
127
+ * @default true
128
+ */
129
+ showAllLink?: boolean;
130
+
131
+ /**
132
+ * MD3 carousel layout type
133
+ * @default 'multi-browse'
134
+ */
135
+ layout?: CarouselLayout;
136
+
137
+ /**
138
+ * Scrolling behavior for the carousel
139
+ * @default depends on layout (snap for multi-browse, hero, full-screen; default for uncontained)
140
+ */
141
+ scrollBehavior?: CarouselScrollBehavior;
142
+
143
+ /**
144
+ * Whether to center the carousel items (applies to hero layout)
145
+ * @default false
146
+ */
147
+ centered?: boolean;
148
+
149
+ /**
150
+ * Maximum width of large items (affects how many items fit on screen)
151
+ * Large items should remain big enough to be easily recognizable
152
+ */
153
+ largeItemMaxWidth?: number;
154
+
155
+ /**
156
+ * Width for small items in pixels
157
+ * @default 40-56dp range as per MD3 guidelines
158
+ */
159
+ smallItemWidth?: number;
160
+ }
161
+
162
+ /**
163
+ * Slides API interface for carousel
164
+ * @category Components
165
+ */
166
+ export interface SlidesAPI {
167
+ /**
168
+ * Adds a new slide to the carousel
169
+ * @param slide - CarouselSlide object with slide data
170
+ * @param index - Optional position to insert the slide
171
+ * @returns The slides API for chaining
172
+ */
173
+ addSlide: (slide: CarouselSlide, index?: number) => SlidesAPI;
174
+
175
+ /**
176
+ * Removes a slide at the specified index
177
+ * @param index - Index of the slide to remove
178
+ * @returns The slides API for chaining
179
+ */
180
+ removeSlide: (index: number) => SlidesAPI;
181
+
182
+ /**
183
+ * Updates an existing slide
184
+ * @param index - Index of the slide to update
185
+ * @param slide - Updated CarouselSlide object
186
+ * @returns The slides API for chaining
187
+ */
188
+ updateSlide: (index: number, slide: CarouselSlide) => SlidesAPI;
189
+
190
+ /**
191
+ * Gets a slide at the specified index
192
+ * @param index - Index of the slide
193
+ * @returns CarouselSlide object or null if not found
194
+ */
195
+ getSlide: (index: number) => CarouselSlide | null;
196
+
197
+ /**
198
+ * Gets the total number of slides
199
+ * @returns Number of slides
200
+ */
201
+ getCount: () => number;
202
+
203
+ /**
204
+ * Gets all slide elements
205
+ * @returns Array of slide elements
206
+ */
207
+ getElements: () => HTMLElement[];
208
+ }
209
+
210
+ /**
211
+ * Carousel component interface
212
+ * @category Components
213
+ */
214
+ export interface CarouselComponent {
215
+ /** The carousel's root DOM element */
216
+ element: HTMLElement;
217
+
218
+ /** API for managing carousel slides */
219
+ slides: SlidesAPI;
220
+
221
+ /** API for managing component lifecycle */
222
+ lifecycle: {
223
+ /** Destroys the component and cleans up resources */
224
+ destroy: () => void;
225
+ };
226
+
227
+ /**
228
+ * Gets a class name with the component's prefix
229
+ * @param name - Base class name
230
+ * @returns Prefixed class name
231
+ */
232
+ getClass: (name: string) => string;
233
+
234
+ /**
235
+ * Goes to the next slide
236
+ * @returns The carousel component for chaining
237
+ */
238
+ next: () => CarouselComponent;
239
+
240
+ /**
241
+ * Goes to the previous slide
242
+ * @returns The carousel component for chaining
243
+ */
244
+ prev: () => CarouselComponent;
245
+
246
+ /**
247
+ * Goes to a specific slide
248
+ * @param index - Slide index
249
+ * @returns The carousel component for chaining
250
+ */
251
+ goTo: (index: number) => CarouselComponent;
252
+
253
+ /**
254
+ * Gets the current slide index
255
+ * @returns Current slide index
256
+ */
257
+ getCurrentSlide: () => number;
258
+
259
+ /**
260
+ * Adds a new slide
261
+ * @param slide - CarouselSlide object with slide data
262
+ * @param index - Optional position to insert the slide
263
+ * @returns The carousel component for chaining
264
+ */
265
+ addSlide: (slide: CarouselSlide, index?: number) => CarouselComponent;
266
+
267
+ /**
268
+ * Removes a slide
269
+ * @param index - Index of the slide to remove
270
+ * @returns The carousel component for chaining
271
+ */
272
+ removeSlide: (index: number) => CarouselComponent;
273
+
274
+ /**
275
+ * Enables the loop mode
276
+ * @returns The carousel component for chaining
277
+ */
278
+ enableLoop: () => CarouselComponent;
279
+
280
+ /**
281
+ * Disables the loop mode
282
+ * @returns The carousel component for chaining
283
+ */
284
+ disableLoop: () => CarouselComponent;
285
+
286
+ /**
287
+ * Sets the carousel border radius
288
+ * @param radius - Border radius in pixels
289
+ * @returns The carousel component for chaining
290
+ */
291
+ setBorderRadius: (radius: number) => CarouselComponent;
292
+
293
+ /**
294
+ * Sets the gap between slides
295
+ * @param gap - Gap size in pixels
296
+ * @returns The carousel component for chaining
297
+ */
298
+ setGap: (gap: number) => CarouselComponent;
299
+
300
+ /**
301
+ * Destroys the carousel component and cleans up resources
302
+ */
303
+ destroy: () => void;
304
+
305
+ /**
306
+ * Adds an event listener to the carousel
307
+ * @param event - Event name
308
+ * @param handler - Event handler function
309
+ * @returns The carousel component for chaining
310
+ */
311
+ on: (event: string, handler: Function) => CarouselComponent;
312
+
313
+ /**
314
+ * Removes an event listener from the carousel
315
+ * @param event - Event name
316
+ * @param handler - Event handler function
317
+ * @returns The carousel component for chaining
318
+ */
319
+ off: (event: string, handler: Function) => CarouselComponent;
320
+
321
+ /**
322
+ * Adds CSS classes to the carousel element
323
+ * @param classes - One or more class names to add
324
+ * @returns The carousel component for chaining
325
+ */
326
+ addClass: (...classes: string[]) => CarouselComponent;
327
+ }
@@ -0,0 +1,213 @@
1
+ // src/components/dialog/_styles.scss
2
+ @use '../../styles/abstract/base' as base;
3
+ @use '../../styles/abstract/variables' as v;
4
+ @use '../../styles/abstract/functions' as f;
5
+ @use '../../styles/abstract/mixins' as m;
6
+ @use '../../styles/abstract/theme' as t;
7
+
8
+ $component: '#{base.$prefix}-dialog';
9
+
10
+ // Dialog overlay - covers the entire screen
11
+ .#{$component}-overlay {
12
+ position: fixed;
13
+ top: 0;
14
+ left: 0;
15
+ right: 0;
16
+ bottom: 0;
17
+ background-color: t.alpha('scrim', 0.32);
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ z-index: 1000;
22
+ padding: 24px;
23
+ opacity: 0;
24
+ visibility: hidden;
25
+ transition: opacity 0.15s ease, visibility 0s linear 0.15s;
26
+ overflow-y: auto;
27
+
28
+ &--visible {
29
+ opacity: 1;
30
+ visibility: visible;
31
+ transition: opacity 0.15s ease, visibility 0s linear;
32
+ }
33
+ }
34
+
35
+ // Dialog container
36
+ .#{$component} {
37
+ position: relative;
38
+ display: flex;
39
+ flex-direction: column;
40
+ min-width: 280px;
41
+ max-width: 90vw;
42
+ width: fit-content;
43
+ max-height: calc(100vh - 48px);
44
+ border-radius: 28px;
45
+ background-color: t.color('surface-container-high');
46
+ color: t.color('on-surface');
47
+ overflow: hidden;
48
+ box-sizing: border-box;
49
+ @include m.elevation(3);
50
+ transform: scale(0.8);
51
+ opacity: 0;
52
+ transition: transform 0.15s ease, opacity 0.15s ease;
53
+
54
+ &--visible {
55
+ transform: scale(1);
56
+ opacity: 1;
57
+ }
58
+
59
+ // Fullscreen variant
60
+ &--fullscreen {
61
+ width: 100vw;
62
+ height: 100vh;
63
+ max-width: 100vw;
64
+ max-height: 100vh;
65
+ border-radius: 0;
66
+ margin: 0;
67
+ }
68
+
69
+ // Fullwidth variant
70
+ &--fullwidth {
71
+ width: 100%;
72
+ max-width: 560px;
73
+ }
74
+
75
+ // Dialog header
76
+ &-header {
77
+ display: flex;
78
+ align-items: flex-start;
79
+ padding: 24px 24px 16px;
80
+
81
+ &-content {
82
+ flex: 1;
83
+ min-width: 0;
84
+ }
85
+
86
+ &-title {
87
+ @include m.typography('headline-small');
88
+ color: t.color('on-surface');
89
+ margin: 0;
90
+ overflow: hidden;
91
+ text-overflow: ellipsis;
92
+ white-space: nowrap;
93
+ }
94
+
95
+ &-subtitle {
96
+ @include m.typography('body-medium');
97
+ color: t.color('on-surface-variant');
98
+ margin: 4px 0 0;
99
+ overflow: hidden;
100
+ text-overflow: ellipsis;
101
+ white-space: nowrap;
102
+ }
103
+
104
+ &-close {
105
+ margin: -8px -8px -8px 8px;
106
+ padding: 8px;
107
+ border: none;
108
+ background: transparent;
109
+ cursor: pointer;
110
+ display: flex;
111
+ align-items: center;
112
+ justify-content: center;
113
+ border-radius: 50%;
114
+ color: t.color('on-surface-variant');
115
+
116
+ &:hover {
117
+ background-color: t.alpha('on-surface', 0.08);
118
+ }
119
+
120
+ &:active {
121
+ background-color: t.alpha('on-surface', 0.12);
122
+ }
123
+
124
+ svg {
125
+ width: 24px;
126
+ height: 24px;
127
+ }
128
+ }
129
+ }
130
+
131
+ // Dialog content
132
+ &-content {
133
+ flex: 1 1 auto;
134
+ padding: 0 24px;
135
+ overflow-y: auto;
136
+ -webkit-overflow-scrolling: touch;
137
+ @include m.typography('body-medium');
138
+ color: t.color('on-surface-variant');
139
+
140
+ &:first-child {
141
+ padding-top: 24px;
142
+ }
143
+
144
+ &:last-child {
145
+ padding-bottom: 24px;
146
+ }
147
+ }
148
+
149
+ // Dialog footer
150
+ &-footer {
151
+ display: flex;
152
+ flex-wrap: wrap;
153
+ align-items: center;
154
+ justify-content: flex-end;
155
+ padding: 16px 24px 24px;
156
+ gap: 8px;
157
+
158
+ &--left {
159
+ justify-content: flex-start;
160
+ }
161
+
162
+ &--center {
163
+ justify-content: center;
164
+ }
165
+
166
+ &--space-between {
167
+ justify-content: space-between;
168
+ }
169
+
170
+ button {
171
+ margin: 0;
172
+ }
173
+ }
174
+
175
+ // Size variants
176
+ &--small {
177
+ max-width: 400px;
178
+ }
179
+
180
+ &--medium {
181
+ max-width: 560px;
182
+ }
183
+
184
+ &--large {
185
+ max-width: 90vw;
186
+ width: 800px;
187
+ }
188
+
189
+ // Animation variants
190
+ &--slide-up {
191
+ transform: translateY(20px) scale(1);
192
+
193
+ &.#{$component}--visible {
194
+ transform: translateY(0) scale(1);
195
+ }
196
+ }
197
+
198
+ &--slide-down {
199
+ transform: translateY(-20px) scale(1);
200
+
201
+ &.#{$component}--visible {
202
+ transform: translateY(0) scale(1);
203
+ }
204
+ }
205
+
206
+ &--fade {
207
+ transform: scale(1);
208
+
209
+ &.#{$component}--visible {
210
+ transform: scale(1);
211
+ }
212
+ }
213
+ }