@douglasneuroinformatics/libui 2.4.3 → 2.4.4

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.
@@ -9,11 +9,11 @@ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<T
9
9
  initialValues?: PartialNullableFormDataType<TData>;
10
10
  onError?: (error: z.ZodError<TData>) => void;
11
11
  onSubmit: (data: TData) => void;
12
+ preventResetValuesOnReset?: boolean;
12
13
  resetBtn?: boolean;
13
14
  submitBtnLabel?: string;
14
- useInitialValuesOnReset?: boolean;
15
15
  validationSchema: z.ZodType<TData>;
16
16
  };
17
- declare const Form: <TSchema extends z.ZodType<FormDataType, z.ZodTypeDef, FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>>({ className, content, id, initialValues, onError, onSubmit, resetBtn, submitBtnLabel, useInitialValuesOnReset, validationSchema, ...props }: FormProps<TSchema, TData>) => React.JSX.Element;
17
+ declare const Form: <TSchema extends z.ZodType<FormDataType, z.ZodTypeDef, FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>>({ className, content, id, initialValues, onError, onSubmit, preventResetValuesOnReset, resetBtn, submitBtnLabel, validationSchema, ...props }: FormProps<TSchema, TData>) => React.JSX.Element;
18
18
  export { Form, type FormProps };
19
19
  //# sourceMappingURL=Form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAGZ,2BAA2B,EAC5B,MAAM,2CAA2C,CAAC;AAInD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,KAAK,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,OAA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AAM,EAAE,GAAG,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,2BAA2B,CAAC,KAAK,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC7C,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,QAAA,MAAM,IAAI,4QAYP,UAAU,OAAO,EAAE,KAAK,CAAC,sBAkG3B,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC"}
@@ -8,7 +8,7 @@ import { Heading } from '../Heading/Heading.js';
8
8
  import { ErrorMessage } from './ErrorMessage.js';
9
9
  import { FieldsComponent } from './FieldsComponent.js';
10
10
  import { getInitialValues } from './utils.js';
11
- const Form = ({ className, content, id, initialValues, onError, onSubmit, resetBtn, submitBtnLabel, useInitialValuesOnReset, validationSchema, ...props }) => {
11
+ const Form = ({ className, content, id, initialValues, onError, onSubmit, preventResetValuesOnReset, resetBtn, submitBtnLabel, validationSchema, ...props }) => {
12
12
  const { t } = useTranslation('libui');
13
13
  const [rootError, setRootError] = useState(null);
14
14
  const [errors, setErrors] = useState({});
@@ -33,10 +33,7 @@ const Form = ({ className, content, id, initialValues, onError, onSubmit, resetB
33
33
  const reset = () => {
34
34
  setRootError(null);
35
35
  setErrors({});
36
- if (useInitialValuesOnReset && initialValues) {
37
- setValues(getInitialValues(initialValues));
38
- }
39
- else {
36
+ if (!preventResetValuesOnReset) {
40
37
  setValues({});
41
38
  }
42
39
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@douglasneuroinformatics/libui",
3
3
  "type": "module",
4
- "version": "2.4.3",
4
+ "version": "2.4.4",
5
5
  "packageManager": "pnpm@8.15.3",
6
6
  "description": "Generic UI components for DNP projects, built using React and TailwindCSS",
7
7
  "author": {
@@ -28,9 +28,9 @@ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<T
28
28
  initialValues?: PartialNullableFormDataType<TData>;
29
29
  onError?: (error: z.ZodError<TData>) => void;
30
30
  onSubmit: (data: TData) => void;
31
+ preventResetValuesOnReset?: boolean;
31
32
  resetBtn?: boolean;
32
33
  submitBtnLabel?: string;
33
- useInitialValuesOnReset?: boolean;
34
34
  validationSchema: z.ZodType<TData>;
35
35
  };
36
36
 
@@ -41,9 +41,9 @@ const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TS
41
41
  initialValues,
42
42
  onError,
43
43
  onSubmit,
44
+ preventResetValuesOnReset,
44
45
  resetBtn,
45
46
  submitBtnLabel,
46
- useInitialValuesOnReset,
47
47
  validationSchema,
48
48
  ...props
49
49
  }: FormProps<TSchema, TData>) => {
@@ -74,9 +74,7 @@ const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TS
74
74
  const reset = () => {
75
75
  setRootError(null);
76
76
  setErrors({});
77
- if (useInitialValuesOnReset && initialValues) {
78
- setValues(getInitialValues(initialValues));
79
- } else {
77
+ if (!preventResetValuesOnReset) {
80
78
  setValues({});
81
79
  }
82
80
  };