react-kui 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/behaviors.json +3 -3
- package/ai/cli.mjs +0 -0
- package/ai/kui-components.json +1552 -1280
- package/ai/mcp.mjs +0 -0
- package/es/_virtual/_rolldown/runtime.js +1 -1
- package/es/affix/index.js +1 -1
- package/es/alert/index.js +29 -15
- package/es/anchor/anchor-context.js +1 -1
- package/es/anchor/anchor-link.js +1 -1
- package/es/anchor/anchor.js +1 -1
- package/es/auto-complete/index.js +378 -437
- package/es/avatar/avatar-group-context.js +1 -1
- package/es/avatar/avatar-group.js +1 -1
- package/es/avatar/avatar.js +2 -2
- package/es/back-top/index.js +3 -3
- package/es/badge/index.js +6 -2
- package/es/base/teleport.js +19 -30
- package/es/base/transition-props.js +1 -1
- package/es/base/transition.js +3 -3
- package/es/breadcrumb/breadcrumb-context.js +1 -1
- package/es/breadcrumb/breadcrumb-item.js +1 -1
- package/es/breadcrumb/breadcrumb.js +1 -1
- package/es/button/button-group-context.js +1 -1
- package/es/button/button-group.js +1 -1
- package/es/button/button.js +2 -2
- package/es/calendar/index.js +1 -1
- package/es/card/index.js +1 -1
- package/es/carousel/carousel-context.js +1 -1
- package/es/carousel/carousel-item.js +1 -1
- package/es/carousel/carousel.js +1 -1
- package/es/cascader/index.js +104 -170
- package/es/check-card/check-card-group.js +1 -1
- package/es/check-card/check-card.js +143 -143
- package/es/check-card/context.js +1 -1
- package/es/checkbox/checkbox-group-context.js +1 -1
- package/es/checkbox/checkbox-group.js +1 -1
- package/es/checkbox/checkbox.js +131 -112
- package/es/checkbox/index.js +1 -1
- package/es/collapse/collapse-panel.js +2 -2
- package/es/collapse/collapse.js +96 -103
- package/es/color-picker/alpha.js +81 -63
- package/es/color-picker/hue.js +69 -51
- package/es/color-picker/index.js +79 -128
- package/es/color-picker/mode.js +1 -1
- package/es/color-picker/paint.js +85 -67
- package/es/color-picker/presets.js +1 -1
- package/es/components.js +4 -2
- package/es/config/config-context.js +1 -1
- package/es/config/context.js +1 -1
- package/es/config/index.js +1 -1
- package/es/config/size-context.js +1 -1
- package/es/config/use-config-appearance.js +1 -1
- package/es/const/var.js +1 -1
- package/es/date-picker/index.js +591 -678
- package/es/descriptions/descriptions-item.js +1 -1
- package/es/descriptions/descriptions.js +2 -2
- package/es/divider/index.js +1 -1
- package/es/drawer/index.js +193 -190
- package/es/dropdown/dropdown-button.js +1 -1
- package/es/dropdown/dropdown-context.js +1 -1
- package/es/dropdown/dropdown.js +173 -331
- package/es/dropdown/trigger.js +1 -1
- package/es/empty/index.js +1 -1
- package/es/feature-card/index.js +1 -1
- package/es/feedback-panel/index.js +1 -1
- package/es/flame-wrap/index.js +1 -1
- package/es/flame-wrap/types.js +1 -1
- package/es/flex/index.js +1 -1
- package/es/form/field-context.js +1 -1
- package/es/form/form-context.js +1 -1
- package/es/form/form-item.js +2 -2
- package/es/form/form.js +1 -1
- package/es/form/utils.js +1 -1
- package/es/grid/grid-item.js +1 -1
- package/es/grid/grid.js +1 -1
- package/es/grid/useBreakpoint.js +1 -1
- package/es/icon/index.js +1 -1
- package/es/image/group.js +1 -1
- package/es/image/image-group-context.js +1 -1
- package/es/image/image.js +1 -1
- package/es/image/instance.js +1 -1
- package/es/image/preview.js +2 -2
- package/es/image/utils.js +1 -1
- package/es/index.js +3 -2
- package/es/input/index.js +1 -1
- package/es/input/input-box.js +1 -1
- package/es/input/input-group.js +2 -2
- package/es/input/input.js +1 -1
- package/es/input/textarea.js +1 -1
- package/es/input-number/index.js +1 -1
- package/es/input-otp/index.js +2 -1
- package/es/input-tag/index.js +13 -43
- package/es/kanban/index.js +1 -1
- package/es/layout/index.js +1 -1
- package/es/layout/layout-context.js +1 -1
- package/es/list-panel/index.js +1 -1
- package/es/loading/index.js +1 -1
- package/es/loading/loading-bar.js +1 -1
- package/es/locale/de.js +1 -1
- package/es/locale/el.js +1 -1
- package/es/locale/en.js +1 -1
- package/es/locale/fr.js +1 -1
- package/es/locale/it.js +1 -1
- package/es/locale/ja.js +1 -1
- package/es/locale/ko.js +1 -1
- package/es/locale/ru.js +1 -1
- package/es/locale/th.js +1 -1
- package/es/locale/uk.js +1 -1
- package/es/locale/vi.js +1 -1
- package/es/locale/zh-CN.js +1 -1
- package/es/locale/zh-TW.js +1 -1
- package/es/mentions/index.js +341 -387
- package/es/menu/menu-context.js +1 -1
- package/es/menu/menu-divider.js +1 -1
- package/es/menu/menu-group.js +1 -1
- package/es/menu/menu-item.js +3 -3
- package/es/menu/menu-keyboard.js +1 -1
- package/es/menu/menu.js +215 -220
- package/es/menu/recursive-menu.js +1 -1
- package/es/menu/sub-menu.js +3 -3
- package/es/message/index.js +1 -1
- package/es/modal/api.js +1 -1
- package/es/modal/modal.js +247 -244
- package/es/modal/toast.js +1 -1
- package/es/node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js +1 -1
- package/es/notice/container.js +1 -1
- package/es/notice/content.js +1 -1
- package/es/notice/index.js +1 -1
- package/es/notice/instance.js +1 -1
- package/es/page/index.js +3 -3
- package/es/page-header/index.js +1 -1
- package/es/popconfirm/index.js +89 -241
- package/es/poptip/index.js +83 -243
- package/es/popup/index.js +429 -0
- package/es/popup/layers.js +33 -0
- package/es/progress/index.js +1 -1
- package/es/qrcode/index.js +1 -1
- package/es/radio/radio-button.js +53 -53
- package/es/radio/radio-group-context.js +1 -1
- package/es/radio/radio-group.js +1 -1
- package/es/radio/radio.js +110 -91
- package/es/rate/index.js +58 -57
- package/es/rate/star.js +1 -1
- package/es/result/index.js +1 -1
- package/es/ripple/index.js +1 -1
- package/es/ripple/types.js +1 -1
- package/es/row-col/col.js +1 -1
- package/es/row-col/row.js +1 -1
- package/es/segmented/index.js +1 -1
- package/es/select/option.js +69 -61
- package/es/select/select.js +78 -213
- package/es/skeleton/skeleton-avatar.js +1 -1
- package/es/skeleton/skeleton-button.js +1 -1
- package/es/skeleton/skeleton-image.js +1 -1
- package/es/skeleton/skeleton-text.js +1 -1
- package/es/skeleton/skeleton.js +1 -1
- package/es/skeleton/use-skeleton-loading.js +1 -1
- package/es/slider/index.js +89 -55
- package/es/slider/thumb.js +2 -1
- package/es/space/index.js +2 -2
- package/es/spin/index.js +1 -1
- package/es/splitter/splitter-panel.js +1 -1
- package/es/splitter/splitter.js +1 -1
- package/es/stat-card/countup.js +8 -4
- package/es/stat-card/rollup.js +122 -0
- package/es/stat-card/stat-card.js +1 -1
- package/es/stat-card/stat-number.js +1 -1
- package/es/stat-card/utils/countup.js +2 -2
- package/es/stat-card/utils/odometer.js +104 -107
- package/es/steps/index.js +1 -1
- package/es/switch/index.js +7 -6
- package/es/table/column-setting.js +1 -1
- package/es/table/index.js +33 -29
- package/es/table/utils.js +1 -1
- package/es/tabs/tab-panel.js +1 -1
- package/es/tabs/tabs.js +15 -6
- package/es/tag/index.js +9 -5
- package/es/time-line/timeline-item.js +1 -1
- package/es/time-line/timeline.js +1 -1
- package/es/tooltip/index.js +127 -248
- package/es/tour/index.js +198 -193
- package/es/transfer/index.js +245 -246
- package/es/tree/index.js +72 -67
- package/es/tree/utils.js +1 -1
- package/es/tree-select/index.js +562 -655
- package/es/typography/index.js +1 -1
- package/es/upload/file-list.js +3 -1
- package/es/upload/index.js +8 -8
- package/es/upload/picture-sort.js +1 -1
- package/es/upload/selector.js +121 -116
- package/es/utils/checked.js +1 -1
- package/es/utils/color.js +1 -1
- package/es/utils/number.js +1 -1
- package/es/utils/placement.js +1 -1
- package/es/utils/popup.js +42 -0
- package/es/utils/react-node.js +1 -1
- package/es/utils/selection-tags.js +55 -0
- package/es/utils/share.js +1 -1
- package/es/utils/theme.js +1 -1
- package/es/utils/transition.js +1 -1
- package/es/utils/use-value.js +1 -1
- package/es/virtual-list/index.js +1 -1
- package/es/virtual-list/range.js +1 -1
- package/es/watermark/index.js +1 -1
- package/lib/index.cjs +2 -2
- package/lib/locale/de.cjs +1 -1
- package/lib/locale/el.cjs +1 -1
- package/lib/locale/en.cjs +1 -1
- package/lib/locale/fr.cjs +1 -1
- package/lib/locale/it.cjs +1 -1
- package/lib/locale/ja.cjs +1 -1
- package/lib/locale/ko.cjs +1 -1
- package/lib/locale/ru.cjs +1 -1
- package/lib/locale/th.cjs +1 -1
- package/lib/locale/uk.cjs +1 -1
- package/lib/locale/vi.cjs +1 -1
- package/lib/locale/zh-CN.cjs +1 -1
- package/lib/locale/zh-TW.cjs +1 -1
- package/package.json +32 -29
- package/style/base.css +1 -1
- package/style/components.css +2 -2
- package/style/index.css +2 -2
- package/style/theme.css +2 -2
- package/types/affix/index.d.cts +1 -1
- package/types/affix/index.d.ts +1 -1
- package/types/alert/index.d.cts +2 -1
- package/types/alert/index.d.ts +2 -1
- package/types/anchor/anchor-link.d.cts +1 -1
- package/types/anchor/anchor-link.d.ts +1 -1
- package/types/anchor/anchor.d.cts +1 -1
- package/types/anchor/anchor.d.ts +1 -1
- package/types/auto-complete/index.d.cts +1 -2
- package/types/auto-complete/index.d.ts +1 -2
- package/types/avatar/avatar-group.d.cts +1 -1
- package/types/avatar/avatar-group.d.ts +1 -1
- package/types/avatar/avatar.d.cts +1 -1
- package/types/avatar/avatar.d.ts +1 -1
- package/types/back-top/index.d.cts +1 -1
- package/types/back-top/index.d.ts +1 -1
- package/types/badge/index.d.cts +1 -1
- package/types/badge/index.d.ts +1 -1
- package/types/base/transition.d.cts +1 -0
- package/types/base/transition.d.ts +1 -0
- package/types/breadcrumb/breadcrumb-item.d.cts +1 -1
- package/types/breadcrumb/breadcrumb-item.d.ts +1 -1
- package/types/breadcrumb/breadcrumb.d.cts +1 -1
- package/types/breadcrumb/breadcrumb.d.ts +1 -1
- package/types/button/button-group.d.cts +1 -1
- package/types/button/button-group.d.ts +1 -1
- package/types/button/button.d.cts +1 -1
- package/types/button/button.d.ts +1 -1
- package/types/calendar/index.d.cts +1 -1
- package/types/calendar/index.d.ts +1 -1
- package/types/card/index.d.cts +2 -2
- package/types/card/index.d.ts +2 -2
- package/types/carousel/carousel-item.d.cts +1 -1
- package/types/carousel/carousel-item.d.ts +1 -1
- package/types/carousel/carousel.d.cts +1 -1
- package/types/carousel/carousel.d.ts +1 -1
- package/types/cascader/index.d.cts +1 -1
- package/types/cascader/index.d.ts +1 -1
- package/types/cascader/types.d.cts +1 -2
- package/types/cascader/types.d.ts +1 -2
- package/types/check-card/types.d.cts +2 -3
- package/types/check-card/types.d.ts +2 -3
- package/types/checkbox/checkbox-group.d.cts +1 -1
- package/types/checkbox/checkbox-group.d.ts +1 -1
- package/types/checkbox/checkbox.d.cts +1 -2
- package/types/checkbox/checkbox.d.ts +1 -2
- package/types/checkbox/index.d.cts +1 -1
- package/types/checkbox/index.d.ts +1 -1
- package/types/collapse/collapse-panel.d.cts +1 -1
- package/types/collapse/collapse-panel.d.ts +1 -1
- package/types/collapse/collapse.d.cts +1 -2
- package/types/collapse/collapse.d.ts +1 -2
- package/types/color-picker/alpha.d.cts +2 -1
- package/types/color-picker/alpha.d.ts +2 -1
- package/types/color-picker/hue.d.cts +2 -1
- package/types/color-picker/hue.d.ts +2 -1
- package/types/color-picker/index.d.cts +3 -4
- package/types/color-picker/index.d.ts +3 -4
- package/types/color-picker/paint.d.cts +2 -1
- package/types/color-picker/paint.d.ts +2 -1
- package/types/components.d.cts +17 -13
- package/types/components.d.ts +17 -13
- package/types/date-picker/index.d.cts +3 -4
- package/types/date-picker/index.d.ts +3 -4
- package/types/descriptions/descriptions.d.cts +1 -1
- package/types/descriptions/descriptions.d.ts +1 -1
- package/types/divider/index.d.cts +1 -1
- package/types/divider/index.d.ts +1 -1
- package/types/drawer/index.d.cts +0 -1
- package/types/drawer/index.d.ts +0 -1
- package/types/dropdown/dropdown-button.d.cts +1 -1
- package/types/dropdown/dropdown-button.d.ts +1 -1
- package/types/dropdown/dropdown.d.cts +1 -2
- package/types/dropdown/dropdown.d.ts +1 -2
- package/types/empty/index.d.cts +1 -1
- package/types/empty/index.d.ts +1 -1
- package/types/feature-card/index.d.cts +1 -1
- package/types/feature-card/index.d.ts +1 -1
- package/types/feedback-panel/index.d.cts +1 -1
- package/types/feedback-panel/index.d.ts +1 -1
- package/types/flex/index.d.cts +1 -1
- package/types/flex/index.d.ts +1 -1
- package/types/form/form.d.cts +1 -1
- package/types/form/form.d.ts +1 -1
- package/types/grid/grid-item.d.cts +1 -1
- package/types/grid/grid-item.d.ts +1 -1
- package/types/grid/grid.d.cts +1 -1
- package/types/grid/grid.d.ts +1 -1
- package/types/icon/index.d.cts +1 -1
- package/types/icon/index.d.ts +1 -1
- package/types/image/group.d.cts +1 -1
- package/types/image/group.d.ts +1 -1
- package/types/image/image.d.cts +1 -1
- package/types/image/image.d.ts +1 -1
- package/types/input/index.d.cts +1 -1
- package/types/input/index.d.ts +1 -1
- package/types/input/input-box.d.cts +1 -1
- package/types/input/input-box.d.ts +1 -1
- package/types/input/input-group.d.cts +1 -1
- package/types/input/input-group.d.ts +1 -1
- package/types/input/input.d.cts +1 -1
- package/types/input/input.d.ts +1 -1
- package/types/input/textarea.d.cts +1 -1
- package/types/input/textarea.d.ts +1 -1
- package/types/input-number/index.d.cts +1 -1
- package/types/input-number/index.d.ts +1 -1
- package/types/input-otp/index.d.cts +1 -1
- package/types/input-otp/index.d.ts +1 -1
- package/types/input-tag/index.d.cts +1 -1
- package/types/input-tag/index.d.ts +1 -1
- package/types/kanban/index.d.cts +1 -1
- package/types/kanban/index.d.ts +1 -1
- package/types/layout/index.d.cts +2 -2
- package/types/layout/index.d.ts +2 -2
- package/types/list-panel/index.d.cts +1 -1
- package/types/list-panel/index.d.ts +1 -1
- package/types/mentions/index.d.cts +1 -1
- package/types/mentions/index.d.ts +1 -1
- package/types/menu/menu.d.cts +1 -2
- package/types/menu/menu.d.ts +1 -2
- package/types/modal/modal.d.cts +1 -2
- package/types/modal/modal.d.ts +1 -2
- package/types/page/index.d.cts +1 -1
- package/types/page/index.d.ts +1 -1
- package/types/page-header/index.d.cts +1 -1
- package/types/page-header/index.d.ts +1 -1
- package/types/popconfirm/index.d.cts +1 -2
- package/types/popconfirm/index.d.ts +1 -2
- package/types/poptip/index.d.cts +1 -2
- package/types/poptip/index.d.ts +1 -2
- package/types/popup/index.d.cts +48 -0
- package/types/popup/index.d.ts +48 -0
- package/types/popup/layers.d.cts +9 -0
- package/types/popup/layers.d.ts +9 -0
- package/types/popup/types.d.cts +15 -0
- package/types/popup/types.d.ts +15 -0
- package/types/progress/index.d.cts +1 -1
- package/types/progress/index.d.ts +1 -1
- package/types/qrcode/index.d.cts +1 -1
- package/types/qrcode/index.d.ts +1 -1
- package/types/radio/index.d.cts +1 -0
- package/types/radio/index.d.ts +1 -0
- package/types/radio/radio-button.d.cts +1 -2
- package/types/radio/radio-button.d.ts +1 -2
- package/types/radio/radio-group.d.cts +1 -1
- package/types/radio/radio-group.d.ts +1 -1
- package/types/radio/radio.d.cts +1 -2
- package/types/radio/radio.d.ts +1 -2
- package/types/rate/index.d.cts +1 -1
- package/types/rate/index.d.ts +1 -1
- package/types/result/index.d.cts +1 -1
- package/types/result/index.d.ts +1 -1
- package/types/row-col/col.d.cts +1 -1
- package/types/row-col/col.d.ts +1 -1
- package/types/row-col/row.d.cts +1 -1
- package/types/row-col/row.d.ts +1 -1
- package/types/segmented/index.d.cts +1 -1
- package/types/segmented/index.d.ts +1 -1
- package/types/select/index.d.cts +2 -2
- package/types/select/index.d.ts +2 -2
- package/types/select/option.d.cts +1 -1
- package/types/select/option.d.ts +1 -1
- package/types/select/select.d.cts +1 -2
- package/types/select/select.d.ts +1 -2
- package/types/skeleton/skeleton-avatar.d.cts +1 -1
- package/types/skeleton/skeleton-avatar.d.ts +1 -1
- package/types/skeleton/skeleton-button.d.cts +1 -1
- package/types/skeleton/skeleton-button.d.ts +1 -1
- package/types/skeleton/skeleton-image.d.cts +1 -1
- package/types/skeleton/skeleton-image.d.ts +1 -1
- package/types/skeleton/skeleton-text.d.cts +1 -1
- package/types/skeleton/skeleton-text.d.ts +1 -1
- package/types/skeleton/skeleton.d.cts +1 -1
- package/types/skeleton/skeleton.d.ts +1 -1
- package/types/slider/index.d.cts +1 -1
- package/types/slider/index.d.ts +1 -1
- package/types/space/index.d.cts +1 -1
- package/types/space/index.d.ts +1 -1
- package/types/spin/index.d.cts +1 -1
- package/types/spin/index.d.ts +1 -1
- package/types/splitter/splitter-panel.d.cts +1 -1
- package/types/splitter/splitter-panel.d.ts +1 -1
- package/types/splitter/splitter.d.cts +1 -1
- package/types/splitter/splitter.d.ts +1 -1
- package/types/stat-card/countup.d.cts +1 -1
- package/types/stat-card/countup.d.ts +1 -1
- package/types/stat-card/rollup.d.cts +3 -2
- package/types/stat-card/rollup.d.ts +3 -2
- package/types/stat-card/stat-card.d.cts +1 -1
- package/types/stat-card/stat-card.d.ts +1 -1
- package/types/stat-card/stat-number.d.cts +1 -1
- package/types/stat-card/stat-number.d.ts +1 -1
- package/types/stat-card/utils/countup.d.cts +1 -1
- package/types/stat-card/utils/countup.d.ts +1 -1
- package/types/stat-card/utils/odometer.d.cts +7 -4
- package/types/stat-card/utils/odometer.d.ts +7 -4
- package/types/steps/index.d.cts +1 -1
- package/types/steps/index.d.ts +1 -1
- package/types/switch/index.d.cts +1 -2
- package/types/switch/index.d.ts +1 -2
- package/types/table/index.d.cts +1 -1
- package/types/table/index.d.ts +1 -1
- package/types/table/types.d.cts +2 -4
- package/types/table/types.d.ts +2 -4
- package/types/tabs/index.d.cts +1 -0
- package/types/tabs/index.d.ts +1 -0
- package/types/tabs/tab-panel.d.cts +1 -1
- package/types/tabs/tab-panel.d.ts +1 -1
- package/types/tabs/tabs.d.cts +1 -1
- package/types/tabs/tabs.d.ts +1 -1
- package/types/tag/index.d.cts +2 -1
- package/types/tag/index.d.ts +2 -1
- package/types/time-line/timeline-item.d.cts +1 -1
- package/types/time-line/timeline-item.d.ts +1 -1
- package/types/time-line/timeline.d.cts +1 -1
- package/types/time-line/timeline.d.ts +1 -1
- package/types/tooltip/index.d.cts +2 -2
- package/types/tooltip/index.d.ts +2 -2
- package/types/tour/index.d.cts +0 -2
- package/types/tour/index.d.ts +0 -2
- package/types/transfer/index.d.cts +2 -3
- package/types/transfer/index.d.ts +2 -3
- package/types/tree/index.d.cts +2 -4
- package/types/tree/index.d.ts +2 -4
- package/types/tree-select/index.d.cts +2 -3
- package/types/tree-select/index.d.ts +2 -3
- package/types/typography/index.d.cts +1 -1
- package/types/typography/index.d.ts +1 -1
- package/types/upload/index.d.cts +1 -2
- package/types/upload/index.d.ts +1 -2
- package/types/upload/selector.d.cts +1 -1
- package/types/upload/selector.d.ts +1 -1
- package/types/utils/popup.d.cts +11 -0
- package/types/utils/popup.d.ts +11 -0
- package/types/utils/selection-tags.d.cts +19 -0
- package/types/utils/selection-tags.d.ts +19 -0
- package/types/virtual-list/index.d.cts +1 -1
- package/types/virtual-list/index.d.ts +1 -1
- package/types/watermark/index.d.cts +1 -1
- package/types/watermark/index.d.ts +1 -1
package/es/color-picker/alpha.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.1.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
@@ -8,26 +8,27 @@
|
|
|
8
8
|
|
|
9
9
|
import { clamp } from "../utils/share.js";
|
|
10
10
|
import { c } from "react/compiler-runtime";
|
|
11
|
-
import { useEffect, useRef } from "react";
|
|
11
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import Color from "color";
|
|
14
14
|
//#region components/color-picker/alpha.tsx
|
|
15
15
|
function Alpha(t0) {
|
|
16
|
-
const $ = c(
|
|
17
|
-
const { value, onUpdateAlpha } = t0;
|
|
16
|
+
const $ = c(23);
|
|
17
|
+
const { disabled: t1, value, onUpdateAlpha } = t0;
|
|
18
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
18
19
|
const canvasRef = useRef(null);
|
|
19
20
|
const dragCleanupRef = useRef(_temp);
|
|
20
|
-
let
|
|
21
|
+
let t2;
|
|
21
22
|
if ($[0] !== value) {
|
|
22
|
-
|
|
23
|
+
t2 = Color(value);
|
|
23
24
|
$[0] = value;
|
|
24
|
-
$[1] =
|
|
25
|
-
} else
|
|
26
|
-
const color =
|
|
27
|
-
let t2;
|
|
25
|
+
$[1] = t2;
|
|
26
|
+
} else t2 = $[1];
|
|
27
|
+
const color = t2;
|
|
28
28
|
let t3;
|
|
29
|
+
let t4;
|
|
29
30
|
if ($[2] !== color) {
|
|
30
|
-
|
|
31
|
+
t3 = () => {
|
|
31
32
|
const canvas = canvasRef.current;
|
|
32
33
|
const context = canvas?.getContext("2d");
|
|
33
34
|
if (!canvas || !context) return;
|
|
@@ -39,30 +40,46 @@ function Alpha(t0) {
|
|
|
39
40
|
context.fillStyle = gradient;
|
|
40
41
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
+
t4 = [color];
|
|
43
44
|
$[2] = color;
|
|
44
|
-
$[3] =
|
|
45
|
-
$[4] =
|
|
45
|
+
$[3] = t3;
|
|
46
|
+
$[4] = t4;
|
|
46
47
|
} else {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
t3 = $[3];
|
|
49
|
+
t4 = $[4];
|
|
49
50
|
}
|
|
50
|
-
useEffect(
|
|
51
|
-
let t4;
|
|
51
|
+
useEffect(t3, t4);
|
|
52
52
|
let t5;
|
|
53
|
+
let t6;
|
|
53
54
|
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
$[5] =
|
|
57
|
-
$[6] =
|
|
55
|
+
t5 = () => () => dragCleanupRef.current();
|
|
56
|
+
t6 = [];
|
|
57
|
+
$[5] = t5;
|
|
58
|
+
$[6] = t6;
|
|
58
59
|
} else {
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
t5 = $[5];
|
|
61
|
+
t6 = $[6];
|
|
61
62
|
}
|
|
62
|
-
useEffect(
|
|
63
|
-
let
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
useEffect(t5, t6);
|
|
64
|
+
let t7;
|
|
65
|
+
let t8;
|
|
66
|
+
if ($[7] !== disabled) {
|
|
67
|
+
t7 = () => {
|
|
68
|
+
if (disabled) dragCleanupRef.current();
|
|
69
|
+
};
|
|
70
|
+
t8 = [disabled];
|
|
71
|
+
$[7] = disabled;
|
|
72
|
+
$[8] = t7;
|
|
73
|
+
$[9] = t8;
|
|
74
|
+
} else {
|
|
75
|
+
t7 = $[8];
|
|
76
|
+
t8 = $[9];
|
|
77
|
+
}
|
|
78
|
+
useLayoutEffect(t7, t8);
|
|
79
|
+
let t9;
|
|
80
|
+
if ($[10] !== disabled || $[11] !== onUpdateAlpha) {
|
|
81
|
+
t9 = (event) => {
|
|
82
|
+
if (disabled) return;
|
|
66
83
|
const move = (x) => {
|
|
67
84
|
const rect = canvasRef.current.getBoundingClientRect();
|
|
68
85
|
onUpdateAlpha?.(Number((clamp(x - rect.left, 0, rect.width) / rect.width).toFixed(2)));
|
|
@@ -78,53 +95,54 @@ function Alpha(t0) {
|
|
|
78
95
|
document.addEventListener("mousemove", mousemove);
|
|
79
96
|
document.addEventListener("mouseup", up);
|
|
80
97
|
};
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
$[10] = disabled;
|
|
99
|
+
$[11] = onUpdateAlpha;
|
|
100
|
+
$[12] = t9;
|
|
101
|
+
} else t9 = $[12];
|
|
102
|
+
const start = t9;
|
|
103
|
+
let t10;
|
|
104
|
+
if ($[13] !== start) {
|
|
105
|
+
t10 = /* @__PURE__ */ jsx("canvas", {
|
|
88
106
|
className: "k-color-picker-alpha",
|
|
89
107
|
width: 190,
|
|
90
108
|
height: 8,
|
|
91
109
|
ref: canvasRef,
|
|
92
110
|
onMouseDown: start
|
|
93
111
|
});
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
} else
|
|
97
|
-
const
|
|
98
|
-
let
|
|
99
|
-
if ($[
|
|
100
|
-
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
} else
|
|
104
|
-
let
|
|
105
|
-
if ($[
|
|
106
|
-
|
|
112
|
+
$[13] = start;
|
|
113
|
+
$[14] = t10;
|
|
114
|
+
} else t10 = $[14];
|
|
115
|
+
const t11 = color.alpha() * 190 - 7;
|
|
116
|
+
let t12;
|
|
117
|
+
if ($[15] !== color) {
|
|
118
|
+
t12 = color.string();
|
|
119
|
+
$[15] = color;
|
|
120
|
+
$[16] = t12;
|
|
121
|
+
} else t12 = $[16];
|
|
122
|
+
let t13;
|
|
123
|
+
if ($[17] !== t11 || $[18] !== t12) {
|
|
124
|
+
t13 = /* @__PURE__ */ jsx("span", {
|
|
107
125
|
className: "k-color-picker-alpha-dot",
|
|
108
126
|
style: {
|
|
109
|
-
left:
|
|
110
|
-
backgroundColor:
|
|
127
|
+
left: t11,
|
|
128
|
+
backgroundColor: t12
|
|
111
129
|
}
|
|
112
130
|
});
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
} else
|
|
117
|
-
let
|
|
118
|
-
if ($[
|
|
119
|
-
|
|
131
|
+
$[17] = t11;
|
|
132
|
+
$[18] = t12;
|
|
133
|
+
$[19] = t13;
|
|
134
|
+
} else t13 = $[19];
|
|
135
|
+
let t14;
|
|
136
|
+
if ($[20] !== t10 || $[21] !== t13) {
|
|
137
|
+
t14 = /* @__PURE__ */ jsxs("div", {
|
|
120
138
|
className: "k-color-picker-alpha-box",
|
|
121
|
-
children: [
|
|
139
|
+
children: [t10, t13]
|
|
122
140
|
});
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
} else
|
|
127
|
-
return
|
|
141
|
+
$[20] = t10;
|
|
142
|
+
$[21] = t13;
|
|
143
|
+
$[22] = t14;
|
|
144
|
+
} else t14 = $[22];
|
|
145
|
+
return t14;
|
|
128
146
|
}
|
|
129
147
|
function _temp() {}
|
|
130
148
|
//#endregion
|
package/es/color-picker/hue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.1.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
@@ -8,19 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
import { clamp } from "../utils/share.js";
|
|
10
10
|
import { c } from "react/compiler-runtime";
|
|
11
|
-
import { useEffect, useRef } from "react";
|
|
11
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
//#region components/color-picker/hue.tsx
|
|
14
14
|
function Hue(t0) {
|
|
15
|
-
const $ = c(
|
|
16
|
-
const {
|
|
17
|
-
const
|
|
15
|
+
const $ = c(17);
|
|
16
|
+
const { disabled: t1, hue: t2, onUpdateHue } = t0;
|
|
17
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
18
|
+
const hue = t2 === void 0 ? 0 : t2;
|
|
18
19
|
const canvasRef = useRef(null);
|
|
19
20
|
const dragCleanupRef = useRef(_temp);
|
|
20
|
-
let t2;
|
|
21
21
|
let t3;
|
|
22
|
+
let t4;
|
|
22
23
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
23
|
-
|
|
24
|
+
t3 = () => {
|
|
24
25
|
const canvas = canvasRef.current;
|
|
25
26
|
const context = canvas?.getContext("2d");
|
|
26
27
|
if (!canvas || !context) return;
|
|
@@ -29,29 +30,45 @@ function Hue(t0) {
|
|
|
29
30
|
context.fillStyle = gradient;
|
|
30
31
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
31
32
|
};
|
|
32
|
-
|
|
33
|
-
$[0] =
|
|
34
|
-
$[1] =
|
|
33
|
+
t4 = [];
|
|
34
|
+
$[0] = t3;
|
|
35
|
+
$[1] = t4;
|
|
35
36
|
} else {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
t3 = $[0];
|
|
38
|
+
t4 = $[1];
|
|
38
39
|
}
|
|
39
|
-
useEffect(
|
|
40
|
-
let t4;
|
|
40
|
+
useEffect(t3, t4);
|
|
41
41
|
let t5;
|
|
42
|
+
let t6;
|
|
42
43
|
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
$[2] =
|
|
46
|
-
$[3] =
|
|
44
|
+
t5 = () => () => dragCleanupRef.current();
|
|
45
|
+
t6 = [];
|
|
46
|
+
$[2] = t5;
|
|
47
|
+
$[3] = t6;
|
|
47
48
|
} else {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
t5 = $[2];
|
|
50
|
+
t6 = $[3];
|
|
50
51
|
}
|
|
51
|
-
useEffect(
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
useEffect(t5, t6);
|
|
53
|
+
let t7;
|
|
54
|
+
let t8;
|
|
55
|
+
if ($[4] !== disabled) {
|
|
56
|
+
t7 = () => {
|
|
57
|
+
if (disabled) dragCleanupRef.current();
|
|
58
|
+
};
|
|
59
|
+
t8 = [disabled];
|
|
60
|
+
$[4] = disabled;
|
|
61
|
+
$[5] = t7;
|
|
62
|
+
$[6] = t8;
|
|
63
|
+
} else {
|
|
64
|
+
t7 = $[5];
|
|
65
|
+
t8 = $[6];
|
|
66
|
+
}
|
|
67
|
+
useLayoutEffect(t7, t8);
|
|
68
|
+
let t9;
|
|
69
|
+
if ($[7] !== disabled || $[8] !== onUpdateHue) {
|
|
70
|
+
t9 = (event) => {
|
|
71
|
+
if (disabled) return;
|
|
55
72
|
const move = (clientX) => {
|
|
56
73
|
const rect = canvasRef.current.getBoundingClientRect();
|
|
57
74
|
onUpdateHue?.(Math.round(clamp(clientX - rect.left, 0, rect.width) / rect.width * 360));
|
|
@@ -68,43 +85,44 @@ function Hue(t0) {
|
|
|
68
85
|
document.addEventListener("mouseup", up);
|
|
69
86
|
event.preventDefault();
|
|
70
87
|
};
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
$[7] = disabled;
|
|
89
|
+
$[8] = onUpdateHue;
|
|
90
|
+
$[9] = t9;
|
|
91
|
+
} else t9 = $[9];
|
|
92
|
+
const start = t9;
|
|
93
|
+
let t10;
|
|
94
|
+
if ($[10] !== start) {
|
|
95
|
+
t10 = /* @__PURE__ */ jsx("canvas", {
|
|
78
96
|
className: "k-color-picker-hue",
|
|
79
97
|
width: 190,
|
|
80
98
|
height: 8,
|
|
81
99
|
ref: canvasRef,
|
|
82
100
|
onMouseDown: start
|
|
83
101
|
});
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
} else
|
|
87
|
-
const
|
|
88
|
-
let
|
|
89
|
-
if ($[
|
|
90
|
-
|
|
102
|
+
$[10] = start;
|
|
103
|
+
$[11] = t10;
|
|
104
|
+
} else t10 = $[11];
|
|
105
|
+
const t11 = hue / 360 * 190 - 7;
|
|
106
|
+
let t12;
|
|
107
|
+
if ($[12] !== t11) {
|
|
108
|
+
t12 = /* @__PURE__ */ jsx("span", {
|
|
91
109
|
className: "k-color-picker-hue-dot",
|
|
92
|
-
style: { left:
|
|
110
|
+
style: { left: t11 }
|
|
93
111
|
});
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
} else
|
|
97
|
-
let
|
|
98
|
-
if ($[
|
|
99
|
-
|
|
112
|
+
$[12] = t11;
|
|
113
|
+
$[13] = t12;
|
|
114
|
+
} else t12 = $[13];
|
|
115
|
+
let t13;
|
|
116
|
+
if ($[14] !== t10 || $[15] !== t12) {
|
|
117
|
+
t13 = /* @__PURE__ */ jsxs("div", {
|
|
100
118
|
className: "k-color-picker-slider-hue",
|
|
101
|
-
children: [
|
|
119
|
+
children: [t10, t12]
|
|
102
120
|
});
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
} else
|
|
107
|
-
return
|
|
121
|
+
$[14] = t10;
|
|
122
|
+
$[15] = t12;
|
|
123
|
+
$[16] = t13;
|
|
124
|
+
} else t13 = $[16];
|
|
125
|
+
return t13;
|
|
108
126
|
}
|
|
109
127
|
function _temp() {}
|
|
110
128
|
//#endregion
|
package/es/color-picker/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.1.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
6
6
|
* Author: Qiu / https://chuchur.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import Popup from "../popup/index.js";
|
|
9
10
|
import { useConfigAppearance } from "../config/use-config-appearance.js";
|
|
10
11
|
import { useValue } from "../utils/use-value.js";
|
|
11
12
|
import { createFormFieldComponent } from "../form/field-context.js";
|
|
12
|
-
import Teleport from "../base/teleport.js";
|
|
13
|
-
import { Transition } from "../base/transition.js";
|
|
14
|
-
import { setPlacement } from "../utils/placement.js";
|
|
15
13
|
import Alpha from "./alpha.js";
|
|
16
14
|
import Hue from "./hue.js";
|
|
17
15
|
import Mode from "./mode.js";
|
|
@@ -19,11 +17,11 @@ import Paint from "./paint.js";
|
|
|
19
17
|
import Presets from "./presets.js";
|
|
20
18
|
import { c } from "react/compiler-runtime";
|
|
21
19
|
import clsx from "clsx";
|
|
22
|
-
import { isValidElement, useCallback,
|
|
20
|
+
import { isValidElement, useCallback, useRef, useState } from "react";
|
|
23
21
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
24
22
|
import Color from "color";
|
|
25
23
|
//#region components/color-picker/index.tsx
|
|
26
|
-
function ColorPicker({ value, open: openProp,
|
|
24
|
+
function ColorPicker({ value, open: openProp, disabled = false, readOnly = false, disabledAlpha = false, showText = false, placement = "bottom-left", trigger = "click", size: sizeProp, theme: themeProp, shape: shapeProp, mode: modeProp, presets, onChange, onUpdateMode, onOpenChange, className, children, panelOnly = false, ...rest }) {
|
|
27
25
|
const inheritedAppearance = useConfigAppearance();
|
|
28
26
|
const size = sizeProp ?? inheritedAppearance.size;
|
|
29
27
|
const theme = themeProp ?? inheritedAppearance.theme ?? "fill";
|
|
@@ -34,114 +32,55 @@ function ColorPicker({ value, open: openProp, defaultOpen = false, disabled = fa
|
|
|
34
32
|
const [initialColor] = useState(() => Color(value ?? "#000000ff"));
|
|
35
33
|
const [currentHue, setCurrentHue] = useState(initialColor.hue());
|
|
36
34
|
const [currentAlpha, setCurrentAlpha] = useState(initialColor.alpha());
|
|
37
|
-
const [innerOpen, setInnerOpen] =
|
|
38
|
-
const currentOpen = panelOnly ||
|
|
39
|
-
const
|
|
40
|
-
left: 0,
|
|
41
|
-
top: 0,
|
|
42
|
-
origin: "bottom"
|
|
43
|
-
});
|
|
44
|
-
const [currentPlacement, setCurrentPlacement] = useState(placement);
|
|
35
|
+
const [innerOpen, setInnerOpen] = useValue(openProp, (next_0) => next_0 ?? false);
|
|
36
|
+
const currentOpen = panelOnly || innerOpen;
|
|
37
|
+
const popup = useRef(null);
|
|
45
38
|
const triggerRef = useRef(null);
|
|
46
39
|
const popoverRef = useRef(null);
|
|
47
|
-
const placementRef = useRef(placement);
|
|
48
|
-
const transOriginRef = useRef("bottom");
|
|
49
|
-
const topRef = useRef(0);
|
|
50
|
-
const leftRef = useRef(0);
|
|
51
|
-
const hideTimerRef = useRef(null);
|
|
52
40
|
const currentValue = innerColor;
|
|
53
41
|
const [syncedValue, setSyncedValue] = useState(currentValue);
|
|
54
42
|
if (syncedValue !== currentValue) {
|
|
55
|
-
const
|
|
43
|
+
const next_1 = Color(currentValue);
|
|
56
44
|
setSyncedValue(currentValue);
|
|
57
|
-
setCurrentAlpha(
|
|
58
|
-
if (
|
|
45
|
+
setCurrentAlpha(next_1.alpha());
|
|
46
|
+
if (next_1.saturationv() > 0) setCurrentHue(next_1.hue());
|
|
59
47
|
}
|
|
60
48
|
const color = Color(currentValue);
|
|
61
|
-
const format = (
|
|
62
|
-
const update = (
|
|
63
|
-
if (readOnly) return;
|
|
64
|
-
const formatted = format(
|
|
49
|
+
const format = (next_2, targetMode = mode) => targetMode === "hex" ? next_2.alpha() < 1 ? next_2.hexa() : next_2.hex() : targetMode === "rgb" ? next_2.rgb().string(0) : next_2.hsl().string(0);
|
|
50
|
+
const update = (next_3, targetMode_0 = mode) => {
|
|
51
|
+
if (disabled || readOnly) return;
|
|
52
|
+
const formatted = format(next_3, targetMode_0);
|
|
65
53
|
setInnerColor(formatted);
|
|
66
54
|
onChange?.(formatted);
|
|
67
55
|
};
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
refSelection: triggerRef,
|
|
73
|
-
refPopper: popoverRef,
|
|
74
|
-
currentPlacement: placementRef,
|
|
75
|
-
transOrigin: transOriginRef,
|
|
76
|
-
top: topRef,
|
|
77
|
-
left: leftRef
|
|
78
|
-
});
|
|
79
|
-
setCurrentPlacement(placementRef.current);
|
|
80
|
-
setPosition({
|
|
81
|
-
left: leftRef.current,
|
|
82
|
-
top: topRef.current,
|
|
83
|
-
origin: transOriginRef.current
|
|
84
|
-
});
|
|
85
|
-
}, [placement]);
|
|
86
|
-
const setVisible = useCallback((next_3) => {
|
|
87
|
-
if (disabled || readOnly || panelOnly) return;
|
|
88
|
-
if (openProp === void 0) setInnerOpen(next_3);
|
|
89
|
-
onOpenChange?.(next_3);
|
|
90
|
-
if (next_3) requestAnimationFrame(updatePosition);
|
|
56
|
+
const setVisible = useCallback((next_4) => {
|
|
57
|
+
if (next_4 && (disabled || readOnly) || panelOnly) return;
|
|
58
|
+
setInnerOpen(next_4);
|
|
59
|
+
onOpenChange?.(next_4);
|
|
91
60
|
}, [
|
|
92
61
|
disabled,
|
|
93
62
|
onOpenChange,
|
|
94
|
-
|
|
95
|
-
panelOnly,
|
|
96
|
-
readOnly,
|
|
97
|
-
updatePosition
|
|
98
|
-
]);
|
|
99
|
-
useEffect(() => () => {
|
|
100
|
-
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
101
|
-
}, []);
|
|
102
|
-
const updatePositionRef = useRef(updatePosition);
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
updatePositionRef.current = updatePosition;
|
|
105
|
-
});
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
if (!currentOpen || panelOnly) return;
|
|
108
|
-
const outside = (event) => {
|
|
109
|
-
if (!popoverRef.current?.contains(event.target) && !triggerRef.current?.contains(event.target)) setVisible(false);
|
|
110
|
-
};
|
|
111
|
-
const handleResize = () => updatePositionRef.current();
|
|
112
|
-
const handleScroll = () => updatePositionRef.current();
|
|
113
|
-
document.addEventListener("mousedown", outside);
|
|
114
|
-
window.addEventListener("resize", handleResize);
|
|
115
|
-
window.addEventListener("scroll", handleScroll, true);
|
|
116
|
-
return () => {
|
|
117
|
-
document.removeEventListener("mousedown", outside);
|
|
118
|
-
window.removeEventListener("resize", handleResize);
|
|
119
|
-
window.removeEventListener("scroll", handleScroll, true);
|
|
120
|
-
};
|
|
121
|
-
}, [
|
|
122
|
-
currentOpen,
|
|
63
|
+
setInnerOpen,
|
|
123
64
|
panelOnly,
|
|
124
|
-
|
|
65
|
+
readOnly
|
|
125
66
|
]);
|
|
126
67
|
const mouseEnter = () => {
|
|
127
|
-
|
|
68
|
+
popup.current?.cancelClose();
|
|
128
69
|
setVisible(true);
|
|
129
70
|
};
|
|
130
|
-
const mouseLeave = () =>
|
|
131
|
-
hideTimerRef.current = setTimeout(() => setVisible(false), 300);
|
|
132
|
-
};
|
|
71
|
+
const mouseLeave = () => popup.current?.scheduleClose();
|
|
133
72
|
const hoverProps = trigger === "hover" ? {
|
|
134
73
|
onMouseEnter: mouseEnter,
|
|
135
74
|
onMouseLeave: mouseLeave
|
|
136
75
|
} : { onClick: () => setVisible(!currentOpen) };
|
|
137
|
-
const onTriggerKeyDown = (
|
|
138
|
-
rest.onKeyDown?.(
|
|
139
|
-
if (
|
|
140
|
-
if (
|
|
141
|
-
|
|
76
|
+
const onTriggerKeyDown = (event) => {
|
|
77
|
+
rest.onKeyDown?.(event);
|
|
78
|
+
if (event.defaultPrevented || disabled || readOnly) return;
|
|
79
|
+
if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown") {
|
|
80
|
+
event.preventDefault();
|
|
142
81
|
setVisible(true);
|
|
143
|
-
} else if (
|
|
144
|
-
|
|
82
|
+
} else if (event.key === "Escape" && currentOpen) {
|
|
83
|
+
event.preventDefault();
|
|
145
84
|
setVisible(false);
|
|
146
85
|
}
|
|
147
86
|
};
|
|
@@ -156,8 +95,8 @@ function ColorPicker({ value, open: openProp, defaultOpen = false, disabled = fa
|
|
|
156
95
|
"aria-disabled": disabled || void 0,
|
|
157
96
|
"aria-readonly": readOnly || void 0,
|
|
158
97
|
onKeyDown: onTriggerKeyDown,
|
|
159
|
-
onClick: (
|
|
160
|
-
if (trigger === "click" && !
|
|
98
|
+
onClick: (event_0) => {
|
|
99
|
+
if (trigger === "click" && !event_0.defaultPrevented) setVisible(!currentOpen);
|
|
161
100
|
},
|
|
162
101
|
onMouseEnter: () => {
|
|
163
102
|
if (trigger === "hover") mouseEnter();
|
|
@@ -200,26 +139,31 @@ function ColorPicker({ value, open: openProp, defaultOpen = false, disabled = fa
|
|
|
200
139
|
})]
|
|
201
140
|
})
|
|
202
141
|
});
|
|
142
|
+
const blockPanelInteraction = (event_1) => {
|
|
143
|
+
if (disabled || readOnly) {
|
|
144
|
+
event_1.preventDefault();
|
|
145
|
+
event_1.stopPropagation();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
203
148
|
const dropdownContent = /* @__PURE__ */ jsxs("div", {
|
|
204
149
|
ref: popoverRef,
|
|
205
|
-
"
|
|
150
|
+
"aria-disabled": disabled || void 0,
|
|
151
|
+
onClickCapture: blockPanelInteraction,
|
|
152
|
+
onMouseDownCapture: blockPanelInteraction,
|
|
153
|
+
onKeyDownCapture: blockPanelInteraction,
|
|
154
|
+
"k-placement": placement,
|
|
206
155
|
className: clsx("k-color-picker-dropdown", {
|
|
207
156
|
"k-color-picker-disabled-alpha": disabledAlpha,
|
|
208
157
|
"k-color-picker-panel": panelOnly
|
|
209
158
|
}),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
top: position.top,
|
|
213
|
-
transformOrigin: position.origin
|
|
214
|
-
},
|
|
215
|
-
onMouseEnter: () => hideTimerRef.current && clearTimeout(hideTimerRef.current),
|
|
216
|
-
onMouseLeave: trigger === "hover" ? () => {
|
|
217
|
-
hideTimerRef.current = setTimeout(() => setVisible(false), 300);
|
|
218
|
-
} : void 0,
|
|
159
|
+
onMouseEnter: () => popup.current?.cancelClose(),
|
|
160
|
+
onMouseLeave: trigger === "hover" ? mouseLeave : void 0,
|
|
219
161
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
220
162
|
className: "k-color-picker-body",
|
|
163
|
+
inert: disabled || readOnly,
|
|
221
164
|
children: [
|
|
222
165
|
/* @__PURE__ */ jsx(Paint, {
|
|
166
|
+
disabled: disabled || readOnly,
|
|
223
167
|
hue: currentHue,
|
|
224
168
|
value: color,
|
|
225
169
|
onUpdateRGB: (rgb) => update(Color({
|
|
@@ -238,16 +182,18 @@ function ColorPicker({ value, open: openProp, defaultOpen = false, disabled = fa
|
|
|
238
182
|
}), /* @__PURE__ */ jsxs("div", {
|
|
239
183
|
className: "k-color-picker-bar-box",
|
|
240
184
|
children: [/* @__PURE__ */ jsx(Hue, {
|
|
185
|
+
disabled: disabled || readOnly,
|
|
241
186
|
hue: currentHue,
|
|
242
187
|
onUpdateHue: (hue) => {
|
|
243
|
-
if (readOnly) return;
|
|
188
|
+
if (disabled || readOnly) return;
|
|
244
189
|
setCurrentHue(hue);
|
|
245
190
|
update(color.hue(hue).rgb());
|
|
246
191
|
}
|
|
247
192
|
}), !disabledAlpha && /* @__PURE__ */ jsx(Alpha, {
|
|
193
|
+
disabled: disabled || readOnly,
|
|
248
194
|
value: color,
|
|
249
195
|
onUpdateAlpha: (alpha) => {
|
|
250
|
-
if (readOnly) return;
|
|
196
|
+
if (disabled || readOnly) return;
|
|
251
197
|
setCurrentAlpha(alpha);
|
|
252
198
|
update(color.alpha(alpha).rgb());
|
|
253
199
|
}
|
|
@@ -258,27 +204,27 @@ function ColorPicker({ value, open: openProp, defaultOpen = false, disabled = fa
|
|
|
258
204
|
mode,
|
|
259
205
|
value: color,
|
|
260
206
|
disabledAlpha,
|
|
261
|
-
onUpdateMode: (
|
|
262
|
-
if (readOnly) return;
|
|
263
|
-
if (modeProp === void 0) setInnerMode(
|
|
264
|
-
onUpdateMode?.(
|
|
265
|
-
update(color,
|
|
207
|
+
onUpdateMode: (next_5) => {
|
|
208
|
+
if (disabled || readOnly) return;
|
|
209
|
+
if (modeProp === void 0) setInnerMode(next_5);
|
|
210
|
+
onUpdateMode?.(next_5);
|
|
211
|
+
update(color, next_5);
|
|
266
212
|
},
|
|
267
|
-
onUpdateColorValue: (
|
|
268
|
-
if (readOnly) return;
|
|
269
|
-
setCurrentAlpha(
|
|
270
|
-
if (
|
|
271
|
-
update(
|
|
213
|
+
onUpdateColorValue: (next_6) => {
|
|
214
|
+
if (disabled || readOnly) return;
|
|
215
|
+
setCurrentAlpha(next_6.alpha());
|
|
216
|
+
if (next_6.saturationv() > 0) setCurrentHue(next_6.hue());
|
|
217
|
+
update(next_6);
|
|
272
218
|
}
|
|
273
219
|
}),
|
|
274
220
|
/* @__PURE__ */ jsx(Presets, {
|
|
275
221
|
presets,
|
|
276
222
|
color,
|
|
277
|
-
onUpdateColor: (
|
|
278
|
-
if (readOnly) return;
|
|
279
|
-
setCurrentAlpha(
|
|
280
|
-
setCurrentHue(
|
|
281
|
-
update(
|
|
223
|
+
onUpdateColor: (next_7) => {
|
|
224
|
+
if (disabled || readOnly) return;
|
|
225
|
+
setCurrentAlpha(next_7.alpha());
|
|
226
|
+
setCurrentHue(next_7.hue());
|
|
227
|
+
update(next_7.rgb());
|
|
282
228
|
}
|
|
283
229
|
})
|
|
284
230
|
]
|
|
@@ -298,15 +244,20 @@ function ColorPicker({ value, open: openProp, defaultOpen = false, disabled = fa
|
|
|
298
244
|
})
|
|
299
245
|
})]
|
|
300
246
|
});
|
|
301
|
-
const dropdown = panelOnly ? dropdownContent : /* @__PURE__ */ jsx(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
247
|
+
const dropdown = panelOnly ? dropdownContent : /* @__PURE__ */ jsx(Popup, {
|
|
248
|
+
ref: popup,
|
|
249
|
+
raw: true,
|
|
250
|
+
open: currentOpen,
|
|
251
|
+
target: triggerRef,
|
|
252
|
+
trigger: "manual",
|
|
253
|
+
placement,
|
|
254
|
+
prefixCls: "k-color-picker-dropdown",
|
|
255
|
+
transitionName: "k-color-picker",
|
|
256
|
+
transitionDuration: 200,
|
|
257
|
+
destroyOnClose: true,
|
|
258
|
+
outsideEvent: "mousedown",
|
|
259
|
+
onOpenChange: setVisible,
|
|
260
|
+
overlay: dropdownContent
|
|
310
261
|
});
|
|
311
262
|
if (panelOnly) return dropdown;
|
|
312
263
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [triggerNode, dropdown] });
|