mtrl 0.10.0-next.0 → 0.10.0-next.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/README.md +55 -1
- package/dist/README.md +55 -1
- package/dist/components/button/constants.d.ts +2 -2
- package/dist/components/button/constants.js +2 -2
- package/dist/components/button/types.d.ts +6 -5
- package/dist/components/button-group/types.d.ts +3 -3
- package/dist/components/card/api.js +8 -8
- package/dist/components/card/card.d.ts +1 -1
- package/dist/components/card/config.js +1 -1
- package/dist/components/card/constants.d.ts +18 -15
- package/dist/components/card/constants.js +15 -15
- package/dist/components/card/content.js +20 -20
- package/dist/components/card/features.js +14 -13
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/card/types.d.ts +4 -4
- package/dist/components/carousel/api.d.ts +4 -3
- package/dist/components/carousel/index.d.ts +1 -1
- package/dist/components/carousel/types.d.ts +13 -2
- package/dist/components/checkbox/api.d.ts +1 -1
- package/dist/components/checkbox/api.js +4 -0
- package/dist/components/checkbox/checkbox.d.ts +1 -2
- package/dist/components/checkbox/checkbox.js +9 -0
- package/dist/components/checkbox/config.d.ts +2 -2
- package/dist/components/checkbox/config.js +1 -1
- package/dist/components/checkbox/constants.d.ts +2 -5
- package/dist/components/checkbox/index.d.ts +4 -4
- package/dist/components/checkbox/types.d.ts +44 -9
- package/dist/components/chips/api.d.ts +3 -2
- package/dist/components/chips/chip/chip.d.ts +2 -6
- package/dist/components/chips/chip/chip.js +253 -68
- package/dist/components/chips/chip/index.d.ts +0 -1
- package/dist/components/chips/chip/index.js +0 -1
- package/dist/components/chips/config.d.ts +5 -12
- package/dist/components/chips/config.js +9 -10
- package/dist/components/chips/constants.d.ts +15 -41
- package/dist/components/chips/constants.js +4 -17
- package/dist/components/chips/factories.d.ts +9 -0
- package/dist/components/chips/factories.js +5 -0
- package/dist/components/chips/features/controller.d.ts +7 -6
- package/dist/components/chips/features/controller.js +96 -105
- package/dist/components/chips/features/dom.d.ts +10 -1
- package/dist/components/chips/features/dom.js +39 -10
- package/dist/components/chips/features/index.d.ts +0 -1
- package/dist/components/chips/features/index.js +0 -1
- package/dist/components/chips/index.d.ts +2 -2
- package/dist/components/chips/index.js +1 -1
- package/dist/components/chips/types.d.ts +120 -238
- package/dist/components/chips/types.js +1 -11
- package/dist/components/datepicker/api.d.ts +7 -18
- package/dist/components/datepicker/api.js +6 -179
- package/dist/components/datepicker/config.d.ts +5 -1129
- package/dist/components/datepicker/config.js +6 -84
- package/dist/components/datepicker/constants.d.ts +22 -14
- package/dist/components/datepicker/constants.js +21 -14
- package/dist/components/datepicker/datepicker.d.ts +2 -6
- package/dist/components/datepicker/datepicker.js +624 -235
- package/dist/components/datepicker/index.d.ts +1 -1
- package/dist/components/datepicker/render.d.ts +3 -51
- package/dist/components/datepicker/render.js +150 -280
- package/dist/components/datepicker/types.d.ts +64 -80
- package/dist/components/datepicker/types.js +6 -6
- package/dist/components/datepicker/utils.d.ts +2 -7
- package/dist/components/datepicker/utils.js +46 -20
- package/dist/components/dialog/api.d.ts +3 -2
- package/dist/components/dialog/config.d.ts +3 -2
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/dialog/features.d.ts +4 -4
- package/dist/components/dialog/features.js +13 -13
- package/dist/components/dialog/types.d.ts +2 -1
- package/dist/components/drawer/api.d.ts +4 -3
- package/dist/components/drawer/config.d.ts +1 -1
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/types.d.ts +12 -2
- package/dist/components/extended-fab/api.d.ts +3 -2
- package/dist/components/extended-fab/config.js +1 -1
- package/dist/components/extended-fab/index.d.ts +1 -1
- package/dist/components/extended-fab/types.d.ts +27 -14
- package/dist/components/fab/api.d.ts +3 -2
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/types.d.ts +27 -8
- package/dist/components/icon-button/api.d.ts +5 -4
- package/dist/components/icon-button/api.js +2 -12
- package/dist/components/icon-button/index.d.ts +3 -3
- package/dist/components/icon-button/types.d.ts +20 -7
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/components/list/api.d.ts +15 -860
- package/dist/components/list/api.js +57 -52
- package/dist/components/list/config.js +2 -20
- package/dist/components/list/constants.d.ts +4 -4
- package/dist/components/list/constants.js +4 -4
- package/dist/components/list/features/anatomy.d.ts +6 -0
- package/dist/components/list/features/anatomy.js +48 -0
- package/dist/components/list/features/renderer.d.ts +3 -7
- package/dist/components/list/features/renderer.js +96 -70
- package/dist/components/list/features/selection.d.ts +0 -7
- package/dist/components/list/features/selection.js +104 -151
- package/dist/components/list/index.d.ts +2 -10
- package/dist/components/list/list.d.ts +1 -2
- package/dist/components/list/types.d.ts +38 -5
- package/dist/components/menu/features/controller.d.ts +2 -1
- package/dist/components/menu/features/controller.js +2 -2
- package/dist/components/menu/features/opener.js +1 -1
- package/dist/components/menu/menu.js +1 -1
- package/dist/components/progress/features/state.d.ts +2 -2
- package/dist/components/radios/api.d.ts +4 -3
- package/dist/components/radios/constants.d.ts +10 -6
- package/dist/components/radios/index.d.ts +1 -1
- package/dist/components/radios/types.d.ts +21 -7
- package/dist/components/search/api.d.ts +3 -2
- package/dist/components/search/config.d.ts +5 -4
- package/dist/components/search/features/input.d.ts +6 -5
- package/dist/components/search/features/input.js +2 -2
- package/dist/components/search/features/states.d.ts +2 -1
- package/dist/components/search/features/states.js +3 -3
- package/dist/components/search/features/suggestions.d.ts +1 -1
- package/dist/components/search/search.js +1 -1
- package/dist/components/segmented-button/config.js +1 -1
- package/dist/components/segmented-button/segment.js +2 -2
- package/dist/components/segmented-button/types.d.ts +3 -3
- package/dist/components/select/features.d.ts +2 -2
- package/dist/components/select/features.js +5 -5
- package/dist/components/select/select.js +1 -1
- package/dist/components/slider/api.d.ts +4 -1
- package/dist/components/slider/api.js +4 -0
- package/dist/components/slider/config.d.ts +7 -1
- package/dist/components/slider/config.js +8 -5
- package/dist/components/slider/constants.d.ts +6 -6
- package/dist/components/slider/features/axis.d.ts +37 -0
- package/dist/components/slider/features/axis.js +17 -0
- package/dist/components/slider/features/controller.d.ts +2 -1
- package/dist/components/slider/features/controller.js +69 -29
- package/dist/components/slider/features/dom.js +2 -2
- package/dist/components/slider/features/handlers.js +75 -94
- package/dist/components/slider/features/range.js +1 -1
- package/dist/components/slider/features/states.d.ts +0 -3
- package/dist/components/slider/features/states.js +2 -15
- package/dist/components/slider/features/tracks.d.ts +19 -1
- package/dist/components/slider/features/tracks.js +135 -50
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/slider/types.d.ts +27 -2
- package/dist/components/switch/api.d.ts +1 -1
- package/dist/components/switch/constants.d.ts +3 -3
- package/dist/components/switch/features.js +30 -8
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/switch/switch.js +4 -0
- package/dist/components/switch/types.d.ts +34 -8
- package/dist/components/tabs/api.d.ts +2 -0
- package/dist/components/tabs/api.js +2 -1
- package/dist/components/tabs/constants.d.ts +15 -9
- package/dist/components/tabs/constants.js +5 -5
- package/dist/components/tabs/features.d.ts +6 -3
- package/dist/components/tabs/features.js +8 -5
- package/dist/components/tabs/indicator.js +19 -17
- package/dist/components/tabs/responsive.d.ts +19 -4
- package/dist/components/tabs/responsive.js +40 -48
- package/dist/components/tabs/state.d.ts +0 -5
- package/dist/components/tabs/state.js +0 -40
- package/dist/components/tabs/tab.js +4 -8
- package/dist/components/tabs/tabs.js +4 -4
- package/dist/components/tabs/types.d.ts +24 -6
- package/dist/components/tabs/utils.d.ts +11 -2
- package/dist/components/tabs/utils.js +9 -1
- package/dist/components/textfield/api.d.ts +1 -1
- package/dist/components/textfield/constants.d.ts +22 -12
- package/dist/components/textfield/constants.js +11 -6
- package/dist/components/textfield/features/leading-icon.js +2 -2
- package/dist/components/textfield/features/placement.js +45 -82
- package/dist/components/textfield/features/trailing-icon.js +2 -2
- package/dist/components/textfield/index.d.ts +1 -1
- package/dist/components/textfield/textfield.d.ts +2 -2
- package/dist/components/textfield/types.d.ts +23 -5
- package/dist/components/timepicker/api.d.ts +3 -2
- package/dist/components/timepicker/api.js +65 -275
- package/dist/components/timepicker/config.js +5 -10
- package/dist/components/timepicker/constants.d.ts +54 -54
- package/dist/components/timepicker/constants.js +54 -54
- package/dist/components/timepicker/dial.d.ts +30 -0
- package/dist/components/timepicker/dial.js +169 -0
- package/dist/components/timepicker/index.d.ts +1 -1
- package/dist/components/timepicker/render.js +225 -299
- package/dist/components/timepicker/timepicker.d.ts +0 -5
- package/dist/components/timepicker/timepicker.js +9 -26
- package/dist/components/timepicker/types.d.ts +34 -6
- package/dist/components/tooltip/constants.d.ts +4 -4
- package/dist/components/tooltip/constants.js +2 -2
- package/dist/core/compose/features/checkable.d.ts +2 -1
- package/dist/core/compose/features/icon.d.ts +1 -1
- package/dist/core/compose/features/icon.js +1 -1
- package/dist/core/compose/features/input.d.ts +6 -1
- package/dist/core/compose/features/input.js +3 -3
- package/dist/core/compose/features/ripple.d.ts +5 -8
- package/dist/core/compose/features/ripple.js +8 -11
- package/dist/core/compose/features/text.d.ts +4 -2
- package/dist/core/compose/features/text.js +8 -2
- package/dist/core/compose/features/textinput.js +1 -1
- package/dist/core/compose/features/textlabel.d.ts +5 -1
- package/dist/core/compose/features/textlabel.js +4 -1
- package/dist/core/compose/features/track.d.ts +5 -0
- package/dist/core/compose/features/track.js +8 -1
- package/dist/core/dom/create.d.ts +24 -5
- package/dist/core/dom/index.d.ts +1 -1
- package/dist/elements/adapter.d.ts +96 -0
- package/dist/elements/adapter.js +69 -0
- package/dist/elements/badge.d.ts +62 -0
- package/dist/elements/badge.js +33 -0
- package/dist/elements/button.d.ts +69 -0
- package/dist/elements/button.js +27 -0
- package/dist/elements/checkbox.d.ts +92 -0
- package/dist/elements/checkbox.js +49 -0
- package/dist/elements/css/badge.js +3 -0
- package/dist/elements/css/button.d.ts +1 -0
- package/dist/elements/css/button.js +4 -0
- package/dist/elements/css/checkbox.d.ts +1 -0
- package/dist/elements/css/checkbox.js +3 -0
- package/dist/elements/css/divider.d.ts +1 -0
- package/dist/elements/css/divider.js +3 -0
- package/dist/elements/css/extended-fab.d.ts +1 -0
- package/dist/elements/css/extended-fab.js +3 -0
- package/dist/elements/css/fab.d.ts +1 -0
- package/dist/elements/css/fab.js +3 -0
- package/dist/elements/css/icon-button.d.ts +1 -0
- package/dist/elements/css/icon-button.js +3 -0
- package/dist/elements/css/index.d.ts +1 -0
- package/dist/elements/css/index.js +14 -0
- package/dist/elements/css/loading-indicator.d.ts +1 -0
- package/dist/elements/css/loading-indicator.js +3 -0
- package/dist/elements/css/progress.d.ts +1 -0
- package/dist/elements/css/progress.js +3 -0
- package/dist/elements/css/radios.d.ts +1 -0
- package/dist/elements/css/radios.js +3 -0
- package/dist/elements/css/ripple.d.ts +1 -0
- package/dist/elements/css/ripple.js +3 -0
- package/dist/elements/css/slider.d.ts +1 -0
- package/dist/elements/css/slider.js +3 -0
- package/dist/elements/css/switch.d.ts +1 -0
- package/dist/elements/css/switch.js +3 -0
- package/dist/elements/css/tabs.d.ts +1 -0
- package/dist/elements/css/tabs.js +5 -0
- package/dist/elements/css/textfield.d.ts +1 -0
- package/dist/elements/css/textfield.js +3 -0
- package/dist/elements/define.d.ts +191 -0
- package/dist/elements/define.js +406 -0
- package/dist/elements/divider.d.ts +54 -0
- package/dist/elements/divider.js +23 -0
- package/dist/elements/extended-fab.d.ts +82 -0
- package/dist/elements/extended-fab.js +32 -0
- package/dist/elements/fab.d.ts +65 -0
- package/dist/elements/fab.js +24 -0
- package/dist/elements/form-button.d.ts +29 -0
- package/dist/elements/form-button.js +19 -0
- package/dist/elements/icon-button.d.ts +104 -0
- package/dist/elements/icon-button.js +56 -0
- package/dist/elements/index.d.ts +103 -0
- package/dist/elements/index.js +67 -0
- package/dist/elements/loading-indicator.d.ts +44 -0
- package/dist/elements/loading-indicator.js +26 -0
- package/dist/elements/progress.d.ts +90 -0
- package/dist/elements/progress.js +40 -0
- package/dist/elements/radios.d.ts +99 -0
- package/dist/elements/radios.js +126 -0
- package/dist/elements/slider.d.ts +160 -0
- package/dist/elements/slider.js +136 -0
- package/dist/elements/styles.d.ts +22 -0
- package/dist/elements/styles.js +34 -0
- package/dist/elements/switch.d.ts +87 -0
- package/dist/elements/switch.js +48 -0
- package/dist/elements/tabs.d.ts +77 -0
- package/dist/elements/tabs.js +108 -0
- package/dist/elements/textfield.d.ts +160 -0
- package/dist/elements/textfield.js +107 -0
- package/dist/index.cjs +0 -0
- package/dist/package.json +52 -2
- package/dist/react/create.d.ts +45 -0
- package/dist/react/create.js +104 -0
- package/dist/react/index.d.ts +40 -0
- package/dist/react/index.js +34 -0
- package/dist/solid/create.d.ts +44 -0
- package/dist/solid/create.js +82 -0
- package/dist/solid/index.d.ts +40 -0
- package/dist/solid/index.js +33 -0
- 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/datepicker.css +2 -0
- package/dist/styles/datepicker.d.ts +1 -0
- package/dist/styles/datepicker.js +2 -0
- 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/svelte/Badge.svelte +20 -0
- package/dist/svelte/Badge.svelte.d.ts +5 -0
- package/dist/svelte/Button.svelte +19 -0
- package/dist/svelte/Button.svelte.d.ts +5 -0
- package/dist/svelte/Checkbox.svelte +21 -0
- package/dist/svelte/Checkbox.svelte.d.ts +5 -0
- package/dist/svelte/Divider.svelte +19 -0
- package/dist/svelte/Divider.svelte.d.ts +5 -0
- package/dist/svelte/ExtendedFab.svelte +19 -0
- package/dist/svelte/ExtendedFab.svelte.d.ts +5 -0
- package/dist/svelte/Fab.svelte +19 -0
- package/dist/svelte/Fab.svelte.d.ts +5 -0
- package/dist/svelte/IconButton.svelte +20 -0
- package/dist/svelte/IconButton.svelte.d.ts +5 -0
- package/dist/svelte/LoadingIndicator.svelte +19 -0
- package/dist/svelte/LoadingIndicator.svelte.d.ts +5 -0
- package/dist/svelte/Progress.svelte +21 -0
- package/dist/svelte/Progress.svelte.d.ts +5 -0
- package/dist/svelte/Radio.svelte +11 -0
- package/dist/svelte/Radio.svelte.d.ts +5 -0
- package/dist/svelte/Radios.svelte +20 -0
- package/dist/svelte/Radios.svelte.d.ts +5 -0
- package/dist/svelte/Slider.svelte +21 -0
- package/dist/svelte/Slider.svelte.d.ts +5 -0
- package/dist/svelte/Switch.svelte +20 -0
- package/dist/svelte/Switch.svelte.d.ts +5 -0
- package/dist/svelte/Tab.svelte +11 -0
- package/dist/svelte/Tab.svelte.d.ts +5 -0
- package/dist/svelte/Tabs.svelte +20 -0
- package/dist/svelte/Tabs.svelte.d.ts +5 -0
- package/dist/svelte/Textfield.svelte +20 -0
- package/dist/svelte/Textfield.svelte.d.ts +5 -0
- package/dist/svelte/index.d.ts +18 -0
- package/dist/svelte/index.js +32 -0
- package/dist/svelte/runtime.d.ts +60 -0
- package/dist/svelte/runtime.js +76 -0
- package/dist/themes/autumn.css +2 -2
- package/dist/themes/baseline.css +2 -2
- package/dist/themes/brownbeige.css +2 -2
- package/dist/themes/browngreen.css +2 -2
- package/dist/themes/desert.css +2 -2
- package/dist/themes/forest.css +2 -2
- package/dist/themes/highcontrast.css +2 -2
- package/dist/themes/legacy.css +2 -2
- package/dist/themes/material.css +2 -2
- package/dist/themes/ocean.css +2 -2
- package/dist/themes/sageivory.css +2 -2
- package/dist/themes/spring.css +2 -2
- package/dist/themes/summer.css +2 -2
- package/dist/themes/sunset.css +2 -2
- package/dist/themes/tealcaramel.css +2 -2
- package/dist/themes/winter.css +2 -2
- package/dist/vue/create.d.ts +53 -0
- package/dist/vue/create.js +86 -0
- package/dist/vue/index.d.ts +40 -0
- package/dist/vue/index.js +33 -0
- package/package.json +74 -4
- package/src/styles/abstract/_mixins.scss +15 -1
- package/src/styles/abstract/_variables.scss +1 -3
- package/src/styles/abstract/chips/_assist.scss +7 -0
- package/src/styles/abstract/chips/_filter.scss +7 -0
- package/src/styles/abstract/chips/_input.scss +7 -0
- package/src/styles/abstract/chips/_suggestion.scss +7 -0
- package/src/styles/components/_card.scss +11 -11
- package/src/styles/components/_checkbox.scss +94 -99
- package/src/styles/components/_chips.scss +174 -508
- package/src/styles/components/_datepicker.scss +143 -353
- package/src/styles/components/_drawer.scss +2 -1
- package/src/styles/components/_icon-button.scss +2 -2
- package/src/styles/components/_list.scss +84 -760
- package/src/styles/components/_radios.scss +60 -51
- package/src/styles/components/_slider.scss +153 -62
- package/src/styles/components/_switch.scss +80 -85
- package/src/styles/components/_tabs.scss +68 -39
- package/src/styles/components/_textfield.scss +122 -70
- package/src/styles/components/_timepicker.scss +191 -102
- package/src/styles/themes/_autumn.scss +10 -0
- package/src/styles/themes/_baseline.scss +12 -0
- package/src/styles/themes/_bluekhaki.scss +10 -0
- package/src/styles/themes/_brownbeige.scss +10 -0
- package/src/styles/themes/_browngreen.scss +10 -0
- package/src/styles/themes/_desert.scss +10 -0
- package/src/styles/themes/_forest.scss +10 -0
- package/src/styles/themes/_greenbeige.scss +10 -0
- package/src/styles/themes/_highcontrast.scss +10 -0
- package/src/styles/themes/_legacy.scss +10 -0
- package/src/styles/themes/_material.scss +10 -0
- package/src/styles/themes/_ocean.scss +10 -0
- package/src/styles/themes/_sageivory.scss +10 -0
- package/src/styles/themes/_spring.scss +10 -0
- package/src/styles/themes/_summer.scss +10 -0
- package/src/styles/themes/_sunset.scss +10 -0
- package/src/styles/themes/_tealcaramel.scss +10 -0
- package/src/styles/themes/_winter.scss +10 -0
- package/src/styles/utilities/_ripple.scss +2 -1
- package/dist/components/chips/chip/api.d.ts +0 -23
- package/dist/components/chips/chip/api.js +0 -187
- package/dist/components/chips/chip/config.d.ts +0 -581
- package/dist/components/chips/chip/config.js +0 -53
- package/dist/components/chips/chip/types.d.ts +0 -11
- package/dist/components/chips/features/label.d.ts +0 -76
- package/dist/components/chips/features/label.js +0 -63
- package/dist/components/tabs/tab-api.d.ts +0 -49
- package/dist/components/tabs/tab-api.js +0 -139
- package/dist/components/timepicker/clockdial.d.ts +0 -34
- package/dist/components/timepicker/clockdial.js +0 -276
- /package/dist/{components/chips/chip/types.js → elements/css/badge.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -134,6 +134,60 @@ const button = createButton({
|
|
|
134
134
|
|
|
135
135
|
Button progress and card actions load on demand; enable code splitting in your build to keep them out of the initial chunk.
|
|
136
136
|
|
|
137
|
+
## Web components and frameworks (experimental)
|
|
138
|
+
|
|
139
|
+
From the 0.10.0 prereleases (`npm install mtrl@next`), components also ship as custom elements, with thin adapters for React, Vue, Svelte and Solid. The API may still change.
|
|
140
|
+
|
|
141
|
+
| Element | Framework component (Vue: `M` prefix, e.g. `MTextfield`) | Kind |
|
|
142
|
+
|---------|---------------------|------|
|
|
143
|
+
| `<m-button>` | `Button` | action, submits or resets its form |
|
|
144
|
+
| `<m-icon-button>` | `IconButton` | action or toggle (`selected`) |
|
|
145
|
+
| `<m-fab>`, `<m-extended-fab>` | `Fab`, `ExtendedFab` | action |
|
|
146
|
+
| `<m-checkbox>` | `Checkbox` | form control (`checked`, `indeterminate`) |
|
|
147
|
+
| `<m-switch>` | `Switch` | form control (`checked`) |
|
|
148
|
+
| `<m-radios>` with `<m-radio>` | `Radios`, `Radio` | form control (`value`) |
|
|
149
|
+
| `<m-slider>` | `Slider` | form control (`value`, `secondValue` with `range`) |
|
|
150
|
+
| `<m-textfield>` | `Textfield` | form control (`value`) |
|
|
151
|
+
| `<m-tabs>` with `<m-tab>` | `Tabs`, `Tab` | selection (`value`) |
|
|
152
|
+
| `<m-progress>`, `<m-loading-indicator>` | `Progress`, `LoadingIndicator` | indicator |
|
|
153
|
+
| `<m-badge>`, `<m-divider>` | `Badge`, `Divider` | display |
|
|
154
|
+
|
|
155
|
+
More components follow through 0.10.x; the others are available as factories today.
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<script type="module">
|
|
159
|
+
import 'mtrl/elements/css'; // the elements' styles
|
|
160
|
+
import { defineAll } from 'mtrl/elements';
|
|
161
|
+
defineAll(); // registers every element (<m-button>, <m-switch>, …)
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<form>
|
|
165
|
+
<m-textfield name="email" type="email" label="Email" required></m-textfield>
|
|
166
|
+
<m-radios name="plan" value="free" aria-label="Plan">
|
|
167
|
+
<m-radio value="free">Free</m-radio>
|
|
168
|
+
<m-radio value="pro">Pro</m-radio>
|
|
169
|
+
</m-radios>
|
|
170
|
+
<m-switch name="news" checked>Newsletter</m-switch>
|
|
171
|
+
<m-button type="submit">Sign up</m-button>
|
|
172
|
+
</form>
|
|
173
|
+
|
|
174
|
+
<m-tabs value="songs">
|
|
175
|
+
<m-tab value="songs">Songs</m-tab>
|
|
176
|
+
<m-tab value="albums">Albums</m-tab>
|
|
177
|
+
</m-tabs>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The page still loads mtrl's base styles and a theme (see [Styles](#styles)); the elements render in shadow DOM and pick up the theme's tokens. Attributes are defaults and properties the live state, as on native controls: a `checked` or `value` attribute sets the state until the user or a script changes it, and `form.reset()` goes back to it. Form controls take part in forms (their host's `name`), reset, validation and back-navigation restore.
|
|
181
|
+
|
|
182
|
+
| Framework | Import | Two-way binding |
|
|
183
|
+
|-----------|--------|-----------------|
|
|
184
|
+
| React 18 and 19 | `import { Switch } from 'mtrl/react'` | `checked` + `onChange`, or `defaultChecked` |
|
|
185
|
+
| Vue 3 | `import { MSwitch } from 'mtrl/vue'` | `v-model` |
|
|
186
|
+
| Svelte 5 | `import { Switch } from 'mtrl/svelte'` | `bind:checked` |
|
|
187
|
+
| Solid | `import { Switch } from 'mtrl/solid'` | `checked` + `onChange` |
|
|
188
|
+
|
|
189
|
+
Each framework is an optional peer dependency; mtrl installs none of them. All adapters render on the server and hydrate. Angular apps use the elements directly, with `CUSTOM_ELEMENTS_SCHEMA`.
|
|
190
|
+
|
|
137
191
|
## Building your own components
|
|
138
192
|
|
|
139
193
|
Components are composed from small features with `pipe`. The same building blocks are public:
|
|
@@ -198,7 +252,7 @@ The policy sees every string, the library's own icons included; a `TrustedHTML`
|
|
|
198
252
|
- `title-large` uses weight 400, as M3 specifies.
|
|
199
253
|
- The slider draws with DOM and CSS; styles for `.mtrl-slider-canvas` no longer apply.
|
|
200
254
|
|
|
201
|
-
The full list, with every renamed property, is in [changelog
|
|
255
|
+
The full list, with every renamed property, is in the [0.8.0 changelog](CHANGELOG.md#080---2026-09-15).
|
|
202
256
|
|
|
203
257
|
## Browser support
|
|
204
258
|
|
package/dist/README.md
CHANGED
|
@@ -134,6 +134,60 @@ const button = createButton({
|
|
|
134
134
|
|
|
135
135
|
Button progress and card actions load on demand; enable code splitting in your build to keep them out of the initial chunk.
|
|
136
136
|
|
|
137
|
+
## Web components and frameworks (experimental)
|
|
138
|
+
|
|
139
|
+
From the 0.10.0 prereleases (`npm install mtrl@next`), components also ship as custom elements, with thin adapters for React, Vue, Svelte and Solid. The API may still change.
|
|
140
|
+
|
|
141
|
+
| Element | Framework component (Vue: `M` prefix, e.g. `MTextfield`) | Kind |
|
|
142
|
+
|---------|---------------------|------|
|
|
143
|
+
| `<m-button>` | `Button` | action, submits or resets its form |
|
|
144
|
+
| `<m-icon-button>` | `IconButton` | action or toggle (`selected`) |
|
|
145
|
+
| `<m-fab>`, `<m-extended-fab>` | `Fab`, `ExtendedFab` | action |
|
|
146
|
+
| `<m-checkbox>` | `Checkbox` | form control (`checked`, `indeterminate`) |
|
|
147
|
+
| `<m-switch>` | `Switch` | form control (`checked`) |
|
|
148
|
+
| `<m-radios>` with `<m-radio>` | `Radios`, `Radio` | form control (`value`) |
|
|
149
|
+
| `<m-slider>` | `Slider` | form control (`value`, `secondValue` with `range`) |
|
|
150
|
+
| `<m-textfield>` | `Textfield` | form control (`value`) |
|
|
151
|
+
| `<m-tabs>` with `<m-tab>` | `Tabs`, `Tab` | selection (`value`) |
|
|
152
|
+
| `<m-progress>`, `<m-loading-indicator>` | `Progress`, `LoadingIndicator` | indicator |
|
|
153
|
+
| `<m-badge>`, `<m-divider>` | `Badge`, `Divider` | display |
|
|
154
|
+
|
|
155
|
+
More components follow through 0.10.x; the others are available as factories today.
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<script type="module">
|
|
159
|
+
import 'mtrl/elements/css'; // the elements' styles
|
|
160
|
+
import { defineAll } from 'mtrl/elements';
|
|
161
|
+
defineAll(); // registers every element (<m-button>, <m-switch>, …)
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<form>
|
|
165
|
+
<m-textfield name="email" type="email" label="Email" required></m-textfield>
|
|
166
|
+
<m-radios name="plan" value="free" aria-label="Plan">
|
|
167
|
+
<m-radio value="free">Free</m-radio>
|
|
168
|
+
<m-radio value="pro">Pro</m-radio>
|
|
169
|
+
</m-radios>
|
|
170
|
+
<m-switch name="news" checked>Newsletter</m-switch>
|
|
171
|
+
<m-button type="submit">Sign up</m-button>
|
|
172
|
+
</form>
|
|
173
|
+
|
|
174
|
+
<m-tabs value="songs">
|
|
175
|
+
<m-tab value="songs">Songs</m-tab>
|
|
176
|
+
<m-tab value="albums">Albums</m-tab>
|
|
177
|
+
</m-tabs>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The page still loads mtrl's base styles and a theme (see [Styles](#styles)); the elements render in shadow DOM and pick up the theme's tokens. Attributes are defaults and properties the live state, as on native controls: a `checked` or `value` attribute sets the state until the user or a script changes it, and `form.reset()` goes back to it. Form controls take part in forms (their host's `name`), reset, validation and back-navigation restore.
|
|
181
|
+
|
|
182
|
+
| Framework | Import | Two-way binding |
|
|
183
|
+
|-----------|--------|-----------------|
|
|
184
|
+
| React 18 and 19 | `import { Switch } from 'mtrl/react'` | `checked` + `onChange`, or `defaultChecked` |
|
|
185
|
+
| Vue 3 | `import { MSwitch } from 'mtrl/vue'` | `v-model` |
|
|
186
|
+
| Svelte 5 | `import { Switch } from 'mtrl/svelte'` | `bind:checked` |
|
|
187
|
+
| Solid | `import { Switch } from 'mtrl/solid'` | `checked` + `onChange` |
|
|
188
|
+
|
|
189
|
+
Each framework is an optional peer dependency; mtrl installs none of them. All adapters render on the server and hydrate. Angular apps use the elements directly, with `CUSTOM_ELEMENTS_SCHEMA`.
|
|
190
|
+
|
|
137
191
|
## Building your own components
|
|
138
192
|
|
|
139
193
|
Components are composed from small features with `pipe`. The same building blocks are public:
|
|
@@ -198,7 +252,7 @@ The policy sees every string, the library's own icons included; a `TrustedHTML`
|
|
|
198
252
|
- `title-large` uses weight 400, as M3 specifies.
|
|
199
253
|
- The slider draws with DOM and CSS; styles for `.mtrl-slider-canvas` no longer apply.
|
|
200
254
|
|
|
201
|
-
The full list, with every renamed property, is in [changelog
|
|
255
|
+
The full list, with every renamed property, is in the [0.8.0 changelog](CHANGELOG.md#080---2026-09-15).
|
|
202
256
|
|
|
203
257
|
## Browser support
|
|
204
258
|
|
|
@@ -64,8 +64,8 @@ export declare const BUTTON_CLASSES: {
|
|
|
64
64
|
readonly ROOT: "button";
|
|
65
65
|
readonly ICON: "button__icon";
|
|
66
66
|
readonly TEXT: "button__text";
|
|
67
|
-
readonly ACTIVE: "button
|
|
68
|
-
readonly DISABLED: "button
|
|
67
|
+
readonly ACTIVE: "button--active";
|
|
68
|
+
readonly DISABLED: "button--disabled";
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
71
|
* Default ripple effect configuration
|
|
@@ -25,8 +25,8 @@ export const BUTTON_CLASSES = {
|
|
|
25
25
|
ROOT: "button",
|
|
26
26
|
ICON: "button__icon",
|
|
27
27
|
TEXT: "button__text",
|
|
28
|
-
ACTIVE: "button
|
|
29
|
-
DISABLED: "button
|
|
28
|
+
ACTIVE: "button--active",
|
|
29
|
+
DISABLED: "button--disabled",
|
|
30
30
|
};
|
|
31
31
|
export const DEFAULT_RIPPLE_CONFIG = {
|
|
32
32
|
DURATION: 450,
|
|
@@ -38,10 +38,11 @@ export interface ButtonConfig extends BaseComponentConfig {
|
|
|
38
38
|
*/
|
|
39
39
|
disabled?: boolean;
|
|
40
40
|
/**
|
|
41
|
-
* Initial button text content
|
|
41
|
+
* Initial button text content, or a node placed where the text goes (the
|
|
42
|
+
* web component passes a `<slot>` so the page's content is the label)
|
|
42
43
|
* @example 'Submit'
|
|
43
44
|
*/
|
|
44
|
-
text?: string;
|
|
45
|
+
text?: string | Node;
|
|
45
46
|
/**
|
|
46
47
|
* Initial button icon HTML content
|
|
47
48
|
* @example '<svg>...</svg>'
|
|
@@ -84,11 +85,11 @@ export interface ButtonConfig extends BaseComponentConfig {
|
|
|
84
85
|
* Ripple effect configuration
|
|
85
86
|
*/
|
|
86
87
|
rippleConfig?: {
|
|
87
|
-
/**
|
|
88
|
+
/** How long, in milliseconds, a released wave lingers before it is removed */
|
|
88
89
|
duration?: number;
|
|
89
|
-
/**
|
|
90
|
+
/** @deprecated Not applied: the ripple's motion comes from the stylesheet (FLO-268). */
|
|
90
91
|
timing?: string;
|
|
91
|
-
/**
|
|
92
|
+
/** @deprecated Not applied: the wave is the 0.10 pressed state layer, drawn by the stylesheet (FLO-268). */
|
|
92
93
|
opacity?: [string, string];
|
|
93
94
|
};
|
|
94
95
|
/**
|
|
@@ -199,11 +199,11 @@ export interface ButtonGroupConfig {
|
|
|
199
199
|
* Ripple effect configuration
|
|
200
200
|
*/
|
|
201
201
|
rippleConfig?: {
|
|
202
|
-
/**
|
|
202
|
+
/** How long, in milliseconds, a released wave lingers before it is removed */
|
|
203
203
|
duration?: number;
|
|
204
|
-
/**
|
|
204
|
+
/** @deprecated Not applied: the ripple's motion comes from the stylesheet (FLO-268). */
|
|
205
205
|
timing?: string;
|
|
206
|
-
/**
|
|
206
|
+
/** @deprecated Not applied: the wave is the 0.10 pressed state layer, drawn by the stylesheet (FLO-268). */
|
|
207
207
|
opacity?: [string, string];
|
|
208
208
|
};
|
|
209
209
|
/**
|
|
@@ -3,16 +3,16 @@ export const withAPI = ({ lifecycle, config }) => (component) => ({
|
|
|
3
3
|
element: component.element,
|
|
4
4
|
config,
|
|
5
5
|
addContent(contentElement) {
|
|
6
|
-
if (contentElement && contentElement.classList.contains(`${component.getClass('card')}
|
|
6
|
+
if (contentElement && contentElement.classList.contains(`${component.getClass('card')}__content`)) {
|
|
7
7
|
component.element.appendChild(contentElement);
|
|
8
8
|
}
|
|
9
9
|
return this;
|
|
10
10
|
},
|
|
11
11
|
setHeader(headerElement) {
|
|
12
12
|
const card = component.getClass('card');
|
|
13
|
-
if (headerElement && headerElement.classList.contains(`${card}
|
|
14
|
-
const title = (header) => header?.querySelector(`.${card}-
|
|
15
|
-
const existingHeader = component.element.querySelector(`.${card}
|
|
13
|
+
if (headerElement && headerElement.classList.contains(`${card}__header`)) {
|
|
14
|
+
const title = (header) => header?.querySelector(`.${card}__header-title`)?.id || null;
|
|
15
|
+
const existingHeader = component.element.querySelector(`.${card}__header`);
|
|
16
16
|
if (existingHeader) {
|
|
17
17
|
const previous = title(existingHeader);
|
|
18
18
|
if (previous && component.element.getAttribute('aria-labelledby') === previous) {
|
|
@@ -21,7 +21,7 @@ export const withAPI = ({ lifecycle, config }) => (component) => ({
|
|
|
21
21
|
existingHeader.remove();
|
|
22
22
|
}
|
|
23
23
|
let before = component.element.firstElementChild;
|
|
24
|
-
while (before && before.classList.contains(`${card}
|
|
24
|
+
while (before && before.classList.contains(`${card}__media`)) {
|
|
25
25
|
before = before.nextElementSibling;
|
|
26
26
|
}
|
|
27
27
|
component.element.insertBefore(headerElement, before);
|
|
@@ -35,7 +35,7 @@ export const withAPI = ({ lifecycle, config }) => (component) => ({
|
|
|
35
35
|
return this;
|
|
36
36
|
},
|
|
37
37
|
addMedia(mediaElement, position = 'top') {
|
|
38
|
-
if (mediaElement && mediaElement.classList.contains(`${component.getClass('card')}
|
|
38
|
+
if (mediaElement && mediaElement.classList.contains(`${component.getClass('card')}__media`)) {
|
|
39
39
|
if (position === 'top') {
|
|
40
40
|
component.element.insertBefore(mediaElement, component.element.firstChild);
|
|
41
41
|
}
|
|
@@ -46,8 +46,8 @@ export const withAPI = ({ lifecycle, config }) => (component) => ({
|
|
|
46
46
|
return this;
|
|
47
47
|
},
|
|
48
48
|
setActions(actionsElement) {
|
|
49
|
-
if (actionsElement && actionsElement.classList.contains(`${component.getClass('card')}
|
|
50
|
-
const existingActions = component.element.querySelector(`.${component.getClass('card')}
|
|
49
|
+
if (actionsElement && actionsElement.classList.contains(`${component.getClass('card')}__actions`)) {
|
|
50
|
+
const existingActions = component.element.querySelector(`.${component.getClass('card')}__actions`);
|
|
51
51
|
if (existingActions) {
|
|
52
52
|
existingActions.remove();
|
|
53
53
|
}
|
|
@@ -57,7 +57,7 @@ import { CardComponent, CardSchema } from "./types.js";
|
|
|
57
57
|
* // Using API methods
|
|
58
58
|
* const card = createCard();
|
|
59
59
|
* const content = document.createElement('div');
|
|
60
|
-
* content.className = 'mtrl-
|
|
60
|
+
* content.className = 'mtrl-card__content';
|
|
61
61
|
* content.textContent = 'Added programmatically';
|
|
62
62
|
* card.addContent(content);
|
|
63
63
|
* card.makeDraggable();
|
|
@@ -145,7 +145,7 @@ export const withInteractiveBehavior = (comp) => {
|
|
|
145
145
|
comp.element.classList.add(`${comp.getClass("card")}--dragging`);
|
|
146
146
|
comp.emit?.("dragstart", { event: e });
|
|
147
147
|
if (e.dataTransfer) {
|
|
148
|
-
const cardTitle = comp.element.querySelector(`.${comp.getClass("card")}-
|
|
148
|
+
const cardTitle = comp.element.querySelector(`.${comp.getClass("card")}__header-title`)
|
|
149
149
|
?.textContent || "Card";
|
|
150
150
|
e.dataTransfer.setData("text/plain", cardTitle);
|
|
151
151
|
}
|
|
@@ -67,19 +67,22 @@ export declare const CARD_MEDIA_POSITION: {
|
|
|
67
67
|
*/
|
|
68
68
|
export declare const CARD_CLASSES: {
|
|
69
69
|
readonly ROOT: "card";
|
|
70
|
-
readonly HEADER: "
|
|
71
|
-
readonly TITLE: "
|
|
72
|
-
readonly SUBTITLE: "
|
|
73
|
-
readonly AVATAR: "
|
|
74
|
-
readonly HEADER_ACTION: "
|
|
75
|
-
readonly CONTENT: "
|
|
76
|
-
readonly MEDIA: "
|
|
77
|
-
readonly ACTIONS: "
|
|
78
|
-
|
|
79
|
-
readonly
|
|
80
|
-
readonly
|
|
81
|
-
readonly
|
|
82
|
-
|
|
83
|
-
readonly
|
|
84
|
-
readonly
|
|
70
|
+
readonly HEADER: "card__header";
|
|
71
|
+
readonly TITLE: "card__header-title";
|
|
72
|
+
readonly SUBTITLE: "card__header-subtitle";
|
|
73
|
+
readonly AVATAR: "card__header-avatar";
|
|
74
|
+
readonly HEADER_ACTION: "card__header-action";
|
|
75
|
+
readonly CONTENT: "card__content";
|
|
76
|
+
readonly MEDIA: "card__media";
|
|
77
|
+
readonly ACTIONS: "card__actions";
|
|
78
|
+
/** Reserved modifier; draggable currently uses the native attribute. */
|
|
79
|
+
readonly DRAGGABLE: "card--draggable";
|
|
80
|
+
readonly INTERACTIVE: "card--interactive";
|
|
81
|
+
readonly FULL_WIDTH: "card--full-width";
|
|
82
|
+
/** Reserved modifier; clickable currently uses INTERACTIVE. */
|
|
83
|
+
readonly CLICKABLE: "card--clickable";
|
|
84
|
+
readonly LOADING: "card--state-loading";
|
|
85
|
+
readonly EXPANDED: "card--expanded";
|
|
86
|
+
/** Reserved modifier prefix; elevation currently uses styles. */
|
|
87
|
+
readonly ELEVATION_PREFIX: "card--elevation-";
|
|
85
88
|
};
|
|
@@ -37,19 +37,19 @@ export const CARD_MEDIA_POSITION = {
|
|
|
37
37
|
};
|
|
38
38
|
export const CARD_CLASSES = {
|
|
39
39
|
ROOT: 'card',
|
|
40
|
-
HEADER: '
|
|
41
|
-
TITLE: '
|
|
42
|
-
SUBTITLE: '
|
|
43
|
-
AVATAR: '
|
|
44
|
-
HEADER_ACTION: '
|
|
45
|
-
CONTENT: '
|
|
46
|
-
MEDIA: '
|
|
47
|
-
ACTIONS: '
|
|
48
|
-
DRAGGABLE: 'card
|
|
49
|
-
INTERACTIVE: 'card
|
|
50
|
-
FULL_WIDTH: 'card
|
|
51
|
-
CLICKABLE: 'card
|
|
52
|
-
LOADING: 'card-loading',
|
|
53
|
-
EXPANDED: 'card
|
|
54
|
-
ELEVATION_PREFIX: 'card
|
|
40
|
+
HEADER: 'card__header',
|
|
41
|
+
TITLE: 'card__header-title',
|
|
42
|
+
SUBTITLE: 'card__header-subtitle',
|
|
43
|
+
AVATAR: 'card__header-avatar',
|
|
44
|
+
HEADER_ACTION: 'card__header-action',
|
|
45
|
+
CONTENT: 'card__content',
|
|
46
|
+
MEDIA: 'card__media',
|
|
47
|
+
ACTIONS: 'card__actions',
|
|
48
|
+
DRAGGABLE: 'card--draggable',
|
|
49
|
+
INTERACTIVE: 'card--interactive',
|
|
50
|
+
FULL_WIDTH: 'card--full-width',
|
|
51
|
+
CLICKABLE: 'card--clickable',
|
|
52
|
+
LOADING: 'card--state-loading',
|
|
53
|
+
EXPANDED: 'card--expanded',
|
|
54
|
+
ELEVATION_PREFIX: 'card--elevation-'
|
|
55
55
|
};
|
|
@@ -9,16 +9,16 @@ let headerCount = 0;
|
|
|
9
9
|
export const createCardContent = (config = {}) => {
|
|
10
10
|
const baseConfig = {
|
|
11
11
|
...config,
|
|
12
|
-
componentName: '
|
|
12
|
+
componentName: 'card__content',
|
|
13
13
|
prefix: PREFIX
|
|
14
14
|
};
|
|
15
15
|
try {
|
|
16
16
|
const content = pipe(createBase, withElement({
|
|
17
17
|
tag: 'div',
|
|
18
|
-
componentName: '
|
|
18
|
+
componentName: 'card__content',
|
|
19
19
|
className: [
|
|
20
20
|
config.class,
|
|
21
|
-
config.padding === false ? `${PREFIX}-
|
|
21
|
+
config.padding === false ? `${PREFIX}-card__content--no-padding` : null
|
|
22
22
|
].filter((name) => Boolean(name)),
|
|
23
23
|
attributes: {
|
|
24
24
|
'role': 'region',
|
|
@@ -50,13 +50,13 @@ export const createCardContent = (config = {}) => {
|
|
|
50
50
|
export const createCardHeader = (config = {}) => {
|
|
51
51
|
const baseConfig = {
|
|
52
52
|
...config,
|
|
53
|
-
componentName: '
|
|
53
|
+
componentName: 'card__header',
|
|
54
54
|
prefix: PREFIX
|
|
55
55
|
};
|
|
56
56
|
try {
|
|
57
57
|
const header = pipe(createBase, withElement({
|
|
58
58
|
tag: 'div',
|
|
59
|
-
componentName: '
|
|
59
|
+
componentName: 'card__header',
|
|
60
60
|
className: config.class,
|
|
61
61
|
attributes: {
|
|
62
62
|
'role': 'heading',
|
|
@@ -65,13 +65,13 @@ export const createCardHeader = (config = {}) => {
|
|
|
65
65
|
}))(baseConfig);
|
|
66
66
|
const textContainer = createElement({
|
|
67
67
|
tag: 'div',
|
|
68
|
-
className: `${PREFIX}-
|
|
68
|
+
className: `${PREFIX}-card__header-text`,
|
|
69
69
|
container: header.element
|
|
70
70
|
});
|
|
71
71
|
if (config.title) {
|
|
72
72
|
createElement({
|
|
73
73
|
tag: 'h3',
|
|
74
|
-
className: `${PREFIX}-
|
|
74
|
+
className: `${PREFIX}-card__header-title`,
|
|
75
75
|
text: config.title,
|
|
76
76
|
container: textContainer,
|
|
77
77
|
attributes: {
|
|
@@ -82,7 +82,7 @@ export const createCardHeader = (config = {}) => {
|
|
|
82
82
|
if (config.subtitle) {
|
|
83
83
|
createElement({
|
|
84
84
|
tag: 'h4',
|
|
85
|
-
className: `${PREFIX}-
|
|
85
|
+
className: `${PREFIX}-card__header-subtitle`,
|
|
86
86
|
text: config.subtitle,
|
|
87
87
|
container: textContainer
|
|
88
88
|
});
|
|
@@ -91,7 +91,7 @@ export const createCardHeader = (config = {}) => {
|
|
|
91
91
|
const avatarElement = typeof config.avatar === 'string'
|
|
92
92
|
? createElement({
|
|
93
93
|
tag: 'div',
|
|
94
|
-
className: `${PREFIX}-
|
|
94
|
+
className: `${PREFIX}-card__header-avatar`,
|
|
95
95
|
html: config.avatar
|
|
96
96
|
})
|
|
97
97
|
: config.avatar;
|
|
@@ -106,7 +106,7 @@ export const createCardHeader = (config = {}) => {
|
|
|
106
106
|
const actionElement = typeof config.action === 'string'
|
|
107
107
|
? createElement({
|
|
108
108
|
tag: 'div',
|
|
109
|
-
className: `${PREFIX}-
|
|
109
|
+
className: `${PREFIX}-card__header-action`,
|
|
110
110
|
html: config.action
|
|
111
111
|
})
|
|
112
112
|
: config.action;
|
|
@@ -122,18 +122,18 @@ export const createCardHeader = (config = {}) => {
|
|
|
122
122
|
export const createCardActions = (config = {}) => {
|
|
123
123
|
const baseConfig = {
|
|
124
124
|
...config,
|
|
125
|
-
componentName: '
|
|
125
|
+
componentName: 'card__actions',
|
|
126
126
|
prefix: PREFIX
|
|
127
127
|
};
|
|
128
128
|
try {
|
|
129
129
|
const actions = pipe(createBase, withElement({
|
|
130
130
|
tag: 'div',
|
|
131
|
-
componentName: '
|
|
131
|
+
componentName: 'card__actions',
|
|
132
132
|
className: [
|
|
133
133
|
config.class,
|
|
134
|
-
config.fullBleed ? `${PREFIX}-
|
|
135
|
-
config.vertical ? `${PREFIX}-
|
|
136
|
-
config.align ? `${PREFIX}-
|
|
134
|
+
config.fullBleed ? `${PREFIX}-card__actions--full-bleed` : null,
|
|
135
|
+
config.vertical ? `${PREFIX}-card__actions--vertical` : null,
|
|
136
|
+
config.align ? `${PREFIX}-card__actions--${config.align}` : null
|
|
137
137
|
].filter((name) => Boolean(name)),
|
|
138
138
|
attributes: {
|
|
139
139
|
'role': 'group'
|
|
@@ -161,17 +161,17 @@ export const createCardActions = (config = {}) => {
|
|
|
161
161
|
export const createCardMedia = (config = {}) => {
|
|
162
162
|
const baseConfig = {
|
|
163
163
|
...config,
|
|
164
|
-
componentName: '
|
|
164
|
+
componentName: 'card__media',
|
|
165
165
|
prefix: PREFIX
|
|
166
166
|
};
|
|
167
167
|
try {
|
|
168
168
|
const media = pipe(createBase, withElement({
|
|
169
169
|
tag: 'div',
|
|
170
|
-
componentName: '
|
|
170
|
+
componentName: 'card__media',
|
|
171
171
|
className: [
|
|
172
172
|
config.class,
|
|
173
|
-
config.aspectRatio ? `${PREFIX}-
|
|
174
|
-
config.contain ? `${PREFIX}-
|
|
173
|
+
config.aspectRatio ? `${PREFIX}-card__media--${config.aspectRatio.replace(':', '-')}` : null,
|
|
174
|
+
config.contain ? `${PREFIX}-card__media--contain` : null
|
|
175
175
|
].filter((name) => Boolean(name))
|
|
176
176
|
}))(baseConfig);
|
|
177
177
|
if (config.element instanceof HTMLElement) {
|
|
@@ -180,7 +180,7 @@ export const createCardMedia = (config = {}) => {
|
|
|
180
180
|
else if (config.src) {
|
|
181
181
|
const img = document.createElement('img');
|
|
182
182
|
img.src = safeUrl(config.src);
|
|
183
|
-
img.className = `${PREFIX}-
|
|
183
|
+
img.className = `${PREFIX}-card__media-img`;
|
|
184
184
|
img.alt = config.alt || '';
|
|
185
185
|
if (!config.alt) {
|
|
186
186
|
img.setAttribute('aria-hidden', 'true');
|
|
@@ -16,7 +16,7 @@ export const withLoading = (config = {}) => (component) => {
|
|
|
16
16
|
if (loading && !loadingElement) {
|
|
17
17
|
loadingElement = createElement({
|
|
18
18
|
tag: "div",
|
|
19
|
-
className: `${PREFIX}-
|
|
19
|
+
className: `${PREFIX}-card__loading-overlay`,
|
|
20
20
|
container: component.element,
|
|
21
21
|
attributes: {
|
|
22
22
|
role: "progressbar",
|
|
@@ -26,7 +26,7 @@ export const withLoading = (config = {}) => (component) => {
|
|
|
26
26
|
});
|
|
27
27
|
createElement({
|
|
28
28
|
tag: "div",
|
|
29
|
-
className: `${PREFIX}-
|
|
29
|
+
className: `${PREFIX}-card__loading-spinner`,
|
|
30
30
|
container: loadingElement,
|
|
31
31
|
});
|
|
32
32
|
component.element.classList.add(`${PREFIX}-card--state-loading`);
|
|
@@ -66,7 +66,7 @@ export const withExpandable = (config = {}) => (component) => {
|
|
|
66
66
|
const expandableContent = config.expandableContent;
|
|
67
67
|
const expandButton = createElement({
|
|
68
68
|
tag: "button",
|
|
69
|
-
className: `${PREFIX}-
|
|
69
|
+
className: `${PREFIX}-card__expand-button`,
|
|
70
70
|
attributes: {
|
|
71
71
|
"aria-expanded": isExpanded ? "true" : "false",
|
|
72
72
|
"aria-label": isExpanded ? "Collapse content" : "Expand content",
|
|
@@ -74,14 +74,14 @@ export const withExpandable = (config = {}) => (component) => {
|
|
|
74
74
|
`${component.element.id || "card"}-expandable-content`,
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
|
-
const actionsContainer = component.element.querySelector(`.${PREFIX}-
|
|
77
|
+
const actionsContainer = component.element.querySelector(`.${PREFIX}-card__actions`);
|
|
78
78
|
if (actionsContainer) {
|
|
79
79
|
actionsContainer.appendChild(expandButton);
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
const newActionsContainer = createElement({
|
|
83
83
|
tag: "div",
|
|
84
|
-
className: `${PREFIX}-
|
|
84
|
+
className: `${PREFIX}-card__actions`,
|
|
85
85
|
container: component.element,
|
|
86
86
|
attributes: {
|
|
87
87
|
role: "group",
|
|
@@ -90,7 +90,7 @@ export const withExpandable = (config = {}) => (component) => {
|
|
|
90
90
|
newActionsContainer.appendChild(expandButton);
|
|
91
91
|
}
|
|
92
92
|
if (expandableContent) {
|
|
93
|
-
expandableContent.classList.add(`${PREFIX}-
|
|
93
|
+
expandableContent.classList.add(`${PREFIX}-card__expandable-content`);
|
|
94
94
|
if (!expandableContent.id) {
|
|
95
95
|
expandableContent.id = `${component.element.id || "card"}-expandable-content`;
|
|
96
96
|
}
|
|
@@ -148,7 +148,7 @@ export const withSwipeable = (config = {}) => (component) => {
|
|
|
148
148
|
component.element.setAttribute("aria-description", "Swipeable card. Swipe left or right to perform actions.");
|
|
149
149
|
const leftActionButton = createElement({
|
|
150
150
|
tag: "button",
|
|
151
|
-
className: `${PREFIX}-
|
|
151
|
+
className: `${PREFIX}-card__swipe-left-action`,
|
|
152
152
|
text: "Swipe Left Action",
|
|
153
153
|
container: component.element,
|
|
154
154
|
attributes: { "aria-label": "Perform swipe left action" },
|
|
@@ -156,7 +156,7 @@ export const withSwipeable = (config = {}) => (component) => {
|
|
|
156
156
|
});
|
|
157
157
|
const rightActionButton = createElement({
|
|
158
158
|
tag: "button",
|
|
159
|
-
className: `${PREFIX}-
|
|
159
|
+
className: `${PREFIX}-card__swipe-right-action`,
|
|
160
160
|
text: "Swipe Right Action",
|
|
161
161
|
container: component.element,
|
|
162
162
|
attributes: { "aria-label": "Perform swipe right action" },
|
|
@@ -166,14 +166,14 @@ export const withSwipeable = (config = {}) => (component) => {
|
|
|
166
166
|
if (config.onSwipeLeft) {
|
|
167
167
|
component.element.style.transform = "translateX(-100%)";
|
|
168
168
|
component.element.style.transition = "transform 0.3s ease";
|
|
169
|
-
config.onSwipeLeft(
|
|
169
|
+
config.onSwipeLeft(card);
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
rightActionButton.addEventListener("click", () => {
|
|
173
173
|
if (config.onSwipeRight) {
|
|
174
174
|
component.element.style.transform = "translateX(100%)";
|
|
175
175
|
component.element.style.transition = "transform 0.3s ease";
|
|
176
|
-
config.onSwipeRight(
|
|
176
|
+
config.onSwipeRight(card);
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
function handleTouchStart(e) {
|
|
@@ -195,11 +195,11 @@ export const withSwipeable = (config = {}) => (component) => {
|
|
|
195
195
|
if (Math.abs(diffX) >= threshold) {
|
|
196
196
|
if (diffX > 0 && config.onSwipeRight) {
|
|
197
197
|
component.element.style.transform = "translateX(100%)";
|
|
198
|
-
config.onSwipeRight(
|
|
198
|
+
config.onSwipeRight(card);
|
|
199
199
|
}
|
|
200
200
|
else if (diffX < 0 && config.onSwipeLeft) {
|
|
201
201
|
component.element.style.transform = "translateX(-100%)";
|
|
202
|
-
config.onSwipeLeft(
|
|
202
|
+
config.onSwipeLeft(card);
|
|
203
203
|
}
|
|
204
204
|
else {
|
|
205
205
|
component.element.style.transform = "translateX(0)";
|
|
@@ -215,7 +215,7 @@ export const withSwipeable = (config = {}) => (component) => {
|
|
|
215
215
|
component.element.addEventListener("touchmove", handleTouchMove, { passive: true });
|
|
216
216
|
component.element.addEventListener("touchend", handleTouchEnd);
|
|
217
217
|
component.element.classList.add(`${PREFIX}-card--swipeable`);
|
|
218
|
-
|
|
218
|
+
const card = {
|
|
219
219
|
...component,
|
|
220
220
|
swipeable: {
|
|
221
221
|
reset: () => {
|
|
@@ -224,4 +224,5 @@ export const withSwipeable = (config = {}) => (component) => {
|
|
|
224
224
|
},
|
|
225
225
|
},
|
|
226
226
|
};
|
|
227
|
+
return card;
|
|
227
228
|
};
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
*
|
|
45
45
|
* // Modify card programmatically using API methods
|
|
46
46
|
* const image = document.createElement('div');
|
|
47
|
-
* image.className = 'mtrl-
|
|
47
|
+
* image.className = 'mtrl-card__media';
|
|
48
48
|
* image.style.backgroundImage = 'url(path/to/image.jpg)';
|
|
49
49
|
*
|
|
50
50
|
* card.addMedia(image, 'top')
|
|
@@ -209,7 +209,7 @@ export interface BaseComponent {
|
|
|
209
209
|
/** The DOM element */
|
|
210
210
|
element: HTMLElement;
|
|
211
211
|
/** Get class name with prefix */
|
|
212
|
-
getClass: (name
|
|
212
|
+
getClass: (name: string) => string;
|
|
213
213
|
/** Get modifier class */
|
|
214
214
|
getModifierClass: (base: string, modifier: string) => string;
|
|
215
215
|
/** Get element class */
|
|
@@ -295,7 +295,7 @@ export interface CardComponent extends BaseComponent {
|
|
|
295
295
|
* @example
|
|
296
296
|
* ```typescript
|
|
297
297
|
* const content = document.createElement('div');
|
|
298
|
-
* content.className = 'mtrl-
|
|
298
|
+
* content.className = 'mtrl-card__content';
|
|
299
299
|
* content.textContent = 'Card content goes here';
|
|
300
300
|
* card.addContent(content);
|
|
301
301
|
* ```
|
|
@@ -327,7 +327,7 @@ export interface CardComponent extends BaseComponent {
|
|
|
327
327
|
* ```typescript
|
|
328
328
|
* // Creating media element
|
|
329
329
|
* const media = document.createElement('div');
|
|
330
|
-
* media.className = 'mtrl-
|
|
330
|
+
* media.className = 'mtrl-card__media';
|
|
331
331
|
*
|
|
332
332
|
* // Adding at the top (default)
|
|
333
333
|
* card.addMedia(media);
|
|
@@ -349,7 +349,7 @@ export interface CardComponent extends BaseComponent {
|
|
|
349
349
|
* ```typescript
|
|
350
350
|
* // Create actions container
|
|
351
351
|
* const actions = document.createElement('div');
|
|
352
|
-
* actions.className = 'mtrl-
|
|
352
|
+
* actions.className = 'mtrl-card__actions';
|
|
353
353
|
*
|
|
354
354
|
* // Add buttons to actions
|
|
355
355
|
* const button = document.createElement('button');
|