@shortfuse/materialdesignweb 0.7.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -90
- package/bin/mdw-css.js +1 -1
- package/components/Badge.js +14 -7
- package/components/Body.js +3 -0
- package/components/BottomAppBar.js +4 -13
- package/components/BottomSheet.js +424 -0
- package/components/Box.js +20 -28
- package/components/Button.js +85 -79
- package/components/Button.md +9 -9
- package/components/Card.js +60 -72
- package/components/Checkbox.js +33 -42
- package/components/CheckboxIcon.js +11 -29
- package/components/Chip.js +13 -11
- package/components/Dialog.js +214 -394
- package/components/DialogActions.js +2 -2
- package/components/Display.js +55 -0
- package/components/Divider.js +3 -3
- package/components/Fab.js +83 -18
- package/components/FabContainer.js +48 -0
- package/components/FilterChip.js +35 -33
- package/components/Grid.js +176 -0
- package/components/Headline.js +5 -28
- package/components/Icon.js +61 -76
- package/components/IconButton.js +72 -126
- package/components/Input.js +859 -1
- package/components/InputChip.js +161 -0
- package/components/Label.js +3 -0
- package/components/List.js +4 -6
- package/components/ListItem.js +46 -30
- package/components/ListOption.js +86 -53
- package/components/Listbox.js +248 -0
- package/components/Menu.js +69 -528
- package/components/MenuItem.js +33 -36
- package/components/NavBar.js +49 -86
- package/components/NavDrawer.js +16 -15
- package/components/NavDrawerItem.js +4 -5
- package/components/NavItem.js +58 -41
- package/components/NavRail.js +30 -20
- package/components/NavRailItem.js +8 -3
- package/components/Page.js +105 -0
- package/components/Pane.js +11 -274
- package/components/Popup.js +29 -0
- package/components/Progress.js +24 -23
- package/components/Radio.js +40 -36
- package/components/RadioIcon.js +12 -16
- package/components/Ripple.js +13 -10
- package/components/Root.js +209 -0
- package/components/Scrim.js +87 -0
- package/components/Search.js +77 -0
- package/components/SegmentedButton.js +33 -45
- package/components/SegmentedButtonGroup.js +25 -13
- package/components/Select.js +10 -11
- package/components/Shape.js +5 -65
- package/components/SideSheet.js +308 -0
- package/components/Slider.js +108 -78
- package/components/Snackbar.js +26 -21
- package/components/SnackbarContainer.js +42 -0
- package/components/Surface.js +17 -12
- package/components/Switch.js +45 -24
- package/components/SwitchIcon.js +49 -39
- package/components/Tab.js +64 -43
- package/components/TabContent.js +5 -3
- package/components/TabList.js +62 -34
- package/components/TabPanel.js +11 -8
- package/components/Table.js +116 -0
- package/components/TextArea.js +54 -50
- package/components/Title.js +4 -9
- package/components/Tooltip.js +44 -22
- package/components/TopAppBar.js +68 -172
- package/constants/shapes.js +36 -0
- package/constants/typography.js +127 -0
- package/core/Composition.js +1164 -645
- package/core/CompositionAdapter.js +314 -0
- package/core/CustomElement.js +701 -286
- package/core/css.js +121 -15
- package/core/customTypes.js +157 -40
- package/core/dom.js +17 -11
- package/{utils → core}/jsonMergePatch.js +42 -18
- package/core/observe.js +343 -244
- package/core/optimizations.js +23 -0
- package/core/template.js +19 -56
- package/core/uid.js +13 -0
- package/dist/index.min.js +85 -184
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +106 -0
- package/loaders/palette.js +13 -0
- package/loaders/theme.js +12 -0
- package/mixins/AriaReflectorMixin.js +53 -14
- package/mixins/AriaToolbarMixin.js +5 -3
- package/mixins/ControlMixin.js +92 -41
- package/mixins/DelegatesFocusMixin.js +54 -0
- package/mixins/DensityMixin.js +2 -3
- package/mixins/ElevationMixin.js +62 -0
- package/mixins/FlexableMixin.js +67 -39
- package/mixins/FormAssociatedMixin.js +71 -16
- package/mixins/HyperlinkMixin.js +66 -0
- package/mixins/InputMixin.js +205 -39
- package/mixins/KeyboardNavMixin.js +22 -7
- package/mixins/NavigationListenerMixin.js +33 -0
- package/mixins/PopupMixin.js +725 -0
- package/mixins/RTLObserverMixin.js +0 -1
- package/mixins/ResizeObserverMixin.js +16 -5
- package/mixins/RippleMixin.js +11 -10
- package/mixins/ScrollListenerMixin.js +42 -33
- package/mixins/SemiStickyMixin.js +97 -0
- package/mixins/ShapeMaskedMixin.js +117 -0
- package/mixins/ShapeMixin.js +17 -194
- package/mixins/StateMixin.js +80 -39
- package/mixins/TextFieldMixin.js +139 -183
- package/mixins/ThemableMixin.js +71 -161
- package/mixins/TooltipTriggerMixin.js +292 -366
- package/mixins/TouchTargetMixin.js +5 -4
- package/mixins/TypographyMixin.js +121 -0
- package/package.json +111 -71
- package/services/rtl.js +10 -0
- package/services/svgAlias.js +17 -0
- package/{theming/index.js → services/theme.js} +25 -175
- package/types/bin/mdw-css.d.ts +3 -0
- package/types/bin/mdw-css.d.ts.map +1 -0
- package/types/components/Badge.d.ts +39 -0
- package/types/components/Badge.d.ts.map +1 -0
- package/types/components/Body.d.ts +29 -0
- package/types/components/Body.d.ts.map +1 -0
- package/types/components/BottomAppBar.d.ts +73 -0
- package/types/components/BottomAppBar.d.ts.map +1 -0
- package/types/components/BottomSheet.d.ts +109 -0
- package/types/components/BottomSheet.d.ts.map +1 -0
- package/types/components/Box.d.ts +16 -0
- package/types/components/Box.d.ts.map +1 -0
- package/types/components/Button.d.ts +714 -0
- package/types/components/Button.d.ts.map +1 -0
- package/types/components/Card.d.ts +412 -0
- package/types/components/Card.d.ts.map +1 -0
- package/types/components/Checkbox.d.ts +205 -0
- package/types/components/Checkbox.d.ts.map +1 -0
- package/types/components/CheckboxIcon.d.ts +44 -0
- package/types/components/CheckboxIcon.d.ts.map +1 -0
- package/types/components/Chip.d.ts +1425 -0
- package/types/components/Chip.d.ts.map +1 -0
- package/types/components/Dialog.d.ts +286 -0
- package/types/components/Dialog.d.ts.map +1 -0
- package/types/components/DialogActions.d.ts +4 -0
- package/types/components/DialogActions.d.ts.map +1 -0
- package/types/components/Display.d.ts +45 -0
- package/types/components/Display.d.ts.map +1 -0
- package/types/components/Divider.d.ts +10 -0
- package/types/components/Divider.d.ts.map +1 -0
- package/types/components/Fab.d.ts +741 -0
- package/types/components/Fab.d.ts.map +1 -0
- package/types/components/FabContainer.d.ts +10 -0
- package/types/components/FabContainer.d.ts.map +1 -0
- package/types/components/FilterChip.d.ts +4283 -0
- package/types/components/FilterChip.d.ts.map +1 -0
- package/types/components/Grid.d.ts +37 -0
- package/types/components/Grid.d.ts.map +1 -0
- package/types/components/Headline.d.ts +47 -0
- package/types/components/Headline.d.ts.map +1 -0
- package/types/components/Icon.d.ts +103 -0
- package/types/components/Icon.d.ts.map +1 -0
- package/types/components/IconButton.d.ts +1486 -0
- package/types/components/IconButton.d.ts.map +1 -0
- package/types/components/Input.d.ts +51288 -0
- package/types/components/Input.d.ts.map +1 -0
- package/types/components/InputChip.d.ts +243 -0
- package/types/components/InputChip.d.ts.map +1 -0
- package/types/components/Label.d.ts +29 -0
- package/types/components/Label.d.ts.map +1 -0
- package/types/components/List.d.ts +31 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/ListItem.d.ts +349 -0
- package/types/components/ListItem.d.ts.map +1 -0
- package/types/components/ListOption.d.ts +1493 -0
- package/types/components/ListOption.d.ts.map +1 -0
- package/types/components/Listbox.d.ts +12012 -0
- package/types/components/Listbox.d.ts.map +1 -0
- package/types/components/Menu.d.ts +119 -0
- package/types/components/Menu.d.ts.map +1 -0
- package/types/components/MenuItem.d.ts +3109 -0
- package/types/components/MenuItem.d.ts.map +1 -0
- package/types/components/NavBar.d.ts +18 -0
- package/types/components/NavBar.d.ts.map +1 -0
- package/types/components/NavBarItem.d.ts +186 -0
- package/types/components/NavBarItem.d.ts.map +1 -0
- package/types/components/NavDrawer.d.ts +108 -0
- package/types/components/NavDrawer.d.ts.map +1 -0
- package/types/components/NavDrawerItem.d.ts +186 -0
- package/types/components/NavDrawerItem.d.ts.map +1 -0
- package/types/components/NavItem.d.ts +190 -0
- package/types/components/NavItem.d.ts.map +1 -0
- package/types/components/NavRail.d.ts +109 -0
- package/types/components/NavRail.d.ts.map +1 -0
- package/types/components/NavRailItem.d.ts +186 -0
- package/types/components/NavRailItem.d.ts.map +1 -0
- package/types/components/Page.d.ts +24 -0
- package/types/components/Page.d.ts.map +1 -0
- package/types/components/Pane.d.ts +44 -0
- package/types/components/Pane.d.ts.map +1 -0
- package/types/components/Popup.d.ts +76 -0
- package/types/components/Popup.d.ts.map +1 -0
- package/types/components/Progress.d.ts +19 -0
- package/types/components/Progress.d.ts.map +1 -0
- package/types/components/Radio.d.ts +199 -0
- package/types/components/Radio.d.ts.map +1 -0
- package/types/components/RadioIcon.d.ts +46 -0
- package/types/components/RadioIcon.d.ts.map +1 -0
- package/types/components/Ripple.d.ts +34 -0
- package/types/components/Ripple.d.ts.map +1 -0
- package/types/components/Root.d.ts +68 -0
- package/types/components/Root.d.ts.map +1 -0
- package/types/components/Scrim.d.ts +6 -0
- package/types/components/Scrim.d.ts.map +1 -0
- package/types/components/Search.d.ts +16 -0
- package/types/components/Search.d.ts.map +1 -0
- package/types/components/SegmentedButton.d.ts +718 -0
- package/types/components/SegmentedButton.d.ts.map +1 -0
- package/types/components/SegmentedButtonGroup.d.ts +44 -0
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
- package/types/components/Select.d.ts +1361 -0
- package/types/components/Select.d.ts.map +1 -0
- package/types/components/Shape.d.ts +10 -0
- package/types/components/Shape.d.ts.map +1 -0
- package/types/components/SideSheet.d.ts +106 -0
- package/types/components/SideSheet.d.ts.map +1 -0
- package/types/components/Slider.d.ts +382 -0
- package/types/components/Slider.d.ts.map +1 -0
- package/types/components/Snackbar.d.ts +65 -0
- package/types/components/Snackbar.d.ts.map +1 -0
- package/types/components/SnackbarContainer.d.ts +6 -0
- package/types/components/SnackbarContainer.d.ts.map +1 -0
- package/types/components/Surface.d.ts +45 -0
- package/types/components/Surface.d.ts.map +1 -0
- package/types/components/Switch.d.ts +183 -0
- package/types/components/Switch.d.ts.map +1 -0
- package/types/components/SwitchIcon.d.ts +169 -0
- package/types/components/SwitchIcon.d.ts.map +1 -0
- package/types/components/Tab.d.ts +879 -0
- package/types/components/Tab.d.ts.map +1 -0
- package/types/components/TabContent.d.ts +122 -0
- package/types/components/TabContent.d.ts.map +1 -0
- package/types/components/TabList.d.ts +6266 -0
- package/types/components/TabList.d.ts.map +1 -0
- package/types/components/TabPanel.d.ts +28 -0
- package/types/components/TabPanel.d.ts.map +1 -0
- package/types/components/Table.d.ts +2 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/TextArea.d.ts +1394 -0
- package/types/components/TextArea.d.ts.map +1 -0
- package/types/components/Title.d.ts +47 -0
- package/types/components/Title.d.ts.map +1 -0
- package/types/components/Tooltip.d.ts +49 -0
- package/types/components/Tooltip.d.ts.map +1 -0
- package/types/components/TopAppBar.d.ts +130 -0
- package/types/components/TopAppBar.d.ts.map +1 -0
- package/types/constants/colorKeywords.d.ts +2 -0
- package/types/constants/colorKeywords.d.ts.map +1 -0
- package/types/constants/shapes.d.ts +38 -0
- package/types/constants/shapes.d.ts.map +1 -0
- package/types/constants/typography.d.ts +212 -0
- package/types/constants/typography.d.ts.map +1 -0
- package/types/core/Composition.d.ts +252 -0
- package/types/core/Composition.d.ts.map +1 -0
- package/types/core/CompositionAdapter.d.ts +92 -0
- package/types/core/CompositionAdapter.d.ts.map +1 -0
- package/types/core/CustomElement.d.ts +302 -0
- package/types/core/CustomElement.d.ts.map +1 -0
- package/types/core/css.d.ts +44 -0
- package/types/core/css.d.ts.map +1 -0
- package/types/core/customTypes.d.ts +26 -0
- package/types/core/customTypes.d.ts.map +1 -0
- package/types/core/dom.d.ts +32 -0
- package/types/core/dom.d.ts.map +1 -0
- package/types/core/jsonMergePatch.d.ts +31 -0
- package/types/core/jsonMergePatch.d.ts.map +1 -0
- package/types/core/observe.d.ts +113 -0
- package/types/core/observe.d.ts.map +1 -0
- package/types/core/optimizations.d.ts +7 -0
- package/types/core/optimizations.d.ts.map +1 -0
- package/types/core/template.d.ts +47 -0
- package/types/core/template.d.ts.map +1 -0
- package/types/core/uid.d.ts +6 -0
- package/types/core/uid.d.ts.map +1 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
- package/types/index.d.ts +88 -0
- package/types/index.d.ts.map +1 -0
- package/types/loaders/palette.d.ts +2 -0
- package/types/loaders/palette.d.ts.map +1 -0
- package/types/loaders/theme.d.ts +2 -0
- package/types/loaders/theme.d.ts.map +1 -0
- package/types/mixins/AriaReflectorMixin.d.ts +23 -0
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
- package/types/mixins/AriaToolbarMixin.d.ts +32 -0
- package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
- package/types/mixins/ControlMixin.d.ts +124 -0
- package/types/mixins/ControlMixin.d.ts.map +1 -0
- package/types/mixins/DelegatesFocusMixin.d.ts +5 -0
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
- package/types/mixins/DensityMixin.d.ts +5 -0
- package/types/mixins/DensityMixin.d.ts.map +1 -0
- package/types/mixins/ElevationMixin.d.ts +33 -0
- package/types/mixins/ElevationMixin.d.ts.map +1 -0
- package/types/mixins/FlexableMixin.d.ts +13 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -0
- package/types/mixins/FormAssociatedMixin.d.ts +122 -0
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
- package/types/mixins/HyperlinkMixin.d.ts +22 -0
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
- package/types/mixins/InputMixin.d.ts +179 -0
- package/types/mixins/InputMixin.d.ts.map +1 -0
- package/types/mixins/KeyboardNavMixin.d.ts +47 -0
- package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
- package/types/mixins/NavigationListenerMixin.d.ts +8 -0
- package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
- package/types/mixins/PopupMixin.d.ts +82 -0
- package/types/mixins/PopupMixin.d.ts.map +1 -0
- package/types/mixins/RTLObserverMixin.d.ts +7 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts +12 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
- package/types/mixins/RippleMixin.d.ts +92 -0
- package/types/mixins/RippleMixin.d.ts.map +1 -0
- package/types/mixins/ScrollListenerMixin.d.ts +41 -0
- package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
- package/types/mixins/SemiStickyMixin.d.ts +50 -0
- package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMaskedMixin.d.ts +9 -0
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMixin.d.ts +38 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -0
- package/types/mixins/StateMixin.d.ts +27 -0
- package/types/mixins/StateMixin.d.ts.map +1 -0
- package/types/mixins/TextFieldMixin.d.ts +1354 -0
- package/types/mixins/TextFieldMixin.d.ts.map +1 -0
- package/types/mixins/ThemableMixin.d.ts +9 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -0
- package/types/mixins/TooltipTriggerMixin.d.ts +106 -0
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
- package/types/mixins/TouchTargetMixin.d.ts +3 -0
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
- package/types/mixins/TypographyMixin.d.ts +17 -0
- package/types/mixins/TypographyMixin.d.ts.map +1 -0
- package/types/services/rtl.d.ts +3 -0
- package/types/services/rtl.d.ts.map +1 -0
- package/types/services/svgAlias.d.ts +13 -0
- package/types/services/svgAlias.d.ts.map +1 -0
- package/types/services/theme.d.ts +45 -0
- package/types/services/theme.d.ts.map +1 -0
- package/types/utils/cli.d.ts +3 -0
- package/types/utils/cli.d.ts.map +1 -0
- package/types/utils/function.d.ts +3 -0
- package/types/utils/function.d.ts.map +1 -0
- package/types/utils/jsx-runtime.d.ts +20 -0
- package/types/utils/jsx-runtime.d.ts.map +1 -0
- package/types/utils/material-color/blend.d.ts +34 -0
- package/types/utils/material-color/blend.d.ts.map +1 -0
- package/types/utils/material-color/hct/Cam16.d.ts +142 -0
- package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
- package/types/utils/material-color/hct/Hct.d.ts +93 -0
- package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
- package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
- package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
- package/types/utils/material-color/helper.d.ts +8 -0
- package/types/utils/material-color/helper.d.ts.map +1 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
- package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
- package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
- package/types/utils/material-color/utils/color.d.ts +172 -0
- package/types/utils/material-color/utils/color.d.ts.map +1 -0
- package/types/utils/material-color/utils/math.d.ts +94 -0
- package/types/utils/material-color/utils/math.d.ts.map +1 -0
- package/types/utils/pixelmatch.d.ts +22 -0
- package/types/utils/pixelmatch.d.ts.map +1 -0
- package/types/utils/popup.d.ts +106 -0
- package/types/utils/popup.d.ts.map +1 -0
- package/types/utils/searchParams.d.ts +3 -0
- package/types/utils/searchParams.d.ts.map +1 -0
- package/types/utils/svg.d.ts +7 -0
- package/types/utils/svg.d.ts.map +1 -0
- package/utils/{hct → material-color}/blend.js +8 -10
- package/utils/{hct → material-color/hct}/Cam16.js +196 -69
- package/utils/{hct → material-color/hct}/Hct.js +61 -19
- package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
- package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
- package/utils/{hct → material-color}/helper.js +11 -18
- package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
- package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
- package/utils/material-color/scheme/Scheme.js +376 -0
- package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
- package/utils/pixelmatch.js +360 -0
- package/utils/popup.js +127 -30
- package/utils/searchParams.js +19 -0
- package/components/ExtendedFab.js +0 -36
- package/components/Layout.js +0 -35
- package/components/ListSelect.js +0 -220
- package/components/Nav.js +0 -40
- package/components/Option.js +0 -91
- package/core/ICustomElement.d.ts +0 -291
- package/core/ICustomElement.js +0 -1
- package/core/identify.js +0 -40
- package/core/typings.d.ts +0 -136
- package/core/typings.js +0 -1
- package/mixins/SurfaceMixin.js +0 -181
- package/theming/loader.js +0 -22
- package/utils/hct/Scheme.js +0 -587
- /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
- /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
* and a difference of 50 guarantees a contrast ratio >= 4.5.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
+
import * as utils from '../utils/color.js';
|
|
35
|
+
|
|
34
36
|
import Cam16 from './Cam16.js';
|
|
35
|
-
import
|
|
37
|
+
import ViewingConditions from './ViewingConditions.js';
|
|
36
38
|
import * as hctSolver from './hctSolver.js';
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -50,15 +52,6 @@ export default class Hct {
|
|
|
50
52
|
* @return HCT representation of a color in default viewing conditions.
|
|
51
53
|
*/
|
|
52
54
|
|
|
53
|
-
/** @type {number} */
|
|
54
|
-
internalHue;
|
|
55
|
-
|
|
56
|
-
/** @type {number} */
|
|
57
|
-
internalChroma;
|
|
58
|
-
|
|
59
|
-
/** @type {number} */
|
|
60
|
-
internalTone;
|
|
61
|
-
|
|
62
55
|
/**
|
|
63
56
|
* @param {number} hue
|
|
64
57
|
* @param {number} chroma
|
|
@@ -77,6 +70,24 @@ export default class Hct {
|
|
|
77
70
|
return new Hct(argb);
|
|
78
71
|
}
|
|
79
72
|
|
|
73
|
+
/** @type {number} */
|
|
74
|
+
internalHue;
|
|
75
|
+
|
|
76
|
+
/** @type {number} */
|
|
77
|
+
internalChroma;
|
|
78
|
+
|
|
79
|
+
/** @type {number} */
|
|
80
|
+
internalTone;
|
|
81
|
+
|
|
82
|
+
/** @param {number} argb */
|
|
83
|
+
constructor(argb) {
|
|
84
|
+
const cam = Cam16.fromInt(argb);
|
|
85
|
+
this.internalHue = cam.hue;
|
|
86
|
+
this.internalChroma = cam.chroma;
|
|
87
|
+
this.internalTone = utils.lstarFromArgb(argb);
|
|
88
|
+
this.argb = argb;
|
|
89
|
+
}
|
|
90
|
+
|
|
80
91
|
/** @return {number} */
|
|
81
92
|
toInt() {
|
|
82
93
|
return this.argb;
|
|
@@ -149,15 +160,6 @@ export default class Hct {
|
|
|
149
160
|
);
|
|
150
161
|
}
|
|
151
162
|
|
|
152
|
-
/** @param {number} argb */
|
|
153
|
-
constructor(argb) {
|
|
154
|
-
const cam = Cam16.fromInt(argb);
|
|
155
|
-
this.internalHue = cam.hue;
|
|
156
|
-
this.internalChroma = cam.chroma;
|
|
157
|
-
this.internalTone = utils.lstarFromArgb(argb);
|
|
158
|
-
this.argb = argb;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
163
|
/**
|
|
162
164
|
* @private
|
|
163
165
|
* @param {number} argb
|
|
@@ -169,4 +171,44 @@ export default class Hct {
|
|
|
169
171
|
this.internalTone = utils.lstarFromArgb(argb);
|
|
170
172
|
this.argb = argb;
|
|
171
173
|
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Translates a color into different [ViewingConditions].
|
|
177
|
+
*
|
|
178
|
+
* Colors change appearance. They look different with lights on versus off,
|
|
179
|
+
* the same color, as in hex code, on white looks different when on black.
|
|
180
|
+
* This is called color relativity, most famously explicated by Josef Albers
|
|
181
|
+
* in Interaction of Color.
|
|
182
|
+
*
|
|
183
|
+
* In color science, color appearance models can account for this and
|
|
184
|
+
* calculate the appearance of a color in different settings. HCT is based on
|
|
185
|
+
* CAM16, a color appearance model, and uses it to make these calculations.
|
|
186
|
+
*
|
|
187
|
+
* See [ViewingConditions.make] for parameters affecting color appearance.
|
|
188
|
+
* @param {ViewingConditions} vc
|
|
189
|
+
* @return {Hct}
|
|
190
|
+
*/
|
|
191
|
+
inViewingConditions(vc) {
|
|
192
|
+
// 1. Use CAM16 to find XYZ coordinates of color in specified VC.
|
|
193
|
+
const cam = Cam16.fromInt(this.toInt());
|
|
194
|
+
const viewedInVc = cam.xyzInViewingConditions(vc);
|
|
195
|
+
|
|
196
|
+
// 2. Create CAM16 of those XYZ coordinates in default VC.
|
|
197
|
+
const recastInVc = Cam16.fromXyzInViewingConditions(
|
|
198
|
+
viewedInVc[0],
|
|
199
|
+
viewedInVc[1],
|
|
200
|
+
viewedInVc[2],
|
|
201
|
+
ViewingConditions.make(),
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
// 3. Create HCT from:
|
|
205
|
+
// - CAM16 using default VC with XYZ coordinates in specified VC.
|
|
206
|
+
// - L* converted from Y in XYZ coordinates in specified VC.
|
|
207
|
+
const recastHct = Hct.from(
|
|
208
|
+
recastInVc.hue,
|
|
209
|
+
recastInVc.chroma,
|
|
210
|
+
utils.lstarFromY(viewedInVc[1]),
|
|
211
|
+
);
|
|
212
|
+
return recastHct;
|
|
213
|
+
}
|
|
172
214
|
}
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import * as utils from '
|
|
19
|
-
import * as math from '
|
|
18
|
+
import * as utils from '../utils/color.js';
|
|
19
|
+
import * as math from '../utils/math.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* In traditional color spaces, a color can be identified solely by the
|
|
@@ -85,7 +85,7 @@ export default class ViewingConditions {
|
|
|
85
85
|
const k4 = k * k * k * k;
|
|
86
86
|
const k4F = 1 - k4;
|
|
87
87
|
const fl = k4 * adaptingLuminance
|
|
88
|
-
|
|
88
|
+
+ 0.1 * k4F * k4F * Math.cbrt(5 * adaptingLuminance);
|
|
89
89
|
const n = utils.yFromLstar(backgroundLstar) / whitePoint[1];
|
|
90
90
|
const z = 1.48 + Math.sqrt(n);
|
|
91
91
|
const nbb = 0.725 / n ** 0.2;
|
|
@@ -15,19 +15,11 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
import * as colorUtils from '../utils/color.js';
|
|
19
|
+
import * as mathUtils from '../utils/math.js';
|
|
20
|
+
|
|
18
21
|
import Cam16 from './Cam16.js';
|
|
19
22
|
import ViewingConditions from './ViewingConditions.js';
|
|
20
|
-
import * as colorUtils from './colorUtils.js';
|
|
21
|
-
import * as mathUtils from './mathUtils.js';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A class that solves the HCT equation.
|
|
25
|
-
*/
|
|
26
|
-
// libmonet is designed to have a consistent API across platforms
|
|
27
|
-
// and modular components that can be moved around easily. Using a class as a
|
|
28
|
-
// namespace facilitates this.
|
|
29
|
-
//
|
|
30
|
-
// tslint:disable-next-line:class-as-namespace
|
|
31
23
|
|
|
32
24
|
export const SCALED_DISCOUNT_FROM_LINRGB = [
|
|
33
25
|
[
|
|
@@ -476,9 +468,10 @@ function findResultByJ(hueRadians, chroma, y) {
|
|
|
476
468
|
const alpha = chroma === 0 || j === 0 ? 0 : chroma / Math.sqrt(jNormalized);
|
|
477
469
|
const t = (alpha * tInnerCoeff) ** (1 / 0.9);
|
|
478
470
|
const ac = viewingConditions.aw
|
|
479
|
-
|
|
471
|
+
* jNormalized ** (1 / viewingConditions.c / viewingConditions.z);
|
|
480
472
|
const p2 = ac / viewingConditions.nbb;
|
|
481
|
-
const gamma = 23 * (p2 + 0.305) * t
|
|
473
|
+
const gamma = (23 * (p2 + 0.305) * t)
|
|
474
|
+
/ (23 * p1 + 11 * t * hCos + 108 * t * hSin);
|
|
482
475
|
const a = gamma * hCos;
|
|
483
476
|
const b = gamma * hSin;
|
|
484
477
|
const rA = (460 * p2 + 451 * a + 288 * b) / 1403;
|
|
@@ -491,9 +484,9 @@ function findResultByJ(hueRadians, chroma, y) {
|
|
|
491
484
|
[rCScaled, gCScaled, bCScaled],
|
|
492
485
|
LINRGB_FROM_SCALED_DISCOUNT,
|
|
493
486
|
);
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
487
|
+
// ===========================================================
|
|
488
|
+
// Operations inlined from Cam16 to avoid repeated calculation
|
|
489
|
+
// ===========================================================
|
|
497
490
|
if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) {
|
|
498
491
|
return 0;
|
|
499
492
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import CorePalette from './CorePalette.js';
|
|
2
|
-
import Scheme from './Scheme.js';
|
|
3
1
|
import { harmonize } from './blend.js';
|
|
4
|
-
import
|
|
2
|
+
import CorePalette from './palettes/CorePalette.js';
|
|
3
|
+
import Scheme from './scheme/Scheme.js';
|
|
4
|
+
import * as colorUtils from './utils/color.js';
|
|
5
5
|
|
|
6
|
-
/** @typedef {import(
|
|
6
|
+
/** @typedef {import("./palettes/TonalPalette.js").default} TonalPalette */
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {string} value
|
|
@@ -109,7 +109,13 @@ function cssVariablesFromScheme(scheme) {
|
|
|
109
109
|
--mdw-color__on-background: ${cssVarFromArgb(scheme.onBackground)};
|
|
110
110
|
--mdw-color__surface: ${cssVarFromArgb(scheme.surface)};
|
|
111
111
|
--mdw-color__on-surface: ${cssVarFromArgb(scheme.onSurface)};
|
|
112
|
-
--mdw-color__surface-
|
|
112
|
+
--mdw-color__surface-dim: ${cssVarFromArgb(scheme.surfaceDim)};
|
|
113
|
+
--mdw-color__surface-bright: ${cssVarFromArgb(scheme.surfaceBright)};
|
|
114
|
+
--mdw-color__surface-container-lowest: ${cssVarFromArgb(scheme.surfaceContainerLowest)};
|
|
115
|
+
--mdw-color__surface-container-low: ${cssVarFromArgb(scheme.surfaceContainerLow)};
|
|
116
|
+
--mdw-color__surface-container: ${cssVarFromArgb(scheme.surfaceContainer)};
|
|
117
|
+
--mdw-color__surface-container-high: ${cssVarFromArgb(scheme.surfaceContainerHigh)};
|
|
118
|
+
--mdw-color__surface-container-highest: ${cssVarFromArgb(scheme.surfaceContainerHighest)};
|
|
113
119
|
--mdw-color__on-surface-variant: ${cssVarFromArgb(scheme.onSurfaceVariant)};
|
|
114
120
|
--mdw-color__outline: ${cssVarFromArgb(scheme.outline)};
|
|
115
121
|
--mdw-color__outline-variant: ${cssVarFromArgb(scheme.outlineVariant)};
|
|
@@ -135,19 +141,6 @@ function cssVariablesFromCustom(name, tonalPalette, isDark) {
|
|
|
135
141
|
--mdw-color__${name}-container: ${cssVarFromArgb(tonalPalette.tone(isDark ? 30 : 90))};
|
|
136
142
|
--mdw-color__on-${name}-container: ${cssVarFromArgb(tonalPalette.tone(isDark ? 90 : 10))};
|
|
137
143
|
}
|
|
138
|
-
.mdw-custom[color="${name}"] {
|
|
139
|
-
--mdw-bg: var(--mdw-color__${name});
|
|
140
|
-
--mdw-ink: var(--mdw-color__on-${name});
|
|
141
|
-
}
|
|
142
|
-
.mdw-custom[color="${name}-container"] {
|
|
143
|
-
--mdw-bg: var(--mdw-color__${name}-container);
|
|
144
|
-
--mdw-ink: var(--mdw-color__on-${name}-container);
|
|
145
|
-
}
|
|
146
|
-
.mdw-custom[ink="${name}"] {
|
|
147
|
-
--mdw-ink: var(--mdw-color__${name});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
144
|
`;
|
|
152
145
|
}
|
|
153
146
|
|
|
@@ -15,15 +15,91 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import Hct from '
|
|
18
|
+
import Hct from '../hct/Hct.js';
|
|
19
|
+
|
|
19
20
|
import TonalPalette from './TonalPalette.js';
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Set of colors to generate a [CorePalette] from
|
|
24
|
+
* @typedef CorePaletteColors
|
|
25
|
+
* @prop {number} primary
|
|
26
|
+
* @prop {number} [secondary]
|
|
27
|
+
* @prop {number} [tertiary]
|
|
28
|
+
* @prop {number} [neutral]
|
|
29
|
+
* @prop {number} [neutralVariant]
|
|
30
|
+
* @prop {number} [error]
|
|
31
|
+
*/
|
|
32
|
+
|
|
21
33
|
/**
|
|
22
34
|
* An intermediate concept between the key color for a UI theme, and a full
|
|
23
35
|
* color scheme. 5 sets of tones are generated, all except one use the same hue
|
|
24
36
|
* as the key color, and all vary in chroma.
|
|
25
37
|
*/
|
|
26
38
|
export default class CorePalette {
|
|
39
|
+
/**
|
|
40
|
+
* @param {boolean} content
|
|
41
|
+
* @param {CorePaletteColors} colors
|
|
42
|
+
* @return {CorePalette}
|
|
43
|
+
*/
|
|
44
|
+
static #createPaletteFromColors(content, colors) {
|
|
45
|
+
const palette = new CorePalette(colors.primary, content);
|
|
46
|
+
if (colors.secondary) {
|
|
47
|
+
const p = new CorePalette(colors.secondary, content);
|
|
48
|
+
palette.a2 = p.a1;
|
|
49
|
+
}
|
|
50
|
+
if (colors.tertiary) {
|
|
51
|
+
const p = new CorePalette(colors.tertiary, content);
|
|
52
|
+
palette.a3 = p.a1;
|
|
53
|
+
}
|
|
54
|
+
if (colors.error) {
|
|
55
|
+
const p = new CorePalette(colors.error, content);
|
|
56
|
+
palette.error = p.a1;
|
|
57
|
+
}
|
|
58
|
+
if (colors.neutral) {
|
|
59
|
+
const p = new CorePalette(colors.neutral, content);
|
|
60
|
+
palette.n1 = p.n1;
|
|
61
|
+
}
|
|
62
|
+
if (colors.neutralVariant) {
|
|
63
|
+
const p = new CorePalette(colors.neutralVariant, content);
|
|
64
|
+
palette.n2 = p.n2;
|
|
65
|
+
}
|
|
66
|
+
return palette;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {number} argb ARGB representation of a color
|
|
71
|
+
* @return {CorePalette}
|
|
72
|
+
*/
|
|
73
|
+
static of(argb) {
|
|
74
|
+
return new CorePalette(argb, false);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {number} argb ARGB representation of a color
|
|
79
|
+
* @return {CorePalette}
|
|
80
|
+
*/
|
|
81
|
+
static contentOf(argb) {
|
|
82
|
+
return new CorePalette(argb, true);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create a [CorePalette] from a set of colors
|
|
87
|
+
* @param {CorePaletteColors} colors
|
|
88
|
+
* @return {CorePalette}
|
|
89
|
+
*/
|
|
90
|
+
static fromColors(colors) {
|
|
91
|
+
return CorePalette.#createPaletteFromColors(false, colors);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Create a content [CorePalette] from a set of colors
|
|
96
|
+
* @param {CorePaletteColors} colors
|
|
97
|
+
* @return {CorePalette}
|
|
98
|
+
*/
|
|
99
|
+
static contentFromColors(colors) {
|
|
100
|
+
return CorePalette.#createPaletteFromColors(true, colors);
|
|
101
|
+
}
|
|
102
|
+
|
|
27
103
|
/** @type {TonalPalette} */
|
|
28
104
|
a1;
|
|
29
105
|
|
|
@@ -42,22 +118,6 @@ export default class CorePalette {
|
|
|
42
118
|
/** @type {TonalPalette} */
|
|
43
119
|
error;
|
|
44
120
|
|
|
45
|
-
/**
|
|
46
|
-
* @param {number} argb ARGB representation of a color
|
|
47
|
-
* @return {CorePalette}
|
|
48
|
-
*/
|
|
49
|
-
static of(argb) {
|
|
50
|
-
return new CorePalette(argb, false);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @param {number} argb ARGB representation of a color
|
|
55
|
-
* @return {CorePalette}
|
|
56
|
-
*/
|
|
57
|
-
static contentOf(argb) {
|
|
58
|
-
return new CorePalette(argb, true);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
121
|
/**
|
|
62
122
|
* @param {number} argb
|
|
63
123
|
* @param {boolean} isContent
|
|
@@ -70,13 +130,13 @@ export default class CorePalette {
|
|
|
70
130
|
this.a1 = TonalPalette.fromHueAndChroma(hue, chroma);
|
|
71
131
|
this.a2 = TonalPalette.fromHueAndChroma(hue, chroma / 3);
|
|
72
132
|
this.a3 = TonalPalette.fromHueAndChroma(hue + 60, chroma / 2);
|
|
73
|
-
this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12,
|
|
133
|
+
this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12, 6)); // Bump from 4
|
|
74
134
|
this.n2 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 6, 8));
|
|
75
135
|
} else {
|
|
76
136
|
this.a1 = TonalPalette.fromHueAndChroma(hue, Math.max(48, chroma));
|
|
77
137
|
this.a2 = TonalPalette.fromHueAndChroma(hue, 16);
|
|
78
138
|
this.a3 = TonalPalette.fromHueAndChroma(hue + 60, 24);
|
|
79
|
-
this.n1 = TonalPalette.fromHueAndChroma(hue,
|
|
139
|
+
this.n1 = TonalPalette.fromHueAndChroma(hue, 6); // Bump from 4
|
|
80
140
|
this.n2 = TonalPalette.fromHueAndChroma(hue, 8);
|
|
81
141
|
}
|
|
82
142
|
this.error = TonalPalette.fromHueAndChroma(25, 84);
|
|
@@ -15,16 +15,13 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import Hct from '
|
|
18
|
+
import Hct from '../hct/Hct.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* A convenience class for retrieving colors that are constant in hue and
|
|
22
22
|
* chroma, but vary in tone.
|
|
23
23
|
*/
|
|
24
24
|
export default class TonalPalette {
|
|
25
|
-
/** @type {Map<number, number>} */
|
|
26
|
-
#cache = new Map();
|
|
27
|
-
|
|
28
25
|
/**
|
|
29
26
|
* @param {number} argb ARGB representation of a color
|
|
30
27
|
* @return {TonalPalette} Tones matching that color's hue and chroma.
|
|
@@ -43,6 +40,9 @@ export default class TonalPalette {
|
|
|
43
40
|
return new TonalPalette(hue, chroma);
|
|
44
41
|
}
|
|
45
42
|
|
|
43
|
+
/** @type {Map<number, number>} */
|
|
44
|
+
#cache = new Map();
|
|
45
|
+
|
|
46
46
|
/**
|
|
47
47
|
* @private
|
|
48
48
|
* @param {number} hue
|
|
@@ -65,4 +65,12 @@ export default class TonalPalette {
|
|
|
65
65
|
}
|
|
66
66
|
return argb;
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {number} tone HCT tone.
|
|
71
|
+
* @return {Hct} HCT representation of a color with that tone.
|
|
72
|
+
*/
|
|
73
|
+
getHct(tone) {
|
|
74
|
+
return Hct.fromInt(this.tone(tone));
|
|
75
|
+
}
|
|
68
76
|
}
|