mtrl 0.5.5 → 0.5.7
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/dist/components/button/index.d.ts +2 -2
- package/dist/components/button-group/button-group.d.ts +51 -0
- package/dist/components/button-group/config.d.ts +78 -0
- package/dist/components/button-group/constants.d.ts +128 -0
- package/dist/components/button-group/index.d.ts +13 -0
- package/dist/components/button-group/types.d.ts +244 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/menu/types.d.ts +6 -0
- package/dist/components/segmented-button/constants.d.ts +7 -4
- package/dist/components/segmented-button/segment.d.ts +7 -1
- package/dist/index.cjs +14 -17
- package/dist/index.cjs.map +14 -11
- package/dist/index.js +14 -17
- package/dist/index.js.map +14 -11
- package/dist/package.json +1 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -1
- package/src/styles/components/_button-group.scss +409 -0
- package/src/styles/components/_dialog.scss +213 -211
- package/src/styles/components/_segmented-button.scss +395 -209
- package/src/styles/components/_select.scss +245 -237
- package/src/styles/main.scss +25 -23
- package/src/styles/themes/_autumn.scss +104 -102
- package/src/styles/themes/_baseline.scss +154 -153
- package/src/styles/themes/_bluekhaki.scss +119 -118
- package/src/styles/themes/_brownbeige.scss +119 -118
- package/src/styles/themes/_browngreen.scss +119 -118
- package/src/styles/themes/_forest.scss +73 -70
- package/src/styles/themes/_greenbeige.scss +120 -117
- package/src/styles/themes/_highcontrast.scss +156 -0
- package/src/styles/themes/_index.scss +16 -14
- package/src/styles/themes/_material.scss +122 -118
- package/src/styles/themes/_ocean.scss +73 -70
- package/src/styles/themes/_sageivory.scss +120 -117
- package/src/styles/themes/_spring.scss +73 -70
- package/src/styles/themes/_summer.scss +89 -86
- package/src/styles/themes/_sunset.scss +79 -59
- package/src/styles/themes/_tealcaramel.scss +120 -117
- package/src/styles/themes/_winter.scss +73 -70
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Button component module
|
|
3
3
|
* @module components/button
|
|
4
4
|
*/
|
|
5
|
-
export { default } from
|
|
6
|
-
export { ButtonConfig, ButtonComponent, ButtonVariant } from
|
|
5
|
+
export { default } from "./button";
|
|
6
|
+
export type { ButtonConfig, ButtonComponent, ButtonVariant } from "./types";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ButtonGroupConfig, ButtonGroupComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new Button Group component
|
|
4
|
+
*
|
|
5
|
+
* The Button Group component provides a container for grouping related action buttons.
|
|
6
|
+
* Unlike Segmented Buttons (used for selection), Button Groups are for grouping
|
|
7
|
+
* related actions where each button triggers an independent action.
|
|
8
|
+
*
|
|
9
|
+
* Per Material Design 3 specifications:
|
|
10
|
+
* - Buttons are visually connected with shared borders
|
|
11
|
+
* - Only outer corners are rounded
|
|
12
|
+
* - All buttons share the same variant for visual consistency
|
|
13
|
+
* - Supports horizontal and vertical orientations
|
|
14
|
+
* - Supports density scaling
|
|
15
|
+
*
|
|
16
|
+
* @param {ButtonGroupConfig} config - Button Group configuration
|
|
17
|
+
* @returns {ButtonGroupComponent} Button Group component instance
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Create a horizontal button group for text formatting
|
|
21
|
+
* const formattingTools = createButtonGroup({
|
|
22
|
+
* buttons: [
|
|
23
|
+
* { icon: boldIcon, ariaLabel: 'Bold' },
|
|
24
|
+
* { icon: italicIcon, ariaLabel: 'Italic' },
|
|
25
|
+
* { icon: underlineIcon, ariaLabel: 'Underline' }
|
|
26
|
+
* ],
|
|
27
|
+
* variant: 'outlined',
|
|
28
|
+
* ariaLabel: 'Text formatting options'
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Listen for button clicks
|
|
32
|
+
* formattingTools.on('click', (event) => {
|
|
33
|
+
* console.log('Button clicked:', event.index);
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Create a vertical button group with text labels
|
|
38
|
+
* const navigationGroup = createButtonGroup({
|
|
39
|
+
* buttons: [
|
|
40
|
+
* { text: 'Previous', icon: prevIcon },
|
|
41
|
+
* { text: 'Play', icon: playIcon },
|
|
42
|
+
* { text: 'Next', icon: nextIcon }
|
|
43
|
+
* ],
|
|
44
|
+
* orientation: 'vertical',
|
|
45
|
+
* variant: 'tonal'
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* @category Components
|
|
49
|
+
*/
|
|
50
|
+
declare const createButtonGroup: (config?: ButtonGroupConfig) => ButtonGroupComponent;
|
|
51
|
+
export default createButtonGroup;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ButtonGroupConfig, ButtonGroupVariant, ButtonGroupOrientation, ButtonGroupDensity } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration values for button groups
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_CONFIG: Partial<ButtonGroupConfig>;
|
|
7
|
+
/**
|
|
8
|
+
* Creates the base configuration for Button Group component
|
|
9
|
+
* @param {ButtonGroupConfig} config - User provided configuration
|
|
10
|
+
* @returns {ButtonGroupConfig} Complete configuration with defaults applied
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const createBaseConfig: (config?: ButtonGroupConfig) => ButtonGroupConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Generates element configuration for the Button Group container
|
|
16
|
+
* @param {ButtonGroupConfig} config - Button Group configuration
|
|
17
|
+
* @returns {Object} Element configuration object for withElement
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare const getContainerConfig: (config: ButtonGroupConfig) => {
|
|
21
|
+
tag: string;
|
|
22
|
+
componentName: string;
|
|
23
|
+
attributes: {
|
|
24
|
+
role: string;
|
|
25
|
+
'aria-label': string;
|
|
26
|
+
'data-variant': ButtonGroupVariant;
|
|
27
|
+
'data-orientation': ButtonGroupOrientation;
|
|
28
|
+
'data-density': ButtonGroupDensity;
|
|
29
|
+
};
|
|
30
|
+
className: string[];
|
|
31
|
+
interactive: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Gets density-specific sizing values per MD3 specifications
|
|
35
|
+
* @param {ButtonGroupDensity} density - The density level
|
|
36
|
+
* @returns {Object} CSS variables with sizing values
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare const getDensityStyles: (density: ButtonGroupDensity) => Record<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* Generates configuration for a button element within the group
|
|
42
|
+
* @param {Object} buttonConfig - Button configuration
|
|
43
|
+
* @param {number} index - Button index in the group
|
|
44
|
+
* @param {number} total - Total number of buttons
|
|
45
|
+
* @param {ButtonGroupConfig} groupConfig - Parent group configuration
|
|
46
|
+
* @returns {Object} Button configuration with group-specific settings
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare const getButtonConfig: (buttonConfig: ButtonGroupConfig["buttons"][number], index: number, total: number, groupConfig: ButtonGroupConfig) => {
|
|
50
|
+
variant: ButtonGroupVariant;
|
|
51
|
+
disabled: boolean;
|
|
52
|
+
ripple: boolean;
|
|
53
|
+
rippleConfig: {
|
|
54
|
+
duration?: number;
|
|
55
|
+
timing?: string;
|
|
56
|
+
opacity?: [string, string];
|
|
57
|
+
};
|
|
58
|
+
class: string;
|
|
59
|
+
id?: string;
|
|
60
|
+
text?: string;
|
|
61
|
+
icon?: string;
|
|
62
|
+
ariaLabel?: string;
|
|
63
|
+
value?: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Maps variant name to button variant
|
|
67
|
+
* @param {ButtonGroupVariant} variant - Group variant
|
|
68
|
+
* @returns {string} Button variant name
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export declare const mapVariantToButton: (variant: ButtonGroupVariant) => string;
|
|
72
|
+
/**
|
|
73
|
+
* Validates button group configuration
|
|
74
|
+
* @param {ButtonGroupConfig} config - Configuration to validate
|
|
75
|
+
* @returns {boolean} Whether configuration is valid
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
export declare const validateConfig: (config: ButtonGroupConfig) => boolean;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button group variants
|
|
3
|
+
* All buttons in the group share the same variant for visual consistency
|
|
4
|
+
*/
|
|
5
|
+
export declare const BUTTON_GROUP_VARIANTS: {
|
|
6
|
+
/** Primary action buttons with solid background */
|
|
7
|
+
readonly FILLED: "filled";
|
|
8
|
+
/** Secondary action buttons with medium emphasis */
|
|
9
|
+
readonly TONAL: "tonal";
|
|
10
|
+
/** Buttons with outline border (default for button groups per MD3) */
|
|
11
|
+
readonly OUTLINED: "outlined";
|
|
12
|
+
/** Buttons with slight elevation/shadow */
|
|
13
|
+
readonly ELEVATED: "elevated";
|
|
14
|
+
/** Text-only buttons without background or border */
|
|
15
|
+
readonly TEXT: "text";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Button group orientations
|
|
19
|
+
*/
|
|
20
|
+
export declare const BUTTON_GROUP_ORIENTATIONS: {
|
|
21
|
+
/** Buttons arranged horizontally (default) */
|
|
22
|
+
readonly HORIZONTAL: "horizontal";
|
|
23
|
+
/** Buttons arranged vertically */
|
|
24
|
+
readonly VERTICAL: "vertical";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Density levels for button groups
|
|
28
|
+
* Controls sizing and spacing per MD3 density specifications
|
|
29
|
+
*/
|
|
30
|
+
export declare const BUTTON_GROUP_DENSITY: {
|
|
31
|
+
/** Default size with standard spacing (40px height) */
|
|
32
|
+
readonly DEFAULT: "default";
|
|
33
|
+
/** Reduced size and spacing (36px height) */
|
|
34
|
+
readonly COMFORTABLE: "comfortable";
|
|
35
|
+
/** Minimal size and spacing (32px height) */
|
|
36
|
+
readonly COMPACT: "compact";
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Button group events
|
|
40
|
+
*/
|
|
41
|
+
export declare const BUTTON_GROUP_EVENTS: {
|
|
42
|
+
/** Fired when any button in the group is clicked */
|
|
43
|
+
readonly CLICK: "click";
|
|
44
|
+
/** Fired when a button receives focus */
|
|
45
|
+
readonly FOCUS: "focus";
|
|
46
|
+
/** Fired when a button loses focus */
|
|
47
|
+
readonly BLUR: "blur";
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Default configuration values
|
|
51
|
+
*/
|
|
52
|
+
export declare const BUTTON_GROUP_DEFAULTS: {
|
|
53
|
+
/** Default variant (outlined per MD3 button group specs) */
|
|
54
|
+
readonly VARIANT: "outlined";
|
|
55
|
+
/** Default orientation */
|
|
56
|
+
readonly ORIENTATION: "horizontal";
|
|
57
|
+
/** Default density level */
|
|
58
|
+
readonly DENSITY: "default";
|
|
59
|
+
/** Whether ripple effect is enabled by default */
|
|
60
|
+
readonly RIPPLE: true;
|
|
61
|
+
/** Whether buttons have equal width by default */
|
|
62
|
+
readonly EQUAL_WIDTH: false;
|
|
63
|
+
/** Default ripple animation duration in milliseconds */
|
|
64
|
+
readonly RIPPLE_DURATION: 300;
|
|
65
|
+
/** Default ripple animation timing function */
|
|
66
|
+
readonly RIPPLE_TIMING: "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
67
|
+
/** Default ripple opacity values [start, end] */
|
|
68
|
+
readonly RIPPLE_OPACITY: [string, string];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* CSS classes for button group elements
|
|
72
|
+
* Following BEM naming convention
|
|
73
|
+
*/
|
|
74
|
+
export declare const BUTTON_GROUP_CLASSES: {
|
|
75
|
+
/** Container element */
|
|
76
|
+
readonly ROOT: "button-group";
|
|
77
|
+
/** Individual button within group */
|
|
78
|
+
readonly BUTTON: "button-group__button";
|
|
79
|
+
/** First button in group */
|
|
80
|
+
readonly FIRST: "button-group__button--first";
|
|
81
|
+
/** Last button in group */
|
|
82
|
+
readonly LAST: "button-group__button--last";
|
|
83
|
+
/** Middle buttons (neither first nor last) */
|
|
84
|
+
readonly MIDDLE: "button-group__button--middle";
|
|
85
|
+
/** Single button (only one in group) */
|
|
86
|
+
readonly SINGLE: "button-group__button--single";
|
|
87
|
+
/** Disabled state */
|
|
88
|
+
readonly DISABLED: "button-group--disabled";
|
|
89
|
+
/** Horizontal orientation */
|
|
90
|
+
readonly HORIZONTAL: "button-group--horizontal";
|
|
91
|
+
/** Vertical orientation */
|
|
92
|
+
readonly VERTICAL: "button-group--vertical";
|
|
93
|
+
/** Equal width buttons */
|
|
94
|
+
readonly EQUAL_WIDTH: "button-group--equal-width";
|
|
95
|
+
/** Filled variant */
|
|
96
|
+
readonly FILLED: "button-group--filled";
|
|
97
|
+
/** Tonal variant */
|
|
98
|
+
readonly TONAL: "button-group--tonal";
|
|
99
|
+
/** Outlined variant */
|
|
100
|
+
readonly OUTLINED: "button-group--outlined";
|
|
101
|
+
/** Elevated variant */
|
|
102
|
+
readonly ELEVATED: "button-group--elevated";
|
|
103
|
+
/** Text variant */
|
|
104
|
+
readonly TEXT: "button-group--text";
|
|
105
|
+
/** Default density */
|
|
106
|
+
readonly DENSITY_DEFAULT: "button-group--density-default";
|
|
107
|
+
/** Comfortable density */
|
|
108
|
+
readonly DENSITY_COMFORTABLE: "button-group--density-comfortable";
|
|
109
|
+
/** Compact density */
|
|
110
|
+
readonly DENSITY_COMPACT: "button-group--density-compact";
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Density-specific height values per MD3 specifications
|
|
114
|
+
*/
|
|
115
|
+
export declare const BUTTON_GROUP_HEIGHTS: {
|
|
116
|
+
readonly default: 40;
|
|
117
|
+
readonly comfortable: 36;
|
|
118
|
+
readonly compact: 32;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Border radius values per MD3 specifications
|
|
122
|
+
* Button groups use full-rounded corners on outer edges
|
|
123
|
+
*/
|
|
124
|
+
export declare const BUTTON_GROUP_RADII: {
|
|
125
|
+
readonly default: 20;
|
|
126
|
+
readonly comfortable: 18;
|
|
127
|
+
readonly compact: 16;
|
|
128
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button Group component exports
|
|
3
|
+
*
|
|
4
|
+
* The Button Group component provides a container for grouping related action buttons.
|
|
5
|
+
* Unlike Segmented Buttons (used for selection), Button Groups are for grouping
|
|
6
|
+
* related actions where each button triggers an independent action.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { default as createButtonGroup } from './button-group';
|
|
11
|
+
export { default } from './button-group';
|
|
12
|
+
export type { ButtonGroupConfig, ButtonGroupComponent, ButtonGroupItemConfig, ButtonGroupEvent, ButtonGroupEventType, ButtonGroupVariant, ButtonGroupOrientation, ButtonGroupDensity } from './types';
|
|
13
|
+
export { BUTTON_GROUP_VARIANTS, BUTTON_GROUP_ORIENTATIONS, BUTTON_GROUP_DENSITY, BUTTON_GROUP_EVENTS, BUTTON_GROUP_DEFAULTS, BUTTON_GROUP_CLASSES, BUTTON_GROUP_HEIGHTS, BUTTON_GROUP_RADII } from './constants';
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { ButtonConfig, ButtonComponent } from "../button/types";
|
|
2
|
+
/**
|
|
3
|
+
* Button group orientation
|
|
4
|
+
* @category Components
|
|
5
|
+
*/
|
|
6
|
+
export type ButtonGroupOrientation = "horizontal" | "vertical";
|
|
7
|
+
/**
|
|
8
|
+
* Button group variant - applies to all buttons in the group
|
|
9
|
+
* @category Components
|
|
10
|
+
*/
|
|
11
|
+
export type ButtonGroupVariant = "filled" | "tonal" | "outlined" | "elevated" | "text";
|
|
12
|
+
/**
|
|
13
|
+
* Button group density options
|
|
14
|
+
* Controls the overall sizing and spacing of buttons in the group
|
|
15
|
+
* @category Components
|
|
16
|
+
*/
|
|
17
|
+
export type ButtonGroupDensity = "default" | "comfortable" | "compact";
|
|
18
|
+
/**
|
|
19
|
+
* Event types for button group
|
|
20
|
+
*/
|
|
21
|
+
export type ButtonGroupEventType = "click" | "focus" | "blur";
|
|
22
|
+
/**
|
|
23
|
+
* Event data for button group events
|
|
24
|
+
*/
|
|
25
|
+
export interface ButtonGroupEvent {
|
|
26
|
+
/** The button group component that contains the clicked button */
|
|
27
|
+
buttonGroup: ButtonGroupComponent;
|
|
28
|
+
/** The button component that was clicked */
|
|
29
|
+
button: ButtonComponent;
|
|
30
|
+
/** Index of the button in the group */
|
|
31
|
+
index: number;
|
|
32
|
+
/** Original DOM event */
|
|
33
|
+
originalEvent: Event;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for a single button within a button group
|
|
37
|
+
* Extends ButtonConfig but omits properties controlled by the group
|
|
38
|
+
* @category Components
|
|
39
|
+
*/
|
|
40
|
+
export interface ButtonGroupItemConfig extends Omit<ButtonConfig, "variant"> {
|
|
41
|
+
/**
|
|
42
|
+
* Unique identifier for the button
|
|
43
|
+
* If not provided, index will be used
|
|
44
|
+
*/
|
|
45
|
+
id?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Button text content
|
|
48
|
+
* @example 'Bold'
|
|
49
|
+
*/
|
|
50
|
+
text?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Button icon HTML content
|
|
53
|
+
* @example '<svg>...</svg>'
|
|
54
|
+
*/
|
|
55
|
+
icon?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Accessible label (required for icon-only buttons)
|
|
58
|
+
* @example 'Toggle bold'
|
|
59
|
+
*/
|
|
60
|
+
ariaLabel?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether this button is disabled
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Value associated with this button
|
|
68
|
+
*/
|
|
69
|
+
value?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Additional CSS class for this button
|
|
72
|
+
*/
|
|
73
|
+
class?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Configuration interface for the Button Group component
|
|
77
|
+
* @category Components
|
|
78
|
+
*/
|
|
79
|
+
export interface ButtonGroupConfig {
|
|
80
|
+
/**
|
|
81
|
+
* Array of button configurations
|
|
82
|
+
*/
|
|
83
|
+
buttons?: ButtonGroupItemConfig[];
|
|
84
|
+
/**
|
|
85
|
+
* Visual variant applied to all buttons in the group
|
|
86
|
+
* @default 'outlined'
|
|
87
|
+
*/
|
|
88
|
+
variant?: ButtonGroupVariant;
|
|
89
|
+
/**
|
|
90
|
+
* Orientation of the button group
|
|
91
|
+
* @default 'horizontal'
|
|
92
|
+
*/
|
|
93
|
+
orientation?: ButtonGroupOrientation;
|
|
94
|
+
/**
|
|
95
|
+
* Density setting that controls button sizing
|
|
96
|
+
* @default 'default'
|
|
97
|
+
*/
|
|
98
|
+
density?: ButtonGroupDensity;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the entire button group is disabled
|
|
101
|
+
* @default false
|
|
102
|
+
*/
|
|
103
|
+
disabled?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether buttons should have equal width
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
equalWidth?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Component prefix for class names
|
|
111
|
+
* @default 'mtrl'
|
|
112
|
+
*/
|
|
113
|
+
prefix?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Component name used in class generation
|
|
116
|
+
*/
|
|
117
|
+
componentName?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Additional CSS class for the button group container
|
|
120
|
+
*/
|
|
121
|
+
class?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Whether to enable ripple effect on buttons
|
|
124
|
+
* @default true
|
|
125
|
+
*/
|
|
126
|
+
ripple?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Ripple effect configuration
|
|
129
|
+
*/
|
|
130
|
+
rippleConfig?: {
|
|
131
|
+
/** Duration of the ripple animation in milliseconds */
|
|
132
|
+
duration?: number;
|
|
133
|
+
/** Timing function for the ripple animation */
|
|
134
|
+
timing?: string;
|
|
135
|
+
/** Opacity values for ripple start and end [start, end] */
|
|
136
|
+
opacity?: [string, string];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Accessible label for the button group
|
|
140
|
+
* @example 'Text formatting options'
|
|
141
|
+
*/
|
|
142
|
+
ariaLabel?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Event handlers for button group events
|
|
145
|
+
*/
|
|
146
|
+
on?: {
|
|
147
|
+
[key in ButtonGroupEventType]?: (event: ButtonGroupEvent) => void;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Button Group component interface
|
|
152
|
+
* @category Components
|
|
153
|
+
*/
|
|
154
|
+
export interface ButtonGroupComponent {
|
|
155
|
+
/** The component's container DOM element */
|
|
156
|
+
element: HTMLElement;
|
|
157
|
+
/** Array of button component instances */
|
|
158
|
+
buttons: ButtonComponent[];
|
|
159
|
+
/**
|
|
160
|
+
* Gets a button by its index
|
|
161
|
+
* @param index - Button index
|
|
162
|
+
* @returns The button component or undefined
|
|
163
|
+
*/
|
|
164
|
+
getButton: (index: number) => ButtonComponent | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Gets a button by its id or value
|
|
167
|
+
* @param id - Button id or value
|
|
168
|
+
* @returns The button component or undefined
|
|
169
|
+
*/
|
|
170
|
+
getButtonById: (id: string) => ButtonComponent | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Gets the current variant
|
|
173
|
+
* @returns Current variant name
|
|
174
|
+
*/
|
|
175
|
+
getVariant: () => ButtonGroupVariant;
|
|
176
|
+
/**
|
|
177
|
+
* Sets the variant for all buttons in the group
|
|
178
|
+
* @param variant - New variant to apply
|
|
179
|
+
* @returns The ButtonGroupComponent for chaining
|
|
180
|
+
*/
|
|
181
|
+
setVariant: (variant: ButtonGroupVariant) => ButtonGroupComponent;
|
|
182
|
+
/**
|
|
183
|
+
* Gets the current orientation
|
|
184
|
+
* @returns Current orientation
|
|
185
|
+
*/
|
|
186
|
+
getOrientation: () => ButtonGroupOrientation;
|
|
187
|
+
/**
|
|
188
|
+
* Sets the orientation of the button group
|
|
189
|
+
* @param orientation - New orientation
|
|
190
|
+
* @returns The ButtonGroupComponent for chaining
|
|
191
|
+
*/
|
|
192
|
+
setOrientation: (orientation: ButtonGroupOrientation) => ButtonGroupComponent;
|
|
193
|
+
/**
|
|
194
|
+
* Gets the current density
|
|
195
|
+
* @returns Current density
|
|
196
|
+
*/
|
|
197
|
+
getDensity: () => ButtonGroupDensity;
|
|
198
|
+
/**
|
|
199
|
+
* Sets the density of the button group
|
|
200
|
+
* @param density - New density level
|
|
201
|
+
* @returns The ButtonGroupComponent for chaining
|
|
202
|
+
*/
|
|
203
|
+
setDensity: (density: ButtonGroupDensity) => ButtonGroupComponent;
|
|
204
|
+
/**
|
|
205
|
+
* Enables the entire button group
|
|
206
|
+
* @returns The ButtonGroupComponent for chaining
|
|
207
|
+
*/
|
|
208
|
+
enable: () => ButtonGroupComponent;
|
|
209
|
+
/**
|
|
210
|
+
* Disables the entire button group
|
|
211
|
+
* @returns The ButtonGroupComponent for chaining
|
|
212
|
+
*/
|
|
213
|
+
disable: () => ButtonGroupComponent;
|
|
214
|
+
/**
|
|
215
|
+
* Enables a specific button by index
|
|
216
|
+
* @param index - Button index
|
|
217
|
+
* @returns The ButtonGroupComponent for chaining
|
|
218
|
+
*/
|
|
219
|
+
enableButton: (index: number) => ButtonGroupComponent;
|
|
220
|
+
/**
|
|
221
|
+
* Disables a specific button by index
|
|
222
|
+
* @param index - Button index
|
|
223
|
+
* @returns The ButtonGroupComponent for chaining
|
|
224
|
+
*/
|
|
225
|
+
disableButton: (index: number) => ButtonGroupComponent;
|
|
226
|
+
/**
|
|
227
|
+
* Adds an event listener to the button group
|
|
228
|
+
* @param event - Event name
|
|
229
|
+
* @param handler - Event handler function
|
|
230
|
+
* @returns The ButtonGroupComponent for chaining
|
|
231
|
+
*/
|
|
232
|
+
on: (event: ButtonGroupEventType, handler: (event: ButtonGroupEvent) => void) => ButtonGroupComponent;
|
|
233
|
+
/**
|
|
234
|
+
* Removes an event listener from the button group
|
|
235
|
+
* @param event - Event name
|
|
236
|
+
* @param handler - Event handler function
|
|
237
|
+
* @returns The ButtonGroupComponent for chaining
|
|
238
|
+
*/
|
|
239
|
+
off: (event: ButtonGroupEventType, handler: (event: ButtonGroupEvent) => void) => ButtonGroupComponent;
|
|
240
|
+
/**
|
|
241
|
+
* Destroys the component and cleans up resources
|
|
242
|
+
*/
|
|
243
|
+
destroy: () => void;
|
|
244
|
+
}
|
|
@@ -11,12 +11,15 @@
|
|
|
11
11
|
export { LIST_DEFAULTS, LIST_TYPES, LIST_SELECTION_MODES, LIST_EVENTS, LIST_SCROLL_POSITIONS, LIST_CLASSES, } from "./list/constants";
|
|
12
12
|
export type { ListConfig, ListComponent, SelectEvent as ListSelectEvent, // Rename to avoid collision
|
|
13
13
|
LoadEvent, } from "./list/types";
|
|
14
|
+
export { BUTTON_GROUP_VARIANTS, BUTTON_GROUP_ORIENTATIONS, BUTTON_GROUP_DENSITY, BUTTON_GROUP_EVENTS, BUTTON_GROUP_DEFAULTS, BUTTON_GROUP_CLASSES, BUTTON_GROUP_HEIGHTS, BUTTON_GROUP_RADII, } from "./button-group/constants";
|
|
15
|
+
export type { ButtonGroupConfig, ButtonGroupComponent, ButtonGroupItemConfig, ButtonGroupEvent, ButtonGroupEventType, ButtonGroupVariant, ButtonGroupOrientation, ButtonGroupDensity, } from "./button-group/types";
|
|
14
16
|
export { SELECT_VARIANTS, SELECT_PLACEMENT, SELECT_INTERACTION, SELECT_EVENTS, SELECT_ICONS, SELECT_DEFAULTS, SELECT_CLASSES, } from "./select/constants";
|
|
15
17
|
export type { SelectConfig, SelectComponent, SelectOption, SelectEvent, // Keep the original name since select is more commonly used
|
|
16
18
|
SelectChangeEvent, } from "./select/types";
|
|
17
19
|
export * from "./badge";
|
|
18
20
|
export * from "./bottom-app-bar";
|
|
19
21
|
export * from "./button";
|
|
22
|
+
export * from "./button-group";
|
|
20
23
|
export * from "./card";
|
|
21
24
|
export * from "./carousel";
|
|
22
25
|
export * from "./checkbox";
|
|
@@ -48,6 +51,7 @@ export { createCardContent, createCardHeader, createCardActions, createCardMedia
|
|
|
48
51
|
export { default as createBadge } from "./badge";
|
|
49
52
|
export { default as createBottomAppBar } from "./bottom-app-bar";
|
|
50
53
|
export { default as createButton } from "./button";
|
|
54
|
+
export { default as createButtonGroup } from "./button-group";
|
|
51
55
|
export { default as createCard } from "./card";
|
|
52
56
|
export { default as createCarousel } from "./carousel";
|
|
53
57
|
export { default as createCheckbox } from "./checkbox";
|
|
@@ -175,6 +175,12 @@ export interface MenuConfig {
|
|
|
175
175
|
* @default false
|
|
176
176
|
*/
|
|
177
177
|
visible?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Container element to append the menu to
|
|
180
|
+
* If not provided, menu will be appended to document.body
|
|
181
|
+
* Use this when the menu needs to stay within a specific container (e.g., inside a dialog)
|
|
182
|
+
*/
|
|
183
|
+
container?: HTMLElement | null;
|
|
178
184
|
/**
|
|
179
185
|
* Additional CSS classes to add to the menu
|
|
180
186
|
*/
|
|
@@ -42,13 +42,16 @@ export declare const SEGMENTED_BUTTON_DEFAULTS: {
|
|
|
42
42
|
/** Default ripple opacity values [start, end] */
|
|
43
43
|
readonly RIPPLE_OPACITY: readonly ["0.2", "0"];
|
|
44
44
|
};
|
|
45
|
-
export declare const DEFAULT_CHECKMARK_ICON = "\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polyline points=\"20 6 9 17 4 12\"></polyline>\n</svg>";
|
|
46
45
|
/**
|
|
47
|
-
* Default checkmark icon for selected segments
|
|
46
|
+
* Default checkmark icon for selected segments (MD3 filled style)
|
|
47
|
+
*/
|
|
48
|
+
export declare const DEFAULT_CHECKMARK_ICON = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\"/></svg>";
|
|
49
|
+
/**
|
|
50
|
+
* Segmented button icons
|
|
48
51
|
*/
|
|
49
52
|
export declare const SEGMENTED_BUTTON_ICONS: {
|
|
50
|
-
/** Default checkmark icon */
|
|
51
|
-
readonly CHECKMARK: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"
|
|
53
|
+
/** Default checkmark icon (filled) */
|
|
54
|
+
readonly CHECKMARK: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\"/></svg>";
|
|
52
55
|
};
|
|
53
56
|
/**
|
|
54
57
|
* CSS classes for segmented button elements
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { SegmentConfig, Segment } from
|
|
1
|
+
import { SegmentConfig, Segment } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a segment for the segmented button using the button component
|
|
4
|
+
*
|
|
5
|
+
* Per MD3 specifications:
|
|
6
|
+
* - Text-only segments: Show checkmark BEFORE text when selected
|
|
7
|
+
* - Icon + text segments: Replace icon with checkmark when selected
|
|
8
|
+
* - Icon-only segments: Do NOT show checkmark (icon remains unchanged)
|
|
9
|
+
*
|
|
4
10
|
* @param {SegmentConfig} config - Segment configuration
|
|
5
11
|
* @param {HTMLElement} container - Container element
|
|
6
12
|
* @param {string} prefix - Component prefix
|