@shortfuse/materialdesignweb 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -198
- package/bin/mdw-css.js +1 -1
- package/components/Badge.js +15 -5
- package/components/Body.js +7 -0
- package/components/BottomAppBar.js +7 -10
- package/components/BottomSheet.js +472 -0
- package/components/Box.js +11 -49
- package/components/Button.js +81 -82
- package/components/Card.js +74 -62
- package/components/Checkbox.js +15 -25
- package/components/CheckboxIcon.js +19 -31
- package/components/Chip.js +18 -13
- package/components/Dialog.js +70 -100
- package/components/DialogActions.js +4 -0
- package/components/Display.js +64 -0
- package/components/Divider.js +5 -0
- package/components/Fab.js +94 -17
- package/components/FabContainer.js +57 -0
- package/components/FilterChip.js +43 -32
- package/components/Grid.js +187 -0
- package/components/Headline.js +9 -28
- package/components/Icon.js +80 -71
- package/components/IconButton.js +77 -120
- package/components/Input.js +745 -86
- package/components/InputChip.js +193 -0
- package/components/Label.js +7 -0
- package/components/List.js +11 -5
- package/components/ListItem.js +92 -23
- package/components/ListOption.js +143 -65
- package/components/Listbox.js +57 -17
- package/components/Menu.js +39 -27
- package/components/MenuItem.js +49 -36
- package/components/NavBar.js +66 -21
- package/components/NavBarItem.js +5 -0
- package/components/NavDrawer.js +33 -16
- package/components/NavDrawerItem.js +7 -4
- package/components/NavItem.js +61 -34
- package/components/NavRail.js +32 -21
- package/components/NavRailItem.js +10 -2
- package/components/Page.js +119 -0
- package/components/Pane.js +24 -0
- package/components/Popup.js +23 -8
- package/components/Progress.js +25 -5
- package/components/Radio.js +8 -7
- package/components/RadioIcon.js +24 -15
- package/components/Ripple.js +25 -7
- package/components/Root.js +225 -0
- package/components/Scrim.js +95 -0
- package/components/Search.js +30 -25
- package/components/SegmentedButton.js +53 -40
- package/components/SegmentedButtonGroup.js +15 -12
- package/components/Select.js +19 -10
- package/components/Shape.js +10 -66
- package/components/SideSheet.js +337 -0
- package/components/Slider.js +93 -36
- package/components/Snackbar.js +52 -20
- package/components/SnackbarContainer.js +51 -0
- package/components/Surface.js +20 -10
- package/components/Switch.js +21 -18
- package/components/SwitchIcon.js +62 -33
- package/components/Tab.js +78 -38
- package/components/TabContent.js +33 -12
- package/components/TabList.js +95 -34
- package/components/TabPanel.js +10 -1
- package/components/Table.js +151 -0
- package/components/TextArea.js +48 -16
- package/components/Title.js +8 -9
- package/components/Tooltip.js +51 -22
- package/components/TopAppBar.js +71 -78
- package/constants/shapes.js +36 -0
- package/constants/typography.js +127 -0
- package/core/Composition.js +391 -201
- package/core/CompositionAdapter.js +35 -18
- package/core/CustomElement.js +634 -254
- package/core/css.js +117 -12
- package/core/customTypes.js +161 -49
- package/core/dom.js +18 -11
- package/core/jsonMergePatch.js +27 -11
- package/core/observe.js +308 -256
- package/core/optimizations.js +9 -9
- package/core/template.js +14 -57
- package/dist/CustomElement.min.js +2 -0
- package/dist/CustomElement.min.js.map +7 -0
- package/dist/core/CustomElement.min.js +2 -0
- package/dist/core/CustomElement.min.js.map +7 -0
- package/dist/index.min.js +85 -115
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +108 -0
- package/{theming/themableMixinLoader.js → loaders/palette.js} +4 -3
- package/loaders/theme.js +12 -0
- package/mixins/AriaReflectorMixin.js +64 -15
- package/mixins/AriaToolbarMixin.js +6 -0
- package/mixins/ControlMixin.js +79 -33
- package/mixins/DelegatesFocusMixin.js +62 -0
- package/mixins/DensityMixin.js +7 -3
- package/mixins/ElevationMixin.js +61 -0
- package/mixins/FlexableMixin.js +87 -39
- package/mixins/FormAssociatedMixin.js +76 -10
- package/mixins/HyperlinkMixin.js +76 -0
- package/mixins/InputMixin.js +227 -32
- package/mixins/KeyboardNavMixin.js +11 -7
- package/mixins/NavigationListenerMixin.js +33 -0
- package/mixins/PopupMixin.js +216 -219
- package/mixins/RTLObserverMixin.js +2 -0
- package/mixins/ResizeObserverMixin.js +18 -4
- package/mixins/RippleMixin.js +11 -7
- package/mixins/ScrollListenerMixin.js +14 -2
- package/mixins/SemiStickyMixin.js +51 -98
- package/mixins/ShapeMaskedMixin.js +125 -0
- package/mixins/ShapeMixin.js +30 -203
- package/mixins/StateMixin.js +74 -34
- package/mixins/TextFieldMixin.js +128 -145
- package/mixins/ThemableMixin.js +57 -56
- package/mixins/TooltipTriggerMixin.js +305 -359
- package/mixins/TouchTargetMixin.js +5 -2
- package/mixins/TypographyMixin.js +128 -0
- package/package.json +125 -81
- package/services/rtl.js +10 -0
- package/services/svgAlias.js +17 -0
- package/{theming/index.js → services/theme.js} +25 -176
- package/types/bin/mdw-css.d.ts +3 -0
- package/types/bin/mdw-css.d.ts.map +1 -0
- package/types/components/Badge.d.ts +39 -0
- package/types/components/Badge.d.ts.map +1 -0
- package/types/components/Body.d.ts +29 -0
- package/types/components/Body.d.ts.map +1 -0
- package/types/components/BottomAppBar.d.ts +72 -0
- package/types/components/BottomAppBar.d.ts.map +1 -0
- package/types/components/BottomSheet.d.ts +135 -0
- package/types/components/BottomSheet.d.ts.map +1 -0
- package/types/components/Box.d.ts +16 -0
- package/types/components/Box.d.ts.map +1 -0
- package/types/components/Button.d.ts +245 -0
- package/types/components/Button.d.ts.map +1 -0
- package/types/components/Card.d.ts +147 -0
- package/types/components/Card.d.ts.map +1 -0
- package/types/components/Checkbox.d.ts +207 -0
- package/types/components/Checkbox.d.ts.map +1 -0
- package/types/components/CheckboxIcon.d.ts +44 -0
- package/types/components/CheckboxIcon.d.ts.map +1 -0
- package/types/components/Chip.d.ts +248 -0
- package/types/components/Chip.d.ts.map +1 -0
- package/types/components/Dialog.d.ts +103 -0
- package/types/components/Dialog.d.ts.map +1 -0
- package/types/components/DialogActions.d.ts +4 -0
- package/types/components/DialogActions.d.ts.map +1 -0
- package/types/components/Display.d.ts +46 -0
- package/types/components/Display.d.ts.map +1 -0
- package/types/components/Divider.d.ts +10 -0
- package/types/components/Divider.d.ts.map +1 -0
- package/types/components/Fab.d.ts +273 -0
- package/types/components/Fab.d.ts.map +1 -0
- package/types/components/FabContainer.d.ts +10 -0
- package/types/components/FabContainer.d.ts.map +1 -0
- package/types/components/FilterChip.d.ts +256 -0
- package/types/components/FilterChip.d.ts.map +1 -0
- package/types/components/Grid.d.ts +38 -0
- package/types/components/Grid.d.ts.map +1 -0
- package/types/components/Headline.d.ts +46 -0
- package/types/components/Headline.d.ts.map +1 -0
- package/types/components/Icon.d.ts +55 -0
- package/types/components/Icon.d.ts.map +1 -0
- package/types/components/IconButton.d.ts +284 -0
- package/types/components/IconButton.d.ts.map +1 -0
- package/types/components/Input.d.ts +2528 -0
- package/types/components/Input.d.ts.map +1 -0
- package/types/components/InputChip.d.ts +85 -0
- package/types/components/InputChip.d.ts.map +1 -0
- package/types/components/Label.d.ts +29 -0
- package/types/components/Label.d.ts.map +1 -0
- package/types/components/List.d.ts +35 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/ListItem.d.ts +124 -0
- package/types/components/ListItem.d.ts.map +1 -0
- package/types/components/ListOption.d.ts +158 -0
- package/types/components/ListOption.d.ts.map +1 -0
- package/types/components/Listbox.d.ts +763 -0
- package/types/components/Listbox.d.ts.map +1 -0
- package/types/components/Menu.d.ts +130 -0
- package/types/components/Menu.d.ts.map +1 -0
- package/types/components/MenuItem.d.ts +232 -0
- package/types/components/MenuItem.d.ts.map +1 -0
- package/types/components/NavBar.d.ts +20 -0
- package/types/components/NavBar.d.ts.map +1 -0
- package/types/components/NavBarItem.d.ts +97 -0
- package/types/components/NavBarItem.d.ts.map +1 -0
- package/types/components/NavDrawer.d.ts +107 -0
- package/types/components/NavDrawer.d.ts.map +1 -0
- package/types/components/NavDrawerItem.d.ts +97 -0
- package/types/components/NavDrawerItem.d.ts.map +1 -0
- package/types/components/NavItem.d.ts +99 -0
- package/types/components/NavItem.d.ts.map +1 -0
- package/types/components/NavRail.d.ts +108 -0
- package/types/components/NavRail.d.ts.map +1 -0
- package/types/components/NavRailItem.d.ts +97 -0
- package/types/components/NavRailItem.d.ts.map +1 -0
- package/types/components/Page.d.ts +25 -0
- package/types/components/Page.d.ts.map +1 -0
- package/types/components/Pane.d.ts +44 -0
- package/types/components/Pane.d.ts.map +1 -0
- package/types/components/Popup.d.ts +78 -0
- package/types/components/Popup.d.ts.map +1 -0
- package/types/components/Progress.d.ts +21 -0
- package/types/components/Progress.d.ts.map +1 -0
- package/types/components/Radio.d.ts +201 -0
- package/types/components/Radio.d.ts.map +1 -0
- package/types/components/RadioIcon.d.ts +46 -0
- package/types/components/RadioIcon.d.ts.map +1 -0
- package/types/components/Ripple.d.ts +35 -0
- package/types/components/Ripple.d.ts.map +1 -0
- package/types/components/Root.d.ts +68 -0
- package/types/components/Root.d.ts.map +1 -0
- package/types/components/Scrim.d.ts +6 -0
- package/types/components/Scrim.d.ts.map +1 -0
- package/types/components/Search.d.ts +516 -0
- package/types/components/Search.d.ts.map +1 -0
- package/types/components/SegmentedButton.d.ts +252 -0
- package/types/components/SegmentedButton.d.ts.map +1 -0
- package/types/components/SegmentedButtonGroup.d.ts +43 -0
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
- package/types/components/Select.d.ts +158 -0
- package/types/components/Select.d.ts.map +1 -0
- package/types/components/Shape.d.ts +10 -0
- package/types/components/Shape.d.ts.map +1 -0
- package/types/components/SideSheet.d.ts +111 -0
- package/types/components/SideSheet.d.ts.map +1 -0
- package/types/components/Slider.d.ts +203 -0
- package/types/components/Slider.d.ts.map +1 -0
- package/types/components/Snackbar.d.ts +73 -0
- package/types/components/Snackbar.d.ts.map +1 -0
- package/types/components/SnackbarContainer.d.ts +6 -0
- package/types/components/SnackbarContainer.d.ts.map +1 -0
- package/types/components/Surface.d.ts +45 -0
- package/types/components/Surface.d.ts.map +1 -0
- package/types/components/Switch.d.ts +187 -0
- package/types/components/Switch.d.ts.map +1 -0
- package/types/components/SwitchIcon.d.ts +61 -0
- package/types/components/SwitchIcon.d.ts.map +1 -0
- package/types/components/Tab.d.ts +139 -0
- package/types/components/Tab.d.ts.map +1 -0
- package/types/components/TabContent.d.ts +124 -0
- package/types/components/TabContent.d.ts.map +1 -0
- package/types/components/TabList.d.ts +1111 -0
- package/types/components/TabList.d.ts.map +1 -0
- package/types/components/TabPanel.d.ts +28 -0
- package/types/components/TabPanel.d.ts.map +1 -0
- package/types/components/Table.d.ts +25 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/TextArea.d.ts +201 -0
- package/types/components/TextArea.d.ts.map +1 -0
- package/types/components/Title.d.ts +46 -0
- package/types/components/Title.d.ts.map +1 -0
- package/types/components/Tooltip.d.ts +49 -0
- package/types/components/Tooltip.d.ts.map +1 -0
- package/types/components/TopAppBar.d.ts +129 -0
- package/types/components/TopAppBar.d.ts.map +1 -0
- package/types/constants/colorKeywords.d.ts +2 -0
- package/types/constants/colorKeywords.d.ts.map +1 -0
- package/types/constants/shapes.d.ts +38 -0
- package/types/constants/shapes.d.ts.map +1 -0
- package/types/constants/typography.d.ts +212 -0
- package/types/constants/typography.d.ts.map +1 -0
- package/types/core/Composition.d.ts +260 -0
- package/types/core/Composition.d.ts.map +1 -0
- package/types/core/CompositionAdapter.d.ts +114 -0
- package/types/core/CompositionAdapter.d.ts.map +1 -0
- package/types/core/CustomElement.d.ts +304 -0
- package/types/core/CustomElement.d.ts.map +1 -0
- package/types/core/css.d.ts +44 -0
- package/types/core/css.d.ts.map +1 -0
- package/types/core/customTypes.d.ts +22 -0
- package/types/core/customTypes.d.ts.map +1 -0
- package/types/core/dom.d.ts +32 -0
- package/types/core/dom.d.ts.map +1 -0
- package/types/core/jsonMergePatch.d.ts +31 -0
- package/types/core/jsonMergePatch.d.ts.map +1 -0
- package/types/core/observe.d.ts +114 -0
- package/types/core/observe.d.ts.map +1 -0
- package/types/core/optimizations.d.ts +7 -0
- package/types/core/optimizations.d.ts.map +1 -0
- package/types/core/template.d.ts +47 -0
- package/types/core/template.d.ts.map +1 -0
- package/types/core/uid.d.ts +6 -0
- package/types/core/uid.d.ts.map +1 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
- package/types/index.d.ts +88 -0
- package/types/index.d.ts.map +1 -0
- package/types/loaders/palette.d.ts +2 -0
- package/types/loaders/palette.d.ts.map +1 -0
- package/types/loaders/theme.d.ts +2 -0
- package/types/loaders/theme.d.ts.map +1 -0
- package/types/mixins/AriaReflectorMixin.d.ts +31 -0
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
- package/types/mixins/AriaToolbarMixin.d.ts +34 -0
- package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
- package/types/mixins/ControlMixin.d.ts +124 -0
- package/types/mixins/ControlMixin.d.ts.map +1 -0
- package/types/mixins/DelegatesFocusMixin.d.ts +13 -0
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
- package/types/mixins/DensityMixin.d.ts +8 -0
- package/types/mixins/DensityMixin.d.ts.map +1 -0
- package/types/mixins/ElevationMixin.d.ts +32 -0
- package/types/mixins/ElevationMixin.d.ts.map +1 -0
- package/types/mixins/FlexableMixin.d.ts +14 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -0
- package/types/mixins/FormAssociatedMixin.d.ts +123 -0
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
- package/types/mixins/HyperlinkMixin.d.ts +25 -0
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
- package/types/mixins/InputMixin.d.ts +173 -0
- package/types/mixins/InputMixin.d.ts.map +1 -0
- package/types/mixins/KeyboardNavMixin.d.ts +46 -0
- package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
- package/types/mixins/NavigationListenerMixin.d.ts +8 -0
- package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
- package/types/mixins/PopupMixin.d.ts +98 -0
- package/types/mixins/PopupMixin.d.ts.map +1 -0
- package/types/mixins/RTLObserverMixin.d.ts +8 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts +13 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
- package/types/mixins/RippleMixin.d.ts +94 -0
- package/types/mixins/RippleMixin.d.ts.map +1 -0
- package/types/mixins/ScrollListenerMixin.d.ts +46 -0
- package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
- package/types/mixins/SemiStickyMixin.d.ts +50 -0
- package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMaskedMixin.d.ts +12 -0
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMixin.d.ts +39 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -0
- package/types/mixins/StateMixin.d.ts +29 -0
- package/types/mixins/StateMixin.d.ts.map +1 -0
- package/types/mixins/TextFieldMixin.d.ts +153 -0
- package/types/mixins/TextFieldMixin.d.ts.map +1 -0
- package/types/mixins/ThemableMixin.d.ts +10 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -0
- package/types/mixins/TooltipTriggerMixin.d.ts +114 -0
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
- package/types/mixins/TouchTargetMixin.d.ts +6 -0
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
- package/types/mixins/TypographyMixin.d.ts +20 -0
- package/types/mixins/TypographyMixin.d.ts.map +1 -0
- package/types/services/rtl.d.ts +3 -0
- package/types/services/rtl.d.ts.map +1 -0
- package/types/services/svgAlias.d.ts +13 -0
- package/types/services/svgAlias.d.ts.map +1 -0
- package/types/services/theme.d.ts +45 -0
- package/types/services/theme.d.ts.map +1 -0
- package/types/utils/cli.d.ts +3 -0
- package/types/utils/cli.d.ts.map +1 -0
- package/types/utils/function.d.ts +3 -0
- package/types/utils/function.d.ts.map +1 -0
- package/types/utils/jsx-runtime.d.ts +20 -0
- package/types/utils/jsx-runtime.d.ts.map +1 -0
- package/types/utils/material-color/blend.d.ts +34 -0
- package/types/utils/material-color/blend.d.ts.map +1 -0
- package/types/utils/material-color/hct/Cam16.d.ts +142 -0
- package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
- package/types/utils/material-color/hct/Hct.d.ts +93 -0
- package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
- package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
- package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
- package/types/utils/material-color/helper.d.ts +8 -0
- package/types/utils/material-color/helper.d.ts.map +1 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
- package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
- package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
- package/types/utils/material-color/utils/color.d.ts +172 -0
- package/types/utils/material-color/utils/color.d.ts.map +1 -0
- package/types/utils/material-color/utils/math.d.ts +94 -0
- package/types/utils/material-color/utils/math.d.ts.map +1 -0
- package/types/utils/pixelmatch.d.ts +22 -0
- package/types/utils/pixelmatch.d.ts.map +1 -0
- package/types/utils/popup.d.ts +106 -0
- package/types/utils/popup.d.ts.map +1 -0
- package/types/utils/searchParams.d.ts +3 -0
- package/types/utils/searchParams.d.ts.map +1 -0
- package/types/utils/svg.d.ts +7 -0
- package/types/utils/svg.d.ts.map +1 -0
- package/utils/jsx-runtime.js +9 -4
- package/utils/material-color/scheme/Scheme.js +1 -1
- package/utils/pixelmatch.js +363 -0
- package/utils/popup.js +86 -10
- package/utils/searchParams.js +22 -0
- package/components/Button.md +0 -61
- package/components/ExtendedFab.js +0 -32
- package/components/Layout.js +0 -504
- package/components/Nav.js +0 -38
- package/core/DomAdapter.js +0 -586
- package/core/ICustomElement.d.ts +0 -291
- package/core/ICustomElement.js +0 -1
- package/core/test.js +0 -126
- package/core/typings.d.ts +0 -142
- package/core/typings.js +0 -1
- package/mixins/SurfaceMixin.js +0 -127
- package/theming/loader.js +0 -22
- /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import CustomElement from '../core/CustomElement.js';
|
|
2
|
+
|
|
3
|
+
// https://html.spec.whatwg.org/multipage/tables.html#htmltableelement
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {Element} parent
|
|
7
|
+
* @param {string} tagName
|
|
8
|
+
* @return {Element?}
|
|
9
|
+
*/
|
|
10
|
+
function getByTagName(parent, tagName) {
|
|
11
|
+
for (const element of parent.children) {
|
|
12
|
+
if (element.tagName === tagName) {
|
|
13
|
+
return element;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {Element} parent
|
|
21
|
+
* @param {string} tagName
|
|
22
|
+
* @param {Element|null} value
|
|
23
|
+
* @param {string} errorMessage
|
|
24
|
+
* @return {Element?}
|
|
25
|
+
*/
|
|
26
|
+
function setByTagName(parent, tagName, value, errorMessage) {
|
|
27
|
+
const current = getByTagName(parent, tagName);
|
|
28
|
+
if (!value) {
|
|
29
|
+
current?.remove();
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (value === current) return value;
|
|
33
|
+
if (value instanceof HTMLElement && value.tagName === tagName) {
|
|
34
|
+
if (current) {
|
|
35
|
+
current.replaceWith(value);
|
|
36
|
+
} else {
|
|
37
|
+
this.prepend(value);
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
throw new TypeError(errorMessage);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {Element} parent
|
|
46
|
+
* @param {string} tagName
|
|
47
|
+
* @return {Element?}
|
|
48
|
+
*/
|
|
49
|
+
function createByTagName(parent, tagName) {
|
|
50
|
+
let element = this.getByTagName(parent, tagName);
|
|
51
|
+
if (element) return element;
|
|
52
|
+
element = document.createElement(tagName);
|
|
53
|
+
this.prepend(element);
|
|
54
|
+
return element;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {Element} parent
|
|
59
|
+
* @param {string} tagName
|
|
60
|
+
* @return {void}
|
|
61
|
+
*/
|
|
62
|
+
function deleteByTagName(parent, tagName) {
|
|
63
|
+
this.setByTagName(parent, tagName, null);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Table provides an HTML-like table API using mdw elements for rows and sections.
|
|
68
|
+
* Implements the {@link https://html.spec.whatwg.org/multipage/tables.html#htmltableelement | HTMLTableElement} API
|
|
69
|
+
* using `mdw-` prefixed sections and rows.
|
|
70
|
+
*
|
|
71
|
+
* Legacy. Modern UI does not use tables and no longer part of Material Design Web.
|
|
72
|
+
* Tables are generally not responsive and do not adapt well to different screen sizes.
|
|
73
|
+
*/
|
|
74
|
+
export default CustomElement
|
|
75
|
+
.extend()
|
|
76
|
+
.define({
|
|
77
|
+
/**
|
|
78
|
+
* The table caption element (`mdw-caption`) or `null` when not present.
|
|
79
|
+
* Mirrors `HTMLTableElement.caption` semantics.
|
|
80
|
+
*/
|
|
81
|
+
caption: {
|
|
82
|
+
get() {
|
|
83
|
+
return getByTagName(this, 'mdw-caption');
|
|
84
|
+
},
|
|
85
|
+
set(value) {
|
|
86
|
+
return setByTagName(this, 'mdw-caption', value, "Failed to set the 'caption' property on 'MDWTableElement': Failed to convert value to 'MDWCaptionElement'.");
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* The table header section (`mdw-thead`) element or `null` when not present.
|
|
91
|
+
* Mirrors `HTMLTableElement.tHead` semantics.
|
|
92
|
+
*/
|
|
93
|
+
tHead: {
|
|
94
|
+
get() {
|
|
95
|
+
return getByTagName(this, 'mdw-thead');
|
|
96
|
+
},
|
|
97
|
+
set(value) {
|
|
98
|
+
return setByTagName(this, 'mdw-thead', value, "Failed to set the 'tHead' property on 'MDWTableElement': Failed to convert value to 'MDWTHeadElement'.");
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
/**
|
|
102
|
+
* The table footer section (`mdw-tfoot`) element or `null` when not present.
|
|
103
|
+
*/
|
|
104
|
+
tFoot: {
|
|
105
|
+
get() {
|
|
106
|
+
return getByTagName(this, 'mdw-tfoot');
|
|
107
|
+
},
|
|
108
|
+
set(value) {
|
|
109
|
+
return setByTagName(this, 'mdw-tfoot', value, "Failed to set the 'tFoot' property on 'MDWTableElement': Failed to convert value to 'MDWTFootElement'.");
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Live `HTMLCollection` of `mdw-tbody` elements contained by the table.
|
|
114
|
+
* Mirrors `HTMLTableElement.tBodies`.
|
|
115
|
+
* @return {HTMLCollectionOf<Element>}
|
|
116
|
+
*/
|
|
117
|
+
tBodies() {
|
|
118
|
+
return this.getElementsByTagName('mdw-tbody');
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Live `HTMLCollection` of row elements (`mdw-tr`) in the table.
|
|
122
|
+
* Mirrors `HTMLTableElement.rows`.
|
|
123
|
+
* @return {HTMLCollectionOf<Element>}
|
|
124
|
+
*/
|
|
125
|
+
rows() {
|
|
126
|
+
return this.getElementsByTagName('mdw-tr');
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
.methods({
|
|
130
|
+
/** Create and return a `mdw-caption` element, appending when necessary. */
|
|
131
|
+
createCaption() { return createByTagName(this, 'mdw-caption'); },
|
|
132
|
+
/** Remove the table's caption element when present. */
|
|
133
|
+
deleteCaption() { return deleteByTagName(this, 'mdw-caption'); },
|
|
134
|
+
/** Create and return a `mdw-thead` element for the table. */
|
|
135
|
+
createTHead() { return createByTagName(this, 'mdw-thead'); },
|
|
136
|
+
/** Remove the table's `mdw-thead` element when present. */
|
|
137
|
+
deleteTHead() { return deleteByTagName(this, 'mdw-thead'); },
|
|
138
|
+
/** Create and return a `mdw-tfoot` element for the table. */
|
|
139
|
+
createTFoot() { return createByTagName(this, 'mdw-tfoot'); },
|
|
140
|
+
/** Remove the table's `mdw-tfoot` element when present. */
|
|
141
|
+
deleteTFoot() { return deleteByTagName(this, 'mdw-tfoot'); },
|
|
142
|
+
/** Insert and return a new `mdw-tbody` element before the tFoot (if any). */
|
|
143
|
+
createTBody() { return this.insertBefore(this.tFoot, document.createElement('mdw-tbody')); },
|
|
144
|
+
})
|
|
145
|
+
.html`<slot id=slot></slot>`
|
|
146
|
+
.css`
|
|
147
|
+
:host{
|
|
148
|
+
display:table;
|
|
149
|
+
}
|
|
150
|
+
`
|
|
151
|
+
.autoRegister('mdw-table');
|
package/components/TextArea.js
CHANGED
|
@@ -8,8 +8,11 @@ import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
|
8
8
|
const DOMString = { nullParser: String, value: '' };
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
+
* TextArea is a multi-line text input that auto-resizes and integrates with
|
|
12
|
+
* text-field patterns for labels and validation.
|
|
13
|
+
* implements {HTMLTextAreaElement}
|
|
14
|
+
* @see https://m3.material.io/components/text-fields/specs
|
|
11
15
|
* @see https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element
|
|
12
|
-
* -implements {HTMLTextAreaElement}
|
|
13
16
|
*/
|
|
14
17
|
export default CustomElement
|
|
15
18
|
.extend()
|
|
@@ -19,33 +22,52 @@ export default CustomElement
|
|
|
19
22
|
.mixin(TextFieldMixin)
|
|
20
23
|
.mixin(ResizeObserverMixin)
|
|
21
24
|
.set({
|
|
25
|
+
/** Whether the UA supports the `lh` CSS unit for line-height. */
|
|
22
26
|
supportsCSSLineHeightUnit: CSS.supports('height', '1lh'),
|
|
27
|
+
/** The control type used by the component. */
|
|
23
28
|
type: 'textarea',
|
|
29
|
+
/** Internal flag used while performing auto-resize logic. */
|
|
24
30
|
_resizing: false,
|
|
25
31
|
})
|
|
26
32
|
.overrides({
|
|
33
|
+
/** Tag name used for the native control element. */
|
|
27
34
|
controlTagName: 'textarea',
|
|
35
|
+
/** Textareas are not void elements. */
|
|
28
36
|
controlVoidElement: false,
|
|
29
37
|
})
|
|
30
38
|
.observe({
|
|
39
|
+
/** When true the textarea is fixed-size and will not auto-resize. */
|
|
31
40
|
fixed: { type: 'boolean' },
|
|
41
|
+
/** Minimum number of rows to display. Mirrors the `minrows` attribute. */
|
|
32
42
|
minRows: { attr: 'minrows', type: 'integer', nullable: false },
|
|
43
|
+
/** Maximum number of rows to allow when auto-resizing. */
|
|
33
44
|
maxRows: { attr: 'maxrows', type: 'integer', nullable: false },
|
|
45
|
+
/** Computed or measured line-height token used for resizing. */
|
|
34
46
|
_lineHeight: 'string',
|
|
47
|
+
/** Number of columns (characters) for the control (integer). */
|
|
35
48
|
cols: { type: 'integer', empty: 0 },
|
|
49
|
+
/** The `dirname` attribute value forwarded to the native control. */
|
|
36
50
|
dirName: { attr: 'dirname', ...DOMString },
|
|
51
|
+
/** Maximum allowed characters for the control. */
|
|
37
52
|
maxLength: { attr: 'maxlength', type: 'integer', empty: 0 },
|
|
53
|
+
/** Minimum required characters for the control. */
|
|
38
54
|
minLength: { attr: 'minlength', type: 'integer', empty: 0 },
|
|
55
|
+
/** Placeholder text forwarded to the native control. */
|
|
39
56
|
placeholder: DOMString,
|
|
57
|
+
/** Number of rows to render; updated when resizing. */
|
|
40
58
|
rows: { type: 'integer', empty: 1 },
|
|
59
|
+
/** Wrapping behavior token forwarded to the native control. */
|
|
41
60
|
wrap: DOMString,
|
|
42
61
|
// Not in spec, but plays nice with HTML linters
|
|
62
|
+
/** Forwards a `value` attribute to the internal `defaultValue`. */
|
|
43
63
|
defaultValueAttr: { attr: 'value', ...DOMString },
|
|
44
64
|
})
|
|
45
65
|
.define({
|
|
66
|
+
/** Return the underlying native `HTMLTextAreaElement` control. */
|
|
46
67
|
_textarea() { return /** @type {HTMLTextAreaElement} */ (this.refs.control); },
|
|
47
68
|
})
|
|
48
69
|
.define({
|
|
70
|
+
/** The default value (initial value) of the internal textarea. */
|
|
49
71
|
defaultValue: {
|
|
50
72
|
get() { return this._textarea.defaultValue; },
|
|
51
73
|
set(value) {
|
|
@@ -58,7 +80,9 @@ export default CustomElement
|
|
|
58
80
|
this.textContent = this._textarea.defaultValue;
|
|
59
81
|
},
|
|
60
82
|
},
|
|
83
|
+
/** Number of characters currently in the textarea. */
|
|
61
84
|
textLength() { return this._textarea.textLength; },
|
|
85
|
+
/** Focus + select helper forwarded to the native control. */
|
|
62
86
|
select() { return this._textarea.select; },
|
|
63
87
|
|
|
64
88
|
selectionDirection: {
|
|
@@ -76,12 +100,18 @@ export default CustomElement
|
|
|
76
100
|
set(value) { this._textarea.selectionEnd = value; },
|
|
77
101
|
},
|
|
78
102
|
|
|
103
|
+
/** Convenience passthrough to `HTMLTextAreaElement.setRangeText`. */
|
|
79
104
|
setRangeText() { return this._textarea.setRangeText; },
|
|
80
105
|
|
|
106
|
+
/** Convenience passthrough to `HTMLTextAreaElement.setSelectionRange`. */
|
|
81
107
|
setSelectionRange() { return this._textarea.setSelectionRange; },
|
|
82
108
|
|
|
83
109
|
})
|
|
84
110
|
.methods({
|
|
111
|
+
/**
|
|
112
|
+
* Resize the textarea to fit content up to `maxRows` and not below
|
|
113
|
+
* `minRows`. This updates the `rows` property and internal layout state.
|
|
114
|
+
*/
|
|
85
115
|
resize() {
|
|
86
116
|
if (this._resizing) return;
|
|
87
117
|
this._resizing = true;
|
|
@@ -135,9 +165,8 @@ export default CustomElement
|
|
|
135
165
|
this._resizing = false;
|
|
136
166
|
// if (this.placeholder) textarea.setAttribute('placeholder', this.placeholder);
|
|
137
167
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
onResizeObserved(entry) {
|
|
168
|
+
/** Called by the ResizeObserver mixin; triggers a resize unless active. */
|
|
169
|
+
onResizeObserved() {
|
|
141
170
|
if (this.matches(':active')) return;
|
|
142
171
|
this.resize();
|
|
143
172
|
},
|
|
@@ -167,19 +196,18 @@ export default CustomElement
|
|
|
167
196
|
},
|
|
168
197
|
},
|
|
169
198
|
})
|
|
199
|
+
.recompose(({ refs: { control } }) => {
|
|
200
|
+
// Spec
|
|
201
|
+
control.removeAttribute('placeholder');
|
|
202
|
+
control.setAttribute('rows', '{rows}');
|
|
203
|
+
|
|
204
|
+
// Custom
|
|
205
|
+
control.setAttribute('input-prefix', '{inputPrefix}');
|
|
206
|
+
control.setAttribute('input-suffix', '{inputSuffix}');
|
|
207
|
+
control.setAttribute('fixed', '{fixed}');
|
|
208
|
+
control.setAttribute('icon', '{icon}');
|
|
209
|
+
})
|
|
170
210
|
.on({
|
|
171
|
-
composed() {
|
|
172
|
-
const { control } = this.refs;
|
|
173
|
-
// Spec
|
|
174
|
-
control.removeAttribute('placeholder');
|
|
175
|
-
control.setAttribute('rows', '{rows}');
|
|
176
|
-
|
|
177
|
-
// Custom
|
|
178
|
-
control.setAttribute('input-prefix', '{inputPrefix}');
|
|
179
|
-
control.setAttribute('input-suffix', '{inputSuffix}');
|
|
180
|
-
control.setAttribute('fixed', '{fixed}');
|
|
181
|
-
control.setAttribute('icon', '{icon}');
|
|
182
|
-
},
|
|
183
211
|
defaultValueAttrChanged(oldValue, newValue) {
|
|
184
212
|
this.defaultValue = newValue;
|
|
185
213
|
},
|
|
@@ -286,6 +314,10 @@ export default CustomElement
|
|
|
286
314
|
max-block-size: calc((var(--max-rows) * var(--line-height)));
|
|
287
315
|
}
|
|
288
316
|
|
|
317
|
+
#icon {
|
|
318
|
+
margin-inline-end: 16px;
|
|
319
|
+
}
|
|
320
|
+
|
|
289
321
|
#control[icon] {
|
|
290
322
|
padding-inline-start: 0;
|
|
291
323
|
}
|
package/components/Title.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Display from './Display.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Material Design Type scale: Title.
|
|
5
|
+
* @see https://m3.material.io/styles/typography/type-scale-tokens
|
|
6
|
+
*/
|
|
7
|
+
export default Display
|
|
4
8
|
.extend()
|
|
5
|
-
.
|
|
6
|
-
|
|
7
|
-
if (ariaLevel) return ariaLevel;
|
|
8
|
-
if (size === 'medium') return '5';
|
|
9
|
-
if (size === 'small') return '6';
|
|
10
|
-
return '4';
|
|
11
|
-
},
|
|
9
|
+
.set({
|
|
10
|
+
_baseAriaLevel: 7,
|
|
12
11
|
})
|
|
13
12
|
.css`
|
|
14
13
|
:host {
|
package/components/Tooltip.js
CHANGED
|
@@ -1,62 +1,91 @@
|
|
|
1
|
+
import CustomElement from '../core/CustomElement.js';
|
|
1
2
|
import AriaReflectorMixin from '../mixins/AriaReflectorMixin.js';
|
|
3
|
+
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
4
|
+
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Tooltip displays brief helper text when hovering or focusing an element.
|
|
8
|
+
* @see https://m3.material.io/components/tooltips/specs
|
|
9
|
+
*/
|
|
10
|
+
export default CustomElement
|
|
6
11
|
.extend()
|
|
12
|
+
.mixin(ThemableMixin)
|
|
13
|
+
.mixin(ShapeMixin)
|
|
7
14
|
.mixin(AriaReflectorMixin)
|
|
8
15
|
.set({
|
|
16
|
+
/** ARIA role applied by the AriaReflectorMixin (defaults to `tooltip`). */
|
|
9
17
|
_ariaRole: 'tooltip',
|
|
10
18
|
})
|
|
11
19
|
.observe({
|
|
20
|
+
/**
|
|
21
|
+
* When true the tooltip is visible/open. This also updates ARIA
|
|
22
|
+
* `aria-hidden` for accessibility.
|
|
23
|
+
*/
|
|
12
24
|
open: {
|
|
13
25
|
type: 'boolean',
|
|
14
26
|
changedCallback(oldValue, newValue) {
|
|
15
27
|
this.updateAriaProperty('ariaHidden', newValue ? 'true' : 'false');
|
|
16
28
|
},
|
|
17
29
|
},
|
|
18
|
-
touch: 'boolean',
|
|
19
30
|
})
|
|
31
|
+
.html`
|
|
32
|
+
<div id=hover-target></div>
|
|
33
|
+
<slot id=slot></slot>
|
|
34
|
+
`
|
|
20
35
|
.css`
|
|
21
|
-
/* https://m2.material.io/components/tooltips */
|
|
22
|
-
|
|
23
36
|
:host {
|
|
24
37
|
--mdw-shape__size: var(--mdw-shape__extra-small);
|
|
25
|
-
--mdw-ink: var(--mdw-
|
|
26
|
-
--mdw-
|
|
38
|
+
--mdw-ink: var(--mdw-color__inverse-on-surface);
|
|
39
|
+
--mdw-bg: var(--mdw-color__inverse-surface);
|
|
27
40
|
display: block;
|
|
28
|
-
vertical-align: middle;
|
|
29
41
|
|
|
30
42
|
box-sizing: border-box;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
padding-block:
|
|
43
|
+
|
|
44
|
+
/* Ensure 24px min-height while keeping display:block */
|
|
45
|
+
padding-block: calc(12px - var(--mdw-typescale__body-small__line-height) / 2);
|
|
34
46
|
padding-inline: 8px;
|
|
35
47
|
|
|
36
48
|
pointer-events: none;
|
|
37
49
|
|
|
38
50
|
opacity: 0;
|
|
39
51
|
transform: scale(0);
|
|
40
|
-
z-index:
|
|
52
|
+
z-index: 28;
|
|
41
53
|
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
background-color: rgb(var(--mdw-bg));
|
|
55
|
+
color: rgb(var(--mdw-ink));
|
|
44
56
|
|
|
45
|
-
|
|
57
|
+
font: var(--mdw-typescale__body-small__font);
|
|
58
|
+
letter-spacing: var(--mdw-typescale__body-small__letter-spacing);
|
|
46
59
|
|
|
60
|
+
transition: transform 200ms, opacity 200ms;
|
|
47
61
|
}
|
|
48
62
|
|
|
49
|
-
:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
font: var(--mdw-typescale__label-large__font);
|
|
54
|
-
letter-spacing: var(--mdw-typescale__label-large__letter-spacing);
|
|
63
|
+
@supports(width: 1lh) {
|
|
64
|
+
:host {
|
|
65
|
+
padding-block: calc(12px - 0.5lh);
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
:host([open]) {
|
|
70
|
+
pointer-events: auto;
|
|
71
|
+
|
|
58
72
|
opacity: 1;
|
|
59
73
|
transform: scale(1);
|
|
60
74
|
}
|
|
75
|
+
|
|
76
|
+
#hover-target {
|
|
77
|
+
position: absolute;
|
|
78
|
+
inset-block-start: 50%;
|
|
79
|
+
inset-inline-start: 50%;
|
|
80
|
+
|
|
81
|
+
box-sizing: content-box;
|
|
82
|
+
block-size: 100%;
|
|
83
|
+
inline-size: 100%;
|
|
84
|
+
padding: 8px;
|
|
85
|
+
|
|
86
|
+
transform: translateX(-50%) translateY(-50%);
|
|
87
|
+
z-index: -1;
|
|
88
|
+
|
|
89
|
+
}
|
|
61
90
|
`
|
|
62
91
|
.autoRegister('mdw-tooltip');
|
package/components/TopAppBar.js
CHANGED
|
@@ -1,36 +1,62 @@
|
|
|
1
1
|
import CustomElement from '../core/CustomElement.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ELEMENT_ANIMATION_TYPE, ELEMENT_STYLE_TYPE } from '../core/customTypes.js';
|
|
3
3
|
import AriaToolbarMixin from '../mixins/AriaToolbarMixin.js';
|
|
4
|
+
import DelegatesFocusMixin from '../mixins/DelegatesFocusMixin.js';
|
|
4
5
|
import SemiStickyMixin from '../mixins/SemiStickyMixin.js';
|
|
5
6
|
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
6
|
-
import SurfaceMixin from '../mixins/SurfaceMixin.js';
|
|
7
7
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Top App Bars should have a background-color that is identical to
|
|
11
|
+
* `transparent`, though an explicit value allows updating the environment's
|
|
12
|
+
* to match the app bar (eg: color system bar).
|
|
13
|
+
*
|
|
14
|
+
* Top corners are shaped when not scrolling to allow matching with pane, but
|
|
15
|
+
* removed when raised
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Top app bar provides a consistent place for navigation and actions at the
|
|
20
|
+
* top of the screen. It supports small, medium, and large variants.
|
|
21
|
+
* @see https://m3.material.io/components/top-app-bar/specs
|
|
22
|
+
*/
|
|
9
23
|
export default CustomElement
|
|
10
24
|
.extend()
|
|
11
25
|
.mixin(ThemableMixin)
|
|
12
|
-
.mixin(SurfaceMixin)
|
|
13
26
|
.mixin(ShapeMixin)
|
|
14
27
|
.mixin(AriaToolbarMixin)
|
|
15
28
|
.mixin(SemiStickyMixin)
|
|
16
|
-
.
|
|
17
|
-
elevated: true,
|
|
18
|
-
})
|
|
29
|
+
.mixin(DelegatesFocusMixin)
|
|
19
30
|
.observe({
|
|
31
|
+
/** Whether the bar is currently raised/elevated (scrolled). */
|
|
20
32
|
_raised: 'boolean',
|
|
33
|
+
/** Headline opacity used when companion region is visible (0..1). */
|
|
21
34
|
_headlineOpacity: { type: 'float', default: 0 },
|
|
35
|
+
/** Headline text displayed in the center area. */
|
|
22
36
|
headline: 'string',
|
|
37
|
+
/** Size variant: 'small' | 'medium' | 'large' or `null` to auto-select. */
|
|
23
38
|
size: { value: /** @type {'small'|'medium'|'large'|null} */ (null) },
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.overrides({
|
|
29
|
-
_getSemiStickyElement() { return this.refs.surface; },
|
|
39
|
+
/** Color token name used for ink/background. */
|
|
40
|
+
color: 'string',
|
|
41
|
+
/** Color token to use when the bar is raised. */
|
|
42
|
+
raisedColor: 'string',
|
|
30
43
|
})
|
|
31
44
|
.observe({
|
|
45
|
+
/** Computed style tokens injected for raised-background when `raisedColor` is set. */
|
|
46
|
+
_styles: {
|
|
47
|
+
...ELEMENT_STYLE_TYPE,
|
|
48
|
+
get({ raisedColor }) {
|
|
49
|
+
if (raisedColor) {
|
|
50
|
+
return '#raised-background:where([raised])'
|
|
51
|
+
+ `{background-color:rgb(var(--mdw-color__${raisedColor}))`
|
|
52
|
+
+ '}';
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
/** Animation config for the headline element when companion is visible. */
|
|
32
58
|
_headlineStyle: {
|
|
33
|
-
...
|
|
59
|
+
...ELEMENT_ANIMATION_TYPE,
|
|
34
60
|
get({ size, _headlineOpacity }) {
|
|
35
61
|
if (size !== 'medium' && size !== 'large') return null;
|
|
36
62
|
return {
|
|
@@ -45,32 +71,25 @@ export default CustomElement
|
|
|
45
71
|
},
|
|
46
72
|
},
|
|
47
73
|
})
|
|
74
|
+
.expressions({
|
|
75
|
+
/** True when the companion region should be rendered (medium/large). */
|
|
76
|
+
_companionIf({ size }) {
|
|
77
|
+
return size === 'medium' || size === 'large';
|
|
78
|
+
},
|
|
79
|
+
})
|
|
48
80
|
.html`
|
|
81
|
+
<div id=raised-background raised={_raised}></div>
|
|
49
82
|
<slot id=leading name=leading on-slotchange={refreshTabIndexes}></slot>
|
|
50
83
|
<div id=headline ink={ink} color={color} type-style={typeStyle} on-slotchange={refreshTabIndexes}>
|
|
51
84
|
{headline}
|
|
52
85
|
<slot id=headline-slot></slot>
|
|
53
86
|
</div>
|
|
54
87
|
<slot id=trailing name=trailing on-slotchange={refreshTabIndexes}></slot>
|
|
55
|
-
<div mdw-if
|
|
88
|
+
<div mdw-if={_companionIf} id=companion aria-hidden=true size={size} color={color} raised={_raised}>
|
|
56
89
|
<slot id=companion-slot name=companion size={size}>{headline}</span>
|
|
57
90
|
</div>
|
|
58
91
|
`
|
|
59
92
|
.on({
|
|
60
|
-
composed({ inline }) {
|
|
61
|
-
const { surface, shape, leading, headline, trailing } = this.refs;
|
|
62
|
-
shape.append(leading, headline, trailing);
|
|
63
|
-
surface.append(shape);
|
|
64
|
-
surface.setAttribute('size', '{size}');
|
|
65
|
-
surface.setAttribute('role', 'toolbar');
|
|
66
|
-
surface.setAttribute('aria-label', '{ariaLabel}');
|
|
67
|
-
surface.setAttribute(
|
|
68
|
-
'aria-labelledby',
|
|
69
|
-
inline(({ ariaLabel }) => (ariaLabel ? null : 'headline')),
|
|
70
|
-
);
|
|
71
|
-
surface.setAttribute('raised', '{_raised}');
|
|
72
|
-
shape.setAttribute('raised', '{_raised}');
|
|
73
|
-
},
|
|
74
93
|
_scrollListenerPositionYChanged(oldValue, newValue) {
|
|
75
94
|
this._raised = (newValue > this._semiStickyOffsetY);
|
|
76
95
|
if (this.size === 'medium' || this.size === 'large') {
|
|
@@ -91,60 +110,20 @@ export default CustomElement
|
|
|
91
110
|
}
|
|
92
111
|
},
|
|
93
112
|
})
|
|
94
|
-
.define({
|
|
95
|
-
ariaActiveDescendantElement: {
|
|
96
|
-
get() {
|
|
97
|
-
// @ts-ignore Accessibility Object Model
|
|
98
|
-
return this.refs.surface.ariaActiveDescendantElement;
|
|
99
|
-
},
|
|
100
|
-
set(value) {
|
|
101
|
-
// @ts-ignore Accessibility Object Model
|
|
102
|
-
this.refs.surface.ariaActiveDescendantElement = value;
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
113
|
.css`
|
|
107
114
|
/* https://m3.material.io/components/bottom-app-bar/specs */
|
|
108
|
-
|
|
109
115
|
:host {
|
|
110
116
|
--mdw-bg: var(--mdw-color__surface);
|
|
111
117
|
--mdw-ink: var(--mdw-color__on-surface);
|
|
112
|
-
display: contents;
|
|
113
118
|
|
|
114
|
-
z-index:2;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
#surface {
|
|
118
119
|
position: sticky;
|
|
119
|
-
inset-block-
|
|
120
|
-
|
|
121
|
-
grid-area: app-bar;
|
|
122
|
-
|
|
123
|
-
margin: inherit; /** Pass through */
|
|
124
|
-
|
|
125
|
-
padding: inherit; /** Pass through */
|
|
126
|
-
|
|
127
|
-
filter: none; /* Never receive shadow */
|
|
128
|
-
|
|
129
|
-
transform: translateY(0);
|
|
130
|
-
|
|
131
|
-
z-index: 5;
|
|
132
|
-
|
|
133
|
-
background-color: rgb(var(--mdw-bg));
|
|
134
|
-
|
|
135
|
-
transition: grid-template-columns 100ms, background-color 100ms;
|
|
136
|
-
|
|
137
|
-
will-change: transform;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
#shape{
|
|
141
|
-
position: initial;
|
|
142
|
-
inset: initial;
|
|
120
|
+
inset-block-start: 0;
|
|
143
121
|
|
|
144
122
|
display: grid;
|
|
145
123
|
|
|
146
124
|
align-items: center;
|
|
147
125
|
gap: 12px;
|
|
126
|
+
|
|
148
127
|
grid-auto-flow: row;
|
|
149
128
|
grid-template-rows: minmax(64px,min-content);
|
|
150
129
|
grid-template-columns: minmax(auto,1fr) minmax(0,auto) minmax(auto,1fr);
|
|
@@ -152,8 +131,6 @@ export default CustomElement
|
|
|
152
131
|
overflow-y: visible;
|
|
153
132
|
|
|
154
133
|
box-sizing: border-box;
|
|
155
|
-
max-inline-size: calc(var(--mdw-content__max-width, 100%) + (2 * var(--mdw-content__padding, 16px) - 4px));
|
|
156
|
-
margin-inline: auto;
|
|
157
134
|
|
|
158
135
|
/* 16px from icon */
|
|
159
136
|
/* inset = (button.width / 2) - (icon.width / 2) */
|
|
@@ -161,15 +138,33 @@ export default CustomElement
|
|
|
161
138
|
/* paddingInlineStart = 16px - ((48px / 2) - (24px / 2)) */
|
|
162
139
|
/* paddingInlineEnd = 16px - ((48px / 2) - (30px / 2)) */
|
|
163
140
|
|
|
164
|
-
padding-inline:
|
|
141
|
+
padding-inline: var(--mdw-pane__padding-inline, 16px);
|
|
165
142
|
|
|
166
143
|
pointer-events: auto;
|
|
167
144
|
|
|
168
|
-
|
|
145
|
+
transform: translateY(0);
|
|
146
|
+
z-index: 5;
|
|
147
|
+
|
|
148
|
+
background-color: rgb(var(--mdw-bg));
|
|
149
|
+
color: rgb(var(--mdw-ink));
|
|
150
|
+
|
|
151
|
+
transition: grid-template-columns 100ms;
|
|
152
|
+
will-change: transform;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#raised-background {
|
|
156
|
+
position: absolute;
|
|
157
|
+
inset: 0;
|
|
158
|
+
|
|
159
|
+
z-index: -1;
|
|
169
160
|
|
|
170
161
|
background-color: transparent;
|
|
171
162
|
|
|
172
|
-
|
|
163
|
+
transition: background-color 200ms;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#raised-background:where([raised]) {
|
|
167
|
+
background-color: rgb(var(--mdw-color__surface-container));
|
|
173
168
|
}
|
|
174
169
|
|
|
175
170
|
#leading {
|
|
@@ -314,15 +309,13 @@ export default CustomElement
|
|
|
314
309
|
will-change: opacity;
|
|
315
310
|
}
|
|
316
311
|
|
|
317
|
-
|
|
312
|
+
:host(:where([color="none"], [color="transparent"])),
|
|
318
313
|
#companion:where([color="none"], [color="transparent"]) {
|
|
319
314
|
background-color: transparent;
|
|
320
315
|
}
|
|
321
316
|
|
|
322
|
-
#surface[raised]:where([color="surface"],[color="none"],[color="transparent"]),
|
|
323
317
|
#companion[raised]:where([color="surface"],[color="none"],[color="transparent"]) {
|
|
324
318
|
background-color: rgb(var(--mdw-color__surface-container));
|
|
325
319
|
}
|
|
326
|
-
|
|
327
320
|
`
|
|
328
321
|
.autoRegister('mdw-top-app-bar');
|