@globalbrain/sefirot 2.7.3 → 2.8.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.
|
@@ -102,10 +102,17 @@ function updateColWidth(key: string, value: string) {
|
|
|
102
102
|
>
|
|
103
103
|
<div class="block">
|
|
104
104
|
<div class="row">
|
|
105
|
-
<STableItem
|
|
105
|
+
<STableItem
|
|
106
|
+
v-for="key in orders"
|
|
107
|
+
:key="key"
|
|
108
|
+
:name="key"
|
|
109
|
+
:class-name="columns[key].className"
|
|
110
|
+
:width="colWidths[key]"
|
|
111
|
+
>
|
|
106
112
|
<STableColumn
|
|
107
113
|
:name="key"
|
|
108
114
|
:label="columns[key].label"
|
|
115
|
+
:class-name="columns[key].className"
|
|
109
116
|
:dropdown="columns[key].dropdown"
|
|
110
117
|
@resize="(value) => updateColWidth(key, value)"
|
|
111
118
|
/>
|
|
@@ -124,9 +131,16 @@ function updateColWidth(key: string, value: string) {
|
|
|
124
131
|
>
|
|
125
132
|
<div class="block">
|
|
126
133
|
<div v-for="(record, rIndex) in records" :key="rIndex" class="row">
|
|
127
|
-
<STableItem
|
|
134
|
+
<STableItem
|
|
135
|
+
v-for="key in orders"
|
|
136
|
+
:key="key"
|
|
137
|
+
:name="key"
|
|
138
|
+
:class-name="columns[key].className"
|
|
139
|
+
:width="colWidths[key]"
|
|
140
|
+
>
|
|
128
141
|
<STableCell
|
|
129
142
|
:name="key"
|
|
143
|
+
:class-name="columns[key].className"
|
|
130
144
|
:cell="columns[key].cell"
|
|
131
145
|
:value="record[key]"
|
|
132
146
|
:record="record"
|
|
@@ -8,6 +8,7 @@ import STableCellText from './STableCellText.vue'
|
|
|
8
8
|
|
|
9
9
|
defineProps<{
|
|
10
10
|
name: string
|
|
11
|
+
className?: string
|
|
11
12
|
cell?: TableCell
|
|
12
13
|
value: any
|
|
13
14
|
record: any
|
|
@@ -16,7 +17,7 @@ defineProps<{
|
|
|
16
17
|
</script>
|
|
17
18
|
|
|
18
19
|
<template>
|
|
19
|
-
<div class="STableCell" :class="[`col-${name}`]">
|
|
20
|
+
<div class="STableCell" :class="[className, `col-${name}`]">
|
|
20
21
|
<STableCellText
|
|
21
22
|
v-if="!cell || cell.type === 'text'"
|
|
22
23
|
:value="value"
|
|
@@ -26,6 +27,7 @@ defineProps<{
|
|
|
26
27
|
:link="cell?.link"
|
|
27
28
|
:color="cell?.color"
|
|
28
29
|
:icon-color="cell?.iconColor"
|
|
30
|
+
:on-click="cell?.onClick"
|
|
29
31
|
/>
|
|
30
32
|
<STableCellDay
|
|
31
33
|
v-else-if="cell.type === 'day'"
|
|
@@ -8,6 +8,7 @@ export type Color =
|
|
|
8
8
|
| 'soft'
|
|
9
9
|
| 'mute'
|
|
10
10
|
| 'info'
|
|
11
|
+
| 'success'
|
|
11
12
|
| 'warning'
|
|
12
13
|
| 'danger'
|
|
13
14
|
|
|
@@ -15,10 +16,11 @@ const props = defineProps<{
|
|
|
15
16
|
value?: any
|
|
16
17
|
record: any
|
|
17
18
|
icon?: any
|
|
18
|
-
getter?: string | ((value: any) => string)
|
|
19
|
+
getter?: string | ((value: any, record: any) => string)
|
|
19
20
|
color?: Color | ((value: any, record: any) => Color)
|
|
20
21
|
iconColor?: Color | ((value: any, record: any) => Color)
|
|
21
22
|
link?(value: any, record: any): string
|
|
23
|
+
onClick?(value: any, record: any): void
|
|
22
24
|
}>()
|
|
23
25
|
|
|
24
26
|
const _value = computed(() => {
|
|
@@ -28,7 +30,7 @@ const _value = computed(() => {
|
|
|
28
30
|
|
|
29
31
|
return typeof props.getter === 'string'
|
|
30
32
|
? props.getter
|
|
31
|
-
: props.getter(props.value)
|
|
33
|
+
: props.getter(props.value, props.record)
|
|
32
34
|
})
|
|
33
35
|
|
|
34
36
|
const _color = computed(() => {
|
|
@@ -45,8 +47,14 @@ const _iconColor = computed(() => {
|
|
|
45
47
|
</script>
|
|
46
48
|
|
|
47
49
|
<template>
|
|
48
|
-
<div class="STableCellText" :class="[{ link }, _color]">
|
|
49
|
-
<SLink
|
|
50
|
+
<div class="STableCellText" :class="[{ link: link || onClick }, _color]">
|
|
51
|
+
<SLink
|
|
52
|
+
v-if="_value"
|
|
53
|
+
class="container"
|
|
54
|
+
:href="link?.(value, record)"
|
|
55
|
+
:role="onClick ? 'button' : null"
|
|
56
|
+
@click="() => onClick?.(value, record)"
|
|
57
|
+
>
|
|
50
58
|
<div v-if="icon" class="icon" :class="[_iconColor ?? _color]">
|
|
51
59
|
<SIcon :icon="icon" class="svg" />
|
|
52
60
|
</div>
|
|
@@ -81,6 +89,7 @@ const _iconColor = computed(() => {
|
|
|
81
89
|
&.soft { color: var(--c-text-2); }
|
|
82
90
|
&.mute { color: var(--c-text-3); }
|
|
83
91
|
&.info { color: var(--c-info); }
|
|
92
|
+
&.success { color: var(--c-success); }
|
|
84
93
|
&.warning { color: var(--c-warning); }
|
|
85
94
|
&.danger { color: var(--c-danger); }
|
|
86
95
|
|
|
@@ -92,9 +101,11 @@ const _iconColor = computed(() => {
|
|
|
92
101
|
.STableCellText.link &.soft { color: var(--c-text-2); }
|
|
93
102
|
.STableCellText.link:hover &.soft { color: var(--c-info); }
|
|
94
103
|
.STableCellText.link &.mute { color: var(--c-text-3); }
|
|
95
|
-
.STableCellText.link:hover &.mute { color: var(--c-
|
|
104
|
+
.STableCellText.link:hover &.mute { color: var(--c-text-3); }
|
|
96
105
|
.STableCellText.link &.info { color: var(--c-info); }
|
|
97
106
|
.STableCellText.link:hover &.info { color: var(--c-info-dark); }
|
|
107
|
+
.STableCellText.link &.success { color: var(--c-success); }
|
|
108
|
+
.STableCellText.link:hover &.success { color: var(--c-success-dark); }
|
|
98
109
|
.STableCellText.link &.warning { color: var(--c-warning); }
|
|
99
110
|
.STableCellText.link:hover &.warning { color: var(--c-warning-darker); }
|
|
100
111
|
.STableCellText.link &.danger { color: var(--c-danger); }
|
|
@@ -126,6 +137,8 @@ const _iconColor = computed(() => {
|
|
|
126
137
|
.STableCellText.link:hover &.mute { color: var(--c-info); }
|
|
127
138
|
.STableCellText.link &.info { color: var(--c-info); }
|
|
128
139
|
.STableCellText.link:hover &.info { color: var(--c-info-dark); }
|
|
140
|
+
.STableCellText.link &.success { color: var(--c-success); }
|
|
141
|
+
.STableCellText.link:hover &.success { color: var(--c-success-dark); }
|
|
129
142
|
.STableCellText.link &.warning { color: var(--c-warning); }
|
|
130
143
|
.STableCellText.link:hover &.warning { color: var(--c-warning-dark); }
|
|
131
144
|
.STableCellText.link &.danger { color: var(--c-danger); }
|
|
@@ -112,7 +112,7 @@ function stopDialogPositionListener() {
|
|
|
112
112
|
</script>
|
|
113
113
|
|
|
114
114
|
<template>
|
|
115
|
-
<div class="STableColumn STableCell" :class="[{ active }, className
|
|
115
|
+
<div class="STableColumn STableCell" :class="[{ active }, className, `col-${name}`]" ref="column">
|
|
116
116
|
<div class="container">
|
|
117
117
|
<p class="label">{{ label }}</p>
|
|
118
118
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
defineProps<{
|
|
3
3
|
name: string
|
|
4
|
+
className?: string
|
|
4
5
|
width?: string
|
|
5
6
|
}>()
|
|
6
7
|
</script>
|
|
@@ -8,7 +9,7 @@ defineProps<{
|
|
|
8
9
|
<template>
|
|
9
10
|
<div
|
|
10
11
|
class="STableItem"
|
|
11
|
-
:class="[`col-${name}`, { adjusted: width }]"
|
|
12
|
+
:class="[className, `col-${name}`, { adjusted: width }]"
|
|
12
13
|
>
|
|
13
14
|
<slot />
|
|
14
15
|
</div>
|
package/lib/composables/Table.ts
CHANGED
|
@@ -45,10 +45,11 @@ export interface TableCellBase {
|
|
|
45
45
|
export interface TableCellText extends TableCellBase {
|
|
46
46
|
type: 'text'
|
|
47
47
|
icon?: any
|
|
48
|
-
value?: string | ((value: any) => string)
|
|
48
|
+
value?: string | ((value: any, record: any) => string)
|
|
49
49
|
link?(value: any, record: any): string
|
|
50
50
|
color?: TableCellTextColor | ((value: any, record: any) => TableCellTextColor)
|
|
51
51
|
iconColor?: TableCellTextColor | ((value: any, record: any) => TableCellTextColor)
|
|
52
|
+
onClick?(value: any, record: any): void
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
export type TableCellTextColor =
|
|
@@ -56,6 +57,7 @@ export type TableCellTextColor =
|
|
|
56
57
|
| 'soft'
|
|
57
58
|
| 'mute'
|
|
58
59
|
| 'info'
|
|
60
|
+
| 'success'
|
|
59
61
|
| 'warning'
|
|
60
62
|
| 'danger'
|
|
61
63
|
|
|
@@ -99,8 +101,8 @@ export interface TableCellAvatarsOption {
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
export interface UseTableOptions {
|
|
102
|
-
orders: string[]
|
|
103
|
-
columns: TableColumns
|
|
104
|
+
orders: MaybeRef<string[]>
|
|
105
|
+
columns: MaybeRef<TableColumns>
|
|
104
106
|
records?: MaybeRef<Record<string, any>[] | null | undefined>
|
|
105
107
|
total?: MaybeRef<number | null | undefined>
|
|
106
108
|
page?: MaybeRef<number | null | undefined>
|