v-nuxt-ui 0.2.27 → 0.2.28

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/dist/module.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "dependencies": [
8
8
  "@nuxt/ui"
9
9
  ],
10
- "version": "0.2.27",
10
+ "version": "0.2.28",
11
11
  "builder": {
12
12
  "@nuxt/module-builder": "1.0.2",
13
13
  "unbuild": "3.6.1"
@@ -41,6 +41,7 @@ const props = defineProps({
41
41
  disableRowCopy: { type: Boolean, required: false },
42
42
  disableRowDeletion: { type: Boolean, required: false },
43
43
  disableRowSelection: { type: Boolean, required: false },
44
+ disableRowDiff: { type: Boolean, required: false },
44
45
  expandable: { type: Boolean, required: false },
45
46
  expandVNode: { type: Function, required: false },
46
47
  rowSpanColumns: { type: Array, required: false },
@@ -40,6 +40,7 @@ const props = defineProps({
40
40
  disableRowCopy: { type: Boolean, required: false },
41
41
  disableRowDeletion: { type: Boolean, required: false },
42
42
  disableRowSelection: { type: Boolean, required: false },
43
+ disableRowDiff: { type: Boolean, required: false },
43
44
  expandable: { type: Boolean, required: false },
44
45
  expandVNode: { type: Function, required: false },
45
46
  rowSpanColumns: { type: Array, required: false },
@@ -21,5 +21,7 @@ export interface UseTableReturn<T> {
21
21
  tblHeaderProps: ComputedRef<TableHeaderProps<T>>;
22
22
  tblPaginationProps: ComputedRef<TablePaginationProps<T>>;
23
23
  tblContextMenuItems: Ref<ContextMenuItem[]>;
24
+ deletingRowKey: Ref<number | null>;
25
+ editingRowKey: Ref<number | null>;
24
26
  }
25
27
  export declare function useTable<T>(props: VTableProps<T>): UseTableReturn<T>;
@@ -42,6 +42,7 @@ export function useTable(props) {
42
42
  disableRowCopy,
43
43
  disableRowDeletion,
44
44
  disableRowSelection,
45
+ disableRowDiff,
45
46
  expandable,
46
47
  rowSpanColumns,
47
48
  customRowCopyFn,
@@ -159,6 +160,7 @@ export function useTable(props) {
159
160
  disableRowUpdate,
160
161
  disableRowCopy,
161
162
  disableRowDeletion,
163
+ disableRowDiff,
162
164
  onEditRowFromModal,
163
165
  extraRowActions,
164
166
  useApiGroup,
@@ -166,7 +168,7 @@ export function useTable(props) {
166
168
  displayFnInDeleteModal,
167
169
  fetchList
168
170
  });
169
- const { getRowActions, generateActionColumn } = rowActionsComposable;
171
+ const { getRowActions, generateActionColumn, deletingRowKey, editingRowKey } = rowActionsComposable;
170
172
  const columns = computed(() => {
171
173
  const newCols = [];
172
174
  if (!disableRowSelection) {
@@ -243,6 +245,22 @@ export function useTable(props) {
243
245
  if (!disableRowActions) {
244
246
  newCols.push(generateActionColumn());
245
247
  }
248
+ newCols.forEach((col) => {
249
+ const existingTdClass = col.meta?.class?.td;
250
+ col.meta = col.meta || {};
251
+ col.meta.class = col.meta.class || {};
252
+ col.meta.class.td = (cell) => {
253
+ const rowKeyValue = cell.row.original[rowKey];
254
+ let highlightClass = "";
255
+ if (deletingRowKey.value !== null && deletingRowKey.value === rowKeyValue) {
256
+ highlightClass = "!bg-(--ui-color-error-50) dark:!bg-(--ui-color-error-900)";
257
+ } else if (editingRowKey.value !== null && editingRowKey.value === rowKeyValue) {
258
+ highlightClass = "!bg-(--ui-color-primary-50) dark:!bg-(--ui-color-primary-900)";
259
+ }
260
+ const existingClass = typeof existingTdClass === "function" ? existingTdClass(cell) : existingTdClass || "";
261
+ return [existingClass, highlightClass].filter(Boolean).join(" ");
262
+ };
263
+ });
246
264
  return newCols;
247
265
  });
248
266
  const tblContextMenuItems = ref([]);
@@ -345,6 +363,8 @@ export function useTable(props) {
345
363
  tblHeaderProps,
346
364
  tblPaginationProps,
347
365
  // others
348
- tblContextMenuItems
366
+ tblContextMenuItems,
367
+ deletingRowKey,
368
+ editingRowKey
349
369
  };
350
370
  }
@@ -8,6 +8,7 @@ export declare function useTableRowActions<T>(props: {
8
8
  disableRowUpdate?: boolean;
9
9
  disableRowCopy?: boolean;
10
10
  disableRowDeletion?: boolean;
11
+ disableRowDiff?: boolean;
11
12
  onEditRowFromModal?: (...args: any[]) => any;
12
13
  extraRowActions?: any[];
13
14
  useApiGroup?: (...args: any[]) => any;
@@ -18,4 +19,6 @@ export declare function useTableRowActions<T>(props: {
18
19
  getRowActions: (row: TableRow<T>) => DropdownMenuItem[];
19
20
  generateActionColumn: () => VColumn<T>;
20
21
  actionLoadingRowIdxSet: import("vue").Ref<Set<number> & Omit<Set<number>, keyof Set<any>>, Set<number> | (Set<number> & Omit<Set<number>, keyof Set<any>>)>;
22
+ deletingRowKey: import("vue").Ref<number | null, number | null>;
23
+ editingRowKey: import("vue").Ref<number | null, number | null>;
21
24
  };
@@ -13,6 +13,7 @@ export function useTableRowActions(props) {
13
13
  disableRowUpdate,
14
14
  disableRowCopy,
15
15
  disableRowDeletion,
16
+ disableRowDiff,
16
17
  onEditRowFromModal,
17
18
  extraRowActions,
18
19
  useApiGroup,
@@ -25,6 +26,8 @@ export function useTableRowActions(props) {
25
26
  const updateDiffModal = overlay.create(UpdateDiffModal);
26
27
  const apiGroup = useApiGroup?.();
27
28
  const actionLoadingRowIdxSet = ref(/* @__PURE__ */ new Set());
29
+ const deletingRowKey = ref(null);
30
+ const editingRowKey = ref(null);
28
31
  function getRowActions(row) {
29
32
  const actionItems = [];
30
33
  if (!disableRowUpdate && onEditRowFromModal) {
@@ -32,9 +35,14 @@ export function useTableRowActions(props) {
32
35
  label: "\u7F16\u8F91",
33
36
  icon: "i-lucide-clipboard-pen-line",
34
37
  onClick: async () => {
35
- const result = await onEditRowFromModal(row.original);
36
- if (result) {
37
- await fetchList();
38
+ editingRowKey.value = row.original[rowKey];
39
+ try {
40
+ const result = await onEditRowFromModal(row.original);
41
+ if (result) {
42
+ await fetchList();
43
+ }
44
+ } finally {
45
+ editingRowKey.value = null;
38
46
  }
39
47
  }
40
48
  });
@@ -94,7 +102,7 @@ export function useTableRowActions(props) {
94
102
  extraRowActions?.forEach((action) => {
95
103
  actionItems.push(buildActionItem(action));
96
104
  });
97
- if (tableName) {
105
+ if (tableName && !disableRowDiff) {
98
106
  if (actionItems.length > 0 && !disableRowDeletion) {
99
107
  actionItems.push({ type: "separator" });
100
108
  }
@@ -120,14 +128,19 @@ export function useTableRowActions(props) {
120
128
  icon: "i-lucide-trash-2",
121
129
  color: "error",
122
130
  onSelect: async () => {
123
- const result = await deleteModal.open({
124
- ids: [row.original[rowKey]],
125
- models: [row.original],
126
- displayFn: displayFnInDeleteModal,
127
- onDelete: (ids) => apiGroup?.batchDelete({ ids })
128
- }).result;
129
- if (result) {
130
- await fetchList();
131
+ deletingRowKey.value = row.original[rowKey];
132
+ try {
133
+ const result = await deleteModal.open({
134
+ ids: [row.original[rowKey]],
135
+ models: [row.original],
136
+ displayFn: displayFnInDeleteModal,
137
+ onDelete: (ids) => apiGroup?.batchDelete({ ids })
138
+ }).result;
139
+ if (result) {
140
+ await fetchList();
141
+ }
142
+ } finally {
143
+ deletingRowKey.value = null;
131
144
  }
132
145
  }
133
146
  });
@@ -185,6 +198,8 @@ export function useTableRowActions(props) {
185
198
  return {
186
199
  getRowActions,
187
200
  generateActionColumn,
188
- actionLoadingRowIdxSet
201
+ actionLoadingRowIdxSet,
202
+ deletingRowKey,
203
+ editingRowKey
189
204
  };
190
205
  }
@@ -23,5 +23,7 @@ export interface UseProTableViewReturn<T> {
23
23
  th: string;
24
24
  td: string;
25
25
  }>;
26
+ deletingRowKey: Ref<number | null>;
27
+ editingRowKey: Ref<number | null>;
26
28
  }
27
29
  export declare function useProTableView<T>(props: VTableProps<T>): UseProTableViewReturn<T>;
@@ -27,7 +27,9 @@ export function useProTableView(props) {
27
27
  tblWhereQueryProps,
28
28
  tblHeaderProps,
29
29
  tblPaginationProps,
30
- tblContextMenuItems
30
+ tblContextMenuItems,
31
+ deletingRowKey,
32
+ editingRowKey
31
33
  } = useTable(props);
32
34
  const thClass = computed(() => {
33
35
  const classList = [];
@@ -145,6 +147,8 @@ export function useProTableView(props) {
145
147
  tableWidth,
146
148
  updateTableWidth,
147
149
  tblClasses,
148
- tblUi
150
+ tblUi,
151
+ deletingRowKey,
152
+ editingRowKey
149
153
  };
150
154
  }
@@ -98,6 +98,7 @@ export type VTableProps<T> = {
98
98
  disableRowCopy?: boolean;
99
99
  disableRowDeletion?: boolean;
100
100
  disableRowSelection?: boolean;
101
+ disableRowDiff?: boolean;
101
102
  expandable?: boolean;
102
103
  expandVNode?: (row: T) => VNode;
103
104
  rowSpanColumns?: (keyof T)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v-nuxt-ui",
3
- "version": "0.2.27",
3
+ "version": "0.2.28",
4
4
  "description": "Veken UI Component Library - Reusable Nuxt UI components, composables, and utilities for enterprise applications",
5
5
  "type": "module",
6
6
  "style": "./dist/runtime/index.css",