@sentecacommerce-theme/lib 0.12.95 → 0.12.99

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 (51) hide show
  1. package/dist/cjs/analytics/Pixel/mainScript.js +2 -1
  2. package/dist/cjs/api/getSDKConfig.js +4 -2
  3. package/dist/cjs/api/myCartApi/index.js +8 -2
  4. package/dist/cjs/config/SentecaProvider.js +3 -1
  5. package/dist/cjs/hooks/useAvailability/index.js +1 -1
  6. package/dist/cjs/hooks/useProduct/index.js +15 -5
  7. package/dist/cjs/listing/api/queries/useListingQuery.js +1 -1
  8. package/dist/cjs/listing/hooks/useListingMeta.js +49 -40
  9. package/dist/cjs/listing/hooks/useSlideFilter.js +24 -3
  10. package/dist/cjs/listing/ssr/prefetchCategories.js +5 -6
  11. package/dist/cjs/listing/ssr/prefetchPredicate.js +4 -4
  12. package/dist/cjs/seo/components/TranslationsMeta/index.js +58 -0
  13. package/dist/cjs/seo/components/index.js +12 -0
  14. package/dist/cjs/seo/hooks/index.js +14 -0
  15. package/dist/cjs/seo/hooks/useSeoTranslations.js +90 -0
  16. package/dist/cjs/ui/components/GridStyles.js +2 -2
  17. package/dist/cjs/ui/components/RangeSliderInput.js +14 -1
  18. package/dist/cjs/utils/getLocaleFromPath.js +13 -0
  19. package/dist/cjs/utils/index.js +12 -0
  20. package/dist/cjs/utils/isTouchDevice.js +2 -1
  21. package/dist/esm/analytics/Pixel/mainScript.js +2 -1
  22. package/dist/esm/api/getSDKConfig.js +5 -3
  23. package/dist/esm/api/myCartApi/index.js +8 -2
  24. package/dist/esm/config/SentecaProvider.js +3 -1
  25. package/dist/esm/hooks/useAvailability/index.js +1 -1
  26. package/dist/esm/hooks/useProduct/index.js +26 -16
  27. package/dist/esm/listing/api/queries/useListingQuery.js +1 -1
  28. package/dist/esm/listing/hooks/useListingMeta.js +49 -40
  29. package/dist/esm/listing/hooks/useSlideFilter.js +24 -3
  30. package/dist/esm/listing/ssr/prefetchCategories.js +6 -7
  31. package/dist/esm/listing/ssr/prefetchPredicate.js +4 -4
  32. package/dist/esm/seo/components/TranslationsMeta/index.js +48 -0
  33. package/dist/esm/seo/components/index.js +1 -0
  34. package/dist/esm/seo/hooks/index.js +1 -0
  35. package/dist/esm/seo/hooks/useSeoTranslations.js +79 -0
  36. package/dist/esm/ui/components/GridStyles.js +2 -2
  37. package/dist/esm/ui/components/RangeSliderInput.js +14 -1
  38. package/dist/esm/utils/getLocaleFromPath.js +8 -0
  39. package/dist/esm/utils/index.js +1 -0
  40. package/dist/esm/utils/isTouchDevice.js +2 -1
  41. package/dist/types/listing/hooks/useSlideFilter.d.ts +4 -0
  42. package/dist/types/listing/types.d.ts +10 -0
  43. package/dist/types/seo/components/TranslationsMeta/index.d.ts +1 -0
  44. package/dist/types/seo/components/index.d.ts +1 -0
  45. package/dist/types/seo/hooks/index.d.ts +1 -0
  46. package/dist/types/seo/hooks/useSeoTranslations.d.ts +24 -0
  47. package/dist/types/ui/components/GridStyles.d.ts +2 -1
  48. package/dist/types/ui/components/RangeSliderInput.d.ts +2 -1
  49. package/dist/types/utils/getLocaleFromPath.d.ts +1 -0
  50. package/dist/types/utils/index.d.ts +1 -0
  51. package/package.json +4 -4
@@ -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: 8rem;\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 ")
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
@@ -0,0 +1,8 @@
1
+ import { canUseDOM } from './canUseDom';
2
+ export var getLocaleFromPath = function() {
3
+ if (!canUseDOM()) return '';
4
+ var locale = window.location.pathname.split('/')[1] || '';
5
+ // the allowed standards: bg bg-BG, en en-US/en-UK
6
+ if (locale.length !== 2 && locale.length !== 5) return '';
7
+ return locale;
8
+ };
@@ -13,6 +13,7 @@ export * from './getTranslatableField';
13
13
  export * from './formatAsCurrency';
14
14
  export * from './createCatalogBreadcrumb';
15
15
  export * from './adjustColor';
16
+ export * from './getLocaleFromPath';
16
17
  export * from './calcDiscount';
17
18
  export * from './canUseDom';
18
19
  export * from './getFirst';
@@ -1,3 +1,4 @@
1
+ import { canUseDOM } from "./canUseDom";
1
2
  export function isTouchDevice() {
2
- return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
3
+ return canUseDOM() && ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
3
4
  }
@@ -3,6 +3,10 @@ export declare const useSlideFilter: (filterName: string, min: number, max: numb
3
3
  from: number;
4
4
  to: number;
5
5
  };
6
+ applyFilter: (data: {
7
+ from: number;
8
+ to: number;
9
+ }) => void;
6
10
  updateValue: (data: {
7
11
  from: number;
8
12
  to: number;
@@ -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;
@@ -0,0 +1 @@
1
+ export declare const TranslationsMeta: () => JSX.Element | null;
@@ -4,3 +4,4 @@ export * from './GlobalSEO';
4
4
  export * from './OpenGraph';
5
5
  export * from './ProductSEO';
6
6
  export * from './HiddenBreadcrumb';
7
+ export * from './TranslationsMeta';
@@ -1 +1,2 @@
1
1
  export * from './useSEOBreadcrumb';
2
+ export * from './useSeoTranslations';
@@ -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 {};
@@ -0,0 +1 @@
1
+ export declare const getLocaleFromPath: () => string;
@@ -13,6 +13,7 @@ export * from './getTranslatableField';
13
13
  export * from './formatAsCurrency';
14
14
  export * from './createCatalogBreadcrumb';
15
15
  export * from './adjustColor';
16
+ export * from './getLocaleFromPath';
16
17
  export * from './calcDiscount';
17
18
  export * from './canUseDom';
18
19
  export * from './getFirst';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.12.95",
4
+ "version": "0.12.99",
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": "e4ce21f505cc0bea992d4a3fb45ff7d72cdee868",
34
+ "gitHead": "d6b1f3475733f0402697b241e884628656aadf92",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.12.95",
40
- "@sentecacommerce-theme/cms": "^0.12.95",
39
+ "@sentecacommerce-theme/base": "^0.12.99",
40
+ "@sentecacommerce-theme/cms": "^0.12.99",
41
41
  "@sentecacommerce/sdk": "2.0.161",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",