@cube-dev/ui-kit 0.0.0-canary-9f74ccc → 0.0.0-canary-a93b304
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/dist/_internal/hooks/use-chained-callback.js +1 -1
- package/dist/_internal/hooks/use-debounced-value.js +1 -1
- package/dist/_internal/hooks/use-deprecation-warning.js +1 -1
- package/dist/_internal/hooks/use-event.js +1 -1
- package/dist/_internal/hooks/use-is-first-render.js +1 -1
- package/dist/_internal/hooks/use-sync-ref.js +1 -1
- package/dist/_internal/hooks/use-timer/timer.js +1 -1
- package/dist/_internal/hooks/use-timer/use-timer.js +1 -1
- package/dist/_internal/hooks/use-warn.js +1 -1
- package/dist/components/Block.js +1 -1
- package/dist/components/CollectionItem.js +1 -1
- package/dist/components/GlobalStyles.js +1 -1
- package/dist/components/GridProvider.js +1 -1
- package/dist/components/HiddenInput.js +1 -1
- package/dist/components/Root.js +1 -1
- package/dist/components/actions/Action/Action.js +1 -1
- package/dist/components/actions/Banner/Banner.js +1 -1
- package/dist/components/actions/Button/Button.d.ts +1 -0
- package/dist/components/actions/Button/Button.js +1 -1
- package/dist/components/actions/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/actions/ButtonSplit/ButtonSplit.js +1 -1
- package/dist/components/actions/ButtonSplit/context.js +1 -1
- package/dist/components/actions/CommandMenu/CommandMenu.js +1 -1
- package/dist/components/actions/CommandMenu/styled.js +1 -1
- package/dist/components/actions/ItemAction/ItemAction.js +1 -1
- package/dist/components/actions/ItemActionContext.js +1 -1
- package/dist/components/actions/ItemButton/ItemButton.js +1 -1
- package/dist/components/actions/Link/Link.js +1 -1
- package/dist/components/actions/Menu/Menu.js +1 -1
- package/dist/components/actions/Menu/MenuItem.js +1 -1
- package/dist/components/actions/Menu/MenuSection.js +1 -1
- package/dist/components/actions/Menu/MenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubMenuTrigger.js +1 -1
- package/dist/components/actions/Menu/SubmenuTriggerContext.js +1 -1
- package/dist/components/actions/Menu/context.js +1 -1
- package/dist/components/actions/Menu/styled.js +1 -1
- package/dist/components/actions/index.js +1 -1
- package/dist/components/actions/use-action.js +1 -1
- package/dist/components/actions/use-anchored-menu.js +1 -1
- package/dist/components/actions/use-context-menu.js +1 -1
- package/dist/components/content/ActiveZone/ActiveZone.js +1 -1
- package/dist/components/content/Alert/Alert.js +1 -1
- package/dist/components/content/Alert/use-alert.js +1 -1
- package/dist/components/content/Avatar/Avatar.js +1 -1
- package/dist/components/content/Badge/Badge.js +1 -1
- package/dist/components/content/Card/Card.js +1 -1
- package/dist/components/content/Content.js +1 -1
- package/dist/components/content/CopyPasteBlock/CopyPasteBlock.js +1 -1
- package/dist/components/content/CopySnippet/CopySnippet.js +1 -1
- package/dist/components/content/Disclosure/Disclosure.js +1 -1
- package/dist/components/content/Divider.js +1 -1
- package/dist/components/content/Footer.js +1 -1
- package/dist/components/content/Header.js +1 -1
- package/dist/components/content/HotKeys/HotKeys.js +1 -1
- package/dist/components/content/InfoBadge/InfoBadge.js +1 -1
- package/dist/components/content/InlineInput/InlineInput.js +1 -1
- package/dist/components/content/Item/Item.js +1 -1
- package/dist/components/content/ItemBadge/ItemBadge.js +1 -1
- package/dist/components/content/ItemCard/ItemCard.js +1 -1
- package/dist/components/content/Layout/GridLayout.js +1 -1
- package/dist/components/content/Layout/Layout.js +1 -1
- package/dist/components/content/Layout/LayoutBlock.js +1 -1
- package/dist/components/content/Layout/LayoutCenter.js +1 -1
- package/dist/components/content/Layout/LayoutContainer.js +1 -1
- package/dist/components/content/Layout/LayoutContent.js +1 -1
- package/dist/components/content/Layout/LayoutContext.js +1 -1
- package/dist/components/content/Layout/LayoutFlex.js +1 -1
- package/dist/components/content/Layout/LayoutFooter.js +1 -1
- package/dist/components/content/Layout/LayoutGrid.js +1 -1
- package/dist/components/content/Layout/LayoutHeader.js +1 -1
- package/dist/components/content/Layout/LayoutPane.js +1 -1
- package/dist/components/content/Layout/LayoutPanel.js +1 -1
- package/dist/components/content/Layout/LayoutPanelHeader.js +1 -1
- package/dist/components/content/Layout/LayoutToolbar.js +1 -1
- package/dist/components/content/Layout/hooks/useTinyScrollbar.js +1 -1
- package/dist/components/content/Layout/index.js +1 -1
- package/dist/components/content/Layout/utils.js +1 -1
- package/dist/components/content/Paragraph.js +1 -1
- package/dist/components/content/Placeholder/Placeholder.js +1 -1
- package/dist/components/content/PrismCode/PrismCode.js +1 -1
- package/dist/components/content/PrismCode/prismSetup.js +1 -1
- package/dist/components/content/PrismDiffCode/PrismDiffCode.js +1 -1
- package/dist/components/content/Result/Result.js +1 -1
- package/dist/components/content/Skeleton/Skeleton.js +1 -1
- package/dist/components/content/Tag/Tag.js +1 -1
- package/dist/components/content/Text.d.ts +14 -14
- package/dist/components/content/Text.js +1 -1
- package/dist/components/content/TextItem/TextItem.js +1 -1
- package/dist/components/content/Title.js +1 -1
- package/dist/components/content/Tree/Tree.js +1 -1
- package/dist/components/content/Tree/TreeNode.js +1 -1
- package/dist/components/content/Tree/styled.js +1 -1
- package/dist/components/content/Tree/tree-index.js +1 -1
- package/dist/components/content/Tree/use-checkbox-tree.js +1 -1
- package/dist/components/content/Tree/use-load-data.js +1 -1
- package/dist/components/content/highlightText.js +1 -1
- package/dist/components/content/use-auto-tooltip.js +1 -1
- package/dist/components/fields/Checkbox/Checkbox.js +1 -1
- package/dist/components/fields/Checkbox/CheckboxGroup.js +1 -1
- package/dist/components/fields/Checkbox/context.js +1 -1
- package/dist/components/fields/ComboBox/ComboBox.js +1 -1
- package/dist/components/fields/CommandTextArea/CommandTextArea.js +1 -1
- package/dist/components/fields/CommandTextArea/caretPosition.js +1 -1
- package/dist/components/fields/CommandTextArea/useCaretAnchor.js +1 -1
- package/dist/components/fields/DatePicker/DateInput.js +1 -1
- package/dist/components/fields/DatePicker/DateInputBase.js +1 -1
- package/dist/components/fields/DatePicker/DatePicker.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerButton.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerElement.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerInput.js +1 -1
- package/dist/components/fields/DatePicker/DatePickerSegment.js +1 -1
- package/dist/components/fields/DatePicker/DateRangePicker.js +1 -1
- package/dist/components/fields/DatePicker/DateRangeSeparatedPicker.js +1 -1
- package/dist/components/fields/DatePicker/MonthPicker.js +1 -1
- package/dist/components/fields/DatePicker/PeriodPicker.js +1 -1
- package/dist/components/fields/DatePicker/QuarterPicker.js +1 -1
- package/dist/components/fields/DatePicker/TimeInput.js +1 -1
- package/dist/components/fields/DatePicker/WeekPicker.js +1 -1
- package/dist/components/fields/DatePicker/YearPicker.js +1 -1
- package/dist/components/fields/DatePicker/parseDate.js +1 -1
- package/dist/components/fields/DatePicker/period.js +1 -1
- package/dist/components/fields/DatePicker/props.js +1 -1
- package/dist/components/fields/DatePicker/utils.js +1 -1
- package/dist/components/fields/FileInput/FileInput.js +1 -1
- package/dist/components/fields/FilterListBox/FilterListBox.js +1 -1
- package/dist/components/fields/FilterPicker/FilterPicker.js +1 -1
- package/dist/components/fields/Input/Input.js +1 -1
- package/dist/components/fields/ListBox/DraggableListBox.js +1 -1
- package/dist/components/fields/ListBox/ListBox.js +1 -1
- package/dist/components/fields/ListBoxPopover/ListBoxPopover.js +1 -1
- package/dist/components/fields/ListBoxPopover/index.d.ts +1 -0
- package/dist/components/fields/ListBoxPopover/listNavigation.js +1 -1
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.d.ts +2 -0
- package/dist/components/fields/ListBoxPopover/useCompositeFocus.js +1 -1
- package/dist/components/fields/NumberInput/NumberInput.js +1 -1
- package/dist/components/fields/NumberInput/StepButton.js +1 -1
- package/dist/components/fields/PasswordInput/PasswordInput.js +1 -1
- package/dist/components/fields/Picker/Picker.js +1 -1
- package/dist/components/fields/RadioGroup/Radio.js +1 -1
- package/dist/components/fields/RadioGroup/RadioGroup.js +1 -1
- package/dist/components/fields/RadioGroup/context.js +1 -1
- package/dist/components/fields/SearchComboBox/SearchComboBox.js +1 -1
- package/dist/components/fields/SearchInput/SearchInput.js +1 -1
- package/dist/components/fields/Select/Select.js +1 -1
- package/dist/components/fields/Slider/Gradation.js +1 -1
- package/dist/components/fields/Slider/HueSlider.js +1 -1
- package/dist/components/fields/Slider/RangeSlider.js +1 -1
- package/dist/components/fields/Slider/Slider.js +1 -1
- package/dist/components/fields/Slider/SliderBase.js +1 -1
- package/dist/components/fields/Slider/SliderThumb.js +1 -1
- package/dist/components/fields/Slider/SliderTrack.js +1 -1
- package/dist/components/fields/Slider/elements.js +1 -1
- package/dist/components/fields/Slider/index.js +1 -1
- package/dist/components/fields/Switch/Switch.js +1 -1
- package/dist/components/fields/TextArea/TextArea.js +1 -1
- package/dist/components/fields/TextInput/TextInput.js +1 -1
- package/dist/components/fields/TextInput/TextInputBase.js +1 -1
- package/dist/components/fields/TextInputMapper/TextInputMapper.js +1 -1
- package/dist/components/fields/index.d.ts +0 -4
- package/dist/components/form/FieldWrapper/FieldWrapper.js +1 -1
- package/dist/components/form/Form/Field.js +1 -1
- package/dist/components/form/Form/Form.js +1 -1
- package/dist/components/form/Form/ResetButton/ResetButton.js +1 -1
- package/dist/components/form/Form/SubmitButton/SubmitButton.js +1 -1
- package/dist/components/form/Form/SubmitError.js +1 -1
- package/dist/components/form/Form/index.js +1 -1
- package/dist/components/form/Form/use-field/use-field-props.js +1 -1
- package/dist/components/form/Form/use-field/use-field.js +1 -1
- package/dist/components/form/Form/use-form.js +1 -1
- package/dist/components/form/Form/validation.js +1 -1
- package/dist/components/form/Label.js +1 -1
- package/dist/components/form/validation/ValidationIndicator.js +1 -1
- package/dist/components/form/validation/resolve-validation-props.js +1 -1
- package/dist/components/form/validation/use-validation-props.js +1 -1
- package/dist/components/form/wrapper.js +1 -1
- package/dist/components/helpers/DisplayTransition/DisplayTransition.js +1 -1
- package/dist/components/helpers/IconSwitch/IconSwitch.js +1 -1
- package/dist/components/layout/Board/Board.d.ts +55 -1
- package/dist/components/layout/Board/Board.js +276 -74
- package/dist/components/layout/Board/Board.js.map +1 -1
- package/dist/components/layout/Board/BoardProvider.js +1 -1
- package/dist/components/layout/Board/BoardResponsive.js +1 -1
- package/dist/components/layout/Board/Widget.d.ts +16 -0
- package/dist/components/layout/Board/Widget.js +6 -3
- package/dist/components/layout/Board/Widget.js.map +1 -1
- package/dist/components/layout/Board/WidgetHost.js +85 -15
- package/dist/components/layout/Board/WidgetHost.js.map +1 -1
- package/dist/components/layout/Board/board-context.js +1 -1
- package/dist/components/layout/Board/board-context.js.map +1 -1
- package/dist/components/layout/Board/board-store.js +2 -2
- package/dist/components/layout/Board/board-store.js.map +1 -1
- package/dist/components/layout/Board/grid-core/calculate.js +1 -1
- package/dist/components/layout/Board/grid-core/collision.js +1 -1
- package/dist/components/layout/Board/grid-core/compactors.js +1 -1
- package/dist/components/layout/Board/grid-core/constraints.js +1 -1
- package/dist/components/layout/Board/grid-core/group-move.js +132 -0
- package/dist/components/layout/Board/grid-core/group-move.js.map +1 -0
- package/dist/components/layout/Board/grid-core/layout.js +1 -1
- package/dist/components/layout/Board/grid-core/sort.js +1 -1
- package/dist/components/layout/Board/index.d.ts +2 -1
- package/dist/components/layout/Board/index.js +2 -2
- package/dist/components/layout/Board/index.js.map +1 -1
- package/dist/components/layout/Board/responsive-utils.js +1 -1
- package/dist/components/layout/Board/use-board-layout.js +17 -12
- package/dist/components/layout/Board/use-board-layout.js.map +1 -1
- package/dist/components/layout/Board/use-board-registry.js +139 -20
- package/dist/components/layout/Board/use-board-registry.js.map +1 -1
- package/dist/components/layout/Board/use-board-select-modifier-key.js +24 -0
- package/dist/components/layout/Board/use-board-select-modifier-key.js.map +1 -0
- package/dist/components/layout/Board/use-board-selection.d.ts +8 -0
- package/dist/components/layout/Board/use-board-selection.js +113 -0
- package/dist/components/layout/Board/use-board-selection.js.map +1 -0
- package/dist/components/layout/Flex.js +1 -1
- package/dist/components/layout/Flow.js +1 -1
- package/dist/components/layout/Grid.js +1 -1
- package/dist/components/layout/Panel.js +1 -1
- package/dist/components/layout/Prefix.js +1 -1
- package/dist/components/layout/ResizablePanel.js +1 -1
- package/dist/components/layout/Space.js +1 -1
- package/dist/components/layout/Suffix.js +1 -1
- package/dist/components/navigation/Tabs/DraggableTabList.js +1 -1
- package/dist/components/navigation/Tabs/TabButton.js +1 -1
- package/dist/components/navigation/Tabs/TabDropIndicator.js +1 -1
- package/dist/components/navigation/Tabs/TabPanel.js +1 -1
- package/dist/components/navigation/Tabs/TabPicker.js +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +1 -1
- package/dist/components/navigation/Tabs/TabsAction.js +1 -1
- package/dist/components/navigation/Tabs/TabsContext.js +1 -1
- package/dist/components/navigation/Tabs/popover-placement.js +1 -1
- package/dist/components/navigation/Tabs/styled.js +1 -1
- package/dist/components/navigation/Tabs/types.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-editing.js +1 -1
- package/dist/components/navigation/Tabs/use-tab-indicator.js +1 -1
- package/dist/components/organisms/FileTabs/FileTabs.js +1 -1
- package/dist/components/organisms/StatsCard/StatsCard.js +1 -1
- package/dist/components/other/Calendar/Calendar.js +1 -1
- package/dist/components/other/Calendar/CalendarCell.js +1 -1
- package/dist/components/other/Calendar/CalendarGrid.js +1 -1
- package/dist/components/other/Calendar/PeriodCalendar.js +1 -1
- package/dist/components/other/Calendar/RangeCalendar.js +1 -1
- package/dist/components/other/CubeLogo/CubeLogo.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogApiProvider.js +1 -1
- package/dist/components/overlays/AlertDialog/AlertDialogZone.js +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +1 -1
- package/dist/components/overlays/Dialog/DialogContainer.js +1 -1
- package/dist/components/overlays/Dialog/DialogForm.js +1 -1
- package/dist/components/overlays/Dialog/DialogTrigger.js +1 -1
- package/dist/components/overlays/Dialog/context.js +1 -1
- package/dist/components/overlays/Dialog/use-dialog-container.js +1 -1
- package/dist/components/overlays/Modal/Modal.d.ts +2 -1
- package/dist/components/overlays/Modal/Modal.js +1 -1
- package/dist/components/overlays/Modal/OpenTransitionContext.js +1 -1
- package/dist/components/overlays/Modal/Overlay.d.ts +1 -0
- package/dist/components/overlays/Modal/Overlay.js +1 -1
- package/dist/components/overlays/Modal/Popover.js +1 -1
- package/dist/components/overlays/Modal/Tray.js +1 -1
- package/dist/components/overlays/Modal/Underlay.js +1 -1
- package/dist/components/overlays/Modal/types.d.ts +1 -0
- package/dist/components/overlays/Notifications/Notification.js +1 -1
- package/dist/components/overlays/Notifications/NotificationAction.js +1 -1
- package/dist/components/overlays/Notifications/NotificationCard.js +1 -1
- package/dist/components/overlays/Notifications/NotificationContext.d.ts +2 -0
- package/dist/components/overlays/Notifications/NotificationContext.js +1 -1
- package/dist/components/overlays/Notifications/NotificationItem.js +1 -1
- package/dist/components/overlays/Notifications/OverlayContainer.js +1 -1
- package/dist/components/overlays/Notifications/OverlayProvider.js +1 -1
- package/dist/components/overlays/Notifications/PersistentNotificationsList.js +1 -1
- package/dist/components/overlays/Notifications/dismissed-storage.js +1 -1
- package/dist/components/overlays/Notifications/format-relative-time.js +1 -1
- package/dist/components/overlays/Notifications/index.js +1 -1
- package/dist/components/overlays/Notifications/use-notification-state.js +1 -1
- package/dist/components/overlays/Notifications/use-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-overlay-timers.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-notifications.js +1 -1
- package/dist/components/overlays/Notifications/use-persistent-state.js +1 -1
- package/dist/components/overlays/Notifications/use-toast-state.js +1 -1
- package/dist/components/overlays/Toast/ToastItem.js +1 -1
- package/dist/components/overlays/Toast/index.js +1 -1
- package/dist/components/overlays/Toast/useProgressToast.js +1 -1
- package/dist/components/overlays/Toast/useToast.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipProvider.js +1 -1
- package/dist/components/overlays/Tooltip/TooltipTrigger.js +1 -1
- package/dist/components/overlays/Tooltip/context.js +1 -1
- package/dist/components/portal/Portal.js +1 -1
- package/dist/components/portal/PortalProvider.d.ts +2 -0
- package/dist/components/portal/PortalProvider.js +1 -1
- package/dist/components/portal/index.d.ts +1 -0
- package/dist/components/portal/usePortal.js +1 -1
- package/dist/components/shared/DraggableCollection.js +1 -1
- package/dist/components/shared/InvalidIcon.js +1 -1
- package/dist/components/shared/ValidIcon.js +1 -1
- package/dist/components/status/LoadingAnimation/LoadingAnimation.js +1 -1
- package/dist/components/status/Spin/Cube.js +1 -1
- package/dist/components/status/Spin/InternalSpinner.js +1 -1
- package/dist/components/status/Spin/Spin.js +1 -1
- package/dist/components/status/Spin/SpinsContainer.js +1 -1
- package/dist/data/item-themes.js +1 -1
- package/dist/data/themes.js +1 -1
- package/dist/eslint-plugin/defaults.generated.js +9 -1
- package/dist/eslint-plugin/defaults.generated.js.map +1 -1
- package/dist/eslint-plugin/index.js +1 -1
- package/dist/eslint-plugin/rules/no-redundant-default-prop.js +1 -1
- package/dist/i18n/I18nProvider.js +1 -1
- package/dist/i18n/createFormatter.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/instance.js +1 -1
- package/dist/i18n/locales/de-DE/uikit.js +9 -1
- package/dist/i18n/locales/en-US/uikit.js +9 -1
- package/dist/i18n/locales/en-US/uikit.json.d.ts +9 -1
- package/dist/i18n/locales/es-ES/uikit.js +9 -1
- package/dist/i18n/locales/es-MX/uikit.js +9 -1
- package/dist/i18n/locales/fr-FR/uikit.js +9 -1
- package/dist/i18n/locales/it-IT/uikit.js +9 -1
- package/dist/i18n/locales/ja-JP/uikit.js +9 -1
- package/dist/i18n/locales/nb-NO/uikit.js +9 -1
- package/dist/i18n/locales/pt-BR/uikit.js +9 -1
- package/dist/i18n/locales/pt-PT/uikit.js +9 -1
- package/dist/i18n/locales/sv-SE/uikit.js +9 -1
- package/dist/i18n/locales/vi-VN/uikit.js +9 -1
- package/dist/i18n/locales.js +1 -1
- package/dist/i18n/useFormatter.js +1 -1
- package/dist/i18n/useI18n.js +1 -1
- package/dist/icons/AdjustmentsHorizontalIcon.js +1 -1
- package/dist/icons/AdjustmentsIcon.js +1 -1
- package/dist/icons/AiIcon.js +1 -1
- package/dist/icons/AreaChartIcon.js +1 -1
- package/dist/icons/BackwardIcon.js +1 -1
- package/dist/icons/BarChartIcon.js +1 -1
- package/dist/icons/BellFilledIcon.js +1 -1
- package/dist/icons/BellIcon.js +1 -1
- package/dist/icons/BooleanIcon.js +1 -1
- package/dist/icons/CalendarEditIcon.js +1 -1
- package/dist/icons/CalendarIcon.js +1 -1
- package/dist/icons/CaretDownIcon.js +1 -1
- package/dist/icons/CaretUpIcon.js +1 -1
- package/dist/icons/ChartAreaStackedIcon.js +1 -1
- package/dist/icons/ChartAreaStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBarGroupedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarGroupedIcon.js +1 -1
- package/dist/icons/ChartBarHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarLineIcon.js +1 -1
- package/dist/icons/ChartBarStackedHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageHorizontalIcon.js +1 -1
- package/dist/icons/ChartBarStackedPercentageIcon.js +1 -1
- package/dist/icons/ChartBoxPlot2Icon.js +1 -1
- package/dist/icons/ChartBoxPlotIcon.js +1 -1
- package/dist/icons/ChartBubbleIcon.js +1 -1
- package/dist/icons/ChartDonut2Icon.js +1 -1
- package/dist/icons/ChartFunnelIcon.js +1 -1
- package/dist/icons/ChartHeatmapIcon.js +1 -1
- package/dist/icons/ChartKPIIcon.js +1 -1
- package/dist/icons/ChartPie2Icon.js +1 -1
- package/dist/icons/ChartScatterIcon.js +1 -1
- package/dist/icons/CheckCircleFilledIcon.js +1 -1
- package/dist/icons/CheckCircleIcon.js +1 -1
- package/dist/icons/CheckIcon.js +1 -1
- package/dist/icons/CircleFilledIcon.js +1 -1
- package/dist/icons/ClearIcon.js +1 -1
- package/dist/icons/CloseCircleFilledIcon.js +1 -1
- package/dist/icons/CloseCircleIcon.js +1 -1
- package/dist/icons/CloseIcon.js +1 -1
- package/dist/icons/CodeIcon.js +1 -1
- package/dist/icons/ColumnTotalIcon.js +1 -1
- package/dist/icons/CopyIcon.js +1 -1
- package/dist/icons/CountIcon.js +1 -1
- package/dist/icons/CubeIcon.js +1 -1
- package/dist/icons/CubePauseIcon.js +1 -1
- package/dist/icons/CubePlayIcon.js +1 -1
- package/dist/icons/CurrencyDollarIcon.js +1 -1
- package/dist/icons/DangerIcon.js +1 -1
- package/dist/icons/DashboardIcon.js +1 -1
- package/dist/icons/DatabaseIcon.js +1 -1
- package/dist/icons/DecimalDecreaseIcon.js +1 -1
- package/dist/icons/DecimalIncreaseIcon.js +1 -1
- package/dist/icons/DirectionIcon.js +1 -1
- package/dist/icons/DonutIcon.js +1 -1
- package/dist/icons/DownIcon.js +1 -1
- package/dist/icons/EditIcon.js +1 -1
- package/dist/icons/ExclamationCircleFilledIcon.js +1 -1
- package/dist/icons/ExclamationCircleIcon.js +1 -1
- package/dist/icons/ExclamationIcon.js +1 -1
- package/dist/icons/EyeIcon.js +1 -1
- package/dist/icons/EyeInvisibleIcon.js +1 -1
- package/dist/icons/FilterIcon.js +1 -1
- package/dist/icons/FolderFilledIcon.js +1 -1
- package/dist/icons/FolderIcon.js +1 -1
- package/dist/icons/FolderOpenFilledIcon.js +1 -1
- package/dist/icons/FolderOpenIcon.js +1 -1
- package/dist/icons/ForwardIcon.js +1 -1
- package/dist/icons/GripVerticalIcon.js +1 -1
- package/dist/icons/HierarchyIcon.js +1 -1
- package/dist/icons/HierarchyOpenIcon.js +1 -1
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/InfoCircleIcon.js +1 -1
- package/dist/icons/InfoIcon.js +1 -1
- package/dist/icons/KeyIcon.js +1 -1
- package/dist/icons/LeftIcon.js +1 -1
- package/dist/icons/LineChartIcon.js +1 -1
- package/dist/icons/LoadingIcon.js +1 -1
- package/dist/icons/LockFilledIcon.js +1 -1
- package/dist/icons/LockIcon.js +1 -1
- package/dist/icons/MoreIcon.js +1 -1
- package/dist/icons/NotAllowedIcon.js +1 -1
- package/dist/icons/Number123Icon.js +1 -1
- package/dist/icons/NumberIcon.js +1 -1
- package/dist/icons/PauseCircleFilledIcon.js +1 -1
- package/dist/icons/PauseCircleIcon.js +1 -1
- package/dist/icons/PauseIcon.js +1 -1
- package/dist/icons/PercentageIcon.js +1 -1
- package/dist/icons/PieChartIcon.js +1 -1
- package/dist/icons/PlayCircleIcon.js +1 -1
- package/dist/icons/PlayIcon.js +1 -1
- package/dist/icons/PlusIcon.js +1 -1
- package/dist/icons/ProgressBarIcon.js +1 -1
- package/dist/icons/ReloadIcon.js +1 -1
- package/dist/icons/ReportIcon.js +1 -1
- package/dist/icons/ReturnIcon.js +1 -1
- package/dist/icons/RightIcon.js +1 -1
- package/dist/icons/RowTotalsIcon.js +1 -1
- package/dist/icons/SchemeIcon.js +1 -1
- package/dist/icons/SearchIcon.js +1 -1
- package/dist/icons/SemanticQueryIcon.js +1 -1
- package/dist/icons/SettingsIcon.js +1 -1
- package/dist/icons/ShieldFilledIcon.js +1 -1
- package/dist/icons/ShieldIcon.js +1 -1
- package/dist/icons/SlashIcon.js +1 -1
- package/dist/icons/SparklesIcon.js +1 -1
- package/dist/icons/SqlIcon.js +1 -1
- package/dist/icons/StatsIcon.js +1 -1
- package/dist/icons/StopIcon.js +1 -1
- package/dist/icons/StringIcon.js +1 -1
- package/dist/icons/SubtotalsIcon.js +1 -1
- package/dist/icons/SwitchIcon.js +1 -1
- package/dist/icons/TableIcon.js +1 -1
- package/dist/icons/ThumbsDownIcon.js +1 -1
- package/dist/icons/ThumbsUpIcon.js +1 -1
- package/dist/icons/ThunderboltCrossedIcon.js +1 -1
- package/dist/icons/ThunderboltFilledIcon.js +1 -1
- package/dist/icons/ThunderboltIcon.js +1 -1
- package/dist/icons/TimeIcon.js +1 -1
- package/dist/icons/TrashIcon.js +1 -1
- package/dist/icons/UnlockIcon.js +1 -1
- package/dist/icons/UpIcon.js +1 -1
- package/dist/icons/UserGroupIcon.js +1 -1
- package/dist/icons/UserIcon.js +1 -1
- package/dist/icons/UserLockIcon.js +1 -1
- package/dist/icons/ViewIcon.js +1 -1
- package/dist/icons/WarningFilledIcon.js +1 -1
- package/dist/icons/WarningIcon.js +1 -1
- package/dist/icons/index.d.ts +0 -1
- package/dist/icons/wrap-icon.js +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +9 -12
- package/dist/index.js.map +1 -1
- package/dist/provider.js +1 -1
- package/dist/providers/TrackingProvider.js +1 -1
- package/dist/providers/navigationAdapter.default.js +1 -1
- package/dist/tokens/base.js +1 -1
- package/dist/tokens/colors.js +1 -1
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/layout.js +1 -1
- package/dist/tokens/lazy-styles.js +1 -1
- package/dist/tokens/palette-config.js +1 -1
- package/dist/tokens/palette.js +1 -1
- package/dist/tokens/shadows.js +1 -1
- package/dist/tokens/sizes.js +1 -1
- package/dist/tokens/spacing.js +1 -1
- package/dist/tokens/typography.js +1 -1
- package/dist/utils/ResizeSensor.js +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/modules.js +1 -1
- package/dist/utils/promise.js +1 -1
- package/dist/utils/raf.js +1 -1
- package/dist/utils/random.js +1 -1
- package/dist/utils/range.js +1 -1
- package/dist/utils/react/RenderCache.js +1 -1
- package/dist/utils/react/Slots.js +1 -1
- package/dist/utils/react/chain.js +1 -1
- package/dist/utils/react/forwardRefWithGenerics.js +1 -1
- package/dist/utils/react/index.js +1 -1
- package/dist/utils/react/interactions.js +1 -1
- package/dist/utils/react/isTextOnly.js +1 -1
- package/dist/utils/react/mapProps.js +1 -1
- package/dist/utils/react/mergeProps.js +1 -1
- package/dist/utils/react/nullableValue.js +1 -1
- package/dist/utils/react/resolveIcon.js +1 -1
- package/dist/utils/react/sharedStore.js +1 -1
- package/dist/utils/react/useCombinedRefs.js +1 -1
- package/dist/utils/react/useControlledFocusVisible.js +1 -1
- package/dist/utils/react/useEventBus.js +1 -1
- package/dist/utils/react/useId.js +1 -1
- package/dist/utils/react/useIsDarwin.js +1 -1
- package/dist/utils/react/useKeySymbols.js +1 -1
- package/dist/utils/react/useLayoutEffect.js +1 -1
- package/dist/utils/react/useLocalStorage.js +1 -1
- package/dist/utils/react/useMergeStyles.js +1 -1
- package/dist/utils/react/usePopoverSync.js +1 -1
- package/dist/utils/react/useQaProps.js +1 -1
- package/dist/utils/react/useViewportSize.js +1 -1
- package/dist/utils/react/wrapNodeIfPlain.js +1 -1
- package/dist/utils/selection.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/dist/utils/tree.js +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/version.js +2 -2
- package/docs/components/layout/Board.md +155 -6
- package/package.json +1 -1
- package/dist/components/fields/ColorPicker/ColorPicker.d.ts +0 -67
- package/dist/components/fields/ColorPicker/ColorPicker.js +0 -211
- package/dist/components/fields/ColorPicker/ColorPicker.js.map +0 -1
- package/dist/components/fields/ColorPicker/ColorPickerPanel.js +0 -149
- package/dist/components/fields/ColorPicker/ColorPickerPanel.js.map +0 -1
- package/dist/components/fields/ColorPicker/channels.d.ts +0 -13
- package/dist/components/fields/ColorPicker/channels.js +0 -194
- package/dist/components/fields/ColorPicker/channels.js.map +0 -1
- package/dist/components/fields/ColorPicker/color.d.ts +0 -15
- package/dist/components/fields/ColorPicker/color.js +0 -274
- package/dist/components/fields/ColorPicker/color.js.map +0 -1
- package/dist/components/fields/ColorPicker/index.d.ts +0 -4
- package/dist/icons/PipetteIcon.d.ts +0 -12
- package/dist/icons/PipetteIcon.js +0 -11
- package/dist/icons/PipetteIcon.js.map +0 -1
- package/docs/components/fields/ColorPicker.md +0 -265
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-9f74ccc | Cube Dev Team */
|
|
2
|
-
import { useEvent } from "../../../_internal/hooks/use-event.js";
|
|
3
|
-
import { formatColor, getContrastingColor, toHex } from "./color.js";
|
|
4
|
-
import { __Radio } from "../RadioGroup/Radio.js";
|
|
5
|
-
import { __Slider } from "../Slider/Slider.js";
|
|
6
|
-
import { CHANNELS, COLOR_SPACES, COLOR_SPACE_HINTS, COLOR_SPACE_LABELS } from "./channels.js";
|
|
7
|
-
import { tasty } from "@tenphi/tasty";
|
|
8
|
-
import { useMemo } from "react";
|
|
9
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
|
|
11
|
-
//#region src/components/fields/ColorPicker/ColorPickerPanel.tsx
|
|
12
|
-
const PanelElement = tasty({
|
|
13
|
-
qa: "ColorPickerPanel",
|
|
14
|
-
styles: {
|
|
15
|
-
display: "grid",
|
|
16
|
-
flow: "row",
|
|
17
|
-
gap: "1x",
|
|
18
|
-
padding: "1x",
|
|
19
|
-
width: "34x"
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const PreviewElement = tasty({
|
|
23
|
-
qa: "ColorPreview",
|
|
24
|
-
styles: {
|
|
25
|
-
display: "grid",
|
|
26
|
-
placeItems: "center",
|
|
27
|
-
height: "6x",
|
|
28
|
-
radius: true,
|
|
29
|
-
preset: "s4",
|
|
30
|
-
fill: "(#color-picker, #clear)",
|
|
31
|
-
color: "(#color-picker-contrast, #dark)",
|
|
32
|
-
shadow: "inset 0 0 0 1bw #dark.1"
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const ChannelsElement = tasty({ styles: {
|
|
36
|
-
display: "grid",
|
|
37
|
-
gridColumns: "max-content 1sf max-content",
|
|
38
|
-
placeItems: "center stretch",
|
|
39
|
-
gap: "1x"
|
|
40
|
-
} });
|
|
41
|
-
const ChannelLabelElement = tasty({ styles: {
|
|
42
|
-
preset: "c2",
|
|
43
|
-
color: "#dark-03",
|
|
44
|
-
textAlign: "center",
|
|
45
|
-
width: "2x"
|
|
46
|
-
} });
|
|
47
|
-
const ChannelTrackElement = tasty({ styles: {
|
|
48
|
-
display: "grid",
|
|
49
|
-
placeItems: "center stretch"
|
|
50
|
-
} });
|
|
51
|
-
const ChannelValueElement = tasty({ styles: {
|
|
52
|
-
preset: "s4",
|
|
53
|
-
color: "#dark-02",
|
|
54
|
-
textAlign: "right",
|
|
55
|
-
whiteSpace: "nowrap",
|
|
56
|
-
width: "5.5x"
|
|
57
|
-
} });
|
|
58
|
-
/**
|
|
59
|
-
* The gradient reaches the track through a plain custom property so the track
|
|
60
|
-
* keeps a single cached style rule. A color picker moves its channels
|
|
61
|
-
* continuously, and a fresh `styles` object per frame would emit a fresh CSS
|
|
62
|
-
* rule per frame.
|
|
63
|
-
*/
|
|
64
|
-
const TRACK_STYLES = {
|
|
65
|
-
height: "1x",
|
|
66
|
-
top: ".5x",
|
|
67
|
-
radius: "1r",
|
|
68
|
-
fill: "#clear",
|
|
69
|
-
image: "$channel-gradient",
|
|
70
|
-
shadow: "inset 0 0 0 1bw #dark.1",
|
|
71
|
-
Fill: false
|
|
72
|
-
};
|
|
73
|
-
/** A ring keeps the thumb visible wherever it sits on its own gradient. */
|
|
74
|
-
const THUMB_STYLES = { shadow: "0 0 0 2bw #surface, 0 0 0 3bw #dark.2" };
|
|
75
|
-
const THUMB_TOKENS = { "#slider-thumb": "(#color-picker, #surface)" };
|
|
76
|
-
const SPACE_STYLES = { width: "100%" };
|
|
77
|
-
const TAB_STYLES = { flexGrow: 1 };
|
|
78
|
-
function ChannelRow({ channel, color, isDisabled, onChange }) {
|
|
79
|
-
const max = channel.max(color);
|
|
80
|
-
const handleChange = useEvent((value) => {
|
|
81
|
-
onChange(channel.apply(color, value));
|
|
82
|
-
});
|
|
83
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
84
|
-
/* @__PURE__ */ jsx(ChannelLabelElement, {
|
|
85
|
-
"aria-hidden": "true",
|
|
86
|
-
children: channel.label
|
|
87
|
-
}),
|
|
88
|
-
/* @__PURE__ */ jsx(ChannelTrackElement, {
|
|
89
|
-
style: { "--channel-gradient": `linear-gradient(to right, ${channel.stops(color)})` },
|
|
90
|
-
children: /* @__PURE__ */ jsx(__Slider, {
|
|
91
|
-
"aria-label": channel.title,
|
|
92
|
-
value: Math.min(channel.value(color), max),
|
|
93
|
-
minValue: channel.min,
|
|
94
|
-
maxValue: max,
|
|
95
|
-
step: channel.step,
|
|
96
|
-
isDisabled,
|
|
97
|
-
trackStyles: TRACK_STYLES,
|
|
98
|
-
thumbStyles: THUMB_STYLES,
|
|
99
|
-
thumbTokens: THUMB_TOKENS,
|
|
100
|
-
onChange: handleChange
|
|
101
|
-
})
|
|
102
|
-
}),
|
|
103
|
-
/* @__PURE__ */ jsx(ChannelValueElement, { children: channel.display(color) })
|
|
104
|
-
] });
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* The popover body of `ColorPicker`: a preview, a switch between the three
|
|
108
|
-
* color concepts, and one gradient slider per channel of the active one.
|
|
109
|
-
*/
|
|
110
|
-
function ColorPickerPanel(props) {
|
|
111
|
-
const { color, space, isDisabled, previewFormat, onChange, onSpaceChange } = props;
|
|
112
|
-
const colorTokens = useMemo(() => ({
|
|
113
|
-
"--color-picker-color": toHex(color),
|
|
114
|
-
"--color-picker-contrast-color": getContrastingColor(color)
|
|
115
|
-
}), [color]);
|
|
116
|
-
const handleSpaceChange = useEvent((value) => {
|
|
117
|
-
onSpaceChange(value);
|
|
118
|
-
});
|
|
119
|
-
return /* @__PURE__ */ jsxs(PanelElement, {
|
|
120
|
-
style: colorTokens,
|
|
121
|
-
children: [
|
|
122
|
-
/* @__PURE__ */ jsx(PreviewElement, { children: formatColor(color, previewFormat) }),
|
|
123
|
-
/* @__PURE__ */ jsx(__Radio.Tabs, {
|
|
124
|
-
"aria-label": "Color space",
|
|
125
|
-
value: space,
|
|
126
|
-
isDisabled,
|
|
127
|
-
styles: SPACE_STYLES,
|
|
128
|
-
onChange: handleSpaceChange,
|
|
129
|
-
children: COLOR_SPACES.map((item) => /* @__PURE__ */ jsx(__Radio, {
|
|
130
|
-
value: item,
|
|
131
|
-
"aria-label": COLOR_SPACE_LABELS[item],
|
|
132
|
-
tooltip: COLOR_SPACE_HINTS[item],
|
|
133
|
-
styles: TAB_STYLES,
|
|
134
|
-
children: COLOR_SPACE_LABELS[item]
|
|
135
|
-
}, item))
|
|
136
|
-
}),
|
|
137
|
-
/* @__PURE__ */ jsx(ChannelsElement, { children: CHANNELS[space].map((channel) => /* @__PURE__ */ jsx(ChannelRow, {
|
|
138
|
-
channel,
|
|
139
|
-
color,
|
|
140
|
-
isDisabled,
|
|
141
|
-
onChange
|
|
142
|
-
}, `${space}-${channel.label}`)) })
|
|
143
|
-
]
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//#endregion
|
|
148
|
-
export { ColorPickerPanel };
|
|
149
|
-
//# sourceMappingURL=ColorPickerPanel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerPanel.js","names":["Slider","Radio"],"sources":["../../../../src/components/fields/ColorPicker/ColorPickerPanel.tsx"],"sourcesContent":["import { Styles, tasty } from '@tenphi/tasty';\nimport { useMemo } from 'react';\n\nimport { useEvent } from '../../../_internal';\nimport { Radio } from '../RadioGroup';\nimport { Slider } from '../Slider';\n\nimport {\n CHANNELS,\n COLOR_SPACE_HINTS,\n COLOR_SPACE_LABELS,\n COLOR_SPACES,\n ColorChannel,\n ColorSpace,\n} from './channels';\nimport {\n ColorFormat,\n ColorValue,\n formatColor,\n getContrastingColor,\n toHex,\n} from './color';\n\nconst PanelElement = tasty({\n qa: 'ColorPickerPanel',\n styles: {\n display: 'grid',\n flow: 'row',\n gap: '1x',\n padding: '1x',\n width: '34x',\n },\n});\n\nconst PreviewElement = tasty({\n qa: 'ColorPreview',\n styles: {\n display: 'grid',\n placeItems: 'center',\n height: '6x',\n radius: true,\n preset: 's4',\n fill: '(#color-picker, #clear)',\n color: '(#color-picker-contrast, #dark)',\n shadow: 'inset 0 0 0 1bw #dark.1',\n },\n});\n\nconst ChannelsElement = tasty({\n styles: {\n display: 'grid',\n gridColumns: 'max-content 1sf max-content',\n placeItems: 'center stretch',\n gap: '1x',\n },\n});\n\nconst ChannelLabelElement = tasty({\n styles: {\n preset: 'c2',\n color: '#dark-03',\n textAlign: 'center',\n width: '2x',\n },\n});\n\nconst ChannelTrackElement = tasty({\n styles: {\n display: 'grid',\n placeItems: 'center stretch',\n },\n});\n\nconst ChannelValueElement = tasty({\n styles: {\n preset: 's4',\n color: '#dark-02',\n textAlign: 'right',\n whiteSpace: 'nowrap',\n width: '5.5x',\n },\n});\n\n/**\n * The gradient reaches the track through a plain custom property so the track\n * keeps a single cached style rule. A color picker moves its channels\n * continuously, and a fresh `styles` object per frame would emit a fresh CSS\n * rule per frame.\n */\nconst TRACK_STYLES: Styles = {\n height: '1x',\n top: '.5x',\n radius: '1r',\n fill: '#clear',\n image: '$channel-gradient',\n shadow: 'inset 0 0 0 1bw #dark.1',\n Fill: false,\n};\n\n/** A ring keeps the thumb visible wherever it sits on its own gradient. */\nconst THUMB_STYLES: Styles = {\n shadow: '0 0 0 2bw #surface, 0 0 0 3bw #dark.2',\n};\n\nconst THUMB_TOKENS = { '#slider-thumb': '(#color-picker, #surface)' };\n\nconst SPACE_STYLES: Styles = { width: '100%' };\nconst TAB_STYLES: Styles = { flexGrow: 1 };\n\nexport interface ColorPickerPanelProps {\n color: ColorValue;\n space: ColorSpace;\n isDisabled?: boolean;\n /** Notation used for the preview caption. */\n previewFormat: ColorFormat;\n onChange: (color: ColorValue) => void;\n onSpaceChange: (space: ColorSpace) => void;\n}\n\ninterface ChannelRowProps {\n channel: ColorChannel;\n color: ColorValue;\n isDisabled?: boolean;\n onChange: (color: ColorValue) => void;\n}\n\nfunction ChannelRow({ channel, color, isDisabled, onChange }: ChannelRowProps) {\n const max = channel.max(color);\n\n const handleChange = useEvent((value: number) => {\n onChange(channel.apply(color, value));\n });\n\n return (\n <>\n <ChannelLabelElement aria-hidden=\"true\">\n {channel.label}\n </ChannelLabelElement>\n <ChannelTrackElement\n style={{\n '--channel-gradient': `linear-gradient(to right, ${channel.stops(\n color,\n )})`,\n }}\n >\n <Slider\n aria-label={channel.title}\n value={Math.min(channel.value(color), max)}\n minValue={channel.min}\n maxValue={max}\n step={channel.step}\n isDisabled={isDisabled}\n trackStyles={TRACK_STYLES}\n thumbStyles={THUMB_STYLES}\n thumbTokens={THUMB_TOKENS}\n onChange={handleChange}\n />\n </ChannelTrackElement>\n <ChannelValueElement>{channel.display(color)}</ChannelValueElement>\n </>\n );\n}\n\n/**\n * The popover body of `ColorPicker`: a preview, a switch between the three\n * color concepts, and one gradient slider per channel of the active one.\n */\nexport function ColorPickerPanel(props: ColorPickerPanelProps) {\n const { color, space, isDisabled, previewFormat, onChange, onSpaceChange } =\n props;\n\n const colorTokens = useMemo(\n () => ({\n '--color-picker-color': toHex(color),\n '--color-picker-contrast-color': getContrastingColor(color),\n }),\n [color],\n );\n\n const handleSpaceChange = useEvent((value: string) => {\n onSpaceChange(value as ColorSpace);\n });\n\n return (\n <PanelElement style={colorTokens}>\n <PreviewElement>{formatColor(color, previewFormat)}</PreviewElement>\n <Radio.Tabs\n aria-label=\"Color space\"\n value={space}\n isDisabled={isDisabled}\n styles={SPACE_STYLES}\n onChange={handleSpaceChange}\n >\n {COLOR_SPACES.map((item) => (\n <Radio\n key={item}\n value={item}\n aria-label={COLOR_SPACE_LABELS[item]}\n tooltip={COLOR_SPACE_HINTS[item]}\n styles={TAB_STYLES}\n >\n {COLOR_SPACE_LABELS[item]}\n </Radio>\n ))}\n </Radio.Tabs>\n <ChannelsElement>\n {CHANNELS[space].map((channel) => (\n <ChannelRow\n key={`${space}-${channel.label}`}\n channel={channel}\n color={color}\n isDisabled={isDisabled}\n onChange={onChange}\n />\n ))}\n </ChannelsElement>\n </PanelElement>\n );\n}\n"],"mappings":";;;;;;;;;;;AAuBA,MAAM,eAAe,MAAM;CACzB,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,MAAM;EACN,KAAK;EACL,SAAS;EACT,OAAO;EACR;CACF,CAAC;AAEF,MAAM,iBAAiB,MAAM;CAC3B,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,MAAM;EACN,OAAO;EACP,QAAQ;EACT;CACF,CAAC;AAEF,MAAM,kBAAkB,MAAM,EAC5B,QAAQ;CACN,SAAS;CACT,aAAa;CACb,YAAY;CACZ,KAAK;CACN,EACF,CAAC;AAEF,MAAM,sBAAsB,MAAM,EAChC,QAAQ;CACN,QAAQ;CACR,OAAO;CACP,WAAW;CACX,OAAO;CACR,EACF,CAAC;AAEF,MAAM,sBAAsB,MAAM,EAChC,QAAQ;CACN,SAAS;CACT,YAAY;CACb,EACF,CAAC;AAEF,MAAM,sBAAsB,MAAM,EAChC,QAAQ;CACN,QAAQ;CACR,OAAO;CACP,WAAW;CACX,YAAY;CACZ,OAAO;CACR,EACF,CAAC;;;;;;;AAQF,MAAM,eAAuB;CAC3B,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;CACP;;AAGD,MAAM,eAAuB,EAC3B,QAAQ,yCACT;AAED,MAAM,eAAe,EAAE,iBAAiB,6BAA6B;AAErE,MAAM,eAAuB,EAAE,OAAO,QAAQ;AAC9C,MAAM,aAAqB,EAAE,UAAU,GAAG;AAmB1C,SAAS,WAAW,EAAE,SAAS,OAAO,YAAY,YAA6B;CAC7E,MAAM,MAAM,QAAQ,IAAI,MAAM;CAE9B,MAAM,eAAe,UAAU,UAAkB;AAC/C,WAAS,QAAQ,MAAM,OAAO,MAAM,CAAC;GACrC;AAEF,QACE;EACE,oBAAC;GAAoB,eAAY;aAC9B,QAAQ;IACW;EACtB,oBAAC;GACC,OAAO,EACL,sBAAsB,6BAA6B,QAAQ,MACzD,MACD,CAAC,IACH;aAED,oBAACA;IACC,cAAY,QAAQ;IACpB,OAAO,KAAK,IAAI,QAAQ,MAAM,MAAM,EAAE,IAAI;IAC1C,UAAU,QAAQ;IAClB,UAAU;IACV,MAAM,QAAQ;IACF;IACZ,aAAa;IACb,aAAa;IACb,aAAa;IACb,UAAU;KACV;IACkB;EACtB,oBAAC,iCAAqB,QAAQ,QAAQ,MAAM,GAAuB;KAClE;;;;;;AAQP,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,EAAE,OAAO,OAAO,YAAY,eAAe,UAAU,kBACzD;CAEF,MAAM,cAAc,eACX;EACL,wBAAwB,MAAM,MAAM;EACpC,iCAAiC,oBAAoB,MAAM;EAC5D,GACD,CAAC,MAAM,CACR;CAED,MAAM,oBAAoB,UAAU,UAAkB;AACpD,gBAAc,MAAoB;GAClC;AAEF,QACE,qBAAC;EAAa,OAAO;;GACnB,oBAAC,4BAAgB,YAAY,OAAO,cAAc,GAAkB;GACpE,oBAACC,QAAM;IACL,cAAW;IACX,OAAO;IACK;IACZ,QAAQ;IACR,UAAU;cAET,aAAa,KAAK,SACjB,oBAACA;KAEC,OAAO;KACP,cAAY,mBAAmB;KAC/B,SAAS,kBAAkB;KAC3B,QAAQ;eAEP,mBAAmB;OANf,KAOC,CACR;KACS;GACb,oBAAC,6BACE,SAAS,OAAO,KAAK,YACpB,oBAAC;IAEU;IACF;IACK;IACF;MAJL,GAAG,MAAM,GAAG,QAAQ,QAKzB,CACF,GACc;;GACL"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import "./color.js";
|
|
3
|
-
|
|
4
|
-
//#region src/components/fields/ColorPicker/channels.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* The three color concepts the popover can be driven by. They all edit the
|
|
7
|
-
* same canonical value — only the axes the user manipulates differ.
|
|
8
|
-
*/
|
|
9
|
-
declare const COLOR_SPACES: readonly ["hst", "lch", "rgb"];
|
|
10
|
-
type ColorSpace = (typeof COLOR_SPACES)[number];
|
|
11
|
-
//#endregion
|
|
12
|
-
export { COLOR_SPACES, ColorSpace };
|
|
13
|
-
//# sourceMappingURL=channels.d.ts.map
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-9f74ccc | Cube Dev Team */
|
|
2
|
-
import { fromOkhst, fromOklch, fromRgb, isAchromatic, maxChroma, normalizeHue, toHex, toOkhst, toOklch, toRgb } from "./color.js";
|
|
3
|
-
|
|
4
|
-
//#region src/components/fields/ColorPicker/channels.ts
|
|
5
|
-
/**
|
|
6
|
-
* The three color concepts the popover can be driven by. They all edit the
|
|
7
|
-
* same canonical value — only the axes the user manipulates differ.
|
|
8
|
-
*/
|
|
9
|
-
const COLOR_SPACES = [
|
|
10
|
-
"hst",
|
|
11
|
-
"lch",
|
|
12
|
-
"rgb"
|
|
13
|
-
];
|
|
14
|
-
const COLOR_SPACE_LABELS = {
|
|
15
|
-
hst: "HST",
|
|
16
|
-
lch: "LCH",
|
|
17
|
-
rgb: "RGB"
|
|
18
|
-
};
|
|
19
|
-
const COLOR_SPACE_HINTS = {
|
|
20
|
-
hst: "OKHST — hue, saturation, tone",
|
|
21
|
-
lch: "OKLCH — lightness, chroma, hue",
|
|
22
|
-
rgb: "sRGB — red, green, blue"
|
|
23
|
-
};
|
|
24
|
-
const constant = (value) => () => value;
|
|
25
|
-
function round(value, precision = 2) {
|
|
26
|
-
const factor = 10 ** precision;
|
|
27
|
-
return Math.round(value * factor) / factor;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* `count` evenly spaced gradient stops, always as hex. Perceptual channels are
|
|
31
|
-
* not linear in sRGB, so a two-stop gradient would misrepresent them —
|
|
32
|
-
* sampling the real conversion keeps the track honest. Hex (rather than an
|
|
33
|
-
* `okhsl()` string) because the gradient reaches the DOM as a raw custom
|
|
34
|
-
* property, without passing through Tasty's color functions.
|
|
35
|
-
*/
|
|
36
|
-
function ramp(count, at) {
|
|
37
|
-
return Array.from({ length: count }, (_, index) => toHex(at(index / (count - 1)))).join(", ");
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The hue strip is drawn at full saturation and a fixed OKHSL lightness, which
|
|
41
|
-
* keeps it perceptually even instead of spiking at yellow the way a CSS-HSL
|
|
42
|
-
* rainbow does. Its own saturation and tone stay fixed: the strip is the same
|
|
43
|
-
* in HST and in LCH, where `H` means the same thing.
|
|
44
|
-
*/
|
|
45
|
-
const HUE_STOPS = ramp(25, (position) => ({
|
|
46
|
-
h: position * 360,
|
|
47
|
-
s: 1,
|
|
48
|
-
l: .6
|
|
49
|
-
}));
|
|
50
|
-
const hueChannel = {
|
|
51
|
-
label: "H",
|
|
52
|
-
title: "Hue",
|
|
53
|
-
min: 0,
|
|
54
|
-
max: constant(359),
|
|
55
|
-
step: 1,
|
|
56
|
-
value: (color) => round(color.h, 1),
|
|
57
|
-
apply: (color, value) => ({
|
|
58
|
-
...color,
|
|
59
|
-
h: normalizeHue(value)
|
|
60
|
-
}),
|
|
61
|
-
stops: () => HUE_STOPS,
|
|
62
|
-
display: (color) => `${Math.round(color.h)}°`
|
|
63
|
-
};
|
|
64
|
-
const saturationChannel = {
|
|
65
|
-
label: "S",
|
|
66
|
-
title: "Saturation",
|
|
67
|
-
min: 0,
|
|
68
|
-
max: constant(100),
|
|
69
|
-
step: 1,
|
|
70
|
-
value: (color) => round(color.s * 100, 1),
|
|
71
|
-
apply: (color, value) => ({
|
|
72
|
-
...color,
|
|
73
|
-
s: value / 100
|
|
74
|
-
}),
|
|
75
|
-
stops: (color) => ramp(7, (position) => ({
|
|
76
|
-
...color,
|
|
77
|
-
s: position
|
|
78
|
-
})),
|
|
79
|
-
display: (color) => `${Math.round(color.s * 100)}%`
|
|
80
|
-
};
|
|
81
|
-
const toneChannel = {
|
|
82
|
-
label: "T",
|
|
83
|
-
title: "Tone",
|
|
84
|
-
min: 0,
|
|
85
|
-
max: constant(100),
|
|
86
|
-
step: 1,
|
|
87
|
-
value: (color) => round(toOkhst(color).t * 100, 1),
|
|
88
|
-
apply: (color, value) => fromOkhst({
|
|
89
|
-
h: color.h,
|
|
90
|
-
s: color.s,
|
|
91
|
-
t: value / 100
|
|
92
|
-
}),
|
|
93
|
-
stops: (color) => ramp(7, (position) => fromOkhst({
|
|
94
|
-
h: color.h,
|
|
95
|
-
s: color.s,
|
|
96
|
-
t: position
|
|
97
|
-
})),
|
|
98
|
-
display: (color) => `${Math.round(toOkhst(color).t * 100)}%`
|
|
99
|
-
};
|
|
100
|
-
const lightnessChannel = {
|
|
101
|
-
label: "L",
|
|
102
|
-
title: "Lightness",
|
|
103
|
-
min: 0,
|
|
104
|
-
max: constant(100),
|
|
105
|
-
step: 1,
|
|
106
|
-
value: (color) => round(toOklch(color).l * 100, 1),
|
|
107
|
-
apply: (color, value) => {
|
|
108
|
-
const { c, h } = toOklch(color);
|
|
109
|
-
return fromOklch({
|
|
110
|
-
l: value / 100,
|
|
111
|
-
c,
|
|
112
|
-
h
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
stops: (color) => {
|
|
116
|
-
const { c, h } = toOklch(color);
|
|
117
|
-
return ramp(7, (position) => fromOklch({
|
|
118
|
-
l: position,
|
|
119
|
-
c,
|
|
120
|
-
h
|
|
121
|
-
}));
|
|
122
|
-
},
|
|
123
|
-
display: (color) => `${Math.round(toOklch(color).l * 100)}%`
|
|
124
|
-
};
|
|
125
|
-
const chromaChannel = {
|
|
126
|
-
label: "C",
|
|
127
|
-
title: "Chroma",
|
|
128
|
-
min: 0,
|
|
129
|
-
max: (color) => Math.max(round(maxChroma(color.h, color.l), 4), .001),
|
|
130
|
-
step: .001,
|
|
131
|
-
value: (color) => round(toOklch(color).c, 4),
|
|
132
|
-
apply: (color, value) => {
|
|
133
|
-
const { l, h } = toOklch(color);
|
|
134
|
-
return fromOklch({
|
|
135
|
-
l,
|
|
136
|
-
c: value,
|
|
137
|
-
h
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
stops: (color) => {
|
|
141
|
-
const { l, h } = toOklch(color);
|
|
142
|
-
const limit = maxChroma(color.h, color.l);
|
|
143
|
-
return ramp(7, (position) => fromOklch({
|
|
144
|
-
l,
|
|
145
|
-
c: position * limit,
|
|
146
|
-
h
|
|
147
|
-
}));
|
|
148
|
-
},
|
|
149
|
-
display: (color) => toOklch(color).c.toFixed(3)
|
|
150
|
-
};
|
|
151
|
-
function rgbChannel(key, label, title) {
|
|
152
|
-
const at = (color, value) => fromRgb({
|
|
153
|
-
...toRgb(color),
|
|
154
|
-
[key]: value
|
|
155
|
-
});
|
|
156
|
-
return {
|
|
157
|
-
label,
|
|
158
|
-
title,
|
|
159
|
-
min: 0,
|
|
160
|
-
max: constant(255),
|
|
161
|
-
step: 1,
|
|
162
|
-
value: (color) => toRgb(color)[key],
|
|
163
|
-
apply: (color, value) => {
|
|
164
|
-
const next = at(color, value);
|
|
165
|
-
return isAchromatic(next) ? {
|
|
166
|
-
...next,
|
|
167
|
-
h: color.h
|
|
168
|
-
} : next;
|
|
169
|
-
},
|
|
170
|
-
stops: (color) => ramp(2, (position) => at(color, position * 255)),
|
|
171
|
-
display: (color) => `${toRgb(color)[key]}`
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
const CHANNELS = {
|
|
175
|
-
hst: [
|
|
176
|
-
hueChannel,
|
|
177
|
-
saturationChannel,
|
|
178
|
-
toneChannel
|
|
179
|
-
],
|
|
180
|
-
lch: [
|
|
181
|
-
lightnessChannel,
|
|
182
|
-
chromaChannel,
|
|
183
|
-
hueChannel
|
|
184
|
-
],
|
|
185
|
-
rgb: [
|
|
186
|
-
rgbChannel("r", "R", "Red"),
|
|
187
|
-
rgbChannel("g", "G", "Green"),
|
|
188
|
-
rgbChannel("b", "B", "Blue")
|
|
189
|
-
]
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
//#endregion
|
|
193
|
-
export { CHANNELS, COLOR_SPACES, COLOR_SPACE_HINTS, COLOR_SPACE_LABELS };
|
|
194
|
-
//# sourceMappingURL=channels.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channels.js","names":[],"sources":["../../../../src/components/fields/ColorPicker/channels.ts"],"sourcesContent":["import {\n ColorValue,\n fromOkhst,\n fromOklch,\n fromRgb,\n isAchromatic,\n maxChroma,\n normalizeHue,\n toHex,\n toOkhst,\n toOklch,\n toRgb,\n} from './color';\n\n/**\n * The three color concepts the popover can be driven by. They all edit the\n * same canonical value — only the axes the user manipulates differ.\n */\nexport const COLOR_SPACES = ['hst', 'lch', 'rgb'] as const;\n\nexport type ColorSpace = (typeof COLOR_SPACES)[number];\n\nexport const COLOR_SPACE_LABELS: Record<ColorSpace, string> = {\n hst: 'HST',\n lch: 'LCH',\n rgb: 'RGB',\n};\n\nexport const COLOR_SPACE_HINTS: Record<ColorSpace, string> = {\n hst: 'OKHST — hue, saturation, tone',\n lch: 'OKLCH — lightness, chroma, hue',\n rgb: 'sRGB — red, green, blue',\n};\n\nexport interface ColorChannel {\n /** Single-letter axis name shown next to the slider. */\n label: string;\n /** Accessible name for the slider. */\n title: string;\n min: number;\n step: number;\n /** The upper bound. Chroma is gamut-bound, so it depends on the color. */\n max: (color: ColorValue) => number;\n value: (color: ColorValue) => number;\n /** The color this channel produces when moved to `value`. */\n apply: (color: ColorValue, value: number) => ColorValue;\n /** Comma-separated gradient stops describing the channel's whole range. */\n stops: (color: ColorValue) => string;\n /** Human-readable rendering of the current channel value. */\n display: (color: ColorValue) => string;\n}\n\nconst constant = (value: number) => () => value;\n\nfunction round(value: number, precision = 2): number {\n const factor = 10 ** precision;\n\n return Math.round(value * factor) / factor;\n}\n\n/**\n * `count` evenly spaced gradient stops, always as hex. Perceptual channels are\n * not linear in sRGB, so a two-stop gradient would misrepresent them —\n * sampling the real conversion keeps the track honest. Hex (rather than an\n * `okhsl()` string) because the gradient reaches the DOM as a raw custom\n * property, without passing through Tasty's color functions.\n */\nfunction ramp(count: number, at: (position: number) => ColorValue): string {\n return Array.from({ length: count }, (_, index) =>\n toHex(at(index / (count - 1))),\n ).join(', ');\n}\n\n/**\n * The hue strip is drawn at full saturation and a fixed OKHSL lightness, which\n * keeps it perceptually even instead of spiking at yellow the way a CSS-HSL\n * rainbow does. Its own saturation and tone stay fixed: the strip is the same\n * in HST and in LCH, where `H` means the same thing.\n */\nconst HUE_STOPS = ramp(25, (position) => ({\n h: position * 360,\n s: 1,\n l: 0.6,\n}));\n\nconst hueChannel: ColorChannel = {\n label: 'H',\n title: 'Hue',\n min: 0,\n // 360° is the same angle as 0°, so the last usable stop is 359 — the range\n // `HueSlider` exposes as well.\n max: constant(359),\n step: 1,\n value: (color) => round(color.h, 1),\n apply: (color, value) => ({ ...color, h: normalizeHue(value) }),\n stops: () => HUE_STOPS,\n display: (color) => `${Math.round(color.h)}°`,\n};\n\nconst saturationChannel: ColorChannel = {\n label: 'S',\n title: 'Saturation',\n min: 0,\n max: constant(100),\n step: 1,\n value: (color) => round(color.s * 100, 1),\n apply: (color, value) => ({ ...color, s: value / 100 }),\n stops: (color) => ramp(7, (position) => ({ ...color, s: position })),\n display: (color) => `${Math.round(color.s * 100)}%`,\n};\n\nconst toneChannel: ColorChannel = {\n label: 'T',\n title: 'Tone',\n min: 0,\n max: constant(100),\n step: 1,\n value: (color) => round(toOkhst(color).t * 100, 1),\n apply: (color, value) =>\n fromOkhst({ h: color.h, s: color.s, t: value / 100 }),\n stops: (color) =>\n ramp(7, (position) => fromOkhst({ h: color.h, s: color.s, t: position })),\n display: (color) => `${Math.round(toOkhst(color).t * 100)}%`,\n};\n\nconst lightnessChannel: ColorChannel = {\n label: 'L',\n title: 'Lightness',\n min: 0,\n max: constant(100),\n step: 1,\n value: (color) => round(toOklch(color).l * 100, 1),\n apply: (color, value) => {\n const { c, h } = toOklch(color);\n\n return fromOklch({ l: value / 100, c, h });\n },\n stops: (color) => {\n const { c, h } = toOklch(color);\n\n return ramp(7, (position) => fromOklch({ l: position, c, h }));\n },\n display: (color) => `${Math.round(toOklch(color).l * 100)}%`,\n};\n\nconst chromaChannel: ColorChannel = {\n label: 'C',\n title: 'Chroma',\n min: 0,\n // Chroma has no fixed ceiling: how far it can go depends on how far the sRGB\n // gamut reaches at the current lightness and hue. Never zero, so the slider\n // always has a range to divide by.\n max: (color) => Math.max(round(maxChroma(color.h, color.l), 4), 0.001),\n step: 0.001,\n value: (color) => round(toOklch(color).c, 4),\n apply: (color, value) => {\n const { l, h } = toOklch(color);\n\n return fromOklch({ l, c: value, h });\n },\n stops: (color) => {\n const { l, h } = toOklch(color);\n const limit = maxChroma(color.h, color.l);\n\n return ramp(7, (position) => fromOklch({ l, c: position * limit, h }));\n },\n display: (color) => toOklch(color).c.toFixed(3),\n};\n\nfunction rgbChannel(\n key: 'r' | 'g' | 'b',\n label: string,\n title: string,\n): ColorChannel {\n const at = (color: ColorValue, value: number) =>\n fromRgb({ ...toRgb(color), [key]: value });\n\n return {\n label,\n title,\n min: 0,\n max: constant(255),\n step: 1,\n value: (color) => toRgb(color)[key],\n apply: (color, value) => {\n const next = at(color, value);\n\n // A gray has no hue of its own, and the conversion invents one. Keeping\n // the authored hue means switching back to HST or LCH resumes where the\n // user left off.\n return isAchromatic(next) ? { ...next, h: color.h } : next;\n },\n // An sRGB channel is linear in the space CSS interpolates gradients in, so\n // the two ends describe the whole ramp exactly.\n stops: (color) => ramp(2, (position) => at(color, position * 255)),\n display: (color) => `${toRgb(color)[key]}`,\n };\n}\n\nexport const CHANNELS: Record<ColorSpace, ColorChannel[]> = {\n hst: [hueChannel, saturationChannel, toneChannel],\n lch: [lightnessChannel, chromaChannel, hueChannel],\n rgb: [\n rgbChannel('r', 'R', 'Red'),\n rgbChannel('g', 'G', 'Green'),\n rgbChannel('b', 'B', 'Blue'),\n ],\n};\n"],"mappings":"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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import "@tenphi/glaze";
|
|
3
|
-
|
|
4
|
-
//#region src/components/fields/ColorPicker/color.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Every color format the picker can read and write.
|
|
7
|
-
*
|
|
8
|
-
* `okhsl` and `okhst` are Glaze / Tasty spaces rather than native CSS ones,
|
|
9
|
-
* but Tasty parses both, so the produced strings are usable as style values.
|
|
10
|
-
*/
|
|
11
|
-
declare const COLOR_FORMATS: readonly ["hex", "rgb", "hsl", "okhsl", "okhst", "oklch"];
|
|
12
|
-
type ColorFormat = (typeof COLOR_FORMATS)[number];
|
|
13
|
-
//#endregion
|
|
14
|
-
export { COLOR_FORMATS, ColorFormat };
|
|
15
|
-
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-9f74ccc | Cube Dev Team */
|
|
2
|
-
import { contrastRatioFromLuminance, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, hslToSrgb, okhslToLinearSrgb, okhslToOkhst, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, parseHexAlpha, relativeLuminanceFromLinearRgb, srgbToHex, srgbToOkhsl } from "@tenphi/glaze";
|
|
3
|
-
|
|
4
|
-
//#region src/components/fields/ColorPicker/color.ts
|
|
5
|
-
/**
|
|
6
|
-
* Every color format the picker can read and write.
|
|
7
|
-
*
|
|
8
|
-
* `okhsl` and `okhst` are Glaze / Tasty spaces rather than native CSS ones,
|
|
9
|
-
* but Tasty parses both, so the produced strings are usable as style values.
|
|
10
|
-
*/
|
|
11
|
-
const COLOR_FORMATS = [
|
|
12
|
-
"hex",
|
|
13
|
-
"rgb",
|
|
14
|
-
"hsl",
|
|
15
|
-
"okhsl",
|
|
16
|
-
"okhst",
|
|
17
|
-
"oklch"
|
|
18
|
-
];
|
|
19
|
-
const FUNCTION_RE = /^([a-z]+)\(([^()]+)\)$/;
|
|
20
|
-
const NUMBER_RE = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?(%|deg)?$/;
|
|
21
|
-
/**
|
|
22
|
-
* Saturation below this rounds to `0%` in every output notation, so the color
|
|
23
|
-
* is achromatic for display purposes even when the conversion left a residue.
|
|
24
|
-
*/
|
|
25
|
-
const ACHROMATIC_SATURATION = 5e-5;
|
|
26
|
-
function clamp(value, min, max) {
|
|
27
|
-
return value < min ? min : value > max ? max : value;
|
|
28
|
-
}
|
|
29
|
-
function normalizeHue(hue) {
|
|
30
|
-
if (!Number.isFinite(hue)) return 0;
|
|
31
|
-
return (hue % 360 + 360) % 360;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The color carries no meaningful hue: every conversion out of it invents an
|
|
35
|
-
* angle, so callers that need one should keep the hue they already had.
|
|
36
|
-
*/
|
|
37
|
-
function isAchromatic(color) {
|
|
38
|
-
return color.s < ACHROMATIC_SATURATION;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Split a color-function body into its numeric arguments, dropping the alpha
|
|
42
|
-
* component. Both the modern space-separated and the legacy comma-separated
|
|
43
|
-
* syntaxes are accepted.
|
|
44
|
-
*
|
|
45
|
-
* Each argument keeps its unit so the caller can tell `50%` from `50`.
|
|
46
|
-
*/
|
|
47
|
-
function splitArguments(body) {
|
|
48
|
-
const [values, ...rest] = body.split("/");
|
|
49
|
-
if (rest.length > 1) return null;
|
|
50
|
-
const args = values.trim().split(values.includes(",") ? "," : /\s+/).map((part) => part.trim()).filter(Boolean);
|
|
51
|
-
if (args.length === 4) args.pop();
|
|
52
|
-
return args.every((arg) => NUMBER_RE.test(arg)) ? args : null;
|
|
53
|
-
}
|
|
54
|
-
/** Parse an argument that may carry a `%` unit. `scale` is the 100% value. */
|
|
55
|
-
function scalar(arg, scale) {
|
|
56
|
-
return arg.endsWith("%") ? parseFloat(arg) / 100 * scale : parseFloat(arg);
|
|
57
|
-
}
|
|
58
|
-
function hueArgument(arg) {
|
|
59
|
-
return arg.endsWith("%") ? NaN : normalizeHue(parseFloat(arg));
|
|
60
|
-
}
|
|
61
|
-
function fromRgb(color) {
|
|
62
|
-
const [h, s, l] = srgbToOkhsl([
|
|
63
|
-
clamp(color.r, 0, 255) / 255,
|
|
64
|
-
clamp(color.g, 0, 255) / 255,
|
|
65
|
-
clamp(color.b, 0, 255) / 255
|
|
66
|
-
]);
|
|
67
|
-
return {
|
|
68
|
-
h: normalizeHue(h),
|
|
69
|
-
s: clamp(s, 0, 1),
|
|
70
|
-
l: clamp(l, 0, 1)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function toRgb(color) {
|
|
74
|
-
const [r, g, b] = okhslToSrgb(color.h, color.s, color.l);
|
|
75
|
-
return {
|
|
76
|
-
r: Math.round(clamp(r, 0, 1) * 255),
|
|
77
|
-
g: Math.round(clamp(g, 0, 1) * 255),
|
|
78
|
-
b: Math.round(clamp(b, 0, 1) * 255)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function fromOkhst(color) {
|
|
82
|
-
const { h, s, l } = okhstToOkhsl({
|
|
83
|
-
h: normalizeHue(color.h),
|
|
84
|
-
s: clamp(color.s, 0, 1),
|
|
85
|
-
t: clamp(color.t, 0, 1)
|
|
86
|
-
});
|
|
87
|
-
return {
|
|
88
|
-
h: normalizeHue(h),
|
|
89
|
-
s: clamp(s, 0, 1),
|
|
90
|
-
l: clamp(l, 0, 1)
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function toOkhst(color) {
|
|
94
|
-
const { t } = okhslToOkhst(color);
|
|
95
|
-
return {
|
|
96
|
-
h: color.h,
|
|
97
|
-
s: color.s,
|
|
98
|
-
t: clamp(t, 0, 1)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* The largest OKLCh chroma that stays inside the sRGB gamut for the given hue
|
|
103
|
-
* and OKHSL lightness — that is exactly what OKHSL saturation `1` means.
|
|
104
|
-
*/
|
|
105
|
-
function maxChroma(hue, lightness) {
|
|
106
|
-
return okhslToOklch(normalizeHue(hue), 1, clamp(lightness, 0, 1))[1];
|
|
107
|
-
}
|
|
108
|
-
function toOklch(color) {
|
|
109
|
-
const [l, c, h] = okhslToOklch(color.h, color.s, color.l);
|
|
110
|
-
return {
|
|
111
|
-
l,
|
|
112
|
-
c,
|
|
113
|
-
h: normalizeHue(h)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* OKLCh addresses colors outside the sRGB gamut, so chroma is clipped to the
|
|
118
|
-
* gamut boundary at the requested lightness before it is stored. Hue is taken
|
|
119
|
-
* from the input rather than from the conversion, which loses it at zero
|
|
120
|
-
* chroma.
|
|
121
|
-
*/
|
|
122
|
-
function fromOklch(color) {
|
|
123
|
-
const h = normalizeHue(color.h);
|
|
124
|
-
const c = Math.max(color.c, 0);
|
|
125
|
-
const radians = h * Math.PI / 180;
|
|
126
|
-
const [, s, l] = oklabToOkhsl([
|
|
127
|
-
clamp(color.l, 0, 1),
|
|
128
|
-
c * Math.cos(radians),
|
|
129
|
-
c * Math.sin(radians)
|
|
130
|
-
]);
|
|
131
|
-
const limit = maxChroma(h, l);
|
|
132
|
-
return {
|
|
133
|
-
h,
|
|
134
|
-
s: limit > 0 ? c >= limit ? 1 : clamp(s, 0, 1) : 0,
|
|
135
|
-
l: clamp(l, 0, 1)
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function toHex(color) {
|
|
139
|
-
return srgbToHex(okhslToSrgb(color.h, color.s, color.l));
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Read any supported color notation into the canonical space. Returns `null`
|
|
143
|
-
* for anything that is not a real color — that is what lets the picker reject
|
|
144
|
-
* partial input instead of guessing.
|
|
145
|
-
*
|
|
146
|
-
* Named CSS colors (`red`, `rebeccapurple`) are intentionally not supported,
|
|
147
|
-
* matching `glaze.color()`.
|
|
148
|
-
*/
|
|
149
|
-
function parseColor(input) {
|
|
150
|
-
const text = input.trim().toLowerCase();
|
|
151
|
-
if (!text) return null;
|
|
152
|
-
if (text.startsWith("#")) {
|
|
153
|
-
const parsed = parseHexAlpha(text);
|
|
154
|
-
return parsed ? fromRgb(rgbFromSrgb(parsed.rgb)) : null;
|
|
155
|
-
}
|
|
156
|
-
const match = FUNCTION_RE.exec(text);
|
|
157
|
-
if (!match) return null;
|
|
158
|
-
const [, name, body] = match;
|
|
159
|
-
const args = splitArguments(body);
|
|
160
|
-
if (!args || args.length !== 3) return null;
|
|
161
|
-
switch (name) {
|
|
162
|
-
case "rgb":
|
|
163
|
-
case "rgba": {
|
|
164
|
-
const [r, g, b] = args.map((arg) => scalar(arg, 255));
|
|
165
|
-
return anyNaN(r, g, b) ? null : fromRgb({
|
|
166
|
-
r,
|
|
167
|
-
g,
|
|
168
|
-
b
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
case "hsl":
|
|
172
|
-
case "hsla": {
|
|
173
|
-
const h = hueArgument(args[0]);
|
|
174
|
-
const s = scalar(args[1], 100) / 100;
|
|
175
|
-
const l = scalar(args[2], 100) / 100;
|
|
176
|
-
if (anyNaN(h, s, l)) return null;
|
|
177
|
-
return fromRgb(rgbFromSrgb(hslToSrgb(h, clamp(s, 0, 1), clamp(l, 0, 1))));
|
|
178
|
-
}
|
|
179
|
-
case "okhsl": {
|
|
180
|
-
const h = hueArgument(args[0]);
|
|
181
|
-
const s = scalar(args[1], 100) / 100;
|
|
182
|
-
const l = scalar(args[2], 100) / 100;
|
|
183
|
-
if (anyNaN(h, s, l)) return null;
|
|
184
|
-
return {
|
|
185
|
-
h,
|
|
186
|
-
s: clamp(s, 0, 1),
|
|
187
|
-
l: clamp(l, 0, 1)
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
case "okhst": {
|
|
191
|
-
const h = hueArgument(args[0]);
|
|
192
|
-
const s = scalar(args[1], 100) / 100;
|
|
193
|
-
const t = scalar(args[2], 100) / 100;
|
|
194
|
-
if (anyNaN(h, s, t)) return null;
|
|
195
|
-
return fromOkhst({
|
|
196
|
-
h,
|
|
197
|
-
s,
|
|
198
|
-
t
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
case "oklch": {
|
|
202
|
-
const l = scalar(args[0], 1);
|
|
203
|
-
const c = scalar(args[1], .4);
|
|
204
|
-
const h = hueArgument(args[2]);
|
|
205
|
-
return anyNaN(l, c, h) ? null : fromOklch({
|
|
206
|
-
l,
|
|
207
|
-
c,
|
|
208
|
-
h
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
default: return null;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function anyNaN(...values) {
|
|
215
|
-
return values.some((value) => !Number.isFinite(value));
|
|
216
|
-
}
|
|
217
|
-
function rgbFromSrgb([r, g, b]) {
|
|
218
|
-
return {
|
|
219
|
-
r: r * 255,
|
|
220
|
-
g: g * 255,
|
|
221
|
-
b: b * 255
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
/** Serialize the canonical color into one of the supported notations. */
|
|
225
|
-
function formatColor(color, format) {
|
|
226
|
-
const gray = isAchromatic(color);
|
|
227
|
-
const hue = gray ? 0 : color.h;
|
|
228
|
-
const saturation = color.s * 100;
|
|
229
|
-
const lightness = color.l * 100;
|
|
230
|
-
switch (format) {
|
|
231
|
-
case "rgb": return formatRgb(hue, saturation, lightness);
|
|
232
|
-
case "hsl": {
|
|
233
|
-
const text = formatHsl(hue, saturation, lightness);
|
|
234
|
-
return gray ? text.replace(/\(-?[\d.]+/, "(0") : text;
|
|
235
|
-
}
|
|
236
|
-
case "okhsl": return formatOkhsl(hue, saturation, lightness);
|
|
237
|
-
case "okhst": return formatOkhst(hue, saturation, toOkhst(color).t * 100);
|
|
238
|
-
case "oklch": return formatOklch(hue, saturation, lightness);
|
|
239
|
-
default: return toHex(color);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Which notation a string is written in, or `null` when it is not a color.
|
|
244
|
-
* Used to keep the user's own notation while still normalizing the value.
|
|
245
|
-
*/
|
|
246
|
-
function detectFormat(input) {
|
|
247
|
-
const text = input.trim().toLowerCase();
|
|
248
|
-
if (!parseColor(text)) return null;
|
|
249
|
-
if (text.startsWith("#")) return "hex";
|
|
250
|
-
switch (FUNCTION_RE.exec(text)?.[1]) {
|
|
251
|
-
case "rgb":
|
|
252
|
-
case "rgba": return "rgb";
|
|
253
|
-
case "hsl":
|
|
254
|
-
case "hsla": return "hsl";
|
|
255
|
-
case "okhsl": return "okhsl";
|
|
256
|
-
case "okhst": return "okhst";
|
|
257
|
-
case "oklch": return "oklch";
|
|
258
|
-
default: return null;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Black or white — whichever the WCAG contrast ratio favors on the given
|
|
263
|
-
* color. Keeps the popover preview label readable at any lightness. Returns a
|
|
264
|
-
* literal hex rather than a token, because the answer is measured against this
|
|
265
|
-
* exact fill and must not adapt with the color scheme.
|
|
266
|
-
*/
|
|
267
|
-
function getContrastingColor(color) {
|
|
268
|
-
const luminance = relativeLuminanceFromLinearRgb(okhslToLinearSrgb(color.h, color.s, color.l));
|
|
269
|
-
return contrastRatioFromLuminance(luminance, 0) >= contrastRatioFromLuminance(1, luminance) ? "#000000" : "#ffffff";
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
//#endregion
|
|
273
|
-
export { COLOR_FORMATS, detectFormat, formatColor, fromOkhst, fromOklch, fromRgb, getContrastingColor, isAchromatic, maxChroma, normalizeHue, parseColor, toHex, toOkhst, toOklch, toRgb };
|
|
274
|
-
//# sourceMappingURL=color.js.map
|