@c-rex/components 0.1.21 → 0.1.23
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/package.json +78 -62
- package/src/article/article-action-bar.tsx +89 -0
- package/src/article/article-content.tsx +55 -0
- package/src/autocomplete.tsx +55 -50
- package/src/breadcrumb.tsx +3 -1
- package/src/directoryNodes/tree-of-content.tsx +49 -0
- package/src/{bookmark-button.tsx → favorites/bookmark-button.tsx} +12 -3
- package/src/{favorite-button.tsx → favorites/favorite-button.tsx} +1 -1
- package/src/generated/client-components.tsx +1350 -0
- package/src/generated/create-client-request.tsx +105 -0
- package/src/generated/create-server-request.tsx +61 -0
- package/src/generated/create-suggestions-request.tsx +56 -0
- package/src/generated/server-components.tsx +1056 -0
- package/src/generated/suggestions.tsx +299 -0
- package/src/info/bookmark.tsx +51 -0
- package/src/info/info-table.tsx +127 -60
- package/src/info/shared.tsx +1 -1
- package/src/navbar/language-switcher/shared.tsx +1 -1
- package/src/navbar/navbar.tsx +1 -1
- package/src/{stories → navbar/stories}/navbar.stories.tsx +1 -1
- package/src/page-wrapper.tsx +1 -1
- package/src/renditions/file-download.tsx +84 -0
- package/src/renditions/html.tsx +55 -0
- package/src/renditions/image/container.tsx +52 -0
- package/src/renditions/image/rendition.tsx +61 -0
- package/src/{dialog-filter.tsx → results/dialog-filter.tsx} +22 -23
- package/src/results/filter-navbar.tsx +241 -0
- package/src/results/filter-sidebar/index.tsx +125 -0
- package/src/results/filter-sidebar/utils.ts +164 -0
- package/src/{pagination.tsx → results/pagination.tsx} +12 -10
- package/src/results/result-container.tsx +70 -0
- package/src/{stories/blog-view.stories.tsx → results/stories/cards.stories.tsx} +1 -1
- package/src/{stories/table-view.stories.tsx → results/stories/table.stories.tsx} +1 -1
- package/src/results/table-with-images.tsx +140 -0
- package/src/{result-view → results}/table.tsx +1 -2
- package/src/results/utils.ts +67 -0
- package/src/{navbar/search-input.tsx → search-input.tsx} +9 -6
- package/src/share-button.tsx +49 -0
- package/src/stores/search-settings-store.ts +1 -1
- package/src/blur-image.tsx +0 -23
- package/src/left-sidebar.tsx +0 -90
- package/src/result-list.tsx +0 -43
- package/src/result-view/table-with-images.tsx +0 -199
- package/src/right-sidebar.tsx +0 -70
- package/src/search-modal.tsx +0 -140
- package/src/stories/blur-image.stories.tsx +0 -51
- package/src/stories/sidebar.stories.tsx +0 -94
- /package/src/{file-icon.tsx → icons/file-icon.tsx} +0 -0
- /package/src/{flag.tsx → icons/flag-icon.tsx} +0 -0
- /package/src/{loading.tsx → icons/loading.tsx} +0 -0
- /package/src/{result-view/blog.tsx → results/cards.tsx} +0 -0
- /package/src/{empty.tsx → results/empty.tsx} +0 -0
- /package/src/{stories → results/stories}/empty.stories.tsx +0 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Auto-generated Suggestion Components
|
|
5
|
+
* Source: https://staging.c-rex.net/ids/api/swagger/v1/swagger.json
|
|
6
|
+
* Generated: 2025-12-10T19:29:03.931Z
|
|
7
|
+
*
|
|
8
|
+
* Each component is a wrapper around AutoComplete with a pre-configured endpoint.
|
|
9
|
+
* Do not edit manually - changes will be overwritten.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import { AutoComplete, type AutoCompleteProps } from "../autocomplete";
|
|
14
|
+
|
|
15
|
+
// Props for suggestion components (endpoint is pre-configured)
|
|
16
|
+
type SuggestionComponentProps = Omit<AutoCompleteProps, 'endpoint'>;
|
|
17
|
+
|
|
18
|
+
// Factory to create suggestion components with pre-configured endpoint
|
|
19
|
+
function createSuggestionComponent(endpoint: string) {
|
|
20
|
+
return function SuggestionComponent(props: SuggestionComponentProps) {
|
|
21
|
+
return <AutoComplete {...props} endpoint={endpoint} />;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ============================================
|
|
26
|
+
// Generated Suggestion Components
|
|
27
|
+
// ============================================
|
|
28
|
+
|
|
29
|
+
export const SearchSuggestions = createSuggestionComponent(
|
|
30
|
+
'ids/v1/Search/Suggestions'
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export const AdministrativeMetadataSuggestions = createSuggestionComponent(
|
|
34
|
+
'AdministrativeMetadata/Suggestions'
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const AfterUsesSuggestions = createSuggestionComponent(
|
|
38
|
+
'AfterUses/Suggestions'
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const CollectionsSuggestions = createSuggestionComponent(
|
|
42
|
+
'Collections/Suggestions'
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const ComponentsSuggestions = createSuggestionComponent(
|
|
46
|
+
'Components/Suggestions'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const ConceptsSuggestions = createSuggestionComponent(
|
|
50
|
+
'Concepts/Suggestions'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export const ConformitiesSuggestions = createSuggestionComponent(
|
|
54
|
+
'Conformities/Suggestions'
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export const ContentLifeCycleStatusSuggestions = createSuggestionComponent(
|
|
58
|
+
'ContentLifeCycleStatus/Suggestions'
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export const DesignAndRealizationsSuggestions = createSuggestionComponent(
|
|
62
|
+
'DesignAndRealizations/Suggestions'
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const DirectoryNodesSuggestions = createSuggestionComponent(
|
|
66
|
+
'DirectoryNodes/Suggestions'
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export const DirectoryNodeTypesSuggestions = createSuggestionComponent(
|
|
70
|
+
'DirectoryNodeTypes/Suggestions'
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export const DocumentationMetadataSuggestions = createSuggestionComponent(
|
|
74
|
+
'DocumentationMetadata/Suggestions'
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
export const DocumentsSuggestions = createSuggestionComponent(
|
|
78
|
+
'Documents/Suggestions'
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export const DocumentTypesSuggestions = createSuggestionComponent(
|
|
82
|
+
'DocumentTypes/Suggestions'
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
export const DomainEntitiesSuggestions = createSuggestionComponent(
|
|
86
|
+
'DomainEntities/Suggestions'
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
export const DownTimesSuggestions = createSuggestionComponent(
|
|
90
|
+
'DownTimes/Suggestions'
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
export const EventsSuggestions = createSuggestionComponent(
|
|
94
|
+
'Events/Suggestions'
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
export const FormalitiesSuggestions = createSuggestionComponent(
|
|
98
|
+
'Formalities/Suggestions'
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export const FormsSuggestions = createSuggestionComponent(
|
|
102
|
+
'Forms/Suggestions'
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export const FragmentsSuggestions = createSuggestionComponent(
|
|
106
|
+
'Fragments/Suggestions'
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
export const FunctionalitiesSuggestions = createSuggestionComponent(
|
|
110
|
+
'Functionalities/Suggestions'
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
export const FunctionalMetadatasSuggestions = createSuggestionComponent(
|
|
114
|
+
'FunctionalMetadatas/Suggestions'
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
export const IdentitiesSuggestions = createSuggestionComponent(
|
|
118
|
+
'Identities/Suggestions'
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
export const IdentityDomainsSuggestions = createSuggestionComponent(
|
|
122
|
+
'IdentityDomains/Suggestions'
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
export const InformationObjectsSuggestions = createSuggestionComponent(
|
|
126
|
+
'InformationObjects/Suggestions'
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
export const InformationSubjectsSuggestions = createSuggestionComponent(
|
|
130
|
+
'InformationSubjects/Suggestions'
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
export const InformationTypesSuggestions = createSuggestionComponent(
|
|
134
|
+
'InformationTypes/Suggestions'
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
export const InformationUnitsSuggestions = createSuggestionComponent(
|
|
138
|
+
'InformationUnits/Suggestions'
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
export const LearningsSuggestions = createSuggestionComponent(
|
|
142
|
+
'Learnings/Suggestions'
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
export const MaintenanceIntervalsSuggestions = createSuggestionComponent(
|
|
146
|
+
'MaintenanceIntervals/Suggestions'
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
export const PackagesSuggestions = createSuggestionComponent(
|
|
150
|
+
'Packages/Suggestions'
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
export const PartiesSuggestions = createSuggestionComponent(
|
|
154
|
+
'Parties/Suggestions'
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
export const PlanningTimesSuggestions = createSuggestionComponent(
|
|
158
|
+
'PlanningTimes/Suggestions'
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
export const ProcessesSuggestions = createSuggestionComponent(
|
|
162
|
+
'Processes/Suggestions'
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
export const ProductFeaturesSuggestions = createSuggestionComponent(
|
|
166
|
+
'ProductFeatures/Suggestions'
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
export const ProductFunctionsSuggestions = createSuggestionComponent(
|
|
170
|
+
'ProductFunctions/Suggestions'
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
export const ProductLifeCyclePhasesSuggestions = createSuggestionComponent(
|
|
174
|
+
'ProductLifeCyclePhases/Suggestions'
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
export const ProductMetadataSuggestions = createSuggestionComponent(
|
|
178
|
+
'ProductMetadata/Suggestions'
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
export const ProductPropertiesSuggestions = createSuggestionComponent(
|
|
182
|
+
'ProductProperties/Suggestions'
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
export const ProductVariantsSuggestions = createSuggestionComponent(
|
|
186
|
+
'ProductVariants/Suggestions'
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
export const PuttingToUsesSuggestions = createSuggestionComponent(
|
|
190
|
+
'PuttingToUses/Suggestions'
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
export const QualificationsSuggestions = createSuggestionComponent(
|
|
194
|
+
'Qualifications/Suggestions'
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
export const ReferencesSuggestions = createSuggestionComponent(
|
|
198
|
+
'References/Suggestions'
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
export const RenditionsSuggestions = createSuggestionComponent(
|
|
202
|
+
'Renditions/Suggestions'
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
export const RolesSuggestions = createSuggestionComponent(
|
|
206
|
+
'Roles/Suggestions'
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
export const SafetiesSuggestions = createSuggestionComponent(
|
|
210
|
+
'Safeties/Suggestions'
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
export const SkillLevelsSuggestions = createSuggestionComponent(
|
|
214
|
+
'SkillLevels/Suggestions'
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
export const SuppliesSuggestions = createSuggestionComponent(
|
|
218
|
+
'Supplies/Suggestions'
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
export const TasksSuggestions = createSuggestionComponent(
|
|
222
|
+
'Tasks/Suggestions'
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
export const TechnicalDataSuggestions = createSuggestionComponent(
|
|
226
|
+
'TechnicalData/Suggestions'
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
export const TechnicalOverviewsSuggestions = createSuggestionComponent(
|
|
230
|
+
'TechnicalOverviews/Suggestions'
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
export const TopicsSuggestions = createSuggestionComponent(
|
|
234
|
+
'Topics/Suggestions'
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
export const TopicTypesSuggestions = createSuggestionComponent(
|
|
238
|
+
'TopicTypes/Suggestions'
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
export const TroubleShootingsSuggestions = createSuggestionComponent(
|
|
242
|
+
'TroubleShootings/Suggestions'
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
export const UsesSuggestions = createSuggestionComponent(
|
|
246
|
+
'Uses/Suggestions'
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
export const WarningMessagesSuggestions = createSuggestionComponent(
|
|
250
|
+
'WarningMessages/Suggestions'
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
export const WorkingTimesSuggestions = createSuggestionComponent(
|
|
254
|
+
'WorkingTimes/Suggestions'
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
export const ConsumablesSuggestions = createSuggestionComponent(
|
|
258
|
+
'iirdsMch/v1/Consumables/Suggestions'
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
export const HardwareToolsSuggestions = createSuggestionComponent(
|
|
262
|
+
'iirdsMch/v1/HardwareTools/Suggestions'
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
export const LubricantsSuggestions = createSuggestionComponent(
|
|
266
|
+
'iirdsMch/v1/Lubricants/Suggestions'
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
export const OperatingSuppliesSuggestions = createSuggestionComponent(
|
|
270
|
+
'iirdsMch/v1/OperatingSupplies/Suggestions'
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
export const SetupTimesSuggestions = createSuggestionComponent(
|
|
274
|
+
'iirdsMch/v1/SetupTimes/Suggestions'
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
export const SparePartsSuggestions = createSuggestionComponent(
|
|
278
|
+
'iirdsMch/v1/SpareParts/Suggestions'
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
export const GroupsSuggestions = createSuggestionComponent(
|
|
282
|
+
'vcard/v1/Groups/Suggestions'
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
export const IndividualsSuggestions = createSuggestionComponent(
|
|
286
|
+
'vcard/v1/Individuals/Suggestions'
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
export const LocationsSuggestions = createSuggestionComponent(
|
|
290
|
+
'vcard/v1/Locations/Suggestions'
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
export const OrganizationsSuggestions = createSuggestionComponent(
|
|
294
|
+
'vcard/v1/Organizations/Suggestions'
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
export const VCardsSuggestions = createSuggestionComponent(
|
|
298
|
+
'vcard/v1/VCards/Suggestions'
|
|
299
|
+
);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import React, { FC } from "react";
|
|
4
|
+
import { Card, CardContent, CardHeader, CardTitle } from "@c-rex/ui/card";
|
|
5
|
+
import { useTranslations } from "next-intl";
|
|
6
|
+
import { filteredItems, renderValue } from "./shared";
|
|
7
|
+
import { useLanguageStore } from "../stores/language-store";
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
title: string;
|
|
11
|
+
items: {
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
link?: string;
|
|
15
|
+
}[]
|
|
16
|
+
}
|
|
17
|
+
export const InfoCard: FC<Props> = ({ title, items }) => {
|
|
18
|
+
const t = useTranslations();
|
|
19
|
+
const uiLang = useLanguageStore(state => state.uiLang);
|
|
20
|
+
const newItems = filteredItems(items)
|
|
21
|
+
const favoritesDocuments = useFavoritesStore((state) => state.documents);
|
|
22
|
+
const isFavoriteDocument = Object.keys(favoritesDocuments).some((docId) => docId === documentId);
|
|
23
|
+
let favoritesList: Favorite[] = []
|
|
24
|
+
|
|
25
|
+
if (Object.keys(favoritesDocuments).some(docId => docId === documentId)) {
|
|
26
|
+
favoritesList = favoritesDocuments[documentId]?.topics || []
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Card>
|
|
31
|
+
<CardHeader>
|
|
32
|
+
<CardTitle className="text-lg">{title}</CardTitle>
|
|
33
|
+
</CardHeader>
|
|
34
|
+
<CardContent className="space-y-3">
|
|
35
|
+
{newItems.map((item, index) => (
|
|
36
|
+
<div key={index} className="border-b border-blog-divider last:border-0 pb-3 last:pb-0">
|
|
37
|
+
{item.link ? (
|
|
38
|
+
<a href={item.link}>
|
|
39
|
+
<h4 className="text-sm font-medium mb-1">{t(item.label)}</h4>
|
|
40
|
+
</a>
|
|
41
|
+
) : (
|
|
42
|
+
<h4 className="text-sm font-medium mb-1">{t(item.label)}</h4>
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
<span className="text-xs text-muted-foreground">{renderValue(item, uiLang)}</span>
|
|
46
|
+
</div>
|
|
47
|
+
))}
|
|
48
|
+
</CardContent>
|
|
49
|
+
</Card>
|
|
50
|
+
);
|
|
51
|
+
}
|
package/src/info/info-table.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { FC } from "react";
|
|
2
|
-
import { articleInfoItemType, DocumentsType, Favorite } from "@c-rex/types";
|
|
3
2
|
import { Card, CardContent, CardHeader, CardTitle } from "@c-rex/ui/card";
|
|
4
3
|
import {
|
|
5
4
|
Table,
|
|
@@ -7,8 +6,8 @@ import {
|
|
|
7
6
|
TableCell,
|
|
8
7
|
TableRow,
|
|
9
8
|
} from "@c-rex/ui/table"
|
|
10
|
-
|
|
11
|
-
import {
|
|
9
|
+
|
|
10
|
+
import { renderValue } from "./shared";
|
|
12
11
|
import {
|
|
13
12
|
DropdownMenu,
|
|
14
13
|
DropdownMenuContent,
|
|
@@ -16,27 +15,100 @@ import {
|
|
|
16
15
|
DropdownMenuTrigger,
|
|
17
16
|
} from "@c-rex/ui/dropdown-menu";
|
|
18
17
|
import { CloudDownload, Eye } from "lucide-react";
|
|
19
|
-
import {
|
|
20
|
-
import { Flag } from "../flag";
|
|
18
|
+
import { InformationUnitModel } from "@c-rex/interfaces";
|
|
19
|
+
import { Flag } from "../icons/flag-icon";
|
|
21
20
|
import { Button } from "@c-rex/ui/button";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
21
|
+
import { FileIcon } from "../icons/file-icon";
|
|
22
|
+
import { BookmarkButton } from "../favorites/bookmark-button";
|
|
23
|
+
import { InformationUnitsGetAll } from "../generated/server-components";
|
|
24
|
+
import { getTranslations } from "next-intl/server";
|
|
25
|
+
import { EN_LANG } from "@c-rex/constants";
|
|
26
|
+
import { getFileRenditions } from "../results/utils";
|
|
26
27
|
|
|
27
28
|
type Props = {
|
|
28
29
|
title: string;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
linkPath: "topics" | "documents";
|
|
31
|
+
data: InformationUnitModel;
|
|
32
|
+
excludeKeys?: string[];
|
|
33
|
+
showBookmarkButton?: boolean;
|
|
33
34
|
}
|
|
35
|
+
type articleInfoItemType = {
|
|
36
|
+
label: string;
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const InfoTable: FC<Props> = async ({
|
|
41
|
+
title,
|
|
42
|
+
data,
|
|
43
|
+
excludeKeys = ['shortId', 'id', 'labels'],
|
|
44
|
+
linkPath = "topics",
|
|
45
|
+
showBookmarkButton = false,
|
|
46
|
+
}) => {
|
|
47
|
+
const t = await getTranslations();
|
|
48
|
+
const files = getFileRenditions({ renditions: data.renditions! });
|
|
49
|
+
|
|
50
|
+
// TODO: implementar um render generico para campos como parties e packages
|
|
51
|
+
const processData = (data: InformationUnitModel) => {
|
|
52
|
+
const result: articleInfoItemType[] = []
|
|
53
|
+
|
|
54
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
55
|
+
|
|
56
|
+
if (excludeKeys.includes(key) || value === null || value === undefined) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const processedValue = processValue(value);
|
|
61
|
+
|
|
62
|
+
if (processedValue !== null) {
|
|
63
|
+
result.push({
|
|
64
|
+
label: key,
|
|
65
|
+
value: processedValue
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
const processValue = (value: any): string | null => {
|
|
73
|
+
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
if (value.length === 0) return null;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if (value.length === 1) {
|
|
79
|
+
return processSingleValue(value[0]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const processedValues = value
|
|
84
|
+
.map(item => processSingleValue(item))
|
|
85
|
+
.filter(item => item !== null);
|
|
86
|
+
|
|
87
|
+
return processedValues.length > 0 ? processedValues.join(", ") : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return processSingleValue(value);
|
|
91
|
+
};
|
|
92
|
+
const processSingleValue = (item: any): string | null => {
|
|
93
|
+
|
|
94
|
+
if (item === null || item === undefined) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
34
97
|
|
|
98
|
+
if (typeof item === 'object') {
|
|
99
|
+
if ('shortId' in item || 'id' in item) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
35
102
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
103
|
+
if ('value' in item && item.value !== null && item.value !== undefined) {
|
|
104
|
+
return String(item.value);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return String(item);
|
|
111
|
+
};
|
|
40
112
|
|
|
41
113
|
return (
|
|
42
114
|
<Card className="p-0 !pt-4">
|
|
@@ -44,63 +116,58 @@ export const InfoTable: FC<Props> = ({ title, items, files, availableVersions, m
|
|
|
44
116
|
<CardTitle className="text-lg flex justify-between items-end">
|
|
45
117
|
{title}
|
|
46
118
|
|
|
47
|
-
{
|
|
48
|
-
<BookmarkButton
|
|
49
|
-
markersList={markersList.filter(item => item.label.length > 0)}
|
|
50
|
-
trigger={
|
|
51
|
-
<Button variant="outline" size="icon" className="relative">
|
|
52
|
-
<FaRegBookmark className="!w-5 color-primary" />
|
|
53
|
-
<span
|
|
54
|
-
className="absolute -top-[10px] -right-[10px] min-w-5 min-h-5 bg-primary text-white rounded-full"
|
|
55
|
-
>
|
|
56
|
-
{markersList.length}
|
|
57
|
-
</span>
|
|
58
|
-
</Button>
|
|
59
|
-
}
|
|
60
|
-
/>
|
|
61
|
-
)}
|
|
119
|
+
{showBookmarkButton && <BookmarkButton shortId={data.shortId!} />}
|
|
62
120
|
</CardTitle>
|
|
63
121
|
</CardHeader>
|
|
64
122
|
<CardContent className="space-y-3 !p-0">
|
|
65
123
|
<Table>
|
|
66
124
|
<TableBody>
|
|
67
|
-
{
|
|
125
|
+
{processData(data).map((item, index) => (
|
|
68
126
|
<TableRow key={index} className="min-h-12">
|
|
69
127
|
<TableCell className="font-medium w-28 pl-4">
|
|
70
|
-
{item.
|
|
71
|
-
<a href={item.link} className="underline">
|
|
72
|
-
<h4 className="text-sm font-medium">{t(item.label)}</h4>
|
|
73
|
-
</a>
|
|
74
|
-
) : (
|
|
75
|
-
<h4 className="text-sm font-medium">{t(item.label)}</h4>
|
|
76
|
-
)}
|
|
128
|
+
<h4 className="text-sm font-medium">{t(item.label)}</h4>
|
|
77
129
|
</TableCell>
|
|
78
130
|
<TableCell className="text-xs text-muted-foreground flex items-center gap-2 min-h-12">
|
|
79
|
-
{renderValue(item,
|
|
131
|
+
{renderValue(item, EN_LANG)}
|
|
80
132
|
</TableCell>
|
|
81
133
|
</TableRow>
|
|
82
134
|
))}
|
|
83
135
|
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
136
|
+
{/*check if has versionOF */}
|
|
137
|
+
<InformationUnitsGetAll
|
|
138
|
+
queryParams={{
|
|
139
|
+
Restrict: [`versionOf.shortId=${data.versionOf?.shortId}`],
|
|
140
|
+
Fields: ["renditions", "class", "languages", "labels"]
|
|
141
|
+
}}
|
|
142
|
+
render={(data, error) => {
|
|
143
|
+
if (error) {
|
|
144
|
+
return JSON.stringify(error);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<TableRow className="min-h-12">
|
|
149
|
+
<TableCell className="font-medium w-28 pl-4">
|
|
150
|
+
<h4 className="text-sm font-medium">{t("availableIn")}</h4>
|
|
151
|
+
</TableCell>
|
|
152
|
+
<TableCell className="text-xs text-muted-foreground flex items-center gap-2 min-h-12">
|
|
153
|
+
{data.items.map((item) => {
|
|
154
|
+
const language = item.languages?.[0] ?? "NO LANGUAGE";
|
|
155
|
+
const country = language.split("-")[1]!;
|
|
156
|
+
return (
|
|
157
|
+
<span className="w-8 block border" key={item.shortId}>
|
|
158
|
+
<a href={`/${linkPath}/${item.shortId}`} title={language}>
|
|
159
|
+
<Flag countryCode={country} />
|
|
160
|
+
</a>
|
|
161
|
+
</span>
|
|
162
|
+
)
|
|
163
|
+
})}
|
|
164
|
+
</TableCell>
|
|
165
|
+
</TableRow>
|
|
166
|
+
)
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
102
169
|
|
|
103
|
-
{files && (
|
|
170
|
+
{Object.keys(files).length > 0 && (
|
|
104
171
|
<TableRow className="min-h-12">
|
|
105
172
|
<TableCell className="font-medium w-28 pl-4">
|
|
106
173
|
<h4 className="text-sm font-medium">{t("files")}</h4>
|
package/src/info/shared.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { articleInfoItemType } from "@c-rex/types";
|
|
3
3
|
import { formatDateToLocale } from "@c-rex/utils";
|
|
4
|
-
import { Flag } from "../flag";
|
|
4
|
+
import { Flag } from "../icons/flag-icon";
|
|
5
5
|
|
|
6
6
|
const isDate = (value: string): boolean => {
|
|
7
7
|
return (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(value))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from "react";
|
|
2
2
|
import { LanguageAndCountries } from "@c-rex/interfaces";
|
|
3
3
|
import { DropdownMenuRadioGroup, DropdownMenuRadioItem } from "@c-rex/ui/dropdown-menu";
|
|
4
|
-
import { Flag } from "../../flag";
|
|
4
|
+
import { Flag } from "../../icons/flag-icon";
|
|
5
5
|
|
|
6
6
|
interface SharedLanguageSwitchProps {
|
|
7
7
|
availableLanguagesAndCountries: (LanguageAndCountries & { link?: string })[];
|
package/src/navbar/navbar.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { SignInBtn } from "./sign-in-out-btns";
|
|
|
4
4
|
import { getServerSession } from "next-auth";
|
|
5
5
|
import { SettingsMenu } from "./settings";
|
|
6
6
|
import { UserMenu } from "./user-menu";
|
|
7
|
-
import { SearchInput } from "
|
|
7
|
+
import { SearchInput } from "../search-input";
|
|
8
8
|
import { CrexSDK } from "@c-rex/core/sdk";
|
|
9
9
|
|
|
10
10
|
interface NavBarProps {
|
package/src/page-wrapper.tsx
CHANGED
|
@@ -7,7 +7,7 @@ type Props = {
|
|
|
7
7
|
title: string;
|
|
8
8
|
pageType: "BLOG" | "DOC" | "HOME"
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
//TODO rename variable to showInput and ShowPkgFilter
|
|
11
11
|
export const PageWrapper = ({ children, title, pageType }: Props) => {
|
|
12
12
|
const showInput = pageType === "DOC" || pageType === "BLOG"
|
|
13
13
|
const showPkgFilter = pageType === "DOC"
|