@c-rex/components 0.1.37 → 0.1.39
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/README.md +73 -73
- package/package.json +250 -235
- package/src/article/article-action-bar.tsx +110 -110
- package/src/article/article-content.tsx +18 -46
- package/src/autocomplete.tsx +201 -201
- package/src/breadcrumb.tsx +124 -124
- package/src/carousel/carousel.tsx +353 -352
- package/src/check-article-lang.tsx +47 -43
- package/src/directoryNodes/directory-tree-context.tsx +388 -0
- package/src/directoryNodes/tree-of-content.tsx +68 -67
- package/src/documents/result-list.tsx +124 -127
- package/src/favorites/bookmark-button.tsx +97 -79
- package/src/favorites/favorite-button.tsx +137 -74
- package/src/footer/footer-shell.tsx +52 -0
- package/src/footer/footer.tsx +7 -0
- package/src/footer/legal-links-block.tsx +25 -0
- package/src/footer/organization-contact-block.tsx +94 -0
- package/src/footer/social-links-block.tsx +38 -0
- package/src/footer/types.ts +10 -0
- package/src/footer/vcard-footer.tsx +72 -0
- package/src/generated/client-components.tsx +1366 -1350
- package/src/generated/create-client-request.tsx +116 -113
- package/src/generated/create-server-request.tsx +70 -61
- package/src/generated/create-suggestions-request.tsx +55 -55
- package/src/generated/server-components.tsx +1056 -1056
- package/src/generated/suggestions.tsx +302 -299
- package/src/icons/file-icon.tsx +8 -8
- package/src/icons/flag-icon.tsx +15 -15
- package/src/icons/loading.tsx +11 -11
- package/src/icons/social-icon.tsx +24 -0
- package/src/info/info-card.tsx +43 -0
- package/src/info/{info-table.tsx → information-unit-metadata-grid.tsx} +157 -146
- package/src/info/shared.tsx +49 -25
- package/src/navbar/language-switcher/content-language-switch.tsx +92 -92
- package/src/navbar/language-switcher/shared.tsx +33 -33
- package/src/navbar/language-switcher/ui-language-switch.tsx +37 -38
- package/src/navbar/navbar.tsx +157 -148
- package/src/navbar/settings.tsx +62 -62
- package/src/navbar/sign-in-out-btns.tsx +35 -35
- package/src/navbar/user-menu.tsx +60 -60
- package/src/page-wrapper.tsx +54 -31
- package/src/render-article.module.css +155 -0
- package/src/render-article.tsx +75 -68
- package/src/renditions/file-download.tsx +83 -83
- package/src/renditions/html.tsx +64 -64
- package/src/renditions/image/container.tsx +54 -54
- package/src/renditions/image/rendition.tsx +55 -55
- package/src/restriction-menu/restriction-menu-container.tsx +117 -53
- package/src/restriction-menu/restriction-menu-item.tsx +155 -147
- package/src/restriction-menu/restriction-menu.tsx +341 -157
- package/src/results/dialog-filter.tsx +166 -166
- package/src/results/empty.tsx +15 -15
- package/src/results/filter-navbar.tsx +294 -261
- package/src/results/filter-sidebar/__tests__/utils.test.ts +129 -0
- package/src/results/filter-sidebar/index.tsx +270 -126
- package/src/results/filter-sidebar/utils.ts +196 -164
- package/src/results/generic/table-result-list.tsx +97 -99
- package/src/results/{table-with-images.tsx → information-unit-search-results-card-list.tsx} +125 -127
- package/src/results/{cards.tsx → information-unit-search-results-cards.tsx} +99 -99
- package/src/results/{table.tsx → information-unit-search-results-table.tsx} +104 -104
- package/src/results/pagination.tsx +81 -81
- package/src/results/summary.ts +30 -0
- package/src/results/utils.ts +54 -47
- package/src/search-input.tsx +70 -70
- package/src/share-button.tsx +49 -49
- package/src/stores/favorites-store.ts +88 -88
- package/src/stores/highlight-store.ts +15 -15
- package/src/stores/language-store.ts +14 -43
- package/src/stores/restriction-store.ts +11 -11
- package/src/stores/search-settings-store.ts +68 -64
- package/src/article/article-action-bar.analysis.md +0 -15
- package/src/article/article-action-bar.stories.tsx +0 -15
- package/src/article/article-content.analysis.md +0 -15
- package/src/article/article-content.stories.tsx +0 -21
- package/src/autocomplete.analysis.md +0 -17
- package/src/breadcrumb.analysis.md +0 -15
- package/src/carousel/carousel.analysis.md +0 -17
- package/src/check-article-lang.analysis.md +0 -15
- package/src/directoryNodes/tree-of-content.analysis.md +0 -14
- package/src/directoryNodes/tree-of-content.stories.tsx +0 -22
- package/src/documents/result-list.analysis.md +0 -14
- package/src/documents/result-list.stories.tsx +0 -19
- package/src/favorites/bookmark-button.analysis.md +0 -17
- package/src/favorites/bookmark-button.stories.tsx +0 -19
- package/src/favorites/favorite-button.analysis.md +0 -18
- package/src/favorites/favorite-button.stories.tsx +0 -22
- package/src/icons/file-icon.analysis.md +0 -14
- package/src/icons/file-icon.stories.tsx +0 -19
- package/src/icons/flag-icon.analysis.md +0 -14
- package/src/icons/flag-icon.stories.tsx +0 -25
- package/src/icons/loading.analysis.md +0 -14
- package/src/icons/loading.stories.tsx +0 -21
- package/src/info/info-table.analysis.md +0 -15
- package/src/info/shared.analysis.md +0 -14
- package/src/info/stories/info-table.stories.tsx +0 -31
- package/src/info/stories/shared.stories.tsx +0 -24
- package/src/navbar/language-switcher/content-language-switch.analysis.md +0 -15
- package/src/navbar/language-switcher/shared.analysis.md +0 -14
- package/src/navbar/language-switcher/ui-language-switch.analysis.md +0 -15
- package/src/navbar/navbar.analysis.md +0 -14
- package/src/navbar/settings.analysis.md +0 -14
- package/src/navbar/sign-in-out-btns.analysis.md +0 -14
- package/src/navbar/stories/navbar.stories.tsx +0 -31
- package/src/navbar/stories/settings.stories.tsx +0 -15
- package/src/navbar/stories/sign-in-out-btns.stories.tsx +0 -15
- package/src/navbar/stories/user-menu.stories.tsx +0 -20
- package/src/navbar/user-menu.analysis.md +0 -14
- package/src/page-wrapper.analysis.md +0 -14
- package/src/render-article.analysis.md +0 -15
- package/src/renditions/file-download.analysis.md +0 -14
- package/src/renditions/file-download.stories.tsx +0 -19
- package/src/renditions/html.analysis.md +0 -17
- package/src/renditions/html.stories.tsx +0 -19
- package/src/renditions/image/container.analysis.md +0 -15
- package/src/renditions/image/container.stories.tsx +0 -19
- package/src/renditions/image/rendition.analysis.md +0 -14
- package/src/renditions/image/rendition.stories.tsx +0 -19
- package/src/restriction-menu/restriction-menu-container.analysis.md +0 -14
- package/src/restriction-menu/restriction-menu-item.analysis.md +0 -14
- package/src/restriction-menu/restriction-menu.analysis.md +0 -17
- package/src/results/analysis/cards.analysis.md +0 -14
- package/src/results/analysis/dialog-filter.analysis.md +0 -17
- package/src/results/analysis/empty.analysis.md +0 -14
- package/src/results/analysis/filter-navbar.analysis.md +0 -16
- package/src/results/analysis/pagination.analysis.md +0 -14
- package/src/results/analysis/table-with-images.analysis.md +0 -15
- package/src/results/analysis/table.analysis.md +0 -15
- package/src/results/filter-sidebar/index.analysis.md +0 -14
- package/src/results/generic/table-result-list.analysis.md +0 -15
- package/src/results/generic/table-result-list.stories.tsx +0 -21
- package/src/results/stories/cards.stories.tsx +0 -66
- package/src/results/stories/dialog-filter.stories.tsx +0 -20
- package/src/results/stories/empty.stories.tsx +0 -25
- package/src/results/stories/filter-navbar.stories.tsx +0 -19
- package/src/results/stories/filter-sidebar.stories.tsx +0 -20
- package/src/results/stories/pagination.stories.tsx +0 -24
- package/src/results/stories/table-with-images.stories.tsx +0 -19
- package/src/results/stories/table.stories.tsx +0 -78
- package/src/search-input.analysis.md +0 -15
- package/src/share-button.analysis.md +0 -19
- package/src/stories/autocomplete.stories.tsx +0 -20
- package/src/stories/breadcrumb.stories.tsx +0 -93
- package/src/stories/check-article-lang.stories.tsx +0 -22
- package/src/stories/render-article.stories.tsx +0 -19
- package/src/stories/search-input.stories.tsx +0 -21
- package/src/stories/share-button.stories.tsx +0 -15
|
@@ -1,164 +1,196 @@
|
|
|
1
|
-
import { FilterItem, Tags } from "@c-rex/interfaces";
|
|
2
|
-
import { EN_LANG } from "@c-rex/constants";
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
1
|
+
import { FilterItem, Tags } from "@c-rex/interfaces";
|
|
2
|
+
import { EN_LANG } from "@c-rex/constants";
|
|
3
|
+
|
|
4
|
+
export type FacetLabelOverride = {
|
|
5
|
+
label: string;
|
|
6
|
+
groupLabel?: string;
|
|
7
|
+
sectionLabel?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type FacetLabelOverrides = Partial<Record<string, Record<string, FacetLabelOverride>>>;
|
|
11
|
+
|
|
12
|
+
export type ResolvedFilterItem = FilterItem & {
|
|
13
|
+
groupLabel?: string;
|
|
14
|
+
sectionLabel?: string;
|
|
15
|
+
taxonomyId?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const updateFilterParam = (key: string, item: FilterItem, filter: string | null): Record<string, string | null> => {
|
|
19
|
+
|
|
20
|
+
if (key === "packages") {
|
|
21
|
+
return { packages: item.shortId }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const value = `${key}.shortId=${item.shortId}`
|
|
25
|
+
let aux = value
|
|
26
|
+
|
|
27
|
+
if (filter != null) {
|
|
28
|
+
const splittedParam = filter.split(",")
|
|
29
|
+
const finalValue = [...splittedParam]
|
|
30
|
+
|
|
31
|
+
const hasParams = filter.includes(key)
|
|
32
|
+
|
|
33
|
+
if (hasParams) {
|
|
34
|
+
let mainIndex = -1
|
|
35
|
+
|
|
36
|
+
splittedParam.forEach((el, index) => {
|
|
37
|
+
if (el.includes(key)) {
|
|
38
|
+
mainIndex = index
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
finalValue[mainIndex] = value
|
|
42
|
+
} else {
|
|
43
|
+
finalValue.push(value)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
aux = finalValue.join(",")
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { filter: aux }
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const removeFilterItem = (key: string, item: FilterItem, filter: string | null): Record<string, string | null> => {
|
|
53
|
+
if (key === "packages") {
|
|
54
|
+
return { packages: null }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (filter !== null) {
|
|
58
|
+
const value = `${key}.shortId=${item.shortId}`
|
|
59
|
+
const newValue = filter.split(",").filter(item => item !== value).join(",")
|
|
60
|
+
return { filter: newValue.length === 0 ? null : newValue }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const resolveLabelByLanguage = (
|
|
67
|
+
labels: { language?: string; value: string }[],
|
|
68
|
+
uiLanguage?: string
|
|
69
|
+
): string | undefined => {
|
|
70
|
+
if (!labels || labels.length === 0) return undefined;
|
|
71
|
+
|
|
72
|
+
const normalizedLanguage = (uiLanguage || EN_LANG).toLowerCase();
|
|
73
|
+
const baseLanguage = normalizedLanguage.split("-")[0];
|
|
74
|
+
|
|
75
|
+
const exact = labels.find((item) => item.language?.toLowerCase() === normalizedLanguage)?.value;
|
|
76
|
+
if (exact) return exact;
|
|
77
|
+
|
|
78
|
+
const base = labels.find((item) => item.language?.toLowerCase() === baseLanguage)?.value;
|
|
79
|
+
if (base) return base;
|
|
80
|
+
|
|
81
|
+
const withoutLanguage = labels.find((item) => !item.language)?.value;
|
|
82
|
+
if (withoutLanguage) return withoutLanguage;
|
|
83
|
+
|
|
84
|
+
return labels[0]?.value;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const clearData = (
|
|
88
|
+
tags: Tags,
|
|
89
|
+
options?: { uiLanguage?: string; labelOverrides?: FacetLabelOverrides; includeZeroHits?: boolean }
|
|
90
|
+
): Record<string, ResolvedFilterItem[]> => {
|
|
91
|
+
const includeZeroHits = options?.includeZeroHits ?? true;
|
|
92
|
+
const filteredTags: Record<string, ResolvedFilterItem[]> = {}
|
|
93
|
+
|
|
94
|
+
for (const [key, value] of Object.entries(tags)) {
|
|
95
|
+
if (!value || !value.items || value.items.length === 0) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const aux = value.items.map(item => {
|
|
100
|
+
if (item?.shortId === undefined) return null
|
|
101
|
+
if (!includeZeroHits && Number(item.hits) === 0) return null
|
|
102
|
+
|
|
103
|
+
const override = options?.labelOverrides?.[key]?.[item.shortId];
|
|
104
|
+
const label = override?.label || resolveLabelByLanguage(item.labels || [], options?.uiLanguage);
|
|
105
|
+
if (!label) return null;
|
|
106
|
+
const taxonomyId = (item as { id?: string }).id;
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
hits: item.hits,
|
|
110
|
+
total: item.total,
|
|
111
|
+
label,
|
|
112
|
+
active: false,
|
|
113
|
+
shortId: item.shortId,
|
|
114
|
+
groupLabel: override?.groupLabel,
|
|
115
|
+
sectionLabel: override?.sectionLabel,
|
|
116
|
+
taxonomyId,
|
|
117
|
+
}
|
|
118
|
+
}).filter((item) => item !== null)
|
|
119
|
+
|
|
120
|
+
if (aux.length === 0) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
filteredTags[key] = aux;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return filteredTags;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const memoizeFilteredTags = (
|
|
131
|
+
tags: Tags | undefined,
|
|
132
|
+
filter: string | null,
|
|
133
|
+
packages: string | null,
|
|
134
|
+
options?: { uiLanguage?: string; labelOverrides?: FacetLabelOverrides; includeZeroHits?: boolean }
|
|
135
|
+
) => {
|
|
136
|
+
|
|
137
|
+
if (!tags) return {};
|
|
138
|
+
|
|
139
|
+
const newTags: Record<string, ResolvedFilterItem[]> = clearData(tags, options);
|
|
140
|
+
|
|
141
|
+
if (filter !== null) {
|
|
142
|
+
const splittedParam = filter.split(",")
|
|
143
|
+
|
|
144
|
+
splittedParam.forEach((item) => {
|
|
145
|
+
const aux = item.split(".shortId=")
|
|
146
|
+
const name = aux[0] as string
|
|
147
|
+
const shortId = aux[1] as string
|
|
148
|
+
|
|
149
|
+
if (!Object.keys(newTags).includes(name)) {
|
|
150
|
+
newTags[name] = []
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
newTags[name]?.forEach((el) => {
|
|
154
|
+
if (el.shortId == shortId) {
|
|
155
|
+
el.active = true
|
|
156
|
+
} else {
|
|
157
|
+
el.active = false
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
} else {
|
|
162
|
+
Object.keys(newTags).forEach((key) => {
|
|
163
|
+
newTags[key]?.forEach((el) => {
|
|
164
|
+
el.active = false
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (packages !== null && newTags["packages"]) {
|
|
170
|
+
newTags["packages"].forEach((el) => {
|
|
171
|
+
if (el.shortId == packages) {
|
|
172
|
+
el.active = true
|
|
173
|
+
} else {
|
|
174
|
+
el.active = false
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return newTags
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export const applyFacetPropertyVisibility = (
|
|
183
|
+
tags: Record<string, ResolvedFilterItem[]>,
|
|
184
|
+
includeProperties?: string[],
|
|
185
|
+
excludeProperties?: string[]
|
|
186
|
+
): Record<string, ResolvedFilterItem[]> => {
|
|
187
|
+
const includeSet = new Set((includeProperties || []).filter(Boolean));
|
|
188
|
+
const excludeSet = new Set((excludeProperties || []).filter(Boolean));
|
|
189
|
+
|
|
190
|
+
return Object.entries(tags).reduce<Record<string, ResolvedFilterItem[]>>((acc, [key, value]) => {
|
|
191
|
+
if (includeSet.size > 0 && !includeSet.has(key)) return acc;
|
|
192
|
+
if (excludeSet.has(key)) return acc;
|
|
193
|
+
acc[key] = value;
|
|
194
|
+
return acc;
|
|
195
|
+
}, {});
|
|
196
|
+
}
|
|
@@ -1,99 +1,97 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
import { CommonItemsModel } from "@c-rex/interfaces";
|
|
3
|
-
import { cn, generateQueryParams
|
|
4
|
-
import { Flag } from "@c-rex/components/flag";
|
|
5
|
-
import { Badge } from "@c-rex/ui/badge";
|
|
6
|
-
import Link from "next/link";
|
|
7
|
-
import { FileDownloadDropdown } from "@c-rex/components/file-download";
|
|
8
|
-
import { getTranslations } from "next-intl/server";
|
|
9
|
-
import { QueryParams } from "@c-rex/types";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div className="
|
|
33
|
-
<div className="w-1/2 md:w-1/5 p-2 flex justify-center">{t("
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const itemType =
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
);
|
|
99
|
-
};
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { CommonItemsModel } from "@c-rex/interfaces";
|
|
3
|
+
import { cn, generateQueryParams } from "@c-rex/utils";
|
|
4
|
+
import { Flag } from "@c-rex/components/flag";
|
|
5
|
+
import { Badge } from "@c-rex/ui/badge";
|
|
6
|
+
import Link from "next/link";
|
|
7
|
+
import { FileDownloadDropdown } from "@c-rex/components/file-download";
|
|
8
|
+
import { getTranslations } from "next-intl/server";
|
|
9
|
+
import { QueryParams } from "@c-rex/types";
|
|
10
|
+
import { getResultItemSummary } from "../summary";
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
items: CommonItemsModel[];
|
|
14
|
+
linkPattern: string;
|
|
15
|
+
addPackageId: boolean
|
|
16
|
+
showFilesColumn?: boolean;
|
|
17
|
+
query?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const GenericTableResultList: FC<Props> = async ({
|
|
21
|
+
items,
|
|
22
|
+
linkPattern,
|
|
23
|
+
addPackageId,
|
|
24
|
+
query,
|
|
25
|
+
showFilesColumn = true,
|
|
26
|
+
}) => {
|
|
27
|
+
const t = await getTranslations("results");
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="rounded-md border mb-6 last:border-b-0">
|
|
31
|
+
<div className="font-bold text-sm p-2 border-b items-center flex-wrap hidden md:flex">
|
|
32
|
+
<div className="flex-1 p-2">{t("title")}</div>
|
|
33
|
+
<div className="w-1/2 md:w-1/5 p-2 flex justify-center">{t("language")}</div>
|
|
34
|
+
<div className="w-1/2 md:w-1/5 p-2 flex justify-center">{t("type")}</div>
|
|
35
|
+
{showFilesColumn &&
|
|
36
|
+
<div className="w-1/2 md:w-1/5 p-2 flex justify-center">{t("files")}</div>
|
|
37
|
+
}
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
{items.map((item) => {
|
|
41
|
+
const { title, itemType, language, countryCode, packageId } = getResultItemSummary(item);
|
|
42
|
+
const queryParams: QueryParams[] = []
|
|
43
|
+
|
|
44
|
+
if (addPackageId && packageId) {
|
|
45
|
+
queryParams.push({
|
|
46
|
+
key: "package",
|
|
47
|
+
value: packageId,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (query != undefined) {
|
|
52
|
+
queryParams.push({
|
|
53
|
+
key: "q",
|
|
54
|
+
value: query,
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const params = generateQueryParams(queryParams)
|
|
59
|
+
const link = linkPattern.replace("{shortId}", item.shortId!) + (params.length > 0 ? `?${params}` : "")
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
className={cn(
|
|
64
|
+
"min-h-12 c-rex-result-item flex flex-wrap items-center border-b",
|
|
65
|
+
`c-rex-result-${itemType.toLowerCase()}`,
|
|
66
|
+
)}
|
|
67
|
+
key={item.shortId}
|
|
68
|
+
>
|
|
69
|
+
<div className="flex-1 p-2">
|
|
70
|
+
<Link href={link} className="hover:underline">{title}</Link>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div className="w-1/5 md:w-1/5 flex justify-center p-2">
|
|
74
|
+
<span className="w-8 inline-block">
|
|
75
|
+
{countryCode.length > 0 && (
|
|
76
|
+
<Flag countryCode={countryCode} />
|
|
77
|
+
)}
|
|
78
|
+
</span>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<div className="w-4/5 md:w-1/5 p-2 flex justify-center">
|
|
82
|
+
<Badge variant="secondary">
|
|
83
|
+
{itemType}
|
|
84
|
+
</Badge>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
{showFilesColumn &&
|
|
88
|
+
<div className="w-1/5 flex justify-center p-2">
|
|
89
|
+
<FileDownloadDropdown renditions={item.renditions} />
|
|
90
|
+
</div>
|
|
91
|
+
}
|
|
92
|
+
</div>
|
|
93
|
+
)
|
|
94
|
+
})}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|