@shipengine/elements 0.37.2 → 0.37.4

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
@@ -2648,6 +2648,15 @@ const featureFlags = {
2648
2648
  * Elements.
2649
2649
  */
2650
2650
  compatibleCountryCodes: ["AU", "CA", "FR", "DE", "GB", "IL", "IT", "NO", "ES", "SE", "US"],
2651
+ /**
2652
+ * `configureShipment` is a group of flags related to the useConfigureShipment functionality
2653
+ */
2654
+ configureShipment: {
2655
+ /**
2656
+ * `enableErrorWhenShipmentCancelled` when enabled will modify the default behavior of creating a new shipment for a salesorder to throwing an error
2657
+ */
2658
+ enableErrorWhenShipmentCancelled: false
2659
+ },
2651
2660
  /**
2652
2661
  * @internal
2653
2662
  *
@@ -3960,11 +3969,29 @@ const getIsCustomsRequiredForShipment = ({
3960
3969
  /**
3961
3970
  * @internal
3962
3971
  *
3972
+ * @deprecated please use getShipmentByStatus instead
3963
3973
  * # Shipment Utilities - getPendingShipment
3964
3974
  *
3965
3975
  * @category Utilities
3966
3976
  */
3967
3977
  const getPendingShipment = shipments => shipments === null || shipments === void 0 ? void 0 : shipments.filter(s => s.shipmentStatus === "pending").sort(sortByCreationDate)[0];
3978
+ /**
3979
+ *
3980
+ * @deprecated please use getShipmentByStatus instead
3981
+ * @internal
3982
+ * @param shipments
3983
+ * @returns the latest created shipment whose status is `cancelled`
3984
+ */
3985
+ const getCancelledShipment = shipments => shipments === null || shipments === void 0 ? void 0 : shipments.filter(shipment => shipment.shipmentStatus === "cancelled").sort(sortByCreationDate)[0];
3986
+ /**
3987
+ *
3988
+ * @param status string containing one of the following values - "pending", "processing", "label_purchased", "cancelled"
3989
+ * @param shipments optional list of shipments to filter from
3990
+ * @returns latest created shipment whose shipmentStatus matches the param status
3991
+ */
3992
+ const getShipmentByStatus = (status, shipments) => shipments === null || shipments === void 0 ? void 0 : shipments.filter(({
3993
+ shipmentStatus
3994
+ }) => shipmentStatus === status).sort(sortByCreationDate)[0];
3968
3995
 
3969
3996
  var uncurryThis$6 = functionUncurryThis;
3970
3997
 
@@ -4509,8 +4536,7 @@ const useShipmentMetadata = shipment => {
4509
4536
  };
4510
4537
 
4511
4538
  let _$2 = t => t,
4512
- _t$2,
4513
- _t2$2;
4539
+ _t$2;
4514
4540
  const findGenericPackageFromCarriers = carriers => {
4515
4541
  const carrier = carriers.find(c => c.packages.some(p => p.packageCode === "package"));
4516
4542
  return carrier === null || carrier === void 0 ? void 0 : carrier.packages.find(p => p.packageCode === "package");
@@ -4537,17 +4563,14 @@ const usePackageOptions = (carriers, customPackageTypes, shipment) => {
4537
4563
  [c.carrierCode]: partialResults[c.carrierCode] === undefined
4538
4564
  }));
4539
4565
  const genericPackage = findGenericPackageFromCarriers(carriers);
4540
- const packageOptions = [...(genericPackage ? [{
4541
- label: t(_t$2 || (_t$2 = _$2`packageCategories.browseRates`)),
4542
- options: [{
4566
+ const customPackageOptions = [...(genericPackage || (customPackageTypes === null || customPackageTypes === void 0 ? void 0 : customPackageTypes.length) ? [{
4567
+ label: t(_t$2 || (_t$2 = _$2`packageCategories.customPackages`)),
4568
+ options: [...(genericPackage ? [{
4543
4569
  label: t("packageCodes.package"),
4544
4570
  value: {
4545
4571
  code: "package"
4546
4572
  }
4547
- }]
4548
- }] : []), ...((customPackageTypes === null || customPackageTypes === void 0 ? void 0 : customPackageTypes.length) ? [{
4549
- label: t(_t2$2 || (_t2$2 = _$2`packageCategories.myCustomPackages`)),
4550
- options: customPackageTypes.sort((a, b) => a.name.localeCompare(b.name)).map(({
4573
+ }] : []), ...((customPackageTypes === null || customPackageTypes === void 0 ? void 0 : customPackageTypes.length) ? customPackageTypes.sort((a, b) => a.name.localeCompare(b.name)).map(({
4551
4574
  dimensions,
4552
4575
  name,
4553
4576
  packageId
@@ -4558,7 +4581,7 @@ const usePackageOptions = (carriers, customPackageTypes, shipment) => {
4558
4581
  code: packageId
4559
4582
  }
4560
4583
  };
4561
- })
4584
+ }) : [])]
4562
4585
  }] : [])];
4563
4586
  return carriers.reduce((options, carrier) => {
4564
4587
  if (carrier.packages.length === 0) return options;
@@ -4579,7 +4602,7 @@ const usePackageOptions = (carriers, customPackageTypes, shipment) => {
4579
4602
  })),
4580
4603
  value: carrier.carrierId
4581
4604
  }];
4582
- }, packageOptions);
4605
+ }, customPackageOptions);
4583
4606
  }, [carriers, customPackageTypes, isPoBox, isUnsupportedUpsCountry, t]);
4584
4607
  };
4585
4608
 
@@ -14884,15 +14907,29 @@ const SuspendSalesOrder = ({
14884
14907
  };
14885
14908
 
14886
14909
  const styles$2 = createStyles({
14910
+ itemDescription: theme => ({
14911
+ display: "flex",
14912
+ flexDirection: "column",
14913
+ padding: `${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0)}px ${theme.spacing(0)}px`
14914
+ }),
14887
14915
  itemDetail: theme => ({
14888
- padding: `${theme.spacing(0)}px ${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0)}px`
14916
+ padding: `${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0.5)}px ${theme.spacing(0)}px`,
14917
+ verticalAlign: "top"
14889
14918
  }),
14890
14919
  itemName: theme => ({
14891
- padding: `${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0.5)}px ${theme.spacing(0)}px`
14920
+ // Set item name to max 3 lines and truncate with ellipsis
14921
+ "-webkit-box-orient": "vertical",
14922
+ "-webkit-line-clamp": "3",
14923
+ display: "-webkit-box",
14924
+ lineHeight: `${theme.spacing(2.5)}px`,
14925
+ maxHeight: `${theme.spacing(7.5)}px`,
14926
+ overflow: "hidden",
14927
+ textOverflow: "ellipsis",
14928
+ whiteSpace: "normal"
14892
14929
  }),
14893
14930
  numericCell: () => ({
14894
14931
  textAlign: "right",
14895
- width: "100px"
14932
+ width: "80px"
14896
14933
  }),
14897
14934
  tableWrapper: theme => ({
14898
14935
  "&& > div": {
@@ -14951,23 +14988,18 @@ const ItemsBreakdown = ({
14951
14988
  quantity,
14952
14989
  value,
14953
14990
  totalValue
14954
- }, index) => jsxRuntime.jsxs(React.Fragment, {
14955
- children: [jsxRuntime.jsx(giger.TableBaseRow, {
14956
- children: jsxRuntime.jsx(giger.TableBodyCell, Object.assign({
14957
- colSpan: 4,
14958
- css: styles$2.itemName
14991
+ }, index) => jsxRuntime.jsx(React.Fragment, {
14992
+ children: jsxRuntime.jsxs(giger.TableBaseRow, {
14993
+ children: [jsxRuntime.jsxs(giger.TableBodyCell, Object.assign({
14994
+ css: styles$2.itemDescription
14959
14995
  }, {
14960
- children: jsxRuntime.jsx(giger.Typography, {
14996
+ children: [jsxRuntime.jsx(giger.Typography, Object.assign({
14997
+ css: styles$2.itemName
14998
+ }, {
14961
14999
  children: name
14962
- })
14963
- }))
14964
- }), jsxRuntime.jsxs(giger.TableBaseRow, {
14965
- children: [jsxRuntime.jsx(giger.TableBodyCell, Object.assign({
14966
- css: styles$2.itemDetail
14967
- }, {
14968
- children: jsxRuntime.jsx(giger.Typography, {
15000
+ })), jsxRuntime.jsx(giger.Typography, {
14969
15001
  children: detail
14970
- })
15002
+ })]
14971
15003
  })), jsxRuntime.jsx(giger.TableBodyCell, Object.assign({
14972
15004
  css: [styles$2.numericCell, styles$2.itemDetail]
14973
15005
  }, {
@@ -14981,7 +15013,7 @@ const ItemsBreakdown = ({
14981
15013
  }, {
14982
15014
  children: totalValue && formatMoney(totalValue)
14983
15015
  }))]
14984
- })]
15016
+ })
14985
15017
  }, index))
14986
15018
  })
14987
15019
  }))
@@ -15978,6 +16010,7 @@ const ShipmentForm = ({
15978
16010
  }, {
15979
16011
  children: presetCategory.options.map(preset => jsxRuntime.jsx(giger.Option, Object.assign({
15980
16012
  onClick: () => {
16013
+ onDirty(); // bypass rate cache
15981
16014
  handleApplyPreset(preset.value);
15982
16015
  },
15983
16016
  selected: ___default["default"].isEqual(selectedPreset, preset.value),
@@ -16862,6 +16895,7 @@ var common = {
16862
16895
  invalidNameOrCompany: "Recipient name and company name (if provided) must have two characters in first and last name.",
16863
16896
  parsingFailure: "Parsing failed. Please check address and try again.",
16864
16897
  incompleteLabelPurchaseRequirements: "Please add your {{requirements}} to continue purchasing a label.",
16898
+ shipmentCancelled: "This shipment is Cancelled in ShipStation. Log into ShipStation to restore the order to Awaiting Shipment status.",
16865
16899
  unableToLoad: {
16866
16900
  accountSettings: "Unable to load account settings",
16867
16901
  autoFundingSettings: "Unable to load auto funding settings",
@@ -16882,6 +16916,7 @@ var common = {
16882
16916
  purchase: "Purchase error",
16883
16917
  rateInvalid: "Invalid rate configuration",
16884
16918
  security: "Security error",
16919
+ shipmentStatus: "Shipment status error",
16885
16920
  system: "System error",
16886
16921
  unknown: "Unknown error",
16887
16922
  validation: "Unable to validate address"
@@ -16920,8 +16955,7 @@ var common = {
16920
16955
  december: "December"
16921
16956
  },
16922
16957
  packageCategories: {
16923
- browseRates: "Browse Rates",
16924
- myCustomPackages: "My Custom Packages"
16958
+ customPackages: "Custom Packages"
16925
16959
  },
16926
16960
  packageCodes: {
16927
16961
  "package": "Custom"
@@ -18400,7 +18434,9 @@ const useShipmentForm = ({
18400
18434
  };
18401
18435
 
18402
18436
  const ConfigureShipment = _a => {
18437
+ var _b;
18403
18438
  var {
18439
+ errors,
18404
18440
  features,
18405
18441
  getPreferredRates,
18406
18442
  onAddressValidation,
@@ -18418,12 +18454,13 @@ const ConfigureShipment = _a => {
18418
18454
  shipment,
18419
18455
  onBeforeRateSaved
18420
18456
  } = _a,
18421
- props = __rest(_a, ["features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18457
+ props = __rest(_a, ["errors", "features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18422
18458
  const hydrateRef = React.useRef();
18459
+ reactI18next.useTranslation();
18423
18460
  const {
18424
18461
  isInternational
18425
18462
  } = useShipmentMetadata(shipment);
18426
- const _b = useRatesForm({
18463
+ const _c = useRatesForm({
18427
18464
  getPreferredRates,
18428
18465
  onBeforeLabelCreate,
18429
18466
  onBeforeRateSaved,
@@ -18444,17 +18481,17 @@ const ConfigureShipment = _a => {
18444
18481
  resetRates,
18445
18482
  resetLabel,
18446
18483
  preferredRates
18447
- } = _b,
18448
- rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18449
- const _c = useShipmentForm({
18484
+ } = _c,
18485
+ rateFormProps = __rest(_c, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18486
+ const _d = useShipmentForm({
18450
18487
  compatibleCountryCodes: features === null || features === void 0 ? void 0 : features.compatibleCountryCodes,
18451
18488
  onAddressValidation,
18452
18489
  onApplyPreset: React.useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
18453
- var _d;
18490
+ var _e;
18454
18491
  if (shipment.packages[0].weight.value) {
18455
18492
  yield requestRates(shipment, isInternational);
18456
18493
  }
18457
- (_d = hydrateRef.current) === null || _d === void 0 ? void 0 : _d.call(hydrateRef, shipment);
18494
+ (_e = hydrateRef.current) === null || _e === void 0 ? void 0 : _e.call(hydrateRef, shipment);
18458
18495
  }), [requestRates, isInternational]),
18459
18496
  onChangeAddress,
18460
18497
  onShipmentUpdated,
@@ -18467,8 +18504,8 @@ const ConfigureShipment = _a => {
18467
18504
  {
18468
18505
  charsetWarning,
18469
18506
  resetSalesOrderShipment
18470
- } = _c,
18471
- shipmentFormProps = __rest(_c, ["charsetWarning", "resetSalesOrderShipment"]);
18507
+ } = _d,
18508
+ shipmentFormProps = __rest(_d, ["charsetWarning", "resetSalesOrderShipment"]);
18472
18509
  const handleOnDirty = React.useCallback(() => {
18473
18510
  resetRates();
18474
18511
  resetLabel();
@@ -18488,6 +18525,9 @@ const ConfigureShipment = _a => {
18488
18525
  return self.indexOf(item) === pos;
18489
18526
  });
18490
18527
  }, [preferredRates, preferredServiceCodes]);
18528
+ if (((_b = features === null || features === void 0 ? void 0 : features.configureShipment) === null || _b === void 0 ? void 0 : _b.enableErrorWhenShipmentCancelled) && (errors === null || errors === void 0 ? void 0 : errors.filter(e => e.message === "shipment_cancelled"))) {
18529
+ throw new Error("errorMessages.shipmentCancelled");
18530
+ }
18491
18531
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
18492
18532
  children: [jsxRuntime.jsx(ShipmentForm, Object.assign({}, shipmentFormProps, props, {
18493
18533
  charsetWarning: charsetWarning,
@@ -18506,6 +18546,7 @@ const ConfigureShipment = _a => {
18506
18546
  };
18507
18547
 
18508
18548
  const usePendingShipment = ({
18549
+ breakOnCancelledShipment: _breakOnCancelledShipment = false,
18509
18550
  onLoad,
18510
18551
  salesOrder,
18511
18552
  warehouseId
@@ -18529,17 +18570,18 @@ const usePendingShipment = ({
18529
18570
  isLoading: isShipmentCreating,
18530
18571
  mutateAsync: createShipment
18531
18572
  } = alchemy.useCreateSalesOrderShipment();
18532
- const pendingShipment = getPendingShipment(shipments);
18573
+ const pendingShipment = getShipmentByStatus("pending", shipments);
18574
+ const cancelledShipment = getShipmentByStatus("cancelled", shipments);
18533
18575
  const defaultWarehouse = (_a = warehouses === null || warehouses === void 0 ? void 0 : warehouses.find(w => w.warehouseId === warehouseId)) !== null && _a !== void 0 ? _a : warehouses === null || warehouses === void 0 ? void 0 : warehouses[0];
18534
18576
  // On page load, check for a shipment and either call the onLoad callback or create a new shipment
18535
18577
  React.useEffect(() => {
18536
18578
  if (salesOrder && (shipments === null || shipments === void 0 ? void 0 : shipments.length) && shipments.every(s => s.shipmentStatus === "label_purchased")) {
18537
- onLoad === null || onLoad === void 0 ? void 0 : onLoad(salesOrder, shipments, pendingShipment);
18579
+ void (onLoad === null || onLoad === void 0 ? void 0 : onLoad(salesOrder, shipments, pendingShipment));
18538
18580
  return;
18539
18581
  }
18540
- if (!salesOrder || !defaultWarehouse || !shipments || pendingShipment) return;
18582
+ if (!salesOrder || !defaultWarehouse || !shipments || _breakOnCancelledShipment && cancelledShipment || pendingShipment) return;
18541
18583
  if (isListShipmentsLoading || isListShipmentsValidating || isShipmentCreating) return;
18542
- createShipment(Object.assign(Object.assign({
18584
+ void createShipment(Object.assign(Object.assign({
18543
18585
  salesOrderId: salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.salesOrderId,
18544
18586
  // /v-beta/shipments/sales_order/:salesOrderId requires at minimum
18545
18587
  // a (warehouseId or shipFrom)
@@ -18555,14 +18597,18 @@ const usePendingShipment = ({
18555
18597
  }
18556
18598
  }]
18557
18599
  })).then(shipment => shipment && reloadShipments());
18558
- }, [createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId]);
18600
+ }, [cancelledShipment, createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId, _breakOnCancelledShipment]);
18559
18601
  const reloadPendingShipment = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18560
18602
  const {
18561
18603
  data: shipments
18562
18604
  } = yield reloadShipments();
18563
- return getPendingShipment(shipments);
18605
+ return getShipmentByStatus("pending", shipments);
18564
18606
  }), [reloadShipments]);
18565
- const errors = [...(listWarehouseErrors !== null && listWarehouseErrors !== void 0 ? listWarehouseErrors : []), ...(createShipmentErrors !== null && createShipmentErrors !== void 0 ? createShipmentErrors : []), ...(listShipmentsErrors !== null && listShipmentsErrors !== void 0 ? listShipmentsErrors : [])];
18607
+ const errors = [...(listWarehouseErrors !== null && listWarehouseErrors !== void 0 ? listWarehouseErrors : []), ...(createShipmentErrors !== null && createShipmentErrors !== void 0 ? createShipmentErrors : []), ...(listShipmentsErrors !== null && listShipmentsErrors !== void 0 ? listShipmentsErrors : []), ...(_breakOnCancelledShipment && cancelledShipment ? [new alchemy.CodedError("shipment_cancelled", {
18608
+ errorCode: "invalid_status",
18609
+ errorSource: "elements",
18610
+ errorType: "business_rules"
18611
+ })] : [])];
18566
18612
  return {
18567
18613
  isPendingShipmentLoading: !pendingShipment && errors.length === 0,
18568
18614
  pendingShipment,
@@ -18573,6 +18619,7 @@ const usePendingShipment = ({
18573
18619
 
18574
18620
  const useConfigureShipment = ({
18575
18621
  onLoad,
18622
+ errorWhenShipmentCancelled: _errorWhenShipmentCancelled = false,
18576
18623
  onShipmentUpdated,
18577
18624
  salesOrder,
18578
18625
  warehouseId,
@@ -18585,6 +18632,7 @@ const useConfigureShipment = ({
18585
18632
  pendingShipmentErrors,
18586
18633
  reloadPendingShipment
18587
18634
  } = usePendingShipment({
18635
+ breakOnCancelledShipment: _errorWhenShipmentCancelled,
18588
18636
  onLoad,
18589
18637
  salesOrder,
18590
18638
  warehouseId
@@ -18661,6 +18709,7 @@ const useImportSalesOrder = ({
18661
18709
  };
18662
18710
 
18663
18711
  const PurchaseLabelBySalesOrder = _a => {
18712
+ var _b;
18664
18713
  var {
18665
18714
  features,
18666
18715
  externalOrderId,
@@ -18673,7 +18722,7 @@ const PurchaseLabelBySalesOrder = _a => {
18673
18722
  printLabelLayout
18674
18723
  } = _a,
18675
18724
  props = __rest(_a, ["features", "externalOrderId", "externalOrderNumber", "onLoad", "onShipmentUpdated", "orderSourceCode", "salesOrderId", "warehouseId", "printLabelLayout"]);
18676
- const _b = useImportSalesOrder({
18725
+ const _c = useImportSalesOrder({
18677
18726
  externalOrderId,
18678
18727
  externalOrderNumber,
18679
18728
  orderSourceCode,
@@ -18682,22 +18731,28 @@ const PurchaseLabelBySalesOrder = _a => {
18682
18731
  {
18683
18732
  salesOrder,
18684
18733
  isLoading: salesOrderLoading
18685
- } = _b,
18686
- salesOrderProps = __rest(_b, ["salesOrder", "isLoading"]);
18734
+ } = _c,
18735
+ salesOrderProps = __rest(_c, ["salesOrder", "isLoading"]);
18687
18736
  const configureShipmentProps = useConfigureShipment({
18737
+ errorWhenShipmentCancelled: (_b = features === null || features === void 0 ? void 0 : features.configureShipment) === null || _b === void 0 ? void 0 : _b.enableErrorWhenShipmentCancelled,
18688
18738
  onLoad,
18689
18739
  onShipmentUpdated,
18690
18740
  printLabelLayout,
18691
18741
  salesOrder,
18692
18742
  warehouseId
18693
18743
  });
18744
+ const {
18745
+ data: insuranceAccount,
18746
+ isLoading: insuranceIsLoading
18747
+ } = alchemy.useGetInsuranceAccount("shipsurance");
18694
18748
  return jsxRuntime.jsx(SuspendSalesOrder, Object.assign({
18695
18749
  salesOrder: salesOrder
18696
18750
  }, salesOrderProps, {
18697
- isLoading: salesOrderLoading || configureShipmentProps.isLoading
18751
+ isLoading: salesOrderLoading || configureShipmentProps.isLoading || insuranceIsLoading
18698
18752
  }, {
18699
18753
  children: salesOrder && jsxRuntime.jsx(ConfigureShipment, Object.assign({
18700
18754
  features: features,
18755
+ insuranceAccount: insuranceAccount,
18701
18756
  salesOrder: salesOrder
18702
18757
  }, configureShipmentProps, props))
18703
18758
  }));
@@ -18766,11 +18821,16 @@ const PurchaseLabelByShipment = _a => {
18766
18821
  void shipmentProps.refetchShipment();
18767
18822
  onShipmentUpdated === null || onShipmentUpdated === void 0 ? void 0 : onShipmentUpdated(shipment);
18768
18823
  };
18824
+ const {
18825
+ data: insuranceAccount,
18826
+ isLoading: insuranceIsLoading
18827
+ } = alchemy.useGetInsuranceAccount("shipsurance");
18769
18828
  return jsxRuntime.jsx(SuspendShipment, Object.assign({
18770
18829
  shipment: shipment
18771
18830
  }, shipmentProps, {
18772
18831
  children: shipment && jsxRuntime.jsx(ConfigureShipment, Object.assign({
18773
18832
  errors: shipmentProps.errors,
18833
+ insuranceAccount: insuranceAccount,
18774
18834
  isLoading: shipmentProps.isLoading,
18775
18835
  onShipmentUpdated: handleShipmentUpdated,
18776
18836
  shipment: shipment
@@ -18825,7 +18885,9 @@ const Component$2 = _a => {
18825
18885
  });
18826
18886
  if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
18827
18887
  if ("salesOrderId" in props || "orderSourceCode" in props) {
18828
- return jsxRuntime.jsx(PurchaseLabelBySalesOrder, Object.assign({}, props));
18888
+ return jsxRuntime.jsx(PurchaseLabelBySalesOrder, Object.assign({
18889
+ features: features
18890
+ }, props));
18829
18891
  } else {
18830
18892
  return jsxRuntime.jsx(PurchaseLabelByShipment, Object.assign({}, props));
18831
18893
  }
@@ -19446,6 +19508,7 @@ exports.formatExpiration = formatExpiration;
19446
19508
  exports.formatFractionalWeight = formatFractionalWeight;
19447
19509
  exports.formatMoney = formatMoney;
19448
19510
  exports.getAddFundsSchema = getAddFundsSchema;
19511
+ exports.getCancelledShipment = getCancelledShipment;
19449
19512
  exports.getCarrierIdByCarrierCode = getCarrierIdByCarrierCode;
19450
19513
  exports.getCustomsFromSalesOrder = getCustomsFromSalesOrder;
19451
19514
  exports.getExpirationYears = getExpirationYears;
@@ -19458,6 +19521,7 @@ exports.getRateRequiresAcknowledgement = getRateRequiresAcknowledgement;
19458
19521
  exports.getRelativeDates = getRelativeDates;
19459
19522
  exports.getRequestedServices = getRequestedServices;
19460
19523
  exports.getSalesOrderItemsFromSalesOrderOrShipment = getSalesOrderItemsFromSalesOrderOrShipment;
19524
+ exports.getShipmentByStatus = getShipmentByStatus;
19461
19525
  exports.getTotalRateAmount = getTotalRateAmount;
19462
19526
  exports.isDecimalWeight = isDecimalWeight;
19463
19527
  exports.isDomesticAddress = isDomesticAddress;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
2
2
  import { useTranslation, Trans } from 'react-i18next';
3
3
  import { InlineNotification, NotificationType, Typography, Link, ButtonSize, Spinner, Icon, IconSize, Divider, Skeleton, SkeletonAnimation, SkeletonVariant, Grid, GridChild, Pagination, SkeletonBackgroundColor, RadioGroup, Radio, SpinnerSize, FormField, FieldMessageType, Checkbox, Input, SelectAutocomplete, Select as Select$1, OptionGroup, Option, Button, Switch as Switch$1, Textarea, ChipList, Chip, ButtonVariant, ButtonColor, Tag, TagColor, Stepper, Step, IconTooltip, Table, TableBody, TableBaseRow, TableBodyCell, TableHeader, TableHeaderCell, Popover, DropdownOptionList, DatePicker as DatePicker$1, BottomSheet } from '@packlink/giger';
4
- import alchemy, { SE, logger, useValidateAddresses, useListCarriers, useConnectCarrier, useListWarehouses, useUpdateWarehouse, useCreateWarehouse, useDeleteWarehouse, useGetWalletHistory, useGetAccountSettings, useUpdateAccountSettings, AlchemyContext, useAddFunds, useGetCarrierById, useUpdateAutoFunding, useGetAutoFundingConfiguration, Currency, useUpdateFundingSource, useListFundingSources, useCreateFundingSource, useRegisterCarrier, useUpdateSalesOrderShipment, useParseAddress, useListCustomPackageTypes, useCalculateRates, useGetShipmentRates, useListLabels, useCreateLabel, useListSalesOrderShipments, useCreateSalesOrderShipment, useListSalesOrders, useGetSalesOrder, useListOrderSources, useRefreshOrderSource, useCreateShipment, useGetShipment, useGetSalesOrderShipment, useGetLabel, useVoidLabel } from '@shipengine/alchemy';
4
+ import alchemy, { SE, logger, useValidateAddresses, useListCarriers, useConnectCarrier, useListWarehouses, useUpdateWarehouse, useCreateWarehouse, useDeleteWarehouse, useGetWalletHistory, useGetAccountSettings, useUpdateAccountSettings, AlchemyContext, useAddFunds, useGetCarrierById, useUpdateAutoFunding, useGetAutoFundingConfiguration, Currency, useUpdateFundingSource, useListFundingSources, useCreateFundingSource, useRegisterCarrier, useUpdateSalesOrderShipment, useParseAddress, useListCustomPackageTypes, useCalculateRates, useGetShipmentRates, useListLabels, useCreateLabel, useListSalesOrderShipments, useCreateSalesOrderShipment, CodedError, useListSalesOrders, useGetSalesOrder, useListOrderSources, useRefreshOrderSource, useGetInsuranceAccount, useCreateShipment, useGetShipment, useGetSalesOrderShipment, useGetLabel, useVoidLabel } from '@shipengine/alchemy';
5
5
  import axios from 'axios';
6
6
  import _$3, { get as get$1, isEqual } from 'lodash';
7
7
  import { zodResolver } from '@hookform/resolvers/zod';
@@ -2616,6 +2616,15 @@ const featureFlags = {
2616
2616
  * Elements.
2617
2617
  */
2618
2618
  compatibleCountryCodes: ["AU", "CA", "FR", "DE", "GB", "IL", "IT", "NO", "ES", "SE", "US"],
2619
+ /**
2620
+ * `configureShipment` is a group of flags related to the useConfigureShipment functionality
2621
+ */
2622
+ configureShipment: {
2623
+ /**
2624
+ * `enableErrorWhenShipmentCancelled` when enabled will modify the default behavior of creating a new shipment for a salesorder to throwing an error
2625
+ */
2626
+ enableErrorWhenShipmentCancelled: false
2627
+ },
2619
2628
  /**
2620
2629
  * @internal
2621
2630
  *
@@ -3928,11 +3937,29 @@ const getIsCustomsRequiredForShipment = ({
3928
3937
  /**
3929
3938
  * @internal
3930
3939
  *
3940
+ * @deprecated please use getShipmentByStatus instead
3931
3941
  * # Shipment Utilities - getPendingShipment
3932
3942
  *
3933
3943
  * @category Utilities
3934
3944
  */
3935
3945
  const getPendingShipment = shipments => shipments === null || shipments === void 0 ? void 0 : shipments.filter(s => s.shipmentStatus === "pending").sort(sortByCreationDate)[0];
3946
+ /**
3947
+ *
3948
+ * @deprecated please use getShipmentByStatus instead
3949
+ * @internal
3950
+ * @param shipments
3951
+ * @returns the latest created shipment whose status is `cancelled`
3952
+ */
3953
+ const getCancelledShipment = shipments => shipments === null || shipments === void 0 ? void 0 : shipments.filter(shipment => shipment.shipmentStatus === "cancelled").sort(sortByCreationDate)[0];
3954
+ /**
3955
+ *
3956
+ * @param status string containing one of the following values - "pending", "processing", "label_purchased", "cancelled"
3957
+ * @param shipments optional list of shipments to filter from
3958
+ * @returns latest created shipment whose shipmentStatus matches the param status
3959
+ */
3960
+ const getShipmentByStatus = (status, shipments) => shipments === null || shipments === void 0 ? void 0 : shipments.filter(({
3961
+ shipmentStatus
3962
+ }) => shipmentStatus === status).sort(sortByCreationDate)[0];
3936
3963
 
3937
3964
  var uncurryThis$6 = functionUncurryThis;
3938
3965
 
@@ -4477,8 +4504,7 @@ const useShipmentMetadata = shipment => {
4477
4504
  };
4478
4505
 
4479
4506
  let _$2 = t => t,
4480
- _t$2,
4481
- _t2$2;
4507
+ _t$2;
4482
4508
  const findGenericPackageFromCarriers = carriers => {
4483
4509
  const carrier = carriers.find(c => c.packages.some(p => p.packageCode === "package"));
4484
4510
  return carrier === null || carrier === void 0 ? void 0 : carrier.packages.find(p => p.packageCode === "package");
@@ -4505,17 +4531,14 @@ const usePackageOptions = (carriers, customPackageTypes, shipment) => {
4505
4531
  [c.carrierCode]: partialResults[c.carrierCode] === undefined
4506
4532
  }));
4507
4533
  const genericPackage = findGenericPackageFromCarriers(carriers);
4508
- const packageOptions = [...(genericPackage ? [{
4509
- label: t(_t$2 || (_t$2 = _$2`packageCategories.browseRates`)),
4510
- options: [{
4534
+ const customPackageOptions = [...(genericPackage || (customPackageTypes === null || customPackageTypes === void 0 ? void 0 : customPackageTypes.length) ? [{
4535
+ label: t(_t$2 || (_t$2 = _$2`packageCategories.customPackages`)),
4536
+ options: [...(genericPackage ? [{
4511
4537
  label: t("packageCodes.package"),
4512
4538
  value: {
4513
4539
  code: "package"
4514
4540
  }
4515
- }]
4516
- }] : []), ...((customPackageTypes === null || customPackageTypes === void 0 ? void 0 : customPackageTypes.length) ? [{
4517
- label: t(_t2$2 || (_t2$2 = _$2`packageCategories.myCustomPackages`)),
4518
- options: customPackageTypes.sort((a, b) => a.name.localeCompare(b.name)).map(({
4541
+ }] : []), ...((customPackageTypes === null || customPackageTypes === void 0 ? void 0 : customPackageTypes.length) ? customPackageTypes.sort((a, b) => a.name.localeCompare(b.name)).map(({
4519
4542
  dimensions,
4520
4543
  name,
4521
4544
  packageId
@@ -4526,7 +4549,7 @@ const usePackageOptions = (carriers, customPackageTypes, shipment) => {
4526
4549
  code: packageId
4527
4550
  }
4528
4551
  };
4529
- })
4552
+ }) : [])]
4530
4553
  }] : [])];
4531
4554
  return carriers.reduce((options, carrier) => {
4532
4555
  if (carrier.packages.length === 0) return options;
@@ -4547,7 +4570,7 @@ const usePackageOptions = (carriers, customPackageTypes, shipment) => {
4547
4570
  })),
4548
4571
  value: carrier.carrierId
4549
4572
  }];
4550
- }, packageOptions);
4573
+ }, customPackageOptions);
4551
4574
  }, [carriers, customPackageTypes, isPoBox, isUnsupportedUpsCountry, t]);
4552
4575
  };
4553
4576
 
@@ -14852,15 +14875,29 @@ const SuspendSalesOrder = ({
14852
14875
  };
14853
14876
 
14854
14877
  const styles$2 = createStyles({
14878
+ itemDescription: theme => ({
14879
+ display: "flex",
14880
+ flexDirection: "column",
14881
+ padding: `${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0)}px ${theme.spacing(0)}px`
14882
+ }),
14855
14883
  itemDetail: theme => ({
14856
- padding: `${theme.spacing(0)}px ${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0)}px`
14884
+ padding: `${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0.5)}px ${theme.spacing(0)}px`,
14885
+ verticalAlign: "top"
14857
14886
  }),
14858
14887
  itemName: theme => ({
14859
- padding: `${theme.spacing(2)}px ${theme.spacing(2)}px ${theme.spacing(0.5)}px ${theme.spacing(0)}px`
14888
+ // Set item name to max 3 lines and truncate with ellipsis
14889
+ "-webkit-box-orient": "vertical",
14890
+ "-webkit-line-clamp": "3",
14891
+ display: "-webkit-box",
14892
+ lineHeight: `${theme.spacing(2.5)}px`,
14893
+ maxHeight: `${theme.spacing(7.5)}px`,
14894
+ overflow: "hidden",
14895
+ textOverflow: "ellipsis",
14896
+ whiteSpace: "normal"
14860
14897
  }),
14861
14898
  numericCell: () => ({
14862
14899
  textAlign: "right",
14863
- width: "100px"
14900
+ width: "80px"
14864
14901
  }),
14865
14902
  tableWrapper: theme => ({
14866
14903
  "&& > div": {
@@ -14919,23 +14956,18 @@ const ItemsBreakdown = ({
14919
14956
  quantity,
14920
14957
  value,
14921
14958
  totalValue
14922
- }, index) => jsxs(Fragment$1, {
14923
- children: [jsx(TableBaseRow, {
14924
- children: jsx(TableBodyCell, Object.assign({
14925
- colSpan: 4,
14926
- css: styles$2.itemName
14959
+ }, index) => jsx(Fragment$1, {
14960
+ children: jsxs(TableBaseRow, {
14961
+ children: [jsxs(TableBodyCell, Object.assign({
14962
+ css: styles$2.itemDescription
14927
14963
  }, {
14928
- children: jsx(Typography, {
14964
+ children: [jsx(Typography, Object.assign({
14965
+ css: styles$2.itemName
14966
+ }, {
14929
14967
  children: name
14930
- })
14931
- }))
14932
- }), jsxs(TableBaseRow, {
14933
- children: [jsx(TableBodyCell, Object.assign({
14934
- css: styles$2.itemDetail
14935
- }, {
14936
- children: jsx(Typography, {
14968
+ })), jsx(Typography, {
14937
14969
  children: detail
14938
- })
14970
+ })]
14939
14971
  })), jsx(TableBodyCell, Object.assign({
14940
14972
  css: [styles$2.numericCell, styles$2.itemDetail]
14941
14973
  }, {
@@ -14949,7 +14981,7 @@ const ItemsBreakdown = ({
14949
14981
  }, {
14950
14982
  children: totalValue && formatMoney(totalValue)
14951
14983
  }))]
14952
- })]
14984
+ })
14953
14985
  }, index))
14954
14986
  })
14955
14987
  }))
@@ -15946,6 +15978,7 @@ const ShipmentForm = ({
15946
15978
  }, {
15947
15979
  children: presetCategory.options.map(preset => jsx(Option, Object.assign({
15948
15980
  onClick: () => {
15981
+ onDirty(); // bypass rate cache
15949
15982
  handleApplyPreset(preset.value);
15950
15983
  },
15951
15984
  selected: _$3.isEqual(selectedPreset, preset.value),
@@ -16830,6 +16863,7 @@ var common = {
16830
16863
  invalidNameOrCompany: "Recipient name and company name (if provided) must have two characters in first and last name.",
16831
16864
  parsingFailure: "Parsing failed. Please check address and try again.",
16832
16865
  incompleteLabelPurchaseRequirements: "Please add your {{requirements}} to continue purchasing a label.",
16866
+ shipmentCancelled: "This shipment is Cancelled in ShipStation. Log into ShipStation to restore the order to Awaiting Shipment status.",
16833
16867
  unableToLoad: {
16834
16868
  accountSettings: "Unable to load account settings",
16835
16869
  autoFundingSettings: "Unable to load auto funding settings",
@@ -16850,6 +16884,7 @@ var common = {
16850
16884
  purchase: "Purchase error",
16851
16885
  rateInvalid: "Invalid rate configuration",
16852
16886
  security: "Security error",
16887
+ shipmentStatus: "Shipment status error",
16853
16888
  system: "System error",
16854
16889
  unknown: "Unknown error",
16855
16890
  validation: "Unable to validate address"
@@ -16888,8 +16923,7 @@ var common = {
16888
16923
  december: "December"
16889
16924
  },
16890
16925
  packageCategories: {
16891
- browseRates: "Browse Rates",
16892
- myCustomPackages: "My Custom Packages"
16926
+ customPackages: "Custom Packages"
16893
16927
  },
16894
16928
  packageCodes: {
16895
16929
  "package": "Custom"
@@ -18368,7 +18402,9 @@ const useShipmentForm = ({
18368
18402
  };
18369
18403
 
18370
18404
  const ConfigureShipment = _a => {
18405
+ var _b;
18371
18406
  var {
18407
+ errors,
18372
18408
  features,
18373
18409
  getPreferredRates,
18374
18410
  onAddressValidation,
@@ -18386,12 +18422,13 @@ const ConfigureShipment = _a => {
18386
18422
  shipment,
18387
18423
  onBeforeRateSaved
18388
18424
  } = _a,
18389
- props = __rest(_a, ["features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18425
+ props = __rest(_a, ["errors", "features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18390
18426
  const hydrateRef = useRef();
18427
+ useTranslation();
18391
18428
  const {
18392
18429
  isInternational
18393
18430
  } = useShipmentMetadata(shipment);
18394
- const _b = useRatesForm({
18431
+ const _c = useRatesForm({
18395
18432
  getPreferredRates,
18396
18433
  onBeforeLabelCreate,
18397
18434
  onBeforeRateSaved,
@@ -18412,17 +18449,17 @@ const ConfigureShipment = _a => {
18412
18449
  resetRates,
18413
18450
  resetLabel,
18414
18451
  preferredRates
18415
- } = _b,
18416
- rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18417
- const _c = useShipmentForm({
18452
+ } = _c,
18453
+ rateFormProps = __rest(_c, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18454
+ const _d = useShipmentForm({
18418
18455
  compatibleCountryCodes: features === null || features === void 0 ? void 0 : features.compatibleCountryCodes,
18419
18456
  onAddressValidation,
18420
18457
  onApplyPreset: useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
18421
- var _d;
18458
+ var _e;
18422
18459
  if (shipment.packages[0].weight.value) {
18423
18460
  yield requestRates(shipment, isInternational);
18424
18461
  }
18425
- (_d = hydrateRef.current) === null || _d === void 0 ? void 0 : _d.call(hydrateRef, shipment);
18462
+ (_e = hydrateRef.current) === null || _e === void 0 ? void 0 : _e.call(hydrateRef, shipment);
18426
18463
  }), [requestRates, isInternational]),
18427
18464
  onChangeAddress,
18428
18465
  onShipmentUpdated,
@@ -18435,8 +18472,8 @@ const ConfigureShipment = _a => {
18435
18472
  {
18436
18473
  charsetWarning,
18437
18474
  resetSalesOrderShipment
18438
- } = _c,
18439
- shipmentFormProps = __rest(_c, ["charsetWarning", "resetSalesOrderShipment"]);
18475
+ } = _d,
18476
+ shipmentFormProps = __rest(_d, ["charsetWarning", "resetSalesOrderShipment"]);
18440
18477
  const handleOnDirty = useCallback(() => {
18441
18478
  resetRates();
18442
18479
  resetLabel();
@@ -18456,6 +18493,9 @@ const ConfigureShipment = _a => {
18456
18493
  return self.indexOf(item) === pos;
18457
18494
  });
18458
18495
  }, [preferredRates, preferredServiceCodes]);
18496
+ if (((_b = features === null || features === void 0 ? void 0 : features.configureShipment) === null || _b === void 0 ? void 0 : _b.enableErrorWhenShipmentCancelled) && (errors === null || errors === void 0 ? void 0 : errors.filter(e => e.message === "shipment_cancelled"))) {
18497
+ throw new Error("errorMessages.shipmentCancelled");
18498
+ }
18459
18499
  return jsxs(Fragment, {
18460
18500
  children: [jsx(ShipmentForm, Object.assign({}, shipmentFormProps, props, {
18461
18501
  charsetWarning: charsetWarning,
@@ -18474,6 +18514,7 @@ const ConfigureShipment = _a => {
18474
18514
  };
18475
18515
 
18476
18516
  const usePendingShipment = ({
18517
+ breakOnCancelledShipment: _breakOnCancelledShipment = false,
18477
18518
  onLoad,
18478
18519
  salesOrder,
18479
18520
  warehouseId
@@ -18497,17 +18538,18 @@ const usePendingShipment = ({
18497
18538
  isLoading: isShipmentCreating,
18498
18539
  mutateAsync: createShipment
18499
18540
  } = useCreateSalesOrderShipment();
18500
- const pendingShipment = getPendingShipment(shipments);
18541
+ const pendingShipment = getShipmentByStatus("pending", shipments);
18542
+ const cancelledShipment = getShipmentByStatus("cancelled", shipments);
18501
18543
  const defaultWarehouse = (_a = warehouses === null || warehouses === void 0 ? void 0 : warehouses.find(w => w.warehouseId === warehouseId)) !== null && _a !== void 0 ? _a : warehouses === null || warehouses === void 0 ? void 0 : warehouses[0];
18502
18544
  // On page load, check for a shipment and either call the onLoad callback or create a new shipment
18503
18545
  useEffect(() => {
18504
18546
  if (salesOrder && (shipments === null || shipments === void 0 ? void 0 : shipments.length) && shipments.every(s => s.shipmentStatus === "label_purchased")) {
18505
- onLoad === null || onLoad === void 0 ? void 0 : onLoad(salesOrder, shipments, pendingShipment);
18547
+ void (onLoad === null || onLoad === void 0 ? void 0 : onLoad(salesOrder, shipments, pendingShipment));
18506
18548
  return;
18507
18549
  }
18508
- if (!salesOrder || !defaultWarehouse || !shipments || pendingShipment) return;
18550
+ if (!salesOrder || !defaultWarehouse || !shipments || _breakOnCancelledShipment && cancelledShipment || pendingShipment) return;
18509
18551
  if (isListShipmentsLoading || isListShipmentsValidating || isShipmentCreating) return;
18510
- createShipment(Object.assign(Object.assign({
18552
+ void createShipment(Object.assign(Object.assign({
18511
18553
  salesOrderId: salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.salesOrderId,
18512
18554
  // /v-beta/shipments/sales_order/:salesOrderId requires at minimum
18513
18555
  // a (warehouseId or shipFrom)
@@ -18523,14 +18565,18 @@ const usePendingShipment = ({
18523
18565
  }
18524
18566
  }]
18525
18567
  })).then(shipment => shipment && reloadShipments());
18526
- }, [createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId]);
18568
+ }, [cancelledShipment, createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId, _breakOnCancelledShipment]);
18527
18569
  const reloadPendingShipment = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18528
18570
  const {
18529
18571
  data: shipments
18530
18572
  } = yield reloadShipments();
18531
- return getPendingShipment(shipments);
18573
+ return getShipmentByStatus("pending", shipments);
18532
18574
  }), [reloadShipments]);
18533
- const errors = [...(listWarehouseErrors !== null && listWarehouseErrors !== void 0 ? listWarehouseErrors : []), ...(createShipmentErrors !== null && createShipmentErrors !== void 0 ? createShipmentErrors : []), ...(listShipmentsErrors !== null && listShipmentsErrors !== void 0 ? listShipmentsErrors : [])];
18575
+ const errors = [...(listWarehouseErrors !== null && listWarehouseErrors !== void 0 ? listWarehouseErrors : []), ...(createShipmentErrors !== null && createShipmentErrors !== void 0 ? createShipmentErrors : []), ...(listShipmentsErrors !== null && listShipmentsErrors !== void 0 ? listShipmentsErrors : []), ...(_breakOnCancelledShipment && cancelledShipment ? [new CodedError("shipment_cancelled", {
18576
+ errorCode: "invalid_status",
18577
+ errorSource: "elements",
18578
+ errorType: "business_rules"
18579
+ })] : [])];
18534
18580
  return {
18535
18581
  isPendingShipmentLoading: !pendingShipment && errors.length === 0,
18536
18582
  pendingShipment,
@@ -18541,6 +18587,7 @@ const usePendingShipment = ({
18541
18587
 
18542
18588
  const useConfigureShipment = ({
18543
18589
  onLoad,
18590
+ errorWhenShipmentCancelled: _errorWhenShipmentCancelled = false,
18544
18591
  onShipmentUpdated,
18545
18592
  salesOrder,
18546
18593
  warehouseId,
@@ -18553,6 +18600,7 @@ const useConfigureShipment = ({
18553
18600
  pendingShipmentErrors,
18554
18601
  reloadPendingShipment
18555
18602
  } = usePendingShipment({
18603
+ breakOnCancelledShipment: _errorWhenShipmentCancelled,
18556
18604
  onLoad,
18557
18605
  salesOrder,
18558
18606
  warehouseId
@@ -18629,6 +18677,7 @@ const useImportSalesOrder = ({
18629
18677
  };
18630
18678
 
18631
18679
  const PurchaseLabelBySalesOrder = _a => {
18680
+ var _b;
18632
18681
  var {
18633
18682
  features,
18634
18683
  externalOrderId,
@@ -18641,7 +18690,7 @@ const PurchaseLabelBySalesOrder = _a => {
18641
18690
  printLabelLayout
18642
18691
  } = _a,
18643
18692
  props = __rest(_a, ["features", "externalOrderId", "externalOrderNumber", "onLoad", "onShipmentUpdated", "orderSourceCode", "salesOrderId", "warehouseId", "printLabelLayout"]);
18644
- const _b = useImportSalesOrder({
18693
+ const _c = useImportSalesOrder({
18645
18694
  externalOrderId,
18646
18695
  externalOrderNumber,
18647
18696
  orderSourceCode,
@@ -18650,22 +18699,28 @@ const PurchaseLabelBySalesOrder = _a => {
18650
18699
  {
18651
18700
  salesOrder,
18652
18701
  isLoading: salesOrderLoading
18653
- } = _b,
18654
- salesOrderProps = __rest(_b, ["salesOrder", "isLoading"]);
18702
+ } = _c,
18703
+ salesOrderProps = __rest(_c, ["salesOrder", "isLoading"]);
18655
18704
  const configureShipmentProps = useConfigureShipment({
18705
+ errorWhenShipmentCancelled: (_b = features === null || features === void 0 ? void 0 : features.configureShipment) === null || _b === void 0 ? void 0 : _b.enableErrorWhenShipmentCancelled,
18656
18706
  onLoad,
18657
18707
  onShipmentUpdated,
18658
18708
  printLabelLayout,
18659
18709
  salesOrder,
18660
18710
  warehouseId
18661
18711
  });
18712
+ const {
18713
+ data: insuranceAccount,
18714
+ isLoading: insuranceIsLoading
18715
+ } = useGetInsuranceAccount("shipsurance");
18662
18716
  return jsx(SuspendSalesOrder, Object.assign({
18663
18717
  salesOrder: salesOrder
18664
18718
  }, salesOrderProps, {
18665
- isLoading: salesOrderLoading || configureShipmentProps.isLoading
18719
+ isLoading: salesOrderLoading || configureShipmentProps.isLoading || insuranceIsLoading
18666
18720
  }, {
18667
18721
  children: salesOrder && jsx(ConfigureShipment, Object.assign({
18668
18722
  features: features,
18723
+ insuranceAccount: insuranceAccount,
18669
18724
  salesOrder: salesOrder
18670
18725
  }, configureShipmentProps, props))
18671
18726
  }));
@@ -18734,11 +18789,16 @@ const PurchaseLabelByShipment = _a => {
18734
18789
  void shipmentProps.refetchShipment();
18735
18790
  onShipmentUpdated === null || onShipmentUpdated === void 0 ? void 0 : onShipmentUpdated(shipment);
18736
18791
  };
18792
+ const {
18793
+ data: insuranceAccount,
18794
+ isLoading: insuranceIsLoading
18795
+ } = useGetInsuranceAccount("shipsurance");
18737
18796
  return jsx(SuspendShipment, Object.assign({
18738
18797
  shipment: shipment
18739
18798
  }, shipmentProps, {
18740
18799
  children: shipment && jsx(ConfigureShipment, Object.assign({
18741
18800
  errors: shipmentProps.errors,
18801
+ insuranceAccount: insuranceAccount,
18742
18802
  isLoading: shipmentProps.isLoading,
18743
18803
  onShipmentUpdated: handleShipmentUpdated,
18744
18804
  shipment: shipment
@@ -18793,7 +18853,9 @@ const Component$2 = _a => {
18793
18853
  });
18794
18854
  if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
18795
18855
  if ("salesOrderId" in props || "orderSourceCode" in props) {
18796
- return jsx(PurchaseLabelBySalesOrder, Object.assign({}, props));
18856
+ return jsx(PurchaseLabelBySalesOrder, Object.assign({
18857
+ features: features
18858
+ }, props));
18797
18859
  } else {
18798
18860
  return jsx(PurchaseLabelByShipment, Object.assign({}, props));
18799
18861
  }
@@ -19345,4 +19407,4 @@ var labelWorkflow = /*#__PURE__*/Object.freeze({
19345
19407
  Element: Element
19346
19408
  });
19347
19409
 
19348
- 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, convertDecimalWeightToFractionalWeight, convertDimensions, convertFractionalWeightToDecimalWeight, convertPoundsAndOuncesToOunces, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, daysAfter, errorMap, euCountryCodes, extendZod, featureFlagComponentNameLookup, featureFlags, formLogger, formatCreditCardNumber, formatDate, formatDateDDMMYY, formatDimensions, formatExpiration, formatFractionalWeight, formatMoney, getAddFundsSchema, getCarrierIdByCarrierCode, getCustomsFromSalesOrder, getExpirationYears, getFeatures, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRelativeDates, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getTotalRateAmount, isDecimalWeight, isDomesticAddress, isEmptyAddress, isFlatRatePackageCode, isMetricWeightUnit, 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, useScrubErrors, useServiceCodeOptions, useShipmentMetadata, useShippingPresetsOptions, useStateCodeOptions, useToggle, useWarehouseOptions, validationResolver };
19410
+ 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, convertDecimalWeightToFractionalWeight, convertDimensions, convertFractionalWeightToDecimalWeight, convertPoundsAndOuncesToOunces, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, daysAfter, errorMap, euCountryCodes, extendZod, featureFlagComponentNameLookup, featureFlags, formLogger, formatCreditCardNumber, formatDate, formatDateDDMMYY, formatDimensions, formatExpiration, formatFractionalWeight, formatMoney, getAddFundsSchema, getCancelledShipment, getCarrierIdByCarrierCode, getCustomsFromSalesOrder, getExpirationYears, getFeatures, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRelativeDates, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getShipmentByStatus, getTotalRateAmount, isDecimalWeight, isDomesticAddress, isEmptyAddress, isFlatRatePackageCode, isMetricWeightUnit, 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, useScrubErrors, useServiceCodeOptions, useShipmentMetadata, useShippingPresetsOptions, useStateCodeOptions, useToggle, useWarehouseOptions, validationResolver };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/elements",
3
- "version": "0.37.2",
3
+ "version": "0.37.4",
4
4
  "peerDependencies": {
5
5
  "@packlink/giger": "*",
6
6
  "react-i18next": "*",
@@ -1,9 +1,22 @@
1
1
  export declare const styles: {
2
+ itemDescription: (theme: import("@packlink/giger-theme/dist/lib/Theme").Theme) => {
3
+ display: "flex";
4
+ flexDirection: "column";
5
+ padding: string;
6
+ };
2
7
  itemDetail: (theme: import("@packlink/giger-theme/dist/lib/Theme").Theme) => {
3
8
  padding: string;
9
+ verticalAlign: string;
4
10
  };
5
11
  itemName: (theme: import("@packlink/giger-theme/dist/lib/Theme").Theme) => {
6
- padding: string;
12
+ "-webkit-box-orient": string;
13
+ "-webkit-line-clamp": string;
14
+ display: "-webkit-box";
15
+ lineHeight: string;
16
+ maxHeight: string;
17
+ overflow: "hidden";
18
+ textOverflow: "ellipsis";
19
+ whiteSpace: "normal";
7
20
  };
8
21
  numericCell: () => {
9
22
  textAlign: "right";
@@ -624,6 +624,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
624
624
  invalidNameOrCompany: string;
625
625
  parsingFailure: string;
626
626
  incompleteLabelPurchaseRequirements: string;
627
+ shipmentCancelled: string;
627
628
  unableToLoad: {
628
629
  accountSettings: string;
629
630
  autoFundingSettings: string;
@@ -644,6 +645,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
644
645
  purchase: string;
645
646
  rateInvalid: string;
646
647
  security: string;
648
+ shipmentStatus: string;
647
649
  system: string;
648
650
  unknown: string;
649
651
  validation: string;
@@ -682,8 +684,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
682
684
  december: string;
683
685
  };
684
686
  packageCategories: {
685
- browseRates: string;
686
- myCustomPackages: string;
687
+ customPackages: string;
687
688
  };
688
689
  packageCodes: {
689
690
  package: string;
@@ -25,6 +25,9 @@ export type RateFormFeatures = {
25
25
  };
26
26
  export type ConfigureShipmentFeatures = {
27
27
  compatibleCountryCodes?: UseShipmentFormProps["compatibleCountryCodes"];
28
+ configureShipment?: {
29
+ enableErrorWhenShipmentCancelled: boolean;
30
+ };
28
31
  partnerMessages?: {
29
32
  incompleteLabelPurchaseRequirements?: string;
30
33
  };
@@ -38,6 +41,7 @@ export type ConfigureShipmentProps = {
38
41
  errors?: Templates.ShipmentFormProps["errors"];
39
42
  features?: ConfigureShipmentFeatures;
40
43
  getPreferredRates?: (shipment: SE.SalesOrderShipment, isInternational: boolean) => Promise<PreferredRatesResponse | undefined>;
44
+ insuranceAccount?: SE.InsuranceAccount;
41
45
  isLoading?: Templates.ShipmentFormProps["isLoading"];
42
46
  onAddressValidation?: UseShipmentFormProps["onAddressValidation"];
43
47
  onApplyPreset?: UseShipmentFormProps["onApplyPreset"];
@@ -58,4 +62,4 @@ export type ConfigureShipmentProps = {
58
62
  shippingPresets?: UseShippingPresetsOptionsProps;
59
63
  warehouseId?: string;
60
64
  };
61
- export declare const ConfigureShipment: ({ features, getPreferredRates, onAddressValidation, onApplyPreset, onBeforeLabelCreate, onChangeAddress, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, preferredServiceCodes, salesOrder, shipment, onBeforeRateSaved, ...props }: ConfigureShipmentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
65
+ export declare const ConfigureShipment: ({ errors, features, getPreferredRates, onAddressValidation, onApplyPreset, onBeforeLabelCreate, onChangeAddress, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, preferredServiceCodes, salesOrder, shipment, onBeforeRateSaved, ...props }: ConfigureShipmentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -586,6 +586,29 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
586
586
  invalidNameOrCompany: string;
587
587
  parsingFailure: string;
588
588
  incompleteLabelPurchaseRequirements: string;
589
+ shipmentCancelled: string;
590
+ /**
591
+ * # Registered Onboarding Element
592
+ *
593
+ * - This is the registered `<Onboarding />` element that will be used to render the
594
+ * `<Onboarding.Element />` component.
595
+ *
596
+ * @param ElementProps The props, callbacks, and resources necessary to render
597
+ * the `<Onboarding.Element />` component.
598
+ *
599
+ * @example
600
+ * The `<Component />` is the source JSX that is rendered when you make use of the `Onboarding`
601
+ * Element directly. Here is a brief example of how you would use it within your application.
602
+ * ```tsx
603
+ * <Onboarding.Element
604
+ * onCompleteOnboarding={() => console.log('Onboarding Complete!')}
605
+ * />
606
+ * ```
607
+ *
608
+ * <br />
609
+ *
610
+ * @see {@link Onboarding.ComponentProps | The **props** that can be passed into the `<Onboarding.Element />` component}
611
+ */
589
612
  unableToLoad: {
590
613
  accountSettings: string;
591
614
  autoFundingSettings: string;
@@ -606,6 +629,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
606
629
  purchase: string;
607
630
  rateInvalid: string;
608
631
  security: string;
632
+ shipmentStatus: string;
609
633
  system: string;
610
634
  unknown: string;
611
635
  validation: string;
@@ -644,8 +668,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
644
668
  december: string;
645
669
  };
646
670
  packageCategories: {
647
- browseRates: string;
648
- myCustomPackages: string;
671
+ customPackages: string;
649
672
  };
650
673
  packageCodes: {
651
674
  package: string;
@@ -2,13 +2,14 @@ import { SE } from "@shipengine/alchemy";
2
2
  import { ConfigureShipmentProps } from "../../configure-shipment";
3
3
  import { UsePendingShipmentProps } from "./use-pending-shipment";
4
4
  export type UseConfigureShipmentProps = {
5
+ errorWhenShipmentCancelled?: boolean;
5
6
  onLoad?: UsePendingShipmentProps["onLoad"];
6
7
  onShipmentUpdated?: ConfigureShipmentProps["onShipmentUpdated"];
7
8
  printLabelLayout?: SE.LabelLayout;
8
9
  salesOrder?: SE.SalesOrder;
9
10
  warehouseId?: UsePendingShipmentProps["warehouseId"];
10
11
  };
11
- export declare const useConfigureShipment: ({ onLoad, onShipmentUpdated, salesOrder, warehouseId, printLabelLayout, }: UseConfigureShipmentProps) => {
12
+ export declare const useConfigureShipment: ({ onLoad, errorWhenShipmentCancelled, onShipmentUpdated, salesOrder, warehouseId, printLabelLayout, }: UseConfigureShipmentProps) => {
12
13
  errors: SE.CodedError[] | undefined;
13
14
  isLoading: boolean;
14
15
  onShipmentUpdated: (shipment: SE.SalesOrderShipment) => Promise<void>;
@@ -1,12 +1,13 @@
1
- import { SE } from "@shipengine/alchemy";
1
+ import { CodedError, SE } from "@shipengine/alchemy";
2
2
  export type UsePendingShipmentProps = {
3
+ breakOnCancelledShipment?: boolean;
3
4
  onLoad?: (salesOrder: SE.SalesOrder, shipments: SE.SalesOrderShipment[], pendingShipment?: SE.SalesOrderShipment) => Promise<void> | void;
4
5
  salesOrder?: SE.SalesOrder;
5
6
  warehouseId?: string;
6
7
  };
7
- export declare const usePendingShipment: ({ onLoad, salesOrder, warehouseId, }: UsePendingShipmentProps) => {
8
+ export declare const usePendingShipment: ({ breakOnCancelledShipment, onLoad, salesOrder, warehouseId, }: UsePendingShipmentProps) => {
8
9
  isPendingShipmentLoading: boolean;
9
10
  pendingShipment: SE.SalesOrderShipment | undefined;
10
- pendingShipmentErrors: SE.CodedError[] | undefined;
11
+ pendingShipmentErrors: CodedError[] | undefined;
11
12
  reloadPendingShipment: () => Promise<SE.SalesOrderShipment | undefined>;
12
13
  };
@@ -705,17 +705,12 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
705
705
  invalidNameOrCompany: string;
706
706
  parsingFailure: string;
707
707
  incompleteLabelPurchaseRequirements: string;
708
+ shipmentCancelled: string;
708
709
  unableToLoad: {
709
710
  accountSettings: string;
710
711
  autoFundingSettings: string;
711
712
  carrier: string;
712
713
  carriers: string;
713
- /**
714
- * `onToggleAddressPreferenceDisclosure` is an async/sync callback function that will be invoked
715
- * each time the user toggles the `Address Preference` disclosure. This disclosure component
716
- * allows the user to select whether they would like to use the address they entered, or
717
- * the formatted address that we return after validation.
718
- */
719
714
  label: string;
720
715
  salesOrder: string;
721
716
  shipment: string;
@@ -731,6 +726,7 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
731
726
  purchase: string;
732
727
  rateInvalid: string;
733
728
  security: string;
729
+ shipmentStatus: string;
734
730
  system: string;
735
731
  unknown: string;
736
732
  validation: string;
@@ -748,10 +744,7 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
748
744
  connectingCarriers: string;
749
745
  data: string;
750
746
  importingSalesOrder: string;
751
- label: string; /**
752
- * `warehouseId` is a string that represents a previously configured warehouse you would
753
- * like to use as the `Ship From Address` when purchasing a label.
754
- */
747
+ label: string;
755
748
  onboarding: string;
756
749
  salesOrder: string;
757
750
  shipment: string;
@@ -769,11 +762,34 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
769
762
  september: string;
770
763
  october: string;
771
764
  november: string;
765
+ /**
766
+ * # Purchase Label Component
767
+ *
768
+ * The `<PurchaseLabel />` component is used to purchase shipping labels from various carriers
769
+ *
770
+ * @param ElementProps The props necessary to render the `<PurchaseLabel />` component for shipment
771
+ * based or sales order based label purchasing.
772
+ *
773
+ * @returns Element An EmotionJSX.Element that will render the `<PurchaseLabel />` component
774
+ * with all the appropriate wrappers.
775
+ *
776
+ * @example
777
+ * You can see how the `<Component />` is used in the `createElement` function call below.
778
+ * ```tsx
779
+ * export const Element = alchemy.createElement(Component, ErrorFallback, {
780
+ * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
781
+ * resources: { en },
782
+ * });
783
+ * ```
784
+ *
785
+ * <br />
786
+ *
787
+ * @see {@link PurchaseLabel.Element | The **Element** created to render `<PurchaseLabel />`}
788
+ */
772
789
  december: string;
773
790
  };
774
791
  packageCategories: {
775
- browseRates: string;
776
- myCustomPackages: string;
792
+ customPackages: string;
777
793
  };
778
794
  packageCodes: {
779
795
  package: string;
@@ -621,9 +621,17 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
621
621
  invalidNameOrCompany: string;
622
622
  parsingFailure: string;
623
623
  incompleteLabelPurchaseRequirements: string;
624
+ shipmentCancelled: string;
624
625
  unableToLoad: {
625
626
  accountSettings: string;
626
627
  autoFundingSettings: string;
628
+ /**
629
+ * # View Shipment Element Props
630
+ *
631
+ * - These are the base props that will be passed into the `<ViewShipment />` element.
632
+ *
633
+ * @see {@link ViewShipment.Element | See the full type that `typeof Element` will return}
634
+ */
627
635
  carrier: string;
628
636
  carriers: string;
629
637
  label: string;
@@ -641,6 +649,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
641
649
  purchase: string;
642
650
  rateInvalid: string;
643
651
  security: string;
652
+ shipmentStatus: string;
644
653
  system: string;
645
654
  unknown: string;
646
655
  validation: string;
@@ -679,8 +688,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
679
688
  december: string;
680
689
  };
681
690
  packageCategories: {
682
- browseRates: string;
683
- myCustomPackages: string;
691
+ customPackages: string;
684
692
  };
685
693
  packageCodes: {
686
694
  package: string;
@@ -624,6 +624,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
624
624
  invalidNameOrCompany: string;
625
625
  parsingFailure: string;
626
626
  incompleteLabelPurchaseRequirements: string;
627
+ shipmentCancelled: string;
627
628
  unableToLoad: {
628
629
  accountSettings: string;
629
630
  autoFundingSettings: string;
@@ -644,6 +645,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
644
645
  purchase: string;
645
646
  rateInvalid: string;
646
647
  security: string;
648
+ shipmentStatus: string;
647
649
  system: string;
648
650
  unknown: string;
649
651
  validation: string;
@@ -682,8 +684,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
682
684
  december: string;
683
685
  };
684
686
  packageCategories: {
685
- browseRates: string;
686
- myCustomPackages: string;
687
+ customPackages: string;
687
688
  };
688
689
  packageCodes: {
689
690
  package: string;
@@ -496,6 +496,7 @@ declare const _default: {
496
496
  invalidNameOrCompany: string;
497
497
  parsingFailure: string;
498
498
  incompleteLabelPurchaseRequirements: string;
499
+ shipmentCancelled: string;
499
500
  unableToLoad: {
500
501
  accountSettings: string;
501
502
  autoFundingSettings: string;
@@ -516,6 +517,7 @@ declare const _default: {
516
517
  purchase: string;
517
518
  rateInvalid: string;
518
519
  security: string;
520
+ shipmentStatus: string;
519
521
  system: string;
520
522
  unknown: string;
521
523
  validation: string;
@@ -554,8 +556,7 @@ declare const _default: {
554
556
  december: string;
555
557
  };
556
558
  packageCategories: {
557
- browseRates: string;
558
- myCustomPackages: string;
559
+ customPackages: string;
559
560
  };
560
561
  packageCodes: {
561
562
  package: string;
@@ -51,6 +51,15 @@ export declare const featureFlags: {
51
51
  * Elements.
52
52
  */
53
53
  readonly compatibleCountryCodes: readonly ["AU", "CA", "FR", "DE", "GB", "IL", "IT", "NO", "ES", "SE", "US"];
54
+ /**
55
+ * `configureShipment` is a group of flags related to the useConfigureShipment functionality
56
+ */
57
+ readonly configureShipment: {
58
+ /**
59
+ * `enableErrorWhenShipmentCancelled` when enabled will modify the default behavior of creating a new shipment for a salesorder to throwing an error
60
+ */
61
+ readonly enableErrorWhenShipmentCancelled: false;
62
+ };
54
63
  /**
55
64
  * @internal
56
65
  *
@@ -18,8 +18,24 @@ export declare const getIsCustomsRequiredForShipment: ({ shipFrom, shipTo }: SE.
18
18
  /**
19
19
  * @internal
20
20
  *
21
+ * @deprecated please use getShipmentByStatus instead
21
22
  * # Shipment Utilities - getPendingShipment
22
23
  *
23
24
  * @category Utilities
24
25
  */
25
26
  export declare const getPendingShipment: (shipments?: SE.SalesOrderShipment[]) => SE.SalesOrderShipment | undefined;
27
+ /**
28
+ *
29
+ * @deprecated please use getShipmentByStatus instead
30
+ * @internal
31
+ * @param shipments
32
+ * @returns the latest created shipment whose status is `cancelled`
33
+ */
34
+ export declare const getCancelledShipment: (shipments?: SE.SalesOrderShipment[]) => SE.SalesOrderShipment | undefined;
35
+ /**
36
+ *
37
+ * @param status string containing one of the following values - "pending", "processing", "label_purchased", "cancelled"
38
+ * @param shipments optional list of shipments to filter from
39
+ * @returns latest created shipment whose shipmentStatus matches the param status
40
+ */
41
+ export declare const getShipmentByStatus: (status: SE.ShipmentStatus, shipments?: SE.SalesOrderShipment[]) => SE.SalesOrderShipment | undefined;