ken-form-design
Version:
基于vue、ant-design-vue的表单设计器,可视化开发表单
577 lines (451 loc) • 17.1 kB
JavaScript
((typeof self !== 'undefined' ? self : this)["webpackJsonpken_form_design"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpken_form_design"] || []).push([[22],{
/***/ "133a":
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.svgBaseProps = undefined;
exports.getThemeFromTypeName = getThemeFromTypeName;
exports.removeTypeTheme = removeTypeTheme;
exports.withThemeSuffix = withThemeSuffix;
exports.alias = alias;
var _warning = __webpack_require__("a7e2");
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
// These props make sure that the SVG behaviours like general text.
// Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
var svgBaseProps = exports.svgBaseProps = {
width: '1em',
height: '1em',
fill: 'currentColor',
'aria-hidden': 'true',
focusable: 'false'
};
var fillTester = /-fill$/;
var outlineTester = /-o$/;
var twoToneTester = /-twotone$/;
function getThemeFromTypeName(type) {
var result = null;
if (fillTester.test(type)) {
result = 'filled';
} else if (outlineTester.test(type)) {
result = 'outlined';
} else if (twoToneTester.test(type)) {
result = 'twoTone';
}
return result;
}
function removeTypeTheme(type) {
return type.replace(fillTester, '').replace(outlineTester, '').replace(twoToneTester, '');
}
function withThemeSuffix(type, theme) {
var result = type;
if (theme === 'filled') {
result += '-fill';
} else if (theme === 'outlined') {
result += '-o';
} else if (theme === 'twoTone') {
result += '-twotone';
} else {
(0, _warning2['default'])(false, 'Icon', 'This icon \'' + type + '\' has unknown theme \'' + theme + '\'');
}
return result;
}
// For alias or compatibility
function alias(type) {
var newType = type;
switch (type) {
case 'cross':
newType = 'close';
break;
// https://github.com/ant-design/ant-design/issues/13007
case 'interation':
newType = 'interaction';
break;
// https://github.com/ant-design/ant-design/issues/16810
case 'canlendar':
newType = 'calendar';
break;
// https://github.com/ant-design/ant-design/issues/17448
case 'colum-height':
newType = 'column-height';
break;
default:
}
(0, _warning2['default'])(newType === type, 'Icon', 'Icon \'' + type + '\' was a typo and is now deprecated, please use \'' + newType + '\' instead.');
return newType;
}
/***/ }),
/***/ "2768":
/***/ (function(module, exports) {
/**
* Checks if `value` is `null` or `undefined`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
* @example
*
* _.isNil(null);
* // => true
*
* _.isNil(void 0);
* // => true
*
* _.isNil(NaN);
* // => false
*/
function isNil(value) {
return value == null;
}
module.exports = isNil;
/***/ }),
/***/ "4b93":
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.momentToString = exports.stringToMoment = exports.TimeOrTimesType = exports.TimesType = exports.TimeType = undefined;
exports.checkValidate = checkValidate;
var _interopDefault = __webpack_require__("8716");
var _interopDefault2 = _interopRequireDefault(_interopDefault);
var _moment = __webpack_require__("c1df");
var moment = _interopRequireWildcard(_moment);
var _warning = __webpack_require__("a7e2");
var _warning2 = _interopRequireDefault(_warning);
var _isNil = __webpack_require__("2768");
var _isNil2 = _interopRequireDefault(_isNil);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var TimeType = exports.TimeType = {
validator: function validator(value) {
return typeof value === 'string' || (0, _isNil2['default'])(value) || moment.isMoment(value);
}
};
var TimesType = exports.TimesType = {
validator: function validator(value) {
if (Array.isArray(value)) {
return value.length === 0 || value.findIndex(function (val) {
return typeof val !== 'string';
}) === -1 || value.findIndex(function (val) {
return !(0, _isNil2['default'])(val) && !moment.isMoment(val);
}) === -1;
}
return false;
}
};
var TimeOrTimesType = exports.TimeOrTimesType = {
validator: function validator(value) {
if (Array.isArray(value)) {
return value.length === 0 || value.findIndex(function (val) {
return typeof val !== 'string';
}) === -1 || value.findIndex(function (val) {
return !(0, _isNil2['default'])(val) && !moment.isMoment(val);
}) === -1;
} else {
return typeof value === 'string' || (0, _isNil2['default'])(value) || moment.isMoment(value);
}
}
};
function checkValidate(componentName, value, propName, valueFormat) {
var values = Array.isArray(value) ? value : [value];
values.forEach(function (val) {
if (!val) return;
valueFormat && (0, _warning2['default'])((0, _interopDefault2['default'])(moment)(val, valueFormat).isValid(), componentName, 'When set `valueFormat`, `' + propName + '` should provides invalidate string time. ');
!valueFormat && (0, _warning2['default'])((0, _interopDefault2['default'])(moment).isMoment(val) && val.isValid(), componentName, '`' + propName + '` provides invalidate moment time. If you want to set empty value, use `null` instead.');
});
}
var stringToMoment = exports.stringToMoment = function stringToMoment(value, valueFormat) {
if (Array.isArray(value)) {
return value.map(function (val) {
return typeof val === 'string' && val ? (0, _interopDefault2['default'])(moment)(val, valueFormat) : val || null;
});
} else {
return typeof value === 'string' && value ? (0, _interopDefault2['default'])(moment)(value, valueFormat) : value || null;
}
};
var momentToString = exports.momentToString = function momentToString(value, valueFormat) {
if (Array.isArray(value)) {
return value.map(function (val) {
return (0, _interopDefault2['default'])(moment).isMoment(val) ? val.format(valueFormat) : val;
});
} else {
return (0, _interopDefault2['default'])(moment).isMoment(value) ? value.format(valueFormat) : value;
}
};
/***/ }),
/***/ "50f6":
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _babelHelperVueJsxMergeProps = __webpack_require__("92fa");
var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);
var _extends2 = __webpack_require__("41b2");
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = __webpack_require__("6042");
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _toConsumableArray2 = __webpack_require__("9b57");
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _classnames = __webpack_require__("4d26");
var _classnames2 = _interopRequireDefault(_classnames);
var _dist = __webpack_require__("3a9b");
var allIcons = _interopRequireWildcard(_dist);
var _iconsVue = __webpack_require__("8520");
var _iconsVue2 = _interopRequireDefault(_iconsVue);
var _vueTypes = __webpack_require__("7b44");
var _vueTypes2 = _interopRequireDefault(_vueTypes);
var _IconFont = __webpack_require__("bbf5");
var _IconFont2 = _interopRequireDefault(_IconFont);
var _utils = __webpack_require__("133a");
var _warning = __webpack_require__("a7e2");
var _warning2 = _interopRequireDefault(_warning);
var _LocaleReceiver = __webpack_require__("3f5f");
var _LocaleReceiver2 = _interopRequireDefault(_LocaleReceiver);
var _twoTonePrimaryColor = __webpack_require__("f3dc");
var _propsUtil = __webpack_require__("73c8");
var _base = __webpack_require__("baff");
var _base2 = _interopRequireDefault(_base);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
// Initial setting
// https://github.com/vueComponent/ant-design-vue/issues/2745
_iconsVue2['default'].add.apply(_iconsVue2['default'], (0, _toConsumableArray3['default'])(Object.keys(allIcons).filter(function (key) {
return key !== 'default';
}).map(function (key) {
return allIcons[key];
})));
(0, _twoTonePrimaryColor.setTwoToneColor)('#1890ff');
var defaultTheme = 'outlined';
var dangerousTheme = void 0;
function renderIcon(h, locale, context) {
var _classNames;
var props = context.$props,
$slots = context.$slots;
var listeners = (0, _propsUtil.getListeners)(context);
var type = props.type,
Component = props.component,
viewBox = props.viewBox,
spin = props.spin,
theme = props.theme,
twoToneColor = props.twoToneColor,
rotate = props.rotate,
tabIndex = props.tabIndex;
var children = (0, _propsUtil.filterEmpty)($slots['default']);
children = children.length === 0 ? undefined : children;
(0, _warning2['default'])(Boolean(type || Component || children), 'Icon', 'Icon should have `type` prop or `component` prop or `children`.');
var classString = (0, _classnames2['default'])((_classNames = {}, (0, _defineProperty3['default'])(_classNames, 'anticon', true), (0, _defineProperty3['default'])(_classNames, 'anticon-' + type, !!type), _classNames));
var svgClassString = (0, _classnames2['default'])((0, _defineProperty3['default'])({}, 'anticon-spin', !!spin || type === 'loading'));
var svgStyle = rotate ? {
msTransform: 'rotate(' + rotate + 'deg)',
transform: 'rotate(' + rotate + 'deg)'
} : undefined;
var innerSvgProps = {
attrs: (0, _extends3['default'])({}, _utils.svgBaseProps, {
viewBox: viewBox
}),
'class': svgClassString,
style: svgStyle
};
if (!viewBox) {
delete innerSvgProps.attrs.viewBox;
}
var renderInnerNode = function renderInnerNode() {
// component > children > type
if (Component) {
return h(
Component,
innerSvgProps,
[children]
);
}
if (children) {
(0, _warning2['default'])(Boolean(viewBox) || children.length === 1 && children[0].tag === 'use', 'Icon', 'Make sure that you provide correct `viewBox`' + ' prop (default `0 0 1024 1024`) to the icon.');
var _innerSvgProps = {
attrs: (0, _extends3['default'])({}, _utils.svgBaseProps),
'class': svgClassString,
style: svgStyle
};
return h(
'svg',
(0, _babelHelperVueJsxMergeProps2['default'])([_innerSvgProps, {
attrs: { viewBox: viewBox }
}]),
[children]
);
}
if (typeof type === 'string') {
var computedType = type;
if (theme) {
var themeInName = (0, _utils.getThemeFromTypeName)(type);
(0, _warning2['default'])(!themeInName || theme === themeInName, 'Icon', 'The icon name \'' + type + '\' already specify a theme \'' + themeInName + '\',' + (' the \'theme\' prop \'' + theme + '\' will be ignored.'));
}
computedType = (0, _utils.withThemeSuffix)((0, _utils.removeTypeTheme)((0, _utils.alias)(computedType)), dangerousTheme || theme || defaultTheme);
return h(_iconsVue2['default'], {
attrs: {
focusable: 'false',
type: computedType,
primaryColor: twoToneColor
},
'class': svgClassString, style: svgStyle
});
}
};
var iconTabIndex = tabIndex;
if (iconTabIndex === undefined && 'click' in listeners) {
iconTabIndex = -1;
}
// functional component not support nativeOn,https://github.com/vuejs/vue/issues/7526
var iProps = {
attrs: {
'aria-label': type && locale.icon + ': ' + type,
tabIndex: iconTabIndex
},
on: listeners,
'class': classString,
staticClass: ''
};
return h(
'i',
iProps,
[renderInnerNode()]
);
}
var Icon = {
name: 'AIcon',
props: {
tabIndex: _vueTypes2['default'].number,
type: _vueTypes2['default'].string,
component: _vueTypes2['default'].any,
viewBox: _vueTypes2['default'].any,
spin: _vueTypes2['default'].bool.def(false),
rotate: _vueTypes2['default'].number,
theme: _vueTypes2['default'].oneOf(['filled', 'outlined', 'twoTone']),
twoToneColor: _vueTypes2['default'].string,
role: _vueTypes2['default'].string
},
render: function render(h) {
var _this = this;
return h(_LocaleReceiver2['default'], {
attrs: {
componentName: 'Icon'
},
scopedSlots: { 'default': function _default(locale) {
return renderIcon(h, locale, _this);
} }
});
}
};
Icon.createFromIconfontCN = _IconFont2['default'];
Icon.getTwoToneColor = _twoTonePrimaryColor.getTwoToneColor;
Icon.setTwoToneColor = _twoTonePrimaryColor.setTwoToneColor;
/* istanbul ignore next */
Icon.install = function (Vue) {
Vue.use(_base2['default']);
Vue.component(Icon.name, Icon);
};
exports['default'] = Icon;
/***/ }),
/***/ "8716":
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = interopDefault;
// https://github.com/moment/moment/issues/3650
function interopDefault(m) {
return m["default"] || m;
}
/***/ }),
/***/ "bbf5":
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _objectWithoutProperties2 = __webpack_require__("8e8e");
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
exports['default'] = create;
var _index = __webpack_require__("50f6");
var _index2 = _interopRequireDefault(_index);
var _propsUtil = __webpack_require__("73c8");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var customCache = new Set();
function create(options) {
var scriptUrl = options.scriptUrl,
_options$extraCommonP = options.extraCommonProps,
extraCommonProps = _options$extraCommonP === undefined ? {} : _options$extraCommonP;
/**
* DOM API required.
* Make sure in browser environment.
* The Custom Icon will create a <script/>
* that loads SVG symbols and insert the SVG Element into the document body.
*/
if (typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function' && typeof scriptUrl === 'string' && scriptUrl.length && !customCache.has(scriptUrl)) {
var script = document.createElement('script');
script.setAttribute('src', scriptUrl);
script.setAttribute('data-namespace', scriptUrl);
customCache.add(scriptUrl);
document.body.appendChild(script);
}
var Iconfont = {
functional: true,
name: 'AIconfont',
props: _index2['default'].props,
render: function render(h, context) {
var props = context.props,
slots = context.slots,
listeners = context.listeners,
data = context.data;
var type = props.type,
restProps = (0, _objectWithoutProperties3['default'])(props, ['type']);
var slotsMap = slots();
var children = slotsMap['default'];
// component > children > type
var content = null;
if (type) {
content = h('use', { attrs: { 'xlink:href': '#' + type } });
}
if (children) {
content = children;
}
var iconProps = (0, _propsUtil.mergeProps)(extraCommonProps, data, { props: restProps, on: listeners });
return h(
_index2['default'],
iconProps,
[content]
);
}
};
return Iconfont;
}
/***/ }),
/***/ "f3dc":
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setTwoToneColor = setTwoToneColor;
exports.getTwoToneColor = getTwoToneColor;
var _iconsVue = __webpack_require__("8520");
var _iconsVue2 = _interopRequireDefault(_iconsVue);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function setTwoToneColor(primaryColor) {
return _iconsVue2['default'].setTwoToneColors({
primaryColor: primaryColor
});
}
function getTwoToneColor() {
var colors = _iconsVue2['default'].getTwoToneColors();
return colors.primaryColor;
}
/***/ })
}]);