@wix/form-public 0.36.0 → 0.38.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/_tsup-dts-rollup.d.cts +1 -1
- package/dist/_tsup-dts-rollup.d.ts +1 -1
- package/dist/index.cjs +90 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +90 -62
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1293,7 +1293,7 @@ export { PhoneInputProps as PhoneInputProps_alias_1 }
|
|
|
1293
1293
|
|
|
1294
1294
|
export declare type PossibleValues = ValueType | {
|
|
1295
1295
|
[target: string]: ValueType;
|
|
1296
|
-
};
|
|
1296
|
+
} | FormValues[];
|
|
1297
1297
|
|
|
1298
1298
|
export declare const ProductListMapper: PropsMapper;
|
|
1299
1299
|
|
|
@@ -1293,7 +1293,7 @@ export { PhoneInputProps as PhoneInputProps_alias_1 }
|
|
|
1293
1293
|
|
|
1294
1294
|
export declare type PossibleValues = ValueType | {
|
|
1295
1295
|
[target: string]: ValueType;
|
|
1296
|
-
};
|
|
1296
|
+
} | FormValues[];
|
|
1297
1297
|
|
|
1298
1298
|
export declare const ProductListMapper: PropsMapper;
|
|
1299
1299
|
|
package/dist/index.cjs
CHANGED
|
@@ -20463,7 +20463,8 @@ var IDENTITY_FIELD_TYPES = {
|
|
|
20463
20463
|
IDENTITY_PASSWORD: "IDENTITY_PASSWORD"
|
|
20464
20464
|
};
|
|
20465
20465
|
var EVENTS_FIELD_TYPES = {
|
|
20466
|
-
EVENTS_RSVP: "EVENTS_RSVP"
|
|
20466
|
+
EVENTS_RSVP: "EVENTS_RSVP",
|
|
20467
|
+
EVENTS_REPEATER: "EVENTS_REPEATER"
|
|
20467
20468
|
};
|
|
20468
20469
|
var INPUT_FIELD_TYPES = {
|
|
20469
20470
|
...CONTACTS_FIELD_TYPES,
|
|
@@ -24409,10 +24410,6 @@ function useExternalData() {
|
|
|
24409
24410
|
}
|
|
24410
24411
|
return context;
|
|
24411
24412
|
}
|
|
24412
|
-
var FieldActionsContext = /* @__PURE__ */ React32.createContext({});
|
|
24413
|
-
function useFieldActions() {
|
|
24414
|
-
return React32.useContext(FieldActionsContext);
|
|
24415
|
-
}
|
|
24416
24413
|
var FormFieldsContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24417
24414
|
function useFormFields() {
|
|
24418
24415
|
const context = React32.useContext(FormFieldsContext);
|
|
@@ -24610,6 +24607,10 @@ var NestedFormField = (_ref) => {
|
|
|
24610
24607
|
|
|
24611
24608
|
// ../form-fields/dist/esm/ui/form/components/form/submit-button-field.js
|
|
24612
24609
|
var import_extends4 = __toESM(require_extends());
|
|
24610
|
+
var FieldActionsContext = /* @__PURE__ */ React32.createContext({});
|
|
24611
|
+
function useFieldActions() {
|
|
24612
|
+
return React32.useContext(FieldActionsContext);
|
|
24613
|
+
}
|
|
24613
24614
|
|
|
24614
24615
|
// ../form-fields/dist/esm/fields/submit-button/submit-button/utils.js
|
|
24615
24616
|
var getCurrentStep = (form, fieldId) => {
|
|
@@ -24778,11 +24779,17 @@ var createFormFields = (_ref) => {
|
|
|
24778
24779
|
onFieldChange,
|
|
24779
24780
|
FieldLayout,
|
|
24780
24781
|
formSchema,
|
|
24781
|
-
validateFields: validateFields2
|
|
24782
|
+
validateFields: validateFields2,
|
|
24783
|
+
fields,
|
|
24784
|
+
fieldActions
|
|
24782
24785
|
} = _ref;
|
|
24783
24786
|
return form.fields.map((formField) => {
|
|
24784
24787
|
const component = /* @__PURE__ */ React32__namespace.default.createElement(FormContext.Provider, {
|
|
24785
24788
|
value: formSchema
|
|
24789
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(FormFieldsContext.Provider, {
|
|
24790
|
+
value: fields
|
|
24791
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(FieldActionsContext.Provider, {
|
|
24792
|
+
value: fieldActions
|
|
24786
24793
|
}, /* @__PURE__ */ React32__namespace.default.createElement(FieldValidationContext.Provider, {
|
|
24787
24794
|
value: {
|
|
24788
24795
|
validateFields: validateFields2
|
|
@@ -24794,7 +24801,7 @@ var createFormFields = (_ref) => {
|
|
|
24794
24801
|
errors,
|
|
24795
24802
|
onFieldChange,
|
|
24796
24803
|
FieldLayout
|
|
24797
|
-
})));
|
|
24804
|
+
})))));
|
|
24798
24805
|
return {
|
|
24799
24806
|
id: formField.id,
|
|
24800
24807
|
fieldType: formField.fieldType,
|
|
@@ -24975,7 +24982,9 @@ var FormRoot = (_ref) => {
|
|
|
24975
24982
|
onFieldChange,
|
|
24976
24983
|
errors,
|
|
24977
24984
|
formSchema,
|
|
24978
|
-
validateFields: validateFields2
|
|
24985
|
+
validateFields: validateFields2,
|
|
24986
|
+
fields,
|
|
24987
|
+
fieldActions
|
|
24979
24988
|
} = _ref;
|
|
24980
24989
|
const {
|
|
24981
24990
|
isRTL
|
|
@@ -24987,7 +24996,9 @@ var FormRoot = (_ref) => {
|
|
|
24987
24996
|
errors,
|
|
24988
24997
|
FieldLayout: DefaultFieldLayout,
|
|
24989
24998
|
formSchema,
|
|
24990
|
-
validateFields: validateFields2
|
|
24999
|
+
validateFields: validateFields2,
|
|
25000
|
+
fields,
|
|
25001
|
+
fieldActions
|
|
24991
25002
|
});
|
|
24992
25003
|
return /* @__PURE__ */ React32__namespace.default.createElement(Grid, {
|
|
24993
25004
|
isRTL,
|
|
@@ -28473,7 +28484,8 @@ var ADDITIONAL_FIELD_VALIDATION = {
|
|
|
28473
28484
|
[FIELD_TYPES.IDENTITY_PASSWORD]: null,
|
|
28474
28485
|
[FIELD_TYPES.SERVICES_DROPDOWN]: null,
|
|
28475
28486
|
[FIELD_TYPES.SERVICES_MULTI_CHOICE]: null,
|
|
28476
|
-
[FIELD_TYPES.EVENTS_RSVP]: null
|
|
28487
|
+
[FIELD_TYPES.EVENTS_RSVP]: null,
|
|
28488
|
+
[FIELD_TYPES.EVENTS_REPEATER]: null
|
|
28477
28489
|
};
|
|
28478
28490
|
|
|
28479
28491
|
// ../form-viewer/dist/esm/services/get-field-errors.js
|
|
@@ -28862,7 +28874,8 @@ var NORMALIZED_VALUE = {
|
|
|
28862
28874
|
[FIELD_TYPES.IDENTITY_PASSWORD]: acceptStringValue,
|
|
28863
28875
|
[FIELD_TYPES.SERVICES_DROPDOWN]: acceptStringValue,
|
|
28864
28876
|
[FIELD_TYPES.SERVICES_MULTI_CHOICE]: removeInvalidOptions,
|
|
28865
|
-
[FIELD_TYPES.EVENTS_RSVP]: acceptOnlyValidOptionByValue
|
|
28877
|
+
[FIELD_TYPES.EVENTS_RSVP]: acceptOnlyValidOptionByValue,
|
|
28878
|
+
[FIELD_TYPES.EVENTS_REPEATER]: normalizeRepeater
|
|
28866
28879
|
};
|
|
28867
28880
|
function keepValueUnchanged({ fieldValue }) {
|
|
28868
28881
|
return fieldValue;
|
|
@@ -29036,6 +29049,27 @@ function acceptOnlyValidPayments({ field, fieldValue }) {
|
|
|
29036
29049
|
}
|
|
29037
29050
|
return fieldValue;
|
|
29038
29051
|
}
|
|
29052
|
+
function normalizeRepeater({ field, fieldValue, config }) {
|
|
29053
|
+
const isEmptyValue = fieldValue === EMPTY_VALUE;
|
|
29054
|
+
const nestedFields = field.view?.fields;
|
|
29055
|
+
if (isEmptyValue) {
|
|
29056
|
+
return fieldValue;
|
|
29057
|
+
}
|
|
29058
|
+
if (!Array.isArray(fieldValue) || !nestedFields) {
|
|
29059
|
+
return EMPTY_VALUE;
|
|
29060
|
+
}
|
|
29061
|
+
const nestedForm = {
|
|
29062
|
+
fields: nestedFields
|
|
29063
|
+
};
|
|
29064
|
+
const normalizedValues = fieldValue.map((values) => {
|
|
29065
|
+
if (!isObject5(values)) {
|
|
29066
|
+
return {};
|
|
29067
|
+
}
|
|
29068
|
+
const normalized = normalizeValues(nestedForm, values, false, config);
|
|
29069
|
+
return Object.fromEntries(Object.entries(normalized).filter(([_23, value]) => value !== EMPTY_VALUE));
|
|
29070
|
+
});
|
|
29071
|
+
return normalizedValues;
|
|
29072
|
+
}
|
|
29039
29073
|
|
|
29040
29074
|
// ../form-viewer/dist/esm/components/form/use-form-values.js
|
|
29041
29075
|
var useFormValues = (form, values, onChange, config) => {
|
|
@@ -29493,7 +29527,8 @@ var FormRoot2 = ({
|
|
|
29493
29527
|
config,
|
|
29494
29528
|
breakpoint,
|
|
29495
29529
|
onStatusChange,
|
|
29496
|
-
validationMode
|
|
29530
|
+
validationMode,
|
|
29531
|
+
fields
|
|
29497
29532
|
}) => {
|
|
29498
29533
|
const formWithOverrides = React32.useMemo(() => applyAllOverrides(unprocessedForm, unprocessedValues, overrides), [unprocessedForm, unprocessedValues, overrides]);
|
|
29499
29534
|
const formId = formWithOverrides.id;
|
|
@@ -29614,18 +29649,14 @@ var FormRoot2 = ({
|
|
|
29614
29649
|
return null;
|
|
29615
29650
|
}
|
|
29616
29651
|
return React32__namespace.default.createElement(
|
|
29617
|
-
|
|
29618
|
-
{
|
|
29652
|
+
FormStatusProvider,
|
|
29653
|
+
{ onStatusChange },
|
|
29619
29654
|
React32__namespace.default.createElement(
|
|
29620
|
-
|
|
29621
|
-
{
|
|
29622
|
-
React32__namespace.default.createElement(
|
|
29623
|
-
|
|
29624
|
-
|
|
29625
|
-
React32__namespace.default.createElement(Form, { formSchema: formWithOverrides, form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT, validateFields: handleFieldValidation }),
|
|
29626
|
-
React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29627
|
-
React32__namespace.default.createElement(SubmitStatusMessage, null)
|
|
29628
|
-
)
|
|
29655
|
+
"div",
|
|
29656
|
+
{ "data-hook": DATA_HOOKS.FORM_ROOT },
|
|
29657
|
+
React32__namespace.default.createElement(Form, { formSchema: formWithOverrides, form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT, validateFields: handleFieldValidation, fields, fieldActions }),
|
|
29658
|
+
React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29659
|
+
React32__namespace.default.createElement(SubmitStatusMessage, null)
|
|
29629
29660
|
)
|
|
29630
29661
|
);
|
|
29631
29662
|
};
|
|
@@ -29666,7 +29697,7 @@ var useFormBi = (form, bi, biFormFillSessionId) => {
|
|
|
29666
29697
|
};
|
|
29667
29698
|
|
|
29668
29699
|
// ../form-viewer/dist/esm/components/root/form-viewer-provider.js
|
|
29669
|
-
var FormViewerProvider = ({ i18n: i18n2, bi, biFormFillSessionId, form, isMobile, isEditor, isComposer, isRTL, compId, locale, regionalFormat, externalData,
|
|
29700
|
+
var FormViewerProvider = ({ i18n: i18n2, bi, biFormFillSessionId, form, isMobile, isEditor, isComposer, isRTL, compId, locale, regionalFormat, externalData, forcedState, instance, children, httpClient, panorama, experiments, translationNamespace, currency, userData, WixRicosViewer, addressTemplates, atlasBaseUrl, fieldInitialData, enableAnimations }) => {
|
|
29670
29701
|
const translations = React32.useMemo(() => ({
|
|
29671
29702
|
t: i18n2.getFixedT(locale, translationNamespace),
|
|
29672
29703
|
i18n: i18n2
|
|
@@ -29701,58 +29732,54 @@ var FormViewerProvider = ({ i18n: i18n2, bi, biFormFillSessionId, form, isMobile
|
|
|
29701
29732
|
]);
|
|
29702
29733
|
const forcedViewState = React32.useMemo(() => forcedState ?? [], [forcedState]);
|
|
29703
29734
|
return React32__namespace.default.createElement(
|
|
29704
|
-
|
|
29705
|
-
{ value:
|
|
29735
|
+
HttpClientContext.Provider,
|
|
29736
|
+
{ value: { httpClient } },
|
|
29706
29737
|
React32__namespace.default.createElement(
|
|
29707
|
-
|
|
29708
|
-
{ value: {
|
|
29738
|
+
PanoramaContext.Provider,
|
|
29739
|
+
{ value: { panorama } },
|
|
29709
29740
|
React32__namespace.default.createElement(
|
|
29710
|
-
|
|
29711
|
-
{ value:
|
|
29741
|
+
TranslationContext.Provider,
|
|
29742
|
+
{ value: translations },
|
|
29712
29743
|
React32__namespace.default.createElement(
|
|
29713
|
-
|
|
29714
|
-
|
|
29744
|
+
ScrollProvider,
|
|
29745
|
+
null,
|
|
29715
29746
|
React32__namespace.default.createElement(
|
|
29716
|
-
|
|
29747
|
+
FocusedFieldProvider,
|
|
29717
29748
|
null,
|
|
29718
29749
|
React32__namespace.default.createElement(
|
|
29719
|
-
|
|
29720
|
-
|
|
29750
|
+
FieldInitialDataContext.Provider,
|
|
29751
|
+
{ value: fieldInitialData },
|
|
29721
29752
|
React32__namespace.default.createElement(
|
|
29722
|
-
|
|
29723
|
-
{ value:
|
|
29753
|
+
BiContext.Provider,
|
|
29754
|
+
{ value: formBi },
|
|
29724
29755
|
React32__namespace.default.createElement(
|
|
29725
|
-
|
|
29726
|
-
{
|
|
29756
|
+
ExternalDataProvider,
|
|
29757
|
+
{ externalData },
|
|
29727
29758
|
React32__namespace.default.createElement(
|
|
29728
|
-
|
|
29729
|
-
{
|
|
29759
|
+
ConfigContext.Provider,
|
|
29760
|
+
{ value: config },
|
|
29730
29761
|
React32__namespace.default.createElement(
|
|
29731
|
-
|
|
29732
|
-
{ value:
|
|
29762
|
+
ForcedStateContext.Provider,
|
|
29763
|
+
{ value: forcedViewState },
|
|
29733
29764
|
React32__namespace.default.createElement(
|
|
29734
|
-
|
|
29735
|
-
{ value:
|
|
29765
|
+
FormContext.Provider,
|
|
29766
|
+
{ value: form },
|
|
29736
29767
|
React32__namespace.default.createElement(
|
|
29737
|
-
|
|
29738
|
-
{ value:
|
|
29768
|
+
AddressFormsContext.Provider,
|
|
29769
|
+
{ value: {
|
|
29770
|
+
getCountryAddressForm: (country) => getAddressForm(addressTemplates, country),
|
|
29771
|
+
addressTemplates
|
|
29772
|
+
} },
|
|
29739
29773
|
React32__namespace.default.createElement(
|
|
29740
|
-
|
|
29741
|
-
{ value:
|
|
29742
|
-
getCountryAddressForm: (country) => getAddressForm(addressTemplates, country),
|
|
29743
|
-
addressTemplates
|
|
29744
|
-
} },
|
|
29774
|
+
ExperimentsContext.Provider,
|
|
29775
|
+
{ value: experiments },
|
|
29745
29776
|
React32__namespace.default.createElement(
|
|
29746
|
-
|
|
29747
|
-
|
|
29777
|
+
EventsProvider,
|
|
29778
|
+
null,
|
|
29748
29779
|
React32__namespace.default.createElement(
|
|
29749
|
-
|
|
29750
|
-
|
|
29751
|
-
React32__namespace.default.createElement(
|
|
29752
|
-
WixRicosViewerContext.Provider,
|
|
29753
|
-
{ value: WixRicosViewer },
|
|
29754
|
-
React32__namespace.default.createElement(SubmitStatusProvider, null, children)
|
|
29755
|
-
)
|
|
29780
|
+
WixRicosViewerContext.Provider,
|
|
29781
|
+
{ value: WixRicosViewer },
|
|
29782
|
+
React32__namespace.default.createElement(SubmitStatusProvider, null, children)
|
|
29756
29783
|
)
|
|
29757
29784
|
)
|
|
29758
29785
|
)
|
|
@@ -29824,7 +29851,7 @@ var FormViewerStatic = React32.forwardRef(({ form, i18n: i18n2, isMobile, isRTL,
|
|
|
29824
29851
|
React32__namespace.default.createElement(
|
|
29825
29852
|
"fieldset",
|
|
29826
29853
|
{ className: form_viewer_static_module_default.fieldsetReset, disabled: readOnly || isDisabled },
|
|
29827
|
-
React32__namespace.default.createElement(FormRoot2, { form: formWithValidSteps, forwardedRef, config, breakpoint, ...rest })
|
|
29854
|
+
React32__namespace.default.createElement(FormRoot2, { form: formWithValidSteps, fields, forwardedRef, config, breakpoint, ...rest })
|
|
29828
29855
|
)
|
|
29829
29856
|
)
|
|
29830
29857
|
)
|
|
@@ -30119,6 +30146,7 @@ var FIELD_TYPE_MAP = {
|
|
|
30119
30146
|
// EVENTS_FIELD_TYPES
|
|
30120
30147
|
EVENTS_RSVP: "RADIO_GROUP",
|
|
30121
30148
|
EVENTS_HEADER: "TEXT",
|
|
30149
|
+
EVENTS_REPEATER: "TEXT",
|
|
30122
30150
|
// COMMON_FIELD_TYPES + READONLY
|
|
30123
30151
|
TEXT_INPUT: "TEXT_INPUT",
|
|
30124
30152
|
NUMBER_INPUT: "NUMBER_INPUT",
|