@vunk/form 1.1.85 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+
5
+ const useSourceManager = (source, opts = {}) => {
6
+ if (!vue.isRef(source)) {
7
+ source = vue.ref(source);
8
+ }
9
+ const op = {
10
+ ...opts,
11
+ slotsChildren: ["default"]
12
+ };
13
+ opts.slotsChildren && op.slotsChildren.push(...opts.slotsChildren);
14
+ const manager = vue.computed(() => {
15
+ const keyRecord = {};
16
+ const propRecord = {};
17
+ const idRecord = {};
18
+ function intoData(list, k = []) {
19
+ list.forEach((item, index) => {
20
+ const currentK = [...k, index];
21
+ const managerInfo = {
22
+ source: item,
23
+ key: currentK,
24
+ nextKey: [...k, index + 1],
25
+ prop: item.prop,
26
+ id: item.id
27
+ };
28
+ keyRecord[currentK.join()] = managerInfo;
29
+ if (item.prop) {
30
+ propRecord[item.prop] = managerInfo;
31
+ }
32
+ if (item.id) {
33
+ idRecord[item.id] = managerInfo;
34
+ }
35
+ if (item.templateSlots) {
36
+ if (Array.isArray(item.templateSlots)) {
37
+ currentK.push("templateSlots");
38
+ intoData(item.templateSlots, currentK);
39
+ }
40
+ op.slotsChildren.forEach((filed) => {
41
+ if (Array.isArray(item.templateSlots[filed])) {
42
+ currentK.push("templateSlots", filed);
43
+ intoData(item.templateSlots[filed], currentK);
44
+ }
45
+ });
46
+ }
47
+ });
48
+ }
49
+ intoData(vue.unref(source));
50
+ return {
51
+ keyRecord,
52
+ propRecord,
53
+ idRecord
54
+ };
55
+ });
56
+ const getManagerInfoByProp = (prop) => {
57
+ return manager.value.propRecord[prop];
58
+ };
59
+ const getManagerInfoByKey = (key) => {
60
+ return manager.value.keyRecord[key.join()];
61
+ };
62
+ const getManagerInfoById = (id) => {
63
+ return manager.value.idRecord[id];
64
+ };
65
+ return [
66
+ source,
67
+ {
68
+ manager,
69
+ getManagerInfoByProp,
70
+ getManagerInfoByKey,
71
+ getManagerInfoById
72
+ }
73
+ ];
74
+ };
75
+
76
+ const useForm = () => {
77
+ return vue.inject("vkfFormVm", null);
78
+ };
79
+ const useComputedReadonly = (props) => {
80
+ const form = useForm();
81
+ const readonly = vue.computed(() => {
82
+ return props.readonly ?? form?.props.readonly ?? false;
83
+ });
84
+ return readonly;
85
+ };
86
+
87
+ exports.useComputedReadonly = useComputedReadonly;
88
+ exports.useForm = useForm;
89
+ exports.useSourceManager = useSourceManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "1.1.85",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {
@@ -20,59 +20,73 @@
20
20
  },
21
21
  "./shared": {
22
22
  "import": "./shared/index.mjs",
23
- "types": "./shared/index.d.ts"
23
+ "types": "./shared/index.d.ts",
24
+ "require": "./shared/index.cjs"
24
25
  },
25
26
  "./shared/upload": {
26
27
  "import": "./shared/upload/index.mjs",
27
- "types": "./shared/upload/index.d.ts"
28
+ "types": "./shared/upload/index.d.ts",
29
+ "require": "./shared/upload/index.cjs"
28
30
  },
29
31
  "./shared/types": {
30
32
  "import": "./shared/types/index.mjs",
31
- "types": "./shared/types/index.d.ts"
33
+ "types": "./shared/types/index.d.ts",
34
+ "require": "./shared/types/index.cjs"
32
35
  },
33
36
  "./shared/types/source-manager": {
34
37
  "import": "./shared/types/source-manager/index.mjs",
35
- "types": "./shared/types/source-manager/index.d.ts"
38
+ "types": "./shared/types/source-manager/index.d.ts",
39
+ "require": "./shared/types/source-manager/index.cjs"
36
40
  },
37
41
  "./shared/types/source": {
38
42
  "import": "./shared/types/source/index.mjs",
39
- "types": "./shared/types/source/index.d.ts"
43
+ "types": "./shared/types/source/index.d.ts",
44
+ "require": "./shared/types/source/index.cjs"
40
45
  },
41
46
  "./shared/types/form": {
42
47
  "import": "./shared/types/form/index.mjs",
43
- "types": "./shared/types/form/index.d.ts"
48
+ "types": "./shared/types/form/index.d.ts",
49
+ "require": "./shared/types/form/index.cjs"
44
50
  },
45
51
  "./shared/rules": {
46
52
  "import": "./shared/rules/index.mjs",
47
- "types": "./shared/rules/index.d.ts"
53
+ "types": "./shared/rules/index.d.ts",
54
+ "require": "./shared/rules/index.cjs"
48
55
  },
49
56
  "./shared/progress-it": {
50
57
  "import": "./shared/progress-it/index.mjs",
51
- "types": "./shared/progress-it/index.d.ts"
58
+ "types": "./shared/progress-it/index.d.ts",
59
+ "require": "./shared/progress-it/index.cjs"
52
60
  },
53
61
  "./shared/infer-prop": {
54
62
  "import": "./shared/infer-prop/index.mjs",
55
- "types": "./shared/infer-prop/index.d.ts"
63
+ "types": "./shared/infer-prop/index.d.ts",
64
+ "require": "./shared/infer-prop/index.cjs"
56
65
  },
57
66
  "./shared/helper": {
58
67
  "import": "./shared/helper/index.mjs",
59
- "types": "./shared/helper/index.d.ts"
68
+ "types": "./shared/helper/index.d.ts",
69
+ "require": "./shared/helper/index.cjs"
60
70
  },
61
71
  "./shared/form": {
62
72
  "import": "./shared/form/index.mjs",
63
- "types": "./shared/form/index.d.ts"
73
+ "types": "./shared/form/index.d.ts",
74
+ "require": "./shared/form/index.cjs"
64
75
  },
65
76
  "./shared/element-plus": {
66
77
  "import": "./shared/element-plus/index.mjs",
67
- "types": "./shared/element-plus/index.d.ts"
78
+ "types": "./shared/element-plus/index.d.ts",
79
+ "require": "./shared/element-plus/index.cjs"
68
80
  },
69
81
  "./shared/const": {
70
82
  "import": "./shared/const/index.mjs",
71
- "types": "./shared/const/index.d.ts"
83
+ "types": "./shared/const/index.d.ts",
84
+ "require": "./shared/const/index.cjs"
72
85
  },
73
86
  "./composables": {
74
87
  "import": "./composables/index.mjs",
75
- "types": "./composables/index.d.ts"
88
+ "types": "./composables/index.d.ts",
89
+ "require": "./composables/index.cjs"
76
90
  },
77
91
  "./components": {
78
92
  "import": "./components/index.mjs",
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ const CORE_FORM_TEMPLATE_OPTIONS = [
4
+ {
5
+ value: "VkfInput",
6
+ label: "\u8F93\u5165\u6846"
7
+ },
8
+ {
9
+ value: "VkfSelect",
10
+ label: "\u4E0B\u62C9\u6846"
11
+ },
12
+ {
13
+ value: "VkfCheckbox",
14
+ label: "\u591A\u9009\u6846"
15
+ },
16
+ {
17
+ value: "VkfRadio",
18
+ label: "\u5355\u9009\u6846"
19
+ },
20
+ {
21
+ value: "VkfDatePicker",
22
+ label: "\u65E5\u671F\u9009\u62E9\u5668"
23
+ },
24
+ {
25
+ value: "VkfInputNumber",
26
+ label: "\u6570\u5B57\u8F93\u5165\u6846"
27
+ },
28
+ {
29
+ value: "VkfSwitch",
30
+ label: "\u5F00\u5173"
31
+ },
32
+ {
33
+ value: "VkfSlider",
34
+ label: "\u6ED1\u5757"
35
+ },
36
+ {
37
+ value: "VkfInputLink",
38
+ label: "\u94FE\u63A5\u8F93\u5165\u6846"
39
+ },
40
+ {
41
+ value: "VkfEsriInputGeojson",
42
+ label: "\u5730\u4FE1\u8F93\u5165\u6846"
43
+ },
44
+ {
45
+ value: "VkfCascader",
46
+ label: "\u7EA7\u8054\u9009\u62E9\u5668"
47
+ },
48
+ {
49
+ value: "VkfUpload",
50
+ label: "\u4E0A\u4F20"
51
+ }
52
+ ];
53
+ const CORE_FORM_TEMPLATE_REFLECT = CORE_FORM_TEMPLATE_OPTIONS.reduce((acc, cur) => {
54
+ acc[cur.value] = cur;
55
+ return acc;
56
+ }, {});
57
+
58
+ exports.CORE_FORM_TEMPLATE_OPTIONS = CORE_FORM_TEMPLATE_OPTIONS;
59
+ exports.CORE_FORM_TEMPLATE_REFLECT = CORE_FORM_TEMPLATE_REFLECT;
@@ -0,0 +1,317 @@
1
+ 'use strict';
2
+
3
+ var elementPlus = require('element-plus');
4
+ var utilsVue = require('@vunk/core/shared/utils-vue');
5
+ var vue = require('vue');
6
+
7
+ /*! Element Plus Icons Vue v2.3.1 */
8
+
9
+ var arrow_down_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
10
+ name: "ArrowDown",
11
+ __name: "arrow-down",
12
+ setup(__props) {
13
+ return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", {
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ viewBox: "0 0 1024 1024"
16
+ }, [
17
+ vue.createElementVNode("path", {
18
+ fill: "currentColor",
19
+ d: "M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"
20
+ })
21
+ ]));
22
+ }
23
+ });
24
+
25
+ // src/components/arrow-down.vue
26
+ var arrow_down_default = arrow_down_vue_vue_type_script_setup_true_lang_default;
27
+ var circle_close_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
28
+ name: "CircleClose",
29
+ __name: "circle-close",
30
+ setup(__props) {
31
+ return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", {
32
+ xmlns: "http://www.w3.org/2000/svg",
33
+ viewBox: "0 0 1024 1024"
34
+ }, [
35
+ vue.createElementVNode("path", {
36
+ fill: "currentColor",
37
+ d: "m466.752 512-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248z"
38
+ }),
39
+ vue.createElementVNode("path", {
40
+ fill: "currentColor",
41
+ d: "M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"
42
+ })
43
+ ]));
44
+ }
45
+ });
46
+
47
+ // src/components/circle-close.vue
48
+ var circle_close_default = circle_close_vue_vue_type_script_setup_true_lang_default;
49
+
50
+ const datePickerProps = {
51
+ ...elementPlus.timePickerDefaultProps,
52
+ type: {
53
+ type: String,
54
+ default: "date"
55
+ }
56
+ };
57
+ const datePickerEmits = {
58
+ "update:modelValue": null,
59
+ "change": null,
60
+ "focus": null,
61
+ "blur": null,
62
+ "calendar-change": null,
63
+ "panel-change": null,
64
+ "visible-change": null,
65
+ "keydown": null
66
+ };
67
+ const selectProps = {
68
+ name: String,
69
+ id: String,
70
+ modelValue: {
71
+ type: [Array, String, Number, Boolean, Object],
72
+ default: void 0
73
+ },
74
+ autocomplete: {
75
+ type: String,
76
+ default: "off"
77
+ },
78
+ automaticDropdown: Boolean,
79
+ size: {
80
+ type: String
81
+ },
82
+ effect: {
83
+ type: String,
84
+ default: "light"
85
+ },
86
+ disabled: Boolean,
87
+ clearable: Boolean,
88
+ filterable: Boolean,
89
+ allowCreate: Boolean,
90
+ loading: Boolean,
91
+ popperClass: {
92
+ type: String,
93
+ default: ""
94
+ },
95
+ remote: Boolean,
96
+ loadingText: String,
97
+ noMatchText: String,
98
+ noDataText: String,
99
+ remoteMethod: Function,
100
+ filterMethod: Function,
101
+ multiple: Boolean,
102
+ multipleLimit: {
103
+ type: Number,
104
+ default: 0
105
+ },
106
+ placeholder: {
107
+ type: String
108
+ },
109
+ defaultFirstOption: Boolean,
110
+ reserveKeyword: {
111
+ type: Boolean,
112
+ default: true
113
+ },
114
+ valueKey: {
115
+ type: String,
116
+ default: "value"
117
+ },
118
+ collapseTags: Boolean,
119
+ collapseTagsTooltip: {
120
+ type: Boolean,
121
+ default: false
122
+ },
123
+ teleported: elementPlus.useTooltipContentProps.teleported,
124
+ persistent: {
125
+ type: Boolean,
126
+ default: true
127
+ },
128
+ clearIcon: {
129
+ type: [String, Object],
130
+ default: circle_close_default
131
+ },
132
+ fitInputWidth: {
133
+ type: Boolean,
134
+ default: false
135
+ },
136
+ suffixIcon: {
137
+ type: [String, Object],
138
+ default: arrow_down_default
139
+ },
140
+ // eslint-disable-next-line vue/require-prop-types
141
+ tagType: { ...elementPlus.tagProps.type, default: "info" }
142
+ };
143
+ const selectEmits = {
144
+ "update:modelValue": null,
145
+ "change": null,
146
+ "remove-tag": null,
147
+ "clear": null,
148
+ "visible-change": null,
149
+ "focus": null,
150
+ "blur": null
151
+ };
152
+
153
+ const createInputBindProps = utilsVue.bindPropsFactory(elementPlus.inputProps);
154
+ const createInputOnEmits = utilsVue.onEmitsFactory(elementPlus.inputEmits);
155
+ const createFormBindProps = utilsVue.bindPropsFactory(elementPlus.formProps);
156
+ const createFormOnEmits = utilsVue.onEmitsFactory(elementPlus.formEmits);
157
+ const createFormItemBindProps = utilsVue.bindPropsFactory(elementPlus.formItemProps);
158
+ const createSwitchBindProps = utilsVue.bindPropsFactory(elementPlus.switchProps);
159
+ const createSwitchOnEmits = utilsVue.onEmitsFactory(elementPlus.switchEmits);
160
+ const createSelectBindProps = utilsVue.bindPropsFactory(selectProps);
161
+ const createSelectOnEmits = utilsVue.onEmitsFactory(selectEmits);
162
+ const createDatePickerBindProps = utilsVue.bindPropsFactory(datePickerProps);
163
+ const createDatePickerOnEmits = utilsVue.onEmitsFactory(datePickerEmits);
164
+ const createInputNumberBindProps = utilsVue.bindPropsFactory(elementPlus.inputNumberProps);
165
+ const createInputNumberOnEmits = utilsVue.onEmitsFactory(elementPlus.inputNumberEmits);
166
+ const createRadioGroupBindProps = utilsVue.bindPropsFactory(elementPlus.radioGroupProps);
167
+ const createRadioGroupOnEmits = utilsVue.onEmitsFactory(elementPlus.radioGroupEmits);
168
+ const createCheckboxGroupBindProps = utilsVue.bindPropsFactory(elementPlus.checkboxGroupProps);
169
+ const createCheckboxGroupOnEmits = utilsVue.onEmitsFactory(elementPlus.checkboxGroupEmits);
170
+ const createUploadBindProps = utilsVue.bindPropsFactory(elementPlus.uploadProps);
171
+ const createColorPickerBindProps = utilsVue.bindPropsFactory(elementPlus.colorPickerProps);
172
+ const createColorPickerOnEmits = utilsVue.onEmitsFactory(elementPlus.colorPickerEmits);
173
+ const createButtonBindProps = utilsVue.bindPropsFactory(elementPlus.buttonProps);
174
+ const createButtonOnEmits = utilsVue.onEmitsFactory(elementPlus.buttonEmits);
175
+ const createCascaderBindProps = utilsVue.bindPropsFactory(elementPlus.cascaderProps);
176
+ const createCascaderOnEmits = utilsVue.onEmitsFactory(elementPlus.cascaderEmits);
177
+ const createSliderBindProps = utilsVue.bindPropsFactory(elementPlus.sliderProps);
178
+ const createSliderOnEmits = utilsVue.onEmitsFactory(elementPlus.sliderEmits);
179
+
180
+ const semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
181
+ const validateAndParse = (version) => {
182
+ if (typeof version !== 'string') {
183
+ throw new TypeError('Invalid argument expected string');
184
+ }
185
+ const match = version.match(semver);
186
+ if (!match) {
187
+ throw new Error(`Invalid argument not valid semver ('${version}' received)`);
188
+ }
189
+ match.shift();
190
+ return match;
191
+ };
192
+ const isWildcard = (s) => s === '*' || s === 'x' || s === 'X';
193
+ const tryParse = (v) => {
194
+ const n = parseInt(v, 10);
195
+ return isNaN(n) ? v : n;
196
+ };
197
+ const forceType = (a, b) => typeof a !== typeof b ? [String(a), String(b)] : [a, b];
198
+ const compareStrings = (a, b) => {
199
+ if (isWildcard(a) || isWildcard(b))
200
+ return 0;
201
+ const [ap, bp] = forceType(tryParse(a), tryParse(b));
202
+ if (ap > bp)
203
+ return 1;
204
+ if (ap < bp)
205
+ return -1;
206
+ return 0;
207
+ };
208
+ const compareSegments = (a, b) => {
209
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
210
+ const r = compareStrings(a[i] || '0', b[i] || '0');
211
+ if (r !== 0)
212
+ return r;
213
+ }
214
+ return 0;
215
+ };
216
+
217
+ /**
218
+ * Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
219
+ * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
220
+ * @param v1 - First version to compare
221
+ * @param v2 - Second version to compare
222
+ * @returns Numeric value compatible with the [Array.sort(fn) interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).
223
+ */
224
+ const compareVersions = (v1, v2) => {
225
+ // validate input and split into segments
226
+ const n1 = validateAndParse(v1);
227
+ const n2 = validateAndParse(v2);
228
+ // pop off the patch
229
+ const p1 = n1.pop();
230
+ const p2 = n2.pop();
231
+ // validate numbers
232
+ const r = compareSegments(n1, n2);
233
+ if (r !== 0)
234
+ return r;
235
+ // validate pre-release
236
+ if (p1 && p2) {
237
+ return compareSegments(p1.split('.'), p2.split('.'));
238
+ }
239
+ else if (p1 || p2) {
240
+ return p1 ? -1 : 1;
241
+ }
242
+ return 0;
243
+ };
244
+
245
+ /**
246
+ * Compare [semver](https://semver.org/) version strings using the specified operator.
247
+ *
248
+ * @param v1 First version to compare
249
+ * @param v2 Second version to compare
250
+ * @param operator Allowed arithmetic operator to use
251
+ * @returns `true` if the comparison between the firstVersion and the secondVersion satisfies the operator, `false` otherwise.
252
+ *
253
+ * @example
254
+ * ```
255
+ * compare('10.1.8', '10.0.4', '>'); // return true
256
+ * compare('10.0.1', '10.0.1', '='); // return true
257
+ * compare('10.1.1', '10.2.2', '<'); // return true
258
+ * compare('10.1.1', '10.2.2', '<='); // return true
259
+ * compare('10.1.1', '10.2.2', '>='); // return false
260
+ * ```
261
+ */
262
+ const compare = (v1, v2, operator) => {
263
+ // validate input operator
264
+ assertValidOperator(operator);
265
+ // since result of compareVersions can only be -1 or 0 or 1
266
+ // a simple map can be used to replace switch
267
+ const res = compareVersions(v1, v2);
268
+ return operatorResMap[operator].includes(res);
269
+ };
270
+ const operatorResMap = {
271
+ '>': [1],
272
+ '>=': [0, 1],
273
+ '=': [0],
274
+ '<=': [-1, 0],
275
+ '<': [-1],
276
+ '!=': [-1, 1],
277
+ };
278
+ const allowedOperators = Object.keys(operatorResMap);
279
+ const assertValidOperator = (op) => {
280
+ if (allowedOperators.indexOf(op) === -1) {
281
+ throw new Error(`Invalid operator, expected one of ${allowedOperators.join('|')}`);
282
+ }
283
+ };
284
+
285
+ const isGte2_6_0 = compare(elementPlus.version, "2.6.0", ">=");
286
+
287
+ exports.createButtonBindProps = createButtonBindProps;
288
+ exports.createButtonOnEmits = createButtonOnEmits;
289
+ exports.createCascaderBindProps = createCascaderBindProps;
290
+ exports.createCascaderOnEmits = createCascaderOnEmits;
291
+ exports.createCheckboxGroupBindProps = createCheckboxGroupBindProps;
292
+ exports.createCheckboxGroupOnEmits = createCheckboxGroupOnEmits;
293
+ exports.createColorPickerBindProps = createColorPickerBindProps;
294
+ exports.createColorPickerOnEmits = createColorPickerOnEmits;
295
+ exports.createDatePickerBindProps = createDatePickerBindProps;
296
+ exports.createDatePickerOnEmits = createDatePickerOnEmits;
297
+ exports.createFormBindProps = createFormBindProps;
298
+ exports.createFormItemBindProps = createFormItemBindProps;
299
+ exports.createFormOnEmits = createFormOnEmits;
300
+ exports.createInputBindProps = createInputBindProps;
301
+ exports.createInputNumberBindProps = createInputNumberBindProps;
302
+ exports.createInputNumberOnEmits = createInputNumberOnEmits;
303
+ exports.createInputOnEmits = createInputOnEmits;
304
+ exports.createRadioGroupBindProps = createRadioGroupBindProps;
305
+ exports.createRadioGroupOnEmits = createRadioGroupOnEmits;
306
+ exports.createSelectBindProps = createSelectBindProps;
307
+ exports.createSelectOnEmits = createSelectOnEmits;
308
+ exports.createSliderBindProps = createSliderBindProps;
309
+ exports.createSliderOnEmits = createSliderOnEmits;
310
+ exports.createSwitchBindProps = createSwitchBindProps;
311
+ exports.createSwitchOnEmits = createSwitchOnEmits;
312
+ exports.createUploadBindProps = createUploadBindProps;
313
+ exports.datePickerEmits = datePickerEmits;
314
+ exports.datePickerProps = datePickerProps;
315
+ exports.isGte2_6_0 = isGte2_6_0;
316
+ exports.selectEmits = selectEmits;
317
+ exports.selectProps = selectProps;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var elementPlus = require('element-plus');
4
+
5
+ const validateCatch = (err, init = {}) => {
6
+ let msg = "";
7
+ msg += init.prefix || "";
8
+ for (const key in err) {
9
+ err[key].forEach((v) => {
10
+ msg += v.message + ";";
11
+ });
12
+ }
13
+ msg += init.suffix || "";
14
+ elementPlus.ElMessage({
15
+ type: "warning",
16
+ message: msg
17
+ });
18
+ };
19
+ const genTemplateIfFunc = (templateIfRaw) => {
20
+ if (typeof templateIfRaw === "boolean") {
21
+ const flag = templateIfRaw;
22
+ return () => flag;
23
+ } else if (typeof templateIfRaw === "string") {
24
+ const templateIf = new Function("data", templateIfRaw);
25
+ return templateIf;
26
+ } else if (typeof templateIfRaw === "function") {
27
+ return templateIfRaw;
28
+ }
29
+ return () => true;
30
+ };
31
+
32
+ exports.genTemplateIfFunc = genTemplateIfFunc;
33
+ exports.validateCatch = validateCatch;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ const createDefaultSlots = (o) => {
4
+ return {
5
+ default: Array.isArray(o) ? o : [
6
+ o
7
+ ]
8
+ };
9
+ };
10
+
11
+ exports.createDefaultSlots = createDefaultSlots;
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var index = require('./const/index.cjs');
4
+
5
+
6
+
7
+ exports.CORE_FORM_TEMPLATE_OPTIONS = index.CORE_FORM_TEMPLATE_OPTIONS;
8
+ exports.CORE_FORM_TEMPLATE_REFLECT = index.CORE_FORM_TEMPLATE_REFLECT;
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const inferString = (item) => ({
4
+ prop: item.prop,
5
+ type: "String"
6
+ });
7
+ const inferBoolean = (item) => ({
8
+ prop: item.prop,
9
+ type: "Boolean"
10
+ });
11
+ const inferNumber = (item) => {
12
+ const info = {
13
+ prop: item.prop,
14
+ type: "Number"
15
+ };
16
+ if (item.precision) {
17
+ info.precision = item.precision;
18
+ }
19
+ return info;
20
+ };
21
+ const inferDate = (item) => ({
22
+ prop: item.prop,
23
+ type: "Date"
24
+ });
25
+ const propInfoAction = {
26
+ VkfSelect: inferString,
27
+ VkfRadio: inferString,
28
+ VkfCheckbox: inferString,
29
+ VkfColorPicker: inferString,
30
+ VkfInputNumber: inferNumber,
31
+ VkfSwitch: inferBoolean,
32
+ VkfUpload: inferString,
33
+ VkfDatePicker: inferDate
34
+ };
35
+
36
+ exports.propInfoAction = propInfoAction;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const ifElse = (fn1, fn2, fn3) => (x) => fn1(x) ? fn2(x) : fn3(x);
4
+ const progress = (effect, option) => (state) => {
5
+ const $data = {
6
+ interval: 100,
7
+ speed: 0.01,
8
+ ...option,
9
+ percent: 0,
10
+ timeLine: 0,
11
+ timer: void 0
12
+ };
13
+ const $stateInitFlow = ($data2) => ifElse(
14
+ (state2) => Boolean(state2),
15
+ (state2) => effect(1, state2),
16
+ (state2) => setInterval(() => {
17
+ $data2.timeLine++;
18
+ $data2.percent = state2 ? 1 : (-1 / ($data2.speed * $data2.timeLine + 1) + 1) * 1;
19
+ effect($data2.percent, state2);
20
+ }, $data2.interval)
21
+ );
22
+ $data.timer = $stateInitFlow($data)(state);
23
+ const setter = (newState) => {
24
+ if (typeof newState !== "boolean") {
25
+ $data.timer && clearInterval($data.timer);
26
+ $data.percent = 1;
27
+ effect($data.percent, "fail");
28
+ return setter;
29
+ }
30
+ if (newState) {
31
+ $data.timer && clearInterval($data.timer);
32
+ $data.percent = 1;
33
+ effect($data.percent, newState);
34
+ }
35
+ return setter;
36
+ };
37
+ return setter;
38
+ };
39
+
40
+ module.exports = progress;