@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/index.js CHANGED
@@ -1,12 +1,1526 @@
1
1
  import "./element-plus-pro.css";
2
- import { a as _sfc_main } from "./form/index-oI6LGSpA.js";
3
- import { b, c, d, u, e } from "./form/index-oI6LGSpA.js";
4
- import "vue";
2
+ import { inject, computed, provide, toValue, defineComponent, renderSlot, mergeProps, normalizeProps, guardReactiveProps, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, ref, useAttrs, createCommentVNode, resolveDynamicComponent, isVNode, createTextVNode, toDisplayString, useSlots, watchEffect, withModifiers, createElementVNode, watch, withKeys, normalizeStyle, useModel, mergeModels, onMounted, resolveDirective, normalizeClass, withDirectives, nextTick } from "vue";
3
+ import { ElFormItem, ElCol, ElTable, ElPagination, useFormDisabled, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, ElRow, ElForm, ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn } from "element-plus";
4
+ import { InjectionPathKey, isPlainObject, getObject, toPath, useForm as useForm$1, omit, cloneDeep, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, get, pick, useTable as useTable$1 } from "@qin-ui/pro-components-core";
5
5
  import { useFormData } from "@qin-ui/pro-components-core";
6
- import "element-plus";
7
- import ProTable from "./table/index.js";
8
- import { useTable } from "./table/index.js";
9
- import { _ as _sfc_main$1 } from "./component-provider/index-BGGIWSkO.js";
6
+ const tableProps = () => ElTable.props || {};
7
+ const paginationProps = () => ElPagination.props || {};
8
+ const gridItemProps = () => ElCol.props || {};
9
+ const formItemProps = () => ElFormItem.props || {};
10
+ const DisabledContextKey = Symbol("pro-form-disabled-context");
11
+ const useDisabledContext = () => {
12
+ const formDisabled = useFormDisabled();
13
+ return inject(
14
+ DisabledContextKey,
15
+ computed(() => !!formDisabled.value)
16
+ );
17
+ };
18
+ const useDisabledContextProvider = (disabled) => {
19
+ provide(
20
+ DisabledContextKey,
21
+ computed(() => !!toValue(disabled))
22
+ );
23
+ };
24
+ const INJECT_CONFIG = {
25
+ "pro-table": {
26
+ injectionKey: Symbol(""),
27
+ default: {
28
+ pagination: {
29
+ layout: "total, sizes, prev, pager, next, jumper",
30
+ pageSizes: [10, 20, 30, 40, 50, 100],
31
+ background: true
32
+ },
33
+ searchFormConfig: {
34
+ layout: "grid",
35
+ expand: { minExpandRows: 2, expandStatus: false }
36
+ },
37
+ control: true,
38
+ addIndexColumn: true
39
+ }
40
+ },
41
+ "pro-form": {
42
+ injectionKey: Symbol(""),
43
+ default: { grid: { gutter: 24 } }
44
+ },
45
+ "pro-form-item": {
46
+ injectionKey: Symbol(""),
47
+ default: { span: 8 }
48
+ },
49
+ input: {
50
+ injectionKey: Symbol(""),
51
+ default: { maxlength: 100, clearable: true, placeholder: "请输入" }
52
+ },
53
+ "input.textarea": {
54
+ injectionKey: Symbol(""),
55
+ default: {
56
+ maxlength: 200,
57
+ autosize: { minRows: 3, maxRows: 6 },
58
+ showWordLimit: true,
59
+ clearable: true,
60
+ placeholder: "请输入"
61
+ }
62
+ },
63
+ "input.password": {
64
+ injectionKey: Symbol(""),
65
+ default: {
66
+ showPassword: true,
67
+ maxlength: 100,
68
+ clearable: true,
69
+ placeholder: "请输入"
70
+ }
71
+ },
72
+ "input-number": {
73
+ injectionKey: Symbol(""),
74
+ default: {
75
+ max: 10 ** 15 - 1,
76
+ min: -1000000000000001,
77
+ controls: false,
78
+ placeholder: "请输入",
79
+ style: { width: "100%" }
80
+ }
81
+ },
82
+ autocomplete: {
83
+ injectionKey: Symbol(""),
84
+ default: { clearable: true, placeholder: "请输入" }
85
+ },
86
+ select: {
87
+ injectionKey: Symbol(""),
88
+ default: { clearable: true, placeholder: "请选择" }
89
+ },
90
+ cascader: {
91
+ injectionKey: Symbol(""),
92
+ default: { clearable: true, placeholder: "请选择" }
93
+ },
94
+ "date-picker": {
95
+ injectionKey: Symbol(""),
96
+ default: { style: { width: "100%" }, placeholder: "请选择" }
97
+ },
98
+ "date-picker.date": {
99
+ injectionKey: Symbol(""),
100
+ default: { style: { width: "100%" }, placeholder: "请选择" }
101
+ },
102
+ "date-picker.dates": {
103
+ injectionKey: Symbol(""),
104
+ default: { style: { width: "100%" }, placeholder: "请选择" }
105
+ },
106
+ "date-picker.daterange": {
107
+ injectionKey: Symbol(""),
108
+ default: {
109
+ style: { width: "100%" },
110
+ startPlaceholder: "开始日期",
111
+ endPlaceholder: "结束日期"
112
+ }
113
+ },
114
+ "date-picker.week": {
115
+ injectionKey: Symbol(""),
116
+ default: { style: { width: "100%" }, placeholder: "请选择" }
117
+ },
118
+ "date-picker.month": {
119
+ injectionKey: Symbol(""),
120
+ default: { style: { width: "100%" }, placeholder: "请选择" }
121
+ },
122
+ "date-picker.monthrange": {
123
+ injectionKey: Symbol(""),
124
+ default: {
125
+ style: { width: "100%" },
126
+ startPlaceholder: "开始月份",
127
+ endPlaceholder: "结束月份"
128
+ }
129
+ },
130
+ "date-picker.months": {
131
+ injectionKey: Symbol(""),
132
+ default: { style: { width: "100%" }, placeholder: "请选择" }
133
+ },
134
+ "date-picker.yearrange": {
135
+ injectionKey: Symbol(""),
136
+ default: {
137
+ style: { width: "100%" },
138
+ startPlaceholder: "开始年份",
139
+ endPlaceholder: "结束年份"
140
+ }
141
+ },
142
+ "date-picker.year": {
143
+ injectionKey: Symbol(""),
144
+ default: { style: { width: "100%" }, placeholder: "请选择" }
145
+ },
146
+ "date-picker.years": {
147
+ injectionKey: Symbol(""),
148
+ default: { style: { width: "100%" }, placeholder: "请选择" }
149
+ },
150
+ "date-picker.datetime": {
151
+ injectionKey: Symbol(""),
152
+ default: { style: { width: "100%" }, placeholder: "请选择" }
153
+ },
154
+ "date-picker.datetimerange": {
155
+ injectionKey: Symbol(""),
156
+ default: {
157
+ style: { width: "100%" },
158
+ startPlaceholder: "开始时间",
159
+ endPlaceholder: "结束时间"
160
+ }
161
+ },
162
+ "time-picker": {
163
+ injectionKey: Symbol(""),
164
+ default: { style: { width: "100%" }, placeholder: "请选择" }
165
+ },
166
+ "time-select": {
167
+ injectionKey: Symbol(""),
168
+ default: { style: { width: "100%" }, placeholder: "请选择" }
169
+ },
170
+ "checkbox-group": {
171
+ injectionKey: Symbol(""),
172
+ default: {}
173
+ },
174
+ "radio-group": {
175
+ injectionKey: Symbol(""),
176
+ default: {}
177
+ },
178
+ switch: {
179
+ injectionKey: Symbol(""),
180
+ default: { modelProp: "modelValue" }
181
+ },
182
+ slider: {
183
+ injectionKey: Symbol(""),
184
+ default: {}
185
+ },
186
+ "tree-select": {
187
+ injectionKey: Symbol(""),
188
+ default: { clearable: true, placeholder: "请选择" }
189
+ },
190
+ transfer: {
191
+ injectionKey: Symbol(""),
192
+ default: {}
193
+ }
194
+ };
195
+ const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
196
+ const DYNAMIC_INJECT_CONFIG = /* @__PURE__ */ Object.create(null);
197
+ const getInjectConfig = (key) => {
198
+ return INJECT_CONFIG[key] || DYNAMIC_INJECT_CONFIG[key];
199
+ };
200
+ const ensureInjectConfig = (key) => {
201
+ const existing = getInjectConfig(key);
202
+ if (existing) return existing;
203
+ const created = {
204
+ injectionKey: Symbol(`dynamic:${key}`),
205
+ default: {}
206
+ };
207
+ DYNAMIC_INJECT_CONFIG[key] = created;
208
+ return created;
209
+ };
210
+ const FORM_ITEM_SLOT_KEYS = ["label", "error"];
211
+ const componentMap = {
212
+ "input": ElInput,
213
+ "input-number": ElInputNumber,
214
+ "autocomplete": ElAutocomplete,
215
+ "select": ElSelect,
216
+ "cascader": ElCascader,
217
+ "date-picker": ElDatePicker,
218
+ "time-picker": ElTimePicker,
219
+ "time-select": ElTimeSelect,
220
+ "checkbox-group": ElCheckboxGroup,
221
+ "radio-group": ElRadioGroup,
222
+ "switch": ElSwitch,
223
+ "slider": ElSlider,
224
+ "tree-select": ElTreeSelect,
225
+ "transfer": ElTransfer
226
+ };
227
+ const TeleportComponentNamePrefix = "TeleportComponent_";
228
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
229
+ __name: "index",
230
+ props: {
231
+ path: {}
232
+ },
233
+ setup(__props) {
234
+ const props = __props;
235
+ const namePath = computed(() => {
236
+ return Array.isArray(props.path) ? props.path.join(".") : props.path;
237
+ });
238
+ provide(InjectionPathKey, namePath);
239
+ return (_ctx, _cache) => {
240
+ return renderSlot(_ctx.$slots, "default", { path: namePath.value });
241
+ };
242
+ }
243
+ });
244
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
245
+ __name: "index",
246
+ props: {
247
+ field: {}
248
+ },
249
+ setup(__props) {
250
+ const formItemPropKeys = Object.keys(formItemProps());
251
+ const gridItemPropKeys = Object.keys(gridItemProps());
252
+ const props = __props;
253
+ const config = INJECT_CONFIG["pro-form-item"];
254
+ const injectFormItemProps = inject(config.injectionKey, config.default);
255
+ const groupedAttributes = computed(() => {
256
+ let gridItemProps2 = {};
257
+ let formItemProps2 = {};
258
+ const componentProps = { slots: {} };
259
+ const formItemSlots = {};
260
+ if (isPlainObject(props.field)) {
261
+ const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = props.field;
262
+ const {
263
+ class: injectClassName,
264
+ style: injectStyle,
265
+ span: injectSpan,
266
+ formItemContainer: injectFormItemContainer,
267
+ xs,
268
+ sm,
269
+ md,
270
+ lg,
271
+ xl,
272
+ ...injectRest
273
+ } = injectFormItemProps;
274
+ const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
275
+ gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
276
+ formItemProps2 = mergeProps(
277
+ injectRest,
278
+ { class: injectClassName, style: injectStyle },
279
+ { class: toValue(formItemClass), style: toValue(formItemStyle) },
280
+ formItemDataAttrs
281
+ );
282
+ formItemProps2.container = formItemContainer ?? injectFormItemContainer;
283
+ Object.keys(rest).forEach((k) => {
284
+ if (gridItemPropKeys.includes(k)) {
285
+ gridItemProps2[k] = rest[k];
286
+ } else if (formItemPropKeys.includes(k)) {
287
+ formItemProps2[k] = rest[k];
288
+ } else {
289
+ componentProps[k] = rest[k];
290
+ }
291
+ });
292
+ Object.assign(componentProps, componentDataAttrs);
293
+ Object.keys(slots).forEach((k) => {
294
+ if (FORM_ITEM_SLOT_KEYS.includes(k)) {
295
+ formItemSlots[k] = slots[k];
296
+ } else {
297
+ componentProps["slots"][k] = slots[k];
298
+ }
299
+ });
300
+ }
301
+ return { gridItemProps: gridItemProps2, formItemProps: formItemProps2, componentProps, formItemSlots };
302
+ });
303
+ return (_ctx, _cache) => {
304
+ return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(groupedAttributes.value)));
305
+ };
306
+ }
307
+ });
308
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
309
+ ...{ name: "BaseFormItem", inheritAttrs: false },
310
+ __name: "index",
311
+ props: {
312
+ grid: { type: [Boolean, Object], default: () => void 0 },
313
+ fields: { default: () => [] },
314
+ disabled: { type: Boolean, default: () => void 0 }
315
+ },
316
+ setup(__props) {
317
+ const validFields = computed(() => {
318
+ var _a, _b;
319
+ return (_b = (_a = __props.fields).filter) == null ? void 0 : _b.call(_a, (field) => !field.hidden);
320
+ });
321
+ useDisabledContextProvider(computed(() => __props.disabled));
322
+ const config = INJECT_CONFIG["pro-form"];
323
+ const { grid: injectGrid } = inject(config.injectionKey, config.default);
324
+ const enableGrid = computed(() => {
325
+ if (__props.grid !== void 0) return !!__props.grid;
326
+ return !!injectGrid;
327
+ });
328
+ const computedGridProps = computed(() => {
329
+ return enableGrid.value ? { ...getObject(injectGrid), ...getObject(__props.grid) } : {};
330
+ });
331
+ const formItemRefs = [];
332
+ const componentRefs = [];
333
+ const onFormItemMounted = (index2, formItemProps2) => {
334
+ const field = validFields.value[index2];
335
+ Object.assign(field, {
336
+ getFormItemRef: () => formItemRefs[index2],
337
+ getFormItemComputedProps: () => formItemProps2
338
+ });
339
+ };
340
+ const onComponentMounted = (index2) => {
341
+ const field = validFields.value[index2];
342
+ Object.assign(field, {
343
+ getComponentRef: () => {
344
+ var _a;
345
+ return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentRef();
346
+ },
347
+ getComponentComputedProps: () => {
348
+ var _a;
349
+ return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentComputedProps();
350
+ }
351
+ });
352
+ };
353
+ return (_ctx, _cache) => {
354
+ const _component_BaseFormItem = resolveComponent("BaseFormItem");
355
+ return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
356
+ component: enableGrid.value ? unref(ElRow) : void 0
357
+ }, computedGridProps.value, { style: { "width": "100%" } }), {
358
+ default: withCtx(() => [
359
+ (openBlock(true), createElementBlock(Fragment, null, renderList(validFields.value, ({ path: _path, ...field }, index2) => {
360
+ return openBlock(), createBlock(_sfc_main$h, mergeProps({
361
+ key: unref(toPath)(toValue(_path ?? index2)).join(".") || index2
362
+ }, { ref_for: true }, { path: _path }), {
363
+ default: withCtx(({ path }) => [
364
+ createVNode(_sfc_main$g, { field }, {
365
+ default: withCtx(({
366
+ gridItemProps: gridItemProps2,
367
+ formItemProps: { container, ...formItemProps2 },
368
+ componentProps,
369
+ formItemSlots
370
+ }) => [
371
+ createVNode(unref(_sfc_main$d), mergeProps({
372
+ component: enableGrid.value ? unref(ElCol) : void 0
373
+ }, { ref_for: true }, gridItemProps2), {
374
+ default: withCtx(() => [
375
+ createVNode(unref(_sfc_main$d), {
376
+ component: container,
377
+ path
378
+ }, {
379
+ default: withCtx(() => [
380
+ createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, formItemProps2, {
381
+ ref_for: true,
382
+ ref: (el) => formItemRefs[index2] = el,
383
+ prop: unref(toPath)(path).join("."),
384
+ path,
385
+ onVnodeMounted: ($event) => onFormItemMounted(index2, formItemProps2)
386
+ }), createSlots({
387
+ default: withCtx(() => [
388
+ field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
389
+ key: 0,
390
+ grid: field.grid ?? __props.grid,
391
+ fields: field.fields,
392
+ disabled: toValue(field.disabled)
393
+ }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
394
+ key: 1,
395
+ ref_for: true,
396
+ ref: (el) => componentRefs[index2] = el
397
+ }, { ref_for: true }, componentProps, {
398
+ path,
399
+ onVnodeMounted: ($event) => onComponentMounted(index2)
400
+ }), null, 16, ["path", "onVnodeMounted"]))
401
+ ]),
402
+ _: 2
403
+ }, [
404
+ renderList(formItemSlots, (slot, name) => {
405
+ return {
406
+ name,
407
+ fn: withCtx((scoped) => [
408
+ createVNode(unref(_sfc_main$c), mergeProps({
409
+ path,
410
+ component: slot
411
+ }, { ref_for: true }, scoped), null, 16, ["path", "component"])
412
+ ])
413
+ };
414
+ })
415
+ ]), 1040, ["prop", "path", "onVnodeMounted"])
416
+ ]),
417
+ _: 2
418
+ }, 1032, ["component", "path"])
419
+ ]),
420
+ _: 2
421
+ }, 1040, ["component"])
422
+ ]),
423
+ _: 2
424
+ }, 1032, ["field"])
425
+ ]),
426
+ _: 2
427
+ }, 1040);
428
+ }), 128))
429
+ ]),
430
+ _: 1
431
+ }, 16, ["component"]);
432
+ };
433
+ }
434
+ });
435
+ const _export_sfc = (sfc, props) => {
436
+ const target = sfc.__vccOpts || sfc;
437
+ for (const [key, val] of props) {
438
+ target[key] = val;
439
+ }
440
+ return target;
441
+ };
442
+ const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-d52742ce"]]);
443
+ function useForm(...args) {
444
+ return useForm$1(...args);
445
+ }
446
+ const getInitProps = (field) => {
447
+ const { component, type } = field;
448
+ if (typeof component === "string") {
449
+ const k = [component, type].filter(Boolean).join(".");
450
+ const config = getInjectConfig(k);
451
+ if (!config) return {};
452
+ const injectProps = inject(config.injectionKey, config.default);
453
+ return injectProps;
454
+ }
455
+ return {};
456
+ };
457
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
458
+ ...{ name: "BaseField", inheritAttrs: false },
459
+ __name: "index",
460
+ props: {
461
+ component: { default: () => void 0 },
462
+ path: { default: "" }
463
+ },
464
+ setup(__props, { expose: __expose }) {
465
+ const form = useForm(false);
466
+ const { getFormData, setFormData } = form;
467
+ const componentRef = ref();
468
+ const attrs = useAttrs();
469
+ function getOldValue() {
470
+ return cloneDeep(getFormData == null ? void 0 : getFormData(__props.path));
471
+ }
472
+ const value = computed({
473
+ get() {
474
+ let val = getFormData == null ? void 0 : getFormData(__props.path);
475
+ const { valueFormatter } = groupedAttrs.value;
476
+ if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
477
+ val = valueFormatter.get(val);
478
+ }
479
+ return val;
480
+ },
481
+ set(val) {
482
+ let newVal = val;
483
+ const { valueFormatter } = groupedAttrs.value;
484
+ if (valueFormatter) {
485
+ if (typeof valueFormatter === "function") {
486
+ newVal = valueFormatter(val, getOldValue());
487
+ } else if (typeof valueFormatter.set === "function") {
488
+ newVal = valueFormatter.set(val, getOldValue());
489
+ }
490
+ }
491
+ setFormData == null ? void 0 : setFormData(__props.path, newVal);
492
+ }
493
+ });
494
+ const parentDisabled = useDisabledContext();
495
+ const groupedAttrs = computed(() => {
496
+ const initProps = getInitProps({
497
+ component: __props.component,
498
+ type: attrs.type
499
+ });
500
+ const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
501
+ const mergedProps = mergeProps(
502
+ initProps,
503
+ attrs,
504
+ { class: attrs.componentClass, style: attrs.componentStyle },
505
+ { class: initProps.componentClass, style: initProps.componentStyle },
506
+ { disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
507
+ { modelProp: modelPropName }
508
+ );
509
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...rest } = mergedProps;
510
+ const modelBindingProp = modelProp ?? "modelValue";
511
+ const bindAttrs = omit(rest, [
512
+ modelBindingProp,
513
+ `onUpdate:${modelBindingProp}`
514
+ ]);
515
+ return {
516
+ attrs: bindAttrs,
517
+ slots,
518
+ componentContainer,
519
+ modelProp: modelBindingProp,
520
+ valueFormatter
521
+ };
522
+ });
523
+ const teleportComponent = inject(
524
+ `${TeleportComponentNamePrefix}${__props.path}`,
525
+ void 0
526
+ );
527
+ const customComponents = inject(INJECT_COMPONENTS, {});
528
+ const is = computed(() => {
529
+ if (teleportComponent) return teleportComponent;
530
+ if (typeof __props.component === "string") {
531
+ return customComponents[__props.component] || componentMap[__props.component] || __props.component;
532
+ }
533
+ return __props.component;
534
+ });
535
+ __expose({
536
+ getComponentRef: () => componentRef.value,
537
+ getComponentComputedProps: () => groupedAttrs.value.attrs
538
+ });
539
+ return (_ctx, _cache) => {
540
+ return openBlock(), createBlock(unref(_sfc_main$d), {
541
+ component: groupedAttrs.value.componentContainer,
542
+ path: __props.path
543
+ }, {
544
+ default: withCtx(() => [
545
+ is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
546
+ ref_key: "componentRef",
547
+ ref: componentRef,
548
+ [`${groupedAttrs.value.modelProp}`]: value.value,
549
+ [`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
550
+ path: __props.path
551
+ }), createSlots({ _: 2 }, [
552
+ renderList(groupedAttrs.value.slots, (slot, name) => {
553
+ return {
554
+ name,
555
+ fn: withCtx((scoped) => [
556
+ createVNode(unref(_sfc_main$c), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
557
+ ])
558
+ };
559
+ })
560
+ ]), 1040, ["path"])) : createCommentVNode("", true)
561
+ ]),
562
+ _: 1
563
+ }, 8, ["component", "path"]);
564
+ };
565
+ }
566
+ });
567
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
568
+ ...{ name: "ContainerFragment", inheritAttrs: false },
569
+ __name: "index",
570
+ props: {
571
+ component: { type: [Object, Function] }
572
+ },
573
+ setup(__props) {
574
+ return (_ctx, _cache) => {
575
+ return __props.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
576
+ default: withCtx(() => [
577
+ renderSlot(_ctx.$slots, "default")
578
+ ]),
579
+ _: 3
580
+ }, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
581
+ };
582
+ }
583
+ });
584
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
585
+ ...{ name: "SlotComponent", inheritAttrs: false },
586
+ __name: "index",
587
+ props: {
588
+ component: { type: [Object, Function, String, Number, Boolean, null] }
589
+ },
590
+ setup(__props) {
591
+ return (_ctx, _cache) => {
592
+ return isVNode(__props.component) || typeof __props.component === "function" ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
593
+ createTextVNode(toDisplayString(__props.component), 1)
594
+ ], 64));
595
+ };
596
+ }
597
+ });
598
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
599
+ ...{ name: "ProForm", inheritAttrs: false },
600
+ __name: "index",
601
+ props: {
602
+ grid: { type: [Boolean, Object], default: false },
603
+ form: { default: () => ({}) }
604
+ },
605
+ setup(__props) {
606
+ provide(InjectionFormKey, __props.form);
607
+ const { formData, fields, setFormRef } = __props.form;
608
+ const _fields = computed(() => fields.value);
609
+ const config = INJECT_CONFIG["pro-form"];
610
+ const attrs = useAttrs();
611
+ const { grid: _injectGrid, ...injectAttrs } = inject(
612
+ config.injectionKey,
613
+ config.default
614
+ );
615
+ const slots = useSlots();
616
+ watchEffect(() => {
617
+ Object.keys(slots).forEach((name) => {
618
+ if (name === "default") return;
619
+ provide(`${TeleportComponentNamePrefix}${name}`, slots[name]);
620
+ });
621
+ });
622
+ return (_ctx, _cache) => {
623
+ return openBlock(), createBlock(unref(ElForm), mergeProps({
624
+ ref: (el) => {
625
+ var _a;
626
+ return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
627
+ },
628
+ model: unref(formData)
629
+ }, mergeProps(injectAttrs, unref(camelizeProperties)(unref(attrs))), {
630
+ class: "pro-form",
631
+ onSubmit: _cache[0] || (_cache[0] = withModifiers(() => {
632
+ }, ["prevent"]))
633
+ }), {
634
+ default: withCtx(() => [
635
+ createVNode(unref(BaseFormItem), {
636
+ fields: _fields.value,
637
+ grid: __props.grid
638
+ }, null, 8, ["fields", "grid"]),
639
+ renderSlot(_ctx.$slots, "default")
640
+ ]),
641
+ _: 3
642
+ }, 16, ["model"]);
643
+ };
644
+ }
645
+ });
646
+ function useFields(initFields) {
647
+ return useFields$1(initFields);
648
+ }
649
+ function useFormRef() {
650
+ return useFormRef$1();
651
+ }
652
+ const _sfc_main$a = {};
653
+ const _hoisted_1$5 = {
654
+ focusable: "false",
655
+ "data-icon": "down",
656
+ width: "1em",
657
+ height: "1em",
658
+ fill: "currentColor",
659
+ "aria-hidden": "true",
660
+ viewBox: "64 64 896 896"
661
+ };
662
+ function _sfc_render$4(_ctx, _cache) {
663
+ return openBlock(), createElementBlock("svg", _hoisted_1$5, [..._cache[0] || (_cache[0] = [
664
+ 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)
665
+ ])]);
666
+ }
667
+ const DownOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$4]]);
668
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
669
+ ...{ name: "SearchForm" },
670
+ __name: "SearchForm",
671
+ props: {
672
+ form: {},
673
+ layout: { default: "grid" },
674
+ expand: { type: [Boolean, Object], default: true },
675
+ searchButton: { type: [Object, Function, Boolean], default: void 0 },
676
+ resetButton: { type: [Object, Function, Boolean], default: void 0 },
677
+ expandButton: { type: [Object, Function, Boolean], default: void 0 },
678
+ rowGap: { default: 16 },
679
+ columnGap: { default: 24 },
680
+ class: {},
681
+ style: {}
682
+ },
683
+ emits: ["search", "reset"],
684
+ setup(__props, { emit: __emit }) {
685
+ const emit = __emit;
686
+ const proFormHeight = ref("unset");
687
+ const collapseHeight = ref(0);
688
+ let rowHeight = 32;
689
+ const computedExpand = computed(() => {
690
+ if (!__props.expand) return false;
691
+ if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
692
+ return {
693
+ minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
694
+ expandStatus: __props.expand.expandStatus ?? false
695
+ };
696
+ });
697
+ const showExpandToggle = ref(false);
698
+ const expandStatus = ref(true);
699
+ const changeExpandStatus = () => {
700
+ expandStatus.value = !expandStatus.value;
701
+ };
702
+ const { formRef, getFormData } = __props.form;
703
+ const setInitExpandStatus = () => {
704
+ expandStatus.value = false;
705
+ if (formRef.value && __props.expand) {
706
+ const formEl = formRef.value.$el;
707
+ const formItemsEl = formEl.querySelectorAll(
708
+ "[class*='-form-item'] > [path]"
709
+ );
710
+ const observer = new IntersectionObserver(
711
+ (entries) => {
712
+ expandStatus.value = entries.some((e) => {
713
+ if (e.intersectionRatio === 0) {
714
+ const path = e.target.getAttribute("path");
715
+ const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
716
+ return ![null, void 0].includes(searchFieldValue);
717
+ }
718
+ return __props.expand.expandStatus;
719
+ });
720
+ observer.disconnect();
721
+ },
722
+ { root: formEl }
723
+ );
724
+ formItemsEl.forEach((element) => {
725
+ observer.observe(element);
726
+ });
727
+ }
728
+ };
729
+ watch(
730
+ [
731
+ () => {
732
+ var _a, _b, _c;
733
+ 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;
734
+ },
735
+ () => formRef.value,
736
+ () => __props.expand
737
+ ],
738
+ () => {
739
+ var _a, _b, _c, _d, _e;
740
+ if (!__props.expand || !expandStatus.value || !formRef.value) return;
741
+ const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
742
+ const { height = 0 } = ((_b = proFormEl == null ? void 0 : proFormEl.getBoundingClientRect) == null ? void 0 : _b.call(proFormEl)) || {};
743
+ proFormHeight.value = height;
744
+ 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;
745
+ },
746
+ { flush: "post", immediate: true }
747
+ );
748
+ watchEffect(
749
+ () => {
750
+ if (typeof proFormHeight.value !== "number") return;
751
+ if (__props.layout === "grid" && computedExpand.value) {
752
+ const { minExpandRows } = computedExpand.value;
753
+ collapseHeight.value = Math.min(
754
+ minExpandRows * rowHeight + (minExpandRows - 1) * __props.rowGap,
755
+ +proFormHeight.value
756
+ );
757
+ showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
758
+ if (showExpandToggle.value) {
759
+ setInitExpandStatus();
760
+ }
761
+ } else {
762
+ showExpandToggle.value = false;
763
+ }
764
+ },
765
+ { flush: "post" }
766
+ );
767
+ const layoutProps = computed(
768
+ () => __props.layout === "grid" ? {
769
+ grid: {
770
+ gutter: __props.columnGap,
771
+ style: { rowGap: `${__props.rowGap}px` }
772
+ },
773
+ style: {
774
+ display: "flex",
775
+ overflow: "hidden",
776
+ columnGap: `${__props.columnGap}px`,
777
+ height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
778
+ }
779
+ } : {
780
+ inline: true,
781
+ style: {
782
+ display: "flex",
783
+ flexWrap: "wrap",
784
+ gap: `${__props.rowGap}px ${__props.columnGap}px`
785
+ },
786
+ grid: false
787
+ }
788
+ );
789
+ const onReset = () => {
790
+ emit("reset");
791
+ };
792
+ const onSearch = () => {
793
+ emit("search");
794
+ };
795
+ return (_ctx, _cache) => {
796
+ return openBlock(), createBlock(unref(_sfc_main$b), mergeProps(layoutProps.value, {
797
+ form: __props.form,
798
+ class: "pro-table_search-form transition",
799
+ onKeyup: withKeys(onSearch, ["enter"])
800
+ }), {
801
+ default: withCtx(() => [
802
+ createVNode(unref(ElSpace), {
803
+ alignment: "start",
804
+ class: "pro-table_search-form_button-group"
805
+ }, {
806
+ default: withCtx(() => [
807
+ renderSlot(_ctx.$slots, "reset-button", { onClick: onReset }, () => [
808
+ __props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
809
+ __props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.resetButton), {
810
+ key: 0,
811
+ onClick: onReset
812
+ })) : (openBlock(), createBlock(unref(ElButton), {
813
+ key: 1,
814
+ class: "pro-table_search-form_reset-button",
815
+ onClick: onReset
816
+ }, {
817
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
818
+ createTextVNode("重置", -1)
819
+ ])]),
820
+ _: 1
821
+ }))
822
+ ], 64)) : createCommentVNode("", true)
823
+ ], true),
824
+ renderSlot(_ctx.$slots, "search-button", { onClick: onSearch }, () => [
825
+ __props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
826
+ __props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.searchButton), {
827
+ key: 0,
828
+ onClick: onSearch
829
+ })) : (openBlock(), createBlock(unref(ElButton), {
830
+ key: 1,
831
+ class: "pro-table_search-form_search-button",
832
+ type: "primary",
833
+ "native-type": "submit",
834
+ onClick: onSearch
835
+ }, {
836
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
837
+ createTextVNode(" 查询 ", -1)
838
+ ])]),
839
+ _: 1
840
+ }))
841
+ ], 64)) : createCommentVNode("", true)
842
+ ], true),
843
+ renderSlot(_ctx.$slots, "expand-button", { onClick: changeExpandStatus }, () => [
844
+ __props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
845
+ __props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.expandButton), {
846
+ key: 0,
847
+ "expand-status": expandStatus.value,
848
+ onClick: changeExpandStatus
849
+ }, null, 8, ["expand-status"])) : (openBlock(), createBlock(unref(ElButton), {
850
+ key: 1,
851
+ text: "",
852
+ class: "pro-table_search-form_expand-toggle-button",
853
+ onClick: changeExpandStatus
854
+ }, {
855
+ default: withCtx(() => [
856
+ createTextVNode(toDisplayString(expandStatus.value ? "收起" : "展开") + " ", 1),
857
+ createVNode(DownOutlined, {
858
+ class: "transition",
859
+ style: normalizeStyle([{ "margin-left": "4px" }, { transform: `rotate(${expandStatus.value ? -180 : 0}deg)` }])
860
+ }, null, 8, ["style"])
861
+ ]),
862
+ _: 1
863
+ }))
864
+ ], 64)) : createCommentVNode("", true)
865
+ ], true)
866
+ ]),
867
+ _: 3
868
+ })
869
+ ]),
870
+ _: 3
871
+ }, 16, ["form"]);
872
+ };
873
+ }
874
+ });
875
+ const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-512bc2e5"]]);
876
+ const _sfc_main$8 = {};
877
+ const _hoisted_1$4 = { class: "pro-table_search-form-container" };
878
+ function _sfc_render$3(_ctx, _cache) {
879
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
880
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
881
+ ]);
882
+ }
883
+ const DefaultSearchFormContainer = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$3], ["__scopeId", "data-v-45e627f4"]]);
884
+ const _sfc_main$7 = {};
885
+ const _hoisted_1$3 = { class: "pro-table_table-container" };
886
+ function _sfc_render$2(_ctx, _cache) {
887
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
888
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
889
+ ]);
890
+ }
891
+ const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$2], ["__scopeId", "data-v-55d01897"]]);
892
+ const _sfc_main$6 = {};
893
+ const _hoisted_1$2 = {
894
+ focusable: "false",
895
+ "data-icon": "column-height",
896
+ width: "1em",
897
+ height: "1em",
898
+ fill: "currentColor",
899
+ "aria-hidden": "true",
900
+ viewBox: "64 64 896 896"
901
+ };
902
+ function _sfc_render$1(_ctx, _cache) {
903
+ return openBlock(), createElementBlock("svg", _hoisted_1$2, [..._cache[0] || (_cache[0] = [
904
+ 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)
905
+ ])]);
906
+ }
907
+ const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$1]]);
908
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
909
+ __name: "SizeControl",
910
+ props: {
911
+ "size": {},
912
+ "sizeModifiers": {}
913
+ },
914
+ emits: ["update:size"],
915
+ setup(__props) {
916
+ const size = useModel(__props, "size");
917
+ size.value = size.value ?? "default";
918
+ const items = [
919
+ { label: "默认", key: "default" },
920
+ { label: "中等", key: "large" },
921
+ { label: "紧凑", key: "small" }
922
+ ];
923
+ return (_ctx, _cache) => {
924
+ return openBlock(), createBlock(unref(ElDropdown), {
925
+ trigger: "click",
926
+ onCommand: _cache[0] || (_cache[0] = (val) => size.value = val)
927
+ }, {
928
+ dropdown: withCtx(() => [
929
+ createVNode(unref(ElDropdownMenu), null, {
930
+ default: withCtx(() => [
931
+ (openBlock(), createElementBlock(Fragment, null, renderList(items, (item) => {
932
+ return createVNode(unref(ElDropdownItem), {
933
+ key: item.key,
934
+ command: item.key,
935
+ disabled: item.key === size.value
936
+ }, {
937
+ default: withCtx(() => [
938
+ createTextVNode(toDisplayString(item.label), 1)
939
+ ]),
940
+ _: 2
941
+ }, 1032, ["command", "disabled"]);
942
+ }), 64))
943
+ ]),
944
+ _: 1
945
+ })
946
+ ]),
947
+ default: withCtx(() => [
948
+ createVNode(unref(ElButton), {
949
+ text: "",
950
+ class: "pro-table_size-control_button"
951
+ }, {
952
+ default: withCtx(() => [
953
+ createVNode(ColumnHeightOutlined)
954
+ ]),
955
+ _: 1
956
+ })
957
+ ]),
958
+ _: 1
959
+ });
960
+ };
961
+ }
962
+ });
963
+ const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-7af52d04"]]);
964
+ const _sfc_main$4 = {};
965
+ const _hoisted_1$1 = {
966
+ focusable: "false",
967
+ "data-icon": "filter",
968
+ width: "1em",
969
+ height: "1em",
970
+ fill: "currentColor",
971
+ "aria-hidden": "true",
972
+ viewBox: "64 64 896 896"
973
+ };
974
+ function _sfc_render(_ctx, _cache) {
975
+ return openBlock(), createElementBlock("svg", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
976
+ 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)
977
+ ])]);
978
+ }
979
+ const FilterOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render]]);
980
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
981
+ __name: "ColumnControl",
982
+ props: {
983
+ columns: {},
984
+ table: { default: () => void 0 }
985
+ },
986
+ setup(__props) {
987
+ const open = ref(false);
988
+ const checkAll = ref(false);
989
+ const indeterminate = ref(false);
990
+ const getColumnKey = (column, index2) => {
991
+ const key = column.key ?? column.prop;
992
+ if (key === void 0 || key === null) return `__idx_${index2}`;
993
+ return Array.isArray(key) ? key.join(".") : String(key);
994
+ };
995
+ const checkedColumnsOptions = computed(
996
+ () => __props.columns.map((item, index2) => ({
997
+ label: String(item.label ?? item.prop ?? `列${index2 + 1}`),
998
+ value: getColumnKey(item, index2),
999
+ checked: !item.hidden,
1000
+ column: item
1001
+ }))
1002
+ );
1003
+ const checkedColumnKeys = computed({
1004
+ get() {
1005
+ return checkedColumnsOptions.value.flatMap(
1006
+ (item) => item.checked ? item.value : []
1007
+ );
1008
+ },
1009
+ set(val) {
1010
+ checkedColumnsOptions.value.forEach((item) => {
1011
+ var _a;
1012
+ (_a = __props.table) == null ? void 0 : _a.setColumn(item.value, {
1013
+ hidden: !val.includes(item.value)
1014
+ });
1015
+ });
1016
+ }
1017
+ });
1018
+ const onCheckAllChange = (value) => {
1019
+ var _a;
1020
+ const checked = !!(((_a = value == null ? void 0 : value.target) == null ? void 0 : _a.checked) ?? value);
1021
+ checkedColumnKeys.value = checked ? checkedColumnsOptions.value.map((item) => item.value) : [];
1022
+ indeterminate.value = false;
1023
+ };
1024
+ const toggleColumnsItem = (val) => {
1025
+ if (checkedColumnKeys.value.includes(val)) {
1026
+ checkedColumnKeys.value = checkedColumnKeys.value.filter(
1027
+ (item) => item !== val
1028
+ );
1029
+ } else {
1030
+ checkedColumnKeys.value = [...checkedColumnKeys.value, val];
1031
+ }
1032
+ };
1033
+ watch(
1034
+ checkedColumnKeys,
1035
+ (val) => {
1036
+ indeterminate.value = !!val.length && val.length < checkedColumnsOptions.value.length;
1037
+ checkAll.value = val.length > 0 && val.length === checkedColumnsOptions.value.length;
1038
+ },
1039
+ { immediate: true }
1040
+ );
1041
+ return (_ctx, _cache) => {
1042
+ return openBlock(), createBlock(unref(ElDropdown), {
1043
+ trigger: "click",
1044
+ "hide-on-click": false,
1045
+ visible: open.value,
1046
+ onVisibleChange: _cache[0] || (_cache[0] = (val) => open.value = val)
1047
+ }, {
1048
+ dropdown: withCtx(() => [
1049
+ createVNode(unref(ElDropdownMenu), null, {
1050
+ default: withCtx(() => [
1051
+ createVNode(unref(ElDropdownItem), {
1052
+ disabled: true,
1053
+ divided: false
1054
+ }, {
1055
+ default: withCtx(() => [
1056
+ createVNode(unref(ElCheckbox), {
1057
+ "model-value": checkAll.value,
1058
+ indeterminate: indeterminate.value,
1059
+ onChange: onCheckAllChange
1060
+ }, {
1061
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
1062
+ createTextVNode(" 全选 ", -1)
1063
+ ])]),
1064
+ _: 1
1065
+ }, 8, ["model-value", "indeterminate"])
1066
+ ]),
1067
+ _: 1
1068
+ }),
1069
+ (openBlock(true), createElementBlock(Fragment, null, renderList(checkedColumnsOptions.value, (item) => {
1070
+ return openBlock(), createBlock(unref(ElDropdownItem), {
1071
+ key: item.value,
1072
+ command: item.value,
1073
+ onClick: withModifiers(($event) => toggleColumnsItem(item.value), ["stop"])
1074
+ }, {
1075
+ default: withCtx(() => [
1076
+ createVNode(unref(ElCheckbox), {
1077
+ "model-value": item.checked,
1078
+ onChange: () => toggleColumnsItem(item.value)
1079
+ }, {
1080
+ default: withCtx(() => [
1081
+ createTextVNode(toDisplayString(item.label), 1)
1082
+ ]),
1083
+ _: 2
1084
+ }, 1032, ["model-value", "onChange"])
1085
+ ]),
1086
+ _: 2
1087
+ }, 1032, ["command", "onClick"]);
1088
+ }), 128))
1089
+ ]),
1090
+ _: 1
1091
+ })
1092
+ ]),
1093
+ default: withCtx(() => [
1094
+ createVNode(unref(ElButton), {
1095
+ text: "",
1096
+ class: "pro-table_column-control_button"
1097
+ }, {
1098
+ default: withCtx(() => [
1099
+ createVNode(FilterOutlined)
1100
+ ]),
1101
+ _: 1
1102
+ })
1103
+ ]),
1104
+ _: 1
1105
+ }, 8, ["visible"]);
1106
+ };
1107
+ }
1108
+ });
1109
+ const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-ce445821"]]);
1110
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1111
+ ...{ name: "TableColumnRenderer" },
1112
+ __name: "TableColumnRenderer",
1113
+ props: {
1114
+ columns: {}
1115
+ },
1116
+ setup(__props) {
1117
+ const getColumnKey = (column, index2) => {
1118
+ const key = column.key ?? column.prop;
1119
+ if (key === void 0 || key === null) return `__idx_${index2}`;
1120
+ return Array.isArray(key) ? key.join(".") : String(key);
1121
+ };
1122
+ const getCellValue = (row, column) => {
1123
+ const path = column.prop;
1124
+ if (!path) return void 0;
1125
+ return get(row, toPath(path));
1126
+ };
1127
+ const normalizedColumns = computed(() => {
1128
+ return __props.columns.filter((column) => !column.hidden);
1129
+ });
1130
+ const getColumnProps = (column) => {
1131
+ const { hidden, render, key, ...rest } = column;
1132
+ const prop = Array.isArray(column.prop) ? column.prop.join(".") : column.prop ? String(column.prop) : void 0;
1133
+ return {
1134
+ ...rest,
1135
+ prop,
1136
+ columnKey: key ? String(key) : prop
1137
+ };
1138
+ };
1139
+ return (_ctx, _cache) => {
1140
+ return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column, index2) => {
1141
+ return openBlock(), createBlock(unref(ElTableColumn), mergeProps({
1142
+ key: getColumnKey(column, index2),
1143
+ ref_for: true
1144
+ }, getColumnProps(column)), {
1145
+ default: withCtx((scope) => {
1146
+ var _a;
1147
+ return [
1148
+ typeof column.render === "function" ? (openBlock(), createBlock(resolveDynamicComponent(
1149
+ (_a = column.render) == null ? void 0 : _a.call(column, {
1150
+ ...scope,
1151
+ column,
1152
+ cellValue: getCellValue(scope.row, column)
1153
+ })
1154
+ ), { key: 0 })) : createCommentVNode("", true)
1155
+ ];
1156
+ }),
1157
+ _: 2
1158
+ }, 1040);
1159
+ }), 128);
1160
+ };
1161
+ }
1162
+ });
1163
+ const _hoisted_1 = { class: "pro-table_header" };
1164
+ const _hoisted_2 = {
1165
+ key: 0,
1166
+ class: "pro-table_header_button-bar"
1167
+ };
1168
+ const _hoisted_3 = {
1169
+ key: 1,
1170
+ class: "pro-table_header_toolbar"
1171
+ };
1172
+ const _hoisted_4 = {
1173
+ key: 2,
1174
+ class: "pro-table_header_size-control"
1175
+ };
1176
+ const _hoisted_5 = {
1177
+ key: 3,
1178
+ class: "pro-table_header_column-control"
1179
+ };
1180
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1181
+ ...{ name: "ProTable", inheritAttrs: false },
1182
+ __name: "ProTable",
1183
+ props: /* @__PURE__ */ mergeModels({
1184
+ table: { default: () => void 0 },
1185
+ search: { type: Function, default: void 0 },
1186
+ addIndexColumn: { type: Boolean, default: () => void 0 },
1187
+ immediateSearch: { type: Boolean, default: () => void 0 },
1188
+ control: { type: [Boolean, Object], default: () => void 0 },
1189
+ searchFormConfig: { default: () => void 0 },
1190
+ tableContainer: { type: [Object, Function, Boolean], default: void 0 },
1191
+ columns: { default: () => void 0 },
1192
+ data: { default: () => void 0 },
1193
+ pagination: { type: [Boolean, Object], default: () => void 0 },
1194
+ size: {},
1195
+ width: {},
1196
+ height: {},
1197
+ maxHeight: {},
1198
+ fit: { type: Boolean },
1199
+ stripe: { type: Boolean },
1200
+ border: { type: Boolean },
1201
+ rowKey: { type: [String, Function] },
1202
+ context: {},
1203
+ showHeader: { type: Boolean },
1204
+ showSummary: { type: Boolean },
1205
+ sumText: {},
1206
+ summaryMethod: { type: Function },
1207
+ rowClassName: { type: [String, Function] },
1208
+ rowStyle: { type: [Object, Function] },
1209
+ cellClassName: { type: [String, Function] },
1210
+ cellStyle: { type: [Object, Function] },
1211
+ headerRowClassName: { type: [String, Function] },
1212
+ headerRowStyle: { type: [Object, Function] },
1213
+ headerCellClassName: { type: [String, Function] },
1214
+ headerCellStyle: { type: [Object, Function] },
1215
+ highlightCurrentRow: { type: Boolean },
1216
+ currentRowKey: {},
1217
+ emptyText: {},
1218
+ expandRowKeys: {},
1219
+ defaultExpandAll: { type: Boolean },
1220
+ rowExpandable: { type: Function },
1221
+ defaultSort: {},
1222
+ tooltipEffect: {},
1223
+ tooltipOptions: {},
1224
+ spanMethod: { type: Function },
1225
+ selectOnIndeterminate: { type: Boolean },
1226
+ indent: {},
1227
+ treeProps: {},
1228
+ lazy: { type: Boolean },
1229
+ load: { type: Function },
1230
+ className: {},
1231
+ style: { type: [Boolean, null, String, Object, Array] },
1232
+ tableLayout: {},
1233
+ scrollbarAlwaysOn: { type: Boolean },
1234
+ flexible: { type: Boolean },
1235
+ showOverflowTooltip: { type: [Boolean, Object] },
1236
+ tooltipFormatter: { type: Function },
1237
+ appendFilterPanelTo: {},
1238
+ scrollbarTabindex: {},
1239
+ nativeScrollbar: { type: Boolean }
1240
+ }, {
1241
+ "size": {},
1242
+ "sizeModifiers": {},
1243
+ "loading": { type: Boolean },
1244
+ "loadingModifiers": {}
1245
+ }),
1246
+ emits: ["update:size", "update:loading"],
1247
+ setup(__props) {
1248
+ const config = INJECT_CONFIG["pro-table"];
1249
+ const injectProps = inject(config.injectionKey, config.default);
1250
+ const tableProperties = Object.keys(tableProps());
1251
+ const paginationProperties = Object.keys(paginationProps());
1252
+ const attrs = useAttrs();
1253
+ const injectTableAttrs = computed(() => {
1254
+ return pick(injectProps, tableProperties);
1255
+ });
1256
+ const attrsTableProps = computed(() => {
1257
+ return pick(
1258
+ camelizeProperties(attrs),
1259
+ tableProperties
1260
+ );
1261
+ });
1262
+ const {
1263
+ columns: tableColumns,
1264
+ data: tableData,
1265
+ searchForm,
1266
+ pageParam,
1267
+ setPageParam
1268
+ } = __props.table || {};
1269
+ const size = useModel(__props, "size");
1270
+ const loading = useModel(__props, "loading");
1271
+ const _search = async () => {
1272
+ var _a;
1273
+ try {
1274
+ loading.value = true;
1275
+ await ((_a = __props.search) == null ? void 0 : _a.call(__props));
1276
+ } finally {
1277
+ loading.value = false;
1278
+ }
1279
+ };
1280
+ const reset = () => {
1281
+ var _a;
1282
+ (_a = __props.table) == null ? void 0 : _a.resetQueryParams();
1283
+ nextTick(() => {
1284
+ _search();
1285
+ });
1286
+ };
1287
+ const slots = useSlots();
1288
+ const searchFormSlot = slots["search-form"];
1289
+ const buttonBarSlot = slots["button-bar"];
1290
+ const toolbarSlot = slots["toolbar"];
1291
+ const tableSlots = computed(() => {
1292
+ const customNames = /* @__PURE__ */ new Set([
1293
+ "search-form",
1294
+ "button-bar",
1295
+ "toolbar",
1296
+ "table"
1297
+ ]);
1298
+ return Object.fromEntries(
1299
+ Object.entries(slots).filter(([name]) => !customNames.has(name))
1300
+ );
1301
+ });
1302
+ const tableSlotNames = computed(() => Object.keys(tableSlots.value));
1303
+ const searchPage1st = () => {
1304
+ setPageParam == null ? void 0 : setPageParam({ current: 1 });
1305
+ _search();
1306
+ };
1307
+ const computedSearchFormConfig = computed(() => {
1308
+ var _a, _b;
1309
+ const container = ((_a = __props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1310
+ return {
1311
+ ...injectProps.searchFormConfig,
1312
+ ...getObject(__props.searchFormConfig),
1313
+ container: container ? container : void 0
1314
+ };
1315
+ });
1316
+ const computedTableContainer = computed(() => {
1317
+ const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
1318
+ return container ? container : void 0;
1319
+ });
1320
+ const normalizedRawColumns = computed(() => {
1321
+ const source = __props.columns ?? (tableColumns == null ? void 0 : tableColumns.value) ?? [];
1322
+ const normalized = source.map((item, index2) => {
1323
+ const current = { ...item };
1324
+ if (current.label === void 0 && current.title !== void 0) {
1325
+ current.label = current.title;
1326
+ }
1327
+ if (current.prop === void 0 && current.dataIndex !== void 0) {
1328
+ current.prop = Array.isArray(current.dataIndex) ? current.dataIndex.join(".") : current.dataIndex;
1329
+ }
1330
+ if (current.key === void 0) {
1331
+ current.key = current.prop ?? (typeof current.columnKey === "string" ? current.columnKey : void 0) ?? `col-${index2}`;
1332
+ }
1333
+ return current;
1334
+ });
1335
+ if (__props.addIndexColumn ?? injectProps.addIndexColumn) {
1336
+ return [
1337
+ {
1338
+ key: "_index",
1339
+ type: "index",
1340
+ label: "序号",
1341
+ width: 80
1342
+ },
1343
+ ...normalized
1344
+ ];
1345
+ }
1346
+ return normalized;
1347
+ });
1348
+ const computedDataSource = computed(() => {
1349
+ const attrsData = attrsTableProps.value.data;
1350
+ return __props.data ?? attrsData ?? (tableData == null ? void 0 : tableData.value) ?? [];
1351
+ });
1352
+ const computedTableProps = computed(() => {
1353
+ const merged = {
1354
+ ...injectTableAttrs.value,
1355
+ ...attrsTableProps.value
1356
+ };
1357
+ delete merged.data;
1358
+ return merged;
1359
+ });
1360
+ const computedPagination = computed(() => {
1361
+ if (__props.pagination === false) return false;
1362
+ const pageConfig = __props.pagination ?? {};
1363
+ return {
1364
+ ...injectProps.pagination,
1365
+ ...pick(pageConfig, paginationProperties),
1366
+ currentPage: pageConfig.currentPage ?? (pageParam == null ? void 0 : pageParam.current) ?? 1,
1367
+ pageSize: pageConfig.pageSize ?? (pageParam == null ? void 0 : pageParam.pageSize) ?? 10,
1368
+ total: pageConfig.total ?? (pageParam == null ? void 0 : pageParam.total) ?? 0
1369
+ };
1370
+ });
1371
+ const showPagination = computed(() => computedPagination.value !== false);
1372
+ const onCurrentChange = (current) => {
1373
+ setPageParam == null ? void 0 : setPageParam({ current });
1374
+ _search();
1375
+ };
1376
+ const onSizeChange = (pageSize) => {
1377
+ setPageParam == null ? void 0 : setPageParam({ pageSize, current: 1 });
1378
+ _search();
1379
+ };
1380
+ const onPaginationChange = (currentPage, pageSize) => {
1381
+ var _a;
1382
+ (_a = attrs.onChange) == null ? void 0 : _a.call(attrs, currentPage, pageSize);
1383
+ };
1384
+ const showSearch = computed(() => {
1385
+ var _a, _b;
1386
+ 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);
1387
+ });
1388
+ const computedControl = computed(() => {
1389
+ const mergedControl = __props.control ?? injectProps.control;
1390
+ const sizeControl = (mergedControl == null ? void 0 : mergedControl.sizeControl) ?? mergedControl;
1391
+ const columnControl = (mergedControl == null ? void 0 : mergedControl.columnControl) ?? mergedControl;
1392
+ return { sizeControl: !!sizeControl, columnControl: !!columnControl };
1393
+ });
1394
+ const resolvedSize = computed(() => {
1395
+ return size.value ?? attrsTableProps.value.size ?? injectTableAttrs.value.size;
1396
+ });
1397
+ onMounted(() => {
1398
+ if (__props.immediateSearch ?? injectProps.immediateSearch) {
1399
+ _search();
1400
+ }
1401
+ });
1402
+ return (_ctx, _cache) => {
1403
+ const _directive_loading = resolveDirective("loading");
1404
+ return openBlock(), createElementBlock("div", {
1405
+ class: normalizeClass(["pro-table", _ctx.$attrs.class]),
1406
+ style: normalizeStyle(_ctx.$attrs.style)
1407
+ }, [
1408
+ showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$d), {
1409
+ key: 0,
1410
+ component: computedSearchFormConfig.value.container
1411
+ }, {
1412
+ default: withCtx(() => [
1413
+ renderSlot(_ctx.$slots, "search-form", {}, () => [
1414
+ unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1415
+ key: 0,
1416
+ form: unref(searchForm)
1417
+ }, computedSearchFormConfig.value, {
1418
+ onSearch: searchPage1st,
1419
+ onReset: reset
1420
+ }), null, 16, ["form"])) : createCommentVNode("", true)
1421
+ ], true)
1422
+ ]),
1423
+ _: 3
1424
+ }, 8, ["component"])) : createCommentVNode("", true),
1425
+ createVNode(unref(_sfc_main$d), { component: computedTableContainer.value }, {
1426
+ default: withCtx(() => [
1427
+ createElementVNode("div", _hoisted_1, [
1428
+ unref(buttonBarSlot) ? (openBlock(), createElementBlock("div", _hoisted_2, [
1429
+ renderSlot(_ctx.$slots, "button-bar", {}, void 0, true)
1430
+ ])) : createCommentVNode("", true),
1431
+ unref(toolbarSlot) ? (openBlock(), createElementBlock("div", _hoisted_3, [
1432
+ renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
1433
+ ])) : createCommentVNode("", true),
1434
+ computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
1435
+ createVNode(unref(SizeControl), {
1436
+ size: size.value,
1437
+ "onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
1438
+ }, null, 8, ["size"])
1439
+ ])) : createCommentVNode("", true),
1440
+ computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
1441
+ createVNode(unref(ColumnControl), {
1442
+ columns: normalizedRawColumns.value,
1443
+ table: __props.table
1444
+ }, null, 8, ["columns", "table"])
1445
+ ])) : createCommentVNode("", true)
1446
+ ]),
1447
+ renderSlot(_ctx.$slots, "table", {}, () => [
1448
+ withDirectives((openBlock(), createBlock(unref(ElTable), mergeProps({ class: "pro-table_content" }, computedTableProps.value, {
1449
+ size: resolvedSize.value,
1450
+ data: computedDataSource.value
1451
+ }), createSlots({
1452
+ default: withCtx(() => [
1453
+ createVNode(_sfc_main$2, { columns: normalizedRawColumns.value }, null, 8, ["columns"])
1454
+ ]),
1455
+ _: 2
1456
+ }, [
1457
+ renderList(tableSlotNames.value, (name) => {
1458
+ return {
1459
+ name,
1460
+ fn: withCtx((scoped) => [
1461
+ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scoped)), void 0, true)
1462
+ ])
1463
+ };
1464
+ })
1465
+ ]), 1040, ["size", "data"])), [
1466
+ [_directive_loading, loading.value]
1467
+ ])
1468
+ ], true),
1469
+ showPagination.value ? (openBlock(), createBlock(unref(ElPagination), mergeProps({
1470
+ key: 0,
1471
+ class: "pro-table_pagination"
1472
+ }, computedPagination.value, {
1473
+ onCurrentChange,
1474
+ onSizeChange,
1475
+ onChange: onPaginationChange
1476
+ }), null, 16)) : createCommentVNode("", true)
1477
+ ]),
1478
+ _: 3
1479
+ }, 8, ["component"])
1480
+ ], 6);
1481
+ };
1482
+ }
1483
+ });
1484
+ const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8617780a"]]);
1485
+ function useTable(params = {}) {
1486
+ const { data, ...rest } = params;
1487
+ const coreTable = useTable$1({
1488
+ ...rest,
1489
+ dataSource: data
1490
+ });
1491
+ const { dataSource, ...tableWithoutDataSource } = coreTable;
1492
+ const table = {
1493
+ ...tableWithoutDataSource,
1494
+ data: dataSource
1495
+ };
1496
+ return table;
1497
+ }
1498
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1499
+ ...{
1500
+ name: "ProComponentProvider",
1501
+ inheritAttrs: false
1502
+ },
1503
+ __name: "index",
1504
+ props: {
1505
+ componentVars: {},
1506
+ componentMap: {}
1507
+ },
1508
+ setup(__props) {
1509
+ const props = __props;
1510
+ if (props.componentVars) {
1511
+ Object.entries(props.componentVars).forEach(([key, val]) => {
1512
+ const config = ensureInjectConfig(key);
1513
+ provide(config.injectionKey, { ...config.default, ...getObject(val) });
1514
+ });
1515
+ }
1516
+ if (props.componentMap) {
1517
+ provide(INJECT_COMPONENTS, props.componentMap);
1518
+ }
1519
+ return (_ctx, _cache) => {
1520
+ return renderSlot(_ctx.$slots, "default");
1521
+ };
1522
+ }
1523
+ });
10
1524
  const index = {
11
1525
  /**
12
1526
  * @qin-ui/element-plus-pro 安装方法
@@ -23,22 +1537,22 @@ const index = {
23
1537
  * ```
24
1538
  */
25
1539
  install(app) {
26
- app.component(_sfc_main.name, _sfc_main);
1540
+ app.component(_sfc_main$b.name, _sfc_main$b);
27
1541
  app.component(ProTable.name, ProTable);
28
- app.component(_sfc_main$1.name, _sfc_main$1);
1542
+ app.component(_sfc_main.name, _sfc_main);
29
1543
  }
30
1544
  };
31
1545
  export {
32
- b as ContainerFragment,
33
- _sfc_main$1 as ProComponentProvider,
34
- _sfc_main as ProForm,
1546
+ _sfc_main$d as ContainerFragment,
1547
+ _sfc_main as ProComponentProvider,
1548
+ _sfc_main$b as ProForm,
35
1549
  ProTable,
36
- c as SlotComponent,
1550
+ _sfc_main$c as SlotComponent,
37
1551
  index as default,
38
- d as useFields,
39
- u as useForm,
1552
+ useFields,
1553
+ useForm,
40
1554
  useFormData,
41
- e as useFormRef,
1555
+ useFormRef,
42
1556
  useTable
43
1557
  };
44
1558
  //# sourceMappingURL=index.js.map