@fibery/ui-kit 1.38.0 → 1.38.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/CHANGELOG.md +11 -0
- package/config/jest/testFrameworkSetup.js +1 -1
- package/package.json +16 -15
- package/src/abbreviate-name.ts +42 -0
- package/src/actions-menu/actions-menu-item.tsx +14 -5
- package/src/actions-menu/actions-menu-props.tsx +1 -0
- package/src/actions-menu/actions-menu.tsx +4 -1
- package/src/actions-menu/context-actions-menu.tsx +22 -0
- package/src/animated-height-container.tsx +24 -5
- package/src/antd/ant-upload.tsx +1 -1
- package/src/antd/input.tsx +4 -0
- package/src/avatar.tsx +1 -27
- package/src/button/base-button.tsx +2 -0
- package/src/button/button.tsx +3 -2
- package/src/button/icon-button.tsx +3 -3
- package/src/card-container.tsx +3 -2
- package/src/checkbox.tsx +17 -0
- package/src/collapsible-section.tsx +3 -1
- package/src/date-picker/autocomplete.tsx +11 -5
- package/src/date-picker/date-range-input.tsx +5 -1
- package/src/date-picker/date-range-picker-popup-content.tsx +31 -13
- package/src/date-picker/single-date-input.tsx +5 -1
- package/src/date-picker/styles.ts +20 -0
- package/src/design-system.ts +24 -0
- package/src/dropdown-menu/index.tsx +11 -1
- package/src/emoji-picker/emoji-picker-preview-footer.tsx +4 -0
- package/src/emoji-picker/emoji.tsx +4 -3
- package/src/emoji-picker/primitives/emoji.tsx +49 -51
- package/src/emoji-picker/primitives/footer.tsx +6 -0
- package/src/emoji-picker/primitives/search.tsx +8 -0
- package/src/emoji-picker/primitives/skin-tone.tsx +12 -2
- package/src/fibermoji-placeholder.tsx +1 -27
- package/src/file-item-2.tsx +408 -0
- package/src/file-item.tsx +63 -12
- package/src/header-layout.tsx +11 -0
- package/src/html-styles.ts +13 -4
- package/src/icons/ast/Back.ts +1 -1
- package/src/icons/ast/ExtensionFiles.ts +1 -1
- package/src/icons/ast/FileUpload.ts +1 -1
- package/src/icons/ast/SwitchToMention.ts +8 -0
- package/src/icons/ast/SwitchToText.ts +8 -0
- package/src/icons/ast/SwitchToWidget.ts +8 -0
- package/src/icons/ast/ViewGallery.ts +8 -0
- package/src/icons/ast/index.tsx +4 -0
- package/src/icons/react/SwitchToMention.tsx +13 -0
- package/src/icons/react/SwitchToText.tsx +13 -0
- package/src/icons/react/SwitchToWidget.tsx +13 -0
- package/src/icons/react/ViewGallery.tsx +13 -0
- package/src/icons/react/index.tsx +4 -0
- package/src/icons/svg/back.svg +3 -1
- package/src/icons/svg/extension/files.svg +3 -1
- package/src/icons/svg/file-upload.svg +3 -6
- package/src/icons/svg/switch-to-mention.svg +3 -0
- package/src/icons/svg/switch-to-text.svg +4 -0
- package/src/icons/svg/switch-to-widget.svg +4 -0
- package/src/icons/svg/view-gallery.svg +4 -0
- package/src/images-gallery/images-gallery-fall-through-provider.tsx +11 -0
- package/src/images-gallery/images-gallery.tsx +13 -10
- package/src/images-gallery/zoom.tsx +13 -2
- package/src/images-gallery-2/images-gallery-2.tsx +442 -0
- package/src/images-gallery-2/slide-buttons.tsx +230 -0
- package/src/images-gallery-2/zoom.tsx +35 -0
- package/src/kbd.tsx +46 -0
- package/src/modal-menu/modal-menu-item.tsx +10 -2
- package/src/modal-menu/modal-menu-trigger.tsx +19 -2
- package/src/notification-dot.tsx +16 -7
- package/src/platform-symbols.ts +9 -0
- package/src/platform.ts +2 -0
- package/src/popover/index.tsx +31 -8
- package/src/popover/modifiers.tsx +26 -19
- package/src/reactions/reaction-button.tsx +323 -101
- package/src/reactions/reaction-picker.tsx +14 -1
- package/src/reactions/reactions.tsx +11 -1
- package/src/reactions/tootltip.tsx +55 -0
- package/src/rich-text-embed-error.tsx +2 -1
- package/src/select/components/group-heading.tsx +8 -0
- package/src/select/components/menu-list-virtualized.tsx +6 -2
- package/src/select/components/option.tsx +4 -0
- package/src/select/select-control-settings-context.tsx +11 -2
- package/src/select/select-in-popover.tsx +10 -7
- package/src/select/styles.ts +21 -1
- package/src/tab-nav/tab-nav.tsx +1 -1
- package/src/toggle.tsx +8 -0
- package/src/tooltip.tsx +27 -18
- package/src/type-badge.tsx +5 -2
- package/src/unit/unit-with-tooltip.tsx +1 -1
- package/src/use-is-phone.tsx +27 -6
- package/src/shortcut-badge.tsx +0 -29
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import {css, cx} from "@linaria/core";
|
|
2
|
+
import {useCallback, useEffect, useState} from "react";
|
|
3
|
+
import {ActionsMenu, ActionsMenuItem, ActionsMenuSeparator} from "./actions-menu";
|
|
4
|
+
import {ActionsButtonCompact} from "./button/actions-button-compact";
|
|
5
|
+
import {border, colors, space, themeVars} from "./design-system";
|
|
6
|
+
import {makeButtonColors} from "./button/make-button-colors";
|
|
7
|
+
import Delete from "./icons/react/Delete";
|
|
8
|
+
import FileDownload from "./icons/react/FileDownload";
|
|
9
|
+
import Link from "./icons/react/Link";
|
|
10
|
+
import RicheditorOpenLink from "./icons/react/RicheditorOpenLink";
|
|
11
|
+
import Spinner from "./icons/react/Spinner";
|
|
12
|
+
import AppWiki from "./icons/react/AppWiki";
|
|
13
|
+
import {copyToClipboard} from "./copy-to-clipboard";
|
|
14
|
+
import {useToast} from "./toast/toast-provider";
|
|
15
|
+
import {Icon} from "./icons/Icon";
|
|
16
|
+
import {useImagesGalleryMethods, useImagesGalleryRegistry} from "./images-gallery/images-gallery";
|
|
17
|
+
|
|
18
|
+
const fileItemStyle = css`
|
|
19
|
+
display: block;
|
|
20
|
+
height: 100%;
|
|
21
|
+
background-color: ${themeVars.transparent};
|
|
22
|
+
background-size: cover;
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
border-radius: ${space.s8}px;
|
|
25
|
+
border: 1px solid ${themeVars.separatorColor};
|
|
26
|
+
background-clip: padding-box;
|
|
27
|
+
&:focus {
|
|
28
|
+
text-decoration: none;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
const overlayStyle = css`
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
padding: ${space.s8}px;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
color: ${themeVars.textColor};
|
|
38
|
+
border-radius: ${border.radius8}px;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
opacity: 0;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
const imageOverlayStyle = css`
|
|
44
|
+
background-size: 100% 200%;
|
|
45
|
+
background-position: 0 100%;
|
|
46
|
+
color: ${themeVars.transparent};
|
|
47
|
+
border-radius: ${border.radius6}px;
|
|
48
|
+
&:hover {
|
|
49
|
+
background-position: 0 0;
|
|
50
|
+
color: ${themeVars.inversedTextColor},
|
|
51
|
+
},
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
const fileOverlayStyle = css`
|
|
55
|
+
opacity: 1;
|
|
56
|
+
background: transparent;
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
export type FileItemType = {
|
|
60
|
+
name: string;
|
|
61
|
+
url: string;
|
|
62
|
+
downloadUrl?: string | null;
|
|
63
|
+
thumbnailUrl: string | null;
|
|
64
|
+
previewData: null | {
|
|
65
|
+
type: "image" | "video" | "iframe";
|
|
66
|
+
previewSrc: string | null;
|
|
67
|
+
originalSrc: string;
|
|
68
|
+
};
|
|
69
|
+
status?: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type FileItemProps = {
|
|
73
|
+
data: FileItemType;
|
|
74
|
+
onRemoveClick?: (x: FileItemType) => void;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export function FileItem(props: FileItemProps) {
|
|
79
|
+
const {name, url, thumbnailUrl, status, previewData: preview} = props.data;
|
|
80
|
+
const isPending = status === "uploading" || status === "deleting";
|
|
81
|
+
const isBackgroundReady = Boolean(thumbnailUrl && !isPending);
|
|
82
|
+
const [isActionsOpened, setIsActionsOpened] = useState(false);
|
|
83
|
+
|
|
84
|
+
const showFileIcon = !isPending && !isBackgroundReady;
|
|
85
|
+
|
|
86
|
+
const [zoomed, setZoomed] = useState(false);
|
|
87
|
+
const imagesRegistry = useImagesGalleryRegistry();
|
|
88
|
+
const galleryMethods = useImagesGalleryMethods();
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!preview) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
imagesRegistry.set(preview.originalSrc, {
|
|
96
|
+
type: preview.type,
|
|
97
|
+
src: preview.originalSrc,
|
|
98
|
+
zoomed: false,
|
|
99
|
+
setZoomed,
|
|
100
|
+
});
|
|
101
|
+
}, [imagesRegistry, preview]);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!preview) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (zoomed) {
|
|
109
|
+
galleryMethods.setActivated(true);
|
|
110
|
+
}
|
|
111
|
+
const imageData = imagesRegistry.get(preview.originalSrc);
|
|
112
|
+
if (imageData) {
|
|
113
|
+
imageData.zoomed = zoomed;
|
|
114
|
+
} else {
|
|
115
|
+
imagesRegistry.set(preview.originalSrc, {
|
|
116
|
+
type: preview.type,
|
|
117
|
+
src: preview.originalSrc,
|
|
118
|
+
zoomed,
|
|
119
|
+
setZoomed,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, [galleryMethods, zoomed, preview, imagesRegistry]);
|
|
123
|
+
|
|
124
|
+
const onContainerClick = useCallback(() => {
|
|
125
|
+
if (preview) {
|
|
126
|
+
setZoomed(true);
|
|
127
|
+
} else {
|
|
128
|
+
stratFileDownload(url, name);
|
|
129
|
+
}
|
|
130
|
+
}, [name, preview, url]);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<div
|
|
134
|
+
className={cx(
|
|
135
|
+
css`
|
|
136
|
+
flex: 1 0 0;
|
|
137
|
+
height: 100%;
|
|
138
|
+
`,
|
|
139
|
+
isBackgroundReady &&
|
|
140
|
+
css`
|
|
141
|
+
&:hover .${overlayStyle} {
|
|
142
|
+
opacity: 1;
|
|
143
|
+
background-position: 0 0;
|
|
144
|
+
color: ${themeVars.inversedTextColor};
|
|
145
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
146
|
+
}
|
|
147
|
+
`,
|
|
148
|
+
isBackgroundReady &&
|
|
149
|
+
isActionsOpened &&
|
|
150
|
+
css`
|
|
151
|
+
.${overlayStyle} {
|
|
152
|
+
opacity: 1;
|
|
153
|
+
background-position: 0 0;
|
|
154
|
+
color: ${themeVars.inversedTextColor};
|
|
155
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
156
|
+
}
|
|
157
|
+
`
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
<div
|
|
161
|
+
style={isBackgroundReady ? {backgroundImage: `url(${thumbnailUrl})`} : {}}
|
|
162
|
+
onClick={onContainerClick}
|
|
163
|
+
className={cx(
|
|
164
|
+
css`
|
|
165
|
+
flex-shrink: 0;
|
|
166
|
+
`,
|
|
167
|
+
fileItemStyle,
|
|
168
|
+
isPending &&
|
|
169
|
+
css`
|
|
170
|
+
${{backgroundColor: themeVars.entityCardSelectedColor}}
|
|
171
|
+
`
|
|
172
|
+
)}
|
|
173
|
+
>
|
|
174
|
+
{isPending && (
|
|
175
|
+
<div
|
|
176
|
+
className={css`
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
justify-content: center; /* centers vertically */
|
|
180
|
+
align-items: center; /* centers horizontally */
|
|
181
|
+
height: 100%;
|
|
182
|
+
width: 100%;
|
|
183
|
+
`}
|
|
184
|
+
>
|
|
185
|
+
<Spinner />
|
|
186
|
+
</div>
|
|
187
|
+
)}
|
|
188
|
+
{showFileIcon && (
|
|
189
|
+
<div className={cx(overlayStyle, fileOverlayStyle)}>
|
|
190
|
+
<div
|
|
191
|
+
className={css`
|
|
192
|
+
display: flex;
|
|
193
|
+
flex-direction: column;
|
|
194
|
+
justify-content: center; /* centers vertically */
|
|
195
|
+
align-items: center; /* centers horizontally */
|
|
196
|
+
height: 100%;
|
|
197
|
+
width: 100%;
|
|
198
|
+
padding-top: ${space.s1}px;
|
|
199
|
+
gap: ${space.s2}px;
|
|
200
|
+
`}
|
|
201
|
+
>
|
|
202
|
+
<Icon containerSize={40} iconSize={40}>
|
|
203
|
+
<AppWiki />
|
|
204
|
+
</Icon>
|
|
205
|
+
<div
|
|
206
|
+
className={css`
|
|
207
|
+
align-content: center;
|
|
208
|
+
|
|
209
|
+
display: flex;
|
|
210
|
+
align-items: center;
|
|
211
|
+
gap: 10px;
|
|
212
|
+
flex-shrink: 0;
|
|
213
|
+
color: ${themeVars.colorTextMenuItem};
|
|
214
|
+
text-overflow: ellipsis;
|
|
215
|
+
overflow: hidden;
|
|
216
|
+
`}
|
|
217
|
+
>
|
|
218
|
+
<FileTitle
|
|
219
|
+
title={name}
|
|
220
|
+
className={css`
|
|
221
|
+
-webkit-line-clamp: 1;
|
|
222
|
+
-webkit-box-orient: vertical;
|
|
223
|
+
overflow: hidden;
|
|
224
|
+
text-overflow: ellipsis;
|
|
225
|
+
`}
|
|
226
|
+
/>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
<div
|
|
230
|
+
className={css`
|
|
231
|
+
position: absolute;
|
|
232
|
+
top: ${space.s8}px;
|
|
233
|
+
right: ${space.s8}px;
|
|
234
|
+
`}
|
|
235
|
+
>
|
|
236
|
+
<FileActionsMenu
|
|
237
|
+
setIsActionsOpened={setIsActionsOpened}
|
|
238
|
+
data={props.data}
|
|
239
|
+
disabled={props.disabled}
|
|
240
|
+
isBackgroundReady={isBackgroundReady}
|
|
241
|
+
onRemoveClick={props.onRemoveClick}
|
|
242
|
+
/>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
)}
|
|
246
|
+
{!isPending && !showFileIcon && (
|
|
247
|
+
<div className={cx(overlayStyle, isBackgroundReady ? imageOverlayStyle : fileOverlayStyle)}>
|
|
248
|
+
<div
|
|
249
|
+
className={css`
|
|
250
|
+
position: relative;
|
|
251
|
+
display: flex;
|
|
252
|
+
flex-direction: column;
|
|
253
|
+
justify-content: space-between; /* Top + bottom placement */
|
|
254
|
+
width: 100%;
|
|
255
|
+
height: 100%;
|
|
256
|
+
overflow: hidden;
|
|
257
|
+
box-sizing: border-box;
|
|
258
|
+
gap: ${space.s8}px;
|
|
259
|
+
`}
|
|
260
|
+
>
|
|
261
|
+
<div
|
|
262
|
+
className={css`
|
|
263
|
+
align-self: flex-end;
|
|
264
|
+
`}
|
|
265
|
+
>
|
|
266
|
+
<FileActionsMenu
|
|
267
|
+
setIsActionsOpened={setIsActionsOpened}
|
|
268
|
+
data={props.data}
|
|
269
|
+
disabled={props.disabled}
|
|
270
|
+
isBackgroundReady={isBackgroundReady}
|
|
271
|
+
onRemoveClick={props.onRemoveClick}
|
|
272
|
+
/>
|
|
273
|
+
</div>
|
|
274
|
+
<div
|
|
275
|
+
className={css`
|
|
276
|
+
display: flex;
|
|
277
|
+
align-self: flex-start;
|
|
278
|
+
align-items: flex-end;
|
|
279
|
+
text-overflow: ellipsis;
|
|
280
|
+
//overflow: hidden;
|
|
281
|
+
box-sizing: border-box;
|
|
282
|
+
|
|
283
|
+
color: ${themeVars.colorBgSidebar};
|
|
284
|
+
`}
|
|
285
|
+
>
|
|
286
|
+
<FileTitle title={name} />
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
)}
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function FileActionsMenu({
|
|
297
|
+
data,
|
|
298
|
+
disabled,
|
|
299
|
+
setIsActionsOpened,
|
|
300
|
+
onRemoveClick,
|
|
301
|
+
isBackgroundReady,
|
|
302
|
+
}: {
|
|
303
|
+
data: FileItemType;
|
|
304
|
+
onRemoveClick?: (data: FileItemType) => void;
|
|
305
|
+
disabled?: boolean;
|
|
306
|
+
setIsActionsOpened: (val: boolean) => void;
|
|
307
|
+
isBackgroundReady: boolean;
|
|
308
|
+
}) {
|
|
309
|
+
const toast = useToast();
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<ActionsMenu
|
|
313
|
+
onOpenChange={setIsActionsOpened}
|
|
314
|
+
trigger={
|
|
315
|
+
<ActionsButtonCompact
|
|
316
|
+
className={css`
|
|
317
|
+
z-index: 1;
|
|
318
|
+
`}
|
|
319
|
+
style={isBackgroundReady ? makeButtonColors(colors.inversedTextColor, "ghost") : undefined}
|
|
320
|
+
/>
|
|
321
|
+
}
|
|
322
|
+
>
|
|
323
|
+
<ActionsMenuItem
|
|
324
|
+
Icon={Link}
|
|
325
|
+
onSelect={() => {
|
|
326
|
+
copyToClipboard(`${window.origin}${data.url}`)
|
|
327
|
+
.then(() => toast.success({title: "Link copied to clipboard"}))
|
|
328
|
+
.catch((error) => toast.error({title: "Unable to copy link to clipboard", subTitle: error.message}));
|
|
329
|
+
}}
|
|
330
|
+
>
|
|
331
|
+
Copy file URL
|
|
332
|
+
</ActionsMenuItem>
|
|
333
|
+
<a href={data.url} target="_blank" rel="noopener noreferrer">
|
|
334
|
+
<ActionsMenuItem Icon={RicheditorOpenLink}>Open in new tab</ActionsMenuItem>
|
|
335
|
+
</a>
|
|
336
|
+
<a download={data.name} href={`${data.url}?attachment`}>
|
|
337
|
+
<ActionsMenuItem Icon={FileDownload}>Download</ActionsMenuItem>
|
|
338
|
+
</a>
|
|
339
|
+
<ActionsMenuSeparator />
|
|
340
|
+
<ActionsMenuItem Icon={Delete} onSelect={() => onRemoveClick?.(data)} dangerous disabled={disabled}>
|
|
341
|
+
Delete
|
|
342
|
+
</ActionsMenuItem>
|
|
343
|
+
</ActionsMenu>
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function FileTitle({title, className}: {title: string; className?: string}) {
|
|
348
|
+
return (
|
|
349
|
+
<div
|
|
350
|
+
className={cx(
|
|
351
|
+
css`
|
|
352
|
+
border-radius: ${border.radius4}px;
|
|
353
|
+
background: ${themeVars.badgeBgColor};
|
|
354
|
+
padding: ${space.s2}px ${space.s5}px;
|
|
355
|
+
height: 100%;
|
|
356
|
+
vertical-align: top;
|
|
357
|
+
|
|
358
|
+
text-align: center;
|
|
359
|
+
justify-content: center;
|
|
360
|
+
|
|
361
|
+
word-break: break-word;
|
|
362
|
+
overflow: hidden;
|
|
363
|
+
/* UI/Heading/H8 (reg-400, up) */
|
|
364
|
+
font-family: Inter;
|
|
365
|
+
font-size: 10px;
|
|
366
|
+
font-style: normal;
|
|
367
|
+
font-weight: 500;
|
|
368
|
+
line-height: 125%; /* 12.5px */
|
|
369
|
+
text-transform: none;
|
|
370
|
+
text-overflow: ellipsis;
|
|
371
|
+
-webkit-line-clamp: 1;
|
|
372
|
+
-webkit-box-orient: vertical;
|
|
373
|
+
|
|
374
|
+
&:hover {
|
|
375
|
+
text-decoration: none;
|
|
376
|
+
color: inherit;
|
|
377
|
+
}
|
|
378
|
+
`,
|
|
379
|
+
className
|
|
380
|
+
)}
|
|
381
|
+
>
|
|
382
|
+
{title}
|
|
383
|
+
</div>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function stratFileDownload(url: string, filename: string) {
|
|
388
|
+
const a = document.createElement("a");
|
|
389
|
+
a.href = `${url}?attachment`;
|
|
390
|
+
a.download = filename;
|
|
391
|
+
a.style.display = "none";
|
|
392
|
+
|
|
393
|
+
document.body.appendChild(a);
|
|
394
|
+
a.click();
|
|
395
|
+
document.body.removeChild(a);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// const long = `long text long text long text long text long text long text long text long text long text long text long
|
|
399
|
+
// long text long text long text long text long text long text long text long text long text long text long text long
|
|
400
|
+
// text long text long text long text long text long text long text long text long text long text long text long text
|
|
401
|
+
// long text long text long text long text long text long text long text long text long text long text long text long
|
|
402
|
+
// text long text long text long text long text long text long text long text long text long text long text long text
|
|
403
|
+
// long text long text long text long text long text long text long text long text long text long text long text long
|
|
404
|
+
// text long text long text long text long text long text long text long text long text long text long text long text
|
|
405
|
+
// long text long text long text long text long text long text long text long text long text long text long text long
|
|
406
|
+
// text long text long text long text long text long text long text long text long text long text long text long text
|
|
407
|
+
// long text long text long text long text long text long text long text
|
|
408
|
+
// `;
|
package/src/file-item.tsx
CHANGED
|
@@ -10,6 +10,8 @@ import ZoomIn from "./icons/react/RicheditorImageZoom";
|
|
|
10
10
|
import {Tooltip} from "./tooltip";
|
|
11
11
|
import {Zoom} from "./images-gallery/zoom";
|
|
12
12
|
import {useImagesGalleryMethods, useImagesGalleryRegistry} from "./images-gallery/images-gallery";
|
|
13
|
+
import FileDownload from "./icons/react/FileDownload";
|
|
14
|
+
import RicheditorOpenLink from "./icons/react/RicheditorOpenLink";
|
|
13
15
|
|
|
14
16
|
const fileItemStyle = css`
|
|
15
17
|
${{
|
|
@@ -67,10 +69,16 @@ const fileOverlayStyle = css`
|
|
|
67
69
|
`;
|
|
68
70
|
|
|
69
71
|
export type FileItemType = {
|
|
72
|
+
uid: string;
|
|
70
73
|
name: string;
|
|
71
74
|
url: string;
|
|
72
75
|
thumbnailUrl: string | null;
|
|
73
|
-
|
|
76
|
+
previewData: null | {
|
|
77
|
+
type: "image" | "video" | "iframe";
|
|
78
|
+
previewSrc: string | null;
|
|
79
|
+
originalSrc: string;
|
|
80
|
+
};
|
|
81
|
+
downloadUrl?: string | null;
|
|
74
82
|
status?: string;
|
|
75
83
|
};
|
|
76
84
|
|
|
@@ -78,26 +86,46 @@ export type FileItemProps = {
|
|
|
78
86
|
data: FileItemType;
|
|
79
87
|
onRemoveClick?: (x: FileItemType) => void;
|
|
80
88
|
disabled?: boolean;
|
|
89
|
+
onRenameClick?: (p: {id: string; name: string}) => void;
|
|
81
90
|
};
|
|
82
91
|
|
|
83
|
-
function
|
|
92
|
+
function PreviewEntry({
|
|
93
|
+
preview,
|
|
94
|
+
actions,
|
|
95
|
+
}: {
|
|
96
|
+
preview: {type: "image" | "video" | "iframe"; originalSrc: string; previewSrc: string | null};
|
|
97
|
+
actions: React.ReactNode;
|
|
98
|
+
}) {
|
|
84
99
|
const [zoomed, setZoomed] = useState(false);
|
|
85
100
|
const imagesRegistry = useImagesGalleryRegistry();
|
|
86
101
|
const galleryMethods = useImagesGalleryMethods();
|
|
102
|
+
|
|
87
103
|
useEffect(() => {
|
|
88
|
-
imagesRegistry.set(
|
|
89
|
-
|
|
104
|
+
imagesRegistry.set(preview.originalSrc, {
|
|
105
|
+
type: preview.type,
|
|
106
|
+
src: preview.originalSrc,
|
|
107
|
+
zoomed: false,
|
|
108
|
+
setZoomed,
|
|
109
|
+
actions,
|
|
110
|
+
});
|
|
111
|
+
}, [imagesRegistry, preview, actions]);
|
|
90
112
|
useEffect(() => {
|
|
91
113
|
if (zoomed) {
|
|
92
114
|
galleryMethods.setActivated(true);
|
|
93
115
|
}
|
|
94
|
-
const imageData = imagesRegistry.get(
|
|
116
|
+
const imageData = imagesRegistry.get(preview.originalSrc);
|
|
95
117
|
if (imageData) {
|
|
96
118
|
imageData.zoomed = zoomed;
|
|
97
119
|
} else {
|
|
98
|
-
imagesRegistry.set(
|
|
120
|
+
imagesRegistry.set(preview.originalSrc, {
|
|
121
|
+
type: preview.type,
|
|
122
|
+
src: preview.originalSrc,
|
|
123
|
+
zoomed,
|
|
124
|
+
setZoomed,
|
|
125
|
+
actions,
|
|
126
|
+
});
|
|
99
127
|
}
|
|
100
|
-
}, [galleryMethods, zoomed,
|
|
128
|
+
}, [galleryMethods, zoomed, preview, imagesRegistry, actions]);
|
|
101
129
|
return (
|
|
102
130
|
<div
|
|
103
131
|
className={css`
|
|
@@ -105,7 +133,7 @@ function ImageZoom({thumbnailUrl, url}: {thumbnailUrl: string; url: string}) {
|
|
|
105
133
|
`}
|
|
106
134
|
>
|
|
107
135
|
<Zoom
|
|
108
|
-
zoomImg={{src:
|
|
136
|
+
zoomImg={preview.previewSrc ? {src: preview.previewSrc} : undefined}
|
|
109
137
|
openOnClick={true}
|
|
110
138
|
className={css`
|
|
111
139
|
position: absolute;
|
|
@@ -119,7 +147,7 @@ function ImageZoom({thumbnailUrl, url}: {thumbnailUrl: string; url: string}) {
|
|
|
119
147
|
zoomed={zoomed}
|
|
120
148
|
onZoomedChange={setZoomed}
|
|
121
149
|
>
|
|
122
|
-
<div role="img" style={{backgroundImage: `url(${
|
|
150
|
+
<div role="img" style={{backgroundImage: `url(${preview.previewSrc})`, outline: "none"}} />
|
|
123
151
|
</Zoom>
|
|
124
152
|
<Tooltip title={"Zoom in"}>
|
|
125
153
|
<IconButton
|
|
@@ -152,7 +180,7 @@ export class FileItem extends PureComponent<FileItemProps> {
|
|
|
152
180
|
}
|
|
153
181
|
|
|
154
182
|
render() {
|
|
155
|
-
const {name, url, thumbnailUrl, status,
|
|
183
|
+
const {name, url, thumbnailUrl, status, previewData} = this.props.data;
|
|
156
184
|
const isActive = status === "uploading" || status === "deleting";
|
|
157
185
|
const isBackgroundReady = thumbnailUrl && !isActive;
|
|
158
186
|
return (
|
|
@@ -210,7 +238,21 @@ export class FileItem extends PureComponent<FileItemProps> {
|
|
|
210
238
|
gap: ${space.s4}px;
|
|
211
239
|
`}
|
|
212
240
|
>
|
|
213
|
-
{
|
|
241
|
+
{previewData ? (
|
|
242
|
+
<PreviewEntry
|
|
243
|
+
preview={previewData}
|
|
244
|
+
actions={
|
|
245
|
+
<>
|
|
246
|
+
<a href={url} target="_blank" rel="noopener noreferrer">
|
|
247
|
+
<ActionsMenuItem Icon={RicheditorOpenLink}>Open in new tab</ActionsMenuItem>
|
|
248
|
+
</a>
|
|
249
|
+
<a download={name} href={`${url}/attachment`}>
|
|
250
|
+
<ActionsMenuItem Icon={FileDownload}>Download</ActionsMenuItem>
|
|
251
|
+
</a>
|
|
252
|
+
</>
|
|
253
|
+
}
|
|
254
|
+
/>
|
|
255
|
+
) : null}
|
|
214
256
|
<ActionsMenu
|
|
215
257
|
trigger={
|
|
216
258
|
<ActionsButtonCompact
|
|
@@ -221,9 +263,18 @@ export class FileItem extends PureComponent<FileItemProps> {
|
|
|
221
263
|
/>
|
|
222
264
|
}
|
|
223
265
|
>
|
|
224
|
-
<a download={name} href={url}>
|
|
266
|
+
<a download={name} href={this.props.data.downloadUrl ?? url}>
|
|
225
267
|
<ActionsMenuItem>Download</ActionsMenuItem>
|
|
226
268
|
</a>
|
|
269
|
+
{this.props.onRenameClick && status === "done" ? (
|
|
270
|
+
<ActionsMenuItem
|
|
271
|
+
onSelect={() =>
|
|
272
|
+
this.props.onRenameClick?.({id: this.props.data.uid, name: this.props.data.name})
|
|
273
|
+
}
|
|
274
|
+
>
|
|
275
|
+
Rename
|
|
276
|
+
</ActionsMenuItem>
|
|
277
|
+
) : null}
|
|
227
278
|
<ActionsMenuItem
|
|
228
279
|
onSelect={() => this.props.onRemoveClick?.(this.props.data)}
|
|
229
280
|
dangerous
|
package/src/header-layout.tsx
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
2
|
import {ReactNode} from "react";
|
|
3
3
|
import {space, textStyles, themeVars} from "./design-system";
|
|
4
|
+
import {mobileRootSelector} from "./mobile-styles";
|
|
4
5
|
|
|
5
6
|
const containerStyle = css`
|
|
6
7
|
padding: ${space.s8}px;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
7
10
|
border-bottom: 1px solid ${themeVars.separatorColor};
|
|
11
|
+
${mobileRootSelector} & {
|
|
12
|
+
padding: ${space.s12}px;
|
|
13
|
+
min-height: ${space.s60}px;
|
|
14
|
+
}
|
|
8
15
|
`;
|
|
9
16
|
|
|
10
17
|
const topGridCompactStyle = css`
|
|
11
18
|
${textStyles.regular}
|
|
19
|
+
width: 100%;
|
|
12
20
|
display: flex;
|
|
13
21
|
align-items: center;
|
|
14
22
|
justify-content: space-between;
|
|
@@ -22,6 +30,9 @@ export function HeaderLayout({actions, children}: {actions?: ReactNode; children
|
|
|
22
30
|
className={css`
|
|
23
31
|
${textStyles.heading4}
|
|
24
32
|
position: relative;
|
|
33
|
+
${mobileRootSelector} & {
|
|
34
|
+
${textStyles.heading3}
|
|
35
|
+
}
|
|
25
36
|
`}
|
|
26
37
|
>
|
|
27
38
|
{children}
|
package/src/html-styles.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {css} from "@linaria/core";
|
|
|
3
3
|
import {
|
|
4
4
|
border,
|
|
5
5
|
fontFamily,
|
|
6
|
+
fontSize,
|
|
6
7
|
fontWeight,
|
|
7
8
|
lineHeight,
|
|
8
9
|
space,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
transition,
|
|
12
13
|
typeSizes,
|
|
13
14
|
} from "./design-system";
|
|
15
|
+
import {mobileRootSelector} from "./mobile-styles";
|
|
14
16
|
|
|
15
17
|
export const linkStyles = {
|
|
16
18
|
color: themeVars.linkColor,
|
|
@@ -252,7 +254,10 @@ const htmlStyles = {
|
|
|
252
254
|
Used in comments and view descriptions
|
|
253
255
|
*/
|
|
254
256
|
const smallHtmlStyles = {
|
|
255
|
-
fontSize:
|
|
257
|
+
fontSize: fontSize.xs,
|
|
258
|
+
[`${mobileRootSelector} &`]: {
|
|
259
|
+
fontSize: fontSize.md,
|
|
260
|
+
},
|
|
256
261
|
"& h1": {
|
|
257
262
|
fontFamily,
|
|
258
263
|
fontSize: 24,
|
|
@@ -453,11 +458,12 @@ const smallHtmlStyles = {
|
|
|
453
458
|
/*
|
|
454
459
|
Used in chat
|
|
455
460
|
*/
|
|
456
|
-
|
|
457
|
-
Used in chat
|
|
458
|
-
*/
|
|
461
|
+
|
|
459
462
|
const chatHtmlStyles = {
|
|
460
463
|
fontSize: typeSizes[4],
|
|
464
|
+
[`${mobileRootSelector} &`]: {
|
|
465
|
+
fontSize: typeSizes[3],
|
|
466
|
+
},
|
|
461
467
|
"& h1": {
|
|
462
468
|
fontFamily,
|
|
463
469
|
fontSize: 20,
|
|
@@ -549,6 +555,9 @@ const chatHtmlStyles = {
|
|
|
549
555
|
paddingBottom: space.s2,
|
|
550
556
|
...textStyles.regular,
|
|
551
557
|
lineHeight: lineHeight.text,
|
|
558
|
+
[`${mobileRootSelector} &`]: {
|
|
559
|
+
...textStyles.big,
|
|
560
|
+
},
|
|
552
561
|
},
|
|
553
562
|
"& .fibery-rich-text-check-item": {
|
|
554
563
|
marginTop: space.s2,
|
package/src/icons/ast/Back.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { IconDefinition } from '../types';
|
|
5
5
|
|
|
6
|
-
const Back: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"
|
|
6
|
+
const Back: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"d":"M7.47 5.22a.75.75 0 0 1 1.06 1.06L5.56 9.25h10.69a.75.75 0 0 1 0 1.5H5.56l2.97 2.97a.75.75 0 1 1-1.06 1.06l-4.25-4.25a.748.748 0 0 1 0-1.06l4.25-4.25Z"},"children":[]}],"metadata":""}]},"name":"back"};
|
|
7
7
|
|
|
8
8
|
export default Back;
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { IconDefinition } from '../types';
|
|
5
5
|
|
|
6
|
-
const ExtensionFiles: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"d":"
|
|
6
|
+
const ExtensionFiles: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"d":"M15.03 6.032c0-.695-.294-1.362-.817-1.854a2.886 2.886 0 0 0-1.974-.767c-.647 0-1.271.212-1.768.594l-.205.173-5.427 5.097c-.855.803-1.336 1.893-1.336 3.03 0 1.136.48 2.225 1.336 3.029a4.718 4.718 0 0 0 3.226 1.255l.226-.006a4.705 4.705 0 0 0 3-1.25l5.426-5.096a.786.786 0 0 1 1.063 0 .676.676 0 0 1 0 .998l-5.426 5.096c-1.067 1.002-2.49 1.592-3.988 1.662l-.3.007c-1.61 0-3.152-.6-4.29-1.669C2.64 15.263 2 13.815 2 12.304c0-1.51.64-2.959 1.777-4.027l5.426-5.096.155-.138A4.454 4.454 0 0 1 12.239 2a4.44 4.44 0 0 1 3.036 1.18 3.913 3.913 0 0 1 1.258 2.852l-.005.2a3.923 3.923 0 0 1-1.253 2.65L9.85 13.98a2.595 2.595 0 0 1-1.535.683l-.249.011c-.669 0-1.31-.25-1.783-.694a2.299 2.299 0 0 1-.74-1.675c0-.628.267-1.23.74-1.675l5.426-5.096a.787.787 0 0 1 1.062 0 .676.676 0 0 1 0 .998l-5.426 5.096a.93.93 0 0 0-.3.677.93.93 0 0 0 .3.678c.191.179.45.28.721.28l.101-.005a1.05 1.05 0 0 0 .62-.275l5.427-5.097c.458-.43.74-.994.804-1.594l.014-.26Z"},"children":[]}],"metadata":""}]},"name":"extension-files"};
|
|
7
7
|
|
|
8
8
|
export default ExtensionFiles;
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { IconDefinition } from '../types';
|
|
5
5
|
|
|
6
|
-
const FileUpload: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0
|
|
6
|
+
const FileUpload: IconDefinition = {"icon":{"type":"root","children":[{"type":"element","tagName":"svg","properties":{"viewBox":"0 0 20 20"},"children":[{"type":"element","tagName":"path","properties":{"d":"m13.029 10.72-2.499-2.5a.75.75 0 0 0-1.06 0l-2.499 2.5a.75.75 0 0 0 1.06 1.06l1.22-1.22v3.94a.75.75 0 1 0 1.499 0v-3.94l1.219 1.22a.75.75 0 1 0 1.06-1.06Z"},"children":[]},{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","clipRule":"evenodd","d":"M5.745 1.5a2.75 2.75 0 0 0-2.748 2.75v11.5a2.75 2.75 0 0 0 2.748 2.75h8.503a2.75 2.75 0 0 0 2.749-2.75V6.747c0-.2-.08-.39-.22-.531l-4.505-4.497a.75.75 0 0 0-.53-.219H5.745Zm-1.25 2.75c0-.69.56-1.25 1.25-1.25h5.248v2.913a1.584 1.584 0 0 0 1.582 1.584h2.922v8.253c0 .69-.56 1.25-1.25 1.25H5.746c-.69 0-1.25-.56-1.25-1.25V4.25Zm9.94 1.747-1.943-1.94v1.856a.083.083 0 0 0 .083.084h1.86Z"},"children":[]}],"metadata":""}]},"name":"file-upload"};
|
|
7
7
|
|
|
8
8
|
export default FileUpload;
|