@shipengine/elements 0.26.7 → 0.26.15

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.cjs CHANGED
@@ -8052,13 +8052,23 @@ const styles$g = createStyles({
8052
8052
  const ListCarriers = ({
8053
8053
  carriers: _carriers = [],
8054
8054
  errors,
8055
+ features,
8055
8056
  isLoading,
8056
8057
  onRegisterCarrier,
8057
8058
  registerCarrierErrors
8058
8059
  }) => {
8060
+ features = Object.assign({
8061
+ carriers: {
8062
+ enabledCarriers: ["dhl_express_walleted", "ups"]
8063
+ }
8064
+ }, features !== null && features !== void 0 ? features : {});
8059
8065
  const {
8060
8066
  t
8061
8067
  } = reactI18next.useTranslation();
8068
+ const enabledCarriers = _carriers.filter(carrier => {
8069
+ var _a;
8070
+ return carrier.carrier.carrierCode === "stamps_com" || ((_a = features === null || features === void 0 ? void 0 : features.carriers) === null || _a === void 0 ? void 0 : _a.enabledCarriers.includes(carrier.carrier.carrierCode));
8071
+ });
8062
8072
  return jsxRuntime.jsxs(Section, Object.assign({
8063
8073
  title: t("list-carriers:headers.carriers")
8064
8074
  }, {
@@ -8081,7 +8091,7 @@ const ListCarriers = ({
8081
8091
  }, {
8082
8092
  children: isLoading ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
8083
8093
  children: [jsxRuntime.jsx(LoadingSkeletonRow, {}), jsxRuntime.jsx(LoadingSkeletonRow, {}), jsxRuntime.jsx(LoadingSkeletonRow, {})]
8084
- }) : _carriers.map(carrier => jsxRuntime.jsx("li", {
8094
+ }) : enabledCarriers.map(carrier => jsxRuntime.jsx("li", {
8085
8095
  children: jsxRuntime.jsx(ListCarriersRow, {
8086
8096
  connectedCarrier: carrier,
8087
8097
  registerCarrier: values => __awaiter(void 0, void 0, void 0, function* () {
@@ -10201,12 +10211,13 @@ const Onboarding = ({
10201
10211
  registerUpsCarrierErrors,
10202
10212
  warehouses
10203
10213
  }) => {
10204
- var _a, _b;
10214
+ var _a, _b, _c;
10205
10215
  features = Object.assign({
10206
- global: {
10207
- presentation: {
10208
- poweredByShipEngine: false
10209
- }
10216
+ carriers: {
10217
+ enabledCarriers: ["ups", "dhl_express_walleted"]
10218
+ },
10219
+ presentation: {
10220
+ poweredByShipEngine: false
10210
10221
  }
10211
10222
  }, features !== null && features !== void 0 ? features : {});
10212
10223
  const {
@@ -10222,9 +10233,10 @@ const Onboarding = ({
10222
10233
  // Make sure their Stamps carrier is not the Free one
10223
10234
  // Once an account adds a UPS carrier to their Stamps wallet, the carrierCode changes from "stamps_com" => "usps"
10224
10235
  const hasStampsWallet = carriers === null || carriers === void 0 ? void 0 : carriers.some(carrier => carrier.carrierCode === "stamps_com" && carrier.nickname !== "Free" || carrier.carrierCode === "usps");
10236
+ const upsEnabled = (_b = (_a = features === null || features === void 0 ? void 0 : features.carriers) === null || _a === void 0 ? void 0 : _a.enabledCarriers) === null || _b === void 0 ? void 0 : _b.includes("ups");
10225
10237
  const hasUps = carriers === null || carriers === void 0 ? void 0 : carriers.some(c => c.carrierCode === "ups");
10226
10238
  const hasDhl = carriers === null || carriers === void 0 ? void 0 : carriers.some(c => c.carrierCode === "dhl_express_worldwide");
10227
- const hasCompletedOnboarding = onboardingComplete || warehouses.length && hasStampsWallet && hasUps && hasDhl;
10239
+ const hasCompletedOnboarding = onboardingComplete || warehouses.length && hasStampsWallet && (hasUps || !upsEnabled) && hasDhl;
10228
10240
  const currentStep = React.useMemo(() => {
10229
10241
  if (hasCompletedOnboarding) {
10230
10242
  return 5;
@@ -10243,7 +10255,7 @@ const Onboarding = ({
10243
10255
  }) => __awaiter(void 0, void 0, void 0, function* () {
10244
10256
  setAddress(address);
10245
10257
  try {
10246
- yield Promise.all([!hasUps && address && registerUpsCarrier({
10258
+ yield Promise.all([upsEnabled && !hasUps && address && registerUpsCarrier({
10247
10259
  address,
10248
10260
  agreeToCarrierTerms: agreedToTerms,
10249
10261
  carrierCode: "ups",
@@ -10253,7 +10265,7 @@ const Onboarding = ({
10253
10265
  carrierCode: "dhl_express_walleted",
10254
10266
  nickname: "dhl_express_walleted"
10255
10267
  })]);
10256
- } catch (_c) {
10268
+ } catch (_d) {
10257
10269
  // Errors shown inline for recovery
10258
10270
  }
10259
10271
  yield onCarrierCreated();
@@ -10282,7 +10294,7 @@ const Onboarding = ({
10282
10294
  });
10283
10295
  });
10284
10296
  const renderStep = () => {
10285
- var _a;
10297
+ var _a, _b, _c;
10286
10298
  // Step 5: Onboarding Complete
10287
10299
  if (hasCompletedOnboarding) {
10288
10300
  return jsxRuntime.jsx(CompletionPage, {
@@ -10296,7 +10308,7 @@ const Onboarding = ({
10296
10308
  // Step 2: Agree to Terms and Conditions
10297
10309
  if (!agreedToTerms) {
10298
10310
  return jsxRuntime.jsx(CarrierTermsForm, {
10299
- carrierCodes: ["stamps_com", "ups", "dhl_express_walleted"],
10311
+ carrierCodes: ["stamps_com"].concat((_b = (_a = features === null || features === void 0 ? void 0 : features.carriers) === null || _a === void 0 ? void 0 : _a.enabledCarriers) !== null && _b !== void 0 ? _b : []),
10300
10312
  onSubmit: () => {
10301
10313
  setAgreedToTerms(true);
10302
10314
  if (!warehouses.length) {
@@ -10346,7 +10358,7 @@ const Onboarding = ({
10346
10358
  }
10347
10359
  // Step 4: Register Stamps Wallet, UPS, DHL
10348
10360
  if (agreedToTerms && warehouses.length && hasValidAddress && !hasStampsWallet && !hasCompletedBilling) {
10349
- const defaultWarehouse = (_a = warehouses.find(w => w.isDefault)) !== null && _a !== void 0 ? _a : warehouses[0];
10361
+ const defaultWarehouse = (_c = warehouses.find(w => w.isDefault)) !== null && _c !== void 0 ? _c : warehouses[0];
10350
10362
  return jsxRuntime.jsx(AddressPreferenceProvider, Object.assign({
10351
10363
  formHeader: jsxRuntime.jsxs("div", Object.assign({
10352
10364
  css: styles$c.walletFormHeader
@@ -10401,7 +10413,7 @@ const Onboarding = ({
10401
10413
  }
10402
10414
  if (hasStampsWallet) {
10403
10415
  // Step 4.1: Handle UPS Registration Errors
10404
- if (!hasUps && registerUpsCarrierErrors) {
10416
+ if (upsEnabled && !hasUps && registerUpsCarrierErrors) {
10405
10417
  return jsxRuntime.jsx(CarrierRecoveryForm, {
10406
10418
  address: address,
10407
10419
  carrierCode: "ups",
@@ -10447,7 +10459,7 @@ const Onboarding = ({
10447
10459
  css: styles$c.step,
10448
10460
  label: t("onboarding:steps.payment")
10449
10461
  })]
10450
- })), renderStep(), ((_b = (_a = features === null || features === void 0 ? void 0 : features.global) === null || _a === void 0 ? void 0 : _a.presentation) === null || _b === void 0 ? void 0 : _b.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
10462
+ })), renderStep(), ((_c = features === null || features === void 0 ? void 0 : features.presentation) === null || _c === void 0 ? void 0 : _c.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
10451
10463
  children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(PoweredByShipEngine, {})]
10452
10464
  })]
10453
10465
  }));
@@ -10805,8 +10817,10 @@ const styles$9 = createStyles({
10805
10817
  });
10806
10818
 
10807
10819
  const CarrierBalance = ({
10820
+ balance,
10808
10821
  carrierId
10809
10822
  }) => {
10823
+ var _a;
10810
10824
  const {
10811
10825
  t
10812
10826
  } = reactI18next.useTranslation();
@@ -10815,16 +10829,16 @@ const CarrierBalance = ({
10815
10829
  isLoading: isLoadingCarrier,
10816
10830
  isRefetching: isRefetchingCarrier
10817
10831
  } = alchemy.useGetCarrierById(carrierId);
10818
- const balance = carrier === null || carrier === void 0 ? void 0 : carrier.balance;
10832
+ const carrierBalance = (_a = carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== null && _a !== void 0 ? _a : balance;
10819
10833
  return jsxRuntime.jsx(InlineLabel, Object.assign({
10820
10834
  label: t("manage-funding:currentBalance")
10821
10835
  }, {
10822
10836
  children: isLoadingCarrier || isRefetchingCarrier ? jsxRuntime.jsx(giger.Spinner, {}) : jsxRuntime.jsx(giger.Typography, Object.assign({
10823
10837
  bold: true,
10824
- css: styles$9.getBalanceText(balance)
10838
+ css: styles$9.getBalanceText(carrierBalance)
10825
10839
  }, {
10826
- children: balance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
10827
- amount: balance,
10840
+ children: carrierBalance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
10841
+ amount: carrierBalance,
10828
10842
  currency: alchemy.SE.Currency.USD
10829
10843
  })
10830
10844
  }))
@@ -10872,6 +10886,7 @@ const styles$8 = createStyles({
10872
10886
  * to submit the funding form followed by the purchase form.
10873
10887
  */
10874
10888
  const FundAndPurchase = ({
10889
+ balance: uspsBalance,
10875
10890
  carrierId,
10876
10891
  className,
10877
10892
  control,
@@ -10947,13 +10962,23 @@ const FundAndPurchase = ({
10947
10962
  }))]
10948
10963
  }))]
10949
10964
  });
10950
- // Render: not a walleted carrier;
10951
- // don't show balance or funding form
10952
- if (!isFundingRequired) return jsxRuntime.jsx("div", Object.assign({
10965
+ // render when no rate has been selected yet
10966
+ if (!carrierId) return jsxRuntime.jsxs("div", Object.assign({
10953
10967
  className: className,
10954
10968
  css: styles$8.container
10955
10969
  }, {
10956
- children: renderActionButtons()
10970
+ children: [jsxRuntime.jsxs(Spread, {
10971
+ children: [jsxRuntime.jsx(CarrierBalance, {
10972
+ balance: uspsBalance
10973
+ }), isFundingEnabled ? jsxRuntime.jsx(LinkAction, {
10974
+ icon: "add",
10975
+ isDisabled: !isFundingRequired || isAddFundsFormOpen || isRateFormSubmitting,
10976
+ onClick: () => setIsAddFundsFormOpen(true),
10977
+ title: t("manage-funding:actions.addFunds")
10978
+ }) : null]
10979
+ }), jsxRuntime.jsx(Spacer, {
10980
+ multiplier: 2
10981
+ }), renderActionButtons()]
10957
10982
  }));
10958
10983
  if (isLoadingCarrier) return jsxRuntime.jsx(Loader, {
10959
10984
  message: t("loading.carrier")
@@ -11550,12 +11575,10 @@ const RateForm = ({
11550
11575
  shipment,
11551
11576
  outOfBandDisplayableErrors
11552
11577
  }) => {
11553
- var _a, _b, _c, _d, _e, _f;
11578
+ var _a, _b, _c, _d, _e;
11554
11579
  features = Object.assign({
11555
- global: {
11556
- presentation: {
11557
- poweredByShipEngine: false
11558
- }
11580
+ presentation: {
11581
+ poweredByShipEngine: false
11559
11582
  },
11560
11583
  rateForm: {
11561
11584
  enableGlobalPostFiltering: false,
@@ -11652,6 +11675,10 @@ const RateForm = ({
11652
11675
  }, 0);
11653
11676
  }
11654
11677
  }, [form, rateOptions, errors === null || errors === void 0 ? void 0 : errors.length]);
11678
+ const balance = React.useMemo(() => {
11679
+ var _a;
11680
+ return (_a = carriers === null || carriers === void 0 ? void 0 : carriers.find(carrier => carrier.carrierCode === "usps")) === null || _a === void 0 ? void 0 : _a.balance;
11681
+ }, [carriers]);
11655
11682
  return jsxRuntime.jsxs("form", Object.assign({
11656
11683
  id: "rate-form",
11657
11684
  onSubmit: handleSubmit,
@@ -11717,6 +11744,7 @@ const RateForm = ({
11717
11744
  display: "purchase"
11718
11745
  })
11719
11746
  })), jsxRuntime.jsx(FundAndPurchase, {
11747
+ balance: balance,
11720
11748
  carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
11721
11749
  control: form.control,
11722
11750
  css: styles$4.fundAndPurchase,
@@ -11726,7 +11754,7 @@ const RateForm = ({
11726
11754
  onPurchase: handleSubmit,
11727
11755
  onSave: handleSaveRate,
11728
11756
  purchaseAmount: getTotalRateAmount(selectedRate)
11729
- }), ((_f = (_e = features === null || features === void 0 ? void 0 : features.global) === null || _e === void 0 ? void 0 : _e.presentation) === null || _f === void 0 ? void 0 : _f.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
11757
+ }), ((_e = features === null || features === void 0 ? void 0 : features.presentation) === null || _e === void 0 ? void 0 : _e.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
11730
11758
  children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(PoweredByShipEngine, {})]
11731
11759
  })]
11732
11760
  }));
@@ -13054,12 +13082,10 @@ const Shipment = ({
13054
13082
  shipment,
13055
13083
  warehouse
13056
13084
  }) => {
13057
- var _a, _b, _c, _d;
13085
+ var _a, _b, _c;
13058
13086
  features = Object.assign({
13059
- global: {
13060
- presentation: {
13061
- poweredByShipEngine: false
13062
- }
13087
+ presentation: {
13088
+ poweredByShipEngine: false
13063
13089
  }
13064
13090
  }, features !== null && features !== void 0 ? features : {});
13065
13091
  const {
@@ -13242,7 +13268,7 @@ const Shipment = ({
13242
13268
  })), "representative."]
13243
13269
  }))
13244
13270
  }))
13245
- })), ((_d = (_c = features === null || features === void 0 ? void 0 : features.global) === null || _c === void 0 ? void 0 : _c.presentation) === null || _d === void 0 ? void 0 : _d.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
13271
+ })), ((_c = features === null || features === void 0 ? void 0 : features.presentation) === null || _c === void 0 ? void 0 : _c.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
13246
13272
  children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(PoweredByShipEngine, {})]
13247
13273
  })]
13248
13274
  });
@@ -14372,7 +14398,9 @@ const useListConnectedCarriers = () => {
14372
14398
  };
14373
14399
  };
14374
14400
 
14375
- const Component$5 = () => {
14401
+ const Component$5 = ({
14402
+ features
14403
+ }) => {
14376
14404
  const {
14377
14405
  data: carriersConnectedStatus,
14378
14406
  error,
@@ -14395,6 +14423,7 @@ const Component$5 = () => {
14395
14423
  return jsxRuntime.jsx(ListCarriers, {
14396
14424
  carriers: carriersConnectedStatus,
14397
14425
  errors: error,
14426
+ features: features,
14398
14427
  isLoading: isLoading,
14399
14428
  onRegisterCarrier: handleRegistration,
14400
14429
  registerCarrierErrors: registerCarrierErrors
@@ -15748,12 +15777,10 @@ const Component = ({
15748
15777
  onSuccess,
15749
15778
  onViewShipment
15750
15779
  }) => {
15751
- var _a, _b, _c;
15780
+ var _a, _b;
15752
15781
  features = Object.assign({
15753
- global: {
15754
- presentation: {
15755
- poweredByShipEngine: false
15756
- }
15782
+ presentation: {
15783
+ poweredByShipEngine: false
15757
15784
  }
15758
15785
  }, features !== null && features !== void 0 ? features : {});
15759
15786
  // TODO [LMNT-910] - labelId should be a required prop
@@ -15789,7 +15816,7 @@ const Component = ({
15789
15816
  onViewShipment: onViewShipment,
15790
15817
  shipment: shipment.data,
15791
15818
  voidRequest: voidLabel.data
15792
- }), ((_c = (_b = features === null || features === void 0 ? void 0 : features.global) === null || _b === void 0 ? void 0 : _b.presentation) === null || _c === void 0 ? void 0 : _c.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
15819
+ }), ((_b = features === null || features === void 0 ? void 0 : features.presentation) === null || _b === void 0 ? void 0 : _b.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
15793
15820
  children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(PoweredByShipEngine, {})]
15794
15821
  })]
15795
15822
  });
package/index.js CHANGED
@@ -8020,13 +8020,23 @@ const styles$g = createStyles({
8020
8020
  const ListCarriers = ({
8021
8021
  carriers: _carriers = [],
8022
8022
  errors,
8023
+ features,
8023
8024
  isLoading,
8024
8025
  onRegisterCarrier,
8025
8026
  registerCarrierErrors
8026
8027
  }) => {
8028
+ features = Object.assign({
8029
+ carriers: {
8030
+ enabledCarriers: ["dhl_express_walleted", "ups"]
8031
+ }
8032
+ }, features !== null && features !== void 0 ? features : {});
8027
8033
  const {
8028
8034
  t
8029
8035
  } = useTranslation();
8036
+ const enabledCarriers = _carriers.filter(carrier => {
8037
+ var _a;
8038
+ return carrier.carrier.carrierCode === "stamps_com" || ((_a = features === null || features === void 0 ? void 0 : features.carriers) === null || _a === void 0 ? void 0 : _a.enabledCarriers.includes(carrier.carrier.carrierCode));
8039
+ });
8030
8040
  return jsxs(Section, Object.assign({
8031
8041
  title: t("list-carriers:headers.carriers")
8032
8042
  }, {
@@ -8049,7 +8059,7 @@ const ListCarriers = ({
8049
8059
  }, {
8050
8060
  children: isLoading ? jsxs(Fragment, {
8051
8061
  children: [jsx(LoadingSkeletonRow, {}), jsx(LoadingSkeletonRow, {}), jsx(LoadingSkeletonRow, {})]
8052
- }) : _carriers.map(carrier => jsx("li", {
8062
+ }) : enabledCarriers.map(carrier => jsx("li", {
8053
8063
  children: jsx(ListCarriersRow, {
8054
8064
  connectedCarrier: carrier,
8055
8065
  registerCarrier: values => __awaiter(void 0, void 0, void 0, function* () {
@@ -10169,12 +10179,13 @@ const Onboarding = ({
10169
10179
  registerUpsCarrierErrors,
10170
10180
  warehouses
10171
10181
  }) => {
10172
- var _a, _b;
10182
+ var _a, _b, _c;
10173
10183
  features = Object.assign({
10174
- global: {
10175
- presentation: {
10176
- poweredByShipEngine: false
10177
- }
10184
+ carriers: {
10185
+ enabledCarriers: ["ups", "dhl_express_walleted"]
10186
+ },
10187
+ presentation: {
10188
+ poweredByShipEngine: false
10178
10189
  }
10179
10190
  }, features !== null && features !== void 0 ? features : {});
10180
10191
  const {
@@ -10190,9 +10201,10 @@ const Onboarding = ({
10190
10201
  // Make sure their Stamps carrier is not the Free one
10191
10202
  // Once an account adds a UPS carrier to their Stamps wallet, the carrierCode changes from "stamps_com" => "usps"
10192
10203
  const hasStampsWallet = carriers === null || carriers === void 0 ? void 0 : carriers.some(carrier => carrier.carrierCode === "stamps_com" && carrier.nickname !== "Free" || carrier.carrierCode === "usps");
10204
+ const upsEnabled = (_b = (_a = features === null || features === void 0 ? void 0 : features.carriers) === null || _a === void 0 ? void 0 : _a.enabledCarriers) === null || _b === void 0 ? void 0 : _b.includes("ups");
10193
10205
  const hasUps = carriers === null || carriers === void 0 ? void 0 : carriers.some(c => c.carrierCode === "ups");
10194
10206
  const hasDhl = carriers === null || carriers === void 0 ? void 0 : carriers.some(c => c.carrierCode === "dhl_express_worldwide");
10195
- const hasCompletedOnboarding = onboardingComplete || warehouses.length && hasStampsWallet && hasUps && hasDhl;
10207
+ const hasCompletedOnboarding = onboardingComplete || warehouses.length && hasStampsWallet && (hasUps || !upsEnabled) && hasDhl;
10196
10208
  const currentStep = useMemo(() => {
10197
10209
  if (hasCompletedOnboarding) {
10198
10210
  return 5;
@@ -10211,7 +10223,7 @@ const Onboarding = ({
10211
10223
  }) => __awaiter(void 0, void 0, void 0, function* () {
10212
10224
  setAddress(address);
10213
10225
  try {
10214
- yield Promise.all([!hasUps && address && registerUpsCarrier({
10226
+ yield Promise.all([upsEnabled && !hasUps && address && registerUpsCarrier({
10215
10227
  address,
10216
10228
  agreeToCarrierTerms: agreedToTerms,
10217
10229
  carrierCode: "ups",
@@ -10221,7 +10233,7 @@ const Onboarding = ({
10221
10233
  carrierCode: "dhl_express_walleted",
10222
10234
  nickname: "dhl_express_walleted"
10223
10235
  })]);
10224
- } catch (_c) {
10236
+ } catch (_d) {
10225
10237
  // Errors shown inline for recovery
10226
10238
  }
10227
10239
  yield onCarrierCreated();
@@ -10250,7 +10262,7 @@ const Onboarding = ({
10250
10262
  });
10251
10263
  });
10252
10264
  const renderStep = () => {
10253
- var _a;
10265
+ var _a, _b, _c;
10254
10266
  // Step 5: Onboarding Complete
10255
10267
  if (hasCompletedOnboarding) {
10256
10268
  return jsx(CompletionPage, {
@@ -10264,7 +10276,7 @@ const Onboarding = ({
10264
10276
  // Step 2: Agree to Terms and Conditions
10265
10277
  if (!agreedToTerms) {
10266
10278
  return jsx(CarrierTermsForm, {
10267
- carrierCodes: ["stamps_com", "ups", "dhl_express_walleted"],
10279
+ carrierCodes: ["stamps_com"].concat((_b = (_a = features === null || features === void 0 ? void 0 : features.carriers) === null || _a === void 0 ? void 0 : _a.enabledCarriers) !== null && _b !== void 0 ? _b : []),
10268
10280
  onSubmit: () => {
10269
10281
  setAgreedToTerms(true);
10270
10282
  if (!warehouses.length) {
@@ -10314,7 +10326,7 @@ const Onboarding = ({
10314
10326
  }
10315
10327
  // Step 4: Register Stamps Wallet, UPS, DHL
10316
10328
  if (agreedToTerms && warehouses.length && hasValidAddress && !hasStampsWallet && !hasCompletedBilling) {
10317
- const defaultWarehouse = (_a = warehouses.find(w => w.isDefault)) !== null && _a !== void 0 ? _a : warehouses[0];
10329
+ const defaultWarehouse = (_c = warehouses.find(w => w.isDefault)) !== null && _c !== void 0 ? _c : warehouses[0];
10318
10330
  return jsx(AddressPreferenceProvider, Object.assign({
10319
10331
  formHeader: jsxs("div", Object.assign({
10320
10332
  css: styles$c.walletFormHeader
@@ -10369,7 +10381,7 @@ const Onboarding = ({
10369
10381
  }
10370
10382
  if (hasStampsWallet) {
10371
10383
  // Step 4.1: Handle UPS Registration Errors
10372
- if (!hasUps && registerUpsCarrierErrors) {
10384
+ if (upsEnabled && !hasUps && registerUpsCarrierErrors) {
10373
10385
  return jsx(CarrierRecoveryForm, {
10374
10386
  address: address,
10375
10387
  carrierCode: "ups",
@@ -10415,7 +10427,7 @@ const Onboarding = ({
10415
10427
  css: styles$c.step,
10416
10428
  label: t("onboarding:steps.payment")
10417
10429
  })]
10418
- })), renderStep(), ((_b = (_a = features === null || features === void 0 ? void 0 : features.global) === null || _a === void 0 ? void 0 : _a.presentation) === null || _b === void 0 ? void 0 : _b.poweredByShipEngine) && jsxs(Fragment, {
10430
+ })), renderStep(), ((_c = features === null || features === void 0 ? void 0 : features.presentation) === null || _c === void 0 ? void 0 : _c.poweredByShipEngine) && jsxs(Fragment, {
10419
10431
  children: [jsx(Spacer, {}), jsx(PoweredByShipEngine, {})]
10420
10432
  })]
10421
10433
  }));
@@ -10773,8 +10785,10 @@ const styles$9 = createStyles({
10773
10785
  });
10774
10786
 
10775
10787
  const CarrierBalance = ({
10788
+ balance,
10776
10789
  carrierId
10777
10790
  }) => {
10791
+ var _a;
10778
10792
  const {
10779
10793
  t
10780
10794
  } = useTranslation();
@@ -10783,16 +10797,16 @@ const CarrierBalance = ({
10783
10797
  isLoading: isLoadingCarrier,
10784
10798
  isRefetching: isRefetchingCarrier
10785
10799
  } = useGetCarrierById(carrierId);
10786
- const balance = carrier === null || carrier === void 0 ? void 0 : carrier.balance;
10800
+ const carrierBalance = (_a = carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== null && _a !== void 0 ? _a : balance;
10787
10801
  return jsx(InlineLabel, Object.assign({
10788
10802
  label: t("manage-funding:currentBalance")
10789
10803
  }, {
10790
10804
  children: isLoadingCarrier || isRefetchingCarrier ? jsx(Spinner, {}) : jsx(Typography, Object.assign({
10791
10805
  bold: true,
10792
- css: styles$9.getBalanceText(balance)
10806
+ css: styles$9.getBalanceText(carrierBalance)
10793
10807
  }, {
10794
- children: balance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
10795
- amount: balance,
10808
+ children: carrierBalance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
10809
+ amount: carrierBalance,
10796
10810
  currency: SE.Currency.USD
10797
10811
  })
10798
10812
  }))
@@ -10840,6 +10854,7 @@ const styles$8 = createStyles({
10840
10854
  * to submit the funding form followed by the purchase form.
10841
10855
  */
10842
10856
  const FundAndPurchase = ({
10857
+ balance: uspsBalance,
10843
10858
  carrierId,
10844
10859
  className,
10845
10860
  control,
@@ -10915,13 +10930,23 @@ const FundAndPurchase = ({
10915
10930
  }))]
10916
10931
  }))]
10917
10932
  });
10918
- // Render: not a walleted carrier;
10919
- // don't show balance or funding form
10920
- if (!isFundingRequired) return jsx("div", Object.assign({
10933
+ // render when no rate has been selected yet
10934
+ if (!carrierId) return jsxs("div", Object.assign({
10921
10935
  className: className,
10922
10936
  css: styles$8.container
10923
10937
  }, {
10924
- children: renderActionButtons()
10938
+ children: [jsxs(Spread, {
10939
+ children: [jsx(CarrierBalance, {
10940
+ balance: uspsBalance
10941
+ }), isFundingEnabled ? jsx(LinkAction, {
10942
+ icon: "add",
10943
+ isDisabled: !isFundingRequired || isAddFundsFormOpen || isRateFormSubmitting,
10944
+ onClick: () => setIsAddFundsFormOpen(true),
10945
+ title: t("manage-funding:actions.addFunds")
10946
+ }) : null]
10947
+ }), jsx(Spacer, {
10948
+ multiplier: 2
10949
+ }), renderActionButtons()]
10925
10950
  }));
10926
10951
  if (isLoadingCarrier) return jsx(Loader, {
10927
10952
  message: t("loading.carrier")
@@ -11518,12 +11543,10 @@ const RateForm = ({
11518
11543
  shipment,
11519
11544
  outOfBandDisplayableErrors
11520
11545
  }) => {
11521
- var _a, _b, _c, _d, _e, _f;
11546
+ var _a, _b, _c, _d, _e;
11522
11547
  features = Object.assign({
11523
- global: {
11524
- presentation: {
11525
- poweredByShipEngine: false
11526
- }
11548
+ presentation: {
11549
+ poweredByShipEngine: false
11527
11550
  },
11528
11551
  rateForm: {
11529
11552
  enableGlobalPostFiltering: false,
@@ -11620,6 +11643,10 @@ const RateForm = ({
11620
11643
  }, 0);
11621
11644
  }
11622
11645
  }, [form, rateOptions, errors === null || errors === void 0 ? void 0 : errors.length]);
11646
+ const balance = useMemo(() => {
11647
+ var _a;
11648
+ return (_a = carriers === null || carriers === void 0 ? void 0 : carriers.find(carrier => carrier.carrierCode === "usps")) === null || _a === void 0 ? void 0 : _a.balance;
11649
+ }, [carriers]);
11623
11650
  return jsxs("form", Object.assign({
11624
11651
  id: "rate-form",
11625
11652
  onSubmit: handleSubmit,
@@ -11685,6 +11712,7 @@ const RateForm = ({
11685
11712
  display: "purchase"
11686
11713
  })
11687
11714
  })), jsx(FundAndPurchase, {
11715
+ balance: balance,
11688
11716
  carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
11689
11717
  control: form.control,
11690
11718
  css: styles$4.fundAndPurchase,
@@ -11694,7 +11722,7 @@ const RateForm = ({
11694
11722
  onPurchase: handleSubmit,
11695
11723
  onSave: handleSaveRate,
11696
11724
  purchaseAmount: getTotalRateAmount(selectedRate)
11697
- }), ((_f = (_e = features === null || features === void 0 ? void 0 : features.global) === null || _e === void 0 ? void 0 : _e.presentation) === null || _f === void 0 ? void 0 : _f.poweredByShipEngine) && jsxs(Fragment, {
11725
+ }), ((_e = features === null || features === void 0 ? void 0 : features.presentation) === null || _e === void 0 ? void 0 : _e.poweredByShipEngine) && jsxs(Fragment, {
11698
11726
  children: [jsx(Spacer, {}), jsx(PoweredByShipEngine, {})]
11699
11727
  })]
11700
11728
  }));
@@ -13022,12 +13050,10 @@ const Shipment = ({
13022
13050
  shipment,
13023
13051
  warehouse
13024
13052
  }) => {
13025
- var _a, _b, _c, _d;
13053
+ var _a, _b, _c;
13026
13054
  features = Object.assign({
13027
- global: {
13028
- presentation: {
13029
- poweredByShipEngine: false
13030
- }
13055
+ presentation: {
13056
+ poweredByShipEngine: false
13031
13057
  }
13032
13058
  }, features !== null && features !== void 0 ? features : {});
13033
13059
  const {
@@ -13210,7 +13236,7 @@ const Shipment = ({
13210
13236
  })), "representative."]
13211
13237
  }))
13212
13238
  }))
13213
- })), ((_d = (_c = features === null || features === void 0 ? void 0 : features.global) === null || _c === void 0 ? void 0 : _c.presentation) === null || _d === void 0 ? void 0 : _d.poweredByShipEngine) && jsxs(Fragment, {
13239
+ })), ((_c = features === null || features === void 0 ? void 0 : features.presentation) === null || _c === void 0 ? void 0 : _c.poweredByShipEngine) && jsxs(Fragment, {
13214
13240
  children: [jsx(Spacer, {}), jsx(PoweredByShipEngine, {})]
13215
13241
  })]
13216
13242
  });
@@ -14340,7 +14366,9 @@ const useListConnectedCarriers = () => {
14340
14366
  };
14341
14367
  };
14342
14368
 
14343
- const Component$5 = () => {
14369
+ const Component$5 = ({
14370
+ features
14371
+ }) => {
14344
14372
  const {
14345
14373
  data: carriersConnectedStatus,
14346
14374
  error,
@@ -14363,6 +14391,7 @@ const Component$5 = () => {
14363
14391
  return jsx(ListCarriers, {
14364
14392
  carriers: carriersConnectedStatus,
14365
14393
  errors: error,
14394
+ features: features,
14366
14395
  isLoading: isLoading,
14367
14396
  onRegisterCarrier: handleRegistration,
14368
14397
  registerCarrierErrors: registerCarrierErrors
@@ -15716,12 +15745,10 @@ const Component = ({
15716
15745
  onSuccess,
15717
15746
  onViewShipment
15718
15747
  }) => {
15719
- var _a, _b, _c;
15748
+ var _a, _b;
15720
15749
  features = Object.assign({
15721
- global: {
15722
- presentation: {
15723
- poweredByShipEngine: false
15724
- }
15750
+ presentation: {
15751
+ poweredByShipEngine: false
15725
15752
  }
15726
15753
  }, features !== null && features !== void 0 ? features : {});
15727
15754
  // TODO [LMNT-910] - labelId should be a required prop
@@ -15757,7 +15784,7 @@ const Component = ({
15757
15784
  onViewShipment: onViewShipment,
15758
15785
  shipment: shipment.data,
15759
15786
  voidRequest: voidLabel.data
15760
- }), ((_c = (_b = features === null || features === void 0 ? void 0 : features.global) === null || _b === void 0 ? void 0 : _b.presentation) === null || _c === void 0 ? void 0 : _c.poweredByShipEngine) && jsxs(Fragment, {
15787
+ }), ((_b = features === null || features === void 0 ? void 0 : features.presentation) === null || _b === void 0 ? void 0 : _b.poweredByShipEngine) && jsxs(Fragment, {
15761
15788
  children: [jsx(Spacer, {}), jsx(PoweredByShipEngine, {})]
15762
15789
  })]
15763
15790
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/elements",
3
- "version": "0.26.7",
3
+ "version": "0.26.15",
4
4
  "typedoc": {
5
5
  "entryPoint": "./src/index.ts",
6
6
  "readmeFile": "../../README.md",
@@ -1,4 +1,5 @@
1
1
  export type CarrierBalanceProps = {
2
- carrierId: string;
2
+ balance?: number;
3
+ carrierId?: string;
3
4
  };
4
- export declare const CarrierBalance: ({ carrierId }: CarrierBalanceProps) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ export declare const CarrierBalance: ({ balance, carrierId }: CarrierBalanceProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { Control } from "react-hook-form";
2
2
  export type FundAndPurchaseProps = {
3
+ balance?: number;
3
4
  carrierId?: string;
4
5
  className?: string;
5
6
  control: Control<any, any>;
@@ -15,4 +16,4 @@ export type FundAndPurchaseProps = {
15
16
  * has the necessary funds available and can add them if not. It allows a single button
16
17
  * to submit the funding form followed by the purchase form.
17
18
  */
18
- export declare const FundAndPurchase: ({ carrierId, className, control, disabled, isFundingEnabled, isFundingRequired, onSave, purchaseAmount, onPurchase, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
19
+ export declare const FundAndPurchase: ({ balance: uspsBalance, carrierId, className, control, disabled, isFundingEnabled, isFundingRequired, onSave, purchaseAmount, onPurchase, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,10 +1,16 @@
1
1
  import { CarrierConnection, CodedError } from "@shipengine/alchemy";
2
2
  import { ConnectedCarrierMetadata } from "../../../elements/list-carriers/hooks/use-list-connected-carriers";
3
+ export type ListCarriersFeatures = {
4
+ carriers?: {
5
+ enabledCarriers: string[];
6
+ };
7
+ };
3
8
  export type ListCarriersProps = {
4
9
  carriers?: ConnectedCarrierMetadata[];
5
10
  errors?: CodedError[] | null;
11
+ features?: ListCarriersFeatures;
6
12
  isLoading?: boolean;
7
13
  onRegisterCarrier: (payload: CarrierConnection) => Promise<void>;
8
14
  registerCarrierErrors?: CodedError[] | null;
9
15
  };
10
- export declare const ListCarriers: ({ carriers, errors, isLoading, onRegisterCarrier, registerCarrierErrors, }: ListCarriersProps) => import("@emotion/react/jsx-runtime").JSX.Element;
16
+ export declare const ListCarriers: ({ carriers, errors, features, isLoading, onRegisterCarrier, registerCarrierErrors, }: ListCarriersProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -13,10 +13,11 @@ export type ValidateBilling = {
13
13
  };
14
14
  export type ValidateAddress = ValidateWarehouse | ValidateBilling;
15
15
  export type OnboardingFeatures = {
16
- global?: {
17
- presentation?: {
18
- poweredByShipEngine?: boolean;
19
- };
16
+ carriers?: {
17
+ enabledCarriers: string[];
18
+ };
19
+ presentation?: {
20
+ poweredByShipEngine?: boolean;
20
21
  };
21
22
  };
22
23
  export type OnboardingProps = {
@@ -6,7 +6,7 @@ export type RateFormProps = {
6
6
  displayableErrors?: string[];
7
7
  displayableLabelErrors?: string[];
8
8
  errors?: SE.CodedError[];
9
- features?: Pick<ConfigureShipmentFeatures, "global" | "rateForm">;
9
+ features?: ConfigureShipmentFeatures;
10
10
  isLoading?: boolean;
11
11
  labelErrors?: SE.CodedError[];
12
12
  labels?: SE.Label[];
@@ -1,10 +1,8 @@
1
1
  import { SE } from "@shipengine/alchemy";
2
2
  export declare const schedulePickupForCarrier: (carrierCode?: string, plaftformSchedulePickupUrl?: string) => string | undefined;
3
3
  export type ShipmentFeatures = {
4
- global?: {
5
- presentation?: {
6
- poweredByShipEngine?: boolean;
7
- };
4
+ presentation?: {
5
+ poweredByShipEngine?: boolean;
8
6
  };
9
7
  shipment?: {
10
8
  schedulePickup?: boolean;
@@ -12,10 +12,8 @@ export type RateFormFeatures = {
12
12
  };
13
13
  export type ConfigureShipmentFeatures = {
14
14
  compatibleCountryCodes?: UseShipmentFormProps["compatibleCountryCodes"];
15
- global?: {
16
- presentation?: {
17
- poweredByShipEngine?: boolean;
18
- };
15
+ presentation?: {
16
+ poweredByShipEngine?: boolean;
19
17
  };
20
18
  rateForm?: RateFormFeatures;
21
19
  shipmentForm?: Templates.ShipmentFormFeatures;
@@ -1,6 +1,10 @@
1
1
  /// <reference types="react" />
2
- export declare const Component: () => import("@emotion/react/jsx-runtime").JSX.Element;
3
- export declare const Element: ({ resources, ...props }: object & {
2
+ import { OnboardingProps } from "../../components/templates";
3
+ export type ComponentProps = {
4
+ features?: OnboardingProps["features"];
5
+ };
6
+ export declare const Component: ({ features }: ComponentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
7
+ export declare const Element: ({ resources, ...props }: ComponentProps & {
4
8
  resources?: {
5
9
  en: {
6
10
  "wallet-history": {
@@ -2,10 +2,8 @@
2
2
  import { SE } from "@shipengine/alchemy";
3
3
  export type ComponentProps = {
4
4
  features?: {
5
- global?: {
6
- presentation?: {
7
- poweredByShipEngine?: boolean;
8
- };
5
+ presentation?: {
6
+ poweredByShipEngine?: boolean;
9
7
  };
10
8
  };
11
9
  labelId?: string;