@asantemedia-org/edwardsvacuum-design-system 1.6.19 → 1.6.20
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.css +22 -6
- package/dist/index.esm.css +22 -6
- package/dist/index.esm.js +150 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +150 -26
- package/dist/index.js.map +1 -1
- package/dist/index.scss +22 -6
- package/dist/src/stories/experiences/QRFormJourney/Qr-form/Qr-form.d.ts +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -753,10 +753,12 @@ var QrFormField = function (props) {
|
|
|
753
753
|
}, []);
|
|
754
754
|
var supportsValue = props.type !== "checkbox";
|
|
755
755
|
return props.type ? /*#__PURE__*/React.createElement("div", {
|
|
756
|
-
className: "qr-form-filed-wrapper"
|
|
756
|
+
className: (props.hasError ? "error" : "") + " qr-form-filed-wrapper"
|
|
757
757
|
}, /*#__PURE__*/React.createElement("label", {
|
|
758
758
|
htmlFor: inputId
|
|
759
|
-
}, /*#__PURE__*/React.createElement("span",
|
|
759
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
760
|
+
className: "label"
|
|
761
|
+
}, props.label, " ", props.required && /*#__PURE__*/React.createElement("span", {
|
|
760
762
|
className: "required-asterisk"
|
|
761
763
|
}, "*")), /*#__PURE__*/React.createElement(FormFieldRenderer, _extends({
|
|
762
764
|
key: props.value,
|
|
@@ -785,20 +787,37 @@ var QrFormField = function (props) {
|
|
|
785
787
|
};
|
|
786
788
|
|
|
787
789
|
var QrForm = function (props) {
|
|
788
|
-
var _a
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
formValues = _b[0],
|
|
793
|
-
setFormValues = _b[1];
|
|
790
|
+
var _a;
|
|
791
|
+
var _b = React.useState(0),
|
|
792
|
+
currentPage = _b[0],
|
|
793
|
+
setCurrentPage = _b[1];
|
|
794
794
|
var _c = React.useState({}),
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
var _d = React.useState(
|
|
798
|
-
_d[0]
|
|
799
|
-
|
|
795
|
+
formValues = _c[0],
|
|
796
|
+
setFormValues = _c[1];
|
|
797
|
+
var _d = React.useState({}),
|
|
798
|
+
errors = _d[0],
|
|
799
|
+
setErrors = _d[1];
|
|
800
|
+
var _e = React.useState(false);
|
|
801
|
+
_e[0];
|
|
802
|
+
var setShowErrors = _e[1];
|
|
803
|
+
var _f = React.useState(null),
|
|
804
|
+
countryOptions = _f[0],
|
|
805
|
+
setCountryOptions = _f[1];
|
|
806
|
+
var _g = React.useState(true);
|
|
807
|
+
_g[0];
|
|
808
|
+
var setIsLoadingCountries = _g[1];
|
|
800
809
|
var i18n = props;
|
|
801
810
|
var buttonProps = props;
|
|
811
|
+
var consentFields = ((_a = props.consents) === null || _a === void 0 ? void 0 : _a.map(function (consent, index) {
|
|
812
|
+
return {
|
|
813
|
+
type: "checkbox",
|
|
814
|
+
name: "consent_".concat(index + 1),
|
|
815
|
+
label: consent.policyText ? consent.policyText : consent.policyLink ? "I accept the policy: ".concat(consent.policyLink) : "Consent ".concat(index + 1),
|
|
816
|
+
value: "true",
|
|
817
|
+
required: !!consent.policyMandatory,
|
|
818
|
+
errorMessage: consent.policyMandatory ? "Please acknowledge this consent" : ""
|
|
819
|
+
};
|
|
820
|
+
})) || [];
|
|
802
821
|
React.useEffect(function () {
|
|
803
822
|
var initialValues = {};
|
|
804
823
|
props.fields.forEach(function (field) {
|
|
@@ -806,6 +825,95 @@ var QrForm = function (props) {
|
|
|
806
825
|
});
|
|
807
826
|
setFormValues(initialValues);
|
|
808
827
|
}, [props.fields]);
|
|
828
|
+
React.useEffect(function () {
|
|
829
|
+
function loadCountries() {
|
|
830
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
831
|
+
var fallbackCountries, res, data, err_1;
|
|
832
|
+
return __generator(this, function (_a) {
|
|
833
|
+
switch (_a.label) {
|
|
834
|
+
case 0:
|
|
835
|
+
fallbackCountries = [{
|
|
836
|
+
value: "us",
|
|
837
|
+
label: "United States"
|
|
838
|
+
}, {
|
|
839
|
+
value: "gb",
|
|
840
|
+
label: "United Kingdom"
|
|
841
|
+
}, {
|
|
842
|
+
value: "de",
|
|
843
|
+
label: "Germany"
|
|
844
|
+
}, {
|
|
845
|
+
value: "fr",
|
|
846
|
+
label: "France"
|
|
847
|
+
}, {
|
|
848
|
+
value: "cn",
|
|
849
|
+
label: "China"
|
|
850
|
+
}, {
|
|
851
|
+
value: "other",
|
|
852
|
+
label: "Other"
|
|
853
|
+
}];
|
|
854
|
+
_a.label = 1;
|
|
855
|
+
case 1:
|
|
856
|
+
_a.trys.push([1, 4, 5, 6]);
|
|
857
|
+
return [4 /*yield*/, fetch("/etc.clientlibs/vtba/clientlibs/resources/countries.json")];
|
|
858
|
+
case 2:
|
|
859
|
+
res = _a.sent();
|
|
860
|
+
if (!res.ok) throw new Error("HTTP ".concat(res.status));
|
|
861
|
+
return [4 /*yield*/, res.json()];
|
|
862
|
+
case 3:
|
|
863
|
+
data = _a.sent();
|
|
864
|
+
setCountryOptions((data === null || data === void 0 ? void 0 : data.options) || fallbackCountries);
|
|
865
|
+
return [3 /*break*/, 6];
|
|
866
|
+
case 4:
|
|
867
|
+
err_1 = _a.sent();
|
|
868
|
+
console.warn("Could not fetch countries.json, using fallback:", err_1);
|
|
869
|
+
setCountryOptions(fallbackCountries);
|
|
870
|
+
return [3 /*break*/, 6];
|
|
871
|
+
case 5:
|
|
872
|
+
setIsLoadingCountries(false);
|
|
873
|
+
return [7 /*endfinally*/];
|
|
874
|
+
case 6:
|
|
875
|
+
return [2 /*return*/];
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
loadCountries();
|
|
881
|
+
}, []);
|
|
882
|
+
React.useEffect(function () {
|
|
883
|
+
function fetchCity() {
|
|
884
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
885
|
+
var res, data_1, err_2;
|
|
886
|
+
return __generator(this, function (_a) {
|
|
887
|
+
switch (_a.label) {
|
|
888
|
+
case 0:
|
|
889
|
+
_a.trys.push([0, 3,, 4]);
|
|
890
|
+
return [4 /*yield*/, fetch('https://ipapi.co/json/')];
|
|
891
|
+
case 1:
|
|
892
|
+
res = _a.sent();
|
|
893
|
+
if (!res.ok) throw new Error('IP lookup failed');
|
|
894
|
+
return [4 /*yield*/, res.json()];
|
|
895
|
+
case 2:
|
|
896
|
+
data_1 = _a.sent();
|
|
897
|
+
if (data_1.city) {
|
|
898
|
+
setFormValues(function (prev) {
|
|
899
|
+
return __assign(__assign({}, prev), {
|
|
900
|
+
ip_location: data_1.city
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
return [3 /*break*/, 4];
|
|
905
|
+
case 3:
|
|
906
|
+
err_2 = _a.sent();
|
|
907
|
+
console.warn('Could not resolve city from IP:', err_2);
|
|
908
|
+
return [3 /*break*/, 4];
|
|
909
|
+
case 4:
|
|
910
|
+
return [2 /*return*/];
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
fetchCity();
|
|
916
|
+
}, []);
|
|
809
917
|
var pages = [__spreadArray(__spreadArray([], props.fields, true), [{
|
|
810
918
|
type: "select",
|
|
811
919
|
name: "how_can_we_help",
|
|
@@ -845,15 +953,17 @@ var QrForm = function (props) {
|
|
|
845
953
|
name: "firstname",
|
|
846
954
|
label: "First Name",
|
|
847
955
|
placeholder: "First Name"
|
|
956
|
+
}, {
|
|
957
|
+
type: "text",
|
|
958
|
+
name: "company",
|
|
959
|
+
label: "Company",
|
|
960
|
+
placeholder: "Company"
|
|
848
961
|
}], /*page 3*/
|
|
849
962
|
[{
|
|
850
963
|
type: "select",
|
|
851
964
|
name: "country",
|
|
852
965
|
label: "Country",
|
|
853
|
-
options: [
|
|
854
|
-
value: 'poland',
|
|
855
|
-
label: 'Poland'
|
|
856
|
-
}]
|
|
966
|
+
options: countryOptions || []
|
|
857
967
|
}, {
|
|
858
968
|
type: "email",
|
|
859
969
|
name: "email",
|
|
@@ -861,15 +971,25 @@ var QrForm = function (props) {
|
|
|
861
971
|
placeholder: "Email",
|
|
862
972
|
required: true,
|
|
863
973
|
errorMessage: "Error"
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
974
|
+
}, {
|
|
975
|
+
type: "tel",
|
|
976
|
+
name: "phone",
|
|
977
|
+
label: "Phone",
|
|
978
|
+
placeholder: "Phone",
|
|
979
|
+
required: false
|
|
980
|
+
}, {
|
|
981
|
+
type: "text",
|
|
982
|
+
name: "city",
|
|
983
|
+
label: "City",
|
|
984
|
+
placeholder: "City",
|
|
985
|
+
required: false
|
|
986
|
+
}, {
|
|
987
|
+
type: "text",
|
|
988
|
+
name: "postcode",
|
|
989
|
+
label: "Postcode / ZIP",
|
|
990
|
+
placeholder: "Postcode / ZIP",
|
|
991
|
+
required: false
|
|
992
|
+
}], __spreadArray([], consentFields, true)];
|
|
873
993
|
var handleChange = function (name, value) {
|
|
874
994
|
setFormValues(function (prevValues) {
|
|
875
995
|
var _a;
|
|
@@ -1066,6 +1186,10 @@ var QrForm = function (props) {
|
|
|
1066
1186
|
}), renderFormSection({
|
|
1067
1187
|
pageIndex: 3,
|
|
1068
1188
|
sectionTitle: "Form consent"
|
|
1189
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
1190
|
+
type: "hidden",
|
|
1191
|
+
name: "ip_location",
|
|
1192
|
+
value: formValues.ip_location || ''
|
|
1069
1193
|
})) : /*#__PURE__*/React.createElement("div", {
|
|
1070
1194
|
className: "qr-form-thank-you-page"
|
|
1071
1195
|
}, /*#__PURE__*/React.createElement("h2", null, props.thankYouTitle), /*#__PURE__*/React.createElement("p", null, props.thankYouText), /*#__PURE__*/React.createElement(Button, {
|