@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
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import CustomElement from '../core/CustomElement.js';
|
|
2
|
+
import { ELEMENT_ANIMATION_TYPE, EVENT_HANDLER_TYPE } from '../core/customTypes.js';
|
|
3
|
+
import AriaReflectorMixin from '../mixins/AriaReflectorMixin.js';
|
|
4
|
+
import DelegatesFocusMixin from '../mixins/DelegatesFocusMixin.js';
|
|
5
|
+
import FlexableMixin from '../mixins/FlexableMixin.js';
|
|
6
|
+
import ResizeObserverMixin from '../mixins/ResizeObserverMixin.js';
|
|
7
|
+
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
8
|
+
import StateMixin from '../mixins/StateMixin.js';
|
|
9
|
+
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
10
|
+
|
|
11
|
+
import Scrim from './Scrim.js';
|
|
12
|
+
|
|
13
|
+
const SUPPORTS_SCROLLEND = 'onscrollend' in window;
|
|
14
|
+
|
|
15
|
+
/* Weak Collection of Events that cane from drag handle */
|
|
16
|
+
const dragHandleEvent = new WeakSet();
|
|
17
|
+
|
|
18
|
+
CustomElement
|
|
19
|
+
.extend()
|
|
20
|
+
.mixin(StateMixin)
|
|
21
|
+
.set({
|
|
22
|
+
stateLayer: true,
|
|
23
|
+
})
|
|
24
|
+
.html`
|
|
25
|
+
<div id=container>
|
|
26
|
+
<div id=icon aria-hidden=true></div>
|
|
27
|
+
</div>
|
|
28
|
+
`
|
|
29
|
+
.recompose(({ refs: { container, state } }) => {
|
|
30
|
+
container.prepend(state);
|
|
31
|
+
})
|
|
32
|
+
.css`
|
|
33
|
+
:host {
|
|
34
|
+
--mdw-state__hovered-opacity: 0;
|
|
35
|
+
--mdw-state__pressed-opacity: 0;
|
|
36
|
+
position: absolute;
|
|
37
|
+
inset-block-start: 0;
|
|
38
|
+
inset-inline: 0;
|
|
39
|
+
align-self: stretch;
|
|
40
|
+
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
|
|
45
|
+
cursor: grab;
|
|
46
|
+
|
|
47
|
+
outline:none;
|
|
48
|
+
pointer-events: auto;
|
|
49
|
+
user-select: none;
|
|
50
|
+
touch-action: none;
|
|
51
|
+
|
|
52
|
+
color: rgb(var(--mdw-color__on-surface-variant));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:host(:active) {
|
|
56
|
+
cursor: grabbing !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#container {
|
|
60
|
+
position: relative;
|
|
61
|
+
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
|
|
66
|
+
min-block-size: 48px;
|
|
67
|
+
min-inline-size: 48px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#state {
|
|
71
|
+
border-radius: 50%;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#state[pointed] {
|
|
75
|
+
--mdw-state__focused-opacity: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
#icon {
|
|
80
|
+
block-size: 4px;
|
|
81
|
+
inline-size: 32px;
|
|
82
|
+
|
|
83
|
+
background-color: currentColor;
|
|
84
|
+
border-radius: 8px;
|
|
85
|
+
}
|
|
86
|
+
`
|
|
87
|
+
.events({
|
|
88
|
+
touchmove(event) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
.autoRegister('mdw-bottom-sheet-handle');
|
|
93
|
+
|
|
94
|
+
export default CustomElement
|
|
95
|
+
.extend()
|
|
96
|
+
.mixin(ThemableMixin)
|
|
97
|
+
.mixin(FlexableMixin)
|
|
98
|
+
.mixin(ShapeMixin)
|
|
99
|
+
.mixin(AriaReflectorMixin)
|
|
100
|
+
.mixin(DelegatesFocusMixin)
|
|
101
|
+
.mixin(ResizeObserverMixin)
|
|
102
|
+
.observe({
|
|
103
|
+
shapeTop: {
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
empty: true,
|
|
106
|
+
},
|
|
107
|
+
modal: 'boolean',
|
|
108
|
+
open: 'boolean',
|
|
109
|
+
expanded: 'boolean',
|
|
110
|
+
_lastComputedBlockSize: {
|
|
111
|
+
type: 'float',
|
|
112
|
+
nullable: false,
|
|
113
|
+
},
|
|
114
|
+
_lastOffsetTop: {
|
|
115
|
+
type: 'float',
|
|
116
|
+
nullable: false,
|
|
117
|
+
},
|
|
118
|
+
_animationDuration: {
|
|
119
|
+
type: 'integer',
|
|
120
|
+
value: 0,
|
|
121
|
+
},
|
|
122
|
+
_animationEasing: {
|
|
123
|
+
value: 'ease-out',
|
|
124
|
+
},
|
|
125
|
+
_translateY: { value: '100%' },
|
|
126
|
+
_lastChildScrollTime: 'float',
|
|
127
|
+
_ariaValueNow: {
|
|
128
|
+
type: 'integer',
|
|
129
|
+
},
|
|
130
|
+
dragHandle: 'boolean',
|
|
131
|
+
onopen: EVENT_HANDLER_TYPE,
|
|
132
|
+
onclose: EVENT_HANDLER_TYPE,
|
|
133
|
+
})
|
|
134
|
+
.set({
|
|
135
|
+
_hasCheckedResize: false,
|
|
136
|
+
/** @type {InstanceType<Scrim>} */
|
|
137
|
+
_scrim: null,
|
|
138
|
+
_dragTimestamp: 0,
|
|
139
|
+
/** @type {number} */
|
|
140
|
+
_dragDeltaY: null,
|
|
141
|
+
/** @type {number} */
|
|
142
|
+
_dragStartY: null,
|
|
143
|
+
})
|
|
144
|
+
.observe({
|
|
145
|
+
hostStyles: {
|
|
146
|
+
...ELEMENT_ANIMATION_TYPE,
|
|
147
|
+
get({
|
|
148
|
+
open, modal, _lastComputedBlockSize, _translateY,
|
|
149
|
+
_animationDuration, _animationEasing,
|
|
150
|
+
}) {
|
|
151
|
+
const computedMargin = (open || modal) ? 0 : `${-1 * _lastComputedBlockSize}px`;
|
|
152
|
+
return {
|
|
153
|
+
styles: {
|
|
154
|
+
marginBottom: computedMargin,
|
|
155
|
+
transform: modal ? `translateY(${_translateY})` : 'none',
|
|
156
|
+
},
|
|
157
|
+
timing: {
|
|
158
|
+
duration: _animationDuration,
|
|
159
|
+
easing: _animationEasing,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
.html`
|
|
166
|
+
<mdw-bottom-sheet-handle id=drag-handle mdw-if={dragHandle} tabindex=0
|
|
167
|
+
role=separator aria-valuemin=-100 aria-valuemax=0 aria-valuenow={_ariaValueNow}></mdw-bottom-sheet-handle>
|
|
168
|
+
<slot id=slot></slot>
|
|
169
|
+
`
|
|
170
|
+
.methods({
|
|
171
|
+
checkForScrim(animate = false) {
|
|
172
|
+
let { open, modal, _scrim } = this;
|
|
173
|
+
if (open && modal) {
|
|
174
|
+
if (!_scrim) {
|
|
175
|
+
_scrim = new Scrim();
|
|
176
|
+
_scrim.addEventListener('click', () => {
|
|
177
|
+
this.open = false;
|
|
178
|
+
if (!this.dispatchEvent(new Event('close', { cancelable: true }))) {
|
|
179
|
+
// Revert if cancelled
|
|
180
|
+
this.open = true;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
this._scrim = _scrim;
|
|
184
|
+
}
|
|
185
|
+
this.before(_scrim);
|
|
186
|
+
_scrim.hidden = false;
|
|
187
|
+
} else if (_scrim) {
|
|
188
|
+
if (!animate) {
|
|
189
|
+
_scrim.remove();
|
|
190
|
+
}
|
|
191
|
+
_scrim.hidden = true;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
checkDragFinished() {
|
|
195
|
+
const { open, _dragStartY, _dragDeltaY, _lastComputedBlockSize, modal, _lastOffsetTop } = this;
|
|
196
|
+
if (!open || !modal || _dragStartY == null || _dragDeltaY == null) return;
|
|
197
|
+
const containerHeight = _lastOffsetTop + _lastComputedBlockSize - 72;
|
|
198
|
+
const min = (_lastComputedBlockSize > containerHeight)
|
|
199
|
+
? _lastComputedBlockSize - containerHeight
|
|
200
|
+
: 0;
|
|
201
|
+
// visiblity = (max - position) / range
|
|
202
|
+
const visibility = (_lastComputedBlockSize - _dragDeltaY) / (_lastComputedBlockSize - min);
|
|
203
|
+
this._dragStartY = null;
|
|
204
|
+
if (visibility < 0.5) {
|
|
205
|
+
// Should close
|
|
206
|
+
this._animationDuration = 200 * visibility;
|
|
207
|
+
this._animationEasing = 'ease-out';
|
|
208
|
+
this._translateY = '100%';
|
|
209
|
+
this._dragDeltaY = null;
|
|
210
|
+
this.open = false;
|
|
211
|
+
this.dispatchEvent(new Event('close', { cancelable: false }));
|
|
212
|
+
} else {
|
|
213
|
+
// Should snap back to fully open
|
|
214
|
+
this._animationDuration = 250 * (0.5 * visibility);
|
|
215
|
+
this._dragDeltaY = min;
|
|
216
|
+
this._translateY = `${0}px`;
|
|
217
|
+
this._animationEasing = 'ease-in';
|
|
218
|
+
this.expanded = true;
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
/** @param {PointerEvent} event */
|
|
222
|
+
onDragHandleActive(event) {
|
|
223
|
+
if (!event.isTrusted) return;
|
|
224
|
+
if (!event.isPrimary) return;
|
|
225
|
+
if (event.pointerType === 'touch') return;
|
|
226
|
+
if (event.buttons !== 1) return;
|
|
227
|
+
dragHandleEvent.add(event);
|
|
228
|
+
},
|
|
229
|
+
/** @param {PointerEvent} event */
|
|
230
|
+
onDragHandleInactive(event) {
|
|
231
|
+
if (!event.isTrusted) return;
|
|
232
|
+
if (!event.isPrimary) return;
|
|
233
|
+
if (event.pointerType === 'touch') return;
|
|
234
|
+
if (event.type !== 'pointerup' && event.buttons !== 1) return;
|
|
235
|
+
this.checkDragFinished();
|
|
236
|
+
},
|
|
237
|
+
/** @param {PointerEvent|TouchEvent} event */
|
|
238
|
+
onPointerOrTouchMove(event) {
|
|
239
|
+
/** @type {{clientY:number,pageY:number}} */
|
|
240
|
+
let source;
|
|
241
|
+
const isTouch = (event.type === 'touchmove');
|
|
242
|
+
if (isTouch) {
|
|
243
|
+
const { touches } = /** @type {TouchEvent} */ (event);
|
|
244
|
+
if (!touches.length) return;
|
|
245
|
+
source = touches[0];
|
|
246
|
+
} else {
|
|
247
|
+
source = /** @type {PointerEvent} */ (event);
|
|
248
|
+
// if (!dragHandleEvent.has(event)) return;
|
|
249
|
+
}
|
|
250
|
+
const { open, _lastChildScrollTime, _dragStartY, _dragTimestamp, expanded } = this;
|
|
251
|
+
if (!open || _dragStartY == null) return;
|
|
252
|
+
if (_lastChildScrollTime && performance.now() - _lastChildScrollTime <= (SUPPORTS_SCROLLEND ? 5000 : 500)) {
|
|
253
|
+
// Assume still scrolling
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let { clientY, pageY } = source;
|
|
257
|
+
clientY ??= pageY - window.scrollY; // Safari
|
|
258
|
+
const { _lastOffsetTop, _lastComputedBlockSize } = this;
|
|
259
|
+
const containerHeight = _lastOffsetTop + _lastComputedBlockSize - 72;
|
|
260
|
+
const min = _lastComputedBlockSize > containerHeight
|
|
261
|
+
? _lastComputedBlockSize - containerHeight
|
|
262
|
+
: 0;
|
|
263
|
+
const delta = Math.max((clientY - _dragStartY), min);
|
|
264
|
+
this._dragDeltaY = delta;
|
|
265
|
+
|
|
266
|
+
if (isTouch && expanded && performance.now() - _dragTimestamp < 100) {
|
|
267
|
+
// Store location, but don't animate until sure not scrolling
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (expanded && delta !== min) {
|
|
271
|
+
// Buggy in demos
|
|
272
|
+
// this.expanded = false;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
this._animationDuration = 0;
|
|
276
|
+
this._translateY = `${delta}px`;
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
.overrides({
|
|
280
|
+
onResizeObserved(entry) {
|
|
281
|
+
this._lastComputedBlockSize = entry.borderBoxSize[0]?.blockSize;
|
|
282
|
+
this._lastOffsetTop = this.offsetTop;
|
|
283
|
+
},
|
|
284
|
+
})
|
|
285
|
+
.events({
|
|
286
|
+
'~pointerdown'(event) {
|
|
287
|
+
if (event.pointerType !== 'touch') {
|
|
288
|
+
if (event.buttons !== 1) return;
|
|
289
|
+
// Pointer down isn't from drag-handle. Ignore
|
|
290
|
+
if (!dragHandleEvent.has(event)) return;
|
|
291
|
+
}
|
|
292
|
+
if (!this.open) return;
|
|
293
|
+
let { clientY, pageY } = event;
|
|
294
|
+
clientY ??= pageY - window.scrollY; // Safari
|
|
295
|
+
this._dragStartY = clientY - (this._dragDeltaY ?? 0);
|
|
296
|
+
this._dragDeltaY = 0;
|
|
297
|
+
this._dragTimestamp = performance.now();
|
|
298
|
+
},
|
|
299
|
+
'~pointermove': 'onPointerOrTouchMove',
|
|
300
|
+
'~pointerup'(event) {
|
|
301
|
+
if (event.pointerType === 'touch') return;
|
|
302
|
+
this.checkDragFinished();
|
|
303
|
+
},
|
|
304
|
+
'pointerleave'(event) {
|
|
305
|
+
if (event.pointerType === 'touch') return;
|
|
306
|
+
this.checkDragFinished();
|
|
307
|
+
},
|
|
308
|
+
'~touchmove': 'onPointerOrTouchMove',
|
|
309
|
+
touchcancel: 'checkDragFinished',
|
|
310
|
+
'~touchend': 'checkDragFinished',
|
|
311
|
+
/** Scroll events do no bubble but can be captured, passively */
|
|
312
|
+
'*~scroll'() {
|
|
313
|
+
if (!this.modal) return;
|
|
314
|
+
this.checkDragFinished();
|
|
315
|
+
this._lastChildScrollTime = performance.now();
|
|
316
|
+
// Wiping touch state
|
|
317
|
+
this._dragStartY = null;
|
|
318
|
+
this._dragDeltaY = null;
|
|
319
|
+
},
|
|
320
|
+
'*scrollend'() {
|
|
321
|
+
if (!this.modal) return;
|
|
322
|
+
this._lastChildScrollTime = null;
|
|
323
|
+
},
|
|
324
|
+
})
|
|
325
|
+
.childEvents({
|
|
326
|
+
dragHandle: {
|
|
327
|
+
'~pointerdown': 'onDragHandleActive',
|
|
328
|
+
'~pointermove': 'onDragHandleActive',
|
|
329
|
+
},
|
|
330
|
+
})
|
|
331
|
+
.on({
|
|
332
|
+
openChanged(previous, open) {
|
|
333
|
+
// Refresh metrics
|
|
334
|
+
const _lastOffsetTop = this.offsetTop;
|
|
335
|
+
this._lastOffsetTop = _lastOffsetTop;
|
|
336
|
+
// No longer using initial animation timing of 0
|
|
337
|
+
this._animationDuration = open ? 250 : 200;
|
|
338
|
+
if (open) {
|
|
339
|
+
let y = 0;
|
|
340
|
+
if (this.modal) {
|
|
341
|
+
const { _lastComputedBlockSize } = this;
|
|
342
|
+
const containerHeight = _lastOffsetTop + _lastComputedBlockSize;
|
|
343
|
+
if (_lastComputedBlockSize > containerHeight / 2) {
|
|
344
|
+
// Bottom Sheet is oversized, clamp to 50%
|
|
345
|
+
y = _lastComputedBlockSize - (containerHeight / 2);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
this._translateY = `${y}px`;
|
|
349
|
+
this._dragDeltaY = y;
|
|
350
|
+
} else {
|
|
351
|
+
this._translateY = '100%';
|
|
352
|
+
this.expanded = false;
|
|
353
|
+
}
|
|
354
|
+
this._animationEasing = open ? 'ease-in' : 'ease-out';
|
|
355
|
+
this.checkForScrim(true);
|
|
356
|
+
if (open) this.focus();
|
|
357
|
+
},
|
|
358
|
+
modalChanged() {
|
|
359
|
+
this._animationDuration = 0;
|
|
360
|
+
this.checkForScrim(false);
|
|
361
|
+
},
|
|
362
|
+
})
|
|
363
|
+
.css`
|
|
364
|
+
:host {
|
|
365
|
+
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
366
|
+
--mdw-ink: var(--mdw-color__on-surface);
|
|
367
|
+
--mdw-shape__size: var(--mdw-shape__extra-large);
|
|
368
|
+
--mdw-shape__size__bottom-start-size: 0px;
|
|
369
|
+
--mdw-shape__size__bottom-end-size: 0px;
|
|
370
|
+
position: sticky;
|
|
371
|
+
inset-block-end: 0;
|
|
372
|
+
inset-inline: 0;
|
|
373
|
+
|
|
374
|
+
overflow-y: clip;
|
|
375
|
+
|
|
376
|
+
overscroll-behavior: none;
|
|
377
|
+
overscroll-behavior: contain;
|
|
378
|
+
|
|
379
|
+
box-sizing: border-box;
|
|
380
|
+
max-inline-size: 640px;
|
|
381
|
+
margin-inline: auto;
|
|
382
|
+
padding-block-start: 16px;
|
|
383
|
+
|
|
384
|
+
pointer-events: none;
|
|
385
|
+
|
|
386
|
+
transform: translateY(100%);
|
|
387
|
+
|
|
388
|
+
visibility: hidden;
|
|
389
|
+
|
|
390
|
+
background-color: rgb(var(--mdw-bg));
|
|
391
|
+
color: rgb(var(--mdw-ink));
|
|
392
|
+
|
|
393
|
+
transition: visibility 200ms;
|
|
394
|
+
|
|
395
|
+
will-change: transform, margin-block-end, visibility;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
:host(:where([open])) {
|
|
399
|
+
pointer-events: auto;
|
|
400
|
+
|
|
401
|
+
visibility: inherit;
|
|
402
|
+
|
|
403
|
+
transition: visibility 0s;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
:host(:where([modal])) {
|
|
407
|
+
position: fixed;
|
|
408
|
+
|
|
409
|
+
max-block-size: calc(100% - 72px);
|
|
410
|
+
touch-action: none;
|
|
411
|
+
|
|
412
|
+
z-index: 24;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
:host(:where([expanded])) {
|
|
416
|
+
overflow-y:auto;
|
|
417
|
+
touch-action: auto;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
:host(:where([drag-handle])) {
|
|
421
|
+
padding-block-start: 48px;
|
|
422
|
+
}
|
|
423
|
+
`
|
|
424
|
+
.autoRegister('mdw-bottom-sheet');
|
package/components/Box.js
CHANGED
|
@@ -3,37 +3,24 @@ import FlexableMixin from '../mixins/FlexableMixin.js';
|
|
|
3
3
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Boxes are stateless elements that may have a color and ink.
|
|
7
7
|
* They should have simple geometry for rendering and layout.
|
|
8
8
|
*/
|
|
9
9
|
export default CustomElement
|
|
10
|
+
.extend()
|
|
10
11
|
.mixin(ThemableMixin)
|
|
11
12
|
.mixin(FlexableMixin)
|
|
12
|
-
.
|
|
13
|
-
.observe({
|
|
14
|
-
inline: 'boolean',
|
|
15
|
-
block: {
|
|
16
|
-
type: 'boolean',
|
|
17
|
-
empty: true,
|
|
18
|
-
},
|
|
19
|
-
})
|
|
13
|
+
.html`<slot id=slot></slot>`
|
|
20
14
|
.css`
|
|
21
|
-
:host {
|
|
22
|
-
display: block;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
:host([inline]) {
|
|
26
|
-
display: inline-block;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
:host([flex]:where([inline])) {
|
|
30
|
-
display: inline-flex;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:host([color]) {
|
|
15
|
+
:host(:where([color])) {
|
|
34
16
|
background-color: rgb(var(--mdw-bg));
|
|
35
17
|
color: rgb(var(--mdw-ink));
|
|
36
18
|
}
|
|
19
|
+
|
|
20
|
+
:host(:is([color="none"],[color="transparent"])) {
|
|
21
|
+
background-color: transparent;
|
|
22
|
+
color: inherit;
|
|
23
|
+
}
|
|
37
24
|
|
|
38
25
|
:host([ink]) {
|
|
39
26
|
color: rgb(var(--mdw-ink));
|
|
@@ -43,12 +30,17 @@ export default CustomElement
|
|
|
43
30
|
font: var(--mdw-type__font);
|
|
44
31
|
letter-spacing: var(--mdw-type__letter-spacing);
|
|
45
32
|
}
|
|
46
|
-
|
|
47
|
-
#slot {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
|
|
34
|
+
#slot::slotted([flex-0]) {
|
|
35
|
+
flex: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#slot::slotted([flex-1]) {
|
|
39
|
+
flex: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#slot::slotted([flex-none]) {
|
|
43
|
+
flex: none;
|
|
51
44
|
}
|
|
52
45
|
`
|
|
53
|
-
.html/* html */`<slot id=slot type-style={typeStyle}></slot>`
|
|
54
46
|
.autoRegister('mdw-box');
|