@shipengine/elements 0.17.2 → 0.18.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 (36) hide show
  1. package/components/auto-funding-form/auto-funding-form.d.ts +3 -1
  2. package/components/auto-funding-form/auto-funding-form.styles.d.ts +2 -1
  3. package/components/field/expiration-input/expiration-input.d.ts +3 -0
  4. package/components/field/expiration-input/index.d.ts +1 -0
  5. package/components/field/fields.d.ts +1 -0
  6. package/components/field/switch/switch.d.ts +1 -1
  7. package/components/fund-and-purchase/fund-and-purchase.d.ts +4 -1
  8. package/components/templates/address-form/address-fields.styles.d.ts +1 -0
  9. package/components/templates/index.d.ts +2 -0
  10. package/components/templates/manage-warehouses/manage-warehouse.styles.d.ts +1 -0
  11. package/components/templates/manage-warehouses/manage-warehouses.d.ts +10 -5
  12. package/components/templates/onboarding/onboarding.d.ts +2 -3
  13. package/components/templates/onboarding/onboarding.styles.d.ts +1 -1
  14. package/components/templates/rate-form/rate-form.d.ts +1 -0
  15. package/components/templates/shipment-form/shipment-schema.d.ts +2 -2
  16. package/components/templates/wallet-form/wallet-schema.d.ts +7 -12
  17. package/components/templates/warehouse-form/warehouse-form-schema.d.ts +2 -102
  18. package/components/templates/warehouse-form/warehouse-form.d.ts +2 -1
  19. package/components/templates/warehouse-preference-select/index.d.ts +1 -0
  20. package/components/templates/warehouse-preference-select/warehouse-preference-select.d.ts +24 -0
  21. package/components/templates/warehouse-preference-wizard/index.d.ts +1 -0
  22. package/components/templates/warehouse-preference-wizard/warehouse-preference-wizard.d.ts +23 -0
  23. package/elements/components/manage-warehouses/manage-warehouses.d.ts +5 -2
  24. package/elements/manage-warehouses.d.ts +1 -1
  25. package/factories/shipengine/warehouse.d.ts +2 -0
  26. package/hooks/index.d.ts +1 -0
  27. package/hooks/use-warehouse-validation.d.ts +14 -0
  28. package/index.cjs +2253 -2576
  29. package/index.d.ts +0 -2
  30. package/index.js +2255 -2545
  31. package/locales/en/index.d.ts +11 -3
  32. package/mocks/carriers/handlers.d.ts +3 -0
  33. package/mocks/warehouses/handlers.d.ts +12 -1
  34. package/package.json +3 -3
  35. package/utilities/money.d.ts +1 -0
  36. package/components/templates/warehouse-form/warehouse-form.styles.d.ts +0 -1
@@ -3,6 +3,8 @@ export type AutoFundingFormProps = {
3
3
  };
4
4
  /**
5
5
  * This form that allows users to enable or disable auto funding, and
6
- * configure auto funding settings in ShipEngine API.
6
+ * configure auto funding rules in ShipEngine API.
7
+ *
8
+ * @param carrierId The carrierId of the carrier provider you wish to configure auto-funding rules for.
7
9
  */
8
10
  export declare const AutoFundingForm: ({ carrierId }: AutoFundingFormProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1 +1,2 @@
1
- export declare const styles: Record<"form", import("@emotion/serialize").Interpolation<import("@packlink/brands/dist/js/theme/Theme").Theme>>;
1
+ import { Theme } from "@packlink/brands";
2
+ export declare const getStyles: (showForm: boolean) => Record<"edit" | "form" | "input" | "marginLeft", import("@emotion/serialize").Interpolation<Theme>>;
@@ -0,0 +1,3 @@
1
+ import { InputProps as NativeInputProps } from "@packlink/giger";
2
+ import { ControlledField } from "../create-field-controller";
3
+ export declare const ExpirationInput: ControlledField<NativeInputProps>;
@@ -0,0 +1 @@
1
+ export * from "./expiration-input";
@@ -1,6 +1,7 @@
1
1
  export * from "./credit-card-input";
2
2
  export * from "./checkbox-input";
3
3
  export * from "./date-picker";
4
+ export * from "./expiration-input";
4
5
  export * from "./input-group";
5
6
  export * from "./money-input";
6
7
  export * from "./number-input";
@@ -3,7 +3,7 @@ import { ISwitchProps } from "@packlink/giger";
3
3
  export type SwitchProps = {
4
4
  children?: React.ReactNode;
5
5
  defaultChecked?: boolean;
6
- label: string;
6
+ label?: string;
7
7
  shouldUnmount?: boolean;
8
8
  } & Omit<ISwitchProps, "children">;
9
9
  export declare const Switch: ({ defaultChecked, children, shouldUnmount, label, onChange, ...props }: SwitchProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,7 +1,10 @@
1
+ import { Control } from "react-hook-form";
1
2
  export type FundAndPurchaseProps = {
2
3
  carrierId?: string;
3
4
  className?: string;
5
+ control: Control<any, any>;
4
6
  disabled?: boolean;
7
+ isFundingEnabled?: boolean;
5
8
  isFundingRequired: boolean;
6
9
  onPurchase: () => void;
7
10
  onSave: () => Promise<void>;
@@ -12,4 +15,4 @@ export type FundAndPurchaseProps = {
12
15
  * has the necessary funds available and can add them if not. It allows a single button
13
16
  * to submit the funding form followed by the purchase form.
14
17
  */
15
- export declare const FundAndPurchase: ({ carrierId, className, disabled, isFundingRequired, onSave, purchaseAmount, onPurchase, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
18
+ export declare const FundAndPurchase: ({ carrierId, className, control, disabled, isFundingEnabled, isFundingRequired, onSave, purchaseAmount, onPurchase, }: FundAndPurchaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const styles: Record<"grow" | "stateWrapper" | "stateZipWrapper" | "zipWrapper", import("@emotion/serialize").Interpolation<import("@packlink/brands/dist/js/theme/Theme").Theme>>;
@@ -19,3 +19,5 @@ export * from "./suspend-shipment";
19
19
  export * from "./warehouse-form";
20
20
  export * from "./void-label";
21
21
  export * from "./wallet-form";
22
+ export * from "./warehouse-preference-wizard";
23
+ export * from "./warehouse-preference-select";
@@ -0,0 +1 @@
1
+ export declare const styles: Record<"cardSpacing" | "header" | "well", import("@emotion/serialize").Interpolation<import("@packlink/brands/dist/js/theme/Theme").Theme>>;
@@ -1,10 +1,15 @@
1
1
  import { SE } from "@shipengine/api";
2
+ import { WarehousePreference } from "../warehouse-preference-wizard";
3
+ export type WarehousePayload = Partial<SE.Warehouse> & Pick<SE.Warehouse, "name" | "originAddress" | "isDefault">;
2
4
  export type ManageWarehousesProps = {
3
5
  errors?: SE.CodedError[];
4
- onAdd: (payload: Omit<SE.Warehouse, "createdAt" | "warehouseId">) => Promise<void> | void;
5
- onDelete: (warehouseId: string) => Promise<void> | void;
6
- onEdit: (payload: Omit<SE.Warehouse, "createdAt" | "warehouseId">, warehouseId: string) => Promise<void> | void;
7
- onSetDefault: (warehouse: Partial<SE.Warehouse>, warehouseId: string) => Promise<void> | void;
6
+ onAdd: (payload: WarehousePayload) => Promise<void>;
7
+ onDelete: (warehouseId: string) => Promise<void>;
8
+ onEdit: (payload: WarehousePayload, warehouseId: string) => Promise<void>;
9
+ onSetDefault: (warehouse: Partial<SE.Warehouse>, warehouseId: string) => Promise<void>;
10
+ onValidate: (warehouse: WarehousePayload) => Promise<WarehousePreference>;
11
+ setWarehousePreference: (warehousePreference?: WarehousePreference) => void;
12
+ warehousePreference?: WarehousePreference;
8
13
  warehouses: SE.Warehouse[];
9
14
  };
10
- export declare const ManageWarehouses: ({ errors, onAdd, onDelete, onEdit, onSetDefault, warehouses, }: ManageWarehousesProps) => import("@emotion/react/jsx-runtime").JSX.Element;
15
+ export declare const ManageWarehouses: ({ errors, onAdd, onDelete, onEdit, onSetDefault, onValidate, setWarehousePreference, warehousePreference, warehouses, }: ManageWarehousesProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,9 +1,8 @@
1
1
  import { SE } from "@shipengine/api";
2
+ import { Templates } from "../../../components";
2
3
  export type OnboardingProps = {
3
4
  carriers: SE.Carrier[];
4
5
  createWarehouse: (payload: Partial<SE.Warehouse>) => Promise<SE.Warehouse>;
5
- isLoadingDhl: boolean;
6
- isLoadingUps: boolean;
7
6
  onCarrierCreated: () => Promise<void>;
8
7
  onCompleteOnboarding: () => void;
9
8
  onWarehouseCreated: () => Promise<void>;
@@ -15,4 +14,4 @@ export type OnboardingProps = {
15
14
  registerUpsCarrierErrors: SE.CodedError[] | null;
16
15
  warehouses: SE.Warehouse[];
17
16
  };
18
- export declare const Onboarding: ({ carriers, createWarehouse, onCarrierCreated, onWarehouseCreated, isLoadingDhl, isLoadingUps, onCompleteOnboarding, registerDhlCarrier, registerDhlCarrierErrors, registerStampsCarrier, registerStampsCarrierErrors, registerUpsCarrier, registerUpsCarrierErrors, warehouses, }: OnboardingProps) => import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export declare const Onboarding: ({ carriers, createWarehouse, onCarrierCreated, onWarehouseCreated, onCompleteOnboarding, registerDhlCarrier, registerDhlCarrierErrors, registerStampsCarrier, registerStampsCarrierErrors, registerUpsCarrier, registerUpsCarrierErrors, warehouses, }: OnboardingProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- export declare const styles: Record<"lastStep" | "step", import("@emotion/serialize").Interpolation<import("@packlink/brands/dist/js/theme/Theme").Theme>>;
1
+ export declare const styles: Record<"step" | "wrapper", import("@emotion/serialize").Interpolation<import("@packlink/brands/dist/js/theme/Theme").Theme>>;
@@ -1,5 +1,6 @@
1
1
  import { SE } from "@shipengine/api";
2
2
  export type RateFormFeatures = {
3
+ enableFunding?: boolean;
3
4
  enableGlobalPostFiltering?: boolean;
4
5
  includeRecommendedRates?: boolean;
5
6
  nicknameRate?: boolean;
@@ -194,7 +194,7 @@ export declare const getShipmentSchema: ({ allowInternationalShipFrom, warehouse
194
194
  }>>>;
195
195
  shipDate: z.ZodString;
196
196
  shipmentId: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodString>>, string | undefined, string | null | undefined>;
197
- warehouseId: z.ZodEffects<z.ZodString, string, string>;
197
+ warehouseId: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
198
198
  }, {
199
199
  __mode: z.ZodLiteral<"browse_rates">;
200
200
  }>, "strip", z.ZodTypeAny, {
@@ -471,7 +471,7 @@ export declare const getShipmentSchema: ({ allowInternationalShipFrom, warehouse
471
471
  }>>>;
472
472
  shipDate: z.ZodString;
473
473
  shipmentId: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodString>>, string | undefined, string | null | undefined>;
474
- warehouseId: z.ZodEffects<z.ZodString, string, string>;
474
+ warehouseId: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
475
475
  }, {
476
476
  __mode: z.ZodLiteral<"select_service">;
477
477
  packages: z.ZodArray<z.ZodObject<z.extendShape<{
@@ -197,24 +197,21 @@ export declare const walletSchema: z.ZodObject<{
197
197
  }>;
198
198
  creditCard: z.ZodEffects<z.ZodObject<{
199
199
  cvv: z.ZodEffects<z.ZodString, string, string>;
200
- expirationMonth: z.ZodEnum<["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]>;
201
- expirationYear: z.ZodEffects<z.ZodString, string, string>;
200
+ expiration: z.ZodEffects<z.ZodString, string, string>;
202
201
  name: z.ZodString;
203
202
  number: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
204
203
  }, "strip", z.ZodTypeAny, {
205
204
  number: string;
206
205
  name: string;
207
206
  cvv: string;
208
- expirationMonth: "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12";
209
- expirationYear: string;
207
+ expiration: string;
210
208
  }, {
211
209
  number: string;
212
210
  name: string;
213
211
  cvv: string;
214
- expirationMonth: "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12";
215
- expirationYear: string;
212
+ expiration: string;
216
213
  }>, {
217
- expirationMonth: "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12";
214
+ expirationMonth: string;
218
215
  expirationYear: string;
219
216
  name: string;
220
217
  number: string;
@@ -223,8 +220,7 @@ export declare const walletSchema: z.ZodObject<{
223
220
  number: string;
224
221
  name: string;
225
222
  cvv: string;
226
- expirationMonth: "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12";
227
- expirationYear: string;
223
+ expiration: string;
228
224
  }>;
229
225
  }, "strip", z.ZodTypeAny, {
230
226
  address: {
@@ -239,7 +235,7 @@ export declare const walletSchema: z.ZodObject<{
239
235
  stateProvince: string;
240
236
  };
241
237
  creditCard: {
242
- expirationMonth: "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12";
238
+ expirationMonth: string;
243
239
  expirationYear: string;
244
240
  name: string;
245
241
  number: string;
@@ -261,8 +257,7 @@ export declare const walletSchema: z.ZodObject<{
261
257
  number: string;
262
258
  name: string;
263
259
  cvv: string;
264
- expirationMonth: "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12";
265
- expirationYear: string;
260
+ expiration: string;
266
261
  };
267
262
  }>;
268
263
  export type WalletFormFields = z.input<typeof walletSchema>;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- export declare const warehouseSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"returnToAddressIsDifferent", z.Primitive, z.ZodObject<{
2
+ export declare const warehouseSchema: z.ZodDiscriminatedUnion<"returnToAddressIsDifferent", z.Primitive, z.ZodObject<{
3
3
  isDefault: z.ZodBoolean;
4
4
  name: z.ZodString;
5
5
  originAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<z.extendShape<{
@@ -398,106 +398,6 @@ export declare const warehouseSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"retu
398
398
  name: string;
399
399
  postalCode: string;
400
400
  };
401
- }>>, {
402
- name: string;
403
- returnToAddressIsDifferent: true;
404
- isDefault: boolean;
405
- originAddress: {
406
- addressLine2?: string | undefined;
407
- companyName?: string | undefined;
408
- addressLine1: string;
409
- cityLocality: string;
410
- countryCode: "AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BN" | "BG" | "BF" | "BI" | "CA" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FM" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "AN" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "RE" | "RO" | "RU" | "RW" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "VI" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW";
411
- name: string;
412
- phone: string;
413
- postalCode: string;
414
- stateProvince: string;
415
- addressResidentialIndicator: "yes" | "no";
416
- };
417
- returnAddress: {
418
- addressLine2?: string | undefined;
419
- companyName?: string | undefined;
420
- addressLine1: string;
421
- cityLocality: string;
422
- countryCode: "AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BN" | "BG" | "BF" | "BI" | "CA" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FM" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "AN" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "RE" | "RO" | "RU" | "RW" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "VI" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW";
423
- name: string;
424
- phone: string;
425
- postalCode: string;
426
- stateProvince: string;
427
- addressResidentialIndicator: "yes" | "no";
428
- };
429
- } | {
430
- returnAddress: {
431
- addressLine2?: string | undefined;
432
- companyName?: string | undefined;
433
- addressLine1: string;
434
- cityLocality: string;
435
- countryCode: "AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BN" | "BG" | "BF" | "BI" | "CA" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FM" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "AN" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "RE" | "RO" | "RU" | "RW" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "VI" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW";
436
- name: string;
437
- phone: string;
438
- postalCode: string;
439
- stateProvince: string;
440
- addressResidentialIndicator: "yes" | "no";
441
- };
442
- name: string;
443
- returnToAddressIsDifferent: false;
444
- isDefault: boolean;
445
- originAddress: {
446
- addressLine2?: string | undefined;
447
- companyName?: string | undefined;
448
- addressLine1: string;
449
- cityLocality: string;
450
- countryCode: "AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BN" | "BG" | "BF" | "BI" | "CA" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FM" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "AN" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "RE" | "RO" | "RU" | "RW" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "VI" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW";
451
- name: string;
452
- phone: string;
453
- postalCode: string;
454
- stateProvince: string;
455
- addressResidentialIndicator: "yes" | "no";
456
- };
457
- }, {
458
- name: string;
459
- returnToAddressIsDifferent: true;
460
- isDefault: boolean;
461
- originAddress: {
462
- addressLine2?: string | null | undefined;
463
- companyName?: string | null | undefined;
464
- phone?: string | null | undefined;
465
- stateProvince?: string | null | undefined;
466
- addressResidentialIndicator?: unknown;
467
- addressLine1: string;
468
- cityLocality: string;
469
- countryCode: "AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BN" | "BG" | "BF" | "BI" | "CA" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FM" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "AN" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "RE" | "RO" | "RU" | "RW" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "VI" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW";
470
- name: string;
471
- postalCode: string;
472
- };
473
- returnAddress: {
474
- addressLine2?: string | null | undefined;
475
- companyName?: string | null | undefined;
476
- phone?: string | null | undefined;
477
- stateProvince?: string | null | undefined;
478
- addressResidentialIndicator?: unknown;
479
- addressLine1: string;
480
- cityLocality: string;
481
- countryCode: "AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BN" | "BG" | "BF" | "BI" | "CA" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FM" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "AN" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "RE" | "RO" | "RU" | "RW" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "VI" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW";
482
- name: string;
483
- postalCode: string;
484
- };
485
- } | {
486
- name: string;
487
- returnToAddressIsDifferent: false;
488
- isDefault: boolean;
489
- originAddress: {
490
- addressLine2?: string | null | undefined;
491
- companyName?: string | null | undefined;
492
- phone?: string | null | undefined;
493
- stateProvince?: string | null | undefined;
494
- addressResidentialIndicator?: unknown;
495
- addressLine1: string;
496
- cityLocality: string;
497
- countryCode: "AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AQ" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BN" | "BG" | "BF" | "BI" | "CA" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CX" | "CC" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "HR" | "CU" | "CW" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FM" | "FJ" | "FI" | "FR" | "GF" | "PF" | "TF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GG" | "GN" | "GW" | "GY" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "AN" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PN" | "PL" | "PT" | "PR" | "QA" | "RE" | "RO" | "RU" | "RW" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SB" | "SO" | "ZA" | "GS" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "VI" | "UM" | "US" | "UY" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW";
498
- name: string;
499
- postalCode: string;
500
- };
501
- }>;
401
+ }>>;
502
402
  export type WarehouseFormFields = z.input<typeof warehouseSchema>;
503
403
  export type WarehouseFormPayload = z.output<typeof warehouseSchema>;
@@ -1,9 +1,10 @@
1
1
  import { SE } from "@shipengine/api";
2
+ import { WarehousePayload } from "../manage-warehouses";
2
3
  export type WarehouseFormProps = {
3
4
  isOnboarding?: boolean;
4
5
  onCancel?: () => void;
5
6
  onDelete?: () => void;
6
- onSubmit: (payload: Omit<SE.Warehouse, "createdAt" | "warehouseId">) => void;
7
+ onSubmit: (payload: WarehousePayload) => void;
7
8
  submitButtonTitle: string;
8
9
  warehouse?: SE.Warehouse;
9
10
  };
@@ -0,0 +1 @@
1
+ export * from "./warehouse-preference-select";
@@ -0,0 +1,24 @@
1
+ import { SE } from "@shipengine/api";
2
+ export type WarehouseSuggested = {
3
+ validation: SE.AddressValidation;
4
+ validationType: "SUGGESTED";
5
+ };
6
+ export type WarehouseError = {
7
+ validation: SE.AddressValidation;
8
+ validationType: "ERROR";
9
+ };
10
+ export type WarehouseExactOrSoft = {
11
+ address: SE.Address;
12
+ validationType: "EXACT" | "SOFT";
13
+ };
14
+ export type WarehouseAddressPreference = WarehouseSuggested | WarehouseError | WarehouseExactOrSoft;
15
+ export type WarehousePreferenceFormProps = {
16
+ onCancel: () => void;
17
+ onSubmit: (payload: {
18
+ originAddress: SE.Address;
19
+ returnAddress?: SE.Address;
20
+ }) => Promise<void> | void;
21
+ originAddress: WarehouseAddressPreference;
22
+ returnAddress?: WarehouseAddressPreference;
23
+ };
24
+ export declare const WarehousePreferenceSelect: ({ onCancel, onSubmit, originAddress, returnAddress, }: WarehousePreferenceFormProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./warehouse-preference-wizard";
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { SE } from "@shipengine/api";
3
+ import { ManageWarehousesProps, WarehousePayload } from "../manage-warehouses";
4
+ import { WarehouseAddressPreference } from "../warehouse-preference-select";
5
+ export type WarehousePreference = {
6
+ isDefault?: boolean;
7
+ name: string;
8
+ originAddress: WarehouseAddressPreference;
9
+ returnAddress?: WarehouseAddressPreference;
10
+ };
11
+ export type WarehousePreferenceWizardProps = {
12
+ className?: string;
13
+ formHeader?: React.ReactNode;
14
+ isOnboarding?: boolean;
15
+ onSubmit: (payload: WarehousePayload) => Promise<void> | void;
16
+ onValidate: ManageWarehousesProps["onValidate"];
17
+ onWarehouseDelete?: () => Promise<void> | void;
18
+ onWarehouseFormCancel?: () => void;
19
+ submitButtonTitle: string;
20
+ warehouse?: SE.Warehouse;
21
+ warehousePreference?: WarehousePreference;
22
+ };
23
+ export declare const WarehousePreferenceWizard: ({ className, formHeader, isOnboarding, onSubmit, onValidate, onWarehouseDelete, onWarehouseFormCancel, submitButtonTitle, warehouse, warehousePreference, }: WarehousePreferenceWizardProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,2 +1,5 @@
1
- export type ManageWarehousesProps = {};
2
- export declare const ManageWarehouses: () => import("@emotion/react/jsx-runtime").JSX.Element;
1
+ import { Templates } from "../../../components";
2
+ export type ManageWarehousesProps = {
3
+ onWarehouseAddressValidation?: (originAddressPreference: Templates.AddressPreference, returnAddressPreference?: Templates.AddressPreference) => Promise<void> | void;
4
+ };
5
+ export declare const ManageWarehouses: ({ onWarehouseAddressValidation }: ManageWarehousesProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- export declare const Element: (props: Record<string, unknown>) => import("@emotion/react/jsx-runtime").JSX.Element;
1
+ export declare const Element: (props: import("./components/manage-warehouses").ManageWarehousesProps & Record<string, unknown>) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,6 +1,8 @@
1
1
  import { Factory } from "fishery";
2
2
  import { SE } from "@shipengine/api";
3
+ import { Templates } from "../../components";
3
4
  /**
4
5
  * @category Factories
5
6
  */
6
7
  export declare const warehouseFactory: Factory<SE.Warehouse, any, SE.Warehouse>;
8
+ export declare const warehouseAddressPreferenceFactory: Factory<Templates.WarehouseAddressPreference, any, Templates.WarehouseAddressPreference>;
package/hooks/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export * from "./use-page-layout";
6
6
  export * from "./use-root-portal";
7
7
  export * from "./use-run-once-on-true";
8
8
  export * from "./use-toggle";
9
+ export * from "./use-warehouse-validation";
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { SE } from "@shipengine/api";
3
+ import { Templates } from "../components";
4
+ export declare const useWarehouseValidation: () => {
5
+ errors: SE.CodedError[] | null;
6
+ setWarehousePreference: import("react").Dispatch<import("react").SetStateAction<Templates.WarehousePreference | undefined>>;
7
+ validate: (warehouse: Partial<SE.Warehouse> & Pick<SE.Warehouse, "name" | "originAddress" | "isDefault">) => Promise<{
8
+ isDefault: boolean;
9
+ name: string;
10
+ originAddress: Templates.WarehouseAddressPreference;
11
+ returnAddress: Templates.WarehouseAddressPreference;
12
+ }>;
13
+ warehousePreference: Templates.WarehousePreference | undefined;
14
+ };