@asantemedia-org/edwardsvacuum-design-system 1.6.18 → 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 CHANGED
@@ -1413,7 +1413,7 @@
1413
1413
  border-radius: 50%;
1414
1414
  }
1415
1415
  .qr-journey-form-wrapper section .progress-indicator .progress-visual {
1416
- --percent:30%;
1416
+ --percent: 30%;
1417
1417
  position: absolute;
1418
1418
  background: conic-gradient(rgb(196, 38, 46) var(--percent), transparent 0);
1419
1419
  width: 51px;
@@ -1453,18 +1453,34 @@
1453
1453
  }
1454
1454
  .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=text], .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=email], .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=number], .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=tel], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=text], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=email], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=number], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=tel], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=text], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=email], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=number], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=tel] {
1455
1455
  line-height: 1em;
1456
- padding: 10px 18px;
1456
+ padding: 20px 18px 2px 18px;
1457
1457
  box-sizing: content-box;
1458
1458
  }
1459
+ .qr-journey-form-wrapper .qr-form-filed-wrapper label input:active, .qr-journey-form-wrapper .qr-form-filed-wrapper label input:focus, .qr-journey-form-wrapper .qr-form-filed-wrapper label input:focus-visible, .qr-journey-form-wrapper .qr-form-filed-wrapper label select:active, .qr-journey-form-wrapper .qr-form-filed-wrapper label select:focus, .qr-journey-form-wrapper .qr-form-filed-wrapper label select:focus-visible, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea:active, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea:focus, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea:focus-visible {
1460
+ border: 2px solid #678B3B;
1461
+ outline: none;
1462
+ }
1459
1463
  .qr-journey-form-wrapper .qr-form-filed-wrapper label select, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea {
1460
1464
  line-height: 1em;
1461
- padding: 10px 18px;
1465
+ padding: 20px 18px 2px 18px;
1462
1466
  box-sizing: content-box;
1463
1467
  }
1464
- .qr-journey-form-wrapper .qr-form-filed-wrapper label > span {
1465
- opacity: 0;
1468
+ .qr-journey-form-wrapper .qr-form-filed-wrapper label > .label {
1469
+ position: relative;
1470
+ top: 10px;
1471
+ left: 10px;
1472
+ font-size: 12px;
1466
1473
  line-height: 0;
1467
1474
  }
1475
+ .qr-journey-form-wrapper .qr-form-filed-wrapper.error label input {
1476
+ border: 2px solid rgb(196, 38, 46);
1477
+ }
1478
+ .qr-journey-form-wrapper .qr-form-filed-wrapper.error .formfield-error {
1479
+ position: relative;
1480
+ top: -10px;
1481
+ font-size: 16px;
1482
+ line-height: 18px;
1483
+ }
1468
1484
  .qr-journey-form-wrapper .disabled-product-fields-section {
1469
1485
  background-color: rgb(233, 233, 233);
1470
1486
  padding: 5px 18px;
@@ -1498,7 +1514,7 @@
1498
1514
  flex: 0.5 1;
1499
1515
  min-width: 50%;
1500
1516
  }
1501
- .qr-journey-form-wrapper .disabled-product-fields-section .qr-form-fields .qr-form-filed-wrapper label span {
1517
+ .qr-journey-form-wrapper .disabled-product-fields-section .qr-form-fields .qr-form-filed-wrapper label .label {
1502
1518
  height: 1em;
1503
1519
  opacity: 1;
1504
1520
  font-weight: 900;
@@ -1413,7 +1413,7 @@
1413
1413
  border-radius: 50%;
1414
1414
  }
1415
1415
  .qr-journey-form-wrapper section .progress-indicator .progress-visual {
1416
- --percent:30%;
1416
+ --percent: 30%;
1417
1417
  position: absolute;
1418
1418
  background: conic-gradient(rgb(196, 38, 46) var(--percent), transparent 0);
1419
1419
  width: 51px;
@@ -1453,18 +1453,34 @@
1453
1453
  }
1454
1454
  .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=text], .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=email], .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=number], .qr-journey-form-wrapper .qr-form-filed-wrapper label input[type=tel], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=text], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=email], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=number], .qr-journey-form-wrapper .qr-form-filed-wrapper label select[type=tel], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=text], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=email], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=number], .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea[type=tel] {
1455
1455
  line-height: 1em;
1456
- padding: 10px 18px;
1456
+ padding: 20px 18px 2px 18px;
1457
1457
  box-sizing: content-box;
1458
1458
  }
1459
+ .qr-journey-form-wrapper .qr-form-filed-wrapper label input:active, .qr-journey-form-wrapper .qr-form-filed-wrapper label input:focus, .qr-journey-form-wrapper .qr-form-filed-wrapper label input:focus-visible, .qr-journey-form-wrapper .qr-form-filed-wrapper label select:active, .qr-journey-form-wrapper .qr-form-filed-wrapper label select:focus, .qr-journey-form-wrapper .qr-form-filed-wrapper label select:focus-visible, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea:active, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea:focus, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea:focus-visible {
1460
+ border: 2px solid #678B3B;
1461
+ outline: none;
1462
+ }
1459
1463
  .qr-journey-form-wrapper .qr-form-filed-wrapper label select, .qr-journey-form-wrapper .qr-form-filed-wrapper label textarea {
1460
1464
  line-height: 1em;
1461
- padding: 10px 18px;
1465
+ padding: 20px 18px 2px 18px;
1462
1466
  box-sizing: content-box;
1463
1467
  }
1464
- .qr-journey-form-wrapper .qr-form-filed-wrapper label > span {
1465
- opacity: 0;
1468
+ .qr-journey-form-wrapper .qr-form-filed-wrapper label > .label {
1469
+ position: relative;
1470
+ top: 10px;
1471
+ left: 10px;
1472
+ font-size: 12px;
1466
1473
  line-height: 0;
1467
1474
  }
1475
+ .qr-journey-form-wrapper .qr-form-filed-wrapper.error label input {
1476
+ border: 2px solid rgb(196, 38, 46);
1477
+ }
1478
+ .qr-journey-form-wrapper .qr-form-filed-wrapper.error .formfield-error {
1479
+ position: relative;
1480
+ top: -10px;
1481
+ font-size: 16px;
1482
+ line-height: 18px;
1483
+ }
1468
1484
  .qr-journey-form-wrapper .disabled-product-fields-section {
1469
1485
  background-color: rgb(233, 233, 233);
1470
1486
  padding: 5px 18px;
@@ -1498,7 +1514,7 @@
1498
1514
  flex: 0.5 1;
1499
1515
  min-width: 50%;
1500
1516
  }
1501
- .qr-journey-form-wrapper .disabled-product-fields-section .qr-form-fields .qr-form-filed-wrapper label span {
1517
+ .qr-journey-form-wrapper .disabled-product-fields-section .qr-form-fields .qr-form-filed-wrapper label .label {
1502
1518
  height: 1em;
1503
1519
  opacity: 1;
1504
1520
  font-weight: 900;
package/dist/index.esm.js CHANGED
@@ -751,10 +751,12 @@ var QrFormField = function (props) {
751
751
  }, []);
752
752
  var supportsValue = props.type !== "checkbox";
753
753
  return props.type ? /*#__PURE__*/React.createElement("div", {
754
- className: "qr-form-filed-wrapper"
754
+ className: (props.hasError ? "error" : "") + " qr-form-filed-wrapper"
755
755
  }, /*#__PURE__*/React.createElement("label", {
756
756
  htmlFor: inputId
757
- }, /*#__PURE__*/React.createElement("span", null, props.label, " ", props.required && /*#__PURE__*/React.createElement("span", {
757
+ }, /*#__PURE__*/React.createElement("span", {
758
+ className: "label"
759
+ }, props.label, " ", props.required && /*#__PURE__*/React.createElement("span", {
758
760
  className: "required-asterisk"
759
761
  }, "*")), /*#__PURE__*/React.createElement(FormFieldRenderer, _extends({
760
762
  key: props.value,
@@ -783,20 +785,37 @@ var QrFormField = function (props) {
783
785
  };
784
786
 
785
787
  var QrForm = function (props) {
786
- var _a = useState(0),
787
- currentPage = _a[0],
788
- setCurrentPage = _a[1];
789
- var _b = useState({}),
790
- formValues = _b[0],
791
- setFormValues = _b[1];
788
+ var _a;
789
+ var _b = useState(0),
790
+ currentPage = _b[0],
791
+ setCurrentPage = _b[1];
792
792
  var _c = useState({}),
793
- errors = _c[0],
794
- setErrors = _c[1];
795
- var _d = useState(false);
796
- _d[0];
797
- var setShowErrors = _d[1];
793
+ formValues = _c[0],
794
+ setFormValues = _c[1];
795
+ var _d = useState({}),
796
+ errors = _d[0],
797
+ setErrors = _d[1];
798
+ var _e = useState(false);
799
+ _e[0];
800
+ var setShowErrors = _e[1];
801
+ var _f = useState(null),
802
+ countryOptions = _f[0],
803
+ setCountryOptions = _f[1];
804
+ var _g = useState(true);
805
+ _g[0];
806
+ var setIsLoadingCountries = _g[1];
798
807
  var i18n = props;
799
808
  var buttonProps = props;
809
+ var consentFields = ((_a = props.consents) === null || _a === void 0 ? void 0 : _a.map(function (consent, index) {
810
+ return {
811
+ type: "checkbox",
812
+ name: "consent_".concat(index + 1),
813
+ label: consent.policyText ? consent.policyText : consent.policyLink ? "I accept the policy: ".concat(consent.policyLink) : "Consent ".concat(index + 1),
814
+ value: "true",
815
+ required: !!consent.policyMandatory,
816
+ errorMessage: consent.policyMandatory ? "Please acknowledge this consent" : ""
817
+ };
818
+ })) || [];
800
819
  useEffect(function () {
801
820
  var initialValues = {};
802
821
  props.fields.forEach(function (field) {
@@ -804,6 +823,95 @@ var QrForm = function (props) {
804
823
  });
805
824
  setFormValues(initialValues);
806
825
  }, [props.fields]);
826
+ useEffect(function () {
827
+ function loadCountries() {
828
+ return __awaiter(this, void 0, void 0, function () {
829
+ var fallbackCountries, res, data, err_1;
830
+ return __generator(this, function (_a) {
831
+ switch (_a.label) {
832
+ case 0:
833
+ fallbackCountries = [{
834
+ value: "us",
835
+ label: "United States"
836
+ }, {
837
+ value: "gb",
838
+ label: "United Kingdom"
839
+ }, {
840
+ value: "de",
841
+ label: "Germany"
842
+ }, {
843
+ value: "fr",
844
+ label: "France"
845
+ }, {
846
+ value: "cn",
847
+ label: "China"
848
+ }, {
849
+ value: "other",
850
+ label: "Other"
851
+ }];
852
+ _a.label = 1;
853
+ case 1:
854
+ _a.trys.push([1, 4, 5, 6]);
855
+ return [4 /*yield*/, fetch("/etc.clientlibs/vtba/clientlibs/resources/countries.json")];
856
+ case 2:
857
+ res = _a.sent();
858
+ if (!res.ok) throw new Error("HTTP ".concat(res.status));
859
+ return [4 /*yield*/, res.json()];
860
+ case 3:
861
+ data = _a.sent();
862
+ setCountryOptions((data === null || data === void 0 ? void 0 : data.options) || fallbackCountries);
863
+ return [3 /*break*/, 6];
864
+ case 4:
865
+ err_1 = _a.sent();
866
+ console.warn("Could not fetch countries.json, using fallback:", err_1);
867
+ setCountryOptions(fallbackCountries);
868
+ return [3 /*break*/, 6];
869
+ case 5:
870
+ setIsLoadingCountries(false);
871
+ return [7 /*endfinally*/];
872
+ case 6:
873
+ return [2 /*return*/];
874
+ }
875
+ });
876
+ });
877
+ }
878
+ loadCountries();
879
+ }, []);
880
+ useEffect(function () {
881
+ function fetchCity() {
882
+ return __awaiter(this, void 0, void 0, function () {
883
+ var res, data_1, err_2;
884
+ return __generator(this, function (_a) {
885
+ switch (_a.label) {
886
+ case 0:
887
+ _a.trys.push([0, 3,, 4]);
888
+ return [4 /*yield*/, fetch('https://ipapi.co/json/')];
889
+ case 1:
890
+ res = _a.sent();
891
+ if (!res.ok) throw new Error('IP lookup failed');
892
+ return [4 /*yield*/, res.json()];
893
+ case 2:
894
+ data_1 = _a.sent();
895
+ if (data_1.city) {
896
+ setFormValues(function (prev) {
897
+ return __assign(__assign({}, prev), {
898
+ ip_location: data_1.city
899
+ });
900
+ });
901
+ }
902
+ return [3 /*break*/, 4];
903
+ case 3:
904
+ err_2 = _a.sent();
905
+ console.warn('Could not resolve city from IP:', err_2);
906
+ return [3 /*break*/, 4];
907
+ case 4:
908
+ return [2 /*return*/];
909
+ }
910
+ });
911
+ });
912
+ }
913
+ fetchCity();
914
+ }, []);
807
915
  var pages = [__spreadArray(__spreadArray([], props.fields, true), [{
808
916
  type: "select",
809
917
  name: "how_can_we_help",
@@ -843,15 +951,17 @@ var QrForm = function (props) {
843
951
  name: "firstname",
844
952
  label: "First Name",
845
953
  placeholder: "First Name"
954
+ }, {
955
+ type: "text",
956
+ name: "company",
957
+ label: "Company",
958
+ placeholder: "Company"
846
959
  }], /*page 3*/
847
960
  [{
848
961
  type: "select",
849
962
  name: "country",
850
963
  label: "Country",
851
- options: [{
852
- value: 'poland',
853
- label: 'Poland'
854
- }]
964
+ options: countryOptions || []
855
965
  }, {
856
966
  type: "email",
857
967
  name: "email",
@@ -859,15 +969,25 @@ var QrForm = function (props) {
859
969
  placeholder: "Email",
860
970
  required: true,
861
971
  errorMessage: "Error"
862
- }], /*Page 4*/
863
- [{
864
- type: "checkbox",
865
- name: "consent1",
866
- label: "I have read and accepted the privacy policy",
867
- value: "true",
868
- required: true,
869
- errorMessage: "Please acknowledge the T&Cs"
870
- }]];
972
+ }, {
973
+ type: "tel",
974
+ name: "phone",
975
+ label: "Phone",
976
+ placeholder: "Phone",
977
+ required: false
978
+ }, {
979
+ type: "text",
980
+ name: "city",
981
+ label: "City",
982
+ placeholder: "City",
983
+ required: false
984
+ }, {
985
+ type: "text",
986
+ name: "postcode",
987
+ label: "Postcode / ZIP",
988
+ placeholder: "Postcode / ZIP",
989
+ required: false
990
+ }], __spreadArray([], consentFields, true)];
871
991
  var handleChange = function (name, value) {
872
992
  setFormValues(function (prevValues) {
873
993
  var _a;
@@ -925,7 +1045,6 @@ var QrForm = function (props) {
925
1045
  return __generator(this, function (_a) {
926
1046
  ev.preventDefault();
927
1047
  setShowErrors(true); // Attempting to submit, so show errors
928
- debugger;
929
1048
  if (validatePage(currentPage)) {
930
1049
  if (props.onSubmit) {
931
1050
  props.onSubmit(formValues);
@@ -1037,8 +1156,7 @@ var QrForm = function (props) {
1037
1156
  };
1038
1157
  return /*#__PURE__*/React.createElement("div", {
1039
1158
  className: "qr-journey-form-wrapper"
1040
- }, props.formHeader && /*#__PURE__*/React.createElement("h1", null, props.formHeader), "Show thank you:", props.showThankYou, /*#__PURE__*/React.createElement("form", {
1041
- hidden: props.showThankYou,
1159
+ }, props.formHeader && /*#__PURE__*/React.createElement("h1", null, props.formHeader), "Show thank you:", props.showThankYou, !props.showThankYou ? /*#__PURE__*/React.createElement("form", {
1042
1160
  action: "".concat(props.formAction, "/").concat(props.hubspotAppId, "/").concat(props.hubspotId),
1043
1161
  onSubmit: handleSubmit
1044
1162
  }, currentPage === 0 && /*#__PURE__*/React.createElement("section", {
@@ -1066,9 +1184,12 @@ var QrForm = function (props) {
1066
1184
  }), renderFormSection({
1067
1185
  pageIndex: 3,
1068
1186
  sectionTitle: "Form consent"
1069
- })), /*#__PURE__*/React.createElement("div", {
1070
- className: "qr-form-thank-you-page",
1071
- hidden: !props.showThankYou
1187
+ }), /*#__PURE__*/React.createElement("input", {
1188
+ type: "hidden",
1189
+ name: "ip_location",
1190
+ value: formValues.ip_location || ''
1191
+ })) : /*#__PURE__*/React.createElement("div", {
1192
+ className: "qr-form-thank-you-page"
1072
1193
  }, /*#__PURE__*/React.createElement("h2", null, props.thankYouTitle), /*#__PURE__*/React.createElement("p", null, props.thankYouText), /*#__PURE__*/React.createElement(Button, {
1073
1194
  label: buttonProps.buttonText,
1074
1195
  href: buttonProps.url,