@spark-ui/components 11.2.4 → 11.3.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/alert-dialog/index.mjs +1 -1
- package/dist/avatar/index.mjs +2 -2
- package/dist/carousel/index.mjs +2 -2
- package/dist/chunk-TKAU6SMC.mjs +197 -0
- package/dist/chunk-TKAU6SMC.mjs.map +1 -0
- package/dist/combobox/index.mjs +3 -3
- package/dist/dialog/index.mjs +1 -1
- package/dist/docgen.json +1800 -6
- package/dist/drawer/index.mjs +2 -2
- package/dist/dropdown/index.mjs +2 -2
- package/dist/file-upload/index.d.mts +283 -0
- package/dist/file-upload/index.d.ts +283 -0
- package/dist/file-upload/index.js +2042 -0
- package/dist/file-upload/index.js.map +1 -0
- package/dist/file-upload/index.mjs +828 -0
- package/dist/file-upload/index.mjs.map +1 -0
- package/dist/pagination/index.mjs +3 -3
- package/dist/popover/index.mjs +1 -1
- package/dist/progress/index.d.mts +2 -2
- package/dist/progress/index.d.ts +2 -2
- package/dist/progress/index.mjs +4 -193
- package/dist/progress/index.mjs.map +1 -1
- package/dist/scrolling-list/index.mjs +3 -3
- package/dist/snackbar/index.mjs +3 -3
- package/dist/stepper/index.mjs +2 -2
- package/dist/tabs/index.mjs +3 -3
- package/dist/toast/index.mjs +3 -3
- package/package.json +5 -5
|
@@ -0,0 +1,2042 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/file-upload/index.ts
|
|
21
|
+
var file_upload_exports = {};
|
|
22
|
+
__export(file_upload_exports, {
|
|
23
|
+
FileUpload: () => FileUpload2
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(file_upload_exports);
|
|
26
|
+
|
|
27
|
+
// src/file-upload/FileUpload.tsx
|
|
28
|
+
var import_use_combined_state = require("@spark-ui/hooks/use-combined-state");
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
|
|
31
|
+
// src/file-upload/utils.ts
|
|
32
|
+
function validateFileAccept(file, accept) {
|
|
33
|
+
if (!accept) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
const patterns = accept.split(",").map((pattern) => pattern.trim());
|
|
37
|
+
return patterns.some((pattern) => {
|
|
38
|
+
if (pattern.includes("/")) {
|
|
39
|
+
if (pattern.endsWith("/*")) {
|
|
40
|
+
const baseType = pattern.slice(0, -2);
|
|
41
|
+
return file.type.startsWith(baseType + "/");
|
|
42
|
+
}
|
|
43
|
+
return file.type === pattern;
|
|
44
|
+
}
|
|
45
|
+
if (pattern.startsWith(".")) {
|
|
46
|
+
const extension2 = pattern.toLowerCase();
|
|
47
|
+
const fileName2 = file.name.toLowerCase();
|
|
48
|
+
return fileName2.endsWith(extension2);
|
|
49
|
+
}
|
|
50
|
+
const extension = "." + pattern.toLowerCase();
|
|
51
|
+
const fileName = file.name.toLowerCase();
|
|
52
|
+
return fileName.endsWith(extension);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function validateFileSize(file, minFileSize, maxFileSize, locale) {
|
|
56
|
+
const defaultLocale = locale || getDefaultLocale();
|
|
57
|
+
if (minFileSize !== void 0 && file.size < minFileSize) {
|
|
58
|
+
const errorMessage = `File "${file.name}" is too small. Minimum size is ${formatFileSize(minFileSize, defaultLocale)}.`;
|
|
59
|
+
return {
|
|
60
|
+
valid: false,
|
|
61
|
+
error: errorMessage
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (maxFileSize !== void 0 && file.size > maxFileSize) {
|
|
65
|
+
const errorMessage = `File "${file.name}" is too large. Maximum size is ${formatFileSize(maxFileSize, defaultLocale)}.`;
|
|
66
|
+
return {
|
|
67
|
+
valid: false,
|
|
68
|
+
error: errorMessage
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return { valid: true };
|
|
72
|
+
}
|
|
73
|
+
function getDefaultLocale() {
|
|
74
|
+
if (typeof navigator !== "undefined" && navigator.language) {
|
|
75
|
+
return navigator.language;
|
|
76
|
+
}
|
|
77
|
+
return "en";
|
|
78
|
+
}
|
|
79
|
+
function formatFileSize(bytes, locale) {
|
|
80
|
+
const defaultLocale = locale || getDefaultLocale();
|
|
81
|
+
let normalizedLocale = defaultLocale;
|
|
82
|
+
if (defaultLocale.length === 2) {
|
|
83
|
+
normalizedLocale = defaultLocale === "fr" ? "fr-FR" : "en-US";
|
|
84
|
+
}
|
|
85
|
+
if (bytes === 0) {
|
|
86
|
+
const formatter2 = new Intl.NumberFormat(normalizedLocale, {
|
|
87
|
+
style: "unit",
|
|
88
|
+
unit: "byte",
|
|
89
|
+
unitDisplay: "long",
|
|
90
|
+
minimumFractionDigits: 0,
|
|
91
|
+
maximumFractionDigits: 0
|
|
92
|
+
});
|
|
93
|
+
return formatter2.format(0);
|
|
94
|
+
}
|
|
95
|
+
const k = 1024;
|
|
96
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
97
|
+
const units = ["byte", "kilobyte", "megabyte", "gigabyte"];
|
|
98
|
+
const unit = units[i] || "byte";
|
|
99
|
+
const size = bytes / Math.pow(k, i);
|
|
100
|
+
const unitDisplay = i === 0 ? "long" : "short";
|
|
101
|
+
const formatter = new Intl.NumberFormat(normalizedLocale, {
|
|
102
|
+
style: "unit",
|
|
103
|
+
unit,
|
|
104
|
+
unitDisplay,
|
|
105
|
+
minimumFractionDigits: 0,
|
|
106
|
+
maximumFractionDigits: 2
|
|
107
|
+
});
|
|
108
|
+
return formatter.format(size);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/file-upload/FileUpload.tsx
|
|
112
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
113
|
+
var FileUploadContext = (0, import_react.createContext)(null);
|
|
114
|
+
var FileUpload = ({
|
|
115
|
+
asChild: _asChild = false,
|
|
116
|
+
children,
|
|
117
|
+
defaultValue = [],
|
|
118
|
+
value: controlledValue,
|
|
119
|
+
onFilesChange,
|
|
120
|
+
multiple = true,
|
|
121
|
+
accept,
|
|
122
|
+
maxFiles,
|
|
123
|
+
onMaxFilesReached,
|
|
124
|
+
maxFileSize,
|
|
125
|
+
minFileSize,
|
|
126
|
+
onFileSizeError,
|
|
127
|
+
disabled = false,
|
|
128
|
+
readOnly = false,
|
|
129
|
+
locale
|
|
130
|
+
}) => {
|
|
131
|
+
const defaultLocale = locale || (typeof navigator !== "undefined" && navigator.language ? navigator.language : "en");
|
|
132
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
133
|
+
const triggerRef = (0, import_react.useRef)(null);
|
|
134
|
+
const dropzoneRef = (0, import_react.useRef)(null);
|
|
135
|
+
const deleteButtonRefs = (0, import_react.useRef)([]);
|
|
136
|
+
const [filesState, setFilesState, ,] = (0, import_use_combined_state.useCombinedState)(
|
|
137
|
+
controlledValue,
|
|
138
|
+
defaultValue,
|
|
139
|
+
onFilesChange
|
|
140
|
+
);
|
|
141
|
+
const files = filesState ?? [];
|
|
142
|
+
const setFiles = setFilesState;
|
|
143
|
+
const [rejectedFiles, setRejectedFiles] = (0, import_react.useState)([]);
|
|
144
|
+
const addFiles = (newFiles) => {
|
|
145
|
+
if (disabled || readOnly) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setRejectedFiles([]);
|
|
149
|
+
const newRejectedFiles = [];
|
|
150
|
+
const fileExists = (file, existingFiles) => {
|
|
151
|
+
return existingFiles.some(
|
|
152
|
+
(existingFile) => existingFile.name === file.name && existingFile.size === file.size
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
const addRejectedFile = (file, error) => {
|
|
156
|
+
const existingRejection = newRejectedFiles.find(
|
|
157
|
+
(rejected) => rejected.file.name === file.name && rejected.file.size === file.size
|
|
158
|
+
);
|
|
159
|
+
if (existingRejection) {
|
|
160
|
+
if (!existingRejection.errors.includes(error)) {
|
|
161
|
+
existingRejection.errors.push(error);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
newRejectedFiles.push({
|
|
165
|
+
file,
|
|
166
|
+
errors: [error]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (onFileSizeError) {
|
|
170
|
+
onFileSizeError(file, error);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
setFiles((prev) => {
|
|
174
|
+
const currentFiles = prev ?? [];
|
|
175
|
+
if (maxFiles !== void 0) {
|
|
176
|
+
const currentCount = currentFiles.length;
|
|
177
|
+
const remainingSlots = maxFiles - currentCount;
|
|
178
|
+
if (remainingSlots <= 0) {
|
|
179
|
+
newFiles.forEach((file) => {
|
|
180
|
+
addRejectedFile(file, "TOO_MANY_FILES");
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
let filteredFiles = newFiles;
|
|
185
|
+
if (accept) {
|
|
186
|
+
const rejectedByAccept = newFiles.filter((file) => !validateFileAccept(file, accept));
|
|
187
|
+
rejectedByAccept.forEach((file) => {
|
|
188
|
+
addRejectedFile(file, "FILE_INVALID_TYPE");
|
|
189
|
+
});
|
|
190
|
+
filteredFiles = newFiles.filter((file) => validateFileAccept(file, accept));
|
|
191
|
+
}
|
|
192
|
+
let validSizeFiles = filteredFiles;
|
|
193
|
+
if (minFileSize !== void 0 || maxFileSize !== void 0) {
|
|
194
|
+
validSizeFiles = filteredFiles.filter((file) => {
|
|
195
|
+
const validation = validateFileSize(file, minFileSize, maxFileSize, defaultLocale);
|
|
196
|
+
if (!validation.valid) {
|
|
197
|
+
if (maxFileSize !== void 0 && file.size > maxFileSize) {
|
|
198
|
+
addRejectedFile(file, "FILE_TOO_LARGE");
|
|
199
|
+
} else if (minFileSize !== void 0 && file.size < minFileSize) {
|
|
200
|
+
addRejectedFile(file, "FILE_TOO_SMALL");
|
|
201
|
+
} else {
|
|
202
|
+
addRejectedFile(file, "FILE_INVALID");
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const seenFiles = /* @__PURE__ */ new Map();
|
|
210
|
+
const duplicateFiles = [];
|
|
211
|
+
const uniqueFiles = validSizeFiles.filter((file) => {
|
|
212
|
+
const fileKey = `${file.name}-${file.size}`;
|
|
213
|
+
const existsInPrev = fileExists(file, currentFiles);
|
|
214
|
+
if (existsInPrev) {
|
|
215
|
+
duplicateFiles.push(file);
|
|
216
|
+
addRejectedFile(file, "FILE_EXISTS");
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (seenFiles.has(fileKey)) {
|
|
220
|
+
duplicateFiles.push(file);
|
|
221
|
+
addRejectedFile(file, "FILE_EXISTS");
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
seenFiles.set(fileKey, file);
|
|
225
|
+
return true;
|
|
226
|
+
});
|
|
227
|
+
let filesToAdd = multiple ? uniqueFiles : uniqueFiles.slice(0, 1);
|
|
228
|
+
if (maxFiles !== void 0) {
|
|
229
|
+
const currentCount = currentFiles.length;
|
|
230
|
+
const remainingSlots = maxFiles - currentCount;
|
|
231
|
+
if (remainingSlots <= 0) {
|
|
232
|
+
filesToAdd.forEach((file) => {
|
|
233
|
+
addRejectedFile(file, "TOO_MANY_FILES");
|
|
234
|
+
});
|
|
235
|
+
onMaxFilesReached?.(maxFiles, filesToAdd.length);
|
|
236
|
+
filesToAdd = [];
|
|
237
|
+
} else if (filesToAdd.length > remainingSlots) {
|
|
238
|
+
filesToAdd.forEach((file) => {
|
|
239
|
+
addRejectedFile(file, "TOO_MANY_FILES");
|
|
240
|
+
});
|
|
241
|
+
onMaxFilesReached?.(maxFiles, filesToAdd.length);
|
|
242
|
+
filesToAdd = [];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const updated = multiple ? [...currentFiles, ...filesToAdd] : filesToAdd;
|
|
246
|
+
const rejectedFilesToAdd = [...newRejectedFiles];
|
|
247
|
+
setRejectedFiles(rejectedFilesToAdd);
|
|
248
|
+
return updated;
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
const removeFile = (index) => {
|
|
252
|
+
if (disabled || readOnly) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
setFiles((prev) => {
|
|
256
|
+
const currentFiles = prev ?? [];
|
|
257
|
+
const updated = currentFiles.filter((_, i) => i !== index);
|
|
258
|
+
if (maxFiles !== void 0 && updated.length < maxFiles) {
|
|
259
|
+
setRejectedFiles(
|
|
260
|
+
(prevRejected) => prevRejected.filter((rejected) => !rejected.errors.includes("TOO_MANY_FILES"))
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
return updated;
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
const clearFiles = () => {
|
|
267
|
+
if (disabled || readOnly) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
setFiles([]);
|
|
271
|
+
setRejectedFiles([]);
|
|
272
|
+
deleteButtonRefs.current = [];
|
|
273
|
+
};
|
|
274
|
+
const removeRejectedFile = (index) => {
|
|
275
|
+
if (disabled || readOnly) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
setRejectedFiles((prev) => prev.filter((_, i) => i !== index));
|
|
279
|
+
};
|
|
280
|
+
const clearRejectedFiles = () => {
|
|
281
|
+
setRejectedFiles([]);
|
|
282
|
+
};
|
|
283
|
+
const maxFilesReached = maxFiles !== void 0 && files.length >= maxFiles;
|
|
284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
285
|
+
FileUploadContext.Provider,
|
|
286
|
+
{
|
|
287
|
+
value: {
|
|
288
|
+
inputRef,
|
|
289
|
+
files,
|
|
290
|
+
rejectedFiles,
|
|
291
|
+
addFiles,
|
|
292
|
+
removeFile,
|
|
293
|
+
removeRejectedFile,
|
|
294
|
+
clearFiles,
|
|
295
|
+
clearRejectedFiles,
|
|
296
|
+
triggerRef,
|
|
297
|
+
dropzoneRef,
|
|
298
|
+
deleteButtonRefs,
|
|
299
|
+
multiple,
|
|
300
|
+
maxFiles,
|
|
301
|
+
maxFilesReached,
|
|
302
|
+
disabled,
|
|
303
|
+
readOnly,
|
|
304
|
+
locale: defaultLocale
|
|
305
|
+
},
|
|
306
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
|
|
307
|
+
children,
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
309
|
+
"input",
|
|
310
|
+
{
|
|
311
|
+
ref: inputRef,
|
|
312
|
+
type: "file",
|
|
313
|
+
tabIndex: -1,
|
|
314
|
+
id: "image_uploads",
|
|
315
|
+
multiple,
|
|
316
|
+
name: "image_uploads",
|
|
317
|
+
accept,
|
|
318
|
+
disabled,
|
|
319
|
+
readOnly: readOnly && !disabled,
|
|
320
|
+
className: "sr-only",
|
|
321
|
+
onChange: (e) => {
|
|
322
|
+
if (e.target.files && !disabled && !readOnly) {
|
|
323
|
+
addFiles(Array.from(e.target.files));
|
|
324
|
+
try {
|
|
325
|
+
e.target.value = "";
|
|
326
|
+
} catch {
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
)
|
|
332
|
+
] })
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
};
|
|
336
|
+
FileUpload.displayName = "FileUpload";
|
|
337
|
+
var useFileUploadContext = () => {
|
|
338
|
+
const context = (0, import_react.useContext)(FileUploadContext);
|
|
339
|
+
if (!context) {
|
|
340
|
+
throw Error("useFileUploadContext must be used within a FileUpload provider");
|
|
341
|
+
}
|
|
342
|
+
return context;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// src/file-upload/FileUploadAcceptedFile.tsx
|
|
346
|
+
var import_CvOutline = require("@spark-ui/icons/CvOutline");
|
|
347
|
+
|
|
348
|
+
// src/icon/Icon.tsx
|
|
349
|
+
var import_react3 = require("react");
|
|
350
|
+
|
|
351
|
+
// src/slot/Slot.tsx
|
|
352
|
+
var import_radix_ui = require("radix-ui");
|
|
353
|
+
var import_react2 = require("react");
|
|
354
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
355
|
+
var Slottable = import_radix_ui.Slot.Slottable;
|
|
356
|
+
var Slot = ({ ref, ...props }) => {
|
|
357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
|
|
358
|
+
};
|
|
359
|
+
var wrapPolymorphicSlot = (asChild, children, callback) => {
|
|
360
|
+
if (!asChild) return callback(children);
|
|
361
|
+
return (0, import_react2.isValidElement)(children) ? (0, import_react2.cloneElement)(
|
|
362
|
+
children,
|
|
363
|
+
void 0,
|
|
364
|
+
callback(children.props.children)
|
|
365
|
+
) : null;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// src/visually-hidden/VisuallyHidden.tsx
|
|
369
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
370
|
+
var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
|
|
371
|
+
const Component = asChild ? Slot : "span";
|
|
372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
373
|
+
Component,
|
|
374
|
+
{
|
|
375
|
+
...props,
|
|
376
|
+
ref,
|
|
377
|
+
style: {
|
|
378
|
+
// See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
|
|
379
|
+
position: "absolute",
|
|
380
|
+
border: 0,
|
|
381
|
+
width: 1,
|
|
382
|
+
height: 1,
|
|
383
|
+
padding: 0,
|
|
384
|
+
margin: -1,
|
|
385
|
+
overflow: "hidden",
|
|
386
|
+
clip: "rect(0, 0, 0, 0)",
|
|
387
|
+
whiteSpace: "nowrap",
|
|
388
|
+
wordWrap: "normal",
|
|
389
|
+
...props.style
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
};
|
|
394
|
+
VisuallyHidden.displayName = "VisuallyHidden";
|
|
395
|
+
|
|
396
|
+
// src/icon/Icon.styles.tsx
|
|
397
|
+
var import_internal_utils = require("@spark-ui/internal-utils");
|
|
398
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
399
|
+
var iconStyles = (0, import_class_variance_authority.cva)(["fill-current shrink-0"], {
|
|
400
|
+
variants: {
|
|
401
|
+
/**
|
|
402
|
+
* Color scheme of the icon.
|
|
403
|
+
*/
|
|
404
|
+
intent: (0, import_internal_utils.makeVariants)({
|
|
405
|
+
current: ["text-current"],
|
|
406
|
+
main: ["text-main"],
|
|
407
|
+
support: ["text-support"],
|
|
408
|
+
accent: ["text-accent"],
|
|
409
|
+
basic: ["text-basic"],
|
|
410
|
+
success: ["text-success"],
|
|
411
|
+
alert: ["text-alert"],
|
|
412
|
+
error: ["text-error"],
|
|
413
|
+
info: ["text-info"],
|
|
414
|
+
neutral: ["text-neutral"]
|
|
415
|
+
}),
|
|
416
|
+
/**
|
|
417
|
+
* Sets the size of the icon.
|
|
418
|
+
*/
|
|
419
|
+
size: (0, import_internal_utils.makeVariants)({
|
|
420
|
+
current: ["u-current-font-size"],
|
|
421
|
+
sm: ["w-sz-16", "h-sz-16"],
|
|
422
|
+
md: ["w-sz-24", "h-sz-24"],
|
|
423
|
+
lg: ["w-sz-32", "h-sz-32"],
|
|
424
|
+
xl: ["w-sz-40", "h-sz-40"]
|
|
425
|
+
})
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// src/icon/Icon.tsx
|
|
430
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
431
|
+
var Icon = ({
|
|
432
|
+
label,
|
|
433
|
+
className,
|
|
434
|
+
size = "current",
|
|
435
|
+
intent = "current",
|
|
436
|
+
children,
|
|
437
|
+
...others
|
|
438
|
+
}) => {
|
|
439
|
+
const child = import_react3.Children.only(children);
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
441
|
+
(0, import_react3.cloneElement)(child, {
|
|
442
|
+
className: iconStyles({ className, size, intent }),
|
|
443
|
+
"data-spark-component": "icon",
|
|
444
|
+
"aria-hidden": "true",
|
|
445
|
+
focusable: "false",
|
|
446
|
+
...others
|
|
447
|
+
}),
|
|
448
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(VisuallyHidden, { children: label })
|
|
449
|
+
] });
|
|
450
|
+
};
|
|
451
|
+
Icon.displayName = "Icon";
|
|
452
|
+
|
|
453
|
+
// src/progress/Progress.tsx
|
|
454
|
+
var import_class_variance_authority4 = require("class-variance-authority");
|
|
455
|
+
var import_radix_ui3 = require("radix-ui");
|
|
456
|
+
var import_react5 = require("react");
|
|
457
|
+
|
|
458
|
+
// src/progress/ProgressBar.styles.ts
|
|
459
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
460
|
+
var progressBarStyles = (0, import_class_variance_authority2.cva)(
|
|
461
|
+
["relative", "h-sz-4 w-full", "transform-gpu overflow-hidden", "bg-on-background/dim-4"],
|
|
462
|
+
{
|
|
463
|
+
variants: {
|
|
464
|
+
shape: {
|
|
465
|
+
square: [],
|
|
466
|
+
rounded: ["rounded-sm"]
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
// src/progress/ProgressContext.tsx
|
|
473
|
+
var import_react4 = require("react");
|
|
474
|
+
var ProgressContext = (0, import_react4.createContext)(null);
|
|
475
|
+
var ID_PREFIX = ":progress";
|
|
476
|
+
var useProgress = () => {
|
|
477
|
+
const context = (0, import_react4.useContext)(ProgressContext);
|
|
478
|
+
if (!context) {
|
|
479
|
+
throw new Error("useProgress must be used within a Progress provider");
|
|
480
|
+
}
|
|
481
|
+
return context;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
// src/progress/ProgressIndicator.tsx
|
|
485
|
+
var import_radix_ui2 = require("radix-ui");
|
|
486
|
+
|
|
487
|
+
// src/progress/ProgressIndicator.styles.ts
|
|
488
|
+
var import_class_variance_authority3 = require("class-variance-authority");
|
|
489
|
+
var progressIndicatorStyles = (0, import_class_variance_authority3.cva)(["h-full w-full", "transition-transform duration-400"], {
|
|
490
|
+
variants: {
|
|
491
|
+
/**
|
|
492
|
+
* Color scheme of the progress component.
|
|
493
|
+
*/
|
|
494
|
+
intent: {
|
|
495
|
+
basic: ["bg-basic"],
|
|
496
|
+
main: ["bg-main"],
|
|
497
|
+
support: ["bg-support"],
|
|
498
|
+
accent: ["bg-accent"],
|
|
499
|
+
success: ["bg-success"],
|
|
500
|
+
alert: ["bg-alert"],
|
|
501
|
+
danger: ["bg-error"],
|
|
502
|
+
info: ["bg-info"],
|
|
503
|
+
neutral: ["bg-neutral"]
|
|
504
|
+
},
|
|
505
|
+
/**
|
|
506
|
+
* Shape of the progress component.
|
|
507
|
+
*/
|
|
508
|
+
shape: {
|
|
509
|
+
square: [],
|
|
510
|
+
rounded: ["rounded-sm"]
|
|
511
|
+
},
|
|
512
|
+
/**
|
|
513
|
+
* Sets if the progress value is not determinated.
|
|
514
|
+
*/
|
|
515
|
+
isIndeterminate: {
|
|
516
|
+
true: ["absolute", "-translate-x-1/2", "animate-standalone-indeterminate-bar"],
|
|
517
|
+
false: []
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
// src/progress/ProgressIndicator.tsx
|
|
523
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
524
|
+
var ProgressIndicator = ({
|
|
525
|
+
className,
|
|
526
|
+
style,
|
|
527
|
+
ref,
|
|
528
|
+
...others
|
|
529
|
+
}) => {
|
|
530
|
+
const { value, max, intent, shape, isIndeterminate } = useProgress();
|
|
531
|
+
const x = (max - value) / max * 100;
|
|
532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
533
|
+
import_radix_ui2.Progress.ProgressIndicator,
|
|
534
|
+
{
|
|
535
|
+
"data-spark-component": "progress-indicator",
|
|
536
|
+
className: progressIndicatorStyles({ className, intent, shape, isIndeterminate }),
|
|
537
|
+
style: { ...style, ...!isIndeterminate && { transform: `translateX(-${x}%)` } },
|
|
538
|
+
ref,
|
|
539
|
+
...others
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
};
|
|
543
|
+
ProgressIndicator.displayName = "Progress.Indicator";
|
|
544
|
+
|
|
545
|
+
// src/progress/ProgressBar.tsx
|
|
546
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
547
|
+
var ProgressBar = ({
|
|
548
|
+
className,
|
|
549
|
+
children = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProgressIndicator, {}),
|
|
550
|
+
ref,
|
|
551
|
+
...others
|
|
552
|
+
}) => {
|
|
553
|
+
const { shape } = useProgress();
|
|
554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
555
|
+
"div",
|
|
556
|
+
{
|
|
557
|
+
"data-spark-component": "progress-bar",
|
|
558
|
+
className: progressBarStyles({ className, shape }),
|
|
559
|
+
ref,
|
|
560
|
+
...others,
|
|
561
|
+
children
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
};
|
|
565
|
+
ProgressBar.displayName = "Progress.Bar";
|
|
566
|
+
|
|
567
|
+
// src/progress/Progress.tsx
|
|
568
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
569
|
+
var Progress = ({
|
|
570
|
+
className,
|
|
571
|
+
value: valueProp,
|
|
572
|
+
max = 100,
|
|
573
|
+
shape = "square",
|
|
574
|
+
intent = "basic",
|
|
575
|
+
isIndeterminate = false,
|
|
576
|
+
children = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ProgressBar, {}),
|
|
577
|
+
ref,
|
|
578
|
+
...others
|
|
579
|
+
}) => {
|
|
580
|
+
const [labelId, setLabelId] = (0, import_react5.useState)();
|
|
581
|
+
const value = (0, import_react5.useMemo)(() => {
|
|
582
|
+
return { value: valueProp ?? 0, max, intent, shape, isIndeterminate, onLabelId: setLabelId };
|
|
583
|
+
}, [max, valueProp, intent, shape, isIndeterminate, setLabelId]);
|
|
584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ProgressContext.Provider, { "data-spark-component": "progress", value, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
585
|
+
import_radix_ui3.Progress.Progress,
|
|
586
|
+
{
|
|
587
|
+
"data-spark-component": "progress",
|
|
588
|
+
ref,
|
|
589
|
+
className: (0, import_class_variance_authority4.cx)("gap-sm focus-visible:u-outline flex flex-col", className),
|
|
590
|
+
value: valueProp,
|
|
591
|
+
"aria-labelledby": labelId,
|
|
592
|
+
max,
|
|
593
|
+
tabIndex: -1,
|
|
594
|
+
...others,
|
|
595
|
+
children
|
|
596
|
+
}
|
|
597
|
+
) });
|
|
598
|
+
};
|
|
599
|
+
Progress.displayName = "Progress";
|
|
600
|
+
|
|
601
|
+
// src/progress/ProgressLabel.tsx
|
|
602
|
+
var import_use_merge_refs = require("@spark-ui/hooks/use-merge-refs");
|
|
603
|
+
var import_react6 = require("react");
|
|
604
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
605
|
+
var ProgressLabel = ({
|
|
606
|
+
id: idProp,
|
|
607
|
+
children,
|
|
608
|
+
ref: forwardedRef,
|
|
609
|
+
...others
|
|
610
|
+
}) => {
|
|
611
|
+
const internalID = `${ID_PREFIX}-label-${(0, import_react6.useId)()}`;
|
|
612
|
+
const id = idProp || internalID;
|
|
613
|
+
const { onLabelId } = useProgress();
|
|
614
|
+
const rootRef = (0, import_react6.useCallback)(
|
|
615
|
+
(el) => {
|
|
616
|
+
onLabelId(el ? id : void 0);
|
|
617
|
+
},
|
|
618
|
+
[id, onLabelId]
|
|
619
|
+
);
|
|
620
|
+
const ref = (0, import_use_merge_refs.useMergeRefs)(forwardedRef, rootRef);
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
622
|
+
"span",
|
|
623
|
+
{
|
|
624
|
+
"data-spark-component": "progress-label",
|
|
625
|
+
id,
|
|
626
|
+
className: "text-body-2 text-on-surface",
|
|
627
|
+
ref,
|
|
628
|
+
...others,
|
|
629
|
+
children
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
};
|
|
633
|
+
ProgressLabel.displayName = "Progress.Label";
|
|
634
|
+
|
|
635
|
+
// src/progress/index.ts
|
|
636
|
+
var Progress2 = Object.assign(Progress, {
|
|
637
|
+
Label: ProgressLabel,
|
|
638
|
+
Bar: ProgressBar,
|
|
639
|
+
Indicator: ProgressIndicator
|
|
640
|
+
});
|
|
641
|
+
Progress2.displayName = "Progress";
|
|
642
|
+
ProgressBar.displayName = "Progress.Bar";
|
|
643
|
+
ProgressIndicator.displayName = "Progress.Indicator";
|
|
644
|
+
ProgressLabel.displayName = "Progress.Label";
|
|
645
|
+
|
|
646
|
+
// src/file-upload/FileUploadItem.tsx
|
|
647
|
+
var import_class_variance_authority5 = require("class-variance-authority");
|
|
648
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
649
|
+
var Item = ({
|
|
650
|
+
asChild: _asChild = false,
|
|
651
|
+
className,
|
|
652
|
+
children,
|
|
653
|
+
...props
|
|
654
|
+
}) => {
|
|
655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
656
|
+
"li",
|
|
657
|
+
{
|
|
658
|
+
"data-spark-component": "file-upload-item",
|
|
659
|
+
className: (0, import_class_variance_authority5.cx)(
|
|
660
|
+
"relative",
|
|
661
|
+
"default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md",
|
|
662
|
+
"gap-md flex items-center justify-between default:w-full",
|
|
663
|
+
className
|
|
664
|
+
),
|
|
665
|
+
...props,
|
|
666
|
+
children
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
};
|
|
670
|
+
Item.displayName = "FileUpload.Item";
|
|
671
|
+
|
|
672
|
+
// src/file-upload/FileUploadItemDeleteTrigger.tsx
|
|
673
|
+
var import_Close = require("@spark-ui/icons/Close");
|
|
674
|
+
var import_class_variance_authority10 = require("class-variance-authority");
|
|
675
|
+
var import_react8 = require("react");
|
|
676
|
+
|
|
677
|
+
// src/button/Button.tsx
|
|
678
|
+
var import_class_variance_authority8 = require("class-variance-authority");
|
|
679
|
+
var import_react7 = require("react");
|
|
680
|
+
|
|
681
|
+
// src/spinner/Spinner.styles.tsx
|
|
682
|
+
var import_internal_utils2 = require("@spark-ui/internal-utils");
|
|
683
|
+
var import_class_variance_authority6 = require("class-variance-authority");
|
|
684
|
+
var defaultVariants = {
|
|
685
|
+
intent: "current",
|
|
686
|
+
size: "current",
|
|
687
|
+
isBackgroundVisible: false
|
|
688
|
+
};
|
|
689
|
+
var spinnerStyles = (0, import_class_variance_authority6.cva)(
|
|
690
|
+
["inline-block", "border-solid", "rounded-full", "border-md", "animate-spin"],
|
|
691
|
+
{
|
|
692
|
+
variants: {
|
|
693
|
+
/**
|
|
694
|
+
* Use `size` prop to set the size of the spinner. If you want to set the full size for the spinner, don't forget to add a wrapping container with its own size.
|
|
695
|
+
*/
|
|
696
|
+
size: {
|
|
697
|
+
current: ["u-current-font-size"],
|
|
698
|
+
sm: ["w-sz-20", "h-sz-20"],
|
|
699
|
+
md: ["w-sz-28", "h-sz-28"],
|
|
700
|
+
full: ["w-full", "h-full"]
|
|
701
|
+
},
|
|
702
|
+
/**
|
|
703
|
+
* Color scheme of the spinner.
|
|
704
|
+
*/
|
|
705
|
+
intent: (0, import_internal_utils2.makeVariants)({
|
|
706
|
+
current: ["border-current"],
|
|
707
|
+
main: ["border-main"],
|
|
708
|
+
support: ["border-support"],
|
|
709
|
+
accent: ["border-accent"],
|
|
710
|
+
basic: ["border-basic"],
|
|
711
|
+
success: ["border-success"],
|
|
712
|
+
alert: ["border-alert"],
|
|
713
|
+
error: ["border-error"],
|
|
714
|
+
info: ["border-info"],
|
|
715
|
+
neutral: ["border-neutral"]
|
|
716
|
+
}),
|
|
717
|
+
/**
|
|
718
|
+
* Size of the button.
|
|
719
|
+
*/
|
|
720
|
+
isBackgroundVisible: {
|
|
721
|
+
true: ["border-b-neutral-container", "border-l-neutral-container"],
|
|
722
|
+
false: ["border-b-transparent", "border-l-transparent"]
|
|
723
|
+
}
|
|
724
|
+
},
|
|
725
|
+
defaultVariants
|
|
726
|
+
}
|
|
727
|
+
);
|
|
728
|
+
|
|
729
|
+
// src/spinner/Spinner.tsx
|
|
730
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
731
|
+
var Spinner = ({
|
|
732
|
+
className,
|
|
733
|
+
size = "current",
|
|
734
|
+
intent = "current",
|
|
735
|
+
label,
|
|
736
|
+
isBackgroundVisible,
|
|
737
|
+
ref,
|
|
738
|
+
...others
|
|
739
|
+
}) => {
|
|
740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
741
|
+
"span",
|
|
742
|
+
{
|
|
743
|
+
role: "status",
|
|
744
|
+
"data-spark-component": "spinner",
|
|
745
|
+
ref,
|
|
746
|
+
className: spinnerStyles({ className, size, intent, isBackgroundVisible }),
|
|
747
|
+
...others,
|
|
748
|
+
children: label && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(VisuallyHidden, { children: label })
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// src/button/Button.styles.tsx
|
|
754
|
+
var import_internal_utils8 = require("@spark-ui/internal-utils");
|
|
755
|
+
var import_class_variance_authority7 = require("class-variance-authority");
|
|
756
|
+
|
|
757
|
+
// src/button/variants/filled.ts
|
|
758
|
+
var import_internal_utils3 = require("@spark-ui/internal-utils");
|
|
759
|
+
var filledVariants = [
|
|
760
|
+
// Main
|
|
761
|
+
{
|
|
762
|
+
intent: "main",
|
|
763
|
+
design: "filled",
|
|
764
|
+
class: (0, import_internal_utils3.tw)([
|
|
765
|
+
"bg-main",
|
|
766
|
+
"text-on-main",
|
|
767
|
+
"hover:bg-main-hovered",
|
|
768
|
+
"enabled:active:bg-main-hovered",
|
|
769
|
+
"focus-visible:bg-main-hovered"
|
|
770
|
+
])
|
|
771
|
+
},
|
|
772
|
+
// Support
|
|
773
|
+
{
|
|
774
|
+
intent: "support",
|
|
775
|
+
design: "filled",
|
|
776
|
+
class: (0, import_internal_utils3.tw)([
|
|
777
|
+
"bg-support",
|
|
778
|
+
"text-on-support",
|
|
779
|
+
"hover:bg-support-hovered",
|
|
780
|
+
"enabled:active:bg-support-hovered",
|
|
781
|
+
"focus-visible:bg-support-hovered"
|
|
782
|
+
])
|
|
783
|
+
},
|
|
784
|
+
// Accent
|
|
785
|
+
{
|
|
786
|
+
intent: "accent",
|
|
787
|
+
design: "filled",
|
|
788
|
+
class: (0, import_internal_utils3.tw)([
|
|
789
|
+
"bg-accent",
|
|
790
|
+
"text-on-accent",
|
|
791
|
+
"hover:bg-accent-hovered",
|
|
792
|
+
"enabled:active:bg-accent-hovered",
|
|
793
|
+
"focus-visible:bg-accent-hovered"
|
|
794
|
+
])
|
|
795
|
+
},
|
|
796
|
+
// Basic
|
|
797
|
+
{
|
|
798
|
+
intent: "basic",
|
|
799
|
+
design: "filled",
|
|
800
|
+
class: (0, import_internal_utils3.tw)([
|
|
801
|
+
"bg-basic",
|
|
802
|
+
"text-on-basic",
|
|
803
|
+
"hover:bg-basic-hovered",
|
|
804
|
+
"enabled:active:bg-basic-hovered",
|
|
805
|
+
"focus-visible:bg-basic-hovered"
|
|
806
|
+
])
|
|
807
|
+
},
|
|
808
|
+
// Success
|
|
809
|
+
{
|
|
810
|
+
intent: "success",
|
|
811
|
+
design: "filled",
|
|
812
|
+
class: (0, import_internal_utils3.tw)([
|
|
813
|
+
"bg-success",
|
|
814
|
+
"text-on-success",
|
|
815
|
+
"hover:bg-success-hovered",
|
|
816
|
+
"enabled:active:bg-success-hovered",
|
|
817
|
+
"focus-visible:bg-success-hovered"
|
|
818
|
+
])
|
|
819
|
+
},
|
|
820
|
+
// Alert
|
|
821
|
+
{
|
|
822
|
+
intent: "alert",
|
|
823
|
+
design: "filled",
|
|
824
|
+
class: (0, import_internal_utils3.tw)([
|
|
825
|
+
"bg-alert",
|
|
826
|
+
"text-on-alert",
|
|
827
|
+
"hover:bg-alert-hovered",
|
|
828
|
+
"enabled:active:bg-alert-hovered",
|
|
829
|
+
"focus-visible:bg-alert-hovered"
|
|
830
|
+
])
|
|
831
|
+
},
|
|
832
|
+
// Danger
|
|
833
|
+
{
|
|
834
|
+
intent: "danger",
|
|
835
|
+
design: "filled",
|
|
836
|
+
class: (0, import_internal_utils3.tw)([
|
|
837
|
+
"text-on-error bg-error",
|
|
838
|
+
"hover:bg-error-hovered enabled:active:bg-error-hovered",
|
|
839
|
+
"focus-visible:bg-error-hovered"
|
|
840
|
+
])
|
|
841
|
+
},
|
|
842
|
+
// Info
|
|
843
|
+
{
|
|
844
|
+
intent: "info",
|
|
845
|
+
design: "filled",
|
|
846
|
+
class: (0, import_internal_utils3.tw)([
|
|
847
|
+
"text-on-error bg-info",
|
|
848
|
+
"hover:bg-info-hovered enabled:active:bg-info-hovered",
|
|
849
|
+
"focus-visible:bg-info-hovered"
|
|
850
|
+
])
|
|
851
|
+
},
|
|
852
|
+
// Neutral
|
|
853
|
+
{
|
|
854
|
+
intent: "neutral",
|
|
855
|
+
design: "filled",
|
|
856
|
+
class: (0, import_internal_utils3.tw)([
|
|
857
|
+
"bg-neutral",
|
|
858
|
+
"text-on-neutral",
|
|
859
|
+
"hover:bg-neutral-hovered",
|
|
860
|
+
"enabled:active:bg-neutral-hovered",
|
|
861
|
+
"focus-visible:bg-neutral-hovered"
|
|
862
|
+
])
|
|
863
|
+
},
|
|
864
|
+
// Surface
|
|
865
|
+
{
|
|
866
|
+
intent: "surface",
|
|
867
|
+
design: "filled",
|
|
868
|
+
class: (0, import_internal_utils3.tw)([
|
|
869
|
+
"bg-surface",
|
|
870
|
+
"text-on-surface",
|
|
871
|
+
"hover:bg-surface-hovered",
|
|
872
|
+
"enabled:active:bg-surface-hovered",
|
|
873
|
+
"focus-visible:bg-surface-hovered"
|
|
874
|
+
])
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
intent: "surfaceInverse",
|
|
878
|
+
design: "filled",
|
|
879
|
+
class: (0, import_internal_utils3.tw)([
|
|
880
|
+
"bg-surface-inverse",
|
|
881
|
+
"text-on-surface-inverse",
|
|
882
|
+
"hover:bg-surface-inverse-hovered",
|
|
883
|
+
"enabled:active:bg-surface-inverse-hovered",
|
|
884
|
+
"focus-visible:bg-surface-inverse-hovered"
|
|
885
|
+
])
|
|
886
|
+
}
|
|
887
|
+
];
|
|
888
|
+
|
|
889
|
+
// src/button/variants/ghost.ts
|
|
890
|
+
var import_internal_utils4 = require("@spark-ui/internal-utils");
|
|
891
|
+
var ghostVariants = [
|
|
892
|
+
{
|
|
893
|
+
intent: "main",
|
|
894
|
+
design: "ghost",
|
|
895
|
+
class: (0, import_internal_utils4.tw)([
|
|
896
|
+
"text-on-main-container",
|
|
897
|
+
"hover:bg-main/dim-5",
|
|
898
|
+
"enabled:active:bg-main/dim-5",
|
|
899
|
+
"focus-visible:bg-main/dim-5"
|
|
900
|
+
])
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
intent: "support",
|
|
904
|
+
design: "ghost",
|
|
905
|
+
class: (0, import_internal_utils4.tw)([
|
|
906
|
+
"text-on-support-container",
|
|
907
|
+
"hover:bg-support/dim-5",
|
|
908
|
+
"enabled:active:bg-support/dim-5",
|
|
909
|
+
"focus-visible:bg-support/dim-5"
|
|
910
|
+
])
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
intent: "accent",
|
|
914
|
+
design: "ghost",
|
|
915
|
+
class: (0, import_internal_utils4.tw)([
|
|
916
|
+
"text-on-accent-container",
|
|
917
|
+
"hover:bg-accent/dim-5",
|
|
918
|
+
"enabled:active:bg-accent/dim-5",
|
|
919
|
+
"focus-visible:bg-accent/dim-5"
|
|
920
|
+
])
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
intent: "basic",
|
|
924
|
+
design: "ghost",
|
|
925
|
+
class: (0, import_internal_utils4.tw)([
|
|
926
|
+
"text-on-basic-container",
|
|
927
|
+
"hover:bg-basic/dim-5",
|
|
928
|
+
"enabled:active:bg-basic/dim-5",
|
|
929
|
+
"focus-visible:bg-basic/dim-5"
|
|
930
|
+
])
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
intent: "success",
|
|
934
|
+
design: "ghost",
|
|
935
|
+
class: (0, import_internal_utils4.tw)([
|
|
936
|
+
"text-on-success-container",
|
|
937
|
+
"hover:bg-success/dim-5",
|
|
938
|
+
"enabled:active:bg-success/dim-5",
|
|
939
|
+
"focus-visible:bg-success/dim-5"
|
|
940
|
+
])
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
intent: "alert",
|
|
944
|
+
design: "ghost",
|
|
945
|
+
class: (0, import_internal_utils4.tw)([
|
|
946
|
+
"text-on-alert-container",
|
|
947
|
+
"hover:bg-alert/dim-5",
|
|
948
|
+
"enabled:active:bg-alert/dim-5",
|
|
949
|
+
"focus-visible:bg-alert/dim-5"
|
|
950
|
+
])
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
intent: "danger",
|
|
954
|
+
design: "ghost",
|
|
955
|
+
class: (0, import_internal_utils4.tw)([
|
|
956
|
+
"text-on-error-container",
|
|
957
|
+
"hover:bg-error/dim-5",
|
|
958
|
+
"enabled:active:bg-error/dim-5",
|
|
959
|
+
"focus-visible:bg-error/dim-5"
|
|
960
|
+
])
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
intent: "info",
|
|
964
|
+
design: "ghost",
|
|
965
|
+
class: (0, import_internal_utils4.tw)([
|
|
966
|
+
"text-on-info-container",
|
|
967
|
+
"hover:bg-info/dim-5",
|
|
968
|
+
"enabled:active:bg-info/dim-5",
|
|
969
|
+
"focus-visible:bg-info/dim-5"
|
|
970
|
+
])
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
intent: "neutral",
|
|
974
|
+
design: "ghost",
|
|
975
|
+
class: (0, import_internal_utils4.tw)([
|
|
976
|
+
"text-on-neutral-container",
|
|
977
|
+
"hover:bg-neutral/dim-5",
|
|
978
|
+
"enabled:active:bg-neutral/dim-5",
|
|
979
|
+
"focus-visible:bg-neutral/dim-5"
|
|
980
|
+
])
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
intent: "surface",
|
|
984
|
+
design: "ghost",
|
|
985
|
+
class: (0, import_internal_utils4.tw)([
|
|
986
|
+
"text-surface",
|
|
987
|
+
"hover:bg-surface/dim-5",
|
|
988
|
+
"enabled:active:bg-surface/dim-5",
|
|
989
|
+
"focus-visible:bg-surface/dim-5"
|
|
990
|
+
])
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
intent: "surfaceInverse",
|
|
994
|
+
design: "ghost",
|
|
995
|
+
class: (0, import_internal_utils4.tw)([
|
|
996
|
+
"text-surface-inverse",
|
|
997
|
+
"hover:bg-surface-inverse/dim-5",
|
|
998
|
+
"enabled:active:bg-surface-inverse/dim-5",
|
|
999
|
+
"focus-visible:bg-surface-inverse/dim-5"
|
|
1000
|
+
])
|
|
1001
|
+
}
|
|
1002
|
+
];
|
|
1003
|
+
|
|
1004
|
+
// src/button/variants/outlined.ts
|
|
1005
|
+
var import_internal_utils5 = require("@spark-ui/internal-utils");
|
|
1006
|
+
var outlinedVariants = [
|
|
1007
|
+
{
|
|
1008
|
+
intent: "main",
|
|
1009
|
+
design: "outlined",
|
|
1010
|
+
class: (0, import_internal_utils5.tw)([
|
|
1011
|
+
"hover:bg-main/dim-5",
|
|
1012
|
+
"enabled:active:bg-main/dim-5",
|
|
1013
|
+
"focus-visible:bg-main/dim-5",
|
|
1014
|
+
"text-main"
|
|
1015
|
+
])
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
intent: "support",
|
|
1019
|
+
design: "outlined",
|
|
1020
|
+
class: (0, import_internal_utils5.tw)([
|
|
1021
|
+
"hover:bg-support/dim-5",
|
|
1022
|
+
"enabled:active:bg-support/dim-5",
|
|
1023
|
+
"focus-visible:bg-support/dim-5",
|
|
1024
|
+
"text-support"
|
|
1025
|
+
])
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
intent: "accent",
|
|
1029
|
+
design: "outlined",
|
|
1030
|
+
class: (0, import_internal_utils5.tw)([
|
|
1031
|
+
"hover:bg-accent/dim-5",
|
|
1032
|
+
"enabled:active:bg-accent/dim-5",
|
|
1033
|
+
"focus-visible:bg-accent/dim-5",
|
|
1034
|
+
"text-accent"
|
|
1035
|
+
])
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
intent: "basic",
|
|
1039
|
+
design: "outlined",
|
|
1040
|
+
class: (0, import_internal_utils5.tw)([
|
|
1041
|
+
"hover:bg-basic/dim-5",
|
|
1042
|
+
"enabled:active:bg-basic/dim-5",
|
|
1043
|
+
"focus-visible:bg-basic/dim-5",
|
|
1044
|
+
"text-basic"
|
|
1045
|
+
])
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
intent: "success",
|
|
1049
|
+
design: "outlined",
|
|
1050
|
+
class: (0, import_internal_utils5.tw)([
|
|
1051
|
+
"hover:bg-success/dim-5",
|
|
1052
|
+
"enabled:active:bg-success/dim-5",
|
|
1053
|
+
"focus-visible:bg-success/dim-5",
|
|
1054
|
+
"text-success"
|
|
1055
|
+
])
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
intent: "alert",
|
|
1059
|
+
design: "outlined",
|
|
1060
|
+
class: (0, import_internal_utils5.tw)([
|
|
1061
|
+
"hover:bg-alert/dim-5",
|
|
1062
|
+
"enabled:active:bg-alert/dim-5",
|
|
1063
|
+
"focus-visible:bg-alert/dim-5",
|
|
1064
|
+
"text-alert"
|
|
1065
|
+
])
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
intent: "danger",
|
|
1069
|
+
design: "outlined",
|
|
1070
|
+
class: (0, import_internal_utils5.tw)([
|
|
1071
|
+
"hover:bg-error/dim-5",
|
|
1072
|
+
"enabled:active:bg-error/dim-5",
|
|
1073
|
+
"focus-visible:bg-error/dim-5",
|
|
1074
|
+
"text-error"
|
|
1075
|
+
])
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
intent: "info",
|
|
1079
|
+
design: "outlined",
|
|
1080
|
+
class: (0, import_internal_utils5.tw)([
|
|
1081
|
+
"hover:bg-info/dim-5",
|
|
1082
|
+
"enabled:active:bg-info/dim-5",
|
|
1083
|
+
"focus-visible:bg-info/dim-5",
|
|
1084
|
+
"text-info"
|
|
1085
|
+
])
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
intent: "neutral",
|
|
1089
|
+
design: "outlined",
|
|
1090
|
+
class: (0, import_internal_utils5.tw)([
|
|
1091
|
+
"hover:bg-neutral/dim-5",
|
|
1092
|
+
"enabled:active:bg-neutral/dim-5",
|
|
1093
|
+
"focus-visible:bg-neutral/dim-5",
|
|
1094
|
+
"text-neutral"
|
|
1095
|
+
])
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
intent: "surface",
|
|
1099
|
+
design: "outlined",
|
|
1100
|
+
class: (0, import_internal_utils5.tw)([
|
|
1101
|
+
"hover:bg-surface/dim-5",
|
|
1102
|
+
"enabled:active:bg-surface/dim-5",
|
|
1103
|
+
"focus-visible:bg-surface/dim-5",
|
|
1104
|
+
"text-surface"
|
|
1105
|
+
])
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
intent: "surfaceInverse",
|
|
1109
|
+
design: "outlined",
|
|
1110
|
+
class: (0, import_internal_utils5.tw)([
|
|
1111
|
+
"hover:bg-surface-inverse/dim-5",
|
|
1112
|
+
"enabled:active:bg-surface-inverse/dim-5",
|
|
1113
|
+
"focus-visible:bg-surface-inverse/dim-5",
|
|
1114
|
+
"text-surface-inverse"
|
|
1115
|
+
])
|
|
1116
|
+
}
|
|
1117
|
+
];
|
|
1118
|
+
|
|
1119
|
+
// src/button/variants/tinted.ts
|
|
1120
|
+
var import_internal_utils6 = require("@spark-ui/internal-utils");
|
|
1121
|
+
var tintedVariants = [
|
|
1122
|
+
{
|
|
1123
|
+
intent: "main",
|
|
1124
|
+
design: "tinted",
|
|
1125
|
+
class: (0, import_internal_utils6.tw)([
|
|
1126
|
+
"bg-main-container",
|
|
1127
|
+
"text-on-main-container",
|
|
1128
|
+
"hover:bg-main-container-hovered",
|
|
1129
|
+
"enabled:active:bg-main-container-hovered",
|
|
1130
|
+
"focus-visible:bg-main-container-hovered"
|
|
1131
|
+
])
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
intent: "support",
|
|
1135
|
+
design: "tinted",
|
|
1136
|
+
class: (0, import_internal_utils6.tw)([
|
|
1137
|
+
"bg-support-container",
|
|
1138
|
+
"text-on-support-container",
|
|
1139
|
+
"hover:bg-support-container-hovered",
|
|
1140
|
+
"enabled:active:bg-support-container-hovered",
|
|
1141
|
+
"focus-visible:bg-support-container-hovered"
|
|
1142
|
+
])
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
intent: "accent",
|
|
1146
|
+
design: "tinted",
|
|
1147
|
+
class: (0, import_internal_utils6.tw)([
|
|
1148
|
+
"bg-accent-container",
|
|
1149
|
+
"text-on-accent-container",
|
|
1150
|
+
"hover:bg-accent-container-hovered",
|
|
1151
|
+
"enabled:active:bg-accent-container-hovered",
|
|
1152
|
+
"focus-visible:bg-accent-container-hovered"
|
|
1153
|
+
])
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
intent: "basic",
|
|
1157
|
+
design: "tinted",
|
|
1158
|
+
class: (0, import_internal_utils6.tw)([
|
|
1159
|
+
"bg-basic-container",
|
|
1160
|
+
"text-on-basic-container",
|
|
1161
|
+
"hover:bg-basic-container-hovered",
|
|
1162
|
+
"enabled:active:bg-basic-container-hovered",
|
|
1163
|
+
"focus-visible:bg-basic-container-hovered"
|
|
1164
|
+
])
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
intent: "success",
|
|
1168
|
+
design: "tinted",
|
|
1169
|
+
class: (0, import_internal_utils6.tw)([
|
|
1170
|
+
"bg-success-container",
|
|
1171
|
+
"text-on-success-container",
|
|
1172
|
+
"hover:bg-success-container-hovered",
|
|
1173
|
+
"enabled:active:bg-success-container-hovered",
|
|
1174
|
+
"focus-visible:bg-success-container-hovered"
|
|
1175
|
+
])
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
intent: "alert",
|
|
1179
|
+
design: "tinted",
|
|
1180
|
+
class: (0, import_internal_utils6.tw)([
|
|
1181
|
+
"bg-alert-container",
|
|
1182
|
+
"text-on-alert-container",
|
|
1183
|
+
"hover:bg-alert-container-hovered",
|
|
1184
|
+
"enabled:active:bg-alert-container-hovered",
|
|
1185
|
+
"focus-visible:bg-alert-container-hovered"
|
|
1186
|
+
])
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
intent: "danger",
|
|
1190
|
+
design: "tinted",
|
|
1191
|
+
class: (0, import_internal_utils6.tw)([
|
|
1192
|
+
"bg-error-container",
|
|
1193
|
+
"text-on-error-container",
|
|
1194
|
+
"hover:bg-error-container-hovered",
|
|
1195
|
+
"enabled:active:bg-error-container-hovered",
|
|
1196
|
+
"focus-visible:bg-error-container-hovered"
|
|
1197
|
+
])
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
intent: "info",
|
|
1201
|
+
design: "tinted",
|
|
1202
|
+
class: (0, import_internal_utils6.tw)([
|
|
1203
|
+
"bg-info-container",
|
|
1204
|
+
"text-on-info-container",
|
|
1205
|
+
"hover:bg-info-container-hovered",
|
|
1206
|
+
"enabled:active:bg-info-container-hovered",
|
|
1207
|
+
"focus-visible:bg-info-container-hovered"
|
|
1208
|
+
])
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
intent: "neutral",
|
|
1212
|
+
design: "tinted",
|
|
1213
|
+
class: (0, import_internal_utils6.tw)([
|
|
1214
|
+
"bg-neutral-container",
|
|
1215
|
+
"text-on-neutral-container",
|
|
1216
|
+
"hover:bg-neutral-container-hovered",
|
|
1217
|
+
"enabled:active:bg-neutral-container-hovered",
|
|
1218
|
+
"focus-visible:bg-neutral-container-hovered"
|
|
1219
|
+
])
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
intent: "surface",
|
|
1223
|
+
design: "tinted",
|
|
1224
|
+
class: (0, import_internal_utils6.tw)([
|
|
1225
|
+
"bg-surface",
|
|
1226
|
+
"text-on-surface",
|
|
1227
|
+
"hover:bg-surface-hovered",
|
|
1228
|
+
"enabled:active:bg-surface-hovered",
|
|
1229
|
+
"focus-visible:bg-surface-hovered"
|
|
1230
|
+
])
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
intent: "surfaceInverse",
|
|
1234
|
+
design: "tinted",
|
|
1235
|
+
class: (0, import_internal_utils6.tw)([
|
|
1236
|
+
"bg-surface-inverse",
|
|
1237
|
+
"text-on-surface-inverse",
|
|
1238
|
+
"hover:bg-surface-inverse-hovered",
|
|
1239
|
+
"enabled:active:bg-surface-inverse-hovered",
|
|
1240
|
+
"focus-visible:bg-surface-inverse-hovered"
|
|
1241
|
+
])
|
|
1242
|
+
}
|
|
1243
|
+
];
|
|
1244
|
+
|
|
1245
|
+
// src/button/variants/contrast.ts
|
|
1246
|
+
var import_internal_utils7 = require("@spark-ui/internal-utils");
|
|
1247
|
+
var contrastVariants = [
|
|
1248
|
+
{
|
|
1249
|
+
intent: "main",
|
|
1250
|
+
design: "contrast",
|
|
1251
|
+
class: (0, import_internal_utils7.tw)([
|
|
1252
|
+
"text-on-main-contaier bg-surface",
|
|
1253
|
+
"hover:bg-main-container-hovered",
|
|
1254
|
+
"enabled:active:bg-main-container-hovered",
|
|
1255
|
+
"focus-visible:bg-main-container-hovered"
|
|
1256
|
+
])
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
intent: "support",
|
|
1260
|
+
design: "contrast",
|
|
1261
|
+
class: (0, import_internal_utils7.tw)([
|
|
1262
|
+
"text-on-support-container bg-surface",
|
|
1263
|
+
"hover:bg-support-container-hovered",
|
|
1264
|
+
"enabled:active:bg-support-container-hovered",
|
|
1265
|
+
"focus-visible:bg-support-container-hovered"
|
|
1266
|
+
])
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
intent: "accent",
|
|
1270
|
+
design: "contrast",
|
|
1271
|
+
class: (0, import_internal_utils7.tw)([
|
|
1272
|
+
"text-on-accent-container bg-surface",
|
|
1273
|
+
"hover:bg-accent-container-hovered",
|
|
1274
|
+
"enabled:active:bg-accent-container-hovered",
|
|
1275
|
+
"focus-visible:bg-accent-container-hovered"
|
|
1276
|
+
])
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
intent: "basic",
|
|
1280
|
+
design: "contrast",
|
|
1281
|
+
class: (0, import_internal_utils7.tw)([
|
|
1282
|
+
"text-on-basic-container bg-surface",
|
|
1283
|
+
"hover:bg-basic-container-hovered",
|
|
1284
|
+
"enabled:active:bg-basic-container-hovered",
|
|
1285
|
+
"focus-visible:bg-basic-container-hovered"
|
|
1286
|
+
])
|
|
1287
|
+
},
|
|
1288
|
+
{
|
|
1289
|
+
intent: "success",
|
|
1290
|
+
design: "contrast",
|
|
1291
|
+
class: (0, import_internal_utils7.tw)([
|
|
1292
|
+
"text-on-success-container bg-surface",
|
|
1293
|
+
"hover:bg-success-container-hovered",
|
|
1294
|
+
"enabled:active:bg-success-container-hovered",
|
|
1295
|
+
"focus-visible:bg-success-container-hovered"
|
|
1296
|
+
])
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
intent: "alert",
|
|
1300
|
+
design: "contrast",
|
|
1301
|
+
class: (0, import_internal_utils7.tw)([
|
|
1302
|
+
"text-on-alert-container bg-surface",
|
|
1303
|
+
"hover:bg-alert-container-hovered",
|
|
1304
|
+
"enabled:active:bg-alert-container-hovered",
|
|
1305
|
+
"focus-visible:bg-alert-container-hovered"
|
|
1306
|
+
])
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
intent: "danger",
|
|
1310
|
+
design: "contrast",
|
|
1311
|
+
class: (0, import_internal_utils7.tw)([
|
|
1312
|
+
"text-on-error-container bg-surface",
|
|
1313
|
+
"hover:bg-error-container-hovered",
|
|
1314
|
+
"enabled:active:bg-error-container-hovered",
|
|
1315
|
+
"focus-visible:bg-error-container-hovered"
|
|
1316
|
+
])
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
intent: "info",
|
|
1320
|
+
design: "contrast",
|
|
1321
|
+
class: (0, import_internal_utils7.tw)([
|
|
1322
|
+
"text-on-info-container bg-surface",
|
|
1323
|
+
"hover:bg-info-container-hovered",
|
|
1324
|
+
"enabled:active:bg-info-container-hovered",
|
|
1325
|
+
"focus-visible:bg-info-container-hovered"
|
|
1326
|
+
])
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
intent: "neutral",
|
|
1330
|
+
design: "contrast",
|
|
1331
|
+
class: (0, import_internal_utils7.tw)([
|
|
1332
|
+
"text-on-neutral-container bg-surface",
|
|
1333
|
+
"hover:bg-neutral-container-hovered",
|
|
1334
|
+
"enabled:active:bg-neutral-container-hovered",
|
|
1335
|
+
"focus-visible:bg-neutral-container-hovered"
|
|
1336
|
+
])
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
intent: "surface",
|
|
1340
|
+
design: "contrast",
|
|
1341
|
+
class: (0, import_internal_utils7.tw)([
|
|
1342
|
+
"text-on-surface bg-surface",
|
|
1343
|
+
"hover:bg-surface-hovered",
|
|
1344
|
+
"enabled:active:bg-surface-hovered",
|
|
1345
|
+
"focus-visible:bg-surface-hovered"
|
|
1346
|
+
])
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
intent: "surfaceInverse",
|
|
1350
|
+
design: "contrast",
|
|
1351
|
+
class: (0, import_internal_utils7.tw)([
|
|
1352
|
+
"text-on-surface-inverse bg-surface-inverse",
|
|
1353
|
+
"hover:bg-surface-inverse-hovered",
|
|
1354
|
+
"enabled:active:bg-surface-inverse-hovered",
|
|
1355
|
+
"focus-visible:bg-surface-inverse-hovered"
|
|
1356
|
+
])
|
|
1357
|
+
}
|
|
1358
|
+
];
|
|
1359
|
+
|
|
1360
|
+
// src/button/Button.styles.tsx
|
|
1361
|
+
var buttonStyles = (0, import_class_variance_authority7.cva)(
|
|
1362
|
+
[
|
|
1363
|
+
"u-shadow-border-transition",
|
|
1364
|
+
"box-border inline-flex items-center justify-center gap-md whitespace-nowrap",
|
|
1365
|
+
"default:px-lg",
|
|
1366
|
+
"text-body-1 font-bold",
|
|
1367
|
+
"focus-visible:u-outline"
|
|
1368
|
+
],
|
|
1369
|
+
{
|
|
1370
|
+
variants: {
|
|
1371
|
+
/**
|
|
1372
|
+
* Main style of the button.
|
|
1373
|
+
*
|
|
1374
|
+
* - `filled`: Button will be plain.
|
|
1375
|
+
*
|
|
1376
|
+
* - `outlined`: Button will be transparent with an outline.
|
|
1377
|
+
*
|
|
1378
|
+
* - `tinted`: Button will be filled but using a lighter color scheme.
|
|
1379
|
+
*
|
|
1380
|
+
* - `ghost`: Button will look like a link. No borders, plain text.
|
|
1381
|
+
*
|
|
1382
|
+
* - `contrast`: Button will be surface filled. No borders, plain text.
|
|
1383
|
+
*
|
|
1384
|
+
*/
|
|
1385
|
+
design: (0, import_internal_utils8.makeVariants)({
|
|
1386
|
+
filled: [],
|
|
1387
|
+
outlined: ["bg-transparent", "border-sm", "border-current"],
|
|
1388
|
+
tinted: [],
|
|
1389
|
+
ghost: ["default:-mx-md px-md hover:bg-main/dim-5"],
|
|
1390
|
+
contrast: []
|
|
1391
|
+
}),
|
|
1392
|
+
underline: {
|
|
1393
|
+
true: ["underline"]
|
|
1394
|
+
},
|
|
1395
|
+
/**
|
|
1396
|
+
* Color scheme of the button.
|
|
1397
|
+
*/
|
|
1398
|
+
intent: (0, import_internal_utils8.makeVariants)({
|
|
1399
|
+
main: [],
|
|
1400
|
+
support: [],
|
|
1401
|
+
accent: [],
|
|
1402
|
+
basic: [],
|
|
1403
|
+
success: [],
|
|
1404
|
+
alert: [],
|
|
1405
|
+
danger: [],
|
|
1406
|
+
info: [],
|
|
1407
|
+
neutral: [],
|
|
1408
|
+
surface: [],
|
|
1409
|
+
surfaceInverse: []
|
|
1410
|
+
}),
|
|
1411
|
+
/**
|
|
1412
|
+
* Size of the button.
|
|
1413
|
+
*/
|
|
1414
|
+
size: (0, import_internal_utils8.makeVariants)({
|
|
1415
|
+
sm: ["min-w-sz-32", "h-sz-32"],
|
|
1416
|
+
md: ["min-w-sz-44", "h-sz-44"],
|
|
1417
|
+
lg: ["min-w-sz-56", "h-sz-56"]
|
|
1418
|
+
}),
|
|
1419
|
+
/**
|
|
1420
|
+
* Shape of the button.
|
|
1421
|
+
*/
|
|
1422
|
+
shape: (0, import_internal_utils8.makeVariants)({
|
|
1423
|
+
rounded: ["rounded-lg"],
|
|
1424
|
+
square: ["rounded-0"],
|
|
1425
|
+
pill: ["rounded-full"]
|
|
1426
|
+
}),
|
|
1427
|
+
/**
|
|
1428
|
+
* Disable the button, preventing user interaction and adding opacity.
|
|
1429
|
+
*/
|
|
1430
|
+
disabled: {
|
|
1431
|
+
true: ["cursor-not-allowed", "opacity-dim-3"],
|
|
1432
|
+
false: ["cursor-pointer"]
|
|
1433
|
+
}
|
|
1434
|
+
},
|
|
1435
|
+
compoundVariants: [
|
|
1436
|
+
...filledVariants,
|
|
1437
|
+
...outlinedVariants,
|
|
1438
|
+
...tintedVariants,
|
|
1439
|
+
...ghostVariants,
|
|
1440
|
+
...contrastVariants
|
|
1441
|
+
],
|
|
1442
|
+
defaultVariants: {
|
|
1443
|
+
design: "filled",
|
|
1444
|
+
intent: "main",
|
|
1445
|
+
size: "md",
|
|
1446
|
+
shape: "rounded"
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
);
|
|
1450
|
+
|
|
1451
|
+
// src/button/Button.tsx
|
|
1452
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1453
|
+
var blockedEventHandlers = [
|
|
1454
|
+
"onClick",
|
|
1455
|
+
"onMouseDown",
|
|
1456
|
+
"onMouseUp",
|
|
1457
|
+
"onMouseEnter",
|
|
1458
|
+
"onMouseLeave",
|
|
1459
|
+
"onMouseOver",
|
|
1460
|
+
"onMouseOut",
|
|
1461
|
+
"onKeyDown",
|
|
1462
|
+
"onKeyPress",
|
|
1463
|
+
"onKeyUp",
|
|
1464
|
+
"onSubmit"
|
|
1465
|
+
];
|
|
1466
|
+
var Button = ({
|
|
1467
|
+
children,
|
|
1468
|
+
design = "filled",
|
|
1469
|
+
disabled = false,
|
|
1470
|
+
intent = "main",
|
|
1471
|
+
isLoading = false,
|
|
1472
|
+
loadingLabel,
|
|
1473
|
+
loadingText,
|
|
1474
|
+
shape = "rounded",
|
|
1475
|
+
size = "md",
|
|
1476
|
+
asChild,
|
|
1477
|
+
className,
|
|
1478
|
+
underline = false,
|
|
1479
|
+
ref,
|
|
1480
|
+
...others
|
|
1481
|
+
}) => {
|
|
1482
|
+
const Component = asChild ? Slot : "button";
|
|
1483
|
+
const shouldNotInteract = !!disabled || isLoading;
|
|
1484
|
+
const disabledEventHandlers = (0, import_react7.useMemo)(() => {
|
|
1485
|
+
const result = {};
|
|
1486
|
+
if (shouldNotInteract) {
|
|
1487
|
+
blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
|
|
1488
|
+
}
|
|
1489
|
+
return result;
|
|
1490
|
+
}, [shouldNotInteract]);
|
|
1491
|
+
const spinnerProps = {
|
|
1492
|
+
size: "current",
|
|
1493
|
+
className: loadingText ? "inline-block" : "absolute",
|
|
1494
|
+
...loadingLabel && { "aria-label": loadingLabel }
|
|
1495
|
+
};
|
|
1496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1497
|
+
Component,
|
|
1498
|
+
{
|
|
1499
|
+
"data-spark-component": "button",
|
|
1500
|
+
...Component === "button" && { type: "button" },
|
|
1501
|
+
ref,
|
|
1502
|
+
className: buttonStyles({
|
|
1503
|
+
className,
|
|
1504
|
+
design,
|
|
1505
|
+
disabled: shouldNotInteract,
|
|
1506
|
+
intent,
|
|
1507
|
+
shape,
|
|
1508
|
+
size,
|
|
1509
|
+
underline
|
|
1510
|
+
}),
|
|
1511
|
+
disabled: !!disabled,
|
|
1512
|
+
"aria-busy": isLoading,
|
|
1513
|
+
"aria-live": isLoading ? "assertive" : "off",
|
|
1514
|
+
...others,
|
|
1515
|
+
...disabledEventHandlers,
|
|
1516
|
+
children: wrapPolymorphicSlot(
|
|
1517
|
+
asChild,
|
|
1518
|
+
children,
|
|
1519
|
+
(slotted) => isLoading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
1520
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Spinner, { ...spinnerProps }),
|
|
1521
|
+
loadingText && loadingText,
|
|
1522
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1523
|
+
"div",
|
|
1524
|
+
{
|
|
1525
|
+
"aria-hidden": true,
|
|
1526
|
+
className: (0, import_class_variance_authority8.cx)("gap-md", loadingText ? "hidden" : "inline-flex opacity-0"),
|
|
1527
|
+
children: slotted
|
|
1528
|
+
}
|
|
1529
|
+
)
|
|
1530
|
+
] }) : slotted
|
|
1531
|
+
)
|
|
1532
|
+
}
|
|
1533
|
+
);
|
|
1534
|
+
};
|
|
1535
|
+
Button.displayName = "Button";
|
|
1536
|
+
|
|
1537
|
+
// src/icon-button/IconButton.styles.tsx
|
|
1538
|
+
var import_internal_utils9 = require("@spark-ui/internal-utils");
|
|
1539
|
+
var import_class_variance_authority9 = require("class-variance-authority");
|
|
1540
|
+
var iconButtonStyles = (0, import_class_variance_authority9.cva)(["pl-0 pr-0"], {
|
|
1541
|
+
variants: {
|
|
1542
|
+
/**
|
|
1543
|
+
* Sets the size of the icon.
|
|
1544
|
+
*/
|
|
1545
|
+
size: (0, import_internal_utils9.makeVariants)({
|
|
1546
|
+
sm: ["text-body-1"],
|
|
1547
|
+
md: ["text-body-1"],
|
|
1548
|
+
lg: ["text-display-3"]
|
|
1549
|
+
})
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
|
|
1553
|
+
// src/icon-button/IconButton.tsx
|
|
1554
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1555
|
+
var IconButton = ({
|
|
1556
|
+
design = "filled",
|
|
1557
|
+
disabled = false,
|
|
1558
|
+
intent = "main",
|
|
1559
|
+
shape = "rounded",
|
|
1560
|
+
size = "md",
|
|
1561
|
+
className,
|
|
1562
|
+
ref,
|
|
1563
|
+
...others
|
|
1564
|
+
}) => {
|
|
1565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1566
|
+
Button,
|
|
1567
|
+
{
|
|
1568
|
+
"data-spark-component": "icon-button",
|
|
1569
|
+
ref,
|
|
1570
|
+
className: iconButtonStyles({ size, className }),
|
|
1571
|
+
design,
|
|
1572
|
+
disabled,
|
|
1573
|
+
intent,
|
|
1574
|
+
shape,
|
|
1575
|
+
size,
|
|
1576
|
+
...others
|
|
1577
|
+
}
|
|
1578
|
+
);
|
|
1579
|
+
};
|
|
1580
|
+
IconButton.displayName = "IconButton";
|
|
1581
|
+
|
|
1582
|
+
// src/file-upload/FileUploadItemDeleteTrigger.tsx
|
|
1583
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1584
|
+
var ItemDeleteTrigger = ({
|
|
1585
|
+
className,
|
|
1586
|
+
fileIndex,
|
|
1587
|
+
onClick,
|
|
1588
|
+
...props
|
|
1589
|
+
}) => {
|
|
1590
|
+
const { removeFile, triggerRef, dropzoneRef, deleteButtonRefs, disabled, readOnly } = useFileUploadContext();
|
|
1591
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
1592
|
+
const handleClick = (e) => {
|
|
1593
|
+
if (disabled || readOnly) {
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
removeFile(fileIndex);
|
|
1597
|
+
setTimeout(() => {
|
|
1598
|
+
const remainingButtons = deleteButtonRefs.current.filter(Boolean);
|
|
1599
|
+
if (remainingButtons.length > 0) {
|
|
1600
|
+
const targetIndex = Math.min(fileIndex, remainingButtons.length - 1);
|
|
1601
|
+
const nextButton = remainingButtons[targetIndex];
|
|
1602
|
+
if (nextButton) {
|
|
1603
|
+
nextButton.focus();
|
|
1604
|
+
}
|
|
1605
|
+
} else {
|
|
1606
|
+
const focusTarget = triggerRef.current || dropzoneRef.current;
|
|
1607
|
+
if (focusTarget) {
|
|
1608
|
+
focusTarget.focus();
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}, 0);
|
|
1612
|
+
onClick?.(e);
|
|
1613
|
+
};
|
|
1614
|
+
const setRef = (node) => {
|
|
1615
|
+
buttonRef.current = node;
|
|
1616
|
+
if (node) {
|
|
1617
|
+
while (deleteButtonRefs.current.length <= fileIndex) {
|
|
1618
|
+
deleteButtonRefs.current.push(null);
|
|
1619
|
+
}
|
|
1620
|
+
deleteButtonRefs.current[fileIndex] = node;
|
|
1621
|
+
} else {
|
|
1622
|
+
if (deleteButtonRefs.current[fileIndex]) {
|
|
1623
|
+
deleteButtonRefs.current[fileIndex] = null;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1628
|
+
IconButton,
|
|
1629
|
+
{
|
|
1630
|
+
ref: setRef,
|
|
1631
|
+
"data-spark-component": "file-upload-item-delete-trigger",
|
|
1632
|
+
className: (0, import_class_variance_authority10.cx)(className),
|
|
1633
|
+
onClick: handleClick,
|
|
1634
|
+
disabled: disabled || readOnly,
|
|
1635
|
+
size: "sm",
|
|
1636
|
+
design: "contrast",
|
|
1637
|
+
intent: "surface",
|
|
1638
|
+
...props,
|
|
1639
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_Close.Close, {}) })
|
|
1640
|
+
}
|
|
1641
|
+
);
|
|
1642
|
+
};
|
|
1643
|
+
ItemDeleteTrigger.displayName = "FileUpload.ItemDeleteTrigger";
|
|
1644
|
+
|
|
1645
|
+
// src/file-upload/FileUploadItemFileName.tsx
|
|
1646
|
+
var import_class_variance_authority11 = require("class-variance-authority");
|
|
1647
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1648
|
+
var ItemFileName = ({
|
|
1649
|
+
asChild: _asChild = false,
|
|
1650
|
+
className,
|
|
1651
|
+
children,
|
|
1652
|
+
...props
|
|
1653
|
+
}) => {
|
|
1654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1655
|
+
"p",
|
|
1656
|
+
{
|
|
1657
|
+
"data-spark-component": "file-upload-item-file-name",
|
|
1658
|
+
className: (0, import_class_variance_authority11.cx)("text-body-2 truncate font-medium", className),
|
|
1659
|
+
...props,
|
|
1660
|
+
children
|
|
1661
|
+
}
|
|
1662
|
+
);
|
|
1663
|
+
};
|
|
1664
|
+
ItemFileName.displayName = "FileUpload.ItemFileName";
|
|
1665
|
+
|
|
1666
|
+
// src/file-upload/FileUploadItemSizeText.tsx
|
|
1667
|
+
var import_class_variance_authority12 = require("class-variance-authority");
|
|
1668
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1669
|
+
var ItemSizeText = ({
|
|
1670
|
+
asChild: _asChild = false,
|
|
1671
|
+
className,
|
|
1672
|
+
children,
|
|
1673
|
+
...props
|
|
1674
|
+
}) => {
|
|
1675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1676
|
+
"p",
|
|
1677
|
+
{
|
|
1678
|
+
"data-spark-component": "file-upload-item-size-text",
|
|
1679
|
+
className: (0, import_class_variance_authority12.cx)("text-caption", className),
|
|
1680
|
+
...props,
|
|
1681
|
+
children
|
|
1682
|
+
}
|
|
1683
|
+
);
|
|
1684
|
+
};
|
|
1685
|
+
ItemSizeText.displayName = "FileUpload.ItemSizeText";
|
|
1686
|
+
|
|
1687
|
+
// src/file-upload/FileUploadAcceptedFile.tsx
|
|
1688
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1689
|
+
var AcceptedFile = ({
|
|
1690
|
+
asChild: _asChild = false,
|
|
1691
|
+
className,
|
|
1692
|
+
file,
|
|
1693
|
+
fileIndex,
|
|
1694
|
+
uploadProgress,
|
|
1695
|
+
...props
|
|
1696
|
+
}) => {
|
|
1697
|
+
const { locale } = useFileUploadContext();
|
|
1698
|
+
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: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_CvOutline.CvOutline, {}) }) }),
|
|
1700
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "gap-md flex flex-row items-center justify-between", children: [
|
|
1702
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ItemFileName, { children: file.name }),
|
|
1703
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ItemSizeText, { className: "opacity-dim-1", children: formatFileSize(file.size, locale) })
|
|
1704
|
+
] }),
|
|
1705
|
+
uploadProgress !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "mt-md", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1706
|
+
Progress2,
|
|
1707
|
+
{
|
|
1708
|
+
value: uploadProgress,
|
|
1709
|
+
max: 100,
|
|
1710
|
+
"aria-label": `Upload progress: ${uploadProgress}%`
|
|
1711
|
+
}
|
|
1712
|
+
) })
|
|
1713
|
+
] }),
|
|
1714
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ItemDeleteTrigger, { "aria-label": "Delete file", fileIndex })
|
|
1715
|
+
] });
|
|
1716
|
+
};
|
|
1717
|
+
AcceptedFile.displayName = "FileUpload.AcceptedFile";
|
|
1718
|
+
|
|
1719
|
+
// src/file-upload/FileUploadContext.tsx
|
|
1720
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1721
|
+
var Context = ({ children }) => {
|
|
1722
|
+
const { files = [], rejectedFiles = [], locale } = useFileUploadContext();
|
|
1723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: children({
|
|
1724
|
+
acceptedFiles: files,
|
|
1725
|
+
rejectedFiles,
|
|
1726
|
+
formatFileSize,
|
|
1727
|
+
locale
|
|
1728
|
+
}) });
|
|
1729
|
+
};
|
|
1730
|
+
Context.displayName = "FileUpload.Context";
|
|
1731
|
+
|
|
1732
|
+
// src/file-upload/FileUploadDropzone.tsx
|
|
1733
|
+
var import_class_variance_authority13 = require("class-variance-authority");
|
|
1734
|
+
var import_react9 = require("react");
|
|
1735
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1736
|
+
function Dropzone({
|
|
1737
|
+
children,
|
|
1738
|
+
onFiles,
|
|
1739
|
+
className,
|
|
1740
|
+
unstyled = false
|
|
1741
|
+
}) {
|
|
1742
|
+
const ctx = useFileUploadContext();
|
|
1743
|
+
const dropzoneRef = (0, import_react9.useRef)(null);
|
|
1744
|
+
if (!ctx) throw new Error("FileUploadDropzone must be used inside <FileUpload>");
|
|
1745
|
+
const handleDrop = (e) => {
|
|
1746
|
+
e.preventDefault();
|
|
1747
|
+
e.stopPropagation();
|
|
1748
|
+
e.currentTarget.setAttribute("data-drag-over", "false");
|
|
1749
|
+
if (ctx.disabled || ctx.readOnly) {
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
const files = e.dataTransfer.files;
|
|
1753
|
+
onFiles?.(files);
|
|
1754
|
+
let filesArray = [];
|
|
1755
|
+
if (files) {
|
|
1756
|
+
filesArray = Array.isArray(files) ? [...files] : Array.from(files);
|
|
1757
|
+
}
|
|
1758
|
+
if (filesArray.length > 0) {
|
|
1759
|
+
ctx.addFiles(filesArray);
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
const handleClick = () => {
|
|
1763
|
+
if (!ctx.disabled && !ctx.readOnly) {
|
|
1764
|
+
ctx.inputRef.current?.click();
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
const handleKeyDown = (e) => {
|
|
1768
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1769
|
+
e.preventDefault();
|
|
1770
|
+
if (!ctx.disabled && !ctx.readOnly) {
|
|
1771
|
+
ctx.inputRef.current?.click();
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
const isDisabled = ctx.disabled || ctx.readOnly;
|
|
1776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1777
|
+
"div",
|
|
1778
|
+
{
|
|
1779
|
+
ref: (node) => {
|
|
1780
|
+
dropzoneRef.current = node;
|
|
1781
|
+
if (ctx.dropzoneRef) {
|
|
1782
|
+
ctx.dropzoneRef.current = node;
|
|
1783
|
+
}
|
|
1784
|
+
},
|
|
1785
|
+
role: "button",
|
|
1786
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
1787
|
+
"aria-disabled": ctx.disabled ? true : void 0,
|
|
1788
|
+
onClick: handleClick,
|
|
1789
|
+
onKeyDown: handleKeyDown,
|
|
1790
|
+
onDrop: handleDrop,
|
|
1791
|
+
onDragOver: (e) => {
|
|
1792
|
+
e.preventDefault();
|
|
1793
|
+
},
|
|
1794
|
+
className: unstyled ? className : (0, import_class_variance_authority13.cx)(
|
|
1795
|
+
"default:bg-surface default:border-sm default:border-outline default:rounded-lg default:border-dashed",
|
|
1796
|
+
"gap-lg flex flex-col items-center justify-center text-center",
|
|
1797
|
+
"default:p-xl",
|
|
1798
|
+
"transition-colors duration-200",
|
|
1799
|
+
!isDisabled && "hover:bg-surface-hovered",
|
|
1800
|
+
"data-[drag-over=true]:border-outline-high data-[drag-over=true]:bg-surface-hovered data-[drag-over=true]:border-solid",
|
|
1801
|
+
// Disabled: more visually disabled (opacity + cursor)
|
|
1802
|
+
ctx.disabled && "cursor-not-allowed opacity-50",
|
|
1803
|
+
// ReadOnly: less visually disabled (just cursor, no opacity)
|
|
1804
|
+
ctx.readOnly && !ctx.disabled && "cursor-default",
|
|
1805
|
+
className
|
|
1806
|
+
),
|
|
1807
|
+
onDragEnter: (e) => {
|
|
1808
|
+
if (!isDisabled) {
|
|
1809
|
+
e.currentTarget.setAttribute("data-drag-over", "true");
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1812
|
+
onDragLeave: (e) => {
|
|
1813
|
+
e.currentTarget.setAttribute("data-drag-over", "false");
|
|
1814
|
+
},
|
|
1815
|
+
children
|
|
1816
|
+
}
|
|
1817
|
+
);
|
|
1818
|
+
}
|
|
1819
|
+
Dropzone.displayName = "FileUploadDropzone";
|
|
1820
|
+
|
|
1821
|
+
// src/file-upload/FileUploadPreviewImage.tsx
|
|
1822
|
+
var import_class_variance_authority14 = require("class-variance-authority");
|
|
1823
|
+
var import_react10 = require("react");
|
|
1824
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1825
|
+
var PreviewImage = ({
|
|
1826
|
+
asChild: _asChild = false,
|
|
1827
|
+
className,
|
|
1828
|
+
file,
|
|
1829
|
+
fallback = "\u{1F4C4}",
|
|
1830
|
+
...props
|
|
1831
|
+
}) => {
|
|
1832
|
+
const [imageError, setImageError] = (0, import_react10.useState)(false);
|
|
1833
|
+
const [imageLoaded, setImageLoaded] = (0, import_react10.useState)(false);
|
|
1834
|
+
const isImage = file.type.startsWith("image/");
|
|
1835
|
+
const imageUrl = isImage ? URL.createObjectURL(file) : null;
|
|
1836
|
+
(0, import_react10.useEffect)(() => {
|
|
1837
|
+
return () => {
|
|
1838
|
+
if (imageUrl) {
|
|
1839
|
+
URL.revokeObjectURL(imageUrl);
|
|
1840
|
+
}
|
|
1841
|
+
};
|
|
1842
|
+
}, [imageUrl]);
|
|
1843
|
+
if (!isImage || imageError) {
|
|
1844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1845
|
+
"div",
|
|
1846
|
+
{
|
|
1847
|
+
"data-spark-component": "file-upload-preview-image",
|
|
1848
|
+
className: (0, import_class_variance_authority14.cx)(
|
|
1849
|
+
"bg-neutral-container flex items-center justify-center rounded-md",
|
|
1850
|
+
className
|
|
1851
|
+
),
|
|
1852
|
+
...props,
|
|
1853
|
+
children: fallback
|
|
1854
|
+
}
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1858
|
+
"div",
|
|
1859
|
+
{
|
|
1860
|
+
"data-spark-component": "file-upload-preview-image",
|
|
1861
|
+
className: (0, import_class_variance_authority14.cx)("bg-neutral-container overflow-hidden", className),
|
|
1862
|
+
...props,
|
|
1863
|
+
children: [
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1865
|
+
"img",
|
|
1866
|
+
{
|
|
1867
|
+
src: imageUrl,
|
|
1868
|
+
alt: file.name,
|
|
1869
|
+
className: (0, import_class_variance_authority14.cx)("size-full object-cover", !imageLoaded && "opacity-0"),
|
|
1870
|
+
onLoad: () => setImageLoaded(true),
|
|
1871
|
+
onError: () => setImageError(true)
|
|
1872
|
+
}
|
|
1873
|
+
),
|
|
1874
|
+
!imageLoaded && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: fallback })
|
|
1875
|
+
]
|
|
1876
|
+
}
|
|
1877
|
+
);
|
|
1878
|
+
};
|
|
1879
|
+
PreviewImage.displayName = "FileUpload.PreviewImage";
|
|
1880
|
+
|
|
1881
|
+
// src/file-upload/FileUploadRejectedFile.tsx
|
|
1882
|
+
var import_WarningOutline = require("@spark-ui/icons/WarningOutline");
|
|
1883
|
+
var import_class_variance_authority16 = require("class-variance-authority");
|
|
1884
|
+
|
|
1885
|
+
// src/file-upload/FileUploadRejectedFileDeleteTrigger.tsx
|
|
1886
|
+
var import_Close2 = require("@spark-ui/icons/Close");
|
|
1887
|
+
var import_class_variance_authority15 = require("class-variance-authority");
|
|
1888
|
+
var import_react11 = require("react");
|
|
1889
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1890
|
+
var RejectedFileDeleteTrigger = ({
|
|
1891
|
+
className,
|
|
1892
|
+
rejectedFileIndex,
|
|
1893
|
+
onClick,
|
|
1894
|
+
...props
|
|
1895
|
+
}) => {
|
|
1896
|
+
const { removeRejectedFile, triggerRef, dropzoneRef, disabled, readOnly } = useFileUploadContext();
|
|
1897
|
+
const buttonRef = (0, import_react11.useRef)(null);
|
|
1898
|
+
const handleClick = (e) => {
|
|
1899
|
+
if (disabled || readOnly) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
removeRejectedFile(rejectedFileIndex);
|
|
1903
|
+
setTimeout(() => {
|
|
1904
|
+
const focusTarget = triggerRef.current || dropzoneRef.current;
|
|
1905
|
+
if (focusTarget) {
|
|
1906
|
+
focusTarget.focus();
|
|
1907
|
+
}
|
|
1908
|
+
}, 0);
|
|
1909
|
+
onClick?.(e);
|
|
1910
|
+
};
|
|
1911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1912
|
+
IconButton,
|
|
1913
|
+
{
|
|
1914
|
+
ref: buttonRef,
|
|
1915
|
+
"data-spark-component": "file-upload-rejected-file-delete-trigger",
|
|
1916
|
+
className: (0, import_class_variance_authority15.cx)(className),
|
|
1917
|
+
onClick: handleClick,
|
|
1918
|
+
disabled: disabled || readOnly,
|
|
1919
|
+
size: "sm",
|
|
1920
|
+
design: "contrast",
|
|
1921
|
+
intent: "surface",
|
|
1922
|
+
...props,
|
|
1923
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_Close2.Close, {}) })
|
|
1924
|
+
}
|
|
1925
|
+
);
|
|
1926
|
+
};
|
|
1927
|
+
RejectedFileDeleteTrigger.displayName = "FileUpload.RejectedFileDeleteTrigger";
|
|
1928
|
+
|
|
1929
|
+
// src/file-upload/FileUploadRejectedFile.tsx
|
|
1930
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1931
|
+
var RejectedFile = ({
|
|
1932
|
+
asChild: _asChild = false,
|
|
1933
|
+
className,
|
|
1934
|
+
rejectedFile,
|
|
1935
|
+
rejectedFileIndex,
|
|
1936
|
+
renderError,
|
|
1937
|
+
...props
|
|
1938
|
+
}) => {
|
|
1939
|
+
const { locale } = useFileUploadContext();
|
|
1940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Item, { className: (0, import_class_variance_authority16.cx)("border-error border-md", className), ...props, children: [
|
|
1941
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "size-sz-40 bg-error-container flex items-center justify-center rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Icon, { size: "md", className: "text-error", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_WarningOutline.WarningOutline, {}) }) }),
|
|
1942
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "gap-md flex flex-col", children: [
|
|
1943
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "gap-md flex flex-row items-center justify-between", children: [
|
|
1944
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ItemFileName, { children: rejectedFile.file.name }),
|
|
1945
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ItemSizeText, { className: "opacity-dim-1", children: formatFileSize(rejectedFile.file.size, locale) })
|
|
1946
|
+
] }),
|
|
1947
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "gap-xs flex flex-col", children: rejectedFile.errors.map((error, errorIndex) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "text-caption text-error", "data-error-code": error, children: renderError(error) }, errorIndex)) })
|
|
1948
|
+
] }) }),
|
|
1949
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1950
|
+
RejectedFileDeleteTrigger,
|
|
1951
|
+
{
|
|
1952
|
+
"aria-label": `Remove ${rejectedFile.file.name} error`,
|
|
1953
|
+
rejectedFileIndex
|
|
1954
|
+
}
|
|
1955
|
+
)
|
|
1956
|
+
] });
|
|
1957
|
+
};
|
|
1958
|
+
RejectedFile.displayName = "FileUpload.RejectedFile";
|
|
1959
|
+
|
|
1960
|
+
// src/file-upload/FileUploadTrigger.tsx
|
|
1961
|
+
var import_class_variance_authority17 = require("class-variance-authority");
|
|
1962
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1963
|
+
var Trigger = ({
|
|
1964
|
+
className,
|
|
1965
|
+
children,
|
|
1966
|
+
asChild = false,
|
|
1967
|
+
unstyled = false,
|
|
1968
|
+
design = "filled",
|
|
1969
|
+
intent = "basic",
|
|
1970
|
+
ref,
|
|
1971
|
+
...props
|
|
1972
|
+
}) => {
|
|
1973
|
+
const { inputRef, triggerRef, disabled, readOnly } = useFileUploadContext();
|
|
1974
|
+
const handleClick = (e) => {
|
|
1975
|
+
e.stopPropagation();
|
|
1976
|
+
e.preventDefault();
|
|
1977
|
+
if (!disabled && !readOnly) {
|
|
1978
|
+
inputRef.current?.click();
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
const buttonComponent = unstyled ? "button" : Button;
|
|
1982
|
+
const Comp = asChild ? Slot : buttonComponent;
|
|
1983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1984
|
+
Comp,
|
|
1985
|
+
{
|
|
1986
|
+
type: "button",
|
|
1987
|
+
ref: (node) => {
|
|
1988
|
+
if (triggerRef) {
|
|
1989
|
+
triggerRef.current = node;
|
|
1990
|
+
}
|
|
1991
|
+
if (ref) {
|
|
1992
|
+
if (typeof ref === "function") {
|
|
1993
|
+
ref(node);
|
|
1994
|
+
} else {
|
|
1995
|
+
ref.current = node;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
},
|
|
1999
|
+
design,
|
|
2000
|
+
intent,
|
|
2001
|
+
"data-spark-component": "file-upload-trigger",
|
|
2002
|
+
className: (0, import_class_variance_authority17.cx)(className),
|
|
2003
|
+
disabled: disabled || readOnly,
|
|
2004
|
+
onClick: handleClick,
|
|
2005
|
+
...props,
|
|
2006
|
+
children
|
|
2007
|
+
}
|
|
2008
|
+
);
|
|
2009
|
+
};
|
|
2010
|
+
Trigger.displayName = "FileUpload.Trigger";
|
|
2011
|
+
|
|
2012
|
+
// src/file-upload/index.ts
|
|
2013
|
+
var FileUpload2 = Object.assign(FileUpload, {
|
|
2014
|
+
Trigger,
|
|
2015
|
+
Dropzone,
|
|
2016
|
+
Context,
|
|
2017
|
+
Item,
|
|
2018
|
+
ItemFileName,
|
|
2019
|
+
ItemSizeText,
|
|
2020
|
+
ItemDeleteTrigger,
|
|
2021
|
+
PreviewImage,
|
|
2022
|
+
AcceptedFile,
|
|
2023
|
+
RejectedFile,
|
|
2024
|
+
RejectedFileDeleteTrigger
|
|
2025
|
+
});
|
|
2026
|
+
FileUpload2.displayName = "FileUpload";
|
|
2027
|
+
Trigger.displayName = "FileUpload.Trigger";
|
|
2028
|
+
Dropzone.displayName = "FileUpload.Dropzone";
|
|
2029
|
+
Context.displayName = "FileUpload.Context";
|
|
2030
|
+
Item.displayName = "FileUpload.Item";
|
|
2031
|
+
ItemFileName.displayName = "FileUpload.ItemFileName";
|
|
2032
|
+
ItemSizeText.displayName = "FileUpload.ItemSizeText";
|
|
2033
|
+
ItemDeleteTrigger.displayName = "FileUpload.ItemDeleteTrigger";
|
|
2034
|
+
PreviewImage.displayName = "FileUpload.PreviewImage";
|
|
2035
|
+
AcceptedFile.displayName = "FileUpload.AcceptedFile";
|
|
2036
|
+
RejectedFile.displayName = "FileUpload.RejectedFile";
|
|
2037
|
+
RejectedFileDeleteTrigger.displayName = "FileUpload.RejectedFileDeleteTrigger";
|
|
2038
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2039
|
+
0 && (module.exports = {
|
|
2040
|
+
FileUpload
|
|
2041
|
+
});
|
|
2042
|
+
//# sourceMappingURL=index.js.map
|