@redneckz/wildless-cms-uni-blocks 0.14.729 → 0.14.730

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.
@@ -2042,10 +2042,7 @@
2042
2042
  };
2043
2043
  const onBlur = () => {
2044
2044
  if (checkIsValidDate(inputValue)) {
2045
- const [day, month, year] = inputValue.split('.');
2046
- onChange?.(new Date(Number(year), Number(month) - 1, Number(day)));
2047
- setSelectedMonth(Number(month) - 1);
2048
- setSelectedYear(Number(year));
2045
+ updateSelectedDate({ inputValue, setSelectedMonth, setSelectedYear, onChange });
2049
2046
  }
2050
2047
  else {
2051
2048
  setInputValue(value || '');
@@ -2060,6 +2057,9 @@
2060
2057
  useEffect(() => {
2061
2058
  setInputValue(value || '');
2062
2059
  }, [value]);
2060
+ useEffect(() => {
2061
+ updateSelectedDate({ inputValue, setSelectedMonth, setSelectedYear, onChange });
2062
+ }, [inputValue]);
2063
2063
  return (jsxs("div", { onClick: onInputClick, className: style('relative', className), children: [jsx("input", { ref: ref, className: "h-full w-full px-m text-l text-black focus-visible:outline-none", value: inputValue, type: "text", onChange: handleChange, onBlur: onBlur, disabled: disabled }), disabled ? null : jsx(Icon, { className: "mr-s", ...ICON_PROPS$1 })] }));
2064
2064
  });
2065
2065
  const isValidYear = (year) => Number(year) >= START_YEAR && Number(year) <= new Date().getFullYear();
@@ -2074,13 +2074,27 @@
2074
2074
  currentDate.setDate(currentDate.getDate() + 1);
2075
2075
  maxDateOfMonth++;
2076
2076
  }
2077
- if (Number(day) > 0 && Number(day) <= maxDateOfMonth) {
2078
- return true;
2079
- }
2077
+ return Number(day) > 0 && Number(day) <= maxDateOfMonth;
2080
2078
  }
2081
2079
  }
2082
2080
  return false;
2083
2081
  };
2082
+ const parseDate = (inputValue) => {
2083
+ const [dayStr, monthStr, yearStr] = inputValue.split('.');
2084
+ return {
2085
+ day: Number(dayStr),
2086
+ month: Number(monthStr) - 1,
2087
+ year: Number(yearStr),
2088
+ };
2089
+ };
2090
+ const updateSelectedDate = ({ inputValue, setSelectedMonth, setSelectedYear, onChange, }) => {
2091
+ if (checkIsValidDate(inputValue)) {
2092
+ const { day, month, year } = parseDate(inputValue);
2093
+ setSelectedMonth(month);
2094
+ setSelectedYear(year);
2095
+ onChange?.(new Date(year, month, day));
2096
+ }
2097
+ };
2084
2098
 
2085
2099
  const formStyle = 'flex justify-between items-center h-14 border rounded-md cursor-pointer ' +
2086
2100
  'hover:border-black active:border-black focus:border-black';
@@ -10478,7 +10492,7 @@
10478
10492
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
10479
10493
  });
10480
10494
 
10481
- const packageVersion = "0.14.728";
10495
+ const packageVersion = "0.14.729";
10482
10496
 
10483
10497
  exports.Blocks = Blocks;
10484
10498
  exports.ContentPage = ContentPage;