ublo-lib 1.15.1 → 1.16.1
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/es/common/components/carousel.js +124 -113
- package/es/common/components/instant-search/hooks/use-constant.d.ts +2 -0
- package/es/common/components/instant-search/hooks/use-constant.d.ts.map +1 -0
- package/es/common/components/instant-search/hooks/use-constant.js +8 -0
- package/es/common/components/instant-search/hooks/use-debounced-search.d.ts +7 -0
- package/es/common/components/instant-search/hooks/use-debounced-search.d.ts.map +1 -0
- package/es/common/components/instant-search/hooks/use-debounced-search.js +11 -0
- package/es/common/components/instant-search/hooks/use-search.d.ts +16 -0
- package/es/common/components/instant-search/hooks/use-search.d.ts.map +1 -0
- package/es/common/components/instant-search/hooks/use-search.js +10 -0
- package/es/common/components/instant-search/i18n.json +76 -0
- package/es/common/components/instant-search/index.d.ts +3 -0
- package/es/common/components/instant-search/index.d.ts.map +1 -0
- package/es/common/components/instant-search/index.js +2 -0
- package/es/common/components/instant-search/input.d.ts +16 -0
- package/es/common/components/instant-search/input.d.ts.map +1 -0
- package/es/common/components/instant-search/input.js +56 -0
- package/es/common/components/instant-search/input.module.css +87 -0
- package/es/common/components/instant-search/instant-search.d.ts +15 -0
- package/es/common/components/instant-search/instant-search.d.ts.map +1 -0
- package/es/common/components/instant-search/instant-search.js +95 -0
- package/es/common/components/instant-search/instant-search.module.css +38 -0
- package/es/common/components/instant-search/links.d.ts +13 -0
- package/es/common/components/instant-search/links.d.ts.map +1 -0
- package/es/common/components/instant-search/links.js +30 -0
- package/es/common/components/instant-search/links.module.css +96 -0
- package/es/common/components/instant-search/no-product.d.ts +7 -0
- package/es/common/components/instant-search/no-product.d.ts.map +1 -0
- package/es/common/components/instant-search/no-product.js +4 -0
- package/es/common/components/instant-search/products.d.ts +14 -0
- package/es/common/components/instant-search/products.d.ts.map +1 -0
- package/es/common/components/instant-search/products.js +42 -0
- package/es/common/components/instant-search/products.module.css +133 -0
- package/es/common/components/instant-search/results.d.ts +77 -0
- package/es/common/components/instant-search/results.d.ts.map +1 -0
- package/es/common/components/instant-search/results.js +41 -0
- package/es/common/components/instant-search/results.module.css +95 -0
- package/es/common/components/instant-search/services/api.d.ts +2 -0
- package/es/common/components/instant-search/services/api.d.ts.map +1 -0
- package/es/common/components/instant-search/services/api.js +13 -0
- package/es/common/components/instant-search/services/dates.js +50 -0
- package/es/common/components/instant-search/services/messages.d.ts +2 -0
- package/es/common/components/instant-search/services/messages.d.ts.map +1 -0
- package/es/common/components/instant-search/services/messages.js +5 -0
- package/es/common/components/instant-search/services/utils.d.ts +4 -0
- package/es/common/components/instant-search/services/utils.d.ts.map +1 -0
- package/es/common/components/instant-search/services/utils.js +39 -0
- package/package.json +3 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.results {
|
|
2
|
+
width: calc(100% - 20px);
|
|
3
|
+
height: 600px;
|
|
4
|
+
max-height: 70vh;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
margin: 0 10px 10px 10px;
|
|
8
|
+
padding: 10px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.results:not(:empty) {
|
|
12
|
+
padding: 0;
|
|
13
|
+
background-color: var(--ds-grey-000, #fff);
|
|
14
|
+
border-radius: var(--ds-radius-100, 6px);
|
|
15
|
+
box-shadow: var(--ds-shadow-200, 0 5px 10px rgba(0, 0, 0, 0.12));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.inner {
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
border-radius: var(--ds-radius-100, 6px);
|
|
24
|
+
overflow: auto;
|
|
25
|
+
overscroll-behavior: contain;
|
|
26
|
+
-webkit-overflow-scrolling: touch;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media (min-width: 730px) {
|
|
30
|
+
.inner {
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
overflow: visible;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.left {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: 10px;
|
|
40
|
+
padding: 16px;
|
|
41
|
+
order: 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.left:empty {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media (min-width: 730px) {
|
|
49
|
+
.left {
|
|
50
|
+
flex: 0 0 330px;
|
|
51
|
+
order: 0;
|
|
52
|
+
overflow: auto;
|
|
53
|
+
overscroll-behavior: contain;
|
|
54
|
+
-webkit-overflow-scrolling: touch;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.right {
|
|
59
|
+
position: relative;
|
|
60
|
+
flex: 1 1 auto;
|
|
61
|
+
display: grid;
|
|
62
|
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
63
|
+
align-content: flex-start;
|
|
64
|
+
background-color: var(--ds-grey-100, #f5f5f5);
|
|
65
|
+
border-radius: var(--ds-radius-100, 6px) var(--ds-radius-100, 6px) 0 0;
|
|
66
|
+
gap: 16px;
|
|
67
|
+
padding: 16px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@media (min-width: 730px) {
|
|
71
|
+
.right {
|
|
72
|
+
border-radius: 0 var(--ds-radius-100, 6px) var(--ds-radius-100, 6px) 0;
|
|
73
|
+
overflow: auto;
|
|
74
|
+
overscroll-behavior: contain;
|
|
75
|
+
-webkit-overflow-scrolling: touch;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.resultsWithWeekTitle,
|
|
80
|
+
.resultsWithoutWeekTitle {
|
|
81
|
+
--ds-button-text-transform: none;
|
|
82
|
+
|
|
83
|
+
grid-column: 1 / -1;
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
flex-wrap: wrap;
|
|
88
|
+
gap: 10px;
|
|
89
|
+
padding: 12px 8px;
|
|
90
|
+
text-align: center;
|
|
91
|
+
font-size: 15px;
|
|
92
|
+
background-color: var(--ds-grey-000, #fff);
|
|
93
|
+
border-radius: var(--ds-radius-100, 6px);
|
|
94
|
+
z-index: 1;
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/instant-search/services/api.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAU,EACtB,OAAO,GAAE,MAAgE,EACzE,cAAc,CAAC,EAAE,MAAM,OAcxB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// import * as Fetcher from "ublo-lib/es/common/utils/fetcher";
|
|
2
|
+
import * as Fetcher from "../../../utils/fetcher";
|
|
3
|
+
const api = "https://search.ublo.app/api";
|
|
4
|
+
export function fetchResults(site, lang, query, groupLimit = 8, queryBy = "title,text,pageTitle,seoKeywords,parentTitle,seoTitle", queryByWeights) {
|
|
5
|
+
const endpoint = `${api}/search`;
|
|
6
|
+
return Fetcher.post(endpoint, {
|
|
7
|
+
q: query,
|
|
8
|
+
query_by: queryBy,
|
|
9
|
+
query_by_weights: queryByWeights,
|
|
10
|
+
group_limit: groupLimit,
|
|
11
|
+
per_page: 30,
|
|
12
|
+
}, { site, lang });
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function padStart(value, count, pad) {
|
|
2
|
+
let str = String(value);
|
|
3
|
+
while (str.length < count) {
|
|
4
|
+
str = pad + str;
|
|
5
|
+
}
|
|
6
|
+
return str;
|
|
7
|
+
}
|
|
8
|
+
function createDate(...args) {
|
|
9
|
+
const ref = new Date(...args);
|
|
10
|
+
const yy = ref.getFullYear();
|
|
11
|
+
const mm = padStart(ref.getMonth() + 1, 2, 0);
|
|
12
|
+
const dd = padStart(ref.getDate(), 2, 0);
|
|
13
|
+
const str = `${yy}-${mm}-${dd}`;
|
|
14
|
+
return new Date(str);
|
|
15
|
+
}
|
|
16
|
+
function getPrevSaturday(date) {
|
|
17
|
+
const clone = createDate(date);
|
|
18
|
+
const day = 1 + clone.getDay();
|
|
19
|
+
const prevSaturday = clone.getDate() - day % 7;
|
|
20
|
+
clone.setDate(prevSaturday);
|
|
21
|
+
return clone;
|
|
22
|
+
}
|
|
23
|
+
function addDays(date, days) {
|
|
24
|
+
const clone = createDate(date);
|
|
25
|
+
clone.setDate(clone.getDate() + days);
|
|
26
|
+
return clone;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function christmasWeek(endWeek, forceSeasonSwitch) {
|
|
30
|
+
const now = createDate();
|
|
31
|
+
const year = now.getFullYear();
|
|
32
|
+
const month = now.getMonth();
|
|
33
|
+
const date = now.getDate();
|
|
34
|
+
const isAfterChristmas = month === 11 && date >= 25;
|
|
35
|
+
const lastChristmasYear = isAfterChristmas || !isAfterChristmas && forceSeasonSwitch ? year : year - 1;
|
|
36
|
+
const lastChristmas = createDate(lastChristmasYear, 11, 25);
|
|
37
|
+
const nextChristmas = createDate(lastChristmasYear + 1, 11, 25);
|
|
38
|
+
const dateSeasonEnd = addDays(getPrevSaturday(lastChristmas), endWeek * 7);
|
|
39
|
+
return getPrevSaturday(now <= dateSeasonEnd ? lastChristmas : nextChristmas);
|
|
40
|
+
}
|
|
41
|
+
function weekToDate(week, endWeek, forceSeasonSwitch) {
|
|
42
|
+
return addDays(christmasWeek(endWeek, forceSeasonSwitch), week * 7);
|
|
43
|
+
}
|
|
44
|
+
export function weekToLongDate(week, endWeek, forceSeasonSwitch) {
|
|
45
|
+
const date = weekToDate(week, endWeek, forceSeasonSwitch);
|
|
46
|
+
const dd = padStart(date.getDate(), 2, 0);
|
|
47
|
+
const mm = padStart(date.getMonth() + 1, 2, 0);
|
|
48
|
+
const yy = date.getFullYear();
|
|
49
|
+
return `${dd}/${mm}/${yy}`;
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/instant-search/services/messages.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAGvD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Hit, PurpleHighlight } from "../results";
|
|
2
|
+
export declare function getHighlight(property: string, highlight: PurpleHighlight, withExtractQuotes?: boolean): any;
|
|
3
|
+
export declare function filterProducts(products: Hit[], weekNumber: number | null): Hit[];
|
|
4
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/instant-search/services/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,eAAe,EAC1B,iBAAiB,GAAE,OAAe,OAoBnC;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,SAkBxE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function getHighlight(property, highlight, withExtractQuotes = false) {
|
|
2
|
+
if (!highlight[property]?.snippet)
|
|
3
|
+
return;
|
|
4
|
+
let snippet = highlight[property].snippet;
|
|
5
|
+
if (!withExtractQuotes)
|
|
6
|
+
return snippet;
|
|
7
|
+
const startsWithMaj = /[A-Z]/.test(snippet);
|
|
8
|
+
const endsWithDot = snippet[snippet.length - 1] === ".";
|
|
9
|
+
if (!startsWithMaj) {
|
|
10
|
+
snippet = `...${snippet}`;
|
|
11
|
+
}
|
|
12
|
+
if (!endsWithDot) {
|
|
13
|
+
snippet = `${snippet}...`;
|
|
14
|
+
}
|
|
15
|
+
return snippet;
|
|
16
|
+
}
|
|
17
|
+
export function filterProducts(products, weekNumber) {
|
|
18
|
+
if (weekNumber !== null) {
|
|
19
|
+
return products.filter((product) => {
|
|
20
|
+
const { weeks = [] } = product.document;
|
|
21
|
+
return weeks.includes(weekNumber);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return products.reduce((acc, product) => {
|
|
25
|
+
const { image, pageTitle } = product.document;
|
|
26
|
+
const isAlreadyInAcc = acc.some((item) => {
|
|
27
|
+
return (normalizeImage(item.document.image) === normalizeImage(image) &&
|
|
28
|
+
item.document.pageTitle === pageTitle);
|
|
29
|
+
});
|
|
30
|
+
if (isAlreadyInAcc)
|
|
31
|
+
return acc;
|
|
32
|
+
return [...acc, product];
|
|
33
|
+
}, []);
|
|
34
|
+
}
|
|
35
|
+
function normalizeImage(image) {
|
|
36
|
+
if (!image)
|
|
37
|
+
return "";
|
|
38
|
+
return image.replace(/(-[0-9]+)?.(jpg|jpeg|png|gif)/, "");
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ublo-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"dt-design-system": "^2.
|
|
5
|
+
"dt-design-system": "^2.9.0",
|
|
6
6
|
"leaflet": "^1.9.1",
|
|
7
7
|
"next": "^12.0.0 || ^13.0.0",
|
|
8
8
|
"react": "^18.2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/react-dom": "^18.0.6",
|
|
39
39
|
"classnames": "^2.3.1",
|
|
40
40
|
"cpx2": "^4.2.0",
|
|
41
|
-
"dt-design-system": "^2.
|
|
41
|
+
"dt-design-system": "^2.9.0",
|
|
42
42
|
"eslint": "^8.23.0",
|
|
43
43
|
"eslint-config-prettier": "^8.5.0",
|
|
44
44
|
"eslint-config-standard": "^17.0.0",
|