@shipengine/elements 2.7.0 → 2.8.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.
Files changed (54) hide show
  1. package/carrier.js +1 -1
  2. package/checks.js +1 -1
  3. package/components.js +1 -1
  4. package/elements.js +1 -1
  5. package/hooks.js +1 -1
  6. package/index.js +1 -1
  7. package/package.json +3 -2
  8. package/src/components/grid-filters/components/created-date-filter/created-date-filter.d.ts +23 -0
  9. package/src/components/grid-filters/components/created-date-filter/created-date-filter.styles.d.ts +41 -0
  10. package/src/components/grid-filters/components/created-date-filter/index.d.ts +1 -0
  11. package/src/components/grid-filters/components/created-date-filter/types/form.d.ts +7 -0
  12. package/src/components/grid-filters/components/created-date-filter/types/index.d.ts +1 -0
  13. package/src/components/grid-filters/components/created-date-filter/utils/dates.d.ts +12 -0
  14. package/src/components/grid-filters/components/created-date-filter/utils/index.d.ts +1 -0
  15. package/src/components/grid-filters/components/index.d.ts +2 -0
  16. package/src/components/grid-filters/components/shipment-id-filter/index.d.ts +1 -0
  17. package/src/components/grid-filters/{shipment-id-filter.d.ts → components/shipment-id-filter/shipment-id-filter.d.ts} +1 -1
  18. package/src/components/grid-filters/components/shipment-id-filter/shipment-id-filter.styles.d.ts +10 -0
  19. package/src/components/grid-filters/grid-filters.d.ts +4 -0
  20. package/src/elements/label-layout/label-layout-element.d.ts +7 -0
  21. package/src/elements/labels-grid/labels-grid.d.ts +7 -0
  22. package/src/elements/manage-carriers/manage-carriers.d.ts +7 -0
  23. package/src/elements/manage-external-carriers/manage-external-carriers.d.ts +7 -0
  24. package/src/elements/manage-funding/manage-funding-element.d.ts +7 -0
  25. package/src/elements/manage-warehouses/manage-warehouses.d.ts +7 -0
  26. package/src/elements/payment-method-settings/payment-method-settings-element.d.ts +7 -0
  27. package/src/elements/purchase-label/purchase-label.d.ts +7 -5
  28. package/src/elements/shipment-summary/shipment-summary.d.ts +7 -0
  29. package/src/elements/shipments-grid/hooks/use-shipments-grid.d.ts +2 -3
  30. package/src/elements/shipments-grid/shipments-grid.d.ts +17 -4
  31. package/src/elements/shipments-grid/utils/created-date-value.d.ts +15 -0
  32. package/src/elements/shipments-grid/utils/index.d.ts +1 -0
  33. package/src/elements/theme-creator/theme-creator.d.ts +7 -0
  34. package/src/elements/transaction-history/transaction-history-element.d.ts +7 -0
  35. package/src/elements/unit-settings/unit-settings-element.d.ts +7 -0
  36. package/src/elements/vat-settings/vat-settings-element.d.ts +7 -0
  37. package/src/elements/void-label/void-label.d.ts +7 -0
  38. package/src/locales/en/index.d.ts +7 -0
  39. package/src/utilities/checks.d.ts +1 -0
  40. package/src/utilities/date.d.ts +1 -1
  41. package/src/utilities/feature-flags/types.d.ts +4 -0
  42. package/src/workflows/account-settings/account-settings.d.ts +7 -0
  43. package/src/workflows/carrier-services/carrier-services.d.ts +7 -0
  44. package/src/workflows/connect-external-carrier/connect-external-carrier.d.ts +7 -0
  45. package/src/workflows/onboarding/onboarding.d.ts +7 -0
  46. package/transaction-history-element.js +1 -1
  47. package/use-unit-settings.js +1 -1
  48. package/usePager.js +1 -1
  49. package/utilities.js +1 -1
  50. package/vat.js +1 -1
  51. package/wallet-form.js +1 -1
  52. package/workflows.js +1 -1
  53. package/src/components/grid-filters/grid-filters.styles.d.ts +0 -11
  54. /package/src/components/grid-filters/{shipment-id-filter-shema.d.ts → components/shipment-id-filter/shipment-id-filter-shema.d.ts} +0 -0
@@ -818,11 +818,18 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
818
818
  rows: string;
819
819
  clearAll: string;
820
820
  shipmentId: string;
821
+ createdDate: string;
821
822
  shipmentIdFilter: string;
823
+ createdDateFilter: string;
822
824
  apply: string;
823
825
  clear: string;
824
826
  search: string;
825
827
  shipmentIdHint: string;
828
+ dateFilterToday: string;
829
+ dateFilterLast7Days: string;
830
+ dateFilterLast30Days: string;
831
+ dateFilterLast12Months: string;
832
+ dateFilterCustom: string;
826
833
  };
827
834
  insuranceProviders: {
828
835
  carrier: string;
@@ -805,11 +805,18 @@ export declare const Element: ({ resources, ...props }: object & {
805
805
  rows: string;
806
806
  clearAll: string;
807
807
  shipmentId: string;
808
+ createdDate: string;
808
809
  shipmentIdFilter: string;
810
+ createdDateFilter: string;
809
811
  apply: string;
810
812
  clear: string;
811
813
  search: string;
812
814
  shipmentIdHint: string;
815
+ dateFilterToday: string;
816
+ dateFilterLast7Days: string;
817
+ dateFilterLast30Days: string;
818
+ dateFilterLast12Months: string;
819
+ dateFilterCustom: string;
813
820
  };
814
821
  insuranceProviders: {
815
822
  carrier: string;
@@ -805,11 +805,18 @@ export declare const Element: ({ resources, ...props }: object & {
805
805
  rows: string;
806
806
  clearAll: string;
807
807
  shipmentId: string;
808
+ createdDate: string;
808
809
  shipmentIdFilter: string;
810
+ createdDateFilter: string;
809
811
  apply: string;
810
812
  clear: string;
811
813
  search: string;
812
814
  shipmentIdHint: string;
815
+ dateFilterToday: string;
816
+ dateFilterLast7Days: string;
817
+ dateFilterLast30Days: string;
818
+ dateFilterLast12Months: string;
819
+ dateFilterCustom: string;
813
820
  };
814
821
  insuranceProviders: {
815
822
  carrier: string;
@@ -805,11 +805,18 @@ export declare const Element: ({ resources, ...props }: object & {
805
805
  rows: string;
806
806
  clearAll: string;
807
807
  shipmentId: string;
808
+ createdDate: string;
808
809
  shipmentIdFilter: string;
810
+ createdDateFilter: string;
809
811
  apply: string;
810
812
  clear: string;
811
813
  search: string;
812
814
  shipmentIdHint: string;
815
+ dateFilterToday: string;
816
+ dateFilterLast7Days: string;
817
+ dateFilterLast30Days: string;
818
+ dateFilterLast12Months: string;
819
+ dateFilterCustom: string;
813
820
  };
814
821
  insuranceProviders: {
815
822
  carrier: string;
@@ -943,11 +943,18 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
943
943
  rows: string;
944
944
  clearAll: string;
945
945
  shipmentId: string;
946
+ createdDate: string;
946
947
  shipmentIdFilter: string;
948
+ createdDateFilter: string;
947
949
  apply: string;
948
950
  clear: string;
949
951
  search: string;
950
952
  shipmentIdHint: string;
953
+ dateFilterToday: string;
954
+ dateFilterLast7Days: string;
955
+ dateFilterLast30Days: string;
956
+ dateFilterLast12Months: string;
957
+ dateFilterCustom: string;
951
958
  };
952
959
  insuranceProviders: {
953
960
  carrier: string;
@@ -801,11 +801,18 @@ declare const _default: {
801
801
  rows: string;
802
802
  clearAll: string;
803
803
  shipmentId: string;
804
+ createdDate: string;
804
805
  shipmentIdFilter: string;
806
+ createdDateFilter: string;
805
807
  apply: string;
806
808
  clear: string;
807
809
  search: string;
808
810
  shipmentIdHint: string;
811
+ dateFilterToday: string;
812
+ dateFilterLast7Days: string;
813
+ dateFilterLast30Days: string;
814
+ dateFilterLast12Months: string;
815
+ dateFilterCustom: string;
809
816
  };
810
817
  insuranceProviders: {
811
818
  carrier: string;
@@ -1,2 +1,3 @@
1
1
  import { Carrier, Warehouse } from "@shipengine/js-api";
2
2
  export declare const isOnboarded: (warehouses?: Warehouse[], carriers?: Carrier[]) => boolean;
3
+ export declare const getSellerIdFromToken: (token: string) => string | undefined;
@@ -120,7 +120,7 @@ export declare const sortByCreationDate: (a: HasCreationDate, b: HasCreationDate
120
120
  *
121
121
  * @category Utilities
122
122
  */
123
- export declare const isNowOrInTheFuture: (shipDate?: string) => boolean;
123
+ export declare const isNowOrInTheFuture: (date?: string | Date) => boolean;
124
124
  /**
125
125
  * @internal
126
126
  *
@@ -124,6 +124,10 @@ export type GlobalFeatures = {
124
124
  * list of all walleted carriers that are enabled for use in Elements.
125
125
  */
126
126
  enabledShipEngineCarriers?: EnabledShipEngineCarriers;
127
+ /**
128
+ * Use Elements in Sandbox mode. Requires a sandbox partner.
129
+ */
130
+ isSandbox?: boolean;
127
131
  /**
128
132
  * Enables the `Powered by ShipEngine` logo in the footer various elements.
129
133
  */
@@ -839,11 +839,18 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
839
839
  rows: string;
840
840
  clearAll: string;
841
841
  shipmentId: string;
842
+ createdDate: string;
842
843
  shipmentIdFilter: string;
844
+ createdDateFilter: string;
843
845
  apply: string;
844
846
  clear: string;
845
847
  search: string;
846
848
  shipmentIdHint: string;
849
+ dateFilterToday: string;
850
+ dateFilterLast7Days: string;
851
+ dateFilterLast30Days: string;
852
+ dateFilterLast12Months: string;
853
+ dateFilterCustom: string;
847
854
  };
848
855
  insuranceProviders: {
849
856
  carrier: string;
@@ -831,11 +831,18 @@ export declare const Element: ({ resources, ...props }: CarrierServicesProps & {
831
831
  rows: string;
832
832
  clearAll: string;
833
833
  shipmentId: string;
834
+ createdDate: string;
834
835
  shipmentIdFilter: string;
836
+ createdDateFilter: string;
835
837
  apply: string;
836
838
  clear: string;
837
839
  search: string;
838
840
  shipmentIdHint: string;
841
+ dateFilterToday: string;
842
+ dateFilterLast7Days: string;
843
+ dateFilterLast30Days: string;
844
+ dateFilterLast12Months: string;
845
+ dateFilterCustom: string;
839
846
  };
840
847
  insuranceProviders: {
841
848
  carrier: string;
@@ -838,11 +838,18 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
838
838
  rows: string;
839
839
  clearAll: string;
840
840
  shipmentId: string;
841
+ createdDate: string;
841
842
  shipmentIdFilter: string;
843
+ createdDateFilter: string;
842
844
  apply: string;
843
845
  clear: string;
844
846
  search: string;
845
847
  shipmentIdHint: string;
848
+ dateFilterToday: string;
849
+ dateFilterLast7Days: string;
850
+ dateFilterLast30Days: string;
851
+ dateFilterLast12Months: string;
852
+ dateFilterCustom: string;
846
853
  };
847
854
  insuranceProviders: {
848
855
  carrier: string;
@@ -881,11 +881,18 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
881
881
  rows: string;
882
882
  clearAll: string;
883
883
  shipmentId: string;
884
+ createdDate: string;
884
885
  shipmentIdFilter: string;
886
+ createdDateFilter: string;
885
887
  apply: string;
886
888
  clear: string;
887
889
  search: string;
888
890
  shipmentIdHint: string;
891
+ dateFilterToday: string;
892
+ dateFilterLast7Days: string;
893
+ dateFilterLast30Days: string;
894
+ dateFilterLast12Months: string;
895
+ dateFilterCustom: string;
889
896
  };
890
897
  insuranceProviders: {
891
898
  carrier: string;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"@emotion/react/jsx-runtime";import{S as s,c as a,e as r,u as i,M as o,d as l,E as c,f as p,U as d,g,h,i as u,P as m,T as b}from"./use-unit-settings.js";import{T as v,h as C,m as f,G as O,r as y,v as j,P as S,y as w,z as x}from"./actions-menu.js";import{k as _,t as k,q as E,T}from"./carrier.js";import{useTranslation as F}from"react-i18next";import{Icon as P,IconSize as A,Select as I,Option as L,Input as D,Popover as R,Typography as z,TagColor as N,Next as B,Tag as $,TagVariant as W,EmptyState as M,Button as U}from"@shipengine/giger";import{useState as G,useCallback as V,useRef as K,useEffect as q,useMemo as H,useContext as Z,createContext as Y}from"react";import{useListLabels 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,E as se,C as ae,G as re,b as ie,a as oe}from"./usePager.js";import{h as le}from"./vat.js";import{IconNames as ce}from"@shipengine/giger-theme";import{d as pe}from"./use-toggle.js";const de=le({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)})}),ge=({paletteConfig:n,onUpdatePaletteConfig:s,formatKey:a})=>{const[r,i]=G(new Set),o=e=>{i((t=>{const n=new Set(t);return n.has(e)?new Set([...n].filter((t=>t!==e))):new Set([...n,e])}))},l=V(((e,t,a)=>{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})(a),i=Object.assign(Object.assign({},n||{}),{[e]:Object.assign(Object.assign({},(null==n?void 0:n[e])||{}),{[t]:r})});s(i)}),[s,n]);return e("div",Object.assign({"data-test-id":"color-palette-editor"},{children:n&&Object.keys(n).map((s=>t("div",Object.assign({css:de.container,id:s},{children:[t("div",Object.assign({"aria-expanded":r.has(s),css:de.category,onClick:e=>{e.preventDefault(),o(s)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),o(s))},role:"button",tabIndex:0},{children:[e("p",{children:_(s)}),e(P,{name:r.has(s)?ce.CHEVRON_TOP:ce.CHEVRON_BOTTOM,size:A.SIZE_REGULAR})]})),r.has(s)&&Object.keys(n[s]).map((r=>t("div",Object.assign({css:de.inputContainer,id:"input-container"},{children:[e("label",Object.assign({css:{fontWeight:"bold"},htmlFor:`${s}.${r}`},{children:a(r)})),t("form",Object.assign({css:de.wrapper},{children:[e("input",{css:de.input,onChange:e=>{e.preventDefault(),l(s,r,e.target.value)},onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},type:"text",value:n[s][r]}),e("input",{css:de.colorPicker,onChange:e=>l(s,r,e.target.value),type:"color",value:n[s][r]})]}))]}),r)))]}),s)))}))},he=le({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"})}),ue=({onUpdateTypographyConfig:s,typographyConfig:a,formatKey:r})=>{const i=V(((e,t,n)=>{const r=Object.assign(Object.assign({},a||{}),{[e]:Object.assign(Object.assign({},(null==a?void 0:a[e])||{}),{[t]:n})});s(r)}),[s,a]),o=V(((e,t)=>{if(e)return e[t]}),[]),l=(t,n)=>{var s;const r=[{label:"Normal",value:"400"},{label:"Semi Bold",value:"600"},{label:"Bold",value:"700"}],l=null===(s=o(a,t))||void 0===s?void 0:s.fontWeight.toString(),c=void 0!==l?r.find((e=>e.value===l)):void 0;return e(I,Object.assign({css:he.select,label:"Font Weight",name:"font-weight",onChange:(e,s)=>i(t,n,null==s?void 0:s.value),value:c},{children:r.map((t=>e(L,Object.assign({value:t.value},{children:t.label}),t.value)))}))},c=(t,n)=>{var s;const r=null===(s=o(a,t))||void 0===s?void 0:s.fontSize.replace("px","");return e(D,{"aria-labelledby":`${t}.${n}`,css:he.input,label:"Font Size(px)",onChange:e=>{e.target.value.match(/^\d{0,2}$/)&&i(t,n,`${e.target.value}px`)},value:r})},p=(t,s)=>{switch(s){case"fontWeight":return e(n,{children:l(t,s)});case"fontSize":return e(n,{children:c(t,s)});default:return null}};return e("div",{children:a&&Object.keys(a).map((n=>t("div",Object.assign({css:he.sectionContainer},{children:[e("p",Object.assign({css:he.keys,id:n},{children:r(n)})),e("section",Object.assign({css:he.section},{children:Object.keys(a[n]).map((t=>e("div",Object.assign({id:`${n}.${t}`},{children:p(n,t)}),t)))}))]}),n)))})},me=le({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`})}),be=({themeConfig:n,onUpdateThemeConfig:s,presets:a,showDrawer:r})=>{const i=K(n),[o,l]=G(!1),c=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:_(e),value:_(e)})),[p,d]=G(c.sort()[0].value),g=e=>k(E(e)),h=K(null),[u,m]=pe(!1),b=e=>{s(e)};return t("div",Object.assign({"aria-label":"Theme Creator",css:me.container,"data-testid":"theme-creator",role:"region"},{children:[t("div",Object.assign({css:me.content},{children:[t("div",Object.assign({css:me.header},{children:[e(v,{onSelectTab:e=>{d(e)},selectedTab:p,tabs:c}),a?t("div",{children:[t("button",Object.assign({"aria-controls":"presets-popover","aria-expanded":u,css:me.presetsButton,onClick:e=>{e.preventDefault(),m()},ref:h},{children:["Presets",e(P,{name:ce.CARET_BOTTOM,size:A.SIZE_SMALL})]})),e(R,Object.assign({container:document.querySelector("#theme-creator"),isOpen:u,onClickAway:()=>m(),placement:"bottom-end",reference:h.current},{children:t("div",Object.assign({css:me.popoverWrapper},{children:[e("button",Object.assign({"aria-label":"Set Default Theme",css:me.presetOption,onClick:e=>{e.preventDefault(),m(),b(i.current)},role:"menuitem"},{children:"Default"})),a.map((t=>e("button",Object.assign({"aria-label":`Set ${t.presetName} Theme`,css:me.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:me.presetsButton,onClick:()=>{b(i.current)},role:"menuitem"},{children:"Reset to Default"}))]})),e(z,Object.assign({role:"heading",variant:"heading4"},{children:`${p} Editor`})),((t,n)=>{var a;switch(n){case"Color Palette":return e(ge,{formatKey:g,onUpdatePaletteConfig:e=>{s(Object.assign(Object.assign({},t),{palette:e}))},paletteConfig:t.palette});case"Typography":return e(ue,{formatKey:g,onUpdateTypographyConfig:e=>{s(Object.assign(Object.assign({},t),{components:Object.assign(Object.assign({},t.components),{Typography:e})}))},typographyConfig:null===(a=t.components)||void 0===a?void 0:a.Typography});default:return null}})(n,p)]})),r&&e(te,Object.assign({"aria-label":"Show themeConfig.js Code Drawer",headerContent:t("div",Object.assign({css:me.drawerHeader},{children:[e("pre",Object.assign({css:me.pre},{children:"themeConfig.js"})),r.copyToClipboardText&&e("div",Object.assign({css:me.copy},{children:e(C,{content:r.copyToClipboardText})}))]})),isOpen:o,toggleDrawer:()=>l(!o)},{children:r.content}))]}))},ve=({onRedirectToOnboarding:t})=>e(s,{onRedirectToOnboarding:t}),Ce=a(ve,f,{resources:{en:r}});var fe=Object.freeze({__proto__:null,Component:ve,Element:Ce});const Oe=()=>{const t=T(i(),[]);return e(o,Object.assign({},t))},ye=a(Oe,f,{resources:{en:r}});var je=Object.freeze({__proto__:null,Component:Oe,Element:ye});const Se=({isModalFullScreen:t})=>{const n=T(l(),[]);return e(c,Object.assign({isModalFullScreen:t},n))},we=a(Se,f,{resources:{en:r}});var xe=Object.freeze({__proto__:null,Component:Se,Element:we});const _e=le({errorState:e=>Object.assign({backgroundColor:e.palette.white},e.getComponentOverride("Table")),tableParagraph:{margin:0}}),ke=({labelStatus:s,showShipmentIdFilter:a=!0,onClickPrintLabel:r,onClickVoidLabel:i,onClickPrintForms:o,onClickViewDetails:l,onRowClick:c})=>{const{t:p}=F(["common","list-labels"]),{globalFeatures:d}=O(),{labels:g,isLoading:h,isError:u,filters:m,setFilters:b,pageConfig:v,isAnyFilterActive:C,shouldShowFilters:f,clearAllFilters:_}=(({labelStatus:e,showShipmentIdFilter:t})=>{const n={shipmentId:{enabled:!!t,value:""}},[s,a]=G(n),r=Object.keys(s).some((e=>{const t=s[e];return t.enabled&&t.value})),i=Object.keys(s).some((e=>s[e].enabled));q((()=>{a({shipmentId:{enabled:!!t,value:""}})}),[t]);const{getServiceName:o}=ee(),{page:l,pageSize:c,pagerProps:p}=ne(20),{data:d,isLoading:g,isError:h}=J({queryFnParams:{labelStatus:e,page:l,pageSize:c,shipmentId:s.shipmentId.value||void 0,sortBy:"modified_at",sortDir:"desc"}}),u=H((()=>(null==d?void 0:d.labels.map((e=>Object.assign(Object.assign({},e),{serviceName:o(e)}))))||[]),[null==d?void 0:d.labels,o]),m=i&&(r||Boolean(null==u?void 0:u.length));return{clearAllFilters:()=>{a(n)},filters:s,isAnyFilterActive:r,isError:h,isLoading:g,labels:u,pageConfig:{currentPage:(null==d?void 0:d.page)||0,pagerProps:p,pagesAmount:(null==d?void 0:d.pages)||0,pageSize:c,showPagination:((null==d?void 0:d.total)||0)>c,totalElements:(null==d?void 0:d.total)||0},setFilters:a,shouldShowFilters:m}})({labelStatus:s,showShipmentIdFilter:a});if(h)return e(y,{message:p("loading.labels")});if(u)return e(se,{css:_e.errorState,subtitle:[p("list-labels:errorMessages.subtitle"),p("errorMessages.refreshAndTryAgain")],title:p("list-labels:errorMessages.title")});const k={completed:{color:N.SUCCESS,text:p("list-labels:status.completed")},error:{color:N.ERROR,text:p("list-labels:status.error")},processing:{color:N.INFO,text:p("list-labels:status.processing")},voided:{color:N.INFO,text:p("list-labels:status.voided")}},E={delivered:{color:N.SUCCESS,text:p("list-labels:trackingStatus.delivered")},error:{color:N.ERROR,text:p("list-labels:trackingStatus.error")},in_transit:{color:N.GRAY,text:p("list-labels:trackingStatus.inTransit")},unknown:{color:N.ALERT,text:p("list-labels:trackingStatus.unknown")}},T=(e,t)=>{e===x.PRINT_LABEL&&(e=>{null==r||r(),window.open(e.labelDownload.href,"_blank","noopener, noreferrer")})(t),e===x.VOID_LABEL&&(null==i||i(t)),e===x.PRINT_FORMS&&(e=>{null==o||o(),window.open(e.formDownload.href,"_blank","noopener, noreferrer")})(t),e===x.VIEW_DETAILS&&(null==l||l(t))},P=[{headerContent:p("list-labels:headers.shipmentId"),renderCellContent:t=>e(z,Object.assign({component:"span",variant:"body2"},{children:t.shipmentId}))},{headerContent:p("list-labels:headers.parcels"),renderCellContent:t=>e(z,Object.assign({component:"span",variant:"body2"},{children:t.packages.length}))},{headerContent:p("list-labels:headers.recipient"),renderCellContent:s=>t(n,{children:[e(z,Object.assign({component:"p",css:_e.tableParagraph,variant:"body2"},{children:s.shipTo.name})),t(z,Object.assign({component:"p",css:_e.tableParagraph,variant:"body2"},{children:[s.shipTo.postalCode,", ",s.shipTo.cityLocality]}))]})},{headerContent:p("list-labels:headers.shipping"),renderCellContent:s=>t(n,{children:[e(z,Object.assign({component:"p",css:_e.tableParagraph,variant:"body2"},{children:s.serviceName||s.serviceCode})),s.trackable&&e(B.Link,Object.assign({bold:!1,href:s.trackingUrl,isExternal:!0,target:"_blank"},{children:s.trackingNumber}))]})},{headerContent:p("list-labels:headers.created"),renderCellContent:t=>e(ae,{date:t.createdAt,short:!0})},{headerContent:p("list-labels:headers.shipDate"),renderCellContent:t=>e(ae,{date:t.shipDate,short:!0})},{headerContent:p("list-labels:headers.status"),renderCellContent:t=>e($,Object.assign({color:k[t.status].color,variant:W.LINEAL_FILLED},{children:k[t.status].text}))},{headerContent:p("list-labels:headers.trackingStatus"),renderCellContent:t=>e($,Object.assign({color:E[t.trackingStatus].color,variant:W.LINEAL_FILLED},{children:E[t.trackingStatus].text}))}];return g.some((e=>"completed"===e.status))&&P.push({headerContent:"",renderCellContent:t=>{var n,s;const a=!!(null===(n=t.labelDownload)||void 0===n?void 0:n.href)&&"completed"===t.status,r=!!i&&"completed"===t.status,o=!!(null===(s=t.formDownload)||void 0===s?void 0:s.href)&&"completed"===t.status,c=!!l;if(!(a||r||o||c))return null;const p=[...c?[x.VIEW_DETAILS]:[],...a?[x.PRINT_LABEL]:[],...r?[x.VOID_LABEL]:[],...o?[x.PRINT_FORMS]:[]];return e(w,{allowedActions:p,onActionClick:e=>T(e,t)})}}),t(n,{children:[e(re,{columns:P,data:g,emptyContent:e(M,C?Object.assign({isElevated:!1,subtitle:p("list-labels:emptyWithFilters.subtitle"),title:p("list-labels:emptyWithFilters.title")},{children:e(U,Object.assign({onClick:_},{children:p("list-labels:emptyWithFilters.button")}))}):{isElevated:!1,subtitle:p("list-labels:empty.subtitle"),title:p("list-labels:empty.title")}),filters:f&&e(ie,{filters:m,onClearAllFilters:_,onFiltersUpdated:b}),footerContent:e(oe,{onPageChange:v.pagerProps.onPageSelect,page:v.currentPage,pages:v.pagesAmount,pageSize:v.pageSize,showPagination:v.showPagination,total:v.totalElements}),onRowClick:c}),d.poweredByShipEngine&&t(n,{children:[e(j,{}),e(S,{})]})]})},Ee=a(ke,f,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var Te=Object.freeze({__proto__:null,Component:ke,Element:Ee});function Fe(e){return{shipmentId:{enabled:e,value:""}}}const Pe=le({errorState:e=>Object.assign({backgroundColor:e.palette.white},e.getComponentOverride("Table")),tableParagraph:{margin:0}}),Ae=({onRowClick:s,shipmentStatus:a,showShipmentIdFilter:r=!0})=>{const{t:i}=F(["common","list-shipments"]),{globalFeatures:o}=O(),{isLoading:l,isError:c,filters:p,setFilters:d,pageConfig:g,getGridData:h,isAnyFilterActive:u,shouldShowFilters:m,clearAllFilters:b}=(({shipmentStatus:e,showShipmentIdFilter:t=!0})=>{const n=Fe(t),[s,a]=G(n),r=Object.keys(s).some((e=>{const t=s[e];return t.enabled&&t.value})),i=Object.keys(s).some((e=>s[e].enabled));q((()=>{const e=Fe(t);a(e)}),[t]);const{getServiceName:o}=ee(),{page:l,pageSize:c,pagerProps:p}=ne(20),{data:d,isLoading:g,isError:h}=Q({page:l,pageSize:c,shipmentStatus:e,sortBy:"modified_at",sortDir:"desc"}),u=H((()=>null==d?void 0:d.shipments.map((e=>Object.assign(Object.assign({},e),{serviceName:o(e)})))),[null==d?void 0:d.shipments,o]),m=i&&(r||Boolean(null==u?void 0:u.length)),{data:b,error:v,isInitialLoading:C}=X({queryFnParams:{shipmentId:s.shipmentId.value||void 0},retry:!1}),f=s.shipmentId.value,O=(y=b,f&&!v?e?(null==y?void 0:y.shipmentStatus)===e?y:void 0:y:void 0);var y;const j=f&&(v||!O);return{clearAllFilters:()=>{a(n)},filters:s,getGridData:()=>O?[Object.assign(Object.assign({},O),{serviceName:o(O)})]:j?[]:u||[],isAnyFilterActive:r,isError:h,isLoading:g||C,pageConfig:{currentPage:O?1:(null==d?void 0:d.page)||0,pagerProps:p,pagesAmount:(null==d?void 0:d.pages)||0,pageSize:c,showPagination:!O&&((null==d?void 0:d.total)||0)>c,totalElements:O?1:(null==d?void 0:d.total)||0},setFilters:a,shipments:u,shouldShowFilters:m}})({shipmentStatus:a,showShipmentIdFilter:r});if(l)return e(y,{message:i("loading.shipments")});if(c)return e(se,{css:Pe.errorState,subtitle:[i("list-shipments:errorMessages.subtitle"),i("errorMessages.refreshAndTryAgain")],title:i("list-shipments:errorMessages.title")});const v={cancelled:{color:N.ALERT,text:i("list-shipments:status.cancelled")},label_purchased:{color:N.SUCCESS,text:i("list-shipments:status.purchased")},pending:{color:N.SUCCESS,text:i("list-shipments:status.readyToBuy")},processing:{color:N.INFO,text:i("list-shipments:status.processing")}},C=[{headerContent:i("list-shipments:headers.shipmentId"),renderCellContent:t=>e(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:t.shipmentId}))},{headerContent:i("list-shipments:headers.parcels"),renderCellContent:t=>e(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:t.packages.length}))},{headerContent:i("list-shipments:headers.recipient"),renderCellContent:s=>{const a=!!(s.shipTo.name||s.shipTo.postalCode||s.shipTo.cityLocality),r=!(!s.shipTo.postalCode&&!s.shipTo.cityLocality);return a?t(n,{children:[e(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:s.shipTo.name})),r&&e(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:[s.shipTo.postalCode,s.shipTo.cityLocality].filter(Boolean).join(", ")}))]}):"--"}},{headerContent:i("list-shipments:headers.shipping"),renderCellContent:t=>e(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:t.serviceName||i("list-shipments:none")}))},{headerContent:i("list-shipments:headers.created"),renderCellContent:t=>e(ae,{date:t.createdAt,short:!0})},{headerContent:i("list-shipments:headers.modified"),renderCellContent:t=>e(ae,{date:t.modifiedAt,short:!0})},{headerContent:i("list-shipments:headers.status"),renderCellContent:t=>e($,Object.assign({color:v[t.shipmentStatus].color,variant:W.LINEAL_FILLED},{children:v[t.shipmentStatus].text}))}];return t(n,{children:[e(re,{columns:C,data:h(),emptyContent:e(M,u?Object.assign({isElevated:!1,subtitle:i("list-shipments:emptyState.filtersSubtitle"),title:i("list-shipments:emptyState.filtersTitle")},{children:e(U,Object.assign({onClick:b},{children:i("list-shipments:emptyState.viewAll")}))}):{isElevated:!1,subtitle:i("list-shipments:emptyState.subtitle"),title:i("list-shipments:emptyState.title")}),filters:m&&e(ie,{filters:p,onClearAllFilters:b,onFiltersUpdated:d}),footerContent:e(oe,{onPageChange:g.pagerProps.onPageSelect,page:g.currentPage,pages:g.pagesAmount,pageSize:g.pageSize,showPagination:g.showPagination,total:g.totalElements}),onRowClick:s}),o.poweredByShipEngine&&t(n,{children:[e(j,{}),e(S,{})]})]})},Ie=a(Ae,f,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var Le=Object.freeze({__proto__:null,Component:Ae,Element:Ie});const De=Y(void 0),Re=({children:t,editableTheme:n})=>{const[s,a]=G(n);return e(De.Provider,Object.assign({value:{setThemeConfig:a,themeConfig:s}},{children:t}))},ze=()=>{const e=Z(De);if(!e)throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");return e},Ne=t=>{var n=T(t,[]);return e(be,Object.assign({},n))},Be=a(Ne,f,{resources:{en:r}});var $e=Object.freeze({__proto__:null,Component:Ne,Element:Be});const We=()=>{const t=T(p(),[]);return e(d,Object.assign({},t))},Me=a(We,f,{resources:{en:r}});var Ue=Object.freeze({__proto__:null,Component:We,Element:Me});const Ge=({onRedirectToOnboarding:t})=>e(g,{onRedirectToOnboarding:t}),Ve=a(Ge,f,{resources:{en:r}});var Ke=Object.freeze({__proto__:null,Component:Ge,Element:Ve});const qe=()=>{const t=T(h(),[]);return e(u,Object.assign({},t))},He=a(qe,f,{resources:{en:r}});var Ze=Object.freeze({__proto__:null,Component:qe,Element:He});const Ye=({onRedirectToOnboarding:t})=>e(m,{onRedirectToOnboarding:t}),Je=a(Ye,f,{resources:{en:r}});var Qe=Object.freeze({__proto__:null,Component:Ye,Element:Je});const Xe=()=>e(b,{}),et=a(Xe,f,{resources:{en:r}});var tt=Object.freeze({__proto__:null,Component:Xe,Element:et});export{Re as T,je as a,xe as b,Ue as c,Ke as d,Ze as e,tt as f,Te as l,fe as m,Qe as p,Le as s,$e as t,ze as u};
1
+ import{jsx as e,jsxs as t,Fragment as n}from"@emotion/react/jsx-runtime";import{S as s,c as a,e as r,u as i,M as o,d as l,E as c,f as d,U as p,g,h,i as u,P as m,T as b}from"./use-unit-settings.js";import{T as v,h as f,m as C,G as O,r as y,v as j,P as S,y as w,z as x}from"./actions-menu.js";import{k as _,t as E,q as k,T}from"./carrier.js";import{useTranslation as F}from"react-i18next";import{Icon as P,IconSize as A,Select as D,Option as I,Input as L,Popover as R,Typography as z,TagColor as N,Next as B,Tag as $,TagVariant as W,EmptyState as M,Button as U}from"@shipengine/giger";import{useState as G,useCallback as V,useRef as K,useEffect as H,useMemo as q,useContext as Z,createContext as Y}from"react";import{useListLabels 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,E as se,C as ae,G as re,b as ie,a as oe}from"./usePager.js";import{h as le}from"./vat.js";import{formatISO as ce}from"date-fns/formatISO";import{isSameDay as de}from"date-fns/isSameDay";import{isWithinInterval as pe}from"date-fns/isWithinInterval";import{setHours as ge}from"date-fns/setHours";import{setMinutes as he}from"date-fns/setMinutes";import{IconNames as ue}from"@shipengine/giger-theme";import{d as me}from"./use-toggle.js";const be=le({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)})}),ve=({paletteConfig:n,onUpdatePaletteConfig:s,formatKey:a})=>{const[r,i]=G(new Set),o=e=>{i((t=>{const n=new Set(t);return n.has(e)?new Set([...n].filter((t=>t!==e))):new Set([...n,e])}))},l=V(((e,t,a)=>{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})(a),i=Object.assign(Object.assign({},n||{}),{[e]:Object.assign(Object.assign({},(null==n?void 0:n[e])||{}),{[t]:r})});s(i)}),[s,n]);return e("div",Object.assign({"data-test-id":"color-palette-editor"},{children:n&&Object.keys(n).map((s=>t("div",Object.assign({css:be.container,id:s},{children:[t("div",Object.assign({"aria-expanded":r.has(s),css:be.category,onClick:e=>{e.preventDefault(),o(s)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),o(s))},role:"button",tabIndex:0},{children:[e("p",{children:_(s)}),e(P,{name:r.has(s)?ue.CHEVRON_TOP:ue.CHEVRON_BOTTOM,size:A.SIZE_REGULAR})]})),r.has(s)&&Object.keys(n[s]).map((r=>t("div",Object.assign({css:be.inputContainer,id:"input-container"},{children:[e("label",Object.assign({css:{fontWeight:"bold"},htmlFor:`${s}.${r}`},{children:a(r)})),t("form",Object.assign({css:be.wrapper},{children:[e("input",{css:be.input,onChange:e=>{e.preventDefault(),l(s,r,e.target.value)},onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},type:"text",value:n[s][r]}),e("input",{css:be.colorPicker,onChange:e=>l(s,r,e.target.value),type:"color",value:n[s][r]})]}))]}),r)))]}),s)))}))},fe=le({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"})}),Ce=({onUpdateTypographyConfig:s,typographyConfig:a,formatKey:r})=>{const i=V(((e,t,n)=>{const r=Object.assign(Object.assign({},a||{}),{[e]:Object.assign(Object.assign({},(null==a?void 0:a[e])||{}),{[t]:n})});s(r)}),[s,a]),o=V(((e,t)=>{if(e)return e[t]}),[]),l=(t,n)=>{var s;const r=[{label:"Normal",value:"400"},{label:"Semi Bold",value:"600"},{label:"Bold",value:"700"}],l=null===(s=o(a,t))||void 0===s?void 0:s.fontWeight.toString(),c=void 0!==l?r.find((e=>e.value===l)):void 0;return e(D,Object.assign({css:fe.select,label:"Font Weight",name:"font-weight",onChange:(e,s)=>i(t,n,null==s?void 0:s.value),value:c},{children:r.map((t=>e(I,Object.assign({value:t.value},{children:t.label}),t.value)))}))},c=(t,n)=>{var s;const r=null===(s=o(a,t))||void 0===s?void 0:s.fontSize.replace("px","");return e(L,{"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})},d=(t,s)=>{switch(s){case"fontWeight":return e(n,{children:l(t,s)});case"fontSize":return e(n,{children:c(t,s)});default:return null}};return e("div",{children:a&&Object.keys(a).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(a[n]).map((t=>e("div",Object.assign({id:`${n}.${t}`},{children:d(n,t)}),t)))}))]}),n)))})},Oe=le({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:s,presets:a,showDrawer:r})=>{const i=K(n),[o,l]=G(!1),c=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:_(e),value:_(e)})),[d,p]=G(c.sort()[0].value),g=e=>E(k(e)),h=K(null),[u,m]=me(!1),b=e=>{s(e)};return t("div",Object.assign({"aria-label":"Theme Creator",css:Oe.container,"data-testid":"theme-creator",role:"region"},{children:[t("div",Object.assign({css:Oe.content},{children:[t("div",Object.assign({css:Oe.header},{children:[e(v,{onSelectTab:e=>{p(e)},selectedTab:d,tabs:c}),a?t("div",{children:[t("button",Object.assign({"aria-controls":"presets-popover","aria-expanded":u,css:Oe.presetsButton,onClick:e=>{e.preventDefault(),m()},ref:h},{children:["Presets",e(P,{name:ue.CARET_BOTTOM,size:A.SIZE_SMALL})]})),e(R,Object.assign({container:document.querySelector("#theme-creator"),isOpen:u,onClickAway:()=>m(),placement:"bottom-end",reference:h.current},{children:t("div",Object.assign({css:Oe.popoverWrapper},{children:[e("button",Object.assign({"aria-label":"Set Default Theme",css:Oe.presetOption,onClick:e=>{e.preventDefault(),m(),b(i.current)},role:"menuitem"},{children:"Default"})),a.map((t=>e("button",Object.assign({"aria-label":`Set ${t.presetName} Theme`,css:Oe.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:Oe.presetsButton,onClick:()=>{b(i.current)},role:"menuitem"},{children:"Reset to Default"}))]})),e(z,Object.assign({role:"heading",variant:"heading4"},{children:`${d} Editor`})),((t,n)=>{var a;switch(n){case"Color Palette":return e(ve,{formatKey:g,onUpdatePaletteConfig:e=>{s(Object.assign(Object.assign({},t),{palette:e}))},paletteConfig:t.palette});case"Typography":return e(Ce,{formatKey:g,onUpdateTypographyConfig:e=>{s(Object.assign(Object.assign({},t),{components:Object.assign(Object.assign({},t.components),{Typography:e})}))},typographyConfig:null===(a=t.components)||void 0===a?void 0:a.Typography});default:return null}})(n,d)]})),r&&e(te,Object.assign({"aria-label":"Show themeConfig.js Code Drawer",headerContent:t("div",Object.assign({css:Oe.drawerHeader},{children:[e("pre",Object.assign({css:Oe.pre},{children:"themeConfig.js"})),r.copyToClipboardText&&e("div",Object.assign({css:Oe.copy},{children:e(f,{content:r.copyToClipboardText})}))]})),isOpen:o,toggleDrawer:()=>l(!o)},{children:r.content}))]}))},je=({onRedirectToOnboarding:t})=>e(s,{onRedirectToOnboarding:t}),Se=a(je,C,{resources:{en:r}});var we=Object.freeze({__proto__:null,Component:je,Element:Se});const xe=()=>{const t=T(i(),[]);return e(o,Object.assign({},t))},_e=a(xe,C,{resources:{en:r}});var Ee=Object.freeze({__proto__:null,Component:xe,Element:_e});const ke=({isModalFullScreen:t})=>{const n=T(l(),[]);return e(c,Object.assign({isModalFullScreen:t},n))},Te=a(ke,C,{resources:{en:r}});var Fe=Object.freeze({__proto__:null,Component:ke,Element:Te});const Pe=le({errorState:e=>Object.assign({backgroundColor:e.palette.white},e.getComponentOverride("Table")),tableParagraph:{margin:0}}),Ae=({labelStatus:s,showShipmentIdFilter:a=!0,onClickPrintLabel:r,onClickVoidLabel:i,onClickPrintForms:o,onClickViewDetails:l,onRowClick:c})=>{const{t:d}=F(["common","list-labels"]),{globalFeatures:p}=O(),{labels:g,isLoading:h,isError:u,filters:m,setFilters:b,pageConfig:v,isAnyFilterActive:f,shouldShowFilters:C,clearAllFilters:_}=(({labelStatus:e,showShipmentIdFilter:t})=>{const n={shipmentId:{enabled:!!t,value:""}},[s,a]=G(n),r=Object.keys(s).some((e=>{const t=s[e];return(null==t?void 0:t.enabled)&&t.value})),i=Object.keys(s).some((e=>{const t=s[e];return null==t?void 0:t.enabled}));H((()=>{a({shipmentId:{enabled:!!t,value:""}})}),[t]);const{getServiceName:o}=ee(),{page:l,pageSize:c,pagerProps:d}=ne(20),{data:p,isLoading:g,isError:h}=J({queryFnParams:{labelStatus:e,page:l,pageSize:c,shipmentId:s.shipmentId.value||void 0,sortBy:"modified_at",sortDir:"desc"}}),u=q((()=>(null==p?void 0:p.labels.map((e=>Object.assign(Object.assign({},e),{serviceName:o(e)}))))||[]),[null==p?void 0:p.labels,o]),m=i&&(r||Boolean(null==u?void 0:u.length));return{clearAllFilters:()=>{a(n)},filters:s,isAnyFilterActive:r,isError:h,isLoading:g,labels:u,pageConfig:{currentPage:(null==p?void 0:p.page)||0,pagerProps:d,pagesAmount:(null==p?void 0:p.pages)||0,pageSize:c,showPagination:((null==p?void 0:p.total)||0)>c,totalElements:(null==p?void 0:p.total)||0},setFilters:a,shouldShowFilters:m}})({labelStatus:s,showShipmentIdFilter:a});if(h)return e(y,{message:d("loading.labels")});if(u)return e(se,{css:Pe.errorState,subtitle:[d("list-labels:errorMessages.subtitle"),d("errorMessages.refreshAndTryAgain")],title:d("list-labels:errorMessages.title")});const E={completed:{color:N.SUCCESS,text:d("list-labels:status.completed")},error:{color:N.ERROR,text:d("list-labels:status.error")},processing:{color:N.INFO,text:d("list-labels:status.processing")},voided:{color:N.INFO,text:d("list-labels:status.voided")}},k={delivered:{color:N.SUCCESS,text:d("list-labels:trackingStatus.delivered")},error:{color:N.ERROR,text:d("list-labels:trackingStatus.error")},in_transit:{color:N.GRAY,text:d("list-labels:trackingStatus.inTransit")},unknown:{color:N.ALERT,text:d("list-labels:trackingStatus.unknown")}},T=(e,t)=>{e===x.PRINT_LABEL&&(e=>{null==r||r(),window.open(e.labelDownload.href,"_blank","noopener, noreferrer")})(t),e===x.VOID_LABEL&&(null==i||i(t)),e===x.PRINT_FORMS&&(e=>{null==o||o(),window.open(e.formDownload.href,"_blank","noopener, noreferrer")})(t),e===x.VIEW_DETAILS&&(null==l||l(t))},P=[{headerContent:d("list-labels:headers.shipmentId"),renderCellContent:t=>e(z,Object.assign({component:"span",variant:"body2"},{children:t.shipmentId}))},{headerContent:d("list-labels:headers.parcels"),renderCellContent:t=>e(z,Object.assign({component:"span",variant:"body2"},{children:t.packages.length}))},{headerContent:d("list-labels:headers.recipient"),renderCellContent:s=>t(n,{children:[e(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:s.shipTo.name})),t(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:[s.shipTo.postalCode,", ",s.shipTo.cityLocality]}))]})},{headerContent:d("list-labels:headers.shipping"),renderCellContent:s=>t(n,{children:[e(z,Object.assign({component:"p",css:Pe.tableParagraph,variant:"body2"},{children:s.serviceName||s.serviceCode})),s.trackable&&e(B.Link,Object.assign({bold:!1,href:s.trackingUrl,isExternal:!0,target:"_blank"},{children:s.trackingNumber}))]})},{headerContent:d("list-labels:headers.created"),renderCellContent:t=>e(ae,{date:t.createdAt,short:!0})},{headerContent:d("list-labels:headers.shipDate"),renderCellContent:t=>e(ae,{date:t.shipDate,short:!0})},{headerContent:d("list-labels:headers.status"),renderCellContent:t=>e($,Object.assign({color:E[t.status].color,variant:W.LINEAL_FILLED},{children:E[t.status].text}))},{headerContent:d("list-labels:headers.trackingStatus"),renderCellContent:t=>e($,Object.assign({color:k[t.trackingStatus].color,variant:W.LINEAL_FILLED},{children:k[t.trackingStatus].text}))}];return g.some((e=>"completed"===e.status))&&P.push({headerContent:"",renderCellContent:t=>{var n,s;const a=!!(null===(n=t.labelDownload)||void 0===n?void 0:n.href)&&"completed"===t.status,r=!!i&&"completed"===t.status,o=!!(null===(s=t.formDownload)||void 0===s?void 0:s.href)&&"completed"===t.status,c=!!l;if(!(a||r||o||c))return null;const d=[...c?[x.VIEW_DETAILS]:[],...a?[x.PRINT_LABEL]:[],...r?[x.VOID_LABEL]:[],...o?[x.PRINT_FORMS]:[]];return e(w,{allowedActions:d,onActionClick:e=>T(e,t)})}}),t(n,{children:[e(re,{columns:P,data:g,emptyContent:e(M,f?Object.assign({isElevated:!1,subtitle:d("list-labels:emptyWithFilters.subtitle"),title:d("list-labels:emptyWithFilters.title")},{children:e(U,Object.assign({onClick:_},{children:d("list-labels:emptyWithFilters.button")}))}):{isElevated:!1,subtitle:d("list-labels:empty.subtitle"),title:d("list-labels:empty.title")}),filters:C&&e(ie,{filters:m,onClearAllFilters:_,onFiltersUpdated:b}),footerContent:e(oe,{onPageChange:v.pagerProps.onPageSelect,page:v.currentPage,pages:v.pagesAmount,pageSize:v.pageSize,showPagination:v.showPagination,total:v.totalElements}),onRowClick:c}),p.poweredByShipEngine&&t(n,{children:[e(j,{}),e(S,{})]})]})},De=a(Ae,C,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var Ie=Object.freeze({__proto__:null,Component:Ae,Element:De});const Le=(e,t)=>({end:ge(he(t,59),23),start:ge(he(e,0),0)}),Re=(e,t)=>({createdDate:{enabled:t,value:null},shipmentId:{enabled:e,value:""}}),ze=({shipmentStatus:e,showShipmentIdFilter:t=!0,showCreatedDateFilter:n=!0})=>{var s,a,r,i;const o=Re(t,n),{getServiceName:l}=ee(),{page:c,pageSize:d,pagerProps:p}=ne(20),[g,h]=G(o),u=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}));H((()=>{const e=Re(t,n);h(e)}),[n,t]);const{data:b,isLoading:v,isError:f}=Q(Object.assign({page:c,pageSize:d,shipmentStatus:e,sortBy:"modified_at",sortDir:"desc"},((e,t)=>{if(!e||!t)return{};const n=Le(e,t);return{createdAtEnd:ce(n.end),createdAtStart:ce(n.start)}})(null===(a=null===(s=g.createdDate)||void 0===s?void 0:s.value)||void 0===a?void 0:a.start,null===(i=null===(r=g.createdDate)||void 0===r?void 0:r.value)||void 0===i?void 0:i.end))),C=q((()=>null==b?void 0:b.shipments.map((e=>Object.assign(Object.assign({},e),{serviceName:l(e)})))),[null==b?void 0:b.shipments,l]),O=m&&(u||Boolean(null==C?void 0:C.length)),{data:y,error:j,isInitialLoading:S}=X({queryFnParams:{shipmentId:g.shipmentId.value||void 0},retry:!1}),w=g.shipmentId.value,x=(t=>{var n,s,a,r;if(w&&!j){let i=!0;e&&(null==t?void 0:t.shipmentStatus)!==e&&(i=!1);const o=null===(n=g.createdDate)||void 0===n?void 0:n.value;return(null==o?void 0:o.start)&&o.end&&(null==t?void 0:t.createdAt)&&(s=o.start,a=o.end,r=t.createdAt,de(s,a)&&de(s,new Date(r))||pe(new Date(r),Le(s,a))||(i=!1)),i?t:void 0}})(y),_=w&&(j||!x);return{clearAllFilters:()=>{h(o)},filters:g,getGridData:()=>x?[Object.assign(Object.assign({},x),{serviceName:l(x)})]:_?[]:C||[],isAnyFilterActive:u,isError:f,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:d,showPagination:!x&&((null==b?void 0:b.total)||0)>d,totalElements:x?1:(null==b?void 0:b.total)||0},setFilters:e=>{p.onPageSelect(1),h(e)},shipments:C,shouldShowFilters:O}},Ne=le({errorState:e=>Object.assign({backgroundColor:e.palette.white},e.getComponentOverride("Table")),tableParagraph:{margin:0}}),Be=({onRowClick:s,shipmentStatus:a,showShipmentIdFilter:r=!0,showCreatedDateFilter:i=!0})=>{const{t:o}=F(["common","list-shipments"]),{globalFeatures:l}=O(),{isLoading:c,isError:d,filters:p,setFilters:g,pageConfig:h,getGridData:u,isAnyFilterActive:m,shouldShowFilters:b,clearAllFilters:v}=ze({shipmentStatus:a,showCreatedDateFilter:i,showShipmentIdFilter:r});if(c)return e(y,{message:o("loading.shipments")});if(d)return e(se,{css:Ne.errorState,subtitle:[o("list-shipments:errorMessages.subtitle"),o("errorMessages.refreshAndTryAgain")],title:o("list-shipments:errorMessages.title")});const f={cancelled:{color:N.ALERT,text:o("list-shipments:status.cancelled")},label_purchased:{color:N.SUCCESS,text:o("list-shipments:status.purchased")},pending:{color:N.SUCCESS,text:o("list-shipments:status.readyToBuy")},processing:{color:N.INFO,text:o("list-shipments:status.processing")}},C=[{headerContent:o("list-shipments:headers.shipmentId"),renderCellContent:t=>e(z,Object.assign({component:"p",css:Ne.tableParagraph,variant:"body2"},{children:t.shipmentId}))},{headerContent:o("list-shipments:headers.parcels"),renderCellContent:t=>e(z,Object.assign({component:"p",css:Ne.tableParagraph,variant:"body2"},{children:t.packages.length}))},{headerContent:o("list-shipments:headers.recipient"),renderCellContent:s=>{const a=!!(s.shipTo.name||s.shipTo.postalCode||s.shipTo.cityLocality),r=!(!s.shipTo.postalCode&&!s.shipTo.cityLocality);return a?t(n,{children:[e(z,Object.assign({component:"p",css:Ne.tableParagraph,variant:"body2"},{children:s.shipTo.name})),r&&e(z,Object.assign({component:"p",css:Ne.tableParagraph,variant:"body2"},{children:[s.shipTo.postalCode,s.shipTo.cityLocality].filter(Boolean).join(", ")}))]}):"--"}},{headerContent:o("list-shipments:headers.shipping"),renderCellContent:t=>e(z,Object.assign({component:"p",css:Ne.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($,Object.assign({color:f[t.shipmentStatus].color,variant:W.LINEAL_FILLED},{children:f[t.shipmentStatus].text}))}];return t(n,{children:[e(re,{columns:C,data:u(),emptyContent:e(M,m?Object.assign({isElevated:!1,subtitle:o("list-shipments:emptyState.filtersSubtitle"),title:o("list-shipments:emptyState.filtersTitle")},{children:e(U,Object.assign({onClick:v},{children:o("list-shipments:emptyState.viewAll")}))}):{isElevated:!1,subtitle:o("list-shipments:emptyState.subtitle"),title:o("list-shipments:emptyState.title")}),filters:b&&e(ie,{filters:p,onClearAllFilters:v,onFiltersUpdated:g}),footerContent:e(oe,{onPageChange:h.pagerProps.onPageSelect,page:h.currentPage,pages:h.pagesAmount,pageSize:h.pageSize,showPagination:h.showPagination,total:h.totalElements}),onRowClick:s}),l.poweredByShipEngine&&t(n,{children:[e(j,{}),e(S,{})]})]})},$e=a(Be,C,{css:{height:"100%",minWidth:"440px",width:"100%"},resources:{en:r}});var We=Object.freeze({__proto__:null,Component:Be,Element:$e});const Me=Y(void 0),Ue=({children:t,editableTheme:n})=>{const[s,a]=G(n);return e(Me.Provider,Object.assign({value:{setThemeConfig:a,themeConfig:s}},{children:t}))},Ge=()=>{const e=Z(Me);if(!e)throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");return e},Ve=t=>{var n=T(t,[]);return e(ye,Object.assign({},n))},Ke=a(Ve,C,{resources:{en:r}});var He=Object.freeze({__proto__:null,Component:Ve,Element:Ke});const qe=()=>{const t=T(d(),[]);return e(p,Object.assign({},t))},Ze=a(qe,C,{resources:{en:r}});var Ye=Object.freeze({__proto__:null,Component:qe,Element:Ze});const Je=({onRedirectToOnboarding:t})=>e(g,{onRedirectToOnboarding:t}),Qe=a(Je,C,{resources:{en:r}});var Xe=Object.freeze({__proto__:null,Component:Je,Element:Qe});const et=()=>{const t=T(h(),[]);return e(u,Object.assign({},t))},tt=a(et,C,{resources:{en:r}});var nt=Object.freeze({__proto__:null,Component:et,Element:tt});const st=({onRedirectToOnboarding:t})=>e(m,{onRedirectToOnboarding:t}),at=a(st,C,{resources:{en:r}});var rt=Object.freeze({__proto__:null,Component:st,Element:at});const it=()=>e(b,{}),ot=a(it,C,{resources:{en:r}});var lt=Object.freeze({__proto__:null,Component:it,Element:ot});export{Ue as T,Ee as a,Fe as b,Ye as c,Xe as d,nt as e,lt as f,Ie as l,we as m,rt as p,We as s,He as t,Ge as u};