@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/mixins/TextFieldMixin.js
CHANGED
|
@@ -5,6 +5,7 @@ import ShapeMixin from './ShapeMixin.js';
|
|
|
5
5
|
/** @typedef {import('../core/CustomElement.js').default} CustomElement */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* Composes a text field with label, supporting text, icons and control wiring.
|
|
8
9
|
* @param {ReturnType<import('./ControlMixin.js').default>} Base
|
|
9
10
|
*/
|
|
10
11
|
export default function TextFieldMixin(Base) {
|
|
@@ -12,21 +13,38 @@ export default function TextFieldMixin(Base) {
|
|
|
12
13
|
.mixin(DensityMixin)
|
|
13
14
|
.mixin(ShapeMixin)
|
|
14
15
|
.set({
|
|
16
|
+
/** Show an internal visual state layer element */
|
|
15
17
|
stateLayer: true,
|
|
16
18
|
})
|
|
17
19
|
.observe({
|
|
20
|
+
/** Input type (text, password, email, etc.) */
|
|
18
21
|
type: { empty: 'text' },
|
|
22
|
+
/** Leading icon key/name to render inside the field */
|
|
19
23
|
icon: 'string',
|
|
24
|
+
/** Variation of the icon display (e.g., filled) */
|
|
25
|
+
iconVariation: 'string',
|
|
26
|
+
/** Floating label text for the field */
|
|
20
27
|
label: 'string',
|
|
28
|
+
/** When true, use filled styling */
|
|
21
29
|
filled: 'boolean',
|
|
30
|
+
/** When true, use outlined styling */
|
|
22
31
|
outlined: 'boolean',
|
|
32
|
+
/** Prefix text shown before the input */
|
|
23
33
|
inputPrefix: 'string',
|
|
34
|
+
/** Suffix text shown after the input */
|
|
24
35
|
inputSuffix: 'string',
|
|
36
|
+
/** Trailing icon key/name */
|
|
25
37
|
trailingIcon: 'string',
|
|
38
|
+
/** Ink/color token for the trailing icon */
|
|
26
39
|
trailingIconInk: 'string',
|
|
40
|
+
/** Accessible label for the trailing icon */
|
|
41
|
+
trailingIconLabel: 'string',
|
|
42
|
+
/** Supporting/helper text shown beneath the field */
|
|
27
43
|
supporting: 'string',
|
|
44
|
+
/** Error message text */
|
|
28
45
|
error: 'string',
|
|
29
|
-
|
|
46
|
+
/** Placeholder text (DOMString) */
|
|
47
|
+
placeholder: { nullParser: String },
|
|
30
48
|
})
|
|
31
49
|
.observe({
|
|
32
50
|
erroredState({ error, _invalid, _userInteracted }) { return _userInteracted && Boolean(error || _invalid); },
|
|
@@ -52,7 +70,27 @@ export default function TextFieldMixin(Base) {
|
|
|
52
70
|
return label && (filled || outlined);
|
|
53
71
|
},
|
|
54
72
|
})
|
|
73
|
+
.expressions({
|
|
74
|
+
_shapeShapeTop({ shapeTop, filled }) {
|
|
75
|
+
return shapeTop || filled;
|
|
76
|
+
},
|
|
77
|
+
computedIconVariation({ iconVariation, outlined }) {
|
|
78
|
+
return iconVariation ?? (outlined ? null : 'filled');
|
|
79
|
+
},
|
|
80
|
+
})
|
|
55
81
|
.html`
|
|
82
|
+
<div id=shape role=none filled={filled} icon={icon} trailing-icon={trailingIcon}
|
|
83
|
+
populated={populatedState} focused={focusedState} label={label} outlined={outlined}
|
|
84
|
+
shape-top={_shapeShapeTop}>
|
|
85
|
+
<mdw-icon mdw-if={icon} id=icon aria-hidden=true disabled={disabledState} icon={icon} variation={computedIconVariation}></mdw-icon>
|
|
86
|
+
<div id=inline role=none filled={filled} icon={icon} trailing-icon={trailingIcon}
|
|
87
|
+
populated={populatedState} focused={focusedState} label={label} outlined={outlined}>
|
|
88
|
+
<span mdw-if={inputPrefix} class=inline id=prefix aria-hidden=true focused={focusedState} populated={populatedState}>{inputPrefix}</span>
|
|
89
|
+
<span mdw-if={inputSuffix} class=inline id=suffix aria-hidden=true focused={focusedState} populated={populatedState}>{inputSuffix}</span>
|
|
90
|
+
</div>
|
|
91
|
+
<mdw-icon-button tabindex=-1 disabled={disabledState} mdw-if={trailingIcon} id=trailing-icon ink={trailingIconInk} disabled={disabledState} icon={trailingIcon}>{trailingIconLabel}</mdw-icon-button>
|
|
92
|
+
<div mdw-if={filled} id=indicator aria-hidden=true focused={focusedState} hovered={hoveredState} errored={erroredState} disabled={disabledState}></div>
|
|
93
|
+
</div>
|
|
56
94
|
<div id=label-text mdw-if={_showLabelText} aria-hidden=true
|
|
57
95
|
outlined={outlined}
|
|
58
96
|
populated={populatedState}
|
|
@@ -65,54 +103,37 @@ export default function TextFieldMixin(Base) {
|
|
|
65
103
|
{computeSupportingText}
|
|
66
104
|
<slot id=supporting-slot name=supporting></slot>
|
|
67
105
|
</div>
|
|
106
|
+
|
|
68
107
|
`
|
|
108
|
+
.recompose(({ html, refs: { control, outline, state, shape, inline } }) => {
|
|
109
|
+
control.setAttribute('placeholder', '{computePlaceholder}');
|
|
110
|
+
control.setAttribute('aria-label', '{label}');
|
|
111
|
+
control.setAttribute('input-suffix', '{inputSuffix}');
|
|
112
|
+
control.setAttribute('errored', '{erroredState}');
|
|
113
|
+
control.setAttribute('aria-describedby', 'supporting');
|
|
114
|
+
control.removeAttribute('aria-labelledby');
|
|
115
|
+
control.classList.add('inline');
|
|
116
|
+
|
|
117
|
+
state.setAttribute('mdw-if', '{!outlined}');
|
|
118
|
+
outline.append(html`
|
|
119
|
+
<div id=outline-left class=outline-section focused={focusedState}></div>
|
|
120
|
+
<div id=gap label={label} populated={populatedState} focused={focusedState}>
|
|
121
|
+
<div id=gap-slot focused={focusedState}></div>
|
|
122
|
+
<span id=gap-label>{label}</span>
|
|
123
|
+
</div>
|
|
124
|
+
<div id=outline-right class=outline-section focused={focusedState}></div>
|
|
125
|
+
`);
|
|
126
|
+
outline.setAttribute('label', '{label}');
|
|
127
|
+
outline.setAttribute('errored', '{erroredState}');
|
|
128
|
+
shape.prepend(outline, state);
|
|
129
|
+
inline.prepend(control);
|
|
130
|
+
})
|
|
69
131
|
.on({
|
|
70
|
-
|
|
71
|
-
const { control, outline, shape, outlineLeft, outlineRight, state } = this.refs;
|
|
72
|
-
control.setAttribute('placeholder', '{computePlaceholder}');
|
|
73
|
-
control.setAttribute('aria-label', '{label}');
|
|
74
|
-
control.setAttribute('input-suffix', '{inputSuffix}');
|
|
75
|
-
control.setAttribute('errored', '{erroredState}');
|
|
76
|
-
control.setAttribute('aria-describedby', 'supporting');
|
|
77
|
-
control.removeAttribute('aria-labelledby');
|
|
78
|
-
control.classList.add('inline');
|
|
79
|
-
|
|
80
|
-
state.setAttribute('mdw-if', '{!outlined}');
|
|
81
|
-
shape.setAttribute('role', 'none');
|
|
82
|
-
shape.setAttribute('filled', '{filled}');
|
|
83
|
-
shape.setAttribute('icon', '{icon}');
|
|
84
|
-
shape.setAttribute('trailingIcon', '{trailingIcon}');
|
|
85
|
-
shape.setAttribute('populated', '{populatedState}');
|
|
86
|
-
shape.setAttribute('focused', '{focusedState}');
|
|
87
|
-
shape.setAttribute('label', '{label}');
|
|
88
|
-
shape.setAttribute('shape-top', inline(({ shapeTop, filled }) => shapeTop || filled));
|
|
89
|
-
shape.append(
|
|
90
|
-
state,
|
|
91
|
-
outline,
|
|
92
|
-
control,
|
|
93
|
-
html`
|
|
94
|
-
<mdw-icon mdw-if={icon} id=icon aria-hidden=true disabled={disabledState}>{icon}</mdw-icon>
|
|
95
|
-
<span mdw-if={inputPrefix} class=inline id=prefix aria-hidden=true focused={focusedState} populated={populatedState}>{inputPrefix}</span>
|
|
96
|
-
<span mdw-if={inputSuffix} class=inline id=suffix aria-hidden=true focused={focusedState} populated={populatedState}>{inputSuffix}</span>
|
|
97
|
-
<mdw-icon mdw-if={trailingIcon} id=trailing-icon ink={trailingIconInk} aria-hidden=true disabled={disabledState}>{trailingIcon}</mdw-icon>
|
|
98
|
-
<div mdw-if={filled} id=indicator aria-hidden=true focused={focusedState} hovered={hoveredState} errored={erroredState} disabled={disabledState}></div>
|
|
99
|
-
`,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
outline.setAttribute('label', '{label}');
|
|
103
|
-
outline.setAttribute('errored', '{erroredState}');
|
|
104
|
-
outlineLeft.after(html`
|
|
105
|
-
<div id=gap mdw-if={label} label={label} populated={populatedState} focused={focusedState}>
|
|
106
|
-
<div id=gap-slot focused={focusedState}></div>
|
|
107
|
-
<span id=gap-label>{label}</span>
|
|
108
|
-
</div>
|
|
109
|
-
`);
|
|
110
|
-
|
|
111
|
-
outlineLeft.setAttribute('focused', '{focusedState}');
|
|
112
|
-
outlineRight.setAttribute('focused', '{focusedState}');
|
|
113
|
-
},
|
|
132
|
+
// @ts-ignore TODO: Missing observable size property
|
|
114
133
|
sizeChanged(oldValue, newValue) {
|
|
115
|
-
|
|
134
|
+
// @ts-ignore TODO: Missing {this} context
|
|
135
|
+
const control = /** @type {HTMLElement} */ (this.refs.control);
|
|
136
|
+
control.style.setProperty('--size', `${newValue}ch`);
|
|
116
137
|
},
|
|
117
138
|
})
|
|
118
139
|
.css`
|
|
@@ -163,6 +184,8 @@ export default function TextFieldMixin(Base) {
|
|
|
163
184
|
|
|
164
185
|
display: inline-block;
|
|
165
186
|
|
|
187
|
+
border-radius: 0;
|
|
188
|
+
|
|
166
189
|
/* State layer */
|
|
167
190
|
color: rgb(var(--mdw-color__on-surface));
|
|
168
191
|
|
|
@@ -170,14 +193,6 @@ export default function TextFieldMixin(Base) {
|
|
|
170
193
|
letter-spacing: var(--mdw-type__letter-spacing);
|
|
171
194
|
}
|
|
172
195
|
|
|
173
|
-
:host([icon]) {
|
|
174
|
-
--padding-inline-start: 12px;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
:host([trailing-icon]) {
|
|
178
|
-
--padding-inline-end: 12px;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
196
|
:host(:is([color], [ink])) {
|
|
182
197
|
background-color: transparent;
|
|
183
198
|
color: rgb(var(--mdw-color__on-surface));
|
|
@@ -189,7 +204,6 @@ export default function TextFieldMixin(Base) {
|
|
|
189
204
|
--mdw-shape__size__bottom-start-size: min(var(--mdw-shape__size), 12px);
|
|
190
205
|
--mdw-shape__size__top-end-size: min(var(--mdw-shape__size), 12px);
|
|
191
206
|
--mdw-shape__size__bottom-end-size: min(var(--mdw-shape__size), 12px);
|
|
192
|
-
-webkit-mask-box-image-width: min(var(--mdw-shape__size), 12px);
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
#shape {
|
|
@@ -197,15 +211,17 @@ export default function TextFieldMixin(Base) {
|
|
|
197
211
|
|
|
198
212
|
display: flex;
|
|
199
213
|
|
|
200
|
-
align-items: center;
|
|
201
|
-
overflow: visible;
|
|
202
|
-
|
|
203
214
|
cursor: inherit;
|
|
204
215
|
|
|
205
216
|
z-index: 0;
|
|
206
217
|
|
|
207
218
|
background-color: transparent;
|
|
208
219
|
|
|
220
|
+
border-start-start-radius: calc(var(--mdw-shape__size__top-start-size));
|
|
221
|
+
border-start-end-radius: calc(var(--mdw-shape__size__top-end-size));
|
|
222
|
+
border-end-start-radius: calc(var(--mdw-shape__size__bottom-start-size));
|
|
223
|
+
border-end-end-radius: calc(var(--mdw-shape__size__bottom-end-size));
|
|
224
|
+
|
|
209
225
|
font-weight: inherit;
|
|
210
226
|
font-size: inherit;
|
|
211
227
|
line-height: inherit;
|
|
@@ -215,10 +231,28 @@ export default function TextFieldMixin(Base) {
|
|
|
215
231
|
transition: none 200ms cubic-bezier(0.0, 0.0, 0.2, 1);
|
|
216
232
|
}
|
|
217
233
|
|
|
218
|
-
#
|
|
219
|
-
|
|
234
|
+
#inline {
|
|
235
|
+
display: flex;
|
|
236
|
+
|
|
237
|
+
align-items: center;
|
|
238
|
+
overflow: visible;
|
|
239
|
+
|
|
240
|
+
flex: 1;
|
|
241
|
+
padding-block: var(--control__margin-top) var(--control__margin-bottom);
|
|
242
|
+
|
|
243
|
+
cursor: inherit;
|
|
244
|
+
|
|
245
|
+
font-weight: inherit;
|
|
246
|
+
font-size: inherit;
|
|
247
|
+
line-height: inherit;
|
|
248
|
+
font-family: inherit;
|
|
249
|
+
letter-spacing: inherit;
|
|
250
|
+
|
|
251
|
+
transition: none 200ms cubic-bezier(0.0, 0.0, 0.2, 1);
|
|
220
252
|
}
|
|
221
253
|
|
|
254
|
+
|
|
255
|
+
|
|
222
256
|
#shape:where([filled],[color]) {
|
|
223
257
|
background-color: rgb(var(--mdw-bg));
|
|
224
258
|
color: rgb(var(--mdw-color__on-surface));
|
|
@@ -237,14 +271,6 @@ export default function TextFieldMixin(Base) {
|
|
|
237
271
|
color: rgb(var(--mdw-ink))
|
|
238
272
|
}
|
|
239
273
|
|
|
240
|
-
#shape:where([filled],[outlined])[icon] {
|
|
241
|
-
padding-inline-start: 12px;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
#shape[trailing-icon] {
|
|
245
|
-
padding-inline-end: 12px;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
274
|
#shape[focused] {
|
|
249
275
|
transition: none 100ms cubic-bezier(0.4, 0.0, 1, 1);
|
|
250
276
|
}
|
|
@@ -252,7 +278,6 @@ export default function TextFieldMixin(Base) {
|
|
|
252
278
|
#shape[shape-top] {
|
|
253
279
|
--mdw-shape__size__bottom-start-size: 0px;
|
|
254
280
|
--mdw-shape__size__bottom-end-size: 0px;
|
|
255
|
-
--mdw-shape__mask: linear-gradient(transparent 50%, black 50%);
|
|
256
281
|
}
|
|
257
282
|
|
|
258
283
|
#prefix,
|
|
@@ -277,16 +302,15 @@ export default function TextFieldMixin(Base) {
|
|
|
277
302
|
inset: auto;
|
|
278
303
|
align-self: flex-start;
|
|
279
304
|
|
|
280
|
-
display: inline;
|
|
305
|
+
display: inline-block;
|
|
281
306
|
|
|
282
307
|
box-sizing: border-box;
|
|
283
308
|
|
|
284
309
|
block-size: auto;
|
|
285
|
-
min-block-size:
|
|
310
|
+
min-block-size: 0;
|
|
286
311
|
inline-size: 100%;
|
|
287
|
-
min-inline-size:
|
|
312
|
+
min-inline-size: 0;
|
|
288
313
|
flex: 1;
|
|
289
|
-
border-block-start: solid var(--control__margin-top) transparent;
|
|
290
314
|
border-block-end: solid var(--control__margin-bottom) transparent;
|
|
291
315
|
padding-block: var(--control__padding-top) var(--control__padding-bottom);
|
|
292
316
|
|
|
@@ -296,7 +320,7 @@ export default function TextFieldMixin(Base) {
|
|
|
296
320
|
|
|
297
321
|
transform: none;
|
|
298
322
|
|
|
299
|
-
visibility:
|
|
323
|
+
visibility: inherit;
|
|
300
324
|
|
|
301
325
|
background-color: transparent;
|
|
302
326
|
border-color: transparent;
|
|
@@ -308,6 +332,7 @@ export default function TextFieldMixin(Base) {
|
|
|
308
332
|
line-height: inherit;
|
|
309
333
|
font-family: inherit;
|
|
310
334
|
letter-spacing: inherit;
|
|
335
|
+
text-align: initial;
|
|
311
336
|
|
|
312
337
|
transition-duration: inherit;
|
|
313
338
|
transition-property: color;
|
|
@@ -317,7 +342,6 @@ export default function TextFieldMixin(Base) {
|
|
|
317
342
|
#suffix,
|
|
318
343
|
#prefix {
|
|
319
344
|
/* Symmetrical to allow centering */
|
|
320
|
-
margin-block: var(--control__margin-top) var(--control__margin-bottom);
|
|
321
345
|
padding-block: var(--control__padding-top) var(--control__padding-bottom);
|
|
322
346
|
}
|
|
323
347
|
|
|
@@ -342,7 +366,7 @@ export default function TextFieldMixin(Base) {
|
|
|
342
366
|
#icon {
|
|
343
367
|
order: -2;
|
|
344
368
|
|
|
345
|
-
margin-inline-
|
|
369
|
+
margin-inline-start: 12px;
|
|
346
370
|
|
|
347
371
|
font-size: 24px;
|
|
348
372
|
}
|
|
@@ -358,7 +382,8 @@ export default function TextFieldMixin(Base) {
|
|
|
358
382
|
#trailing-icon {
|
|
359
383
|
order: 2;
|
|
360
384
|
|
|
361
|
-
|
|
385
|
+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
386
|
+
margin-inline-end: 12px;
|
|
362
387
|
}
|
|
363
388
|
|
|
364
389
|
#indicator {
|
|
@@ -465,6 +490,31 @@ export default function TextFieldMixin(Base) {
|
|
|
465
490
|
|
|
466
491
|
/** Outlined **/
|
|
467
492
|
|
|
493
|
+
#outline {
|
|
494
|
+
position: absolute;
|
|
495
|
+
inset: 0;
|
|
496
|
+
|
|
497
|
+
border-style: solid;
|
|
498
|
+
border-width: 0px;
|
|
499
|
+
|
|
500
|
+
pointer-events: none;
|
|
501
|
+
|
|
502
|
+
border-color: currentColor;
|
|
503
|
+
border-radius: inherit;
|
|
504
|
+
color: rgb(var(--mdw-color__outline));
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
#outline:is([pressed],[focused]) {
|
|
508
|
+
color: rgb(var(--mdw-ink));
|
|
509
|
+
|
|
510
|
+
transition-delay: 0;
|
|
511
|
+
transition-duration: 0;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
#outline[disabled] {
|
|
515
|
+
color: rgba(var(--mdw-color__on-surface), 0.12);
|
|
516
|
+
}
|
|
517
|
+
|
|
468
518
|
#outline::before {
|
|
469
519
|
content: none;
|
|
470
520
|
}
|
|
@@ -601,73 +651,6 @@ export default function TextFieldMixin(Base) {
|
|
|
601
651
|
border-block-start-width: 2px;
|
|
602
652
|
}
|
|
603
653
|
|
|
604
|
-
@supports(-webkit-mask-box-image: none) {
|
|
605
|
-
#outline[focused] {
|
|
606
|
-
/** Fake 2px outline */
|
|
607
|
-
filter:
|
|
608
|
-
drop-shadow(1px 0px 0px currentColor)
|
|
609
|
-
drop-shadow(0px 1px 0px currentColor)
|
|
610
|
-
drop-shadow(-1px 0px 0px currentColor)
|
|
611
|
-
drop-shadow(0px -1px 0px currentColor);
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
#outline::before {
|
|
615
|
-
content: '';
|
|
616
|
-
|
|
617
|
-
position: absolute;
|
|
618
|
-
inset: 0;
|
|
619
|
-
|
|
620
|
-
grid-column: calc(2 - var(--mdw-dir, 1)) / span 1;
|
|
621
|
-
/* stylelint-disable-next-line liberty/use-logical-spec */
|
|
622
|
-
margin-right: -0.99px;
|
|
623
|
-
border: none;
|
|
624
|
-
|
|
625
|
-
background-color: currentColor;
|
|
626
|
-
-webkit-mask-box-image: var(--mdw-shape__mask-image__edges)
|
|
627
|
-
8 fill /
|
|
628
|
-
auto
|
|
629
|
-
stretch;
|
|
630
|
-
-webkit-mask-box-image-width: auto 0 auto auto;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
#outline::after {
|
|
634
|
-
grid-column: calc(2 + var(--mdw-dir, 1)) / span 1;
|
|
635
|
-
grid-row: 1;
|
|
636
|
-
|
|
637
|
-
/* stylelint-disable-next-line liberty/use-logical-spec */
|
|
638
|
-
margin-left: -0.99px;
|
|
639
|
-
-webkit-mask-box-image-width: auto auto auto 0;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
.outline-section {
|
|
643
|
-
border: none;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
#gap::after {
|
|
647
|
-
border: none;
|
|
648
|
-
|
|
649
|
-
background-color: currentColor;
|
|
650
|
-
-webkit-mask-box-image: var(--mdw-shape__mask-image__edges)
|
|
651
|
-
8 fill /
|
|
652
|
-
auto
|
|
653
|
-
stretch;
|
|
654
|
-
-webkit-mask-box-image-width: 0 0 auto 0;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
#gap-slot::before,
|
|
658
|
-
#gap-slot::after {
|
|
659
|
-
border: none;
|
|
660
|
-
|
|
661
|
-
background-color: currentColor;
|
|
662
|
-
|
|
663
|
-
-webkit-mask-box-image: var(--mdw-shape__mask-image__edges)
|
|
664
|
-
8 fill /
|
|
665
|
-
auto
|
|
666
|
-
stretch;
|
|
667
|
-
-webkit-mask-box-image-width: auto 0 0 0;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
654
|
#gap-slot::before {
|
|
672
655
|
/* stylelint-disable-next-line liberty/use-logical-spec */
|
|
673
656
|
margin-right: -0.99px;
|
|
@@ -693,7 +676,7 @@ export default function TextFieldMixin(Base) {
|
|
|
693
676
|
padding: 0;
|
|
694
677
|
}
|
|
695
678
|
|
|
696
|
-
#
|
|
679
|
+
#inline[label][filled] {
|
|
697
680
|
align-items: flex-start;
|
|
698
681
|
}
|
|
699
682
|
|
package/mixins/ThemableMixin.js
CHANGED
|
@@ -1,24 +1,67 @@
|
|
|
1
|
+
import { PALETTES, TYPE_STYLES } from '../services/theme.js';
|
|
2
|
+
|
|
3
|
+
const colorAttributeCSS = PALETTES.map((palette) => [
|
|
4
|
+
`:host([color="${palette}"]){`,
|
|
5
|
+
`--mdw-bg: var(--mdw-color__${palette});`,
|
|
6
|
+
`--mdw-ink: var(--mdw-color__on-${palette});`,
|
|
7
|
+
'}',
|
|
8
|
+
`:host([color="${palette}-container"]){`,
|
|
9
|
+
`--mdw-bg: var(--mdw-color__${palette}-container);`,
|
|
10
|
+
`--mdw-ink: var(--mdw-color__on-${palette}-container);`,
|
|
11
|
+
'}',
|
|
12
|
+
].join('')).join('');
|
|
13
|
+
|
|
14
|
+
const inkAttributeCSS = PALETTES.map((palette) => [
|
|
15
|
+
`:host([ink="${palette}"]){`,
|
|
16
|
+
`--mdw-ink: var(--mdw-color__${palette});`,
|
|
17
|
+
'}',
|
|
18
|
+
`:host([ink="on-${palette}"]){`,
|
|
19
|
+
`--mdw-ink: var(--mdw-color__on-${palette});`,
|
|
20
|
+
'}',
|
|
21
|
+
`:host([ink="on-${palette}-container"]){`,
|
|
22
|
+
`--mdw-ink: var(--mdw-color__on-${palette}-container);`,
|
|
23
|
+
'}',
|
|
24
|
+
].join('')).join('');
|
|
25
|
+
|
|
26
|
+
const typeStyleAttributeCSS = TYPE_STYLES.map((typeStyle) => [
|
|
27
|
+
`:host([type-style|="${typeStyle}"]) {`,
|
|
28
|
+
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-large__font);`,
|
|
29
|
+
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-large__letter-spacing);`,
|
|
30
|
+
'}',
|
|
31
|
+
`:host([type-style="${typeStyle}-medium"]) {`,
|
|
32
|
+
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-medium__font);`,
|
|
33
|
+
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-medium__letter-spacing);`,
|
|
34
|
+
'}',
|
|
35
|
+
`:host([type-style="${typeStyle}-small"]) {`,
|
|
36
|
+
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-small__font);`,
|
|
37
|
+
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-small__letter-spacing);`,
|
|
38
|
+
'}',
|
|
39
|
+
].join('')).join('');
|
|
40
|
+
|
|
1
41
|
/**
|
|
42
|
+
* Adds theming attributes (`color`, `ink`, `typeStyle`) that map to CSS tokens.
|
|
2
43
|
* @param {typeof import('../core/CustomElement.js').default} Base
|
|
3
44
|
*/
|
|
4
45
|
export default function ThemableMixin(Base) {
|
|
5
46
|
return Base
|
|
6
47
|
.observe({
|
|
48
|
+
/**
|
|
49
|
+
* Palette or surface token used to select background/ink tokens.
|
|
50
|
+
* Examples: 'primary', 'background', 'surface-container-low'.
|
|
51
|
+
*/
|
|
7
52
|
color: 'string',
|
|
53
|
+
/**
|
|
54
|
+
* Explicit ink override token (e.g. 'outline', 'on-primary', 'inverse-on-surface', 'inherit').
|
|
55
|
+
* Maps to `--mdw-ink`.
|
|
56
|
+
*/
|
|
8
57
|
ink: 'string',
|
|
58
|
+
/**
|
|
59
|
+
* Typographic style shortcut that maps to type scale variables
|
|
60
|
+
* (e.g. 'headline-large', 'body-medium').
|
|
61
|
+
*/
|
|
9
62
|
typeStyle: 'string',
|
|
10
63
|
})
|
|
11
|
-
.css
|
|
12
|
-
ThemableMixin.PALETTES.map((palette) => [
|
|
13
|
-
`:host([color="${palette}"]){`,
|
|
14
|
-
`--mdw-bg: var(--mdw-color__${palette});`,
|
|
15
|
-
`--mdw-ink: var(--mdw-color__on-${palette});`,
|
|
16
|
-
'}',
|
|
17
|
-
`:host([color="${palette}-container"]){`,
|
|
18
|
-
`--mdw-bg: var(--mdw-color__${palette}-container);`,
|
|
19
|
-
`--mdw-ink: var(--mdw-color__on-${palette}-container);`,
|
|
20
|
-
'}',
|
|
21
|
-
].join('')).join('')}`
|
|
64
|
+
.css(colorAttributeCSS)
|
|
22
65
|
.css`
|
|
23
66
|
:host([color="background"]) {
|
|
24
67
|
--mdw-bg: var(--mdw-color__background);
|
|
@@ -51,6 +94,7 @@ export default function ThemableMixin(Base) {
|
|
|
51
94
|
|
|
52
95
|
/* Quality-of-life */
|
|
53
96
|
:host([color="surface-primary"]) {
|
|
97
|
+
--mdw-bg: var(--mdw-color__surface);
|
|
54
98
|
--mdw-ink: var(--mdw-color__primary);
|
|
55
99
|
}
|
|
56
100
|
|
|
@@ -67,21 +111,8 @@ export default function ThemableMixin(Base) {
|
|
|
67
111
|
:host([color="inverse-primary"]) {
|
|
68
112
|
--mdw-ink: var(--mdw-color__inverse-primary);
|
|
69
113
|
}
|
|
70
|
-
|
|
71
|
-
:host([color][disabled]) {
|
|
72
|
-
/* background-color: rgba(var(--mdw-color__on-surface), 0.12); */
|
|
73
|
-
/* color: rgba(var(--mdw-color__on-surface), 0.38); */
|
|
74
|
-
}
|
|
75
114
|
`
|
|
76
|
-
.css
|
|
77
|
-
ThemableMixin.PALETTES.map((palette) => [
|
|
78
|
-
`:host([ink="${palette}"]){`,
|
|
79
|
-
`--mdw-ink: var(--mdw-color__${palette});`,
|
|
80
|
-
'}',
|
|
81
|
-
`:host([ink="on-${palette}-container"]){`,
|
|
82
|
-
`--mdw-ink: var(--mdw-color__on-${palette}-container);`,
|
|
83
|
-
'}',
|
|
84
|
-
].join('')).join('')}`
|
|
115
|
+
.css(inkAttributeCSS)
|
|
85
116
|
.css`
|
|
86
117
|
:host([ink="inverse-primary"]) {
|
|
87
118
|
--mdw-ink: var(--mdw-color__inverse-primary);
|
|
@@ -107,35 +138,5 @@ export default function ThemableMixin(Base) {
|
|
|
107
138
|
--mdw-ink: inherit;
|
|
108
139
|
}
|
|
109
140
|
`
|
|
110
|
-
.css
|
|
111
|
-
ThemableMixin.TYPE_STYLES.map((typeStyle) => [
|
|
112
|
-
`:host([type-style|="${typeStyle}"]) {`,
|
|
113
|
-
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-large__font);`,
|
|
114
|
-
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-large__letter-spacing);`,
|
|
115
|
-
'}',
|
|
116
|
-
`:host([type-style="${typeStyle}-medium"]) {`,
|
|
117
|
-
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-medium__font);`,
|
|
118
|
-
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-medium__letter-spacing);`,
|
|
119
|
-
'}',
|
|
120
|
-
`:host([type-style="${typeStyle}-small"]) {`,
|
|
121
|
-
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-small__font);`,
|
|
122
|
-
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-small__letter-spacing);`,
|
|
123
|
-
'}',
|
|
124
|
-
].join(''))}`;
|
|
141
|
+
.css(typeStyleAttributeCSS);
|
|
125
142
|
}
|
|
126
|
-
|
|
127
|
-
ThemableMixin.PALETTES = [
|
|
128
|
-
'primary',
|
|
129
|
-
'secondary',
|
|
130
|
-
'tertiary',
|
|
131
|
-
'error',
|
|
132
|
-
'surface',
|
|
133
|
-
];
|
|
134
|
-
|
|
135
|
-
ThemableMixin.TYPE_STYLES = [
|
|
136
|
-
'display',
|
|
137
|
-
'headline',
|
|
138
|
-
'title',
|
|
139
|
-
'label',
|
|
140
|
-
'body',
|
|
141
|
-
];
|