mtrl 0.9.8 → 0.10.0-next.0
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/badge/api.d.ts +14 -20
- package/dist/components/badge/api.js +4 -5
- package/dist/components/badge/config.d.ts +549 -17
- package/dist/components/badge/config.js +7 -0
- package/dist/components/badge/features.d.ts +9 -7
- package/dist/components/badge/features.js +13 -12
- package/dist/components/badge/types.d.ts +38 -0
- package/dist/components/bottom-app-bar/bottom-app-bar.js +6 -2
- package/dist/components/bottom-app-bar/constants.d.ts +2 -2
- package/dist/components/bottom-app-bar/constants.js +2 -2
- package/dist/components/bottom-app-bar/types.d.ts +4 -4
- package/dist/components/bottom-sheet/config.d.ts +531 -17
- package/dist/components/bottom-sheet/constants.d.ts +6 -6
- package/dist/components/bottom-sheet/constants.js +6 -6
- package/dist/components/bottom-sheet/features/structure.d.ts +3 -3
- package/dist/components/button/api.d.ts +3 -2
- package/dist/components/button/api.js +1 -1
- package/dist/components/button/button.d.ts +2 -2
- package/dist/components/button/config.d.ts +531 -17
- package/dist/components/button/constants.d.ts +2 -2
- package/dist/components/button/constants.js +2 -2
- package/dist/components/button/features/progress.js +4 -4
- package/dist/components/button/types.d.ts +50 -6
- package/dist/components/button-group/button-group.js +5 -5
- package/dist/components/button-group/config.d.ts +64 -25
- package/dist/components/button-group/types.d.ts +24 -2
- package/dist/components/card/config.d.ts +532 -18
- package/dist/components/card/features.js +10 -8
- package/dist/components/card/types.d.ts +10 -0
- package/dist/components/carousel/config.d.ts +531 -17
- package/dist/components/checkbox/config.d.ts +531 -17
- package/dist/components/checkbox/config.js +1 -1
- package/dist/components/checkbox/constants.d.ts +3 -3
- package/dist/components/checkbox/constants.js +3 -3
- package/dist/components/checkbox/types.d.ts +10 -0
- package/dist/components/chips/api.d.ts +12 -3
- package/dist/components/chips/chip/config.d.ts +534 -20
- package/dist/components/chips/config.d.ts +562 -53
- package/dist/components/chips/config.js +10 -8
- package/dist/components/chips/features/chip-items.d.ts +33 -2
- package/dist/components/chips/features/container.d.ts +68 -1
- package/dist/components/chips/features/container.js +1 -1
- package/dist/components/chips/features/controller.d.ts +53 -2
- package/dist/components/chips/features/controller.js +2 -6
- package/dist/components/chips/features/dom.js +2 -2
- package/dist/components/chips/features/label.d.ts +69 -1
- package/dist/components/chips/features/label.js +2 -2
- package/dist/components/chips/schema.d.ts +8 -6
- package/dist/components/chips/schema.js +2 -2
- package/dist/components/chips/types.d.ts +49 -0
- package/dist/components/datepicker/config.d.ts +1596 -54
- package/dist/components/datepicker/datepicker.js +6 -5
- package/dist/components/dialog/api.d.ts +6 -1
- package/dist/components/dialog/api.js +1 -1
- package/dist/components/dialog/config.d.ts +549 -63
- package/dist/components/dialog/constants.d.ts +9 -9
- package/dist/components/dialog/constants.js +9 -9
- package/dist/components/dialog/features.d.ts +18 -8
- package/dist/components/dialog/features.js +44 -42
- package/dist/components/dialog/types.d.ts +77 -0
- package/dist/components/divider/features.d.ts +4 -4
- package/dist/components/divider/types.d.ts +31 -13
- package/dist/components/drawer/config.d.ts +533 -19
- package/dist/components/drawer/drawer.d.ts +2 -2
- package/dist/components/extended-fab/config.d.ts +531 -17
- package/dist/components/extended-fab/constants.d.ts +2 -2
- package/dist/components/extended-fab/constants.js +2 -2
- package/dist/components/fab/config.d.ts +533 -19
- package/dist/components/fab/config.js +7 -6
- package/dist/components/fab/constants.d.ts +1 -1
- package/dist/components/fab/constants.js +1 -1
- package/dist/components/fab/fab.d.ts +1 -1
- package/dist/components/fab/fab.js +1 -1
- package/dist/components/fab/types.d.ts +6 -1
- package/dist/components/icon-button/config.d.ts +534 -20
- package/dist/components/icon-button/config.js +8 -7
- package/dist/components/icon-button/icon-button.d.ts +1 -1
- package/dist/components/icon-button/icon-button.js +1 -1
- package/dist/components/icon-button/types.d.ts +6 -1
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -2
- package/dist/components/list/api.d.ts +865 -13
- package/dist/components/list/api.js +18 -18
- package/dist/components/list/config.d.ts +589 -42
- package/dist/components/list/config.js +3 -2
- package/dist/components/list/features/renderer.d.ts +4 -1
- package/dist/components/list/features/renderer.js +3 -8
- package/dist/components/list/features/selection.d.ts +2 -1
- package/dist/components/list/features/selection.js +42 -32
- package/dist/components/list/list.d.ts +4 -22
- package/dist/components/list/list.js +0 -1
- package/dist/components/list/types.d.ts +103 -0
- package/dist/components/loading-indicator/config.d.ts +531 -17
- package/dist/components/menu/api.d.ts +5 -1
- package/dist/components/menu/config.d.ts +535 -47
- package/dist/components/menu/config.js +9 -11
- package/dist/components/menu/features/controller.d.ts +4 -2
- package/dist/components/menu/features/controller.js +26 -46
- package/dist/components/menu/features/keyboard.d.ts +3 -19
- package/dist/components/menu/features/keyboard.js +11 -11
- package/dist/components/menu/features/opener.d.ts +8 -2
- package/dist/components/menu/features/opener.js +1 -5
- package/dist/components/menu/features/position.d.ts +3 -3
- package/dist/components/menu/features/submenu.d.ts +20 -2
- package/dist/components/menu/features/submenu.js +4 -11
- package/dist/components/menu/features/tasks.d.ts +1 -1
- package/dist/components/menu/types.d.ts +131 -0
- package/dist/components/navigation-rail/navigation-rail.js +2 -1
- package/dist/components/navigation-rail/types.d.ts +10 -0
- package/dist/components/progress/api.js +3 -2
- package/dist/components/progress/config.d.ts +567 -29
- package/dist/components/progress/config.js +9 -15
- package/dist/components/progress/features/canvas.js +1 -1
- package/dist/components/progress/features/state.d.ts +2 -3
- package/dist/components/progress/features/state.js +2 -1
- package/dist/components/radios/config.d.ts +537 -21
- package/dist/components/radios/radio.d.ts +19 -2
- package/dist/components/radios/radio.js +18 -13
- package/dist/components/search/config.d.ts +548 -34
- package/dist/components/search/features/input.d.ts +85 -2
- package/dist/components/search/features/states.d.ts +99 -2
- package/dist/components/search/features/structure.d.ts +10 -2
- package/dist/components/search/features/suggestions.d.ts +53 -1
- package/dist/components/segmented-button/config.d.ts +5 -5
- package/dist/components/segmented-button/segment.js +1 -1
- package/dist/components/segmented-button/segmented-button.js +20 -7
- package/dist/components/select/features.js +26 -4
- package/dist/components/select/types.d.ts +2 -2
- package/dist/components/side-sheet/config.d.ts +531 -17
- package/dist/components/side-sheet/constants.d.ts +8 -8
- package/dist/components/side-sheet/constants.js +8 -8
- package/dist/components/side-sheet/features/structure.d.ts +3 -3
- package/dist/components/slider/api.d.ts +10 -6
- package/dist/components/slider/config.d.ts +570 -56
- package/dist/components/slider/config.js +7 -6
- package/dist/components/slider/features/controller.d.ts +520 -2
- package/dist/components/slider/features/controller.js +9 -11
- package/dist/components/slider/features/dom.js +5 -5
- package/dist/components/slider/features/handlers.d.ts +11 -20
- package/dist/components/slider/features/handlers.js +21 -18
- package/dist/components/slider/features/range.d.ts +7 -1
- package/dist/components/slider/features/range.js +3 -3
- package/dist/components/slider/features/states.d.ts +71 -1
- package/dist/components/slider/features/tracks.d.ts +28 -2
- package/dist/components/slider/features/tracks.js +9 -9
- package/dist/components/slider/types.d.ts +135 -0
- package/dist/components/snackbar/config.d.ts +531 -17
- package/dist/components/snackbar/constants.d.ts +3 -3
- package/dist/components/snackbar/constants.js +3 -3
- package/dist/components/snackbar/index.d.ts +1 -1
- package/dist/components/snackbar/types.d.ts +27 -4
- package/dist/components/split-button/api.js +2 -2
- package/dist/components/split-button/config.d.ts +531 -17
- package/dist/components/switch/config.d.ts +531 -17
- package/dist/components/switch/constants.d.ts +8 -8
- package/dist/components/switch/constants.js +8 -8
- package/dist/components/switch/features.js +8 -8
- package/dist/components/switch/types.d.ts +10 -0
- package/dist/components/tabs/api.d.ts +6 -9
- package/dist/components/tabs/api.js +14 -3
- package/dist/components/tabs/config.d.ts +3 -18
- package/dist/components/tabs/config.js +1 -12
- package/dist/components/tabs/constants.d.ts +3 -3
- package/dist/components/tabs/constants.js +3 -3
- package/dist/components/tabs/features.d.ts +5 -3
- package/dist/components/tabs/features.js +5 -3
- package/dist/components/tabs/indicator.js +4 -4
- package/dist/components/tabs/scroll-indicators.js +11 -11
- package/dist/components/tabs/tab.d.ts +13 -0
- package/dist/components/tabs/tab.js +5 -13
- package/dist/components/tabs/types.d.ts +20 -6
- package/dist/components/tabs/utils.d.ts +31 -1
- package/dist/components/tabs/utils.js +44 -29
- package/dist/components/textfield/config.d.ts +536 -20
- package/dist/components/textfield/config.js +3 -3
- package/dist/components/textfield/constants.d.ts +5 -5
- package/dist/components/textfield/constants.js +5 -5
- package/dist/components/textfield/features/density.d.ts +1 -1
- package/dist/components/textfield/features/leading-icon.d.ts +16 -2
- package/dist/components/textfield/features/leading-icon.js +1 -1
- package/dist/components/textfield/features/placement.js +3 -3
- package/dist/components/textfield/features/prefix-text.d.ts +16 -2
- package/dist/components/textfield/features/prefix-text.js +1 -1
- package/dist/components/textfield/features/suffix-text.d.ts +16 -2
- package/dist/components/textfield/features/suffix-text.js +1 -1
- package/dist/components/textfield/features/supporting-text.js +2 -2
- package/dist/components/textfield/features/trailing-icon.d.ts +16 -2
- package/dist/components/textfield/features/trailing-icon.js +1 -1
- package/dist/components/textfield/types.d.ts +10 -0
- package/dist/components/timepicker/api.d.ts +2 -2
- package/dist/components/timepicker/api.js +3 -1
- package/dist/components/timepicker/clockdial.js +7 -8
- package/dist/components/timepicker/config.d.ts +1602 -60
- package/dist/components/timepicker/render.d.ts +2 -2
- package/dist/components/timepicker/render.js +44 -29
- package/dist/components/timepicker/types.d.ts +11 -0
- package/dist/components/tooltip/config.d.ts +534 -19
- package/dist/components/tooltip/constants.d.ts +1 -1
- package/dist/components/tooltip/constants.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/top-app-bar/constants.d.ts +6 -6
- package/dist/components/top-app-bar/constants.js +6 -6
- package/dist/components/top-app-bar/top-app-bar.js +11 -7
- package/dist/components/top-app-bar/types.d.ts +5 -5
- package/dist/core/compose/component.d.ts +5 -3
- package/dist/core/compose/component.js +1 -1
- package/dist/core/compose/features/events.d.ts +3 -3
- package/dist/core/compose/features/icon.js +1 -1
- package/dist/core/compose/features/input.d.ts +18 -5
- package/dist/core/compose/features/input.js +2 -1
- package/dist/core/compose/features/text.js +1 -1
- package/dist/core/compose/features/textinput.d.ts +22 -8
- package/dist/core/compose/features/textinput.js +2 -1
- package/dist/core/compose/features/textlabel.js +1 -1
- package/dist/core/compose/features/track.js +3 -3
- package/dist/core/compose/features/withEvents.d.ts +2 -2
- package/dist/core/compose/features/withEvents.js +8 -2
- package/dist/core/config/component.d.ts +546 -42
- package/dist/core/config/component.js +3 -11
- package/dist/core/config/global.d.ts +0 -22
- package/dist/core/config.d.ts +0 -33
- package/dist/core/config.js +1 -58
- package/dist/core/dom/attributes.js +9 -3
- package/dist/core/dom/classes.js +8 -26
- package/dist/core/dom/create.d.ts +11 -1
- package/dist/core/dom/create.js +3 -7
- package/dist/core/dom/utils.js +2 -1
- package/dist/core/index.d.ts +1 -5
- package/dist/core/index.js +1 -3
- package/dist/core/state/index.d.ts +0 -4
- package/dist/core/state/index.js +0 -2
- package/dist/core/utils/attributes.d.ts +29 -0
- package/dist/core/utils/attributes.js +11 -0
- package/dist/core/utils/warn.d.ts +8 -0
- package/dist/core/utils/warn.js +15 -0
- package/dist/index.cjs +0 -0
- package/dist/package.json +1 -1
- package/dist/styles/badge.css +2 -2
- package/dist/styles/base.css +2 -2
- package/dist/styles/bottom-app-bar.css +2 -2
- package/dist/styles/bottom-sheet.css +2 -2
- package/dist/styles/button-group.css +2 -2
- package/dist/styles/button.css +2 -2
- package/dist/styles/card.css +2 -2
- package/dist/styles/carousel.css +2 -2
- package/dist/styles/checkbox.css +2 -2
- package/dist/styles/chips.css +2 -2
- package/dist/styles/dialog.css +2 -2
- package/dist/styles/divider.css +2 -2
- package/dist/styles/drawer.css +2 -2
- package/dist/styles/extended-fab.css +2 -2
- package/dist/styles/fab.css +2 -2
- package/dist/styles/icon-button.css +2 -2
- package/dist/styles/list.css +2 -2
- package/dist/styles/loading-indicator.css +2 -2
- package/dist/styles/menu.css +2 -2
- package/dist/styles/navigation-rail.css +2 -2
- package/dist/styles/progress.css +2 -2
- package/dist/styles/radios.css +2 -2
- package/dist/styles/search.css +2 -2
- package/dist/styles/segmented-button.css +2 -2
- package/dist/styles/select.css +2 -2
- package/dist/styles/side-sheet.css +2 -2
- package/dist/styles/slider.css +2 -2
- package/dist/styles/snackbar.css +2 -2
- package/dist/styles/split-button.css +2 -2
- package/dist/styles/switch.css +2 -2
- package/dist/styles/tabs.css +2 -2
- package/dist/styles/textfield.css +2 -2
- package/dist/styles/timepicker.css +2 -2
- package/dist/styles/tooltip.css +2 -2
- package/dist/styles/top-app-bar.css +2 -2
- package/dist/styles/utilities.css +2 -2
- package/dist/styles.css +2 -2
- package/dist/themes/autumn.css +1 -1
- package/dist/themes/baseline.css +1 -1
- package/dist/themes/brownbeige.css +1 -1
- package/dist/themes/browngreen.css +1 -1
- package/dist/themes/desert.css +1 -1
- package/dist/themes/forest.css +1 -1
- package/dist/themes/highcontrast.css +1 -1
- package/dist/themes/legacy.css +1 -1
- package/dist/themes/material.css +1 -1
- package/dist/themes/ocean.css +1 -1
- package/dist/themes/sageivory.css +1 -1
- package/dist/themes/spring.css +1 -1
- package/dist/themes/summer.css +1 -1
- package/dist/themes/sunset.css +1 -1
- package/dist/themes/tealcaramel.css +1 -1
- package/dist/themes/winter.css +1 -1
- package/package.json +5 -1
- package/src/styles/components/_badge.scss +1 -1
- package/src/styles/components/_bottom-app-bar.scss +5 -5
- package/src/styles/components/_bottom-sheet.scss +17 -17
- package/src/styles/components/_button-group.scss +2 -2
- package/src/styles/components/_button.scss +12 -12
- package/src/styles/components/_checkbox.scss +25 -25
- package/src/styles/components/_chips.scss +5 -5
- package/src/styles/components/_dialog.scss +36 -36
- package/src/styles/components/_extended-fab.scss +7 -7
- package/src/styles/components/_fab.scss +4 -4
- package/src/styles/components/_icon-button.scss +5 -5
- package/src/styles/components/_menu.scss +25 -25
- package/src/styles/components/_progress.scss +1 -1
- package/src/styles/components/_radios.scss +18 -18
- package/src/styles/components/_segmented-button.scss +6 -6
- package/src/styles/components/_select.scss +22 -22
- package/src/styles/components/_side-sheet.scss +20 -20
- package/src/styles/components/_slider.scss +20 -20
- package/src/styles/components/_snackbar.scss +7 -7
- package/src/styles/components/_split-button.scss +1 -1
- package/src/styles/components/_switch.scss +36 -36
- package/src/styles/components/_tabs.scss +31 -20
- package/src/styles/components/_textfield.scss +153 -153
- package/src/styles/components/_timepicker.scss +24 -8
- package/src/styles/components/_top-app-bar.scss +20 -20
- package/src/styles/main.scss +0 -1
- package/dist/components/navigation/api.d.ts +0 -8
- package/dist/components/navigation/api.js +0 -117
- package/dist/components/navigation/config.d.ts +0 -45
- package/dist/components/navigation/config.js +0 -39
- package/dist/components/navigation/constants.d.ts +0 -137
- package/dist/components/navigation/constants.js +0 -65
- package/dist/components/navigation/features/controller.d.ts +0 -28
- package/dist/components/navigation/features/controller.js +0 -173
- package/dist/components/navigation/features/items.d.ts +0 -32
- package/dist/components/navigation/features/items.js +0 -236
- package/dist/components/navigation/index.d.ts +0 -3
- package/dist/components/navigation/index.js +0 -2
- package/dist/components/navigation/nav-item.d.ts +0 -30
- package/dist/components/navigation/nav-item.js +0 -119
- package/dist/components/navigation/navigation.d.ts +0 -8
- package/dist/components/navigation/navigation.js +0 -52
- package/dist/components/navigation/system/core.d.ts +0 -72
- package/dist/components/navigation/system/core.js +0 -148
- package/dist/components/navigation/system/events.d.ts +0 -35
- package/dist/components/navigation/system/events.js +0 -126
- package/dist/components/navigation/system/index.d.ts +0 -10
- package/dist/components/navigation/system/index.js +0 -92
- package/dist/components/navigation/system/mobile.d.ts +0 -52
- package/dist/components/navigation/system/mobile.js +0 -140
- package/dist/components/navigation/system/state.d.ts +0 -22
- package/dist/components/navigation/system/state.js +0 -44
- package/dist/components/navigation/system/types.d.ts +0 -337
- package/dist/components/navigation/system/types.js +0 -1
- package/dist/components/navigation/types.d.ts +0 -225
- package/dist/components/navigation/types.js +0 -33
- package/dist/core/state/disabled.d.ts +0 -32
- package/dist/core/state/disabled.js +0 -26
- package/dist/core/state/lifecycle.d.ts +0 -56
- package/dist/core/state/lifecycle.js +0 -51
- package/dist/styles/navigation.css +0 -2
- package/dist/styles/navigation.d.ts +0 -1
- package/dist/styles/navigation.js +0 -2
- package/src/styles/components/_navigation-mobile.scss +0 -244
- package/src/styles/components/_navigation-system.scss +0 -153
- package/src/styles/components/_navigation.scss +0 -407
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import { BadgeConfig } from "./types.js";
|
|
1
|
+
import { BadgeConfig, BadgeFeatureHost, BadgeVisibility } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Higher-order function that adds visibility control features to a component
|
|
4
4
|
* @returns {Function} Component enhancer with visibility features
|
|
5
5
|
*/
|
|
6
|
-
export declare const withVisibility: () => (component:
|
|
6
|
+
export declare const withVisibility: () => <C extends BadgeFeatureHost>(component: C) => C & {
|
|
7
|
+
visibility: BadgeVisibility;
|
|
8
|
+
};
|
|
7
9
|
/**
|
|
8
10
|
* Higher-order function that adds variant features to a badge component
|
|
9
11
|
* @param {BadgeConfig} config - Badge configuration
|
|
10
12
|
* @returns {Function} Component enhancer with variant features
|
|
11
13
|
*/
|
|
12
|
-
export declare const withVariant: (config: BadgeConfig) => (component:
|
|
14
|
+
export declare const withVariant: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
|
|
13
15
|
/**
|
|
14
16
|
* Higher-order function that adds color features to a badge component
|
|
15
17
|
* @param {BadgeConfig} config - Badge configuration
|
|
16
18
|
* @returns {Function} Component enhancer with color features
|
|
17
19
|
*/
|
|
18
|
-
export declare const withColor: (config: BadgeConfig) => (component:
|
|
20
|
+
export declare const withColor: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
|
|
19
21
|
/**
|
|
20
22
|
* Higher-order function that adds positioning features to a badge component
|
|
21
23
|
* @param {BadgeConfig} config - Badge configuration
|
|
22
24
|
* @returns {Function} Component enhancer with positioning features
|
|
23
25
|
*/
|
|
24
|
-
export declare const withPosition: (config: BadgeConfig) => (component:
|
|
26
|
+
export declare const withPosition: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
|
|
25
27
|
/**
|
|
26
28
|
* Higher-order function that adds max value features to a badge component
|
|
27
29
|
* @param {BadgeConfig} config - Badge configuration
|
|
28
30
|
* @returns {Function} Component enhancer with max value features
|
|
29
31
|
*/
|
|
30
|
-
export declare const withMax: (config: BadgeConfig) => (component:
|
|
32
|
+
export declare const withMax: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
|
|
31
33
|
/**
|
|
32
34
|
* Higher-order function that attaches badge to a target element
|
|
33
35
|
* @param {BadgeConfig} config - Badge configuration
|
|
34
36
|
* @returns {Function} Component enhancer with attachment features
|
|
35
37
|
*/
|
|
36
|
-
export declare const withAttachment: (config: BadgeConfig) => (component:
|
|
38
|
+
export declare const withAttachment: (config: BadgeConfig) => <C extends BadgeFeatureHost>(component: C) => C;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { formatBadgeLabel } from "./config.js";
|
|
1
|
+
import { formatBadgeLabel, isBadgeOverflow, isEmptyBadgeLabel } from "./config.js";
|
|
2
2
|
const VARIANT_SMALL = 'small';
|
|
3
3
|
const VARIANT_LARGE = 'large';
|
|
4
4
|
const COLOR_ERROR = 'error';
|
|
5
5
|
const POSITION_TOP_RIGHT = 'top-right';
|
|
6
|
-
export const withVisibility = () => component => {
|
|
6
|
+
export const withVisibility = () => (component) => {
|
|
7
7
|
const visible = component.config.visible !== false;
|
|
8
|
-
|
|
8
|
+
const nothingToShow = isEmptyBadgeLabel(formatBadgeLabel(component.config.label ?? "", component.config.max));
|
|
9
|
+
if (!visible || nothingToShow) {
|
|
9
10
|
component.element.classList.add(`${component.getClass('badge')}--invisible`);
|
|
10
11
|
}
|
|
11
12
|
return {
|
|
@@ -34,7 +35,7 @@ export const withVisibility = () => component => {
|
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
|
-
export const withVariant = (config) => component => {
|
|
38
|
+
export const withVariant = (config) => (component) => {
|
|
38
39
|
const variant = config.variant || VARIANT_LARGE;
|
|
39
40
|
component.element.classList.add(`${component.getClass('badge')}--${variant}`);
|
|
40
41
|
if (variant === VARIANT_SMALL) {
|
|
@@ -50,39 +51,39 @@ export const withVariant = (config) => component => {
|
|
|
50
51
|
}
|
|
51
52
|
return component;
|
|
52
53
|
};
|
|
53
|
-
export const withColor = (config) => component => {
|
|
54
|
+
export const withColor = (config) => (component) => {
|
|
54
55
|
const color = config.color || COLOR_ERROR;
|
|
55
56
|
component.element.classList.add(`${component.getClass('badge')}--${color}`);
|
|
56
57
|
return component;
|
|
57
58
|
};
|
|
58
|
-
export const withPosition = (config) => component => {
|
|
59
|
+
export const withPosition = (config) => (component) => {
|
|
59
60
|
const position = config.position || POSITION_TOP_RIGHT;
|
|
60
61
|
component.element.classList.add(`${component.getClass('badge')}--${position}`);
|
|
61
|
-
if (config.target) {
|
|
62
|
+
if (config.target && config.target.parentNode) {
|
|
62
63
|
component.element.classList.add(`${component.getClass('badge')}--positioned`);
|
|
63
64
|
}
|
|
64
65
|
return component;
|
|
65
66
|
};
|
|
66
|
-
export const withMax = (config) => component => {
|
|
67
|
+
export const withMax = (config) => (component) => {
|
|
67
68
|
if (config.max === undefined || config.variant === VARIANT_SMALL) {
|
|
68
69
|
return component;
|
|
69
70
|
}
|
|
70
71
|
component.config.max = config.max;
|
|
71
|
-
if (config.label !== undefined
|
|
72
|
+
if (config.label !== undefined) {
|
|
72
73
|
const formattedLabel = formatBadgeLabel(config.label, config.max);
|
|
73
74
|
component.element.textContent = formattedLabel;
|
|
74
|
-
if (
|
|
75
|
+
if (isBadgeOverflow(config.label, config.max)) {
|
|
75
76
|
component.element.classList.add(`${component.getClass('badge')}--overflow`);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
return component;
|
|
79
80
|
};
|
|
80
|
-
export const withAttachment = (config) => component => {
|
|
81
|
+
export const withAttachment = (config) => (component) => {
|
|
81
82
|
if (!config.target) {
|
|
82
83
|
return component;
|
|
83
84
|
}
|
|
84
85
|
const wrapper = document.createElement('div');
|
|
85
|
-
wrapper.classList.add(component.getClass('
|
|
86
|
+
wrapper.classList.add(component.getClass('badge__wrapper'));
|
|
86
87
|
wrapper.style.position = 'relative';
|
|
87
88
|
const parent = config.target.parentNode;
|
|
88
89
|
if (parent) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ElementComponent } from "../../core/compose/component.js";
|
|
1
2
|
/**
|
|
2
3
|
* Badge variant types - determines the badge size and appearance
|
|
3
4
|
* @category Components
|
|
@@ -96,6 +97,43 @@ export interface BadgeConfig {
|
|
|
96
97
|
*/
|
|
97
98
|
componentName?: string;
|
|
98
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The visibility control withVisibility installs on a badge.
|
|
102
|
+
*
|
|
103
|
+
* Named because three places need the same shape: the feature that builds it,
|
|
104
|
+
* getApiConfig that forwards it, and withAPI that wraps it.
|
|
105
|
+
*
|
|
106
|
+
* @category Components
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export interface BadgeVisibility {
|
|
110
|
+
/** Shows the badge */
|
|
111
|
+
show: () => void;
|
|
112
|
+
/** Hides the badge */
|
|
113
|
+
hide: () => void;
|
|
114
|
+
/** Toggles badge visibility, or forces it when given a flag */
|
|
115
|
+
toggle: (visible?: boolean) => void;
|
|
116
|
+
/** Whether the badge is currently visible */
|
|
117
|
+
isVisible: () => boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* What a badge feature enhancer needs from the component it is handed.
|
|
121
|
+
*
|
|
122
|
+
* The badge pipe is createBase, withEvents, withElement, then these features --
|
|
123
|
+
* so the element half is installed before any of them runs, which is why
|
|
124
|
+
* `element` and `getClass` are required rather than optional.
|
|
125
|
+
*
|
|
126
|
+
* `config` is the badge's own config: createBase keeps the type it was created
|
|
127
|
+
* with, so a feature reading `config.variant` gets BadgeVariant and not
|
|
128
|
+
* `unknown`. `wrapper` is written by withAttachment, not read by it.
|
|
129
|
+
*
|
|
130
|
+
* @category Components
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export interface BadgeFeatureHost extends ElementComponent {
|
|
134
|
+
config: BadgeConfig & Record<string, unknown>;
|
|
135
|
+
wrapper?: HTMLElement;
|
|
136
|
+
}
|
|
99
137
|
/**
|
|
100
138
|
* Badge component interface
|
|
101
139
|
* Provides methods for controlling a Material Design 3 badge
|
|
@@ -4,9 +4,9 @@ export const createBottomAppBar = (config = {}) => {
|
|
|
4
4
|
const componentConfig = createConfig(config);
|
|
5
5
|
const component = createBase(componentConfig);
|
|
6
6
|
const actionsContainer = document.createElement("div");
|
|
7
|
-
actionsContainer.className = `${component.getClass("bottom-app-bar")}
|
|
7
|
+
actionsContainer.className = `${component.getClass("bottom-app-bar")}__actions`;
|
|
8
8
|
const fabContainer = document.createElement("div");
|
|
9
|
-
fabContainer.className = `${component.getClass("bottom-app-bar")}-
|
|
9
|
+
fabContainer.className = `${component.getClass("bottom-app-bar")}__fab-container`;
|
|
10
10
|
const enhancedComponent = withElement({
|
|
11
11
|
tag: componentConfig.tag,
|
|
12
12
|
componentName: "bottom-app-bar",
|
|
@@ -55,6 +55,10 @@ export const createBottomAppBar = (config = {}) => {
|
|
|
55
55
|
}
|
|
56
56
|
const bottomBar = {
|
|
57
57
|
...withLifecycleComponent,
|
|
58
|
+
addClass(...classes) {
|
|
59
|
+
withLifecycleComponent.addClass(...classes);
|
|
60
|
+
return this;
|
|
61
|
+
},
|
|
58
62
|
destroy() {
|
|
59
63
|
withLifecycleComponent.lifecycle.destroy();
|
|
60
64
|
},
|
|
@@ -14,8 +14,8 @@ export declare const DEFAULT_TRANSITION_DURATION = 300;
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const BOTTOM_APP_BAR_CLASSES: {
|
|
16
16
|
readonly ROOT: "bottom-app-bar";
|
|
17
|
-
readonly ACTIONS: "bottom-app-
|
|
18
|
-
readonly FAB_CONTAINER: "bottom-app-
|
|
17
|
+
readonly ACTIONS: "bottom-app-bar__actions";
|
|
18
|
+
readonly FAB_CONTAINER: "bottom-app-bar__fab-container";
|
|
19
19
|
readonly HIDDEN: "bottom-app-bar--hidden";
|
|
20
20
|
readonly FAB_CENTER: "bottom-app-bar--fab-center";
|
|
21
21
|
readonly FAB_END: "bottom-app-bar--fab-end";
|
|
@@ -5,8 +5,8 @@ export const FAB_POSITIONS = {
|
|
|
5
5
|
export const DEFAULT_TRANSITION_DURATION = 300;
|
|
6
6
|
export const BOTTOM_APP_BAR_CLASSES = {
|
|
7
7
|
ROOT: 'bottom-app-bar',
|
|
8
|
-
ACTIONS: 'bottom-app-
|
|
9
|
-
FAB_CONTAINER: 'bottom-app-
|
|
8
|
+
ACTIONS: 'bottom-app-bar__actions',
|
|
9
|
+
FAB_CONTAINER: 'bottom-app-bar__fab-container',
|
|
10
10
|
HIDDEN: 'bottom-app-bar--hidden',
|
|
11
11
|
FAB_CENTER: 'bottom-app-bar--fab-center',
|
|
12
12
|
FAB_END: 'bottom-app-bar--fab-end'
|
|
@@ -66,23 +66,23 @@ export interface BottomAppBar extends ElementComponent {
|
|
|
66
66
|
* @param {HTMLElement} button - Button element to add
|
|
67
67
|
* @returns {BottomAppBar} BottomAppBar instance for chaining
|
|
68
68
|
*/
|
|
69
|
-
addAction
|
|
69
|
+
addAction(button: HTMLElement): this;
|
|
70
70
|
/**
|
|
71
71
|
* Adds a floating action button to the bottom bar
|
|
72
72
|
* @param {HTMLElement} fab - FAB element to add
|
|
73
73
|
* @returns {BottomAppBar} BottomAppBar instance for chaining
|
|
74
74
|
*/
|
|
75
|
-
addFab
|
|
75
|
+
addFab(fab: HTMLElement): this;
|
|
76
76
|
/**
|
|
77
77
|
* Shows the bottom bar
|
|
78
78
|
* @returns {BottomAppBar} BottomAppBar instance for chaining
|
|
79
79
|
*/
|
|
80
|
-
show
|
|
80
|
+
show(): this;
|
|
81
81
|
/**
|
|
82
82
|
* Hides the bottom bar
|
|
83
83
|
* @returns {BottomAppBar} BottomAppBar instance for chaining
|
|
84
84
|
*/
|
|
85
|
-
hide
|
|
85
|
+
hide(): this;
|
|
86
86
|
/**
|
|
87
87
|
* Checks if the bottom bar is visible
|
|
88
88
|
* @returns {boolean} Whether the bottom bar is visible
|