@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/Dialog.js
CHANGED
|
@@ -1,41 +1,97 @@
|
|
|
1
1
|
import './Button.js';
|
|
2
|
-
import './Surface.js';
|
|
3
2
|
import './Divider.js';
|
|
4
3
|
import './Icon.js';
|
|
5
4
|
import './DialogActions.js';
|
|
6
5
|
|
|
7
|
-
import { handleTabKeyPress } from '../aria/modal.js';
|
|
8
6
|
import CustomElement from '../core/CustomElement.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import { attemptFocus } from '../core/dom.js';
|
|
8
|
+
import PopupMixin from '../mixins/PopupMixin.js';
|
|
9
|
+
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
10
|
+
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @prop {DialogStackState} [state]
|
|
19
|
-
* @prop {DialogStackState} [previousState]
|
|
13
|
+
* Returns array of elements that *may* be focusable over tab
|
|
14
|
+
* @param {Node} root
|
|
15
|
+
* @return {Element[]}
|
|
20
16
|
*/
|
|
17
|
+
function listTabbables(root) {
|
|
18
|
+
const treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
19
|
+
const focusables = [];
|
|
20
|
+
/** @type {HTMLElement} */
|
|
21
|
+
let node;
|
|
22
|
+
while ((node = /** @type {HTMLElement} */ (treeWalker.nextNode()))) {
|
|
23
|
+
if (node.tagName === 'SLOT') {
|
|
24
|
+
for (const el of (/** @type {HTMLSlotElement} */ (node)).assignedElements()) {
|
|
25
|
+
if ((/** @type {HTMLElement} */ (el)).tabIndex >= 0 && !el.matches(':disabled')) {
|
|
26
|
+
focusables.push(el);
|
|
27
|
+
}
|
|
28
|
+
focusables.push(...listTabbables(el));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (node.tabIndex >= 0 && !node.matches(':disabled')) {
|
|
32
|
+
focusables.push(node);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return focusables;
|
|
36
|
+
}
|
|
21
37
|
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Iterate through root looking for autofocusable, or first focusable element
|
|
40
|
+
* Attempt focus on each and return true if successful
|
|
41
|
+
* @param {Node} root
|
|
42
|
+
* @param {boolean} [autofocus=true]
|
|
43
|
+
* @param {boolean} [forward=true]
|
|
44
|
+
* @return {boolean} focused
|
|
45
|
+
*/
|
|
46
|
+
function focusOnTree(root, autofocus, forward = true) {
|
|
47
|
+
const treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
48
|
+
const focusables = [];
|
|
49
|
+
/** @type {Element} */
|
|
50
|
+
let node;
|
|
51
|
+
while ((node = /** @type {Element} */ (treeWalker.nextNode()))) {
|
|
52
|
+
if (autofocus && node.hasAttribute('autofocus')) {
|
|
53
|
+
if (attemptFocus(node)) return true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (node.tagName === 'SLOT') {
|
|
57
|
+
for (const el of (/** @type {HTMLSlotElement} */ (node)).assignedElements({ flatten: true })) {
|
|
58
|
+
if (autofocus && el.hasAttribute('autofocus')) {
|
|
59
|
+
if (attemptFocus(el)) return true;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (el.tabIndex >= 0) {
|
|
63
|
+
// Can focus, add to later in case we find an autofocusable
|
|
64
|
+
if (autofocus || !forward) {
|
|
65
|
+
focusables.push(node);
|
|
66
|
+
} else if (attemptFocus(node)) return true;
|
|
67
|
+
}
|
|
68
|
+
if (focusOnTree(el, autofocus, forward)) return true;
|
|
69
|
+
}
|
|
70
|
+
// Step through
|
|
71
|
+
}
|
|
72
|
+
if (node.tabIndex >= 0) {
|
|
73
|
+
if (autofocus || !forward) {
|
|
74
|
+
focusables.push(node);
|
|
75
|
+
} else if (attemptFocus(node)) return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const el of forward ? focusables : focusables.reverse()) {
|
|
79
|
+
if (attemptFocus(el)) return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
26
83
|
|
|
27
84
|
export default CustomElement
|
|
28
85
|
.extend()
|
|
86
|
+
.mixin(ThemableMixin)
|
|
87
|
+
.mixin(ShapeMixin)
|
|
88
|
+
.mixin(PopupMixin)
|
|
29
89
|
.define({
|
|
30
|
-
_dialog() {
|
|
31
|
-
return /** @type {HTMLDialogElement} */ (this.refs.dialog);
|
|
32
|
-
},
|
|
33
90
|
returnValue() {
|
|
34
91
|
return /** @type {HTMLDialogElement} */ (this.refs.dialog).returnValue;
|
|
35
92
|
},
|
|
36
93
|
})
|
|
37
94
|
.observe({
|
|
38
|
-
open: 'boolean',
|
|
39
95
|
dividers: {
|
|
40
96
|
/** @type {'full'|''|'inset'} */
|
|
41
97
|
value: null,
|
|
@@ -45,23 +101,19 @@ export default CustomElement
|
|
|
45
101
|
default: { value: 'confirm' },
|
|
46
102
|
cancel: { value: 'Cancel' },
|
|
47
103
|
confirm: { value: 'Confirm' },
|
|
48
|
-
_isNativeModal: 'boolean',
|
|
49
|
-
color: { empty: 'surface' },
|
|
50
|
-
ink: 'string',
|
|
51
|
-
outlined: 'boolean',
|
|
52
|
-
elevation: { empty: 3 },
|
|
53
104
|
})
|
|
54
|
-
.
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
onTransitionEnd(event) {
|
|
60
|
-
if (event.propertyName !== 'opacity') return;
|
|
61
|
-
if (this.getAttribute('aria-hidden') !== 'true') return;
|
|
62
|
-
this.setAttribute('mdw-ready', '');
|
|
105
|
+
.define({
|
|
106
|
+
/** Dialogs are not anchored to source */
|
|
107
|
+
_anchor: {
|
|
108
|
+
get() { return null; },
|
|
109
|
+
set() { /* noop */ },
|
|
63
110
|
},
|
|
64
|
-
|
|
111
|
+
})
|
|
112
|
+
.set({
|
|
113
|
+
flow: 'center',
|
|
114
|
+
_useScrim: true,
|
|
115
|
+
})
|
|
116
|
+
.methods({
|
|
65
117
|
/**
|
|
66
118
|
* @param {Event & {currentTarget: HTMLSlotElement}} event
|
|
67
119
|
* @return {void}
|
|
@@ -72,368 +124,79 @@ export default CustomElement
|
|
|
72
124
|
|| (node.nodeType === node.TEXT_NODE && node.nodeValue.trim().length));
|
|
73
125
|
currentTarget.toggleAttribute('slotted', hasContent);
|
|
74
126
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* @param {SubmitEvent & {currentTarget: HTMLFormElement}} event
|
|
78
|
-
* @return {void}
|
|
79
|
-
*/
|
|
80
|
-
onFormSubmit(event) {
|
|
81
|
-
if (event.currentTarget.assignedSlot) {
|
|
82
|
-
// Custom form.
|
|
83
|
-
// @ts-ignore Skip cast
|
|
84
|
-
const returnValue = event.submitter?.value;
|
|
85
|
-
this.close(returnValue);
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @param {Event & {currentTarget: HTMLFormElement}} event
|
|
92
|
-
* @return {void}
|
|
93
|
-
*/
|
|
94
|
-
onFormSlotChange({ currentTarget }) {
|
|
95
|
-
/** @type {HTMLFormElement} */
|
|
96
|
-
const [form] = currentTarget.assignedNodes();
|
|
97
|
-
form?.addEventListener('submit', (e) => this.onFormSubmit(e));
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @param {PopStateEvent} event
|
|
102
|
-
* @return {void}
|
|
103
|
-
*/
|
|
104
|
-
onPopState(event) {
|
|
105
|
-
if (!event.state) return;
|
|
106
|
-
|
|
107
|
-
const lastOpenDialog = OPEN_DIALOGS.at(-1);
|
|
108
|
-
if (!lastOpenDialog || !lastOpenDialog.previousState) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if ((lastOpenDialog.previousState === event.state) || Object.entries(event.state)
|
|
112
|
-
.every(([key, value]) => value === lastOpenDialog.previousState[key])) {
|
|
113
|
-
const cancelEvent = new Event('cancel', { cancelable: true });
|
|
114
|
-
if (lastOpenDialog.element.dispatchEvent(cancelEvent)) {
|
|
115
|
-
lastOpenDialog.element.close();
|
|
116
|
-
} else {
|
|
117
|
-
// Revert pop state by pushing state again
|
|
118
|
-
window.history.pushState(lastOpenDialog.state, lastOpenDialog.state.title);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @param {any} returnValue
|
|
125
|
-
* @return {boolean} handled
|
|
126
|
-
*/
|
|
127
|
-
close(returnValue) {
|
|
128
|
-
if (!this.open) return false;
|
|
129
|
-
if (this._isNativeModal) {
|
|
130
|
-
this._isNativeModal = false;
|
|
131
|
-
} else {
|
|
132
|
-
const main = document.querySelector('main');
|
|
133
|
-
if (main) {
|
|
134
|
-
main.removeAttribute('aria-hidden');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// if (this.dialogElement.getAttribute('aria-hidden') === 'true') return false;
|
|
138
|
-
if (supportsHTMLDialogElement && this._dialog.open) {
|
|
139
|
-
// Force close native dialog
|
|
140
|
-
this._dialog.close(returnValue);
|
|
141
|
-
} else {
|
|
142
|
-
this._dialog.returnValue = returnValue;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Will invoke observed attribute change: ('aria-hidden', 'true');
|
|
146
|
-
this.open = false;
|
|
147
|
-
this.dispatchEvent(new Event('close'));
|
|
148
|
-
// .mdw-dialog__popup hidden by transitionEnd event
|
|
149
|
-
let stackIndex = -1;
|
|
150
|
-
OPEN_DIALOGS.some((stack, index) => {
|
|
151
|
-
// @ts-ignore Skip unknown
|
|
152
|
-
if (stack.element === this) {
|
|
153
|
-
stackIndex = index;
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
return false;
|
|
157
|
-
});
|
|
158
|
-
if (stackIndex !== -1) {
|
|
159
|
-
const stack = OPEN_DIALOGS[stackIndex];
|
|
160
|
-
if (stack.previousFocus
|
|
161
|
-
&& stack.previousFocus instanceof HTMLElement
|
|
162
|
-
&& document.activeElement?.closest(this.constructor.elementName) === this) {
|
|
163
|
-
// Only pop focus back when hiding a dialog with focus within itself.
|
|
164
|
-
try {
|
|
165
|
-
stack.previousFocus.focus();
|
|
166
|
-
} catch {
|
|
167
|
-
// Failed to focus
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
OPEN_DIALOGS.splice(stackIndex, 1);
|
|
171
|
-
if (stack.state && window.history && window.history.state // IE11 returns a cloned state object, not the original
|
|
172
|
-
&& stack.state.hash === window.history.state.hash) {
|
|
173
|
-
window.history.back();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (!OPEN_DIALOGS.length) {
|
|
177
|
-
window.removeEventListener('popstate', this.onPopState);
|
|
178
|
-
}
|
|
179
|
-
return true;
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @param {Event} [event]
|
|
184
|
-
* @return {boolean} handled
|
|
185
|
-
*/
|
|
186
|
-
showModal(event) {
|
|
187
|
-
if (this.open) return false;
|
|
188
|
-
if (supportsHTMLDialogElement) {
|
|
189
|
-
this._dialog.showModal();
|
|
190
|
-
this._isNativeModal = true;
|
|
191
|
-
}
|
|
192
|
-
return this.show(event);
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @param {MouseEvent|PointerEvent|HTMLElement|Event} [source]
|
|
197
|
-
* @return {boolean} handled
|
|
198
|
-
*/
|
|
199
|
-
show(source) {
|
|
200
|
-
if (this.open) return false;
|
|
201
|
-
this.open = true;
|
|
202
|
-
|
|
203
|
-
if (supportsHTMLDialogElement) {
|
|
204
|
-
this._dialog.show();
|
|
205
|
-
const main = document.querySelector('main');
|
|
206
|
-
if (main) {
|
|
207
|
-
main.setAttribute('aria-hidden', 'true');
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const previousFocus = document.activeElement;
|
|
212
|
-
const title = this.headline || this.textContent;
|
|
213
|
-
const newState = { time: Date.now(), random: Math.random(), title };
|
|
214
|
-
let previousState = null;
|
|
215
|
-
|
|
216
|
-
if (!window.history.state) {
|
|
217
|
-
window.history.replaceState({
|
|
218
|
-
hash: Math.random().toString(36).slice(2, 18),
|
|
219
|
-
}, document.title);
|
|
220
|
-
}
|
|
221
|
-
previousState = window.history.state;
|
|
222
|
-
window.history.pushState(newState, title);
|
|
223
|
-
window.addEventListener('popstate', this.onPopState);
|
|
224
|
-
|
|
225
|
-
/** @type {DialogStack} */
|
|
226
|
-
const dialogStack = {
|
|
227
|
-
// @ts-ignore Recursive cast
|
|
228
|
-
element: this,
|
|
229
|
-
previousFocus,
|
|
230
|
-
state: newState,
|
|
231
|
-
previousState,
|
|
232
|
-
};
|
|
233
|
-
OPEN_DIALOGS.push(dialogStack);
|
|
234
|
-
const focusElement = this.querySelector('[autofocus]')
|
|
235
|
-
?? this.shadowRoot.querySelector('[autofocus]');
|
|
236
|
-
try {
|
|
237
|
-
if (focusElement && focusElement instanceof HTMLElement) {
|
|
238
|
-
if (focusElement.scrollIntoView) {
|
|
239
|
-
focusElement.scrollIntoView();
|
|
240
|
-
}
|
|
241
|
-
focusElement.focus();
|
|
242
|
-
} else {
|
|
243
|
-
this.refs.surface.focus();
|
|
244
|
-
}
|
|
245
|
-
} catch {
|
|
246
|
-
// Failed to focus
|
|
247
|
-
}
|
|
248
|
-
return true;
|
|
127
|
+
focus() {
|
|
128
|
+
focusOnTree(this.shadowRoot, true, true);
|
|
249
129
|
},
|
|
250
130
|
})
|
|
251
131
|
.expressions({
|
|
252
132
|
cancelAutoFocus({ default: d }) { return d === 'cancel'; },
|
|
253
133
|
confirmAutoFocus({ default: d }) { return d === 'confirm'; },
|
|
254
|
-
_ariaHidden({ open }) { return (open ? 'false' : 'true'); },
|
|
255
134
|
})
|
|
256
|
-
.html
|
|
257
|
-
<
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
<
|
|
261
|
-
<mdw-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
<
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
<mdw-button id=cancel type=submit value=cancel
|
|
272
|
-
autofocus={cancelAutoFocus}>{cancel}</mdw-button>
|
|
273
|
-
<mdw-button id=confirm type=submit value=confirm
|
|
274
|
-
autofocus={confirmAutoFocus}>{confirm}</mdw-button>
|
|
275
|
-
</mdw-dialog-actions>
|
|
276
|
-
</form>
|
|
277
|
-
</slot>
|
|
278
|
-
</mdw-surface>
|
|
279
|
-
</dialog>
|
|
135
|
+
.html`
|
|
136
|
+
<div id=dialog-inner>
|
|
137
|
+
<mdw-icon mdw-if={icon} id=icon class=content ink=secondary aria-hidden=true icon={icon}></mdw-icon>
|
|
138
|
+
<slot id=headline name=headline on-slotchange={onSlotChange} role=header>{headline}</slot>
|
|
139
|
+
<slot id=fixed name=fixed class=content on-slotchange={onSlotChange}></slot>
|
|
140
|
+
<mdw-divider id=divider-top size={dividers}></mdw-divider>
|
|
141
|
+
<slot id=content name=content></slot>
|
|
142
|
+
<mdw-divider id=divider-bottom size={dividers}></mdw-divider>
|
|
143
|
+
<slot id=actions name=actions>
|
|
144
|
+
<form method=dialog role=none>
|
|
145
|
+
<mdw-button id=cancel type=submit value=cancel autofocus={cancelAutoFocus} formnovalidate>{cancel}</mdw-button>
|
|
146
|
+
<mdw-button id=confirm type=submit value=confirm autofocus={confirmAutoFocus}>{confirm}</mdw-button>
|
|
147
|
+
</form>
|
|
148
|
+
</slot>
|
|
149
|
+
</div>
|
|
280
150
|
`
|
|
151
|
+
.recompose(({ refs: { dialog, dialogInner, content, slot } }) => {
|
|
152
|
+
dialog.setAttribute('aria-labelledby', 'headline');
|
|
153
|
+
dialog.setAttribute('aria-describedby', 'slot');
|
|
154
|
+
|
|
155
|
+
// Use content slot as content
|
|
156
|
+
// Use default slot as padded content
|
|
157
|
+
slot.classList.add('content');
|
|
158
|
+
content.append(slot);
|
|
159
|
+
|
|
160
|
+
dialog.prepend(...dialogInner.childNodes);
|
|
161
|
+
dialogInner.remove();
|
|
162
|
+
})
|
|
281
163
|
.css`
|
|
282
164
|
/* https://m3.material.io/components/dialogs/specs */
|
|
283
165
|
|
|
284
166
|
:host {
|
|
285
|
-
--mdw-
|
|
286
|
-
--mdw-
|
|
287
|
-
--mdw-dialog__standard-easing: var(--mdw-motion-standard-easing, cubic-bezier(0.4, 0.0, 0.2, 1));
|
|
288
|
-
--mdw-dialog__deceleration-easing: var(--mdw-motion-deceleration-easing, cubic-bezier(0.0, 0.0, 0.2, 1));
|
|
289
|
-
--mdw-dialog__fade-in-duration: var(--mdw-motion-fade-in-duration, 150ms);
|
|
290
|
-
|
|
167
|
+
--mdw-bg: var(--mdw-color__surface-container-high);
|
|
168
|
+
--mdw-ink: var(--mdw-color__on-surface);
|
|
291
169
|
position: fixed;
|
|
292
|
-
inset: 0;
|
|
293
|
-
|
|
294
|
-
pointer-events: none;
|
|
295
|
-
|
|
296
|
-
z-index: 24;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
#dialog {
|
|
300
|
-
position: fixed;
|
|
301
|
-
inset-block-start: 0;
|
|
302
|
-
inset-inline-start: 0;
|
|
303
|
-
|
|
304
|
-
display: flex;
|
|
305
|
-
align-items: center;
|
|
306
|
-
flex-direction: row;
|
|
307
|
-
justify-content: center;
|
|
308
|
-
|
|
309
|
-
box-sizing: border-box;
|
|
310
|
-
block-size:100%;
|
|
311
|
-
max-block-size: none;
|
|
312
|
-
inline-size:100%;
|
|
313
|
-
max-inline-size: none;
|
|
314
|
-
margin:0;
|
|
315
|
-
border: none;
|
|
316
|
-
padding: 48px;
|
|
317
|
-
|
|
318
|
-
opacity: 0;
|
|
319
|
-
/* visiblity:hidden still registers events, hide from pointer with scale(0) */
|
|
320
|
-
transform: scale(0);
|
|
321
|
-
visibility: hidden;
|
|
322
|
-
z-index: 24;
|
|
323
|
-
|
|
324
|
-
background-color: transparent;
|
|
325
|
-
|
|
326
|
-
transition-delay: 0s, 200ms, 200ms;
|
|
327
|
-
transition-duration: 200ms, 0s, 0s;
|
|
328
|
-
transition-property: opacity, transform, visibility;
|
|
329
|
-
transition-timing-function: ease-out;
|
|
330
|
-
will-change: opacity;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
@media (min-width: 1440px) {
|
|
334
|
-
#dialog {
|
|
335
|
-
padding: 56px;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
#dialog::backdrop {
|
|
340
|
-
/** Use scrim instead */
|
|
341
|
-
display: none;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
#dialog[aria-hidden="false"],
|
|
345
|
-
#dialog:modal {
|
|
346
|
-
pointer-events: auto;
|
|
347
|
-
|
|
348
|
-
opacity: 1;
|
|
349
|
-
|
|
350
|
-
transform: none;
|
|
351
|
-
visibility: visible;
|
|
352
|
-
|
|
353
|
-
transition-delay: 0s;
|
|
354
|
-
transition-duration: 0s;
|
|
355
|
-
transition-timing-function: ease-in;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
#scrim {
|
|
359
|
-
position: fixed;
|
|
360
|
-
inset: 0;
|
|
361
|
-
|
|
362
|
-
overflow-y: scroll;
|
|
363
|
-
overscroll-behavior: none;
|
|
364
|
-
overscroll-behavior: contain;
|
|
365
|
-
scrollbar-width: none;
|
|
366
|
-
|
|
367
|
-
block-size: 100%;
|
|
368
|
-
inline-size: 100%;
|
|
369
|
-
|
|
370
|
-
cursor: default;
|
|
371
|
-
pointer-events: inherit;
|
|
372
|
-
-webkit-tap-highlight-color: transparent;
|
|
373
|
-
|
|
374
|
-
opacity: 0.38;
|
|
375
|
-
z-index: 0;
|
|
376
|
-
|
|
377
|
-
background-color: rgb(var(--mdw-color__scrim));
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
#scrim::-webkit-scrollbar {
|
|
381
|
-
display: none;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
#scrim::after {
|
|
385
|
-
content: '';
|
|
386
|
-
|
|
387
|
-
display: block;
|
|
388
|
-
|
|
389
|
-
block-size: 200%;
|
|
390
|
-
inline-size: 200%;
|
|
391
|
-
}
|
|
392
|
-
@keyframes scaleUpAnimation {
|
|
393
|
-
from {
|
|
394
|
-
transform: scaleY(0);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
to {
|
|
398
|
-
transform: scaleY(1);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
#surface {
|
|
403
|
-
--mdw-shape__size: 28px;
|
|
404
|
-
|
|
405
|
-
position: relative;
|
|
406
170
|
|
|
407
171
|
display: flex;
|
|
408
172
|
align-items: flex-start;
|
|
409
173
|
flex-direction: column;
|
|
174
|
+
justify-content: center;
|
|
175
|
+
overflow: visible;
|
|
410
176
|
-webkit-overflow-scrolling: touch;
|
|
411
177
|
overscroll-behavior: none;
|
|
412
178
|
overscroll-behavior: contain;
|
|
413
179
|
|
|
414
|
-
|
|
415
|
-
|
|
180
|
+
max-block-size: calc(100% - 40px);
|
|
181
|
+
inline-size: max-content;
|
|
416
182
|
min-inline-size: 280px;
|
|
417
|
-
max-inline-size: 560px;
|
|
418
|
-
flex-shrink: 1;
|
|
419
|
-
|
|
183
|
+
max-inline-size: min(560px, calc(100% - 40px));
|
|
420
184
|
padding-block-start: 8px;
|
|
421
185
|
|
|
422
|
-
transform:
|
|
423
|
-
transform-origin: top center;
|
|
424
|
-
|
|
186
|
+
transform: translateY(-40px) scaleY(0);
|
|
187
|
+
transform-origin: top center !important;
|
|
188
|
+
|
|
189
|
+
background-color: rgb(var(--mdw-bg));
|
|
190
|
+
color: rgb(var(--mdw-ink));
|
|
425
191
|
|
|
426
|
-
will-change: display, transform;
|
|
427
192
|
}
|
|
428
193
|
|
|
429
|
-
#
|
|
430
|
-
|
|
194
|
+
#dialog:modal {
|
|
195
|
+
overflow: visible;
|
|
431
196
|
}
|
|
432
197
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
animation-duration: 200ms;
|
|
436
|
-
animation-direction: forwards;
|
|
198
|
+
:host([icon]) {
|
|
199
|
+
align-items: center;
|
|
437
200
|
}
|
|
438
201
|
|
|
439
202
|
#icon {
|
|
@@ -511,10 +274,85 @@ export default CustomElement
|
|
|
511
274
|
display: contents;
|
|
512
275
|
}
|
|
513
276
|
|
|
514
|
-
#
|
|
515
|
-
display:
|
|
277
|
+
#actions {
|
|
278
|
+
display: flex;
|
|
279
|
+
align-self: flex-end;
|
|
280
|
+
|
|
281
|
+
margin-block: 24px;
|
|
282
|
+
padding-inline: 24px;
|
|
516
283
|
}
|
|
517
284
|
`
|
|
285
|
+
.events({
|
|
286
|
+
keydown(event) {
|
|
287
|
+
if (event.key === 'Tab') {
|
|
288
|
+
if (!this.native) {
|
|
289
|
+
// Tab trap
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
const tabbables = listTabbables(this.shadowRoot);
|
|
292
|
+
if (event.shiftKey) {
|
|
293
|
+
tabbables.reverse();
|
|
294
|
+
}
|
|
295
|
+
let focusNext = false;
|
|
296
|
+
let focused = false;
|
|
297
|
+
// Find and mark next
|
|
298
|
+
for (const el of tabbables) {
|
|
299
|
+
if (focusNext) {
|
|
300
|
+
if (attemptFocus(el)) {
|
|
301
|
+
focused = true;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
focusNext = el.matches(':focus');
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// Loop
|
|
309
|
+
if (!focused) {
|
|
310
|
+
for (const el of tabbables) {
|
|
311
|
+
if (attemptFocus(el)) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (event.key === 'Escape' || event.key === 'Esc') {
|
|
321
|
+
event.preventDefault();
|
|
322
|
+
event.stopPropagation();
|
|
323
|
+
const cancelEvent = new Event('cancel', { cancelable: true });
|
|
324
|
+
if (this.dispatchEvent(cancelEvent)) {
|
|
325
|
+
this.close();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
focusout(event) {
|
|
330
|
+
if (!this.open) return;
|
|
331
|
+
if (this._closing) return;
|
|
332
|
+
if (this.modal) return;
|
|
333
|
+
if (event.relatedTarget === this.refs.scrim) return;
|
|
334
|
+
|
|
335
|
+
// Wait until end of event loop cycle to see if focus really is lost
|
|
336
|
+
queueMicrotask(() => {
|
|
337
|
+
if (this.matches(':focus-within')) return;
|
|
338
|
+
const activeElement = document.activeElement;
|
|
339
|
+
if (activeElement && this.contains(activeElement)) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
// Focus has left dialog (programmatic?)
|
|
343
|
+
// Invoke cancel without returning focus
|
|
344
|
+
this.close(undefined, false);
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
submit(event) {
|
|
348
|
+
if (event.defaultPrevented) return;
|
|
349
|
+
const form = event.target;
|
|
350
|
+
if (form instanceof HTMLFormElement === false) return;
|
|
351
|
+
if (form.method !== 'dialog') return;
|
|
352
|
+
const returnValue = event.submitter?.value;
|
|
353
|
+
this.close(returnValue);
|
|
354
|
+
},
|
|
355
|
+
})
|
|
518
356
|
.childEvents({
|
|
519
357
|
dialog: {
|
|
520
358
|
cancel(event) {
|
|
@@ -528,34 +366,16 @@ export default CustomElement
|
|
|
528
366
|
event.stopPropagation();
|
|
529
367
|
this.close(this.returnValue);
|
|
530
368
|
},
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
369
|
+
'~click'(event) {
|
|
370
|
+
// Track if click on backdrop
|
|
371
|
+
if (event.target !== event.currentTarget) return;
|
|
372
|
+
if (!this.native) return;
|
|
373
|
+
if (event.offsetX >= 0 && event.offsetX < event.currentTarget.offsetWidth
|
|
374
|
+
&& event.offsetY >= 0 && event.offsetY < event.currentTarget.offsetHeight) return;
|
|
534
375
|
const cancelEvent = new Event('cancel', { cancelable: true });
|
|
535
376
|
if (!this.dispatchEvent(cancelEvent)) return;
|
|
536
377
|
this.close();
|
|
537
378
|
},
|
|
538
379
|
},
|
|
539
|
-
surface: {
|
|
540
|
-
keydown(event) {
|
|
541
|
-
if (event.key === 'Tab') {
|
|
542
|
-
const surface = /** @type {HTMLElement} */ (event.currentTarget);
|
|
543
|
-
if (!this._isNativeModal) {
|
|
544
|
-
// Move via Light or Shadow DOM, depending on target
|
|
545
|
-
const context = surface.contains(event.target) ? surface : this;
|
|
546
|
-
handleTabKeyPress.call(context, event);
|
|
547
|
-
}
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
if (event.key === 'Escape' || event.key === 'Esc') {
|
|
551
|
-
event.preventDefault();
|
|
552
|
-
event.stopPropagation();
|
|
553
|
-
const cancelEvent = new Event('cancel', { cancelable: true });
|
|
554
|
-
if (this.dispatchEvent(cancelEvent)) {
|
|
555
|
-
this.close();
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
},
|
|
560
380
|
})
|
|
561
381
|
.autoRegister('mdw-dialog');
|