@ttoss/components 2.14.25 → 2.14.26
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/index.d.mts +910 -0
- package/dist/index.mjs +3074 -0
- package/package.json +14 -100
- package/dist/Accordion/index.d.mts +0 -157
- package/dist/Accordion/index.mjs +0 -175
- package/dist/DatePicker/index.d.mts +0 -26
- package/dist/DatePicker/index.mjs +0 -339
- package/dist/Drawer/index.d.mts +0 -17
- package/dist/Drawer/index.mjs +0 -66
- package/dist/EnhancedTitle/index.d.mts +0 -107
- package/dist/EnhancedTitle/index.mjs +0 -234
- package/dist/FileUploader/index.d.mts +0 -77
- package/dist/FileUploader/index.mjs +0 -386
- package/dist/InstallPwa/index.d.mts +0 -13
- package/dist/InstallPwa/index.mjs +0 -64
- package/dist/JsonEditor/index.d.mts +0 -3
- package/dist/JsonEditor/index.mjs +0 -3
- package/dist/JsonView/index.d.mts +0 -3
- package/dist/JsonView/index.mjs +0 -3
- package/dist/List/index.d.mts +0 -16
- package/dist/List/index.mjs +0 -34
- package/dist/LockedOverlay/index.d.mts +0 -162
- package/dist/LockedOverlay/index.mjs +0 -386
- package/dist/Markdown/index.d.mts +0 -16
- package/dist/Markdown/index.mjs +0 -26
- package/dist/Menu/index.d.mts +0 -16
- package/dist/Menu/index.mjs +0 -136
- package/dist/MetricCard/index.d.mts +0 -153
- package/dist/MetricCard/index.mjs +0 -408
- package/dist/Modal/index.d.mts +0 -11
- package/dist/Modal/index.mjs +0 -64
- package/dist/NavList/index.d.mts +0 -64
- package/dist/NavList/index.mjs +0 -252
- package/dist/NotificationCard/index.d.mts +0 -22
- package/dist/NotificationCard/index.mjs +0 -173
- package/dist/NotificationsMenu/index.d.mts +0 -47
- package/dist/NotificationsMenu/index.mjs +0 -380
- package/dist/Search/index.d.mts +0 -18
- package/dist/Search/index.mjs +0 -31
- package/dist/SpotlightCard/index.d.mts +0 -36
- package/dist/SpotlightCard/index.mjs +0 -219
- package/dist/Table/index.d.mts +0 -17
- package/dist/Table/index.mjs +0 -64
- package/dist/Tabs/index.d.mts +0 -17
- package/dist/Tabs/index.mjs +0 -87
- package/dist/Toast/index.d.mts +0 -8
- package/dist/Toast/index.mjs +0 -43
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { Badge, Flex, Heading, Stack, Text, keyframes } from "@ttoss/ui";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Icon } from "@ttoss/react-icons";
|
|
5
|
-
|
|
6
|
-
//#region src/components/EnhancedTitle/EnhancedTitle.styles.ts
|
|
7
|
-
var gradientFlow = keyframes({
|
|
8
|
-
"0%": {
|
|
9
|
-
backgroundPosition: "0% 50%"
|
|
10
|
-
},
|
|
11
|
-
"50%": {
|
|
12
|
-
backgroundPosition: "100% 50%"
|
|
13
|
-
},
|
|
14
|
-
"100%": {
|
|
15
|
-
backgroundPosition: "0% 50%"
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
var getAccentGradientBackground = t => {
|
|
19
|
-
const theme = t;
|
|
20
|
-
const start = theme.colors?.action?.background?.accent?.default || theme.colors?.input?.background?.accent?.default;
|
|
21
|
-
if (!start) return void 0;
|
|
22
|
-
return `linear-gradient(270deg, ${start}, ${theme.colors?.action?.background?.accent?.active || theme.colors?.input?.background?.accent?.active || start}, ${start})`;
|
|
23
|
-
};
|
|
24
|
-
var getPrimaryGradientBackground = t => {
|
|
25
|
-
const theme = t;
|
|
26
|
-
const start = theme.colors?.action?.background?.primary?.default;
|
|
27
|
-
if (!start) return void 0;
|
|
28
|
-
return `linear-gradient(270deg, ${start}, ${theme.colors?.action?.background?.secondary?.default || start}, ${start})`;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Returns style configuration for the icon wrapper based on variant.
|
|
32
|
-
*/
|
|
33
|
-
var getEnhancedTitleIconSx = variant => {
|
|
34
|
-
return {
|
|
35
|
-
flexShrink: 0,
|
|
36
|
-
alignItems: "center",
|
|
37
|
-
justifyContent: "center",
|
|
38
|
-
borderRadius: "2xl",
|
|
39
|
-
border: "md",
|
|
40
|
-
width: "56px",
|
|
41
|
-
height: "56px",
|
|
42
|
-
...{
|
|
43
|
-
"spotlight-accent": {
|
|
44
|
-
backgroundColor: "input.background.accent.default",
|
|
45
|
-
color: "action.text.accent.default",
|
|
46
|
-
borderColor: "display.border.muted.default",
|
|
47
|
-
background: getAccentGradientBackground,
|
|
48
|
-
backgroundSize: "400% 400%",
|
|
49
|
-
animation: `${gradientFlow} 6s ease infinite`
|
|
50
|
-
},
|
|
51
|
-
"spotlight-primary": {
|
|
52
|
-
backgroundColor: "action.background.primary.default",
|
|
53
|
-
color: "display.text.accent.default",
|
|
54
|
-
borderColor: "display.border.muted.default",
|
|
55
|
-
background: getPrimaryGradientBackground,
|
|
56
|
-
backgroundSize: "400% 400%",
|
|
57
|
-
animation: `${gradientFlow} 6s ease infinite`
|
|
58
|
-
},
|
|
59
|
-
primary: {
|
|
60
|
-
backgroundColor: "action.background.primary.default",
|
|
61
|
-
color: "action.text.primary.default",
|
|
62
|
-
borderColor: "display.border.muted.default"
|
|
63
|
-
},
|
|
64
|
-
secondary: {
|
|
65
|
-
backgroundColor: "action.background.secondary.default",
|
|
66
|
-
color: "action.text.primary.default",
|
|
67
|
-
borderColor: "display.border.muted.default"
|
|
68
|
-
},
|
|
69
|
-
accent: {
|
|
70
|
-
backgroundColor: "action.background.accent.default",
|
|
71
|
-
color: "action.text.accent.default",
|
|
72
|
-
borderColor: "display.border.muted.default"
|
|
73
|
-
},
|
|
74
|
-
positive: {
|
|
75
|
-
backgroundColor: "display.bg.positive.boldest",
|
|
76
|
-
color: "display.fg.positive.bolder",
|
|
77
|
-
borderColor: "display.border.muted.default"
|
|
78
|
-
},
|
|
79
|
-
negative: {
|
|
80
|
-
backgroundColor: "display.bg.negative.boldest",
|
|
81
|
-
color: "display.fg.negative.bolder",
|
|
82
|
-
borderColor: "display.border.muted.default"
|
|
83
|
-
},
|
|
84
|
-
informative: {
|
|
85
|
-
backgroundColor: "display.bg.informative.boldest",
|
|
86
|
-
color: "display.fg.informative.bolder",
|
|
87
|
-
borderColor: "display.border.muted.default"
|
|
88
|
-
},
|
|
89
|
-
muted: {
|
|
90
|
-
backgroundColor: "display.bg.muted.boldest",
|
|
91
|
-
color: "display.fg.muted.bolder",
|
|
92
|
-
borderColor: "display.border.muted.default"
|
|
93
|
-
}
|
|
94
|
-
}[variant]
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/components/EnhancedTitle/EnhancedTitle.tsx
|
|
100
|
-
/**
|
|
101
|
-
* EnhancedTitle component renders a structured title section with icon, badges, and metadata.
|
|
102
|
-
*
|
|
103
|
-
* This component is useful for displaying rich title sections with status indicators,
|
|
104
|
-
* feature tags, and supplementary information in a consistent layout.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```tsx
|
|
108
|
-
* <EnhancedTitle
|
|
109
|
-
* icon="fluent:shield-24-filled"
|
|
110
|
-
* title="Starter Plan"
|
|
111
|
-
* frontTitle="R$ 49,90/mês"
|
|
112
|
-
* description="Perfect for small teams"
|
|
113
|
-
* variant="primary"
|
|
114
|
-
* topBadges={[
|
|
115
|
-
* { label: 'Active', variant: 'positive', icon: 'fluent:checkmark-circle-24-filled' }
|
|
116
|
-
* ]}
|
|
117
|
-
* bottomBadges={[
|
|
118
|
-
* { label: 'OneClick Tracking', icon: 'fluent:checkmark-24-filled' }
|
|
119
|
-
* ]}
|
|
120
|
-
* />
|
|
121
|
-
* ```
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```tsx
|
|
125
|
-
* <EnhancedTitle
|
|
126
|
-
* title="Pro Plan"
|
|
127
|
-
* frontTitle="$99/month"
|
|
128
|
-
* variant="accent"
|
|
129
|
-
* topBadges={[
|
|
130
|
-
* { label: 'Most Popular', variant: 'informative' }
|
|
131
|
-
* ]}
|
|
132
|
-
* />
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
var EnhancedTitle = ({
|
|
136
|
-
variant = "spotlight-primary",
|
|
137
|
-
icon,
|
|
138
|
-
title,
|
|
139
|
-
description,
|
|
140
|
-
frontTitle,
|
|
141
|
-
topBadges = [],
|
|
142
|
-
bottomBadges = []
|
|
143
|
-
}) => {
|
|
144
|
-
return /* @__PURE__ */jsx(Stack, {
|
|
145
|
-
sx: {
|
|
146
|
-
paddingY: "6",
|
|
147
|
-
paddingX: "6",
|
|
148
|
-
width: "full"
|
|
149
|
-
},
|
|
150
|
-
children: /* @__PURE__ */jsxs(Flex, {
|
|
151
|
-
sx: {
|
|
152
|
-
gap: "6",
|
|
153
|
-
alignItems: "flex-start",
|
|
154
|
-
flexDirection: ["column", "row"]
|
|
155
|
-
},
|
|
156
|
-
children: [icon && /* @__PURE__ */jsx(Flex, {
|
|
157
|
-
sx: getEnhancedTitleIconSx(variant),
|
|
158
|
-
children: /* @__PURE__ */jsx(Icon, {
|
|
159
|
-
icon,
|
|
160
|
-
width: 24,
|
|
161
|
-
height: 24
|
|
162
|
-
})
|
|
163
|
-
}), /* @__PURE__ */jsxs(Flex, {
|
|
164
|
-
sx: {
|
|
165
|
-
flexDirection: "column",
|
|
166
|
-
gap: ["4", "5"],
|
|
167
|
-
flex: 1
|
|
168
|
-
},
|
|
169
|
-
children: [topBadges.length > 0 && /* @__PURE__ */jsx(Flex, {
|
|
170
|
-
sx: {
|
|
171
|
-
flexWrap: "wrap",
|
|
172
|
-
gap: "2",
|
|
173
|
-
alignItems: "center"
|
|
174
|
-
},
|
|
175
|
-
children: topBadges.map((badge, index) => {
|
|
176
|
-
return /* @__PURE__ */jsx(Badge, {
|
|
177
|
-
icon: badge.icon,
|
|
178
|
-
variant: badge.variant ?? "muted",
|
|
179
|
-
sx: {
|
|
180
|
-
borderRadius: "full"
|
|
181
|
-
},
|
|
182
|
-
children: badge.label
|
|
183
|
-
}, index);
|
|
184
|
-
})
|
|
185
|
-
}), /* @__PURE__ */jsxs(Flex, {
|
|
186
|
-
sx: {
|
|
187
|
-
flexDirection: ["column", "row"],
|
|
188
|
-
alignItems: ["flex-start", "baseline"],
|
|
189
|
-
gap: ["1", "3"]
|
|
190
|
-
},
|
|
191
|
-
children: [/* @__PURE__ */jsx(Heading, {
|
|
192
|
-
as: "h2",
|
|
193
|
-
sx: {
|
|
194
|
-
fontSize: "4xl",
|
|
195
|
-
fontWeight: "semibold",
|
|
196
|
-
color: "display.text.primary.default"
|
|
197
|
-
},
|
|
198
|
-
children: title
|
|
199
|
-
}), frontTitle && /* @__PURE__ */jsx(Text, {
|
|
200
|
-
sx: {
|
|
201
|
-
fontSize: "xl",
|
|
202
|
-
color: "display.text.secondary.default"
|
|
203
|
-
},
|
|
204
|
-
children: frontTitle
|
|
205
|
-
})]
|
|
206
|
-
}), description && /* @__PURE__ */jsx(Text, {
|
|
207
|
-
sx: {
|
|
208
|
-
fontSize: "md",
|
|
209
|
-
color: "display.text.secondary.default"
|
|
210
|
-
},
|
|
211
|
-
children: description
|
|
212
|
-
}), bottomBadges.length > 0 && /* @__PURE__ */jsx(Flex, {
|
|
213
|
-
sx: {
|
|
214
|
-
flexWrap: "wrap",
|
|
215
|
-
gap: "2"
|
|
216
|
-
},
|
|
217
|
-
children: bottomBadges.map((badge, index) => {
|
|
218
|
-
return /* @__PURE__ */jsx(Badge, {
|
|
219
|
-
icon: badge.icon ?? "fluent:checkmark-24-filled",
|
|
220
|
-
variant: badge.variant ?? "muted",
|
|
221
|
-
sx: {
|
|
222
|
-
borderRadius: "full"
|
|
223
|
-
},
|
|
224
|
-
children: badge.label
|
|
225
|
-
}, index);
|
|
226
|
-
})
|
|
227
|
-
})]
|
|
228
|
-
})]
|
|
229
|
-
})
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
//#endregion
|
|
234
|
-
export { EnhancedTitle };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/components/FileUploader/FileUploader.d.ts
|
|
5
|
-
type UploadResult = {
|
|
6
|
-
url: string;
|
|
7
|
-
id: string | number;
|
|
8
|
-
};
|
|
9
|
-
type FileUploadState = {
|
|
10
|
-
file: File;
|
|
11
|
-
status: 'pending' | 'uploading' | 'completed' | 'error';
|
|
12
|
-
progress?: number;
|
|
13
|
-
result?: UploadResult;
|
|
14
|
-
error?: Error;
|
|
15
|
-
};
|
|
16
|
-
type OnUpload = (file: File, onProgress?: (progress: number) => void) => Promise<UploadResult>;
|
|
17
|
-
type OnUploadStart = (file: File) => void;
|
|
18
|
-
type OnUploadProgress = (file: File, progress: number) => void;
|
|
19
|
-
type OnUploadComplete = (file: File, result: UploadResult) => void;
|
|
20
|
-
type OnUploadError = (file: File, error: Error) => void;
|
|
21
|
-
type OnFilesChange = (files: FileUploadState[]) => void;
|
|
22
|
-
type OnRemove = (file: UploadedFile, index: number) => void;
|
|
23
|
-
type UploadedFile = {
|
|
24
|
-
id: string | number;
|
|
25
|
-
name: string;
|
|
26
|
-
imageUrl?: string;
|
|
27
|
-
url: string;
|
|
28
|
-
};
|
|
29
|
-
type FileUploaderProps = {
|
|
30
|
-
onUpload: OnUpload;
|
|
31
|
-
onUploadStart?: OnUploadStart;
|
|
32
|
-
onUploadProgress?: OnUploadProgress;
|
|
33
|
-
onUploadComplete?: OnUploadComplete;
|
|
34
|
-
onUploadError?: OnUploadError;
|
|
35
|
-
onFilesChange?: OnFilesChange;
|
|
36
|
-
onRemove?: OnRemove;
|
|
37
|
-
accept?: string;
|
|
38
|
-
multiple?: boolean;
|
|
39
|
-
maxSize?: number;
|
|
40
|
-
maxFiles?: number;
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
autoUpload?: boolean;
|
|
43
|
-
retryAttempts?: number;
|
|
44
|
-
placeholder?: string;
|
|
45
|
-
error?: string;
|
|
46
|
-
children?: React.ReactNode;
|
|
47
|
-
showFileList?: boolean;
|
|
48
|
-
FileListComponent?: (props: {
|
|
49
|
-
files: UploadedFile[];
|
|
50
|
-
onRemove: (index: number) => void;
|
|
51
|
-
}) => React.ReactNode;
|
|
52
|
-
files?: UploadedFile[];
|
|
53
|
-
};
|
|
54
|
-
declare const FileUploader: ({
|
|
55
|
-
onUpload,
|
|
56
|
-
onUploadStart,
|
|
57
|
-
onUploadProgress,
|
|
58
|
-
onUploadComplete,
|
|
59
|
-
onUploadError,
|
|
60
|
-
onFilesChange,
|
|
61
|
-
onRemove,
|
|
62
|
-
accept,
|
|
63
|
-
multiple,
|
|
64
|
-
maxSize,
|
|
65
|
-
maxFiles,
|
|
66
|
-
disabled,
|
|
67
|
-
autoUpload,
|
|
68
|
-
retryAttempts,
|
|
69
|
-
placeholder,
|
|
70
|
-
error,
|
|
71
|
-
children,
|
|
72
|
-
showFileList,
|
|
73
|
-
FileListComponent,
|
|
74
|
-
files: uploadedFiles
|
|
75
|
-
}: FileUploaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
76
|
-
//#endregion
|
|
77
|
-
export { FileUploadState, FileUploader, FileUploaderProps, OnFilesChange, OnRemove, OnUpload, OnUploadComplete, OnUploadError, OnUploadProgress, OnUploadStart, UploadResult, UploadedFile };
|
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { Box, Button, Flex, Stack, Text } from "@ttoss/ui";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { useI18n } from "@ttoss/react-i18n";
|
|
6
|
-
|
|
7
|
-
//#region src/components/FileUploader/FileUploader.tsx
|
|
8
|
-
var FileUploader = ({
|
|
9
|
-
onUpload,
|
|
10
|
-
onUploadStart,
|
|
11
|
-
onUploadProgress,
|
|
12
|
-
onUploadComplete,
|
|
13
|
-
onUploadError,
|
|
14
|
-
onFilesChange,
|
|
15
|
-
onRemove,
|
|
16
|
-
accept,
|
|
17
|
-
multiple = true,
|
|
18
|
-
maxSize = 10 * 1024 * 1024,
|
|
19
|
-
maxFiles = 5,
|
|
20
|
-
disabled = false,
|
|
21
|
-
autoUpload = true,
|
|
22
|
-
retryAttempts = 2,
|
|
23
|
-
placeholder,
|
|
24
|
-
error,
|
|
25
|
-
children,
|
|
26
|
-
showFileList = true,
|
|
27
|
-
FileListComponent,
|
|
28
|
-
files: uploadedFiles = []
|
|
29
|
-
}) => {
|
|
30
|
-
const {
|
|
31
|
-
intl
|
|
32
|
-
} = useI18n();
|
|
33
|
-
const [files, setFiles] = React.useState([]);
|
|
34
|
-
const [isDragOver, setIsDragOver] = React.useState(false);
|
|
35
|
-
const fileInputRef = React.useRef(null);
|
|
36
|
-
const formatFileSize = bytes => {
|
|
37
|
-
if (bytes === 0) return "0 Bytes";
|
|
38
|
-
const k = 1024;
|
|
39
|
-
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
40
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
41
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
|
42
|
-
};
|
|
43
|
-
const validateFiles = newFiles => {
|
|
44
|
-
const fileArray = Array.from(newFiles);
|
|
45
|
-
const validFiles = [];
|
|
46
|
-
const currentFileCount = files.length;
|
|
47
|
-
if (currentFileCount >= maxFiles) return [];
|
|
48
|
-
for (const file of fileArray) {
|
|
49
|
-
if (maxSize && file.size > maxSize) continue;
|
|
50
|
-
if (validFiles.length + currentFileCount >= maxFiles) break;
|
|
51
|
-
validFiles.push(file);
|
|
52
|
-
}
|
|
53
|
-
return validFiles;
|
|
54
|
-
};
|
|
55
|
-
const updateFileState = React.useCallback((file, updates) => {
|
|
56
|
-
setFiles(prevFiles => {
|
|
57
|
-
const newFiles = prevFiles.map(f => {
|
|
58
|
-
return f.file === file ? {
|
|
59
|
-
...f,
|
|
60
|
-
...updates
|
|
61
|
-
} : f;
|
|
62
|
-
});
|
|
63
|
-
onFilesChange?.(newFiles);
|
|
64
|
-
return newFiles;
|
|
65
|
-
});
|
|
66
|
-
}, [onFilesChange]);
|
|
67
|
-
const uploadFile = React.useCallback(async (fileState, attempts = 0) => {
|
|
68
|
-
try {
|
|
69
|
-
onUploadStart?.(fileState.file);
|
|
70
|
-
updateFileState(fileState.file, {
|
|
71
|
-
status: "uploading",
|
|
72
|
-
progress: 0
|
|
73
|
-
});
|
|
74
|
-
const result = await onUpload(fileState.file, progress => {
|
|
75
|
-
updateFileState(fileState.file, {
|
|
76
|
-
progress
|
|
77
|
-
});
|
|
78
|
-
onUploadProgress?.(fileState.file, progress);
|
|
79
|
-
});
|
|
80
|
-
updateFileState(fileState.file, {
|
|
81
|
-
status: "completed",
|
|
82
|
-
progress: 100,
|
|
83
|
-
result
|
|
84
|
-
});
|
|
85
|
-
onUploadComplete?.(fileState.file, result);
|
|
86
|
-
} catch (error_) {
|
|
87
|
-
const error = error_;
|
|
88
|
-
if (attempts < retryAttempts) setTimeout(() => {
|
|
89
|
-
return uploadFile(fileState, attempts + 1);
|
|
90
|
-
}, 1e3 * (attempts + 1));else {
|
|
91
|
-
updateFileState(fileState.file, {
|
|
92
|
-
status: "error",
|
|
93
|
-
error
|
|
94
|
-
});
|
|
95
|
-
onUploadError?.(fileState.file, error);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}, [onUpload, onUploadStart, onUploadProgress, onUploadComplete, onUploadError, retryAttempts, updateFileState]);
|
|
99
|
-
const addFiles = newFiles => {
|
|
100
|
-
const newFileStates = newFiles.map(file => {
|
|
101
|
-
return {
|
|
102
|
-
file,
|
|
103
|
-
status: "pending"
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
setFiles(prevFiles => {
|
|
107
|
-
const updatedFiles = [...prevFiles, ...newFileStates];
|
|
108
|
-
onFilesChange?.(updatedFiles);
|
|
109
|
-
return updatedFiles;
|
|
110
|
-
});
|
|
111
|
-
if (autoUpload) for (const fileState of newFileStates) uploadFile(fileState);
|
|
112
|
-
};
|
|
113
|
-
const handleFileChange = event => {
|
|
114
|
-
if (event.target.files) addFiles(validateFiles(event.target.files));
|
|
115
|
-
};
|
|
116
|
-
const handleDrop = event => {
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
setIsDragOver(false);
|
|
119
|
-
if (disabled || files.length >= maxFiles) return;
|
|
120
|
-
const droppedFiles = event.dataTransfer.files;
|
|
121
|
-
if (droppedFiles) addFiles(validateFiles(droppedFiles));
|
|
122
|
-
};
|
|
123
|
-
const handleDragOver = event => {
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
if (!disabled && files.length < maxFiles) setIsDragOver(true);
|
|
126
|
-
};
|
|
127
|
-
const handleDragLeave = event => {
|
|
128
|
-
event.preventDefault();
|
|
129
|
-
setIsDragOver(false);
|
|
130
|
-
};
|
|
131
|
-
const handleClick = () => {
|
|
132
|
-
if (!disabled && files.length < maxFiles && fileInputRef.current) fileInputRef.current.click();
|
|
133
|
-
};
|
|
134
|
-
const handleRemoveFile = React.useCallback(index => {
|
|
135
|
-
const fileToRemove = uploadedFiles[index];
|
|
136
|
-
onRemove?.(fileToRemove, index);
|
|
137
|
-
}, [uploadedFiles, onRemove]);
|
|
138
|
-
const isUploading = files.some(f => {
|
|
139
|
-
return f.status === "uploading";
|
|
140
|
-
});
|
|
141
|
-
const isMaxFilesReached = files.length >= maxFiles;
|
|
142
|
-
const fileListNode = React.useMemo(() => {
|
|
143
|
-
if (!showFileList || files.length === 0 && uploadedFiles.length === 0) return null;
|
|
144
|
-
if (FileListComponent) return /* @__PURE__ */jsx(FileListComponent, {
|
|
145
|
-
files: uploadedFiles,
|
|
146
|
-
onRemove: handleRemoveFile
|
|
147
|
-
});
|
|
148
|
-
return /* @__PURE__ */jsx(Stack, {
|
|
149
|
-
sx: {
|
|
150
|
-
gap: 1,
|
|
151
|
-
width: "100%"
|
|
152
|
-
},
|
|
153
|
-
children: uploadedFiles.map((file, index) => {
|
|
154
|
-
return /* @__PURE__ */jsxs(Flex, {
|
|
155
|
-
sx: {
|
|
156
|
-
width: "full",
|
|
157
|
-
alignItems: "center",
|
|
158
|
-
justifyContent: "space-between",
|
|
159
|
-
p: 2,
|
|
160
|
-
backgroundColor: "display.background.secondary.default",
|
|
161
|
-
borderRadius: "md",
|
|
162
|
-
gap: 2
|
|
163
|
-
},
|
|
164
|
-
children: [/* @__PURE__ */jsxs(Flex, {
|
|
165
|
-
sx: {
|
|
166
|
-
alignItems: "center",
|
|
167
|
-
gap: 2,
|
|
168
|
-
flex: 1
|
|
169
|
-
},
|
|
170
|
-
children: [file.imageUrl && /* @__PURE__ */jsx(Box, {
|
|
171
|
-
sx: {
|
|
172
|
-
width: 32,
|
|
173
|
-
height: 32
|
|
174
|
-
},
|
|
175
|
-
children: /* @__PURE__ */jsx("img", {
|
|
176
|
-
src: file.imageUrl,
|
|
177
|
-
alt: file.name,
|
|
178
|
-
style: {
|
|
179
|
-
width: "100%",
|
|
180
|
-
height: "100%",
|
|
181
|
-
objectFit: "cover",
|
|
182
|
-
borderRadius: 4
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
}), /* @__PURE__ */jsx(Box, {
|
|
186
|
-
sx: {
|
|
187
|
-
flex: 1
|
|
188
|
-
},
|
|
189
|
-
children: /* @__PURE__ */jsx("a", {
|
|
190
|
-
href: file.url,
|
|
191
|
-
target: "_blank",
|
|
192
|
-
rel: "noopener noreferrer",
|
|
193
|
-
style: {
|
|
194
|
-
textDecoration: "none",
|
|
195
|
-
color: "inherit"
|
|
196
|
-
},
|
|
197
|
-
children: /* @__PURE__ */jsx(Text, {
|
|
198
|
-
variant: "body",
|
|
199
|
-
sx: {
|
|
200
|
-
fontWeight: "medium",
|
|
201
|
-
"&:hover": {
|
|
202
|
-
textDecoration: "underline",
|
|
203
|
-
color: "primary.default"
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
children: file.name
|
|
207
|
-
})
|
|
208
|
-
})
|
|
209
|
-
})]
|
|
210
|
-
}), /* @__PURE__ */jsx(Button, {
|
|
211
|
-
variant: "destructive",
|
|
212
|
-
onClick: () => {
|
|
213
|
-
return handleRemoveFile(index);
|
|
214
|
-
},
|
|
215
|
-
sx: {
|
|
216
|
-
fontSize: "sm",
|
|
217
|
-
color: "text.muted",
|
|
218
|
-
"&:hover": {
|
|
219
|
-
color: "error.default"
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
children: intl.formatMessage({
|
|
223
|
-
id: "G/yZLu",
|
|
224
|
-
defaultMessage: [{
|
|
225
|
-
"type": 0,
|
|
226
|
-
"value": "Remove"
|
|
227
|
-
}]
|
|
228
|
-
})
|
|
229
|
-
})]
|
|
230
|
-
}, file.id);
|
|
231
|
-
})
|
|
232
|
-
});
|
|
233
|
-
}, [files.length, uploadedFiles, handleRemoveFile, intl, showFileList, FileListComponent]);
|
|
234
|
-
const placeholderTexts = React.useMemo(() => {
|
|
235
|
-
const texts = [];
|
|
236
|
-
if (isUploading) texts.push(intl.formatMessage({
|
|
237
|
-
id: "JEsxDw",
|
|
238
|
-
defaultMessage: [{
|
|
239
|
-
"type": 0,
|
|
240
|
-
"value": "Uploading..."
|
|
241
|
-
}]
|
|
242
|
-
}));else if (isMaxFilesReached) texts.push(intl.formatMessage({
|
|
243
|
-
id: "eRShvB",
|
|
244
|
-
defaultMessage: [{
|
|
245
|
-
"type": 0,
|
|
246
|
-
"value": "Maximum files reached"
|
|
247
|
-
}]
|
|
248
|
-
}));else texts.push(placeholder || intl.formatMessage({
|
|
249
|
-
id: "gy0Ynb",
|
|
250
|
-
defaultMessage: [{
|
|
251
|
-
"type": 0,
|
|
252
|
-
"value": "Click or drag files here"
|
|
253
|
-
}]
|
|
254
|
-
}));
|
|
255
|
-
if (!isUploading && !isMaxFilesReached) {
|
|
256
|
-
if (accept) texts.push(accept);
|
|
257
|
-
if (maxSize) texts.push(`Max ${formatFileSize(maxSize)}`);
|
|
258
|
-
if (multiple && maxFiles) texts.push(intl.formatMessage({
|
|
259
|
-
id: "fOOwej",
|
|
260
|
-
defaultMessage: [{
|
|
261
|
-
"type": 6,
|
|
262
|
-
"value": "max_files",
|
|
263
|
-
"options": {
|
|
264
|
-
"one": {
|
|
265
|
-
"value": [{
|
|
266
|
-
"type": 0,
|
|
267
|
-
"value": "Up to "
|
|
268
|
-
}, {
|
|
269
|
-
"type": 7
|
|
270
|
-
}, {
|
|
271
|
-
"type": 0,
|
|
272
|
-
"value": " file"
|
|
273
|
-
}]
|
|
274
|
-
},
|
|
275
|
-
"other": {
|
|
276
|
-
"value": [{
|
|
277
|
-
"type": 0,
|
|
278
|
-
"value": "Up to "
|
|
279
|
-
}, {
|
|
280
|
-
"type": 7
|
|
281
|
-
}, {
|
|
282
|
-
"type": 0,
|
|
283
|
-
"value": " files"
|
|
284
|
-
}]
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
"offset": 0,
|
|
288
|
-
"pluralType": "cardinal"
|
|
289
|
-
}]
|
|
290
|
-
}, {
|
|
291
|
-
max_files: maxFiles
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
return texts.filter(Boolean).join(" • ");
|
|
295
|
-
}, [isUploading, isMaxFilesReached, intl, placeholder, accept, maxSize, multiple, maxFiles]);
|
|
296
|
-
return /* @__PURE__ */jsxs(Stack, {
|
|
297
|
-
sx: {
|
|
298
|
-
gap: 3,
|
|
299
|
-
justifyContent: "stretch",
|
|
300
|
-
width: "100%"
|
|
301
|
-
},
|
|
302
|
-
children: [/* @__PURE__ */jsxs(Box, {
|
|
303
|
-
onDrop: handleDrop,
|
|
304
|
-
onDragOver: handleDragOver,
|
|
305
|
-
onDragLeave: handleDragLeave,
|
|
306
|
-
onClick: handleClick,
|
|
307
|
-
sx: {
|
|
308
|
-
width: "100%",
|
|
309
|
-
border: "2px dashed",
|
|
310
|
-
borderColor: error ? "error.default" : isDragOver ? "primary.default" : "display.border.muted.default",
|
|
311
|
-
borderRadius: "xl",
|
|
312
|
-
padding: 6,
|
|
313
|
-
textAlign: "center",
|
|
314
|
-
cursor: disabled || isUploading || isMaxFilesReached ? "not-allowed" : "pointer",
|
|
315
|
-
backgroundColor: isDragOver ? "primary.muted" : "display.background.secondary.default",
|
|
316
|
-
transition: "all 0.2s ease",
|
|
317
|
-
opacity: disabled || isMaxFilesReached ? .6 : 1,
|
|
318
|
-
"&:hover": {
|
|
319
|
-
borderColor: !disabled && !isUploading && !error && !isMaxFilesReached ? "primary.default" : void 0,
|
|
320
|
-
backgroundColor: !disabled && !isUploading && !isMaxFilesReached ? "primary.muted" : void 0
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
children: [/* @__PURE__ */jsx("input", {
|
|
324
|
-
ref: fileInputRef,
|
|
325
|
-
type: "file",
|
|
326
|
-
accept,
|
|
327
|
-
multiple,
|
|
328
|
-
onChange: handleFileChange,
|
|
329
|
-
disabled: disabled || isUploading || isMaxFilesReached,
|
|
330
|
-
style: {
|
|
331
|
-
display: "none"
|
|
332
|
-
}
|
|
333
|
-
}), children || /* @__PURE__ */jsxs(Flex, {
|
|
334
|
-
sx: {
|
|
335
|
-
flexDirection: "column",
|
|
336
|
-
alignItems: "center",
|
|
337
|
-
gap: 3,
|
|
338
|
-
justifyContent: "center"
|
|
339
|
-
},
|
|
340
|
-
children: [/* @__PURE__ */jsx(Text, {
|
|
341
|
-
sx: {
|
|
342
|
-
fontSize: "2xl"
|
|
343
|
-
},
|
|
344
|
-
children: intl.formatMessage({
|
|
345
|
-
id: "XKyo5X",
|
|
346
|
-
defaultMessage: [{
|
|
347
|
-
"type": 0,
|
|
348
|
-
"value": "File Upload"
|
|
349
|
-
}]
|
|
350
|
-
})
|
|
351
|
-
}), /* @__PURE__ */jsx(Box, {
|
|
352
|
-
sx: {
|
|
353
|
-
textAlign: "center"
|
|
354
|
-
},
|
|
355
|
-
children: /* @__PURE__ */jsx(Text, {
|
|
356
|
-
variant: "body",
|
|
357
|
-
sx: {
|
|
358
|
-
color: "text.default",
|
|
359
|
-
mb: 1
|
|
360
|
-
},
|
|
361
|
-
children: placeholderTexts
|
|
362
|
-
})
|
|
363
|
-
}), !isUploading && !isMaxFilesReached && /* @__PURE__ */jsx(Button, {
|
|
364
|
-
variant: "secondary",
|
|
365
|
-
disabled,
|
|
366
|
-
children: intl.formatMessage({
|
|
367
|
-
id: "fDCMA6",
|
|
368
|
-
defaultMessage: [{
|
|
369
|
-
"type": 0,
|
|
370
|
-
"value": "Select Files"
|
|
371
|
-
}]
|
|
372
|
-
})
|
|
373
|
-
})]
|
|
374
|
-
})]
|
|
375
|
-
}), error && /* @__PURE__ */jsx(Text, {
|
|
376
|
-
variant: "caption",
|
|
377
|
-
sx: {
|
|
378
|
-
color: "error.default"
|
|
379
|
-
},
|
|
380
|
-
children: error
|
|
381
|
-
}), fileListNode]
|
|
382
|
-
});
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
//#endregion
|
|
386
|
-
export { FileUploader };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/components/InstallPwa/InstallPwa.d.ts
|
|
5
|
-
type InstallPwaUiProps = {
|
|
6
|
-
onInstall: React.MouseEventHandler<HTMLButtonElement>;
|
|
7
|
-
};
|
|
8
|
-
declare const InstallPwaUi: ({
|
|
9
|
-
onInstall
|
|
10
|
-
}: InstallPwaUiProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
declare const InstallPwa: () => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { InstallPwa, InstallPwaUi, InstallPwaUiProps };
|