vueless 0.0.465 → 0.0.467

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": "vueless",
3
- "version": "0.0.465",
3
+ "version": "0.0.467",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -75,11 +75,7 @@
75
75
  </div>
76
76
  </template>
77
77
 
78
- <ULoaderProgress
79
- v-if="resource && isHeaderSticky"
80
- :resources="resource"
81
- v-bind="stickyHeaderLoaderAttrs"
82
- />
78
+ <ULoaderProgress v-if="isHeaderSticky" :loading="loading" v-bind="stickyHeaderLoaderAttrs" />
83
79
  </div>
84
80
 
85
81
  <div ref="table-wrapper" v-bind="tableWrapperAttrs">
@@ -148,7 +144,7 @@
148
144
  </th>
149
145
  </tr>
150
146
 
151
- <ULoaderProgress v-if="resource" :resources="resource" v-bind="headerLoaderAttrs" />
147
+ <ULoaderProgress :loading="loading" v-bind="headerLoaderAttrs" />
152
148
  </thead>
153
149
 
154
150
  <tbody v-if="tableRows.length" v-bind="bodyAttrs">
@@ -297,7 +293,7 @@ import {
297
293
  toggleRowVisibility,
298
294
  switchRowCheck,
299
295
  getFlatRows,
300
- rowsHasId,
296
+ addRowId,
301
297
  } from "./utilTable.js";
302
298
 
303
299
  import { PX_IN_REM } from "../constants.js";
@@ -365,11 +361,11 @@ const props = defineProps({
365
361
  },
366
362
 
367
363
  /**
368
- * Set loader resource name to activate table progress loader exact for that resource (deprecated).
364
+ * Set table loader state.
369
365
  */
370
- resource: {
371
- type: String,
372
- default: "",
366
+ loading: {
367
+ type: Boolean,
368
+ default: getDefault(defaultConfig, UTable).loading,
373
369
  },
374
370
 
375
371
  /**
@@ -565,20 +561,13 @@ watch(isFooterSticky, (newValue) =>
565
561
  newValue ? nextTick(setFooterCellWidth) : setFooterCellWidth(null),
566
562
  );
567
563
  watch(
568
- () => selectedRows.value.length,
569
- () => {
570
- tableRows.value = tableRows.value.map((row) => syncRowCheck(row, selectedRows.value));
571
- },
572
- );
573
- watch(
574
- () => props.rows,
564
+ () => selectedRows.value,
575
565
  () => {
576
- if (!rowsHasId(props.rows)) {
577
- // eslint-disable-next-line no-console
578
- console.warn("[Vueless][UTable]: Each table row must have unique id.");
579
- }
566
+ tableRows.value = tableRows.value
567
+ .map(addRowId)
568
+ .map((row) => syncRowCheck(row, selectedRows.value));
580
569
  },
581
- { deep: true, immediate: true },
570
+ { deep: true },
582
571
  );
583
572
 
584
573
  onMounted(() => {
@@ -98,6 +98,7 @@ export default /*tw*/ {
98
98
  dateDivider: false,
99
99
  stickyHeader: false,
100
100
  stickyFooter: false,
101
+ loading: false,
101
102
  /* icons */
102
103
  expandIcon: "add",
103
104
  collapseIcon: "remove",
@@ -405,7 +405,6 @@ CellSlots.args = {
405
405
  { key: "tags", label: "tags" },
406
406
  ],
407
407
  row: {
408
- id: getRandomId(),
409
408
  link: "some link",
410
409
  money: {
411
410
  sum: 10,
@@ -418,7 +417,6 @@ CellSlots.args = {
418
417
  },
419
418
  row: [
420
419
  {
421
- id: getRandomId(),
422
420
  isHidden: false,
423
421
  link: "some link",
424
422
  money: {
@@ -432,7 +430,6 @@ CellSlots.args = {
432
430
  },
433
431
  },
434
432
  {
435
- id: getRandomId(),
436
433
  isHidden: false,
437
434
  link: "some link",
438
435
  money: {
@@ -1,3 +1,5 @@
1
+ import { getRandomId } from "../utils/utilUI";
2
+
1
3
  export function normalizeColumns(columns) {
2
4
  return columns.map((column) => (typeof column === "string" ? { label: column } : column));
3
5
  }
@@ -15,13 +17,29 @@ export function getFilteredRow(row, columns) {
15
17
  export function syncRowCheck(row, selectedRows) {
16
18
  row.isChecked = selectedRows.includes(row.id);
17
19
 
18
- if (row.row) {
20
+ if (row.row && !Array.isArray(row.row)) {
19
21
  row.row = syncRowCheck(row.row, selectedRows);
20
22
  }
21
23
 
22
24
  return row;
23
25
  }
24
26
 
27
+ export function addRowId(row) {
28
+ const hasRowId = typeof row.id !== "undefined" && row.id !== null && row.id !== "";
29
+
30
+ row.id = hasRowId ? row.id : getRandomId();
31
+
32
+ if (row.row && !Array.isArray(row.row)) {
33
+ row.row = addRowId(row.row);
34
+ }
35
+
36
+ if (row.row && Array.isArray(row.row)) {
37
+ row.row = row.row.map((nestedRow) => addRowId(nestedRow));
38
+ }
39
+
40
+ return row;
41
+ }
42
+
25
43
  export function toggleRowVisibility(row, targetRowId) {
26
44
  if (row.id === targetRowId) {
27
45
  if (Object.hasOwn(row, "isHidden")) {
@@ -73,28 +91,3 @@ export function getFlatRows(tableRows) {
73
91
 
74
92
  return rows;
75
93
  }
76
-
77
- export function rowsHasId(rows) {
78
- const ids = new Set();
79
- let totalRows = 0;
80
-
81
- function addId(row) {
82
- totalRows++;
83
-
84
- if (typeof row.id !== "undefined") {
85
- ids.add(row.id);
86
- }
87
-
88
- if (row.row && !Array.isArray(row.row)) {
89
- addId(row.row);
90
- }
91
-
92
- if (row.row && Array.isArray(row.row)) {
93
- row.row.forEach(addId);
94
- }
95
- }
96
-
97
- rows.forEach((row) => addId(row));
98
-
99
- return ids.size === totalRows;
100
- }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.465",
4
+ "version": "0.0.467",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -8600,13 +8600,13 @@
8600
8600
  "default": "false"
8601
8601
  },
8602
8602
  {
8603
- "name": "resource",
8604
- "description": "Set loader resource name to activate table progress loader exact for that resource (deprecated).",
8603
+ "name": "loading",
8604
+ "description": "Set table loader state.",
8605
8605
  "value": {
8606
8606
  "kind": "expression",
8607
- "type": "string"
8607
+ "type": "boolean"
8608
8608
  },
8609
- "default": "\"\""
8609
+ "default": "false"
8610
8610
  },
8611
8611
  {
8612
8612
  "name": "config",