@weni/unnnic-system 3.2.6 → 3.2.7

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": "@weni/unnnic-system",
3
- "version": "3.2.6",
3
+ "version": "3.2.7",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -69,12 +69,19 @@
69
69
  'unnnic-data-table__body-row--loading',
70
70
  ]"
71
71
  >
72
- <img
73
- class="unnnic-data-table__body-cell--loading"
74
- data-testid="body-row-loading"
75
- src="../../assets/icons/weni-loading.svg"
76
- height="40"
77
- />
72
+ <td
73
+ :class="[
74
+ 'unnnic-data-table__body-cell',
75
+ `unnnic-data-table__body-cell--${size}`,
76
+ ]"
77
+ >
78
+ <img
79
+ class="unnnic-data-table__body-cell--loading"
80
+ data-testid="body-row-loading"
81
+ src="../../assets/icons/weni-loading.svg"
82
+ height="40"
83
+ />
84
+ </td>
78
85
  </tr>
79
86
  <template v-else-if="props.items.length">
80
87
  <tr
@@ -116,13 +123,16 @@
116
123
  </template>
117
124
  <tr
118
125
  v-else
119
- class="unnnic-data-table__body-row"
126
+ :class="[
127
+ 'unnnic-data-table__body-row',
128
+ 'unnnic-data-table__body-row--without-results',
129
+ ]"
120
130
  >
121
131
  <td
122
132
  v-if="slots['without-results']"
123
133
  :class="[
124
134
  'unnnic-data-table__body-cell',
125
- `unnnic-data-table__body-cell--${size}`,
135
+ `unnnic-data-table__body-cell--${size}`
126
136
  ]"
127
137
  >
128
138
  <slot name="without-results" />
@@ -197,7 +207,7 @@ defineOptions({
197
207
  const slots = useSlots();
198
208
 
199
209
  const emit = defineEmits<{
200
- 'update:sort': [sort: { header: string; order: string }];
210
+ 'update:sort': [sort: { header: string; itemKey: string; order: string }];
201
211
  itemClick: [item: DataTableItem];
202
212
  'update:page': [page: number];
203
213
  }>();
@@ -245,6 +255,7 @@ const headersItemsKeys: ComputedRef<string[]> = computed(() => {
245
255
 
246
256
  const sort = ref({
247
257
  header: '',
258
+ itemKey: '',
248
259
  order: '',
249
260
  });
250
261
 
@@ -262,8 +273,8 @@ const gridTemplateColumns: ComputedRef<string> = computed(() => {
262
273
  return columnSizes.join(' ');
263
274
  });
264
275
 
265
- const handleSort = (key: string, order: string) => {
266
- sort.value = { header: key, order };
276
+ const handleSort = (header: typeof sort.value, order: string) => {
277
+ sort.value = { ...header, order };
267
278
  emit('update:sort', sort.value);
268
279
  };
269
280
 
@@ -281,7 +292,7 @@ const handleClickHeader = (header: DataTableHeader) => {
281
292
  ? 'asc'
282
293
  : nextSortOrderMapper[sort.value.order];
283
294
 
284
- handleSort(nextSort === '' ? '' : header.title, nextSort);
295
+ handleSort(nextSort === '' ? { header: '', itemKey: '', order: '' } : { header: header.title, itemKey: header.itemKey, order: nextSort }, nextSort);
285
296
  };
286
297
 
287
298
  const handleClickRow = (item: DataTableItem) => {
@@ -398,7 +409,8 @@ $tableBorder: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
398
409
 
399
410
  grid-template-columns: v-bind(gridTemplateColumns);
400
411
 
401
- &--loading {
412
+ &--loading,
413
+ &--without-results {
402
414
  grid-template-columns: 1fr;
403
415
  }
404
416
 
@@ -433,7 +445,7 @@ $tableBorder: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
433
445
  }
434
446
 
435
447
  &-cell--loading {
436
- margin: $unnnic-spacing-xl 0;
448
+ margin: $unnnic-space-10 0;
437
449
  padding: 0;
438
450
 
439
451
  width: 100%;
@@ -11,7 +11,7 @@
11
11
  @dragleave.stop.prevent="dragleave"
12
12
  @dragend.stop.prevent="dragend"
13
13
  @drop.stop.prevent="drop"
14
- @click="() => $refs.file.click()"
14
+ @click="handleDropzoneClick"
15
15
  >
16
16
  <UnnnicIcon
17
17
  class="unnnic-upload-area__dropzone__icon"
@@ -64,7 +64,7 @@
64
64
  </template>
65
65
 
66
66
  <script setup>
67
- import { ref, computed, getCurrentInstance } from 'vue';
67
+ import { ref, computed, getCurrentInstance, useTemplateRef } from 'vue';
68
68
  import mime from 'mime';
69
69
 
70
70
  import UnnnicIcon from '../Icon.vue';
@@ -73,6 +73,7 @@ const isDragging = ref(false);
73
73
  const hasError = ref(false);
74
74
  const dragEnterCounter = ref(0);
75
75
  const file = ref();
76
+ const fileRef = useTemplateRef('file');
76
77
 
77
78
  const props = defineProps({
78
79
  acceptMultiple: {
@@ -111,6 +112,11 @@ const props = defineProps({
111
112
  type: String,
112
113
  default: '',
113
114
  },
115
+
116
+ disabled: {
117
+ type: Boolean,
118
+ default: false,
119
+ }
114
120
  });
115
121
 
116
122
  const emit = defineEmits([
@@ -135,15 +141,21 @@ const formattedSupportedFormats = computed(() => {
135
141
  });
136
142
 
137
143
  function dragenter() {
144
+ if (props.disabled) return;
145
+
138
146
  dragEnterCounter.value += 1;
139
147
  isDragging.value = true;
140
148
  }
141
149
 
142
150
  function dragover() {
151
+ if (props.disabled) return;
152
+
143
153
  isDragging.value = true;
144
154
  }
145
155
 
146
156
  function dragleave() {
157
+ if (props.disabled) return;
158
+
147
159
  dragEnterCounter.value -= 1;
148
160
  if (dragEnterCounter.value === 0) {
149
161
  isDragging.value = false;
@@ -151,10 +163,14 @@ function dragleave() {
151
163
  }
152
164
 
153
165
  function dragend() {
166
+ if (props.disabled) return;
167
+
154
168
  isDragging.value = false;
155
169
  }
156
170
 
157
171
  function drop(event) {
172
+ if (props.disabled) return;
173
+
158
174
  isDragging.value = false;
159
175
 
160
176
  const { files } = event.dataTransfer;
@@ -164,7 +180,15 @@ function drop(event) {
164
180
  }
165
181
  }
166
182
 
183
+ function handleDropzoneClick() {
184
+ if (props.disabled) return;
185
+
186
+ fileRef.value.click();
187
+ }
188
+
167
189
  function handleFileChange(event) {
190
+ if (props.disabled) return;
191
+
168
192
  const { files } = event.target;
169
193
 
170
194
  if (validateFiles(files)) {
@@ -76,8 +76,8 @@ export default {
76
76
  UnnnicDataTable,
77
77
  },
78
78
  setup() {
79
- const sort = ({ order, header }) => {
80
- action('update:sort')({ order, header });
79
+ const sort = ({ order, header, itemKey }) => {
80
+ action('update:sort')({ order, header, itemKey });
81
81
  if (order === 'asc')
82
82
  args.items = args.items.sort((a, b) => a.id - b.id);
83
83
  if (order === 'desc')