@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
|
@@ -23,7 +23,34 @@ import {
|
|
|
23
23
|
useRef,
|
|
24
24
|
useState
|
|
25
25
|
} from "react";
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
Binary,
|
|
28
|
+
BookOpen,
|
|
29
|
+
Box,
|
|
30
|
+
CalendarDays,
|
|
31
|
+
Captions,
|
|
32
|
+
CloudUpload,
|
|
33
|
+
FileArchive,
|
|
34
|
+
Contact,
|
|
35
|
+
Database,
|
|
36
|
+
Disc3,
|
|
37
|
+
FileCode,
|
|
38
|
+
FileJson,
|
|
39
|
+
FileTerminal,
|
|
40
|
+
FileType,
|
|
41
|
+
Globe,
|
|
42
|
+
Mail,
|
|
43
|
+
Package,
|
|
44
|
+
Presentation,
|
|
45
|
+
FileIcon,
|
|
46
|
+
FileAudio,
|
|
47
|
+
FileImage,
|
|
48
|
+
FileSpreadsheet,
|
|
49
|
+
FileText,
|
|
50
|
+
FileUp,
|
|
51
|
+
FileVideo,
|
|
52
|
+
X
|
|
53
|
+
} from "lucide-react";
|
|
27
54
|
import { Schema as Schema3 } from "effect";
|
|
28
55
|
import {
|
|
29
56
|
Attachment,
|
|
@@ -41,13 +68,115 @@ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/reac
|
|
|
41
68
|
|
|
42
69
|
// ../../src/components/file-input/classes.ts
|
|
43
70
|
var fileInputClasses = {
|
|
44
|
-
root: "grid min-w-0 gap-3"
|
|
71
|
+
root: "grid min-w-0 grid-cols-1 gap-3"
|
|
45
72
|
};
|
|
46
73
|
var resolveFileInputClasses = (overrides) => ({
|
|
47
74
|
...fileInputClasses,
|
|
48
75
|
...overrides
|
|
49
76
|
});
|
|
50
77
|
|
|
78
|
+
// ../../src/components/file-input/file-type.ts
|
|
79
|
+
var fileType = (mimeType) => {
|
|
80
|
+
const type = mimeType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
81
|
+
if (!type || type === "application/octet-stream")
|
|
82
|
+
return "file";
|
|
83
|
+
if (type.startsWith("image/"))
|
|
84
|
+
return "image";
|
|
85
|
+
if (type.startsWith("video/"))
|
|
86
|
+
return "video";
|
|
87
|
+
if (type.startsWith("audio/"))
|
|
88
|
+
return "audio";
|
|
89
|
+
if (type.startsWith("font/"))
|
|
90
|
+
return "font";
|
|
91
|
+
if (type.startsWith("model/"))
|
|
92
|
+
return "model";
|
|
93
|
+
if (type.startsWith("message/"))
|
|
94
|
+
return "mail";
|
|
95
|
+
if (type.endsWith("+json") || type === "application/json")
|
|
96
|
+
return "json";
|
|
97
|
+
if (type.includes("spreadsheet") || type.includes("ms-excel"))
|
|
98
|
+
return "spreadsheet";
|
|
99
|
+
if (type.includes("presentation") || type.includes("ms-powerpoint"))
|
|
100
|
+
return "presentation";
|
|
101
|
+
switch (type) {
|
|
102
|
+
case "text/vtt":
|
|
103
|
+
case "application/x-subrip":
|
|
104
|
+
case "application/ttml+xml":
|
|
105
|
+
return "caption";
|
|
106
|
+
case "application/zip":
|
|
107
|
+
case "application/x-zip-compressed":
|
|
108
|
+
case "application/x-7z-compressed":
|
|
109
|
+
case "application/vnd.rar":
|
|
110
|
+
case "application/x-rar-compressed":
|
|
111
|
+
case "application/x-tar":
|
|
112
|
+
case "application/gzip":
|
|
113
|
+
case "application/x-gzip":
|
|
114
|
+
case "application/x-bzip2":
|
|
115
|
+
case "application/x-xz":
|
|
116
|
+
case "application/zstd":
|
|
117
|
+
return "archive";
|
|
118
|
+
case "text/csv":
|
|
119
|
+
case "text/tab-separated-values":
|
|
120
|
+
return "spreadsheet";
|
|
121
|
+
case "text/html":
|
|
122
|
+
case "application/xhtml+xml":
|
|
123
|
+
return "web";
|
|
124
|
+
case "text/css":
|
|
125
|
+
case "text/javascript":
|
|
126
|
+
case "application/javascript":
|
|
127
|
+
case "text/typescript":
|
|
128
|
+
case "application/typescript":
|
|
129
|
+
case "application/yaml":
|
|
130
|
+
case "text/yaml":
|
|
131
|
+
case "application/toml":
|
|
132
|
+
return "code";
|
|
133
|
+
case "application/x-sh":
|
|
134
|
+
case "text/x-shellscript":
|
|
135
|
+
case "application/x-bat":
|
|
136
|
+
return "script";
|
|
137
|
+
case "application/sql":
|
|
138
|
+
case "application/vnd.sqlite3":
|
|
139
|
+
case "application/x-sqlite3":
|
|
140
|
+
return "database";
|
|
141
|
+
case "application/epub+zip":
|
|
142
|
+
case "application/x-mobipocket-ebook":
|
|
143
|
+
case "application/vnd.amazon.ebook":
|
|
144
|
+
return "book";
|
|
145
|
+
case "application/x-iso9660-image":
|
|
146
|
+
case "application/x-apple-diskimage":
|
|
147
|
+
return "disc";
|
|
148
|
+
case "application/vnd.android.package-archive":
|
|
149
|
+
case "application/x-debian-package":
|
|
150
|
+
case "application/x-rpm":
|
|
151
|
+
case "application/x-msi":
|
|
152
|
+
return "package";
|
|
153
|
+
case "application/wasm":
|
|
154
|
+
case "application/x-msdownload":
|
|
155
|
+
case "application/x-executable":
|
|
156
|
+
return "binary";
|
|
157
|
+
case "application/vnd.ms-fontobject":
|
|
158
|
+
case "application/font-woff":
|
|
159
|
+
case "application/x-font-ttf":
|
|
160
|
+
return "font";
|
|
161
|
+
case "application/vnd.ms-outlook":
|
|
162
|
+
return "mail";
|
|
163
|
+
case "text/calendar":
|
|
164
|
+
return "calendar";
|
|
165
|
+
case "text/vcard":
|
|
166
|
+
case "text/x-vcard":
|
|
167
|
+
return "contact";
|
|
168
|
+
case "application/xml":
|
|
169
|
+
case "text/xml":
|
|
170
|
+
return "code";
|
|
171
|
+
default:
|
|
172
|
+
if (type.endsWith("+xml") || type.startsWith("text/x-"))
|
|
173
|
+
return "code";
|
|
174
|
+
if (type.startsWith("text/") || type.includes("word") || type === "application/pdf" || type === "application/rtf")
|
|
175
|
+
return "document";
|
|
176
|
+
return "file";
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
51
180
|
// ../../src/components/file-input/index.ts
|
|
52
181
|
import { Redacted, Schema as Schema2 } from "effect";
|
|
53
182
|
import { Component, UiSchema } from "effect/ui";
|
|
@@ -83,7 +212,8 @@ var FilePickerPropsSchema = Schema.Struct({
|
|
|
83
212
|
}).annotate({ identifier: "FilePickerMessageOverrides" }))),
|
|
84
213
|
multiple: Schema.optional(Schema.Boolean),
|
|
85
214
|
name: Schema.String,
|
|
86
|
-
required: Schema.optional(Schema.Boolean)
|
|
215
|
+
required: Schema.optional(Schema.Boolean),
|
|
216
|
+
showImageThumbnails: Schema.optionalKey(Schema.Boolean)
|
|
87
217
|
}).annotate({ identifier: "FilePickerProps" });
|
|
88
218
|
|
|
89
219
|
// ../../src/components/file-input/index.ts
|
|
@@ -190,10 +320,64 @@ var filePickerBehaviours = {
|
|
|
190
320
|
// ../../src/components/file-input/react.tsx
|
|
191
321
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
192
322
|
"use client";
|
|
323
|
+
var fileIcons = {
|
|
324
|
+
file: FileIcon,
|
|
325
|
+
archive: FileArchive,
|
|
326
|
+
binary: Binary,
|
|
327
|
+
book: BookOpen,
|
|
328
|
+
calendar: CalendarDays,
|
|
329
|
+
code: FileCode,
|
|
330
|
+
contact: Contact,
|
|
331
|
+
database: Database,
|
|
332
|
+
disc: Disc3,
|
|
333
|
+
font: FileType,
|
|
334
|
+
json: FileJson,
|
|
335
|
+
mail: Mail,
|
|
336
|
+
model: Box,
|
|
337
|
+
package: Package,
|
|
338
|
+
presentation: Presentation,
|
|
339
|
+
script: FileTerminal,
|
|
340
|
+
web: Globe,
|
|
341
|
+
image: FileImage,
|
|
342
|
+
video: FileVideo,
|
|
343
|
+
audio: FileAudio,
|
|
344
|
+
caption: Captions,
|
|
345
|
+
spreadsheet: FileSpreadsheet,
|
|
346
|
+
document: FileText
|
|
347
|
+
};
|
|
348
|
+
var FileTypeIcon = ({ mimeType }) => {
|
|
349
|
+
const Icon = fileIcons[fileType(mimeType)];
|
|
350
|
+
return /* @__PURE__ */ jsx(Icon, {
|
|
351
|
+
"aria-hidden": "true"
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
var FileThumbnail = ({ file }) => {
|
|
355
|
+
const image = useRef(null);
|
|
356
|
+
const isImage = fileType(file.type) === "image";
|
|
357
|
+
useEffect(() => {
|
|
358
|
+
const element = image.current;
|
|
359
|
+
if (!element || typeof URL.createObjectURL !== "function")
|
|
360
|
+
return;
|
|
361
|
+
const url = URL.createObjectURL(file);
|
|
362
|
+
element.src = url;
|
|
363
|
+
return () => {
|
|
364
|
+
element.removeAttribute("src");
|
|
365
|
+
URL.revokeObjectURL(url);
|
|
366
|
+
};
|
|
367
|
+
}, [file, isImage]);
|
|
368
|
+
return isImage ? /* @__PURE__ */ jsx("img", {
|
|
369
|
+
ref: image,
|
|
370
|
+
alt: "",
|
|
371
|
+
className: "size-9 shrink-0 rounded-md object-cover"
|
|
372
|
+
}) : /* @__PURE__ */ jsx(FileTypeIcon, {
|
|
373
|
+
mimeType: file.type
|
|
374
|
+
});
|
|
375
|
+
};
|
|
193
376
|
var FileInput = ({
|
|
377
|
+
actions,
|
|
194
378
|
classes: classOverrides,
|
|
195
379
|
accept = "",
|
|
196
|
-
canClear =
|
|
380
|
+
canClear = true,
|
|
197
381
|
file,
|
|
198
382
|
files = [],
|
|
199
383
|
id,
|
|
@@ -208,6 +392,8 @@ var FileInput = ({
|
|
|
208
392
|
onClear,
|
|
209
393
|
onFilesChange,
|
|
210
394
|
required,
|
|
395
|
+
showAcceptHint = true,
|
|
396
|
+
showImageThumbnails,
|
|
211
397
|
title
|
|
212
398
|
}) => {
|
|
213
399
|
const fileInputClasses = resolveFileInputClasses(classOverrides);
|
|
@@ -247,80 +433,92 @@ var FileInput = ({
|
|
|
247
433
|
const input = /* @__PURE__ */ jsx(Input, {
|
|
248
434
|
ref: inputRef,
|
|
249
435
|
className: "sr-only",
|
|
436
|
+
hidden: !multiple && selected,
|
|
250
437
|
id,
|
|
251
438
|
name,
|
|
252
439
|
type: "file",
|
|
253
440
|
accept,
|
|
254
441
|
multiple,
|
|
255
|
-
required: required && (
|
|
442
|
+
required: required && (multiple ? files.length === 0 : !selected),
|
|
256
443
|
onBlur,
|
|
257
444
|
onChange: (event) => {
|
|
258
445
|
if (event.target.files)
|
|
259
446
|
selectFiles(event.target.files);
|
|
260
|
-
if (multiple)
|
|
447
|
+
if (multiple || !name)
|
|
261
448
|
event.target.value = "";
|
|
262
449
|
},
|
|
263
450
|
"aria-invalid": invalid
|
|
264
451
|
});
|
|
452
|
+
const dropzone = /* @__PURE__ */ jsxs("div", {
|
|
453
|
+
className: "bg-muted/30 data-[dragging=true]:bg-muted flex min-h-32 min-w-0 flex-col items-center justify-center gap-3 rounded-xl border border-dashed p-6 text-center transition-colors",
|
|
454
|
+
"data-dragging": dragging,
|
|
455
|
+
onDragEnter: (event) => {
|
|
456
|
+
event.preventDefault();
|
|
457
|
+
dragDepthRef.current += 1;
|
|
458
|
+
setDragging(true);
|
|
459
|
+
},
|
|
460
|
+
onDragLeave: (event) => {
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
|
|
463
|
+
if (dragDepthRef.current === 0)
|
|
464
|
+
setDragging(false);
|
|
465
|
+
},
|
|
466
|
+
onDragOver: (event) => event.preventDefault(),
|
|
467
|
+
onDrop: handleDrop,
|
|
468
|
+
children: [
|
|
469
|
+
/* @__PURE__ */ jsx(CloudUpload, {
|
|
470
|
+
className: "text-muted-foreground size-6"
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ jsxs("div", {
|
|
473
|
+
className: "max-w-full min-w-0",
|
|
474
|
+
children: [
|
|
475
|
+
/* @__PURE__ */ jsx("p", {
|
|
476
|
+
className: "text-sm font-medium",
|
|
477
|
+
children: multiple ? labels.dropFiles : labels.dropFile
|
|
478
|
+
}),
|
|
479
|
+
showAcceptHint && accept && /* @__PURE__ */ jsx("p", {
|
|
480
|
+
className: "text-muted-foreground text-xs [overflow-wrap:anywhere]",
|
|
481
|
+
children: labels.accepts(accept)
|
|
482
|
+
})
|
|
483
|
+
]
|
|
484
|
+
}),
|
|
485
|
+
/* @__PURE__ */ jsxs("div", {
|
|
486
|
+
className: "flex flex-wrap items-center justify-center gap-2",
|
|
487
|
+
children: [
|
|
488
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
489
|
+
type: "button",
|
|
490
|
+
variant: "outline",
|
|
491
|
+
onClick: () => inputRef.current?.click(),
|
|
492
|
+
children: [
|
|
493
|
+
/* @__PURE__ */ jsx(FileUp, {
|
|
494
|
+
"data-icon": "inline-start"
|
|
495
|
+
}),
|
|
496
|
+
multiple ? labels.chooseFiles : labels.chooseFile
|
|
497
|
+
]
|
|
498
|
+
}),
|
|
499
|
+
actions
|
|
500
|
+
]
|
|
501
|
+
})
|
|
502
|
+
]
|
|
503
|
+
});
|
|
265
504
|
if (multiple) {
|
|
266
505
|
return /* @__PURE__ */ jsxs("div", {
|
|
267
506
|
className: fileInputClasses.root,
|
|
268
507
|
children: [
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
"data-dragging": dragging,
|
|
272
|
-
onDragEnter: (event) => {
|
|
273
|
-
event.preventDefault();
|
|
274
|
-
dragDepthRef.current += 1;
|
|
275
|
-
setDragging(true);
|
|
276
|
-
},
|
|
277
|
-
onDragLeave: (event) => {
|
|
278
|
-
event.preventDefault();
|
|
279
|
-
dragDepthRef.current -= 1;
|
|
280
|
-
if (dragDepthRef.current <= 0) {
|
|
281
|
-
dragDepthRef.current = 0;
|
|
282
|
-
setDragging(false);
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
onDragOver: (event) => event.preventDefault(),
|
|
286
|
-
onDrop: handleDrop,
|
|
287
|
-
children: [
|
|
288
|
-
/* @__PURE__ */ jsx(CloudUpload, {
|
|
289
|
-
className: "text-muted-foreground size-6"
|
|
290
|
-
}),
|
|
291
|
-
/* @__PURE__ */ jsxs("div", {
|
|
292
|
-
className: "max-w-full min-w-0",
|
|
293
|
-
children: [
|
|
294
|
-
/* @__PURE__ */ jsx("p", {
|
|
295
|
-
className: "text-sm font-medium",
|
|
296
|
-
children: labels.dropFiles
|
|
297
|
-
}),
|
|
298
|
-
/* @__PURE__ */ jsx("p", {
|
|
299
|
-
className: "text-muted-foreground max-w-full text-xs [overflow-wrap:anywhere]",
|
|
300
|
-
children: labels.accepts(accept)
|
|
301
|
-
})
|
|
302
|
-
]
|
|
303
|
-
}),
|
|
304
|
-
/* @__PURE__ */ jsxs(Button, {
|
|
305
|
-
type: "button",
|
|
306
|
-
variant: "outline",
|
|
307
|
-
onClick: () => inputRef.current?.click(),
|
|
308
|
-
children: [
|
|
309
|
-
/* @__PURE__ */ jsx(FileUp, {
|
|
310
|
-
"data-icon": "inline-start"
|
|
311
|
-
}),
|
|
312
|
-
labels.chooseFiles
|
|
313
|
-
]
|
|
314
|
-
}),
|
|
315
|
-
input
|
|
316
|
-
]
|
|
317
|
-
}),
|
|
508
|
+
dropzone,
|
|
509
|
+
input,
|
|
318
510
|
files.length > 0 ? /* @__PURE__ */ jsx(AttachmentGroup, {
|
|
511
|
+
className: "w-full px-1 focus-within:mask-none",
|
|
319
512
|
children: files.map((selectedFile) => /* @__PURE__ */ jsxs(Attachment, {
|
|
513
|
+
className: "focus-within:ring-0",
|
|
320
514
|
state: invalid ? "error" : "idle",
|
|
321
515
|
children: [
|
|
322
516
|
/* @__PURE__ */ jsx(AttachmentMedia, {
|
|
323
|
-
children: /* @__PURE__ */ jsx(
|
|
517
|
+
children: showImageThumbnails ? /* @__PURE__ */ jsx(FileThumbnail, {
|
|
518
|
+
file: selectedFile
|
|
519
|
+
}) : /* @__PURE__ */ jsx(FileTypeIcon, {
|
|
520
|
+
mimeType: selectedFile.type
|
|
521
|
+
})
|
|
324
522
|
}),
|
|
325
523
|
/* @__PURE__ */ jsxs(AttachmentContent, {
|
|
326
524
|
children: [
|
|
@@ -337,7 +535,9 @@ var FileInput = ({
|
|
|
337
535
|
type: "button",
|
|
338
536
|
"aria-label": `${labels.deleteFile} ${selectedFile.name}`,
|
|
339
537
|
onClick: () => onFilesChange?.(files.filter((candidate) => candidate !== selectedFile)),
|
|
340
|
-
children: /* @__PURE__ */ jsx(
|
|
538
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
539
|
+
"aria-hidden": "true"
|
|
540
|
+
})
|
|
341
541
|
})
|
|
342
542
|
})
|
|
343
543
|
]
|
|
@@ -346,60 +546,10 @@ var FileInput = ({
|
|
|
346
546
|
]
|
|
347
547
|
});
|
|
348
548
|
}
|
|
349
|
-
if (!selected) {
|
|
350
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
351
|
-
className: "bg-muted/30 data-[dragging=true]:bg-muted flex min-h-32 flex-col items-center justify-center gap-3 rounded-xl border border-dashed p-6 text-center transition-colors",
|
|
352
|
-
"data-dragging": dragging,
|
|
353
|
-
onDragEnter: (event) => {
|
|
354
|
-
event.preventDefault();
|
|
355
|
-
dragDepthRef.current += 1;
|
|
356
|
-
setDragging(true);
|
|
357
|
-
},
|
|
358
|
-
onDragLeave: (event) => {
|
|
359
|
-
event.preventDefault();
|
|
360
|
-
dragDepthRef.current -= 1;
|
|
361
|
-
if (dragDepthRef.current <= 0) {
|
|
362
|
-
dragDepthRef.current = 0;
|
|
363
|
-
setDragging(false);
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
onDragOver: (event) => event.preventDefault(),
|
|
367
|
-
onDrop: handleDrop,
|
|
368
|
-
children: [
|
|
369
|
-
/* @__PURE__ */ jsx(CloudUpload, {
|
|
370
|
-
className: "text-muted-foreground size-6"
|
|
371
|
-
}),
|
|
372
|
-
/* @__PURE__ */ jsxs("div", {
|
|
373
|
-
children: [
|
|
374
|
-
/* @__PURE__ */ jsx("p", {
|
|
375
|
-
className: "text-sm font-medium",
|
|
376
|
-
children: labels.dropFile
|
|
377
|
-
}),
|
|
378
|
-
/* @__PURE__ */ jsx("p", {
|
|
379
|
-
className: "text-muted-foreground text-xs",
|
|
380
|
-
children: labels.accepts(accept)
|
|
381
|
-
})
|
|
382
|
-
]
|
|
383
|
-
}),
|
|
384
|
-
/* @__PURE__ */ jsxs(Button, {
|
|
385
|
-
type: "button",
|
|
386
|
-
variant: "outline",
|
|
387
|
-
onClick: () => inputRef.current?.click(),
|
|
388
|
-
children: [
|
|
389
|
-
/* @__PURE__ */ jsx(FileUp, {
|
|
390
|
-
"data-icon": "inline-start"
|
|
391
|
-
}),
|
|
392
|
-
labels.chooseFile
|
|
393
|
-
]
|
|
394
|
-
}),
|
|
395
|
-
input
|
|
396
|
-
]
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
549
|
return /* @__PURE__ */ jsxs(Fragment, {
|
|
400
550
|
children: [
|
|
401
|
-
/* @__PURE__ */ jsxs(Attachment, {
|
|
402
|
-
className: "w-full",
|
|
551
|
+
!selected ? dropzone : /* @__PURE__ */ jsxs(Attachment, {
|
|
552
|
+
className: "w-full focus-within:ring-0",
|
|
403
553
|
orientation: "horizontal",
|
|
404
554
|
state: invalid ? "error" : "done",
|
|
405
555
|
children: [
|
|
@@ -416,7 +566,11 @@ var FileInput = ({
|
|
|
416
566
|
width: image.width,
|
|
417
567
|
height: image.height,
|
|
418
568
|
className: "size-full object-contain"
|
|
419
|
-
}) : /* @__PURE__ */ jsx(
|
|
569
|
+
}) : file && showImageThumbnails ? /* @__PURE__ */ jsx(FileThumbnail, {
|
|
570
|
+
file
|
|
571
|
+
}) : /* @__PURE__ */ jsx(FileTypeIcon, {
|
|
572
|
+
mimeType: file?.type ?? ""
|
|
573
|
+
})
|
|
420
574
|
}),
|
|
421
575
|
/* @__PURE__ */ jsxs(AttachmentContent, {
|
|
422
576
|
children: [
|
|
@@ -429,22 +583,16 @@ var FileInput = ({
|
|
|
429
583
|
}) : null
|
|
430
584
|
]
|
|
431
585
|
}),
|
|
432
|
-
/* @__PURE__ */
|
|
433
|
-
className: "ml-auto
|
|
434
|
-
children:
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
})
|
|
441
|
-
|
|
442
|
-
type: "button",
|
|
443
|
-
"aria-label": `${labels.deleteFile} ${Schema3.is(Schema3.String)(title) ? title : ""}`,
|
|
444
|
-
onClick: clear,
|
|
445
|
-
children: /* @__PURE__ */ jsx(Trash2, {})
|
|
446
|
-
}) : null
|
|
447
|
-
]
|
|
586
|
+
canClear && /* @__PURE__ */ jsx(AttachmentActions, {
|
|
587
|
+
className: "ml-auto",
|
|
588
|
+
children: /* @__PURE__ */ jsx(AttachmentAction, {
|
|
589
|
+
type: "button",
|
|
590
|
+
"aria-label": `${labels.deleteFile} ${Schema3.is(Schema3.String)(title) ? title : ""}`,
|
|
591
|
+
onClick: clear,
|
|
592
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
593
|
+
"aria-hidden": "true"
|
|
594
|
+
})
|
|
595
|
+
})
|
|
448
596
|
})
|
|
449
597
|
]
|
|
450
598
|
}),
|
|
@@ -479,12 +627,13 @@ import { Textarea } from "@/components/ui/textarea";
|
|
|
479
627
|
// ../../src/components/virtualized-combobox/react.tsx
|
|
480
628
|
import { Combobox as ComboboxPrimitive } from "@base-ui/react";
|
|
481
629
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
482
|
-
import { Check, ChevronsUpDown, X } from "lucide-react";
|
|
630
|
+
import { Check, ChevronsUpDown, X as X2 } from "lucide-react";
|
|
483
631
|
import {
|
|
484
632
|
useCallback,
|
|
485
633
|
useEffect as useEffect2,
|
|
486
634
|
useImperativeHandle,
|
|
487
|
-
useRef as useRef2
|
|
635
|
+
useRef as useRef2,
|
|
636
|
+
useState as useState2
|
|
488
637
|
} from "react";
|
|
489
638
|
import { Button as Button2 } from "@/components/ui/button";
|
|
490
639
|
import { InputGroup, InputGroupInput } from "@/components/ui/input-group";
|
|
@@ -497,8 +646,15 @@ import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/
|
|
|
497
646
|
|
|
498
647
|
// ../../src/components/virtualized-combobox/classes.ts
|
|
499
648
|
var virtualizedComboboxClasses = {
|
|
500
|
-
itemLabel: "min-w-0 truncate"
|
|
649
|
+
itemLabel: "min-w-0 truncate",
|
|
650
|
+
groupLabel: "text-muted-foreground px-2 pt-3 pb-1 text-start text-xs",
|
|
651
|
+
itemContent: "flex min-w-0 flex-1 items-center gap-2 text-start",
|
|
652
|
+
itemMedia: "bg-muted grid size-8 shrink-0 place-items-center overflow-hidden rounded-md [&_svg]:size-4",
|
|
653
|
+
itemImage: "size-full object-cover",
|
|
654
|
+
itemDescription: "text-muted-foreground block truncate text-xs"
|
|
501
655
|
};
|
|
656
|
+
var virtualizedComboboxGroupHeight = 36;
|
|
657
|
+
var virtualizedComboboxDetailHeight = 52;
|
|
502
658
|
var resolveVirtualizedComboboxClasses = (overrides) => ({
|
|
503
659
|
...virtualizedComboboxClasses,
|
|
504
660
|
...overrides
|
|
@@ -509,10 +665,14 @@ import { Schema as Schema5 } from "effect";
|
|
|
509
665
|
import { Component as Component2, UiSchema as UiSchema2 } from "effect/ui";
|
|
510
666
|
|
|
511
667
|
// ../../src/components/virtualized-combobox/schema.ts
|
|
512
|
-
import { Schema as Schema4, Struct as Struct2 } from "effect";
|
|
668
|
+
import { Predicate, Schema as Schema4, Struct as Struct2 } from "effect";
|
|
669
|
+
var Icon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
|
|
513
670
|
var VirtualizedComboboxOptionSchema = Schema4.Struct({
|
|
514
671
|
value: Schema4.String.pipe(Schema4.mutableKey),
|
|
515
|
-
label: Schema4.String.pipe(Schema4.mutableKey)
|
|
672
|
+
label: Schema4.String.pipe(Schema4.mutableKey),
|
|
673
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
674
|
+
imageSrc: Schema4.optionalKey(Schema4.String),
|
|
675
|
+
icon: Schema4.optionalKey(Icon)
|
|
516
676
|
}).annotate({ identifier: "VirtualizedComboboxOption" });
|
|
517
677
|
var VirtualizedComboboxLabelsSchema = Schema4.Struct({
|
|
518
678
|
clear: Schema4.optionalKey(Schema4.String),
|
|
@@ -537,6 +697,8 @@ var htmlFields = {
|
|
|
537
697
|
emptyLabel: Schema4.String,
|
|
538
698
|
placeholder: Schema4.String,
|
|
539
699
|
triggerLabel: Schema4.optionalKey(Schema4.String),
|
|
700
|
+
triggerIcon: Schema4.optionalKey(Icon),
|
|
701
|
+
itemHeight: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
540
702
|
filter: Schema4.optionalKey(Schema4.Literals(["contains", "none"])),
|
|
541
703
|
messages: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Struct({
|
|
542
704
|
...VirtualizedComboboxLabelsSchema.fields,
|
|
@@ -626,7 +788,8 @@ var VirtualizedComboboxEvents = UiSchema2.TaggedEnum(events).annotate({
|
|
|
626
788
|
});
|
|
627
789
|
var VirtualizedComboboxMessage = UiSchema2.TaggedEnum({
|
|
628
790
|
...events,
|
|
629
|
-
Highlighted: { value: Schema5.String }
|
|
791
|
+
Highlighted: { value: Schema5.String },
|
|
792
|
+
ImageFailed: { src: Schema5.String }
|
|
630
793
|
}).annotate({ identifier: "VirtualizedComboboxMessage" });
|
|
631
794
|
var virtualizedComboboxOptions = {
|
|
632
795
|
name: "VirtualizedCombobox",
|
|
@@ -634,6 +797,7 @@ var virtualizedComboboxOptions = {
|
|
|
634
797
|
model: Schema5.Struct({
|
|
635
798
|
open: Schema5.Boolean,
|
|
636
799
|
searchValue: Schema5.String,
|
|
800
|
+
failedImages: Schema5.Array(Schema5.String),
|
|
637
801
|
highlight: Schema5.NullOr(Schema5.Struct({ value: Schema5.String, id: Schema5.Int }))
|
|
638
802
|
}).annotate({ identifier: "VirtualizedComboboxModel" }),
|
|
639
803
|
message: VirtualizedComboboxMessage,
|
|
@@ -653,17 +817,24 @@ var update = Component2.define(virtualizedComboboxOptions).update({
|
|
|
653
817
|
ValueChanged: ($, { value }) => $.set($.model).emit(VirtualizedComboboxEvents.ValueChanged({ value })),
|
|
654
818
|
Highlighted: ($, { value }) => $.evolve({
|
|
655
819
|
highlight: { value, id: ($.model.highlight?.id ?? 0) + 1 }
|
|
656
|
-
})
|
|
820
|
+
}),
|
|
821
|
+
ImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] })
|
|
657
822
|
});
|
|
658
823
|
|
|
659
824
|
// ../../src/components/virtualized-combobox/react.tsx
|
|
660
825
|
import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
661
826
|
"use client";
|
|
662
827
|
var optionEquals = (item, selected) => item.value === selected.value;
|
|
828
|
+
var hasOptionDetails = ({
|
|
829
|
+
description,
|
|
830
|
+
imageSrc,
|
|
831
|
+
icon
|
|
832
|
+
}) => Boolean(description || imageSrc || icon);
|
|
663
833
|
var VirtualizedComboboxList = ({
|
|
664
834
|
classes,
|
|
665
835
|
emptyLabel,
|
|
666
836
|
groupSelections,
|
|
837
|
+
itemHeight,
|
|
667
838
|
itemIndexRef,
|
|
668
839
|
locale = "en",
|
|
669
840
|
messages: messageOverrides,
|
|
@@ -676,6 +847,8 @@ var VirtualizedComboboxList = ({
|
|
|
676
847
|
const labels = virtualizedComboboxMessages(locale, messageOverrides);
|
|
677
848
|
const entries = selectionEntries(filteredItems, selectedValues, groupSelections, labels);
|
|
678
849
|
const scrollRef = useRef2(null);
|
|
850
|
+
const [failedImages, setFailedImages] = useState2(() => new Set);
|
|
851
|
+
const rowHeight = itemHeight ?? (filteredItems.some(hasOptionDetails) ? virtualizedComboboxDetailHeight : 36);
|
|
679
852
|
const virtualizer = useVirtualizer({
|
|
680
853
|
count: entries.length,
|
|
681
854
|
getScrollElement: () => scrollRef.current,
|
|
@@ -683,7 +856,7 @@ var VirtualizedComboboxList = ({
|
|
|
683
856
|
const entry = entries[index];
|
|
684
857
|
return entry?.kind === "group" ? `group-${entry.key}` : entry?.item.value ?? index;
|
|
685
858
|
},
|
|
686
|
-
estimateSize: () =>
|
|
859
|
+
estimateSize: (index) => entries[index]?.kind === "group" ? virtualizedComboboxGroupHeight : rowHeight,
|
|
687
860
|
overscan: 8
|
|
688
861
|
});
|
|
689
862
|
useEffect2(() => {
|
|
@@ -725,7 +898,7 @@ var VirtualizedComboboxList = ({
|
|
|
725
898
|
return /* @__PURE__ */ jsx2(ComboboxPrimitive.Group, {
|
|
726
899
|
className: "contents",
|
|
727
900
|
children: /* @__PURE__ */ jsx2(ComboboxPrimitive.GroupLabel, {
|
|
728
|
-
className:
|
|
901
|
+
className: `absolute top-0 left-0 w-full ${virtualizedComboboxClasses.groupLabel}`,
|
|
729
902
|
"data-index": virtualItem.index,
|
|
730
903
|
ref: virtualizer.measureElement,
|
|
731
904
|
style,
|
|
@@ -733,6 +906,8 @@ var VirtualizedComboboxList = ({
|
|
|
733
906
|
})
|
|
734
907
|
}, entry.key);
|
|
735
908
|
}
|
|
909
|
+
const details = entry.item;
|
|
910
|
+
const image = details.imageSrc && !failedImages.has(details.imageSrc) ? details.imageSrc : undefined;
|
|
736
911
|
return /* @__PURE__ */ jsxs2(ComboboxPrimitive.Item, {
|
|
737
912
|
"aria-posinset": entry.index + 1,
|
|
738
913
|
"aria-setsize": filteredItems.length,
|
|
@@ -743,10 +918,38 @@ var VirtualizedComboboxList = ({
|
|
|
743
918
|
style,
|
|
744
919
|
value: entry.item,
|
|
745
920
|
children: [
|
|
746
|
-
renderItem?.(entry.item) ?? /* @__PURE__ */
|
|
921
|
+
renderItem?.(entry.item) ?? (hasOptionDetails(details) ? /* @__PURE__ */ jsxs2("span", {
|
|
922
|
+
className: virtualizedComboboxClasses.itemContent,
|
|
923
|
+
children: [
|
|
924
|
+
(image || details.icon) && /* @__PURE__ */ jsx2("span", {
|
|
925
|
+
"aria-hidden": "true",
|
|
926
|
+
className: virtualizedComboboxClasses.itemMedia,
|
|
927
|
+
children: image ? /* @__PURE__ */ jsx2("img", {
|
|
928
|
+
src: image,
|
|
929
|
+
alt: "",
|
|
930
|
+
loading: "lazy",
|
|
931
|
+
onError: () => setFailedImages((failed) => new Set(failed).add(image)),
|
|
932
|
+
className: virtualizedComboboxClasses.itemImage
|
|
933
|
+
}) : details.icon
|
|
934
|
+
}),
|
|
935
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
936
|
+
className: "min-w-0 flex-1",
|
|
937
|
+
children: [
|
|
938
|
+
/* @__PURE__ */ jsx2("span", {
|
|
939
|
+
className: cn("block", virtualizedComboboxClasses.itemLabel),
|
|
940
|
+
children: entry.item.label
|
|
941
|
+
}),
|
|
942
|
+
details.description && /* @__PURE__ */ jsx2("span", {
|
|
943
|
+
className: virtualizedComboboxClasses.itemDescription,
|
|
944
|
+
children: details.description
|
|
945
|
+
})
|
|
946
|
+
]
|
|
947
|
+
})
|
|
948
|
+
]
|
|
949
|
+
}) : /* @__PURE__ */ jsx2("span", {
|
|
747
950
|
className: virtualizedComboboxClasses.itemLabel,
|
|
748
951
|
children: entry.item.label
|
|
749
|
-
}),
|
|
952
|
+
})),
|
|
750
953
|
/* @__PURE__ */ jsx2(ComboboxPrimitive.ItemIndicator, {
|
|
751
954
|
className: "absolute right-2 flex size-4 items-center justify-center",
|
|
752
955
|
children: /* @__PURE__ */ jsx2(Check, {})
|
|
@@ -764,6 +967,7 @@ var VirtualizedComboboxContent = ({
|
|
|
764
967
|
contentClassName,
|
|
765
968
|
emptyLabel,
|
|
766
969
|
groupSelections,
|
|
970
|
+
itemHeight,
|
|
767
971
|
itemIndexRef,
|
|
768
972
|
locale = "en",
|
|
769
973
|
messages: messageOverrides,
|
|
@@ -795,6 +999,7 @@ var VirtualizedComboboxContent = ({
|
|
|
795
999
|
classes,
|
|
796
1000
|
emptyLabel,
|
|
797
1001
|
groupSelections,
|
|
1002
|
+
itemHeight,
|
|
798
1003
|
itemIndexRef,
|
|
799
1004
|
locale,
|
|
800
1005
|
messages: messageOverrides,
|
|
@@ -829,7 +1034,7 @@ var defaultClear = (label) => /* @__PURE__ */ jsx2(ComboboxPrimitive.Clear, {
|
|
|
829
1034
|
"aria-label": label,
|
|
830
1035
|
className: "text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 absolute top-1/2 right-7 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded-sm outline-none focus-visible:border focus-visible:ring-3",
|
|
831
1036
|
type: "button",
|
|
832
|
-
children: /* @__PURE__ */ jsx2(
|
|
1037
|
+
children: /* @__PURE__ */ jsx2(X2, {
|
|
833
1038
|
className: "size-3.5"
|
|
834
1039
|
})
|
|
835
1040
|
});
|