@wix/headless-stores 0.0.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 (150) hide show
  1. package/astro/actions/package.json +4 -0
  2. package/cjs/dist/astro/actions/custom-checkout.d.ts +50 -0
  3. package/cjs/dist/astro/actions/custom-checkout.js +53 -0
  4. package/cjs/dist/astro/actions/index.d.ts +1 -0
  5. package/cjs/dist/astro/actions/index.js +1 -0
  6. package/cjs/dist/data-component-tags.d.ts +8 -0
  7. package/cjs/dist/data-component-tags.js +9 -0
  8. package/cjs/dist/enums/index.d.ts +2 -0
  9. package/cjs/dist/enums/index.js +2 -0
  10. package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
  11. package/cjs/dist/enums/social-platform-enums.js +27 -0
  12. package/cjs/dist/enums/sort-enums.d.ts +17 -0
  13. package/cjs/dist/enums/sort-enums.js +18 -0
  14. package/cjs/dist/react/Category.d.ts +242 -0
  15. package/cjs/dist/react/Category.js +235 -0
  16. package/cjs/dist/react/CategoryList.d.ts +107 -0
  17. package/cjs/dist/react/CategoryList.js +91 -0
  18. package/cjs/dist/react/Choice.d.ts +211 -0
  19. package/cjs/dist/react/Choice.js +213 -0
  20. package/cjs/dist/react/Option.d.ts +242 -0
  21. package/cjs/dist/react/Option.js +346 -0
  22. package/cjs/dist/react/Product.d.ts +1065 -0
  23. package/cjs/dist/react/Product.js +1157 -0
  24. package/cjs/dist/react/ProductList.d.ts +400 -0
  25. package/cjs/dist/react/ProductList.js +368 -0
  26. package/cjs/dist/react/core/CategoryList.d.ts +194 -0
  27. package/cjs/dist/react/core/CategoryList.js +180 -0
  28. package/cjs/dist/react/core/Product.d.ts +225 -0
  29. package/cjs/dist/react/core/Product.js +190 -0
  30. package/cjs/dist/react/core/ProductList.d.ts +235 -0
  31. package/cjs/dist/react/core/ProductList.js +217 -0
  32. package/cjs/dist/react/core/ProductListFilters.d.ts +138 -0
  33. package/cjs/dist/react/core/ProductListFilters.js +242 -0
  34. package/cjs/dist/react/core/ProductListPagination.d.ts +49 -0
  35. package/cjs/dist/react/core/ProductListPagination.js +41 -0
  36. package/cjs/dist/react/core/ProductListSort.d.ts +19 -0
  37. package/cjs/dist/react/core/ProductListSort.js +52 -0
  38. package/cjs/dist/react/core/ProductModifiers.d.ts +416 -0
  39. package/cjs/dist/react/core/ProductModifiers.js +413 -0
  40. package/cjs/dist/react/core/ProductVariantSelector.d.ts +313 -0
  41. package/cjs/dist/react/core/ProductVariantSelector.js +291 -0
  42. package/cjs/dist/react/core/SelectedVariant.d.ts +230 -0
  43. package/cjs/dist/react/core/SelectedVariant.js +269 -0
  44. package/cjs/dist/react/index.d.ts +6 -0
  45. package/cjs/dist/react/index.js +6 -0
  46. package/cjs/dist/react/types.d.ts +8 -0
  47. package/cjs/dist/react/types.js +9 -0
  48. package/cjs/dist/server-actions/custom-checkout-action.d.ts +49 -0
  49. package/cjs/dist/server-actions/custom-checkout-action.js +64 -0
  50. package/cjs/dist/server-actions/index.d.ts +1 -0
  51. package/cjs/dist/server-actions/index.js +1 -0
  52. package/cjs/dist/services/buy-now-service.d.ts +346 -0
  53. package/cjs/dist/services/buy-now-service.js +197 -0
  54. package/cjs/dist/services/categories-list-service.d.ts +164 -0
  55. package/cjs/dist/services/categories-list-service.js +148 -0
  56. package/cjs/dist/services/index.d.ts +5 -0
  57. package/cjs/dist/services/index.js +5 -0
  58. package/cjs/dist/services/pay-now-service.d.ts +214 -0
  59. package/cjs/dist/services/pay-now-service.js +156 -0
  60. package/cjs/dist/services/product-modifiers-service.d.ts +34 -0
  61. package/cjs/dist/services/product-modifiers-service.js +107 -0
  62. package/cjs/dist/services/product-service.d.ts +177 -0
  63. package/cjs/dist/services/product-service.js +190 -0
  64. package/cjs/dist/services/products-list-search-service.d.ts +1 -0
  65. package/cjs/dist/services/products-list-search-service.js +1 -0
  66. package/cjs/dist/services/products-list-service.d.ts +429 -0
  67. package/cjs/dist/services/products-list-service.js +893 -0
  68. package/cjs/dist/services/selected-variant-service.d.ts +66 -0
  69. package/cjs/dist/services/selected-variant-service.js +527 -0
  70. package/cjs/dist/utils/index.d.ts +1 -0
  71. package/cjs/dist/utils/index.js +30 -0
  72. package/cjs/dist/utils/url-params.d.ts +73 -0
  73. package/cjs/dist/utils/url-params.js +114 -0
  74. package/cjs/package.json +3 -0
  75. package/dist/astro/actions/custom-checkout.d.ts +50 -0
  76. package/dist/astro/actions/custom-checkout.js +53 -0
  77. package/dist/astro/actions/index.d.ts +1 -0
  78. package/dist/astro/actions/index.js +1 -0
  79. package/dist/data-component-tags.d.ts +8 -0
  80. package/dist/data-component-tags.js +9 -0
  81. package/dist/enums/index.d.ts +2 -0
  82. package/dist/enums/index.js +2 -0
  83. package/dist/enums/social-platform-enums.d.ts +25 -0
  84. package/dist/enums/social-platform-enums.js +27 -0
  85. package/dist/enums/sort-enums.d.ts +17 -0
  86. package/dist/enums/sort-enums.js +18 -0
  87. package/dist/react/Category.d.ts +242 -0
  88. package/dist/react/Category.js +235 -0
  89. package/dist/react/CategoryList.d.ts +107 -0
  90. package/dist/react/CategoryList.js +91 -0
  91. package/dist/react/Choice.d.ts +211 -0
  92. package/dist/react/Choice.js +213 -0
  93. package/dist/react/Option.d.ts +242 -0
  94. package/dist/react/Option.js +346 -0
  95. package/dist/react/Product.d.ts +1065 -0
  96. package/dist/react/Product.js +1157 -0
  97. package/dist/react/ProductList.d.ts +400 -0
  98. package/dist/react/ProductList.js +368 -0
  99. package/dist/react/core/CategoryList.d.ts +194 -0
  100. package/dist/react/core/CategoryList.js +180 -0
  101. package/dist/react/core/Product.d.ts +225 -0
  102. package/dist/react/core/Product.js +190 -0
  103. package/dist/react/core/ProductList.d.ts +235 -0
  104. package/dist/react/core/ProductList.js +217 -0
  105. package/dist/react/core/ProductListFilters.d.ts +138 -0
  106. package/dist/react/core/ProductListFilters.js +242 -0
  107. package/dist/react/core/ProductListPagination.d.ts +49 -0
  108. package/dist/react/core/ProductListPagination.js +41 -0
  109. package/dist/react/core/ProductListSort.d.ts +19 -0
  110. package/dist/react/core/ProductListSort.js +52 -0
  111. package/dist/react/core/ProductModifiers.d.ts +416 -0
  112. package/dist/react/core/ProductModifiers.js +413 -0
  113. package/dist/react/core/ProductVariantSelector.d.ts +313 -0
  114. package/dist/react/core/ProductVariantSelector.js +291 -0
  115. package/dist/react/core/SelectedVariant.d.ts +230 -0
  116. package/dist/react/core/SelectedVariant.js +269 -0
  117. package/dist/react/index.d.ts +6 -0
  118. package/dist/react/index.js +6 -0
  119. package/dist/react/types.d.ts +8 -0
  120. package/dist/react/types.js +9 -0
  121. package/dist/server-actions/custom-checkout-action.d.ts +49 -0
  122. package/dist/server-actions/custom-checkout-action.js +64 -0
  123. package/dist/server-actions/index.d.ts +1 -0
  124. package/dist/server-actions/index.js +1 -0
  125. package/dist/services/buy-now-service.d.ts +346 -0
  126. package/dist/services/buy-now-service.js +197 -0
  127. package/dist/services/categories-list-service.d.ts +164 -0
  128. package/dist/services/categories-list-service.js +148 -0
  129. package/dist/services/index.d.ts +5 -0
  130. package/dist/services/index.js +5 -0
  131. package/dist/services/pay-now-service.d.ts +214 -0
  132. package/dist/services/pay-now-service.js +156 -0
  133. package/dist/services/product-modifiers-service.d.ts +34 -0
  134. package/dist/services/product-modifiers-service.js +107 -0
  135. package/dist/services/product-service.d.ts +177 -0
  136. package/dist/services/product-service.js +190 -0
  137. package/dist/services/products-list-search-service.d.ts +0 -0
  138. package/dist/services/products-list-search-service.js +1 -0
  139. package/dist/services/products-list-service.d.ts +429 -0
  140. package/dist/services/products-list-service.js +893 -0
  141. package/dist/services/selected-variant-service.d.ts +66 -0
  142. package/dist/services/selected-variant-service.js +527 -0
  143. package/dist/utils/index.d.ts +1 -0
  144. package/dist/utils/index.js +30 -0
  145. package/dist/utils/url-params.d.ts +73 -0
  146. package/dist/utils/url-params.js +114 -0
  147. package/package.json +89 -0
  148. package/react/package.json +4 -0
  149. package/server-actions/package.json +4 -0
  150. package/services/package.json +4 -0
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Utility class for managing URL parameters in web applications.
3
+ * Provides methods to parse, update, and retrieve URL search parameters with support for multiple values.
4
+ *
5
+ * @class URLParamsUtils
6
+ */
7
+ export declare class URLParamsUtils {
8
+ /**
9
+ * Parses URLSearchParams into a more convenient format that supports multiple values for the same key.
10
+ * Converts multiple parameters with the same key into an array.
11
+ *
12
+ * @static
13
+ * @param {URLSearchParams} searchParams - The URLSearchParams object to parse
14
+ * @returns {Record<string, string | string[]>} Object with parameter names as keys and values as strings or arrays
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // URL: ?color=red&color=blue&size=large
19
+ * const params = new URLSearchParams('color=red&color=blue&size=large');
20
+ * const parsed = URLParamsUtils.parseSearchParams(params);
21
+ * // Result: { color: ['red', 'blue'], size: 'large' }
22
+ * ```
23
+ */
24
+ static parseSearchParams(searchParams: URLSearchParams): Record<string, string | string[]>;
25
+ /**
26
+ * Updates the current page URL with new parameters without causing a page reload.
27
+ * Supports multiple values for the same parameter key.
28
+ *
29
+ * @static
30
+ * @param {Record<string, string | string[]>} params - Object with parameter names and values to set
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Update URL with single and multiple values
35
+ * URLParamsUtils.updateURL({
36
+ * category: 'electronics',
37
+ * color: ['red', 'blue'],
38
+ * price: '100'
39
+ * });
40
+ * // URL becomes: ?category=electronics&color=red&color=blue&price=100
41
+ * ```
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Clear all parameters by passing empty object
46
+ * URLParamsUtils.updateURL({});
47
+ * // URL becomes: current-path (no query string)
48
+ * ```
49
+ */
50
+ static updateURL(params: Record<string, string | string[]>): void;
51
+ /**
52
+ * Gets the current URL parameters parsed into a convenient format.
53
+ * Returns an empty object when running in server-side environment.
54
+ *
55
+ * @static
56
+ * @returns {Record<string, string | string[]>} Object with current URL parameters
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Current URL: ?category=electronics&color=red&color=blue
61
+ * const params = URLParamsUtils.getURLParams();
62
+ * // Result: { category: 'electronics', color: ['red', 'blue'] }
63
+ * ```
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // Server-side usage
68
+ * const params = URLParamsUtils.getURLParams();
69
+ * // Result: {} (empty object)
70
+ * ```
71
+ */
72
+ static getURLParams(): Record<string, string | string[]>;
73
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Utility class for managing URL parameters in web applications.
3
+ * Provides methods to parse, update, and retrieve URL search parameters with support for multiple values.
4
+ *
5
+ * @class URLParamsUtils
6
+ */
7
+ export class URLParamsUtils {
8
+ /**
9
+ * Parses URLSearchParams into a more convenient format that supports multiple values for the same key.
10
+ * Converts multiple parameters with the same key into an array.
11
+ *
12
+ * @static
13
+ * @param {URLSearchParams} searchParams - The URLSearchParams object to parse
14
+ * @returns {Record<string, string | string[]>} Object with parameter names as keys and values as strings or arrays
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // URL: ?color=red&color=blue&size=large
19
+ * const params = new URLSearchParams('color=red&color=blue&size=large');
20
+ * const parsed = URLParamsUtils.parseSearchParams(params);
21
+ * // Result: { color: ['red', 'blue'], size: 'large' }
22
+ * ```
23
+ */
24
+ static parseSearchParams(searchParams) {
25
+ const params = {};
26
+ // Parse all parameters
27
+ for (const [key, value] of searchParams.entries()) {
28
+ if (params[key]) {
29
+ // Convert to array if multiple values
30
+ if (Array.isArray(params[key])) {
31
+ params[key].push(value);
32
+ }
33
+ else {
34
+ params[key] = [params[key], value];
35
+ }
36
+ }
37
+ else {
38
+ params[key] = value;
39
+ }
40
+ }
41
+ return params;
42
+ }
43
+ /**
44
+ * Updates the current page URL with new parameters without causing a page reload.
45
+ * Supports multiple values for the same parameter key.
46
+ *
47
+ * @static
48
+ * @param {Record<string, string | string[]>} params - Object with parameter names and values to set
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // Update URL with single and multiple values
53
+ * URLParamsUtils.updateURL({
54
+ * category: 'electronics',
55
+ * color: ['red', 'blue'],
56
+ * price: '100'
57
+ * });
58
+ * // URL becomes: ?category=electronics&color=red&color=blue&price=100
59
+ * ```
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * // Clear all parameters by passing empty object
64
+ * URLParamsUtils.updateURL({});
65
+ * // URL becomes: current-path (no query string)
66
+ * ```
67
+ */
68
+ static updateURL(params) {
69
+ if (typeof window === 'undefined')
70
+ return;
71
+ const url = new URL(window.location.href);
72
+ const urlParams = new URLSearchParams();
73
+ // Add all parameters
74
+ Object.entries(params).forEach(([key, value]) => {
75
+ if (Array.isArray(value)) {
76
+ value.forEach((v) => urlParams.append(key, v));
77
+ }
78
+ else if (value) {
79
+ urlParams.set(key, value);
80
+ }
81
+ });
82
+ // Update URL without page reload
83
+ const newURL = urlParams.toString()
84
+ ? `${url.pathname}?${urlParams.toString()}`
85
+ : url.pathname;
86
+ window.history.replaceState({}, '', newURL);
87
+ }
88
+ /**
89
+ * Gets the current URL parameters parsed into a convenient format.
90
+ * Returns an empty object when running in server-side environment.
91
+ *
92
+ * @static
93
+ * @returns {Record<string, string | string[]>} Object with current URL parameters
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * // Current URL: ?category=electronics&color=red&color=blue
98
+ * const params = URLParamsUtils.getURLParams();
99
+ * // Result: { category: 'electronics', color: ['red', 'blue'] }
100
+ * ```
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * // Server-side usage
105
+ * const params = URLParamsUtils.getURLParams();
106
+ * // Result: {} (empty object)
107
+ * ```
108
+ */
109
+ static getURLParams() {
110
+ if (typeof window === 'undefined')
111
+ return {};
112
+ return this.parseSearchParams(new URLSearchParams(window.location.search));
113
+ }
114
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,50 @@
1
+ import { type CustomLineItemCheckoutOptions } from '../../server-actions/index.js';
2
+ /**
3
+ * Creates an Astro action factory for custom checkout functionality with line items.
4
+ *
5
+ * This factory function generates an Astro action that can be used to create custom
6
+ * checkout URLs with specific line items. It wraps the Wix headless stores server
7
+ * action functionality in an Astro-compatible action format.
8
+ *
9
+ * @param {CustomLineItemCheckoutOptions} factoryOpts - Configuration options for the custom checkout
10
+ * @param {string} factoryOpts.productName - The name of the product for the custom line item
11
+ * @param {string} [factoryOpts.priceDescription] - A description for the price, which will be displayed to the customer
12
+ * @param {Array<{content: string, title: string}>} [factoryOpts.policies] - An array of policies related to this custom item
13
+ * @param {string} [factoryOpts.postFlowUrl] - The URL to redirect the user to after the checkout is successfully completed
14
+ * @param {number} [factoryOpts.quantity=1] - The quantity of the product
15
+ * @param {string} factoryOpts.price - The price of the product
16
+ *
17
+ * @returns {ReturnType<typeof defineAction>} An Astro action that when invoked returns checkout URL
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Define the action with your configuration
22
+ * const customCheckoutAction = customCheckoutActionFactory({
23
+ * productName: "Premium Subscription",
24
+ * price: "29.99",
25
+ * priceDescription: "per month",
26
+ * quantity: 1,
27
+ * postFlowUrl: "https://yoursite.com/thank-you",
28
+ * policies: [
29
+ * {
30
+ * title: "Refund Policy",
31
+ * content: "30-day money back guarantee"
32
+ * }
33
+ * ]
34
+ * });
35
+ *
36
+ * export const server = {
37
+ * checkout: customCheckoutAction
38
+ * };
39
+ *
40
+ * // Use in your Astro component or API route
41
+ * import { actions } from "astro:actions";
42
+ * const checkoutUrl = await actions.customCheckoutAction();
43
+ * ```
44
+ *
45
+ * @see {@link https://docs.astro.build/en/guides/actions/} Astro Actions Documentation
46
+ * @see {@link https://dev.wix.com/docs/sdk/headless/api-reference/stores/checkout} Wix Stores Checkout API
47
+ */
48
+ export declare const customCheckoutActionFactory: (factoryOpts: CustomLineItemCheckoutOptions) => ((input?: any) => Promise<import("astro:actions").SafeResult<never, string>>) & {
49
+ orThrow: (input?: any) => Promise<string>;
50
+ } & string;
@@ -0,0 +1,53 @@
1
+ /// <reference types="astro/env" />
2
+ // @ts-ignore
3
+ import { defineAction } from 'astro:actions';
4
+ import { getCustomLineItemCheckoutURLFactory, } from '../../server-actions/index.js';
5
+ /**
6
+ * Creates an Astro action factory for custom checkout functionality with line items.
7
+ *
8
+ * This factory function generates an Astro action that can be used to create custom
9
+ * checkout URLs with specific line items. It wraps the Wix headless stores server
10
+ * action functionality in an Astro-compatible action format.
11
+ *
12
+ * @param {CustomLineItemCheckoutOptions} factoryOpts - Configuration options for the custom checkout
13
+ * @param {string} factoryOpts.productName - The name of the product for the custom line item
14
+ * @param {string} [factoryOpts.priceDescription] - A description for the price, which will be displayed to the customer
15
+ * @param {Array<{content: string, title: string}>} [factoryOpts.policies] - An array of policies related to this custom item
16
+ * @param {string} [factoryOpts.postFlowUrl] - The URL to redirect the user to after the checkout is successfully completed
17
+ * @param {number} [factoryOpts.quantity=1] - The quantity of the product
18
+ * @param {string} factoryOpts.price - The price of the product
19
+ *
20
+ * @returns {ReturnType<typeof defineAction>} An Astro action that when invoked returns checkout URL
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Define the action with your configuration
25
+ * const customCheckoutAction = customCheckoutActionFactory({
26
+ * productName: "Premium Subscription",
27
+ * price: "29.99",
28
+ * priceDescription: "per month",
29
+ * quantity: 1,
30
+ * postFlowUrl: "https://yoursite.com/thank-you",
31
+ * policies: [
32
+ * {
33
+ * title: "Refund Policy",
34
+ * content: "30-day money back guarantee"
35
+ * }
36
+ * ]
37
+ * });
38
+ *
39
+ * export const server = {
40
+ * checkout: customCheckoutAction
41
+ * };
42
+ *
43
+ * // Use in your Astro component or API route
44
+ * import { actions } from "astro:actions";
45
+ * const checkoutUrl = await actions.customCheckoutAction();
46
+ * ```
47
+ *
48
+ * @see {@link https://docs.astro.build/en/guides/actions/} Astro Actions Documentation
49
+ * @see {@link https://dev.wix.com/docs/sdk/headless/api-reference/stores/checkout} Wix Stores Checkout API
50
+ */
51
+ export const customCheckoutActionFactory = (factoryOpts) => defineAction({
52
+ handler: () => getCustomLineItemCheckoutURLFactory(factoryOpts)(),
53
+ });
@@ -0,0 +1 @@
1
+ export * from './custom-checkout.js';
@@ -0,0 +1 @@
1
+ export * from './custom-checkout.js';
@@ -0,0 +1,8 @@
1
+ export declare enum DataComponentTags {
2
+ categoryListRoot = "stores.category-list-root",
3
+ categoryRoot = "stores.category-root",
4
+ choiceRoot = "stores.choice-root",
5
+ optionRoot = "stores.option-root",
6
+ productListRoot = "stores.product-list-root",
7
+ productRoot = "stores.product-root"
8
+ }
@@ -0,0 +1,9 @@
1
+ export var DataComponentTags;
2
+ (function (DataComponentTags) {
3
+ DataComponentTags["categoryListRoot"] = "stores.category-list-root";
4
+ DataComponentTags["categoryRoot"] = "stores.category-root";
5
+ DataComponentTags["choiceRoot"] = "stores.choice-root";
6
+ DataComponentTags["optionRoot"] = "stores.option-root";
7
+ DataComponentTags["productListRoot"] = "stores.product-list-root";
8
+ DataComponentTags["productRoot"] = "stores.product-root";
9
+ })(DataComponentTags || (DataComponentTags = {}));
@@ -0,0 +1,2 @@
1
+ export * from './sort-enums.js';
2
+ export * from './social-platform-enums.js';
@@ -0,0 +1,2 @@
1
+ export * from './sort-enums.js';
2
+ export * from './social-platform-enums.js';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Business logic enums for social sharing platforms (headless layer)
3
+ */
4
+ /**
5
+ * Enum for social sharing platforms (business identifiers)
6
+ */
7
+ export declare enum SocialPlatform {
8
+ FACEBOOK = "facebook",
9
+ TWITTER = "twitter",
10
+ LINKEDIN = "linkedin",
11
+ WHATSAPP = "whatsapp",
12
+ EMAIL = "email",
13
+ CLIPBOARD = "clipboard",
14
+ NATIVE = "native"
15
+ }
16
+ /**
17
+ * Enum for social platform share URLs (business logic)
18
+ */
19
+ export declare enum SocialPlatformShareUrl {
20
+ FACEBOOK = "https://www.facebook.com/sharer/sharer.php",
21
+ TWITTER = "https://twitter.com/intent/tweet",
22
+ LINKEDIN = "https://www.linkedin.com/sharing/share-offsite/",
23
+ WHATSAPP = "https://wa.me/",
24
+ EMAIL = "mailto:"
25
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Business logic enums for social sharing platforms (headless layer)
3
+ */
4
+ /**
5
+ * Enum for social sharing platforms (business identifiers)
6
+ */
7
+ export var SocialPlatform;
8
+ (function (SocialPlatform) {
9
+ SocialPlatform["FACEBOOK"] = "facebook";
10
+ SocialPlatform["TWITTER"] = "twitter";
11
+ SocialPlatform["LINKEDIN"] = "linkedin";
12
+ SocialPlatform["WHATSAPP"] = "whatsapp";
13
+ SocialPlatform["EMAIL"] = "email";
14
+ SocialPlatform["CLIPBOARD"] = "clipboard";
15
+ SocialPlatform["NATIVE"] = "native";
16
+ })(SocialPlatform || (SocialPlatform = {}));
17
+ /**
18
+ * Enum for social platform share URLs (business logic)
19
+ */
20
+ export var SocialPlatformShareUrl;
21
+ (function (SocialPlatformShareUrl) {
22
+ SocialPlatformShareUrl["FACEBOOK"] = "https://www.facebook.com/sharer/sharer.php";
23
+ SocialPlatformShareUrl["TWITTER"] = "https://twitter.com/intent/tweet";
24
+ SocialPlatformShareUrl["LINKEDIN"] = "https://www.linkedin.com/sharing/share-offsite/";
25
+ SocialPlatformShareUrl["WHATSAPP"] = "https://wa.me/";
26
+ SocialPlatformShareUrl["EMAIL"] = "mailto:";
27
+ })(SocialPlatformShareUrl || (SocialPlatformShareUrl = {}));
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Enum for sort types used in the store
3
+ * Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
4
+ * while this enum represents user-facing sort options
5
+ */
6
+ export declare enum SortType {
7
+ NEWEST = "newest",
8
+ NAME_ASC = "name_asc",
9
+ NAME_DESC = "name_desc",
10
+ PRICE_ASC = "price_asc",
11
+ PRICE_DESC = "price_desc",
12
+ RECOMMENDED = "recommended"
13
+ }
14
+ /**
15
+ * Default sort type
16
+ */
17
+ export declare const DEFAULT_SORT_TYPE = SortType.NEWEST;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Enum for sort types used in the store
3
+ * Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
4
+ * while this enum represents user-facing sort options
5
+ */
6
+ export var SortType;
7
+ (function (SortType) {
8
+ SortType["NEWEST"] = "newest";
9
+ SortType["NAME_ASC"] = "name_asc";
10
+ SortType["NAME_DESC"] = "name_desc";
11
+ SortType["PRICE_ASC"] = "price_asc";
12
+ SortType["PRICE_DESC"] = "price_desc";
13
+ SortType["RECOMMENDED"] = "recommended";
14
+ })(SortType || (SortType = {}));
15
+ /**
16
+ * Default sort type
17
+ */
18
+ export const DEFAULT_SORT_TYPE = SortType.NEWEST;
@@ -0,0 +1,242 @@
1
+ import React from 'react';
2
+ import { categories } from '@wix/categories';
3
+ import { AsChildChildren } from '@wix/headless-utils/react';
4
+ export type Category = categories.Category;
5
+ /**
6
+ * Props for Category.Root component
7
+ */
8
+ export interface CategoryRootProps {
9
+ /** Category data */
10
+ category: Category;
11
+ /** Child components */
12
+ children: React.ReactNode;
13
+ }
14
+ /**
15
+ * Props for Category.Trigger component
16
+ */
17
+ export interface CategoryTriggerProps {
18
+ /** Whether to render as a child component */
19
+ asChild?: boolean;
20
+ /** Custom render function when using asChild */
21
+ children?: AsChildChildren<{
22
+ category: Category;
23
+ isSelected: boolean;
24
+ onSelect: () => void;
25
+ setIsSelected: (isSelected: boolean) => void;
26
+ }>;
27
+ /** Callback when category is selected */
28
+ onSelect?: (category: Category) => void;
29
+ /** CSS classes to apply to the default element */
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Props for Category.Label component
34
+ */
35
+ export interface CategoryLabelProps {
36
+ /** Whether to render as a child component */
37
+ asChild?: boolean;
38
+ /** Custom render function when using asChild */
39
+ children?: AsChildChildren<{
40
+ name: string;
41
+ category: Category;
42
+ }>;
43
+ /** CSS classes to apply to the default element */
44
+ className?: string;
45
+ }
46
+ /**
47
+ * Props for Category.ID component
48
+ */
49
+ export interface CategoryIDProps {
50
+ /** Whether to render as a child component */
51
+ asChild?: boolean;
52
+ /** Custom render function when using asChild */
53
+ children?: AsChildChildren<{
54
+ id: string;
55
+ category: Category;
56
+ }>;
57
+ /** CSS classes to apply to the default element */
58
+ className?: string;
59
+ }
60
+ /**
61
+ * Props for Category.Raw component
62
+ */
63
+ export interface CategoryRawProps {
64
+ /** Whether to render as a child component */
65
+ asChild?: boolean;
66
+ /** Custom render function when using asChild */
67
+ children?: AsChildChildren<{
68
+ category: Category;
69
+ isSelected: boolean;
70
+ }>;
71
+ /** CSS classes to apply to the default element */
72
+ className?: string;
73
+ }
74
+ /**
75
+ * Props for CategoryFilter component
76
+ */
77
+ export interface CategoryFilterProps {
78
+ /** Whether to render as a child component */
79
+ asChild?: boolean;
80
+ /** Custom render function when using asChild */
81
+ children?: AsChildChildren<{
82
+ selectedCategory: Category | null;
83
+ setSelectedCategory: (category: Category | null) => void;
84
+ }>;
85
+ /** CSS classes to apply to the default element */
86
+ className?: string;
87
+ /** Label for the selected category display */
88
+ label?: string;
89
+ }
90
+ /**
91
+ * Root container for a single category item.
92
+ * This component sets up the necessary services for managing category state
93
+ * and provides category context to child components.
94
+ *
95
+ * @order 1
96
+ * @component
97
+ * @example
98
+ * ```tsx
99
+ * import { Category } from '@wix/headless-stores/react';
100
+ *
101
+ * <Category.Root category={category}>
102
+ * <Category.Trigger />
103
+ * <Category.Label />
104
+ * <Category.ID />
105
+ * </Category.Root>
106
+ * ```
107
+ */
108
+ export declare const Root: React.ForwardRefExoticComponent<CategoryRootProps & React.RefAttributes<HTMLElement>>;
109
+ /**
110
+ * Interactive element for selecting or triggering category actions.
111
+ * Provides category data and selection state to custom render functions.
112
+ *
113
+ * @component
114
+ * @example
115
+ * ```tsx
116
+ * // Default usage
117
+ * <Category.Trigger className="px-4 py-2 rounded border hover:bg-surface-hover" />
118
+ *
119
+ * // Custom rendering with forwardRef
120
+ * <Category.Trigger asChild>
121
+ * {React.forwardRef(({category, isSelected, onSelect, ...props}, ref) => (
122
+ * <button
123
+ * ref={ref}
124
+ * {...props}
125
+ * onClick={onSelect}
126
+ * className={`px-4 py-2 rounded transition-colors ${
127
+ * isSelected
128
+ * ? 'bg-brand-primary text-white'
129
+ * : 'border border-surface-subtle hover:bg-surface-hover'
130
+ * }`}
131
+ * >
132
+ * {category.name}
133
+ * </button>
134
+ * ))}
135
+ * </Category.Trigger>
136
+ * ```
137
+ */
138
+ export declare const Trigger: React.ForwardRefExoticComponent<CategoryTriggerProps & React.RefAttributes<HTMLButtonElement>>;
139
+ /**
140
+ * Displays the category name or label.
141
+ * Provides category name and full category data to custom render functions.
142
+ *
143
+ * @component
144
+ * @example
145
+ * ```tsx
146
+ * // Default usage
147
+ * <Category.Label className="text-lg font-medium text-content-primary" />
148
+ *
149
+ * // Custom rendering with forwardRef
150
+ * <Category.Label asChild>
151
+ * {React.forwardRef(({name, category, ...props}, ref) => (
152
+ * <span ref={ref} {...props} className="text-lg font-medium text-content-primary">
153
+ * {name}
154
+ * {category.numberOfProducts > 0 && (
155
+ * <span className="text-sm text-content-muted ml-2">
156
+ * ({category.numberOfProducts})
157
+ * </span>
158
+ * )}
159
+ * </span>
160
+ * ))}
161
+ * </Category.Label>
162
+ * ```
163
+ */
164
+ export declare const Label: React.ForwardRefExoticComponent<CategoryLabelProps & React.RefAttributes<HTMLElement>>;
165
+ /**
166
+ * Provides access to the category ID for advanced use cases.
167
+ * Typically used for tracking, analytics, or hidden form fields.
168
+ *
169
+ * @component
170
+ * @example
171
+ * ```tsx
172
+ * // Default usage (hidden by default)
173
+ * <Category.ID className="hidden" />
174
+ *
175
+ * // Custom rendering with forwardRef
176
+ * <Category.ID asChild>
177
+ * {React.forwardRef(({id, category, ...props}, ref) => (
178
+ * <span
179
+ * ref={ref}
180
+ * {...props}
181
+ * data-category-id={id}
182
+ * className="sr-only"
183
+ * >
184
+ * Category ID: {id}
185
+ * </span>
186
+ * ))}
187
+ * </Category.ID>
188
+ * ```
189
+ */
190
+ export declare const ID: React.ForwardRefExoticComponent<CategoryIDProps & React.RefAttributes<HTMLElement>>;
191
+ /**
192
+ * Provides access to the full category data for advanced use cases.
193
+ * Useful for custom implementations that need access to all category properties.
194
+ *
195
+ * @component
196
+ * @example
197
+ * ```tsx
198
+ * // Custom rendering with forwardRef
199
+ * <Category.Raw asChild>
200
+ * {React.forwardRef(({category, ...props}, ref) => (
201
+ * <div
202
+ * ref={ref}
203
+ * {...props}
204
+ * data-category-id={category._id}
205
+ * className="category-raw-data"
206
+ * >
207
+ * <pre>{JSON.stringify(category, null, 2)}</pre>
208
+ * </div>
209
+ * ))}
210
+ * </Category.Raw>
211
+ * ```
212
+ */
213
+ export declare const Raw: React.ForwardRefExoticComponent<CategoryRawProps & React.RefAttributes<HTMLElement>>;
214
+ /**
215
+ * Category filter component that provides category selection functionality.
216
+ * Provides selected category state and selection controls to custom render functions.
217
+ *
218
+ * @component
219
+ * @example
220
+ * ```tsx
221
+ * // Default usage
222
+ * <CategoryFilter className="category-filter" />
223
+ *
224
+ * // With custom label
225
+ * <CategoryFilter label="Current Category:" />
226
+ *
227
+ * // Custom rendering with forwardRef
228
+ * <CategoryFilter asChild>
229
+ * {React.forwardRef(({selectedCategory, setSelectedCategory, ...props}, ref) => (
230
+ * <div ref={ref} {...props} className="custom-category-filter">
231
+ * {selectedCategory && (
232
+ * <span>Selected: {selectedCategory.name}</span>
233
+ * )}
234
+ * <button onClick={() => setSelectedCategory(null)}>
235
+ * Clear Selection
236
+ * </button>
237
+ * </div>
238
+ * ))}
239
+ * </CategoryFilter>
240
+ * ```
241
+ */
242
+ export declare const CategoryFilter: React.ForwardRefExoticComponent<CategoryFilterProps & React.RefAttributes<HTMLElement>>;