trotl-filter 1.0.50 → 1.0.51

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/index.cjs.js CHANGED
@@ -9593,6 +9593,22 @@ function DateTimeInput({
9593
9593
  return toInputString(d.getTime());
9594
9594
  });
9595
9595
 
9596
+ // internal value for the time input. Previously the <input> read
9597
+ // directly from `value` which meant that when the component was
9598
+ // controlled the field could never update until the parent passed a
9599
+ // new prop. By keeping a separate `timeValue` that syncs from `value` but
9600
+ // is mutated as the user types we allow the time field to stay responsive
9601
+ // even in controlled scenarios.
9602
+ const [timeValue, setTimeValue] = React.useState(() => {
9603
+ if (value) {
9604
+ const d = new Date(value);
9605
+ const hh = String(d.getHours()).padStart(2, '0');
9606
+ const mm = String(d.getMinutes()).padStart(2, '0');
9607
+ return `${hh}:${mm}`;
9608
+ }
9609
+ return timeStart || "";
9610
+ });
9611
+
9596
9612
  // Dropdown state & positioning
9597
9613
  const [open, setOpen] = React.useState(false);
9598
9614
  const dropdownRef = React.useRef(null);
@@ -9846,6 +9862,18 @@ function DateTimeInput({
9846
9862
  }
9847
9863
  }, [isControlled, normalizedControlledValue]);
9848
9864
 
9865
+ // keep the timeValue in sync whenever the effective value or start time changes
9866
+ React.useEffect(() => {
9867
+ if (value) {
9868
+ const d = new Date(value);
9869
+ const hh = String(d.getHours()).padStart(2, '0');
9870
+ const mm = String(d.getMinutes()).padStart(2, '0');
9871
+ setTimeValue(`${hh}:${mm}`);
9872
+ } else {
9873
+ setTimeValue(timeStart || '');
9874
+ }
9875
+ }, [value, timeStart]);
9876
+
9849
9877
  // Formatting display (similar to RangePicker)
9850
9878
  const formatDisplay = () => {
9851
9879
  if (!value) return "";
@@ -9942,12 +9970,18 @@ function DateTimeInput({
9942
9970
  };
9943
9971
  const handleTimeChange = e => {
9944
9972
  const t = e.target.value; // HH:mm
9945
- if (!value) return;
9946
- const d = new Date(value);
9973
+ setTimeValue(t);
9974
+ // determine base date: prefer current value, fall back to now
9975
+ const baseDate = value ? new Date(value) : new Date();
9947
9976
  const [h, m] = t.split(":");
9948
- d.setHours(Number(h), Number(m), 0, 0);
9949
- const str = toInputString(d.getTime());
9950
- if (!isControlled) setValue(str);
9977
+ baseDate.setHours(Number(h), Number(m), 0, 0);
9978
+ const str = toInputString(baseDate.getTime());
9979
+ // always update local `value` so the dropdown display keeps up
9980
+ if (!isControlled) {
9981
+ setValue(str);
9982
+ } else {
9983
+ setValue(str);
9984
+ }
9951
9985
  setUrlParam(str);
9952
9986
  onChange?.(str);
9953
9987
  };
@@ -10125,13 +10159,7 @@ function DateTimeInput({
10125
10159
  }
10126
10160
  }, "Time:"), /*#__PURE__*/React.createElement("input", {
10127
10161
  type: "time",
10128
- value: (() => {
10129
- if (!value) return '';
10130
- const d = new Date(value);
10131
- const hh = String(d.getHours()).padStart(2, '0');
10132
- const mm = String(d.getMinutes()).padStart(2, '0');
10133
- return `${hh}:${mm}`;
10134
- })(),
10162
+ value: timeValue,
10135
10163
  onChange: handleTimeChange,
10136
10164
  className: "basic-input",
10137
10165
  disabled: disabled,