@shipengine/elements 0.33.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/index.cjs +1975 -493
  2. package/index.js +1970 -496
  3. package/package.json +1 -1
  4. package/src/components/add-funds-form/add-funds-form.d.ts +22 -2
  5. package/src/components/add-funds-form/add-funds-schema.d.ts +26 -0
  6. package/src/components/address-preference-context/address-preference-context.d.ts +8 -0
  7. package/src/components/auto-funding-form/auto-funding-form.d.ts +22 -0
  8. package/src/components/auto-funding-form/auto-funding-schema.d.ts +17 -0
  9. package/src/components/button-group/button-group.d.ts +29 -0
  10. package/src/components/carrier-balance/carrier-balance.d.ts +23 -0
  11. package/src/components/collapsible-panel/collapsible-panel.d.ts +32 -0
  12. package/src/components/copy/copy-button.d.ts +4 -0
  13. package/src/components/cube/cube.d.ts +16 -0
  14. package/src/components/date-range-combo/date-range-combo.d.ts +14 -0
  15. package/src/components/date-range-select/date-range-select.d.ts +6 -0
  16. package/src/components/error-fallback/error-fallback.d.ts +12 -1
  17. package/src/components/field-label/field-label.d.ts +10 -0
  18. package/src/components/form-portal/form-portal.d.ts +9 -0
  19. package/src/components/fund-and-purchase/fund-and-purchase.d.ts +13 -0
  20. package/src/components/inline-label/inline-label.d.ts +10 -0
  21. package/src/components/items-breakdown/items-breakdown.d.ts +15 -0
  22. package/src/components/label-layout/label-layout.d.ts +5 -0
  23. package/src/components/link-action/link-action.d.ts +10 -0
  24. package/src/components/loader/loader.d.ts +5 -0
  25. package/src/components/manage-funding/manage-funding.d.ts +26 -0
  26. package/src/components/payment-method-settings/payment-method-settings.d.ts +19 -0
  27. package/src/components/portal/portal.d.ts +10 -1
  28. package/src/components/powered-by-shipengine/powered-by-shipengine.d.ts +8 -0
  29. package/src/components/section/section.d.ts +10 -0
  30. package/src/components/spacer/spacer.d.ts +30 -0
  31. package/src/components/spread/spread.d.ts +10 -0
  32. package/src/components/story-notes/story-notes.d.ts +10 -1
  33. package/src/components/templates/carrier-terms-form/carrier-terms-form.styles.d.ts +1 -0
  34. package/src/components/templates/landing-page/landing-page.d.ts +2 -1
  35. package/src/components/templates/onboarding/onboarding.d.ts +3 -1
  36. package/src/components/templates/onboarding/onboarding.styles.d.ts +10 -0
  37. package/src/components/templates/rate-form/rate-form.d.ts +2 -2
  38. package/src/components/templates/shipment-form/shipment-form.d.ts +2 -1
  39. package/src/components/templates/shipment-form/shipment-schema.d.ts +179 -17
  40. package/src/components/templates/warehouse-form/warehouse-form.d.ts +1 -1
  41. package/src/components/unit-settings/unit-settings.d.ts +5 -0
  42. package/src/constants/shipengine/address.d.ts +75 -0
  43. package/src/elements/account-settings/account-settings.d.ts +139 -3
  44. package/src/elements/configure-shipment/configure-shipment.d.ts +1 -0
  45. package/src/elements/configure-shipment/hooks/use-rates-form.d.ts +2 -2
  46. package/src/elements/configure-shipment/hooks/use-rates-with-cache.d.ts +1 -1
  47. package/src/elements/configure-shipment/hooks/use-request-rates.d.ts +1 -1
  48. package/src/elements/configure-shipment/hooks/use-shipment-form.d.ts +1 -0
  49. package/src/elements/list-carriers/list-carriers.d.ts +31 -0
  50. package/src/elements/manage-warehouses/manage-warehouses.d.ts +34 -0
  51. package/src/elements/onboarding/onboarding.d.ts +99 -5
  52. package/src/elements/purchase-label/purchase-label.d.ts +194 -9
  53. package/src/elements/shipengine-workflow/label-workflow.d.ts +138 -2
  54. package/src/elements/view-shipment/view-shipment.d.ts +131 -4
  55. package/src/elements/void-label/void-label.d.ts +137 -5
  56. package/src/extensions/zod.d.ts +5 -0
  57. package/src/factories/shipengine/package.d.ts +11 -0
  58. package/src/features/wallet-history/wallet-history.d.ts +5 -0
  59. package/src/hooks/index.d.ts +1 -0
  60. package/src/hooks/options/use-confirmation-options.d.ts +7 -0
  61. package/src/hooks/options/use-country-code-options.d.ts +16 -3
  62. package/src/hooks/options/use-customs-contents-options.d.ts +7 -0
  63. package/src/hooks/options/use-customs-non-delivery-options.d.ts +7 -0
  64. package/src/hooks/options/use-date-range-options.d.ts +22 -1
  65. package/src/hooks/options/use-expiration-month-options.d.ts +7 -0
  66. package/src/hooks/options/use-insurance-provider-options.d.ts +7 -0
  67. package/src/hooks/options/use-package-options.d.ts +7 -0
  68. package/src/hooks/options/use-rate-options.d.ts +11 -1
  69. package/src/hooks/options/use-service-code-options.d.ts +7 -0
  70. package/src/hooks/options/use-shipment-metadata.d.ts +8 -0
  71. package/src/hooks/options/use-shipping-presets-options.d.ts +10 -0
  72. package/src/hooks/options/use-state-code-options.d.ts +7 -0
  73. package/src/hooks/options/use-warehouse-options.d.ts +7 -0
  74. package/src/hooks/use-address-validation.d.ts +7 -0
  75. package/src/hooks/use-black-box-detection.d.ts +17 -1
  76. package/src/hooks/use-carrier-metadata.d.ts +7 -0
  77. package/src/hooks/use-nested-form.d.ts +9 -0
  78. package/src/hooks/use-page-layout.d.ts +25 -1
  79. package/src/hooks/use-root-portal.d.ts +15 -2
  80. package/src/hooks/use-run-once-on-true.d.ts +5 -1
  81. package/src/hooks/use-scrub-errors.d.ts +6 -3
  82. package/src/hooks/use-toggle.d.ts +5 -1
  83. package/src/locales/en/index.d.ts +11 -3
  84. package/src/schemas/shipengine/money.d.ts +4 -0
  85. package/src/schemas/shipengine/phone.d.ts +8 -0
  86. package/src/types/carrier-metadata.d.ts +20 -0
  87. package/src/utilities/create-dictionary.d.ts +4 -0
  88. package/src/utilities/date.d.ts +51 -2
  89. package/src/utilities/error.d.ts +16 -2
  90. package/src/utilities/feature-flags.d.ts +181 -0
  91. package/src/utilities/form-logger.d.ts +4 -0
  92. package/src/utilities/index.d.ts +1 -1
  93. package/src/utilities/money.d.ts +25 -0
  94. package/src/utilities/predicates/isString.d.ts +7 -0
  95. package/src/utilities/rates.d.ts +22 -1
  96. package/src/utilities/shipengine/address.d.ts +31 -0
  97. package/src/utilities/shipengine/carrier.d.ts +21 -0
  98. package/src/utilities/shipengine/dimensions.d.ts +27 -4
  99. package/src/utilities/shipengine/package.d.ts +4 -0
  100. package/src/utilities/shipengine/sales-order.d.ts +26 -0
  101. package/src/utilities/shipengine/shipment.d.ts +12 -0
  102. package/src/utilities/shipengine/weight.d.ts +92 -2
  103. package/src/utilities/string.d.ts +7 -0
  104. package/src/utilities/styles.d.ts +4 -0
  105. package/src/utilities/validation.d.ts +8 -0
@@ -4,26 +4,171 @@ import { ConfigureShipmentProps } from "../configure-shipment";
4
4
  import { UseConfigureShipmentProps } from "./hooks";
5
5
  import { PurchaseLabelSalesOrderProps } from "./purchase-label-by-sales-order";
6
6
  import { PurchaseLabelByShipmentProps } from "./purchase-label-by-shipment";
7
+ /**
8
+ * # Purchase Label Component Props
9
+ *
10
+ * These are the shared props that will be passed into the `<PurchaseLabel.Element />`, and work
11
+ * for either shipment-based or sales order-based label purchasing.
12
+ *
13
+ * @see {@link PurchaseLabel.Element | This prop types usage in `<PurchaseLabel.Element />`}
14
+ */
7
15
  export type PurchaseLabelCommonProps = {
16
+ /**
17
+ * `features` is a set of feature flags you would like to enable or disable in this component.
18
+ */
8
19
  features?: ConfigureShipmentProps["features"];
20
+ /**
21
+ * `onAddressValidation` is an async/sync callback function that will be invoked on each Address
22
+ * validation request. For example, whenever you update the `Ship To Address` or
23
+ * `Ship From Address` for a given shipment.
24
+ */
9
25
  onAddressValidation?: ConfigureShipmentProps["onAddressValidation"];
26
+ /**
27
+ * `onApplyPreset` is an async/sync callback function that will be invoked each time a `Preset`
28
+ * has been applied to a shipment.
29
+ */
10
30
  onApplyPreset?: ConfigureShipmentProps["onApplyPreset"];
31
+ /**
32
+ * `onBeforeLabelCreate` is an async/sync callback function that will be invoked before every
33
+ * label purchase.
34
+ */
11
35
  onBeforeLabelCreate?: ConfigureShipmentProps["onBeforeLabelCreate"];
36
+ /**
37
+ * `onChangeAddress` is an async/sync callback function that will be invoked each time a
38
+ * `Ship To Address` or `Ship From Address` has been updated.
39
+ */
12
40
  onChangeAddress?: ConfigureShipmentProps["onChangeAddress"];
41
+ /**
42
+ * `onChangeShipmentFormMode` is an async/sync callback function that will be invoked each time
43
+ * the user toggles the `Shipment Form Mode` between `Browse Rates` and `Selected Rate`.
44
+ */
13
45
  onChangeShipmentFormMode?: ConfigureShipmentProps["onChangeShipmentFormMode"];
46
+ /**
47
+ * `onLabelCreateFailure` is an async/sync callback function that will be invoked each time a
48
+ * label purchase fails.
49
+ */
14
50
  onLabelCreateFailure?: ConfigureShipmentProps["onLabelCreateFailure"];
51
+ /**
52
+ * `onLabelCreateSuccess` is an async/sync callback provided by the client that is invoked if the
53
+ * label is successfully created/purchased.
54
+ */
15
55
  onLabelCreateSuccess?: ConfigureShipmentProps["onLabelCreateSuccess"];
56
+ /**
57
+ * `onLoad` is an async/sync callback provided by the host application that is invoked after the
58
+ * element is loaded. (This may be useful to grab the shipmentId of a one-off label)
59
+ */
16
60
  onLoad?: UseConfigureShipmentProps["onLoad"];
61
+ /**
62
+ * `onRateSaved` is an async/sync callback function that will be invoked each time a rate is
63
+ * saved by the user when rate shopping in the host application.
64
+ */
17
65
  onRateSaved?: ConfigureShipmentProps["onRateSaved"];
66
+ /**
67
+ * `onRatesCalculated` is an async/sync callback function that will be invoked each time rates
68
+ * are calculated for a given shipment.
69
+ */
18
70
  onRatesCalculated?: ConfigureShipmentProps["onRatesCalculated"];
71
+ /**
72
+ * `onShipmentUpdated` is an async/sync callback function that will be invoked each time a
73
+ * shipment is updated with a new `ShipTo/ShipFrom Address`, `rate`, `preset`, etc.
74
+ */
19
75
  onShipmentUpdated?: ConfigureShipmentProps["onShipmentUpdated"];
76
+ /**
77
+ * `onToggleAddressPreferenceDisclosure` is an async/sync callback function that will be invoked
78
+ * each time the user toggles the `Address Preference` disclosure. This disclosure component
79
+ * allows the user to select whether they would like to use the address they entered, or
80
+ * the formatted address that we return after validation.
81
+ */
20
82
  onToggleAddressPreferenceDisclosure?: ConfigureShipmentProps["onToggleAddressPreferenceDisclosure"];
83
+ /**
84
+ * `printLabelLayout` is a string that represents the label layout you would like to use when
85
+ * purchasing a label. e.g. `4x6`
86
+ */
21
87
  printLabelLayout?: ConfigureShipmentProps["printLabelLayout"];
88
+ /**
89
+ * `shippingPresets` is an object that contains configured shipment details/specs
90
+ * (dimensions, shipping service, etc) that can be applied to a shipment when purchasing a label.
91
+ */
22
92
  shippingPresets?: UseShippingPresetsOptionsProps;
93
+ /**
94
+ * `warehouseId` is a string that represents a previously configured warehouse you would
95
+ * like to use as the `Ship From Address` when purchasing a label.
96
+ */
23
97
  warehouseId?: UseConfigureShipmentProps["warehouseId"];
24
98
  };
25
- type ElementProps = PurchaseLabelByShipmentProps | PurchaseLabelSalesOrderProps;
99
+ /**
100
+ * # PurchaseLabel Element Props
101
+ *
102
+ * - The Purchase Label `ElementProps` is a `union` of the `PurchaseLabelByShipmentProps` and
103
+ * `PurchaseLabelSalesOrderProps` prop types. This is for ease of use when purchasing labels by
104
+ * `shipment` or `sales order`.
105
+ *
106
+ * @see {@link PurchaseLabel.Element | This prop types usage in `<PurchaseLabel />`}
107
+ */
108
+ export type ElementProps = PurchaseLabelByShipmentProps | PurchaseLabelSalesOrderProps;
109
+ /**
110
+ * # Purchase Label Component
111
+ *
112
+ * The `<PurchaseLabel />` component is used to purchase shipping labels from various carriers
113
+ *
114
+ * @param ElementProps The props necessary to render the `<PurchaseLabel />` component for shipment
115
+ * based or sales order based label purchasing.
116
+ *
117
+ * @returns Element An EmotionJSX.Element that will render the `<PurchaseLabel />` component
118
+ * with all the appropriate wrappers.
119
+ *
120
+ * @example
121
+ * You can see how the `<Component />` is used in the `createElement` function call below.
122
+ * ```tsx
123
+ * export const Element = alchemy.createElement(Component, ErrorFallback, {
124
+ * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
125
+ * resources: { en },
126
+ * });
127
+ * ```
128
+ *
129
+ * <br />
130
+ *
131
+ * @see {@link PurchaseLabel.Element | The **Element** created to render `<PurchaseLabel />`}
132
+ */
26
133
  export declare const Component: ({ ...props }: ElementProps) => import("@emotion/react/jsx-runtime").JSX.Element;
134
+ /**
135
+ * # Registered Purchase Label Element
136
+ *
137
+ * @param ElementProps The props necessary to render the `<PurchaseLabel.Element />` for shipment
138
+ * based or sales order based label purchasing.
139
+ *
140
+ * @example
141
+ * The `<Component />` is the source JSX that is rendered when you make use of the `PurchaseLabel`
142
+ * Element directly.
143
+ * ```tsx
144
+ * <PurchaseLabel.Element
145
+ * key={currentSalesOrderId}
146
+ * printLabelLayout='4x6'
147
+ * shippingPresets={presets}
148
+ * onShipmentUpdated={(shipment) => console.log('Shipment Updated', shipment)}
149
+ * onRateSaved={(
150
+ * shipment: SE.SalesOrderShipment,
151
+ * rate?: SE.Rate,
152
+ * rateOptions?: SE.Rate[]
153
+ * ) => console.log('Rate Saved', shipment, rate, rateOptions)}
154
+ * onRatesCalculated={() => console.log('Rates Calculated')}
155
+ * onBeforeLabelCreate={onBeforeLabelPurchase}
156
+ * onLabelCreateSuccess={onLabelPurchaseSuccess}
157
+ * onLabelCreateFailure={(rate) => console.log('Label Purchase Failed', rate)}
158
+ * warehouseId={defaultWarehouseId}
159
+ * />
160
+ * ```
161
+ *
162
+ * <br />
163
+ *
164
+ * - Once a label has been purchased using this Element, you can take the `shipmentId` for the
165
+ * associated shipment and pass it into the `<ViewShipment.Element />` Element in order to view
166
+ * the shipment details.
167
+ *
168
+ * @see {@link PurchaseLabel.PurchaseLabelCommonProps | The **Common props** used in `<PurchaseLabel.Element />`}
169
+ *
170
+ * @see {@link ViewShipment.Element | The next step in the label purchase workflow `<ViewShipment.Element />`}
171
+ */
27
172
  export declare const Element: ({ resources, ...props }: ElementProps & {
28
173
  resources?: {
29
174
  en: {
@@ -164,12 +309,22 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
164
309
  currentBalance: string;
165
310
  insufficientBalanceCTA: string;
166
311
  };
312
+ /**
313
+ * # Purchase Label Component Props
314
+ *
315
+ * These are the shared props that will be passed into the `<PurchaseLabel.Element />`, and work
316
+ * for either shipment-based or sales order-based label purchasing.
317
+ *
318
+ * @see {@link PurchaseLabel.Element | This prop types usage in `<PurchaseLabel.Element />`}
319
+ */
167
320
  cta: {
168
321
  addPackageDetails: string;
169
322
  };
170
323
  errorMessages: {
171
324
  customsItemsRequired: string;
172
- invalidAddress: string;
325
+ invalidAddress: string; /**
326
+ * `features` is a set of feature flags you would like to enable or disable in this component.
327
+ */
173
328
  noRates: string;
174
329
  salesOrderNotLoaded: string;
175
330
  unsupportedAddress: string;
@@ -230,6 +385,7 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
230
385
  rates: {
231
386
  uspsMediaMailAcknowledgement: string;
232
387
  uspsFirstClassMailAcknowledgement_leof: string;
388
+ dhlExpressTermsAcknowledgement: string;
233
389
  };
234
390
  shipToAddressFormFields: string;
235
391
  sections: {
@@ -252,13 +408,14 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
252
408
  subtitle: string;
253
409
  welcome: string;
254
410
  messageLine1: string;
411
+ partnerMessageLine1: string;
255
412
  messageLine2: string;
256
413
  };
257
414
  steps: {
258
- login: string;
415
+ register: string;
259
416
  carriers: string;
260
417
  addresses: string;
261
- payment: string;
418
+ billing: string;
262
419
  };
263
420
  warehouse: {
264
421
  title: string;
@@ -290,6 +447,14 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
290
447
  status: {
291
448
  saving: string;
292
449
  saved: string;
450
+ /**
451
+ * # Purchase Label Component Props
452
+ *
453
+ * These are the shared props that will be passed into the `<PurchaseLabel.Element />`, and work
454
+ * for either shipment-based or sales order-based label purchasing.
455
+ *
456
+ * @see {@link PurchaseLabel.Element | This prop types usage in `<PurchaseLabel.Element />`}
457
+ */
293
458
  savingFailed: string;
294
459
  };
295
460
  units: {
@@ -303,7 +468,9 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
303
468
  title: string;
304
469
  standard: string;
305
470
  g: string;
306
- kg: string;
471
+ kg: string; /**
472
+ * `features` is a set of feature flags you would like to enable or disable in this component.
473
+ */
307
474
  };
308
475
  };
309
476
  };
@@ -496,7 +663,12 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
496
663
  fields: {
497
664
  contentsType: string;
498
665
  countryOfOrigin: string;
499
- description: string;
666
+ description: string; /**
667
+ * `onToggleAddressPreferenceDisclosure` is an async/sync callback function that will be invoked
668
+ * each time the user toggles the `Address Preference` disclosure. This disclosure component
669
+ * allows the user to select whether they would like to use the address they entered, or
670
+ * the formatted address that we return after validation.
671
+ */
500
672
  harmonizedTariffCode: string;
501
673
  ifDeliveryFails: string;
502
674
  quantity: string;
@@ -513,7 +685,10 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
513
685
  };
514
686
  errorMessages: {
515
687
  invalidNameOrCompany: string;
516
- parsingFailure: string;
688
+ parsingFailure: string; /**
689
+ * `shippingPresets` is an object that contains configured shipment details/specs
690
+ * (dimensions, shipping service, etc) that can be applied to a shipment when purchasing a label.
691
+ */
517
692
  noWarehouses: string;
518
693
  unableToLoad: {
519
694
  accountSettings: string;
@@ -615,11 +790,16 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
615
790
  ounces: string;
616
791
  pounds_one: string;
617
792
  pounds_other: string;
793
+ kilogram: string;
794
+ gram: string;
618
795
  };
619
796
  units: {
620
- in: string;
797
+ inch: string;
621
798
  lbs: string;
622
799
  oz: string;
800
+ centimeter: string;
801
+ gram: string;
802
+ kilogram: string;
623
803
  };
624
804
  "VGhlIHNlbGVjdGVkIHNlcnZpY2UgaW5jbHVkZXMgaW5zdXJhbmNlIGZvciBhbiBpbnN1cmVkIGFtb3VudCB1cCB0byAkMTAwLgo=": string;
625
805
  "VGhlIHNlbGVjdGVkIHNlcnZpY2UgaW5jbHVkZXMgaW5zdXJhbmNlIGZvciBhbiBpbnN1cmVkIGFtb3VudCB1cCB0byAkNTAuCg==": string;
@@ -628,6 +808,7 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
628
808
  QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBVUFMgd2VpZ2h0IGxpbWl0IHBlciBwYWNrYWdlIGlzIDE1MCBsYnMu: string;
629
809
  UGxlYXNlIGFkZCBhIFN0YW1wcy5jb20gYWNjb3VudCB0byBTaGlwRW5naW5lIGluIG9yZGVyIHRvIGNyZWF0ZSBzaGlwcGluZyBsYWJlbHMu: string;
630
810
  QSBzaGlwcGluZyBlcnJvciBvY2N1cnJlZDogTWlzc2luZyBvciBpbnZhbGlkIHNoaXBwZXIgbnVtYmVy: string;
811
+ QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBNaXNzaW5nIG9yIGludmFsaWQgc2hpcHBlciBuYW1l: string;
631
812
  "QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBNaXNzaW5nIG9yIGludmFsaWQgc2hpcCB0byBTdGF0ZVByb3ZpbmNlQ29kZQ==": string;
632
813
  "QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBJbnZhbGlkIHNvbGQgdG8gc3RhdGUgcHJvdmluY2UgY29kZS4gVmFsaWQgbGVuZ3RoIGlzIDAgdG8gNSBhbHBoYW51bWVyaWM=": string;
633
814
  };
@@ -647,5 +828,9 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
647
828
  };
648
829
  } | undefined;
649
830
  }) => import("@emotion/react/jsx-runtime").JSX.Element;
831
+ /**
832
+ * # Purchase Label Component Props
833
+ *
834
+ * @see {@link PurchaseLabel.Component | The **Common Props** used in the `<PurchaseLabel /> component`}
835
+ */
650
836
  export type ComponentProps = React.ComponentProps<typeof Element>;
651
- export {};
@@ -1,12 +1,39 @@
1
+ import React from "react";
1
2
  import { Shipment } from "@shipengine/js-api";
2
- type LabelWorkflowProps = {
3
+ /**
4
+ * @internal
5
+ *
6
+ * # Label Workflow Props
7
+ *
8
+ * - These are the base props that will be passed into the `<LabelWorkflow />` component.
9
+ *
10
+ * @see {@link LabelWorkflow.Element | The `<LabelWorkflow.Element />` component}
11
+ */
12
+ export type LabelWorkflowProps = {
13
+ /**
14
+ * `callbacks` is an optional set of callbacks that will be invoked at various points in the
15
+ * label purchasing workflow.
16
+ */
3
17
  callbacks?: {
18
+ /**
19
+ * `onLabelCreateSuccess` is an optional callback function that will be invoked when a label
20
+ * has been successfully purchased.
21
+ */
4
22
  onLabelCreateSuccess?: (label: {
5
23
  labelId: string;
6
24
  }, shipment: Shipment) => void;
7
25
  };
26
+ /**
27
+ * `features` is a set of feature flags you would like to enable or disable in this component.
28
+ */
8
29
  features: any;
30
+ /**
31
+ * `labelId` is the unique identifier for the label you wish to view.
32
+ */
9
33
  labelId?: string;
34
+ /**
35
+ * `multiplexedId` is the unique pattern of props that help index which Element is being displayed.
36
+ */
10
37
  multiplexedId: ({
11
38
  orderSourceCode: string;
12
39
  } & ({
@@ -21,5 +48,114 @@ type LabelWorkflowProps = {
21
48
  oneOff: true;
22
49
  };
23
50
  };
51
+ /**
52
+ * @internal
53
+ *
54
+ * # Label Workflow Component
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * const {
59
+ * labelId,
60
+ * multiplexedId,
61
+ * isVoidingLabel,
62
+ * shipmentId,
63
+ * setLabelId,
64
+ * setShipmentId,
65
+ * setIsVoidingLabel,
66
+ * } = useLabelWorkflow({
67
+ * _labelId,
68
+ * _multiplexedId,
69
+ * });
70
+ * ```
71
+ *
72
+ * <br />
73
+ *
74
+ * @see {@link LabelWorkflow.Element | The `<LabelWorkflow.Element />` component using this hook}
75
+ */
76
+ export declare const useLabelWorkflow: ({ _multiplexedId, _labelId, }: {
77
+ _callbacks?: {
78
+ /**
79
+ * `onLabelCreateSuccess` is an optional callback function that will be invoked when a label
80
+ * has been successfully purchased.
81
+ */
82
+ onLabelCreateSuccess?: ((label: {
83
+ labelId: string;
84
+ }, shipment: Shipment) => void) | undefined;
85
+ } | undefined;
86
+ _labelId?: string | undefined;
87
+ _multiplexedId: ({
88
+ orderSourceCode: string;
89
+ } & ({
90
+ externalOrderNumber: string;
91
+ } | {
92
+ externalOrderId: string;
93
+ })) | {
94
+ salesOrderId: string;
95
+ } | {
96
+ shipmentId: string;
97
+ } | {
98
+ oneOff: true;
99
+ };
100
+ }) => {
101
+ isVoidingLabel: boolean;
102
+ labelId: string | undefined;
103
+ multiplexedId: ({
104
+ orderSourceCode: string;
105
+ } & ({
106
+ externalOrderNumber: string;
107
+ } | {
108
+ externalOrderId: string;
109
+ })) | {
110
+ salesOrderId: string;
111
+ } | {
112
+ shipmentId: string;
113
+ } | {
114
+ oneOff: true;
115
+ };
116
+ setIsVoidingLabel: React.Dispatch<React.SetStateAction<boolean>>;
117
+ setLabelId: (nextLabelId: LabelWorkflowProps["labelId"]) => void;
118
+ setMultiplexedId: React.Dispatch<React.SetStateAction<({
119
+ orderSourceCode: string;
120
+ } & ({
121
+ externalOrderNumber: string;
122
+ } | {
123
+ externalOrderId: string;
124
+ })) | {
125
+ salesOrderId: string;
126
+ } | {
127
+ shipmentId: string;
128
+ } | {
129
+ oneOff: true;
130
+ }>>;
131
+ setShipmentId: React.Dispatch<React.SetStateAction<string | undefined>>;
132
+ shipmentId: string | undefined;
133
+ };
134
+ /**
135
+ * @internal
136
+ *
137
+ * # Label Workflow Element
138
+ *
139
+ * - The `<LabelWorkflow.Element />` component is a composition of the PurchaseLabel, ViewShipment,
140
+ * and VoidLabel elements that allows users to purchase a label, view the shipment details, and optionally void their shipping label.
141
+ *
142
+ * @param LabelWorkflowProps The props necessary to render the `<LabelWorkflow.Element />` for shipment
143
+ * based or sales order based label purchasing.
144
+ *
145
+ * @returns Element A React Element that will render the `<LabelWorkflow />` component.
146
+ *
147
+ * @example
148
+ * ```tsx
149
+ * <LabelWorkflow
150
+ * {...elementProps}
151
+ * callbacks={{ onLabelCreateSuccess }}
152
+ * multiplexedId={elementIdProps}
153
+ * />
154
+ * ```
155
+ *
156
+ * <br />
157
+ *
158
+ * @see {@link LabelWorkflowProps | The props that are passed into the `<LabelWorkflow />` component}
159
+ * @see {@link LabelWorkflow.useLabelWorkflow | The `hook` that is used to manage the state of the `<LabelWorkflow />` component}
160
+ */
24
161
  export declare const Element: ({ multiplexedId: _multiplexedId, labelId: _labelId, features: propFeatures, callbacks, }: LabelWorkflowProps) => import("@emotion/react/jsx-runtime").JSX.Element;
25
- export {};
@@ -1,14 +1,94 @@
1
1
  /// <reference types="react" />
2
2
  import { SE } from "@shipengine/alchemy";
3
3
  import { Templates } from "../../components";
4
+ /**
5
+ * # View Shipment Component Props
6
+ *
7
+ * - These are the base props that will be passed into the `<ViewShipment />` component.
8
+ *
9
+ * @see {@link ViewShipment.Component | This prop types usage in the `<ViewShipment />` component}
10
+ */
4
11
  export type ComponentProps = {
12
+ /**
13
+ * `features` is a set of feature flags you would like to enable or disable in this component.
14
+ */
5
15
  features?: Templates.ShipmentFeatures;
16
+ /**
17
+ * `onClickPrintLabel` is a callback function that will be invoked when the user clicks the
18
+ * `Print Label` button.
19
+ */
6
20
  onClickPrintLabel?: () => void;
21
+ /**
22
+ * `onClickPurchaseLabel` is a callback function that will be invoked when the user clicks the
23
+ * `Purchase Label` button.
24
+ */
7
25
  onClickPurchaseLabel?: (order: SE.SalesOrder) => void;
26
+ /**
27
+ * `onClickVoidLabel` is a callback function that will be invoked when the user clicks the
28
+ * `Void Label` button.
29
+ */
8
30
  onClickVoidLabel?: (label: SE.Label) => void;
31
+ /**
32
+ * `shipmentId` is the unique identifier for the shipment you wish to view.
33
+ */
9
34
  shipmentId?: string;
10
35
  };
36
+ /**
37
+ * # View Shipment Component
38
+ *
39
+ * - The `<ViewShipment />` component is used to for viewing the shipment's tracking number, printing the label that
40
+ * was created, and the option to void the label. When a label is voided, you can see a list of the
41
+ * previously voided labels for a given shipment using this component.
42
+ *
43
+ * @param ComponentProps The base props that will be passed into the `<ViewShipment />` component.
44
+ *
45
+ * @returns Element An EmotionJSX.Element that will render the `<ViewShipment />` component
46
+ * with all the appropriate wrappers.
47
+ *
48
+ * @example
49
+ * You can see how the `<Component />` is used in the `createElement` function call below.
50
+ * ```tsx
51
+ * export const Element = alchemy.createElement(Component, ErrorFallback, {
52
+ * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
53
+ * resources: { en },
54
+ * });
55
+ * ```
56
+ *
57
+ * <br />
58
+ *
59
+ * @see {@link ViewShipment.Element | The **Element** created to render `<ViewShipment />`}
60
+ */
11
61
  export declare const Component: ({ features, onClickPrintLabel, onClickPurchaseLabel, onClickVoidLabel, shipmentId, }: ComponentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
62
+ /**
63
+ * # Registered View Shipment Element
64
+ *
65
+ * - This is the registered `<ViewShipment />` element that will be used to render the
66
+ * `<ViewShipment.Element />` component.
67
+ *
68
+ * @param ElementProps The props, callbacks, and resources necessary to render
69
+ * the `<ViewShipment.Element />` component.
70
+ *
71
+ * @example
72
+ * The `<Component />` is the source JSX that is rendered when you make use of the `ViewShipment`
73
+ * Element directly. Here is a brief example of how you would use it within your application.
74
+ * ```tsx
75
+ * <ViewShipment.Element
76
+ * onClickPurchaseLabel={({ salesOrderId }) => {
77
+ * console.log('sales order ID', salesOrderId);
78
+ * }}
79
+ * onClickVoidLabel={({ labelId }) => {
80
+ * console.log('voided label', labelId);
81
+ * }}
82
+ * shipmentId="se-1234567"
83
+ * />
84
+ * ```
85
+ *
86
+ * <br />
87
+ *
88
+ * @see {@link ViewShipment.ComponentProps | The **props** that can be passed into the `<ViewShipment.Element />` component}
89
+ *
90
+ * @see {@link VoidLabel.Element | The next step in the label purchase workflow `<VoidLabel.Element />`}
91
+ **/
12
92
  export declare const Element: ({ resources, ...props }: ComponentProps & {
13
93
  resources?: {
14
94
  en: {
@@ -215,6 +295,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
215
295
  rates: {
216
296
  uspsMediaMailAcknowledgement: string;
217
297
  uspsFirstClassMailAcknowledgement_leof: string;
298
+ dhlExpressTermsAcknowledgement: string;
218
299
  };
219
300
  shipToAddressFormFields: string;
220
301
  sections: {
@@ -237,13 +318,18 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
237
318
  subtitle: string;
238
319
  welcome: string;
239
320
  messageLine1: string;
321
+ partnerMessageLine1: string;
240
322
  messageLine2: string;
241
323
  };
242
324
  steps: {
243
- login: string;
325
+ register: string;
244
326
  carriers: string;
245
327
  addresses: string;
246
- payment: string;
328
+ /**
329
+ * `onClickPrintLabel` is a callback function that will be invoked when the user clicks the
330
+ * `Print Label` button.
331
+ */
332
+ billing: string;
247
333
  };
248
334
  warehouse: {
249
335
  title: string;
@@ -281,7 +367,10 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
281
367
  title: string;
282
368
  dimensions: {
283
369
  title: string;
284
- standard: string;
370
+ standard: string; /**
371
+ * `onClickPrintLabel` is a callback function that will be invoked when the user clicks the
372
+ * `Print Label` button.
373
+ */
285
374
  metric: string;
286
375
  };
287
376
  weight: {
@@ -417,6 +506,31 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
417
506
  title: string;
418
507
  originalAddress: string;
419
508
  matchedAddress: string;
509
+ /**
510
+ * # View Shipment Component
511
+ *
512
+ * - The `<ViewShipment />` component is used to for viewing the shipment's tracking number, printing the label that
513
+ * was created, and the option to void the label. When a label is voided, you can see a list of the
514
+ * previously voided labels for a given shipment using this component.
515
+ *
516
+ * @param ComponentProps The base props that will be passed into the `<ViewShipment />` component.
517
+ *
518
+ * @returns Element An EmotionJSX.Element that will render the `<ViewShipment />` component
519
+ * with all the appropriate wrappers.
520
+ *
521
+ * @example
522
+ * You can see how the `<Component />` is used in the `createElement` function call below.
523
+ * ```tsx
524
+ * export const Element = alchemy.createElement(Component, ErrorFallback, {
525
+ * css: { height: "100%", maxWidth: "800px", minWidth: "440px", width: "100%" },
526
+ * resources: { en },
527
+ * });
528
+ * ```
529
+ *
530
+ * <br />
531
+ *
532
+ * @see {@link ViewShipment.Element | The **Element** created to render `<ViewShipment />`}
533
+ */
420
534
  unableToValidate: string;
421
535
  use: {
422
536
  originalAddress: string;
@@ -600,11 +714,16 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
600
714
  ounces: string;
601
715
  pounds_one: string;
602
716
  pounds_other: string;
717
+ kilogram: string;
718
+ gram: string;
603
719
  };
604
720
  units: {
605
- in: string;
721
+ inch: string;
606
722
  lbs: string;
607
723
  oz: string;
724
+ centimeter: string;
725
+ gram: string;
726
+ kilogram: string;
608
727
  };
609
728
  "VGhlIHNlbGVjdGVkIHNlcnZpY2UgaW5jbHVkZXMgaW5zdXJhbmNlIGZvciBhbiBpbnN1cmVkIGFtb3VudCB1cCB0byAkMTAwLgo=": string;
610
729
  "VGhlIHNlbGVjdGVkIHNlcnZpY2UgaW5jbHVkZXMgaW5zdXJhbmNlIGZvciBhbiBpbnN1cmVkIGFtb3VudCB1cCB0byAkNTAuCg==": string;
@@ -613,6 +732,7 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
613
732
  QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBVUFMgd2VpZ2h0IGxpbWl0IHBlciBwYWNrYWdlIGlzIDE1MCBsYnMu: string;
614
733
  UGxlYXNlIGFkZCBhIFN0YW1wcy5jb20gYWNjb3VudCB0byBTaGlwRW5naW5lIGluIG9yZGVyIHRvIGNyZWF0ZSBzaGlwcGluZyBsYWJlbHMu: string;
615
734
  QSBzaGlwcGluZyBlcnJvciBvY2N1cnJlZDogTWlzc2luZyBvciBpbnZhbGlkIHNoaXBwZXIgbnVtYmVy: string;
735
+ QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBNaXNzaW5nIG9yIGludmFsaWQgc2hpcHBlciBuYW1l: string;
616
736
  "QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBNaXNzaW5nIG9yIGludmFsaWQgc2hpcCB0byBTdGF0ZVByb3ZpbmNlQ29kZQ==": string;
617
737
  "QSBzaGlwcGluZyBjYXJyaWVyIGVycm9yIG9jY3VycmVkOiBJbnZhbGlkIHNvbGQgdG8gc3RhdGUgcHJvdmluY2UgY29kZS4gVmFsaWQgbGVuZ3RoIGlzIDAgdG8gNSBhbHBoYW51bWVyaWM=": string;
618
738
  };
@@ -632,4 +752,11 @@ export declare const Element: ({ resources, ...props }: ComponentProps & {
632
752
  };
633
753
  } | undefined;
634
754
  }) => import("@emotion/react/jsx-runtime").JSX.Element;
755
+ /**
756
+ * # View Shipment Element Props
757
+ *
758
+ * - These are the base props that will be passed into the `<ViewShipment />` element.
759
+ *
760
+ * @see {@link ViewShipment.Element | See the full type that `typeof Element` will return}
761
+ */
635
762
  export type ElementProps = React.ComponentProps<typeof Element>;