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