@shortfuse/materialdesignweb 0.7.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -90
- package/bin/mdw-css.js +1 -1
- package/components/Badge.js +14 -7
- package/components/Body.js +3 -0
- package/components/BottomAppBar.js +4 -13
- package/components/BottomSheet.js +424 -0
- package/components/Box.js +20 -28
- package/components/Button.js +85 -79
- package/components/Button.md +9 -9
- package/components/Card.js +60 -72
- package/components/Checkbox.js +33 -42
- package/components/CheckboxIcon.js +11 -29
- package/components/Chip.js +13 -11
- package/components/Dialog.js +214 -394
- package/components/DialogActions.js +2 -2
- package/components/Display.js +55 -0
- package/components/Divider.js +3 -3
- package/components/Fab.js +83 -18
- package/components/FabContainer.js +48 -0
- package/components/FilterChip.js +35 -33
- package/components/Grid.js +176 -0
- package/components/Headline.js +5 -28
- package/components/Icon.js +61 -76
- package/components/IconButton.js +72 -126
- package/components/Input.js +859 -1
- package/components/InputChip.js +161 -0
- package/components/Label.js +3 -0
- package/components/List.js +4 -6
- package/components/ListItem.js +46 -30
- package/components/ListOption.js +86 -53
- package/components/Listbox.js +248 -0
- package/components/Menu.js +69 -528
- package/components/MenuItem.js +33 -36
- package/components/NavBar.js +49 -86
- package/components/NavDrawer.js +16 -15
- package/components/NavDrawerItem.js +4 -5
- package/components/NavItem.js +58 -41
- package/components/NavRail.js +30 -20
- package/components/NavRailItem.js +8 -3
- package/components/Page.js +105 -0
- package/components/Pane.js +11 -274
- package/components/Popup.js +29 -0
- package/components/Progress.js +24 -23
- package/components/Radio.js +40 -36
- package/components/RadioIcon.js +12 -16
- package/components/Ripple.js +13 -10
- package/components/Root.js +209 -0
- package/components/Scrim.js +87 -0
- package/components/Search.js +77 -0
- package/components/SegmentedButton.js +33 -45
- package/components/SegmentedButtonGroup.js +25 -13
- package/components/Select.js +10 -11
- package/components/Shape.js +5 -65
- package/components/SideSheet.js +308 -0
- package/components/Slider.js +108 -78
- package/components/Snackbar.js +26 -21
- package/components/SnackbarContainer.js +42 -0
- package/components/Surface.js +17 -12
- package/components/Switch.js +45 -24
- package/components/SwitchIcon.js +49 -39
- package/components/Tab.js +64 -43
- package/components/TabContent.js +5 -3
- package/components/TabList.js +62 -34
- package/components/TabPanel.js +11 -8
- package/components/Table.js +116 -0
- package/components/TextArea.js +54 -50
- package/components/Title.js +4 -9
- package/components/Tooltip.js +44 -22
- package/components/TopAppBar.js +68 -172
- package/constants/shapes.js +36 -0
- package/constants/typography.js +127 -0
- package/core/Composition.js +1164 -645
- package/core/CompositionAdapter.js +314 -0
- package/core/CustomElement.js +701 -286
- package/core/css.js +121 -15
- package/core/customTypes.js +157 -40
- package/core/dom.js +17 -11
- package/{utils → core}/jsonMergePatch.js +42 -18
- package/core/observe.js +343 -244
- package/core/optimizations.js +23 -0
- package/core/template.js +19 -56
- package/core/uid.js +13 -0
- package/dist/index.min.js +85 -184
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +106 -0
- package/loaders/palette.js +13 -0
- package/loaders/theme.js +12 -0
- package/mixins/AriaReflectorMixin.js +53 -14
- package/mixins/AriaToolbarMixin.js +5 -3
- package/mixins/ControlMixin.js +92 -41
- package/mixins/DelegatesFocusMixin.js +54 -0
- package/mixins/DensityMixin.js +2 -3
- package/mixins/ElevationMixin.js +62 -0
- package/mixins/FlexableMixin.js +67 -39
- package/mixins/FormAssociatedMixin.js +71 -16
- package/mixins/HyperlinkMixin.js +66 -0
- package/mixins/InputMixin.js +205 -39
- package/mixins/KeyboardNavMixin.js +22 -7
- package/mixins/NavigationListenerMixin.js +33 -0
- package/mixins/PopupMixin.js +725 -0
- package/mixins/RTLObserverMixin.js +0 -1
- package/mixins/ResizeObserverMixin.js +16 -5
- package/mixins/RippleMixin.js +11 -10
- package/mixins/ScrollListenerMixin.js +42 -33
- package/mixins/SemiStickyMixin.js +97 -0
- package/mixins/ShapeMaskedMixin.js +117 -0
- package/mixins/ShapeMixin.js +17 -194
- package/mixins/StateMixin.js +80 -39
- package/mixins/TextFieldMixin.js +139 -183
- package/mixins/ThemableMixin.js +71 -161
- package/mixins/TooltipTriggerMixin.js +292 -366
- package/mixins/TouchTargetMixin.js +5 -4
- package/mixins/TypographyMixin.js +121 -0
- package/package.json +111 -71
- package/services/rtl.js +10 -0
- package/services/svgAlias.js +17 -0
- package/{theming/index.js → services/theme.js} +25 -175
- 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 +73 -0
- package/types/components/BottomAppBar.d.ts.map +1 -0
- package/types/components/BottomSheet.d.ts +109 -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 +714 -0
- package/types/components/Button.d.ts.map +1 -0
- package/types/components/Card.d.ts +412 -0
- package/types/components/Card.d.ts.map +1 -0
- package/types/components/Checkbox.d.ts +205 -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 +1425 -0
- package/types/components/Chip.d.ts.map +1 -0
- package/types/components/Dialog.d.ts +286 -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 +45 -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 +741 -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 +4283 -0
- package/types/components/FilterChip.d.ts.map +1 -0
- package/types/components/Grid.d.ts +37 -0
- package/types/components/Grid.d.ts.map +1 -0
- package/types/components/Headline.d.ts +47 -0
- package/types/components/Headline.d.ts.map +1 -0
- package/types/components/Icon.d.ts +103 -0
- package/types/components/Icon.d.ts.map +1 -0
- package/types/components/IconButton.d.ts +1486 -0
- package/types/components/IconButton.d.ts.map +1 -0
- package/types/components/Input.d.ts +51288 -0
- package/types/components/Input.d.ts.map +1 -0
- package/types/components/InputChip.d.ts +243 -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 +31 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/ListItem.d.ts +349 -0
- package/types/components/ListItem.d.ts.map +1 -0
- package/types/components/ListOption.d.ts +1493 -0
- package/types/components/ListOption.d.ts.map +1 -0
- package/types/components/Listbox.d.ts +12012 -0
- package/types/components/Listbox.d.ts.map +1 -0
- package/types/components/Menu.d.ts +119 -0
- package/types/components/Menu.d.ts.map +1 -0
- package/types/components/MenuItem.d.ts +3109 -0
- package/types/components/MenuItem.d.ts.map +1 -0
- package/types/components/NavBar.d.ts +18 -0
- package/types/components/NavBar.d.ts.map +1 -0
- package/types/components/NavBarItem.d.ts +186 -0
- package/types/components/NavBarItem.d.ts.map +1 -0
- package/types/components/NavDrawer.d.ts +108 -0
- package/types/components/NavDrawer.d.ts.map +1 -0
- package/types/components/NavDrawerItem.d.ts +186 -0
- package/types/components/NavDrawerItem.d.ts.map +1 -0
- package/types/components/NavItem.d.ts +190 -0
- package/types/components/NavItem.d.ts.map +1 -0
- package/types/components/NavRail.d.ts +109 -0
- package/types/components/NavRail.d.ts.map +1 -0
- package/types/components/NavRailItem.d.ts +186 -0
- package/types/components/NavRailItem.d.ts.map +1 -0
- package/types/components/Page.d.ts +24 -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 +76 -0
- package/types/components/Popup.d.ts.map +1 -0
- package/types/components/Progress.d.ts +19 -0
- package/types/components/Progress.d.ts.map +1 -0
- package/types/components/Radio.d.ts +199 -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 +34 -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 +16 -0
- package/types/components/Search.d.ts.map +1 -0
- package/types/components/SegmentedButton.d.ts +718 -0
- package/types/components/SegmentedButton.d.ts.map +1 -0
- package/types/components/SegmentedButtonGroup.d.ts +44 -0
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
- package/types/components/Select.d.ts +1361 -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 +106 -0
- package/types/components/SideSheet.d.ts.map +1 -0
- package/types/components/Slider.d.ts +382 -0
- package/types/components/Slider.d.ts.map +1 -0
- package/types/components/Snackbar.d.ts +65 -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 +183 -0
- package/types/components/Switch.d.ts.map +1 -0
- package/types/components/SwitchIcon.d.ts +169 -0
- package/types/components/SwitchIcon.d.ts.map +1 -0
- package/types/components/Tab.d.ts +879 -0
- package/types/components/Tab.d.ts.map +1 -0
- package/types/components/TabContent.d.ts +122 -0
- package/types/components/TabContent.d.ts.map +1 -0
- package/types/components/TabList.d.ts +6266 -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 +2 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/TextArea.d.ts +1394 -0
- package/types/components/TextArea.d.ts.map +1 -0
- package/types/components/Title.d.ts +47 -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 +130 -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 +252 -0
- package/types/core/Composition.d.ts.map +1 -0
- package/types/core/CompositionAdapter.d.ts +92 -0
- package/types/core/CompositionAdapter.d.ts.map +1 -0
- package/types/core/CustomElement.d.ts +302 -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 +26 -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 +113 -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 +23 -0
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
- package/types/mixins/AriaToolbarMixin.d.ts +32 -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 +5 -0
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
- package/types/mixins/DensityMixin.d.ts +5 -0
- package/types/mixins/DensityMixin.d.ts.map +1 -0
- package/types/mixins/ElevationMixin.d.ts +33 -0
- package/types/mixins/ElevationMixin.d.ts.map +1 -0
- package/types/mixins/FlexableMixin.d.ts +13 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -0
- package/types/mixins/FormAssociatedMixin.d.ts +122 -0
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
- package/types/mixins/HyperlinkMixin.d.ts +22 -0
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
- package/types/mixins/InputMixin.d.ts +179 -0
- package/types/mixins/InputMixin.d.ts.map +1 -0
- package/types/mixins/KeyboardNavMixin.d.ts +47 -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 +82 -0
- package/types/mixins/PopupMixin.d.ts.map +1 -0
- package/types/mixins/RTLObserverMixin.d.ts +7 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts +12 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
- package/types/mixins/RippleMixin.d.ts +92 -0
- package/types/mixins/RippleMixin.d.ts.map +1 -0
- package/types/mixins/ScrollListenerMixin.d.ts +41 -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 +9 -0
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMixin.d.ts +38 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -0
- package/types/mixins/StateMixin.d.ts +27 -0
- package/types/mixins/StateMixin.d.ts.map +1 -0
- package/types/mixins/TextFieldMixin.d.ts +1354 -0
- package/types/mixins/TextFieldMixin.d.ts.map +1 -0
- package/types/mixins/ThemableMixin.d.ts +9 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -0
- package/types/mixins/TooltipTriggerMixin.d.ts +106 -0
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
- package/types/mixins/TouchTargetMixin.d.ts +3 -0
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
- package/types/mixins/TypographyMixin.d.ts +17 -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/{hct → material-color}/blend.js +8 -10
- package/utils/{hct → material-color/hct}/Cam16.js +196 -69
- package/utils/{hct → material-color/hct}/Hct.js +61 -19
- package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
- package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
- package/utils/{hct → material-color}/helper.js +11 -18
- package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
- package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
- package/utils/material-color/scheme/Scheme.js +376 -0
- package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
- package/utils/pixelmatch.js +360 -0
- package/utils/popup.js +127 -30
- package/utils/searchParams.js +19 -0
- package/components/ExtendedFab.js +0 -36
- package/components/Layout.js +0 -35
- package/components/ListSelect.js +0 -220
- package/components/Nav.js +0 -40
- package/components/Option.js +0 -91
- package/core/ICustomElement.d.ts +0 -291
- package/core/ICustomElement.js +0 -1
- package/core/identify.js +0 -40
- package/core/typings.d.ts +0 -136
- package/core/typings.js +0 -1
- package/mixins/SurfaceMixin.js +0 -181
- package/theming/loader.js +0 -22
- package/utils/hct/Scheme.js +0 -587
- /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
- /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
package/components/Button.js
CHANGED
|
@@ -1,31 +1,49 @@
|
|
|
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
|
+
|
|
11
14
|
export default CustomElement
|
|
15
|
+
.extend()
|
|
12
16
|
.mixin(ThemableMixin)
|
|
13
17
|
.mixin(DensityMixin)
|
|
14
|
-
.mixin(SurfaceMixin)
|
|
15
|
-
.mixin(ShapeMixin)
|
|
16
18
|
.mixin(StateMixin)
|
|
19
|
+
.mixin(ElevationMixin)
|
|
20
|
+
.mixin(ShapeMixin)
|
|
17
21
|
.mixin(RippleMixin)
|
|
18
22
|
.mixin(InputMixin)
|
|
19
|
-
.
|
|
23
|
+
.mixin(HyperlinkMixin)
|
|
20
24
|
.define({
|
|
21
25
|
stateTargetElement() { return this.refs.control; },
|
|
22
26
|
})
|
|
23
27
|
.set({
|
|
24
28
|
stateLayer: true,
|
|
25
|
-
|
|
29
|
+
_allowedTypes: ['button', 'submit', 'reset', 'file'],
|
|
26
30
|
})
|
|
27
31
|
.observe({
|
|
28
|
-
type: {
|
|
32
|
+
type: {
|
|
33
|
+
empty: 'button',
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} value
|
|
36
|
+
* @param {*} internalSet
|
|
37
|
+
*/
|
|
38
|
+
set(value, internalSet) {
|
|
39
|
+
const enumeratedValue = value?.toLowerCase() ?? 'button';
|
|
40
|
+
internalSet(
|
|
41
|
+
this._allowedTypes.includes(enumeratedValue)
|
|
42
|
+
? enumeratedValue
|
|
43
|
+
: 'button',
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
29
47
|
elevated: 'boolean',
|
|
30
48
|
filled: 'string',
|
|
31
49
|
outlined: 'boolean',
|
|
@@ -33,35 +51,41 @@ export default CustomElement
|
|
|
33
51
|
iconInk: 'string',
|
|
34
52
|
src: 'string',
|
|
35
53
|
svg: 'string',
|
|
54
|
+
viewBox: 'string',
|
|
36
55
|
svgPath: 'string',
|
|
37
56
|
})
|
|
38
57
|
.expressions({
|
|
39
|
-
hasIcon({ icon, svg, src, svgPath }) {
|
|
58
|
+
hasIcon({ icon, svg, src, svgPath } = this) {
|
|
40
59
|
return icon ?? svg ?? src ?? svgPath;
|
|
41
60
|
},
|
|
61
|
+
iconVariation({ outlined } = this) {
|
|
62
|
+
return outlined ? null : 'filled';
|
|
63
|
+
},
|
|
42
64
|
})
|
|
43
|
-
.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
surface, control, label, slot,
|
|
52
|
-
icon,
|
|
53
|
-
} = this.refs;
|
|
54
|
-
surface.append(shape);
|
|
55
|
-
shape.append(state, rippleContainer, surfaceTint);
|
|
56
|
-
label.append(icon, slot);
|
|
57
|
-
|
|
58
|
-
shape.setAttribute('filled', '{filled}');
|
|
59
|
-
control.setAttribute('role', 'button');
|
|
65
|
+
.methods({
|
|
66
|
+
/** @type {HTMLElement['focus']} */
|
|
67
|
+
focus(...options) {
|
|
68
|
+
if (this.href) {
|
|
69
|
+
this.refs.anchor.focus(...options);
|
|
70
|
+
} else {
|
|
71
|
+
this.refs.control.focus(...options);
|
|
72
|
+
}
|
|
60
73
|
},
|
|
61
74
|
})
|
|
75
|
+
.html`
|
|
76
|
+
<mdw-icon mdw-if={hasIcon} id=icon ink={iconInk} disabled={disabledState}
|
|
77
|
+
outlined={outlined} variation={iconVariation} aria-hidden=true svg={svg} src={src}
|
|
78
|
+
svg-path={svgPath} view-box={viewBox} icon={icon}></mdw-icon>
|
|
79
|
+
<slot id=slot disabled={disabledState} aria-hidden=true>{_defaultValue}</slot>
|
|
80
|
+
`
|
|
81
|
+
.recompose(({ refs: { anchor, control } }) => {
|
|
82
|
+
control.setAttribute('mdw-if', '{!href}');
|
|
83
|
+
control.setAttribute('role', 'button');
|
|
84
|
+
anchor.setAttribute('mdw-if', '{href}');
|
|
85
|
+
anchor.setAttribute('aria-label', '{_computedAriaLabel}');
|
|
86
|
+
anchor.setAttribute('aria-labelledby', '{_computedAriaLabelledby}');
|
|
87
|
+
})
|
|
62
88
|
.css`
|
|
63
|
-
/* https://m3.material.io/components/buttons/specs */
|
|
64
|
-
|
|
65
89
|
:host {
|
|
66
90
|
--mdw-shape__size: var(--mdw-shape__full);
|
|
67
91
|
--mdw-ink: var(--mdw-color__primary);
|
|
@@ -94,27 +118,39 @@ export default CustomElement
|
|
|
94
118
|
}
|
|
95
119
|
|
|
96
120
|
:host(:where([elevated],[filled])) {
|
|
97
|
-
|
|
121
|
+
transition: box-shadow 200ms;
|
|
122
|
+
will-change: box-shadow;
|
|
98
123
|
}
|
|
99
124
|
|
|
100
125
|
/** Elevated Color Defaults */
|
|
101
126
|
:host(:where([elevated])) {
|
|
102
|
-
--mdw-bg: var(--mdw-color__surface);
|
|
127
|
+
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
103
128
|
--mdw-ink: var(--mdw-color__primary);
|
|
104
|
-
|
|
105
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__2);
|
|
106
|
-
--mdw-surface__tint: var(--mdw-surface__tint__1);
|
|
107
|
-
--mdw-surface__tint__raised: var(--mdw-surface__tint__2);
|
|
129
|
+
box-shadow: var(--mdw-elevation__box-shadow__1);
|
|
108
130
|
}
|
|
109
131
|
/** Filled Color Defaults */
|
|
110
132
|
:host(:where([filled])) {
|
|
111
133
|
--mdw-bg: var(--mdw-color__primary);
|
|
112
134
|
--mdw-ink: var(--mdw-color__on-primary);
|
|
113
|
-
|
|
114
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__1);
|
|
115
|
-
--mdw-surface__tint: 0;
|
|
116
|
-
--mdw-surface__tint__raised: var(--mdw-surface__tint__1);
|
|
135
|
+
box-shadow: var(--mdw-elevation__box-shadow__0);
|
|
117
136
|
}
|
|
137
|
+
|
|
138
|
+
:host(:where([elevated]:hover:not(:active))) {
|
|
139
|
+
box-shadow: var(--mdw-elevation__box-shadow__2);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
:host(:where([filled]:hover:not(:active))) {
|
|
143
|
+
box-shadow: var(--mdw-elevation__box-shadow__1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
:host(:where([elevated]:disabled)) {
|
|
147
|
+
box-shadow: var(--mdw-elevation__box-shadow__0);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:host(:where([filled]:disabled)) {
|
|
151
|
+
box-shadow: var(--mdw-elevation__box-shadow__0);
|
|
152
|
+
}
|
|
153
|
+
|
|
118
154
|
/** Filled Tonal Color Defaults */
|
|
119
155
|
:host(:where([filled="tonal"])) {
|
|
120
156
|
--mdw-bg: var(--mdw-color__secondary-container);
|
|
@@ -141,7 +177,7 @@ export default CustomElement
|
|
|
141
177
|
padding-inline: calc(16px + (var(--mdw-density) * 2px)) calc(24px + (var(--mdw-density) * 2px));
|
|
142
178
|
}
|
|
143
179
|
|
|
144
|
-
|
|
180
|
+
:host(:where([elevated],[filled],[color])) {
|
|
145
181
|
background-color: rgb(var(--mdw-bg));
|
|
146
182
|
}
|
|
147
183
|
|
|
@@ -152,7 +188,15 @@ export default CustomElement
|
|
|
152
188
|
}
|
|
153
189
|
|
|
154
190
|
#control {
|
|
155
|
-
cursor:
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
#anchor {
|
|
195
|
+
position: absolute;
|
|
196
|
+
inset: 0;
|
|
197
|
+
|
|
198
|
+
cursor: pointer;
|
|
199
|
+
outline: none;
|
|
156
200
|
}
|
|
157
201
|
|
|
158
202
|
:host([disabled]) {
|
|
@@ -161,7 +205,7 @@ export default CustomElement
|
|
|
161
205
|
color: rgba(var(--mdw-color__on-surface), 0.38);
|
|
162
206
|
}
|
|
163
207
|
|
|
164
|
-
|
|
208
|
+
:host([disabled]:is([elevated], [filled])) {
|
|
165
209
|
background-color: rgba(var(--mdw-color__on-surface), 0.12);
|
|
166
210
|
color: rgba(var(--mdw-color__on-surface), 0.38);
|
|
167
211
|
}
|
|
@@ -172,11 +216,6 @@ export default CustomElement
|
|
|
172
216
|
|
|
173
217
|
#icon {
|
|
174
218
|
font-size: calc(18/14 * 1em);
|
|
175
|
-
font-variation-settings: 'FILL' 1;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
#icon[outlined] {
|
|
179
|
-
font-variation-settings: 'FILL' 0;
|
|
180
219
|
}
|
|
181
220
|
|
|
182
221
|
#icon[disabled] {
|
|
@@ -185,47 +224,14 @@ export default CustomElement
|
|
|
185
224
|
color: rgba(var(--mdw-color__on-surface));
|
|
186
225
|
}
|
|
187
226
|
|
|
188
|
-
#
|
|
189
|
-
cursor: pointer;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
#label[disabled] {
|
|
227
|
+
#control[form-disabled] {
|
|
193
228
|
cursor: not-allowed;
|
|
194
229
|
}
|
|
195
230
|
|
|
196
231
|
@media (any-pointer: coarse) {
|
|
197
232
|
#touch-target {
|
|
198
|
-
visibility:
|
|
233
|
+
visibility: inherit;
|
|
199
234
|
}
|
|
200
235
|
}
|
|
201
236
|
`
|
|
202
|
-
.childEvents({
|
|
203
|
-
control: {
|
|
204
|
-
/**
|
|
205
|
-
* Duplicates button for form submission
|
|
206
|
-
* @see https://github.com/WICG/webcomponents/issues/814
|
|
207
|
-
* @param {{currentTarget:HTMLInputElement}} event
|
|
208
|
-
* @type {any}
|
|
209
|
-
*/
|
|
210
|
-
'~click'({ currentTarget }) {
|
|
211
|
-
if (currentTarget.disabled) return;
|
|
212
|
-
if (currentTarget.type !== 'submit') return;
|
|
213
|
-
if (this.disabled) return;
|
|
214
|
-
const { value } = currentTarget;
|
|
215
|
-
const form = this.elementInternals?.form;
|
|
216
|
-
if (!form) return;
|
|
217
|
-
this.elementInternals.setFormValue(value);
|
|
218
|
-
if ((currentTarget.type ?? 'submit') !== 'submit') return;
|
|
219
|
-
const duplicatedButton = /** @type {HTMLInputElement} */ (currentTarget.cloneNode());
|
|
220
|
-
duplicatedButton.hidden = true;
|
|
221
|
-
form.append(duplicatedButton);
|
|
222
|
-
if ('requestSubmit' in form) {
|
|
223
|
-
form.requestSubmit(duplicatedButton);
|
|
224
|
-
} else {
|
|
225
|
-
duplicatedButton.click();
|
|
226
|
-
}
|
|
227
|
-
duplicatedButton.remove();
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
})
|
|
231
237
|
.autoRegister('mdw-button');
|
package/components/Button.md
CHANGED
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
|
|
42
42
|
## Custom
|
|
43
43
|
```html
|
|
44
|
-
<mdw-button
|
|
45
|
-
<mdw-button
|
|
46
|
-
<mdw-button
|
|
47
|
-
<mdw-button
|
|
48
|
-
<mdw-button
|
|
44
|
+
<mdw-button ink=yellow>Custom text</mdw-button>
|
|
45
|
+
<mdw-button elevated ink=yellow>Custom elevated</mdw-button>
|
|
46
|
+
<mdw-button filled color=yellow>Custom filled</mdw-button>
|
|
47
|
+
<mdw-button filled=tonal icon=add color=yellow-container>Custom tonal</mdw-button>
|
|
48
|
+
<mdw-button outlined ink=yellow>Custom outlined</mdw-button>
|
|
49
49
|
<mdw-button disabled outlined>Outlined (Disabled)</mdw-button>
|
|
50
50
|
<mdw-button disabled outlined icon=add>Outlined icon (Disabled)</mdw-button>
|
|
51
|
-
<mdw-button disabled
|
|
52
|
-
<mdw-button disabled
|
|
53
|
-
<mdw-button disabled filled
|
|
54
|
-
<mdw-button disabled filled=tonal
|
|
51
|
+
<mdw-button disabled ink=yellow>Custom text</mdw-button>
|
|
52
|
+
<mdw-button disabled elevated=yellow>Custom elevated</mdw-button>
|
|
53
|
+
<mdw-button disabled filled color=yellow>Custom filled</mdw-button>
|
|
54
|
+
<mdw-button disabled filled=tonal icon=add color=yellow-container>Custom tonal</mdw-button>
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
```js
|
package/components/Card.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
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';
|
|
11
|
+
|
|
12
|
+
/* https://m3.material.io/components/cards/specs */
|
|
10
13
|
|
|
11
14
|
const SUPPORTS_INERT = 'inert' in HTMLElement.prototype;
|
|
12
15
|
|
|
13
|
-
export default
|
|
14
|
-
.
|
|
15
|
-
.mixin(
|
|
16
|
-
.mixin(
|
|
16
|
+
export default Box
|
|
17
|
+
.extend()
|
|
18
|
+
.mixin(StateMixin)
|
|
19
|
+
.mixin(ElevationMixin)
|
|
17
20
|
.mixin(ShapeMixin)
|
|
18
21
|
.mixin(FormAssociatedMixin) // Tap into FormAssociated for disabledState
|
|
19
|
-
.mixin(StateMixin)
|
|
20
22
|
.mixin(AriaReflectorMixin)
|
|
21
|
-
.
|
|
22
|
-
.
|
|
23
|
-
delegatesFocus: true,
|
|
24
|
-
})
|
|
23
|
+
.mixin(DelegatesFocusMixin)
|
|
24
|
+
.mixin(HyperlinkMixin)
|
|
25
25
|
.set({
|
|
26
26
|
_ariaRole: 'figure',
|
|
27
27
|
})
|
|
28
28
|
.observe({
|
|
29
|
+
elevated: 'boolean',
|
|
29
30
|
filled: 'boolean',
|
|
30
31
|
actionable: 'boolean',
|
|
31
32
|
actionLabel: 'string',
|
|
@@ -35,7 +36,8 @@ export default CustomElement
|
|
|
35
36
|
stateTargetElement() { return this.actionable ? this.refs.action : this; },
|
|
36
37
|
})
|
|
37
38
|
.expressions({
|
|
38
|
-
showBlocker: ({ disabledState }) =>
|
|
39
|
+
showBlocker: ({ disabledState, disabled }) => disabledState && (!disabled || !SUPPORTS_INERT),
|
|
40
|
+
showButton: ({ actionable, href }) => Boolean(actionable || href),
|
|
39
41
|
})
|
|
40
42
|
.methods({
|
|
41
43
|
focus() {
|
|
@@ -43,75 +45,63 @@ export default CustomElement
|
|
|
43
45
|
if (this.actionable) this.refs.action.focus();
|
|
44
46
|
},
|
|
45
47
|
})
|
|
46
|
-
.html
|
|
47
|
-
<mdw-button
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
.html`
|
|
49
|
+
<mdw-button mdw-if={showButton} aria-label={actionLabel} href={href}
|
|
50
|
+
target={target}
|
|
51
|
+
download={download}
|
|
52
|
+
ping={ping}
|
|
53
|
+
rel={rel}
|
|
54
|
+
hreflang={hreflang}
|
|
55
|
+
referrerpolicy={referrerPolicy} id=action disabled={disabledState}></mdw-button>
|
|
56
|
+
<div mdw-if={showBlocker} id=inert-blocker></div>
|
|
50
57
|
`
|
|
58
|
+
.recompose(({ refs: { anchor, inertBlocker, slot } }) => {
|
|
59
|
+
anchor.remove();
|
|
60
|
+
slot.setAttribute('disabled', '{disabledState}');
|
|
61
|
+
inertBlocker.before(slot);
|
|
62
|
+
})
|
|
51
63
|
.css`
|
|
52
|
-
/* https://m3.material.io/components/cards/specs */
|
|
53
|
-
|
|
54
64
|
:host {
|
|
55
|
-
--mdw-shape__size:
|
|
56
|
-
--mdw-surface__tint: var(--mdw-surface__tint__0);
|
|
57
|
-
--mdw-surface__tint__raised: var(--mdw-surface__tint);
|
|
65
|
+
--mdw-shape__size: var(--mdw-shape__medium);
|
|
58
66
|
|
|
59
|
-
--mdw-surface__shadow__resting: none;
|
|
60
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__resting);
|
|
61
67
|
/* padding-inline: 12px; */
|
|
62
68
|
|
|
63
69
|
--mdw-bg: var(--mdw-color__surface);
|
|
64
70
|
--mdw-ink: var(--mdw-color__on-surface);
|
|
65
71
|
position: relative;
|
|
66
72
|
|
|
67
|
-
display: block;
|
|
68
|
-
|
|
69
|
-
color: rgb(var(--mdw-ink));
|
|
70
|
-
|
|
71
73
|
font: var(--mdw-type__font);
|
|
72
74
|
letter-spacing: var(--mdw-type__letter-spacing);
|
|
73
|
-
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
transition: filter 200ms;
|
|
77
|
+
will-change: filter;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
:host(:where([filled])) {
|
|
80
|
-
|
|
81
|
-
--mdw-ink: var(--mdw-color__on-surface-variant);
|
|
80
|
+
:host(:where([elevated],[filled],[outlined])) {
|
|
81
|
+
background-color: rgb(var(--mdw-bg));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
:host(:where([elevated])) {
|
|
85
|
-
--mdw-bg: var(--mdw-color__surface);
|
|
85
|
+
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
86
86
|
--mdw-ink: var(--mdw-color__on-surface);
|
|
87
|
+
filter: var(--mdw-elevation__drop-shadow__1);
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
:host([filled]) {
|
|
90
|
-
--mdw-
|
|
91
|
-
--mdw-
|
|
90
|
+
:host(:where([filled])) {
|
|
91
|
+
--mdw-bg: var(--mdw-color__surface-container-highest);
|
|
92
|
+
--mdw-ink: var(--mdw-color__on-surface-variant);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
:host([filled][actionable]) {
|
|
95
|
-
|
|
96
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__1);
|
|
95
|
+
:host(:where([filled][actionable])) {
|
|
96
|
+
filter: var(--mdw-elevation__drop-shadow__0);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
:host([elevated]) {
|
|
100
|
-
|
|
101
|
-
--mdw-surface__shadow__resting: var(--mdw-surface__shadow__1);
|
|
99
|
+
:host(:where([elevated][actionable]:hover:not(:active))) {
|
|
100
|
+
filter: var(--mdw-elevation__drop-shadow__2);
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
:host([
|
|
105
|
-
|
|
106
|
-
--mdw-surface__shadow__raised: var(--mdw-surface__shadow__2);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
#shape[disabled] {
|
|
110
|
-
|
|
111
|
-
/* Works on images */
|
|
112
|
-
filter: grayscale();
|
|
113
|
-
|
|
114
|
-
color: rgb(var(--mdw-color__on-surface));
|
|
103
|
+
:host(:where([filled][actionable]:hover:not(:active))) {
|
|
104
|
+
filter: var(--mdw-elevation__drop-shadow__1);
|
|
115
105
|
}
|
|
116
106
|
|
|
117
107
|
:host([disabled]) {
|
|
@@ -119,6 +109,8 @@ export default CustomElement
|
|
|
119
109
|
|
|
120
110
|
filter: grayscale();
|
|
121
111
|
opacity: 0.38;
|
|
112
|
+
|
|
113
|
+
color: rgb(var(--mdw-color__on-surface));
|
|
122
114
|
}
|
|
123
115
|
|
|
124
116
|
#slot[disabled] {
|
|
@@ -141,8 +133,12 @@ export default CustomElement
|
|
|
141
133
|
z-index: 99;
|
|
142
134
|
}
|
|
143
135
|
|
|
144
|
-
|
|
145
|
-
background-color: rgba(var(--mdw-color__surface-
|
|
136
|
+
:host([disabled][elevated]) {
|
|
137
|
+
background-color: rgba(var(--mdw-color__surface-container-highest));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
:host([disabled][filled]) {
|
|
141
|
+
background-color: rgba(var(--mdw-color__surface));
|
|
146
142
|
}
|
|
147
143
|
|
|
148
144
|
#action {
|
|
@@ -159,20 +155,12 @@ export default CustomElement
|
|
|
159
155
|
color: inherit
|
|
160
156
|
}
|
|
161
157
|
`
|
|
162
|
-
.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
outline.removeAttribute('focused');
|
|
169
|
-
|
|
170
|
-
shape.setAttribute('filled', '{filled}');
|
|
171
|
-
slot.setAttribute('inert', '{disabledState}');
|
|
172
|
-
slot.setAttribute('disabled', '{disabledState}');
|
|
173
|
-
// shape.setAttribute('disabled', '{disabledState}');
|
|
174
|
-
// shape.setAttribute('filled', '{filled}');
|
|
175
|
-
},
|
|
158
|
+
.recompose(({ refs: { slot, outline } }) => {
|
|
159
|
+
outline.removeAttribute('pressed');
|
|
160
|
+
outline.removeAttribute('focused');
|
|
161
|
+
|
|
162
|
+
slot.setAttribute('inert', '{disabledState}');
|
|
163
|
+
slot.setAttribute('disabled', '{disabledState}');
|
|
176
164
|
})
|
|
177
165
|
.childEvents({
|
|
178
166
|
action: {
|
package/components/Checkbox.js
CHANGED
|
@@ -8,12 +8,12 @@ import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
|
8
8
|
import TouchTargetMixin from '../mixins/TouchTargetMixin.js';
|
|
9
9
|
|
|
10
10
|
export default CustomElement
|
|
11
|
+
.extend()
|
|
11
12
|
.mixin(ThemableMixin)
|
|
12
13
|
.mixin(StateMixin)
|
|
13
14
|
.mixin(RippleMixin)
|
|
14
15
|
.mixin(InputMixin)
|
|
15
16
|
.mixin(TouchTargetMixin)
|
|
16
|
-
.extend()
|
|
17
17
|
.set({
|
|
18
18
|
stateLayer: true,
|
|
19
19
|
type: 'checkbox',
|
|
@@ -21,16 +21,25 @@ export default CustomElement
|
|
|
21
21
|
.observe({
|
|
22
22
|
icon: { value: 'check' },
|
|
23
23
|
indeterminateIcon: { value: 'check_indeterminate_small' },
|
|
24
|
-
/** Reflected property */
|
|
25
|
-
indeterminate: 'boolean',
|
|
26
24
|
})
|
|
27
|
-
.
|
|
28
|
-
_ariaChecked({ indeterminate, checked }) {
|
|
29
|
-
return (indeterminate ? 'mixed' : `${!!checked}`);
|
|
30
|
-
},
|
|
25
|
+
.expressions({
|
|
31
26
|
_determinateIcon({ indeterminate, indeterminateIcon, icon }) {
|
|
32
27
|
return (indeterminate ? indeterminateIcon : icon);
|
|
33
28
|
},
|
|
29
|
+
_iconSelectedState({ checked, indeterminate }) {
|
|
30
|
+
return checked || indeterminate;
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
.html`
|
|
34
|
+
<div id=checkbox errored={erroredState} selected={checked}>
|
|
35
|
+
<mdw-checkbox-icon id=icon errored={erroredState} disabled={disabledState}
|
|
36
|
+
icon={_determinateIcon} selected={_iconSelectedState}>
|
|
37
|
+
</mdw-checkbox-icon>
|
|
38
|
+
</div>
|
|
39
|
+
<slot id=slot></slot>
|
|
40
|
+
`
|
|
41
|
+
.recompose(({ refs: { checkbox, state, rippleContainer } }) => {
|
|
42
|
+
checkbox.append(state, rippleContainer);
|
|
34
43
|
})
|
|
35
44
|
.css`
|
|
36
45
|
/* https://m3.material.io/components/checkbox/specs */
|
|
@@ -50,7 +59,15 @@ export default CustomElement
|
|
|
50
59
|
transition: none 100ms cubic-bezier(0.4, 0.0, 1, 1);
|
|
51
60
|
}
|
|
52
61
|
|
|
53
|
-
:host(
|
|
62
|
+
:host(:disabled) {
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
|
|
65
|
+
opacity: 0.38;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host([internals-disabled]) {
|
|
69
|
+
cursor: not-allowed;
|
|
70
|
+
|
|
54
71
|
opacity: 0.38;
|
|
55
72
|
}
|
|
56
73
|
|
|
@@ -60,28 +77,18 @@ export default CustomElement
|
|
|
60
77
|
line-height: 18px;
|
|
61
78
|
}
|
|
62
79
|
|
|
63
|
-
:host(:empty) #checkbox {
|
|
64
|
-
transform: none;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
80
|
#control {
|
|
68
81
|
grid-column: 1/1;
|
|
69
82
|
|
|
70
83
|
cursor: inherit;
|
|
71
84
|
}
|
|
72
85
|
|
|
73
|
-
#label {
|
|
74
|
-
cursor: inherit;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#label[disabled] {
|
|
78
|
-
cursor: not-allowed;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
86
|
#state,
|
|
82
87
|
#ripple-container {
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
/* stylelint-disable-next-line liberty/use-logical-spec */
|
|
89
|
+
top: 50%;
|
|
90
|
+
/* stylelint-disable-next-line liberty/use-logical-spec */
|
|
91
|
+
left: 50%;
|
|
85
92
|
|
|
86
93
|
block-size: 40px;
|
|
87
94
|
inline-size: 40px;
|
|
@@ -117,30 +124,14 @@ export default CustomElement
|
|
|
117
124
|
color: rgb(var(--mdw-color__error));
|
|
118
125
|
}
|
|
119
126
|
|
|
127
|
+
:host(:empty) #checkbox {
|
|
128
|
+
transform: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
120
131
|
#icon {
|
|
121
132
|
--mdw-ink: inherit;
|
|
122
133
|
--mdw-bg: inherit;
|
|
123
134
|
--disabled-opacity: 1;
|
|
124
135
|
}
|
|
125
136
|
`
|
|
126
|
-
.on({
|
|
127
|
-
composed({ html }) {
|
|
128
|
-
const { label, control, state, rippleContainer, touchTarget } = this.refs;
|
|
129
|
-
label.append(html`
|
|
130
|
-
${touchTarget}
|
|
131
|
-
${control}
|
|
132
|
-
<div id=checkbox errored={erroredState} selected={checked}>
|
|
133
|
-
<mdw-checkbox-icon id=icon errored={erroredState} disabled={disabledState}
|
|
134
|
-
icon={_determinateIcon} selected={checked}>
|
|
135
|
-
</mdw-checkbox-icon>
|
|
136
|
-
${state}
|
|
137
|
-
${rippleContainer}
|
|
138
|
-
</div>
|
|
139
|
-
<slot id=slot></slot>
|
|
140
|
-
`);
|
|
141
|
-
|
|
142
|
-
// Indeterminate must be manually expressed for ARIA
|
|
143
|
-
control.setAttribute('aria-checked', '{_ariaChecked}');
|
|
144
|
-
},
|
|
145
|
-
})
|
|
146
137
|
.autoRegister('mdw-checkbox');
|