@douglasneuroinformatics/libui 3.7.4 → 3.7.5
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/components.js +12 -4
- package/dist/components.js.map +1 -1
- package/dist/douglasneuroinformatics-libui-3.7.5.tgz +0 -0
- package/package.json +1 -1
- package/src/components/Form/Form.stories.tsx +15 -3
- package/src/components/Form/NumberRecordField.tsx +7 -2
- package/src/components/Form/RecordArrayField.tsx +6 -2
- package/dist/douglasneuroinformatics-libui-3.7.4.tgz +0 -0
package/dist/components.js
CHANGED
|
@@ -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,12 @@ var NumberRecordField = ({
|
|
|
2633
2633
|
setValue: setRecordValue,
|
|
2634
2634
|
value: recordValue
|
|
2635
2635
|
}) => {
|
|
2636
|
+
const isFirstRenderRef = useRef3(true);
|
|
2636
2637
|
useEffect4(() => {
|
|
2637
|
-
|
|
2638
|
+
if (isFirstRenderRef.current && !recordValue || !isFirstRenderRef.current) {
|
|
2639
|
+
setRecordValue({});
|
|
2640
|
+
}
|
|
2641
|
+
isFirstRenderRef.current = false;
|
|
2638
2642
|
}, [options]);
|
|
2639
2643
|
if (!recordValue) {
|
|
2640
2644
|
return null;
|
|
@@ -2664,7 +2668,7 @@ var NumberRecordField = ({
|
|
|
2664
2668
|
};
|
|
2665
2669
|
|
|
2666
2670
|
// src/components/Form/RecordArrayField.tsx
|
|
2667
|
-
import { memo, useEffect as useEffect8 } from "react";
|
|
2671
|
+
import { memo, useEffect as useEffect8, useRef as useRef4 } from "react";
|
|
2668
2672
|
import { MinusCircleIcon, PlusCircleIcon } from "lucide-react";
|
|
2669
2673
|
|
|
2670
2674
|
// src/components/Form/BooleanField/BooleanField.tsx
|
|
@@ -3223,10 +3227,14 @@ var RecordArrayField = memo(function RecordArrayField2({
|
|
|
3223
3227
|
setValue: setArrayValue,
|
|
3224
3228
|
value: arrayValue
|
|
3225
3229
|
}) {
|
|
3230
|
+
const isFirstRenderRef = useRef4(true);
|
|
3226
3231
|
const { t } = useTranslation("libui");
|
|
3227
3232
|
const createNewRecord = () => Object.fromEntries(Object.keys(fieldset).map((fieldName) => [fieldName, void 0]));
|
|
3228
3233
|
useEffect8(() => {
|
|
3229
|
-
|
|
3234
|
+
if (isFirstRenderRef.current && !arrayValue || !isFirstRenderRef.current) {
|
|
3235
|
+
setArrayValue([createNewRecord()]);
|
|
3236
|
+
}
|
|
3237
|
+
isFirstRenderRef.current = false;
|
|
3230
3238
|
}, [fieldset]);
|
|
3231
3239
|
if (!arrayValue) {
|
|
3232
3240
|
return null;
|