@trackunit/react-form-wizard 0.1.65 → 0.1.68

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/index.cjs.js CHANGED
@@ -275,12 +275,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
275
275
  });
276
276
  setSubmitHandlerInternal(() => wrappedCallbackFunction);
277
277
  }, [setSubmitHandlerInternal]);
278
- const isEmptyStep = sharedUtils.objectKeys(form.getValues()).length === 0;
279
- const emptyStepSubmitHandler = react.useCallback((e) => {
280
- e === null || e === void 0 ? void 0 : e.preventDefault();
281
- submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(fullFormState);
282
- }, [fullFormState, submitHandlerInternal]);
283
- const nonEmptyStepSubmitHandler = react.useMemo(() => form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
278
+ const stepSubmitHandler = react.useMemo(() => form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
284
279
  //? This state is not updated for the submit handler below; therefore, there is duplication.
285
280
  setFullFormState(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: data })));
286
281
  if (isLastStep) {
@@ -301,8 +296,10 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
301
296
  stepKey,
302
297
  submitHandlerInternal,
303
298
  ]);
304
- const handleSubmit = react.useMemo(() => (isEmptyStep ? emptyStepSubmitHandler : nonEmptyStepSubmitHandler), [emptyStepSubmitHandler, isEmptyStep, nonEmptyStepSubmitHandler]);
305
- return (jsxRuntime.jsxs("form", { className: cvaFormWizardComponentStepForm(), onSubmit: handleSubmit, ref: formRef, children: [jsxRuntime.jsx(FormWizardHeader, { title, description }), jsxRuntime.jsx("div", { className: cvaFormWizardComponentContainer({ className: containerClassName }), children: component({
299
+ return (jsxRuntime.jsxs("form", { className: cvaFormWizardComponentStepForm(), noValidate: true, onSubmit: e => {
300
+ e.preventDefault();
301
+ stepSubmitHandler();
302
+ }, ref: formRef, children: [jsxRuntime.jsx(FormWizardHeader, { title, description }), jsxRuntime.jsx("div", { className: cvaFormWizardComponentContainer({ className: containerClassName }), children: component({
306
303
  form,
307
304
  fullForm,
308
305
  setSubmitHandler: isLastStep ? setSubmitHandler : null,
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
3
  import { Link, useNavigate, useParams } from '@tanstack/react-router';
4
- import { objectKeys, objectFromEntries, objectEntries, objectValues } from '@trackunit/shared-utils';
4
+ import { objectFromEntries, objectEntries, objectKeys, objectValues } from '@trackunit/shared-utils';
5
5
  import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
6
6
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
7
7
  import { Icon, Button, Heading } from '@trackunit/react-components';
@@ -271,12 +271,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
271
271
  });
272
272
  setSubmitHandlerInternal(() => wrappedCallbackFunction);
273
273
  }, [setSubmitHandlerInternal]);
274
- const isEmptyStep = objectKeys(form.getValues()).length === 0;
275
- const emptyStepSubmitHandler = useCallback((e) => {
276
- e === null || e === void 0 ? void 0 : e.preventDefault();
277
- submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(fullFormState);
278
- }, [fullFormState, submitHandlerInternal]);
279
- const nonEmptyStepSubmitHandler = useMemo(() => form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
274
+ const stepSubmitHandler = useMemo(() => form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
280
275
  //? This state is not updated for the submit handler below; therefore, there is duplication.
281
276
  setFullFormState(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: data })));
282
277
  if (isLastStep) {
@@ -297,8 +292,10 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
297
292
  stepKey,
298
293
  submitHandlerInternal,
299
294
  ]);
300
- const handleSubmit = useMemo(() => (isEmptyStep ? emptyStepSubmitHandler : nonEmptyStepSubmitHandler), [emptyStepSubmitHandler, isEmptyStep, nonEmptyStepSubmitHandler]);
301
- return (jsxs("form", { className: cvaFormWizardComponentStepForm(), onSubmit: handleSubmit, ref: formRef, children: [jsx(FormWizardHeader, { title, description }), jsx("div", { className: cvaFormWizardComponentContainer({ className: containerClassName }), children: component({
295
+ return (jsxs("form", { className: cvaFormWizardComponentStepForm(), noValidate: true, onSubmit: e => {
296
+ e.preventDefault();
297
+ stepSubmitHandler();
298
+ }, ref: formRef, children: [jsx(FormWizardHeader, { title, description }), jsx("div", { className: cvaFormWizardComponentContainer({ className: containerClassName }), children: component({
302
299
  form,
303
300
  fullForm,
304
301
  setSubmitHandler: isLastStep ? setSubmitHandler : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-wizard",
3
- "version": "0.1.65",
3
+ "version": "0.1.68",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {