@shortfuse/materialdesignweb 0.8.0 → 0.9.1
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 +50 -198
- package/bin/mdw-css.js +1 -1
- package/components/Badge.js +15 -5
- package/components/Body.js +7 -0
- package/components/BottomAppBar.js +7 -10
- package/components/BottomSheet.js +472 -0
- package/components/Box.js +11 -49
- package/components/Button.js +81 -82
- package/components/Card.js +74 -62
- package/components/Checkbox.js +15 -25
- package/components/CheckboxIcon.js +19 -31
- package/components/Chip.js +18 -13
- package/components/Dialog.js +70 -100
- package/components/DialogActions.js +4 -0
- package/components/Display.js +64 -0
- package/components/Divider.js +5 -0
- package/components/Fab.js +94 -17
- package/components/FabContainer.js +57 -0
- package/components/FilterChip.js +43 -32
- package/components/Grid.js +187 -0
- package/components/Headline.js +9 -28
- package/components/Icon.js +80 -71
- package/components/IconButton.js +77 -120
- package/components/Input.js +745 -86
- package/components/InputChip.js +193 -0
- package/components/Label.js +7 -0
- package/components/List.js +11 -5
- package/components/ListItem.js +92 -23
- package/components/ListOption.js +143 -65
- package/components/Listbox.js +57 -17
- package/components/Menu.js +39 -27
- package/components/MenuItem.js +49 -36
- package/components/NavBar.js +66 -21
- package/components/NavBarItem.js +5 -0
- package/components/NavDrawer.js +33 -16
- package/components/NavDrawerItem.js +7 -4
- package/components/NavItem.js +61 -34
- package/components/NavRail.js +32 -21
- package/components/NavRailItem.js +10 -2
- package/components/Page.js +119 -0
- package/components/Pane.js +24 -0
- package/components/Popup.js +23 -8
- package/components/Progress.js +25 -5
- package/components/Radio.js +8 -7
- package/components/RadioIcon.js +24 -15
- package/components/Ripple.js +25 -7
- package/components/Root.js +225 -0
- package/components/Scrim.js +95 -0
- package/components/Search.js +30 -25
- package/components/SegmentedButton.js +53 -40
- package/components/SegmentedButtonGroup.js +15 -12
- package/components/Select.js +19 -10
- package/components/Shape.js +10 -66
- package/components/SideSheet.js +337 -0
- package/components/Slider.js +93 -36
- package/components/Snackbar.js +52 -20
- package/components/SnackbarContainer.js +51 -0
- package/components/Surface.js +20 -10
- package/components/Switch.js +21 -18
- package/components/SwitchIcon.js +62 -33
- package/components/Tab.js +78 -38
- package/components/TabContent.js +33 -12
- package/components/TabList.js +95 -34
- package/components/TabPanel.js +10 -1
- package/components/Table.js +151 -0
- package/components/TextArea.js +48 -16
- package/components/Title.js +8 -9
- package/components/Tooltip.js +51 -22
- package/components/TopAppBar.js +71 -78
- package/constants/shapes.js +36 -0
- package/constants/typography.js +127 -0
- package/core/Composition.js +391 -201
- package/core/CompositionAdapter.js +35 -18
- package/core/CustomElement.js +634 -254
- package/core/css.js +117 -12
- package/core/customTypes.js +161 -49
- package/core/dom.js +18 -11
- package/core/jsonMergePatch.js +27 -11
- package/core/observe.js +308 -256
- package/core/optimizations.js +9 -9
- package/core/template.js +14 -57
- package/dist/CustomElement.min.js +2 -0
- package/dist/CustomElement.min.js.map +7 -0
- package/dist/core/CustomElement.min.js +2 -0
- package/dist/core/CustomElement.min.js.map +7 -0
- package/dist/index.min.js +85 -115
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +108 -0
- package/{theming/themableMixinLoader.js → loaders/palette.js} +4 -3
- package/loaders/theme.js +12 -0
- package/mixins/AriaReflectorMixin.js +64 -15
- package/mixins/AriaToolbarMixin.js +6 -0
- package/mixins/ControlMixin.js +79 -33
- package/mixins/DelegatesFocusMixin.js +62 -0
- package/mixins/DensityMixin.js +7 -3
- package/mixins/ElevationMixin.js +61 -0
- package/mixins/FlexableMixin.js +87 -39
- package/mixins/FormAssociatedMixin.js +76 -10
- package/mixins/HyperlinkMixin.js +76 -0
- package/mixins/InputMixin.js +227 -32
- package/mixins/KeyboardNavMixin.js +11 -7
- package/mixins/NavigationListenerMixin.js +33 -0
- package/mixins/PopupMixin.js +216 -219
- package/mixins/RTLObserverMixin.js +2 -0
- package/mixins/ResizeObserverMixin.js +18 -4
- package/mixins/RippleMixin.js +11 -7
- package/mixins/ScrollListenerMixin.js +14 -2
- package/mixins/SemiStickyMixin.js +51 -98
- package/mixins/ShapeMaskedMixin.js +125 -0
- package/mixins/ShapeMixin.js +30 -203
- package/mixins/StateMixin.js +74 -34
- package/mixins/TextFieldMixin.js +128 -145
- package/mixins/ThemableMixin.js +57 -56
- package/mixins/TooltipTriggerMixin.js +305 -359
- package/mixins/TouchTargetMixin.js +5 -2
- package/mixins/TypographyMixin.js +128 -0
- package/package.json +125 -81
- package/services/rtl.js +10 -0
- package/services/svgAlias.js +17 -0
- package/{theming/index.js → services/theme.js} +25 -176
- package/types/bin/mdw-css.d.ts +3 -0
- package/types/bin/mdw-css.d.ts.map +1 -0
- package/types/components/Badge.d.ts +39 -0
- package/types/components/Badge.d.ts.map +1 -0
- package/types/components/Body.d.ts +29 -0
- package/types/components/Body.d.ts.map +1 -0
- package/types/components/BottomAppBar.d.ts +72 -0
- package/types/components/BottomAppBar.d.ts.map +1 -0
- package/types/components/BottomSheet.d.ts +135 -0
- package/types/components/BottomSheet.d.ts.map +1 -0
- package/types/components/Box.d.ts +16 -0
- package/types/components/Box.d.ts.map +1 -0
- package/types/components/Button.d.ts +245 -0
- package/types/components/Button.d.ts.map +1 -0
- package/types/components/Card.d.ts +147 -0
- package/types/components/Card.d.ts.map +1 -0
- package/types/components/Checkbox.d.ts +207 -0
- package/types/components/Checkbox.d.ts.map +1 -0
- package/types/components/CheckboxIcon.d.ts +44 -0
- package/types/components/CheckboxIcon.d.ts.map +1 -0
- package/types/components/Chip.d.ts +248 -0
- package/types/components/Chip.d.ts.map +1 -0
- package/types/components/Dialog.d.ts +103 -0
- package/types/components/Dialog.d.ts.map +1 -0
- package/types/components/DialogActions.d.ts +4 -0
- package/types/components/DialogActions.d.ts.map +1 -0
- package/types/components/Display.d.ts +46 -0
- package/types/components/Display.d.ts.map +1 -0
- package/types/components/Divider.d.ts +10 -0
- package/types/components/Divider.d.ts.map +1 -0
- package/types/components/Fab.d.ts +273 -0
- package/types/components/Fab.d.ts.map +1 -0
- package/types/components/FabContainer.d.ts +10 -0
- package/types/components/FabContainer.d.ts.map +1 -0
- package/types/components/FilterChip.d.ts +256 -0
- package/types/components/FilterChip.d.ts.map +1 -0
- package/types/components/Grid.d.ts +38 -0
- package/types/components/Grid.d.ts.map +1 -0
- package/types/components/Headline.d.ts +46 -0
- package/types/components/Headline.d.ts.map +1 -0
- package/types/components/Icon.d.ts +55 -0
- package/types/components/Icon.d.ts.map +1 -0
- package/types/components/IconButton.d.ts +284 -0
- package/types/components/IconButton.d.ts.map +1 -0
- package/types/components/Input.d.ts +2528 -0
- package/types/components/Input.d.ts.map +1 -0
- package/types/components/InputChip.d.ts +85 -0
- package/types/components/InputChip.d.ts.map +1 -0
- package/types/components/Label.d.ts +29 -0
- package/types/components/Label.d.ts.map +1 -0
- package/types/components/List.d.ts +35 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/ListItem.d.ts +124 -0
- package/types/components/ListItem.d.ts.map +1 -0
- package/types/components/ListOption.d.ts +158 -0
- package/types/components/ListOption.d.ts.map +1 -0
- package/types/components/Listbox.d.ts +763 -0
- package/types/components/Listbox.d.ts.map +1 -0
- package/types/components/Menu.d.ts +130 -0
- package/types/components/Menu.d.ts.map +1 -0
- package/types/components/MenuItem.d.ts +232 -0
- package/types/components/MenuItem.d.ts.map +1 -0
- package/types/components/NavBar.d.ts +20 -0
- package/types/components/NavBar.d.ts.map +1 -0
- package/types/components/NavBarItem.d.ts +97 -0
- package/types/components/NavBarItem.d.ts.map +1 -0
- package/types/components/NavDrawer.d.ts +107 -0
- package/types/components/NavDrawer.d.ts.map +1 -0
- package/types/components/NavDrawerItem.d.ts +97 -0
- package/types/components/NavDrawerItem.d.ts.map +1 -0
- package/types/components/NavItem.d.ts +99 -0
- package/types/components/NavItem.d.ts.map +1 -0
- package/types/components/NavRail.d.ts +108 -0
- package/types/components/NavRail.d.ts.map +1 -0
- package/types/components/NavRailItem.d.ts +97 -0
- package/types/components/NavRailItem.d.ts.map +1 -0
- package/types/components/Page.d.ts +25 -0
- package/types/components/Page.d.ts.map +1 -0
- package/types/components/Pane.d.ts +44 -0
- package/types/components/Pane.d.ts.map +1 -0
- package/types/components/Popup.d.ts +78 -0
- package/types/components/Popup.d.ts.map +1 -0
- package/types/components/Progress.d.ts +21 -0
- package/types/components/Progress.d.ts.map +1 -0
- package/types/components/Radio.d.ts +201 -0
- package/types/components/Radio.d.ts.map +1 -0
- package/types/components/RadioIcon.d.ts +46 -0
- package/types/components/RadioIcon.d.ts.map +1 -0
- package/types/components/Ripple.d.ts +35 -0
- package/types/components/Ripple.d.ts.map +1 -0
- package/types/components/Root.d.ts +68 -0
- package/types/components/Root.d.ts.map +1 -0
- package/types/components/Scrim.d.ts +6 -0
- package/types/components/Scrim.d.ts.map +1 -0
- package/types/components/Search.d.ts +516 -0
- package/types/components/Search.d.ts.map +1 -0
- package/types/components/SegmentedButton.d.ts +252 -0
- package/types/components/SegmentedButton.d.ts.map +1 -0
- package/types/components/SegmentedButtonGroup.d.ts +43 -0
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
- package/types/components/Select.d.ts +158 -0
- package/types/components/Select.d.ts.map +1 -0
- package/types/components/Shape.d.ts +10 -0
- package/types/components/Shape.d.ts.map +1 -0
- package/types/components/SideSheet.d.ts +111 -0
- package/types/components/SideSheet.d.ts.map +1 -0
- package/types/components/Slider.d.ts +203 -0
- package/types/components/Slider.d.ts.map +1 -0
- package/types/components/Snackbar.d.ts +73 -0
- package/types/components/Snackbar.d.ts.map +1 -0
- package/types/components/SnackbarContainer.d.ts +6 -0
- package/types/components/SnackbarContainer.d.ts.map +1 -0
- package/types/components/Surface.d.ts +45 -0
- package/types/components/Surface.d.ts.map +1 -0
- package/types/components/Switch.d.ts +187 -0
- package/types/components/Switch.d.ts.map +1 -0
- package/types/components/SwitchIcon.d.ts +61 -0
- package/types/components/SwitchIcon.d.ts.map +1 -0
- package/types/components/Tab.d.ts +139 -0
- package/types/components/Tab.d.ts.map +1 -0
- package/types/components/TabContent.d.ts +124 -0
- package/types/components/TabContent.d.ts.map +1 -0
- package/types/components/TabList.d.ts +1111 -0
- package/types/components/TabList.d.ts.map +1 -0
- package/types/components/TabPanel.d.ts +28 -0
- package/types/components/TabPanel.d.ts.map +1 -0
- package/types/components/Table.d.ts +25 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/TextArea.d.ts +201 -0
- package/types/components/TextArea.d.ts.map +1 -0
- package/types/components/Title.d.ts +46 -0
- package/types/components/Title.d.ts.map +1 -0
- package/types/components/Tooltip.d.ts +49 -0
- package/types/components/Tooltip.d.ts.map +1 -0
- package/types/components/TopAppBar.d.ts +129 -0
- package/types/components/TopAppBar.d.ts.map +1 -0
- package/types/constants/colorKeywords.d.ts +2 -0
- package/types/constants/colorKeywords.d.ts.map +1 -0
- package/types/constants/shapes.d.ts +38 -0
- package/types/constants/shapes.d.ts.map +1 -0
- package/types/constants/typography.d.ts +212 -0
- package/types/constants/typography.d.ts.map +1 -0
- package/types/core/Composition.d.ts +260 -0
- package/types/core/Composition.d.ts.map +1 -0
- package/types/core/CompositionAdapter.d.ts +114 -0
- package/types/core/CompositionAdapter.d.ts.map +1 -0
- package/types/core/CustomElement.d.ts +304 -0
- package/types/core/CustomElement.d.ts.map +1 -0
- package/types/core/css.d.ts +44 -0
- package/types/core/css.d.ts.map +1 -0
- package/types/core/customTypes.d.ts +22 -0
- package/types/core/customTypes.d.ts.map +1 -0
- package/types/core/dom.d.ts +32 -0
- package/types/core/dom.d.ts.map +1 -0
- package/types/core/jsonMergePatch.d.ts +31 -0
- package/types/core/jsonMergePatch.d.ts.map +1 -0
- package/types/core/observe.d.ts +114 -0
- package/types/core/observe.d.ts.map +1 -0
- package/types/core/optimizations.d.ts +7 -0
- package/types/core/optimizations.d.ts.map +1 -0
- package/types/core/template.d.ts +47 -0
- package/types/core/template.d.ts.map +1 -0
- package/types/core/uid.d.ts +6 -0
- package/types/core/uid.d.ts.map +1 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
- package/types/index.d.ts +88 -0
- package/types/index.d.ts.map +1 -0
- package/types/loaders/palette.d.ts +2 -0
- package/types/loaders/palette.d.ts.map +1 -0
- package/types/loaders/theme.d.ts +2 -0
- package/types/loaders/theme.d.ts.map +1 -0
- package/types/mixins/AriaReflectorMixin.d.ts +31 -0
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
- package/types/mixins/AriaToolbarMixin.d.ts +34 -0
- package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
- package/types/mixins/ControlMixin.d.ts +124 -0
- package/types/mixins/ControlMixin.d.ts.map +1 -0
- package/types/mixins/DelegatesFocusMixin.d.ts +13 -0
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
- package/types/mixins/DensityMixin.d.ts +8 -0
- package/types/mixins/DensityMixin.d.ts.map +1 -0
- package/types/mixins/ElevationMixin.d.ts +32 -0
- package/types/mixins/ElevationMixin.d.ts.map +1 -0
- package/types/mixins/FlexableMixin.d.ts +14 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -0
- package/types/mixins/FormAssociatedMixin.d.ts +123 -0
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
- package/types/mixins/HyperlinkMixin.d.ts +25 -0
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
- package/types/mixins/InputMixin.d.ts +173 -0
- package/types/mixins/InputMixin.d.ts.map +1 -0
- package/types/mixins/KeyboardNavMixin.d.ts +46 -0
- package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
- package/types/mixins/NavigationListenerMixin.d.ts +8 -0
- package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
- package/types/mixins/PopupMixin.d.ts +98 -0
- package/types/mixins/PopupMixin.d.ts.map +1 -0
- package/types/mixins/RTLObserverMixin.d.ts +8 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts +13 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
- package/types/mixins/RippleMixin.d.ts +94 -0
- package/types/mixins/RippleMixin.d.ts.map +1 -0
- package/types/mixins/ScrollListenerMixin.d.ts +46 -0
- package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
- package/types/mixins/SemiStickyMixin.d.ts +50 -0
- package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMaskedMixin.d.ts +12 -0
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMixin.d.ts +39 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -0
- package/types/mixins/StateMixin.d.ts +29 -0
- package/types/mixins/StateMixin.d.ts.map +1 -0
- package/types/mixins/TextFieldMixin.d.ts +153 -0
- package/types/mixins/TextFieldMixin.d.ts.map +1 -0
- package/types/mixins/ThemableMixin.d.ts +10 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -0
- package/types/mixins/TooltipTriggerMixin.d.ts +114 -0
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
- package/types/mixins/TouchTargetMixin.d.ts +6 -0
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
- package/types/mixins/TypographyMixin.d.ts +20 -0
- package/types/mixins/TypographyMixin.d.ts.map +1 -0
- package/types/services/rtl.d.ts +3 -0
- package/types/services/rtl.d.ts.map +1 -0
- package/types/services/svgAlias.d.ts +13 -0
- package/types/services/svgAlias.d.ts.map +1 -0
- package/types/services/theme.d.ts +45 -0
- package/types/services/theme.d.ts.map +1 -0
- package/types/utils/cli.d.ts +3 -0
- package/types/utils/cli.d.ts.map +1 -0
- package/types/utils/function.d.ts +3 -0
- package/types/utils/function.d.ts.map +1 -0
- package/types/utils/jsx-runtime.d.ts +20 -0
- package/types/utils/jsx-runtime.d.ts.map +1 -0
- package/types/utils/material-color/blend.d.ts +34 -0
- package/types/utils/material-color/blend.d.ts.map +1 -0
- package/types/utils/material-color/hct/Cam16.d.ts +142 -0
- package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
- package/types/utils/material-color/hct/Hct.d.ts +93 -0
- package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
- package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
- package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
- package/types/utils/material-color/helper.d.ts +8 -0
- package/types/utils/material-color/helper.d.ts.map +1 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
- package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
- package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
- package/types/utils/material-color/utils/color.d.ts +172 -0
- package/types/utils/material-color/utils/color.d.ts.map +1 -0
- package/types/utils/material-color/utils/math.d.ts +94 -0
- package/types/utils/material-color/utils/math.d.ts.map +1 -0
- package/types/utils/pixelmatch.d.ts +22 -0
- package/types/utils/pixelmatch.d.ts.map +1 -0
- package/types/utils/popup.d.ts +106 -0
- package/types/utils/popup.d.ts.map +1 -0
- package/types/utils/searchParams.d.ts +3 -0
- package/types/utils/searchParams.d.ts.map +1 -0
- package/types/utils/svg.d.ts +7 -0
- package/types/utils/svg.d.ts.map +1 -0
- package/utils/jsx-runtime.js +9 -4
- package/utils/material-color/scheme/Scheme.js +1 -1
- package/utils/pixelmatch.js +363 -0
- package/utils/popup.js +86 -10
- package/utils/searchParams.js +22 -0
- package/components/Button.md +0 -61
- package/components/ExtendedFab.js +0 -32
- package/components/Layout.js +0 -504
- package/components/Nav.js +0 -38
- package/core/DomAdapter.js +0 -586
- package/core/ICustomElement.d.ts +0 -291
- package/core/ICustomElement.js +0 -1
- package/core/test.js +0 -126
- package/core/typings.d.ts +0 -142
- package/core/typings.js +0 -1
- package/mixins/SurfaceMixin.js +0 -127
- package/theming/loader.js +0 -22
- /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
package/components/Button.js
CHANGED
|
@@ -1,52 +1,89 @@
|
|
|
1
1
|
import './Icon.js';
|
|
2
2
|
import CustomElement from '../core/CustomElement.js';
|
|
3
3
|
import DensityMixin from '../mixins/DensityMixin.js';
|
|
4
|
+
import ElevationMixin from '../mixins/ElevationMixin.js';
|
|
5
|
+
import HyperlinkMixin from '../mixins/HyperlinkMixin.js';
|
|
4
6
|
import InputMixin from '../mixins/InputMixin.js';
|
|
5
7
|
import RippleMixin from '../mixins/RippleMixin.js';
|
|
6
8
|
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
7
9
|
import StateMixin from '../mixins/StateMixin.js';
|
|
8
|
-
import SurfaceMixin from '../mixins/SurfaceMixin.js';
|
|
9
10
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
10
11
|
|
|
12
|
+
/* https://m3.material.io/components/buttons/specs */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Buttons prompt most actions in a UI.
|
|
16
|
+
* @see https://m3.material.io/components/buttons/specs
|
|
17
|
+
*/
|
|
11
18
|
export default CustomElement
|
|
12
19
|
.extend()
|
|
13
20
|
.mixin(ThemableMixin)
|
|
14
21
|
.mixin(DensityMixin)
|
|
15
|
-
.mixin(SurfaceMixin)
|
|
16
|
-
.mixin(ShapeMixin)
|
|
17
22
|
.mixin(StateMixin)
|
|
23
|
+
.mixin(ElevationMixin)
|
|
24
|
+
.mixin(ShapeMixin)
|
|
18
25
|
.mixin(RippleMixin)
|
|
19
26
|
.mixin(InputMixin)
|
|
27
|
+
.mixin(HyperlinkMixin)
|
|
20
28
|
.define({
|
|
29
|
+
/**
|
|
30
|
+
* Returns the element used as the state target for visual states
|
|
31
|
+
* (e.g., pressed/hover). Typically the internal control element.
|
|
32
|
+
* @return {HTMLElement}
|
|
33
|
+
*/
|
|
21
34
|
stateTargetElement() { return this.refs.control; },
|
|
22
35
|
})
|
|
23
36
|
.set({
|
|
24
37
|
stateLayer: true,
|
|
25
|
-
|
|
38
|
+
_allowedTypes: ['button', 'submit', 'reset', 'file'],
|
|
26
39
|
})
|
|
27
40
|
.observe({
|
|
28
|
-
|
|
41
|
+
/** The underlying control `type` (button, submit, reset, file). */
|
|
42
|
+
type: {
|
|
43
|
+
empty: 'button',
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} value
|
|
46
|
+
* @param {*} internalSet
|
|
47
|
+
*/
|
|
48
|
+
set(value, internalSet) {
|
|
49
|
+
const enumeratedValue = value?.toLowerCase() ?? 'button';
|
|
50
|
+
internalSet(
|
|
51
|
+
this._allowedTypes.includes(enumeratedValue)
|
|
52
|
+
? enumeratedValue
|
|
53
|
+
: 'button',
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
/** Bound to [elevated] specifying whether the element should be elevated. */
|
|
29
58
|
elevated: 'boolean',
|
|
59
|
+
/** Visual filled variant; may be "tonal" or boolean-filled token. */
|
|
30
60
|
filled: 'string',
|
|
31
|
-
|
|
61
|
+
/** Whether the button should render an outline. */
|
|
32
62
|
outlined: 'boolean',
|
|
63
|
+
/** Icon name (uses internal `mdw-icon` when set). */
|
|
33
64
|
icon: 'string',
|
|
65
|
+
/** Ink color override for the icon. */
|
|
34
66
|
iconInk: 'string',
|
|
67
|
+
// Overrides to string instead of DOMString
|
|
68
|
+
/** Image source URL for an icon. */
|
|
35
69
|
src: 'string',
|
|
70
|
+
/** Inline SVG markup to render as icon. */
|
|
36
71
|
svg: 'string',
|
|
72
|
+
/** SVG `viewBox` attribute for inline SVG icons. */
|
|
37
73
|
viewBox: 'string',
|
|
74
|
+
/** Path data for an inline SVG icon. */
|
|
38
75
|
svgPath: 'string',
|
|
39
|
-
_slotInnerText: 'string',
|
|
40
76
|
})
|
|
41
77
|
.expressions({
|
|
42
|
-
hasIcon({ icon, svg, src, svgPath }) {
|
|
78
|
+
hasIcon({ icon, svg, src, svgPath } = this) {
|
|
43
79
|
return icon ?? svg ?? src ?? svgPath;
|
|
44
80
|
},
|
|
45
|
-
|
|
46
|
-
return
|
|
81
|
+
iconVariation({ outlined } = this) {
|
|
82
|
+
return outlined ? null : 'filled';
|
|
47
83
|
},
|
|
48
84
|
})
|
|
49
85
|
.methods({
|
|
86
|
+
/** @type {HTMLElement['focus']} */
|
|
50
87
|
focus(...options) {
|
|
51
88
|
if (this.href) {
|
|
52
89
|
this.refs.anchor.focus(...options);
|
|
@@ -56,39 +93,19 @@ export default CustomElement
|
|
|
56
93
|
},
|
|
57
94
|
})
|
|
58
95
|
.html`
|
|
59
|
-
<mdw-icon mdw-if={hasIcon} id=icon ink={iconInk} disabled={disabledState}
|
|
60
|
-
|
|
61
|
-
|
|
96
|
+
<mdw-icon mdw-if={hasIcon} id=icon ink={iconInk} disabled={disabledState}
|
|
97
|
+
outlined={outlined} variation={iconVariation} aria-hidden=true svg={svg} src={src}
|
|
98
|
+
svg-path={svgPath} view-box={viewBox} icon={icon}></mdw-icon>
|
|
99
|
+
<slot id=slot disabled={disabledState} aria-hidden=true>{_defaultValue}</slot>
|
|
62
100
|
`
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (navigator.userAgent.includes('Firefox')
|
|
70
|
-
|| (navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrom'))) {
|
|
71
|
-
this._slotInnerText = this.textContent;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
.on({
|
|
77
|
-
composed() {
|
|
78
|
-
const {
|
|
79
|
-
shape, state, rippleContainer, surface, control,
|
|
80
|
-
} = this.refs;
|
|
81
|
-
surface.append(shape);
|
|
82
|
-
shape.append(state, rippleContainer);
|
|
83
|
-
shape.setAttribute('filled', '{filled}');
|
|
84
|
-
control.setAttribute('aria-label', '{computedAriaLabel}');
|
|
85
|
-
control.setAttribute('hidden', '{href}');
|
|
86
|
-
control.setAttribute('role', 'button');
|
|
87
|
-
},
|
|
101
|
+
.recompose(({ refs: { anchor, control } }) => {
|
|
102
|
+
control.setAttribute('mdw-if', '{!href}');
|
|
103
|
+
control.setAttribute('role', 'button');
|
|
104
|
+
anchor.setAttribute('mdw-if', '{href}');
|
|
105
|
+
anchor.setAttribute('aria-label', '{_computedAriaLabel}');
|
|
106
|
+
anchor.setAttribute('aria-labelledby', '{_computedAriaLabelledby}');
|
|
88
107
|
})
|
|
89
108
|
.css`
|
|
90
|
-
/* https://m3.material.io/components/buttons/specs */
|
|
91
|
-
|
|
92
109
|
:host {
|
|
93
110
|
--mdw-shape__size: var(--mdw-shape__full);
|
|
94
111
|
--mdw-ink: var(--mdw-color__primary);
|
|
@@ -121,23 +138,39 @@ export default CustomElement
|
|
|
121
138
|
}
|
|
122
139
|
|
|
123
140
|
:host(:where([elevated],[filled])) {
|
|
124
|
-
|
|
141
|
+
transition: box-shadow 200ms;
|
|
142
|
+
will-change: box-shadow;
|
|
125
143
|
}
|
|
126
144
|
|
|
127
145
|
/** Elevated Color Defaults */
|
|
128
146
|
:host(:where([elevated])) {
|
|
129
147
|
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
130
148
|
--mdw-ink: var(--mdw-color__primary);
|
|
131
|
-
|
|
132
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__2);
|
|
149
|
+
box-shadow: var(--mdw-elevation__box-shadow__1);
|
|
133
150
|
}
|
|
134
151
|
/** Filled Color Defaults */
|
|
135
152
|
:host(:where([filled])) {
|
|
136
153
|
--mdw-bg: var(--mdw-color__primary);
|
|
137
154
|
--mdw-ink: var(--mdw-color__on-primary);
|
|
138
|
-
|
|
139
|
-
|
|
155
|
+
box-shadow: var(--mdw-elevation__box-shadow__0);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
:host(:where([elevated]:hover:not(:active))) {
|
|
159
|
+
box-shadow: var(--mdw-elevation__box-shadow__2);
|
|
140
160
|
}
|
|
161
|
+
|
|
162
|
+
:host(:where([filled]:hover:not(:active))) {
|
|
163
|
+
box-shadow: var(--mdw-elevation__box-shadow__1);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
:host(:where([elevated]:disabled)) {
|
|
167
|
+
box-shadow: var(--mdw-elevation__box-shadow__0);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
:host(:where([filled]:disabled)) {
|
|
171
|
+
box-shadow: var(--mdw-elevation__box-shadow__0);
|
|
172
|
+
}
|
|
173
|
+
|
|
141
174
|
/** Filled Tonal Color Defaults */
|
|
142
175
|
:host(:where([filled="tonal"])) {
|
|
143
176
|
--mdw-bg: var(--mdw-color__secondary-container);
|
|
@@ -164,7 +197,7 @@ export default CustomElement
|
|
|
164
197
|
padding-inline: calc(16px + (var(--mdw-density) * 2px)) calc(24px + (var(--mdw-density) * 2px));
|
|
165
198
|
}
|
|
166
199
|
|
|
167
|
-
|
|
200
|
+
:host(:where([elevated],[filled],[color])) {
|
|
168
201
|
background-color: rgb(var(--mdw-bg));
|
|
169
202
|
}
|
|
170
203
|
|
|
@@ -192,7 +225,7 @@ export default CustomElement
|
|
|
192
225
|
color: rgba(var(--mdw-color__on-surface), 0.38);
|
|
193
226
|
}
|
|
194
227
|
|
|
195
|
-
|
|
228
|
+
:host([disabled]:is([elevated], [filled])) {
|
|
196
229
|
background-color: rgba(var(--mdw-color__on-surface), 0.12);
|
|
197
230
|
color: rgba(var(--mdw-color__on-surface), 0.38);
|
|
198
231
|
}
|
|
@@ -203,11 +236,6 @@ export default CustomElement
|
|
|
203
236
|
|
|
204
237
|
#icon {
|
|
205
238
|
font-size: calc(18/14 * 1em);
|
|
206
|
-
font-variation-settings: 'FILL' 1;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
#icon[outlined] {
|
|
210
|
-
font-variation-settings: 'FILL' 0;
|
|
211
239
|
}
|
|
212
240
|
|
|
213
241
|
#icon[disabled] {
|
|
@@ -222,37 +250,8 @@ export default CustomElement
|
|
|
222
250
|
|
|
223
251
|
@media (any-pointer: coarse) {
|
|
224
252
|
#touch-target {
|
|
225
|
-
visibility:
|
|
253
|
+
visibility: inherit;
|
|
226
254
|
}
|
|
227
255
|
}
|
|
228
256
|
`
|
|
229
|
-
.childEvents({
|
|
230
|
-
control: {
|
|
231
|
-
/**
|
|
232
|
-
* Duplicates button for form submission
|
|
233
|
-
* @see https://github.com/WICG/webcomponents/issues/814
|
|
234
|
-
* @param {{currentTarget:HTMLInputElement}} event
|
|
235
|
-
* @type {any}
|
|
236
|
-
*/
|
|
237
|
-
'~click'({ currentTarget }) {
|
|
238
|
-
if (currentTarget.disabled) return;
|
|
239
|
-
if (currentTarget.type !== 'submit') return;
|
|
240
|
-
if (this.disabled) return;
|
|
241
|
-
const { value } = currentTarget;
|
|
242
|
-
const form = this.elementInternals?.form;
|
|
243
|
-
if (!form) return;
|
|
244
|
-
this.elementInternals.setFormValue(value);
|
|
245
|
-
if ((currentTarget.type ?? 'submit') !== 'submit') return;
|
|
246
|
-
const duplicatedButton = /** @type {HTMLInputElement} */ (currentTarget.cloneNode());
|
|
247
|
-
duplicatedButton.hidden = true;
|
|
248
|
-
form.append(duplicatedButton);
|
|
249
|
-
if ('requestSubmit' in form) {
|
|
250
|
-
form.requestSubmit(duplicatedButton);
|
|
251
|
-
} else {
|
|
252
|
-
duplicatedButton.click();
|
|
253
|
-
}
|
|
254
|
-
duplicatedButton.remove();
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
})
|
|
258
257
|
.autoRegister('mdw-button');
|
package/components/Card.js
CHANGED
|
@@ -1,111 +1,124 @@
|
|
|
1
|
-
import CustomElement from '../core/CustomElement.js';
|
|
2
1
|
import { EVENT_HANDLER_TYPE } from '../core/customTypes.js';
|
|
3
2
|
import AriaReflectorMixin from '../mixins/AriaReflectorMixin.js';
|
|
4
|
-
import
|
|
3
|
+
import DelegatesFocusMixin from '../mixins/DelegatesFocusMixin.js';
|
|
4
|
+
import ElevationMixin from '../mixins/ElevationMixin.js';
|
|
5
5
|
import FormAssociatedMixin from '../mixins/FormAssociatedMixin.js';
|
|
6
|
+
import HyperlinkMixin from '../mixins/HyperlinkMixin.js';
|
|
6
7
|
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
7
8
|
import StateMixin from '../mixins/StateMixin.js';
|
|
8
|
-
|
|
9
|
-
import
|
|
9
|
+
|
|
10
|
+
import Box from './Box.js';
|
|
10
11
|
|
|
11
12
|
const SUPPORTS_INERT = 'inert' in HTMLElement.prototype;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Cards display content and actions about a single subject.
|
|
16
|
+
* @see https://m3.material.io/components/cards/specs
|
|
17
|
+
*/
|
|
18
|
+
export default Box
|
|
14
19
|
.extend()
|
|
15
|
-
.mixin(
|
|
16
|
-
.mixin(
|
|
17
|
-
.mixin(SurfaceMixin)
|
|
20
|
+
.mixin(StateMixin)
|
|
21
|
+
.mixin(ElevationMixin)
|
|
18
22
|
.mixin(ShapeMixin)
|
|
19
23
|
.mixin(FormAssociatedMixin) // Tap into FormAssociated for disabledState
|
|
20
|
-
.mixin(StateMixin)
|
|
21
24
|
.mixin(AriaReflectorMixin)
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
+
.mixin(DelegatesFocusMixin)
|
|
26
|
+
.mixin(HyperlinkMixin)
|
|
25
27
|
.set({
|
|
26
28
|
_ariaRole: 'figure',
|
|
27
29
|
})
|
|
28
30
|
.observe({
|
|
31
|
+
/** Whether the card displays an elevated surface. */
|
|
32
|
+
elevated: 'boolean',
|
|
33
|
+
/** Whether the card uses a filled surface style. */
|
|
29
34
|
filled: 'boolean',
|
|
35
|
+
/** When true, card renders an actionable control (clickable). */
|
|
30
36
|
actionable: 'boolean',
|
|
37
|
+
/** Label for the action control used for accessibility. */
|
|
31
38
|
actionLabel: 'string',
|
|
39
|
+
/** Event handler called when the card action is triggered. */
|
|
32
40
|
onaction: EVENT_HANDLER_TYPE,
|
|
33
41
|
})
|
|
34
42
|
.define({
|
|
43
|
+
/**
|
|
44
|
+
* Element used as the target for state styling (pressed/focus).
|
|
45
|
+
* Returns the internal action control when actionable, otherwise the host.
|
|
46
|
+
* @return {HTMLElement}
|
|
47
|
+
*/
|
|
35
48
|
stateTargetElement() { return this.actionable ? this.refs.action : this; },
|
|
36
49
|
})
|
|
37
50
|
.expressions({
|
|
38
|
-
showBlocker: ({ disabledState }) =>
|
|
51
|
+
showBlocker: ({ disabledState, disabled }) => disabledState && (!disabled || !SUPPORTS_INERT),
|
|
52
|
+
showButton: ({ actionable, href }) => Boolean(actionable || href),
|
|
39
53
|
})
|
|
40
54
|
.methods({
|
|
55
|
+
/**
|
|
56
|
+
* Focuses the internal action control if the card is actionable and not disabled.
|
|
57
|
+
* @return {void}
|
|
58
|
+
*/
|
|
41
59
|
focus() {
|
|
42
60
|
if (this.disabledState) return;
|
|
43
|
-
if (this.actionable)
|
|
61
|
+
if (!this.actionable) return;
|
|
62
|
+
this.refs.action.focus();
|
|
44
63
|
},
|
|
45
64
|
})
|
|
46
65
|
.html`
|
|
47
|
-
<mdw-button mdw-if={
|
|
66
|
+
<mdw-button mdw-if={showButton} aria-label={actionLabel} href={href}
|
|
67
|
+
target={target}
|
|
68
|
+
download={download}
|
|
69
|
+
ping={ping}
|
|
70
|
+
rel={rel}
|
|
71
|
+
hreflang={hreflang}
|
|
72
|
+
referrerpolicy={referrerPolicy} id=action disabled={disabledState}></mdw-button>
|
|
48
73
|
<div mdw-if={showBlocker} id=inert-blocker></div>
|
|
49
|
-
<slot id=slot disabled={disabledState}></slot>
|
|
50
74
|
`
|
|
75
|
+
.recompose(({ refs: { anchor, inertBlocker, slot } }) => {
|
|
76
|
+
anchor.remove();
|
|
77
|
+
slot.setAttribute('disabled', '{disabledState}');
|
|
78
|
+
inertBlocker.before(slot);
|
|
79
|
+
})
|
|
51
80
|
.css`
|
|
52
|
-
/* https://m3.material.io/components/cards/specs */
|
|
53
|
-
|
|
54
81
|
:host {
|
|
55
|
-
--mdw-shape__size:
|
|
82
|
+
--mdw-shape__size: var(--mdw-shape__medium);
|
|
56
83
|
|
|
57
|
-
--mdw-surface__shadow__resting: none;
|
|
58
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__resting);
|
|
59
84
|
/* padding-inline: 12px; */
|
|
60
85
|
|
|
61
|
-
--mdw-bg: var(--mdw-color__surface
|
|
86
|
+
--mdw-bg: var(--mdw-color__surface);
|
|
62
87
|
--mdw-ink: var(--mdw-color__on-surface);
|
|
63
88
|
position: relative;
|
|
64
89
|
|
|
65
|
-
display: block;
|
|
66
|
-
|
|
67
|
-
color: rgb(var(--mdw-ink));
|
|
68
|
-
|
|
69
90
|
font: var(--mdw-type__font);
|
|
70
91
|
letter-spacing: var(--mdw-type__letter-spacing);
|
|
71
|
-
}
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
transition: filter 200ms;
|
|
94
|
+
will-change: filter;
|
|
75
95
|
}
|
|
76
96
|
|
|
77
|
-
:host(:where([filled])) {
|
|
78
|
-
|
|
79
|
-
--mdw-ink: var(--mdw-color__on-surface-variant);
|
|
97
|
+
:host(:where([elevated],[filled],[outlined])) {
|
|
98
|
+
background-color: rgb(var(--mdw-bg));
|
|
80
99
|
}
|
|
81
100
|
|
|
82
101
|
:host(:where([elevated])) {
|
|
83
102
|
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
84
103
|
--mdw-ink: var(--mdw-color__on-surface);
|
|
104
|
+
filter: var(--mdw-elevation__drop-shadow__1);
|
|
85
105
|
}
|
|
86
106
|
|
|
87
|
-
:host([filled]) {
|
|
88
|
-
--mdw-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
:host([filled][actionable]) {
|
|
92
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__1);
|
|
107
|
+
:host(:where([filled])) {
|
|
108
|
+
--mdw-bg: var(--mdw-color__surface-container-highest);
|
|
109
|
+
--mdw-ink: var(--mdw-color__on-surface-variant);
|
|
93
110
|
}
|
|
94
111
|
|
|
95
|
-
:host([
|
|
96
|
-
|
|
112
|
+
:host(:where([filled][actionable])) {
|
|
113
|
+
filter: var(--mdw-elevation__drop-shadow__0);
|
|
97
114
|
}
|
|
98
115
|
|
|
99
|
-
:host([elevated][actionable]) {
|
|
100
|
-
|
|
116
|
+
:host(:where([elevated][actionable]:hover:not(:active))) {
|
|
117
|
+
filter: var(--mdw-elevation__drop-shadow__2);
|
|
101
118
|
}
|
|
102
119
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/* Works on images */
|
|
106
|
-
filter: grayscale();
|
|
107
|
-
|
|
108
|
-
color: rgb(var(--mdw-color__on-surface));
|
|
120
|
+
:host(:where([filled][actionable]:hover:not(:active))) {
|
|
121
|
+
filter: var(--mdw-elevation__drop-shadow__1);
|
|
109
122
|
}
|
|
110
123
|
|
|
111
124
|
:host([disabled]) {
|
|
@@ -113,6 +126,8 @@ export default CustomElement
|
|
|
113
126
|
|
|
114
127
|
filter: grayscale();
|
|
115
128
|
opacity: 0.38;
|
|
129
|
+
|
|
130
|
+
color: rgb(var(--mdw-color__on-surface));
|
|
116
131
|
}
|
|
117
132
|
|
|
118
133
|
#slot[disabled] {
|
|
@@ -135,10 +150,14 @@ export default CustomElement
|
|
|
135
150
|
z-index: 99;
|
|
136
151
|
}
|
|
137
152
|
|
|
138
|
-
|
|
153
|
+
:host([disabled][elevated]) {
|
|
139
154
|
background-color: rgba(var(--mdw-color__surface-container-highest));
|
|
140
155
|
}
|
|
141
156
|
|
|
157
|
+
:host([disabled][filled]) {
|
|
158
|
+
background-color: rgba(var(--mdw-color__surface));
|
|
159
|
+
}
|
|
160
|
+
|
|
142
161
|
#action {
|
|
143
162
|
--mdw-ink: inherit;
|
|
144
163
|
--mdw-shape__size: inherit;
|
|
@@ -153,19 +172,12 @@ export default CustomElement
|
|
|
153
172
|
color: inherit
|
|
154
173
|
}
|
|
155
174
|
`
|
|
156
|
-
.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
shape.setAttribute('filled', '{filled}');
|
|
164
|
-
slot.setAttribute('inert', '{disabledState}');
|
|
165
|
-
slot.setAttribute('disabled', '{disabledState}');
|
|
166
|
-
// shape.setAttribute('disabled', '{disabledState}');
|
|
167
|
-
// shape.setAttribute('filled', '{filled}');
|
|
168
|
-
},
|
|
175
|
+
.recompose(({ refs: { slot, outline } }) => {
|
|
176
|
+
outline.removeAttribute('pressed');
|
|
177
|
+
outline.removeAttribute('focused');
|
|
178
|
+
|
|
179
|
+
slot.setAttribute('inert', '{disabledState}');
|
|
180
|
+
slot.setAttribute('disabled', '{disabledState}');
|
|
169
181
|
})
|
|
170
182
|
.childEvents({
|
|
171
183
|
action: {
|
package/components/Checkbox.js
CHANGED
|
@@ -7,6 +7,10 @@ import StateMixin from '../mixins/StateMixin.js';
|
|
|
7
7
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
8
8
|
import TouchTargetMixin from '../mixins/TouchTargetMixin.js';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Checkboxes let users select one or more items from a list, or turn an item on or off.
|
|
12
|
+
* @see https://m3.material.io/components/checkbox/specs
|
|
13
|
+
*/
|
|
10
14
|
export default CustomElement
|
|
11
15
|
.extend()
|
|
12
16
|
.mixin(ThemableMixin)
|
|
@@ -15,49 +19,35 @@ export default CustomElement
|
|
|
15
19
|
.mixin(InputMixin)
|
|
16
20
|
.mixin(TouchTargetMixin)
|
|
17
21
|
.set({
|
|
22
|
+
/** Whether the element renders a state layer for interaction feedback. */
|
|
18
23
|
stateLayer: true,
|
|
24
|
+
/** The underlying control input `type` value. */
|
|
19
25
|
type: 'checkbox',
|
|
20
26
|
})
|
|
21
27
|
.observe({
|
|
28
|
+
/** Icon name to show for the checked state. */
|
|
22
29
|
icon: { value: 'check' },
|
|
30
|
+
/** Icon name to show when the control is indeterminate. */
|
|
23
31
|
indeterminateIcon: { value: 'check_indeterminate_small' },
|
|
24
|
-
/** Reflected property */
|
|
25
|
-
indeterminate: 'boolean',
|
|
26
32
|
})
|
|
27
|
-
.
|
|
28
|
-
_ariaChecked({ indeterminate, checked }) {
|
|
29
|
-
return (indeterminate ? 'mixed' : `${!!checked}`);
|
|
30
|
-
},
|
|
33
|
+
.expressions({
|
|
31
34
|
_determinateIcon({ indeterminate, indeterminateIcon, icon }) {
|
|
32
35
|
return (indeterminate ? indeterminateIcon : icon);
|
|
33
36
|
},
|
|
37
|
+
_iconSelectedState({ checked, indeterminate }) {
|
|
38
|
+
return checked || indeterminate;
|
|
39
|
+
},
|
|
34
40
|
})
|
|
35
41
|
.html`
|
|
36
42
|
<div id=checkbox errored={erroredState} selected={checked}>
|
|
37
43
|
<mdw-checkbox-icon id=icon errored={erroredState} disabled={disabledState}
|
|
38
|
-
icon={_determinateIcon} selected={
|
|
44
|
+
icon={_determinateIcon} selected={_iconSelectedState}>
|
|
39
45
|
</mdw-checkbox-icon>
|
|
40
46
|
</div>
|
|
41
47
|
<slot id=slot></slot>
|
|
42
48
|
`
|
|
43
|
-
.
|
|
44
|
-
|
|
45
|
-
const { control } = this.refs;
|
|
46
|
-
if (event.target !== control) {
|
|
47
|
-
// Label-like click
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
control.click();
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
.on({
|
|
54
|
-
composed() {
|
|
55
|
-
const { control, checkbox, state, rippleContainer } = this.refs;
|
|
56
|
-
checkbox.append(state, rippleContainer);
|
|
57
|
-
|
|
58
|
-
// Indeterminate must be manually expressed for ARIA
|
|
59
|
-
control.setAttribute('aria-checked', '{_ariaChecked}');
|
|
60
|
-
},
|
|
49
|
+
.recompose(({ refs: { checkbox, state, rippleContainer } }) => {
|
|
50
|
+
checkbox.append(state, rippleContainer);
|
|
61
51
|
})
|
|
62
52
|
.css`
|
|
63
53
|
/* https://m3.material.io/components/checkbox/specs */
|
|
@@ -3,26 +3,32 @@ import CustomElement from '../core/CustomElement.js';
|
|
|
3
3
|
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
4
4
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* CheckboxIcon is a visual helper for checkboxes, rendering the box and checkmark.
|
|
8
|
+
* @see https://m3.material.io/components/checkbox/specs
|
|
9
|
+
*/
|
|
6
10
|
export default CustomElement
|
|
7
11
|
.extend()
|
|
8
12
|
.mixin(ThemableMixin)
|
|
9
13
|
.mixin(ShapeMixin)
|
|
10
14
|
.observe({
|
|
15
|
+
/** Whether the icon is selected (checked). */
|
|
11
16
|
selected: 'boolean',
|
|
17
|
+
/** Icon name to render inside the checkbox icon. */
|
|
12
18
|
icon: 'string',
|
|
19
|
+
/** Whether the associated control is in an error state. */
|
|
13
20
|
errored: 'boolean',
|
|
21
|
+
/** Whether the associated control is disabled. */
|
|
14
22
|
disabled: 'boolean',
|
|
15
23
|
})
|
|
16
24
|
.define({
|
|
17
|
-
/** Alias for
|
|
25
|
+
/** Alias for `selected` (quality-of-life property). */
|
|
18
26
|
checked: {
|
|
19
27
|
get() { return this.selected; },
|
|
20
28
|
set(value) { this.selected = value; },
|
|
21
29
|
},
|
|
22
30
|
})
|
|
23
31
|
.css`
|
|
24
|
-
/* https://m3.material.io/components/checkbox/specs */
|
|
25
|
-
|
|
26
32
|
:host {
|
|
27
33
|
--mdw-ink: var(--mdw-color__on-primary);
|
|
28
34
|
--mdw-bg: var(--mdw-color__primary);
|
|
@@ -42,16 +48,6 @@ export default CustomElement
|
|
|
42
48
|
line-height: 18px;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
#shape {
|
|
46
|
-
--mdw-shape__size: inherit;
|
|
47
|
-
position: absolute;
|
|
48
|
-
inset: 0;
|
|
49
|
-
|
|
50
|
-
z-index: auto;
|
|
51
|
-
|
|
52
|
-
background-color: transparent;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
#icon {
|
|
56
52
|
position: absolute;
|
|
57
53
|
inset: 0;
|
|
@@ -59,6 +55,7 @@ export default CustomElement
|
|
|
59
55
|
opacity: 0;
|
|
60
56
|
|
|
61
57
|
background-color: rgb(var(--mdw-bg));
|
|
58
|
+
border-radius: inherit;
|
|
62
59
|
color: rgb(var(--mdw-ink));
|
|
63
60
|
|
|
64
61
|
transition-duration: 200ms;
|
|
@@ -67,11 +64,7 @@ export default CustomElement
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
#outline {
|
|
70
|
-
|
|
71
|
-
drop-shadow(1px 0px 0px currentColor)
|
|
72
|
-
drop-shadow(0px 1px 0px currentColor)
|
|
73
|
-
drop-shadow(-1px 0px 0px currentColor)
|
|
74
|
-
drop-shadow(0px -1px 0px currentColor);
|
|
67
|
+
border-width: 2px;
|
|
75
68
|
|
|
76
69
|
color: rgb(var(--mdw-color__on-surface));
|
|
77
70
|
|
|
@@ -112,18 +105,13 @@ export default CustomElement
|
|
|
112
105
|
color: rgb(var(--mdw-color__on-surface), var(--disabled-opacity));
|
|
113
106
|
}
|
|
114
107
|
`
|
|
115
|
-
.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// outlineRight.remove();
|
|
124
|
-
shape.append(html`
|
|
125
|
-
<mdw-icon id=icon selected={selected} errored={errored} disabled={disabled}>{icon}</mdw-icon>
|
|
126
|
-
`);
|
|
127
|
-
},
|
|
108
|
+
.html`
|
|
109
|
+
<mdw-icon id=icon selected={selected} errored={errored} disabled={disabled} icon={icon}></mdw-icon>
|
|
110
|
+
`
|
|
111
|
+
.recompose(({ refs: { outline } }) => {
|
|
112
|
+
outline.removeAttribute('mdw-if');
|
|
113
|
+
outline.setAttribute('selected', '{selected}');
|
|
114
|
+
outline.setAttribute('errored', '{errored}');
|
|
115
|
+
outline.setAttribute('disabled', '{disabled}');
|
|
128
116
|
})
|
|
129
117
|
.autoRegister('mdw-checkbox-icon');
|