@shortfuse/materialdesignweb 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -198
- package/bin/mdw-css.js +1 -1
- package/components/Badge.js +15 -5
- package/components/Body.js +7 -0
- package/components/BottomAppBar.js +7 -10
- package/components/BottomSheet.js +472 -0
- package/components/Box.js +11 -49
- package/components/Button.js +81 -82
- package/components/Card.js +74 -62
- package/components/Checkbox.js +15 -25
- package/components/CheckboxIcon.js +19 -31
- package/components/Chip.js +18 -13
- package/components/Dialog.js +70 -100
- package/components/DialogActions.js +4 -0
- package/components/Display.js +64 -0
- package/components/Divider.js +5 -0
- package/components/Fab.js +94 -17
- package/components/FabContainer.js +57 -0
- package/components/FilterChip.js +43 -32
- package/components/Grid.js +187 -0
- package/components/Headline.js +9 -28
- package/components/Icon.js +80 -71
- package/components/IconButton.js +77 -120
- package/components/Input.js +745 -86
- package/components/InputChip.js +193 -0
- package/components/Label.js +7 -0
- package/components/List.js +11 -5
- package/components/ListItem.js +92 -23
- package/components/ListOption.js +143 -65
- package/components/Listbox.js +57 -17
- package/components/Menu.js +39 -27
- package/components/MenuItem.js +49 -36
- package/components/NavBar.js +66 -21
- package/components/NavBarItem.js +5 -0
- package/components/NavDrawer.js +33 -16
- package/components/NavDrawerItem.js +7 -4
- package/components/NavItem.js +61 -34
- package/components/NavRail.js +32 -21
- package/components/NavRailItem.js +10 -2
- package/components/Page.js +119 -0
- package/components/Pane.js +24 -0
- package/components/Popup.js +23 -8
- package/components/Progress.js +25 -5
- package/components/Radio.js +8 -7
- package/components/RadioIcon.js +24 -15
- package/components/Ripple.js +25 -7
- package/components/Root.js +225 -0
- package/components/Scrim.js +95 -0
- package/components/Search.js +30 -25
- package/components/SegmentedButton.js +53 -40
- package/components/SegmentedButtonGroup.js +15 -12
- package/components/Select.js +19 -10
- package/components/Shape.js +10 -66
- package/components/SideSheet.js +337 -0
- package/components/Slider.js +93 -36
- package/components/Snackbar.js +52 -20
- package/components/SnackbarContainer.js +51 -0
- package/components/Surface.js +20 -10
- package/components/Switch.js +21 -18
- package/components/SwitchIcon.js +62 -33
- package/components/Tab.js +78 -38
- package/components/TabContent.js +33 -12
- package/components/TabList.js +95 -34
- package/components/TabPanel.js +10 -1
- package/components/Table.js +151 -0
- package/components/TextArea.js +48 -16
- package/components/Title.js +8 -9
- package/components/Tooltip.js +51 -22
- package/components/TopAppBar.js +71 -78
- package/constants/shapes.js +36 -0
- package/constants/typography.js +127 -0
- package/core/Composition.js +391 -201
- package/core/CompositionAdapter.js +35 -18
- package/core/CustomElement.js +634 -254
- package/core/css.js +117 -12
- package/core/customTypes.js +161 -49
- package/core/dom.js +18 -11
- package/core/jsonMergePatch.js +27 -11
- package/core/observe.js +308 -256
- package/core/optimizations.js +9 -9
- package/core/template.js +14 -57
- package/dist/CustomElement.min.js +2 -0
- package/dist/CustomElement.min.js.map +7 -0
- package/dist/core/CustomElement.min.js +2 -0
- package/dist/core/CustomElement.min.js.map +7 -0
- package/dist/index.min.js +85 -115
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +108 -0
- package/{theming/themableMixinLoader.js → loaders/palette.js} +4 -3
- package/loaders/theme.js +12 -0
- package/mixins/AriaReflectorMixin.js +64 -15
- package/mixins/AriaToolbarMixin.js +6 -0
- package/mixins/ControlMixin.js +79 -33
- package/mixins/DelegatesFocusMixin.js +62 -0
- package/mixins/DensityMixin.js +7 -3
- package/mixins/ElevationMixin.js +61 -0
- package/mixins/FlexableMixin.js +87 -39
- package/mixins/FormAssociatedMixin.js +76 -10
- package/mixins/HyperlinkMixin.js +76 -0
- package/mixins/InputMixin.js +227 -32
- package/mixins/KeyboardNavMixin.js +11 -7
- package/mixins/NavigationListenerMixin.js +33 -0
- package/mixins/PopupMixin.js +216 -219
- package/mixins/RTLObserverMixin.js +2 -0
- package/mixins/ResizeObserverMixin.js +18 -4
- package/mixins/RippleMixin.js +11 -7
- package/mixins/ScrollListenerMixin.js +14 -2
- package/mixins/SemiStickyMixin.js +51 -98
- package/mixins/ShapeMaskedMixin.js +125 -0
- package/mixins/ShapeMixin.js +30 -203
- package/mixins/StateMixin.js +74 -34
- package/mixins/TextFieldMixin.js +128 -145
- package/mixins/ThemableMixin.js +57 -56
- package/mixins/TooltipTriggerMixin.js +305 -359
- package/mixins/TouchTargetMixin.js +5 -2
- package/mixins/TypographyMixin.js +128 -0
- package/package.json +125 -81
- package/services/rtl.js +10 -0
- package/services/svgAlias.js +17 -0
- package/{theming/index.js → services/theme.js} +25 -176
- package/types/bin/mdw-css.d.ts +3 -0
- package/types/bin/mdw-css.d.ts.map +1 -0
- package/types/components/Badge.d.ts +39 -0
- package/types/components/Badge.d.ts.map +1 -0
- package/types/components/Body.d.ts +29 -0
- package/types/components/Body.d.ts.map +1 -0
- package/types/components/BottomAppBar.d.ts +72 -0
- package/types/components/BottomAppBar.d.ts.map +1 -0
- package/types/components/BottomSheet.d.ts +135 -0
- package/types/components/BottomSheet.d.ts.map +1 -0
- package/types/components/Box.d.ts +16 -0
- package/types/components/Box.d.ts.map +1 -0
- package/types/components/Button.d.ts +245 -0
- package/types/components/Button.d.ts.map +1 -0
- package/types/components/Card.d.ts +147 -0
- package/types/components/Card.d.ts.map +1 -0
- package/types/components/Checkbox.d.ts +207 -0
- package/types/components/Checkbox.d.ts.map +1 -0
- package/types/components/CheckboxIcon.d.ts +44 -0
- package/types/components/CheckboxIcon.d.ts.map +1 -0
- package/types/components/Chip.d.ts +248 -0
- package/types/components/Chip.d.ts.map +1 -0
- package/types/components/Dialog.d.ts +103 -0
- package/types/components/Dialog.d.ts.map +1 -0
- package/types/components/DialogActions.d.ts +4 -0
- package/types/components/DialogActions.d.ts.map +1 -0
- package/types/components/Display.d.ts +46 -0
- package/types/components/Display.d.ts.map +1 -0
- package/types/components/Divider.d.ts +10 -0
- package/types/components/Divider.d.ts.map +1 -0
- package/types/components/Fab.d.ts +273 -0
- package/types/components/Fab.d.ts.map +1 -0
- package/types/components/FabContainer.d.ts +10 -0
- package/types/components/FabContainer.d.ts.map +1 -0
- package/types/components/FilterChip.d.ts +256 -0
- package/types/components/FilterChip.d.ts.map +1 -0
- package/types/components/Grid.d.ts +38 -0
- package/types/components/Grid.d.ts.map +1 -0
- package/types/components/Headline.d.ts +46 -0
- package/types/components/Headline.d.ts.map +1 -0
- package/types/components/Icon.d.ts +55 -0
- package/types/components/Icon.d.ts.map +1 -0
- package/types/components/IconButton.d.ts +284 -0
- package/types/components/IconButton.d.ts.map +1 -0
- package/types/components/Input.d.ts +2528 -0
- package/types/components/Input.d.ts.map +1 -0
- package/types/components/InputChip.d.ts +85 -0
- package/types/components/InputChip.d.ts.map +1 -0
- package/types/components/Label.d.ts +29 -0
- package/types/components/Label.d.ts.map +1 -0
- package/types/components/List.d.ts +35 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/ListItem.d.ts +124 -0
- package/types/components/ListItem.d.ts.map +1 -0
- package/types/components/ListOption.d.ts +158 -0
- package/types/components/ListOption.d.ts.map +1 -0
- package/types/components/Listbox.d.ts +763 -0
- package/types/components/Listbox.d.ts.map +1 -0
- package/types/components/Menu.d.ts +130 -0
- package/types/components/Menu.d.ts.map +1 -0
- package/types/components/MenuItem.d.ts +232 -0
- package/types/components/MenuItem.d.ts.map +1 -0
- package/types/components/NavBar.d.ts +20 -0
- package/types/components/NavBar.d.ts.map +1 -0
- package/types/components/NavBarItem.d.ts +97 -0
- package/types/components/NavBarItem.d.ts.map +1 -0
- package/types/components/NavDrawer.d.ts +107 -0
- package/types/components/NavDrawer.d.ts.map +1 -0
- package/types/components/NavDrawerItem.d.ts +97 -0
- package/types/components/NavDrawerItem.d.ts.map +1 -0
- package/types/components/NavItem.d.ts +99 -0
- package/types/components/NavItem.d.ts.map +1 -0
- package/types/components/NavRail.d.ts +108 -0
- package/types/components/NavRail.d.ts.map +1 -0
- package/types/components/NavRailItem.d.ts +97 -0
- package/types/components/NavRailItem.d.ts.map +1 -0
- package/types/components/Page.d.ts +25 -0
- package/types/components/Page.d.ts.map +1 -0
- package/types/components/Pane.d.ts +44 -0
- package/types/components/Pane.d.ts.map +1 -0
- package/types/components/Popup.d.ts +78 -0
- package/types/components/Popup.d.ts.map +1 -0
- package/types/components/Progress.d.ts +21 -0
- package/types/components/Progress.d.ts.map +1 -0
- package/types/components/Radio.d.ts +201 -0
- package/types/components/Radio.d.ts.map +1 -0
- package/types/components/RadioIcon.d.ts +46 -0
- package/types/components/RadioIcon.d.ts.map +1 -0
- package/types/components/Ripple.d.ts +35 -0
- package/types/components/Ripple.d.ts.map +1 -0
- package/types/components/Root.d.ts +68 -0
- package/types/components/Root.d.ts.map +1 -0
- package/types/components/Scrim.d.ts +6 -0
- package/types/components/Scrim.d.ts.map +1 -0
- package/types/components/Search.d.ts +516 -0
- package/types/components/Search.d.ts.map +1 -0
- package/types/components/SegmentedButton.d.ts +252 -0
- package/types/components/SegmentedButton.d.ts.map +1 -0
- package/types/components/SegmentedButtonGroup.d.ts +43 -0
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
- package/types/components/Select.d.ts +158 -0
- package/types/components/Select.d.ts.map +1 -0
- package/types/components/Shape.d.ts +10 -0
- package/types/components/Shape.d.ts.map +1 -0
- package/types/components/SideSheet.d.ts +111 -0
- package/types/components/SideSheet.d.ts.map +1 -0
- package/types/components/Slider.d.ts +203 -0
- package/types/components/Slider.d.ts.map +1 -0
- package/types/components/Snackbar.d.ts +73 -0
- package/types/components/Snackbar.d.ts.map +1 -0
- package/types/components/SnackbarContainer.d.ts +6 -0
- package/types/components/SnackbarContainer.d.ts.map +1 -0
- package/types/components/Surface.d.ts +45 -0
- package/types/components/Surface.d.ts.map +1 -0
- package/types/components/Switch.d.ts +187 -0
- package/types/components/Switch.d.ts.map +1 -0
- package/types/components/SwitchIcon.d.ts +61 -0
- package/types/components/SwitchIcon.d.ts.map +1 -0
- package/types/components/Tab.d.ts +139 -0
- package/types/components/Tab.d.ts.map +1 -0
- package/types/components/TabContent.d.ts +124 -0
- package/types/components/TabContent.d.ts.map +1 -0
- package/types/components/TabList.d.ts +1111 -0
- package/types/components/TabList.d.ts.map +1 -0
- package/types/components/TabPanel.d.ts +28 -0
- package/types/components/TabPanel.d.ts.map +1 -0
- package/types/components/Table.d.ts +25 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/TextArea.d.ts +201 -0
- package/types/components/TextArea.d.ts.map +1 -0
- package/types/components/Title.d.ts +46 -0
- package/types/components/Title.d.ts.map +1 -0
- package/types/components/Tooltip.d.ts +49 -0
- package/types/components/Tooltip.d.ts.map +1 -0
- package/types/components/TopAppBar.d.ts +129 -0
- package/types/components/TopAppBar.d.ts.map +1 -0
- package/types/constants/colorKeywords.d.ts +2 -0
- package/types/constants/colorKeywords.d.ts.map +1 -0
- package/types/constants/shapes.d.ts +38 -0
- package/types/constants/shapes.d.ts.map +1 -0
- package/types/constants/typography.d.ts +212 -0
- package/types/constants/typography.d.ts.map +1 -0
- package/types/core/Composition.d.ts +260 -0
- package/types/core/Composition.d.ts.map +1 -0
- package/types/core/CompositionAdapter.d.ts +114 -0
- package/types/core/CompositionAdapter.d.ts.map +1 -0
- package/types/core/CustomElement.d.ts +304 -0
- package/types/core/CustomElement.d.ts.map +1 -0
- package/types/core/css.d.ts +44 -0
- package/types/core/css.d.ts.map +1 -0
- package/types/core/customTypes.d.ts +22 -0
- package/types/core/customTypes.d.ts.map +1 -0
- package/types/core/dom.d.ts +32 -0
- package/types/core/dom.d.ts.map +1 -0
- package/types/core/jsonMergePatch.d.ts +31 -0
- package/types/core/jsonMergePatch.d.ts.map +1 -0
- package/types/core/observe.d.ts +114 -0
- package/types/core/observe.d.ts.map +1 -0
- package/types/core/optimizations.d.ts +7 -0
- package/types/core/optimizations.d.ts.map +1 -0
- package/types/core/template.d.ts +47 -0
- package/types/core/template.d.ts.map +1 -0
- package/types/core/uid.d.ts +6 -0
- package/types/core/uid.d.ts.map +1 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
- package/types/index.d.ts +88 -0
- package/types/index.d.ts.map +1 -0
- package/types/loaders/palette.d.ts +2 -0
- package/types/loaders/palette.d.ts.map +1 -0
- package/types/loaders/theme.d.ts +2 -0
- package/types/loaders/theme.d.ts.map +1 -0
- package/types/mixins/AriaReflectorMixin.d.ts +31 -0
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
- package/types/mixins/AriaToolbarMixin.d.ts +34 -0
- package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
- package/types/mixins/ControlMixin.d.ts +124 -0
- package/types/mixins/ControlMixin.d.ts.map +1 -0
- package/types/mixins/DelegatesFocusMixin.d.ts +13 -0
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
- package/types/mixins/DensityMixin.d.ts +8 -0
- package/types/mixins/DensityMixin.d.ts.map +1 -0
- package/types/mixins/ElevationMixin.d.ts +32 -0
- package/types/mixins/ElevationMixin.d.ts.map +1 -0
- package/types/mixins/FlexableMixin.d.ts +14 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -0
- package/types/mixins/FormAssociatedMixin.d.ts +123 -0
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
- package/types/mixins/HyperlinkMixin.d.ts +25 -0
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
- package/types/mixins/InputMixin.d.ts +173 -0
- package/types/mixins/InputMixin.d.ts.map +1 -0
- package/types/mixins/KeyboardNavMixin.d.ts +46 -0
- package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
- package/types/mixins/NavigationListenerMixin.d.ts +8 -0
- package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
- package/types/mixins/PopupMixin.d.ts +98 -0
- package/types/mixins/PopupMixin.d.ts.map +1 -0
- package/types/mixins/RTLObserverMixin.d.ts +8 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts +13 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
- package/types/mixins/RippleMixin.d.ts +94 -0
- package/types/mixins/RippleMixin.d.ts.map +1 -0
- package/types/mixins/ScrollListenerMixin.d.ts +46 -0
- package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
- package/types/mixins/SemiStickyMixin.d.ts +50 -0
- package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMaskedMixin.d.ts +12 -0
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMixin.d.ts +39 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -0
- package/types/mixins/StateMixin.d.ts +29 -0
- package/types/mixins/StateMixin.d.ts.map +1 -0
- package/types/mixins/TextFieldMixin.d.ts +153 -0
- package/types/mixins/TextFieldMixin.d.ts.map +1 -0
- package/types/mixins/ThemableMixin.d.ts +10 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -0
- package/types/mixins/TooltipTriggerMixin.d.ts +114 -0
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
- package/types/mixins/TouchTargetMixin.d.ts +6 -0
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
- package/types/mixins/TypographyMixin.d.ts +20 -0
- package/types/mixins/TypographyMixin.d.ts.map +1 -0
- package/types/services/rtl.d.ts +3 -0
- package/types/services/rtl.d.ts.map +1 -0
- package/types/services/svgAlias.d.ts +13 -0
- package/types/services/svgAlias.d.ts.map +1 -0
- package/types/services/theme.d.ts +45 -0
- package/types/services/theme.d.ts.map +1 -0
- package/types/utils/cli.d.ts +3 -0
- package/types/utils/cli.d.ts.map +1 -0
- package/types/utils/function.d.ts +3 -0
- package/types/utils/function.d.ts.map +1 -0
- package/types/utils/jsx-runtime.d.ts +20 -0
- package/types/utils/jsx-runtime.d.ts.map +1 -0
- package/types/utils/material-color/blend.d.ts +34 -0
- package/types/utils/material-color/blend.d.ts.map +1 -0
- package/types/utils/material-color/hct/Cam16.d.ts +142 -0
- package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
- package/types/utils/material-color/hct/Hct.d.ts +93 -0
- package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
- package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
- package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
- package/types/utils/material-color/helper.d.ts +8 -0
- package/types/utils/material-color/helper.d.ts.map +1 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
- package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
- package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
- package/types/utils/material-color/utils/color.d.ts +172 -0
- package/types/utils/material-color/utils/color.d.ts.map +1 -0
- package/types/utils/material-color/utils/math.d.ts +94 -0
- package/types/utils/material-color/utils/math.d.ts.map +1 -0
- package/types/utils/pixelmatch.d.ts +22 -0
- package/types/utils/pixelmatch.d.ts.map +1 -0
- package/types/utils/popup.d.ts +106 -0
- package/types/utils/popup.d.ts.map +1 -0
- package/types/utils/searchParams.d.ts +3 -0
- package/types/utils/searchParams.d.ts.map +1 -0
- package/types/utils/svg.d.ts +7 -0
- package/types/utils/svg.d.ts.map +1 -0
- package/utils/jsx-runtime.js +9 -4
- package/utils/material-color/scheme/Scheme.js +1 -1
- package/utils/pixelmatch.js +363 -0
- package/utils/popup.js +86 -10
- package/utils/searchParams.js +22 -0
- package/components/Button.md +0 -61
- package/components/ExtendedFab.js +0 -32
- package/components/Layout.js +0 -504
- package/components/Nav.js +0 -38
- package/core/DomAdapter.js +0 -586
- package/core/ICustomElement.d.ts +0 -291
- package/core/ICustomElement.js +0 -1
- package/core/test.js +0 -126
- package/core/typings.d.ts +0 -142
- package/core/typings.js +0 -1
- package/mixins/SurfaceMixin.js +0 -127
- package/theming/loader.js +0 -22
- /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
package/components/MenuItem.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
// https://www.w3.org/TR/wai-aria-practices/#menu
|
|
2
2
|
|
|
3
|
+
import { isFocused } from '../core/dom.js';
|
|
3
4
|
import FormAssociatedMixin from '../mixins/FormAssociatedMixin.js';
|
|
4
5
|
|
|
5
6
|
import './Icon.js';
|
|
6
7
|
import ListOption from './ListOption.js';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Menu items represent selectable options within a menu. They can trigger
|
|
11
|
+
* actions, toggle state, or open nested submenus.
|
|
12
|
+
* @see https://m3.material.io/components/menus/specs
|
|
13
|
+
*/
|
|
14
|
+
export default ListOption
|
|
9
15
|
.extend()
|
|
10
16
|
.mixin(FormAssociatedMixin)
|
|
11
17
|
.set({
|
|
18
|
+
/** Timeout handle used to schedule submenu cascade. */
|
|
12
19
|
_cascadeTimeout: null,
|
|
20
|
+
|
|
21
|
+
/** Milliseconds to delay before opening a cascaded submenu. */
|
|
13
22
|
CASCADE_TIMEOUT: 500,
|
|
23
|
+
|
|
24
|
+
/** Internal flag indicating a cascade is in progress. */
|
|
14
25
|
_cascading: false,
|
|
15
26
|
})
|
|
16
27
|
.define({
|
|
@@ -21,9 +32,13 @@ export default class MenuItem extends ListOption
|
|
|
21
32
|
},
|
|
22
33
|
})
|
|
23
34
|
.observe({
|
|
24
|
-
/** ID of
|
|
35
|
+
/** ID of the submenu to open when this item cascades. */
|
|
25
36
|
cascades: 'string',
|
|
26
|
-
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Backing field for the menu item's value attribute. Can be `null` to
|
|
40
|
+
* indicate no explicit value; reflected to the `value` attribute.
|
|
41
|
+
*/
|
|
27
42
|
_defaultValue: {
|
|
28
43
|
attr: 'value',
|
|
29
44
|
reflect: true,
|
|
@@ -32,7 +47,10 @@ export default class MenuItem extends ListOption
|
|
|
32
47
|
},
|
|
33
48
|
})
|
|
34
49
|
.observe({
|
|
35
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Non-null string representation of the default value used for form
|
|
52
|
+
* association. Getter never returns null; setter writes to `_defaultValue`.
|
|
53
|
+
*/
|
|
36
54
|
defaultValue: {
|
|
37
55
|
reflect: false,
|
|
38
56
|
get() {
|
|
@@ -70,12 +88,7 @@ export default class MenuItem extends ListOption
|
|
|
70
88
|
const [name, value] = event.detail;
|
|
71
89
|
if (this.name !== name) return;
|
|
72
90
|
if (value === this.value) return;
|
|
73
|
-
|
|
74
|
-
console.log('unchecking', this.name, this.value);
|
|
75
|
-
this.selected = false;
|
|
76
|
-
} else {
|
|
77
|
-
this.selected = false;
|
|
78
|
-
}
|
|
91
|
+
this.selected = false;
|
|
79
92
|
},
|
|
80
93
|
})
|
|
81
94
|
.expressions({
|
|
@@ -121,7 +134,7 @@ export default class MenuItem extends ListOption
|
|
|
121
134
|
.events({
|
|
122
135
|
mouseenter() {
|
|
123
136
|
if (this.disabledState) return;
|
|
124
|
-
if (
|
|
137
|
+
if (!isFocused(this)) {
|
|
125
138
|
this.focus();
|
|
126
139
|
}
|
|
127
140
|
if (!this.cascades) return;
|
|
@@ -157,7 +170,9 @@ export default class MenuItem extends ListOption
|
|
|
157
170
|
if (!this.cascades) break;
|
|
158
171
|
if (getComputedStyle(this).direction === 'rtl') {
|
|
159
172
|
if (event.key === 'ArrowRight') break;
|
|
160
|
-
} else if (event.key === 'ArrowLeft')
|
|
173
|
+
} else if (event.key === 'ArrowLeft') {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
161
176
|
event.stopPropagation();
|
|
162
177
|
event.preventDefault();
|
|
163
178
|
this.cascade();
|
|
@@ -175,33 +190,32 @@ export default class MenuItem extends ListOption
|
|
|
175
190
|
this.dispatchEvent(new CustomEvent('mdw-menu-item:cascader-blur', { detail: this.cascades, bubbles: true }));
|
|
176
191
|
},
|
|
177
192
|
})
|
|
178
|
-
.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
checkboxRef.remove();
|
|
182
|
-
radioRef.remove();
|
|
193
|
+
.recompose(({ inline, html, refs: { checkbox: checkboxRef, radio: radioRef, anchor, trailing, trailingIcon } }) => {
|
|
194
|
+
checkboxRef.remove();
|
|
195
|
+
radioRef.remove();
|
|
183
196
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
anchor.setAttribute('role', inline(({ checkbox, radio }) => {
|
|
198
|
+
if (checkbox != null) return 'menuitemcheckbox';
|
|
199
|
+
if (radio != null) return 'menuitemradio';
|
|
200
|
+
return 'menuitem';
|
|
201
|
+
}));
|
|
189
202
|
|
|
190
|
-
|
|
191
|
-
|
|
203
|
+
// MenuItems use checked instead of selected as in list items.
|
|
204
|
+
anchor.setAttribute('ariaChecked', anchor.getAttribute('aria-selected'));
|
|
192
205
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
anchor.after(html`
|
|
207
|
+
<mdw-icon id=selection
|
|
208
|
+
mdw-if=${({ checkbox, radio }) => checkbox ?? radio ?? false}
|
|
209
|
+
class=${({ checkbox, radio }) => checkbox || radio || 'leading'}
|
|
210
|
+
selected={selected} icon=check></mdw-icon>
|
|
211
|
+
`);
|
|
199
212
|
|
|
200
|
-
|
|
213
|
+
trailing.setAttribute('type-style', 'label-large');
|
|
201
214
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
215
|
+
trailingIcon.setAttribute('mdw-if', '{computeTrailingIcon}');
|
|
216
|
+
trailingIcon.setAttribute('icon', '{computeTrailingIcon}');
|
|
217
|
+
})
|
|
218
|
+
.on({
|
|
205
219
|
_formResetChanged(oldValue, newValue) {
|
|
206
220
|
if (!newValue) return;
|
|
207
221
|
this._selected = this.defaultSelected;
|
|
@@ -262,5 +276,4 @@ export default class MenuItem extends ListOption
|
|
|
262
276
|
color: inherit;
|
|
263
277
|
}
|
|
264
278
|
`
|
|
265
|
-
.autoRegister('mdw-menu-item')
|
|
266
|
-
.tsClassFix() {}
|
|
279
|
+
.autoRegister('mdw-menu-item');
|
package/components/NavBar.js
CHANGED
|
@@ -1,29 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CustomElement from '../core/CustomElement.js';
|
|
2
|
+
import DelegatesFocusMixin from '../mixins/DelegatesFocusMixin.js';
|
|
3
|
+
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
2
4
|
|
|
3
|
-
import
|
|
5
|
+
import NavItem from './NavItem.js';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Navigation bars let people switch between UI views on smaller devices
|
|
9
|
+
* @see https://m3.material.io/components/navigation-bar/specs
|
|
10
|
+
*/
|
|
11
|
+
export default CustomElement
|
|
6
12
|
.extend()
|
|
7
|
-
.mixin(
|
|
13
|
+
.mixin(DelegatesFocusMixin)
|
|
14
|
+
.mixin(ThemableMixin)
|
|
8
15
|
.observe({
|
|
9
|
-
|
|
16
|
+
/** When true, the navigation bar is expanded and visible on small viewports. */
|
|
17
|
+
open: 'boolean',
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Pixel threshold for auto-closing the nav bar based on viewport width.
|
|
21
|
+
* A value of `-1` disables auto-close. Default: 728.
|
|
22
|
+
*/
|
|
23
|
+
autoClose: {
|
|
24
|
+
type: 'float',
|
|
25
|
+
empty: 728,
|
|
26
|
+
},
|
|
10
27
|
})
|
|
11
|
-
.
|
|
12
|
-
|
|
28
|
+
.set({
|
|
29
|
+
/** Color token used for the nav surface (defaults to `surface-container`). */
|
|
30
|
+
color: 'surface-container',
|
|
13
31
|
|
|
32
|
+
/** ARIA role applied to the host element (default: 'navigation'). */
|
|
33
|
+
_ariaRole: 'navigation',
|
|
34
|
+
})
|
|
35
|
+
.html`<slot id=slot></slot>`
|
|
36
|
+
.css`
|
|
14
37
|
:host {
|
|
15
38
|
--mdw-bg: var(--mdw-color__surface-container);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
inset-block-end: 0;
|
|
19
|
-
order:1; /* Nav Bars are at top of tab order, but bottom of page */
|
|
39
|
+
--mdw-ink: var(--mdw-color__on-surface);
|
|
40
|
+
display: none;
|
|
20
41
|
|
|
21
|
-
display: grid;
|
|
22
42
|
align-content: flex-start;
|
|
23
43
|
align-items: flex-start;
|
|
24
44
|
gap: 8px;
|
|
25
45
|
|
|
26
|
-
grid-area: nav-bar;
|
|
27
46
|
grid-auto-columns: minmax(48px, 1fr);
|
|
28
47
|
grid-auto-flow: column;
|
|
29
48
|
|
|
@@ -33,20 +52,46 @@ export default Nav
|
|
|
33
52
|
min-block-size: 80px;
|
|
34
53
|
inline-size: 100%;
|
|
35
54
|
|
|
36
|
-
|
|
55
|
+
pointer-events: auto;
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
background-color: rgb(var(--mdw-bg));
|
|
39
58
|
|
|
40
|
-
|
|
59
|
+
color: rgb(var(--mdw-ink));
|
|
41
60
|
|
|
42
|
-
|
|
61
|
+
font: var(--mdw-typescale__label-medium__font);
|
|
62
|
+
letter-spacing: var(--mdw-typescale__label-medium__letter-spacing);
|
|
43
63
|
|
|
44
|
-
|
|
64
|
+
text-align: center;
|
|
45
65
|
}
|
|
46
66
|
|
|
47
|
-
|
|
48
|
-
|
|
67
|
+
:host(:where([open])) {
|
|
68
|
+
display: grid;
|
|
49
69
|
}
|
|
50
|
-
|
|
51
70
|
`
|
|
71
|
+
.methods({
|
|
72
|
+
onWindowResize() {
|
|
73
|
+
const { autoClose } = this;
|
|
74
|
+
const containerWidth = window.innerWidth;
|
|
75
|
+
this.open = (autoClose === -1 || containerWidth < autoClose);
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
.events({
|
|
79
|
+
'~click'(event) {
|
|
80
|
+
// Abort if not child
|
|
81
|
+
if (event.target === this) return;
|
|
82
|
+
if (event.target instanceof NavItem === false) return;
|
|
83
|
+
for (const el of this.querySelectorAll('*')) {
|
|
84
|
+
if (el instanceof NavItem === false) continue;
|
|
85
|
+
/** @type {InstanceType<typeof NavItem>} */ (el).active = (el === event.target);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
.on({
|
|
90
|
+
constructed() {
|
|
91
|
+
window.addEventListener('resize', this.onWindowResize.bind(this));
|
|
92
|
+
},
|
|
93
|
+
connected() {
|
|
94
|
+
this.onWindowResize();
|
|
95
|
+
},
|
|
96
|
+
})
|
|
52
97
|
.autoRegister('mdw-nav-bar');
|
package/components/NavBarItem.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import NavItem from './NavItem.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A navigation bar item represents a destination within a navigation bar,
|
|
5
|
+
* providing an icon and optional label to help users move between app sections.
|
|
6
|
+
* @see https://m3.material.io/components/navigation-bar/specs
|
|
7
|
+
*/
|
|
3
8
|
export default NavItem
|
|
4
9
|
.extend()
|
|
5
10
|
.css`
|
package/components/NavDrawer.js
CHANGED
|
@@ -1,18 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import SideSheet from './SideSheet.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Navigation drawers provide access to destinations and app-level navigation
|
|
5
|
+
* in a side panel. They can be modal, dismissible, or permanent depending on
|
|
6
|
+
* viewport and application needs.
|
|
7
|
+
* @see https://m3.material.io/components/navigation-drawer/specs
|
|
8
|
+
*/
|
|
9
|
+
export default SideSheet
|
|
4
10
|
.extend()
|
|
5
11
|
.observe({
|
|
12
|
+
/** When true, apply drawer shape at the end edge (RTL-aware). */
|
|
6
13
|
shapeEnd: {
|
|
7
14
|
type: 'boolean',
|
|
8
15
|
empty: true,
|
|
9
16
|
},
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Viewport width in pixels at or above which the drawer auto-opens.
|
|
20
|
+
* Use `-1` to disable auto-open. Default: 1248.
|
|
21
|
+
*/
|
|
22
|
+
autoOpen: {
|
|
23
|
+
type: 'float',
|
|
24
|
+
empty: 1248,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Fixed layout breakpoint in pixels for permanent/dismissible drawer modes.
|
|
29
|
+
* Default: 1248.
|
|
30
|
+
*/
|
|
31
|
+
fixedBreakpoint: {
|
|
32
|
+
type: 'float',
|
|
33
|
+
empty: 1248,
|
|
34
|
+
},
|
|
10
35
|
})
|
|
11
36
|
.css`
|
|
12
37
|
/* https://m3.material.io/components/navigation-drawer/specs */
|
|
13
38
|
:host {
|
|
14
39
|
--mdw-shape__size: var(--mdw-shape__large, 16px);
|
|
15
40
|
--mdw-shape__size__top-start-size: 0px;
|
|
41
|
+
--mdw-shape__size__bottom-start-size: 0px;
|
|
16
42
|
|
|
17
43
|
--mdw-nav-item__badge__position: static;
|
|
18
44
|
--mdw-nav-item__badge__transform: none;
|
|
@@ -21,25 +47,16 @@ export default NavRail
|
|
|
21
47
|
--mdw-nav-item__label__padding-inline: 52px 0;
|
|
22
48
|
--mdw-nav-item__anchor__display: block;
|
|
23
49
|
--mdw-nav-item__indicator__grid-area: auto;
|
|
24
|
-
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
25
50
|
|
|
26
|
-
display:
|
|
27
|
-
grid-template-columns: 1fr;
|
|
51
|
+
display:inline-block;
|
|
28
52
|
|
|
29
|
-
min-block-size: 100vh;
|
|
30
|
-
max-block-size: 100vh;
|
|
31
53
|
inline-size: 360px;
|
|
32
54
|
max-inline-size: calc(100vw - 56px);
|
|
33
|
-
padding-inline:
|
|
34
|
-
|
|
35
|
-
box-shadow: none;
|
|
55
|
+
padding-inline: 12px;
|
|
36
56
|
}
|
|
37
57
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
inline-size: auto;
|
|
42
|
-
padding-inline: 12px;
|
|
58
|
+
::slotted(mdw-divider) {
|
|
59
|
+
padding-inline: 16px;
|
|
43
60
|
}
|
|
44
61
|
|
|
45
62
|
`
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import NavItem from './NavItem.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A navigation drawer item represents a destination inside a navigation drawer,
|
|
5
|
+
* showing an icon, label, and optional badge to help users navigate app sections.
|
|
6
|
+
* @see https://m3.material.io/components/navigation-drawer/specs
|
|
7
|
+
*/
|
|
3
8
|
export default NavItem
|
|
4
9
|
.extend()
|
|
5
10
|
.css`
|
|
@@ -47,9 +52,7 @@ export default NavItem
|
|
|
47
52
|
z-index: 1;
|
|
48
53
|
}
|
|
49
54
|
`
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
this.refs.badge.replaceWith(html`<span id="badge-text">{badge}</span>`);
|
|
53
|
-
},
|
|
55
|
+
.recompose(({ html, refs: { badge } }) => {
|
|
56
|
+
badge.replaceWith(html`<span id="badge-text">{badge}</span>`);
|
|
54
57
|
})
|
|
55
58
|
.autoRegister('mdw-nav-drawer-item');
|
package/components/NavItem.js
CHANGED
|
@@ -1,63 +1,86 @@
|
|
|
1
1
|
import './Icon.js';
|
|
2
2
|
import './Ripple.js';
|
|
3
3
|
import './Badge.js';
|
|
4
|
+
import './Shape.js';
|
|
4
5
|
|
|
5
6
|
import CustomElement from '../core/CustomElement.js';
|
|
7
|
+
import DelegatesFocusMixin from '../mixins/DelegatesFocusMixin.js';
|
|
8
|
+
import HyperlinkMixin from '../mixins/HyperlinkMixin.js';
|
|
6
9
|
import RippleMixin from '../mixins/RippleMixin.js';
|
|
7
|
-
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
8
10
|
import StateMixin from '../mixins/StateMixin.js';
|
|
9
11
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
10
12
|
|
|
11
13
|
/** @typedef {'charset'|'coords'|'name'|'shape'} DeprecatedHTMLAnchorElementProperties */
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
/**
|
|
16
|
+
* A navigation item represents a single destination used by navigation bars,
|
|
17
|
+
* navigation drawers, and navigation rails. It provides an icon, optional
|
|
18
|
+
* label, and optional badge to help users move between app sections.
|
|
19
|
+
* @see https://m3.material.io/components/navigation-bar/specs
|
|
20
|
+
* @see https://m3.material.io/components/navigation-drawer/specs
|
|
21
|
+
* @see https://m3.material.io/components/navigation-rail/specs
|
|
22
|
+
*/
|
|
23
|
+
export default CustomElement
|
|
14
24
|
.extend()
|
|
15
25
|
.mixin(ThemableMixin)
|
|
16
26
|
.mixin(StateMixin)
|
|
17
27
|
.mixin(RippleMixin)
|
|
18
|
-
.mixin(
|
|
28
|
+
.mixin(HyperlinkMixin)
|
|
29
|
+
.mixin(DelegatesFocusMixin)
|
|
19
30
|
.set({
|
|
20
|
-
delegatesFocus: true,
|
|
21
31
|
stateLayer: true,
|
|
22
32
|
})
|
|
23
33
|
.observe({
|
|
34
|
+
/** Whether the label slot is visible. When true the label is shown. */
|
|
24
35
|
showLabel: 'string',
|
|
36
|
+
/** Whether the item is active/selected; affects styling and aria-current. */
|
|
25
37
|
active: 'boolean',
|
|
38
|
+
/** Name of the icon to display (e.g. 'home'); ignored when `src` is provided. */
|
|
26
39
|
icon: 'string',
|
|
40
|
+
/** URL of an icon image; takes precedence over `icon` when present. */
|
|
27
41
|
src: 'string',
|
|
28
|
-
|
|
42
|
+
/** Badge content to display on the item (e.g. notification count). */
|
|
29
43
|
badge: 'string',
|
|
44
|
+
/** Accessible label for the anchor; when present it is used instead of the slot text. */
|
|
30
45
|
ariaLabel: 'string', // watch attribute and emit callback
|
|
31
46
|
})
|
|
32
47
|
.methods({
|
|
48
|
+
/** Focus the internal anchor element. */
|
|
33
49
|
/** @type {HTMLElement['focus']} */
|
|
34
50
|
focus(...args) {
|
|
35
51
|
this.refs.anchor.focus(...args);
|
|
36
52
|
},
|
|
37
53
|
})
|
|
54
|
+
.expressions({
|
|
55
|
+
_anchorAriaCurrent({ active }) {
|
|
56
|
+
return active ? 'page' : null;
|
|
57
|
+
},
|
|
58
|
+
_anchorAriaLabelledby({ ariaLabel }) {
|
|
59
|
+
return ariaLabel ? null : 'slot';
|
|
60
|
+
},
|
|
61
|
+
_anchorHref({ href }) { return href ?? '#'; },
|
|
62
|
+
iconVariation({ active }) {
|
|
63
|
+
return active ? 'filled' : null;
|
|
64
|
+
},
|
|
65
|
+
})
|
|
38
66
|
.html`
|
|
39
|
-
<mdw-icon id=icon aria-hidden=true src={src} active={active}
|
|
40
|
-
<a id=anchor
|
|
41
|
-
aria-current=${({ active }) => (active ? 'page' : null)}
|
|
42
|
-
aria-describedby=badge
|
|
43
|
-
aria-label={ariaLabel}
|
|
44
|
-
aria-labelledby=${({ ariaLabel }) => (ariaLabel ? null : 'slot')}
|
|
45
|
-
href=${({ href }) => href ?? '#'}>
|
|
46
|
-
</a>
|
|
67
|
+
<mdw-icon id=icon aria-hidden=true src={src} active={active} icon={icon} variation={iconVariation}></mdw-icon>
|
|
47
68
|
<slot id=slot active={active} show-label={showLabel} aria-hidden=true></slot>
|
|
48
69
|
<mdw-badge part=badge id=badge badge={badge} show-label={showLabel} aria-hidden=true>{badge}</mdw-badge>
|
|
49
70
|
`
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
.recompose(({ html, refs: { anchor, state, rippleContainer } }) => {
|
|
72
|
+
anchor.setAttribute('aria-current', '{_anchorAriaCurrent}');
|
|
73
|
+
anchor.setAttribute('aria-describedby', 'badge');
|
|
74
|
+
anchor.setAttribute('aria-label', '{ariaLabel}');
|
|
75
|
+
anchor.setAttribute('aria-labelledby', '{_anchorAriaLabelledby}');
|
|
76
|
+
anchor.setAttribute('href', '{_anchorHref}');
|
|
77
|
+
anchor.before(html`
|
|
78
|
+
<mdw-shape id=shape active={active} shape-style=full>
|
|
54
79
|
<mdw-ripple id=ripple ripple-origin=center keep-alive hold-ripple ripple-state=${({ active }) => ((active) ? null : 'complete')}></mdw-ripple>
|
|
55
80
|
${state}
|
|
56
81
|
${rippleContainer}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
shape.removeAttribute('color');
|
|
60
|
-
},
|
|
82
|
+
</mdw-shape>
|
|
83
|
+
`);
|
|
61
84
|
})
|
|
62
85
|
.css`
|
|
63
86
|
/* https://m3.material.io/components/navigation-bar/specs */
|
|
@@ -86,7 +109,7 @@ export default class NavItem extends CustomElement
|
|
|
86
109
|
padding-inline: 0;
|
|
87
110
|
|
|
88
111
|
cursor: pointer;
|
|
89
|
-
|
|
112
|
+
|
|
90
113
|
user-select: none;
|
|
91
114
|
|
|
92
115
|
font: var(--mdw-typescale__label-large__font);
|
|
@@ -149,6 +172,8 @@ export default class NavItem extends CustomElement
|
|
|
149
172
|
/* stylelint-disable-next-line liberty/use-logical-spec */
|
|
150
173
|
left: 50%;
|
|
151
174
|
|
|
175
|
+
overflow: hidden;
|
|
176
|
+
|
|
152
177
|
block-size: 100%;
|
|
153
178
|
inline-size: 100%;
|
|
154
179
|
max-inline-size: 56px;
|
|
@@ -157,7 +182,6 @@ export default class NavItem extends CustomElement
|
|
|
157
182
|
grid-row: 1 / 1;
|
|
158
183
|
|
|
159
184
|
transform: translateX(-50%) translateY(-50%) translateY(var(--mdw-nav-item__offset-y));
|
|
160
|
-
z-index: 0;
|
|
161
185
|
|
|
162
186
|
background-color: transparent;
|
|
163
187
|
|
|
@@ -177,7 +201,6 @@ export default class NavItem extends CustomElement
|
|
|
177
201
|
color: rgb(var(--mdw-color__on-surface-variant));
|
|
178
202
|
|
|
179
203
|
font-size: 24px;
|
|
180
|
-
font-variation-settings: 'FILL' 0;
|
|
181
204
|
|
|
182
205
|
transition: transform 200ms;
|
|
183
206
|
will-change: transform;
|
|
@@ -235,8 +258,6 @@ export default class NavItem extends CustomElement
|
|
|
235
258
|
|
|
236
259
|
#icon[active] {
|
|
237
260
|
color: rgb(var(--mdw-ink));
|
|
238
|
-
|
|
239
|
-
font-variation-settings: 'FILL' 1;
|
|
240
261
|
}
|
|
241
262
|
|
|
242
263
|
#slot[active] {
|
|
@@ -259,15 +280,21 @@ export default class NavItem extends CustomElement
|
|
|
259
280
|
},
|
|
260
281
|
keydown({ key, repeat }) {
|
|
261
282
|
if (key !== ' ') return true;
|
|
262
|
-
if (!repeat)
|
|
283
|
+
if (!repeat) {
|
|
284
|
+
this.click();
|
|
285
|
+
}
|
|
263
286
|
return false;
|
|
264
287
|
},
|
|
265
288
|
},
|
|
266
289
|
})
|
|
267
|
-
.
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
290
|
+
.extend((Base) => class NavItem extends Base {
|
|
291
|
+
/**
|
|
292
|
+
* Add a ripple effect only when the item is active.
|
|
293
|
+
* @type {InstanceType<ReturnType<RippleMixin>>['addRipple']}
|
|
294
|
+
*/
|
|
295
|
+
addRipple(...args) {
|
|
296
|
+
if (!this.active) return null;
|
|
297
|
+
return super.addRipple(...args);
|
|
298
|
+
}
|
|
299
|
+
})
|
|
300
|
+
.autoRegister('mdw-nav-item');
|
package/components/NavRail.js
CHANGED
|
@@ -1,39 +1,52 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SideSheet from './SideSheet.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Navigation rails provide access to app destinations and destinations-level
|
|
5
|
+
* navigation in a vertical rail, suited for larger screens and desktop layouts.
|
|
6
|
+
* @see https://m3.material.io/components/navigation-rail/specs
|
|
7
|
+
*/
|
|
8
|
+
export default SideSheet
|
|
4
9
|
.extend()
|
|
5
10
|
.observe({
|
|
11
|
+
/** Horizontal alignment for rail content: 'start', 'center', or 'end'. */
|
|
6
12
|
align: { value: /** @type {'start'|'center'|'end'} */ (null) },
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
/** Viewport width (pixels) threshold at or above which the rail will auto-open. */
|
|
14
|
+
autoOpen: {
|
|
15
|
+
type: 'float',
|
|
16
|
+
empty: 728,
|
|
17
|
+
},
|
|
18
|
+
/** Viewport width (pixels) threshold at or below which the rail will auto-close. */
|
|
19
|
+
autoClose: {
|
|
20
|
+
type: 'float',
|
|
21
|
+
empty: 1248,
|
|
22
|
+
},
|
|
23
|
+
/** Viewport width (pixels) at which the rail becomes fixed (non-collapsible). */
|
|
24
|
+
fixedBreakpoint: {
|
|
25
|
+
type: 'float',
|
|
26
|
+
empty: 728,
|
|
13
27
|
},
|
|
14
28
|
})
|
|
29
|
+
.recompose(({ html, refs: { slot } }) => {
|
|
30
|
+
slot.before(html`<slot id=start name=start></slot>`);
|
|
31
|
+
slot.setAttribute('align', '{align}');
|
|
32
|
+
})
|
|
15
33
|
.css`
|
|
16
34
|
/* https://m3.material.io/components/navigation-rail/specs */
|
|
17
35
|
|
|
18
36
|
:host{
|
|
19
|
-
position: relative;
|
|
20
|
-
|
|
21
|
-
inset-block-start: 0;
|
|
22
|
-
inset-inline-start: 0;
|
|
23
37
|
align-self: flex-start;
|
|
24
38
|
|
|
25
|
-
display: grid;
|
|
39
|
+
display: inline-grid;
|
|
26
40
|
align-content: flex-start;
|
|
27
41
|
flex-direction: column;
|
|
28
42
|
gap:0;
|
|
29
|
-
grid-template-rows: auto minmax(
|
|
43
|
+
grid-template-rows: auto minmax(auto,1fr);
|
|
30
44
|
grid-template-columns: 100%;
|
|
31
45
|
justify-items: stretch;
|
|
46
|
+
overscroll-behavior: none;
|
|
47
|
+
overscroll-behavior: contain;
|
|
32
48
|
|
|
33
|
-
min-block-size:
|
|
34
|
-
max-block-size: 100vh;
|
|
35
|
-
min-inline-size: 80px;
|
|
36
|
-
max-inline-size: 80px;
|
|
49
|
+
min-block-size: 0;
|
|
37
50
|
|
|
38
51
|
text-align: center;
|
|
39
52
|
}
|
|
@@ -43,6 +56,7 @@ export default Nav
|
|
|
43
56
|
align-items: center;
|
|
44
57
|
flex-direction: column;
|
|
45
58
|
gap: 12px;
|
|
59
|
+
justify-content: center;
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
#slot {
|
|
@@ -52,8 +66,6 @@ export default Nav
|
|
|
52
66
|
align-items: stretch;
|
|
53
67
|
flex-direction: column;
|
|
54
68
|
gap: 12px;
|
|
55
|
-
overflow-x: clip;
|
|
56
|
-
overflow-y: auto;
|
|
57
69
|
|
|
58
70
|
box-sizing: border-box;
|
|
59
71
|
max-block-size: 100%;
|
|
@@ -68,6 +80,5 @@ export default Nav
|
|
|
68
80
|
#slot[align="end"] {
|
|
69
81
|
align-self: flex-end;
|
|
70
82
|
}
|
|
71
|
-
|
|
72
83
|
`
|
|
73
84
|
.autoRegister('mdw-nav-rail');
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import NavItem from './NavItem.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A navigation rail item represents a destination within a navigation rail,
|
|
7
|
+
* showing an icon and optional label for vertical navigation on larger screens.
|
|
8
|
+
* @see https://m3.material.io/components/navigation-rail/specs
|
|
9
|
+
*/
|
|
5
10
|
export default NavItem
|
|
6
11
|
.extend()
|
|
7
12
|
.css`
|
|
@@ -9,11 +14,14 @@ export default NavItem
|
|
|
9
14
|
grid-auto-flow: row;
|
|
10
15
|
grid-auto-rows: minmax(20px, auto);
|
|
11
16
|
grid-template-rows: [icon] minmax(32px, 1fr);
|
|
12
|
-
grid-template-columns: [icon] minmax(
|
|
17
|
+
grid-template-columns: [icon] minmax(72px, 1fr);
|
|
13
18
|
|
|
14
19
|
min-block-size: 56px;
|
|
15
20
|
flex: none;
|
|
16
|
-
padding-inline:
|
|
21
|
+
padding-inline: 4px;
|
|
22
|
+
|
|
23
|
+
font: var(--mdw-typescale__label-medium__font);
|
|
24
|
+
letter-spacing: var(--mdw-typescale__label-medium__letter-spacing);
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
#slot {
|