@yamada-ui/color-picker 1.4.8-dev-20241105102243 → 1.4.9-dev-20241109080944

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/dist/alpha-slider.d.mts +1 -1
  2. package/dist/alpha-slider.d.ts +1 -1
  3. package/dist/alpha-slider.js +98 -45
  4. package/dist/alpha-slider.js.map +1 -1
  5. package/dist/alpha-slider.mjs +2 -2
  6. package/dist/{chunk-XL5VWGU4.mjs → chunk-FP3X3PED.mjs} +78 -43
  7. package/dist/chunk-FP3X3PED.mjs.map +1 -0
  8. package/dist/{chunk-CZCTI6T2.mjs → chunk-HJMXAALX.mjs} +2 -2
  9. package/dist/{chunk-62A7F566.mjs → chunk-HPP26MVU.mjs} +3 -3
  10. package/dist/{chunk-CAVDEKGO.mjs → chunk-LJHUX2RB.mjs} +2 -2
  11. package/dist/{chunk-APTJWP7T.mjs → chunk-OJVCLBAG.mjs} +2 -2
  12. package/dist/{chunk-F5EYME2W.mjs → chunk-SGAM4TJL.mjs} +26 -7
  13. package/dist/chunk-SGAM4TJL.mjs.map +1 -0
  14. package/dist/chunk-WZEWATJ3.mjs +139 -0
  15. package/dist/chunk-WZEWATJ3.mjs.map +1 -0
  16. package/dist/color-picker.js +170 -80
  17. package/dist/color-picker.js.map +1 -1
  18. package/dist/color-picker.mjs +7 -7
  19. package/dist/color-selector-body.js +170 -80
  20. package/dist/color-selector-body.js.map +1 -1
  21. package/dist/color-selector-body.mjs +5 -5
  22. package/dist/color-selector-sliders.js +170 -80
  23. package/dist/color-selector-sliders.js.map +1 -1
  24. package/dist/color-selector-sliders.mjs +4 -4
  25. package/dist/color-selector.js +170 -80
  26. package/dist/color-selector.js.map +1 -1
  27. package/dist/color-selector.mjs +6 -6
  28. package/dist/hue-slider.d.mts +1 -1
  29. package/dist/hue-slider.d.ts +1 -1
  30. package/dist/hue-slider.js +95 -40
  31. package/dist/hue-slider.js.map +1 -1
  32. package/dist/hue-slider.mjs +2 -2
  33. package/dist/index.js +170 -80
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +7 -7
  36. package/dist/use-color-slider.d.mts +7 -1
  37. package/dist/use-color-slider.d.ts +7 -1
  38. package/dist/use-color-slider.js +25 -5
  39. package/dist/use-color-slider.js.map +1 -1
  40. package/dist/use-color-slider.mjs +3 -1
  41. package/package.json +2 -2
  42. package/dist/chunk-7NWT5PKE.mjs +0 -102
  43. package/dist/chunk-7NWT5PKE.mjs.map +0 -1
  44. package/dist/chunk-F5EYME2W.mjs.map +0 -1
  45. package/dist/chunk-XL5VWGU4.mjs.map +0 -1
  46. /package/dist/{chunk-CZCTI6T2.mjs.map → chunk-HJMXAALX.mjs.map} +0 -0
  47. /package/dist/{chunk-62A7F566.mjs.map → chunk-HPP26MVU.mjs.map} +0 -0
  48. /package/dist/{chunk-CAVDEKGO.mjs.map → chunk-LJHUX2RB.mjs.map} +0 -0
  49. /package/dist/{chunk-APTJWP7T.mjs.map → chunk-OJVCLBAG.mjs.map} +0 -0
@@ -517,6 +517,7 @@ var useColorSlider = ({
517
517
  id,
518
518
  name,
519
519
  style: styleProp,
520
+ channel = "hue",
520
521
  defaultValue,
521
522
  max,
522
523
  min = 0,
@@ -733,6 +734,7 @@ var useColorSlider = ({
733
734
  "aria-valuemax": max,
734
735
  "aria-valuemin": min,
735
736
  "aria-valuenow": value,
737
+ "aria-valuetext": getAriaValueText(channel, value),
736
738
  "data-active": (0, import_utils3.dataAttr)(isDragging && focusThumbOnChange),
737
739
  role: "slider",
738
740
  tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
@@ -748,14 +750,15 @@ var useColorSlider = ({
748
750
  value,
749
751
  formControlProps,
750
752
  ariaReadonly,
751
- isInteractive,
752
- focusThumbOnChange,
753
- min,
754
753
  max,
754
+ min,
755
+ channel,
755
756
  isDragging,
756
- onKeyDown,
757
+ focusThumbOnChange,
758
+ isInteractive,
759
+ onBlurProp,
757
760
  onFocusProp,
758
- onBlurProp
761
+ onKeyDown
759
762
  ]
760
763
  );
761
764
  return {
@@ -766,9 +769,30 @@ var useColorSlider = ({
766
769
  getTrackProps
767
770
  };
768
771
  };
772
+ var getAriaValueText = (channel, value) => {
773
+ if (channel === "hue") {
774
+ return `${value}\xB0, ${getColorName(value)}`;
775
+ } else {
776
+ return `${value * 100}%`;
777
+ }
778
+ };
779
+ var getColorName = (hue) => {
780
+ if (hue < 30 || hue >= 330) return "Red";
781
+ if (hue < 90) return "Yellow";
782
+ if (hue < 150) return "Green";
783
+ if (hue < 210) return "Cyan";
784
+ if (hue < 270) return "Blue";
785
+ return "Magenta";
786
+ };
769
787
 
770
788
  // src/alpha-slider.tsx
771
789
  var import_jsx_runtime2 = require("react/jsx-runtime");
790
+ var [AlphaSliderProvider, useAlphaSlider] = (0, import_utils4.createContext)(
791
+ {
792
+ name: "SliderContext",
793
+ errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<AlphaSlider />" `
794
+ }
795
+ );
772
796
  var defaultOverlays = (color, min, max, withShadow) => {
773
797
  let overlays = [
774
798
  {
@@ -822,14 +846,15 @@ var AlphaSlider = (0, import_core2.forwardRef)(
822
846
  min,
823
847
  step: 0.01,
824
848
  thumbColor: "transparent",
825
- ...computedProps
849
+ ...computedProps,
850
+ channel: "alpha"
826
851
  });
827
852
  const css = {
828
853
  position: "relative",
829
854
  ...styles.container,
830
855
  ...__css
831
856
  };
832
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
857
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
833
858
  import_core2.ui.div,
834
859
  {
835
860
  className: (0, import_utils4.cx)("ui-alpha-slider", className),
@@ -837,55 +862,87 @@ var AlphaSlider = (0, import_core2.forwardRef)(
837
862
  ...getContainerProps(),
838
863
  children: [
839
864
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.input, { ...getInputProps(inputProps, ref) }),
840
- overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
841
- import_core2.ui.div,
842
- {
843
- className: "ui-alpha-slider__overlay",
844
- __css: {
845
- bottom: 0,
846
- left: 0,
847
- position: "absolute",
848
- right: 0,
849
- top: 0,
850
- ...styles.overlay
851
- },
852
- ...props2
853
- },
854
- index
855
- )),
856
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
857
- import_core2.ui.div,
858
- {
859
- className: "ui-alpha-slider__track",
860
- __css: {
861
- h: "100%",
862
- position: "relative",
863
- w: "100%",
864
- ...styles.track
865
- },
866
- ...getTrackProps(trackProps),
867
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
868
- import_core2.ui.div,
869
- {
870
- className: "ui-alpha-slider__thumb",
871
- __css: { ...styles.thumb },
872
- ...getThumbProps(thumbProps)
873
- }
874
- )
875
- }
876
- )
865
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderOverlay, { ...props2 }, index)),
866
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderThumb, { ...getThumbProps(thumbProps) }) })
877
867
  ]
878
868
  }
879
- );
869
+ ) });
880
870
  }
881
871
  );
882
872
  AlphaSlider.displayName = "AlphaSlider";
883
873
  AlphaSlider.__ui__ = "AlphaSlider";
874
+ var AlphaSliderOverlay = (0, import_core2.forwardRef)(
875
+ ({ className, ...rest }, ref) => {
876
+ const { styles } = useAlphaSlider();
877
+ const css = {
878
+ bottom: 0,
879
+ left: 0,
880
+ position: "absolute",
881
+ right: 0,
882
+ top: 0,
883
+ ...styles.overlay
884
+ };
885
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
886
+ import_core2.ui.div,
887
+ {
888
+ ref,
889
+ className: (0, import_utils4.cx)("ui-alpha-slider__overlay", className),
890
+ __css: css,
891
+ ...rest
892
+ }
893
+ );
894
+ }
895
+ );
896
+ AlphaSliderOverlay.displayName = "AlphaSliderOverlay";
897
+ AlphaSliderOverlay.__ui__ = "AlphaSliderOverlay";
898
+ var AlphaSliderTrack = (0, import_core2.forwardRef)(
899
+ ({ className, ...rest }, ref) => {
900
+ const { styles } = useAlphaSlider();
901
+ const css = {
902
+ h: "100%",
903
+ position: "relative",
904
+ w: "100%",
905
+ ...styles.track
906
+ };
907
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
908
+ import_core2.ui.div,
909
+ {
910
+ ref,
911
+ className: (0, import_utils4.cx)("ui-alpha-slider__track", className),
912
+ __css: css,
913
+ ...rest
914
+ }
915
+ );
916
+ }
917
+ );
918
+ AlphaSliderTrack.displayName = "AlphaSliderTrack";
919
+ AlphaSliderTrack.__ui__ = "AlphaSliderTrack";
920
+ var AlphaSliderThumb = (0, import_core2.forwardRef)(
921
+ ({ className, ...rest }, ref) => {
922
+ const { styles } = useAlphaSlider();
923
+ const css = { ...styles.thumb };
924
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
925
+ import_core2.ui.div,
926
+ {
927
+ ref,
928
+ className: (0, import_utils4.cx)("ui-alpha-slider__thumb", className),
929
+ __css: css,
930
+ ...rest
931
+ }
932
+ );
933
+ }
934
+ );
935
+ AlphaSliderThumb.displayName = "AlphaSliderThumb";
936
+ AlphaSliderThumb.__ui__ = "AlphaSliderThumb";
884
937
 
885
938
  // src/hue-slider.tsx
886
939
  var import_core3 = require("@yamada-ui/core");
887
940
  var import_utils5 = require("@yamada-ui/utils");
888
941
  var import_jsx_runtime3 = require("react/jsx-runtime");
942
+ var [HueSliderProvider, useHueSlider] = (0, import_utils5.createContext)({
943
+ name: "SliderContext",
944
+ errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<HueSlider />" `
945
+ });
889
946
  var defaultOverlays2 = (min, max, withShadow) => {
890
947
  let overlays = [
891
948
  {
@@ -917,13 +974,13 @@ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
917
974
  __css,
918
975
  ...computedProps
919
976
  } = (0, import_core3.omitThemeProps)(mergedProps);
920
- const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps });
977
+ const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps, channel: "hue" });
921
978
  const css = {
922
979
  position: "relative",
923
980
  ...styles.container,
924
981
  ...__css
925
982
  };
926
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
983
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
927
984
  import_core3.ui.div,
928
985
  {
929
986
  className: (0, import_utils5.cx)("ui-hue-slider", className),
@@ -931,44 +988,77 @@ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
931
988
  ...getContainerProps(),
932
989
  children: [
933
990
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.input, { ...getInputProps(inputProps, ref) }),
934
- overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
935
- import_core3.ui.div,
936
- {
937
- className: "ui-hue-slider__overlay",
938
- __css: {
939
- bottom: 0,
940
- left: 0,
941
- position: "absolute",
942
- right: 0,
943
- top: 0,
944
- ...styles.overlay
945
- },
946
- ...props2
947
- },
948
- index
949
- )),
950
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
951
- import_core3.ui.div,
952
- {
953
- className: "ui-hue-slider__track",
954
- __css: { h: "100%", position: "relative", w: "100%", ...styles.track },
955
- ...getTrackProps(trackProps),
956
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
957
- import_core3.ui.div,
958
- {
959
- className: "ui-hue-slider__thumb",
960
- __css: { ...styles.thumb },
961
- ...getThumbProps(thumbProps)
962
- }
963
- )
964
- }
965
- )
991
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderOverlay, { ...props2 }, index)),
992
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderThumb, { ...getThumbProps(thumbProps) }) })
966
993
  ]
967
994
  }
968
- );
995
+ ) });
969
996
  });
970
997
  HueSlider.displayName = "HueSlider";
971
998
  HueSlider.__ui__ = "HueSlider";
999
+ var HueSliderOverlay = (0, import_core3.forwardRef)(
1000
+ ({ className, ...rest }, ref) => {
1001
+ const { styles } = useHueSlider();
1002
+ const css = {
1003
+ bottom: 0,
1004
+ left: 0,
1005
+ position: "absolute",
1006
+ right: 0,
1007
+ top: 0,
1008
+ ...styles.overlay
1009
+ };
1010
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1011
+ import_core3.ui.div,
1012
+ {
1013
+ ref,
1014
+ className: (0, import_utils5.cx)("ui-hue-slider__overlay", className),
1015
+ __css: css,
1016
+ ...rest
1017
+ }
1018
+ );
1019
+ }
1020
+ );
1021
+ HueSliderOverlay.displayName = "HueSliderOverlay";
1022
+ HueSliderOverlay.__ui__ = "HueSliderOverlay";
1023
+ var HueSliderTrack = (0, import_core3.forwardRef)(
1024
+ ({ className, ...rest }, ref) => {
1025
+ const { styles } = useHueSlider();
1026
+ const css = {
1027
+ h: "100%",
1028
+ position: "relative",
1029
+ w: "100%",
1030
+ ...styles.track
1031
+ };
1032
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1033
+ import_core3.ui.div,
1034
+ {
1035
+ ref,
1036
+ className: (0, import_utils5.cx)("ui-hue-slider__track", className),
1037
+ __css: css,
1038
+ ...rest
1039
+ }
1040
+ );
1041
+ }
1042
+ );
1043
+ HueSliderTrack.displayName = "HueSliderTrack";
1044
+ HueSliderTrack.__ui__ = "HueSliderTrack";
1045
+ var HueSliderThumb = (0, import_core3.forwardRef)(
1046
+ ({ className, ...rest }, ref) => {
1047
+ const { styles } = useHueSlider();
1048
+ const css = { ...styles.thumb };
1049
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1050
+ import_core3.ui.div,
1051
+ {
1052
+ ref,
1053
+ className: (0, import_utils5.cx)("ui-hue-slider__thumb", className),
1054
+ __css: css,
1055
+ ...rest
1056
+ }
1057
+ );
1058
+ }
1059
+ );
1060
+ HueSliderThumb.displayName = "HueSliderThumb";
1061
+ HueSliderThumb.__ui__ = "HueSliderThumb";
972
1062
 
973
1063
  // src/color-selector-sliders.tsx
974
1064
  var import_jsx_runtime4 = require("react/jsx-runtime");