@v1nt1248/3nclient-lib 0.1.45 → 0.1.47

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
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.1.45",
5
+ "version": "0.1.47",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -17,6 +17,7 @@ export type Ui3nTableConfig<T extends Ui3nTableBodyBaseItem, K extends keyof T =
17
17
  // draggableColumns?: boolean; // ToDo this will be done in the next version
18
18
  columnStyle?: { [P in Omit<K, 'id'> as string | number]: Record<string, string> };
19
19
  fieldAsRowKey?: keyof T;
20
+ showNoDataMessage?: boolean;
20
21
  };
21
22
 
22
23
  export type Ui3nTableHeadProps<T extends Ui3nTableBodyBaseItem> = {
@@ -42,9 +43,14 @@ export interface Ui3nTableProps<T extends Ui3nTableBodyBaseItem> {
42
43
 
43
44
  export interface Ui3nTableEmits<T extends Ui3nTableBodyBaseItem> {
44
45
  (ev: 'change:sort', val: Ui3nTableSort<T>): void;
46
+
45
47
  (ev: 'select:row', val: T[]): void;
46
48
  }
47
49
 
50
+ export type Ui3nTableNoDataSlot = {
51
+ 'no-data': () => VNode;
52
+ };
53
+
48
54
  export type Ui3nTableGroupActionsSlot = {
49
55
  'group-actions': () => VNode;
50
56
  };
@@ -80,7 +86,8 @@ export type Ui3nTableBodyRowCellSlot<T extends Ui3nTableBodyBaseItem, K extends
80
86
  [p in `row-cell-${K}`]: (scope: Ui3nTableBodyRowCellSlotScope<T, K>) => VNode;
81
87
  };
82
88
 
83
- export type Ui3nTableSlots<T extends Ui3nTableBodyBaseItem, K extends string & keyof T> = Ui3nTableGroupActionsSlot &
89
+ export type Ui3nTableSlots<T extends Ui3nTableBodyBaseItem, K extends string & keyof T> = Ui3nTableNoDataSlot &
90
+ Ui3nTableGroupActionsSlot &
84
91
  Ui3nTableHeaderCellSlot<T, K> &
85
92
  Ui3nTableBodyRowSlot<T> &
86
93
  Ui3nTableBodyRowCellSlot<T, K>;
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts" generic="T extends Ui3nTableBodyBaseItem">
2
+ import size from 'lodash/size';
2
3
  import { useTable } from './composables/useTable';
3
4
  import type { Ui3nTableBodyBaseItem, Ui3nTableEmits, Ui3nTableProps, Ui3nTableSlots } from './types';
4
5
  import Ui3nButton from '../ui3n-button/ui3n-button.vue';
@@ -28,6 +29,12 @@
28
29
  const eventHandlers = {
29
30
  select: processSelection,
30
31
  };
32
+
33
+ defineExpose({
34
+ getRowStyle,
35
+ selectedRowsArray,
36
+ closeGroupActionsRow,
37
+ });
31
38
  </script>
32
39
 
33
40
  <template>
@@ -98,61 +105,69 @@
98
105
 
99
106
  <!-- table body -->
100
107
  <div :class="$style.body">
101
- <template v-if="$slots['row']">
102
- <div
103
- v-for="(row, rowIndex) in body.content"
104
- :key="getRowKey(row, rowIndex)"
105
- :class="[$style.row, isRowSelected(row) && $style.selected, config.selectable && $style.selectable]"
106
- >
107
- <slot
108
- name="row"
109
- :row="row"
110
- :row-style="getRowStyle(row)"
111
- :row-index="rowIndex"
112
- :is-row-selected="isRowSelected(row)"
113
- :column-style="config?.columnStyle"
114
- :events="eventHandlers"
115
- />
116
- </div>
108
+ <template v-if="config?.showNoDataMessage && !size(body.content)">
109
+ <slot name="no-data">
110
+ <div :class="$style.noData">No data</div>
111
+ </slot>
117
112
  </template>
118
113
 
119
114
  <template v-else>
120
- <div
121
- v-for="(row, rowIndex) in body.content"
122
- :key="getRowKey(row, rowIndex)"
123
- :class="[$style.row, isRowSelected(row) && $style.selected, config.selectable && $style.selectable]"
124
- :style="getRowStyle(row)"
125
- >
115
+ <template v-if="$slots['row']">
126
116
  <div
127
- v-if="config.selectable"
128
- :class="$style.rowCheckbox"
117
+ v-for="(row, rowIndex) in body.content"
118
+ :key="getRowKey(row, rowIndex)"
119
+ :class="[$style.row, isRowSelected(row) && $style.selected, config.selectable && $style.selectable]"
129
120
  >
130
- <ui3n-checkbox
131
- :model-value="isRowSelected(row)"
132
- @change="processSelection(row)"
121
+ <slot
122
+ name="row"
123
+ :row="row"
124
+ :row-style="getRowStyle(row)"
125
+ :row-index="rowIndex"
126
+ :is-row-selected="isRowSelected(row)"
127
+ :column-style="config?.columnStyle"
128
+ :events="eventHandlers"
133
129
  />
134
130
  </div>
131
+ </template>
135
132
 
136
- <template
137
- v-for="(col, colIndex) in visibleColumns"
138
- :key="col.key"
133
+ <template v-else>
134
+ <div
135
+ v-for="(row, rowIndex) in body.content"
136
+ :key="getRowKey(row, rowIndex)"
137
+ :class="[$style.row, isRowSelected(row) && $style.selected, config.selectable && $style.selectable]"
138
+ :style="getRowStyle(row)"
139
139
  >
140
- <div :class="[$style.bodyItem, colIndex === 0 && $style.bodyItemFirst]">
141
- <slot
142
- :name="`row-cell-${col.key as string & keyof T}`"
143
- :row="row"
144
- :row-index="rowIndex"
145
- :is-row-selected="isRowSelected(row)"
146
- :column-style="config?.columnStyle"
147
- :cell="row[col.key]"
148
- >
140
+ <div
141
+ v-if="config.selectable"
142
+ :class="$style.rowCheckbox"
143
+ >
144
+ <ui3n-checkbox
145
+ :model-value="isRowSelected(row)"
146
+ @change="processSelection(row)"
147
+ />
148
+ </div>
149
+
150
+ <template
151
+ v-for="(col, colIndex) in visibleColumns"
152
+ :key="col.key"
153
+ >
154
+ <div :class="[$style.bodyItem, colIndex === 0 && $style.bodyItemFirst]">
155
+ <slot
156
+ :name="`row-cell-${col.key as string & keyof T}`"
157
+ :row="row"
158
+ :row-index="rowIndex"
159
+ :is-row-selected="isRowSelected(row)"
160
+ :column-style="config?.columnStyle"
161
+ :cell="row[col.key]"
162
+ >
149
163
  <span :class="$style.cell">
150
164
  {{ row[col.key] }}
151
165
  </span>
152
- </slot>
153
- </div>
154
- </template>
155
- </div>
166
+ </slot>
167
+ </div>
168
+ </template>
169
+ </div>
170
+ </template>
156
171
  </template>
157
172
  </div>
158
173
  </div>
@@ -317,4 +332,17 @@
317
332
  font-weight: 400;
318
333
  color: var(--color-text-table-primary-default);
319
334
  }
335
+
336
+ .noData {
337
+ position: relative;
338
+ width: 100%;
339
+ height: var(--spacing-xxl);
340
+ padding-top: var(--spacing-ml);
341
+ display: flex;
342
+ justify-content: center;
343
+ align-items: center;
344
+ font-size: var(--font-12);
345
+ font-weight: 600;
346
+ color: var(--color-text-control-secondary-default);
347
+ }
320
348
  </style>