@lobehub/ui 6.0.0-beta.7 → 6.0.0-beta.9
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/es/Accordion/Accordion.mjs +3 -3
- package/es/Accordion/Accordion.mjs.map +1 -1
- package/es/Accordion/atoms.mjs +2 -2
- package/es/Accordion/atoms.mjs.map +1 -1
- package/es/Accordion/style.d.mts +1 -1
- package/es/ActionIcon/ActionIcon.mjs +2 -2
- package/es/ActionIcon/ActionIcon.mjs.map +1 -1
- package/es/Alert/Alert.mjs +5 -5
- package/es/Alert/Alert.mjs.map +1 -1
- package/es/AutoComplete/AutoComplete.mjs +5 -5
- package/es/AutoComplete/AutoComplete.mjs.map +1 -1
- package/es/AutoComplete/style.mjs +2 -2
- package/es/AutoComplete/style.mjs.map +1 -1
- package/es/Avatar/Avatar.mjs +2 -2
- package/es/Avatar/Avatar.mjs.map +1 -1
- package/es/Avatar/AvatarGroup/index.mjs +2 -2
- package/es/Avatar/AvatarGroup/index.mjs.map +1 -1
- package/es/Breadcrumb/Breadcrumb.mjs +2 -2
- package/es/Breadcrumb/Breadcrumb.mjs.map +1 -1
- package/es/Button/Button.mjs +1 -1
- package/es/Button/Button.mjs.map +1 -1
- package/es/Button/style.d.mts +8 -1
- package/es/Button/style.mjs +41 -18
- package/es/Button/style.mjs.map +1 -1
- package/es/Checkbox/Checkbox.mjs +3 -3
- package/es/Checkbox/Checkbox.mjs.map +1 -1
- package/es/CodeDiff/DiffPanel.mjs +4 -4
- package/es/CodeDiff/DiffPanel.mjs.map +1 -1
- package/es/CodeEditor/CodeEditor.mjs +4 -4
- package/es/CodeEditor/CodeEditor.mjs.map +1 -1
- package/es/ColorPicker/ColorInputs.mjs +136 -0
- package/es/ColorPicker/ColorInputs.mjs.map +1 -0
- package/es/ColorPicker/ColorPanel.mjs +145 -0
- package/es/ColorPicker/ColorPanel.mjs.map +1 -0
- package/es/ColorPicker/ColorPicker.mjs +62 -199
- package/es/ColorPicker/ColorPicker.mjs.map +1 -1
- package/es/ColorPicker/SaturationArea.mjs +2 -1
- package/es/ColorPicker/SaturationArea.mjs.map +1 -1
- package/es/ColorPicker/Swatch.mjs +24 -0
- package/es/ColorPicker/Swatch.mjs.map +1 -0
- package/es/ColorPicker/Swatches.mjs +66 -0
- package/es/ColorPicker/Swatches.mjs.map +1 -0
- package/es/ColorPicker/Trigger.mjs +112 -0
- package/es/ColorPicker/Trigger.mjs.map +1 -0
- package/es/ColorPicker/color.mjs +25 -1
- package/es/ColorPicker/color.mjs.map +1 -1
- package/es/ColorPicker/recent.mjs +25 -0
- package/es/ColorPicker/recent.mjs.map +1 -0
- package/es/ColorPicker/style.mjs +269 -70
- package/es/ColorPicker/style.mjs.map +1 -1
- package/es/ColorPicker/type.d.mts +15 -0
- package/es/ContextMenu/ContextMenuHost.mjs +2 -2
- package/es/ContextMenu/ContextMenuHost.mjs.map +1 -1
- package/es/ContextMenu/ContextMenuTrigger.mjs +2 -2
- package/es/ContextMenu/ContextMenuTrigger.mjs.map +1 -1
- package/es/ContextMenu/renderItems.mjs +3 -3
- package/es/ContextMenu/renderItems.mjs.map +1 -1
- package/es/DatePicker/DatePicker.d.mts +9 -2
- package/es/DatePicker/DatePicker.mjs +15 -85
- package/es/DatePicker/DatePicker.mjs.map +1 -1
- package/es/DatePicker/DateRangePicker.d.mts +3 -2
- package/es/DatePicker/DateRangePicker.mjs +3 -125
- package/es/DatePicker/DateRangePicker.mjs.map +1 -1
- package/es/DatePicker/DayjsDatePicker.d.mts +12 -0
- package/es/DatePicker/DayjsDatePicker.mjs +19 -0
- package/es/DatePicker/DayjsDatePicker.mjs.map +1 -0
- package/es/DatePicker/DayjsDateRangePicker.d.mts +7 -0
- package/es/DatePicker/DayjsDateRangePicker.mjs +8 -0
- package/es/DatePicker/DayjsDateRangePicker.mjs.map +1 -0
- package/es/DatePicker/PurePanel.mjs +65 -0
- package/es/DatePicker/PurePanel.mjs.map +1 -0
- package/es/DatePicker/RangePicker.mjs +121 -0
- package/es/DatePicker/RangePicker.mjs.map +1 -0
- package/es/DatePicker/SinglePicker.mjs +134 -0
- package/es/DatePicker/SinglePicker.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Popup/Footer.mjs +57 -0
- package/es/DatePicker/core/PickerInput/Popup/Footer.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Popup/PopupPanel.mjs +57 -0
- package/es/DatePicker/core/PickerInput/Popup/PopupPanel.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Popup/PresetPanel.mjs +29 -0
- package/es/DatePicker/core/PickerInput/Popup/PresetPanel.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Popup/index.mjs +133 -0
- package/es/DatePicker/core/PickerInput/Popup/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/RangePicker.d.mts +51 -0
- package/es/DatePicker/core/PickerInput/RangePicker.mjs +343 -0
- package/es/DatePicker/core/PickerInput/RangePicker.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/ClearIcon.mjs +27 -0
- package/es/DatePicker/core/PickerInput/Selector/ClearIcon.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/Icon.mjs +19 -0
- package/es/DatePicker/core/PickerInput/Selector/Icon.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/Input.mjs +237 -0
- package/es/DatePicker/core/PickerInput/Selector/Input.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/MaskFormat.mjs +70 -0
- package/es/DatePicker/core/PickerInput/Selector/MaskFormat.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/RangeSelector.d.mts +8 -0
- package/es/DatePicker/core/PickerInput/Selector/RangeSelector.mjs +136 -0
- package/es/DatePicker/core/PickerInput/Selector/RangeSelector.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/SingleSelector/HoverSelector.mjs +28 -0
- package/es/DatePicker/core/PickerInput/Selector/SingleSelector/HoverSelector.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/SingleSelector/MultipleDates.mjs +69 -0
- package/es/DatePicker/core/PickerInput/Selector/SingleSelector/MultipleDates.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/SingleSelector/index.mjs +111 -0
- package/es/DatePicker/core/PickerInput/Selector/SingleSelector/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/hooks/useClearIcon.mjs +18 -0
- package/es/DatePicker/core/PickerInput/Selector/hooks/useClearIcon.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/hooks/useInputProps.mjs +108 -0
- package/es/DatePicker/core/PickerInput/Selector/hooks/useInputProps.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/hooks/useRootProps.mjs +11 -0
- package/es/DatePicker/core/PickerInput/Selector/hooks/useRootProps.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/Selector/util.mjs +20 -0
- package/es/DatePicker/core/PickerInput/Selector/util.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/SinglePicker.d.mts +55 -0
- package/es/DatePicker/core/PickerInput/SinglePicker.mjs +318 -0
- package/es/DatePicker/core/PickerInput/SinglePicker.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/context.mjs +7 -0
- package/es/DatePicker/core/PickerInput/context.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useCellRender.mjs +30 -0
- package/es/DatePicker/core/PickerInput/hooks/useCellRender.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useDelayState.mjs +37 -0
- package/es/DatePicker/core/PickerInput/hooks/useDelayState.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useDisabledBoundary.mjs +18 -0
- package/es/DatePicker/core/PickerInput/hooks/useDisabledBoundary.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useFieldFormat.mjs +20 -0
- package/es/DatePicker/core/PickerInput/hooks/useFieldFormat.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useFieldsInvalidate.mjs +31 -0
- package/es/DatePicker/core/PickerInput/hooks/useFieldsInvalidate.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useFilledProps.mjs +98 -0
- package/es/DatePicker/core/PickerInput/hooks/useFilledProps.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useFocusEvents.mjs +41 -0
- package/es/DatePicker/core/PickerInput/hooks/useFocusEvents.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useFocusLock.mjs +34 -0
- package/es/DatePicker/core/PickerInput/hooks/useFocusLock.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useHoverStore.mjs +35 -0
- package/es/DatePicker/core/PickerInput/hooks/useHoverStore.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useInputReadOnly.mjs +9 -0
- package/es/DatePicker/core/PickerInput/hooks/useInputReadOnly.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useInvalidate.mjs +36 -0
- package/es/DatePicker/core/PickerInput/hooks/useInvalidate.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useLockEffect.mjs +27 -0
- package/es/DatePicker/core/PickerInput/hooks/useLockEffect.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useOpen.mjs +18 -0
- package/es/DatePicker/core/PickerInput/hooks/useOpen.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/usePickerRef.mjs +19 -0
- package/es/DatePicker/core/PickerInput/hooks/usePickerRef.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/usePresets.mjs +20 -0
- package/es/DatePicker/core/PickerInput/hooks/usePresets.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangeDisabledDate.mjs +24 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangeDisabledDate.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangePickerValue.mjs +107 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangePickerValue.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangeValue.mjs +144 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangeValue.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangeValueChange.mjs +219 -0
- package/es/DatePicker/core/PickerInput/hooks/useRangeValueChange.mjs.map +1 -0
- package/es/DatePicker/core/PickerInput/hooks/useShowNow.mjs +11 -0
- package/es/DatePicker/core/PickerInput/hooks/useShowNow.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/DatePanel/index.mjs +131 -0
- package/es/DatePicker/core/PickerPanel/DatePanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/DateTimePanel/index.mjs +35 -0
- package/es/DatePicker/core/PickerPanel/DateTimePanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/DecadePanel/index.mjs +84 -0
- package/es/DatePicker/core/PickerPanel/DecadePanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/MonthPanel/index.mjs +73 -0
- package/es/DatePicker/core/PickerPanel/MonthPanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/PanelBody.mjs +95 -0
- package/es/DatePicker/core/PickerPanel/PanelBody.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/PanelHeader.mjs +130 -0
- package/es/DatePicker/core/PickerPanel/PanelHeader.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/QuarterPanel/index.mjs +64 -0
- package/es/DatePicker/core/PickerPanel/QuarterPanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimeClock/ClockDial.mjs +108 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimeClock/ClockDial.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimeClock/geometry.mjs +44 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimeClock/geometry.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimeClock/index.mjs +157 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimeClock/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/TimeColumn.mjs +100 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/TimeColumn.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/index.mjs +71 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/useScrollTo.mjs +62 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/useScrollTo.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/useTimeState.mjs +200 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/useTimeState.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/util.mjs +25 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/TimePanelBody/util.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/index.mjs +31 -0
- package/es/DatePicker/core/PickerPanel/TimePanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/WeekPanel/index.mjs +34 -0
- package/es/DatePicker/core/PickerPanel/WeekPanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/YearPanel/index.mjs +92 -0
- package/es/DatePicker/core/PickerPanel/YearPanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/context.mjs +48 -0
- package/es/DatePicker/core/PickerPanel/context.mjs.map +1 -0
- package/es/DatePicker/core/PickerPanel/index.d.mts +1 -0
- package/es/DatePicker/core/PickerPanel/index.mjs +175 -0
- package/es/DatePicker/core/PickerPanel/index.mjs.map +1 -0
- package/es/DatePicker/core/PickerPopup.mjs +118 -0
- package/es/DatePicker/core/PickerPopup.mjs.map +1 -0
- package/es/DatePicker/core/generate/dayjs.mjs +109 -0
- package/es/DatePicker/core/generate/dayjs.mjs.map +1 -0
- package/es/DatePicker/core/generate/index.d.mts +40 -0
- package/es/DatePicker/core/hooks/react.mjs +58 -0
- package/es/DatePicker/core/hooks/react.mjs.map +1 -0
- package/es/DatePicker/core/hooks/useLocale.mjs +51 -0
- package/es/DatePicker/core/hooks/useLocale.mjs.map +1 -0
- package/es/DatePicker/core/hooks/useSemantic.mjs +20 -0
- package/es/DatePicker/core/hooks/useSemantic.mjs.map +1 -0
- package/es/DatePicker/core/hooks/useSyncState.mjs +25 -0
- package/es/DatePicker/core/hooks/useSyncState.mjs.map +1 -0
- package/es/DatePicker/core/hooks/useTimeConfig.mjs +173 -0
- package/es/DatePicker/core/hooks/useTimeConfig.mjs.map +1 -0
- package/es/DatePicker/core/hooks/useTimeInfo.mjs +110 -0
- package/es/DatePicker/core/hooks/useTimeInfo.mjs.map +1 -0
- package/es/DatePicker/core/hooks/useToggleDates.mjs +21 -0
- package/es/DatePicker/core/hooks/useToggleDates.mjs.map +1 -0
- package/es/DatePicker/core/index.d.mts +5 -0
- package/es/DatePicker/core/index.mjs +9 -0
- package/es/DatePicker/core/index.mjs.map +1 -0
- package/es/DatePicker/core/interface.d.mts +325 -0
- package/es/DatePicker/core/locale/common.mjs +11 -0
- package/es/DatePicker/core/locale/common.mjs.map +1 -0
- package/es/DatePicker/core/locale/en_US.mjs +39 -0
- package/es/DatePicker/core/locale/en_US.mjs.map +1 -0
- package/es/DatePicker/core/utils/common.mjs +73 -0
- package/es/DatePicker/core/utils/common.mjs.map +1 -0
- package/es/DatePicker/core/utils/dateUtil.mjs +106 -0
- package/es/DatePicker/core/utils/dateUtil.mjs.map +1 -0
- package/es/DatePicker/core/utils/miscUtil.mjs +46 -0
- package/es/DatePicker/core/utils/miscUtil.mjs.map +1 -0
- package/es/DatePicker/core/utils/uiUtil.mjs +9 -0
- package/es/DatePicker/core/utils/uiUtil.mjs.map +1 -0
- package/es/DatePicker/dateGenerateConfig.mjs +52 -0
- package/es/DatePicker/dateGenerateConfig.mjs.map +1 -0
- package/es/DatePicker/generateConfig.mjs +12 -0
- package/es/DatePicker/generateConfig.mjs.map +1 -0
- package/es/DatePicker/generatePicker.d.mts +12 -0
- package/es/DatePicker/generatePicker.mjs +22 -0
- package/es/DatePicker/generatePicker.mjs.map +1 -0
- package/es/DatePicker/index.d.mts +8 -3
- package/es/DatePicker/index.mjs +5 -1
- package/es/DatePicker/legacyDate.mjs +58 -0
- package/es/DatePicker/legacyDate.mjs.map +1 -0
- package/es/DatePicker/locale.d.mts +15 -0
- package/es/DatePicker/locale.mjs +143 -0
- package/es/DatePicker/locale.mjs.map +1 -0
- package/es/DatePicker/semantic.mjs +29 -0
- package/es/DatePicker/semantic.mjs.map +1 -0
- package/es/DatePicker/style.mjs +3 -155
- package/es/DatePicker/style.mjs.map +1 -1
- package/es/DatePicker/type.d.mts +294 -27
- package/es/DatePicker/usePanelKeyboard.mjs +230 -0
- package/es/DatePicker/usePanelKeyboard.mjs.map +1 -0
- package/es/DatePicker/usePickerShared.mjs +106 -0
- package/es/DatePicker/usePickerShared.mjs.map +1 -0
- package/es/DatePicker/usePresetActive.mjs +49 -0
- package/es/DatePicker/usePresetActive.mjs.map +1 -0
- package/es/DraggablePanel/atoms.mjs +5 -5
- package/es/DraggablePanel/atoms.mjs.map +1 -1
- package/es/DraggableSideNav/DraggableSideNav.mjs +3 -3
- package/es/DraggableSideNav/DraggableSideNav.mjs.map +1 -1
- package/es/Drawer/Drawer.mjs +2 -2
- package/es/Drawer/Drawer.mjs.map +1 -1
- package/es/Drawer/atoms.mjs +6 -6
- package/es/Drawer/atoms.mjs.map +1 -1
- package/es/DropdownMenu/atoms.mjs +22 -22
- package/es/DropdownMenu/atoms.mjs.map +1 -1
- package/es/DropdownMenu/sharedStyle.mjs +2 -2
- package/es/DropdownMenu/sharedStyle.mjs.map +1 -1
- package/es/EditorSlashMenu/atoms.mjs +12 -12
- package/es/EditorSlashMenu/atoms.mjs.map +1 -1
- package/es/EmojiPicker/EmojiPicker.mjs +7 -7
- package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
- package/es/EmojiPicker/loadEmojiData.mjs +6 -0
- package/es/EmojiPicker/loadEmojiData.mjs.map +1 -0
- package/es/FloatingPanel/FloatingPanel.mjs +2 -2
- package/es/FloatingPanel/FloatingPanel.mjs.map +1 -1
- package/es/FormKit/List.mjs +2 -2
- package/es/FormKit/List.mjs.map +1 -1
- package/es/Highlighter/FullFeatured.mjs +2 -2
- package/es/Highlighter/FullFeatured.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/StreamRenderer.mjs +2 -2
- package/es/Highlighter/SyntaxHighlighter/StreamRenderer.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/index.mjs +4 -4
- package/es/Highlighter/SyntaxHighlighter/index.mjs.map +1 -1
- package/es/Highlighter/style.mjs +2 -2
- package/es/Highlighter/style.mjs.map +1 -1
- package/es/HtmlPreview/HtmlPreview.mjs +2 -2
- package/es/HtmlPreview/HtmlPreview.mjs.map +1 -1
- package/es/Icon/Icon.mjs +2 -2
- package/es/Icon/Icon.mjs.map +1 -1
- package/es/List/ListRow.mjs +3 -3
- package/es/List/ListRow.mjs.map +1 -1
- package/es/Markdown/Markdown.mjs +2 -2
- package/es/Markdown/Markdown.mjs.map +1 -1
- package/es/Markdown/Typography.mjs +2 -2
- package/es/Markdown/Typography.mjs.map +1 -1
- package/es/Mermaid/FullFeatured.mjs +2 -2
- package/es/Mermaid/FullFeatured.mjs.map +1 -1
- package/es/Mermaid/SyntaxMermaid/index.mjs +4 -4
- package/es/Mermaid/SyntaxMermaid/index.mjs.map +1 -1
- package/es/Modal/atoms.mjs +6 -6
- package/es/Modal/atoms.mjs.map +1 -1
- package/es/Pagination/Pagination.mjs +181 -41
- package/es/Pagination/Pagination.mjs.map +1 -1
- package/es/Pagination/helpers.mjs +3 -3
- package/es/Pagination/helpers.mjs.map +1 -1
- package/es/Pagination/index.d.mts +2 -2
- package/es/Pagination/marker.stylex.mjs +9 -0
- package/es/Pagination/marker.stylex.mjs.map +1 -0
- package/es/Pagination/style.mjs +74 -4
- package/es/Pagination/style.mjs.map +1 -1
- package/es/Pagination/type.d.mts +41 -3
- package/es/Popover/PopoverInGroup.mjs +2 -2
- package/es/Popover/PopoverInGroup.mjs.map +1 -1
- package/es/Popover/atoms.mjs +6 -6
- package/es/Popover/atoms.mjs.map +1 -1
- package/es/ProTable/ProTable.d.mts +11 -0
- package/es/ProTable/ProTable.mjs +208 -0
- package/es/ProTable/ProTable.mjs.map +1 -0
- package/es/ProTable/hooks/useColumnRequest.mjs +55 -0
- package/es/ProTable/hooks/useColumnRequest.mjs.map +1 -0
- package/es/ProTable/hooks/useColumnsState.mjs +37 -0
- package/es/ProTable/hooks/useColumnsState.mjs.map +1 -0
- package/es/ProTable/hooks/useDelayedFlag.mjs +18 -0
- package/es/ProTable/hooks/useDelayedFlag.mjs.map +1 -0
- package/es/ProTable/hooks/useDensity.mjs +15 -0
- package/es/ProTable/hooks/useDensity.mjs.map +1 -0
- package/es/ProTable/hooks/useFetchData.mjs +97 -0
- package/es/ProTable/hooks/useFetchData.mjs.map +1 -0
- package/es/ProTable/hooks/useFullscreen.mjs +22 -0
- package/es/ProTable/hooks/useFullscreen.mjs.map +1 -0
- package/es/ProTable/hooks/usePageInfo.mjs +35 -0
- package/es/ProTable/hooks/usePageInfo.mjs.map +1 -0
- package/es/ProTable/hooks/useProColumns.mjs +123 -0
- package/es/ProTable/hooks/useProColumns.mjs.map +1 -0
- package/es/ProTable/hooks/useProLoading.mjs +19 -0
- package/es/ProTable/hooks/useProLoading.mjs.map +1 -0
- package/es/ProTable/hooks/useProLocale.mjs +22 -0
- package/es/ProTable/hooks/useProLocale.mjs.map +1 -0
- package/es/ProTable/hooks/useProRequest.mjs +137 -0
- package/es/ProTable/hooks/useProRequest.mjs.map +1 -0
- package/es/ProTable/hooks/useRowCache.mjs +11 -0
- package/es/ProTable/hooks/useRowCache.mjs.map +1 -0
- package/es/ProTable/hooks/useSearchForm.mjs +141 -0
- package/es/ProTable/hooks/useSearchForm.mjs.map +1 -0
- package/es/ProTable/hooks/useTableBindings.mjs +39 -0
- package/es/ProTable/hooks/useTableBindings.mjs.map +1 -0
- package/es/ProTable/hooks/useTableSelection.mjs +14 -0
- package/es/ProTable/hooks/useTableSelection.mjs.map +1 -0
- package/es/ProTable/index.d.mts +4 -0
- package/es/ProTable/index.d.ts +1 -0
- package/es/ProTable/index.js +1 -0
- package/es/ProTable/index.mjs +3 -0
- package/es/ProTable/locale.d.mts +15 -0
- package/es/ProTable/locale.mjs +66 -0
- package/es/ProTable/locale.mjs.map +1 -0
- package/es/ProTable/parts/ColumnSetting.mjs +155 -0
- package/es/ProTable/parts/ColumnSetting.mjs.map +1 -0
- package/es/ProTable/parts/FieldControl.mjs +117 -0
- package/es/ProTable/parts/FieldControl.mjs.map +1 -0
- package/es/ProTable/parts/KeywordInput.mjs +19 -0
- package/es/ProTable/parts/KeywordInput.mjs.map +1 -0
- package/es/ProTable/parts/LightFilter.mjs +70 -0
- package/es/ProTable/parts/LightFilter.mjs.map +1 -0
- package/es/ProTable/parts/OptionPopover.mjs +17 -0
- package/es/ProTable/parts/OptionPopover.mjs.map +1 -0
- package/es/ProTable/parts/SearchForm.mjs +180 -0
- package/es/ProTable/parts/SearchForm.mjs.map +1 -0
- package/es/ProTable/parts/SearchSection.mjs +33 -0
- package/es/ProTable/parts/SearchSection.mjs.map +1 -0
- package/es/ProTable/parts/TableAlert.mjs +38 -0
- package/es/ProTable/parts/TableAlert.mjs.map +1 -0
- package/es/ProTable/parts/Toolbar.mjs +50 -0
- package/es/ProTable/parts/Toolbar.mjs.map +1 -0
- package/es/ProTable/parts/ToolbarOptions.mjs +103 -0
- package/es/ProTable/parts/ToolbarOptions.mjs.map +1 -0
- package/es/ProTable/parts/renderValue.mjs +118 -0
- package/es/ProTable/parts/renderValue.mjs.map +1 -0
- package/es/ProTable/style.mjs +278 -0
- package/es/ProTable/style.mjs.map +1 -0
- package/es/ProTable/type.d.mts +397 -0
- package/es/ProTable/utils.mjs +152 -0
- package/es/ProTable/utils.mjs.map +1 -0
- package/es/Radio/Radio.mjs +3 -3
- package/es/Radio/Radio.mjs.map +1 -1
- package/es/ScrollArea/atoms.mjs +4 -4
- package/es/ScrollArea/atoms.mjs.map +1 -1
- package/es/Segmented/Segmented.mjs +3 -3
- package/es/Segmented/Segmented.mjs.map +1 -1
- package/es/Segmented/atoms.mjs +2 -2
- package/es/Segmented/atoms.mjs.map +1 -1
- package/es/Select/Select.mjs +22 -13
- package/es/Select/Select.mjs.map +1 -1
- package/es/Select/atoms.mjs +4 -4
- package/es/Select/atoms.mjs.map +1 -1
- package/es/Select/helpers.mjs +8 -1
- package/es/Select/helpers.mjs.map +1 -1
- package/es/Select/hooks.mjs +8 -4
- package/es/Select/hooks.mjs.map +1 -1
- package/es/Select/renderOptions.mjs +2 -2
- package/es/Select/renderOptions.mjs.map +1 -1
- package/es/Select/type.d.mts +7 -0
- package/es/Switch/Switch.mjs +2 -2
- package/es/Switch/Switch.mjs.map +1 -1
- package/es/Switch/atoms.mjs +2 -2
- package/es/Switch/atoms.mjs.map +1 -1
- package/es/Table/Column.d.mts +8 -0
- package/es/Table/Column.mjs +6 -0
- package/es/Table/Column.mjs.map +1 -0
- package/es/Table/ColumnGroup.d.mts +11 -0
- package/es/Table/ColumnGroup.mjs +6 -0
- package/es/Table/ColumnGroup.mjs.map +1 -0
- package/es/Table/Table.d.mts +16 -2
- package/es/Table/Table.mjs +149 -118
- package/es/Table/Table.mjs.map +1 -1
- package/es/Table/atoms/cells.d.mts +42 -0
- package/es/Table/atoms/cells.mjs +72 -0
- package/es/Table/atoms/cells.mjs.map +1 -0
- package/es/Table/atoms/index.d.mts +3 -0
- package/es/Table/atoms/layout.d.mts +44 -0
- package/es/Table/atoms/layout.mjs +62 -0
- package/es/Table/atoms/layout.mjs.map +1 -0
- package/es/Table/constants.mjs +16 -0
- package/es/Table/constants.mjs.map +1 -0
- package/es/Table/engine/fixed.d.mts +1 -0
- package/es/Table/engine/fixed.mjs +53 -0
- package/es/Table/engine/fixed.mjs.map +1 -0
- package/es/Table/engine/types.d.mts +1 -0
- package/es/Table/engine/useTableEngine.mjs +180 -0
- package/es/Table/engine/useTableEngine.mjs.map +1 -0
- package/es/Table/index.d.mts +7 -2
- package/es/Table/index.mjs +4 -1
- package/es/Table/internal.d.mts +3 -0
- package/es/Table/pipeline/columnUtils.d.mts +5 -0
- package/es/Table/pipeline/columnUtils.mjs +58 -0
- package/es/Table/pipeline/columnUtils.mjs.map +1 -0
- package/es/Table/pipeline/convertChildrenToColumns.mjs +24 -0
- package/es/Table/pipeline/convertChildrenToColumns.mjs.map +1 -0
- package/es/Table/pipeline/normalizeColumns.mjs +140 -0
- package/es/Table/pipeline/normalizeColumns.mjs.map +1 -0
- package/es/Table/pipeline/selectionUtils.d.mts +9 -0
- package/es/Table/pipeline/selectionUtils.mjs +115 -0
- package/es/Table/pipeline/selectionUtils.mjs.map +1 -0
- package/es/Table/pipeline/useBreakpoint.mjs +36 -0
- package/es/Table/pipeline/useBreakpoint.mjs.map +1 -0
- package/es/Table/pipeline/useExpandable.mjs +45 -0
- package/es/Table/pipeline/useExpandable.mjs.map +1 -0
- package/es/Table/pipeline/useFilter.mjs +52 -0
- package/es/Table/pipeline/useFilter.mjs.map +1 -0
- package/es/Table/pipeline/useSelection.mjs +302 -0
- package/es/Table/pipeline/useSelection.mjs.map +1 -0
- package/es/Table/pipeline/useSorter.mjs +146 -0
- package/es/Table/pipeline/useSorter.mjs.map +1 -0
- package/es/Table/pipeline/useTableLocale.mjs +30 -0
- package/es/Table/pipeline/useTableLocale.mjs.map +1 -0
- package/es/Table/pipeline/useTableState.mjs +118 -0
- package/es/Table/pipeline/useTableState.mjs.map +1 -0
- package/es/Table/pipeline/useVirtualLayout.mjs +80 -0
- package/es/Table/pipeline/useVirtualLayout.mjs.map +1 -0
- package/es/Table/render/Body.mjs +150 -0
- package/es/Table/render/Body.mjs.map +1 -0
- package/es/Table/render/BodyCell.mjs +87 -0
- package/es/Table/render/BodyCell.mjs.map +1 -0
- package/es/Table/render/CellShell.mjs +84 -0
- package/es/Table/render/CellShell.mjs.map +1 -0
- package/es/Table/render/ExpandIcon.mjs +28 -0
- package/es/Table/render/ExpandIcon.mjs.map +1 -0
- package/es/Table/render/FilterDropdown.mjs +139 -0
- package/es/Table/render/FilterDropdown.mjs.map +1 -0
- package/es/Table/render/FilterPanel.mjs +152 -0
- package/es/Table/render/FilterPanel.mjs.map +1 -0
- package/es/Table/render/FixedFrost.mjs +113 -0
- package/es/Table/render/FixedFrost.mjs.map +1 -0
- package/es/Table/render/FixedHolder.mjs +51 -0
- package/es/Table/render/FixedHolder.mjs.map +1 -0
- package/es/Table/render/Header.mjs +184 -0
- package/es/Table/render/Header.mjs.map +1 -0
- package/es/Table/render/LoadingSkeleton.mjs +78 -0
- package/es/Table/render/LoadingSkeleton.mjs.map +1 -0
- package/es/Table/render/PaginationBar.mjs +71 -0
- package/es/Table/render/PaginationBar.mjs.map +1 -0
- package/es/Table/render/SelectionCells.mjs +111 -0
- package/es/Table/render/SelectionCells.mjs.map +1 -0
- package/es/Table/render/StickyScrollBar.mjs +99 -0
- package/es/Table/render/StickyScrollBar.mjs.map +1 -0
- package/es/Table/render/Summary.d.mts +16 -0
- package/es/Table/render/Summary.mjs +58 -0
- package/es/Table/render/Summary.mjs.map +1 -0
- package/es/Table/render/TableView.mjs +215 -0
- package/es/Table/render/TableView.mjs.map +1 -0
- package/es/Table/render/VirtualBody.mjs +101 -0
- package/es/Table/render/VirtualBody.mjs.map +1 -0
- package/es/Table/render/context.mjs +15 -0
- package/es/Table/render/context.mjs.map +1 -0
- package/es/Table/render/filterUtils.mjs +22 -0
- package/es/Table/render/filterUtils.mjs.map +1 -0
- package/es/Table/render/tableHelpers.mjs +27 -0
- package/es/Table/render/tableHelpers.mjs.map +1 -0
- package/es/Table/render/useColGroups.mjs +23 -0
- package/es/Table/render/useColGroups.mjs.map +1 -0
- package/es/Table/render/useScrollSync.mjs +104 -0
- package/es/Table/render/useScrollSync.mjs.map +1 -0
- package/es/Table/render/useViewContexts.mjs +134 -0
- package/es/Table/render/useViewContexts.mjs.map +1 -0
- package/es/Table/semantic.mjs +45 -0
- package/es/Table/semantic.mjs.map +1 -0
- package/es/Table/store/createTableStore.d.mts +1 -0
- package/es/Table/store/createTableStore.mjs +40 -0
- package/es/Table/store/createTableStore.mjs.map +1 -0
- package/es/Table/store/hooks.mjs +24 -0
- package/es/Table/store/hooks.mjs.map +1 -0
- package/es/Table/style.mjs +175 -90
- package/es/Table/style.mjs.map +1 -1
- package/es/Table/type.d.mts +467 -37
- package/es/Table/useTableController.mjs +293 -0
- package/es/Table/useTableController.mjs.map +1 -0
- package/es/Tabs/Tabs.mjs +2 -2
- package/es/Tabs/Tabs.mjs.map +1 -1
- package/es/Tabs/atoms.mjs +2 -2
- package/es/Tabs/atoms.mjs.map +1 -1
- package/es/Tag/Tag.mjs +2 -2
- package/es/Tag/Tag.mjs.map +1 -1
- package/es/Text/Text.mjs +2 -2
- package/es/Text/Text.mjs.map +1 -1
- package/es/Text/style.d.mts +3 -3
- package/es/Text/style.mjs +3 -3
- package/es/Text/style.mjs.map +1 -1
- package/es/ToggleGroup/ToggleGroup.mjs +3 -3
- package/es/ToggleGroup/ToggleGroup.mjs.map +1 -1
- package/es/ToggleGroup/atoms.mjs +2 -2
- package/es/ToggleGroup/atoms.mjs.map +1 -1
- package/es/Tooltip/TooltipGroup.mjs +3 -3
- package/es/Tooltip/TooltipGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipStandalone.mjs +3 -3
- package/es/Tooltip/TooltipStandalone.mjs.map +1 -1
- package/es/Tree/Tree.mjs +2 -2
- package/es/Tree/Tree.mjs.map +1 -1
- package/es/Tree/TreeNode.mjs +2 -2
- package/es/Tree/TreeNode.mjs.map +1 -1
- package/es/Video/Video.mjs +2 -2
- package/es/Video/Video.mjs.map +1 -1
- package/es/awesome/Features/FeatureItem.mjs +2 -2
- package/es/awesome/Features/FeatureItem.mjs.map +1 -1
- package/es/awesome/Hero/Hero.mjs +3 -3
- package/es/awesome/Hero/Hero.mjs.map +1 -1
- package/es/awesome/InstallBanner/InstallBanner.mjs +2 -2
- package/es/awesome/InstallBanner/InstallBanner.mjs.map +1 -1
- package/es/awesome/LandingHero/LandingHero.mjs +3 -3
- package/es/awesome/LandingHero/LandingHero.mjs.map +1 -1
- package/es/awesome/LogoMarquee/LogoMarquee.mjs +2 -2
- package/es/awesome/LogoMarquee/LogoMarquee.mjs.map +1 -1
- package/es/awesome/TypewriterEffect/TypewriterEffect.mjs +4 -4
- package/es/awesome/TypewriterEffect/TypewriterEffect.mjs.map +1 -1
- package/es/awesome/landingActions.mjs +2 -2
- package/es/awesome/landingActions.mjs.map +1 -1
- package/es/chat/ChatItem/ChatItem.mjs +2 -2
- package/es/chat/ChatItem/ChatItem.mjs.map +1 -1
- package/es/chat/EditableMessage/EditableMessage.mjs +3 -3
- package/es/chat/EditableMessage/EditableMessage.mjs.map +1 -1
- package/es/chat/EditableMessageList/EditableMessageList.mjs +1 -1
- package/es/chat/MessageInput/MessageInput.mjs +3 -3
- package/es/chat/MessageInput/MessageInput.mjs.map +1 -1
- package/es/dashboard/AuthLayout/AuthLayout.mjs +8 -4
- package/es/dashboard/AuthLayout/AuthLayout.mjs.map +1 -1
- package/es/dashboard/AuthLayout/style.mjs +14 -3
- package/es/dashboard/AuthLayout/style.mjs.map +1 -1
- package/es/dashboard/AuthTools/AuthLocaleSwitch.mjs +2 -2
- package/es/dashboard/AuthTools/AuthLocaleSwitch.mjs.map +1 -1
- package/es/dashboard/AuthTools/AuthThemeSwitch.mjs +2 -2
- package/es/dashboard/AuthTools/AuthThemeSwitch.mjs.map +1 -1
- package/es/dashboard/ConsoleNav/ConsoleNav.mjs +3 -3
- package/es/dashboard/ConsoleNav/ConsoleNav.mjs.map +1 -1
- package/es/dashboard/ConsoleNav/style.mjs +2 -2
- package/es/dashboard/ConsoleNav/style.mjs.map +1 -1
- package/es/dashboard/ConsoleShell/style.mjs +1 -1
- package/es/dashboard/ConsoleShell/style.mjs.map +1 -1
- package/es/dashboard/FilterSidebar/FilterSidebar.mjs +1 -1
- package/es/dashboard/FilterSidebar/style.mjs +2 -2
- package/es/dashboard/FilterSidebar/style.mjs.map +1 -1
- package/es/dashboard/FilterStrip/style.mjs +1 -1
- package/es/dashboard/FilterStrip/style.mjs.map +1 -1
- package/es/dashboard/MetricStrip/MetricCell.mjs +25 -14
- package/es/dashboard/MetricStrip/MetricCell.mjs.map +1 -1
- package/es/dashboard/MetricStrip/style.mjs +14 -1
- package/es/dashboard/MetricStrip/style.mjs.map +1 -1
- package/es/dashboard/MetricStrip/type.d.mts +2 -0
- package/es/dashboard/PageSkeleton/style.mjs +2 -1
- package/es/dashboard/PageSkeleton/style.mjs.map +1 -1
- package/es/dashboard/StatCard/StatCard.d.mts +1 -1
- package/es/dashboard/StatCard/StatCard.mjs +2 -1
- package/es/dashboard/StatCard/StatCard.mjs.map +1 -1
- package/es/dashboard/StatCard/type.d.mts +2 -0
- package/es/dashboard/Surface/Surface.mjs +3 -4
- package/es/dashboard/Surface/Surface.mjs.map +1 -1
- package/es/dashboard/Surface/link.mjs +1 -1
- package/es/dashboard/Surface/link.mjs.map +1 -1
- package/es/dashboard/Surface/style.mjs +15 -14
- package/es/dashboard/Surface/style.mjs.map +1 -1
- package/es/dashboard/index.mjs +2 -2
- package/es/eslint/noBaseUiSubpath.mjs +2 -1
- package/es/eslint/noBaseUiSubpath.mjs.map +1 -1
- package/es/i18n/resources/en/colorPicker.d.mts +5 -0
- package/es/i18n/resources/en/colorPicker.mjs +5 -0
- package/es/i18n/resources/en/colorPicker.mjs.map +1 -1
- package/es/i18n/resources/en/datePicker.d.mts +54 -0
- package/es/i18n/resources/en/datePicker.mjs +55 -1
- package/es/i18n/resources/en/datePicker.mjs.map +1 -1
- package/es/i18n/resources/en/index.d.mts +4 -3
- package/es/i18n/resources/en/index.mjs +3 -1
- package/es/i18n/resources/en/index.mjs.map +1 -1
- package/es/i18n/resources/en/table.d.mts +23 -0
- package/es/i18n/resources/en/table.mjs +24 -0
- package/es/i18n/resources/en/table.mjs.map +1 -0
- package/es/i18n/resources/zhCn/colorPicker.d.mts +5 -0
- package/es/i18n/resources/zhCn/colorPicker.mjs +5 -0
- package/es/i18n/resources/zhCn/colorPicker.mjs.map +1 -1
- package/es/i18n/resources/zhCn/datePicker.d.mts +54 -0
- package/es/i18n/resources/zhCn/datePicker.mjs +55 -1
- package/es/i18n/resources/zhCn/datePicker.mjs.map +1 -1
- package/es/i18n/resources/zhCn/index.d.mts +4 -3
- package/es/i18n/resources/zhCn/index.mjs +4 -2
- package/es/i18n/resources/zhCn/index.mjs.map +1 -1
- package/es/i18n/resources/zhCn/table.d.mts +23 -0
- package/es/i18n/resources/zhCn/table.mjs +24 -0
- package/es/i18n/resources/zhCn/table.mjs.map +1 -0
- package/es/i18n/types.d.mts +3 -2
- package/es/index.d.mts +15 -6
- package/es/index.mjs +12 -6
- package/es/internal/overflow/OverflowList.mjs +71 -0
- package/es/internal/overflow/OverflowList.mjs.map +1 -0
- package/es/mdx/Callout/index.mjs +2 -2
- package/es/mdx/Callout/index.mjs.map +1 -1
- package/es/mdx/Cards/Card.mjs +2 -2
- package/es/mdx/Cards/Card.mjs.map +1 -1
- package/es/mdx/Cards/index.mjs +2 -2
- package/es/mdx/Cards/index.mjs.map +1 -1
- package/es/mdx/Mdx/index.mjs +2 -2
- package/es/mdx/Mdx/index.mjs.map +1 -1
- package/es/mdx/Steps/index.mjs +2 -2
- package/es/mdx/Steps/index.mjs.map +1 -1
- package/es/mdx/mdxComponents/Pre.mjs +5 -5
- package/es/mdx/mdxComponents/Pre.mjs.map +1 -1
- package/es/storybook/StoryBook/style.mjs +2 -0
- package/es/storybook/StoryBook/style.mjs.map +1 -1
- package/es/style.css +2966 -957
- package/es/styles/stylex/props.mjs +2 -2
- package/es/styles/stylex/props.mjs.map +1 -1
- package/es/styles/theme/themeCss.mjs +15 -0
- package/es/styles/theme/themeCss.mjs.map +1 -1
- package/es/theme.css +8 -0
- package/package.json +6 -1
- package/es/DatePicker/CalendarPanel.mjs +0 -189
- package/es/DatePicker/CalendarPanel.mjs.map +0 -1
- package/es/DatePicker/PickerShell.mjs +0 -43
- package/es/DatePicker/PickerShell.mjs.map +0 -1
- package/es/DatePicker/calendar.d.mts +0 -4
- package/es/DatePicker/calendar.mjs +0 -46
- package/es/DatePicker/calendar.mjs.map +0 -1
- package/es/Table/FilterMenu.mjs +0 -45
- package/es/Table/FilterMenu.mjs.map +0 -1
- package/es/Table/TableBody.mjs +0 -67
- package/es/Table/TableBody.mjs.map +0 -1
- package/es/Table/TableHead.mjs +0 -58
- package/es/Table/TableHead.mjs.map +0 -1
- package/es/Table/features.mjs +0 -12
- package/es/Table/features.mjs.map +0 -1
- package/es/Table/fixedOffsets.mjs +0 -29
- package/es/Table/fixedOffsets.mjs.map +0 -1
- package/es/Table/marker.stylex.mjs +0 -9
- package/es/Table/marker.stylex.mjs.map +0 -1
- package/es/Table/toColumnDefs.mjs +0 -26
- package/es/Table/toColumnDefs.mjs.map +0 -1
- package/es/Table/useTableState.mjs +0 -99
- package/es/Table/useTableState.mjs.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { focusRing } from "../styles/stylex/focusRing.mjs";
|
|
3
|
+
import Icon from "../Icon/Icon.mjs";
|
|
4
|
+
import { formatColor, parseColor } from "./color.mjs";
|
|
5
|
+
import Slider from "../Slider/Slider.mjs";
|
|
6
|
+
import { styles } from "./style.mjs";
|
|
7
|
+
import ColorInputs from "./ColorInputs.mjs";
|
|
8
|
+
import SaturationArea from "./SaturationArea.mjs";
|
|
9
|
+
import Swatches from "./Swatches.mjs";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import * as stylex from "@stylexjs/stylex";
|
|
12
|
+
import { Pipette } from "lucide-react";
|
|
13
|
+
//#region src/ColorPicker/ColorPanel.tsx
|
|
14
|
+
const hasEyeDropper = () => typeof window !== "undefined" && "EyeDropper" in window;
|
|
15
|
+
const ColorPanel = ({ alpha, format, hsva, labels, onApply, onCommit, onFormatChange, onUpdate, original, presets, recent }) => {
|
|
16
|
+
const hex = formatColor(hsva, alpha);
|
|
17
|
+
const opaque = formatColor(hsva, false);
|
|
18
|
+
const sliderClassNames = (track) => ({
|
|
19
|
+
indicator: stylex.props(styles.hidden).className,
|
|
20
|
+
thumb: stylex.props(styles.sliderThumb).className,
|
|
21
|
+
track: stylex.props(styles[track]).className
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
...stylex.props(styles.panel),
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ jsx(SaturationArea, {
|
|
27
|
+
color: opaque,
|
|
28
|
+
hue: hsva.h,
|
|
29
|
+
label: labels.saturation,
|
|
30
|
+
saturation: hsva.s,
|
|
31
|
+
value: hsva.v,
|
|
32
|
+
onChange: (s, v) => onUpdate({
|
|
33
|
+
...hsva,
|
|
34
|
+
s,
|
|
35
|
+
v
|
|
36
|
+
}),
|
|
37
|
+
onChangeComplete: (s, v) => onCommit({
|
|
38
|
+
...hsva,
|
|
39
|
+
s,
|
|
40
|
+
v
|
|
41
|
+
})
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ jsxs("div", {
|
|
44
|
+
...stylex.props(styles.controls),
|
|
45
|
+
children: [
|
|
46
|
+
hasEyeDropper() && /* @__PURE__ */ jsx("button", {
|
|
47
|
+
"aria-label": labels.eyeDropper,
|
|
48
|
+
type: "button",
|
|
49
|
+
...stylex.props(focusRing.info, styles.eyeDropper),
|
|
50
|
+
onClick: async () => {
|
|
51
|
+
const result = await new window.EyeDropper().open().catch(() => null);
|
|
52
|
+
if (result) onApply({
|
|
53
|
+
...parseColor(result.sRGBHex, hsva.h),
|
|
54
|
+
a: hsva.a
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
58
|
+
icon: Pipette,
|
|
59
|
+
size: 14
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ jsxs("div", {
|
|
63
|
+
...stylex.props(styles.sliders),
|
|
64
|
+
children: [/* @__PURE__ */ jsx(Slider, {
|
|
65
|
+
"aria-label": labels.hue,
|
|
66
|
+
classNames: sliderClassNames("hueTrack"),
|
|
67
|
+
max: 360,
|
|
68
|
+
min: 0,
|
|
69
|
+
value: hsva.h,
|
|
70
|
+
styles: { track: { "--lobe-color-picker-thumb": `hsl(${hsva.h} 100% 50%)` } },
|
|
71
|
+
onChange: (h) => onUpdate({
|
|
72
|
+
...hsva,
|
|
73
|
+
h
|
|
74
|
+
}),
|
|
75
|
+
onChangeComplete: (h) => onCommit({
|
|
76
|
+
...hsva,
|
|
77
|
+
h
|
|
78
|
+
})
|
|
79
|
+
}), alpha && /* @__PURE__ */ jsx(Slider, {
|
|
80
|
+
"aria-label": labels.alpha,
|
|
81
|
+
classNames: sliderClassNames("alphaTrack"),
|
|
82
|
+
max: 100,
|
|
83
|
+
min: 0,
|
|
84
|
+
value: Math.round(hsva.a * 100),
|
|
85
|
+
styles: { track: {
|
|
86
|
+
"--lobe-color-picker-alpha": opaque,
|
|
87
|
+
"--lobe-color-picker-thumb": hex
|
|
88
|
+
} },
|
|
89
|
+
onChange: (a) => onUpdate({
|
|
90
|
+
...hsva,
|
|
91
|
+
a: a / 100
|
|
92
|
+
}),
|
|
93
|
+
onChangeComplete: (a) => onCommit({
|
|
94
|
+
...hsva,
|
|
95
|
+
a: a / 100
|
|
96
|
+
})
|
|
97
|
+
})]
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ jsxs("div", {
|
|
100
|
+
...stylex.props(styles.compare),
|
|
101
|
+
style: { height: alpha ? 30 : 28 },
|
|
102
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
103
|
+
"aria-label": labels.original,
|
|
104
|
+
title: labels.original,
|
|
105
|
+
type: "button",
|
|
106
|
+
...stylex.props(focusRing.info, styles.compareHalf, styles.compareRestore),
|
|
107
|
+
style: { background: original },
|
|
108
|
+
onClick: () => onApply(parseColor(original, hsva.h))
|
|
109
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
110
|
+
...stylex.props(styles.compareHalf),
|
|
111
|
+
style: { background: hex }
|
|
112
|
+
})]
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ jsx(ColorInputs, {
|
|
117
|
+
alpha,
|
|
118
|
+
alphaLabel: labels.alpha,
|
|
119
|
+
format,
|
|
120
|
+
formatLabel: labels.format,
|
|
121
|
+
hsva,
|
|
122
|
+
onCommit: onApply,
|
|
123
|
+
onFormatChange
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ jsx(Swatches, {
|
|
126
|
+
current: hex,
|
|
127
|
+
labels: {
|
|
128
|
+
presets: labels.presets,
|
|
129
|
+
recent: labels.recent,
|
|
130
|
+
swatches: labels.swatches
|
|
131
|
+
},
|
|
132
|
+
presets,
|
|
133
|
+
recent,
|
|
134
|
+
onPick: (color) => onApply({
|
|
135
|
+
...parseColor(color, hsva.h),
|
|
136
|
+
a: parseColor(color).a
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
//#endregion
|
|
143
|
+
export { ColorPanel as default };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=ColorPanel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPanel.mjs","names":[],"sources":["../../src/ColorPicker/ColorPanel.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { Pipette } from 'lucide-react';\nimport type { CSSProperties } from 'react';\n\nimport Icon from '@/Icon';\nimport { Slider } from '@/Slider';\nimport { focusRing } from '@/styles/stylex/focusRing';\n\nimport { type ColorFormat, formatColor, type Hsva, parseColor } from './color';\nimport ColorInputs from './ColorInputs';\nimport SaturationArea from './SaturationArea';\nimport { styles } from './style';\nimport Swatches from './Swatches';\n\nconst hasEyeDropper = () => typeof window !== 'undefined' && 'EyeDropper' in window;\n\ntype EyeDropperConstructor = new () => { open: () => Promise<{ sRGBHex: string }> };\n\nexport interface ColorPanelLabels {\n alpha: string;\n eyeDropper: string;\n format: string;\n hue: string;\n original: string;\n presets: string;\n recent: string;\n saturation: string;\n swatches: string;\n}\n\nexport interface ColorPanelProps {\n alpha: boolean;\n format: ColorFormat;\n hsva: Hsva;\n labels: ColorPanelLabels;\n onApply: (next: Hsva) => void;\n onCommit: (next: Hsva) => void;\n onFormatChange: (format: ColorFormat) => void;\n onUpdate: (next: Hsva) => void;\n original: string;\n presets?: string[];\n recent: boolean;\n}\n\nconst ColorPanel = ({\n alpha,\n format,\n hsva,\n labels,\n onApply,\n onCommit,\n onFormatChange,\n onUpdate,\n original,\n presets,\n recent,\n}: ColorPanelProps) => {\n const hex = formatColor(hsva, alpha);\n const opaque = formatColor(hsva, false);\n const sliderClassNames = (track: keyof typeof styles) => ({\n indicator: stylex.props(styles.hidden).className,\n thumb: stylex.props(styles.sliderThumb).className,\n track: stylex.props(styles[track]).className,\n });\n\n return (\n <div {...stylex.props(styles.panel)}>\n <SaturationArea\n color={opaque}\n hue={hsva.h}\n label={labels.saturation}\n saturation={hsva.s}\n value={hsva.v}\n onChange={(s, v) => onUpdate({ ...hsva, s, v })}\n onChangeComplete={(s, v) => onCommit({ ...hsva, s, v })}\n />\n <div {...stylex.props(styles.controls)}>\n {hasEyeDropper() && (\n <button\n aria-label={labels.eyeDropper}\n type=\"button\"\n {...stylex.props(focusRing.info, styles.eyeDropper)}\n onClick={async () => {\n const dropper = new (\n window as unknown as { EyeDropper: EyeDropperConstructor }\n ).EyeDropper();\n const result = await dropper.open().catch(() => null);\n if (result) onApply({ ...parseColor(result.sRGBHex, hsva.h), a: hsva.a });\n }}\n >\n <Icon icon={Pipette} size={14} />\n </button>\n )}\n <div {...stylex.props(styles.sliders)}>\n <Slider\n aria-label={labels.hue}\n classNames={sliderClassNames('hueTrack')}\n max={360}\n min={0}\n value={hsva.h}\n styles={{\n track: { '--lobe-color-picker-thumb': `hsl(${hsva.h} 100% 50%)` } as CSSProperties,\n }}\n onChange={(h) => onUpdate({ ...hsva, h })}\n onChangeComplete={(h) => onCommit({ ...hsva, h })}\n />\n {alpha && (\n <Slider\n aria-label={labels.alpha}\n classNames={sliderClassNames('alphaTrack')}\n max={100}\n min={0}\n value={Math.round(hsva.a * 100)}\n styles={{\n track: {\n '--lobe-color-picker-alpha': opaque,\n '--lobe-color-picker-thumb': hex,\n } as CSSProperties,\n }}\n onChange={(a) => onUpdate({ ...hsva, a: a / 100 })}\n onChangeComplete={(a) => onCommit({ ...hsva, a: a / 100 })}\n />\n )}\n </div>\n <div {...stylex.props(styles.compare)} style={{ height: alpha ? 30 : 28 }}>\n <button\n aria-label={labels.original}\n title={labels.original}\n type=\"button\"\n {...stylex.props(focusRing.info, styles.compareHalf, styles.compareRestore)}\n style={{ background: original }}\n onClick={() => onApply(parseColor(original, hsva.h))}\n />\n <span {...stylex.props(styles.compareHalf)} style={{ background: hex }} />\n </div>\n </div>\n <ColorInputs\n alpha={alpha}\n alphaLabel={labels.alpha}\n format={format}\n formatLabel={labels.format}\n hsva={hsva}\n onCommit={onApply}\n onFormatChange={onFormatChange}\n />\n <Swatches\n current={hex}\n labels={{ presets: labels.presets, recent: labels.recent, swatches: labels.swatches }}\n presets={presets}\n recent={recent}\n onPick={(color) => onApply({ ...parseColor(color, hsva.h), a: parseColor(color).a })}\n />\n </div>\n );\n};\n\nexport default ColorPanel;\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,sBAAsB,OAAO,WAAW,eAAe,gBAAgB;AA8B7E,MAAM,cAAc,EAClB,OACA,QACA,MACA,QACA,SACA,UACA,gBACA,UACA,UACA,SACA,aACqB;CACrB,MAAM,MAAM,YAA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AAK,CAAC,CAAC;IACvB,CAAC;GAAI,CAAA;EACA;;AACT"}
|
|
@@ -1,232 +1,95 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { styleProps } from "../styles/stylex/props.mjs";
|
|
3
|
-
import { focusRing } from "../styles/stylex/focusRing.mjs";
|
|
4
|
-
import Icon from "../Icon/Icon.mjs";
|
|
5
|
-
import { useThemeMode } from "../styles/theme/scope.mjs";
|
|
6
2
|
import { useControlledState } from "../hooks/useControlledState.mjs";
|
|
7
3
|
import { useTranslation } from "../i18n/useTranslation.mjs";
|
|
8
|
-
import { inputRootStyles } from "../Input/style.mjs";
|
|
9
|
-
import Input_default from "../Input/Input.mjs";
|
|
10
|
-
import InputNumber_default from "../Input/InputNumber.mjs";
|
|
11
4
|
import colorPicker_default from "../i18n/resources/en/colorPicker.mjs";
|
|
12
5
|
import { panelStyles } from "../internal/panelStyles.mjs";
|
|
13
6
|
import { PopoverPopup, PopoverPortal, PopoverPositioner, PopoverRoot, PopoverTriggerElement } from "../Popover/atoms.mjs";
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
7
|
+
import { formatColor, parseColor } from "./color.mjs";
|
|
8
|
+
import { pushRecentColor } from "./recent.mjs";
|
|
9
|
+
import ColorPanel from "./ColorPanel.mjs";
|
|
10
|
+
import ColorTrigger from "./Trigger.mjs";
|
|
11
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
19
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
-
import * as stylex from "@stylexjs/stylex";
|
|
21
|
-
import { Pipette } from "lucide-react";
|
|
22
13
|
//#region src/ColorPicker/ColorPicker.tsx
|
|
23
14
|
const DEFAULT_COLOR = "#000000";
|
|
24
|
-
const
|
|
25
|
-
const ColorPicker = memo(({ alpha = false, children, className, defaultValue = DEFAULT_COLOR, disabled, onChange, onChangeComplete, presets, showText, size = "middle", style, value }) => {
|
|
15
|
+
const ColorPicker = memo(({ alpha = false, children, className, defaultFormat = "hex", defaultValue = DEFAULT_COLOR, disabled, onChange, onChangeComplete, presets, recent = true, showText, size = "middle", style, trigger = showText ? "field" : "swatch", value }) => {
|
|
26
16
|
const { t } = useTranslation(colorPicker_default);
|
|
27
|
-
const { isDarkMode } = useThemeMode();
|
|
28
17
|
const [hex, setHex] = useControlledState(defaultValue, {
|
|
29
18
|
defaultValue,
|
|
30
19
|
onChange,
|
|
31
20
|
value
|
|
32
21
|
});
|
|
33
22
|
const [hsva, setHsva] = useState(() => parseColor(hex));
|
|
34
|
-
const [
|
|
23
|
+
const [format, setFormat] = useState(defaultFormat);
|
|
24
|
+
const [original, setOriginal] = useState(hex);
|
|
35
25
|
const popupRef = useRef(null);
|
|
36
26
|
useEffect(() => {
|
|
27
|
+
if (!hex) return;
|
|
37
28
|
setHsva((current) => formatColor(current, alpha) === hex.toLowerCase() ? current : parseColor(hex, current.h));
|
|
38
|
-
setDraft(hex.slice(1).toUpperCase());
|
|
39
29
|
}, [hex, alpha]);
|
|
40
30
|
const update = (next) => {
|
|
41
31
|
setHsva(next);
|
|
42
32
|
setHex(formatColor(next, alpha));
|
|
43
33
|
};
|
|
44
|
-
const commit = (next) =>
|
|
34
|
+
const commit = (next) => {
|
|
35
|
+
const nextHex = formatColor(next, alpha);
|
|
36
|
+
if (recent) pushRecentColor(nextHex);
|
|
37
|
+
onChangeComplete?.(nextHex);
|
|
38
|
+
};
|
|
45
39
|
const apply = (next) => {
|
|
46
40
|
update(next);
|
|
47
41
|
commit(next);
|
|
48
42
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
apply(parseColor(normalized, hsva.h));
|
|
53
|
-
};
|
|
54
|
-
const swatch = (dimension) => /* @__PURE__ */ jsx("span", {
|
|
55
|
-
...stylex.props(styles.swatch),
|
|
56
|
-
style: {
|
|
57
|
-
height: dimension,
|
|
58
|
-
width: dimension
|
|
43
|
+
return /* @__PURE__ */ jsxs(PopoverRoot, {
|
|
44
|
+
onOpenChange: (open) => {
|
|
45
|
+
if (open) setOriginal(hex);
|
|
59
46
|
},
|
|
60
|
-
children: /* @__PURE__ */ jsx(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
cursor: "pointer",
|
|
74
|
-
...style
|
|
75
|
-
}),
|
|
76
|
-
children: [swatch(18), /* @__PURE__ */ jsx("span", {
|
|
77
|
-
style: { fontFamily: "var(--lobe-font-family-code, monospace)" },
|
|
78
|
-
children: hex.toUpperCase()
|
|
79
|
-
})]
|
|
80
|
-
}) : /* @__PURE__ */ jsx("button", {
|
|
81
|
-
"aria-label": t("colorPicker.trigger"),
|
|
82
|
-
disabled,
|
|
83
|
-
type: "button",
|
|
84
|
-
...styleProps([focusRing.info, styles.swatchButton], className, style),
|
|
85
|
-
children: swatch(24)
|
|
86
|
-
}));
|
|
87
|
-
return /* @__PURE__ */ jsxs(PopoverRoot, { children: [/* @__PURE__ */ jsx(PopoverTriggerElement, { children: trigger }), /* @__PURE__ */ jsx(PopoverPortal, { children: /* @__PURE__ */ jsx(PopoverPositioner, {
|
|
88
|
-
placement: "bottomLeft",
|
|
89
|
-
children: /* @__PURE__ */ jsx(PopoverPopup, {
|
|
90
|
-
ref: popupRef,
|
|
91
|
-
xstyle: panelStyles.popup,
|
|
92
|
-
initialFocus: () => popupRef.current?.querySelector("[role=\"slider\"]") ?? true,
|
|
93
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
94
|
-
...stylex.props(styles.panel),
|
|
95
|
-
children: [
|
|
96
|
-
/* @__PURE__ */ jsxs("div", {
|
|
97
|
-
...stylex.props(styles.summary),
|
|
98
|
-
children: [
|
|
99
|
-
swatch(40),
|
|
100
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
101
|
-
...stylex.props(styles.value),
|
|
102
|
-
children: hex.toUpperCase()
|
|
103
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
104
|
-
...stylex.props(panelStyles.label),
|
|
105
|
-
children: alpha ? `HEX · ${Math.round(hsva.a * 100)}%` : "HEX"
|
|
106
|
-
})] }),
|
|
107
|
-
hasEyeDropper() && /* @__PURE__ */ jsx("button", {
|
|
108
|
-
"aria-label": t("colorPicker.eyeDropper"),
|
|
109
|
-
...stylex.props(panelStyles.nav, styles.eyeDropper),
|
|
110
|
-
type: "button",
|
|
111
|
-
onClick: async () => {
|
|
112
|
-
const result = await new window.EyeDropper().open().catch(() => null);
|
|
113
|
-
if (result) apply({
|
|
114
|
-
...parseColor(result.sRGBHex, hsva.h),
|
|
115
|
-
a: hsva.a
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
119
|
-
icon: Pipette,
|
|
120
|
-
size: 14
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
]
|
|
124
|
-
}),
|
|
125
|
-
/* @__PURE__ */ jsx(SaturationArea, {
|
|
126
|
-
hue: hsva.h,
|
|
127
|
-
label: t("colorPicker.saturation"),
|
|
128
|
-
saturation: hsva.s,
|
|
129
|
-
value: hsva.v,
|
|
130
|
-
onChange: (s, v) => update({
|
|
131
|
-
...hsva,
|
|
132
|
-
s,
|
|
133
|
-
v
|
|
134
|
-
}),
|
|
135
|
-
onChangeComplete: (s, v) => commit({
|
|
136
|
-
...hsva,
|
|
137
|
-
s,
|
|
138
|
-
v
|
|
139
|
-
})
|
|
140
|
-
}),
|
|
141
|
-
/* @__PURE__ */ jsx(Slider, {
|
|
142
|
-
"aria-label": t("colorPicker.hue"),
|
|
143
|
-
max: 360,
|
|
144
|
-
min: 0,
|
|
145
|
-
value: hsva.h,
|
|
146
|
-
classNames: {
|
|
147
|
-
indicator: stylex.props(styles.hidden).className,
|
|
148
|
-
thumb: stylex.props(styles.sliderThumb).className,
|
|
149
|
-
track: stylex.props(styles.hueTrack).className
|
|
150
|
-
},
|
|
151
|
-
onChange: (h) => update({
|
|
152
|
-
...hsva,
|
|
153
|
-
h
|
|
154
|
-
}),
|
|
155
|
-
onChangeComplete: (h) => commit({
|
|
156
|
-
...hsva,
|
|
157
|
-
h
|
|
158
|
-
})
|
|
159
|
-
}),
|
|
160
|
-
alpha && /* @__PURE__ */ jsx(Slider, {
|
|
161
|
-
"aria-label": t("colorPicker.alpha"),
|
|
162
|
-
max: 100,
|
|
163
|
-
min: 0,
|
|
164
|
-
value: Math.round(hsva.a * 100),
|
|
165
|
-
classNames: {
|
|
166
|
-
indicator: stylex.props(styles.hidden).className,
|
|
167
|
-
thumb: stylex.props(styles.sliderThumb).className,
|
|
168
|
-
track: stylex.props(styles.alphaTrack).className
|
|
169
|
-
},
|
|
170
|
-
styles: { track: { "--lobe-color-picker-alpha": formatColor(hsva, false) } },
|
|
171
|
-
onChange: (a) => update({
|
|
172
|
-
...hsva,
|
|
173
|
-
a: a / 100
|
|
174
|
-
}),
|
|
175
|
-
onChangeComplete: (a) => commit({
|
|
176
|
-
...hsva,
|
|
177
|
-
a: a / 100
|
|
178
|
-
})
|
|
179
|
-
}),
|
|
180
|
-
/* @__PURE__ */ jsxs("div", {
|
|
181
|
-
...stylex.props(styles.hexRow),
|
|
182
|
-
children: [/* @__PURE__ */ jsx(Input_default, {
|
|
183
|
-
"aria-label": "HEX",
|
|
184
|
-
className: stylex.props(styles.hexField).className,
|
|
185
|
-
prefix: /* @__PURE__ */ jsx("span", {
|
|
186
|
-
...stylex.props(panelStyles.label),
|
|
187
|
-
children: "HEX"
|
|
188
|
-
}),
|
|
189
|
-
value: draft,
|
|
190
|
-
variant: "filled",
|
|
191
|
-
onBlur: commitDraft,
|
|
192
|
-
onChange: (event) => setDraft(event.target.value),
|
|
193
|
-
onPressEnter: commitDraft
|
|
194
|
-
}), alpha && /* @__PURE__ */ jsx(InputNumber_default, {
|
|
195
|
-
"aria-label": t("colorPicker.alpha"),
|
|
196
|
-
className: stylex.props(styles.hexField, styles.alphaField).className,
|
|
197
|
-
controls: false,
|
|
198
|
-
max: 100,
|
|
199
|
-
min: 0,
|
|
200
|
-
suffix: "%",
|
|
201
|
-
value: Math.round(hsva.a * 100),
|
|
202
|
-
variant: "filled",
|
|
203
|
-
onChange: (a) => a !== null && apply({
|
|
204
|
-
...hsva,
|
|
205
|
-
a: a / 100
|
|
206
|
-
})
|
|
207
|
-
})]
|
|
208
|
-
}),
|
|
209
|
-
presets && presets.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
210
|
-
"aria-label": t("colorPicker.presets"),
|
|
211
|
-
...stylex.props(styles.presets),
|
|
212
|
-
role: "group",
|
|
213
|
-
children: presets.map((color) => /* @__PURE__ */ createElement("button", {
|
|
214
|
-
"aria-label": color,
|
|
215
|
-
"aria-pressed": color.toLowerCase() === hex.slice(0, 7).toLowerCase(),
|
|
216
|
-
...stylex.props(focusRing.info, styles.preset),
|
|
217
|
-
key: color,
|
|
218
|
-
style: { background: color },
|
|
219
|
-
type: "button",
|
|
220
|
-
onClick: () => apply({
|
|
221
|
-
...parseColor(color, hsva.h),
|
|
222
|
-
a: parseColor(color).a
|
|
223
|
-
})
|
|
224
|
-
}))
|
|
225
|
-
})
|
|
226
|
-
]
|
|
47
|
+
children: [/* @__PURE__ */ jsx(PopoverTriggerElement, {
|
|
48
|
+
nativeButton: true,
|
|
49
|
+
disabled,
|
|
50
|
+
children: children ?? /* @__PURE__ */ jsx(ColorTrigger, {
|
|
51
|
+
alpha: alpha && hex ? hsva.a : void 0,
|
|
52
|
+
className,
|
|
53
|
+
disabled,
|
|
54
|
+
emptyLabel: t("colorPicker.empty"),
|
|
55
|
+
hex,
|
|
56
|
+
label: t("colorPicker.trigger"),
|
|
57
|
+
size,
|
|
58
|
+
style,
|
|
59
|
+
variant: trigger
|
|
227
60
|
})
|
|
228
|
-
})
|
|
229
|
-
|
|
61
|
+
}), /* @__PURE__ */ jsx(PopoverPortal, { children: /* @__PURE__ */ jsx(PopoverPositioner, {
|
|
62
|
+
placement: "bottomLeft",
|
|
63
|
+
children: /* @__PURE__ */ jsx(PopoverPopup, {
|
|
64
|
+
ref: popupRef,
|
|
65
|
+
xstyle: panelStyles.popup,
|
|
66
|
+
initialFocus: () => popupRef.current?.querySelector("[role=\"slider\"]") ?? true,
|
|
67
|
+
children: /* @__PURE__ */ jsx(ColorPanel, {
|
|
68
|
+
alpha,
|
|
69
|
+
format,
|
|
70
|
+
hsva,
|
|
71
|
+
original,
|
|
72
|
+
presets,
|
|
73
|
+
recent,
|
|
74
|
+
labels: {
|
|
75
|
+
alpha: t("colorPicker.alpha"),
|
|
76
|
+
eyeDropper: t("colorPicker.eyeDropper"),
|
|
77
|
+
format: t("colorPicker.format"),
|
|
78
|
+
hue: t("colorPicker.hue"),
|
|
79
|
+
original: t("colorPicker.original"),
|
|
80
|
+
presets: t("colorPicker.presets"),
|
|
81
|
+
recent: t("colorPicker.recent"),
|
|
82
|
+
saturation: t("colorPicker.saturation"),
|
|
83
|
+
swatches: t("colorPicker.swatches")
|
|
84
|
+
},
|
|
85
|
+
onApply: apply,
|
|
86
|
+
onCommit: commit,
|
|
87
|
+
onFormatChange: setFormat,
|
|
88
|
+
onUpdate: update
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
}) })]
|
|
92
|
+
});
|
|
230
93
|
});
|
|
231
94
|
ColorPicker.displayName = "ColorPicker";
|
|
232
95
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.mjs","names":["colorPickerMessages","Input","InputNumber"],"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { Pipette } from 'lucide-react';\nimport { type CSSProperties, memo, useEffect, useRef, useState } from 'react';\n\nimport { useControlledState } from '@/hooks/useControlledState';\nimport colorPickerMessages from '@/i18n/resources/en/colorPicker';\nimport { useTranslation } from '@/i18n/useTranslation';\nimport Icon from '@/Icon';\nimport { Input, InputNumber } from '@/Input';\nimport { inputRootStyles } from '@/Input/style';\nimport { panelStyles } from '@/internal/panelStyles';\nimport {\n PopoverPopup,\n PopoverPortal,\n PopoverPositioner,\n PopoverRoot,\n PopoverTriggerElement,\n} from '@/Popover';\nimport { Slider } from '@/Slider';\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { useThemeMode } from '@/styles/theme/scope';\n\nimport { formatColor, type Hsva, normalizeHexInput, parseColor } from './color';\nimport SaturationArea from './SaturationArea';\nimport { styles } from './style';\nimport type { ColorPickerProps } from './type';\n\nconst DEFAULT_COLOR = '#000000';\n\nconst hasEyeDropper = () => typeof window !== 'undefined' && 'EyeDropper' in window;\n\nconst ColorPicker = memo<ColorPickerProps>(\n ({\n alpha = false,\n children,\n className,\n defaultValue = DEFAULT_COLOR,\n disabled,\n onChange,\n onChangeComplete,\n presets,\n showText,\n size = 'middle',\n style,\n value,\n }) => {\n const { t } = useTranslation(colorPickerMessages);\n const { isDarkMode } = useThemeMode();\n const [hex, setHex] = useControlledState<string>(defaultValue, {\n defaultValue,\n onChange,\n value,\n });\n const [hsva, setHsva] = useState<Hsva>(() => parseColor(hex));\n const [draft, setDraft] = useState(hex.slice(1).toUpperCase());\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setHsva((current) =>\n formatColor(current, alpha) === hex.toLowerCase() ? current : parseColor(hex, current.h),\n );\n setDraft(hex.slice(1).toUpperCase());\n }, [hex, alpha]);\n\n const update = (next: Hsva) => {\n setHsva(next);\n setHex(formatColor(next, alpha));\n };\n const commit = (next: Hsva) => onChangeComplete?.(formatColor(next, alpha));\n const apply = (next: Hsva) => {\n update(next);\n commit(next);\n };\n\n const commitDraft = () => {\n const normalized = normalizeHexInput(draft);\n if (!normalized) return setDraft(hex.slice(1).toUpperCase());\n apply(parseColor(normalized, hsva.h));\n };\n\n const swatch = (dimension: number) => (\n <span {...stylex.props(styles.swatch)} style={{ height: dimension, width: dimension }}>\n <span {...stylex.props(styles.swatchFill)} style={{ background: hex }} />\n </span>\n );\n\n const trigger =\n children ??\n (showText ? (\n <button\n aria-label={t('colorPicker.trigger')}\n disabled={disabled}\n type=\"button\"\n {...styleProps(\n [\n ...inputRootStyles({ size, variant: isDarkMode ? 'filled' : 'outlined' }),\n styles.textTrigger,\n ],\n className,\n { cursor: 'pointer', ...style },\n )}\n >\n {swatch(18)}\n <span style={{ fontFamily: 'var(--lobe-font-family-code, monospace)' }}>\n {hex.toUpperCase()}\n </span>\n </button>\n ) : (\n <button\n aria-label={t('colorPicker.trigger')}\n disabled={disabled}\n type=\"button\"\n {...styleProps([focusRing.info, styles.swatchButton], className, style)}\n >\n {swatch(24)}\n </button>\n ));\n\n return (\n <PopoverRoot>\n <PopoverTriggerElement>{trigger}</PopoverTriggerElement>\n <PopoverPortal>\n <PopoverPositioner placement=\"bottomLeft\">\n <PopoverPopup\n ref={popupRef}\n xstyle={panelStyles.popup}\n initialFocus={() =>\n popupRef.current?.querySelector<HTMLElement>('[role=\"slider\"]') ?? true\n }\n >\n <div {...stylex.props(styles.panel)}>\n <div {...stylex.props(styles.summary)}>\n {swatch(40)}\n <div>\n <div {...stylex.props(styles.value)}>{hex.toUpperCase()}</div>\n <div {...stylex.props(panelStyles.label)}>\n {alpha ? `HEX · ${Math.round(hsva.a * 100)}%` : 'HEX'}\n </div>\n </div>\n {hasEyeDropper() && (\n <button\n aria-label={t('colorPicker.eyeDropper')}\n {...stylex.props(panelStyles.nav, styles.eyeDropper)}\n type=\"button\"\n onClick={async () => {\n const dropper = new (\n window as unknown as {\n EyeDropper: new () => { open: () => Promise<{ sRGBHex: string }> };\n }\n ).EyeDropper();\n const result = await dropper.open().catch(() => null);\n if (result) apply({ ...parseColor(result.sRGBHex, hsva.h), a: hsva.a });\n }}\n >\n <Icon icon={Pipette} size={14} />\n </button>\n )}\n </div>\n <SaturationArea\n hue={hsva.h}\n label={t('colorPicker.saturation')}\n saturation={hsva.s}\n value={hsva.v}\n onChange={(s, v) => update({ ...hsva, s, v })}\n onChangeComplete={(s, v) => commit({ ...hsva, s, v })}\n />\n <Slider\n aria-label={t('colorPicker.hue')}\n max={360}\n min={0}\n value={hsva.h}\n classNames={{\n indicator: stylex.props(styles.hidden).className,\n thumb: stylex.props(styles.sliderThumb).className,\n track: stylex.props(styles.hueTrack).className,\n }}\n onChange={(h) => update({ ...hsva, h })}\n onChangeComplete={(h) => commit({ ...hsva, h })}\n />\n {alpha && (\n <Slider\n aria-label={t('colorPicker.alpha')}\n max={100}\n min={0}\n value={Math.round(hsva.a * 100)}\n classNames={{\n indicator: stylex.props(styles.hidden).className,\n thumb: stylex.props(styles.sliderThumb).className,\n track: stylex.props(styles.alphaTrack).className,\n }}\n styles={{\n track: {\n '--lobe-color-picker-alpha': formatColor(hsva, false),\n } as CSSProperties,\n }}\n onChange={(a) => update({ ...hsva, a: a / 100 })}\n onChangeComplete={(a) => commit({ ...hsva, a: a / 100 })}\n />\n )}\n <div {...stylex.props(styles.hexRow)}>\n <Input\n aria-label=\"HEX\"\n className={stylex.props(styles.hexField).className}\n prefix={<span {...stylex.props(panelStyles.label)}>HEX</span>}\n value={draft}\n variant=\"filled\"\n onBlur={commitDraft}\n onChange={(event) => setDraft(event.target.value)}\n onPressEnter={commitDraft}\n />\n {alpha && (\n <InputNumber\n aria-label={t('colorPicker.alpha')}\n className={stylex.props(styles.hexField, styles.alphaField).className}\n controls={false}\n max={100}\n min={0}\n suffix=\"%\"\n value={Math.round(hsva.a * 100)}\n variant=\"filled\"\n onChange={(a) => a !== null && apply({ ...hsva, a: a / 100 })}\n />\n )}\n </div>\n {presets && presets.length > 0 && (\n <div\n aria-label={t('colorPicker.presets')}\n {...stylex.props(styles.presets)}\n role=\"group\"\n >\n {presets.map((color) => (\n <button\n aria-label={color}\n aria-pressed={color.toLowerCase() === hex.slice(0, 7).toLowerCase()}\n {...stylex.props(focusRing.info, styles.preset)}\n key={color}\n style={{ background: color }}\n type=\"button\"\n onClick={() =>\n apply({ ...parseColor(color, hsva.h), a: parseColor(color).a })\n }\n />\n ))}\n </div>\n )}\n </div>\n </PopoverPopup>\n </PopoverPositioner>\n </PopoverPortal>\n </PopoverRoot>\n );\n },\n);\n\nColorPicker.displayName = 'ColorPicker';\n\nexport default ColorPicker;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,gBAAgB;AACtB,MAAM,sBAAsB,OAAO,WAAW,eAAe,gBAAgB;AAC7E,MAAM,cAAc,MAAwB,EAC1C,QAAQ,OACR,UACA,WACA,eAAe,eACf,UACA,UACA,kBACA,SACA,UACA,OAAO,UACP,OACA,YACI;CACJ,MAAM,EACJ,MACE,eAAeA,mBAAmB;CACtC,MAAM,EACJ,eACE,aAAa;CACjB,MAAM,CAAC,KAAK,UAAU,mBAA2B,cAAc;EAC7D;EACA;EACA;CACF,CAAC;CACD,MAAM,CAAC,MAAM,WAAW,eAAqB,WAAW,GAAG,CAAC;CAC5D,MAAM,CAAC,OAAO,YAAY,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC;CAC7D,MAAM,WAAW,OAAuB,IAAI;CAC5C,gBAAgB;EACd,SAAQ,YAAW,YAAY,SAAS,KAAK,MAAM,IAAI,YAAY,IAAI,UAAU,WAAW,KAAK,QAAQ,CAAC,CAAC;EAC3G,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC;CACrC,GAAG,CAAC,KAAK,KAAK,CAAC;CACf,MAAM,UAAU,SAAe;EAC7B,QAAQ,IAAI;EACZ,OAAO,YAAY,MAAM,KAAK,CAAC;CACjC;CACA,MAAM,UAAU,SAAe,mBAAmB,YAAY,MAAM,KAAK,CAAC;CAC1E,MAAM,SAAS,SAAe;EAC5B,OAAO,IAAI;EACX,OAAO,IAAI;CACb;CACA,MAAM,oBAAoB;EACxB,MAAM,aAAa,kBAAkB,KAAK;EAC1C,IAAI,CAAC,YAAY,OAAO,SAAS,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,QAAQ,SAAS,KAAK,oBAAC,OAAD;MAAK,cAAY,EAAE,qBAAqB;MAAG,GAAI,OAAO,MAAM,OAAO,OAAO;MAAG,MAAK;MAC/G,UAAA,QAAQ,KAAI,UAAS,8BAAC,UAAD;OAAQ,cAAY;OAAO,gBAAc,MAAM,YAAY,MAAM,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY;OAAG,GAAI,OAAO,MAAM,UAAU,MAAM,OAAO,MAAM;OAAG,KAAK;OAAO,OAAO,EAC9L,YAAY,MACd;OAAG,MAAK;OAAS,eAAe,MAAM;QACpC,GAAG,WAAW,OAAO,KAAK,CAAC;QAC3B,GAAG,WAAW,KAAK,CAAC,CAAC;OACvB,CAAC;MAAI,CAAA,CAAC;KACG,CAAA;IACJ;;EACO,CAAA;CACG,CAAA,EACN,CAAA,CACJ,EAAA,CAAA;AACnB,CAAC;AACD,YAAY,cAAc"}
|
|
1
|
+
{"version":3,"file":"ColorPicker.mjs","names":["colorPickerMessages"],"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["'use client';\n\nimport { memo, useEffect, useRef, useState } from 'react';\n\nimport { useControlledState } from '@/hooks/useControlledState';\nimport colorPickerMessages from '@/i18n/resources/en/colorPicker';\nimport { useTranslation } from '@/i18n/useTranslation';\nimport { panelStyles } from '@/internal/panelStyles';\nimport {\n PopoverPopup,\n PopoverPortal,\n PopoverPositioner,\n PopoverRoot,\n PopoverTriggerElement,\n} from '@/Popover';\n\nimport { type ColorFormat, formatColor, type Hsva, parseColor } from './color';\nimport ColorPanel from './ColorPanel';\nimport { pushRecentColor } from './recent';\nimport ColorTrigger from './Trigger';\nimport type { ColorPickerProps } from './type';\n\nconst DEFAULT_COLOR = '#000000';\n\nconst ColorPicker = memo<ColorPickerProps>(\n ({\n alpha = false,\n children,\n className,\n defaultFormat = 'hex',\n defaultValue = DEFAULT_COLOR,\n disabled,\n onChange,\n onChangeComplete,\n presets,\n recent = true,\n showText,\n size = 'middle',\n style,\n trigger = showText ? 'field' : 'swatch',\n value,\n }) => {\n const { t } = useTranslation(colorPickerMessages);\n const [hex, setHex] = useControlledState<string>(defaultValue, {\n defaultValue,\n onChange,\n value,\n });\n const [hsva, setHsva] = useState<Hsva>(() => parseColor(hex));\n const [format, setFormat] = useState<ColorFormat>(defaultFormat);\n const [original, setOriginal] = useState(hex);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!hex) return;\n setHsva((current) =>\n formatColor(current, alpha) === hex.toLowerCase() ? current : parseColor(hex, current.h),\n );\n }, [hex, alpha]);\n\n const update = (next: Hsva) => {\n setHsva(next);\n setHex(formatColor(next, alpha));\n };\n const commit = (next: Hsva) => {\n const nextHex = formatColor(next, alpha);\n if (recent) pushRecentColor(nextHex);\n onChangeComplete?.(nextHex);\n };\n const apply = (next: Hsva) => {\n update(next);\n commit(next);\n };\n\n return (\n <PopoverRoot\n onOpenChange={(open) => {\n if (open) setOriginal(hex);\n }}\n >\n <PopoverTriggerElement nativeButton disabled={disabled}>\n {children ?? (\n <ColorTrigger\n alpha={alpha && hex ? hsva.a : undefined}\n className={className}\n disabled={disabled}\n emptyLabel={t('colorPicker.empty')}\n hex={hex}\n label={t('colorPicker.trigger')}\n size={size}\n style={style}\n variant={trigger}\n />\n )}\n </PopoverTriggerElement>\n <PopoverPortal>\n <PopoverPositioner placement=\"bottomLeft\">\n <PopoverPopup\n ref={popupRef}\n xstyle={panelStyles.popup}\n initialFocus={() =>\n popupRef.current?.querySelector<HTMLElement>('[role=\"slider\"]') ?? true\n }\n >\n <ColorPanel\n alpha={alpha}\n format={format}\n hsva={hsva}\n original={original}\n presets={presets}\n recent={recent}\n labels={{\n alpha: t('colorPicker.alpha'),\n eyeDropper: t('colorPicker.eyeDropper'),\n format: t('colorPicker.format'),\n hue: t('colorPicker.hue'),\n original: t('colorPicker.original'),\n presets: t('colorPicker.presets'),\n recent: t('colorPicker.recent'),\n saturation: t('colorPicker.saturation'),\n swatches: t('colorPicker.swatches'),\n }}\n onApply={apply}\n onCommit={commit}\n onFormatChange={setFormat}\n onUpdate={update}\n />\n </PopoverPopup>\n </PopoverPositioner>\n </PopoverPortal>\n </PopoverRoot>\n );\n },\n);\n\nColorPicker.displayName = 'ColorPicker';\n\nexport default ColorPicker;\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAM,gBAAgB;AAEtB,MAAM,cAAc,MACjB,EACC,QAAQ,OACR,UACA,WACA,gBAAgB,OAChB,eAAe,eACf,UACA,UACA,kBACA,SACA,SAAS,MACT,UACA,OAAO,UACP,OACA,UAAU,WAAW,UAAU,UAC/B,YACI;CACJ,MAAM,EAAE,MAAM,eAAeA,mBAAmB;CAChD,MAAM,CAAC,KAAK,UAAU,mBAA2B,cAAc;EAC7D;EACA;EACA;CACF,CAAC;CACD,MAAM,CAAC,MAAM,WAAW,eAAqB,WAAW,GAAG,CAAC;CAC5D,MAAM,CAAC,QAAQ,aAAa,SAAsB,aAAa;CAC/D,MAAM,CAAC,UAAU,eAAe,SAAS,GAAG;CAC5C,MAAM,WAAW,OAAuB,IAAI;CAE5C,gBAAgB;EACd,IAAI,CAAC,KAAK;EACV,SAAS,YACP,YAAY,SAAS,KAAK,MAAM,IAAI,YAAY,IAAI,UAAU,WAAW,KAAK,QAAQ,CAAC,CACzF;CACF,GAAG,CAAC,KAAK,KAAK,CAAC;CAEf,MAAM,UAAU,SAAe;EAC7B,QAAQ,IAAI;EACZ,OAAO,YAAY,MAAM,KAAK,CAAC;CACjC;CACA,MAAM,UAAU,SAAe;EAC7B,MAAM,UAAU,YAAY,MAAM,KAAK;EACvC,IAAI,QAAQ,gBAAgB,OAAO;EACnC,mBAAmB,OAAO;CAC5B;CACA,MAAM,SAAS,SAAe;EAC5B,OAAO,IAAI;EACX,OAAO,IAAI;CACb;CAEA,OACE,qBAAC,aAAD;EACE,eAAe,SAAS;GACtB,IAAI,MAAM,YAAY,GAAG;EAC3B;EAHF,UAAA,CAKE,oBAAC,uBAAD;GAAuB,cAAA;GAAuB;GAC3C,UAAA,YACC,oBAAC,cAAD;IACE,OAAO,SAAS,MAAM,KAAK,IAAI,KAAA;IACpB;IACD;IACV,YAAY,EAAE,mBAAmB;IAC5B;IACL,OAAO,EAAE,qBAAqB;IACxB;IACC;IACP,SAAS;GACV,CAAA;EAEkB,CAAA,GACvB,oBAAC,eAAD,EAAA,UACE,oBAAC,mBAAD;GAAmB,WAAU;GAC3B,UAAA,oBAAC,cAAD;IACE,KAAK;IACL,QAAQ,YAAY;IACpB,oBACE,SAAS,SAAS,cAA2B,mBAAiB,KAAK;IAGrE,UAAA,oBAAC,YAAD;KACS;KACC;KACF;KACI;KACD;KACD;KACR,QAAQ;MACN,OAAO,EAAE,mBAAmB;MAC5B,YAAY,EAAE,wBAAwB;MACtC,QAAQ,EAAE,oBAAoB;MAC9B,KAAK,EAAE,iBAAiB;MACxB,UAAU,EAAE,sBAAsB;MAClC,SAAS,EAAE,qBAAqB;MAChC,QAAQ,EAAE,oBAAoB;MAC9B,YAAY,EAAE,wBAAwB;MACtC,UAAU,EAAE,sBAAsB;KACpC;KACA,SAAS;KACT,UAAU;KACV,gBAAgB;KAChB,UAAU;IACX,CAAA;GACW,CAAA;EACG,CAAA,EACN,CAAA,CACJ;;AAEjB,CACF;AAEA,YAAY,cAAc"}
|
|
@@ -6,7 +6,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import * as stylex from "@stylexjs/stylex";
|
|
7
7
|
//#region src/ColorPicker/SaturationArea.tsx
|
|
8
8
|
const clamp = (n) => Math.min(1, Math.max(0, Math.round(n * 100) / 100));
|
|
9
|
-
const SaturationArea = memo(({ hue, label, onChange, onChangeComplete, saturation, value }) => {
|
|
9
|
+
const SaturationArea = memo(({ color, hue, label, onChange, onChangeComplete, saturation, value }) => {
|
|
10
10
|
const areaRef = useRef(null);
|
|
11
11
|
const fromPointer = (event) => {
|
|
12
12
|
const rect = areaRef.current.getBoundingClientRect();
|
|
@@ -53,6 +53,7 @@ const SaturationArea = memo(({ hue, label, onChange, onChangeComplete, saturatio
|
|
|
53
53
|
children: /* @__PURE__ */ jsx("span", {
|
|
54
54
|
...stylex.props(styles.thumb),
|
|
55
55
|
style: {
|
|
56
|
+
background: color,
|
|
56
57
|
left: `${saturation * 100}%`,
|
|
57
58
|
top: `${(1 - value) * 100}%`
|
|
58
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaturationArea.mjs","names":[],"sources":["../../src/ColorPicker/SaturationArea.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { memo, type PointerEvent, useRef } from 'react';\n\nimport { focusRing } from '@/styles/stylex/focusRing';\n\nimport { styles } from './style';\n\nexport interface SaturationAreaProps {\n hue: number;\n label: string;\n onChange: (saturation: number, value: number) => void;\n onChangeComplete: (saturation: number, value: number) => void;\n saturation: number;\n value: number;\n}\n\nconst clamp = (n: number) => Math.min(1, Math.max(0, Math.round(n * 100) / 100));\n\nconst SaturationArea = memo<SaturationAreaProps>(\n ({ hue, label, onChange, onChangeComplete, saturation, value }) => {\n const areaRef = useRef<HTMLDivElement>(null);\n\n const fromPointer = (event: PointerEvent<HTMLDivElement>): [number, number] => {\n const rect = areaRef.current!.getBoundingClientRect();\n const next: [number, number] = [\n clamp((event.clientX - rect.left) / rect.width),\n clamp(1 - (event.clientY - rect.top) / rect.height),\n ];\n onChange(...next);\n return next;\n };\n\n return (\n <div\n aria-label={label}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={Math.round(saturation * 100)}\n aria-valuetext={`Saturation ${Math.round(saturation * 100)}%, brightness ${Math.round(value * 100)}%`}\n {...stylex.props(focusRing.info, styles.saturation)}\n ref={areaRef}\n role=\"slider\"\n tabIndex={0}\n style={{\n background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${hue} 100% 50%))`,\n }}\n onKeyDown={(event) => {\n const delta = event.shiftKey ? 0.1 : 0.01;\n const moves: Record<string, [number, number]> = {\n ArrowDown: [0, -delta],\n ArrowLeft: [-delta, 0],\n ArrowRight: [delta, 0],\n ArrowUp: [0, delta],\n };\n const move = moves[event.key];\n if (!move) return;\n event.preventDefault();\n const next: [number, number] = [clamp(saturation + move[0]), clamp(value + move[1])];\n onChange(...next);\n onChangeComplete(...next);\n }}\n onPointerDown={(event) => {\n event.currentTarget.setPointerCapture(event.pointerId);\n fromPointer(event);\n }}\n onPointerMove={(event) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) fromPointer(event);\n }}\n onPointerUp={(event) => {\n event.currentTarget.releasePointerCapture(event.pointerId);\n onChangeComplete(...fromPointer(event));\n }}\n >\n <span\n {...stylex.props(styles.thumb)}\n style={{ left: `${saturation * 100}%`, top: `${(1 - value) * 100}%` }}\n />\n </div>\n );\n },\n);\n\nSaturationArea.displayName = 'ColorPickerSaturationArea';\n\nexport default SaturationArea;\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"SaturationArea.mjs","names":[],"sources":["../../src/ColorPicker/SaturationArea.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { memo, type PointerEvent, useRef } from 'react';\n\nimport { focusRing } from '@/styles/stylex/focusRing';\n\nimport { styles } from './style';\n\nexport interface SaturationAreaProps {\n color: string;\n hue: number;\n label: string;\n onChange: (saturation: number, value: number) => void;\n onChangeComplete: (saturation: number, value: number) => void;\n saturation: number;\n value: number;\n}\n\nconst clamp = (n: number) => Math.min(1, Math.max(0, Math.round(n * 100) / 100));\n\nconst SaturationArea = memo<SaturationAreaProps>(\n ({ color, hue, label, onChange, onChangeComplete, saturation, value }) => {\n const areaRef = useRef<HTMLDivElement>(null);\n\n const fromPointer = (event: PointerEvent<HTMLDivElement>): [number, number] => {\n const rect = areaRef.current!.getBoundingClientRect();\n const next: [number, number] = [\n clamp((event.clientX - rect.left) / rect.width),\n clamp(1 - (event.clientY - rect.top) / rect.height),\n ];\n onChange(...next);\n return next;\n };\n\n return (\n <div\n aria-label={label}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={Math.round(saturation * 100)}\n aria-valuetext={`Saturation ${Math.round(saturation * 100)}%, brightness ${Math.round(value * 100)}%`}\n {...stylex.props(focusRing.info, styles.saturation)}\n ref={areaRef}\n role=\"slider\"\n tabIndex={0}\n style={{\n background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${hue} 100% 50%))`,\n }}\n onKeyDown={(event) => {\n const delta = event.shiftKey ? 0.1 : 0.01;\n const moves: Record<string, [number, number]> = {\n ArrowDown: [0, -delta],\n ArrowLeft: [-delta, 0],\n ArrowRight: [delta, 0],\n ArrowUp: [0, delta],\n };\n const move = moves[event.key];\n if (!move) return;\n event.preventDefault();\n const next: [number, number] = [clamp(saturation + move[0]), clamp(value + move[1])];\n onChange(...next);\n onChangeComplete(...next);\n }}\n onPointerDown={(event) => {\n event.currentTarget.setPointerCapture(event.pointerId);\n fromPointer(event);\n }}\n onPointerMove={(event) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) fromPointer(event);\n }}\n onPointerUp={(event) => {\n event.currentTarget.releasePointerCapture(event.pointerId);\n onChangeComplete(...fromPointer(event));\n }}\n >\n <span\n {...stylex.props(styles.thumb)}\n style={{ background: color, left: `${saturation * 100}%`, top: `${(1 - value) * 100}%` }}\n />\n </div>\n );\n },\n);\n\nSaturationArea.displayName = 'ColorPickerSaturationArea';\n\nexport default SaturationArea;\n"],"mappings":";;;;;;;AAeA,MAAM,SAAS,MAAc,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC;AAC/E,MAAM,iBAAiB,MAA2B,EAChD,OACA,KACA,OACA,UACA,kBACA,YACA,YACI;CACJ,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,eAAe,UAA0D;EAC7E,MAAM,OAAO,QAAQ,QAAS,sBAAsB;EACpD,MAAM,OAAyB,CAAC,OAAO,MAAM,UAAU,KAAK,QAAQ,KAA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,KAAK,IAAI,IAAI,SAAS,IAAI;GAC5B;EAAI,CAAA;CACG,CAAA;AACX,CAAC;AACD,eAAe,cAAc"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { swatchStyles } from "./style.mjs";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as stylex from "@stylexjs/stylex";
|
|
4
|
+
//#region src/ColorPicker/Swatch.tsx
|
|
5
|
+
const Swatch = ({ color, radius, size }) => {
|
|
6
|
+
const boxStyle = {
|
|
7
|
+
borderRadius: radius,
|
|
8
|
+
height: size,
|
|
9
|
+
width: size
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
12
|
+
"aria-hidden": true,
|
|
13
|
+
...stylex.props(swatchStyles.box),
|
|
14
|
+
style: boxStyle,
|
|
15
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
16
|
+
...stylex.props(swatchStyles.fill),
|
|
17
|
+
style: { background: color || "transparent" }
|
|
18
|
+
}), !color && /* @__PURE__ */ jsx("span", { ...stylex.props(swatchStyles.slash) })]
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Swatch as default };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=Swatch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swatch.mjs","names":[],"sources":["../../src/ColorPicker/Swatch.tsx"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\nimport type { CSSProperties } from 'react';\n\nimport { swatchStyles } from './style';\n\nexport interface SwatchProps {\n color?: string;\n radius: number | string;\n size: number;\n}\n\nconst Swatch = ({ color, radius, size }: SwatchProps) => {\n const boxStyle: CSSProperties = { borderRadius: radius, height: size, width: size };\n return (\n <span aria-hidden {...stylex.props(swatchStyles.box)} style={boxStyle}>\n <span {...stylex.props(swatchStyles.fill)} style={{ background: color || 'transparent' }} />\n {!color && <span {...stylex.props(swatchStyles.slash)} />}\n </span>\n );\n};\n\nexport default Swatch;\n"],"mappings":";;;;AAQA,MAAM,UAAU,EACd,OACA,QACA,WACiB;CACjB,MAAM,WAA0B;EAC9B,cAAc;EACd,QAAQ;EACR,OAAO;CACT;CACA,OAAO,qBAAC,QAAD;EAAM,eAAA;EAAY,GAAI,OAAO,MAAM,aAAa,GAAG;EAAG,OAAO;EAA7D,UAAA,CACH,oBAAC,QAAD;GAAM,GAAI,OAAO,MAAM,aAAa,IAAI;GAAG,OAAO,EAClD,YAAY,SAAS,cACvB;EAAI,CAAA,GACD,CAAC,SAAS,oBAAC,QAAD,EAAM,GAAI,OAAO,MAAM,aAAa,KAAK,EAAI,CAAA,CACpD;;AACV"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { focusRing } from "../styles/stylex/focusRing.mjs";
|
|
3
|
+
import { styles, swatchStyles } from "./style.mjs";
|
|
4
|
+
import { useRecentColors } from "./recent.mjs";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import * as stylex from "@stylexjs/stylex";
|
|
8
|
+
//#region src/ColorPicker/Swatches.tsx
|
|
9
|
+
const Swatches = ({ current, labels, onPick, presets = [], recent }) => {
|
|
10
|
+
const recentColors = useRecentColors();
|
|
11
|
+
const [tab, setTab] = useState("presets");
|
|
12
|
+
const shownRecent = recent ? recentColors : [];
|
|
13
|
+
const hasPresets = presets.length > 0;
|
|
14
|
+
const hasRecent = shownRecent.length > 0;
|
|
15
|
+
if (!hasPresets && !hasRecent) return null;
|
|
16
|
+
const tabbed = hasPresets && hasRecent;
|
|
17
|
+
const active = tabbed ? tab : hasPresets ? "presets" : "recent";
|
|
18
|
+
const colors = active === "recent" ? shownRecent : presets;
|
|
19
|
+
const currentKey = current.toLowerCase();
|
|
20
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
21
|
+
...stylex.props(styles.swatchSection),
|
|
22
|
+
children: [tabbed ? /* @__PURE__ */ jsx("div", {
|
|
23
|
+
"aria-label": labels.swatches,
|
|
24
|
+
role: "tablist",
|
|
25
|
+
...stylex.props(styles.swatchHeader),
|
|
26
|
+
children: ["presets", "recent"].map((item) => /* @__PURE__ */ jsx("button", {
|
|
27
|
+
"aria-selected": active === item,
|
|
28
|
+
role: "tab",
|
|
29
|
+
type: "button",
|
|
30
|
+
...stylex.props(focusRing.info, styles.swatchTab),
|
|
31
|
+
onClick: () => setTab(item),
|
|
32
|
+
children: labels[item]
|
|
33
|
+
}, item))
|
|
34
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
35
|
+
...stylex.props(styles.swatchHeader),
|
|
36
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
37
|
+
...stylex.props(styles.swatchLabel),
|
|
38
|
+
children: labels[active]
|
|
39
|
+
})
|
|
40
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
41
|
+
"aria-label": labels[active],
|
|
42
|
+
role: "group",
|
|
43
|
+
...stylex.props(styles.swatchGrid),
|
|
44
|
+
children: colors.map((color) => {
|
|
45
|
+
const key = color.toLowerCase();
|
|
46
|
+
const selected = key === currentKey || key === currentKey.slice(0, 7);
|
|
47
|
+
return /* @__PURE__ */ jsx("button", {
|
|
48
|
+
"aria-label": color,
|
|
49
|
+
"aria-pressed": selected,
|
|
50
|
+
type: "button",
|
|
51
|
+
...stylex.props(focusRing.info, styles.swatchItem),
|
|
52
|
+
style: { color },
|
|
53
|
+
onClick: () => onPick(color),
|
|
54
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
55
|
+
...stylex.props(swatchStyles.fill),
|
|
56
|
+
style: { background: color }
|
|
57
|
+
})
|
|
58
|
+
}, color);
|
|
59
|
+
})
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { Swatches as default };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=Swatches.mjs.map
|