webcake-ui-kit 1.2.13 → 1.2.14
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 +1 -2
- package/src/components/date-picker/date-picker.css +3 -1
- package/src/components/dropdown/Dropdown.vue +2 -2
- package/src/components/select-option/SelectOption.vue +2 -1
- package/src/components/select-option/select_option.css +0 -62
- package/src/components/select-option/select_option_sub.css +61 -0
- package/src/components/{table-v2 → table}/ColumnDragHandle.vue +2 -2
- package/src/components/table/Table.vue +250 -772
- package/src/components/{table-v2 → table}/TableColGroup.vue +2 -2
- package/src/components/{table-v2 → table}/TableEmpty.vue +2 -2
- package/src/components/{table-v2 → table}/TableLoading.vue +3 -3
- package/src/components/{table-v2 → table}/TableWrapper.vue +14 -9
- package/src/components/{table-v2 → table}/body/DragPreview.vue +4 -18
- package/src/components/{table-v2 → table}/body/TableBody.vue +6 -6
- package/src/components/{table-v2 → table}/body/TableCell.vue +8 -8
- package/src/components/{table-v2 → table}/body/TableRow.vue +4 -4
- package/src/components/{table-v2 → table}/header/TableHeader.vue +2 -2
- package/src/components/{table-v2 → table}/header/TableHeaderCell.vue +9 -9
- package/src/components/{table-v2 → table}/header/TableHeaderRow.vue +3 -3
- package/src/components/{table-v2 → table}/style/table-loading.css +3 -3
- package/src/components/{table-v2 → table}/style/table-wrapper.css +67 -51
- package/src/components/{table-v2 → table}/style/table.css +1 -1
- package/src/components/textarea/Textarea.vue +1 -1
- package/src/index.js +0 -1
- package/src/components/table/table.css +0 -396
- package/src/components/table-v2/Table.vue +0 -305
- /package/src/components/{table-v2 → table}/TableResizeObserver.vue +0 -0
- /package/src/components/{table-v2 → table}/body/MeasureCell.vue +0 -0
- /package/src/components/{table-v2 → table}/composables/useColumns.js +0 -0
- /package/src/components/{table-v2 → table}/composables/useSorter.js +0 -0
- /package/src/components/{table-v2 → table}/composables/useSticky.js +0 -0
- /package/src/components/{table-v2 → table}/constants.js +0 -0
- /package/src/components/{table-v2 → table}/context/createTableContext.js +0 -0
- /package/src/components/{table-v2 → table}/style/table-body.css +0 -0
- /package/src/components/{table-v2 → table}/style/table-header.css +0 -0
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
.ui-table {
|
|
2
|
-
width: 100%;
|
|
3
|
-
font-family: var(--font-family-body);
|
|
4
|
-
color: var(--primary-fg);
|
|
5
|
-
border: 1px solid var(--border-primary);
|
|
6
|
-
border-radius: var(--rounded-2xl);
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.ui-table__table {
|
|
11
|
-
width: 100%;
|
|
12
|
-
border-collapse: collapse;
|
|
13
|
-
border-spacing: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* drag col is always 36px — the header cell is empty so it has no content to size it */
|
|
17
|
-
.ui-table__col--drag {
|
|
18
|
-
width: 1%;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.ui-table__col--selection {
|
|
22
|
-
width: 1%;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/* ---------- Cells ---------- */
|
|
26
|
-
.ui-table__cell {
|
|
27
|
-
padding: var(--spacing-xs);
|
|
28
|
-
font-size: var(--paragraph-small-font-size);
|
|
29
|
-
line-height: var(--paragraph-small-line-height);
|
|
30
|
-
letter-spacing: var(--paragraph-small-letter-spacing);
|
|
31
|
-
text-align: left;
|
|
32
|
-
vertical-align: middle;
|
|
33
|
-
border-bottom: 1px solid var(--border-primary);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.ui-table__cell--right {
|
|
37
|
-
text-align: right;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.ui-table__cell--center {
|
|
41
|
-
text-align: center;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.ui-table__cell--ellipsis {
|
|
45
|
-
max-width: 0;
|
|
46
|
-
overflow: hidden;
|
|
47
|
-
white-space: nowrap;
|
|
48
|
-
text-overflow: ellipsis;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.ui-table__cell--drag {
|
|
52
|
-
width: 1%;
|
|
53
|
-
white-space: nowrap;
|
|
54
|
-
text-align: center;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.ui-table__td.ui-table__cell--drag {
|
|
58
|
-
cursor: grab;
|
|
59
|
-
color: var(--muted-fg);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.ui-table__td.ui-table__cell--drag:active {
|
|
63
|
-
cursor: grabbing;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.ui-table__cell--selection {
|
|
67
|
-
width: 1%;
|
|
68
|
-
white-space: nowrap;
|
|
69
|
-
text-align: center;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.ui-table__cell--fixed-left,
|
|
73
|
-
.ui-table__cell--fixed-right {
|
|
74
|
-
position: sticky;
|
|
75
|
-
z-index: 1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@keyframes ui-table-sticky-shadow {
|
|
79
|
-
to {
|
|
80
|
-
opacity: 1;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@keyframes ui-table-sticky-shadow-right {
|
|
85
|
-
to {
|
|
86
|
-
opacity: 0;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.ui-table__cell--fixed-left-last::after {
|
|
91
|
-
content: '';
|
|
92
|
-
position: absolute;
|
|
93
|
-
top: 0;
|
|
94
|
-
right: -6px;
|
|
95
|
-
bottom: 0;
|
|
96
|
-
width: 6px;
|
|
97
|
-
box-shadow: inset var(--shadow-fixed-column-left);
|
|
98
|
-
pointer-events: none;
|
|
99
|
-
opacity: 0;
|
|
100
|
-
animation: ui-table-sticky-shadow linear both;
|
|
101
|
-
animation-timeline: scroll(nearest x);
|
|
102
|
-
animation-range: 0px 1px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.ui-table__cell--fixed-right-first::after {
|
|
106
|
-
content: '';
|
|
107
|
-
position: absolute;
|
|
108
|
-
top: 0;
|
|
109
|
-
left: -6px;
|
|
110
|
-
bottom: 0;
|
|
111
|
-
width: 6px;
|
|
112
|
-
box-shadow: inset var(--shadow-fixed-column-right);
|
|
113
|
-
pointer-events: none;
|
|
114
|
-
animation: ui-table-sticky-shadow-right linear both;
|
|
115
|
-
animation-timeline: scroll(nearest x);
|
|
116
|
-
animation-range: calc(100% - 2px) 100%;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* Sticky cells need an opaque background so content doesn't bleed through. */
|
|
120
|
-
.ui-table__th.ui-table__cell--fixed-left,
|
|
121
|
-
.ui-table__th.ui-table__cell--fixed-right {
|
|
122
|
-
background: var(--secondary-bg);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.ui-table__td.ui-table__cell--fixed-left,
|
|
126
|
-
.ui-table__td.ui-table__cell--fixed-right {
|
|
127
|
-
background: var(--primary-bg);
|
|
128
|
-
transition: background-color 0.12s ease;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.ui-table__row--body:hover .ui-table__td.ui-table__cell--fixed-left,
|
|
132
|
-
.ui-table__row--body:hover .ui-table__td.ui-table__cell--fixed-right {
|
|
133
|
-
background: var(--accent-bg);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.ui-table__row--selected .ui-table__td.ui-table__cell--fixed-left,
|
|
137
|
-
.ui-table__row--selected .ui-table__td.ui-table__cell--fixed-right {
|
|
138
|
-
background: var(--secondary-bg);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/* ---------- Header ---------- */
|
|
142
|
-
.ui-table__th {
|
|
143
|
-
background: var(--secondary-bg);
|
|
144
|
-
font-weight: var(--paragraph-medium-font-weight);
|
|
145
|
-
white-space: nowrap;
|
|
146
|
-
padding: 0;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.ui-table__th-inner-wrap {
|
|
150
|
-
padding: var(--spacing-xs);
|
|
151
|
-
position: relative;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.ui-table__resize-handle {
|
|
155
|
-
position: absolute;
|
|
156
|
-
top: 50%;
|
|
157
|
-
right: -4px;
|
|
158
|
-
width: 8px;
|
|
159
|
-
height: 50%;
|
|
160
|
-
transform: translateY(-50%);
|
|
161
|
-
cursor: col-resize;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.ui-table__resize-handle:hover {
|
|
165
|
-
height: 100%;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.ui-table__resize-handle--left {
|
|
169
|
-
right: auto;
|
|
170
|
-
left: -4px;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.ui-table__resize-handle::before {
|
|
174
|
-
content: '';
|
|
175
|
-
position: absolute;
|
|
176
|
-
top: 0;
|
|
177
|
-
bottom: 0;
|
|
178
|
-
left: 50%;
|
|
179
|
-
width: 1px;
|
|
180
|
-
transform: translateX(-50%);
|
|
181
|
-
background: var(--border-focus);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.ui-table__resize-handle:hover::before,
|
|
185
|
-
.ui-table__resize-handle.resizing::before {
|
|
186
|
-
width: 3px;
|
|
187
|
-
background: #3f8dff;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.ui-table__th-inner {
|
|
191
|
-
display: inline-flex;
|
|
192
|
-
align-items: center;
|
|
193
|
-
gap: var(--spacing-xs);
|
|
194
|
-
max-width: 100%;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.ui-table__th--sortable {
|
|
198
|
-
cursor: pointer;
|
|
199
|
-
user-select: none;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.ui-table__th--sortable:hover,
|
|
203
|
-
.ui-table__th:has(:is(.ui-table__resize-handle, .ui-table__resize-handle--left)):hover {
|
|
204
|
-
background: var(--accent-2);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
.ui-table__th--sortable:focus-visible {
|
|
208
|
-
outline: none;
|
|
209
|
-
box-shadow: inset 0 0 0 2px var(--focus-ring);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.ui-table__sort {
|
|
213
|
-
display: inline-flex;
|
|
214
|
-
align-items: center;
|
|
215
|
-
justify-content: center;
|
|
216
|
-
flex-shrink: 0;
|
|
217
|
-
width: 16px;
|
|
218
|
-
height: 16px;
|
|
219
|
-
color: var(--muted-fg);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.ui-table__sort--inactive {
|
|
223
|
-
opacity: 0.5;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.ui-table__sort--active {
|
|
227
|
-
opacity: 1;
|
|
228
|
-
color: var(--primary-fg);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/* ---------- Body ---------- */
|
|
232
|
-
.ui-table__td {
|
|
233
|
-
background: var(--primary-bg);
|
|
234
|
-
font-weight: var(--paragraph-font-weight);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.ui-table__row--body {
|
|
238
|
-
transition: background-color 0.12s ease;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.ui-table__row--dragging .ui-table__td {
|
|
242
|
-
opacity: 0.35;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.ui-table__row--drag-over .ui-table__td {
|
|
246
|
-
border-top: 2px solid var(--border-focus);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.ui-table__row--drag-preview .ui-table__td {
|
|
250
|
-
background: var(--accent-bg);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.ui-table__row--body:hover .ui-table__td {
|
|
254
|
-
background: var(--accent-bg);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.ui-table__row--selected .ui-table__td {
|
|
258
|
-
background: var(--secondary-bg);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/* ---------- Empty ---------- */
|
|
262
|
-
.ui-table__empty-cell {
|
|
263
|
-
padding: var(--spacing-3xl) var(--spacing-xs);
|
|
264
|
-
text-align: center;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/* ---------- Bordered ---------- */
|
|
268
|
-
.ui-table--bordered {
|
|
269
|
-
border: 1px solid var(--border-primary);
|
|
270
|
-
border-radius: var(--rounded-xl);
|
|
271
|
-
overflow: hidden;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.ui-table--bordered .ui-table__cell {
|
|
275
|
-
border-right: 1px solid var(--border-primary);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.ui-table--bordered .ui-table__cell:last-child {
|
|
279
|
-
border-right: none;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
@keyframes ui-table-sticky-border-hide {
|
|
283
|
-
to {
|
|
284
|
-
border-right-width: 0;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
.ui-table--bordered .ui-table__cell--fixed-left-last {
|
|
289
|
-
animation: ui-table-sticky-border-hide linear both;
|
|
290
|
-
animation-timeline: scroll(nearest x);
|
|
291
|
-
animation-range: 0px 1px;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/* With a scrollbar spacer present, the last real header column is second-to-last. */
|
|
295
|
-
.ui-table--bordered .ui-table__row--has-scrollbar .ui-table__cell:nth-last-child(2) {
|
|
296
|
-
border-right: none;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
.ui-table--bordered .ui-table__row--body:last-child .ui-table__td {
|
|
300
|
-
border-bottom: none;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/* ---------- Scroll viewport (fixed header, scrollable body) ---------- */
|
|
304
|
-
.ui-table--scroll-y .ui-table__table,
|
|
305
|
-
.ui-table--scroll-y .ui-table__head,
|
|
306
|
-
.ui-table--scroll-y .ui-table__body {
|
|
307
|
-
display: block;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/*
|
|
311
|
-
* Switch to separate borders in scroll mode so each cell owns its border width precisely.
|
|
312
|
-
* border-collapse: collapse splits shared borders by 0.5px, which causes the scrollbar
|
|
313
|
-
* spacer <th> to be off by 1px. separate + border-spacing: 0 is visually identical
|
|
314
|
-
* (cells only have border-bottom and border-right, never border-top/left) but width-exact.
|
|
315
|
-
*/
|
|
316
|
-
.ui-table--scroll-y .ui-table__table {
|
|
317
|
-
border-collapse: separate;
|
|
318
|
-
border-spacing: 0;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/* Each row becomes its own fixed-layout table so header and body columns line up. */
|
|
322
|
-
.ui-table--scroll-y .ui-table__row {
|
|
323
|
-
display: table;
|
|
324
|
-
width: 100%;
|
|
325
|
-
table-layout: fixed;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/* The body is the actual scroll area; the header above it stays put. */
|
|
329
|
-
.ui-table--scroll-y .ui-table__body {
|
|
330
|
-
overflow-y: auto;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.ui-table__body::-webkit-scrollbar {
|
|
334
|
-
width: 10px;
|
|
335
|
-
height: 10px;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.ui-table__body::-webkit-scrollbar-track:vertical {
|
|
339
|
-
border-left: 1px solid var(--border-primary);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
.ui-table__body::-webkit-scrollbar-track:horizontal {
|
|
343
|
-
border-top: 1px solid var(--border-primary);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.ui-table__body::-webkit-scrollbar-thumb {
|
|
347
|
-
background: var(--border-primary);
|
|
348
|
-
border-radius: 3px;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
.ui-table__body::-webkit-scrollbar-thumb:vertical {
|
|
352
|
-
border-left: 2px solid transparent;
|
|
353
|
-
border-right: 1px solid transparent;
|
|
354
|
-
background-clip: content-box;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
.ui-table__body::-webkit-scrollbar-thumb:horizontal {
|
|
358
|
-
border-top: 2px solid transparent;
|
|
359
|
-
border-bottom: 1px solid transparent;
|
|
360
|
-
background-clip: content-box;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
.ui-table--scroll-y .ui-table__head {
|
|
364
|
-
overflow: hidden;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
.ui-table__th--scrollbar {
|
|
368
|
-
padding: 0;
|
|
369
|
-
border: none;
|
|
370
|
-
background: var(--secondary-bg);
|
|
371
|
-
border-bottom: 1px solid var(--border-primary);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
.ui-table--scroll-y .ui-table__cell--selection,
|
|
375
|
-
.ui-table--scroll-y .ui-table__cell--drag {
|
|
376
|
-
width: 36px;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/* ---------- Virtual scroll spacers ---------- */
|
|
380
|
-
/*
|
|
381
|
-
* Spacer rows reserve the scroll height of the off-window rows. They must paint
|
|
382
|
-
* nothing (no border/padding/background) so the row-height math stays exact, and
|
|
383
|
-
* are display:block so their inline height is honored verbatim inside the
|
|
384
|
-
* block-level scrolling tbody (the real rows are display:table; table-layout:fixed).
|
|
385
|
-
*/
|
|
386
|
-
.ui-table__spacer {
|
|
387
|
-
display: block;
|
|
388
|
-
padding: 0;
|
|
389
|
-
border: none;
|
|
390
|
-
background: transparent;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
.ui-table__spacer-cell {
|
|
394
|
-
padding: 0;
|
|
395
|
-
border: none;
|
|
396
|
-
}
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="ui-table-v2">
|
|
3
|
-
<TableLoading>
|
|
4
|
-
<TableResizeObserver @resize="handleContainerResize">
|
|
5
|
-
<TableWrapper>
|
|
6
|
-
<template #bodyCell="slotData">
|
|
7
|
-
<slot name="bodyCell" v-bind="slotData"></slot>
|
|
8
|
-
</template>
|
|
9
|
-
<template #empty>
|
|
10
|
-
<slot name="empty"></slot>
|
|
11
|
-
</template>
|
|
12
|
-
</TableWrapper>
|
|
13
|
-
</TableResizeObserver>
|
|
14
|
-
</TableLoading>
|
|
15
|
-
</div>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script>
|
|
19
|
-
import { createTableContext } from './context/createTableContext.js'
|
|
20
|
-
import { flattenColumns } from './composables/useColumns.js'
|
|
21
|
-
import { sortData } from './composables/useSorter.js'
|
|
22
|
-
import { computeOffsets } from './composables/useSticky.js'
|
|
23
|
-
import { SELECTION_COLUMN, DRAGGABLE_COLUMN } from './constants.js'
|
|
24
|
-
import TableWrapper from './TableWrapper.vue'
|
|
25
|
-
import TableLoading from './TableLoading.vue'
|
|
26
|
-
import TableResizeObserver from './TableResizeObserver.vue'
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
name: 'TableV2',
|
|
30
|
-
|
|
31
|
-
components: { TableWrapper, TableLoading, TableResizeObserver },
|
|
32
|
-
|
|
33
|
-
provide: function () {
|
|
34
|
-
return { tableContext: this.tableCtx }
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
props: {
|
|
38
|
-
columns: {
|
|
39
|
-
type: Array,
|
|
40
|
-
default: function () {
|
|
41
|
-
return []
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
dataSource: {
|
|
45
|
-
type: Array,
|
|
46
|
-
default: function () {
|
|
47
|
-
return []
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
bordered: { type: Boolean, default: false },
|
|
51
|
-
size: { type: String, default: 'md' },
|
|
52
|
-
rowKey: { type: String, default: 'key' },
|
|
53
|
-
scroll: { type: Object, default: null },
|
|
54
|
-
loading: { type: Boolean, default: false },
|
|
55
|
-
rowSelection: { type: Object, default: null },
|
|
56
|
-
customRow: { type: Function, default: null },
|
|
57
|
-
customHeaderRow: { type: Function, default: null },
|
|
58
|
-
rowDraggable: { type: Object, default: null },
|
|
59
|
-
enableFixedLeft: { type: Boolean, default: false },
|
|
60
|
-
rowHeight: { type: Number, default: 50 },
|
|
61
|
-
headerHeight: { type: Number, default: 36 },
|
|
62
|
-
emptyText: { type: String, default: '' },
|
|
63
|
-
height: { type: [Number, String], default: 0 }
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
emits: ['change', 'sort-change', 'select-change'],
|
|
67
|
-
|
|
68
|
-
data: function () {
|
|
69
|
-
return { tableCtx: createTableContext() }
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
computed: {
|
|
73
|
-
isEmpty: function () {
|
|
74
|
-
return this.tableCtx.data.display.length === 0
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
columnsInput: function () {
|
|
78
|
-
return {
|
|
79
|
-
columns: this.columns,
|
|
80
|
-
rowKey: this.rowKey,
|
|
81
|
-
hasSelection: !!this.rowSelection,
|
|
82
|
-
hasDraggable: !!this.rowDraggable
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
rowsInput: function () {
|
|
87
|
-
return { customRow: this.customRow, customHeaderRow: this.customHeaderRow }
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
layoutInput: function () {
|
|
91
|
-
return {
|
|
92
|
-
bordered: this.bordered,
|
|
93
|
-
size: this.size,
|
|
94
|
-
scroll: this.scroll,
|
|
95
|
-
rowHeight: this.rowHeight,
|
|
96
|
-
headerHeight: this.headerHeight,
|
|
97
|
-
height: this.height
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
dataInput: function () {
|
|
102
|
-
return {
|
|
103
|
-
source: this.dataSource,
|
|
104
|
-
sortKey: this.tableCtx.sort.columnKey,
|
|
105
|
-
sortOrder: this.tableCtx.sort.order,
|
|
106
|
-
loading: this.loading,
|
|
107
|
-
emptyText: this.emptyText
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
stickyInput: function () {
|
|
112
|
-
return {
|
|
113
|
-
columns: this.tableCtx.columns.flat,
|
|
114
|
-
widths: this.tableCtx.layout.columnWidths
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
selectionInput: function () {
|
|
119
|
-
return this.rowSelection
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
draggableInput: function () {
|
|
123
|
-
return this.rowDraggable
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
watch: {
|
|
128
|
-
columnsInput: {
|
|
129
|
-
immediate: true,
|
|
130
|
-
handler: function (v) {
|
|
131
|
-
var cols = flattenColumns(v.columns)
|
|
132
|
-
const isHasFixedLeft = cols.some(col => col.fixed === 'left')
|
|
133
|
-
if (v.hasSelection) {
|
|
134
|
-
cols.unshift({
|
|
135
|
-
key: '__selection__',
|
|
136
|
-
type: SELECTION_COLUMN,
|
|
137
|
-
width: 36,
|
|
138
|
-
dataIndex: '',
|
|
139
|
-
title: '',
|
|
140
|
-
align: null,
|
|
141
|
-
fixed: isHasFixedLeft || this.enableFixedLeft ? 'left' : null,
|
|
142
|
-
ellipsis: false
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
if (v.hasDraggable) {
|
|
146
|
-
cols.unshift({
|
|
147
|
-
key: '__draggable__',
|
|
148
|
-
type: DRAGGABLE_COLUMN,
|
|
149
|
-
width: 36,
|
|
150
|
-
dataIndex: '',
|
|
151
|
-
title: '',
|
|
152
|
-
align: null,
|
|
153
|
-
fixed: isHasFixedLeft || this.enableFixedLeft ? 'left' : null,
|
|
154
|
-
ellipsis: false
|
|
155
|
-
})
|
|
156
|
-
}
|
|
157
|
-
this.tableCtx.columns.flat = cols
|
|
158
|
-
this.tableCtx.layout.rowKey = v.rowKey
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
rowsInput: {
|
|
163
|
-
immediate: true,
|
|
164
|
-
handler: function (v) {
|
|
165
|
-
this.tableCtx.rows.customRow = v.customRow
|
|
166
|
-
this.tableCtx.rows.customHeaderRow = v.customHeaderRow
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
layoutInput: {
|
|
171
|
-
immediate: true,
|
|
172
|
-
deep: true,
|
|
173
|
-
handler: function (v) {
|
|
174
|
-
this.tableCtx.layout.bordered = v.bordered
|
|
175
|
-
this.tableCtx.layout.size = v.size
|
|
176
|
-
this.tableCtx.layout.scroll = v.scroll
|
|
177
|
-
this.tableCtx.layout.tableLayout = v.scroll && v.scroll.y ? 'fixed' : 'auto'
|
|
178
|
-
this.tableCtx.layout.height = v.height
|
|
179
|
-
this.tableCtx.layout.headerHeight = v.headerHeight
|
|
180
|
-
this.tableCtx.layout.rowHeight = v.rowHeight
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
dataInput: {
|
|
185
|
-
immediate: true,
|
|
186
|
-
handler: function (v) {
|
|
187
|
-
this.tableCtx.data.source = v.source
|
|
188
|
-
;((this.tableCtx.data.display = v.sortKey ? sortData(v.source, v.sortKey, v.sortOrder) : v.source),
|
|
189
|
-
(this.tableCtx.data.loading = v.loading))
|
|
190
|
-
this.tableCtx.data.emptyText = v.emptyText
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
stickyInput: {
|
|
195
|
-
deep: true,
|
|
196
|
-
immediate: true,
|
|
197
|
-
handler: function (v) {
|
|
198
|
-
if (!v.columns.length) return
|
|
199
|
-
var offsets = computeOffsets(v.columns, v.widths)
|
|
200
|
-
this.tableCtx.sticky.leftOffsets = offsets.left
|
|
201
|
-
this.tableCtx.sticky.rightOffsets = offsets.right
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
selectionInput: {
|
|
206
|
-
immediate: true,
|
|
207
|
-
deep: true,
|
|
208
|
-
handler: function (v) {
|
|
209
|
-
if (!v) return
|
|
210
|
-
this.tableCtx.selection.selectedRowKeys = v.selectedRowKeys || []
|
|
211
|
-
this.tableCtx.selection.hideSelectAll = v.hideSelectAll
|
|
212
|
-
this.tableCtx.selection.columnWidth = v.columnWidth
|
|
213
|
-
this.tableCtx.selection.type = v.type
|
|
214
|
-
this.tableCtx.selection.onChange = v.onChange
|
|
215
|
-
this.tableCtx.selection.onSelect = v.onSelect
|
|
216
|
-
this.tableCtx.selection.onSelectAll = v.onSelectAll
|
|
217
|
-
this.tableCtx.selection.onSelectNone = v.onSelectNone
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
|
|
221
|
-
draggableInput: {
|
|
222
|
-
immediate: true,
|
|
223
|
-
deep: true,
|
|
224
|
-
handler: function (v) {
|
|
225
|
-
this.tableCtx.draggable.enabled = !!v
|
|
226
|
-
if (!v) return
|
|
227
|
-
this.tableCtx.draggable.columnWidth = v.columnWidth || 36
|
|
228
|
-
this.tableCtx.draggable.handleReorder = v.handleReorder || null
|
|
229
|
-
this.tableCtx.draggable.enableAnimationFlip = v.enableAnimationFlip || false
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
created: function () {
|
|
235
|
-
this.tableCtx.actions.sort = this.handleSort
|
|
236
|
-
this.tableCtx.actions.select = this.handleSelect
|
|
237
|
-
this.tableCtx.actions.resize = this.handleResize
|
|
238
|
-
this.tableCtx.actions.reorder = this.handleReorder
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
methods: {
|
|
242
|
-
handleSort: function (columnKey, order) {
|
|
243
|
-
this.tableCtx.sort.columnKey = columnKey
|
|
244
|
-
this.tableCtx.sort.order = order
|
|
245
|
-
this.$emit('sort-change', { columnKey: columnKey, order: order })
|
|
246
|
-
this.$emit('change', { sort: { columnKey: columnKey, order: order } })
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
handleSelect: function (keys, meta) {
|
|
250
|
-
var prevKeys = this.tableCtx.selection.selectedRowKeys
|
|
251
|
-
var display = this.tableCtx.data.display
|
|
252
|
-
var rowKey = this.tableCtx.layout.rowKey
|
|
253
|
-
var rs = this.rowSelection || {}
|
|
254
|
-
|
|
255
|
-
this.tableCtx.selection.checkAll = keys.length === display.length && display.length > 0
|
|
256
|
-
|
|
257
|
-
var selectedRows = display.filter(function (r) {
|
|
258
|
-
return keys.indexOf(r[rowKey]) !== -1
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
if (rs.onChange) rs.onChange(keys, selectedRows)
|
|
262
|
-
|
|
263
|
-
if (!meta) return
|
|
264
|
-
|
|
265
|
-
if (meta.type === 'row') {
|
|
266
|
-
if (rs.onSelect) rs.onSelect(meta.record, meta.selected, selectedRows, meta.nativeEvent)
|
|
267
|
-
} else if (meta.type === 'all') {
|
|
268
|
-
// changeRows = rows mới được check (chưa có trong prevKeys)
|
|
269
|
-
var changeRows = display.filter(function (r) {
|
|
270
|
-
return prevKeys.indexOf(r[rowKey]) === -1
|
|
271
|
-
})
|
|
272
|
-
if (rs.onSelectAll) rs.onSelectAll(true, selectedRows, changeRows)
|
|
273
|
-
} else if (meta.type === 'none') {
|
|
274
|
-
// changeRows = rows bị uncheck (đang có trong prevKeys)
|
|
275
|
-
changeRows = display.filter(function (r) {
|
|
276
|
-
return prevKeys.indexOf(r[rowKey]) !== -1
|
|
277
|
-
})
|
|
278
|
-
if (rs.onSelectAll) rs.onSelectAll(false, [], changeRows)
|
|
279
|
-
if (rs.onSelectNone) rs.onSelectNone()
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
handleResize: function (colKey, width) {
|
|
284
|
-
var widths = new Map(this.tableCtx.layout.columnWidths)
|
|
285
|
-
widths.set(colKey, width)
|
|
286
|
-
this.tableCtx.layout.columnWidths = widths
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
handleReorder: function (oldIndex, newIndex) {
|
|
290
|
-
const display = this.tableCtx.data.display.slice()
|
|
291
|
-
const moved = display.splice(oldIndex, 1)[0]
|
|
292
|
-
display.splice(newIndex, 0, moved)
|
|
293
|
-
|
|
294
|
-
const cb = this.tableCtx.draggable.handleReorder
|
|
295
|
-
if (typeof cb === 'function') cb(oldIndex, newIndex, display)
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
handleContainerResize: function (size) {
|
|
299
|
-
this.tableCtx.layout.containerWidth = size.width
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
</script>
|
|
304
|
-
|
|
305
|
-
<style src="./style/table.css" scoped></style>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|