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

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(() => {
@@ -12412,22 +12418,24 @@ function LastName({
12412
12418
  const handleInputChange = React.useCallback(value => {
12413
12419
  setLastName(value);
12414
12420
 
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 {
12421
+ if (finishedTyping) {
12422
+ if (lastName !== null && lastName !== void 0 && lastName.length) {
12427
12423
  dispatch({
12428
12424
  type: SET_LAST_NAME,
12429
- payload: value
12425
+ payload: lastName
12430
12426
  });
12427
+ } else {
12428
+ if (otherProps.required) {
12429
+ dispatch({
12430
+ type: SET_LAST_NAME_ERROR,
12431
+ payload: t("validation.enterLastName")
12432
+ });
12433
+ } else {
12434
+ dispatch({
12435
+ type: SET_LAST_NAME,
12436
+ payload: lastName
12437
+ });
12438
+ }
12431
12439
  }
12432
12440
  }
12433
12441
  }, [dispatch, lastName, finishedTyping]);
@@ -12437,6 +12445,10 @@ function LastName({
12437
12445
 
12438
12446
  const loadLastNameIntoField = () => {
12439
12447
  handleInputChange(window.Pelcro.user.read().last_name);
12448
+ dispatch({
12449
+ type: SET_LAST_NAME,
12450
+ payload: window.Pelcro.user.read().last_name
12451
+ });
12440
12452
  };
12441
12453
 
12442
12454
  React.useEffect(() => {
@@ -12484,22 +12496,24 @@ function Phone({
12484
12496
  const handleInputChange = React.useCallback(value => {
12485
12497
  setPhone(value);
12486
12498
 
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 {
12499
+ if (finishedTyping) {
12500
+ if (phone !== null && phone !== void 0 && phone.length) {
12499
12501
  dispatch({
12500
12502
  type: SET_PHONE,
12501
- payload: value
12503
+ payload: phone
12502
12504
  });
12505
+ } else {
12506
+ if (otherProps.required) {
12507
+ dispatch({
12508
+ type: SET_PHONE_ERROR,
12509
+ payload: t("validation.enterPhone")
12510
+ });
12511
+ } else {
12512
+ dispatch({
12513
+ type: SET_PHONE,
12514
+ payload: phone
12515
+ });
12516
+ }
12503
12517
  }
12504
12518
  }
12505
12519
  }, [dispatch, phone, finishedTyping]);
@@ -12509,6 +12523,10 @@ function Phone({
12509
12523
 
12510
12524
  const loadPhoneIntoField = () => {
12511
12525
  handleInputChange(window.Pelcro.user.read().phone);
12526
+ dispatch({
12527
+ type: SET_PHONE,
12528
+ payload: window.Pelcro.user.read().phone
12529
+ });
12512
12530
  };
12513
12531
 
12514
12532
  React.useEffect(() => {
@@ -17269,6 +17287,14 @@ const SubmitPaymentMethod = ({
17269
17287
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17270
17288
  const [isDisabled, setDisabled] = React.useState(true);
17271
17289
  React.useEffect(() => {
17290
+ console.log("Support Tap", supportsTap);
17291
+ console.log("firstNameError", firstNameError);
17292
+ console.log("lastNameError", lastNameError);
17293
+ console.log("phoneError", phoneError);
17294
+ console.log("firstName", firstName);
17295
+ console.log("lastName", lastName);
17296
+ console.log("phone", phone);
17297
+
17272
17298
  if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
17273
17299
  setDisabled(disableSubmit);
17274
17300
  } else {
@@ -19689,16 +19715,30 @@ const UserUpdateButton = ({
19689
19715
  onClick,
19690
19716
  ...otherProps
19691
19717
  }) => {
19718
+ var _window$Pelcro$site$r;
19719
+
19692
19720
  const {
19693
19721
  state: {
19694
19722
  buttonDisabled,
19695
- emailError
19723
+ email,
19724
+ firstName,
19725
+ lastName,
19726
+ phone,
19727
+ emailError,
19728
+ firstNameError,
19729
+ lastNameError,
19730
+ phoneError
19696
19731
  },
19697
19732
  dispatch
19698
19733
  } = React.useContext(store$f);
19734
+ 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
19735
  const {
19700
19736
  t
19701
19737
  } = useTranslation("userEdit");
19738
+ const [isDisabled, setDisabled] = React.useState(true);
19739
+ React.useEffect(() => {
19740
+ 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));
19741
+ }, [email, firstName, lastName, phone, buttonDisabled, emailError, firstNameError, lastNameError, phoneError]);
19702
19742
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
19703
19743
  onClick: () => {
19704
19744
  dispatch({
@@ -19706,7 +19746,7 @@ const UserUpdateButton = ({
19706
19746
  });
19707
19747
  onClick === null || onClick === void 0 ? void 0 : onClick();
19708
19748
  },
19709
- disabled: buttonDisabled || emailError,
19749
+ disabled: isDisabled,
19710
19750
  isLoading: buttonDisabled && !emailError
19711
19751
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
19712
19752
  };
@@ -19751,9 +19791,12 @@ const UserUpdateProfilePic = ({
19751
19791
  };
19752
19792
 
19753
19793
  const UserUpdateView = props => {
19794
+ var _window$Pelcro$site$r;
19795
+
19754
19796
  const {
19755
19797
  t
19756
19798
  } = useTranslation("userEdit");
19799
+ 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
19800
  return /*#__PURE__*/React__default['default'].createElement("div", {
19758
19801
  id: "pelcro-user-update-view"
19759
19802
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -19772,19 +19815,22 @@ const UserUpdateView = props => {
19772
19815
  id: "pelcro-input-first-name",
19773
19816
  errorId: "pelcro-input-first-name-error",
19774
19817
  label: t("labels.firstName"),
19775
- autoFocus: true
19818
+ autoFocus: true,
19819
+ required: supportsTap ? true : false
19776
19820
  }), /*#__PURE__*/React__default['default'].createElement(UserUpdateLastName, {
19777
19821
  wrapperClassName: "plc-ml-3",
19778
19822
  autoComplete: "last-name",
19779
19823
  id: "pelcro-input-last-name",
19780
19824
  errorId: "pelcro-input-last-name-error",
19781
- label: t("labels.lastName")
19825
+ label: t("labels.lastName"),
19826
+ required: supportsTap ? true : false
19782
19827
  })), /*#__PURE__*/React__default['default'].createElement("div", {
19783
19828
  className: "plc-flex plc-items-start"
19784
19829
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdatePhone, {
19785
19830
  id: "pelcro-input-phone",
19786
19831
  errorId: "pelcro-input-phone-error",
19787
- label: t("labels.phone")
19832
+ label: t("labels.phone"),
19833
+ required: supportsTap ? true : false
19788
19834
  })), /*#__PURE__*/React__default['default'].createElement(UserUpdateButton, {
19789
19835
  role: "submit",
19790
19836
  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(() => {
@@ -12382,22 +12388,24 @@ function LastName({
12382
12388
  const handleInputChange = useCallback(value => {
12383
12389
  setLastName(value);
12384
12390
 
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 {
12391
+ if (finishedTyping) {
12392
+ if (lastName !== null && lastName !== void 0 && lastName.length) {
12397
12393
  dispatch({
12398
12394
  type: SET_LAST_NAME,
12399
- payload: value
12395
+ payload: lastName
12400
12396
  });
12397
+ } else {
12398
+ if (otherProps.required) {
12399
+ dispatch({
12400
+ type: SET_LAST_NAME_ERROR,
12401
+ payload: t("validation.enterLastName")
12402
+ });
12403
+ } else {
12404
+ dispatch({
12405
+ type: SET_LAST_NAME,
12406
+ payload: lastName
12407
+ });
12408
+ }
12401
12409
  }
12402
12410
  }
12403
12411
  }, [dispatch, lastName, finishedTyping]);
@@ -12407,6 +12415,10 @@ function LastName({
12407
12415
 
12408
12416
  const loadLastNameIntoField = () => {
12409
12417
  handleInputChange(window.Pelcro.user.read().last_name);
12418
+ dispatch({
12419
+ type: SET_LAST_NAME,
12420
+ payload: window.Pelcro.user.read().last_name
12421
+ });
12410
12422
  };
12411
12423
 
12412
12424
  useEffect(() => {
@@ -12454,22 +12466,24 @@ function Phone({
12454
12466
  const handleInputChange = useCallback(value => {
12455
12467
  setPhone(value);
12456
12468
 
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 {
12469
+ if (finishedTyping) {
12470
+ if (phone !== null && phone !== void 0 && phone.length) {
12469
12471
  dispatch({
12470
12472
  type: SET_PHONE,
12471
- payload: value
12473
+ payload: phone
12472
12474
  });
12475
+ } else {
12476
+ if (otherProps.required) {
12477
+ dispatch({
12478
+ type: SET_PHONE_ERROR,
12479
+ payload: t("validation.enterPhone")
12480
+ });
12481
+ } else {
12482
+ dispatch({
12483
+ type: SET_PHONE,
12484
+ payload: phone
12485
+ });
12486
+ }
12473
12487
  }
12474
12488
  }
12475
12489
  }, [dispatch, phone, finishedTyping]);
@@ -12479,6 +12493,10 @@ function Phone({
12479
12493
 
12480
12494
  const loadPhoneIntoField = () => {
12481
12495
  handleInputChange(window.Pelcro.user.read().phone);
12496
+ dispatch({
12497
+ type: SET_PHONE,
12498
+ payload: window.Pelcro.user.read().phone
12499
+ });
12482
12500
  };
12483
12501
 
12484
12502
  useEffect(() => {
@@ -17239,6 +17257,14 @@ const SubmitPaymentMethod = ({
17239
17257
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17240
17258
  const [isDisabled, setDisabled] = useState(true);
17241
17259
  useEffect(() => {
17260
+ console.log("Support Tap", supportsTap);
17261
+ console.log("firstNameError", firstNameError);
17262
+ console.log("lastNameError", lastNameError);
17263
+ console.log("phoneError", phoneError);
17264
+ console.log("firstName", firstName);
17265
+ console.log("lastName", lastName);
17266
+ console.log("phone", phone);
17267
+
17242
17268
  if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
17243
17269
  setDisabled(disableSubmit);
17244
17270
  } else {
@@ -19659,16 +19685,30 @@ const UserUpdateButton = ({
19659
19685
  onClick,
19660
19686
  ...otherProps
19661
19687
  }) => {
19688
+ var _window$Pelcro$site$r;
19689
+
19662
19690
  const {
19663
19691
  state: {
19664
19692
  buttonDisabled,
19665
- emailError
19693
+ email,
19694
+ firstName,
19695
+ lastName,
19696
+ phone,
19697
+ emailError,
19698
+ firstNameError,
19699
+ lastNameError,
19700
+ phoneError
19666
19701
  },
19667
19702
  dispatch
19668
19703
  } = useContext(store$f);
19704
+ 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
19705
  const {
19670
19706
  t
19671
19707
  } = useTranslation("userEdit");
19708
+ const [isDisabled, setDisabled] = useState(true);
19709
+ useEffect(() => {
19710
+ 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));
19711
+ }, [email, firstName, lastName, phone, buttonDisabled, emailError, firstNameError, lastNameError, phoneError]);
19672
19712
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
19673
19713
  onClick: () => {
19674
19714
  dispatch({
@@ -19676,7 +19716,7 @@ const UserUpdateButton = ({
19676
19716
  });
19677
19717
  onClick === null || onClick === void 0 ? void 0 : onClick();
19678
19718
  },
19679
- disabled: buttonDisabled || emailError,
19719
+ disabled: isDisabled,
19680
19720
  isLoading: buttonDisabled && !emailError
19681
19721
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
19682
19722
  };
@@ -19721,9 +19761,12 @@ const UserUpdateProfilePic = ({
19721
19761
  };
19722
19762
 
19723
19763
  const UserUpdateView = props => {
19764
+ var _window$Pelcro$site$r;
19765
+
19724
19766
  const {
19725
19767
  t
19726
19768
  } = useTranslation("userEdit");
19769
+ 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
19770
  return /*#__PURE__*/React__default.createElement("div", {
19728
19771
  id: "pelcro-user-update-view"
19729
19772
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -19742,19 +19785,22 @@ const UserUpdateView = props => {
19742
19785
  id: "pelcro-input-first-name",
19743
19786
  errorId: "pelcro-input-first-name-error",
19744
19787
  label: t("labels.firstName"),
19745
- autoFocus: true
19788
+ autoFocus: true,
19789
+ required: supportsTap ? true : false
19746
19790
  }), /*#__PURE__*/React__default.createElement(UserUpdateLastName, {
19747
19791
  wrapperClassName: "plc-ml-3",
19748
19792
  autoComplete: "last-name",
19749
19793
  id: "pelcro-input-last-name",
19750
19794
  errorId: "pelcro-input-last-name-error",
19751
- label: t("labels.lastName")
19795
+ label: t("labels.lastName"),
19796
+ required: supportsTap ? true : false
19752
19797
  })), /*#__PURE__*/React__default.createElement("div", {
19753
19798
  className: "plc-flex plc-items-start"
19754
19799
  }, /*#__PURE__*/React__default.createElement(UserUpdatePhone, {
19755
19800
  id: "pelcro-input-phone",
19756
19801
  errorId: "pelcro-input-phone-error",
19757
- label: t("labels.phone")
19802
+ label: t("labels.phone"),
19803
+ required: supportsTap ? true : false
19758
19804
  })), /*#__PURE__*/React__default.createElement(UserUpdateButton, {
19759
19805
  role: "submit",
19760
19806
  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.6",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",