@douglasneuroinformatics/libui 3.7.5 → 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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@douglasneuroinformatics/libui",
3
3
  "type": "module",
4
- "version": "3.7.5",
4
+ "version": "3.7.6",
5
5
  "packageManager": "pnpm@9.14.2",
6
6
  "description": "Generic UI components for DNP projects, built using React and Tailwind CSS",
7
7
  "author": "Joshua Unrau",
@@ -69,7 +69,7 @@
69
69
  "zod": "^3.23.6"
70
70
  },
71
71
  "dependencies": {
72
- "@douglasneuroinformatics/libjs": "^0.8.0",
72
+ "@douglasneuroinformatics/libjs": "^1.1.0",
73
73
  "@douglasneuroinformatics/libui-form-types": "^0.11.0",
74
74
  "@radix-ui/react-accordion": "^1.2.1",
75
75
  "@radix-ui/react-alert-dialog": "^1.1.2",
@@ -19,7 +19,7 @@ export type DateFieldProps = Simplify<BaseFieldComponentProps<Date> & Omit<DateF
19
19
  export const DateField = ({ disabled, error, label, name, readOnly, setValue, value }: DateFieldProps) => {
20
20
  const [isDatePickerOpen, setIsDatePickerOpen] = useState(false);
21
21
  const [isInputFocused, setIsInputFocused] = useState(false);
22
- const [inputValue, setInputValue] = useState('');
22
+ const [inputValue, setInputValue] = useState(value ? toBasicISOString(value) : '');
23
23
 
24
24
  useEffect(() => {
25
25
  const isSelecting = isDatePickerOpen || isInputFocused;
@@ -27,13 +27,19 @@ export const NumberRecordField = <T extends NumberRecordFieldValue = NumberRecor
27
27
  setValue: setRecordValue,
28
28
  value: recordValue
29
29
  }: NumberRecordFieldProps<T>) => {
30
- const isFirstRenderRef = useRef(true);
30
+ const optionsRef = useRef(options);
31
31
 
32
32
  useEffect(() => {
33
- if ((isFirstRenderRef.current && !recordValue) || !isFirstRenderRef.current) {
33
+ if (!recordValue) {
34
34
  setRecordValue({});
35
35
  }
36
- isFirstRenderRef.current = false;
36
+ }, []);
37
+
38
+ useEffect(() => {
39
+ if (optionsRef.current !== options) {
40
+ setRecordValue({});
41
+ optionsRef.current = options;
42
+ }
37
43
  }, [options]);
38
44
 
39
45
  if (!recordValue) {
@@ -25,16 +25,22 @@ export const RecordArrayField = memo(function RecordArrayField({
25
25
  setValue: setArrayValue,
26
26
  value: arrayValue
27
27
  }: RecordArrayFieldProps) {
28
- const isFirstRenderRef = useRef(true);
28
+ const fieldsetRef = useRef(fieldset);
29
29
  const { t } = useTranslation('libui');
30
30
 
31
31
  const createNewRecord = () => Object.fromEntries(Object.keys(fieldset).map((fieldName) => [fieldName, undefined]));
32
32
 
33
33
  useEffect(() => {
34
- if ((isFirstRenderRef.current && !arrayValue) || !isFirstRenderRef.current) {
34
+ if (!arrayValue) {
35
35
  setArrayValue([createNewRecord()]);
36
36
  }
37
- isFirstRenderRef.current = false;
37
+ }, []);
38
+
39
+ useEffect(() => {
40
+ if (fieldsetRef.current !== fieldset) {
41
+ setArrayValue([createNewRecord()]);
42
+ fieldsetRef.current = fieldset;
43
+ }
38
44
  }, [fieldset]);
39
45
 
40
46
  if (!arrayValue) {