@fibery/ui-kit 1.37.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 +25 -0
- package/config/jest/testFrameworkSetup.js +1 -1
- package/package.json +20 -16
- package/src/abbreviate-name.ts +42 -0
- package/src/actions-menu/actions-menu-item.tsx +32 -11
- package/src/actions-menu/actions-menu-props.tsx +5 -0
- package/src/actions-menu/actions-menu-sub-command-menu.tsx +7 -4
- package/src/actions-menu/actions-menu-sub-menu.tsx +9 -3
- package/src/actions-menu/actions-menu.tsx +28 -9
- package/src/actions-menu/context-actions-menu.tsx +22 -0
- package/src/actions-panel.tsx +12 -2
- 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/axis-header.tsx +136 -76
- package/src/box.tsx +1 -1
- package/src/breadcrumb.tsx +78 -0
- package/src/button/actions-button-compact.tsx +4 -1
- package/src/button/base-button.tsx +7 -3
- package/src/button/button-group.tsx +1 -1
- package/src/button/button.tsx +33 -1
- package/src/button/icon-button.tsx +10 -1
- package/src/button/select-button.tsx +4 -0
- package/src/card-container.tsx +10 -6
- package/src/checkbox.tsx +17 -0
- package/src/collapsible-section.tsx +3 -1
- package/src/color-picker/swatch.tsx +1 -0
- package/src/command-menu/index.tsx +3 -3
- package/src/context-menu/index.tsx +10 -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/date-range-picker.tsx +6 -3
- package/src/date-picker/relative-date-picker.tsx +6 -2
- package/src/date-picker/single-date-input.tsx +5 -1
- package/src/date-picker/single-date-picker.tsx +8 -5
- package/src/date-picker/styles.ts +52 -26
- package/src/date-picker/types.ts +3 -1
- package/src/day-select/day-select.tsx +21 -75
- package/src/day-select/iso-week-day-select.tsx +1 -1
- package/src/day-select/mount-day-select.tsx +2 -2
- package/src/day-select/week-day-select.tsx +1 -5
- package/src/design-system.ts +45 -12
- package/src/dropdown-menu/index.tsx +19 -2
- package/src/emoji-picker/app-icon-picker.tsx +6 -4
- package/src/emoji-picker/emoji-picker-preview-footer.tsx +5 -1
- package/src/emoji-picker/emoji-picker.tsx +3 -0
- package/src/emoji-picker/emoji.tsx +5 -3
- package/src/emoji-picker/icon-emoji-picker.tsx +10 -1
- package/src/emoji-picker/primitives/emoji.tsx +49 -51
- package/src/emoji-picker/primitives/footer.tsx +5 -0
- package/src/emoji-picker/primitives/search.tsx +8 -0
- package/src/emoji-picker/primitives/skin-tone.tsx +12 -1
- package/src/emoji-picker/use-responsive-emoji-size.ts +11 -0
- package/src/emoji-picker/utils/emoji-set.ts +2 -1
- package/src/empty-state/empty-state.tsx +6 -0
- package/src/fibermoji-placeholder.tsx +1 -27
- package/src/field-icon.tsx +4 -1
- package/src/file-item-2.tsx +408 -0
- package/src/file-item.tsx +215 -47
- package/src/header-layout.tsx +11 -0
- package/src/html-styles.ts +21 -4
- package/src/icons/ast/ActivityFilled.ts +8 -0
- package/src/icons/ast/AiAssistantFilled.ts +8 -0
- package/src/icons/ast/Back.ts +1 -1
- package/src/icons/ast/CollapseAllHorizontal.ts +8 -0
- package/src/icons/ast/DateRange.ts +1 -1
- package/src/icons/ast/EntityCreateFilled.ts +8 -0
- package/src/icons/ast/ExpandAllHorizontal.ts +8 -0
- package/src/icons/ast/ExtensionFiles.ts +1 -1
- package/src/icons/ast/FileUpload.ts +1 -1
- package/src/icons/ast/GlobeUnpublish.ts +8 -0
- package/src/icons/ast/HomeFilled.ts +8 -0
- package/src/icons/ast/KeyboardHideDown.ts +8 -0
- package/src/icons/ast/LayoutMultiple.ts +8 -0
- package/src/icons/ast/RicheditorHistoryRedo.ts +1 -1
- package/src/icons/ast/RicheditorHistoryUndo.ts +1 -1
- package/src/icons/ast/SearchFilled.ts +8 -0
- package/src/icons/ast/SettingsFilled.ts +8 -0
- package/src/icons/ast/SlideMenuFilled.ts +8 -0
- 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/TypeDate.ts +1 -1
- package/src/icons/ast/ViewGallery.ts +8 -0
- package/src/icons/ast/index.tsx +16 -0
- package/src/icons/react/ActivityFilled.tsx +13 -0
- package/src/icons/react/AiAssistantFilled.tsx +13 -0
- package/src/icons/react/CollapseAllHorizontal.tsx +13 -0
- package/src/icons/react/EntityCreateFilled.tsx +13 -0
- package/src/icons/react/ExpandAllHorizontal.tsx +13 -0
- package/src/icons/react/GlobeUnpublish.tsx +13 -0
- package/src/icons/react/HomeFilled.tsx +13 -0
- package/src/icons/react/KeyboardHideDown.tsx +13 -0
- package/src/icons/react/LayoutMultiple.tsx +13 -0
- package/src/icons/react/SearchFilled.tsx +13 -0
- package/src/icons/react/SettingsFilled.tsx +13 -0
- package/src/icons/react/SlideMenuFilled.tsx +13 -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 +16 -0
- package/src/icons/svg/activity-filled.svg +4 -0
- package/src/icons/svg/ai-assistant-filled.svg +3 -0
- package/src/icons/svg/back.svg +3 -1
- package/src/icons/svg/collapse-all-horizontal.svg +3 -0
- package/src/icons/svg/date-range.svg +3 -3
- package/src/icons/svg/entity-create-filled.svg +4 -0
- package/src/icons/svg/expand-all-horizontal.svg +3 -0
- package/src/icons/svg/extension/files.svg +3 -1
- package/src/icons/svg/file-upload.svg +3 -6
- package/src/icons/svg/globe-unpublish.svg +4 -0
- package/src/icons/svg/home-filled.svg +3 -0
- package/src/icons/svg/keyboard-hide-down.svg +1 -0
- package/src/icons/svg/layout-multiple.svg +3 -0
- package/src/icons/svg/richeditor/history/redo.svg +3 -2
- package/src/icons/svg/richeditor/history/undo.svg +3 -2
- package/src/icons/svg/search-filled.svg +3 -0
- package/src/icons/svg/settings-filled.svg +3 -0
- package/src/icons/svg/slide-menu-filled.svg +1 -0
- 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/type/date.svg +3 -2
- 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 +257 -0
- package/src/images-gallery/zoom.tsx +123 -0
- 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/is-in-popup.ts +1 -1
- package/src/kbd.tsx +46 -0
- package/src/layout-styles.ts +21 -1
- package/src/lists/actions-menu-row-surface.tsx +3 -1
- package/src/lists/list-row-surface.tsx +7 -1
- package/src/mobile-keyboard-aware-popup.tsx +87 -0
- package/src/mobile-styles.ts +8 -0
- package/src/modal-menu/contexts/modal-menu-context.tsx +22 -0
- package/src/modal-menu/contexts/modal-submenu-context.tsx +16 -0
- package/src/modal-menu/index.tsx +14 -0
- package/src/modal-menu/modal-menu-content.tsx +68 -0
- package/src/modal-menu/modal-menu-group.tsx +10 -0
- package/src/modal-menu/modal-menu-item.tsx +45 -0
- package/src/modal-menu/modal-menu-label.tsx +24 -0
- package/src/modal-menu/modal-menu-root.tsx +57 -0
- package/src/modal-menu/modal-menu-separator.tsx +14 -0
- package/src/modal-menu/modal-menu-trigger.tsx +54 -0
- package/src/modal-menu/modal-submenu-content.tsx +49 -0
- package/src/modal-menu/modal-submenu-trigger.tsx +34 -0
- package/src/modal-menu/modal-submenu.tsx +17 -0
- package/src/notification-dot.tsx +16 -7
- package/src/online-users.tsx +3 -3
- package/src/palette.ts +1 -1
- package/src/platform-symbols.ts +9 -0
- package/src/platform.ts +2 -0
- package/src/popover/index.tsx +710 -0
- package/src/popover/mobile-popup-context.tsx +29 -0
- package/src/{popup → popover}/modifiers.tsx +25 -25
- package/src/{popup → popover}/popup-modifiers-context.ts +3 -3
- package/src/reactions/reaction-button.tsx +342 -135
- package/src/reactions/reaction-picker.tsx +51 -44
- 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/index.tsx +8 -4
- package/src/select/select-control-settings-context.tsx +11 -2
- package/src/select/select-in-popover.tsx +30 -39
- package/src/select/styles.ts +21 -1
- package/src/tab-nav/tab-nav.tsx +36 -10
- package/src/toast/primitives.tsx +8 -1
- package/src/toggle-button/round-toggle-button.tsx +23 -0
- package/src/toggle-button/toggle-button-group.tsx +34 -0
- package/src/toggle-button/toggle-button.tsx +164 -0
- package/src/toggle.tsx +11 -3
- package/src/tooltip.tsx +29 -20
- package/src/type-badge.tsx +5 -2
- package/src/unit/styles.ts +2 -2
- package/src/unit/unit-with-tooltip.tsx +1 -1
- package/src/use-is-phone.tsx +50 -4
- package/src/use-is-support-hover.ts +1 -1
- package/src/use-on-screen-keyboard-data.tsx +66 -0
- package/src/workflow-progress-icon.tsx +16 -22
- package/src/popup/index.tsx +0 -383
- package/src/shortcut-badge.tsx +0 -29
- /package/src/{popup → popover}/popup-stack-context.tsx +0 -0
- /package/src/{popup → popover}/reference.ts +0 -0
- /package/src/{popup → popover}/styles.ts +0 -0
- /package/src/{popup → popover}/use-click-outside.ts +0 -0
package/src/field-icon.tsx
CHANGED
|
@@ -18,8 +18,11 @@ export function FieldIcon({
|
|
|
18
18
|
if (iconName && isAppIcon(iconName)) {
|
|
19
19
|
return <FieldAppIcon iconName={iconName} color={color} containerSize={containerSize} iconSize={iconSize} />;
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
const defaultSize = containerSize || iconSize;
|
|
23
|
+
|
|
21
24
|
return (
|
|
22
|
-
<Suspense fallback={
|
|
25
|
+
<Suspense fallback={<div style={{width: defaultSize, height: defaultSize}} />}>
|
|
23
26
|
<FieldTypeIconLazy iconName={iconName} color={color} containerSize={containerSize} iconSize={iconSize} />
|
|
24
27
|
</Suspense>
|
|
25
28
|
);
|
|
@@ -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
|
+
// `;
|