@v1nt1248/3nclient-lib 0.3.14 → 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.
@@ -1,3 +1,4 @@
1
+ import { VNode } from 'vue';
1
2
  export interface Ui3nInputFileProps {
2
3
  /**
3
4
  * Selected files
@@ -40,3 +41,9 @@ export interface Ui3nInputFileEmits {
40
41
  */
41
42
  (event: 'error', value: string): void;
42
43
  }
44
+ export interface Ui3nInputFileSlots {
45
+ /**
46
+ * Default slot
47
+ */
48
+ default: () => VNode;
49
+ }
@@ -1,5 +1,14 @@
1
- import { Ui3nInputFileProps } from './types';
2
- declare const _default: import('vue').DefineComponent<Ui3nInputFileProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
1
+ import { Ui3nInputFileProps, Ui3nInputFileSlots } from './types';
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: Readonly<Ui3nInputFileSlots> & Ui3nInputFileSlots;
5
+ refs: {
6
+ fileInput: HTMLInputElement;
7
+ };
8
+ rootEl: HTMLDivElement;
9
+ };
10
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
11
+ declare const __VLS_component: import('vue').DefineComponent<Ui3nInputFileProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
3
12
  error: (value: string) => any;
4
13
  "update:modelValue": (value: FileList | File[]) => any;
5
14
  }, string, import('vue').PublicProps, Readonly<Ui3nInputFileProps> & Readonly<{
@@ -12,4 +21,10 @@ declare const _default: import('vue').DefineComponent<Ui3nInputFileProps, {}, {}
12
21
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
13
22
  fileInput: HTMLInputElement;
14
23
  }, HTMLDivElement>;
24
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
15
25
  export default _default;
26
+ type __VLS_WithTemplateSlots<T, S> = T & {
27
+ new (): {
28
+ $slots: S;
29
+ };
30
+ };
@@ -18089,23 +18089,23 @@ var Wo = {
18089
18089
  function o(e) {
18090
18090
  n.disabled || (e.stopImmediatePropagation(), a.value?.click());
18091
18091
  }
18092
- function l(e) {
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 u(e) {
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 d(e) {
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 f(e = []) {
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 p(e) {
18116
+ function m(e) {
18117
18117
  if ((0, ws.default)(e)) {
18118
- if (!f(e)) return;
18119
- let t = e.filter((e) => d(e)).filter((e) => l(e)).filter((e) => u(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 m() {
18124
- a.value && a.value.files && p([...a.value.files]), a.value && (a.value.value = "");
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), 11, Ds), c("input", {
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: m
18140
+ onChange: h
18141
18141
  }, null, 40, Os)], 2));
18142
18142
  }
18143
18143
  }), [["__cssModules", { $style: {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.3.14",
5
+ "version": "0.3.15",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -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;