@choice-ui/react 1.7.6 → 1.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/colors/dist/index.d.ts +878 -0
- package/dist/components/colors/scripts/build-worker.d.ts +1 -0
- package/dist/components/colors/src/check-color-contrast/check-color-contrast-boundary.d.ts +14 -0
- package/dist/components/colors/src/check-color-contrast/check-color-contrast-boundary.js +403 -0
- package/dist/components/colors/src/check-color-contrast/check-color-contrast-toolbar.d.ts +12 -0
- package/dist/components/colors/src/check-color-contrast/check-color-contrast-toolbar.js +285 -0
- package/dist/components/colors/src/check-color-contrast/index.d.ts +2 -0
- package/dist/components/colors/src/color-area/color-area.d.ts +24 -0
- package/dist/components/colors/src/color-area/color-area.js +228 -0
- package/dist/components/colors/src/color-area/index.d.ts +1 -0
- package/dist/components/colors/src/color-area/tv.d.ts +34 -0
- package/dist/components/colors/src/color-area/tv.js +22 -0
- package/dist/components/colors/src/color-channel-field/color-channel-field.d.ts +22 -0
- package/dist/components/colors/src/color-channel-field/color-channel-field.js +110 -0
- package/dist/components/colors/src/color-channel-field/color-channel-input.d.ts +20 -0
- package/dist/components/colors/src/color-channel-field/color-channel-input.js +261 -0
- package/dist/components/colors/src/color-channel-field/index.d.ts +1 -0
- package/dist/components/colors/src/color-channel-field/tv.d.ts +101 -0
- package/dist/components/colors/src/color-channel-field/tv.js +85 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-combined.d.ts +16 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-combined.js +54 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-control.d.ts +18 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-control.js +149 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-list.d.ts +20 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-list.js +111 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-slider.d.ts +18 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradient-slider.js +281 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradients-paint.d.ts +17 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradients-paint.js +162 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradients-toolbar.d.ts +10 -0
- package/dist/components/colors/src/color-gradients-paint/color-gradients-toolbar.js +62 -0
- package/dist/components/colors/src/color-gradients-paint/index.d.ts +3 -0
- package/dist/components/colors/src/color-image-paint/color-image-paint.d.ts +13 -0
- package/dist/components/colors/src/color-image-paint/color-image-paint.js +236 -0
- package/dist/components/colors/src/color-image-paint/color-image-toolbar.d.ts +9 -0
- package/dist/components/colors/src/color-image-paint/color-image-toolbar.js +52 -0
- package/dist/components/colors/src/color-image-paint/index.d.ts +1 -0
- package/dist/components/colors/src/color-image-paint/tv.d.ts +89 -0
- package/dist/components/colors/src/color-image-paint/tv.js +45 -0
- package/dist/components/colors/src/color-picker-content/color-picker-content.d.ts +18 -0
- package/dist/components/colors/src/color-picker-content/color-picker-content.js +58 -0
- package/dist/components/colors/src/color-picker-content/color-picker-custom-content.d.ts +16 -0
- package/dist/components/colors/src/color-picker-content/color-picker-custom-content.js +75 -0
- package/dist/components/colors/src/color-picker-content/index.d.ts +1 -0
- package/dist/components/colors/src/color-picker-content/paint-type-selector.d.ts +13 -0
- package/dist/components/colors/src/color-picker-content/paint-type-selector.js +50 -0
- package/dist/components/colors/src/color-picker-content/tv.d.ts +31 -0
- package/dist/components/colors/src/color-picker-content/tv.js +13 -0
- package/dist/components/colors/src/color-picker-popover/color-paints-type.d.ts +15 -0
- package/dist/components/colors/src/color-picker-popover/color-paints-type.js +56 -0
- package/dist/components/colors/src/color-picker-popover/color-picker-popover.d.ts +26 -0
- package/dist/components/colors/src/color-picker-popover/color-picker-popover.js +116 -0
- package/dist/components/colors/src/color-picker-popover/color-picker-tabs.d.ts +14 -0
- package/dist/components/colors/src/color-picker-popover/color-picker-tabs.js +47 -0
- package/dist/components/colors/src/color-picker-popover/color-picker-title.d.ts +14 -0
- package/dist/components/colors/src/color-picker-popover/color-picker-title.js +30 -0
- package/dist/components/colors/src/color-picker-popover/index.d.ts +3 -0
- package/dist/components/colors/src/color-picker-popover/tv.d.ts +37 -0
- package/dist/components/colors/src/color-slider/color-slider.d.ts +19 -0
- package/dist/components/colors/src/color-slider/color-slider.js +185 -0
- package/dist/components/colors/src/color-slider/index.d.ts +1 -0
- package/dist/components/colors/src/color-slider/tv.d.ts +31 -0
- package/dist/components/colors/src/color-slider/tv.js +21 -0
- package/dist/components/colors/src/color-solid-paint/color-native-picker.d.ts +8 -0
- package/dist/components/colors/src/color-solid-paint/color-native-picker.js +63 -0
- package/dist/components/colors/src/color-solid-paint/color-solid-paint.d.ts +25 -0
- package/dist/components/colors/src/color-solid-paint/color-solid-paint.js +295 -0
- package/dist/components/colors/src/color-solid-paint/index.d.ts +3 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-alpha-slider.d.ts +10 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-alpha-slider.js +20 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-area.d.ts +17 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-area.js +131 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-channel-field.d.ts +20 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-channel-field.js +147 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-hue-slider.d.ts +14 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-hue-slider.js +46 -0
- package/dist/components/colors/src/color-solid-paint/solid-paint-library-item.d.ts +8 -0
- package/dist/components/colors/src/color-solid-paint/tv.d.ts +79 -0
- package/dist/components/colors/src/color-solid-paint/tv.js +39 -0
- package/dist/components/colors/src/color-swatch/color-swatch.d.ts +15 -0
- package/dist/components/colors/src/color-swatch/color-swatch.js +111 -0
- package/dist/components/colors/src/color-swatch/index.d.ts +1 -0
- package/dist/components/colors/src/contents/color-space.d.ts +19 -0
- package/dist/components/colors/src/contents/color-space.js +16 -0
- package/dist/components/colors/src/contents/colors.d.ts +42 -0
- package/dist/components/colors/src/contents/colors.js +24 -0
- package/dist/components/colors/src/contents/index.d.ts +3 -0
- package/dist/components/colors/src/contents/translation.d.ts +100 -0
- package/dist/components/colors/src/contents/translation.js +94 -0
- package/dist/components/colors/src/context/colots-context.d.ts +24 -0
- package/dist/components/colors/src/context/colots-context.js +62 -0
- package/dist/components/colors/src/context/index.d.ts +1 -0
- package/dist/components/colors/src/fill-input/alpha-input.d.ts +12 -0
- package/dist/components/colors/src/fill-input/alpha-input.js +48 -0
- package/dist/components/colors/src/fill-input/color-input.d.ts +31 -0
- package/dist/components/colors/src/fill-input/color-input.js +115 -0
- package/dist/components/colors/src/fill-input/gradient-item.d.ts +25 -0
- package/dist/components/colors/src/fill-input/gradient-item.js +103 -0
- package/dist/components/colors/src/fill-input/image-item.d.ts +25 -0
- package/dist/components/colors/src/fill-input/image-item.js +89 -0
- package/dist/components/colors/src/fill-input/index.d.ts +5 -0
- package/dist/components/colors/src/fill-input/tv.d.ts +221 -0
- package/dist/components/colors/src/fill-input/tv.js +205 -0
- package/dist/components/colors/src/fill-input/variable-item.d.ts +22 -0
- package/dist/components/colors/src/fill-input/variable-item.js +105 -0
- package/dist/components/colors/src/hex-input/hex-input.d.ts +10 -0
- package/dist/components/colors/src/hex-input/hex-input.js +182 -0
- package/dist/components/colors/src/hex-input/index.d.ts +1 -0
- package/dist/components/colors/src/hex-input/tv.d.ts +1 -0
- package/dist/components/colors/src/hex-input/tv.js +12 -0
- package/dist/components/colors/src/hooks/index.d.ts +10 -0
- package/dist/components/colors/src/hooks/use-color-contrast-recommendation.d.ts +36 -0
- package/dist/components/colors/src/hooks/use-color-contrast-recommendation.js +502 -0
- package/dist/components/colors/src/hooks/use-color-parser.d.ts +10 -0
- package/dist/components/colors/src/hooks/use-color-parser.js +146 -0
- package/dist/components/colors/src/hooks/use-color-picker.d.ts +45 -0
- package/dist/components/colors/src/hooks/use-color-picker.js +117 -0
- package/dist/components/colors/src/hooks/use-color-profile.d.ts +2 -0
- package/dist/components/colors/src/hooks/use-color-profile.js +27 -0
- package/dist/components/colors/src/hooks/use-cursor.d.ts +1 -0
- package/dist/components/colors/src/hooks/use-cursor.js +25 -0
- package/dist/components/colors/src/hooks/use-features.d.ts +21 -0
- package/dist/components/colors/src/hooks/use-features.js +73 -0
- package/dist/components/colors/src/hooks/use-image-filter-style.d.ts +9 -0
- package/dist/components/colors/src/hooks/use-image-filter-style.js +25 -0
- package/dist/components/colors/src/hooks/use-image-processor.d.ts +10 -0
- package/dist/components/colors/src/hooks/use-image-processor.js +121 -0
- package/dist/components/colors/src/hooks/use-paint-state.d.ts +16 -0
- package/dist/components/colors/src/hooks/use-paint-state.js +37 -0
- package/dist/components/colors/src/hooks/use-rgb-color-handler.d.ts +21 -0
- package/dist/components/colors/src/hooks/use-rgb-color-handler.js +58 -0
- package/dist/components/colors/src/index.d.ts +38 -0
- package/dist/components/colors/src/libraries/components/virtualized-grid-row.d.ts +36 -0
- package/dist/components/colors/src/libraries/components/virtualized-grid-row.js +53 -0
- package/dist/components/colors/src/libraries/components/virtualized-header.d.ts +9 -0
- package/dist/components/colors/src/libraries/components/virtualized-header.js +30 -0
- package/dist/components/colors/src/libraries/hooks/index.d.ts +2 -0
- package/dist/components/colors/src/libraries/hooks/use-category-options.d.ts +11 -0
- package/dist/components/colors/src/libraries/hooks/use-category-options.js +27 -0
- package/dist/components/colors/src/libraries/hooks/use-palette-color.d.ts +19 -0
- package/dist/components/colors/src/libraries/hooks/use-palette-color.js +41 -0
- package/dist/components/colors/src/libraries/index.d.ts +8 -0
- package/dist/components/colors/src/libraries/libraries-content.d.ts +8 -0
- package/dist/components/colors/src/libraries/libraries-empty-content.d.ts +5 -0
- package/dist/components/colors/src/libraries/libraries-header.d.ts +18 -0
- package/dist/components/colors/src/libraries/libraries-header.js +111 -0
- package/dist/components/colors/src/libraries/libraries-search-empty-content.d.ts +1 -0
- package/dist/components/colors/src/libraries/libraries-search-input.d.ts +6 -0
- package/dist/components/colors/src/libraries/libraries.d.ts +42 -0
- package/dist/components/colors/src/libraries/libraries.js +461 -0
- package/dist/components/colors/src/libraries/library-color-swatch.d.ts +21 -0
- package/dist/components/colors/src/libraries/library-item/index.d.ts +4 -0
- package/dist/components/colors/src/libraries/library-item/library-item.d.ts +21 -0
- package/dist/components/colors/src/libraries/library-item/library-item.js +151 -0
- package/dist/components/colors/src/libraries/library-item/library-list-item.d.ts +6 -0
- package/dist/components/colors/src/libraries/library-item/style-items.d.ts +17 -0
- package/dist/components/colors/src/libraries/library-item/style-items.js +63 -0
- package/dist/components/colors/src/libraries/library-item/variable-items.d.ts +19 -0
- package/dist/components/colors/src/libraries/library-item/variable-items.js +47 -0
- package/dist/components/colors/src/libraries/tv.d.ts +198 -0
- package/dist/components/colors/src/libraries/tv.js +141 -0
- package/dist/components/colors/src/simple-color-picker/index.d.ts +1 -0
- package/dist/components/colors/src/simple-color-picker/simple-color-picker.d.ts +17 -0
- package/dist/components/colors/src/simple-color-picker/simple-color-picker.js +153 -0
- package/dist/components/colors/src/types/base.d.ts +5 -0
- package/dist/components/colors/src/types/colors.d.ts +139 -0
- package/dist/components/colors/src/types/effect.d.ts +18 -0
- package/dist/components/colors/src/types/fill.d.ts +15 -0
- package/dist/components/colors/src/types/fonts.d.ts +38 -0
- package/dist/components/colors/src/types/index.d.ts +7 -0
- package/dist/components/colors/src/types/libraries.d.ts +7 -0
- package/dist/components/colors/src/types/paint.d.ts +139 -0
- package/dist/components/colors/src/types/style.d.ts +51 -0
- package/dist/components/colors/src/types/testing-library.d.ts +0 -0
- package/dist/components/colors/src/types/util.d.ts +26 -0
- package/dist/components/colors/src/types/variable.d.ts +27 -0
- package/dist/components/colors/src/utils/background.d.ts +12 -0
- package/dist/components/colors/src/utils/background.js +216 -0
- package/dist/components/colors/src/utils/color-profile-storage.d.ts +29 -0
- package/dist/components/colors/src/utils/color.d.ts +20 -0
- package/dist/components/colors/src/utils/color.js +45 -0
- package/dist/components/colors/src/utils/colors-convert.d.ts +18 -0
- package/dist/components/colors/src/utils/colors-convert.js +138 -0
- package/dist/components/colors/src/utils/contrast-utils.d.ts +27 -0
- package/dist/components/colors/src/utils/contrast-utils.js +25 -0
- package/dist/components/colors/src/utils/cursor.d.ts +1 -0
- package/dist/components/colors/src/utils/index.d.ts +7 -0
- package/dist/components/colors/src/utils/math.d.ts +9 -0
- package/dist/components/colors/src/utils/position.d.ts +33 -0
- package/dist/components/colors/src/utils/position.js +60 -0
- package/dist/components/colors/src/utils/validate.d.ts +10 -0
- package/dist/components/colors/src/workers/boundary-calculator.worker.bundled.d.ts +2 -0
- package/dist/components/colors/src/workers/boundary-calculator.worker.bundled.js +36 -0
- package/dist/components/colors/src/workers/boundary-calculator.worker.d.ts +1 -0
- package/dist/components/colors/src/workers/index.d.ts +1 -0
- package/dist/components/colors/tsup.config.d.ts +2 -0
- package/dist/components/icon-button/src/icon-button.d.ts +1 -1
- package/dist/components/icon-button/src/tv.d.ts +9 -0
- package/dist/components/icon-button/src/tv.js +29 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/textarea/src/tv.d.ts +9 -3
- package/dist/components/textarea/src/tv.js +3 -1
- package/dist/components/toggle-button/dist/index.js +602 -0
- package/dist/index.js +69 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/index.js +119 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/Color.js +42 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/chroma.js +9 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/colors/colorbrewer.js +57 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/colors/w3cx11.js +159 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/generator/average.js +82 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/generator/bezier.js +68 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/generator/blend.js +43 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/generator/cubehelix.js +81 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/generator/mix.js +20 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/generator/random.js +13 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/generator/scale.js +325 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/_hsx.js +54 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/hcg.js +10 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/hsi.js +10 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/hsl.js +10 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/hsv.js +10 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/index.js +4 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/lab.js +17 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/lch.js +11 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/lrgb.js +17 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/num.js +12 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/oklab.js +17 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/oklch.js +10 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/interpolator/rgb.js +16 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/cmyk/cmyk2rgb.js +20 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/cmyk/index.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/cmyk/rgb2cmyk.js +18 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/css2rgb.js +169 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/hsl2css.js +20 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/index.js +23 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/lab2css.js +19 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/lch2css.js +19 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/oklab2css.js +17 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/oklch2css.js +17 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/css/rgb2css.js +53 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/gl/index.js +21 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hcg/hcg2rgb.js +48 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hcg/index.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hcg/rgb2hcg.js +24 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hex/hex2rgb.js +37 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hex/index.js +23 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hex/rgb2hex.js +31 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsi/hsi2rgb.js +36 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsi/index.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsi/rgb2hsi.js +28 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsl/hsl2rgb.js +35 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsl/index.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsl/rgb2hsl.js +29 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsv/hsv2rgb.js +46 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsv/index.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/hsv/rgb2hsv.js +27 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/input.js +7 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lab/index.js +28 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lab/lab-constants.js +106 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lab/lab2rgb.js +59 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lab/rgb2lab.js +51 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lch/hcl2rgb.js +10 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lch/index.js +35 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lch/lab2lch.js +13 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lch/lch2lab.js +12 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lch/lch2rgb.js +14 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/lch/rgb2lch.js +13 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/named/index.js +26 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/num/index.js +23 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/num/num2rgb.js +13 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/num/rgb2num.js +9 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/oklab/index.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/oklab/oklab2rgb.js +31 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/oklab/rgb2oklab.js +30 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/oklch/index.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/oklch/oklch2rgb.js +14 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/oklch/rgb2oklch.js +13 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/rgb/index.js +34 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/temp/index.js +16 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/temp/rgb2temperature.js +25 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/io/temp/temperature2rgb.js +18 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/alpha.js +12 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/clipped.js +4 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/darken.js +14 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/get.js +12 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/luminance.js +38 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/mix.js +5 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/premultiply.js +11 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/saturate.js +13 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/set.js +42 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/ops/shade.js +9 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/analyze.js +161 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/clip_rgb.js +17 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/contrast.js +12 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/contrastAPCA.js +43 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/delta-e.js +48 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/distance.js +16 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/index.js +24 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/last.js +10 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/limit.js +7 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/multiply-matrices.js +29 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/scales.js +16 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/type.js +20 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/unpack.js +11 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/utils/valid.js +12 -0
- package/dist/node_modules/.pnpm/chroma-js@3.2.0/node_modules/chroma-js/src/version.js +4 -0
- package/dist/node_modules/.pnpm/fuse.js@7.1.0/node_modules/fuse.js/dist/fuse.js +1317 -0
- package/dist/styles/components.css +55 -0
- package/dist/tailwind.css +1 -0
- package/package.json +32 -20
- package/dist/components/virtual-select/dist/index.d.ts +0 -48
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { nanoid } from "nanoid";
|
|
2
|
+
import { useState, useMemo, useEffect } from "react";
|
|
3
|
+
import { useEventCallback } from "usehooks-ts";
|
|
4
|
+
import { getColorArr } from "../utils/color.js";
|
|
5
|
+
import { DEFAULT_ALPHA, DEFAULT_COLOR, DEFAULT_GRADIENT_TRANSFORM, BLACK } from "../contents/colors.js";
|
|
6
|
+
const useColorPicker = () => {
|
|
7
|
+
const [colorState, setColorState] = useState({
|
|
8
|
+
color: DEFAULT_COLOR,
|
|
9
|
+
alpha: DEFAULT_ALPHA
|
|
10
|
+
});
|
|
11
|
+
const [paintsType, setPaintsType] = useState("SOLID");
|
|
12
|
+
const [librariesState, setLibrariesState] = useState({
|
|
13
|
+
selected: null,
|
|
14
|
+
selectedCategory: "all",
|
|
15
|
+
displayType: "LIST",
|
|
16
|
+
pickerType: "CUSTOM"
|
|
17
|
+
});
|
|
18
|
+
const [gradient, setGradient] = useState({
|
|
19
|
+
gradientStops: [
|
|
20
|
+
{ id: nanoid(), position: 0, color: DEFAULT_COLOR, alpha: 0 },
|
|
21
|
+
{ id: nanoid(), position: 1, color: DEFAULT_COLOR, alpha: 1 }
|
|
22
|
+
],
|
|
23
|
+
type: "GRADIENT_LINEAR",
|
|
24
|
+
gradientTransform: DEFAULT_GRADIENT_TRANSFORM,
|
|
25
|
+
opacity: 1
|
|
26
|
+
});
|
|
27
|
+
const handleColorChange = useEventCallback((color) => {
|
|
28
|
+
setColorState((prev) => ({ ...prev, color }));
|
|
29
|
+
});
|
|
30
|
+
const handleAlphaChange = useEventCallback((alpha) => {
|
|
31
|
+
setColorState((prev) => ({ ...prev, alpha }));
|
|
32
|
+
});
|
|
33
|
+
const handleGradientChange = useEventCallback((gradient2) => {
|
|
34
|
+
setGradient(gradient2);
|
|
35
|
+
});
|
|
36
|
+
const handlePickerTypeChange = useEventCallback((type) => {
|
|
37
|
+
setLibrariesState((prev) => ({ ...prev, pickerType: type }));
|
|
38
|
+
});
|
|
39
|
+
const handlePaintsTypeChange = useEventCallback((type) => {
|
|
40
|
+
setPaintsType(type);
|
|
41
|
+
});
|
|
42
|
+
const handleLibraryChange = useEventCallback(
|
|
43
|
+
(item) => {
|
|
44
|
+
try {
|
|
45
|
+
console.log("item", item);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error("Error handling library change:", error);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
const handleCategoryChange = useEventCallback((category) => {
|
|
52
|
+
setLibrariesState((prev) => ({ ...prev, selectedCategory: category }));
|
|
53
|
+
});
|
|
54
|
+
const handleDisplayTypeChange = useEventCallback((displayType) => {
|
|
55
|
+
setLibrariesState((prev) => ({ ...prev, displayType }));
|
|
56
|
+
});
|
|
57
|
+
const variableColor = useMemo(() => {
|
|
58
|
+
if (!librariesState.selected) {
|
|
59
|
+
return { color: DEFAULT_COLOR, alpha: DEFAULT_ALPHA };
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
let color;
|
|
63
|
+
if (librariesState.selected.type === "VARIABLE") {
|
|
64
|
+
color = librariesState.selected.item.value;
|
|
65
|
+
} else {
|
|
66
|
+
const firstFill = librariesState.selected.item.fills[0];
|
|
67
|
+
if (firstFill.type === "SOLID") {
|
|
68
|
+
color = firstFill.color;
|
|
69
|
+
}
|
|
70
|
+
color = BLACK;
|
|
71
|
+
}
|
|
72
|
+
return getColorArr(color) || { color: DEFAULT_COLOR, alpha: DEFAULT_ALPHA };
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Error computing variable color:", error);
|
|
75
|
+
return { color: DEFAULT_COLOR, alpha: DEFAULT_ALPHA };
|
|
76
|
+
}
|
|
77
|
+
}, [librariesState.selected]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (paintsType !== "SOLID") {
|
|
80
|
+
setLibrariesState((prev) => ({
|
|
81
|
+
...prev,
|
|
82
|
+
selected: null
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
}, [paintsType]);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!librariesState.selected) return;
|
|
88
|
+
const { color, alpha } = colorState;
|
|
89
|
+
const { color: varColor, alpha: varAlpha } = variableColor;
|
|
90
|
+
if (varColor.r !== color.r || varColor.g !== color.g || varColor.b !== color.b || varAlpha !== alpha) {
|
|
91
|
+
setLibrariesState((prev) => ({
|
|
92
|
+
...prev,
|
|
93
|
+
selected: null
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
}, [colorState, variableColor, librariesState.selected]);
|
|
97
|
+
return {
|
|
98
|
+
pickerType: librariesState.pickerType,
|
|
99
|
+
paintsType,
|
|
100
|
+
color: colorState.color,
|
|
101
|
+
alpha: colorState.alpha,
|
|
102
|
+
gradient,
|
|
103
|
+
libraries: librariesState,
|
|
104
|
+
variableColor,
|
|
105
|
+
handleColorChange,
|
|
106
|
+
handleAlphaChange,
|
|
107
|
+
handleGradientChange,
|
|
108
|
+
handlePickerTypeChange,
|
|
109
|
+
handlePaintsTypeChange,
|
|
110
|
+
handleLibraryChange,
|
|
111
|
+
handleCategoryChange,
|
|
112
|
+
handleDisplayTypeChange
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export {
|
|
116
|
+
useColorPicker
|
|
117
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
function useColorProfile() {
|
|
3
|
+
const [colorProfile, setColorProfile] = useState("srgb");
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const checkDisplayP3Support = () => {
|
|
6
|
+
if (!window.CSS || !CSS.supports) return false;
|
|
7
|
+
try {
|
|
8
|
+
if (!CSS.supports("color", "color(display-p3 0 0 0)")) return false;
|
|
9
|
+
const el = document.createElement("div");
|
|
10
|
+
el.style.display = "none";
|
|
11
|
+
document.body.appendChild(el);
|
|
12
|
+
el.style.color = "color(display-p3 1 0 0)";
|
|
13
|
+
const computed = getComputedStyle(el).color;
|
|
14
|
+
document.body.removeChild(el);
|
|
15
|
+
return computed !== "rgb(255, 0, 0)";
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error("Error in checkDisplayP3Support:", error);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
setColorProfile(checkDisplayP3Support() ? "display-p3" : "srgb");
|
|
22
|
+
}, []);
|
|
23
|
+
return colorProfile;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
useColorProfile
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getColorPickerCursor(): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const COLOR_PICKER_SVG = `
|
|
2
|
+
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<g filter="url(#filter0_d_73257_77541)">
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.0263 19.5948L11.2871 25.334C10.9187 25.7024 10.4443 25.9465 9.93033 26.0322L8.62738 26.2493C6.93533 26.5314 5.46839 25.0644 5.7504 23.3724L5.96756 22.0694C6.05322 21.5554 6.29733 21.0811 6.66578 20.7126L12.405 14.9734C11.7005 13.9741 11.7952 12.5834 12.6893 11.6894C13.5833 10.7953 14.9741 10.7005 15.9734 11.4052L18.1893 9.18935C19.4654 7.91321 21.5344 7.9132 22.8106 9.18935C24.0867 10.4655 24.0867 12.5345 22.8106 13.8107L20.5948 16.0265C21.2994 17.0259 21.2046 18.4166 20.3106 19.3107C19.4164 20.2048 18.0256 20.2995 17.0263 19.5948Z" fill="white"/>
|
|
5
|
+
</g>
|
|
6
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.3963 14.6036L13.7926 15L7.37288 21.4198C7.15181 21.6408 7.00534 21.9254 6.95395 22.2338L6.73679 23.5368C6.56758 24.552 7.44775 25.4322 8.46298 25.2629L9.76592 25.0458C10.0743 24.9944 10.3589 24.8479 10.58 24.6269L16.9997 18.2071L17.3962 18.6036C18.0057 19.2131 18.9939 19.2131 19.6034 18.6036C20.2129 17.9941 20.213 17.0059 19.6035 16.3964L19.2071 15.9999L22.1035 13.1036C22.9891 12.2179 22.9891 10.7821 22.1035 9.89645C21.2179 9.01083 19.782 9.01084 18.8964 9.89646L16 12.7928L15.6035 12.3964C14.994 11.7869 14.0058 11.787 13.3964 12.3965C12.7869 13.0059 12.7869 13.9941 13.3963 14.6036ZM14.4997 15.7071L16.2926 17.5L9.87288 23.9198C9.79919 23.9934 9.70432 24.0423 9.60152 24.0594L8.29858 24.2766C7.96017 24.333 7.66678 24.0396 7.72318 23.7012L7.94034 22.3982C7.95747 22.2954 8.00629 22.2005 8.07998 22.1269L14.4997 15.7071Z" fill="black"/>
|
|
7
|
+
<defs>
|
|
8
|
+
<filter id="filter0_d_73257_77541" x="2.71545" y="6.23224" width="24.0522" height="24.0521" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
9
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
10
|
+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
|
11
|
+
<feOffset dy="1"/>
|
|
12
|
+
<feGaussianBlur stdDeviation="1.5"/>
|
|
13
|
+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/>
|
|
14
|
+
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_73257_77541"/>
|
|
15
|
+
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_73257_77541" result="shape"/>
|
|
16
|
+
</filter>
|
|
17
|
+
</defs>
|
|
18
|
+
</svg>
|
|
19
|
+
`;
|
|
20
|
+
function getColorPickerCursor() {
|
|
21
|
+
return `data:image/svg+xml;base64,${btoa(COLOR_PICKER_SVG)}`;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
getColorPickerCursor
|
|
25
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChannelFieldFeature, ChannelFieldSpace, PickerFeatures } from '../types/colors';
|
|
2
|
+
import { Paint } from '../types/paint';
|
|
3
|
+
interface UseChannelFieldFeaturesProps {
|
|
4
|
+
colorSpace?: ChannelFieldSpace;
|
|
5
|
+
features: ChannelFieldFeature;
|
|
6
|
+
onAlphaChange?: (alpha: number) => void;
|
|
7
|
+
onChangeColorSpace?: (colorSpace: ChannelFieldSpace) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const useChannelFieldFeatures: (props: UseChannelFieldFeaturesProps) => boolean;
|
|
10
|
+
interface UseColorPickerFeaturesProps {
|
|
11
|
+
features: PickerFeatures;
|
|
12
|
+
onChangePaintsType?: (paintsType: Paint["type"]) => void;
|
|
13
|
+
onChangePickerType?: (pickerType: string) => void;
|
|
14
|
+
paintsType?: Paint["type"];
|
|
15
|
+
pickerType?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const useColorPickerFeatures: (props: UseColorPickerFeaturesProps) => {
|
|
18
|
+
paintsTypeAvailable: boolean;
|
|
19
|
+
pickerTypeAvailable: boolean;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useMemo, useEffect } from "react";
|
|
2
|
+
import { COLOR_SPACES } from "../contents/color-space.js";
|
|
3
|
+
const useChannelFieldFeatures = (props) => {
|
|
4
|
+
const { features, colorSpace, onChangeColorSpace, onAlphaChange } = props;
|
|
5
|
+
const availableSpaces = useMemo(
|
|
6
|
+
() => [
|
|
7
|
+
features.hex && COLOR_SPACES.HEX,
|
|
8
|
+
features.rgb && COLOR_SPACES.RGB,
|
|
9
|
+
features.hsl && COLOR_SPACES.HSL,
|
|
10
|
+
features.hsb && COLOR_SPACES.HSB
|
|
11
|
+
].filter(Boolean),
|
|
12
|
+
[features]
|
|
13
|
+
);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (features.alpha === false) {
|
|
16
|
+
onAlphaChange == null ? void 0 : onAlphaChange(1);
|
|
17
|
+
}
|
|
18
|
+
}, [features.alpha]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const currentSpaceEnabled = features[colorSpace == null ? void 0 : colorSpace.toLowerCase()];
|
|
21
|
+
if (!currentSpaceEnabled && availableSpaces.length > 0) {
|
|
22
|
+
onChangeColorSpace == null ? void 0 : onChangeColorSpace(availableSpaces[0]);
|
|
23
|
+
}
|
|
24
|
+
}, [features]);
|
|
25
|
+
const spacesAvailable = availableSpaces.length > 0;
|
|
26
|
+
return spacesAvailable;
|
|
27
|
+
};
|
|
28
|
+
const useColorPickerFeatures = (props) => {
|
|
29
|
+
const { features, paintsType, onChangePaintsType, pickerType, onChangePickerType } = props;
|
|
30
|
+
const availablePickerType = useMemo(() => {
|
|
31
|
+
const types = [];
|
|
32
|
+
if (features.custom) {
|
|
33
|
+
types.push("CUSTOM");
|
|
34
|
+
}
|
|
35
|
+
return types;
|
|
36
|
+
}, [features]);
|
|
37
|
+
const availablePaintsType = useMemo(() => {
|
|
38
|
+
const types = [];
|
|
39
|
+
if (features.solid) {
|
|
40
|
+
types.push("SOLID");
|
|
41
|
+
}
|
|
42
|
+
if (features.gradient) {
|
|
43
|
+
types.push("GRADIENT_LINEAR", "GRADIENT_RADIAL", "GRADIENT_ANGULAR");
|
|
44
|
+
}
|
|
45
|
+
if (features.image) {
|
|
46
|
+
types.push("IMAGE");
|
|
47
|
+
}
|
|
48
|
+
if (features.pattern) {
|
|
49
|
+
types.push("PATTERN");
|
|
50
|
+
}
|
|
51
|
+
return types;
|
|
52
|
+
}, [features]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!paintsType || !availablePaintsType.length) return;
|
|
55
|
+
const isEnabled = paintsType.startsWith("GRADIENT") ? features.gradient : features[paintsType.toLowerCase()];
|
|
56
|
+
if (!isEnabled) {
|
|
57
|
+
onChangePaintsType == null ? void 0 : onChangePaintsType(availablePaintsType[0]);
|
|
58
|
+
}
|
|
59
|
+
}, [features, paintsType, availablePaintsType, onChangePaintsType]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!pickerType || !availablePickerType.length) return;
|
|
62
|
+
if (pickerType === "CUSTOM" && !features.custom) {
|
|
63
|
+
onChangePickerType == null ? void 0 : onChangePickerType(availablePickerType[0]);
|
|
64
|
+
}
|
|
65
|
+
}, [features, pickerType, availablePickerType, onChangePickerType]);
|
|
66
|
+
const pickerTypeAvailable = availablePickerType.length > 0;
|
|
67
|
+
const paintsTypeAvailable = availablePaintsType.length > 0;
|
|
68
|
+
return { paintsTypeAvailable, pickerTypeAvailable };
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
useChannelFieldFeatures,
|
|
72
|
+
useColorPickerFeatures
|
|
73
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
const useImageFilterStyle = (filters) => {
|
|
3
|
+
return useMemo(() => {
|
|
4
|
+
const mapBrightness = (value) => {
|
|
5
|
+
const val = value ?? 0;
|
|
6
|
+
return val === 0 ? 100 : val < 0 ? 100 - Math.abs(val) * 0.75 : 100 + val * 0.75;
|
|
7
|
+
};
|
|
8
|
+
const mapContrast = (value) => {
|
|
9
|
+
const val = value ?? 0;
|
|
10
|
+
return val === 0 ? 100 : val < 0 ? 100 - Math.abs(val) * 0.5 : 100 + val * 0.5;
|
|
11
|
+
};
|
|
12
|
+
const mapSaturation = (value) => {
|
|
13
|
+
const val = value ?? 0;
|
|
14
|
+
return val === 0 ? 100 : val < 0 ? 100 - Math.abs(val) : 100 + val;
|
|
15
|
+
};
|
|
16
|
+
const mapTemperature = (value) => (value ?? 0) * 0.3;
|
|
17
|
+
const mapTint = (value) => Math.max(0, value ?? 0);
|
|
18
|
+
return {
|
|
19
|
+
filter: `brightness(${mapBrightness(filters == null ? void 0 : filters.exposure)}%) contrast(${mapContrast(filters == null ? void 0 : filters.contrast)}%) saturate(${mapSaturation(filters == null ? void 0 : filters.saturation)}%) hue-rotate(${mapTemperature(filters == null ? void 0 : filters.temperature)}deg) sepia(${mapTint(filters == null ? void 0 : filters.tint)}%)`
|
|
20
|
+
};
|
|
21
|
+
}, [filters]);
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
useImageFilterStyle
|
|
25
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ImageSizes } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 图片处理钩子,用于处理上传的图片并生成多个不同尺寸的版本
|
|
4
|
+
* @returns 图片处理相关函数和状态
|
|
5
|
+
*/
|
|
6
|
+
export declare const useImageProcessor: () => {
|
|
7
|
+
processImage: (file: File) => Promise<ImageSizes>;
|
|
8
|
+
isProcessing: boolean;
|
|
9
|
+
processedUrls: ImageSizes | null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useEventCallback } from "usehooks-ts";
|
|
3
|
+
const useImageProcessor = () => {
|
|
4
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
5
|
+
const [processedUrls, setProcessedUrls] = useState(null);
|
|
6
|
+
const measureImageSize = useEventCallback(
|
|
7
|
+
(imageUrl) => {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const img = new Image();
|
|
10
|
+
img.onload = () => {
|
|
11
|
+
resolve({
|
|
12
|
+
width: img.width,
|
|
13
|
+
height: img.height
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
img.onerror = () => {
|
|
17
|
+
reject(new Error("Failed to load image for measuring size"));
|
|
18
|
+
};
|
|
19
|
+
img.src = imageUrl;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
const resizeImage = useEventCallback(
|
|
24
|
+
async (imageUrl, maxDimension) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const img = new Image();
|
|
27
|
+
img.onload = () => {
|
|
28
|
+
const { width, height } = img;
|
|
29
|
+
const isLandscape = width > height;
|
|
30
|
+
let newWidth, newHeight;
|
|
31
|
+
if (isLandscape) {
|
|
32
|
+
if (width <= maxDimension) {
|
|
33
|
+
resolve(imageUrl);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
newWidth = maxDimension;
|
|
37
|
+
newHeight = Math.round(height * maxDimension / width);
|
|
38
|
+
} else {
|
|
39
|
+
if (height <= maxDimension) {
|
|
40
|
+
resolve(imageUrl);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
newHeight = maxDimension;
|
|
44
|
+
newWidth = Math.round(width * maxDimension / height);
|
|
45
|
+
}
|
|
46
|
+
const canvas = document.createElement("canvas");
|
|
47
|
+
canvas.width = newWidth;
|
|
48
|
+
canvas.height = newHeight;
|
|
49
|
+
const ctx = canvas.getContext("2d");
|
|
50
|
+
if (!ctx) {
|
|
51
|
+
reject(new Error("Failed to create Canvas context"));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
ctx.drawImage(img, 0, 0, newWidth, newHeight);
|
|
55
|
+
const quality = maxDimension <= 64 ? 0.8 : 0.9;
|
|
56
|
+
const dataUrl = canvas.toDataURL("image/jpeg", quality);
|
|
57
|
+
resolve(dataUrl);
|
|
58
|
+
};
|
|
59
|
+
img.onerror = () => {
|
|
60
|
+
reject(new Error("Image loading failed"));
|
|
61
|
+
};
|
|
62
|
+
img.src = imageUrl;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
const readFileAsDataURL = useEventCallback((file) => {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
const reader = new FileReader();
|
|
69
|
+
reader.onload = (event) => {
|
|
70
|
+
var _a;
|
|
71
|
+
if ((_a = event.target) == null ? void 0 : _a.result) {
|
|
72
|
+
resolve(event.target.result);
|
|
73
|
+
} else {
|
|
74
|
+
reject(new Error("File reading failed"));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
reader.onerror = () => {
|
|
78
|
+
reject(new Error("File reading error"));
|
|
79
|
+
};
|
|
80
|
+
reader.readAsDataURL(file);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
const processImage = useEventCallback(async (file) => {
|
|
84
|
+
setIsProcessing(true);
|
|
85
|
+
try {
|
|
86
|
+
const rawImageUrl = await readFileAsDataURL(file);
|
|
87
|
+
const sourceSize = await measureImageSize(rawImageUrl);
|
|
88
|
+
const [thumbUrl, smallUrl, regularUrl] = await Promise.all([
|
|
89
|
+
resizeImage(rawImageUrl, 64),
|
|
90
|
+
// 缩略图 (64px)
|
|
91
|
+
resizeImage(rawImageUrl, 512),
|
|
92
|
+
// 小图 (512px)
|
|
93
|
+
resizeImage(rawImageUrl, 3840)
|
|
94
|
+
// 常规图 (3840px)
|
|
95
|
+
]);
|
|
96
|
+
const urls = {
|
|
97
|
+
thumb: thumbUrl,
|
|
98
|
+
small: smallUrl,
|
|
99
|
+
regular: regularUrl,
|
|
100
|
+
raw: rawImageUrl,
|
|
101
|
+
sourceSize
|
|
102
|
+
// 添加原始尺寸信息
|
|
103
|
+
};
|
|
104
|
+
setProcessedUrls(urls);
|
|
105
|
+
return urls;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error("Image processing failed:", error);
|
|
108
|
+
throw error;
|
|
109
|
+
} finally {
|
|
110
|
+
setIsProcessing(false);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
processImage,
|
|
115
|
+
isProcessing,
|
|
116
|
+
processedUrls
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export {
|
|
120
|
+
useImageProcessor
|
|
121
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PaintState, RGB } from '../types/colors';
|
|
2
|
+
import { ColorUpdateSource } from '../types/paint';
|
|
3
|
+
interface UsePaintStateOptions {
|
|
4
|
+
color: RGB;
|
|
5
|
+
}
|
|
6
|
+
interface UsePaintStateReturn {
|
|
7
|
+
paintState: PaintState;
|
|
8
|
+
setPaintState: (state: PaintState) => void;
|
|
9
|
+
updateSourceRef: React.MutableRefObject<ColorUpdateSource>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 管理颜色的绘制状态,包括 HSL、HSV 等颜色空间的值
|
|
13
|
+
* 当外部颜色变化时,自动同步内部状态
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePaintState(options: UsePaintStateOptions): UsePaintStateReturn;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from "react";
|
|
2
|
+
import tinycolor from "tinycolor2";
|
|
3
|
+
function usePaintState(options) {
|
|
4
|
+
const { color } = options;
|
|
5
|
+
const updateSourceRef = useRef("external");
|
|
6
|
+
const [paintState, setPaintState] = useState({
|
|
7
|
+
h: 0,
|
|
8
|
+
hsl_s: 0,
|
|
9
|
+
l: 0,
|
|
10
|
+
hsv_s: 0,
|
|
11
|
+
v: 0
|
|
12
|
+
});
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (updateSourceRef.current !== "external") return;
|
|
15
|
+
const tc = tinycolor(color);
|
|
16
|
+
const hsl = tc.toHsl();
|
|
17
|
+
const hsv = tc.toHsv();
|
|
18
|
+
setPaintState((prev) => {
|
|
19
|
+
const newHue = Math.abs(hsl.h - prev.h) < 1 ? prev.h : hsl.h;
|
|
20
|
+
return {
|
|
21
|
+
h: newHue,
|
|
22
|
+
hsl_s: hsl.s,
|
|
23
|
+
l: hsl.l,
|
|
24
|
+
hsv_s: hsv.s,
|
|
25
|
+
v: hsv.v
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}, [color]);
|
|
29
|
+
return {
|
|
30
|
+
paintState,
|
|
31
|
+
setPaintState,
|
|
32
|
+
updateSourceRef
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
usePaintState
|
|
37
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChannelFieldSpace, PaintState, RGB } from '../types/colors';
|
|
2
|
+
import { ColorUpdateSource } from '../types/paint';
|
|
3
|
+
interface UseRgbColorHandlerOptions {
|
|
4
|
+
paintState: PaintState;
|
|
5
|
+
setPaintState: (state: PaintState) => void;
|
|
6
|
+
updateSourceRef: React.MutableRefObject<ColorUpdateSource>;
|
|
7
|
+
colorSpace: ChannelFieldSpace;
|
|
8
|
+
onColorChange?: (color: RGB) => void;
|
|
9
|
+
}
|
|
10
|
+
interface UseRgbColorHandlerReturn {
|
|
11
|
+
handleRgbChange: (rgb: RGB) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 处理 RGB 颜色变化的逻辑,包括:
|
|
15
|
+
* - 验证 RGB 值
|
|
16
|
+
* - 根据颜色空间更新绘制状态
|
|
17
|
+
* - 处理灰度和边界值的特殊情况
|
|
18
|
+
* - 触发颜色变化回调
|
|
19
|
+
*/
|
|
20
|
+
export declare function useRgbColorHandler(options: UseRgbColorHandlerOptions): UseRgbColorHandlerReturn;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import tinycolor from "tinycolor2";
|
|
2
|
+
import { useEventCallback } from "usehooks-ts";
|
|
3
|
+
import { isEdgeValue } from "../utils/position.js";
|
|
4
|
+
import { COLOR_SPACES } from "../contents/color-space.js";
|
|
5
|
+
function useRgbColorHandler(options) {
|
|
6
|
+
const { paintState, setPaintState, updateSourceRef, colorSpace, onColorChange } = options;
|
|
7
|
+
const handleRgbChange = useEventCallback((rgb) => {
|
|
8
|
+
if (isNaN(rgb.r) || isNaN(rgb.g) || isNaN(rgb.b)) return;
|
|
9
|
+
const isHsl = colorSpace === COLOR_SPACES.HSL;
|
|
10
|
+
const colorInstance = tinycolor(rgb);
|
|
11
|
+
const hsl = colorInstance.toHsl();
|
|
12
|
+
const hsv = colorInstance.toHsv();
|
|
13
|
+
const prev = { ...paintState };
|
|
14
|
+
const isGrayscale = rgb.r === rgb.g && rgb.g === rgb.b;
|
|
15
|
+
const updates = { ...prev };
|
|
16
|
+
if (isHsl) {
|
|
17
|
+
if (isGrayscale || isEdgeValue(hsl.s)) {
|
|
18
|
+
if (isEdgeValue(hsl.l)) {
|
|
19
|
+
updates.h = prev.h;
|
|
20
|
+
updates.hsl_s = prev.hsl_s;
|
|
21
|
+
updates.l = hsl.l;
|
|
22
|
+
updates.hsv_s = hsv.s;
|
|
23
|
+
updates.v = hsv.v;
|
|
24
|
+
} else {
|
|
25
|
+
updates.h = prev.h;
|
|
26
|
+
updates.hsl_s = hsl.s;
|
|
27
|
+
updates.l = hsl.l;
|
|
28
|
+
updates.hsv_s = hsv.s;
|
|
29
|
+
updates.v = hsv.v;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
updates.h = hsl.h;
|
|
33
|
+
updates.hsl_s = hsl.s;
|
|
34
|
+
updates.l = hsl.l;
|
|
35
|
+
updates.hsv_s = hsv.s;
|
|
36
|
+
updates.v = hsv.v;
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
updates.h = isGrayscale || isEdgeValue(hsv.s) ? prev.h : hsv.h;
|
|
40
|
+
updates.hsv_s = hsv.s;
|
|
41
|
+
updates.v = hsv.v;
|
|
42
|
+
updates.hsl_s = hsl.s;
|
|
43
|
+
updates.l = hsl.l;
|
|
44
|
+
}
|
|
45
|
+
setPaintState(updates);
|
|
46
|
+
updateSourceRef.current = "internal";
|
|
47
|
+
onColorChange == null ? void 0 : onColorChange(rgb);
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
updateSourceRef.current = "external";
|
|
50
|
+
}, 0);
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
handleRgbChange
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
useRgbColorHandler
|
|
58
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { ColorArea } from './color-area';
|
|
2
|
+
export type { ColorAreaProps } from './color-area';
|
|
3
|
+
export { ColorSlider } from './color-slider';
|
|
4
|
+
export type { ColorSliderProps } from './color-slider';
|
|
5
|
+
export { ColorSwatch } from './color-swatch';
|
|
6
|
+
export type { ColorSwatchProps } from './color-swatch';
|
|
7
|
+
export { ColorInput, AlphaInput, GradientItem, ImageItem, VariableItem } from './fill-input';
|
|
8
|
+
export type { ColorInputProps, AlphaInputProps, GradientItemProps, ImageItemProps, VariableItemProps, } from './fill-input';
|
|
9
|
+
export { HexInput } from './hex-input';
|
|
10
|
+
export type { HexInputProps } from './hex-input';
|
|
11
|
+
export { ColorChannelField } from './color-channel-field';
|
|
12
|
+
export type { ColorChannelFieldProps } from './color-channel-field';
|
|
13
|
+
export { ColorSolidPaint, ColorNativePicker } from './color-solid-paint';
|
|
14
|
+
export type { ColorSolidPaintProps } from './color-solid-paint';
|
|
15
|
+
export { ColorPickerPopover } from './color-picker-popover';
|
|
16
|
+
export type { ColorPickerPopoverProps } from './color-picker-popover';
|
|
17
|
+
export { ColorGradientsPaint } from './color-gradients-paint';
|
|
18
|
+
export type { ColorGradientsPaintProps } from './color-gradients-paint';
|
|
19
|
+
export { ColorImagePaint } from './color-image-paint';
|
|
20
|
+
export type { ColorImagePaintProps } from './color-image-paint';
|
|
21
|
+
export { SimpleColorPicker } from './simple-color-picker';
|
|
22
|
+
export { Libraries } from './libraries';
|
|
23
|
+
export type { LibrariesProps } from './libraries';
|
|
24
|
+
export { useColors, ColorsContext, ColorsProvider } from './context/colots-context';
|
|
25
|
+
export type { ColorsProviderProps } from './context/colots-context';
|
|
26
|
+
export { useColorParser, useColorPicker, useImageFilterStyle, useColorProfile } from './hooks';
|
|
27
|
+
export { getContrastThreshold, hsbToRgb, hslToRgb, p3StringToRgbString, p3ToRgb, profileConvertString, rgbaToRgb, rgbToHsb, rgbToHsl, rgbToP3, stringToRgba, } from './utils/colors-convert';
|
|
28
|
+
export { colorToAreaPosition, positionToAreaColor } from './utils/position';
|
|
29
|
+
export type { GradientPaint, ImagePaint, PatternPaint, SolidPaint } from './types/paint';
|
|
30
|
+
export { getGradientString } from './utils/color';
|
|
31
|
+
export type { BezierCurveSegment, BoundaryCalculationResult, BoundaryInfo, ChannelFieldFeature, ChannelFieldSpace, CheckColorContrastCategory, CheckColorContrastLevel, ColorContrast, ColorProfile, ColorStop, HSB, HSBA, HSL, HSLA, HSV, ImagePaintFeature, PaintState, PaletteType, PickerAreaType, PickerFeatures, PickerGradientType, PickerSliderType, PickerType, RecommendedPoint, RGB, RGBA, SolidPaintFeature, Transform, } from './types/colors';
|
|
32
|
+
export type { LibrariesDisplayType, LibrariesFeature, LibrariesType } from './types/libraries';
|
|
33
|
+
export type { ColorChannelLabels, ColorContrastLabels, ColorPickerLabels, ColorUpdateSource, FillItemLabels, GradientControlLabels, GradientFillLabels, GradientLabels, GradientListLabels, GradientPaintType, GradientToolbarLabels, ImageFilters, ImageScaleMode, ImageSizes, Paint, PaintType, PaintTypeLabels, SolidPaintLabels, TextPaint, } from './types/paint';
|
|
34
|
+
export type { BasePaintStyle, BasePendingStyle, BasePendingStyleCommon, BaseStyleCommon, BaseTextStyle, BaseEffectStyle, EffectStyle, PaintStyle, PendingEffectStyle, PendingPaintStyle, PendingTextStyle, Style, StyleId, StyleType, TextStyle, TextStyleKey, TextStyleValue, } from './types/style';
|
|
35
|
+
export type { BaseVariableValue, Property, Variable, VariableControlKey, VariableId, VariableOption, VariableType, VariableValue, } from './types/variable';
|
|
36
|
+
export type { EffectItem, EffectItemType, EffectItemKey, EffectItemValue } from './types/effect';
|
|
37
|
+
export type { SolidFillItem, TextFillItem, GradientFillItem, ImageFillItem, FillItem, FillItemKey, FillItemValue, FillType, } from './types/fill';
|
|
38
|
+
export { COLOR_SPACES, DEFAULT_COLOR, DEFAULT_GRADIENT_TRANSFORM, BLACK_RGBA } from './contents';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LibrariesDisplayType, LibrariesType, RGB, Style, Variable } from '../../types';
|
|
2
|
+
type VirtualizedItem = {
|
|
3
|
+
headerType: "category" | "subcategory";
|
|
4
|
+
isFirst?: boolean;
|
|
5
|
+
title: string;
|
|
6
|
+
type: "header";
|
|
7
|
+
} | {
|
|
8
|
+
index: number;
|
|
9
|
+
item: Variable | Style;
|
|
10
|
+
itemType: "VARIABLE" | "STYLE";
|
|
11
|
+
type: "item";
|
|
12
|
+
};
|
|
13
|
+
interface VirtualizedGridRowProps {
|
|
14
|
+
columns?: number;
|
|
15
|
+
displayType: LibrariesDisplayType;
|
|
16
|
+
duplicateIndex?: number | null;
|
|
17
|
+
offset?: number;
|
|
18
|
+
onLibraryChange?: (value: {
|
|
19
|
+
item: Variable | Style;
|
|
20
|
+
type: LibrariesType;
|
|
21
|
+
}) => void;
|
|
22
|
+
onSwatchChange?: (value: {
|
|
23
|
+
alpha: number;
|
|
24
|
+
color: RGB;
|
|
25
|
+
}) => void;
|
|
26
|
+
padding?: string;
|
|
27
|
+
row: VirtualizedItem[];
|
|
28
|
+
selectedItem?: {
|
|
29
|
+
item: Variable | Style;
|
|
30
|
+
type: LibrariesType;
|
|
31
|
+
} | null;
|
|
32
|
+
size: number;
|
|
33
|
+
start: number;
|
|
34
|
+
}
|
|
35
|
+
export declare const VirtualizedGridRow: import('react').NamedExoticComponent<VirtualizedGridRowProps>;
|
|
36
|
+
export {};
|