@v1nt1248/3nclient-lib 0.3.13 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui3n-input-file/types.d.ts +7 -0
- package/dist/components/ui3n-input-file/ui3n-input-file.vue.d.ts +17 -2
- package/dist/style.css +1 -1
- package/dist/ui3n-components.js +11 -11
- package/package.json +1 -1
- package/src/components/ui3n-input-file/types.ts +9 -0
- package/src/components/ui3n-input-file/ui3n-input-file.vue +26 -25
package/dist/ui3n-components.js
CHANGED
|
@@ -18089,23 +18089,23 @@ var Wo = {
|
|
|
18089
18089
|
function o(e) {
|
|
18090
18090
|
n.disabled || (e.stopImmediatePropagation(), a.value?.click());
|
|
18091
18091
|
}
|
|
18092
|
-
function
|
|
18092
|
+
function u(e) {
|
|
18093
18093
|
if (!e) return !1;
|
|
18094
18094
|
if (!n.maxFileSize) return !0;
|
|
18095
18095
|
let { name: t, size: i } = e;
|
|
18096
18096
|
return i > n.maxFileSize ? (r("error", `The [${t}] file is too big. Maximum file size ${co(n.maxFileSize)}`), !1) : !0;
|
|
18097
18097
|
}
|
|
18098
|
-
function
|
|
18098
|
+
function d(e) {
|
|
18099
18099
|
if (!e) return !1;
|
|
18100
18100
|
let { name: t } = e, i = `.${(0, Ts.default)(t.split("."))}`.toLowerCase(), a = n.allowedFileTypes.split(",").map((e) => (0, Es.default)(e).toLowerCase()), o = a.includes("*") || a.includes(i);
|
|
18101
18101
|
return o || r("error", `The [${t}] file type is not valid.`), o;
|
|
18102
18102
|
}
|
|
18103
|
-
function
|
|
18103
|
+
function f(e) {
|
|
18104
18104
|
if (!e) return !1;
|
|
18105
18105
|
let { name: t } = e, i = [...n.modelValue].find((e) => e.name === t);
|
|
18106
18106
|
return i && r("error", `The [${t}] file has already been downloaded.`), !i;
|
|
18107
18107
|
}
|
|
18108
|
-
function
|
|
18108
|
+
function p(e = []) {
|
|
18109
18109
|
if (!n.maxNumberOfFiles) return !0;
|
|
18110
18110
|
let t = e.reduce((e, t) => {
|
|
18111
18111
|
let { size: n } = t;
|
|
@@ -18113,21 +18113,21 @@ var Wo = {
|
|
|
18113
18113
|
}, 0) <= Number(n.maxNumberOfFiles);
|
|
18114
18114
|
return t || r("error", `You cannot select more than ${n.maxNumberOfFiles} files.`), t;
|
|
18115
18115
|
}
|
|
18116
|
-
function
|
|
18116
|
+
function m(e) {
|
|
18117
18117
|
if ((0, ws.default)(e)) {
|
|
18118
|
-
if (!
|
|
18119
|
-
let t = e.filter((e) =>
|
|
18118
|
+
if (!p(e)) return;
|
|
18119
|
+
let t = e.filter((e) => f(e)).filter((e) => u(e)).filter((e) => d(e));
|
|
18120
18120
|
(0, ws.default)(t) > 0 && r("update:modelValue", [...n.modelValue, ...t]);
|
|
18121
18121
|
}
|
|
18122
18122
|
}
|
|
18123
|
-
function
|
|
18124
|
-
a.value && a.value.files &&
|
|
18123
|
+
function h() {
|
|
18124
|
+
a.value && a.value.files && m([...a.value.files]), a.value && (a.value.value = "");
|
|
18125
18125
|
}
|
|
18126
18126
|
return (t, n) => (x(), s("div", { class: g(t.$style.ui3nInputFile) }, [c("label", {
|
|
18127
18127
|
for: A(i),
|
|
18128
18128
|
class: g([t.$style.label, e.disabled && t.$style.disabled]),
|
|
18129
18129
|
onClick: B(o, ["stop", "prevent"])
|
|
18130
|
-
}, D(e.buttonText),
|
|
18130
|
+
}, [T(t.$slots, "default", {}, () => [l(D(e.buttonText), 1)])], 10, Ds), c("input", {
|
|
18131
18131
|
id: A(i),
|
|
18132
18132
|
ref_key: "fileInput",
|
|
18133
18133
|
ref: a,
|
|
@@ -18137,7 +18137,7 @@ var Wo = {
|
|
|
18137
18137
|
multiple: e.multiple,
|
|
18138
18138
|
accept: e.allowedFileTypes,
|
|
18139
18139
|
disabled: e.disabled,
|
|
18140
|
-
onChange:
|
|
18140
|
+
onChange: h
|
|
18141
18141
|
}, null, 40, Os)], 2));
|
|
18142
18142
|
}
|
|
18143
18143
|
}), [["__cssModules", { $style: {
|
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
|
|
1
3
|
export interface Ui3nInputFileProps {
|
|
2
4
|
/**
|
|
3
5
|
* Selected files
|
|
@@ -41,3 +43,10 @@ export interface Ui3nInputFileEmits {
|
|
|
41
43
|
*/
|
|
42
44
|
(event: 'error', value: string): void;
|
|
43
45
|
}
|
|
46
|
+
|
|
47
|
+
export interface Ui3nInputFileSlots {
|
|
48
|
+
/**
|
|
49
|
+
* Default slot
|
|
50
|
+
*/
|
|
51
|
+
default: () => VNode;
|
|
52
|
+
}
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="$style.ui3nInputFile">
|
|
3
|
-
<label
|
|
4
|
-
:for="id"
|
|
5
|
-
:class="[$style.label, disabled && $style.disabled]"
|
|
6
|
-
@click.stop.prevent="selectFiles"
|
|
7
|
-
>
|
|
8
|
-
{{ buttonText }}
|
|
9
|
-
</label>
|
|
10
|
-
|
|
11
|
-
<input
|
|
12
|
-
:id="id"
|
|
13
|
-
ref="fileInput"
|
|
14
|
-
type="file"
|
|
15
|
-
name="file"
|
|
16
|
-
hidden
|
|
17
|
-
:multiple="multiple"
|
|
18
|
-
:accept="allowedFileTypes"
|
|
19
|
-
:disabled="disabled"
|
|
20
|
-
@change="onChange"
|
|
21
|
-
>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
1
|
<script lang="ts" setup>
|
|
26
2
|
import { ref } from 'vue';
|
|
27
3
|
import size from 'lodash/size';
|
|
28
4
|
import last from 'lodash/last';
|
|
29
5
|
import trim from 'lodash/trim';
|
|
30
6
|
import { getRandomId, formatFileSize } from '@/utils';
|
|
31
|
-
import type { Ui3nInputFileProps, Ui3nInputFileEmits } from './types';
|
|
7
|
+
import type { Ui3nInputFileProps, Ui3nInputFileEmits, Ui3nInputFileSlots } from './types';
|
|
32
8
|
import type { Nullable } from '@/types';
|
|
33
9
|
|
|
34
10
|
const props = withDefaults(defineProps<Ui3nInputFileProps>(), {
|
|
@@ -37,6 +13,7 @@
|
|
|
37
13
|
allowedFileTypes: '*',
|
|
38
14
|
});
|
|
39
15
|
const emits = defineEmits<Ui3nInputFileEmits>();
|
|
16
|
+
defineSlots<Ui3nInputFileSlots>();
|
|
40
17
|
|
|
41
18
|
const id = getRandomId(4);
|
|
42
19
|
const fileInput = ref<Nullable<HTMLInputElement>>(null);
|
|
@@ -141,6 +118,30 @@
|
|
|
141
118
|
}
|
|
142
119
|
</script>
|
|
143
120
|
|
|
121
|
+
<template>
|
|
122
|
+
<div :class="$style.ui3nInputFile">
|
|
123
|
+
<label
|
|
124
|
+
:for="id"
|
|
125
|
+
:class="[$style.label, disabled && $style.disabled]"
|
|
126
|
+
@click.stop.prevent="selectFiles"
|
|
127
|
+
>
|
|
128
|
+
<slot>{{ buttonText }}</slot>
|
|
129
|
+
</label>
|
|
130
|
+
|
|
131
|
+
<input
|
|
132
|
+
:id="id"
|
|
133
|
+
ref="fileInput"
|
|
134
|
+
type="file"
|
|
135
|
+
name="file"
|
|
136
|
+
hidden
|
|
137
|
+
:multiple="multiple"
|
|
138
|
+
:accept="allowedFileTypes"
|
|
139
|
+
:disabled="disabled"
|
|
140
|
+
@change="onChange"
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
</template>
|
|
144
|
+
|
|
144
145
|
<style lang="scss" module>
|
|
145
146
|
.ui3nInputFile {
|
|
146
147
|
position: relative;
|