@alfakit/vue 0.1.0 → 0.1.2
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 +17 -0
- package/dist/components/actions/ActionButton.js.map +1 -1
- package/dist/components/actions/ActionButton.vue.d.ts.map +1 -1
- package/dist/components/actions/ActionButton.vue_vue_type_script_setup_true_lang.js +160 -159
- package/dist/components/actions/ActionButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/actions/ActionModal.js.map +1 -1
- package/dist/components/actions/ActionModal.vue.d.ts.map +1 -1
- package/dist/components/actions/ActionModal.vue_vue_type_script_setup_true_lang.js +214 -214
- package/dist/components/actions/ActionModal.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/cms/CmsLinkButton.vue.d.ts +1 -1
- package/dist/components/fields/ColorPickerField.js.map +1 -1
- package/dist/components/fields/ColorPickerField.vue.d.ts.map +1 -1
- package/dist/components/fields/ColorPickerField.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/components/fields/ColorPickerField.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/fields/ComboboxSelect.js.map +1 -1
- package/dist/components/fields/ComboboxSelect.vue.d.ts.map +1 -1
- package/dist/components/fields/ComboboxSelect.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/fields/ComboboxSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/fields/FileUploadField.js.map +1 -1
- package/dist/components/fields/FileUploadField.vue.d.ts.map +1 -1
- package/dist/components/fields/FileUploadField.vue_vue_type_script_setup_true_lang.js +183 -183
- package/dist/components/fields/FileUploadField.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/fields/OneTimeCodeInputField.js.map +1 -1
- package/dist/components/fields/OneTimeCodeInputField.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/components/fields/OneTimeCodeInputField.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/fields/SelectField.js.map +1 -1
- package/dist/components/fields/SelectField.vue.d.ts.map +1 -1
- package/dist/components/fields/SelectField.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/fields/SelectField.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/fields/TableColumnHeaders.js.map +1 -1
- package/dist/components/fields/TableColumnHeaders.vue.d.ts.map +1 -1
- package/dist/components/fields/TableColumnHeaders.vue_vue_type_script_setup_true_lang.js +6 -3
- package/dist/components/fields/TableColumnHeaders.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/file-manager/FileManagerView.js.map +1 -1
- package/dist/components/file-manager/FileManagerView.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/file-manager/FileManagerView.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form/FormBlock.js.map +1 -1
- package/dist/components/form/FormBlock.vue.d.ts.map +1 -1
- package/dist/components/form/FormBlock.vue_vue_type_script_setup_true_lang.js +81 -77
- package/dist/components/form/FormBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form/form-context.js +25 -25
- package/dist/components/form/form-context.js.map +1 -1
- package/dist/components/layout/FusedGroupComponent.js.map +1 -1
- package/dist/components/layout/FusedGroupComponent.vue.d.ts.map +1 -1
- package/dist/components/layout/FusedGroupComponent.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/components/layout/FusedGroupComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/layout/TabsComponent.js.map +1 -1
- package/dist/components/layout/TabsComponent.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsComponent.vue_vue_type_script_setup_true_lang.js +76 -55
- package/dist/components/layout/TabsComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/notifications/NotificationsMenu.js.map +1 -1
- package/dist/components/notifications/NotificationsMenu.vue.d.ts.map +1 -1
- package/dist/components/notifications/NotificationsMenu.vue_vue_type_script_setup_true_lang.js +44 -42
- package/dist/components/notifications/NotificationsMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/panel/GlobalSearch.js.map +1 -1
- package/dist/components/panel/GlobalSearch.vue.d.ts.map +1 -1
- package/dist/components/panel/GlobalSearch.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/components/panel/GlobalSearch.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/panel/ShortcutKeys.js.map +1 -1
- package/dist/components/panel/ShortcutKeys.vue.d.ts.map +1 -1
- package/dist/components/panel/ShortcutKeys.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/components/panel/ShortcutKeys.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/panel/TenantMenu.js.map +1 -1
- package/dist/components/panel/TenantMenu.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/panel/TenantMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/table/GroupHeaderRow.js.map +1 -1
- package/dist/components/table/GroupHeaderRow.vue.d.ts.map +1 -1
- package/dist/components/table/GroupHeaderRow.vue_vue_type_script_setup_true_lang.js +55 -34
- package/dist/components/table/GroupHeaderRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/table/SelectCell.js.map +1 -1
- package/dist/components/table/SelectCell.vue.d.ts.map +1 -1
- package/dist/components/table/SelectCell.vue_vue_type_script_setup_true_lang.js +24 -19
- package/dist/components/table/SelectCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/table/TextInputCell.js.map +1 -1
- package/dist/components/table/TextInputCell.vue.d.ts.map +1 -1
- package/dist/components/table/TextInputCell.vue_vue_type_script_setup_true_lang.js +38 -33
- package/dist/components/table/TextInputCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components.css +347 -0
- package/dist/eject-manifest.json +2 -2
- package/dist/lib/Icon.js.map +1 -1
- package/dist/lib/Icon.vue.d.ts.map +1 -1
- package/dist/lib/Icon.vue_vue_type_script_setup_true_lang.js +18 -19
- package/dist/lib/Icon.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/lib/hydration.d.ts +9 -0
- package/dist/lib/hydration.d.ts.map +1 -0
- package/dist/lib/hydration.js +17 -0
- package/dist/lib/hydration.js.map +1 -0
- package/dist/lib/icons.d.ts +3 -5
- package/dist/lib/icons.d.ts.map +1 -1
- package/dist/lib/icons.js +19 -22
- package/dist/lib/icons.js.map +1 -1
- package/dist/lib/lazy.d.ts +1 -1
- package/dist/lib/lazy.d.ts.map +1 -1
- package/dist/lib/lazy.js +12 -11
- package/dist/lib/lazy.js.map +1 -1
- package/dist/standalone/AlfakitToaster.js.map +1 -1
- package/dist/standalone/AlfakitToaster.vue.d.ts.map +1 -1
- package/dist/standalone/AlfakitToaster.vue_vue_type_script_setup_true_lang.js +23 -15
- package/dist/standalone/AlfakitToaster.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/standalone.css +47 -0
- package/dist/starter-kit/widgets/SearchTrigger.js.map +1 -1
- package/dist/starter-kit/widgets/SearchTrigger.vue.d.ts.map +1 -1
- package/dist/starter-kit/widgets/SearchTrigger.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/starter-kit/widgets/SearchTrigger.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/starter-kit/widgets/TenantChooser.js.map +1 -1
- package/dist/starter-kit/widgets/TenantChooser.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/starter-kit/widgets/TenantChooser.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/themes.css +2 -334
- package/package.json +3 -3
- package/src/components/actions/ActionButton.vue +14 -6
- package/src/components/actions/ActionModal.vue +3 -1
- package/src/components/fields/ColorPickerField.vue +1 -0
- package/src/components/fields/ComboboxSelect.vue +1 -1
- package/src/components/fields/FileUploadField.vue +14 -11
- package/src/components/fields/OneTimeCodeInputField.vue +1 -1
- package/src/components/fields/SelectField.vue +4 -2
- package/src/components/fields/TableColumnHeaders.vue +6 -1
- package/src/components/file-manager/FileManagerView.vue +1 -1
- package/src/components/form/FormBlock.vue +24 -0
- package/src/components/form/form-context.ts +2 -2
- package/src/components/layout/FusedGroupComponent.vue +1 -0
- package/src/components/layout/TabsComponent.vue +61 -5
- package/src/components/notifications/NotificationsMenu.vue +11 -0
- package/src/components/panel/GlobalSearch.vue +1 -0
- package/src/components/panel/ShortcutKeys.vue +1 -0
- package/src/components/panel/TenantMenu.vue +2 -2
- package/src/components/table/GroupHeaderRow.vue +27 -0
- package/src/components/table/SelectCell.vue +5 -2
- package/src/components/table/TextInputCell.vue +11 -5
- package/src/lib/Icon.vue +6 -5
- package/src/lib/hydration.ts +35 -0
- package/src/lib/icons.ts +6 -11
- package/src/lib/lazy.ts +5 -6
- package/src/standalone/AlfakitToaster.vue +12 -2
- package/src/starter-kit/widgets/SearchTrigger.vue +1 -0
- package/src/starter-kit/widgets/TenantChooser.vue +1 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { useChoice as e,
|
|
2
|
-
import { cn as
|
|
3
|
-
import { useStore as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { useField as
|
|
7
|
-
import { lazyComponent as
|
|
8
|
-
import
|
|
9
|
-
import { canEditImage as
|
|
10
|
-
import { Fragment as
|
|
11
|
-
import { ChevronDownIcon as
|
|
1
|
+
import { useChoice as e, useFormatter as t, usePanel as n, useT as r } from "../../context.js";
|
|
2
|
+
import { cn as i } from "../../lib/utils.js";
|
|
3
|
+
import { useStore as a } from "../../composables/use-store.js";
|
|
4
|
+
import o from "../ui/Button2.js";
|
|
5
|
+
import s from "../ui/Spinner.js";
|
|
6
|
+
import { useField as c, useFormStore as ee } from "../form/form-context.js";
|
|
7
|
+
import { lazyComponent as te } from "../../lib/lazy.js";
|
|
8
|
+
import ne from "../schema/FieldWrapper.js";
|
|
9
|
+
import { canEditImage as re, concurrencyLimiter as ie, cssAspectRatio as ae, editableImageName as oe, fetchEditableImage as se, fieldMemory as l, fileManagerSize as u, fileUploadAccept as ce, fileUploadPaths as le, filesFromClipboard as ue, insertUploadedFile as de, moveRepeaterItem as fe, panelUploadOptions as pe, requestJson as me, transformImage as he, uploadTemporaryFile as ge, uploadedFileLinks as d } from "@alfakit/core";
|
|
10
|
+
import { Fragment as _e, computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createVNode as _, defineComponent as v, normalizeClass as y, normalizeStyle as ve, openBlock as b, ref as x, renderList as ye, shallowRef as be, toDisplayString as S, unref as C, watch as xe, withCtx as w, withKeys as T, withModifiers as E } from "vue";
|
|
11
|
+
import { ChevronDownIcon as Se, ChevronUpIcon as Ce, DownloadIcon as we, ExternalLinkIcon as Te, FileIcon as Ee, PencilIcon as De, UploadCloudIcon as Oe, XIcon as ke } from "@lucide/vue";
|
|
12
12
|
//#region src/components/fields/FileUploadField.vue?vue&type=script&setup=true&lang.ts
|
|
13
|
-
var
|
|
13
|
+
var Ae = ["data-layout"], je = [
|
|
14
14
|
"draggable",
|
|
15
15
|
"onDragstart",
|
|
16
16
|
"onDrop"
|
|
17
|
-
],
|
|
17
|
+
], Me = ["src", "onError"], Ne = {
|
|
18
18
|
key: 4,
|
|
19
19
|
class: "min-w-0 flex-1"
|
|
20
|
-
},
|
|
20
|
+
}, Pe = { class: "truncate font-medium" }, Fe = ["href", "aria-label"], Ie = ["href", "aria-label"], Le = ["data-align", "aria-describedby"], Re = { key: 0 }, ze = {
|
|
21
21
|
key: 1,
|
|
22
22
|
class: "text-muted-foreground text-xs"
|
|
23
|
-
},
|
|
23
|
+
}, Be = [
|
|
24
24
|
"id",
|
|
25
25
|
"aria-invalid",
|
|
26
26
|
"aria-describedby",
|
|
@@ -28,70 +28,70 @@ var Oe = ["data-layout"], ke = [
|
|
|
28
28
|
"multiple",
|
|
29
29
|
"accept",
|
|
30
30
|
"disabled"
|
|
31
|
-
],
|
|
31
|
+
], Ve = te("ImageEditorDialog", () => import("./ImageEditorDialog.js").then((e) => e.default), v({
|
|
32
32
|
name: "ImageEditorDialogLoading",
|
|
33
33
|
render: () => null
|
|
34
|
-
})),
|
|
34
|
+
})), D = /*@__PURE__*/ v({
|
|
35
35
|
__name: "FileUploadField",
|
|
36
36
|
props: { component: {} },
|
|
37
|
-
setup(
|
|
38
|
-
let
|
|
39
|
-
get: () =>
|
|
37
|
+
setup(te) {
|
|
38
|
+
let v = te, D = r(), O = t(), He = e(), k = n(), { value: Ue, setValue: We, error: Ge, id: Ke, disabled: qe, readOnly: Je, aria: A } = c(() => v.component), j = f(() => qe.value || Je.value), M = ee(), N = l(M, `${v.component.statePath}:uploading`, () => []), P = l(M, `${v.component.statePath}:uploaded`, () => []), Ye = a(N), Xe = a(P), F = f({
|
|
39
|
+
get: () => Ye.value,
|
|
40
|
+
set: (e) => N.set(e)
|
|
41
|
+
}), I = f({
|
|
42
|
+
get: () => Xe.value,
|
|
40
43
|
set: (e) => P.set(e)
|
|
41
|
-
}), L =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}), R = S(!1), z = S(null), B = S(null), V = ve(null), Je = S(!1);
|
|
45
|
-
ye(V, (e) => {
|
|
46
|
-
e && (Je.value = !0);
|
|
44
|
+
}), L = x(!1), R = x(null), z = x(null), B = be(null), Ze = x(!1);
|
|
45
|
+
xe(B, (e) => {
|
|
46
|
+
e && (Ze.value = !0);
|
|
47
47
|
});
|
|
48
|
-
let
|
|
49
|
-
|
|
48
|
+
let V = (e) => new Promise((t) => {
|
|
49
|
+
B.value = {
|
|
50
50
|
file: e,
|
|
51
51
|
resolve: (e) => {
|
|
52
|
-
|
|
52
|
+
B.value = null, t(e);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
}),
|
|
56
|
-
e &&
|
|
57
|
-
},
|
|
55
|
+
}), H = l(M, `${v.component.statePath}:previews`, () => /* @__PURE__ */ new Set()).get(), U = (e) => {
|
|
56
|
+
e && H.delete(e) && URL.revokeObjectURL(e);
|
|
57
|
+
}, W = f(() => le(Ue.value)), G = f(() => W.value.map((e) => [...v.component.files, ...I.value].find((t) => t.path === e) ?? {
|
|
58
58
|
path: e,
|
|
59
59
|
name: e.replace(/^tmp:/, "")
|
|
60
|
-
})),
|
|
60
|
+
})), K = f(() => v.component.multiple ? v.component.maxFiles ?? Infinity : 1), Qe = f(() => G.value.length + F.value.length < K.value), q = f(() => v.component.panelLayout === "circle" || v.component.avatar), $e = f(() => v.component.panelLayout === "integrated" && !q.value), et = f(() => v.component.positions?.removeButton === "start"), tt = f(() => v.component.positions?.progressIndicator === "start"), J = f(() => v.component.positions?.uploadButton ?? "center"), Y = (e) => We(v.component.multiple ? e : e[0] ?? null), X = async (e) => {
|
|
61
61
|
let t = k.value.endpoints.upload;
|
|
62
62
|
if (!t) return;
|
|
63
|
-
let n = Array.from(e).slice(0, Math.max(0,
|
|
63
|
+
let n = Array.from(e).slice(0, Math.max(0, K.value - G.value.length - F.value.length)), r = ie(v.component.maxParallelUploads ?? 1), i = [];
|
|
64
64
|
for (let [e, a] of n.entries()) {
|
|
65
|
-
let n = a, o = !!(
|
|
65
|
+
let n = a, o = !!(v.component.imageEditor && re(a));
|
|
66
66
|
if (o) {
|
|
67
|
-
let e = await
|
|
67
|
+
let e = await V(a);
|
|
68
68
|
if (!e) continue;
|
|
69
69
|
n = e;
|
|
70
70
|
}
|
|
71
71
|
let s = await nt(n, o);
|
|
72
72
|
if (!s) continue;
|
|
73
73
|
let c = rt(s, e);
|
|
74
|
-
|
|
74
|
+
F.value = [...F.value, c], i.push(r(() => ot(t, s, c)));
|
|
75
75
|
}
|
|
76
76
|
await Promise.all(i);
|
|
77
77
|
}, nt = async (e, t) => {
|
|
78
|
-
let n =
|
|
79
|
-
aspectRatio: t ? null :
|
|
80
|
-
mode:
|
|
81
|
-
width:
|
|
82
|
-
height:
|
|
83
|
-
orient:
|
|
78
|
+
let n = v.component.imageCropAspectRatio || v.component.imageResizeTargetWidth || v.component.imageResizeTargetHeight || v.component.orientImagesFromExif ? await he(e, {
|
|
79
|
+
aspectRatio: t ? null : v.component.imageCropAspectRatio,
|
|
80
|
+
mode: v.component.imageResizeMode,
|
|
81
|
+
width: v.component.imageResizeTargetWidth,
|
|
82
|
+
height: v.component.imageResizeTargetHeight,
|
|
83
|
+
orient: v.component.orientImagesFromExif
|
|
84
84
|
}) : e;
|
|
85
|
-
return
|
|
85
|
+
return v.component.minSize && n.size < v.component.minSize * 1024 ? (F.value = [...F.value, {
|
|
86
86
|
path: n.name,
|
|
87
87
|
name: n.name,
|
|
88
88
|
size: n.size,
|
|
89
|
-
error:
|
|
90
|
-
}], null) :
|
|
89
|
+
error: D("form.file_too_small", {}, "This file is too small.")
|
|
90
|
+
}], null) : v.component.maxSize && n.size > v.component.maxSize * 1024 ? (F.value = [...F.value, {
|
|
91
91
|
path: n.name,
|
|
92
92
|
name: n.name,
|
|
93
93
|
size: n.size,
|
|
94
|
-
error:
|
|
94
|
+
error: D("form.file_too_large", {}, "This file is too large.")
|
|
95
95
|
}], null) : n;
|
|
96
96
|
}, rt = (e, t) => {
|
|
97
97
|
let n = {
|
|
@@ -101,177 +101,177 @@ var Oe = ["data-layout"], ke = [
|
|
|
101
101
|
progress: 0,
|
|
102
102
|
preview: e.type.startsWith("image/") ? URL.createObjectURL(e) : void 0
|
|
103
103
|
};
|
|
104
|
-
return n.preview &&
|
|
105
|
-
}, it = (e, t) => !!
|
|
106
|
-
let t = k.value.endpoints.upload, n = e.url ?? e.preview, r =
|
|
104
|
+
return n.preview && H.add(n.preview), n;
|
|
105
|
+
}, it = (e, t) => !!v.component.imageEditor && !j.value && t < G.value.length && !e.missing && !!(e.url ?? e.preview) && oe(e) !== null, at = async (e) => {
|
|
106
|
+
let t = k.value.endpoints.upload, n = e.url ?? e.preview, r = oe(e);
|
|
107
107
|
if (!t || !n || !r) return;
|
|
108
|
-
let i = await
|
|
108
|
+
let i = await se(n, r);
|
|
109
109
|
if (!i) {
|
|
110
|
-
|
|
110
|
+
F.value = [...F.value, {
|
|
111
111
|
path: `failed:${e.path}`,
|
|
112
112
|
name: e.name,
|
|
113
|
-
error:
|
|
113
|
+
error: D("image_editor.load_failed", {}, "The image could not be opened.")
|
|
114
114
|
}];
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
|
-
let a = await
|
|
117
|
+
let a = await V(i);
|
|
118
118
|
if (!a || a === i) return;
|
|
119
119
|
let o = await nt(a, !0);
|
|
120
120
|
if (!o) return;
|
|
121
121
|
let s = rt(o, `edit:${e.path}`);
|
|
122
|
-
|
|
123
|
-
},
|
|
122
|
+
F.value = [...F.value, s], await ot(t, o, s, e.path);
|
|
123
|
+
}, ot = async (e, t, n, r) => {
|
|
124
124
|
try {
|
|
125
|
-
let i = await
|
|
126
|
-
...
|
|
125
|
+
let i = await ge(e, t, {
|
|
126
|
+
...pe(k.value, v.component.uploadPolicy),
|
|
127
127
|
onProgress: (e) => {
|
|
128
|
-
|
|
128
|
+
F.value = F.value.map((t) => t.path === n.path ? {
|
|
129
129
|
...t,
|
|
130
130
|
progress: e
|
|
131
131
|
} : t);
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
-
|
|
134
|
+
I.value = [...I.value, {
|
|
135
135
|
path: i.key,
|
|
136
136
|
name: i.name,
|
|
137
137
|
size: i.size,
|
|
138
138
|
temporary: !0,
|
|
139
139
|
url: n.preview
|
|
140
|
-
}],
|
|
141
|
-
let a =
|
|
142
|
-
r !== void 0 && a.includes(r) ? (
|
|
140
|
+
}], F.value = F.value.filter((e) => e.path !== n.path);
|
|
141
|
+
let a = le(M.getValue(v.component.statePath, null));
|
|
142
|
+
r !== void 0 && a.includes(r) ? (Y(a.map((e) => e === r ? i.key : e)), ct(r)) : Y(de(a, i.key, v.component, K.value));
|
|
143
143
|
} catch (e) {
|
|
144
144
|
let t = e.errors?.file?.[0] ?? e.message;
|
|
145
|
-
|
|
145
|
+
F.value = F.value.map((e) => e.path === n.path ? {
|
|
146
146
|
...e,
|
|
147
147
|
error: t,
|
|
148
148
|
progress: void 0
|
|
149
149
|
} : e);
|
|
150
150
|
}
|
|
151
|
-
}, ot = (e) => {
|
|
152
|
-
q(H.value.filter((t) => t !== e)), st(e);
|
|
153
151
|
}, st = (e) => {
|
|
154
|
-
|
|
152
|
+
Y(W.value.filter((t) => t !== e)), ct(e);
|
|
153
|
+
}, ct = (e) => {
|
|
154
|
+
U(P.get().find((t) => t.path === e)?.url), e.startsWith("tmp:") && k.value.endpoints.uploadDestroy && me(k.value.endpoints.uploadDestroy, {
|
|
155
155
|
method: "DELETE",
|
|
156
156
|
body: { key: e }
|
|
157
157
|
}).catch(() => void 0);
|
|
158
|
-
}, ct = (e) => {
|
|
159
|
-
e.error || e.progress !== void 0 ? (Ze(e.preview), I.value = I.value.filter((t) => t.path !== e.path)) : ot(e.path);
|
|
160
158
|
}, lt = (e) => {
|
|
161
|
-
e.
|
|
159
|
+
e.error || e.progress !== void 0 ? (U(e.preview), F.value = F.value.filter((t) => t.path !== e.path)) : st(e.path);
|
|
162
160
|
}, ut = (e) => {
|
|
163
|
-
|
|
164
|
-
let t = ce(e.clipboardData);
|
|
165
|
-
t.length > 0 && (e.preventDefault(), J(t));
|
|
161
|
+
e.preventDefault(), L.value = !1, !j.value && e.dataTransfer && e.dataTransfer.files.length > 0 && X(e.dataTransfer.files);
|
|
166
162
|
}, dt = (e) => {
|
|
163
|
+
if (j.value || v.component.pasteable === !1) return;
|
|
164
|
+
let t = ue(e.clipboardData);
|
|
165
|
+
t.length > 0 && (e.preventDefault(), X(t));
|
|
166
|
+
}, ft = (e) => {
|
|
167
167
|
let t = e.target, n = t.files ? Array.from(t.files) : [];
|
|
168
|
-
t.value = "",
|
|
169
|
-
},
|
|
170
|
-
if (!
|
|
168
|
+
t.value = "", X(n);
|
|
169
|
+
}, Z = (e, t) => Y(fe(W.value, e, t)), Q = f(() => !!(v.component.reorderable && v.component.multiple && !j.value)), pt = (e, t) => {
|
|
170
|
+
if (!Q.value || z.value === null) return;
|
|
171
171
|
e.preventDefault(), e.stopPropagation();
|
|
172
|
-
let n =
|
|
173
|
-
n !== -1 && t <
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
].filter(Boolean).join(" · ")),
|
|
179
|
-
function
|
|
172
|
+
let n = W.value.indexOf(z.value);
|
|
173
|
+
n !== -1 && t < G.value.length && Z(n, t), z.value = null;
|
|
174
|
+
}, mt = f(() => [
|
|
175
|
+
v.component.acceptedFileTypes?.join(", "),
|
|
176
|
+
v.component.maxSize ? `≤ ${u(v.component.maxSize * 1024, O.value)}` : null,
|
|
177
|
+
v.component.minFiles ? He("form.min_files", v.component.minFiles, {}, "At least :count file|At least :count files") : null
|
|
178
|
+
].filter(Boolean).join(" · ")), ht = (e) => v.component.previewable !== !1 && (v.component.image || /\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e.name)), $ = x(/* @__PURE__ */ new Set());
|
|
179
|
+
function gt(e) {
|
|
180
180
|
return typeof e == "number" || /^\d+(\.\d+)?$/.test(e) ? `${e}px` : e;
|
|
181
181
|
}
|
|
182
|
-
return (e, t) => (
|
|
183
|
-
field:
|
|
184
|
-
"html-for":
|
|
185
|
-
error:
|
|
182
|
+
return (e, t) => (b(), p(ne, {
|
|
183
|
+
field: v.component,
|
|
184
|
+
"html-for": C(Ke),
|
|
185
|
+
error: C(Ge)
|
|
186
186
|
}, {
|
|
187
|
-
default:
|
|
187
|
+
default: w(() => [g("div", {
|
|
188
188
|
"data-slot": "file-upload",
|
|
189
|
-
"data-layout":
|
|
190
|
-
class:
|
|
189
|
+
"data-layout": v.component.panelLayout,
|
|
190
|
+
class: y(C(i)("flex flex-col gap-3", $e.value && "rounded-md border p-2"))
|
|
191
191
|
}, [
|
|
192
|
-
|
|
192
|
+
G.value.length > 0 || F.value.length > 0 ? (b(), h("ul", {
|
|
193
193
|
key: 0,
|
|
194
|
-
class:
|
|
195
|
-
}, [(
|
|
194
|
+
class: y(C(i)("grid gap-2", v.component.panelLayout === "grid" && "grid-cols-2 sm:grid-cols-3 md:grid-cols-4", q.value && "justify-items-center"))
|
|
195
|
+
}, [(b(!0), h(_e, null, ye([...G.value, ...F.value], (e, n) => (b(), h("li", {
|
|
196
196
|
key: e.path,
|
|
197
|
-
draggable:
|
|
198
|
-
class:
|
|
199
|
-
onDragstart: (t) =>
|
|
200
|
-
onDragover: t[0] ||= (e) =>
|
|
201
|
-
onDrop: (e) =>
|
|
202
|
-
onDragend: t[1] ||= (e) =>
|
|
197
|
+
draggable: Q.value && n < G.value.length,
|
|
198
|
+
class: y(C(i)(z.value === e.path && "opacity-50", "bg-muted/30 relative flex min-w-0 items-center gap-3 overflow-hidden rounded-md border p-2 text-sm", q.value && "size-28 justify-center rounded-full border-0 p-0", e.error && "border-destructive")),
|
|
199
|
+
onDragstart: (t) => z.value = e.path,
|
|
200
|
+
onDragover: t[0] ||= (e) => Q.value && e.preventDefault(),
|
|
201
|
+
onDrop: (e) => pt(e, n),
|
|
202
|
+
onDragend: t[1] ||= (e) => z.value = null
|
|
203
203
|
}, [
|
|
204
|
-
!
|
|
204
|
+
!q.value && et.value && v.component.deletable && !j.value ? (b(), p(o, {
|
|
205
205
|
key: 0,
|
|
206
206
|
type: "button",
|
|
207
207
|
variant: "ghost",
|
|
208
208
|
size: "icon-xs",
|
|
209
|
-
"aria-label":
|
|
210
|
-
onClick: (t) =>
|
|
209
|
+
"aria-label": C(D)("file_upload.remove", { name: e.name }, "Remove :name"),
|
|
210
|
+
onClick: (t) => lt(e)
|
|
211
211
|
}, {
|
|
212
|
-
default:
|
|
212
|
+
default: w(() => [_(C(ke))]),
|
|
213
213
|
_: 1
|
|
214
|
-
}, 8, ["aria-label", "onClick"])) :
|
|
215
|
-
!
|
|
216
|
-
|
|
214
|
+
}, 8, ["aria-label", "onClick"])) : m("", !0),
|
|
215
|
+
!q.value && tt.value && e.progress !== void 0 && !e.error ? (b(), p(s, { key: 1 })) : m("", !0),
|
|
216
|
+
ht(e) && (e.url || e.preview) && !$.value.has(e.path) ? (b(), h("img", {
|
|
217
217
|
key: 2,
|
|
218
218
|
src: e.url ?? e.preview,
|
|
219
219
|
alt: "",
|
|
220
|
-
class:
|
|
221
|
-
style:
|
|
222
|
-
height:
|
|
220
|
+
class: y(C(i)("size-12 shrink-0 rounded object-cover", q.value && "size-28 rounded-full")),
|
|
221
|
+
style: ve(!q.value && v.component.imagePreviewHeight ? {
|
|
222
|
+
height: gt(v.component.imagePreviewHeight),
|
|
223
223
|
width: "auto",
|
|
224
224
|
maxWidth: "50%"
|
|
225
225
|
} : void 0),
|
|
226
226
|
onError: (t) => $.value = new Set($.value).add(e.path)
|
|
227
|
-
}, null, 46,
|
|
227
|
+
}, null, 46, Me)) : q.value ? m("", !0) : (b(), p(C(Ee), {
|
|
228
228
|
key: 3,
|
|
229
229
|
class: "text-muted-foreground size-6 shrink-0"
|
|
230
230
|
})),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
(
|
|
234
|
-
|
|
231
|
+
q.value ? m("", !0) : (b(), h("div", Ne, [g("p", Pe, S(e.name), 1), g("p", { class: y(C(i)("text-muted-foreground text-xs", e.missing && "text-destructive")) }, S(e.error ?? (e.missing ? C(D)("form.file_missing", {}, "This file no longer exists.") : e.progress !== void 0 && !e.error ? v.component.uploadingMessage ?? C(D)("form.uploading", {}, "Uploading…") : e.size ? C(u)(e.size, C(O)) : e.temporary ? C(D)("form.uploading", {}, "Pending") : "")), 3)])),
|
|
232
|
+
g("div", { class: y(C(i)("flex items-center gap-1", q.value && "absolute -end-1 -bottom-1")) }, [
|
|
233
|
+
(q.value || !tt.value) && e.progress !== void 0 && !e.error ? (b(), p(s, { key: 0 })) : m("", !0),
|
|
234
|
+
Q.value && n < G.value.length ? (b(), h(_e, { key: 1 }, [_(o, {
|
|
235
235
|
type: "button",
|
|
236
236
|
variant: "ghost",
|
|
237
237
|
size: "icon-xs",
|
|
238
|
-
"aria-label":
|
|
238
|
+
"aria-label": C(D)("file_upload.move_up", { name: e.name }, "Move :name up"),
|
|
239
239
|
disabled: n === 0,
|
|
240
|
-
onClick: (e) =>
|
|
240
|
+
onClick: (e) => Z(n, n - 1)
|
|
241
241
|
}, {
|
|
242
|
-
default:
|
|
242
|
+
default: w(() => [_(C(Ce))]),
|
|
243
243
|
_: 1
|
|
244
244
|
}, 8, [
|
|
245
245
|
"aria-label",
|
|
246
246
|
"disabled",
|
|
247
247
|
"onClick"
|
|
248
|
-
]),
|
|
248
|
+
]), _(o, {
|
|
249
249
|
type: "button",
|
|
250
250
|
variant: "ghost",
|
|
251
251
|
size: "icon-xs",
|
|
252
|
-
"aria-label":
|
|
253
|
-
disabled: n ===
|
|
254
|
-
onClick: (e) =>
|
|
252
|
+
"aria-label": C(D)("file_upload.move_down", { name: e.name }, "Move :name down"),
|
|
253
|
+
disabled: n === G.value.length - 1,
|
|
254
|
+
onClick: (e) => Z(n, n + 1)
|
|
255
255
|
}, {
|
|
256
|
-
default:
|
|
256
|
+
default: w(() => [_(C(Se))]),
|
|
257
257
|
_: 1
|
|
258
258
|
}, 8, [
|
|
259
259
|
"aria-label",
|
|
260
260
|
"disabled",
|
|
261
261
|
"onClick"
|
|
262
|
-
])], 64)) :
|
|
263
|
-
it(e, n) ? (
|
|
262
|
+
])], 64)) : m("", !0),
|
|
263
|
+
it(e, n) ? (b(), p(o, {
|
|
264
264
|
key: 2,
|
|
265
265
|
type: "button",
|
|
266
|
-
variant:
|
|
266
|
+
variant: q.value ? "secondary" : "ghost",
|
|
267
267
|
size: "icon-xs",
|
|
268
|
-
class:
|
|
269
|
-
"aria-label":
|
|
270
|
-
title:
|
|
268
|
+
class: y(C(i)(q.value && "rounded-full shadow")),
|
|
269
|
+
"aria-label": C(D)("file_upload.edit", { name: e.name }, "Edit :name"),
|
|
270
|
+
title: C(D)("image_editor.title", {}, "Edit image"),
|
|
271
271
|
"data-action": "edit-image",
|
|
272
272
|
onClick: (t) => void at(e)
|
|
273
273
|
}, {
|
|
274
|
-
default:
|
|
274
|
+
default: w(() => [_(C(De))]),
|
|
275
275
|
_: 1
|
|
276
276
|
}, 8, [
|
|
277
277
|
"variant",
|
|
@@ -279,95 +279,95 @@ var Oe = ["data-layout"], ke = [
|
|
|
279
279
|
"aria-label",
|
|
280
280
|
"title",
|
|
281
281
|
"onClick"
|
|
282
|
-
])) :
|
|
283
|
-
|
|
282
|
+
])) : m("", !0),
|
|
283
|
+
v.component.openable && C(d)(e).open ? (b(), p(o, {
|
|
284
284
|
key: 3,
|
|
285
285
|
"as-child": "",
|
|
286
286
|
type: "button",
|
|
287
287
|
variant: "ghost",
|
|
288
288
|
size: "icon-xs"
|
|
289
289
|
}, {
|
|
290
|
-
default:
|
|
291
|
-
href:
|
|
290
|
+
default: w(() => [g("a", {
|
|
291
|
+
href: C(d)(e).open,
|
|
292
292
|
target: "_blank",
|
|
293
293
|
rel: "noopener noreferrer",
|
|
294
|
-
"aria-label": `${
|
|
295
|
-
}, [
|
|
294
|
+
"aria-label": `${C(D)("file_upload.open", { name: e.name }, "Open :name")} ${C(D)("opens_in_new_tab", {}, "(opens in a new tab)")}`
|
|
295
|
+
}, [_(C(Te))], 8, Fe)]),
|
|
296
296
|
_: 2
|
|
297
|
-
}, 1024)) :
|
|
298
|
-
|
|
297
|
+
}, 1024)) : m("", !0),
|
|
298
|
+
v.component.downloadable && C(d)(e).download ? (b(), p(o, {
|
|
299
299
|
key: 4,
|
|
300
300
|
"as-child": "",
|
|
301
301
|
type: "button",
|
|
302
302
|
variant: "ghost",
|
|
303
303
|
size: "icon-xs"
|
|
304
304
|
}, {
|
|
305
|
-
default:
|
|
306
|
-
href:
|
|
305
|
+
default: w(() => [g("a", {
|
|
306
|
+
href: C(d)(e).download,
|
|
307
307
|
download: "",
|
|
308
|
-
"aria-label":
|
|
309
|
-
}, [
|
|
308
|
+
"aria-label": C(D)("file_upload.download", { name: e.name }, "Download :name")
|
|
309
|
+
}, [_(C(we))], 8, Ie)]),
|
|
310
310
|
_: 2
|
|
311
|
-
}, 1024)) :
|
|
312
|
-
|
|
311
|
+
}, 1024)) : m("", !0),
|
|
312
|
+
v.component.deletable && !j.value && (q.value || !et.value) ? (b(), p(o, {
|
|
313
313
|
key: 5,
|
|
314
314
|
type: "button",
|
|
315
|
-
variant:
|
|
315
|
+
variant: q.value ? "secondary" : "ghost",
|
|
316
316
|
size: "icon-xs",
|
|
317
|
-
class:
|
|
318
|
-
"aria-label":
|
|
319
|
-
onClick: (t) =>
|
|
317
|
+
class: y(C(i)(q.value && "rounded-full shadow")),
|
|
318
|
+
"aria-label": C(D)("file_upload.remove", { name: e.name }, "Remove :name"),
|
|
319
|
+
onClick: (t) => lt(e)
|
|
320
320
|
}, {
|
|
321
|
-
default:
|
|
321
|
+
default: w(() => [_(C(ke))]),
|
|
322
322
|
_: 1
|
|
323
323
|
}, 8, [
|
|
324
324
|
"variant",
|
|
325
325
|
"class",
|
|
326
326
|
"aria-label",
|
|
327
327
|
"onClick"
|
|
328
|
-
])) :
|
|
328
|
+
])) : m("", !0)
|
|
329
329
|
], 2)
|
|
330
|
-
], 42,
|
|
331
|
-
Qe.value && !
|
|
330
|
+
], 42, je))), 128))], 2)) : m("", !0),
|
|
331
|
+
Qe.value && !j.value ? (b(), h("div", {
|
|
332
332
|
key: 1,
|
|
333
333
|
role: "button",
|
|
334
334
|
tabindex: "0",
|
|
335
|
-
"data-align":
|
|
336
|
-
style:
|
|
337
|
-
class:
|
|
338
|
-
"aria-describedby":
|
|
339
|
-
onClick: t[2] ||= (e) =>
|
|
340
|
-
onKeydown: [t[3] ||=
|
|
341
|
-
onDragover: t[5] ||= E((e) =>
|
|
342
|
-
onDragleave: t[6] ||= (e) =>
|
|
343
|
-
onDrop:
|
|
344
|
-
onPaste:
|
|
335
|
+
"data-align": J.value,
|
|
336
|
+
style: ve(!q.value && v.component.panelAspectRatio ? { aspectRatio: C(ae)(v.component.panelAspectRatio) } : void 0),
|
|
337
|
+
class: y(C(i)("text-muted-foreground hover:border-ring flex cursor-pointer flex-col justify-center gap-1 rounded-md border border-dashed px-4 py-6 text-sm transition-colors", J.value === "start" ? "items-start text-start" : J.value === "end" ? "items-end text-end" : "items-center text-center", $e.value && "border-transparent", L.value && "border-ring bg-accent", q.value && "size-28 items-center rounded-full py-0")),
|
|
338
|
+
"aria-describedby": C(A)["aria-describedby"],
|
|
339
|
+
onClick: t[2] ||= (e) => R.value?.click(),
|
|
340
|
+
onKeydown: [t[3] ||= T(E((e) => R.value?.click(), ["prevent"]), ["enter"]), t[4] ||= T(E((e) => R.value?.click(), ["prevent"]), ["space"])],
|
|
341
|
+
onDragover: t[5] ||= E((e) => L.value = !0, ["prevent"]),
|
|
342
|
+
onDragleave: t[6] ||= (e) => L.value = !1,
|
|
343
|
+
onDrop: ut,
|
|
344
|
+
onPaste: dt
|
|
345
345
|
}, [
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
!
|
|
349
|
-
], 46,
|
|
350
|
-
|
|
351
|
-
id:
|
|
346
|
+
_(C(Oe), { class: "size-5" }),
|
|
347
|
+
q.value ? m("", !0) : (b(), h("span", Re, S(v.component.placeholder ?? C(D)("form.drop_files", {}, "Drop files here or click to browse")), 1)),
|
|
348
|
+
!q.value && mt.value ? (b(), h("span", ze, S(mt.value), 1)) : m("", !0)
|
|
349
|
+
], 46, Le)) : m("", !0),
|
|
350
|
+
g("input", {
|
|
351
|
+
id: C(Ke),
|
|
352
352
|
ref_key: "inputRef",
|
|
353
|
-
ref:
|
|
353
|
+
ref: R,
|
|
354
354
|
type: "file",
|
|
355
355
|
class: "sr-only",
|
|
356
356
|
tabindex: "-1",
|
|
357
|
-
"aria-invalid":
|
|
358
|
-
"aria-describedby":
|
|
359
|
-
"aria-required":
|
|
360
|
-
multiple:
|
|
361
|
-
accept:
|
|
362
|
-
disabled:
|
|
363
|
-
onChange:
|
|
364
|
-
}, null, 40,
|
|
365
|
-
|
|
357
|
+
"aria-invalid": C(A)["aria-invalid"],
|
|
358
|
+
"aria-describedby": C(A)["aria-describedby"],
|
|
359
|
+
"aria-required": C(A)["aria-required"],
|
|
360
|
+
multiple: v.component.multiple,
|
|
361
|
+
accept: C(ce)(v.component),
|
|
362
|
+
disabled: j.value,
|
|
363
|
+
onChange: ft
|
|
364
|
+
}, null, 40, Be),
|
|
365
|
+
v.component.imageEditor && (B.value || Ze.value) ? (b(), p(C(Ve), {
|
|
366
366
|
key: 2,
|
|
367
|
-
request:
|
|
368
|
-
options:
|
|
369
|
-
}, null, 8, ["request", "options"])) :
|
|
370
|
-
], 10,
|
|
367
|
+
request: B.value,
|
|
368
|
+
options: v.component.imageEditor
|
|
369
|
+
}, null, 8, ["request", "options"])) : m("", !0)
|
|
370
|
+
], 10, Ae)]),
|
|
371
371
|
_: 1
|
|
372
372
|
}, 8, [
|
|
373
373
|
"field",
|
|
@@ -377,6 +377,6 @@ var Oe = ["data-layout"], ke = [
|
|
|
377
377
|
}
|
|
378
378
|
});
|
|
379
379
|
//#endregion
|
|
380
|
-
export {
|
|
380
|
+
export { D as default };
|
|
381
381
|
|
|
382
382
|
//# sourceMappingURL=FileUploadField.vue_vue_type_script_setup_true_lang.js.map
|