@react-aria/color 3.0.0-nightly.4545 → 3.0.0-nightly.4550

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/import.mjs CHANGED
@@ -383,6 +383,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
383
383
  state.setValue(newColor);
384
384
  });
385
385
  let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $7KHxM$useState)(false);
386
+ let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $7KHxM$useState)(false);
386
387
  let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
387
388
  let xChannelStep = state.xChannelStep;
388
389
  let yChannelStep = state.yChannelStep;
@@ -467,7 +468,10 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
467
468
  let { moveProps: movePropsThumb } = (0, $7KHxM$useMove)(moveHandler);
468
469
  let { focusWithinProps: focusWithinProps } = (0, $7KHxM$useFocusWithin)({
469
470
  onFocusWithinChange: (focusWithin)=>{
470
- if (!focusWithin) setValueChangedViaKeyboard(false);
471
+ if (!focusWithin) {
472
+ setValueChangedViaKeyboard(false);
473
+ setValueChangedViaInputChangeEvent(false);
474
+ }
471
475
  }
472
476
  });
473
477
  let currentPointer = (0, $7KHxM$useRef)(undefined);
@@ -592,22 +596,43 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
592
596
  setFocusedInput("y");
593
597
  }
594
598
  });
599
+ const onChange = (e)=>{
600
+ const { target: target } = e;
601
+ setValueChangedViaInputChangeEvent(true);
602
+ if (target === inputXRef.current) state.setXValue(parseFloat(target.value));
603
+ else if (target === inputYRef.current) state.setYValue(parseFloat(target.value));
604
+ };
595
605
  let isMobile = (0, $7KHxM$isIOS)() || (0, $7KHxM$isAndroid)();
596
- function getAriaValueTextForChannel(channel) {
597
- return valueChangedViaKeyboard ? stringFormatter.format("colorNameAndValue", {
598
- name: state.value.getChannelName(channel, locale),
599
- value: state.value.formatChannelValue(channel, locale)
606
+ let value = state.getDisplayColor();
607
+ const getAriaValueTextForChannel = (0, $7KHxM$useCallback)((channel)=>{
608
+ const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
609
+ return `${isAfterInput ? stringFormatter.format("colorNameAndValue", {
610
+ name: value.getChannelName(channel, locale),
611
+ value: value.formatChannelValue(channel, locale)
600
612
  }) : [
601
613
  stringFormatter.format("colorNameAndValue", {
602
- name: state.value.getChannelName(channel, locale),
603
- value: state.value.formatChannelValue(channel, locale)
614
+ name: value.getChannelName(channel, locale),
615
+ value: value.formatChannelValue(channel, locale)
616
+ }),
617
+ stringFormatter.format("colorNameAndValue", {
618
+ name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
619
+ value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
604
620
  }),
605
621
  stringFormatter.format("colorNameAndValue", {
606
- name: state.value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
607
- value: state.value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
622
+ name: value.getChannelName(zChannel, locale),
623
+ value: value.formatChannelValue(zChannel, locale)
608
624
  })
609
- ].join(", ");
610
- }
625
+ ].join(", ")}, ${value.getColorName(locale)}`;
626
+ }, [
627
+ locale,
628
+ value,
629
+ stringFormatter,
630
+ valueChangedViaInputChangeEvent,
631
+ valueChangedViaKeyboard,
632
+ xChannel,
633
+ yChannel,
634
+ zChannel
635
+ ]);
611
636
  let colorPickerLabel = stringFormatter.format("colorPicker");
612
637
  let xInputLabellingProps = (0, $7KHxM$useLabels)({
613
638
  ...props,
@@ -669,6 +694,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
669
694
  step: xChannelStep,
670
695
  "aria-roledescription": ariaRoleDescription,
671
696
  "aria-valuetext": getAriaValueTextForChannel(xChannel),
697
+ "aria-orientation": "horizontal",
672
698
  disabled: isDisabled,
673
699
  value: state.value.getChannelValue(xChannel),
674
700
  name: xName,
@@ -678,9 +704,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
678
704
  add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
679
705
  but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
680
706
  */ "aria-hidden": isMobile || !focusedInput || focusedInput === "x" || valueChangedViaKeyboard ? undefined : "true",
681
- onChange: (e)=>{
682
- state.setXValue(parseFloat(e.target.value));
683
- }
707
+ onChange: onChange
684
708
  },
685
709
  yInputProps: {
686
710
  ...yInputLabellingProps,
@@ -702,9 +726,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
702
726
  add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
703
727
  but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
704
728
  */ "aria-hidden": isMobile || focusedInput === "y" || valueChangedViaKeyboard ? undefined : "true",
705
- onChange: (e)=>{
706
- state.setYValue(parseFloat(e.target.value));
707
- }
729
+ onChange: onChange
708
730
  }
709
731
  };
710
732
  }
@@ -741,8 +763,8 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
741
763
  trackRef: trackRef,
742
764
  inputRef: inputRef
743
765
  }, state);
766
+ let value = state.getDisplayColor();
744
767
  let generateBackground = ()=>{
745
- let value = state.getDisplayColor();
746
768
  let to;
747
769
  if (orientation === "vertical") to = "top";
748
770
  else if (direction === "ltr") to = "right";
@@ -779,6 +801,8 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
779
801
  let forcedColorAdjustNoneStyle = {
780
802
  forcedColorAdjust: "none"
781
803
  };
804
+ if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
805
+ else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
782
806
  return {
783
807
  trackProps: {
784
808
  ...(0, $7KHxM$mergeProps)(groupProps, trackProps),
@@ -1034,7 +1058,7 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
1034
1058
  min: String(minValue),
1035
1059
  max: String(maxValue),
1036
1060
  step: String(step),
1037
- "aria-valuetext": state.value.formatChannelValue("hue", locale),
1061
+ "aria-valuetext": `${state.value.formatChannelValue("hue", locale)}, ${state.value.getHueName(locale)}`,
1038
1062
  disabled: isDisabled,
1039
1063
  value: `${state.value.getChannelValue("hue")}`,
1040
1064
  name: name,
package/dist/main.js CHANGED
@@ -392,6 +392,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
392
392
  state.setValue(newColor);
393
393
  });
394
394
  let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $kZqDi$react.useState)(false);
395
+ let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $kZqDi$react.useState)(false);
395
396
  let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
396
397
  let xChannelStep = state.xChannelStep;
397
398
  let yChannelStep = state.yChannelStep;
@@ -476,7 +477,10 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
476
477
  let { moveProps: movePropsThumb } = (0, $kZqDi$reactariainteractions.useMove)(moveHandler);
477
478
  let { focusWithinProps: focusWithinProps } = (0, $kZqDi$reactariainteractions.useFocusWithin)({
478
479
  onFocusWithinChange: (focusWithin)=>{
479
- if (!focusWithin) setValueChangedViaKeyboard(false);
480
+ if (!focusWithin) {
481
+ setValueChangedViaKeyboard(false);
482
+ setValueChangedViaInputChangeEvent(false);
483
+ }
480
484
  }
481
485
  });
482
486
  let currentPointer = (0, $kZqDi$react.useRef)(undefined);
@@ -601,22 +605,43 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
601
605
  setFocusedInput("y");
602
606
  }
603
607
  });
608
+ const onChange = (e)=>{
609
+ const { target: target } = e;
610
+ setValueChangedViaInputChangeEvent(true);
611
+ if (target === inputXRef.current) state.setXValue(parseFloat(target.value));
612
+ else if (target === inputYRef.current) state.setYValue(parseFloat(target.value));
613
+ };
604
614
  let isMobile = (0, $kZqDi$reactariautils.isIOS)() || (0, $kZqDi$reactariautils.isAndroid)();
605
- function getAriaValueTextForChannel(channel) {
606
- return valueChangedViaKeyboard ? stringFormatter.format("colorNameAndValue", {
607
- name: state.value.getChannelName(channel, locale),
608
- value: state.value.formatChannelValue(channel, locale)
615
+ let value = state.getDisplayColor();
616
+ const getAriaValueTextForChannel = (0, $kZqDi$react.useCallback)((channel)=>{
617
+ const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
618
+ return `${isAfterInput ? stringFormatter.format("colorNameAndValue", {
619
+ name: value.getChannelName(channel, locale),
620
+ value: value.formatChannelValue(channel, locale)
609
621
  }) : [
610
622
  stringFormatter.format("colorNameAndValue", {
611
- name: state.value.getChannelName(channel, locale),
612
- value: state.value.formatChannelValue(channel, locale)
623
+ name: value.getChannelName(channel, locale),
624
+ value: value.formatChannelValue(channel, locale)
625
+ }),
626
+ stringFormatter.format("colorNameAndValue", {
627
+ name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
628
+ value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
613
629
  }),
614
630
  stringFormatter.format("colorNameAndValue", {
615
- name: state.value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
616
- value: state.value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
631
+ name: value.getChannelName(zChannel, locale),
632
+ value: value.formatChannelValue(zChannel, locale)
617
633
  })
618
- ].join(", ");
619
- }
634
+ ].join(", ")}, ${value.getColorName(locale)}`;
635
+ }, [
636
+ locale,
637
+ value,
638
+ stringFormatter,
639
+ valueChangedViaInputChangeEvent,
640
+ valueChangedViaKeyboard,
641
+ xChannel,
642
+ yChannel,
643
+ zChannel
644
+ ]);
620
645
  let colorPickerLabel = stringFormatter.format("colorPicker");
621
646
  let xInputLabellingProps = (0, $kZqDi$reactariautils.useLabels)({
622
647
  ...props,
@@ -678,6 +703,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
678
703
  step: xChannelStep,
679
704
  "aria-roledescription": ariaRoleDescription,
680
705
  "aria-valuetext": getAriaValueTextForChannel(xChannel),
706
+ "aria-orientation": "horizontal",
681
707
  disabled: isDisabled,
682
708
  value: state.value.getChannelValue(xChannel),
683
709
  name: xName,
@@ -687,9 +713,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
687
713
  add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
688
714
  but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
689
715
  */ "aria-hidden": isMobile || !focusedInput || focusedInput === "x" || valueChangedViaKeyboard ? undefined : "true",
690
- onChange: (e)=>{
691
- state.setXValue(parseFloat(e.target.value));
692
- }
716
+ onChange: onChange
693
717
  },
694
718
  yInputProps: {
695
719
  ...yInputLabellingProps,
@@ -711,9 +735,7 @@ function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
711
735
  add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
712
736
  but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
713
737
  */ "aria-hidden": isMobile || focusedInput === "y" || valueChangedViaKeyboard ? undefined : "true",
714
- onChange: (e)=>{
715
- state.setYValue(parseFloat(e.target.value));
716
- }
738
+ onChange: onChange
717
739
  }
718
740
  };
719
741
  }
@@ -750,8 +772,8 @@ function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
750
772
  trackRef: trackRef,
751
773
  inputRef: inputRef
752
774
  }, state);
775
+ let value = state.getDisplayColor();
753
776
  let generateBackground = ()=>{
754
- let value = state.getDisplayColor();
755
777
  let to;
756
778
  if (orientation === "vertical") to = "top";
757
779
  else if (direction === "ltr") to = "right";
@@ -788,6 +810,8 @@ function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
788
810
  let forcedColorAdjustNoneStyle = {
789
811
  forcedColorAdjust: "none"
790
812
  };
813
+ if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
814
+ else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
791
815
  return {
792
816
  trackProps: {
793
817
  ...(0, $kZqDi$reactariautils.mergeProps)(groupProps, trackProps),
@@ -1043,7 +1067,7 @@ function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
1043
1067
  min: String(minValue),
1044
1068
  max: String(maxValue),
1045
1069
  step: String(step),
1046
- "aria-valuetext": state.value.formatChannelValue("hue", locale),
1070
+ "aria-valuetext": `${state.value.formatChannelValue("hue", locale)}, ${state.value.getHueName(locale)}`,
1047
1071
  disabled: isDisabled,
1048
1072
  value: `${state.value.getChannelValue("hue")}`,
1049
1073
  name: name,