@wix/form-public 0.40.0 → 0.41.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 +1338 -1297
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1338 -1297
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15828,6 +15828,9 @@ var import_extends = __toESM(require_extends());
|
|
|
15828
15828
|
init_esm();
|
|
15829
15829
|
|
|
15830
15830
|
// ../../node_modules/@wix/bi-logger-forms-platform-uou/dist/esm/v2/index.js
|
|
15831
|
+
function formFieldEdit(params) {
|
|
15832
|
+
return { evid: 1002, src: 156, endpoint: "forms-platform-uou", params };
|
|
15833
|
+
}
|
|
15831
15834
|
function formFieldFocus(params) {
|
|
15832
15835
|
return { evid: 1004, src: 156, endpoint: "forms-platform-uou", params };
|
|
15833
15836
|
}
|
|
@@ -18548,180 +18551,662 @@ var validateBirthdate = (_ref) => {
|
|
|
18548
18551
|
return void 0;
|
|
18549
18552
|
};
|
|
18550
18553
|
|
|
18551
|
-
//
|
|
18552
|
-
var
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
function combineComparators(comparatorA, comparatorB) {
|
|
18556
|
-
return function isEqual(a, b, state) {
|
|
18557
|
-
return comparatorA(a, b, state) && comparatorB(a, b, state);
|
|
18558
|
-
};
|
|
18554
|
+
// ../form-viewer/dist/esm/services/utils.js
|
|
18555
|
+
var RATING_VALUES = [1, 2, 3, 4, 5];
|
|
18556
|
+
function isObject3(value) {
|
|
18557
|
+
return typeof value === "object" && !Array.isArray(value) && value !== null;
|
|
18559
18558
|
}
|
|
18560
|
-
function
|
|
18561
|
-
return
|
|
18562
|
-
if (!a || !b || typeof a !== "object" || typeof b !== "object") {
|
|
18563
|
-
return areItemsEqual(a, b, state);
|
|
18564
|
-
}
|
|
18565
|
-
var cache = state.cache;
|
|
18566
|
-
var cachedA = cache.get(a);
|
|
18567
|
-
var cachedB = cache.get(b);
|
|
18568
|
-
if (cachedA && cachedB) {
|
|
18569
|
-
return cachedA === b && cachedB === a;
|
|
18570
|
-
}
|
|
18571
|
-
cache.set(a, b);
|
|
18572
|
-
cache.set(b, a);
|
|
18573
|
-
var result2 = areItemsEqual(a, b, state);
|
|
18574
|
-
cache.delete(a);
|
|
18575
|
-
cache.delete(b);
|
|
18576
|
-
return result2;
|
|
18577
|
-
};
|
|
18559
|
+
function isString(value) {
|
|
18560
|
+
return typeof value === "string";
|
|
18578
18561
|
}
|
|
18579
|
-
function
|
|
18580
|
-
return
|
|
18562
|
+
function isNumber(value) {
|
|
18563
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
18581
18564
|
}
|
|
18582
|
-
|
|
18583
|
-
return
|
|
18584
|
-
});
|
|
18585
|
-
function sameValueZeroEqual(a, b) {
|
|
18586
|
-
return a === b || !a && !b && a !== a && b !== b;
|
|
18565
|
+
function isRating(value) {
|
|
18566
|
+
return typeof value === "number" && RATING_VALUES.includes(value);
|
|
18587
18567
|
}
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
var
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18568
|
+
|
|
18569
|
+
// ../form-viewer/dist/esm/services/has-multiline-address.js
|
|
18570
|
+
var hasMultilineAddress = (form, { excludeEcomAddress } = {
|
|
18571
|
+
excludeEcomAddress: false
|
|
18572
|
+
}) => {
|
|
18573
|
+
const fields = [...form?.fields || [], ...form?.deletedFields || []];
|
|
18574
|
+
return fields.some((field) => field.view?.fieldType === "MULTILINE_ADDRESS" || field.view?.fieldType === "BOOKINGS_ADDRESS" || !excludeEcomAddress && field.view?.fieldType === "ECOM_ADDRESS");
|
|
18575
|
+
};
|
|
18576
|
+
|
|
18577
|
+
// ../form-viewer/dist/esm/services/validation.js
|
|
18578
|
+
var removeFalsyValues = (values = {}) => {
|
|
18579
|
+
return Object.keys(values).reduce((withoutFalsy, target) => {
|
|
18580
|
+
const value = values[target];
|
|
18581
|
+
if (value === "" || typeof value === "undefined" || value === null) {
|
|
18582
|
+
return withoutFalsy;
|
|
18583
|
+
}
|
|
18584
|
+
if (Array.isArray(value) && !value.length) {
|
|
18585
|
+
return withoutFalsy;
|
|
18586
|
+
}
|
|
18587
|
+
if (isObject3(value)) {
|
|
18588
|
+
withoutFalsy[target] = removeFalsyValues(value);
|
|
18589
|
+
} else {
|
|
18590
|
+
withoutFalsy[target] = value;
|
|
18601
18591
|
}
|
|
18592
|
+
return withoutFalsy;
|
|
18593
|
+
}, {});
|
|
18594
|
+
};
|
|
18595
|
+
var getFormValidator = async (form, addressTemplates, validationMode) => {
|
|
18596
|
+
const [{ FormValidator: FormValidator2 }, { MultilineAddressToolkit: MultilineAddressToolkit2 }] = await Promise.all([
|
|
18597
|
+
Promise.resolve().then(() => (init_esm(), esm_exports)),
|
|
18598
|
+
Promise.resolve().then(() => (init_esm2(), esm_exports2))
|
|
18599
|
+
]);
|
|
18600
|
+
if (addressTemplates?.length) {
|
|
18601
|
+
const addressForms = addressTemplates.map((template) => template.template);
|
|
18602
|
+
const addressToolkit = new MultilineAddressToolkit2(addressForms);
|
|
18603
|
+
return new FormValidator2([form], validationMode, false, addressToolkit.getFormForValidation, addressToolkit.normalizeEmptyValues, true);
|
|
18602
18604
|
}
|
|
18603
|
-
return true;
|
|
18604
|
-
}
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
function areErrorsEqual(a, b) {
|
|
18609
|
-
return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
|
|
18610
|
-
}
|
|
18611
|
-
function areFunctionsEqual(a, b) {
|
|
18612
|
-
return a === b;
|
|
18613
|
-
}
|
|
18614
|
-
function areMapsEqual(a, b, state) {
|
|
18615
|
-
var size = a.size;
|
|
18616
|
-
if (size !== b.size) {
|
|
18617
|
-
return false;
|
|
18605
|
+
return new FormValidator2([form], validationMode, void 0, void 0, void 0, true);
|
|
18606
|
+
};
|
|
18607
|
+
var validate = async (form, values, addressTemplates, validationMode) => {
|
|
18608
|
+
if (!form.id) {
|
|
18609
|
+
return;
|
|
18618
18610
|
}
|
|
18619
|
-
|
|
18620
|
-
|
|
18611
|
+
const formValidator = await getFormValidator(form, addressTemplates, validationMode);
|
|
18612
|
+
return formValidator.validate(form.id, hasMultilineAddress(form, { excludeEcomAddress: true }) ? values : removeFalsyValues(values));
|
|
18613
|
+
};
|
|
18614
|
+
var validateFields = async (form, values, addressTemplates, validationMode) => {
|
|
18615
|
+
if (!form.id) {
|
|
18616
|
+
return;
|
|
18621
18617
|
}
|
|
18622
|
-
|
|
18623
|
-
|
|
18624
|
-
|
|
18625
|
-
|
|
18626
|
-
|
|
18627
|
-
|
|
18628
|
-
|
|
18629
|
-
|
|
18630
|
-
|
|
18631
|
-
|
|
18632
|
-
|
|
18633
|
-
|
|
18634
|
-
|
|
18635
|
-
|
|
18636
|
-
|
|
18618
|
+
const formValidator = await getFormValidator(form, addressTemplates, validationMode);
|
|
18619
|
+
return formValidator.validateFields(form.id, hasMultilineAddress(form) ? values : removeFalsyValues(values));
|
|
18620
|
+
};
|
|
18621
|
+
|
|
18622
|
+
// ../form-viewer/dist/esm/services/apply-nested-forms.js
|
|
18623
|
+
function applyNestedForms(form, nestedFormsById) {
|
|
18624
|
+
if (!form.nestedForms && !nestedFormsById) {
|
|
18625
|
+
return form;
|
|
18626
|
+
}
|
|
18627
|
+
const nestedFormsByTarget = getNestedFormsByTarget(form);
|
|
18628
|
+
return {
|
|
18629
|
+
...form,
|
|
18630
|
+
fields: form.fields?.map((field) => {
|
|
18631
|
+
const fieldTarget = field.target;
|
|
18632
|
+
if (!fieldTarget) {
|
|
18633
|
+
return field;
|
|
18637
18634
|
}
|
|
18638
|
-
|
|
18639
|
-
|
|
18640
|
-
|
|
18635
|
+
const nestedFormId = field.nestedFormId;
|
|
18636
|
+
if (!nestedFormId) {
|
|
18637
|
+
return field;
|
|
18641
18638
|
}
|
|
18642
|
-
|
|
18643
|
-
|
|
18644
|
-
|
|
18645
|
-
hasMatch = matchedIndices[matchIndex] = true;
|
|
18646
|
-
break;
|
|
18639
|
+
const nestedForm = nestedFormsByTarget?.[fieldTarget] ?? nestedFormsById?.[nestedFormId];
|
|
18640
|
+
if (nestedForm) {
|
|
18641
|
+
return { ...field, view: { ...field.view, form: nestedForm } };
|
|
18647
18642
|
}
|
|
18648
|
-
|
|
18649
|
-
}
|
|
18650
|
-
|
|
18651
|
-
return false;
|
|
18652
|
-
}
|
|
18653
|
-
index++;
|
|
18654
|
-
}
|
|
18655
|
-
return true;
|
|
18656
|
-
}
|
|
18657
|
-
var areNumbersEqual = sameValueZeroEqual;
|
|
18658
|
-
function areObjectsEqual(a, b, state) {
|
|
18659
|
-
var properties = keys(a);
|
|
18660
|
-
var index = properties.length;
|
|
18661
|
-
if (keys(b).length !== index) {
|
|
18662
|
-
return false;
|
|
18663
|
-
}
|
|
18664
|
-
while (index-- > 0) {
|
|
18665
|
-
if (!isPropertyEqual(a, b, state, properties[index])) {
|
|
18666
|
-
return false;
|
|
18667
|
-
}
|
|
18668
|
-
}
|
|
18669
|
-
return true;
|
|
18643
|
+
return field;
|
|
18644
|
+
})
|
|
18645
|
+
};
|
|
18670
18646
|
}
|
|
18671
|
-
function
|
|
18672
|
-
|
|
18673
|
-
|
|
18674
|
-
|
|
18675
|
-
return false;
|
|
18676
|
-
}
|
|
18677
|
-
var property;
|
|
18678
|
-
var descriptorA;
|
|
18679
|
-
var descriptorB;
|
|
18680
|
-
while (index-- > 0) {
|
|
18681
|
-
property = properties[index];
|
|
18682
|
-
if (!isPropertyEqual(a, b, state, property)) {
|
|
18683
|
-
return false;
|
|
18647
|
+
function getNestedFormsByTarget(form) {
|
|
18648
|
+
return form.nestedForms?.reduce((byTarget, { targets, form: nestedForm }) => {
|
|
18649
|
+
if (!nestedForm || !targets) {
|
|
18650
|
+
return byTarget;
|
|
18684
18651
|
}
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
if ((descriptorA || descriptorB) && (!descriptorA || !descriptorB || descriptorA.configurable !== descriptorB.configurable || descriptorA.enumerable !== descriptorB.enumerable || descriptorA.writable !== descriptorB.writable)) {
|
|
18688
|
-
return false;
|
|
18652
|
+
for (const target of targets) {
|
|
18653
|
+
byTarget[target] = nestedForm;
|
|
18689
18654
|
}
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
}
|
|
18693
|
-
function arePrimitiveWrappersEqual(a, b) {
|
|
18694
|
-
return sameValueZeroEqual(a.valueOf(), b.valueOf());
|
|
18655
|
+
return byTarget;
|
|
18656
|
+
}, {});
|
|
18695
18657
|
}
|
|
18696
|
-
function
|
|
18697
|
-
return
|
|
18658
|
+
function getNestedFormArray(formsByTarget) {
|
|
18659
|
+
return Object.keys(formsByTarget).map((target) => {
|
|
18660
|
+
return { targets: [target], form: formsByTarget[target] };
|
|
18661
|
+
});
|
|
18698
18662
|
}
|
|
18699
|
-
|
|
18700
|
-
|
|
18701
|
-
|
|
18702
|
-
|
|
18703
|
-
|
|
18704
|
-
|
|
18705
|
-
|
|
18706
|
-
}
|
|
18707
|
-
var matchedIndices = new Array(size);
|
|
18708
|
-
var aIterable = a.values();
|
|
18709
|
-
var aResult;
|
|
18710
|
-
var bResult;
|
|
18711
|
-
while (aResult = aIterable.next()) {
|
|
18712
|
-
if (aResult.done) {
|
|
18713
|
-
break;
|
|
18663
|
+
|
|
18664
|
+
// ../form-viewer/dist/esm/services/additional-field-validation.js
|
|
18665
|
+
var runAdditionalValidation = ({ form, values, externalData }) => {
|
|
18666
|
+
const additionalErrors = form.fields?.reduce((acc, field) => {
|
|
18667
|
+
const fieldTarget = field.target;
|
|
18668
|
+
if (!fieldTarget) {
|
|
18669
|
+
return acc;
|
|
18714
18670
|
}
|
|
18715
|
-
|
|
18716
|
-
|
|
18717
|
-
|
|
18718
|
-
|
|
18719
|
-
|
|
18720
|
-
|
|
18721
|
-
|
|
18722
|
-
|
|
18723
|
-
|
|
18724
|
-
|
|
18671
|
+
const fieldType = field?.view?.fieldType;
|
|
18672
|
+
const fieldValue = values[fieldTarget];
|
|
18673
|
+
const validateField = ADDITIONAL_FIELD_VALIDATION[fieldType];
|
|
18674
|
+
const error = validateField?.({
|
|
18675
|
+
value: fieldValue,
|
|
18676
|
+
target: fieldTarget,
|
|
18677
|
+
externalData
|
|
18678
|
+
});
|
|
18679
|
+
if (error) {
|
|
18680
|
+
acc[fieldTarget] = error;
|
|
18681
|
+
}
|
|
18682
|
+
return acc;
|
|
18683
|
+
}, {});
|
|
18684
|
+
return additionalErrors;
|
|
18685
|
+
};
|
|
18686
|
+
var ADDITIONAL_FIELD_VALIDATION = {
|
|
18687
|
+
[FIELD_TYPES.TEXT_INPUT]: null,
|
|
18688
|
+
[FIELD_TYPES.CHECKBOX_GROUP]: null,
|
|
18689
|
+
[FIELD_TYPES.RADIO_GROUP]: null,
|
|
18690
|
+
[FIELD_TYPES.DONATION]: null,
|
|
18691
|
+
[FIELD_TYPES.DROPDOWN]: null,
|
|
18692
|
+
[FIELD_TYPES.URL_INPUT]: null,
|
|
18693
|
+
[FIELD_TYPES.NUMBER_INPUT]: null,
|
|
18694
|
+
[FIELD_TYPES.QUIZ_NUMBER]: null,
|
|
18695
|
+
[FIELD_TYPES.QUIZ_SHORT_TEXT]: null,
|
|
18696
|
+
[FIELD_TYPES.QUIZ_LONG_TEXT]: null,
|
|
18697
|
+
[FIELD_TYPES.QUIZ_MULTI_CHOICE]: null,
|
|
18698
|
+
[FIELD_TYPES.QUIZ_IMAGE_CHOICE]: null,
|
|
18699
|
+
[FIELD_TYPES.QUIZ_SINGLE_CHOICE]: null,
|
|
18700
|
+
[FIELD_TYPES.QUIZ_FILE_UPLOAD]: null,
|
|
18701
|
+
[FIELD_TYPES.FILE_UPLOAD]: null,
|
|
18702
|
+
[FIELD_TYPES.SIGNATURE]: null,
|
|
18703
|
+
[FIELD_TYPES.CONTACTS_EMAIL]: null,
|
|
18704
|
+
[FIELD_TYPES.CONTACTS_PHONE]: null,
|
|
18705
|
+
[FIELD_TYPES.CHECKBOX]: null,
|
|
18706
|
+
[FIELD_TYPES.DATE_INPUT]: null,
|
|
18707
|
+
[FIELD_TYPES.DATE_TIME_INPUT]: null,
|
|
18708
|
+
[FIELD_TYPES.TIME_INPUT]: null,
|
|
18709
|
+
[FIELD_TYPES.DATE_PICKER]: null,
|
|
18710
|
+
[FIELD_TYPES.CONTACTS_COMPANY]: null,
|
|
18711
|
+
[FIELD_TYPES.CONTACTS_POSITION]: null,
|
|
18712
|
+
[FIELD_TYPES.CONTACTS_TAX_ID]: null,
|
|
18713
|
+
[FIELD_TYPES.CONTACTS_FIRST_NAME]: null,
|
|
18714
|
+
[FIELD_TYPES.CONTACTS_LAST_NAME]: null,
|
|
18715
|
+
[FIELD_TYPES.CONTACTS_ADDRESS]: null,
|
|
18716
|
+
[FIELD_TYPES.CONTACTS_BIRTHDATE]: validateBirthdate,
|
|
18717
|
+
[FIELD_TYPES.TEXT_AREA]: null,
|
|
18718
|
+
[FIELD_TYPES.CONTACTS_SUBSCRIBE]: null,
|
|
18719
|
+
[FIELD_TYPES.NESTED_FORM]: null,
|
|
18720
|
+
[FIELD_TYPES.MULTILINE_ADDRESS]: null,
|
|
18721
|
+
[FIELD_TYPES.MLA_COUNTRY]: null,
|
|
18722
|
+
[FIELD_TYPES.MLA_CITY]: null,
|
|
18723
|
+
[FIELD_TYPES.MLA_ADDRESS_LINE]: null,
|
|
18724
|
+
[FIELD_TYPES.MLA_ADDRESS_LINE_2]: null,
|
|
18725
|
+
[FIELD_TYPES.MLA_POSTAL_CODE]: null,
|
|
18726
|
+
[FIELD_TYPES.MLA_SUBDIVISION]: null,
|
|
18727
|
+
[FIELD_TYPES.MLA_STREET_NAME]: null,
|
|
18728
|
+
[FIELD_TYPES.MLA_STREET_NUMBER]: null,
|
|
18729
|
+
[FIELD_TYPES.MLA_APARTMENT]: null,
|
|
18730
|
+
[FIELD_TYPES.FULL_NAME_FIRST_NAME]: null,
|
|
18731
|
+
[FIELD_TYPES.FULL_NAME_LAST_NAME]: null,
|
|
18732
|
+
[FIELD_TYPES.FULL_NAME]: null,
|
|
18733
|
+
[FIELD_TYPES.DEXT_TEXT_INPUT]: null,
|
|
18734
|
+
[FIELD_TYPES.DEXT_NUMBER_INPUT]: null,
|
|
18735
|
+
[FIELD_TYPES.DEXT_CHECKBOX]: null,
|
|
18736
|
+
[FIELD_TYPES.DEXT_CHECKBOX_GROUP]: null,
|
|
18737
|
+
[FIELD_TYPES.DEXT_TAGS]: null,
|
|
18738
|
+
[FIELD_TYPES.DEXT_RATING_INPUT]: null,
|
|
18739
|
+
[FIELD_TYPES.ECOM_ADDITIONAL_INFO]: null,
|
|
18740
|
+
[FIELD_TYPES.ECOM_ADDRESS]: null,
|
|
18741
|
+
[FIELD_TYPES.ECOM_PHONE]: null,
|
|
18742
|
+
[FIELD_TYPES.ECOM_FULL_NAME]: null,
|
|
18743
|
+
[FIELD_TYPES.ECOM_COMPANY_NAME]: null,
|
|
18744
|
+
[FIELD_TYPES.ECOM_EMAIL]: null,
|
|
18745
|
+
[FIELD_TYPES.ECOM_SUBSCRIPTION]: null,
|
|
18746
|
+
[FIELD_TYPES.DEXT_TEXT_AREA]: null,
|
|
18747
|
+
[FIELD_TYPES.DEXT_DROPDOWN]: null,
|
|
18748
|
+
[FIELD_TYPES.DEXT_RADIO_GROUP]: null,
|
|
18749
|
+
[FIELD_TYPES.DEXT_URL_INPUT]: null,
|
|
18750
|
+
[FIELD_TYPES.DEXT_EMAIL]: null,
|
|
18751
|
+
[FIELD_TYPES.DEXT_PHONE]: null,
|
|
18752
|
+
[FIELD_TYPES.DEXT_DATE_PICKER]: null,
|
|
18753
|
+
[FIELD_TYPES.VAT_ID]: validateVatID,
|
|
18754
|
+
[FIELD_TYPES.PRODUCT_LIST]: null,
|
|
18755
|
+
[FIELD_TYPES.RATING_INPUT]: null,
|
|
18756
|
+
[FIELD_TYPES.TAGS]: null,
|
|
18757
|
+
[FIELD_TYPES.PAYMENT_INPUT]: null,
|
|
18758
|
+
[FIELD_TYPES.FIXED_PAYMENT]: null,
|
|
18759
|
+
[FIELD_TYPES.BOOKINGS_FIRST_NAME]: null,
|
|
18760
|
+
[FIELD_TYPES.BOOKINGS_LAST_NAME]: null,
|
|
18761
|
+
[FIELD_TYPES.BOOKINGS_EMAIL]: null,
|
|
18762
|
+
[FIELD_TYPES.BOOKINGS_PHONE]: null,
|
|
18763
|
+
[FIELD_TYPES.BOOKINGS_ADDRESS]: null,
|
|
18764
|
+
[FIELD_TYPES.APPOINTMENT]: null,
|
|
18765
|
+
[FIELD_TYPES.IDENTITY_PASSWORD]: null,
|
|
18766
|
+
[FIELD_TYPES.SERVICES_DROPDOWN]: null,
|
|
18767
|
+
[FIELD_TYPES.SERVICES_MULTI_CHOICE]: null,
|
|
18768
|
+
[FIELD_TYPES.EVENTS_RSVP]: null,
|
|
18769
|
+
[FIELD_TYPES.EVENTS_REPEATER]: null
|
|
18770
|
+
};
|
|
18771
|
+
|
|
18772
|
+
// ../form-viewer/dist/esm/services/get-field-errors.js
|
|
18773
|
+
var getFieldErrors = async (fieldsToValidate, form, addressTemplates, externalData, validationMode) => {
|
|
18774
|
+
const formValues = fieldsToValidate.reduce((acc, field) => setValue(acc, field.path, field.value), {});
|
|
18775
|
+
const result2 = await validateFields(form, formValues, addressTemplates, validationMode);
|
|
18776
|
+
const _errors = result2?.errors || [];
|
|
18777
|
+
const additionalErrors = runAdditionalValidation({
|
|
18778
|
+
form,
|
|
18779
|
+
values: formValues,
|
|
18780
|
+
externalData
|
|
18781
|
+
});
|
|
18782
|
+
const allErrors = mergeErrors({ errors: _errors, additionalErrors });
|
|
18783
|
+
const fieldErrors = allErrors.filter((error) => findErrorByNormalizedPath(fieldsToValidate, error.errorPath));
|
|
18784
|
+
return fieldErrors;
|
|
18785
|
+
};
|
|
18786
|
+
var findErrorByNormalizedPath = (fieldsToValidate, errorPath) => {
|
|
18787
|
+
const path = errorPath.split("/").length > 2 ? errorPath.split("/").at(0) : errorPath;
|
|
18788
|
+
return !!fieldsToValidate.find((field) => path === field.path);
|
|
18789
|
+
};
|
|
18790
|
+
function setValue(object, path, value) {
|
|
18791
|
+
const delimiter = "/";
|
|
18792
|
+
const decomposedPath = path.split(delimiter);
|
|
18793
|
+
const base = decomposedPath[0];
|
|
18794
|
+
if (base === void 0) {
|
|
18795
|
+
return object;
|
|
18796
|
+
}
|
|
18797
|
+
if (!object.hasOwnProperty(base)) {
|
|
18798
|
+
object[base] = {};
|
|
18799
|
+
}
|
|
18800
|
+
value = decomposedPath.length <= 1 ? value : setValue(object[base], decomposedPath.slice(1).join(delimiter), value);
|
|
18801
|
+
return {
|
|
18802
|
+
...object,
|
|
18803
|
+
[base]: value
|
|
18804
|
+
};
|
|
18805
|
+
}
|
|
18806
|
+
var mergeErrors = ({ errors, additionalErrors }) => {
|
|
18807
|
+
const errorsToAdd = [];
|
|
18808
|
+
if (additionalErrors) {
|
|
18809
|
+
Object.keys(additionalErrors).forEach((fieldTarget) => {
|
|
18810
|
+
const errorExists = errors.find((error) => error.errorPath === fieldTarget);
|
|
18811
|
+
if (!errorExists) {
|
|
18812
|
+
errorsToAdd.push(additionalErrors[fieldTarget]);
|
|
18813
|
+
}
|
|
18814
|
+
});
|
|
18815
|
+
}
|
|
18816
|
+
return [...errors, ...errorsToAdd];
|
|
18817
|
+
};
|
|
18818
|
+
|
|
18819
|
+
// ../form-viewer/dist/esm/services/form-overrides.js
|
|
18820
|
+
function applyFormOverrides(form, overrides, recursive = true) {
|
|
18821
|
+
const nestedFormsByTarget = getNestedFormsByTarget(form);
|
|
18822
|
+
const fields = (form.fields ?? []).map((field) => {
|
|
18823
|
+
const override = getOverride({
|
|
18824
|
+
id: field.id,
|
|
18825
|
+
target: field.target,
|
|
18826
|
+
overrides
|
|
18827
|
+
});
|
|
18828
|
+
if (!override) {
|
|
18829
|
+
return field;
|
|
18830
|
+
}
|
|
18831
|
+
if (field.target && field.nestedFormId && recursive) {
|
|
18832
|
+
const nestedForm = nestedFormsByTarget?.[field.target];
|
|
18833
|
+
if (nestedForm) {
|
|
18834
|
+
nestedFormsByTarget[field.target] = applyFormOverrides(nestedForm, override, false);
|
|
18835
|
+
}
|
|
18836
|
+
return field;
|
|
18837
|
+
}
|
|
18838
|
+
let validation = field.validation;
|
|
18839
|
+
let options = {};
|
|
18840
|
+
if (Array.isArray(override.countries)) {
|
|
18841
|
+
validation = {
|
|
18842
|
+
...validation,
|
|
18843
|
+
string: {
|
|
18844
|
+
...validation?.string,
|
|
18845
|
+
enum: override.countries
|
|
18846
|
+
}
|
|
18847
|
+
};
|
|
18848
|
+
options = override.countries ? {
|
|
18849
|
+
options: override.countries?.map((country) => ({ value: country }))
|
|
18850
|
+
} : {};
|
|
18851
|
+
}
|
|
18852
|
+
if (field.view?.fieldType === "MULTILINE_ADDRESS") {
|
|
18853
|
+
return applyMultilineAddressOverrides({
|
|
18854
|
+
field,
|
|
18855
|
+
override
|
|
18856
|
+
});
|
|
18857
|
+
}
|
|
18858
|
+
return {
|
|
18859
|
+
...field,
|
|
18860
|
+
...pick(override, "hidden"),
|
|
18861
|
+
...pick(override, "readOnly"),
|
|
18862
|
+
view: {
|
|
18863
|
+
...field.view,
|
|
18864
|
+
...pick(override, "label"),
|
|
18865
|
+
...pick(override, "autocomplete"),
|
|
18866
|
+
...pick(override, "disabled"),
|
|
18867
|
+
...options
|
|
18868
|
+
},
|
|
18869
|
+
validation: {
|
|
18870
|
+
...validation,
|
|
18871
|
+
...pick(override, "required")
|
|
18872
|
+
}
|
|
18873
|
+
};
|
|
18874
|
+
});
|
|
18875
|
+
const nestedForms = nestedFormsByTarget ? getNestedFormArray(nestedFormsByTarget) : void 0;
|
|
18876
|
+
return {
|
|
18877
|
+
...form,
|
|
18878
|
+
fields,
|
|
18879
|
+
...nestedForms ? { nestedForms } : {}
|
|
18880
|
+
};
|
|
18881
|
+
}
|
|
18882
|
+
function pick(override, key) {
|
|
18883
|
+
return override.hasOwnProperty(key) ? { [key]: override[key] } : {};
|
|
18884
|
+
}
|
|
18885
|
+
var getOverride = ({ target, id, overrides }) => {
|
|
18886
|
+
if (target && target in overrides) {
|
|
18887
|
+
return overrides[target];
|
|
18888
|
+
}
|
|
18889
|
+
if (id && id in overrides) {
|
|
18890
|
+
return overrides[id];
|
|
18891
|
+
}
|
|
18892
|
+
return void 0;
|
|
18893
|
+
};
|
|
18894
|
+
var applyAddressFieldOverride = (fieldName, override, multilineAddressOptionsFields, multilineAddressFieldSettings) => {
|
|
18895
|
+
const fieldOverride = override[fieldName];
|
|
18896
|
+
if (!fieldOverride) {
|
|
18897
|
+
return {
|
|
18898
|
+
multilineAddressOptionsFields,
|
|
18899
|
+
multilineAddressFieldSettings
|
|
18900
|
+
};
|
|
18901
|
+
}
|
|
18902
|
+
return {
|
|
18903
|
+
multilineAddressOptionsFields: {
|
|
18904
|
+
...multilineAddressOptionsFields,
|
|
18905
|
+
[fieldName]: {
|
|
18906
|
+
required: fieldOverride.required
|
|
18907
|
+
}
|
|
18908
|
+
},
|
|
18909
|
+
multilineAddressFieldSettings: {
|
|
18910
|
+
...multilineAddressFieldSettings,
|
|
18911
|
+
[fieldName]: {
|
|
18912
|
+
...multilineAddressFieldSettings?.[fieldName],
|
|
18913
|
+
show: !fieldOverride.hidden
|
|
18914
|
+
}
|
|
18915
|
+
}
|
|
18916
|
+
};
|
|
18917
|
+
};
|
|
18918
|
+
var ADDRESS_FIELD_NAMES = [
|
|
18919
|
+
"addressLine",
|
|
18920
|
+
"addressLine2",
|
|
18921
|
+
"streetName",
|
|
18922
|
+
"streetNumber",
|
|
18923
|
+
"city",
|
|
18924
|
+
"postalCode",
|
|
18925
|
+
"subdivision",
|
|
18926
|
+
"country",
|
|
18927
|
+
"apartment"
|
|
18928
|
+
];
|
|
18929
|
+
var applyMultilineAddressOverrides = ({ field, override }) => {
|
|
18930
|
+
const finalState = ADDRESS_FIELD_NAMES.reduce((state, fieldName) => applyAddressFieldOverride(fieldName, override, state.multilineAddressOptionsFields ?? {}, state.multilineAddressFieldSettings ?? {}), {
|
|
18931
|
+
multilineAddressOptionsFields: field.validation?.predefined?.multilineAddressOptions?.fields,
|
|
18932
|
+
multilineAddressFieldSettings: field.view?.fieldSettings
|
|
18933
|
+
});
|
|
18934
|
+
const autocompleteEnabled = (override.addressLine?.autocomplete || override.streetName?.autocomplete) ?? true;
|
|
18935
|
+
const multilineAddressOptions = {
|
|
18936
|
+
...field.validation?.predefined?.multilineAddressOptions,
|
|
18937
|
+
fields: {
|
|
18938
|
+
...field.validation?.predefined?.multilineAddressOptions?.fields,
|
|
18939
|
+
...finalState.multilineAddressOptionsFields
|
|
18940
|
+
},
|
|
18941
|
+
...Array.isArray(override.countries) && override.countries.length > 0 ? { allowedCountries: override.countries } : {}
|
|
18942
|
+
};
|
|
18943
|
+
return {
|
|
18944
|
+
...field,
|
|
18945
|
+
view: {
|
|
18946
|
+
...field.view,
|
|
18947
|
+
fieldSettings: {
|
|
18948
|
+
...field.view?.fieldSettings,
|
|
18949
|
+
...finalState.multilineAddressFieldSettings
|
|
18950
|
+
},
|
|
18951
|
+
autocompleteEnabled
|
|
18952
|
+
},
|
|
18953
|
+
validation: {
|
|
18954
|
+
...field.validation,
|
|
18955
|
+
predefined: {
|
|
18956
|
+
...field.validation?.predefined,
|
|
18957
|
+
multilineAddressOptions
|
|
18958
|
+
}
|
|
18959
|
+
}
|
|
18960
|
+
};
|
|
18961
|
+
};
|
|
18962
|
+
|
|
18963
|
+
// ../form-viewer/dist/esm/hooks/use-validation.js
|
|
18964
|
+
var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
18965
|
+
const { addressTemplates } = useAddressForms();
|
|
18966
|
+
const externalData = useExternalData();
|
|
18967
|
+
const validateFields2 = useCallback(async (newValues) => {
|
|
18968
|
+
const result2 = await validate(form, newValues, addressTemplates, validationMode);
|
|
18969
|
+
const _errors = result2?.errors || [];
|
|
18970
|
+
const additionalErrors = runAdditionalValidation({
|
|
18971
|
+
form,
|
|
18972
|
+
values: newValues,
|
|
18973
|
+
externalData
|
|
18974
|
+
});
|
|
18975
|
+
const allErrors = mergeErrors({ errors: _errors, additionalErrors });
|
|
18976
|
+
setErrors(allErrors);
|
|
18977
|
+
return allErrors;
|
|
18978
|
+
}, [form, setErrors, addressTemplates, externalData, validationMode]);
|
|
18979
|
+
const handleFieldValidation = useCallback(async (fieldsToValidate) => {
|
|
18980
|
+
const fieldErrors = await getFieldErrors(fieldsToValidate, form, addressTemplates, externalData, validationMode);
|
|
18981
|
+
const otherErrors = (errorsRef.current ?? []).filter((error) => {
|
|
18982
|
+
return !findErrorByNormalizedPath(fieldsToValidate, error.errorPath);
|
|
18983
|
+
});
|
|
18984
|
+
const allErrors = [...otherErrors, ...fieldErrors];
|
|
18985
|
+
setErrors(allErrors);
|
|
18986
|
+
return allErrors;
|
|
18987
|
+
}, [
|
|
18988
|
+
errorsRef,
|
|
18989
|
+
form,
|
|
18990
|
+
setErrors,
|
|
18991
|
+
addressTemplates,
|
|
18992
|
+
externalData,
|
|
18993
|
+
validationMode
|
|
18994
|
+
]);
|
|
18995
|
+
const validateStep = useCallback(async (stepId, newValues) => {
|
|
18996
|
+
const items = form?.steps?.find((step) => step.id === stepId)?.layout?.large?.items || [];
|
|
18997
|
+
const validationErrors = await Promise.all(items.map(async (item) => {
|
|
18998
|
+
const field = form?.fields?.find((_field) => _field.id === item.fieldId);
|
|
18999
|
+
const fieldValidationResult = field?.target ? await handleFieldValidation([
|
|
19000
|
+
{
|
|
19001
|
+
path: field.target,
|
|
19002
|
+
value: newValues[field.target]
|
|
19003
|
+
}
|
|
19004
|
+
]) : [];
|
|
19005
|
+
return fieldValidationResult;
|
|
19006
|
+
}));
|
|
19007
|
+
const validationErrorsFlatten = validationErrors.flat();
|
|
19008
|
+
setErrors(validationErrorsFlatten);
|
|
19009
|
+
return !validationErrorsFlatten.length;
|
|
19010
|
+
}, [form, setErrors, handleFieldValidation]);
|
|
19011
|
+
return { validateFields: validateFields2, validateStep, handleFieldValidation };
|
|
19012
|
+
};
|
|
19013
|
+
var SubmitStatusContext = createContext(void 0);
|
|
19014
|
+
var SubmitStatusProvider = ({ children }) => {
|
|
19015
|
+
const [submitSuccessMessage, setSubmitSuccessMessage] = useState();
|
|
19016
|
+
const [submitFailureCode, setSubmitFailureCode] = useState();
|
|
19017
|
+
const [submitFailureMessage, setSubmitFailureMessage] = useState();
|
|
19018
|
+
const value = useMemo(() => ({
|
|
19019
|
+
submitSuccessMessage,
|
|
19020
|
+
submitFailureCode,
|
|
19021
|
+
submitFailureMessage,
|
|
19022
|
+
setSubmitSuccessMessage,
|
|
19023
|
+
setSubmitFailureCode,
|
|
19024
|
+
setSubmitFailureMessage
|
|
19025
|
+
}), [submitSuccessMessage, submitFailureCode, submitFailureMessage]);
|
|
19026
|
+
return React14.createElement(SubmitStatusContext.Provider, { value }, children);
|
|
19027
|
+
};
|
|
19028
|
+
var useSubmitStatus = () => {
|
|
19029
|
+
const context = useContext(SubmitStatusContext);
|
|
19030
|
+
if (context === void 0) {
|
|
19031
|
+
throw new Error("useSubmitStatus must be used within a SubmitStatusProvider");
|
|
19032
|
+
}
|
|
19033
|
+
return context;
|
|
19034
|
+
};
|
|
19035
|
+
|
|
19036
|
+
// ../../node_modules/fast-equals/dist/esm/index.mjs
|
|
19037
|
+
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
19038
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
19039
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
19040
|
+
function combineComparators(comparatorA, comparatorB) {
|
|
19041
|
+
return function isEqual(a, b, state) {
|
|
19042
|
+
return comparatorA(a, b, state) && comparatorB(a, b, state);
|
|
19043
|
+
};
|
|
19044
|
+
}
|
|
19045
|
+
function createIsCircular(areItemsEqual) {
|
|
19046
|
+
return function isCircular(a, b, state) {
|
|
19047
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object") {
|
|
19048
|
+
return areItemsEqual(a, b, state);
|
|
19049
|
+
}
|
|
19050
|
+
var cache = state.cache;
|
|
19051
|
+
var cachedA = cache.get(a);
|
|
19052
|
+
var cachedB = cache.get(b);
|
|
19053
|
+
if (cachedA && cachedB) {
|
|
19054
|
+
return cachedA === b && cachedB === a;
|
|
19055
|
+
}
|
|
19056
|
+
cache.set(a, b);
|
|
19057
|
+
cache.set(b, a);
|
|
19058
|
+
var result2 = areItemsEqual(a, b, state);
|
|
19059
|
+
cache.delete(a);
|
|
19060
|
+
cache.delete(b);
|
|
19061
|
+
return result2;
|
|
19062
|
+
};
|
|
19063
|
+
}
|
|
19064
|
+
function getStrictProperties(object) {
|
|
19065
|
+
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
19066
|
+
}
|
|
19067
|
+
var hasOwn = Object.hasOwn || (function(object, property) {
|
|
19068
|
+
return hasOwnProperty.call(object, property);
|
|
19069
|
+
});
|
|
19070
|
+
function sameValueZeroEqual(a, b) {
|
|
19071
|
+
return a === b || !a && !b && a !== a && b !== b;
|
|
19072
|
+
}
|
|
19073
|
+
var PREACT_VNODE = "__v";
|
|
19074
|
+
var PREACT_OWNER = "__o";
|
|
19075
|
+
var REACT_OWNER = "_owner";
|
|
19076
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
19077
|
+
var keys = Object.keys;
|
|
19078
|
+
function areArraysEqual(a, b, state) {
|
|
19079
|
+
var index = a.length;
|
|
19080
|
+
if (b.length !== index) {
|
|
19081
|
+
return false;
|
|
19082
|
+
}
|
|
19083
|
+
while (index-- > 0) {
|
|
19084
|
+
if (!state.equals(a[index], b[index], index, index, a, b, state)) {
|
|
19085
|
+
return false;
|
|
19086
|
+
}
|
|
19087
|
+
}
|
|
19088
|
+
return true;
|
|
19089
|
+
}
|
|
19090
|
+
function areDatesEqual(a, b) {
|
|
19091
|
+
return sameValueZeroEqual(a.getTime(), b.getTime());
|
|
19092
|
+
}
|
|
19093
|
+
function areErrorsEqual(a, b) {
|
|
19094
|
+
return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
|
|
19095
|
+
}
|
|
19096
|
+
function areFunctionsEqual(a, b) {
|
|
19097
|
+
return a === b;
|
|
19098
|
+
}
|
|
19099
|
+
function areMapsEqual(a, b, state) {
|
|
19100
|
+
var size = a.size;
|
|
19101
|
+
if (size !== b.size) {
|
|
19102
|
+
return false;
|
|
19103
|
+
}
|
|
19104
|
+
if (!size) {
|
|
19105
|
+
return true;
|
|
19106
|
+
}
|
|
19107
|
+
var matchedIndices = new Array(size);
|
|
19108
|
+
var aIterable = a.entries();
|
|
19109
|
+
var aResult;
|
|
19110
|
+
var bResult;
|
|
19111
|
+
var index = 0;
|
|
19112
|
+
while (aResult = aIterable.next()) {
|
|
19113
|
+
if (aResult.done) {
|
|
19114
|
+
break;
|
|
19115
|
+
}
|
|
19116
|
+
var bIterable = b.entries();
|
|
19117
|
+
var hasMatch = false;
|
|
19118
|
+
var matchIndex = 0;
|
|
19119
|
+
while (bResult = bIterable.next()) {
|
|
19120
|
+
if (bResult.done) {
|
|
19121
|
+
break;
|
|
19122
|
+
}
|
|
19123
|
+
if (matchedIndices[matchIndex]) {
|
|
19124
|
+
matchIndex++;
|
|
19125
|
+
continue;
|
|
19126
|
+
}
|
|
19127
|
+
var aEntry = aResult.value;
|
|
19128
|
+
var bEntry = bResult.value;
|
|
19129
|
+
if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
|
|
19130
|
+
hasMatch = matchedIndices[matchIndex] = true;
|
|
19131
|
+
break;
|
|
19132
|
+
}
|
|
19133
|
+
matchIndex++;
|
|
19134
|
+
}
|
|
19135
|
+
if (!hasMatch) {
|
|
19136
|
+
return false;
|
|
19137
|
+
}
|
|
19138
|
+
index++;
|
|
19139
|
+
}
|
|
19140
|
+
return true;
|
|
19141
|
+
}
|
|
19142
|
+
var areNumbersEqual = sameValueZeroEqual;
|
|
19143
|
+
function areObjectsEqual(a, b, state) {
|
|
19144
|
+
var properties = keys(a);
|
|
19145
|
+
var index = properties.length;
|
|
19146
|
+
if (keys(b).length !== index) {
|
|
19147
|
+
return false;
|
|
19148
|
+
}
|
|
19149
|
+
while (index-- > 0) {
|
|
19150
|
+
if (!isPropertyEqual(a, b, state, properties[index])) {
|
|
19151
|
+
return false;
|
|
19152
|
+
}
|
|
19153
|
+
}
|
|
19154
|
+
return true;
|
|
19155
|
+
}
|
|
19156
|
+
function areObjectsEqualStrict(a, b, state) {
|
|
19157
|
+
var properties = getStrictProperties(a);
|
|
19158
|
+
var index = properties.length;
|
|
19159
|
+
if (getStrictProperties(b).length !== index) {
|
|
19160
|
+
return false;
|
|
19161
|
+
}
|
|
19162
|
+
var property;
|
|
19163
|
+
var descriptorA;
|
|
19164
|
+
var descriptorB;
|
|
19165
|
+
while (index-- > 0) {
|
|
19166
|
+
property = properties[index];
|
|
19167
|
+
if (!isPropertyEqual(a, b, state, property)) {
|
|
19168
|
+
return false;
|
|
19169
|
+
}
|
|
19170
|
+
descriptorA = getOwnPropertyDescriptor(a, property);
|
|
19171
|
+
descriptorB = getOwnPropertyDescriptor(b, property);
|
|
19172
|
+
if ((descriptorA || descriptorB) && (!descriptorA || !descriptorB || descriptorA.configurable !== descriptorB.configurable || descriptorA.enumerable !== descriptorB.enumerable || descriptorA.writable !== descriptorB.writable)) {
|
|
19173
|
+
return false;
|
|
19174
|
+
}
|
|
19175
|
+
}
|
|
19176
|
+
return true;
|
|
19177
|
+
}
|
|
19178
|
+
function arePrimitiveWrappersEqual(a, b) {
|
|
19179
|
+
return sameValueZeroEqual(a.valueOf(), b.valueOf());
|
|
19180
|
+
}
|
|
19181
|
+
function areRegExpsEqual(a, b) {
|
|
19182
|
+
return a.source === b.source && a.flags === b.flags;
|
|
19183
|
+
}
|
|
19184
|
+
function areSetsEqual(a, b, state) {
|
|
19185
|
+
var size = a.size;
|
|
19186
|
+
if (size !== b.size) {
|
|
19187
|
+
return false;
|
|
19188
|
+
}
|
|
19189
|
+
if (!size) {
|
|
19190
|
+
return true;
|
|
19191
|
+
}
|
|
19192
|
+
var matchedIndices = new Array(size);
|
|
19193
|
+
var aIterable = a.values();
|
|
19194
|
+
var aResult;
|
|
19195
|
+
var bResult;
|
|
19196
|
+
while (aResult = aIterable.next()) {
|
|
19197
|
+
if (aResult.done) {
|
|
19198
|
+
break;
|
|
19199
|
+
}
|
|
19200
|
+
var bIterable = b.values();
|
|
19201
|
+
var hasMatch = false;
|
|
19202
|
+
var matchIndex = 0;
|
|
19203
|
+
while (bResult = bIterable.next()) {
|
|
19204
|
+
if (bResult.done) {
|
|
19205
|
+
break;
|
|
19206
|
+
}
|
|
19207
|
+
if (!matchedIndices[matchIndex] && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
|
|
19208
|
+
hasMatch = matchedIndices[matchIndex] = true;
|
|
19209
|
+
break;
|
|
18725
19210
|
}
|
|
18726
19211
|
matchIndex++;
|
|
18727
19212
|
}
|
|
@@ -19003,979 +19488,570 @@ function asUtcDate(value) {
|
|
|
19003
19488
|
return null;
|
|
19004
19489
|
}
|
|
19005
19490
|
}
|
|
19006
|
-
function getNumberValuesToCompare(...values) {
|
|
19007
|
-
return values.map((value) => {
|
|
19008
|
-
if (typeof value === "string") {
|
|
19009
|
-
return getDateUtcTimestamp(value);
|
|
19010
|
-
}
|
|
19011
|
-
if (typeof value === "number") {
|
|
19012
|
-
return value;
|
|
19013
|
-
}
|
|
19014
|
-
if (isProductSubmission(value)) {
|
|
19015
|
-
return getProductPrice(value);
|
|
19016
|
-
}
|
|
19017
|
-
return null;
|
|
19018
|
-
});
|
|
19019
|
-
}
|
|
19020
|
-
function getDateUtcTimestamp(givenValue) {
|
|
19021
|
-
const givenDate = asUtcDate(givenValue);
|
|
19022
|
-
return givenDate ? givenDate.getTime() : null;
|
|
19023
|
-
}
|
|
19024
|
-
function getProductPrice(givenValue) {
|
|
19025
|
-
return givenValue[0].price;
|
|
19026
|
-
}
|
|
19027
|
-
function isObject3(givenValue) {
|
|
19028
|
-
return typeof givenValue === "object" && !Array.isArray(givenValue) && givenValue !== null;
|
|
19029
|
-
}
|
|
19030
|
-
var isArrayOfNumbers = (value) => {
|
|
19031
|
-
return value.every((item) => typeof item === "number");
|
|
19032
|
-
};
|
|
19033
|
-
function isProductSubmission(value) {
|
|
19034
|
-
return Array.isArray(value) && value.every((element) => isObject3(element) && "productId" in element && "price" in element && "quantity" in element);
|
|
19035
|
-
}
|
|
19036
|
-
function isValueEmpty(givenValue) {
|
|
19037
|
-
return givenValue === void 0 || givenValue === null || givenValue === "";
|
|
19038
|
-
}
|
|
19039
|
-
function isValidCondition(rule, fields = []) {
|
|
19040
|
-
if (rule === void 0) {
|
|
19041
|
-
return true;
|
|
19042
|
-
}
|
|
19043
|
-
const rulesOrConditions = getRulesOrConditions(rule);
|
|
19044
|
-
if (!rulesOrConditions.length) {
|
|
19045
|
-
return false;
|
|
19046
|
-
}
|
|
19047
|
-
return rulesOrConditions.every((conditionOrRule) => {
|
|
19048
|
-
if (isCondition(conditionOrRule)) {
|
|
19049
|
-
return fields?.some((field) => field.id === conditionOrRule.fact);
|
|
19050
|
-
}
|
|
19051
|
-
return isValidCondition(conditionOrRule, fields);
|
|
19052
|
-
});
|
|
19053
|
-
}
|
|
19054
|
-
function isFormRuleValid(formRule, formSchema) {
|
|
19055
|
-
if (!formRule || !formRule?.overrides?.length || !formSchema) {
|
|
19056
|
-
return false;
|
|
19057
|
-
}
|
|
19058
|
-
const { fieldsV2, fields, nestedForms, formFields } = formSchema;
|
|
19059
|
-
const fieldsToCheck = (fields ?? []).concat(fieldsV2 ?? []).concat(formFields ?? []);
|
|
19060
|
-
const conditionValid = isValidCondition(formRule.condition, fieldsToCheck);
|
|
19061
|
-
const overrideValid = formRule?.overrides.some((override) => {
|
|
19062
|
-
if (override.entityType === OverrideEntityType.FORM) {
|
|
19063
|
-
return formSchema.id === override.entityId || nestedForms?.some((nestedForm) => nestedForm.form?.id === override.entityId);
|
|
19064
|
-
}
|
|
19065
|
-
const wasFieldFound = (fieldsToCheck?.map((f) => f.id) ?? []).includes(override.entityId);
|
|
19066
|
-
return override.entityId ? wasFieldFound : false;
|
|
19067
|
-
});
|
|
19068
|
-
return conditionValid && overrideValid;
|
|
19069
|
-
}
|
|
19070
|
-
|
|
19071
|
-
// ../form-conditions/dist/esm/lib/transform-path-to-v2.js
|
|
19072
|
-
var supportedPaths = [
|
|
19073
|
-
"hidden",
|
|
19074
|
-
"validation.required",
|
|
19075
|
-
"validation.string.enum",
|
|
19076
|
-
"validation.boolean.enum",
|
|
19077
|
-
"validation.predefined.multilineAddressOptions.fields",
|
|
19078
|
-
"view.options",
|
|
19079
|
-
"view.countryCode"
|
|
19080
|
-
];
|
|
19081
|
-
var fieldPathMapToPlatfomized = {
|
|
19082
|
-
hidden: ["hidden"],
|
|
19083
|
-
"validation.required": ["inputOptions.required"],
|
|
19084
|
-
"validation.string.enum": ["inputOptions.stringOptions.validation.enum"],
|
|
19085
|
-
"validation.boolean.enum": ["inputOptions.booleanOptions.validation.enum"],
|
|
19086
|
-
"view.options": [
|
|
19087
|
-
"inputOptions.stringOptions.radioGroupOptions.options",
|
|
19088
|
-
"inputOptions.stringOptions.dropdownOptions.options",
|
|
19089
|
-
"inputOptions.arrayOptions.checkboxGroupOptions.options"
|
|
19090
|
-
],
|
|
19091
|
-
"view.countryCode": []
|
|
19092
|
-
};
|
|
19093
|
-
|
|
19094
|
-
// ../form-conditions/dist/esm/lib/apply-item-properties-override.js
|
|
19095
|
-
var PATH_SEPARATOR = ".";
|
|
19096
|
-
function applyItemPropertiesOverride(formSchema, rule) {
|
|
19097
|
-
if (rule.overrides) {
|
|
19098
|
-
const overriddenFormSchema = applyFormOverride(formSchema, mapOverridesByItem(rule.overrides, isFormOverride, isSupportedFormPath));
|
|
19099
|
-
return {
|
|
19100
|
-
...overriddenFormSchema,
|
|
19101
|
-
fields: applyItemsOverride(overriddenFormSchema.fields ?? [], mapOverridesByItem(rule.overrides, isFieldOverride, isSupportedFieldPath)),
|
|
19102
|
-
...overriddenFormSchema.fieldsV2 && {
|
|
19103
|
-
fieldsV2: applyItemsOverride(overriddenFormSchema.fieldsV2 ?? [], mapOverridesV2ByItem(rule.overrides, isFieldOverride))
|
|
19104
|
-
},
|
|
19105
|
-
...overriddenFormSchema.formFields && {
|
|
19106
|
-
formFields: applyItemsOverride(overriddenFormSchema.formFields ?? [], mapOverridesV2ByItem(rule.overrides, isFieldOverride))
|
|
19107
|
-
}
|
|
19108
|
-
};
|
|
19109
|
-
}
|
|
19110
|
-
return formSchema;
|
|
19111
|
-
}
|
|
19112
|
-
function applyItemsOverride(items, formItemOverrides) {
|
|
19113
|
-
return items.map((formField) => {
|
|
19114
|
-
const fieldOverrides = formItemOverrides[asRequired2(formField.id)] || [];
|
|
19115
|
-
return fieldOverrides.reduce((acc, override) => setToValue(acc, override.path, override.value), formField);
|
|
19116
|
-
});
|
|
19117
|
-
}
|
|
19118
|
-
function applyFormOverride(formSchema, formItemOverrides) {
|
|
19119
|
-
const formOverrides = Object.values(formItemOverrides).flat();
|
|
19120
|
-
return formOverrides.reduce((acc, override) => setToValue(acc, override.path, override.value), formSchema);
|
|
19121
|
-
}
|
|
19122
|
-
function mapOverridesByItem(overrideItems, isOverride, isSupportedPath) {
|
|
19123
|
-
return overrideItems.filter(isOverride).reduce((acc, overrideItem) => {
|
|
19124
|
-
const entityId = asRequired2(overrideItem.entityId);
|
|
19125
|
-
const overrides = Object.entries(overrideItem.valueChanges ?? {}).filter(([path]) => isSupportedPath(path)).map(([path, value]) => ({
|
|
19126
|
-
path: path.split(PATH_SEPARATOR),
|
|
19127
|
-
value
|
|
19128
|
-
}));
|
|
19129
|
-
acc[entityId] = [...acc[entityId] || [], ...overrides];
|
|
19130
|
-
return acc;
|
|
19131
|
-
}, {});
|
|
19132
|
-
}
|
|
19133
|
-
function mapOverridesV2ByItem(overrideItems, isOverride) {
|
|
19134
|
-
return overrideItems.filter(isOverride).reduce((acc, overrideItem) => {
|
|
19135
|
-
const entityId = asRequired2(overrideItem.entityId);
|
|
19136
|
-
const overrides = Object.entries(overrideItem.valueChanges ?? {}).flatMap(([path, value]) => {
|
|
19137
|
-
const resolvedV2Paths = fieldPathMapToPlatfomized[path] || [];
|
|
19138
|
-
return resolvedV2Paths.map((pathV2) => [pathV2, value]);
|
|
19139
|
-
}).map(([path, value]) => ({
|
|
19140
|
-
path: path.split(PATH_SEPARATOR),
|
|
19141
|
-
value
|
|
19142
|
-
}));
|
|
19143
|
-
acc[entityId] = [...acc[entityId] || [], ...overrides];
|
|
19144
|
-
return acc;
|
|
19145
|
-
}, {});
|
|
19146
|
-
}
|
|
19147
|
-
function setToValue(obj, pathProps, value) {
|
|
19148
|
-
if (value !== void 0 && obj !== void 0) {
|
|
19149
|
-
const [prop, ...rest] = pathProps;
|
|
19150
|
-
if (rest.length) {
|
|
19151
|
-
const valueToSet = setToValue(obj[prop], rest, value);
|
|
19152
|
-
if (valueToSet !== void 0) {
|
|
19153
|
-
return {
|
|
19154
|
-
...obj,
|
|
19155
|
-
[prop]: valueToSet
|
|
19156
|
-
};
|
|
19157
|
-
}
|
|
19158
|
-
return obj;
|
|
19159
|
-
}
|
|
19160
|
-
return {
|
|
19161
|
-
...obj,
|
|
19162
|
-
[prop]: value
|
|
19163
|
-
};
|
|
19164
|
-
}
|
|
19165
|
-
return obj;
|
|
19166
|
-
}
|
|
19167
|
-
function isFieldOverride(override) {
|
|
19168
|
-
return override.entityType === OverrideEntityType.FIELD;
|
|
19169
|
-
}
|
|
19170
|
-
function isFormOverride(override) {
|
|
19171
|
-
return override.entityType === OverrideEntityType.FORM;
|
|
19172
|
-
}
|
|
19173
|
-
function isSupportedFieldPath(path) {
|
|
19174
|
-
return supportedPaths.includes(path);
|
|
19175
|
-
}
|
|
19176
|
-
function isSupportedFormPath(path) {
|
|
19177
|
-
return ["fields", "steps"].includes(path);
|
|
19178
|
-
}
|
|
19179
|
-
|
|
19180
|
-
// ../form-conditions/dist/esm/lib/evaluate-override-condition.js
|
|
19181
|
-
var import_js_rules_engine2 = __toESM(require_dist5());
|
|
19182
|
-
|
|
19183
|
-
// ../form-conditions/dist/esm/lib/set-up-operators.js
|
|
19184
|
-
var import_js_rules_engine = __toESM(require_dist5());
|
|
19185
|
-
|
|
19186
|
-
// ../form-conditions/dist/esm/lib/operators/between.js
|
|
19187
|
-
function valueIsBetween(givenValue, expectedValue) {
|
|
19188
|
-
if (isValueEmpty(givenValue)) {
|
|
19189
|
-
return false;
|
|
19190
|
-
}
|
|
19191
|
-
if (!Array.isArray(expectedValue) || expectedValue.length !== 2) {
|
|
19192
|
-
throw new Error("Expected value should be array of two elements");
|
|
19193
|
-
}
|
|
19194
|
-
const values = getNumberValuesToCompare(givenValue, expectedValue[0], expectedValue[1]);
|
|
19195
|
-
if (isArrayOfNumbers(values)) {
|
|
19196
|
-
const [given, firstBound, secondBound] = values;
|
|
19197
|
-
return between(given, Math.min(firstBound, secondBound), Math.max(firstBound, secondBound));
|
|
19198
|
-
}
|
|
19199
|
-
throw new Error(`Between operator: Unsupported values to compare ${givenValue}, ${JSON.stringify(expectedValue)}`);
|
|
19200
|
-
}
|
|
19201
|
-
|
|
19202
|
-
// ../form-conditions/dist/esm/lib/operators/greater-than.js
|
|
19203
|
-
function valueIsGreaterThan(givenValue, expectedValue, orEqual = false) {
|
|
19204
|
-
if (isValueEmpty(givenValue)) {
|
|
19205
|
-
return false;
|
|
19206
|
-
}
|
|
19207
|
-
const values = getNumberValuesToCompare(givenValue, expectedValue);
|
|
19208
|
-
if (isArrayOfNumbers(values)) {
|
|
19209
|
-
const [given, expected] = values;
|
|
19210
|
-
return greaterThan(given, expected, orEqual);
|
|
19211
|
-
}
|
|
19212
|
-
throw new Error(`GreaterThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19213
|
-
}
|
|
19214
|
-
|
|
19215
|
-
// ../form-conditions/dist/esm/lib/operators/less-than.js
|
|
19216
|
-
function valueIsLessThan(givenValue, expectedValue, orEqual = false) {
|
|
19217
|
-
if (isValueEmpty(givenValue)) {
|
|
19218
|
-
return false;
|
|
19219
|
-
}
|
|
19220
|
-
const values = getNumberValuesToCompare(givenValue, expectedValue);
|
|
19221
|
-
if (isArrayOfNumbers(values)) {
|
|
19222
|
-
const [given, expected] = values;
|
|
19223
|
-
return lessThan(given, expected, orEqual);
|
|
19224
|
-
}
|
|
19225
|
-
throw new Error(`LessThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19226
|
-
}
|
|
19227
|
-
|
|
19228
|
-
// ../form-conditions/dist/esm/lib/operators/contains.js
|
|
19229
|
-
function valueContains(givenValue, expectedValue) {
|
|
19230
|
-
if (isValueEmpty(givenValue)) {
|
|
19231
|
-
return false;
|
|
19232
|
-
}
|
|
19233
|
-
if (isObject3(givenValue)) {
|
|
19234
|
-
return Object.values(givenValue).includes(expectedValue);
|
|
19235
|
-
}
|
|
19236
|
-
if (Array.isArray(givenValue) || typeof givenValue === "string") {
|
|
19237
|
-
return givenValue.indexOf(expectedValue) > -1;
|
|
19238
|
-
}
|
|
19239
|
-
throw new Error(`Contains operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19240
|
-
}
|
|
19241
|
-
|
|
19242
|
-
// ../form-conditions/dist/esm/lib/operators/array-equals.js
|
|
19243
|
-
function arrayEquals(givenValue, expectedValue) {
|
|
19244
|
-
if (isValueEmpty(givenValue)) {
|
|
19245
|
-
return false;
|
|
19246
|
-
}
|
|
19247
|
-
if (!Array.isArray(givenValue) || !Array.isArray(expectedValue)) {
|
|
19248
|
-
throw new Error(`All operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19249
|
-
}
|
|
19250
|
-
if (givenValue.length !== expectedValue.length) {
|
|
19251
|
-
return false;
|
|
19252
|
-
}
|
|
19253
|
-
if (isProductSubmission(givenValue)) {
|
|
19254
|
-
return equals(givenValue.map((product) => product.productId), expectedValue);
|
|
19255
|
-
}
|
|
19256
|
-
return equals(givenValue, expectedValue);
|
|
19491
|
+
function getNumberValuesToCompare(...values) {
|
|
19492
|
+
return values.map((value) => {
|
|
19493
|
+
if (typeof value === "string") {
|
|
19494
|
+
return getDateUtcTimestamp(value);
|
|
19495
|
+
}
|
|
19496
|
+
if (typeof value === "number") {
|
|
19497
|
+
return value;
|
|
19498
|
+
}
|
|
19499
|
+
if (isProductSubmission(value)) {
|
|
19500
|
+
return getProductPrice(value);
|
|
19501
|
+
}
|
|
19502
|
+
return null;
|
|
19503
|
+
});
|
|
19257
19504
|
}
|
|
19258
|
-
function
|
|
19259
|
-
|
|
19505
|
+
function getDateUtcTimestamp(givenValue) {
|
|
19506
|
+
const givenDate = asUtcDate(givenValue);
|
|
19507
|
+
return givenDate ? givenDate.getTime() : null;
|
|
19260
19508
|
}
|
|
19261
|
-
|
|
19262
|
-
|
|
19263
|
-
function valueContainsAny(_givenValue, expectedValue) {
|
|
19264
|
-
if (isValueEmpty(_givenValue)) {
|
|
19265
|
-
return false;
|
|
19266
|
-
}
|
|
19267
|
-
const givenValue = Array.isArray(_givenValue) ? _givenValue : [_givenValue];
|
|
19268
|
-
if (!Array.isArray(givenValue) || !Array.isArray(expectedValue)) {
|
|
19269
|
-
throw new Error(`Any operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19270
|
-
}
|
|
19271
|
-
if (isProductSubmission(givenValue)) {
|
|
19272
|
-
return any(givenValue.map((product) => product.productId), expectedValue);
|
|
19273
|
-
}
|
|
19274
|
-
return any(givenValue, expectedValue);
|
|
19509
|
+
function getProductPrice(givenValue) {
|
|
19510
|
+
return givenValue[0].price;
|
|
19275
19511
|
}
|
|
19276
|
-
function
|
|
19277
|
-
return givenValue.
|
|
19512
|
+
function isObject4(givenValue) {
|
|
19513
|
+
return typeof givenValue === "object" && !Array.isArray(givenValue) && givenValue !== null;
|
|
19278
19514
|
}
|
|
19279
|
-
|
|
19280
|
-
|
|
19281
|
-
|
|
19282
|
-
|
|
19283
|
-
|
|
19284
|
-
}
|
|
19285
|
-
if (Array.isArray(expectedValue) || typeof expectedValue === "string") {
|
|
19286
|
-
return expectedValue.indexOf(givenValue) > -1;
|
|
19287
|
-
}
|
|
19288
|
-
throw new Error(`In operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19515
|
+
var isArrayOfNumbers = (value) => {
|
|
19516
|
+
return value.every((item) => typeof item === "number");
|
|
19517
|
+
};
|
|
19518
|
+
function isProductSubmission(value) {
|
|
19519
|
+
return Array.isArray(value) && value.every((element) => isObject4(element) && "productId" in element && "price" in element && "quantity" in element);
|
|
19289
19520
|
}
|
|
19290
|
-
|
|
19291
|
-
|
|
19292
|
-
var ConditionOperators;
|
|
19293
|
-
(function(ConditionOperators2) {
|
|
19294
|
-
ConditionOperators2["equal"] = "equal";
|
|
19295
|
-
ConditionOperators2["notEqual"] = "notEqual";
|
|
19296
|
-
ConditionOperators2["notEmpty"] = "notEmpty";
|
|
19297
|
-
ConditionOperators2["empty"] = "empty";
|
|
19298
|
-
ConditionOperators2["contains"] = "contains";
|
|
19299
|
-
ConditionOperators2["notContains"] = "notContains";
|
|
19300
|
-
ConditionOperators2["greaterThanOrEqual"] = "greaterThanOrEqual";
|
|
19301
|
-
ConditionOperators2["greaterThan"] = "greaterThan";
|
|
19302
|
-
ConditionOperators2["afterOrEqual"] = "afterOrEqual";
|
|
19303
|
-
ConditionOperators2["after"] = "after";
|
|
19304
|
-
ConditionOperators2["lessThanOrEqual"] = "lessThanOrEqual";
|
|
19305
|
-
ConditionOperators2["lessThan"] = "lessThan";
|
|
19306
|
-
ConditionOperators2["beforeOrEqual"] = "beforeOrEqual";
|
|
19307
|
-
ConditionOperators2["before"] = "before";
|
|
19308
|
-
ConditionOperators2["between"] = "between";
|
|
19309
|
-
ConditionOperators2["any"] = "any";
|
|
19310
|
-
ConditionOperators2["arrayEqual"] = "arrayEqual";
|
|
19311
|
-
ConditionOperators2["arrayNotEqual"] = "arrayNotEqual";
|
|
19312
|
-
ConditionOperators2["checked"] = "checked";
|
|
19313
|
-
ConditionOperators2["notChecked"] = "notChecked";
|
|
19314
|
-
ConditionOperators2["in"] = "in";
|
|
19315
|
-
ConditionOperators2["notIn"] = "notIn";
|
|
19316
|
-
ConditionOperators2["isDateNewerThan"] = "isDateNewerThan";
|
|
19317
|
-
ConditionOperators2["isDateOlderThan"] = "isDateOlderThan";
|
|
19318
|
-
ConditionOperators2["isDateNewerThanOrEqual"] = "isDateNewerThanOrEqual";
|
|
19319
|
-
ConditionOperators2["isDateOlderThanOrEqual"] = "isDateOlderThanOrEqual";
|
|
19320
|
-
})(ConditionOperators || (ConditionOperators = {}));
|
|
19321
|
-
|
|
19322
|
-
// ../form-conditions/dist/esm/lib/operators/checked.js
|
|
19323
|
-
function checked(givenValue) {
|
|
19324
|
-
return Boolean(givenValue);
|
|
19521
|
+
function isValueEmpty(givenValue) {
|
|
19522
|
+
return givenValue === void 0 || givenValue === null || givenValue === "";
|
|
19325
19523
|
}
|
|
19326
|
-
|
|
19327
|
-
|
|
19328
|
-
|
|
19329
|
-
if (isProductSubmission(givenValue)) {
|
|
19330
|
-
return getProductPrice(givenValue) === expectedValue;
|
|
19524
|
+
function isValidCondition(rule, fields = []) {
|
|
19525
|
+
if (rule === void 0) {
|
|
19526
|
+
return true;
|
|
19331
19527
|
}
|
|
19332
|
-
|
|
19333
|
-
|
|
19334
|
-
|
|
19335
|
-
// ../form-conditions/dist/esm/lib/operators/is-date-newer-than.js
|
|
19336
|
-
var import_dayjs2 = __toESM(require_dayjs_min());
|
|
19337
|
-
var import_isSameOrAfter = __toESM(require_isSameOrAfter());
|
|
19338
|
-
function valueIsDateNewerThan(givenValue, expectedValue, { orEqual = false, dateFactory = () => /* @__PURE__ */ new Date() } = {}) {
|
|
19339
|
-
import_dayjs2.default.extend(import_isSameOrAfter.default);
|
|
19340
|
-
if (isValueEmpty(givenValue)) {
|
|
19528
|
+
const rulesOrConditions = getRulesOrConditions(rule);
|
|
19529
|
+
if (!rulesOrConditions.length) {
|
|
19341
19530
|
return false;
|
|
19342
19531
|
}
|
|
19343
|
-
|
|
19344
|
-
|
|
19345
|
-
|
|
19346
|
-
|
|
19347
|
-
|
|
19348
|
-
|
|
19349
|
-
case "day":
|
|
19350
|
-
case "month":
|
|
19351
|
-
if (isArrayOfNumbers(values)) {
|
|
19352
|
-
const [given, units] = values;
|
|
19353
|
-
const date = (0, import_dayjs2.default)(given);
|
|
19354
|
-
const nowUnitsAdded = (0, import_dayjs2.default)(dateFactory()).add(units, unit);
|
|
19355
|
-
if (orEqual) {
|
|
19356
|
-
return date.isSameOrAfter(nowUnitsAdded, "day");
|
|
19357
|
-
}
|
|
19358
|
-
return date.isAfter(nowUnitsAdded, "day");
|
|
19359
|
-
}
|
|
19360
|
-
}
|
|
19361
|
-
throw new Error(`IsDateNewerThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19532
|
+
return rulesOrConditions.every((conditionOrRule) => {
|
|
19533
|
+
if (isCondition(conditionOrRule)) {
|
|
19534
|
+
return fields?.some((field) => field.id === conditionOrRule.fact);
|
|
19535
|
+
}
|
|
19536
|
+
return isValidCondition(conditionOrRule, fields);
|
|
19537
|
+
});
|
|
19362
19538
|
}
|
|
19363
|
-
|
|
19364
|
-
|
|
19365
|
-
var import_dayjs3 = __toESM(require_dayjs_min());
|
|
19366
|
-
var import_isSameOrBefore = __toESM(require_isSameOrBefore());
|
|
19367
|
-
function valueIsDateOlderThan(givenValue, expectedValue, { orEqual = false, dateFactory = () => /* @__PURE__ */ new Date() } = {}) {
|
|
19368
|
-
import_dayjs3.default.extend(import_isSameOrBefore.default);
|
|
19369
|
-
if (isValueEmpty(givenValue)) {
|
|
19539
|
+
function isFormRuleValid(formRule, formSchema) {
|
|
19540
|
+
if (!formRule || !formRule?.overrides?.length || !formSchema) {
|
|
19370
19541
|
return false;
|
|
19371
19542
|
}
|
|
19372
|
-
|
|
19373
|
-
|
|
19374
|
-
|
|
19375
|
-
const
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
const [given, units] = values;
|
|
19382
|
-
const date = (0, import_dayjs3.default)(given);
|
|
19383
|
-
const nowUnitsAdded = (0, import_dayjs3.default)(dateFactory()).add(-units, unit);
|
|
19384
|
-
if (orEqual) {
|
|
19385
|
-
return date.isSameOrBefore(nowUnitsAdded, "day");
|
|
19386
|
-
}
|
|
19387
|
-
return date.isBefore(nowUnitsAdded, "day");
|
|
19388
|
-
}
|
|
19389
|
-
}
|
|
19390
|
-
throw new Error(`IsDateOlderThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19391
|
-
}
|
|
19392
|
-
|
|
19393
|
-
// ../form-conditions/dist/esm/lib/set-up-operators.js
|
|
19394
|
-
function setUpOperators(defaultEngine2, dateFactory) {
|
|
19395
|
-
const operators = [
|
|
19396
|
-
new import_js_rules_engine.Operator(ConditionOperators.empty, (value) => valueIsMissing(value)),
|
|
19397
|
-
new import_js_rules_engine.Operator(ConditionOperators.notEmpty, (value) => !valueIsMissing(value)),
|
|
19398
|
-
new import_js_rules_engine.Operator(ConditionOperators.between, (givenValue, expectedValue) => valueIsBetween(givenValue, expectedValue)),
|
|
19399
|
-
new import_js_rules_engine.Operator(ConditionOperators.greaterThan, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue)),
|
|
19400
|
-
new import_js_rules_engine.Operator(ConditionOperators.after, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue)),
|
|
19401
|
-
new import_js_rules_engine.Operator(ConditionOperators.greaterThanOrEqual, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue, true)),
|
|
19402
|
-
new import_js_rules_engine.Operator(ConditionOperators.afterOrEqual, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue, true)),
|
|
19403
|
-
new import_js_rules_engine.Operator(ConditionOperators.lessThan, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue)),
|
|
19404
|
-
new import_js_rules_engine.Operator(ConditionOperators.before, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue)),
|
|
19405
|
-
new import_js_rules_engine.Operator(ConditionOperators.lessThanOrEqual, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue, true)),
|
|
19406
|
-
new import_js_rules_engine.Operator(ConditionOperators.beforeOrEqual, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue, true)),
|
|
19407
|
-
new import_js_rules_engine.Operator(ConditionOperators.contains, (givenValue, expectedValue) => valueContains(givenValue, expectedValue)),
|
|
19408
|
-
new import_js_rules_engine.Operator(ConditionOperators.equal, (givenValue, expectedValue) => valueEqual(givenValue, expectedValue)),
|
|
19409
|
-
new import_js_rules_engine.Operator(ConditionOperators.notEqual, (givenValue, expectedValue) => !valueEqual(givenValue, expectedValue)),
|
|
19410
|
-
new import_js_rules_engine.Operator(ConditionOperators.notContains, (givenValue, expectedValue) => !valueContains(givenValue, expectedValue)),
|
|
19411
|
-
new import_js_rules_engine.Operator(ConditionOperators.arrayEqual, (givenValue, expectedValue) => arrayEquals(givenValue, expectedValue)),
|
|
19412
|
-
new import_js_rules_engine.Operator(ConditionOperators.arrayNotEqual, (givenValue, expectedValue) => !arrayEquals(givenValue, expectedValue)),
|
|
19413
|
-
new import_js_rules_engine.Operator(ConditionOperators.checked, checked),
|
|
19414
|
-
new import_js_rules_engine.Operator(ConditionOperators.notChecked, (givenValue) => !checked(givenValue)),
|
|
19415
|
-
new import_js_rules_engine.Operator(ConditionOperators.any, (givenValue, expectedValue) => valueContainsAny(givenValue, expectedValue)),
|
|
19416
|
-
new import_js_rules_engine.Operator(ConditionOperators.in, (givenValue, expectedValue) => valueIn(givenValue, expectedValue)),
|
|
19417
|
-
new import_js_rules_engine.Operator(ConditionOperators.notIn, (givenValue, expectedValue) => !valueIn(givenValue, expectedValue)),
|
|
19418
|
-
new import_js_rules_engine.Operator(ConditionOperators.isDateNewerThan, (givenValue, expectedValue) => valueIsDateNewerThan(givenValue, expectedValue, { dateFactory })),
|
|
19419
|
-
new import_js_rules_engine.Operator(ConditionOperators.isDateOlderThan, (givenValue, expectedValue) => valueIsDateOlderThan(givenValue, expectedValue, { dateFactory })),
|
|
19420
|
-
new import_js_rules_engine.Operator(ConditionOperators.isDateNewerThanOrEqual, (givenValue, expectedValue) => valueIsDateNewerThan(givenValue, expectedValue, {
|
|
19421
|
-
orEqual: true,
|
|
19422
|
-
dateFactory
|
|
19423
|
-
})),
|
|
19424
|
-
new import_js_rules_engine.Operator(ConditionOperators.isDateOlderThanOrEqual, (givenValue, expectedValue) => valueIsDateOlderThan(givenValue, expectedValue, {
|
|
19425
|
-
orEqual: true,
|
|
19426
|
-
dateFactory
|
|
19427
|
-
}))
|
|
19428
|
-
];
|
|
19429
|
-
operators.forEach((operator) => {
|
|
19430
|
-
defaultEngine2.removeOperator(operator.name);
|
|
19431
|
-
defaultEngine2.addOperator(operator);
|
|
19543
|
+
const { fieldsV2, fields, nestedForms, formFields } = formSchema;
|
|
19544
|
+
const fieldsToCheck = (fields ?? []).concat(fieldsV2 ?? []).concat(formFields ?? []);
|
|
19545
|
+
const conditionValid = isValidCondition(formRule.condition, fieldsToCheck);
|
|
19546
|
+
const overrideValid = formRule?.overrides.some((override) => {
|
|
19547
|
+
if (override.entityType === OverrideEntityType.FORM) {
|
|
19548
|
+
return formSchema.id === override.entityId || nestedForms?.some((nestedForm) => nestedForm.form?.id === override.entityId);
|
|
19549
|
+
}
|
|
19550
|
+
const wasFieldFound = (fieldsToCheck?.map((f) => f.id) ?? []).includes(override.entityId);
|
|
19551
|
+
return override.entityId ? wasFieldFound : false;
|
|
19432
19552
|
});
|
|
19553
|
+
return conditionValid && overrideValid;
|
|
19433
19554
|
}
|
|
19434
19555
|
|
|
19435
|
-
// ../form-conditions/dist/esm/lib/
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19441
|
-
|
|
19442
|
-
|
|
19443
|
-
|
|
19444
|
-
|
|
19445
|
-
|
|
19556
|
+
// ../form-conditions/dist/esm/lib/transform-path-to-v2.js
|
|
19557
|
+
var supportedPaths = [
|
|
19558
|
+
"hidden",
|
|
19559
|
+
"validation.required",
|
|
19560
|
+
"validation.string.enum",
|
|
19561
|
+
"validation.boolean.enum",
|
|
19562
|
+
"validation.predefined.multilineAddressOptions.fields",
|
|
19563
|
+
"view.options",
|
|
19564
|
+
"view.countryCode"
|
|
19565
|
+
];
|
|
19566
|
+
var fieldPathMapToPlatfomized = {
|
|
19567
|
+
hidden: ["hidden"],
|
|
19568
|
+
"validation.required": ["inputOptions.required"],
|
|
19569
|
+
"validation.string.enum": ["inputOptions.stringOptions.validation.enum"],
|
|
19570
|
+
"validation.boolean.enum": ["inputOptions.booleanOptions.validation.enum"],
|
|
19571
|
+
"view.options": [
|
|
19572
|
+
"inputOptions.stringOptions.radioGroupOptions.options",
|
|
19573
|
+
"inputOptions.stringOptions.dropdownOptions.options",
|
|
19574
|
+
"inputOptions.arrayOptions.checkboxGroupOptions.options"
|
|
19575
|
+
],
|
|
19576
|
+
"view.countryCode": []
|
|
19577
|
+
};
|
|
19578
|
+
|
|
19579
|
+
// ../form-conditions/dist/esm/lib/apply-item-properties-override.js
|
|
19580
|
+
var PATH_SEPARATOR = ".";
|
|
19581
|
+
function applyItemPropertiesOverride(formSchema, rule) {
|
|
19582
|
+
if (rule.overrides) {
|
|
19583
|
+
const overriddenFormSchema = applyFormOverride(formSchema, mapOverridesByItem(rule.overrides, isFormOverride, isSupportedFormPath));
|
|
19584
|
+
return {
|
|
19585
|
+
...overriddenFormSchema,
|
|
19586
|
+
fields: applyItemsOverride(overriddenFormSchema.fields ?? [], mapOverridesByItem(rule.overrides, isFieldOverride, isSupportedFieldPath)),
|
|
19587
|
+
...overriddenFormSchema.fieldsV2 && {
|
|
19588
|
+
fieldsV2: applyItemsOverride(overriddenFormSchema.fieldsV2 ?? [], mapOverridesV2ByItem(rule.overrides, isFieldOverride))
|
|
19589
|
+
},
|
|
19590
|
+
...overriddenFormSchema.formFields && {
|
|
19591
|
+
formFields: applyItemsOverride(overriddenFormSchema.formFields ?? [], mapOverridesV2ByItem(rule.overrides, isFieldOverride))
|
|
19446
19592
|
}
|
|
19447
|
-
}
|
|
19448
|
-
return true;
|
|
19449
|
-
};
|
|
19450
|
-
function getRule(condition) {
|
|
19451
|
-
return new import_js_rules_engine2.Rule(condition);
|
|
19593
|
+
};
|
|
19452
19594
|
}
|
|
19595
|
+
return formSchema;
|
|
19453
19596
|
}
|
|
19454
|
-
|
|
19455
|
-
|
|
19456
|
-
|
|
19457
|
-
|
|
19597
|
+
function applyItemsOverride(items, formItemOverrides) {
|
|
19598
|
+
return items.map((formField) => {
|
|
19599
|
+
const fieldOverrides = formItemOverrides[asRequired2(formField.id)] || [];
|
|
19600
|
+
return fieldOverrides.reduce((acc, override) => setToValue(acc, override.path, override.value), formField);
|
|
19601
|
+
});
|
|
19458
19602
|
}
|
|
19459
|
-
function
|
|
19460
|
-
const
|
|
19461
|
-
|
|
19462
|
-
|
|
19463
|
-
|
|
19464
|
-
|
|
19465
|
-
|
|
19466
|
-
|
|
19467
|
-
|
|
19468
|
-
|
|
19469
|
-
}
|
|
19470
|
-
|
|
19471
|
-
return fields.reduce((acc, field) => {
|
|
19472
|
-
const source = getIdOrTarget(field, from);
|
|
19473
|
-
const destination = getIdOrTarget(field, by);
|
|
19474
|
-
if (source && destination && source !== destination && acc.hasOwnProperty(source)) {
|
|
19475
|
-
acc[destination] = acc[source];
|
|
19476
|
-
const { [source]: omitted, ...rest } = acc;
|
|
19477
|
-
acc = rest;
|
|
19478
|
-
}
|
|
19603
|
+
function applyFormOverride(formSchema, formItemOverrides) {
|
|
19604
|
+
const formOverrides = Object.values(formItemOverrides).flat();
|
|
19605
|
+
return formOverrides.reduce((acc, override) => setToValue(acc, override.path, override.value), formSchema);
|
|
19606
|
+
}
|
|
19607
|
+
function mapOverridesByItem(overrideItems, isOverride, isSupportedPath) {
|
|
19608
|
+
return overrideItems.filter(isOverride).reduce((acc, overrideItem) => {
|
|
19609
|
+
const entityId = asRequired2(overrideItem.entityId);
|
|
19610
|
+
const overrides = Object.entries(overrideItem.valueChanges ?? {}).filter(([path]) => isSupportedPath(path)).map(([path, value]) => ({
|
|
19611
|
+
path: path.split(PATH_SEPARATOR),
|
|
19612
|
+
value
|
|
19613
|
+
}));
|
|
19614
|
+
acc[entityId] = [...acc[entityId] || [], ...overrides];
|
|
19479
19615
|
return acc;
|
|
19480
|
-
}, {
|
|
19616
|
+
}, {});
|
|
19481
19617
|
}
|
|
19482
|
-
|
|
19483
|
-
|
|
19484
|
-
|
|
19485
|
-
|
|
19486
|
-
|
|
19487
|
-
|
|
19488
|
-
|
|
19489
|
-
|
|
19618
|
+
function mapOverridesV2ByItem(overrideItems, isOverride) {
|
|
19619
|
+
return overrideItems.filter(isOverride).reduce((acc, overrideItem) => {
|
|
19620
|
+
const entityId = asRequired2(overrideItem.entityId);
|
|
19621
|
+
const overrides = Object.entries(overrideItem.valueChanges ?? {}).flatMap(([path, value]) => {
|
|
19622
|
+
const resolvedV2Paths = fieldPathMapToPlatfomized[path] || [];
|
|
19623
|
+
return resolvedV2Paths.map((pathV2) => [pathV2, value]);
|
|
19624
|
+
}).map(([path, value]) => ({
|
|
19625
|
+
path: path.split(PATH_SEPARATOR),
|
|
19626
|
+
value
|
|
19627
|
+
}));
|
|
19628
|
+
acc[entityId] = [...acc[entityId] || [], ...overrides];
|
|
19629
|
+
return acc;
|
|
19630
|
+
}, {});
|
|
19490
19631
|
}
|
|
19491
|
-
function
|
|
19492
|
-
|
|
19493
|
-
|
|
19494
|
-
|
|
19495
|
-
|
|
19632
|
+
function setToValue(obj, pathProps, value) {
|
|
19633
|
+
if (value !== void 0 && obj !== void 0) {
|
|
19634
|
+
const [prop, ...rest] = pathProps;
|
|
19635
|
+
if (rest.length) {
|
|
19636
|
+
const valueToSet = setToValue(obj[prop], rest, value);
|
|
19637
|
+
if (valueToSet !== void 0) {
|
|
19638
|
+
return {
|
|
19639
|
+
...obj,
|
|
19640
|
+
[prop]: valueToSet
|
|
19641
|
+
};
|
|
19642
|
+
}
|
|
19643
|
+
return obj;
|
|
19644
|
+
}
|
|
19645
|
+
return {
|
|
19646
|
+
...obj,
|
|
19647
|
+
[prop]: value
|
|
19648
|
+
};
|
|
19496
19649
|
}
|
|
19497
|
-
return
|
|
19650
|
+
return obj;
|
|
19498
19651
|
}
|
|
19499
|
-
|
|
19500
|
-
|
|
19501
|
-
function partition(items, condition) {
|
|
19502
|
-
return items.reduce(([truthy, falsy], element) => {
|
|
19503
|
-
if (condition(element)) {
|
|
19504
|
-
truthy.push(element);
|
|
19505
|
-
} else {
|
|
19506
|
-
falsy.push(element);
|
|
19507
|
-
}
|
|
19508
|
-
return [truthy, falsy];
|
|
19509
|
-
}, [[], []]);
|
|
19652
|
+
function isFieldOverride(override) {
|
|
19653
|
+
return override.entityType === OverrideEntityType.FIELD;
|
|
19510
19654
|
}
|
|
19511
|
-
function
|
|
19512
|
-
return
|
|
19513
|
-
acc[keyFn(item)] = item;
|
|
19514
|
-
return acc;
|
|
19515
|
-
}, {});
|
|
19655
|
+
function isFormOverride(override) {
|
|
19656
|
+
return override.entityType === OverrideEntityType.FORM;
|
|
19516
19657
|
}
|
|
19517
|
-
|
|
19518
|
-
|
|
19519
|
-
function isDefined2(value) {
|
|
19520
|
-
return !(value === null || value === void 0);
|
|
19658
|
+
function isSupportedFieldPath(path) {
|
|
19659
|
+
return supportedPaths.includes(path);
|
|
19521
19660
|
}
|
|
19522
|
-
|
|
19523
|
-
|
|
19524
|
-
function isEmpty(object) {
|
|
19525
|
-
return Boolean(object) && Boolean(Object.keys(object).length);
|
|
19661
|
+
function isSupportedFormPath(path) {
|
|
19662
|
+
return ["fields", "steps"].includes(path);
|
|
19526
19663
|
}
|
|
19527
19664
|
|
|
19528
|
-
// ../
|
|
19529
|
-
|
|
19530
|
-
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
|
|
19538
|
-
|
|
19539
|
-
|
|
19540
|
-
|
|
19541
|
-
|
|
19542
|
-
|
|
19543
|
-
|
|
19544
|
-
|
|
19545
|
-
|
|
19665
|
+
// ../form-conditions/dist/esm/lib/evaluate-override-condition.js
|
|
19666
|
+
var import_js_rules_engine2 = __toESM(require_dist5());
|
|
19667
|
+
|
|
19668
|
+
// ../form-conditions/dist/esm/lib/set-up-operators.js
|
|
19669
|
+
var import_js_rules_engine = __toESM(require_dist5());
|
|
19670
|
+
|
|
19671
|
+
// ../form-conditions/dist/esm/lib/operators/between.js
|
|
19672
|
+
function valueIsBetween(givenValue, expectedValue) {
|
|
19673
|
+
if (isValueEmpty(givenValue)) {
|
|
19674
|
+
return false;
|
|
19675
|
+
}
|
|
19676
|
+
if (!Array.isArray(expectedValue) || expectedValue.length !== 2) {
|
|
19677
|
+
throw new Error("Expected value should be array of two elements");
|
|
19678
|
+
}
|
|
19679
|
+
const values = getNumberValuesToCompare(givenValue, expectedValue[0], expectedValue[1]);
|
|
19680
|
+
if (isArrayOfNumbers(values)) {
|
|
19681
|
+
const [given, firstBound, secondBound] = values;
|
|
19682
|
+
return between(given, Math.min(firstBound, secondBound), Math.max(firstBound, secondBound));
|
|
19683
|
+
}
|
|
19684
|
+
throw new Error(`Between operator: Unsupported values to compare ${givenValue}, ${JSON.stringify(expectedValue)}`);
|
|
19546
19685
|
}
|
|
19547
|
-
|
|
19548
|
-
|
|
19549
|
-
|
|
19550
|
-
|
|
19551
|
-
|
|
19552
|
-
|
|
19553
|
-
|
|
19554
|
-
|
|
19555
|
-
|
|
19556
|
-
|
|
19557
|
-
|
|
19558
|
-
|
|
19559
|
-
required: requiredOverride
|
|
19560
|
-
}
|
|
19561
|
-
}
|
|
19562
|
-
};
|
|
19563
|
-
})
|
|
19564
|
-
};
|
|
19686
|
+
|
|
19687
|
+
// ../form-conditions/dist/esm/lib/operators/greater-than.js
|
|
19688
|
+
function valueIsGreaterThan(givenValue, expectedValue, orEqual = false) {
|
|
19689
|
+
if (isValueEmpty(givenValue)) {
|
|
19690
|
+
return false;
|
|
19691
|
+
}
|
|
19692
|
+
const values = getNumberValuesToCompare(givenValue, expectedValue);
|
|
19693
|
+
if (isArrayOfNumbers(values)) {
|
|
19694
|
+
const [given, expected] = values;
|
|
19695
|
+
return greaterThan(given, expected, orEqual);
|
|
19696
|
+
}
|
|
19697
|
+
throw new Error(`GreaterThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19565
19698
|
}
|
|
19566
19699
|
|
|
19567
|
-
// ../form-
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
|
|
19700
|
+
// ../form-conditions/dist/esm/lib/operators/less-than.js
|
|
19701
|
+
function valueIsLessThan(givenValue, expectedValue, orEqual = false) {
|
|
19702
|
+
if (isValueEmpty(givenValue)) {
|
|
19703
|
+
return false;
|
|
19704
|
+
}
|
|
19705
|
+
const values = getNumberValuesToCompare(givenValue, expectedValue);
|
|
19706
|
+
if (isArrayOfNumbers(values)) {
|
|
19707
|
+
const [given, expected] = values;
|
|
19708
|
+
return lessThan(given, expected, orEqual);
|
|
19709
|
+
}
|
|
19710
|
+
throw new Error(`LessThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19571
19711
|
}
|
|
19572
|
-
|
|
19573
|
-
|
|
19712
|
+
|
|
19713
|
+
// ../form-conditions/dist/esm/lib/operators/contains.js
|
|
19714
|
+
function valueContains(givenValue, expectedValue) {
|
|
19715
|
+
if (isValueEmpty(givenValue)) {
|
|
19716
|
+
return false;
|
|
19717
|
+
}
|
|
19718
|
+
if (isObject4(givenValue)) {
|
|
19719
|
+
return Object.values(givenValue).includes(expectedValue);
|
|
19720
|
+
}
|
|
19721
|
+
if (Array.isArray(givenValue) || typeof givenValue === "string") {
|
|
19722
|
+
return givenValue.indexOf(expectedValue) > -1;
|
|
19723
|
+
}
|
|
19724
|
+
throw new Error(`Contains operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19574
19725
|
}
|
|
19575
|
-
|
|
19576
|
-
|
|
19726
|
+
|
|
19727
|
+
// ../form-conditions/dist/esm/lib/operators/array-equals.js
|
|
19728
|
+
function arrayEquals(givenValue, expectedValue) {
|
|
19729
|
+
if (isValueEmpty(givenValue)) {
|
|
19730
|
+
return false;
|
|
19731
|
+
}
|
|
19732
|
+
if (!Array.isArray(givenValue) || !Array.isArray(expectedValue)) {
|
|
19733
|
+
throw new Error(`All operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19734
|
+
}
|
|
19735
|
+
if (givenValue.length !== expectedValue.length) {
|
|
19736
|
+
return false;
|
|
19737
|
+
}
|
|
19738
|
+
if (isProductSubmission(givenValue)) {
|
|
19739
|
+
return equals(givenValue.map((product) => product.productId), expectedValue);
|
|
19740
|
+
}
|
|
19741
|
+
return equals(givenValue, expectedValue);
|
|
19577
19742
|
}
|
|
19578
|
-
function
|
|
19579
|
-
return
|
|
19743
|
+
function equals(givenValue, expectedValue) {
|
|
19744
|
+
return expectedValue.every((v) => givenValue.includes(v));
|
|
19580
19745
|
}
|
|
19581
19746
|
|
|
19582
|
-
// ../form-
|
|
19583
|
-
|
|
19584
|
-
|
|
19585
|
-
|
|
19586
|
-
const fields = [...form?.fields || [], ...form?.deletedFields || []];
|
|
19587
|
-
return fields.some((field) => field.view?.fieldType === "MULTILINE_ADDRESS" || field.view?.fieldType === "BOOKINGS_ADDRESS" || !excludeEcomAddress && field.view?.fieldType === "ECOM_ADDRESS");
|
|
19588
|
-
};
|
|
19589
|
-
|
|
19590
|
-
// ../form-viewer/dist/esm/services/validation.js
|
|
19591
|
-
var removeFalsyValues = (values = {}) => {
|
|
19592
|
-
return Object.keys(values).reduce((withoutFalsy, target) => {
|
|
19593
|
-
const value = values[target];
|
|
19594
|
-
if (value === "" || typeof value === "undefined" || value === null) {
|
|
19595
|
-
return withoutFalsy;
|
|
19596
|
-
}
|
|
19597
|
-
if (Array.isArray(value) && !value.length) {
|
|
19598
|
-
return withoutFalsy;
|
|
19599
|
-
}
|
|
19600
|
-
if (isObject4(value)) {
|
|
19601
|
-
withoutFalsy[target] = removeFalsyValues(value);
|
|
19602
|
-
} else {
|
|
19603
|
-
withoutFalsy[target] = value;
|
|
19604
|
-
}
|
|
19605
|
-
return withoutFalsy;
|
|
19606
|
-
}, {});
|
|
19607
|
-
};
|
|
19608
|
-
var getFormValidator = async (form, addressTemplates, validationMode) => {
|
|
19609
|
-
const [{ FormValidator: FormValidator2 }, { MultilineAddressToolkit: MultilineAddressToolkit2 }] = await Promise.all([
|
|
19610
|
-
Promise.resolve().then(() => (init_esm(), esm_exports)),
|
|
19611
|
-
Promise.resolve().then(() => (init_esm2(), esm_exports2))
|
|
19612
|
-
]);
|
|
19613
|
-
if (addressTemplates?.length) {
|
|
19614
|
-
const addressForms = addressTemplates.map((template) => template.template);
|
|
19615
|
-
const addressToolkit = new MultilineAddressToolkit2(addressForms);
|
|
19616
|
-
return new FormValidator2([form], validationMode, false, addressToolkit.getFormForValidation, addressToolkit.normalizeEmptyValues, true);
|
|
19747
|
+
// ../form-conditions/dist/esm/lib/operators/any.js
|
|
19748
|
+
function valueContainsAny(_givenValue, expectedValue) {
|
|
19749
|
+
if (isValueEmpty(_givenValue)) {
|
|
19750
|
+
return false;
|
|
19617
19751
|
}
|
|
19618
|
-
|
|
19619
|
-
|
|
19620
|
-
|
|
19621
|
-
if (!form.id) {
|
|
19622
|
-
return;
|
|
19752
|
+
const givenValue = Array.isArray(_givenValue) ? _givenValue : [_givenValue];
|
|
19753
|
+
if (!Array.isArray(givenValue) || !Array.isArray(expectedValue)) {
|
|
19754
|
+
throw new Error(`Any operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19623
19755
|
}
|
|
19624
|
-
|
|
19625
|
-
|
|
19626
|
-
};
|
|
19627
|
-
var validateFields = async (form, values, addressTemplates, validationMode) => {
|
|
19628
|
-
if (!form.id) {
|
|
19629
|
-
return;
|
|
19756
|
+
if (isProductSubmission(givenValue)) {
|
|
19757
|
+
return any(givenValue.map((product) => product.productId), expectedValue);
|
|
19630
19758
|
}
|
|
19631
|
-
|
|
19632
|
-
|
|
19633
|
-
|
|
19759
|
+
return any(givenValue, expectedValue);
|
|
19760
|
+
}
|
|
19761
|
+
function any(givenValue, expectedValue) {
|
|
19762
|
+
return givenValue.some((v) => expectedValue.includes(v));
|
|
19763
|
+
}
|
|
19634
19764
|
|
|
19635
|
-
// ../form-
|
|
19636
|
-
function
|
|
19637
|
-
if (
|
|
19638
|
-
return
|
|
19765
|
+
// ../form-conditions/dist/esm/lib/operators/in.js
|
|
19766
|
+
function valueIn(givenValue, expectedValue) {
|
|
19767
|
+
if (isObject4(expectedValue)) {
|
|
19768
|
+
return Object.values(expectedValue).includes(givenValue);
|
|
19639
19769
|
}
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
|
|
19643
|
-
|
|
19644
|
-
const fieldTarget = field.target;
|
|
19645
|
-
if (!fieldTarget) {
|
|
19646
|
-
return field;
|
|
19647
|
-
}
|
|
19648
|
-
const nestedFormId = field.nestedFormId;
|
|
19649
|
-
if (!nestedFormId) {
|
|
19650
|
-
return field;
|
|
19651
|
-
}
|
|
19652
|
-
const nestedForm = nestedFormsByTarget?.[fieldTarget] ?? nestedFormsById?.[nestedFormId];
|
|
19653
|
-
if (nestedForm) {
|
|
19654
|
-
return { ...field, view: { ...field.view, form: nestedForm } };
|
|
19655
|
-
}
|
|
19656
|
-
return field;
|
|
19657
|
-
})
|
|
19658
|
-
};
|
|
19659
|
-
}
|
|
19660
|
-
function getNestedFormsByTarget(form) {
|
|
19661
|
-
return form.nestedForms?.reduce((byTarget, { targets, form: nestedForm }) => {
|
|
19662
|
-
if (!nestedForm || !targets) {
|
|
19663
|
-
return byTarget;
|
|
19664
|
-
}
|
|
19665
|
-
for (const target of targets) {
|
|
19666
|
-
byTarget[target] = nestedForm;
|
|
19667
|
-
}
|
|
19668
|
-
return byTarget;
|
|
19669
|
-
}, {});
|
|
19770
|
+
if (Array.isArray(expectedValue) || typeof expectedValue === "string") {
|
|
19771
|
+
return expectedValue.indexOf(givenValue) > -1;
|
|
19772
|
+
}
|
|
19773
|
+
throw new Error(`In operator: Unsupported values to compare ${JSON.stringify(givenValue)}, ${JSON.stringify(expectedValue)}`);
|
|
19670
19774
|
}
|
|
19671
|
-
|
|
19672
|
-
|
|
19673
|
-
|
|
19674
|
-
|
|
19775
|
+
|
|
19776
|
+
// ../form-conditions/dist/esm/lib/condition-operators.js
|
|
19777
|
+
var ConditionOperators;
|
|
19778
|
+
(function(ConditionOperators2) {
|
|
19779
|
+
ConditionOperators2["equal"] = "equal";
|
|
19780
|
+
ConditionOperators2["notEqual"] = "notEqual";
|
|
19781
|
+
ConditionOperators2["notEmpty"] = "notEmpty";
|
|
19782
|
+
ConditionOperators2["empty"] = "empty";
|
|
19783
|
+
ConditionOperators2["contains"] = "contains";
|
|
19784
|
+
ConditionOperators2["notContains"] = "notContains";
|
|
19785
|
+
ConditionOperators2["greaterThanOrEqual"] = "greaterThanOrEqual";
|
|
19786
|
+
ConditionOperators2["greaterThan"] = "greaterThan";
|
|
19787
|
+
ConditionOperators2["afterOrEqual"] = "afterOrEqual";
|
|
19788
|
+
ConditionOperators2["after"] = "after";
|
|
19789
|
+
ConditionOperators2["lessThanOrEqual"] = "lessThanOrEqual";
|
|
19790
|
+
ConditionOperators2["lessThan"] = "lessThan";
|
|
19791
|
+
ConditionOperators2["beforeOrEqual"] = "beforeOrEqual";
|
|
19792
|
+
ConditionOperators2["before"] = "before";
|
|
19793
|
+
ConditionOperators2["between"] = "between";
|
|
19794
|
+
ConditionOperators2["any"] = "any";
|
|
19795
|
+
ConditionOperators2["arrayEqual"] = "arrayEqual";
|
|
19796
|
+
ConditionOperators2["arrayNotEqual"] = "arrayNotEqual";
|
|
19797
|
+
ConditionOperators2["checked"] = "checked";
|
|
19798
|
+
ConditionOperators2["notChecked"] = "notChecked";
|
|
19799
|
+
ConditionOperators2["in"] = "in";
|
|
19800
|
+
ConditionOperators2["notIn"] = "notIn";
|
|
19801
|
+
ConditionOperators2["isDateNewerThan"] = "isDateNewerThan";
|
|
19802
|
+
ConditionOperators2["isDateOlderThan"] = "isDateOlderThan";
|
|
19803
|
+
ConditionOperators2["isDateNewerThanOrEqual"] = "isDateNewerThanOrEqual";
|
|
19804
|
+
ConditionOperators2["isDateOlderThanOrEqual"] = "isDateOlderThanOrEqual";
|
|
19805
|
+
})(ConditionOperators || (ConditionOperators = {}));
|
|
19806
|
+
|
|
19807
|
+
// ../form-conditions/dist/esm/lib/operators/checked.js
|
|
19808
|
+
function checked(givenValue) {
|
|
19809
|
+
return Boolean(givenValue);
|
|
19675
19810
|
}
|
|
19676
19811
|
|
|
19677
|
-
// ../form-
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
-
|
|
19681
|
-
|
|
19682
|
-
|
|
19683
|
-
|
|
19684
|
-
const fieldType = field?.view?.fieldType;
|
|
19685
|
-
const fieldValue = values[fieldTarget];
|
|
19686
|
-
const validateField = ADDITIONAL_FIELD_VALIDATION[fieldType];
|
|
19687
|
-
const error = validateField?.({
|
|
19688
|
-
value: fieldValue,
|
|
19689
|
-
target: fieldTarget,
|
|
19690
|
-
externalData
|
|
19691
|
-
});
|
|
19692
|
-
if (error) {
|
|
19693
|
-
acc[fieldTarget] = error;
|
|
19694
|
-
}
|
|
19695
|
-
return acc;
|
|
19696
|
-
}, {});
|
|
19697
|
-
return additionalErrors;
|
|
19698
|
-
};
|
|
19699
|
-
var ADDITIONAL_FIELD_VALIDATION = {
|
|
19700
|
-
[FIELD_TYPES.TEXT_INPUT]: null,
|
|
19701
|
-
[FIELD_TYPES.CHECKBOX_GROUP]: null,
|
|
19702
|
-
[FIELD_TYPES.RADIO_GROUP]: null,
|
|
19703
|
-
[FIELD_TYPES.DONATION]: null,
|
|
19704
|
-
[FIELD_TYPES.DROPDOWN]: null,
|
|
19705
|
-
[FIELD_TYPES.URL_INPUT]: null,
|
|
19706
|
-
[FIELD_TYPES.NUMBER_INPUT]: null,
|
|
19707
|
-
[FIELD_TYPES.QUIZ_NUMBER]: null,
|
|
19708
|
-
[FIELD_TYPES.QUIZ_SHORT_TEXT]: null,
|
|
19709
|
-
[FIELD_TYPES.QUIZ_LONG_TEXT]: null,
|
|
19710
|
-
[FIELD_TYPES.QUIZ_MULTI_CHOICE]: null,
|
|
19711
|
-
[FIELD_TYPES.QUIZ_IMAGE_CHOICE]: null,
|
|
19712
|
-
[FIELD_TYPES.QUIZ_SINGLE_CHOICE]: null,
|
|
19713
|
-
[FIELD_TYPES.QUIZ_FILE_UPLOAD]: null,
|
|
19714
|
-
[FIELD_TYPES.FILE_UPLOAD]: null,
|
|
19715
|
-
[FIELD_TYPES.SIGNATURE]: null,
|
|
19716
|
-
[FIELD_TYPES.CONTACTS_EMAIL]: null,
|
|
19717
|
-
[FIELD_TYPES.CONTACTS_PHONE]: null,
|
|
19718
|
-
[FIELD_TYPES.CHECKBOX]: null,
|
|
19719
|
-
[FIELD_TYPES.DATE_INPUT]: null,
|
|
19720
|
-
[FIELD_TYPES.DATE_TIME_INPUT]: null,
|
|
19721
|
-
[FIELD_TYPES.TIME_INPUT]: null,
|
|
19722
|
-
[FIELD_TYPES.DATE_PICKER]: null,
|
|
19723
|
-
[FIELD_TYPES.CONTACTS_COMPANY]: null,
|
|
19724
|
-
[FIELD_TYPES.CONTACTS_POSITION]: null,
|
|
19725
|
-
[FIELD_TYPES.CONTACTS_TAX_ID]: null,
|
|
19726
|
-
[FIELD_TYPES.CONTACTS_FIRST_NAME]: null,
|
|
19727
|
-
[FIELD_TYPES.CONTACTS_LAST_NAME]: null,
|
|
19728
|
-
[FIELD_TYPES.CONTACTS_ADDRESS]: null,
|
|
19729
|
-
[FIELD_TYPES.CONTACTS_BIRTHDATE]: validateBirthdate,
|
|
19730
|
-
[FIELD_TYPES.TEXT_AREA]: null,
|
|
19731
|
-
[FIELD_TYPES.CONTACTS_SUBSCRIBE]: null,
|
|
19732
|
-
[FIELD_TYPES.NESTED_FORM]: null,
|
|
19733
|
-
[FIELD_TYPES.MULTILINE_ADDRESS]: null,
|
|
19734
|
-
[FIELD_TYPES.MLA_COUNTRY]: null,
|
|
19735
|
-
[FIELD_TYPES.MLA_CITY]: null,
|
|
19736
|
-
[FIELD_TYPES.MLA_ADDRESS_LINE]: null,
|
|
19737
|
-
[FIELD_TYPES.MLA_ADDRESS_LINE_2]: null,
|
|
19738
|
-
[FIELD_TYPES.MLA_POSTAL_CODE]: null,
|
|
19739
|
-
[FIELD_TYPES.MLA_SUBDIVISION]: null,
|
|
19740
|
-
[FIELD_TYPES.MLA_STREET_NAME]: null,
|
|
19741
|
-
[FIELD_TYPES.MLA_STREET_NUMBER]: null,
|
|
19742
|
-
[FIELD_TYPES.MLA_APARTMENT]: null,
|
|
19743
|
-
[FIELD_TYPES.FULL_NAME_FIRST_NAME]: null,
|
|
19744
|
-
[FIELD_TYPES.FULL_NAME_LAST_NAME]: null,
|
|
19745
|
-
[FIELD_TYPES.FULL_NAME]: null,
|
|
19746
|
-
[FIELD_TYPES.DEXT_TEXT_INPUT]: null,
|
|
19747
|
-
[FIELD_TYPES.DEXT_NUMBER_INPUT]: null,
|
|
19748
|
-
[FIELD_TYPES.DEXT_CHECKBOX]: null,
|
|
19749
|
-
[FIELD_TYPES.DEXT_CHECKBOX_GROUP]: null,
|
|
19750
|
-
[FIELD_TYPES.DEXT_TAGS]: null,
|
|
19751
|
-
[FIELD_TYPES.DEXT_RATING_INPUT]: null,
|
|
19752
|
-
[FIELD_TYPES.ECOM_ADDITIONAL_INFO]: null,
|
|
19753
|
-
[FIELD_TYPES.ECOM_ADDRESS]: null,
|
|
19754
|
-
[FIELD_TYPES.ECOM_PHONE]: null,
|
|
19755
|
-
[FIELD_TYPES.ECOM_FULL_NAME]: null,
|
|
19756
|
-
[FIELD_TYPES.ECOM_COMPANY_NAME]: null,
|
|
19757
|
-
[FIELD_TYPES.ECOM_EMAIL]: null,
|
|
19758
|
-
[FIELD_TYPES.ECOM_SUBSCRIPTION]: null,
|
|
19759
|
-
[FIELD_TYPES.DEXT_TEXT_AREA]: null,
|
|
19760
|
-
[FIELD_TYPES.DEXT_DROPDOWN]: null,
|
|
19761
|
-
[FIELD_TYPES.DEXT_RADIO_GROUP]: null,
|
|
19762
|
-
[FIELD_TYPES.DEXT_URL_INPUT]: null,
|
|
19763
|
-
[FIELD_TYPES.DEXT_EMAIL]: null,
|
|
19764
|
-
[FIELD_TYPES.DEXT_PHONE]: null,
|
|
19765
|
-
[FIELD_TYPES.DEXT_DATE_PICKER]: null,
|
|
19766
|
-
[FIELD_TYPES.VAT_ID]: validateVatID,
|
|
19767
|
-
[FIELD_TYPES.PRODUCT_LIST]: null,
|
|
19768
|
-
[FIELD_TYPES.RATING_INPUT]: null,
|
|
19769
|
-
[FIELD_TYPES.TAGS]: null,
|
|
19770
|
-
[FIELD_TYPES.PAYMENT_INPUT]: null,
|
|
19771
|
-
[FIELD_TYPES.FIXED_PAYMENT]: null,
|
|
19772
|
-
[FIELD_TYPES.BOOKINGS_FIRST_NAME]: null,
|
|
19773
|
-
[FIELD_TYPES.BOOKINGS_LAST_NAME]: null,
|
|
19774
|
-
[FIELD_TYPES.BOOKINGS_EMAIL]: null,
|
|
19775
|
-
[FIELD_TYPES.BOOKINGS_PHONE]: null,
|
|
19776
|
-
[FIELD_TYPES.BOOKINGS_ADDRESS]: null,
|
|
19777
|
-
[FIELD_TYPES.APPOINTMENT]: null,
|
|
19778
|
-
[FIELD_TYPES.IDENTITY_PASSWORD]: null,
|
|
19779
|
-
[FIELD_TYPES.SERVICES_DROPDOWN]: null,
|
|
19780
|
-
[FIELD_TYPES.SERVICES_MULTI_CHOICE]: null,
|
|
19781
|
-
[FIELD_TYPES.EVENTS_RSVP]: null,
|
|
19782
|
-
[FIELD_TYPES.EVENTS_REPEATER]: null
|
|
19783
|
-
};
|
|
19812
|
+
// ../form-conditions/dist/esm/lib/operators/equal.js
|
|
19813
|
+
function valueEqual(givenValue, expectedValue) {
|
|
19814
|
+
if (isProductSubmission(givenValue)) {
|
|
19815
|
+
return getProductPrice(givenValue) === expectedValue;
|
|
19816
|
+
}
|
|
19817
|
+
return givenValue === expectedValue;
|
|
19818
|
+
}
|
|
19784
19819
|
|
|
19785
|
-
// ../form-
|
|
19786
|
-
var
|
|
19787
|
-
|
|
19788
|
-
|
|
19789
|
-
|
|
19790
|
-
|
|
19791
|
-
|
|
19792
|
-
values: formValues,
|
|
19793
|
-
externalData
|
|
19794
|
-
});
|
|
19795
|
-
const allErrors = mergeErrors({ errors: _errors, additionalErrors });
|
|
19796
|
-
const fieldErrors = allErrors.filter((error) => findErrorByNormalizedPath(fieldsToValidate, error.errorPath));
|
|
19797
|
-
return fieldErrors;
|
|
19798
|
-
};
|
|
19799
|
-
var findErrorByNormalizedPath = (fieldsToValidate, errorPath) => {
|
|
19800
|
-
const path = errorPath.split("/").length > 2 ? errorPath.split("/").at(0) : errorPath;
|
|
19801
|
-
return !!fieldsToValidate.find((field) => path === field.path);
|
|
19802
|
-
};
|
|
19803
|
-
function setValue(object, path, value) {
|
|
19804
|
-
const delimiter = "/";
|
|
19805
|
-
const decomposedPath = path.split(delimiter);
|
|
19806
|
-
const base = decomposedPath[0];
|
|
19807
|
-
if (base === void 0) {
|
|
19808
|
-
return object;
|
|
19820
|
+
// ../form-conditions/dist/esm/lib/operators/is-date-newer-than.js
|
|
19821
|
+
var import_dayjs2 = __toESM(require_dayjs_min());
|
|
19822
|
+
var import_isSameOrAfter = __toESM(require_isSameOrAfter());
|
|
19823
|
+
function valueIsDateNewerThan(givenValue, expectedValue, { orEqual = false, dateFactory = () => /* @__PURE__ */ new Date() } = {}) {
|
|
19824
|
+
import_dayjs2.default.extend(import_isSameOrAfter.default);
|
|
19825
|
+
if (isValueEmpty(givenValue)) {
|
|
19826
|
+
return false;
|
|
19809
19827
|
}
|
|
19810
|
-
if (!
|
|
19811
|
-
|
|
19828
|
+
if (!Array.isArray(expectedValue) || expectedValue.length !== 2) {
|
|
19829
|
+
throw new Error("Expected value should be array of two elements");
|
|
19812
19830
|
}
|
|
19813
|
-
|
|
19814
|
-
|
|
19815
|
-
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
|
|
19822
|
-
|
|
19823
|
-
|
|
19824
|
-
|
|
19825
|
-
|
|
19831
|
+
const values = getNumberValuesToCompare(givenValue, expectedValue[0]);
|
|
19832
|
+
const unit = expectedValue[1];
|
|
19833
|
+
switch (unit) {
|
|
19834
|
+
case "day":
|
|
19835
|
+
case "month":
|
|
19836
|
+
if (isArrayOfNumbers(values)) {
|
|
19837
|
+
const [given, units] = values;
|
|
19838
|
+
const date = (0, import_dayjs2.default)(given);
|
|
19839
|
+
const nowUnitsAdded = (0, import_dayjs2.default)(dateFactory()).add(units, unit);
|
|
19840
|
+
if (orEqual) {
|
|
19841
|
+
return date.isSameOrAfter(nowUnitsAdded, "day");
|
|
19842
|
+
}
|
|
19843
|
+
return date.isAfter(nowUnitsAdded, "day");
|
|
19826
19844
|
}
|
|
19827
|
-
});
|
|
19828
19845
|
}
|
|
19829
|
-
|
|
19830
|
-
}
|
|
19846
|
+
throw new Error(`IsDateNewerThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19847
|
+
}
|
|
19831
19848
|
|
|
19832
|
-
// ../form-
|
|
19833
|
-
|
|
19834
|
-
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
|
|
19844
|
-
|
|
19845
|
-
|
|
19846
|
-
|
|
19847
|
-
|
|
19848
|
-
|
|
19849
|
-
|
|
19850
|
-
|
|
19851
|
-
|
|
19852
|
-
|
|
19853
|
-
|
|
19854
|
-
validation = {
|
|
19855
|
-
...validation,
|
|
19856
|
-
string: {
|
|
19857
|
-
...validation?.string,
|
|
19858
|
-
enum: override.countries
|
|
19849
|
+
// ../form-conditions/dist/esm/lib/operators/is-date-older-than.js
|
|
19850
|
+
var import_dayjs3 = __toESM(require_dayjs_min());
|
|
19851
|
+
var import_isSameOrBefore = __toESM(require_isSameOrBefore());
|
|
19852
|
+
function valueIsDateOlderThan(givenValue, expectedValue, { orEqual = false, dateFactory = () => /* @__PURE__ */ new Date() } = {}) {
|
|
19853
|
+
import_dayjs3.default.extend(import_isSameOrBefore.default);
|
|
19854
|
+
if (isValueEmpty(givenValue)) {
|
|
19855
|
+
return false;
|
|
19856
|
+
}
|
|
19857
|
+
if (!Array.isArray(expectedValue) || expectedValue.length !== 2) {
|
|
19858
|
+
throw new Error("Expected value should be array of two elements");
|
|
19859
|
+
}
|
|
19860
|
+
const values = getNumberValuesToCompare(givenValue, expectedValue[0]);
|
|
19861
|
+
const unit = expectedValue[1];
|
|
19862
|
+
switch (unit) {
|
|
19863
|
+
case "day":
|
|
19864
|
+
case "month":
|
|
19865
|
+
if (isArrayOfNumbers(values)) {
|
|
19866
|
+
const [given, units] = values;
|
|
19867
|
+
const date = (0, import_dayjs3.default)(given);
|
|
19868
|
+
const nowUnitsAdded = (0, import_dayjs3.default)(dateFactory()).add(-units, unit);
|
|
19869
|
+
if (orEqual) {
|
|
19870
|
+
return date.isSameOrBefore(nowUnitsAdded, "day");
|
|
19859
19871
|
}
|
|
19860
|
-
|
|
19861
|
-
options = override.countries ? {
|
|
19862
|
-
options: override.countries?.map((country) => ({ value: country }))
|
|
19863
|
-
} : {};
|
|
19864
|
-
}
|
|
19865
|
-
if (field.view?.fieldType === "MULTILINE_ADDRESS") {
|
|
19866
|
-
return applyMultilineAddressOverrides({
|
|
19867
|
-
field,
|
|
19868
|
-
override
|
|
19869
|
-
});
|
|
19870
|
-
}
|
|
19871
|
-
return {
|
|
19872
|
-
...field,
|
|
19873
|
-
...pick(override, "hidden"),
|
|
19874
|
-
...pick(override, "readOnly"),
|
|
19875
|
-
view: {
|
|
19876
|
-
...field.view,
|
|
19877
|
-
...pick(override, "label"),
|
|
19878
|
-
...pick(override, "autocomplete"),
|
|
19879
|
-
...pick(override, "disabled"),
|
|
19880
|
-
...options
|
|
19881
|
-
},
|
|
19882
|
-
validation: {
|
|
19883
|
-
...validation,
|
|
19884
|
-
...pick(override, "required")
|
|
19872
|
+
return date.isBefore(nowUnitsAdded, "day");
|
|
19885
19873
|
}
|
|
19886
|
-
|
|
19874
|
+
}
|
|
19875
|
+
throw new Error(`IsDateOlderThan operator: Unsupported values to compare ${givenValue}, ${expectedValue}`);
|
|
19876
|
+
}
|
|
19877
|
+
|
|
19878
|
+
// ../form-conditions/dist/esm/lib/set-up-operators.js
|
|
19879
|
+
function setUpOperators(defaultEngine2, dateFactory) {
|
|
19880
|
+
const operators = [
|
|
19881
|
+
new import_js_rules_engine.Operator(ConditionOperators.empty, (value) => valueIsMissing(value)),
|
|
19882
|
+
new import_js_rules_engine.Operator(ConditionOperators.notEmpty, (value) => !valueIsMissing(value)),
|
|
19883
|
+
new import_js_rules_engine.Operator(ConditionOperators.between, (givenValue, expectedValue) => valueIsBetween(givenValue, expectedValue)),
|
|
19884
|
+
new import_js_rules_engine.Operator(ConditionOperators.greaterThan, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue)),
|
|
19885
|
+
new import_js_rules_engine.Operator(ConditionOperators.after, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue)),
|
|
19886
|
+
new import_js_rules_engine.Operator(ConditionOperators.greaterThanOrEqual, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue, true)),
|
|
19887
|
+
new import_js_rules_engine.Operator(ConditionOperators.afterOrEqual, (givenValue, expectedValue) => valueIsGreaterThan(givenValue, expectedValue, true)),
|
|
19888
|
+
new import_js_rules_engine.Operator(ConditionOperators.lessThan, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue)),
|
|
19889
|
+
new import_js_rules_engine.Operator(ConditionOperators.before, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue)),
|
|
19890
|
+
new import_js_rules_engine.Operator(ConditionOperators.lessThanOrEqual, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue, true)),
|
|
19891
|
+
new import_js_rules_engine.Operator(ConditionOperators.beforeOrEqual, (givenValue, expectedValue) => valueIsLessThan(givenValue, expectedValue, true)),
|
|
19892
|
+
new import_js_rules_engine.Operator(ConditionOperators.contains, (givenValue, expectedValue) => valueContains(givenValue, expectedValue)),
|
|
19893
|
+
new import_js_rules_engine.Operator(ConditionOperators.equal, (givenValue, expectedValue) => valueEqual(givenValue, expectedValue)),
|
|
19894
|
+
new import_js_rules_engine.Operator(ConditionOperators.notEqual, (givenValue, expectedValue) => !valueEqual(givenValue, expectedValue)),
|
|
19895
|
+
new import_js_rules_engine.Operator(ConditionOperators.notContains, (givenValue, expectedValue) => !valueContains(givenValue, expectedValue)),
|
|
19896
|
+
new import_js_rules_engine.Operator(ConditionOperators.arrayEqual, (givenValue, expectedValue) => arrayEquals(givenValue, expectedValue)),
|
|
19897
|
+
new import_js_rules_engine.Operator(ConditionOperators.arrayNotEqual, (givenValue, expectedValue) => !arrayEquals(givenValue, expectedValue)),
|
|
19898
|
+
new import_js_rules_engine.Operator(ConditionOperators.checked, checked),
|
|
19899
|
+
new import_js_rules_engine.Operator(ConditionOperators.notChecked, (givenValue) => !checked(givenValue)),
|
|
19900
|
+
new import_js_rules_engine.Operator(ConditionOperators.any, (givenValue, expectedValue) => valueContainsAny(givenValue, expectedValue)),
|
|
19901
|
+
new import_js_rules_engine.Operator(ConditionOperators.in, (givenValue, expectedValue) => valueIn(givenValue, expectedValue)),
|
|
19902
|
+
new import_js_rules_engine.Operator(ConditionOperators.notIn, (givenValue, expectedValue) => !valueIn(givenValue, expectedValue)),
|
|
19903
|
+
new import_js_rules_engine.Operator(ConditionOperators.isDateNewerThan, (givenValue, expectedValue) => valueIsDateNewerThan(givenValue, expectedValue, { dateFactory })),
|
|
19904
|
+
new import_js_rules_engine.Operator(ConditionOperators.isDateOlderThan, (givenValue, expectedValue) => valueIsDateOlderThan(givenValue, expectedValue, { dateFactory })),
|
|
19905
|
+
new import_js_rules_engine.Operator(ConditionOperators.isDateNewerThanOrEqual, (givenValue, expectedValue) => valueIsDateNewerThan(givenValue, expectedValue, {
|
|
19906
|
+
orEqual: true,
|
|
19907
|
+
dateFactory
|
|
19908
|
+
})),
|
|
19909
|
+
new import_js_rules_engine.Operator(ConditionOperators.isDateOlderThanOrEqual, (givenValue, expectedValue) => valueIsDateOlderThan(givenValue, expectedValue, {
|
|
19910
|
+
orEqual: true,
|
|
19911
|
+
dateFactory
|
|
19912
|
+
}))
|
|
19913
|
+
];
|
|
19914
|
+
operators.forEach((operator) => {
|
|
19915
|
+
defaultEngine2.removeOperator(operator.name);
|
|
19916
|
+
defaultEngine2.addOperator(operator);
|
|
19887
19917
|
});
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
|
|
19891
|
-
|
|
19892
|
-
|
|
19918
|
+
}
|
|
19919
|
+
|
|
19920
|
+
// ../form-conditions/dist/esm/lib/evaluate-override-condition.js
|
|
19921
|
+
function evaluateOverrideConditionFactory(dateFactory = () => /* @__PURE__ */ new Date()) {
|
|
19922
|
+
setUpOperators(import_js_rules_engine2.defaultEngine, dateFactory);
|
|
19923
|
+
return function evaluateOverrideCondition(override, submission = {}) {
|
|
19924
|
+
if (override.condition) {
|
|
19925
|
+
try {
|
|
19926
|
+
const rule = getRule(override.condition);
|
|
19927
|
+
return rule.evaluate(submission);
|
|
19928
|
+
} catch (e) {
|
|
19929
|
+
console.error(e);
|
|
19930
|
+
return false;
|
|
19931
|
+
}
|
|
19932
|
+
}
|
|
19933
|
+
return true;
|
|
19893
19934
|
};
|
|
19935
|
+
function getRule(condition) {
|
|
19936
|
+
return new import_js_rules_engine2.Rule(condition);
|
|
19937
|
+
}
|
|
19894
19938
|
}
|
|
19895
|
-
|
|
19896
|
-
|
|
19939
|
+
|
|
19940
|
+
// ../form-mapper/dist/esm/lib/submission-mapper.js
|
|
19941
|
+
function mapByIds(submission, form) {
|
|
19942
|
+
return mapBy(submission, form, "id");
|
|
19897
19943
|
}
|
|
19898
|
-
|
|
19899
|
-
|
|
19900
|
-
|
|
19901
|
-
|
|
19902
|
-
|
|
19903
|
-
|
|
19904
|
-
|
|
19905
|
-
|
|
19906
|
-
}
|
|
19907
|
-
|
|
19908
|
-
const fieldOverride = override[fieldName];
|
|
19909
|
-
if (!fieldOverride) {
|
|
19910
|
-
return {
|
|
19911
|
-
multilineAddressOptionsFields,
|
|
19912
|
-
multilineAddressFieldSettings
|
|
19913
|
-
};
|
|
19914
|
-
}
|
|
19915
|
-
return {
|
|
19916
|
-
multilineAddressOptionsFields: {
|
|
19917
|
-
...multilineAddressOptionsFields,
|
|
19918
|
-
[fieldName]: {
|
|
19919
|
-
required: fieldOverride.required
|
|
19920
|
-
}
|
|
19921
|
-
},
|
|
19922
|
-
multilineAddressFieldSettings: {
|
|
19923
|
-
...multilineAddressFieldSettings,
|
|
19924
|
-
[fieldName]: {
|
|
19925
|
-
...multilineAddressFieldSettings?.[fieldName],
|
|
19926
|
-
show: !fieldOverride.hidden
|
|
19927
|
-
}
|
|
19944
|
+
function mapBy(submission, form, by) {
|
|
19945
|
+
const from = "target" ;
|
|
19946
|
+
const fields = (form?.fields?.length ?? 0) > 0 ? form?.fields ?? [] : (form?.formFields?.length ?? 0) > 0 ? form?.formFields ?? [] : form?.fieldsV2 ?? [];
|
|
19947
|
+
const getIdOrTarget = (field, _by) => {
|
|
19948
|
+
if (_by === "id") {
|
|
19949
|
+
return field[_by];
|
|
19950
|
+
} else if ("inputOptions" in field) {
|
|
19951
|
+
return field.inputOptions?.target;
|
|
19952
|
+
} else {
|
|
19953
|
+
return field.target;
|
|
19928
19954
|
}
|
|
19929
19955
|
};
|
|
19930
|
-
|
|
19931
|
-
|
|
19932
|
-
|
|
19933
|
-
|
|
19934
|
-
|
|
19935
|
-
|
|
19936
|
-
|
|
19937
|
-
|
|
19938
|
-
|
|
19939
|
-
|
|
19940
|
-
|
|
19941
|
-
|
|
19942
|
-
|
|
19943
|
-
|
|
19944
|
-
|
|
19945
|
-
|
|
19946
|
-
|
|
19947
|
-
|
|
19948
|
-
|
|
19949
|
-
|
|
19950
|
-
|
|
19951
|
-
|
|
19952
|
-
|
|
19953
|
-
|
|
19954
|
-
|
|
19955
|
-
}
|
|
19956
|
-
return
|
|
19957
|
-
|
|
19958
|
-
|
|
19959
|
-
|
|
19960
|
-
|
|
19961
|
-
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
validation: {
|
|
19967
|
-
...field.validation,
|
|
19968
|
-
predefined: {
|
|
19969
|
-
...field.validation?.predefined,
|
|
19970
|
-
multilineAddressOptions
|
|
19971
|
-
}
|
|
19956
|
+
return fields.reduce((acc, field) => {
|
|
19957
|
+
const source = getIdOrTarget(field, from);
|
|
19958
|
+
const destination = getIdOrTarget(field, by);
|
|
19959
|
+
if (source && destination && source !== destination && acc.hasOwnProperty(source)) {
|
|
19960
|
+
acc[destination] = acc[source];
|
|
19961
|
+
const { [source]: omitted, ...rest } = acc;
|
|
19962
|
+
acc = rest;
|
|
19963
|
+
}
|
|
19964
|
+
return acc;
|
|
19965
|
+
}, { ...submission });
|
|
19966
|
+
}
|
|
19967
|
+
|
|
19968
|
+
// ../form-conditions/dist/esm/lib/apply-overrides.js
|
|
19969
|
+
function applyOverrides(formSchema, submission) {
|
|
19970
|
+
const nestedForms = (formSchema?.nestedForms || []).flatMap(({ targets, form }) => (targets || []).map((target) => ({
|
|
19971
|
+
form: applyFormOverrides2(asRequired2(form), (submission || {})[target]),
|
|
19972
|
+
targets: [target]
|
|
19973
|
+
})));
|
|
19974
|
+
return { ...applyFormOverrides2(formSchema, submission), nestedForms };
|
|
19975
|
+
}
|
|
19976
|
+
function applyFormOverrides2(formSchema, submission) {
|
|
19977
|
+
const submissionsById = mapByIds(submission, formSchema);
|
|
19978
|
+
const { rules } = formSchema;
|
|
19979
|
+
if (rules) {
|
|
19980
|
+
return rules.filter((rule) => isFormRuleValid(rule, formSchema)).filter((rule) => evaluateOverrideConditionFactory()(rule, submissionsById)).reduce((form, rule) => applyItemPropertiesOverride(form, rule), formSchema);
|
|
19981
|
+
}
|
|
19982
|
+
return formSchema;
|
|
19983
|
+
}
|
|
19984
|
+
|
|
19985
|
+
// ../nested-form-overrides/dist/esm/lib/array-utils.js
|
|
19986
|
+
function partition(items, condition) {
|
|
19987
|
+
return items.reduce(([truthy, falsy], element) => {
|
|
19988
|
+
if (condition(element)) {
|
|
19989
|
+
truthy.push(element);
|
|
19990
|
+
} else {
|
|
19991
|
+
falsy.push(element);
|
|
19972
19992
|
}
|
|
19993
|
+
return [truthy, falsy];
|
|
19994
|
+
}, [[], []]);
|
|
19995
|
+
}
|
|
19996
|
+
function mapBy2(items, keyFn) {
|
|
19997
|
+
return items.reduce((acc, item) => {
|
|
19998
|
+
acc[keyFn(item)] = item;
|
|
19999
|
+
return acc;
|
|
20000
|
+
}, {});
|
|
20001
|
+
}
|
|
20002
|
+
|
|
20003
|
+
// ../nested-form-overrides/dist/esm/lib/lang-utils.js
|
|
20004
|
+
function isDefined2(value) {
|
|
20005
|
+
return !(value === null || value === void 0);
|
|
20006
|
+
}
|
|
20007
|
+
|
|
20008
|
+
// ../nested-form-overrides/dist/esm/lib/object-utils.js
|
|
20009
|
+
function isEmpty(object) {
|
|
20010
|
+
return Boolean(object) && Boolean(Object.keys(object).length);
|
|
20011
|
+
}
|
|
20012
|
+
|
|
20013
|
+
// ../nested-form-overrides/dist/esm/lib/nested-form-overrides.js
|
|
20014
|
+
function applyNestedFormOverrides(parentForm) {
|
|
20015
|
+
const fieldsWithFormOverrides = parentForm.fields.filter((field) => isEmpty(field.nestedFormOverrides?.fieldOverrides));
|
|
20016
|
+
const fieldsWithFormOverridesByTarget = mapBy2(fieldsWithFormOverrides, (field) => field.target);
|
|
20017
|
+
const nestedForms = (parentForm.nestedForms || []).reduce((acc, { targets, form } = {}) => {
|
|
20018
|
+
const [targetsWithOverride, targetsWithoutOverride] = partition(targets, (target) => Boolean(fieldsWithFormOverridesByTarget[target]));
|
|
20019
|
+
const nestedFormsWithOverrides = targetsWithOverride.map((target) => ({
|
|
20020
|
+
targets: [target],
|
|
20021
|
+
form: applyOverrides2(form, fieldsWithFormOverridesByTarget[target].nestedFormOverrides)
|
|
20022
|
+
}));
|
|
20023
|
+
const nestedFormsWithoutOverrides = targetsWithoutOverride.length ? [{ targets: targetsWithoutOverride, form }] : [];
|
|
20024
|
+
return [
|
|
20025
|
+
...acc,
|
|
20026
|
+
...nestedFormsWithoutOverrides,
|
|
20027
|
+
...nestedFormsWithOverrides
|
|
20028
|
+
];
|
|
20029
|
+
}, []);
|
|
20030
|
+
return { ...parentForm, nestedForms };
|
|
20031
|
+
}
|
|
20032
|
+
function applyOverrides2(form, overrides) {
|
|
20033
|
+
const fieldOverrides = overrides.fieldOverrides;
|
|
20034
|
+
return {
|
|
20035
|
+
...form,
|
|
20036
|
+
fields: form.fields.map((field) => {
|
|
20037
|
+
const { hidden: hiddenOverride, required: requiredOverride } = fieldOverrides[field.id] || {};
|
|
20038
|
+
return {
|
|
20039
|
+
...field,
|
|
20040
|
+
...isDefined2(hiddenOverride) && { hidden: hiddenOverride },
|
|
20041
|
+
...isDefined2(requiredOverride) && isDefined2(field.validation) && {
|
|
20042
|
+
validation: {
|
|
20043
|
+
...field.validation,
|
|
20044
|
+
required: requiredOverride
|
|
20045
|
+
}
|
|
20046
|
+
}
|
|
20047
|
+
};
|
|
20048
|
+
})
|
|
19973
20049
|
};
|
|
19974
|
-
}
|
|
20050
|
+
}
|
|
19975
20051
|
|
|
19976
20052
|
// ../form-viewer/dist/esm/components/form/all-overrides.js
|
|
19977
20053
|
function applyAllOverrides(form, values, overrides) {
|
|
19978
|
-
return applyNestedForms(
|
|
20054
|
+
return applyNestedForms(applyFormOverrides(applyNestedFormOverrides(applyOverrides(form, values)), overrides ?? {}));
|
|
19979
20055
|
}
|
|
19980
20056
|
|
|
19981
20057
|
// ../form-viewer/dist/esm/components/form/clear-fields.js
|
|
@@ -20020,7 +20096,7 @@ function findHiddenTargets(form) {
|
|
|
20020
20096
|
}, []);
|
|
20021
20097
|
}
|
|
20022
20098
|
|
|
20023
|
-
// ../form-viewer/dist/esm/
|
|
20099
|
+
// ../form-viewer/dist/esm/hooks/form-values.js
|
|
20024
20100
|
var fillEmptyValues = (form, values, recursive = true) => {
|
|
20025
20101
|
if (!form?.fields) {
|
|
20026
20102
|
return {};
|
|
@@ -20058,7 +20134,7 @@ var getStepIndex = (stepId, steps) => {
|
|
|
20058
20134
|
return 0;
|
|
20059
20135
|
};
|
|
20060
20136
|
|
|
20061
|
-
// ../form-viewer/dist/esm/
|
|
20137
|
+
// ../form-viewer/dist/esm/hooks/use-form-values/normalize-values.js
|
|
20062
20138
|
init_types_impl();
|
|
20063
20139
|
init_esm2();
|
|
20064
20140
|
var normalizeValues = (form, values, recursive = true, config) => {
|
|
@@ -20224,7 +20300,7 @@ function acceptOnlyValidProducts({ field, fieldValue }) {
|
|
|
20224
20300
|
return EMPTY_VALUE;
|
|
20225
20301
|
}
|
|
20226
20302
|
const validProducts = fieldValue.filter((productValue) => {
|
|
20227
|
-
const hasAllProps =
|
|
20303
|
+
const hasAllProps = isObject3(productValue) && productValue.hasOwnProperty("productId") && productValue.hasOwnProperty("price") && productValue.hasOwnProperty("quantity");
|
|
20228
20304
|
if (!hasAllProps) {
|
|
20229
20305
|
return false;
|
|
20230
20306
|
}
|
|
@@ -20260,7 +20336,7 @@ function normalizeVatIDValue({ fieldValue }) {
|
|
|
20260
20336
|
if (isEmptyValue) {
|
|
20261
20337
|
return fieldValue;
|
|
20262
20338
|
}
|
|
20263
|
-
if (fieldValue &&
|
|
20339
|
+
if (fieldValue && isObject3(fieldValue) && fieldValue.hasOwnProperty("id")) {
|
|
20264
20340
|
if (fieldValue.hasOwnProperty("type")) {
|
|
20265
20341
|
const type = getVatIDType(vatID.id);
|
|
20266
20342
|
return { id: vatID.id, type };
|
|
@@ -20356,7 +20432,7 @@ function normalizeRepeater({ field, fieldValue, config }) {
|
|
|
20356
20432
|
fields: nestedFields
|
|
20357
20433
|
};
|
|
20358
20434
|
const normalizedValues = fieldValue.map((values) => {
|
|
20359
|
-
if (!
|
|
20435
|
+
if (!isObject3(values)) {
|
|
20360
20436
|
return {};
|
|
20361
20437
|
}
|
|
20362
20438
|
const normalized = normalizeValues(nestedForm, values, false, config);
|
|
@@ -20365,7 +20441,7 @@ function normalizeRepeater({ field, fieldValue, config }) {
|
|
|
20365
20441
|
return normalizedValues;
|
|
20366
20442
|
}
|
|
20367
20443
|
|
|
20368
|
-
// ../form-viewer/dist/esm/
|
|
20444
|
+
// ../form-viewer/dist/esm/hooks/use-form-values/use-form-values.js
|
|
20369
20445
|
var useFormValues = (form, values, onChange, config) => {
|
|
20370
20446
|
const normalizedValues = useMemo(() => normalizeValues(form, fillEmptyValues(form, values), true, config), [form, values, config]);
|
|
20371
20447
|
useEffect(() => {
|
|
@@ -20376,22 +20452,6 @@ var useFormValues = (form, values, onChange, config) => {
|
|
|
20376
20452
|
}, [values, normalizedValues, onChange]);
|
|
20377
20453
|
return normalizedValues;
|
|
20378
20454
|
};
|
|
20379
|
-
var useFormView2 = (form, stepId, breakpoint) => {
|
|
20380
|
-
const { isMobile } = useConfig();
|
|
20381
|
-
const experiments = useExperiments();
|
|
20382
|
-
const useFieldsV2 = experiments.isExperimentEnabled(EXPERIMENTS.USE_FIELDS_V2);
|
|
20383
|
-
return useMemo(() => {
|
|
20384
|
-
return (form?.steps || []).filter((step) => !stepId || stepId === step.id).map((step) => {
|
|
20385
|
-
return createFormView({
|
|
20386
|
-
form,
|
|
20387
|
-
stepId: step.id,
|
|
20388
|
-
isMobile,
|
|
20389
|
-
breakpoint,
|
|
20390
|
-
useFieldsV2
|
|
20391
|
-
});
|
|
20392
|
-
});
|
|
20393
|
-
}, [form, stepId, isMobile, breakpoint, useFieldsV2]);
|
|
20394
|
-
};
|
|
20395
20455
|
var useScrollToFirstError = ({ form, handleStepChange, currentStepId }) => {
|
|
20396
20456
|
const { setFocusedFieldId } = useFocusedField();
|
|
20397
20457
|
const scrollToFirstError = useCallback((errors) => {
|
|
@@ -20430,10 +20490,10 @@ function submitFormClick(params) {
|
|
|
20430
20490
|
return { evid: 1003, src: 156, endpoint: "", params };
|
|
20431
20491
|
}
|
|
20432
20492
|
|
|
20433
|
-
// ../form-viewer/dist/esm/
|
|
20493
|
+
// ../form-viewer/dist/esm/hooks/use-submit/use-submit.js
|
|
20434
20494
|
init_types_impl();
|
|
20435
20495
|
|
|
20436
|
-
// ../form-viewer/dist/esm/
|
|
20496
|
+
// ../form-viewer/dist/esm/hooks/use-submit/utils.js
|
|
20437
20497
|
init_types_impl();
|
|
20438
20498
|
var redirectToExternalUrl = (redirectOptions) => {
|
|
20439
20499
|
const urlWithoutProtocol = redirectOptions?.redirectUrl?.replace(/^https?:\/\//, "");
|
|
@@ -20478,28 +20538,6 @@ var getCheckoutMessage = (text) => {
|
|
|
20478
20538
|
}
|
|
20479
20539
|
};
|
|
20480
20540
|
};
|
|
20481
|
-
var SubmitStatusContext = createContext(void 0);
|
|
20482
|
-
var SubmitStatusProvider = ({ children }) => {
|
|
20483
|
-
const [submitSuccessMessage, setSubmitSuccessMessage] = useState();
|
|
20484
|
-
const [submitFailureCode, setSubmitFailureCode] = useState();
|
|
20485
|
-
const [submitFailureMessage, setSubmitFailureMessage] = useState();
|
|
20486
|
-
const value = useMemo(() => ({
|
|
20487
|
-
submitSuccessMessage,
|
|
20488
|
-
submitFailureCode,
|
|
20489
|
-
submitFailureMessage,
|
|
20490
|
-
setSubmitSuccessMessage,
|
|
20491
|
-
setSubmitFailureCode,
|
|
20492
|
-
setSubmitFailureMessage
|
|
20493
|
-
}), [submitSuccessMessage, submitFailureCode, submitFailureMessage]);
|
|
20494
|
-
return React14.createElement(SubmitStatusContext.Provider, { value }, children);
|
|
20495
|
-
};
|
|
20496
|
-
var useSubmitStatus = () => {
|
|
20497
|
-
const context = useContext(SubmitStatusContext);
|
|
20498
|
-
if (context === void 0) {
|
|
20499
|
-
throw new Error("useSubmitStatus must be used within a SubmitStatusProvider");
|
|
20500
|
-
}
|
|
20501
|
-
return context;
|
|
20502
|
-
};
|
|
20503
20541
|
|
|
20504
20542
|
// ../form-viewer/dist/esm/features/monitoring/interactions.js
|
|
20505
20543
|
var INTERACTIONS = {
|
|
@@ -20507,7 +20545,7 @@ var INTERACTIONS = {
|
|
|
20507
20545
|
SUBMIT_FORM: "wix.forms.submit-form"
|
|
20508
20546
|
};
|
|
20509
20547
|
|
|
20510
|
-
// ../form-viewer/dist/esm/
|
|
20548
|
+
// ../form-viewer/dist/esm/types/bi.js
|
|
20511
20549
|
var BiFormSubmissionStatus;
|
|
20512
20550
|
(function(BiFormSubmissionStatus2) {
|
|
20513
20551
|
BiFormSubmissionStatus2["INIT"] = "INITIATE_SUBMISSION";
|
|
@@ -20515,6 +20553,8 @@ var BiFormSubmissionStatus;
|
|
|
20515
20553
|
BiFormSubmissionStatus2["FAILURE"] = "FAILURE";
|
|
20516
20554
|
BiFormSubmissionStatus2["SUCCESS"] = "SUCCESS";
|
|
20517
20555
|
})(BiFormSubmissionStatus || (BiFormSubmissionStatus = {}));
|
|
20556
|
+
|
|
20557
|
+
// ../form-viewer/dist/esm/hooks/use-submit/use-submit.js
|
|
20518
20558
|
var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuccess, onSubmitFailure, resetFormValues, values, submitSettings, handleStepChange, navigateToCheckout, onValidate, handleScrollToFirstError }) => {
|
|
20519
20559
|
const { setSubmitSuccessMessage, setSubmitFailureCode, setSubmitFailureMessage } = useSubmitStatus();
|
|
20520
20560
|
const { t } = useTranslation();
|
|
@@ -20602,72 +20642,194 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
20602
20642
|
handleSubmitSuccess(response);
|
|
20603
20643
|
resetFormValues?.();
|
|
20604
20644
|
}
|
|
20605
|
-
return response;
|
|
20606
|
-
}, [
|
|
20607
|
-
validateAndScrollToError,
|
|
20608
|
-
values,
|
|
20609
|
-
onSubmit,
|
|
20610
|
-
reportSubmitFormBi,
|
|
20611
|
-
panorama,
|
|
20645
|
+
return response;
|
|
20646
|
+
}, [
|
|
20647
|
+
validateAndScrollToError,
|
|
20648
|
+
values,
|
|
20649
|
+
onSubmit,
|
|
20650
|
+
reportSubmitFormBi,
|
|
20651
|
+
panorama,
|
|
20652
|
+
submitAction,
|
|
20653
|
+
onSubmitFailure,
|
|
20654
|
+
handleCustomErrorMessages,
|
|
20655
|
+
handleSubmitFailure,
|
|
20656
|
+
onSubmitSuccess,
|
|
20657
|
+
fireSubmitSuccess,
|
|
20658
|
+
handleSubmitSuccess,
|
|
20659
|
+
resetFormValues
|
|
20660
|
+
]);
|
|
20661
|
+
return { submitForm };
|
|
20662
|
+
};
|
|
20663
|
+
var useFormView2 = (form, stepId, breakpoint) => {
|
|
20664
|
+
const { isMobile } = useConfig();
|
|
20665
|
+
const experiments = useExperiments();
|
|
20666
|
+
const useFieldsV2 = experiments.isExperimentEnabled(EXPERIMENTS.USE_FIELDS_V2);
|
|
20667
|
+
return useMemo(() => {
|
|
20668
|
+
return (form?.steps || []).filter((step) => !stepId || stepId === step.id).map((step) => {
|
|
20669
|
+
return createFormView({
|
|
20670
|
+
form,
|
|
20671
|
+
stepId: step.id,
|
|
20672
|
+
isMobile,
|
|
20673
|
+
breakpoint,
|
|
20674
|
+
useFieldsV2
|
|
20675
|
+
});
|
|
20676
|
+
});
|
|
20677
|
+
}, [form, stepId, isMobile, breakpoint, useFieldsV2]);
|
|
20678
|
+
};
|
|
20679
|
+
var useReportFieldEdit = (form) => {
|
|
20680
|
+
const lastChangedFields = useRef([]);
|
|
20681
|
+
const bi = useBi();
|
|
20682
|
+
return (changedValues) => {
|
|
20683
|
+
const changedFieldTargets = Object.keys(changedValues);
|
|
20684
|
+
const isEditingDifferentFields = changedFieldTargets.length !== lastChangedFields.current.length || changedFieldTargets.some((target, index) => target !== lastChangedFields.current[index]);
|
|
20685
|
+
if (isEditingDifferentFields) {
|
|
20686
|
+
lastChangedFields.current = changedFieldTargets;
|
|
20687
|
+
changedFieldTargets.forEach((target) => {
|
|
20688
|
+
const changedField = form?.fields?.find((field) => field.target === target);
|
|
20689
|
+
bi.report(formFieldEdit({
|
|
20690
|
+
field_id: changedField?.id,
|
|
20691
|
+
field_label: changedField?.view?.label,
|
|
20692
|
+
field_target: changedField?.target || void 0
|
|
20693
|
+
}));
|
|
20694
|
+
});
|
|
20695
|
+
}
|
|
20696
|
+
};
|
|
20697
|
+
};
|
|
20698
|
+
|
|
20699
|
+
// ../form-viewer/dist/esm/hooks/use-form.js
|
|
20700
|
+
var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange, onChange, errors, onValidate, onSubmit, onSubmitSuccess, onSubmitFailure, enableScrollToFirstError = true, forwardedRef, overrides, actions, config, breakpoint, validationMode, fieldMap, inProgress }) => {
|
|
20701
|
+
const formWithOverrides = useMemo(() => applyAllOverrides(paramForm, paramValues, overrides), [paramForm, paramValues, overrides]);
|
|
20702
|
+
const formId = formWithOverrides.id;
|
|
20703
|
+
const { setFocusedFieldId } = useFocusedField();
|
|
20704
|
+
const normalizedValues = useFormValues(formWithOverrides, paramValues, onChange, config);
|
|
20705
|
+
const valuesRef = useRef(normalizedValues);
|
|
20706
|
+
valuesRef.current = normalizedValues;
|
|
20707
|
+
const errorsRef = useRef(errors);
|
|
20708
|
+
errorsRef.current = errors;
|
|
20709
|
+
const reportFieldEdit = useReportFieldEdit(formWithOverrides);
|
|
20710
|
+
const onFieldChange = (target, newValue) => {
|
|
20711
|
+
const oldValues = valuesRef.current;
|
|
20712
|
+
const oldErrors = errorsRef.current;
|
|
20713
|
+
if (!deepEqual(newValue, oldValues[target])) {
|
|
20714
|
+
reportFieldEdit({
|
|
20715
|
+
[target]: newValue
|
|
20716
|
+
});
|
|
20717
|
+
const newValues = {
|
|
20718
|
+
...oldValues,
|
|
20719
|
+
[target]: newValue
|
|
20720
|
+
};
|
|
20721
|
+
const cleared = clearFieldsWhenHiddenByRule(paramForm, overrides, oldValues, newValues, oldErrors);
|
|
20722
|
+
onChange(cleared.values);
|
|
20723
|
+
onValidate(cleared.errors);
|
|
20724
|
+
}
|
|
20725
|
+
};
|
|
20726
|
+
const _onValidate = (newErrors) => {
|
|
20727
|
+
onValidate(newErrors);
|
|
20728
|
+
};
|
|
20729
|
+
const formViews = useFormView2(formWithOverrides, stepId, breakpoint);
|
|
20730
|
+
const currentView = formViews[0];
|
|
20731
|
+
const { validateFields: validateFields2, validateStep, handleFieldValidation } = useValidation({
|
|
20732
|
+
form: formWithOverrides,
|
|
20733
|
+
errorsRef,
|
|
20734
|
+
setErrors: _onValidate,
|
|
20735
|
+
validationMode
|
|
20736
|
+
});
|
|
20737
|
+
const handleStepChange = useCallback((step) => {
|
|
20738
|
+
const newStepId = formWithOverrides.steps?.[step]?.id;
|
|
20739
|
+
if (newStepId) {
|
|
20740
|
+
const firstFieldInStep = getSortedFields(formWithOverrides, {
|
|
20741
|
+
stepId: newStepId
|
|
20742
|
+
})[0];
|
|
20743
|
+
onStepIdChange?.(newStepId);
|
|
20744
|
+
setFocusedFieldId(firstFieldInStep?.id);
|
|
20745
|
+
}
|
|
20746
|
+
}, [formWithOverrides, onStepIdChange, setFocusedFieldId]);
|
|
20747
|
+
const { scrollToFirstError, handleScrollToFirstError } = useScrollToFirstError({
|
|
20748
|
+
form: formWithOverrides,
|
|
20749
|
+
handleStepChange,
|
|
20750
|
+
currentStepId: stepId
|
|
20751
|
+
});
|
|
20752
|
+
const resetFormValues = useCallback(() => {
|
|
20753
|
+
onChange(fillEmptyValues(formWithOverrides, {}));
|
|
20754
|
+
}, [formWithOverrides, onChange]);
|
|
20755
|
+
const validateAndScrollToError = useCallback(async (values) => {
|
|
20756
|
+
const validationErrors = await validateFields2(values);
|
|
20757
|
+
if (validationErrors && validationErrors.length) {
|
|
20758
|
+
handleScrollToFirstError(validationErrors);
|
|
20759
|
+
}
|
|
20760
|
+
return validationErrors;
|
|
20761
|
+
}, [validateFields2, handleScrollToFirstError]);
|
|
20762
|
+
const submitAction = useCallback(async (values) => {
|
|
20763
|
+
const response = await actions?.submitForm?.(formId, values);
|
|
20764
|
+
return response?.submission;
|
|
20765
|
+
}, [actions, formId]);
|
|
20766
|
+
const { submitForm } = useSubmit({
|
|
20612
20767
|
submitAction,
|
|
20613
|
-
|
|
20614
|
-
handleCustomErrorMessages,
|
|
20615
|
-
handleSubmitFailure,
|
|
20768
|
+
onSubmit,
|
|
20616
20769
|
onSubmitSuccess,
|
|
20617
|
-
|
|
20618
|
-
|
|
20619
|
-
|
|
20620
|
-
|
|
20621
|
-
|
|
20622
|
-
|
|
20623
|
-
|
|
20624
|
-
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
const allErrors = mergeErrors({ errors: _errors, additionalErrors });
|
|
20635
|
-
setErrors(allErrors);
|
|
20636
|
-
return allErrors;
|
|
20637
|
-
}, [form, setErrors, addressTemplates, externalData, validationMode]);
|
|
20638
|
-
const handleFieldValidation = useCallback(async (fieldsToValidate) => {
|
|
20639
|
-
const fieldErrors = await getFieldErrors(fieldsToValidate, form, addressTemplates, externalData, validationMode);
|
|
20640
|
-
const otherErrors = (errorsRef.current ?? []).filter((error) => {
|
|
20641
|
-
return !findErrorByNormalizedPath(fieldsToValidate, error.errorPath);
|
|
20642
|
-
});
|
|
20643
|
-
const allErrors = [...otherErrors, ...fieldErrors];
|
|
20644
|
-
setErrors(allErrors);
|
|
20645
|
-
return allErrors;
|
|
20646
|
-
}, [
|
|
20647
|
-
errorsRef,
|
|
20648
|
-
form,
|
|
20649
|
-
setErrors,
|
|
20650
|
-
addressTemplates,
|
|
20651
|
-
externalData,
|
|
20652
|
-
validationMode
|
|
20653
|
-
]);
|
|
20654
|
-
const validateStep = useCallback(async (stepId, newValues) => {
|
|
20655
|
-
const items = form?.steps?.find((step) => step.id === stepId)?.layout?.large?.items || [];
|
|
20656
|
-
const validationErrors = await Promise.all(items.map(async (item) => {
|
|
20657
|
-
const field = form?.fields?.find((_field) => _field.id === item.fieldId);
|
|
20658
|
-
const fieldValidationResult = field?.target ? await handleFieldValidation([
|
|
20659
|
-
{
|
|
20660
|
-
path: field.target,
|
|
20661
|
-
value: newValues[field.target]
|
|
20770
|
+
onSubmitFailure,
|
|
20771
|
+
resetFormValues,
|
|
20772
|
+
validateAndScrollToError,
|
|
20773
|
+
values: normalizedValues,
|
|
20774
|
+
submitSettings: formWithOverrides.submitSettings,
|
|
20775
|
+
navigateToCheckout: actions?.navigateToCheckout,
|
|
20776
|
+
handleStepChange,
|
|
20777
|
+
onValidate: _onValidate,
|
|
20778
|
+
handleScrollToFirstError
|
|
20779
|
+
});
|
|
20780
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
20781
|
+
submit: submitForm,
|
|
20782
|
+
validate: async () => {
|
|
20783
|
+
const validationErrors = await validateFields2(normalizedValues);
|
|
20784
|
+
if (validationErrors && validationErrors.length > 0) {
|
|
20785
|
+
if (enableScrollToFirstError) {
|
|
20786
|
+
scrollToFirstError(validationErrors);
|
|
20662
20787
|
}
|
|
20663
|
-
|
|
20664
|
-
|
|
20665
|
-
|
|
20666
|
-
|
|
20667
|
-
|
|
20668
|
-
|
|
20669
|
-
|
|
20670
|
-
|
|
20788
|
+
return false;
|
|
20789
|
+
}
|
|
20790
|
+
return true;
|
|
20791
|
+
},
|
|
20792
|
+
validateStep: (step) => validateStep(step, normalizedValues)
|
|
20793
|
+
}), [
|
|
20794
|
+
submitForm,
|
|
20795
|
+
validateStep,
|
|
20796
|
+
validateFields2,
|
|
20797
|
+
normalizedValues,
|
|
20798
|
+
enableScrollToFirstError,
|
|
20799
|
+
scrollToFirstError
|
|
20800
|
+
]);
|
|
20801
|
+
const currentStep = getStepIndex(stepId, formWithOverrides.steps);
|
|
20802
|
+
const setNextStep = useCallback(() => handleStepChange(currentStep + 1), [currentStep, handleStepChange]);
|
|
20803
|
+
const setPreviousStep = useCallback(() => handleStepChange(currentStep - 1), [currentStep, handleStepChange]);
|
|
20804
|
+
const fieldActions = useMemo(() => actions ? {
|
|
20805
|
+
actions: { ...actions, submitForm, setNextStep, setPreviousStep },
|
|
20806
|
+
formId,
|
|
20807
|
+
inProgress
|
|
20808
|
+
} : { actions: { submitForm, setNextStep, setPreviousStep } }, [actions, formId, inProgress, submitForm, setNextStep, setPreviousStep]);
|
|
20809
|
+
const formFields = createFormFields({
|
|
20810
|
+
form: currentView,
|
|
20811
|
+
formSchema: formWithOverrides,
|
|
20812
|
+
values: normalizedValues,
|
|
20813
|
+
onFieldChange,
|
|
20814
|
+
errors,
|
|
20815
|
+
FieldLayout: DefaultFieldLayout,
|
|
20816
|
+
fields: fieldMap,
|
|
20817
|
+
validateFields: handleFieldValidation,
|
|
20818
|
+
fieldActions
|
|
20819
|
+
});
|
|
20820
|
+
return {
|
|
20821
|
+
currentView,
|
|
20822
|
+
formViews,
|
|
20823
|
+
normalizedValues,
|
|
20824
|
+
onFieldChange,
|
|
20825
|
+
errors,
|
|
20826
|
+
formFields,
|
|
20827
|
+
handleFieldValidation,
|
|
20828
|
+
formWithOverrides,
|
|
20829
|
+
currentStep,
|
|
20830
|
+
fieldActions,
|
|
20831
|
+
submitForm
|
|
20832
|
+
};
|
|
20671
20833
|
};
|
|
20672
20834
|
var dummyBi = {
|
|
20673
20835
|
log: () => Promise.resolve(),
|
|
@@ -20805,127 +20967,6 @@ var FormViewerProvider = ({ i18n, bi, biFormFillSessionId, form, isMobile, isEdi
|
|
|
20805
20967
|
)
|
|
20806
20968
|
);
|
|
20807
20969
|
};
|
|
20808
|
-
var useForm2 = ({ form: paramForm, values: paramValues, stepId, onStepIdChange, onChange, errors, onValidate, enableScrollToFirstError = true, forwardedRef, overrides, actions, config, breakpoint, validationMode, fieldMap }) => {
|
|
20809
|
-
const formWithOverrides = useMemo(() => applyAllOverrides(paramForm, paramValues, overrides), [paramForm, paramValues, overrides]);
|
|
20810
|
-
const formId = formWithOverrides.id;
|
|
20811
|
-
const { setFocusedFieldId } = useFocusedField();
|
|
20812
|
-
const normalizedValues = useFormValues(formWithOverrides, paramValues, onChange, config);
|
|
20813
|
-
const valuesRef = useRef(normalizedValues);
|
|
20814
|
-
valuesRef.current = normalizedValues;
|
|
20815
|
-
const errorsRef = useRef(errors);
|
|
20816
|
-
errorsRef.current = errors;
|
|
20817
|
-
const onFieldChange = (target, newValue) => {
|
|
20818
|
-
const oldValues = valuesRef.current;
|
|
20819
|
-
const oldErrors = errorsRef.current;
|
|
20820
|
-
if (!deepEqual(newValue, oldValues[target])) {
|
|
20821
|
-
const newValues = {
|
|
20822
|
-
...oldValues,
|
|
20823
|
-
[target]: newValue
|
|
20824
|
-
};
|
|
20825
|
-
const cleared = clearFieldsWhenHiddenByRule(paramForm, overrides, oldValues, newValues, oldErrors);
|
|
20826
|
-
onChange(cleared.values);
|
|
20827
|
-
onValidate(cleared.errors);
|
|
20828
|
-
}
|
|
20829
|
-
};
|
|
20830
|
-
const _onValidate = (newErrors) => {
|
|
20831
|
-
onValidate(newErrors);
|
|
20832
|
-
};
|
|
20833
|
-
const formViews = useFormView2(formWithOverrides, stepId, breakpoint);
|
|
20834
|
-
const currentView = formViews[0];
|
|
20835
|
-
const { validateFields: validateFields2, validateStep, handleFieldValidation } = useValidation({
|
|
20836
|
-
form: formWithOverrides,
|
|
20837
|
-
errorsRef,
|
|
20838
|
-
setErrors: _onValidate,
|
|
20839
|
-
validationMode
|
|
20840
|
-
});
|
|
20841
|
-
const handleStepChange = useCallback((step) => {
|
|
20842
|
-
const newStepId = formWithOverrides.steps?.[step]?.id;
|
|
20843
|
-
if (newStepId) {
|
|
20844
|
-
const firstFieldInStep = getSortedFields(formWithOverrides, {
|
|
20845
|
-
stepId: newStepId
|
|
20846
|
-
})[0];
|
|
20847
|
-
onStepIdChange?.(newStepId);
|
|
20848
|
-
setFocusedFieldId(firstFieldInStep?.id);
|
|
20849
|
-
}
|
|
20850
|
-
}, [formWithOverrides, onStepIdChange, setFocusedFieldId]);
|
|
20851
|
-
const { scrollToFirstError, handleScrollToFirstError } = useScrollToFirstError({
|
|
20852
|
-
form: formWithOverrides,
|
|
20853
|
-
handleStepChange,
|
|
20854
|
-
currentStepId: stepId
|
|
20855
|
-
});
|
|
20856
|
-
const resetFormValues = useCallback(() => {
|
|
20857
|
-
onChange(fillEmptyValues(formWithOverrides, {}));
|
|
20858
|
-
}, [formWithOverrides, onChange]);
|
|
20859
|
-
const validateAndScrollToError = useCallback(async (values) => {
|
|
20860
|
-
const validationErrors = await validateFields2(values);
|
|
20861
|
-
if (validationErrors && validationErrors.length) {
|
|
20862
|
-
handleScrollToFirstError(validationErrors);
|
|
20863
|
-
}
|
|
20864
|
-
return validationErrors;
|
|
20865
|
-
}, [validateFields2, handleScrollToFirstError]);
|
|
20866
|
-
const submitAction = useCallback(async (values) => {
|
|
20867
|
-
const response = await actions?.submitForm?.(formId, values);
|
|
20868
|
-
return response?.submission;
|
|
20869
|
-
}, [actions, formId]);
|
|
20870
|
-
const { submitForm } = useSubmit({
|
|
20871
|
-
submitAction,
|
|
20872
|
-
resetFormValues,
|
|
20873
|
-
validateAndScrollToError,
|
|
20874
|
-
values: normalizedValues,
|
|
20875
|
-
submitSettings: formWithOverrides.submitSettings,
|
|
20876
|
-
navigateToCheckout: actions?.navigateToCheckout,
|
|
20877
|
-
handleStepChange,
|
|
20878
|
-
onValidate: _onValidate,
|
|
20879
|
-
handleScrollToFirstError
|
|
20880
|
-
});
|
|
20881
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
20882
|
-
submit: submitForm,
|
|
20883
|
-
validate: async () => {
|
|
20884
|
-
const validationErrors = await validateFields2(normalizedValues);
|
|
20885
|
-
if (validationErrors && validationErrors.length > 0) {
|
|
20886
|
-
if (enableScrollToFirstError) {
|
|
20887
|
-
scrollToFirstError(validationErrors);
|
|
20888
|
-
}
|
|
20889
|
-
return false;
|
|
20890
|
-
}
|
|
20891
|
-
return true;
|
|
20892
|
-
},
|
|
20893
|
-
validateStep: (step) => validateStep(step, normalizedValues)
|
|
20894
|
-
}), [
|
|
20895
|
-
submitForm,
|
|
20896
|
-
validateStep,
|
|
20897
|
-
validateFields2,
|
|
20898
|
-
normalizedValues,
|
|
20899
|
-
enableScrollToFirstError,
|
|
20900
|
-
scrollToFirstError
|
|
20901
|
-
]);
|
|
20902
|
-
const currentStep = getStepIndex(stepId, formWithOverrides.steps);
|
|
20903
|
-
const setNextStep = useCallback(() => handleStepChange(currentStep + 1), [currentStep, handleStepChange]);
|
|
20904
|
-
const setPreviousStep = useCallback(() => handleStepChange(currentStep - 1), [currentStep, handleStepChange]);
|
|
20905
|
-
const fieldActions = useMemo(() => actions ? {
|
|
20906
|
-
actions: { ...actions, submitForm, setNextStep, setPreviousStep },
|
|
20907
|
-
formId,
|
|
20908
|
-
inProgress: false
|
|
20909
|
-
} : { actions: { submitForm, setNextStep, setPreviousStep } }, [actions, formId, submitForm, setNextStep, setPreviousStep]);
|
|
20910
|
-
const formFields = createFormFields({
|
|
20911
|
-
form: currentView,
|
|
20912
|
-
formSchema: formWithOverrides,
|
|
20913
|
-
values: normalizedValues,
|
|
20914
|
-
onFieldChange,
|
|
20915
|
-
errors,
|
|
20916
|
-
FieldLayout: DefaultFieldLayout,
|
|
20917
|
-
fields: fieldMap,
|
|
20918
|
-
validateFields: handleFieldValidation,
|
|
20919
|
-
fieldActions
|
|
20920
|
-
});
|
|
20921
|
-
return {
|
|
20922
|
-
currentView,
|
|
20923
|
-
normalizedValues,
|
|
20924
|
-
onFieldChange,
|
|
20925
|
-
errors,
|
|
20926
|
-
formFields
|
|
20927
|
-
};
|
|
20928
|
-
};
|
|
20929
20970
|
function normalizeSchema(obj) {
|
|
20930
20971
|
if (Array.isArray(obj)) {
|
|
20931
20972
|
return obj.map(normalizeSchema);
|