@shipengine/elements 1.4.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -2836,6 +2836,11 @@ const featureFlags = {
2836
2836
  * `<PurchaseLabel />` element.
2837
2837
  */
2838
2838
  shipmentForm: {
2839
+ /**
2840
+ * `addOns` enables the `Add-Ons` section of the shipment form. This allows users to
2841
+ * add additional services to their shipment such as delivery confirmation and insurance.
2842
+ */
2843
+ addOns: true,
2839
2844
  /**
2840
2845
  * `browseRates` enables the `browse rates` button in the shipment form. This allows users
2841
2846
  * to browse rates for a shipment with varying shipment configurations. This is useful for
@@ -15177,7 +15182,7 @@ var en = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(O
15177
15182
  *
15178
15183
  * @see {@link ConnectCarrier.ComponentProps | The props that are passed into the `<ConnectCarrier />` component}
15179
15184
  */
15180
- const Component$9 = ({
15185
+ const Component$b = ({
15181
15186
  carrierName,
15182
15187
  features,
15183
15188
  onCancel,
@@ -15246,7 +15251,7 @@ const Component$9 = ({
15246
15251
  }
15247
15252
  });
15248
15253
  };
15249
- alchemy__default["default"].createElement(Component$9, ErrorFallback, {
15254
+ alchemy__default["default"].createElement(Component$b, ErrorFallback, {
15250
15255
  css: {
15251
15256
  height: "100%",
15252
15257
  maxWidth: "800px",
@@ -15282,7 +15287,7 @@ alchemy__default["default"].createElement(Component$9, ErrorFallback, {
15282
15287
  * @see {@link ExternalCarriers.ComponentProps | The props that are passed into the `<ExternalCarriers />` component}
15283
15288
  * @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<ExternalCarriers />` component}
15284
15289
  */
15285
- const Component$8 = ({
15290
+ const Component$a = ({
15286
15291
  features
15287
15292
  }) => {
15288
15293
  const {
@@ -15307,7 +15312,7 @@ const Component$8 = ({
15307
15312
  }, [isAddingCarrier, connectedCarriersFetching]);
15308
15313
  const carrierList = React.useMemo(() => {
15309
15314
  const carriers = [];
15310
- connectedCarriers === null || connectedCarriers === void 0 ? void 0 : connectedCarriers.forEach(carrier => {
15315
+ connectedCarriers === null || connectedCarriers === void 0 ? void 0 : connectedCarriers.filter(carrier => !carrier.requiresFundedAmount).forEach(carrier => {
15311
15316
  const metadata = carrierMetadata === null || carrierMetadata === void 0 ? void 0 : carrierMetadata.find(m => m.carrierName === carrier.carrierCode);
15312
15317
  if (metadata) {
15313
15318
  carriers.push({
@@ -15340,7 +15345,7 @@ const Component$8 = ({
15340
15345
  textAlign: "left"
15341
15346
  }
15342
15347
  }, {
15343
- children: jsxRuntime.jsx(Component$9, {
15348
+ children: jsxRuntime.jsx(Component$b, {
15344
15349
  features: features,
15345
15350
  onCarrierConnected: () => {
15346
15351
  setAddModalOpen(false);
@@ -15355,7 +15360,7 @@ const Component$8 = ({
15355
15360
 
15356
15361
  var externalCarriers = /*#__PURE__*/Object.freeze({
15357
15362
  __proto__: null,
15358
- Component: Component$8
15363
+ Component: Component$a
15359
15364
  });
15360
15365
 
15361
15366
  const styles$l = createStyles({
@@ -15785,7 +15790,7 @@ const useListConnectedCarriers = () => {
15785
15790
  * @see {@link ListCarriers.ComponentProps | The props that are passed into the `<List-Carriers />` component}
15786
15791
  * @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<List-Carriers />` component}
15787
15792
  */
15788
- const Component$7 = ({
15793
+ const Component$9 = ({
15789
15794
  features
15790
15795
  }) => {
15791
15796
  const {
@@ -15826,7 +15831,7 @@ const Component$7 = ({
15826
15831
 
15827
15832
  var listCarriers = /*#__PURE__*/Object.freeze({
15828
15833
  __proto__: null,
15829
- Component: Component$7
15834
+ Component: Component$9
15830
15835
  });
15831
15836
 
15832
15837
  const WarehouseDisplay = ({
@@ -16366,24 +16371,19 @@ const ManageWarehouses = ({
16366
16371
  }),
16367
16372
  submitButtonTitle: t("actions.save")
16368
16373
  })
16369
- })) : jsxRuntime.jsx(ButtonGroup, Object.assign({
16370
- justify: "end"
16371
- }, {
16372
- children: jsxRuntime.jsxs(giger.Button, Object.assign({
16373
- bold: false,
16374
- onClick: () => toggleShowAddNewWarehouseForm(true),
16375
- type: "button",
16376
- variant: giger.ButtonVariant.TEXT
16374
+ })) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
16375
+ children: [jsxRuntime.jsx(ButtonGroup, Object.assign({
16376
+ justify: "end"
16377
16377
  }, {
16378
- children: [t("manage-warehouses:addNew"), jsxRuntime.jsx(giger.Icon, {
16379
- css: {
16380
- paddingLeft: 6
16381
- },
16382
- name: gigerTheme.IconNames.ADD,
16383
- size: giger.IconSize.SIZE_SMALL
16384
- })]
16385
- }))
16386
- })), jsxRuntime.jsx("div", Object.assign({
16378
+ children: jsxRuntime.jsx(LinkAction, {
16379
+ icon: "add",
16380
+ onClick: () => toggleShowAddNewWarehouseForm(true),
16381
+ title: t("manage-warehouses:addNew")
16382
+ })
16383
+ })), jsxRuntime.jsx(Spacer, {
16384
+ multiplier: 2
16385
+ })]
16386
+ }), jsxRuntime.jsx("div", Object.assign({
16387
16387
  css: styles$i.cardSpacing
16388
16388
  }, {
16389
16389
  children: warehouses.map(warehouse => {
@@ -16470,7 +16470,7 @@ const ManageWarehouses = ({
16470
16470
  * @see {@link ManageWarehouses.ComponentProps | The props that are passed into the `<ManageWarehouses />` component}
16471
16471
  * @see {@link AccountSettings.Element | The `<AccountSettings />` component renders the `<ManageWarehouses />` component}
16472
16472
  */
16473
- const Component$6 = ({
16473
+ const Component$8 = ({
16474
16474
  onWarehouseAddressValidation: _ARE_WE_ACTUALLY_GOING_TO_USE_THIS
16475
16475
  }) => {
16476
16476
  const {
@@ -16553,7 +16553,7 @@ const Component$6 = ({
16553
16553
 
16554
16554
  var manageWarehouses = /*#__PURE__*/Object.freeze({
16555
16555
  __proto__: null,
16556
- Component: Component$6
16556
+ Component: Component$8
16557
16557
  });
16558
16558
 
16559
16559
  var img = "data:image/svg+xml,%3csvg fill='none' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'%3e %3cpath d='M22.9425 6.62223L18.63 5.81973C18.4275 5.78223 18.2325 5.91723 18.195 6.11973L17.3925 10.4322C17.355 10.6347 17.49 10.8297 17.6925 10.8672C17.715 10.8672 17.7375 10.8672 17.76 10.8672C17.94 10.8672 18.0975 10.7397 18.1275 10.5597L18.765 7.13973C21.15 10.3872 20.8125 14.9472 17.9475 17.8047C15.3225 20.4297 11.25 20.9697 8.04001 19.1247C7.86001 19.0197 7.63501 19.0797 7.53001 19.2597C7.42501 19.4397 7.49251 19.6647 7.66501 19.7697C9.05251 20.5722 10.5975 20.9622 12.1275 20.9622C14.4525 20.9622 16.755 20.0622 18.48 18.3372C21.5925 15.2247 21.9675 10.2597 19.3875 6.71973L22.8 7.34973C22.995 7.38723 23.1975 7.25223 23.235 7.04973C23.2725 6.84723 23.1375 6.65223 22.935 6.61473L22.9425 6.62223Z' fill='black' /%3e %3cpath d='M6.30022 12.7798C6.09772 12.7423 5.90272 12.8773 5.86522 13.0798L5.24272 16.4548C3.15022 13.2223 3.60022 8.91728 6.33022 6.18728C8.85022 3.66728 12.6752 3.05228 15.8477 4.65728C16.0277 4.74728 16.2602 4.67978 16.3502 4.49228C16.4402 4.30478 16.3727 4.07978 16.1852 3.98978C12.7202 2.23478 8.54272 2.90978 5.79772 5.65478C2.79022 8.66228 2.31772 13.3948 4.65022 16.9273L1.19272 16.2898C0.990221 16.2523 0.795221 16.3873 0.757721 16.5898C0.720221 16.7923 0.855221 16.9873 1.05772 17.0248L5.37022 17.8273C5.37022 17.8273 5.41522 17.8273 5.43772 17.8273C5.61772 17.8273 5.77522 17.6998 5.80522 17.5198L6.60772 13.2073C6.64522 13.0048 6.51022 12.8098 6.30772 12.7723L6.30022 12.7798Z' fill='black' /%3e %3cpath d='M15.0824 13.2223C14.9249 12.9373 14.7224 12.6973 14.4674 12.4948C14.2124 12.2998 13.9349 12.1348 13.6274 11.9998C13.3199 11.8648 13.0124 11.7598 12.7124 11.6773L12.3149 11.5648V7.87482C12.8324 7.91232 13.2749 8.06232 13.6349 8.33232C14.0549 8.64732 14.2874 9.07482 14.3399 9.60732H15.1874C15.1724 9.11982 15.0224 8.68482 14.7524 8.30232C14.4824 7.91982 14.1149 7.61982 13.6574 7.40232C13.2599 7.21482 12.8099 7.12482 12.3149 7.09482V6.31482C12.3149 6.14232 12.1799 6.00732 12.0074 6.00732C11.8349 6.00732 11.6999 6.14232 11.6999 6.31482V7.10982C11.2649 7.14732 10.8449 7.22982 10.4774 7.40232C10.0049 7.61982 9.62988 7.92732 9.35238 8.31732C9.07488 8.70732 8.93988 9.16482 8.93988 9.67482C8.93988 10.2898 9.14988 10.7998 9.56238 11.1898C9.97488 11.5798 10.5599 11.8948 11.3174 12.1198L11.6999 12.2323V16.1323C11.3849 16.1098 11.0849 16.0573 10.8224 15.9523C10.4699 15.8173 10.1849 15.6148 9.96738 15.3523C9.74988 15.0898 9.62238 14.7673 9.59238 14.3923V14.3323C9.59238 14.0848 9.38988 13.8823 9.14238 13.8823C8.89488 13.8823 8.69238 14.0848 8.69238 14.3323V14.3923C8.72988 14.8948 8.87988 15.3448 9.15738 15.7273C9.43488 16.1098 9.80988 16.4098 10.2899 16.6273C10.6949 16.8073 11.1749 16.8973 11.6999 16.9273V17.6848C11.6999 17.8573 11.8349 17.9923 12.0074 17.9923C12.1799 17.9923 12.3149 17.8573 12.3149 17.6848V16.9348C12.8699 16.9048 13.3574 16.7923 13.7774 16.5898C14.2724 16.3498 14.6549 16.0273 14.9174 15.6148C15.1799 15.2023 15.3149 14.7448 15.3149 14.2348C15.3149 13.8373 15.2399 13.4923 15.0824 13.2073V13.2223ZM11.0099 11.1448C10.7849 11.0473 10.5749 10.9348 10.3949 10.7923C10.2074 10.6573 10.0574 10.4923 9.95238 10.3048C9.84738 10.1173 9.78738 9.89232 9.78738 9.63732C9.78738 9.29232 9.88488 8.98482 10.0724 8.71482C10.2674 8.44482 10.5299 8.23482 10.8674 8.07732C11.1149 7.96482 11.3924 7.91232 11.6924 7.88232V11.3848C11.4599 11.3173 11.2349 11.2348 11.0024 11.1373L11.0099 11.1448ZM14.1449 15.2473C13.9274 15.5398 13.6349 15.7648 13.2674 15.9223C12.9824 16.0423 12.6599 16.1023 12.3149 16.1323V12.4198L12.4649 12.4648C12.8624 12.5773 13.2074 12.7123 13.5149 12.8623C13.8149 13.0123 14.0549 13.1998 14.2199 13.4173C14.3849 13.6348 14.4749 13.9123 14.4749 14.2348C14.4749 14.6173 14.3699 14.9548 14.1524 15.2473H14.1449Z' fill='black' /%3e %3cpath d='M14.7525 10.0796C14.985 10.0796 15.1725 9.89211 15.1725 9.65961V9.59961H14.3325V9.65961C14.3325 9.89211 14.52 10.0796 14.7525 10.0796Z' fill='black' /%3e%3c/svg%3e";
@@ -17735,9 +17735,9 @@ const AccountSettings = _a => {
17735
17735
  }), jsxRuntime.jsx(ManageFunding, {
17736
17736
  carrierId: carriers ? carriers[0].carrierId : "",
17737
17737
  currency: currency
17738
- }), jsxRuntime.jsx(PaymentMethodSettings, {}), jsxRuntime.jsx(WalletHistory, {}), jsxRuntime.jsx(Component$6, {}), jsxRuntime.jsx(Component$7, {
17738
+ }), jsxRuntime.jsx(PaymentMethodSettings, {}), jsxRuntime.jsx(WalletHistory, {}), jsxRuntime.jsx(Component$8, {}), jsxRuntime.jsx(Component$9, {
17739
17739
  features: features
17740
- }), jsxRuntime.jsx(Component$8, {
17740
+ }), jsxRuntime.jsx(Component$a, {
17741
17741
  features: features
17742
17742
  }), jsxRuntime.jsx(LabelLayout, {
17743
17743
  display: "settings"
@@ -17773,7 +17773,7 @@ const AccountSettings = _a => {
17773
17773
  *
17774
17774
  * @see {@link AccountSettings.Element | The **Element** created to render `<AccountSettings />`}
17775
17775
  */
17776
- const Component$5 = ({
17776
+ const Component$7 = ({
17777
17777
  features,
17778
17778
  onSaveSettings
17779
17779
  }) => {
@@ -17817,7 +17817,7 @@ const Component$5 = ({
17817
17817
  * @see {@link PaymentMethodSettings | The `<PaymentMethodSettings />` component used to manage payment methods}
17818
17818
  * @see {@link ManageFunding | The `<ManageFunding />` component used to manage funding rules and add funds to a carrier account}
17819
17819
  */
17820
- const Element$6 = alchemy__default["default"].createElement(Component$5, ErrorFallback, {
17820
+ const Element$8 = alchemy__default["default"].createElement(Component$7, ErrorFallback, {
17821
17821
  css: {
17822
17822
  height: "100%",
17823
17823
  maxWidth: "800px",
@@ -17831,8 +17831,8 @@ const Element$6 = alchemy__default["default"].createElement(Component$5, ErrorFa
17831
17831
 
17832
17832
  var accountSettings = /*#__PURE__*/Object.freeze({
17833
17833
  __proto__: null,
17834
- Component: Component$5,
17835
- Element: Element$6
17834
+ Component: Component$7,
17835
+ Element: Element$8
17836
17836
  });
17837
17837
 
17838
17838
  const SuspendSalesOrder = ({
@@ -19123,6 +19123,7 @@ const ShipmentForm = ({
19123
19123
  }) => {
19124
19124
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19125
19125
  features = Object.assign({
19126
+ addOns: true,
19126
19127
  browseRates: true,
19127
19128
  includeShipsuranceInsurance: true,
19128
19129
  includeThirdPartyInsurance: true,
@@ -19808,82 +19809,84 @@ const ShipmentForm = ({
19808
19809
  hint: t("purchase-label:hints.contentDescription"),
19809
19810
  label: t("purchase-label:fields.contentDescription"),
19810
19811
  name: "packages.0.contentDescription"
19811
- }), jsxRuntime.jsx(giger.Divider, {}), jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsxs(FieldLabel, Object.assign({
19812
- label: "purchase-label:fields.addOns"
19813
- }, {
19814
- children: [jsxRuntime.jsx(Switch, Object.assign({
19815
- defaultChecked: ((_g = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _g !== void 0 ? _g : "none") !== "none",
19816
- label: t("purchase-label:fields.confirmation"),
19817
- name: "confirmationEnabled",
19818
- onChange: e => form.setValue("confirmation", e.target.checked ? alchemy.SE.ConfirmationType.DELIVERY : undefined, {
19819
- shouldDirty: true
19820
- }),
19821
- shouldUnmount: true,
19822
- value: ((_h = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _h !== void 0 ? _h : "none") !== "none"
19812
+ }), features.addOns && jsxRuntime.jsxs(jsxRuntime.Fragment, {
19813
+ children: [jsxRuntime.jsx(giger.Divider, {}), jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsxs(FieldLabel, Object.assign({
19814
+ label: "purchase-label:fields.addOns"
19823
19815
  }, {
19824
- children: jsxRuntime.jsx(Select, {
19825
- control: form.control,
19826
- defaultValue: alchemy.SE.ConfirmationType.DELIVERY,
19827
- displayLabel: false,
19816
+ children: [jsxRuntime.jsx(Switch, Object.assign({
19817
+ defaultChecked: ((_g = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _g !== void 0 ? _g : "none") !== "none",
19828
19818
  label: t("purchase-label:fields.confirmation"),
19829
- name: "confirmation",
19830
- options: confirmationOptions,
19831
- shouldUnregister: true
19832
- })
19833
- })), jsxRuntime.jsxs(Switch, Object.assign({
19834
- defaultChecked: ((_j = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _j !== void 0 ? _j : "none") !== "none",
19835
- label: t("purchase-label:fields.insurance"),
19836
- name: "insuranceEnabled",
19837
- onChange: e => {
19838
- setInsuranceEnabled(e.target.checked);
19839
- form.setValue("insuranceProvider", e.target.checked ? alchemy.SE.InsuranceProviderType.CARRIER : undefined, {
19819
+ name: "confirmationEnabled",
19820
+ onChange: e => form.setValue("confirmation", e.target.checked ? alchemy.SE.ConfirmationType.DELIVERY : undefined, {
19840
19821
  shouldDirty: true
19841
- });
19842
- },
19843
- shouldUnmount: true,
19844
- value: ((_k = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _k !== void 0 ? _k : "none") !== "none"
19845
- }, {
19846
- children: [insuranceProviderOptions.length === 1 && insuranceProviderOptions[0].value === "carrier" ? null : jsxRuntime.jsx(Select, {
19847
- control: form.control,
19848
- defaultValue: insuranceEnabled ? alchemy.SE.InsuranceProviderType.CARRIER : alchemy.SE.InsuranceProviderType.NONE,
19849
- displayLabel: false,
19850
- label: t("purchase-label:fields.insuranceProvider"),
19851
- name: "insuranceProvider",
19852
- options: insuranceProviderOptions,
19853
- shouldUnregister: true
19854
- }), jsxRuntime.jsx(MoneyInput, {
19855
- control: form.control,
19856
- defaultValue: {
19857
- amount: undefined,
19858
- currency
19822
+ }),
19823
+ shouldUnmount: true,
19824
+ value: ((_h = shipment === null || shipment === void 0 ? void 0 : shipment.confirmation) !== null && _h !== void 0 ? _h : "none") !== "none"
19825
+ }, {
19826
+ children: jsxRuntime.jsx(Select, {
19827
+ control: form.control,
19828
+ defaultValue: alchemy.SE.ConfirmationType.DELIVERY,
19829
+ displayLabel: false,
19830
+ label: t("purchase-label:fields.confirmation"),
19831
+ name: "confirmation",
19832
+ options: confirmationOptions,
19833
+ shouldUnregister: true
19834
+ })
19835
+ })), jsxRuntime.jsxs(Switch, Object.assign({
19836
+ defaultChecked: ((_j = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _j !== void 0 ? _j : "none") !== "none",
19837
+ label: t("purchase-label:fields.insurance"),
19838
+ name: "insuranceEnabled",
19839
+ onChange: e => {
19840
+ setInsuranceEnabled(e.target.checked);
19841
+ form.setValue("insuranceProvider", e.target.checked ? alchemy.SE.InsuranceProviderType.CARRIER : undefined, {
19842
+ shouldDirty: true
19843
+ });
19859
19844
  },
19860
- displayLabel: false,
19861
- label: t("purchase-label:fields.insuredValue"),
19862
- name: "packages.0.insuredValue",
19863
- placeholder: t("purchase-label:fields.insuredValue"),
19864
- shouldUnregister: true,
19865
- showCurrencySymbol: true
19845
+ shouldUnmount: true,
19846
+ value: ((_k = shipment === null || shipment === void 0 ? void 0 : shipment.insuranceProvider) !== null && _k !== void 0 ? _k : "none") !== "none"
19847
+ }, {
19848
+ children: [insuranceProviderOptions.length === 1 && insuranceProviderOptions[0].value === "carrier" ? null : jsxRuntime.jsx(Select, {
19849
+ control: form.control,
19850
+ defaultValue: insuranceEnabled ? alchemy.SE.InsuranceProviderType.CARRIER : alchemy.SE.InsuranceProviderType.NONE,
19851
+ displayLabel: false,
19852
+ label: t("purchase-label:fields.insuranceProvider"),
19853
+ name: "insuranceProvider",
19854
+ options: insuranceProviderOptions,
19855
+ shouldUnregister: true
19856
+ }), jsxRuntime.jsx(MoneyInput, {
19857
+ control: form.control,
19858
+ defaultValue: {
19859
+ amount: undefined,
19860
+ currency
19861
+ },
19862
+ displayLabel: false,
19863
+ label: t("purchase-label:fields.insuredValue"),
19864
+ name: "packages.0.insuredValue",
19865
+ placeholder: t("purchase-label:fields.insuredValue"),
19866
+ shouldUnregister: true,
19867
+ showCurrencySymbol: true
19868
+ })]
19869
+ })), hasUpsOptions && jsxRuntime.jsx(Switch, {
19870
+ defaultChecked: ((_l = shipment === null || shipment === void 0 ? void 0 : shipment.advancedOptions) === null || _l === void 0 ? void 0 : _l.additionalHandling) || false,
19871
+ label: jsxRuntime.jsx(reactI18next.Trans, {
19872
+ components: {
19873
+ Link: jsxRuntime.jsx(giger.Link, {
19874
+ href: "https://help.paypal.shipstation.com/hc/en-us/articles/13823149193755-UPS-Additional-Handling",
19875
+ rel: "noopener noreferrer",
19876
+ target: "_blank"
19877
+ })
19878
+ },
19879
+ i18nKey: "purchase-label:fields.requires-additional-handling",
19880
+ t: t
19881
+ }),
19882
+ name: "advancedOptions.additionalHandling",
19883
+ onChange: e => form.setValue("advancedOptions.additionalHandling", e.target.checked, {
19884
+ shouldDirty: true
19885
+ }),
19886
+ value: form.getValues("advancedOptions.additionalHandling") || false
19866
19887
  })]
19867
- })), hasUpsOptions && jsxRuntime.jsx(Switch, {
19868
- defaultChecked: ((_l = shipment === null || shipment === void 0 ? void 0 : shipment.advancedOptions) === null || _l === void 0 ? void 0 : _l.additionalHandling) || false,
19869
- label: jsxRuntime.jsx(reactI18next.Trans, {
19870
- components: {
19871
- Link: jsxRuntime.jsx(giger.Link, {
19872
- href: "https://help.paypal.shipstation.com/hc/en-us/articles/13823149193755-UPS-Additional-Handling",
19873
- rel: "noopener noreferrer",
19874
- target: "_blank"
19875
- })
19876
- },
19877
- i18nKey: "purchase-label:fields.requires-additional-handling",
19878
- t: t
19879
- }),
19880
- name: "advancedOptions.additionalHandling",
19881
- onChange: e => form.setValue("advancedOptions.additionalHandling", e.target.checked, {
19882
- shouldDirty: true
19883
- }),
19884
- value: form.getValues("advancedOptions.additionalHandling") || false
19885
- })]
19886
- })), jsxRuntime.jsx("div", Object.assign({
19888
+ }))]
19889
+ }), jsxRuntime.jsx("div", Object.assign({
19887
19890
  css: {
19888
19891
  display: "flex",
19889
19892
  justifyContent: "flex-end"
@@ -22080,7 +22083,7 @@ const PurchaseLabelByShipment = _a => {
22080
22083
  *
22081
22084
  * @see {@link PurchaseLabel.Element | The **Element** created to render `<PurchaseLabel />`}
22082
22085
  */
22083
- const Component$4 = _a => {
22086
+ const Component$6 = _a => {
22084
22087
  var _b, _c;
22085
22088
  var {
22086
22089
  features
@@ -22172,7 +22175,7 @@ const Component$4 = _a => {
22172
22175
  *
22173
22176
  * @see {@link ViewShipment.Element | The next step in the label purchase workflow `<ViewShipment.Element />`}
22174
22177
  */
22175
- const Element$5 = alchemy__default["default"].createElement(Component$4, ErrorFallback, {
22178
+ const Element$7 = alchemy__default["default"].createElement(Component$6, ErrorFallback, {
22176
22179
  css: {
22177
22180
  height: "100%",
22178
22181
  maxWidth: "800px",
@@ -22186,8 +22189,8 @@ const Element$5 = alchemy__default["default"].createElement(Component$4, ErrorFa
22186
22189
 
22187
22190
  var purchaseLabel = /*#__PURE__*/Object.freeze({
22188
22191
  __proto__: null,
22189
- Component: Component$4,
22190
- Element: Element$5
22192
+ Component: Component$6,
22193
+ Element: Element$7
22191
22194
  });
22192
22195
 
22193
22196
  const styles$8 = createStyles({
@@ -22549,338 +22552,642 @@ const Shipment = ({
22549
22552
  });
22550
22553
  };
22551
22554
 
22552
- /**
22553
- * # View Shipment Component
22554
- *
22555
- * - The `<ViewShipment />` component is used to for viewing the shipment's tracking number, printing the label that
22556
- * was created, and the option to void the label. When a label is voided, you can see a list of the
22557
- * previously voided labels for a given shipment using this component.
22558
- *
22559
- * @param ComponentProps The base props that will be passed into the `<ViewShipment />` component.
22560
- *
22561
- * @returns Element An EmotionJSX.Element that will render the `<ViewShipment />` component
22562
- * with all the appropriate wrappers.
22563
- *
22564
- * @example
22565
- * You can see how the `<Component />` is used in the `createElement` function call below.
22566
- * ```tsx
22567
- * export const Element = alchemy.createElement(Component, ErrorFallback, {
22568
- * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
22569
- * resources: { en },
22570
- * });
22571
- * ```
22572
- *
22573
- * <br />
22574
- *
22575
- * @see {@link ViewShipment.Element | The **Element** created to render `<ViewShipment />`}
22576
- */
22577
- const Component$3 = ({
22578
- features,
22579
- onClickPrintLabel,
22580
- onClickPurchaseLabel,
22581
- onClickVoidLabel,
22582
- shipmentId
22583
- }) => {
22584
- var _a, _b, _c;
22585
- const {
22586
- t
22587
- } = reactI18next.useTranslation(["common", "view-shipment"]);
22588
- const shipment = alchemy.useGetSalesOrderShipment(shipmentId);
22589
- const {
22590
- data: {
22591
- labels = []
22592
- } = {}
22593
- } = alchemy.useListLabels({
22594
- shipmentId
22595
- });
22596
- const salesOrder = alchemy.useGetSalesOrder((_b = (_a = shipment.data) === null || _a === void 0 ? void 0 : _a.salesOrderIds) === null || _b === void 0 ? void 0 : _b[0]);
22597
- const warehouses = alchemy.useListWarehouses();
22598
- const carriers = alchemy.useListCarriers();
22599
- if (shipment.isInitialLoading) return jsxRuntime.jsx(Loader, {
22600
- message: t("loading.shipment")
22601
- });
22602
- if (shipment.error) throw new Error(shipment.error.map(e => e.message).join(", "));
22603
- if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
22604
- const warehouse = (_c = warehouses.data) === null || _c === void 0 ? void 0 : _c.find(w => {
22605
- var _a;
22606
- return w.warehouseId === ((_a = shipment.data) === null || _a === void 0 ? void 0 : _a.warehouseId);
22607
- });
22608
- return jsxRuntime.jsx(Shipment, {
22609
- carriers: carriers.data,
22610
- features: features,
22611
- labels: labels,
22612
- onClickPrintLabel: onClickPrintLabel,
22613
- onClickPurchaseLabel: onClickPurchaseLabel,
22614
- onClickVoidLabel: onClickVoidLabel,
22615
- salesOrder: salesOrder.data,
22616
- shipment: shipment.data,
22617
- warehouse: warehouse
22618
- });
22619
- };
22620
- /**
22621
- * # Registered View Shipment Element
22622
- *
22623
- * - This is the registered `<ViewShipment />` element that will be used to render the
22624
- * `<ViewShipment.Element />` component.
22625
- *
22626
- * @param ElementProps The props, callbacks, and resources necessary to render
22627
- * the `<ViewShipment.Element />` component.
22628
- *
22629
- * @example
22630
- * The `<Component />` is the source JSX that is rendered when you make use of the `ViewShipment`
22631
- * Element directly. Here is a brief example of how you would use it within your application.
22632
- * ```tsx
22633
- * <ViewShipment.Element
22634
- * onClickPurchaseLabel={({ salesOrderId }) => {
22635
- * console.log('sales order ID', salesOrderId);
22636
- * }}
22637
- * onClickVoidLabel={({ labelId }) => {
22638
- * console.log('voided label', labelId);
22639
- * }}
22640
- * shipmentId="se-1234567"
22641
- * />
22642
- * ```
22643
- *
22644
- * <br />
22645
- *
22646
- * @see {@link ViewShipment.ComponentProps | The **props** that can be passed into the `<ViewShipment.Element />` component}
22647
- *
22648
- * @see {@link VoidLabel.Element | The next step in the label purchase workflow `<VoidLabel.Element />`}
22649
- **/
22650
- const Element$4 = alchemy__default["default"].createElement(Component$3, ErrorFallback, {
22651
- css: {
22652
- height: "100%",
22653
- maxWidth: "800px",
22654
- minWidth: "440px",
22655
- width: "100%"
22555
+ const styles$7 = createStyles({
22556
+ category: {
22557
+ alignItems: "center",
22558
+ cursor: "pointer",
22559
+ display: "flex",
22560
+ flexDirection: "row",
22561
+ justifyContent: "space-between"
22656
22562
  },
22657
- resources: {
22658
- en
22659
- }
22660
- });
22661
-
22662
- var viewShipment = /*#__PURE__*/Object.freeze({
22663
- __proto__: null,
22664
- Component: Component$3,
22665
- Element: Element$4
22563
+ colorPicker: theme => ({
22564
+ "&::-webkit-color-swatch": {
22565
+ border: `1px solid ${theme.palette.gray.light}`,
22566
+ borderRadius: "4px",
22567
+ padding: 0
22568
+ },
22569
+ "&::-webkit-color-swatch-wrapper": {
22570
+ padding: 0
22571
+ },
22572
+ alignSelf: "center",
22573
+ appearance: "none",
22574
+ background: "none",
22575
+ border: 0,
22576
+ cursor: "pointer",
22577
+ height: theme.spacing(4.25),
22578
+ outline: "none",
22579
+ width: theme.spacing(4.25)
22580
+ }),
22581
+ container: theme => ({
22582
+ marginBottom: theme.spacing(2)
22583
+ }),
22584
+ input: theme => ({
22585
+ border: `1px solid ${theme.palette.gray.light}`,
22586
+ borderRadius: "4px",
22587
+ color: theme.palette.gray.main,
22588
+ fontSize: "14px",
22589
+ padding: theme.spacing(1)
22590
+ }),
22591
+ inputContainer: theme => ({
22592
+ alignItems: "center",
22593
+ display: "flex",
22594
+ flexDirection: "row",
22595
+ justifyContent: "space-between",
22596
+ padding: `${theme.spacing(2)}px 0`
22597
+ }),
22598
+ wrapper: theme => ({
22599
+ display: "flex",
22600
+ gap: theme.spacing(1)
22601
+ })
22666
22602
  });
22667
22603
 
22668
- const Actions = ({
22669
- onComplete,
22670
- onSubmit,
22671
- onViewShipment,
22672
- shipment,
22673
- voidRequest
22604
+ const ColorPaletteEditor = ({
22605
+ paletteConfig,
22606
+ onUpdatePaletteConfig,
22607
+ formatKey
22674
22608
  }) => {
22675
- const {
22676
- t
22677
- } = reactI18next.useTranslation(["common", "void-label"]);
22678
- const [isSubmitting, setIsSubmitting] = React.useState(false);
22679
- const handleSubmit = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
22680
- setIsSubmitting(true);
22681
- yield onSubmit();
22682
- setIsSubmitting(false);
22683
- }), [onSubmit]);
22684
- return jsxRuntime.jsx(giger.BottomSheet, Object.assign({
22685
- alwaysVisible: true,
22686
- css: theme => ({
22687
- borderTop: `1px solid ${theme.palette.gray.ultraLight}`,
22688
- boxShadow: "none",
22689
- position: "static"
22690
- })
22691
- }, {
22692
- children: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ?
22693
- // The void request has been approved
22694
- jsxRuntime.jsxs(ButtonGroup, {
22695
- children: [jsxRuntime.jsx(giger.Button, Object.assign({
22696
- bold: false,
22697
- onClick: () => onComplete(voidRequest, shipment),
22698
- variant: giger.ButtonVariant.OUTLINED
22609
+ const [expandedCategories, setExpandedCategories] = React.useState(new Set());
22610
+ const toggleExpandedCategories = category => {
22611
+ setExpandedCategories(prev => {
22612
+ const openCategories = new Set(prev);
22613
+ if (openCategories.has(category)) {
22614
+ return new Set([...openCategories].filter(item => item !== category));
22615
+ } else {
22616
+ return new Set([...openCategories, category]);
22617
+ }
22618
+ });
22619
+ };
22620
+ const handleInputChange = React.useCallback((category, key, value) => {
22621
+ const updatedConfig = Object.assign(Object.assign({}, paletteConfig || {}), {
22622
+ [category]: Object.assign(Object.assign({}, (paletteConfig === null || paletteConfig === void 0 ? void 0 : paletteConfig[category]) || {}), {
22623
+ [key]: value
22624
+ })
22625
+ });
22626
+ onUpdatePaletteConfig(updatedConfig);
22627
+ }, [onUpdatePaletteConfig, paletteConfig]);
22628
+ return jsxRuntime.jsx("div", Object.assign({
22629
+ "data-test-id": "color-palette-editor"
22630
+ }, {
22631
+ children: paletteConfig && Object.keys(paletteConfig).map(category => jsxRuntime.jsxs("div", Object.assign({
22632
+ css: styles$7.container,
22633
+ id: category
22634
+ }, {
22635
+ children: [jsxRuntime.jsxs("div", Object.assign({
22636
+ "aria-expanded": expandedCategories.has(category),
22637
+ css: styles$7.category,
22638
+ onClick: event => {
22639
+ event.preventDefault();
22640
+ toggleExpandedCategories(category);
22641
+ },
22642
+ role: "button"
22699
22643
  }, {
22700
- children: t("void-label:actions.complete")
22701
- })), jsxRuntime.jsx(giger.Button, Object.assign({
22702
- bold: false,
22703
- isFullWidth: true,
22704
- onClick: () => onViewShipment(shipment)
22644
+ children: [jsxRuntime.jsx("p", {
22645
+ children: capitalizeFirstLetter(category)
22646
+ }), jsxRuntime.jsx(giger.Icon, {
22647
+ name: expandedCategories.has(category) ? gigerTheme.IconNames.CHEVRON_TOP : gigerTheme.IconNames.CHEVRON_BOTTOM,
22648
+ size: giger.IconSize.SIZE_REGULAR
22649
+ })]
22650
+ })), expandedCategories.has(category) && Object.keys(paletteConfig[category]).map(key => jsxRuntime.jsxs("div", Object.assign({
22651
+ css: styles$7.inputContainer,
22652
+ id: "input-container"
22705
22653
  }, {
22706
- children: t("void-label:actions.viewShipment")
22707
- }))]
22708
- }) :
22709
- // The void request has yet to be made or was rejected
22710
- jsxRuntime.jsx(giger.Button, Object.assign({
22711
- bold: false,
22712
- isFullWidth: true,
22713
- isLoading: isSubmitting,
22714
- onClick: handleSubmit
22715
- }, {
22716
- children: t("void-label:actions.confirmVoid")
22717
- }))
22654
+ children: [jsxRuntime.jsx("label", Object.assign({
22655
+ css: {
22656
+ fontWeight: "bold"
22657
+ },
22658
+ htmlFor: `${category}.${key}`
22659
+ }, {
22660
+ children: formatKey(key)
22661
+ })), jsxRuntime.jsxs("form", Object.assign({
22662
+ css: styles$7.wrapper
22663
+ }, {
22664
+ children: [jsxRuntime.jsx("input", {
22665
+ css: styles$7.input,
22666
+ onChange: e => {
22667
+ if (e.target.value.match(/^#[0-9A-Fa-f]{0,6}$/)) handleInputChange(category, key, e.target.value);
22668
+ },
22669
+ onKeyDown: e => {
22670
+ if (e.key === "Enter") e.preventDefault();
22671
+ },
22672
+ type: "text",
22673
+ value: paletteConfig[category][key]
22674
+ }), jsxRuntime.jsx("input", {
22675
+ css: styles$7.colorPicker,
22676
+ onChange: e => handleInputChange(category, key, e.target.value),
22677
+ type: "color",
22678
+ value: paletteConfig[category][key]
22679
+ })]
22680
+ }))]
22681
+ }), key))]
22682
+ }), category))
22718
22683
  }));
22719
22684
  };
22720
22685
 
22721
- const Message = ({
22722
- voidRequest
22686
+ const styles$6 = createStyles({
22687
+ input: theme => ({
22688
+ border: `1px solid ${theme.palette.gray.light}`,
22689
+ borderRadius: "4px",
22690
+ color: theme.palette.gray.main,
22691
+ fontSize: "14px",
22692
+ maxWidth: theme.spacing(16),
22693
+ padding: 0
22694
+ }),
22695
+ keys: {
22696
+ fontSize: "16px",
22697
+ fontWeight: "bold",
22698
+ marginTop: "8px"
22699
+ },
22700
+ section: theme => ({
22701
+ "& > div:first-child": {
22702
+ flexGrow: 3
22703
+ },
22704
+ "& > div:last-child": {
22705
+ flexShrink: 1
22706
+ },
22707
+ display: "flex",
22708
+ gap: theme.spacing(1),
22709
+ justifyContent: "space-between"
22710
+ }),
22711
+ sectionContainer: theme => ({
22712
+ marginBottom: theme.spacing(4)
22713
+ }),
22714
+ select: theme => ({
22715
+ border: `1px solid ${theme.palette.gray.light}`,
22716
+ borderRadius: "4px",
22717
+ color: theme.palette.gray.main,
22718
+ fontSize: "14px"
22719
+ })
22720
+ });
22721
+
22722
+ const TypographyEditor = ({
22723
+ onUpdateTypographyConfig,
22724
+ typographyConfig,
22725
+ formatKey
22723
22726
  }) => {
22724
- const {
22725
- t
22726
- } = reactI18next.useTranslation(["common", "void-label"]);
22727
- return jsxRuntime.jsx(Section, {
22728
- children: voidRequest ? jsxRuntime.jsxs("section", Object.assign({
22729
- css: {
22730
- textAlign: "center",
22731
- width: "100%"
22732
- }
22727
+ const handleInputChange = React.useCallback((variant, key, value) => {
22728
+ const updatedConfig = Object.assign(Object.assign({}, typographyConfig || {}), {
22729
+ [variant]: Object.assign(Object.assign({}, (typographyConfig === null || typographyConfig === void 0 ? void 0 : typographyConfig[variant]) || {}), {
22730
+ [key]: value
22731
+ })
22732
+ });
22733
+ onUpdateTypographyConfig(updatedConfig);
22734
+ }, [onUpdateTypographyConfig, typographyConfig]);
22735
+ const getNestedValue = React.useCallback((obj, key) => {
22736
+ if (!obj) return undefined;
22737
+ return obj[key];
22738
+ }, []);
22739
+ const renderFontWeightSelect = (variant, key) => {
22740
+ var _a;
22741
+ const options = [{
22742
+ label: "Normal",
22743
+ value: "400"
22733
22744
  }, {
22734
- children: [jsxRuntime.jsx(giger.Icon, {
22735
- css: theme => ({
22736
- color: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? theme.palette.success.main : theme.palette.error.main
22737
- }),
22738
- name: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? gigerTheme.IconNames.CHECK_FILLED : gigerTheme.IconNames.ALERT,
22739
- size: giger.IconSize.SIZE_LARGE
22740
- }), (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
22741
- children: [jsxRuntime.jsx(giger.Typography, Object.assign({
22742
- component: "h2"
22743
- }, {
22744
- children: t("void-label:resultTitles.approved")
22745
- })), jsxRuntime.jsx(giger.Typography, {
22746
- children: t("void-label:resultMessages.approved")
22747
- })]
22748
- }) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
22749
- children: [jsxRuntime.jsx(giger.Typography, Object.assign({
22750
- component: "h2"
22751
- }, {
22752
- children: t("void-label:resultTitles.rejected")
22753
- })), jsxRuntime.jsx(giger.Typography, {
22754
- children: jsxRuntime.jsx("p", {
22755
- dangerouslySetInnerHTML: {
22756
- __html: t("void-label:resultMessages.rejected")
22757
- }
22758
- })
22759
- })]
22760
- })]
22761
- })) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
22762
- children: [jsxRuntime.jsx(giger.Typography, {
22763
- children: t("void-label:refund_process")
22764
- }), jsxRuntime.jsx(giger.Typography, Object.assign({
22765
- component: "p"
22745
+ label: "Semi Bold",
22746
+ value: "600"
22747
+ }, {
22748
+ label: "Bold",
22749
+ value: "700"
22750
+ }];
22751
+ const fontWeightValue = (_a = getNestedValue(typographyConfig, variant)) === null || _a === void 0 ? void 0 : _a.fontWeight.toString();
22752
+ const selectOption = fontWeightValue !== undefined ? options.find(option => option.value === fontWeightValue) : undefined;
22753
+ return jsxRuntime.jsx(giger.Select, Object.assign({
22754
+ css: styles$6.select,
22755
+ label: "Font Weight",
22756
+ name: "font-weight",
22757
+ onChange: (_name, value) => handleInputChange(variant, key, value === null || value === void 0 ? void 0 : value.value),
22758
+ value: selectOption
22759
+ }, {
22760
+ children: options.map(option => jsxRuntime.jsx(giger.Option, Object.assign({
22761
+ value: option.value
22766
22762
  }, {
22767
- children: t("void-label:refund_rules")
22768
- }))]
22769
- })
22770
- });
22771
- };
22772
-
22773
- /**
22774
- * # Void Label Component
22775
- *
22776
- * - The `<VoidLabel />` component is used to void a given shipping label. When a label is voided,
22777
- * you then get the option to view the associated shipment via the `View Shipment` Element, or
22778
- * you can purchase another label for the shipment via the `Purchase Label` Element.
22779
- *
22780
- * @param ComponentProps The base props that will be passed into the `<VoidLabel />` component.
22781
- *
22782
- * @returns Element An EmotionJSX.Element that will render the `<VoidLabel />` component
22783
- * with all the appropriate wrappers.
22784
- *
22785
- * @example
22786
- * You can see how the `<Component />` is used in the `createElement` function call below.
22787
- * ```tsx
22788
- * export const Element = alchemy.createElement(Component, ErrorFallback, {
22789
- * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
22790
- * resources: { en },
22791
- * });
22792
- * ```
22793
- *
22794
- * <br />
22795
- *
22796
- * @see {@link VoidLabel.Element | The **Element** created to render `<VoidLabel />`}
22797
- */
22798
- const Component$2 = ({
22799
- features,
22800
- labelId,
22801
- onComplete,
22802
- onSuccess,
22803
- onViewShipment
22804
- }) => {
22805
- var _a, _b;
22806
- features = Object.assign({
22807
- presentation: {
22808
- poweredByShipEngine: false
22809
- }
22810
- }, features !== null && features !== void 0 ? features : {});
22811
- // TODO [LMNT-910] - labelId should be a required prop
22812
- if (!labelId) throw new Error("void-label:errorMessages.labelIdRequired");
22763
+ children: option.label
22764
+ }), option.value))
22765
+ }));
22766
+ };
22767
+ const renderFontSizeInput = (variant, key) => {
22768
+ var _a;
22769
+ const formattedFontSizeValue = (_a = getNestedValue(typographyConfig, variant)) === null || _a === void 0 ? void 0 : _a.fontSize.replace("px", "");
22770
+ return jsxRuntime.jsx(giger.Input, {
22771
+ "aria-labelledby": `${variant}.${key}`,
22772
+ css: styles$6.input,
22773
+ label: "Font Size(px)",
22774
+ onChange: e => {
22775
+ if (e.target.value.match(/^\d{0,2}$/)) handleInputChange(variant, key, `${e.target.value}px`);
22776
+ },
22777
+ value: formattedFontSizeValue
22778
+ });
22779
+ };
22780
+ const renderChildren = (variant, key) => {
22781
+ switch (key) {
22782
+ case "fontWeight":
22783
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
22784
+ children: renderFontWeightSelect(variant, key)
22785
+ });
22786
+ case "fontSize":
22787
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
22788
+ children: renderFontSizeInput(variant, key)
22789
+ });
22790
+ default:
22791
+ return null;
22792
+ }
22793
+ };
22794
+ return jsxRuntime.jsx("div", {
22795
+ children: typographyConfig && Object.keys(typographyConfig).map(variant => jsxRuntime.jsxs("div", Object.assign({
22796
+ css: styles$6.sectionContainer
22797
+ }, {
22798
+ children: [jsxRuntime.jsx("p", Object.assign({
22799
+ css: styles$6.keys,
22800
+ id: variant
22801
+ }, {
22802
+ children: formatKey(variant)
22803
+ })), jsxRuntime.jsx("section", Object.assign({
22804
+ css: styles$6.section
22805
+ }, {
22806
+ children: Object.keys(typographyConfig[variant]).map(key => jsxRuntime.jsx("div", Object.assign({
22807
+ id: `${variant}.${key}`
22808
+ }, {
22809
+ children: renderChildren(variant, key)
22810
+ }), key))
22811
+ }))]
22812
+ }), variant))
22813
+ });
22814
+ };
22815
+
22816
+ const styles$5 = createStyles({
22817
+ container: theme => ({
22818
+ color: theme.palette.gray.dark,
22819
+ display: "flex",
22820
+ flexDirection: "column",
22821
+ flexGrow: 1,
22822
+ overflow: "hidden",
22823
+ position: "relative"
22824
+ }),
22825
+ content: theme => ({
22826
+ display: "flex",
22827
+ flexDirection: "column",
22828
+ gap: theme.spacing(3),
22829
+ padding: theme.spacing(3)
22830
+ }),
22831
+ copy: theme => ({
22832
+ backgroundColor: theme.palette.white,
22833
+ borderRadius: "4px",
22834
+ padding: theme.spacing(0.5)
22835
+ }),
22836
+ drawerHeader: theme => ({
22837
+ alignItems: "center",
22838
+ display: "flex",
22839
+ gap: theme.spacing(2),
22840
+ justifyContent: "end",
22841
+ width: "50%"
22842
+ }),
22843
+ drawerWrapper: {
22844
+ display: "flex",
22845
+ justifyContent: "space-between",
22846
+ position: "relative"
22847
+ },
22848
+ header: {
22849
+ alignItems: "center",
22850
+ display: "flex",
22851
+ justifyContent: "space-between"
22852
+ },
22853
+ popoverWrapper: theme => ({
22854
+ display: "flex",
22855
+ flexDirection: "column",
22856
+ gap: theme.spacing(1)
22857
+ }),
22858
+ pre: theme => ({
22859
+ backgroundColor: "#FFFFFF66",
22860
+ borderRadius: "8px",
22861
+ fontSize: "14px",
22862
+ padding: theme.spacing(0.3)
22863
+ }),
22864
+ presetOption: theme => ({
22865
+ "&:hover": {
22866
+ backgroundColor: "theme.palette.gray.ultraLight"
22867
+ },
22868
+ backgroundColor: "transparent",
22869
+ borderRadius: "4px",
22870
+ fontSize: "14px",
22871
+ padding: theme.spacing(1)
22872
+ }),
22873
+ presetsButton: theme => ({
22874
+ "&:hover": {
22875
+ backgroundColor: "#d1d4d7"
22876
+ },
22877
+ backgroundColor: "#E4E5E7",
22878
+ borderRadius: "4px",
22879
+ cursor: "pointer",
22880
+ display: "flex",
22881
+ fontSize: "14px",
22882
+ gap: theme.spacing(0.5),
22883
+ padding: `${theme.spacing(0.5)}px ${theme.spacing(1)}px`
22884
+ })
22885
+ });
22886
+
22887
+ const ThemeCreator = ({
22888
+ themeConfig,
22889
+ onUpdateThemeConfig,
22890
+ presets,
22891
+ showDrawer
22892
+ }) => {
22893
+ const defaultThemeConfigRef = React.useRef(themeConfig);
22894
+ const [isDrawerOpen, setIsDrawerOpen] = React.useState(false);
22895
+ const globalKeys = Object.keys(themeConfig);
22896
+ // If the themeConfig has a "components" key, show only the child component keys, not "components" itself
22897
+ const tabs = globalKeys.flatMap(key => {
22898
+ if (key === "components" && themeConfig[key] && typeof themeConfig[key] === "object") {
22899
+ const childComponentKeys = Object.keys(themeConfig[key]);
22900
+ return childComponentKeys;
22901
+ } else {
22902
+ return [key];
22903
+ }
22904
+ });
22905
+ const formattedThemeTabs = tabs.map(tab => {
22906
+ if (tab === "palette") {
22907
+ return "Color Palette";
22908
+ }
22909
+ return capitalizeFirstLetter(tab);
22910
+ });
22911
+ const [selectedTab, setSelectedTab] = React.useState(formattedThemeTabs.sort()[0]);
22912
+ const handleSelectedTab = tab => {
22913
+ setSelectedTab(tab);
22914
+ };
22915
+ const formatKey = key => addSpaceBetweenWords(pascalize(key));
22916
+ const renderContentBySelectedTab = (themeConfig, selectedTab) => {
22917
+ var _a;
22918
+ switch (selectedTab) {
22919
+ case "Color Palette":
22920
+ return jsxRuntime.jsx(ColorPaletteEditor, {
22921
+ formatKey: formatKey,
22922
+ onUpdatePaletteConfig: updatedPalette => {
22923
+ onUpdateThemeConfig(Object.assign(Object.assign({}, themeConfig), {
22924
+ palette: updatedPalette
22925
+ }));
22926
+ },
22927
+ paletteConfig: themeConfig.palette
22928
+ });
22929
+ case "Typography":
22930
+ return jsxRuntime.jsx(TypographyEditor, {
22931
+ formatKey: formatKey,
22932
+ onUpdateTypographyConfig: updatedTypography => {
22933
+ onUpdateThemeConfig(Object.assign(Object.assign({}, themeConfig), {
22934
+ components: Object.assign(Object.assign({}, themeConfig.components), {
22935
+ Typography: updatedTypography
22936
+ })
22937
+ }));
22938
+ },
22939
+ typographyConfig: (_a = themeConfig.components) === null || _a === void 0 ? void 0 : _a.Typography
22940
+ });
22941
+ default:
22942
+ return null;
22943
+ }
22944
+ };
22945
+ // const formattedThemeObj = `const theme = ${JSON.stringify(themeConfig, null, 2)}`;
22946
+ const presetsRef = React.useRef(null);
22947
+ const [showPresets, toggleShowPresets] = useToggle(false);
22948
+ const applyPreset = theme => {
22949
+ onUpdateThemeConfig(theme);
22950
+ };
22951
+ return jsxRuntime.jsxs("div", Object.assign({
22952
+ "aria-label": "Theme Creator",
22953
+ css: styles$5.container,
22954
+ "data-testid": "theme-creator",
22955
+ role: "region"
22956
+ }, {
22957
+ children: [jsxRuntime.jsxs("div", Object.assign({
22958
+ css: styles$5.content
22959
+ }, {
22960
+ children: [jsxRuntime.jsxs("div", Object.assign({
22961
+ css: styles$5.header
22962
+ }, {
22963
+ children: [jsxRuntime.jsx(Tabs, {
22964
+ onSelectTab: handleSelectedTab,
22965
+ selectedTab: selectedTab,
22966
+ tabs: formattedThemeTabs
22967
+ }), presets ? jsxRuntime.jsxs("div", {
22968
+ children: [jsxRuntime.jsxs("button", Object.assign({
22969
+ "aria-controls": "presets-popover",
22970
+ "aria-expanded": showPresets,
22971
+ css: styles$5.presetsButton,
22972
+ onClick: e => {
22973
+ e.preventDefault();
22974
+ toggleShowPresets();
22975
+ },
22976
+ ref: presetsRef
22977
+ }, {
22978
+ children: ["Presets", jsxRuntime.jsx(giger.Icon, {
22979
+ name: gigerTheme.IconNames.CARET_BOTTOM,
22980
+ size: giger.IconSize.SIZE_SMALL
22981
+ })]
22982
+ })), jsxRuntime.jsx(giger.Popover, Object.assign({
22983
+ container: document.querySelector("#theme-creator"),
22984
+ isOpen: showPresets,
22985
+ onClickAway: () => toggleShowPresets(),
22986
+ placement: "bottom-end",
22987
+ reference: presetsRef.current
22988
+ }, {
22989
+ children: jsxRuntime.jsxs("div", Object.assign({
22990
+ css: styles$5.popoverWrapper
22991
+ }, {
22992
+ children: [jsxRuntime.jsx("button", Object.assign({
22993
+ "aria-label": "Set Default Theme",
22994
+ css: styles$5.presetOption,
22995
+ onClick: e => {
22996
+ e.preventDefault();
22997
+ toggleShowPresets();
22998
+ applyPreset(defaultThemeConfigRef.current);
22999
+ },
23000
+ role: "menuitem"
23001
+ }, {
23002
+ children: "Default"
23003
+ })), presets.map(preset => jsxRuntime.jsx("button", Object.assign({
23004
+ "aria-label": `Set ${preset.presetName} Theme`,
23005
+ css: styles$5.presetOption,
23006
+ onClick: e => {
23007
+ e.preventDefault();
23008
+ toggleShowPresets();
23009
+ applyPreset(preset.themeConfig);
23010
+ },
23011
+ role: "menuitem"
23012
+ }, {
23013
+ children: preset.presetName
23014
+ }), preset.presetName))]
23015
+ }))
23016
+ }))]
23017
+ }) :
23018
+ //reset to default button
23019
+ jsxRuntime.jsx("button", Object.assign({
23020
+ "aria-label": "Set Default Theme",
23021
+ css: styles$5.presetsButton,
23022
+ onClick: () => {
23023
+ applyPreset(defaultThemeConfigRef.current);
23024
+ },
23025
+ role: "menuitem"
23026
+ }, {
23027
+ children: "Reset to Default"
23028
+ }))]
23029
+ })), jsxRuntime.jsx(giger.Typography, Object.assign({
23030
+ role: "heading",
23031
+ variant: "heading4"
23032
+ }, {
23033
+ children: `${selectedTab} Editor`
23034
+ })), renderContentBySelectedTab(themeConfig, selectedTab)]
23035
+ })), showDrawer && jsxRuntime.jsx(Drawer, Object.assign({
23036
+ "aria-label": "Show themeConfig.js Code Drawer",
23037
+ headerContent: jsxRuntime.jsxs("div", Object.assign({
23038
+ css: styles$5.drawerHeader
23039
+ }, {
23040
+ children: [jsxRuntime.jsx("pre", Object.assign({
23041
+ css: styles$5.pre
23042
+ }, {
23043
+ children: "themeConfig.js"
23044
+ })), showDrawer.copyToClipboardText && jsxRuntime.jsx("div", Object.assign({
23045
+ css: styles$5.copy
23046
+ }, {
23047
+ children: jsxRuntime.jsx(CopyButton, {
23048
+ content: showDrawer.copyToClipboardText
23049
+ })
23050
+ }))]
23051
+ })),
23052
+ isOpen: isDrawerOpen,
23053
+ toggleDrawer: () => setIsDrawerOpen(!isDrawerOpen)
23054
+ }, {
23055
+ children: showDrawer.content
23056
+ }))]
23057
+ }));
23058
+ };
23059
+
23060
+ const Component$5 = ({
23061
+ onRowClick
23062
+ }) => {
22813
23063
  const {
22814
23064
  t
22815
- } = reactI18next.useTranslation();
22816
- const label = alchemy.useGetLabel(labelId);
22817
- const shipment = alchemy.useGetSalesOrderShipment((_a = label.data) === null || _a === void 0 ? void 0 : _a.shipmentId);
22818
- const voidLabel = alchemy.useVoidLabel();
22819
- if (label.isInitialLoading) return jsxRuntime.jsx(Loader, {
22820
- message: t("loading.label")
23065
+ } = reactI18next.useTranslation(["common", "list-labels"]);
23066
+ const {
23067
+ page,
23068
+ pageSize,
23069
+ pagerProps
23070
+ } = usePager();
23071
+ const {
23072
+ data: carriersData,
23073
+ isLoading: carriersLoading
23074
+ } = alchemy.useListCarriers();
23075
+ const {
23076
+ data: labelsData,
23077
+ isLoading,
23078
+ isError,
23079
+ error
23080
+ } = alchemy.useListLabels({
23081
+ page,
23082
+ pageSize
22821
23083
  });
22822
- if (shipment.isInitialLoading) return jsxRuntime.jsx(Loader, {
22823
- message: t("loading.shipment")
23084
+ const shipmentIds = (labelsData === null || labelsData === void 0 ? void 0 : labelsData.labels) ? labelsData.labels.filter(l => l.shipmentId).map(l => l.shipmentId) : [];
23085
+ const {
23086
+ data: shipmentsData,
23087
+ isLoading: shipmentsLoading
23088
+ } = alchemy.useListSalesOrderShipments({
23089
+ shipmentIds
22824
23090
  });
22825
- throwAny(label.error);
22826
- throwAny(shipment.error);
22827
- if (!label.data) throw new Error("errorMessages.unableToLoad.label");
22828
- if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
22829
- const handleVoidLabelSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
22830
- const result = yield voidLabel.mutateAsync(labelId);
22831
- if (result.approved) {
22832
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(label.data, shipment.data);
22833
- }
23091
+ if (isLoading) return jsxRuntime.jsx(Loader, {
23092
+ message: t("loading.labels")
22834
23093
  });
22835
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
22836
- children: [jsxRuntime.jsx(Message, {
22837
- voidRequest: voidLabel.data
22838
- }), jsxRuntime.jsx(Actions, {
22839
- onComplete: onComplete,
22840
- onSubmit: handleVoidLabelSubmit,
22841
- onViewShipment: onViewShipment,
22842
- shipment: shipment.data,
22843
- voidRequest: voidLabel.data
22844
- }), ((_b = features === null || features === void 0 ? void 0 : features.presentation) === null || _b === void 0 ? void 0 : _b.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
22845
- children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(PoweredByShipEngine, {})]
22846
- })]
23094
+ if (isError) throw new Error(error.map(e => e.message).join(", "));
23095
+ if (!labelsData) throw new Error(t("errorMessages.unableToLoad.labels"));
23096
+ const columns = [{
23097
+ headerContent: t("list-labels:headers.labelId"),
23098
+ renderCellContent: data => {
23099
+ return jsxRuntime.jsx("div", {
23100
+ children: data.labelId
23101
+ });
23102
+ }
23103
+ }, {
23104
+ headerContent: t("list-labels:headers.created"),
23105
+ renderCellContent: data => {
23106
+ return (data === null || data === void 0 ? void 0 : data.shipDate) && jsxRuntime.jsx(CellFormattedDate, {
23107
+ date: data.shipDate
23108
+ });
23109
+ }
23110
+ }, {
23111
+ headerContent: t("list-labels:headers.shipTo"),
23112
+ renderCellContent: data => {
23113
+ const labelShipment = shipmentsData === null || shipmentsData === void 0 ? void 0 : shipmentsData.find(s => s.shipmentId === data.shipmentId);
23114
+ const displayAddress = labelShipment && labelShipment.shipTo.addressLine1 ? jsxRuntime.jsx(AddressDisplay, {
23115
+ address: labelShipment.shipTo
23116
+ }) : "--";
23117
+ return jsxRuntime.jsx(SuspendText, Object.assign({
23118
+ loading: shipmentsLoading
23119
+ }, {
23120
+ children: displayAddress
23121
+ }));
23122
+ }
23123
+ }, {
23124
+ headerContent: t("list-labels:headers.service"),
23125
+ renderCellContent: data => {
23126
+ if (!carriersLoading && carriersData) {
23127
+ const carrier = carriersData.find(c => c.carrierCode === data.carrierCode);
23128
+ if (carrier) {
23129
+ const service = carrier.services.find(s => s.serviceCode === data.serviceCode);
23130
+ if (service) {
23131
+ return jsxRuntime.jsxs("div", {
23132
+ children: [jsxRuntime.jsx(CarrierIcon, {
23133
+ carrierCode: data.carrierCode
23134
+ }, data.carrierCode), "\u00A0 ", service.name]
23135
+ });
23136
+ }
23137
+ }
23138
+ }
23139
+ return jsxRuntime.jsxs(SuspendText, Object.assign({
23140
+ loading: carriersLoading
23141
+ }, {
23142
+ children: ["`$", data.carrierCode, " - $", data.serviceCode, "`"]
23143
+ }));
23144
+ }
23145
+ }, {
23146
+ // Download
23147
+ headerContent: jsxRuntime.jsx("div", {
23148
+ "aria-label": t("list-labels:headers.download")
23149
+ }),
23150
+ renderCellContent: data => {
23151
+ if (data.status === "completed") return jsxRuntime.jsx("div", Object.assign({
23152
+ css: {
23153
+ textAlign: "right"
23154
+ }
23155
+ }, {
23156
+ children: jsxRuntime.jsx(giger.ButtonIcon, {
23157
+ ariaDescribedby: "",
23158
+ children: t("list-labels:actions.download.pdf"),
23159
+ icon: gigerTheme.IconNames.DOWNLOAD,
23160
+ onClick: e => {
23161
+ e.stopPropagation();
23162
+ window.open(data.labelDownload.pdf);
23163
+ }
23164
+ })
23165
+ }));
23166
+ return jsxRuntime.jsx("div", Object.assign({
23167
+ css: {
23168
+ textAlign: "right"
23169
+ }
23170
+ }, {
23171
+ children: jsxRuntime.jsx(giger.Tag, Object.assign({
23172
+ color: giger.TagColor.INFO
23173
+ }, {
23174
+ children: data.status.toLocaleUpperCase()
23175
+ }))
23176
+ }));
23177
+ }
23178
+ }];
23179
+ return jsxRuntime.jsx(GridController, {
23180
+ columns: columns,
23181
+ data: labelsData.labels,
23182
+ footerContent: jsxRuntime.jsx(Pager, Object.assign({}, pagerProps, {
23183
+ pagingData: labelsData
23184
+ })),
23185
+ onRowClick: onRowClick
22847
23186
  });
22848
23187
  };
22849
- /**
22850
- * # Registered Void Label Element
22851
- *
22852
- * - This is the registered `<VoidLabel />` element that will be used to render the
22853
- * `<VoidLabel.Element />` component.
22854
- *
22855
- * @param ElementProps The props, callbacks, and resources necessary to render
22856
- * the `<VoidLabel.Element />` component.
22857
- *
22858
- * @example
22859
- * The `<Component />` is the source JSX that is rendered when you make use of the `VoidLabel`
22860
- * Element directly. Here is a brief example of how you would use it within your application.
22861
- * ```tsx
22862
- * <VoidLabel.Element
22863
- * labelId="se-1234567"
22864
- * onComplete={() => console.log('onComplete')}
22865
- * onSuccess={(_, { salesOrderIds: [salesOrderId] }) =>
22866
- * console.log('sales order ID', salesOrderId)
22867
- * }
22868
- * onViewShipment={({ shipmentId }) => {
22869
- * console.log('onViewShipment', shipmentId);
22870
- * }}
22871
- * />
22872
- * ```
22873
- *
22874
- * <br />
22875
- *
22876
- * @see {@link VoidLabel.ComponentProps | The **props** that can be passed into the `<VoidLabel.Element />` component}
22877
- *
22878
- * @see {@link PurchaseLabel.Element | Go back to the frst step in the label purchase workflow `<PurchaseLabel.Element />`}
22879
- */
22880
- const Element$3 = alchemy__default["default"].createElement(Component$2, ErrorFallback, {
23188
+ const Element$6 = alchemy__default["default"].createElement(Component$5, ErrorFallback, {
22881
23189
  css: {
22882
23190
  height: "100%",
22883
- maxWidth: "800px",
22884
23191
  minWidth: "440px",
22885
23192
  width: "100%"
22886
23193
  },
@@ -22889,686 +23196,600 @@ const Element$3 = alchemy__default["default"].createElement(Component$2, ErrorFa
22889
23196
  }
22890
23197
  });
22891
23198
 
22892
- var voidLabel = /*#__PURE__*/Object.freeze({
23199
+ var labelsGrid = /*#__PURE__*/Object.freeze({
22893
23200
  __proto__: null,
22894
- Component: Component$2,
22895
- Element: Element$3
23201
+ Element: Element$6
22896
23202
  });
22897
23203
 
22898
23204
  /**
22899
- * @internal
23205
+ * # View Shipment Component
22900
23206
  *
22901
- * # Label Workflow Component
23207
+ * - The `<ViewShipment />` component is used to for viewing the shipment's tracking number, printing the label that
23208
+ * was created, and the option to void the label. When a label is voided, you can see a list of the
23209
+ * previously voided labels for a given shipment using this component.
23210
+ *
23211
+ * @param ComponentProps The base props that will be passed into the `<ViewShipment />` component.
23212
+ *
23213
+ * @returns Element An EmotionJSX.Element that will render the `<ViewShipment />` component
23214
+ * with all the appropriate wrappers.
22902
23215
  *
22903
23216
  * @example
23217
+ * You can see how the `<Component />` is used in the `createElement` function call below.
22904
23218
  * ```tsx
22905
- * const {
22906
- * labelId,
22907
- * multiplexedId,
22908
- * isVoidingLabel,
22909
- * shipmentId,
22910
- * setLabelId,
22911
- * setShipmentId,
22912
- * setIsVoidingLabel,
22913
- * } = useLabelWorkflow({
22914
- * _labelId,
22915
- * _multiplexedId,
22916
- * });
23219
+ * export const Element = alchemy.createElement(Component, ErrorFallback, {
23220
+ * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
23221
+ * resources: { en },
23222
+ * });
22917
23223
  * ```
22918
23224
  *
22919
23225
  * <br />
22920
23226
  *
22921
- * @see {@link LabelWorkflow.Element | The `<LabelWorkflow.Element />` component using this hook}
23227
+ * @see {@link ViewShipment.Element | The **Element** created to render `<ViewShipment />`}
22922
23228
  */
22923
- const useLabelWorkflow = ({
22924
- _multiplexedId,
22925
- _labelId
23229
+ const Component$4 = ({
23230
+ features,
23231
+ onClickPrintLabel,
23232
+ onClickPurchaseLabel,
23233
+ onClickVoidLabel,
23234
+ shipmentId
22926
23235
  }) => {
22927
- // Fix first ids as the user of the library shouldn't be changing them
22928
- const [multiplexedId, setMultiplexedId] = React.useState(_multiplexedId);
22929
- const [shipmentId, setShipmentId] = React.useState("shipmentId" in _multiplexedId ? _multiplexedId.shipmentId : undefined);
22930
- const [labelId, _setLabelId] = React.useState(_labelId);
22931
- const [isVoidingLabel, setIsVoidingLabel] = React.useState(false);
22932
- const setLabelId = React.useCallback(nextLabelId => {
22933
- setIsVoidingLabel(false);
22934
- _setLabelId(nextLabelId);
22935
- }, []);
22936
- return {
22937
- isVoidingLabel,
22938
- labelId,
22939
- multiplexedId,
22940
- setIsVoidingLabel,
22941
- setLabelId,
22942
- setMultiplexedId,
22943
- setShipmentId,
23236
+ var _a, _b, _c;
23237
+ const {
23238
+ t
23239
+ } = reactI18next.useTranslation(["common", "view-shipment"]);
23240
+ const shipment = alchemy.useGetSalesOrderShipment(shipmentId);
23241
+ const {
23242
+ data: {
23243
+ labels = []
23244
+ } = {}
23245
+ } = alchemy.useListLabels({
22944
23246
  shipmentId
22945
- };
23247
+ });
23248
+ const salesOrder = alchemy.useGetSalesOrder((_b = (_a = shipment.data) === null || _a === void 0 ? void 0 : _a.salesOrderIds) === null || _b === void 0 ? void 0 : _b[0]);
23249
+ const warehouses = alchemy.useListWarehouses();
23250
+ const carriers = alchemy.useListCarriers();
23251
+ if (shipment.isInitialLoading) return jsxRuntime.jsx(Loader, {
23252
+ message: t("loading.shipment")
23253
+ });
23254
+ if (shipment.error) throw new Error(shipment.error.map(e => e.message).join(", "));
23255
+ if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
23256
+ const warehouse = (_c = warehouses.data) === null || _c === void 0 ? void 0 : _c.find(w => {
23257
+ var _a;
23258
+ return w.warehouseId === ((_a = shipment.data) === null || _a === void 0 ? void 0 : _a.warehouseId);
23259
+ });
23260
+ return jsxRuntime.jsx(Shipment, {
23261
+ carriers: carriers.data,
23262
+ features: features,
23263
+ labels: labels,
23264
+ onClickPrintLabel: onClickPrintLabel,
23265
+ onClickPurchaseLabel: onClickPurchaseLabel,
23266
+ onClickVoidLabel: onClickVoidLabel,
23267
+ salesOrder: salesOrder.data,
23268
+ shipment: shipment.data,
23269
+ warehouse: warehouse
23270
+ });
22946
23271
  };
22947
23272
  /**
22948
- * @internal
22949
- *
22950
- * # Label Workflow Element
22951
- *
22952
- * - The `<LabelWorkflow.Element />` component is a composition of the PurchaseLabel, ViewShipment,
22953
- * and VoidLabel elements that allows users to purchase a label, view the shipment details, and optionally void their shipping label.
23273
+ * # Registered View Shipment Element
22954
23274
  *
22955
- * @param LabelWorkflowProps The props necessary to render the `<LabelWorkflow.Element />` for shipment
22956
- * based or sales order based label purchasing.
23275
+ * - This is the registered `<ViewShipment />` element that will be used to render the
23276
+ * `<ViewShipment.Element />` component.
22957
23277
  *
22958
- * @returns Element A React Element that will render the `<LabelWorkflow />` component.
23278
+ * @param ElementProps The props, callbacks, and resources necessary to render
23279
+ * the `<ViewShipment.Element />` component.
22959
23280
  *
22960
23281
  * @example
23282
+ * The `<Component />` is the source JSX that is rendered when you make use of the `ViewShipment`
23283
+ * Element directly. Here is a brief example of how you would use it within your application.
22961
23284
  * ```tsx
22962
- * <LabelWorkflow
22963
- * {...elementProps}
22964
- * callbacks={{ onLabelCreateSuccess }}
22965
- * multiplexedId={elementIdProps}
23285
+ * <ViewShipment.Element
23286
+ * onClickPurchaseLabel={({ salesOrderId }) => {
23287
+ * console.log('sales order ID', salesOrderId);
23288
+ * }}
23289
+ * onClickVoidLabel={({ labelId }) => {
23290
+ * console.log('voided label', labelId);
23291
+ * }}
23292
+ * shipmentId="se-1234567"
22966
23293
  * />
22967
23294
  * ```
22968
23295
  *
22969
23296
  * <br />
22970
23297
  *
22971
- * @see {@link LabelWorkflowProps | The props that are passed into the `<LabelWorkflow />` component}
22972
- * @see {@link LabelWorkflow.useLabelWorkflow | The `hook` that is used to manage the state of the `<LabelWorkflow />` component}
22973
- */
22974
- const Element$2 = (
22975
- /*
22976
- The passed props are underscore prefixed as they will be stashed, then from them stateful versions will be made
22977
- */
22978
- {
22979
- multiplexedId: _multiplexedId,
22980
- labelId: _labelId,
22981
- features: propFeatures,
22982
- callbacks
22983
- }) => {
22984
- const {
22985
- labelId,
22986
- multiplexedId,
22987
- isVoidingLabel,
22988
- shipmentId,
22989
- setLabelId,
22990
- setShipmentId,
22991
- setIsVoidingLabel
22992
- } = useLabelWorkflow({
22993
- _labelId,
22994
- _multiplexedId
22995
- });
22996
- const _features = useFeatures("Globals");
22997
- const features = React.useMemo(() => {
22998
- var _a;
22999
- return Object.assign(Object.assign(Object.assign({}, propFeatures), _features), {
23000
- global: Object.assign(Object.assign({}, _features.global), {
23001
- presentation: Object.assign(Object.assign({}, (_a = _features.global) === null || _a === void 0 ? void 0 : _a.presentation), {
23002
- poweredByShipEngine: true
23003
- })
23004
- })
23005
- });
23006
- }, []);
23007
- return !labelId ? jsxRuntime.jsx(Element$5, Object.assign({}, multiplexedId, {
23008
- features: features,
23009
- onLabelCreateSuccess: (label, shipment) => {
23010
- var _a;
23011
- setLabelId(label.labelId);
23012
- setShipmentId(shipment.shipmentId);
23013
- (_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.onLabelCreateSuccess) === null || _a === void 0 ? void 0 : _a.call(callbacks, label, shipment);
23014
- },
23015
- onLoad: (salesOrder, shipments, pendingShipment) => {
23016
- if (shipments.length > 0) {
23017
- setShipmentId(prior => prior !== undefined ? prior : shipments[0].shipmentId);
23018
- }
23019
- }
23020
- })) : !isVoidingLabel ? jsxRuntime.jsx(Element$4, {
23021
- features: features,
23022
- onClickPurchaseLabel: () => {
23023
- setLabelId(undefined);
23024
- },
23025
- onClickVoidLabel: () => {
23026
- setIsVoidingLabel(true);
23027
- },
23028
- shipmentId: shipmentId
23029
- }) : jsxRuntime.jsx(Element$3, {
23030
- features: features,
23031
- labelId: labelId,
23032
- onComplete: () => {
23033
- setIsVoidingLabel(false);
23034
- },
23035
- onViewShipment: () => {
23036
- setIsVoidingLabel(false);
23037
- }
23038
- });
23039
- };
23040
-
23041
- var labelWorkflow = /*#__PURE__*/Object.freeze({
23042
- __proto__: null,
23043
- useLabelWorkflow: useLabelWorkflow,
23044
- Element: Element$2
23298
+ * @see {@link ViewShipment.ComponentProps | The **props** that can be passed into the `<ViewShipment.Element />` component}
23299
+ *
23300
+ * @see {@link VoidLabel.Element | The next step in the label purchase workflow `<VoidLabel.Element />`}
23301
+ **/
23302
+ const Element$5 = alchemy__default["default"].createElement(Component$4, ErrorFallback, {
23303
+ css: {
23304
+ height: "100%",
23305
+ maxWidth: "800px",
23306
+ minWidth: "440px",
23307
+ width: "100%"
23308
+ },
23309
+ resources: {
23310
+ en
23311
+ }
23045
23312
  });
23046
23313
 
23047
- const ThemeCreatorContext = /*#__PURE__*/React.createContext(undefined);
23048
- const ThemeCreatorProvider = ({
23049
- children,
23050
- editableTheme
23051
- }) => {
23052
- const [themeConfig, setThemeConfig] = React.useState(editableTheme);
23053
- return jsxRuntime.jsx(ThemeCreatorContext.Provider, Object.assign({
23054
- value: {
23055
- setThemeConfig,
23056
- themeConfig
23057
- }
23058
- }, {
23059
- children: children
23060
- }));
23061
- };
23062
- const useThemeCreator = () => {
23063
- const themeCreatorContext = React.useContext(ThemeCreatorContext);
23064
- if (!themeCreatorContext) throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");
23065
- return themeCreatorContext;
23066
- };
23067
-
23068
- const styles$7 = createStyles({
23069
- category: {
23070
- alignItems: "center",
23071
- cursor: "pointer",
23072
- display: "flex",
23073
- flexDirection: "row",
23074
- justifyContent: "space-between"
23075
- },
23076
- colorPicker: theme => ({
23077
- "&::-webkit-color-swatch": {
23078
- border: `1px solid ${theme.palette.gray.light}`,
23079
- borderRadius: "4px",
23080
- padding: 0
23081
- },
23082
- "&::-webkit-color-swatch-wrapper": {
23083
- padding: 0
23084
- },
23085
- alignSelf: "center",
23086
- appearance: "none",
23087
- background: "none",
23088
- border: 0,
23089
- cursor: "pointer",
23090
- height: theme.spacing(4.25),
23091
- outline: "none",
23092
- width: theme.spacing(4.25)
23093
- }),
23094
- container: theme => ({
23095
- marginBottom: theme.spacing(2)
23096
- }),
23097
- input: theme => ({
23098
- border: `1px solid ${theme.palette.gray.light}`,
23099
- borderRadius: "4px",
23100
- color: theme.palette.gray.main,
23101
- fontSize: "14px",
23102
- padding: theme.spacing(1)
23103
- }),
23104
- inputContainer: theme => ({
23105
- alignItems: "center",
23106
- display: "flex",
23107
- flexDirection: "row",
23108
- justifyContent: "space-between",
23109
- padding: `${theme.spacing(2)}px 0`
23110
- }),
23111
- wrapper: theme => ({
23112
- display: "flex",
23113
- gap: theme.spacing(1)
23114
- })
23314
+ var viewShipment = /*#__PURE__*/Object.freeze({
23315
+ __proto__: null,
23316
+ Component: Component$4,
23317
+ Element: Element$5
23115
23318
  });
23116
23319
 
23117
- const ColorPaletteEditor = ({
23118
- paletteConfig,
23119
- onUpdatePaletteConfig,
23120
- formatKey
23320
+ const Actions = ({
23321
+ onComplete,
23322
+ onSubmit,
23323
+ onViewShipment,
23324
+ shipment,
23325
+ voidRequest
23121
23326
  }) => {
23122
- const [expandedCategories, setExpandedCategories] = React.useState(new Set());
23123
- const toggleExpandedCategories = category => {
23124
- setExpandedCategories(prev => {
23125
- const openCategories = new Set(prev);
23126
- if (openCategories.has(category)) {
23127
- return new Set([...openCategories].filter(item => item !== category));
23128
- } else {
23129
- return new Set([...openCategories, category]);
23130
- }
23131
- });
23132
- };
23133
- const handleInputChange = React.useCallback((category, key, value) => {
23134
- const updatedConfig = Object.assign(Object.assign({}, paletteConfig || {}), {
23135
- [category]: Object.assign(Object.assign({}, (paletteConfig === null || paletteConfig === void 0 ? void 0 : paletteConfig[category]) || {}), {
23136
- [key]: value
23137
- })
23138
- });
23139
- onUpdatePaletteConfig(updatedConfig);
23140
- }, [onUpdatePaletteConfig, paletteConfig]);
23141
- return jsxRuntime.jsx("div", Object.assign({
23142
- "data-test-id": "color-palette-editor"
23327
+ const {
23328
+ t
23329
+ } = reactI18next.useTranslation(["common", "void-label"]);
23330
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
23331
+ const handleSubmit = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
23332
+ setIsSubmitting(true);
23333
+ yield onSubmit();
23334
+ setIsSubmitting(false);
23335
+ }), [onSubmit]);
23336
+ return jsxRuntime.jsx(giger.BottomSheet, Object.assign({
23337
+ alwaysVisible: true,
23338
+ css: theme => ({
23339
+ borderTop: `1px solid ${theme.palette.gray.ultraLight}`,
23340
+ boxShadow: "none",
23341
+ position: "static"
23342
+ })
23143
23343
  }, {
23144
- children: paletteConfig && Object.keys(paletteConfig).map(category => jsxRuntime.jsxs("div", Object.assign({
23145
- css: styles$7.container,
23146
- id: category
23147
- }, {
23148
- children: [jsxRuntime.jsxs("div", Object.assign({
23149
- "aria-expanded": expandedCategories.has(category),
23150
- css: styles$7.category,
23151
- onClick: event => {
23152
- event.preventDefault();
23153
- toggleExpandedCategories(category);
23154
- },
23155
- role: "button"
23344
+ children: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ?
23345
+ // The void request has been approved
23346
+ jsxRuntime.jsxs(ButtonGroup, {
23347
+ children: [jsxRuntime.jsx(giger.Button, Object.assign({
23348
+ bold: false,
23349
+ onClick: () => onComplete(voidRequest, shipment),
23350
+ variant: giger.ButtonVariant.OUTLINED
23156
23351
  }, {
23157
- children: [jsxRuntime.jsx("p", {
23158
- children: capitalizeFirstLetter(category)
23159
- }), jsxRuntime.jsx(giger.Icon, {
23160
- name: expandedCategories.has(category) ? gigerTheme.IconNames.CHEVRON_TOP : gigerTheme.IconNames.CHEVRON_BOTTOM,
23161
- size: giger.IconSize.SIZE_REGULAR
23162
- })]
23163
- })), expandedCategories.has(category) && Object.keys(paletteConfig[category]).map(key => jsxRuntime.jsxs("div", Object.assign({
23164
- css: styles$7.inputContainer,
23165
- id: "input-container"
23352
+ children: t("void-label:actions.complete")
23353
+ })), jsxRuntime.jsx(giger.Button, Object.assign({
23354
+ bold: false,
23355
+ isFullWidth: true,
23356
+ onClick: () => onViewShipment(shipment)
23166
23357
  }, {
23167
- children: [jsxRuntime.jsx("label", Object.assign({
23168
- css: {
23169
- fontWeight: "bold"
23170
- },
23171
- htmlFor: `${category}.${key}`
23358
+ children: t("void-label:actions.viewShipment")
23359
+ }))]
23360
+ }) :
23361
+ // The void request has yet to be made or was rejected
23362
+ jsxRuntime.jsx(giger.Button, Object.assign({
23363
+ bold: false,
23364
+ isFullWidth: true,
23365
+ isLoading: isSubmitting,
23366
+ onClick: handleSubmit
23367
+ }, {
23368
+ children: t("void-label:actions.confirmVoid")
23369
+ }))
23370
+ }));
23371
+ };
23372
+
23373
+ const Message = ({
23374
+ voidRequest
23375
+ }) => {
23376
+ const {
23377
+ t
23378
+ } = reactI18next.useTranslation(["common", "void-label"]);
23379
+ return jsxRuntime.jsx(Section, {
23380
+ children: voidRequest ? jsxRuntime.jsxs("section", Object.assign({
23381
+ css: {
23382
+ textAlign: "center",
23383
+ width: "100%"
23384
+ }
23385
+ }, {
23386
+ children: [jsxRuntime.jsx(giger.Icon, {
23387
+ css: theme => ({
23388
+ color: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? theme.palette.success.main : theme.palette.error.main
23389
+ }),
23390
+ name: (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? gigerTheme.IconNames.CHECK_FILLED : gigerTheme.IconNames.ALERT,
23391
+ size: giger.IconSize.SIZE_LARGE
23392
+ }), (voidRequest === null || voidRequest === void 0 ? void 0 : voidRequest.approved) ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
23393
+ children: [jsxRuntime.jsx(giger.Typography, Object.assign({
23394
+ component: "h2"
23172
23395
  }, {
23173
- children: formatKey(key)
23174
- })), jsxRuntime.jsxs("form", Object.assign({
23175
- css: styles$7.wrapper
23396
+ children: t("void-label:resultTitles.approved")
23397
+ })), jsxRuntime.jsx(giger.Typography, {
23398
+ children: t("void-label:resultMessages.approved")
23399
+ })]
23400
+ }) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
23401
+ children: [jsxRuntime.jsx(giger.Typography, Object.assign({
23402
+ component: "h2"
23176
23403
  }, {
23177
- children: [jsxRuntime.jsx("input", {
23178
- css: styles$7.input,
23179
- onChange: e => {
23180
- if (e.target.value.match(/^#[0-9A-Fa-f]{0,6}$/)) handleInputChange(category, key, e.target.value);
23181
- },
23182
- onKeyDown: e => {
23183
- if (e.key === "Enter") e.preventDefault();
23184
- },
23185
- type: "text",
23186
- value: paletteConfig[category][key]
23187
- }), jsxRuntime.jsx("input", {
23188
- css: styles$7.colorPicker,
23189
- onChange: e => handleInputChange(category, key, e.target.value),
23190
- type: "color",
23191
- value: paletteConfig[category][key]
23192
- })]
23193
- }))]
23194
- }), key))]
23195
- }), category))
23196
- }));
23404
+ children: t("void-label:resultTitles.rejected")
23405
+ })), jsxRuntime.jsx(giger.Typography, {
23406
+ children: jsxRuntime.jsx("p", {
23407
+ dangerouslySetInnerHTML: {
23408
+ __html: t("void-label:resultMessages.rejected")
23409
+ }
23410
+ })
23411
+ })]
23412
+ })]
23413
+ })) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
23414
+ children: [jsxRuntime.jsx(giger.Typography, {
23415
+ children: t("void-label:refund_process")
23416
+ }), jsxRuntime.jsx(giger.Typography, Object.assign({
23417
+ component: "p"
23418
+ }, {
23419
+ children: t("void-label:refund_rules")
23420
+ }))]
23421
+ })
23422
+ });
23197
23423
  };
23198
23424
 
23199
- const styles$6 = createStyles({
23200
- input: theme => ({
23201
- border: `1px solid ${theme.palette.gray.light}`,
23202
- borderRadius: "4px",
23203
- color: theme.palette.gray.main,
23204
- fontSize: "14px",
23205
- maxWidth: theme.spacing(16),
23206
- padding: 0
23207
- }),
23208
- keys: {
23209
- fontSize: "16px",
23210
- fontWeight: "bold",
23211
- marginTop: "8px"
23425
+ /**
23426
+ * # Void Label Component
23427
+ *
23428
+ * - The `<VoidLabel />` component is used to void a given shipping label. When a label is voided,
23429
+ * you then get the option to view the associated shipment via the `View Shipment` Element, or
23430
+ * you can purchase another label for the shipment via the `Purchase Label` Element.
23431
+ *
23432
+ * @param ComponentProps The base props that will be passed into the `<VoidLabel />` component.
23433
+ *
23434
+ * @returns Element An EmotionJSX.Element that will render the `<VoidLabel />` component
23435
+ * with all the appropriate wrappers.
23436
+ *
23437
+ * @example
23438
+ * You can see how the `<Component />` is used in the `createElement` function call below.
23439
+ * ```tsx
23440
+ * export const Element = alchemy.createElement(Component, ErrorFallback, {
23441
+ * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
23442
+ * resources: { en },
23443
+ * });
23444
+ * ```
23445
+ *
23446
+ * <br />
23447
+ *
23448
+ * @see {@link VoidLabel.Element | The **Element** created to render `<VoidLabel />`}
23449
+ */
23450
+ const Component$3 = ({
23451
+ features,
23452
+ labelId,
23453
+ onComplete,
23454
+ onSuccess,
23455
+ onViewShipment
23456
+ }) => {
23457
+ var _a, _b;
23458
+ features = Object.assign({
23459
+ presentation: {
23460
+ poweredByShipEngine: false
23461
+ }
23462
+ }, features !== null && features !== void 0 ? features : {});
23463
+ // TODO [LMNT-910] - labelId should be a required prop
23464
+ if (!labelId) throw new Error("void-label:errorMessages.labelIdRequired");
23465
+ const {
23466
+ t
23467
+ } = reactI18next.useTranslation();
23468
+ const label = alchemy.useGetLabel(labelId);
23469
+ const shipment = alchemy.useGetSalesOrderShipment((_a = label.data) === null || _a === void 0 ? void 0 : _a.shipmentId);
23470
+ const voidLabel = alchemy.useVoidLabel();
23471
+ if (label.isInitialLoading) return jsxRuntime.jsx(Loader, {
23472
+ message: t("loading.label")
23473
+ });
23474
+ if (shipment.isInitialLoading) return jsxRuntime.jsx(Loader, {
23475
+ message: t("loading.shipment")
23476
+ });
23477
+ throwAny(label.error);
23478
+ throwAny(shipment.error);
23479
+ if (!label.data) throw new Error("errorMessages.unableToLoad.label");
23480
+ if (!shipment.data) throw new Error("errorMessages.unableToLoad.shipment");
23481
+ const handleVoidLabelSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
23482
+ const result = yield voidLabel.mutateAsync(labelId);
23483
+ if (result.approved) {
23484
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(label.data, shipment.data);
23485
+ }
23486
+ });
23487
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
23488
+ children: [jsxRuntime.jsx(Message, {
23489
+ voidRequest: voidLabel.data
23490
+ }), jsxRuntime.jsx(Actions, {
23491
+ onComplete: onComplete,
23492
+ onSubmit: handleVoidLabelSubmit,
23493
+ onViewShipment: onViewShipment,
23494
+ shipment: shipment.data,
23495
+ voidRequest: voidLabel.data
23496
+ }), ((_b = features === null || features === void 0 ? void 0 : features.presentation) === null || _b === void 0 ? void 0 : _b.poweredByShipEngine) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
23497
+ children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(PoweredByShipEngine, {})]
23498
+ })]
23499
+ });
23500
+ };
23501
+ /**
23502
+ * # Registered Void Label Element
23503
+ *
23504
+ * - This is the registered `<VoidLabel />` element that will be used to render the
23505
+ * `<VoidLabel.Element />` component.
23506
+ *
23507
+ * @param ElementProps The props, callbacks, and resources necessary to render
23508
+ * the `<VoidLabel.Element />` component.
23509
+ *
23510
+ * @example
23511
+ * The `<Component />` is the source JSX that is rendered when you make use of the `VoidLabel`
23512
+ * Element directly. Here is a brief example of how you would use it within your application.
23513
+ * ```tsx
23514
+ * <VoidLabel.Element
23515
+ * labelId="se-1234567"
23516
+ * onComplete={() => console.log('onComplete')}
23517
+ * onSuccess={(_, { salesOrderIds: [salesOrderId] }) =>
23518
+ * console.log('sales order ID', salesOrderId)
23519
+ * }
23520
+ * onViewShipment={({ shipmentId }) => {
23521
+ * console.log('onViewShipment', shipmentId);
23522
+ * }}
23523
+ * />
23524
+ * ```
23525
+ *
23526
+ * <br />
23527
+ *
23528
+ * @see {@link VoidLabel.ComponentProps | The **props** that can be passed into the `<VoidLabel.Element />` component}
23529
+ *
23530
+ * @see {@link PurchaseLabel.Element | Go back to the frst step in the label purchase workflow `<PurchaseLabel.Element />`}
23531
+ */
23532
+ const Element$4 = alchemy__default["default"].createElement(Component$3, ErrorFallback, {
23533
+ css: {
23534
+ height: "100%",
23535
+ maxWidth: "800px",
23536
+ minWidth: "440px",
23537
+ width: "100%"
23212
23538
  },
23213
- section: theme => ({
23214
- "& > div:first-child": {
23215
- flexGrow: 3
23216
- },
23217
- "& > div:last-child": {
23218
- flexShrink: 1
23219
- },
23220
- display: "flex",
23221
- gap: theme.spacing(1),
23222
- justifyContent: "space-between"
23223
- }),
23224
- sectionContainer: theme => ({
23225
- marginBottom: theme.spacing(4)
23226
- }),
23227
- select: theme => ({
23228
- border: `1px solid ${theme.palette.gray.light}`,
23229
- borderRadius: "4px",
23230
- color: theme.palette.gray.main,
23231
- fontSize: "14px"
23232
- })
23539
+ resources: {
23540
+ en
23541
+ }
23233
23542
  });
23234
23543
 
23235
- const TypographyEditor = ({
23236
- onUpdateTypographyConfig,
23237
- typographyConfig,
23238
- formatKey
23544
+ var voidLabel = /*#__PURE__*/Object.freeze({
23545
+ __proto__: null,
23546
+ Component: Component$3,
23547
+ Element: Element$4
23548
+ });
23549
+
23550
+ /**
23551
+ * @internal
23552
+ *
23553
+ * # Label Workflow Component
23554
+ *
23555
+ * @example
23556
+ * ```tsx
23557
+ * const {
23558
+ * labelId,
23559
+ * multiplexedId,
23560
+ * isVoidingLabel,
23561
+ * shipmentId,
23562
+ * setLabelId,
23563
+ * setShipmentId,
23564
+ * setIsVoidingLabel,
23565
+ * } = useLabelWorkflow({
23566
+ * _labelId,
23567
+ * _multiplexedId,
23568
+ * });
23569
+ * ```
23570
+ *
23571
+ * <br />
23572
+ *
23573
+ * @see {@link LabelWorkflow.Element | The `<LabelWorkflow.Element />` component using this hook}
23574
+ */
23575
+ const useLabelWorkflow = ({
23576
+ _multiplexedId,
23577
+ _labelId
23239
23578
  }) => {
23240
- const handleInputChange = React.useCallback((variant, key, value) => {
23241
- const updatedConfig = Object.assign(Object.assign({}, typographyConfig || {}), {
23242
- [variant]: Object.assign(Object.assign({}, (typographyConfig === null || typographyConfig === void 0 ? void 0 : typographyConfig[variant]) || {}), {
23243
- [key]: value
23244
- })
23245
- });
23246
- onUpdateTypographyConfig(updatedConfig);
23247
- }, [onUpdateTypographyConfig, typographyConfig]);
23248
- const getNestedValue = React.useCallback((obj, key) => {
23249
- if (!obj) return undefined;
23250
- return obj[key];
23579
+ // Fix first ids as the user of the library shouldn't be changing them
23580
+ const [multiplexedId, setMultiplexedId] = React.useState(_multiplexedId);
23581
+ const [shipmentId, setShipmentId] = React.useState("shipmentId" in _multiplexedId ? _multiplexedId.shipmentId : undefined);
23582
+ const [labelId, _setLabelId] = React.useState(_labelId);
23583
+ const [isVoidingLabel, setIsVoidingLabel] = React.useState(false);
23584
+ const setLabelId = React.useCallback(nextLabelId => {
23585
+ setIsVoidingLabel(false);
23586
+ _setLabelId(nextLabelId);
23251
23587
  }, []);
23252
- const renderFontWeightSelect = (variant, key) => {
23253
- var _a;
23254
- const options = [{
23255
- label: "Normal",
23256
- value: "400"
23257
- }, {
23258
- label: "Semi Bold",
23259
- value: "600"
23260
- }, {
23261
- label: "Bold",
23262
- value: "700"
23263
- }];
23264
- const fontWeightValue = (_a = getNestedValue(typographyConfig, variant)) === null || _a === void 0 ? void 0 : _a.fontWeight.toString();
23265
- const selectOption = fontWeightValue !== undefined ? options.find(option => option.value === fontWeightValue) : undefined;
23266
- return jsxRuntime.jsx(giger.Select, Object.assign({
23267
- css: styles$6.select,
23268
- label: "Font Weight",
23269
- name: "font-weight",
23270
- onChange: (_name, value) => handleInputChange(variant, key, value === null || value === void 0 ? void 0 : value.value),
23271
- value: selectOption
23272
- }, {
23273
- children: options.map(option => jsxRuntime.jsx(giger.Option, Object.assign({
23274
- value: option.value
23275
- }, {
23276
- children: option.label
23277
- }), option.value))
23278
- }));
23588
+ return {
23589
+ isVoidingLabel,
23590
+ labelId,
23591
+ multiplexedId,
23592
+ setIsVoidingLabel,
23593
+ setLabelId,
23594
+ setMultiplexedId,
23595
+ setShipmentId,
23596
+ shipmentId
23279
23597
  };
23280
- const renderFontSizeInput = (variant, key) => {
23598
+ };
23599
+ /**
23600
+ * @internal
23601
+ *
23602
+ * # Label Workflow Element
23603
+ *
23604
+ * - The `<LabelWorkflow.Element />` component is a composition of the PurchaseLabel, ViewShipment,
23605
+ * and VoidLabel elements that allows users to purchase a label, view the shipment details, and optionally void their shipping label.
23606
+ *
23607
+ * @param LabelWorkflowProps The props necessary to render the `<LabelWorkflow.Element />` for shipment
23608
+ * based or sales order based label purchasing.
23609
+ *
23610
+ * @returns Element A React Element that will render the `<LabelWorkflow />` component.
23611
+ *
23612
+ * @example
23613
+ * ```tsx
23614
+ * <LabelWorkflow
23615
+ * {...elementProps}
23616
+ * callbacks={{ onLabelCreateSuccess }}
23617
+ * multiplexedId={elementIdProps}
23618
+ * />
23619
+ * ```
23620
+ *
23621
+ * <br />
23622
+ *
23623
+ * @see {@link LabelWorkflowProps | The props that are passed into the `<LabelWorkflow />` component}
23624
+ * @see {@link LabelWorkflow.useLabelWorkflow | The `hook` that is used to manage the state of the `<LabelWorkflow />` component}
23625
+ */
23626
+ const Element$3 = (
23627
+ /*
23628
+ The passed props are underscore prefixed as they will be stashed, then from them stateful versions will be made
23629
+ */
23630
+ {
23631
+ multiplexedId: _multiplexedId,
23632
+ labelId: _labelId,
23633
+ features: propFeatures,
23634
+ callbacks
23635
+ }) => {
23636
+ const {
23637
+ labelId,
23638
+ multiplexedId,
23639
+ isVoidingLabel,
23640
+ shipmentId,
23641
+ setLabelId,
23642
+ setShipmentId,
23643
+ setIsVoidingLabel
23644
+ } = useLabelWorkflow({
23645
+ _labelId,
23646
+ _multiplexedId
23647
+ });
23648
+ const _features = useFeatures("Globals");
23649
+ const features = React.useMemo(() => {
23281
23650
  var _a;
23282
- const formattedFontSizeValue = (_a = getNestedValue(typographyConfig, variant)) === null || _a === void 0 ? void 0 : _a.fontSize.replace("px", "");
23283
- return jsxRuntime.jsx(giger.Input, {
23284
- "aria-labelledby": `${variant}.${key}`,
23285
- css: styles$6.input,
23286
- label: "Font Size(px)",
23287
- onChange: e => {
23288
- if (e.target.value.match(/^\d{0,2}$/)) handleInputChange(variant, key, `${e.target.value}px`);
23289
- },
23290
- value: formattedFontSizeValue
23651
+ return Object.assign(Object.assign(Object.assign({}, propFeatures), _features), {
23652
+ global: Object.assign(Object.assign({}, _features.global), {
23653
+ presentation: Object.assign(Object.assign({}, (_a = _features.global) === null || _a === void 0 ? void 0 : _a.presentation), {
23654
+ poweredByShipEngine: true
23655
+ })
23656
+ })
23291
23657
  });
23292
- };
23293
- const renderChildren = (variant, key) => {
23294
- switch (key) {
23295
- case "fontWeight":
23296
- return jsxRuntime.jsx(jsxRuntime.Fragment, {
23297
- children: renderFontWeightSelect(variant, key)
23298
- });
23299
- case "fontSize":
23300
- return jsxRuntime.jsx(jsxRuntime.Fragment, {
23301
- children: renderFontSizeInput(variant, key)
23302
- });
23303
- default:
23304
- return null;
23305
- }
23306
- };
23307
- return jsxRuntime.jsx("div", {
23308
- children: typographyConfig && Object.keys(typographyConfig).map(variant => jsxRuntime.jsxs("div", Object.assign({
23309
- css: styles$6.sectionContainer
23310
- }, {
23311
- children: [jsxRuntime.jsx("p", Object.assign({
23312
- css: styles$6.keys,
23313
- id: variant
23314
- }, {
23315
- children: formatKey(variant)
23316
- })), jsxRuntime.jsx("section", Object.assign({
23317
- css: styles$6.section
23318
- }, {
23319
- children: Object.keys(typographyConfig[variant]).map(key => jsxRuntime.jsx("div", Object.assign({
23320
- id: `${variant}.${key}`
23321
- }, {
23322
- children: renderChildren(variant, key)
23323
- }), key))
23324
- }))]
23325
- }), variant))
23326
- });
23327
- };
23328
-
23329
- const styles$5 = createStyles({
23330
- container: theme => ({
23331
- color: theme.palette.gray.dark,
23332
- display: "flex",
23333
- flexDirection: "column",
23334
- flexGrow: 1,
23335
- overflow: "hidden",
23336
- position: "relative"
23337
- }),
23338
- content: theme => ({
23339
- display: "flex",
23340
- flexDirection: "column",
23341
- gap: theme.spacing(3),
23342
- padding: theme.spacing(3)
23343
- }),
23344
- copy: theme => ({
23345
- backgroundColor: theme.palette.white,
23346
- borderRadius: "4px",
23347
- padding: theme.spacing(0.5)
23348
- }),
23349
- drawerHeader: theme => ({
23350
- alignItems: "center",
23351
- display: "flex",
23352
- gap: theme.spacing(2),
23353
- justifyContent: "end",
23354
- width: "50%"
23355
- }),
23356
- drawerWrapper: {
23357
- display: "flex",
23358
- justifyContent: "space-between",
23359
- position: "relative"
23360
- },
23361
- header: {
23362
- alignItems: "center",
23363
- display: "flex",
23364
- justifyContent: "space-between"
23365
- },
23366
- popoverWrapper: theme => ({
23367
- display: "flex",
23368
- flexDirection: "column",
23369
- gap: theme.spacing(1)
23370
- }),
23371
- pre: theme => ({
23372
- backgroundColor: "#FFFFFF66",
23373
- borderRadius: "8px",
23374
- fontSize: "14px",
23375
- padding: theme.spacing(0.3)
23376
- }),
23377
- presetOption: theme => ({
23378
- "&:hover": {
23379
- backgroundColor: "theme.palette.gray.ultraLight"
23658
+ }, []);
23659
+ return !labelId ? jsxRuntime.jsx(Element$7, Object.assign({}, multiplexedId, {
23660
+ features: features,
23661
+ onLabelCreateSuccess: (label, shipment) => {
23662
+ var _a;
23663
+ setLabelId(label.labelId);
23664
+ setShipmentId(shipment.shipmentId);
23665
+ (_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.onLabelCreateSuccess) === null || _a === void 0 ? void 0 : _a.call(callbacks, label, shipment);
23380
23666
  },
23381
- backgroundColor: "transparent",
23382
- borderRadius: "4px",
23383
- fontSize: "14px",
23384
- padding: theme.spacing(1)
23385
- }),
23386
- presetsButton: theme => ({
23387
- "&:hover": {
23388
- backgroundColor: "#d1d4d7"
23667
+ onLoad: (salesOrder, shipments, pendingShipment) => {
23668
+ if (shipments.length > 0) {
23669
+ setShipmentId(prior => prior !== undefined ? prior : shipments[0].shipmentId);
23670
+ }
23671
+ }
23672
+ })) : !isVoidingLabel ? jsxRuntime.jsx(Element$5, {
23673
+ features: features,
23674
+ onClickPurchaseLabel: () => {
23675
+ setLabelId(undefined);
23389
23676
  },
23390
- backgroundColor: "#E4E5E7",
23391
- borderRadius: "4px",
23392
- cursor: "pointer",
23393
- display: "flex",
23394
- fontSize: "14px",
23395
- gap: theme.spacing(0.5),
23396
- padding: `${theme.spacing(0.5)}px ${theme.spacing(1)}px`
23397
- })
23677
+ onClickVoidLabel: () => {
23678
+ setIsVoidingLabel(true);
23679
+ },
23680
+ shipmentId: shipmentId
23681
+ }) : jsxRuntime.jsx(Element$4, {
23682
+ features: features,
23683
+ labelId: labelId,
23684
+ onComplete: () => {
23685
+ setIsVoidingLabel(false);
23686
+ },
23687
+ onViewShipment: () => {
23688
+ setIsVoidingLabel(false);
23689
+ }
23690
+ });
23691
+ };
23692
+
23693
+ var labelWorkflow = /*#__PURE__*/Object.freeze({
23694
+ __proto__: null,
23695
+ useLabelWorkflow: useLabelWorkflow,
23696
+ Element: Element$3
23398
23697
  });
23399
23698
 
23400
- const ThemeCreator = ({
23401
- themeConfig,
23402
- onUpdateThemeConfig,
23403
- presets,
23404
- showDrawer
23699
+ const Component$2 = ({
23700
+ onRowClick,
23701
+ shipmentStatus: _shipmentStatus = "pending"
23405
23702
  }) => {
23406
- const defaultThemeConfigRef = React.useRef(themeConfig);
23407
- const [isDrawerOpen, setIsDrawerOpen] = React.useState(false);
23408
- const globalKeys = Object.keys(themeConfig);
23409
- // If the themeConfig has a "components" key, show only the child component keys, not "components" itself
23410
- const tabs = globalKeys.flatMap(key => {
23411
- if (key === "components" && themeConfig[key] && typeof themeConfig[key] === "object") {
23412
- const childComponentKeys = Object.keys(themeConfig[key]);
23413
- return childComponentKeys;
23414
- } else {
23415
- return [key];
23416
- }
23703
+ const {
23704
+ t
23705
+ } = reactI18next.useTranslation(["common", "list-shipments"]);
23706
+ const {
23707
+ page,
23708
+ pageSize,
23709
+ pagerProps
23710
+ } = usePager();
23711
+ const {
23712
+ data,
23713
+ isLoading,
23714
+ isError,
23715
+ error
23716
+ } = alchemy.useListShipments({
23717
+ page,
23718
+ pageSize,
23719
+ shipmentStatus: _shipmentStatus
23417
23720
  });
23418
- const formattedThemeTabs = tabs.map(tab => {
23419
- if (tab === "palette") {
23420
- return "Color Palette";
23721
+ if (isLoading) return jsxRuntime.jsx(Loader, {
23722
+ message: t("loading.shipments")
23723
+ });
23724
+ if (isError) throw new Error(error.map(e => e.message).join(", "));
23725
+ if (!data) throw new Error(t("errorMessages.unableToLoad.shipments"));
23726
+ const columns = [{
23727
+ headerContent: t("list-shipments:headers.shipmentId"),
23728
+ renderCellContent: shipment => {
23729
+ return jsxRuntime.jsx("div", {
23730
+ children: shipment.shipmentId
23731
+ });
23421
23732
  }
23422
- return capitalizeFirstLetter(tab);
23733
+ }, {
23734
+ headerContent: t("list-shipments:headers.shipTo"),
23735
+ renderCellContent: shipment => {
23736
+ return shipment.shipTo.addressLine1 ? jsxRuntime.jsx(AddressDisplay, {
23737
+ address: shipment.shipTo
23738
+ }) : "--";
23739
+ }
23740
+ }, {
23741
+ headerContent: t("list-shipments:headers.shipDate"),
23742
+ renderCellContent: shipment => {
23743
+ return shipment.shipDate ? jsxRuntime.jsx(CellFormattedDate, {
23744
+ date: shipment.shipDate
23745
+ }) : "--";
23746
+ }
23747
+ }];
23748
+ return jsxRuntime.jsx(GridController, {
23749
+ columns: columns,
23750
+ data: data.shipments,
23751
+ footerContent: jsxRuntime.jsx(Pager, Object.assign({}, pagerProps, {
23752
+ pagingData: data
23753
+ })),
23754
+ onRowClick: onRowClick
23423
23755
  });
23424
- const [selectedTab, setSelectedTab] = React.useState(formattedThemeTabs.sort()[0]);
23425
- const handleSelectedTab = tab => {
23426
- setSelectedTab(tab);
23427
- };
23428
- const formatKey = key => addSpaceBetweenWords(pascalize(key));
23429
- const renderContentBySelectedTab = (themeConfig, selectedTab) => {
23430
- var _a;
23431
- switch (selectedTab) {
23432
- case "Color Palette":
23433
- return jsxRuntime.jsx(ColorPaletteEditor, {
23434
- formatKey: formatKey,
23435
- onUpdatePaletteConfig: updatedPalette => {
23436
- onUpdateThemeConfig(Object.assign(Object.assign({}, themeConfig), {
23437
- palette: updatedPalette
23438
- }));
23439
- },
23440
- paletteConfig: themeConfig.palette
23441
- });
23442
- case "Typography":
23443
- return jsxRuntime.jsx(TypographyEditor, {
23444
- formatKey: formatKey,
23445
- onUpdateTypographyConfig: updatedTypography => {
23446
- onUpdateThemeConfig(Object.assign(Object.assign({}, themeConfig), {
23447
- components: Object.assign(Object.assign({}, themeConfig.components), {
23448
- Typography: updatedTypography
23449
- })
23450
- }));
23451
- },
23452
- typographyConfig: (_a = themeConfig.components) === null || _a === void 0 ? void 0 : _a.Typography
23453
- });
23454
- default:
23455
- return null;
23756
+ };
23757
+ const Element$2 = alchemy__default["default"].createElement(Component$2, ErrorFallback, {
23758
+ css: {
23759
+ height: "100%",
23760
+ minWidth: "440px",
23761
+ width: "100%"
23762
+ },
23763
+ resources: {
23764
+ en
23765
+ }
23766
+ });
23767
+
23768
+ var shipmentsGrid = /*#__PURE__*/Object.freeze({
23769
+ __proto__: null,
23770
+ Element: Element$2
23771
+ });
23772
+
23773
+ const ThemeCreatorContext = /*#__PURE__*/React.createContext(undefined);
23774
+ const ThemeCreatorProvider = ({
23775
+ children,
23776
+ editableTheme
23777
+ }) => {
23778
+ const [themeConfig, setThemeConfig] = React.useState(editableTheme);
23779
+ return jsxRuntime.jsx(ThemeCreatorContext.Provider, Object.assign({
23780
+ value: {
23781
+ setThemeConfig,
23782
+ themeConfig
23456
23783
  }
23457
- };
23458
- // const formattedThemeObj = `const theme = ${JSON.stringify(themeConfig, null, 2)}`;
23459
- const presetsRef = React.useRef(null);
23460
- const [showPresets, toggleShowPresets] = useToggle(false);
23461
- const applyPreset = theme => {
23462
- onUpdateThemeConfig(theme);
23463
- };
23464
- return jsxRuntime.jsxs("div", Object.assign({
23465
- "aria-label": "Theme Creator",
23466
- css: styles$5.container,
23467
- "data-testid": "theme-creator",
23468
- role: "region"
23469
23784
  }, {
23470
- children: [jsxRuntime.jsxs("div", Object.assign({
23471
- css: styles$5.content
23472
- }, {
23473
- children: [jsxRuntime.jsxs("div", Object.assign({
23474
- css: styles$5.header
23475
- }, {
23476
- children: [jsxRuntime.jsx(Tabs, {
23477
- onSelectTab: handleSelectedTab,
23478
- selectedTab: selectedTab,
23479
- tabs: formattedThemeTabs
23480
- }), presets ? jsxRuntime.jsxs("div", {
23481
- children: [jsxRuntime.jsxs("button", Object.assign({
23482
- "aria-controls": "presets-popover",
23483
- "aria-expanded": showPresets,
23484
- css: styles$5.presetsButton,
23485
- onClick: e => {
23486
- e.preventDefault();
23487
- toggleShowPresets();
23488
- },
23489
- ref: presetsRef
23490
- }, {
23491
- children: ["Presets", jsxRuntime.jsx(giger.Icon, {
23492
- name: gigerTheme.IconNames.CARET_BOTTOM,
23493
- size: giger.IconSize.SIZE_SMALL
23494
- })]
23495
- })), jsxRuntime.jsx(giger.Popover, Object.assign({
23496
- container: document.querySelector("#theme-creator"),
23497
- isOpen: showPresets,
23498
- onClickAway: () => toggleShowPresets(),
23499
- placement: "bottom-end",
23500
- reference: presetsRef.current
23501
- }, {
23502
- children: jsxRuntime.jsxs("div", Object.assign({
23503
- css: styles$5.popoverWrapper
23504
- }, {
23505
- children: [jsxRuntime.jsx("button", Object.assign({
23506
- "aria-label": "Set Default Theme",
23507
- css: styles$5.presetOption,
23508
- onClick: e => {
23509
- e.preventDefault();
23510
- toggleShowPresets();
23511
- applyPreset(defaultThemeConfigRef.current);
23512
- },
23513
- role: "menuitem"
23514
- }, {
23515
- children: "Default"
23516
- })), presets.map(preset => jsxRuntime.jsx("button", Object.assign({
23517
- "aria-label": `Set ${preset.presetName} Theme`,
23518
- css: styles$5.presetOption,
23519
- onClick: e => {
23520
- e.preventDefault();
23521
- toggleShowPresets();
23522
- applyPreset(preset.themeConfig);
23523
- },
23524
- role: "menuitem"
23525
- }, {
23526
- children: preset.presetName
23527
- }), preset.presetName))]
23528
- }))
23529
- }))]
23530
- }) :
23531
- //reset to default button
23532
- jsxRuntime.jsx("button", Object.assign({
23533
- "aria-label": "Set Default Theme",
23534
- css: styles$5.presetsButton,
23535
- onClick: () => {
23536
- applyPreset(defaultThemeConfigRef.current);
23537
- },
23538
- role: "menuitem"
23539
- }, {
23540
- children: "Reset to Default"
23541
- }))]
23542
- })), jsxRuntime.jsx(giger.Typography, Object.assign({
23543
- role: "heading",
23544
- variant: "heading4"
23545
- }, {
23546
- children: `${selectedTab} Editor`
23547
- })), renderContentBySelectedTab(themeConfig, selectedTab)]
23548
- })), showDrawer && jsxRuntime.jsx(Drawer, Object.assign({
23549
- "aria-label": "Show themeConfig.js Code Drawer",
23550
- headerContent: jsxRuntime.jsxs("div", Object.assign({
23551
- css: styles$5.drawerHeader
23552
- }, {
23553
- children: [jsxRuntime.jsx("pre", Object.assign({
23554
- css: styles$5.pre
23555
- }, {
23556
- children: "themeConfig.js"
23557
- })), showDrawer.copyToClipboardText && jsxRuntime.jsx("div", Object.assign({
23558
- css: styles$5.copy
23559
- }, {
23560
- children: jsxRuntime.jsx(CopyButton, {
23561
- content: showDrawer.copyToClipboardText
23562
- })
23563
- }))]
23564
- })),
23565
- isOpen: isDrawerOpen,
23566
- toggleDrawer: () => setIsDrawerOpen(!isDrawerOpen)
23567
- }, {
23568
- children: showDrawer.content
23569
- }))]
23785
+ children: children
23570
23786
  }));
23571
23787
  };
23788
+ const useThemeCreator = () => {
23789
+ const themeCreatorContext = React.useContext(ThemeCreatorContext);
23790
+ if (!themeCreatorContext) throw new Error("useThemeConfigurator must be used within a ThemeConfiguratorProvider");
23791
+ return themeCreatorContext;
23792
+ };
23572
23793
 
23573
23794
  const Component$1 = _a => {
23574
23795
  var props = __rest(_a, []);
@@ -24588,6 +24809,7 @@ exports.GridController = GridController;
24588
24809
  exports.InlineLabel = InlineLabel;
24589
24810
  exports.ItemsBreakdown = ItemsBreakdown;
24590
24811
  exports.LabelWorkflow = labelWorkflow;
24812
+ exports.LabelsGrid = labelsGrid;
24591
24813
  exports.LinkAction = LinkAction;
24592
24814
  exports.ListCarriers = listCarriers;
24593
24815
  exports.Loader = Loader;
@@ -24602,6 +24824,7 @@ exports.PoweredByShipEngine = PoweredByShipEngine;
24602
24824
  exports.PurchaseLabel = purchaseLabel;
24603
24825
  exports.RootPortalProvider = RootPortalProvider;
24604
24826
  exports.Section = Section;
24827
+ exports.ShipmentsGrid = shipmentsGrid;
24605
24828
  exports.SkeletonCarrierRow = SkeletonCarrierRow;
24606
24829
  exports.Spacer = Spacer;
24607
24830
  exports.Spread = Spread;