vueless 0.0.405 → 0.0.406
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 +1 -1
- package/ui.data-table/UTable.vue +4 -3
- package/ui.data-table/UTableRow.vue +15 -3
- package/ui.data-table/storybook/stories.js +124 -105
- package/web-types.json +1 -1
package/package.json
CHANGED
package/ui.data-table/UTable.vue
CHANGED
|
@@ -190,7 +190,8 @@
|
|
|
190
190
|
:columns="columns"
|
|
191
191
|
:config="config"
|
|
192
192
|
:attrs="keysAttrs"
|
|
193
|
-
v-bind="
|
|
193
|
+
v-bind="getRowAttrs(row.id)"
|
|
194
|
+
:class="cx([getRowAttrs(row.id).class, row.class])"
|
|
194
195
|
@click="onClickRow"
|
|
195
196
|
@toggle-row-visibility="onToggleRowVisibility"
|
|
196
197
|
>
|
|
@@ -598,8 +599,8 @@ function shouldDisplayDateSeparator(rowIndex) {
|
|
|
598
599
|
return (isPreviousRowChecked && isCheckedRowAfter) || isFirstRowAndNextChecked;
|
|
599
600
|
}
|
|
600
601
|
|
|
601
|
-
function
|
|
602
|
-
return
|
|
602
|
+
function getRowAttrs(rowId) {
|
|
603
|
+
return selectedRows.value.includes(rowId) ? bodyRowCheckedAttrs : bodyRowAttrs;
|
|
603
604
|
}
|
|
604
605
|
|
|
605
606
|
function setFooterCellWidth(width) {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
v-for="(value, key, index) in getFilteredRow(row, columns)"
|
|
16
16
|
:key="index"
|
|
17
17
|
v-bind="getCellAttrs(key, row, index)"
|
|
18
|
-
:class="cx([getCellAttrs(key, row, index).class, columns[index].tdClass])"
|
|
18
|
+
:class="cx([getCellAttrs(key, row, index).class, columns[index].tdClass, row[key]?.class])"
|
|
19
19
|
>
|
|
20
20
|
<div
|
|
21
21
|
v-if="(row.row || nestedLevel || row.nestedData) && index === 0"
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
/>
|
|
35
35
|
</div>
|
|
36
36
|
|
|
37
|
-
<div v-if="value
|
|
37
|
+
<div v-if="isCellObject(value)">
|
|
38
38
|
<slot :name="`cell-${key}`" :value="value" :row="row">
|
|
39
39
|
<div v-bind="bodyCellPrimaryAttrs" ref="cellRef" :data-test="`${dataTest}-${key}-cell`">
|
|
40
|
-
{{ value
|
|
40
|
+
{{ getCellPrimaryContent(value) }}
|
|
41
41
|
</div>
|
|
42
42
|
|
|
43
43
|
<div v-bind="bodyCellSecondaryAttrs">
|
|
@@ -188,6 +188,18 @@ onMounted(() => {
|
|
|
188
188
|
cellRef.value.forEach(setElementTitle);
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
function isCellObject(value) {
|
|
192
|
+
return typeof value === "object" && value !== null && ("primary" in value || "value" in value);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function getCellPrimaryContent(value) {
|
|
196
|
+
if (typeof value === "object" && value !== null) {
|
|
197
|
+
return value.primary || value.value || HYPHEN_SYMBOL;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return value || HYPHEN_SYMBOL;
|
|
201
|
+
}
|
|
202
|
+
|
|
191
203
|
function getCellAttrs(key, row, cellIndex) {
|
|
192
204
|
const isNestedRow = (row.row || row.nestedData || props.nestedLevel > 0) && cellIndex === 0;
|
|
193
205
|
|
|
@@ -51,82 +51,34 @@ function getNestedRow() {
|
|
|
51
51
|
return {
|
|
52
52
|
id: getRandomId(),
|
|
53
53
|
isChecked: false,
|
|
54
|
-
key_1:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
key_2: {
|
|
59
|
-
primary: "primary",
|
|
60
|
-
secondary: "secondary",
|
|
61
|
-
},
|
|
62
|
-
key_3: {
|
|
63
|
-
primary: "primary",
|
|
64
|
-
secondary: "secondary",
|
|
65
|
-
},
|
|
66
|
-
key_4: {
|
|
67
|
-
primary: "primary",
|
|
68
|
-
secondary: "secondary",
|
|
69
|
-
},
|
|
54
|
+
key_1: "Click to expand",
|
|
55
|
+
key_2: "Some data",
|
|
56
|
+
key_3: "Numbers",
|
|
57
|
+
key_4: "Statistics",
|
|
70
58
|
row: {
|
|
71
59
|
id: getRandomId(),
|
|
72
60
|
isChecked: false,
|
|
73
61
|
isHidden: true,
|
|
74
|
-
key_1:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
key_2: {
|
|
79
|
-
primary: "Nesting",
|
|
80
|
-
secondary: "secondary",
|
|
81
|
-
},
|
|
82
|
-
key_3: {
|
|
83
|
-
primary: "Nesting",
|
|
84
|
-
secondary: "secondary",
|
|
85
|
-
},
|
|
86
|
-
key_4: {
|
|
87
|
-
primary: "Nesting",
|
|
88
|
-
secondary: "secondary",
|
|
89
|
-
},
|
|
62
|
+
key_1: "Nesting",
|
|
63
|
+
key_2: "Nesting",
|
|
64
|
+
key_3: "Nesting",
|
|
65
|
+
key_4: "Nesting",
|
|
90
66
|
row: {
|
|
91
67
|
id: getRandomId(),
|
|
92
68
|
isChecked: false,
|
|
93
69
|
isHidden: true,
|
|
94
|
-
key_1:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
key_2: {
|
|
99
|
-
primary: "Two level nesting",
|
|
100
|
-
secondary: "secondary",
|
|
101
|
-
},
|
|
102
|
-
key_3: {
|
|
103
|
-
primary: "Two level nesting",
|
|
104
|
-
secondary: "secondary",
|
|
105
|
-
},
|
|
106
|
-
key_4: {
|
|
107
|
-
primary: "Two level nesting",
|
|
108
|
-
secondary: "secondary",
|
|
109
|
-
},
|
|
70
|
+
key_1: "Second level nesting",
|
|
71
|
+
key_2: "Second level nesting",
|
|
72
|
+
key_3: "Second level nesting",
|
|
73
|
+
key_4: "Second level nesting",
|
|
110
74
|
row: {
|
|
111
75
|
id: getRandomId(),
|
|
112
76
|
isChecked: false,
|
|
113
77
|
isHidden: true,
|
|
114
|
-
key_1:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
key_2: {
|
|
119
|
-
primary: "Three level nesting",
|
|
120
|
-
secondary: "secondary",
|
|
121
|
-
},
|
|
122
|
-
key_3: {
|
|
123
|
-
primary: "Three level nesting",
|
|
124
|
-
secondary: "secondary",
|
|
125
|
-
},
|
|
126
|
-
key_4: {
|
|
127
|
-
primary: "Three level nesting",
|
|
128
|
-
secondary: "secondary",
|
|
129
|
-
},
|
|
78
|
+
key_1: "Third level nesting",
|
|
79
|
+
key_2: "Third level nesting",
|
|
80
|
+
key_3: "Third level nesting",
|
|
81
|
+
key_4: "Third level nesting",
|
|
130
82
|
},
|
|
131
83
|
},
|
|
132
84
|
},
|
|
@@ -137,22 +89,10 @@ function getRow() {
|
|
|
137
89
|
return {
|
|
138
90
|
id: getRandomId(),
|
|
139
91
|
isChecked: false,
|
|
140
|
-
key_1:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
key_2: {
|
|
145
|
-
primary: "primary",
|
|
146
|
-
secondary: "secondary",
|
|
147
|
-
},
|
|
148
|
-
key_3: {
|
|
149
|
-
primary: "primary",
|
|
150
|
-
secondary: "secondary",
|
|
151
|
-
},
|
|
152
|
-
key_4: {
|
|
153
|
-
primary: "primary",
|
|
154
|
-
secondary: "secondary",
|
|
155
|
-
},
|
|
92
|
+
key_1: "Info",
|
|
93
|
+
key_2: "Statistics",
|
|
94
|
+
key_3: "Reports",
|
|
95
|
+
key_4: "Discounts",
|
|
156
96
|
};
|
|
157
97
|
}
|
|
158
98
|
|
|
@@ -166,7 +106,7 @@ const DefaultTemplate = (args) => ({
|
|
|
166
106
|
template: `
|
|
167
107
|
<UTable
|
|
168
108
|
v-bind="args"
|
|
169
|
-
:rows="itemsData"
|
|
109
|
+
:rows="args.rows || itemsData"
|
|
170
110
|
>
|
|
171
111
|
${args.slotTemplate || getSlotsFragment()}
|
|
172
112
|
</UTable>
|
|
@@ -218,18 +158,9 @@ NestedContent.args = {
|
|
|
218
158
|
return {
|
|
219
159
|
id: getRandomId(),
|
|
220
160
|
isChecked: false,
|
|
221
|
-
key_1:
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
},
|
|
225
|
-
key_2: {
|
|
226
|
-
primary: "Primary content",
|
|
227
|
-
secondary: "Secondary content",
|
|
228
|
-
},
|
|
229
|
-
key_3: {
|
|
230
|
-
primary: "More info",
|
|
231
|
-
secondary: "Details below",
|
|
232
|
-
},
|
|
161
|
+
key_1: "Row with nested content",
|
|
162
|
+
key_2: "Basic data",
|
|
163
|
+
key_3: "More info",
|
|
233
164
|
nestedData: {
|
|
234
165
|
isChecked: false,
|
|
235
166
|
isHidden: true,
|
|
@@ -259,18 +190,9 @@ NestedContent.args = {
|
|
|
259
190
|
return {
|
|
260
191
|
id: getRandomId(),
|
|
261
192
|
isChecked: false,
|
|
262
|
-
key_1: {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
},
|
|
266
|
-
key_2: {
|
|
267
|
-
primary: "Standard info",
|
|
268
|
-
secondary: "Nothing special",
|
|
269
|
-
},
|
|
270
|
-
key_3: {
|
|
271
|
-
primary: "Basic data",
|
|
272
|
-
secondary: "No details",
|
|
273
|
-
},
|
|
193
|
+
key_1: `Regular row ${index}`,
|
|
194
|
+
key_2: "Standard info",
|
|
195
|
+
key_3: "Basic data",
|
|
274
196
|
};
|
|
275
197
|
}
|
|
276
198
|
},
|
|
@@ -292,6 +214,103 @@ NestedContent.args = {
|
|
|
292
214
|
`,
|
|
293
215
|
};
|
|
294
216
|
|
|
217
|
+
export const RowAndCellClasses = DefaultTemplate.bind({});
|
|
218
|
+
RowAndCellClasses.args = {
|
|
219
|
+
rows: [
|
|
220
|
+
{
|
|
221
|
+
id: getRandomId(),
|
|
222
|
+
isChecked: false,
|
|
223
|
+
key_1: "Info",
|
|
224
|
+
key_2: "Statistics",
|
|
225
|
+
key_3: { value: "Reports", class: "bg-red-200" },
|
|
226
|
+
key_4: "Discounts",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: getRandomId(),
|
|
230
|
+
isChecked: false,
|
|
231
|
+
class: "bg-green-100",
|
|
232
|
+
key_1: "Data",
|
|
233
|
+
key_2: "Meetings",
|
|
234
|
+
key_3: "Calendar",
|
|
235
|
+
key_4: "Departments",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: getRandomId(),
|
|
239
|
+
isChecked: false,
|
|
240
|
+
key_1: "Events",
|
|
241
|
+
key_2: "Sales",
|
|
242
|
+
key_3: "Renovation",
|
|
243
|
+
key_4: "Calendar",
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export const PrimaryAndSecondaryContent = DefaultTemplate.bind({});
|
|
249
|
+
PrimaryAndSecondaryContent.args = {
|
|
250
|
+
rows: [
|
|
251
|
+
{
|
|
252
|
+
id: getRandomId(),
|
|
253
|
+
isChecked: false,
|
|
254
|
+
key_1: {
|
|
255
|
+
primary: "Primary",
|
|
256
|
+
secondary: "Secondary",
|
|
257
|
+
},
|
|
258
|
+
key_2: {
|
|
259
|
+
primary: "Primary",
|
|
260
|
+
secondary: "Secondary",
|
|
261
|
+
},
|
|
262
|
+
key_3: {
|
|
263
|
+
primary: "Primary",
|
|
264
|
+
secondary: "Secondary",
|
|
265
|
+
},
|
|
266
|
+
key_4: {
|
|
267
|
+
primary: "Primary",
|
|
268
|
+
secondary: "Secondary",
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: getRandomId(),
|
|
273
|
+
isChecked: false,
|
|
274
|
+
key_1: {
|
|
275
|
+
primary: "Primary",
|
|
276
|
+
secondary: "Secondary",
|
|
277
|
+
},
|
|
278
|
+
key_2: {
|
|
279
|
+
primary: "Primary",
|
|
280
|
+
secondary: "Secondary",
|
|
281
|
+
},
|
|
282
|
+
key_3: {
|
|
283
|
+
primary: "Primary",
|
|
284
|
+
secondary: "Secondary",
|
|
285
|
+
},
|
|
286
|
+
key_4: {
|
|
287
|
+
primary: "Primary",
|
|
288
|
+
secondary: "Secondary",
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: getRandomId(),
|
|
293
|
+
isChecked: false,
|
|
294
|
+
key_1: {
|
|
295
|
+
primary: "Primary",
|
|
296
|
+
secondary: "Secondary",
|
|
297
|
+
},
|
|
298
|
+
key_2: {
|
|
299
|
+
primary: "Primary",
|
|
300
|
+
secondary: "Secondary",
|
|
301
|
+
},
|
|
302
|
+
key_3: {
|
|
303
|
+
primary: "Primary",
|
|
304
|
+
secondary: "Secondary",
|
|
305
|
+
},
|
|
306
|
+
key_4: {
|
|
307
|
+
primary: "Primary",
|
|
308
|
+
secondary: "Secondary",
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
};
|
|
313
|
+
|
|
295
314
|
export const Empty = EmptyTemplate.bind({});
|
|
296
315
|
Empty.args = {};
|
|
297
316
|
|