@pelcro/react-pelcro-js 3.9.0-beta.5 → 3.9.0-beta.7

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.js CHANGED
@@ -12340,22 +12340,24 @@ function FirstName({
12340
12340
  const handleInputChange = React.useCallback(value => {
12341
12341
  setFirstName(value);
12342
12342
 
12343
- if (firstName !== null && firstName !== void 0 && firstName.length) {
12344
- dispatch({
12345
- type: SET_FIRST_NAME,
12346
- payload: firstName
12347
- });
12348
- } else {
12349
- if (finishedTyping && otherProps.required) {
12350
- dispatch({
12351
- type: SET_FIRST_NAME_ERROR,
12352
- payload: t("validation.enterFirstName")
12353
- });
12354
- } else {
12343
+ if (finishedTyping) {
12344
+ if (firstName !== null && firstName !== void 0 && firstName.length) {
12355
12345
  dispatch({
12356
12346
  type: SET_FIRST_NAME,
12357
- payload: value
12347
+ payload: firstName
12358
12348
  });
12349
+ } else {
12350
+ if (otherProps.required) {
12351
+ dispatch({
12352
+ type: SET_FIRST_NAME_ERROR,
12353
+ payload: t("validation.enterFirstName")
12354
+ });
12355
+ } else {
12356
+ dispatch({
12357
+ type: SET_FIRST_NAME,
12358
+ payload: firstName
12359
+ });
12360
+ }
12359
12361
  }
12360
12362
  }
12361
12363
  }, [dispatch, firstName, finishedTyping]);
@@ -12365,6 +12367,10 @@ function FirstName({
12365
12367
 
12366
12368
  const loadFirstNameIntoField = () => {
12367
12369
  handleInputChange(window.Pelcro.user.read().first_name);
12370
+ dispatch({
12371
+ type: SET_FIRST_NAME,
12372
+ payload: window.Pelcro.user.read().first_name
12373
+ });
12368
12374
  };
12369
12375
 
12370
12376
  React.useEffect(() => {
@@ -12375,6 +12381,10 @@ function FirstName({
12375
12381
  loadFirstNameIntoField();
12376
12382
  return () => {
12377
12383
  document.removeEventListener("PelcroUserLoaded", handleInputChange);
12384
+ dispatch({
12385
+ type: SET_FIRST_NAME,
12386
+ payload: ""
12387
+ });
12378
12388
  };
12379
12389
  }
12380
12390
  }, []);
@@ -12412,22 +12422,24 @@ function LastName({
12412
12422
  const handleInputChange = React.useCallback(value => {
12413
12423
  setLastName(value);
12414
12424
 
12415
- if (lastName !== null && lastName !== void 0 && lastName.length) {
12416
- dispatch({
12417
- type: SET_LAST_NAME,
12418
- payload: lastName
12419
- });
12420
- } else {
12421
- if (finishedTyping && otherProps.required) {
12422
- dispatch({
12423
- type: SET_LAST_NAME_ERROR,
12424
- payload: t("validation.enterLastName")
12425
- });
12426
- } else {
12425
+ if (finishedTyping) {
12426
+ if (lastName !== null && lastName !== void 0 && lastName.length) {
12427
12427
  dispatch({
12428
12428
  type: SET_LAST_NAME,
12429
- payload: value
12429
+ payload: lastName
12430
12430
  });
12431
+ } else {
12432
+ if (otherProps.required) {
12433
+ dispatch({
12434
+ type: SET_LAST_NAME_ERROR,
12435
+ payload: t("validation.enterLastName")
12436
+ });
12437
+ } else {
12438
+ dispatch({
12439
+ type: SET_LAST_NAME,
12440
+ payload: lastName
12441
+ });
12442
+ }
12431
12443
  }
12432
12444
  }
12433
12445
  }, [dispatch, lastName, finishedTyping]);
@@ -12437,6 +12449,10 @@ function LastName({
12437
12449
 
12438
12450
  const loadLastNameIntoField = () => {
12439
12451
  handleInputChange(window.Pelcro.user.read().last_name);
12452
+ dispatch({
12453
+ type: SET_LAST_NAME,
12454
+ payload: window.Pelcro.user.read().last_name
12455
+ });
12440
12456
  };
12441
12457
 
12442
12458
  React.useEffect(() => {
@@ -12447,6 +12463,10 @@ function LastName({
12447
12463
  loadLastNameIntoField();
12448
12464
  return () => {
12449
12465
  document.removeEventListener("PelcroUserLoaded", handleInputChange);
12466
+ dispatch({
12467
+ type: SET_LAST_NAME,
12468
+ payload: ""
12469
+ });
12450
12470
  };
12451
12471
  }
12452
12472
  }, []);
@@ -12484,22 +12504,24 @@ function Phone({
12484
12504
  const handleInputChange = React.useCallback(value => {
12485
12505
  setPhone(value);
12486
12506
 
12487
- if (phone !== null && phone !== void 0 && phone.length) {
12488
- dispatch({
12489
- type: SET_PHONE,
12490
- payload: phone
12491
- });
12492
- } else {
12493
- if (finishedTyping && otherProps.required) {
12494
- dispatch({
12495
- type: SET_PHONE_ERROR,
12496
- payload: t("validation.enterPhone")
12497
- });
12498
- } else {
12507
+ if (finishedTyping) {
12508
+ if (phone !== null && phone !== void 0 && phone.length) {
12499
12509
  dispatch({
12500
12510
  type: SET_PHONE,
12501
- payload: value
12511
+ payload: phone
12502
12512
  });
12513
+ } else {
12514
+ if (otherProps.required) {
12515
+ dispatch({
12516
+ type: SET_PHONE_ERROR,
12517
+ payload: t("validation.enterPhone")
12518
+ });
12519
+ } else {
12520
+ dispatch({
12521
+ type: SET_PHONE,
12522
+ payload: phone
12523
+ });
12524
+ }
12503
12525
  }
12504
12526
  }
12505
12527
  }, [dispatch, phone, finishedTyping]);
@@ -12509,6 +12531,10 @@ function Phone({
12509
12531
 
12510
12532
  const loadPhoneIntoField = () => {
12511
12533
  handleInputChange(window.Pelcro.user.read().phone);
12534
+ dispatch({
12535
+ type: SET_PHONE,
12536
+ payload: window.Pelcro.user.read().phone
12537
+ });
12512
12538
  };
12513
12539
 
12514
12540
  React.useEffect(() => {
@@ -12519,6 +12545,10 @@ function Phone({
12519
12545
  loadPhoneIntoField();
12520
12546
  return () => {
12521
12547
  document.removeEventListener("PelcroUserLoaded", handleInputChange);
12548
+ dispatch({
12549
+ type: SET_PHONE,
12550
+ payload: ""
12551
+ });
12522
12552
  };
12523
12553
  }
12524
12554
  }, []);
@@ -17269,6 +17299,14 @@ const SubmitPaymentMethod = ({
17269
17299
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17270
17300
  const [isDisabled, setDisabled] = React.useState(true);
17271
17301
  React.useEffect(() => {
17302
+ console.log("Support Tap", supportsTap);
17303
+ console.log("firstNameError", firstNameError);
17304
+ console.log("lastNameError", lastNameError);
17305
+ console.log("phoneError", phoneError);
17306
+ console.log("firstName", firstName);
17307
+ console.log("lastName", lastName);
17308
+ console.log("phone", phone);
17309
+
17272
17310
  if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
17273
17311
  setDisabled(disableSubmit);
17274
17312
  } else {
@@ -19689,16 +19727,30 @@ const UserUpdateButton = ({
19689
19727
  onClick,
19690
19728
  ...otherProps
19691
19729
  }) => {
19730
+ var _window$Pelcro$site$r;
19731
+
19692
19732
  const {
19693
19733
  state: {
19694
19734
  buttonDisabled,
19695
- emailError
19735
+ email,
19736
+ firstName,
19737
+ lastName,
19738
+ phone,
19739
+ emailError,
19740
+ firstNameError,
19741
+ lastNameError,
19742
+ phoneError
19696
19743
  },
19697
19744
  dispatch
19698
19745
  } = React.useContext(store$f);
19746
+ const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19699
19747
  const {
19700
19748
  t
19701
19749
  } = useTranslation("userEdit");
19750
+ const [isDisabled, setDisabled] = React.useState(true);
19751
+ React.useEffect(() => {
19752
+ setDisabled(buttonDisabled || emailError || !(email !== null && email !== void 0 && email.length) || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length));
19753
+ }, [email, firstName, lastName, phone, buttonDisabled, emailError, firstNameError, lastNameError, phoneError]);
19702
19754
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
19703
19755
  onClick: () => {
19704
19756
  dispatch({
@@ -19706,7 +19758,7 @@ const UserUpdateButton = ({
19706
19758
  });
19707
19759
  onClick === null || onClick === void 0 ? void 0 : onClick();
19708
19760
  },
19709
- disabled: buttonDisabled || emailError,
19761
+ disabled: isDisabled,
19710
19762
  isLoading: buttonDisabled && !emailError
19711
19763
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
19712
19764
  };
@@ -19751,9 +19803,12 @@ const UserUpdateProfilePic = ({
19751
19803
  };
19752
19804
 
19753
19805
  const UserUpdateView = props => {
19806
+ var _window$Pelcro$site$r;
19807
+
19754
19808
  const {
19755
19809
  t
19756
19810
  } = useTranslation("userEdit");
19811
+ const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19757
19812
  return /*#__PURE__*/React__default['default'].createElement("div", {
19758
19813
  id: "pelcro-user-update-view"
19759
19814
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -19772,19 +19827,22 @@ const UserUpdateView = props => {
19772
19827
  id: "pelcro-input-first-name",
19773
19828
  errorId: "pelcro-input-first-name-error",
19774
19829
  label: t("labels.firstName"),
19775
- autoFocus: true
19830
+ autoFocus: true,
19831
+ required: supportsTap ? true : false
19776
19832
  }), /*#__PURE__*/React__default['default'].createElement(UserUpdateLastName, {
19777
19833
  wrapperClassName: "plc-ml-3",
19778
19834
  autoComplete: "last-name",
19779
19835
  id: "pelcro-input-last-name",
19780
19836
  errorId: "pelcro-input-last-name-error",
19781
- label: t("labels.lastName")
19837
+ label: t("labels.lastName"),
19838
+ required: supportsTap ? true : false
19782
19839
  })), /*#__PURE__*/React__default['default'].createElement("div", {
19783
19840
  className: "plc-flex plc-items-start"
19784
19841
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdatePhone, {
19785
19842
  id: "pelcro-input-phone",
19786
19843
  errorId: "pelcro-input-phone-error",
19787
- label: t("labels.phone")
19844
+ label: t("labels.phone"),
19845
+ required: supportsTap ? true : false
19788
19846
  })), /*#__PURE__*/React__default['default'].createElement(UserUpdateButton, {
19789
19847
  role: "submit",
19790
19848
  className: "plc-w-full plc-mt-2",
package/dist/index.esm.js CHANGED
@@ -12310,22 +12310,24 @@ function FirstName({
12310
12310
  const handleInputChange = useCallback(value => {
12311
12311
  setFirstName(value);
12312
12312
 
12313
- if (firstName !== null && firstName !== void 0 && firstName.length) {
12314
- dispatch({
12315
- type: SET_FIRST_NAME,
12316
- payload: firstName
12317
- });
12318
- } else {
12319
- if (finishedTyping && otherProps.required) {
12320
- dispatch({
12321
- type: SET_FIRST_NAME_ERROR,
12322
- payload: t("validation.enterFirstName")
12323
- });
12324
- } else {
12313
+ if (finishedTyping) {
12314
+ if (firstName !== null && firstName !== void 0 && firstName.length) {
12325
12315
  dispatch({
12326
12316
  type: SET_FIRST_NAME,
12327
- payload: value
12317
+ payload: firstName
12328
12318
  });
12319
+ } else {
12320
+ if (otherProps.required) {
12321
+ dispatch({
12322
+ type: SET_FIRST_NAME_ERROR,
12323
+ payload: t("validation.enterFirstName")
12324
+ });
12325
+ } else {
12326
+ dispatch({
12327
+ type: SET_FIRST_NAME,
12328
+ payload: firstName
12329
+ });
12330
+ }
12329
12331
  }
12330
12332
  }
12331
12333
  }, [dispatch, firstName, finishedTyping]);
@@ -12335,6 +12337,10 @@ function FirstName({
12335
12337
 
12336
12338
  const loadFirstNameIntoField = () => {
12337
12339
  handleInputChange(window.Pelcro.user.read().first_name);
12340
+ dispatch({
12341
+ type: SET_FIRST_NAME,
12342
+ payload: window.Pelcro.user.read().first_name
12343
+ });
12338
12344
  };
12339
12345
 
12340
12346
  useEffect(() => {
@@ -12345,6 +12351,10 @@ function FirstName({
12345
12351
  loadFirstNameIntoField();
12346
12352
  return () => {
12347
12353
  document.removeEventListener("PelcroUserLoaded", handleInputChange);
12354
+ dispatch({
12355
+ type: SET_FIRST_NAME,
12356
+ payload: ""
12357
+ });
12348
12358
  };
12349
12359
  }
12350
12360
  }, []);
@@ -12382,22 +12392,24 @@ function LastName({
12382
12392
  const handleInputChange = useCallback(value => {
12383
12393
  setLastName(value);
12384
12394
 
12385
- if (lastName !== null && lastName !== void 0 && lastName.length) {
12386
- dispatch({
12387
- type: SET_LAST_NAME,
12388
- payload: lastName
12389
- });
12390
- } else {
12391
- if (finishedTyping && otherProps.required) {
12392
- dispatch({
12393
- type: SET_LAST_NAME_ERROR,
12394
- payload: t("validation.enterLastName")
12395
- });
12396
- } else {
12395
+ if (finishedTyping) {
12396
+ if (lastName !== null && lastName !== void 0 && lastName.length) {
12397
12397
  dispatch({
12398
12398
  type: SET_LAST_NAME,
12399
- payload: value
12399
+ payload: lastName
12400
12400
  });
12401
+ } else {
12402
+ if (otherProps.required) {
12403
+ dispatch({
12404
+ type: SET_LAST_NAME_ERROR,
12405
+ payload: t("validation.enterLastName")
12406
+ });
12407
+ } else {
12408
+ dispatch({
12409
+ type: SET_LAST_NAME,
12410
+ payload: lastName
12411
+ });
12412
+ }
12401
12413
  }
12402
12414
  }
12403
12415
  }, [dispatch, lastName, finishedTyping]);
@@ -12407,6 +12419,10 @@ function LastName({
12407
12419
 
12408
12420
  const loadLastNameIntoField = () => {
12409
12421
  handleInputChange(window.Pelcro.user.read().last_name);
12422
+ dispatch({
12423
+ type: SET_LAST_NAME,
12424
+ payload: window.Pelcro.user.read().last_name
12425
+ });
12410
12426
  };
12411
12427
 
12412
12428
  useEffect(() => {
@@ -12417,6 +12433,10 @@ function LastName({
12417
12433
  loadLastNameIntoField();
12418
12434
  return () => {
12419
12435
  document.removeEventListener("PelcroUserLoaded", handleInputChange);
12436
+ dispatch({
12437
+ type: SET_LAST_NAME,
12438
+ payload: ""
12439
+ });
12420
12440
  };
12421
12441
  }
12422
12442
  }, []);
@@ -12454,22 +12474,24 @@ function Phone({
12454
12474
  const handleInputChange = useCallback(value => {
12455
12475
  setPhone(value);
12456
12476
 
12457
- if (phone !== null && phone !== void 0 && phone.length) {
12458
- dispatch({
12459
- type: SET_PHONE,
12460
- payload: phone
12461
- });
12462
- } else {
12463
- if (finishedTyping && otherProps.required) {
12464
- dispatch({
12465
- type: SET_PHONE_ERROR,
12466
- payload: t("validation.enterPhone")
12467
- });
12468
- } else {
12477
+ if (finishedTyping) {
12478
+ if (phone !== null && phone !== void 0 && phone.length) {
12469
12479
  dispatch({
12470
12480
  type: SET_PHONE,
12471
- payload: value
12481
+ payload: phone
12472
12482
  });
12483
+ } else {
12484
+ if (otherProps.required) {
12485
+ dispatch({
12486
+ type: SET_PHONE_ERROR,
12487
+ payload: t("validation.enterPhone")
12488
+ });
12489
+ } else {
12490
+ dispatch({
12491
+ type: SET_PHONE,
12492
+ payload: phone
12493
+ });
12494
+ }
12473
12495
  }
12474
12496
  }
12475
12497
  }, [dispatch, phone, finishedTyping]);
@@ -12479,6 +12501,10 @@ function Phone({
12479
12501
 
12480
12502
  const loadPhoneIntoField = () => {
12481
12503
  handleInputChange(window.Pelcro.user.read().phone);
12504
+ dispatch({
12505
+ type: SET_PHONE,
12506
+ payload: window.Pelcro.user.read().phone
12507
+ });
12482
12508
  };
12483
12509
 
12484
12510
  useEffect(() => {
@@ -12489,6 +12515,10 @@ function Phone({
12489
12515
  loadPhoneIntoField();
12490
12516
  return () => {
12491
12517
  document.removeEventListener("PelcroUserLoaded", handleInputChange);
12518
+ dispatch({
12519
+ type: SET_PHONE,
12520
+ payload: ""
12521
+ });
12492
12522
  };
12493
12523
  }
12494
12524
  }, []);
@@ -17239,6 +17269,14 @@ const SubmitPaymentMethod = ({
17239
17269
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17240
17270
  const [isDisabled, setDisabled] = useState(true);
17241
17271
  useEffect(() => {
17272
+ console.log("Support Tap", supportsTap);
17273
+ console.log("firstNameError", firstNameError);
17274
+ console.log("lastNameError", lastNameError);
17275
+ console.log("phoneError", phoneError);
17276
+ console.log("firstName", firstName);
17277
+ console.log("lastName", lastName);
17278
+ console.log("phone", phone);
17279
+
17242
17280
  if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
17243
17281
  setDisabled(disableSubmit);
17244
17282
  } else {
@@ -19659,16 +19697,30 @@ const UserUpdateButton = ({
19659
19697
  onClick,
19660
19698
  ...otherProps
19661
19699
  }) => {
19700
+ var _window$Pelcro$site$r;
19701
+
19662
19702
  const {
19663
19703
  state: {
19664
19704
  buttonDisabled,
19665
- emailError
19705
+ email,
19706
+ firstName,
19707
+ lastName,
19708
+ phone,
19709
+ emailError,
19710
+ firstNameError,
19711
+ lastNameError,
19712
+ phoneError
19666
19713
  },
19667
19714
  dispatch
19668
19715
  } = useContext(store$f);
19716
+ const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19669
19717
  const {
19670
19718
  t
19671
19719
  } = useTranslation("userEdit");
19720
+ const [isDisabled, setDisabled] = useState(true);
19721
+ useEffect(() => {
19722
+ setDisabled(buttonDisabled || emailError || !(email !== null && email !== void 0 && email.length) || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length));
19723
+ }, [email, firstName, lastName, phone, buttonDisabled, emailError, firstNameError, lastNameError, phoneError]);
19672
19724
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
19673
19725
  onClick: () => {
19674
19726
  dispatch({
@@ -19676,7 +19728,7 @@ const UserUpdateButton = ({
19676
19728
  });
19677
19729
  onClick === null || onClick === void 0 ? void 0 : onClick();
19678
19730
  },
19679
- disabled: buttonDisabled || emailError,
19731
+ disabled: isDisabled,
19680
19732
  isLoading: buttonDisabled && !emailError
19681
19733
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
19682
19734
  };
@@ -19721,9 +19773,12 @@ const UserUpdateProfilePic = ({
19721
19773
  };
19722
19774
 
19723
19775
  const UserUpdateView = props => {
19776
+ var _window$Pelcro$site$r;
19777
+
19724
19778
  const {
19725
19779
  t
19726
19780
  } = useTranslation("userEdit");
19781
+ const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19727
19782
  return /*#__PURE__*/React__default.createElement("div", {
19728
19783
  id: "pelcro-user-update-view"
19729
19784
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -19742,19 +19797,22 @@ const UserUpdateView = props => {
19742
19797
  id: "pelcro-input-first-name",
19743
19798
  errorId: "pelcro-input-first-name-error",
19744
19799
  label: t("labels.firstName"),
19745
- autoFocus: true
19800
+ autoFocus: true,
19801
+ required: supportsTap ? true : false
19746
19802
  }), /*#__PURE__*/React__default.createElement(UserUpdateLastName, {
19747
19803
  wrapperClassName: "plc-ml-3",
19748
19804
  autoComplete: "last-name",
19749
19805
  id: "pelcro-input-last-name",
19750
19806
  errorId: "pelcro-input-last-name-error",
19751
- label: t("labels.lastName")
19807
+ label: t("labels.lastName"),
19808
+ required: supportsTap ? true : false
19752
19809
  })), /*#__PURE__*/React__default.createElement("div", {
19753
19810
  className: "plc-flex plc-items-start"
19754
19811
  }, /*#__PURE__*/React__default.createElement(UserUpdatePhone, {
19755
19812
  id: "pelcro-input-phone",
19756
19813
  errorId: "pelcro-input-phone-error",
19757
- label: t("labels.phone")
19814
+ label: t("labels.phone"),
19815
+ required: supportsTap ? true : false
19758
19816
  })), /*#__PURE__*/React__default.createElement(UserUpdateButton, {
19759
19817
  role: "submit",
19760
19818
  className: "plc-w-full plc-mt-2",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.9.0-beta.5",
4
+ "version": "3.9.0-beta.7",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",