@sentecacommerce-theme/lib 0.12.92 → 0.12.96
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/cjs/analytics/Pixel/hooks/usePixelProductsImpression.js +9 -8
- package/dist/cjs/hooks/wishlist-hooks/useWishlistItem/index.js +39 -15
- package/dist/cjs/listing/api/queries/useListingQuery.js +1 -1
- package/dist/cjs/listing/hooks/useListingMeta.js +49 -40
- package/dist/cjs/listing/hooks/useSlideFilter.js +24 -3
- package/dist/cjs/listing/ssr/prefetchCategories.js +4 -5
- package/dist/cjs/listing/ssr/prefetchPredicate.js +4 -4
- package/dist/cjs/navigation/components/SearchBox/Components/EmptyBox/index.js +7 -7
- package/dist/cjs/navigation/components/SearchBox/index.js +4 -4
- package/dist/cjs/seo/components/TranslationsMeta/index.js +58 -0
- package/dist/cjs/seo/components/index.js +12 -0
- package/dist/cjs/seo/hooks/index.js +14 -0
- package/dist/cjs/seo/hooks/useSeoTranslations.js +90 -0
- package/dist/cjs/ui/components/GridStyles.js +2 -2
- package/dist/cjs/ui/components/RangeSliderInput.js +14 -1
- package/dist/esm/analytics/Pixel/hooks/usePixelProductsImpression.js +9 -8
- package/dist/esm/hooks/wishlist-hooks/useWishlistItem/index.js +21 -13
- package/dist/esm/listing/api/queries/useListingQuery.js +1 -1
- package/dist/esm/listing/hooks/useListingMeta.js +49 -40
- package/dist/esm/listing/hooks/useSlideFilter.js +24 -3
- package/dist/esm/listing/ssr/prefetchCategories.js +5 -6
- package/dist/esm/listing/ssr/prefetchPredicate.js +4 -4
- package/dist/esm/navigation/components/SearchBox/Components/EmptyBox/index.js +7 -7
- package/dist/esm/navigation/components/SearchBox/index.js +4 -4
- package/dist/esm/seo/components/TranslationsMeta/index.js +48 -0
- package/dist/esm/seo/components/index.js +1 -0
- package/dist/esm/seo/hooks/index.js +1 -0
- package/dist/esm/seo/hooks/useSeoTranslations.js +79 -0
- package/dist/esm/ui/components/GridStyles.js +2 -2
- package/dist/esm/ui/components/RangeSliderInput.js +14 -1
- package/dist/types/listing/hooks/useSlideFilter.d.ts +4 -0
- package/dist/types/listing/types.d.ts +10 -0
- package/dist/types/navigation/components/SearchBox/Components/EmptyBox/index.d.ts +5 -4
- package/dist/types/navigation/components/SearchBox/index.d.ts +7 -6
- package/dist/types/seo/components/TranslationsMeta/index.d.ts +1 -0
- package/dist/types/seo/components/index.d.ts +1 -0
- package/dist/types/seo/hooks/index.d.ts +1 -0
- package/dist/types/seo/hooks/useSeoTranslations.d.ts +24 -0
- package/dist/types/ui/components/GridStyles.d.ts +2 -1
- package/dist/types/ui/components/RangeSliderInput.d.ts +2 -1
- package/package.json +4 -4
@@ -0,0 +1,48 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { useSeoTranslations } from '../../hooks/useSeoTranslations';
|
3
|
+
import Head from 'next/head';
|
4
|
+
import { useRouter } from 'next/router';
|
5
|
+
function _extends() {
|
6
|
+
_extends = Object.assign || function(target) {
|
7
|
+
for(var i = 1; i < arguments.length; i++){
|
8
|
+
var source = arguments[i];
|
9
|
+
for(var key in source){
|
10
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
11
|
+
target[key] = source[key];
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
15
|
+
return target;
|
16
|
+
};
|
17
|
+
return _extends.apply(this, arguments);
|
18
|
+
}
|
19
|
+
export var TranslationsMeta = function() {
|
20
|
+
var ref = useSeoTranslations(), translationsMap = ref.translationsMap, allLocales = ref.allLocales, defaultLocale = ref.defaultLocale;
|
21
|
+
var router = useRouter();
|
22
|
+
var defaultTranslation = translationsMap[defaultLocale];
|
23
|
+
var isError = router.route === '/404' || router.route === '/_error';
|
24
|
+
if (isError) return null;
|
25
|
+
var domain = defaultTranslation === null || defaultTranslation === void 0 ? void 0 : defaultTranslation.domain;
|
26
|
+
return(/*#__PURE__*/ React.createElement(Head, null, allLocales === null || allLocales === void 0 ? void 0 : allLocales.map(function(locale) {
|
27
|
+
var translation = translationsMap === null || translationsMap === void 0 ? void 0 : translationsMap[locale];
|
28
|
+
var href = translation === null || translation === void 0 ? void 0 : translation.slug;
|
29
|
+
// go to the same page but with the right locale.
|
30
|
+
// This is for pages that does not have a translated slug
|
31
|
+
// example: /checkout -> /en/checkout, /ro/checkout
|
32
|
+
if (!href) href = "/".concat(locale).concat(router.asPath);
|
33
|
+
return(/*#__PURE__*/ React.createElement("link", _extends({
|
34
|
+
rel: "alternate"
|
35
|
+
}, {
|
36
|
+
hreflang: locale
|
37
|
+
}, {
|
38
|
+
href: domain + href,
|
39
|
+
key: 'Translation__' + href
|
40
|
+
})));
|
41
|
+
}), defaultTranslation && /*#__PURE__*/ React.createElement("link", _extends({
|
42
|
+
rel: "alternate"
|
43
|
+
}, {
|
44
|
+
hreflang: 'x-default'
|
45
|
+
}, {
|
46
|
+
href: "".concat(domain).concat(defaultTranslation === null || defaultTranslation === void 0 ? void 0 : defaultTranslation.slug)
|
47
|
+
}))));
|
48
|
+
};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { useRouter } from 'next/router';
|
3
|
+
function _defineProperty(obj, key, value) {
|
4
|
+
if (key in obj) {
|
5
|
+
Object.defineProperty(obj, key, {
|
6
|
+
value: value,
|
7
|
+
enumerable: true,
|
8
|
+
configurable: true,
|
9
|
+
writable: true
|
10
|
+
});
|
11
|
+
} else {
|
12
|
+
obj[key] = value;
|
13
|
+
}
|
14
|
+
return obj;
|
15
|
+
}
|
16
|
+
function _objectSpread(target) {
|
17
|
+
for(var i = 1; i < arguments.length; i++){
|
18
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
19
|
+
var ownKeys = Object.keys(source);
|
20
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
21
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
22
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
23
|
+
}));
|
24
|
+
}
|
25
|
+
ownKeys.forEach(function(key) {
|
26
|
+
_defineProperty(target, key, source[key]);
|
27
|
+
});
|
28
|
+
}
|
29
|
+
return target;
|
30
|
+
}
|
31
|
+
var SeoTranslationsContext = /*#__PURE__*/ React.createContext({});
|
32
|
+
export var SeoTranslationsProvider = function(param) {
|
33
|
+
var children = param.children, translations = param.translations, defaultLocale = param.defaultLocale, localesMap = param.localesMap;
|
34
|
+
var router = useRouter();
|
35
|
+
var currentLocale = router.locale;
|
36
|
+
var currentPath = router.asPath;
|
37
|
+
var data1 = React.useMemo(function() {
|
38
|
+
if (!translations) translations = {};
|
39
|
+
translations[currentLocale] = {
|
40
|
+
slug: currentPath.split('?')[0].replace("/".concat(currentLocale), ''),
|
41
|
+
title: '',
|
42
|
+
id: Date.now().toString()
|
43
|
+
};
|
44
|
+
var map = Object.keys(translations || {}).filter(function(lang) {
|
45
|
+
return Boolean(localesMap[lang]);
|
46
|
+
}).reduce(function(acc, lang) {
|
47
|
+
var ref;
|
48
|
+
var data = translations === null || translations === void 0 ? void 0 : translations[lang];
|
49
|
+
var localeData = localesMap[lang];
|
50
|
+
var isDefault = defaultLocale === lang;
|
51
|
+
var isFrontPage = data.slug === '/';
|
52
|
+
var prefix = ((ref = data.slug) === null || ref === void 0 ? void 0 : ref[0]) === '/' ? '' : '/';
|
53
|
+
var slug = "".concat(isDefault ? '' : "/".concat(lang)).concat(prefix).concat(isFrontPage ? '' : data.slug);
|
54
|
+
return _objectSpread({}, acc, _defineProperty({}, lang, {
|
55
|
+
slug: slug,
|
56
|
+
locale: lang,
|
57
|
+
isDefault: isDefault,
|
58
|
+
domain: "https://".concat(localeData.domain)
|
59
|
+
}));
|
60
|
+
}, {});
|
61
|
+
return {
|
62
|
+
translationsMap: map,
|
63
|
+
defaultLocale: defaultLocale,
|
64
|
+
allLocales: Object.keys(localesMap)
|
65
|
+
};
|
66
|
+
}, [
|
67
|
+
defaultLocale,
|
68
|
+
translations,
|
69
|
+
localesMap,
|
70
|
+
currentLocale,
|
71
|
+
currentPath
|
72
|
+
]);
|
73
|
+
return(/*#__PURE__*/ React.createElement(SeoTranslationsContext.Provider, {
|
74
|
+
value: data1
|
75
|
+
}, children));
|
76
|
+
};
|
77
|
+
export var useSeoTranslations = function() {
|
78
|
+
return React.useContext(SeoTranslationsContext) || {};
|
79
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
export var GridStyles = function(param) {
|
3
|
-
var spaceX = param.spaceX, breakpoints = param.breakpoints, _remSize = param.remSize, remSize = _remSize === void 0 ? 10 : _remSize;
|
3
|
+
var spaceX = param.spaceX, breakpoints = param.breakpoints, _remSize = param.remSize, remSize = _remSize === void 0 ? 10 : _remSize, _spaceBetweenSections = param.spaceBetweenSections, spaceBetweenSections = _spaceBetweenSections === void 0 ? 80 : _spaceBetweenSections;
|
4
4
|
var getSize = function getSize(width) {
|
5
5
|
return "min-width: calc(".concat(width, "% - ").concat(spaceX / remSize, "rem);") + "max-width: calc(".concat(width, "% - ").concat(spaceX / remSize, "rem);") + "margin: 0 ".concat(spaceX / 2 / remSize, "rem;");
|
6
6
|
};
|
@@ -20,7 +20,7 @@ export var GridStyles = function(param) {
|
|
20
20
|
}, '');
|
21
21
|
return(/*#__PURE__*/ React.createElement("style", {
|
22
22
|
dangerouslySetInnerHTML: {
|
23
|
-
__html: "\n .Page--row {\n display: flex;\n display: -webkit-flex;\n flex-wrap: wrap;\n -webkit-flex-wrap: wrap;\n margin: 0 -".concat(spaceX / remSize / 2, "rem;\n }\n\n .Page__section {\n padding-bottom:
|
23
|
+
__html: "\n .Page--row {\n display: flex;\n display: -webkit-flex;\n flex-wrap: wrap;\n -webkit-flex-wrap: wrap;\n margin: 0 -".concat(spaceX / remSize / 2, "rem;\n }\n\n .Page__section {\n padding-bottom: ").concat(spaceBetweenSections / remSize, "rem;\n }\n\n .Page--col {\n display: block;\n width: 100%;\n }\n \n .size-default-inherit {\n width: 100%;\n }\n ").concat(queries, "\n ")
|
24
24
|
}
|
25
25
|
}));
|
26
26
|
};
|
@@ -117,7 +117,7 @@ export var RangeSlideClasses = {
|
|
117
117
|
thumbActive: 'RangeSlider--thumb-active'
|
118
118
|
};
|
119
119
|
export var RangeSliderInput = function(param) {
|
120
|
-
var defaultValue = param.defaultValue, onChange = param.onChange, _min = param.min, min = _min === void 0 ? 0 : _min, _max = param.max, max = _max === void 0 ? 100 : _max, _step = param.step, step = _step === void 0 ? 1 : _step;
|
120
|
+
var defaultValue = param.defaultValue, onChange = param.onChange, onSlide = param.onSlide, _min = param.min, min = _min === void 0 ? 0 : _min, _max = param.max, max = _max === void 0 ? 100 : _max, _step = param.step, step = _step === void 0 ? 1 : _step;
|
121
121
|
var ref1 = _slicedToArray(useState(defaultValue), 2), value = ref1[0], setValue = ref1[1];
|
122
122
|
var inputLeftRef = React.useRef(null);
|
123
123
|
var inputRightRef = React.useRef(null);
|
@@ -130,6 +130,17 @@ export var RangeSliderInput = function(param) {
|
|
130
130
|
}, [
|
131
131
|
defaultValue
|
132
132
|
]);
|
133
|
+
var onSlideGeneric = function() {
|
134
|
+
var inputLeft = inputLeftRef.current;
|
135
|
+
var inputRight = inputRightRef.current;
|
136
|
+
if (!inputLeft || !inputRight) return;
|
137
|
+
var leftValue = Math.min(Number(inputLeft.value), Number(inputRight.value) - 1);
|
138
|
+
var rightValue = Math.max(Number(inputRight.value), Number(inputLeft.value) + 1);
|
139
|
+
onSlide === null || onSlide === void 0 ? void 0 : onSlide({
|
140
|
+
left: leftValue,
|
141
|
+
right: rightValue
|
142
|
+
});
|
143
|
+
};
|
133
144
|
var updateLeftValue = useCallback(function() {
|
134
145
|
var inputLeft = inputLeftRef.current;
|
135
146
|
var inputRight = inputRightRef.current;
|
@@ -138,6 +149,7 @@ export var RangeSliderInput = function(param) {
|
|
138
149
|
setValue(_objectSpread({}, value, {
|
139
150
|
left: leftValue
|
140
151
|
}));
|
152
|
+
onSlideGeneric();
|
141
153
|
}, [
|
142
154
|
setValue,
|
143
155
|
value
|
@@ -150,6 +162,7 @@ export var RangeSliderInput = function(param) {
|
|
150
162
|
setValue(_objectSpread({}, value, {
|
151
163
|
right: rightValue
|
152
164
|
}));
|
165
|
+
onSlideGeneric();
|
153
166
|
}, [
|
154
167
|
setValue,
|
155
168
|
value
|
@@ -84,4 +84,14 @@ export interface ListingPageMeta {
|
|
84
84
|
collapseMode?: StringField;
|
85
85
|
limit: NumberField;
|
86
86
|
includeVariants?: BooleanField;
|
87
|
+
getTitle?: GetListingPageTitle;
|
87
88
|
}
|
89
|
+
export declare type GetListingPageTitle = (type: ListingTypesEnum, meta: Omit<ListingPageMeta, 'getTitle'>, data: {
|
90
|
+
brand?: string;
|
91
|
+
category?: string;
|
92
|
+
defaultName?: string;
|
93
|
+
attribute?: string;
|
94
|
+
search?: string;
|
95
|
+
isWithAttribute: boolean;
|
96
|
+
childAttribute?: string;
|
97
|
+
}) => string;
|
@@ -3,11 +3,12 @@ interface EmptyBoxProps {
|
|
3
3
|
backgroundColor?: StringField;
|
4
4
|
searchHistory?: any[];
|
5
5
|
labels: GroupField<{
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
promoOffers: StringField;
|
7
|
+
products: StringField;
|
8
|
+
recentSearches: StringField;
|
9
|
+
popularSearches: StringField;
|
10
10
|
blogLabel: StringField;
|
11
|
+
noResults: StringField;
|
11
12
|
blog: GroupField<{
|
12
13
|
blogTitle: StringField;
|
13
14
|
image: StringField;
|
@@ -1,12 +1,13 @@
|
|
1
1
|
import { StringField, GroupField, BooleanField, NumberField } from '@sentecacommerce-theme/cms';
|
2
2
|
interface SearchLabels {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
recentSearches: StringField;
|
4
|
+
popularSearches: StringField;
|
5
|
+
suggestedBrands: StringField;
|
6
|
+
suggestedCategories: StringField;
|
7
|
+
promoOffers: StringField;
|
8
|
+
products: StringField;
|
9
9
|
blogLabel: StringField;
|
10
|
+
noResults: StringField;
|
10
11
|
blog: GroupField<{
|
11
12
|
blogTitle: StringField;
|
12
13
|
image: StringField;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const TranslationsMeta: () => JSX.Element | null;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import type { TranslationsMapDTO } from '@sentecacommerce-theme/cms';
|
2
|
+
import type { LocaleData } from '../../config';
|
3
|
+
export declare const SeoTranslationsProvider: ({ children, translations, defaultLocale, localesMap, }: {
|
4
|
+
children: any;
|
5
|
+
translations: TranslationsMapDTO;
|
6
|
+
defaultLocale: string;
|
7
|
+
localesMap: {
|
8
|
+
[key: string]: LocaleData;
|
9
|
+
};
|
10
|
+
}) => JSX.Element;
|
11
|
+
export declare const useSeoTranslations: () => SeoTranslationContextType;
|
12
|
+
export declare type SeoTranslationContextType = {
|
13
|
+
translationsMap: {
|
14
|
+
[key: string]: SeoTranslationType;
|
15
|
+
};
|
16
|
+
defaultLocale: string;
|
17
|
+
allLocales: string[];
|
18
|
+
};
|
19
|
+
export declare type SeoTranslationType = {
|
20
|
+
slug: string;
|
21
|
+
locale: string;
|
22
|
+
isDefault: boolean;
|
23
|
+
domain: string;
|
24
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { StringField } from '@sentecacommerce-theme/cms';
|
2
|
-
export declare const GridStyles: ({ spaceX, breakpoints, remSize, }: {
|
2
|
+
export declare const GridStyles: ({ spaceX, breakpoints, remSize, spaceBetweenSections, }: {
|
3
3
|
breakpoints?: {
|
4
4
|
[key: string]: {
|
5
5
|
min: StringField;
|
@@ -7,4 +7,5 @@ export declare const GridStyles: ({ spaceX, breakpoints, remSize, }: {
|
|
7
7
|
} | undefined;
|
8
8
|
spaceX: number;
|
9
9
|
remSize?: number | undefined;
|
10
|
+
spaceBetweenSections?: number | undefined;
|
10
11
|
}) => JSX.Element;
|
@@ -15,11 +15,12 @@ export declare const RangeSlideClasses: {
|
|
15
15
|
thumbHover: string;
|
16
16
|
thumbActive: string;
|
17
17
|
};
|
18
|
-
export declare const RangeSliderInput: ({ defaultValue, onChange, min, max, step, }: {
|
18
|
+
export declare const RangeSliderInput: ({ defaultValue, onChange, onSlide, min, max, step, }: {
|
19
19
|
min: number;
|
20
20
|
max: number;
|
21
21
|
step: number;
|
22
22
|
defaultValue: ValueType;
|
23
23
|
onChange: (data: ValueType) => void;
|
24
|
+
onSlide?: ((data: ValueType) => void) | undefined;
|
24
25
|
}) => JSX.Element;
|
25
26
|
export {};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentecacommerce-theme/lib",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "0.12.
|
4
|
+
"version": "0.12.96",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
7
7
|
"types": "dist/types/index.d.ts",
|
@@ -31,13 +31,13 @@
|
|
31
31
|
"watch:cjs": "swc src --out-dir dist/cjs -w",
|
32
32
|
"watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
|
33
33
|
},
|
34
|
-
"gitHead": "
|
34
|
+
"gitHead": "857da38c2eb402b3d8a51ad70ffbb5dc770febff",
|
35
35
|
"peerDependencies": {
|
36
36
|
"react-query": "^2.26.2"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@sentecacommerce-theme/base": "^0.12.
|
40
|
-
"@sentecacommerce-theme/cms": "^0.12.
|
39
|
+
"@sentecacommerce-theme/base": "^0.12.96",
|
40
|
+
"@sentecacommerce-theme/cms": "^0.12.96",
|
41
41
|
"@sentecacommerce/sdk": "2.0.161",
|
42
42
|
"body-scroll-lock": "^3.1.5",
|
43
43
|
"copy-to-clipboard": "^3.3.1",
|