@c-rex/components 0.1.23 → 0.1.24
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c-rex/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"files": [
|
|
5
5
|
"src"
|
|
6
6
|
],
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"import": "./src/favorites/favorite-button.tsx"
|
|
43
43
|
},
|
|
44
44
|
"./flag": {
|
|
45
|
-
"types": "./src/flag.tsx",
|
|
46
|
-
"import": "./src/flag.tsx"
|
|
45
|
+
"types": "./src/icons/flag-icon.tsx",
|
|
46
|
+
"import": "./src/icons/flag-icon.tsx"
|
|
47
47
|
},
|
|
48
48
|
"./loading": {
|
|
49
49
|
"types": "./src/loading.tsx",
|
|
@@ -136,6 +136,10 @@
|
|
|
136
136
|
"./share-button": {
|
|
137
137
|
"types": "./src/share-button.tsx",
|
|
138
138
|
"import": "./src/share-button.tsx"
|
|
139
|
+
},
|
|
140
|
+
"./file-download": {
|
|
141
|
+
"types": "./src/renditions/file-download.tsx",
|
|
142
|
+
"import": "./src/renditions/file-download.tsx"
|
|
139
143
|
}
|
|
140
144
|
},
|
|
141
145
|
"scripts": {
|
package/src/info/shared.tsx
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { articleInfoItemType } from "@c-rex/types";
|
|
3
|
-
import { formatDateToLocale } from "@c-rex/utils";
|
|
3
|
+
import { formatDateToLocale, isDate, isLanguage } from "@c-rex/utils";
|
|
4
4
|
import { Flag } from "../icons/flag-icon";
|
|
5
5
|
|
|
6
|
-
const isDate = (value: string): boolean => {
|
|
7
|
-
return (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(value))
|
|
8
|
-
}
|
|
9
|
-
const isLanguage = (label: string): boolean => {
|
|
10
|
-
return label === "language" || label === "languages";
|
|
11
|
-
}
|
|
12
6
|
|
|
13
7
|
export const renderValue = (item: articleInfoItemType, uiLang: string): ReactNode => {
|
|
14
8
|
if (isDate(item.value)) return formatDateToLocale(item.value, uiLang);
|
|
@@ -11,11 +11,11 @@ import { FileIcon } from "../icons/file-icon";
|
|
|
11
11
|
import { CloudDownload, Eye } from "lucide-react";
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
interface
|
|
14
|
+
interface FileDownloadDropdown {
|
|
15
15
|
renditions: RenditionModel[] | null | undefined;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const FileDownloadDropdown: FC<FileDownloadDropdown> = async ({ renditions }) => {
|
|
19
19
|
|
|
20
20
|
if (renditions == null || renditions.length == 0) return null;
|
|
21
21
|
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
TopicModel
|
|
9
9
|
} from "@c-rex/interfaces";
|
|
10
10
|
import { FileStack } from "lucide-react";
|
|
11
|
-
import {
|
|
11
|
+
import { FileDownloadDropdown } from "../renditions/file-download";
|
|
12
12
|
import { cn, getType, getTitle, getLanguage } from "@c-rex/utils";
|
|
13
13
|
import { Button } from "@c-rex/ui/button";
|
|
14
14
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@c-rex/ui/tooltip";
|
|
@@ -103,7 +103,7 @@ export const TableWithImage: FC<TableWithImageProps> = ({ items, query = "", dis
|
|
|
103
103
|
{item.revision}
|
|
104
104
|
</span>
|
|
105
105
|
<div className="flex gap-2">
|
|
106
|
-
<
|
|
106
|
+
<FileDownloadDropdown renditions={item.renditions} />
|
|
107
107
|
|
|
108
108
|
{isDocument && (
|
|
109
109
|
<BookmarkButton
|
package/src/info/bookmark.tsx
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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-card.tsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Card>
|
|
24
|
-
<CardHeader>
|
|
25
|
-
<CardTitle className="text-lg">{title}</CardTitle>
|
|
26
|
-
</CardHeader>
|
|
27
|
-
<CardContent className="space-y-3">
|
|
28
|
-
{newItems.map((item, index) => (
|
|
29
|
-
<div key={index} className="border-b border-blog-divider last:border-0 pb-3 last:pb-0">
|
|
30
|
-
{item.link ? (
|
|
31
|
-
<a href={item.link}>
|
|
32
|
-
<h4 className="text-sm font-medium mb-1">{t(item.label)}</h4>
|
|
33
|
-
</a>
|
|
34
|
-
) : (
|
|
35
|
-
<h4 className="text-sm font-medium mb-1">{t(item.label)}</h4>
|
|
36
|
-
)}
|
|
37
|
-
|
|
38
|
-
<span className="text-xs text-muted-foreground">{renderValue(item, uiLang)}</span>
|
|
39
|
-
</div>
|
|
40
|
-
))}
|
|
41
|
-
</CardContent>
|
|
42
|
-
</Card>
|
|
43
|
-
);
|
|
44
|
-
}
|