@spark-ui/components 11.3.1 → 11.4.0
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/docgen.json
CHANGED
|
@@ -31996,6 +31996,207 @@
|
|
|
31996
31996
|
"methods": [],
|
|
31997
31997
|
"props": {}
|
|
31998
31998
|
},
|
|
31999
|
+
"getFileIcon": {
|
|
32000
|
+
"tags": {
|
|
32001
|
+
"param": "file - The file to get the icon for",
|
|
32002
|
+
"returns": "React element representing the icon component"
|
|
32003
|
+
},
|
|
32004
|
+
"description": "Returns the appropriate icon component based on the file type",
|
|
32005
|
+
"displayName": "getFileIcon",
|
|
32006
|
+
"methods": [],
|
|
32007
|
+
"props": {
|
|
32008
|
+
"lastModified": {
|
|
32009
|
+
"defaultValue": null,
|
|
32010
|
+
"description": "The **`lastModified`** read-only property of the File interface provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight).\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)",
|
|
32011
|
+
"name": "lastModified",
|
|
32012
|
+
"parent": {
|
|
32013
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32014
|
+
"name": "File"
|
|
32015
|
+
},
|
|
32016
|
+
"declarations": [
|
|
32017
|
+
{
|
|
32018
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32019
|
+
"name": "File"
|
|
32020
|
+
}
|
|
32021
|
+
],
|
|
32022
|
+
"required": true,
|
|
32023
|
+
"type": {
|
|
32024
|
+
"name": "number"
|
|
32025
|
+
}
|
|
32026
|
+
},
|
|
32027
|
+
"name": {
|
|
32028
|
+
"defaultValue": null,
|
|
32029
|
+
"description": "The **`name`** read-only property of the File interface returns the name of the file represented by a File object.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)",
|
|
32030
|
+
"name": "name",
|
|
32031
|
+
"parent": {
|
|
32032
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32033
|
+
"name": "File"
|
|
32034
|
+
},
|
|
32035
|
+
"declarations": [
|
|
32036
|
+
{
|
|
32037
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32038
|
+
"name": "File"
|
|
32039
|
+
}
|
|
32040
|
+
],
|
|
32041
|
+
"required": true,
|
|
32042
|
+
"type": {
|
|
32043
|
+
"name": "string"
|
|
32044
|
+
}
|
|
32045
|
+
},
|
|
32046
|
+
"webkitRelativePath": {
|
|
32047
|
+
"defaultValue": null,
|
|
32048
|
+
"description": "The **`webkitRelativePath`** read-only property of the File interface contains a string which specifies the file's path relative to the directory selected by the user in an input element with its `webkitdirectory` attribute set.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/File/webkitRelativePath)",
|
|
32049
|
+
"name": "webkitRelativePath",
|
|
32050
|
+
"parent": {
|
|
32051
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32052
|
+
"name": "File"
|
|
32053
|
+
},
|
|
32054
|
+
"declarations": [
|
|
32055
|
+
{
|
|
32056
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32057
|
+
"name": "File"
|
|
32058
|
+
}
|
|
32059
|
+
],
|
|
32060
|
+
"required": true,
|
|
32061
|
+
"type": {
|
|
32062
|
+
"name": "string"
|
|
32063
|
+
}
|
|
32064
|
+
},
|
|
32065
|
+
"size": {
|
|
32066
|
+
"defaultValue": null,
|
|
32067
|
+
"description": "The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)",
|
|
32068
|
+
"name": "size",
|
|
32069
|
+
"parent": {
|
|
32070
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32071
|
+
"name": "Blob"
|
|
32072
|
+
},
|
|
32073
|
+
"declarations": [
|
|
32074
|
+
{
|
|
32075
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32076
|
+
"name": "Blob"
|
|
32077
|
+
}
|
|
32078
|
+
],
|
|
32079
|
+
"required": true,
|
|
32080
|
+
"type": {
|
|
32081
|
+
"name": "number"
|
|
32082
|
+
}
|
|
32083
|
+
},
|
|
32084
|
+
"type": {
|
|
32085
|
+
"defaultValue": null,
|
|
32086
|
+
"description": "The **`type`** read-only property of the Blob interface returns the MIME type of the file.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)",
|
|
32087
|
+
"name": "type",
|
|
32088
|
+
"parent": {
|
|
32089
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32090
|
+
"name": "Blob"
|
|
32091
|
+
},
|
|
32092
|
+
"declarations": [
|
|
32093
|
+
{
|
|
32094
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32095
|
+
"name": "Blob"
|
|
32096
|
+
}
|
|
32097
|
+
],
|
|
32098
|
+
"required": true,
|
|
32099
|
+
"type": {
|
|
32100
|
+
"name": "string"
|
|
32101
|
+
}
|
|
32102
|
+
},
|
|
32103
|
+
"arrayBuffer": {
|
|
32104
|
+
"defaultValue": null,
|
|
32105
|
+
"description": "The **`arrayBuffer()`** method of the Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)",
|
|
32106
|
+
"name": "arrayBuffer",
|
|
32107
|
+
"parent": {
|
|
32108
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32109
|
+
"name": "Blob"
|
|
32110
|
+
},
|
|
32111
|
+
"declarations": [
|
|
32112
|
+
{
|
|
32113
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32114
|
+
"name": "Blob"
|
|
32115
|
+
}
|
|
32116
|
+
],
|
|
32117
|
+
"required": true,
|
|
32118
|
+
"type": {
|
|
32119
|
+
"name": "() => Promise<ArrayBuffer>"
|
|
32120
|
+
}
|
|
32121
|
+
},
|
|
32122
|
+
"bytes": {
|
|
32123
|
+
"defaultValue": null,
|
|
32124
|
+
"description": "The **`bytes()`** method of the Blob interface returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)",
|
|
32125
|
+
"name": "bytes",
|
|
32126
|
+
"parent": {
|
|
32127
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32128
|
+
"name": "Blob"
|
|
32129
|
+
},
|
|
32130
|
+
"declarations": [
|
|
32131
|
+
{
|
|
32132
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32133
|
+
"name": "Blob"
|
|
32134
|
+
}
|
|
32135
|
+
],
|
|
32136
|
+
"required": true,
|
|
32137
|
+
"type": {
|
|
32138
|
+
"name": "() => Promise<Uint8Array<ArrayBuffer>>"
|
|
32139
|
+
}
|
|
32140
|
+
},
|
|
32141
|
+
"slice": {
|
|
32142
|
+
"defaultValue": null,
|
|
32143
|
+
"description": "The **`slice()`** method of the Blob interface creates and returns a new `Blob` object which contains data from a subset of the blob on which it's called.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)",
|
|
32144
|
+
"name": "slice",
|
|
32145
|
+
"parent": {
|
|
32146
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32147
|
+
"name": "Blob"
|
|
32148
|
+
},
|
|
32149
|
+
"declarations": [
|
|
32150
|
+
{
|
|
32151
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32152
|
+
"name": "Blob"
|
|
32153
|
+
}
|
|
32154
|
+
],
|
|
32155
|
+
"required": true,
|
|
32156
|
+
"type": {
|
|
32157
|
+
"name": "(start?: number, end?: number, contentType?: string) => Blob"
|
|
32158
|
+
}
|
|
32159
|
+
},
|
|
32160
|
+
"stream": {
|
|
32161
|
+
"defaultValue": null,
|
|
32162
|
+
"description": "The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)",
|
|
32163
|
+
"name": "stream",
|
|
32164
|
+
"parent": {
|
|
32165
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32166
|
+
"name": "Blob"
|
|
32167
|
+
},
|
|
32168
|
+
"declarations": [
|
|
32169
|
+
{
|
|
32170
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32171
|
+
"name": "Blob"
|
|
32172
|
+
}
|
|
32173
|
+
],
|
|
32174
|
+
"required": true,
|
|
32175
|
+
"type": {
|
|
32176
|
+
"name": "() => ReadableStream<Uint8Array<ArrayBuffer>>"
|
|
32177
|
+
}
|
|
32178
|
+
},
|
|
32179
|
+
"text": {
|
|
32180
|
+
"defaultValue": null,
|
|
32181
|
+
"description": "The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.\n\n[MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)",
|
|
32182
|
+
"name": "text",
|
|
32183
|
+
"parent": {
|
|
32184
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32185
|
+
"name": "Blob"
|
|
32186
|
+
},
|
|
32187
|
+
"declarations": [
|
|
32188
|
+
{
|
|
32189
|
+
"fileName": "spark-web/node_modules/typescript/lib/lib.dom.d.ts",
|
|
32190
|
+
"name": "Blob"
|
|
32191
|
+
}
|
|
32192
|
+
],
|
|
32193
|
+
"required": true,
|
|
32194
|
+
"type": {
|
|
32195
|
+
"name": "() => Promise<string>"
|
|
32196
|
+
}
|
|
32197
|
+
}
|
|
32198
|
+
}
|
|
32199
|
+
},
|
|
31999
32200
|
"FormField": {
|
|
32000
32201
|
"tags": {},
|
|
32001
32202
|
"description": "",
|
|
@@ -26,9 +26,14 @@ module.exports = __toCommonJS(file_upload_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/file-upload/FileUpload.tsx
|
|
28
28
|
var import_use_combined_state = require("@spark-ui/hooks/use-combined-state");
|
|
29
|
-
var
|
|
29
|
+
var import_react2 = require("react");
|
|
30
30
|
|
|
31
31
|
// src/file-upload/utils.ts
|
|
32
|
+
var import_CvOutline = require("@spark-ui/icons/CvOutline");
|
|
33
|
+
var import_FilePdfOutline = require("@spark-ui/icons/FilePdfOutline");
|
|
34
|
+
var import_ImageOutline = require("@spark-ui/icons/ImageOutline");
|
|
35
|
+
var import_PlayOutline = require("@spark-ui/icons/PlayOutline");
|
|
36
|
+
var import_react = require("react");
|
|
32
37
|
function validateFileAccept(file, accept) {
|
|
33
38
|
if (!accept) {
|
|
34
39
|
return true;
|
|
@@ -107,10 +112,24 @@ function formatFileSize(bytes, locale) {
|
|
|
107
112
|
});
|
|
108
113
|
return formatter.format(size);
|
|
109
114
|
}
|
|
115
|
+
function getFileIcon(file) {
|
|
116
|
+
const fileType = file.type.toLowerCase();
|
|
117
|
+
const fileName = file.name.toLowerCase();
|
|
118
|
+
if (fileType.startsWith("image/") || /\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(fileName)) {
|
|
119
|
+
return (0, import_react.createElement)(import_ImageOutline.ImageOutline);
|
|
120
|
+
}
|
|
121
|
+
if (fileType === "application/pdf" || fileName.endsWith(".pdf")) {
|
|
122
|
+
return (0, import_react.createElement)(import_FilePdfOutline.FilePdfOutline);
|
|
123
|
+
}
|
|
124
|
+
if (fileType.startsWith("video/") || /\.(mp4|avi|mov|wmv|flv|webm|mkv)$/i.test(fileName)) {
|
|
125
|
+
return (0, import_react.createElement)(import_PlayOutline.PlayOutline);
|
|
126
|
+
}
|
|
127
|
+
return (0, import_react.createElement)(import_CvOutline.CvOutline);
|
|
128
|
+
}
|
|
110
129
|
|
|
111
130
|
// src/file-upload/FileUpload.tsx
|
|
112
131
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
113
|
-
var FileUploadContext = (0,
|
|
132
|
+
var FileUploadContext = (0, import_react2.createContext)(null);
|
|
114
133
|
var FileUpload = ({
|
|
115
134
|
asChild: _asChild = false,
|
|
116
135
|
children,
|
|
@@ -129,10 +148,10 @@ var FileUpload = ({
|
|
|
129
148
|
locale
|
|
130
149
|
}) => {
|
|
131
150
|
const defaultLocale = locale || (typeof navigator !== "undefined" && navigator.language ? navigator.language : "en");
|
|
132
|
-
const inputRef = (0,
|
|
133
|
-
const triggerRef = (0,
|
|
134
|
-
const dropzoneRef = (0,
|
|
135
|
-
const deleteButtonRefs = (0,
|
|
151
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
152
|
+
const triggerRef = (0, import_react2.useRef)(null);
|
|
153
|
+
const dropzoneRef = (0, import_react2.useRef)(null);
|
|
154
|
+
const deleteButtonRefs = (0, import_react2.useRef)([]);
|
|
136
155
|
const [filesState, setFilesState, ,] = (0, import_use_combined_state.useCombinedState)(
|
|
137
156
|
controlledValue,
|
|
138
157
|
defaultValue,
|
|
@@ -140,7 +159,7 @@ var FileUpload = ({
|
|
|
140
159
|
);
|
|
141
160
|
const files = filesState ?? [];
|
|
142
161
|
const setFiles = setFilesState;
|
|
143
|
-
const [rejectedFiles, setRejectedFiles] = (0,
|
|
162
|
+
const [rejectedFiles, setRejectedFiles] = (0, import_react2.useState)([]);
|
|
144
163
|
const addFiles = (newFiles) => {
|
|
145
164
|
if (disabled || readOnly) {
|
|
146
165
|
return;
|
|
@@ -335,22 +354,19 @@ var FileUpload = ({
|
|
|
335
354
|
};
|
|
336
355
|
FileUpload.displayName = "FileUpload";
|
|
337
356
|
var useFileUploadContext = () => {
|
|
338
|
-
const context = (0,
|
|
357
|
+
const context = (0, import_react2.useContext)(FileUploadContext);
|
|
339
358
|
if (!context) {
|
|
340
359
|
throw Error("useFileUploadContext must be used within a FileUpload provider");
|
|
341
360
|
}
|
|
342
361
|
return context;
|
|
343
362
|
};
|
|
344
363
|
|
|
345
|
-
// src/file-upload/FileUploadAcceptedFile.tsx
|
|
346
|
-
var import_CvOutline = require("@spark-ui/icons/CvOutline");
|
|
347
|
-
|
|
348
364
|
// src/icon/Icon.tsx
|
|
349
|
-
var
|
|
365
|
+
var import_react4 = require("react");
|
|
350
366
|
|
|
351
367
|
// src/slot/Slot.tsx
|
|
352
368
|
var import_radix_ui = require("radix-ui");
|
|
353
|
-
var
|
|
369
|
+
var import_react3 = require("react");
|
|
354
370
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
355
371
|
var Slottable = import_radix_ui.Slot.Slottable;
|
|
356
372
|
var Slot = ({ ref, ...props }) => {
|
|
@@ -358,7 +374,7 @@ var Slot = ({ ref, ...props }) => {
|
|
|
358
374
|
};
|
|
359
375
|
var wrapPolymorphicSlot = (asChild, children, callback) => {
|
|
360
376
|
if (!asChild) return callback(children);
|
|
361
|
-
return (0,
|
|
377
|
+
return (0, import_react3.isValidElement)(children) ? (0, import_react3.cloneElement)(
|
|
362
378
|
children,
|
|
363
379
|
void 0,
|
|
364
380
|
callback(children.props.children)
|
|
@@ -436,9 +452,9 @@ var Icon = ({
|
|
|
436
452
|
children,
|
|
437
453
|
...others
|
|
438
454
|
}) => {
|
|
439
|
-
const child =
|
|
455
|
+
const child = import_react4.Children.only(children);
|
|
440
456
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
441
|
-
(0,
|
|
457
|
+
(0, import_react4.cloneElement)(child, {
|
|
442
458
|
className: iconStyles({ className, size, intent }),
|
|
443
459
|
"data-spark-component": "icon",
|
|
444
460
|
"aria-hidden": "true",
|
|
@@ -453,7 +469,7 @@ Icon.displayName = "Icon";
|
|
|
453
469
|
// src/progress/Progress.tsx
|
|
454
470
|
var import_class_variance_authority4 = require("class-variance-authority");
|
|
455
471
|
var import_radix_ui3 = require("radix-ui");
|
|
456
|
-
var
|
|
472
|
+
var import_react6 = require("react");
|
|
457
473
|
|
|
458
474
|
// src/progress/ProgressBar.styles.ts
|
|
459
475
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
@@ -470,11 +486,11 @@ var progressBarStyles = (0, import_class_variance_authority2.cva)(
|
|
|
470
486
|
);
|
|
471
487
|
|
|
472
488
|
// src/progress/ProgressContext.tsx
|
|
473
|
-
var
|
|
474
|
-
var ProgressContext = (0,
|
|
489
|
+
var import_react5 = require("react");
|
|
490
|
+
var ProgressContext = (0, import_react5.createContext)(null);
|
|
475
491
|
var ID_PREFIX = ":progress";
|
|
476
492
|
var useProgress = () => {
|
|
477
|
-
const context = (0,
|
|
493
|
+
const context = (0, import_react5.useContext)(ProgressContext);
|
|
478
494
|
if (!context) {
|
|
479
495
|
throw new Error("useProgress must be used within a Progress provider");
|
|
480
496
|
}
|
|
@@ -577,8 +593,8 @@ var Progress = ({
|
|
|
577
593
|
ref,
|
|
578
594
|
...others
|
|
579
595
|
}) => {
|
|
580
|
-
const [labelId, setLabelId] = (0,
|
|
581
|
-
const value = (0,
|
|
596
|
+
const [labelId, setLabelId] = (0, import_react6.useState)();
|
|
597
|
+
const value = (0, import_react6.useMemo)(() => {
|
|
582
598
|
return { value: valueProp ?? 0, max, intent, shape, isIndeterminate, onLabelId: setLabelId };
|
|
583
599
|
}, [max, valueProp, intent, shape, isIndeterminate, setLabelId]);
|
|
584
600
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ProgressContext.Provider, { "data-spark-component": "progress", value, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -600,7 +616,7 @@ Progress.displayName = "Progress";
|
|
|
600
616
|
|
|
601
617
|
// src/progress/ProgressLabel.tsx
|
|
602
618
|
var import_use_merge_refs = require("@spark-ui/hooks/use-merge-refs");
|
|
603
|
-
var
|
|
619
|
+
var import_react7 = require("react");
|
|
604
620
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
605
621
|
var ProgressLabel = ({
|
|
606
622
|
id: idProp,
|
|
@@ -608,10 +624,10 @@ var ProgressLabel = ({
|
|
|
608
624
|
ref: forwardedRef,
|
|
609
625
|
...others
|
|
610
626
|
}) => {
|
|
611
|
-
const internalID = `${ID_PREFIX}-label-${(0,
|
|
627
|
+
const internalID = `${ID_PREFIX}-label-${(0, import_react7.useId)()}`;
|
|
612
628
|
const id = idProp || internalID;
|
|
613
629
|
const { onLabelId } = useProgress();
|
|
614
|
-
const rootRef = (0,
|
|
630
|
+
const rootRef = (0, import_react7.useCallback)(
|
|
615
631
|
(el) => {
|
|
616
632
|
onLabelId(el ? id : void 0);
|
|
617
633
|
},
|
|
@@ -672,11 +688,11 @@ Item.displayName = "FileUpload.Item";
|
|
|
672
688
|
// src/file-upload/FileUploadItemDeleteTrigger.tsx
|
|
673
689
|
var import_Close = require("@spark-ui/icons/Close");
|
|
674
690
|
var import_class_variance_authority10 = require("class-variance-authority");
|
|
675
|
-
var
|
|
691
|
+
var import_react9 = require("react");
|
|
676
692
|
|
|
677
693
|
// src/button/Button.tsx
|
|
678
694
|
var import_class_variance_authority8 = require("class-variance-authority");
|
|
679
|
-
var
|
|
695
|
+
var import_react8 = require("react");
|
|
680
696
|
|
|
681
697
|
// src/spinner/Spinner.styles.tsx
|
|
682
698
|
var import_internal_utils2 = require("@spark-ui/internal-utils");
|
|
@@ -1481,7 +1497,7 @@ var Button = ({
|
|
|
1481
1497
|
}) => {
|
|
1482
1498
|
const Component = asChild ? Slot : "button";
|
|
1483
1499
|
const shouldNotInteract = !!disabled || isLoading;
|
|
1484
|
-
const disabledEventHandlers = (0,
|
|
1500
|
+
const disabledEventHandlers = (0, import_react8.useMemo)(() => {
|
|
1485
1501
|
const result = {};
|
|
1486
1502
|
if (shouldNotInteract) {
|
|
1487
1503
|
blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
|
|
@@ -1588,7 +1604,7 @@ var ItemDeleteTrigger = ({
|
|
|
1588
1604
|
...props
|
|
1589
1605
|
}) => {
|
|
1590
1606
|
const { removeFile, triggerRef, dropzoneRef, deleteButtonRefs, disabled, readOnly } = useFileUploadContext();
|
|
1591
|
-
const buttonRef = (0,
|
|
1607
|
+
const buttonRef = (0, import_react9.useRef)(null);
|
|
1592
1608
|
const handleClick = (e) => {
|
|
1593
1609
|
if (disabled || readOnly) {
|
|
1594
1610
|
return;
|
|
@@ -1696,7 +1712,7 @@ var AcceptedFile = ({
|
|
|
1696
1712
|
}) => {
|
|
1697
1713
|
const { locale } = useFileUploadContext();
|
|
1698
1714
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Item, { className, ...props, children: [
|
|
1699
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "size-sz-40 bg-support-container flex items-center justify-center rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { size: "md", children:
|
|
1715
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "size-sz-40 bg-support-container flex items-center justify-center rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { size: "md", children: getFileIcon(file) }) }),
|
|
1700
1716
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
1701
1717
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "gap-md flex flex-row items-center justify-between", children: [
|
|
1702
1718
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ItemFileName, { children: file.name }),
|
|
@@ -1731,7 +1747,7 @@ Context.displayName = "FileUpload.Context";
|
|
|
1731
1747
|
|
|
1732
1748
|
// src/file-upload/FileUploadDropzone.tsx
|
|
1733
1749
|
var import_class_variance_authority13 = require("class-variance-authority");
|
|
1734
|
-
var
|
|
1750
|
+
var import_react10 = require("react");
|
|
1735
1751
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1736
1752
|
function Dropzone({
|
|
1737
1753
|
children,
|
|
@@ -1740,7 +1756,7 @@ function Dropzone({
|
|
|
1740
1756
|
unstyled = false
|
|
1741
1757
|
}) {
|
|
1742
1758
|
const ctx = useFileUploadContext();
|
|
1743
|
-
const dropzoneRef = (0,
|
|
1759
|
+
const dropzoneRef = (0, import_react10.useRef)(null);
|
|
1744
1760
|
if (!ctx) throw new Error("FileUploadDropzone must be used inside <FileUpload>");
|
|
1745
1761
|
const handleDrop = (e) => {
|
|
1746
1762
|
e.preventDefault();
|
|
@@ -1820,7 +1836,7 @@ Dropzone.displayName = "FileUploadDropzone";
|
|
|
1820
1836
|
|
|
1821
1837
|
// src/file-upload/FileUploadPreviewImage.tsx
|
|
1822
1838
|
var import_class_variance_authority14 = require("class-variance-authority");
|
|
1823
|
-
var
|
|
1839
|
+
var import_react11 = require("react");
|
|
1824
1840
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1825
1841
|
var PreviewImage = ({
|
|
1826
1842
|
asChild: _asChild = false,
|
|
@@ -1829,11 +1845,11 @@ var PreviewImage = ({
|
|
|
1829
1845
|
fallback = "\u{1F4C4}",
|
|
1830
1846
|
...props
|
|
1831
1847
|
}) => {
|
|
1832
|
-
const [imageError, setImageError] = (0,
|
|
1833
|
-
const [imageLoaded, setImageLoaded] = (0,
|
|
1848
|
+
const [imageError, setImageError] = (0, import_react11.useState)(false);
|
|
1849
|
+
const [imageLoaded, setImageLoaded] = (0, import_react11.useState)(false);
|
|
1834
1850
|
const isImage = file.type.startsWith("image/");
|
|
1835
1851
|
const imageUrl = isImage ? URL.createObjectURL(file) : null;
|
|
1836
|
-
(0,
|
|
1852
|
+
(0, import_react11.useEffect)(() => {
|
|
1837
1853
|
return () => {
|
|
1838
1854
|
if (imageUrl) {
|
|
1839
1855
|
URL.revokeObjectURL(imageUrl);
|
|
@@ -1885,7 +1901,7 @@ var import_class_variance_authority16 = require("class-variance-authority");
|
|
|
1885
1901
|
// src/file-upload/FileUploadRejectedFileDeleteTrigger.tsx
|
|
1886
1902
|
var import_Close2 = require("@spark-ui/icons/Close");
|
|
1887
1903
|
var import_class_variance_authority15 = require("class-variance-authority");
|
|
1888
|
-
var
|
|
1904
|
+
var import_react12 = require("react");
|
|
1889
1905
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1890
1906
|
var RejectedFileDeleteTrigger = ({
|
|
1891
1907
|
className,
|
|
@@ -1894,7 +1910,7 @@ var RejectedFileDeleteTrigger = ({
|
|
|
1894
1910
|
...props
|
|
1895
1911
|
}) => {
|
|
1896
1912
|
const { removeRejectedFile, triggerRef, dropzoneRef, disabled, readOnly } = useFileUploadContext();
|
|
1897
|
-
const buttonRef = (0,
|
|
1913
|
+
const buttonRef = (0, import_react12.useRef)(null);
|
|
1898
1914
|
const handleClick = (e) => {
|
|
1899
1915
|
if (disabled || readOnly) {
|
|
1900
1916
|
return;
|