@shipengine/elements 0.37.2 → 0.37.3

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
 
@@ -16862,6 +16889,7 @@ var common = {
16862
16889
  invalidNameOrCompany: "Recipient name and company name (if provided) must have two characters in first and last name.",
16863
16890
  parsingFailure: "Parsing failed. Please check address and try again.",
16864
16891
  incompleteLabelPurchaseRequirements: "Please add your {{requirements}} to continue purchasing a label.",
16892
+ shipmentCancelled: "This shipment is Cancelled in ShipStation. Log into ShipStation to restore the order to Awaiting Shipment status.",
16865
16893
  unableToLoad: {
16866
16894
  accountSettings: "Unable to load account settings",
16867
16895
  autoFundingSettings: "Unable to load auto funding settings",
@@ -16882,6 +16910,7 @@ var common = {
16882
16910
  purchase: "Purchase error",
16883
16911
  rateInvalid: "Invalid rate configuration",
16884
16912
  security: "Security error",
16913
+ shipmentStatus: "Shipment status error",
16885
16914
  system: "System error",
16886
16915
  unknown: "Unknown error",
16887
16916
  validation: "Unable to validate address"
@@ -18400,7 +18429,9 @@ const useShipmentForm = ({
18400
18429
  };
18401
18430
 
18402
18431
  const ConfigureShipment = _a => {
18432
+ var _b;
18403
18433
  var {
18434
+ errors,
18404
18435
  features,
18405
18436
  getPreferredRates,
18406
18437
  onAddressValidation,
@@ -18418,12 +18449,13 @@ const ConfigureShipment = _a => {
18418
18449
  shipment,
18419
18450
  onBeforeRateSaved
18420
18451
  } = _a,
18421
- props = __rest(_a, ["features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18452
+ props = __rest(_a, ["errors", "features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18422
18453
  const hydrateRef = React.useRef();
18454
+ reactI18next.useTranslation();
18423
18455
  const {
18424
18456
  isInternational
18425
18457
  } = useShipmentMetadata(shipment);
18426
- const _b = useRatesForm({
18458
+ const _c = useRatesForm({
18427
18459
  getPreferredRates,
18428
18460
  onBeforeLabelCreate,
18429
18461
  onBeforeRateSaved,
@@ -18444,17 +18476,17 @@ const ConfigureShipment = _a => {
18444
18476
  resetRates,
18445
18477
  resetLabel,
18446
18478
  preferredRates
18447
- } = _b,
18448
- rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18449
- const _c = useShipmentForm({
18479
+ } = _c,
18480
+ rateFormProps = __rest(_c, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18481
+ const _d = useShipmentForm({
18450
18482
  compatibleCountryCodes: features === null || features === void 0 ? void 0 : features.compatibleCountryCodes,
18451
18483
  onAddressValidation,
18452
18484
  onApplyPreset: React.useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
18453
- var _d;
18485
+ var _e;
18454
18486
  if (shipment.packages[0].weight.value) {
18455
18487
  yield requestRates(shipment, isInternational);
18456
18488
  }
18457
- (_d = hydrateRef.current) === null || _d === void 0 ? void 0 : _d.call(hydrateRef, shipment);
18489
+ (_e = hydrateRef.current) === null || _e === void 0 ? void 0 : _e.call(hydrateRef, shipment);
18458
18490
  }), [requestRates, isInternational]),
18459
18491
  onChangeAddress,
18460
18492
  onShipmentUpdated,
@@ -18467,8 +18499,8 @@ const ConfigureShipment = _a => {
18467
18499
  {
18468
18500
  charsetWarning,
18469
18501
  resetSalesOrderShipment
18470
- } = _c,
18471
- shipmentFormProps = __rest(_c, ["charsetWarning", "resetSalesOrderShipment"]);
18502
+ } = _d,
18503
+ shipmentFormProps = __rest(_d, ["charsetWarning", "resetSalesOrderShipment"]);
18472
18504
  const handleOnDirty = React.useCallback(() => {
18473
18505
  resetRates();
18474
18506
  resetLabel();
@@ -18488,6 +18520,9 @@ const ConfigureShipment = _a => {
18488
18520
  return self.indexOf(item) === pos;
18489
18521
  });
18490
18522
  }, [preferredRates, preferredServiceCodes]);
18523
+ 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"))) {
18524
+ throw new Error("errorMessages.shipmentCancelled");
18525
+ }
18491
18526
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
18492
18527
  children: [jsxRuntime.jsx(ShipmentForm, Object.assign({}, shipmentFormProps, props, {
18493
18528
  charsetWarning: charsetWarning,
@@ -18506,6 +18541,7 @@ const ConfigureShipment = _a => {
18506
18541
  };
18507
18542
 
18508
18543
  const usePendingShipment = ({
18544
+ breakOnCancelledShipment: _breakOnCancelledShipment = false,
18509
18545
  onLoad,
18510
18546
  salesOrder,
18511
18547
  warehouseId
@@ -18529,17 +18565,18 @@ const usePendingShipment = ({
18529
18565
  isLoading: isShipmentCreating,
18530
18566
  mutateAsync: createShipment
18531
18567
  } = alchemy.useCreateSalesOrderShipment();
18532
- const pendingShipment = getPendingShipment(shipments);
18568
+ const pendingShipment = getShipmentByStatus("pending", shipments);
18569
+ const cancelledShipment = getShipmentByStatus("cancelled", shipments);
18533
18570
  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
18571
  // On page load, check for a shipment and either call the onLoad callback or create a new shipment
18535
18572
  React.useEffect(() => {
18536
18573
  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);
18574
+ void (onLoad === null || onLoad === void 0 ? void 0 : onLoad(salesOrder, shipments, pendingShipment));
18538
18575
  return;
18539
18576
  }
18540
- if (!salesOrder || !defaultWarehouse || !shipments || pendingShipment) return;
18577
+ if (!salesOrder || !defaultWarehouse || !shipments || _breakOnCancelledShipment && cancelledShipment || pendingShipment) return;
18541
18578
  if (isListShipmentsLoading || isListShipmentsValidating || isShipmentCreating) return;
18542
- createShipment(Object.assign(Object.assign({
18579
+ void createShipment(Object.assign(Object.assign({
18543
18580
  salesOrderId: salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.salesOrderId,
18544
18581
  // /v-beta/shipments/sales_order/:salesOrderId requires at minimum
18545
18582
  // a (warehouseId or shipFrom)
@@ -18555,14 +18592,18 @@ const usePendingShipment = ({
18555
18592
  }
18556
18593
  }]
18557
18594
  })).then(shipment => shipment && reloadShipments());
18558
- }, [createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId]);
18595
+ }, [cancelledShipment, createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId, _breakOnCancelledShipment]);
18559
18596
  const reloadPendingShipment = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18560
18597
  const {
18561
18598
  data: shipments
18562
18599
  } = yield reloadShipments();
18563
- return getPendingShipment(shipments);
18600
+ return getShipmentByStatus("pending", shipments);
18564
18601
  }), [reloadShipments]);
18565
- const errors = [...(listWarehouseErrors !== null && listWarehouseErrors !== void 0 ? listWarehouseErrors : []), ...(createShipmentErrors !== null && createShipmentErrors !== void 0 ? createShipmentErrors : []), ...(listShipmentsErrors !== null && listShipmentsErrors !== void 0 ? listShipmentsErrors : [])];
18602
+ 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", {
18603
+ errorCode: "invalid_status",
18604
+ errorSource: "elements",
18605
+ errorType: "business_rules"
18606
+ })] : [])];
18566
18607
  return {
18567
18608
  isPendingShipmentLoading: !pendingShipment && errors.length === 0,
18568
18609
  pendingShipment,
@@ -18573,6 +18614,7 @@ const usePendingShipment = ({
18573
18614
 
18574
18615
  const useConfigureShipment = ({
18575
18616
  onLoad,
18617
+ errorWhenShipmentCancelled: _errorWhenShipmentCancelled = false,
18576
18618
  onShipmentUpdated,
18577
18619
  salesOrder,
18578
18620
  warehouseId,
@@ -18585,6 +18627,7 @@ const useConfigureShipment = ({
18585
18627
  pendingShipmentErrors,
18586
18628
  reloadPendingShipment
18587
18629
  } = usePendingShipment({
18630
+ breakOnCancelledShipment: _errorWhenShipmentCancelled,
18588
18631
  onLoad,
18589
18632
  salesOrder,
18590
18633
  warehouseId
@@ -18661,6 +18704,7 @@ const useImportSalesOrder = ({
18661
18704
  };
18662
18705
 
18663
18706
  const PurchaseLabelBySalesOrder = _a => {
18707
+ var _b;
18664
18708
  var {
18665
18709
  features,
18666
18710
  externalOrderId,
@@ -18673,7 +18717,7 @@ const PurchaseLabelBySalesOrder = _a => {
18673
18717
  printLabelLayout
18674
18718
  } = _a,
18675
18719
  props = __rest(_a, ["features", "externalOrderId", "externalOrderNumber", "onLoad", "onShipmentUpdated", "orderSourceCode", "salesOrderId", "warehouseId", "printLabelLayout"]);
18676
- const _b = useImportSalesOrder({
18720
+ const _c = useImportSalesOrder({
18677
18721
  externalOrderId,
18678
18722
  externalOrderNumber,
18679
18723
  orderSourceCode,
@@ -18682,9 +18726,10 @@ const PurchaseLabelBySalesOrder = _a => {
18682
18726
  {
18683
18727
  salesOrder,
18684
18728
  isLoading: salesOrderLoading
18685
- } = _b,
18686
- salesOrderProps = __rest(_b, ["salesOrder", "isLoading"]);
18729
+ } = _c,
18730
+ salesOrderProps = __rest(_c, ["salesOrder", "isLoading"]);
18687
18731
  const configureShipmentProps = useConfigureShipment({
18732
+ errorWhenShipmentCancelled: (_b = features === null || features === void 0 ? void 0 : features.configureShipment) === null || _b === void 0 ? void 0 : _b.enableErrorWhenShipmentCancelled,
18688
18733
  onLoad,
18689
18734
  onShipmentUpdated,
18690
18735
  printLabelLayout,
@@ -18825,7 +18870,9 @@ const Component$2 = _a => {
18825
18870
  });
18826
18871
  if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
18827
18872
  if ("salesOrderId" in props || "orderSourceCode" in props) {
18828
- return jsxRuntime.jsx(PurchaseLabelBySalesOrder, Object.assign({}, props));
18873
+ return jsxRuntime.jsx(PurchaseLabelBySalesOrder, Object.assign({
18874
+ features: features
18875
+ }, props));
18829
18876
  } else {
18830
18877
  return jsxRuntime.jsx(PurchaseLabelByShipment, Object.assign({}, props));
18831
18878
  }
@@ -19446,6 +19493,7 @@ exports.formatExpiration = formatExpiration;
19446
19493
  exports.formatFractionalWeight = formatFractionalWeight;
19447
19494
  exports.formatMoney = formatMoney;
19448
19495
  exports.getAddFundsSchema = getAddFundsSchema;
19496
+ exports.getCancelledShipment = getCancelledShipment;
19449
19497
  exports.getCarrierIdByCarrierCode = getCarrierIdByCarrierCode;
19450
19498
  exports.getCustomsFromSalesOrder = getCustomsFromSalesOrder;
19451
19499
  exports.getExpirationYears = getExpirationYears;
@@ -19458,6 +19506,7 @@ exports.getRateRequiresAcknowledgement = getRateRequiresAcknowledgement;
19458
19506
  exports.getRelativeDates = getRelativeDates;
19459
19507
  exports.getRequestedServices = getRequestedServices;
19460
19508
  exports.getSalesOrderItemsFromSalesOrderOrShipment = getSalesOrderItemsFromSalesOrderOrShipment;
19509
+ exports.getShipmentByStatus = getShipmentByStatus;
19461
19510
  exports.getTotalRateAmount = getTotalRateAmount;
19462
19511
  exports.isDecimalWeight = isDecimalWeight;
19463
19512
  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, 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
 
@@ -16830,6 +16857,7 @@ var common = {
16830
16857
  invalidNameOrCompany: "Recipient name and company name (if provided) must have two characters in first and last name.",
16831
16858
  parsingFailure: "Parsing failed. Please check address and try again.",
16832
16859
  incompleteLabelPurchaseRequirements: "Please add your {{requirements}} to continue purchasing a label.",
16860
+ shipmentCancelled: "This shipment is Cancelled in ShipStation. Log into ShipStation to restore the order to Awaiting Shipment status.",
16833
16861
  unableToLoad: {
16834
16862
  accountSettings: "Unable to load account settings",
16835
16863
  autoFundingSettings: "Unable to load auto funding settings",
@@ -16850,6 +16878,7 @@ var common = {
16850
16878
  purchase: "Purchase error",
16851
16879
  rateInvalid: "Invalid rate configuration",
16852
16880
  security: "Security error",
16881
+ shipmentStatus: "Shipment status error",
16853
16882
  system: "System error",
16854
16883
  unknown: "Unknown error",
16855
16884
  validation: "Unable to validate address"
@@ -18368,7 +18397,9 @@ const useShipmentForm = ({
18368
18397
  };
18369
18398
 
18370
18399
  const ConfigureShipment = _a => {
18400
+ var _b;
18371
18401
  var {
18402
+ errors,
18372
18403
  features,
18373
18404
  getPreferredRates,
18374
18405
  onAddressValidation,
@@ -18386,12 +18417,13 @@ const ConfigureShipment = _a => {
18386
18417
  shipment,
18387
18418
  onBeforeRateSaved
18388
18419
  } = _a,
18389
- props = __rest(_a, ["features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18420
+ props = __rest(_a, ["errors", "features", "getPreferredRates", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "preferredServiceCodes", "salesOrder", "shipment", "onBeforeRateSaved"]);
18390
18421
  const hydrateRef = useRef();
18422
+ useTranslation();
18391
18423
  const {
18392
18424
  isInternational
18393
18425
  } = useShipmentMetadata(shipment);
18394
- const _b = useRatesForm({
18426
+ const _c = useRatesForm({
18395
18427
  getPreferredRates,
18396
18428
  onBeforeLabelCreate,
18397
18429
  onBeforeRateSaved,
@@ -18412,17 +18444,17 @@ const ConfigureShipment = _a => {
18412
18444
  resetRates,
18413
18445
  resetLabel,
18414
18446
  preferredRates
18415
- } = _b,
18416
- rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18417
- const _c = useShipmentForm({
18447
+ } = _c,
18448
+ rateFormProps = __rest(_c, ["requestRates", "resetRates", "resetLabel", "preferredRates"]);
18449
+ const _d = useShipmentForm({
18418
18450
  compatibleCountryCodes: features === null || features === void 0 ? void 0 : features.compatibleCountryCodes,
18419
18451
  onAddressValidation,
18420
18452
  onApplyPreset: useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
18421
- var _d;
18453
+ var _e;
18422
18454
  if (shipment.packages[0].weight.value) {
18423
18455
  yield requestRates(shipment, isInternational);
18424
18456
  }
18425
- (_d = hydrateRef.current) === null || _d === void 0 ? void 0 : _d.call(hydrateRef, shipment);
18457
+ (_e = hydrateRef.current) === null || _e === void 0 ? void 0 : _e.call(hydrateRef, shipment);
18426
18458
  }), [requestRates, isInternational]),
18427
18459
  onChangeAddress,
18428
18460
  onShipmentUpdated,
@@ -18435,8 +18467,8 @@ const ConfigureShipment = _a => {
18435
18467
  {
18436
18468
  charsetWarning,
18437
18469
  resetSalesOrderShipment
18438
- } = _c,
18439
- shipmentFormProps = __rest(_c, ["charsetWarning", "resetSalesOrderShipment"]);
18470
+ } = _d,
18471
+ shipmentFormProps = __rest(_d, ["charsetWarning", "resetSalesOrderShipment"]);
18440
18472
  const handleOnDirty = useCallback(() => {
18441
18473
  resetRates();
18442
18474
  resetLabel();
@@ -18456,6 +18488,9 @@ const ConfigureShipment = _a => {
18456
18488
  return self.indexOf(item) === pos;
18457
18489
  });
18458
18490
  }, [preferredRates, preferredServiceCodes]);
18491
+ 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"))) {
18492
+ throw new Error("errorMessages.shipmentCancelled");
18493
+ }
18459
18494
  return jsxs(Fragment, {
18460
18495
  children: [jsx(ShipmentForm, Object.assign({}, shipmentFormProps, props, {
18461
18496
  charsetWarning: charsetWarning,
@@ -18474,6 +18509,7 @@ const ConfigureShipment = _a => {
18474
18509
  };
18475
18510
 
18476
18511
  const usePendingShipment = ({
18512
+ breakOnCancelledShipment: _breakOnCancelledShipment = false,
18477
18513
  onLoad,
18478
18514
  salesOrder,
18479
18515
  warehouseId
@@ -18497,17 +18533,18 @@ const usePendingShipment = ({
18497
18533
  isLoading: isShipmentCreating,
18498
18534
  mutateAsync: createShipment
18499
18535
  } = useCreateSalesOrderShipment();
18500
- const pendingShipment = getPendingShipment(shipments);
18536
+ const pendingShipment = getShipmentByStatus("pending", shipments);
18537
+ const cancelledShipment = getShipmentByStatus("cancelled", shipments);
18501
18538
  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
18539
  // On page load, check for a shipment and either call the onLoad callback or create a new shipment
18503
18540
  useEffect(() => {
18504
18541
  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);
18542
+ void (onLoad === null || onLoad === void 0 ? void 0 : onLoad(salesOrder, shipments, pendingShipment));
18506
18543
  return;
18507
18544
  }
18508
- if (!salesOrder || !defaultWarehouse || !shipments || pendingShipment) return;
18545
+ if (!salesOrder || !defaultWarehouse || !shipments || _breakOnCancelledShipment && cancelledShipment || pendingShipment) return;
18509
18546
  if (isListShipmentsLoading || isListShipmentsValidating || isShipmentCreating) return;
18510
- createShipment(Object.assign(Object.assign({
18547
+ void createShipment(Object.assign(Object.assign({
18511
18548
  salesOrderId: salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.salesOrderId,
18512
18549
  // /v-beta/shipments/sales_order/:salesOrderId requires at minimum
18513
18550
  // a (warehouseId or shipFrom)
@@ -18523,14 +18560,18 @@ const usePendingShipment = ({
18523
18560
  }
18524
18561
  }]
18525
18562
  })).then(shipment => shipment && reloadShipments());
18526
- }, [createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId]);
18563
+ }, [cancelledShipment, createShipment, defaultWarehouse, isListShipmentsLoading, isListShipmentsValidating, isShipmentCreating, onLoad, pendingShipment, reloadShipments, salesOrder, shipments, warehouseId, _breakOnCancelledShipment]);
18527
18564
  const reloadPendingShipment = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18528
18565
  const {
18529
18566
  data: shipments
18530
18567
  } = yield reloadShipments();
18531
- return getPendingShipment(shipments);
18568
+ return getShipmentByStatus("pending", shipments);
18532
18569
  }), [reloadShipments]);
18533
- const errors = [...(listWarehouseErrors !== null && listWarehouseErrors !== void 0 ? listWarehouseErrors : []), ...(createShipmentErrors !== null && createShipmentErrors !== void 0 ? createShipmentErrors : []), ...(listShipmentsErrors !== null && listShipmentsErrors !== void 0 ? listShipmentsErrors : [])];
18570
+ 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", {
18571
+ errorCode: "invalid_status",
18572
+ errorSource: "elements",
18573
+ errorType: "business_rules"
18574
+ })] : [])];
18534
18575
  return {
18535
18576
  isPendingShipmentLoading: !pendingShipment && errors.length === 0,
18536
18577
  pendingShipment,
@@ -18541,6 +18582,7 @@ const usePendingShipment = ({
18541
18582
 
18542
18583
  const useConfigureShipment = ({
18543
18584
  onLoad,
18585
+ errorWhenShipmentCancelled: _errorWhenShipmentCancelled = false,
18544
18586
  onShipmentUpdated,
18545
18587
  salesOrder,
18546
18588
  warehouseId,
@@ -18553,6 +18595,7 @@ const useConfigureShipment = ({
18553
18595
  pendingShipmentErrors,
18554
18596
  reloadPendingShipment
18555
18597
  } = usePendingShipment({
18598
+ breakOnCancelledShipment: _errorWhenShipmentCancelled,
18556
18599
  onLoad,
18557
18600
  salesOrder,
18558
18601
  warehouseId
@@ -18629,6 +18672,7 @@ const useImportSalesOrder = ({
18629
18672
  };
18630
18673
 
18631
18674
  const PurchaseLabelBySalesOrder = _a => {
18675
+ var _b;
18632
18676
  var {
18633
18677
  features,
18634
18678
  externalOrderId,
@@ -18641,7 +18685,7 @@ const PurchaseLabelBySalesOrder = _a => {
18641
18685
  printLabelLayout
18642
18686
  } = _a,
18643
18687
  props = __rest(_a, ["features", "externalOrderId", "externalOrderNumber", "onLoad", "onShipmentUpdated", "orderSourceCode", "salesOrderId", "warehouseId", "printLabelLayout"]);
18644
- const _b = useImportSalesOrder({
18688
+ const _c = useImportSalesOrder({
18645
18689
  externalOrderId,
18646
18690
  externalOrderNumber,
18647
18691
  orderSourceCode,
@@ -18650,9 +18694,10 @@ const PurchaseLabelBySalesOrder = _a => {
18650
18694
  {
18651
18695
  salesOrder,
18652
18696
  isLoading: salesOrderLoading
18653
- } = _b,
18654
- salesOrderProps = __rest(_b, ["salesOrder", "isLoading"]);
18697
+ } = _c,
18698
+ salesOrderProps = __rest(_c, ["salesOrder", "isLoading"]);
18655
18699
  const configureShipmentProps = useConfigureShipment({
18700
+ errorWhenShipmentCancelled: (_b = features === null || features === void 0 ? void 0 : features.configureShipment) === null || _b === void 0 ? void 0 : _b.enableErrorWhenShipmentCancelled,
18656
18701
  onLoad,
18657
18702
  onShipmentUpdated,
18658
18703
  printLabelLayout,
@@ -18793,7 +18838,9 @@ const Component$2 = _a => {
18793
18838
  });
18794
18839
  if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
18795
18840
  if ("salesOrderId" in props || "orderSourceCode" in props) {
18796
- return jsx(PurchaseLabelBySalesOrder, Object.assign({}, props));
18841
+ return jsx(PurchaseLabelBySalesOrder, Object.assign({
18842
+ features: features
18843
+ }, props));
18797
18844
  } else {
18798
18845
  return jsx(PurchaseLabelByShipment, Object.assign({}, props));
18799
18846
  }
@@ -19345,4 +19392,4 @@ var labelWorkflow = /*#__PURE__*/Object.freeze({
19345
19392
  Element: Element
19346
19393
  });
19347
19394
 
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 };
19395
+ 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.3",
4
4
  "peerDependencies": {
5
5
  "@packlink/giger": "*",
6
6
  "react-i18next": "*",
@@ -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;
@@ -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
  };
@@ -58,4 +61,4 @@ export type ConfigureShipmentProps = {
58
61
  shippingPresets?: UseShippingPresetsOptionsProps;
59
62
  warehouseId?: string;
60
63
  };
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;
64
+ 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;
@@ -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,6 +762,30 @@ 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: {
@@ -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;
@@ -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;
@@ -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;
@@ -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;