@krak-stack/registry 0.11.7 → 0.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/README.md +39 -0
- package/dist/components/app-switcher/html.d.ts +2 -2
- package/dist/components/asset-input/html.d.ts +70 -0
- package/dist/components/asset-input/html.js +1549 -0
- package/dist/components/asset-input/index.d.ts +280 -0
- package/dist/components/asset-input/react.d.ts +32 -0
- package/dist/components/asset-input/react.js +2269 -0
- package/dist/components/asset-input/schema.d.ts +93 -0
- package/dist/components/asset-input/upload.d.ts +15 -0
- package/dist/components/asset-table/html.d.ts +110 -0
- package/dist/components/asset-table/html.js +4934 -0
- package/dist/components/asset-table/index.d.ts +225 -0
- package/dist/components/asset-table/react.d.ts +21 -0
- package/dist/components/asset-table/react.js +8241 -0
- package/dist/components/asset-table/schema.d.ts +73 -0
- package/dist/components/audit-log-table/html.js +47 -13
- package/dist/components/audit-log-table/react.js +36 -12
- package/dist/components/copy-button/html.d.ts +2 -2
- package/dist/components/danger-confirmation/html.d.ts +2 -2
- package/dist/components/data-table/classes.d.ts +2 -0
- package/dist/components/data-table/html.d.ts +58 -0
- package/dist/components/data-table/html.js +47 -13
- package/dist/components/data-table/index.d.ts +51 -1
- package/dist/components/data-table/react.d.ts +1 -0
- package/dist/components/data-table/react.js +36 -12
- package/dist/components/data-table/schema.d.ts +93 -3
- package/dist/components/date-input/html.d.ts +2 -2
- package/dist/components/docs/html.js +22 -4
- package/dist/components/docs/react.js +33 -2
- package/dist/components/editable-text/html.d.ts +2 -2
- package/dist/components/editing-locale-switcher/html.d.ts +2 -2
- package/dist/components/effect-form/react.js +343 -138
- package/dist/components/file-input/classes.d.ts +1 -1
- package/dist/components/file-input/file-type.d.ts +1 -0
- package/dist/components/file-input/html.d.ts +8 -1
- package/dist/components/file-input/html.js +170 -12
- package/dist/components/file-input/index.d.ts +1 -0
- package/dist/components/file-input/react.d.ts +9 -1
- package/dist/components/file-input/react.js +277 -127
- package/dist/components/file-input/schema.d.ts +1 -0
- package/dist/components/form/react.d.ts +5 -5
- package/dist/components/form/react.js +343 -138
- package/dist/components/icon-input/html.js +19 -5
- package/dist/components/icon-input/react.js +70 -13
- package/dist/components/locale-switcher/html.d.ts +2 -2
- package/dist/components/map-menu/html.d.ts +10 -4
- package/dist/components/map-menu/html.js +13 -8
- package/dist/components/map-menu/index.d.ts +5 -4
- package/dist/components/map-menu/react.d.ts +28 -17
- package/dist/components/map-menu/react.js +84 -178
- package/dist/components/map-menu/schema.d.ts +6 -0
- package/dist/components/map-menu/shared.d.ts +4 -0
- package/dist/components/permissions-input/classes.d.ts +8 -0
- package/dist/components/permissions-input/html.d.ts +41 -0
- package/dist/components/permissions-input/html.js +130 -0
- package/dist/components/permissions-input/index.d.ts +80 -0
- package/dist/components/permissions-input/react.d.ts +7 -0
- package/dist/components/permissions-input/react.js +201 -0
- package/dist/components/permissions-input/schema.d.ts +33 -0
- package/dist/components/phone-number-input/html.js +48 -14
- package/dist/components/phone-number-input/react.js +67 -10
- package/dist/components/presence-transition/index.d.ts +2 -2
- package/dist/components/search-menu/html.d.ts +2 -2
- package/dist/components/sidebar-layout/html.d.ts +3 -2
- package/dist/components/sidebar-layout/html.js +20 -2
- package/dist/components/sidebar-layout/index.d.ts +1 -0
- package/dist/components/sidebar-layout/react.js +33 -2
- package/dist/components/time-input/html.d.ts +2 -2
- package/dist/components/timezone-input/html.js +48 -14
- package/dist/components/timezone-input/react.js +67 -10
- package/dist/components/tracking-notice/html.d.ts +4 -4
- package/dist/components/tracking-notice/index.d.ts +2 -2
- package/dist/components/upload-attachment/classes.d.ts +3 -2
- package/dist/components/upload-attachment/html.d.ts +1 -1
- package/dist/components/upload-attachment/html.js +7 -5
- package/dist/components/upload-attachment/react.d.ts +3 -1
- package/dist/components/upload-attachment/react.js +25 -17
- package/dist/components/virtualized-combobox/classes.d.ts +12 -0
- package/dist/components/virtualized-combobox/html.d.ts +45 -3
- package/dist/components/virtualized-combobox/html.js +48 -14
- package/dist/components/virtualized-combobox/index.d.ts +55 -4
- package/dist/components/virtualized-combobox/react.d.ts +6 -2
- package/dist/components/virtualized-combobox/react.js +67 -10
- package/dist/components/virtualized-combobox/schema.d.ts +60 -4
- package/dist/components/webhook-delivery-table/html.js +47 -13
- package/dist/components/webhook-delivery-table/react.js +36 -12
- package/dist/lib/access/index.d.ts +61 -0
- package/dist/lib/access/index.js +92 -0
- package/dist/lib/access/table/classes.d.ts +13 -0
- package/dist/lib/access/table/html.d.ts +39 -0
- package/dist/lib/access/table/html.js +157 -0
- package/dist/lib/access/table/index.d.ts +32 -0
- package/dist/lib/access/table/react.d.ts +3 -0
- package/dist/lib/access/table/react.js +195 -0
- package/dist/lib/access/table/schema.d.ts +43 -0
- package/dist/lib/docs.integrations.server.js +23 -1
- package/dist/lib/docs.js +33 -2
- package/dist/lib/docs.server.js +29 -2
- package/dist/lib/documentation-toolkit.js +23 -1
- package/dist/lib/effect-ui-adapter/use-model.d.ts +1 -1
- package/dist/lib/effect-ui-adapter/use-model.js +19 -11
- package/dist/lib/lucide-effect.d.ts +19 -19
- package/dist/lib/lucide-effect.js +38 -38
- package/dist/services/assets/library.d.ts +221 -0
- package/dist/services/assets/schema.d.ts +3 -0
- package/dist/services/assets/url.d.ts +12 -0
- package/dist/services/assets/use-library.d.ts +20 -0
- package/package.json +13 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FileInputClassesOverrides } from "./schema.js";
|
|
2
2
|
export declare const fileInputClasses: {
|
|
3
|
-
readonly root: "grid min-w-0 gap-3";
|
|
3
|
+
readonly root: "grid min-w-0 grid-cols-1 gap-3";
|
|
4
4
|
};
|
|
5
5
|
export declare const resolveFileInputClasses: (overrides?: FileInputClassesOverrides) => {
|
|
6
6
|
root: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fileType: (mimeType: string) => "archive" | "audio" | "binary" | "book" | "calendar" | "caption" | "code" | "contact" | "database" | "disc" | "document" | "file" | "font" | "image" | "json" | "mail" | "model" | "package" | "presentation" | "script" | "spreadsheet" | "video" | "web";
|
|
@@ -3,6 +3,9 @@ import { Component } from "effect/ui";
|
|
|
3
3
|
import { Html } from "effect/ui/html";
|
|
4
4
|
export { FilePickerEvents } from "./index.js";
|
|
5
5
|
export type { FilePickerMessages, FilePickerMessageTranslations, FilePickerMessageOverrides, } from "./schema.js";
|
|
6
|
+
export declare const fileTypeIconRenderer: (mimeType: string) => <Msg>(h: Html.H<Msg>, { size, color, strokeWidth, className, }?: import("../../lib/lucide-effect.js").LucideIconProps) => Html.SvgElement<Msg, never, SVGSVGElement, "svg">;
|
|
7
|
+
export declare const FileTypeIcon: <Msg>(h: Html.H<Msg>, mimeType: string) => Html.SvgElement<Msg, never, SVGSVGElement, "svg">;
|
|
8
|
+
export declare const FileThumbnail: <Msg>(h: Html.H<Msg>, file: File) => Html.SvgElement<Msg, never, SVGSVGElement, "svg"> | Html.VoidElement<Msg, import("effect/Scope").Scope, Html.EventsOf<"img">, HTMLImageElement, "img">;
|
|
6
9
|
declare const props: Schema.Struct<{
|
|
7
10
|
readonly classes: Schema.optional<Schema.$Record<Schema.Literals<"root"[]>, Schema.optionalKey<Schema.String>>>;
|
|
8
11
|
readonly accept: Schema.optional<Schema.String>;
|
|
@@ -30,7 +33,9 @@ declare const props: Schema.Struct<{
|
|
|
30
33
|
readonly multiple: Schema.optional<Schema.Boolean>;
|
|
31
34
|
readonly name: Schema.String;
|
|
32
35
|
readonly required: Schema.optional<Schema.Boolean>;
|
|
36
|
+
readonly showImageThumbnails: Schema.optionalKey<Schema.Boolean>;
|
|
33
37
|
readonly title: Schema.String;
|
|
38
|
+
readonly showAcceptHint: Schema.optionalKey<Schema.Boolean>;
|
|
34
39
|
}>;
|
|
35
40
|
export type FileInputProps = typeof props.Type;
|
|
36
41
|
export declare const FileInput: Component.Component<"FilePicker", {
|
|
@@ -64,7 +69,9 @@ export declare const FileInput: Component.Component<"FilePicker", {
|
|
|
64
69
|
readonly multiple?: boolean | undefined;
|
|
65
70
|
readonly name: string;
|
|
66
71
|
readonly required?: boolean | undefined;
|
|
72
|
+
readonly showImageThumbnails?: boolean | undefined;
|
|
67
73
|
readonly title: string;
|
|
74
|
+
readonly showAcceptHint?: boolean | undefined;
|
|
68
75
|
}, number, {
|
|
69
76
|
readonly _tag: "Blurred";
|
|
70
77
|
} | {
|
|
@@ -92,4 +99,4 @@ export declare const FileInput: Component.Component<"FilePicker", {
|
|
|
92
99
|
} | {
|
|
93
100
|
readonly _tag: "FilesChange";
|
|
94
101
|
readonly files: Redacted.Redacted<readonly File[]>;
|
|
95
|
-
}, never, Html.Elements, {},
|
|
102
|
+
}, never, Html.Elements, {}, "actions">;
|
|
@@ -13,9 +13,30 @@ import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/htm
|
|
|
13
13
|
import {
|
|
14
14
|
CloudUpload as UploadIcon,
|
|
15
15
|
File as FileIcon,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
Captions,
|
|
17
|
+
Binary,
|
|
18
|
+
BookOpen,
|
|
19
|
+
Box,
|
|
20
|
+
CalendarDays,
|
|
21
|
+
Contact,
|
|
22
|
+
Database,
|
|
23
|
+
Disc3,
|
|
24
|
+
FileCode,
|
|
25
|
+
FileJson,
|
|
26
|
+
FileTerminal,
|
|
27
|
+
FileType,
|
|
28
|
+
Globe,
|
|
29
|
+
Mail,
|
|
30
|
+
Package,
|
|
31
|
+
Presentation,
|
|
32
|
+
FileArchive,
|
|
33
|
+
FileAudio,
|
|
34
|
+
FileImage,
|
|
35
|
+
FileSpreadsheet,
|
|
36
|
+
FileText,
|
|
37
|
+
FileVideo,
|
|
38
|
+
FileUp as ChooseIcon,
|
|
39
|
+
X as RemoveIcon
|
|
19
40
|
} from "@krak-stack/registry/lucide-effect";
|
|
20
41
|
|
|
21
42
|
// ../../src/lib/utils.ts
|
|
@@ -23,13 +44,115 @@ import { cn } from "cn";
|
|
|
23
44
|
|
|
24
45
|
// ../../src/components/file-input/classes.ts
|
|
25
46
|
var fileInputClasses = {
|
|
26
|
-
root: "grid min-w-0 gap-3"
|
|
47
|
+
root: "grid min-w-0 grid-cols-1 gap-3"
|
|
27
48
|
};
|
|
28
49
|
var resolveFileInputClasses = (overrides) => ({
|
|
29
50
|
...fileInputClasses,
|
|
30
51
|
...overrides
|
|
31
52
|
});
|
|
32
53
|
|
|
54
|
+
// ../../src/components/file-input/file-type.ts
|
|
55
|
+
var fileType = (mimeType) => {
|
|
56
|
+
const type = mimeType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
57
|
+
if (!type || type === "application/octet-stream")
|
|
58
|
+
return "file";
|
|
59
|
+
if (type.startsWith("image/"))
|
|
60
|
+
return "image";
|
|
61
|
+
if (type.startsWith("video/"))
|
|
62
|
+
return "video";
|
|
63
|
+
if (type.startsWith("audio/"))
|
|
64
|
+
return "audio";
|
|
65
|
+
if (type.startsWith("font/"))
|
|
66
|
+
return "font";
|
|
67
|
+
if (type.startsWith("model/"))
|
|
68
|
+
return "model";
|
|
69
|
+
if (type.startsWith("message/"))
|
|
70
|
+
return "mail";
|
|
71
|
+
if (type.endsWith("+json") || type === "application/json")
|
|
72
|
+
return "json";
|
|
73
|
+
if (type.includes("spreadsheet") || type.includes("ms-excel"))
|
|
74
|
+
return "spreadsheet";
|
|
75
|
+
if (type.includes("presentation") || type.includes("ms-powerpoint"))
|
|
76
|
+
return "presentation";
|
|
77
|
+
switch (type) {
|
|
78
|
+
case "text/vtt":
|
|
79
|
+
case "application/x-subrip":
|
|
80
|
+
case "application/ttml+xml":
|
|
81
|
+
return "caption";
|
|
82
|
+
case "application/zip":
|
|
83
|
+
case "application/x-zip-compressed":
|
|
84
|
+
case "application/x-7z-compressed":
|
|
85
|
+
case "application/vnd.rar":
|
|
86
|
+
case "application/x-rar-compressed":
|
|
87
|
+
case "application/x-tar":
|
|
88
|
+
case "application/gzip":
|
|
89
|
+
case "application/x-gzip":
|
|
90
|
+
case "application/x-bzip2":
|
|
91
|
+
case "application/x-xz":
|
|
92
|
+
case "application/zstd":
|
|
93
|
+
return "archive";
|
|
94
|
+
case "text/csv":
|
|
95
|
+
case "text/tab-separated-values":
|
|
96
|
+
return "spreadsheet";
|
|
97
|
+
case "text/html":
|
|
98
|
+
case "application/xhtml+xml":
|
|
99
|
+
return "web";
|
|
100
|
+
case "text/css":
|
|
101
|
+
case "text/javascript":
|
|
102
|
+
case "application/javascript":
|
|
103
|
+
case "text/typescript":
|
|
104
|
+
case "application/typescript":
|
|
105
|
+
case "application/yaml":
|
|
106
|
+
case "text/yaml":
|
|
107
|
+
case "application/toml":
|
|
108
|
+
return "code";
|
|
109
|
+
case "application/x-sh":
|
|
110
|
+
case "text/x-shellscript":
|
|
111
|
+
case "application/x-bat":
|
|
112
|
+
return "script";
|
|
113
|
+
case "application/sql":
|
|
114
|
+
case "application/vnd.sqlite3":
|
|
115
|
+
case "application/x-sqlite3":
|
|
116
|
+
return "database";
|
|
117
|
+
case "application/epub+zip":
|
|
118
|
+
case "application/x-mobipocket-ebook":
|
|
119
|
+
case "application/vnd.amazon.ebook":
|
|
120
|
+
return "book";
|
|
121
|
+
case "application/x-iso9660-image":
|
|
122
|
+
case "application/x-apple-diskimage":
|
|
123
|
+
return "disc";
|
|
124
|
+
case "application/vnd.android.package-archive":
|
|
125
|
+
case "application/x-debian-package":
|
|
126
|
+
case "application/x-rpm":
|
|
127
|
+
case "application/x-msi":
|
|
128
|
+
return "package";
|
|
129
|
+
case "application/wasm":
|
|
130
|
+
case "application/x-msdownload":
|
|
131
|
+
case "application/x-executable":
|
|
132
|
+
return "binary";
|
|
133
|
+
case "application/vnd.ms-fontobject":
|
|
134
|
+
case "application/font-woff":
|
|
135
|
+
case "application/x-font-ttf":
|
|
136
|
+
return "font";
|
|
137
|
+
case "application/vnd.ms-outlook":
|
|
138
|
+
return "mail";
|
|
139
|
+
case "text/calendar":
|
|
140
|
+
return "calendar";
|
|
141
|
+
case "text/vcard":
|
|
142
|
+
case "text/x-vcard":
|
|
143
|
+
return "contact";
|
|
144
|
+
case "application/xml":
|
|
145
|
+
case "text/xml":
|
|
146
|
+
return "code";
|
|
147
|
+
default:
|
|
148
|
+
if (type.endsWith("+xml") || type.startsWith("text/x-"))
|
|
149
|
+
return "code";
|
|
150
|
+
if (type.startsWith("text/") || type.includes("word") || type === "application/pdf" || type === "application/rtf")
|
|
151
|
+
return "document";
|
|
152
|
+
return "file";
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
33
156
|
// ../../src/components/file-input/index.ts
|
|
34
157
|
import { Redacted, Schema as Schema2 } from "effect";
|
|
35
158
|
import { Component, UiSchema } from "effect/ui";
|
|
@@ -65,7 +188,8 @@ var FilePickerPropsSchema = Schema.Struct({
|
|
|
65
188
|
}).annotate({ identifier: "FilePickerMessageOverrides" }))),
|
|
66
189
|
multiple: Schema.optional(Schema.Boolean),
|
|
67
190
|
name: Schema.String,
|
|
68
|
-
required: Schema.optional(Schema.Boolean)
|
|
191
|
+
required: Schema.optional(Schema.Boolean),
|
|
192
|
+
showImageThumbnails: Schema.optionalKey(Schema.Boolean)
|
|
69
193
|
}).annotate({ identifier: "FilePickerProps" });
|
|
70
194
|
|
|
71
195
|
// ../../src/components/file-input/index.ts
|
|
@@ -170,6 +294,33 @@ var filePickerBehaviours = {
|
|
|
170
294
|
};
|
|
171
295
|
|
|
172
296
|
// ../../src/components/file-input/html.ts
|
|
297
|
+
var fileIcons = {
|
|
298
|
+
file: FileIcon,
|
|
299
|
+
archive: FileArchive,
|
|
300
|
+
binary: Binary,
|
|
301
|
+
book: BookOpen,
|
|
302
|
+
calendar: CalendarDays,
|
|
303
|
+
code: FileCode,
|
|
304
|
+
contact: Contact,
|
|
305
|
+
database: Database,
|
|
306
|
+
disc: Disc3,
|
|
307
|
+
font: FileType,
|
|
308
|
+
json: FileJson,
|
|
309
|
+
mail: Mail,
|
|
310
|
+
model: Box,
|
|
311
|
+
package: Package,
|
|
312
|
+
presentation: Presentation,
|
|
313
|
+
script: FileTerminal,
|
|
314
|
+
web: Globe,
|
|
315
|
+
image: FileImage,
|
|
316
|
+
video: FileVideo,
|
|
317
|
+
audio: FileAudio,
|
|
318
|
+
caption: Captions,
|
|
319
|
+
spreadsheet: FileSpreadsheet,
|
|
320
|
+
document: FileText
|
|
321
|
+
};
|
|
322
|
+
var fileTypeIconRenderer = (mimeType) => fileIcons[fileType(mimeType)];
|
|
323
|
+
var FileTypeIcon = (h, mimeType) => fileTypeIconRenderer(mimeType)(h, { size: 18 });
|
|
173
324
|
var PreviewFile = Mount.make("FilePickerPreviewFile", { args: { file: Schema3.Redacted(Schema3.File) } }, (image, _, changes) => Effect.gen(function* () {
|
|
174
325
|
let url;
|
|
175
326
|
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
@@ -184,13 +335,16 @@ var PreviewFile = Mount.make("FilePickerPreviewFile", { args: { file: Schema3.Re
|
|
|
184
335
|
})));
|
|
185
336
|
return Component2.noop;
|
|
186
337
|
}));
|
|
338
|
+
var FileThumbnail = (h, file) => fileType(file.type) === "image" ? h.img.class("size-9 shrink-0 rounded-md object-cover").attr("alt", "").onMount(PreviewFile({ file: Redacted2.make(file) })) : FileTypeIcon(h, file.type);
|
|
187
339
|
var props = Schema3.Struct({
|
|
188
340
|
...filePickerOptions.props.fields,
|
|
189
|
-
title: Schema3.String
|
|
341
|
+
title: Schema3.String,
|
|
342
|
+
showAcceptHint: Schema3.optionalKey(Schema3.Boolean)
|
|
190
343
|
}).annotate({ identifier: "FilePickerHtmlProps" });
|
|
191
344
|
var FileInput = Html.component({
|
|
192
345
|
...filePickerOptions,
|
|
193
346
|
props,
|
|
347
|
+
slots: ["actions"],
|
|
194
348
|
reads: { localeConfig: krakstackLocaleRead }
|
|
195
349
|
}).make({
|
|
196
350
|
...filePickerBehaviours,
|
|
@@ -200,9 +354,10 @@ var FileInput = Html.component({
|
|
|
200
354
|
const locale = p.locale ?? h.reads.localeConfig?.locale ?? "en";
|
|
201
355
|
const copy = filePickerMessages(locale, p.messages);
|
|
202
356
|
const files = p.files ?? [];
|
|
357
|
+
const icon = (file) => file && p.showImageThumbnails ? FileThumbnail(h, file) : FileTypeIcon(h, file?.type ?? "");
|
|
203
358
|
const selected = !p.multiple && Boolean(p.file ?? p.image?.src);
|
|
204
|
-
const inputLabel =
|
|
205
|
-
const chooser = h.label.class(cn(buttonVariants(
|
|
359
|
+
const inputLabel = p.multiple ? copy.chooseFiles : copy.chooseFile;
|
|
360
|
+
const chooser = h.label.class(cn(buttonVariants({ variant: "outline" }), "focus-within:ring-ring relative cursor-pointer overflow-hidden focus-within:ring-2")).children(ChooseIcon(h), inputLabel, h.input.id(p.id).class("absolute inset-0 z-10 size-full cursor-pointer opacity-0").attrs({
|
|
206
361
|
type: "file",
|
|
207
362
|
name: p.name,
|
|
208
363
|
accept: p.accept,
|
|
@@ -216,22 +371,25 @@ var FileInput = Html.component({
|
|
|
216
371
|
size: "icon-sm",
|
|
217
372
|
props: { type: "button" },
|
|
218
373
|
onPress
|
|
219
|
-
}).attr("aria-label", label).children(
|
|
374
|
+
}).attr("aria-label", label).children(RemoveIcon(h));
|
|
220
375
|
const attachment = (name, file) => h.div.class("min-w-0 flex-1").children(h.p.class("break-words text-sm font-medium").children(name), file && h.p.class("text-muted-foreground break-words text-xs").children(fileDescription(file, locale)));
|
|
221
376
|
const dropzone = h.div.class(cn(fileDropZoneClass, "min-h-32 min-w-0")).attrs({
|
|
222
377
|
"data-dragging": dragDepth > 0 ? "true" : "false",
|
|
223
378
|
"data-drag-over": dragDepth > 0 ? "" : undefined
|
|
224
|
-
}).dropTarget({ accepts: ["Files"], dropEffect: "copy" }).on("dragenter", FilePickerMessage.DragEntered()).on("dragleave", FilePickerMessage.DragLeft()).on("drop", ({ files }) => FilePickerMessage.Dropped({ files: Redacted2.make(files) })).children(FileDropIcon(h).children(UploadIcon(h)), h.div.class("min-w-0").children(FileDropTitle(h).children(p.multiple ? copy.dropFiles : copy.dropFile), FileDropHint(h, { class: "break-words" }).children(copy.accepts(p.accept ?? ""))), chooser);
|
|
379
|
+
}).dropTarget({ accepts: ["Files"], dropEffect: "copy" }).on("dragenter", FilePickerMessage.DragEntered()).on("dragleave", FilePickerMessage.DragLeft()).on("drop", ({ files }) => FilePickerMessage.Dropped({ files: Redacted2.make(files) })).children(FileDropIcon(h).children(UploadIcon(h)), h.div.class("min-w-0").children(FileDropTitle(h).children(p.multiple ? copy.dropFiles : copy.dropFile), p.showAcceptHint !== false && p.accept && FileDropHint(h, { class: "break-words" }).children(copy.accepts(p.accept ?? ""))), h.div.class("flex flex-wrap items-center justify-center gap-2").children(chooser, h.slots.actions));
|
|
225
380
|
const preview = p.image && (p.file || p.image.src) ? h.img.class("h-auto max-w-full rounded border object-contain").attrs({
|
|
226
381
|
alt: p.image.alt,
|
|
227
382
|
width: String(p.image.width),
|
|
228
383
|
height: String(p.image.height),
|
|
229
384
|
src: p.file ? undefined : p.image.src
|
|
230
385
|
}) : null;
|
|
231
|
-
return h.div.class(fileInputClasses.root).children(selected ? h.div.class("flex flex-wrap items-center gap-3 rounded-lg border p-3").children(preview && p.file ? preview.onMount(PreviewFile({ file: Redacted2.make(p.file) })) : preview ??
|
|
386
|
+
return h.div.class(fileInputClasses.root).children(selected ? h.div.class("flex flex-wrap items-center gap-3 rounded-lg border p-3").children(preview && p.file ? preview.onMount(PreviewFile({ file: Redacted2.make(p.file) })) : preview ?? icon(p.file), attachment(p.file?.name ?? p.title, p.file), p.canClear !== false && remove(`${copy.deleteFile} ${p.title}`, FilePickerMessage.Cleared())) : dropzone, p.multiple && files.length > 0 && h.ul.class("grid gap-2").children(files.map((file, index) => h.li.key(`${filePickerKey(file)}:${index}`).class("flex items-center gap-3 rounded-lg border p-3").children(icon(file), attachment(file.name, file), remove(`${copy.deleteFile} ${file.name}`, FilePickerMessage.Removed({ index }))))));
|
|
232
387
|
}
|
|
233
388
|
});
|
|
234
389
|
export {
|
|
235
390
|
FileInput,
|
|
236
|
-
FilePickerEvents
|
|
391
|
+
FilePickerEvents,
|
|
392
|
+
FileThumbnail,
|
|
393
|
+
FileTypeIcon,
|
|
394
|
+
fileTypeIconRenderer
|
|
237
395
|
};
|
|
@@ -59,6 +59,7 @@ export declare const filePickerOptions: {
|
|
|
59
59
|
readonly multiple: Schema.optional<Schema.Boolean>;
|
|
60
60
|
readonly name: Schema.String;
|
|
61
61
|
readonly required: Schema.optional<Schema.Boolean>;
|
|
62
|
+
readonly showImageThumbnails: Schema.optionalKey<Schema.Boolean>;
|
|
62
63
|
}>;
|
|
63
64
|
readonly model: Schema.Int;
|
|
64
65
|
readonly message: UiSchema.TaggedEnum<{
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { FilePickerSharedProps } from "./schema.js";
|
|
3
3
|
export type { FilePickerMessages, FilePickerMessageOverrides, FilePickerMessageTranslations, } from "./schema.js";
|
|
4
|
+
export declare const FileTypeIcon: ({ mimeType }: {
|
|
5
|
+
mimeType: string;
|
|
6
|
+
}) => import("react").JSX.Element;
|
|
7
|
+
export declare const FileThumbnail: ({ file }: {
|
|
8
|
+
file: File;
|
|
9
|
+
}) => import("react").JSX.Element;
|
|
4
10
|
export type FileInputProps = FilePickerSharedProps & {
|
|
11
|
+
actions?: ReactNode;
|
|
12
|
+
showAcceptHint?: boolean;
|
|
5
13
|
onBlur?: () => void;
|
|
6
14
|
onChange?: (file: File) => void;
|
|
7
15
|
onClear: () => void;
|
|
8
16
|
onFilesChange?: (files: File[]) => void;
|
|
9
17
|
title: ReactNode;
|
|
10
18
|
};
|
|
11
|
-
export declare const FileInput: ({ classes: classOverrides, accept, canClear, file, files, id, image, invalid, locale: localeOverride, messages, multiple, name, onBlur, onChange, onClear, onFilesChange, required, title, }: FileInputProps) => import("react").JSX.Element;
|
|
19
|
+
export declare const FileInput: ({ actions, classes: classOverrides, accept, canClear, file, files, id, image, invalid, locale: localeOverride, messages, multiple, name, onBlur, onChange, onClear, onFilesChange, required, showAcceptHint, showImageThumbnails, title, }: FileInputProps) => import("react").JSX.Element;
|