@shipengine/elements 1.5.0 → 1.5.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 +1168 -948
- package/index.js +1168 -950
- package/package.json +1 -1
- package/src/elements/index.d.ts +2 -0
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useEffect, useRef, createElement as createElement$2, forwardRef, useCallback, useReducer, useMemo, useState, createContext, useContext, memo, useLayoutEffect, Fragment as Fragment$1 } from 'react';
|
|
4
4
|
import { useController, get as get$2, set as set$2, useWatch, useFormState, useForm } from 'react-hook-form';
|
|
5
5
|
import { useTranslation, Trans } from 'react-i18next';
|
|
6
|
-
import alchemy, { logger, SE, useAlchemy, useListServicePoints, useValidateAddresses, useAddFunds, useGetCarrierById, useUpdateAutoFunding, useGetAutoFundingConfiguration, useUpdateFundingSource, useListFundingSources, useConnectCarrierAccount, useGetCarrierConnectionForm, useListCarrierConnections, useListCarriers, useConnectCarrier, useListWarehouses, useUpdateWarehouse, useCreateWarehouse, useDeleteWarehouse, useGetFundingSourceTransactions, useListSalesOrderShipments, useGetAccountSettings, useUpdateAccountSettings, useUpdateSalesOrderShipment, useParseAddress, useListCustomPackageTypes, useCalculateRates, useGetShipmentRates, useListLabels, useCreateLabel, useCreateSalesOrderShipment, CodedError, useListSalesOrders, useGetSalesOrder, useListOrderSources, useRefreshOrderSource, useGetInsuranceAccount, useCreateShipment, useGetShipment, useGetSalesOrderShipment, useGetLabel, useVoidLabel, useCreateFundingSource, useRegisterCarrier, useGetFundingSourceMetadata } from '@shipengine/alchemy';
|
|
6
|
+
import alchemy, { logger, SE, useAlchemy, useListServicePoints, useValidateAddresses, useAddFunds, useGetCarrierById, useUpdateAutoFunding, useGetAutoFundingConfiguration, useUpdateFundingSource, useListFundingSources, useConnectCarrierAccount, useGetCarrierConnectionForm, useListCarrierConnections, useListCarriers, useConnectCarrier, useListWarehouses, useUpdateWarehouse, useCreateWarehouse, useDeleteWarehouse, useGetFundingSourceTransactions, useListSalesOrderShipments, useGetAccountSettings, useUpdateAccountSettings, useUpdateSalesOrderShipment, useParseAddress, useListCustomPackageTypes, useCalculateRates, useGetShipmentRates, useListLabels, useCreateLabel, useCreateSalesOrderShipment, CodedError, useListSalesOrders, useGetSalesOrder, useListOrderSources, useRefreshOrderSource, useGetInsuranceAccount, useCreateShipment, useGetShipment, useGetSalesOrderShipment, useGetLabel, useVoidLabel, useListShipments, useCreateFundingSource, useRegisterCarrier, useGetFundingSourceMetadata } from '@shipengine/alchemy';
|
|
7
7
|
import { Typography, IconTooltip, IconSize, FormField, FieldMessageType, Checkbox, Input, Icon, InlineNotification, NotificationType, Tag, TagColor, TagVariant, Divider, Button, ButtonVariant, Skeleton, SkeletonAnimation, SkeletonBackgroundColor, SkeletonVariant, Link, SelectAutocomplete, Select as Select$1, OptionGroup, Option, Switch as Switch$1, Textarea, Spinner, SpinnerSize, ChipList, Chip, ButtonSize, DatePicker as DatePicker$1, Table, TableFooter, TableHeader, TableHeaderRow, TableHeaderCell, TableBody, TableRow, TableBodyCell, TableBaseRow, DropdownOptionList, Pagination, Grid, GridChild, RadioGroup, Radio, ButtonColor, Dialog, DialogHeader, ButtonIcon, DialogContent, Popover, BottomSheet, Stepper, Step } from '@shipengine/giger';
|
|
8
8
|
import { format, parse } from 'date-fns';
|
|
9
9
|
import * as Locales from 'date-fns/locale';
|
|
@@ -15148,7 +15148,7 @@ var en = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(O
|
|
|
15148
15148
|
*
|
|
15149
15149
|
* @see {@link ConnectCarrier.ComponentProps | The props that are passed into the `<ConnectCarrier />` component}
|
|
15150
15150
|
*/
|
|
15151
|
-
const Component$
|
|
15151
|
+
const Component$b = ({
|
|
15152
15152
|
carrierName,
|
|
15153
15153
|
features,
|
|
15154
15154
|
onCancel,
|
|
@@ -15217,7 +15217,7 @@ const Component$9 = ({
|
|
|
15217
15217
|
}
|
|
15218
15218
|
});
|
|
15219
15219
|
};
|
|
15220
|
-
alchemy.createElement(Component$
|
|
15220
|
+
alchemy.createElement(Component$b, ErrorFallback, {
|
|
15221
15221
|
css: {
|
|
15222
15222
|
height: "100%",
|
|
15223
15223
|
maxWidth: "800px",
|
|
@@ -15253,7 +15253,7 @@ alchemy.createElement(Component$9, ErrorFallback, {
|
|
|
15253
15253
|
* @see {@link ExternalCarriers.ComponentProps | The props that are passed into the `<ExternalCarriers />` component}
|
|
15254
15254
|
* @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<ExternalCarriers />` component}
|
|
15255
15255
|
*/
|
|
15256
|
-
const Component$
|
|
15256
|
+
const Component$a = ({
|
|
15257
15257
|
features
|
|
15258
15258
|
}) => {
|
|
15259
15259
|
const {
|
|
@@ -15311,7 +15311,7 @@ const Component$8 = ({
|
|
|
15311
15311
|
textAlign: "left"
|
|
15312
15312
|
}
|
|
15313
15313
|
}, {
|
|
15314
|
-
children: jsx(Component$
|
|
15314
|
+
children: jsx(Component$b, {
|
|
15315
15315
|
features: features,
|
|
15316
15316
|
onCarrierConnected: () => {
|
|
15317
15317
|
setAddModalOpen(false);
|
|
@@ -15326,7 +15326,7 @@ const Component$8 = ({
|
|
|
15326
15326
|
|
|
15327
15327
|
var externalCarriers = /*#__PURE__*/Object.freeze({
|
|
15328
15328
|
__proto__: null,
|
|
15329
|
-
Component: Component$
|
|
15329
|
+
Component: Component$a
|
|
15330
15330
|
});
|
|
15331
15331
|
|
|
15332
15332
|
const styles$l = createStyles({
|
|
@@ -15756,7 +15756,7 @@ const useListConnectedCarriers = () => {
|
|
|
15756
15756
|
* @see {@link ListCarriers.ComponentProps | The props that are passed into the `<List-Carriers />` component}
|
|
15757
15757
|
* @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<List-Carriers />` component}
|
|
15758
15758
|
*/
|
|
15759
|
-
const Component$
|
|
15759
|
+
const Component$9 = ({
|
|
15760
15760
|
features
|
|
15761
15761
|
}) => {
|
|
15762
15762
|
const {
|
|
@@ -15797,7 +15797,7 @@ const Component$7 = ({
|
|
|
15797
15797
|
|
|
15798
15798
|
var listCarriers = /*#__PURE__*/Object.freeze({
|
|
15799
15799
|
__proto__: null,
|
|
15800
|
-
Component: Component$
|
|
15800
|
+
Component: Component$9
|
|
15801
15801
|
});
|
|
15802
15802
|
|
|
15803
15803
|
const WarehouseDisplay = ({
|
|
@@ -16436,7 +16436,7 @@ const ManageWarehouses = ({
|
|
|
16436
16436
|
* @see {@link ManageWarehouses.ComponentProps | The props that are passed into the `<ManageWarehouses />` component}
|
|
16437
16437
|
* @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<ManageWarehouses />` component}
|
|
16438
16438
|
*/
|
|
16439
|
-
const Component$
|
|
16439
|
+
const Component$8 = ({
|
|
16440
16440
|
onWarehouseAddressValidation: _ARE_WE_ACTUALLY_GOING_TO_USE_THIS
|
|
16441
16441
|
}) => {
|
|
16442
16442
|
const {
|
|
@@ -16519,7 +16519,7 @@ const Component$6 = ({
|
|
|
16519
16519
|
|
|
16520
16520
|
var manageWarehouses = /*#__PURE__*/Object.freeze({
|
|
16521
16521
|
__proto__: null,
|
|
16522
|
-
Component: Component$
|
|
16522
|
+
Component: Component$8
|
|
16523
16523
|
});
|
|
16524
16524
|
|
|
16525
16525
|
var img = "data:image/svg+xml,%3csvg fill='none' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'%3e %3cpath d='M22.9425 6.62223L18.63 5.81973C18.4275 5.78223 18.2325 5.91723 18.195 6.11973L17.3925 10.4322C17.355 10.6347 17.49 10.8297 17.6925 10.8672C17.715 10.8672 17.7375 10.8672 17.76 10.8672C17.94 10.8672 18.0975 10.7397 18.1275 10.5597L18.765 7.13973C21.15 10.3872 20.8125 14.9472 17.9475 17.8047C15.3225 20.4297 11.25 20.9697 8.04001 19.1247C7.86001 19.0197 7.63501 19.0797 7.53001 19.2597C7.42501 19.4397 7.49251 19.6647 7.66501 19.7697C9.05251 20.5722 10.5975 20.9622 12.1275 20.9622C14.4525 20.9622 16.755 20.0622 18.48 18.3372C21.5925 15.2247 21.9675 10.2597 19.3875 6.71973L22.8 7.34973C22.995 7.38723 23.1975 7.25223 23.235 7.04973C23.2725 6.84723 23.1375 6.65223 22.935 6.61473L22.9425 6.62223Z' fill='black' /%3e %3cpath d='M6.30022 12.7798C6.09772 12.7423 5.90272 12.8773 5.86522 13.0798L5.24272 16.4548C3.15022 13.2223 3.60022 8.91728 6.33022 6.18728C8.85022 3.66728 12.6752 3.05228 15.8477 4.65728C16.0277 4.74728 16.2602 4.67978 16.3502 4.49228C16.4402 4.30478 16.3727 4.07978 16.1852 3.98978C12.7202 2.23478 8.54272 2.90978 5.79772 5.65478C2.79022 8.66228 2.31772 13.3948 4.65022 16.9273L1.19272 16.2898C0.990221 16.2523 0.795221 16.3873 0.757721 16.5898C0.720221 16.7923 0.855221 16.9873 1.05772 17.0248L5.37022 17.8273C5.37022 17.8273 5.41522 17.8273 5.43772 17.8273C5.61772 17.8273 5.77522 17.6998 5.80522 17.5198L6.60772 13.2073C6.64522 13.0048 6.51022 12.8098 6.30772 12.7723L6.30022 12.7798Z' fill='black' /%3e %3cpath d='M15.0824 13.2223C14.9249 12.9373 14.7224 12.6973 14.4674 12.4948C14.2124 12.2998 13.9349 12.1348 13.6274 11.9998C13.3199 11.8648 13.0124 11.7598 12.7124 11.6773L12.3149 11.5648V7.87482C12.8324 7.91232 13.2749 8.06232 13.6349 8.33232C14.0549 8.64732 14.2874 9.07482 14.3399 9.60732H15.1874C15.1724 9.11982 15.0224 8.68482 14.7524 8.30232C14.4824 7.91982 14.1149 7.61982 13.6574 7.40232C13.2599 7.21482 12.8099 7.12482 12.3149 7.09482V6.31482C12.3149 6.14232 12.1799 6.00732 12.0074 6.00732C11.8349 6.00732 11.6999 6.14232 11.6999 6.31482V7.10982C11.2649 7.14732 10.8449 7.22982 10.4774 7.40232C10.0049 7.61982 9.62988 7.92732 9.35238 8.31732C9.07488 8.70732 8.93988 9.16482 8.93988 9.67482C8.93988 10.2898 9.14988 10.7998 9.56238 11.1898C9.97488 11.5798 10.5599 11.8948 11.3174 12.1198L11.6999 12.2323V16.1323C11.3849 16.1098 11.0849 16.0573 10.8224 15.9523C10.4699 15.8173 10.1849 15.6148 9.96738 15.3523C9.74988 15.0898 9.62238 14.7673 9.59238 14.3923V14.3323C9.59238 14.0848 9.38988 13.8823 9.14238 13.8823C8.89488 13.8823 8.69238 14.0848 8.69238 14.3323V14.3923C8.72988 14.8948 8.87988 15.3448 9.15738 15.7273C9.43488 16.1098 9.80988 16.4098 10.2899 16.6273C10.6949 16.8073 11.1749 16.8973 11.6999 16.9273V17.6848C11.6999 17.8573 11.8349 17.9923 12.0074 17.9923C12.1799 17.9923 12.3149 17.8573 12.3149 17.6848V16.9348C12.8699 16.9048 13.3574 16.7923 13.7774 16.5898C14.2724 16.3498 14.6549 16.0273 14.9174 15.6148C15.1799 15.2023 15.3149 14.7448 15.3149 14.2348C15.3149 13.8373 15.2399 13.4923 15.0824 13.2073V13.2223ZM11.0099 11.1448C10.7849 11.0473 10.5749 10.9348 10.3949 10.7923C10.2074 10.6573 10.0574 10.4923 9.95238 10.3048C9.84738 10.1173 9.78738 9.89232 9.78738 9.63732C9.78738 9.29232 9.88488 8.98482 10.0724 8.71482C10.2674 8.44482 10.5299 8.23482 10.8674 8.07732C11.1149 7.96482 11.3924 7.91232 11.6924 7.88232V11.3848C11.4599 11.3173 11.2349 11.2348 11.0024 11.1373L11.0099 11.1448ZM14.1449 15.2473C13.9274 15.5398 13.6349 15.7648 13.2674 15.9223C12.9824 16.0423 12.6599 16.1023 12.3149 16.1323V12.4198L12.4649 12.4648C12.8624 12.5773 13.2074 12.7123 13.5149 12.8623C13.8149 13.0123 14.0549 13.1998 14.2199 13.4173C14.3849 13.6348 14.4749 13.9123 14.4749 14.2348C14.4749 14.6173 14.3699 14.9548 14.1524 15.2473H14.1449Z' fill='black' /%3e %3cpath d='M14.7525 10.0796C14.985 10.0796 15.1725 9.89211 15.1725 9.65961V9.59961H14.3325V9.65961C14.3325 9.89211 14.52 10.0796 14.7525 10.0796Z' fill='black' /%3e%3c/svg%3e";
|
|
@@ -17701,9 +17701,9 @@ const AccountSettings = _a => {
|
|
|
17701
17701
|
}), jsx(ManageFunding, {
|
|
17702
17702
|
carrierId: carriers ? carriers[0].carrierId : "",
|
|
17703
17703
|
currency: currency
|
|
17704
|
-
}), jsx(PaymentMethodSettings, {}), jsx(WalletHistory, {}), jsx(Component$
|
|
17704
|
+
}), jsx(PaymentMethodSettings, {}), jsx(WalletHistory, {}), jsx(Component$8, {}), jsx(Component$9, {
|
|
17705
17705
|
features: features
|
|
17706
|
-
}), jsx(Component$
|
|
17706
|
+
}), jsx(Component$a, {
|
|
17707
17707
|
features: features
|
|
17708
17708
|
}), jsx(LabelLayout, {
|
|
17709
17709
|
display: "settings"
|
|
@@ -17739,7 +17739,7 @@ const AccountSettings = _a => {
|
|
|
17739
17739
|
*
|
|
17740
17740
|
* @see {@link AccountSettings.Element | The **Element** created to render `<AccountSettings />`}
|
|
17741
17741
|
*/
|
|
17742
|
-
const Component$
|
|
17742
|
+
const Component$7 = ({
|
|
17743
17743
|
features,
|
|
17744
17744
|
onSaveSettings
|
|
17745
17745
|
}) => {
|
|
@@ -17783,7 +17783,7 @@ const Component$5 = ({
|
|
|
17783
17783
|
* @see {@link PaymentMethodSettings | The `<PaymentMethodSettings />` component used to manage payment methods}
|
|
17784
17784
|
* @see {@link ManageFunding | The `<ManageFunding />` component used to manage funding rules and add funds to a carrier account}
|
|
17785
17785
|
*/
|
|
17786
|
-
const Element$
|
|
17786
|
+
const Element$8 = alchemy.createElement(Component$7, ErrorFallback, {
|
|
17787
17787
|
css: {
|
|
17788
17788
|
height: "100%",
|
|
17789
17789
|
maxWidth: "800px",
|
|
@@ -17797,8 +17797,8 @@ const Element$6 = alchemy.createElement(Component$5, ErrorFallback, {
|
|
|
17797
17797
|
|
|
17798
17798
|
var accountSettings = /*#__PURE__*/Object.freeze({
|
|
17799
17799
|
__proto__: null,
|
|
17800
|
-
Component: Component$
|
|
17801
|
-
Element: Element$
|
|
17800
|
+
Component: Component$7,
|
|
17801
|
+
Element: Element$8
|
|
17802
17802
|
});
|
|
17803
17803
|
|
|
17804
17804
|
const SuspendSalesOrder = ({
|
|
@@ -22049,7 +22049,7 @@ const PurchaseLabelByShipment = _a => {
|
|
|
22049
22049
|
*
|
|
22050
22050
|
* @see {@link PurchaseLabel.Element | The **Element** created to render `<PurchaseLabel />`}
|
|
22051
22051
|
*/
|
|
22052
|
-
const Component$
|
|
22052
|
+
const Component$6 = _a => {
|
|
22053
22053
|
var _b, _c;
|
|
22054
22054
|
var {
|
|
22055
22055
|
features
|
|
@@ -22141,7 +22141,7 @@ const Component$4 = _a => {
|
|
|
22141
22141
|
*
|
|
22142
22142
|
* @see {@link ViewShipment.Element | The next step in the label purchase workflow `<ViewShipment.Element />`}
|
|
22143
22143
|
*/
|
|
22144
|
-
const Element$
|
|
22144
|
+
const Element$7 = alchemy.createElement(Component$6, ErrorFallback, {
|
|
22145
22145
|
css: {
|
|
22146
22146
|
height: "100%",
|
|
22147
22147
|
maxWidth: "800px",
|
|
@@ -22155,8 +22155,8 @@ const Element$5 = alchemy.createElement(Component$4, ErrorFallback, {
|
|
|
22155
22155
|
|
|
22156
22156
|
var purchaseLabel = /*#__PURE__*/Object.freeze({
|
|
22157
22157
|
__proto__: null,
|
|
22158
|
-
Component: Component$
|
|
22159
|
-
Element: Element$
|
|
22158
|
+
Component: Component$6,
|
|
22159
|
+
Element: Element$7
|
|
22160
22160
|
});
|
|
22161
22161
|
|
|
22162
22162
|
const styles$8 = createStyles({
|
|
@@ -22518,338 +22518,642 @@ const Shipment = ({
|
|
|
22518
22518
|
});
|
|
22519
22519
|
};
|
|
22520
22520
|
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
22527
|
-
|
|
22528
|
-
* @param ComponentProps The base props that will be passed into the `<ViewShipment />` component.
|
|
22529
|
-
*
|
|
22530
|
-
* @returns Element An EmotionJSX.Element that will render the `<ViewShipment />` component
|
|
22531
|
-
* with all the appropriate wrappers.
|
|
22532
|
-
*
|
|
22533
|
-
* @example
|
|
22534
|
-
* You can see how the `<Component />` is used in the `createElement` function call below.
|
|
22535
|
-
* ```tsx
|
|
22536
|
-
* export const Element = alchemy.createElement(Component, ErrorFallback, {
|
|
22537
|
-
* css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
|
|
22538
|
-
* resources: { en },
|
|
22539
|
-
* });
|
|
22540
|
-
* ```
|
|
22541
|
-
*
|
|
22542
|
-
* <br />
|
|
22543
|
-
*
|
|
22544
|
-
* @see {@link ViewShipment.Element | The **Element** created to render `<ViewShipment />`}
|
|
22545
|
-
*/
|
|
22546
|
-
const Component$3 = ({
|
|
22547
|
-
features,
|
|
22548
|
-
onClickPrintLabel,
|
|
22549
|
-
onClickPurchaseLabel,
|
|
22550
|
-
onClickVoidLabel,
|
|
22551
|
-
shipmentId
|
|
22552
|
-
}) => {
|
|
22553
|
-
var _a, _b, _c;
|
|
22554
|
-
const {
|
|
22555
|
-
t
|
|
22556
|
-
} = useTranslation(["common", "view-shipment"]);
|
|
22557
|
-
const shipment = useGetSalesOrderShipment(shipmentId);
|
|
22558
|
-
const {
|
|
22559
|
-
data: {
|
|
22560
|
-
labels = []
|
|
22561
|
-
} = {}
|
|
22562
|
-
} = useListLabels({
|
|
22563
|
-
shipmentId
|
|
22564
|
-
});
|
|
22565
|
-
const salesOrder = useGetSalesOrder((_b = (_a = shipment.data) === null || _a === void 0 ? void 0 : _a.salesOrderIds) === null || _b === void 0 ? void 0 : _b[0]);
|
|
22566
|
-
const warehouses = useListWarehouses();
|
|
22567
|
-
const carriers = useListCarriers();
|
|
22568
|
-
if (shipment.isInitialLoading) return jsx(Loader, {
|
|
22569
|
-
message: t("loading.shipment")
|
|
22570
|
-
});
|
|
22571
|
-
if (shipment.error) throw new Error(shipment.error.map(e => e.message).join(", "));
|
|
22572
|
-
if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
|
|
22573
|
-
const warehouse = (_c = warehouses.data) === null || _c === void 0 ? void 0 : _c.find(w => {
|
|
22574
|
-
var _a;
|
|
22575
|
-
return w.warehouseId === ((_a = shipment.data) === null || _a === void 0 ? void 0 : _a.warehouseId);
|
|
22576
|
-
});
|
|
22577
|
-
return jsx(Shipment, {
|
|
22578
|
-
carriers: carriers.data,
|
|
22579
|
-
features: features,
|
|
22580
|
-
labels: labels,
|
|
22581
|
-
onClickPrintLabel: onClickPrintLabel,
|
|
22582
|
-
onClickPurchaseLabel: onClickPurchaseLabel,
|
|
22583
|
-
onClickVoidLabel: onClickVoidLabel,
|
|
22584
|
-
salesOrder: salesOrder.data,
|
|
22585
|
-
shipment: shipment.data,
|
|
22586
|
-
warehouse: warehouse
|
|
22587
|
-
});
|
|
22588
|
-
};
|
|
22589
|
-
/**
|
|
22590
|
-
* # Registered View Shipment Element
|
|
22591
|
-
*
|
|
22592
|
-
* - This is the registered `<ViewShipment />` element that will be used to render the
|
|
22593
|
-
* `<ViewShipment.Element />` component.
|
|
22594
|
-
*
|
|
22595
|
-
* @param ElementProps The props, callbacks, and resources necessary to render
|
|
22596
|
-
* the `<ViewShipment.Element />` component.
|
|
22597
|
-
*
|
|
22598
|
-
* @example
|
|
22599
|
-
* The `<Component />` is the source JSX that is rendered when you make use of the `ViewShipment`
|
|
22600
|
-
* Element directly. Here is a brief example of how you would use it within your application.
|
|
22601
|
-
* ```tsx
|
|
22602
|
-
* <ViewShipment.Element
|
|
22603
|
-
* onClickPurchaseLabel={({ salesOrderId }) => {
|
|
22604
|
-
* console.log('sales order ID', salesOrderId);
|
|
22605
|
-
* }}
|
|
22606
|
-
* onClickVoidLabel={({ labelId }) => {
|
|
22607
|
-
* console.log('voided label', labelId);
|
|
22608
|
-
* }}
|
|
22609
|
-
* shipmentId="se-1234567"
|
|
22610
|
-
* />
|
|
22611
|
-
* ```
|
|
22612
|
-
*
|
|
22613
|
-
* <br />
|
|
22614
|
-
*
|
|
22615
|
-
* @see {@link ViewShipment.ComponentProps | The **props** that can be passed into the `<ViewShipment.Element />` component}
|
|
22616
|
-
*
|
|
22617
|
-
* @see {@link VoidLabel.Element | The next step in the label purchase workflow `<VoidLabel.Element />`}
|
|
22618
|
-
**/
|
|
22619
|
-
const Element$4 = alchemy.createElement(Component$3, ErrorFallback, {
|
|
22620
|
-
css: {
|
|
22621
|
-
height: "100%",
|
|
22622
|
-
maxWidth: "800px",
|
|
22623
|
-
minWidth: "440px",
|
|
22624
|
-
width: "100%"
|
|
22521
|
+
const styles$7 = createStyles({
|
|
22522
|
+
category: {
|
|
22523
|
+
alignItems: "center",
|
|
22524
|
+
cursor: "pointer",
|
|
22525
|
+
display: "flex",
|
|
22526
|
+
flexDirection: "row",
|
|
22527
|
+
justifyContent: "space-between"
|
|
22625
22528
|
},
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22630
|
-
|
|
22631
|
-
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
|
|
22529
|
+
colorPicker: theme => ({
|
|
22530
|
+
"&::-webkit-color-swatch": {
|
|
22531
|
+
border: `1px solid ${theme.palette.gray.light}`,
|
|
22532
|
+
borderRadius: "4px",
|
|
22533
|
+
padding: 0
|
|
22534
|
+
},
|
|
22535
|
+
"&::-webkit-color-swatch-wrapper": {
|
|
22536
|
+
padding: 0
|
|
22537
|
+
},
|
|
22538
|
+
alignSelf: "center",
|
|
22539
|
+
appearance: "none",
|
|
22540
|
+
background: "none",
|
|
22541
|
+
border: 0,
|
|
22542
|
+
cursor: "pointer",
|
|
22543
|
+
height: theme.spacing(4.25),
|
|
22544
|
+
outline: "none",
|
|
22545
|
+
width: theme.spacing(4.25)
|
|
22546
|
+
}),
|
|
22547
|
+
container: theme => ({
|
|
22548
|
+
marginBottom: theme.spacing(2)
|
|
22549
|
+
}),
|
|
22550
|
+
input: theme => ({
|
|
22551
|
+
border: `1px solid ${theme.palette.gray.light}`,
|
|
22552
|
+
borderRadius: "4px",
|
|
22553
|
+
color: theme.palette.gray.main,
|
|
22554
|
+
fontSize: "14px",
|
|
22555
|
+
padding: theme.spacing(1)
|
|
22556
|
+
}),
|
|
22557
|
+
inputContainer: theme => ({
|
|
22558
|
+
alignItems: "center",
|
|
22559
|
+
display: "flex",
|
|
22560
|
+
flexDirection: "row",
|
|
22561
|
+
justifyContent: "space-between",
|
|
22562
|
+
padding: `${theme.spacing(2)}px 0`
|
|
22563
|
+
}),
|
|
22564
|
+
wrapper: theme => ({
|
|
22565
|
+
display: "flex",
|
|
22566
|
+
gap: theme.spacing(1)
|
|
22567
|
+
})
|
|
22635
22568
|
});
|
|
22636
22569
|
|
|
22637
|
-
const
|
|
22638
|
-
|
|
22639
|
-
|
|
22640
|
-
|
|
22641
|
-
shipment,
|
|
22642
|
-
voidRequest
|
|
22570
|
+
const ColorPaletteEditor = ({
|
|
22571
|
+
paletteConfig,
|
|
22572
|
+
onUpdatePaletteConfig,
|
|
22573
|
+
formatKey
|
|
22643
22574
|
}) => {
|
|
22644
|
-
const
|
|
22645
|
-
|
|
22646
|
-
|
|
22647
|
-
|
|
22648
|
-
|
|
22649
|
-
|
|
22650
|
-
|
|
22651
|
-
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
|
|
22656
|
-
|
|
22657
|
-
|
|
22658
|
-
|
|
22659
|
-
|
|
22575
|
+
const [expandedCategories, setExpandedCategories] = useState(new Set());
|
|
22576
|
+
const toggleExpandedCategories = category => {
|
|
22577
|
+
setExpandedCategories(prev => {
|
|
22578
|
+
const openCategories = new Set(prev);
|
|
22579
|
+
if (openCategories.has(category)) {
|
|
22580
|
+
return new Set([...openCategories].filter(item => item !== category));
|
|
22581
|
+
} else {
|
|
22582
|
+
return new Set([...openCategories, category]);
|
|
22583
|
+
}
|
|
22584
|
+
});
|
|
22585
|
+
};
|
|
22586
|
+
const handleInputChange = useCallback((category, key, value) => {
|
|
22587
|
+
const updatedConfig = Object.assign(Object.assign({}, paletteConfig || {}), {
|
|
22588
|
+
[category]: Object.assign(Object.assign({}, (paletteConfig === null || paletteConfig === void 0 ? void 0 : paletteConfig[category]) || {}), {
|
|
22589
|
+
[key]: value
|
|
22590
|
+
})
|
|
22591
|
+
});
|
|
22592
|
+
onUpdatePaletteConfig(updatedConfig);
|
|
22593
|
+
}, [onUpdatePaletteConfig, paletteConfig]);
|
|
22594
|
+
return jsx("div", Object.assign({
|
|
22595
|
+
"data-test-id": "color-palette-editor"
|
|
22660
22596
|
}, {
|
|
22661
|
-
children:
|
|
22662
|
-
|
|
22663
|
-
|
|
22664
|
-
|
|
22665
|
-
|
|
22666
|
-
|
|
22667
|
-
|
|
22597
|
+
children: paletteConfig && Object.keys(paletteConfig).map(category => jsxs("div", Object.assign({
|
|
22598
|
+
css: styles$7.container,
|
|
22599
|
+
id: category
|
|
22600
|
+
}, {
|
|
22601
|
+
children: [jsxs("div", Object.assign({
|
|
22602
|
+
"aria-expanded": expandedCategories.has(category),
|
|
22603
|
+
css: styles$7.category,
|
|
22604
|
+
onClick: event => {
|
|
22605
|
+
event.preventDefault();
|
|
22606
|
+
toggleExpandedCategories(category);
|
|
22607
|
+
},
|
|
22608
|
+
role: "button"
|
|
22668
22609
|
}, {
|
|
22669
|
-
children:
|
|
22670
|
-
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
22610
|
+
children: [jsx("p", {
|
|
22611
|
+
children: capitalizeFirstLetter(category)
|
|
22612
|
+
}), jsx(Icon, {
|
|
22613
|
+
name: expandedCategories.has(category) ? IconNames.CHEVRON_TOP : IconNames.CHEVRON_BOTTOM,
|
|
22614
|
+
size: IconSize.SIZE_REGULAR
|
|
22615
|
+
})]
|
|
22616
|
+
})), expandedCategories.has(category) && Object.keys(paletteConfig[category]).map(key => jsxs("div", Object.assign({
|
|
22617
|
+
css: styles$7.inputContainer,
|
|
22618
|
+
id: "input-container"
|
|
22674
22619
|
}, {
|
|
22675
|
-
children:
|
|
22676
|
-
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22620
|
+
children: [jsx("label", Object.assign({
|
|
22621
|
+
css: {
|
|
22622
|
+
fontWeight: "bold"
|
|
22623
|
+
},
|
|
22624
|
+
htmlFor: `${category}.${key}`
|
|
22625
|
+
}, {
|
|
22626
|
+
children: formatKey(key)
|
|
22627
|
+
})), jsxs("form", Object.assign({
|
|
22628
|
+
css: styles$7.wrapper
|
|
22629
|
+
}, {
|
|
22630
|
+
children: [jsx("input", {
|
|
22631
|
+
css: styles$7.input,
|
|
22632
|
+
onChange: e => {
|
|
22633
|
+
if (e.target.value.match(/^#[0-9A-Fa-f]{0,6}$/)) handleInputChange(category, key, e.target.value);
|
|
22634
|
+
},
|
|
22635
|
+
onKeyDown: e => {
|
|
22636
|
+
if (e.key === "Enter") e.preventDefault();
|
|
22637
|
+
},
|
|
22638
|
+
type: "text",
|
|
22639
|
+
value: paletteConfig[category][key]
|
|
22640
|
+
}), jsx("input", {
|
|
22641
|
+
css: styles$7.colorPicker,
|
|
22642
|
+
onChange: e => handleInputChange(category, key, e.target.value),
|
|
22643
|
+
type: "color",
|
|
22644
|
+
value: paletteConfig[category][key]
|
|
22645
|
+
})]
|
|
22646
|
+
}))]
|
|
22647
|
+
}), key))]
|
|
22648
|
+
}), category))
|
|
22687
22649
|
}));
|
|
22688
22650
|
};
|
|
22689
22651
|
|
|
22690
|
-
const
|
|
22691
|
-
|
|
22652
|
+
const styles$6 = createStyles({
|
|
22653
|
+
input: theme => ({
|
|
22654
|
+
border: `1px solid ${theme.palette.gray.light}`,
|
|
22655
|
+
borderRadius: "4px",
|
|
22656
|
+
color: theme.palette.gray.main,
|
|
22657
|
+
fontSize: "14px",
|
|
22658
|
+
maxWidth: theme.spacing(16),
|
|
22659
|
+
padding: 0
|
|
22660
|
+
}),
|
|
22661
|
+
keys: {
|
|
22662
|
+
fontSize: "16px",
|
|
22663
|
+
fontWeight: "bold",
|
|
22664
|
+
marginTop: "8px"
|
|
22665
|
+
},
|
|
22666
|
+
section: theme => ({
|
|
22667
|
+
"& > div:first-child": {
|
|
22668
|
+
flexGrow: 3
|
|
22669
|
+
},
|
|
22670
|
+
"& > div:last-child": {
|
|
22671
|
+
flexShrink: 1
|
|
22672
|
+
},
|
|
22673
|
+
display: "flex",
|
|
22674
|
+
gap: theme.spacing(1),
|
|
22675
|
+
justifyContent: "space-between"
|
|
22676
|
+
}),
|
|
22677
|
+
sectionContainer: theme => ({
|
|
22678
|
+
marginBottom: theme.spacing(4)
|
|
22679
|
+
}),
|
|
22680
|
+
select: theme => ({
|
|
22681
|
+
border: `1px solid ${theme.palette.gray.light}`,
|
|
22682
|
+
borderRadius: "4px",
|
|
22683
|
+
color: theme.palette.gray.main,
|
|
22684
|
+
fontSize: "14px"
|
|
22685
|
+
})
|
|
22686
|
+
});
|
|
22687
|
+
|
|
22688
|
+
const TypographyEditor = ({
|
|
22689
|
+
onUpdateTypographyConfig,
|
|
22690
|
+
typographyConfig,
|
|
22691
|
+
formatKey
|
|
22692
22692
|
}) => {
|
|
22693
|
-
const {
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
|
|
22697
|
-
|
|
22698
|
-
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22693
|
+
const handleInputChange = useCallback((variant, key, value) => {
|
|
22694
|
+
const updatedConfig = Object.assign(Object.assign({}, typographyConfig || {}), {
|
|
22695
|
+
[variant]: Object.assign(Object.assign({}, (typographyConfig === null || typographyConfig === void 0 ? void 0 : typographyConfig[variant]) || {}), {
|
|
22696
|
+
[key]: value
|
|
22697
|
+
})
|
|
22698
|
+
});
|
|
22699
|
+
onUpdateTypographyConfig(updatedConfig);
|
|
22700
|
+
}, [onUpdateTypographyConfig, typographyConfig]);
|
|
22701
|
+
const getNestedValue = useCallback((obj, key) => {
|
|
22702
|
+
if (!obj) return undefined;
|
|
22703
|
+
return obj[key];
|
|
22704
|
+
}, []);
|
|
22705
|
+
const renderFontWeightSelect = (variant, key) => {
|
|
22706
|
+
var _a;
|
|
22707
|
+
const options = [{
|
|
22708
|
+
label: "Normal",
|
|
22709
|
+
value: "400"
|
|
22702
22710
|
}, {
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22720
|
-
}, {
|
|
22721
|
-
children: t("void-label:resultTitles.rejected")
|
|
22722
|
-
})), jsx(Typography, {
|
|
22723
|
-
children: jsx("p", {
|
|
22724
|
-
dangerouslySetInnerHTML: {
|
|
22725
|
-
__html: t("void-label:resultMessages.rejected")
|
|
22726
|
-
}
|
|
22727
|
-
})
|
|
22728
|
-
})]
|
|
22729
|
-
})]
|
|
22730
|
-
})) : jsxs(Fragment, {
|
|
22731
|
-
children: [jsx(Typography, {
|
|
22732
|
-
children: t("void-label:refund_process")
|
|
22733
|
-
}), jsx(Typography, Object.assign({
|
|
22734
|
-
component: "p"
|
|
22711
|
+
label: "Semi Bold",
|
|
22712
|
+
value: "600"
|
|
22713
|
+
}, {
|
|
22714
|
+
label: "Bold",
|
|
22715
|
+
value: "700"
|
|
22716
|
+
}];
|
|
22717
|
+
const fontWeightValue = (_a = getNestedValue(typographyConfig, variant)) === null || _a === void 0 ? void 0 : _a.fontWeight.toString();
|
|
22718
|
+
const selectOption = fontWeightValue !== undefined ? options.find(option => option.value === fontWeightValue) : undefined;
|
|
22719
|
+
return jsx(Select$1, Object.assign({
|
|
22720
|
+
css: styles$6.select,
|
|
22721
|
+
label: "Font Weight",
|
|
22722
|
+
name: "font-weight",
|
|
22723
|
+
onChange: (_name, value) => handleInputChange(variant, key, value === null || value === void 0 ? void 0 : value.value),
|
|
22724
|
+
value: selectOption
|
|
22725
|
+
}, {
|
|
22726
|
+
children: options.map(option => jsx(Option, Object.assign({
|
|
22727
|
+
value: option.value
|
|
22735
22728
|
}, {
|
|
22736
|
-
children:
|
|
22729
|
+
children: option.label
|
|
22730
|
+
}), option.value))
|
|
22731
|
+
}));
|
|
22732
|
+
};
|
|
22733
|
+
const renderFontSizeInput = (variant, key) => {
|
|
22734
|
+
var _a;
|
|
22735
|
+
const formattedFontSizeValue = (_a = getNestedValue(typographyConfig, variant)) === null || _a === void 0 ? void 0 : _a.fontSize.replace("px", "");
|
|
22736
|
+
return jsx(Input, {
|
|
22737
|
+
"aria-labelledby": `${variant}.${key}`,
|
|
22738
|
+
css: styles$6.input,
|
|
22739
|
+
label: "Font Size(px)",
|
|
22740
|
+
onChange: e => {
|
|
22741
|
+
if (e.target.value.match(/^\d{0,2}$/)) handleInputChange(variant, key, `${e.target.value}px`);
|
|
22742
|
+
},
|
|
22743
|
+
value: formattedFontSizeValue
|
|
22744
|
+
});
|
|
22745
|
+
};
|
|
22746
|
+
const renderChildren = (variant, key) => {
|
|
22747
|
+
switch (key) {
|
|
22748
|
+
case "fontWeight":
|
|
22749
|
+
return jsx(Fragment, {
|
|
22750
|
+
children: renderFontWeightSelect(variant, key)
|
|
22751
|
+
});
|
|
22752
|
+
case "fontSize":
|
|
22753
|
+
return jsx(Fragment, {
|
|
22754
|
+
children: renderFontSizeInput(variant, key)
|
|
22755
|
+
});
|
|
22756
|
+
default:
|
|
22757
|
+
return null;
|
|
22758
|
+
}
|
|
22759
|
+
};
|
|
22760
|
+
return jsx("div", {
|
|
22761
|
+
children: typographyConfig && Object.keys(typographyConfig).map(variant => jsxs("div", Object.assign({
|
|
22762
|
+
css: styles$6.sectionContainer
|
|
22763
|
+
}, {
|
|
22764
|
+
children: [jsx("p", Object.assign({
|
|
22765
|
+
css: styles$6.keys,
|
|
22766
|
+
id: variant
|
|
22767
|
+
}, {
|
|
22768
|
+
children: formatKey(variant)
|
|
22769
|
+
})), jsx("section", Object.assign({
|
|
22770
|
+
css: styles$6.section
|
|
22771
|
+
}, {
|
|
22772
|
+
children: Object.keys(typographyConfig[variant]).map(key => jsx("div", Object.assign({
|
|
22773
|
+
id: `${variant}.${key}`
|
|
22774
|
+
}, {
|
|
22775
|
+
children: renderChildren(variant, key)
|
|
22776
|
+
}), key))
|
|
22737
22777
|
}))]
|
|
22738
|
-
})
|
|
22778
|
+
}), variant))
|
|
22739
22779
|
});
|
|
22740
22780
|
};
|
|
22741
22781
|
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
|
|
22753
|
-
|
|
22754
|
-
|
|
22755
|
-
|
|
22756
|
-
|
|
22757
|
-
|
|
22758
|
-
|
|
22759
|
-
|
|
22760
|
-
|
|
22761
|
-
|
|
22762
|
-
|
|
22763
|
-
|
|
22764
|
-
|
|
22765
|
-
|
|
22766
|
-
|
|
22767
|
-
|
|
22768
|
-
|
|
22769
|
-
|
|
22770
|
-
|
|
22771
|
-
|
|
22772
|
-
|
|
22773
|
-
}
|
|
22774
|
-
|
|
22775
|
-
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22792
|
-
|
|
22782
|
+
const styles$5 = createStyles({
|
|
22783
|
+
container: theme => ({
|
|
22784
|
+
color: theme.palette.gray.dark,
|
|
22785
|
+
display: "flex",
|
|
22786
|
+
flexDirection: "column",
|
|
22787
|
+
flexGrow: 1,
|
|
22788
|
+
overflow: "hidden",
|
|
22789
|
+
position: "relative"
|
|
22790
|
+
}),
|
|
22791
|
+
content: theme => ({
|
|
22792
|
+
display: "flex",
|
|
22793
|
+
flexDirection: "column",
|
|
22794
|
+
gap: theme.spacing(3),
|
|
22795
|
+
padding: theme.spacing(3)
|
|
22796
|
+
}),
|
|
22797
|
+
copy: theme => ({
|
|
22798
|
+
backgroundColor: theme.palette.white,
|
|
22799
|
+
borderRadius: "4px",
|
|
22800
|
+
padding: theme.spacing(0.5)
|
|
22801
|
+
}),
|
|
22802
|
+
drawerHeader: theme => ({
|
|
22803
|
+
alignItems: "center",
|
|
22804
|
+
display: "flex",
|
|
22805
|
+
gap: theme.spacing(2),
|
|
22806
|
+
justifyContent: "end",
|
|
22807
|
+
width: "50%"
|
|
22808
|
+
}),
|
|
22809
|
+
drawerWrapper: {
|
|
22810
|
+
display: "flex",
|
|
22811
|
+
justifyContent: "space-between",
|
|
22812
|
+
position: "relative"
|
|
22813
|
+
},
|
|
22814
|
+
header: {
|
|
22815
|
+
alignItems: "center",
|
|
22816
|
+
display: "flex",
|
|
22817
|
+
justifyContent: "space-between"
|
|
22818
|
+
},
|
|
22819
|
+
popoverWrapper: theme => ({
|
|
22820
|
+
display: "flex",
|
|
22821
|
+
flexDirection: "column",
|
|
22822
|
+
gap: theme.spacing(1)
|
|
22823
|
+
}),
|
|
22824
|
+
pre: theme => ({
|
|
22825
|
+
backgroundColor: "#FFFFFF66",
|
|
22826
|
+
borderRadius: "8px",
|
|
22827
|
+
fontSize: "14px",
|
|
22828
|
+
padding: theme.spacing(0.3)
|
|
22829
|
+
}),
|
|
22830
|
+
presetOption: theme => ({
|
|
22831
|
+
"&:hover": {
|
|
22832
|
+
backgroundColor: "theme.palette.gray.ultraLight"
|
|
22833
|
+
},
|
|
22834
|
+
backgroundColor: "transparent",
|
|
22835
|
+
borderRadius: "4px",
|
|
22836
|
+
fontSize: "14px",
|
|
22837
|
+
padding: theme.spacing(1)
|
|
22838
|
+
}),
|
|
22839
|
+
presetsButton: theme => ({
|
|
22840
|
+
"&:hover": {
|
|
22841
|
+
backgroundColor: "#d1d4d7"
|
|
22842
|
+
},
|
|
22843
|
+
backgroundColor: "#E4E5E7",
|
|
22844
|
+
borderRadius: "4px",
|
|
22845
|
+
cursor: "pointer",
|
|
22846
|
+
display: "flex",
|
|
22847
|
+
fontSize: "14px",
|
|
22848
|
+
gap: theme.spacing(0.5),
|
|
22849
|
+
padding: `${theme.spacing(0.5)}px ${theme.spacing(1)}px`
|
|
22850
|
+
})
|
|
22851
|
+
});
|
|
22852
|
+
|
|
22853
|
+
const ThemeCreator = ({
|
|
22854
|
+
themeConfig,
|
|
22855
|
+
onUpdateThemeConfig,
|
|
22856
|
+
presets,
|
|
22857
|
+
showDrawer
|
|
22858
|
+
}) => {
|
|
22859
|
+
const defaultThemeConfigRef = useRef(themeConfig);
|
|
22860
|
+
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
|
22861
|
+
const globalKeys = Object.keys(themeConfig);
|
|
22862
|
+
// If the themeConfig has a "components" key, show only the child component keys, not "components" itself
|
|
22863
|
+
const tabs = globalKeys.flatMap(key => {
|
|
22864
|
+
if (key === "components" && themeConfig[key] && typeof themeConfig[key] === "object") {
|
|
22865
|
+
const childComponentKeys = Object.keys(themeConfig[key]);
|
|
22866
|
+
return childComponentKeys;
|
|
22867
|
+
} else {
|
|
22868
|
+
return [key];
|
|
22869
|
+
}
|
|
22793
22870
|
});
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
|
|
22798
|
-
const handleVoidLabelSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22799
|
-
const result = yield voidLabel.mutateAsync(labelId);
|
|
22800
|
-
if (result.approved) {
|
|
22801
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(label.data, shipment.data);
|
|
22871
|
+
const formattedThemeTabs = tabs.map(tab => {
|
|
22872
|
+
if (tab === "palette") {
|
|
22873
|
+
return "Color Palette";
|
|
22802
22874
|
}
|
|
22875
|
+
return capitalizeFirstLetter(tab);
|
|
22803
22876
|
});
|
|
22804
|
-
|
|
22805
|
-
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22815
|
-
|
|
22877
|
+
const [selectedTab, setSelectedTab] = useState(formattedThemeTabs.sort()[0]);
|
|
22878
|
+
const handleSelectedTab = tab => {
|
|
22879
|
+
setSelectedTab(tab);
|
|
22880
|
+
};
|
|
22881
|
+
const formatKey = key => addSpaceBetweenWords(pascalize(key));
|
|
22882
|
+
const renderContentBySelectedTab = (themeConfig, selectedTab) => {
|
|
22883
|
+
var _a;
|
|
22884
|
+
switch (selectedTab) {
|
|
22885
|
+
case "Color Palette":
|
|
22886
|
+
return jsx(ColorPaletteEditor, {
|
|
22887
|
+
formatKey: formatKey,
|
|
22888
|
+
onUpdatePaletteConfig: updatedPalette => {
|
|
22889
|
+
onUpdateThemeConfig(Object.assign(Object.assign({}, themeConfig), {
|
|
22890
|
+
palette: updatedPalette
|
|
22891
|
+
}));
|
|
22892
|
+
},
|
|
22893
|
+
paletteConfig: themeConfig.palette
|
|
22894
|
+
});
|
|
22895
|
+
case "Typography":
|
|
22896
|
+
return jsx(TypographyEditor, {
|
|
22897
|
+
formatKey: formatKey,
|
|
22898
|
+
onUpdateTypographyConfig: updatedTypography => {
|
|
22899
|
+
onUpdateThemeConfig(Object.assign(Object.assign({}, themeConfig), {
|
|
22900
|
+
components: Object.assign(Object.assign({}, themeConfig.components), {
|
|
22901
|
+
Typography: updatedTypography
|
|
22902
|
+
})
|
|
22903
|
+
}));
|
|
22904
|
+
},
|
|
22905
|
+
typographyConfig: (_a = themeConfig.components) === null || _a === void 0 ? void 0 : _a.Typography
|
|
22906
|
+
});
|
|
22907
|
+
default:
|
|
22908
|
+
return null;
|
|
22909
|
+
}
|
|
22910
|
+
};
|
|
22911
|
+
// const formattedThemeObj = `const theme = ${JSON.stringify(themeConfig, null, 2)}`;
|
|
22912
|
+
const presetsRef = useRef(null);
|
|
22913
|
+
const [showPresets, toggleShowPresets] = useToggle(false);
|
|
22914
|
+
const applyPreset = theme => {
|
|
22915
|
+
onUpdateThemeConfig(theme);
|
|
22916
|
+
};
|
|
22917
|
+
return jsxs("div", Object.assign({
|
|
22918
|
+
"aria-label": "Theme Creator",
|
|
22919
|
+
css: styles$5.container,
|
|
22920
|
+
"data-testid": "theme-creator",
|
|
22921
|
+
role: "region"
|
|
22922
|
+
}, {
|
|
22923
|
+
children: [jsxs("div", Object.assign({
|
|
22924
|
+
css: styles$5.content
|
|
22925
|
+
}, {
|
|
22926
|
+
children: [jsxs("div", Object.assign({
|
|
22927
|
+
css: styles$5.header
|
|
22928
|
+
}, {
|
|
22929
|
+
children: [jsx(Tabs, {
|
|
22930
|
+
onSelectTab: handleSelectedTab,
|
|
22931
|
+
selectedTab: selectedTab,
|
|
22932
|
+
tabs: formattedThemeTabs
|
|
22933
|
+
}), presets ? jsxs("div", {
|
|
22934
|
+
children: [jsxs("button", Object.assign({
|
|
22935
|
+
"aria-controls": "presets-popover",
|
|
22936
|
+
"aria-expanded": showPresets,
|
|
22937
|
+
css: styles$5.presetsButton,
|
|
22938
|
+
onClick: e => {
|
|
22939
|
+
e.preventDefault();
|
|
22940
|
+
toggleShowPresets();
|
|
22941
|
+
},
|
|
22942
|
+
ref: presetsRef
|
|
22943
|
+
}, {
|
|
22944
|
+
children: ["Presets", jsx(Icon, {
|
|
22945
|
+
name: IconNames.CARET_BOTTOM,
|
|
22946
|
+
size: IconSize.SIZE_SMALL
|
|
22947
|
+
})]
|
|
22948
|
+
})), jsx(Popover, Object.assign({
|
|
22949
|
+
container: document.querySelector("#theme-creator"),
|
|
22950
|
+
isOpen: showPresets,
|
|
22951
|
+
onClickAway: () => toggleShowPresets(),
|
|
22952
|
+
placement: "bottom-end",
|
|
22953
|
+
reference: presetsRef.current
|
|
22954
|
+
}, {
|
|
22955
|
+
children: jsxs("div", Object.assign({
|
|
22956
|
+
css: styles$5.popoverWrapper
|
|
22957
|
+
}, {
|
|
22958
|
+
children: [jsx("button", Object.assign({
|
|
22959
|
+
"aria-label": "Set Default Theme",
|
|
22960
|
+
css: styles$5.presetOption,
|
|
22961
|
+
onClick: e => {
|
|
22962
|
+
e.preventDefault();
|
|
22963
|
+
toggleShowPresets();
|
|
22964
|
+
applyPreset(defaultThemeConfigRef.current);
|
|
22965
|
+
},
|
|
22966
|
+
role: "menuitem"
|
|
22967
|
+
}, {
|
|
22968
|
+
children: "Default"
|
|
22969
|
+
})), presets.map(preset => jsx("button", Object.assign({
|
|
22970
|
+
"aria-label": `Set ${preset.presetName} Theme`,
|
|
22971
|
+
css: styles$5.presetOption,
|
|
22972
|
+
onClick: e => {
|
|
22973
|
+
e.preventDefault();
|
|
22974
|
+
toggleShowPresets();
|
|
22975
|
+
applyPreset(preset.themeConfig);
|
|
22976
|
+
},
|
|
22977
|
+
role: "menuitem"
|
|
22978
|
+
}, {
|
|
22979
|
+
children: preset.presetName
|
|
22980
|
+
}), preset.presetName))]
|
|
22981
|
+
}))
|
|
22982
|
+
}))]
|
|
22983
|
+
}) :
|
|
22984
|
+
//reset to default button
|
|
22985
|
+
jsx("button", Object.assign({
|
|
22986
|
+
"aria-label": "Set Default Theme",
|
|
22987
|
+
css: styles$5.presetsButton,
|
|
22988
|
+
onClick: () => {
|
|
22989
|
+
applyPreset(defaultThemeConfigRef.current);
|
|
22990
|
+
},
|
|
22991
|
+
role: "menuitem"
|
|
22992
|
+
}, {
|
|
22993
|
+
children: "Reset to Default"
|
|
22994
|
+
}))]
|
|
22995
|
+
})), jsx(Typography, Object.assign({
|
|
22996
|
+
role: "heading",
|
|
22997
|
+
variant: "heading4"
|
|
22998
|
+
}, {
|
|
22999
|
+
children: `${selectedTab} Editor`
|
|
23000
|
+
})), renderContentBySelectedTab(themeConfig, selectedTab)]
|
|
23001
|
+
})), showDrawer && jsx(Drawer, Object.assign({
|
|
23002
|
+
"aria-label": "Show themeConfig.js Code Drawer",
|
|
23003
|
+
headerContent: jsxs("div", Object.assign({
|
|
23004
|
+
css: styles$5.drawerHeader
|
|
23005
|
+
}, {
|
|
23006
|
+
children: [jsx("pre", Object.assign({
|
|
23007
|
+
css: styles$5.pre
|
|
23008
|
+
}, {
|
|
23009
|
+
children: "themeConfig.js"
|
|
23010
|
+
})), showDrawer.copyToClipboardText && jsx("div", Object.assign({
|
|
23011
|
+
css: styles$5.copy
|
|
23012
|
+
}, {
|
|
23013
|
+
children: jsx(CopyButton, {
|
|
23014
|
+
content: showDrawer.copyToClipboardText
|
|
23015
|
+
})
|
|
23016
|
+
}))]
|
|
23017
|
+
})),
|
|
23018
|
+
isOpen: isDrawerOpen,
|
|
23019
|
+
toggleDrawer: () => setIsDrawerOpen(!isDrawerOpen)
|
|
23020
|
+
}, {
|
|
23021
|
+
children: showDrawer.content
|
|
23022
|
+
}))]
|
|
23023
|
+
}));
|
|
23024
|
+
};
|
|
23025
|
+
|
|
23026
|
+
const Component$5 = ({
|
|
23027
|
+
onRowClick
|
|
23028
|
+
}) => {
|
|
23029
|
+
const {
|
|
23030
|
+
t
|
|
23031
|
+
} = useTranslation(["common", "list-labels"]);
|
|
23032
|
+
const {
|
|
23033
|
+
page,
|
|
23034
|
+
pageSize,
|
|
23035
|
+
pagerProps
|
|
23036
|
+
} = usePager();
|
|
23037
|
+
const {
|
|
23038
|
+
data: carriersData,
|
|
23039
|
+
isLoading: carriersLoading
|
|
23040
|
+
} = useListCarriers();
|
|
23041
|
+
const {
|
|
23042
|
+
data: labelsData,
|
|
23043
|
+
isLoading,
|
|
23044
|
+
isError,
|
|
23045
|
+
error
|
|
23046
|
+
} = useListLabels({
|
|
23047
|
+
page,
|
|
23048
|
+
pageSize
|
|
23049
|
+
});
|
|
23050
|
+
const shipmentIds = (labelsData === null || labelsData === void 0 ? void 0 : labelsData.labels) ? labelsData.labels.filter(l => l.shipmentId).map(l => l.shipmentId) : [];
|
|
23051
|
+
const {
|
|
23052
|
+
data: shipmentsData,
|
|
23053
|
+
isLoading: shipmentsLoading
|
|
23054
|
+
} = useListSalesOrderShipments({
|
|
23055
|
+
shipmentIds
|
|
23056
|
+
});
|
|
23057
|
+
if (isLoading) return jsx(Loader, {
|
|
23058
|
+
message: t("loading.labels")
|
|
23059
|
+
});
|
|
23060
|
+
if (isError) throw new Error(error.map(e => e.message).join(", "));
|
|
23061
|
+
if (!labelsData) throw new Error(t("errorMessages.unableToLoad.labels"));
|
|
23062
|
+
const columns = [{
|
|
23063
|
+
headerContent: t("list-labels:headers.labelId"),
|
|
23064
|
+
renderCellContent: data => {
|
|
23065
|
+
return jsx("div", {
|
|
23066
|
+
children: data.labelId
|
|
23067
|
+
});
|
|
23068
|
+
}
|
|
23069
|
+
}, {
|
|
23070
|
+
headerContent: t("list-labels:headers.created"),
|
|
23071
|
+
renderCellContent: data => {
|
|
23072
|
+
return (data === null || data === void 0 ? void 0 : data.shipDate) && jsx(CellFormattedDate, {
|
|
23073
|
+
date: data.shipDate
|
|
23074
|
+
});
|
|
23075
|
+
}
|
|
23076
|
+
}, {
|
|
23077
|
+
headerContent: t("list-labels:headers.shipTo"),
|
|
23078
|
+
renderCellContent: data => {
|
|
23079
|
+
const labelShipment = shipmentsData === null || shipmentsData === void 0 ? void 0 : shipmentsData.find(s => s.shipmentId === data.shipmentId);
|
|
23080
|
+
const displayAddress = labelShipment && labelShipment.shipTo.addressLine1 ? jsx(AddressDisplay, {
|
|
23081
|
+
address: labelShipment.shipTo
|
|
23082
|
+
}) : "--";
|
|
23083
|
+
return jsx(SuspendText, Object.assign({
|
|
23084
|
+
loading: shipmentsLoading
|
|
23085
|
+
}, {
|
|
23086
|
+
children: displayAddress
|
|
23087
|
+
}));
|
|
23088
|
+
}
|
|
23089
|
+
}, {
|
|
23090
|
+
headerContent: t("list-labels:headers.service"),
|
|
23091
|
+
renderCellContent: data => {
|
|
23092
|
+
if (!carriersLoading && carriersData) {
|
|
23093
|
+
const carrier = carriersData.find(c => c.carrierCode === data.carrierCode);
|
|
23094
|
+
if (carrier) {
|
|
23095
|
+
const service = carrier.services.find(s => s.serviceCode === data.serviceCode);
|
|
23096
|
+
if (service) {
|
|
23097
|
+
return jsxs("div", {
|
|
23098
|
+
children: [jsx(CarrierIcon, {
|
|
23099
|
+
carrierCode: data.carrierCode
|
|
23100
|
+
}, data.carrierCode), "\u00A0 ", service.name]
|
|
23101
|
+
});
|
|
23102
|
+
}
|
|
23103
|
+
}
|
|
23104
|
+
}
|
|
23105
|
+
return jsxs(SuspendText, Object.assign({
|
|
23106
|
+
loading: carriersLoading
|
|
23107
|
+
}, {
|
|
23108
|
+
children: ["`$", data.carrierCode, " - $", data.serviceCode, "`"]
|
|
23109
|
+
}));
|
|
23110
|
+
}
|
|
23111
|
+
}, {
|
|
23112
|
+
// Download
|
|
23113
|
+
headerContent: jsx("div", {
|
|
23114
|
+
"aria-label": t("list-labels:headers.download")
|
|
23115
|
+
}),
|
|
23116
|
+
renderCellContent: data => {
|
|
23117
|
+
if (data.status === "completed") return jsx("div", Object.assign({
|
|
23118
|
+
css: {
|
|
23119
|
+
textAlign: "right"
|
|
23120
|
+
}
|
|
23121
|
+
}, {
|
|
23122
|
+
children: jsx(ButtonIcon, {
|
|
23123
|
+
ariaDescribedby: "",
|
|
23124
|
+
children: t("list-labels:actions.download.pdf"),
|
|
23125
|
+
icon: IconNames.DOWNLOAD,
|
|
23126
|
+
onClick: e => {
|
|
23127
|
+
e.stopPropagation();
|
|
23128
|
+
window.open(data.labelDownload.pdf);
|
|
23129
|
+
}
|
|
23130
|
+
})
|
|
23131
|
+
}));
|
|
23132
|
+
return jsx("div", Object.assign({
|
|
23133
|
+
css: {
|
|
23134
|
+
textAlign: "right"
|
|
23135
|
+
}
|
|
23136
|
+
}, {
|
|
23137
|
+
children: jsx(Tag, Object.assign({
|
|
23138
|
+
color: TagColor.INFO
|
|
23139
|
+
}, {
|
|
23140
|
+
children: data.status.toLocaleUpperCase()
|
|
23141
|
+
}))
|
|
23142
|
+
}));
|
|
23143
|
+
}
|
|
23144
|
+
}];
|
|
23145
|
+
return jsx(GridController, {
|
|
23146
|
+
columns: columns,
|
|
23147
|
+
data: labelsData.labels,
|
|
23148
|
+
footerContent: jsx(Pager, Object.assign({}, pagerProps, {
|
|
23149
|
+
pagingData: labelsData
|
|
23150
|
+
})),
|
|
23151
|
+
onRowClick: onRowClick
|
|
22816
23152
|
});
|
|
22817
23153
|
};
|
|
22818
|
-
|
|
22819
|
-
* # Registered Void Label Element
|
|
22820
|
-
*
|
|
22821
|
-
* - This is the registered `<VoidLabel />` element that will be used to render the
|
|
22822
|
-
* `<VoidLabel.Element />` component.
|
|
22823
|
-
*
|
|
22824
|
-
* @param ElementProps The props, callbacks, and resources necessary to render
|
|
22825
|
-
* the `<VoidLabel.Element />` component.
|
|
22826
|
-
*
|
|
22827
|
-
* @example
|
|
22828
|
-
* The `<Component />` is the source JSX that is rendered when you make use of the `VoidLabel`
|
|
22829
|
-
* Element directly. Here is a brief example of how you would use it within your application.
|
|
22830
|
-
* ```tsx
|
|
22831
|
-
* <VoidLabel.Element
|
|
22832
|
-
* labelId="se-1234567"
|
|
22833
|
-
* onComplete={() => console.log('onComplete')}
|
|
22834
|
-
* onSuccess={(_, { salesOrderIds: [salesOrderId] }) =>
|
|
22835
|
-
* console.log('sales order ID', salesOrderId)
|
|
22836
|
-
* }
|
|
22837
|
-
* onViewShipment={({ shipmentId }) => {
|
|
22838
|
-
* console.log('onViewShipment', shipmentId);
|
|
22839
|
-
* }}
|
|
22840
|
-
* />
|
|
22841
|
-
* ```
|
|
22842
|
-
*
|
|
22843
|
-
* <br />
|
|
22844
|
-
*
|
|
22845
|
-
* @see {@link VoidLabel.ComponentProps | The **props** that can be passed into the `<VoidLabel.Element />` component}
|
|
22846
|
-
*
|
|
22847
|
-
* @see {@link PurchaseLabel.Element | Go back to the frst step in the label purchase workflow `<PurchaseLabel.Element />`}
|
|
22848
|
-
*/
|
|
22849
|
-
const Element$3 = alchemy.createElement(Component$2, ErrorFallback, {
|
|
23154
|
+
const Element$6 = alchemy.createElement(Component$5, ErrorFallback, {
|
|
22850
23155
|
css: {
|
|
22851
23156
|
height: "100%",
|
|
22852
|
-
maxWidth: "800px",
|
|
22853
23157
|
minWidth: "440px",
|
|
22854
23158
|
width: "100%"
|
|
22855
23159
|
},
|
|
@@ -22858,686 +23162,600 @@ const Element$3 = alchemy.createElement(Component$2, ErrorFallback, {
|
|
|
22858
23162
|
}
|
|
22859
23163
|
});
|
|
22860
23164
|
|
|
22861
|
-
var
|
|
23165
|
+
var labelsGrid = /*#__PURE__*/Object.freeze({
|
|
22862
23166
|
__proto__: null,
|
|
22863
|
-
|
|
22864
|
-
Element: Element$3
|
|
23167
|
+
Element: Element$6
|
|
22865
23168
|
});
|
|
22866
23169
|
|
|
22867
23170
|
/**
|
|
22868
|
-
*
|
|
23171
|
+
* # View Shipment Component
|
|
22869
23172
|
*
|
|
22870
|
-
*
|
|
23173
|
+
* - The `<ViewShipment />` component is used to for viewing the shipment's tracking number, printing the label that
|
|
23174
|
+
* was created, and the option to void the label. When a label is voided, you can see a list of the
|
|
23175
|
+
* previously voided labels for a given shipment using this component.
|
|
23176
|
+
*
|
|
23177
|
+
* @param ComponentProps The base props that will be passed into the `<ViewShipment />` component.
|
|
23178
|
+
*
|
|
23179
|
+
* @returns Element An EmotionJSX.Element that will render the `<ViewShipment />` component
|
|
23180
|
+
* with all the appropriate wrappers.
|
|
22871
23181
|
*
|
|
22872
23182
|
* @example
|
|
23183
|
+
* You can see how the `<Component />` is used in the `createElement` function call below.
|
|
22873
23184
|
* ```tsx
|
|
22874
|
-
*
|
|
22875
|
-
*
|
|
22876
|
-
*
|
|
22877
|
-
*
|
|
22878
|
-
* shipmentId,
|
|
22879
|
-
* setLabelId,
|
|
22880
|
-
* setShipmentId,
|
|
22881
|
-
* setIsVoidingLabel,
|
|
22882
|
-
* } = useLabelWorkflow({
|
|
22883
|
-
* _labelId,
|
|
22884
|
-
* _multiplexedId,
|
|
22885
|
-
* });
|
|
23185
|
+
* export const Element = alchemy.createElement(Component, ErrorFallback, {
|
|
23186
|
+
* css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
|
|
23187
|
+
* resources: { en },
|
|
23188
|
+
* });
|
|
22886
23189
|
* ```
|
|
22887
23190
|
*
|
|
22888
23191
|
* <br />
|
|
22889
23192
|
*
|
|
22890
|
-
* @see {@link
|
|
23193
|
+
* @see {@link ViewShipment.Element | The **Element** created to render `<ViewShipment />`}
|
|
22891
23194
|
*/
|
|
22892
|
-
const
|
|
22893
|
-
|
|
22894
|
-
|
|
23195
|
+
const Component$4 = ({
|
|
23196
|
+
features,
|
|
23197
|
+
onClickPrintLabel,
|
|
23198
|
+
onClickPurchaseLabel,
|
|
23199
|
+
onClickVoidLabel,
|
|
23200
|
+
shipmentId
|
|
22895
23201
|
}) => {
|
|
22896
|
-
|
|
22897
|
-
const
|
|
22898
|
-
|
|
22899
|
-
|
|
22900
|
-
const
|
|
22901
|
-
const
|
|
22902
|
-
|
|
22903
|
-
|
|
22904
|
-
|
|
22905
|
-
|
|
22906
|
-
isVoidingLabel,
|
|
22907
|
-
labelId,
|
|
22908
|
-
multiplexedId,
|
|
22909
|
-
setIsVoidingLabel,
|
|
22910
|
-
setLabelId,
|
|
22911
|
-
setMultiplexedId,
|
|
22912
|
-
setShipmentId,
|
|
23202
|
+
var _a, _b, _c;
|
|
23203
|
+
const {
|
|
23204
|
+
t
|
|
23205
|
+
} = useTranslation(["common", "view-shipment"]);
|
|
23206
|
+
const shipment = useGetSalesOrderShipment(shipmentId);
|
|
23207
|
+
const {
|
|
23208
|
+
data: {
|
|
23209
|
+
labels = []
|
|
23210
|
+
} = {}
|
|
23211
|
+
} = useListLabels({
|
|
22913
23212
|
shipmentId
|
|
22914
|
-
};
|
|
23213
|
+
});
|
|
23214
|
+
const salesOrder = useGetSalesOrder((_b = (_a = shipment.data) === null || _a === void 0 ? void 0 : _a.salesOrderIds) === null || _b === void 0 ? void 0 : _b[0]);
|
|
23215
|
+
const warehouses = useListWarehouses();
|
|
23216
|
+
const carriers = useListCarriers();
|
|
23217
|
+
if (shipment.isInitialLoading) return jsx(Loader, {
|
|
23218
|
+
message: t("loading.shipment")
|
|
23219
|
+
});
|
|
23220
|
+
if (shipment.error) throw new Error(shipment.error.map(e => e.message).join(", "));
|
|
23221
|
+
if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
|
|
23222
|
+
const warehouse = (_c = warehouses.data) === null || _c === void 0 ? void 0 : _c.find(w => {
|
|
23223
|
+
var _a;
|
|
23224
|
+
return w.warehouseId === ((_a = shipment.data) === null || _a === void 0 ? void 0 : _a.warehouseId);
|
|
23225
|
+
});
|
|
23226
|
+
return jsx(Shipment, {
|
|
23227
|
+
carriers: carriers.data,
|
|
23228
|
+
features: features,
|
|
23229
|
+
labels: labels,
|
|
23230
|
+
onClickPrintLabel: onClickPrintLabel,
|
|
23231
|
+
onClickPurchaseLabel: onClickPurchaseLabel,
|
|
23232
|
+
onClickVoidLabel: onClickVoidLabel,
|
|
23233
|
+
salesOrder: salesOrder.data,
|
|
23234
|
+
shipment: shipment.data,
|
|
23235
|
+
warehouse: warehouse
|
|
23236
|
+
});
|
|
22915
23237
|
};
|
|
22916
23238
|
/**
|
|
22917
|
-
*
|
|
22918
|
-
*
|
|
22919
|
-
* # Label Workflow Element
|
|
22920
|
-
*
|
|
22921
|
-
* - The `<LabelWorkflow.Element />` component is a composition of the PurchaseLabel, ViewShipment,
|
|
22922
|
-
* and VoidLabel elements that allows users to purchase a label, view the shipment details, and optionally void their shipping label.
|
|
23239
|
+
* # Registered View Shipment Element
|
|
22923
23240
|
*
|
|
22924
|
-
*
|
|
22925
|
-
*
|
|
23241
|
+
* - This is the registered `<ViewShipment />` element that will be used to render the
|
|
23242
|
+
* `<ViewShipment.Element />` component.
|
|
22926
23243
|
*
|
|
22927
|
-
* @
|
|
23244
|
+
* @param ElementProps The props, callbacks, and resources necessary to render
|
|
23245
|
+
* the `<ViewShipment.Element />` component.
|
|
22928
23246
|
*
|
|
22929
23247
|
* @example
|
|
23248
|
+
* The `<Component />` is the source JSX that is rendered when you make use of the `ViewShipment`
|
|
23249
|
+
* Element directly. Here is a brief example of how you would use it within your application.
|
|
22930
23250
|
* ```tsx
|
|
22931
|
-
* <
|
|
22932
|
-
*
|
|
22933
|
-
*
|
|
22934
|
-
*
|
|
23251
|
+
* <ViewShipment.Element
|
|
23252
|
+
* onClickPurchaseLabel={({ salesOrderId }) => {
|
|
23253
|
+
* console.log('sales order ID', salesOrderId);
|
|
23254
|
+
* }}
|
|
23255
|
+
* onClickVoidLabel={({ labelId }) => {
|
|
23256
|
+
* console.log('voided label', labelId);
|
|
23257
|
+
* }}
|
|
23258
|
+
* shipmentId="se-1234567"
|
|
22935
23259
|
* />
|
|
22936
23260
|
* ```
|
|
22937
23261
|
*
|
|
22938
23262
|
* <br />
|
|
22939
23263
|
*
|
|
22940
|
-
* @see {@link
|
|
22941
|
-
*
|
|
22942
|
-
|
|
22943
|
-
|
|
22944
|
-
|
|
22945
|
-
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
|
|
22949
|
-
|
|
22950
|
-
|
|
22951
|
-
|
|
22952
|
-
|
|
22953
|
-
|
|
22954
|
-
labelId,
|
|
22955
|
-
multiplexedId,
|
|
22956
|
-
isVoidingLabel,
|
|
22957
|
-
shipmentId,
|
|
22958
|
-
setLabelId,
|
|
22959
|
-
setShipmentId,
|
|
22960
|
-
setIsVoidingLabel
|
|
22961
|
-
} = useLabelWorkflow({
|
|
22962
|
-
_labelId,
|
|
22963
|
-
_multiplexedId
|
|
22964
|
-
});
|
|
22965
|
-
const _features = useFeatures("Globals");
|
|
22966
|
-
const features = useMemo(() => {
|
|
22967
|
-
var _a;
|
|
22968
|
-
return Object.assign(Object.assign(Object.assign({}, propFeatures), _features), {
|
|
22969
|
-
global: Object.assign(Object.assign({}, _features.global), {
|
|
22970
|
-
presentation: Object.assign(Object.assign({}, (_a = _features.global) === null || _a === void 0 ? void 0 : _a.presentation), {
|
|
22971
|
-
poweredByShipEngine: true
|
|
22972
|
-
})
|
|
22973
|
-
})
|
|
22974
|
-
});
|
|
22975
|
-
}, []);
|
|
22976
|
-
return !labelId ? jsx(Element$5, Object.assign({}, multiplexedId, {
|
|
22977
|
-
features: features,
|
|
22978
|
-
onLabelCreateSuccess: (label, shipment) => {
|
|
22979
|
-
var _a;
|
|
22980
|
-
setLabelId(label.labelId);
|
|
22981
|
-
setShipmentId(shipment.shipmentId);
|
|
22982
|
-
(_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.onLabelCreateSuccess) === null || _a === void 0 ? void 0 : _a.call(callbacks, label, shipment);
|
|
22983
|
-
},
|
|
22984
|
-
onLoad: (salesOrder, shipments, pendingShipment) => {
|
|
22985
|
-
if (shipments.length > 0) {
|
|
22986
|
-
setShipmentId(prior => prior !== undefined ? prior : shipments[0].shipmentId);
|
|
22987
|
-
}
|
|
22988
|
-
}
|
|
22989
|
-
})) : !isVoidingLabel ? jsx(Element$4, {
|
|
22990
|
-
features: features,
|
|
22991
|
-
onClickPurchaseLabel: () => {
|
|
22992
|
-
setLabelId(undefined);
|
|
22993
|
-
},
|
|
22994
|
-
onClickVoidLabel: () => {
|
|
22995
|
-
setIsVoidingLabel(true);
|
|
22996
|
-
},
|
|
22997
|
-
shipmentId: shipmentId
|
|
22998
|
-
}) : jsx(Element$3, {
|
|
22999
|
-
features: features,
|
|
23000
|
-
labelId: labelId,
|
|
23001
|
-
onComplete: () => {
|
|
23002
|
-
setIsVoidingLabel(false);
|
|
23003
|
-
},
|
|
23004
|
-
onViewShipment: () => {
|
|
23005
|
-
setIsVoidingLabel(false);
|
|
23006
|
-
}
|
|
23007
|
-
});
|
|
23008
|
-
};
|
|
23009
|
-
|
|
23010
|
-
var labelWorkflow = /*#__PURE__*/Object.freeze({
|
|
23011
|
-
__proto__: null,
|
|
23012
|
-
useLabelWorkflow: useLabelWorkflow,
|
|
23013
|
-
Element: Element$2
|
|
23264
|
+
* @see {@link ViewShipment.ComponentProps | The **props** that can be passed into the `<ViewShipment.Element />` component}
|
|
23265
|
+
*
|
|
23266
|
+
* @see {@link VoidLabel.Element | The next step in the label purchase workflow `<VoidLabel.Element />`}
|
|
23267
|
+
**/
|
|
23268
|
+
const Element$5 = alchemy.createElement(Component$4, ErrorFallback, {
|
|
23269
|
+
css: {
|
|
23270
|
+
height: "100%",
|
|
23271
|
+
maxWidth: "800px",
|
|
23272
|
+
minWidth: "440px",
|
|
23273
|
+
width: "100%"
|
|
23274
|
+
},
|
|
23275
|
+
resources: {
|
|
23276
|
+
en
|
|
23277
|
+
}
|
|
23014
23278
|
});
|
|
23015
23279
|
|
|
23016
|
-
|
|
23017
|
-
|
|
23018
|
-
|
|
23019
|
-
|
|
23020
|
-
}) => {
|
|
23021
|
-
const [themeConfig, setThemeConfig] = useState(editableTheme);
|
|
23022
|
-
return jsx(ThemeCreatorContext.Provider, Object.assign({
|
|
23023
|
-
value: {
|
|
23024
|
-
setThemeConfig,
|
|
23025
|
-
themeConfig
|
|
23026
|
-
}
|
|
23027
|
-
}, {
|
|
23028
|
-
children: children
|
|
23029
|
-
}));
|
|
23030
|
-
};
|
|
23031
|
-
const useThemeCreator = () => {
|
|
23032
|
-
const themeCreatorContext = useContext(ThemeCreatorContext);
|
|
23033
|
-
if (!themeCreatorContext) throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");
|
|
23034
|
-
return themeCreatorContext;
|
|
23035
|
-
};
|
|
23036
|
-
|
|
23037
|
-
const styles$7 = createStyles({
|
|
23038
|
-
category: {
|
|
23039
|
-
alignItems: "center",
|
|
23040
|
-
cursor: "pointer",
|
|
23041
|
-
display: "flex",
|
|
23042
|
-
flexDirection: "row",
|
|
23043
|
-
justifyContent: "space-between"
|
|
23044
|
-
},
|
|
23045
|
-
colorPicker: theme => ({
|
|
23046
|
-
"&::-webkit-color-swatch": {
|
|
23047
|
-
border: `1px solid ${theme.palette.gray.light}`,
|
|
23048
|
-
borderRadius: "4px",
|
|
23049
|
-
padding: 0
|
|
23050
|
-
},
|
|
23051
|
-
"&::-webkit-color-swatch-wrapper": {
|
|
23052
|
-
padding: 0
|
|
23053
|
-
},
|
|
23054
|
-
alignSelf: "center",
|
|
23055
|
-
appearance: "none",
|
|
23056
|
-
background: "none",
|
|
23057
|
-
border: 0,
|
|
23058
|
-
cursor: "pointer",
|
|
23059
|
-
height: theme.spacing(4.25),
|
|
23060
|
-
outline: "none",
|
|
23061
|
-
width: theme.spacing(4.25)
|
|
23062
|
-
}),
|
|
23063
|
-
container: theme => ({
|
|
23064
|
-
marginBottom: theme.spacing(2)
|
|
23065
|
-
}),
|
|
23066
|
-
input: theme => ({
|
|
23067
|
-
border: `1px solid ${theme.palette.gray.light}`,
|
|
23068
|
-
borderRadius: "4px",
|
|
23069
|
-
color: theme.palette.gray.main,
|
|
23070
|
-
fontSize: "14px",
|
|
23071
|
-
padding: theme.spacing(1)
|
|
23072
|
-
}),
|
|
23073
|
-
inputContainer: theme => ({
|
|
23074
|
-
alignItems: "center",
|
|
23075
|
-
display: "flex",
|
|
23076
|
-
flexDirection: "row",
|
|
23077
|
-
justifyContent: "space-between",
|
|
23078
|
-
padding: `${theme.spacing(2)}px 0`
|
|
23079
|
-
}),
|
|
23080
|
-
wrapper: theme => ({
|
|
23081
|
-
display: "flex",
|
|
23082
|
-
gap: theme.spacing(1)
|
|
23083
|
-
})
|
|
23280
|
+
var viewShipment = /*#__PURE__*/Object.freeze({
|
|
23281
|
+
__proto__: null,
|
|
23282
|
+
Component: Component$4,
|
|
23283
|
+
Element: Element$5
|
|
23084
23284
|
});
|
|
23085
23285
|
|
|
23086
|
-
const
|
|
23087
|
-
|
|
23088
|
-
|
|
23089
|
-
|
|
23286
|
+
const Actions = ({
|
|
23287
|
+
onComplete,
|
|
23288
|
+
onSubmit,
|
|
23289
|
+
onViewShipment,
|
|
23290
|
+
shipment,
|
|
23291
|
+
voidRequest
|
|
23090
23292
|
}) => {
|
|
23091
|
-
const
|
|
23092
|
-
|
|
23093
|
-
|
|
23094
|
-
|
|
23095
|
-
|
|
23096
|
-
|
|
23097
|
-
|
|
23098
|
-
|
|
23099
|
-
|
|
23100
|
-
|
|
23101
|
-
|
|
23102
|
-
|
|
23103
|
-
|
|
23104
|
-
|
|
23105
|
-
|
|
23106
|
-
|
|
23107
|
-
});
|
|
23108
|
-
onUpdatePaletteConfig(updatedConfig);
|
|
23109
|
-
}, [onUpdatePaletteConfig, paletteConfig]);
|
|
23110
|
-
return jsx("div", Object.assign({
|
|
23111
|
-
"data-test-id": "color-palette-editor"
|
|
23293
|
+
const {
|
|
23294
|
+
t
|
|
23295
|
+
} = useTranslation(["common", "void-label"]);
|
|
23296
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
23297
|
+
const handleSubmit = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
23298
|
+
setIsSubmitting(true);
|
|
23299
|
+
yield onSubmit();
|
|
23300
|
+
setIsSubmitting(false);
|
|
23301
|
+
}), [onSubmit]);
|
|
23302
|
+
return jsx(BottomSheet, Object.assign({
|
|
23303
|
+
alwaysVisible: true,
|
|
23304
|
+
css: theme => ({
|
|
23305
|
+
borderTop: `1px solid ${theme.palette.gray.ultraLight}`,
|
|
23306
|
+
boxShadow: "none",
|
|
23307
|
+
position: "static"
|
|
23308
|
+
})
|
|
23112
23309
|
}, {
|
|
23113
|
-
children:
|
|
23114
|
-
|
|
23115
|
-
|
|
23116
|
-
|
|
23117
|
-
|
|
23118
|
-
|
|
23119
|
-
|
|
23120
|
-
onClick: event => {
|
|
23121
|
-
event.preventDefault();
|
|
23122
|
-
toggleExpandedCategories(category);
|
|
23123
|
-
},
|
|
23124
|
-
role: "button"
|
|
23310
|
+
children: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ?
|
|
23311
|
+
// The void request has been approved
|
|
23312
|
+
jsxs(ButtonGroup, {
|
|
23313
|
+
children: [jsx(Button, Object.assign({
|
|
23314
|
+
bold: false,
|
|
23315
|
+
onClick: () => onComplete(voidRequest, shipment),
|
|
23316
|
+
variant: ButtonVariant.OUTLINED
|
|
23125
23317
|
}, {
|
|
23126
|
-
children:
|
|
23127
|
-
|
|
23128
|
-
|
|
23129
|
-
|
|
23130
|
-
|
|
23131
|
-
})]
|
|
23132
|
-
})), expandedCategories.has(category) && Object.keys(paletteConfig[category]).map(key => jsxs("div", Object.assign({
|
|
23133
|
-
css: styles$7.inputContainer,
|
|
23134
|
-
id: "input-container"
|
|
23318
|
+
children: t("void-label:actions.complete")
|
|
23319
|
+
})), jsx(Button, Object.assign({
|
|
23320
|
+
bold: false,
|
|
23321
|
+
isFullWidth: true,
|
|
23322
|
+
onClick: () => onViewShipment(shipment)
|
|
23135
23323
|
}, {
|
|
23136
|
-
children:
|
|
23137
|
-
|
|
23138
|
-
|
|
23139
|
-
|
|
23140
|
-
|
|
23324
|
+
children: t("void-label:actions.viewShipment")
|
|
23325
|
+
}))]
|
|
23326
|
+
}) :
|
|
23327
|
+
// The void request has yet to be made or was rejected
|
|
23328
|
+
jsx(Button, Object.assign({
|
|
23329
|
+
bold: false,
|
|
23330
|
+
isFullWidth: true,
|
|
23331
|
+
isLoading: isSubmitting,
|
|
23332
|
+
onClick: handleSubmit
|
|
23333
|
+
}, {
|
|
23334
|
+
children: t("void-label:actions.confirmVoid")
|
|
23335
|
+
}))
|
|
23336
|
+
}));
|
|
23337
|
+
};
|
|
23338
|
+
|
|
23339
|
+
const Message = ({
|
|
23340
|
+
voidRequest
|
|
23341
|
+
}) => {
|
|
23342
|
+
const {
|
|
23343
|
+
t
|
|
23344
|
+
} = useTranslation(["common", "void-label"]);
|
|
23345
|
+
return jsx(Section, {
|
|
23346
|
+
children: voidRequest ? jsxs("section", Object.assign({
|
|
23347
|
+
css: {
|
|
23348
|
+
textAlign: "center",
|
|
23349
|
+
width: "100%"
|
|
23350
|
+
}
|
|
23351
|
+
}, {
|
|
23352
|
+
children: [jsx(Icon, {
|
|
23353
|
+
css: theme => ({
|
|
23354
|
+
color: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? theme.palette.success.main : theme.palette.error.main
|
|
23355
|
+
}),
|
|
23356
|
+
name: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? IconNames.CHECK_FILLED : IconNames.ALERT,
|
|
23357
|
+
size: IconSize.SIZE_LARGE
|
|
23358
|
+
}), (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? jsxs(Fragment, {
|
|
23359
|
+
children: [jsx(Typography, Object.assign({
|
|
23360
|
+
component: "h2"
|
|
23141
23361
|
}, {
|
|
23142
|
-
children:
|
|
23143
|
-
})),
|
|
23144
|
-
|
|
23362
|
+
children: t("void-label:resultTitles.approved")
|
|
23363
|
+
})), jsx(Typography, {
|
|
23364
|
+
children: t("void-label:resultMessages.approved")
|
|
23365
|
+
})]
|
|
23366
|
+
}) : jsxs(Fragment, {
|
|
23367
|
+
children: [jsx(Typography, Object.assign({
|
|
23368
|
+
component: "h2"
|
|
23145
23369
|
}, {
|
|
23146
|
-
children:
|
|
23147
|
-
|
|
23148
|
-
|
|
23149
|
-
|
|
23150
|
-
|
|
23151
|
-
|
|
23152
|
-
|
|
23153
|
-
|
|
23154
|
-
|
|
23155
|
-
|
|
23156
|
-
|
|
23157
|
-
|
|
23158
|
-
|
|
23159
|
-
|
|
23160
|
-
|
|
23161
|
-
|
|
23162
|
-
|
|
23163
|
-
|
|
23164
|
-
|
|
23165
|
-
}));
|
|
23370
|
+
children: t("void-label:resultTitles.rejected")
|
|
23371
|
+
})), jsx(Typography, {
|
|
23372
|
+
children: jsx("p", {
|
|
23373
|
+
dangerouslySetInnerHTML: {
|
|
23374
|
+
__html: t("void-label:resultMessages.rejected")
|
|
23375
|
+
}
|
|
23376
|
+
})
|
|
23377
|
+
})]
|
|
23378
|
+
})]
|
|
23379
|
+
})) : jsxs(Fragment, {
|
|
23380
|
+
children: [jsx(Typography, {
|
|
23381
|
+
children: t("void-label:refund_process")
|
|
23382
|
+
}), jsx(Typography, Object.assign({
|
|
23383
|
+
component: "p"
|
|
23384
|
+
}, {
|
|
23385
|
+
children: t("void-label:refund_rules")
|
|
23386
|
+
}))]
|
|
23387
|
+
})
|
|
23388
|
+
});
|
|
23166
23389
|
};
|
|
23167
23390
|
|
|
23168
|
-
|
|
23169
|
-
|
|
23170
|
-
|
|
23171
|
-
|
|
23172
|
-
|
|
23173
|
-
|
|
23174
|
-
|
|
23175
|
-
|
|
23176
|
-
|
|
23177
|
-
|
|
23178
|
-
|
|
23179
|
-
|
|
23180
|
-
|
|
23391
|
+
/**
|
|
23392
|
+
* # Void Label Component
|
|
23393
|
+
*
|
|
23394
|
+
* - The `<VoidLabel />` component is used to void a given shipping label. When a label is voided,
|
|
23395
|
+
* you then get the option to view the associated shipment via the `View Shipment` Element, or
|
|
23396
|
+
* you can purchase another label for the shipment via the `Purchase Label` Element.
|
|
23397
|
+
*
|
|
23398
|
+
* @param ComponentProps The base props that will be passed into the `<VoidLabel />` component.
|
|
23399
|
+
*
|
|
23400
|
+
* @returns Element An EmotionJSX.Element that will render the `<VoidLabel />` component
|
|
23401
|
+
* with all the appropriate wrappers.
|
|
23402
|
+
*
|
|
23403
|
+
* @example
|
|
23404
|
+
* You can see how the `<Component />` is used in the `createElement` function call below.
|
|
23405
|
+
* ```tsx
|
|
23406
|
+
* export const Element = alchemy.createElement(Component, ErrorFallback, {
|
|
23407
|
+
* css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
|
|
23408
|
+
* resources: { en },
|
|
23409
|
+
* });
|
|
23410
|
+
* ```
|
|
23411
|
+
*
|
|
23412
|
+
* <br />
|
|
23413
|
+
*
|
|
23414
|
+
* @see {@link VoidLabel.Element | The **Element** created to render `<VoidLabel />`}
|
|
23415
|
+
*/
|
|
23416
|
+
const Component$3 = ({
|
|
23417
|
+
features,
|
|
23418
|
+
labelId,
|
|
23419
|
+
onComplete,
|
|
23420
|
+
onSuccess,
|
|
23421
|
+
onViewShipment
|
|
23422
|
+
}) => {
|
|
23423
|
+
var _a, _b;
|
|
23424
|
+
features = Object.assign({
|
|
23425
|
+
presentation: {
|
|
23426
|
+
poweredByShipEngine: false
|
|
23427
|
+
}
|
|
23428
|
+
}, features !== null && features !== void 0 ? features : {});
|
|
23429
|
+
// TODO [LMNT-910] - labelId should be a required prop
|
|
23430
|
+
if (!labelId) throw new Error("void-label:errorMessages.labelIdRequired");
|
|
23431
|
+
const {
|
|
23432
|
+
t
|
|
23433
|
+
} = useTranslation();
|
|
23434
|
+
const label = useGetLabel(labelId);
|
|
23435
|
+
const shipment = useGetSalesOrderShipment((_a = label.data) === null || _a === void 0 ? void 0 : _a.shipmentId);
|
|
23436
|
+
const voidLabel = useVoidLabel();
|
|
23437
|
+
if (label.isInitialLoading) return jsx(Loader, {
|
|
23438
|
+
message: t("loading.label")
|
|
23439
|
+
});
|
|
23440
|
+
if (shipment.isInitialLoading) return jsx(Loader, {
|
|
23441
|
+
message: t("loading.shipment")
|
|
23442
|
+
});
|
|
23443
|
+
throwAny(label.error);
|
|
23444
|
+
throwAny(shipment.error);
|
|
23445
|
+
if (!label.data) throw new Error("errorMessages.unableToLoad.label");
|
|
23446
|
+
if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
|
|
23447
|
+
const handleVoidLabelSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23448
|
+
const result = yield voidLabel.mutateAsync(labelId);
|
|
23449
|
+
if (result.approved) {
|
|
23450
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(label.data, shipment.data);
|
|
23451
|
+
}
|
|
23452
|
+
});
|
|
23453
|
+
return jsxs(Fragment, {
|
|
23454
|
+
children: [jsx(Message, {
|
|
23455
|
+
voidRequest: voidLabel.data
|
|
23456
|
+
}), jsx(Actions, {
|
|
23457
|
+
onComplete: onComplete,
|
|
23458
|
+
onSubmit: handleVoidLabelSubmit,
|
|
23459
|
+
onViewShipment: onViewShipment,
|
|
23460
|
+
shipment: shipment.data,
|
|
23461
|
+
voidRequest: voidLabel.data
|
|
23462
|
+
}), ((_b = features === null || features === void 0 ? void 0 : features.presentation) === null || _b === void 0 ? void 0 : _b.poweredByShipEngine) && jsxs(Fragment, {
|
|
23463
|
+
children: [jsx(Spacer, {}), jsx(PoweredByShipEngine, {})]
|
|
23464
|
+
})]
|
|
23465
|
+
});
|
|
23466
|
+
};
|
|
23467
|
+
/**
|
|
23468
|
+
* # Registered Void Label Element
|
|
23469
|
+
*
|
|
23470
|
+
* - This is the registered `<VoidLabel />` element that will be used to render the
|
|
23471
|
+
* `<VoidLabel.Element />` component.
|
|
23472
|
+
*
|
|
23473
|
+
* @param ElementProps The props, callbacks, and resources necessary to render
|
|
23474
|
+
* the `<VoidLabel.Element />` component.
|
|
23475
|
+
*
|
|
23476
|
+
* @example
|
|
23477
|
+
* The `<Component />` is the source JSX that is rendered when you make use of the `VoidLabel`
|
|
23478
|
+
* Element directly. Here is a brief example of how you would use it within your application.
|
|
23479
|
+
* ```tsx
|
|
23480
|
+
* <VoidLabel.Element
|
|
23481
|
+
* labelId="se-1234567"
|
|
23482
|
+
* onComplete={() => console.log('onComplete')}
|
|
23483
|
+
* onSuccess={(_, { salesOrderIds: [salesOrderId] }) =>
|
|
23484
|
+
* console.log('sales order ID', salesOrderId)
|
|
23485
|
+
* }
|
|
23486
|
+
* onViewShipment={({ shipmentId }) => {
|
|
23487
|
+
* console.log('onViewShipment', shipmentId);
|
|
23488
|
+
* }}
|
|
23489
|
+
* />
|
|
23490
|
+
* ```
|
|
23491
|
+
*
|
|
23492
|
+
* <br />
|
|
23493
|
+
*
|
|
23494
|
+
* @see {@link VoidLabel.ComponentProps | The **props** that can be passed into the `<VoidLabel.Element />` component}
|
|
23495
|
+
*
|
|
23496
|
+
* @see {@link PurchaseLabel.Element | Go back to the frst step in the label purchase workflow `<PurchaseLabel.Element />`}
|
|
23497
|
+
*/
|
|
23498
|
+
const Element$4 = alchemy.createElement(Component$3, ErrorFallback, {
|
|
23499
|
+
css: {
|
|
23500
|
+
height: "100%",
|
|
23501
|
+
maxWidth: "800px",
|
|
23502
|
+
minWidth: "440px",
|
|
23503
|
+
width: "100%"
|
|
23181
23504
|
},
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
|
|
23185
|
-
},
|
|
23186
|
-
"& > div:last-child": {
|
|
23187
|
-
flexShrink: 1
|
|
23188
|
-
},
|
|
23189
|
-
display: "flex",
|
|
23190
|
-
gap: theme.spacing(1),
|
|
23191
|
-
justifyContent: "space-between"
|
|
23192
|
-
}),
|
|
23193
|
-
sectionContainer: theme => ({
|
|
23194
|
-
marginBottom: theme.spacing(4)
|
|
23195
|
-
}),
|
|
23196
|
-
select: theme => ({
|
|
23197
|
-
border: `1px solid ${theme.palette.gray.light}`,
|
|
23198
|
-
borderRadius: "4px",
|
|
23199
|
-
color: theme.palette.gray.main,
|
|
23200
|
-
fontSize: "14px"
|
|
23201
|
-
})
|
|
23505
|
+
resources: {
|
|
23506
|
+
en
|
|
23507
|
+
}
|
|
23202
23508
|
});
|
|
23203
23509
|
|
|
23204
|
-
|
|
23205
|
-
|
|
23206
|
-
|
|
23207
|
-
|
|
23510
|
+
var voidLabel = /*#__PURE__*/Object.freeze({
|
|
23511
|
+
__proto__: null,
|
|
23512
|
+
Component: Component$3,
|
|
23513
|
+
Element: Element$4
|
|
23514
|
+
});
|
|
23515
|
+
|
|
23516
|
+
/**
|
|
23517
|
+
* @internal
|
|
23518
|
+
*
|
|
23519
|
+
* # Label Workflow Component
|
|
23520
|
+
*
|
|
23521
|
+
* @example
|
|
23522
|
+
* ```tsx
|
|
23523
|
+
* const {
|
|
23524
|
+
* labelId,
|
|
23525
|
+
* multiplexedId,
|
|
23526
|
+
* isVoidingLabel,
|
|
23527
|
+
* shipmentId,
|
|
23528
|
+
* setLabelId,
|
|
23529
|
+
* setShipmentId,
|
|
23530
|
+
* setIsVoidingLabel,
|
|
23531
|
+
* } = useLabelWorkflow({
|
|
23532
|
+
* _labelId,
|
|
23533
|
+
* _multiplexedId,
|
|
23534
|
+
* });
|
|
23535
|
+
* ```
|
|
23536
|
+
*
|
|
23537
|
+
* <br />
|
|
23538
|
+
*
|
|
23539
|
+
* @see {@link LabelWorkflow.Element | The `<LabelWorkflow.Element />` component using this hook}
|
|
23540
|
+
*/
|
|
23541
|
+
const useLabelWorkflow = ({
|
|
23542
|
+
_multiplexedId,
|
|
23543
|
+
_labelId
|
|
23208
23544
|
}) => {
|
|
23209
|
-
|
|
23210
|
-
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
const getNestedValue = useCallback((obj, key) => {
|
|
23218
|
-
if (!obj) return undefined;
|
|
23219
|
-
return obj[key];
|
|
23545
|
+
// Fix first ids as the user of the library shouldn't be changing them
|
|
23546
|
+
const [multiplexedId, setMultiplexedId] = useState(_multiplexedId);
|
|
23547
|
+
const [shipmentId, setShipmentId] = useState("shipmentId" in _multiplexedId ? _multiplexedId.shipmentId : undefined);
|
|
23548
|
+
const [labelId, _setLabelId] = useState(_labelId);
|
|
23549
|
+
const [isVoidingLabel, setIsVoidingLabel] = useState(false);
|
|
23550
|
+
const setLabelId = useCallback(nextLabelId => {
|
|
23551
|
+
setIsVoidingLabel(false);
|
|
23552
|
+
_setLabelId(nextLabelId);
|
|
23220
23553
|
}, []);
|
|
23221
|
-
|
|
23222
|
-
|
|
23223
|
-
|
|
23224
|
-
|
|
23225
|
-
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
label: "Bold",
|
|
23231
|
-
value: "700"
|
|
23232
|
-
}];
|
|
23233
|
-
const fontWeightValue = (_a = getNestedValue(typographyConfig, variant)) === null || _a === void 0 ? void 0 : _a.fontWeight.toString();
|
|
23234
|
-
const selectOption = fontWeightValue !== undefined ? options.find(option => option.value === fontWeightValue) : undefined;
|
|
23235
|
-
return jsx(Select$1, Object.assign({
|
|
23236
|
-
css: styles$6.select,
|
|
23237
|
-
label: "Font Weight",
|
|
23238
|
-
name: "font-weight",
|
|
23239
|
-
onChange: (_name, value) => handleInputChange(variant, key, value === null || value === void 0 ? void 0 : value.value),
|
|
23240
|
-
value: selectOption
|
|
23241
|
-
}, {
|
|
23242
|
-
children: options.map(option => jsx(Option, Object.assign({
|
|
23243
|
-
value: option.value
|
|
23244
|
-
}, {
|
|
23245
|
-
children: option.label
|
|
23246
|
-
}), option.value))
|
|
23247
|
-
}));
|
|
23554
|
+
return {
|
|
23555
|
+
isVoidingLabel,
|
|
23556
|
+
labelId,
|
|
23557
|
+
multiplexedId,
|
|
23558
|
+
setIsVoidingLabel,
|
|
23559
|
+
setLabelId,
|
|
23560
|
+
setMultiplexedId,
|
|
23561
|
+
setShipmentId,
|
|
23562
|
+
shipmentId
|
|
23248
23563
|
};
|
|
23249
|
-
|
|
23564
|
+
};
|
|
23565
|
+
/**
|
|
23566
|
+
* @internal
|
|
23567
|
+
*
|
|
23568
|
+
* # Label Workflow Element
|
|
23569
|
+
*
|
|
23570
|
+
* - The `<LabelWorkflow.Element />` component is a composition of the PurchaseLabel, ViewShipment,
|
|
23571
|
+
* and VoidLabel elements that allows users to purchase a label, view the shipment details, and optionally void their shipping label.
|
|
23572
|
+
*
|
|
23573
|
+
* @param LabelWorkflowProps The props necessary to render the `<LabelWorkflow.Element />` for shipment
|
|
23574
|
+
* based or sales order based label purchasing.
|
|
23575
|
+
*
|
|
23576
|
+
* @returns Element A React Element that will render the `<LabelWorkflow />` component.
|
|
23577
|
+
*
|
|
23578
|
+
* @example
|
|
23579
|
+
* ```tsx
|
|
23580
|
+
* <LabelWorkflow
|
|
23581
|
+
* {...elementProps}
|
|
23582
|
+
* callbacks={{ onLabelCreateSuccess }}
|
|
23583
|
+
* multiplexedId={elementIdProps}
|
|
23584
|
+
* />
|
|
23585
|
+
* ```
|
|
23586
|
+
*
|
|
23587
|
+
* <br />
|
|
23588
|
+
*
|
|
23589
|
+
* @see {@link LabelWorkflowProps | The props that are passed into the `<LabelWorkflow />` component}
|
|
23590
|
+
* @see {@link LabelWorkflow.useLabelWorkflow | The `hook` that is used to manage the state of the `<LabelWorkflow />` component}
|
|
23591
|
+
*/
|
|
23592
|
+
const Element$3 = (
|
|
23593
|
+
/*
|
|
23594
|
+
The passed props are underscore prefixed as they will be stashed, then from them stateful versions will be made
|
|
23595
|
+
*/
|
|
23596
|
+
{
|
|
23597
|
+
multiplexedId: _multiplexedId,
|
|
23598
|
+
labelId: _labelId,
|
|
23599
|
+
features: propFeatures,
|
|
23600
|
+
callbacks
|
|
23601
|
+
}) => {
|
|
23602
|
+
const {
|
|
23603
|
+
labelId,
|
|
23604
|
+
multiplexedId,
|
|
23605
|
+
isVoidingLabel,
|
|
23606
|
+
shipmentId,
|
|
23607
|
+
setLabelId,
|
|
23608
|
+
setShipmentId,
|
|
23609
|
+
setIsVoidingLabel
|
|
23610
|
+
} = useLabelWorkflow({
|
|
23611
|
+
_labelId,
|
|
23612
|
+
_multiplexedId
|
|
23613
|
+
});
|
|
23614
|
+
const _features = useFeatures("Globals");
|
|
23615
|
+
const features = useMemo(() => {
|
|
23250
23616
|
var _a;
|
|
23251
|
-
|
|
23252
|
-
|
|
23253
|
-
|
|
23254
|
-
|
|
23255
|
-
|
|
23256
|
-
|
|
23257
|
-
if (e.target.value.match(/^\d{0,2}$/)) handleInputChange(variant, key, `${e.target.value}px`);
|
|
23258
|
-
},
|
|
23259
|
-
value: formattedFontSizeValue
|
|
23617
|
+
return Object.assign(Object.assign(Object.assign({}, propFeatures), _features), {
|
|
23618
|
+
global: Object.assign(Object.assign({}, _features.global), {
|
|
23619
|
+
presentation: Object.assign(Object.assign({}, (_a = _features.global) === null || _a === void 0 ? void 0 : _a.presentation), {
|
|
23620
|
+
poweredByShipEngine: true
|
|
23621
|
+
})
|
|
23622
|
+
})
|
|
23260
23623
|
});
|
|
23261
|
-
};
|
|
23262
|
-
|
|
23263
|
-
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
|
|
23269
|
-
return jsx(Fragment, {
|
|
23270
|
-
children: renderFontSizeInput(variant, key)
|
|
23271
|
-
});
|
|
23272
|
-
default:
|
|
23273
|
-
return null;
|
|
23274
|
-
}
|
|
23275
|
-
};
|
|
23276
|
-
return jsx("div", {
|
|
23277
|
-
children: typographyConfig && Object.keys(typographyConfig).map(variant => jsxs("div", Object.assign({
|
|
23278
|
-
css: styles$6.sectionContainer
|
|
23279
|
-
}, {
|
|
23280
|
-
children: [jsx("p", Object.assign({
|
|
23281
|
-
css: styles$6.keys,
|
|
23282
|
-
id: variant
|
|
23283
|
-
}, {
|
|
23284
|
-
children: formatKey(variant)
|
|
23285
|
-
})), jsx("section", Object.assign({
|
|
23286
|
-
css: styles$6.section
|
|
23287
|
-
}, {
|
|
23288
|
-
children: Object.keys(typographyConfig[variant]).map(key => jsx("div", Object.assign({
|
|
23289
|
-
id: `${variant}.${key}`
|
|
23290
|
-
}, {
|
|
23291
|
-
children: renderChildren(variant, key)
|
|
23292
|
-
}), key))
|
|
23293
|
-
}))]
|
|
23294
|
-
}), variant))
|
|
23295
|
-
});
|
|
23296
|
-
};
|
|
23297
|
-
|
|
23298
|
-
const styles$5 = createStyles({
|
|
23299
|
-
container: theme => ({
|
|
23300
|
-
color: theme.palette.gray.dark,
|
|
23301
|
-
display: "flex",
|
|
23302
|
-
flexDirection: "column",
|
|
23303
|
-
flexGrow: 1,
|
|
23304
|
-
overflow: "hidden",
|
|
23305
|
-
position: "relative"
|
|
23306
|
-
}),
|
|
23307
|
-
content: theme => ({
|
|
23308
|
-
display: "flex",
|
|
23309
|
-
flexDirection: "column",
|
|
23310
|
-
gap: theme.spacing(3),
|
|
23311
|
-
padding: theme.spacing(3)
|
|
23312
|
-
}),
|
|
23313
|
-
copy: theme => ({
|
|
23314
|
-
backgroundColor: theme.palette.white,
|
|
23315
|
-
borderRadius: "4px",
|
|
23316
|
-
padding: theme.spacing(0.5)
|
|
23317
|
-
}),
|
|
23318
|
-
drawerHeader: theme => ({
|
|
23319
|
-
alignItems: "center",
|
|
23320
|
-
display: "flex",
|
|
23321
|
-
gap: theme.spacing(2),
|
|
23322
|
-
justifyContent: "end",
|
|
23323
|
-
width: "50%"
|
|
23324
|
-
}),
|
|
23325
|
-
drawerWrapper: {
|
|
23326
|
-
display: "flex",
|
|
23327
|
-
justifyContent: "space-between",
|
|
23328
|
-
position: "relative"
|
|
23329
|
-
},
|
|
23330
|
-
header: {
|
|
23331
|
-
alignItems: "center",
|
|
23332
|
-
display: "flex",
|
|
23333
|
-
justifyContent: "space-between"
|
|
23334
|
-
},
|
|
23335
|
-
popoverWrapper: theme => ({
|
|
23336
|
-
display: "flex",
|
|
23337
|
-
flexDirection: "column",
|
|
23338
|
-
gap: theme.spacing(1)
|
|
23339
|
-
}),
|
|
23340
|
-
pre: theme => ({
|
|
23341
|
-
backgroundColor: "#FFFFFF66",
|
|
23342
|
-
borderRadius: "8px",
|
|
23343
|
-
fontSize: "14px",
|
|
23344
|
-
padding: theme.spacing(0.3)
|
|
23345
|
-
}),
|
|
23346
|
-
presetOption: theme => ({
|
|
23347
|
-
"&:hover": {
|
|
23348
|
-
backgroundColor: "theme.palette.gray.ultraLight"
|
|
23624
|
+
}, []);
|
|
23625
|
+
return !labelId ? jsx(Element$7, Object.assign({}, multiplexedId, {
|
|
23626
|
+
features: features,
|
|
23627
|
+
onLabelCreateSuccess: (label, shipment) => {
|
|
23628
|
+
var _a;
|
|
23629
|
+
setLabelId(label.labelId);
|
|
23630
|
+
setShipmentId(shipment.shipmentId);
|
|
23631
|
+
(_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.onLabelCreateSuccess) === null || _a === void 0 ? void 0 : _a.call(callbacks, label, shipment);
|
|
23349
23632
|
},
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
|
|
23633
|
+
onLoad: (salesOrder, shipments, pendingShipment) => {
|
|
23634
|
+
if (shipments.length > 0) {
|
|
23635
|
+
setShipmentId(prior => prior !== undefined ? prior : shipments[0].shipmentId);
|
|
23636
|
+
}
|
|
23637
|
+
}
|
|
23638
|
+
})) : !isVoidingLabel ? jsx(Element$5, {
|
|
23639
|
+
features: features,
|
|
23640
|
+
onClickPurchaseLabel: () => {
|
|
23641
|
+
setLabelId(undefined);
|
|
23358
23642
|
},
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
23643
|
+
onClickVoidLabel: () => {
|
|
23644
|
+
setIsVoidingLabel(true);
|
|
23645
|
+
},
|
|
23646
|
+
shipmentId: shipmentId
|
|
23647
|
+
}) : jsx(Element$4, {
|
|
23648
|
+
features: features,
|
|
23649
|
+
labelId: labelId,
|
|
23650
|
+
onComplete: () => {
|
|
23651
|
+
setIsVoidingLabel(false);
|
|
23652
|
+
},
|
|
23653
|
+
onViewShipment: () => {
|
|
23654
|
+
setIsVoidingLabel(false);
|
|
23655
|
+
}
|
|
23656
|
+
});
|
|
23657
|
+
};
|
|
23658
|
+
|
|
23659
|
+
var labelWorkflow = /*#__PURE__*/Object.freeze({
|
|
23660
|
+
__proto__: null,
|
|
23661
|
+
useLabelWorkflow: useLabelWorkflow,
|
|
23662
|
+
Element: Element$3
|
|
23367
23663
|
});
|
|
23368
23664
|
|
|
23369
|
-
const
|
|
23370
|
-
|
|
23371
|
-
|
|
23372
|
-
presets,
|
|
23373
|
-
showDrawer
|
|
23665
|
+
const Component$2 = ({
|
|
23666
|
+
onRowClick,
|
|
23667
|
+
shipmentStatus: _shipmentStatus = "pending"
|
|
23374
23668
|
}) => {
|
|
23375
|
-
const
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23669
|
+
const {
|
|
23670
|
+
t
|
|
23671
|
+
} = useTranslation(["common", "list-shipments"]);
|
|
23672
|
+
const {
|
|
23673
|
+
page,
|
|
23674
|
+
pageSize,
|
|
23675
|
+
pagerProps
|
|
23676
|
+
} = usePager();
|
|
23677
|
+
const {
|
|
23678
|
+
data,
|
|
23679
|
+
isLoading,
|
|
23680
|
+
isError,
|
|
23681
|
+
error
|
|
23682
|
+
} = useListShipments({
|
|
23683
|
+
page,
|
|
23684
|
+
pageSize,
|
|
23685
|
+
shipmentStatus: _shipmentStatus
|
|
23386
23686
|
});
|
|
23387
|
-
|
|
23388
|
-
|
|
23389
|
-
|
|
23687
|
+
if (isLoading) return jsx(Loader, {
|
|
23688
|
+
message: t("loading.shipments")
|
|
23689
|
+
});
|
|
23690
|
+
if (isError) throw new Error(error.map(e => e.message).join(", "));
|
|
23691
|
+
if (!data) throw new Error(t("errorMessages.unableToLoad.shipments"));
|
|
23692
|
+
const columns = [{
|
|
23693
|
+
headerContent: t("list-shipments:headers.shipmentId"),
|
|
23694
|
+
renderCellContent: shipment => {
|
|
23695
|
+
return jsx("div", {
|
|
23696
|
+
children: shipment.shipmentId
|
|
23697
|
+
});
|
|
23390
23698
|
}
|
|
23391
|
-
|
|
23699
|
+
}, {
|
|
23700
|
+
headerContent: t("list-shipments:headers.shipTo"),
|
|
23701
|
+
renderCellContent: shipment => {
|
|
23702
|
+
return shipment.shipTo.addressLine1 ? jsx(AddressDisplay, {
|
|
23703
|
+
address: shipment.shipTo
|
|
23704
|
+
}) : "--";
|
|
23705
|
+
}
|
|
23706
|
+
}, {
|
|
23707
|
+
headerContent: t("list-shipments:headers.shipDate"),
|
|
23708
|
+
renderCellContent: shipment => {
|
|
23709
|
+
return shipment.shipDate ? jsx(CellFormattedDate, {
|
|
23710
|
+
date: shipment.shipDate
|
|
23711
|
+
}) : "--";
|
|
23712
|
+
}
|
|
23713
|
+
}];
|
|
23714
|
+
return jsx(GridController, {
|
|
23715
|
+
columns: columns,
|
|
23716
|
+
data: data.shipments,
|
|
23717
|
+
footerContent: jsx(Pager, Object.assign({}, pagerProps, {
|
|
23718
|
+
pagingData: data
|
|
23719
|
+
})),
|
|
23720
|
+
onRowClick: onRowClick
|
|
23392
23721
|
});
|
|
23393
|
-
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
|
|
23410
|
-
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
},
|
|
23421
|
-
typographyConfig: (_a = themeConfig.components) === null || _a === void 0 ? void 0 : _a.Typography
|
|
23422
|
-
});
|
|
23423
|
-
default:
|
|
23424
|
-
return null;
|
|
23722
|
+
};
|
|
23723
|
+
const Element$2 = alchemy.createElement(Component$2, ErrorFallback, {
|
|
23724
|
+
css: {
|
|
23725
|
+
height: "100%",
|
|
23726
|
+
minWidth: "440px",
|
|
23727
|
+
width: "100%"
|
|
23728
|
+
},
|
|
23729
|
+
resources: {
|
|
23730
|
+
en
|
|
23731
|
+
}
|
|
23732
|
+
});
|
|
23733
|
+
|
|
23734
|
+
var shipmentsGrid = /*#__PURE__*/Object.freeze({
|
|
23735
|
+
__proto__: null,
|
|
23736
|
+
Element: Element$2
|
|
23737
|
+
});
|
|
23738
|
+
|
|
23739
|
+
const ThemeCreatorContext = /*#__PURE__*/createContext(undefined);
|
|
23740
|
+
const ThemeCreatorProvider = ({
|
|
23741
|
+
children,
|
|
23742
|
+
editableTheme
|
|
23743
|
+
}) => {
|
|
23744
|
+
const [themeConfig, setThemeConfig] = useState(editableTheme);
|
|
23745
|
+
return jsx(ThemeCreatorContext.Provider, Object.assign({
|
|
23746
|
+
value: {
|
|
23747
|
+
setThemeConfig,
|
|
23748
|
+
themeConfig
|
|
23425
23749
|
}
|
|
23426
|
-
};
|
|
23427
|
-
// const formattedThemeObj = `const theme = ${JSON.stringify(themeConfig, null, 2)}`;
|
|
23428
|
-
const presetsRef = useRef(null);
|
|
23429
|
-
const [showPresets, toggleShowPresets] = useToggle(false);
|
|
23430
|
-
const applyPreset = theme => {
|
|
23431
|
-
onUpdateThemeConfig(theme);
|
|
23432
|
-
};
|
|
23433
|
-
return jsxs("div", Object.assign({
|
|
23434
|
-
"aria-label": "Theme Creator",
|
|
23435
|
-
css: styles$5.container,
|
|
23436
|
-
"data-testid": "theme-creator",
|
|
23437
|
-
role: "region"
|
|
23438
23750
|
}, {
|
|
23439
|
-
children:
|
|
23440
|
-
css: styles$5.content
|
|
23441
|
-
}, {
|
|
23442
|
-
children: [jsxs("div", Object.assign({
|
|
23443
|
-
css: styles$5.header
|
|
23444
|
-
}, {
|
|
23445
|
-
children: [jsx(Tabs, {
|
|
23446
|
-
onSelectTab: handleSelectedTab,
|
|
23447
|
-
selectedTab: selectedTab,
|
|
23448
|
-
tabs: formattedThemeTabs
|
|
23449
|
-
}), presets ? jsxs("div", {
|
|
23450
|
-
children: [jsxs("button", Object.assign({
|
|
23451
|
-
"aria-controls": "presets-popover",
|
|
23452
|
-
"aria-expanded": showPresets,
|
|
23453
|
-
css: styles$5.presetsButton,
|
|
23454
|
-
onClick: e => {
|
|
23455
|
-
e.preventDefault();
|
|
23456
|
-
toggleShowPresets();
|
|
23457
|
-
},
|
|
23458
|
-
ref: presetsRef
|
|
23459
|
-
}, {
|
|
23460
|
-
children: ["Presets", jsx(Icon, {
|
|
23461
|
-
name: IconNames.CARET_BOTTOM,
|
|
23462
|
-
size: IconSize.SIZE_SMALL
|
|
23463
|
-
})]
|
|
23464
|
-
})), jsx(Popover, Object.assign({
|
|
23465
|
-
container: document.querySelector("#theme-creator"),
|
|
23466
|
-
isOpen: showPresets,
|
|
23467
|
-
onClickAway: () => toggleShowPresets(),
|
|
23468
|
-
placement: "bottom-end",
|
|
23469
|
-
reference: presetsRef.current
|
|
23470
|
-
}, {
|
|
23471
|
-
children: jsxs("div", Object.assign({
|
|
23472
|
-
css: styles$5.popoverWrapper
|
|
23473
|
-
}, {
|
|
23474
|
-
children: [jsx("button", Object.assign({
|
|
23475
|
-
"aria-label": "Set Default Theme",
|
|
23476
|
-
css: styles$5.presetOption,
|
|
23477
|
-
onClick: e => {
|
|
23478
|
-
e.preventDefault();
|
|
23479
|
-
toggleShowPresets();
|
|
23480
|
-
applyPreset(defaultThemeConfigRef.current);
|
|
23481
|
-
},
|
|
23482
|
-
role: "menuitem"
|
|
23483
|
-
}, {
|
|
23484
|
-
children: "Default"
|
|
23485
|
-
})), presets.map(preset => jsx("button", Object.assign({
|
|
23486
|
-
"aria-label": `Set ${preset.presetName} Theme`,
|
|
23487
|
-
css: styles$5.presetOption,
|
|
23488
|
-
onClick: e => {
|
|
23489
|
-
e.preventDefault();
|
|
23490
|
-
toggleShowPresets();
|
|
23491
|
-
applyPreset(preset.themeConfig);
|
|
23492
|
-
},
|
|
23493
|
-
role: "menuitem"
|
|
23494
|
-
}, {
|
|
23495
|
-
children: preset.presetName
|
|
23496
|
-
}), preset.presetName))]
|
|
23497
|
-
}))
|
|
23498
|
-
}))]
|
|
23499
|
-
}) :
|
|
23500
|
-
//reset to default button
|
|
23501
|
-
jsx("button", Object.assign({
|
|
23502
|
-
"aria-label": "Set Default Theme",
|
|
23503
|
-
css: styles$5.presetsButton,
|
|
23504
|
-
onClick: () => {
|
|
23505
|
-
applyPreset(defaultThemeConfigRef.current);
|
|
23506
|
-
},
|
|
23507
|
-
role: "menuitem"
|
|
23508
|
-
}, {
|
|
23509
|
-
children: "Reset to Default"
|
|
23510
|
-
}))]
|
|
23511
|
-
})), jsx(Typography, Object.assign({
|
|
23512
|
-
role: "heading",
|
|
23513
|
-
variant: "heading4"
|
|
23514
|
-
}, {
|
|
23515
|
-
children: `${selectedTab} Editor`
|
|
23516
|
-
})), renderContentBySelectedTab(themeConfig, selectedTab)]
|
|
23517
|
-
})), showDrawer && jsx(Drawer, Object.assign({
|
|
23518
|
-
"aria-label": "Show themeConfig.js Code Drawer",
|
|
23519
|
-
headerContent: jsxs("div", Object.assign({
|
|
23520
|
-
css: styles$5.drawerHeader
|
|
23521
|
-
}, {
|
|
23522
|
-
children: [jsx("pre", Object.assign({
|
|
23523
|
-
css: styles$5.pre
|
|
23524
|
-
}, {
|
|
23525
|
-
children: "themeConfig.js"
|
|
23526
|
-
})), showDrawer.copyToClipboardText && jsx("div", Object.assign({
|
|
23527
|
-
css: styles$5.copy
|
|
23528
|
-
}, {
|
|
23529
|
-
children: jsx(CopyButton, {
|
|
23530
|
-
content: showDrawer.copyToClipboardText
|
|
23531
|
-
})
|
|
23532
|
-
}))]
|
|
23533
|
-
})),
|
|
23534
|
-
isOpen: isDrawerOpen,
|
|
23535
|
-
toggleDrawer: () => setIsDrawerOpen(!isDrawerOpen)
|
|
23536
|
-
}, {
|
|
23537
|
-
children: showDrawer.content
|
|
23538
|
-
}))]
|
|
23751
|
+
children: children
|
|
23539
23752
|
}));
|
|
23540
23753
|
};
|
|
23754
|
+
const useThemeCreator = () => {
|
|
23755
|
+
const themeCreatorContext = useContext(ThemeCreatorContext);
|
|
23756
|
+
if (!themeCreatorContext) throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");
|
|
23757
|
+
return themeCreatorContext;
|
|
23758
|
+
};
|
|
23541
23759
|
|
|
23542
23760
|
const Component$1 = _a => {
|
|
23543
23761
|
var props = __rest(_a, []);
|
|
@@ -24530,4 +24748,4 @@ var onboarding = /*#__PURE__*/Object.freeze({
|
|
|
24530
24748
|
Element: Element
|
|
24531
24749
|
});
|
|
24532
24750
|
|
|
24533
|
-
export { accountSettings as AccountSettings, AddFundsForm, AutoFundingForm, ButtonGroup, CarrierBalance, CarrierConnectionCard, CarrierIcon, CarrierLogo, CellFormattedDate, CollapsiblePanel, CopyButton, Country, Cube, DateRangeCombo, DateRangeSelect, DisplayTerm, Drawer, ErrorFallback, externalCarriers as ExternalCarriers, fields as Field, FieldLabel, FormPortal, FundAndPurchase, GridController, InlineLabel, ItemsBreakdown, labelWorkflow as LabelWorkflow, LinkAction, listCarriers as ListCarriers, Loader, ManageFunding, manageWarehouses as ManageWarehouses, onboarding as Onboarding, PageLayoutProvider, Pager, PaymentMethodSettings, Portal, PoweredByShipEngine, PudoType, purchaseLabel as PurchaseLabel, RootPortalProvider, Section, SkeletonCarrierRow, Spacer, Spread, StoryNotes, SuspendText, Tabs, themeCreator as ThemeCreator, ThemeCreatorProvider, UsState, UsaCity, viewShipment as ViewShipment, voidLabel as VoidLabel, addEmailToValidation, addSpaceBetweenWords, assert, autoFundingSchema, calculateTotal, capitalizeFirstLetter, convertDecimalWeightToFractionalWeight, convertDimensions, convertFractionalWeightToDecimalWeight, convertPoundsAndOuncesToOunces, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, daysAfter, errorMap, euCountryCodes, extendZod, featureFlagComponentNameLookup, featureFlags, findDateLocale, formLogger, formatByDateAndLocale, formatCreditCardNumber, formatDate, formatDateDDMMYY, formatDateDDMMYYYY, formatDimensions, formatExpiration, formatFractionalWeight, formatMoney, getAddFundsSchema, getCancelledShipment, getCarrierIdByCarrierCode, getCurrencyFromString, getCurrencySymbolFromString, getCustomsFromSalesOrder, getExpirationYears, getFeatures, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRelativeDates, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getShipmentByStatus, getTotalRateAmount, getlocaleDateStringFormat, isCollectionService, isDecimalWeight, isDomesticAddress, isEmptyAddress, isFlatRatePackageCode, isMetricWeightUnit, isMilitaryAddress, isNowOrInTheFuture, isPoBox, isPoBoxAddress, isPudoEligibleRate, isString, isUnitedStatesTerritory, isUnsupportedByUps, isUpsCarrier, isUspsCarrier, moneySchema, mostRecent, nextDayCutoff, omitTime, overrideCarrierCodes$1 as overrideCarrierCodes, parseLocaleDate, pascalize, phoneSchema, phoneSchemaUnvalidated, postalCodeRegex$3 as postalCodeRegex, raise, sortByCreationDate, throwAny, throwJoinedMessages, usCities, usStateCodes, usStates, useAddressValidation, useBlackboxDetection, useCarrierMetadata, useConfirmationOptions, useCountryCodeOptions, useCustomsContentsOptions, useCustomsNonDeliveryOptions, useDateRangeOptions, useExpirationMonthOptions, useFeatures, useInsuranceProviderOptions, useNestedForm, usePackageOptions, usePageLayout, usePager, useRateOptions, useRootPortal, useRunOnceOnTrue, useScrubErrors, useServiceCodeOptions, useServicePoints, useShipmentMetadata, useShippingPresetsOptions, useStateCodeOptions, useThemeCreator, useToggle, useWarehouseOptions, validationResolver };
|
|
24751
|
+
export { accountSettings as AccountSettings, AddFundsForm, AutoFundingForm, ButtonGroup, CarrierBalance, CarrierConnectionCard, CarrierIcon, CarrierLogo, CellFormattedDate, CollapsiblePanel, CopyButton, Country, Cube, DateRangeCombo, DateRangeSelect, DisplayTerm, Drawer, ErrorFallback, externalCarriers as ExternalCarriers, fields as Field, FieldLabel, FormPortal, FundAndPurchase, GridController, InlineLabel, ItemsBreakdown, labelWorkflow as LabelWorkflow, labelsGrid as LabelsGrid, LinkAction, listCarriers as ListCarriers, Loader, ManageFunding, manageWarehouses as ManageWarehouses, onboarding as Onboarding, PageLayoutProvider, Pager, PaymentMethodSettings, Portal, PoweredByShipEngine, PudoType, purchaseLabel as PurchaseLabel, RootPortalProvider, Section, shipmentsGrid as ShipmentsGrid, SkeletonCarrierRow, Spacer, Spread, StoryNotes, SuspendText, Tabs, themeCreator as ThemeCreator, ThemeCreatorProvider, UsState, UsaCity, viewShipment as ViewShipment, voidLabel as VoidLabel, addEmailToValidation, addSpaceBetweenWords, assert, autoFundingSchema, calculateTotal, capitalizeFirstLetter, convertDecimalWeightToFractionalWeight, convertDimensions, convertFractionalWeightToDecimalWeight, convertPoundsAndOuncesToOunces, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, daysAfter, errorMap, euCountryCodes, extendZod, featureFlagComponentNameLookup, featureFlags, findDateLocale, formLogger, formatByDateAndLocale, formatCreditCardNumber, formatDate, formatDateDDMMYY, formatDateDDMMYYYY, formatDimensions, formatExpiration, formatFractionalWeight, formatMoney, getAddFundsSchema, getCancelledShipment, getCarrierIdByCarrierCode, getCurrencyFromString, getCurrencySymbolFromString, getCustomsFromSalesOrder, getExpirationYears, getFeatures, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRelativeDates, getRequestedServices, getSalesOrderItemsFromSalesOrderOrShipment, getShipmentByStatus, getTotalRateAmount, getlocaleDateStringFormat, isCollectionService, isDecimalWeight, isDomesticAddress, isEmptyAddress, isFlatRatePackageCode, isMetricWeightUnit, isMilitaryAddress, isNowOrInTheFuture, isPoBox, isPoBoxAddress, isPudoEligibleRate, isString, isUnitedStatesTerritory, isUnsupportedByUps, isUpsCarrier, isUspsCarrier, moneySchema, mostRecent, nextDayCutoff, omitTime, overrideCarrierCodes$1 as overrideCarrierCodes, parseLocaleDate, pascalize, phoneSchema, phoneSchemaUnvalidated, postalCodeRegex$3 as postalCodeRegex, raise, sortByCreationDate, throwAny, throwJoinedMessages, usCities, usStateCodes, usStates, useAddressValidation, useBlackboxDetection, useCarrierMetadata, useConfirmationOptions, useCountryCodeOptions, useCustomsContentsOptions, useCustomsNonDeliveryOptions, useDateRangeOptions, useExpirationMonthOptions, useFeatures, useInsuranceProviderOptions, useNestedForm, usePackageOptions, usePageLayout, usePager, useRateOptions, useRootPortal, useRunOnceOnTrue, useScrubErrors, useServiceCodeOptions, useServicePoints, useShipmentMetadata, useShippingPresetsOptions, useStateCodeOptions, useThemeCreator, useToggle, useWarehouseOptions, validationResolver };
|