vueless 0.0.461 → 0.0.463

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.461",
3
+ "version": "0.0.463",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -25,8 +25,8 @@
25
25
  <template #left-icon="{ iconName, iconSize }">
26
26
  <!--
27
27
  @slot Use it add an icon before the date.
28
- @binding {string} iconName
29
- @binding {string} iconSize
28
+ @binding {string} icon-name
29
+ @binding {string} icon-nize
30
30
  -->
31
31
  <slot name="left-icon" :icon-name="iconName" :icon-size="iconSize" />
32
32
  </template>
@@ -34,8 +34,8 @@
34
34
  <template #right-icon="{ iconName, iconSize }">
35
35
  <!--
36
36
  @slot Use it add an icon after the date.
37
- @binding {string} iconName
38
- @binding {string} iconSize
37
+ @binding {string} icon-name
38
+ @binding {string} icon-size
39
39
  -->
40
40
  <slot name="right-icon" :icon-name="iconName" :icon-size="iconSize">
41
41
  <UIcon :name="iconName" :size="iconSize" color="gray" />
@@ -21,22 +21,15 @@
21
21
 
22
22
  <span v-if="!isValue" v-bind="placeholderAttrs" v-text="currentLocale.noFile" />
23
23
 
24
- <UFiles :size="size" v-bind="fileListAttrs" :file-list="fileList">
24
+ <UFiles
25
+ :size="size"
26
+ v-bind="fileListAttrs"
27
+ :file-list="fileList"
28
+ :removable="multiple && !disabled"
29
+ @remove="onClickRemoveItem"
30
+ >
25
31
  <template #right="{ file }">
26
- <UButton
27
- v-if="props.multiple && !disabled"
28
- round
29
- filled
30
- square
31
- no-ring
32
- variant="thirdary"
33
- :size="removeItemButtonSize"
34
- :left-icon="config.defaults.removeItemIcon"
35
- :disabled="disabled"
36
- v-bind="removeItemButtonAttrs"
37
- :data-test="`${dataTest}-remove-item`"
38
- @click.stop.prevent="onClickRemoveItem(file.id)"
39
- />
32
+ <slot name="right" :file="file" />
40
33
  </template>
41
34
  </UFiles>
42
35
 
@@ -254,7 +247,6 @@ const {
254
247
  inputAttrs,
255
248
  fileListAttrs,
256
249
  buttonsAttrs,
257
- removeItemButtonAttrs,
258
250
  hasSlotContent,
259
251
  } = useAttrs(props);
260
252
 
@@ -299,16 +291,6 @@ const fileList = computed(() => {
299
291
  return currentFiles.value ? [currentFiles.value] : [];
300
292
  });
301
293
 
302
- const removeItemButtonSize = computed(() => {
303
- const sizes = {
304
- sm: "2xs",
305
- md: "xs",
306
- lg: "sm",
307
- };
308
-
309
- return sizes[props.size];
310
- });
311
-
312
294
  const buttonSize = computed(() => {
313
295
  const sizes = {
314
296
  sm: "xs",
@@ -60,7 +60,6 @@ export default /*tw*/ {
60
60
  },
61
61
  },
62
62
  clearButton: "{UButton}",
63
- removeItemButton: "{UButton} ml-2",
64
63
  input: "sr-only",
65
64
  i18n: {
66
65
  sizeError: "File size is too big.",
@@ -78,6 +77,5 @@ export default /*tw*/ {
78
77
  /* icons */
79
78
  chooseFileIcon: "attach_file",
80
79
  clearIcon: "close",
81
- removeItemIcon: "close",
82
80
  },
83
81
  };
@@ -22,7 +22,21 @@
22
22
  </div>
23
23
  </slot>
24
24
 
25
- <slot name="right" :file="{ elementId, label, url, imageUrl }" />
25
+ <slot name="right" :file="{ elementId, label, url, imageUrl }">
26
+ <UButton
27
+ v-if="removable"
28
+ round
29
+ filled
30
+ square
31
+ no-ring
32
+ variant="thirdary"
33
+ :size="removeButtonSize"
34
+ :icon="config.defaults.removeIcon"
35
+ v-bind="removeButtonAttrs"
36
+ :data-test="`${dataTest}-remove-item`"
37
+ @click.stop.prevent="onRemove"
38
+ />
39
+ </slot>
26
40
  </ULink>
27
41
  </template>
28
42
 
@@ -31,6 +45,7 @@ import { computed, ref, useId } from "vue";
31
45
 
32
46
  import ULink from "../ui.button-link/ULink.vue";
33
47
  import UIcon from "../ui.image-icon/UIcon.vue";
48
+ import UButton from "../ui.button/UButton.vue";
34
49
 
35
50
  import { getDefault } from "../utils/utilUI.js";
36
51
 
@@ -82,6 +97,14 @@ const props = defineProps({
82
97
  default: "",
83
98
  },
84
99
 
100
+ /**
101
+ * Show remove button.
102
+ */
103
+ removable: {
104
+ type: Boolean,
105
+ default: false,
106
+ },
107
+
85
108
  /**
86
109
  * Component config object.
87
110
  */
@@ -99,12 +122,27 @@ const props = defineProps({
99
122
  },
100
123
  });
101
124
 
125
+ const emit = defineEmits([
126
+ /**
127
+ * Triggers when remove button is clicked.
128
+ * @property {string} fileId
129
+ */
130
+ "remove",
131
+ ]);
132
+
102
133
  const focus = ref(false);
103
134
 
104
135
  const elementId = props.id || useId();
105
136
 
106
- const { config, fileAttrs, bodyAttrs, fileIconAttrs, fileLabelAttrs, fileImageAttrs } =
107
- useAttrs(props);
137
+ const {
138
+ config,
139
+ fileAttrs,
140
+ bodyAttrs,
141
+ fileIconAttrs,
142
+ fileLabelAttrs,
143
+ fileImageAttrs,
144
+ removeButtonAttrs,
145
+ } = useAttrs(props);
108
146
 
109
147
  const iconSize = computed(() => {
110
148
  const sizes = {
@@ -116,6 +154,20 @@ const iconSize = computed(() => {
116
154
  return sizes[props.size];
117
155
  });
118
156
 
157
+ const removeButtonSize = computed(() => {
158
+ const sizes = {
159
+ sm: "2xs",
160
+ md: "xs",
161
+ lg: "sm",
162
+ };
163
+
164
+ return sizes[props.size];
165
+ });
166
+
167
+ function onRemove() {
168
+ emit("remove", props.id);
169
+ }
170
+
119
171
  function onFocus() {
120
172
  focus.value = true;
121
173
  }
@@ -13,9 +13,11 @@ export default /*tw*/ {
13
13
  fileImage: "rounded-sm max-w-7",
14
14
  fileIcon: "{UIcon}",
15
15
  fileLabel: "{ULink}",
16
+ removeButton: "{UButton} ml-2",
16
17
  defaults: {
17
18
  size: "md",
18
19
  /* icons */
19
20
  fileIcon: "description",
21
+ removeIcon: "close",
20
22
  },
21
23
  };
@@ -17,8 +17,10 @@
17
17
  :url="file.url"
18
18
  :image-url="file.imageUrl"
19
19
  :size="size"
20
+ :removable="removable"
20
21
  v-bind="itemAttrs"
21
22
  :data-test="`${dataTest}-item`"
23
+ @remove="onRemoveFile"
22
24
  >
23
25
  <template #left="{ file: currentFile }">
24
26
  <!-- @slot Use it to add something left.
@@ -96,6 +98,14 @@ const props = defineProps({
96
98
  default: getDefault(defaultConfig, UFiles).size,
97
99
  },
98
100
 
101
+ /**
102
+ * Show remove button for each file
103
+ */
104
+ removable: {
105
+ type: Boolean,
106
+ default: false,
107
+ },
108
+
99
109
  /**
100
110
  * Component config object.
101
111
  */
@@ -113,6 +123,14 @@ const props = defineProps({
113
123
  },
114
124
  });
115
125
 
126
+ const emit = defineEmits([
127
+ /**
128
+ * Triggers when remove button is clicked.
129
+ * @property {string} fileId
130
+ */
131
+ "remove",
132
+ ]);
133
+
116
134
  const { filesLabelAttrs, itemsAttrs, itemAttrs } = useAttrs(props);
117
135
 
118
136
  const formattedFileList = computed(() =>
@@ -125,4 +143,8 @@ const formattedFileList = computed(() =>
125
143
  };
126
144
  }),
127
145
  );
146
+
147
+ function onRemoveFile(fileId) {
148
+ emit("remove", fileId);
149
+ }
128
150
  </script>
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.461",
4
+ "version": "0.0.463",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -2575,6 +2575,7 @@
2575
2575
  "description": "Use it add an icon before the date.",
2576
2576
  "bindings": [
2577
2577
  {
2578
+ "type": "string",
2578
2579
  "name": "icon-name"
2579
2580
  },
2580
2581
  {
@@ -2588,9 +2589,11 @@
2588
2589
  "description": "Use it add an icon after the date.",
2589
2590
  "bindings": [
2590
2591
  {
2592
+ "type": "string",
2591
2593
  "name": "icon-name"
2592
2594
  },
2593
2595
  {
2596
+ "type": "string",
2594
2597
  "name": "icon-size"
2595
2598
  }
2596
2599
  ]
@@ -4070,6 +4073,15 @@
4070
4073
  },
4071
4074
  "default": "\"\""
4072
4075
  },
4076
+ {
4077
+ "name": "removable",
4078
+ "description": "Show remove button.",
4079
+ "value": {
4080
+ "kind": "expression",
4081
+ "type": "boolean"
4082
+ },
4083
+ "default": "false"
4084
+ },
4073
4085
  {
4074
4086
  "name": "config",
4075
4087
  "description": "Component config object.",
@@ -4089,6 +4101,20 @@
4089
4101
  "default": "\"\""
4090
4102
  }
4091
4103
  ],
4104
+ "events": [
4105
+ {
4106
+ "name": "remove",
4107
+ "description": "Triggers when remove button is clicked.",
4108
+ "properties": [
4109
+ {
4110
+ "type": [
4111
+ "string"
4112
+ ],
4113
+ "name": "fileId"
4114
+ }
4115
+ ]
4116
+ }
4117
+ ],
4092
4118
  "slots": [
4093
4119
  {
4094
4120
  "name": "left",
@@ -4172,6 +4198,15 @@
4172
4198
  },
4173
4199
  "default": "md"
4174
4200
  },
4201
+ {
4202
+ "name": "removable",
4203
+ "description": "Show remove button for each file",
4204
+ "value": {
4205
+ "kind": "expression",
4206
+ "type": "boolean"
4207
+ },
4208
+ "default": "false"
4209
+ },
4175
4210
  {
4176
4211
  "name": "config",
4177
4212
  "description": "Component config object.",
@@ -4191,6 +4226,20 @@
4191
4226
  "default": "\"\""
4192
4227
  }
4193
4228
  ],
4229
+ "events": [
4230
+ {
4231
+ "name": "remove",
4232
+ "description": "Triggers when remove button is clicked.",
4233
+ "properties": [
4234
+ {
4235
+ "type": [
4236
+ "string"
4237
+ ],
4238
+ "name": "fileId"
4239
+ }
4240
+ ]
4241
+ }
4242
+ ],
4194
4243
  "slots": [
4195
4244
  {
4196
4245
  "name": "default",
@@ -4967,6 +5016,15 @@
4967
5016
  "name": "left",
4968
5017
  "description": "Use it to add something before the placeholder."
4969
5018
  },
5019
+ {
5020
+ "name": "right",
5021
+ "scoped": true,
5022
+ "bindings": [
5023
+ {
5024
+ "name": "file"
5025
+ }
5026
+ ]
5027
+ },
4970
5028
  {
4971
5029
  "name": "bottom",
4972
5030
  "description": "Use it to add something below the component content."