@tapcart/mobile-components 0.11.8 → 0.12.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/dist/components/hooks/use-block-conditional-rendering.d.ts +2 -2
- package/dist/components/hooks/use-block-conditional-rendering.d.ts.map +1 -1
- package/dist/components/hooks/use-block-conditional-rendering.js +27 -14
- package/dist/components/hooks/use-infinite-scroll.d.ts +2 -1
- package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
- package/dist/components/hooks/use-infinite-scroll.js +7 -3
- package/dist/components/hooks/use-product-options.js +3 -2
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-products.js +3 -1
- package/dist/components/hooks/use-reviews.d.ts.map +1 -1
- package/dist/components/hooks/use-reviews.js +8 -1
- package/dist/components/hooks/use-sort-filter.d.ts.map +1 -1
- package/dist/components/hooks/use-sort-filter.js +27 -5
- package/dist/components/libs/cache/ProductsLocalStorage.js +1 -1
- package/dist/components/libs/sort-filter/custom-search.js +1 -1
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +2 -4
- package/dist/components/ui/drawer.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/lib/utils.d.ts +9 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +60 -11
- package/dist/styles.css +12 -0
- package/dist/tests/utils.test.js +200 -1
- package/package.json +1 -1
|
@@ -4,8 +4,8 @@ export declare const useBlockConditionalRendering: (_props: {
|
|
|
4
4
|
apiUrl: string;
|
|
5
5
|
deviceVariables: any;
|
|
6
6
|
customerVariables: any;
|
|
7
|
-
}, _block: PhoenixBlock) => {
|
|
7
|
+
}, _block: PhoenixBlock, mobileComponentOverrides?: any) => {
|
|
8
8
|
shouldShow: boolean;
|
|
9
|
-
isLoading:
|
|
9
|
+
isLoading: any;
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=use-block-conditional-rendering.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAezB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY,6BACO,GAAG;;;CA4Q/B,CAAA"}
|
|
@@ -11,23 +11,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { useMemo } from "react";
|
|
14
|
-
import { useProducts } from "./use-products";
|
|
15
|
-
import { useCollection } from "./use-collection";
|
|
14
|
+
import { useProducts as mclUseProducts } from "./use-products";
|
|
15
|
+
import { useCollection as mclUseCollection } from "./use-collection";
|
|
16
16
|
import { useSearchParams } from "next/navigation";
|
|
17
|
-
import { gidFromId, countNumberOfTagsInState, getEnvState, shouldShowBlock, evaluateConditions, } from "../../lib/utils";
|
|
18
|
-
export const useBlockConditionalRendering = (_props, _block) => {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f;
|
|
20
|
-
const
|
|
17
|
+
import { gidFromId, countNumberOfTagsInState, getEnvState, shouldShowBlock, evaluateConditions, parseBCP47Locale, } from "../../lib/utils";
|
|
18
|
+
export const useBlockConditionalRendering = (_props, _block, mobileComponentOverrides) => {
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
20
|
+
const _k = ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions) || {}, { enabled: conditionalsV1IsEnabled = false, exclude: isInverse = false } = _k, restOfProps = __rest(_k, ["enabled", "exclude"]);
|
|
21
21
|
const { _version = 1, conditions, enabled: conditionalsV2IsEnabled = false, } = (_block === null || _block === void 0 ? void 0 : _block.visibilityConditions) || {};
|
|
22
22
|
const isConditionalsEnabled = conditionalsV1IsEnabled || conditionalsV2IsEnabled;
|
|
23
23
|
const blockState = restOfProps;
|
|
24
24
|
const { appId = "", apiUrl = "", deviceVariables, customerVariables } = _props;
|
|
25
25
|
const searchParams = useSearchParams();
|
|
26
|
-
|
|
27
|
-
const
|
|
26
|
+
const [deviceLanguage = "en", deviceCountry = "US"] = parseBCP47Locale(deviceVariables === null || deviceVariables === void 0 ? void 0 : deviceVariables.locale);
|
|
27
|
+
const country = (_c = (_b = deviceVariables === null || deviceVariables === void 0 ? void 0 : deviceVariables.countryCode) !== null && _b !== void 0 ? _b : searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("country")) !== null && _c !== void 0 ? _c : deviceCountry;
|
|
28
|
+
const language = (_e = (_d = deviceVariables === null || deviceVariables === void 0 ? void 0 : deviceVariables.language) !== null && _d !== void 0 ? _d : searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("lang")) !== null && _e !== void 0 ? _e : deviceLanguage;
|
|
28
29
|
const { id: deviceId = "" } = deviceVariables || {};
|
|
29
|
-
const productId = (
|
|
30
|
-
const productHandle = (
|
|
30
|
+
const productId = (_f = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("productId")) !== null && _f !== void 0 ? _f : undefined;
|
|
31
|
+
const productHandle = (_g = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("productHandle")) !== null && _g !== void 0 ? _g : undefined;
|
|
31
32
|
const location = {
|
|
32
33
|
country,
|
|
33
34
|
language,
|
|
@@ -65,8 +66,14 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
65
66
|
isConditionalsEnabled,
|
|
66
67
|
]);
|
|
67
68
|
const shouldFetchProduct = isConditionalsEnabled && (productId || productHandle);
|
|
68
|
-
const
|
|
69
|
+
const useProducts = (mobileComponentOverrides === null || mobileComponentOverrides === void 0 ? void 0 : mobileComponentOverrides.useProducts) || mclUseProducts;
|
|
70
|
+
const useProductsArguments = (mobileComponentOverrides === null || mobileComponentOverrides === void 0 ? void 0 : mobileComponentOverrides.useProducts)
|
|
69
71
|
? {
|
|
72
|
+
productIds: productId ? [gidFromId(productId)] : [],
|
|
73
|
+
productHandles: productHandle ? [productHandle] : [],
|
|
74
|
+
metafields: productMetafieldsQuery,
|
|
75
|
+
}
|
|
76
|
+
: {
|
|
70
77
|
productIds: productId ? [gidFromId(productId)] : [],
|
|
71
78
|
baseURL: apiUrl,
|
|
72
79
|
productHandles: productHandle ? [productHandle] : [],
|
|
@@ -75,8 +82,13 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
75
82
|
language,
|
|
76
83
|
country,
|
|
77
84
|
},
|
|
85
|
+
};
|
|
86
|
+
const useProductsSkipArguments = (mobileComponentOverrides === null || mobileComponentOverrides === void 0 ? void 0 : mobileComponentOverrides.useProducts)
|
|
87
|
+
? {
|
|
88
|
+
skip: true,
|
|
78
89
|
}
|
|
79
|
-
: null
|
|
90
|
+
: null;
|
|
91
|
+
const { products, error: useProductsError, isLoading: isProductsLoading, } = useProducts(shouldFetchProduct ? useProductsArguments : useProductsSkipArguments);
|
|
80
92
|
const blockCollectionMetafields = useMemo(() => {
|
|
81
93
|
var _a;
|
|
82
94
|
if (!isConditionalsEnabled) {
|
|
@@ -128,9 +140,10 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
128
140
|
.map((m) => `${m.namespace}.${m.key}`)
|
|
129
141
|
.join(",");
|
|
130
142
|
}, [collectionMetafieldsQuery, isConditionalsEnabled]);
|
|
131
|
-
const collectionId = (
|
|
132
|
-
const collectionHandle = (
|
|
143
|
+
const collectionId = (_h = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("collectionId")) !== null && _h !== void 0 ? _h : undefined;
|
|
144
|
+
const collectionHandle = (_j = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("collectionHandle")) !== null && _j !== void 0 ? _j : undefined;
|
|
133
145
|
const shouldFetchCollection = isConditionalsEnabled && (collectionId || collectionHandle);
|
|
146
|
+
const useCollection = (mobileComponentOverrides === null || mobileComponentOverrides === void 0 ? void 0 : mobileComponentOverrides.useCollection) || mclUseCollection;
|
|
134
147
|
const { specificCollection = {}, error: useCollectionError, loading: isCollectionLoading, } = useCollection({
|
|
135
148
|
appId,
|
|
136
149
|
apiUrl,
|
|
@@ -19,6 +19,7 @@ interface UseInfiniteScrollProps {
|
|
|
19
19
|
interval?: number;
|
|
20
20
|
customFetcher?: (...args: any[]) => Promise<any>;
|
|
21
21
|
customGetKey?: (pageIndex: number, previousPageData: any | null, ...args: any[]) => any;
|
|
22
|
+
shouldSkipFetch?: boolean;
|
|
22
23
|
}
|
|
23
24
|
interface UseInfiniteScrollReturn {
|
|
24
25
|
data: PageData[] | undefined;
|
|
@@ -35,6 +36,6 @@ interface UseInfiniteScrollReturn {
|
|
|
35
36
|
}
|
|
36
37
|
export declare const formatSearchParamsAsNextQueryVariables: (searchParams: ReadonlyURLSearchParams) => {};
|
|
37
38
|
declare const constructURL: (apiURL: string) => string;
|
|
38
|
-
declare const useInfiniteScroll: ({ searchClient, initialData, queryVariables: queryVariableProps, direction, productLimit, threshold, interval, customFetcher, customGetKey, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
39
|
+
declare const useInfiniteScroll: ({ searchClient, initialData, queryVariables: queryVariableProps, direction, productLimit, threshold, interval, customFetcher, customGetKey, shouldSkipFetch: shouldSkipFetchProp, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
39
40
|
export { useInfiniteScroll, constructURL };
|
|
40
41
|
//# sourceMappingURL=use-infinite-scroll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACxC;AAED,UAAU,sBAAsB;IAE9B,YAAY,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAGxC,WAAW,CAAC,EAAE,QAAQ,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAGpC,SAAS,CAAC,EAAE,UAAU,GAAG,YAAY,CAAA;IACrC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAChD,YAAY,CAAC,EAAE,CACb,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,GAAG,GAAG,IAAI,EAC5B,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,OAAO,EAAE,OAAO,E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,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,oBAAoB,EAAE,GAAG,EAAE,CAAA;IAC3B,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,eAAO,MAAM,sCAAsC,iBACnC,uBAAuB,OAsBtC,CAAA;AAED,QAAA,MAAM,YAAY,WAAY,MAAM,WAGnC,CAAA;AAED,QAAA,MAAM,iBAAiB,wLAgBpB,sBAAsB,KAAG,uBAwR3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -48,7 +48,7 @@ searchClient,
|
|
|
48
48
|
initialData, queryVariables: queryVariableProps,
|
|
49
49
|
// Common props
|
|
50
50
|
direction = "vertical", productLimit = Infinity, threshold = 0.01, interval = 33, // ~2 frames
|
|
51
|
-
customFetcher, customGetKey, }) => {
|
|
51
|
+
customFetcher, customGetKey, shouldSkipFetch: shouldSkipFetchProp, }) => {
|
|
52
52
|
var _a, _b, _c, _d, _e;
|
|
53
53
|
const searchParams = useSearchParams();
|
|
54
54
|
const productCount = useRef(0);
|
|
@@ -79,7 +79,9 @@ customFetcher, customGetKey, }) => {
|
|
|
79
79
|
const hasQuery = useMemo(() => {
|
|
80
80
|
return Boolean(currentSearchQuery);
|
|
81
81
|
}, [currentSearchQuery]);
|
|
82
|
-
const shouldSkipFetch =
|
|
82
|
+
const shouldSkipFetch = shouldSkipFetchProp !== undefined
|
|
83
|
+
? shouldSkipFetchProp
|
|
84
|
+
: !hasCollection && !hasQuery;
|
|
83
85
|
// Search client approach - getKey and fetcher
|
|
84
86
|
const searchClientGetKey = useMemo(() => customGetKey || (searchClient === null || searchClient === void 0 ? void 0 : searchClient.getKey), [customGetKey, searchClient === null || searchClient === void 0 ? void 0 : searchClient.getKey]);
|
|
85
87
|
const searchClientFetcher = useMemo(() => customFetcher || (searchClient === null || searchClient === void 0 ? void 0 : searchClient.fetcher), [customFetcher, searchClient === null || searchClient === void 0 ? void 0 : searchClient.fetcher]);
|
|
@@ -124,9 +126,11 @@ customFetcher, customGetKey, }) => {
|
|
|
124
126
|
return searchClientGetKey(pageIndex, previousPageData);
|
|
125
127
|
}
|
|
126
128
|
: (pageIndex, previousPageData) => {
|
|
129
|
+
if (customGetKey)
|
|
130
|
+
return customGetKey(pageIndex, previousPageData, queryVariables !== null && queryVariables !== void 0 ? queryVariables : {});
|
|
127
131
|
if (shouldSkipFetch)
|
|
128
132
|
return null;
|
|
129
|
-
return
|
|
133
|
+
return apiGetKey(pageIndex, previousPageData, queryVariables !== null && queryVariables !== void 0 ? queryVariables : {});
|
|
130
134
|
};
|
|
131
135
|
const fetcher = usingSearchClient
|
|
132
136
|
? (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -20,8 +20,9 @@ export function useProductOptions(variants, selectedVariantId) {
|
|
|
20
20
|
}, [safeVariants]);
|
|
21
21
|
const getSelectedOptions = useMemo(() => {
|
|
22
22
|
return (variant) => {
|
|
23
|
+
var _a;
|
|
23
24
|
const selectedOptions = {};
|
|
24
|
-
variant.selectedOptions.forEach((option) => {
|
|
25
|
+
(_a = variant.selectedOptions) === null || _a === void 0 ? void 0 : _a.forEach((option) => {
|
|
25
26
|
selectedOptions[option.name] = option.value;
|
|
26
27
|
});
|
|
27
28
|
return selectedOptions;
|
|
@@ -52,7 +53,7 @@ export function useProductOptions(variants, selectedVariantId) {
|
|
|
52
53
|
useEffect(() => {
|
|
53
54
|
setSelectedOptions(initializeSelectedOptions(selectedVariantId));
|
|
54
55
|
}, [safeVariants, initializeSelectedOptions, selectedVariantId]);
|
|
55
|
-
const selectedVariant = useMemo(() => safeVariants.find((v) => v.selectedOptions.every((o) => selectedOptions[o.name] === o.value)), [safeVariants, selectedOptions]);
|
|
56
|
+
const selectedVariant = useMemo(() => safeVariants.find((v) => { var _a; return (_a = v.selectedOptions) === null || _a === void 0 ? void 0 : _a.every((o) => selectedOptions[o.name] === o.value); }), [safeVariants, selectedOptions]);
|
|
56
57
|
return {
|
|
57
58
|
selectedOptions,
|
|
58
59
|
handleSelect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAK1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,OAAO,EAAE,GAAG,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AACD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;IACrB,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,KAC3B;QACE,EAAE,EAAE,MAAM,CAAA;QACV,MAAM,EAAE,MAAM,CAAA;KACf,GACD,SAAS,CAAA;CACd,CAA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A;CACd,CAAA;AAqDD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CA0J7E"}
|
|
@@ -106,7 +106,9 @@ export function useProducts(props) {
|
|
|
106
106
|
const data = yield res.json();
|
|
107
107
|
// Check if data is an object with a products property or an array
|
|
108
108
|
const productsArray = Array.isArray(data) ? data : data.products || [];
|
|
109
|
-
const cachedProducts = productsArray
|
|
109
|
+
const cachedProducts = productsArray
|
|
110
|
+
.filter((product) => !!product)
|
|
111
|
+
.map((product) => {
|
|
110
112
|
productsLocalStorage.setCacheItem(product);
|
|
111
113
|
return product;
|
|
112
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AAGzB,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACvC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAA;IACjB,MAAM,EAAE,CAAC,MAAM,CAAC,CAAA;IAChB,MAAM,EACF,MAAM,GACN,UAAU,GACV,YAAY,GACZ,MAAM,GACN,QAAQ,GACR,eAAe,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,iBAAiB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AA;IACrB,oBAAoB,CAAC,EAAE,GAAG,CAAA;IAC1B,eAAe,CAAC,EAAE;QAChB,YAAY,EAAE,MAAM,CAAA;QACpB,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAA;CACF,CAAA;AA2ED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,gBAAgB,CA8E1E;AAED,KAAK,wBAAwB,GAAG,gBAAgB,GAAG;IACjD,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAA;CACrC,CAAA;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,eAAe,GAAG,IAAI,GAC5B,wBAAwB,CAmK1B"}
|
|
@@ -3,6 +3,10 @@ import { useCallback, useEffect, useRef } from "react";
|
|
|
3
3
|
import useSWR from "swr";
|
|
4
4
|
import useSWRInfinite from "swr/infinite";
|
|
5
5
|
import { useInView } from "react-intersection-observer";
|
|
6
|
+
const YOTPO = "yotpo";
|
|
7
|
+
const OKENDO = "okendo";
|
|
8
|
+
const STAMPED = "stamped";
|
|
9
|
+
const SUPPORTED_PROVIDERS = [YOTPO, OKENDO, STAMPED];
|
|
6
10
|
const reviewsMockData = [
|
|
7
11
|
{
|
|
8
12
|
id: "dabbba8a-1188-4423-8aa2-1789dca7d67c",
|
|
@@ -91,7 +95,10 @@ export function useReviews(props) {
|
|
|
91
95
|
if (limit) {
|
|
92
96
|
queryParams.set("limit", String(limit));
|
|
93
97
|
}
|
|
94
|
-
if (dataType === null ||
|
|
98
|
+
if (dataType === null ||
|
|
99
|
+
productId === null ||
|
|
100
|
+
productId.length === 0 ||
|
|
101
|
+
!SUPPORTED_PROVIDERS.includes(provider)) {
|
|
95
102
|
url = null;
|
|
96
103
|
}
|
|
97
104
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-sort-filter.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-sort-filter.ts"],"names":[],"mappings":"AAC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kB,CAAA;AAExE,OAAO,EACL,cAAc,EACd,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACpB,MAAM,wCAAwC,CAAA;AAI/C,UAAU,kBAAkB;IAC1B,WAAW,EAAE,QAAQ,CAAA;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,KAAK,MAAM,GAAG,CAAA;IAC/C,YAAY,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;CACzC;AAED,UAAU,QAAQ;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,cAAc,EAAE,CAAA;IAC/B,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACxC;AAED,UAAU,mBAAmB;IAC3B,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1B,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,OAAO,CAAA;CACzB;AAED,UAAU,cAAc;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,2BAA2B,EAAE,2BAA2B,CAAA;IACxD,WAAW,EAAE,mBAAmB,EAAE,CAAA;IAClC,qBAAqB,EAAE,OAAO,CAAA;IAC9B,YAAY,EAAE,WAAW,EAAE,CAAA;CAC5B;AAeD,QAAA,MAAM,aAAa,+DAKhB,kBAAkB,KAAG,mBAmGvB,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -22,27 +22,49 @@ const fetcher = ({ apiURL, body }) => fetch(constructURL(apiURL), {
|
|
|
22
22
|
.then((res) => res.json())
|
|
23
23
|
.catch((error) => console.error(error));
|
|
24
24
|
const useSortFilter = ({ initialData, queryVariables, dynamicKey, searchClient, }) => {
|
|
25
|
-
|
|
25
|
+
var _a;
|
|
26
|
+
// Extract current critical params
|
|
27
|
+
const currentCollectionId = queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.collectionId;
|
|
28
|
+
const currentCollectionHandle = queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.collectionHandle;
|
|
29
|
+
const currentSearchQuery = (_a = queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.searchParams) === null || _a === void 0 ? void 0 : _a.searchQuery;
|
|
30
|
+
// Determine whether we should skip fetching
|
|
31
|
+
// Always skip if searchClient is provided (it handles fetching)
|
|
32
|
+
// Otherwise, skip if there's no collection and no query
|
|
33
|
+
const hasCollection = useMemo(() => {
|
|
34
|
+
return Boolean(currentCollectionId || currentCollectionHandle);
|
|
35
|
+
}, [currentCollectionId, currentCollectionHandle]);
|
|
36
|
+
const hasQuery = useMemo(() => {
|
|
37
|
+
return Boolean(currentSearchQuery);
|
|
38
|
+
}, [currentSearchQuery]);
|
|
39
|
+
const shouldSkipFetch = Boolean(searchClient) || (!hasCollection && !hasQuery);
|
|
40
|
+
const shouldFetch = queryVariables && Object.keys(queryVariables).length > 0 && !shouldSkipFetch;
|
|
26
41
|
const { data: sortFilterData, isLoading } = useSWR(shouldFetch
|
|
27
42
|
? { apiUrl: initialData.sortFilterURL, body: Object.assign({}, queryVariables) }
|
|
28
43
|
: null, ({ apiUrl, body }) => fetcher({ apiURL: apiUrl, body }), { revalidateOnFocus: false });
|
|
29
44
|
const getKey = () => {
|
|
30
|
-
if (
|
|
31
|
-
!sortFilterData
|
|
32
|
-
|
|
45
|
+
if (shouldSkipFetch ||
|
|
46
|
+
!sortFilterData ||
|
|
47
|
+
!sortFilterData.dynamicFiltersEnabled)
|
|
33
48
|
return null;
|
|
34
49
|
return Object.assign(Object.assign({}, sortFilterData.queryVariables), (initialData.uiFilterState && {
|
|
35
50
|
filterCategories: initialData.uiFilterState,
|
|
36
51
|
}));
|
|
37
52
|
};
|
|
38
53
|
const memoizedDynamicKey = useCallback(() => {
|
|
54
|
+
if (shouldSkipFetch)
|
|
55
|
+
return null;
|
|
39
56
|
if (dynamicKey && !searchClient) {
|
|
40
57
|
return dynamicKey(sortFilterData === null || sortFilterData === void 0 ? void 0 : sortFilterData.queryVariables);
|
|
41
58
|
}
|
|
42
59
|
else {
|
|
43
60
|
return null;
|
|
44
61
|
}
|
|
45
|
-
}, [
|
|
62
|
+
}, [
|
|
63
|
+
shouldSkipFetch,
|
|
64
|
+
dynamicKey,
|
|
65
|
+
sortFilterData === null || sortFilterData === void 0 ? void 0 : sortFilterData.queryVariables,
|
|
66
|
+
searchClient,
|
|
67
|
+
]);
|
|
46
68
|
const memoizedFetch = useMemo(() => {
|
|
47
69
|
return (body) => fetcher({ apiURL: initialData.filtersURL, body });
|
|
48
70
|
}, [initialData.filtersURL]);
|
|
@@ -57,7 +57,7 @@ export default class ProductsLocalStorage extends AppStudioCache {
|
|
|
57
57
|
}
|
|
58
58
|
setCacheItem(product, cache, shouldExpire = true) {
|
|
59
59
|
var _a, _b;
|
|
60
|
-
if (!((_a = product.handle) === null || _a === void 0 ? void 0 : _a.length) || !((_b = product.id) === null || _b === void 0 ? void 0 : _b.length))
|
|
60
|
+
if (!((_a = product === null || product === void 0 ? void 0 : product.handle) === null || _a === void 0 ? void 0 : _a.length) || !((_b = product === null || product === void 0 ? void 0 : product.id) === null || _b === void 0 ? void 0 : _b.length))
|
|
61
61
|
return;
|
|
62
62
|
if (shouldExpire) {
|
|
63
63
|
this.expireCacheData();
|
|
@@ -6,7 +6,7 @@ export class CustomSearch extends KMP {
|
|
|
6
6
|
const filtersToApply = filters.reduce((acc, it) => {
|
|
7
7
|
const inner = it.filters.reduce((innerAcc, f) => {
|
|
8
8
|
if (f.isSelected) {
|
|
9
|
-
innerAcc.push(`${it.id}
|
|
9
|
+
innerAcc.push(`${it.id}::${f.tag}`);
|
|
10
10
|
}
|
|
11
11
|
return innerAcc;
|
|
12
12
|
}, []);
|
|
@@ -1 +1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7 +19,7 @@ const badgeVariants = cva("inline-flex items-center justify-center gap-1 py-1 px
|
|
|
19
19
|
alignment: {
|
|
20
20
|
start: "",
|
|
21
21
|
end: "",
|
|
22
|
-
center: "
|
|
22
|
+
center: "",
|
|
23
23
|
},
|
|
24
24
|
cornerRadius: {
|
|
25
25
|
rounded: "",
|
|
@@ -70,9 +70,7 @@ function Badge(_a) {
|
|
|
70
70
|
const badgeHeightOverride = badgeHeight
|
|
71
71
|
? { height: badgeHeight, minHeight: badgeHeight }
|
|
72
72
|
: {};
|
|
73
|
-
const badgeWidthOverride = badgeWidth
|
|
74
|
-
? { width: badgeWidth, minWidth: badgeWidth }
|
|
75
|
-
: {};
|
|
73
|
+
const badgeWidthOverride = badgeWidth ? { minWidth: badgeWidth } : {};
|
|
76
74
|
const BadgeText = () => (_jsx(Text, Object.assign({ type: size === "plp-layout" ? "body-primary" : "body-secondary", className: cn("text-productBadging-text", textAlignment && "flex-1" // Take full width when alignment is specified
|
|
77
75
|
), fontColor: fontColor, fontFamily: fontFamily, fontWeight: fontWeight, fontSize: fontSize, textAlignment: textAlignment }, { children: children })));
|
|
78
76
|
return (_jsx("div", Object.assign({ className: cn(badgeVariants({ alignment, cornerRadius }), className) }, props, { style: Object.assign(Object.assign(Object.assign(Object.assign({}, style), backgroundColorOverride), badgeHeightOverride), badgeWidthOverride) }, { children: type === "icon-and-text" ? (_jsxs(_Fragment, { children: [(icon || iconUrl) && (_jsx(Icon, { name: icon, url: iconUrl, color: fontColor, size: size === "carousels" || size === "plp-layout-small"
|
|
@@ -51,7 +51,7 @@ const DrawerContentBase = React.forwardRef((_a, ref) => {
|
|
|
51
51
|
const baseStyles = isSheet
|
|
52
52
|
? { height: "calc(100dvh - 112px)" }
|
|
53
53
|
: { maxHeight: maxHeight || "calc(100dvh - 112px)" };
|
|
54
|
-
return (_jsxs(DrawerPortal, Object.assign({ containerRef: containerRef }, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: Object.assign(Object.assign({}, baseStyles), style), className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] })));
|
|
54
|
+
return (_jsxs(DrawerPortal, Object.assign({ containerRef: containerRef }, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: Object.assign(Object.assign({}, baseStyles), style), className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground pb-safe", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] })));
|
|
55
55
|
});
|
|
56
56
|
DrawerContentBase.displayName = "DrawerContentBase";
|
|
57
57
|
const DrawerHeaderBase = (_a) => {
|
|
@@ -66,7 +66,7 @@ const DrawerTitle = React.forwardRef((_a, ref) => {
|
|
|
66
66
|
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
|
67
67
|
const DrawerFooter = (_a) => {
|
|
68
68
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
69
|
-
return (_jsx("div", Object.assign({ className: cn("mt-auto flex flex-row gap-2 pb-
|
|
69
|
+
return (_jsx("div", Object.assign({ className: cn("mt-auto flex flex-row gap-2 pb-2 pt-4 pl-4 pr-4 border-t border-coreColors-dividingLines", className) }, props)));
|
|
70
70
|
};
|
|
71
71
|
DrawerFooter.displayName = "DrawerFooter";
|
|
72
72
|
const DrawerDescription = React.forwardRef((_a, ref) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { cn, cva,
|
|
1
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, } from "./lib/utils";
|
|
2
2
|
export type { WishlistEntryMatch } from "./lib/utils";
|
|
3
3
|
export * from "./lib/cart.util";
|
|
4
4
|
export * from "./lib/variablesCart.util";
|
|
@@ -87,4 +87,5 @@ export * from "./components/ui/circular-progress";
|
|
|
87
87
|
export * from "./components/ui/swipeable-list-item";
|
|
88
88
|
export * from "./components/ui/dialog";
|
|
89
89
|
export * from "./components/ui/input-otp";
|
|
90
|
+
export { default as ProductsLocalStorage } from "./components/libs/cache/ProductsLocalStorage";
|
|
90
91
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,EAAE,EACF,wBAAwB,EACxB,GAAG,EACH,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACR,qBAAqB,EACrB,6BAA6B,EAC7B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,cAAc,qCAAqC,CAAA;AACnD,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA;AACnC,cAAc,mCAAmC,CAAA;AACjD,cAAc,qCAAqC,CAAA;AACnD,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// component exports
|
|
2
|
-
export { cn, cva,
|
|
2
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, } from "./lib/utils";
|
|
3
3
|
export * from "./lib/cart.util";
|
|
4
4
|
export * from "./lib/variablesCart.util";
|
|
5
5
|
export * from "./lib/isTapcartVersion20.util";
|
|
@@ -88,3 +88,4 @@ export * from "./components/ui/circular-progress";
|
|
|
88
88
|
export * from "./components/ui/swipeable-list-item";
|
|
89
89
|
export * from "./components/ui/dialog";
|
|
90
90
|
export * from "./components/ui/input-otp";
|
|
91
|
+
export { default as ProductsLocalStorage } from "./components/libs/cache/ProductsLocalStorage";
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Integrations, Integration, ConditionalSelectorMetafield, ConditionalSelectorValues, Collection, UserSelectedTag, Product, Customer, ShopifyMetafield } from "app-studio-types";
|
|
2
2
|
import { ClassValue } from "clsx";
|
|
3
3
|
import { CSSProperties } from "react";
|
|
4
|
+
export declare const supportedVideoExtensions: string[];
|
|
5
|
+
export declare const isVideo: (url: string) => boolean;
|
|
4
6
|
export declare const parsePhoneNumber: (input: string, country?: string) => import("phone").PhoneResult;
|
|
5
7
|
export type Color = {
|
|
6
8
|
type: "custom" | "brand-kit";
|
|
@@ -1119,7 +1121,7 @@ export declare const createCollectionImageMap: (collections: {
|
|
|
1119
1121
|
export declare const isFavoriteIntegrationEnabled: (integrations: Integrations) => boolean;
|
|
1120
1122
|
export declare const getEnabledWishlistIntegration: (integrations: Integrations) => Integration | null;
|
|
1121
1123
|
export declare const supportsMultipleWishlists: (integration: Integration | null | undefined) => boolean;
|
|
1122
|
-
export declare const getWishlistAddItemNavigation: (productId: string, isAuthenticated?: boolean) => {
|
|
1124
|
+
export declare const getWishlistAddItemNavigation: (productId: string, variantCount: number, isAuthenticated?: boolean) => {
|
|
1123
1125
|
destination: {
|
|
1124
1126
|
type: "internal";
|
|
1125
1127
|
url: string;
|
|
@@ -1165,6 +1167,7 @@ export declare const addItemToWishlist: ({ Tapcart, integrations, product, selec
|
|
|
1165
1167
|
product: {
|
|
1166
1168
|
id: string;
|
|
1167
1169
|
variants?: any[] | undefined;
|
|
1170
|
+
options?: any[] | undefined;
|
|
1168
1171
|
};
|
|
1169
1172
|
selectedVariantId?: string | undefined;
|
|
1170
1173
|
}) => Promise<boolean>;
|
|
@@ -1257,4 +1260,9 @@ type LogicGroup = {
|
|
|
1257
1260
|
conditions: (Condition | LogicGroup)[];
|
|
1258
1261
|
};
|
|
1259
1262
|
export declare const evaluateConditions: (group: LogicGroup, context: any) => boolean;
|
|
1263
|
+
/**
|
|
1264
|
+
* Parse BCP 47 language tag (e.g., en-US, en_US, zh-Hans-CN, en-US-POSIX)
|
|
1265
|
+
* Returns [language, country] tuple
|
|
1266
|
+
*/
|
|
1267
|
+
export declare const parseBCP47Locale: (locale: string | undefined) => [string, string];
|
|
1260
1268
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,4BAA4B,EAC5B,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,OAAO,EACP,QAAQ,EACR,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAMvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,eAAO,MAAM,gBAAgB,UAAW,MAAM,YAAY,MAAM,gCACrC,CAAA;AAE3B,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnE,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,eAAO,MAAM,eAAe,UAc3B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAA;AAMjE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAI9C,eAAO,MAAM,QAAQ,gBAAiB,KAAK,GAAG,SAAS,uBAUtD,CAAA;AAED,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC7D,KAAK,WAAW,GAAG,UAAU,EAAE,CAAA;AAE/B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;CAU/B,CAAA;AAED,KAA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,QAC/B,GAAG,EAAE,6BAGX,CAAA;AAED,eAAO,MAAM,mBAAmB,QACzB,GAAG,EAAE,0CAGX,CAAA;AA6BD,eAAO,MAAM,eAAe,aAChB,yBAAyB,cACvB,yBAAyB,YAoDtC,CAAA;AAGD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,GAAG,CAAA;CACX,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAAA;IAC3B,UAAU,EAAE,CAAC,SAAS,GAAG,UAAU,CAAC,EAAE,CAAA;CACvC,CAAA;AAoDD,eAAO,MAAM,kBAAkB,UACtB,UAAU,WACR,GAAG,KACX,OAyBF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WACnB,MAAM,GAAG,SAAS,KACzB,CAAC,MAAM,EAAE,MAAM,CAoCjB,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -13,6 +13,8 @@ import relativeTime from "dayjs/plugin/relativeTime";
|
|
|
13
13
|
import { twMerge } from "tailwind-merge";
|
|
14
14
|
import Pluralize from "pluralize";
|
|
15
15
|
import { phone } from "phone";
|
|
16
|
+
export const supportedVideoExtensions = [".mp4", ".mov"];
|
|
17
|
+
export const isVideo = (url) => supportedVideoExtensions.some((extension) => url.includes(extension));
|
|
16
18
|
export const parsePhoneNumber = (input, country) => phone(input, { country });
|
|
17
19
|
export function cn(...inputs) {
|
|
18
20
|
return twMerge(clsx(inputs));
|
|
@@ -123,7 +125,7 @@ export const getBorderStyle = (borderStyle, borderWidth = 1) => {
|
|
|
123
125
|
};
|
|
124
126
|
export const getBackgroundAndPaddingStyle = (backgroundAndPadding, { omitBorder = false } = {}) => {
|
|
125
127
|
const { backgroundColor, borderSides, borderColor, cornerRadius, padding, borderRadius, } = backgroundAndPadding;
|
|
126
|
-
const radius = cornerRadius
|
|
128
|
+
const radius = cornerRadius !== null && cornerRadius !== void 0 ? cornerRadius : borderRadius;
|
|
127
129
|
const backgroundAndPaddingStyle = Object.assign(Object.assign({}, getPaddingStyle(padding)), { backgroundColor: getColor(backgroundColor), borderRadius: radius !== undefined ? `${radius}px` : undefined });
|
|
128
130
|
if (omitBorder)
|
|
129
131
|
return backgroundAndPaddingStyle;
|
|
@@ -346,7 +348,7 @@ export const supportsMultipleWishlists = (integration) => {
|
|
|
346
348
|
return false;
|
|
347
349
|
}
|
|
348
350
|
};
|
|
349
|
-
export const getWishlistAddItemNavigation = (productId, isAuthenticated = false) => {
|
|
351
|
+
export const getWishlistAddItemNavigation = (productId, variantCount, isAuthenticated = false) => {
|
|
350
352
|
return {
|
|
351
353
|
destination: {
|
|
352
354
|
type: "internal",
|
|
@@ -355,7 +357,15 @@ export const getWishlistAddItemNavigation = (productId, isAuthenticated = false)
|
|
|
355
357
|
presentation: {
|
|
356
358
|
transition: "popover",
|
|
357
359
|
style: "default",
|
|
358
|
-
snapPoints: isAuthenticated
|
|
360
|
+
snapPoints: isAuthenticated
|
|
361
|
+
? variantCount === 1
|
|
362
|
+
? [0.5, 0.75]
|
|
363
|
+
: variantCount === 2
|
|
364
|
+
? [0.6, 0.75]
|
|
365
|
+
: variantCount === 3
|
|
366
|
+
? [0.7, 0.75]
|
|
367
|
+
: [0.8, 0.9] // 4+ variants
|
|
368
|
+
: [0.3, 0.5, 0.75],
|
|
359
369
|
},
|
|
360
370
|
header: {
|
|
361
371
|
visible: false,
|
|
@@ -425,7 +435,7 @@ export const getInputPlaceholderTextProps = (placeholderText) => {
|
|
|
425
435
|
* @param selectedVariantId
|
|
426
436
|
*/
|
|
427
437
|
export const addItemToWishlist = ({ Tapcart, integrations, product, selectedVariantId, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
428
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
438
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
429
439
|
const isAuthenticated = !!((_b = (_a = Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.variables) === null || _a === void 0 ? void 0 : _a.customer) === null || _b === void 0 ? void 0 : _b.id);
|
|
430
440
|
const defaultWishListId = ((_e = (_d = (_c = Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.variables) === null || _c === void 0 ? void 0 : _c.wishlists) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.id) || "Default Wishlist";
|
|
431
441
|
const wishlistIntegration = getEnabledWishlistIntegration(integrations);
|
|
@@ -447,10 +457,10 @@ export const addItemToWishlist = ({ Tapcart, integrations, product, selectedVari
|
|
|
447
457
|
((product === null || product === void 0 ? void 0 : product.variants) && ((_f = product === null || product === void 0 ? void 0 : product.variants) === null || _f === void 0 ? void 0 : _f.length) > 1) ||
|
|
448
458
|
!isAuthenticated;
|
|
449
459
|
if (shouldOpenDrawer) {
|
|
450
|
-
Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.action("screen/open", getWishlistAddItemNavigation(getIdFromGid(product === null || product === void 0 ? void 0 : product.id), isAuthenticated));
|
|
460
|
+
Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.action("screen/open", getWishlistAddItemNavigation(getIdFromGid(product === null || product === void 0 ? void 0 : product.id), ((_g = product === null || product === void 0 ? void 0 : product.options) === null || _g === void 0 ? void 0 : _g.length) || 1, isAuthenticated));
|
|
451
461
|
return false;
|
|
452
462
|
}
|
|
453
|
-
const variantId = selectedVariantId || ((
|
|
463
|
+
const variantId = selectedVariantId || ((_j = (_h = product === null || product === void 0 ? void 0 : product.variants) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.id);
|
|
454
464
|
if (!variantId) {
|
|
455
465
|
console.error("Missing variant id for wishlist add");
|
|
456
466
|
return false;
|
|
@@ -476,17 +486,17 @@ export const addItemToWishlist = ({ Tapcart, integrations, product, selectedVari
|
|
|
476
486
|
* @returns {Promise<{ id: string; variantId: string; productId: string }[]>} - An array of removed wishlist entries.
|
|
477
487
|
*/
|
|
478
488
|
export const removeItemFromWishlists = ({ Tapcart, productId, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
479
|
-
var
|
|
489
|
+
var _k, _l, _m, _o;
|
|
480
490
|
if (!Tapcart) {
|
|
481
491
|
console.error("Tapcart instance is missing");
|
|
482
492
|
return [];
|
|
483
493
|
}
|
|
484
494
|
const removedWishlistEntries = [];
|
|
485
495
|
try {
|
|
486
|
-
const wishlistEntries = findWishlistEntries((
|
|
496
|
+
const wishlistEntries = findWishlistEntries((_k = Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.variables) === null || _k === void 0 ? void 0 : _k.wishlists, productId);
|
|
487
497
|
// Remove all wishlist entries for the product
|
|
488
498
|
for (const wishlistEntry of wishlistEntries) {
|
|
489
|
-
if (!((
|
|
499
|
+
if (!((_l = wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.item) === null || _l === void 0 ? void 0 : _l.variantId)) {
|
|
490
500
|
console.error("Missing variant id for wishlist removal");
|
|
491
501
|
continue;
|
|
492
502
|
}
|
|
@@ -496,13 +506,13 @@ export const removeItemFromWishlists = ({ Tapcart, productId, }) => __awaiter(vo
|
|
|
496
506
|
}
|
|
497
507
|
const result = yield Tapcart.action("wishlist/item/remove", {
|
|
498
508
|
productId,
|
|
499
|
-
variantId: getIdFromGid((
|
|
509
|
+
variantId: getIdFromGid((_m = wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.item) === null || _m === void 0 ? void 0 : _m.variantId),
|
|
500
510
|
wishlistId: getIdFromGid(wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.wishlistId),
|
|
501
511
|
});
|
|
502
512
|
if (result) {
|
|
503
513
|
removedWishlistEntries.push({
|
|
504
514
|
id: getIdFromGid(wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.wishlistId),
|
|
505
|
-
variantId: getIdFromGid((
|
|
515
|
+
variantId: getIdFromGid((_o = wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.item) === null || _o === void 0 ? void 0 : _o.variantId),
|
|
506
516
|
productId,
|
|
507
517
|
});
|
|
508
518
|
}
|
|
@@ -806,4 +816,43 @@ export const evaluateConditions = (group, context) => {
|
|
|
806
816
|
return true;
|
|
807
817
|
}
|
|
808
818
|
};
|
|
819
|
+
/**
|
|
820
|
+
* Parse BCP 47 language tag (e.g., en-US, en_US, zh-Hans-CN, en-US-POSIX)
|
|
821
|
+
* Returns [language, country] tuple
|
|
822
|
+
*/
|
|
823
|
+
export const parseBCP47Locale = (locale) => {
|
|
824
|
+
var _a;
|
|
825
|
+
if (!locale)
|
|
826
|
+
return ["en", "US"];
|
|
827
|
+
// Normalize underscores to hyphens
|
|
828
|
+
const normalized = locale.replace(/_/g, "-");
|
|
829
|
+
const parts = normalized.split("-");
|
|
830
|
+
if (parts.length === 0)
|
|
831
|
+
return ["en", "US"];
|
|
832
|
+
// First part is always the language (lowercase)
|
|
833
|
+
const language = ((_a = parts[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "en";
|
|
834
|
+
// Look for country/region subtag:
|
|
835
|
+
// - 2 uppercase letters (e.g., US, GB, FR)
|
|
836
|
+
// - 3 digits (e.g., 001, 419)
|
|
837
|
+
// Script subtags are 4 letters, so we skip those
|
|
838
|
+
let country = "US"; // default
|
|
839
|
+
for (let i = 1; i < parts.length; i++) {
|
|
840
|
+
const part = parts[i];
|
|
841
|
+
if (!part)
|
|
842
|
+
continue;
|
|
843
|
+
// Check if it's a 2-letter country code (uppercase or lowercase)
|
|
844
|
+
if (/^[A-Za-z]{2}$/.test(part)) {
|
|
845
|
+
country = part.toUpperCase();
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
// Check if it's a 3-digit region code
|
|
849
|
+
if (/^\d{3}$/.test(part)) {
|
|
850
|
+
country = part;
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
// If it's a 4-letter script subtag (e.g., Hans, Latn), continue looking
|
|
854
|
+
// Otherwise, if it's not a script, it might be a variant - we'll use the first valid country we find
|
|
855
|
+
}
|
|
856
|
+
return [language, country];
|
|
857
|
+
};
|
|
809
858
|
// --- End (Block conditional rendering util functions) ----
|
package/dist/styles.css
CHANGED
|
@@ -953,6 +953,9 @@ video {
|
|
|
953
953
|
.inline {
|
|
954
954
|
display: inline;
|
|
955
955
|
}
|
|
956
|
+
.\!flex {
|
|
957
|
+
display: flex !important;
|
|
958
|
+
}
|
|
956
959
|
.flex {
|
|
957
960
|
display: flex;
|
|
958
961
|
}
|
|
@@ -1101,6 +1104,9 @@ video {
|
|
|
1101
1104
|
.min-h-screen {
|
|
1102
1105
|
min-height: 100vh;
|
|
1103
1106
|
}
|
|
1107
|
+
.\!w-\[calc\(100\%_-_20px\)\] {
|
|
1108
|
+
width: calc(100% - 20px) !important;
|
|
1109
|
+
}
|
|
1104
1110
|
.w-0 {
|
|
1105
1111
|
width: 0px;
|
|
1106
1112
|
}
|
|
@@ -1202,6 +1208,9 @@ video {
|
|
|
1202
1208
|
.w-px {
|
|
1203
1209
|
width: 1px;
|
|
1204
1210
|
}
|
|
1211
|
+
.\!min-w-0 {
|
|
1212
|
+
min-width: 0px !important;
|
|
1213
|
+
}
|
|
1205
1214
|
.min-w-0 {
|
|
1206
1215
|
min-width: 0px;
|
|
1207
1216
|
}
|
|
@@ -1457,6 +1466,9 @@ video {
|
|
|
1457
1466
|
.justify-end {
|
|
1458
1467
|
justify-content: flex-end;
|
|
1459
1468
|
}
|
|
1469
|
+
.\!justify-center {
|
|
1470
|
+
justify-content: center !important;
|
|
1471
|
+
}
|
|
1460
1472
|
.justify-center {
|
|
1461
1473
|
justify-content: center;
|
|
1462
1474
|
}
|
package/dist/tests/utils.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDestinationHandler, getTextStyle } from "../lib/utils";
|
|
1
|
+
import { getDestinationHandler, getTextStyle, parseBCP47Locale, } from "../lib/utils";
|
|
2
2
|
describe("DESTINATION_HANDLERS", () => {
|
|
3
3
|
describe("url handler", () => {
|
|
4
4
|
const mockActions = {
|
|
@@ -609,3 +609,202 @@ describe("getTextStyle", () => {
|
|
|
609
609
|
});
|
|
610
610
|
});
|
|
611
611
|
});
|
|
612
|
+
describe("parseBCP47Locale", () => {
|
|
613
|
+
describe("basic formats", () => {
|
|
614
|
+
it("should parse hyphen-separated locale (en-US)", () => {
|
|
615
|
+
const result = parseBCP47Locale("en-US");
|
|
616
|
+
expect(result).toEqual(["en", "US"]);
|
|
617
|
+
});
|
|
618
|
+
it("should parse underscore-separated locale (en_US)", () => {
|
|
619
|
+
const result = parseBCP47Locale("en_US");
|
|
620
|
+
expect(result).toEqual(["en", "US"]);
|
|
621
|
+
});
|
|
622
|
+
it("should parse lowercase country code (en-us)", () => {
|
|
623
|
+
const result = parseBCP47Locale("en-us");
|
|
624
|
+
expect(result).toEqual(["en", "US"]);
|
|
625
|
+
});
|
|
626
|
+
it("should parse mixed case country code (en-Uy)", () => {
|
|
627
|
+
const result = parseBCP47Locale("en-Uy");
|
|
628
|
+
expect(result).toEqual(["en", "UY"]);
|
|
629
|
+
});
|
|
630
|
+
it("should parse uppercase language code (EN-US)", () => {
|
|
631
|
+
const result = parseBCP47Locale("EN-US");
|
|
632
|
+
expect(result).toEqual(["en", "US"]);
|
|
633
|
+
});
|
|
634
|
+
it("should parse various country codes", () => {
|
|
635
|
+
const testCases = [
|
|
636
|
+
["en-GB", ["en", "GB"]],
|
|
637
|
+
["en-FR", ["en", "FR"]],
|
|
638
|
+
["en-CA", ["en", "CA"]],
|
|
639
|
+
["en-AU", ["en", "AU"]],
|
|
640
|
+
["en-MX", ["en", "MX"]],
|
|
641
|
+
["es-ES", ["es", "ES"]],
|
|
642
|
+
["fr-FR", ["fr", "FR"]],
|
|
643
|
+
["de-DE", ["de", "DE"]],
|
|
644
|
+
["ja-JP", ["ja", "JP"]],
|
|
645
|
+
["zh-CN", ["zh", "CN"]],
|
|
646
|
+
];
|
|
647
|
+
testCases.forEach(([input, expected]) => {
|
|
648
|
+
const result = parseBCP47Locale(input);
|
|
649
|
+
expect(result).toEqual(expected);
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
describe("language only", () => {
|
|
654
|
+
it("should default to US when only language is provided (en)", () => {
|
|
655
|
+
const result = parseBCP47Locale("en");
|
|
656
|
+
expect(result).toEqual(["en", "US"]);
|
|
657
|
+
});
|
|
658
|
+
it("should default to US when only language is provided (fr)", () => {
|
|
659
|
+
const result = parseBCP47Locale("fr");
|
|
660
|
+
expect(result).toEqual(["fr", "US"]);
|
|
661
|
+
});
|
|
662
|
+
it("should handle lowercase language code", () => {
|
|
663
|
+
const result = parseBCP47Locale("es");
|
|
664
|
+
expect(result).toEqual(["es", "US"]);
|
|
665
|
+
});
|
|
666
|
+
it("should handle uppercase language code", () => {
|
|
667
|
+
const result = parseBCP47Locale("DE");
|
|
668
|
+
expect(result).toEqual(["de", "US"]);
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
describe("BCP 47 with script subtag", () => {
|
|
672
|
+
it("should parse locale with script subtag (zh-Hans-CN)", () => {
|
|
673
|
+
const result = parseBCP47Locale("zh-Hans-CN");
|
|
674
|
+
expect(result).toEqual(["zh", "CN"]);
|
|
675
|
+
});
|
|
676
|
+
it("should parse locale with script subtag (zh-Hant-TW)", () => {
|
|
677
|
+
const result = parseBCP47Locale("zh-Hant-TW");
|
|
678
|
+
expect(result).toEqual(["zh", "TW"]);
|
|
679
|
+
});
|
|
680
|
+
it("should parse locale with script subtag (sr-Latn-RS)", () => {
|
|
681
|
+
const result = parseBCP47Locale("sr-Latn-RS");
|
|
682
|
+
expect(result).toEqual(["sr", "RS"]);
|
|
683
|
+
});
|
|
684
|
+
it("should parse locale with script subtag using underscore (zh_Hans_CN)", () => {
|
|
685
|
+
const result = parseBCP47Locale("zh_Hans_CN");
|
|
686
|
+
expect(result).toEqual(["zh", "CN"]);
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
describe("BCP 47 with variant subtag", () => {
|
|
690
|
+
it("should parse locale with variant (en-US-POSIX)", () => {
|
|
691
|
+
const result = parseBCP47Locale("en-US-POSIX");
|
|
692
|
+
expect(result).toEqual(["en", "US"]);
|
|
693
|
+
});
|
|
694
|
+
it("should parse locale with variant (en-GB-OED)", () => {
|
|
695
|
+
const result = parseBCP47Locale("en-GB-OED");
|
|
696
|
+
expect(result).toEqual(["en", "GB"]);
|
|
697
|
+
});
|
|
698
|
+
it("should parse locale with multiple variants", () => {
|
|
699
|
+
const result = parseBCP47Locale("en-US-x-private");
|
|
700
|
+
expect(result).toEqual(["en", "US"]);
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
describe("numeric region codes", () => {
|
|
704
|
+
it("should parse 3-digit region code (en-001)", () => {
|
|
705
|
+
const result = parseBCP47Locale("en-001");
|
|
706
|
+
expect(result).toEqual(["en", "001"]);
|
|
707
|
+
});
|
|
708
|
+
it("should parse 3-digit region code (en-419)", () => {
|
|
709
|
+
const result = parseBCP47Locale("en-419");
|
|
710
|
+
expect(result).toEqual(["en", "419"]);
|
|
711
|
+
});
|
|
712
|
+
it("should parse 3-digit region code with script (zh-Hans-001)", () => {
|
|
713
|
+
const result = parseBCP47Locale("zh-Hans-001");
|
|
714
|
+
expect(result).toEqual(["zh", "001"]);
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
describe("edge cases", () => {
|
|
718
|
+
it("should return default values for undefined", () => {
|
|
719
|
+
const result = parseBCP47Locale(undefined);
|
|
720
|
+
expect(result).toEqual(["en", "US"]);
|
|
721
|
+
});
|
|
722
|
+
it("should return default values for empty string", () => {
|
|
723
|
+
const result = parseBCP47Locale("");
|
|
724
|
+
expect(result).toEqual(["en", "US"]);
|
|
725
|
+
});
|
|
726
|
+
it("should handle locale with only country code (US)", () => {
|
|
727
|
+
const result = parseBCP47Locale("US");
|
|
728
|
+
expect(result).toEqual(["us", "US"]);
|
|
729
|
+
});
|
|
730
|
+
it("should handle locale with only country code lowercase (us)", () => {
|
|
731
|
+
const result = parseBCP47Locale("us");
|
|
732
|
+
expect(result).toEqual(["us", "US"]);
|
|
733
|
+
});
|
|
734
|
+
it("should handle complex BCP 47 tag with script and variant", () => {
|
|
735
|
+
const result = parseBCP47Locale("zh-Hans-CN-x-private");
|
|
736
|
+
expect(result).toEqual(["zh", "CN"]);
|
|
737
|
+
});
|
|
738
|
+
it("should handle locale with multiple hyphens", () => {
|
|
739
|
+
const result = parseBCP47Locale("en-US-POSIX-x-private");
|
|
740
|
+
expect(result).toEqual(["en", "US"]);
|
|
741
|
+
});
|
|
742
|
+
it("should handle locale with underscores and hyphens mixed", () => {
|
|
743
|
+
const result = parseBCP47Locale("en_US-POSIX");
|
|
744
|
+
expect(result).toEqual(["en", "US"]);
|
|
745
|
+
});
|
|
746
|
+
});
|
|
747
|
+
describe("real-world examples", () => {
|
|
748
|
+
it("should parse common locale formats", () => {
|
|
749
|
+
const testCases = [
|
|
750
|
+
["en-US", ["en", "US"]],
|
|
751
|
+
["en_US", ["en", "US"]],
|
|
752
|
+
["en-us", ["en", "US"]],
|
|
753
|
+
["pt-BR", ["pt", "BR"]],
|
|
754
|
+
["pt_BR", ["pt", "BR"]],
|
|
755
|
+
["es-MX", ["es", "MX"]],
|
|
756
|
+
["fr-CA", ["fr", "CA"]],
|
|
757
|
+
["de-AT", ["de", "AT"]],
|
|
758
|
+
["it-IT", ["it", "IT"]],
|
|
759
|
+
["nl-NL", ["nl", "NL"]],
|
|
760
|
+
["sv-SE", ["sv", "SE"]],
|
|
761
|
+
["no-NO", ["no", "NO"]],
|
|
762
|
+
["da-DK", ["da", "DK"]],
|
|
763
|
+
["fi-FI", ["fi", "FI"]],
|
|
764
|
+
["pl-PL", ["pl", "PL"]],
|
|
765
|
+
["ru-RU", ["ru", "RU"]],
|
|
766
|
+
["ko-KR", ["ko", "KR"]],
|
|
767
|
+
["ar-SA", ["ar", "SA"]],
|
|
768
|
+
["he-IL", ["he", "IL"]],
|
|
769
|
+
["th-TH", ["th", "TH"]],
|
|
770
|
+
["vi-VN", ["vi", "VN"]],
|
|
771
|
+
["id-ID", ["id", "ID"]],
|
|
772
|
+
["tr-TR", ["tr", "TR"]],
|
|
773
|
+
];
|
|
774
|
+
testCases.forEach(([input, expected]) => {
|
|
775
|
+
const result = parseBCP47Locale(input);
|
|
776
|
+
expect(result).toEqual(expected);
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
it("should parse extended language tags", () => {
|
|
780
|
+
const result = parseBCP47Locale("zh-Hans-CN");
|
|
781
|
+
expect(result).toEqual(["zh", "CN"]);
|
|
782
|
+
});
|
|
783
|
+
it("should parse locale with private use subtag", () => {
|
|
784
|
+
const result = parseBCP47Locale("en-US-x-private");
|
|
785
|
+
expect(result).toEqual(["en", "US"]);
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
describe("case normalization", () => {
|
|
789
|
+
it("should normalize language to lowercase", () => {
|
|
790
|
+
const result = parseBCP47Locale("EN-US");
|
|
791
|
+
expect(result[0]).toBe("en");
|
|
792
|
+
});
|
|
793
|
+
it("should normalize country to uppercase", () => {
|
|
794
|
+
const result = parseBCP47Locale("en-us");
|
|
795
|
+
expect(result[1]).toBe("US");
|
|
796
|
+
});
|
|
797
|
+
it("should handle mixed case input", () => {
|
|
798
|
+
const result = parseBCP47Locale("En-Us");
|
|
799
|
+
expect(result).toEqual(["en", "US"]);
|
|
800
|
+
});
|
|
801
|
+
it("should handle all lowercase input", () => {
|
|
802
|
+
const result = parseBCP47Locale("en-gb");
|
|
803
|
+
expect(result).toEqual(["en", "GB"]);
|
|
804
|
+
});
|
|
805
|
+
it("should handle all uppercase input", () => {
|
|
806
|
+
const result = parseBCP47Locale("EN-GB");
|
|
807
|
+
expect(result).toEqual(["en", "GB"]);
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
});
|