mtrl 0.2.7 → 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/package.json +14 -3
- package/server.ts +86 -0
- package/src/components/badge/api.ts +23 -14
- package/src/components/badge/badge.ts +2 -2
- package/src/components/badge/config.ts +10 -11
- package/src/components/badge/features.ts +15 -10
- package/src/components/badge/index.ts +27 -2
- package/src/components/badge/types.ts +28 -8
- package/src/components/bottom-app-bar/bottom-app-bar.ts +2 -44
- package/src/components/bottom-app-bar/config.ts +1 -45
- package/src/components/bottom-app-bar/index.ts +7 -1
- package/src/components/bottom-app-bar/types.ts +7 -1
- package/src/components/button/button.ts +0 -1
- package/src/components/button/config.ts +1 -2
- package/src/components/button/index.ts +10 -2
- package/src/components/button/types.ts +14 -2
- package/src/components/card/config.ts +17 -9
- package/src/components/card/content.ts +8 -10
- package/src/components/card/features.ts +4 -6
- package/src/components/card/index.ts +29 -2
- package/src/components/card/types.ts +6 -23
- 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 +18 -25
- package/src/components/datepicker/config.ts +9 -12
- package/src/components/datepicker/datepicker.ts +7 -12
- package/src/components/datepicker/index.ts +10 -7
- package/src/components/datepicker/render.ts +16 -18
- package/src/components/datepicker/types.ts +164 -35
- package/src/components/datepicker/utils.ts +1 -2
- package/src/components/dialog/api.ts +7 -8
- package/src/components/dialog/config.ts +3 -4
- package/src/components/dialog/features.ts +56 -22
- package/src/components/dialog/index.ts +38 -8
- package/src/components/dialog/types.ts +33 -10
- package/src/components/divider/index.ts +5 -1
- package/src/components/extended-fab/config.ts +6 -2
- package/src/components/extended-fab/index.ts +7 -2
- package/src/components/extended-fab/types.ts +21 -4
- package/src/components/fab/config.ts +3 -4
- package/src/components/fab/fab.ts +1 -1
- package/src/components/fab/index.ts +7 -2
- package/src/components/fab/types.ts +21 -4
- 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/config.ts +22 -10
- package/src/components/navigation/features/items.ts +31 -27
- package/src/components/navigation/index.ts +0 -6
- package/src/components/navigation/nav-item.ts +12 -24
- package/src/components/navigation/navigation.ts +4 -6
- package/src/components/navigation/types.ts +228 -203
- 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/config.ts +1 -2
- package/src/components/search/features/search.ts +14 -15
- package/src/components/search/features/states.ts +5 -1
- package/src/components/search/features/structure.ts +3 -4
- package/src/components/search/index.ts +0 -3
- package/src/components/search/types.ts +18 -6
- package/src/components/segmented-button/config.ts +20 -7
- package/src/components/segmented-button/segment.ts +6 -7
- package/src/components/segmented-button/segmented-button.ts +4 -5
- package/src/components/segmented-button/types.ts +37 -2
- package/src/components/slider/types.ts +34 -8
- 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/index.ts +0 -15
- package/src/components/tabs/tab-api.ts +12 -4
- package/src/components/tabs/tab.ts +18 -6
- package/src/components/tabs/types.ts +13 -3
- 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/api.ts +1 -1
- package/src/components/timepicker/clockdial.ts +1 -1
- package/src/components/timepicker/config.ts +102 -4
- package/src/components/timepicker/index.ts +1 -6
- package/src/components/timepicker/render.ts +1 -1
- package/src/components/timepicker/timepicker.ts +1 -1
- 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/core/compose/features/textlabel.ts +0 -3
- package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +1 -1
- package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
- package/src/styles/main.scss +98 -49
- package/src/components/badge/constants.ts +0 -40
- package/src/components/button/constants.ts +0 -11
- package/src/components/card/constants.ts +0 -84
- package/src/components/datepicker/constants.ts +0 -98
- package/src/components/dialog/constants.ts +0 -32
- package/src/components/extended-fab/constants.ts +0 -36
- package/src/components/fab/constants.ts +0 -41
- package/src/components/menu/constants.ts +0 -154
- package/src/components/navigation/constants.ts +0 -200
- package/src/components/progress/constants.ts +0 -29
- package/src/components/search/constants.ts +0 -21
- package/src/components/segmented-button/constants.ts +0 -42
- package/src/components/switch/constants.ts +0 -80
- package/src/components/tabs/constants.ts +0 -89
- package/src/components/timepicker/constants.ts +0 -138
- /package/src/{components/badge/_styles.scss → styles/components/_badge.scss} +0 -0
- /package/src/{components/bottom-app-bar/_styles.scss → styles/components/_bottom-app-bar.scss} +0 -0
- /package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -0
- /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/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -0
- /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
- /package/src/{components/datepicker/_styles.scss → styles/components/_datepicker.scss} +0 -0
- /package/src/{components/dialog/_styles.scss → styles/components/_dialog.scss} +0 -0
- /package/src/{components/divider/_styles.scss → styles/components/_divider.scss} +0 -0
- /package/src/{components/extended-fab/_styles.scss → styles/components/_extended-fab.scss} +0 -0
- /package/src/{components/fab/_styles.scss → styles/components/_fab.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/navigation/_styles.scss → styles/components/_navigation.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/search/_styles.scss → styles/components/_search.scss} +0 -0
- /package/src/{components/segmented-button/_styles.scss → styles/components/_segmented-button.scss} +0 -0
- /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
- /package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +0 -0
- /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
- /package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -0
- /package/src/{components/timepicker/_styles.scss → styles/components/_timepicker.scss} +0 -0
- /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
- /package/src/{components/top-app-bar/_styles.scss → styles/components/_top-app-bar.scss} +0 -0
- /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { createElement } from '../../core/dom/create';
|
|
3
3
|
import { createRipple } from '../../core/build/ripple';
|
|
4
4
|
import { SegmentConfig, Segment } from './types';
|
|
5
|
-
import { DEFAULT_CHECKMARK_ICON, CLASSES } from './constants';
|
|
6
5
|
import { getSegmentConfig } from './config';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -40,7 +39,7 @@ export const createSegment = (
|
|
|
40
39
|
if (config.text) {
|
|
41
40
|
textElement = createElement({
|
|
42
41
|
tag: 'span',
|
|
43
|
-
className: `${prefix}
|
|
42
|
+
className: `${prefix}-segmentedbutton-segment-text`,
|
|
44
43
|
text: config.text,
|
|
45
44
|
container: element
|
|
46
45
|
});
|
|
@@ -52,7 +51,7 @@ export const createSegment = (
|
|
|
52
51
|
// Create icon element
|
|
53
52
|
iconElement = createElement({
|
|
54
53
|
tag: 'span',
|
|
55
|
-
className: `${prefix}
|
|
54
|
+
className: `${prefix}-segmentedbutton-segment-icon`,
|
|
56
55
|
html: config.icon,
|
|
57
56
|
container: element
|
|
58
57
|
});
|
|
@@ -60,8 +59,8 @@ export const createSegment = (
|
|
|
60
59
|
// Create checkmark element (hidden initially)
|
|
61
60
|
checkmarkElement = createElement({
|
|
62
61
|
tag: 'span',
|
|
63
|
-
className: `${prefix}
|
|
64
|
-
html:
|
|
62
|
+
className: `${prefix}-segmentedbutton-segment-'checkmark'`,
|
|
63
|
+
html: 'icon',
|
|
65
64
|
container: element
|
|
66
65
|
});
|
|
67
66
|
|
|
@@ -82,7 +81,7 @@ export const createSegment = (
|
|
|
82
81
|
* @private
|
|
83
82
|
*/
|
|
84
83
|
const updateSelectedState = (selected: boolean) => {
|
|
85
|
-
element.classList.toggle(`${prefix}
|
|
84
|
+
element.classList.toggle(`${prefix}-segmentedbutton-segment--selected`, selected);
|
|
86
85
|
element.setAttribute('aria-pressed', selected ? 'true' : 'false');
|
|
87
86
|
|
|
88
87
|
// Handle icon/checkmark swap if we have both text and icon
|
|
@@ -102,7 +101,7 @@ export const createSegment = (
|
|
|
102
101
|
*/
|
|
103
102
|
const updateDisabledState = (disabled: boolean) => {
|
|
104
103
|
const isDisabled = disabled || groupDisabled;
|
|
105
|
-
element.classList.toggle(`${prefix}
|
|
104
|
+
element.classList.toggle(`${prefix}-segmentedbutton-segment--disabled`, isDisabled);
|
|
106
105
|
|
|
107
106
|
if (isDisabled) {
|
|
108
107
|
element.setAttribute('disabled', 'true');
|
|
@@ -6,7 +6,6 @@ import { createEmitter } from '../../core/state/emitter';
|
|
|
6
6
|
import { SegmentedButtonConfig, SegmentedButtonComponent, SelectionMode, Segment } from './types';
|
|
7
7
|
import { createBaseConfig, getContainerConfig } from './config';
|
|
8
8
|
import { createSegment } from './segment';
|
|
9
|
-
import { EVENTS } from './constants';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Creates a new Segmented Button component
|
|
@@ -91,7 +90,7 @@ const createSegmentedButton = (config: SegmentedButtonConfig = {}): SegmentedBut
|
|
|
91
90
|
oldValue.some(v => !newValue.includes(v)) ||
|
|
92
91
|
newValue.some(v => !oldValue.includes(v))
|
|
93
92
|
) {
|
|
94
|
-
emitter.emit(
|
|
93
|
+
emitter.emit('change', {
|
|
95
94
|
selected: getSelected(),
|
|
96
95
|
value: newValue,
|
|
97
96
|
oldValue
|
|
@@ -153,7 +152,7 @@ const createSegmentedButton = (config: SegmentedButtonConfig = {}): SegmentedBut
|
|
|
153
152
|
// Emit change event
|
|
154
153
|
const newValue = getSelectedValues();
|
|
155
154
|
if (oldValue.join(',') !== newValue.join(',')) {
|
|
156
|
-
emitter.emit(
|
|
155
|
+
emitter.emit('change', {
|
|
157
156
|
selected: getSelected(),
|
|
158
157
|
value: newValue,
|
|
159
158
|
oldValue
|
|
@@ -177,7 +176,7 @@ const createSegmentedButton = (config: SegmentedButtonConfig = {}): SegmentedBut
|
|
|
177
176
|
// Emit change event
|
|
178
177
|
const newValue = getSelectedValues();
|
|
179
178
|
if (oldValue.join(',') !== newValue.join(',')) {
|
|
180
|
-
emitter.emit(
|
|
179
|
+
emitter.emit('change', {
|
|
181
180
|
selected: getSelected(),
|
|
182
181
|
value: newValue,
|
|
183
182
|
oldValue
|
|
@@ -192,7 +191,7 @@ const createSegmentedButton = (config: SegmentedButtonConfig = {}): SegmentedBut
|
|
|
192
191
|
// Emit change event
|
|
193
192
|
const newValue = getSelectedValues();
|
|
194
193
|
if (oldValue.join(',') !== newValue.join(',')) {
|
|
195
|
-
emitter.emit(
|
|
194
|
+
emitter.emit('change', {
|
|
196
195
|
selected: getSelected(),
|
|
197
196
|
value: newValue,
|
|
198
197
|
oldValue
|
|
@@ -11,6 +11,34 @@ export enum SelectionMode {
|
|
|
11
11
|
MULTI = 'multi'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Event types for segmented button
|
|
16
|
+
*/
|
|
17
|
+
export type SegmentedButtonEventType = 'change';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Event data for segmented button events
|
|
21
|
+
*/
|
|
22
|
+
export interface SegmentedButtonEvent {
|
|
23
|
+
/** The segmented button component that triggered the event */
|
|
24
|
+
segmentedButton: SegmentedButtonComponent;
|
|
25
|
+
|
|
26
|
+
/** The selected segments */
|
|
27
|
+
selected: Segment[];
|
|
28
|
+
|
|
29
|
+
/** Values of the selected segments */
|
|
30
|
+
values: string[];
|
|
31
|
+
|
|
32
|
+
/** Original DOM event if available */
|
|
33
|
+
originalEvent: Event | null;
|
|
34
|
+
|
|
35
|
+
/** Function to prevent default behavior */
|
|
36
|
+
preventDefault: () => void;
|
|
37
|
+
|
|
38
|
+
/** Whether default behavior was prevented */
|
|
39
|
+
defaultPrevented: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
14
42
|
/**
|
|
15
43
|
* Configuration for a single segment within a segmented button
|
|
16
44
|
* @category Components
|
|
@@ -106,6 +134,13 @@ export interface SegmentedButtonConfig {
|
|
|
106
134
|
/** Opacity values for ripple start and end [start, end] */
|
|
107
135
|
opacity?: [string, string];
|
|
108
136
|
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Event handlers for segmented button events
|
|
140
|
+
*/
|
|
141
|
+
on?: {
|
|
142
|
+
[key in SegmentedButtonEventType]?: (event: SegmentedButtonEvent) => void;
|
|
143
|
+
};
|
|
109
144
|
}
|
|
110
145
|
|
|
111
146
|
/**
|
|
@@ -202,7 +237,7 @@ export interface SegmentedButtonComponent {
|
|
|
202
237
|
* @param handler - Event handler function
|
|
203
238
|
* @returns The SegmentedButtonComponent for chaining
|
|
204
239
|
*/
|
|
205
|
-
on: (event:
|
|
240
|
+
on: (event: SegmentedButtonEventType, handler: (event: SegmentedButtonEvent) => void) => SegmentedButtonComponent;
|
|
206
241
|
|
|
207
242
|
/**
|
|
208
243
|
* Removes an event listener from the segmented button
|
|
@@ -210,7 +245,7 @@ export interface SegmentedButtonComponent {
|
|
|
210
245
|
* @param handler - Event handler function
|
|
211
246
|
* @returns The SegmentedButtonComponent for chaining
|
|
212
247
|
*/
|
|
213
|
-
off: (event:
|
|
248
|
+
off: (event: SegmentedButtonEventType, handler: (event: SegmentedButtonEvent) => void) => SegmentedButtonComponent;
|
|
214
249
|
|
|
215
250
|
/**
|
|
216
251
|
* Destroys the component and cleans up resources
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
// src/components/slider/types.ts
|
|
2
|
-
import { SLIDER_COLORS, SLIDER_SIZES, SLIDER_EVENTS } from './constants';
|
|
3
2
|
|
|
3
|
+
/**
|
|
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
|
|
21
|
+
*/
|
|
4
22
|
export interface SliderConfig {
|
|
5
23
|
/** Minimum value of the slider */
|
|
6
24
|
min?: number;
|
|
@@ -21,10 +39,10 @@ export interface SliderConfig {
|
|
|
21
39
|
disabled?: boolean;
|
|
22
40
|
|
|
23
41
|
/** Color variant of the slider */
|
|
24
|
-
color?:
|
|
42
|
+
color?: SliderColor;
|
|
25
43
|
|
|
26
44
|
/** Size variant of the slider */
|
|
27
|
-
size?:
|
|
45
|
+
size?: SliderSize;
|
|
28
46
|
|
|
29
47
|
/** Whether to show tick marks */
|
|
30
48
|
ticks?: boolean;
|
|
@@ -58,10 +76,14 @@ export interface SliderConfig {
|
|
|
58
76
|
|
|
59
77
|
/** Event handlers for slider events */
|
|
60
78
|
on?: {
|
|
61
|
-
[key in
|
|
79
|
+
[key in SliderEventType]?: (event: SliderEvent) => void;
|
|
62
80
|
};
|
|
63
81
|
}
|
|
64
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Slider event data
|
|
85
|
+
* @interface SliderEvent
|
|
86
|
+
*/
|
|
65
87
|
export interface SliderEvent {
|
|
66
88
|
/** The slider component that triggered the event */
|
|
67
89
|
slider: any;
|
|
@@ -82,6 +104,10 @@ export interface SliderEvent {
|
|
|
82
104
|
defaultPrevented: boolean;
|
|
83
105
|
}
|
|
84
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Slider component public API interface
|
|
109
|
+
* @interface SliderComponent
|
|
110
|
+
*/
|
|
85
111
|
export interface SliderComponent {
|
|
86
112
|
/** The root element of the slider */
|
|
87
113
|
element: HTMLElement;
|
|
@@ -126,13 +152,13 @@ export interface SliderComponent {
|
|
|
126
152
|
isDisabled: () => boolean;
|
|
127
153
|
|
|
128
154
|
/** Sets slider color */
|
|
129
|
-
setColor: (color:
|
|
155
|
+
setColor: (color: SliderColor) => SliderComponent;
|
|
130
156
|
|
|
131
157
|
/** Gets slider color */
|
|
132
158
|
getColor: () => string;
|
|
133
159
|
|
|
134
160
|
/** Sets slider size */
|
|
135
|
-
setSize: (size:
|
|
161
|
+
setSize: (size: SliderSize) => SliderComponent;
|
|
136
162
|
|
|
137
163
|
/** Gets slider size */
|
|
138
164
|
getSize: () => string;
|
|
@@ -156,10 +182,10 @@ export interface SliderComponent {
|
|
|
156
182
|
getIcon: () => string;
|
|
157
183
|
|
|
158
184
|
/** Adds event listener */
|
|
159
|
-
on: (event:
|
|
185
|
+
on: (event: SliderEventType, handler: (event: SliderEvent) => void) => SliderComponent;
|
|
160
186
|
|
|
161
187
|
/** Removes event listener */
|
|
162
|
-
off: (event:
|
|
188
|
+
off: (event: SliderEventType, handler: (event: SliderEvent) => void) => SliderComponent;
|
|
163
189
|
|
|
164
190
|
/** Destroys the slider component and cleans up resources */
|
|
165
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
|
};
|
|
@@ -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,
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
// src/components/tabs/tab-api.ts
|
|
2
2
|
import { TabComponent } from './types';
|
|
3
|
-
import { TAB_STATES, TAB_LAYOUT } from './constants';
|
|
4
3
|
import { BadgeComponent } from '../badge/types';
|
|
5
4
|
import createBadge from '../badge';
|
|
6
5
|
|
|
6
|
+
const TAB_LAYOUT = {
|
|
7
|
+
/** Icon-only tab layout */
|
|
8
|
+
ICON_ONLY: 'icon-only',
|
|
9
|
+
/** Text-only tab layout */
|
|
10
|
+
TEXT_ONLY: 'text-only',
|
|
11
|
+
/** Icon and text layout */
|
|
12
|
+
ICON_AND_TEXT: 'icon-and-text'
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* API options for a Tab component
|
|
9
17
|
*/
|
|
@@ -82,7 +90,7 @@ export const withTabAPI = ({ disabled, lifecycle, button }: ApiOptions) =>
|
|
|
82
90
|
* Activates the tab
|
|
83
91
|
*/
|
|
84
92
|
activate() {
|
|
85
|
-
component.element.classList.add(`${component.getClass('tab')}
|
|
93
|
+
component.element.classList.add(`${component.getClass('tab')}--active`);
|
|
86
94
|
component.element.setAttribute('aria-selected', 'true');
|
|
87
95
|
return this;
|
|
88
96
|
},
|
|
@@ -91,7 +99,7 @@ export const withTabAPI = ({ disabled, lifecycle, button }: ApiOptions) =>
|
|
|
91
99
|
* Deactivates the tab
|
|
92
100
|
*/
|
|
93
101
|
deactivate() {
|
|
94
|
-
component.element.classList.remove(`${component.getClass('tab')}
|
|
102
|
+
component.element.classList.remove(`${component.getClass('tab')}--active`);
|
|
95
103
|
component.element.setAttribute('aria-selected', 'false');
|
|
96
104
|
return this;
|
|
97
105
|
},
|
|
@@ -100,7 +108,7 @@ export const withTabAPI = ({ disabled, lifecycle, button }: ApiOptions) =>
|
|
|
100
108
|
* Checks if the tab is active
|
|
101
109
|
*/
|
|
102
110
|
isActive() {
|
|
103
|
-
return component.element.classList.contains(`${component.getClass('tab')}
|
|
111
|
+
return component.element.classList.contains(`${component.getClass('tab')}--active`);
|
|
104
112
|
},
|
|
105
113
|
|
|
106
114
|
/**
|