@shipengine/elements 0.37.0 → 0.37.1
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 +41 -34
- package/index.js +41 -34
- package/package.json +1 -1
- package/src/components/templates/shipment-form/shipment-form.d.ts +0 -3
- package/src/elements/configure-shipment/configure-shipment.d.ts +3 -0
- package/src/elements/purchase-label/purchase-label.d.ts +36 -42
- package/src/utilities/feature-flags.d.ts +8 -8
package/index.cjs
CHANGED
|
@@ -2648,6 +2648,14 @@ const featureFlags = {
|
|
|
2648
2648
|
* Elements.
|
|
2649
2649
|
*/
|
|
2650
2650
|
compatibleCountryCodes: ["AU", "CA", "FR", "DE", "GB", "IL", "IT", "NO", "ES", "SE", "US"],
|
|
2651
|
+
/**
|
|
2652
|
+
* @internal
|
|
2653
|
+
*
|
|
2654
|
+
* `partnerMessages` enables the partner consuming elements to specify override messages in specific cases.
|
|
2655
|
+
*/
|
|
2656
|
+
partnerMessages: {
|
|
2657
|
+
incompleteLabelPurchaseRequirements: undefined
|
|
2658
|
+
},
|
|
2651
2659
|
/**
|
|
2652
2660
|
* `rateForm` all scoped feature flags for the `rate form` section of the `<PurchaseLabel />`
|
|
2653
2661
|
* element.
|
|
@@ -2701,14 +2709,6 @@ const featureFlags = {
|
|
|
2701
2709
|
* to opt for third party insurance when insuring their shipment.
|
|
2702
2710
|
*/
|
|
2703
2711
|
includeThirdPartyInsurance: true,
|
|
2704
|
-
/**
|
|
2705
|
-
* @internal
|
|
2706
|
-
*
|
|
2707
|
-
* `partnerMessages` enables the partner consuming elements to specify override messages in specific cases.
|
|
2708
|
-
*/
|
|
2709
|
-
partnerMessages: {
|
|
2710
|
-
incompleteLabelPurchaseRequirements: undefined
|
|
2711
|
-
},
|
|
2712
2712
|
/**
|
|
2713
2713
|
* `selectService` enables the `select service` feature, allowing users to select a service
|
|
2714
2714
|
* when rate shopping across multiple carrier providers.
|
|
@@ -15411,7 +15411,7 @@ const ShipmentForm = ({
|
|
|
15411
15411
|
warehouseId,
|
|
15412
15412
|
warehouses
|
|
15413
15413
|
}) => {
|
|
15414
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
15414
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
15415
15415
|
features = Object.assign({
|
|
15416
15416
|
browseRates: true,
|
|
15417
15417
|
includeShipsuranceInsurance: true,
|
|
@@ -15597,16 +15597,16 @@ const ShipmentForm = ({
|
|
|
15597
15597
|
}, [form]);
|
|
15598
15598
|
const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
15599
15599
|
try {
|
|
15600
|
-
const
|
|
15600
|
+
const _l = values,
|
|
15601
15601
|
{
|
|
15602
15602
|
__mode: discard
|
|
15603
|
-
} =
|
|
15604
|
-
payload = __rest(
|
|
15603
|
+
} = _l,
|
|
15604
|
+
payload = __rest(_l, ["__mode"]);
|
|
15605
15605
|
const updatedShipment = yield onSubmit(Object.assign(Object.assign({}, shipment || {}), payload));
|
|
15606
15606
|
// Defer shipment hydration to the task queue so that the submission promise resolves first, otherwise the
|
|
15607
15607
|
// submission count will increment after hydration resets the form, keeping it in revalidate mode
|
|
15608
15608
|
if (updatedShipment) setTimeout(() => hydrateShipment(updatedShipment), 0);
|
|
15609
|
-
} catch (
|
|
15609
|
+
} catch (_m) {
|
|
15610
15610
|
// Reset the form to its current state, but as a side effect this sets isDirty to false
|
|
15611
15611
|
// That way, form lifecycle contract is upheld
|
|
15612
15612
|
form.reset(form.getValues());
|
|
@@ -15739,19 +15739,6 @@ const ShipmentForm = ({
|
|
|
15739
15739
|
const hasUpsOptions = React.useMemo(() => {
|
|
15740
15740
|
return (packageOptions === null || packageOptions === void 0 ? void 0 : packageOptions.some(option => option.label === "UPS")) && ((selectedPackage === null || selectedPackage === void 0 ? void 0 : selectedPackage.code) === "package" || selectedCarrierId === upsCarrierId);
|
|
15741
15741
|
}, [packageOptions, selectedPackage, selectedCarrierId, upsCarrierId]);
|
|
15742
|
-
const incompleteRequirementsKeys = React.useMemo(() => {
|
|
15743
|
-
if ((warehouses === null || warehouses === void 0 ? void 0 : warehouses.length) === 0 && (carriers === null || carriers === void 0 ? void 0 : carriers.length) === 0) {
|
|
15744
|
-
return ["noWarehouseOrCarrier"];
|
|
15745
|
-
} else {
|
|
15746
|
-
const keys = [(warehouses === null || warehouses === void 0 ? void 0 : warehouses.length) === 0 && "noWarehouse", (carriers === null || carriers === void 0 ? void 0 : carriers.length) === 0 && "noCarrier"].filter(Boolean);
|
|
15747
|
-
return keys;
|
|
15748
|
-
}
|
|
15749
|
-
}, [carriers, warehouses]);
|
|
15750
|
-
const isPartnerMessagingEnabled = !!((_d = features.partnerMessages) === null || _d === void 0 ? void 0 : _d.incompleteLabelPurchaseRequirements);
|
|
15751
|
-
const incompleteRequirementsError = isPartnerMessagingEnabled ? (_e = features.partnerMessages) === null || _e === void 0 ? void 0 : _e.incompleteLabelPurchaseRequirements : t("errorMessages.incompleteLabelPurchaseRequirements", {
|
|
15752
|
-
requirements: incompleteRequirementsKeys.map(key => t(`purchase-label:requirements.${key}`))
|
|
15753
|
-
});
|
|
15754
|
-
if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
|
|
15755
15742
|
if (isLoading) return jsxRuntime.jsx(Loader, {
|
|
15756
15743
|
message: t("loading.shipment")
|
|
15757
15744
|
});
|
|
@@ -15825,7 +15812,7 @@ const ShipmentForm = ({
|
|
|
15825
15812
|
}, {
|
|
15826
15813
|
children: formatDate(salesOrder.orderDate)
|
|
15827
15814
|
})), jsxRuntime.jsx(Spacer, {})]
|
|
15828
|
-
})), ((
|
|
15815
|
+
})), ((_d = salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.paymentDetails) === null || _d === void 0 ? void 0 : _d.grandTotal) && jsxRuntime.jsxs(FieldLabel, Object.assign({
|
|
15829
15816
|
label: t("purchase-label:fields.orderValue")
|
|
15830
15817
|
}, {
|
|
15831
15818
|
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
@@ -15903,7 +15890,7 @@ const ShipmentForm = ({
|
|
|
15903
15890
|
}), jsxRuntime.jsx(CustomsItemsDisplay, {
|
|
15904
15891
|
onUpdate: handleUpdateCustomsItems,
|
|
15905
15892
|
shipment: shipment
|
|
15906
|
-
}), ((
|
|
15893
|
+
}), ((_e = customsErrors === null || customsErrors === void 0 ? void 0 : customsErrors.customsItems) === null || _e === void 0 ? void 0 : _e.type) === "too_small" && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
15907
15894
|
children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(giger.InlineNotification, {
|
|
15908
15895
|
title: t("purchase-label:errorMessages.customsItemsRequired"),
|
|
15909
15896
|
type: giger.NotificationType.ERROR
|
|
@@ -16094,14 +16081,14 @@ const ShipmentForm = ({
|
|
|
16094
16081
|
label: "purchase-label:fields.addOns"
|
|
16095
16082
|
}, {
|
|
16096
16083
|
children: [jsxRuntime.jsx(Switch, Object.assign({
|
|
16097
|
-
defaultChecked: ((
|
|
16084
|
+
defaultChecked: ((_f = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _f !== void 0 ? _f : "none") !== "none",
|
|
16098
16085
|
label: t("purchase-label:fields.confirmation"),
|
|
16099
16086
|
name: "confirmationEnabled",
|
|
16100
16087
|
onChange: e => form.setValue("confirmation", e.target.checked ? alchemy.SE.ConfirmationType.DELIVERY : undefined, {
|
|
16101
16088
|
shouldDirty: true
|
|
16102
16089
|
}),
|
|
16103
16090
|
shouldUnmount: true,
|
|
16104
|
-
value: ((
|
|
16091
|
+
value: ((_g = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _g !== void 0 ? _g : "none") !== "none"
|
|
16105
16092
|
}, {
|
|
16106
16093
|
children: jsxRuntime.jsx(Select, {
|
|
16107
16094
|
control: form.control,
|
|
@@ -16113,7 +16100,7 @@ const ShipmentForm = ({
|
|
|
16113
16100
|
shouldUnregister: true
|
|
16114
16101
|
})
|
|
16115
16102
|
})), jsxRuntime.jsxs(Switch, Object.assign({
|
|
16116
|
-
defaultChecked: ((
|
|
16103
|
+
defaultChecked: ((_h = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _h !== void 0 ? _h : "none") !== "none",
|
|
16117
16104
|
label: t("purchase-label:fields.insurance"),
|
|
16118
16105
|
name: "insuranceEnabled",
|
|
16119
16106
|
onChange: e => {
|
|
@@ -16123,7 +16110,7 @@ const ShipmentForm = ({
|
|
|
16123
16110
|
});
|
|
16124
16111
|
},
|
|
16125
16112
|
shouldUnmount: true,
|
|
16126
|
-
value: ((
|
|
16113
|
+
value: ((_j = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _j !== void 0 ? _j : "none") !== "none"
|
|
16127
16114
|
}, {
|
|
16128
16115
|
children: [insuranceProviderOptions.length === 1 && insuranceProviderOptions[0].value === "carrier" ? null : jsxRuntime.jsx(Select, {
|
|
16129
16116
|
control: form.control,
|
|
@@ -16147,7 +16134,7 @@ const ShipmentForm = ({
|
|
|
16147
16134
|
showCurrencySymbol: true
|
|
16148
16135
|
})]
|
|
16149
16136
|
})), hasUpsOptions && jsxRuntime.jsx(Switch, {
|
|
16150
|
-
defaultChecked: ((
|
|
16137
|
+
defaultChecked: ((_k = shipment === null || shipment === void 0 ? void 0 : shipment.advancedOptions) === null || _k === void 0 ? void 0 : _k.additionalHandling) || false,
|
|
16151
16138
|
label: jsxRuntime.jsx(reactI18next.Trans, {
|
|
16152
16139
|
components: {
|
|
16153
16140
|
Link: jsxRuntime.jsx(giger.Link, {
|
|
@@ -18774,7 +18761,27 @@ const PurchaseLabelByShipment = _a => {
|
|
|
18774
18761
|
* @see {@link PurchaseLabel.Element | The **Element** created to render `<PurchaseLabel />`}
|
|
18775
18762
|
*/
|
|
18776
18763
|
const Component$2 = _a => {
|
|
18777
|
-
var
|
|
18764
|
+
var _b;
|
|
18765
|
+
var {
|
|
18766
|
+
features
|
|
18767
|
+
} = _a,
|
|
18768
|
+
props = __rest(_a, ["features"]);
|
|
18769
|
+
const {
|
|
18770
|
+
t
|
|
18771
|
+
} = reactI18next.useTranslation();
|
|
18772
|
+
const warehouses = alchemy.useListWarehouses();
|
|
18773
|
+
const carriers = alchemy.useListCarriers();
|
|
18774
|
+
const incompleteRequirementsKeys = React.useMemo(() => {
|
|
18775
|
+
var _a, _b;
|
|
18776
|
+
const isMissingWarehouse = ((_a = warehouses.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
18777
|
+
const isMissingCarrier = ((_b = carriers.data) === null || _b === void 0 ? void 0 : _b.length) === 0;
|
|
18778
|
+
return isMissingWarehouse && isMissingCarrier ? ["noWarehouseOrCarrier"] : [isMissingWarehouse && "noWarehouse", isMissingCarrier && "noCarrier"].filter(Boolean);
|
|
18779
|
+
}, [carriers, warehouses]);
|
|
18780
|
+
const partnerMessages = (_b = features === null || features === void 0 ? void 0 : features.partnerMessages) === null || _b === void 0 ? void 0 : _b.incompleteLabelPurchaseRequirements;
|
|
18781
|
+
const incompleteRequirementsError = partnerMessages ? partnerMessages : t("errorMessages.incompleteLabelPurchaseRequirements", {
|
|
18782
|
+
requirements: incompleteRequirementsKeys.map(key => t(`purchase-label:requirements.${key}`))
|
|
18783
|
+
});
|
|
18784
|
+
if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
|
|
18778
18785
|
if ("salesOrderId" in props || "orderSourceCode" in props) {
|
|
18779
18786
|
return jsxRuntime.jsx(PurchaseLabelBySalesOrder, Object.assign({}, props));
|
|
18780
18787
|
} else {
|
package/index.js
CHANGED
|
@@ -2616,6 +2616,14 @@ const featureFlags = {
|
|
|
2616
2616
|
* Elements.
|
|
2617
2617
|
*/
|
|
2618
2618
|
compatibleCountryCodes: ["AU", "CA", "FR", "DE", "GB", "IL", "IT", "NO", "ES", "SE", "US"],
|
|
2619
|
+
/**
|
|
2620
|
+
* @internal
|
|
2621
|
+
*
|
|
2622
|
+
* `partnerMessages` enables the partner consuming elements to specify override messages in specific cases.
|
|
2623
|
+
*/
|
|
2624
|
+
partnerMessages: {
|
|
2625
|
+
incompleteLabelPurchaseRequirements: undefined
|
|
2626
|
+
},
|
|
2619
2627
|
/**
|
|
2620
2628
|
* `rateForm` all scoped feature flags for the `rate form` section of the `<PurchaseLabel />`
|
|
2621
2629
|
* element.
|
|
@@ -2669,14 +2677,6 @@ const featureFlags = {
|
|
|
2669
2677
|
* to opt for third party insurance when insuring their shipment.
|
|
2670
2678
|
*/
|
|
2671
2679
|
includeThirdPartyInsurance: true,
|
|
2672
|
-
/**
|
|
2673
|
-
* @internal
|
|
2674
|
-
*
|
|
2675
|
-
* `partnerMessages` enables the partner consuming elements to specify override messages in specific cases.
|
|
2676
|
-
*/
|
|
2677
|
-
partnerMessages: {
|
|
2678
|
-
incompleteLabelPurchaseRequirements: undefined
|
|
2679
|
-
},
|
|
2680
2680
|
/**
|
|
2681
2681
|
* `selectService` enables the `select service` feature, allowing users to select a service
|
|
2682
2682
|
* when rate shopping across multiple carrier providers.
|
|
@@ -15379,7 +15379,7 @@ const ShipmentForm = ({
|
|
|
15379
15379
|
warehouseId,
|
|
15380
15380
|
warehouses
|
|
15381
15381
|
}) => {
|
|
15382
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
15382
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
15383
15383
|
features = Object.assign({
|
|
15384
15384
|
browseRates: true,
|
|
15385
15385
|
includeShipsuranceInsurance: true,
|
|
@@ -15565,16 +15565,16 @@ const ShipmentForm = ({
|
|
|
15565
15565
|
}, [form]);
|
|
15566
15566
|
const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
15567
15567
|
try {
|
|
15568
|
-
const
|
|
15568
|
+
const _l = values,
|
|
15569
15569
|
{
|
|
15570
15570
|
__mode: discard
|
|
15571
|
-
} =
|
|
15572
|
-
payload = __rest(
|
|
15571
|
+
} = _l,
|
|
15572
|
+
payload = __rest(_l, ["__mode"]);
|
|
15573
15573
|
const updatedShipment = yield onSubmit(Object.assign(Object.assign({}, shipment || {}), payload));
|
|
15574
15574
|
// Defer shipment hydration to the task queue so that the submission promise resolves first, otherwise the
|
|
15575
15575
|
// submission count will increment after hydration resets the form, keeping it in revalidate mode
|
|
15576
15576
|
if (updatedShipment) setTimeout(() => hydrateShipment(updatedShipment), 0);
|
|
15577
|
-
} catch (
|
|
15577
|
+
} catch (_m) {
|
|
15578
15578
|
// Reset the form to its current state, but as a side effect this sets isDirty to false
|
|
15579
15579
|
// That way, form lifecycle contract is upheld
|
|
15580
15580
|
form.reset(form.getValues());
|
|
@@ -15707,19 +15707,6 @@ const ShipmentForm = ({
|
|
|
15707
15707
|
const hasUpsOptions = useMemo(() => {
|
|
15708
15708
|
return (packageOptions === null || packageOptions === void 0 ? void 0 : packageOptions.some(option => option.label === "UPS")) && ((selectedPackage === null || selectedPackage === void 0 ? void 0 : selectedPackage.code) === "package" || selectedCarrierId === upsCarrierId);
|
|
15709
15709
|
}, [packageOptions, selectedPackage, selectedCarrierId, upsCarrierId]);
|
|
15710
|
-
const incompleteRequirementsKeys = useMemo(() => {
|
|
15711
|
-
if ((warehouses === null || warehouses === void 0 ? void 0 : warehouses.length) === 0 && (carriers === null || carriers === void 0 ? void 0 : carriers.length) === 0) {
|
|
15712
|
-
return ["noWarehouseOrCarrier"];
|
|
15713
|
-
} else {
|
|
15714
|
-
const keys = [(warehouses === null || warehouses === void 0 ? void 0 : warehouses.length) === 0 && "noWarehouse", (carriers === null || carriers === void 0 ? void 0 : carriers.length) === 0 && "noCarrier"].filter(Boolean);
|
|
15715
|
-
return keys;
|
|
15716
|
-
}
|
|
15717
|
-
}, [carriers, warehouses]);
|
|
15718
|
-
const isPartnerMessagingEnabled = !!((_d = features.partnerMessages) === null || _d === void 0 ? void 0 : _d.incompleteLabelPurchaseRequirements);
|
|
15719
|
-
const incompleteRequirementsError = isPartnerMessagingEnabled ? (_e = features.partnerMessages) === null || _e === void 0 ? void 0 : _e.incompleteLabelPurchaseRequirements : t("errorMessages.incompleteLabelPurchaseRequirements", {
|
|
15720
|
-
requirements: incompleteRequirementsKeys.map(key => t(`purchase-label:requirements.${key}`))
|
|
15721
|
-
});
|
|
15722
|
-
if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
|
|
15723
15710
|
if (isLoading) return jsx(Loader, {
|
|
15724
15711
|
message: t("loading.shipment")
|
|
15725
15712
|
});
|
|
@@ -15793,7 +15780,7 @@ const ShipmentForm = ({
|
|
|
15793
15780
|
}, {
|
|
15794
15781
|
children: formatDate(salesOrder.orderDate)
|
|
15795
15782
|
})), jsx(Spacer, {})]
|
|
15796
|
-
})), ((
|
|
15783
|
+
})), ((_d = salesOrder === null || salesOrder === void 0 ? void 0 : salesOrder.paymentDetails) === null || _d === void 0 ? void 0 : _d.grandTotal) && jsxs(FieldLabel, Object.assign({
|
|
15797
15784
|
label: t("purchase-label:fields.orderValue")
|
|
15798
15785
|
}, {
|
|
15799
15786
|
children: [jsx(Typography, Object.assign({
|
|
@@ -15871,7 +15858,7 @@ const ShipmentForm = ({
|
|
|
15871
15858
|
}), jsx(CustomsItemsDisplay, {
|
|
15872
15859
|
onUpdate: handleUpdateCustomsItems,
|
|
15873
15860
|
shipment: shipment
|
|
15874
|
-
}), ((
|
|
15861
|
+
}), ((_e = customsErrors === null || customsErrors === void 0 ? void 0 : customsErrors.customsItems) === null || _e === void 0 ? void 0 : _e.type) === "too_small" && jsxs(Fragment, {
|
|
15875
15862
|
children: [jsx(Spacer, {}), jsx(InlineNotification, {
|
|
15876
15863
|
title: t("purchase-label:errorMessages.customsItemsRequired"),
|
|
15877
15864
|
type: NotificationType.ERROR
|
|
@@ -16062,14 +16049,14 @@ const ShipmentForm = ({
|
|
|
16062
16049
|
label: "purchase-label:fields.addOns"
|
|
16063
16050
|
}, {
|
|
16064
16051
|
children: [jsx(Switch, Object.assign({
|
|
16065
|
-
defaultChecked: ((
|
|
16052
|
+
defaultChecked: ((_f = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _f !== void 0 ? _f : "none") !== "none",
|
|
16066
16053
|
label: t("purchase-label:fields.confirmation"),
|
|
16067
16054
|
name: "confirmationEnabled",
|
|
16068
16055
|
onChange: e => form.setValue("confirmation", e.target.checked ? SE.ConfirmationType.DELIVERY : undefined, {
|
|
16069
16056
|
shouldDirty: true
|
|
16070
16057
|
}),
|
|
16071
16058
|
shouldUnmount: true,
|
|
16072
|
-
value: ((
|
|
16059
|
+
value: ((_g = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _g !== void 0 ? _g : "none") !== "none"
|
|
16073
16060
|
}, {
|
|
16074
16061
|
children: jsx(Select, {
|
|
16075
16062
|
control: form.control,
|
|
@@ -16081,7 +16068,7 @@ const ShipmentForm = ({
|
|
|
16081
16068
|
shouldUnregister: true
|
|
16082
16069
|
})
|
|
16083
16070
|
})), jsxs(Switch, Object.assign({
|
|
16084
|
-
defaultChecked: ((
|
|
16071
|
+
defaultChecked: ((_h = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _h !== void 0 ? _h : "none") !== "none",
|
|
16085
16072
|
label: t("purchase-label:fields.insurance"),
|
|
16086
16073
|
name: "insuranceEnabled",
|
|
16087
16074
|
onChange: e => {
|
|
@@ -16091,7 +16078,7 @@ const ShipmentForm = ({
|
|
|
16091
16078
|
});
|
|
16092
16079
|
},
|
|
16093
16080
|
shouldUnmount: true,
|
|
16094
|
-
value: ((
|
|
16081
|
+
value: ((_j = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _j !== void 0 ? _j : "none") !== "none"
|
|
16095
16082
|
}, {
|
|
16096
16083
|
children: [insuranceProviderOptions.length === 1 && insuranceProviderOptions[0].value === "carrier" ? null : jsx(Select, {
|
|
16097
16084
|
control: form.control,
|
|
@@ -16115,7 +16102,7 @@ const ShipmentForm = ({
|
|
|
16115
16102
|
showCurrencySymbol: true
|
|
16116
16103
|
})]
|
|
16117
16104
|
})), hasUpsOptions && jsx(Switch, {
|
|
16118
|
-
defaultChecked: ((
|
|
16105
|
+
defaultChecked: ((_k = shipment === null || shipment === void 0 ? void 0 : shipment.advancedOptions) === null || _k === void 0 ? void 0 : _k.additionalHandling) || false,
|
|
16119
16106
|
label: jsx(Trans, {
|
|
16120
16107
|
components: {
|
|
16121
16108
|
Link: jsx(Link, {
|
|
@@ -18742,7 +18729,27 @@ const PurchaseLabelByShipment = _a => {
|
|
|
18742
18729
|
* @see {@link PurchaseLabel.Element | The **Element** created to render `<PurchaseLabel />`}
|
|
18743
18730
|
*/
|
|
18744
18731
|
const Component$2 = _a => {
|
|
18745
|
-
var
|
|
18732
|
+
var _b;
|
|
18733
|
+
var {
|
|
18734
|
+
features
|
|
18735
|
+
} = _a,
|
|
18736
|
+
props = __rest(_a, ["features"]);
|
|
18737
|
+
const {
|
|
18738
|
+
t
|
|
18739
|
+
} = useTranslation();
|
|
18740
|
+
const warehouses = useListWarehouses();
|
|
18741
|
+
const carriers = useListCarriers();
|
|
18742
|
+
const incompleteRequirementsKeys = useMemo(() => {
|
|
18743
|
+
var _a, _b;
|
|
18744
|
+
const isMissingWarehouse = ((_a = warehouses.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
18745
|
+
const isMissingCarrier = ((_b = carriers.data) === null || _b === void 0 ? void 0 : _b.length) === 0;
|
|
18746
|
+
return isMissingWarehouse && isMissingCarrier ? ["noWarehouseOrCarrier"] : [isMissingWarehouse && "noWarehouse", isMissingCarrier && "noCarrier"].filter(Boolean);
|
|
18747
|
+
}, [carriers, warehouses]);
|
|
18748
|
+
const partnerMessages = (_b = features === null || features === void 0 ? void 0 : features.partnerMessages) === null || _b === void 0 ? void 0 : _b.incompleteLabelPurchaseRequirements;
|
|
18749
|
+
const incompleteRequirementsError = partnerMessages ? partnerMessages : t("errorMessages.incompleteLabelPurchaseRequirements", {
|
|
18750
|
+
requirements: incompleteRequirementsKeys.map(key => t(`purchase-label:requirements.${key}`))
|
|
18751
|
+
});
|
|
18752
|
+
if (incompleteRequirementsKeys.length > 0) throw new Error(incompleteRequirementsError);
|
|
18746
18753
|
if ("salesOrderId" in props || "orderSourceCode" in props) {
|
|
18747
18754
|
return jsx(PurchaseLabelBySalesOrder, Object.assign({}, props));
|
|
18748
18755
|
} else {
|
package/package.json
CHANGED
|
@@ -12,9 +12,6 @@ export type ShipmentFormFeatures = {
|
|
|
12
12
|
browseRates?: boolean;
|
|
13
13
|
includeShipsuranceInsurance?: boolean;
|
|
14
14
|
includeThirdPartyInsurance?: boolean;
|
|
15
|
-
partnerMessages?: {
|
|
16
|
-
incompleteLabelPurchaseRequirements?: string;
|
|
17
|
-
};
|
|
18
15
|
selectService?: boolean;
|
|
19
16
|
shippingPresets?: boolean;
|
|
20
17
|
};
|
|
@@ -25,6 +25,9 @@ export type RateFormFeatures = {
|
|
|
25
25
|
};
|
|
26
26
|
export type ConfigureShipmentFeatures = {
|
|
27
27
|
compatibleCountryCodes?: UseShipmentFormProps["compatibleCountryCodes"];
|
|
28
|
+
partnerMessages?: {
|
|
29
|
+
incompleteLabelPurchaseRequirements?: string;
|
|
30
|
+
};
|
|
28
31
|
presentation?: {
|
|
29
32
|
poweredByShipEngine?: boolean;
|
|
30
33
|
};
|
|
@@ -149,7 +149,7 @@ export type ElementProps = PurchaseLabelByShipmentProps | PurchaseLabelSalesOrde
|
|
|
149
149
|
*
|
|
150
150
|
* @see {@link PurchaseLabel.Element | The **Element** created to render `<PurchaseLabel />`}
|
|
151
151
|
*/
|
|
152
|
-
export declare const Component: ({ ...props }: ElementProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
152
|
+
export declare const Component: ({ features, ...props }: ElementProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
153
153
|
/**
|
|
154
154
|
* # Registered Purchase Label Element
|
|
155
155
|
*
|
|
@@ -254,7 +254,14 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
254
254
|
highVolumeForms: string;
|
|
255
255
|
multipleShippingServices: string;
|
|
256
256
|
sections: {
|
|
257
|
-
labels: string;
|
|
257
|
+
labels: string; /**
|
|
258
|
+
*`getPreferredRates is an async/sync optional callback function that will be invoked each time rates are caculated.
|
|
259
|
+
* This is an optional callback function that returns an array of ShipEngine rates. The rates from this response will
|
|
260
|
+
* be spliced into the normal get rates response the Elements makes internally. If a service code matches a service
|
|
261
|
+
* code on a rate returned from getPreferredRates, the rate returned from getPreferredRates will not be shown in the
|
|
262
|
+
* rate form. These preferred rates will be displayed with a set of UI enhancements that incude a dynamic cost savings
|
|
263
|
+
* flag and green checkmark when the rate is selected.
|
|
264
|
+
*/
|
|
258
265
|
};
|
|
259
266
|
noLabels: string;
|
|
260
267
|
};
|
|
@@ -328,22 +335,12 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
328
335
|
currentBalance: string;
|
|
329
336
|
insufficientBalanceCTA: string;
|
|
330
337
|
};
|
|
331
|
-
/**
|
|
332
|
-
* # Purchase Label Component Props
|
|
333
|
-
*
|
|
334
|
-
* These are the shared props that will be passed into the `<PurchaseLabel.Element />`, and work
|
|
335
|
-
* for either shipment-based or sales order-based label purchasing.
|
|
336
|
-
*
|
|
337
|
-
* @see {@link PurchaseLabel.Element | This prop types usage in `<PurchaseLabel.Element />`}
|
|
338
|
-
*/
|
|
339
338
|
cta: {
|
|
340
339
|
addPackageDetails: string;
|
|
341
340
|
};
|
|
342
341
|
errorMessages: {
|
|
343
342
|
customsItemsRequired: string;
|
|
344
|
-
invalidAddress: string;
|
|
345
|
-
* `features` is a set of feature flags you would like to enable or disable in this component.
|
|
346
|
-
*/
|
|
343
|
+
invalidAddress: string;
|
|
347
344
|
noRates: string;
|
|
348
345
|
salesOrderNotLoaded: string;
|
|
349
346
|
unsupportedAddress: string;
|
|
@@ -367,19 +364,13 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
367
364
|
estimatedShipping: string;
|
|
368
365
|
insurance: string;
|
|
369
366
|
insuranceProvider: string;
|
|
370
|
-
insuredValue: string;
|
|
371
|
-
* `onApplyPreset` is an async/sync callback function that will be invoked each time a `Preset`
|
|
372
|
-
* has been applied to a shipment.
|
|
373
|
-
*/
|
|
367
|
+
insuredValue: string;
|
|
374
368
|
items: string;
|
|
375
369
|
orderDate: string;
|
|
376
370
|
orderValue: string;
|
|
377
371
|
packageCode: string;
|
|
378
372
|
requestedShipping: string;
|
|
379
|
-
shipDate: string;
|
|
380
|
-
* `onBeforeLabelCreate` is an async/sync callback function that will be invoked before every
|
|
381
|
-
* label purchase.
|
|
382
|
-
*/
|
|
373
|
+
shipDate: string;
|
|
383
374
|
service: string;
|
|
384
375
|
shipTo: string;
|
|
385
376
|
addShipToAddress: string;
|
|
@@ -392,6 +383,10 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
392
383
|
today: string;
|
|
393
384
|
};
|
|
394
385
|
hints: {
|
|
386
|
+
/**
|
|
387
|
+
* `onBeforeRateSave` is an async/sync callback function that will be invoked before each time a user
|
|
388
|
+
* saves a rate.
|
|
389
|
+
*/
|
|
395
390
|
contentDescription: string;
|
|
396
391
|
};
|
|
397
392
|
loading: {
|
|
@@ -410,15 +405,15 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
410
405
|
rates: {
|
|
411
406
|
uspsMediaMailAcknowledgement: string;
|
|
412
407
|
uspsFirstClassMailAcknowledgement_leof: string;
|
|
413
|
-
rateSavings: string;
|
|
408
|
+
rateSavings: string; /**
|
|
409
|
+
* `onLabelCreateSuccess` is an async/sync callback provided by the client that is invoked if the
|
|
410
|
+
* label is successfully created/purchased.
|
|
411
|
+
*/
|
|
414
412
|
upsGroundSaverTermsAcknowledgement: string;
|
|
415
413
|
dhlExpressTermsAcknowledgement: string;
|
|
416
414
|
};
|
|
417
415
|
requirements: {
|
|
418
|
-
noWarehouse: string;
|
|
419
|
-
* `onRateSaved` is an async/sync callback function that will be invoked each time a rate is
|
|
420
|
-
* saved by the user when rate shopping in the host application.
|
|
421
|
-
*/
|
|
416
|
+
noWarehouse: string;
|
|
422
417
|
noCarrier: string;
|
|
423
418
|
noWarehouseOrCarrier: string;
|
|
424
419
|
};
|
|
@@ -458,6 +453,9 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
458
453
|
inlineMessage: string;
|
|
459
454
|
};
|
|
460
455
|
success: {
|
|
456
|
+
/**
|
|
457
|
+
* `features` is a set of feature flags you would like to enable or disable in this component.
|
|
458
|
+
*/
|
|
461
459
|
title: string;
|
|
462
460
|
subtitle: string;
|
|
463
461
|
action: string;
|
|
@@ -482,14 +480,6 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
482
480
|
status: {
|
|
483
481
|
saving: string;
|
|
484
482
|
saved: string;
|
|
485
|
-
/**
|
|
486
|
-
* # Purchase Label Component Props
|
|
487
|
-
*
|
|
488
|
-
* These are the shared props that will be passed into the `<PurchaseLabel.Element />`, and work
|
|
489
|
-
* for either shipment-based or sales order-based label purchasing.
|
|
490
|
-
*
|
|
491
|
-
* @see {@link PurchaseLabel.Element | This prop types usage in `<PurchaseLabel.Element />`}
|
|
492
|
-
*/
|
|
493
483
|
savingFailed: string;
|
|
494
484
|
};
|
|
495
485
|
units: {
|
|
@@ -503,9 +493,7 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
503
493
|
title: string;
|
|
504
494
|
standard: string;
|
|
505
495
|
g: string;
|
|
506
|
-
kg: string;
|
|
507
|
-
* `features` is a set of feature flags you would like to enable or disable in this component.
|
|
508
|
-
*/
|
|
496
|
+
kg: string;
|
|
509
497
|
};
|
|
510
498
|
};
|
|
511
499
|
};
|
|
@@ -683,10 +671,7 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
683
671
|
none: string;
|
|
684
672
|
signature: string;
|
|
685
673
|
verbalConfirmation: string;
|
|
686
|
-
};
|
|
687
|
-
* `onLabelCreateFailure` is an async/sync callback function that will be invoked each time a
|
|
688
|
-
* label purchase fails.
|
|
689
|
-
*/
|
|
674
|
+
};
|
|
690
675
|
customs: {
|
|
691
676
|
addDeclaration: string;
|
|
692
677
|
contents: {
|
|
@@ -725,6 +710,12 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
725
710
|
autoFundingSettings: string;
|
|
726
711
|
carrier: string;
|
|
727
712
|
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
|
+
*/
|
|
728
719
|
label: string;
|
|
729
720
|
salesOrder: string;
|
|
730
721
|
shipment: string;
|
|
@@ -757,7 +748,10 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
|
|
|
757
748
|
connectingCarriers: string;
|
|
758
749
|
data: string;
|
|
759
750
|
importingSalesOrder: string;
|
|
760
|
-
label: 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
|
+
*/
|
|
761
755
|
onboarding: string;
|
|
762
756
|
salesOrder: string;
|
|
763
757
|
shipment: string;
|
|
@@ -51,6 +51,14 @@ 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
|
+
* @internal
|
|
56
|
+
*
|
|
57
|
+
* `partnerMessages` enables the partner consuming elements to specify override messages in specific cases.
|
|
58
|
+
*/
|
|
59
|
+
readonly partnerMessages: {
|
|
60
|
+
readonly incompleteLabelPurchaseRequirements: undefined;
|
|
61
|
+
};
|
|
54
62
|
/**
|
|
55
63
|
* `rateForm` all scoped feature flags for the `rate form` section of the `<PurchaseLabel />`
|
|
56
64
|
* element.
|
|
@@ -104,14 +112,6 @@ export declare const featureFlags: {
|
|
|
104
112
|
* to opt for third party insurance when insuring their shipment.
|
|
105
113
|
*/
|
|
106
114
|
readonly includeThirdPartyInsurance: true;
|
|
107
|
-
/**
|
|
108
|
-
* @internal
|
|
109
|
-
*
|
|
110
|
-
* `partnerMessages` enables the partner consuming elements to specify override messages in specific cases.
|
|
111
|
-
*/
|
|
112
|
-
readonly partnerMessages: {
|
|
113
|
-
readonly incompleteLabelPurchaseRequirements: undefined;
|
|
114
|
-
};
|
|
115
115
|
/**
|
|
116
116
|
* `selectService` enables the `select service` feature, allowing users to select a service
|
|
117
117
|
* when rate shopping across multiple carrier providers.
|