@douglasneuroinformatics/libui 3.7.4 → 3.7.6

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.
@@ -2118,7 +2118,7 @@ import "react";
2118
2118
  import { match as match7 } from "ts-pattern";
2119
2119
 
2120
2120
  // src/components/Form/NumberRecordField.tsx
2121
- import { useEffect as useEffect4 } from "react";
2121
+ import { useEffect as useEffect4, useRef as useRef3 } from "react";
2122
2122
 
2123
2123
  // src/components/Form/NumberField/NumberField.tsx
2124
2124
  import { match as match2 } from "ts-pattern";
@@ -2633,8 +2633,17 @@ var NumberRecordField = ({
2633
2633
  setValue: setRecordValue,
2634
2634
  value: recordValue
2635
2635
  }) => {
2636
+ const optionsRef = useRef3(options);
2636
2637
  useEffect4(() => {
2637
- setRecordValue({});
2638
+ if (!recordValue) {
2639
+ setRecordValue({});
2640
+ }
2641
+ }, []);
2642
+ useEffect4(() => {
2643
+ if (optionsRef.current !== options) {
2644
+ setRecordValue({});
2645
+ optionsRef.current = options;
2646
+ }
2638
2647
  }, [options]);
2639
2648
  if (!recordValue) {
2640
2649
  return null;
@@ -2664,7 +2673,7 @@ var NumberRecordField = ({
2664
2673
  };
2665
2674
 
2666
2675
  // src/components/Form/RecordArrayField.tsx
2667
- import { memo, useEffect as useEffect8 } from "react";
2676
+ import { memo, useEffect as useEffect8, useRef as useRef4 } from "react";
2668
2677
  import { MinusCircleIcon, PlusCircleIcon } from "lucide-react";
2669
2678
 
2670
2679
  // src/components/Form/BooleanField/BooleanField.tsx
@@ -2780,7 +2789,7 @@ var isValidDateString = (s) => /^(\d{4})-((0[1-9])|(1[0-2]))-((0[1-9])|([12])[0-
2780
2789
  var DateField = ({ disabled, error, label, name, readOnly, setValue, value }) => {
2781
2790
  const [isDatePickerOpen, setIsDatePickerOpen] = useState5(false);
2782
2791
  const [isInputFocused, setIsInputFocused] = useState5(false);
2783
- const [inputValue, setInputValue] = useState5("");
2792
+ const [inputValue, setInputValue] = useState5(value ? toBasicISOString2(value) : "");
2784
2793
  useEffect5(() => {
2785
2794
  const isSelecting = isDatePickerOpen || isInputFocused;
2786
2795
  if (isSelecting) {
@@ -3223,10 +3232,19 @@ var RecordArrayField = memo(function RecordArrayField2({
3223
3232
  setValue: setArrayValue,
3224
3233
  value: arrayValue
3225
3234
  }) {
3235
+ const fieldsetRef = useRef4(fieldset);
3226
3236
  const { t } = useTranslation("libui");
3227
3237
  const createNewRecord = () => Object.fromEntries(Object.keys(fieldset).map((fieldName) => [fieldName, void 0]));
3228
3238
  useEffect8(() => {
3229
- setArrayValue([createNewRecord()]);
3239
+ if (!arrayValue) {
3240
+ setArrayValue([createNewRecord()]);
3241
+ }
3242
+ }, []);
3243
+ useEffect8(() => {
3244
+ if (fieldsetRef.current !== fieldset) {
3245
+ setArrayValue([createNewRecord()]);
3246
+ fieldsetRef.current = fieldset;
3247
+ }
3230
3248
  }, [fieldset]);
3231
3249
  if (!arrayValue) {
3232
3250
  return null;