@shipengine/elements 2.12.0 → 2.13.0

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.
Files changed (58) hide show
  1. package/actions-menu.js +5 -5
  2. package/index.js +1 -1
  3. package/package.json +2 -2
  4. package/src/components/add-funds-form/add-funds-form.d.ts +9 -1
  5. package/src/components/carrier-connection-card/carrier-connection-card.styles.d.ts +1 -1
  6. package/src/components/collapsible-panel/collapsible-panel.d.ts +15 -1
  7. package/src/components/field/date-picker/date-picker.d.ts +3 -1
  8. package/src/components/field/rate-select/rate-card/cost-breakdown/cost-breakdown.styles.d.ts +2 -1
  9. package/src/components/field/rate-select/rate-card/rate-card.styles.d.ts +1 -1
  10. package/src/components/grid-controller/grid-controller.styles.d.ts +8 -3
  11. package/src/components/grid-filters/components/label-id-filter/label-id-filter.styles.d.ts +1 -1
  12. package/src/components/history/history-card/history-card.styles.d.ts +1 -1
  13. package/src/components/save-status/save-status.d.ts +15 -1
  14. package/src/components/templates/label-display/label-card.styles.d.ts +1 -1
  15. package/src/components/templates/shipment-form/shipment-schema.d.ts +15 -109
  16. package/src/components/templates/theme-creator/theme-creator.styles.d.ts +1 -1
  17. package/src/elements/labels-grid/labels-grid.d.ts +15 -6
  18. package/src/elements/manage-carriers/manage-carriers.d.ts +10 -1
  19. package/src/elements/manage-external-carriers/manage-external-carriers.d.ts +10 -1
  20. package/src/elements/manage-funding/manage-funding-element.d.ts +10 -1
  21. package/src/elements/manage-warehouses/manage-warehouses.d.ts +10 -1
  22. package/src/elements/payment-method-settings/payment-method-settings-element.d.ts +10 -1
  23. package/src/elements/purchase-label/purchase-label.d.ts +14 -2
  24. package/src/elements/select-label-layout/select-label-layout-element.d.ts +10 -1
  25. package/src/elements/shipment-summary/shipment-summary.d.ts +13 -2
  26. package/src/elements/shipments-grid/shipments-grid.d.ts +10 -1
  27. package/src/elements/theme-creator/theme-creator.d.ts +10 -1
  28. package/src/elements/transaction-history/transaction-history-element.d.ts +10 -1
  29. package/src/elements/unit-settings/unit-settings-element.d.ts +10 -1
  30. package/src/elements/vat-settings/vat-settings-element.d.ts +10 -1
  31. package/src/elements/void-label/components/actions/actions.d.ts +2 -1
  32. package/src/elements/void-label/void-label.d.ts +65 -25
  33. package/src/elements-provider/elements-context-provider.d.ts +10 -3
  34. package/src/elements-provider/elements-provider.d.ts +7 -2
  35. package/src/features/manage-carriers/index.d.ts +1 -0
  36. package/src/features/manage-carriers/manage-carriers.d.ts +12 -1
  37. package/src/features/manage-carriers/use-manage-carriers.d.ts +15 -0
  38. package/src/features/manage-funding/manage-funding.d.ts +10 -1
  39. package/src/features/vat-settings/use-vat-settings.d.ts +1 -1
  40. package/src/hooks/options/use-insurance-provider-options.d.ts +1 -1
  41. package/src/hooks/use-root-portal.d.ts +3 -2
  42. package/src/locales/en/index.d.ts +10 -1
  43. package/src/utilities/styles.d.ts +6 -2
  44. package/src/workflows/account-settings/account-settings.d.ts +10 -1
  45. package/src/workflows/account-settings/use-get-panel-props.d.ts +2 -2
  46. package/src/workflows/carrier-services/carrier-services.d.ts +60 -2
  47. package/src/workflows/connect-external-carrier/connect-external-carrier.d.ts +33 -1
  48. package/src/workflows/label-workflow/label-workflow.d.ts +10 -0
  49. package/src/workflows/onboarding/onboarding.d.ts +17 -1
  50. package/suspend-text.js +1 -1
  51. package/transaction-history-element.js +1 -1
  52. package/use-scrub-errors.js +1 -1
  53. package/use-toggle.js +1 -1
  54. package/use-unit-settings.js +1 -1
  55. package/usePager.js +1 -1
  56. package/utilities.js +1 -1
  57. package/validation.js +1 -1
  58. package/wallet-form.js +1 -1
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  type RootPortalProviderProps = {
3
3
  children: React.ReactNode;
4
+ emotionCacheShadowRootContainer?: ShadowRoot & HTMLElement;
4
5
  };
5
6
  /**
6
7
  * @internal
@@ -13,7 +14,7 @@ type RootPortalProviderProps = {
13
14
  *
14
15
  * @see {@link useRootPortal | The associated `hook` for this provider}
15
16
  */
16
- export declare const RootPortalProvider: ({ children }: RootPortalProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export declare const RootPortalProvider: ({ children, emotionCacheShadowRootContainer, }: RootPortalProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
17
18
  /**
18
19
  * @internal
19
20
  *
@@ -28,5 +29,5 @@ export declare const RootPortalProvider: ({ children }: RootPortalProviderProps)
28
29
  *
29
30
  * @see {@link RootPortalProvider | The associated `provider` for this hook}
30
31
  */
31
- export declare const useRootPortal: () => HTMLDivElement;
32
+ export declare const useRootPortal: () => HTMLElement;
32
33
  export {};
@@ -28,6 +28,7 @@ declare const _default: {
28
28
  };
29
29
  errorMessages: {
30
30
  labelIdRequired: string;
31
+ request_failed_to_complete: string;
31
32
  };
32
33
  resultMessages: {
33
34
  approved: string;
@@ -957,6 +958,9 @@ declare const _default: {
957
958
  tooManyCharacters: string;
958
959
  requiredShipmentId: string;
959
960
  requiredLabelId: string;
961
+ heightExceeded: string;
962
+ widthExceeded: string;
963
+ lengthExceeded: string;
960
964
  };
961
965
  shippingPresets: {
962
966
  apply: string;
@@ -1031,7 +1035,12 @@ declare const _default: {
1031
1035
  transactionHistory: string;
1032
1036
  adjustmentHistory: string;
1033
1037
  warehouses: string;
1034
- carriers: string;
1038
+ carriers: {
1039
+ title: string;
1040
+ customStatusMessages: {
1041
+ success: string;
1042
+ };
1043
+ };
1035
1044
  externalCarriers: string;
1036
1045
  labelLayout: string;
1037
1046
  unitSettings: string;
@@ -1,4 +1,5 @@
1
1
  import { Interpolation } from "@emotion/serialize";
2
+ import { THEME_ID } from "@shipengine/giger";
2
3
  import { Theme } from "@shipengine/giger-theme";
3
4
  /**
4
5
  * The verbose typing is necessary to get around TypeScript's limitations on contextual inference
@@ -29,10 +30,10 @@ type StylesConstraint = Record<GetterKey, GetterFunction> & Record<`${NotGetterK
29
30
  * ```
30
31
  * const styles = createStyles({
31
32
  * basicObject: { color: "red" },
32
- * withTheme: (theme) => ({ backgroundColor: theme.palette.primary.main }),
33
+ * withTheme: (theme) => ({ backgroundColor: scopeTheme(theme).palette.primary.main }),
33
34
  *
34
35
  * getWithArbitraryPropsAndTheme: (disabled?: boolean) => (theme) => ({
35
- * color: theme.palette[disabled ? 'primary' : 'gray'].main,
36
+ * color: scopeTheme(theme).palette[disabled ? 'primary' : 'gray'].main,
36
37
  * }),
37
38
  * });
38
39
  * ```
@@ -40,4 +41,7 @@ type StylesConstraint = Record<GetterKey, GetterFunction> & Record<`${NotGetterK
40
41
  * @category Utilities
41
42
  */
42
43
  export declare const createStyles: <T extends StylesConstraint>(styles: T) => T;
44
+ export declare const scopeTheme: (theme: Theme | {
45
+ [THEME_ID]: Theme;
46
+ }) => Theme;
43
47
  export {};
@@ -64,6 +64,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
64
64
  };
65
65
  errorMessages: {
66
66
  labelIdRequired: string;
67
+ request_failed_to_complete: string;
67
68
  };
68
69
  resultMessages: {
69
70
  approved: string;
@@ -993,6 +994,9 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
993
994
  tooManyCharacters: string;
994
995
  requiredShipmentId: string;
995
996
  requiredLabelId: string;
997
+ heightExceeded: string;
998
+ widthExceeded: string;
999
+ lengthExceeded: string;
996
1000
  };
997
1001
  shippingPresets: {
998
1002
  apply: string;
@@ -1067,7 +1071,12 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
1067
1071
  transactionHistory: string;
1068
1072
  adjustmentHistory: string;
1069
1073
  warehouses: string;
1070
- carriers: string;
1074
+ carriers: {
1075
+ title: string;
1076
+ customStatusMessages: {
1077
+ success: string;
1078
+ };
1079
+ };
1071
1080
  externalCarriers: string;
1072
1081
  labelLayout: string;
1073
1082
  unitSettings: string;
@@ -1,8 +1,8 @@
1
1
  import { CollapsiblePanelProps } from "../../components";
2
- import { ExternalCarriersProps, UnitSettingsProps } from "../../features";
2
+ import { ExternalCarriersProps, ShipEngineCarriersProps, UnitSettingsProps } from "../../features";
3
3
  import { ManageWarehousesProps } from "../../features/manage-warehouses/";
4
4
  import { SelectLabelLayoutSettingsProps } from "../../features/select-label-layout/select-label-layout";
5
- type SettingProps = ExternalCarriersProps | SelectLabelLayoutSettingsProps | UnitSettingsProps | ManageWarehousesProps;
5
+ type SettingProps = ShipEngineCarriersProps | ExternalCarriersProps | SelectLabelLayoutSettingsProps | UnitSettingsProps | ManageWarehousesProps;
6
6
  export type SettingPropsIntersection = ExternalCarriersProps & SelectLabelLayoutSettingsProps & UnitSettingsProps & ManageWarehousesProps;
7
7
  export declare const useGetPanelProps: () => {
8
8
  getSettingPanelProps: (setting: string) => [panelProps?: CollapsiblePanelProps, settingProps?: SettingProps];
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { CodedError } from "@shipengine/react-api";
2
3
  /**
3
4
  * # Carrier-Services Component
4
5
  *
@@ -23,9 +24,11 @@
23
24
  * @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<CarrierServices />` component}
24
25
  */
25
26
  export type CarrierServicesProps = {
27
+ addedFundsError?: CodedError[] | null;
28
+ addFunds?: () => Promise<any>;
26
29
  onRedirectToOnboarding?: () => void;
27
30
  };
28
- export declare const Component: ({ onRedirectToOnboarding }: CarrierServicesProps) => import("@emotion/react/jsx-runtime").JSX.Element;
31
+ export declare const Component: ({ onRedirectToOnboarding, addFunds, addedFundsError }: CarrierServicesProps) => import("@emotion/react/jsx-runtime").JSX.Element;
29
32
  export declare const Element: ({ resources, ...props }: CarrierServicesProps & {
30
33
  resources?: {
31
34
  en: {
@@ -58,6 +61,7 @@ export declare const Element: ({ resources, ...props }: CarrierServicesProps & {
58
61
  };
59
62
  errorMessages: {
60
63
  labelIdRequired: string;
64
+ request_failed_to_complete: string;
61
65
  };
62
66
  resultMessages: {
63
67
  approved: string;
@@ -128,6 +132,29 @@ export declare const Element: ({ resources, ...props }: CarrierServicesProps & {
128
132
  vatFormText: string;
129
133
  vatFormRegisterLater: string;
130
134
  vatNumberInputHint: string;
135
+ /**
136
+ * # Carrier-Services Component
137
+ *
138
+ * @param ComponentProps The base props that will be passed into the `<CarrierServices />` component.
139
+ *
140
+ * @returns Element A React element that renders the `<CarrierServices />` component allowing users
141
+ * to view a list of carriers that are connected to their ShipEngine account, add funds to their wallet, view transaction history, and manage their payment method. This component is
142
+ * composed in the `<AccountSettings />` Element.
143
+ *
144
+ * @example
145
+ * ```tsx
146
+ * (() => {
147
+ * const features = useFeatures("Global");
148
+ *
149
+ * return <CarrierServices.Element features={features} />;
150
+ * })();
151
+ * ```
152
+ *
153
+ * <br />
154
+ *
155
+ * @see {@link CarrierServices.ComponentProps | The props that are passed into the `<CarrierServices />` component}
156
+ * @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<CarrierServices />` component}
157
+ */
131
158
  vatNumberInputPlaceholder: string;
132
159
  verifiedVat: string;
133
160
  vatFormErrors: {
@@ -592,6 +619,29 @@ export declare const Element: ({ resources, ...props }: CarrierServicesProps & {
592
619
  pdf: string;
593
620
  };
594
621
  };
622
+ /**
623
+ * # Carrier-Services Component
624
+ *
625
+ * @param ComponentProps The base props that will be passed into the `<CarrierServices />` component.
626
+ *
627
+ * @returns Element A React element that renders the `<CarrierServices />` component allowing users
628
+ * to view a list of carriers that are connected to their ShipEngine account, add funds to their wallet, view transaction history, and manage their payment method. This component is
629
+ * composed in the `<AccountSettings />` Element.
630
+ *
631
+ * @example
632
+ * ```tsx
633
+ * (() => {
634
+ * const features = useFeatures("Global");
635
+ *
636
+ * return <CarrierServices.Element features={features} />;
637
+ * })();
638
+ * ```
639
+ *
640
+ * <br />
641
+ *
642
+ * @see {@link CarrierServices.ComponentProps | The props that are passed into the `<CarrierServices />` component}
643
+ * @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<CarrierServices />` component}
644
+ */
595
645
  emptyState: {
596
646
  title: string;
597
647
  subtitle: string;
@@ -987,6 +1037,9 @@ export declare const Element: ({ resources, ...props }: CarrierServicesProps & {
987
1037
  tooManyCharacters: string;
988
1038
  requiredShipmentId: string;
989
1039
  requiredLabelId: string;
1040
+ heightExceeded: string;
1041
+ widthExceeded: string;
1042
+ lengthExceeded: string;
990
1043
  };
991
1044
  shippingPresets: {
992
1045
  apply: string;
@@ -1061,7 +1114,12 @@ export declare const Element: ({ resources, ...props }: CarrierServicesProps & {
1061
1114
  transactionHistory: string;
1062
1115
  adjustmentHistory: string;
1063
1116
  warehouses: string;
1064
- carriers: string;
1117
+ carriers: {
1118
+ title: string;
1119
+ customStatusMessages: {
1120
+ success: string;
1121
+ };
1122
+ };
1065
1123
  externalCarriers: string;
1066
1124
  labelLayout: string;
1067
1125
  unitSettings: string;
@@ -65,6 +65,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
65
65
  };
66
66
  errorMessages: {
67
67
  labelIdRequired: string;
68
+ request_failed_to_complete: string;
68
69
  };
69
70
  resultMessages: {
70
71
  approved: string;
@@ -72,6 +73,29 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
72
73
  dpdwallet: string;
73
74
  };
74
75
  refund_process: string;
76
+ /**
77
+ * # ConnectExternalCarrier Component
78
+ *
79
+ * @param ComponentProps The base props that will be passed into the `<ConnectExternalCarrier />` component.
80
+ *
81
+ * @returns Element A React element that renders the `<ConnectExternalCarrier />` component allowing users
82
+ * to connect their own existing carrier account. If no carrier is provided, the user may
83
+ * select from a list of carriers specified by `features.availableCarrierConnections`.
84
+ * This component is composed in the `<AccountSettings />` Element.
85
+ *
86
+ * @example
87
+ * ```tsx
88
+ * (() => {
89
+ * const features = useFeatures("CarrierConnections");
90
+ *
91
+ * return <ConnectExternalCarrier.Component features={features} />;
92
+ * })();
93
+ * ```
94
+ *
95
+ * <br />
96
+ *
97
+ * @see {@link ConnectExternalCarrier.ComponentProps | The props that are passed into the `<ConnectExternalCarrier />` component}
98
+ */
75
99
  refund_rules: string;
76
100
  resultTitles: {
77
101
  approved: string;
@@ -994,6 +1018,9 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
994
1018
  tooManyCharacters: string;
995
1019
  requiredShipmentId: string;
996
1020
  requiredLabelId: string;
1021
+ heightExceeded: string;
1022
+ widthExceeded: string;
1023
+ lengthExceeded: string;
997
1024
  };
998
1025
  shippingPresets: {
999
1026
  apply: string;
@@ -1068,7 +1095,12 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
1068
1095
  transactionHistory: string;
1069
1096
  adjustmentHistory: string;
1070
1097
  warehouses: string;
1071
- carriers: string;
1098
+ carriers: {
1099
+ title: string;
1100
+ customStatusMessages: {
1101
+ success: string;
1102
+ };
1103
+ };
1072
1104
  externalCarriers: string;
1073
1105
  labelLayout: string;
1074
1106
  unitSettings: string;
@@ -24,6 +24,11 @@ export type LabelWorkflowProps = {
24
24
  onLabelCreateSuccess?: (label: {
25
25
  labelId: string;
26
26
  }, shipment: Shipment) => void;
27
+ /**
28
+ * `onRateSaved` is an async/sync callback function that will be invoked each time a rate is
29
+ * saved by the user.
30
+ */
31
+ onRateSaved?: (shipment: SE.SalesOrderShipment) => Promise<void> | void;
27
32
  /**
28
33
  * `onVoidLabelComplete` is a callback function that will be invoked when the request to void a given
29
34
  * shipping label is completed.
@@ -67,6 +72,11 @@ export declare const useLabelWorkflow: ({ _multiplexedId, }: {
67
72
  onLabelCreateSuccess?: ((label: {
68
73
  labelId: string;
69
74
  }, shipment: Shipment) => void) | undefined;
75
+ /**
76
+ * `onRateSaved` is an async/sync callback function that will be invoked each time a rate is
77
+ * saved by the user.
78
+ */
79
+ onRateSaved?: ((shipment: SE.SalesOrderShipment) => Promise<void> | void) | undefined;
70
80
  /**
71
81
  * `onVoidLabelComplete` is a callback function that will be invoked when the request to void a given
72
82
  * shipping label is completed.
@@ -101,6 +101,14 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
101
101
  };
102
102
  errorMessages: {
103
103
  labelIdRequired: string;
104
+ /**
105
+ * # Onboarding Component Props
106
+ *
107
+ * - These are the base props that will be passed into the `<Onboarding />` component.
108
+ *
109
+ * @see {@link Onboarding.Component | This prop types usage in the `<Onboarding />` component}
110
+ */
111
+ request_failed_to_complete: string;
104
112
  };
105
113
  resultMessages: {
106
114
  approved: string;
@@ -1037,6 +1045,9 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
1037
1045
  tooManyCharacters: string;
1038
1046
  requiredShipmentId: string;
1039
1047
  requiredLabelId: string;
1048
+ heightExceeded: string;
1049
+ widthExceeded: string;
1050
+ lengthExceeded: string;
1040
1051
  };
1041
1052
  shippingPresets: {
1042
1053
  apply: string;
@@ -1111,7 +1122,12 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
1111
1122
  transactionHistory: string;
1112
1123
  adjustmentHistory: string;
1113
1124
  warehouses: string;
1114
- carriers: string;
1125
+ carriers: {
1126
+ title: string;
1127
+ customStatusMessages: {
1128
+ success: string;
1129
+ };
1130
+ };
1115
1131
  externalCarriers: string;
1116
1132
  labelLayout: string;
1117
1133
  unitSettings: string;
package/suspend-text.js CHANGED
@@ -1 +1 @@
1
- import{K as e,M as t,N as n,O as a,Q as o,U as i,X as r,Y as s,Z as c,_ as l,$ as g,a0 as p,J as d,a1 as m,a2 as u,G as h}from"./actions-menu.js";import{jsxs as b,jsx as f,Fragment as C}from"@emotion/react/jsx-runtime";import{useState as w,useRef as S,useCallback as x}from"react";import{useTranslation as O,Trans as v}from"react-i18next";import{Button as j,ButtonVariant as I,Icon as y,IconSize as T,DropdownOptionList as k,Option as E,Pagination as P,Typography as _,Skeleton as D,SkeletonAnimation as M,SkeletonVariant as R}from"@shipengine/giger";import{IconNames as A}from"@shipengine/giger-theme";import{b as W}from"./validation.js";var z=Object.freeze({__proto__:null,CheckboxInput:e,CreditCardInput:t,DatePicker:n,ExpirationInput:a,InputGroup:o,transform:i,MoneyInput:r,NumberInput:s,RateSelect:c,SelectAutoComplete:l,Select:g,SelectWithCategories:p,SubmitButton:d,Switch:m,TextArea:u,TextInput:h});const B=W({footer:{"> *":{borderTop:"0 !important"},alignItems:"center",display:"flex",justifyContent:"space-between",width:"100%"},leftFooter:e=>({display:"flex",margin:e.spacing(2),span:{fontWeight:e.typography.fontWeight.bold}}),rowCount:e=>({alignItems:"center",display:"flex",marginRight:e.spacing(4),whiteSpace:"pre"}),rowCountDropDown:{"> * > *":{justifyContent:"center !important"}},rowsActions:e=>({"#selected-row":{":hover":{backgroundColor:"transparent"},borderRadius:e.borderRadius.XS,color:e.palette.black,padding:e.spacing(1),paddingRight:e.spacing(.5)},alignItems:"baseline",display:"flex",span:{alignSelf:"center"}})}),N=[5,10,25,50],X=({currentPageSize:e,pagingData:t,rowCountSelection:n=N,onPageSelect:a,onPageSizeSelect:o})=>{const[i,r]=w(!1),s=S(null),{t:c}=O(),l=x((()=>r((e=>!e))),[]);return b("div",Object.assign({css:B.footer},{children:[b("div",Object.assign({css:B.leftFooter},{children:[f("div",Object.assign({css:B.rowCount},{children:f(v,{components:[f("b",{style:{fontWeight:"bold"}},"1")],count:t.total,i18nKey:"common:grid.row-count",values:{firstIndex:0!==t.total?1+(t.page-1)*e:0,lastIndex:Math.min(t.total,t.page*e)}})})),b("div",Object.assign({css:B.rowsActions},{children:[c("common:grid.rows"),f(j,Object.assign({id:"selected-row",onClick:()=>l(),ref:s,variant:I.TEXT},{children:e})),f(y,i?{name:A.CHEVRON_TOP,onClick:()=>l(),size:T.SIZE_MEDIUM}:{name:A.CHEVRON_BOTTOM,onClick:()=>l(),size:T.SIZE_MEDIUM}),f(k,Object.assign({css:B.rowCountDropDown,dropdownWidth:"max-content",isOpen:i,onChange:()=>l(),onClickAway:e=>{var t;(null===(t=s.current)||void 0===t?void 0:t.contains(e.target))||l()},placement:"bottom",reference:s.current},{children:n.map((e=>f(E,Object.assign({onClick:()=>o(e),value:String(e)},{children:e}),e)))}))]}))]})),f("div",{children:f(P,{boundaryPagesToShow:5,currentPage:t.page,onPageChange:a,totalPages:t.pages})})]}))},U=({children:e,notes:t})=>b(C,{children:[b("div",Object.assign({css:()=>({backgroundColor:"lightsteelblue",marginBottom:"16px",padding:"16px",paddingLeft:"32px"})},{children:[f(_,Object.assign({variant:"heading5"},{children:"Story notes:"})),f("ul",Object.assign({css:e=>({"> li":{marginTop:e.spacing(1)}})},{children:t.map((e=>f("li",{children:e},e)))}))]})),f("hr",{css:()=>({backgroundColor:"transparent",borderTop:"1px dotted lightgrey",marginBottom:"16px"})}),e]}),V=({children:e,loading:t})=>t?f(D,{animation:M.WAVE,variant:R.TEXT}):f("span",{children:e});export{X as P,U as S,V as a,z as f};
1
+ import{K as e,M as t,N as n,O as a,Q as o,U as i,X as r,Y as s,Z as c,_ as l,$ as g,a0 as p,J as d,a1 as m,a2 as u,G as h}from"./actions-menu.js";import{jsxs as b,jsx as f,Fragment as C}from"@emotion/react/jsx-runtime";import{useState as w,useRef as S,useCallback as x}from"react";import{useTranslation as O,Trans as v}from"react-i18next";import{Button as j,ButtonVariant as I,Icon as y,IconSize as T,DropdownOptionList as k,Option as E,Pagination as P,Typography as _,Skeleton as D,SkeletonAnimation as M,SkeletonVariant as R}from"@shipengine/giger";import{IconNames as A}from"@shipengine/giger-theme";import{b as W,s as z}from"./validation.js";var B=Object.freeze({__proto__:null,CheckboxInput:e,CreditCardInput:t,DatePicker:n,ExpirationInput:a,InputGroup:o,transform:i,MoneyInput:r,NumberInput:s,RateSelect:c,SelectAutoComplete:l,Select:g,SelectWithCategories:p,SubmitButton:d,Switch:m,TextArea:u,TextInput:h});const N=W({footer:{"> *":{borderTop:"0 !important"},alignItems:"center",display:"flex",justifyContent:"space-between",width:"100%"},leftFooter:e=>({display:"flex",margin:z(e).spacing(2),span:{fontWeight:z(e).typography.fontWeight.bold}}),rowCount:e=>({alignItems:"center",display:"flex",marginRight:z(e).spacing(4),whiteSpace:"pre"}),rowCountDropDown:{"> * > *":{justifyContent:"center !important"}},rowsActions:e=>({"#selected-row":{":hover":{backgroundColor:"transparent"},borderRadius:z(e).borderRadius.XS,color:z(e).palette.black,padding:z(e).spacing(1),paddingRight:z(e).spacing(.5)},alignItems:"baseline",display:"flex",span:{alignSelf:"center"}})}),X=[5,10,25,50],U=({currentPageSize:e,pagingData:t,rowCountSelection:n=X,onPageSelect:a,onPageSizeSelect:o})=>{const[i,r]=w(!1),s=S(null),{t:c}=O(),l=x((()=>r((e=>!e))),[]);return b("div",Object.assign({css:N.footer},{children:[b("div",Object.assign({css:N.leftFooter},{children:[f("div",Object.assign({css:N.rowCount},{children:f(v,{components:[f("b",{style:{fontWeight:"bold"}},"1")],count:t.total,i18nKey:"common:grid.row-count",values:{firstIndex:0!==t.total?1+(t.page-1)*e:0,lastIndex:Math.min(t.total,t.page*e)}})})),b("div",Object.assign({css:N.rowsActions},{children:[c("common:grid.rows"),f(j,Object.assign({id:"selected-row",onClick:()=>l(),ref:s,variant:I.TEXT},{children:e})),f(y,i?{name:A.CHEVRON_TOP,onClick:()=>l(),size:T.SIZE_MEDIUM}:{name:A.CHEVRON_BOTTOM,onClick:()=>l(),size:T.SIZE_MEDIUM}),f(k,Object.assign({css:N.rowCountDropDown,dropdownWidth:"max-content",isOpen:i,onChange:()=>l(),onClickAway:e=>{var t;(null===(t=s.current)||void 0===t?void 0:t.contains(e.target))||l()},placement:"bottom",reference:s.current},{children:n.map((e=>f(E,Object.assign({onClick:()=>o(e),value:String(e)},{children:e}),e)))}))]}))]})),f("div",{children:f(P,{boundaryPagesToShow:5,currentPage:t.page,onPageChange:a,totalPages:t.pages})})]}))},V=({children:e,notes:t})=>b(C,{children:[b("div",Object.assign({css:()=>({backgroundColor:"lightsteelblue",marginBottom:"16px",padding:"16px",paddingLeft:"32px"})},{children:[f(_,Object.assign({variant:"heading5"},{children:"Story notes:"})),f("ul",Object.assign({css:e=>({"> li":{marginTop:z(e).spacing(1)}})},{children:t.map((e=>f("li",{children:e},e)))}))]})),f("hr",{css:()=>({backgroundColor:"transparent",borderTop:"1px dotted lightgrey",marginBottom:"16px"})}),e]}),Z=({children:e,loading:t})=>t?f(D,{animation:M.WAVE,variant:R.TEXT}):f("span",{children:e});export{U as P,V as S,Z as a,B as f};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"@emotion/react/jsx-runtime";import{S as a,c as s,e as r,u as i,M as l,d as o,E as d,f as c,U as p,g,h as u,i as h,P as m,T as b}from"./use-unit-settings.js";import{T as v,h as C,l as f,q as O,x as j,u as y,P as S,y as w}from"./actions-menu.js";import{t as x,x as I,v as k,a1 as E}from"./carrier.js";import{useState as _,useCallback as T,useRef as F,useEffect as P,useMemo as A,useContext as D,createContext as L}from"react";import{useTranslation as R}from"react-i18next";import{Icon as z,IconSize as N,Select as B,Option as $,Input as M,Popover as W,Typography as U,TagColor as G,Next as V,Tag as H,TagVariant as K,EmptyState as q,Button as Z}from"@shipengine/giger";import{useListLabels as Y,useGetLabel as J,useListShipments as Q,useGetShipment as X}from"@shipengine/react-api";import{u as ee}from"./use-get-service-name.js";import{D as te,u as ne,C as ae,E as se,G as re,b as ie,a as le}from"./usePager.js";import{b as oe}from"./validation.js";import{f as de,g as ce}from"./use-toggle.js";import{formatISO as pe}from"date-fns/formatISO";import{isSameDay as ge}from"date-fns/isSameDay";import{isWithinInterval as ue}from"date-fns/isWithinInterval";import{setHours as he}from"date-fns/setHours";import{setMinutes as me}from"date-fns/setMinutes";import{IconNames as be}from"@shipengine/giger-theme";const ve=oe({category:{alignItems:"center",cursor:"pointer",display:"flex",flexDirection:"row",justifyContent:"space-between"},colorPicker:e=>({"&::-webkit-color-swatch":{border:`1px solid ${e.palette.gray.light}`,borderRadius:"4px",padding:0},"&::-webkit-color-swatch-wrapper":{padding:0},alignSelf:"center",appearance:"none",background:"none",border:0,cursor:"pointer",height:e.spacing(4.25),outline:"none",width:e.spacing(4.25)}),container:e=>({marginBottom:e.spacing(2)}),input:e=>({border:`1px solid ${e.palette.gray.light}`,borderRadius:"4px",color:e.palette.gray.main,fontSize:"14px",padding:e.spacing(1)}),inputContainer:e=>({alignItems:"center",display:"flex",flexDirection:"row",justifyContent:"space-between",padding:`${e.spacing(2)}px 0`}),wrapper:e=>({display:"flex",gap:e.spacing(1)})}),Ce=({paletteConfig:n,onUpdatePaletteConfig:a,formatKey:s})=>{const[r,i]=_(new Set),l=e=>{i((t=>{const n=new Set(t);return n.has(e)?new Set([...n].filter((t=>t!==e))):new Set([...n,e])}))},o=T(((e,t,s)=>{const r=(e=>{if(e)return e.match(/^#[0-9A-Fa-f]{0,6}$/)?e:e.match(/^[0-9A-Fa-f]{6}$/)?`#${e}`:void 0})(s),i=Object.assign(Object.assign({},n||{}),{[e]:Object.assign(Object.assign({},(null==n?void 0:n[e])||{}),{[t]:r})});a(i)}),[a,n]);return e("div",Object.assign({"data-test-id":"color-palette-editor"},{children:n&&Object.keys(n).map((a=>t("div",Object.assign({css:ve.container,id:a},{children:[t("div",Object.assign({"aria-expanded":r.has(a),css:ve.category,onClick:e=>{e.preventDefault(),l(a)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l(a))},role:"button",tabIndex:0},{children:[e("p",{children:x(a)}),e(z,{name:r.has(a)?be.CHEVRON_TOP:be.CHEVRON_BOTTOM,size:N.SIZE_REGULAR})]})),r.has(a)&&Object.keys(n[a]).map((r=>t("div",Object.assign({css:ve.inputContainer,id:"input-container"},{children:[e("label",Object.assign({css:{fontWeight:"bold"},htmlFor:`${a}.${r}`},{children:s(r)})),t("form",Object.assign({css:ve.wrapper},{children:[e("input",{css:ve.input,onChange:e=>{e.preventDefault(),o(a,r,e.target.value)},onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},type:"text",value:n[a][r]}),e("input",{css:ve.colorPicker,onChange:e=>o(a,r,e.target.value),type:"color",value:n[a][r]})]}))]}),r)))]}),a)))}))},fe=oe({input:e=>({border:`1px solid ${e.palette.gray.light}`,borderRadius:"4px",color:e.palette.gray.main,fontSize:"14px",maxWidth:e.spacing(16),padding:0}),keys:{fontSize:"16px",fontWeight:"bold",marginTop:"8px"},section:e=>({"& > div:first-child":{flexGrow:3},"& > div:last-child":{flexShrink:1},display:"flex",gap:e.spacing(1),justifyContent:"space-between"}),sectionContainer:e=>({marginBottom:e.spacing(4)}),select:e=>({border:`1px solid ${e.palette.gray.light}`,borderRadius:"4px",color:e.palette.gray.main,fontSize:"14px"})}),Oe=({onUpdateTypographyConfig:a,typographyConfig:s,formatKey:r})=>{const i=T(((e,t,n)=>{const r=Object.assign(Object.assign({},s||{}),{[e]:Object.assign(Object.assign({},(null==s?void 0:s[e])||{}),{[t]:n})});a(r)}),[a,s]),l=T(((e,t)=>{if(e)return e[t]}),[]),o=(t,n)=>{var a;const r=[{label:"Normal",value:"400"},{label:"Semi Bold",value:"600"},{label:"Bold",value:"700"}],o=null===(a=l(s,t))||void 0===a?void 0:a.fontWeight.toString(),d=void 0!==o?r.find((e=>e.value===o)):void 0;return e(B,Object.assign({css:fe.select,label:"Font Weight",name:"font-weight",onChange:(e,a)=>i(t,n,null==a?void 0:a.value),value:d},{children:r.map((t=>e($,Object.assign({value:t.value},{children:t.label}),t.value)))}))},d=(t,n)=>{var a;const r=null===(a=l(s,t))||void 0===a?void 0:a.fontSize.replace("px","");return e(M,{"aria-labelledby":`${t}.${n}`,css:fe.input,label:"Font Size(px)",onChange:e=>{e.target.value.match(/^\d{0,2}$/)&&i(t,n,`${e.target.value}px`)},value:r})},c=(t,a)=>{switch(a){case"fontWeight":return e(n,{children:o(t,a)});case"fontSize":return e(n,{children:d(t,a)});default:return null}};return e("div",{children:s&&Object.keys(s).map((n=>t("div",Object.assign({css:fe.sectionContainer},{children:[e("p",Object.assign({css:fe.keys,id:n},{children:r(n)})),e("section",Object.assign({css:fe.section},{children:Object.keys(s[n]).map((t=>e("div",Object.assign({id:`${n}.${t}`},{children:c(n,t)}),t)))}))]}),n)))})},je=oe({container:e=>({color:e.palette.gray.dark,display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",position:"relative"}),content:e=>({display:"flex",flexDirection:"column",gap:e.spacing(3),padding:e.spacing(3)}),copy:e=>({backgroundColor:e.palette.white,borderRadius:"4px",padding:e.spacing(.5)}),drawerHeader:e=>({alignItems:"center",display:"flex",gap:e.spacing(2),justifyContent:"end",width:"50%"}),drawerWrapper:{display:"flex",justifyContent:"space-between",position:"relative"},header:{alignItems:"center",display:"flex",justifyContent:"space-between"},popoverWrapper:e=>({display:"flex",flexDirection:"column",gap:e.spacing(1)}),pre:e=>({backgroundColor:"#FFFFFF66",borderRadius:"8px",fontSize:"14px",padding:e.spacing(.3)}),presetOption:e=>({"&:hover":{backgroundColor:"theme.palette.gray.ultraLight"},backgroundColor:"transparent",borderRadius:"4px",fontSize:"14px",padding:e.spacing(1)}),presetsButton:e=>({"&:hover":{backgroundColor:"#d1d4d7"},backgroundColor:"#E4E5E7",borderRadius:"4px",cursor:"pointer",display:"flex",fontSize:"14px",gap:e.spacing(.5),padding:`${e.spacing(.5)}px ${e.spacing(1)}px`})}),ye=({themeConfig:n,onUpdateThemeConfig:a,presets:s,showDrawer:r})=>{const i=F(n),[l,o]=_(!1),d=Object.keys(n).flatMap((e=>{if("components"===e&&n[e]&&"object"==typeof n[e]){return Object.keys(n[e])}return[e]})).map((e=>"palette"===e?{label:"Color Palette",value:"Color Palette"}:{label:x(e),value:x(e)})),[c,p]=_(d.sort()[0].value),g=e=>I(k(e)),u=F(null),[h,m]=de(!1),b=e=>{a(e)};return t("div",Object.assign({"aria-label":"Theme Creator",css:je.container,"data-testid":"theme-creator",role:"region"},{children:[t("div",Object.assign({css:je.content},{children:[t("div",Object.assign({css:je.header},{children:[e(v,{onSelectTab:e=>{p(e)},selectedTab:c,tabs:d}),s?t("div",{children:[t("button",Object.assign({"aria-controls":"presets-popover","aria-expanded":h,css:je.presetsButton,onClick:e=>{e.preventDefault(),m()},ref:u},{children:["Presets",e(z,{name:be.CARET_BOTTOM,size:N.SIZE_SMALL})]})),e(W,Object.assign({container:document.querySelector("#theme-creator"),isOpen:h,onClickAway:()=>m(),placement:"bottom-end",reference:u.current},{children:t("div",Object.assign({css:je.popoverWrapper},{children:[e("button",Object.assign({"aria-label":"Set Default Theme",css:je.presetOption,onClick:e=>{e.preventDefault(),m(),b(i.current)},role:"menuitem"},{children:"Default"})),s.map((t=>e("button",Object.assign({"aria-label":`Set ${t.presetName} Theme`,css:je.presetOption,onClick:e=>{e.preventDefault(),m(),b(t.themeConfig)},role:"menuitem"},{children:t.presetName}),t.presetName)))]}))}))]}):e("button",Object.assign({"aria-label":"Set Default Theme",css:je.presetsButton,onClick:()=>{b(i.current)},role:"menuitem"},{children:"Reset to Default"}))]})),e(U,Object.assign({role:"heading",variant:"heading4"},{children:`${c} Editor`})),((t,n)=>{var s;switch(n){case"Color Palette":return e(Ce,{formatKey:g,onUpdatePaletteConfig:e=>{a(Object.assign(Object.assign({},t),{palette:e}))},paletteConfig:t.palette});case"Typography":return e(Oe,{formatKey:g,onUpdateTypographyConfig:e=>{a(Object.assign(Object.assign({},t),{components:Object.assign(Object.assign({},t.components),{Typography:e})}))},typographyConfig:null===(s=t.components)||void 0===s?void 0:s.Typography});default:return null}})(n,c)]})),r&&e(te,Object.assign({"aria-label":"Show themeConfig.js Code Drawer",headerContent:t("div",Object.assign({css:je.drawerHeader},{children:[e("pre",Object.assign({css:je.pre},{children:"themeConfig.js"})),r.copyToClipboardText&&e("div",Object.assign({css:je.copy},{children:e(C,{content:r.copyToClipboardText})}))]})),isOpen:l,toggleDrawer:()=>o(!l)},{children:r.content}))]}))},Se=({onRedirectToOnboarding:t})=>e(a,{onRedirectToOnboarding:t}),we=s(Se,f,{resources:{en:r}});var xe=Object.freeze({__proto__:null,Component:Se,Element:we});const Ie=()=>{const t=E(i(),[]);return e(l,Object.assign({},t))},ke=s(Ie,f,{resources:{en:r}});var Ee=Object.freeze({__proto__:null,Component:Ie,Element:ke});const _e=({isModalFullScreen:t})=>{const n=E(o(),[]);return e(d,Object.assign({isModalFullScreen:t},n))},Te=s(_e,f,{resources:{en:r}});var Fe=Object.freeze({__proto__:null,Component:_e,Element:Te});const Pe=oe({errorState:e=>Object.assign({backgroundColor:e.palette.white},e.getComponentOverride("Table")),tableParagraph:{margin:0}}),Ae=({labelStatus:a,features:s,onClickPrintLabel:r,onClickVoidLabel:i,onClickPrintForms:l,onClickViewDetails:o,onRowClick:d,onClickExternalOrderId:c,onClickExternalShipmentId:p})=>{var g,u;const{t:h}=R(["common","list-labels"]),{globalFeatures:m,getFeatures:b}=ce(),v=b("labelsGridFeatures");s=Object.assign(Object.assign({},v),null!=s?s:{});const C=A((()=>{var e;return null===(e=null==s?void 0:s.columns)||void 0===e?void 0:e.find((e=>"labelId"===e.name))}),[s]),f=A((()=>{var e;return null===(e=null==s?void 0:s.columns)||void 0===e?void 0:e.find((e=>"shipmentId"===e.name))}),[s]),x=C&&(null===(g=C.allowFilter)||void 0===g||g),I=f&&(null===(u=f.allowFilter)||void 0===u||u),{labels:k,getGridData:E,isError:T,isLoading:F,filters:D,setFilters:L,pageConfig:z,isAnyFilterActive:N,shouldShowFilters:B,clearAllFilters:$}=(({labelStatus:e,showShipmentIdFilter:t,showLabelIdFilter:n})=>{var a,s;const r={labelId:{enabled:!!n,value:""},shipmentId:{enabled:!!t,value:""}},{getServiceName:i}=ee(),{page:l,pageSize:o,pagerProps:d}=ne(20),[c,p]=_(r),g=Object.keys(c).some((e=>{const t=c[e];return(null==t?void 0:t.enabled)&&t.value})),u=Object.keys(c).some((e=>{const t=c[e];return null==t?void 0:t.enabled}));P((()=>{p({labelId:{enabled:!!n,value:""},shipmentId:{enabled:!!t,value:""}})}),[n,t]);const{data:h,isLoading:m,isError:b}=Y({queryFnParams:{labelStatus:e,page:l,pageSize:o,shipmentId:c.shipmentId.value||void 0,sortBy:"modified_at",sortDir:"desc"}}),v=A((()=>(null==h?void 0:h.labels.map((e=>Object.assign(Object.assign({},e),{serviceName:i(e)}))))||[]),[null==h?void 0:h.labels,i]),C=u&&(g||Boolean(null==v?void 0:v.length)),{data:f,isError:O,isInitialLoading:j}=J((null===(a=c.labelId)||void 0===a?void 0:a.value)||void 0),y=null===(s=c.labelId)||void 0===s?void 0:s.value,S=(t=>{if(y&&!O){let n=!0;return e&&e!==(null==t?void 0:t.status)&&(n=!1),""!==(null==c?void 0:c.shipmentId.value)&&(null==c?void 0:c.shipmentId.value)!==(null==t?void 0:t.shipmentId)&&(n=!1),n?t:void 0}})(f),w=y&&(O||!S);return{clearAllFilters:()=>{p(r)},filters:c,getGridData:()=>S?[Object.assign(Object.assign({},S),{serviceName:i(S)})]:w?[]:v||[],isAnyFilterActive:g,isError:b,isLoading:m||j,labels:v,pageConfig:{currentPage:S?1:(null==h?void 0:h.page)||0,pagerProps:d,pagesAmount:(null==h?void 0:h.pages)||0,pageSize:o,showPagination:!S&&((null==h?void 0:h.total)||0)>o,totalElements:S?1:(null==h?void 0:h.total)||0},setFilters:e=>{d.onPageSelect(1),p(e)},shouldShowFilters:C}})({labelStatus:a,showLabelIdFilter:x,showShipmentIdFilter:I}),M=A((()=>({labelId:Object.assign(Object.assign({},D.labelId),{nickname:null==C?void 0:C.nickname}),shipmentId:Object.assign(Object.assign({},D.shipmentId),{nickname:null==f?void 0:f.nickname})})),[D,C,f]),W=A((()=>{var a;const r={completed:{color:G.SUCCESS,text:h("list-labels:status.completed")},error:{color:G.ERROR,text:h("list-labels:status.error")},processing:{color:G.INFO,text:h("list-labels:status.processing")},voided:{color:G.INFO,text:h("list-labels:status.voided")}},i={delivered:{color:G.SUCCESS,text:h("list-labels:trackingStatus.delivered")},error:{color:G.ERROR,text:h("list-labels:trackingStatus.error")},in_transit:{color:G.GRAY,text:h("list-labels:trackingStatus.inTransit")},unknown:{color:G.ALERT,text:h("list-labels:trackingStatus.unknown")}},l={createdDate:{headerContent:h("list-labels:headers.created"),renderCellContent:t=>e(ae,{date:t.createdAt,short:!0})},externalOrderId:{headerContent:h("list-labels:headers.externalOrderId"),renderCellContent:t=>t.externalOrderId&&c?e(V.Link,Object.assign({bold:!1,onClick:()=>{var e;return null==c?void 0:c(null!==(e=t.externalOrderId)&&void 0!==e?e:void 0)}},{children:t.externalOrderId})):e(U,Object.assign({component:"span",variant:"body2"},{children:t.externalOrderId}))},externalShipmentId:{headerContent:h("list-labels:headers.externalShipmentId"),renderCellContent:t=>t.externalShipmentId&&p?e(V.Link,Object.assign({bold:!1,onClick:()=>{var e;return null==p?void 0:p(null!==(e=t.externalShipmentId)&&void 0!==e?e:void 0)}},{children:t.externalShipmentId})):e(U,Object.assign({component:"span",variant:"body2"},{children:t.externalShipmentId}))},labelId:{headerContent:h("list-labels:headers.labelId"),renderCellContent:t=>e(U,Object.assign({component:"span",variant:"body2"},{children:t.labelId}))},packages:{headerContent:h("list-labels:headers.parcels"),renderCellContent:t=>e(U,Object.assign({component:"span",variant:"body2"},{children:t.packages.length}))},recipient:{headerContent:h("list-labels:headers.recipient"),renderCellContent:a=>t(n,{children:[e(U,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:a.shipTo.name})),t(U,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:[a.shipTo.postalCode,", ",a.shipTo.cityLocality]}))]})},shipDate:{headerContent:h("list-labels:headers.shipDate"),renderCellContent:t=>e(ae,{date:t.shipDate,short:!0})},shipmentId:{headerContent:h("list-labels:headers.shipmentId"),renderCellContent:t=>e(U,Object.assign({component:"span",variant:"body2"},{children:t.shipmentId}))},shippingService:{headerContent:h("list-labels:headers.shipping"),renderCellContent:a=>t(n,{children:[e(U,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:a.serviceName||a.serviceCode})),a.trackable&&e(V.Link,Object.assign({bold:!1,href:a.trackingUrl,isExternal:!0,target:"_blank"},{children:a.trackingNumber}))]})},status:{headerContent:h("list-labels:headers.status"),renderCellContent:t=>e(H,Object.assign({color:r[t.status].color,variant:K.LINEAL_FILLED},{children:r[t.status].text}))},trackingStatus:{headerContent:h("list-labels:headers.trackingStatus"),renderCellContent:t=>e(H,Object.assign({color:i[t.trackingStatus].color,variant:K.LINEAL_FILLED},{children:i[t.trackingStatus].text}))}},o=[];return null===(a=null==s?void 0:s.columns)||void 0===a||a.forEach((e=>{l[e.name]&&(e.nickname?o.push(Object.assign(Object.assign({},l[e.name]),{headerContent:e.nickname})):o.push(l[e.name]))})),o}),[s,h,c,p]);if(F)return e(O,{message:h("loading.labels")});if(T)return e(se,{css:Pe.errorState,subtitle:[h("list-labels:errorMessages.subtitle"),h("errorMessages.refreshAndTryAgain")],title:h("list-labels:errorMessages.title")});const Q=(e,t)=>{e===w.PRINT_LABEL&&(e=>{null==r||r(),window.open(e.labelDownload.href,"_blank","noopener, noreferrer")})(t),e===w.VOID_LABEL&&(null==i||i(t)),e===w.PRINT_FORMS&&(e=>{null==l||l(),window.open(e.formDownload.href,"_blank","noopener, noreferrer")})(t),e===w.VIEW_DETAILS&&(null==o||o(t))};return(null==s?void 0:s.showActions)&&k.some((e=>"completed"===e.status))&&W.push({headerContent:"",renderCellContent:t=>{var n,a;const s=!!(null===(n=t.labelDownload)||void 0===n?void 0:n.href)&&"completed"===t.status,r=!!i&&"completed"===t.status,l=!!(null===(a=t.formDownload)||void 0===a?void 0:a.href)&&"completed"===t.status,d=!!o;if(!(s||r||l||d))return null;const c=[...d?[w.VIEW_DETAILS]:[],...s?[w.PRINT_LABEL]:[],...r?[w.VOID_LABEL]:[],...l?[w.PRINT_FORMS]:[]];return e(j,{allowedActions:c,onActionClick:e=>Q(e,t)})}}),t(n,{children:[e(re,{columns:W,data:E(),emptyContent:e(q,N?Object.assign({isElevated:!1,subtitle:h("list-labels:emptyWithFilters.subtitle"),title:h("list-labels:emptyWithFilters.title")},{children:e(Z,Object.assign({onClick:$},{children:h("list-labels:emptyWithFilters.button")}))}):{isElevated:!1,subtitle:h("list-labels:empty.subtitle"),title:h("list-labels:empty.title")}),filters:B&&e(ie,{filters:M,onClearAllFilters:$,onFiltersUpdated:L}),footerContent:e(le,{onPageChange:z.pagerProps.onPageSelect,page:z.currentPage,pages:z.pagesAmount,pageSize:z.pageSize,showPagination:z.showPagination,total:z.totalElements}),onRowClick:d}),m.poweredByShipEngine&&t(n,{children:[e(y,{}),e(S,{})]})]})},De=s(Ae,f,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var Le=Object.freeze({__proto__:null,Component:Ae,Element:De});const Re=(e,t)=>({end:he(me(t,59),23),start:he(me(e,0),0)}),ze=(e,t)=>({createdDate:{enabled:t,value:null},shipmentId:{enabled:e,value:""}}),Ne=({shipmentStatus:e,showShipmentIdFilter:t=!0,showCreatedDateFilter:n=!0})=>{var a,s,r,i;const l=ze(t,n),{getServiceName:o}=ee(),{page:d,pageSize:c,pagerProps:p}=ne(20),[g,u]=_(l),h=Object.keys(g).some((e=>{const t=g[e];return(null==t?void 0:t.enabled)&&t.value})),m=Object.keys(g).some((e=>{const t=g[e];return null==t?void 0:t.enabled}));P((()=>{const e=ze(t,n);u(e)}),[n,t]);const{data:b,isLoading:v,isError:C}=Q(Object.assign({page:d,pageSize:c,shipmentStatus:e,sortBy:"modified_at",sortDir:"desc"},((e,t)=>{if(!e||!t)return{};const n=Re(e,t);return{createdAtEnd:pe(n.end),createdAtStart:pe(n.start)}})(null===(s=null===(a=g.createdDate)||void 0===a?void 0:a.value)||void 0===s?void 0:s.start,null===(i=null===(r=g.createdDate)||void 0===r?void 0:r.value)||void 0===i?void 0:i.end))),f=A((()=>null==b?void 0:b.shipments.map((e=>Object.assign(Object.assign({},e),{serviceName:o(e)})))),[null==b?void 0:b.shipments,o]),O=m&&(h||Boolean(null==f?void 0:f.length)),{data:j,error:y,isInitialLoading:S}=X({queryFnParams:{shipmentId:g.shipmentId.value||void 0},retry:!1}),w=g.shipmentId.value,x=(t=>{var n,a,s,r;if(w&&!y){let i=!0;e&&(null==t?void 0:t.shipmentStatus)!==e&&(i=!1);const l=null===(n=g.createdDate)||void 0===n?void 0:n.value;return(null==l?void 0:l.start)&&l.end&&(null==t?void 0:t.createdAt)&&(a=l.start,s=l.end,r=t.createdAt,ge(a,s)&&ge(a,new Date(r))||ue(new Date(r),Re(a,s))||(i=!1)),i?t:void 0}})(j),I=w&&(y||!x);return{clearAllFilters:()=>{u(l)},filters:g,getGridData:()=>x?[Object.assign(Object.assign({},x),{serviceName:o(x)})]:I?[]:f||[],isAnyFilterActive:h,isError:C,isLoading:v||S,pageConfig:{currentPage:x?1:(null==b?void 0:b.page)||0,pagerProps:p,pagesAmount:(null==b?void 0:b.pages)||0,pageSize:c,showPagination:!x&&((null==b?void 0:b.total)||0)>c,totalElements:x?1:(null==b?void 0:b.total)||0},setFilters:e=>{p.onPageSelect(1),u(e)},shipments:f,shouldShowFilters:O}},Be=oe({errorState:e=>Object.assign({backgroundColor:e.palette.white},e.getComponentOverride("Table")),tableParagraph:{margin:0}}),$e=({onRowClick:a,onClickCancelShipment:s,shipmentStatus:r,showShipmentIdFilter:i=!0,showCreatedDateFilter:l=!0})=>{const{t:o}=R(["common","list-shipments"]),{globalFeatures:d}=ce(),{isLoading:c,isError:p,filters:g,setFilters:u,pageConfig:h,getGridData:m,isAnyFilterActive:b,shouldShowFilters:v,clearAllFilters:C}=Ne({shipmentStatus:r,showCreatedDateFilter:l,showShipmentIdFilter:i});if(c)return e(O,{message:o("loading.shipments")});if(p)return e(se,{css:Be.errorState,subtitle:[o("list-shipments:errorMessages.subtitle"),o("errorMessages.refreshAndTryAgain")],title:o("list-shipments:errorMessages.title")});const f={cancelled:{color:G.ALERT,text:o("list-shipments:status.cancelled")},label_purchased:{color:G.SUCCESS,text:o("list-shipments:status.purchased")},pending:{color:G.SUCCESS,text:o("list-shipments:status.readyToBuy")},processing:{color:G.INFO,text:o("list-shipments:status.processing")}},x=[{headerContent:o("list-shipments:headers.shipmentId"),renderCellContent:t=>e(U,Object.assign({component:"p",css:Be.tableParagraph,variant:"body2"},{children:t.shipmentId}))},{headerContent:o("list-shipments:headers.parcels"),renderCellContent:t=>e(U,Object.assign({component:"p",css:Be.tableParagraph,variant:"body2"},{children:t.packages.length}))},{headerContent:o("list-shipments:headers.recipient"),renderCellContent:a=>{const s=!!(a.shipTo.name||a.shipTo.postalCode||a.shipTo.cityLocality),r=!(!a.shipTo.postalCode&&!a.shipTo.cityLocality);return s?t(n,{children:[e(U,Object.assign({component:"p",css:Be.tableParagraph,variant:"body2"},{children:a.shipTo.name})),r&&e(U,Object.assign({component:"p",css:Be.tableParagraph,variant:"body2"},{children:[a.shipTo.postalCode,a.shipTo.cityLocality].filter(Boolean).join(", ")}))]}):"--"}},{headerContent:o("list-shipments:headers.shipping"),renderCellContent:t=>e(U,Object.assign({component:"p",css:Be.tableParagraph,variant:"body2"},{children:t.serviceName||o("list-shipments:none")}))},{headerContent:o("list-shipments:headers.created"),renderCellContent:t=>e(ae,{date:t.createdAt,short:!0})},{headerContent:o("list-shipments:headers.modified"),renderCellContent:t=>e(ae,{date:t.modifiedAt,short:!0})},{headerContent:o("list-shipments:headers.status"),renderCellContent:t=>e(H,Object.assign({color:f[t.shipmentStatus].color,variant:K.LINEAL_FILLED},{children:f[t.shipmentStatus].text}))},{headerContent:"",renderCellContent:t=>{const n=[...!!s&&"pending"===t.shipmentStatus?[w.CANCEL_SHIPMENT]:[]];return n.length>0&&e(j,{allowedActions:n,onActionClick:e=>((e,t)=>{e===w.CANCEL_SHIPMENT&&(null==s||s(t))})(e,t)})}}];return t(n,{children:[e(re,{columns:x,data:m(),emptyContent:e(q,b?Object.assign({isElevated:!1,subtitle:o("list-shipments:emptyState.filtersSubtitle"),title:o("list-shipments:emptyState.filtersTitle")},{children:e(Z,Object.assign({onClick:C},{children:o("list-shipments:emptyState.viewAll")}))}):{isElevated:!1,subtitle:o("list-shipments:emptyState.subtitle"),title:o("list-shipments:emptyState.title")}),filters:v&&e(ie,{filters:g,onClearAllFilters:C,onFiltersUpdated:u}),footerContent:e(le,{onPageChange:h.pagerProps.onPageSelect,page:h.currentPage,pages:h.pagesAmount,pageSize:h.pageSize,showPagination:h.showPagination,total:h.totalElements}),onRowClick:a}),d.poweredByShipEngine&&t(n,{children:[e(y,{}),e(S,{})]})]})},Me=s($e,f,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var We=Object.freeze({__proto__:null,Component:$e,Element:Me});const Ue=L(void 0),Ge=({children:t,editableTheme:n})=>{const[a,s]=_(n);return e(Ue.Provider,Object.assign({value:{setThemeConfig:s,themeConfig:a}},{children:t}))},Ve=()=>{const e=D(Ue);if(!e)throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");return e},He=t=>{var n=E(t,[]);return e(ye,Object.assign({},n))},Ke=s(He,f,{resources:{en:r}});var qe=Object.freeze({__proto__:null,Component:He,Element:Ke});const Ze=()=>{const t=E(c(),[]);return e(p,Object.assign({},t))},Ye=s(Ze,f,{resources:{en:r}});var Je=Object.freeze({__proto__:null,Component:Ze,Element:Ye});const Qe=({onRedirectToOnboarding:t})=>e(g,{onRedirectToOnboarding:t}),Xe=s(Qe,f,{resources:{en:r}});var et=Object.freeze({__proto__:null,Component:Qe,Element:Xe});const tt=()=>{const t=E(u(),[]);return e(h,Object.assign({},t))},nt=s(tt,f,{resources:{en:r}});var at=Object.freeze({__proto__:null,Component:tt,Element:nt});const st=({onRedirectToOnboarding:t})=>e(m,{onRedirectToOnboarding:t}),rt=s(st,f,{resources:{en:r}});var it=Object.freeze({__proto__:null,Component:st,Element:rt});const lt=()=>e(b,{}),ot=s(lt,f,{resources:{en:r}});var dt=Object.freeze({__proto__:null,Component:lt,Element:ot});export{Ge as T,Ee as a,Fe as b,Je as c,et as d,at as e,dt as f,Le as l,xe as m,it as p,We as s,qe as t,Ve as u};
1
+ import{jsx as e,jsxs as t,Fragment as n}from"@emotion/react/jsx-runtime";import{S as a,c as s,e as r,u as i,M as l,d as o,E as d,f as c,U as p,g,h as u,i as h,P as m,T as b}from"./use-unit-settings.js";import{T as v,h as C,l as f,q as O,x as j,u as y,P as S,y as w}from"./actions-menu.js";import{t as x,x as I,v as k,a1 as E}from"./carrier.js";import{useState as _,useCallback as T,useRef as F,useEffect as P,useMemo as A,useContext as D,createContext as L}from"react";import{useTranslation as R}from"react-i18next";import{Icon as z,IconSize as N,Select as B,Option as $,Input as M,Popover as W,Typography as U,TagColor as G,Next as V,Tag as H,TagVariant as K,EmptyState as q,Button as Z}from"@shipengine/giger";import{useListLabels as Y,useGetLabel as J,useListShipments as Q,useGetShipment as X}from"@shipengine/react-api";import{u as ee}from"./use-get-service-name.js";import{D as te,u as ne,C as ae,E as se,G as re,b as ie,a as le}from"./usePager.js";import{b as oe,s as de}from"./validation.js";import{f as ce,g as pe}from"./use-toggle.js";import{formatISO as ge}from"date-fns/formatISO";import{isSameDay as ue}from"date-fns/isSameDay";import{isWithinInterval as he}from"date-fns/isWithinInterval";import{setHours as me}from"date-fns/setHours";import{setMinutes as be}from"date-fns/setMinutes";import{IconNames as ve}from"@shipengine/giger-theme";const Ce=oe({category:{alignItems:"center",cursor:"pointer",display:"flex",flexDirection:"row",justifyContent:"space-between"},colorPicker:e=>({"&::-webkit-color-swatch":{border:`1px solid ${de(e).palette.gray.light}`,borderRadius:"4px",padding:0},"&::-webkit-color-swatch-wrapper":{padding:0},alignSelf:"center",appearance:"none",background:"none",border:0,cursor:"pointer",height:de(e).spacing(4.25),outline:"none",width:de(e).spacing(4.25)}),container:e=>({marginBottom:de(e).spacing(2)}),input:e=>({border:`1px solid ${de(e).palette.gray.light}`,borderRadius:"4px",color:de(e).palette.gray.main,fontSize:"14px",padding:de(e).spacing(1)}),inputContainer:e=>({alignItems:"center",display:"flex",flexDirection:"row",justifyContent:"space-between",padding:`${de(e).spacing(2)}px 0`}),wrapper:e=>({display:"flex",gap:de(e).spacing(1)})}),fe=({paletteConfig:n,onUpdatePaletteConfig:a,formatKey:s})=>{const[r,i]=_(new Set),l=e=>{i((t=>{const n=new Set(t);return n.has(e)?new Set([...n].filter((t=>t!==e))):new Set([...n,e])}))},o=T(((e,t,s)=>{const r=(e=>{if(e)return e.match(/^#[0-9A-Fa-f]{0,6}$/)?e:e.match(/^[0-9A-Fa-f]{6}$/)?`#${e}`:void 0})(s),i=Object.assign(Object.assign({},n||{}),{[e]:Object.assign(Object.assign({},(null==n?void 0:n[e])||{}),{[t]:r})});a(i)}),[a,n]);return e("div",Object.assign({"data-test-id":"color-palette-editor"},{children:n&&Object.keys(n).map((a=>t("div",Object.assign({css:Ce.container,id:a},{children:[t("div",Object.assign({"aria-expanded":r.has(a),css:Ce.category,onClick:e=>{e.preventDefault(),l(a)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l(a))},role:"button",tabIndex:0},{children:[e("p",{children:x(a)}),e(z,{name:r.has(a)?ve.CHEVRON_TOP:ve.CHEVRON_BOTTOM,size:N.SIZE_REGULAR})]})),r.has(a)&&Object.keys(n[a]).map((r=>t("div",Object.assign({css:Ce.inputContainer,id:"input-container"},{children:[e("label",Object.assign({css:{fontWeight:"bold"},htmlFor:`${a}.${r}`},{children:s(r)})),t("form",Object.assign({css:Ce.wrapper},{children:[e("input",{css:Ce.input,onChange:e=>{e.preventDefault(),o(a,r,e.target.value)},onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},type:"text",value:n[a][r]}),e("input",{css:Ce.colorPicker,onChange:e=>o(a,r,e.target.value),type:"color",value:n[a][r]})]}))]}),r)))]}),a)))}))},Oe=oe({input:e=>({border:`1px solid ${de(e).palette.gray.light}`,borderRadius:"4px",color:de(e).palette.gray.main,fontSize:"14px",maxWidth:de(e).spacing(16),padding:0}),keys:{fontSize:"16px",fontWeight:"bold",marginTop:"8px"},section:e=>({"& > div:first-child":{flexGrow:3},"& > div:last-child":{flexShrink:1},display:"flex",gap:de(e).spacing(1),justifyContent:"space-between"}),sectionContainer:e=>({marginBottom:de(e).spacing(4)}),select:e=>({border:`1px solid ${de(e).palette.gray.light}`,borderRadius:"4px",color:de(e).palette.gray.main,fontSize:"14px"})}),je=({onUpdateTypographyConfig:a,typographyConfig:s,formatKey:r})=>{const i=T(((e,t,n)=>{const r=Object.assign(Object.assign({},s||{}),{[e]:Object.assign(Object.assign({},(null==s?void 0:s[e])||{}),{[t]:n})});a(r)}),[a,s]),l=T(((e,t)=>{if(e)return e[t]}),[]),o=(t,n)=>{var a;const r=[{label:"Normal",value:"400"},{label:"Semi Bold",value:"600"},{label:"Bold",value:"700"}],o=null===(a=l(s,t))||void 0===a?void 0:a.fontWeight.toString(),d=void 0!==o?r.find((e=>e.value===o)):void 0;return e(B,Object.assign({css:Oe.select,label:"Font Weight",name:"font-weight",onChange:(e,a)=>i(t,n,null==a?void 0:a.value),value:d},{children:r.map((t=>e($,Object.assign({value:t.value},{children:t.label}),t.value)))}))},d=(t,n)=>{var a;const r=null===(a=l(s,t))||void 0===a?void 0:a.fontSize.replace("px","");return e(M,{"aria-labelledby":`${t}.${n}`,css:Oe.input,label:"Font Size(px)",onChange:e=>{e.target.value.match(/^\d{0,2}$/)&&i(t,n,`${e.target.value}px`)},value:r})},c=(t,a)=>{switch(a){case"fontWeight":return e(n,{children:o(t,a)});case"fontSize":return e(n,{children:d(t,a)});default:return null}};return e("div",{children:s&&Object.keys(s).map((n=>t("div",Object.assign({css:Oe.sectionContainer},{children:[e("p",Object.assign({css:Oe.keys,id:n},{children:r(n)})),e("section",Object.assign({css:Oe.section},{children:Object.keys(s[n]).map((t=>e("div",Object.assign({id:`${n}.${t}`},{children:c(n,t)}),t)))}))]}),n)))})},ye=oe({container:e=>({color:de(e).palette.gray.dark,display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",position:"relative"}),content:e=>({display:"flex",flexDirection:"column",gap:de(e).spacing(3),padding:de(e).spacing(3)}),copy:e=>({backgroundColor:de(e).palette.white,borderRadius:"4px",padding:de(e).spacing(.5)}),drawerHeader:e=>({alignItems:"center",display:"flex",gap:de(e).spacing(2),justifyContent:"end",width:"50%"}),drawerWrapper:{display:"flex",justifyContent:"space-between",position:"relative"},header:{alignItems:"center",display:"flex",justifyContent:"space-between"},popoverWrapper:e=>({display:"flex",flexDirection:"column",gap:de(e).spacing(1)}),pre:e=>({backgroundColor:"#FFFFFF66",borderRadius:"8px",fontSize:"14px",padding:de(e).spacing(.3)}),presetOption:e=>({"&:hover":{backgroundColor:"scopeTheme(theme).palette.gray.ultraLight"},backgroundColor:"transparent",borderRadius:"4px",fontSize:"14px",padding:de(e).spacing(1)}),presetsButton:e=>({"&:hover":{backgroundColor:"#d1d4d7"},backgroundColor:"#E4E5E7",borderRadius:"4px",cursor:"pointer",display:"flex",fontSize:"14px",gap:de(e).spacing(.5),padding:`${de(e).spacing(.5)}px ${de(e).spacing(1)}px`})}),Se=({themeConfig:n,onUpdateThemeConfig:a,presets:s,showDrawer:r})=>{const i=F(n),[l,o]=_(!1),d=Object.keys(n).flatMap((e=>{if("components"===e&&n[e]&&"object"==typeof n[e]){return Object.keys(n[e])}return[e]})).map((e=>"palette"===e?{label:"Color Palette",value:"Color Palette"}:{label:x(e),value:x(e)})),[c,p]=_(d.sort()[0].value),g=e=>I(k(e)),u=F(null),[h,m]=ce(!1),b=e=>{a(e)};return t("div",Object.assign({"aria-label":"Theme Creator",css:ye.container,"data-testid":"theme-creator",role:"region"},{children:[t("div",Object.assign({css:ye.content},{children:[t("div",Object.assign({css:ye.header},{children:[e(v,{onSelectTab:e=>{p(e)},selectedTab:c,tabs:d}),s?t("div",{children:[t("button",Object.assign({"aria-controls":"presets-popover","aria-expanded":h,css:ye.presetsButton,onClick:e=>{e.preventDefault(),m()},ref:u},{children:["Presets",e(z,{name:ve.CARET_BOTTOM,size:N.SIZE_SMALL})]})),e(W,Object.assign({container:document.querySelector("#theme-creator"),isOpen:h,onClickAway:()=>m(),placement:"bottom-end",reference:u.current},{children:t("div",Object.assign({css:ye.popoverWrapper},{children:[e("button",Object.assign({"aria-label":"Set Default Theme",css:ye.presetOption,onClick:e=>{e.preventDefault(),m(),b(i.current)},role:"menuitem"},{children:"Default"})),s.map((t=>e("button",Object.assign({"aria-label":`Set ${t.presetName} Theme`,css:ye.presetOption,onClick:e=>{e.preventDefault(),m(),b(t.themeConfig)},role:"menuitem"},{children:t.presetName}),t.presetName)))]}))}))]}):e("button",Object.assign({"aria-label":"Set Default Theme",css:ye.presetsButton,onClick:()=>{b(i.current)},role:"menuitem"},{children:"Reset to Default"}))]})),e(U,Object.assign({role:"heading",variant:"heading4"},{children:`${c} Editor`})),((t,n)=>{var s;switch(n){case"Color Palette":return e(fe,{formatKey:g,onUpdatePaletteConfig:e=>{a(Object.assign(Object.assign({},t),{palette:e}))},paletteConfig:t.palette});case"Typography":return e(je,{formatKey:g,onUpdateTypographyConfig:e=>{a(Object.assign(Object.assign({},t),{components:Object.assign(Object.assign({},t.components),{Typography:e})}))},typographyConfig:null===(s=t.components)||void 0===s?void 0:s.Typography});default:return null}})(n,c)]})),r&&e(te,Object.assign({"aria-label":"Show themeConfig.js Code Drawer",headerContent:t("div",Object.assign({css:ye.drawerHeader},{children:[e("pre",Object.assign({css:ye.pre},{children:"themeConfig.js"})),r.copyToClipboardText&&e("div",Object.assign({css:ye.copy},{children:e(C,{content:r.copyToClipboardText})}))]})),isOpen:l,toggleDrawer:()=>o(!l)},{children:r.content}))]}))},we=({onRedirectToOnboarding:t})=>e(a,{onRedirectToOnboarding:t}),xe=s(we,f,{resources:{en:r}});var Ie=Object.freeze({__proto__:null,Component:we,Element:xe});const ke=()=>{const t=E(i(),[]);return e(l,Object.assign({},t))},Ee=s(ke,f,{resources:{en:r}});var _e=Object.freeze({__proto__:null,Component:ke,Element:Ee});const Te=({isModalFullScreen:t})=>{const n=E(o(),[]);return e(d,Object.assign({isModalFullScreen:t},n))},Fe=s(Te,f,{resources:{en:r}});var Pe=Object.freeze({__proto__:null,Component:Te,Element:Fe});const Ae=oe({errorState:e=>Object.assign({backgroundColor:de(e).palette.white},de(e).getComponentOverride("Table")),tableParagraph:{margin:0}}),De=({labelStatus:a,features:s,onClickPrintLabel:r,onClickVoidLabel:i,onClickPrintForms:l,onClickViewDetails:o,onRowClick:d,onClickExternalOrderId:c,onClickExternalShipmentId:p})=>{var g,u;const{t:h}=R(["common","list-labels"]),{globalFeatures:m,getFeatures:b}=pe(),v=b("labelsGridFeatures");s=Object.assign(Object.assign({},v),null!=s?s:{});const C=A((()=>{var e;return null===(e=null==s?void 0:s.columns)||void 0===e?void 0:e.find((e=>"labelId"===e.name))}),[s]),f=A((()=>{var e;return null===(e=null==s?void 0:s.columns)||void 0===e?void 0:e.find((e=>"shipmentId"===e.name))}),[s]),x=C&&(null===(g=C.allowFilter)||void 0===g||g),I=f&&(null===(u=f.allowFilter)||void 0===u||u),{labels:k,getGridData:E,isError:T,isLoading:F,filters:D,setFilters:L,pageConfig:z,isAnyFilterActive:N,shouldShowFilters:B,clearAllFilters:$}=(({labelStatus:e,showShipmentIdFilter:t,showLabelIdFilter:n})=>{var a,s;const r={labelId:{enabled:!!n,value:""},shipmentId:{enabled:!!t,value:""}},{getServiceName:i}=ee(),{page:l,pageSize:o,pagerProps:d}=ne(20),[c,p]=_(r),g=Object.keys(c).some((e=>{const t=c[e];return(null==t?void 0:t.enabled)&&t.value})),u=Object.keys(c).some((e=>{const t=c[e];return null==t?void 0:t.enabled}));P((()=>{p({labelId:{enabled:!!n,value:""},shipmentId:{enabled:!!t,value:""}})}),[n,t]);const{data:h,isLoading:m,isError:b}=Y({queryFnParams:{labelStatus:e,page:l,pageSize:o,shipmentId:c.shipmentId.value||void 0,sortBy:"modified_at",sortDir:"desc"}}),v=A((()=>(null==h?void 0:h.labels.map((e=>Object.assign(Object.assign({},e),{serviceName:i(e)}))))||[]),[null==h?void 0:h.labels,i]),C=u&&(g||Boolean(null==v?void 0:v.length)),{data:f,isError:O,isInitialLoading:j}=J((null===(a=c.labelId)||void 0===a?void 0:a.value)||void 0),y=null===(s=c.labelId)||void 0===s?void 0:s.value,S=(t=>{if(y&&!O){let n=!0;return e&&e!==(null==t?void 0:t.status)&&(n=!1),""!==(null==c?void 0:c.shipmentId.value)&&(null==c?void 0:c.shipmentId.value)!==(null==t?void 0:t.shipmentId)&&(n=!1),n?t:void 0}})(f),w=y&&(O||!S);return{clearAllFilters:()=>{p(r)},filters:c,getGridData:()=>S?[Object.assign(Object.assign({},S),{serviceName:i(S)})]:w?[]:v||[],isAnyFilterActive:g,isError:b,isLoading:m||j,labels:v,pageConfig:{currentPage:S?1:(null==h?void 0:h.page)||0,pagerProps:d,pagesAmount:(null==h?void 0:h.pages)||0,pageSize:o,showPagination:!S&&((null==h?void 0:h.total)||0)>o,totalElements:S?1:(null==h?void 0:h.total)||0},setFilters:e=>{d.onPageSelect(1),p(e)},shouldShowFilters:C}})({labelStatus:a,showLabelIdFilter:x,showShipmentIdFilter:I}),M=A((()=>({labelId:Object.assign(Object.assign({},D.labelId),{nickname:null==C?void 0:C.nickname}),shipmentId:Object.assign(Object.assign({},D.shipmentId),{nickname:null==f?void 0:f.nickname})})),[D,C,f]),W=A((()=>{var a;const r={completed:{color:G.SUCCESS,text:h("list-labels:status.completed")},error:{color:G.ERROR,text:h("list-labels:status.error")},processing:{color:G.INFO,text:h("list-labels:status.processing")},voided:{color:G.INFO,text:h("list-labels:status.voided")}},i={delivered:{color:G.SUCCESS,text:h("list-labels:trackingStatus.delivered")},error:{color:G.ERROR,text:h("list-labels:trackingStatus.error")},in_transit:{color:G.GRAY,text:h("list-labels:trackingStatus.inTransit")},unknown:{color:G.ALERT,text:h("list-labels:trackingStatus.unknown")}},l={createdDate:{headerContent:h("list-labels:headers.created"),renderCellContent:t=>e(ae,{date:t.createdAt,short:!0})},externalOrderId:{headerContent:h("list-labels:headers.externalOrderId"),renderCellContent:t=>t.externalOrderId&&c?e(V.Link,Object.assign({bold:!1,onClick:()=>{var e;return null==c?void 0:c(null!==(e=t.externalOrderId)&&void 0!==e?e:void 0)}},{children:t.externalOrderId})):e(U,Object.assign({component:"span",variant:"body2"},{children:t.externalOrderId}))},externalShipmentId:{headerContent:h("list-labels:headers.externalShipmentId"),renderCellContent:t=>t.externalShipmentId&&p?e(V.Link,Object.assign({bold:!1,onClick:()=>{var e;return null==p?void 0:p(null!==(e=t.externalShipmentId)&&void 0!==e?e:void 0)}},{children:t.externalShipmentId})):e(U,Object.assign({component:"span",variant:"body2"},{children:t.externalShipmentId}))},labelId:{headerContent:h("list-labels:headers.labelId"),renderCellContent:t=>e(U,Object.assign({component:"span",variant:"body2"},{children:t.labelId}))},packages:{headerContent:h("list-labels:headers.parcels"),renderCellContent:t=>e(U,Object.assign({component:"span",variant:"body2"},{children:t.packages.length}))},recipient:{headerContent:h("list-labels:headers.recipient"),renderCellContent:a=>t(n,{children:[e(U,Object.assign({component:"p",css:Ae.tableParagraph,variant:"body2"},{children:a.shipTo.name})),t(U,Object.assign({component:"p",css:Ae.tableParagraph,variant:"body2"},{children:[a.shipTo.postalCode,", ",a.shipTo.cityLocality]}))]})},shipDate:{headerContent:h("list-labels:headers.shipDate"),renderCellContent:t=>e(ae,{date:t.shipDate,short:!0})},shipmentId:{headerContent:h("list-labels:headers.shipmentId"),renderCellContent:t=>e(U,Object.assign({component:"span",variant:"body2"},{children:t.shipmentId}))},shippingService:{headerContent:h("list-labels:headers.shipping"),renderCellContent:a=>t(n,{children:[e(U,Object.assign({component:"p",css:Ae.tableParagraph,variant:"body2"},{children:a.serviceName||a.serviceCode})),a.trackable&&e(V.Link,Object.assign({bold:!1,href:a.trackingUrl,isExternal:!0,target:"_blank"},{children:a.trackingNumber}))]})},status:{headerContent:h("list-labels:headers.status"),renderCellContent:t=>e(H,Object.assign({color:r[t.status].color,variant:K.LINEAL_FILLED},{children:r[t.status].text}))},trackingStatus:{headerContent:h("list-labels:headers.trackingStatus"),renderCellContent:t=>e(H,Object.assign({color:i[t.trackingStatus].color,variant:K.LINEAL_FILLED},{children:i[t.trackingStatus].text}))}},o=[];return null===(a=null==s?void 0:s.columns)||void 0===a||a.forEach((e=>{l[e.name]&&(e.nickname?o.push(Object.assign(Object.assign({},l[e.name]),{headerContent:e.nickname})):o.push(l[e.name]))})),o}),[s,h,c,p]);if(F)return e(O,{message:h("loading.labels")});if(T)return e(se,{css:Ae.errorState,subtitle:[h("list-labels:errorMessages.subtitle"),h("errorMessages.refreshAndTryAgain")],title:h("list-labels:errorMessages.title")});const Q=(e,t)=>{e===w.PRINT_LABEL&&(e=>{null==r||r(),window.open(e.labelDownload.href,"_blank","noopener, noreferrer")})(t),e===w.VOID_LABEL&&(null==i||i(t)),e===w.PRINT_FORMS&&(e=>{null==l||l(),window.open(e.formDownload.href,"_blank","noopener, noreferrer")})(t),e===w.VIEW_DETAILS&&(null==o||o(t))};return(null==s?void 0:s.showActions)&&k.some((e=>"completed"===e.status))&&W.push({headerContent:"",renderCellContent:t=>{var n,a;const s=!!(null===(n=t.labelDownload)||void 0===n?void 0:n.href)&&"completed"===t.status,r=!!i&&"completed"===t.status,l=!!(null===(a=t.formDownload)||void 0===a?void 0:a.href)&&"completed"===t.status,d=!!o;if(!(s||r||l||d))return null;const c=[...d?[w.VIEW_DETAILS]:[],...s?[w.PRINT_LABEL]:[],...r?[w.VOID_LABEL]:[],...l?[w.PRINT_FORMS]:[]];return e(j,{allowedActions:c,onActionClick:e=>Q(e,t)})}}),t(n,{children:[e(re,{columns:W,data:E(),emptyContent:e(q,N?Object.assign({isElevated:!1,subtitle:h("list-labels:emptyWithFilters.subtitle"),title:h("list-labels:emptyWithFilters.title")},{children:e(Z,Object.assign({onClick:$},{children:h("list-labels:emptyWithFilters.button")}))}):{isElevated:!1,subtitle:h("list-labels:empty.subtitle"),title:h("list-labels:empty.title")}),filters:B&&e(ie,{filters:M,onClearAllFilters:$,onFiltersUpdated:L}),footerContent:e(le,{onPageChange:z.pagerProps.onPageSelect,page:z.currentPage,pages:z.pagesAmount,pageSize:z.pageSize,showPagination:z.showPagination,total:z.totalElements}),onRowClick:d}),m.poweredByShipEngine&&t(n,{children:[e(y,{}),e(S,{})]})]})},Le=s(De,f,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var Re=Object.freeze({__proto__:null,Component:De,Element:Le});const ze=(e,t)=>({end:me(be(t,59),23),start:me(be(e,0),0)}),Ne=(e,t)=>({createdDate:{enabled:t,value:null},shipmentId:{enabled:e,value:""}}),Be=({shipmentStatus:e,showShipmentIdFilter:t=!0,showCreatedDateFilter:n=!0})=>{var a,s,r,i;const l=Ne(t,n),{getServiceName:o}=ee(),{page:d,pageSize:c,pagerProps:p}=ne(20),[g,u]=_(l),h=Object.keys(g).some((e=>{const t=g[e];return(null==t?void 0:t.enabled)&&t.value})),m=Object.keys(g).some((e=>{const t=g[e];return null==t?void 0:t.enabled}));P((()=>{const e=Ne(t,n);u(e)}),[n,t]);const{data:b,isLoading:v,isError:C}=Q(Object.assign({page:d,pageSize:c,shipmentStatus:e,sortBy:"modified_at",sortDir:"desc"},((e,t)=>{if(!e||!t)return{};const n=ze(e,t);return{createdAtEnd:ge(n.end),createdAtStart:ge(n.start)}})(null===(s=null===(a=g.createdDate)||void 0===a?void 0:a.value)||void 0===s?void 0:s.start,null===(i=null===(r=g.createdDate)||void 0===r?void 0:r.value)||void 0===i?void 0:i.end))),f=A((()=>null==b?void 0:b.shipments.map((e=>Object.assign(Object.assign({},e),{serviceName:o(e)})))),[null==b?void 0:b.shipments,o]),O=m&&(h||Boolean(null==f?void 0:f.length)),{data:j,error:y,isInitialLoading:S}=X({queryFnParams:{shipmentId:g.shipmentId.value||void 0},retry:!1}),w=g.shipmentId.value,x=(t=>{var n,a,s,r;if(w&&!y){let i=!0;e&&(null==t?void 0:t.shipmentStatus)!==e&&(i=!1);const l=null===(n=g.createdDate)||void 0===n?void 0:n.value;return(null==l?void 0:l.start)&&l.end&&(null==t?void 0:t.createdAt)&&(a=l.start,s=l.end,r=t.createdAt,ue(a,s)&&ue(a,new Date(r))||he(new Date(r),ze(a,s))||(i=!1)),i?t:void 0}})(j),I=w&&(y||!x);return{clearAllFilters:()=>{u(l)},filters:g,getGridData:()=>x?[Object.assign(Object.assign({},x),{serviceName:o(x)})]:I?[]:f||[],isAnyFilterActive:h,isError:C,isLoading:v||S,pageConfig:{currentPage:x?1:(null==b?void 0:b.page)||0,pagerProps:p,pagesAmount:(null==b?void 0:b.pages)||0,pageSize:c,showPagination:!x&&((null==b?void 0:b.total)||0)>c,totalElements:x?1:(null==b?void 0:b.total)||0},setFilters:e=>{p.onPageSelect(1),u(e)},shipments:f,shouldShowFilters:O}},$e=oe({errorState:e=>Object.assign({backgroundColor:de(e).palette.white},de(e).getComponentOverride("Table")),tableParagraph:{margin:0}}),Me=({onRowClick:a,onClickCancelShipment:s,shipmentStatus:r,showShipmentIdFilter:i=!0,showCreatedDateFilter:l=!0})=>{const{t:o}=R(["common","list-shipments"]),{globalFeatures:d}=pe(),{isLoading:c,isError:p,filters:g,setFilters:u,pageConfig:h,getGridData:m,isAnyFilterActive:b,shouldShowFilters:v,clearAllFilters:C}=Be({shipmentStatus:r,showCreatedDateFilter:l,showShipmentIdFilter:i});if(c)return e(O,{message:o("loading.shipments")});if(p)return e(se,{css:$e.errorState,subtitle:[o("list-shipments:errorMessages.subtitle"),o("errorMessages.refreshAndTryAgain")],title:o("list-shipments:errorMessages.title")});const f={cancelled:{color:G.ALERT,text:o("list-shipments:status.cancelled")},label_purchased:{color:G.SUCCESS,text:o("list-shipments:status.purchased")},pending:{color:G.SUCCESS,text:o("list-shipments:status.readyToBuy")},processing:{color:G.INFO,text:o("list-shipments:status.processing")}},x=[{headerContent:o("list-shipments:headers.shipmentId"),renderCellContent:t=>e(U,Object.assign({component:"p",css:$e.tableParagraph,variant:"body2"},{children:t.shipmentId}))},{headerContent:o("list-shipments:headers.parcels"),renderCellContent:t=>e(U,Object.assign({component:"p",css:$e.tableParagraph,variant:"body2"},{children:t.packages.length}))},{headerContent:o("list-shipments:headers.recipient"),renderCellContent:a=>{const s=!!(a.shipTo.name||a.shipTo.postalCode||a.shipTo.cityLocality),r=!(!a.shipTo.postalCode&&!a.shipTo.cityLocality);return s?t(n,{children:[e(U,Object.assign({component:"p",css:$e.tableParagraph,variant:"body2"},{children:a.shipTo.name})),r&&e(U,Object.assign({component:"p",css:$e.tableParagraph,variant:"body2"},{children:[a.shipTo.postalCode,a.shipTo.cityLocality].filter(Boolean).join(", ")}))]}):"--"}},{headerContent:o("list-shipments:headers.shipping"),renderCellContent:t=>e(U,Object.assign({component:"p",css:$e.tableParagraph,variant:"body2"},{children:t.serviceName||o("list-shipments:none")}))},{headerContent:o("list-shipments:headers.created"),renderCellContent:t=>e(ae,{date:t.createdAt,short:!0})},{headerContent:o("list-shipments:headers.modified"),renderCellContent:t=>e(ae,{date:t.modifiedAt,short:!0})},{headerContent:o("list-shipments:headers.status"),renderCellContent:t=>e(H,Object.assign({color:f[t.shipmentStatus].color,variant:K.LINEAL_FILLED},{children:f[t.shipmentStatus].text}))},{headerContent:"",renderCellContent:t=>{const n=[...!!s&&"pending"===t.shipmentStatus?[w.CANCEL_SHIPMENT]:[]];return n.length>0&&e(j,{allowedActions:n,onActionClick:e=>((e,t)=>{e===w.CANCEL_SHIPMENT&&(null==s||s(t))})(e,t)})}}];return t(n,{children:[e(re,{columns:x,data:m(),emptyContent:e(q,b?Object.assign({isElevated:!1,subtitle:o("list-shipments:emptyState.filtersSubtitle"),title:o("list-shipments:emptyState.filtersTitle")},{children:e(Z,Object.assign({onClick:C},{children:o("list-shipments:emptyState.viewAll")}))}):{isElevated:!1,subtitle:o("list-shipments:emptyState.subtitle"),title:o("list-shipments:emptyState.title")}),filters:v&&e(ie,{filters:g,onClearAllFilters:C,onFiltersUpdated:u}),footerContent:e(le,{onPageChange:h.pagerProps.onPageSelect,page:h.currentPage,pages:h.pagesAmount,pageSize:h.pageSize,showPagination:h.showPagination,total:h.totalElements}),onRowClick:a}),d.poweredByShipEngine&&t(n,{children:[e(y,{}),e(S,{})]})]})},We=s(Me,f,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var Ue=Object.freeze({__proto__:null,Component:Me,Element:We});const Ge=L(void 0),Ve=({children:t,editableTheme:n})=>{const[a,s]=_(n);return e(Ge.Provider,Object.assign({value:{setThemeConfig:s,themeConfig:a}},{children:t}))},He=()=>{const e=D(Ge);if(!e)throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");return e},Ke=t=>{var n=E(t,[]);return e(Se,Object.assign({},n))},qe=s(Ke,f,{resources:{en:r}});var Ze=Object.freeze({__proto__:null,Component:Ke,Element:qe});const Ye=()=>{const t=E(c(),[]);return e(p,Object.assign({},t))},Je=s(Ye,f,{resources:{en:r}});var Qe=Object.freeze({__proto__:null,Component:Ye,Element:Je});const Xe=({onRedirectToOnboarding:t})=>e(g,{onRedirectToOnboarding:t}),et=s(Xe,f,{resources:{en:r}});var tt=Object.freeze({__proto__:null,Component:Xe,Element:et});const nt=()=>{const t=E(u(),[]);return e(h,Object.assign({},t))},at=s(nt,f,{resources:{en:r}});var st=Object.freeze({__proto__:null,Component:nt,Element:at});const rt=({onRedirectToOnboarding:t})=>e(m,{onRedirectToOnboarding:t}),it=s(rt,f,{resources:{en:r}});var lt=Object.freeze({__proto__:null,Component:rt,Element:it});const ot=()=>e(b,{}),dt=s(ot,f,{resources:{en:r}});var ct=Object.freeze({__proto__:null,Component:ot,Element:dt});export{Ve as T,_e as a,Pe as b,Qe as c,tt as d,st as e,ct as f,Re as l,Ie as m,lt as p,Ue as s,Ze as t,He as u};