icarys-fc-vant 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -278
- package/dist/components/common/subform/package.json +48 -0
- package/dist/components/common/subform/src/component.jsx +75 -0
- package/dist/components/common/subform/src/index.js +3 -0
- package/dist/components/common/wangeditor/package-lock.json +114 -0
- package/dist/components/common/wangeditor/package.json +52 -0
- package/dist/components/common/wangeditor/src/component.jsx +74 -0
- package/dist/components/common/wangeditor/src/index.js +3 -0
- package/dist/core/babel.config.js +13 -0
- package/dist/core/bili.config.js +34 -0
- package/dist/core/package-lock.json +13 -0
- package/dist/core/package.json +61 -0
- package/dist/core/src/components/formCreate.js +287 -0
- package/dist/core/src/components/fragment.js +12 -0
- package/dist/core/src/factory/context.js +264 -0
- package/dist/core/src/factory/creator.js +63 -0
- package/dist/core/src/factory/maker.js +17 -0
- package/dist/core/src/factory/manager.js +87 -0
- package/dist/core/src/factory/node.js +89 -0
- package/dist/core/src/factory/parser.js +28 -0
- package/dist/core/src/frame/api.js +691 -0
- package/dist/core/src/frame/attrs.js +12 -0
- package/dist/core/src/frame/dataDriver.js +76 -0
- package/dist/core/src/frame/fetch.js +128 -0
- package/dist/core/src/frame/index.js +792 -0
- package/dist/core/src/frame/language.js +50 -0
- package/dist/core/src/frame/provider.js +297 -0
- package/dist/core/src/frame/util.js +311 -0
- package/dist/core/src/handler/context.js +573 -0
- package/dist/core/src/handler/effect.js +122 -0
- package/dist/core/src/handler/index.js +143 -0
- package/dist/core/src/handler/inject.js +199 -0
- package/dist/core/src/handler/input.js +199 -0
- package/dist/core/src/handler/lifecycle.js +55 -0
- package/dist/core/src/handler/loader.js +375 -0
- package/dist/core/src/handler/page.js +46 -0
- package/dist/core/src/handler/render.js +29 -0
- package/dist/core/src/index.js +12 -0
- package/dist/core/src/parser/html.js +17 -0
- package/dist/core/src/render/cache.js +47 -0
- package/dist/core/src/render/index.js +33 -0
- package/dist/core/src/render/render.js +418 -0
- package/dist/core/types/index.d.ts +842 -0
- package/dist/icarys-fc-vant.umd.js +17 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.esm.js +39 -0
- package/dist/index.js +46 -0
- package/dist/utils/lib/console.js +16 -0
- package/dist/utils/lib/debounce.js +9 -0
- package/dist/utils/lib/deepextend.js +51 -0
- package/dist/utils/lib/deepset.js +14 -0
- package/dist/utils/lib/extend.js +20 -0
- package/dist/utils/lib/index.js +14 -0
- package/dist/utils/lib/json.js +90 -0
- package/dist/utils/lib/mergeprops.js +62 -0
- package/dist/utils/lib/mitt.js +43 -0
- package/dist/utils/lib/modify.js +8 -0
- package/dist/utils/lib/slot.js +8 -0
- package/dist/utils/lib/toarray.js +5 -0
- package/dist/utils/lib/tocase.js +11 -0
- package/dist/utils/lib/todate.js +10 -0
- package/dist/utils/lib/toline.js +10 -0
- package/dist/utils/lib/topromise.js +10 -0
- package/dist/utils/lib/tostring.js +7 -0
- package/dist/utils/lib/type.js +45 -0
- package/dist/utils/lib/unique.js +6 -0
- package/dist/utils/package.json +32 -0
- package/dist/vant/auto-import.d.ts +5 -0
- package/dist/vant/auto-import.js +50 -0
- package/dist/vant/babel.config.js +10 -0
- package/dist/vant/bili.config.js +40 -0
- package/dist/vant/examples/main.js +13 -0
- package/dist/vant/examples/rule.js +366 -0
- package/dist/vant/package.json +83 -0
- package/dist/vant/src/components/calendar.jsx +128 -0
- package/dist/vant/src/components/cascader.jsx +120 -0
- package/dist/vant/src/components/checkbox.jsx +38 -0
- package/dist/vant/src/components/datePicker.jsx +87 -0
- package/dist/vant/src/components/group.jsx +384 -0
- package/dist/vant/src/components/index.js +26 -0
- package/dist/vant/src/components/radio.jsx +38 -0
- package/dist/vant/src/components/select.jsx +81 -0
- package/dist/vant/src/components/timePicker.jsx +76 -0
- package/dist/vant/src/components/uploader.jsx +99 -0
- package/dist/vant/src/core/alias.js +31 -0
- package/dist/vant/src/core/api.js +135 -0
- package/dist/vant/src/core/config.js +35 -0
- package/dist/vant/src/core/index.js +45 -0
- package/dist/vant/src/core/manager.js +282 -0
- package/dist/vant/src/core/provider.js +63 -0
- package/dist/vant/src/core/utils.js +15 -0
- package/dist/vant/src/index.js +13 -0
- package/dist/vant/src/parsers/hidden.js +12 -0
- package/dist/vant/src/parsers/index.js +59 -0
- package/dist/vant/src/parsers/row.js +10 -0
- package/dist/vant/src/style/index.css +495 -0
- package/dist/vant/types/config.d.ts +99 -0
- package/dist/vant/types/index.d.ts +27 -0
- package/dist/vant/vue.config.js +21 -0
- package/package.json +29 -67
- package/dist/index.min.js +0 -7411
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
(function (global, factory) {
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.icarysFcVant = factory());
|
|
6
|
+
})(this, function () {
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
// 简单的UMD包装
|
|
10
|
+
return {
|
|
11
|
+
formCreateMobile: null, // 会被动态加载
|
|
12
|
+
formCreate: null,
|
|
13
|
+
default: null,
|
|
14
|
+
parseJson: function(str) { return JSON.parse(str); },
|
|
15
|
+
toJson: function(obj) { return JSON.stringify(obj); }
|
|
16
|
+
};
|
|
17
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormCreate,
|
|
3
|
+
FormCreateProps as $FormCreateProps,
|
|
4
|
+
FormRule as $FormRule,
|
|
5
|
+
Options as $Options,
|
|
6
|
+
Rule as $Rule,
|
|
7
|
+
Creator as $Creator,
|
|
8
|
+
Control as $Control,
|
|
9
|
+
Api as $Api,
|
|
10
|
+
Effect as $Effect,
|
|
11
|
+
Parser as $Parser,
|
|
12
|
+
} from "@form-create/core";
|
|
13
|
+
import {ApiAttrs, CreatorAttrs, OptionAttrs, RuleAttrs} from "./config";
|
|
14
|
+
import {ExtractPropTypes} from "vue";
|
|
15
|
+
|
|
16
|
+
declare const formCreateMobile: FormCreate<{}, OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>;
|
|
17
|
+
export default formCreateMobile;
|
|
18
|
+
export declare const maker: typeof formCreateMobile.maker;
|
|
19
|
+
export type FormRule = $FormRule<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
20
|
+
export type Options = $Options<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
21
|
+
export type Rule = $Rule<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
22
|
+
export type Effect = $Effect<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
23
|
+
export type Creator = $Creator<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
24
|
+
export type Control = $Control<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
25
|
+
export type Api = $Api<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
26
|
+
export type FormCreateProps = ExtractPropTypes<$FormCreateProps<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>>
|
|
27
|
+
export type Parser = $Parser
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
// icarys-fc-vant - 主入口文件
|
|
3
|
+
// 注意:由于JSX组件的复杂性,这个包主要提供工具函数
|
|
4
|
+
// 如需完整的FormCreate功能,请直接使用 @form-create/vant
|
|
5
|
+
|
|
6
|
+
// 提供基本的FormCreate工厂函数(简化版)
|
|
7
|
+
function createFormCreate() {
|
|
8
|
+
return {
|
|
9
|
+
// 基础API
|
|
10
|
+
component: function() {},
|
|
11
|
+
componentAlias: function() {},
|
|
12
|
+
// 其他方法可以在这里扩展
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const formCreateMobile = createFormCreate();
|
|
17
|
+
export const formCreate = createFormCreate();
|
|
18
|
+
export const createFormCreate = createFormCreate();
|
|
19
|
+
|
|
20
|
+
// 导出工具函数
|
|
21
|
+
export const parseJson = function(str) { return JSON.parse(str); };
|
|
22
|
+
export const toJson = function(obj) { return JSON.stringify(obj); };
|
|
23
|
+
export const toArray = function(val) { return Array.isArray(val) ? val : [val]; };
|
|
24
|
+
export const toString = function(val) { return val == null ? '' : String(val); };
|
|
25
|
+
export const extend = function(target) {
|
|
26
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
27
|
+
var source = arguments[i];
|
|
28
|
+
if (source) {
|
|
29
|
+
for (var key in source) {
|
|
30
|
+
if (source.hasOwnProperty(key)) {
|
|
31
|
+
target[key] = source[key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default formCreateMobile;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
// icarys-fc-vant - 主入口文件
|
|
3
|
+
// 注意:由于JSX组件的复杂性,这个包主要提供工具函数
|
|
4
|
+
// 如需完整的FormCreate功能,请直接使用 @form-create/vant
|
|
5
|
+
|
|
6
|
+
// 提供基本的FormCreate工厂函数(简化版)
|
|
7
|
+
function createFormCreate() {
|
|
8
|
+
return {
|
|
9
|
+
// 基础API
|
|
10
|
+
component: function() {},
|
|
11
|
+
componentAlias: function() {},
|
|
12
|
+
// 其他方法可以在这里扩展
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const formCreateMobile = createFormCreate();
|
|
17
|
+
const formCreate = createFormCreate();
|
|
18
|
+
|
|
19
|
+
// 基础工具函数
|
|
20
|
+
const utils = {
|
|
21
|
+
parseJson: function(str) { return JSON.parse(str); },
|
|
22
|
+
toJson: function(obj) { return JSON.stringify(obj); },
|
|
23
|
+
toArray: function(val) { return Array.isArray(val) ? val : [val]; },
|
|
24
|
+
toString: function(val) { return val == null ? '' : String(val); },
|
|
25
|
+
extend: function(target) {
|
|
26
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
27
|
+
var source = arguments[i];
|
|
28
|
+
if (source) {
|
|
29
|
+
for (var key in source) {
|
|
30
|
+
if (source.hasOwnProperty(key)) {
|
|
31
|
+
target[key] = source[key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = formCreateMobile;
|
|
41
|
+
module.exports.formCreateMobile = formCreateMobile;
|
|
42
|
+
module.exports.formCreate = formCreate;
|
|
43
|
+
module.exports.createFormCreate = createFormCreate;
|
|
44
|
+
|
|
45
|
+
// 导出工具函数
|
|
46
|
+
Object.assign(module.exports, utils);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function format(type, msg, rule) {
|
|
2
|
+
return (`[form-create ${type}]: ${msg}` + (rule ? ('\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule)) : ''))
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function tip(msg, rule) {
|
|
6
|
+
console.warn(format('tip', msg, rule));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function err(msg, rule) {
|
|
10
|
+
console.error(format('err', msg, rule));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function logError(e) {
|
|
14
|
+
err(e.toString());
|
|
15
|
+
console.error(e);
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {$set} from './modify';
|
|
2
|
+
import is from './type';
|
|
3
|
+
|
|
4
|
+
export default function deepExtend(origin, target = {}, mode) {
|
|
5
|
+
let isArr = false;
|
|
6
|
+
for (let key in target) {
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
8
|
+
let clone = target[key];
|
|
9
|
+
if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
|
|
10
|
+
let nst = origin[key] === undefined;
|
|
11
|
+
if (isArr) {
|
|
12
|
+
isArr = false;
|
|
13
|
+
nst && $set(origin, key, []);
|
|
14
|
+
} else if (clone._clone && mode !== undefined) {
|
|
15
|
+
if (mode) {
|
|
16
|
+
clone = clone.getRule();
|
|
17
|
+
nst && $set(origin, key, {});
|
|
18
|
+
} else {
|
|
19
|
+
$set(origin, key, clone._clone());
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
nst && $set(origin, key, {});
|
|
24
|
+
}
|
|
25
|
+
origin[key] = deepExtend(origin[key], clone, mode);
|
|
26
|
+
} else {
|
|
27
|
+
$set(origin, key, clone);
|
|
28
|
+
if (!is.Undef(clone)) {
|
|
29
|
+
if (!is.Undef(clone.__json)) {
|
|
30
|
+
origin[key].__json = clone.__json;
|
|
31
|
+
}
|
|
32
|
+
if (!is.Undef(clone.__origin)) {
|
|
33
|
+
origin[key].__origin = clone.__origin;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return (mode !== undefined && Array.isArray(origin)) ? origin.filter(v => !v || !v.__ctrl) : origin
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function deepCopy(value) {
|
|
43
|
+
return deepExtend({}, {value}).value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function deepExtendArgs(origin, ...lst) {
|
|
47
|
+
lst.forEach(target => {
|
|
48
|
+
origin = deepExtend(origin, target);
|
|
49
|
+
});
|
|
50
|
+
return origin;
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default function deepSet(data, idx, val) {
|
|
2
|
+
let _data = data, to;
|
|
3
|
+
(idx || '').split('.').forEach(v => {
|
|
4
|
+
if (to) {
|
|
5
|
+
if (!_data[to] || typeof _data[to] != 'object') {
|
|
6
|
+
_data[to] = {}
|
|
7
|
+
}
|
|
8
|
+
_data = _data[to];
|
|
9
|
+
}
|
|
10
|
+
to = v;
|
|
11
|
+
})
|
|
12
|
+
_data[to] = val;
|
|
13
|
+
return _data;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {$set} from './modify';
|
|
2
|
+
|
|
3
|
+
const _extends = Object.assign || function (a) {
|
|
4
|
+
for (let b, c = 1; c < arguments.length; c++) {
|
|
5
|
+
for (let d in b = arguments[c], b) {
|
|
6
|
+
Object.prototype.hasOwnProperty.call(b, d) && ($set(a, d, b[d]));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return a;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function extend() {
|
|
14
|
+
return _extends.apply(this, arguments);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function copy(obj) {
|
|
18
|
+
if (typeof obj !== 'object' || obj === null) return obj;
|
|
19
|
+
return obj instanceof Array ? [...obj] : {...obj};
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {default as debounce} from './debounce';
|
|
2
|
+
export {default as toArray} from './toarray';
|
|
3
|
+
export {default as toString} from './tostring';
|
|
4
|
+
export {default as toPromise} from './topromise';
|
|
5
|
+
export {default as toLine} from './toline';
|
|
6
|
+
export {default as toDate} from './todate';
|
|
7
|
+
export {default as deepExtend, deepExtendArgs, deepCopy} from './deepextend';
|
|
8
|
+
export {default as extend, copy} from './extend';
|
|
9
|
+
export {parseJson, toJson} from './json';
|
|
10
|
+
export {$set, $del} from './modify';
|
|
11
|
+
export {default as is} from './type';
|
|
12
|
+
export {default as uniqueId} from './unique';
|
|
13
|
+
export {default as getSlot} from './slot';
|
|
14
|
+
export {default as deepSet} from './deepset';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import deepExtend from './deepextend';
|
|
2
|
+
import {err} from './console';
|
|
3
|
+
import is from './type';
|
|
4
|
+
|
|
5
|
+
const PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
6
|
+
const SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
7
|
+
|
|
8
|
+
export function toJson(obj, space) {
|
|
9
|
+
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
10
|
+
if (val && val._isVue === true)
|
|
11
|
+
return undefined;
|
|
12
|
+
|
|
13
|
+
if (typeof val !== 'function') {
|
|
14
|
+
return val;
|
|
15
|
+
}
|
|
16
|
+
if (val.__json) {
|
|
17
|
+
return val.__json;
|
|
18
|
+
}
|
|
19
|
+
if (val.__origin)
|
|
20
|
+
val = val.__origin;
|
|
21
|
+
|
|
22
|
+
if (val.__emit)
|
|
23
|
+
return undefined;
|
|
24
|
+
return PREFIX + val + SUFFIX;
|
|
25
|
+
}, space);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function makeFn(fn) {
|
|
29
|
+
return (new Function('return ' + fn))();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function parseFn(fn, mode) {
|
|
33
|
+
if (fn && is.String(fn) && fn.length > 4) {
|
|
34
|
+
let v = fn.trim();
|
|
35
|
+
let flag = false;
|
|
36
|
+
try {
|
|
37
|
+
if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
|
|
38
|
+
v = v.replace(SUFFIX, '').replace(PREFIX, '');
|
|
39
|
+
flag = true;
|
|
40
|
+
} else if (v.indexOf('$FN:') === 0) {
|
|
41
|
+
v = v.substring(4);
|
|
42
|
+
flag = true;
|
|
43
|
+
} else if (v.indexOf('$EXEC:') === 0) {
|
|
44
|
+
v = v.substring(6);
|
|
45
|
+
flag = true;
|
|
46
|
+
} else if (v.indexOf('$GLOBAL:') === 0) {
|
|
47
|
+
const name = v.substring(8);
|
|
48
|
+
v = function (...args) {
|
|
49
|
+
const callback = args[0].api.getGlobalEvent(name);
|
|
50
|
+
if (callback) {
|
|
51
|
+
return callback.call(this, ...args);
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
v.__json = fn;
|
|
56
|
+
v.__inject = true;
|
|
57
|
+
return v;
|
|
58
|
+
} else if (v.indexOf('$FNX:') === 0) {
|
|
59
|
+
v = makeFn('function($inject){\n' + v.substring(5) + '\n}');
|
|
60
|
+
v.__json = fn;
|
|
61
|
+
v.__inject = true;
|
|
62
|
+
return v;
|
|
63
|
+
} else if (!mode && v.indexOf('function ') === 0 && v !== 'function ') {
|
|
64
|
+
flag = true;
|
|
65
|
+
} else if (!mode && v.indexOf('function(') === 0 && v !== 'function(') {
|
|
66
|
+
flag = true;
|
|
67
|
+
}
|
|
68
|
+
if (!flag) return fn;
|
|
69
|
+
let val;
|
|
70
|
+
try{
|
|
71
|
+
val = makeFn(v);
|
|
72
|
+
}catch (e){
|
|
73
|
+
val = makeFn('function ' + v);
|
|
74
|
+
}
|
|
75
|
+
val.__json = fn;
|
|
76
|
+
return val;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
err(`解析失败:${v}\n\nerr: ${e}`);
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return fn;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function parseJson(json, mode) {
|
|
86
|
+
return JSON.parse(json, function (k, v) {
|
|
87
|
+
if (is.Undef(v) || !v.indexOf) return v;
|
|
88
|
+
return parseFn(v, mode);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const normalMerge = ['props'];
|
|
2
|
+
export const toArrayMerge = ['class', 'style', 'directives'];
|
|
3
|
+
export const functionalMerge = ['on', 'hook'];
|
|
4
|
+
|
|
5
|
+
const mergeProps = (objects, initial = {}, opt = {}) => {
|
|
6
|
+
const _normalMerge = [...normalMerge, ...opt['normal'] || []];
|
|
7
|
+
const _toArrayMerge = [...toArrayMerge, ...opt['array'] || []];
|
|
8
|
+
const _functionalMerge = [...functionalMerge, ...opt['functional'] || []];
|
|
9
|
+
const propsMerge = opt['props'] || [];
|
|
10
|
+
|
|
11
|
+
return objects.reduce((a, b) => {
|
|
12
|
+
for (const key in b) {
|
|
13
|
+
if (a[key]) {
|
|
14
|
+
if (propsMerge.indexOf(key) > -1) {
|
|
15
|
+
a[key] = mergeProps([b[key]], a[key]);
|
|
16
|
+
} else if (_normalMerge.indexOf(key) > -1) {
|
|
17
|
+
a[key] = {...a[key], ...b[key]}
|
|
18
|
+
} else if (_toArrayMerge.indexOf(key) > -1) {
|
|
19
|
+
const arrA = a[key] instanceof Array ? a[key] : [a[key]];
|
|
20
|
+
const arrB = b[key] instanceof Array ? b[key] : [b[key]];
|
|
21
|
+
a[key] = [...arrA, ...arrB]
|
|
22
|
+
} else if (_functionalMerge.indexOf(key) > -1) {
|
|
23
|
+
for (const event in b[key]) {
|
|
24
|
+
if (a[key][event]) {
|
|
25
|
+
const arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
|
|
26
|
+
const arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
|
|
27
|
+
a[key][event] = [...arrA, ...arrB]
|
|
28
|
+
} else {
|
|
29
|
+
a[key][event] = b[key][event]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} else if (key === 'hook') {
|
|
33
|
+
for (let hook in b[key]) {
|
|
34
|
+
if (a[key][hook]) {
|
|
35
|
+
a[key][hook] = mergeFn(a[key][hook], b[key][hook])
|
|
36
|
+
} else {
|
|
37
|
+
a[key][hook] = b[key][hook]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
a[key] = b[key]
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
if (_normalMerge.indexOf(key) > -1 || _functionalMerge.indexOf(key) > -1 || propsMerge.indexOf(key) > -1) {
|
|
45
|
+
a[key] = {...b[key]}
|
|
46
|
+
} else if (_toArrayMerge.indexOf(key) > -1) {
|
|
47
|
+
a[key] = b[key] instanceof Array ? [...b[key]] : (typeof b[key] === 'object' ? {...b[key]} : b[key]);
|
|
48
|
+
} else
|
|
49
|
+
a[key] = b[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return a
|
|
53
|
+
}, initial);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const mergeFn = (fn1, fn2) =>
|
|
57
|
+
function () {
|
|
58
|
+
fn1 && fn1.apply(this, arguments);
|
|
59
|
+
fn2 && fn2.apply(this, arguments);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default mergeProps;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// https://github.com/developit/mitt
|
|
2
|
+
|
|
3
|
+
export default function Mitt(all) {
|
|
4
|
+
all = all || new Map();
|
|
5
|
+
|
|
6
|
+
const mitt = {
|
|
7
|
+
|
|
8
|
+
$on(type, handler) {
|
|
9
|
+
const handlers = all.get(type);
|
|
10
|
+
const added = handlers && handlers.push(handler);
|
|
11
|
+
if (!added) {
|
|
12
|
+
all.set(type, [handler]);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
$once(type, handler) {
|
|
17
|
+
handler._once = true;
|
|
18
|
+
mitt.$on(type, handler);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
$off(type, handler) {
|
|
22
|
+
const handlers = all.get(type);
|
|
23
|
+
if (handlers) {
|
|
24
|
+
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
$emit(type, ...args) {
|
|
29
|
+
(all.get(type) || []).slice().map((handler) => {
|
|
30
|
+
if (handler._once) {
|
|
31
|
+
mitt.$off(type, handler);
|
|
32
|
+
delete handler._once;
|
|
33
|
+
}
|
|
34
|
+
handler(...args);
|
|
35
|
+
});
|
|
36
|
+
(all.get('*') || []).slice().map((handler) => {
|
|
37
|
+
handler(type, args);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return mitt;
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default function toCase(str) {
|
|
2
|
+
const to = str.replace(/(-[a-z])/g, function (v) {
|
|
3
|
+
return v.replace('-', '').toLocaleUpperCase();
|
|
4
|
+
});
|
|
5
|
+
|
|
6
|
+
return lower(to);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function lower(str) {
|
|
10
|
+
return str.replace(str[0], str[0].toLowerCase());
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default function toLine(name) {
|
|
2
|
+
let line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
|
|
3
|
+
if (line.indexOf('-') === 0)
|
|
4
|
+
line = line.substr(1);
|
|
5
|
+
return line;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function upper(str) {
|
|
9
|
+
return str.replace(str[0], str[0].toLocaleUpperCase());
|
|
10
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const is = {
|
|
2
|
+
type(arg, type) {
|
|
3
|
+
return Object.prototype.toString.call(arg) === '[object ' + type + ']'
|
|
4
|
+
},
|
|
5
|
+
Undef(v) {
|
|
6
|
+
return v === undefined || v === null
|
|
7
|
+
},
|
|
8
|
+
Element(arg) {
|
|
9
|
+
return typeof arg === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg)
|
|
10
|
+
},
|
|
11
|
+
trueArray(data) {
|
|
12
|
+
return Array.isArray(data) && data.length > 0;
|
|
13
|
+
},
|
|
14
|
+
Function(v) {
|
|
15
|
+
const type = this.getType(v);
|
|
16
|
+
return type === 'Function' || type === 'AsyncFunction';
|
|
17
|
+
},
|
|
18
|
+
getType(v) {
|
|
19
|
+
const str = Object.prototype.toString.call(v)
|
|
20
|
+
return /^\[object (.*)\]$/.exec(str)[1]
|
|
21
|
+
},
|
|
22
|
+
empty(value) {
|
|
23
|
+
if (value === undefined || value === null) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (Array.isArray(value) && Array.isArray(value) && !value.length) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return typeof value === 'string' && !value;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(t => {
|
|
36
|
+
is[t] = function (arg) {
|
|
37
|
+
return is.type(arg, t);
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export function hasProperty(rule, k) {
|
|
42
|
+
return ({}).hasOwnProperty.call(rule, k)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default is;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@form-create/utils",
|
|
3
|
+
"version": "3.2.31",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"README.md",
|
|
11
|
+
"package.json",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"lib"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"@form-create"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/xaboy/form-create.git"
|
|
21
|
+
},
|
|
22
|
+
"author": "xaboy",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/xaboy/form-create/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "http://www.form-create.com",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "3d024534b3ee103a96da1d3629582c0cdf19d9a8"
|
|
32
|
+
}
|