@vunk/plus 0.2.0 → 1.1.1

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.
@@ -0,0 +1,7 @@
1
+ .vk-tables-v1-table{
2
+ height: 100%;
3
+ }
4
+ .vk-tables-v1-pagination-x {
5
+ display: flex;
6
+ justify-content: center;
7
+ }
@@ -0,0 +1,5 @@
1
+ import VkTablesV1 from './src/index.vue';
2
+ export * as _VkTabelsV1Ctx from './src/ctx';
3
+ export * as __VkTablesV1 from './src/types';
4
+ export { VkTablesV1, };
5
+ export default VkTablesV1;
@@ -0,0 +1,431 @@
1
+ import { VkTableColumns, _VkTableColumnsElCtx as _VkTableColumnsElCtx$1 } from '@vunk/plus/components/table-columns';
2
+ import { useElBreakpoints } from '@vunk/plus/composables/el-breakpoints';
3
+ import { VkDuplexCalc } from '@vunk/core';
4
+ import { useSizeProp, paginationProps, paginationEmits, ElPagination, ElTable } from 'element-plus';
5
+ import { defineComponent, computed, resolveComponent, openBlock, createBlock, withCtx, createVNode, mergeProps, toHandlers, createElementBlock, createCommentVNode } from 'vue';
6
+ import { bindPropsFactory, onEmitsFactory } from '@vunk/core/shared/utils-vue';
7
+ import { pickObject } from '@vunk/core/shared/utils-object';
8
+ import { _VkTableColumnsElCtx } from '@vunk/skzz/components/table-columns';
9
+ import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
10
+
11
+ const tableProps$1 = {
12
+ /**
13
+ * @description table data
14
+ */
15
+ data: {
16
+ type: Array,
17
+ default: () => []
18
+ },
19
+ /**
20
+ * @description size of Table
21
+ */
22
+ size: useSizeProp,
23
+ width: [String, Number],
24
+ /**
25
+ * @description table's height. By default it has an `auto` height. If its value is a number, the height is measured in pixels; if its value is a string, the value will be assigned to element's style.height, the height is affected by external styles
26
+ */
27
+ height: [String, Number],
28
+ /**
29
+ * @description table's max-height. The legal value is a number or the height in px
30
+ */
31
+ maxHeight: [String, Number],
32
+ /**
33
+ * @description whether width of column automatically fits its container
34
+ */
35
+ fit: {
36
+ type: Boolean,
37
+ default: true
38
+ },
39
+ /**
40
+ * @description whether Table is striped
41
+ */
42
+ stripe: Boolean,
43
+ /**
44
+ * @description whether Table has vertical border
45
+ */
46
+ border: Boolean,
47
+ /**
48
+ * @description key of row data, used for optimizing rendering. Required if `reserve-selection` is on or display tree data. When its type is String, multi-level access is supported, e.g. `user.info.id`, but `user.info[0].id` is not supported, in which case `Function` should be used
49
+ */
50
+ rowKey: [String, Function],
51
+ /**
52
+ * @description whether Table header is visible
53
+ */
54
+ showHeader: {
55
+ type: Boolean,
56
+ default: true
57
+ },
58
+ /**
59
+ * @description whether to display a summary row
60
+ */
61
+ showSummary: Boolean,
62
+ /**
63
+ * @description displayed text for the first column of summary row
64
+ */
65
+ sumText: String,
66
+ /**
67
+ * @description custom summary method
68
+ */
69
+ summaryMethod: Function,
70
+ /**
71
+ * @description function that returns custom class names for a row, or a string assigning class names for every row
72
+ */
73
+ rowClassName: [String, Function],
74
+ /**
75
+ * @description function that returns custom style for a row, or an object assigning custom style for every row
76
+ */
77
+ rowStyle: [Object, Function],
78
+ /**
79
+ * @description function that returns custom class names for a cell, or a string assigning class names for every cell
80
+ */
81
+ cellClassName: [String, Function],
82
+ /**
83
+ * @description function that returns custom style for a cell, or an object assigning custom style for every cell
84
+ */
85
+ cellStyle: [Object, Function],
86
+ /**
87
+ * @description function that returns custom class names for a row in table header, or a string assigning class names for every row in table header
88
+ */
89
+ headerRowClassName: [String, Function],
90
+ /**
91
+ * @description function that returns custom style for a row in table header, or an object assigning custom style for every row in table header
92
+ */
93
+ headerRowStyle: [Object, Function],
94
+ /**
95
+ * @description function that returns custom class names for a cell in table header, or a string assigning class names for every cell in table header
96
+ */
97
+ headerCellClassName: [String, Function],
98
+ /**
99
+ * @description function that returns custom style for a cell in table header, or an object assigning custom style for every cell in table header
100
+ */
101
+ headerCellStyle: [Object, Function],
102
+ /**
103
+ * @description whether current row is highlighted
104
+ */
105
+ highlightCurrentRow: Boolean,
106
+ /**
107
+ * @description key of current row, a set only prop
108
+ */
109
+ currentRowKey: [String, Number],
110
+ /**
111
+ * @description displayed text when data is empty. You can customize this area with `#empty`
112
+ */
113
+ emptyText: String,
114
+ /**
115
+ * @description set expanded rows by this prop, prop's value is the keys of expand rows, you should set row-key before using this prop
116
+ */
117
+ expandRowKeys: Array,
118
+ /**
119
+ * @description whether expand all rows by default, works when the table has a column type="expand" or contains tree structure data
120
+ */
121
+ defaultExpandAll: Boolean,
122
+ /**
123
+ * @description set the default sort column and order. property `prop` is used to set default sort column, property `order` is used to set default sort order
124
+ */
125
+ defaultSort: Object,
126
+ /**
127
+ * @description the `effect` of the overflow tooltip
128
+ */
129
+ tooltipEffect: String,
130
+ /**
131
+ * @description the options for the overflow tooltip, [see the following tooltip component](tooltip.html#attributes)
132
+ */
133
+ tooltipOptions: Object,
134
+ /**
135
+ * @description method that returns rowspan and colspan
136
+ */
137
+ spanMethod: Function,
138
+ /**
139
+ * @description controls the behavior of master checkbox in multi-select tables when only some rows are selected (but not all). If true, all rows will be selected, else deselected
140
+ */
141
+ selectOnIndeterminate: {
142
+ type: Boolean,
143
+ default: true
144
+ },
145
+ /**
146
+ * @description horizontal indentation of tree data
147
+ */
148
+ indent: {
149
+ type: Number,
150
+ default: 16
151
+ },
152
+ /**
153
+ * @description configuration for rendering nested data
154
+ */
155
+ treeProps: {
156
+ type: Object,
157
+ default: () => {
158
+ return {
159
+ hasChildren: "hasChildren",
160
+ children: "children",
161
+ checkStrictly: false
162
+ };
163
+ }
164
+ },
165
+ /**
166
+ * @description whether to lazy loading data
167
+ */
168
+ lazy: Boolean,
169
+ /**
170
+ * @description method for loading child row data, only works when `lazy` is true
171
+ */
172
+ load: Function,
173
+ style: {
174
+ type: Object,
175
+ default: () => ({})
176
+ },
177
+ className: {
178
+ type: String,
179
+ default: ""
180
+ },
181
+ /**
182
+ * @description sets the algorithm used to lay out table cells, rows, and columns
183
+ */
184
+ tableLayout: {
185
+ type: String,
186
+ default: "fixed"
187
+ },
188
+ /**
189
+ * @description always show scrollbar
190
+ */
191
+ scrollbarAlwaysOn: Boolean,
192
+ /**
193
+ * @description ensure main axis minimum-size doesn't follow the content
194
+ */
195
+ flexible: Boolean,
196
+ /**
197
+ * @description whether to hide extra content and show them in a tooltip when hovering on the cell.It will affect all the table columns
198
+ */
199
+ showOverflowTooltip: [Boolean, Object],
200
+ appendFilterPanelTo: String,
201
+ scrollbarTabindex: {
202
+ type: [Number, String],
203
+ default: void 0
204
+ }
205
+ };
206
+ bindPropsFactory(tableProps$1);
207
+ const tableEmits = {
208
+ "select": null,
209
+ "select-all": null,
210
+ "selection-change": null,
211
+ "cell-mouse-enter": null,
212
+ "cell-mouse-leave": null,
213
+ "cell-contextmenu": null,
214
+ "cell-click": null,
215
+ "cell-dblclick": null,
216
+ "row-click": null,
217
+ "row-contextmenu": null,
218
+ "row-dblclick": null,
219
+ "header-click": null,
220
+ "header-contextmenu": null,
221
+ "sort-change": null,
222
+ "filter-change": null,
223
+ "current-change": null,
224
+ "header-dragend": null,
225
+ "expand-change": null,
226
+ "scroll": null
227
+ };
228
+ const createElTableOnEmits = onEmitsFactory(tableEmits);
229
+
230
+ const createPaginationBindProps = bindPropsFactory(paginationProps);
231
+ const createPaginationOnEmits = onEmitsFactory(paginationEmits);
232
+ const tableProps = pickObject(tableProps$1, {
233
+ excludes: ["style", "className"]
234
+ });
235
+ const createTableBindProps = bindPropsFactory(tableProps);
236
+ const props = {
237
+ ..._VkTableColumnsElCtx.tableColumnProps,
238
+ ...paginationProps,
239
+ ...tableProps,
240
+ border: {
241
+ type: Boolean,
242
+ default: true
243
+ },
244
+ tableClass: {
245
+ type: String,
246
+ default: ""
247
+ },
248
+ tableStyle: {
249
+ type: Object,
250
+ default: void 0
251
+ },
252
+ layout: {
253
+ type: String,
254
+ default: void 0
255
+ },
256
+ pageSize: {
257
+ type: Number,
258
+ default: 10
259
+ },
260
+ currentPage: {
261
+ type: Number,
262
+ default: 1
263
+ },
264
+ /**
265
+ * @description 表示偏移量 v-model:start 和 v-model:currentPage 二选一
266
+ */
267
+ start: {
268
+ type: Number,
269
+ default: void 0
270
+ },
271
+ /**
272
+ * @description 表格列
273
+ * @link ./table-columns
274
+ */
275
+ columns: {
276
+ type: Array,
277
+ default: () => []
278
+ },
279
+ /**
280
+ * @description 组件模块。
281
+ * 如无需分页,可传入 `:modules="[]"`
282
+ */
283
+ modules: {
284
+ type: Array,
285
+ default: () => ["pagination"]
286
+ },
287
+ align: {
288
+ type: String,
289
+ default: "center"
290
+ },
291
+ headerAlign: {
292
+ type: String,
293
+ default: "center"
294
+ },
295
+ elRef: {
296
+ type: Function,
297
+ default: void 0
298
+ }
299
+ };
300
+ const createBindProps = bindPropsFactory(props);
301
+ const emits = {
302
+ ...paginationEmits,
303
+ ...tableEmits,
304
+ "update:start": (val) => typeof val === "number"
305
+ };
306
+ const createOnEmits = onEmitsFactory(emits);
307
+
308
+ var ctx = /*#__PURE__*/Object.freeze({
309
+ __proto__: null,
310
+ createBindProps: createBindProps,
311
+ createOnEmits: createOnEmits,
312
+ createPaginationBindProps: createPaginationBindProps,
313
+ createPaginationOnEmits: createPaginationOnEmits,
314
+ createTableBindProps: createTableBindProps,
315
+ emits: emits,
316
+ props: props
317
+ });
318
+
319
+ var _sfc_main = defineComponent({
320
+ name: "VkTablesV1",
321
+ components: {
322
+ VkTableColumns,
323
+ VkDuplexCalc,
324
+ ElPagination,
325
+ ElTable
326
+ },
327
+ props,
328
+ emits,
329
+ setup(props2, { emit }) {
330
+ const paginationBindProps = createPaginationBindProps(props2, ["layout", "currentPage"]);
331
+ const paginationOnEmits = createPaginationOnEmits(emit, [
332
+ "update:current-page"
333
+ ]);
334
+ const columnsProps = _VkTableColumnsElCtx$1.createTableColumnBindProps(props2);
335
+ const tableProps = createTableBindProps(props2);
336
+ const tableOnEmits = createElTableOnEmits(emit);
337
+ const { isMobile } = useElBreakpoints();
338
+ const hasPagination = computed(() => props2.modules.includes("pagination"));
339
+ const theCurrentPage = computed({
340
+ get: () => {
341
+ if (props2.start !== void 0) {
342
+ return Math.floor(props2.start / props2.pageSize) + 1;
343
+ }
344
+ return props2.currentPage;
345
+ },
346
+ set: (val) => {
347
+ emit("update:current-page", val);
348
+ updateStart({ currentPage: val });
349
+ }
350
+ });
351
+ function updateStart(e) {
352
+ const currentPage = e.currentPage ?? theCurrentPage.value;
353
+ const pageSize = e.pageSize ?? props2.pageSize;
354
+ emit("update:start", (currentPage - 1) * pageSize);
355
+ }
356
+ const layout = computed(() => {
357
+ if (props2.layout) {
358
+ return props2.layout;
359
+ }
360
+ if (isMobile.value) {
361
+ return "total, prev, pager, next";
362
+ }
363
+ return "total, sizes, prev, pager, next, jumper";
364
+ });
365
+ return {
366
+ paginationBindProps,
367
+ paginationOnEmits,
368
+ theCurrentPage,
369
+ updateStart,
370
+ columnsProps,
371
+ tableProps,
372
+ tableOnEmits,
373
+ layout,
374
+ hasPagination
375
+ };
376
+ }
377
+ });
378
+
379
+ const _hoisted_1 = {
380
+ key: 0,
381
+ class: "vk-tables-v1-pagination-x"
382
+ };
383
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
384
+ const _component_VkTableColumns = resolveComponent("VkTableColumns");
385
+ const _component_ElTable = resolveComponent("ElTable");
386
+ const _component_ElPagination = resolveComponent("ElPagination");
387
+ const _component_VkDuplexCalc = resolveComponent("VkDuplexCalc");
388
+ return openBlock(), createBlock(_component_VkDuplexCalc, {
389
+ class: "vk-tables-v1",
390
+ "with-resize": "one",
391
+ gap: "var(--vk-tables-v1-gap, 14px)"
392
+ }, {
393
+ one: withCtx(() => [
394
+ createVNode(_component_ElTable, mergeProps(_ctx.tableProps, {
395
+ ref: _ctx.elRef,
396
+ style: _ctx.tableStyle,
397
+ "class-name": `vk-tables-v1-table ${_ctx.tableClass}`
398
+ }, toHandlers(_ctx.tableOnEmits)), {
399
+ default: withCtx(() => [
400
+ createVNode(_component_VkTableColumns, mergeProps(_ctx.columnsProps, { source: _ctx.columns }), null, 16, ["source"])
401
+ ]),
402
+ _: 1
403
+ /* STABLE */
404
+ }, 16, ["style", "class-name"])
405
+ ]),
406
+ default: withCtx(() => [
407
+ _ctx.hasPagination ? (openBlock(), createElementBlock("div", _hoisted_1, [
408
+ createVNode(_component_ElPagination, mergeProps(_ctx.paginationBindProps, {
409
+ "current-page": _ctx.theCurrentPage,
410
+ "onUpdate:currentPage": _cache[0] || (_cache[0] = ($event) => _ctx.theCurrentPage = $event),
411
+ layout: _ctx.layout
412
+ }, toHandlers(_ctx.paginationOnEmits), {
413
+ "onUpdate:pageSize": _cache[1] || (_cache[1] = ($event) => _ctx.updateStart({ pageSize: $event }))
414
+ }), null, 16, ["current-page", "layout"])
415
+ ])) : createCommentVNode("v-if", true)
416
+ ]),
417
+ _: 1
418
+ /* STABLE */
419
+ });
420
+ }
421
+ var VkTablesV1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/tables-v1/src/index.vue"]]);
422
+
423
+ var types = /*#__PURE__*/Object.freeze({
424
+ __proto__: null
425
+ });
426
+
427
+ VkTablesV1.install = (app) => {
428
+ app.component(VkTablesV1.name || "VkTablesV1", VkTablesV1);
429
+ };
430
+
431
+ export { VkTablesV1, ctx as _VkTabelsV1Ctx, types as __VkTablesV1, VkTablesV1 as default };