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
|
@@ -3,62 +3,141 @@ import { createComponentConfig } from '../../core/config/component-config';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration options for divider components
|
|
6
|
+
*
|
|
7
|
+
* Controls the appearance, orientation, and behavior of Material Design 3 dividers.
|
|
8
|
+
*
|
|
9
|
+
* @category Components
|
|
6
10
|
*/
|
|
7
11
|
export interface DividerConfig {
|
|
8
12
|
/**
|
|
9
13
|
* CSS class prefix (defaults to 'mtrl')
|
|
14
|
+
*
|
|
15
|
+
* Used for generating BEM-style class names for the component
|
|
10
16
|
*/
|
|
11
17
|
prefix?: string;
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
20
|
* CSS class to add to the divider
|
|
21
|
+
*
|
|
22
|
+
* Additional classes for custom styling needs
|
|
23
|
+
*
|
|
24
|
+
* @example 'my-custom-divider'
|
|
15
25
|
*/
|
|
16
26
|
class?: string;
|
|
17
27
|
|
|
18
28
|
/**
|
|
19
|
-
* Orientation of the divider
|
|
29
|
+
* Orientation of the divider
|
|
30
|
+
*
|
|
31
|
+
* - 'horizontal': Creates a horizontal line (default)
|
|
32
|
+
* - 'vertical': Creates a vertical line
|
|
33
|
+
*
|
|
20
34
|
* @default 'horizontal'
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Create a vertical divider
|
|
39
|
+
* createDivider({ orientation: 'vertical' })
|
|
40
|
+
* ```
|
|
21
41
|
*/
|
|
22
42
|
orientation?: 'horizontal' | 'vertical';
|
|
23
43
|
|
|
24
44
|
/**
|
|
25
|
-
* Variant of the divider
|
|
45
|
+
* Variant of the divider
|
|
46
|
+
*
|
|
47
|
+
* Controls how the divider is inset within its container:
|
|
48
|
+
* - 'full-width': Spans the entire width/height (default)
|
|
49
|
+
* - 'inset': Adds space at the start (left for horizontal, top for vertical)
|
|
50
|
+
* - 'middle-inset': Adds space at both start and end
|
|
51
|
+
*
|
|
52
|
+
* Most commonly used in lists to align dividers with text content.
|
|
53
|
+
*
|
|
26
54
|
* @default 'full-width'
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Create a list divider with left inset
|
|
59
|
+
* createDivider({ variant: 'inset' })
|
|
60
|
+
* ```
|
|
27
61
|
*/
|
|
28
62
|
variant?: 'full-width' | 'inset' | 'middle-inset';
|
|
29
63
|
|
|
30
64
|
/**
|
|
31
65
|
* Custom inset value (left margin for horizontal, top margin for vertical)
|
|
32
|
-
*
|
|
66
|
+
*
|
|
67
|
+
* Overrides the default inset spacing at the start of the divider.
|
|
68
|
+
* Only applies when variant is 'inset' or 'middle-inset'.
|
|
69
|
+
*
|
|
70
|
+
* @default 16 for 'inset' and 'middle-inset' variants
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* // Create a divider with 24px left inset
|
|
75
|
+
* createDivider({ variant: 'inset', insetStart: 24 })
|
|
76
|
+
* ```
|
|
33
77
|
*/
|
|
34
78
|
insetStart?: number;
|
|
35
79
|
|
|
36
80
|
/**
|
|
37
81
|
* Custom inset end value (right margin for horizontal, bottom margin for vertical)
|
|
38
|
-
*
|
|
82
|
+
*
|
|
83
|
+
* Overrides the default inset spacing at the end of the divider.
|
|
84
|
+
* Only applies when variant is 'middle-inset'.
|
|
85
|
+
*
|
|
86
|
+
* @default 0 for 'inset', 16 for 'middle-inset'
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Create a divider with custom insets on both sides
|
|
91
|
+
* createDivider({ variant: 'middle-inset', insetStart: 16, insetEnd: 24 })
|
|
92
|
+
* ```
|
|
39
93
|
*/
|
|
40
94
|
insetEnd?: number;
|
|
41
95
|
|
|
42
96
|
/**
|
|
43
|
-
* Color of the divider
|
|
97
|
+
* Color of the divider
|
|
98
|
+
*
|
|
99
|
+
* Sets a custom color for the divider. Accepts any valid CSS color value.
|
|
100
|
+
* By default, dividers use the 'outline-variant' color from the Material theme.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Create a blue divider
|
|
105
|
+
* createDivider({ color: '#2196F3' })
|
|
106
|
+
*
|
|
107
|
+
* // Create a divider with a semi-transparent color
|
|
108
|
+
* createDivider({ color: 'rgba(0, 0, 0, 0.12)' })
|
|
109
|
+
* ```
|
|
44
110
|
*/
|
|
45
111
|
color?: string;
|
|
46
112
|
|
|
47
113
|
/**
|
|
48
114
|
* Thickness of the divider in pixels
|
|
115
|
+
*
|
|
116
|
+
* Controls the thickness (height for horizontal, width for vertical) of the divider.
|
|
117
|
+
* Material Design 3 typically uses 1px thickness for dividers.
|
|
118
|
+
*
|
|
49
119
|
* @default 1
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* // Create a bold divider
|
|
124
|
+
* createDivider({ thickness: 2 })
|
|
125
|
+
* ```
|
|
50
126
|
*/
|
|
51
127
|
thickness?: number;
|
|
52
128
|
|
|
53
129
|
/**
|
|
54
130
|
* Used internally for component composition
|
|
55
|
-
*
|
|
131
|
+
*
|
|
132
|
+
* @internal
|
|
56
133
|
*/
|
|
57
134
|
componentName?: string;
|
|
58
135
|
}
|
|
59
136
|
|
|
60
137
|
/**
|
|
61
138
|
* Default configuration for dividers
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
62
141
|
*/
|
|
63
142
|
export const defaultConfig: Partial<DividerConfig> = {
|
|
64
143
|
orientation: 'horizontal',
|
|
@@ -69,8 +148,13 @@ export const defaultConfig: Partial<DividerConfig> = {
|
|
|
69
148
|
/**
|
|
70
149
|
* Creates a base configuration object for divider
|
|
71
150
|
*
|
|
151
|
+
* Merges user-provided configuration with default values and ensures
|
|
152
|
+
* all required properties have values.
|
|
153
|
+
*
|
|
72
154
|
* @param config - User provided configuration
|
|
73
155
|
* @returns Complete configuration with defaults applied
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
74
158
|
*/
|
|
75
159
|
export const createBaseConfig = (config: DividerConfig = {}): DividerConfig => {
|
|
76
160
|
return createComponentConfig(
|
|
@@ -11,10 +11,40 @@ import { withOrientation, withInset, withStyle } from './features';
|
|
|
11
11
|
import { DividerComponent } from './types';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Creates a
|
|
14
|
+
* Creates a new Divider component with the specified configuration.
|
|
15
|
+
*
|
|
16
|
+
* Dividers are thin lines that separate content into distinct sections following
|
|
17
|
+
* Material Design 3 guidelines. They can be horizontal or vertical, and offer
|
|
18
|
+
* various customization options for inset, thickness, and color.
|
|
15
19
|
*
|
|
16
20
|
* @param config - Divider configuration options
|
|
17
|
-
* @returns Divider component instance
|
|
21
|
+
* @returns Divider component instance with methods for managing appearance and behavior
|
|
22
|
+
*
|
|
23
|
+
* @throws {Error} If divider creation fails due to invalid configuration
|
|
24
|
+
*
|
|
25
|
+
* @category Components
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // Create a basic horizontal divider
|
|
30
|
+
* const divider = createDivider();
|
|
31
|
+
* container.appendChild(divider.element);
|
|
32
|
+
*
|
|
33
|
+
* // Create a vertical divider with custom styling
|
|
34
|
+
* const separator = createDivider({
|
|
35
|
+
* orientation: 'vertical',
|
|
36
|
+
* thickness: 2,
|
|
37
|
+
* color: '#2196F3',
|
|
38
|
+
* variant: 'middle-inset',
|
|
39
|
+
* insetStart: 8,
|
|
40
|
+
* insetEnd: 8
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Later, change the divider's appearance
|
|
44
|
+
* divider.setColor('var(--md-sys-color-outline)');
|
|
45
|
+
* divider.setThickness(1);
|
|
46
|
+
* divider.setVariant('inset');
|
|
47
|
+
* ```
|
|
18
48
|
*/
|
|
19
49
|
export const createDivider = (config: DividerConfig = {}): DividerComponent => {
|
|
20
50
|
// Process configuration
|
|
@@ -6,8 +6,14 @@ import { DividerComponent } from './types';
|
|
|
6
6
|
/**
|
|
7
7
|
* Adds orientation functionality to divider
|
|
8
8
|
*
|
|
9
|
+
* Higher-order function that enhances a component with the ability to be
|
|
10
|
+
* oriented horizontally (default) or vertically. Controls the appropriate
|
|
11
|
+
* CSS classes and dimensional styling based on orientation.
|
|
12
|
+
*
|
|
9
13
|
* @param config - Divider configuration
|
|
10
14
|
* @returns Function that enhances a component with orientation capabilities
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
11
17
|
*/
|
|
12
18
|
export const withOrientation = (config: DividerConfig) =>
|
|
13
19
|
<C extends ElementComponent & BaseComponent>(component: C): C & Partial<DividerComponent> => {
|
|
@@ -66,8 +72,18 @@ export const withOrientation = (config: DividerConfig) =>
|
|
|
66
72
|
/**
|
|
67
73
|
* Adds inset functionality to divider
|
|
68
74
|
*
|
|
75
|
+
* Higher-order function that enhances a component with the ability to have
|
|
76
|
+
* customized inset spacing. Supports three variants (full-width, inset, middle-inset)
|
|
77
|
+
* and allows fine-grained control over start and end insets.
|
|
78
|
+
*
|
|
79
|
+
* Insets are applied as margins in the appropriate direction based on orientation:
|
|
80
|
+
* - For horizontal dividers: left/right margins
|
|
81
|
+
* - For vertical dividers: top/bottom margins
|
|
82
|
+
*
|
|
69
83
|
* @param config - Divider configuration
|
|
70
84
|
* @returns Function that enhances a component with inset capabilities
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
71
87
|
*/
|
|
72
88
|
export const withInset = (config: DividerConfig) =>
|
|
73
89
|
<C extends ElementComponent & Partial<DividerComponent>>(component: C): C & Partial<DividerComponent> => {
|
|
@@ -164,8 +180,18 @@ export const withInset = (config: DividerConfig) =>
|
|
|
164
180
|
/**
|
|
165
181
|
* Adds style customization to divider
|
|
166
182
|
*
|
|
183
|
+
* Higher-order function that enhances a component with visual customization
|
|
184
|
+
* capabilities, including:
|
|
185
|
+
* - Custom thickness (height for horizontal, width for vertical dividers)
|
|
186
|
+
* - Custom colors (background-color CSS property)
|
|
187
|
+
*
|
|
188
|
+
* These styling options allow dividers to be visually adapted to different
|
|
189
|
+
* design requirements while maintaining Material Design principles.
|
|
190
|
+
*
|
|
167
191
|
* @param config - Divider configuration
|
|
168
192
|
* @returns Function that enhances a component with style capabilities
|
|
193
|
+
*
|
|
194
|
+
* @internal
|
|
169
195
|
*/
|
|
170
196
|
export const withStyle = (config: DividerConfig) =>
|
|
171
197
|
<C extends ElementComponent & Partial<DividerComponent>>(component: C): C & Partial<DividerComponent> => {
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
// src/components/divider/index.ts
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @module Divider
|
|
5
|
+
*
|
|
6
|
+
* The Divider component provides horizontal or vertical lines that separate content into distinct sections.
|
|
7
|
+
* Dividers follow Material Design 3 guidelines for separating content in lists, layouts, and other UI containers.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Horizontal and vertical orientations
|
|
11
|
+
* - Multiple inset variants (full-width, inset, middle-inset)
|
|
12
|
+
* - Customizable thickness and color
|
|
13
|
+
* - Responsive to parent container
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Create a standard horizontal divider
|
|
18
|
+
* const divider = createDivider();
|
|
19
|
+
* document.body.appendChild(divider.element);
|
|
20
|
+
*
|
|
21
|
+
* // Create a vertical divider with custom styles
|
|
22
|
+
* const verticalDivider = createDivider({
|
|
23
|
+
* orientation: 'vertical',
|
|
24
|
+
* thickness: 2,
|
|
25
|
+
* color: '#2196F3',
|
|
26
|
+
* variant: 'middle-inset'
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @category Components
|
|
31
|
+
*/
|
|
32
|
+
|
|
3
33
|
// Use a more explicit export to avoid bundler confusion
|
|
4
34
|
import { createDivider } from './divider';
|
|
5
35
|
export { createDivider };
|
|
@@ -3,53 +3,130 @@ import { BaseComponent, ElementComponent } from '../../core/compose';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Divider component interface
|
|
6
|
+
*
|
|
7
|
+
* Represents a Material Design 3 divider that separates content into distinct sections.
|
|
8
|
+
* Provides methods for configuring the appearance, orientation, and inset behavior.
|
|
9
|
+
*
|
|
10
|
+
* @category Components
|
|
6
11
|
*/
|
|
7
12
|
export interface DividerComponent extends BaseComponent, ElementComponent {
|
|
8
13
|
/**
|
|
9
|
-
* Gets current orientation
|
|
10
|
-
*
|
|
14
|
+
* Gets current orientation of the divider
|
|
15
|
+
*
|
|
16
|
+
* @returns Current orientation ('horizontal' or 'vertical')
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const divider = createDivider();
|
|
21
|
+
* const orientation = divider.getOrientation(); // Returns 'horizontal' by default
|
|
22
|
+
* ```
|
|
11
23
|
*/
|
|
12
24
|
getOrientation: () => 'horizontal' | 'vertical';
|
|
13
25
|
|
|
14
26
|
/**
|
|
15
27
|
* Sets orientation of the divider
|
|
16
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* Changes the divider's orientation between horizontal (default) and vertical.
|
|
30
|
+
* This affects the divider's positioning, dimension constraints, and how insets are applied.
|
|
31
|
+
*
|
|
32
|
+
* @param orientation - New orientation ('horizontal' or 'vertical')
|
|
17
33
|
* @returns DividerComponent instance for chaining
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Change a divider from horizontal to vertical
|
|
38
|
+
* divider.setOrientation('vertical');
|
|
39
|
+
* ```
|
|
18
40
|
*/
|
|
19
41
|
setOrientation: (orientation: 'horizontal' | 'vertical') => DividerComponent;
|
|
20
42
|
|
|
21
43
|
/**
|
|
22
|
-
* Gets current variant
|
|
23
|
-
*
|
|
44
|
+
* Gets current variant of the divider
|
|
45
|
+
*
|
|
46
|
+
* @returns Current variant ('full-width', 'inset', or 'middle-inset')
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const variant = divider.getVariant(); // Returns 'full-width' by default
|
|
51
|
+
* ```
|
|
24
52
|
*/
|
|
25
53
|
getVariant: () => 'full-width' | 'inset' | 'middle-inset';
|
|
26
54
|
|
|
27
55
|
/**
|
|
28
56
|
* Sets variant of the divider
|
|
57
|
+
*
|
|
58
|
+
* Changes how the divider is inset within its container:
|
|
59
|
+
* - 'full-width': Spans the entire width/height of the container (default)
|
|
60
|
+
* - 'inset': Adds space at the start (left for horizontal, top for vertical)
|
|
61
|
+
* - 'middle-inset': Adds space at both start and end
|
|
62
|
+
*
|
|
29
63
|
* @param variant - New variant
|
|
30
64
|
* @returns DividerComponent instance for chaining
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // Create a list divider with left inset
|
|
69
|
+
* divider.setVariant('inset');
|
|
70
|
+
*
|
|
71
|
+
* // Create a divider with space on both sides
|
|
72
|
+
* divider.setVariant('middle-inset');
|
|
73
|
+
* ```
|
|
31
74
|
*/
|
|
32
75
|
setVariant: (variant: 'full-width' | 'inset' | 'middle-inset') => DividerComponent;
|
|
33
76
|
|
|
34
77
|
/**
|
|
35
|
-
* Sets custom inset values
|
|
36
|
-
*
|
|
37
|
-
*
|
|
78
|
+
* Sets custom inset values for the divider
|
|
79
|
+
*
|
|
80
|
+
* Allows fine-grained control over inset spacing, overriding the default values
|
|
81
|
+
* applied by the variant. Only applies if variant is 'inset' or 'middle-inset'.
|
|
82
|
+
*
|
|
83
|
+
* @param insetStart - Start inset value in pixels (left for horizontal, top for vertical)
|
|
84
|
+
* @param insetEnd - End inset value in pixels (right for horizontal, bottom for vertical)
|
|
38
85
|
* @returns DividerComponent instance for chaining
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Create a divider with custom insets
|
|
90
|
+
* const divider = createDivider({ variant: 'inset' });
|
|
91
|
+
* divider.setInset(24, 8); // 24px from start, 8px from end
|
|
92
|
+
* ```
|
|
39
93
|
*/
|
|
40
94
|
setInset: (insetStart?: number, insetEnd?: number) => DividerComponent;
|
|
41
95
|
|
|
42
96
|
/**
|
|
43
97
|
* Sets thickness of the divider
|
|
98
|
+
*
|
|
99
|
+
* Changes the divider's thickness (height for horizontal, width for vertical).
|
|
100
|
+
* The default thickness is 1px, following Material Design 3 guidelines.
|
|
101
|
+
*
|
|
44
102
|
* @param thickness - Thickness in pixels
|
|
45
103
|
* @returns DividerComponent instance for chaining
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* // Create a bold divider
|
|
108
|
+
* divider.setThickness(2);
|
|
109
|
+
* ```
|
|
46
110
|
*/
|
|
47
111
|
setThickness: (thickness: number) => DividerComponent;
|
|
48
112
|
|
|
49
113
|
/**
|
|
50
114
|
* Sets custom color for the divider
|
|
51
|
-
*
|
|
115
|
+
*
|
|
116
|
+
* By default, dividers use the 'outline-variant' color from the theme.
|
|
117
|
+
* This method allows setting a custom color via any valid CSS color value.
|
|
118
|
+
*
|
|
119
|
+
* @param color - CSS color value (hex, rgb, rgba, hsl, etc.)
|
|
52
120
|
* @returns DividerComponent instance for chaining
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // Create a blue divider
|
|
125
|
+
* divider.setColor('#2196F3');
|
|
126
|
+
*
|
|
127
|
+
* // Create a semi-transparent divider
|
|
128
|
+
* divider.setColor('rgba(0, 0, 0, 0.12)');
|
|
129
|
+
* ```
|
|
53
130
|
*/
|
|
54
131
|
setColor: (color: string) => DividerComponent;
|
|
55
132
|
}
|
|
@@ -1,40 +1,92 @@
|
|
|
1
1
|
// src/components/extended-fab/api.ts
|
|
2
2
|
import { ExtendedFabComponent } from './types';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* API configuration options for the Extended 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
|
+
* Text content management API
|
|
31
|
+
*/
|
|
12
32
|
text: {
|
|
33
|
+
/** Sets text content */
|
|
13
34
|
setText: (text: string) => any;
|
|
35
|
+
/** Gets text content */
|
|
14
36
|
getText: () => string;
|
|
15
37
|
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Base class name for the Extended FAB
|
|
41
|
+
*/
|
|
16
42
|
className: string;
|
|
17
43
|
}
|
|
18
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Base component with element properties
|
|
47
|
+
*
|
|
48
|
+
* @category Components
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
19
51
|
interface ComponentWithElements {
|
|
52
|
+
/** The DOM element */
|
|
20
53
|
element: HTMLElement;
|
|
54
|
+
|
|
55
|
+
/** Icon management */
|
|
21
56
|
icon: {
|
|
57
|
+
/** Sets icon HTML content */
|
|
22
58
|
setIcon: (html: string) => any;
|
|
59
|
+
/** Gets icon HTML content */
|
|
23
60
|
getIcon: () => string;
|
|
61
|
+
/** Gets icon DOM element */
|
|
24
62
|
getElement: () => HTMLElement | null;
|
|
25
63
|
};
|
|
64
|
+
|
|
65
|
+
/** Text management */
|
|
26
66
|
text: {
|
|
67
|
+
/** Sets text content */
|
|
27
68
|
setText: (text: string) => any;
|
|
69
|
+
/** Gets text content */
|
|
28
70
|
getText: () => string;
|
|
71
|
+
/** Gets text DOM element */
|
|
29
72
|
getElement: () => HTMLElement | null;
|
|
30
73
|
};
|
|
74
|
+
|
|
75
|
+
/** Gets a class name with component's prefix */
|
|
31
76
|
getClass: (name: string) => string;
|
|
32
77
|
}
|
|
33
78
|
|
|
34
79
|
/**
|
|
35
|
-
* Enhances an Extended FAB component with API methods
|
|
80
|
+
* Enhances an Extended FAB component with public API methods
|
|
81
|
+
*
|
|
82
|
+
* Higher-order function that adds the full public API to the Extended FAB component,
|
|
83
|
+
* exposing methods for changing appearance, handling state, managing position,
|
|
84
|
+
* and controlling the collapse/expand behavior.
|
|
85
|
+
*
|
|
36
86
|
* @param {ApiOptions} options - API configuration options
|
|
37
87
|
* @returns {Function} Higher-order function that adds API methods to component
|
|
88
|
+
*
|
|
89
|
+
* @category Components
|
|
38
90
|
* @internal This is an internal utility for the Extended FAB component
|
|
39
91
|
*/
|
|
40
92
|
export const withAPI = ({ disabled, lifecycle, text, className }: ApiOptions) =>
|
|
@@ -8,6 +8,12 @@ import { ExtendedFabConfig } from './types';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Default configuration for the Extended FAB component
|
|
11
|
+
*
|
|
12
|
+
* Provides reasonable defaults for creating Extended FABs
|
|
13
|
+
* according to Material Design 3 guidelines.
|
|
14
|
+
*
|
|
15
|
+
* @category Components
|
|
16
|
+
* @internal
|
|
11
17
|
*/
|
|
12
18
|
export const defaultConfig: ExtendedFabConfig = {
|
|
13
19
|
variant: 'primary',
|
|
@@ -19,16 +25,31 @@ export const defaultConfig: ExtendedFabConfig = {
|
|
|
19
25
|
|
|
20
26
|
/**
|
|
21
27
|
* Creates the base configuration for Extended FAB component
|
|
28
|
+
*
|
|
29
|
+
* Merges user-provided configuration with default values and validates
|
|
30
|
+
* the configuration to ensure all required properties have values.
|
|
31
|
+
*
|
|
22
32
|
* @param {ExtendedFabConfig} config - User provided configuration
|
|
23
33
|
* @returns {ExtendedFabConfig} Complete configuration with defaults applied
|
|
34
|
+
*
|
|
35
|
+
* @category Components
|
|
36
|
+
* @internal
|
|
24
37
|
*/
|
|
25
38
|
export const createBaseConfig = (config: ExtendedFabConfig = {}): ExtendedFabConfig =>
|
|
26
39
|
createComponentConfig(defaultConfig, config, 'extended-fab') as ExtendedFabConfig;
|
|
27
40
|
|
|
28
41
|
/**
|
|
29
42
|
* Generates element configuration for the Extended FAB component
|
|
43
|
+
*
|
|
44
|
+
* Transforms the user-friendly ExtendedFabConfig into the internal format required
|
|
45
|
+
* by the withElement function. Creates all the appropriate CSS classes and attributes
|
|
46
|
+
* needed to properly render the Extended FAB in the DOM.
|
|
47
|
+
*
|
|
30
48
|
* @param {ExtendedFabConfig} config - Extended FAB configuration
|
|
31
49
|
* @returns {Object} Element configuration object for withElement
|
|
50
|
+
*
|
|
51
|
+
* @category Components
|
|
52
|
+
* @internal
|
|
32
53
|
*/
|
|
33
54
|
export const getElementConfig = (config: ExtendedFabConfig) => {
|
|
34
55
|
// Create the attributes object
|
|
@@ -91,8 +112,15 @@ export const getElementConfig = (config: ExtendedFabConfig) => {
|
|
|
91
112
|
|
|
92
113
|
/**
|
|
93
114
|
* Creates API configuration for the Extended FAB component
|
|
115
|
+
*
|
|
116
|
+
* Provides access to various component sub-features like disabled state,
|
|
117
|
+
* lifecycle management, and text content.
|
|
118
|
+
*
|
|
94
119
|
* @param {Object} comp - Component with disabled and lifecycle features
|
|
95
|
-
* @returns {Object} API configuration object
|
|
120
|
+
* @returns {Object} API configuration object for withAPI
|
|
121
|
+
*
|
|
122
|
+
* @category Components
|
|
123
|
+
* @internal
|
|
96
124
|
*/
|
|
97
125
|
export const getApiConfig = (comp: any) => ({
|
|
98
126
|
disabled: {
|
|
@@ -17,9 +17,25 @@ import { createBaseConfig, getElementConfig, getApiConfig } from './config';
|
|
|
17
17
|
/**
|
|
18
18
|
* Creates a new Extended Floating Action Button (Extended FAB) component
|
|
19
19
|
*
|
|
20
|
+
* Extended FABs are a variant of the standard Floating Action Button that include
|
|
21
|
+
* both an icon and text label. They're designed for primary actions that need
|
|
22
|
+
* more description than just an icon, and can be positioned in various corners
|
|
23
|
+
* of the interface.
|
|
24
|
+
*
|
|
25
|
+
* Extended FABs follow Material Design 3 guidelines with support for:
|
|
26
|
+
* - Multiple color variants (primary, secondary, tertiary, surface)
|
|
27
|
+
* - Icon and text label configuration
|
|
28
|
+
* - Fixed or fluid width
|
|
29
|
+
* - Automatic collapse on scroll
|
|
30
|
+
* - Various positioning options
|
|
31
|
+
*
|
|
20
32
|
* @param {ExtendedFabConfig} config - Extended FAB configuration object
|
|
21
33
|
* @returns {ExtendedFabComponent} Extended FAB component instance
|
|
22
34
|
*
|
|
35
|
+
* @throws {Error} If the Extended FAB cannot be created due to invalid configuration
|
|
36
|
+
*
|
|
37
|
+
* @category Components
|
|
38
|
+
*
|
|
23
39
|
* @example
|
|
24
40
|
* ```typescript
|
|
25
41
|
* // Create a basic Extended FAB with icon and text
|
|
@@ -42,6 +58,18 @@ import { createBaseConfig, getElementConfig, getApiConfig } from './config';
|
|
|
42
58
|
* extendedFab.on('click', () => {
|
|
43
59
|
* console.log('Extended FAB clicked');
|
|
44
60
|
* });
|
|
61
|
+
*
|
|
62
|
+
* // Attach to DOM
|
|
63
|
+
* document.body.appendChild(extendedFab.element);
|
|
64
|
+
*
|
|
65
|
+
* // Programmatically collapse and expand
|
|
66
|
+
* document.querySelector('#collapseBtn').addEventListener('click', () => {
|
|
67
|
+
* extendedFab.collapse();
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* document.querySelector('#expandBtn').addEventListener('click', () => {
|
|
71
|
+
* extendedFab.expand();
|
|
72
|
+
* });
|
|
45
73
|
* ```
|
|
46
74
|
*/
|
|
47
75
|
const createExtendedFab = (config: ExtendedFabConfig = {}): ExtendedFabComponent => {
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
// src/components/extended-fab/index.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module ExtendedFab
|
|
5
|
+
*
|
|
6
|
+
* Extended Floating Action Button (Extended FAB) component following Material Design 3 guidelines.
|
|
7
|
+
* Extended FABs are wider than standard FABs, containing both an icon and a text label.
|
|
8
|
+
* They provide a primary action that's prominently displayed and easily accessible.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Multiple variants (primary, secondary, tertiary, surface)
|
|
12
|
+
* - Icon and text label combination
|
|
13
|
+
* - Configurable positioning
|
|
14
|
+
* - Collapsible behavior on scroll
|
|
15
|
+
* - Ripple effect on interaction
|
|
16
|
+
* - Accessibility support
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Create a primary Extended FAB with icon and text
|
|
21
|
+
* const extendedFab = createExtendedFab({
|
|
22
|
+
* text: 'Create',
|
|
23
|
+
* icon: '<svg>...</svg>',
|
|
24
|
+
* position: 'bottom-right',
|
|
25
|
+
* collapseOnScroll: true
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Attach to DOM and add click handler
|
|
29
|
+
* container.appendChild(extendedFab.element);
|
|
30
|
+
* extendedFab.on('click', () => {
|
|
31
|
+
* console.log('Extended FAB clicked');
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @category Components
|
|
36
|
+
*/
|
|
37
|
+
|
|
2
38
|
export { default, default as createExtendedFab } from './extended-fab';
|
|
3
39
|
export {
|
|
4
40
|
ExtendedFabConfig,
|