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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.818",
3
+ "version": "0.0.820",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: {
3
- base: "flex",
3
+ base: "flex relative",
4
4
  variants: {
5
5
  vertical: {
6
6
  true: "h-full w-fit",
@@ -82,7 +82,7 @@ export default /*tw*/ {
82
82
  },
83
83
  bodySelectedDateDivider: {
84
84
  base: "{>bodyDateDivider}",
85
- label: "bg-gray-100 transition",
85
+ label: "!bg-gray-100 transition",
86
86
  },
87
87
  bodyEmptyState: "{UEmpty} my-8",
88
88
  bodyEmptyStateCell: "",
@@ -319,8 +319,15 @@ const {
319
319
  :removable="multiple && !disabled"
320
320
  @remove="onClickRemoveItem"
321
321
  >
322
- <template #right="{ file }">
323
- <slot name="right" :file="file" />
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: "Vueless file input",
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 AllowedFileTypes = DefaultTemplate.bind({});
86
- AllowedFileTypes.args = { allowedFileTypes: ["png", "jpeg"], label: "Allow only png and jpeg" };
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 Error = DefaultTemplate.bind({});
89
- Error.args = { error: "some error" };
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 SlotLeft = DefaultTemplate.bind({});
98
- SlotLeft.args = {
107
+ export const SlotLabel = DefaultTemplate.bind({});
108
+ SlotLabel.args = {
99
109
  slotTemplate: `
100
- <template #left>
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
+ });
@@ -29,10 +29,10 @@ const emit = defineEmits([
29
29
 
30
30
  const focus = ref(false);
31
31
 
32
- const elementId = props.id || useId();
32
+ const fileId = props.id || useId();
33
33
 
34
34
  function onRemove() {
35
- emit("remove", props.id);
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
- <slot name="left" :file="{ elementId, label, url, imageUrl }" />
65
-
66
- <slot :file="{ elementId, label, url, imageUrl }">
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
- <slot name="right" :file="{ elementId, label, url, imageUrl }">
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
@@ -25,7 +25,7 @@ export interface Props {
25
25
  size?: "sm" | "md" | "lg";
26
26
 
27
27
  /**
28
- * Unique element id.
28
+ * Unique file id.
29
29
  */
30
30
  id?: string;
31
31
 
@@ -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="{ file: currentFile }">
90
- <!-- @slot Use it to add something left.
91
- @binding {object} file
89
+ <template #left>
90
+ <!--
91
+ @slot Use it to add something left.
92
92
  @binding {number} index
93
93
  -->
94
- <slot name="left" :file="currentFile" :index="index" />
94
+ <slot name="left" :index="index" />
95
95
  </template>
96
96
 
97
- <template #right="{ file: currentFile }">
98
- <!-- @slot Use it to add something right.
99
- @binding {object} file
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 name="right" :file="currentFile" :index="index" />
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>