@cerberus-design/react 0.25.0-rc.7 → 0.25.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/combobox/combobox.cjs +1 -2
- package/dist/components/combobox/combobox.d.cts +1 -3
- package/dist/components/combobox/combobox.d.ts +1 -3
- package/dist/components/combobox/combobox.js +1 -2
- package/dist/components/cta-dialog/provider.cjs +3 -1
- package/dist/components/cta-dialog/provider.d.cts +2 -1
- package/dist/components/cta-dialog/provider.d.ts +2 -1
- package/dist/components/cta-dialog/provider.js +3 -1
- package/dist/components/date-picker/calendar.cjs +3 -1
- package/dist/components/date-picker/calendar.d.cts +4 -8
- package/dist/components/date-picker/calendar.d.ts +4 -8
- package/dist/components/date-picker/calendar.js +3 -1
- package/dist/components/date-picker/content.cjs +1 -3
- package/dist/components/date-picker/content.d.cts +1 -2
- package/dist/components/date-picker/content.d.ts +1 -2
- package/dist/components/date-picker/content.js +1 -3
- package/dist/components/date-picker/date-picker.cjs +47 -2
- package/dist/components/date-picker/date-picker.d.cts +1 -6
- package/dist/components/date-picker/date-picker.d.ts +1 -6
- package/dist/components/date-picker/date-picker.js +47 -2
- package/dist/components/date-picker/index.cjs +3 -3
- package/dist/components/date-picker/index.js +3 -3
- package/dist/components/date-picker/input.cjs +1 -1
- package/dist/components/date-picker/input.js +1 -1
- package/dist/components/date-picker/primitives.cjs +4 -1
- package/dist/components/date-picker/primitives.d.cts +1 -4
- package/dist/components/date-picker/primitives.d.ts +1 -4
- package/dist/components/date-picker/primitives.js +4 -1
- package/dist/components/date-picker/range-input.cjs +2 -2
- package/dist/components/date-picker/range-input.js +2 -2
- package/dist/components/field/status-indicator.cjs +1 -2
- package/dist/components/field/status-indicator.d.cts +1 -1
- package/dist/components/field/status-indicator.d.ts +1 -1
- package/dist/components/field/status-indicator.js +1 -2
- package/dist/components/file-upload/file-status.cjs +26 -43
- package/dist/components/file-upload/file-status.js +27 -44
- package/dist/components/file-upload/file-uploader.cjs +21 -47
- package/dist/components/file-upload/file-uploader.d.cts +7 -10
- package/dist/components/file-upload/file-uploader.d.ts +7 -10
- package/dist/components/file-upload/file-uploader.js +22 -48
- package/dist/components/file-upload/helpers.cjs +17 -0
- package/dist/components/file-upload/helpers.d.cts +16 -0
- package/dist/components/file-upload/helpers.d.ts +16 -0
- package/dist/components/file-upload/helpers.js +13 -0
- package/dist/components/file-upload/img-preview.cjs +30 -0
- package/dist/components/file-upload/img-preview.d.cts +2 -0
- package/dist/components/file-upload/img-preview.d.ts +2 -0
- package/dist/components/file-upload/img-preview.js +26 -0
- package/dist/components/file-upload/index.cjs +24 -0
- package/dist/components/file-upload/index.d.cts +4 -0
- package/dist/components/file-upload/index.d.ts +4 -0
- package/dist/components/file-upload/index.js +4 -0
- package/dist/components/file-upload/parts.cjs +28 -0
- package/dist/components/file-upload/parts.d.cts +86 -0
- package/dist/components/file-upload/parts.d.ts +86 -0
- package/dist/components/file-upload/parts.js +24 -0
- package/dist/components/file-upload/primitives.cjs +81 -0
- package/dist/components/file-upload/primitives.d.cts +45 -0
- package/dist/components/file-upload/primitives.d.ts +45 -0
- package/dist/components/file-upload/primitives.js +61 -0
- package/dist/components/file-upload/utils.cjs +18 -0
- package/dist/components/file-upload/utils.d.cts +7 -0
- package/dist/components/file-upload/utils.d.ts +7 -0
- package/dist/components/file-upload/utils.js +14 -0
- package/dist/components/select/select.cjs +6 -3
- package/dist/components/select/select.d.cts +1 -3
- package/dist/components/select/select.d.ts +1 -3
- package/dist/components/select/select.js +6 -3
- package/dist/context/confirm-modal.cjs +3 -1
- package/dist/context/confirm-modal.d.cts +2 -1
- package/dist/context/confirm-modal.d.ts +2 -1
- package/dist/context/confirm-modal.js +3 -1
- package/dist/context/prompt-modal.cjs +4 -2
- package/dist/context/prompt-modal.d.cts +2 -1
- package/dist/context/prompt-modal.d.ts +2 -1
- package/dist/context/prompt-modal.js +5 -3
- package/dist/index.cjs +163 -131
- package/dist/index.client.d.cts +1 -1
- package/dist/index.client.d.ts +1 -1
- package/dist/index.js +8 -4
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-clear-trigger.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-clear-trigger.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-context.cjs +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-context.js +6 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-dropzone.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-dropzone.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-hidden-input.cjs +21 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-hidden-input.js +17 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-delete-trigger.cjs +23 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-delete-trigger.js +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-group.cjs +23 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-group.js +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-name.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-name.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview-image.cjs +28 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview-image.js +24 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-size-text.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-size-text.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item.cjs +26 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item.js +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-label.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-label.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-root.cjs +47 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-root.js +43 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-trigger.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-trigger.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-group-props-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-group-props-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-props-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-props-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload.cjs +36 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload.js +32 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/CalendarDate.js +3 -3
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/conversion.js +1 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/queries.js +1 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/CalendarDate.cjs +218 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/CalendarDate.js +212 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/DateFormatter.cjs +135 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/DateFormatter.js +131 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/calendars/GregorianCalendar.cjs +101 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/calendars/GregorianCalendar.js +93 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/conversion.cjs +200 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/conversion.js +186 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/manipulation.cjs +352 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/manipulation.js +336 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/queries.cjs +39 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/queries.js +30 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/string.cjs +44 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/string.js +37 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/utils.cjs +10 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/utils.js +6 -0
- package/dist/node_modules/.pnpm/@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.cjs +649 -0
- package/dist/node_modules/.pnpm/@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.js +643 -0
- package/dist/node_modules/.pnpm/@zag-js_file-utils@1.31.1/node_modules/@zag-js/file-utils/dist/index.cjs +147 -0
- package/dist/node_modules/.pnpm/@zag-js_file-utils@1.31.1/node_modules/@zag-js/file-utils/dist/index.js +138 -0
- package/dist/node_modules/.pnpm/@zag-js_i18n-utils@1.31.1/node_modules/@zag-js/i18n-utils/dist/index.cjs +53 -0
- package/dist/node_modules/.pnpm/@zag-js_i18n-utils@1.31.1/node_modules/@zag-js/i18n-utils/dist/index.js +48 -0
- package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.cjs +9 -0
- package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.js +9 -1
- package/package.json +7 -7
- package/src/components/combobox/combobox.tsx +7 -13
- package/src/components/cta-dialog/provider.tsx +8 -3
- package/src/components/date-picker/calendar.tsx +10 -9
- package/src/components/date-picker/content.tsx +4 -11
- package/src/components/date-picker/date-picker.tsx +55 -18
- package/src/components/date-picker/input.tsx +1 -1
- package/src/components/date-picker/primitives.tsx +4 -1
- package/src/components/date-picker/range-input.tsx +2 -2
- package/src/components/field/status-indicator.tsx +2 -5
- package/src/components/file-upload/file-status.tsx +14 -21
- package/src/components/file-upload/file-uploader.tsx +37 -49
- package/src/components/file-upload/helpers.ts +28 -0
- package/src/components/file-upload/img-preview.tsx +41 -0
- package/src/components/file-upload/index.ts +4 -0
- package/src/components/file-upload/parts.tsx +126 -0
- package/src/components/file-upload/primitives.ts +156 -0
- package/src/components/file-upload/utils.ts +20 -0
- package/src/components/select/select.tsx +11 -12
- package/src/context/confirm-modal.tsx +7 -2
- package/src/context/prompt-modal.tsx +9 -4
- package/src/index.client.ts +2 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
// src/data-transfer.ts
|
|
6
|
+
var getItemEntry = (item) => typeof item.getAsEntry === "function" ? item.getAsEntry() : typeof item.webkitGetAsEntry === "function" ? item.webkitGetAsEntry() : null;
|
|
7
|
+
var isDirectoryEntry = (entry) => entry.isDirectory;
|
|
8
|
+
var isFileEntry = (entry) => entry.isFile;
|
|
9
|
+
var addRelativePath = (file, path) => {
|
|
10
|
+
Object.defineProperty(file, "relativePath", { value: path ? `${path}/${file.name}` : file.name });
|
|
11
|
+
return file;
|
|
12
|
+
};
|
|
13
|
+
var getFileEntries = (items, traverseDirectories) => Promise.all(
|
|
14
|
+
Array.from(items).filter((item) => item.kind === "file").map((item) => {
|
|
15
|
+
const entry = getItemEntry(item);
|
|
16
|
+
if (!entry) return null;
|
|
17
|
+
if (isDirectoryEntry(entry) && traverseDirectories) {
|
|
18
|
+
return getDirectoryFiles(entry.createReader(), `${entry.name}`);
|
|
19
|
+
}
|
|
20
|
+
if (isFileEntry(entry) && typeof item.getAsFile === "function") {
|
|
21
|
+
const file = item.getAsFile();
|
|
22
|
+
return Promise.resolve(file ? addRelativePath(file, "") : null);
|
|
23
|
+
}
|
|
24
|
+
if (isFileEntry(entry)) {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
entry.file((file) => {
|
|
27
|
+
resolve(addRelativePath(file, ""));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}).filter((b) => b)
|
|
32
|
+
);
|
|
33
|
+
var getDirectoryFiles = (reader, path = "") => new Promise((resolve) => {
|
|
34
|
+
const entryPromises = [];
|
|
35
|
+
const readDirectoryEntries = () => {
|
|
36
|
+
reader.readEntries((entries) => {
|
|
37
|
+
if (entries.length === 0) {
|
|
38
|
+
resolve(Promise.all(entryPromises).then((entries2) => entries2.flat()));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const promises = entries.map((entry) => {
|
|
42
|
+
if (!entry) return null;
|
|
43
|
+
if (isDirectoryEntry(entry)) {
|
|
44
|
+
return getDirectoryFiles(entry.createReader(), `${path}${entry.name}`);
|
|
45
|
+
}
|
|
46
|
+
if (isFileEntry(entry)) {
|
|
47
|
+
return new Promise((resolve2) => {
|
|
48
|
+
entry.file((file) => {
|
|
49
|
+
resolve2(addRelativePath(file, path));
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}).filter((b) => b);
|
|
54
|
+
entryPromises.push(Promise.all(promises));
|
|
55
|
+
readDirectoryEntries();
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
readDirectoryEntries();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// src/get-accept-attr.ts
|
|
62
|
+
function isMIMEType(v) {
|
|
63
|
+
return v === "audio/*" || v === "video/*" || v === "image/*" || v === "text/*" || /\w+\/[-+.\w]+/g.test(v);
|
|
64
|
+
}
|
|
65
|
+
function isExt(v) {
|
|
66
|
+
return /^.*\.[\w]+$/.test(v);
|
|
67
|
+
}
|
|
68
|
+
var isValidMIME = (v) => isMIMEType(v) || isExt(v);
|
|
69
|
+
function getAcceptAttrString(accept) {
|
|
70
|
+
if (accept == null) return;
|
|
71
|
+
if (typeof accept === "string") {
|
|
72
|
+
return accept;
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(accept)) {
|
|
75
|
+
return accept.filter(isValidMIME).join(",");
|
|
76
|
+
}
|
|
77
|
+
return Object.entries(accept).reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], []).filter(isValidMIME).join(",");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/is-file-equal.ts
|
|
81
|
+
var isFileEqual = (file1, file2) => {
|
|
82
|
+
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/is-valid-file-size.ts
|
|
86
|
+
var isDefined = (v) => v !== void 0 && v !== null;
|
|
87
|
+
function isValidFileSize(file, minSize, maxSize) {
|
|
88
|
+
if (isDefined(file.size)) {
|
|
89
|
+
if (isDefined(minSize) && isDefined(maxSize)) {
|
|
90
|
+
if (file.size > maxSize) return [false, "FILE_TOO_LARGE"];
|
|
91
|
+
if (file.size < minSize) return [false, "FILE_TOO_SMALL"];
|
|
92
|
+
} else if (isDefined(minSize) && file.size < minSize) {
|
|
93
|
+
return [false, "FILE_TOO_SMALL"];
|
|
94
|
+
} else if (isDefined(maxSize) && file.size > maxSize) {
|
|
95
|
+
return [false, "FILE_TOO_LARGE"];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [true, null];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/mime-types.ts
|
|
102
|
+
var mimeTypes = "3g2_video/3gpp2[3gp,3gpp_video/3gpp[3mf_model/3mf[7z_application/x-7z-compressed[aac_audio/aac[ac_application/pkix-attr-cert[adp_audio/adpcm[adts_audio/aac[ai_application/postscript[aml_application/automationml-aml+xml[amlx_application/automationml-amlx+zip[amr_audio/amr[apk_application/vnd.android.package-archive[apng_image/apng[appcache,manifest_text/cache-manifest[appinstaller_application/appinstaller[appx_application/appx[appxbundle_application/appxbundle[asc_application/pgp-keys[atom_application/atom+xml[atomcat_application/atomcat+xml[atomdeleted_application/atomdeleted+xml[atomsvc_application/atomsvc+xml[au,snd_audio/basic[avi_video/x-msvideo[avci_image/avci[avcs_image/avcs[avif_image/avif[aw_application/applixware[bdoc_application/bdoc[bin,bpk,buffer,deb,deploy,dist,distz,dll,dmg,dms,dump,elc,exe,img,iso,lrf,mar,msi,msm,msp,pkg,so_application/octet-stream[bmp,dib_image/bmp[btf,btif_image/prs.btif[bz2_application/x-bzip2[c_text/x-c[ccxml_application/ccxml+xml[cdfx_application/cdfx+xml[cdmia_application/cdmi-capability[cdmic_application/cdmi-container[cdmid_application/cdmi-domain[cdmio_application/cdmi-object[cdmiq_application/cdmi-queue[cer_application/pkix-cert[cgm_image/cgm[cjs_application/node[class_application/java-vm[coffee,litcoffee_text/coffeescript[conf,def,in,ini,list,log,text,txt_text/plain[cpp,cxx,cc_text/x-c++src[cpl_application/cpl+xml[cpt_application/mac-compactpro[crl_application/pkix-crl[css_text/css[csv_text/csv[cu_application/cu-seeme[cwl_application/cwl[cww_application/prs.cww[davmount_application/davmount+xml[dbk_application/docbook+xml[doc_application/msword[docx_application/vnd.openxmlformats-officedocument.wordprocessingml.document[dsc_text/prs.lines.tag[dssc_application/dssc+der[dtd_application/xml-dtd[dwd_application/atsc-dwd+xml[ear,jar,war_application/java-archive[ecma_application/ecmascript[emf_image/emf[eml,mime_message/rfc822[emma_application/emma+xml[emotionml_application/emotionml+xml[eot_application/vnd.ms-fontobject[eps,ps_application/postscript[epub_application/epub+zip[exi_application/exi[exp_application/express[exr_image/aces[ez_application/andrew-inset[fdf_application/fdf[fdt_application/fdt+xml[fits_image/fits[flac_audio/flac[flv_video/x-flv[g3_image/g3fax[geojson_application/geo+json[gif_image/gif[glb_model/gltf-binary[gltf_model/gltf+json[gml_application/gml+xml[go_text/x-go[gpx_application/gpx+xml[gz_application/gzip[h_text/x-h[h261_video/h261[h263_video/h263[h264_video/h264[heic_image/heic[heics_image/heic-sequence[heif_image/heif[heifs_image/heif-sequence[htm,html,shtml_text/html[ico_image/x-icon[icns_image/x-icns[ics,ifb_text/calendar[iges,igs_model/iges[ink,inkml_application/inkml+xml[ipa_application/octet-stream[java_text/x-java-source[jp2,jpg2_image/jp2[jpeg,jpe,jpg_image/jpeg[jpf,jpx_image/jpx[jpm,jpgm_image/jpm[jpgv_video/jpeg[jph_image/jph[js,mjs_text/javascript[json_application/json[json5_application/json5[jsonld_application/ld+json[jsx_text/jsx[jxl_image/jxl[jxr_image/jxr[ktx_image/ktx[ktx2_image/ktx2[less_text/less[m1v,m2v,mpe,mpeg,mpg_video/mpeg[m4a_audio/mp4[m4v_video/x-m4v[md,markdown_text/markdown[mid,midi,kar,rmi_audio/midi[mkv_video/x-matroska[mp2,mp2a,mp3,mpga,m3a,m2a_audio/mpeg[mp4,mp4v,mpg4_video/mp4[mp4a_audio/mp4[mp4s,m4p_application/mp4[odp_application/vnd.oasis.opendocument.presentation[oda_application/oda[ods_application/vnd.oasis.opendocument.spreadsheet[odt_application/vnd.oasis.opendocument.text[oga,ogg,opus,spx_audio/ogg[ogv_video/ogg[ogx_application/ogg[otf_font/otf[p12,pfx_application/x-pkcs12[pdf_application/pdf[pem_application/x-pem-file[php_text/x-php[png_image/png[ppt_application/vnd.ms-powerpoint[pptx_application/vnd.openxmlformats-officedocument.presentationml.presentation[pskcxml_application/pskc+xml[psd_image/vnd.adobe.photoshop[py_text/x-python[qt,mov_video/quicktime[rar_application/vnd.rar[rdf_application/rdf+xml[rtf_text/rtf[sass_text/x-sass[scss_text/x-scss[sgm,sgml_text/sgml[sh_application/x-sh[svg,svgz_image/svg+xml[swf_application/x-shockwave-flash[tar_application/x-tar[tif,tiff_image/tiff[toml_application/toml[ts_video/mp2t[tsx_text/tsx[tsv_text/tab-separated-values[ttc_font/collection[ttf_font/ttf[vtt_text/vtt[wasm_application/wasm[wav_audio/wav[weba_audio/webm[webm_video/webm[webmanifest_application/manifest+json[webp_image/webp[wma_audio/x-ms-wma[wmv_video/x-ms-wmv[woff_font/woff[woff2_font/woff2[xls_application/vnd.ms-excel[xlsx_application/vnd.openxmlformats-officedocument.spreadsheetml.sheet[xml_application/xml[xz_application/x-xz[yaml,yml_text/yaml[zip_application/zip";
|
|
103
|
+
var mimeTypesMap = new Map(
|
|
104
|
+
mimeTypes.split("[").flatMap((mime) => {
|
|
105
|
+
const [extensions, mimeType] = mime.split("_");
|
|
106
|
+
return extensions.split(",").map((ext) => [ext, mimeType]);
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// src/get-file-mime-type.ts
|
|
111
|
+
function getFileMimeType(name) {
|
|
112
|
+
const extension = name.split(".").pop();
|
|
113
|
+
return extension ? mimeTypesMap.get(extension) || null : null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/is-valid-file-type.ts
|
|
117
|
+
function isFileAccepted(file, accept) {
|
|
118
|
+
if (file && accept) {
|
|
119
|
+
const types = Array.isArray(accept) ? accept : typeof accept === "string" ? accept.split(",") : [];
|
|
120
|
+
if (types.length === 0) return true;
|
|
121
|
+
const fileName = file.name || "";
|
|
122
|
+
const mimeType = (file.type || getFileMimeType(fileName) || "").toLowerCase();
|
|
123
|
+
const baseMimeType = mimeType.replace(/\/.*$/, "");
|
|
124
|
+
return types.some((type) => {
|
|
125
|
+
const validType = type.trim().toLowerCase();
|
|
126
|
+
if (validType.charAt(0) === ".") {
|
|
127
|
+
return fileName.toLowerCase().endsWith(validType);
|
|
128
|
+
}
|
|
129
|
+
if (validType.endsWith("/*")) {
|
|
130
|
+
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
131
|
+
}
|
|
132
|
+
return mimeType === validType;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
function isValidFileType(file, accept) {
|
|
138
|
+
const isAcceptable = file.type === "application/x-moz-file" || isFileAccepted(file, accept);
|
|
139
|
+
return [isAcceptable, isAcceptable ? null : "FILE_INVALID_TYPE"];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
exports.getAcceptAttrString = getAcceptAttrString;
|
|
143
|
+
exports.getFileEntries = getFileEntries;
|
|
144
|
+
exports.getFileMimeType = getFileMimeType;
|
|
145
|
+
exports.isFileEqual = isFileEqual;
|
|
146
|
+
exports.isValidFileSize = isValidFileSize;
|
|
147
|
+
exports.isValidFileType = isValidFileType;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// src/data-transfer.ts
|
|
2
|
+
var getItemEntry = (item) => typeof item.getAsEntry === "function" ? item.getAsEntry() : typeof item.webkitGetAsEntry === "function" ? item.webkitGetAsEntry() : null;
|
|
3
|
+
var isDirectoryEntry = (entry) => entry.isDirectory;
|
|
4
|
+
var isFileEntry = (entry) => entry.isFile;
|
|
5
|
+
var addRelativePath = (file, path) => {
|
|
6
|
+
Object.defineProperty(file, "relativePath", { value: path ? `${path}/${file.name}` : file.name });
|
|
7
|
+
return file;
|
|
8
|
+
};
|
|
9
|
+
var getFileEntries = (items, traverseDirectories) => Promise.all(
|
|
10
|
+
Array.from(items).filter((item) => item.kind === "file").map((item) => {
|
|
11
|
+
const entry = getItemEntry(item);
|
|
12
|
+
if (!entry) return null;
|
|
13
|
+
if (isDirectoryEntry(entry) && traverseDirectories) {
|
|
14
|
+
return getDirectoryFiles(entry.createReader(), `${entry.name}`);
|
|
15
|
+
}
|
|
16
|
+
if (isFileEntry(entry) && typeof item.getAsFile === "function") {
|
|
17
|
+
const file = item.getAsFile();
|
|
18
|
+
return Promise.resolve(file ? addRelativePath(file, "") : null);
|
|
19
|
+
}
|
|
20
|
+
if (isFileEntry(entry)) {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
entry.file((file) => {
|
|
23
|
+
resolve(addRelativePath(file, ""));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}).filter((b) => b)
|
|
28
|
+
);
|
|
29
|
+
var getDirectoryFiles = (reader, path = "") => new Promise((resolve) => {
|
|
30
|
+
const entryPromises = [];
|
|
31
|
+
const readDirectoryEntries = () => {
|
|
32
|
+
reader.readEntries((entries) => {
|
|
33
|
+
if (entries.length === 0) {
|
|
34
|
+
resolve(Promise.all(entryPromises).then((entries2) => entries2.flat()));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const promises = entries.map((entry) => {
|
|
38
|
+
if (!entry) return null;
|
|
39
|
+
if (isDirectoryEntry(entry)) {
|
|
40
|
+
return getDirectoryFiles(entry.createReader(), `${path}${entry.name}`);
|
|
41
|
+
}
|
|
42
|
+
if (isFileEntry(entry)) {
|
|
43
|
+
return new Promise((resolve2) => {
|
|
44
|
+
entry.file((file) => {
|
|
45
|
+
resolve2(addRelativePath(file, path));
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}).filter((b) => b);
|
|
50
|
+
entryPromises.push(Promise.all(promises));
|
|
51
|
+
readDirectoryEntries();
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
readDirectoryEntries();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// src/get-accept-attr.ts
|
|
58
|
+
function isMIMEType(v) {
|
|
59
|
+
return v === "audio/*" || v === "video/*" || v === "image/*" || v === "text/*" || /\w+\/[-+.\w]+/g.test(v);
|
|
60
|
+
}
|
|
61
|
+
function isExt(v) {
|
|
62
|
+
return /^.*\.[\w]+$/.test(v);
|
|
63
|
+
}
|
|
64
|
+
var isValidMIME = (v) => isMIMEType(v) || isExt(v);
|
|
65
|
+
function getAcceptAttrString(accept) {
|
|
66
|
+
if (accept == null) return;
|
|
67
|
+
if (typeof accept === "string") {
|
|
68
|
+
return accept;
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(accept)) {
|
|
71
|
+
return accept.filter(isValidMIME).join(",");
|
|
72
|
+
}
|
|
73
|
+
return Object.entries(accept).reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], []).filter(isValidMIME).join(",");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/is-file-equal.ts
|
|
77
|
+
var isFileEqual = (file1, file2) => {
|
|
78
|
+
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/is-valid-file-size.ts
|
|
82
|
+
var isDefined = (v) => v !== void 0 && v !== null;
|
|
83
|
+
function isValidFileSize(file, minSize, maxSize) {
|
|
84
|
+
if (isDefined(file.size)) {
|
|
85
|
+
if (isDefined(minSize) && isDefined(maxSize)) {
|
|
86
|
+
if (file.size > maxSize) return [false, "FILE_TOO_LARGE"];
|
|
87
|
+
if (file.size < minSize) return [false, "FILE_TOO_SMALL"];
|
|
88
|
+
} else if (isDefined(minSize) && file.size < minSize) {
|
|
89
|
+
return [false, "FILE_TOO_SMALL"];
|
|
90
|
+
} else if (isDefined(maxSize) && file.size > maxSize) {
|
|
91
|
+
return [false, "FILE_TOO_LARGE"];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return [true, null];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/mime-types.ts
|
|
98
|
+
var mimeTypes = "3g2_video/3gpp2[3gp,3gpp_video/3gpp[3mf_model/3mf[7z_application/x-7z-compressed[aac_audio/aac[ac_application/pkix-attr-cert[adp_audio/adpcm[adts_audio/aac[ai_application/postscript[aml_application/automationml-aml+xml[amlx_application/automationml-amlx+zip[amr_audio/amr[apk_application/vnd.android.package-archive[apng_image/apng[appcache,manifest_text/cache-manifest[appinstaller_application/appinstaller[appx_application/appx[appxbundle_application/appxbundle[asc_application/pgp-keys[atom_application/atom+xml[atomcat_application/atomcat+xml[atomdeleted_application/atomdeleted+xml[atomsvc_application/atomsvc+xml[au,snd_audio/basic[avi_video/x-msvideo[avci_image/avci[avcs_image/avcs[avif_image/avif[aw_application/applixware[bdoc_application/bdoc[bin,bpk,buffer,deb,deploy,dist,distz,dll,dmg,dms,dump,elc,exe,img,iso,lrf,mar,msi,msm,msp,pkg,so_application/octet-stream[bmp,dib_image/bmp[btf,btif_image/prs.btif[bz2_application/x-bzip2[c_text/x-c[ccxml_application/ccxml+xml[cdfx_application/cdfx+xml[cdmia_application/cdmi-capability[cdmic_application/cdmi-container[cdmid_application/cdmi-domain[cdmio_application/cdmi-object[cdmiq_application/cdmi-queue[cer_application/pkix-cert[cgm_image/cgm[cjs_application/node[class_application/java-vm[coffee,litcoffee_text/coffeescript[conf,def,in,ini,list,log,text,txt_text/plain[cpp,cxx,cc_text/x-c++src[cpl_application/cpl+xml[cpt_application/mac-compactpro[crl_application/pkix-crl[css_text/css[csv_text/csv[cu_application/cu-seeme[cwl_application/cwl[cww_application/prs.cww[davmount_application/davmount+xml[dbk_application/docbook+xml[doc_application/msword[docx_application/vnd.openxmlformats-officedocument.wordprocessingml.document[dsc_text/prs.lines.tag[dssc_application/dssc+der[dtd_application/xml-dtd[dwd_application/atsc-dwd+xml[ear,jar,war_application/java-archive[ecma_application/ecmascript[emf_image/emf[eml,mime_message/rfc822[emma_application/emma+xml[emotionml_application/emotionml+xml[eot_application/vnd.ms-fontobject[eps,ps_application/postscript[epub_application/epub+zip[exi_application/exi[exp_application/express[exr_image/aces[ez_application/andrew-inset[fdf_application/fdf[fdt_application/fdt+xml[fits_image/fits[flac_audio/flac[flv_video/x-flv[g3_image/g3fax[geojson_application/geo+json[gif_image/gif[glb_model/gltf-binary[gltf_model/gltf+json[gml_application/gml+xml[go_text/x-go[gpx_application/gpx+xml[gz_application/gzip[h_text/x-h[h261_video/h261[h263_video/h263[h264_video/h264[heic_image/heic[heics_image/heic-sequence[heif_image/heif[heifs_image/heif-sequence[htm,html,shtml_text/html[ico_image/x-icon[icns_image/x-icns[ics,ifb_text/calendar[iges,igs_model/iges[ink,inkml_application/inkml+xml[ipa_application/octet-stream[java_text/x-java-source[jp2,jpg2_image/jp2[jpeg,jpe,jpg_image/jpeg[jpf,jpx_image/jpx[jpm,jpgm_image/jpm[jpgv_video/jpeg[jph_image/jph[js,mjs_text/javascript[json_application/json[json5_application/json5[jsonld_application/ld+json[jsx_text/jsx[jxl_image/jxl[jxr_image/jxr[ktx_image/ktx[ktx2_image/ktx2[less_text/less[m1v,m2v,mpe,mpeg,mpg_video/mpeg[m4a_audio/mp4[m4v_video/x-m4v[md,markdown_text/markdown[mid,midi,kar,rmi_audio/midi[mkv_video/x-matroska[mp2,mp2a,mp3,mpga,m3a,m2a_audio/mpeg[mp4,mp4v,mpg4_video/mp4[mp4a_audio/mp4[mp4s,m4p_application/mp4[odp_application/vnd.oasis.opendocument.presentation[oda_application/oda[ods_application/vnd.oasis.opendocument.spreadsheet[odt_application/vnd.oasis.opendocument.text[oga,ogg,opus,spx_audio/ogg[ogv_video/ogg[ogx_application/ogg[otf_font/otf[p12,pfx_application/x-pkcs12[pdf_application/pdf[pem_application/x-pem-file[php_text/x-php[png_image/png[ppt_application/vnd.ms-powerpoint[pptx_application/vnd.openxmlformats-officedocument.presentationml.presentation[pskcxml_application/pskc+xml[psd_image/vnd.adobe.photoshop[py_text/x-python[qt,mov_video/quicktime[rar_application/vnd.rar[rdf_application/rdf+xml[rtf_text/rtf[sass_text/x-sass[scss_text/x-scss[sgm,sgml_text/sgml[sh_application/x-sh[svg,svgz_image/svg+xml[swf_application/x-shockwave-flash[tar_application/x-tar[tif,tiff_image/tiff[toml_application/toml[ts_video/mp2t[tsx_text/tsx[tsv_text/tab-separated-values[ttc_font/collection[ttf_font/ttf[vtt_text/vtt[wasm_application/wasm[wav_audio/wav[weba_audio/webm[webm_video/webm[webmanifest_application/manifest+json[webp_image/webp[wma_audio/x-ms-wma[wmv_video/x-ms-wmv[woff_font/woff[woff2_font/woff2[xls_application/vnd.ms-excel[xlsx_application/vnd.openxmlformats-officedocument.spreadsheetml.sheet[xml_application/xml[xz_application/x-xz[yaml,yml_text/yaml[zip_application/zip";
|
|
99
|
+
var mimeTypesMap = new Map(
|
|
100
|
+
mimeTypes.split("[").flatMap((mime) => {
|
|
101
|
+
const [extensions, mimeType] = mime.split("_");
|
|
102
|
+
return extensions.split(",").map((ext) => [ext, mimeType]);
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// src/get-file-mime-type.ts
|
|
107
|
+
function getFileMimeType(name) {
|
|
108
|
+
const extension = name.split(".").pop();
|
|
109
|
+
return extension ? mimeTypesMap.get(extension) || null : null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/is-valid-file-type.ts
|
|
113
|
+
function isFileAccepted(file, accept) {
|
|
114
|
+
if (file && accept) {
|
|
115
|
+
const types = Array.isArray(accept) ? accept : typeof accept === "string" ? accept.split(",") : [];
|
|
116
|
+
if (types.length === 0) return true;
|
|
117
|
+
const fileName = file.name || "";
|
|
118
|
+
const mimeType = (file.type || getFileMimeType(fileName) || "").toLowerCase();
|
|
119
|
+
const baseMimeType = mimeType.replace(/\/.*$/, "");
|
|
120
|
+
return types.some((type) => {
|
|
121
|
+
const validType = type.trim().toLowerCase();
|
|
122
|
+
if (validType.charAt(0) === ".") {
|
|
123
|
+
return fileName.toLowerCase().endsWith(validType);
|
|
124
|
+
}
|
|
125
|
+
if (validType.endsWith("/*")) {
|
|
126
|
+
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
127
|
+
}
|
|
128
|
+
return mimeType === validType;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
function isValidFileType(file, accept) {
|
|
134
|
+
const isAcceptable = file.type === "application/x-moz-file" || isFileAccepted(file, accept);
|
|
135
|
+
return [isAcceptable, isAcceptable ? null : "FILE_INVALID_TYPE"];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { getAcceptAttrString, getFileEntries, getFileMimeType, isFileEqual, isValidFileSize, isValidFileType };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
// src/cache.ts
|
|
6
|
+
function i18nCache(Ins) {
|
|
7
|
+
const formatterCache = /* @__PURE__ */ new Map();
|
|
8
|
+
return function create(locale, options) {
|
|
9
|
+
const cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : "");
|
|
10
|
+
if (formatterCache.has(cacheKey)) {
|
|
11
|
+
return formatterCache.get(cacheKey);
|
|
12
|
+
}
|
|
13
|
+
let formatter = new Ins(locale, options);
|
|
14
|
+
formatterCache.set(cacheKey, formatter);
|
|
15
|
+
return formatter;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/format-number.ts
|
|
20
|
+
var getNumberFormatter = i18nCache(Intl.NumberFormat);
|
|
21
|
+
function formatNumber(v, locale, options = {}) {
|
|
22
|
+
const formatter = getNumberFormatter(locale, options);
|
|
23
|
+
return formatter.format(v);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/format-bytes.ts
|
|
27
|
+
var bitPrefixes = ["", "kilo", "mega", "giga", "tera"];
|
|
28
|
+
var bytePrefixes = ["", "kilo", "mega", "giga", "tera", "peta"];
|
|
29
|
+
var formatBytes = (bytes, locale = "en-US", options = {}) => {
|
|
30
|
+
if (Number.isNaN(bytes)) return "";
|
|
31
|
+
if (bytes === 0) return "0 B";
|
|
32
|
+
const { unitSystem = "decimal", precision = 3, unit = "byte", unitDisplay = "short" } = options;
|
|
33
|
+
const factor = unitSystem === "binary" ? 1024 : 1e3;
|
|
34
|
+
const prefix = unit === "bit" ? bitPrefixes : bytePrefixes;
|
|
35
|
+
const isNegative = bytes < 0;
|
|
36
|
+
const absoluteBytes = Math.abs(bytes);
|
|
37
|
+
let value = absoluteBytes;
|
|
38
|
+
let index = 0;
|
|
39
|
+
while (value >= factor && index < prefix.length - 1) {
|
|
40
|
+
value /= factor;
|
|
41
|
+
index++;
|
|
42
|
+
}
|
|
43
|
+
const v = parseFloat(value.toPrecision(precision));
|
|
44
|
+
const finalValue = isNegative ? -v : v;
|
|
45
|
+
return formatNumber(finalValue, locale, {
|
|
46
|
+
style: "unit",
|
|
47
|
+
unit: prefix[index] + unit,
|
|
48
|
+
unitDisplay
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.formatBytes = formatBytes;
|
|
53
|
+
exports.formatNumber = formatNumber;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/cache.ts
|
|
2
|
+
function i18nCache(Ins) {
|
|
3
|
+
const formatterCache = /* @__PURE__ */ new Map();
|
|
4
|
+
return function create(locale, options) {
|
|
5
|
+
const cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : "");
|
|
6
|
+
if (formatterCache.has(cacheKey)) {
|
|
7
|
+
return formatterCache.get(cacheKey);
|
|
8
|
+
}
|
|
9
|
+
let formatter = new Ins(locale, options);
|
|
10
|
+
formatterCache.set(cacheKey, formatter);
|
|
11
|
+
return formatter;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/format-number.ts
|
|
16
|
+
var getNumberFormatter = i18nCache(Intl.NumberFormat);
|
|
17
|
+
function formatNumber(v, locale, options = {}) {
|
|
18
|
+
const formatter = getNumberFormatter(locale, options);
|
|
19
|
+
return formatter.format(v);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/format-bytes.ts
|
|
23
|
+
var bitPrefixes = ["", "kilo", "mega", "giga", "tera"];
|
|
24
|
+
var bytePrefixes = ["", "kilo", "mega", "giga", "tera", "peta"];
|
|
25
|
+
var formatBytes = (bytes, locale = "en-US", options = {}) => {
|
|
26
|
+
if (Number.isNaN(bytes)) return "";
|
|
27
|
+
if (bytes === 0) return "0 B";
|
|
28
|
+
const { unitSystem = "decimal", precision = 3, unit = "byte", unitDisplay = "short" } = options;
|
|
29
|
+
const factor = unitSystem === "binary" ? 1024 : 1e3;
|
|
30
|
+
const prefix = unit === "bit" ? bitPrefixes : bytePrefixes;
|
|
31
|
+
const isNegative = bytes < 0;
|
|
32
|
+
const absoluteBytes = Math.abs(bytes);
|
|
33
|
+
let value = absoluteBytes;
|
|
34
|
+
let index = 0;
|
|
35
|
+
while (value >= factor && index < prefix.length - 1) {
|
|
36
|
+
value /= factor;
|
|
37
|
+
index++;
|
|
38
|
+
}
|
|
39
|
+
const v = parseFloat(value.toPrecision(precision));
|
|
40
|
+
const finalValue = isNegative ? -v : v;
|
|
41
|
+
return formatNumber(finalValue, locale, {
|
|
42
|
+
style: "unit",
|
|
43
|
+
unit: prefix[index] + unit,
|
|
44
|
+
unitDisplay
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { formatBytes, formatNumber };
|
package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.cjs
CHANGED
|
@@ -45,6 +45,14 @@ function chunk(v, size) {
|
|
|
45
45
|
return rows;
|
|
46
46
|
}, []);
|
|
47
47
|
}
|
|
48
|
+
function flatArray(arr) {
|
|
49
|
+
return arr.reduce((flat, item) => {
|
|
50
|
+
if (Array.isArray(item)) {
|
|
51
|
+
return flat.concat(flatArray(item));
|
|
52
|
+
}
|
|
53
|
+
return flat.concat(item);
|
|
54
|
+
}, []);
|
|
55
|
+
}
|
|
48
56
|
|
|
49
57
|
// src/equal.ts
|
|
50
58
|
var isArrayLike = (value) => value?.constructor.name === "Array";
|
|
@@ -364,6 +372,7 @@ exports.decrementValue = decrementValue;
|
|
|
364
372
|
exports.ensure = ensure;
|
|
365
373
|
exports.ensureProps = ensureProps;
|
|
366
374
|
exports.first = first;
|
|
375
|
+
exports.flatArray = flatArray;
|
|
367
376
|
exports.getValuePercent = getValuePercent;
|
|
368
377
|
exports.has = has;
|
|
369
378
|
exports.hasProp = hasProp;
|
package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.js
CHANGED
|
@@ -41,6 +41,14 @@ function chunk(v, size) {
|
|
|
41
41
|
return rows;
|
|
42
42
|
}, []);
|
|
43
43
|
}
|
|
44
|
+
function flatArray(arr) {
|
|
45
|
+
return arr.reduce((flat, item) => {
|
|
46
|
+
if (Array.isArray(item)) {
|
|
47
|
+
return flat.concat(flatArray(item));
|
|
48
|
+
}
|
|
49
|
+
return flat.concat(item);
|
|
50
|
+
}, []);
|
|
51
|
+
}
|
|
44
52
|
|
|
45
53
|
// src/equal.ts
|
|
46
54
|
var isArrayLike = (value) => value?.constructor.name === "Array";
|
|
@@ -348,4 +356,4 @@ function ensureProps(props, keys, scope) {
|
|
|
348
356
|
throw new Error(`[zag-js${scope ? ` > ${scope}` : ""}] missing required props: ${missingKeys.join(", ")}`);
|
|
349
357
|
}
|
|
350
358
|
|
|
351
|
-
export { Timer, add, addOrRemove, callAll, chunk, clampValue, compact, createStore, decrementValue, ensure, ensureProps, first, getValuePercent, has, hasProp, identity, incrementValue, invariant, isArray, isBoolean, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, last, match, nan, nextIndex, noop, prevIndex, remove, roundToDpr, runIfFn, setRafTimeout, setValueAtIndex, throttle, toArray, toPx, uniq, uuid, warn, wrap };
|
|
359
|
+
export { Timer, add, addOrRemove, callAll, chunk, clampValue, compact, createStore, decrementValue, ensure, ensureProps, first, flatArray, getValuePercent, has, hasProp, identity, incrementValue, invariant, isArray, isBoolean, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, last, match, nan, nextIndex, noop, prevIndex, remove, roundToDpr, runIfFn, setRafTimeout, setValueAtIndex, throttle, toArray, toPx, uniq, uuid, warn, wrap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.1-rc.1",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"@dnd-kit/core": "^6.3.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@internationalized/date": "^3.10.
|
|
21
|
-
"@pandacss/dev": "^1.8.
|
|
22
|
-
"@types/react": "^19.2.
|
|
20
|
+
"@internationalized/date": "^3.10.1",
|
|
21
|
+
"@pandacss/dev": "^1.8.1",
|
|
22
|
+
"@types/react": "^19.2.9",
|
|
23
23
|
"@types/react-dom": "^19.2.3",
|
|
24
|
-
"@vitejs/plugin-react": "^5.1.
|
|
25
|
-
"globby": "^
|
|
24
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
25
|
+
"globby": "^16.1.0",
|
|
26
26
|
"react": "^19.2.3",
|
|
27
27
|
"react-dom": "^19.2.3",
|
|
28
28
|
"vite": "^7.2.4",
|
|
29
29
|
"vite-plugin-dts": "^4.5.4",
|
|
30
30
|
"@cerberus-design/configs": "0.0.0",
|
|
31
|
-
"@cerberus/panda-preset": "0.25.
|
|
31
|
+
"@cerberus/panda-preset": "0.25.1-rc.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
@@ -7,14 +7,12 @@ import { useCerberusContext } from '../../context/cerberus'
|
|
|
7
7
|
import { splitProps } from '../../utils/index'
|
|
8
8
|
import type { SelectCollectionItem } from '../select/select'
|
|
9
9
|
import { type FieldInputElProps } from '../field/index'
|
|
10
|
-
import { Portal } from '../portal/index'
|
|
11
10
|
import { Show } from '../show/index'
|
|
12
11
|
import { ComboboxParts } from './parts'
|
|
13
12
|
import { ComboboxStartIcon } from './primitives'
|
|
14
13
|
|
|
15
14
|
export interface ComboboxProps
|
|
16
|
-
extends ComboboxRootProps<SelectCollectionItem>,
|
|
17
|
-
ComboboxVariantProps {
|
|
15
|
+
extends ComboboxRootProps<SelectCollectionItem>, ComboboxVariantProps {
|
|
18
16
|
/**
|
|
19
17
|
* The label that appears above the combobox input.
|
|
20
18
|
*/
|
|
@@ -24,9 +22,7 @@ export interface ComboboxProps
|
|
|
24
22
|
*/
|
|
25
23
|
startIcon?: FieldInputElProps['startIcon']
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
28
|
-
* to render the Select dropdown in a specific context, such as a modal.
|
|
29
|
-
* @default document.body
|
|
25
|
+
* @deprecated - this is no longer needed
|
|
30
26
|
*/
|
|
31
27
|
container?: RefObject<HTMLElement | null>
|
|
32
28
|
}
|
|
@@ -67,13 +63,11 @@ export function Combobox(props: ComboboxProps) {
|
|
|
67
63
|
</ComboboxParts.Trigger>
|
|
68
64
|
</ComboboxParts.Control>
|
|
69
65
|
|
|
70
|
-
<
|
|
71
|
-
<ComboboxParts.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</ComboboxParts.Positioner>
|
|
76
|
-
</Portal>
|
|
66
|
+
<ComboboxParts.Positioner>
|
|
67
|
+
<ComboboxParts.Content size={rootProps.size}>
|
|
68
|
+
{elProps.children}
|
|
69
|
+
</ComboboxParts.Content>
|
|
70
|
+
</ComboboxParts.Positioner>
|
|
77
71
|
</ComboboxParts.Root>
|
|
78
72
|
)
|
|
79
73
|
}
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
DialogDescription,
|
|
20
20
|
DialogHeading,
|
|
21
21
|
DialogProvider,
|
|
22
|
-
|
|
22
|
+
DialogRootProps,
|
|
23
|
+
} from '../dialog/index'
|
|
23
24
|
import { DialogCloseIconTrigger } from '../dialog/close-icon-trigger'
|
|
24
25
|
import type { CTAButtonAction, CTAModalActionReturn } from './utils'
|
|
25
26
|
import {
|
|
@@ -66,9 +67,12 @@ import { TriggerItem } from './trigger-item'
|
|
|
66
67
|
* }, [cta])
|
|
67
68
|
* ```
|
|
68
69
|
*/
|
|
69
|
-
export function CTAModal(props: PropsWithChildren<
|
|
70
|
+
export function CTAModal(props: PropsWithChildren<DialogRootProps>) {
|
|
71
|
+
const { children, ...rootProps } = props
|
|
72
|
+
|
|
70
73
|
const [open, setOpen] = useState<boolean>(false)
|
|
71
74
|
const [content, setContent] = useState<ShowCTAModalOptions | null>(null)
|
|
75
|
+
|
|
72
76
|
const confirmIcon = content?.icon
|
|
73
77
|
|
|
74
78
|
const { icons } = useCerberusContext()
|
|
@@ -102,13 +106,14 @@ export function CTAModal(props: PropsWithChildren<object>) {
|
|
|
102
106
|
|
|
103
107
|
return (
|
|
104
108
|
<CTAModalContext.Provider value={value}>
|
|
105
|
-
{
|
|
109
|
+
{children}
|
|
106
110
|
|
|
107
111
|
<DialogProvider
|
|
108
112
|
lazyMount
|
|
109
113
|
open={open}
|
|
110
114
|
onOpenChange={(e) => setOpen(e.open)}
|
|
111
115
|
unmountOnExit
|
|
116
|
+
{...rootProps}
|
|
112
117
|
>
|
|
113
118
|
<Dialog
|
|
114
119
|
size="sm"
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { RefObject } from 'react'
|
|
2
|
+
import { splitProps } from '../../utils/index'
|
|
2
3
|
import { DatePickerContent } from './content'
|
|
3
4
|
import { DatePickerDayView } from './day-view'
|
|
4
5
|
import { DatePickerMonthView } from './month-view'
|
|
5
6
|
import { DatePickerYearView } from './year-view'
|
|
7
|
+
import { DatePickerContentProps } from './primitives'
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* This module contains an abstraction of the DatePicker component.
|
|
@@ -11,16 +13,11 @@ import { DatePickerYearView } from './year-view'
|
|
|
11
13
|
|
|
12
14
|
export interface DatePickerCalendarProps {
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
15
|
-
* content in a modal. This is an alternative to using the `container` prop
|
|
16
|
-
* which provides the context to the Portal instead.
|
|
17
|
-
* @default false
|
|
16
|
+
* @deprecated - this is no longer needed.
|
|
18
17
|
*/
|
|
19
18
|
withModal?: boolean
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
22
|
-
* to render the DatePicker content in a specific context, such as a modal.
|
|
23
|
-
* @default document.body
|
|
20
|
+
* @deprecated - this is no longer needed.
|
|
24
21
|
*/
|
|
25
22
|
container?: RefObject<HTMLElement | null>
|
|
26
23
|
}
|
|
@@ -40,9 +37,13 @@ export interface DatePickerCalendarProps {
|
|
|
40
37
|
* </Field>
|
|
41
38
|
* ```
|
|
42
39
|
*/
|
|
43
|
-
export function DatePickerCalendar(
|
|
40
|
+
export function DatePickerCalendar(
|
|
41
|
+
props: DatePickerCalendarProps & DatePickerContentProps,
|
|
42
|
+
) {
|
|
43
|
+
const [, contentProps] = splitProps(props, ['withModal', 'container'])
|
|
44
|
+
|
|
44
45
|
return (
|
|
45
|
-
<DatePickerContent {...
|
|
46
|
+
<DatePickerContent {...contentProps}>
|
|
46
47
|
<DatePickerDayView />
|
|
47
48
|
<DatePickerMonthView view="month" />
|
|
48
49
|
<DatePickerYearView view="year" />
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Portal } from '../portal/index'
|
|
2
|
-
import type { DatePickerCalendarProps } from './calendar'
|
|
3
1
|
import { DatePickerParts } from './parts'
|
|
4
2
|
import type { DatePickerContentProps } from './primitives'
|
|
5
3
|
|
|
@@ -14,15 +12,10 @@ import type { DatePickerContentProps } from './primitives'
|
|
|
14
12
|
* primitives.
|
|
15
13
|
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
16
14
|
*/
|
|
17
|
-
export function DatePickerContent(
|
|
18
|
-
props: DatePickerContentProps & DatePickerCalendarProps,
|
|
19
|
-
) {
|
|
20
|
-
const { withModal, container, ...contentProps } = props
|
|
15
|
+
export function DatePickerContent(props: DatePickerContentProps) {
|
|
21
16
|
return (
|
|
22
|
-
<
|
|
23
|
-
<DatePickerParts.
|
|
24
|
-
|
|
25
|
-
</DatePickerParts.Positioner>
|
|
26
|
-
</Portal>
|
|
17
|
+
<DatePickerParts.Positioner>
|
|
18
|
+
<DatePickerParts.Content {...props} />
|
|
19
|
+
</DatePickerParts.Positioner>
|
|
27
20
|
)
|
|
28
21
|
}
|