@shipengine/elements 0.32.1 → 0.33.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/index.js CHANGED
@@ -13,7 +13,6 @@ import { IconNames } from '@packlink/giger-theme';
13
13
  import { css, keyframes, useTheme, createElement as createElement$3 } from '@emotion/react';
14
14
  import { camelize } from 'humps';
15
15
  import { createPortal } from 'react-dom';
16
- import { IconNames as IconNames$1 } from '@packlink/brands';
17
16
  import { useQueryClient } from 'react-query';
18
17
  import { useController, get as get$2, set as set$2, useWatch, useFormState, useForm } from 'react-hook-form';
19
18
  import ReactDatePicker, { registerLocale, setDefaultLocale } from 'react-datepicker';
@@ -4473,6 +4472,66 @@ const useAddressValidation = () => {
4473
4472
  };
4474
4473
  };
4475
4474
 
4475
+ /*
4476
+ * ****** WARNING *******
4477
+ * This hook was designed with the intention of only being used within the onboarding flow during carrier registration and carrier recovery and as such is not intended to be used elsewhere.
4478
+ * There is a chance that more than one script will be mounted if this hook is used elsewhere.
4479
+ */
4480
+ /**
4481
+ * Creates an encoded device fingerprint string - aka black box - containing information about the end-user's computing device such as OS, browser, etc.
4482
+ * https://developer.bazaarvoice.com/conversations-api/deprecations/iovation-web#snare_js_only
4483
+ */
4484
+ const useBlackboxDetection = ({
4485
+ onSuccess,
4486
+ onError
4487
+ }) => {
4488
+ useEffect(() => {
4489
+ // basic configurations must be on page before snare.js is loaded
4490
+ global.window.io_install_stm = false; // do not install Active X
4491
+ global.window.io_exclude_stm = 12; // do not run Active X
4492
+ global.window.io_install_flash = false; // do not install Flash
4493
+ global.window.io_enable_rip = true; // collect Real IP information
4494
+ const pollBlackBox = () => {
4495
+ try {
4496
+ if (typeof ioGetBlackbox !== "function") {
4497
+ return;
4498
+ }
4499
+ // eslint-disable-next-line
4500
+ const blackboxInfo = ioGetBlackbox();
4501
+ // Each call to ioGetBlackbox() returns a JavaScript object with information about the current state of the black box and eventually the black box string itself
4502
+ if (blackboxInfo.finished) {
4503
+ clearTimeout(intervalId);
4504
+ onSuccess(blackboxInfo.blackbox);
4505
+ }
4506
+ } catch (_e) {
4507
+ onError();
4508
+ }
4509
+ };
4510
+ const intervalId = setInterval(pollBlackBox, 500);
4511
+ // attach script to DOM
4512
+ const script = global.document.createElement("script");
4513
+ script.type = "text/javascript";
4514
+ script.async = true;
4515
+ script.src = "https://mpsnare.iesnare.com/snare.js";
4516
+ script.addEventListener("error", _e => {
4517
+ if (typeof ioGetBlackbox !== "function") {
4518
+ onError();
4519
+ }
4520
+ });
4521
+ global.document.head.appendChild(script);
4522
+ return () => {
4523
+ if (intervalId) {
4524
+ clearTimeout(intervalId);
4525
+ }
4526
+ delete global.window.io_install_stm;
4527
+ delete global.window.io_exclude_stm;
4528
+ delete global.window.io_install_flash;
4529
+ delete global.window.io_enable_rip;
4530
+ global.document.head.removeChild(script);
4531
+ };
4532
+ }, [onSuccess, onError]);
4533
+ };
4534
+
4476
4535
  const useListConnectedCarriers = () => {
4477
4536
  const {
4478
4537
  data: carriers,
@@ -6855,7 +6914,7 @@ const LabelLayoutSettings = ({
6855
6914
  }, {
6856
6915
  children: [labelLayout === "letter" && jsx(Icon, {
6857
6916
  css: styles$p.icon,
6858
- name: IconNames$1.CHECK_FILLED
6917
+ name: IconNames.CHECK_FILLED
6859
6918
  }), jsx("div", Object.assign({
6860
6919
  css: styles$p.letterInner
6861
6920
  }, {
@@ -6887,7 +6946,7 @@ const LabelLayoutSettings = ({
6887
6946
  }, {
6888
6947
  children: [labelLayout === "4x6" && jsx(Icon, {
6889
6948
  css: styles$p.icon,
6890
- name: IconNames$1.CHECK_FILLED
6949
+ name: IconNames.CHECK_FILLED
6891
6950
  }), jsx("div", Object.assign({
6892
6951
  css: styles$p.thermalInner
6893
6952
  }, {
@@ -9001,7 +9060,7 @@ const InlineLabel = ({
9001
9060
 
9002
9061
  const styles$l = createStyles({
9003
9062
  getBalanceText: balance => theme => ({
9004
- color: balance === undefined ? theme.palette.alert.main : balance >= 0 ? theme.palette.secondary.dark : theme.palette.error.main
9063
+ color: balance === undefined ? theme.palette.gray.main : balance >= 0 ? theme.palette.secondary.dark : theme.palette.error.main
9005
9064
  })
9006
9065
  });
9007
9066
 
@@ -9026,7 +9085,7 @@ const CarrierBalance = ({
9026
9085
  bold: true,
9027
9086
  css: styles$l.getBalanceText(carrierBalance)
9028
9087
  }, {
9029
- children: carrierBalance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
9088
+ children: carrierBalance === undefined ? "----" : formatMoney({
9030
9089
  amount: carrierBalance,
9031
9090
  currency: SE.Currency.USD
9032
9091
  })
@@ -9310,19 +9369,6 @@ const AddressFields = ({
9310
9369
  });
9311
9370
  };
9312
9371
 
9313
- /* eslint-disable @typescript-eslint/no-unused-vars -- Allow unused generics in ZodObject interface overload */
9314
- function nullishDefault(defaultValue) {
9315
- return this.nullish().transform(v => v !== null && v !== void 0 ? v : defaultValue);
9316
- }
9317
- /**
9318
- * @category Form Validation
9319
- */
9320
- const extendZod = () => {
9321
- z.ZodString.prototype.nullishDefault = nullishDefault;
9322
- z.ZodNumber.prototype.nullishDefault = nullishDefault;
9323
- z.ZodObject.prototype.nullishDefault = nullishDefault;
9324
- };
9325
-
9326
9372
  var call = functionCall;
9327
9373
  var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
9328
9374
  var anObject = anObject$f;
@@ -9371,8 +9417,20 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
9371
9417
  ];
9372
9418
  });
9373
9419
 
9420
+ /* eslint-disable @typescript-eslint/no-unused-vars -- Allow unused generics in ZodObject interface overload */
9421
+ function nullishDefault(defaultValue) {
9422
+ return this.nullish().transform(v => v !== null && v !== void 0 ? v : defaultValue);
9423
+ }
9424
+ /**
9425
+ * @category Form Validation
9426
+ */
9427
+ const extendZod = () => {
9428
+ z.ZodString.prototype.nullishDefault = nullishDefault;
9429
+ z.ZodNumber.prototype.nullishDefault = nullishDefault;
9430
+ z.ZodObject.prototype.nullishDefault = nullishDefault;
9431
+ };
9432
+
9374
9433
  extendZod();
9375
- const refineName = n => n.match(/^[a-zA-Z']{2,} [a-zA-Z']{2,}/);
9376
9434
  const addressLine1Schema = z.string().trim().min(1);
9377
9435
  const addressLine2Schema = z.string().trim().nullishDefault(undefined);
9378
9436
  const companyNameSchema = z.string().trim().min(2).max(40).nullishDefault(undefined).or(z.literal("")).transform(companyName => companyName || undefined);
@@ -9382,7 +9440,7 @@ const addressSchema = z.object({
9382
9440
  cityLocality: z.string().trim().min(1),
9383
9441
  companyName: companyNameSchema,
9384
9442
  countryCode: z.enum(countryCodes),
9385
- name: z.string().trim().min(1).refine(refineName, "schemaErrors.invalidAddressName"),
9443
+ name: z.string().trim().min(1),
9386
9444
  phone: z.string().trim().nullishDefault(""),
9387
9445
  postalCode: z.string().trim(),
9388
9446
  stateProvince: z.string().trim().nullishDefault("")
@@ -9390,7 +9448,14 @@ const addressSchema = z.object({
9390
9448
 
9391
9449
  extendZod();
9392
9450
  const postalCodeRegex$2 = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
9393
- const addressFormSchema = addressSchema.refine(schema => !schema.phone || isValidPhoneNumber(schema.phone, schema.countryCode), {
9451
+ const refineName = n => n.match(/^[a-zA-Z']/);
9452
+ const refineNameStrict = n => n.match(/^[a-zA-Z']{2,} [a-zA-Z']{2,}/);
9453
+ const shipToAddressSchema = addressSchema.refine(schema => {
9454
+ return refineName(schema.name);
9455
+ }, {
9456
+ message: "schemaErrors.invalidAddressName",
9457
+ path: ["name"]
9458
+ }).refine(schema => !schema.phone || isValidPhoneNumber(schema.phone, schema.countryCode), {
9394
9459
  message: "schemaErrors.notAValidPhoneNumber",
9395
9460
  path: ["phone"]
9396
9461
  }).refine(schema => {
@@ -9410,11 +9475,18 @@ const addressFormSchema = addressSchema.refine(schema => !schema.phone || isVali
9410
9475
  message: "schemaErrors.invalidPostalCode",
9411
9476
  path: ["postalCode"]
9412
9477
  });
9478
+ const addressFormSchema = shipToAddressSchema.refine(schema => {
9479
+ return refineNameStrict(schema.name);
9480
+ }, {
9481
+ message: "schemaErrors.invalidAddressNameStrict",
9482
+ path: ["name"]
9483
+ });
9413
9484
 
9414
9485
  const AddressForm = ({
9415
9486
  address,
9416
9487
  domestic,
9417
9488
  formId,
9489
+ isShipToForm,
9418
9490
  onCancel,
9419
9491
  onCancelParse,
9420
9492
  onSubmit,
@@ -9428,7 +9500,7 @@ const AddressForm = ({
9428
9500
  } = useTranslation();
9429
9501
  const form = useForm({
9430
9502
  defaultValues: Object.assign({}, address && address),
9431
- resolver: validationResolver(addressFormSchema)
9503
+ resolver: validationResolver(isShipToForm ? shipToAddressSchema : addressFormSchema)
9432
9504
  });
9433
9505
  const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
9434
9506
  const payload = __rest(values, []);
@@ -10013,7 +10085,8 @@ const creditCardSchema = z.object({
10013
10085
  });
10014
10086
  const walletSchema = z.object({
10015
10087
  address: billingAddressSchema,
10016
- creditCard: creditCardSchema
10088
+ creditCard: creditCardSchema,
10089
+ iovationBlackbox: z.string().trim().min(1)
10017
10090
  });
10018
10091
 
10019
10092
  const EditWalletAddressForm = ({
@@ -10099,6 +10172,7 @@ const WalletForm = ({
10099
10172
  const {
10100
10173
  validateAddress
10101
10174
  } = useAddressPreference();
10175
+ const [codedErrors, setCodedErrors] = useState(errors);
10102
10176
  const form = useForm({
10103
10177
  defaultValues:
10104
10178
  // If the warehouse address is a PO Box they cannot use it as their billing address
@@ -10113,6 +10187,23 @@ const WalletForm = ({
10113
10187
  },
10114
10188
  resolver: validationResolver(walletSchema)
10115
10189
  });
10190
+ useBlackboxDetection({
10191
+ onError: () => {
10192
+ setCodedErrors(errors => {
10193
+ const blackBoxError = {
10194
+ errorCode: "unspecified",
10195
+ errorSource: "client",
10196
+ errorType: "unknown",
10197
+ message: t("register-wallet:sections.notifications.blackBox.description")
10198
+ };
10199
+ return [...(errors !== null && errors !== void 0 ? errors : []), blackBoxError];
10200
+ });
10201
+ },
10202
+ onSuccess: bb => {
10203
+ console.log("bb", bb);
10204
+ form.setValue("iovationBlackbox", bb);
10205
+ }
10206
+ });
10116
10207
  const watchAddress = form.watch("address");
10117
10208
  const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
10118
10209
  const payload = __rest(values, []);
@@ -10126,7 +10217,8 @@ const WalletForm = ({
10126
10217
  onValid: validatedAddressesPayload => __awaiter(void 0, void 0, void 0, function* () {
10127
10218
  yield onSubmit({
10128
10219
  address: validatedAddressesPayload.originAddress,
10129
- creditCard: payload.creditCard
10220
+ creditCard: payload.creditCard,
10221
+ iovationBlackbox: payload.iovationBlackbox
10130
10222
  });
10131
10223
  })
10132
10224
  });
@@ -10149,11 +10241,11 @@ const WalletForm = ({
10149
10241
  children: [jsx(GridChild, Object.assign({
10150
10242
  colSpan: 12
10151
10243
  }, {
10152
- children: (errors === null || errors === void 0 ? void 0 : errors.length) && jsx(InlineNotification, Object.assign({
10244
+ children: !!(codedErrors === null || codedErrors === void 0 ? void 0 : codedErrors.length) && jsx(InlineNotification, Object.assign({
10153
10245
  title: t("register-wallet:sections.notifications.error.title"),
10154
10246
  type: NotificationType.ERROR
10155
10247
  }, {
10156
- children: errors.map(({
10248
+ children: codedErrors.map(({
10157
10249
  message
10158
10250
  }) => message).join(" ")
10159
10251
  }))
@@ -11147,10 +11239,10 @@ const AddressPreferenceDisplay = ({
11147
11239
  children: [jsx(Button, Object.assign({
11148
11240
  bold: false,
11149
11241
  isFullWidth: true,
11150
- onClick: () => {
11151
- handleChangePreference();
11242
+ onClick: () => __awaiter(void 0, void 0, void 0, function* () {
11243
+ yield handleChangePreference();
11152
11244
  toggleDisclosure();
11153
- },
11245
+ }),
11154
11246
  type: "button",
11155
11247
  variant: ButtonVariant.OUTLINED
11156
11248
  }, {
@@ -11195,7 +11287,8 @@ const baseSchema = addressSchema.extend({
11195
11287
  path: ["postalCode"]
11196
11288
  });
11197
11289
  const getCarrierRecoverySchema = requiresAddress => z.object({
11198
- address: requiresAddress ? baseSchema : baseSchema.optional()
11290
+ address: requiresAddress ? baseSchema : baseSchema.optional(),
11291
+ iovationBlackbox: z.string().trim().min(1)
11199
11292
  });
11200
11293
 
11201
11294
  const styles$c = createStyles({
@@ -11222,6 +11315,7 @@ const CarrierRecoveryForm = ({
11222
11315
  const {
11223
11316
  t
11224
11317
  } = useTranslation();
11318
+ const [codedErrors, setCodedErrors] = useState(errors);
11225
11319
  const metadata = useCarrierMetadata();
11226
11320
  const carrier = metadata.find(m => m.carrierCode === carrierCode);
11227
11321
  const carrierFriendlyName = (_a = carrier === null || carrier === void 0 ? void 0 : carrier.shortname) !== null && _a !== void 0 ? _a : "your carrier";
@@ -11234,6 +11328,22 @@ const CarrierRecoveryForm = ({
11234
11328
  }),
11235
11329
  resolver: validationResolver(getCarrierRecoverySchema(requiresAddress))
11236
11330
  });
11331
+ useBlackboxDetection({
11332
+ onError: () => {
11333
+ setCodedErrors(errors => {
11334
+ const blackBoxError = {
11335
+ errorCode: "unspecified",
11336
+ errorSource: "client",
11337
+ errorType: "unknown",
11338
+ message: t("register-wallet:sections.notifications.blackBox.description")
11339
+ };
11340
+ return [...(errors !== null && errors !== void 0 ? errors : []), blackBoxError];
11341
+ });
11342
+ },
11343
+ onSuccess: bb => {
11344
+ form.setValue("iovationBlackbox", bb);
11345
+ }
11346
+ });
11237
11347
  const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
11238
11348
  yield onSubmit(fundingSourceId, values);
11239
11349
  }));
@@ -11265,7 +11375,7 @@ const CarrierRecoveryForm = ({
11265
11375
  children: t("register-wallet:sections.carriers.subtitle")
11266
11376
  }))
11267
11377
  }))]
11268
- }), !!(errors === null || errors === void 0 ? void 0 : errors.length) && jsx(GridChild, Object.assign({
11378
+ }), !!(codedErrors === null || codedErrors === void 0 ? void 0 : codedErrors.length) && jsx(GridChild, Object.assign({
11269
11379
  colSpan: 12
11270
11380
  }, {
11271
11381
  children: jsx(InlineNotification, Object.assign({
@@ -11274,7 +11384,7 @@ const CarrierRecoveryForm = ({
11274
11384
  }),
11275
11385
  type: NotificationType.ERROR
11276
11386
  }, {
11277
- children: errors.map(({
11387
+ children: codedErrors.map(({
11278
11388
  message
11279
11389
  }) => message).join(" ")
11280
11390
  }))
@@ -11820,7 +11930,6 @@ const LandingPageForm = ({
11820
11930
  alwaysRequireValidity: true,
11821
11931
  control: form.control,
11822
11932
  "data-testid": "onboarding:landing.action",
11823
- form: "landing-page-form",
11824
11933
  variant: ButtonVariant.FILLED
11825
11934
  }, {
11826
11935
  children: t("onboarding:landing.action")
@@ -12581,6 +12690,7 @@ const Onboarding = ({
12581
12690
  createWarehouse,
12582
12691
  features,
12583
12692
  fundingSources,
12693
+ isRegisteringCarriers,
12584
12694
  onCarrierCreated,
12585
12695
  onCompleteOnboarding,
12586
12696
  onFundingSourceCreated,
@@ -12647,8 +12757,9 @@ const Onboarding = ({
12647
12757
  return [];
12648
12758
  };
12649
12759
  const handleWalletRegistrationSuccess = (fundingSourceId, {
12650
- address
12651
- } = {}) => __awaiter(void 0, void 0, void 0, function* () {
12760
+ address,
12761
+ iovationBlackbox
12762
+ }) => __awaiter(void 0, void 0, void 0, function* () {
12652
12763
  const addressToRegister = address !== null && address !== void 0 ? address : defaultWarehouse.originAddress;
12653
12764
  const pickupAddress = Object.assign(Object.assign({}, addressToRegister), {
12654
12765
  company: addressToRegister.companyName || "",
@@ -12665,6 +12776,7 @@ const Onboarding = ({
12665
12776
  agreeToTerms: true,
12666
12777
  carrierCode: "ups_walleted",
12667
12778
  fundingSourceId: fundingSourceId,
12779
+ iovationBlackBox: iovationBlackbox,
12668
12780
  pickupAddress: pickupAddress
12669
12781
  });
12670
12782
  }
@@ -12673,7 +12785,8 @@ const Onboarding = ({
12673
12785
  acceptedTerms: getTerms("dhl_express_walleted"),
12674
12786
  agreeToTerms: true,
12675
12787
  carrierCode: "dhl_express_worldwide",
12676
- fundingSourceId: fundingSourceId
12788
+ fundingSourceId: fundingSourceId,
12789
+ iovationBlackBox: iovationBlackbox
12677
12790
  });
12678
12791
  }
12679
12792
  return {
@@ -12694,7 +12807,8 @@ const Onboarding = ({
12694
12807
  });
12695
12808
  const handleWalletRegistration = ({
12696
12809
  address,
12697
- creditCard
12810
+ creditCard,
12811
+ iovationBlackbox
12698
12812
  }) => __awaiter(void 0, void 0, void 0, function* () {
12699
12813
  setHasCompletedBilling(true);
12700
12814
  const billingInfo = Object.assign(Object.assign({}, address), {
@@ -12707,11 +12821,14 @@ const Onboarding = ({
12707
12821
  acceptedTerms: getTerms("stamps_com"),
12708
12822
  agreeToTerms: agreedToTerms,
12709
12823
  billingInfo: billingInfo,
12824
+ iovationBlackBox: iovationBlackbox,
12710
12825
  paymentMethod: {
12711
12826
  creditCardInfo: Object.assign({}, creditCard)
12712
12827
  }
12713
12828
  });
12714
- yield handleWalletRegistrationSuccess(fundingSource.fundingSource.fundingSourceId);
12829
+ yield handleWalletRegistrationSuccess(fundingSource.fundingSource.fundingSourceId, {
12830
+ iovationBlackbox
12831
+ });
12715
12832
  } catch (_e) {
12716
12833
  setHasCompletedBilling(false);
12717
12834
  }
@@ -12861,6 +12978,11 @@ const Onboarding = ({
12861
12978
  });
12862
12979
  }
12863
12980
  }
12981
+ if (isRegisteringCarriers || currentStep === 4) {
12982
+ return jsx(Loader, {
12983
+ message: t("loading.connectingCarriers")
12984
+ });
12985
+ }
12864
12986
  return jsx(Loader, {
12865
12987
  message: t("loading.onboarding")
12866
12988
  });
@@ -14295,6 +14417,7 @@ const ShipmentForm = ({
14295
14417
  const [editShipToForm, isEditShipFormToOpen, toggleIsEditShipFormToOpen] = useNestedForm(AddressForm, {
14296
14418
  address: (_b = (_a = addressPreference === null || addressPreference === void 0 ? void 0 : addressPreference.selection) !== null && _a !== void 0 ? _a : shipment === null || shipment === void 0 ? void 0 : shipment.shipTo) !== null && _b !== void 0 ? _b : salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.shipTo,
14297
14419
  formId: "edit-ship-to-form",
14420
+ isShipToForm: true,
14298
14421
  onSubmit: handleSubmitEditShipTo,
14299
14422
  onSubmitParse: onSubmitParseShipTo,
14300
14423
  parseAddressErrors,
@@ -14522,6 +14645,7 @@ const ShipmentForm = ({
14522
14645
  })), jsx(DropdownOptionList, Object.assign({
14523
14646
  "data-id": "dropdown",
14524
14647
  dropdownWidth: "400px",
14648
+ hideWhenReferenceNotVisible: true,
14525
14649
  isOpen: showApplyPreset,
14526
14650
  onChange: () => setShowApplyPreset(false),
14527
14651
  onClickAway: e => {
@@ -14533,7 +14657,7 @@ const ShipmentForm = ({
14533
14657
  },
14534
14658
  reference: applyPresetRef.current
14535
14659
  }, {
14536
- children: shippingPresetOptions.map(presetCategory => jsx(OptionGroup, Object.assign({
14660
+ children: shippingPresetOptions.filter(preset => preset.options.length > 0).map(presetCategory => jsx(OptionGroup, Object.assign({
14537
14661
  label: presetCategory.categoryName
14538
14662
  }, {
14539
14663
  children: presetCategory.options.map(preset => jsx(Option, Object.assign({
@@ -15029,6 +15153,7 @@ var index = /*#__PURE__*/Object.freeze({
15029
15153
  addCarrierSchema: addCarrierSchema,
15030
15154
  AddressDisplay: AddressDisplay,
15031
15155
  AddressForm: AddressForm,
15156
+ shipToAddressSchema: shipToAddressSchema,
15032
15157
  addressFormSchema: addressFormSchema,
15033
15158
  AddressFields: AddressFields,
15034
15159
  addressLine1Schema: addressLine1Schema,
@@ -15092,7 +15217,7 @@ const DateRangeSelect = ({
15092
15217
  "data-testid": "date-range-select",
15093
15218
  label: t("wallet-history:dateRange"),
15094
15219
  leftContent: jsx(Icon, {
15095
- name: IconNames$1.FILTER
15220
+ name: IconNames.FILTER
15096
15221
  }),
15097
15222
  name: "date-range-select",
15098
15223
  onChange: handleChange,
@@ -15407,6 +15532,7 @@ var common = {
15407
15532
  accountSettings: "Loading account settings...",
15408
15533
  carrier: "Loading carrier...",
15409
15534
  carriers: "Loading carriers...",
15535
+ connectingCarriers: "Connecting carriers...",
15410
15536
  data: "Loading...",
15411
15537
  importingSalesOrder: "Importing order...",
15412
15538
  label: "Loading label...",
@@ -15446,7 +15572,8 @@ var common = {
15446
15572
  group: {
15447
15573
  allMeasurementsOrNone: "All measurements must be provided when entering {{fieldLabel}}"
15448
15574
  },
15449
- invalidAddressName: "Recipient Name must have two characters in First and Last Name.",
15575
+ invalidAddressName: "Invalid recipient name.",
15576
+ invalidAddressNameStrict: "Recipient Name must have two characters in First and Last Name.",
15450
15577
  invalidAddressPoBox: "A physical address is required for wallet registration. You can add a PO Box as a Ship From address.",
15451
15578
  invalidCreditCardType: "Card type must be Visa, Mastercard, American Express, or Discover",
15452
15579
  invalidExpiration: "Invalid Expiration Date",
@@ -15793,6 +15920,9 @@ var registerWallet = {
15793
15920
  title: "There was an error connecting {{carrierFriendlyName}}",
15794
15921
  confirmAddress: "Confirm your address details and try again.",
15795
15922
  description: "You can also skip this step for now and connect {{carrierFriendlyName}} in your Account Settings later."
15923
+ },
15924
+ blackBox: {
15925
+ description: "Please turn off all tracking add-ons like ad-blockers; they restrict our ability to confirm your activity is valid so we can more effectively prevent fraud."
15796
15926
  }
15797
15927
  }
15798
15928
  },
@@ -15934,6 +16064,7 @@ const Component$3 = ({
15934
16064
  } = useListCarriers();
15935
16065
  const {
15936
16066
  error: createFundingSourceErrors,
16067
+ isLoading: creatingFundingSource,
15937
16068
  mutateAsync: createFundingSource
15938
16069
  } = useCreateFundingSource();
15939
16070
  const {
@@ -15942,7 +16073,8 @@ const Component$3 = ({
15942
16073
  } = useListFundingSources();
15943
16074
  const {
15944
16075
  error: registerCarrierErrors,
15945
- mutateAsync: registerCarrier
16076
+ mutateAsync: registerCarrier,
16077
+ isLoading: registeringCarriers
15946
16078
  } = useRegisterCarrier();
15947
16079
  const onWarehouseCreated = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
15948
16080
  yield refetchWarehouses();
@@ -15966,6 +16098,7 @@ const Component$3 = ({
15966
16098
  createWarehouse: createWarehouse,
15967
16099
  features: features,
15968
16100
  fundingSources: fundingSources,
16101
+ isRegisteringCarriers: registeringCarriers || creatingFundingSource,
15969
16102
  onCarrierCreated: onCarrierCreated,
15970
16103
  onCompleteOnboarding: onCompleteOnboarding,
15971
16104
  onFundingSourceCreated: onFundingSourceCreated,
@@ -16083,7 +16216,6 @@ const useAddress = ({
16083
16216
  return parseResult;
16084
16217
  });
16085
16218
  const handleValidateAddress = useCallback((address, fallbackAddress) => __awaiter(void 0, void 0, void 0, function* () {
16086
- setAddressPreference(undefined);
16087
16219
  if (compatibleCountryCodes && !compatibleCountryCodes.includes(address.countryCode)) {
16088
16220
  resetAddressPreference({
16089
16221
  messages: [],
@@ -16097,6 +16229,7 @@ const useAddress = ({
16097
16229
  if (addressValidation) {
16098
16230
  const updatedAddressPreference = resetAddressPreference(addressValidation, fallbackAddress);
16099
16231
  yield onValidation === null || onValidation === void 0 ? void 0 : onValidation(updatedAddressPreference);
16232
+ return updatedAddressPreference;
16100
16233
  } else {
16101
16234
  // validate_and_clean failure is preventing the address preference object
16102
16235
  // from being refreshed. Manualy set the address preference to an error state.
@@ -16107,20 +16240,23 @@ const useAddress = ({
16107
16240
  originalAddress: address,
16108
16241
  status: "error"
16109
16242
  });
16243
+ return;
16110
16244
  }
16111
- }), [compatibleCountryCodes, onValidation, resetAddressPreference, validateAddresses]);
16245
+ }), [compatibleCountryCodes, onValidation, resetAddressPreference, setAddressPreference, validateAddresses]);
16112
16246
  const handleChangeAddress = useCallback((shipTo, {
16113
16247
  shouldValidate
16114
16248
  }) => __awaiter(void 0, void 0, void 0, function* () {
16249
+ var _a;
16115
16250
  if (!shipment) throw new Error("shipment not found");
16251
+ let updatedAddressPreference;
16252
+ if (shouldValidate) {
16253
+ updatedAddressPreference = yield handleValidateAddress(shipTo);
16254
+ }
16116
16255
  const updatedShipment = yield updateShipment(Object.assign(Object.assign({}, shipment), {
16117
16256
  shipDate: isNowOrInTheFuture(shipment.shipDate) ? shipment.shipDate : undefined,
16118
- shipTo
16257
+ shipTo: (_a = updatedAddressPreference === null || updatedAddressPreference === void 0 ? void 0 : updatedAddressPreference.selection) !== null && _a !== void 0 ? _a : shipTo
16119
16258
  }));
16120
16259
  yield onChange === null || onChange === void 0 ? void 0 : onChange(shipment, updatedShipment);
16121
- if (shouldValidate) {
16122
- yield handleValidateAddress(shipTo);
16123
- }
16124
16260
  return updatedShipment;
16125
16261
  }), [handleValidateAddress, onChange, shipment, updateShipment]);
16126
16262
  useEffect(() => {
@@ -17355,4 +17491,4 @@ var labelWorkflow = /*#__PURE__*/Object.freeze({
17355
17491
  Element: Element
17356
17492
  });
17357
17493
 
17358
- export { accountSettings as AccountSettings, AddFundsForm, AutoFundingForm, ButtonGroup, CarrierBalance, CollapsiblePanel, CopyButton, Country, Cube, DateRangeCombo, DateRangeSelect, ErrorFallback, fields as Field, FieldLabel, FormPortal, FundAndPurchase, InlineLabel, ItemsBreakdown, labelWorkflow as LabelWorkflow, LinkAction, listCarriers$1 as ListCarriers, Loader, ManageFunding, manageWarehouses$1 as ManageWarehouses, onboarding as Onboarding, PageLayoutProvider, PaymentMethodSettings, Portal, PoweredByShipEngine, purchaseLabel as PurchaseLabel, RootPortalProvider, Section, Spacer, Spread, StoryNotes, index as Templates, UsState, UsaCity, viewShipment as ViewShipment, voidLabel as VoidLabel, autoFundingSchema, calculateTotal, capitalizeFirstLetter, convertDimensions, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, daysAfter, errorMap, euCountryCodes, extendZod, featureFlagComponentNameLookup, formLogger, formatCreditCardNumber, formatDate, formatDateDDMMYY, formatExpiration, formatFractionalWeight, formatMoney, getAddFundsSchema, getCarrierIdByCarrierCode, getCustomsFromSalesOrder, getExpirationYears, getFeatures, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRelativeDates, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getTotalRateAmount, isDomesticAddress, isEmptyAddress, isFlatRatePackageCode, isMilitaryAddress, isNowOrInTheFuture, isPoBox, isPoBoxAddress, isString, isUnitedStatesTerritory, isUnsupportedByUps, isUpsCarrier, isUspsCarrier, moneySchema, mostRecent, nextDayCutoff, omitTime, overrideCarrierCodes$1 as overrideCarrierCodes, phoneSchema, phoneSchemaUnvalidated, postalCodeRegex$3 as postalCodeRegex, sortByCreationDate, throwAny, throwJoinedMessages, usCities, usStateCodes, usStates, useAddressValidation, useCarrierMetadata, useConfirmationOptions, useCountryCodeOptions, useCustomsContentsOptions, useCustomsNonDeliveryOptions, useDateRangeOptions, useExpirationMonthOptions, useFeatures, useInsuranceProviderOptions, useNestedForm, usePackageOptions, usePageLayout, useRateOptions, useRootPortal, useRunOnceOnTrue, useServiceCodeOptions, useShipmentMetadata, useShippingPresetsOptions, useStateCodeOptions, useToggle, useWarehouseOptions, validationResolver };
17494
+ export { accountSettings as AccountSettings, AddFundsForm, AutoFundingForm, ButtonGroup, CarrierBalance, CollapsiblePanel, CopyButton, Country, Cube, DateRangeCombo, DateRangeSelect, ErrorFallback, fields as Field, FieldLabel, FormPortal, FundAndPurchase, InlineLabel, ItemsBreakdown, labelWorkflow as LabelWorkflow, LinkAction, listCarriers$1 as ListCarriers, Loader, ManageFunding, manageWarehouses$1 as ManageWarehouses, onboarding as Onboarding, PageLayoutProvider, PaymentMethodSettings, Portal, PoweredByShipEngine, purchaseLabel as PurchaseLabel, RootPortalProvider, Section, Spacer, Spread, StoryNotes, index as Templates, UsState, UsaCity, viewShipment as ViewShipment, voidLabel as VoidLabel, autoFundingSchema, calculateTotal, capitalizeFirstLetter, convertDimensions, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, daysAfter, errorMap, euCountryCodes, extendZod, featureFlagComponentNameLookup, formLogger, formatCreditCardNumber, formatDate, formatDateDDMMYY, formatExpiration, formatFractionalWeight, formatMoney, getAddFundsSchema, getCarrierIdByCarrierCode, getCustomsFromSalesOrder, getExpirationYears, getFeatures, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRelativeDates, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getTotalRateAmount, isDomesticAddress, isEmptyAddress, isFlatRatePackageCode, isMilitaryAddress, isNowOrInTheFuture, isPoBox, isPoBoxAddress, isString, isUnitedStatesTerritory, isUnsupportedByUps, isUpsCarrier, isUspsCarrier, moneySchema, mostRecent, nextDayCutoff, omitTime, overrideCarrierCodes$1 as overrideCarrierCodes, phoneSchema, phoneSchemaUnvalidated, postalCodeRegex$3 as postalCodeRegex, sortByCreationDate, throwAny, throwJoinedMessages, usCities, usStateCodes, usStates, useAddressValidation, useBlackboxDetection, useCarrierMetadata, useConfirmationOptions, useCountryCodeOptions, useCustomsContentsOptions, useCustomsNonDeliveryOptions, useDateRangeOptions, useExpirationMonthOptions, useFeatures, useInsuranceProviderOptions, useNestedForm, usePackageOptions, usePageLayout, useRateOptions, useRootPortal, useRunOnceOnTrue, useServiceCodeOptions, useShipmentMetadata, useShippingPresetsOptions, useStateCodeOptions, useToggle, useWarehouseOptions, validationResolver };
package/package.json CHANGED
@@ -1,11 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/elements",
3
- "version": "0.32.1",
4
- "typedoc": {
5
- "entryPoint": "./src/index.ts",
6
- "readmeFile": "../../README.md",
7
- "displayName": "ShipEngine Elements"
8
- },
3
+ "version": "0.33.0",
9
4
  "peerDependencies": {
10
5
  "@packlink/giger": "*",
11
6
  "react-i18next": "*",
@@ -28,10 +23,10 @@
28
23
  "@faker-js/faker": "7.6.0",
29
24
  "@hookform/resolvers": "2.9.1",
30
25
  "@jest/globals": "28.1.3",
31
- "@packlink/brands": "3.24.0",
32
- "@packlink/giger-theme": "1.3.1",
33
- "@shipengine/alchemy": "0.5.14",
34
- "@shipengine/js-api": "0.19.1",
26
+ "@packlink/brands": "4.0.0",
27
+ "@packlink/giger-theme": "1.7.0",
28
+ "@shipengine/alchemy": "2.1.0",
29
+ "@shipengine/js-api": "0.23.0",
35
30
  "@storybook/addons": "6.5.16",
36
31
  "@storybook/components": "7.0.0-rc.1",
37
32
  "@storybook/core-events": "7.0.0-rc.1",
@@ -6,7 +6,7 @@ export declare const addCarrierSchema: z.ZodObject<{
6
6
  cityLocality: z.ZodString;
7
7
  companyName: z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodString>>, string | undefined, string | null | undefined>, z.ZodLiteral<"">]>, string | undefined, string | null | undefined>;
8
8
  countryCode: z.ZodEnum<["AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BR", "IO", "VG", "BN", "BG", "BF", "BI", "CA", "KH", "CM", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FM", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "CI", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "AN", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "KP", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "VI", "UM", "US", "UY", "UZ", "VU", "VE", "VN", "WF", "EH", "YE", "ZM", "ZW"]>;
9
- name: z.ZodEffects<z.ZodString, string, string>;
9
+ name: z.ZodString;
10
10
  phone: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodString>>, string, string | null | undefined>;
11
11
  postalCode: z.ZodString;
12
12
  stateProvince: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodString>>, string, string | null | undefined>;