mtrl 0.2.6 → 0.2.8
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/demo/build.ts +349 -0
- package/demo/index.html +110 -0
- package/demo/main.js +448 -0
- package/demo/styles.css +239 -0
- package/index.ts +18 -0
- package/package.json +14 -3
- package/server.ts +86 -0
- package/src/components/badge/api.ts +70 -63
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +66 -13
- package/src/components/badge/features.ts +51 -42
- package/src/components/badge/index.ts +27 -2
- package/src/components/badge/types.ts +62 -30
- package/src/components/bottom-app-bar/bottom-app-bar.ts +154 -0
- package/src/components/bottom-app-bar/config.ts +29 -0
- package/src/components/bottom-app-bar/index.ts +17 -0
- package/src/components/bottom-app-bar/types.ts +114 -0
- package/src/components/button/api.ts +5 -0
- package/src/components/button/button.ts +0 -1
- package/src/components/button/config.ts +6 -2
- package/src/components/button/index.ts +10 -2
- package/src/components/button/types.ts +20 -2
- package/src/components/card/card.ts +13 -25
- package/src/components/card/config.ts +83 -30
- package/src/components/card/content.ts +8 -10
- package/src/components/card/features.ts +4 -3
- package/src/components/card/index.ts +29 -2
- package/src/components/card/types.ts +33 -22
- package/src/components/checkbox/config.ts +3 -4
- package/src/components/checkbox/index.ts +1 -2
- package/src/components/checkbox/types.ts +12 -3
- package/src/components/chip/api.ts +170 -221
- package/src/components/chip/chip.ts +34 -302
- package/src/components/chip/config.ts +1 -2
- package/src/components/chip/index.ts +10 -2
- package/src/components/chip/types.ts +224 -35
- package/src/components/datepicker/api.ts +265 -0
- package/src/components/datepicker/config.ts +141 -0
- package/src/components/datepicker/datepicker.ts +341 -0
- package/src/components/datepicker/index.ts +12 -0
- package/src/components/datepicker/render.ts +450 -0
- package/src/components/datepicker/types.ts +397 -0
- package/src/components/datepicker/utils.ts +289 -0
- package/src/components/dialog/api.ts +55 -21
- package/src/components/dialog/config.ts +12 -9
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +345 -151
- package/src/components/dialog/index.ts +38 -8
- package/src/components/dialog/types.ts +40 -14
- package/src/components/divider/config.ts +81 -0
- package/src/components/divider/divider.ts +37 -0
- package/src/components/divider/features.ts +207 -0
- package/src/components/divider/index.ts +9 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +112 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +9 -0
- package/src/components/extended-fab/types.ts +304 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +93 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +9 -0
- package/src/components/fab/types.ts +251 -0
- package/src/components/list/config.ts +4 -5
- package/src/components/list/features.ts +6 -7
- package/src/components/list/index.ts +7 -9
- package/src/components/list/list-item.ts +12 -13
- package/src/components/list/types.ts +50 -5
- package/src/components/list/utils.ts +30 -3
- package/src/components/menu/features/items-manager.ts +9 -9
- package/src/components/menu/features/positioning.ts +7 -7
- package/src/components/menu/features/visibility.ts +7 -7
- package/src/components/menu/index.ts +7 -9
- package/src/components/menu/menu-item.ts +6 -6
- package/src/components/menu/menu.ts +22 -0
- package/src/components/menu/types.ts +29 -10
- package/src/components/menu/utils.ts +67 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/config.ts +22 -10
- package/src/components/navigation/features/items.ts +284 -0
- package/src/components/navigation/index.ts +0 -6
- package/src/components/navigation/nav-item.ts +70 -33
- package/src/components/navigation/navigation.ts +53 -3
- package/src/components/navigation/types.ts +117 -70
- package/src/components/progress/api.ts +2 -3
- package/src/components/progress/config.ts +2 -3
- package/src/components/progress/index.ts +0 -1
- package/src/components/progress/progress.ts +1 -2
- package/src/components/progress/types.ts +186 -33
- package/src/components/radios/config.ts +1 -1
- package/src/components/radios/index.ts +0 -1
- package/src/components/radios/types.ts +0 -7
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +86 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +717 -0
- package/src/components/search/features/states.ts +169 -0
- package/src/components/search/features/structure.ts +197 -0
- package/src/components/search/index.ts +7 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +175 -0
- package/src/components/segmented-button/config.ts +80 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +154 -0
- package/src/components/segmented-button/segmented-button.ts +249 -0
- package/src/components/segmented-button/types.ts +254 -0
- package/src/components/slider/accessibility.md +5 -5
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -47
- package/src/components/slider/features/handlers.ts +495 -0
- package/src/components/slider/features/index.ts +1 -2
- package/src/components/slider/features/slider.ts +66 -84
- package/src/components/slider/features/states.ts +195 -0
- package/src/components/slider/features/structure.ts +136 -206
- package/src/components/slider/features/ui.ts +145 -206
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +67 -26
- package/src/components/snackbar/config.ts +2 -3
- package/src/components/snackbar/constants.ts +0 -32
- package/src/components/snackbar/index.ts +0 -1
- package/src/components/snackbar/position.ts +9 -1
- package/src/components/snackbar/types.ts +122 -46
- package/src/components/switch/config.ts +2 -3
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/types.ts +3 -2
- package/src/components/tabs/config.ts +3 -4
- package/src/components/tabs/features.ts +4 -2
- package/src/components/tabs/index.ts +0 -15
- package/src/components/tabs/indicator.ts +73 -13
- package/src/components/tabs/tab-api.ts +12 -4
- package/src/components/tabs/tab.ts +18 -6
- package/src/components/tabs/types.ts +23 -5
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/index.ts +0 -1
- package/src/components/textfield/types.ts +17 -3
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +228 -0
- package/src/components/timepicker/index.ts +3 -0
- package/src/components/timepicker/render.ts +613 -0
- package/src/components/timepicker/timepicker.ts +117 -0
- package/src/components/timepicker/types.ts +336 -0
- package/src/components/timepicker/utils.ts +241 -0
- package/src/components/tooltip/api.ts +1 -1
- package/src/components/tooltip/config.ts +27 -6
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/types.ts +13 -3
- package/src/components/top-app-bar/config.ts +83 -0
- package/src/components/top-app-bar/index.ts +11 -0
- package/src/components/top-app-bar/top-app-bar.ts +316 -0
- package/src/components/top-app-bar/types.ts +140 -0
- package/src/core/build/_ripple.scss +6 -6
- package/src/core/build/ripple.ts +72 -95
- package/src/core/compose/features/icon.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +23 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +9 -1
- package/src/styles/components/_badge.scss +182 -0
- package/src/styles/components/_bottom-app-bar.scss +103 -0
- package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -10
- package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -2
- package/src/styles/components/_datepicker.scss +358 -0
- package/src/styles/components/_dialog.scss +259 -0
- package/src/styles/components/_divider.scss +57 -0
- package/src/styles/components/_extended-fab.scss +267 -0
- package/src/styles/components/_fab.scss +225 -0
- package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +1 -0
- package/src/styles/components/_search.scss +306 -0
- package/src/styles/components/_segmented-button.scss +117 -0
- package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +83 -24
- package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -2
- package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +95 -33
- package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
- package/src/styles/components/_timepicker.scss +451 -0
- package/src/styles/components/_top-app-bar.scss +225 -0
- package/src/styles/main.scss +98 -49
- package/src/styles/themes/_autumn.scss +21 -0
- package/src/styles/themes/_base-theme.scss +61 -0
- package/src/styles/themes/_baseline.scss +58 -0
- package/src/styles/themes/_bluekhaki.scss +125 -0
- package/src/styles/themes/_brownbeige.scss +125 -0
- package/src/styles/themes/_browngreen.scss +125 -0
- package/src/styles/themes/_forest.scss +6 -0
- package/src/styles/themes/_greenbeige.scss +125 -0
- package/src/styles/themes/_material.scss +125 -0
- package/src/styles/themes/_ocean.scss +6 -0
- package/src/styles/themes/_sageivory.scss +125 -0
- package/src/styles/themes/_spring.scss +6 -0
- package/src/styles/themes/_summer.scss +5 -0
- package/src/styles/themes/_sunset.scss +5 -0
- package/src/styles/themes/_tealcaramel.scss +125 -0
- package/src/styles/themes/_winter.scss +6 -0
- package/src/components/badge/_styles.scss +0 -174
- package/src/components/badge/constants.ts +0 -30
- package/src/components/button/constants.ts +0 -11
- package/src/components/card/constants.ts +0 -84
- package/src/components/dialog/_styles.scss +0 -213
- package/src/components/dialog/constants.ts +0 -32
- package/src/components/menu/constants.ts +0 -154
- package/src/components/navigation/constants.ts +0 -200
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/progress/constants.ts +0 -29
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -68
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -396
- package/src/components/slider/features/keyboard.ts +0 -233
- package/src/components/switch/constants.ts +0 -80
- package/src/components/tabs/constants.ts +0 -89
- package/src/core/collection/adapters/mongodb.js +0 -232
- /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
- /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
- /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
- /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
- /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
- /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
- /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
- /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
- /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
- /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
- /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
// src/components/slider/types.ts
|
|
2
|
-
import { SLIDER_COLORS, SLIDER_SIZES, SLIDER_EVENTS } from './constants';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Available slider color variants
|
|
5
|
+
*/
|
|
6
|
+
export type SliderColor = 'primary' | 'secondary' | 'tertiary' | 'error';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Available slider size variants
|
|
10
|
+
*/
|
|
11
|
+
export type SliderSize = 'small' | 'medium' | 'large';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Available slider event types
|
|
15
|
+
*/
|
|
16
|
+
export type SliderEventType = 'change' | 'input' | 'focus' | 'blur' | 'start' | 'end';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Configuration options for the slider component
|
|
20
|
+
* @interface SliderConfig
|
|
6
21
|
*/
|
|
7
22
|
export interface SliderConfig {
|
|
8
23
|
/** Minimum value of the slider */
|
|
@@ -14,7 +29,7 @@ export interface SliderConfig {
|
|
|
14
29
|
/** Current value of the slider */
|
|
15
30
|
value?: number;
|
|
16
31
|
|
|
17
|
-
/** Secondary value for range slider (when using two
|
|
32
|
+
/** Secondary value for range slider (when using two handles) */
|
|
18
33
|
secondValue?: number;
|
|
19
34
|
|
|
20
35
|
/** Step size for discrete slider */
|
|
@@ -24,10 +39,10 @@ export interface SliderConfig {
|
|
|
24
39
|
disabled?: boolean;
|
|
25
40
|
|
|
26
41
|
/** Color variant of the slider */
|
|
27
|
-
color?:
|
|
42
|
+
color?: SliderColor;
|
|
28
43
|
|
|
29
44
|
/** Size variant of the slider */
|
|
30
|
-
size?:
|
|
45
|
+
size?: SliderSize;
|
|
31
46
|
|
|
32
47
|
/** Whether to show tick marks */
|
|
33
48
|
ticks?: boolean;
|
|
@@ -41,46 +56,60 @@ export interface SliderConfig {
|
|
|
41
56
|
/** Whether to snap to steps while dragging (discrete slider) */
|
|
42
57
|
snapToSteps?: boolean;
|
|
43
58
|
|
|
44
|
-
/** Whether the slider is a range slider (two
|
|
59
|
+
/** Whether the slider is a range slider (two handles) */
|
|
45
60
|
range?: boolean;
|
|
46
61
|
|
|
62
|
+
/** Label text for the slider */
|
|
63
|
+
label?: string;
|
|
64
|
+
|
|
65
|
+
/** Position of the label (start or end) - defaults to 'start' */
|
|
66
|
+
labelPosition?: 'start' | 'end';
|
|
67
|
+
|
|
68
|
+
/** Icon to display with the slider */
|
|
69
|
+
icon?: string;
|
|
70
|
+
|
|
71
|
+
/** Position of the icon (start or end) */
|
|
72
|
+
iconPosition?: 'start' | 'end';
|
|
73
|
+
|
|
47
74
|
/** Additional CSS classes */
|
|
48
75
|
class?: string;
|
|
49
76
|
|
|
50
77
|
/** Event handlers for slider events */
|
|
51
78
|
on?: {
|
|
52
|
-
[key in
|
|
79
|
+
[key in SliderEventType]?: (event: SliderEvent) => void;
|
|
53
80
|
};
|
|
54
81
|
}
|
|
55
82
|
|
|
56
83
|
/**
|
|
57
|
-
* Slider event
|
|
84
|
+
* Slider event data
|
|
85
|
+
* @interface SliderEvent
|
|
58
86
|
*/
|
|
59
87
|
export interface SliderEvent {
|
|
60
|
-
/**
|
|
61
|
-
slider:
|
|
88
|
+
/** The slider component that triggered the event */
|
|
89
|
+
slider: any;
|
|
62
90
|
|
|
63
91
|
/** Current slider value */
|
|
64
92
|
value: number;
|
|
65
93
|
|
|
66
|
-
/** Secondary
|
|
67
|
-
secondValue
|
|
94
|
+
/** Secondary value (for range sliders) */
|
|
95
|
+
secondValue: number | null;
|
|
68
96
|
|
|
69
|
-
/** Original event if
|
|
70
|
-
originalEvent
|
|
97
|
+
/** Original DOM event if available */
|
|
98
|
+
originalEvent: Event | null;
|
|
71
99
|
|
|
72
|
-
/**
|
|
100
|
+
/** Function to prevent default behavior */
|
|
73
101
|
preventDefault: () => void;
|
|
74
102
|
|
|
75
|
-
/** Whether default
|
|
103
|
+
/** Whether default behavior was prevented */
|
|
76
104
|
defaultPrevented: boolean;
|
|
77
105
|
}
|
|
78
106
|
|
|
79
107
|
/**
|
|
80
|
-
* Slider component interface
|
|
108
|
+
* Slider component public API interface
|
|
109
|
+
* @interface SliderComponent
|
|
81
110
|
*/
|
|
82
111
|
export interface SliderComponent {
|
|
83
|
-
/**
|
|
112
|
+
/** The root element of the slider */
|
|
84
113
|
element: HTMLElement;
|
|
85
114
|
|
|
86
115
|
/** Sets slider value */
|
|
@@ -95,16 +124,16 @@ export interface SliderComponent {
|
|
|
95
124
|
/** Gets secondary slider value */
|
|
96
125
|
getSecondValue: () => number | null;
|
|
97
126
|
|
|
98
|
-
/** Sets slider minimum */
|
|
127
|
+
/** Sets slider minimum value */
|
|
99
128
|
setMin: (min: number) => SliderComponent;
|
|
100
129
|
|
|
101
|
-
/** Gets slider minimum */
|
|
130
|
+
/** Gets slider minimum value */
|
|
102
131
|
getMin: () => number;
|
|
103
132
|
|
|
104
|
-
/** Sets slider maximum */
|
|
133
|
+
/** Sets slider maximum value */
|
|
105
134
|
setMax: (max: number) => SliderComponent;
|
|
106
135
|
|
|
107
|
-
/** Gets slider maximum */
|
|
136
|
+
/** Gets slider maximum value */
|
|
108
137
|
getMax: () => number;
|
|
109
138
|
|
|
110
139
|
/** Sets slider step size */
|
|
@@ -123,13 +152,13 @@ export interface SliderComponent {
|
|
|
123
152
|
isDisabled: () => boolean;
|
|
124
153
|
|
|
125
154
|
/** Sets slider color */
|
|
126
|
-
setColor: (color:
|
|
155
|
+
setColor: (color: SliderColor) => SliderComponent;
|
|
127
156
|
|
|
128
157
|
/** Gets slider color */
|
|
129
158
|
getColor: () => string;
|
|
130
159
|
|
|
131
160
|
/** Sets slider size */
|
|
132
|
-
setSize: (size:
|
|
161
|
+
setSize: (size: SliderSize) => SliderComponent;
|
|
133
162
|
|
|
134
163
|
/** Gets slider size */
|
|
135
164
|
getSize: () => string;
|
|
@@ -140,11 +169,23 @@ export interface SliderComponent {
|
|
|
140
169
|
/** Shows or hides current value while dragging */
|
|
141
170
|
showCurrentValue: (show: boolean) => SliderComponent;
|
|
142
171
|
|
|
172
|
+
/** Sets label text */
|
|
173
|
+
setLabel: (text: string) => SliderComponent;
|
|
174
|
+
|
|
175
|
+
/** Gets label text */
|
|
176
|
+
getLabel: () => string;
|
|
177
|
+
|
|
178
|
+
/** Sets icon HTML */
|
|
179
|
+
setIcon: (iconHtml: string) => SliderComponent;
|
|
180
|
+
|
|
181
|
+
/** Gets icon HTML */
|
|
182
|
+
getIcon: () => string;
|
|
183
|
+
|
|
143
184
|
/** Adds event listener */
|
|
144
|
-
on: (event:
|
|
185
|
+
on: (event: SliderEventType, handler: (event: SliderEvent) => void) => SliderComponent;
|
|
145
186
|
|
|
146
187
|
/** Removes event listener */
|
|
147
|
-
off: (event:
|
|
188
|
+
off: (event: SliderEventType, handler: (event: SliderEvent) => void) => SliderComponent;
|
|
148
189
|
|
|
149
190
|
/** Destroys the slider component and cleans up resources */
|
|
150
191
|
destroy: () => void;
|
|
@@ -5,14 +5,13 @@ import {
|
|
|
5
5
|
BaseComponentConfig
|
|
6
6
|
} from '../../core/config/component-config';
|
|
7
7
|
import { SnackbarConfig, BaseComponent, ApiOptions } from './types';
|
|
8
|
-
import { SNACKBAR_VARIANTS, SNACKBAR_POSITIONS } from './constants';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Default configuration for the Snackbar component
|
|
12
11
|
*/
|
|
13
12
|
export const defaultConfig: SnackbarConfig = {
|
|
14
|
-
variant:
|
|
15
|
-
position:
|
|
13
|
+
variant: 'basic',
|
|
14
|
+
position: 'center',
|
|
16
15
|
duration: 4000
|
|
17
16
|
};
|
|
18
17
|
|
|
@@ -17,38 +17,6 @@ export const SNACKBAR_POSITIONS = {
|
|
|
17
17
|
END: 'end'
|
|
18
18
|
} as const;
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Validation schema for snackbar configuration
|
|
22
|
-
*/
|
|
23
|
-
export const SNACKBAR_SCHEMA = {
|
|
24
|
-
variant: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
enum: Object.values(SNACKBAR_VARIANTS),
|
|
27
|
-
required: false
|
|
28
|
-
},
|
|
29
|
-
position: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
enum: Object.values(SNACKBAR_POSITIONS),
|
|
32
|
-
required: false
|
|
33
|
-
},
|
|
34
|
-
message: {
|
|
35
|
-
type: 'string',
|
|
36
|
-
required: true
|
|
37
|
-
},
|
|
38
|
-
action: {
|
|
39
|
-
type: 'string',
|
|
40
|
-
required: false
|
|
41
|
-
},
|
|
42
|
-
duration: {
|
|
43
|
-
type: 'number',
|
|
44
|
-
required: false
|
|
45
|
-
},
|
|
46
|
-
class: {
|
|
47
|
-
type: 'string',
|
|
48
|
-
required: false
|
|
49
|
-
}
|
|
50
|
-
} as const;
|
|
51
|
-
|
|
52
20
|
/**
|
|
53
21
|
* Snackbar state classes
|
|
54
22
|
*/
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// src/components/snackbar/position.ts
|
|
2
|
-
import { SNACKBAR_POSITIONS } from './constants';
|
|
3
2
|
import { BaseComponent } from './types';
|
|
4
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Snackbar display positions
|
|
6
|
+
*/
|
|
7
|
+
const SNACKBAR_POSITIONS = {
|
|
8
|
+
CENTER: 'center',
|
|
9
|
+
START: 'start',
|
|
10
|
+
END: 'end'
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
/**
|
|
6
14
|
* Position configuration for the withPosition function
|
|
7
15
|
*/
|
|
@@ -1,58 +1,134 @@
|
|
|
1
|
-
// src/components/snackbar/
|
|
1
|
+
// src/components/snackbar/types.ts
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Available snackbar variants
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
BASIC: 'basic',
|
|
8
|
-
ACTION: 'action' // With action button
|
|
9
|
-
} as const;
|
|
6
|
+
export type SnackbarVariant = 'basic' | 'action';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
|
-
*
|
|
9
|
+
* Available snackbar positions
|
|
13
10
|
*/
|
|
14
|
-
export
|
|
15
|
-
CENTER: 'center',
|
|
16
|
-
START: 'start',
|
|
17
|
-
END: 'end'
|
|
18
|
-
} as const;
|
|
11
|
+
export type SnackbarPosition = 'center' | 'start' | 'end';
|
|
19
12
|
|
|
20
13
|
/**
|
|
21
|
-
*
|
|
14
|
+
* Snackbar visibility states
|
|
22
15
|
*/
|
|
23
|
-
export
|
|
24
|
-
variant: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
enum: Object.values(SNACKBAR_VARIANTS),
|
|
27
|
-
required: false
|
|
28
|
-
},
|
|
29
|
-
position: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
enum: Object.values(SNACKBAR_POSITIONS),
|
|
32
|
-
required: false
|
|
33
|
-
},
|
|
34
|
-
message: {
|
|
35
|
-
type: 'string',
|
|
36
|
-
required: true
|
|
37
|
-
},
|
|
38
|
-
action: {
|
|
39
|
-
type: 'string',
|
|
40
|
-
required: false
|
|
41
|
-
},
|
|
42
|
-
duration: {
|
|
43
|
-
type: 'number',
|
|
44
|
-
required: false
|
|
45
|
-
},
|
|
46
|
-
class: {
|
|
47
|
-
type: 'string',
|
|
48
|
-
required: false
|
|
49
|
-
}
|
|
50
|
-
} as const;
|
|
16
|
+
export type SnackbarState = 'visible' | 'hidden';
|
|
51
17
|
|
|
52
18
|
/**
|
|
53
|
-
*
|
|
19
|
+
* Available snackbar event types
|
|
54
20
|
*/
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
21
|
+
export type SnackbarEventType = 'open' | 'close' | 'action';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Snackbar event data
|
|
25
|
+
* @interface SnackbarEvent
|
|
26
|
+
*/
|
|
27
|
+
export interface SnackbarEvent {
|
|
28
|
+
/** The snackbar component that triggered the event */
|
|
29
|
+
snackbar: SnackbarComponent;
|
|
30
|
+
|
|
31
|
+
/** Original DOM event if available */
|
|
32
|
+
originalEvent: Event | null;
|
|
33
|
+
|
|
34
|
+
/** Function to prevent default behavior */
|
|
35
|
+
preventDefault: () => void;
|
|
36
|
+
|
|
37
|
+
/** Whether default behavior was prevented */
|
|
38
|
+
defaultPrevented: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Configuration options for the snackbar component
|
|
43
|
+
* @interface SnackbarConfig
|
|
44
|
+
*/
|
|
45
|
+
export interface SnackbarConfig {
|
|
46
|
+
/** Visual variant of the snackbar */
|
|
47
|
+
variant?: SnackbarVariant;
|
|
48
|
+
|
|
49
|
+
/** Position of the snackbar on screen */
|
|
50
|
+
position?: SnackbarPosition;
|
|
51
|
+
|
|
52
|
+
/** Text message to display */
|
|
53
|
+
message: string;
|
|
54
|
+
|
|
55
|
+
/** Action button text (for 'action' variant) */
|
|
56
|
+
action?: string;
|
|
57
|
+
|
|
58
|
+
/** Duration in milliseconds to show the snackbar (0 for indefinite) */
|
|
59
|
+
duration?: number;
|
|
60
|
+
|
|
61
|
+
/** Action button callback function */
|
|
62
|
+
onAction?: (event: SnackbarEvent) => void;
|
|
63
|
+
|
|
64
|
+
/** Callback function when the snackbar opens */
|
|
65
|
+
onOpen?: (event: SnackbarEvent) => void;
|
|
66
|
+
|
|
67
|
+
/** Callback function when the snackbar closes */
|
|
68
|
+
onClose?: (event: SnackbarEvent) => void;
|
|
69
|
+
|
|
70
|
+
/** Additional CSS classes */
|
|
71
|
+
class?: string;
|
|
72
|
+
|
|
73
|
+
/** Component prefix for CSS classes */
|
|
74
|
+
prefix?: string;
|
|
75
|
+
|
|
76
|
+
/** Component name for CSS classes */
|
|
77
|
+
componentName?: string;
|
|
78
|
+
|
|
79
|
+
/** Event handlers for snackbar events */
|
|
80
|
+
on?: {
|
|
81
|
+
[key in SnackbarEventType]?: (event: SnackbarEvent) => void;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Snackbar component public API interface
|
|
87
|
+
* @interface SnackbarComponent
|
|
88
|
+
*/
|
|
89
|
+
export interface SnackbarComponent {
|
|
90
|
+
/** The root element of the snackbar */
|
|
91
|
+
element: HTMLElement;
|
|
92
|
+
|
|
93
|
+
/** Current state of the snackbar */
|
|
94
|
+
state: SnackbarState;
|
|
95
|
+
|
|
96
|
+
/** Displays the snackbar */
|
|
97
|
+
show: () => SnackbarComponent;
|
|
98
|
+
|
|
99
|
+
/** Hides the snackbar */
|
|
100
|
+
hide: () => SnackbarComponent;
|
|
101
|
+
|
|
102
|
+
/** Sets the message text */
|
|
103
|
+
setMessage: (message: string) => SnackbarComponent;
|
|
104
|
+
|
|
105
|
+
/** Gets the message text */
|
|
106
|
+
getMessage: () => string;
|
|
107
|
+
|
|
108
|
+
/** Sets the action button text */
|
|
109
|
+
setAction: (text: string) => SnackbarComponent;
|
|
110
|
+
|
|
111
|
+
/** Gets the action button text */
|
|
112
|
+
getAction: () => string;
|
|
113
|
+
|
|
114
|
+
/** Sets the display duration */
|
|
115
|
+
setDuration: (duration: number) => SnackbarComponent;
|
|
116
|
+
|
|
117
|
+
/** Gets the display duration */
|
|
118
|
+
getDuration: () => number;
|
|
119
|
+
|
|
120
|
+
/** Sets the snackbar position */
|
|
121
|
+
setPosition: (position: SnackbarPosition) => SnackbarComponent;
|
|
122
|
+
|
|
123
|
+
/** Gets the snackbar position */
|
|
124
|
+
getPosition: () => SnackbarPosition;
|
|
125
|
+
|
|
126
|
+
/** Adds event listener */
|
|
127
|
+
on: (event: SnackbarEventType, handler: (event: SnackbarEvent) => void) => SnackbarComponent;
|
|
128
|
+
|
|
129
|
+
/** Removes event listener */
|
|
130
|
+
off: (event: SnackbarEventType, handler: (event: SnackbarEvent) => void) => SnackbarComponent;
|
|
131
|
+
|
|
132
|
+
/** Destroys the snackbar component and cleans up resources */
|
|
133
|
+
destroy: () => void;
|
|
134
|
+
}
|
|
@@ -5,13 +5,12 @@ import {
|
|
|
5
5
|
BaseComponentConfig
|
|
6
6
|
} from '../../core/config/component-config';
|
|
7
7
|
import { SwitchConfig, BaseComponent, ApiOptions } from './types';
|
|
8
|
-
import { SWITCH_LABEL_POSITION } from './constants';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Default configuration for the Switch component
|
|
12
11
|
*/
|
|
13
12
|
export const defaultConfig: SwitchConfig = {
|
|
14
|
-
labelPosition:
|
|
13
|
+
labelPosition: 'end'
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -42,7 +41,7 @@ export const getElementConfig = (config: SwitchConfig) =>
|
|
|
42
41
|
export const withLabelPosition = (config: SwitchConfig) => (component: BaseComponent): BaseComponent => {
|
|
43
42
|
if (!config.label) return component;
|
|
44
43
|
|
|
45
|
-
const position = config.labelPosition ||
|
|
44
|
+
const position = config.labelPosition || 'end';
|
|
46
45
|
const positionClass = `${config.prefix}-switch--label-${position}`;
|
|
47
46
|
|
|
48
47
|
component.element.classList.add(positionClass);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/components/switch/types.ts
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
export type SwitchPosition = 'center' | 'start' | 'end';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Configuration interface for the Switch component
|
|
@@ -24,7 +25,7 @@ export interface SwitchConfig {
|
|
|
24
25
|
label?: string;
|
|
25
26
|
|
|
26
27
|
/** Label position (start/end) */
|
|
27
|
-
labelPosition?:
|
|
28
|
+
labelPosition?: SwitchPosition | string;
|
|
28
29
|
|
|
29
30
|
/** Additional CSS classes */
|
|
30
31
|
class?: string;
|
|
@@ -6,13 +6,12 @@ import {
|
|
|
6
6
|
} from '../../core/config/component-config';
|
|
7
7
|
import { withElement } from '../../core/compose/component';
|
|
8
8
|
import { TabConfig } from './types';
|
|
9
|
-
import { TABS_VARIANTS, TAB_STATES } from './constants';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Default configuration for a Tab
|
|
13
12
|
*/
|
|
14
13
|
export const defaultTabConfig: TabConfig = {
|
|
15
|
-
state:
|
|
14
|
+
state: 'inactive',
|
|
16
15
|
componentName: 'tab',
|
|
17
16
|
ripple: true
|
|
18
17
|
};
|
|
@@ -21,7 +20,7 @@ export const defaultTabConfig: TabConfig = {
|
|
|
21
20
|
* Default configuration for the Tabs component
|
|
22
21
|
*/
|
|
23
22
|
export const defaultTabsConfig = {
|
|
24
|
-
variant:
|
|
23
|
+
variant: 'primary',
|
|
25
24
|
scrollable: true,
|
|
26
25
|
showDivider: true,
|
|
27
26
|
componentName: 'tabs'
|
|
@@ -48,7 +47,7 @@ export const getTabsElementConfig = (config) => {
|
|
|
48
47
|
},
|
|
49
48
|
className: [
|
|
50
49
|
`${config.prefix}-tabs`,
|
|
51
|
-
`${config.prefix}-tabs--${config.variant ||
|
|
50
|
+
`${config.prefix}-tabs--${config.variant || 'primary'}`,
|
|
52
51
|
config.class
|
|
53
52
|
]
|
|
54
53
|
};
|
|
@@ -282,12 +282,14 @@ export const withIndicator = <T extends IndicatorFeatureConfig>(config: T) =>
|
|
|
282
282
|
const indicator: TabIndicator = createTabIndicator({
|
|
283
283
|
prefix: config.prefix,
|
|
284
284
|
// Support both new and legacy config
|
|
285
|
-
widthStrategy: indicatorConfig.widthStrategy || config.indicatorWidthStrategy || '
|
|
285
|
+
widthStrategy: indicatorConfig.widthStrategy || config.indicatorWidthStrategy || 'auto', // Changed default to 'auto'
|
|
286
286
|
height: indicatorConfig.height || config.indicatorHeight || 3,
|
|
287
287
|
fixedWidth: indicatorConfig.fixedWidth || 40,
|
|
288
288
|
animationDuration: indicatorConfig.animationDuration || 250,
|
|
289
289
|
animationTiming: indicatorConfig.animationTiming || 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
290
|
-
color: indicatorConfig.color
|
|
290
|
+
color: indicatorConfig.color,
|
|
291
|
+
// Pass the tabs variant to the indicator
|
|
292
|
+
variant: config.variant || 'primary'
|
|
291
293
|
});
|
|
292
294
|
|
|
293
295
|
// Find the scroll container and add the indicator to it
|
|
@@ -7,21 +7,6 @@ import { createTabsState } from './state';
|
|
|
7
7
|
import { createTabIndicator } from './indicator';
|
|
8
8
|
import { updateTabPanels, setupKeyboardNavigation } from './utils';
|
|
9
9
|
|
|
10
|
-
export {
|
|
11
|
-
// Main component creators
|
|
12
|
-
createTabs,
|
|
13
|
-
createTab,
|
|
14
|
-
|
|
15
|
-
// Constants
|
|
16
|
-
TABS_VARIANTS,
|
|
17
|
-
TAB_STATES,
|
|
18
|
-
TAB_LAYOUT,
|
|
19
|
-
TAB_INTERACTION_STATES,
|
|
20
|
-
TAB_ANIMATION,
|
|
21
|
-
TAB_A11Y,
|
|
22
|
-
TAB_COLORS
|
|
23
|
-
} from './constants';
|
|
24
|
-
|
|
25
10
|
export {
|
|
26
11
|
// Types
|
|
27
12
|
TabsConfig,
|