framework7 7.0.9 → 8.0.0-beta.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/components/accordion/accordion.js +2 -16
- package/components/accordion/accordion.less +0 -3
- package/components/actions/actions-class.js +13 -58
- package/components/actions/actions-ios.less +42 -0
- package/components/actions/actions-md.less +12 -0
- package/components/actions/actions-rtl.css +1 -1
- package/components/actions/actions-vars.less +17 -42
- package/components/actions/actions.css +1 -1
- package/components/actions/actions.d.ts +2 -2
- package/components/actions/actions.js +0 -4
- package/components/actions/actions.lazy.js +1 -1
- package/components/actions/actions.less +5 -35
- package/components/app/app-class.d.ts +14 -12
- package/components/app/app-class.js +93 -75
- package/components/app/app-ios.less +0 -2
- package/components/app/app-md.less +0 -2
- package/components/app/app-vars.less +13 -96
- package/components/app/app.less +1 -4
- package/components/app/load-module.js +17 -36
- package/components/area-chart/area-chart-class.js +8 -64
- package/components/area-chart/area-chart.js +0 -3
- package/components/area-chart/area-chart.less +0 -3
- package/components/autocomplete/autocomplete-class.js +30 -175
- package/components/autocomplete/autocomplete-ios.less +0 -8
- package/components/autocomplete/autocomplete-rtl.css +1 -1
- package/components/autocomplete/autocomplete-vars.less +8 -22
- package/components/autocomplete/autocomplete.css +1 -1
- package/components/autocomplete/autocomplete.d.ts +1 -3
- package/components/autocomplete/autocomplete.js +1 -6
- package/components/autocomplete/autocomplete.lazy.js +1 -1
- package/components/autocomplete/autocomplete.less +6 -18
- package/components/badge/badge-vars.less +3 -6
- package/components/badge/badge.less +1 -3
- package/components/block/block-vars.less +25 -52
- package/components/block/block.less +37 -12
- package/components/breadcrumbs/breadcrumbs-rtl.css +1 -1
- package/components/breadcrumbs/breadcrumbs-vars.less +31 -15
- package/components/breadcrumbs/breadcrumbs.css +1 -1
- package/components/breadcrumbs/breadcrumbs.js +0 -2
- package/components/breadcrumbs/breadcrumbs.less +4 -10
- package/components/button/button-vars.less +42 -43
- package/components/button/button.less +24 -26
- package/components/calendar/calendar-class.js +81 -401
- package/components/calendar/calendar-rtl.css +1 -1
- package/components/calendar/calendar-vars.less +32 -46
- package/components/calendar/calendar.css +1 -1
- package/components/calendar/calendar.js +6 -4
- package/components/calendar/calendar.lazy.js +1 -1
- package/components/calendar/calendar.less +10 -21
- package/components/card/card-rtl.css +1 -1
- package/components/card/card-vars.less +41 -44
- package/components/card/card.css +1 -1
- package/components/card/card.js +0 -108
- package/components/card/card.less +18 -24
- package/components/checkbox/checkbox-rtl.css +1 -1
- package/components/checkbox/checkbox-vars.less +0 -8
- package/components/checkbox/checkbox.css +1 -1
- package/components/checkbox/checkbox.less +10 -3
- package/components/chip/chip-ios.less +3 -0
- package/components/chip/chip-md.less +4 -3
- package/components/chip/chip-rtl.css +1 -1
- package/components/chip/chip-vars.less +17 -20
- package/components/chip/chip.css +1 -1
- package/components/chip/chip.less +16 -21
- package/components/color-picker/color-picker-class.js +27 -158
- package/components/color-picker/color-picker-rtl.css +1 -1
- package/components/color-picker/color-picker.css +1 -1
- package/components/color-picker/color-picker.js +0 -4
- package/components/color-picker/color-picker.lazy.js +1 -1
- package/components/color-picker/color-picker.less +18 -8
- package/components/color-picker/modules/alpha-slider.js +0 -12
- package/components/color-picker/modules/brightness-slider.js +0 -8
- package/components/color-picker/modules/current-color.js +0 -2
- package/components/color-picker/modules/hex.js +0 -12
- package/components/color-picker/modules/hs-spectrum.js +0 -20
- package/components/color-picker/modules/hsb-sliders.js +0 -18
- package/components/color-picker/modules/hue-slider.js +0 -7
- package/components/color-picker/modules/initial-current-colors.js +0 -7
- package/components/color-picker/modules/palette.js +2 -10
- package/components/color-picker/modules/rgb-bars.js +0 -17
- package/components/color-picker/modules/rgb-sliders.js +0 -17
- package/components/color-picker/modules/sb-spectrum.js +0 -20
- package/components/color-picker/modules/wheel.js +0 -28
- package/components/contacts-list/contacts-list-md.less +4 -3
- package/components/contacts-list/contacts-list-rtl.css +1 -1
- package/components/contacts-list/contacts-list-vars.less +3 -15
- package/components/contacts-list/contacts-list.css +1 -1
- package/components/contacts-list/contacts-list.less +0 -3
- package/components/data-table/data-table-class.js +10 -32
- package/components/data-table/data-table-rtl.css +1 -1
- package/components/data-table/data-table-vars.less +6 -39
- package/components/data-table/data-table.css +1 -1
- package/components/data-table/data-table.js +0 -8
- package/components/data-table/data-table.less +0 -3
- package/components/dialog/dialog-class.js +7 -41
- package/components/dialog/dialog-ios.less +0 -3
- package/components/dialog/dialog-md.less +9 -9
- package/components/dialog/dialog-rtl.css +1 -1
- package/components/dialog/dialog-vars.less +25 -70
- package/components/dialog/dialog.css +1 -1
- package/components/dialog/dialog.d.ts +2 -2
- package/components/dialog/dialog.js +12 -48
- package/components/dialog/dialog.lazy.js +1 -1
- package/components/dialog/dialog.less +8 -4
- package/components/fab/fab-rtl.css +1 -1
- package/components/fab/fab-vars.less +20 -14
- package/components/fab/fab.css +1 -1
- package/components/fab/fab.js +0 -21
- package/components/fab/fab.less +50 -53
- package/components/form/form.d.ts +4 -4
- package/components/form/form.js +58 -94
- package/components/form/form.lazy.js +1 -1
- package/components/form/form.less +0 -3
- package/components/gauge/gauge-class.js +4 -20
- package/components/gauge/gauge.js +0 -9
- package/components/gauge/gauge.less +0 -3
- package/components/grid/grid-rtl.css +1 -1
- package/components/grid/grid-vars.less +0 -7
- package/components/grid/grid.css +1 -1
- package/components/grid/grid.d.ts +2 -8
- package/components/grid/grid.js +1 -225
- package/components/grid/grid.lazy.js +1 -1
- package/components/grid/grid.less +54 -184
- package/components/icon/icon.less +0 -3
- package/components/infinite-scroll/infinite-scroll-rtl.css +1 -1
- package/components/infinite-scroll/infinite-scroll.css +1 -1
- package/components/infinite-scroll/infinite-scroll.js +0 -16
- package/components/infinite-scroll/infinite-scroll.less +0 -3
- package/components/input/input-ios.less +49 -41
- package/components/input/input-md.less +87 -19
- package/components/input/input-rtl.css +1 -1
- package/components/input/input-vars.less +26 -60
- package/components/input/input.css +1 -1
- package/components/input/input.js +8 -67
- package/components/input/input.less +67 -153
- package/components/link/link-vars.less +0 -5
- package/components/link/link.less +3 -3
- package/components/list/list-md.less +0 -7
- package/components/list/list-vars.less +59 -108
- package/components/list/list.less +122 -90
- package/components/list-index/list-index-class.js +12 -69
- package/components/list-index/list-index-rtl.css +1 -1
- package/components/list-index/list-index-vars.less +0 -7
- package/components/list-index/list-index.css +1 -1
- package/components/list-index/list-index.d.ts +1 -3
- package/components/list-index/list-index.js +0 -8
- package/components/list-index/list-index.lazy.js +1 -1
- package/components/list-index/list-index.less +4 -7
- package/components/login-screen/login-screen-class.js +4 -9
- package/components/login-screen/login-screen-rtl.css +1 -1
- package/components/login-screen/login-screen-vars.less +13 -12
- package/components/login-screen/login-screen.css +1 -1
- package/components/login-screen/login-screen.js +0 -4
- package/components/login-screen/login-screen.less +2 -8
- package/components/messagebar/messagebar-class.js +18 -79
- package/components/messagebar/messagebar-ios.less +36 -0
- package/components/messagebar/messagebar-md.less +96 -16
- package/components/messagebar/messagebar-rtl.css +1 -1
- package/components/messagebar/messagebar-vars.less +27 -50
- package/components/messagebar/messagebar.css +1 -1
- package/components/messagebar/messagebar.js +0 -8
- package/components/messagebar/messagebar.less +11 -42
- package/components/messages/messages-class.js +17 -110
- package/components/messages/messages-ios.less +9 -0
- package/components/messages/messages-md.less +63 -28
- package/components/messages/messages-rtl.css +1 -1
- package/components/messages/messages-vars.less +43 -50
- package/components/messages/messages.css +1 -1
- package/components/messages/messages.js +0 -8
- package/components/messages/messages.lazy.js +1 -1
- package/components/messages/messages.less +0 -11
- package/components/modal/custom-modal-class.js +4 -14
- package/components/modal/modal-class.js +19 -55
- package/components/modal/modal.js +0 -3
- package/components/navbar/navbar-ios.less +3 -39
- package/components/navbar/navbar-md.less +12 -0
- package/components/navbar/navbar-vars.less +20 -49
- package/components/navbar/navbar.d.ts +0 -2
- package/components/navbar/navbar.js +37 -166
- package/components/navbar/navbar.less +4 -26
- package/components/notification/notification-class.js +4 -39
- package/components/notification/notification-md.less +18 -8
- package/components/notification/notification-rtl.css +1 -1
- package/components/notification/notification-vars.less +15 -54
- package/components/notification/notification.css +1 -1
- package/components/notification/notification.js +0 -2
- package/components/notification/notification.lazy.js +1 -1
- package/components/notification/notification.less +0 -3
- package/components/page/page-md.less +40 -10
- package/components/page/page-transitions/circle.less +15 -9
- package/components/page/page-transitions/fade.less +17 -11
- package/components/page/page-transitions/flip.less +9 -4
- package/components/page/page-vars.less +3 -19
- package/components/page/page.less +2 -10
- package/components/panel/panel-class.js +23 -127
- package/components/panel/panel-md.less +9 -0
- package/components/panel/panel-rtl.css +1 -1
- package/components/panel/panel-vars.less +7 -21
- package/components/panel/panel.css +1 -1
- package/components/panel/panel.d.ts +2 -2
- package/components/panel/panel.js +0 -34
- package/components/panel/panel.lazy.js +1 -1
- package/components/panel/panel.less +56 -48
- package/components/panel/resizable-panel.js +2 -32
- package/components/panel/swipe-panel.js +16 -71
- package/components/photo-browser/photo-browser-class.js +41 -171
- package/components/photo-browser/photo-browser-rtl.css +1 -1
- package/components/photo-browser/photo-browser-vars.less +0 -3
- package/components/photo-browser/photo-browser.css +1 -1
- package/components/photo-browser/photo-browser.d.ts +2 -4
- package/components/photo-browser/photo-browser.js +1 -6
- package/components/photo-browser/photo-browser.lazy.js +1 -1
- package/components/photo-browser/photo-browser.less +0 -4
- package/components/picker/picker-class.js +26 -133
- package/components/picker/picker-column.js +11 -31
- package/components/picker/picker-ios.less +10 -0
- package/components/picker/picker-md.less +6 -0
- package/components/picker/picker-rtl.css +1 -1
- package/components/picker/picker-vars.less +9 -25
- package/components/picker/picker.css +1 -1
- package/components/picker/picker.js +0 -4
- package/components/picker/picker.lazy.js +1 -1
- package/components/picker/picker.less +0 -11
- package/components/pie-chart/pie-chart-class.js +8 -31
- package/components/pie-chart/pie-chart.js +0 -3
- package/components/pie-chart/pie-chart.less +0 -3
- package/components/popover/popover-class.js +72 -126
- package/components/popover/popover-ios.less +0 -50
- package/components/popover/popover-rtl.css +1 -1
- package/components/popover/popover-vars.less +6 -23
- package/components/popover/popover.css +1 -1
- package/components/popover/popover.d.ts +2 -0
- package/components/popover/popover.js +1 -12
- package/components/popover/popover.lazy.js +1 -1
- package/components/popover/popover.less +62 -5
- package/components/popup/popup-class.js +12 -78
- package/components/popup/popup-rtl.css +1 -1
- package/components/popup/popup-vars.less +7 -9
- package/components/popup/popup.css +1 -1
- package/components/popup/popup.js +0 -4
- package/components/popup/popup.lazy.js +1 -1
- package/components/popup/popup.less +4 -4
- package/components/preloader/preloader-ios.less +3 -1
- package/components/preloader/preloader-md.less +5 -1
- package/components/preloader/preloader-rtl.css +1 -1
- package/components/preloader/preloader-vars.less +0 -6
- package/components/preloader/preloader.css +1 -1
- package/components/preloader/preloader.js +8 -25
- package/components/preloader/preloader.lazy.js +1 -1
- package/components/preloader/preloader.less +6 -3
- package/components/progressbar/progressbar-rtl.css +1 -1
- package/components/progressbar/progressbar-vars.less +2 -12
- package/components/progressbar/progressbar.css +1 -1
- package/components/progressbar/progressbar.js +2 -31
- package/components/progressbar/progressbar.less +0 -3
- package/components/pull-to-refresh/pull-to-refresh-class.js +15 -107
- package/components/pull-to-refresh/pull-to-refresh-md.less +2 -1
- package/components/pull-to-refresh/pull-to-refresh-rtl.css +1 -1
- package/components/pull-to-refresh/pull-to-refresh-vars.less +0 -4
- package/components/pull-to-refresh/pull-to-refresh.css +1 -1
- package/components/pull-to-refresh/pull-to-refresh.js +0 -8
- package/components/pull-to-refresh/pull-to-refresh.lazy.js +1 -1
- package/components/pull-to-refresh/pull-to-refresh.less +0 -3
- package/components/radio/radio-rtl.css +1 -1
- package/components/radio/radio-vars.less +0 -7
- package/components/radio/radio.css +1 -1
- package/components/radio/radio.less +12 -5
- package/components/range/range-class.js +27 -112
- package/components/range/range-rtl.css +1 -1
- package/components/range/range-vars.less +10 -32
- package/components/range/range.css +1 -1
- package/components/range/range.js +0 -12
- package/components/range/range.less +0 -3
- package/components/searchbar/remove-diacritics.js +0 -4
- package/components/searchbar/searchbar-class.js +17 -138
- package/components/searchbar/searchbar-md.less +41 -16
- package/components/searchbar/searchbar-rtl.css +1 -1
- package/components/searchbar/searchbar-vars.less +25 -76
- package/components/searchbar/searchbar.css +1 -1
- package/components/searchbar/searchbar.d.ts +2 -2
- package/components/searchbar/searchbar.js +0 -15
- package/components/searchbar/searchbar.lazy.js +1 -1
- package/components/searchbar/searchbar.less +14 -28
- package/components/sheet/sheet-class.js +15 -110
- package/components/sheet/sheet-rtl.css +1 -1
- package/components/sheet/sheet-vars.less +17 -6
- package/components/sheet/sheet.css +1 -1
- package/components/sheet/sheet.js +0 -9
- package/components/sheet/sheet.lazy.js +1 -1
- package/components/sheet/sheet.less +10 -3
- package/components/skeleton/skeleton.less +1 -4
- package/components/smart-select/smart-select-class.js +36 -173
- package/components/smart-select/smart-select.d.ts +1 -3
- package/components/smart-select/smart-select.js +1 -14
- package/components/smart-select/smart-select.lazy.js +1 -1
- package/components/smart-select/smart-select.less +0 -3
- package/components/sortable/sortable-rtl.css +1 -1
- package/components/sortable/sortable-vars.less +8 -8
- package/components/sortable/sortable.css +1 -1
- package/components/sortable/sortable.js +0 -44
- package/components/sortable/sortable.less +0 -3
- package/components/statusbar/statusbar.js +0 -36
- package/components/statusbar/statusbar.less +0 -3
- package/components/stepper/stepper-class.js +10 -83
- package/components/stepper/stepper-rtl.css +1 -1
- package/components/stepper/stepper-vars.less +12 -24
- package/components/stepper/stepper.css +1 -1
- package/components/stepper/stepper.js +0 -12
- package/components/stepper/stepper.less +12 -23
- package/components/subnavbar/subnavbar-vars.less +3 -18
- package/components/subnavbar/subnavbar.js +0 -3
- package/components/subnavbar/subnavbar.less +1 -11
- package/components/swipeout/swipeout-rtl.css +1 -1
- package/components/swipeout/swipeout-vars.less +7 -6
- package/components/swipeout/swipeout.css +1 -1
- package/components/swipeout/swipeout.js +2 -99
- package/components/swipeout/swipeout.less +2 -7
- package/components/swiper/swiper-rtl.css +1 -1
- package/components/swiper/swiper.css +1 -1
- package/components/swiper/swiper.js +9 -30
- package/components/swiper/swiper.lazy.js +1 -1
- package/components/swiper/swiper.less +1 -16
- package/components/tabs/tabs-rtl.css +1 -1
- package/components/tabs/tabs.css +1 -1
- package/components/tabs/tabs.js +23 -60
- package/components/tabs/tabs.lazy.js +1 -1
- package/components/tabs/tabs.less +1 -3
- package/components/text-editor/text-editor-class.js +16 -102
- package/components/text-editor/text-editor-rtl.css +1 -1
- package/components/text-editor/text-editor-vars.less +12 -16
- package/components/text-editor/text-editor.css +1 -1
- package/components/text-editor/text-editor.js +0 -8
- package/components/text-editor/text-editor.lazy.js +1 -1
- package/components/text-editor/text-editor.less +0 -6
- package/components/timeline/timeline-rtl.css +1 -1
- package/components/timeline/timeline-vars.less +13 -47
- package/components/timeline/timeline.css +1 -1
- package/components/timeline/timeline.less +2 -9
- package/components/toast/toast-class.js +2 -16
- package/components/toast/toast-rtl.css +1 -1
- package/components/toast/toast-vars.less +5 -9
- package/components/toast/toast.css +1 -1
- package/components/toast/toast.js +0 -3
- package/components/toast/toast.less +0 -3
- package/components/toggle/toggle-class.js +6 -30
- package/components/toggle/toggle-ios.less +5 -1
- package/components/toggle/toggle-md.less +27 -11
- package/components/toggle/toggle-rtl.css +1 -1
- package/components/toggle/toggle-vars.less +19 -21
- package/components/toggle/toggle.css +1 -1
- package/components/toggle/toggle.js +0 -8
- package/components/toggle/toggle.less +0 -4
- package/components/toolbar/toolbar-ios.less +2 -2
- package/components/toolbar/toolbar-md.less +28 -4
- package/components/toolbar/toolbar-vars.less +17 -52
- package/components/toolbar/toolbar.js +5 -43
- package/components/toolbar/toolbar.less +27 -45
- package/components/tooltip/tooltip-class.js +10 -64
- package/components/tooltip/tooltip-rtl.css +1 -1
- package/components/tooltip/tooltip-vars.less +12 -3
- package/components/tooltip/tooltip.css +1 -1
- package/components/tooltip/tooltip.js +0 -15
- package/components/tooltip/tooltip.less +0 -3
- package/components/touch-ripple/touch-ripple-class.js +0 -13
- package/components/touch-ripple/touch-ripple.js +0 -4
- package/components/touch-ripple/touch-ripple.less +1 -5
- package/components/treeview/treeview-rtl.css +1 -1
- package/components/treeview/treeview-vars.less +0 -3
- package/components/treeview/treeview.css +1 -1
- package/components/treeview/treeview.js +2 -11
- package/components/treeview/treeview.lazy.js +1 -1
- package/components/treeview/treeview.less +0 -3
- package/components/typography/typography-rtl.css +1 -1
- package/components/typography/typography.css +1 -1
- package/components/typography/typography.less +25 -3
- package/components/view/resizable-view.js +2 -24
- package/components/view/view-class.js +28 -53
- package/components/view/view.d.ts +0 -14
- package/components/view/view.js +8 -32
- package/components/view/view.less +1 -4
- package/components/virtual-list/virtual-list-class.js +58 -146
- package/components/virtual-list/virtual-list.d.ts +1 -1
- package/components/virtual-list/virtual-list.js +0 -2
- package/components/virtual-list/virtual-list.lazy.js +1 -1
- package/components/virtual-list/virtual-list.less +0 -3
- package/framework7-bundle-rtl.css +3593 -5977
- package/framework7-bundle-rtl.min.css +3 -3
- package/framework7-bundle.css +3591 -5978
- package/framework7-bundle.esm.js +4 -10
- package/framework7-bundle.js +6063 -12044
- package/framework7-bundle.js.map +1 -1
- package/framework7-bundle.less +2 -27
- package/framework7-bundle.min.css +3 -3
- package/framework7-bundle.min.js +3 -3
- package/framework7-bundle.min.js.map +1 -1
- package/framework7-lite-bundle.esm.js +4 -10
- package/framework7-lite.esm.js +4 -6
- package/framework7-lite.js +31 -0
- package/framework7-rtl.css +803 -1591
- package/framework7-rtl.min.css +3 -3
- package/framework7-types.d.ts +1 -32
- package/framework7.css +803 -1594
- package/framework7.d.ts +1 -32
- package/framework7.esm.js +4 -6
- package/framework7.js +1770 -3407
- package/framework7.js.map +1 -1
- package/framework7.less +2 -23
- package/framework7.min.css +3 -3
- package/framework7.min.js +3 -3
- package/framework7.min.js.map +1 -1
- package/less/mixins.less +7 -88
- package/less/plugin.js +15 -0
- package/modules/clicks/clicks.js +10 -22
- package/modules/component/$h.js +0 -3
- package/modules/component/$jsx.js +0 -5
- package/modules/component/component-class.js +13 -66
- package/modules/component/component.d.ts +1 -2
- package/modules/component/component.js +0 -8
- package/modules/component/eventslisteners.js +12 -20
- package/modules/component/parse-component.js +18 -20
- package/modules/component/snabbdom/h.js +3 -12
- package/modules/component/snabbdom/helpers/attachto.js +9 -14
- package/modules/component/snabbdom/htmldomapi.js +0 -16
- package/modules/component/snabbdom/modules/attributes.js +7 -11
- package/modules/component/snabbdom/modules/class.js +4 -8
- package/modules/component/snabbdom/modules/dataset.js +3 -7
- package/modules/component/snabbdom/modules/eventlisteners.js +16 -22
- package/modules/component/snabbdom/modules/hero.js +4 -44
- package/modules/component/snabbdom/modules/props.js +5 -9
- package/modules/component/snabbdom/modules/style.js +13 -30
- package/modules/component/snabbdom/snabbdom.bundle.js +0 -6
- package/modules/component/snabbdom/snabbdom.js +13 -72
- package/modules/component/snabbdom/thunk.js +3 -11
- package/modules/component/snabbdom/tovnode.js +1 -6
- package/modules/component/vdom.js +4 -62
- package/modules/demo-module.js +0 -8
- package/modules/device/device.js +6 -11
- package/modules/history/history.js +0 -1
- package/modules/resize/resize.js +8 -11
- package/modules/router/async-component.js +0 -3
- package/modules/router/back.js +86 -275
- package/modules/router/clear-previous-history.js +5 -18
- package/modules/router/component-loader.js +4 -25
- package/modules/router/modal.js +16 -43
- package/modules/router/navigate.js +80 -249
- package/modules/router/process-route-queue.js +0 -12
- package/modules/router/redirect.js +0 -8
- package/modules/router/router-class.js +92 -315
- package/modules/router/router.d.ts +3 -5
- package/modules/router/router.js +0 -3
- package/modules/router/swipe-back.js +35 -139
- package/modules/router/tab.js +14 -43
- package/modules/service-worker/service-worker.js +0 -11
- package/modules/store/create-store.js +10 -29
- package/modules/touch/touch.d.ts +2 -4
- package/modules/touch/touch.js +13 -108
- package/package.json +4 -18
- package/shared/$jsx.js +0 -6
- package/shared/class.js +18 -43
- package/shared/constructor-methods.js +0 -11
- package/shared/events-class.js +0 -17
- package/shared/get-device.js +18 -34
- package/shared/get-support.js +2 -8
- package/shared/history.js +2 -30
- package/shared/material-color-utils.js +728 -0
- package/shared/material-colors.js +75 -0
- package/shared/modal-methods.js +0 -18
- package/shared/utils.d.ts +0 -4
- package/shared/utils.js +191 -71
- package/components/accordion/accordion-aurora.less +0 -2
- package/components/actions/actions-aurora.less +0 -9
- package/components/app/app-aurora.less +0 -10
- package/components/appbar/appbar-aurora.less +0 -2
- package/components/appbar/appbar-ios.less +0 -2
- package/components/appbar/appbar-md.less +0 -2
- package/components/appbar/appbar-rtl.css +0 -1
- package/components/appbar/appbar-vars.less +0 -28
- package/components/appbar/appbar.css +0 -1
- package/components/appbar/appbar.d.ts +0 -14
- package/components/appbar/appbar.js +0 -3
- package/components/appbar/appbar.lazy.js +0 -1
- package/components/appbar/appbar.less +0 -106
- package/components/area-chart/area-chart-aurora.less +0 -2
- package/components/autocomplete/autocomplete-aurora.less +0 -17
- package/components/badge/badge-aurora.less +0 -2
- package/components/block/block-aurora.less +0 -2
- package/components/breadcrumbs/breadcrumbs-aurora.less +0 -2
- package/components/button/button-aurora.less +0 -25
- package/components/calendar/calendar-aurora.less +0 -2
- package/components/card/card-aurora.less +0 -2
- package/components/checkbox/checkbox-aurora.less +0 -39
- package/components/chip/chip-aurora.less +0 -14
- package/components/color-picker/color-picker-aurora.less +0 -2
- package/components/contacts-list/contacts-list-aurora.less +0 -2
- package/components/data-table/data-table-aurora.less +0 -64
- package/components/dialog/dialog-aurora.less +0 -112
- package/components/elevation/elevation-aurora.less +0 -2
- package/components/elevation/elevation-ios.less +0 -2
- package/components/elevation/elevation-md.less +0 -2
- package/components/elevation/elevation-rtl.css +0 -1
- package/components/elevation/elevation-vars.less +0 -51
- package/components/elevation/elevation.css +0 -1
- package/components/elevation/elevation.d.ts +0 -14
- package/components/elevation/elevation.js +0 -3
- package/components/elevation/elevation.lazy.js +0 -1
- package/components/elevation/elevation.less +0 -54
- package/components/fab/fab-aurora.less +0 -2
- package/components/form/form-aurora.less +0 -0
- package/components/gauge/gauge-aurora.less +0 -2
- package/components/grid/grid-aurora.less +0 -2
- package/components/icon/icon-aurora.less +0 -49
- package/components/infinite-scroll/infinite-scroll-aurora.less +0 -6
- package/components/input/input-aurora.less +0 -120
- package/components/lazy/lazy-aurora.less +0 -2
- package/components/lazy/lazy-ios.less +0 -2
- package/components/lazy/lazy-md.less +0 -2
- package/components/lazy/lazy-rtl.css +0 -1
- package/components/lazy/lazy.css +0 -1
- package/components/lazy/lazy.d.ts +0 -57
- package/components/lazy/lazy.js +0 -283
- package/components/lazy/lazy.lazy.js +0 -1
- package/components/lazy/lazy.less +0 -23
- package/components/link/link-aurora.less +0 -15
- package/components/list/list-aurora.less +0 -25
- package/components/list-index/list-index-aurora.less +0 -21
- package/components/login-screen/login-screen-aurora.less +0 -2
- package/components/menu/menu-aurora.less +0 -8
- package/components/menu/menu-ios.less +0 -2
- package/components/menu/menu-md.less +0 -2
- package/components/menu/menu-rtl.css +0 -1
- package/components/menu/menu-vars.less +0 -27
- package/components/menu/menu.css +0 -1
- package/components/menu/menu.d.ts +0 -32
- package/components/menu/menu.js +0 -87
- package/components/menu/menu.lazy.js +0 -1
- package/components/menu/menu.less +0 -232
- package/components/messagebar/messagebar-aurora.less +0 -53
- package/components/messages/messages-aurora.less +0 -137
- package/components/navbar/navbar-aurora.less +0 -70
- package/components/notification/notification-aurora.less +0 -59
- package/components/page/page-aurora.less +0 -49
- package/components/panel/panel-aurora.less +0 -2
- package/components/photo-browser/photo-browser-aurora.less +0 -2
- package/components/picker/picker-aurora.less +0 -2
- package/components/pie-chart/pie-chart-aurora.less +0 -2
- package/components/popover/popover-aurora.less +0 -56
- package/components/popup/popup-aurora.less +0 -2
- package/components/preloader/preloader-aurora.less +0 -53
- package/components/progressbar/progressbar-aurora.less +0 -72
- package/components/pull-to-refresh/pull-to-refresh-aurora.less +0 -122
- package/components/radio/radio-aurora.less +0 -86
- package/components/range/range-aurora.less +0 -9
- package/components/searchbar/searchbar-aurora.less +0 -86
- package/components/sheet/sheet-aurora.less +0 -2
- package/components/skeleton/skeleton-aurora.less +0 -2
- package/components/smart-select/smart-select-aurora.less +0 -2
- package/components/sortable/sortable-aurora.less +0 -7
- package/components/statusbar/statusbar-aurora.less +0 -2
- package/components/stepper/stepper-aurora.less +0 -32
- package/components/subnavbar/subnavbar-aurora.less +0 -51
- package/components/swipeout/swipeout-aurora.less +0 -2
- package/components/swiper/swiper-aurora.less +0 -2
- package/components/tabs/tabs-aurora.less +0 -2
- package/components/text-editor/text-editor-aurora.less +0 -9
- package/components/timeline/timeline-aurora.less +0 -7
- package/components/toast/toast-aurora.less +0 -64
- package/components/toggle/toggle-aurora.less +0 -26
- package/components/toolbar/toolbar-aurora.less +0 -43
- package/components/tooltip/tooltip-aurora.less +0 -2
- package/components/touch-ripple/touch-ripple-aurora.less +0 -2
- package/components/treeview/treeview-aurora.less +0 -31
- package/components/typography/typography-aurora.less +0 -2
- package/components/view/view-aurora.less +0 -2
- package/components/virtual-list/virtual-list-aurora.less +0 -2
- package/modules/request/request.d.ts +0 -15
- package/modules/request/request.js +0 -11
- package/postinstall.js +0 -3
- package/shared/request.d.ts +0 -115
- package/shared/request.js +0 -512
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
function signum(num) {
|
|
3
|
+
return num < 0 ? -1 : 0 === num ? 0 : 1;
|
|
4
|
+
}
|
|
5
|
+
function lerp(start, stop, amount) {
|
|
6
|
+
return (1 - amount) * start + amount * stop;
|
|
7
|
+
}
|
|
8
|
+
function clampInt(min, max, input) {
|
|
9
|
+
return input < min ? min : input > max ? max : input;
|
|
10
|
+
}
|
|
11
|
+
function sanitizeDegreesDouble(degrees) {
|
|
12
|
+
return (degrees %= 360) < 0 && (degrees += 360), degrees;
|
|
13
|
+
}
|
|
14
|
+
function rotationDirection(from, to) {
|
|
15
|
+
return sanitizeDegreesDouble(to - from) <= 180 ? 1 : -1;
|
|
16
|
+
}
|
|
17
|
+
function differenceDegrees(a, b) {
|
|
18
|
+
return 180 - Math.abs(Math.abs(a - b) - 180);
|
|
19
|
+
}
|
|
20
|
+
function matrixMultiply(row, matrix) {
|
|
21
|
+
return [row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2], row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2], row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2]];
|
|
22
|
+
}
|
|
23
|
+
const SRGB_TO_XYZ = [[.41233895, .35762064, .18051042], [.2126, .7152, .0722], [.01932141, .11916382, .95034478]],
|
|
24
|
+
XYZ_TO_SRGB = [[3.2413774792388685, -1.5376652402851851, -.49885366846268053], [-.9691452513005321, 1.8758853451067872, .04156585616912061], [.05562093689691305, -.20395524564742123, 1.0571799111220335]],
|
|
25
|
+
WHITE_POINT_D65 = [95.047, 100, 108.883];
|
|
26
|
+
function argbFromRgb(red, green, blue) {
|
|
27
|
+
return (255 << 24 | (255 & red) << 16 | (255 & green) << 8 | 255 & blue) >>> 0;
|
|
28
|
+
}
|
|
29
|
+
function argbFromLinrgb(linrgb) {
|
|
30
|
+
return argbFromRgb(delinearized(linrgb[0]), delinearized(linrgb[1]), delinearized(linrgb[2]));
|
|
31
|
+
}
|
|
32
|
+
function redFromArgb(argb) {
|
|
33
|
+
return argb >> 16 & 255;
|
|
34
|
+
}
|
|
35
|
+
function greenFromArgb(argb) {
|
|
36
|
+
return argb >> 8 & 255;
|
|
37
|
+
}
|
|
38
|
+
function blueFromArgb(argb) {
|
|
39
|
+
return 255 & argb;
|
|
40
|
+
}
|
|
41
|
+
function argbFromXyz(x, y, z) {
|
|
42
|
+
const matrix = XYZ_TO_SRGB,
|
|
43
|
+
linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z,
|
|
44
|
+
linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z,
|
|
45
|
+
linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;
|
|
46
|
+
return argbFromRgb(delinearized(linearR), delinearized(linearG), delinearized(linearB));
|
|
47
|
+
}
|
|
48
|
+
function xyzFromArgb(argb) {
|
|
49
|
+
return matrixMultiply([linearized(redFromArgb(argb)), linearized(greenFromArgb(argb)), linearized(blueFromArgb(argb))], SRGB_TO_XYZ);
|
|
50
|
+
}
|
|
51
|
+
function argbFromLstar(lstar) {
|
|
52
|
+
const component = delinearized(yFromLstar(lstar));
|
|
53
|
+
return argbFromRgb(component, component, component);
|
|
54
|
+
}
|
|
55
|
+
function lstarFromArgb(argb) {
|
|
56
|
+
return 116 * labF(xyzFromArgb(argb)[1] / 100) - 16;
|
|
57
|
+
}
|
|
58
|
+
function yFromLstar(lstar) {
|
|
59
|
+
return 100 * labInvf((lstar + 16) / 116);
|
|
60
|
+
}
|
|
61
|
+
function linearized(rgbComponent) {
|
|
62
|
+
const normalized = rgbComponent / 255;
|
|
63
|
+
return normalized <= .040449936 ? normalized / 12.92 * 100 : 100 * Math.pow((normalized + .055) / 1.055, 2.4);
|
|
64
|
+
}
|
|
65
|
+
function delinearized(rgbComponent) {
|
|
66
|
+
const normalized = rgbComponent / 100;
|
|
67
|
+
let delinearized = 0;
|
|
68
|
+
return delinearized = normalized <= .0031308 ? 12.92 * normalized : 1.055 * Math.pow(normalized, 1 / 2.4) - .055, clampInt(0, 255, Math.round(255 * delinearized));
|
|
69
|
+
}
|
|
70
|
+
function whitePointD65() {
|
|
71
|
+
return WHITE_POINT_D65;
|
|
72
|
+
}
|
|
73
|
+
function labF(t) {
|
|
74
|
+
return t > 216 / 24389 ? Math.pow(t, 1 / 3) : (903.2962962962963 * t + 16) / 116;
|
|
75
|
+
}
|
|
76
|
+
function labInvf(ft) {
|
|
77
|
+
const ft3 = ft * ft * ft;
|
|
78
|
+
return ft3 > 216 / 24389 ? ft3 : (116 * ft - 16) / 903.2962962962963;
|
|
79
|
+
}
|
|
80
|
+
class ViewingConditions {
|
|
81
|
+
constructor(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
|
|
82
|
+
this.n = n, this.aw = aw, this.nbb = nbb, this.ncb = ncb, this.c = c, this.nc = nc, this.rgbD = rgbD, this.fl = fl, this.fLRoot = fLRoot, this.z = z;
|
|
83
|
+
}
|
|
84
|
+
static make(whitePoint, adaptingLuminance, backgroundLstar, surround, discountingIlluminant) {
|
|
85
|
+
if (whitePoint === void 0) {
|
|
86
|
+
whitePoint = whitePointD65();
|
|
87
|
+
}
|
|
88
|
+
if (adaptingLuminance === void 0) {
|
|
89
|
+
adaptingLuminance = 200 / Math.PI * yFromLstar(50) / 100;
|
|
90
|
+
}
|
|
91
|
+
if (backgroundLstar === void 0) {
|
|
92
|
+
backgroundLstar = 50;
|
|
93
|
+
}
|
|
94
|
+
if (surround === void 0) {
|
|
95
|
+
surround = 2;
|
|
96
|
+
}
|
|
97
|
+
if (discountingIlluminant === void 0) {
|
|
98
|
+
discountingIlluminant = !1;
|
|
99
|
+
}
|
|
100
|
+
const xyz = whitePoint,
|
|
101
|
+
rW = .401288 * xyz[0] + .650173 * xyz[1] + -.051461 * xyz[2],
|
|
102
|
+
gW = -.250268 * xyz[0] + 1.204414 * xyz[1] + .045854 * xyz[2],
|
|
103
|
+
bW = -.002079 * xyz[0] + .048952 * xyz[1] + .953127 * xyz[2],
|
|
104
|
+
f = .8 + surround / 10,
|
|
105
|
+
c = f >= .9 ? lerp(.59, .69, 10 * (f - .9)) : lerp(.525, .59, 10 * (f - .8));
|
|
106
|
+
let d = discountingIlluminant ? 1 : f * (1 - 1 / 3.6 * Math.exp((-adaptingLuminance - 42) / 92));
|
|
107
|
+
d = d > 1 ? 1 : d < 0 ? 0 : d;
|
|
108
|
+
const nc = f,
|
|
109
|
+
rgbD = [d * (100 / rW) + 1 - d, d * (100 / gW) + 1 - d, d * (100 / bW) + 1 - d],
|
|
110
|
+
k = 1 / (5 * adaptingLuminance + 1),
|
|
111
|
+
k4 = k * k * k * k,
|
|
112
|
+
k4F = 1 - k4,
|
|
113
|
+
fl = k4 * adaptingLuminance + .1 * k4F * k4F * Math.cbrt(5 * adaptingLuminance),
|
|
114
|
+
n = yFromLstar(backgroundLstar) / whitePoint[1],
|
|
115
|
+
z = 1.48 + Math.sqrt(n),
|
|
116
|
+
nbb = .725 / Math.pow(n, .2),
|
|
117
|
+
ncb = nbb,
|
|
118
|
+
rgbAFactors = [Math.pow(fl * rgbD[0] * rW / 100, .42), Math.pow(fl * rgbD[1] * gW / 100, .42), Math.pow(fl * rgbD[2] * bW / 100, .42)],
|
|
119
|
+
rgbA = [400 * rgbAFactors[0] / (rgbAFactors[0] + 27.13), 400 * rgbAFactors[1] / (rgbAFactors[1] + 27.13), 400 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)];
|
|
120
|
+
return new ViewingConditions(n, (2 * rgbA[0] + rgbA[1] + .05 * rgbA[2]) * nbb, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, .25), z);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
ViewingConditions.DEFAULT = ViewingConditions.make();
|
|
124
|
+
class Cam16 {
|
|
125
|
+
constructor(hue, chroma, j, q, m, s, jstar, astar, bstar) {
|
|
126
|
+
this.hue = hue, this.chroma = chroma, this.j = j, this.q = q, this.m = m, this.s = s, this.jstar = jstar, this.astar = astar, this.bstar = bstar;
|
|
127
|
+
}
|
|
128
|
+
distance(other) {
|
|
129
|
+
const dJ = this.jstar - other.jstar,
|
|
130
|
+
dA = this.astar - other.astar,
|
|
131
|
+
dB = this.bstar - other.bstar,
|
|
132
|
+
dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
|
|
133
|
+
return 1.41 * Math.pow(dEPrime, .63);
|
|
134
|
+
}
|
|
135
|
+
static fromInt(argb) {
|
|
136
|
+
return Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);
|
|
137
|
+
}
|
|
138
|
+
static fromIntInViewingConditions(argb, viewingConditions) {
|
|
139
|
+
const green = (65280 & argb) >> 8,
|
|
140
|
+
blue = 255 & argb,
|
|
141
|
+
redL = linearized((16711680 & argb) >> 16),
|
|
142
|
+
greenL = linearized(green),
|
|
143
|
+
blueL = linearized(blue),
|
|
144
|
+
x = .41233895 * redL + .35762064 * greenL + .18051042 * blueL,
|
|
145
|
+
y = .2126 * redL + .7152 * greenL + .0722 * blueL,
|
|
146
|
+
z = .01932141 * redL + .11916382 * greenL + .95034478 * blueL,
|
|
147
|
+
rC = .401288 * x + .650173 * y - .051461 * z,
|
|
148
|
+
gC = -.250268 * x + 1.204414 * y + .045854 * z,
|
|
149
|
+
bC = -.002079 * x + .048952 * y + .953127 * z,
|
|
150
|
+
rD = viewingConditions.rgbD[0] * rC,
|
|
151
|
+
gD = viewingConditions.rgbD[1] * gC,
|
|
152
|
+
bD = viewingConditions.rgbD[2] * bC,
|
|
153
|
+
rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, .42),
|
|
154
|
+
gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, .42),
|
|
155
|
+
bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, .42),
|
|
156
|
+
rA = 400 * signum(rD) * rAF / (rAF + 27.13),
|
|
157
|
+
gA = 400 * signum(gD) * gAF / (gAF + 27.13),
|
|
158
|
+
bA = 400 * signum(bD) * bAF / (bAF + 27.13),
|
|
159
|
+
a = (11 * rA + -12 * gA + bA) / 11,
|
|
160
|
+
b = (rA + gA - 2 * bA) / 9,
|
|
161
|
+
u = (20 * rA + 20 * gA + 21 * bA) / 20,
|
|
162
|
+
p2 = (40 * rA + 20 * gA + bA) / 20,
|
|
163
|
+
atanDegrees = 180 * Math.atan2(b, a) / Math.PI,
|
|
164
|
+
hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees,
|
|
165
|
+
hueRadians = hue * Math.PI / 180,
|
|
166
|
+
ac = p2 * viewingConditions.nbb,
|
|
167
|
+
j = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z),
|
|
168
|
+
q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot,
|
|
169
|
+
huePrime = hue < 20.14 ? hue + 360 : hue,
|
|
170
|
+
t = 5e4 / 13 * (.25 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8)) * viewingConditions.nc * viewingConditions.ncb * Math.sqrt(a * a + b * b) / (u + .305),
|
|
171
|
+
alpha = Math.pow(t, .9) * Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73),
|
|
172
|
+
c = alpha * Math.sqrt(j / 100),
|
|
173
|
+
m = c * viewingConditions.fLRoot,
|
|
174
|
+
s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)),
|
|
175
|
+
jstar = (1 + 100 * .007) * j / (1 + .007 * j),
|
|
176
|
+
mstar = 1 / .0228 * Math.log(1 + .0228 * m),
|
|
177
|
+
astar = mstar * Math.cos(hueRadians),
|
|
178
|
+
bstar = mstar * Math.sin(hueRadians);
|
|
179
|
+
return new Cam16(hue, c, j, q, m, s, jstar, astar, bstar);
|
|
180
|
+
}
|
|
181
|
+
static fromJch(j, c, h) {
|
|
182
|
+
return Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);
|
|
183
|
+
}
|
|
184
|
+
static fromJchInViewingConditions(j, c, h, viewingConditions) {
|
|
185
|
+
const q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot,
|
|
186
|
+
m = c * viewingConditions.fLRoot,
|
|
187
|
+
alpha = c / Math.sqrt(j / 100),
|
|
188
|
+
s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)),
|
|
189
|
+
hueRadians = h * Math.PI / 180,
|
|
190
|
+
jstar = (1 + 100 * .007) * j / (1 + .007 * j),
|
|
191
|
+
mstar = 1 / .0228 * Math.log(1 + .0228 * m),
|
|
192
|
+
astar = mstar * Math.cos(hueRadians),
|
|
193
|
+
bstar = mstar * Math.sin(hueRadians);
|
|
194
|
+
return new Cam16(h, c, j, q, m, s, jstar, astar, bstar);
|
|
195
|
+
}
|
|
196
|
+
static fromUcs(jstar, astar, bstar) {
|
|
197
|
+
return Cam16.fromUcsInViewingConditions(jstar, astar, bstar, ViewingConditions.DEFAULT);
|
|
198
|
+
}
|
|
199
|
+
static fromUcsInViewingConditions(jstar, astar, bstar, viewingConditions) {
|
|
200
|
+
const a = astar,
|
|
201
|
+
b = bstar,
|
|
202
|
+
m = Math.sqrt(a * a + b * b),
|
|
203
|
+
c = (Math.exp(.0228 * m) - 1) / .0228 / viewingConditions.fLRoot;
|
|
204
|
+
let h = Math.atan2(b, a) * (180 / Math.PI);
|
|
205
|
+
h < 0 && (h += 360);
|
|
206
|
+
const j = jstar / (1 - .007 * (jstar - 100));
|
|
207
|
+
return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
|
|
208
|
+
}
|
|
209
|
+
toInt() {
|
|
210
|
+
return this.viewed(ViewingConditions.DEFAULT);
|
|
211
|
+
}
|
|
212
|
+
viewed(viewingConditions) {
|
|
213
|
+
const alpha = 0 === this.chroma || 0 === this.j ? 0 : this.chroma / Math.sqrt(this.j / 100),
|
|
214
|
+
t = Math.pow(alpha / Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73), 1 / .9),
|
|
215
|
+
hRad = this.hue * Math.PI / 180,
|
|
216
|
+
eHue = .25 * (Math.cos(hRad + 2) + 3.8),
|
|
217
|
+
ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z),
|
|
218
|
+
p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb,
|
|
219
|
+
p2 = ac / viewingConditions.nbb,
|
|
220
|
+
hSin = Math.sin(hRad),
|
|
221
|
+
hCos = Math.cos(hRad),
|
|
222
|
+
gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin),
|
|
223
|
+
a = gamma * hCos,
|
|
224
|
+
b = gamma * hSin,
|
|
225
|
+
rA = (460 * p2 + 451 * a + 288 * b) / 1403,
|
|
226
|
+
gA = (460 * p2 - 891 * a - 261 * b) / 1403,
|
|
227
|
+
bA = (460 * p2 - 220 * a - 6300 * b) / 1403,
|
|
228
|
+
rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))),
|
|
229
|
+
rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / .42),
|
|
230
|
+
gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))),
|
|
231
|
+
gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / .42),
|
|
232
|
+
bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))),
|
|
233
|
+
bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / .42),
|
|
234
|
+
rF = rC / viewingConditions.rgbD[0],
|
|
235
|
+
gF = gC / viewingConditions.rgbD[1],
|
|
236
|
+
bF = bC / viewingConditions.rgbD[2];
|
|
237
|
+
return argbFromXyz(1.86206786 * rF - 1.01125463 * gF + .14918677 * bF, .38752654 * rF + .62144744 * gF - .00897398 * bF, -.0158415 * rF - .03412294 * gF + 1.04996444 * bF);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
class HctSolver {
|
|
241
|
+
static sanitizeRadians(angle) {
|
|
242
|
+
return (angle + 8 * Math.PI) % (2 * Math.PI);
|
|
243
|
+
}
|
|
244
|
+
static trueDelinearized(rgbComponent) {
|
|
245
|
+
const normalized = rgbComponent / 100;
|
|
246
|
+
let delinearized = 0;
|
|
247
|
+
return delinearized = normalized <= .0031308 ? 12.92 * normalized : 1.055 * Math.pow(normalized, 1 / 2.4) - .055, 255 * delinearized;
|
|
248
|
+
}
|
|
249
|
+
static chromaticAdaptation(component) {
|
|
250
|
+
const af = Math.pow(Math.abs(component), .42);
|
|
251
|
+
return 400 * signum(component) * af / (af + 27.13);
|
|
252
|
+
}
|
|
253
|
+
static hueOf(linrgb) {
|
|
254
|
+
const scaledDiscount = matrixMultiply(linrgb, HctSolver.SCALED_DISCOUNT_FROM_LINRGB),
|
|
255
|
+
rA = HctSolver.chromaticAdaptation(scaledDiscount[0]),
|
|
256
|
+
gA = HctSolver.chromaticAdaptation(scaledDiscount[1]),
|
|
257
|
+
bA = HctSolver.chromaticAdaptation(scaledDiscount[2]),
|
|
258
|
+
a = (11 * rA + -12 * gA + bA) / 11,
|
|
259
|
+
b = (rA + gA - 2 * bA) / 9;
|
|
260
|
+
return Math.atan2(b, a);
|
|
261
|
+
}
|
|
262
|
+
static areInCyclicOrder(a, b, c) {
|
|
263
|
+
return HctSolver.sanitizeRadians(b - a) < HctSolver.sanitizeRadians(c - a);
|
|
264
|
+
}
|
|
265
|
+
static intercept(source, mid, target) {
|
|
266
|
+
return (mid - source) / (target - source);
|
|
267
|
+
}
|
|
268
|
+
static lerpPoint(source, t, target) {
|
|
269
|
+
return [source[0] + (target[0] - source[0]) * t, source[1] + (target[1] - source[1]) * t, source[2] + (target[2] - source[2]) * t];
|
|
270
|
+
}
|
|
271
|
+
static setCoordinate(source, coordinate, target, axis) {
|
|
272
|
+
const t = HctSolver.intercept(source[axis], coordinate, target[axis]);
|
|
273
|
+
return HctSolver.lerpPoint(source, t, target);
|
|
274
|
+
}
|
|
275
|
+
static isBounded(x) {
|
|
276
|
+
return 0 <= x && x <= 100;
|
|
277
|
+
}
|
|
278
|
+
static nthVertex(y, n) {
|
|
279
|
+
const kR = HctSolver.Y_FROM_LINRGB[0],
|
|
280
|
+
kG = HctSolver.Y_FROM_LINRGB[1],
|
|
281
|
+
kB = HctSolver.Y_FROM_LINRGB[2],
|
|
282
|
+
coordA = n % 4 <= 1 ? 0 : 100,
|
|
283
|
+
coordB = n % 2 == 0 ? 0 : 100;
|
|
284
|
+
if (n < 4) {
|
|
285
|
+
const g = coordA,
|
|
286
|
+
b = coordB,
|
|
287
|
+
r = (y - g * kG - b * kB) / kR;
|
|
288
|
+
return HctSolver.isBounded(r) ? [r, g, b] : [-1, -1, -1];
|
|
289
|
+
}
|
|
290
|
+
if (n < 8) {
|
|
291
|
+
const b = coordA,
|
|
292
|
+
r = coordB,
|
|
293
|
+
g = (y - r * kR - b * kB) / kG;
|
|
294
|
+
return HctSolver.isBounded(g) ? [r, g, b] : [-1, -1, -1];
|
|
295
|
+
}
|
|
296
|
+
{
|
|
297
|
+
const r = coordA,
|
|
298
|
+
g = coordB,
|
|
299
|
+
b = (y - r * kR - g * kG) / kB;
|
|
300
|
+
return HctSolver.isBounded(b) ? [r, g, b] : [-1, -1, -1];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
static bisectToSegment(y, targetHue) {
|
|
304
|
+
let left = [-1, -1, -1],
|
|
305
|
+
right = left,
|
|
306
|
+
leftHue = 0,
|
|
307
|
+
rightHue = 0,
|
|
308
|
+
initialized = !1,
|
|
309
|
+
uncut = !0;
|
|
310
|
+
for (let n = 0; n < 12; n++) {
|
|
311
|
+
const mid = HctSolver.nthVertex(y, n);
|
|
312
|
+
if (mid[0] < 0) continue;
|
|
313
|
+
const midHue = HctSolver.hueOf(mid);
|
|
314
|
+
initialized ? (uncut || HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) && (uncut = !1, HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rightHue = midHue) : (left = mid, leftHue = midHue)) : (left = mid, right = mid, leftHue = midHue, rightHue = midHue, initialized = !0);
|
|
315
|
+
}
|
|
316
|
+
return [left, right];
|
|
317
|
+
}
|
|
318
|
+
static midpoint(a, b) {
|
|
319
|
+
return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
|
|
320
|
+
}
|
|
321
|
+
static criticalPlaneBelow(x) {
|
|
322
|
+
return Math.floor(x - .5);
|
|
323
|
+
}
|
|
324
|
+
static criticalPlaneAbove(x) {
|
|
325
|
+
return Math.ceil(x - .5);
|
|
326
|
+
}
|
|
327
|
+
static bisectToLimit(y, targetHue) {
|
|
328
|
+
const segment = HctSolver.bisectToSegment(y, targetHue);
|
|
329
|
+
let left = segment[0],
|
|
330
|
+
leftHue = HctSolver.hueOf(left),
|
|
331
|
+
right = segment[1];
|
|
332
|
+
for (let axis = 0; axis < 3; axis++) if (left[axis] !== right[axis]) {
|
|
333
|
+
let lPlane = -1,
|
|
334
|
+
rPlane = 255;
|
|
335
|
+
left[axis] < right[axis] ? (lPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(left[axis])), rPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(right[axis]))) : (lPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(left[axis])), rPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(right[axis])));
|
|
336
|
+
for (let i = 0; i < 8 && !(Math.abs(rPlane - lPlane) <= 1); i++) {
|
|
337
|
+
const mPlane = Math.floor((lPlane + rPlane) / 2),
|
|
338
|
+
midPlaneCoordinate = HctSolver.CRITICAL_PLANES[mPlane],
|
|
339
|
+
mid = HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis),
|
|
340
|
+
midHue = HctSolver.hueOf(mid);
|
|
341
|
+
HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rPlane = mPlane) : (left = mid, leftHue = midHue, lPlane = mPlane);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return HctSolver.midpoint(left, right);
|
|
345
|
+
}
|
|
346
|
+
static inverseChromaticAdaptation(adapted) {
|
|
347
|
+
const adaptedAbs = Math.abs(adapted),
|
|
348
|
+
base = Math.max(0, 27.13 * adaptedAbs / (400 - adaptedAbs));
|
|
349
|
+
return signum(adapted) * Math.pow(base, 1 / .42);
|
|
350
|
+
}
|
|
351
|
+
static findResultByJ(hueRadians, chroma, y) {
|
|
352
|
+
let j = 11 * Math.sqrt(y);
|
|
353
|
+
const viewingConditions = ViewingConditions.DEFAULT,
|
|
354
|
+
tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73),
|
|
355
|
+
p1 = .25 * (Math.cos(hueRadians + 2) + 3.8) * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb,
|
|
356
|
+
hSin = Math.sin(hueRadians),
|
|
357
|
+
hCos = Math.cos(hueRadians);
|
|
358
|
+
for (let iterationRound = 0; iterationRound < 5; iterationRound++) {
|
|
359
|
+
const jNormalized = j / 100,
|
|
360
|
+
alpha = 0 === chroma || 0 === j ? 0 : chroma / Math.sqrt(jNormalized),
|
|
361
|
+
t = Math.pow(alpha * tInnerCoeff, 1 / .9),
|
|
362
|
+
p2 = viewingConditions.aw * Math.pow(jNormalized, 1 / viewingConditions.c / viewingConditions.z) / viewingConditions.nbb,
|
|
363
|
+
gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin),
|
|
364
|
+
a = gamma * hCos,
|
|
365
|
+
b = gamma * hSin,
|
|
366
|
+
rA = (460 * p2 + 451 * a + 288 * b) / 1403,
|
|
367
|
+
gA = (460 * p2 - 891 * a - 261 * b) / 1403,
|
|
368
|
+
bA = (460 * p2 - 220 * a - 6300 * b) / 1403,
|
|
369
|
+
linrgb = matrixMultiply([HctSolver.inverseChromaticAdaptation(rA), HctSolver.inverseChromaticAdaptation(gA), HctSolver.inverseChromaticAdaptation(bA)], HctSolver.LINRGB_FROM_SCALED_DISCOUNT);
|
|
370
|
+
if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) return 0;
|
|
371
|
+
const kR = HctSolver.Y_FROM_LINRGB[0],
|
|
372
|
+
kG = HctSolver.Y_FROM_LINRGB[1],
|
|
373
|
+
kB = HctSolver.Y_FROM_LINRGB[2],
|
|
374
|
+
fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];
|
|
375
|
+
if (fnj <= 0) return 0;
|
|
376
|
+
if (4 === iterationRound || Math.abs(fnj - y) < .002) return linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01 ? 0 : argbFromLinrgb(linrgb);
|
|
377
|
+
j -= (fnj - y) * j / (2 * fnj);
|
|
378
|
+
}
|
|
379
|
+
return 0;
|
|
380
|
+
}
|
|
381
|
+
static solveToInt(hueDegrees, chroma, lstar) {
|
|
382
|
+
if (chroma < 1e-4 || lstar < 1e-4 || lstar > 99.9999) return argbFromLstar(lstar);
|
|
383
|
+
const hueRadians = (hueDegrees = sanitizeDegreesDouble(hueDegrees)) / 180 * Math.PI,
|
|
384
|
+
y = yFromLstar(lstar),
|
|
385
|
+
exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);
|
|
386
|
+
if (0 !== exactAnswer) return exactAnswer;
|
|
387
|
+
return argbFromLinrgb(HctSolver.bisectToLimit(y, hueRadians));
|
|
388
|
+
}
|
|
389
|
+
static solveToCam(hueDegrees, chroma, lstar) {
|
|
390
|
+
return Cam16.fromInt(HctSolver.solveToInt(hueDegrees, chroma, lstar));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
HctSolver.SCALED_DISCOUNT_FROM_LINRGB = [[.001200833568784504, .002389694492170889, .0002795742885861124], [.0005891086651375999, .0029785502573438758, .0003270666104008398], [.00010146692491640572, .0005364214359186694, .0032979401770712076]], HctSolver.LINRGB_FROM_SCALED_DISCOUNT = [[1373.2198709594231, -1100.4251190754821, -7.278681089101213], [-271.815969077903, 559.6580465940733, -32.46047482791194], [1.9622899599665666, -57.173814538844006, 308.7233197812385]], HctSolver.Y_FROM_LINRGB = [.2126, .7152, .0722], HctSolver.CRITICAL_PLANES = [.015176349177441876, .045529047532325624, .07588174588720938, .10623444424209313, .13658714259697685, .16693984095186062, .19729253930674434, .2276452376616281, .2579979360165119, .28835063437139563, .3188300904430532, .350925934958123, .3848314933096426, .42057480301049466, .458183274052838, .4976837250274023, .5391024159806381, .5824650784040898, .6277969426914107, .6751227633498623, .7244668422128921, .775853049866786, .829304845476233, .8848452951698498, .942497089126609, 1.0022825574869039, 1.0642236851973577, 1.1283421258858297, 1.1946592148522128, 1.2631959812511864, 1.3339731595349034, 1.407011200216447, 1.4823302800086415, 1.5599503113873272, 1.6398909516233677, 1.7221716113234105, 1.8068114625156377, 1.8938294463134073, 1.9832442801866852, 2.075074464868551, 2.1693382909216234, 2.2660538449872063, 2.36523901573795, 2.4669114995532007, 2.5710888059345764, 2.6777882626779785, 2.7870270208169257, 2.898822059350997, 3.0131901897720907, 3.1301480604002863, 3.2497121605402226, 3.3718988244681087, 3.4967242352587946, 3.624204428461639, 3.754355295633311, 3.887192587735158, 4.022731918402185, 4.160988767090289, 4.301978482107941, 4.445716283538092, 4.592217266055746, 4.741496401646282, 4.893568542229298, 5.048448422192488, 5.20615066083972, 5.3666897647573375, 5.5300801301023865, 5.696336044816294, 5.865471690767354, 6.037501145825082, 6.212438385869475, 6.390297286737924, 6.571091626112461, 6.7548350853498045, 6.941541251256611, 7.131223617812143, 7.323895587840543, 7.5195704746346665, 7.7182615035334345, 7.919981813454504, 8.124744458384042, 8.332562408825165, 8.543448553206703, 8.757415699253682, 8.974476575321063, 9.194643831691977, 9.417930041841839, 9.644347703669503, 9.873909240696694, 10.106627003236781, 10.342513269534024, 10.58158024687427, 10.8238400726681, 11.069304815507364, 11.317986476196008, 11.569896988756009, 11.825048221409341, 12.083451977536606, 12.345119996613247, 12.610063955123938, 12.878295467455942, 13.149826086772048, 13.42466730586372, 13.702830557985108, 13.984327217668513, 14.269168601521828, 14.55736596900856, 14.848930523210871, 15.143873411576273, 15.44220572664832, 15.743938506781891, 16.04908273684337, 16.35764934889634, 16.66964922287304, 16.985093187232053, 17.30399201960269, 17.62635644741625, 17.95219714852476, 18.281524751807332, 18.614349837764564, 18.95068293910138, 19.290534541298456, 19.633915083172692, 19.98083495742689, 20.331304511189067, 20.685334046541502, 21.042933821039977, 21.404114048223256, 21.76888489811322, 22.137256497705877, 22.50923893145328, 22.884842241736916, 23.264076429332462, 23.6469514538663, 24.033477234264016, 24.42366364919083, 24.817520537484558, 25.21505769858089, 25.61628489293138, 26.021211842414342, 26.429848230738664, 26.842203703840827, 27.258287870275353, 27.678110301598522, 28.10168053274597, 28.529008062403893, 28.96010235337422, 29.39497283293396, 29.83362889318845, 30.276079891419332, 30.722335150426627, 31.172403958865512, 31.62629557157785, 32.08401920991837, 32.54558406207592, 33.010999283389665, 33.4802739966603, 33.953417292456834, 34.430438229418264, 34.911345834551085, 35.39614910352207, 35.88485700094671, 36.37747846067349, 36.87402238606382, 37.37449765026789, 37.87891309649659, 38.38727753828926, 38.89959975977785, 39.41588851594697, 39.93615253289054, 40.460400508064545, 40.98864111053629, 41.520882981230194, 42.05713473317016, 42.597404951718396, 43.141702194811224, 43.6900349931913, 44.24241185063697, 44.798841244188324, 45.35933162437017, 45.92389141541209, 46.49252901546552, 47.065252796817916, 47.64207110610409, 48.22299226451468, 48.808024568002054, 49.3971762874833, 49.9904556690408, 50.587870934119984, 51.189430279724725, 51.79514187861014, 52.40501387947288, 53.0190544071392, 53.637271562750364, 54.259673423945976, 54.88626804504493, 55.517063457223934, 56.15206766869424, 56.79128866487574, 57.43473440856916, 58.08241284012621, 58.734331877617365, 59.39049941699807, 60.05092333227251, 60.715611475655585, 61.38457167773311, 62.057811747619894, 62.7353394731159, 63.417162620860914, 64.10328893648692, 64.79372614476921, 65.48848194977529, 66.18756403501224, 66.89098006357258, 67.59873767827808, 68.31084450182222, 69.02730813691093, 69.74813616640164, 70.47333615344107, 71.20291564160104, 71.93688215501312, 72.67524319850172, 73.41800625771542, 74.16517879925733, 74.9167682708136, 75.67278210128072, 76.43322770089146, 77.1981124613393, 77.96744375590167, 78.74122893956174, 79.51947534912904, 80.30219030335869, 81.08938110306934, 81.88105503125999, 82.67721935322541, 83.4778813166706, 84.28304815182372, 85.09272707154808, 85.90692527145302, 86.72564993000343, 87.54890820862819, 88.3767072518277, 89.2090541872801, 90.04595612594655, 90.88742016217518, 91.73345337380438, 92.58406282226491, 93.43925555268066, 94.29903859396902, 95.16341895893969, 96.03240364439274, 96.9059996312159, 97.78421388448044, 98.6670533535366, 99.55452497210776];
|
|
394
|
+
class Hct {
|
|
395
|
+
constructor(argb) {
|
|
396
|
+
this.argb = argb;
|
|
397
|
+
const cam = Cam16.fromInt(argb);
|
|
398
|
+
this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
|
|
399
|
+
}
|
|
400
|
+
static from(hue, chroma, tone) {
|
|
401
|
+
return new Hct(HctSolver.solveToInt(hue, chroma, tone));
|
|
402
|
+
}
|
|
403
|
+
static fromInt(argb) {
|
|
404
|
+
return new Hct(argb);
|
|
405
|
+
}
|
|
406
|
+
toInt() {
|
|
407
|
+
return this.argb;
|
|
408
|
+
}
|
|
409
|
+
get hue() {
|
|
410
|
+
return this.internalHue;
|
|
411
|
+
}
|
|
412
|
+
set hue(newHue) {
|
|
413
|
+
this.setInternalState(HctSolver.solveToInt(newHue, this.internalChroma, this.internalTone));
|
|
414
|
+
}
|
|
415
|
+
get chroma() {
|
|
416
|
+
return this.internalChroma;
|
|
417
|
+
}
|
|
418
|
+
set chroma(newChroma) {
|
|
419
|
+
this.setInternalState(HctSolver.solveToInt(this.internalHue, newChroma, this.internalTone));
|
|
420
|
+
}
|
|
421
|
+
get tone() {
|
|
422
|
+
return this.internalTone;
|
|
423
|
+
}
|
|
424
|
+
set tone(newTone) {
|
|
425
|
+
this.setInternalState(HctSolver.solveToInt(this.internalHue, this.internalChroma, newTone));
|
|
426
|
+
}
|
|
427
|
+
setInternalState(argb) {
|
|
428
|
+
const cam = Cam16.fromInt(argb);
|
|
429
|
+
this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
class Blend {
|
|
433
|
+
static harmonize(designColor, sourceColor) {
|
|
434
|
+
const fromHct = Hct.fromInt(designColor),
|
|
435
|
+
toHct = Hct.fromInt(sourceColor),
|
|
436
|
+
differenceDegrees$1 = differenceDegrees(fromHct.hue, toHct.hue),
|
|
437
|
+
rotationDegrees = Math.min(.5 * differenceDegrees$1, 15),
|
|
438
|
+
outputHue = sanitizeDegreesDouble(fromHct.hue + rotationDegrees * rotationDirection(fromHct.hue, toHct.hue));
|
|
439
|
+
return Hct.from(outputHue, fromHct.chroma, fromHct.tone).toInt();
|
|
440
|
+
}
|
|
441
|
+
static hctHue(from, to, amount) {
|
|
442
|
+
const ucs = Blend.cam16Ucs(from, to, amount),
|
|
443
|
+
ucsCam = Cam16.fromInt(ucs),
|
|
444
|
+
fromCam = Cam16.fromInt(from);
|
|
445
|
+
return Hct.from(ucsCam.hue, fromCam.chroma, lstarFromArgb(from)).toInt();
|
|
446
|
+
}
|
|
447
|
+
static cam16Ucs(from, to, amount) {
|
|
448
|
+
const fromCam = Cam16.fromInt(from),
|
|
449
|
+
toCam = Cam16.fromInt(to),
|
|
450
|
+
fromJ = fromCam.jstar,
|
|
451
|
+
fromA = fromCam.astar,
|
|
452
|
+
fromB = fromCam.bstar,
|
|
453
|
+
jstar = fromJ + (toCam.jstar - fromJ) * amount,
|
|
454
|
+
astar = fromA + (toCam.astar - fromA) * amount,
|
|
455
|
+
bstar = fromB + (toCam.bstar - fromB) * amount;
|
|
456
|
+
return Cam16.fromUcs(jstar, astar, bstar).toInt();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
class TonalPalette {
|
|
460
|
+
constructor(hue, chroma) {
|
|
461
|
+
this.hue = hue, this.chroma = chroma, this.cache = new Map();
|
|
462
|
+
}
|
|
463
|
+
static fromInt(argb) {
|
|
464
|
+
const hct = Hct.fromInt(argb);
|
|
465
|
+
return TonalPalette.fromHueAndChroma(hct.hue, hct.chroma);
|
|
466
|
+
}
|
|
467
|
+
static fromHueAndChroma(hue, chroma) {
|
|
468
|
+
return new TonalPalette(hue, chroma);
|
|
469
|
+
}
|
|
470
|
+
tone(tone) {
|
|
471
|
+
let argb = this.cache.get(tone);
|
|
472
|
+
return void 0 === argb && (argb = Hct.from(this.hue, this.chroma, tone).toInt(), this.cache.set(tone, argb)), argb;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
class CorePalette {
|
|
476
|
+
constructor(argb, isContent) {
|
|
477
|
+
const hct = Hct.fromInt(argb),
|
|
478
|
+
hue = hct.hue,
|
|
479
|
+
chroma = hct.chroma;
|
|
480
|
+
isContent ? (this.a1 = TonalPalette.fromHueAndChroma(hue, chroma), this.a2 = TonalPalette.fromHueAndChroma(hue, chroma / 3), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, chroma / 2), this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12, 4)), this.n2 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 6, 8))) : (this.a1 = TonalPalette.fromHueAndChroma(hue, Math.max(48, chroma)), this.a2 = TonalPalette.fromHueAndChroma(hue, 16), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, 24), this.n1 = TonalPalette.fromHueAndChroma(hue, 4), this.n2 = TonalPalette.fromHueAndChroma(hue, 8)), this.error = TonalPalette.fromHueAndChroma(25, 84);
|
|
481
|
+
}
|
|
482
|
+
static of(argb) {
|
|
483
|
+
return new CorePalette(argb, !1);
|
|
484
|
+
}
|
|
485
|
+
static contentOf(argb) {
|
|
486
|
+
return new CorePalette(argb, !0);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
class Scheme {
|
|
490
|
+
constructor(props) {
|
|
491
|
+
this.props = props;
|
|
492
|
+
}
|
|
493
|
+
get primary() {
|
|
494
|
+
return this.props.primary;
|
|
495
|
+
}
|
|
496
|
+
get onPrimary() {
|
|
497
|
+
return this.props.onPrimary;
|
|
498
|
+
}
|
|
499
|
+
get primaryContainer() {
|
|
500
|
+
return this.props.primaryContainer;
|
|
501
|
+
}
|
|
502
|
+
get onPrimaryContainer() {
|
|
503
|
+
return this.props.onPrimaryContainer;
|
|
504
|
+
}
|
|
505
|
+
get secondary() {
|
|
506
|
+
return this.props.secondary;
|
|
507
|
+
}
|
|
508
|
+
get onSecondary() {
|
|
509
|
+
return this.props.onSecondary;
|
|
510
|
+
}
|
|
511
|
+
get secondaryContainer() {
|
|
512
|
+
return this.props.secondaryContainer;
|
|
513
|
+
}
|
|
514
|
+
get onSecondaryContainer() {
|
|
515
|
+
return this.props.onSecondaryContainer;
|
|
516
|
+
}
|
|
517
|
+
get tertiary() {
|
|
518
|
+
return this.props.tertiary;
|
|
519
|
+
}
|
|
520
|
+
get onTertiary() {
|
|
521
|
+
return this.props.onTertiary;
|
|
522
|
+
}
|
|
523
|
+
get tertiaryContainer() {
|
|
524
|
+
return this.props.tertiaryContainer;
|
|
525
|
+
}
|
|
526
|
+
get onTertiaryContainer() {
|
|
527
|
+
return this.props.onTertiaryContainer;
|
|
528
|
+
}
|
|
529
|
+
get error() {
|
|
530
|
+
return this.props.error;
|
|
531
|
+
}
|
|
532
|
+
get onError() {
|
|
533
|
+
return this.props.onError;
|
|
534
|
+
}
|
|
535
|
+
get errorContainer() {
|
|
536
|
+
return this.props.errorContainer;
|
|
537
|
+
}
|
|
538
|
+
get onErrorContainer() {
|
|
539
|
+
return this.props.onErrorContainer;
|
|
540
|
+
}
|
|
541
|
+
get background() {
|
|
542
|
+
return this.props.background;
|
|
543
|
+
}
|
|
544
|
+
get onBackground() {
|
|
545
|
+
return this.props.onBackground;
|
|
546
|
+
}
|
|
547
|
+
get surface() {
|
|
548
|
+
return this.props.surface;
|
|
549
|
+
}
|
|
550
|
+
get onSurface() {
|
|
551
|
+
return this.props.onSurface;
|
|
552
|
+
}
|
|
553
|
+
get surfaceVariant() {
|
|
554
|
+
return this.props.surfaceVariant;
|
|
555
|
+
}
|
|
556
|
+
get onSurfaceVariant() {
|
|
557
|
+
return this.props.onSurfaceVariant;
|
|
558
|
+
}
|
|
559
|
+
get outline() {
|
|
560
|
+
return this.props.outline;
|
|
561
|
+
}
|
|
562
|
+
get outlineVariant() {
|
|
563
|
+
return this.props.outlineVariant;
|
|
564
|
+
}
|
|
565
|
+
get shadow() {
|
|
566
|
+
return this.props.shadow;
|
|
567
|
+
}
|
|
568
|
+
get scrim() {
|
|
569
|
+
return this.props.scrim;
|
|
570
|
+
}
|
|
571
|
+
get inverseSurface() {
|
|
572
|
+
return this.props.inverseSurface;
|
|
573
|
+
}
|
|
574
|
+
get inverseOnSurface() {
|
|
575
|
+
return this.props.inverseOnSurface;
|
|
576
|
+
}
|
|
577
|
+
get inversePrimary() {
|
|
578
|
+
return this.props.inversePrimary;
|
|
579
|
+
}
|
|
580
|
+
static light(argb) {
|
|
581
|
+
return Scheme.lightFromCorePalette(CorePalette.of(argb));
|
|
582
|
+
}
|
|
583
|
+
static dark(argb) {
|
|
584
|
+
return Scheme.darkFromCorePalette(CorePalette.of(argb));
|
|
585
|
+
}
|
|
586
|
+
static lightContent(argb) {
|
|
587
|
+
return Scheme.lightFromCorePalette(CorePalette.contentOf(argb));
|
|
588
|
+
}
|
|
589
|
+
static darkContent(argb) {
|
|
590
|
+
return Scheme.darkFromCorePalette(CorePalette.contentOf(argb));
|
|
591
|
+
}
|
|
592
|
+
static lightFromCorePalette(core) {
|
|
593
|
+
return new Scheme({
|
|
594
|
+
primary: core.a1.tone(40),
|
|
595
|
+
onPrimary: core.a1.tone(100),
|
|
596
|
+
primaryContainer: core.a1.tone(90),
|
|
597
|
+
onPrimaryContainer: core.a1.tone(10),
|
|
598
|
+
secondary: core.a2.tone(40),
|
|
599
|
+
onSecondary: core.a2.tone(100),
|
|
600
|
+
secondaryContainer: core.a2.tone(90),
|
|
601
|
+
onSecondaryContainer: core.a2.tone(10),
|
|
602
|
+
tertiary: core.a3.tone(40),
|
|
603
|
+
onTertiary: core.a3.tone(100),
|
|
604
|
+
tertiaryContainer: core.a3.tone(90),
|
|
605
|
+
onTertiaryContainer: core.a3.tone(10),
|
|
606
|
+
error: core.error.tone(40),
|
|
607
|
+
onError: core.error.tone(100),
|
|
608
|
+
errorContainer: core.error.tone(90),
|
|
609
|
+
onErrorContainer: core.error.tone(10),
|
|
610
|
+
background: core.n1.tone(99),
|
|
611
|
+
onBackground: core.n1.tone(10),
|
|
612
|
+
surface: core.n1.tone(99),
|
|
613
|
+
onSurface: core.n1.tone(10),
|
|
614
|
+
surfaceVariant: core.n2.tone(90),
|
|
615
|
+
onSurfaceVariant: core.n2.tone(30),
|
|
616
|
+
outline: core.n2.tone(50),
|
|
617
|
+
outlineVariant: core.n2.tone(80),
|
|
618
|
+
shadow: core.n1.tone(0),
|
|
619
|
+
scrim: core.n1.tone(0),
|
|
620
|
+
inverseSurface: core.n1.tone(20),
|
|
621
|
+
inverseOnSurface: core.n1.tone(95),
|
|
622
|
+
inversePrimary: core.a1.tone(80)
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
static darkFromCorePalette(core) {
|
|
626
|
+
return new Scheme({
|
|
627
|
+
primary: core.a1.tone(80),
|
|
628
|
+
onPrimary: core.a1.tone(20),
|
|
629
|
+
primaryContainer: core.a1.tone(30),
|
|
630
|
+
onPrimaryContainer: core.a1.tone(90),
|
|
631
|
+
secondary: core.a2.tone(80),
|
|
632
|
+
onSecondary: core.a2.tone(20),
|
|
633
|
+
secondaryContainer: core.a2.tone(30),
|
|
634
|
+
onSecondaryContainer: core.a2.tone(90),
|
|
635
|
+
tertiary: core.a3.tone(80),
|
|
636
|
+
onTertiary: core.a3.tone(20),
|
|
637
|
+
tertiaryContainer: core.a3.tone(30),
|
|
638
|
+
onTertiaryContainer: core.a3.tone(90),
|
|
639
|
+
error: core.error.tone(80),
|
|
640
|
+
onError: core.error.tone(20),
|
|
641
|
+
errorContainer: core.error.tone(30),
|
|
642
|
+
onErrorContainer: core.error.tone(80),
|
|
643
|
+
background: core.n1.tone(10),
|
|
644
|
+
onBackground: core.n1.tone(90),
|
|
645
|
+
surface: core.n1.tone(10),
|
|
646
|
+
onSurface: core.n1.tone(90),
|
|
647
|
+
surfaceVariant: core.n2.tone(30),
|
|
648
|
+
onSurfaceVariant: core.n2.tone(80),
|
|
649
|
+
outline: core.n2.tone(60),
|
|
650
|
+
outlineVariant: core.n2.tone(30),
|
|
651
|
+
shadow: core.n1.tone(0),
|
|
652
|
+
scrim: core.n1.tone(0),
|
|
653
|
+
inverseSurface: core.n1.tone(90),
|
|
654
|
+
inverseOnSurface: core.n1.tone(20),
|
|
655
|
+
inversePrimary: core.a1.tone(40)
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
toJSON() {
|
|
659
|
+
return Object.assign({}, this.props);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
const hexFromArgb = argb => {
|
|
663
|
+
const r = redFromArgb(argb),
|
|
664
|
+
g = greenFromArgb(argb),
|
|
665
|
+
b = blueFromArgb(argb),
|
|
666
|
+
outParts = [r.toString(16), g.toString(16), b.toString(16)];
|
|
667
|
+
for (const [i, part] of outParts.entries()) 1 === part.length && (outParts[i] = "0" + part);
|
|
668
|
+
return "#" + outParts.join("");
|
|
669
|
+
},
|
|
670
|
+
argbFromHex = hex => {
|
|
671
|
+
const isThree = 3 === (hex = hex.replace("#", "")).length,
|
|
672
|
+
isSix = 6 === hex.length,
|
|
673
|
+
isEight = 8 === hex.length;
|
|
674
|
+
if (!isThree && !isSix && !isEight) throw new Error("unexpected hex " + hex);
|
|
675
|
+
let r = 0,
|
|
676
|
+
g = 0,
|
|
677
|
+
b = 0;
|
|
678
|
+
return isThree ? (r = parseIntHex(hex.slice(0, 1).repeat(2)), g = parseIntHex(hex.slice(1, 2).repeat(2)), b = parseIntHex(hex.slice(2, 3).repeat(2))) : isSix ? (r = parseIntHex(hex.slice(0, 2)), g = parseIntHex(hex.slice(2, 4)), b = parseIntHex(hex.slice(4, 6))) : isEight && (r = parseIntHex(hex.slice(2, 4)), g = parseIntHex(hex.slice(4, 6)), b = parseIntHex(hex.slice(6, 8))), (255 << 24 | (255 & r) << 16 | (255 & g) << 8 | 255 & b) >>> 0;
|
|
679
|
+
};
|
|
680
|
+
function parseIntHex(value) {
|
|
681
|
+
return parseInt(value, 16);
|
|
682
|
+
}
|
|
683
|
+
function themeFromSourceColor(source, customColors) {
|
|
684
|
+
if (customColors === void 0) {
|
|
685
|
+
customColors = [];
|
|
686
|
+
}
|
|
687
|
+
const palette = CorePalette.of(source);
|
|
688
|
+
return {
|
|
689
|
+
source: source,
|
|
690
|
+
schemes: {
|
|
691
|
+
light: Scheme.light(source),
|
|
692
|
+
dark: Scheme.dark(source)
|
|
693
|
+
},
|
|
694
|
+
palettes: {
|
|
695
|
+
primary: palette.a1,
|
|
696
|
+
secondary: palette.a2,
|
|
697
|
+
tertiary: palette.a3,
|
|
698
|
+
neutral: palette.n1,
|
|
699
|
+
neutralVariant: palette.n2,
|
|
700
|
+
error: palette.error
|
|
701
|
+
},
|
|
702
|
+
customColors: customColors.map(c => customColor(source, c))
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
function customColor(source, color) {
|
|
706
|
+
let value = color.value;
|
|
707
|
+
const from = value,
|
|
708
|
+
to = source;
|
|
709
|
+
color.blend && (value = Blend.harmonize(from, to));
|
|
710
|
+
const tones = CorePalette.of(value).a1;
|
|
711
|
+
return {
|
|
712
|
+
color: color,
|
|
713
|
+
value: value,
|
|
714
|
+
light: {
|
|
715
|
+
color: tones.tone(40),
|
|
716
|
+
onColor: tones.tone(100),
|
|
717
|
+
colorContainer: tones.tone(90),
|
|
718
|
+
onColorContainer: tones.tone(10)
|
|
719
|
+
},
|
|
720
|
+
dark: {
|
|
721
|
+
color: tones.tone(80),
|
|
722
|
+
onColor: tones.tone(20),
|
|
723
|
+
colorContainer: tones.tone(30),
|
|
724
|
+
onColorContainer: tones.tone(90)
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
export { argbFromHex, hexFromArgb, themeFromSourceColor };
|