@globalbrain/sefirot 2.27.0 → 2.29.0
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.
|
@@ -18,6 +18,7 @@ const {
|
|
|
18
18
|
records,
|
|
19
19
|
header,
|
|
20
20
|
footer,
|
|
21
|
+
summary,
|
|
21
22
|
total,
|
|
22
23
|
page,
|
|
23
24
|
perPage,
|
|
@@ -71,6 +72,12 @@ const classes = computed(() => ({
|
|
|
71
72
|
'borderless': borderless?.value
|
|
72
73
|
}))
|
|
73
74
|
|
|
75
|
+
const recordsWithSummary = computed(() => {
|
|
76
|
+
return (records?.value && summary?.value)
|
|
77
|
+
? [...records?.value, summary?.value]
|
|
78
|
+
: records?.value ?? []
|
|
79
|
+
})
|
|
80
|
+
|
|
74
81
|
watch(() => records?.value, () => {
|
|
75
82
|
headLock = true
|
|
76
83
|
bodyLock = true
|
|
@@ -107,6 +114,16 @@ function lockBody(value: boolean) {
|
|
|
107
114
|
function updateColWidth(key: string, value: string) {
|
|
108
115
|
colWidths[key] = value
|
|
109
116
|
}
|
|
117
|
+
|
|
118
|
+
function isSummary(index: number) {
|
|
119
|
+
return index === records?.value?.length
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function getCell(key: string, index: number) {
|
|
123
|
+
return (isSummary(index) && columns.value[key]?.summaryCell)
|
|
124
|
+
? columns.value[key]?.summaryCell
|
|
125
|
+
: columns.value[key]?.cell
|
|
126
|
+
}
|
|
110
127
|
</script>
|
|
111
128
|
|
|
112
129
|
<template>
|
|
@@ -160,7 +177,12 @@ function updateColWidth(key: string, value: string) {
|
|
|
160
177
|
@scroll="syncBodyScroll"
|
|
161
178
|
>
|
|
162
179
|
<div class="block">
|
|
163
|
-
<div
|
|
180
|
+
<div
|
|
181
|
+
v-for="(record, rIndex) in recordsWithSummary"
|
|
182
|
+
:key="rIndex"
|
|
183
|
+
class="row"
|
|
184
|
+
:class="isSummary(rIndex) && 'summary'"
|
|
185
|
+
>
|
|
164
186
|
<STableItem
|
|
165
187
|
v-for="key in orders"
|
|
166
188
|
:key="key"
|
|
@@ -170,8 +192,9 @@ function updateColWidth(key: string, value: string) {
|
|
|
170
192
|
>
|
|
171
193
|
<STableCell
|
|
172
194
|
:name="key"
|
|
195
|
+
:class="isSummary(rIndex) && 'summary'"
|
|
173
196
|
:class-name="columns[key].className"
|
|
174
|
-
:cell="
|
|
197
|
+
:cell="getCell(key, rIndex)"
|
|
175
198
|
:value="record[key]"
|
|
176
199
|
:record="record"
|
|
177
200
|
:records="records"
|
|
@@ -95,7 +95,11 @@ const computedCell = computed<TableCell | undefined>(() =>
|
|
|
95
95
|
overflow: hidden;
|
|
96
96
|
|
|
97
97
|
.row:hover & {
|
|
98
|
-
background-color: var(--c-bg-elv);
|
|
98
|
+
background-color: var(--c-bg-elv-1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.summary & {
|
|
102
|
+
background-color: var(--c-bg-elv-2);
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
.STableItem:first-child & {
|
|
@@ -42,5 +42,9 @@ const _value = computed(() => {
|
|
|
42
42
|
.STableCellDay.neutral & { color: var(--c-text-1); }
|
|
43
43
|
.STableCellDay.soft & { color: var(--c-text-2); }
|
|
44
44
|
.STableCellDay.mute & { color: var(--c-text-3); }
|
|
45
|
+
|
|
46
|
+
.STableCell.summary & {
|
|
47
|
+
font-weight: var(--table-cell-summary-font-weight);
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
</style>
|
|
@@ -110,6 +110,10 @@ const _iconColor = computed(() => {
|
|
|
110
110
|
.STableCellText.link:hover &.warning { color: var(--c-warning-darker); }
|
|
111
111
|
.STableCellText.link &.danger { color: var(--c-danger); }
|
|
112
112
|
.STableCellText.link:hover &.danger { color: var(--c-danger-dark); }
|
|
113
|
+
|
|
114
|
+
.STableCell.summary & {
|
|
115
|
+
font-weight: var(--table-cell-summary-font-weight);
|
|
116
|
+
}
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
.icon {
|
package/lib/composables/Table.ts
CHANGED
|
@@ -6,13 +6,15 @@ import type { DropdownSection } from './Dropdown'
|
|
|
6
6
|
|
|
7
7
|
export interface Table<
|
|
8
8
|
O extends string = any,
|
|
9
|
-
R extends Record<string, any> = any
|
|
9
|
+
R extends Record<string, any> = any,
|
|
10
|
+
SR extends Record<string, any> = any
|
|
10
11
|
> {
|
|
11
12
|
orders: O[]
|
|
12
|
-
columns: TableColumns<O, R>
|
|
13
|
+
columns: TableColumns<O, R, SR>
|
|
13
14
|
records?: R[] | null
|
|
14
15
|
header?: boolean
|
|
15
16
|
footer?: boolean
|
|
17
|
+
summary?: SR | null
|
|
16
18
|
total?: number | null
|
|
17
19
|
page?: number | null
|
|
18
20
|
perPage?: number | null
|
|
@@ -26,21 +28,23 @@ export interface Table<
|
|
|
26
28
|
|
|
27
29
|
export type TableColumns<
|
|
28
30
|
O extends string,
|
|
29
|
-
R extends Record<string, any
|
|
31
|
+
R extends Record<string, any>,
|
|
32
|
+
SR extends Record<string, any>
|
|
30
33
|
> = {
|
|
31
|
-
[K in O]: K
|
|
32
|
-
? TableColumn<R[K], R>
|
|
33
|
-
: TableColumn<undefined, R>
|
|
34
|
+
[K in O]: TableColumn<R[K], R, SR[K], SR>
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
export interface TableColumn<V, R> {
|
|
37
|
+
export interface TableColumn<V, R, SV, SR> {
|
|
37
38
|
label?: string
|
|
38
39
|
className?: string
|
|
39
40
|
dropdown?: DropdownSection[]
|
|
40
41
|
resizable?: boolean
|
|
41
|
-
cell?: TableCell |
|
|
42
|
+
cell?: TableCell | TableColumnCellFn<V, R>
|
|
43
|
+
summaryCell?: TableCell | TableColumnCellFn<SV, SR>
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
export type TableColumnCellFn<V, R> = (value: V, record: R) => TableCell
|
|
47
|
+
|
|
44
48
|
export type TableCell =
|
|
45
49
|
| TableCellText
|
|
46
50
|
| TableCellDay
|
|
@@ -138,12 +142,17 @@ export interface TableCellComponent extends TableCellBase {
|
|
|
138
142
|
props?: Record<string, any>
|
|
139
143
|
}
|
|
140
144
|
|
|
141
|
-
export interface UseTableOptions<
|
|
145
|
+
export interface UseTableOptions<
|
|
146
|
+
O extends string,
|
|
147
|
+
R extends Record<string, any>,
|
|
148
|
+
SR extends Record<string, any>
|
|
149
|
+
> {
|
|
142
150
|
orders: MaybeRef<O[]>
|
|
143
|
-
columns: MaybeRef<TableColumns<O, R>>
|
|
151
|
+
columns: MaybeRef<TableColumns<O, R, SR>>
|
|
144
152
|
records?: MaybeRef<R[] | null | undefined>
|
|
145
153
|
header?: MaybeRef<boolean | undefined>
|
|
146
154
|
footer?: MaybeRef<boolean | undefined>
|
|
155
|
+
summary?: MaybeRef<SR | null | undefined>
|
|
147
156
|
total?: MaybeRef<number | null | undefined>
|
|
148
157
|
page?: MaybeRef<number | null | undefined>
|
|
149
158
|
perPage?: MaybeRef<number | null | undefined>
|
|
@@ -155,8 +164,12 @@ export interface UseTableOptions<O extends string, R extends Record<string, any>
|
|
|
155
164
|
onReset?(): void
|
|
156
165
|
}
|
|
157
166
|
|
|
158
|
-
export function useTable<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
167
|
+
export function useTable<
|
|
168
|
+
O extends string,
|
|
169
|
+
R extends Record<string, any>,
|
|
170
|
+
SR extends Record<string, any>
|
|
171
|
+
>(
|
|
172
|
+
options: UseTableOptions<O, R, SR>
|
|
173
|
+
): Table<O, R, SR> {
|
|
174
|
+
return reactive(options) as Table<O, R, SR>
|
|
162
175
|
}
|
package/lib/styles/variables.css
CHANGED