@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.
@@ -1,68 +1,71 @@
1
- import { Button, Card, Typography } from "antd";
2
- import { SquareArrowOutUpRight } from "lucide-react";
3
- import type { FC, HTMLAttributes } from "react";
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
- source: {
13
- type: string;
14
- name: string;
15
- id: string;
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
- category: string;
18
- categories: string[];
19
- cover: string;
20
- title: string;
21
- summary: string;
22
- type: string;
23
- lang: string;
24
- content: string;
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
- metadata: {
36
- version: string;
37
- department: string;
38
- last_reviewed: string;
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
- last_updated_by: {
60
- user: {
61
- avatar: string;
62
- username: string;
63
- userid: string;
64
- };
65
- timestamp: string;
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 extraInfo = [
88
- {
89
- label: i18n?.labels?.updatedAt ?? "Updated At",
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?.updatedBy ?? "Updated By",
106
- value: data?.last_updated_by?.user.username,
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 className={cn("flex flex-col h-full", className)} {...rest}>
112
- <div className="flex flex-col flex-1 mb-6 overflow-hidden">
113
- <div>
114
- <img src={data?.icon} className="size-6 mr-3 float-left" />
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
- <div className="text-4.5/6 text-primary">{data?.title}</div>
117
- </div>
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
- <Text type="secondary" className="block my-3 text-3">
120
- <span>{data?.source?.name}</span>
121
- <span> &gt; </span>
122
- <span>{data?.category}</span>
123
- <span> | </span>
124
- <span>{data?.owner?.username}</span>
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 mb-6">
130
- <Button
131
- color="primary"
132
- variant="filled"
133
- shape="round"
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
- </Button>
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
- <Card
151
- classNames={{
152
- root: "border-border",
153
- body: "flex flex-wrap gap-row-2 py-4!",
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
- {extraInfo.map((item) => {
157
- const { label, value } = item;
158
-
159
- return (
160
- <div
161
- key={label}
162
- className="w-1/2 inline-flex items-center <sm:w-full"
163
- >
164
- <Text type="secondary" className="w-24">
165
- {label}
166
- </Text>
167
-
168
- <span>{value ?? "-"}</span>
169
- </div>
170
- );
171
- })}
172
- </Card>
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
  };
@@ -1,4 +1,5 @@
1
1
  import "virtual:uno.css";
2
2
  import DocDetail from "./DocDetail";
3
+ import ActionButton from "./ActionButton";
3
4
 
4
- export { DocDetail };
5
+ export { DocDetail, ActionButton };