@storepecker/storefront-core 2.9.1 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/address-BdIB6IuI.d.cts +42 -0
  2. package/dist/address-BdIB6IuI.d.ts +42 -0
  3. package/dist/api/index.cjs +36 -32
  4. package/dist/api/index.d.cts +20 -17
  5. package/dist/api/index.d.ts +20 -17
  6. package/dist/api/index.js +4 -4
  7. package/dist/{buy-now-BqVWXyy8.d.cts → buy-now-CDug6LJ_.d.ts} +2 -2
  8. package/dist/{buy-now-DFdnuLjO.d.ts → buy-now-DrKY5_9R.d.cts} +2 -2
  9. package/dist/checkout/index.cjs +163 -76
  10. package/dist/checkout/index.d.cts +37 -26
  11. package/dist/checkout/index.d.ts +37 -26
  12. package/dist/checkout/index.js +50 -64
  13. package/dist/checkout-totals-CbmXM9L7.d.cts +220 -0
  14. package/dist/checkout-totals-DU8l-Wyb.d.ts +220 -0
  15. package/dist/{chunk-IG4BW3ZB.cjs → chunk-32X4SWN4.cjs} +3 -3
  16. package/dist/{chunk-NQZ5GUOG.cjs → chunk-3YPE6UPC.cjs} +24 -16
  17. package/dist/{chunk-RDUT4W3B.cjs → chunk-6APRQ2ED.cjs} +4 -1
  18. package/dist/{chunk-ICKTXS6B.js → chunk-6IXTFZFS.js} +3 -3
  19. package/dist/{chunk-7M5CVYZJ.js → chunk-A7EI7XLU.js} +8 -1
  20. package/dist/chunk-DZPK7GPG.js +601 -0
  21. package/dist/{chunk-TH7OAMGC.js → chunk-E4D4XOAE.js} +24 -16
  22. package/dist/{chunk-NRPK5GCJ.cjs → chunk-EFYAFXIS.cjs} +3 -3
  23. package/dist/{chunk-CBKJ3Y2I.js → chunk-EWZ7TGI7.js} +11 -1
  24. package/dist/{chunk-5XVHYPOC.js → chunk-FF5N7PTB.js} +1 -1
  25. package/dist/{chunk-NOT6VKXA.cjs → chunk-H6UZTS5O.cjs} +67 -23
  26. package/dist/{chunk-XFOUNOKO.cjs → chunk-KNG4OMS5.cjs} +8 -0
  27. package/dist/{chunk-ZAWZ3RB6.js → chunk-NNE42NMP.js} +1 -1
  28. package/dist/chunk-PN6KH5PX.cjs +661 -0
  29. package/dist/{chunk-QQHQTBAM.js → chunk-QSRVMOXT.js} +48 -6
  30. package/dist/{chunk-W6BDMNSU.js → chunk-QVO56X4E.js} +1 -1
  31. package/dist/{chunk-6LS5F4R3.cjs → chunk-SGJUMI3M.cjs} +11 -0
  32. package/dist/{chunk-YLLAP3H2.cjs → chunk-SGKLMS7W.cjs} +2 -2
  33. package/dist/{chunk-ZGMLOLTC.js → chunk-VRZRV2BR.js} +4 -1
  34. package/dist/{chunk-IVKJJLG7.cjs → chunk-WWJAPKRQ.cjs} +8 -8
  35. package/dist/{collections-CXgOv5_G.d.cts → collections-CKNFcE2d.d.cts} +1 -1
  36. package/dist/{collections-CNh2OGbl.d.ts → collections-CtRKsWVx.d.ts} +1 -1
  37. package/dist/components/address-form.cjs +6 -6
  38. package/dist/components/address-form.d.cts +10 -6
  39. package/dist/components/address-form.d.ts +10 -6
  40. package/dist/components/address-form.js +5 -5
  41. package/dist/components/digital-product-download-modal.d.cts +2 -2
  42. package/dist/components/digital-product-download-modal.d.ts +2 -2
  43. package/dist/components/index.cjs +8 -8
  44. package/dist/components/index.d.cts +6 -7
  45. package/dist/components/index.d.ts +6 -7
  46. package/dist/components/index.js +6 -6
  47. package/dist/components/search-dropdown.d.cts +4 -4
  48. package/dist/components/search-dropdown.d.ts +4 -4
  49. package/dist/components/share-button.cjs +3 -3
  50. package/dist/components/share-button.d.cts +1 -1
  51. package/dist/components/share-button.d.ts +1 -1
  52. package/dist/components/share-button.js +2 -2
  53. package/dist/components/theme-data-initializer.d.cts +4 -5
  54. package/dist/components/theme-data-initializer.d.ts +4 -5
  55. package/dist/hooks/index.cjs +672 -44
  56. package/dist/hooks/index.d.cts +239 -13
  57. package/dist/hooks/index.d.ts +239 -13
  58. package/dist/hooks/index.js +630 -11
  59. package/dist/{instagram-DalreBu6.d.cts → instagram-CSzrxk10.d.cts} +8 -2
  60. package/dist/{instagram-BADLnNQ3.d.ts → instagram-CagTLmyq.d.ts} +8 -2
  61. package/dist/models/index.d.cts +8 -8
  62. package/dist/models/index.d.ts +8 -8
  63. package/dist/orders-B6BmHCJN.d.ts +337 -0
  64. package/dist/orders-ZKP0lqRN.d.cts +337 -0
  65. package/dist/pincode-8u7yWLpQ.d.cts +29 -0
  66. package/dist/pincode-8u7yWLpQ.d.ts +29 -0
  67. package/dist/{pixelEvents-LsealscG.d.ts → pixelEvents-DqJ_CEEr.d.ts} +4 -4
  68. package/dist/{pixelEvents-BtEO5QAR.d.cts → pixelEvents-bahgVW4_.d.cts} +4 -4
  69. package/dist/{product-D9liEtl4.d.cts → product-D4kol-Z-.d.cts} +26 -2
  70. package/dist/{product-D9liEtl4.d.ts → product-D4kol-Z-.d.ts} +26 -2
  71. package/dist/store/index.cjs +20 -30
  72. package/dist/store/index.d.cts +21 -7
  73. package/dist/store/index.d.ts +21 -7
  74. package/dist/store/index.js +9 -26
  75. package/dist/{useAddressForm-DGbEn91-.d.cts → useAddressForm-fMOb5Z-a.d.ts} +6 -1
  76. package/dist/{useAddressForm-cO3Au33k.d.ts → useAddressForm-wleIo78M.d.cts} +6 -1
  77. package/dist/utils/index.cjs +60 -56
  78. package/dist/utils/index.d.cts +24 -9
  79. package/dist/utils/index.d.ts +24 -9
  80. package/dist/utils/index.js +4 -4
  81. package/dist/{wishlist-Cj0sQxiY.d.ts → wishlist-L3fM5-ie.d.ts} +1 -1
  82. package/dist/{wishlist-BakHvIFN.d.cts → wishlist-_0x0r1jt.d.cts} +1 -1
  83. package/package.json +1 -1
  84. package/dist/address-DwBZHzbI.d.cts +0 -19
  85. package/dist/address-DwBZHzbI.d.ts +0 -19
  86. package/dist/cart-DZq1ZEnE.d.ts +0 -153
  87. package/dist/cart-DwMFBmpC.d.cts +0 -153
  88. package/dist/chunk-34Y7Y5FU.cjs +0 -246
  89. package/dist/chunk-VPTN4YXD.js +0 -232
  90. package/dist/orders-B3G4CyhH.d.cts +0 -166
  91. package/dist/orders-Bl-Slh72.d.ts +0 -166
@@ -1,13 +1,15 @@
1
- import { A as Address } from '../address-DwBZHzbI.cjs';
2
- import * as React from 'react';
3
- import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-DwMFBmpC.cjs';
4
- import { O as Order } from '../orders-B3G4CyhH.cjs';
5
- import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-D9liEtl4.cjs';
6
- import { W as Wishlist } from '../wishlist-BakHvIFN.cjs';
7
- import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-BqVWXyy8.cjs';
8
- export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-DGbEn91-.cjs';
1
+ import { A as Address, a as AddressPayload } from '../address-BdIB6IuI.cjs';
2
+ import * as react from 'react';
3
+ import { C as Cart, O as Order, b as Category, U as User, c as Coupon } from '../orders-ZKP0lqRN.cjs';
4
+ import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-D4kol-Z-.cjs';
5
+ import { W as Wishlist } from '../wishlist-_0x0r1jt.cjs';
6
+ import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-DrKY5_9R.cjs';
7
+ export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-wleIo78M.cjs';
8
+ import { A as AddressFormat, f as PincodeMatch, a as AddressSchemaMessages, C as CartLike, b as CheckoutTotals } from '../checkout-totals-CbmXM9L7.cjs';
9
+ import * as formik from 'formik';
9
10
  import 'react-toastify';
10
- import 'formik';
11
+ import 'yup';
12
+ import '../pincode-8u7yWLpQ.cjs';
11
13
 
12
14
  declare const useAddress: () => {
13
15
  data: Address[];
@@ -22,7 +24,7 @@ declare const useCart: (addressId?: number) => {
22
24
  isLoading: boolean;
23
25
  mutate: (addrId?: number, shippingId?: number) => Promise<void>;
24
26
  refetchWithParams: (newAddressId?: number, shippingId?: number) => void;
25
- setData: React.Dispatch<React.SetStateAction<Cart.Root | undefined>>;
27
+ setData: react.Dispatch<react.SetStateAction<Cart.Root | undefined>>;
26
28
  };
27
29
 
28
30
  declare const useOrders: (filters: Record<string, any>) => {
@@ -30,7 +32,7 @@ declare const useOrders: (filters: Record<string, any>) => {
30
32
  error: unknown;
31
33
  isLoading: boolean;
32
34
  mutate: () => Promise<void>;
33
- setData: React.Dispatch<React.SetStateAction<Order.OrderResponse | undefined>>;
35
+ setData: react.Dispatch<react.SetStateAction<Order.OrderResponse | undefined>>;
34
36
  };
35
37
 
36
38
  type PaginationMode = "append" | "replace";
@@ -76,7 +78,7 @@ declare const useWishlist: () => {
76
78
  error: unknown;
77
79
  isLoading: boolean;
78
80
  mutate: () => Promise<void>;
79
- setData: React.Dispatch<React.SetStateAction<Wishlist.Root | undefined>>;
81
+ setData: react.Dispatch<react.SetStateAction<Wishlist.Root | undefined>>;
80
82
  };
81
83
 
82
84
  declare const useProductDetailModal: () => {
@@ -398,4 +400,228 @@ interface UseCouponReturn {
398
400
  }
399
401
  declare function useCoupon(options?: UseCouponOptions): UseCouponReturn;
400
402
 
401
- export { BUY_NOW_PAYLOAD_KEY, type BuyNowError, type BuyNowItem, type InlinePlaceOrderArgs, type PaginationMode, type PublicCheckoutError, type UseBuyNowReturn, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseInlineCheckoutPaymentOptions, type UseInlineCheckoutPaymentReturn, type UsePublicCheckoutReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, useAddress, useBuyNow, useCart, useCheckoutCoupon, useCheckoutPayment, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useInlineCheckoutPayment, useOrders, useProductDetailModal, usePublicCheckout, useServiceFormModal, useShopCheckout, useUserDetails, useVariantSelector, useWishlist };
403
+ /** Countries change about never, so one fetch serves every address form on the page. */
404
+ declare const useCountries: () => {
405
+ countries: CountryModel.Country[];
406
+ error: unknown;
407
+ isLoading: boolean;
408
+ };
409
+ /** Subdivisions (states, provinces, counties) of a country; nothing is fetched without an id. */
410
+ declare const useSubdivisions: (countryId?: number) => {
411
+ states: CountryModel.State1[];
412
+ error: unknown;
413
+ isLoading: boolean;
414
+ };
415
+
416
+ /**
417
+ * The address format for a country. While it loads, or if Google's metadata is
418
+ * unreachable, a fallback built from the local overrides keeps the form usable.
419
+ * Both objects are stable for a given country, so effects keyed on `format`
420
+ * run once per country rather than once per render.
421
+ */
422
+ declare function useAddressFormat(countryCode?: string): {
423
+ format: AddressFormat;
424
+ error: unknown;
425
+ isLoading: boolean;
426
+ };
427
+
428
+ /** What's wrong with the pincode, if anything. The caller words it in the country's labels. */
429
+ type PincodeIssue = {
430
+ kind: "invalid";
431
+ } | {
432
+ kind: "mismatch";
433
+ stateName: string;
434
+ } | {
435
+ kind: "server";
436
+ message: string;
437
+ };
438
+ type UsePincodeLookupOptions = {
439
+ countryCode: string | undefined;
440
+ pincode: string;
441
+ /** The value is complete enough to look up (and the shopper typed it). */
442
+ ready: boolean;
443
+ states: CountryModel.State1[];
444
+ stateId: string;
445
+ /** A recognised pincode. `state` is undefined until the subdivisions load; it's called again then. */
446
+ onMatch: (match: PincodeMatch, state: CountryModel.State1 | undefined) => void;
447
+ /**
448
+ * The store's `pincode_validation_enabled` flag. When omitted, it is read
449
+ * from the `useThemeData` store (hydrated by `ThemeDataInitializer`).
450
+ */
451
+ enabled?: boolean;
452
+ };
453
+ /**
454
+ * Looks the pincode up on our backend as the shopper types, when the store has
455
+ * `pincode_validation_enabled`. Otherwise it does nothing: no request, no
456
+ * prefill, no issue.
457
+ */
458
+ declare function usePincodeLookup({ countryCode, pincode, ready, states, stateId, onMatch, enabled: enabledOption, }: UsePincodeLookupOptions): {
459
+ enabled: boolean;
460
+ loading: boolean;
461
+ issue: PincodeIssue | null;
462
+ areaOptions: string[];
463
+ checkNow: () => void;
464
+ verify: () => Promise<PincodeIssue | null>;
465
+ setServerError: (message: string) => void;
466
+ };
467
+ type UsePincodeLookupReturn = ReturnType<typeof usePincodeLookup>;
468
+
469
+ /** An option for the country and phone-code pickers. `dial` is set on phone options. */
470
+ type CountryOption = {
471
+ value: string;
472
+ label: string;
473
+ dial?: string;
474
+ };
475
+ /** The signed-in shopper's profile, used to prefill contact fields on a new address. */
476
+ type AddressFormProfile = {
477
+ customer_name?: string | null;
478
+ email?: string | null;
479
+ phone?: string | null;
480
+ /** ISO code ("IN") or dial code ("+91"). */
481
+ country_code?: string | null;
482
+ };
483
+ type CountryAwareAddressFormValues = {
484
+ customer_name: string;
485
+ customer_email: string;
486
+ customer_phone: string;
487
+ /** ISO code of the phone's country ("IN"); turned into "+91" on submit. */
488
+ customer_country_code: string;
489
+ country_obj: number | "";
490
+ country_name: string;
491
+ state_obj: string;
492
+ state_name: string;
493
+ city: string;
494
+ pincode: string;
495
+ /** House number and street. */
496
+ address: string;
497
+ /** Optional apartment / building line, folded into `address` on submit. */
498
+ address_line_2: string;
499
+ is_default: boolean;
500
+ };
501
+ declare const EMPTY_ADDRESS_FORM_VALUES: CountryAwareAddressFormValues;
502
+ declare function toAddressPayload(values: CountryAwareAddressFormValues): AddressPayload;
503
+ /** The default message under the postcode field, in the country's own labels. */
504
+ declare function describePincodeIssue(issue: PincodeIssue | null, format: AddressFormat): string | undefined;
505
+ type UseCountryAwareAddressFormOptions = {
506
+ /** A saved address to edit; its own country wins over the visitor's location. */
507
+ address?: Address;
508
+ /** Reads a saved draft. Called once, in the browser, after countries load. */
509
+ loadDraft?: () => Partial<CountryAwareAddressFormValues> | null;
510
+ /**
511
+ * Receives the payload for `/store/customer_address/` (or a guest checkout).
512
+ * The hook never saves on its own: the theme calls `addAddress` /
513
+ * `updateAddress`, and passes a rejected save to `showServerPincodeError`.
514
+ */
515
+ onSubmit: (payload: AddressPayload, values: CountryAwareAddressFormValues) => void | Promise<void>;
516
+ /**
517
+ * The signed-in shopper's profile. Fills empty contact fields on a new
518
+ * address (never when editing). Omit for guests.
519
+ */
520
+ profile?: AddressFormProfile | null;
521
+ /**
522
+ * The store's `pincode_validation_enabled` flag. When omitted, it is read
523
+ * from the `useThemeData` store.
524
+ */
525
+ pincodeValidationEnabled?: boolean;
526
+ /** Country preselected when there's no address, draft or visitor location. Default 105 (India). */
527
+ defaultCountryId?: number;
528
+ /** localStorage key holding the visitor's IP location. Default `"ip_geolocation_data"`. */
529
+ locationCacheKey?: string;
530
+ /** Override any validation message. */
531
+ messages?: Partial<AddressSchemaMessages>;
532
+ /** Override the wording of a pincode problem (invalid / state mismatch / server error). */
533
+ formatPincodeIssue?: (issue: PincodeIssue, format: AddressFormat) => string;
534
+ /** Receives invalid fields on a failed submit. Default: focus the first one inside `formRef`. */
535
+ onInvalid?: (errors: Record<string, unknown>) => void;
536
+ };
537
+ /**
538
+ * Everything the address forms share: countries, states, the country's format,
539
+ * the schema that follows it, postcode autofill, and the phone dial code that
540
+ * follows the delivery country until the shopper picks a different one.
541
+ *
542
+ * Handlers are stable (refs + Formik's stable setters), so the memoised fields
543
+ * in `<AddressFields />` only re-render when their own value changes.
544
+ */
545
+ declare function useCountryAwareAddressForm({ address, loadDraft, onSubmit, profile, pincodeValidationEnabled, defaultCountryId, locationCacheKey, messages, formatPincodeIssue, onInvalid, }: UseCountryAwareAddressFormOptions): {
546
+ formik: {
547
+ initialValues: CountryAwareAddressFormValues;
548
+ initialErrors: formik.FormikErrors<unknown>;
549
+ initialTouched: formik.FormikTouched<unknown>;
550
+ initialStatus: any;
551
+ handleBlur: {
552
+ (e: React.FocusEvent<any, Element>): void;
553
+ <T = any>(fieldOrEvent: T): T extends string ? (e: any) => void : void;
554
+ };
555
+ handleChange: {
556
+ (e: React.ChangeEvent<any>): void;
557
+ <T_1 = string | React.ChangeEvent<any>>(field: T_1): T_1 extends React.ChangeEvent<any> ? void : (e: string | React.ChangeEvent<any>) => void;
558
+ };
559
+ handleReset: (e: any) => void;
560
+ handleSubmit: (e?: React.FormEvent<HTMLFormElement>) => void;
561
+ resetForm: (nextState?: Partial<formik.FormikState<CountryAwareAddressFormValues>> | undefined) => void;
562
+ setErrors: (errors: formik.FormikErrors<CountryAwareAddressFormValues>) => void;
563
+ setFormikState: (stateOrCb: formik.FormikState<CountryAwareAddressFormValues> | ((state: formik.FormikState<CountryAwareAddressFormValues>) => formik.FormikState<CountryAwareAddressFormValues>)) => void;
564
+ setFieldTouched: (field: string, touched?: boolean, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
565
+ setFieldValue: (field: string, value: React.SetStateAction<any>, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
566
+ setFieldError: (field: string, value: string | undefined) => void;
567
+ setStatus: (status: any) => void;
568
+ setSubmitting: (isSubmitting: boolean) => void;
569
+ setTouched: (touched: formik.FormikTouched<CountryAwareAddressFormValues>, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
570
+ setValues: (values: react.SetStateAction<CountryAwareAddressFormValues>, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
571
+ submitForm: () => Promise<any>;
572
+ validateForm: (values?: CountryAwareAddressFormValues | undefined) => Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
573
+ validateField: (name: string) => Promise<void> | Promise<string | undefined>;
574
+ isValid: boolean;
575
+ dirty: boolean;
576
+ unregisterField: (name: string) => void;
577
+ registerField: (name: string, { validate }: any) => void;
578
+ getFieldProps: (nameOrOptions: string | formik.FieldConfig<any>) => formik.FieldInputProps<any>;
579
+ getFieldMeta: (name: string) => formik.FieldMetaProps<any>;
580
+ getFieldHelpers: (name: string) => formik.FieldHelperProps<any>;
581
+ validateOnBlur: boolean;
582
+ validateOnChange: boolean;
583
+ validateOnMount: boolean;
584
+ values: CountryAwareAddressFormValues;
585
+ errors: formik.FormikErrors<CountryAwareAddressFormValues>;
586
+ touched: formik.FormikTouched<CountryAwareAddressFormValues>;
587
+ isSubmitting: boolean;
588
+ isValidating: boolean;
589
+ status?: any;
590
+ submitCount: number;
591
+ };
592
+ formRef: react.MutableRefObject<HTMLFormElement | null>;
593
+ submitting: boolean;
594
+ country: CountryModel.Country | undefined;
595
+ format: AddressFormat;
596
+ formatError: unknown;
597
+ countriesError: unknown;
598
+ countriesLoading: boolean;
599
+ states: CountryModel.State1[];
600
+ statesError: unknown;
601
+ showState: boolean;
602
+ requireState: boolean;
603
+ countryOptions: CountryOption[];
604
+ phoneOptions: CountryOption[];
605
+ cityAutofilled: boolean;
606
+ stateAutofilled: boolean;
607
+ lookupLoading: boolean;
608
+ pincodeIssue: string | undefined;
609
+ areaOptions: string[];
610
+ changeCountry: (iso: string | number) => void;
611
+ changePhoneCountry: (iso: string | number) => void;
612
+ changeState: (e: React.ChangeEvent<HTMLSelectElement>) => void;
613
+ changePostcode: (e: React.ChangeEvent<HTMLInputElement>) => void;
614
+ blurPostcode: (e: React.FocusEvent<HTMLInputElement>) => void;
615
+ addArea: (area: string) => void;
616
+ changePhone: (e: React.ChangeEvent<HTMLInputElement>) => void;
617
+ showServerPincodeError: (error: unknown) => boolean;
618
+ submit: () => Promise<boolean>;
619
+ };
620
+ type CountryAwareAddressFormController = ReturnType<typeof useCountryAwareAddressForm>;
621
+ /** Alias matching the name the themes' `<AddressFields controller>` prop uses. */
622
+ type UseCountryAwareAddressFormReturn = CountryAwareAddressFormController;
623
+
624
+ /** Memoised {@link calculateCartTotals} for a checkout page. */
625
+ declare function useCheckoutTotals(cart: CartLike, customizationOverride?: Cart.CustomizationInput[] | null): CheckoutTotals;
626
+
627
+ export { type AddressFormProfile, BUY_NOW_PAYLOAD_KEY, type BuyNowError, type BuyNowItem, type CountryAwareAddressFormController, type CountryAwareAddressFormValues, type CountryOption, EMPTY_ADDRESS_FORM_VALUES, type InlinePlaceOrderArgs, type PaginationMode, type PincodeIssue, type PublicCheckoutError, type UseBuyNowReturn, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCountryAwareAddressFormOptions, type UseCountryAwareAddressFormReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseInlineCheckoutPaymentOptions, type UseInlineCheckoutPaymentReturn, type UsePincodeLookupOptions, type UsePincodeLookupReturn, type UsePublicCheckoutReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, describePincodeIssue, toAddressPayload, useAddress, useAddressFormat, useBuyNow, useCart, useCheckoutCoupon, useCheckoutPayment, useCheckoutTotals, useCountries, useCountryAwareAddressForm, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useInlineCheckoutPayment, useOrders, usePincodeLookup, useProductDetailModal, usePublicCheckout, useServiceFormModal, useShopCheckout, useSubdivisions, useUserDetails, useVariantSelector, useWishlist };
@@ -1,13 +1,15 @@
1
- import { A as Address } from '../address-DwBZHzbI.js';
2
- import * as React from 'react';
3
- import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-DZq1ZEnE.js';
4
- import { O as Order } from '../orders-Bl-Slh72.js';
5
- import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-D9liEtl4.js';
6
- import { W as Wishlist } from '../wishlist-Cj0sQxiY.js';
7
- import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-DFdnuLjO.js';
8
- export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-cO3Au33k.js';
1
+ import { A as Address, a as AddressPayload } from '../address-BdIB6IuI.js';
2
+ import * as react from 'react';
3
+ import { C as Cart, O as Order, b as Category, U as User, c as Coupon } from '../orders-B6BmHCJN.js';
4
+ import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-D4kol-Z-.js';
5
+ import { W as Wishlist } from '../wishlist-L3fM5-ie.js';
6
+ import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-CDug6LJ_.js';
7
+ export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-fMOb5Z-a.js';
8
+ import { A as AddressFormat, f as PincodeMatch, a as AddressSchemaMessages, C as CartLike, b as CheckoutTotals } from '../checkout-totals-DU8l-Wyb.js';
9
+ import * as formik from 'formik';
9
10
  import 'react-toastify';
10
- import 'formik';
11
+ import 'yup';
12
+ import '../pincode-8u7yWLpQ.js';
11
13
 
12
14
  declare const useAddress: () => {
13
15
  data: Address[];
@@ -22,7 +24,7 @@ declare const useCart: (addressId?: number) => {
22
24
  isLoading: boolean;
23
25
  mutate: (addrId?: number, shippingId?: number) => Promise<void>;
24
26
  refetchWithParams: (newAddressId?: number, shippingId?: number) => void;
25
- setData: React.Dispatch<React.SetStateAction<Cart.Root | undefined>>;
27
+ setData: react.Dispatch<react.SetStateAction<Cart.Root | undefined>>;
26
28
  };
27
29
 
28
30
  declare const useOrders: (filters: Record<string, any>) => {
@@ -30,7 +32,7 @@ declare const useOrders: (filters: Record<string, any>) => {
30
32
  error: unknown;
31
33
  isLoading: boolean;
32
34
  mutate: () => Promise<void>;
33
- setData: React.Dispatch<React.SetStateAction<Order.OrderResponse | undefined>>;
35
+ setData: react.Dispatch<react.SetStateAction<Order.OrderResponse | undefined>>;
34
36
  };
35
37
 
36
38
  type PaginationMode = "append" | "replace";
@@ -76,7 +78,7 @@ declare const useWishlist: () => {
76
78
  error: unknown;
77
79
  isLoading: boolean;
78
80
  mutate: () => Promise<void>;
79
- setData: React.Dispatch<React.SetStateAction<Wishlist.Root | undefined>>;
81
+ setData: react.Dispatch<react.SetStateAction<Wishlist.Root | undefined>>;
80
82
  };
81
83
 
82
84
  declare const useProductDetailModal: () => {
@@ -398,4 +400,228 @@ interface UseCouponReturn {
398
400
  }
399
401
  declare function useCoupon(options?: UseCouponOptions): UseCouponReturn;
400
402
 
401
- export { BUY_NOW_PAYLOAD_KEY, type BuyNowError, type BuyNowItem, type InlinePlaceOrderArgs, type PaginationMode, type PublicCheckoutError, type UseBuyNowReturn, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseInlineCheckoutPaymentOptions, type UseInlineCheckoutPaymentReturn, type UsePublicCheckoutReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, useAddress, useBuyNow, useCart, useCheckoutCoupon, useCheckoutPayment, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useInlineCheckoutPayment, useOrders, useProductDetailModal, usePublicCheckout, useServiceFormModal, useShopCheckout, useUserDetails, useVariantSelector, useWishlist };
403
+ /** Countries change about never, so one fetch serves every address form on the page. */
404
+ declare const useCountries: () => {
405
+ countries: CountryModel.Country[];
406
+ error: unknown;
407
+ isLoading: boolean;
408
+ };
409
+ /** Subdivisions (states, provinces, counties) of a country; nothing is fetched without an id. */
410
+ declare const useSubdivisions: (countryId?: number) => {
411
+ states: CountryModel.State1[];
412
+ error: unknown;
413
+ isLoading: boolean;
414
+ };
415
+
416
+ /**
417
+ * The address format for a country. While it loads, or if Google's metadata is
418
+ * unreachable, a fallback built from the local overrides keeps the form usable.
419
+ * Both objects are stable for a given country, so effects keyed on `format`
420
+ * run once per country rather than once per render.
421
+ */
422
+ declare function useAddressFormat(countryCode?: string): {
423
+ format: AddressFormat;
424
+ error: unknown;
425
+ isLoading: boolean;
426
+ };
427
+
428
+ /** What's wrong with the pincode, if anything. The caller words it in the country's labels. */
429
+ type PincodeIssue = {
430
+ kind: "invalid";
431
+ } | {
432
+ kind: "mismatch";
433
+ stateName: string;
434
+ } | {
435
+ kind: "server";
436
+ message: string;
437
+ };
438
+ type UsePincodeLookupOptions = {
439
+ countryCode: string | undefined;
440
+ pincode: string;
441
+ /** The value is complete enough to look up (and the shopper typed it). */
442
+ ready: boolean;
443
+ states: CountryModel.State1[];
444
+ stateId: string;
445
+ /** A recognised pincode. `state` is undefined until the subdivisions load; it's called again then. */
446
+ onMatch: (match: PincodeMatch, state: CountryModel.State1 | undefined) => void;
447
+ /**
448
+ * The store's `pincode_validation_enabled` flag. When omitted, it is read
449
+ * from the `useThemeData` store (hydrated by `ThemeDataInitializer`).
450
+ */
451
+ enabled?: boolean;
452
+ };
453
+ /**
454
+ * Looks the pincode up on our backend as the shopper types, when the store has
455
+ * `pincode_validation_enabled`. Otherwise it does nothing: no request, no
456
+ * prefill, no issue.
457
+ */
458
+ declare function usePincodeLookup({ countryCode, pincode, ready, states, stateId, onMatch, enabled: enabledOption, }: UsePincodeLookupOptions): {
459
+ enabled: boolean;
460
+ loading: boolean;
461
+ issue: PincodeIssue | null;
462
+ areaOptions: string[];
463
+ checkNow: () => void;
464
+ verify: () => Promise<PincodeIssue | null>;
465
+ setServerError: (message: string) => void;
466
+ };
467
+ type UsePincodeLookupReturn = ReturnType<typeof usePincodeLookup>;
468
+
469
+ /** An option for the country and phone-code pickers. `dial` is set on phone options. */
470
+ type CountryOption = {
471
+ value: string;
472
+ label: string;
473
+ dial?: string;
474
+ };
475
+ /** The signed-in shopper's profile, used to prefill contact fields on a new address. */
476
+ type AddressFormProfile = {
477
+ customer_name?: string | null;
478
+ email?: string | null;
479
+ phone?: string | null;
480
+ /** ISO code ("IN") or dial code ("+91"). */
481
+ country_code?: string | null;
482
+ };
483
+ type CountryAwareAddressFormValues = {
484
+ customer_name: string;
485
+ customer_email: string;
486
+ customer_phone: string;
487
+ /** ISO code of the phone's country ("IN"); turned into "+91" on submit. */
488
+ customer_country_code: string;
489
+ country_obj: number | "";
490
+ country_name: string;
491
+ state_obj: string;
492
+ state_name: string;
493
+ city: string;
494
+ pincode: string;
495
+ /** House number and street. */
496
+ address: string;
497
+ /** Optional apartment / building line, folded into `address` on submit. */
498
+ address_line_2: string;
499
+ is_default: boolean;
500
+ };
501
+ declare const EMPTY_ADDRESS_FORM_VALUES: CountryAwareAddressFormValues;
502
+ declare function toAddressPayload(values: CountryAwareAddressFormValues): AddressPayload;
503
+ /** The default message under the postcode field, in the country's own labels. */
504
+ declare function describePincodeIssue(issue: PincodeIssue | null, format: AddressFormat): string | undefined;
505
+ type UseCountryAwareAddressFormOptions = {
506
+ /** A saved address to edit; its own country wins over the visitor's location. */
507
+ address?: Address;
508
+ /** Reads a saved draft. Called once, in the browser, after countries load. */
509
+ loadDraft?: () => Partial<CountryAwareAddressFormValues> | null;
510
+ /**
511
+ * Receives the payload for `/store/customer_address/` (or a guest checkout).
512
+ * The hook never saves on its own: the theme calls `addAddress` /
513
+ * `updateAddress`, and passes a rejected save to `showServerPincodeError`.
514
+ */
515
+ onSubmit: (payload: AddressPayload, values: CountryAwareAddressFormValues) => void | Promise<void>;
516
+ /**
517
+ * The signed-in shopper's profile. Fills empty contact fields on a new
518
+ * address (never when editing). Omit for guests.
519
+ */
520
+ profile?: AddressFormProfile | null;
521
+ /**
522
+ * The store's `pincode_validation_enabled` flag. When omitted, it is read
523
+ * from the `useThemeData` store.
524
+ */
525
+ pincodeValidationEnabled?: boolean;
526
+ /** Country preselected when there's no address, draft or visitor location. Default 105 (India). */
527
+ defaultCountryId?: number;
528
+ /** localStorage key holding the visitor's IP location. Default `"ip_geolocation_data"`. */
529
+ locationCacheKey?: string;
530
+ /** Override any validation message. */
531
+ messages?: Partial<AddressSchemaMessages>;
532
+ /** Override the wording of a pincode problem (invalid / state mismatch / server error). */
533
+ formatPincodeIssue?: (issue: PincodeIssue, format: AddressFormat) => string;
534
+ /** Receives invalid fields on a failed submit. Default: focus the first one inside `formRef`. */
535
+ onInvalid?: (errors: Record<string, unknown>) => void;
536
+ };
537
+ /**
538
+ * Everything the address forms share: countries, states, the country's format,
539
+ * the schema that follows it, postcode autofill, and the phone dial code that
540
+ * follows the delivery country until the shopper picks a different one.
541
+ *
542
+ * Handlers are stable (refs + Formik's stable setters), so the memoised fields
543
+ * in `<AddressFields />` only re-render when their own value changes.
544
+ */
545
+ declare function useCountryAwareAddressForm({ address, loadDraft, onSubmit, profile, pincodeValidationEnabled, defaultCountryId, locationCacheKey, messages, formatPincodeIssue, onInvalid, }: UseCountryAwareAddressFormOptions): {
546
+ formik: {
547
+ initialValues: CountryAwareAddressFormValues;
548
+ initialErrors: formik.FormikErrors<unknown>;
549
+ initialTouched: formik.FormikTouched<unknown>;
550
+ initialStatus: any;
551
+ handleBlur: {
552
+ (e: React.FocusEvent<any, Element>): void;
553
+ <T = any>(fieldOrEvent: T): T extends string ? (e: any) => void : void;
554
+ };
555
+ handleChange: {
556
+ (e: React.ChangeEvent<any>): void;
557
+ <T_1 = string | React.ChangeEvent<any>>(field: T_1): T_1 extends React.ChangeEvent<any> ? void : (e: string | React.ChangeEvent<any>) => void;
558
+ };
559
+ handleReset: (e: any) => void;
560
+ handleSubmit: (e?: React.FormEvent<HTMLFormElement>) => void;
561
+ resetForm: (nextState?: Partial<formik.FormikState<CountryAwareAddressFormValues>> | undefined) => void;
562
+ setErrors: (errors: formik.FormikErrors<CountryAwareAddressFormValues>) => void;
563
+ setFormikState: (stateOrCb: formik.FormikState<CountryAwareAddressFormValues> | ((state: formik.FormikState<CountryAwareAddressFormValues>) => formik.FormikState<CountryAwareAddressFormValues>)) => void;
564
+ setFieldTouched: (field: string, touched?: boolean, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
565
+ setFieldValue: (field: string, value: React.SetStateAction<any>, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
566
+ setFieldError: (field: string, value: string | undefined) => void;
567
+ setStatus: (status: any) => void;
568
+ setSubmitting: (isSubmitting: boolean) => void;
569
+ setTouched: (touched: formik.FormikTouched<CountryAwareAddressFormValues>, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
570
+ setValues: (values: react.SetStateAction<CountryAwareAddressFormValues>, shouldValidate?: boolean) => Promise<void> | Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
571
+ submitForm: () => Promise<any>;
572
+ validateForm: (values?: CountryAwareAddressFormValues | undefined) => Promise<formik.FormikErrors<CountryAwareAddressFormValues>>;
573
+ validateField: (name: string) => Promise<void> | Promise<string | undefined>;
574
+ isValid: boolean;
575
+ dirty: boolean;
576
+ unregisterField: (name: string) => void;
577
+ registerField: (name: string, { validate }: any) => void;
578
+ getFieldProps: (nameOrOptions: string | formik.FieldConfig<any>) => formik.FieldInputProps<any>;
579
+ getFieldMeta: (name: string) => formik.FieldMetaProps<any>;
580
+ getFieldHelpers: (name: string) => formik.FieldHelperProps<any>;
581
+ validateOnBlur: boolean;
582
+ validateOnChange: boolean;
583
+ validateOnMount: boolean;
584
+ values: CountryAwareAddressFormValues;
585
+ errors: formik.FormikErrors<CountryAwareAddressFormValues>;
586
+ touched: formik.FormikTouched<CountryAwareAddressFormValues>;
587
+ isSubmitting: boolean;
588
+ isValidating: boolean;
589
+ status?: any;
590
+ submitCount: number;
591
+ };
592
+ formRef: react.MutableRefObject<HTMLFormElement | null>;
593
+ submitting: boolean;
594
+ country: CountryModel.Country | undefined;
595
+ format: AddressFormat;
596
+ formatError: unknown;
597
+ countriesError: unknown;
598
+ countriesLoading: boolean;
599
+ states: CountryModel.State1[];
600
+ statesError: unknown;
601
+ showState: boolean;
602
+ requireState: boolean;
603
+ countryOptions: CountryOption[];
604
+ phoneOptions: CountryOption[];
605
+ cityAutofilled: boolean;
606
+ stateAutofilled: boolean;
607
+ lookupLoading: boolean;
608
+ pincodeIssue: string | undefined;
609
+ areaOptions: string[];
610
+ changeCountry: (iso: string | number) => void;
611
+ changePhoneCountry: (iso: string | number) => void;
612
+ changeState: (e: React.ChangeEvent<HTMLSelectElement>) => void;
613
+ changePostcode: (e: React.ChangeEvent<HTMLInputElement>) => void;
614
+ blurPostcode: (e: React.FocusEvent<HTMLInputElement>) => void;
615
+ addArea: (area: string) => void;
616
+ changePhone: (e: React.ChangeEvent<HTMLInputElement>) => void;
617
+ showServerPincodeError: (error: unknown) => boolean;
618
+ submit: () => Promise<boolean>;
619
+ };
620
+ type CountryAwareAddressFormController = ReturnType<typeof useCountryAwareAddressForm>;
621
+ /** Alias matching the name the themes' `<AddressFields controller>` prop uses. */
622
+ type UseCountryAwareAddressFormReturn = CountryAwareAddressFormController;
623
+
624
+ /** Memoised {@link calculateCartTotals} for a checkout page. */
625
+ declare function useCheckoutTotals(cart: CartLike, customizationOverride?: Cart.CustomizationInput[] | null): CheckoutTotals;
626
+
627
+ export { type AddressFormProfile, BUY_NOW_PAYLOAD_KEY, type BuyNowError, type BuyNowItem, type CountryAwareAddressFormController, type CountryAwareAddressFormValues, type CountryOption, EMPTY_ADDRESS_FORM_VALUES, type InlinePlaceOrderArgs, type PaginationMode, type PincodeIssue, type PublicCheckoutError, type UseBuyNowReturn, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseCountryAwareAddressFormOptions, type UseCountryAwareAddressFormReturn, type UseCouponOptions, type UseCouponReturn, type UseGetProductsOptions, type UseGetProductsReturn, type UseInlineCheckoutPaymentOptions, type UseInlineCheckoutPaymentReturn, type UsePincodeLookupOptions, type UsePincodeLookupReturn, type UsePublicCheckoutReturn, type UseShopCheckoutOptions, type UseShopCheckoutReturn, type UseVariantSelectorOptions, type UseVariantSelectorReturn, describePincodeIssue, toAddressPayload, useAddress, useAddressFormat, useBuyNow, useCart, useCheckoutCoupon, useCheckoutPayment, useCheckoutTotals, useCountries, useCountryAwareAddressForm, useCoupon, useGetProductCategories, useGetProductDetails, useGetProducts, useInlineCheckoutPayment, useOrders, usePincodeLookup, useProductDetailModal, usePublicCheckout, useServiceFormModal, useShopCheckout, useSubdivisions, useUserDetails, useVariantSelector, useWishlist };