@qin-ui/element-plus-pro 1.0.8 → 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.
Files changed (126) hide show
  1. package/AI-CONTEXT.md +49 -37
  2. package/LICENSE +9 -0
  3. package/api.json +45 -28
  4. package/bin/init-ai.mjs +0 -0
  5. package/es/components/component-provider/components/index.vue.d.ts +27 -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 +35 -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 +31 -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 +67 -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 +234 -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 +47 -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/TableColumnRenderer.vue.d.ts +17 -0
  58. package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -0
  59. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts +3 -0
  60. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
  61. package/es/components/table/components/icons/DownOutlined.vue.d.ts +3 -0
  62. package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
  63. package/es/components/table/components/icons/FilterOutlined.vue.d.ts +3 -0
  64. package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
  65. package/es/components/table/components/index.d.ts +5 -0
  66. package/es/components/table/components/index.d.ts.map +1 -0
  67. package/es/components/table/index.d.ts +33 -0
  68. package/es/components/table/index.d.ts.map +1 -0
  69. package/es/components/table/types/index.d.ts +67 -0
  70. package/es/components/table/types/index.d.ts.map +1 -0
  71. package/es/components/table/useTable.d.ts +111 -0
  72. package/es/components/table/useTable.d.ts.map +1 -0
  73. package/es/element-plus-pro.css +10 -10
  74. package/es/index.d.ts +76 -1472
  75. package/es/index.d.ts.map +1 -0
  76. package/es/index.js +1534 -29
  77. package/es/index.js.map +1 -0
  78. package/es/shared/core/index.d.ts +6 -0
  79. package/es/shared/core/index.d.ts.map +1 -0
  80. package/es/shared/ui/index.d.ts +12 -0
  81. package/es/shared/ui/index.d.ts.map +1 -0
  82. package/package.json +20 -13
  83. package/src/components/component-provider/components/index.vue +67 -0
  84. package/src/components/component-provider/constants/index.ts +209 -0
  85. package/src/components/component-provider/index.ts +6 -0
  86. package/src/components/component-provider/types/index.ts +64 -0
  87. package/src/components/form/components/BaseField/index.vue +181 -0
  88. package/src/components/form/components/BaseField/utils/index.ts +15 -0
  89. package/src/components/form/components/BaseFormItem/index.vue +170 -0
  90. package/src/components/form/components/ContainerFragment/index.vue +24 -0
  91. package/src/components/form/components/GroupedFieldAttrs/index.vue +115 -0
  92. package/src/components/form/components/PathProvider/index.vue +19 -0
  93. package/src/components/form/components/ProForm/index.vue +106 -0
  94. package/src/components/form/components/SlotComponent/index.vue +26 -0
  95. package/src/components/form/components/index.ts +15 -0
  96. package/src/components/form/constants/index.ts +116 -0
  97. package/src/components/form/hooks/index.ts +5 -0
  98. package/src/components/form/hooks/useFields.ts +67 -0
  99. package/src/components/form/hooks/useForm.ts +110 -0
  100. package/src/components/form/hooks/useFormRef.ts +35 -0
  101. package/src/components/form/index.ts +29 -0
  102. package/src/components/form/types/index.ts +300 -0
  103. package/src/components/table/components/ColumnControl.vue +136 -0
  104. package/src/components/table/components/DefaultSearchFormContainer.vue +14 -0
  105. package/src/components/table/components/DefaultTableContainer.vue +14 -0
  106. package/src/components/table/components/ProTable.vue +420 -0
  107. package/src/components/table/components/SearchForm.vue +302 -0
  108. package/src/components/table/components/SizeControl.vue +55 -0
  109. package/src/components/table/components/TableColumnRenderer.vue +71 -0
  110. package/src/components/table/components/icons/ColumnHeightOutlined.vue +4 -0
  111. package/src/components/table/components/icons/DownOutlined.vue +4 -0
  112. package/src/components/table/components/icons/FilterOutlined.vue +4 -0
  113. package/src/components/table/components/index.ts +4 -0
  114. package/src/components/table/index.ts +38 -0
  115. package/src/components/table/types/index.ts +77 -0
  116. package/src/components/table/useTable.ts +144 -0
  117. package/src/index.ts +81 -0
  118. package/src/shared/core/index.ts +38 -0
  119. package/src/shared/ui/index.ts +106 -0
  120. package/es/component-provider/index-Bmx9Q9Q-.js +0 -220
  121. package/es/component-provider/index.js +0 -4
  122. package/es/core/index-C0Pbv44C.js +0 -360
  123. package/es/form/index-D8btGgqa.js +0 -470
  124. package/es/form/index.js +0 -13
  125. package/es/table/index.js +0 -856
  126. package/es/vendor/utils/lodash-es-p6jau26B.js +0 -1120
@@ -1,220 +0,0 @@
1
- import { defineComponent, provide, renderSlot } from "vue";
2
- import { g as getObject } from "../core/index-C0Pbv44C.js";
3
- const INJECT_CONFIG = {
4
- "pro-table": {
5
- injectionKey: Symbol(""),
6
- default: {
7
- pagination: {
8
- layout: "total, sizes, prev, pager, next, jumper",
9
- pageSizes: [10, 20, 30, 40, 50, 100],
10
- background: true
11
- },
12
- searchFormConfig: {
13
- layout: "grid",
14
- expand: { minExpandRows: 2, expandStatus: false }
15
- },
16
- control: true,
17
- addIndexColumn: true
18
- }
19
- },
20
- "pro-form": {
21
- injectionKey: Symbol(""),
22
- default: { grid: { gutter: 24 } }
23
- },
24
- "pro-form-item": {
25
- injectionKey: Symbol(""),
26
- default: { span: 8 }
27
- },
28
- input: {
29
- injectionKey: Symbol(""),
30
- default: { maxlength: 100, clearable: true, placeholder: "请输入" }
31
- },
32
- "input.textarea": {
33
- injectionKey: Symbol(""),
34
- default: {
35
- maxlength: 200,
36
- autosize: { minRows: 3, maxRows: 6 },
37
- showWordLimit: true,
38
- clearable: true,
39
- placeholder: "请输入"
40
- }
41
- },
42
- "input.password": {
43
- injectionKey: Symbol(""),
44
- default: {
45
- showPassword: true,
46
- maxlength: 100,
47
- clearable: true,
48
- placeholder: "请输入"
49
- }
50
- },
51
- "input-number": {
52
- injectionKey: Symbol(""),
53
- default: {
54
- max: 10 ** 15 - 1,
55
- min: -1000000000000001,
56
- controls: false,
57
- placeholder: "请输入",
58
- style: { width: "100%" }
59
- }
60
- },
61
- autocomplete: {
62
- injectionKey: Symbol(""),
63
- default: { clearable: true, placeholder: "请输入" }
64
- },
65
- select: {
66
- injectionKey: Symbol(""),
67
- default: { clearable: true, placeholder: "请选择" }
68
- },
69
- cascader: {
70
- injectionKey: Symbol(""),
71
- default: { clearable: true, placeholder: "请选择" }
72
- },
73
- "date-picker": {
74
- injectionKey: Symbol(""),
75
- default: { style: { width: "100%" }, placeholder: "请选择" }
76
- },
77
- "date-picker.date": {
78
- injectionKey: Symbol(""),
79
- default: { style: { width: "100%" }, placeholder: "请选择" }
80
- },
81
- "date-picker.dates": {
82
- injectionKey: Symbol(""),
83
- default: { style: { width: "100%" }, placeholder: "请选择" }
84
- },
85
- "date-picker.daterange": {
86
- injectionKey: Symbol(""),
87
- default: {
88
- style: { width: "100%" },
89
- startPlaceholder: "开始日期",
90
- endPlaceholder: "结束日期"
91
- }
92
- },
93
- "date-picker.week": {
94
- injectionKey: Symbol(""),
95
- default: { style: { width: "100%" }, placeholder: "请选择" }
96
- },
97
- "date-picker.month": {
98
- injectionKey: Symbol(""),
99
- default: { style: { width: "100%" }, placeholder: "请选择" }
100
- },
101
- "date-picker.monthrange": {
102
- injectionKey: Symbol(""),
103
- default: {
104
- style: { width: "100%" },
105
- startPlaceholder: "开始月份",
106
- endPlaceholder: "结束月份"
107
- }
108
- },
109
- "date-picker.months": {
110
- injectionKey: Symbol(""),
111
- default: { style: { width: "100%" }, placeholder: "请选择" }
112
- },
113
- "date-picker.yearrange": {
114
- injectionKey: Symbol(""),
115
- default: {
116
- style: { width: "100%" },
117
- startPlaceholder: "开始年份",
118
- endPlaceholder: "结束年份"
119
- }
120
- },
121
- "date-picker.year": {
122
- injectionKey: Symbol(""),
123
- default: { style: { width: "100%" }, placeholder: "请选择" }
124
- },
125
- "date-picker.years": {
126
- injectionKey: Symbol(""),
127
- default: { style: { width: "100%" }, placeholder: "请选择" }
128
- },
129
- "date-picker.datetime": {
130
- injectionKey: Symbol(""),
131
- default: { style: { width: "100%" }, placeholder: "请选择" }
132
- },
133
- "date-picker.datetimerange": {
134
- injectionKey: Symbol(""),
135
- default: {
136
- style: { width: "100%" },
137
- startPlaceholder: "开始时间",
138
- endPlaceholder: "结束时间"
139
- }
140
- },
141
- "time-picker": {
142
- injectionKey: Symbol(""),
143
- default: { style: { width: "100%" }, placeholder: "请选择" }
144
- },
145
- "time-select": {
146
- injectionKey: Symbol(""),
147
- default: { style: { width: "100%" }, placeholder: "请选择" }
148
- },
149
- "checkbox-group": {
150
- injectionKey: Symbol(""),
151
- default: {}
152
- },
153
- "radio-group": {
154
- injectionKey: Symbol(""),
155
- default: {}
156
- },
157
- switch: {
158
- injectionKey: Symbol(""),
159
- default: { modelProp: "modelValue" }
160
- },
161
- slider: {
162
- injectionKey: Symbol(""),
163
- default: {}
164
- },
165
- "tree-select": {
166
- injectionKey: Symbol(""),
167
- default: { clearable: true, placeholder: "请选择" }
168
- },
169
- transfer: {
170
- injectionKey: Symbol(""),
171
- default: {}
172
- }
173
- };
174
- const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
175
- const DYNAMIC_INJECT_CONFIG = /* @__PURE__ */ Object.create(null);
176
- const getInjectConfig = (key) => {
177
- return INJECT_CONFIG[key] || DYNAMIC_INJECT_CONFIG[key];
178
- };
179
- const ensureInjectConfig = (key) => {
180
- const existing = getInjectConfig(key);
181
- if (existing) return existing;
182
- const created = {
183
- injectionKey: Symbol(`dynamic:${key}`),
184
- default: {}
185
- };
186
- DYNAMIC_INJECT_CONFIG[key] = created;
187
- return created;
188
- };
189
- const _sfc_main = /* @__PURE__ */ defineComponent({
190
- ...{
191
- name: "ProComponentProvider",
192
- inheritAttrs: false
193
- },
194
- __name: "index",
195
- props: {
196
- componentVars: {},
197
- componentMap: {}
198
- },
199
- setup(__props) {
200
- const props = __props;
201
- if (props.componentVars) {
202
- Object.entries(props.componentVars).forEach(([key, val]) => {
203
- const config = ensureInjectConfig(key);
204
- provide(config.injectionKey, { ...config.default, ...getObject(val) });
205
- });
206
- }
207
- if (props.componentMap) {
208
- provide(INJECT_COMPONENTS, props.componentMap);
209
- }
210
- return (_ctx, _cache) => {
211
- return renderSlot(_ctx.$slots, "default");
212
- };
213
- }
214
- });
215
- export {
216
- INJECT_CONFIG as I,
217
- _sfc_main as _,
218
- INJECT_COMPONENTS as a,
219
- getInjectConfig as g
220
- };
@@ -1,4 +0,0 @@
1
- import { _ } from "./index-Bmx9Q9Q-.js";
2
- export {
3
- _ as default
4
- };
@@ -1,360 +0,0 @@
1
- import { inject, ref, reactive, provide, camelize, toValue } from "vue";
2
- import { i as isPlainObject, s as set, g as get, c as cloneDeep, t as toPath, p as pick } from "../vendor/utils/lodash-es-p6jau26B.js";
3
- const InjectionFormKey = Symbol("form");
4
- const InjectionPathKey = Symbol("path");
5
- function getObject(val) {
6
- return isPlainObject(val) ? val : {};
7
- }
8
- function camelizeProperties(obj) {
9
- return Object.fromEntries(
10
- Object.entries(obj).map(([key, value]) => [camelize(key), value])
11
- );
12
- }
13
- const useFields = (initFields) => {
14
- const fields = ref([]);
15
- fields.value = initFields || [];
16
- const _map = /* @__PURE__ */ new Map();
17
- const cacheMatch = (pathStr, updater) => {
18
- var _a;
19
- const fieldPath = _map.get(pathStr) || [];
20
- if (fieldPath.length === 0) return false;
21
- const fieldIndex = fieldPath[fieldPath.length - 1];
22
- const parentField = fieldPath.length === 1 ? fields.value : get(fields.value, fieldPath.slice(0, -2));
23
- const field = (_a = parentField == null ? void 0 : parentField.fields) == null ? void 0 : _a[fieldIndex];
24
- const _path = toPath((field == null ? void 0 : field.name) ?? (field == null ? void 0 : field.path)).join(".");
25
- if (_path === pathStr) {
26
- updater({ field, fieldIndex, parentField });
27
- return true;
28
- }
29
- return false;
30
- };
31
- const updaterMatch = (path, updater, options = {}) => {
32
- if (!path) return;
33
- const pathStr = typeof path === "function" ? "" : toPath(path).join(".");
34
- const { all = typeof path === "function" } = options;
35
- if (pathStr && _map.has(pathStr) && !all) {
36
- const bool = cacheMatch(pathStr, updater);
37
- if (bool) return;
38
- }
39
- const queue = fields.value.map((field, i) => ({
40
- field,
41
- fieldPath: [i],
42
- parentField: { fields: fields.value }
43
- }));
44
- while (queue.length) {
45
- const { field, fieldPath, parentField } = queue.shift();
46
- let matched = false;
47
- const _path = toPath(field.name ?? field.path).join(".");
48
- if (_path) _map.set(_path, fieldPath);
49
- if (typeof path === "function") {
50
- matched = path(field);
51
- } else if (_path) {
52
- matched = pathStr === _path;
53
- }
54
- if (matched) {
55
- const fieldIndex = fieldPath[fieldPath.length - 1];
56
- updater({ field, fieldIndex, parentField });
57
- if (!all) return;
58
- }
59
- if (Array.isArray(field.fields)) {
60
- field.fields.forEach((f, i) => {
61
- queue.push({
62
- field: f,
63
- fieldPath: [...fieldPath, "fields", i],
64
- parentField: field
65
- });
66
- });
67
- }
68
- }
69
- };
70
- function getField(path, options) {
71
- if (!path) return void 0;
72
- const res = [];
73
- updaterMatch(
74
- path,
75
- ({ field }) => {
76
- res.push(field);
77
- },
78
- options
79
- );
80
- return (options == null ? void 0 : options.all) ? res : res[0];
81
- }
82
- function setField(path, field, options) {
83
- if (!path) return;
84
- const { updateType = "merge", ...rest } = options || {};
85
- updaterMatch(
86
- path,
87
- ({ field: preField, fieldIndex, parentField }) => {
88
- let value = field;
89
- if (typeof field === "function") {
90
- value = field(preField);
91
- }
92
- if (!value) return;
93
- if (updateType === "rewrite") {
94
- parentField.fields[fieldIndex] = value;
95
- } else {
96
- Object.assign(preField, value);
97
- }
98
- },
99
- rest
100
- );
101
- }
102
- function deleteField(path, options) {
103
- if (!path) return;
104
- updaterMatch(
105
- path,
106
- ({ fieldIndex, parentField }) => {
107
- parentField.fields.splice(fieldIndex, 1);
108
- },
109
- options
110
- );
111
- }
112
- function appendField(path, field, options) {
113
- const newFields = Array.isArray(field) ? field : [field];
114
- addFields(path, newFields, options, "after");
115
- }
116
- function prependField(path, field, options) {
117
- const newFields = Array.isArray(field) ? field : [field];
118
- addFields(path, newFields, options, "before");
119
- }
120
- function getParentField(path, options) {
121
- if (!path) return void 0;
122
- const res = [];
123
- updaterMatch(
124
- path,
125
- ({ parentField }) => {
126
- res.push(parentField);
127
- },
128
- options
129
- );
130
- return (options == null ? void 0 : options.all) ? res : res[0];
131
- }
132
- function addFields(path, newFields, options, placement) {
133
- if (newFields.length === 0) return;
134
- if (path) {
135
- updaterMatch(
136
- path,
137
- ({ fieldIndex, parentField }) => {
138
- const index = placement === "after" ? fieldIndex + 1 : fieldIndex;
139
- parentField.fields.splice(index, 0, ...newFields);
140
- },
141
- options
142
- );
143
- } else if (placement === "after") {
144
- fields.value.push(...newFields);
145
- } else {
146
- fields.value.unshift(...newFields);
147
- }
148
- }
149
- return {
150
- fields,
151
- getField,
152
- setField,
153
- deleteField,
154
- appendField,
155
- prependField,
156
- getParentField
157
- };
158
- };
159
- const InjectionFormDataKey = Symbol("form-data");
160
- const useFormData = (initFormData) => {
161
- if (!initFormData) {
162
- const injectFormDataStore = inject(InjectionFormDataKey, void 0);
163
- if (injectFormDataStore) return injectFormDataStore;
164
- }
165
- const formData = reactive(initFormData ?? {});
166
- function getFormData(path) {
167
- if (!path) return void 0;
168
- return get(formData, path);
169
- }
170
- function setFormData(...args) {
171
- let path;
172
- let value;
173
- if (args.length >= 2) {
174
- [path, value] = args;
175
- if (!path) return;
176
- } else {
177
- [value] = args;
178
- }
179
- if (path) {
180
- if (typeof value === "function") {
181
- const preValue = getFormData(path);
182
- value = value(preValue);
183
- }
184
- set(formData, path, value);
185
- } else {
186
- if (typeof value === "function") {
187
- const preValue = formData;
188
- value = value(preValue);
189
- }
190
- if (!isPlainObject(value)) return;
191
- Object.keys(formData).forEach((key) => {
192
- delete formData[key];
193
- });
194
- Object.assign(formData, value);
195
- }
196
- }
197
- const formDataStore = { formData, getFormData, setFormData };
198
- provide(InjectionFormDataKey, formDataStore);
199
- return formDataStore;
200
- };
201
- const useFormRef = () => {
202
- const formRef = ref();
203
- const setFormRef = (inst) => {
204
- formRef.value = inst;
205
- };
206
- return { formRef, setFormRef };
207
- };
208
- function useForm(...args) {
209
- let initFormData = {}, initFields = [], root = true;
210
- if (args.length === 1) {
211
- root = args[0];
212
- } else if (args.length >= 2) {
213
- initFormData = args[0] ?? {};
214
- initFields = args[1];
215
- root = args[2] ?? root;
216
- }
217
- if (!root) {
218
- const injectForm = inject(InjectionFormKey);
219
- if (injectForm) return injectForm;
220
- }
221
- return {
222
- ...useFormData(initFormData),
223
- ...useFields(initFields),
224
- ...useFormRef()
225
- };
226
- }
227
- const getDefaultPageParam = () => ({
228
- current: 1,
229
- pageSize: 10,
230
- total: 0
231
- });
232
- const pageParamProperty = ["current", "pageSize", "total"];
233
- const useTable = (params) => {
234
- const {
235
- columns: initColumns = [],
236
- dataSource: initDataSource = [],
237
- pageParam: initPageParam = getDefaultPageParam(),
238
- searchParam: initSearchParam = {},
239
- searchFields: initSearchFields = []
240
- } = params;
241
- const _initSearchParam = cloneDeep(toValue(initSearchParam));
242
- const columns = ref([]);
243
- columns.value = initColumns;
244
- const dataSource = ref(initDataSource);
245
- const pageParam = reactive(initPageParam);
246
- const setPageParam = (pa) => {
247
- let newPageParam = pa;
248
- if (typeof pa === "function") {
249
- newPageParam = pa(pageParam);
250
- }
251
- Object.assign(pageParam, pick(newPageParam, pageParamProperty));
252
- };
253
- const searchForm = useForm(initSearchParam, initSearchFields, true);
254
- const resetQueryParams = () => {
255
- Object.assign(pageParam, getDefaultPageParam());
256
- searchForm.setFormData(cloneDeep(_initSearchParam));
257
- };
258
- const updaterMatch = (key, updater, options = {}) => {
259
- if (!key) return;
260
- const { all = typeof key === "function" } = options;
261
- for (let i = 0; i < columns.value.length; i++) {
262
- const columnItem = columns.value[i];
263
- let matched = false;
264
- if (typeof key === "function") {
265
- matched = key(columnItem);
266
- } else if (columnItem.key) {
267
- matched = columnItem.key === key;
268
- } else if (columnItem.dataIndex) {
269
- const dataIndexKey = Array.isArray(columnItem.dataIndex) ? columnItem.dataIndex.join(".") : columnItem.dataIndex;
270
- matched = dataIndexKey === key;
271
- }
272
- if (matched) {
273
- updater({
274
- column: columnItem,
275
- columnIndex: i,
276
- group: columns.value
277
- });
278
- if (!all) return;
279
- }
280
- }
281
- };
282
- const setColumn = (key, column, options) => {
283
- if (!key || !column) return;
284
- const { updateType = "merge", ...rest } = options || {};
285
- updaterMatch(
286
- key,
287
- ({ column: preColumn, columnIndex, group }) => {
288
- let value = column;
289
- if (typeof column === "function") {
290
- value = column(preColumn);
291
- }
292
- if (!value) return;
293
- if (updateType === "rewrite") {
294
- group[columnIndex] = value;
295
- } else {
296
- Object.assign(preColumn, value);
297
- }
298
- },
299
- rest
300
- );
301
- };
302
- function deleteColumn(path, options) {
303
- if (!path) return;
304
- updaterMatch(
305
- path,
306
- ({ columnIndex, group }) => {
307
- group.splice(columnIndex, 1);
308
- },
309
- options
310
- );
311
- }
312
- function appendColumn(path, column, options) {
313
- const newColumns = Array.isArray(column) ? column : [column];
314
- addColumns(path, newColumns, options, "after");
315
- }
316
- function prependColumn(path, column, options) {
317
- const newColumns = Array.isArray(column) ? column : [column];
318
- addColumns(path, newColumns, options, "before");
319
- }
320
- function addColumns(path, newColumns, options, placement) {
321
- if (newColumns.length === 0) return;
322
- if (path) {
323
- updaterMatch(
324
- path,
325
- ({ columnIndex, group }) => {
326
- const index = placement === "after" ? columnIndex + 1 : columnIndex;
327
- group.splice(index, 0, ...newColumns);
328
- },
329
- options
330
- );
331
- } else if (placement === "after") {
332
- columns.value.push(...newColumns);
333
- } else {
334
- columns.value.unshift(...newColumns);
335
- }
336
- }
337
- return {
338
- columns,
339
- dataSource,
340
- pageParam,
341
- searchForm,
342
- setColumn,
343
- deleteColumn,
344
- appendColumn,
345
- prependColumn,
346
- setPageParam,
347
- resetQueryParams
348
- };
349
- };
350
- export {
351
- InjectionPathKey as I,
352
- InjectionFormKey as a,
353
- useFields as b,
354
- camelizeProperties as c,
355
- useFormRef as d,
356
- useFormData as e,
357
- useTable as f,
358
- getObject as g,
359
- useForm as u
360
- };