@weni/unnnic-system 2.1.1 → 2.3.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 +18 -0
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +187 -171
- package/dist/unnnic.umd.js +14 -14
- package/package.json +1 -1
- package/src/components/Button/Button.vue +7 -6
- package/src/components/TableNext/TableNext.vue +15 -2
- package/src/components/TableNext/validation.js +11 -3
- package/src/stories/Button.stories.js +55 -13
- package/src/stories/TableNext.stories.js +1 -0
package/package.json
CHANGED
|
@@ -74,7 +74,7 @@ export default {
|
|
|
74
74
|
},
|
|
75
75
|
text: {
|
|
76
76
|
type: String,
|
|
77
|
-
default:
|
|
77
|
+
default: '',
|
|
78
78
|
},
|
|
79
79
|
type: {
|
|
80
80
|
type: String,
|
|
@@ -86,28 +86,29 @@ export default {
|
|
|
86
86
|
},
|
|
87
87
|
iconLeft: {
|
|
88
88
|
type: String,
|
|
89
|
-
default:
|
|
89
|
+
default: '',
|
|
90
90
|
},
|
|
91
91
|
iconRight: {
|
|
92
92
|
type: String,
|
|
93
|
-
default:
|
|
93
|
+
default: '',
|
|
94
94
|
},
|
|
95
95
|
iconCenter: {
|
|
96
96
|
type: String,
|
|
97
|
-
default:
|
|
97
|
+
default: '',
|
|
98
98
|
},
|
|
99
99
|
next: {
|
|
100
100
|
type: Boolean,
|
|
101
|
-
default:
|
|
101
|
+
default: false,
|
|
102
102
|
},
|
|
103
103
|
|
|
104
104
|
disabled: {
|
|
105
105
|
type: Boolean,
|
|
106
|
-
default:
|
|
106
|
+
default: false,
|
|
107
107
|
},
|
|
108
108
|
|
|
109
109
|
loading: {
|
|
110
110
|
type: Boolean,
|
|
111
|
+
default: false,
|
|
111
112
|
},
|
|
112
113
|
},
|
|
113
114
|
computed: {
|
|
@@ -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',
|
|
@@ -3,7 +3,36 @@ import iconList from '../utils/iconList';
|
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
title: 'Form/Button',
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: `Allows users to perform an action or navigate to another page.
|
|
10
|
+
It has styles for various needs and are ideal for directing the user's attention.
|
|
11
|
+
It is divided into 6 types: Primary, Secondary, Tertiary, Alternative, Warning, Attention.
|
|
12
|
+
Each of these types has its states.
|
|
13
|
+
<br/>
|
|
14
|
+
<br/>
|
|
15
|
+
This component has 5 variations: without icon, with icon on the left, with icon on the right, just the icon and float.
|
|
16
|
+
Each of this variation has 4 states: default, hover, active and disabled.
|
|
17
|
+
The component has a fixed height of 46px and variable width. However, the icon-only variation has a fixed height and width of 46px.
|
|
18
|
+
`,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
6
22
|
component: unnnicButton,
|
|
23
|
+
tags: ['autodocs'],
|
|
24
|
+
args: {
|
|
25
|
+
text: '',
|
|
26
|
+
type: 'primary',
|
|
27
|
+
size: 'large',
|
|
28
|
+
iconLeft: '',
|
|
29
|
+
iconCenter: '',
|
|
30
|
+
iconRight: '',
|
|
31
|
+
disabled: false,
|
|
32
|
+
loading: false,
|
|
33
|
+
float: false,
|
|
34
|
+
next: false,
|
|
35
|
+
},
|
|
7
36
|
argTypes: {
|
|
8
37
|
type: {
|
|
9
38
|
control: { type: 'select' },
|
|
@@ -19,7 +48,6 @@ export default {
|
|
|
19
48
|
size: {
|
|
20
49
|
control: { type: 'select' },
|
|
21
50
|
options: ['large', 'small'],
|
|
22
|
-
defaultValue: 'large',
|
|
23
51
|
},
|
|
24
52
|
text: { control: { type: 'text' } },
|
|
25
53
|
iconLeft: {
|
|
@@ -37,13 +65,17 @@ export default {
|
|
|
37
65
|
disabled: { control: { type: 'boolean' } },
|
|
38
66
|
loading: { control: { type: 'boolean' } },
|
|
39
67
|
float: { control: { type: 'boolean' } },
|
|
68
|
+
next: {
|
|
69
|
+
control: { type: 'boolean' },
|
|
70
|
+
description:
|
|
71
|
+
'Used to indicate whether the button icon should be converted to the new icon library',
|
|
72
|
+
},
|
|
40
73
|
},
|
|
41
74
|
};
|
|
42
75
|
|
|
43
76
|
export const Primary = {
|
|
44
77
|
args: {
|
|
45
78
|
text: 'Button Text',
|
|
46
|
-
disabled: false,
|
|
47
79
|
},
|
|
48
80
|
};
|
|
49
81
|
|
|
@@ -51,7 +83,6 @@ export const Secondary = {
|
|
|
51
83
|
args: {
|
|
52
84
|
type: 'secondary',
|
|
53
85
|
text: 'Button Text',
|
|
54
|
-
disabled: false,
|
|
55
86
|
},
|
|
56
87
|
};
|
|
57
88
|
|
|
@@ -59,20 +90,19 @@ export const Tertiary = {
|
|
|
59
90
|
args: {
|
|
60
91
|
type: 'tertiary',
|
|
61
92
|
text: 'Button Text',
|
|
62
|
-
disabled: false,
|
|
63
93
|
},
|
|
64
94
|
};
|
|
65
95
|
|
|
66
96
|
export const WithIcon = {
|
|
67
97
|
args: {
|
|
68
98
|
text: 'Button Text',
|
|
69
|
-
iconLeft: '
|
|
99
|
+
iconLeft: 'add',
|
|
70
100
|
},
|
|
71
101
|
};
|
|
72
102
|
|
|
73
103
|
export const OnlyIcon = {
|
|
74
104
|
args: {
|
|
75
|
-
iconCenter: 'add
|
|
105
|
+
iconCenter: 'add',
|
|
76
106
|
},
|
|
77
107
|
};
|
|
78
108
|
|
|
@@ -85,9 +115,17 @@ export const Alternative = {
|
|
|
85
115
|
};
|
|
86
116
|
|
|
87
117
|
export const Warning = {
|
|
118
|
+
parameters: {
|
|
119
|
+
docs: {
|
|
120
|
+
description: {
|
|
121
|
+
story: `This variation aims to highlight actions that could be destructive or have negative consequences if taken.
|
|
122
|
+
For example: Deleting an element.`,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
88
126
|
args: {
|
|
89
127
|
type: 'warning',
|
|
90
|
-
iconLeft: 'add
|
|
128
|
+
iconLeft: 'add',
|
|
91
129
|
text: 'Text',
|
|
92
130
|
},
|
|
93
131
|
};
|
|
@@ -95,12 +133,21 @@ export const Warning = {
|
|
|
95
133
|
export const Attention = {
|
|
96
134
|
args: {
|
|
97
135
|
type: 'attention',
|
|
98
|
-
iconLeft: 'add
|
|
136
|
+
iconLeft: 'add',
|
|
99
137
|
text: 'Text',
|
|
100
138
|
},
|
|
101
139
|
};
|
|
102
140
|
|
|
103
141
|
export const Float = {
|
|
142
|
+
parameters: {
|
|
143
|
+
docs: {
|
|
144
|
+
description: {
|
|
145
|
+
story: `When there is a need to present a main action above a list of contents. <br/>
|
|
146
|
+
It is important that the component is always floating over the content and fixed to the bottom right side. <br/>
|
|
147
|
+
(Remember to add ${'`position relative`'} style to your container)`,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
104
151
|
argTypes: {
|
|
105
152
|
size: {
|
|
106
153
|
control: { type: 'select' },
|
|
@@ -116,11 +163,6 @@ export const Float = {
|
|
|
116
163
|
template: `<div style="height: 80vh; display: grid; position: relative;">
|
|
117
164
|
<unnnic-button v-bind="args" />
|
|
118
165
|
|
|
119
|
-
When to use this variation: <br/>
|
|
120
|
-
When there is a need to present a main action above a list of contents. <br/>
|
|
121
|
-
It is important that the component is always floating over the content and fixed to the bottom right side. <br/>
|
|
122
|
-
(Remember to add position relative style to your container)
|
|
123
|
-
|
|
124
166
|
<br/>
|
|
125
167
|
<br/>
|
|
126
168
|
|