@qin-ui/element-plus-pro 1.1.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.
package/es/table/index.js DELETED
@@ -1,856 +0,0 @@
1
- import { createElementBlock, openBlock, createElementVNode, defineComponent, ref, computed, watch, watchEffect, createBlock, unref, mergeProps, withKeys, withCtx, createVNode, renderSlot, createCommentVNode, Fragment, resolveDynamicComponent, createTextVNode, toDisplayString, normalizeStyle, useModel, renderList, withModifiers, mergeModels, inject, useAttrs, useSlots, onMounted, resolveDirective, normalizeClass, withDirectives, createSlots, normalizeProps, guardReactiveProps, nextTick } from "vue";
2
- import { ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn, ElTable, ElPagination } from "element-plus";
3
- import { _ as _export_sfc, a as _sfc_main$a, t as tableProps, p as paginationProps, b as _sfc_main$b } from "../form/index-oI6LGSpA.js";
4
- import { I as INJECT_CONFIG } from "../component-provider/index-BGGIWSkO.js";
5
- import { get, toPath, pick, camelizeProperties, getObject, useTable as useTable$1 } from "@qin-ui/pro-components-core";
6
- const _sfc_main$9 = {};
7
- const _hoisted_1$5 = {
8
- focusable: "false",
9
- "data-icon": "down",
10
- width: "1em",
11
- height: "1em",
12
- fill: "currentColor",
13
- "aria-hidden": "true",
14
- viewBox: "64 64 896 896"
15
- };
16
- function _sfc_render$4(_ctx, _cache) {
17
- return openBlock(), createElementBlock("svg", _hoisted_1$5, [..._cache[0] || (_cache[0] = [
18
- createElementVNode("path", { d: "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z" }, null, -1)
19
- ])]);
20
- }
21
- const DownOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$4]]);
22
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
23
- ...{ name: "SearchForm" },
24
- __name: "SearchForm",
25
- props: {
26
- form: {},
27
- layout: { default: "grid" },
28
- expand: { type: [Boolean, Object], default: true },
29
- searchButton: { type: [Object, Function, Boolean], default: void 0 },
30
- resetButton: { type: [Object, Function, Boolean], default: void 0 },
31
- expandButton: { type: [Object, Function, Boolean], default: void 0 },
32
- rowGap: { default: 16 },
33
- columnGap: { default: 24 },
34
- class: {},
35
- style: {}
36
- },
37
- emits: ["search", "reset"],
38
- setup(__props, { emit: __emit }) {
39
- const emit = __emit;
40
- const proFormHeight = ref("unset");
41
- const collapseHeight = ref(0);
42
- let rowHeight = 32;
43
- const computedExpand = computed(() => {
44
- if (!__props.expand) return false;
45
- if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
46
- return {
47
- minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
48
- expandStatus: __props.expand.expandStatus ?? false
49
- };
50
- });
51
- const showExpandToggle = ref(false);
52
- const expandStatus = ref(true);
53
- const changeExpandStatus = () => {
54
- expandStatus.value = !expandStatus.value;
55
- };
56
- const { formRef, getFormData } = __props.form;
57
- const setInitExpandStatus = () => {
58
- expandStatus.value = false;
59
- if (formRef.value && __props.expand) {
60
- const formEl = formRef.value.$el;
61
- const formItemsEl = formEl.querySelectorAll(
62
- "[class*='-form-item'] > [path]"
63
- );
64
- const observer = new IntersectionObserver(
65
- (entries) => {
66
- expandStatus.value = entries.some((e) => {
67
- if (e.intersectionRatio === 0) {
68
- const path = e.target.getAttribute("path");
69
- const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
70
- return ![null, void 0].includes(searchFieldValue);
71
- }
72
- return __props.expand.expandStatus;
73
- });
74
- observer.disconnect();
75
- },
76
- { root: formEl }
77
- );
78
- formItemsEl.forEach((element) => {
79
- observer.observe(element);
80
- });
81
- }
82
- };
83
- watch(
84
- [
85
- () => {
86
- var _a, _b, _c;
87
- return (_c = (_b = (_a = __props.form) == null ? void 0 : _a.fields.value) == null ? void 0 : _b.filter((f) => !f.hidden)) == null ? void 0 : _c.length;
88
- },
89
- () => formRef.value,
90
- () => __props.expand
91
- ],
92
- () => {
93
- var _a, _b, _c, _d, _e;
94
- if (!__props.expand || !expandStatus.value || !formRef.value) return;
95
- const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
96
- const { height = 0 } = ((_b = proFormEl == null ? void 0 : proFormEl.getBoundingClientRect) == null ? void 0 : _b.call(proFormEl)) || {};
97
- proFormHeight.value = height;
98
- rowHeight = (_e = (_d = (_c = proFormEl == null ? void 0 : proFormEl.querySelector("[class*='-form-item']")) == null ? void 0 : _c.getBoundingClientRect) == null ? void 0 : _d.call(_c)) == null ? void 0 : _e.height;
99
- },
100
- { flush: "post", immediate: true }
101
- );
102
- watchEffect(
103
- () => {
104
- if (typeof proFormHeight.value !== "number") return;
105
- if (__props.layout === "grid" && computedExpand.value) {
106
- const { minExpandRows } = computedExpand.value;
107
- collapseHeight.value = Math.min(
108
- minExpandRows * rowHeight + (minExpandRows - 1) * __props.rowGap,
109
- +proFormHeight.value
110
- );
111
- showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
112
- if (showExpandToggle.value) {
113
- setInitExpandStatus();
114
- }
115
- } else {
116
- showExpandToggle.value = false;
117
- }
118
- },
119
- { flush: "post" }
120
- );
121
- const layoutProps = computed(
122
- () => __props.layout === "grid" ? {
123
- grid: {
124
- gutter: __props.columnGap,
125
- style: { rowGap: `${__props.rowGap}px` }
126
- },
127
- style: {
128
- display: "flex",
129
- overflow: "hidden",
130
- columnGap: `${__props.columnGap}px`,
131
- height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
132
- }
133
- } : {
134
- inline: true,
135
- style: {
136
- display: "flex",
137
- flexWrap: "wrap",
138
- gap: `${__props.rowGap}px ${__props.columnGap}px`
139
- },
140
- grid: false
141
- }
142
- );
143
- const onReset = () => {
144
- emit("reset");
145
- };
146
- const onSearch = () => {
147
- emit("search");
148
- };
149
- return (_ctx, _cache) => {
150
- return openBlock(), createBlock(unref(_sfc_main$a), mergeProps(layoutProps.value, {
151
- form: __props.form,
152
- class: "pro-table_search-form transition",
153
- onKeyup: withKeys(onSearch, ["enter"])
154
- }), {
155
- default: withCtx(() => [
156
- createVNode(unref(ElSpace), {
157
- alignment: "start",
158
- class: "pro-table_search-form_button-group"
159
- }, {
160
- default: withCtx(() => [
161
- renderSlot(_ctx.$slots, "reset-button", { onClick: onReset }, () => [
162
- __props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
163
- __props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.resetButton), {
164
- key: 0,
165
- onClick: onReset
166
- })) : (openBlock(), createBlock(unref(ElButton), {
167
- key: 1,
168
- class: "pro-table_search-form_reset-button",
169
- onClick: onReset
170
- }, {
171
- default: withCtx(() => [..._cache[0] || (_cache[0] = [
172
- createTextVNode("重置", -1)
173
- ])]),
174
- _: 1
175
- }))
176
- ], 64)) : createCommentVNode("", true)
177
- ], true),
178
- renderSlot(_ctx.$slots, "search-button", { onClick: onSearch }, () => [
179
- __props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
180
- __props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.searchButton), {
181
- key: 0,
182
- onClick: onSearch
183
- })) : (openBlock(), createBlock(unref(ElButton), {
184
- key: 1,
185
- class: "pro-table_search-form_search-button",
186
- type: "primary",
187
- "native-type": "submit",
188
- onClick: onSearch
189
- }, {
190
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
191
- createTextVNode(" 查询 ", -1)
192
- ])]),
193
- _: 1
194
- }))
195
- ], 64)) : createCommentVNode("", true)
196
- ], true),
197
- renderSlot(_ctx.$slots, "expand-button", { onClick: changeExpandStatus }, () => [
198
- __props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
199
- __props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.expandButton), {
200
- key: 0,
201
- "expand-status": expandStatus.value,
202
- onClick: changeExpandStatus
203
- }, null, 8, ["expand-status"])) : (openBlock(), createBlock(unref(ElButton), {
204
- key: 1,
205
- text: "",
206
- class: "pro-table_search-form_expand-toggle-button",
207
- onClick: changeExpandStatus
208
- }, {
209
- default: withCtx(() => [
210
- createTextVNode(toDisplayString(expandStatus.value ? "收起" : "展开") + " ", 1),
211
- createVNode(DownOutlined, {
212
- class: "transition",
213
- style: normalizeStyle([{ "margin-left": "4px" }, { transform: `rotate(${expandStatus.value ? -180 : 0}deg)` }])
214
- }, null, 8, ["style"])
215
- ]),
216
- _: 1
217
- }))
218
- ], 64)) : createCommentVNode("", true)
219
- ], true)
220
- ]),
221
- _: 3
222
- })
223
- ]),
224
- _: 3
225
- }, 16, ["form"]);
226
- };
227
- }
228
- });
229
- const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-512bc2e5"]]);
230
- const _sfc_main$7 = {};
231
- const _hoisted_1$4 = { class: "pro-table_search-form-container" };
232
- function _sfc_render$3(_ctx, _cache) {
233
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
234
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
235
- ]);
236
- }
237
- const DefaultSearchFormContainer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3], ["__scopeId", "data-v-45e627f4"]]);
238
- const _sfc_main$6 = {};
239
- const _hoisted_1$3 = { class: "pro-table_table-container" };
240
- function _sfc_render$2(_ctx, _cache) {
241
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
242
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
243
- ]);
244
- }
245
- const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$2], ["__scopeId", "data-v-55d01897"]]);
246
- const _sfc_main$5 = {};
247
- const _hoisted_1$2 = {
248
- focusable: "false",
249
- "data-icon": "column-height",
250
- width: "1em",
251
- height: "1em",
252
- fill: "currentColor",
253
- "aria-hidden": "true",
254
- viewBox: "64 64 896 896"
255
- };
256
- function _sfc_render$1(_ctx, _cache) {
257
- return openBlock(), createElementBlock("svg", _hoisted_1$2, [..._cache[0] || (_cache[0] = [
258
- createElementVNode("path", { d: "M840 836H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm0-724H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM610.8 378c6 0 9.4-7 5.7-11.7L515.7 238.7a7.14 7.14 0 00-11.3 0L403.6 366.3a7.23 7.23 0 005.7 11.7H476v268h-62.8c-6 0-9.4 7-5.7 11.7l100.8 127.5c2.9 3.7 8.5 3.7 11.3 0l100.8-127.5c3.7-4.7.4-11.7-5.7-11.7H548V378h62.8z" }, null, -1)
259
- ])]);
260
- }
261
- const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$1]]);
262
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
263
- __name: "SizeControl",
264
- props: {
265
- "size": {},
266
- "sizeModifiers": {}
267
- },
268
- emits: ["update:size"],
269
- setup(__props) {
270
- const size = useModel(__props, "size");
271
- size.value = size.value ?? "default";
272
- const items = [
273
- { label: "默认", key: "default" },
274
- { label: "中等", key: "large" },
275
- { label: "紧凑", key: "small" }
276
- ];
277
- return (_ctx, _cache) => {
278
- return openBlock(), createBlock(unref(ElDropdown), {
279
- trigger: "click",
280
- onCommand: _cache[0] || (_cache[0] = (val) => size.value = val)
281
- }, {
282
- dropdown: withCtx(() => [
283
- createVNode(unref(ElDropdownMenu), null, {
284
- default: withCtx(() => [
285
- (openBlock(), createElementBlock(Fragment, null, renderList(items, (item) => {
286
- return createVNode(unref(ElDropdownItem), {
287
- key: item.key,
288
- command: item.key,
289
- disabled: item.key === size.value
290
- }, {
291
- default: withCtx(() => [
292
- createTextVNode(toDisplayString(item.label), 1)
293
- ]),
294
- _: 2
295
- }, 1032, ["command", "disabled"]);
296
- }), 64))
297
- ]),
298
- _: 1
299
- })
300
- ]),
301
- default: withCtx(() => [
302
- createVNode(unref(ElButton), {
303
- text: "",
304
- class: "pro-table_size-control_button"
305
- }, {
306
- default: withCtx(() => [
307
- createVNode(ColumnHeightOutlined)
308
- ]),
309
- _: 1
310
- })
311
- ]),
312
- _: 1
313
- });
314
- };
315
- }
316
- });
317
- const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-7af52d04"]]);
318
- const _sfc_main$3 = {};
319
- const _hoisted_1$1 = {
320
- focusable: "false",
321
- "data-icon": "filter",
322
- width: "1em",
323
- height: "1em",
324
- fill: "currentColor",
325
- "aria-hidden": "true",
326
- viewBox: "64 64 896 896"
327
- };
328
- function _sfc_render(_ctx, _cache) {
329
- return openBlock(), createElementBlock("svg", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
330
- createElementVNode("path", { d: "M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z" }, null, -1)
331
- ])]);
332
- }
333
- const FilterOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
334
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
335
- __name: "ColumnControl",
336
- props: {
337
- columns: {},
338
- table: { default: () => void 0 }
339
- },
340
- setup(__props) {
341
- const open = ref(false);
342
- const checkAll = ref(false);
343
- const indeterminate = ref(false);
344
- const getColumnKey = (column, index) => {
345
- const key = column.key ?? column.prop;
346
- if (key === void 0 || key === null) return `__idx_${index}`;
347
- return Array.isArray(key) ? key.join(".") : String(key);
348
- };
349
- const checkedColumnsOptions = computed(
350
- () => __props.columns.map((item, index) => ({
351
- label: String(item.label ?? item.prop ?? `列${index + 1}`),
352
- value: getColumnKey(item, index),
353
- checked: !item.hidden,
354
- column: item
355
- }))
356
- );
357
- const checkedColumnKeys = computed({
358
- get() {
359
- return checkedColumnsOptions.value.flatMap(
360
- (item) => item.checked ? item.value : []
361
- );
362
- },
363
- set(val) {
364
- checkedColumnsOptions.value.forEach((item) => {
365
- var _a;
366
- (_a = __props.table) == null ? void 0 : _a.setColumn(item.value, {
367
- hidden: !val.includes(item.value)
368
- });
369
- });
370
- }
371
- });
372
- const onCheckAllChange = (value) => {
373
- var _a;
374
- const checked = !!(((_a = value == null ? void 0 : value.target) == null ? void 0 : _a.checked) ?? value);
375
- checkedColumnKeys.value = checked ? checkedColumnsOptions.value.map((item) => item.value) : [];
376
- indeterminate.value = false;
377
- };
378
- const toggleColumnsItem = (val) => {
379
- if (checkedColumnKeys.value.includes(val)) {
380
- checkedColumnKeys.value = checkedColumnKeys.value.filter(
381
- (item) => item !== val
382
- );
383
- } else {
384
- checkedColumnKeys.value = [...checkedColumnKeys.value, val];
385
- }
386
- };
387
- watch(
388
- checkedColumnKeys,
389
- (val) => {
390
- indeterminate.value = !!val.length && val.length < checkedColumnsOptions.value.length;
391
- checkAll.value = val.length > 0 && val.length === checkedColumnsOptions.value.length;
392
- },
393
- { immediate: true }
394
- );
395
- return (_ctx, _cache) => {
396
- return openBlock(), createBlock(unref(ElDropdown), {
397
- trigger: "click",
398
- "hide-on-click": false,
399
- visible: open.value,
400
- onVisibleChange: _cache[0] || (_cache[0] = (val) => open.value = val)
401
- }, {
402
- dropdown: withCtx(() => [
403
- createVNode(unref(ElDropdownMenu), null, {
404
- default: withCtx(() => [
405
- createVNode(unref(ElDropdownItem), {
406
- disabled: true,
407
- divided: false
408
- }, {
409
- default: withCtx(() => [
410
- createVNode(unref(ElCheckbox), {
411
- "model-value": checkAll.value,
412
- indeterminate: indeterminate.value,
413
- onChange: onCheckAllChange
414
- }, {
415
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
416
- createTextVNode(" 全选 ", -1)
417
- ])]),
418
- _: 1
419
- }, 8, ["model-value", "indeterminate"])
420
- ]),
421
- _: 1
422
- }),
423
- (openBlock(true), createElementBlock(Fragment, null, renderList(checkedColumnsOptions.value, (item) => {
424
- return openBlock(), createBlock(unref(ElDropdownItem), {
425
- key: item.value,
426
- command: item.value,
427
- onClick: withModifiers(($event) => toggleColumnsItem(item.value), ["stop"])
428
- }, {
429
- default: withCtx(() => [
430
- createVNode(unref(ElCheckbox), {
431
- "model-value": item.checked,
432
- onChange: () => toggleColumnsItem(item.value)
433
- }, {
434
- default: withCtx(() => [
435
- createTextVNode(toDisplayString(item.label), 1)
436
- ]),
437
- _: 2
438
- }, 1032, ["model-value", "onChange"])
439
- ]),
440
- _: 2
441
- }, 1032, ["command", "onClick"]);
442
- }), 128))
443
- ]),
444
- _: 1
445
- })
446
- ]),
447
- default: withCtx(() => [
448
- createVNode(unref(ElButton), {
449
- text: "",
450
- class: "pro-table_column-control_button"
451
- }, {
452
- default: withCtx(() => [
453
- createVNode(FilterOutlined)
454
- ]),
455
- _: 1
456
- })
457
- ]),
458
- _: 1
459
- }, 8, ["visible"]);
460
- };
461
- }
462
- });
463
- const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-ce445821"]]);
464
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
465
- ...{ name: "TableColumnRenderer" },
466
- __name: "TableColumnRenderer",
467
- props: {
468
- columns: {}
469
- },
470
- setup(__props) {
471
- const getColumnKey = (column, index) => {
472
- const key = column.key ?? column.prop;
473
- if (key === void 0 || key === null) return `__idx_${index}`;
474
- return Array.isArray(key) ? key.join(".") : String(key);
475
- };
476
- const getCellValue = (row, column) => {
477
- const path = column.prop;
478
- if (!path) return void 0;
479
- return get(row, toPath(path));
480
- };
481
- const normalizedColumns = computed(() => {
482
- return __props.columns.filter((column) => !column.hidden);
483
- });
484
- const getColumnProps = (column) => {
485
- const { hidden, render, key, ...rest } = column;
486
- const prop = Array.isArray(column.prop) ? column.prop.join(".") : column.prop ? String(column.prop) : void 0;
487
- return {
488
- ...rest,
489
- prop,
490
- columnKey: key ? String(key) : prop
491
- };
492
- };
493
- return (_ctx, _cache) => {
494
- return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column, index) => {
495
- return openBlock(), createBlock(unref(ElTableColumn), mergeProps({
496
- key: getColumnKey(column, index),
497
- ref_for: true
498
- }, getColumnProps(column)), {
499
- default: withCtx((scope) => {
500
- var _a;
501
- return [
502
- typeof column.render === "function" ? (openBlock(), createBlock(resolveDynamicComponent(
503
- (_a = column.render) == null ? void 0 : _a.call(column, {
504
- ...scope,
505
- column,
506
- cellValue: getCellValue(scope.row, column)
507
- })
508
- ), { key: 0 })) : createCommentVNode("", true)
509
- ];
510
- }),
511
- _: 2
512
- }, 1040);
513
- }), 128);
514
- };
515
- }
516
- });
517
- const _hoisted_1 = { class: "pro-table_header" };
518
- const _hoisted_2 = {
519
- key: 0,
520
- class: "pro-table_header_button-bar"
521
- };
522
- const _hoisted_3 = {
523
- key: 1,
524
- class: "pro-table_header_toolbar"
525
- };
526
- const _hoisted_4 = {
527
- key: 2,
528
- class: "pro-table_header_size-control"
529
- };
530
- const _hoisted_5 = {
531
- key: 3,
532
- class: "pro-table_header_column-control"
533
- };
534
- const _sfc_main = /* @__PURE__ */ defineComponent({
535
- ...{ name: "ProTable", inheritAttrs: false },
536
- __name: "ProTable",
537
- props: /* @__PURE__ */ mergeModels({
538
- table: { default: () => void 0 },
539
- search: { type: Function, default: void 0 },
540
- addIndexColumn: { type: Boolean, default: () => void 0 },
541
- immediateSearch: { type: Boolean, default: () => void 0 },
542
- control: { type: [Boolean, Object], default: () => void 0 },
543
- searchFormConfig: { default: () => void 0 },
544
- tableContainer: { type: [Object, Function, Boolean], default: void 0 },
545
- columns: { default: () => void 0 },
546
- data: { default: () => void 0 },
547
- pagination: { type: [Boolean, Object], default: () => void 0 },
548
- size: {},
549
- width: {},
550
- height: {},
551
- maxHeight: {},
552
- fit: { type: Boolean },
553
- stripe: { type: Boolean },
554
- border: { type: Boolean },
555
- rowKey: { type: [String, Function] },
556
- context: {},
557
- showHeader: { type: Boolean },
558
- showSummary: { type: Boolean },
559
- sumText: {},
560
- summaryMethod: { type: Function },
561
- rowClassName: { type: [String, Function] },
562
- rowStyle: { type: [Object, Function] },
563
- cellClassName: { type: [String, Function] },
564
- cellStyle: { type: [Object, Function] },
565
- headerRowClassName: { type: [String, Function] },
566
- headerRowStyle: { type: [Object, Function] },
567
- headerCellClassName: { type: [String, Function] },
568
- headerCellStyle: { type: [Object, Function] },
569
- highlightCurrentRow: { type: Boolean },
570
- currentRowKey: {},
571
- emptyText: {},
572
- expandRowKeys: {},
573
- defaultExpandAll: { type: Boolean },
574
- rowExpandable: { type: Function },
575
- defaultSort: {},
576
- tooltipEffect: {},
577
- tooltipOptions: {},
578
- spanMethod: { type: Function },
579
- selectOnIndeterminate: { type: Boolean },
580
- indent: {},
581
- treeProps: {},
582
- lazy: { type: Boolean },
583
- load: { type: Function },
584
- className: {},
585
- style: { type: [Boolean, null, String, Object, Array] },
586
- tableLayout: {},
587
- scrollbarAlwaysOn: { type: Boolean },
588
- flexible: { type: Boolean },
589
- showOverflowTooltip: { type: [Boolean, Object] },
590
- tooltipFormatter: { type: Function },
591
- appendFilterPanelTo: {},
592
- scrollbarTabindex: {},
593
- nativeScrollbar: { type: Boolean }
594
- }, {
595
- "size": {},
596
- "sizeModifiers": {},
597
- "loading": { type: Boolean },
598
- "loadingModifiers": {}
599
- }),
600
- emits: ["update:size", "update:loading"],
601
- setup(__props) {
602
- const config = INJECT_CONFIG["pro-table"];
603
- const injectProps = inject(config.injectionKey, config.default);
604
- const tableProperties = Object.keys(tableProps());
605
- const paginationProperties = Object.keys(paginationProps());
606
- const attrs = useAttrs();
607
- const injectTableAttrs = computed(() => {
608
- return pick(injectProps, tableProperties);
609
- });
610
- const attrsTableProps = computed(() => {
611
- return pick(
612
- camelizeProperties(attrs),
613
- tableProperties
614
- );
615
- });
616
- const {
617
- columns: tableColumns,
618
- data: tableData,
619
- searchForm,
620
- pageParam,
621
- setPageParam
622
- } = __props.table || {};
623
- const size = useModel(__props, "size");
624
- const loading = useModel(__props, "loading");
625
- const _search = async () => {
626
- var _a;
627
- try {
628
- loading.value = true;
629
- await ((_a = __props.search) == null ? void 0 : _a.call(__props));
630
- } finally {
631
- loading.value = false;
632
- }
633
- };
634
- const reset = () => {
635
- var _a;
636
- (_a = __props.table) == null ? void 0 : _a.resetQueryParams();
637
- nextTick(() => {
638
- _search();
639
- });
640
- };
641
- const slots = useSlots();
642
- const searchFormSlot = slots["search-form"];
643
- const buttonBarSlot = slots["button-bar"];
644
- const toolbarSlot = slots["toolbar"];
645
- const tableSlots = computed(() => {
646
- const customNames = /* @__PURE__ */ new Set([
647
- "search-form",
648
- "button-bar",
649
- "toolbar",
650
- "table"
651
- ]);
652
- return Object.fromEntries(
653
- Object.entries(slots).filter(([name]) => !customNames.has(name))
654
- );
655
- });
656
- const tableSlotNames = computed(() => Object.keys(tableSlots.value));
657
- const searchPage1st = () => {
658
- setPageParam == null ? void 0 : setPageParam({ current: 1 });
659
- _search();
660
- };
661
- const computedSearchFormConfig = computed(() => {
662
- var _a, _b;
663
- const container = ((_a = __props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
664
- return {
665
- ...injectProps.searchFormConfig,
666
- ...getObject(__props.searchFormConfig),
667
- container: container ? container : void 0
668
- };
669
- });
670
- const computedTableContainer = computed(() => {
671
- const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
672
- return container ? container : void 0;
673
- });
674
- const normalizedRawColumns = computed(() => {
675
- const source = __props.columns ?? (tableColumns == null ? void 0 : tableColumns.value) ?? [];
676
- const normalized = source.map((item, index) => {
677
- const current = { ...item };
678
- if (current.label === void 0 && current.title !== void 0) {
679
- current.label = current.title;
680
- }
681
- if (current.prop === void 0 && current.dataIndex !== void 0) {
682
- current.prop = Array.isArray(current.dataIndex) ? current.dataIndex.join(".") : current.dataIndex;
683
- }
684
- if (current.key === void 0) {
685
- current.key = current.prop ?? (typeof current.columnKey === "string" ? current.columnKey : void 0) ?? `col-${index}`;
686
- }
687
- return current;
688
- });
689
- if (__props.addIndexColumn ?? injectProps.addIndexColumn) {
690
- return [
691
- {
692
- key: "_index",
693
- type: "index",
694
- label: "序号",
695
- width: 80
696
- },
697
- ...normalized
698
- ];
699
- }
700
- return normalized;
701
- });
702
- const computedDataSource = computed(() => {
703
- const attrsData = attrsTableProps.value.data;
704
- return __props.data ?? attrsData ?? (tableData == null ? void 0 : tableData.value) ?? [];
705
- });
706
- const computedTableProps = computed(() => {
707
- const merged = {
708
- ...injectTableAttrs.value,
709
- ...attrsTableProps.value
710
- };
711
- delete merged.data;
712
- return merged;
713
- });
714
- const computedPagination = computed(() => {
715
- if (__props.pagination === false) return false;
716
- const pageConfig = __props.pagination ?? {};
717
- return {
718
- ...injectProps.pagination,
719
- ...pick(pageConfig, paginationProperties),
720
- currentPage: pageConfig.currentPage ?? (pageParam == null ? void 0 : pageParam.current) ?? 1,
721
- pageSize: pageConfig.pageSize ?? (pageParam == null ? void 0 : pageParam.pageSize) ?? 10,
722
- total: pageConfig.total ?? (pageParam == null ? void 0 : pageParam.total) ?? 0
723
- };
724
- });
725
- const showPagination = computed(() => computedPagination.value !== false);
726
- const onCurrentChange = (current) => {
727
- setPageParam == null ? void 0 : setPageParam({ current });
728
- _search();
729
- };
730
- const onSizeChange = (pageSize) => {
731
- setPageParam == null ? void 0 : setPageParam({ pageSize, current: 1 });
732
- _search();
733
- };
734
- const onPaginationChange = (currentPage, pageSize) => {
735
- var _a;
736
- (_a = attrs.onChange) == null ? void 0 : _a.call(attrs, currentPage, pageSize);
737
- };
738
- const showSearch = computed(() => {
739
- var _a, _b;
740
- return !!(searchFormSlot || ((_a = computedSearchFormConfig.value) == null ? void 0 : _a.hidden) !== true && searchForm && ((_b = searchForm.fields.value.filter((item) => !item.hidden)) == null ? void 0 : _b.length) > 0);
741
- });
742
- const computedControl = computed(() => {
743
- const mergedControl = __props.control ?? injectProps.control;
744
- const sizeControl = (mergedControl == null ? void 0 : mergedControl.sizeControl) ?? mergedControl;
745
- const columnControl = (mergedControl == null ? void 0 : mergedControl.columnControl) ?? mergedControl;
746
- return { sizeControl: !!sizeControl, columnControl: !!columnControl };
747
- });
748
- const resolvedSize = computed(() => {
749
- return size.value ?? attrsTableProps.value.size ?? injectTableAttrs.value.size;
750
- });
751
- onMounted(() => {
752
- if (__props.immediateSearch ?? injectProps.immediateSearch) {
753
- _search();
754
- }
755
- });
756
- return (_ctx, _cache) => {
757
- const _directive_loading = resolveDirective("loading");
758
- return openBlock(), createElementBlock("div", {
759
- class: normalizeClass(["pro-table", _ctx.$attrs.class]),
760
- style: normalizeStyle(_ctx.$attrs.style)
761
- }, [
762
- showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$b), {
763
- key: 0,
764
- component: computedSearchFormConfig.value.container
765
- }, {
766
- default: withCtx(() => [
767
- renderSlot(_ctx.$slots, "search-form", {}, () => [
768
- unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
769
- key: 0,
770
- form: unref(searchForm)
771
- }, computedSearchFormConfig.value, {
772
- onSearch: searchPage1st,
773
- onReset: reset
774
- }), null, 16, ["form"])) : createCommentVNode("", true)
775
- ], true)
776
- ]),
777
- _: 3
778
- }, 8, ["component"])) : createCommentVNode("", true),
779
- createVNode(unref(_sfc_main$b), { component: computedTableContainer.value }, {
780
- default: withCtx(() => [
781
- createElementVNode("div", _hoisted_1, [
782
- unref(buttonBarSlot) ? (openBlock(), createElementBlock("div", _hoisted_2, [
783
- renderSlot(_ctx.$slots, "button-bar", {}, void 0, true)
784
- ])) : createCommentVNode("", true),
785
- unref(toolbarSlot) ? (openBlock(), createElementBlock("div", _hoisted_3, [
786
- renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
787
- ])) : createCommentVNode("", true),
788
- computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
789
- createVNode(unref(SizeControl), {
790
- size: size.value,
791
- "onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
792
- }, null, 8, ["size"])
793
- ])) : createCommentVNode("", true),
794
- computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
795
- createVNode(unref(ColumnControl), {
796
- columns: normalizedRawColumns.value,
797
- table: __props.table
798
- }, null, 8, ["columns", "table"])
799
- ])) : createCommentVNode("", true)
800
- ]),
801
- renderSlot(_ctx.$slots, "table", {}, () => [
802
- withDirectives((openBlock(), createBlock(unref(ElTable), mergeProps({ class: "pro-table_content" }, computedTableProps.value, {
803
- size: resolvedSize.value,
804
- data: computedDataSource.value
805
- }), createSlots({
806
- default: withCtx(() => [
807
- createVNode(_sfc_main$1, { columns: normalizedRawColumns.value }, null, 8, ["columns"])
808
- ]),
809
- _: 2
810
- }, [
811
- renderList(tableSlotNames.value, (name) => {
812
- return {
813
- name,
814
- fn: withCtx((scoped) => [
815
- renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scoped)), void 0, true)
816
- ])
817
- };
818
- })
819
- ]), 1040, ["size", "data"])), [
820
- [_directive_loading, loading.value]
821
- ])
822
- ], true),
823
- showPagination.value ? (openBlock(), createBlock(unref(ElPagination), mergeProps({
824
- key: 0,
825
- class: "pro-table_pagination"
826
- }, computedPagination.value, {
827
- onCurrentChange,
828
- onSizeChange,
829
- onChange: onPaginationChange
830
- }), null, 16)) : createCommentVNode("", true)
831
- ]),
832
- _: 3
833
- }, 8, ["component"])
834
- ], 6);
835
- };
836
- }
837
- });
838
- const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8617780a"]]);
839
- function useTable(params = {}) {
840
- const { data, ...rest } = params;
841
- const coreTable = useTable$1({
842
- ...rest,
843
- dataSource: data
844
- });
845
- const { dataSource, ...tableWithoutDataSource } = coreTable;
846
- const table = {
847
- ...tableWithoutDataSource,
848
- data: dataSource
849
- };
850
- return table;
851
- }
852
- export {
853
- ProTable as default,
854
- useTable
855
- };
856
- //# sourceMappingURL=index.js.map