webcake-ui-kit 1.1.18 → 1.1.19
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 +2 -1
- package/src/components/button/button.css +1 -0
- package/src/components/checkbox/checkbox.css +1 -0
- package/src/components/dropdown/Dropdown.vue +5 -1
- package/src/components/dropdown/DropdownMenuItems.vue +27 -33
- package/src/components/dropdown/dropdown-menu-items.css +5 -0
- package/src/components/empty/Empty.vue +2 -2
- package/src/components/table/Table.vue +310 -0
- package/src/components/table/table.css +197 -0
- package/src/components/typography/Typography.vue +5 -3
- package/src/floating/focus-mixin.js +5 -0
- package/src/icons/ClippingMask.vue +56 -0
- package/src/icons/index.js +1 -0
- package/src/index.js +1 -0
- package/src/utils/common.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcake-ui-kit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.19",
|
|
4
4
|
"description": "UI Kit for Vue 2 && 3 - Pure Options API",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"./WkSpinner": "./src/components/spinner/Spinner.vue",
|
|
49
49
|
"./WkSwitch": "./src/components/switch/Switch.vue",
|
|
50
50
|
"./WkSwitchGroup": "./src/components/switch-group/SwitchGroup.vue",
|
|
51
|
+
"./WkTable": "./src/components/table/Table.vue",
|
|
51
52
|
"./WkTabs": "./src/components/tabs/Tabs.vue",
|
|
52
53
|
"./WkTag": "./src/components/tag/Tag.vue",
|
|
53
54
|
"./WkToggle": "./src/components/toggle/Toggle.vue",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<slot></slot>
|
|
22
22
|
</span>
|
|
23
23
|
</template>
|
|
24
|
-
<DropdownMenuItems v-if="hasItems" :items="items" @select="onItemSelect" />
|
|
24
|
+
<DropdownMenuItems v-if="hasItems" :items="items" :value="value" @select="onItemSelect" />
|
|
25
25
|
<slot v-else name="overlay"></slot>
|
|
26
26
|
</Menu>
|
|
27
27
|
</template>
|
|
@@ -71,6 +71,10 @@ export default {
|
|
|
71
71
|
default: function () {
|
|
72
72
|
return []
|
|
73
73
|
}
|
|
74
|
+
},
|
|
75
|
+
value: {
|
|
76
|
+
type: [String, Array],
|
|
77
|
+
default: null
|
|
74
78
|
}
|
|
75
79
|
},
|
|
76
80
|
emits: ['change', 'update:modelValue', 'open', 'close', 'select'],
|
|
@@ -7,12 +7,7 @@
|
|
|
7
7
|
<!-- Group: non-clickable label + flat children -->
|
|
8
8
|
<div v-else-if="item._type === 'group'" class="ui-dropdown-items__group">
|
|
9
9
|
<div class="ui-dropdown-items__group-label" :title="item.title || undefined">
|
|
10
|
-
<component
|
|
11
|
-
:is="item.icon"
|
|
12
|
-
v-if="item.icon && isComponent(item.icon)"
|
|
13
|
-
class="ui-dropdown-items__icon"
|
|
14
|
-
:color="item.colorIcon"
|
|
15
|
-
/>
|
|
10
|
+
<component :is="item.icon" v-if="item.icon && isComponent(item.icon)" :size="20" :color="item.colorIcon" />
|
|
16
11
|
<span :style="item.color ? { color: item.color } : undefined">{{ item.label }}</span>
|
|
17
12
|
</div>
|
|
18
13
|
<div
|
|
@@ -21,21 +16,18 @@
|
|
|
21
16
|
class="ui-dropdown-items__item"
|
|
22
17
|
:class="{
|
|
23
18
|
'ui-dropdown-items__item--disabled': child.disabled,
|
|
24
|
-
'ui-dropdown-items__item--destructive': child.destructive
|
|
19
|
+
'ui-dropdown-items__item--destructive': child.destructive,
|
|
20
|
+
'ui-dropdown-items__item--active': isActive(child.key)
|
|
25
21
|
}"
|
|
26
22
|
:title="child.title || undefined"
|
|
27
23
|
@click="onItemClick(child)"
|
|
28
24
|
>
|
|
29
|
-
<component
|
|
30
|
-
:is="child.icon"
|
|
31
|
-
v-if="child.icon && isComponent(child.icon)"
|
|
32
|
-
class="ui-dropdown-items__icon"
|
|
33
|
-
:color="item.colorIcon"
|
|
34
|
-
/>
|
|
25
|
+
<component :is="child.icon" v-if="child.icon && isComponent(child.icon)" :size="20" :color="item.colorIcon" />
|
|
35
26
|
<span class="ui-dropdown-items__label" :style="child.color ? { color: child.color } : undefined">{{
|
|
36
27
|
child.label
|
|
37
28
|
}}</span>
|
|
38
29
|
<span v-if="child.extra" class="ui-dropdown-items__extra">{{ child.extra }}</span>
|
|
30
|
+
<WkiCheck v-if="isActive(child.key)" :size="16" color="var(--muted-fg)" />
|
|
39
31
|
</div>
|
|
40
32
|
</div>
|
|
41
33
|
|
|
@@ -49,12 +41,7 @@
|
|
|
49
41
|
}"
|
|
50
42
|
:title="item.title || undefined"
|
|
51
43
|
>
|
|
52
|
-
<component
|
|
53
|
-
:is="item.icon"
|
|
54
|
-
v-if="item.icon && isComponent(item.icon)"
|
|
55
|
-
class="ui-dropdown-items__icon"
|
|
56
|
-
:color="item.colorIcon"
|
|
57
|
-
/>
|
|
44
|
+
<component :is="item.icon" v-if="item.icon && isComponent(item.icon)" :size="20" :color="item.colorIcon" />
|
|
58
45
|
<span class="ui-dropdown-items__label" :style="item.color ? { color: item.color } : undefined">{{
|
|
59
46
|
item.label
|
|
60
47
|
}}</span>
|
|
@@ -65,21 +52,18 @@
|
|
|
65
52
|
class="ui-dropdown-items__item ui-dropdown-items__item--sub"
|
|
66
53
|
:class="{
|
|
67
54
|
'ui-dropdown-items__item--disabled': child.disabled || item.disabled,
|
|
68
|
-
'ui-dropdown-items__item--destructive': child.destructive
|
|
55
|
+
'ui-dropdown-items__item--destructive': child.destructive,
|
|
56
|
+
'ui-dropdown-items__item--active': isActive(child.key)
|
|
69
57
|
}"
|
|
70
58
|
:title="child.title || undefined"
|
|
71
59
|
@click="onItemClick(child, item)"
|
|
72
60
|
>
|
|
73
|
-
<component
|
|
74
|
-
:is="child.icon"
|
|
75
|
-
v-if="child.icon && isComponent(child.icon)"
|
|
76
|
-
class="ui-dropdown-items__icon"
|
|
77
|
-
:color="item.colorIcon"
|
|
78
|
-
/>
|
|
61
|
+
<component :is="child.icon" v-if="child.icon && isComponent(child.icon)" :size="20" :color="item.colorIcon" />
|
|
79
62
|
<span class="ui-dropdown-items__label" :style="child.color ? { color: child.color } : undefined">{{
|
|
80
63
|
child.label
|
|
81
64
|
}}</span>
|
|
82
65
|
<span v-if="child.extra" class="ui-dropdown-items__extra">{{ child.extra }}</span>
|
|
66
|
+
<WkiCheck v-if="isActive(child.key)" :size="16" color="var(--muted-fg)" />
|
|
83
67
|
</div>
|
|
84
68
|
</div>
|
|
85
69
|
|
|
@@ -89,27 +73,26 @@
|
|
|
89
73
|
class="ui-dropdown-items__item"
|
|
90
74
|
:class="{
|
|
91
75
|
'ui-dropdown-items__item--disabled': item.disabled,
|
|
92
|
-
'ui-dropdown-items__item--destructive': item.destructive
|
|
76
|
+
'ui-dropdown-items__item--destructive': item.destructive,
|
|
77
|
+
'ui-dropdown-items__item--active': isActive(item.key)
|
|
93
78
|
}"
|
|
94
79
|
:title="item.title || undefined"
|
|
95
80
|
@click="onItemClick(item)"
|
|
96
81
|
>
|
|
97
|
-
<component
|
|
98
|
-
:is="item.icon"
|
|
99
|
-
v-if="item.icon && isComponent(item.icon)"
|
|
100
|
-
class="ui-dropdown-items__icon"
|
|
101
|
-
:color="item.colorIcon"
|
|
102
|
-
/>
|
|
82
|
+
<component :is="item.icon" v-if="item.icon && isComponent(item.icon)" :size="20" :color="item.colorIcon" />
|
|
103
83
|
<span class="ui-dropdown-items__label" :style="item.color ? { color: item.color } : undefined">{{
|
|
104
84
|
item.label
|
|
105
85
|
}}</span>
|
|
106
86
|
<span v-if="item.extra" class="ui-dropdown-items__extra">{{ item.extra }}</span>
|
|
87
|
+
<WkiCheck v-if="isActive(item.key)" :size="16" color="var(--muted-fg)" />
|
|
107
88
|
</div>
|
|
108
89
|
</div>
|
|
109
90
|
</div>
|
|
110
91
|
</template>
|
|
111
92
|
|
|
112
93
|
<script>
|
|
94
|
+
import WkiCheck from '../../icons/Check.vue'
|
|
95
|
+
|
|
113
96
|
function skipReactive(val) {
|
|
114
97
|
if (val && typeof val === 'object' && !val.__v_skip) {
|
|
115
98
|
val.__v_skip = true
|
|
@@ -119,12 +102,18 @@ function skipReactive(val) {
|
|
|
119
102
|
export default {
|
|
120
103
|
name: 'DropdownMenuItems',
|
|
121
104
|
|
|
105
|
+
components: { WkiCheck },
|
|
106
|
+
|
|
122
107
|
props: {
|
|
123
108
|
items: {
|
|
124
109
|
type: Array,
|
|
125
110
|
default: function () {
|
|
126
111
|
return []
|
|
127
112
|
}
|
|
113
|
+
},
|
|
114
|
+
value: {
|
|
115
|
+
type: [String, Array],
|
|
116
|
+
default: null
|
|
128
117
|
}
|
|
129
118
|
},
|
|
130
119
|
|
|
@@ -162,6 +151,11 @@ export default {
|
|
|
162
151
|
isComponent(val) {
|
|
163
152
|
return val !== null && typeof val === 'object'
|
|
164
153
|
},
|
|
154
|
+
isActive(key) {
|
|
155
|
+
if (this.value === null || this.value === undefined) return false
|
|
156
|
+
if (Array.isArray(this.value)) return this.value.indexOf(key) !== -1
|
|
157
|
+
return this.value === key
|
|
158
|
+
},
|
|
165
159
|
onItemClick(item, parentItem) {
|
|
166
160
|
if (item.disabled || (parentItem && parentItem.disabled)) return
|
|
167
161
|
this.$emit('select', item.key)
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
<slot name="media"></slot>
|
|
6
6
|
</div>
|
|
7
7
|
<div v-if="hasTextBlock" class="ui-empty__text">
|
|
8
|
-
<Typography v-if="hasTitle" variant="paragraph" weight="medium">
|
|
8
|
+
<Typography v-if="hasTitle" class="ui-empty__title" variant="paragraph-regular" weight="medium">
|
|
9
9
|
<slot name="title">{{ title }}</slot>
|
|
10
10
|
</Typography>
|
|
11
|
-
<Typography v-if="hasDescription" variant="paragraph-small" weight="regular">
|
|
11
|
+
<Typography v-if="hasDescription" class="ui-empty__description" variant="paragraph-small" weight="regular">
|
|
12
12
|
<slot name="description">{{ description }}</slot>
|
|
13
13
|
</Typography>
|
|
14
14
|
</div>
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="['ui-table', bordered && 'ui-table--bordered', hasVerticalScroll && 'ui-table--scroll-y']"
|
|
4
|
+
:style="containerStyle"
|
|
5
|
+
>
|
|
6
|
+
<table class="ui-table__table" :style="tableStyle">
|
|
7
|
+
<colgroup>
|
|
8
|
+
<col v-if="hasSelection" class="ui-table__col ui-table__col--selection" />
|
|
9
|
+
<col v-for="col in columns" :key="colKey(col)" :style="colStyle(col)" />
|
|
10
|
+
</colgroup>
|
|
11
|
+
<thead class="ui-table__head">
|
|
12
|
+
<tr
|
|
13
|
+
:class="['ui-table__row', 'ui-table__row--head', scrollbarWidth > 0 && 'ui-table__row--has-scrollbar']"
|
|
14
|
+
:style="{ height: toCssSize(headerHeight) }"
|
|
15
|
+
>
|
|
16
|
+
<th
|
|
17
|
+
v-if="hasSelection"
|
|
18
|
+
class="ui-table__cell ui-table__th ui-table__cell--selection"
|
|
19
|
+
:style="headCellStyle(0)"
|
|
20
|
+
>
|
|
21
|
+
<WkCheckbox :checked="allSelected" :disabled="!rows.length" @change="onToggleAll" />
|
|
22
|
+
</th>
|
|
23
|
+
<th
|
|
24
|
+
v-for="(col, i) in columns"
|
|
25
|
+
:key="colKey(col)"
|
|
26
|
+
:class="[
|
|
27
|
+
'ui-table__cell',
|
|
28
|
+
'ui-table__th',
|
|
29
|
+
`ui-table__cell--${alignOf(col)}`,
|
|
30
|
+
isSortable(col) && 'ui-table__th--sortable'
|
|
31
|
+
]"
|
|
32
|
+
:style="headCellStyle(hasSelection ? i + 1 : i, col)"
|
|
33
|
+
:tabindex="isSortable(col) ? 0 : undefined"
|
|
34
|
+
:aria-sort="ariaSort(col)"
|
|
35
|
+
@click="onHeaderClick(col)"
|
|
36
|
+
@keydown.enter.prevent="onHeaderClick(col)"
|
|
37
|
+
@keydown.space.prevent="onHeaderClick(col)"
|
|
38
|
+
>
|
|
39
|
+
<span class="ui-table__th-inner">
|
|
40
|
+
<slot name="headerCell" :column="col">{{ col.title }}</slot>
|
|
41
|
+
<span
|
|
42
|
+
v-if="isSortable(col)"
|
|
43
|
+
:class="['ui-table__sort', sortStateOf(col) ? 'ui-table__sort--active' : 'ui-table__sort--inactive']"
|
|
44
|
+
aria-hidden="true"
|
|
45
|
+
>
|
|
46
|
+
<WkiArrowUp v-if="sortStateOf(col) === 'ascend'" :size="16" />
|
|
47
|
+
<WkiArrowDown v-else-if="sortStateOf(col) === 'descend'" :size="16" />
|
|
48
|
+
<WkiArrowDownUp v-else :size="16" />
|
|
49
|
+
</span>
|
|
50
|
+
</span>
|
|
51
|
+
</th>
|
|
52
|
+
<th
|
|
53
|
+
v-if="scrollbarWidth > 0"
|
|
54
|
+
class="ui-table__th--scrollbar"
|
|
55
|
+
:style="{ width: scrollbarWidth + 'px' }"
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
/>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
<tbody class="ui-table__body" :style="bodyStyle">
|
|
61
|
+
<tr v-if="!rows.length" class="ui-table__row ui-table__row--empty">
|
|
62
|
+
<td class="ui-table__cell ui-table__empty-cell" :colspan="totalColumns">
|
|
63
|
+
<slot name="emptyText">
|
|
64
|
+
<WkEmpty :title="emptyText" />
|
|
65
|
+
</slot>
|
|
66
|
+
</td>
|
|
67
|
+
</tr>
|
|
68
|
+
<tr
|
|
69
|
+
v-for="(record, index) in rows"
|
|
70
|
+
v-else
|
|
71
|
+
:key="getRowKey(record, index)"
|
|
72
|
+
:class="['ui-table__row', 'ui-table__row--body', isSelected(record, index) && 'ui-table__row--selected']"
|
|
73
|
+
:style="{ height: toCssSize(rowHeight) }"
|
|
74
|
+
@click="onRowClick(record, index, $event)"
|
|
75
|
+
>
|
|
76
|
+
<td v-if="hasSelection" class="ui-table__cell ui-table__td ui-table__cell--selection">
|
|
77
|
+
<WkCheckbox :checked="isSelected(record, index)" @change="checked => onToggleRow(record, index, checked)" />
|
|
78
|
+
</td>
|
|
79
|
+
<td
|
|
80
|
+
v-for="col in columns"
|
|
81
|
+
:key="colKey(col)"
|
|
82
|
+
:class="[
|
|
83
|
+
'ui-table__cell',
|
|
84
|
+
'ui-table__td',
|
|
85
|
+
`ui-table__cell--${alignOf(col)}`,
|
|
86
|
+
col.ellipsis && 'ui-table__cell--ellipsis'
|
|
87
|
+
]"
|
|
88
|
+
:style="colStyle(col)"
|
|
89
|
+
>
|
|
90
|
+
<slot name="bodyCell" :column="col" :record="record" :text="cellText(col, record)" :index="index">{{
|
|
91
|
+
cellText(col, record)
|
|
92
|
+
}}</slot>
|
|
93
|
+
</td>
|
|
94
|
+
</tr>
|
|
95
|
+
</tbody>
|
|
96
|
+
</table>
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
<script>
|
|
101
|
+
import WkCheckbox from '../checkbox/Checkbox.vue'
|
|
102
|
+
import WkEmpty from '../empty/Empty.vue'
|
|
103
|
+
import WkiArrowUp from '../../icons/ArrowUp.vue'
|
|
104
|
+
import WkiArrowDown from '../../icons/ArrowDown.vue'
|
|
105
|
+
import WkiArrowDownUp from '../../icons/ArrowDownUp.vue'
|
|
106
|
+
import { toCssSize } from '../../utils/common'
|
|
107
|
+
|
|
108
|
+
function defaultCompare(a, b) {
|
|
109
|
+
if (a == null && b == null) return 0
|
|
110
|
+
if (a == null) return -1
|
|
111
|
+
if (b == null) return 1
|
|
112
|
+
if (typeof a === 'number' && typeof b === 'number') return a - b
|
|
113
|
+
return String(a).localeCompare(String(b))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default {
|
|
117
|
+
name: 'Table',
|
|
118
|
+
components: { WkCheckbox, WkEmpty, WkiArrowUp, WkiArrowDown, WkiArrowDownUp },
|
|
119
|
+
props: {
|
|
120
|
+
// Column descriptors: { title, dataIndex, key?, width?, align?, sorter?, ellipsis? }
|
|
121
|
+
columns: { type: Array, default: () => [] },
|
|
122
|
+
// Row records. Each record should expose a stable key (see rowKey).
|
|
123
|
+
dataSource: { type: Array, default: () => [] },
|
|
124
|
+
// How to derive a row's key: a record field name, or a function (record) => key.
|
|
125
|
+
rowKey: { type: [String, Function], default: 'key' },
|
|
126
|
+
// Outer border + vertical column dividers.
|
|
127
|
+
bordered: { type: Boolean, default: false },
|
|
128
|
+
// Render a leading checkbox column for row selection.
|
|
129
|
+
rowSelection: { type: Boolean, default: false },
|
|
130
|
+
// Controlled selection — array of selected row keys.
|
|
131
|
+
selectedRowKeys: { type: Array, default: () => [] },
|
|
132
|
+
// Placeholder shown when dataSource is empty.
|
|
133
|
+
emptyText: { type: String, default: 'No data' },
|
|
134
|
+
// Fixed scroll viewport: { x, y } as px (number) or any CSS size (string).
|
|
135
|
+
// x sets the table min-width (horizontal scroll); y caps the body height (vertical scroll + sticky header).
|
|
136
|
+
scroll: { type: Object, default: null },
|
|
137
|
+
// Fixed overall height of the table viewport (px number or CSS size). Enables vertical scroll + sticky header.
|
|
138
|
+
height: { type: [Number, String], default: null },
|
|
139
|
+
rowHeight: { type: [Number, String], default: 39 },
|
|
140
|
+
headerHeight: { type: [Number, String], default: 39 }
|
|
141
|
+
},
|
|
142
|
+
emits: ['change', 'sort-change', 'update:selectedRowKeys', 'selection-change', 'row-click'],
|
|
143
|
+
data() {
|
|
144
|
+
return {
|
|
145
|
+
sortField: null,
|
|
146
|
+
sortOrder: null,
|
|
147
|
+
internalSelected: this.selectedRowKeys.slice(),
|
|
148
|
+
scrollbarWidth: 0,
|
|
149
|
+
colWidths: [],
|
|
150
|
+
toCssSize
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
computed: {
|
|
154
|
+
hasSelection() {
|
|
155
|
+
return !!this.rowSelection
|
|
156
|
+
},
|
|
157
|
+
totalColumns() {
|
|
158
|
+
return this.columns.length + (this.hasSelection ? 1 : 0)
|
|
159
|
+
},
|
|
160
|
+
rows() {
|
|
161
|
+
const data = this.dataSource.slice()
|
|
162
|
+
if (!this.sortField || !this.sortOrder) return data
|
|
163
|
+
const col = this.columns.find(c => this.fieldOf(c) === this.sortField)
|
|
164
|
+
if (!col || !col.sorter) return data
|
|
165
|
+
const cmp =
|
|
166
|
+
typeof col.sorter === 'function' ? col.sorter : (a, b) => defaultCompare(a[this.sortField], b[this.sortField])
|
|
167
|
+
data.sort(cmp)
|
|
168
|
+
if (this.sortOrder === 'descend') data.reverse()
|
|
169
|
+
return data
|
|
170
|
+
},
|
|
171
|
+
allSelected() {
|
|
172
|
+
if (!this.rows.length) return false
|
|
173
|
+
return this.rows.every((record, index) => this.internalSelected.includes(this.getRowKey(record, index)))
|
|
174
|
+
},
|
|
175
|
+
hasVerticalScroll() {
|
|
176
|
+
return this.height != null || !!(this.scroll && this.scroll.y != null)
|
|
177
|
+
},
|
|
178
|
+
containerStyle() {
|
|
179
|
+
const scroll = this.scroll || {}
|
|
180
|
+
return scroll.x != null ? { overflowX: 'auto' } : {}
|
|
181
|
+
},
|
|
182
|
+
bodyStyle() {
|
|
183
|
+
const scroll = this.scroll || {}
|
|
184
|
+
if (this.height != null) return { height: toCssSize(this.height) }
|
|
185
|
+
if (scroll.y != null) return { maxHeight: toCssSize(scroll.y) }
|
|
186
|
+
return {}
|
|
187
|
+
},
|
|
188
|
+
tableStyle() {
|
|
189
|
+
const scroll = this.scroll || {}
|
|
190
|
+
return scroll.x != null ? { minWidth: toCssSize(scroll.x) } : {}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
watch: {
|
|
194
|
+
selectedRowKeys(next) {
|
|
195
|
+
this.internalSelected = (next || []).slice()
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
mounted() {
|
|
199
|
+
this.$nextTick(this.syncScrollbarGutter)
|
|
200
|
+
},
|
|
201
|
+
updated() {
|
|
202
|
+
this.$nextTick(this.syncScrollbarGutter)
|
|
203
|
+
},
|
|
204
|
+
methods: {
|
|
205
|
+
syncScrollbarGutter() {
|
|
206
|
+
if (!this.$el) return
|
|
207
|
+
const body = this.$el.querySelector('.ui-table__body')
|
|
208
|
+
this.scrollbarWidth = body && this.hasVerticalScroll ? body.offsetWidth - body.clientWidth : 0
|
|
209
|
+
|
|
210
|
+
if (this.hasVerticalScroll) {
|
|
211
|
+
const firstRow = this.$el.querySelector('.ui-table__row--body')
|
|
212
|
+
if (firstRow) {
|
|
213
|
+
const cells = Array.from(firstRow.children)
|
|
214
|
+
const widths = cells.map(c => c.getBoundingClientRect().width)
|
|
215
|
+
const changed =
|
|
216
|
+
widths.length !== this.colWidths.length ||
|
|
217
|
+
widths.some((w, i) => Math.abs(w - (this.colWidths[i] || 0)) > 0.1)
|
|
218
|
+
if (changed) {
|
|
219
|
+
this.colWidths = widths
|
|
220
|
+
}
|
|
221
|
+
} else if (this.colWidths.length) {
|
|
222
|
+
this.colWidths = []
|
|
223
|
+
}
|
|
224
|
+
} else if (this.colWidths.length) {
|
|
225
|
+
this.colWidths = []
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
headCellStyle(index, col = null) {
|
|
229
|
+
if (this.hasVerticalScroll && this.colWidths[index] !== undefined) {
|
|
230
|
+
return { width: `${this.colWidths[index]}px` }
|
|
231
|
+
}
|
|
232
|
+
return col ? this.colStyle(col) : {}
|
|
233
|
+
},
|
|
234
|
+
fieldOf(col) {
|
|
235
|
+
return col.dataIndex != null ? col.dataIndex : col.key
|
|
236
|
+
},
|
|
237
|
+
colKey(col) {
|
|
238
|
+
return col.key != null ? col.key : col.dataIndex
|
|
239
|
+
},
|
|
240
|
+
colStyle(col) {
|
|
241
|
+
if (col.width == null) return {}
|
|
242
|
+
return { width: typeof col.width === 'number' ? `${col.width}px` : col.width }
|
|
243
|
+
},
|
|
244
|
+
alignOf(col) {
|
|
245
|
+
return ['left', 'right', 'center'].includes(col.align) ? col.align : 'left'
|
|
246
|
+
},
|
|
247
|
+
cellText(col, record) {
|
|
248
|
+
const field = this.fieldOf(col)
|
|
249
|
+
return field != null ? record[field] : ''
|
|
250
|
+
},
|
|
251
|
+
isSortable(col) {
|
|
252
|
+
return !!col.sorter
|
|
253
|
+
},
|
|
254
|
+
sortStateOf(col) {
|
|
255
|
+
return this.sortField === this.fieldOf(col) ? this.sortOrder : null
|
|
256
|
+
},
|
|
257
|
+
ariaSort(col) {
|
|
258
|
+
const state = this.sortStateOf(col)
|
|
259
|
+
if (state === 'ascend') return 'ascending'
|
|
260
|
+
if (state === 'descend') return 'descending'
|
|
261
|
+
return undefined
|
|
262
|
+
},
|
|
263
|
+
onHeaderClick(col) {
|
|
264
|
+
if (!this.isSortable(col)) return
|
|
265
|
+
const field = this.fieldOf(col)
|
|
266
|
+
let order
|
|
267
|
+
if (this.sortField !== field) {
|
|
268
|
+
order = 'ascend'
|
|
269
|
+
} else {
|
|
270
|
+
order = this.sortOrder === 'ascend' ? 'descend' : this.sortOrder === 'descend' ? null : 'ascend'
|
|
271
|
+
}
|
|
272
|
+
this.sortField = order ? field : null
|
|
273
|
+
this.sortOrder = order
|
|
274
|
+
const payload = { field: this.sortField, order }
|
|
275
|
+
this.$emit('sort-change', payload)
|
|
276
|
+
this.$emit('change', { sorter: payload })
|
|
277
|
+
},
|
|
278
|
+
getRowKey(record, index) {
|
|
279
|
+
if (typeof this.rowKey === 'function') return this.rowKey(record)
|
|
280
|
+
const key = record[this.rowKey]
|
|
281
|
+
return key != null ? key : index
|
|
282
|
+
},
|
|
283
|
+
isSelected(record, index) {
|
|
284
|
+
return this.internalSelected.includes(this.getRowKey(record, index))
|
|
285
|
+
},
|
|
286
|
+
emitSelection() {
|
|
287
|
+
const keys = this.internalSelected.slice()
|
|
288
|
+
const selectedRows = this.dataSource.filter((record, index) => keys.includes(this.getRowKey(record, index)))
|
|
289
|
+
this.$emit('update:selectedRowKeys', keys)
|
|
290
|
+
this.$emit('selection-change', keys, selectedRows)
|
|
291
|
+
},
|
|
292
|
+
onToggleRow(record, index, checked) {
|
|
293
|
+
const key = this.getRowKey(record, index)
|
|
294
|
+
const set = this.internalSelected.filter(k => k !== key)
|
|
295
|
+
if (checked) set.push(key)
|
|
296
|
+
this.internalSelected = set
|
|
297
|
+
this.emitSelection()
|
|
298
|
+
},
|
|
299
|
+
onToggleAll(checked) {
|
|
300
|
+
this.internalSelected = checked ? this.rows.map((record, index) => this.getRowKey(record, index)) : []
|
|
301
|
+
this.emitSelection()
|
|
302
|
+
},
|
|
303
|
+
onRowClick(record, index, event) {
|
|
304
|
+
this.$emit('row-click', record, index, event)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
</script>
|
|
309
|
+
|
|
310
|
+
<style src="./table.css" scoped></style>
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
.ui-table {
|
|
2
|
+
width: 100%;
|
|
3
|
+
font-family: var(--font-family-body);
|
|
4
|
+
color: var(--primary-fg);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.ui-table__table {
|
|
8
|
+
width: 100%;
|
|
9
|
+
border-collapse: collapse;
|
|
10
|
+
border-spacing: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ui-table__col--selection {
|
|
14
|
+
width: 1%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ---------- Cells ---------- */
|
|
18
|
+
.ui-table__cell {
|
|
19
|
+
padding: var(--spacing-xs);
|
|
20
|
+
font-size: var(--paragraph-small-font-size);
|
|
21
|
+
line-height: var(--paragraph-small-line-height);
|
|
22
|
+
letter-spacing: var(--paragraph-small-letter-spacing);
|
|
23
|
+
text-align: left;
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
border-bottom: 1px solid var(--border-primary);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ui-table__cell--right {
|
|
29
|
+
text-align: right;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ui-table__cell--center {
|
|
33
|
+
text-align: center;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ui-table__cell--ellipsis {
|
|
37
|
+
max-width: 0;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.ui-table__cell--selection {
|
|
44
|
+
width: 1%;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
text-align: center;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* ---------- Header ---------- */
|
|
50
|
+
.ui-table__th {
|
|
51
|
+
background: var(--secondary-bg);
|
|
52
|
+
font-weight: var(--paragraph-medium-font-weight);
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.ui-table__th-inner {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
gap: var(--spacing-xs);
|
|
60
|
+
max-width: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ui-table__th--sortable {
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
user-select: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ui-table__th--sortable:hover {
|
|
69
|
+
background: var(--accent-2);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ui-table__th--sortable:focus-visible {
|
|
73
|
+
outline: none;
|
|
74
|
+
box-shadow: inset 0 0 0 2px var(--focus-ring);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ui-table__sort {
|
|
78
|
+
display: inline-flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
flex-shrink: 0;
|
|
82
|
+
width: 16px;
|
|
83
|
+
height: 16px;
|
|
84
|
+
color: var(--muted-fg);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ui-table__sort--inactive {
|
|
88
|
+
opacity: 0.5;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ui-table__sort--active {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
color: var(--primary-fg);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* ---------- Body ---------- */
|
|
97
|
+
.ui-table__td {
|
|
98
|
+
background: var(--primary-bg);
|
|
99
|
+
font-weight: var(--paragraph-font-weight);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.ui-table__row--body {
|
|
103
|
+
transition: background-color 0.12s ease;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ui-table__row--body:hover .ui-table__td {
|
|
107
|
+
background: var(--accent-bg);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.ui-table__row--selected .ui-table__td {
|
|
111
|
+
background: var(--secondary-bg);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* ---------- Empty ---------- */
|
|
115
|
+
.ui-table__empty-cell {
|
|
116
|
+
padding: var(--spacing-3xl) var(--spacing-xs);
|
|
117
|
+
text-align: center;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* ---------- Bordered ---------- */
|
|
121
|
+
.ui-table--bordered {
|
|
122
|
+
border: 1px solid var(--border-primary);
|
|
123
|
+
border-radius: var(--rounded-xl);
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.ui-table--bordered .ui-table__cell {
|
|
128
|
+
border-right: 1px solid var(--border-primary);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ui-table--bordered .ui-table__cell:last-child {
|
|
132
|
+
border-right: none;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* With a scrollbar spacer present, the last real header column is second-to-last. */
|
|
136
|
+
.ui-table--bordered .ui-table__row--has-scrollbar .ui-table__cell:nth-last-child(2) {
|
|
137
|
+
border-right: none;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.ui-table--bordered .ui-table__row--body:last-child .ui-table__td {
|
|
141
|
+
border-bottom: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* ---------- Scroll viewport (fixed header, scrollable body) ---------- */
|
|
145
|
+
.ui-table--scroll-y .ui-table__table,
|
|
146
|
+
.ui-table--scroll-y .ui-table__head,
|
|
147
|
+
.ui-table--scroll-y .ui-table__body {
|
|
148
|
+
display: block;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* Switch to separate borders in scroll mode so each cell owns its border width precisely.
|
|
153
|
+
* border-collapse: collapse splits shared borders by 0.5px, which causes the scrollbar
|
|
154
|
+
* spacer <th> to be off by 1px. separate + border-spacing: 0 is visually identical
|
|
155
|
+
* (cells only have border-bottom and border-right, never border-top/left) but width-exact.
|
|
156
|
+
*/
|
|
157
|
+
.ui-table--scroll-y .ui-table__table {
|
|
158
|
+
border-collapse: separate;
|
|
159
|
+
border-spacing: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Each row becomes its own fixed-layout table so header and body columns line up. */
|
|
163
|
+
.ui-table--scroll-y .ui-table__row {
|
|
164
|
+
display: table;
|
|
165
|
+
width: 100%;
|
|
166
|
+
table-layout: fixed;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* The body is the actual scroll area; the header above it stays put. */
|
|
170
|
+
.ui-table--scroll-y .ui-table__body {
|
|
171
|
+
overflow-y: auto;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.ui-table__body::-webkit-scrollbar {
|
|
175
|
+
width: 6px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.ui-table__body::-webkit-scrollbar-thumb {
|
|
179
|
+
background: var(--border-primary);
|
|
180
|
+
border-radius: 3px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.ui-table--scroll-y .ui-table__head {
|
|
184
|
+
overflow: hidden;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.ui-table__th--scrollbar {
|
|
188
|
+
padding: 0;
|
|
189
|
+
border: none;
|
|
190
|
+
background: var(--secondary-bg);
|
|
191
|
+
border-bottom: 1px solid var(--border-primary);
|
|
192
|
+
box-sizing: border-box;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.ui-table--scroll-y .ui-table__cell--selection {
|
|
196
|
+
width: 44px;
|
|
197
|
+
}
|
|
@@ -75,8 +75,7 @@ export default {
|
|
|
75
75
|
},
|
|
76
76
|
color: {
|
|
77
77
|
type: String,
|
|
78
|
-
default: ''
|
|
79
|
-
validator: v => COLORS.indexOf(v) !== -1
|
|
78
|
+
default: ''
|
|
80
79
|
},
|
|
81
80
|
align: {
|
|
82
81
|
type: String,
|
|
@@ -95,7 +94,10 @@ export default {
|
|
|
95
94
|
},
|
|
96
95
|
rootStyle() {
|
|
97
96
|
if (!this.color) return null
|
|
98
|
-
|
|
97
|
+
if (COLORS.includes(this.color)) {
|
|
98
|
+
return { '--ui-typography-color': 'var(--' + this.color + ')' }
|
|
99
|
+
}
|
|
100
|
+
return { '--ui-typography-color': this.color }
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
}
|
|
@@ -28,6 +28,11 @@ export default {
|
|
|
28
28
|
document.contains &&
|
|
29
29
|
document.contains(t)
|
|
30
30
|
) {
|
|
31
|
+
// Skip restore if the user has already focused another element (e.g. clicked a different input
|
|
32
|
+
// while the close animation was running). Only restore when focus fell back to body/html,
|
|
33
|
+
// which happens when the floating panel itself held focus and then disappeared.
|
|
34
|
+
const active = document.activeElement
|
|
35
|
+
if (active && active !== document.body && active !== document.documentElement) return
|
|
31
36
|
t.focus()
|
|
32
37
|
}
|
|
33
38
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<BaseIcon v-bind="$attrs" v-on="listeners">
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
4
|
+
<path
|
|
5
|
+
fill-rule="evenodd"
|
|
6
|
+
clip-rule="evenodd"
|
|
7
|
+
d="M13.4203 4.82946C18.1574 4.82946 22.0111 8.68328 22.0112 13.4203C22.0112 18.1574 18.1574 22.0112 13.4203 22.0112C8.68326 22.0111 4.82946 18.1574 4.82946 13.4203C4.82951 8.68331 8.6833 4.82951 13.4203 4.82946ZM15.6194 14.8406C15.6194 15.2707 15.2707 15.6194 14.8406 15.6194H6.74129C7.66689 18.4238 10.3101 20.4535 13.4203 20.4536C17.2986 20.4536 20.4536 17.2986 20.4536 13.4203C20.4535 10.3102 18.4238 7.6669 15.6194 6.74129V14.8406ZM6.5558 11.9183C6.44868 12.4033 6.38705 12.9044 6.38704 13.4203C6.38704 13.6365 6.39852 13.8504 6.41785 14.0618H8.69932L6.5558 11.9183ZM7.93057 9.03147C7.62082 9.41901 7.35486 9.84227 7.13102 10.2911L10.9018 14.0618H12.9609L7.93057 9.03147ZM10.2911 7.13103C9.84223 7.35488 9.41836 7.62013 9.0308 7.92991L14.0618 12.9609V10.9018L10.2911 7.13103ZM13.4203 6.38705C12.9044 6.38706 12.4033 6.44869 11.9183 6.5558L14.0618 8.69933V6.41719C13.8504 6.39786 13.6365 6.38705 13.4203 6.38705Z"
|
|
8
|
+
fill="currentColor"
|
|
9
|
+
/>
|
|
10
|
+
<path
|
|
11
|
+
d="M2.76763 12.6415C3.19754 12.6417 3.54637 12.9904 3.54642 13.4203V14.0618H4.28705L4.2924 14.1254C4.32931 14.607 4.40392 15.0769 4.51271 15.535L4.5328 15.6194H2.76763C2.33755 15.6194 1.98883 15.2707 1.98883 14.8406V13.4203C1.98888 12.9903 2.33758 12.6415 2.76763 12.6415Z"
|
|
12
|
+
fill="currentColor"
|
|
13
|
+
/>
|
|
14
|
+
<path
|
|
15
|
+
d="M2.76763 9.0904C3.19751 9.09056 3.54632 9.4393 3.54642 9.8692V11.2895C3.54642 11.7195 3.19757 12.0681 2.76763 12.0683C2.33755 12.0683 1.98883 11.7196 1.98883 11.2895V9.8692C1.98893 9.4392 2.33761 9.0904 2.76763 9.0904Z"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
d="M2.76763 5.53928C3.19748 5.53944 3.54627 5.88823 3.54642 6.31808V7.73906C3.54626 8.16891 3.19748 8.5177 2.76763 8.51786C2.33764 8.51786 1.98899 8.16901 1.98883 7.73906V6.31808C1.98899 5.88813 2.33764 5.53928 2.76763 5.53928Z"
|
|
20
|
+
fill="currentColor"
|
|
21
|
+
/>
|
|
22
|
+
<path
|
|
23
|
+
d="M4.18794 1.98884C4.61793 1.98894 4.96673 2.33762 4.96673 2.76763C4.96658 3.19752 4.61783 3.54632 4.18794 3.54643H3.54642V4.18795C3.54632 4.61784 3.19751 4.96659 2.76763 4.96674C2.33761 4.96674 1.98893 4.61794 1.98883 4.18795V2.76763C1.98883 2.33755 2.33755 1.98884 2.76763 1.98884H4.18794Z"
|
|
24
|
+
fill="currentColor"
|
|
25
|
+
/>
|
|
26
|
+
<path
|
|
27
|
+
d="M14.8406 1.98884C15.2707 1.98884 15.6194 2.33755 15.6194 2.76763V4.53281L15.535 4.51272C15.0769 4.40392 14.607 4.32932 14.1254 4.29241L14.0618 4.28705V3.54643H13.4203C12.9904 3.54638 12.6417 3.19755 12.6415 2.76763C12.6415 2.33759 12.9903 1.98889 13.4203 1.98884H14.8406Z"
|
|
28
|
+
fill="currentColor"
|
|
29
|
+
/>
|
|
30
|
+
<path
|
|
31
|
+
d="M7.73905 1.98884C8.169 1.989 8.51785 2.33765 8.51785 2.76763C8.51769 3.19748 8.1689 3.54627 7.73905 3.54643H6.31807C5.88822 3.54628 5.53943 3.19749 5.53928 2.76763C5.53928 2.33765 5.88812 1.98899 6.31807 1.98884H7.73905Z"
|
|
32
|
+
fill="currentColor"
|
|
33
|
+
/>
|
|
34
|
+
<path
|
|
35
|
+
d="M11.2895 1.98884C11.7196 1.98884 12.0683 2.33755 12.0683 2.76763C12.0681 3.19758 11.7195 3.54643 11.2895 3.54643H9.86919C9.4393 3.54632 9.09055 3.19751 9.09039 2.76763C9.09039 2.33762 9.4392 1.98895 9.86919 1.98884H11.2895Z"
|
|
36
|
+
fill="currentColor"
|
|
37
|
+
/>
|
|
38
|
+
</svg>
|
|
39
|
+
</BaseIcon>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
import BaseIcon from './BaseIcon.vue'
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
name: 'GenerateImage',
|
|
47
|
+
components: { BaseIcon },
|
|
48
|
+
inheritAttrs: false,
|
|
49
|
+
emits: [],
|
|
50
|
+
computed: {
|
|
51
|
+
listeners() {
|
|
52
|
+
return this.$listeners || {}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
package/src/icons/index.js
CHANGED
|
@@ -1736,4 +1736,5 @@ export { default as WkiLayersDown } from './LayersDown.vue'
|
|
|
1736
1736
|
export { default as WkiLayersUpToTop } from './LayersUpToTop.vue'
|
|
1737
1737
|
export { default as WkiLayersDownToBottom } from './LayersDownToBottom.vue'
|
|
1738
1738
|
export { default as WkiGeneratePrompt } from './GeneratePrompt.vue'
|
|
1739
|
+
export { default as WkiClippingMask } from './ClippingMask.vue'
|
|
1739
1740
|
// --- AUTO-GENERATED LUCIDE EXPORTS END ---
|
package/src/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export { default as WkSlider } from './components/slider/Slider.vue'
|
|
|
31
31
|
export { default as WkSpinner } from './components/spinner/Spinner.vue'
|
|
32
32
|
export { default as WkSwitch } from './components/switch/Switch.vue'
|
|
33
33
|
export { default as WkSwitchGroup } from './components/switch-group/SwitchGroup.vue'
|
|
34
|
+
export { default as WkTable } from './components/table/Table.vue'
|
|
34
35
|
export { default as WkTabs } from './components/tabs/Tabs.vue'
|
|
35
36
|
export { default as WkTag } from './components/tag/Tag.vue'
|
|
36
37
|
export { default as WkToggle } from './components/toggle/Toggle.vue'
|