@infinilabs/doc-detail 0.0.0 → 0.0.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/dist/doc-detail.cjs +171 -12
- package/dist/doc-detail.js +84225 -16690
- package/dist/index.d.ts +15 -1
- package/package.json +9 -1
- package/src/App.tsx +35 -1
- 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 +91 -49
- package/src/components/index.tsx +2 -1
- package/src/components/DocDetail/components/Preview/components/Pdf/test.pdf +0 -0
|
@@ -1,12 +1,30 @@
|
|
|
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
30
|
source: {
|
|
@@ -55,6 +73,10 @@ export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
55
73
|
width: number;
|
|
56
74
|
height: number;
|
|
57
75
|
};
|
|
76
|
+
content_type: MetadataContentType;
|
|
77
|
+
mime_type: string;
|
|
78
|
+
preview_url: string;
|
|
79
|
+
ai_insights: string;
|
|
58
80
|
};
|
|
59
81
|
last_updated_by: {
|
|
60
82
|
user: {
|
|
@@ -79,12 +101,15 @@ export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
79
101
|
size?: string;
|
|
80
102
|
};
|
|
81
103
|
};
|
|
104
|
+
extraButtons?: ReactNode[];
|
|
82
105
|
}
|
|
83
106
|
|
|
84
107
|
const DocDetail: FC<DocDetailProps> = (props) => {
|
|
85
|
-
const { data, i18n, className, ...rest } = props;
|
|
108
|
+
const { data, i18n, extraButtons, className, ...rest } = props;
|
|
109
|
+
|
|
110
|
+
const [visibleMore, setVisibleMore] = useState(false);
|
|
86
111
|
|
|
87
|
-
const
|
|
112
|
+
const moreInfo = [
|
|
88
113
|
{
|
|
89
114
|
label: i18n?.labels?.updatedAt ?? "Updated At",
|
|
90
115
|
value: data?.last_updated_by?.timestamp,
|
|
@@ -108,68 +133,85 @@ const DocDetail: FC<DocDetailProps> = (props) => {
|
|
|
108
133
|
];
|
|
109
134
|
|
|
110
135
|
return (
|
|
111
|
-
<div
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
136
|
+
<div
|
|
137
|
+
className={cn("flex flex-col h-full overflow-hidden", className)}
|
|
138
|
+
{...rest}
|
|
139
|
+
>
|
|
140
|
+
<div>
|
|
141
|
+
<img src={data?.icon} className="size-6 mr-3 float-left" />
|
|
115
142
|
|
|
116
|
-
|
|
117
|
-
|
|
143
|
+
<div className="text-4.5/6 text-primary">{data?.title}</div>
|
|
144
|
+
</div>
|
|
118
145
|
|
|
119
|
-
|
|
146
|
+
<div className="flex items-center justify-between my-2">
|
|
147
|
+
<Text
|
|
148
|
+
type="secondary"
|
|
149
|
+
className="inline-flex items-center gap-0.5 text-3"
|
|
150
|
+
>
|
|
120
151
|
<span>{data?.source?.name}</span>
|
|
121
|
-
<
|
|
152
|
+
<ChevronRight className="size-3" />
|
|
122
153
|
<span>{data?.category}</span>
|
|
123
|
-
<
|
|
154
|
+
<Minus className="size-3 rotate-90" />
|
|
124
155
|
<span>{data?.owner?.username}</span>
|
|
125
|
-
<
|
|
156
|
+
<Dot className="size-3" />
|
|
126
157
|
<span>{data?.last_updated_by?.timestamp}</span>
|
|
158
|
+
|
|
159
|
+
<Ellipsis
|
|
160
|
+
className="pl-2 size-3 hover:text-primary transition cursor-pointer"
|
|
161
|
+
onClick={() => {
|
|
162
|
+
setVisibleMore((prev) => !prev);
|
|
163
|
+
}}
|
|
164
|
+
/>
|
|
127
165
|
</Text>
|
|
128
166
|
|
|
129
|
-
<div className="flex gap-2
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
icon={<SquareArrowOutUpRight className="size-4" />}
|
|
167
|
+
<div className="inline-flex gap-2">
|
|
168
|
+
{extraButtons}
|
|
169
|
+
|
|
170
|
+
<ActionButton
|
|
171
|
+
icon={<SquareArrowOutUpRight />}
|
|
135
172
|
onClick={() => {
|
|
136
173
|
window.open(data.url);
|
|
137
174
|
}}
|
|
138
175
|
>
|
|
139
176
|
{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} />
|
|
177
|
+
</ActionButton>
|
|
147
178
|
</div>
|
|
148
179
|
</div>
|
|
149
180
|
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
<motion.div
|
|
182
|
+
className="bg-black/3 dark:bg-white/4 rounded-lg overflow-hidden"
|
|
183
|
+
initial={false}
|
|
184
|
+
animate={{
|
|
185
|
+
height: visibleMore ? "auto" : 0,
|
|
186
|
+
opacity: visibleMore ? 1 : 0,
|
|
187
|
+
marginBottom: visibleMore ? "1rem" : 0,
|
|
154
188
|
}}
|
|
155
189
|
>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
190
|
+
<div className="flex flex-wrap gap-row-2 p-4">
|
|
191
|
+
{moreInfo.map((item) => {
|
|
192
|
+
const { label, value } = item;
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<div
|
|
196
|
+
key={label}
|
|
197
|
+
className="w-1/2 inline-flex items-center <sm:w-full"
|
|
198
|
+
>
|
|
199
|
+
<Text type="secondary" className="w-24">
|
|
200
|
+
{label}
|
|
201
|
+
</Text>
|
|
202
|
+
|
|
203
|
+
<span className="text-3.5">{value ?? "-"}</span>
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
})}
|
|
207
|
+
</div>
|
|
208
|
+
</motion.div>
|
|
209
|
+
|
|
210
|
+
<div className="flex flex-col gap-4 flex-1 overflow-auto">
|
|
211
|
+
<Preview {...props} />
|
|
212
|
+
|
|
213
|
+
<AIInterpretation {...props} />
|
|
214
|
+
</div>
|
|
173
215
|
</div>
|
|
174
216
|
);
|
|
175
217
|
};
|
package/src/components/index.tsx
CHANGED
|
Binary file
|