@wix/form-public 0.555.0 → 0.556.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 +19 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +23 -5
- package/dist/index.css.map +1 -1
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -38665,6 +38665,8 @@ var INPUT_FIELD_TYPES = {
|
|
|
38665
38665
|
...COMMON_FIELD_TYPES,
|
|
38666
38666
|
...EVENTS_FIELD_TYPES
|
|
38667
38667
|
};
|
|
38668
|
+
var INPUT_FIELD_TYPE_VALUES = Object.values(INPUT_FIELD_TYPES);
|
|
38669
|
+
var isInputFieldType = (fieldType) => fieldType && INPUT_FIELD_TYPE_VALUES.includes(fieldType);
|
|
38668
38670
|
|
|
38669
38671
|
// ../form-fields/dist/esm/constants/readonly-field-types.js
|
|
38670
38672
|
var READONLY_FIELD_TYPES = {
|
|
@@ -51309,7 +51311,7 @@ var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
|
51309
51311
|
};
|
|
51310
51312
|
|
|
51311
51313
|
// ../form-viewer/dist/esm/hooks/use-form.js
|
|
51312
|
-
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 }) => {
|
|
51314
|
+
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 }) => {
|
|
51313
51315
|
const formWithOverrides = useMemo(() => applyAllOverrides(paramForm, paramValues, overrides), [
|
|
51314
51316
|
paramForm,
|
|
51315
51317
|
paramValues,
|
|
@@ -51355,11 +51357,12 @@ var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange,
|
|
|
51355
51357
|
const handleStepChange = useCallback((step) => {
|
|
51356
51358
|
const newStepId = formWithOverrides.steps?.[step]?.id;
|
|
51357
51359
|
if (newStepId) {
|
|
51358
|
-
const
|
|
51359
|
-
stepId: newStepId
|
|
51360
|
+
const firstInputFieldInStep = getSortedFields(formWithOverrides, {
|
|
51361
|
+
stepId: newStepId,
|
|
51362
|
+
filter: (field) => !field?.hidden && !field?.view?.disabled && !!isInputFieldType(field?.view?.fieldType)
|
|
51360
51363
|
})[0];
|
|
51361
51364
|
onStepIdChange?.(newStepId);
|
|
51362
|
-
setFocusedFieldId(
|
|
51365
|
+
setFocusedFieldId(firstInputFieldInStep?.id);
|
|
51363
51366
|
}
|
|
51364
51367
|
}, [
|
|
51365
51368
|
formWithOverrides,
|
|
@@ -51434,13 +51437,21 @@ var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange,
|
|
|
51434
51437
|
scrollToFirstError
|
|
51435
51438
|
]);
|
|
51436
51439
|
const currentStep = getStepIndex(stepId, formWithOverrides.steps);
|
|
51437
|
-
const setNextStep = useCallback(() =>
|
|
51440
|
+
const setNextStep = useCallback(() => {
|
|
51441
|
+
onStepNavigation?.();
|
|
51442
|
+
handleStepChange(currentStep + 1);
|
|
51443
|
+
}, [
|
|
51438
51444
|
currentStep,
|
|
51439
|
-
handleStepChange
|
|
51445
|
+
handleStepChange,
|
|
51446
|
+
onStepNavigation
|
|
51440
51447
|
]);
|
|
51441
|
-
const setPreviousStep = useCallback(() =>
|
|
51448
|
+
const setPreviousStep = useCallback(() => {
|
|
51449
|
+
onStepNavigation?.();
|
|
51450
|
+
handleStepChange(currentStep - 1);
|
|
51451
|
+
}, [
|
|
51442
51452
|
currentStep,
|
|
51443
|
-
handleStepChange
|
|
51453
|
+
handleStepChange,
|
|
51454
|
+
onStepNavigation
|
|
51444
51455
|
]);
|
|
51445
51456
|
const fieldActions = useMemo(() => actions ? {
|
|
51446
51457
|
actions: {
|