@infinilabs/doc-detail 0.0.0 → 0.0.2
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/dist/doc-detail.cjs +171 -12
- package/dist/doc-detail.js +83964 -16429
- package/dist/index.d.ts +47 -52
- package/package.json +9 -1
- package/src/App.tsx +15 -44
- package/src/components/ActionButton/index.tsx +51 -0
- package/src/components/DocDetail/components/AIInterpretation/index.tsx +6 -81
- package/src/components/DocDetail/components/Preview/components/Docx/index.tsx +37 -0
- package/src/components/DocDetail/components/Preview/components/Markdown/index.tsx +30 -0
- package/src/components/DocDetail/components/Preview/components/Pdf/index.tsx +20 -31
- package/src/components/DocDetail/components/Preview/components/Pptx/index.tsx +37 -0
- package/src/components/DocDetail/components/Preview/index.tsx +39 -5
- package/src/components/DocDetail/index.tsx +137 -114
- package/src/components/index.tsx +2 -1
- package/src/components/DocDetail/components/Preview/components/Pdf/test.pdf +0 -0
|
@@ -1,68 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Typography } from "antd";
|
|
2
|
+
import {
|
|
3
|
+
ChevronRight,
|
|
4
|
+
Dot,
|
|
5
|
+
Ellipsis,
|
|
6
|
+
Minus,
|
|
7
|
+
SquareArrowOutUpRight,
|
|
8
|
+
} from "lucide-react";
|
|
9
|
+
import { motion } from "motion/react";
|
|
10
|
+
|
|
11
|
+
import { useState, type FC, type HTMLAttributes, type ReactNode } from "react";
|
|
4
12
|
import Preview from "./components/Preview";
|
|
5
13
|
import AIInterpretation from "./components/AIInterpretation";
|
|
6
14
|
import { cn } from "@/utils/cn";
|
|
15
|
+
import ActionButton from "../ActionButton";
|
|
7
16
|
|
|
8
17
|
const { Text } = Typography;
|
|
9
18
|
|
|
19
|
+
export type MetadataContentType =
|
|
20
|
+
| "image"
|
|
21
|
+
| "video"
|
|
22
|
+
| "markdown"
|
|
23
|
+
| "pdf"
|
|
24
|
+
| "docx"
|
|
25
|
+
| "pptx"
|
|
26
|
+
| "xlsx";
|
|
27
|
+
|
|
10
28
|
export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
29
|
data: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
id?: string;
|
|
31
|
+
created?: ReactNode;
|
|
32
|
+
updated?: ReactNode;
|
|
33
|
+
_system?: {
|
|
34
|
+
owner_id?: string;
|
|
35
|
+
parent_path?: string;
|
|
36
|
+
tenant_id?: string;
|
|
16
37
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
icon: string;
|
|
26
|
-
thumbnail: string;
|
|
27
|
-
tags: string[];
|
|
28
|
-
url: string;
|
|
29
|
-
size: number;
|
|
30
|
-
owner: {
|
|
31
|
-
avatar: string;
|
|
32
|
-
username: string;
|
|
33
|
-
userid: string;
|
|
38
|
+
metadata?: {
|
|
39
|
+
ai_insights?: string;
|
|
40
|
+
colors?: string[];
|
|
41
|
+
content_type?: MetadataContentType;
|
|
42
|
+
height?: number;
|
|
43
|
+
mime_type?: string;
|
|
44
|
+
users?: null | unknown;
|
|
45
|
+
width?: number;
|
|
34
46
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
file_extension: string;
|
|
40
|
-
icon_link: string;
|
|
41
|
-
has_thumbnail: boolean;
|
|
42
|
-
kind: string;
|
|
43
|
-
parents: string[];
|
|
44
|
-
properties: Record<string, string>;
|
|
45
|
-
spaces: string[];
|
|
46
|
-
starred: boolean;
|
|
47
|
-
driveId: string;
|
|
48
|
-
thumbnail_link: string;
|
|
49
|
-
video_media_metadata?: {
|
|
50
|
-
durationMillis: string;
|
|
51
|
-
width: number;
|
|
52
|
-
height: number;
|
|
53
|
-
};
|
|
54
|
-
image_media_metadata?: {
|
|
55
|
-
width: number;
|
|
56
|
-
height: number;
|
|
57
|
-
};
|
|
47
|
+
source?: {
|
|
48
|
+
type?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
id?: string;
|
|
58
51
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
type?: string;
|
|
53
|
+
category?: string;
|
|
54
|
+
title?: string;
|
|
55
|
+
summary?: string;
|
|
56
|
+
icon?: string;
|
|
57
|
+
thumbnail?: string;
|
|
58
|
+
cover?: string;
|
|
59
|
+
tags?: string[];
|
|
60
|
+
url?: string;
|
|
61
|
+
size?: ReactNode;
|
|
62
|
+
owner: {
|
|
63
|
+
type?: string;
|
|
64
|
+
id?: string;
|
|
65
|
+
icon?: string;
|
|
66
|
+
title?: string;
|
|
67
|
+
subtitle?: string;
|
|
68
|
+
cover?: string;
|
|
66
69
|
};
|
|
67
70
|
};
|
|
68
71
|
i18n?: {
|
|
@@ -79,97 +82,117 @@ export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
79
82
|
size?: string;
|
|
80
83
|
};
|
|
81
84
|
};
|
|
85
|
+
extraButtons?: ReactNode[];
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
const DocDetail: FC<DocDetailProps> = (props) => {
|
|
85
|
-
const { data, i18n, className, ...rest } = props;
|
|
89
|
+
const { data, i18n, extraButtons, className, ...rest } = props;
|
|
86
90
|
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
value: data?.last_updated_by?.timestamp,
|
|
91
|
-
},
|
|
91
|
+
const [visibleMore, setVisibleMore] = useState(false);
|
|
92
|
+
|
|
93
|
+
const moreInfo = [
|
|
92
94
|
{
|
|
93
95
|
label: i18n?.labels?.type ?? "Type",
|
|
94
96
|
value: data?.type,
|
|
95
97
|
},
|
|
96
|
-
{
|
|
97
|
-
label: i18n?.labels?.createdBy ?? "Created By",
|
|
98
|
-
value: data?.owner?.username,
|
|
99
|
-
},
|
|
100
98
|
{
|
|
101
99
|
label: i18n?.labels?.size ?? "Size",
|
|
102
100
|
value: data?.size,
|
|
103
101
|
},
|
|
104
102
|
{
|
|
105
|
-
label: i18n?.labels?.
|
|
106
|
-
value: data?.
|
|
103
|
+
label: i18n?.labels?.createdBy ?? "Created At",
|
|
104
|
+
value: data?.created,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: i18n?.labels?.createdBy ?? "Created By",
|
|
108
|
+
value: data?.owner?.title,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: i18n?.labels?.updatedAt ?? "Updated At",
|
|
112
|
+
value: data?.updated,
|
|
107
113
|
},
|
|
108
114
|
];
|
|
109
115
|
|
|
110
116
|
return (
|
|
111
|
-
<div
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
<div
|
|
118
|
+
className={cn("flex flex-col h-full overflow-hidden", className)}
|
|
119
|
+
{...rest}
|
|
120
|
+
>
|
|
121
|
+
<div>
|
|
122
|
+
<img src={data?.icon} className="size-6 mr-3 float-left" />
|
|
115
123
|
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
<div className="text-4.5/6 text-primary">{data?.title}</div>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div className="flex items-center justify-between my-2">
|
|
128
|
+
<Text
|
|
129
|
+
type="secondary"
|
|
130
|
+
className="inline-flex items-center gap-0.5 text-3"
|
|
131
|
+
>
|
|
132
|
+
<div>{data?.source?.name ?? "-"}</div>
|
|
133
|
+
<ChevronRight className="size-3" />
|
|
134
|
+
<div>{data?.category ?? "-"}</div>
|
|
135
|
+
<Minus className="size-3 rotate-90" />
|
|
136
|
+
<div>{data?.owner?.title ?? "-"}</div>
|
|
137
|
+
<Dot className="size-3" />
|
|
138
|
+
<div>{data?.updated ?? "-"}</div>
|
|
118
139
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<span> · </span>
|
|
126
|
-
<span>{data?.last_updated_by?.timestamp}</span>
|
|
140
|
+
<Ellipsis
|
|
141
|
+
className="pl-2 min-w-3 size-3 hover:text-primary transition cursor-pointer"
|
|
142
|
+
onClick={() => {
|
|
143
|
+
setVisibleMore((prev) => !prev);
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
127
146
|
</Text>
|
|
128
147
|
|
|
129
|
-
<div className="flex gap-2
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
icon={<SquareArrowOutUpRight className="size-4" />}
|
|
148
|
+
<div className="inline-flex gap-2">
|
|
149
|
+
{extraButtons}
|
|
150
|
+
|
|
151
|
+
<ActionButton
|
|
152
|
+
icon={<SquareArrowOutUpRight />}
|
|
135
153
|
onClick={() => {
|
|
136
154
|
window.open(data.url);
|
|
137
155
|
}}
|
|
138
156
|
>
|
|
139
157
|
{i18n?.buttons?.openSource ?? "Open Source"}
|
|
140
|
-
</
|
|
141
|
-
</div>
|
|
142
|
-
|
|
143
|
-
<div className="flex flex-col gap-6 flex-1 overflow-auto">
|
|
144
|
-
<Preview {...props} />
|
|
145
|
-
|
|
146
|
-
<AIInterpretation {...props} />
|
|
158
|
+
</ActionButton>
|
|
147
159
|
</div>
|
|
148
160
|
</div>
|
|
149
161
|
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
<motion.div
|
|
163
|
+
className="bg-black/3 dark:bg-white/4 rounded-lg overflow-hidden"
|
|
164
|
+
initial={false}
|
|
165
|
+
animate={{
|
|
166
|
+
height: visibleMore ? "auto" : 0,
|
|
167
|
+
opacity: visibleMore ? 1 : 0,
|
|
168
|
+
marginBottom: visibleMore ? "1rem" : 0,
|
|
154
169
|
}}
|
|
155
170
|
>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
<div className="flex flex-wrap gap-row-2 p-4">
|
|
172
|
+
{moreInfo.map((item) => {
|
|
173
|
+
const { label, value } = item;
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<div
|
|
177
|
+
key={label}
|
|
178
|
+
className="w-1/2 inline-flex items-center <sm:w-full"
|
|
179
|
+
>
|
|
180
|
+
<Text type="secondary" className="w-24">
|
|
181
|
+
{label}
|
|
182
|
+
</Text>
|
|
183
|
+
|
|
184
|
+
<span className="text-3.5">{value ?? "-"}</span>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
})}
|
|
188
|
+
</div>
|
|
189
|
+
</motion.div>
|
|
190
|
+
|
|
191
|
+
<div className="flex flex-col gap-4 flex-1 overflow-auto">
|
|
192
|
+
<Preview {...props} />
|
|
193
|
+
|
|
194
|
+
<AIInterpretation {...props} />
|
|
195
|
+
</div>
|
|
173
196
|
</div>
|
|
174
197
|
);
|
|
175
198
|
};
|
package/src/components/index.tsx
CHANGED
|
Binary file
|