@shipengine/elements 0.9.15 → 0.10.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/components/configure-shipment/configure-shipment.d.ts +6 -1
- package/components/configure-shipment/hooks/use-customs.d.ts +1 -1
- package/components/configure-shipment/hooks/use-rates-form.d.ts +2 -0
- package/components/configure-shipment/hooks/use-shipment-form.d.ts +2 -2
- package/index.cjs +31 -5
- package/index.js +31 -5
- package/package.json +4 -4
|
@@ -3,8 +3,13 @@ import * as SE from "@shipengine/types";
|
|
|
3
3
|
import { UseShippingPresetsOptionsProps } from "@shipengine/elements-ui";
|
|
4
4
|
import { UseRatesFormProps, UseShipmentFormProps } from "./hooks";
|
|
5
5
|
export type ShipmentFormMode = "browse_rates" | "select_service";
|
|
6
|
+
export type Features = {
|
|
7
|
+
shipmentForm?: Templates.ShipmentFormFeatures;
|
|
8
|
+
rateForm?: Templates.RateFormFeatures;
|
|
9
|
+
};
|
|
6
10
|
export type ConfigureShipmentProps = {
|
|
7
11
|
errors?: Templates.ShipmentFormProps["errors"];
|
|
12
|
+
features?: Features;
|
|
8
13
|
isLoading?: Templates.ShipmentFormProps["isLoading"];
|
|
9
14
|
onAddressValidation?: UseShipmentFormProps["onAddressValidation"];
|
|
10
15
|
onApplyPreset?: UseShipmentFormProps["onApplyPreset"];
|
|
@@ -23,4 +28,4 @@ export type ConfigureShipmentProps = {
|
|
|
23
28
|
shippingPresets?: UseShippingPresetsOptionsProps;
|
|
24
29
|
warehouseId?: string;
|
|
25
30
|
};
|
|
26
|
-
export declare const ConfigureShipment: ({ onAddressValidation, onApplyPreset, onBeforeLabelCreate, onChangeAddress, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, salesOrder, shipment, ...props }: ConfigureShipmentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare const ConfigureShipment: ({ features, onAddressValidation, onApplyPreset, onBeforeLabelCreate, onChangeAddress, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, salesOrder, shipment, ...props }: ConfigureShipmentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -4,6 +4,6 @@ export type UseCustomsProps = {
|
|
|
4
4
|
shipment?: SE.SalesOrderShipment;
|
|
5
5
|
};
|
|
6
6
|
export declare const useCustoms: ({ onUpdate, shipment }: UseCustomsProps) => {
|
|
7
|
-
handleUpdateCustoms: (customs: SE.Customs) => Promise<
|
|
7
|
+
handleUpdateCustoms: (customs: SE.Customs) => Promise<SE.SalesOrderShipment | undefined>;
|
|
8
8
|
customsErrors: SE.CodedError[] | undefined;
|
|
9
9
|
};
|
|
@@ -13,11 +13,13 @@ export type UseRatesFormProps = {
|
|
|
13
13
|
export declare const useRatesForm: ({ onBeforeLabelCreate, onLabelCreateFailure, onLabelCreateSuccess, onRateSaved, onRatesCalculated, onShipmentUpdated, printLabelLayout, shipment, }: UseRatesFormProps) => {
|
|
14
14
|
carriers: SE.Carrier[] | undefined;
|
|
15
15
|
errors: SE.CodedError[] | undefined;
|
|
16
|
+
labelErrors: SE.CodedError[] | undefined;
|
|
16
17
|
isLoading: boolean;
|
|
17
18
|
onSave: ({ carrierId, serviceCode }: Pick<SE.Rate, "carrierId" | "serviceCode">) => Promise<void>;
|
|
18
19
|
onSubmit: (rateId: string) => Promise<void>;
|
|
19
20
|
rates: SE.Rate[] | undefined;
|
|
20
21
|
requestRates: (shipment: SE.SalesOrderShipment) => Promise<void>;
|
|
22
|
+
resetLabel: () => void;
|
|
21
23
|
resetRates: () => void;
|
|
22
24
|
shipment: SE.SalesOrderShipment | undefined;
|
|
23
25
|
};
|
|
@@ -18,11 +18,11 @@ export declare const useShipmentForm: ({ onAddressValidation, onApplyPreset, onC
|
|
|
18
18
|
errors: SE.CodedError[] | undefined;
|
|
19
19
|
onApplyPreset: (preset: ShippingPreset) => Promise<void>;
|
|
20
20
|
onChangeAddress: (shipTo: SE.Address, { shouldValidate }: import("dist/elements-ui/components/templates").OnChangeAddressOptions) => Promise<void>;
|
|
21
|
-
onSubmit: (values: Partial<SE.SalesOrderShipment>) => Promise<
|
|
21
|
+
onSubmit: (values: Partial<SE.SalesOrderShipment>) => Promise<SE.SalesOrderShipment | undefined>;
|
|
22
22
|
onSubmitParseShipTo: ({ fullAddress }: {
|
|
23
23
|
fullAddress: string;
|
|
24
24
|
}) => Promise<SE.AddressParseResponse | undefined>;
|
|
25
|
-
onUpdateCustoms: (customs: SE.Customs) => Promise<
|
|
25
|
+
onUpdateCustoms: (customs: SE.Customs) => Promise<SE.SalesOrderShipment | undefined>;
|
|
26
26
|
salesOrder: SE.SalesOrder;
|
|
27
27
|
shipment: SE.SalesOrderShipment | undefined;
|
|
28
28
|
warehouses: SE.Warehouse[] | undefined;
|
package/index.cjs
CHANGED
|
@@ -19003,6 +19003,7 @@ const useCustoms = ({
|
|
|
19003
19003
|
if (updatedShipment) {
|
|
19004
19004
|
yield onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(updatedShipment);
|
|
19005
19005
|
}
|
|
19006
|
+
return updatedShipment;
|
|
19006
19007
|
}), [onUpdate, shipment, updateShipment]);
|
|
19007
19008
|
return {
|
|
19008
19009
|
handleUpdateCustoms,
|
|
@@ -19338,6 +19339,8 @@ const useRatesForm = ({
|
|
|
19338
19339
|
shipmentId: shipment === null || shipment === void 0 ? void 0 : shipment.shipmentId
|
|
19339
19340
|
});
|
|
19340
19341
|
const {
|
|
19342
|
+
errors: labelErrors,
|
|
19343
|
+
reset: resetLabel,
|
|
19341
19344
|
trigger: createLabel
|
|
19342
19345
|
} = elementsCore.useCreateLabel(printLabelLayout);
|
|
19343
19346
|
const {
|
|
@@ -19408,11 +19411,13 @@ const useRatesForm = ({
|
|
|
19408
19411
|
return {
|
|
19409
19412
|
carriers,
|
|
19410
19413
|
errors: errors.length > 0 ? errors : undefined,
|
|
19414
|
+
labelErrors: (labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length) ? labelErrors : undefined,
|
|
19411
19415
|
isLoading: ratesCalculating,
|
|
19412
19416
|
onSave: handleSave,
|
|
19413
19417
|
onSubmit: handleSubmit,
|
|
19414
19418
|
rates: ratesResponse === null || ratesResponse === void 0 ? void 0 : ratesResponse.rates,
|
|
19415
19419
|
requestRates,
|
|
19420
|
+
resetLabel,
|
|
19416
19421
|
resetRates,
|
|
19417
19422
|
shipment
|
|
19418
19423
|
};
|
|
@@ -19479,6 +19484,7 @@ const useShipmentForm = ({
|
|
|
19479
19484
|
yield onShipmentUpdated === null || onShipmentUpdated === void 0 ? void 0 : onShipmentUpdated(updatedShipment);
|
|
19480
19485
|
yield onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(updatedShipment);
|
|
19481
19486
|
}
|
|
19487
|
+
return updatedShipment;
|
|
19482
19488
|
}), [onShipmentUpdated, onSubmit, updateShipment]);
|
|
19483
19489
|
const errors = [...(addressErrors !== null && addressErrors !== void 0 ? addressErrors : []), ...(customsErrors !== null && customsErrors !== void 0 ? customsErrors : []), ...(presetErrors !== null && presetErrors !== void 0 ? presetErrors : []), ...(updateShipmentErrors !== null && updateShipmentErrors !== void 0 ? updateShipmentErrors : [])];
|
|
19484
19490
|
return {
|
|
@@ -19499,6 +19505,7 @@ const useShipmentForm = ({
|
|
|
19499
19505
|
|
|
19500
19506
|
const ConfigureShipment = _a => {
|
|
19501
19507
|
var {
|
|
19508
|
+
features,
|
|
19502
19509
|
onAddressValidation,
|
|
19503
19510
|
onApplyPreset,
|
|
19504
19511
|
onBeforeLabelCreate,
|
|
@@ -19512,7 +19519,7 @@ const ConfigureShipment = _a => {
|
|
|
19512
19519
|
salesOrder,
|
|
19513
19520
|
shipment
|
|
19514
19521
|
} = _a,
|
|
19515
|
-
props = __rest(_a, ["onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "salesOrder", "shipment"]);
|
|
19522
|
+
props = __rest(_a, ["features", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "salesOrder", "shipment"]);
|
|
19516
19523
|
const _b = useRatesForm({
|
|
19517
19524
|
onBeforeLabelCreate,
|
|
19518
19525
|
onLabelCreateFailure,
|
|
@@ -19524,10 +19531,11 @@ const ConfigureShipment = _a => {
|
|
|
19524
19531
|
shipment
|
|
19525
19532
|
}),
|
|
19526
19533
|
{
|
|
19534
|
+
requestRates,
|
|
19527
19535
|
resetRates,
|
|
19528
|
-
|
|
19536
|
+
resetLabel
|
|
19529
19537
|
} = _b,
|
|
19530
|
-
rateFormProps = __rest(_b, ["resetRates", "
|
|
19538
|
+
rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel"]);
|
|
19531
19539
|
const shipmentFormProps = useShipmentForm({
|
|
19532
19540
|
onAddressValidation,
|
|
19533
19541
|
onApplyPreset: react.useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -19543,10 +19551,28 @@ const ConfigureShipment = _a => {
|
|
|
19543
19551
|
salesOrder,
|
|
19544
19552
|
shipment
|
|
19545
19553
|
});
|
|
19554
|
+
const [rateFormDisabled, setRateFormDisabled] = react.useState(false);
|
|
19555
|
+
const handleCharsetWarning = react.useCallback(charsetWarning => {
|
|
19556
|
+
if (charsetWarning === null || charsetWarning === void 0 ? void 0 : charsetWarning.error) {
|
|
19557
|
+
setRateFormDisabled(true);
|
|
19558
|
+
} else {
|
|
19559
|
+
setRateFormDisabled(false);
|
|
19560
|
+
}
|
|
19561
|
+
}, []);
|
|
19562
|
+
const handleOnDirty = react.useCallback(() => {
|
|
19563
|
+
resetRates();
|
|
19564
|
+
resetLabel();
|
|
19565
|
+
}, [resetRates, resetLabel]);
|
|
19546
19566
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
19547
19567
|
children: [jsxRuntime.jsx(elementsUi.Templates.ShipmentForm, Object.assign({}, shipmentFormProps, props, {
|
|
19548
|
-
onDirty:
|
|
19549
|
-
|
|
19568
|
+
onDirty: handleOnDirty,
|
|
19569
|
+
onCharsetWarning: handleCharsetWarning,
|
|
19570
|
+
features: features === null || features === void 0 ? void 0 : features.shipmentForm
|
|
19571
|
+
})), jsxRuntime.jsx(elementsUi.Templates.RateForm, Object.assign({}, rateFormProps, {
|
|
19572
|
+
disabled: rateFormDisabled,
|
|
19573
|
+
features: features === null || features === void 0 ? void 0 : features.rateForm,
|
|
19574
|
+
onSelectRate: resetLabel
|
|
19575
|
+
}))]
|
|
19550
19576
|
});
|
|
19551
19577
|
};
|
|
19552
19578
|
|
package/index.js
CHANGED
|
@@ -18999,6 +18999,7 @@ const useCustoms = ({
|
|
|
18999
18999
|
if (updatedShipment) {
|
|
19000
19000
|
yield onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(updatedShipment);
|
|
19001
19001
|
}
|
|
19002
|
+
return updatedShipment;
|
|
19002
19003
|
}), [onUpdate, shipment, updateShipment]);
|
|
19003
19004
|
return {
|
|
19004
19005
|
handleUpdateCustoms,
|
|
@@ -19334,6 +19335,8 @@ const useRatesForm = ({
|
|
|
19334
19335
|
shipmentId: shipment === null || shipment === void 0 ? void 0 : shipment.shipmentId
|
|
19335
19336
|
});
|
|
19336
19337
|
const {
|
|
19338
|
+
errors: labelErrors,
|
|
19339
|
+
reset: resetLabel,
|
|
19337
19340
|
trigger: createLabel
|
|
19338
19341
|
} = useCreateLabel(printLabelLayout);
|
|
19339
19342
|
const {
|
|
@@ -19404,11 +19407,13 @@ const useRatesForm = ({
|
|
|
19404
19407
|
return {
|
|
19405
19408
|
carriers,
|
|
19406
19409
|
errors: errors.length > 0 ? errors : undefined,
|
|
19410
|
+
labelErrors: (labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length) ? labelErrors : undefined,
|
|
19407
19411
|
isLoading: ratesCalculating,
|
|
19408
19412
|
onSave: handleSave,
|
|
19409
19413
|
onSubmit: handleSubmit,
|
|
19410
19414
|
rates: ratesResponse === null || ratesResponse === void 0 ? void 0 : ratesResponse.rates,
|
|
19411
19415
|
requestRates,
|
|
19416
|
+
resetLabel,
|
|
19412
19417
|
resetRates,
|
|
19413
19418
|
shipment
|
|
19414
19419
|
};
|
|
@@ -19475,6 +19480,7 @@ const useShipmentForm = ({
|
|
|
19475
19480
|
yield onShipmentUpdated === null || onShipmentUpdated === void 0 ? void 0 : onShipmentUpdated(updatedShipment);
|
|
19476
19481
|
yield onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(updatedShipment);
|
|
19477
19482
|
}
|
|
19483
|
+
return updatedShipment;
|
|
19478
19484
|
}), [onShipmentUpdated, onSubmit, updateShipment]);
|
|
19479
19485
|
const errors = [...(addressErrors !== null && addressErrors !== void 0 ? addressErrors : []), ...(customsErrors !== null && customsErrors !== void 0 ? customsErrors : []), ...(presetErrors !== null && presetErrors !== void 0 ? presetErrors : []), ...(updateShipmentErrors !== null && updateShipmentErrors !== void 0 ? updateShipmentErrors : [])];
|
|
19480
19486
|
return {
|
|
@@ -19495,6 +19501,7 @@ const useShipmentForm = ({
|
|
|
19495
19501
|
|
|
19496
19502
|
const ConfigureShipment = _a => {
|
|
19497
19503
|
var {
|
|
19504
|
+
features,
|
|
19498
19505
|
onAddressValidation,
|
|
19499
19506
|
onApplyPreset,
|
|
19500
19507
|
onBeforeLabelCreate,
|
|
@@ -19508,7 +19515,7 @@ const ConfigureShipment = _a => {
|
|
|
19508
19515
|
salesOrder,
|
|
19509
19516
|
shipment
|
|
19510
19517
|
} = _a,
|
|
19511
|
-
props = __rest(_a, ["onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "salesOrder", "shipment"]);
|
|
19518
|
+
props = __rest(_a, ["features", "onAddressValidation", "onApplyPreset", "onBeforeLabelCreate", "onChangeAddress", "onLabelCreateFailure", "onLabelCreateSuccess", "onRateSaved", "onRatesCalculated", "onShipmentUpdated", "printLabelLayout", "salesOrder", "shipment"]);
|
|
19512
19519
|
const _b = useRatesForm({
|
|
19513
19520
|
onBeforeLabelCreate,
|
|
19514
19521
|
onLabelCreateFailure,
|
|
@@ -19520,10 +19527,11 @@ const ConfigureShipment = _a => {
|
|
|
19520
19527
|
shipment
|
|
19521
19528
|
}),
|
|
19522
19529
|
{
|
|
19530
|
+
requestRates,
|
|
19523
19531
|
resetRates,
|
|
19524
|
-
|
|
19532
|
+
resetLabel
|
|
19525
19533
|
} = _b,
|
|
19526
|
-
rateFormProps = __rest(_b, ["resetRates", "
|
|
19534
|
+
rateFormProps = __rest(_b, ["requestRates", "resetRates", "resetLabel"]);
|
|
19527
19535
|
const shipmentFormProps = useShipmentForm({
|
|
19528
19536
|
onAddressValidation,
|
|
19529
19537
|
onApplyPreset: useCallback((_preset, shipment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -19539,10 +19547,28 @@ const ConfigureShipment = _a => {
|
|
|
19539
19547
|
salesOrder,
|
|
19540
19548
|
shipment
|
|
19541
19549
|
});
|
|
19550
|
+
const [rateFormDisabled, setRateFormDisabled] = useState(false);
|
|
19551
|
+
const handleCharsetWarning = useCallback(charsetWarning => {
|
|
19552
|
+
if (charsetWarning === null || charsetWarning === void 0 ? void 0 : charsetWarning.error) {
|
|
19553
|
+
setRateFormDisabled(true);
|
|
19554
|
+
} else {
|
|
19555
|
+
setRateFormDisabled(false);
|
|
19556
|
+
}
|
|
19557
|
+
}, []);
|
|
19558
|
+
const handleOnDirty = useCallback(() => {
|
|
19559
|
+
resetRates();
|
|
19560
|
+
resetLabel();
|
|
19561
|
+
}, [resetRates, resetLabel]);
|
|
19542
19562
|
return jsxs(Fragment, {
|
|
19543
19563
|
children: [jsx(Templates.ShipmentForm, Object.assign({}, shipmentFormProps, props, {
|
|
19544
|
-
onDirty:
|
|
19545
|
-
|
|
19564
|
+
onDirty: handleOnDirty,
|
|
19565
|
+
onCharsetWarning: handleCharsetWarning,
|
|
19566
|
+
features: features === null || features === void 0 ? void 0 : features.shipmentForm
|
|
19567
|
+
})), jsx(Templates.RateForm, Object.assign({}, rateFormProps, {
|
|
19568
|
+
disabled: rateFormDisabled,
|
|
19569
|
+
features: features === null || features === void 0 ? void 0 : features.rateForm,
|
|
19570
|
+
onSelectRate: resetLabel
|
|
19571
|
+
}))]
|
|
19546
19572
|
});
|
|
19547
19573
|
};
|
|
19548
19574
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipengine/elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@packlink/giger": "*",
|
|
6
6
|
"react-i18next": "*",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"types": "./index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"react": "^18.2.0",
|
|
15
|
-
"@shipengine/elements-core": "0.
|
|
16
|
-
"@shipengine/elements-ui": "0.
|
|
17
|
-
"@shipengine/types": "0.
|
|
15
|
+
"@shipengine/elements-core": "0.10.1",
|
|
16
|
+
"@shipengine/elements-ui": "0.10.1",
|
|
17
|
+
"@shipengine/types": "0.10.1",
|
|
18
18
|
"@emotion/react": "^11.10.0",
|
|
19
19
|
"@packlink/brands": "^3.18.0"
|
|
20
20
|
}
|