@weni/unnnic-system 2.1.1 → 2.2.0
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/CHANGELOG.md +6 -0
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +178 -163
- package/dist/unnnic.umd.js +14 -14
- package/package.json +1 -1
- package/src/components/TableNext/TableNext.vue +15 -2
- package/src/components/TableNext/validation.js +11 -3
- package/src/stories/TableNext.stories.js +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<table class="unnnic-table-next">
|
|
3
3
|
<thead class="unnnic-table-next__header">
|
|
4
|
-
<tr
|
|
4
|
+
<tr
|
|
5
|
+
class="unnnic-table-next__header-row"
|
|
6
|
+
:style="{ gridTemplateColumns }"
|
|
7
|
+
>
|
|
5
8
|
<th
|
|
6
9
|
v-for="(cell, index) of headers"
|
|
7
10
|
:key="cell.content + index"
|
|
@@ -28,10 +31,14 @@
|
|
|
28
31
|
v-for="(row, index) of rows"
|
|
29
32
|
:key="row.content + index"
|
|
30
33
|
class="unnnic-table-next__body-row"
|
|
34
|
+
:style="{
|
|
35
|
+
gridTemplateColumns: row.link ? 'auto' : gridTemplateColumns,
|
|
36
|
+
}"
|
|
31
37
|
>
|
|
32
38
|
<a
|
|
33
39
|
v-if="row.link"
|
|
34
40
|
class="unnnic-table-next__body-row--redirect"
|
|
41
|
+
:style="{ gridTemplateColumns }"
|
|
35
42
|
:href="row.link.url"
|
|
36
43
|
:target="row.link.target || '_blank'"
|
|
37
44
|
>
|
|
@@ -92,6 +99,7 @@ export default {
|
|
|
92
99
|
/**
|
|
93
100
|
* @typedef {Array} HeaderItem
|
|
94
101
|
* @property {string} content - The content of the header cell.
|
|
102
|
+
* @property {number} size - The size of the header cell in fractions.
|
|
95
103
|
* @property {boolean|undefined} isSortable - Indicates if the cell is enabled for sorting.
|
|
96
104
|
*/
|
|
97
105
|
|
|
@@ -157,6 +165,9 @@ export default {
|
|
|
157
165
|
treatedPaginationTotal() {
|
|
158
166
|
return this.rows.length === 0 ? 0 : this.paginationTotal;
|
|
159
167
|
},
|
|
168
|
+
gridTemplateColumns() {
|
|
169
|
+
return this.headers.map((header) => `${header.size || 1}fr`).join(' ');
|
|
170
|
+
},
|
|
160
171
|
},
|
|
161
172
|
};
|
|
162
173
|
</script>
|
|
@@ -173,6 +184,9 @@ $tableBorder: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
|
|
|
173
184
|
|
|
174
185
|
width: 100%;
|
|
175
186
|
|
|
187
|
+
display: flex;
|
|
188
|
+
flex-direction: column;
|
|
189
|
+
|
|
176
190
|
&__header {
|
|
177
191
|
&-row {
|
|
178
192
|
@extend %base-row;
|
|
@@ -268,7 +282,6 @@ $tableBorder: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
|
|
|
268
282
|
|
|
269
283
|
%base-row {
|
|
270
284
|
display: grid;
|
|
271
|
-
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
|
|
272
285
|
align-items: center;
|
|
273
286
|
}
|
|
274
287
|
}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
const validateHeader = (
|
|
2
|
-
const isContentString = typeof
|
|
1
|
+
const validateHeader = (header) => {
|
|
2
|
+
const isContentString = typeof header.content !== 'string';
|
|
3
3
|
if (isContentString) {
|
|
4
4
|
throw new Error('Each item in "headers" must have "content" as a string.');
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
const isSizePositiveNumber =
|
|
8
|
+
'size' in header && (typeof header.size !== 'number' || header.size < 0);
|
|
9
|
+
if (isSizePositiveNumber) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
'Each item in "headers" that contains "size" must assign it as positive number',
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
const isSortableBoolean =
|
|
8
|
-
'isSortable' in
|
|
16
|
+
'isSortable' in header && typeof header.isSortable !== 'boolean';
|
|
9
17
|
if (isSortableBoolean) {
|
|
10
18
|
throw new Error(
|
|
11
19
|
'Each item in "headers" that contains “isSortable” must assign it as boolean',
|