@qin-ui/antd-vue-pro 2.1.15 → 2.2.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.
Files changed (124) hide show
  1. package/AI-CONTEXT.md +52 -38
  2. package/LICENSE +9 -0
  3. package/api.json +42 -31
  4. package/es/antd-vue-pro.css +9 -9
  5. package/es/components/component-provider/components/index.vue.d.ts +35 -0
  6. package/es/components/component-provider/components/index.vue.d.ts.map +1 -0
  7. package/es/components/component-provider/constants/index.d.ts +16 -0
  8. package/es/components/component-provider/constants/index.d.ts.map +1 -0
  9. package/es/components/component-provider/index.d.ts +4 -0
  10. package/es/components/component-provider/index.d.ts.map +1 -0
  11. package/es/components/component-provider/types/index.d.ts +63 -0
  12. package/es/components/component-provider/types/index.d.ts.map +1 -0
  13. package/es/components/form/components/BaseField/index.vue.d.ts +13 -0
  14. package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -0
  15. package/es/components/form/components/BaseField/utils/index.d.ts +3 -0
  16. package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -0
  17. package/es/components/form/components/BaseFormItem/index.vue.d.ts +9 -0
  18. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
  19. package/es/components/form/components/ContainerFragment/index.vue.d.ts +23 -0
  20. package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
  21. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +29 -0
  22. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +1 -0
  23. package/es/components/form/components/PathProvider/index.vue.d.ts +24 -0
  24. package/es/components/form/components/PathProvider/index.vue.d.ts.map +1 -0
  25. package/es/components/form/components/ProForm/index.vue.d.ts +36 -0
  26. package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -0
  27. package/es/components/form/components/SlotComponent/index.vue.d.ts +7 -0
  28. package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
  29. package/es/components/form/components/index.d.ts +12 -0
  30. package/es/components/form/components/index.d.ts.map +1 -0
  31. package/es/components/form/constants/index.d.ts +78 -0
  32. package/es/components/form/constants/index.d.ts.map +1 -0
  33. package/es/components/form/hooks/index.d.ts +5 -0
  34. package/es/components/form/hooks/index.d.ts.map +1 -0
  35. package/es/components/form/hooks/useFields.d.ts +57 -0
  36. package/es/components/form/hooks/useFields.d.ts.map +1 -0
  37. package/es/components/form/hooks/useForm.d.ts +93 -0
  38. package/es/components/form/hooks/useForm.d.ts.map +1 -0
  39. package/es/components/form/hooks/useFormRef.d.ts +30 -0
  40. package/es/components/form/hooks/useFormRef.d.ts.map +1 -0
  41. package/es/components/form/index.d.ts +7 -0
  42. package/es/components/form/index.d.ts.map +1 -0
  43. package/es/components/form/types/index.d.ts +207 -0
  44. package/es/components/form/types/index.d.ts.map +1 -0
  45. package/es/components/table/components/ColumnControl.vue.d.ts +9 -0
  46. package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -0
  47. package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts +18 -0
  48. package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
  49. package/es/components/table/components/DefaultTableContainer.vue.d.ts +18 -0
  50. package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
  51. package/es/components/table/components/ProTable.vue.d.ts +100 -0
  52. package/es/components/table/components/ProTable.vue.d.ts.map +1 -0
  53. package/es/components/table/components/SearchForm.vue.d.ts +48 -0
  54. package/es/components/table/components/SearchForm.vue.d.ts.map +1 -0
  55. package/es/components/table/components/SizeControl.vue.d.ts +12 -0
  56. package/es/components/table/components/SizeControl.vue.d.ts.map +1 -0
  57. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts +3 -0
  58. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
  59. package/es/components/table/components/icons/DownOutlined.vue.d.ts +3 -0
  60. package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
  61. package/es/components/table/components/icons/FilterOutlined.vue.d.ts +3 -0
  62. package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
  63. package/es/components/table/components/index.d.ts +5 -0
  64. package/es/components/table/components/index.d.ts.map +1 -0
  65. package/es/components/table/hooks/index.d.ts +2 -0
  66. package/es/components/table/hooks/index.d.ts.map +1 -0
  67. package/es/components/table/hooks/useTable.d.ts +112 -0
  68. package/es/components/table/hooks/useTable.d.ts.map +1 -0
  69. package/es/components/table/index.d.ts +8 -0
  70. package/es/components/table/index.d.ts.map +1 -0
  71. package/es/components/table/types/index.d.ts +70 -0
  72. package/es/components/table/types/index.d.ts.map +1 -0
  73. package/es/index.d.ts +76 -1622
  74. package/es/index.d.ts.map +1 -0
  75. package/es/index.js +1314 -25
  76. package/es/index.js.map +1 -0
  77. package/es/shared/core/index.d.ts +6 -0
  78. package/es/shared/core/index.d.ts.map +1 -0
  79. package/es/shared/ui/index.d.ts +15 -0
  80. package/es/shared/ui/index.d.ts.map +1 -0
  81. package/package.json +20 -17
  82. package/src/components/component-provider/components/index.vue +81 -0
  83. package/src/components/component-provider/constants/index.ts +165 -0
  84. package/src/components/component-provider/index.ts +6 -0
  85. package/src/components/component-provider/types/index.ts +90 -0
  86. package/src/components/form/components/BaseField/index.vue +188 -0
  87. package/src/components/form/components/BaseField/utils/index.ts +16 -0
  88. package/src/components/form/components/BaseFormItem/index.vue +163 -0
  89. package/src/components/form/components/ContainerFragment/index.vue +24 -0
  90. package/src/components/form/components/GroupedFieldAttrs/index.vue +118 -0
  91. package/src/components/form/components/PathProvider/index.vue +19 -0
  92. package/src/components/form/components/ProForm/index.vue +109 -0
  93. package/src/components/form/components/SlotComponent/index.vue +26 -0
  94. package/src/components/form/components/index.ts +15 -0
  95. package/src/components/form/constants/index.ts +135 -0
  96. package/src/components/form/hooks/index.ts +5 -0
  97. package/src/components/form/hooks/useFields.ts +67 -0
  98. package/src/components/form/hooks/useForm.ts +110 -0
  99. package/src/components/form/hooks/useFormRef.ts +35 -0
  100. package/src/components/form/index.ts +29 -0
  101. package/src/components/form/types/index.ts +271 -0
  102. package/src/components/table/components/ColumnControl.vue +132 -0
  103. package/src/components/table/components/DefaultSearchFormContainer.vue +20 -0
  104. package/src/components/table/components/DefaultTableContainer.vue +20 -0
  105. package/src/components/table/components/ProTable.vue +366 -0
  106. package/src/components/table/components/SearchForm.vue +295 -0
  107. package/src/components/table/components/SizeControl.vue +59 -0
  108. package/src/components/table/components/icons/ColumnHeightOutlined.vue +4 -0
  109. package/src/components/table/components/icons/DownOutlined.vue +4 -0
  110. package/src/components/table/components/icons/FilterOutlined.vue +4 -0
  111. package/src/components/table/components/index.ts +4 -0
  112. package/src/components/table/hooks/index.ts +1 -0
  113. package/src/components/table/hooks/useTable.ts +130 -0
  114. package/src/components/table/index.ts +14 -0
  115. package/src/components/table/types/index.ts +74 -0
  116. package/src/index.ts +80 -0
  117. package/src/shared/core/index.ts +37 -0
  118. package/src/shared/ui/index.ts +60 -0
  119. package/es/component-provider/index-Dmz32tSB.js +0 -174
  120. package/es/component-provider/index.js +0 -4
  121. package/es/core/index-ghYuQ3Sy.js +0 -360
  122. package/es/form/index.js +0 -451
  123. package/es/table/index.js +0 -703
  124. package/es/vendor/utils/lodash-es-p6jau26B.js +0 -1120
package/es/index.js CHANGED
@@ -1,20 +1,1309 @@
1
1
  import "./antd-vue-pro.css";
2
- import _sfc_main from "./form/index.js";
3
- import { ContainerFragment, SlotComponent, useFields, useForm, useFormRef } from "./form/index.js";
4
- import BaseTable from "./table/index.js";
5
- import { useTable } from "./table/index.js";
6
- import { _ as _sfc_main$1 } from "./component-provider/index-Dmz32tSB.js";
7
- import { e } from "./core/index-ghYuQ3Sy.js";
8
- const withInstall = (comp) => {
9
- comp.install = (app) => {
10
- app.component(comp.name, comp);
2
+ import { defineComponent, computed, provide, renderSlot, inject, mergeProps, toValue, normalizeProps, guardReactiveProps, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, ref, useAttrs, createCommentVNode, resolveDynamicComponent, isVNode, createTextVNode, toDisplayString, useSlots, watchEffect, createElementVNode, watch, normalizeStyle, useModel, withModifiers, mergeModels, onMounted, normalizeClass, nextTick } from "vue";
3
+ import { InjectionPathKey, isPlainObject, getObject, toPath, useForm as useForm$1, omit, cloneDeep, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, pick, useTable as useTable$1 } from "@qin-ui/pro-components-core";
4
+ import { useFormData } from "@qin-ui/pro-components-core";
5
+ import { Transfer, TreeSelect, Slider, Switch, RadioGroup, CheckboxGroup, TimePicker, RangePicker, DatePicker, Cascader, Select, InputNumber, InputPassword, InputSearch, Textarea, Input, Row, Col, FormItem, Form, Space, Button, theme, Dropdown, Menu, MenuItem, Checkbox, MenuDivider, Table } from "ant-design-vue";
6
+ import { formItemProps, useInjectFormItemContext } from "ant-design-vue/es/form";
7
+ import { colProps } from "ant-design-vue/es/grid/Col";
8
+ import { useProviderDisabled, useInjectDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
9
+ import { useConfigContextInject } from "ant-design-vue/es/config-provider/context";
10
+ import { tableProps } from "ant-design-vue/es/table";
11
+ const getPopupContainer = (triggerNode) => triggerNode.closest("form[class*='-form']");
12
+ const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
13
+ const INJECT_CONFIG = {
14
+ "pro-table": {
15
+ injectionKey: Symbol(""),
16
+ default: {
17
+ pagination: {
18
+ showTotal: (total) => `共 ${total} 条`,
19
+ showSizeChanger: true,
20
+ pageSizeOptions: ["10", "20", "30", "40", "50", "100"],
21
+ showQuickJumper: true
22
+ },
23
+ searchFormConfig: {
24
+ layout: "grid",
25
+ expand: { minExpandRows: 2, expandStatus: false }
26
+ },
27
+ control: true,
28
+ addIndexColumn: true
29
+ }
30
+ },
31
+ "pro-form": {
32
+ injectionKey: Symbol(""),
33
+ default: { grid: { gutter: { xs: 8, sm: 16, md: 16, lg: 24 } } }
34
+ },
35
+ "pro-form-item": {
36
+ injectionKey: Symbol(""),
37
+ default: { validateFirst: true, span: 8 }
38
+ },
39
+ // field
40
+ input: {
41
+ injectionKey: Symbol(""),
42
+ default: { maxlength: 100, allowClear: true, placeholder: "请输入" }
43
+ },
44
+ textarea: {
45
+ injectionKey: Symbol(""),
46
+ default: {
47
+ maxlength: 200,
48
+ autoSize: { minRows: 3, maxRows: 6 },
49
+ showCount: true,
50
+ allowClear: true,
51
+ placeholder: "请输入"
52
+ }
53
+ },
54
+ "input-password": {
55
+ injectionKey: Symbol(""),
56
+ default: { maxlength: 100, allowClear: true, placeholder: "请输入" }
57
+ },
58
+ "input-search": {
59
+ injectionKey: Symbol(""),
60
+ default: {}
61
+ },
62
+ "input-number": {
63
+ injectionKey: Symbol(""),
64
+ default: {
65
+ max: 10 ** 15 - 1,
66
+ min: -1000000000000001,
67
+ controls: false,
68
+ placeholder: "请输入",
69
+ style: { width: "100%" }
70
+ }
71
+ },
72
+ select: {
73
+ injectionKey: Symbol(""),
74
+ default: { allowClear: true, placeholder: "请选择", getPopupContainer }
75
+ },
76
+ cascader: {
77
+ injectionKey: Symbol(""),
78
+ default: { allowClear: true, placeholder: "请选择", getPopupContainer }
79
+ },
80
+ "date-picker": {
81
+ injectionKey: Symbol(""),
82
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
83
+ },
84
+ "date-picker.date": {
85
+ injectionKey: Symbol(""),
86
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
87
+ },
88
+ "date-picker.week": {
89
+ injectionKey: Symbol(""),
90
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
91
+ },
92
+ "date-picker.month": {
93
+ injectionKey: Symbol(""),
94
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
95
+ },
96
+ "date-picker.year": {
97
+ injectionKey: Symbol(""),
98
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
99
+ },
100
+ "date-picker.quarter": {
101
+ injectionKey: Symbol(""),
102
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
103
+ },
104
+ "range-picker": {
105
+ injectionKey: Symbol(""),
106
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
107
+ },
108
+ "time-picker": {
109
+ injectionKey: Symbol(""),
110
+ default: { allowClear: true, getPopupContainer, style: { width: "100%" } }
111
+ },
112
+ "checkbox-group": {
113
+ injectionKey: Symbol(""),
114
+ default: {}
115
+ },
116
+ "radio-group": {
117
+ injectionKey: Symbol(""),
118
+ default: {}
119
+ },
120
+ switch: {
121
+ injectionKey: Symbol(""),
122
+ default: { modelProp: "checked" }
123
+ },
124
+ slider: {
125
+ injectionKey: Symbol(""),
126
+ default: {}
127
+ },
128
+ "tree-select": {
129
+ injectionKey: Symbol(""),
130
+ default: {}
131
+ },
132
+ transfer: {
133
+ injectionKey: Symbol(""),
134
+ default: {}
135
+ }
136
+ };
137
+ const DYNAMIC_INJECT_CONFIG = /* @__PURE__ */ Object.create(null);
138
+ const getInjectConfig = (key) => {
139
+ return INJECT_CONFIG[key] || DYNAMIC_INJECT_CONFIG[key];
140
+ };
141
+ const ensureInjectConfig = (key) => {
142
+ const existing = getInjectConfig(key);
143
+ if (existing) return existing;
144
+ const created = {
145
+ injectionKey: Symbol(`dynamic:${key}`),
146
+ default: {}
11
147
  };
12
- return comp;
148
+ DYNAMIC_INJECT_CONFIG[key] = created;
149
+ return created;
150
+ };
151
+ const FORM_ITEM_SLOT_KEYS = [
152
+ "label",
153
+ "extra",
154
+ "help",
155
+ "tooltip"
156
+ ];
157
+ const componentMap = {
158
+ "input": Input,
159
+ "textarea": Textarea,
160
+ "input-search": InputSearch,
161
+ "input-password": InputPassword,
162
+ "input-number": InputNumber,
163
+ "select": Select,
164
+ "cascader": Cascader,
165
+ "date-picker": DatePicker,
166
+ "range-picker": RangePicker,
167
+ "time-picker": TimePicker,
168
+ "checkbox-group": CheckboxGroup,
169
+ "radio-group": RadioGroup,
170
+ "switch": Switch,
171
+ "slider": Slider,
172
+ "tree-select": TreeSelect,
173
+ "transfer": Transfer
174
+ };
175
+ const TeleportComponentNamePrefix = "TeleportComponent_";
176
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
177
+ __name: "index",
178
+ props: {
179
+ path: {}
180
+ },
181
+ setup(__props) {
182
+ const props = __props;
183
+ const namePath = computed(() => {
184
+ return Array.isArray(props.path) ? props.path.join(".") : props.path;
185
+ });
186
+ provide(InjectionPathKey, namePath);
187
+ return (_ctx, _cache) => {
188
+ return renderSlot(_ctx.$slots, "default", { path: namePath.value });
189
+ };
190
+ }
191
+ });
192
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
193
+ __name: "index",
194
+ props: {
195
+ field: {}
196
+ },
197
+ setup(__props) {
198
+ const formItemPropKeys = Object.keys(formItemProps()).concat([
199
+ "formItemContainer"
200
+ ]);
201
+ const gridItemPropKeys = Object.keys(colProps());
202
+ const props = __props;
203
+ const config = INJECT_CONFIG["pro-form-item"];
204
+ const injectFormItemProps = inject(config.injectionKey, config.default);
205
+ const groupedAttributes = computed(() => {
206
+ let gridItemProps2 = {};
207
+ let formItemProps2 = {};
208
+ const componentProps = { slots: {} };
209
+ const formItemSlots = {};
210
+ if (isPlainObject(props.field)) {
211
+ const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = props.field;
212
+ const {
213
+ class: injectClassName,
214
+ style: injectStyle,
215
+ span: injectSpan,
216
+ xs,
217
+ sm,
218
+ md,
219
+ lg,
220
+ xl,
221
+ xxl,
222
+ ...injectRest
223
+ } = injectFormItemProps;
224
+ const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
225
+ gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
226
+ formItemProps2 = mergeProps(
227
+ injectRest,
228
+ { class: injectClassName, style: injectStyle },
229
+ { class: toValue(formItemClass), style: toValue(formItemStyle) },
230
+ formItemDataAttrs
231
+ );
232
+ Object.keys(rest).forEach((k) => {
233
+ if (gridItemPropKeys.includes(k)) {
234
+ gridItemProps2[k] = rest[k];
235
+ } else if (formItemPropKeys.includes(k)) {
236
+ formItemProps2[k] = rest[k];
237
+ } else {
238
+ componentProps[k] = rest[k];
239
+ }
240
+ });
241
+ Object.assign(componentProps, componentDataAttrs);
242
+ Object.keys(slots).forEach((k) => {
243
+ if (FORM_ITEM_SLOT_KEYS.includes(k)) {
244
+ formItemSlots[k] = slots[k];
245
+ } else {
246
+ componentProps["slots"][k] = slots[k];
247
+ }
248
+ });
249
+ }
250
+ return { gridItemProps: gridItemProps2, formItemProps: formItemProps2, componentProps, formItemSlots };
251
+ });
252
+ return (_ctx, _cache) => {
253
+ return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(groupedAttributes.value)));
254
+ };
255
+ }
256
+ });
257
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
258
+ ...{ name: "BaseFormItem", inheritAttrs: false },
259
+ __name: "index",
260
+ props: {
261
+ grid: { type: [Boolean, Object], default: () => void 0 },
262
+ fields: { default: () => [] },
263
+ disabled: { type: Boolean, default: () => void 0 }
264
+ },
265
+ setup(__props) {
266
+ const validFields = computed(() => {
267
+ var _a, _b;
268
+ return (_b = (_a = __props.fields).filter) == null ? void 0 : _b.call(_a, (field) => !field.hidden);
269
+ });
270
+ useProviderDisabled(computed(() => __props.disabled));
271
+ const config = INJECT_CONFIG["pro-form"];
272
+ const { grid: injectGrid } = inject(config.injectionKey, config.default);
273
+ const enableGrid = computed(() => {
274
+ if (__props.grid !== void 0) return !!__props.grid;
275
+ return !!injectGrid;
276
+ });
277
+ const computedGridProps = computed(() => {
278
+ return enableGrid.value ? { ...getObject(injectGrid), ...getObject(__props.grid) } : {};
279
+ });
280
+ const formItemRefs = [];
281
+ const componentRefs = [];
282
+ const onFormItemMounted = (index2, formItemProps2) => {
283
+ const field = validFields.value[index2];
284
+ Object.assign(field, {
285
+ getFormItemRef: () => formItemRefs[index2],
286
+ getFormItemComputedProps: () => formItemProps2
287
+ });
288
+ };
289
+ const onComponentMounted = (index2) => {
290
+ const field = validFields.value[index2];
291
+ Object.assign(field, {
292
+ getComponentRef: () => {
293
+ var _a;
294
+ return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentRef();
295
+ },
296
+ getComponentComputedProps: () => {
297
+ var _a;
298
+ return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentComputedProps();
299
+ }
300
+ });
301
+ };
302
+ return (_ctx, _cache) => {
303
+ const _component_BaseFormItem = resolveComponent("BaseFormItem");
304
+ return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
305
+ component: enableGrid.value ? unref(Row) : void 0
306
+ }, computedGridProps.value), {
307
+ default: withCtx(() => [
308
+ (openBlock(true), createElementBlock(Fragment, null, renderList(validFields.value, ({ path: _path, name: _name, ...field }, index2) => {
309
+ return openBlock(), createBlock(_sfc_main$g, mergeProps({
310
+ key: unref(toPath)(toValue(_name ?? _path)).join(".") || index2
311
+ }, { ref_for: true }, { path: _name ?? _path }), {
312
+ default: withCtx(({ path }) => [
313
+ createVNode(_sfc_main$f, { field }, {
314
+ default: withCtx(({
315
+ gridItemProps,
316
+ formItemProps: { formItemContainer, ...formItemProps2 },
317
+ componentProps,
318
+ formItemSlots
319
+ }) => [
320
+ createVNode(unref(_sfc_main$c), mergeProps({
321
+ component: enableGrid.value ? unref(Col) : void 0
322
+ }, { ref_for: true }, gridItemProps), {
323
+ default: withCtx(() => [
324
+ createVNode(unref(_sfc_main$c), {
325
+ component: formItemContainer,
326
+ path
327
+ }, {
328
+ default: withCtx(() => [
329
+ createVNode(unref(FormItem), mergeProps({ ref_for: true }, formItemProps2, {
330
+ ref_for: true,
331
+ ref: (el) => formItemRefs[index2] = el,
332
+ name: unref(toPath)(path),
333
+ path,
334
+ onVnodeMounted: ($event) => onFormItemMounted(index2, formItemProps2)
335
+ }), createSlots({
336
+ default: withCtx(() => [
337
+ field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
338
+ key: 0,
339
+ grid: field.grid ?? __props.grid,
340
+ fields: field.fields,
341
+ disabled: toValue(field.disabled)
342
+ }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
343
+ key: 1,
344
+ ref_for: true,
345
+ ref: (el) => componentRefs[index2] = el
346
+ }, { ref_for: true }, componentProps, {
347
+ path,
348
+ onVnodeMounted: ($event) => onComponentMounted(index2)
349
+ }), null, 16, ["path", "onVnodeMounted"]))
350
+ ]),
351
+ _: 2
352
+ }, [
353
+ renderList(formItemSlots, (slot, name) => {
354
+ return {
355
+ name,
356
+ fn: withCtx((scoped) => [
357
+ createVNode(unref(_sfc_main$b), mergeProps({
358
+ path,
359
+ component: slot
360
+ }, { ref_for: true }, scoped), null, 16, ["path", "component"])
361
+ ])
362
+ };
363
+ })
364
+ ]), 1040, ["name", "path", "onVnodeMounted"])
365
+ ]),
366
+ _: 2
367
+ }, 1032, ["component", "path"])
368
+ ]),
369
+ _: 2
370
+ }, 1040, ["component"])
371
+ ]),
372
+ _: 2
373
+ }, 1032, ["field"])
374
+ ]),
375
+ _: 2
376
+ }, 1040);
377
+ }), 128))
378
+ ]),
379
+ _: 1
380
+ }, 16, ["component"]);
381
+ };
382
+ }
383
+ });
384
+ function useForm(...args) {
385
+ return useForm$1(...args);
386
+ }
387
+ const getInitProps = (field) => {
388
+ const { component } = field;
389
+ const picker = component === "date-picker" ? "" : field.picker;
390
+ if (typeof component === "string") {
391
+ const k = [component, picker].filter(Boolean).join(".");
392
+ const config = getInjectConfig(k);
393
+ if (!config) return {};
394
+ const injectProps = inject(config.injectionKey, config.default);
395
+ return injectProps;
396
+ }
397
+ return {};
13
398
  };
14
- const ProForm = withInstall(_sfc_main);
15
- const ProTable = withInstall(BaseTable);
16
- const ProComponentProvider = withInstall(_sfc_main$1);
17
- const components = [ProForm, ProTable, ProComponentProvider];
399
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
400
+ ...{ name: "BaseField", inheritAttrs: false },
401
+ __name: "index",
402
+ props: {
403
+ component: { default: () => void 0 },
404
+ path: { default: "" }
405
+ },
406
+ setup(__props, { expose: __expose }) {
407
+ const form = useForm(false);
408
+ const { getFormData, setFormData } = form;
409
+ const componentRef = ref();
410
+ const formItemContext = useInjectFormItemContext();
411
+ const triggerFormItemChange = () => {
412
+ formItemContext.onFieldChange();
413
+ };
414
+ const attrs = useAttrs();
415
+ function getOldValue() {
416
+ return cloneDeep(getFormData == null ? void 0 : getFormData(__props.path));
417
+ }
418
+ const value = computed({
419
+ get() {
420
+ let val = getFormData == null ? void 0 : getFormData(__props.path);
421
+ const { valueFormatter } = groupedAttrs.value;
422
+ if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
423
+ val = valueFormatter.get(val);
424
+ }
425
+ return val;
426
+ },
427
+ set(val) {
428
+ let newVal = val;
429
+ const { valueFormatter } = groupedAttrs.value;
430
+ if (valueFormatter) {
431
+ if (typeof valueFormatter === "function") {
432
+ newVal = valueFormatter(val, getOldValue());
433
+ } else if (typeof valueFormatter.set === "function") {
434
+ newVal = valueFormatter.set(val, getOldValue());
435
+ }
436
+ }
437
+ setFormData == null ? void 0 : setFormData(__props.path, newVal);
438
+ triggerFormItemChange();
439
+ }
440
+ });
441
+ const parentDisabled = useInjectDisabled();
442
+ const groupedAttrs = computed(() => {
443
+ const initProps = getInitProps({
444
+ component: __props.component,
445
+ picker: attrs.picker
446
+ });
447
+ const mergedProps = mergeProps(
448
+ initProps,
449
+ attrs,
450
+ { class: attrs.componentClass, style: attrs.componentStyle },
451
+ { class: initProps.componentClass, style: initProps.componentStyle },
452
+ { disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
453
+ { modelProp: attrs.modelProp ?? initProps.modelProp ?? "value" }
454
+ );
455
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...rest } = mergedProps;
456
+ const bindAttrs = omit(rest, [modelProp, `onUpdate:${modelProp}`]);
457
+ return {
458
+ attrs: bindAttrs,
459
+ slots,
460
+ componentContainer,
461
+ modelProp,
462
+ valueFormatter
463
+ };
464
+ });
465
+ const teleportComponent = inject(
466
+ `${TeleportComponentNamePrefix}${__props.path}`,
467
+ void 0
468
+ );
469
+ const customComponents = inject(INJECT_COMPONENTS, {});
470
+ const is = computed(() => {
471
+ if (teleportComponent) return teleportComponent;
472
+ if (typeof __props.component === "string") {
473
+ return customComponents[__props.component] || componentMap[__props.component] || __props.component;
474
+ }
475
+ return __props.component;
476
+ });
477
+ __expose({
478
+ getComponentRef: () => componentRef.value,
479
+ getComponentComputedProps: () => groupedAttrs.value.attrs
480
+ });
481
+ return (_ctx, _cache) => {
482
+ return openBlock(), createBlock(unref(_sfc_main$c), {
483
+ component: groupedAttrs.value.componentContainer,
484
+ path: __props.path
485
+ }, {
486
+ default: withCtx(() => [
487
+ is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
488
+ ref_key: "componentRef",
489
+ ref: componentRef,
490
+ [`${groupedAttrs.value.modelProp}`]: value.value,
491
+ [`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
492
+ path: __props.path
493
+ }), createSlots({ _: 2 }, [
494
+ renderList(groupedAttrs.value.slots, (slot, name) => {
495
+ return {
496
+ name,
497
+ fn: withCtx((scoped) => [
498
+ createVNode(unref(_sfc_main$b), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
499
+ ])
500
+ };
501
+ })
502
+ ]), 1040, ["path"])) : createCommentVNode("", true)
503
+ ]),
504
+ _: 1
505
+ }, 8, ["component", "path"]);
506
+ };
507
+ }
508
+ });
509
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
510
+ ...{ name: "ContainerFragment", inheritAttrs: false },
511
+ __name: "index",
512
+ props: {
513
+ component: { type: [Object, Function] }
514
+ },
515
+ setup(__props) {
516
+ return (_ctx, _cache) => {
517
+ return __props.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
518
+ default: withCtx(() => [
519
+ renderSlot(_ctx.$slots, "default")
520
+ ]),
521
+ _: 3
522
+ }, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
523
+ };
524
+ }
525
+ });
526
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
527
+ ...{ name: "SlotComponent", inheritAttrs: false },
528
+ __name: "index",
529
+ props: {
530
+ component: { type: [Object, Function, String, Number, Boolean, null] }
531
+ },
532
+ setup(__props) {
533
+ return (_ctx, _cache) => {
534
+ 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 }, [
535
+ createTextVNode(toDisplayString(__props.component), 1)
536
+ ], 64));
537
+ };
538
+ }
539
+ });
540
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
541
+ ...{ name: "ProForm", inheritAttrs: false },
542
+ __name: "index",
543
+ props: {
544
+ grid: { type: [Boolean, Object], default: false },
545
+ form: { default: () => ({}) }
546
+ },
547
+ setup(__props) {
548
+ provide(InjectionFormKey, __props.form);
549
+ const { formData, fields, setFormRef } = __props.form;
550
+ const config = INJECT_CONFIG["pro-form"];
551
+ const { grid: _injectGrid, ...injectAttrs } = inject(
552
+ config.injectionKey,
553
+ config.default
554
+ );
555
+ const slots = useSlots();
556
+ watchEffect(() => {
557
+ Object.keys(slots).forEach((name) => {
558
+ if (name === "default") return;
559
+ provide(`${TeleportComponentNamePrefix}${name}`, slots[name]);
560
+ });
561
+ });
562
+ return (_ctx, _cache) => {
563
+ return openBlock(), createBlock(unref(Form), mergeProps({
564
+ ref: (el) => {
565
+ var _a;
566
+ return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
567
+ },
568
+ model: unref(formData)
569
+ }, mergeProps(injectAttrs, unref(camelizeProperties)(_ctx.$attrs)), { class: "pro-form" }), {
570
+ default: withCtx(() => [
571
+ createVNode(unref(_sfc_main$e), {
572
+ fields: unref(fields),
573
+ grid: __props.grid
574
+ }, null, 8, ["fields", "grid"]),
575
+ renderSlot(_ctx.$slots, "default")
576
+ ]),
577
+ _: 3
578
+ }, 16, ["model"]);
579
+ };
580
+ }
581
+ });
582
+ function useFields(initFields) {
583
+ return useFields$1(initFields);
584
+ }
585
+ function useFormRef() {
586
+ return useFormRef$1();
587
+ }
588
+ const _export_sfc = (sfc, props) => {
589
+ const target = sfc.__vccOpts || sfc;
590
+ for (const [key, val] of props) {
591
+ target[key] = val;
592
+ }
593
+ return target;
594
+ };
595
+ const _sfc_main$9 = {};
596
+ const _hoisted_1$3 = {
597
+ focusable: "false",
598
+ "data-icon": "down",
599
+ width: "1em",
600
+ height: "1em",
601
+ fill: "currentColor",
602
+ "aria-hidden": "true",
603
+ viewBox: "64 64 896 896"
604
+ };
605
+ function _sfc_render$2(_ctx, _cache) {
606
+ return openBlock(), createElementBlock("svg", _hoisted_1$3, [..._cache[0] || (_cache[0] = [
607
+ 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)
608
+ ])]);
609
+ }
610
+ const DownOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
611
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
612
+ ...{ name: "SearchForm" },
613
+ __name: "SearchForm",
614
+ props: {
615
+ form: {},
616
+ layout: { default: "grid" },
617
+ expand: { type: [Boolean, Object], default: true },
618
+ searchButton: { type: [Object, Function, Boolean], default: void 0 },
619
+ resetButton: { type: [Object, Function, Boolean], default: void 0 },
620
+ expandButton: { type: [Object, Function, Boolean], default: void 0 },
621
+ rowGap: { default: 16 },
622
+ columnGap: { default: 24 },
623
+ class: {},
624
+ style: {}
625
+ },
626
+ emits: ["search", "reset"],
627
+ setup(__props, { emit: __emit }) {
628
+ const emit = __emit;
629
+ const proFormHeight = ref("unset");
630
+ const collapseHeight = ref(0);
631
+ let rowHeight = 32;
632
+ const computedExpand = computed(() => {
633
+ if (!__props.expand) return false;
634
+ if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
635
+ return {
636
+ minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
637
+ expandStatus: __props.expand.expandStatus ?? false
638
+ };
639
+ });
640
+ const showExpandToggle = ref(false);
641
+ const expandStatus = ref(true);
642
+ const changeExpandStatus = () => {
643
+ expandStatus.value = !expandStatus.value;
644
+ };
645
+ const { formRef, getFormData } = __props.form;
646
+ const setInitExpandStatus = () => {
647
+ expandStatus.value = false;
648
+ if (formRef.value && __props.expand) {
649
+ const formEl = formRef.value.$el;
650
+ const formItemsEl = formEl.querySelectorAll(
651
+ "[class*='-form-item'] > [path]"
652
+ );
653
+ const observer = new IntersectionObserver(
654
+ (entries) => {
655
+ expandStatus.value = entries.some((e) => {
656
+ if (e.intersectionRatio === 0) {
657
+ const path = e.target.getAttribute("path");
658
+ const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
659
+ return ![null, void 0].includes(searchFieldValue);
660
+ }
661
+ return __props.expand.expandStatus;
662
+ });
663
+ observer.disconnect();
664
+ },
665
+ { root: formEl }
666
+ );
667
+ formItemsEl.forEach((element) => {
668
+ observer.observe(element);
669
+ });
670
+ }
671
+ };
672
+ watch(
673
+ [
674
+ () => {
675
+ var _a, _b, _c;
676
+ 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;
677
+ },
678
+ () => formRef.value,
679
+ () => __props.expand
680
+ ],
681
+ () => {
682
+ var _a, _b, _c, _d, _e;
683
+ if (!__props.expand || !expandStatus.value || !formRef.value) return;
684
+ const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
685
+ const { height = 0 } = ((_b = proFormEl == null ? void 0 : proFormEl.getBoundingClientRect) == null ? void 0 : _b.call(proFormEl)) || {};
686
+ proFormHeight.value = height;
687
+ 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;
688
+ },
689
+ { flush: "post", immediate: true }
690
+ );
691
+ watchEffect(
692
+ () => {
693
+ if (typeof proFormHeight.value !== "number") return;
694
+ if (__props.layout === "grid" && computedExpand.value) {
695
+ const { minExpandRows } = computedExpand.value;
696
+ collapseHeight.value = Math.min(
697
+ minExpandRows * rowHeight + (minExpandRows - 1) * __props.rowGap,
698
+ +proFormHeight.value
699
+ );
700
+ showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
701
+ if (showExpandToggle.value) {
702
+ setInitExpandStatus();
703
+ }
704
+ } else {
705
+ showExpandToggle.value = false;
706
+ }
707
+ },
708
+ { flush: "post" }
709
+ );
710
+ const layoutProps = computed(
711
+ () => __props.layout === "grid" ? {
712
+ grid: {
713
+ gutter: [__props.columnGap, __props.rowGap],
714
+ style: { flex: 1, marginRight: "12px" }
715
+ },
716
+ style: {
717
+ display: "flex",
718
+ overflow: "hidden",
719
+ height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
720
+ }
721
+ } : {
722
+ layout: "inline",
723
+ style: { gap: `${__props.rowGap}px ${__props.columnGap}px` },
724
+ grid: false
725
+ }
726
+ );
727
+ const onReset = () => {
728
+ emit("reset");
729
+ };
730
+ const onSearch = () => {
731
+ emit("search");
732
+ };
733
+ return (_ctx, _cache) => {
734
+ return openBlock(), createBlock(unref(_sfc_main$a), mergeProps(layoutProps.value, {
735
+ form: __props.form,
736
+ class: "pro-table_search-form transition"
737
+ }), {
738
+ default: withCtx(() => [
739
+ createVNode(unref(Space), {
740
+ align: "start",
741
+ class: "pro-table_search-form_button-group"
742
+ }, {
743
+ default: withCtx(() => [
744
+ renderSlot(_ctx.$slots, "reset-button", { onClick: onReset }, () => [
745
+ __props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
746
+ __props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.resetButton), {
747
+ key: 0,
748
+ onClick: onReset
749
+ })) : (openBlock(), createBlock(unref(Button), {
750
+ key: 1,
751
+ class: "pro-table_search-form_reset-button",
752
+ onClick: onReset
753
+ }, {
754
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
755
+ createTextVNode("重置", -1)
756
+ ])]),
757
+ _: 1
758
+ }))
759
+ ], 64)) : createCommentVNode("", true)
760
+ ], true),
761
+ renderSlot(_ctx.$slots, "search-button", { onClick: onSearch }, () => [
762
+ __props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
763
+ __props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.searchButton), {
764
+ key: 0,
765
+ onClick: onSearch
766
+ })) : (openBlock(), createBlock(unref(Button), {
767
+ key: 1,
768
+ class: "pro-table_search-form_search-button",
769
+ type: "primary",
770
+ "html-type": "submit",
771
+ onClick: onSearch
772
+ }, {
773
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
774
+ createTextVNode("查询 ", -1)
775
+ ])]),
776
+ _: 1
777
+ }))
778
+ ], 64)) : createCommentVNode("", true)
779
+ ], true),
780
+ renderSlot(_ctx.$slots, "expand-button", { onClick: changeExpandStatus }, () => [
781
+ __props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
782
+ __props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.expandButton), {
783
+ key: 0,
784
+ "expand-status": expandStatus.value,
785
+ onClick: changeExpandStatus
786
+ }, null, 8, ["expand-status"])) : (openBlock(), createBlock(unref(Button), {
787
+ key: 1,
788
+ type: "link",
789
+ class: "pro-table_search-form_expand-toggle-button",
790
+ onClick: changeExpandStatus
791
+ }, {
792
+ default: withCtx(() => [
793
+ createTextVNode(toDisplayString(expandStatus.value ? "收起" : "展开") + " ", 1),
794
+ createVNode(DownOutlined, {
795
+ class: "transition",
796
+ style: normalizeStyle([{ "margin-left": "4px" }, { transform: `rotate(${expandStatus.value ? -180 : 0}deg)` }])
797
+ }, null, 8, ["style"])
798
+ ]),
799
+ _: 1
800
+ }))
801
+ ], 64)) : createCommentVNode("", true)
802
+ ], true)
803
+ ]),
804
+ _: 3
805
+ })
806
+ ]),
807
+ _: 3
808
+ }, 16, ["form"]);
809
+ };
810
+ }
811
+ });
812
+ const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-aee49e85"]]);
813
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
814
+ __name: "DefaultSearchFormContainer",
815
+ setup(__props) {
816
+ const { token } = theme.useToken();
817
+ return (_ctx, _cache) => {
818
+ return openBlock(), createElementBlock("div", {
819
+ class: "pro-table_search-form-container",
820
+ style: normalizeStyle({ backgroundColor: unref(token).colorBgContainer })
821
+ }, [
822
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
823
+ ], 4);
824
+ };
825
+ }
826
+ });
827
+ const DefaultSearchFormContainer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-c385cd54"]]);
828
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
829
+ __name: "DefaultTableContainer",
830
+ setup(__props) {
831
+ const { token } = theme.useToken();
832
+ return (_ctx, _cache) => {
833
+ return openBlock(), createElementBlock("div", {
834
+ class: "pro-table_table-container",
835
+ style: normalizeStyle({ backgroundColor: unref(token).colorBgContainer })
836
+ }, [
837
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
838
+ ], 4);
839
+ };
840
+ }
841
+ });
842
+ const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-ac3cdb51"]]);
843
+ const _sfc_main$5 = {};
844
+ const _hoisted_1$2 = {
845
+ focusable: "false",
846
+ "data-icon": "column-height",
847
+ width: "1em",
848
+ height: "1em",
849
+ fill: "currentColor",
850
+ "aria-hidden": "true",
851
+ viewBox: "64 64 896 896"
852
+ };
853
+ function _sfc_render$1(_ctx, _cache) {
854
+ return openBlock(), createElementBlock("svg", _hoisted_1$2, [..._cache[0] || (_cache[0] = [
855
+ 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)
856
+ ])]);
857
+ }
858
+ const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$1]]);
859
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
860
+ __name: "SizeControl",
861
+ props: {
862
+ "size": {},
863
+ "sizeModifiers": {}
864
+ },
865
+ emits: ["update:size"],
866
+ setup(__props) {
867
+ var _a;
868
+ const configContext = useConfigContextInject();
869
+ const size = useModel(__props, "size");
870
+ size.value = size.value ?? ((_a = configContext.componentSize) == null ? void 0 : _a.value) ?? "large";
871
+ const onSizeChange = (val) => {
872
+ size.value = val.key;
873
+ };
874
+ const sizeOptions = [
875
+ { label: "默认", key: "large" },
876
+ { label: "中等", key: "middle" },
877
+ { label: "紧凑", key: "small" }
878
+ ];
879
+ return (_ctx, _cache) => {
880
+ return openBlock(), createBlock(unref(Dropdown), {
881
+ arrow: "",
882
+ placement: "bottomRight"
883
+ }, {
884
+ overlay: withCtx(() => [
885
+ createVNode(unref(Menu), {
886
+ style: { "width": "100px", "text-align": "center" },
887
+ "selected-keys": size.value ? [size.value] : [],
888
+ items: sizeOptions,
889
+ onClick: onSizeChange
890
+ }, null, 8, ["selected-keys"])
891
+ ]),
892
+ default: withCtx(() => [
893
+ createVNode(unref(Button), {
894
+ type: "text",
895
+ class: "pro-table_size-control_button"
896
+ }, {
897
+ default: withCtx(() => [
898
+ createVNode(ColumnHeightOutlined)
899
+ ]),
900
+ _: 1
901
+ })
902
+ ]),
903
+ _: 1
904
+ });
905
+ };
906
+ }
907
+ });
908
+ const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-db17998d"]]);
909
+ const _sfc_main$3 = {};
910
+ const _hoisted_1$1 = {
911
+ focusable: "false",
912
+ "data-icon": "filter",
913
+ width: "1em",
914
+ height: "1em",
915
+ fill: "currentColor",
916
+ "aria-hidden": "true",
917
+ viewBox: "64 64 896 896"
918
+ };
919
+ function _sfc_render(_ctx, _cache) {
920
+ return openBlock(), createElementBlock("svg", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
921
+ 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)
922
+ ])]);
923
+ }
924
+ const FilterOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render]]);
925
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
926
+ __name: "ColumnControl",
927
+ props: {
928
+ columns: {},
929
+ table: { default: () => void 0 }
930
+ },
931
+ setup(__props) {
932
+ const open = ref(false);
933
+ const checkAll = ref(false);
934
+ const indeterminate = ref(false);
935
+ const checkedColumnsOptions = computed(
936
+ () => __props.columns.flatMap(
937
+ (item) => item.key && item.title ? {
938
+ label: item.title,
939
+ value: item.key,
940
+ checked: !item.hidden
941
+ } : []
942
+ )
943
+ );
944
+ const checkedColumnKeys = computed({
945
+ get() {
946
+ return checkedColumnsOptions.value.flatMap(
947
+ (item) => item.checked ? item.value : []
948
+ ) || [];
949
+ },
950
+ set(val) {
951
+ var _a;
952
+ (_a = checkedColumnsOptions.value) == null ? void 0 : _a.forEach((item) => {
953
+ var _a2, _b;
954
+ (_b = (_a2 = __props.table) == null ? void 0 : _a2.setColumn) == null ? void 0 : _b.call(_a2, item.value, {
955
+ hidden: !val.includes(item.value)
956
+ });
957
+ });
958
+ }
959
+ });
960
+ const onCheckAllChange = (e) => {
961
+ checkedColumnKeys.value = e.target.checked ? checkedColumnsOptions.value.map((item) => item.value) : [];
962
+ indeterminate.value = false;
963
+ };
964
+ const checkColumnsMenuItemClick = (val) => {
965
+ if (checkedColumnKeys.value.includes(val)) {
966
+ checkedColumnKeys.value = checkedColumnKeys.value.filter(
967
+ (item) => item !== val
968
+ );
969
+ } else {
970
+ checkedColumnKeys.value = [...checkedColumnKeys.value, val];
971
+ }
972
+ };
973
+ watch(
974
+ checkedColumnKeys,
975
+ (val) => {
976
+ indeterminate.value = !!val.length && val.length < checkedColumnsOptions.value.length;
977
+ checkAll.value = val.length === checkedColumnsOptions.value.length;
978
+ },
979
+ { immediate: true }
980
+ );
981
+ return (_ctx, _cache) => {
982
+ return openBlock(), createBlock(unref(Dropdown), {
983
+ open: open.value,
984
+ "onUpdate:open": _cache[1] || (_cache[1] = ($event) => open.value = $event),
985
+ arrow: "",
986
+ placement: "bottomRight"
987
+ }, {
988
+ overlay: withCtx(() => [
989
+ createVNode(unref(Menu), {
990
+ style: { "min-width": "100px", "max-height": "500px", "overflow-y": "scroll" },
991
+ selectable: false
992
+ }, {
993
+ default: withCtx(() => [
994
+ (openBlock(), createBlock(unref(MenuItem), { key: 0 }, {
995
+ default: withCtx(() => [
996
+ createElementVNode("div", null, [
997
+ createVNode(unref(Checkbox), {
998
+ checked: checkAll.value,
999
+ indeterminate: indeterminate.value,
1000
+ onChange: onCheckAllChange
1001
+ }, {
1002
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
1003
+ createTextVNode(" 全选 ", -1)
1004
+ ])]),
1005
+ _: 1
1006
+ }, 8, ["checked", "indeterminate"])
1007
+ ])
1008
+ ]),
1009
+ _: 1
1010
+ })),
1011
+ createVNode(unref(MenuDivider)),
1012
+ (openBlock(true), createElementBlock(Fragment, null, renderList(checkedColumnsOptions.value, (item) => {
1013
+ return openBlock(), createBlock(unref(MenuItem), {
1014
+ key: item.value,
1015
+ onClick: ($event) => checkColumnsMenuItemClick(item.value)
1016
+ }, {
1017
+ default: withCtx(() => [
1018
+ createVNode(unref(Checkbox), {
1019
+ checked: checkedColumnKeys.value.includes(item.value)
1020
+ }, {
1021
+ default: withCtx(() => [
1022
+ createElementVNode("div", {
1023
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
1024
+ }, ["stop"]))
1025
+ }, toDisplayString(item.label), 1)
1026
+ ]),
1027
+ _: 2
1028
+ }, 1032, ["checked"])
1029
+ ]),
1030
+ _: 2
1031
+ }, 1032, ["onClick"]);
1032
+ }), 128))
1033
+ ]),
1034
+ _: 1
1035
+ })
1036
+ ]),
1037
+ default: withCtx(() => [
1038
+ createVNode(unref(Button), {
1039
+ type: "text",
1040
+ class: "pro-table_column-control_button"
1041
+ }, {
1042
+ default: withCtx(() => [
1043
+ createVNode(FilterOutlined)
1044
+ ]),
1045
+ _: 1
1046
+ })
1047
+ ]),
1048
+ _: 1
1049
+ }, 8, ["open"]);
1050
+ };
1051
+ }
1052
+ });
1053
+ const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-d503f78a"]]);
1054
+ const _hoisted_1 = { class: "pro-table_header" };
1055
+ const _hoisted_2 = {
1056
+ key: 0,
1057
+ class: "pro-table_header_button-bar"
1058
+ };
1059
+ const _hoisted_3 = {
1060
+ key: 1,
1061
+ class: "pro-table_header_toolbar"
1062
+ };
1063
+ const _hoisted_4 = {
1064
+ key: 2,
1065
+ class: "pro-table_header_size-control"
1066
+ };
1067
+ const _hoisted_5 = {
1068
+ key: 3,
1069
+ class: "pro-table_header_column-control"
1070
+ };
1071
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1072
+ ...{ name: "ProTable", inheritAttrs: false },
1073
+ __name: "ProTable",
1074
+ props: /* @__PURE__ */ mergeModels({
1075
+ table: { default: () => void 0 },
1076
+ search: { type: Function, default: void 0 },
1077
+ addIndexColumn: { type: Boolean, default: () => void 0 },
1078
+ immediateSearch: { type: Boolean, default: () => void 0 },
1079
+ control: { type: [Boolean, Object], default: () => void 0 },
1080
+ searchFormConfig: { default: () => void 0 },
1081
+ tableContainer: { type: [Object, Function, Boolean], default: void 0 }
1082
+ }, {
1083
+ "size": {},
1084
+ "sizeModifiers": {},
1085
+ "loading": { type: Boolean },
1086
+ "loadingModifiers": {}
1087
+ }),
1088
+ emits: ["update:size", "update:loading"],
1089
+ setup(__props) {
1090
+ const config = INJECT_CONFIG["pro-table"];
1091
+ const injectProps = inject(config.injectionKey, config.default);
1092
+ const tableProperties = Object.keys(tableProps());
1093
+ const injectAttrs = pick(injectProps, tableProperties);
1094
+ const computedSearchFormConfig = computed(() => {
1095
+ var _a, _b;
1096
+ const container = ((_a = __props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1097
+ return {
1098
+ ...injectProps.searchFormConfig,
1099
+ ...getObject(__props.searchFormConfig),
1100
+ container: container ? container : void 0
1101
+ };
1102
+ });
1103
+ const attrs = useAttrs();
1104
+ const tableAttrs = computed(() => {
1105
+ return pick(camelizeProperties(attrs), tableProperties);
1106
+ });
1107
+ const { columns, dataSource, searchForm, pageParam, setPageParam } = __props.table || {};
1108
+ const size = useModel(__props, "size");
1109
+ const loading = useModel(__props, "loading");
1110
+ const _search = async () => {
1111
+ var _a;
1112
+ try {
1113
+ loading.value = true;
1114
+ await ((_a = __props.search) == null ? void 0 : _a.call(__props));
1115
+ } finally {
1116
+ loading.value = false;
1117
+ }
1118
+ };
1119
+ const reset = () => {
1120
+ var _a;
1121
+ (_a = __props.table) == null ? void 0 : _a.resetQueryParams();
1122
+ nextTick(() => {
1123
+ _search();
1124
+ });
1125
+ };
1126
+ const slots = useSlots();
1127
+ const {
1128
+ "search-form": searchFormSlot,
1129
+ "button-bar": buttonBarSlot,
1130
+ toolbar: toolbarSlot,
1131
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1132
+ table: tableSlot,
1133
+ ...tableSlots
1134
+ } = slots;
1135
+ const searchPage1st = () => {
1136
+ setPageParam == null ? void 0 : setPageParam({ current: 1 });
1137
+ _search();
1138
+ };
1139
+ const computedTableProps = computed(() => {
1140
+ return {
1141
+ ...injectAttrs,
1142
+ ...tableAttrs.value,
1143
+ pagination: void 0,
1144
+ onChange: void 0
1145
+ };
1146
+ });
1147
+ const computedTableContainer = computed(() => {
1148
+ const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
1149
+ return container ? container : void 0;
1150
+ });
1151
+ const indexColumn = {
1152
+ title: "序号",
1153
+ dataIndex: "_index",
1154
+ width: 80,
1155
+ customRender: ({ index: index2 }) => index2 + 1
1156
+ };
1157
+ const computedColumns = computed(
1158
+ () => [
1159
+ ...__props.addIndexColumn ?? injectProps.addIndexColumn ? [indexColumn] : [],
1160
+ ...(tableAttrs.value.columns ?? (columns == null ? void 0 : columns.value) ?? []).flatMap(
1161
+ (item, index2) => {
1162
+ if (item.key) return [{ ...item, key: item.key }];
1163
+ if (item.dataIndex) {
1164
+ const dataIndexKey = Array.isArray(item.dataIndex) ? item.dataIndex.join(".") : item.dataIndex;
1165
+ return [{ ...item, key: dataIndexKey }];
1166
+ }
1167
+ return [{ ...item, key: index2 }];
1168
+ }
1169
+ )
1170
+ ]
1171
+ );
1172
+ const visibleComputedColumns = computed(() => {
1173
+ return computedColumns.value.filter((item) => !item.hidden);
1174
+ });
1175
+ const computedDataSource = computed(() => {
1176
+ return tableAttrs.value.dataSource ?? (dataSource == null ? void 0 : dataSource.value);
1177
+ });
1178
+ const computedPagination = computed(() => {
1179
+ if (tableAttrs.value.pagination === false) return false;
1180
+ return {
1181
+ ...injectAttrs.pagination,
1182
+ ...pageParam,
1183
+ ...tableAttrs.value.pagination
1184
+ };
1185
+ });
1186
+ const onTableChange = (...args) => {
1187
+ var _a;
1188
+ setPageParam == null ? void 0 : setPageParam(args[0]);
1189
+ (_a = attrs.onChange) == null ? void 0 : _a.call(attrs, ...args);
1190
+ _search();
1191
+ };
1192
+ const showSearch = computed(() => {
1193
+ var _a, _b;
1194
+ 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);
1195
+ });
1196
+ const computedControl = computed(() => {
1197
+ const mergedControl = __props.control ?? injectProps.control;
1198
+ const sizeControl = (mergedControl == null ? void 0 : mergedControl.sizeControl) ?? mergedControl;
1199
+ const columnControl = (mergedControl == null ? void 0 : mergedControl.columnControl) ?? mergedControl;
1200
+ return { sizeControl, columnControl };
1201
+ });
1202
+ onMounted(() => {
1203
+ if (__props.immediateSearch ?? injectProps.immediateSearch) {
1204
+ _search();
1205
+ }
1206
+ });
1207
+ return (_ctx, _cache) => {
1208
+ return openBlock(), createElementBlock("div", {
1209
+ class: normalizeClass(["pro-table", _ctx.$attrs.class]),
1210
+ style: normalizeStyle(_ctx.$attrs.style)
1211
+ }, [
1212
+ showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$c), {
1213
+ key: 0,
1214
+ component: computedSearchFormConfig.value.container
1215
+ }, {
1216
+ default: withCtx(() => [
1217
+ renderSlot(_ctx.$slots, "search-form", {}, () => [
1218
+ unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1219
+ key: 0,
1220
+ form: unref(searchForm)
1221
+ }, computedSearchFormConfig.value, {
1222
+ onSearch: searchPage1st,
1223
+ onReset: reset
1224
+ }), null, 16, ["form"])) : createCommentVNode("", true)
1225
+ ], true)
1226
+ ]),
1227
+ _: 3
1228
+ }, 8, ["component"])) : createCommentVNode("", true),
1229
+ createVNode(unref(_sfc_main$c), { component: computedTableContainer.value }, {
1230
+ default: withCtx(() => [
1231
+ createElementVNode("div", _hoisted_1, [
1232
+ unref(buttonBarSlot) ? (openBlock(), createElementBlock("div", _hoisted_2, [
1233
+ renderSlot(_ctx.$slots, "button-bar", {}, void 0, true)
1234
+ ])) : createCommentVNode("", true),
1235
+ unref(toolbarSlot) ? (openBlock(), createElementBlock("div", _hoisted_3, [
1236
+ renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
1237
+ ])) : createCommentVNode("", true),
1238
+ computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
1239
+ createVNode(unref(SizeControl), {
1240
+ size: size.value,
1241
+ "onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
1242
+ }, null, 8, ["size"])
1243
+ ])) : createCommentVNode("", true),
1244
+ computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
1245
+ createVNode(unref(ColumnControl), {
1246
+ columns: computedColumns.value,
1247
+ table: __props.table
1248
+ }, null, 8, ["columns", "table"])
1249
+ ])) : createCommentVNode("", true)
1250
+ ]),
1251
+ renderSlot(_ctx.$slots, "table", {}, () => [
1252
+ createVNode(unref(Table), mergeProps({ class: "pro-table_content" }, computedTableProps.value, {
1253
+ size: size.value,
1254
+ loading: loading.value,
1255
+ columns: visibleComputedColumns.value,
1256
+ "data-source": computedDataSource.value,
1257
+ pagination: computedPagination.value,
1258
+ onChange: onTableChange
1259
+ }), createSlots({ _: 2 }, [
1260
+ renderList(tableSlots, (_, name) => {
1261
+ return {
1262
+ name,
1263
+ fn: withCtx((scoped) => [
1264
+ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scoped)), void 0, true)
1265
+ ])
1266
+ };
1267
+ })
1268
+ ]), 1040, ["size", "loading", "columns", "data-source", "pagination"])
1269
+ ], true)
1270
+ ]),
1271
+ _: 3
1272
+ }, 8, ["component"])
1273
+ ], 6);
1274
+ };
1275
+ }
1276
+ });
1277
+ const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-856c096b"]]);
1278
+ function useTable(params) {
1279
+ return useTable$1(params);
1280
+ }
1281
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1282
+ ...{
1283
+ name: "ProComponentProvider",
1284
+ inheritAttrs: false
1285
+ },
1286
+ __name: "index",
1287
+ props: {
1288
+ componentVars: {},
1289
+ componentMap: {}
1290
+ },
1291
+ setup(__props) {
1292
+ const props = __props;
1293
+ if (props.componentVars) {
1294
+ Object.entries(props.componentVars).forEach(([key, val]) => {
1295
+ const config = ensureInjectConfig(key);
1296
+ provide(config.injectionKey, { ...config.default, ...getObject(val) });
1297
+ });
1298
+ }
1299
+ if (props.componentMap) {
1300
+ provide(INJECT_COMPONENTS, props.componentMap);
1301
+ }
1302
+ return (_ctx, _cache) => {
1303
+ return renderSlot(_ctx.$slots, "default");
1304
+ };
1305
+ }
1306
+ });
18
1307
  const index = {
19
1308
  /**
20
1309
  * @qin-ui/antd-vue-pro 安装方法
@@ -25,28 +1314,28 @@ const index = {
25
1314
  * @example
26
1315
  * ```ts
27
1316
  * import { createApp } from 'vue'
28
- * import QinUI from '@qin-ui/antd-vue-pro'
29
- *
1317
+ * import ProComponents from '@qin-ui/antd-vue-pro'
30
1318
  * const app = createApp(App)
31
- * app.use(QinUI) // 全局注册所有组件
1319
+ * app.use(ProComponents)
32
1320
  * ```
33
1321
  */
34
1322
  install(app) {
35
- components.forEach((component) => {
36
- app.component(component.name, component);
37
- });
1323
+ app.component(_sfc_main$a.name, _sfc_main$a);
1324
+ app.component(ProTable.name, ProTable);
1325
+ app.component(_sfc_main.name, _sfc_main);
38
1326
  }
39
1327
  };
40
1328
  export {
41
- ContainerFragment,
42
- ProComponentProvider,
43
- ProForm,
1329
+ _sfc_main$c as ContainerFragment,
1330
+ _sfc_main as ProComponentProvider,
1331
+ _sfc_main$a as ProForm,
44
1332
  ProTable,
45
- SlotComponent,
1333
+ _sfc_main$b as SlotComponent,
46
1334
  index as default,
47
1335
  useFields,
48
1336
  useForm,
49
- e as useFormData,
1337
+ useFormData,
50
1338
  useFormRef,
51
1339
  useTable
52
1340
  };
1341
+ //# sourceMappingURL=index.js.map