vueless 0.0.533 → 0.0.534

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.533",
3
+ "version": "0.0.534",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -3,7 +3,6 @@ import {
3
3
  ref,
4
4
  computed,
5
5
  watch,
6
- toValue,
7
6
  useSlots,
8
7
  nextTick,
9
8
  onMounted,
@@ -39,6 +38,7 @@ import { useLocale } from "../composables/useLocale.ts";
39
38
 
40
39
  import type { Cell, Row, RowId, UTableProps, UTableRowAttrs } from "./types.ts";
41
40
  import type { Ref, RendererElement, ComputedRef } from "vue";
41
+ import { isEqual } from "lodash-es";
42
42
 
43
43
  defineOptions({ inheritAttrs: false });
44
44
 
@@ -254,7 +254,15 @@ const tableRowAttrs = computed(() => ({
254
254
 
255
255
  watch(selectAll, onChangeSelectAll, { deep: true });
256
256
  watch(selectedRows, onChangeSelectedRows, { deep: true });
257
- watch(tableRows, () => emit("update:rows", toValue(tableRows)), { deep: true });
257
+ watch(
258
+ tableRows,
259
+ () => {
260
+ if (!isEqual(tableRows.value, props.rows)) {
261
+ emit("update:rows", tableRows.value);
262
+ }
263
+ },
264
+ { deep: true },
265
+ );
258
266
  watch(() => tableRows.value.length, updateSelectedRows);
259
267
  watch(() => props.rows, synchronizeTableItemsWithProps, { deep: true });
260
268
  watch(isHeaderSticky, setHeaderCellWidth);
@@ -337,7 +345,9 @@ function synchronizeTableItemsWithProps() {
337
345
  selectedRows.value = [];
338
346
  }
339
347
 
340
- tableRows.value = props.rows;
348
+ if (!isEqual(tableRows.value, props.rows)) {
349
+ tableRows.value = props.rows;
350
+ }
341
351
  }
342
352
 
343
353
  function updateSelectedRows() {
@@ -379,11 +389,11 @@ function onChangeSelectAll(selectAll: boolean) {
379
389
  if (selectAll && canSelectAll.value) {
380
390
  selectedRows.value = getFlatRows(tableRows.value).map((row) => row.id);
381
391
 
382
- tableRows.value.forEach((row) => switchRowCheck(row, true));
392
+ tableRows.value = tableRows.value.map((row) => switchRowCheck({ ...row }, true));
383
393
  } else if (!selectAll) {
384
394
  selectedRows.value = [];
385
395
 
386
- tableRows.value.forEach((row) => switchRowCheck(row, false));
396
+ tableRows.value = tableRows.value.map((row) => switchRowCheck({ ...row }, false));
387
397
  }
388
398
 
389
399
  canSelectAll.value = true;
@@ -406,8 +416,7 @@ function clearSelectedItems() {
406
416
  }
407
417
 
408
418
  function onToggleRowVisibility(rowId: string | number) {
409
- // TODO: Use map instead of forEach to get rid of implicit array mutation.
410
- tableRows.value.forEach((row) => toggleRowVisibility(row, rowId));
419
+ tableRows.value = tableRows.value.map((row) => toggleRowVisibility({ ...row }, rowId));
411
420
  }
412
421
 
413
422
  defineExpose({
@@ -290,8 +290,6 @@ function getRowAttrs(rowId: string | number) {
290
290
  :data-test="`${dataTest}-${key}-cell`"
291
291
  >
292
292
  {{ formatCellValue(value) }}
293
-
294
- {{ nestedRows }}
295
293
  </div>
296
294
  </slot>
297
295
  </template>
@@ -50,7 +50,7 @@ export function toggleRowVisibility(row: Row, targetRowId: string | number) {
50
50
  row.nestedData.isHidden = !row.nestedData.isHidden;
51
51
  }
52
52
 
53
- return;
53
+ return row;
54
54
  }
55
55
 
56
56
  if (row.row && !Array.isArray(row.row)) {
@@ -64,6 +64,8 @@ export function toggleRowVisibility(row: Row, targetRowId: string | number) {
64
64
  if (row.nestedData) {
65
65
  toggleRowVisibility(row.nestedData, targetRowId);
66
66
  }
67
+
68
+ return row;
67
69
  }
68
70
 
69
71
  export function switchRowCheck(row: Row, isChecked: boolean) {
@@ -76,6 +78,8 @@ export function switchRowCheck(row: Row, isChecked: boolean) {
76
78
  if (row.row && Array.isArray(row.row)) {
77
79
  row.row.map((currentRow) => switchRowCheck(currentRow, isChecked));
78
80
  }
81
+
82
+ return row;
79
83
  }
80
84
 
81
85
  export function getFlatRows(tableRows: Row[]) {
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.533",
4
+ "version": "0.0.534",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",