@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
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import CustomElement from '../core/CustomElement.js';
|
|
2
|
+
import { ELEMENT_ANIMATION_TYPE, ELEMENT_STYLE_TYPE, EVENT_HANDLER_TYPE } from '../core/customTypes.js';
|
|
3
|
+
import { isRtl } from '../core/dom.js';
|
|
4
|
+
import AriaReflectorMixin from '../mixins/AriaReflectorMixin.js';
|
|
5
|
+
import DelegatesFocusMixin from '../mixins/DelegatesFocusMixin.js';
|
|
6
|
+
import ElevationMixin from '../mixins/ElevationMixin.js';
|
|
7
|
+
import FlexableMixin from '../mixins/FlexableMixin.js';
|
|
8
|
+
import ResizeObserverMixin from '../mixins/ResizeObserverMixin.js';
|
|
9
|
+
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
10
|
+
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
11
|
+
|
|
12
|
+
import Scrim from './Scrim.js';
|
|
13
|
+
|
|
14
|
+
const SUPPORTS_SCROLLEND = 'onscrollend' in window;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Side sheets may be static.
|
|
18
|
+
* Side sheets may be modal while retaining their own position.
|
|
19
|
+
* Side sheets can have different modal and static max-sizes.
|
|
20
|
+
* Side sheets can be themed with background color and ink.
|
|
21
|
+
* Side sheets can be shaped.
|
|
22
|
+
* Side sheets do not have states
|
|
23
|
+
* Side sheets can have roles
|
|
24
|
+
* Side sheets delegate focus
|
|
25
|
+
* Static side sheets push in and out content.
|
|
26
|
+
* Modal side sheets slide in and out over content.
|
|
27
|
+
* Modal side sheets anchor position does not need to match static position.
|
|
28
|
+
* Modal side sheets must become "dialog-like", blocking access to all other elements on the screen.
|
|
29
|
+
* Modal side sheets can display elevation
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Side sheets present content in a surface that slides in from an edge; they
|
|
33
|
+
* support modal and static modes and can be themed and shaped.
|
|
34
|
+
* @see https://m3.material.io/components/side-sheets/overview
|
|
35
|
+
*/
|
|
36
|
+
export default CustomElement
|
|
37
|
+
.extend()
|
|
38
|
+
.mixin(ThemableMixin)
|
|
39
|
+
.mixin(FlexableMixin)
|
|
40
|
+
.mixin(ElevationMixin)
|
|
41
|
+
.mixin(ShapeMixin)
|
|
42
|
+
.mixin(AriaReflectorMixin)
|
|
43
|
+
.mixin(DelegatesFocusMixin)
|
|
44
|
+
.mixin(ResizeObserverMixin)
|
|
45
|
+
.observe({
|
|
46
|
+
/** When true the side sheet is fixed (non-modal/static), occupying layout space. */
|
|
47
|
+
fixed: 'boolean',
|
|
48
|
+
/** Whether the sheet is currently open (visible). */
|
|
49
|
+
open: 'boolean',
|
|
50
|
+
/** When true, position the sheet at the inline end edge. */
|
|
51
|
+
inlineEnd: 'boolean',
|
|
52
|
+
/** Last measured inline size (px) used for layout/translate calculations. */
|
|
53
|
+
_lastComputedInlineSize: {
|
|
54
|
+
type: 'float',
|
|
55
|
+
nullable: false,
|
|
56
|
+
},
|
|
57
|
+
/** Animation duration (ms) for sheet open/close transitions. */
|
|
58
|
+
_animationDuration: {
|
|
59
|
+
type: 'integer',
|
|
60
|
+
value: 0,
|
|
61
|
+
},
|
|
62
|
+
/** Animation easing keyword used for sheet transitions. */
|
|
63
|
+
_animationEasing: {
|
|
64
|
+
value: 'ease-out',
|
|
65
|
+
},
|
|
66
|
+
/** Current drag delta X (px) while user is swiping the sheet. */
|
|
67
|
+
_dragDeltaX: 'float',
|
|
68
|
+
/** Starting X coordinate (px) for a drag gesture. */
|
|
69
|
+
_dragStartX: 'float',
|
|
70
|
+
/** CSS translateX value used to animate the sheet position. */
|
|
71
|
+
_translateX: { value: '-100%' },
|
|
72
|
+
/** Timestamp of the last child scroll event (used to avoid gesture conflicts). */
|
|
73
|
+
_lastChildScrollTime: 'float',
|
|
74
|
+
/** Event handler invoked when the sheet toggles. */
|
|
75
|
+
ontoggle: EVENT_HANDLER_TYPE,
|
|
76
|
+
/** Event handler invoked when the sheet closes. */
|
|
77
|
+
onclose: EVENT_HANDLER_TYPE,
|
|
78
|
+
/** Optional auto-open minimum viewport inline-size (px); -1 disables. */
|
|
79
|
+
autoOpen: {
|
|
80
|
+
type: 'float',
|
|
81
|
+
empty: -1,
|
|
82
|
+
},
|
|
83
|
+
/** Optional auto-close maximum viewport inline-size (px); -1 disables. */
|
|
84
|
+
autoClose: {
|
|
85
|
+
type: 'float',
|
|
86
|
+
empty: -1,
|
|
87
|
+
},
|
|
88
|
+
/** Inline-size breakpoint (px) at which the sheet becomes `fixed`. */
|
|
89
|
+
fixedBreakpoint: {
|
|
90
|
+
type: 'float',
|
|
91
|
+
empty: 0,
|
|
92
|
+
},
|
|
93
|
+
/** Internal flag computed from directionality and `inlineEnd`. */
|
|
94
|
+
_isSideSheetRtl: 'boolean',
|
|
95
|
+
/** The theme color token used for the sheet background. */
|
|
96
|
+
color: 'string',
|
|
97
|
+
/** Optional fixed-mode color token applied when sheet is fixed. */
|
|
98
|
+
fixedColor: 'string',
|
|
99
|
+
})
|
|
100
|
+
.set({
|
|
101
|
+
/** @type {InstanceType<Scrim>} */
|
|
102
|
+
_scrim: null,
|
|
103
|
+
})
|
|
104
|
+
.observe({
|
|
105
|
+
/** Computed host style when `fixed` and `fixedColor` are set. */
|
|
106
|
+
_styles: {
|
|
107
|
+
...ELEMENT_STYLE_TYPE,
|
|
108
|
+
get({ fixed, fixedColor }) {
|
|
109
|
+
if (fixed && fixedColor) {
|
|
110
|
+
return { backgroundColor: `rgb(var(--mdw-color__${fixedColor}))` };
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
/** Computed animation/style object applied to the host for open/close. */
|
|
115
|
+
hostStyles: {
|
|
116
|
+
...ELEMENT_ANIMATION_TYPE,
|
|
117
|
+
get({
|
|
118
|
+
open, fixed, _isSideSheetRtl, _lastComputedInlineSize, _translateX,
|
|
119
|
+
_animationDuration, _animationEasing,
|
|
120
|
+
}) {
|
|
121
|
+
const computedMargin = (open || !fixed) ? 0 : `${-1 * _lastComputedInlineSize}px`;
|
|
122
|
+
return {
|
|
123
|
+
styles: {
|
|
124
|
+
marginLeft: _isSideSheetRtl ? 0 : computedMargin,
|
|
125
|
+
marginRight: _isSideSheetRtl ? computedMargin : 0,
|
|
126
|
+
transform: fixed ? 'none' : `translateX(${_translateX})`,
|
|
127
|
+
},
|
|
128
|
+
timing: {
|
|
129
|
+
duration: _animationDuration,
|
|
130
|
+
easing: _animationEasing,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
})
|
|
136
|
+
.html`<slot id=slot></slot>`
|
|
137
|
+
.methods({
|
|
138
|
+
/**
|
|
139
|
+
* Ensure a scrim is present when the sheet is modal (open && !fixed).
|
|
140
|
+
* When `animate` is true, keep the scrim around to run its fade-out.
|
|
141
|
+
*/
|
|
142
|
+
checkForScrim(animate = false) {
|
|
143
|
+
let { open, fixed, _scrim } = this;
|
|
144
|
+
if (open && !fixed) {
|
|
145
|
+
if (!_scrim) {
|
|
146
|
+
_scrim = new Scrim();
|
|
147
|
+
_scrim.addEventListener('click', () => {
|
|
148
|
+
this.open = false;
|
|
149
|
+
if (!this.dispatchEvent(new Event('close', { cancelable: true }))) {
|
|
150
|
+
// Revert if cancelled
|
|
151
|
+
this.open = true;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
this._scrim = _scrim;
|
|
155
|
+
}
|
|
156
|
+
this.before(_scrim);
|
|
157
|
+
_scrim.hidden = false;
|
|
158
|
+
} else if (_scrim) {
|
|
159
|
+
if (!animate) {
|
|
160
|
+
_scrim.remove();
|
|
161
|
+
}
|
|
162
|
+
_scrim.hidden = true;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
/** Evaluate drag state and decide whether to close or snap open. */
|
|
166
|
+
checkDragFinished() {
|
|
167
|
+
const { open, _dragDeltaX, _lastComputedInlineSize, fixed, _isSideSheetRtl } = this;
|
|
168
|
+
if (!open || fixed || _dragDeltaX == null) return;
|
|
169
|
+
const visibility = (_dragDeltaX + _lastComputedInlineSize) / _lastComputedInlineSize;
|
|
170
|
+
if (visibility < 0.5) {
|
|
171
|
+
// Should close
|
|
172
|
+
this._animationDuration = 200 * visibility;
|
|
173
|
+
this._animationEasing = 'ease-out';
|
|
174
|
+
this._translateX = _isSideSheetRtl ? '-100%' : '100%';
|
|
175
|
+
this.open = false;
|
|
176
|
+
this.dispatchEvent(new Event('close', { cancelable: false }));
|
|
177
|
+
} else {
|
|
178
|
+
// Should snap back to fully open
|
|
179
|
+
this._animationDuration = 250 * (0.5 * visibility);
|
|
180
|
+
this._translateX = '0';
|
|
181
|
+
this._animationEasing = 'ease-in';
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
/** Recompute `fixed`/`open` state based on the window width and breakpoints. */
|
|
185
|
+
onWindowResize() {
|
|
186
|
+
const { autoOpen, fixedBreakpoint, autoClose } = this;
|
|
187
|
+
const containerWidth = window.innerWidth;
|
|
188
|
+
const fixed = (containerWidth >= fixedBreakpoint);
|
|
189
|
+
this.open = fixed
|
|
190
|
+
&& autoOpen >= 0
|
|
191
|
+
&& (containerWidth >= autoOpen && (autoClose === -1 || containerWidth < autoClose));
|
|
192
|
+
this.fixed = fixed;
|
|
193
|
+
},
|
|
194
|
+
})
|
|
195
|
+
.overrides({
|
|
196
|
+
onResizeObserved(entry) {
|
|
197
|
+
this._lastComputedInlineSize = entry.borderBoxSize[0]?.inlineSize;
|
|
198
|
+
},
|
|
199
|
+
})
|
|
200
|
+
.events({
|
|
201
|
+
'~touchstart'(event) {
|
|
202
|
+
if (!event.touches.length) return;
|
|
203
|
+
const { open, fixed, _isSideSheetRtl } = this;
|
|
204
|
+
if (!open || fixed) return;
|
|
205
|
+
let [{ clientX, pageX }] = event.touches;
|
|
206
|
+
clientX ??= pageX - window.scrollX; // Safari
|
|
207
|
+
this._dragStartX = _isSideSheetRtl
|
|
208
|
+
? window.innerWidth - clientX
|
|
209
|
+
: clientX;
|
|
210
|
+
this._dragDeltaX = 0;
|
|
211
|
+
},
|
|
212
|
+
'~touchmove'({ touches }) {
|
|
213
|
+
if (!touches.length) return;
|
|
214
|
+
const { open, fixed, _lastChildScrollTime, _dragStartX, _isSideSheetRtl } = this;
|
|
215
|
+
if (!open || fixed || _dragStartX == null) return;
|
|
216
|
+
if (_lastChildScrollTime && performance.now() - _lastChildScrollTime <= (SUPPORTS_SCROLLEND ? 5000 : 500)) {
|
|
217
|
+
// Assume still scrolling
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
let [{ clientX, pageX }] = touches;
|
|
221
|
+
clientX ??= pageX - window.scrollX; // Safari
|
|
222
|
+
|
|
223
|
+
const delta = _isSideSheetRtl
|
|
224
|
+
? Math.min((window.innerWidth - clientX) - _dragStartX, 0)
|
|
225
|
+
: Math.min((clientX - _dragStartX), 0);
|
|
226
|
+
|
|
227
|
+
this._animationDuration = 0;
|
|
228
|
+
this._dragDeltaX = delta;
|
|
229
|
+
this._translateX = `${_isSideSheetRtl ? (-1 * delta) : delta}px`;
|
|
230
|
+
},
|
|
231
|
+
touchcancel: 'checkDragFinished',
|
|
232
|
+
'~touchend': 'checkDragFinished',
|
|
233
|
+
/** Scroll events do no bubble but can be captured, passively */
|
|
234
|
+
'*~scroll'() {
|
|
235
|
+
if (this.fixed) return;
|
|
236
|
+
this.checkDragFinished();
|
|
237
|
+
this._lastChildScrollTime = performance.now();
|
|
238
|
+
// Wiping touch state
|
|
239
|
+
this._dragStartX = null;
|
|
240
|
+
this._dragDeltaX = null;
|
|
241
|
+
},
|
|
242
|
+
'*scrollend'() {
|
|
243
|
+
if (this.fixed) return;
|
|
244
|
+
this._lastChildScrollTime = null;
|
|
245
|
+
},
|
|
246
|
+
})
|
|
247
|
+
.on({
|
|
248
|
+
openChanged(previous, open) {
|
|
249
|
+
// No longer using initial animation timing of 0
|
|
250
|
+
this._animationDuration = open ? 250 : 200;
|
|
251
|
+
this._translateX = open ? '0' : (this.inlineEnd ? '100%' : '-100%');
|
|
252
|
+
this._animationEasing = open ? 'ease-in' : 'ease-out';
|
|
253
|
+
this.checkForScrim(true);
|
|
254
|
+
this.dispatchEvent(new Event('toggle'));
|
|
255
|
+
},
|
|
256
|
+
fixedChanged() {
|
|
257
|
+
this._animationDuration = 0;
|
|
258
|
+
this.checkForScrim(false);
|
|
259
|
+
},
|
|
260
|
+
constructed() {
|
|
261
|
+
window.addEventListener('resize', this.onWindowResize.bind(this));
|
|
262
|
+
},
|
|
263
|
+
connected() {
|
|
264
|
+
this.onWindowResize();
|
|
265
|
+
},
|
|
266
|
+
inlineEndChanged(previous, inlineEnd) {
|
|
267
|
+
this._isSideSheetRtl = isRtl(this) ? !inlineEnd : inlineEnd;
|
|
268
|
+
this._translateX = this.open ? '0' : (this.inlineEnd ? '100%' : '-100%');
|
|
269
|
+
},
|
|
270
|
+
})
|
|
271
|
+
.css`
|
|
272
|
+
:host {
|
|
273
|
+
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
274
|
+
--mdw-ink: var(--mdw-color__on-surface-variant);
|
|
275
|
+
|
|
276
|
+
position: fixed;
|
|
277
|
+
|
|
278
|
+
inset-block: 0;
|
|
279
|
+
inset-inline: 0 auto;
|
|
280
|
+
|
|
281
|
+
display: inline-flex;
|
|
282
|
+
|
|
283
|
+
overflow-y:auto;
|
|
284
|
+
|
|
285
|
+
overscroll-behavior: none;
|
|
286
|
+
overscroll-behavior: contain;
|
|
287
|
+
|
|
288
|
+
box-sizing: border-box;
|
|
289
|
+
block-size: 100vh;
|
|
290
|
+
block-size: 100dvh;
|
|
291
|
+
min-block-size: 100vh;
|
|
292
|
+
min-block-size: 100dvh;
|
|
293
|
+
max-block-size: 100%;
|
|
294
|
+
|
|
295
|
+
max-inline-size: calc(100vw - 56px);
|
|
296
|
+
grid-column: 1;
|
|
297
|
+
|
|
298
|
+
transform: translateX(-100%);
|
|
299
|
+
|
|
300
|
+
visibility: hidden;
|
|
301
|
+
|
|
302
|
+
z-index: 24;
|
|
303
|
+
|
|
304
|
+
background-color: rgb(var(--mdw-bg));
|
|
305
|
+
color: rgb(var(--mdw-ink));
|
|
306
|
+
|
|
307
|
+
transition: visibility 200ms;
|
|
308
|
+
will-change: transform, margin-inline-start, margin-inline-end, visibility;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
:host(:where([open])) {
|
|
312
|
+
visibility: inherit;
|
|
313
|
+
|
|
314
|
+
transition-delay: 0s;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
:host(:where[inline-end]) {
|
|
318
|
+
inset-inline: auto 0;
|
|
319
|
+
|
|
320
|
+
transform: translateX(100%);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
:host(:where([fixed])) {
|
|
324
|
+
position: sticky;
|
|
325
|
+
inset-inline: auto;
|
|
326
|
+
|
|
327
|
+
max-inline-size: none;
|
|
328
|
+
|
|
329
|
+
transform: none;
|
|
330
|
+
z-index: auto;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
:host(:where([inline-end][fixed])) {
|
|
334
|
+
grid-column: 3;
|
|
335
|
+
}
|
|
336
|
+
`
|
|
337
|
+
.autoRegister('mdw-side-sheet');
|
package/components/Slider.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import CustomElement from '../core/CustomElement.js';
|
|
2
|
-
import { isRtl } from '../core/dom.js';
|
|
2
|
+
import { SAFARI_VERSION, isFocused, isRtl } from '../core/dom.js';
|
|
3
3
|
import InputMixin from '../mixins/InputMixin.js';
|
|
4
4
|
import StateMixin from '../mixins/StateMixin.js';
|
|
5
5
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
6
|
+
import { loadGlobalStyles } from '../services/rtl.js';
|
|
7
|
+
|
|
8
|
+
loadGlobalStyles();
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* @param {string} value
|
|
@@ -29,6 +32,10 @@ function valueAsFraction(value, min, max) {
|
|
|
29
32
|
return (nValue - nMin) / (nMax - nMin);
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Slider allows users to select a value from a range by dragging a thumb.
|
|
37
|
+
* @see https://m3.material.io/components/sliders/specs
|
|
38
|
+
*/
|
|
32
39
|
export default CustomElement
|
|
33
40
|
.extend()
|
|
34
41
|
.mixin(ThemableMixin)
|
|
@@ -39,15 +46,26 @@ export default CustomElement
|
|
|
39
46
|
type: 'range',
|
|
40
47
|
})
|
|
41
48
|
.observe({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
/** Number of tick marks to show along the track (integer). */
|
|
50
|
+
ticks: 'integer',
|
|
51
|
+
/** Internal string representation of the current value used for formatting. */
|
|
52
|
+
_valueAsText: { nullable: false },
|
|
53
|
+
/** Text to show in the thumb label; when null the numeric value is shown. */
|
|
54
|
+
thumbLabel: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
reflect: 'read',
|
|
57
|
+
},
|
|
58
|
+
/** Rounded numeric value (used while dragging) tracked as a float. */
|
|
45
59
|
_roundedValue: 'float',
|
|
60
|
+
/** True while the pointer is hovering the thumb (used to show the label). */
|
|
46
61
|
_isHoveringThumb: 'boolean',
|
|
62
|
+
/** Last `value` string that produced a dispatched `change` event; used to avoid duplicates. */
|
|
47
63
|
_lastDispatchedChangeValue: 'string',
|
|
48
64
|
})
|
|
49
65
|
.methods({
|
|
50
66
|
/**
|
|
67
|
+
* Handle pointer or touch interactions on the native control to compute
|
|
68
|
+
* position and update the intermediate rounded value while dragging.
|
|
51
69
|
* @param {(MouseEvent|TouchEvent) & {currentTarget:HTMLInputElement}} event
|
|
52
70
|
* @return {void}
|
|
53
71
|
*/
|
|
@@ -120,7 +138,20 @@ export default CustomElement
|
|
|
120
138
|
}
|
|
121
139
|
|
|
122
140
|
this._roundedValue = roundedValue;
|
|
123
|
-
this.
|
|
141
|
+
this._valueAsText = roundedValue.toString(10);
|
|
142
|
+
if (isTouch && SAFARI_VERSION) {
|
|
143
|
+
// Safari does not update input when drag wasn't initiated at thumb
|
|
144
|
+
if (event.type === 'touchstart') {
|
|
145
|
+
// Default touch action on Safari is to magnify when on track
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
}
|
|
148
|
+
const { _input } = this;
|
|
149
|
+
if (_input.valueAsNumber !== roundedValue) {
|
|
150
|
+
_input.valueAsNumber = roundedValue;
|
|
151
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
124
155
|
return;
|
|
125
156
|
}
|
|
126
157
|
|
|
@@ -136,25 +167,32 @@ export default CustomElement
|
|
|
136
167
|
this._isHoveringThumb = offsetX >= thumbMin && offsetX <= thumbMax;
|
|
137
168
|
},
|
|
138
169
|
|
|
139
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Pointer leave/blur handler for the control; hides the thumb label when focus is lost.
|
|
172
|
+
* @param {Event} event
|
|
173
|
+
*/
|
|
140
174
|
onLeaveEvent({ currentTarget }) {
|
|
141
|
-
if (
|
|
175
|
+
if (isFocused(/** @type {Element} */ (currentTarget))) return;
|
|
142
176
|
this._isHoveringThumb = false;
|
|
143
177
|
},
|
|
144
178
|
|
|
145
179
|
/**
|
|
180
|
+
* Finalize interaction with the control: commit the rounded value to the
|
|
181
|
+
* native input and dispatch a `change` event if the value changed.
|
|
146
182
|
* @param {(MouseEvent|TouchEvent) & {currentTarget:HTMLInputElement}} event
|
|
147
183
|
* @return {void}
|
|
148
184
|
*/
|
|
149
185
|
onControlFinish(event) {
|
|
150
186
|
const input = event.currentTarget;
|
|
151
187
|
if (input.disabled) return;
|
|
152
|
-
event.
|
|
188
|
+
if (event.type === 'click') {
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
}
|
|
153
191
|
input.valueAsNumber = this._roundedValue;
|
|
154
192
|
this._value = input.value;
|
|
155
193
|
if (this._lastDispatchedChangeValue !== this._value) {
|
|
156
194
|
this._lastDispatchedChangeValue = this._value;
|
|
157
|
-
|
|
195
|
+
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
158
196
|
}
|
|
159
197
|
},
|
|
160
198
|
})
|
|
@@ -167,26 +205,39 @@ export default CustomElement
|
|
|
167
205
|
'~mousedown': 'onControlMouseOrTouch',
|
|
168
206
|
'~mousemove': 'onControlMouseOrTouch',
|
|
169
207
|
'~mouseout': 'onControlMouseOrTouch',
|
|
208
|
+
touchstart: 'onControlMouseOrTouch',
|
|
170
209
|
'~touchmove': 'onControlMouseOrTouch',
|
|
171
|
-
'~touchstart': 'onControlMouseOrTouch',
|
|
172
|
-
// @ts-expect-error Old spec
|
|
173
210
|
'~touchleave': 'onControlMouseOrTouch',
|
|
174
211
|
'~touchcancel': 'onControlMouseOrTouch',
|
|
175
212
|
'~touchend': 'onControlMouseOrTouch',
|
|
176
213
|
touchend: 'onControlFinish',
|
|
177
214
|
click: 'onControlFinish',
|
|
215
|
+
'~change'(event) {
|
|
216
|
+
// Change event will be rethrown by ControlMixin
|
|
217
|
+
// Track value to avoid double dispatch
|
|
218
|
+
if (this._lastDispatchedChangeValue === this._value) {
|
|
219
|
+
event.stopPropagation();
|
|
220
|
+
}
|
|
221
|
+
this._lastDispatchedChangeValue = this._value;
|
|
222
|
+
},
|
|
178
223
|
},
|
|
179
224
|
})
|
|
180
225
|
.expressions({
|
|
181
|
-
|
|
226
|
+
/** Compute inline style variables for the track, including ticks and value fraction. */
|
|
227
|
+
computeTrackStyle({ ticks, _valueAsText, min, max }) {
|
|
182
228
|
return [
|
|
183
229
|
ticks ? `--ticks:${ticks}` : null,
|
|
184
|
-
`--value:${valueAsFraction(
|
|
230
|
+
`--value:${valueAsFraction(_valueAsText, min, max)}`,
|
|
185
231
|
].filter(Boolean).join(';') || null;
|
|
186
232
|
},
|
|
233
|
+
/** True when the thumb label should be hidden (not hovering and not focused). */
|
|
187
234
|
_thumbLabelHidden({ _isHoveringThumb, focusedState }) {
|
|
188
235
|
return (!_isHoveringThumb && !focusedState);
|
|
189
236
|
},
|
|
237
|
+
/** Compute the label text to show in the thumb: explicit `thumbLabel` or numeric value. */
|
|
238
|
+
_computedThumbLabel({ thumbLabel, _valueAsText }) {
|
|
239
|
+
return thumbLabel ?? _valueAsText;
|
|
240
|
+
},
|
|
190
241
|
})
|
|
191
242
|
.html`
|
|
192
243
|
<div id=track style={computeTrackStyle} aria-hidden=true disabled={disabledState}>
|
|
@@ -196,18 +247,17 @@ export default CustomElement
|
|
|
196
247
|
<div id=thumb></div>
|
|
197
248
|
<div id=thumb-label
|
|
198
249
|
hidden={_thumbLabelHidden}
|
|
199
|
-
text={
|
|
250
|
+
text={_computedThumbLabel}></div>
|
|
200
251
|
</div>
|
|
201
252
|
</div>
|
|
202
253
|
`
|
|
254
|
+
.recompose(({ refs: { thumb, state, control } }) => {
|
|
255
|
+
thumb.append(state);
|
|
256
|
+
control.removeAttribute('aria-labelledby');
|
|
257
|
+
})
|
|
203
258
|
.on({
|
|
204
|
-
composed() {
|
|
205
|
-
const { thumb, state, control } = this.refs;
|
|
206
|
-
thumb.append(state);
|
|
207
|
-
control.removeAttribute('aria-labelledby');
|
|
208
|
-
},
|
|
209
259
|
valueChanged(oldValue, newValue) {
|
|
210
|
-
this.
|
|
260
|
+
this._valueAsText = newValue;
|
|
211
261
|
},
|
|
212
262
|
})
|
|
213
263
|
.css`
|
|
@@ -307,6 +357,10 @@ export default CustomElement
|
|
|
307
357
|
border-radius: 50%;
|
|
308
358
|
}
|
|
309
359
|
|
|
360
|
+
#control[disabled] {
|
|
361
|
+
cursor: not-allowed;
|
|
362
|
+
}
|
|
363
|
+
|
|
310
364
|
#track {
|
|
311
365
|
--value: 0.5;
|
|
312
366
|
position: absolute;
|
|
@@ -321,6 +375,7 @@ export default CustomElement
|
|
|
321
375
|
|
|
322
376
|
background-color: rgb(var(--mdw-color__surface-container-highest));
|
|
323
377
|
border-radius: inherit;
|
|
378
|
+
color: rgb(var(--mdw-bg));
|
|
324
379
|
}
|
|
325
380
|
|
|
326
381
|
#thumb {
|
|
@@ -340,7 +395,7 @@ export default CustomElement
|
|
|
340
395
|
|
|
341
396
|
border-radius: 50%;
|
|
342
397
|
|
|
343
|
-
color:
|
|
398
|
+
color: currentColor;
|
|
344
399
|
}
|
|
345
400
|
|
|
346
401
|
#thumb::before {
|
|
@@ -354,7 +409,7 @@ export default CustomElement
|
|
|
354
409
|
background-color: currentColor;
|
|
355
410
|
border-radius: 50%;
|
|
356
411
|
|
|
357
|
-
transition: background-color 100ms;
|
|
412
|
+
transition: color 100ms, background-color 100ms;
|
|
358
413
|
}
|
|
359
414
|
|
|
360
415
|
/* Inactive ticks */
|
|
@@ -366,28 +421,27 @@ export default CustomElement
|
|
|
366
421
|
position: absolute;
|
|
367
422
|
inset: 0;
|
|
368
423
|
|
|
369
|
-
padding-inline:
|
|
424
|
+
padding-inline: 2px;
|
|
370
425
|
|
|
371
426
|
background-clip: content-box;
|
|
372
|
-
|
|
373
|
-
background-
|
|
374
|
-
background-position: center center;
|
|
427
|
+
background-image: radial-gradient(circle at 1px, currentColor 0, currentColor 1px, transparent 0);
|
|
428
|
+
background-position: -1px 50%;
|
|
375
429
|
background-repeat: repeat-x;
|
|
376
|
-
background-size: 0
|
|
377
|
-
background-size: calc(100% / var(--ticks, 0)) 2px;
|
|
430
|
+
background-size: calc(100% / (var(--ticks, 0) + 1)) 2px;
|
|
378
431
|
}
|
|
379
432
|
|
|
380
433
|
#ticks::before {
|
|
381
|
-
|
|
434
|
+
color: rgb(var(--mdw-color__on-surface-variant));
|
|
382
435
|
}
|
|
383
436
|
|
|
384
437
|
#ticks::after {
|
|
385
|
-
--tick-color: rgb(var(--mdw-ink));
|
|
386
438
|
/* TODO: Use single-paint implementation */
|
|
387
439
|
padding-inline-end: calc(100% - (100% * var(--value)) + 10px);
|
|
388
440
|
|
|
389
441
|
z-index: 1;
|
|
390
442
|
|
|
443
|
+
color: rgb(var(--mdw-ink));
|
|
444
|
+
|
|
391
445
|
will-change: padding-inline-end;
|
|
392
446
|
}
|
|
393
447
|
/* Active Indicator */
|
|
@@ -409,7 +463,7 @@ export default CustomElement
|
|
|
409
463
|
transform: scaleX(var(--value));
|
|
410
464
|
transform-origin: calc(100% * calc(-0.5 * var(--mdw-dir, 1) + 0.5)) 0;
|
|
411
465
|
|
|
412
|
-
background-color:
|
|
466
|
+
background-color: currentColor;
|
|
413
467
|
|
|
414
468
|
will-change: transform;
|
|
415
469
|
}
|
|
@@ -465,21 +519,24 @@ export default CustomElement
|
|
|
465
519
|
align-items: center;
|
|
466
520
|
justify-content: center;
|
|
467
521
|
|
|
522
|
+
box-sizing: border-box;
|
|
523
|
+
|
|
468
524
|
min-block-size: 28px;
|
|
469
525
|
min-inline-size: 28px;
|
|
526
|
+
padding: 4px;
|
|
470
527
|
|
|
471
528
|
z-index: 1;
|
|
472
529
|
|
|
473
530
|
background-color: rgb(var(--mdw-bg));
|
|
474
|
-
border-radius:
|
|
531
|
+
border-radius: 14px;
|
|
475
532
|
color: rgb(var(--mdw-ink));
|
|
476
533
|
}
|
|
477
534
|
|
|
478
535
|
#thumb-label::after {
|
|
479
536
|
/* Values from Figma SVG */
|
|
480
|
-
--x-start:
|
|
481
|
-
--x-end:
|
|
482
|
-
--y:
|
|
537
|
+
--x-start: 4.1005px; /*4.1005px*/
|
|
538
|
+
--x-end: calc(100% - 4.1005px);
|
|
539
|
+
--y: calc(100% - 9.9584px); /*24.0416px*/
|
|
483
540
|
|
|
484
541
|
content: "";
|
|
485
542
|
|
|
@@ -489,7 +546,7 @@ export default CustomElement
|
|
|
489
546
|
|
|
490
547
|
clip-path: polygon(var(--x-start) var(--y), var(--x-end) var(--y), 50% 100%, var(--x-start) var(--y));
|
|
491
548
|
|
|
492
|
-
background-color:
|
|
549
|
+
background-color: currentColor;
|
|
493
550
|
}
|
|
494
551
|
|
|
495
552
|
#track[disabled] {
|