mtrl 0.2.7 → 0.2.9
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/index.ts +2 -0
- package/package.json +14 -3
- 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/api.ts +131 -96
- package/src/components/navigation/config.ts +22 -10
- package/src/components/navigation/features/controller.ts +273 -0
- package/src/components/navigation/features/items.ts +160 -87
- package/src/components/navigation/index.ts +0 -6
- package/src/components/navigation/nav-item.ts +12 -24
- package/src/components/navigation/navigation.ts +21 -8
- package/src/components/navigation/system-types.ts +124 -0
- package/src/components/navigation/system.ts +776 -0
- 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/config.ts +20 -2
- package/src/components/slider/features/controller.ts +761 -0
- package/src/components/slider/features/handlers.ts +18 -15
- package/src/components/slider/features/index.ts +3 -2
- package/src/components/slider/features/range.ts +104 -0
- package/src/components/slider/slider.ts +34 -14
- package/src/components/slider/structure.ts +152 -0
- 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/api.ts +53 -0
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/features.ts +322 -0
- package/src/components/textfield/index.ts +0 -1
- package/src/components/textfield/textfield.ts +8 -0
- package/src/components/textfield/types.ts +29 -6
- package/src/components/timepicker/api.ts +1 -1
- package/src/components/timepicker/clockdial.ts +2 -5
- 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/textinput.ts +15 -2
- package/src/core/compose/features/textlabel.ts +0 -3
- package/src/core/composition/features/dom.ts +33 -0
- package/src/core/composition/features/icon.ts +131 -0
- package/src/core/composition/features/index.ts +11 -0
- package/src/core/composition/features/label.ts +156 -0
- package/src/core/composition/features/structure.ts +22 -0
- package/src/core/composition/index.ts +26 -0
- package/src/core/index.ts +1 -1
- package/src/core/structure.ts +288 -0
- package/src/index.ts +1 -0
- package/src/styles/components/_navigation-mobile.scss +244 -0
- package/src/styles/components/_navigation-system.scss +151 -0
- package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +1 -1
- package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +314 -72
- 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/slider/features/slider.ts +0 -318
- package/src/components/slider/features/structure.ts +0 -181
- package/src/components/slider/features/ui.ts +0 -388
- package/src/components/switch/constants.ts +0 -80
- package/src/components/tabs/constants.ts +0 -89
- package/src/components/textfield/constants.ts +0 -100
- 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
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from '../../core/config/component-config';
|
|
6
6
|
import { SliderConfig } from './types';
|
|
7
7
|
import { SLIDER_COLORS, SLIDER_SIZES } from './constants';
|
|
8
|
+
import { createSliderDefinition } from './structure';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Default configuration for the Slider component
|
|
@@ -31,8 +32,25 @@ export const defaultConfig: SliderConfig = {
|
|
|
31
32
|
* @param {SliderConfig} config - User provided configuration
|
|
32
33
|
* @returns {SliderConfig} Complete configuration with defaults applied
|
|
33
34
|
*/
|
|
34
|
-
export const createBaseConfig = (config: SliderConfig = {}): SliderConfig =>
|
|
35
|
-
|
|
35
|
+
export const createBaseConfig = (config: SliderConfig = {}): SliderConfig => {
|
|
36
|
+
// Create the base config with defaults applied
|
|
37
|
+
const baseConfig = createComponentConfig(defaultConfig, config, 'slider') as SliderConfig;
|
|
38
|
+
|
|
39
|
+
// Create a basic component object for structure generation
|
|
40
|
+
const baseComponent = {
|
|
41
|
+
componentName: 'slider',
|
|
42
|
+
config: baseConfig,
|
|
43
|
+
getClass: (className) => {
|
|
44
|
+
const prefix = baseConfig.prefix || 'mtrl';
|
|
45
|
+
return `${prefix}-${className}`;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Add the structure definition to the config
|
|
50
|
+
baseConfig.structureDefinition = createSliderDefinition(baseComponent, baseConfig);
|
|
51
|
+
|
|
52
|
+
return baseConfig;
|
|
53
|
+
};
|
|
36
54
|
|
|
37
55
|
/**
|
|
38
56
|
* Generates element configuration for the Slider component
|