mtrl 0.2.2 → 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/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/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 -12
- package/tsconfig.json +22 -0
- package/typedoc.json +28 -0
- package/typedoc.simple.json +14 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// src/components/slider/types.ts
|
|
2
|
+
import { SLIDER_COLORS, SLIDER_SIZES, SLIDER_ORIENTATIONS, SLIDER_EVENTS } from './constants';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration interface for the Slider component
|
|
6
|
+
*/
|
|
7
|
+
export interface SliderConfig {
|
|
8
|
+
/** Minimum value of the slider */
|
|
9
|
+
min?: number;
|
|
10
|
+
|
|
11
|
+
/** Maximum value of the slider */
|
|
12
|
+
max?: number;
|
|
13
|
+
|
|
14
|
+
/** Current value of the slider */
|
|
15
|
+
value?: number;
|
|
16
|
+
|
|
17
|
+
/** Secondary value for range slider (when using two thumbs) */
|
|
18
|
+
secondValue?: number;
|
|
19
|
+
|
|
20
|
+
/** Step size for discrete slider */
|
|
21
|
+
step?: number;
|
|
22
|
+
|
|
23
|
+
/** Whether the slider is disabled */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
|
|
26
|
+
/** Color variant of the slider */
|
|
27
|
+
color?: keyof typeof SLIDER_COLORS | SLIDER_COLORS;
|
|
28
|
+
|
|
29
|
+
/** Size variant of the slider */
|
|
30
|
+
size?: keyof typeof SLIDER_SIZES | SLIDER_SIZES;
|
|
31
|
+
|
|
32
|
+
/** Orientation of the slider */
|
|
33
|
+
orientation?: keyof typeof SLIDER_ORIENTATIONS | SLIDER_ORIENTATIONS;
|
|
34
|
+
|
|
35
|
+
/** Whether to show tick marks */
|
|
36
|
+
ticks?: boolean;
|
|
37
|
+
|
|
38
|
+
/** Whether to show tick labels */
|
|
39
|
+
tickLabels?: boolean | string[];
|
|
40
|
+
|
|
41
|
+
/** Whether to show the current value while dragging */
|
|
42
|
+
showValue?: boolean;
|
|
43
|
+
|
|
44
|
+
/** Format function for displayed values */
|
|
45
|
+
valueFormatter?: (value: number) => string;
|
|
46
|
+
|
|
47
|
+
/** Whether to snap to steps while dragging (discrete slider) */
|
|
48
|
+
snapToSteps?: boolean;
|
|
49
|
+
|
|
50
|
+
/** Whether the slider is a range slider (two thumbs) */
|
|
51
|
+
range?: boolean;
|
|
52
|
+
|
|
53
|
+
/** Additional CSS classes */
|
|
54
|
+
class?: string;
|
|
55
|
+
|
|
56
|
+
/** Event handlers for slider events */
|
|
57
|
+
on?: {
|
|
58
|
+
[key in keyof typeof SLIDER_EVENTS]?: (event: SliderEvent) => void;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Slider event object
|
|
64
|
+
*/
|
|
65
|
+
export interface SliderEvent {
|
|
66
|
+
/** Slider component instance */
|
|
67
|
+
slider: SliderComponent;
|
|
68
|
+
|
|
69
|
+
/** Current slider value */
|
|
70
|
+
value: number;
|
|
71
|
+
|
|
72
|
+
/** Secondary slider value (for range slider) */
|
|
73
|
+
secondValue?: number;
|
|
74
|
+
|
|
75
|
+
/** Original event if applicable */
|
|
76
|
+
originalEvent?: Event;
|
|
77
|
+
|
|
78
|
+
/** Whether to prevent the default action */
|
|
79
|
+
preventDefault: () => void;
|
|
80
|
+
|
|
81
|
+
/** Whether default action was prevented */
|
|
82
|
+
defaultPrevented: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Slider component interface
|
|
87
|
+
*/
|
|
88
|
+
export interface SliderComponent {
|
|
89
|
+
/** Slider element */
|
|
90
|
+
element: HTMLElement;
|
|
91
|
+
|
|
92
|
+
/** Sets slider value */
|
|
93
|
+
setValue: (value: number, triggerEvent?: boolean) => SliderComponent;
|
|
94
|
+
|
|
95
|
+
/** Gets slider value */
|
|
96
|
+
getValue: () => number;
|
|
97
|
+
|
|
98
|
+
/** Sets secondary slider value (for range slider) */
|
|
99
|
+
setSecondValue: (value: number, triggerEvent?: boolean) => SliderComponent;
|
|
100
|
+
|
|
101
|
+
/** Gets secondary slider value */
|
|
102
|
+
getSecondValue: () => number | null;
|
|
103
|
+
|
|
104
|
+
/** Sets slider minimum */
|
|
105
|
+
setMin: (min: number) => SliderComponent;
|
|
106
|
+
|
|
107
|
+
/** Gets slider minimum */
|
|
108
|
+
getMin: () => number;
|
|
109
|
+
|
|
110
|
+
/** Sets slider maximum */
|
|
111
|
+
setMax: (max: number) => SliderComponent;
|
|
112
|
+
|
|
113
|
+
/** Gets slider maximum */
|
|
114
|
+
getMax: () => number;
|
|
115
|
+
|
|
116
|
+
/** Sets slider step size */
|
|
117
|
+
setStep: (step: number) => SliderComponent;
|
|
118
|
+
|
|
119
|
+
/** Gets slider step size */
|
|
120
|
+
getStep: () => number;
|
|
121
|
+
|
|
122
|
+
/** Enables the slider */
|
|
123
|
+
enable: () => SliderComponent;
|
|
124
|
+
|
|
125
|
+
/** Disables the slider */
|
|
126
|
+
disable: () => SliderComponent;
|
|
127
|
+
|
|
128
|
+
/** Checks if slider is disabled */
|
|
129
|
+
isDisabled: () => boolean;
|
|
130
|
+
|
|
131
|
+
/** Sets slider color */
|
|
132
|
+
setColor: (color: keyof typeof SLIDER_COLORS | SLIDER_COLORS) => SliderComponent;
|
|
133
|
+
|
|
134
|
+
/** Gets slider color */
|
|
135
|
+
getColor: () => string;
|
|
136
|
+
|
|
137
|
+
/** Sets slider size */
|
|
138
|
+
setSize: (size: keyof typeof SLIDER_SIZES | SLIDER_SIZES) => SliderComponent;
|
|
139
|
+
|
|
140
|
+
/** Gets slider size */
|
|
141
|
+
getSize: () => string;
|
|
142
|
+
|
|
143
|
+
/** Sets slider orientation */
|
|
144
|
+
setOrientation: (orientation: keyof typeof SLIDER_ORIENTATIONS | SLIDER_ORIENTATIONS) => SliderComponent;
|
|
145
|
+
|
|
146
|
+
/** Gets slider orientation */
|
|
147
|
+
getOrientation: () => string;
|
|
148
|
+
|
|
149
|
+
/** Shows or hides tick marks */
|
|
150
|
+
showTicks: (show: boolean) => SliderComponent;
|
|
151
|
+
|
|
152
|
+
/** Shows or hides tick labels */
|
|
153
|
+
showTickLabels: (show: boolean | string[]) => SliderComponent;
|
|
154
|
+
|
|
155
|
+
/** Shows or hides current value while dragging */
|
|
156
|
+
showCurrentValue: (show: boolean) => SliderComponent;
|
|
157
|
+
|
|
158
|
+
/** Adds event listener */
|
|
159
|
+
on: (event: keyof typeof SLIDER_EVENTS | SLIDER_EVENTS, handler: (event: SliderEvent) => void) => SliderComponent;
|
|
160
|
+
|
|
161
|
+
/** Removes event listener */
|
|
162
|
+
off: (event: keyof typeof SLIDER_EVENTS | SLIDER_EVENTS, handler: (event: SliderEvent) => void) => SliderComponent;
|
|
163
|
+
|
|
164
|
+
/** Destroys the slider component and cleans up resources */
|
|
165
|
+
destroy: () => void;
|
|
166
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// src/components/tabs/_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}-tabs';
|
|
9
|
+
|
|
10
|
+
.#{$component} {
|
|
11
|
+
// Base styles
|
|
12
|
+
position: relative;
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
width: 100%;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
|
|
18
|
+
// Tabs list container
|
|
19
|
+
&__list {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
width: 100%;
|
|
23
|
+
position: relative;
|
|
24
|
+
|
|
25
|
+
// Handle scrollable tabs
|
|
26
|
+
.#{$component}--scrollable & {
|
|
27
|
+
overflow-x: auto;
|
|
28
|
+
scrollbar-width: none; // Firefox
|
|
29
|
+
-ms-overflow-style: none; // IE/Edge
|
|
30
|
+
|
|
31
|
+
// Hide scrollbar in WebKit
|
|
32
|
+
&::-webkit-scrollbar {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Individual tab
|
|
39
|
+
&__tab {
|
|
40
|
+
position: relative;
|
|
41
|
+
min-width: 90px;
|
|
42
|
+
max-width: 360px;
|
|
43
|
+
height: 48px;
|
|
44
|
+
padding: 0 16px;
|
|
45
|
+
background: transparent;
|
|
46
|
+
border: none;
|
|
47
|
+
border-radius: 0;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
outline: none;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
|
|
54
|
+
// Typography
|
|
55
|
+
@include m.typography('label-large');
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
text-align: center;
|
|
58
|
+
color: t.color('on-surface-variant');
|
|
59
|
+
|
|
60
|
+
// Transitions
|
|
61
|
+
@include m.motion-transition(
|
|
62
|
+
color,
|
|
63
|
+
background-color
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Hover state
|
|
67
|
+
&:hover:not(:disabled) {
|
|
68
|
+
@include m.state-layer(t.color('on-surface'), 'hover');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Active state
|
|
72
|
+
&:active:not(:disabled) {
|
|
73
|
+
@include m.state-layer(t.color('on-surface'), 'pressed');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Selected state (active tab)
|
|
77
|
+
&--active {
|
|
78
|
+
color: t.color('primary');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Focus state
|
|
82
|
+
&:focus-visible {
|
|
83
|
+
outline: 2px solid t.color('outline');
|
|
84
|
+
outline-offset: -2px;
|
|
85
|
+
z-index: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Disabled state
|
|
89
|
+
&:disabled {
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
color: t.alpha('on-surface', 0.38);
|
|
92
|
+
cursor: default;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Tab content
|
|
96
|
+
&-content {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
gap: 8px;
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Tab icon
|
|
106
|
+
&-icon {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
width: 18px;
|
|
111
|
+
height: 18px;
|
|
112
|
+
|
|
113
|
+
svg {
|
|
114
|
+
width: 18px;
|
|
115
|
+
height: 18px;
|
|
116
|
+
fill: currentColor;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Tab label
|
|
121
|
+
&-label {
|
|
122
|
+
@include m.truncate;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Active indicator
|
|
127
|
+
&__indicator {
|
|
128
|
+
position: absolute;
|
|
129
|
+
bottom: 0;
|
|
130
|
+
left: 0;
|
|
131
|
+
height: 2px;
|
|
132
|
+
background-color: t.color('primary');
|
|
133
|
+
transform-origin: left center;
|
|
134
|
+
z-index: 1;
|
|
135
|
+
|
|
136
|
+
.#{$component}--animated & {
|
|
137
|
+
transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1), width 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Hide indicator if specified
|
|
141
|
+
.#{$component}--no-indicator & {
|
|
142
|
+
display: none;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Variants
|
|
147
|
+
|
|
148
|
+
// Primary variant (default)
|
|
149
|
+
&--primary {
|
|
150
|
+
.#{$component}__tab {
|
|
151
|
+
color: t.color('on-surface-variant');
|
|
152
|
+
|
|
153
|
+
&--active {
|
|
154
|
+
color: t.color('primary');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.#{$component}__indicator {
|
|
159
|
+
background-color: t.color('primary');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Secondary variant
|
|
164
|
+
&--secondary {
|
|
165
|
+
.#{$component}__tab {
|
|
166
|
+
color: t.color('on-surface-variant');
|
|
167
|
+
|
|
168
|
+
&--active {
|
|
169
|
+
color: t.color('secondary');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.#{$component}__indicator {
|
|
174
|
+
background-color: t.color('secondary');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Segmented variant (Material Design 3 segmented buttons style)
|
|
179
|
+
&--segmented {
|
|
180
|
+
background-color: t.color('surface-container-low');
|
|
181
|
+
border-radius: 16px;
|
|
182
|
+
padding: 4px;
|
|
183
|
+
|
|
184
|
+
.#{$component}__list {
|
|
185
|
+
background-color: transparent;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.#{$component}__tab {
|
|
189
|
+
border-radius: 12px;
|
|
190
|
+
color: t.color('on-surface');
|
|
191
|
+
|
|
192
|
+
&--active {
|
|
193
|
+
background-color: t.color('surface');
|
|
194
|
+
color: t.color('on-surface');
|
|
195
|
+
@include m.elevation(1);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.#{$component}__indicator {
|
|
200
|
+
display: none;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Neutral variant
|
|
205
|
+
&--neutral {
|
|
206
|
+
.#{$component}__tab {
|
|
207
|
+
color: t.color('on-surface-variant');
|
|
208
|
+
|
|
209
|
+
&--active {
|
|
210
|
+
color: t.color('on-surface');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.#{$component}__indicator {
|
|
215
|
+
background-color: t.color('on-surface');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Disabled state
|
|
220
|
+
&[aria-disabled="true"] {
|
|
221
|
+
pointer-events: none;
|
|
222
|
+
opacity: 0.38;
|
|
223
|
+
}
|
|
224
|
+
}
|