vueless 0.0.818 → 0.0.820
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/package.json +1 -1
- package/ui.container-divider/config.ts +1 -1
- package/ui.data-table/config.ts +1 -1
- package/ui.form-input-file/UInputFile.vue +9 -2
- package/ui.form-input-file/storybook/stories.ts +69 -19
- package/ui.text-file/UFile.vue +15 -6
- package/ui.text-file/types.ts +1 -1
- package/ui.text-files/UFiles.vue +26 -8
package/package.json
CHANGED
package/ui.data-table/config.ts
CHANGED
|
@@ -319,8 +319,15 @@ const {
|
|
|
319
319
|
:removable="multiple && !disabled"
|
|
320
320
|
@remove="onClickRemoveItem"
|
|
321
321
|
>
|
|
322
|
-
<template #
|
|
323
|
-
|
|
322
|
+
<template #default="{ id, label, url, imageUrl }">
|
|
323
|
+
<!--
|
|
324
|
+
@slot Use it to add a file directly.
|
|
325
|
+
@binding {string | number} id
|
|
326
|
+
@binding {string} label
|
|
327
|
+
@binding {string} url
|
|
328
|
+
@binding {string} image-url
|
|
329
|
+
-->
|
|
330
|
+
<slot :id="id" :label="label" :url="url" :image-url="imageUrl" />
|
|
324
331
|
</template>
|
|
325
332
|
</UFiles>
|
|
326
333
|
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import UInputFile from "../../ui.form-input-file/UInputFile.vue";
|
|
9
9
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
10
|
+
import UBadge from "../../ui.text-badge/UBadge.vue";
|
|
11
|
+
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
10
12
|
|
|
11
13
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
12
14
|
import type { Props } from "../types.ts";
|
|
@@ -21,7 +23,8 @@ export default {
|
|
|
21
23
|
title: "Form Inputs & Controls / Input File",
|
|
22
24
|
component: UInputFile,
|
|
23
25
|
args: {
|
|
24
|
-
label: "
|
|
26
|
+
label: "Choose a file to upload",
|
|
27
|
+
files: [],
|
|
25
28
|
},
|
|
26
29
|
argTypes: {
|
|
27
30
|
...getArgTypes(UInputFile.__name),
|
|
@@ -34,22 +37,14 @@ export default {
|
|
|
34
37
|
} as Meta;
|
|
35
38
|
|
|
36
39
|
const DefaultTemplate: StoryFn<UInputFileArgs> = (args: UInputFileArgs) => ({
|
|
37
|
-
components: { UInputFile },
|
|
40
|
+
components: { UInputFile, UBadge },
|
|
38
41
|
setup() {
|
|
39
42
|
const slots = getSlotNames(UInputFile.__name);
|
|
40
43
|
|
|
41
44
|
return { args, slots };
|
|
42
45
|
},
|
|
43
|
-
data() {
|
|
44
|
-
return {
|
|
45
|
-
files: [],
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
46
|
template: `
|
|
49
|
-
<UInputFile
|
|
50
|
-
v-bind="args"
|
|
51
|
-
v-model="files"
|
|
52
|
-
>
|
|
47
|
+
<UInputFile v-bind="args" v-model="args.files">
|
|
53
48
|
${args.slotTemplate || getSlotsFragment("")}
|
|
54
49
|
</UInputFile>
|
|
55
50
|
`,
|
|
@@ -79,14 +74,29 @@ const EnumVariantTemplate: StoryFn<UInputFileArgs> = (args: UInputFileArgs, { ar
|
|
|
79
74
|
export const Default = DefaultTemplate.bind({});
|
|
80
75
|
Default.args = {};
|
|
81
76
|
|
|
77
|
+
export const Description = DefaultTemplate.bind({});
|
|
78
|
+
Description.args = { description: "Ensure the document is clear and readable before uploading." };
|
|
79
|
+
|
|
80
|
+
export const Error = DefaultTemplate.bind({});
|
|
81
|
+
Error.args = { error: "Upload failed. Please try again later." };
|
|
82
|
+
|
|
83
|
+
export const Disabled = DefaultTemplate.bind({});
|
|
84
|
+
Disabled.args = { disabled: true };
|
|
85
|
+
|
|
82
86
|
export const Multiple = DefaultTemplate.bind({});
|
|
83
87
|
Multiple.args = { multiple: true };
|
|
84
88
|
|
|
85
|
-
export const
|
|
86
|
-
|
|
89
|
+
export const MaxFileSize = DefaultTemplate.bind({});
|
|
90
|
+
MaxFileSize.args = {
|
|
91
|
+
description: "File size limit is 5 MB.",
|
|
92
|
+
maxFileSize: 5,
|
|
93
|
+
};
|
|
87
94
|
|
|
88
|
-
export const
|
|
89
|
-
|
|
95
|
+
export const AllowedFileTypes = DefaultTemplate.bind({});
|
|
96
|
+
AllowedFileTypes.args = {
|
|
97
|
+
allowedFileTypes: ["png", "jpeg"],
|
|
98
|
+
description: "Only png and jpeg formats are allowed.",
|
|
99
|
+
};
|
|
90
100
|
|
|
91
101
|
export const Sizes = EnumVariantTemplate.bind({});
|
|
92
102
|
Sizes.args = { enum: "size" };
|
|
@@ -94,11 +104,51 @@ Sizes.args = { enum: "size" };
|
|
|
94
104
|
export const LabelAlign = EnumVariantTemplate.bind({});
|
|
95
105
|
LabelAlign.args = { enum: "labelAlign" };
|
|
96
106
|
|
|
97
|
-
export const
|
|
98
|
-
|
|
107
|
+
export const SlotLabel = DefaultTemplate.bind({});
|
|
108
|
+
SlotLabel.args = {
|
|
99
109
|
slotTemplate: `
|
|
100
|
-
<template #
|
|
101
|
-
|
|
110
|
+
<template #label="{ label }">
|
|
111
|
+
<UBadge :label="label" />
|
|
102
112
|
</template>
|
|
103
113
|
`,
|
|
104
114
|
};
|
|
115
|
+
|
|
116
|
+
export const Slots: StoryFn<UInputFileArgs> = (args) => ({
|
|
117
|
+
components: { UInputFile, UCol, UBadge, UIcon },
|
|
118
|
+
setup() {
|
|
119
|
+
return { args };
|
|
120
|
+
},
|
|
121
|
+
template: `
|
|
122
|
+
<UCol>
|
|
123
|
+
<UInputFile
|
|
124
|
+
v-bind="args"
|
|
125
|
+
v-model="args.files"
|
|
126
|
+
label="Slot Top"
|
|
127
|
+
>
|
|
128
|
+
<template #top>
|
|
129
|
+
<UBadge label="Pending Review..." />
|
|
130
|
+
</template>
|
|
131
|
+
</UInputFile>
|
|
132
|
+
|
|
133
|
+
<UInputFile
|
|
134
|
+
v-bind="args"
|
|
135
|
+
v-model="args.files"
|
|
136
|
+
label="Slot Left"
|
|
137
|
+
>
|
|
138
|
+
<template #left>
|
|
139
|
+
<UIcon name="info" color="orange" />
|
|
140
|
+
</template>
|
|
141
|
+
</UInputFile>
|
|
142
|
+
|
|
143
|
+
<UInputFile
|
|
144
|
+
v-bind="args"
|
|
145
|
+
v-model="args.files"
|
|
146
|
+
label="Slot Bottom"
|
|
147
|
+
>
|
|
148
|
+
<template #bottom>
|
|
149
|
+
<UBadge label="An antivirus check will be performed after file upload." />
|
|
150
|
+
</template>
|
|
151
|
+
</UInputFile>
|
|
152
|
+
</UCol>
|
|
153
|
+
`,
|
|
154
|
+
});
|
package/ui.text-file/UFile.vue
CHANGED
|
@@ -29,10 +29,10 @@ const emit = defineEmits([
|
|
|
29
29
|
|
|
30
30
|
const focus = ref(false);
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const fileId = props.id || useId();
|
|
33
33
|
|
|
34
34
|
function onRemove() {
|
|
35
|
-
emit("remove",
|
|
35
|
+
emit("remove", fileId);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function onFocus() {
|
|
@@ -61,9 +61,17 @@ const {
|
|
|
61
61
|
|
|
62
62
|
<template>
|
|
63
63
|
<ULink :href="url" v-bind="fileAttrs" :data-test="getDataTest()">
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
<!-- @slot Use it to add something before the file. -->
|
|
65
|
+
<slot name="left" />
|
|
66
|
+
|
|
67
|
+
<!--
|
|
68
|
+
@slot Use it to add a file directly.
|
|
69
|
+
@binding {string | number} id
|
|
70
|
+
@binding {string} label
|
|
71
|
+
@binding {string} url
|
|
72
|
+
@binding {string} image-url
|
|
73
|
+
-->
|
|
74
|
+
<slot :id="fileId" :label="label" :url="url" :image-url="imageUrl">
|
|
67
75
|
<div v-bind="bodyAttrs">
|
|
68
76
|
<img v-if="imageUrl" :alt="label" :src="imageUrl" v-bind="fileImageAttrs" />
|
|
69
77
|
|
|
@@ -82,7 +90,8 @@ const {
|
|
|
82
90
|
</div>
|
|
83
91
|
</slot>
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
<!-- @slot Use it to add something after the file. -->
|
|
94
|
+
<slot name="right">
|
|
86
95
|
<UIcon
|
|
87
96
|
v-if="removable"
|
|
88
97
|
internal
|
package/ui.text-file/types.ts
CHANGED
package/ui.text-files/UFiles.vue
CHANGED
|
@@ -86,20 +86,38 @@ const { getDataTest, filesLabelAttrs, itemsAttrs, itemAttrs } = useUI<Config>(de
|
|
|
86
86
|
:data-test="getDataTest(`item-${index}`)"
|
|
87
87
|
@remove="onRemoveFile"
|
|
88
88
|
>
|
|
89
|
-
<template #left
|
|
90
|
-
<!--
|
|
91
|
-
@
|
|
89
|
+
<template #left>
|
|
90
|
+
<!--
|
|
91
|
+
@slot Use it to add something left.
|
|
92
92
|
@binding {number} index
|
|
93
93
|
-->
|
|
94
|
-
<slot name="left" :
|
|
94
|
+
<slot name="left" :index="index" />
|
|
95
95
|
</template>
|
|
96
96
|
|
|
97
|
-
<template #
|
|
98
|
-
<!-- @slot Use it to add
|
|
99
|
-
@binding {
|
|
97
|
+
<template #default="{ id, label, url, imageUrl }">
|
|
98
|
+
<!-- @slot Use it to add a file directly.
|
|
99
|
+
@binding {string | number} id
|
|
100
|
+
@binding {string} label
|
|
101
|
+
@binding {string} url
|
|
102
|
+
@binding {string} image-url
|
|
100
103
|
@binding {number} index
|
|
101
104
|
-->
|
|
102
|
-
<slot
|
|
105
|
+
<slot
|
|
106
|
+
:id="id"
|
|
107
|
+
name="default"
|
|
108
|
+
:label="label"
|
|
109
|
+
:url="url"
|
|
110
|
+
:image-url="imageUrl"
|
|
111
|
+
:index="index"
|
|
112
|
+
/>
|
|
113
|
+
</template>
|
|
114
|
+
|
|
115
|
+
<template #right>
|
|
116
|
+
<!--
|
|
117
|
+
@slot Use it to add something right.
|
|
118
|
+
@binding {number} index
|
|
119
|
+
-->
|
|
120
|
+
<slot name="right" :index="index" />
|
|
103
121
|
</template>
|
|
104
122
|
</UFile>
|
|
105
123
|
</slot>
|