mtrl 0.3.0 → 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 -69
- package/package.json +10 -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/navigation/index.ts +4 -1
- package/src/components/navigation/types.ts +33 -0
- 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/snackbar/index.ts +7 -1
- package/src/components/snackbar/types.ts +25 -0
- package/src/components/switch/index.ts +5 -1
- package/src/components/switch/types.ts +13 -0
- package/src/components/tabs/tab-api.ts +1 -1
- package/src/components/tabs/types.ts +1 -1
- package/src/components/textfield/index.ts +7 -1
- package/src/components/textfield/types.ts +36 -0
- 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/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/snackbar/constants.ts +0 -26
- package/src/components/tooltip/constants.ts +0 -27
- package/test/components/button.test.js +0 -170
- package/test/components/checkbox.test.js +0 -238
- package/test/components/list.test.js +0 -105
- package/test/components/menu.test.js +0 -385
- package/test/components/navigation.test.js +0 -227
- package/test/components/snackbar.test.js +0 -234
- package/test/components/switch.test.js +0 -186
- package/test/components/textfield.test.js +0 -314
- package/test/core/emitter.test.js +0 -141
- package/test/core/ripple.test.js +0 -66
- package/test/setup.js +0 -371
- package/tsconfig.json +0 -22
- package/typedoc.json +0 -28
- package/typedoc.simple.json +0 -14
|
@@ -1,32 +1,72 @@
|
|
|
1
1
|
// src/components/fab/api.ts
|
|
2
2
|
import { FabComponent } from './types';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* API configuration options for the FAB component
|
|
6
|
+
*
|
|
7
|
+
* @category Components
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
4
10
|
interface ApiOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Disabled state management API
|
|
13
|
+
*/
|
|
5
14
|
disabled: {
|
|
15
|
+
/** Enables the component */
|
|
6
16
|
enable: () => void;
|
|
17
|
+
/** Disables the component */
|
|
7
18
|
disable: () => void;
|
|
8
19
|
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Lifecycle management API
|
|
23
|
+
*/
|
|
9
24
|
lifecycle: {
|
|
25
|
+
/** Destroys the component */
|
|
10
26
|
destroy: () => void;
|
|
11
27
|
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Base class name for the FAB
|
|
31
|
+
*/
|
|
12
32
|
className: string;
|
|
13
33
|
}
|
|
14
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Base component with element properties
|
|
37
|
+
*
|
|
38
|
+
* @category Components
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
15
41
|
interface ComponentWithElements {
|
|
42
|
+
/** The DOM element */
|
|
16
43
|
element: HTMLElement;
|
|
44
|
+
|
|
45
|
+
/** Icon management */
|
|
17
46
|
icon: {
|
|
47
|
+
/** Sets icon HTML content */
|
|
18
48
|
setIcon: (html: string) => any;
|
|
49
|
+
/** Gets icon HTML content */
|
|
19
50
|
getIcon: () => string;
|
|
51
|
+
/** Gets icon DOM element */
|
|
20
52
|
getElement: () => HTMLElement | null;
|
|
21
53
|
};
|
|
54
|
+
|
|
55
|
+
/** Gets a class name with component's prefix */
|
|
22
56
|
getClass: (name: string) => string;
|
|
23
57
|
}
|
|
24
58
|
|
|
25
59
|
/**
|
|
26
|
-
* Enhances a FAB component with API methods
|
|
60
|
+
* Enhances a FAB component with public API methods
|
|
61
|
+
*
|
|
62
|
+
* Higher-order function that adds the full public API to the FAB component,
|
|
63
|
+
* exposing methods for changing appearance, handling state, and managing position.
|
|
64
|
+
*
|
|
27
65
|
* @param {ApiOptions} options - API configuration options
|
|
28
66
|
* @returns {Function} Higher-order function that adds API methods to component
|
|
29
|
-
*
|
|
67
|
+
*
|
|
68
|
+
* @category Components
|
|
69
|
+
* @internal
|
|
30
70
|
*/
|
|
31
71
|
export const withAPI = ({ disabled, lifecycle, className }: ApiOptions) =>
|
|
32
72
|
(component: ComponentWithElements): FabComponent => ({
|
|
@@ -8,6 +8,12 @@ import { FabConfig } from './types';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Default configuration for the FAB component
|
|
11
|
+
*
|
|
12
|
+
* Provides reasonable defaults for creating FABs
|
|
13
|
+
* according to Material Design 3 guidelines.
|
|
14
|
+
*
|
|
15
|
+
* @category Components
|
|
16
|
+
* @internal
|
|
11
17
|
*/
|
|
12
18
|
export const defaultConfig: FabConfig = {
|
|
13
19
|
variant: 'primary',
|
|
@@ -18,16 +24,31 @@ export const defaultConfig: FabConfig = {
|
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* Creates the base configuration for FAB component
|
|
27
|
+
*
|
|
28
|
+
* Merges user-provided configuration with default values and validates
|
|
29
|
+
* the configuration to ensure all required properties have values.
|
|
30
|
+
*
|
|
21
31
|
* @param {FabConfig} config - User provided configuration
|
|
22
32
|
* @returns {FabConfig} Complete configuration with defaults applied
|
|
33
|
+
*
|
|
34
|
+
* @category Components
|
|
35
|
+
* @internal
|
|
23
36
|
*/
|
|
24
37
|
export const createBaseConfig = (config: FabConfig = {}): FabConfig =>
|
|
25
38
|
createComponentConfig(defaultConfig, config, 'fab') as FabConfig;
|
|
26
39
|
|
|
27
40
|
/**
|
|
28
41
|
* Generates element configuration for the FAB component
|
|
42
|
+
*
|
|
43
|
+
* Transforms the user-friendly FabConfig into the internal format required
|
|
44
|
+
* by the withElement function. Creates all the appropriate CSS classes and attributes
|
|
45
|
+
* needed to properly render the FAB in the DOM.
|
|
46
|
+
*
|
|
29
47
|
* @param {FabConfig} config - FAB configuration
|
|
30
48
|
* @returns {Object} Element configuration object for withElement
|
|
49
|
+
*
|
|
50
|
+
* @category Components
|
|
51
|
+
* @internal
|
|
31
52
|
*/
|
|
32
53
|
export const getElementConfig = (config: FabConfig) => {
|
|
33
54
|
// Create the attributes object
|
|
@@ -76,8 +97,15 @@ export const getElementConfig = (config: FabConfig) => {
|
|
|
76
97
|
|
|
77
98
|
/**
|
|
78
99
|
* Creates API configuration for the FAB component
|
|
100
|
+
*
|
|
101
|
+
* Provides access to various component sub-features like disabled state
|
|
102
|
+
* and lifecycle management.
|
|
103
|
+
*
|
|
79
104
|
* @param {Object} comp - Component with disabled and lifecycle features
|
|
80
|
-
* @returns {Object} API configuration object
|
|
105
|
+
* @returns {Object} API configuration object for withAPI
|
|
106
|
+
*
|
|
107
|
+
* @category Components
|
|
108
|
+
* @internal
|
|
81
109
|
*/
|
|
82
110
|
export const getApiConfig = (comp: any) => ({
|
|
83
111
|
disabled: {
|
|
@@ -16,14 +16,23 @@ import { createBaseConfig, getElementConfig, getApiConfig } from './config';
|
|
|
16
16
|
/**
|
|
17
17
|
* Creates a new Floating Action Button (FAB) component
|
|
18
18
|
*
|
|
19
|
+
* Floating Action Buttons (FABs) represent the primary action in an application.
|
|
20
|
+
* They're circular buttons that float above the UI, and typically contain an icon.
|
|
21
|
+
* FABs follow Material Design 3 guidelines with support for multiple variants,
|
|
22
|
+
* sizes, and positioning options.
|
|
23
|
+
*
|
|
19
24
|
* @param {FabConfig} config - FAB configuration object
|
|
20
25
|
* @returns {FabComponent} FAB component instance
|
|
21
26
|
*
|
|
27
|
+
* @throws {Error} If the FAB cannot be created due to invalid configuration
|
|
28
|
+
*
|
|
29
|
+
* @category Components
|
|
30
|
+
*
|
|
22
31
|
* @example
|
|
23
32
|
* ```typescript
|
|
24
33
|
* // Create a default FAB with a plus icon
|
|
25
34
|
* const fab = createFab({
|
|
26
|
-
* icon: '<svg
|
|
35
|
+
* icon: '<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',
|
|
27
36
|
* ariaLabel: 'Add new item'
|
|
28
37
|
* });
|
|
29
38
|
*
|
|
@@ -35,10 +44,15 @@ import { createBaseConfig, getElementConfig, getApiConfig } from './config';
|
|
|
35
44
|
* position: 'bottom-right'
|
|
36
45
|
* });
|
|
37
46
|
*
|
|
38
|
-
* // Add click handler
|
|
47
|
+
* // Add click handler and attach to DOM
|
|
39
48
|
* fab.on('click', () => {
|
|
40
49
|
* console.log('FAB clicked');
|
|
41
50
|
* });
|
|
51
|
+
* document.body.appendChild(fab.element);
|
|
52
|
+
*
|
|
53
|
+
* // Later, update the FAB's appearance
|
|
54
|
+
* fab.setIcon('<span class="material-icons">edit</span>');
|
|
55
|
+
* fab.setPosition('bottom-left');
|
|
42
56
|
* ```
|
|
43
57
|
*/
|
|
44
58
|
const createFab = (config: FabConfig = {}): FabComponent => {
|
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
// src/components/fab/index.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module Fab
|
|
5
|
+
*
|
|
6
|
+
* Floating Action Button (FAB) component following Material Design 3 guidelines.
|
|
7
|
+
* FABs are circular buttons that represent the primary action in an application.
|
|
8
|
+
* They are prominently displayed, typically in a fixed position overlaid on the UI.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Multiple variants (primary, secondary, tertiary, surface)
|
|
12
|
+
* - Three size options (small, default, large)
|
|
13
|
+
* - Configurable positioning
|
|
14
|
+
* - Icon support with customization
|
|
15
|
+
* - Ripple effect on interaction
|
|
16
|
+
* - Accessibility support
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Create a primary FAB with a plus icon
|
|
21
|
+
* const fab = createFab({
|
|
22
|
+
* icon: '<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',
|
|
23
|
+
* position: 'bottom-right',
|
|
24
|
+
* ariaLabel: 'Add new item'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Attach to DOM and add click handler
|
|
28
|
+
* container.appendChild(fab.element);
|
|
29
|
+
* fab.on('click', () => {
|
|
30
|
+
* console.log('FAB clicked');
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @category Components
|
|
35
|
+
*/
|
|
36
|
+
|
|
2
37
|
export { default, default as createFab } from './fab';
|
|
3
38
|
export {
|
|
4
39
|
FabConfig,
|