@wix/form-public 0.555.0 → 0.557.0

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/index.cjs CHANGED
@@ -38675,6 +38675,8 @@ var INPUT_FIELD_TYPES = {
38675
38675
  ...COMMON_FIELD_TYPES,
38676
38676
  ...EVENTS_FIELD_TYPES
38677
38677
  };
38678
+ var INPUT_FIELD_TYPE_VALUES = Object.values(INPUT_FIELD_TYPES);
38679
+ var isInputFieldType = (fieldType) => fieldType && INPUT_FIELD_TYPE_VALUES.includes(fieldType);
38678
38680
 
38679
38681
  // ../form-fields/dist/esm/constants/readonly-field-types.js
38680
38682
  var READONLY_FIELD_TYPES = {
@@ -51319,7 +51321,7 @@ var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
51319
51321
  };
51320
51322
 
51321
51323
  // ../form-viewer/dist/esm/hooks/use-form.js
51322
- var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange, onChange, onBlur, onFocus, errors, onValidate, onSubmit, onSubmitSuccess, onSubmitFailure, enableScrollToFirstError = true, forwardedRef, overrides, actions, userData, addressTemplates, breakpoint, validationMode, fieldMap, inProgress, enableAutofill, onSubmissionLimitReached }) => {
51324
+ var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange, onChange, onBlur, onFocus, errors, onValidate, onSubmit, onSubmitSuccess, onSubmitFailure, enableScrollToFirstError = true, forwardedRef, overrides, actions, userData, addressTemplates, breakpoint, validationMode, fieldMap, inProgress, enableAutofill, onSubmissionLimitReached, onStepNavigation }) => {
51323
51325
  const formWithOverrides = React172.useMemo(() => applyAllOverrides(paramForm, paramValues, overrides), [
51324
51326
  paramForm,
51325
51327
  paramValues,
@@ -51365,11 +51367,12 @@ var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange,
51365
51367
  const handleStepChange = React172.useCallback((step) => {
51366
51368
  const newStepId = formWithOverrides.steps?.[step]?.id;
51367
51369
  if (newStepId) {
51368
- const firstFieldInStep = getSortedFields(formWithOverrides, {
51369
- stepId: newStepId
51370
+ const firstInputFieldInStep = getSortedFields(formWithOverrides, {
51371
+ stepId: newStepId,
51372
+ filter: (field) => !field?.hidden && !field?.view?.disabled && !!isInputFieldType(field?.view?.fieldType)
51370
51373
  })[0];
51371
51374
  onStepIdChange?.(newStepId);
51372
- setFocusedFieldId(firstFieldInStep?.id);
51375
+ setFocusedFieldId(firstInputFieldInStep?.id);
51373
51376
  }
51374
51377
  }, [
51375
51378
  formWithOverrides,
@@ -51444,13 +51447,21 @@ var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange,
51444
51447
  scrollToFirstError
51445
51448
  ]);
51446
51449
  const currentStep = getStepIndex(stepId, formWithOverrides.steps);
51447
- const setNextStep = React172.useCallback(() => handleStepChange(currentStep + 1), [
51450
+ const setNextStep = React172.useCallback(() => {
51451
+ onStepNavigation?.();
51452
+ handleStepChange(currentStep + 1);
51453
+ }, [
51448
51454
  currentStep,
51449
- handleStepChange
51455
+ handleStepChange,
51456
+ onStepNavigation
51450
51457
  ]);
51451
- const setPreviousStep = React172.useCallback(() => handleStepChange(currentStep - 1), [
51458
+ const setPreviousStep = React172.useCallback(() => {
51459
+ onStepNavigation?.();
51460
+ handleStepChange(currentStep - 1);
51461
+ }, [
51452
51462
  currentStep,
51453
- handleStepChange
51463
+ handleStepChange,
51464
+ onStepNavigation
51454
51465
  ]);
51455
51466
  const fieldActions = React172.useMemo(() => actions ? {
51456
51467
  actions: {