mtrl 0.8.0-next.13 → 0.8.0-next.15

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.
Files changed (35) hide show
  1. package/dist/components/card/index.d.ts +1 -1
  2. package/dist/components/dialog/config.d.ts +1 -5
  3. package/dist/components/dialog/features.d.ts +0 -5
  4. package/dist/components/dialog/index.d.ts +1 -1
  5. package/dist/components/dialog/types.d.ts +13 -2
  6. package/dist/components/extended-fab/index.d.ts +1 -1
  7. package/dist/components/fab/index.d.ts +1 -1
  8. package/dist/components/index.d.ts +2 -0
  9. package/dist/components/navigation/index.d.ts +1 -1
  10. package/dist/components/radios/index.d.ts +1 -1
  11. package/dist/components/sheet/index.d.ts +1 -1
  12. package/dist/components/slider/index.d.ts +1 -1
  13. package/dist/components/split-button/api.d.ts +14 -0
  14. package/dist/components/split-button/config.d.ts +40 -0
  15. package/dist/components/split-button/constants.d.ts +67 -0
  16. package/dist/components/split-button/features/buttons.d.ts +7 -0
  17. package/dist/components/split-button/features/menu.d.ts +7 -0
  18. package/dist/components/split-button/index.d.ts +3 -0
  19. package/dist/components/split-button/split-button.d.ts +24 -0
  20. package/dist/components/split-button/types.d.ts +116 -0
  21. package/dist/components/switch/index.d.ts +3 -2
  22. package/dist/components/tabs/index.d.ts +3 -2
  23. package/dist/components/textfield/index.d.ts +1 -1
  24. package/dist/components/tooltip/index.d.ts +1 -1
  25. package/dist/index.cjs +13 -13
  26. package/dist/index.cjs.map +13 -7
  27. package/dist/index.js +13 -13
  28. package/dist/index.js.map +13 -7
  29. package/dist/package.json +1 -1
  30. package/dist/styles.css +2 -2
  31. package/package.json +1 -1
  32. package/src/styles/abstract/_variables.scss +3 -0
  33. package/src/styles/components/_dialog.scss +86 -22
  34. package/src/styles/components/_split-button.scss +185 -0
  35. package/src/styles/main.scss +1 -0
@@ -65,7 +65,7 @@ export { default } from "./card";
65
65
  *
66
66
  * These types define the structure and behavior of the Card component.
67
67
  */
68
- export { CardVariant, CardElevationLevel, CardSchema, CardHeaderConfig, CardContentConfig, CardActionsConfig, CardMediaConfig, CardAriaAttributes, CardComponent, LoadingFeature, ExpandableFeature, SwipeableFeature, } from "./types";
68
+ export type { CardVariant, CardElevationLevel, CardSchema, CardHeaderConfig, CardContentConfig, CardActionsConfig, CardMediaConfig, CardAriaAttributes, CardComponent, LoadingFeature, ExpandableFeature, SwipeableFeature, } from "./types";
69
69
  export { createCardContent, createCardHeader, createCardActions, createCardMedia, } from "./content";
70
70
  export { withAPI } from "./api";
71
71
  export { withLoading, withExpandable, withSwipeable, withElevation, } from "./features";
@@ -43,11 +43,7 @@ export declare const getElementConfig: (config: DialogConfig) => {
43
43
  */
44
44
  export declare const getOverlayConfig: (config: DialogConfig) => {
45
45
  tag: string;
46
- attributes: {
47
- 'aria-modal': boolean;
48
- role: string;
49
- tabindex: number;
50
- };
46
+ attributes: {};
51
47
  className: string;
52
48
  };
53
49
  /**
@@ -1,9 +1,4 @@
1
1
  import { DialogConfig } from "./types";
2
- /**
3
- * Creates the dialog DOM structure with proper divider handling
4
- * @param config Dialog configuration
5
- * @returns Component enhancer with DOM structure
6
- */
7
2
  export declare const withStructure: (config: DialogConfig) => (component: any) => any;
8
3
  /**
9
4
  * Add methods to manage dividers
@@ -11,4 +11,4 @@
11
11
  * @category Components
12
12
  */
13
13
  export { default } from "./dialog";
14
- export { DialogConfig, DialogComponent, DialogButton, DialogEvent, DialogConfirmOptions, DialogSize, DialogAnimation, DialogFooterAlignment, DialogEventType, } from "./types";
14
+ export type { DialogConfig, DialogComponent, DialogButton, DialogEvent, DialogConfirmOptions, DialogSize, DialogAnimation, DialogFooterAlignment, DialogEventType, } from "./types";
@@ -71,10 +71,21 @@ export interface DialogConfig {
71
71
  */
72
72
  content?: string;
73
73
  /**
74
- * Whether to show close button (X) in the header
75
- * @default true
74
+ * Whether to show a close affordance in the header. A basic dialog has
75
+ * none in M3: it is dismissed by its actions. A full-screen dialog shows
76
+ * one unless this is set to false.
77
+ * @default false (true for the fullscreen size)
76
78
  */
77
79
  closeButton?: boolean;
80
+ /**
81
+ * Accessible name for a dialog without a headline
82
+ */
83
+ ariaLabel?: string;
84
+ /**
85
+ * ARIA role for the dialog. A basic dialog is an `alertdialog` and a
86
+ * full-screen one a `dialog`; set this to override.
87
+ */
88
+ role?: 'alertdialog' | 'dialog';
78
89
  /**
79
90
  * Additional CSS classes to apply to the dialog
80
91
  * @example "settings-dialog important-dialog"
@@ -33,4 +33,4 @@
33
33
  * @category Components
34
34
  */
35
35
  export { default, default as createExtendedFab } from './extended-fab';
36
- export { ExtendedFabConfig, ExtendedFabComponent, ExtendedFabVariant, ExtendedFabWidth, ExtendedFabPosition } from './types';
36
+ export type { ExtendedFabConfig, ExtendedFabComponent, ExtendedFabVariant, ExtendedFabWidth, ExtendedFabPosition } from './types';
@@ -32,4 +32,4 @@
32
32
  * @category Components
33
33
  */
34
34
  export { default, default as createFab } from "./fab";
35
- export { FabConfig, FabComponent, FabVariant, FabSize, FabPosition, } from "./types";
35
+ export type { FabConfig, FabComponent, FabVariant, FabSize, FabPosition, } from "./types";
@@ -28,6 +28,7 @@ export { default as createNavigation } from "./navigation";
28
28
  export { default as createNavigationSystem } from "./navigation/system";
29
29
  export { default as createProgress } from "./progress";
30
30
  export { default as createLoadingIndicator } from "./loading-indicator";
31
+ export { default as createSplitButton } from "./split-button";
31
32
  export { default as createRadios } from "./radios";
32
33
  export { default as createSearch } from "./search";
33
34
  export { default as createSelect } from "./select";
@@ -63,6 +64,7 @@ export type { ExtendedFabConfig, ExtendedFabComponent, } from "./extended-fab/ty
63
64
  export type { IconButtonConfig, IconButtonComponent, } from "./icon-button/types";
64
65
  export type { ListConfig, ListComponent, SelectEvent as ListSelectEvent, LoadEvent, } from "./list/types";
65
66
  export type { MenuConfig, MenuComponent, MenuItem } from "./menu/types";
67
+ export type { SplitButtonConfig, SplitButtonComponent, } from "./split-button/types";
66
68
  export type { LoadingIndicatorConfig, LoadingIndicatorComponent, } from "./loading-indicator/types";
67
69
  export type { ProgressConfig, ProgressComponent, ProgressShape, } from "./progress/types";
68
70
  export type { RadiosConfig, RadiosComponent, RadioOptionConfig, } from "./radios/types";
@@ -1,3 +1,3 @@
1
1
  export { default } from './navigation';
2
- export { NavigationConfig, NavigationComponent, NavItemConfig, NavGroupConfig } from './types';
2
+ export type { NavigationConfig, NavigationComponent, NavItemConfig, NavGroupConfig } from './types';
3
3
  export { NAV_VARIANTS, NAV_POSITIONS, NAV_BEHAVIORS, NAV_ITEM_STATES, NAV_EVENTS, NAV_DEFAULTS, NAV_CLASSES } from './constants';
@@ -1,3 +1,3 @@
1
1
  export { default } from './radios';
2
- export { RadiosConfig, RadiosComponent, RadioOptionConfig } from './types';
2
+ export type { RadiosConfig, RadiosComponent, RadioOptionConfig } from './types';
3
3
  export { RADIO_STATES, RADIO_DIRECTIONS, RADIO_VARIANTS, RADIO_LABEL_POSITIONS, RADIO_SIZES, RADIO_EVENTS, RADIO_DEFAULTS, RADIO_CLASSES } from './constants';
@@ -1,3 +1,3 @@
1
1
  export { default } from './sheet';
2
2
  export { SHEET_VARIANTS, SHEET_POSITIONS, SHEET_EVENTS, SHEET_ELEVATION, SHEET_DEFAULTS, SHEET_ANIMATION, SHEET_GESTURE, SHEET_CLASSES } from './constants';
3
- export { SheetConfig, SheetComponent } from './types';
3
+ export type { SheetConfig, SheetComponent } from './types';
@@ -1,2 +1,2 @@
1
1
  export { default } from "./slider";
2
- export { type SliderConfig, type SliderComponent, type SliderEvent, } from "./types";
2
+ export type { SliderConfig, SliderComponent, SliderEvent, } from "./types";
@@ -0,0 +1,14 @@
1
+ import { BaseComponent, SplitButtonComponent, SplitButtonConfig } from "./types";
2
+ interface ApiOptions {
3
+ config: SplitButtonConfig;
4
+ lifecycle: {
5
+ destroy: () => void;
6
+ };
7
+ }
8
+ /**
9
+ * Adds the public API and wires the two buttons together
10
+ * @param {ApiOptions} options - API configuration
11
+ * @returns {Function} Higher-order function that adds the API
12
+ */
13
+ export declare const withAPI: ({ config, lifecycle }: ApiOptions) => (component: BaseComponent) => SplitButtonComponent;
14
+ export {};
@@ -0,0 +1,40 @@
1
+ import { SplitButtonConfig } from "./types";
2
+ /**
3
+ * Default configuration
4
+ */
5
+ export declare const defaultConfig: Partial<SplitButtonConfig>;
6
+ /**
7
+ * Creates the base configuration with the defaults applied
8
+ * @param {SplitButtonConfig} config - User provided configuration
9
+ * @returns {SplitButtonConfig} Complete configuration
10
+ */
11
+ export declare const createBaseConfig: (config?: SplitButtonConfig) => SplitButtonConfig;
12
+ /**
13
+ * Element configuration. The two buttons are a group, so a screen reader
14
+ * announces them together and the group can carry a name of its own.
15
+ * @param {SplitButtonConfig} config - Configuration
16
+ * @returns {Object} Element configuration for withElement
17
+ */
18
+ export declare const getElementConfig: (config: SplitButtonConfig) => {
19
+ tag: string;
20
+ componentName: string;
21
+ attributes: Record<string, any>;
22
+ className: string[];
23
+ rawClass: string | string[];
24
+ id: string;
25
+ name: string;
26
+ title: string;
27
+ tabIndex: number;
28
+ style: string | Partial<CSSStyleDeclaration>;
29
+ data: Record<string, string>;
30
+ role: string;
31
+ ariaLabel: string;
32
+ ariaDescribedBy: string;
33
+ ariaLabelledBy: string;
34
+ ariaHidden: boolean;
35
+ html: string;
36
+ text: string;
37
+ forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
38
+ interactive: boolean;
39
+ };
40
+ export default defaultConfig;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Visual styles, the same set the button offers
3
+ * @category Components
4
+ */
5
+ export declare const SPLIT_BUTTON_VARIANTS: {
6
+ readonly FILLED: "filled";
7
+ readonly TONAL: "tonal";
8
+ readonly OUTLINED: "outlined";
9
+ readonly ELEVATED: "elevated";
10
+ };
11
+ /**
12
+ * Sizes, matching the button and icon button scale
13
+ * @category Components
14
+ */
15
+ export declare const SPLIT_BUTTON_SIZES: {
16
+ readonly XS: "xs";
17
+ readonly S: "s";
18
+ readonly M: "m";
19
+ readonly L: "l";
20
+ readonly XL: "xl";
21
+ };
22
+ /**
23
+ * Events the component emits
24
+ * @category Components
25
+ */
26
+ export declare const SPLIT_BUTTON_EVENTS: {
27
+ /** The leading button was activated */
28
+ readonly CLICK: "click";
29
+ /** The trailing button opened whatever it opens */
30
+ readonly EXPAND: "expand";
31
+ /** The trailing button closed it */
32
+ readonly COLLAPSE: "collapse";
33
+ /** Either of the two, carrying the new state */
34
+ readonly CHANGE: "change";
35
+ /** A menu item was chosen, when the component owns a menu */
36
+ readonly SELECT: "select";
37
+ };
38
+ /**
39
+ * Defaults
40
+ * @category Components
41
+ */
42
+ export declare const SPLIT_BUTTON_DEFAULTS: {
43
+ readonly VARIANT: "filled";
44
+ readonly SIZE: "s";
45
+ /** Accessible name of the trailing button when none is given */
46
+ readonly TRAILING_LABEL: "More options";
47
+ /** How far the menu sits from the button (M3 split button guidelines) */
48
+ readonly MENU_OFFSET: 4;
49
+ };
50
+ /**
51
+ * CSS class names, without the prefix
52
+ * @category Components
53
+ */
54
+ export declare const SPLIT_BUTTON_CLASSES: {
55
+ readonly ROOT: "split-button";
56
+ readonly LEADING: "split-button__leading";
57
+ readonly TRAILING: "split-button__trailing";
58
+ readonly CHEVRON: "split-button__chevron";
59
+ readonly EXPANDED: "split-button--expanded";
60
+ };
61
+ /**
62
+ * The trailing button's icon. It always points down and turns 180 degrees
63
+ * when the button is activated, so it should not be swapped out
64
+ * (M3 split button guidelines, "Anatomy").
65
+ * @category Components
66
+ */
67
+ export declare const SPLIT_BUTTON_CHEVRON: string;
@@ -0,0 +1,7 @@
1
+ import { BaseComponent, SplitButtonConfig } from "../types";
2
+ /**
3
+ * Adds the leading and trailing buttons
4
+ * @param {SplitButtonConfig} config - Component configuration
5
+ * @returns {Function} Higher-order function that adds both buttons
6
+ */
7
+ export declare const withButtons: (config: SplitButtonConfig) => (component: BaseComponent) => BaseComponent;
@@ -0,0 +1,7 @@
1
+ import { BaseComponent, SplitButtonConfig } from "../types";
2
+ /**
3
+ * Adds a menu anchored to the trailing button
4
+ * @param {SplitButtonConfig} config - Component configuration
5
+ * @returns {Function} Higher-order function that adds the menu
6
+ */
7
+ export declare const withMenu: (config: SplitButtonConfig) => (component: BaseComponent) => BaseComponent;
@@ -0,0 +1,3 @@
1
+ export { default } from "./split-button";
2
+ export type { SplitButtonConfig, SplitButtonComponent, SplitButtonEvent, SplitButtonVariant, SplitButtonSize, } from "./types";
3
+ export { SPLIT_BUTTON_VARIANTS, SPLIT_BUTTON_SIZES, SPLIT_BUTTON_EVENTS, } from "./constants";
@@ -0,0 +1,24 @@
1
+ import { SplitButtonConfig, SplitButtonComponent } from "./types";
2
+ /**
3
+ * Creates a split button: one action beside a button that opens more choices.
4
+ *
5
+ * @param {SplitButtonConfig} config - Split button configuration
6
+ * @returns {SplitButtonComponent} Split button component instance
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const button = createSplitButton({
11
+ * text: 'Watch later',
12
+ * icon: watchIcon,
13
+ * trailingLabel: 'More watch options',
14
+ * items: [
15
+ * { id: 'queue', text: 'Add to queue' },
16
+ * { id: 'playlist', text: 'Save to playlist' }
17
+ * ],
18
+ * onClick: () => watchLater(),
19
+ * onSelect: ({ item }) => choose(item.id)
20
+ * });
21
+ * ```
22
+ */
23
+ declare const createSplitButton: (config?: SplitButtonConfig) => SplitButtonComponent;
24
+ export default createSplitButton;
@@ -0,0 +1,116 @@
1
+ import type { MenuContent, MenuComponent } from "../menu/types";
2
+ /** Visual style, the same set the button offers */
3
+ export type SplitButtonVariant = "filled" | "tonal" | "outlined" | "elevated";
4
+ /** Size, matching the button and icon button scale */
5
+ export type SplitButtonSize = "xs" | "s" | "m" | "l" | "xl";
6
+ /** Events the component emits */
7
+ export type SplitButtonEventType = "click" | "expand" | "collapse" | "change" | "select";
8
+ /** What an event handler receives */
9
+ export interface SplitButtonEvent {
10
+ /** The component that emitted it */
11
+ splitButton: SplitButtonComponent;
12
+ /** Whether the trailing button is showing its menu */
13
+ expanded: boolean;
14
+ /** The DOM event behind it, when there was one */
15
+ originalEvent: Event | null;
16
+ /** The chosen item, on a `select` event */
17
+ item?: MenuContent;
18
+ }
19
+ /**
20
+ * Configuration for the split button
21
+ * @interface SplitButtonConfig
22
+ */
23
+ export interface SplitButtonConfig {
24
+ /** Label of the leading button */
25
+ text?: string;
26
+ /** Icon of the leading button, as an HTML string */
27
+ icon?: string;
28
+ /** Visual style, shared by both buttons */
29
+ variant?: SplitButtonVariant;
30
+ /** Size of both buttons */
31
+ size?: SplitButtonSize;
32
+ /** Whether both buttons are disabled */
33
+ disabled?: boolean;
34
+ /**
35
+ * Accessible name of the trailing button. It should say that more choices
36
+ * are available and how they relate to the leading action, such as
37
+ * "More watch options" beside a "Watch later" button (M3 split button
38
+ * accessibility).
39
+ * @default 'More options'
40
+ */
41
+ trailingLabel?: string;
42
+ /** Accessible name of the leading button, when its label is not enough */
43
+ ariaLabel?: string;
44
+ /** Accessible name of the whole group */
45
+ groupLabel?: string;
46
+ /** What the leading button does */
47
+ onClick?: (event: SplitButtonEvent) => void;
48
+ /**
49
+ * Menu items for the trailing button to open. Without them the component
50
+ * only reports that the trailing button was activated, and the caller
51
+ * shows whatever it likes.
52
+ */
53
+ items?: MenuContent[];
54
+ /** Called with the chosen item when the component owns the menu */
55
+ onSelect?: (event: SplitButtonEvent) => void;
56
+ /** Additional CSS classes */
57
+ class?: string;
58
+ /** Component prefix for CSS class names */
59
+ prefix?: string;
60
+ /** Component name for CSS class names */
61
+ componentName?: string;
62
+ /** Event handlers */
63
+ on?: {
64
+ [key in SplitButtonEventType]?: (event: SplitButtonEvent) => void;
65
+ };
66
+ }
67
+ /**
68
+ * The split button's public API
69
+ * @interface SplitButtonComponent
70
+ */
71
+ export interface SplitButtonComponent {
72
+ /** The element holding both buttons */
73
+ element: HTMLElement;
74
+ /** The leading button's element */
75
+ leadingElement: HTMLButtonElement;
76
+ /** The trailing button's element */
77
+ trailingElement: HTMLButtonElement;
78
+ /** The menu, when the component was given items */
79
+ menu?: MenuComponent;
80
+ /** Sets the leading button's label */
81
+ setText: (text: string) => SplitButtonComponent;
82
+ /** The leading button's label */
83
+ getText: () => string;
84
+ /** Sets the leading button's icon */
85
+ setIcon: (icon: string) => SplitButtonComponent;
86
+ /** Opens whatever the trailing button opens */
87
+ expand: () => SplitButtonComponent;
88
+ /** Closes it */
89
+ collapse: () => SplitButtonComponent;
90
+ /** Whether it is open */
91
+ isExpanded: () => boolean;
92
+ /** Disables both buttons */
93
+ disable: () => SplitButtonComponent;
94
+ /** Enables both buttons */
95
+ enable: () => SplitButtonComponent;
96
+ /** Whether both buttons are disabled */
97
+ isDisabled: () => boolean;
98
+ /** Adds an event listener */
99
+ on: (event: SplitButtonEventType, handler: (event: SplitButtonEvent) => void) => SplitButtonComponent;
100
+ /** Removes an event listener */
101
+ off: (event: SplitButtonEventType, handler: (event: SplitButtonEvent) => void) => SplitButtonComponent;
102
+ /** Takes the component off the page and releases what it holds */
103
+ destroy: () => void;
104
+ }
105
+ /** The component as it passes through the enhancers */
106
+ export interface BaseComponent {
107
+ element: HTMLElement;
108
+ emit?: (event: string, data?: unknown) => void;
109
+ on?: (event: string, handler: (...args: unknown[]) => void) => unknown;
110
+ off?: (event: string, handler: (...args: unknown[]) => void) => unknown;
111
+ getClass?: (name: string) => string;
112
+ lifecycle?: {
113
+ destroy?: () => void;
114
+ };
115
+ [key: string]: unknown;
116
+ }
@@ -1,4 +1,5 @@
1
1
  export { default } from './switch';
2
2
  export { SWITCH_LABEL_POSITIONS, SWITCH_STATES, SWITCH_EVENTS, SWITCH_DEFAULTS, SWITCH_CLASSES } from './constants';
3
- export { SwitchConfig, SwitchComponent } from './types';
4
- export { withSupportingText, SupportingTextComponent } from './features';
3
+ export type { SwitchConfig, SwitchComponent } from './types';
4
+ export { withSupportingText } from './features';
5
+ export type { SupportingTextComponent } from './features';
@@ -5,7 +5,8 @@ import { createTabsState } from "./state";
5
5
  import { createTabIndicator } from "./indicator";
6
6
  import { updateTabPanels, setupKeyboardNavigation } from "./utils";
7
7
  export { TAB_VARIANTS, TAB_STATES, TAB_INDICATOR_WIDTH_STRATEGIES, TAB_EVENTS, TABS_EVENTS, TABS_DEFAULTS, TABS_CLASSES, TAB_CLASSES, } from "./constants";
8
- export { TabsConfig, TabsComponent, TabComponent, TabConfig, TabChangeEventData, IndicatorConfig, } from "./types";
8
+ export type { TabsConfig, TabsComponent, TabComponent, TabConfig, TabChangeEventData, IndicatorConfig, } from "./types";
9
9
  export { addScrollIndicators, setupResponsiveBehavior, createTabsState, createTabIndicator, updateTabPanels, setupKeyboardNavigation, };
10
- export { withTabsManagement, withScrollable, withDivider, withIndicator, TabsManagementConfig, TabsManagementComponent, ScrollableConfig, ScrollableComponent, DividerConfig, IndicatorFeatureConfig, IndicatorComponent, } from "./features";
10
+ export { withTabsManagement, withScrollable, withDivider, withIndicator } from "./features";
11
+ export type { TabsManagementConfig, TabsManagementComponent, ScrollableConfig, ScrollableComponent, DividerConfig, IndicatorFeatureConfig, IndicatorComponent } from "./features";
11
12
  export default createTabs;
@@ -1,2 +1,2 @@
1
1
  export { default } from "./textfield";
2
- export { TextfieldConfig, TextfieldComponent, TextfieldDensity } from "./types";
2
+ export type { TextfieldConfig, TextfieldComponent, TextfieldDensity } from "./types";
@@ -1,3 +1,3 @@
1
1
  export { default } from './tooltip';
2
2
  export { TOOLTIP_POSITIONS, TOOLTIP_VARIANTS, TOOLTIP_EVENTS, TOOLTIP_DEFAULTS, TOOLTIP_CLASSES } from './constants';
3
- export { TooltipConfig, TooltipComponent } from './types';
3
+ export type { TooltipConfig, TooltipComponent } from './types';