@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.
- package/astro/actions/package.json +4 -0
- package/cjs/dist/astro/actions/custom-checkout.d.ts +50 -0
- package/cjs/dist/astro/actions/custom-checkout.js +53 -0
- package/cjs/dist/astro/actions/index.d.ts +1 -0
- package/cjs/dist/astro/actions/index.js +1 -0
- package/cjs/dist/data-component-tags.d.ts +8 -0
- package/cjs/dist/data-component-tags.js +9 -0
- package/cjs/dist/enums/index.d.ts +2 -0
- package/cjs/dist/enums/index.js +2 -0
- package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
- package/cjs/dist/enums/social-platform-enums.js +27 -0
- package/cjs/dist/enums/sort-enums.d.ts +17 -0
- package/cjs/dist/enums/sort-enums.js +18 -0
- package/cjs/dist/react/Category.d.ts +242 -0
- package/cjs/dist/react/Category.js +235 -0
- package/cjs/dist/react/CategoryList.d.ts +107 -0
- package/cjs/dist/react/CategoryList.js +91 -0
- package/cjs/dist/react/Choice.d.ts +211 -0
- package/cjs/dist/react/Choice.js +213 -0
- package/cjs/dist/react/Option.d.ts +242 -0
- package/cjs/dist/react/Option.js +346 -0
- package/cjs/dist/react/Product.d.ts +1065 -0
- package/cjs/dist/react/Product.js +1157 -0
- package/cjs/dist/react/ProductList.d.ts +400 -0
- package/cjs/dist/react/ProductList.js +368 -0
- package/cjs/dist/react/core/CategoryList.d.ts +194 -0
- package/cjs/dist/react/core/CategoryList.js +180 -0
- package/cjs/dist/react/core/Product.d.ts +225 -0
- package/cjs/dist/react/core/Product.js +190 -0
- package/cjs/dist/react/core/ProductList.d.ts +235 -0
- package/cjs/dist/react/core/ProductList.js +217 -0
- package/cjs/dist/react/core/ProductListFilters.d.ts +138 -0
- package/cjs/dist/react/core/ProductListFilters.js +242 -0
- package/cjs/dist/react/core/ProductListPagination.d.ts +49 -0
- package/cjs/dist/react/core/ProductListPagination.js +41 -0
- package/cjs/dist/react/core/ProductListSort.d.ts +19 -0
- package/cjs/dist/react/core/ProductListSort.js +52 -0
- package/cjs/dist/react/core/ProductModifiers.d.ts +416 -0
- package/cjs/dist/react/core/ProductModifiers.js +413 -0
- package/cjs/dist/react/core/ProductVariantSelector.d.ts +313 -0
- package/cjs/dist/react/core/ProductVariantSelector.js +291 -0
- package/cjs/dist/react/core/SelectedVariant.d.ts +230 -0
- package/cjs/dist/react/core/SelectedVariant.js +269 -0
- package/cjs/dist/react/index.d.ts +6 -0
- package/cjs/dist/react/index.js +6 -0
- package/cjs/dist/react/types.d.ts +8 -0
- package/cjs/dist/react/types.js +9 -0
- package/cjs/dist/server-actions/custom-checkout-action.d.ts +49 -0
- package/cjs/dist/server-actions/custom-checkout-action.js +64 -0
- package/cjs/dist/server-actions/index.d.ts +1 -0
- package/cjs/dist/server-actions/index.js +1 -0
- package/cjs/dist/services/buy-now-service.d.ts +346 -0
- package/cjs/dist/services/buy-now-service.js +197 -0
- package/cjs/dist/services/categories-list-service.d.ts +164 -0
- package/cjs/dist/services/categories-list-service.js +148 -0
- package/cjs/dist/services/index.d.ts +5 -0
- package/cjs/dist/services/index.js +5 -0
- package/cjs/dist/services/pay-now-service.d.ts +214 -0
- package/cjs/dist/services/pay-now-service.js +156 -0
- package/cjs/dist/services/product-modifiers-service.d.ts +34 -0
- package/cjs/dist/services/product-modifiers-service.js +107 -0
- package/cjs/dist/services/product-service.d.ts +177 -0
- package/cjs/dist/services/product-service.js +190 -0
- package/cjs/dist/services/products-list-search-service.d.ts +1 -0
- package/cjs/dist/services/products-list-search-service.js +1 -0
- package/cjs/dist/services/products-list-service.d.ts +429 -0
- package/cjs/dist/services/products-list-service.js +893 -0
- package/cjs/dist/services/selected-variant-service.d.ts +66 -0
- package/cjs/dist/services/selected-variant-service.js +527 -0
- package/cjs/dist/utils/index.d.ts +1 -0
- package/cjs/dist/utils/index.js +30 -0
- package/cjs/dist/utils/url-params.d.ts +73 -0
- package/cjs/dist/utils/url-params.js +114 -0
- package/cjs/package.json +3 -0
- package/dist/astro/actions/custom-checkout.d.ts +50 -0
- package/dist/astro/actions/custom-checkout.js +53 -0
- package/dist/astro/actions/index.d.ts +1 -0
- package/dist/astro/actions/index.js +1 -0
- package/dist/data-component-tags.d.ts +8 -0
- package/dist/data-component-tags.js +9 -0
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/index.js +2 -0
- package/dist/enums/social-platform-enums.d.ts +25 -0
- package/dist/enums/social-platform-enums.js +27 -0
- package/dist/enums/sort-enums.d.ts +17 -0
- package/dist/enums/sort-enums.js +18 -0
- package/dist/react/Category.d.ts +242 -0
- package/dist/react/Category.js +235 -0
- package/dist/react/CategoryList.d.ts +107 -0
- package/dist/react/CategoryList.js +91 -0
- package/dist/react/Choice.d.ts +211 -0
- package/dist/react/Choice.js +213 -0
- package/dist/react/Option.d.ts +242 -0
- package/dist/react/Option.js +346 -0
- package/dist/react/Product.d.ts +1065 -0
- package/dist/react/Product.js +1157 -0
- package/dist/react/ProductList.d.ts +400 -0
- package/dist/react/ProductList.js +368 -0
- package/dist/react/core/CategoryList.d.ts +194 -0
- package/dist/react/core/CategoryList.js +180 -0
- package/dist/react/core/Product.d.ts +225 -0
- package/dist/react/core/Product.js +190 -0
- package/dist/react/core/ProductList.d.ts +235 -0
- package/dist/react/core/ProductList.js +217 -0
- package/dist/react/core/ProductListFilters.d.ts +138 -0
- package/dist/react/core/ProductListFilters.js +242 -0
- package/dist/react/core/ProductListPagination.d.ts +49 -0
- package/dist/react/core/ProductListPagination.js +41 -0
- package/dist/react/core/ProductListSort.d.ts +19 -0
- package/dist/react/core/ProductListSort.js +52 -0
- package/dist/react/core/ProductModifiers.d.ts +416 -0
- package/dist/react/core/ProductModifiers.js +413 -0
- package/dist/react/core/ProductVariantSelector.d.ts +313 -0
- package/dist/react/core/ProductVariantSelector.js +291 -0
- package/dist/react/core/SelectedVariant.d.ts +230 -0
- package/dist/react/core/SelectedVariant.js +269 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +6 -0
- package/dist/react/types.d.ts +8 -0
- package/dist/react/types.js +9 -0
- package/dist/server-actions/custom-checkout-action.d.ts +49 -0
- package/dist/server-actions/custom-checkout-action.js +64 -0
- package/dist/server-actions/index.d.ts +1 -0
- package/dist/server-actions/index.js +1 -0
- package/dist/services/buy-now-service.d.ts +346 -0
- package/dist/services/buy-now-service.js +197 -0
- package/dist/services/categories-list-service.d.ts +164 -0
- package/dist/services/categories-list-service.js +148 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.js +5 -0
- package/dist/services/pay-now-service.d.ts +214 -0
- package/dist/services/pay-now-service.js +156 -0
- package/dist/services/product-modifiers-service.d.ts +34 -0
- package/dist/services/product-modifiers-service.js +107 -0
- package/dist/services/product-service.d.ts +177 -0
- package/dist/services/product-service.js +190 -0
- package/dist/services/products-list-search-service.d.ts +0 -0
- package/dist/services/products-list-search-service.js +1 -0
- package/dist/services/products-list-service.d.ts +429 -0
- package/dist/services/products-list-service.js +893 -0
- package/dist/services/selected-variant-service.d.ts +66 -0
- package/dist/services/selected-variant-service.js +527 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +30 -0
- package/dist/utils/url-params.d.ts +73 -0
- package/dist/utils/url-params.js +114 -0
- package/package.json +89 -0
- package/react/package.json +4 -0
- package/server-actions/package.json +4 -0
- 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
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wix/headless-stores",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prebuild": "cd ../media && yarn build && cd ../ecom && yarn build",
|
|
8
|
+
"build": "npm run build:esm && npm run build:cjs",
|
|
9
|
+
"build:esm": "tsc -p tsconfig.json",
|
|
10
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
11
|
+
"test": "vitest",
|
|
12
|
+
"lint:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
13
|
+
"lint:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md}\""
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"cjs",
|
|
18
|
+
"react",
|
|
19
|
+
"services",
|
|
20
|
+
"server-actions",
|
|
21
|
+
"astro"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
"./react": {
|
|
25
|
+
"types": "./dist/react/index.d.ts",
|
|
26
|
+
"import": "./dist/react/index.js",
|
|
27
|
+
"require": "./cjs/dist/react/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./services": {
|
|
30
|
+
"types": "./dist/services/index.d.ts",
|
|
31
|
+
"import": "./dist/services/index.js",
|
|
32
|
+
"require": "./cjs/dist/services/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./server-actions": {
|
|
35
|
+
"types": "./dist/server-actions/index.d.ts",
|
|
36
|
+
"import": "./dist/server-actions/index.js",
|
|
37
|
+
"require": "./cjs/dist/server-actions/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./astro/actions": {
|
|
40
|
+
"types": "./dist/astro/actions/index.d.ts",
|
|
41
|
+
"import": "./dist/astro/actions/index.js",
|
|
42
|
+
"require": "./cjs/dist/astro/actions/index.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@testing-library/dom": "^10.4.0",
|
|
47
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
48
|
+
"@testing-library/react": "^16.3.0",
|
|
49
|
+
"@types/node": "^20.9.0",
|
|
50
|
+
"@vitest/ui": "^3.1.4",
|
|
51
|
+
"@wix/categories": "^1.0.133",
|
|
52
|
+
"@wix/stores": "^1.0.551",
|
|
53
|
+
"jsdom": "^26.1.0",
|
|
54
|
+
"prettier": "^3.4.2",
|
|
55
|
+
"typescript": "^5.8.3",
|
|
56
|
+
"vitest": "^3.1.4"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
60
|
+
"@wix/auto_sdk_bookings_availability-calendar": "^1.0.155",
|
|
61
|
+
"@wix/auto_sdk_categories_categories": "^1.0.62",
|
|
62
|
+
"@wix/auto_sdk_stores_customizations-v-3": "^1.0.26",
|
|
63
|
+
"@wix/auto_sdk_stores_inventory-items-v-3": "^1.0.26",
|
|
64
|
+
"@wix/auto_sdk_stores_products-v-3": "^1.0.53",
|
|
65
|
+
"@wix/auto_sdk_stores_read-only-variants-v-3": "^1.0.23",
|
|
66
|
+
"@wix/ecom": "^1.0.1461",
|
|
67
|
+
"@wix/essentials": "^0.1.24",
|
|
68
|
+
"@wix/headless-ecom": "0.0.0",
|
|
69
|
+
"@wix/headless-media": "0.0.0",
|
|
70
|
+
"@wix/headless-utils": "0.0.0",
|
|
71
|
+
"@wix/redirects": "^1.0.83",
|
|
72
|
+
"@wix/services-definitions": "^0.1.4",
|
|
73
|
+
"@wix/services-manager-react": "^0.1.26"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"@wix/headless-components": "workspace:*"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"registry": "https://registry.npmjs.org/",
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"wix": {
|
|
83
|
+
"artifact": {
|
|
84
|
+
"artifactId": "headless-stores",
|
|
85
|
+
"groupId": "com.wixpress.headless-components"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"falconPackageHash": "7653948b615ac703ee86eb8d5519ffba34d7becae41c1e3fe7a33c8e"
|
|
89
|
+
}
|