vueless 0.0.399 → 0.0.400
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
package/ui.data-table/UTable.vue
CHANGED
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
:class="cx([getCellAttrs(key, row, index).class, columns[index].tdClass])"
|
|
19
19
|
>
|
|
20
20
|
<div
|
|
21
|
-
v-if="(row.row || nestedLevel) && index === 0"
|
|
21
|
+
v-if="(row.row || nestedLevel || row.nestedData) && index === 0"
|
|
22
22
|
:style="getNestedShift()"
|
|
23
23
|
v-bind="bodyCellNestedAttrs"
|
|
24
24
|
>
|
|
25
25
|
<UIcon
|
|
26
|
-
v-if="row.row"
|
|
26
|
+
v-if="row.row || (row.nestedData && hasSlotContent($slots['nested-content']))"
|
|
27
27
|
size="xs"
|
|
28
28
|
internal
|
|
29
29
|
interactive
|
|
30
|
-
:name="row
|
|
30
|
+
:name="getToggleIconName(row)"
|
|
31
31
|
color="brand"
|
|
32
32
|
v-bind="toggleIconConfig"
|
|
33
|
-
@click="onClickToggleRowChild(row.row.id)"
|
|
33
|
+
@click="onClickToggleRowChild(row.row?.id || row.id)"
|
|
34
34
|
/>
|
|
35
35
|
</div>
|
|
36
36
|
|
|
@@ -66,8 +66,20 @@
|
|
|
66
66
|
</td>
|
|
67
67
|
</tr>
|
|
68
68
|
|
|
69
|
+
<template
|
|
70
|
+
v-if="row.nestedData && !row.nestedData.isHidden && hasSlotContent($slots['nested-content'])"
|
|
71
|
+
>
|
|
72
|
+
<tr>
|
|
73
|
+
<td :colspan="columns.length + (selectable ? 1 : 0)">
|
|
74
|
+
<div :style="getNestedShift()">
|
|
75
|
+
<slot name="nested-content" :row="row" />
|
|
76
|
+
</div>
|
|
77
|
+
</td>
|
|
78
|
+
</tr>
|
|
79
|
+
</template>
|
|
80
|
+
|
|
69
81
|
<UTableRow
|
|
70
|
-
v-if="row.row && !row.row.isHidden"
|
|
82
|
+
v-if="row.row && !row.row.isHidden && !row.nestedData"
|
|
71
83
|
v-bind="$attrs"
|
|
72
84
|
v-model:selected-rows="selectedRows"
|
|
73
85
|
:attrs="attrs"
|
|
@@ -85,6 +97,7 @@
|
|
|
85
97
|
<script setup>
|
|
86
98
|
import { computed, onMounted, ref } from "vue";
|
|
87
99
|
import { cx } from "../utils/utilUI.js";
|
|
100
|
+
import useUI from "../composables/useUI.js";
|
|
88
101
|
|
|
89
102
|
import { HYPHEN_SYMBOL } from "../constants.js";
|
|
90
103
|
import { getFilteredRow } from "./utilTable.js";
|
|
@@ -94,6 +107,8 @@ import { useMutationObserver } from "../composables/useMutationObserver.js";
|
|
|
94
107
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
95
108
|
import UCheckbox from "../ui.form-checkbox/UCheckbox.vue";
|
|
96
109
|
|
|
110
|
+
const { hasSlotContent } = useUI();
|
|
111
|
+
|
|
97
112
|
const props = defineProps({
|
|
98
113
|
row: {
|
|
99
114
|
type: Object,
|
|
@@ -163,12 +178,18 @@ const toggleIconConfig = computed(() =>
|
|
|
163
178
|
|
|
164
179
|
const shift = computed(() => (props.row.row ? 1.5 : 2));
|
|
165
180
|
|
|
181
|
+
const getToggleIconName = computed(() => (row) => {
|
|
182
|
+
const isHidden = row.row?.isHidden || row.nestedData?.isHidden;
|
|
183
|
+
|
|
184
|
+
return isHidden ? props.config.defaults.expandIcon : props.config.defaults.collapseIcon;
|
|
185
|
+
});
|
|
186
|
+
|
|
166
187
|
onMounted(() => {
|
|
167
188
|
cellRef.value.forEach(setElementTitle);
|
|
168
189
|
});
|
|
169
190
|
|
|
170
191
|
function getCellAttrs(key, row, cellIndex) {
|
|
171
|
-
const isNestedRow = (row.row || props.nestedLevel > 0) && cellIndex === 0;
|
|
192
|
+
const isNestedRow = (row.row || row.nestedData || props.nestedLevel > 0) && cellIndex === 0;
|
|
172
193
|
|
|
173
194
|
return isNestedRow ? bodyCellNestedRowAttrs.value : bodyCellBaseAttrs.value;
|
|
174
195
|
}
|
|
@@ -182,7 +203,9 @@ function getNestedCheckboxShift() {
|
|
|
182
203
|
}
|
|
183
204
|
|
|
184
205
|
function onClickToggleRowChild(rowId) {
|
|
185
|
-
|
|
206
|
+
if (props.row.row || props.row.nestedData) {
|
|
207
|
+
emit("toggleRowVisibility", rowId);
|
|
208
|
+
}
|
|
186
209
|
}
|
|
187
210
|
|
|
188
211
|
function onClick(row) {
|
|
@@ -177,7 +177,7 @@ const DefaultTemplate = (args) => ({
|
|
|
177
177
|
|
|
178
178
|
if (typeof args.row === "function") {
|
|
179
179
|
for (let i = 0; i < args.numberOfRows; i++) {
|
|
180
|
-
rows.push(args.row());
|
|
180
|
+
rows.push(args.row(i));
|
|
181
181
|
}
|
|
182
182
|
} else {
|
|
183
183
|
rows.push(args.row);
|
|
@@ -206,6 +206,92 @@ Default.args = {};
|
|
|
206
206
|
export const Nesting = DefaultTemplate.bind({});
|
|
207
207
|
Nesting.args = { row: getNestedRow, selectable: true };
|
|
208
208
|
|
|
209
|
+
export const NestedContent = DefaultTemplate.bind({});
|
|
210
|
+
NestedContent.args = {
|
|
211
|
+
columns: [
|
|
212
|
+
{ key: "key_1", label: "Title 1" },
|
|
213
|
+
{ key: "key_2", label: "Title 2" },
|
|
214
|
+
{ key: "key_3", label: "Title 3" },
|
|
215
|
+
],
|
|
216
|
+
row: (index) => {
|
|
217
|
+
if (index === 0) {
|
|
218
|
+
return {
|
|
219
|
+
id: getRandomId(),
|
|
220
|
+
isChecked: false,
|
|
221
|
+
key_1: {
|
|
222
|
+
primary: "Row with nested content",
|
|
223
|
+
secondary: "Click to expand",
|
|
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
|
+
},
|
|
233
|
+
nestedData: {
|
|
234
|
+
isChecked: false,
|
|
235
|
+
isHidden: true,
|
|
236
|
+
rows: [
|
|
237
|
+
{
|
|
238
|
+
id: getRandomId(),
|
|
239
|
+
key_1: "Detail 1A",
|
|
240
|
+
key_2: "Info 1B",
|
|
241
|
+
key_3: "Data 1C",
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
id: getRandomId(),
|
|
245
|
+
key_1: "Detail 2A",
|
|
246
|
+
key_2: "Info 2B",
|
|
247
|
+
key_3: "Data 2C",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: getRandomId(),
|
|
251
|
+
key_1: "Detail 3A",
|
|
252
|
+
key_2: "Info 3B",
|
|
253
|
+
key_3: "Data 3C",
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
} else {
|
|
259
|
+
return {
|
|
260
|
+
id: getRandomId(),
|
|
261
|
+
isChecked: false,
|
|
262
|
+
key_1: {
|
|
263
|
+
primary: `Regular row ${index}`,
|
|
264
|
+
secondary: "No nested content",
|
|
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
|
+
},
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
selectable: true,
|
|
278
|
+
slotTemplate: `
|
|
279
|
+
<template #nested-content="{ row }">
|
|
280
|
+
<div class="p-4 bg-gray-100">
|
|
281
|
+
<UTable
|
|
282
|
+
:columns="[
|
|
283
|
+
{ key: 'key_1', label: 'Detail' },
|
|
284
|
+
{ key: 'key_2', label: 'Info' },
|
|
285
|
+
{ key: 'key_3', label: 'Data' },
|
|
286
|
+
]"
|
|
287
|
+
:rows="row.nestedData.rows"
|
|
288
|
+
compact
|
|
289
|
+
/>
|
|
290
|
+
</div>
|
|
291
|
+
</template>
|
|
292
|
+
`,
|
|
293
|
+
};
|
|
294
|
+
|
|
209
295
|
export const Empty = EmptyTemplate.bind({});
|
|
210
296
|
Empty.args = {};
|
|
211
297
|
|
|
@@ -23,11 +23,23 @@ export function syncRowCheck(row, selectedRows) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function toggleRowVisibility(row, targetRowId) {
|
|
26
|
-
if (row.id === targetRowId)
|
|
26
|
+
if (row.id === targetRowId) {
|
|
27
|
+
if ("isHidden" in row) {
|
|
28
|
+
row.isHidden = !row.isHidden;
|
|
29
|
+
} else if (row.nestedData && "isHidden" in row.nestedData) {
|
|
30
|
+
row.nestedData.isHidden = !row.nestedData.isHidden;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
27
35
|
|
|
28
36
|
if (row.row) {
|
|
29
37
|
toggleRowVisibility(row.row, targetRowId);
|
|
30
38
|
}
|
|
39
|
+
|
|
40
|
+
if (row.nestedData) {
|
|
41
|
+
toggleRowVisibility(row.nestedData, targetRowId);
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
export function switchRowCheck(row, isChecked) {
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "vueless",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.400",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -8253,6 +8253,15 @@
|
|
|
8253
8253
|
}
|
|
8254
8254
|
]
|
|
8255
8255
|
},
|
|
8256
|
+
{
|
|
8257
|
+
"name": "nested-content",
|
|
8258
|
+
"scoped": true,
|
|
8259
|
+
"bindings": [
|
|
8260
|
+
{
|
|
8261
|
+
"name": "row"
|
|
8262
|
+
}
|
|
8263
|
+
]
|
|
8264
|
+
},
|
|
8256
8265
|
{
|
|
8257
8266
|
"name": "after-last-row",
|
|
8258
8267
|
"description": "Use it to add something after last row."
|
|
@@ -8370,6 +8379,15 @@
|
|
|
8370
8379
|
"name": "row"
|
|
8371
8380
|
}
|
|
8372
8381
|
]
|
|
8382
|
+
},
|
|
8383
|
+
{
|
|
8384
|
+
"name": "nested-content",
|
|
8385
|
+
"scoped": true,
|
|
8386
|
+
"bindings": [
|
|
8387
|
+
{
|
|
8388
|
+
"name": "row"
|
|
8389
|
+
}
|
|
8390
|
+
]
|
|
8373
8391
|
}
|
|
8374
8392
|
],
|
|
8375
8393
|
"source": {
|