@connectif/ui-components 5.0.0 → 5.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.0.2] - 2026-01-23
4
+
5
+ ### Fixed
6
+
7
+ - Fixed bug in `ColorPicker` component that prevented selecting and setting black color via mouse
8
+ - Fixed `Autocomplete` component overriding `data-testid` prop when passed through `textFieldProps`
9
+
10
+ ## [5.0.1] - 2026-01-23
11
+
12
+ ### Fixed
13
+
14
+ - Fixed a bug in the `Select` component when multiple options are selected.
15
+
3
16
  ## [5.0.0] - 2026-01-23
4
17
 
5
18
  ### Fixed
@@ -49,7 +49,7 @@ export type TextFieldContainerProps = React.PropsWithChildren<{
49
49
  /**
50
50
  * Settled directly in DOM element, for testing easy location purposes.
51
51
  */
52
- 'data-test'?: string;
52
+ 'data-testid'?: string;
53
53
  }>;
54
54
  /**
55
55
  * A TextFieldContainer is just a Box with the visual styles that uses the TextField component.
@@ -104,7 +104,7 @@ declare const TextFieldContainer: React.ForwardRefExoticComponent<{
104
104
  /**
105
105
  * Settled directly in DOM element, for testing easy location purposes.
106
106
  */
107
- 'data-test'?: string;
107
+ 'data-testid'?: string;
108
108
  } & {
109
109
  children?: React.ReactNode | undefined;
110
110
  } & React.RefAttributes<HTMLDivElement>>;
package/dist/index.js CHANGED
@@ -18967,7 +18967,7 @@ var TextFieldContainer = React48.forwardRef(function TextFieldContainer2({
18967
18967
  onClick,
18968
18968
  className = "",
18969
18969
  sx,
18970
- "data-test": dataTest,
18970
+ "data-testid": dataTestId,
18971
18971
  onMouseEnter,
18972
18972
  onMouseLeave
18973
18973
  }, ref) {
@@ -19017,8 +19017,8 @@ var TextFieldContainer = React48.forwardRef(function TextFieldContainer2({
19017
19017
  ...sx
19018
19018
  },
19019
19019
  ref,
19020
- ...dataTest && {
19021
- "data-test": dataTest
19020
+ ...dataTestId && {
19021
+ "data-testid": dataTestId
19022
19022
  },
19023
19023
  onMouseEnter,
19024
19024
  onMouseLeave,
@@ -19261,7 +19261,7 @@ var TextField = React51.forwardRef(function TextField2({
19261
19261
  ref: containerRef,
19262
19262
  className: `Cn-TextField ${className}`,
19263
19263
  ...dataTestId && {
19264
- "data-test": `${dataTestId}-container`
19264
+ "data-testid": `${dataTestId}-container`
19265
19265
  },
19266
19266
  onMouseEnter,
19267
19267
  onMouseLeave,
@@ -21181,6 +21181,7 @@ var ChevronIcon = ({ disabled = false }) => /* @__PURE__ */ jsx114(
21181
21181
  }
21182
21182
  );
21183
21183
  var SelectOption = ({
21184
+ value,
21184
21185
  id,
21185
21186
  label,
21186
21187
  selected,
@@ -21192,7 +21193,7 @@ var SelectOption = ({
21192
21193
  {
21193
21194
  role: "option",
21194
21195
  selected,
21195
- "data-value": id,
21196
+ "data-value": value,
21196
21197
  text: label,
21197
21198
  ...id && {
21198
21199
  "data-testid": `select-option-${id}`,
@@ -21496,6 +21497,7 @@ var Select = function Select2({
21496
21497
  SelectOption,
21497
21498
  {
21498
21499
  label: label ?? value?.toString() ?? "",
21500
+ value: optionValue,
21499
21501
  id: optionValue,
21500
21502
  colors: !menuColors?.selectedColor ? {
21501
21503
  ...menuColors ?? {},
@@ -21646,26 +21648,23 @@ var ColorPicker = React62.forwardRef(function ColorPickerWrapper({
21646
21648
  const [internalPickerValue, setInternalPickerValue] = React62.useState(
21647
21649
  value || white
21648
21650
  );
21649
- const [textFieldValue, setTextFieldValue] = React62.useState(value ?? "");
21651
+ const [textFieldValue, setTextFieldValue] = React62.useState(
21652
+ value ? allowAlpha ? value : rgbToHex(value) : ""
21653
+ );
21654
+ const [isValidPickerChange, setValidPickerChange] = React62.useState(false);
21655
+ const [colorChangeOccurred, setColorChangeOccurred] = React62.useState(false);
21656
+ const [isPopoverInputFocused, setIsPopoverInputFocused] = React62.useState(false);
21650
21657
  const [anchorEl, setAnchorEl] = React62.useState();
21658
+ const containerRef = React62.useRef(null);
21651
21659
  const handleTextFieldChange = (event) => {
21652
21660
  const newValue = event.target.value;
21661
+ setValidPickerChange(false);
21653
21662
  setTextFieldValue(newValue);
21654
21663
  if (isValidColor(newValue) || allowEmpty && newValue === "") {
21655
21664
  setInternalPickerValue(newValue);
21656
21665
  onChange(newValue);
21657
21666
  }
21658
21667
  };
21659
- const rgbToHex = (rgb) => {
21660
- const rgbValues = rgb.match(/\d+/g);
21661
- if (!rgbValues || rgbValues.length !== 3 && rgbValues.length !== 4) {
21662
- return rgb;
21663
- }
21664
- return "#" + rgbValues.slice(0, 3).map((val) => {
21665
- const hex = parseInt(val, 10).toString(16);
21666
- return hex.length === 1 ? "0" + hex : hex;
21667
- }).join("");
21668
- };
21669
21668
  const normalizeBlack = (color2) => {
21670
21669
  const rgb = color2.match(/\d+/g);
21671
21670
  if (!rgb) {
@@ -21677,13 +21676,6 @@ var ColorPicker = React62.forwardRef(function ColorPickerWrapper({
21677
21676
  }
21678
21677
  return color2;
21679
21678
  };
21680
- const commitColor = React62.useCallback(() => {
21681
- const finalValue = allowAlpha ? internalPickerValue : rgbToHex(internalPickerValue);
21682
- setInternalPickerValue(finalValue);
21683
- setTextFieldValue(finalValue);
21684
- setPreviousColors((prev) => [finalValue, ...prev.slice(0, 17)]);
21685
- onChange(finalValue);
21686
- }, [internalPickerValue, allowAlpha, onChange]);
21687
21679
  const iconColor = /* @__PURE__ */ jsx117(
21688
21680
  IconButton_default,
21689
21681
  {
@@ -21695,6 +21687,56 @@ var ColorPicker = React62.forwardRef(function ColorPickerWrapper({
21695
21687
  sx: { color: value || grey600 }
21696
21688
  }
21697
21689
  );
21690
+ React62.useEffect(() => {
21691
+ const handleColorChange = (color2) => {
21692
+ setPreviousColors((prev) => [color2, ...prev.slice(0, 17)]);
21693
+ setTextFieldValue(rgbToHex(color2));
21694
+ onChange(color2);
21695
+ setValidPickerChange(false);
21696
+ setColorChangeOccurred(false);
21697
+ };
21698
+ if (colorChangeOccurred && (isValidPickerChange || isPopoverInputFocused) && internalPickerValue && internalPickerValue !== value) {
21699
+ handleColorChange(internalPickerValue);
21700
+ }
21701
+ }, [
21702
+ value,
21703
+ internalPickerValue,
21704
+ onChange,
21705
+ isValidPickerChange,
21706
+ colorChangeOccurred,
21707
+ isPopoverInputFocused
21708
+ ]);
21709
+ React62.useEffect(() => {
21710
+ if (anchorEl) {
21711
+ const handleFocus = () => {
21712
+ setIsPopoverInputFocused(true);
21713
+ };
21714
+ const handleBlur = () => {
21715
+ setIsPopoverInputFocused(false);
21716
+ };
21717
+ let inputs;
21718
+ const timeoutId = setTimeout(() => {
21719
+ if (containerRef.current) {
21720
+ inputs = containerRef.current.querySelectorAll(
21721
+ "input#rbgcp-input, input#rbgcp-hex-input"
21722
+ );
21723
+ inputs.forEach((input) => {
21724
+ input.addEventListener("focus", handleFocus);
21725
+ input.addEventListener("blur", handleBlur);
21726
+ });
21727
+ }
21728
+ }, 0);
21729
+ return () => {
21730
+ clearTimeout(timeoutId);
21731
+ if (inputs) {
21732
+ inputs.forEach((input) => {
21733
+ input.removeEventListener("focus", handleFocus);
21734
+ input.removeEventListener("blur", handleBlur);
21735
+ });
21736
+ }
21737
+ };
21738
+ }
21739
+ }, [anchorEl]);
21698
21740
  return /* @__PURE__ */ jsxs53(Fragment23, { children: [
21699
21741
  /* @__PURE__ */ jsx117(
21700
21742
  TextField_default,
@@ -21727,11 +21769,13 @@ var ColorPicker = React62.forwardRef(function ColorPickerWrapper({
21727
21769
  anchorEl,
21728
21770
  onClose: () => setAnchorEl(void 0),
21729
21771
  sx: { zIndex: popoverZIndex },
21730
- onMouseUp: commitColor,
21772
+ onMouseUp: () => setValidPickerChange(true),
21731
21773
  children: /* @__PURE__ */ jsx117(
21732
21774
  Box_default2,
21733
21775
  {
21776
+ ref: containerRef,
21734
21777
  className: "Cn-Color-Gradient-Box",
21778
+ onMouseUp: () => setValidPickerChange(true),
21735
21779
  sx: {
21736
21780
  "&.Cn-Color-Gradient-Box": {
21737
21781
  backgroundColor: "white !important",
@@ -21781,7 +21825,7 @@ var ColorPicker = React62.forwardRef(function ColorPickerWrapper({
21781
21825
  const normalized = normalizeBlack(newColor);
21782
21826
  const preview = allowAlpha ? normalized : rgbToHex(normalized);
21783
21827
  setInternalPickerValue(preview);
21784
- setTextFieldValue(preview);
21828
+ setColorChangeOccurred(true);
21785
21829
  },
21786
21830
  hideAdvancedSliders: true,
21787
21831
  hideColorGuide: true,
@@ -21798,6 +21842,16 @@ var ColorPicker = React62.forwardRef(function ColorPickerWrapper({
21798
21842
  ] });
21799
21843
  });
21800
21844
  var ColorPicker_default = ColorPicker;
21845
+ var rgbToHex = (rgb) => {
21846
+ const rgbValues = rgb.match(/\d+/g);
21847
+ if (!rgbValues || rgbValues.length !== 3 && rgbValues.length !== 4) {
21848
+ return rgb;
21849
+ }
21850
+ return "#" + rgbValues.slice(0, 3).map((val) => {
21851
+ const hex = parseInt(val, 10).toString(16);
21852
+ return hex.length === 1 ? "0" + hex : hex;
21853
+ }).join("");
21854
+ };
21801
21855
 
21802
21856
  // src/components/input/UploadClickableArea.tsx
21803
21857
  import { Box as Box3 } from "@mui/material";
@@ -23007,8 +23061,7 @@ var AutocompleteInput = function AutocompleteInput2({
23007
23061
  ),
23008
23062
  autoComplete: "off",
23009
23063
  onMouseEnter: () => setIsHover(true),
23010
- onMouseLeave: () => setIsHover(false),
23011
- "data-testid": "autocomplete-input"
23064
+ onMouseLeave: () => setIsHover(false)
23012
23065
  }
23013
23066
  ) });
23014
23067
  };
@@ -26665,7 +26718,7 @@ import MuiTabs from "@mui/material/Tabs";
26665
26718
 
26666
26719
  // src/components/layout/SwipeableViews.tsx
26667
26720
  import * as React87 from "react";
26668
- import { useEffect as useEffect22, useRef as useRef26, useState as useState34 } from "react";
26721
+ import { useEffect as useEffect23, useRef as useRef27, useState as useState34 } from "react";
26669
26722
  import { jsx as jsx155 } from "react/jsx-runtime";
26670
26723
  var styles = {
26671
26724
  container: {
@@ -26699,12 +26752,12 @@ function SwipeableViews({
26699
26752
  disableScroll = false,
26700
26753
  ...rootProps
26701
26754
  }) {
26702
- const containerRef = useRef26(null);
26703
- const scrollTimeout = useRef26();
26704
- const scrollingMethod = useRef26("none");
26755
+ const containerRef = useRef27(null);
26756
+ const scrollTimeout = useRef27();
26757
+ const scrollingMethod = useRef27("none");
26705
26758
  const [previousIndex, setPreviousIndex] = useState34(index);
26706
- const hideScrollAnimation = useRef26(true);
26707
- useEffect22(() => {
26759
+ const hideScrollAnimation = useRef27(true);
26760
+ useEffect23(() => {
26708
26761
  if (containerRef.current) {
26709
26762
  if (scrollingMethod.current === "manual") {
26710
26763
  scrollingMethod.current = "none";
@@ -27864,31 +27917,31 @@ var MinimizableWindow = React92.forwardRef(function MinimizableWindow2({
27864
27917
  var MinimizableWindow_default = MinimizableWindow;
27865
27918
 
27866
27919
  // src/hooks/useFormatters.ts
27867
- import { useCallback as useCallback23, useContext as useContext16 } from "react";
27920
+ import { useCallback as useCallback22, useContext as useContext16 } from "react";
27868
27921
  var useFormatters = () => {
27869
27922
  const { locale, currency, timezone } = useContext16(IntlContext);
27870
27923
  return {
27871
- formatCompactNumber: useCallback23(
27924
+ formatCompactNumber: useCallback22(
27872
27925
  (value) => formatCompactNumber(value, locale),
27873
27926
  [locale]
27874
27927
  ),
27875
- formatNumber: useCallback23(
27928
+ formatNumber: useCallback22(
27876
27929
  (value, fractionSize) => formatNumber(value, locale, fractionSize),
27877
27930
  [locale]
27878
27931
  ),
27879
- formatPercentage: useCallback23(
27932
+ formatPercentage: useCallback22(
27880
27933
  (value, fractionSize) => formatPercentage(value, locale, fractionSize),
27881
27934
  [locale]
27882
27935
  ),
27883
- formatCurrency: useCallback23(
27936
+ formatCurrency: useCallback22(
27884
27937
  (value, notation) => formatCurrency(value, locale, currency, notation),
27885
27938
  [currency, locale]
27886
27939
  ),
27887
- formatDate: useCallback23(
27940
+ formatDate: useCallback22(
27888
27941
  (date, format2) => formatDate(date, locale, timezone, format2),
27889
27942
  [locale, timezone]
27890
27943
  ),
27891
- formatPhone: useCallback23(
27944
+ formatPhone: useCallback22(
27892
27945
  (phone, format2) => formatPhone(phone, format2),
27893
27946
  []
27894
27947
  )