mtrl 0.3.1 → 0.3.2
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/.env +15 -0
- package/CONTRIBUTING.md +8 -8
- package/DOCS.md +3 -3
- package/README.md +43 -20
- package/TESTING.md +128 -18
- package/dist/index.js +14865 -0
- package/git-user-stats.js +545 -0
- package/index.ts +9 -67
- package/package.json +8 -3
- package/src/components/badge/api.ts +15 -1
- package/src/components/badge/badge.ts +43 -4
- package/src/components/badge/config.ts +40 -8
- package/src/components/badge/index.ts +64 -3
- package/src/components/badge/types.ts +175 -33
- package/src/components/button/api.ts +63 -1
- package/src/components/button/button.ts +39 -3
- package/src/components/button/config.ts +21 -4
- package/src/components/button/index.ts +26 -1
- package/src/components/button/types.ts +7 -1
- package/src/components/card/api.ts +78 -9
- package/src/components/card/card.ts +58 -3
- package/src/components/card/config.ts +41 -11
- package/src/components/card/features.ts +39 -12
- package/src/components/card/index.ts +84 -19
- package/src/components/card/types.ts +218 -29
- package/src/components/carousel/carousel.ts +92 -28
- package/src/components/carousel/constants.ts +107 -21
- package/src/components/carousel/index.ts +31 -13
- package/src/components/checkbox/checkbox.ts +83 -16
- package/src/components/checkbox/index.ts +43 -1
- package/src/components/checkbox/types.ts +219 -32
- package/src/components/chips/api.ts +194 -0
- package/src/components/{chip → chips/chip}/api.ts +42 -2
- package/src/components/chips/chip/chip.ts +131 -0
- package/src/components/{chip → chips/chip}/config.ts +3 -3
- package/src/components/chips/chip/index.ts +3 -0
- package/src/components/chips/chips.md +481 -0
- package/src/components/chips/chips.ts +75 -0
- package/src/components/chips/config.ts +109 -0
- package/src/components/chips/constants.ts +61 -0
- package/src/components/chips/features/chip-items.ts +33 -0
- package/src/components/chips/features/container.ts +77 -0
- package/src/components/chips/features/controller.ts +448 -0
- package/src/components/chips/features/index.ts +5 -0
- package/src/components/chips/features/label.ts +108 -0
- package/src/components/chips/index.ts +11 -0
- package/src/components/chips/schema.ts +61 -0
- package/src/components/{chip → chips}/types.ts +203 -92
- package/src/components/dialog/dialog.ts +99 -16
- package/src/components/dialog/index.ts +97 -1
- package/src/components/dialog/types.ts +375 -69
- package/src/components/divider/config.ts +90 -6
- package/src/components/divider/divider.ts +32 -2
- package/src/components/divider/features.ts +26 -0
- package/src/components/divider/index.ts +30 -0
- package/src/components/divider/types.ts +86 -9
- package/src/components/extended-fab/api.ts +53 -1
- package/src/components/extended-fab/config.ts +29 -1
- package/src/components/extended-fab/extended-fab.ts +28 -0
- package/src/components/extended-fab/index.ts +36 -0
- package/src/components/extended-fab/types.ts +458 -13
- package/src/components/fab/api.ts +42 -2
- package/src/components/fab/config.ts +29 -1
- package/src/components/fab/fab.ts +16 -2
- package/src/components/fab/index.ts +35 -0
- package/src/components/fab/types.ts +374 -10
- package/src/components/list/api.ts +12 -2
- package/src/components/list/config.ts +21 -0
- package/src/components/list/features.ts +6 -0
- package/src/components/list/index.ts +56 -1
- package/src/components/list/list-item.ts +46 -2
- package/src/components/list/list.ts +73 -2
- package/src/components/list/types.ts +172 -0
- package/src/components/list/utils.ts +26 -2
- package/src/components/menu/api.ts +217 -20
- package/src/components/menu/config.ts +27 -0
- package/src/components/menu/features/visibility.ts +55 -6
- package/src/components/menu/index.ts +64 -0
- package/src/components/menu/menu-item.ts +46 -3
- package/src/components/menu/menu.ts +77 -1
- package/src/components/menu/types.ts +404 -39
- package/src/components/sheet/config.ts +1 -2
- package/src/components/sheet/features/gestures.ts +1 -1
- package/src/components/sheet/features/position.ts +1 -2
- package/src/components/sheet/features/state.ts +1 -1
- package/src/components/sheet/index.ts +10 -2
- package/src/components/sheet/sheet.ts +1 -2
- package/src/components/sheet/types.ts +29 -1
- package/src/components/slider/api.ts +1 -1
- package/src/components/slider/config.ts +1 -1
- package/src/components/slider/features/controller.ts +1 -1
- package/src/components/slider/features/handlers.ts +1 -1
- package/src/components/slider/features/states.ts +1 -1
- package/src/components/slider/index.ts +12 -5
- package/src/components/slider/schema.ts +1 -1
- package/src/components/slider/types.ts +31 -0
- package/src/components/tabs/tab-api.ts +1 -1
- package/src/components/tabs/types.ts +1 -1
- package/src/components/tooltip/api.ts +6 -2
- package/src/components/tooltip/config.ts +9 -28
- package/src/components/tooltip/index.ts +10 -1
- package/src/components/tooltip/types.ts +38 -3
- package/src/index.ts +129 -31
- package/src/styles/abstract/_mixins.scss +23 -9
- package/src/styles/abstract/_variables.scss +14 -4
- package/src/styles/components/_card.scss +1 -1
- package/src/styles/components/_chip.scss +323 -113
- package/src/styles/components/_tabs.scss +1 -1
- package/CLAUDE.md +0 -33
- package/src/components/checkbox/constants.ts +0 -37
- package/src/components/chip/chip-set.ts +0 -225
- package/src/components/chip/chip.ts +0 -118
- package/src/components/chip/constants.ts +0 -28
- package/src/components/chip/index.ts +0 -12
- package/src/components/list/constants.ts +0 -116
- package/src/components/sheet/constants.ts +0 -20
- package/src/components/slider/constants.ts +0 -32
- package/src/components/tooltip/constants.ts +0 -27
- package/test/components/badge.test.ts +0 -545
- package/test/components/bottom-app-bar.test.ts +0 -303
- package/test/components/button.test.ts +0 -233
- package/test/components/card.test.ts +0 -560
- package/test/components/carousel.test.ts +0 -951
- package/test/components/checkbox.test.ts +0 -462
- package/test/components/chip.test.ts +0 -692
- package/test/components/datepicker.test.ts +0 -1124
- package/test/components/dialog.test.ts +0 -990
- package/test/components/divider.test.ts +0 -412
- package/test/components/extended-fab.test.ts +0 -672
- package/test/components/fab.test.ts +0 -561
- package/test/components/list.test.ts +0 -365
- package/test/components/menu.test.ts +0 -718
- package/test/components/navigation.test.ts +0 -186
- package/test/components/progress.test.ts +0 -567
- package/test/components/radios.test.ts +0 -699
- package/test/components/search.test.ts +0 -1135
- package/test/components/segmented-button.test.ts +0 -732
- package/test/components/sheet.test.ts +0 -641
- package/test/components/slider.test.ts +0 -1220
- package/test/components/snackbar.test.ts +0 -461
- package/test/components/switch.test.ts +0 -452
- package/test/components/tabs.test.ts +0 -1369
- package/test/components/textfield.test.ts +0 -400
- package/test/components/timepicker.test.ts +0 -592
- package/test/components/tooltip.test.ts +0 -630
- package/test/components/top-app-bar.test.ts +0 -566
- package/test/core/dom.attributes.test.ts +0 -148
- package/test/core/dom.classes.test.ts +0 -152
- package/test/core/dom.events.test.ts +0 -243
- package/test/core/emitter.test.ts +0 -141
- package/test/core/ripple.test.ts +0 -99
- package/test/core/state.store.test.ts +0 -189
- package/test/core/utils.normalize.test.ts +0 -61
- package/test/core/utils.object.test.ts +0 -120
- package/test/setup.js +0 -371
- package/test/setup.ts +0 -451
- package/tsconfig.json +0 -22
- package/typedoc.json +0 -28
- package/typedoc.simple.json +0 -14
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/components/chips/config.ts
|
|
2
|
+
import {
|
|
3
|
+
createComponentConfig,
|
|
4
|
+
createElementConfig
|
|
5
|
+
} from '../../core/config/component-config';
|
|
6
|
+
import { ChipsConfig } from './types';
|
|
7
|
+
import { createChipsSchema } from './schema';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Default configuration for the Chips component
|
|
11
|
+
*/
|
|
12
|
+
export const defaultConfig: ChipsConfig = {
|
|
13
|
+
chips: [],
|
|
14
|
+
scrollable: false,
|
|
15
|
+
vertical: false,
|
|
16
|
+
multiSelect: false,
|
|
17
|
+
onChange: null,
|
|
18
|
+
selector: null,
|
|
19
|
+
labelPosition: 'start'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates the base configuration for Chips component
|
|
24
|
+
* @param {ChipsConfig} config - User provided configuration
|
|
25
|
+
* @returns {ChipsConfig} Complete configuration with defaults applied
|
|
26
|
+
*/
|
|
27
|
+
export const createBaseConfig = (config: ChipsConfig = {}): ChipsConfig => {
|
|
28
|
+
// Create the base config with defaults applied
|
|
29
|
+
const baseConfig = createComponentConfig(defaultConfig, config, 'chips') as ChipsConfig;
|
|
30
|
+
|
|
31
|
+
// Create a basic component object for structure generation
|
|
32
|
+
const baseComponent = {
|
|
33
|
+
componentName: 'chips',
|
|
34
|
+
config: baseConfig,
|
|
35
|
+
getClass: (className) => {
|
|
36
|
+
const prefix = baseConfig.prefix || 'mtrl';
|
|
37
|
+
return className ? `${prefix}-${className}` : prefix;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Add the structure definition to the config
|
|
42
|
+
baseConfig.schema = createChipsSchema(baseComponent, baseConfig);
|
|
43
|
+
|
|
44
|
+
return baseConfig;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generates element configuration for the Chips component
|
|
49
|
+
* @param {ChipsConfig} config - Chips configuration
|
|
50
|
+
* @returns {Object} Element configuration object for withElement
|
|
51
|
+
*/
|
|
52
|
+
export const getElementConfig = (config: ChipsConfig) =>
|
|
53
|
+
createElementConfig(config, {
|
|
54
|
+
tag: 'div',
|
|
55
|
+
attrs: {
|
|
56
|
+
tabindex: '0',
|
|
57
|
+
role: 'group',
|
|
58
|
+
'aria-multiselectable': config.multiSelect === true ? 'true' : 'false'
|
|
59
|
+
},
|
|
60
|
+
className: [
|
|
61
|
+
config.class
|
|
62
|
+
].filter(Boolean)
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates API configuration for the Chips component
|
|
67
|
+
* @param {Object} comp - Component with chips features
|
|
68
|
+
* @returns {Object} API configuration object
|
|
69
|
+
*/
|
|
70
|
+
export const getApiConfig = (comp) => ({
|
|
71
|
+
chips: {
|
|
72
|
+
addChip: function(chipConfig) {
|
|
73
|
+
if (comp.chips && typeof comp.chips.addChip === 'function') {
|
|
74
|
+
return comp.chips.addChip(chipConfig);
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
},
|
|
78
|
+
removeChip: (chipOrIndex) => comp.chips?.removeChip?.(chipOrIndex),
|
|
79
|
+
getChips: () => comp.chips?.getChips?.() ?? [],
|
|
80
|
+
getSelectedChips: () => comp.chips?.getSelectedChips?.() ?? [],
|
|
81
|
+
getSelectedValues: () => comp.chips?.getSelectedValues?.() ?? [],
|
|
82
|
+
selectByValue: (values) => comp.chips?.selectByValue?.(values),
|
|
83
|
+
clearSelection: () => comp.chips?.clearSelection?.(),
|
|
84
|
+
scrollToChip: (chipOrIndex) => comp.chips?.scrollToChip?.(chipOrIndex)
|
|
85
|
+
},
|
|
86
|
+
layout: {
|
|
87
|
+
setScrollable: (isScrollable) => comp.layout?.setScrollable?.(isScrollable),
|
|
88
|
+
isScrollable: () => comp.layout?.isScrollable?.() ?? false,
|
|
89
|
+
setVertical: (isVertical) => comp.layout?.setVertical?.(isVertical),
|
|
90
|
+
isVertical: () => comp.layout?.isVertical?.() ?? false
|
|
91
|
+
},
|
|
92
|
+
label: {
|
|
93
|
+
setText: (t) => comp.label?.setText?.(t),
|
|
94
|
+
getText: () => comp.label?.getText?.() ?? '',
|
|
95
|
+
setPosition: (p) => comp.label?.setPosition?.(p),
|
|
96
|
+
getPosition: () => comp.label?.getPosition?.() ?? 'start'
|
|
97
|
+
},
|
|
98
|
+
keyboard: {
|
|
99
|
+
enableKeyboardNavigation: () => comp.keyboard?.enable?.(),
|
|
100
|
+
disableKeyboardNavigation: () => comp.keyboard?.disable?.()
|
|
101
|
+
},
|
|
102
|
+
events: {
|
|
103
|
+
on: (e, h) => comp.on?.(e, h),
|
|
104
|
+
off: (e, h) => comp.off?.(e, h)
|
|
105
|
+
},
|
|
106
|
+
lifecycle: {
|
|
107
|
+
destroy: () => comp.lifecycle?.destroy?.()
|
|
108
|
+
}
|
|
109
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/components/chips/constants.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Available variants for the Chip component
|
|
5
|
+
* @enum {string}
|
|
6
|
+
*/
|
|
7
|
+
export const CHIP_VARIANTS = {
|
|
8
|
+
/** Standard filled chip with solid background */
|
|
9
|
+
FILLED: 'filled',
|
|
10
|
+
|
|
11
|
+
/** Outlined chip with transparent background and border */
|
|
12
|
+
OUTLINED: 'outlined',
|
|
13
|
+
|
|
14
|
+
/** Elevated chip with shadow */
|
|
15
|
+
ELEVATED: 'elevated',
|
|
16
|
+
|
|
17
|
+
/** Assist chip for suggesting actions */
|
|
18
|
+
ASSIST: 'assist',
|
|
19
|
+
|
|
20
|
+
/** Filter chip for filtering content */
|
|
21
|
+
FILTER: 'filter',
|
|
22
|
+
|
|
23
|
+
/** Input chip for representing user input */
|
|
24
|
+
INPUT: 'input',
|
|
25
|
+
|
|
26
|
+
/** Suggestion chip for presenting options */
|
|
27
|
+
SUGGESTION: 'suggestion'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Available event types for Chip component
|
|
32
|
+
* @enum {string}
|
|
33
|
+
*/
|
|
34
|
+
export const CHIP_EVENTS = {
|
|
35
|
+
/** Fired when chip selection state changes */
|
|
36
|
+
CHANGE: 'change',
|
|
37
|
+
|
|
38
|
+
/** Fired when chip is selected */
|
|
39
|
+
SELECT: 'select',
|
|
40
|
+
|
|
41
|
+
/** Fired when chip is deselected */
|
|
42
|
+
DESELECT: 'deselect',
|
|
43
|
+
|
|
44
|
+
/** Fired when chip is about to be removed */
|
|
45
|
+
REMOVE: 'remove'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Available event types for Chips container component
|
|
50
|
+
* @enum {string}
|
|
51
|
+
*/
|
|
52
|
+
export const CHIPS_EVENTS = {
|
|
53
|
+
/** Fired when any chip selection changes */
|
|
54
|
+
CHANGE: 'change',
|
|
55
|
+
|
|
56
|
+
/** Fired when a chip is added to the container */
|
|
57
|
+
ADD: 'add',
|
|
58
|
+
|
|
59
|
+
/** Fired when a chip is removed from the container */
|
|
60
|
+
REMOVE: 'remove'
|
|
61
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/components/chips/features/chip-items.ts
|
|
2
|
+
import { ChipsConfig } from '../types';
|
|
3
|
+
import createChip from '../chip/chip';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Adds chip item management to chips component
|
|
7
|
+
*
|
|
8
|
+
* @param config Chips configuration
|
|
9
|
+
* @returns Component enhancer that adds chip items functionality
|
|
10
|
+
*/
|
|
11
|
+
export const withChipItems = (config: ChipsConfig) => component => {
|
|
12
|
+
// Chip instances stored in component state
|
|
13
|
+
const chipInstances = [];
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
...component,
|
|
17
|
+
chipInstances,
|
|
18
|
+
|
|
19
|
+
// When DOM is created, add initial chips
|
|
20
|
+
onCreated() {
|
|
21
|
+
if (typeof component.onCreated === 'function') {
|
|
22
|
+
component.onCreated();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Initialize with provided chips
|
|
26
|
+
if (Array.isArray(config.chips) && config.chips.length > 0) {
|
|
27
|
+
config.chips.forEach(chipConfig => {
|
|
28
|
+
this.chips?.addChip?.(chipConfig);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/components/chips/features/container.ts
|
|
2
|
+
import { ChipsConfig } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Adds container layout features to chips component
|
|
6
|
+
*
|
|
7
|
+
* @param config Chips configuration
|
|
8
|
+
* @returns Component enhancer that adds container layout functionality
|
|
9
|
+
*/
|
|
10
|
+
export const withContainer = (config: ChipsConfig) => component => {
|
|
11
|
+
// Track current layout state
|
|
12
|
+
const state = {
|
|
13
|
+
scrollable: config.scrollable === true,
|
|
14
|
+
vertical: config.vertical === true
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
...component,
|
|
19
|
+
|
|
20
|
+
// Layout management API
|
|
21
|
+
layout: {
|
|
22
|
+
/**
|
|
23
|
+
* Sets the scrollable state of the chips container
|
|
24
|
+
* @param {boolean} isScrollable - Whether the chips container should be scrollable
|
|
25
|
+
* @returns Layout controller for chaining
|
|
26
|
+
*/
|
|
27
|
+
setScrollable(isScrollable: boolean) {
|
|
28
|
+
state.scrollable = isScrollable;
|
|
29
|
+
|
|
30
|
+
if (component.element) {
|
|
31
|
+
if (isScrollable) {
|
|
32
|
+
component.element.classList.add(`${component.getClass('chips')}--scrollable`);
|
|
33
|
+
} else {
|
|
34
|
+
component.element.classList.remove(`${component.getClass('chips')}--scrollable`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return this;
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Gets the scrollable state
|
|
43
|
+
* @returns {boolean} Whether the container is scrollable
|
|
44
|
+
*/
|
|
45
|
+
isScrollable() {
|
|
46
|
+
return state.scrollable;
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Sets the vertical layout state
|
|
51
|
+
* @param {boolean} isVertical - Whether the chips container should be vertically stacked
|
|
52
|
+
* @returns Layout controller for chaining
|
|
53
|
+
*/
|
|
54
|
+
setVertical(isVertical: boolean) {
|
|
55
|
+
state.vertical = isVertical;
|
|
56
|
+
|
|
57
|
+
if (component.element) {
|
|
58
|
+
if (isVertical) {
|
|
59
|
+
component.element.classList.add(`${component.getClass('chips')}--vertical`);
|
|
60
|
+
} else {
|
|
61
|
+
component.element.classList.remove(`${component.getClass('chips')}--vertical`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return this;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Gets the vertical state
|
|
70
|
+
* @returns {boolean} Whether the container has vertical layout
|
|
71
|
+
*/
|
|
72
|
+
isVertical() {
|
|
73
|
+
return state.vertical;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|