@sledge-app/react-instant-search 2.0.53 → 2.0.54

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.
@@ -859,6 +859,7 @@ const Slider = (props) => {
859
859
  minMaxClassName = "",
860
860
  minMaxTextClassName = ""
861
861
  } = props;
862
+ const { isJsVersion, locale } = React__default.useContext(SledgeContext) || {};
862
863
  const [inputRangeMin, setInputRangeMin] = React__default.useState(inputRangeFormatter(value == null ? void 0 : value[0]));
863
864
  const [inputRangeMax, setInputRangeMax] = React__default.useState(inputRangeFormatter((value == null ? void 0 : value[1]) || (value == null ? void 0 : value[0])));
864
865
  const delayInputRangeRef = React__default.useRef(null);
@@ -869,8 +870,9 @@ const Slider = (props) => {
869
870
  const isTypeIncludeSlider = (_b = String(type)) == null ? void 0 : _b.includes("slider");
870
871
  const isTypeIncludeInputRange = (_c = String(type)) == null ? void 0 : _c.includes("input_range");
871
872
  const handleChangeInputRange = ({ event, type: type2 }) => {
872
- var _a2;
873
+ var _a2, _b2;
873
874
  let valueInput = (_a2 = event == null ? void 0 : event.target) == null ? void 0 : _a2.value;
875
+ valueInput = (_b2 = valueInput == null ? void 0 : valueInput.replaceAll) == null ? void 0 : _b2.call(valueInput, ",", ".");
874
876
  if (!Number(valueInput) && Number(valueInput) !== 0)
875
877
  return;
876
878
  let valueCommit = type2 === "min" ? [valueInput || 0, (value == null ? void 0 : value[1]) || (value == null ? void 0 : value[0])] : [value == null ? void 0 : value[0], valueInput || 0];
@@ -909,6 +911,22 @@ const Slider = (props) => {
909
911
  }
910
912
  }, 500);
911
913
  };
914
+ const decimalFormatter = (value2) => {
915
+ var _a2, _b2, _c2;
916
+ const selectedLocale = isJsVersion ? selectedLocaleJs() : locale;
917
+ if (value2 && selectedLocale) {
918
+ try {
919
+ const formatted = new Intl.NumberFormat(selectedLocale).format(value2);
920
+ const nonDigits = (_a2 = formatted == null ? void 0 : formatted.replace) == null ? void 0 : _a2.call(formatted, /\d/g, "");
921
+ const decimalSeparator = (_b2 = nonDigits == null ? void 0 : nonDigits.slice) == null ? void 0 : _b2.call(nonDigits, -1);
922
+ if (decimalSeparator === ",")
923
+ return (_c2 = value2 == null ? void 0 : value2.replaceAll) == null ? void 0 : _c2.call(value2, ".", ",");
924
+ } catch (error) {
925
+ return value2;
926
+ }
927
+ }
928
+ return value2;
929
+ };
912
930
  useEffectOnChange(() => {
913
931
  if (isTypeIncludeInputRange && !(valueFilterSliderChange == null ? void 0 : valueFilterSliderChange.length)) {
914
932
  setInputRangeMin(inputRangeFormatter(value == null ? void 0 : value[0]));
@@ -926,7 +944,7 @@ const Slider = (props) => {
926
944
  className: "sledge__slider-input-range-minmax",
927
945
  type: "text",
928
946
  onChange: (event) => handleChangeInputRange({ event, type: "min" }),
929
- value: inputRangeMin,
947
+ value: decimalFormatter(inputRangeMin),
930
948
  style: labelStyle
931
949
  }
932
950
  ),
@@ -937,7 +955,7 @@ const Slider = (props) => {
937
955
  className: "sledge__slider-input-range-minmax",
938
956
  type: "text",
939
957
  onChange: (event) => handleChangeInputRange({ event, type: "max" }),
940
- value: inputRangeMax,
958
+ value: decimalFormatter(inputRangeMax),
941
959
  style: labelStyle
942
960
  }
943
961
  )