@bridge-ui/vue 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Adapters/Examples/icon-fontawesome.js +52 -40
- package/dist/Adapters/Examples/icon-heroicons.js +43 -31
- package/dist/Adapters/Examples/icon-lucide.js +46 -34
- package/dist/Adapters/Examples/icon-phosphor.js +36 -24
- package/dist/Adapters/Examples/icon-tabler.js +44 -32
- package/dist/Adapters/Examples/rich-text-tiptap.d.ts +5 -0
- package/dist/Adapters/Examples/rich-text-tiptap.js +138 -0
- package/dist/Adapters/RichText/index.d.ts +1 -0
- package/dist/Adapters/RichText/index.js +2 -0
- package/dist/Adapters/RichText/mockRichTextAdapter.d.ts +5 -0
- package/dist/Adapters/RichText/useRichTextAdapter.d.ts +12 -0
- package/dist/Adapters/RichText/useRichTextAdapter.js +13 -0
- package/dist/Adapters/index.d.ts +1 -0
- package/dist/Adapters/index.js +2 -1
- package/dist/Components/ActionFooter/composables/useActionFooter.d.ts +6 -6
- package/dist/Components/Autocomplete/composables/useAutocomplete.js +2 -2
- package/dist/Components/Breadcrumb/Breadcrumb.vue.d.ts +17 -10
- package/dist/Components/Breadcrumb/Breadcrumb.vue_vue_type_script_setup_true_lang.js +7 -2
- package/dist/Components/Breadcrumb/breadcrumb.types.d.ts +22 -4
- package/dist/Components/Breadcrumb/breadcrumbInjectionKey.d.ts +5 -1
- package/dist/Components/Breadcrumb/composables/useBreadcrumb.d.ts +6 -5
- package/dist/Components/Breadcrumb/composables/useBreadcrumb.js +2 -0
- package/dist/Components/BreadcrumbItem/BreadcrumbItem.vue.d.ts +17 -11
- package/dist/Components/BreadcrumbItem/BreadcrumbItem.vue_vue_type_script_setup_true_lang.js +2 -0
- package/dist/Components/BreadcrumbItem/breadcrumbItem.types.d.ts +21 -3
- package/dist/Components/BreadcrumbItem/composables/useBreadcrumbItem.d.ts +10 -6
- package/dist/Components/BreadcrumbItem/composables/useBreadcrumbItem.js +65 -59
- package/dist/Components/Button/Button.vue.d.ts +17 -8
- package/dist/Components/Button/Button.vue_vue_type_script_setup_true_lang.js +10 -10
- package/dist/Components/Button/button.types.d.ts +22 -5
- package/dist/Components/Button/composables/useButton.d.ts +198 -8
- package/dist/Components/Button/composables/useButton.js +101 -86
- package/dist/Components/ColorPicker/composables/useColorPicker.js +1 -1
- package/dist/Components/DataTable/DataTable.vue.d.ts +1 -1
- package/dist/Components/DataTable/composables/useDataTable.d.ts +1 -1
- package/dist/Components/DataTable/composables/useDataTable.js +288 -282
- package/dist/Components/Drawer/composables/useDrawer.d.ts +1 -1
- package/dist/Components/Drawer/composables/useDrawer.js +2 -2
- package/dist/Components/FileUpload/FileUpload.js +5 -0
- package/dist/Components/FileUpload/FileUpload.vue.d.ts +28 -0
- package/dist/Components/FileUpload/FileUpload.vue_vue_type_script_setup_true_lang.js +132 -0
- package/dist/Components/FileUpload/composables/useFileUpload.d.ts +70 -0
- package/dist/Components/FileUpload/composables/useFileUpload.js +210 -0
- package/dist/Components/FileUpload/fileUpload.types.d.ts +306 -0
- package/dist/Components/FileUpload/index.d.ts +3 -0
- package/dist/Components/FileUpload/index.js +3 -0
- package/dist/Components/FormField/composables/useFormField.d.ts +1 -1
- package/dist/Components/Link/Link.vue.d.ts +17 -8
- package/dist/Components/Link/Link.vue_vue_type_script_setup_true_lang.js +30 -25
- package/dist/Components/Link/composables/useLink.d.ts +8 -6
- package/dist/Components/Link/composables/useLink.js +52 -45
- package/dist/Components/Link/link.types.d.ts +21 -4
- package/dist/Components/ListItem/ListItem.vue.d.ts +17 -15
- package/dist/Components/ListItem/ListItem.vue_vue_type_script_setup_true_lang.js +2 -0
- package/dist/Components/ListItem/composables/useListItem.d.ts +7 -6
- package/dist/Components/ListItem/composables/useListItem.js +108 -105
- package/dist/Components/ListItem/listItem.types.d.ts +19 -3
- package/dist/Components/Listbox/composables/useListbox.d.ts +2 -2
- package/dist/Components/Menu/composables/useMenu.js +6 -6
- package/dist/Components/Modal/composables/useModal.d.ts +1 -1
- package/dist/Components/Modal/composables/useModal.js +2 -2
- package/dist/Components/RichTextEditor/RichTextEditor.js +5 -0
- package/dist/Components/RichTextEditor/RichTextEditor.vue.d.ts +23 -0
- package/dist/Components/RichTextEditor/RichTextEditor.vue_vue_type_script_setup_true_lang.js +104 -0
- package/dist/Components/RichTextEditor/composables/useRichTextEditor.d.ts +488 -0
- package/dist/Components/RichTextEditor/composables/useRichTextEditor.js +226 -0
- package/dist/Components/RichTextEditor/index.d.ts +3 -0
- package/dist/Components/RichTextEditor/index.js +3 -0
- package/dist/Components/RichTextEditor/richTextEditor.types.d.ts +103 -0
- package/dist/Components/Select/composables/useSelect.js +2 -2
- package/dist/Components/Sidebar/SidebarListItem.vue.d.ts +17 -9
- package/dist/Components/Sidebar/SidebarListItem.vue_vue_type_script_setup_true_lang.js +2 -0
- package/dist/Components/Sidebar/composables/useSidebarListItem.js +1 -1
- package/dist/Components/Sidebar/sidebar.types.d.ts +2 -1
- package/dist/Components/Snackbar/composables/useSnackbar.js +1 -1
- package/dist/Components/Textarea/composables/useTextarea.js +1 -1
- package/dist/Components/Tooltip/composables/useTooltip.js +3 -3
- package/dist/Utils/linkAs.d.ts +29 -0
- package/dist/Utils/linkAs.js +18 -0
- package/dist/augments.d.ts +10 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +175 -170
- package/dist/theme.css +3 -0
- package/docs/README.md +3 -0
- package/docs/components/Breadcrumb.md +16 -0
- package/docs/components/BridgeUIProvider.md +18 -1
- package/docs/components/Button.md +31 -19
- package/docs/components/DataTable.md +1 -1
- package/docs/components/FileUpload.md +122 -0
- package/docs/components/Link.md +28 -12
- package/docs/components/List.md +21 -19
- package/docs/components/RichTextEditor.md +88 -0
- package/docs/components/Sidebar.md +1 -1
- package/package.json +54 -18
|
@@ -34,7 +34,7 @@ export declare function useDrawer(props: DrawerOwnProps, libDefaults: DrawerLibD
|
|
|
34
34
|
};
|
|
35
35
|
"aria-hidden": boolean | undefined;
|
|
36
36
|
class: string;
|
|
37
|
-
}, "class", import('vue').HTMLAttributes | undefined, Omit<DrawerProps, "size" | "classes" | "customProps" | "scroll" | "ariaLabel" | "ariaLabelledBy" | "autoFocus" | "blur" | "closeOnEscape" | "closeOnOverlay" | "disableEnforceFocus" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "persistent" | "placement" | "stackId" | "teleportTo"
|
|
37
|
+
}, "class", import('vue').HTMLAttributes | undefined, Omit<DrawerProps, "size" | "classes" | "customProps" | "transition" | "scroll" | "ariaLabel" | "ariaLabelledBy" | "autoFocus" | "blur" | "closeOnEscape" | "closeOnOverlay" | "disableEnforceFocus" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "persistent" | "placement" | "stackId" | "teleportTo">>>;
|
|
38
38
|
panelBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<{
|
|
39
39
|
"data-drawer-part": string;
|
|
40
40
|
"data-state": "open" | "closed";
|
|
@@ -160,13 +160,13 @@ function m(m, h, g = {}) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
function Z() {
|
|
163
|
-
P.value.closeOnOverlay
|
|
163
|
+
P.value.closeOnOverlay !== !1 && U.value && X();
|
|
164
164
|
}
|
|
165
165
|
function Q(e) {
|
|
166
166
|
f(e) && Z();
|
|
167
167
|
}
|
|
168
168
|
function Pe() {
|
|
169
|
-
|
|
169
|
+
j.value && P.value.closeOnEscape !== !1 && U.value && X();
|
|
170
170
|
}
|
|
171
171
|
o(j, (e) => {
|
|
172
172
|
if (e) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FileUploadOwnProps, FileUploadSlots } from './fileUpload.types';
|
|
2
|
+
type __VLS_Slots = FileUploadSlots;
|
|
3
|
+
type __VLS_Props = FileUploadOwnProps;
|
|
4
|
+
type __VLS_ModelProps = {
|
|
5
|
+
modelValue?: File[] | undefined;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
9
|
+
remove: (file: File, index: number) => any;
|
|
10
|
+
"update:modelValue": (...args: unknown[]) => any;
|
|
11
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
12
|
+
onRemove?: ((file: File, index: number) => any) | undefined;
|
|
13
|
+
"onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
|
|
14
|
+
}>, {
|
|
15
|
+
color: import('@bridge-ui/core/Utils').MergeProps<import('@bridge-ui/core/Tokens').ButtonColor, import('./fileUpload.types').FileUploadColorOverrides>;
|
|
16
|
+
size: import('@bridge-ui/core/Utils').MergeProps<import('@bridge-ui/core/Tokens').FileUploadSize, import('./fileUpload.types').FileUploadSizeOverrides>;
|
|
17
|
+
rounded: import('@bridge-ui/core/Utils').MergeProps<import('@bridge-ui/core/Tokens').FileUploadRounded, import('./fileUpload.types').FileUploadRoundedOverrides>;
|
|
18
|
+
variant: import('@bridge-ui/core/Utils').MergeProps<import('@bridge-ui/core/Tokens').FileUploadVariant, import('./fileUpload.types').FileUploadVariantOverrides>;
|
|
19
|
+
multiple: boolean;
|
|
20
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
25
|
+
new (): {
|
|
26
|
+
$slots: S;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { hasNamedSlot as e, isPropPresent as t } from "../../Utils/slotOrProp.js";
|
|
2
|
+
import { useOptionalModel as n } from "../../Utils/useOptionalModel.js";
|
|
3
|
+
import r from "../Icon/Icon.js";
|
|
4
|
+
import i from "../Button/Button.js";
|
|
5
|
+
import { useFileUpload as a } from "./composables/useFileUpload.js";
|
|
6
|
+
import { Fragment as o, computed as ee, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, guardReactiveProps as m, mergeModels as h, mergeProps as g, normalizeProps as _, openBlock as v, ref as y, renderList as b, renderSlot as x, toDisplayString as S, unref as C, useModel as w, withCtx as T } from "vue";
|
|
7
|
+
//#region src/Components/FileUpload/FileUpload.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
var E = {
|
|
9
|
+
key: 2,
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
class: "text-error-600 dark:text-error-400"
|
|
12
|
+
}, D = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "m-0 font-medium text-dark-900 dark:text-dark-100"
|
|
15
|
+
}, O = {
|
|
16
|
+
key: 1,
|
|
17
|
+
class: "m-0 text-sm text-dark-500 dark:text-dark-400"
|
|
18
|
+
}, k = ["tabindex"], A = ["src"], j = /*@__PURE__*/ p({
|
|
19
|
+
inheritAttrs: !1,
|
|
20
|
+
__name: "FileUpload",
|
|
21
|
+
props: /*@__PURE__*/ h({
|
|
22
|
+
accept: {},
|
|
23
|
+
buttonLabel: {},
|
|
24
|
+
classes: {},
|
|
25
|
+
color: { default: "primary" },
|
|
26
|
+
customProps: {},
|
|
27
|
+
defaultValue: {},
|
|
28
|
+
description: {},
|
|
29
|
+
disabled: { type: Boolean },
|
|
30
|
+
error: { type: Boolean },
|
|
31
|
+
errorMessage: {},
|
|
32
|
+
label: {},
|
|
33
|
+
maxFiles: {},
|
|
34
|
+
maxSize: {},
|
|
35
|
+
multiple: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: !1
|
|
38
|
+
},
|
|
39
|
+
required: { type: Boolean },
|
|
40
|
+
rounded: { default: "md" },
|
|
41
|
+
size: { default: "md" },
|
|
42
|
+
title: {},
|
|
43
|
+
variant: { default: "button" }
|
|
44
|
+
}, {
|
|
45
|
+
modelValue: {},
|
|
46
|
+
modelModifiers: {}
|
|
47
|
+
}),
|
|
48
|
+
emits: /*@__PURE__*/ h(["remove", "update:modelValue"], ["update:modelValue"]),
|
|
49
|
+
setup(p, { emit: h }) {
|
|
50
|
+
let j = h, M = w(p, "modelValue"), N = p, P = y(N.defaultValue ?? []), F = n(M, P), { slots: I, merged: L, rootBind: R, listBind: z, inputRef: B, labelBind: V, inputBind: H, errorBind: U, mediaBind: W, titleBind: te, fileItems: G, showError: K, isDropzone: q, showPicker: J, actionsBind: Y, contentBind: X, triggerBind: Z, getItemBind: Q, buttonLabel: ne, dropzoneBind: re, openFileDialog: $, descriptionBind: ie, itemDescriptionBind: ae, resolvedErrorMessage: oe } = a(N, {
|
|
51
|
+
size: "md",
|
|
52
|
+
rounded: "md",
|
|
53
|
+
multiple: !1,
|
|
54
|
+
color: "primary",
|
|
55
|
+
variant: "button"
|
|
56
|
+
}, F, j), se = ee(() => !K.value && !q.value && (e(I, "description") || t(L.value.description)));
|
|
57
|
+
function ce(e) {
|
|
58
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), $());
|
|
59
|
+
}
|
|
60
|
+
return (n, a) => (v(), l("div", _(m(C(R))), [
|
|
61
|
+
u("input", g({
|
|
62
|
+
ref_key: "inputRef",
|
|
63
|
+
ref: B
|
|
64
|
+
}, C(H)), null, 16),
|
|
65
|
+
C(t)(C(L).label) || C(e)(C(I), "label") ? (v(), l("label", _(g({ key: 0 }, C(V))), [C(e)(C(I), "label") ? x(n.$slots, "label", {}, void 0, void 0, 0) : C(t)(C(L).label) ? (v(), l(o, { key: 1 }, [d(S(C(L).label), 1)], 64)) : c("", !0), C(L).required ? (v(), l("span", E, " * ")) : c("", !0)], 16)) : c("", !0),
|
|
66
|
+
C(J) ? (v(), l(o, { key: 1 }, [C(q) ? (v(), l("div", _(g({ key: 0 }, C(re))), [C(e)(C(I), "dropzone") ? x(n.$slots, "dropzone", {}, void 0, void 0, 0) : (v(), l(o, { key: 1 }, [
|
|
67
|
+
f(C(r), {
|
|
68
|
+
icon: "inbox",
|
|
69
|
+
class: "mb-1 text-dark-400"
|
|
70
|
+
}),
|
|
71
|
+
C(t)(C(L).title) ? (v(), l("p", D, S(C(L).title), 1)) : c("", !0),
|
|
72
|
+
C(t)(C(L).description) ? (v(), l("p", O, S(C(L).description), 1)) : c("", !0)
|
|
73
|
+
], 64))], 16)) : (v(), l("div", _(g({ key: 1 }, C(Z))), [C(e)(C(I), "trigger") ? (v(), l("span", {
|
|
74
|
+
key: 0,
|
|
75
|
+
role: "button",
|
|
76
|
+
onClick: a[0] ||= (...e) => C($) && C($)(...e),
|
|
77
|
+
onKeydown: ce,
|
|
78
|
+
tabindex: C(L).disabled ? -1 : 0
|
|
79
|
+
}, [x(n.$slots, "trigger")], 40, k)) : (v(), s(C(i), {
|
|
80
|
+
key: 1,
|
|
81
|
+
type: "button",
|
|
82
|
+
size: C(L).size,
|
|
83
|
+
color: C(L).color,
|
|
84
|
+
rounded: C(L).rounded,
|
|
85
|
+
disabled: C(L).disabled,
|
|
86
|
+
onClick: C($)
|
|
87
|
+
}, {
|
|
88
|
+
default: T(() => [d(S(C(ne)), 1)]),
|
|
89
|
+
_: 1
|
|
90
|
+
}, 8, [
|
|
91
|
+
"size",
|
|
92
|
+
"color",
|
|
93
|
+
"rounded",
|
|
94
|
+
"disabled",
|
|
95
|
+
"onClick"
|
|
96
|
+
]))], 16))], 64)) : c("", !0),
|
|
97
|
+
C(G).length > 0 ? (v(), l("ul", _(g({ key: 2 }, C(z))), [(v(!0), l(o, null, b(C(G), (t) => (v(), l("li", g({ ref_for: !0 }, C(Q)(t.index), { key: `${t.file.name}-${t.index}` }), [C(e)(C(I), "item") ? x(n.$slots, "item", g({ ref_for: !0 }, t), void 0, void 0, 0) : (v(), l(o, { key: 1 }, [
|
|
98
|
+
u("div", g({ ref_for: !0 }, C(W)), [t.isImage && t.previewUrl ? (v(), l("img", {
|
|
99
|
+
key: 0,
|
|
100
|
+
alt: "",
|
|
101
|
+
src: t.previewUrl
|
|
102
|
+
}, null, 8, A)) : (v(), s(C(r), {
|
|
103
|
+
key: 1,
|
|
104
|
+
icon: "download"
|
|
105
|
+
}))], 16),
|
|
106
|
+
u("div", g({ ref_for: !0 }, C(X)), [u("p", g({ ref_for: !0 }, C(te)), S(t.file.name), 17), u("p", g({ ref_for: !0 }, C(ae)), S(t.metaLabel), 17)], 16),
|
|
107
|
+
u("div", g({ ref_for: !0 }, C(Y)), [f(C(i), {
|
|
108
|
+
size: "sm",
|
|
109
|
+
icon: "clear",
|
|
110
|
+
type: "button",
|
|
111
|
+
variant: "flat",
|
|
112
|
+
density: "mini",
|
|
113
|
+
color: C(L).color,
|
|
114
|
+
onClick: t.remove,
|
|
115
|
+
rounded: C(L).rounded,
|
|
116
|
+
disabled: C(L).disabled,
|
|
117
|
+
"aria-label": `Remove ${t.file.name}`
|
|
118
|
+
}, null, 8, [
|
|
119
|
+
"color",
|
|
120
|
+
"onClick",
|
|
121
|
+
"rounded",
|
|
122
|
+
"disabled",
|
|
123
|
+
"aria-label"
|
|
124
|
+
])], 16)
|
|
125
|
+
], 64))], 16))), 128))], 16)) : c("", !0),
|
|
126
|
+
se.value ? (v(), l("p", _(g({ key: 3 }, C(ie))), [C(e)(C(I), "description") ? x(n.$slots, "description", {}, void 0, void 0, 0) : C(t)(C(L).description) ? (v(), l(o, { key: 1 }, [d(S(C(L).description), 1)], 64)) : c("", !0)], 16)) : c("", !0),
|
|
127
|
+
C(K) ? (v(), l("p", _(g({ key: 4 }, C(U))), [C(e)(C(I), "errorMessage") ? x(n.$slots, "errorMessage", {}, void 0, void 0, 0) : (v(), l(o, { key: 1 }, [d(S(C(oe)), 1)], 64))], 16)) : c("", !0)
|
|
128
|
+
], 16));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
//#endregion
|
|
132
|
+
export { j as default };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Ref, WritableComputedRef } from 'vue';
|
|
2
|
+
import { LibDefaultsShape, MergeLibDefaults } from '@bridge-ui/core/Utils';
|
|
3
|
+
import { FileUploadOwnProps, FileUploadProps } from '../fileUpload.types';
|
|
4
|
+
type FileUploadLibDefaults = LibDefaultsShape<FileUploadOwnProps, "size" | "color" | "rounded" | "variant" | "multiple">;
|
|
5
|
+
type FileUploadMerged = MergeLibDefaults<FileUploadOwnProps, FileUploadLibDefaults>;
|
|
6
|
+
export declare function useFileUpload(props: FileUploadOwnProps, libDefaults: FileUploadLibDefaults, files: WritableComputedRef<File[]>, emit: {
|
|
7
|
+
(event: "remove", file: File, index: number): void;
|
|
8
|
+
(event: "update:modelValue", files: File[]): void;
|
|
9
|
+
}): {
|
|
10
|
+
slots: Readonly<{
|
|
11
|
+
[name: string]: import('vue').Slot<any> | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
merged: import('vue').ComputedRef<FileUploadMerged>;
|
|
14
|
+
dragging: Ref<boolean, boolean>;
|
|
15
|
+
rootBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, Omit<Omit<FileUploadProps, "error" | "color" | "size" | "classes" | "customProps" | "title" | "disabled" | "rounded" | "variant" | "label" | "required" | "description" | "errorMessage" | "multiple" | "accept" | "defaultValue" | "modelValue" | "buttonLabel" | "maxFiles" | "maxSize">, "class">>>;
|
|
16
|
+
listBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
17
|
+
labelBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
18
|
+
inputBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<{
|
|
19
|
+
type: string;
|
|
20
|
+
tabIndex: number;
|
|
21
|
+
"aria-hidden": boolean;
|
|
22
|
+
accept: string | undefined;
|
|
23
|
+
onChange: (event: Event) => void;
|
|
24
|
+
multiple: NonNullable<boolean | undefined>;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
class: string;
|
|
27
|
+
}, "class", import('vue').InputHTMLAttributes | undefined, {}>>;
|
|
28
|
+
errorBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {
|
|
29
|
+
role: string;
|
|
30
|
+
}>>;
|
|
31
|
+
mediaBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
32
|
+
titleBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
33
|
+
fileItems: import('vue').ComputedRef<{
|
|
34
|
+
file: File;
|
|
35
|
+
index: number;
|
|
36
|
+
isImage: boolean;
|
|
37
|
+
metaLabel: string;
|
|
38
|
+
previewUrl: string | undefined;
|
|
39
|
+
sizeLabel: string;
|
|
40
|
+
remove: () => void;
|
|
41
|
+
}[]>;
|
|
42
|
+
showError: import('vue').ComputedRef<boolean>;
|
|
43
|
+
isDropzone: import('vue').ComputedRef<boolean>;
|
|
44
|
+
isDisabled: import('vue').ComputedRef<boolean>;
|
|
45
|
+
showPicker: import('vue').ComputedRef<boolean>;
|
|
46
|
+
canAddMore: import('vue').ComputedRef<boolean>;
|
|
47
|
+
actionsBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
48
|
+
contentBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
49
|
+
triggerBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
50
|
+
getItemBind: (_index: number) => import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>;
|
|
51
|
+
buttonLabel: import('vue').ComputedRef<string>;
|
|
52
|
+
dropzoneBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {
|
|
53
|
+
role: string;
|
|
54
|
+
onDrop: (event: DragEvent) => void;
|
|
55
|
+
onClick: () => void;
|
|
56
|
+
onDragover: (event: DragEvent) => void;
|
|
57
|
+
onDragenter: (event: DragEvent) => void;
|
|
58
|
+
onDragleave: (event: DragEvent) => void;
|
|
59
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
60
|
+
tabindex: number;
|
|
61
|
+
"aria-disabled": true | undefined;
|
|
62
|
+
}>>;
|
|
63
|
+
openFileDialog: () => void;
|
|
64
|
+
descriptionBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
65
|
+
validationError: Ref<string | undefined, string | undefined>;
|
|
66
|
+
itemDescriptionBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", {}, {}>>;
|
|
67
|
+
resolvedErrorMessage: import('vue').ComputedRef<string | undefined>;
|
|
68
|
+
inputRef: Ref<null | HTMLInputElement>;
|
|
69
|
+
};
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { mergePartBind as e, useBridgeUIComponent as t, useBridgeUIMergedRegistryClasses as ee } from "../../../Utils/index.js";
|
|
2
|
+
import { computed as n, onUnmounted as r, ref as i, useAttrs as a, useSlots as o, watch as s } from "vue";
|
|
3
|
+
import { get as c, omit as l } from "es-toolkit/compat";
|
|
4
|
+
import { filesFromFileList as u, formatFileMeta as d, formatFileSize as f, isImageFile as p, mergeFileUploadSelection as m, removeFileAtIndex as h } from "@bridge-ui/core/Domain";
|
|
5
|
+
import { fileUploadRoundedProps as g, fileUploadSizeProps as _, fileUploadVariantProps as v } from "@bridge-ui/core/Tokens";
|
|
6
|
+
import { cn as y, mergeBridgeUILayeredClasses as b, splitComponentProps as x } from "@bridge-ui/core/Utils";
|
|
7
|
+
//#region src/Components/FileUpload/composables/useFileUpload.ts
|
|
8
|
+
var S = [
|
|
9
|
+
"size",
|
|
10
|
+
"color",
|
|
11
|
+
"error",
|
|
12
|
+
"label",
|
|
13
|
+
"title",
|
|
14
|
+
"accept",
|
|
15
|
+
"classes",
|
|
16
|
+
"maxSize",
|
|
17
|
+
"rounded",
|
|
18
|
+
"variant",
|
|
19
|
+
"disabled",
|
|
20
|
+
"maxFiles",
|
|
21
|
+
"multiple",
|
|
22
|
+
"required",
|
|
23
|
+
"modelValue",
|
|
24
|
+
"buttonLabel",
|
|
25
|
+
"customProps",
|
|
26
|
+
"description",
|
|
27
|
+
"defaultValue",
|
|
28
|
+
"errorMessage"
|
|
29
|
+
];
|
|
30
|
+
function C(C, w, T, E) {
|
|
31
|
+
let D = a(), te = o(), O = i(null), k = i(0), A = i(!1), j = i(), M = i([]), N = n(() => x({
|
|
32
|
+
bridgeKeys: S,
|
|
33
|
+
props: {
|
|
34
|
+
...D,
|
|
35
|
+
...C
|
|
36
|
+
}
|
|
37
|
+
})), { merged: P, entry: F } = t({
|
|
38
|
+
libDefaults: w,
|
|
39
|
+
componentName: "FileUpload",
|
|
40
|
+
props: () => N.value.componentProps
|
|
41
|
+
}), I = n(() => P.value.customProps), L = n(() => P.value.variant === "dropzone"), R = n(() => !!P.value.disabled), z = n(() => P.value.multiple ? P.value.maxFiles != null && P.value.maxFiles > 0 ? T.value.length < P.value.maxFiles : !0 : T.value.length === 0), B = n(() => z.value), V = n(() => P.value.errorMessage ?? j.value), H = n(() => P.value.error === !0 || V.value != null && V.value !== ""), U = ee({
|
|
42
|
+
entry: F,
|
|
43
|
+
props: () => N.value.componentProps
|
|
44
|
+
}), W = n(() => {
|
|
45
|
+
let e = b(_, F.value?.tokens?.size);
|
|
46
|
+
return c(e, P.value.size);
|
|
47
|
+
}), G = n(() => {
|
|
48
|
+
let e = b(g, F.value?.tokens?.rounded);
|
|
49
|
+
return c(e, P.value.rounded);
|
|
50
|
+
}), K = n(() => {
|
|
51
|
+
let e = b(v, F.value?.tokens?.variant);
|
|
52
|
+
return c(e, P.value.variant);
|
|
53
|
+
});
|
|
54
|
+
s(T, (e) => {
|
|
55
|
+
for (let e of M.value) e && URL.revokeObjectURL(e);
|
|
56
|
+
M.value = e.map((e) => p(e) ? URL.createObjectURL(e) : void 0);
|
|
57
|
+
}, { immediate: !0 }), r(() => {
|
|
58
|
+
for (let e of M.value) e && URL.revokeObjectURL(e);
|
|
59
|
+
});
|
|
60
|
+
function q(e, t) {
|
|
61
|
+
T.value = e, t > 0 ? j.value = t === 1 ? "1 file could not be added." : `${t} files could not be added.` : j.value = void 0;
|
|
62
|
+
}
|
|
63
|
+
function J(e) {
|
|
64
|
+
if (R.value || e.length === 0) return;
|
|
65
|
+
let t = m(T.value, e, {
|
|
66
|
+
accept: P.value.accept,
|
|
67
|
+
maxSize: P.value.maxSize,
|
|
68
|
+
maxFiles: P.value.maxFiles,
|
|
69
|
+
multiple: P.value.multiple
|
|
70
|
+
});
|
|
71
|
+
q(t.accepted, t.rejected.length);
|
|
72
|
+
}
|
|
73
|
+
function Y() {
|
|
74
|
+
!R.value && z.value && O.value?.click();
|
|
75
|
+
}
|
|
76
|
+
function X(e) {
|
|
77
|
+
if (R.value) return;
|
|
78
|
+
let t = T.value[e];
|
|
79
|
+
t && (T.value = h(T.value, e), E("remove", t, e), j.value = void 0);
|
|
80
|
+
}
|
|
81
|
+
function Z(e) {
|
|
82
|
+
let t = e.target;
|
|
83
|
+
J(u(t.files)), t.value = "";
|
|
84
|
+
}
|
|
85
|
+
function Q(e) {
|
|
86
|
+
e.preventDefault(), e.stopPropagation(), !R.value && L.value && z.value && (k.value += 1, A.value = !0);
|
|
87
|
+
}
|
|
88
|
+
function ne(e) {
|
|
89
|
+
e.preventDefault(), e.stopPropagation(), !R.value && L.value && (k.value = Math.max(0, k.value - 1), k.value === 0 && (A.value = !1));
|
|
90
|
+
}
|
|
91
|
+
function re(e) {
|
|
92
|
+
e.preventDefault(), e.stopPropagation(), !R.value && L.value && z.value && e.dataTransfer && (e.dataTransfer.dropEffect = "copy");
|
|
93
|
+
}
|
|
94
|
+
function ie(e) {
|
|
95
|
+
e.preventDefault(), e.stopPropagation(), k.value = 0, A.value = !1, !R.value && L.value && z.value && J(u(e.dataTransfer?.files));
|
|
96
|
+
}
|
|
97
|
+
function ae(e) {
|
|
98
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), Y());
|
|
99
|
+
}
|
|
100
|
+
let oe = n(() => e(I.value?.root, l(N.value.inheritedAttrs, ["class"]), y({
|
|
101
|
+
"flex w-full flex-col": !0,
|
|
102
|
+
[c(U.value, "root") ?? ""]: !0,
|
|
103
|
+
[String(N.value.inheritedAttrs.class ?? "")]: !0
|
|
104
|
+
}))), se = n(() => e(I.value?.input, {}, {
|
|
105
|
+
type: "file",
|
|
106
|
+
tabIndex: -1,
|
|
107
|
+
"aria-hidden": !0,
|
|
108
|
+
accept: P.value.accept,
|
|
109
|
+
onChange: Z,
|
|
110
|
+
multiple: P.value.multiple,
|
|
111
|
+
disabled: R.value || !z.value,
|
|
112
|
+
class: y({ "sr-only": !0 })
|
|
113
|
+
})), ce = n(() => e(I.value?.label, {}, y({
|
|
114
|
+
"mb-1 inline-flex items-center gap-1 text-sm font-medium text-dark-800 dark:text-dark-200": !0,
|
|
115
|
+
[c(U.value, "label") ?? ""]: !0
|
|
116
|
+
}))), le = n(() => e(I.value?.description, {}, y({
|
|
117
|
+
"mt-1 text-sm text-dark-500 dark:text-dark-400": !0,
|
|
118
|
+
[c(U.value, "description") ?? ""]: !0
|
|
119
|
+
}))), ue = n(() => e(I.value?.errorMessage, { role: "alert" }, y({
|
|
120
|
+
"mt-1 text-sm text-error-600 dark:text-error-400": !0,
|
|
121
|
+
[c(U.value, "errorMessage") ?? ""]: !0
|
|
122
|
+
}))), de = n(() => e(I.value?.trigger, {}, y({
|
|
123
|
+
[c(W.value, "trigger") ?? ""]: !0,
|
|
124
|
+
[c(U.value, "trigger") ?? ""]: !0
|
|
125
|
+
}))), fe = n(() => e(I.value?.dropzone, {
|
|
126
|
+
role: "button",
|
|
127
|
+
onDrop: ie,
|
|
128
|
+
onClick: Y,
|
|
129
|
+
onDragover: re,
|
|
130
|
+
onDragenter: Q,
|
|
131
|
+
onDragleave: ne,
|
|
132
|
+
onKeydown: ae,
|
|
133
|
+
tabindex: R.value || !z.value ? -1 : 0,
|
|
134
|
+
"aria-disabled": R.value || !z.value || void 0
|
|
135
|
+
}, y({
|
|
136
|
+
[c(W.value, "dropzone") ?? ""]: !0,
|
|
137
|
+
[G.value ?? ""]: !0,
|
|
138
|
+
[c(K.value, "surface") ?? ""]: !0,
|
|
139
|
+
[c(K.value, "dragging") ?? ""]: A.value,
|
|
140
|
+
"cursor-pointer": !R.value && z.value,
|
|
141
|
+
"pointer-events-none opacity-60": R.value || !z.value,
|
|
142
|
+
[c(U.value, "dropzone") ?? ""]: !0
|
|
143
|
+
}))), pe = n(() => e(I.value?.list, {}, y({
|
|
144
|
+
[c(W.value, "list") ?? ""]: !0,
|
|
145
|
+
[c(U.value, "list") ?? ""]: !0
|
|
146
|
+
})));
|
|
147
|
+
function $(t) {
|
|
148
|
+
return e(I.value?.item, {}, y({
|
|
149
|
+
[c(W.value, "item") ?? ""]: !0,
|
|
150
|
+
[G.value ?? ""]: !0,
|
|
151
|
+
[c(U.value, "item") ?? ""]: !0
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
let me = n(() => e(I.value?.media, {}, y({
|
|
155
|
+
[c(W.value, "media") ?? ""]: !0,
|
|
156
|
+
[G.value ?? ""]: !0,
|
|
157
|
+
[c(U.value, "media") ?? ""]: !0
|
|
158
|
+
}))), he = n(() => e(I.value?.content, {}, y({
|
|
159
|
+
[c(W.value, "content") ?? ""]: !0,
|
|
160
|
+
[c(U.value, "content") ?? ""]: !0
|
|
161
|
+
}))), ge = n(() => e(I.value?.title, {}, y({
|
|
162
|
+
[c(W.value, "title") ?? ""]: !0,
|
|
163
|
+
[c(U.value, "title") ?? ""]: !0
|
|
164
|
+
}))), _e = n(() => e({}, {}, y({ [c(W.value, "description") ?? ""]: !0 }))), ve = n(() => e(I.value?.actions, {}, y({
|
|
165
|
+
[c(W.value, "actions") ?? ""]: !0,
|
|
166
|
+
[c(U.value, "actions") ?? ""]: !0
|
|
167
|
+
}))), ye = n(() => P.value.buttonLabel == null ? P.value.multiple ? "Choose files" : "Choose file" : P.value.buttonLabel);
|
|
168
|
+
return {
|
|
169
|
+
slots: te,
|
|
170
|
+
merged: P,
|
|
171
|
+
dragging: A,
|
|
172
|
+
rootBind: oe,
|
|
173
|
+
listBind: pe,
|
|
174
|
+
labelBind: ce,
|
|
175
|
+
inputBind: se,
|
|
176
|
+
errorBind: ue,
|
|
177
|
+
mediaBind: me,
|
|
178
|
+
titleBind: ge,
|
|
179
|
+
fileItems: n(() => T.value.map((e, t) => ({
|
|
180
|
+
file: e,
|
|
181
|
+
index: t,
|
|
182
|
+
isImage: p(e),
|
|
183
|
+
metaLabel: d(e),
|
|
184
|
+
previewUrl: M.value[t],
|
|
185
|
+
sizeLabel: f(e.size),
|
|
186
|
+
remove: () => {
|
|
187
|
+
X(t);
|
|
188
|
+
}
|
|
189
|
+
}))),
|
|
190
|
+
showError: H,
|
|
191
|
+
isDropzone: L,
|
|
192
|
+
isDisabled: R,
|
|
193
|
+
showPicker: B,
|
|
194
|
+
canAddMore: z,
|
|
195
|
+
actionsBind: ve,
|
|
196
|
+
contentBind: he,
|
|
197
|
+
triggerBind: de,
|
|
198
|
+
getItemBind: $,
|
|
199
|
+
buttonLabel: ye,
|
|
200
|
+
dropzoneBind: fe,
|
|
201
|
+
openFileDialog: Y,
|
|
202
|
+
descriptionBind: le,
|
|
203
|
+
validationError: j,
|
|
204
|
+
itemDescriptionBind: _e,
|
|
205
|
+
resolvedErrorMessage: V,
|
|
206
|
+
inputRef: O
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
export { C as useFileUpload };
|