bkui-vue 0.0.1-beta.387 → 0.0.1-beta.389

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 (150) hide show
  1. package/dist/index.cjs.js +22 -22
  2. package/dist/index.esm.js +1 -0
  3. package/dist/index.umd.js +23 -23
  4. package/lib/affix/index.js +353 -1
  5. package/lib/alert/index.js +251 -1
  6. package/lib/animate-number/index.js +226 -1
  7. package/lib/backtop/index.js +260 -1
  8. package/lib/badge/index.js +274 -1
  9. package/lib/breadcrumb/index.js +329 -1
  10. package/lib/button/index.js +371 -1
  11. package/lib/card/index.js +326 -1
  12. package/lib/cascader/index.js +2168 -1
  13. package/lib/checkbox/index.js +571 -1
  14. package/lib/code-diff/index.js +5520 -1
  15. package/lib/collapse/index.js +698 -1
  16. package/lib/color-picker/index.js +2816 -1
  17. package/lib/components.js +759 -1
  18. package/lib/container/index.js +369 -1
  19. package/lib/date-picker/index.js +5601 -1
  20. package/lib/dialog/index.js +545 -1
  21. package/lib/directives/index.js +1428 -2
  22. package/lib/dist.index.js +166 -1
  23. package/lib/divider/index.js +512 -1
  24. package/lib/dropdown/index.js +414 -1
  25. package/lib/exception/index.js +405 -1
  26. package/lib/fixed-navbar/index.js +214 -1
  27. package/lib/form/index.js +986 -1
  28. package/lib/icon/angle-double-down-line.js +426 -1
  29. package/lib/icon/angle-double-left-line.js +426 -1
  30. package/lib/icon/angle-double-left.js +426 -1
  31. package/lib/icon/angle-double-right-line.js +426 -1
  32. package/lib/icon/angle-double-right.js +426 -1
  33. package/lib/icon/angle-double-up-line.js +426 -1
  34. package/lib/icon/angle-down-fill.js +426 -1
  35. package/lib/icon/angle-down-line.js +426 -1
  36. package/lib/icon/angle-down.js +426 -1
  37. package/lib/icon/angle-left.js +426 -1
  38. package/lib/icon/angle-right.js +426 -1
  39. package/lib/icon/angle-up-fill.js +426 -1
  40. package/lib/icon/angle-up.js +426 -1
  41. package/lib/icon/archive-fill.js +426 -1
  42. package/lib/icon/arrows-left.js +426 -1
  43. package/lib/icon/arrows-right.js +426 -1
  44. package/lib/icon/audio-fill.js +426 -1
  45. package/lib/icon/bk.js +426 -1
  46. package/lib/icon/circle.js +426 -1
  47. package/lib/icon/close-line.js +426 -1
  48. package/lib/icon/close.js +426 -1
  49. package/lib/icon/code.js +426 -1
  50. package/lib/icon/cog-shape.js +426 -1
  51. package/lib/icon/collapse-left.js +426 -1
  52. package/lib/icon/copy.js +426 -1
  53. package/lib/icon/data-shape.js +426 -1
  54. package/lib/icon/del.js +426 -1
  55. package/lib/icon/doc-fill.js +426 -1
  56. package/lib/icon/done.js +426 -1
  57. package/lib/icon/down-shape.js +426 -1
  58. package/lib/icon/down-small.js +426 -1
  59. package/lib/icon/edit-line.js +426 -1
  60. package/lib/icon/ellipsis.js +426 -1
  61. package/lib/icon/enlarge-line.js +426 -1
  62. package/lib/icon/error.js +426 -1
  63. package/lib/icon/excel-fill.js +426 -1
  64. package/lib/icon/exclamation-circle-shape.js +426 -1
  65. package/lib/icon/eye.js +426 -1
  66. package/lib/icon/filliscreen-line.js +426 -1
  67. package/lib/icon/folder-open.js +426 -1
  68. package/lib/icon/folder-shape-open.js +426 -1
  69. package/lib/icon/folder-shape.js +426 -1
  70. package/lib/icon/folder.js +426 -1
  71. package/lib/icon/funnel.js +426 -1
  72. package/lib/icon/help-document-fill.js +426 -1
  73. package/lib/icon/help-fill.js +426 -1
  74. package/lib/icon/help.js +426 -1
  75. package/lib/icon/image-fill.js +426 -1
  76. package/lib/icon/img-placehoulder.js +448 -1
  77. package/lib/icon/index.js +2275 -1
  78. package/lib/icon/info-line.js +448 -1
  79. package/lib/icon/info.js +448 -1
  80. package/lib/icon/left-shape.js +448 -1
  81. package/lib/icon/left-turn-line.js +448 -1
  82. package/lib/icon/narrow-line.js +448 -1
  83. package/lib/icon/original.js +448 -1
  84. package/lib/icon/pdf-fill.js +448 -1
  85. package/lib/icon/play-shape.js +448 -1
  86. package/lib/icon/plus.js +448 -1
  87. package/lib/icon/ppt-fill.js +448 -1
  88. package/lib/icon/qq.js +448 -1
  89. package/lib/icon/right-shape.js +448 -1
  90. package/lib/icon/right-turn-line.js +448 -1
  91. package/lib/icon/search.js +448 -1
  92. package/lib/icon/share.js +448 -1
  93. package/lib/icon/spinner.js +448 -1
  94. package/lib/icon/success.js +448 -1
  95. package/lib/icon/switcher-loading.js +448 -1
  96. package/lib/icon/text-file.js +448 -1
  97. package/lib/icon/text-fill.js +448 -1
  98. package/lib/icon/transfer.js +448 -1
  99. package/lib/icon/tree-application-shape.js +448 -1
  100. package/lib/icon/unfull-screen.js +448 -1
  101. package/lib/icon/unvisible.js +448 -1
  102. package/lib/icon/up-shape.js +448 -1
  103. package/lib/icon/upload.js +448 -1
  104. package/lib/icon/video-fill.js +448 -1
  105. package/lib/icon/warn.js +448 -1
  106. package/lib/icon/weixin.js +448 -1
  107. package/lib/image/index.js +873 -1
  108. package/lib/index.js +169 -1
  109. package/lib/info-box/index.js +1784 -1
  110. package/lib/input/index.js +846 -1
  111. package/lib/link/index.js +226 -1
  112. package/lib/loading/index.js +309 -1
  113. package/lib/menu/index.js +796 -1
  114. package/lib/message/index.js +401 -1
  115. package/lib/modal/index.js +395 -1
  116. package/lib/navigation/index.js +431 -1
  117. package/lib/notify/index.js +430 -1
  118. package/lib/overflow-title/index.js +512 -1
  119. package/lib/pagination/index.js +1026 -1
  120. package/lib/plugin-popover/index.js +2448 -1
  121. package/lib/plugins/index.js +130 -1
  122. package/lib/popover/index.js +2454 -1
  123. package/lib/popover2/index.js +172 -1
  124. package/lib/preset.js +129 -1
  125. package/lib/process/index.js +1417 -1
  126. package/lib/progress/index.js +479 -1
  127. package/lib/radio/index.js +649 -1
  128. package/lib/rate/index.js +358 -1
  129. package/lib/resize-layout/index.js +495 -1
  130. package/lib/search-select/index.js +3388 -1
  131. package/lib/select/index.js +2819 -1
  132. package/lib/shared/index.js +2813 -1
  133. package/lib/sideslider/index.js +1362 -1
  134. package/lib/slider/index.js +2060 -1
  135. package/lib/steps/index.js +1504 -1
  136. package/lib/swiper/index.js +374 -1
  137. package/lib/switcher/index.js +308 -1
  138. package/lib/tab/index.js +919 -1
  139. package/lib/table/index.js +6635 -1
  140. package/lib/table-column/index.js +737 -1
  141. package/lib/tag/index.js +278 -1
  142. package/lib/tag-input/index.js +1897 -1
  143. package/lib/time-picker/index.js +142 -1
  144. package/lib/timeline/index.js +315 -1
  145. package/lib/transfer/index.js +658 -1
  146. package/lib/tree/index.js +2917 -1
  147. package/lib/upload/index.js +3735 -1
  148. package/lib/virtual-render/index.js +825 -1
  149. package/package.json +1 -3
  150. package/lib/directives/index.js.LICENSE.txt +0 -14
package/lib/form/index.js CHANGED
@@ -1 +1,986 @@
1
- !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon"));else if("function"==typeof define&&define.amd)define(["../shared","vue","lodash","../directives","../icon"],r);else{var t="object"==typeof exports?r(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon")):r(e["../shared"],e.vue,e.lodash,e["../directives"],e["../icon"]);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(self,((e,r,t,o,n)=>(()=>{"use strict";var i={4061:e=>{e.exports=o},6870:e=>{e.exports=n},4212:r=>{r.exports=e},467:e=>{e.exports=t},748:e=>{e.exports=r}},s={};function a(e){var r=s[e];if(void 0!==r)return r.exports;var t=s[e]={exports:{}};return i[e](t,t.exports,a),t.exports}a.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return a.d(r,{a:r}),r},a.d=(e,r)=>{for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{a.r(l),a.d(l,{BkComposeFormItem:()=>o,BkForm:()=>x,BkFormItem:()=>h,default:()=>P});var e=a(4212),r=a(748),t=function(e){return e.__v_isVNode};const o=(0,r.defineComponent)({name:"ComposeFormItem",props:{headBackgroundColor:{type:String,default:"#FAFBFD"},tailBackgroundColor:String},render:function(){if(!this.$slots.default)return null;var e=this.$slots.default();if(e.length>1){for(var o=e.length,n=0,i=null;n<o;){if(t(e[n])){i=e[n];break}n+=1}for(var s=o-1,a=null;s>=0&&s>n;){if(t(e[s])){a=e[s];break}s-=1}if(i&&a){i.props||(i.props={});var l="bk-compose-form-item-head";i.props.class&&(l+=" ".concat(i.props.class)),this.headBackgroundColor&&(i.props.style=Object.assign(i.props.style||{},{"background-color":this.headBackgroundColor})),i.props.class=l,a.props||(a.props={});var u="bk-compose-form-item-tail";a.props.class&&(u+=" ".concat(a.props.class)),this.tailBackgroundColor&&(a.props.style=Object.assign(a.props.style||{},{"background-color":this.tailBackgroundColor})),a.props.class=u}}return(0,r.h)("div",{class:"bk-compose-form-item"},e)}});function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var i={formType:e.PropTypes.oneOf(["default","vertical"]).def("default"),labelWidth:e.PropTypes.oneOfType([Number,String]).def(150),labelPosition:e.PropTypes.oneOf(["left","center","right"]),model:e.PropTypes.object,rules:e.PropTypes.object};const s=(0,r.defineComponent)({name:"Form",props:i,emits:["submit"],setup:function(t,o){var i=[];return(0,r.provide)(e.formKey,{props:t,register:function(e){i.push(e)},unregister:function(e){i=i.reduce((function(r,t){return t!==e&&r.push(t),r}),[])}}),{handleSubmit:function(e){e.preventDefault(),o.emit("submit")},validate:function(e){var r={};return r=e?("string"==typeof e?[e]:e).reduce((function(e,r){return Object.assign(Object.assign({},e),n({},r,!0))}),{}):i.reduce((function(e,r){return r.property?Object.assign(Object.assign({},e),n({},r.property,!0)):e}),{}),Promise.all(i.reduce((function(e,t){return r[t.property]&&e.push(t.validate()),e}),[])).then((function(){return Promise.resolve(t.model)}))},clearValidate:function(e){var r={};r=e?("string"==typeof e?[e]:e).reduce((function(e,r){return Object.assign(Object.assign({},e),n({},r,!0))}),{}):i.reduce((function(e,r){return Object.assign(Object.assign({},e),n({},r.property,!0))}),{}),i.forEach((function(e){return r[e.property]&&e.clearValidate()}))}}},render:function(){var t,o,i=(0,e.classes)(n({"bk-form":!0},"bk-form--".concat(this.formType),!0));return(0,r.createVNode)("form",{class:i,onSubmit:this.handleSubmit},[null===(o=(t=this.$slots).default)||void 0===o?void 0:o.call(t)])}});function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return u(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var p=a(467),d=a.n(p),f=a(4061),m=a(6870),g=function(e){return"function"==typeof e.message?e.message():e.message};const b={required:function(e){return!("number"!=typeof e&&"boolean"!=typeof e&&!d().isDate(e)&&d().isEmpty(e))},min:function(e,r){return e>=r},max:function(e,r){return r>=e},email:function(e){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(e)},maxlength:function(e,r){return e.length<=r},pattern:function(e,r){return r.test(e)}};var v={label:e.PropTypes.string,labelWidth:e.PropTypes.oneOfType([Number,String]),labelPosition:e.PropTypes.oneOf(["left","center","right"]),property:e.PropTypes.string.def(""),required:e.PropTypes.bool.def(!1),email:e.PropTypes.bool.def(!1),max:e.PropTypes.number,min:e.PropTypes.number,maxlength:e.PropTypes.number,rules:e.PropTypes.array,autoCheck:e.PropTypes.bool.def(!1),description:e.PropTypes.string,errorDisplayType:e.PropTypes.oneOf(["tooltips","normal"]).def("normal")},y=function(e){return void 0!==e};const h=(0,r.defineComponent)({name:"FormItem",directives:{bkTooltips:f.bkTooltips},props:v,setup:function(t,o){var i=(0,e.useForm)(),s=Boolean(i),a=(0,e.useFormItem)(),l=Boolean(a),u=(0,r.getCurrentInstance)(),d=(0,r.reactive)({isError:!1,errorMessage:""}),f=(0,r.computed)((function(){return!!s&&"vertical"===i.props.formType})),m=(0,r.computed)((function(){return!(!t.label&&!o.slots.label)})),v=(0,r.computed)((function(){var e={width:"",paddingRight:"",textAlign:""},r=t.labelPosition||s&&i.props.labelPosition;if(r&&(e["text-align"]=r),"vertical"===i.props.formType||!t.label&&l)return e;var o=y(t.labelWidth)?t.labelWidth:s&&i.props.labelWidth;return y(o)&&(e.width="".concat(o,"px"),e.paddingRight=o?"":"0px"),e})),h=(0,r.computed)((function(){return n({},"margin-left",v.value.width)})),x=function(e){if(!t.property||s&&!i.props.model)return Promise.resolve(!0);var r,o,n,a,l,u,f,m,v=[];s&&i.props.rules&&(r=i.props.rules,o=t.property,Object.prototype.hasOwnProperty.call(r,o))&&(v=i.props.rules[t.property]),t.rules&&(v=t.rules),v=function(e,r){return r.reduce((function(r,t){return t.trigger&&e?((Array.isArray(t.trigger)?t.trigger:[t.trigger]).includes(e)&&r.push(t),r):(r.push(t),r)}),[])}(e,(n=v,a=function(e){var r=[],t=e.label||"";return e.required&&r.push({required:!0,validator:b.required,message:"".concat(t,"不能为空"),trigger:"change"}),e.email&&r.push({email:!0,validator:b.email,message:"".concat(t,"格式不正确"),trigger:"change"}),Number(e.max)>-1&&r.push({validator:function(r){return b.max(r,e.max)},message:"".concat(t,"最大值 ").concat(e.max),trigger:"change"}),Number(e.min)>-1&&r.push({validator:function(r){return b.min(r,e.min)},message:"".concat(t,"最小值 ").concat(e.min),trigger:"change"}),Number(e.maxlength)>-1&&r.push({validator:function(r){return b.maxlength(r,e.maxlength)},message:"".concat(t,"最大长度 ").concat(e.maxlength),trigger:"change"}),r}(t),l=!1,u=!1,f=n.reduce((function(e,r){var t;if(r.required)t=(0,p.isFunction)(r.validator)?r.validator:b.required,l=!0;else if(r.email)t=(0,p.isFunction)(r.validator)?r.validator:b.email,u=!0;else if(Number(r.max)>-1)t=function(e){return b.max(e,r.max)};else if(Number(r.min)>-1)t=function(e){return b.min(e,r.max)};else if(Number(r.maxlength)>-1)t=function(e){return b.min(e,r.max)};else if("[object RegExp]"===Object.prototype.toString.call(r.pattern))t=function(e){return b.pattern(e,r.pattern)};else{if(!(0,p.isFunction)(r.validator))return e;t=r.validator}return e.push({validator:t,message:r.message||"验证错误",trigger:r.trigger||"blur"}),e}),[]),m=a.reduce((function(e,r){return r.required&&l||r.email&&u||e.push(r),e}),[]),[].concat(c(m),c(f)))),v.length>0&&(d.isError=!1,d.errorMessage="");var y,h=(0,p.get)(i.props.model,t.property),x=(y=-1,function(){if((y+=1)>=v.length)return Promise.resolve(!0);var e=v[y];return Promise.resolve().then((function(){var r=e.validator(h);return"boolean"!=typeof r&&"function"==typeof r.then?r.then((function(r){if(!1===r)return Promise.reject(g(e))})).then((function(){return x()}),(function(){return d.isError=!0,d.errorMessage=g(e),Promise.reject(d.errorMessage)})):r?x():(d.isError=!0,d.errorMessage="string"==typeof r?r:g(e),Promise.reject(d.errorMessage))}))});return x()},P=function(){d.isError=!1,d.errorMessage=""};return(0,r.provide)(e.formItemKey,Object.assign(Object.assign({},t),{validate:x,clearValidate:P})),(0,r.onMounted)((function(){s&&i.register(u.proxy)})),(0,r.onBeforeUnmount)((function(){s&&i.unregister(u.proxy)})),Object.assign(Object.assign({},(0,r.toRefs)(d)),{isShowLabel:m,labelStyles:v,contentStyles:h,isFormTypeVertical:f,validate:x,clearValidate:P})},render:function(){var t,o,n,i,s=this,a=(0,e.classes)({"bk-form-item":!0,"is-error":this.isError,"is-required":this.required});return(0,r.createVNode)("div",{class:a},[this.isShowLabel&&(0,r.createVNode)("div",{class:"bk-form-label",style:this.labelStyles},[s.$slots.label?s.$slots.label():s.description?(0,r.withDirectives)((0,r.createVNode)("span",{class:{"bk-form-label-description":Boolean(s.description)}},[s.label]),[[(0,r.resolveDirective)("bk-tooltips"),s.description]]):s.label,this.isFormTypeVertical&&(null===(o=(t=this.$slots).labelAppend)||void 0===o?void 0:o.call(t))]),(0,r.createVNode)("div",{class:"bk-form-content",style:this.contentStyles},[null===(i=(n=this.$slots).default)||void 0===i?void 0:i.call(n),s.isError?"tooltips"===s.errorDisplayType?(0,r.withDirectives)((0,r.createVNode)("div",{class:"bk-form-error-tips"},[(0,r.createVNode)(m.ExclamationCircleShape,null,null)]),[[(0,r.resolveDirective)("bk-tooltips"),s.errorMessage]]):(0,r.createVNode)("div",{class:"bk-form-error"},[s.$slots.error?s.$slots.error(s.errorMessage):s.errorMessage]):null])])}});var x=(0,e.withInstallProps)(s,{FormItem:h,ComposeFormItem:o});const P=x})(),l})()));
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("../shared"), require("vue"), require("lodash"), require("../directives"), require("../icon"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["../shared", "vue", "lodash", "../directives", "../icon"], factory);
6
+ else {
7
+ var a = typeof exports === 'object' ? factory(require("../shared"), require("vue"), require("lodash"), require("../directives"), require("../icon")) : factory(root["../shared"], root["vue"], root["lodash"], root["../directives"], root["../icon"]);
8
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
+ }
10
+ })(self, (__WEBPACK_EXTERNAL_MODULE__4212__, __WEBPACK_EXTERNAL_MODULE__748__, __WEBPACK_EXTERNAL_MODULE__467__, __WEBPACK_EXTERNAL_MODULE__4061__, __WEBPACK_EXTERNAL_MODULE__6870__) => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 4061:
16
+ /***/ ((module) => {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__4061__;
19
+
20
+ /***/ }),
21
+
22
+ /***/ 6870:
23
+ /***/ ((module) => {
24
+
25
+ module.exports = __WEBPACK_EXTERNAL_MODULE__6870__;
26
+
27
+ /***/ }),
28
+
29
+ /***/ 4212:
30
+ /***/ ((module) => {
31
+
32
+ module.exports = __WEBPACK_EXTERNAL_MODULE__4212__;
33
+
34
+ /***/ }),
35
+
36
+ /***/ 467:
37
+ /***/ ((module) => {
38
+
39
+ module.exports = __WEBPACK_EXTERNAL_MODULE__467__;
40
+
41
+ /***/ }),
42
+
43
+ /***/ 748:
44
+ /***/ ((module) => {
45
+
46
+ module.exports = __WEBPACK_EXTERNAL_MODULE__748__;
47
+
48
+ /***/ })
49
+
50
+ /******/ });
51
+ /************************************************************************/
52
+ /******/ // The module cache
53
+ /******/ var __webpack_module_cache__ = {};
54
+ /******/
55
+ /******/ // The require function
56
+ /******/ function __webpack_require__(moduleId) {
57
+ /******/ // Check if module is in cache
58
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
59
+ /******/ if (cachedModule !== undefined) {
60
+ /******/ return cachedModule.exports;
61
+ /******/ }
62
+ /******/ // Create a new module (and put it into the cache)
63
+ /******/ var module = __webpack_module_cache__[moduleId] = {
64
+ /******/ // no module.id needed
65
+ /******/ // no module.loaded needed
66
+ /******/ exports: {}
67
+ /******/ };
68
+ /******/
69
+ /******/ // Execute the module function
70
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
71
+ /******/
72
+ /******/ // Return the exports of the module
73
+ /******/ return module.exports;
74
+ /******/ }
75
+ /******/
76
+ /************************************************************************/
77
+ /******/ /* webpack/runtime/compat get default export */
78
+ /******/ (() => {
79
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
80
+ /******/ __webpack_require__.n = (module) => {
81
+ /******/ var getter = module && module.__esModule ?
82
+ /******/ () => (module['default']) :
83
+ /******/ () => (module);
84
+ /******/ __webpack_require__.d(getter, { a: getter });
85
+ /******/ return getter;
86
+ /******/ };
87
+ /******/ })();
88
+ /******/
89
+ /******/ /* webpack/runtime/define property getters */
90
+ /******/ (() => {
91
+ /******/ // define getter functions for harmony exports
92
+ /******/ __webpack_require__.d = (exports, definition) => {
93
+ /******/ for(var key in definition) {
94
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
95
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
96
+ /******/ }
97
+ /******/ }
98
+ /******/ };
99
+ /******/ })();
100
+ /******/
101
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
102
+ /******/ (() => {
103
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
104
+ /******/ })();
105
+ /******/
106
+ /******/ /* webpack/runtime/make namespace object */
107
+ /******/ (() => {
108
+ /******/ // define __esModule on exports
109
+ /******/ __webpack_require__.r = (exports) => {
110
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
111
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
112
+ /******/ }
113
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
114
+ /******/ };
115
+ /******/ })();
116
+ /******/
117
+ /************************************************************************/
118
+ var __webpack_exports__ = {};
119
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
120
+ (() => {
121
+ // ESM COMPAT FLAG
122
+ __webpack_require__.r(__webpack_exports__);
123
+
124
+ // EXPORTS
125
+ __webpack_require__.d(__webpack_exports__, {
126
+ "BkComposeFormItem": () => (/* reexport */ compose_form_item),
127
+ "BkForm": () => (/* binding */ BkForm),
128
+ "BkFormItem": () => (/* reexport */ form_item),
129
+ "default": () => (/* binding */ src)
130
+ });
131
+
132
+ // EXTERNAL MODULE: external "../shared"
133
+ var external_shared_ = __webpack_require__(4212);
134
+ // EXTERNAL MODULE: external "vue"
135
+ var external_vue_ = __webpack_require__(748);
136
+ ;// CONCATENATED MODULE: ../../packages/form/src/compose-form-item.tsx
137
+ /*
138
+ * Tencent is pleased to support the open source community by making
139
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
140
+ *
141
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
142
+ *
143
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
144
+ *
145
+ * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
146
+ *
147
+ * ---------------------------------------------------
148
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
149
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
150
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
151
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
152
+ *
153
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
154
+ * the Software.
155
+ *
156
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
157
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
158
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
159
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
160
+ * IN THE SOFTWARE.
161
+ */
162
+
163
+
164
+ var isCustomComponent = function isCustomComponent(node) {
165
+ return node.__v_isVNode;
166
+ };
167
+
168
+ /* harmony default export */ const compose_form_item = ((0,external_vue_.defineComponent)({
169
+ name: 'ComposeFormItem',
170
+ props: {
171
+ headBackgroundColor: {
172
+ type: String,
173
+ "default": '#FAFBFD'
174
+ },
175
+ tailBackgroundColor: String
176
+ },
177
+ render: function render() {
178
+ if (!this.$slots["default"]) {
179
+ return null;
180
+ }
181
+
182
+ var childrenArr = this.$slots["default"]();
183
+
184
+ if (childrenArr.length > 1) {
185
+ var childrenLength = childrenArr.length;
186
+ var startIndex = 0;
187
+ var headChildren = null;
188
+
189
+ while (startIndex < childrenLength) {
190
+ if (isCustomComponent(childrenArr[startIndex])) {
191
+ headChildren = childrenArr[startIndex];
192
+ break;
193
+ }
194
+
195
+ startIndex = startIndex + 1;
196
+ }
197
+
198
+ var tailIndex = childrenLength - 1;
199
+ var tailChildren = null;
200
+
201
+ while (tailIndex >= 0 && tailIndex > startIndex) {
202
+ if (isCustomComponent(childrenArr[tailIndex])) {
203
+ tailChildren = childrenArr[tailIndex];
204
+ break;
205
+ }
206
+
207
+ tailIndex = tailIndex - 1;
208
+ }
209
+
210
+ if (headChildren && tailChildren) {
211
+ if (!headChildren.props) {
212
+ headChildren.props = {};
213
+ }
214
+
215
+ var headChildClass = 'bk-compose-form-item-head';
216
+
217
+ if (headChildren.props["class"]) {
218
+ headChildClass += " ".concat(headChildren.props["class"]);
219
+ }
220
+
221
+ if (this.headBackgroundColor) {
222
+ headChildren.props.style = Object.assign(headChildren.props.style || {}, {
223
+ 'background-color': this.headBackgroundColor
224
+ });
225
+ }
226
+
227
+ headChildren.props["class"] = headChildClass;
228
+
229
+ if (!tailChildren.props) {
230
+ tailChildren.props = {};
231
+ }
232
+
233
+ var tailChildStaticClass = 'bk-compose-form-item-tail';
234
+
235
+ if (tailChildren.props["class"]) {
236
+ tailChildStaticClass += " ".concat(tailChildren.props["class"]);
237
+ }
238
+
239
+ if (this.tailBackgroundColor) {
240
+ tailChildren.props.style = Object.assign(tailChildren.props.style || {}, {
241
+ 'background-color': this.tailBackgroundColor
242
+ });
243
+ }
244
+
245
+ tailChildren.props["class"] = tailChildStaticClass;
246
+ }
247
+ }
248
+
249
+ return (0,external_vue_.h)('div', {
250
+ "class": 'bk-compose-form-item'
251
+ }, childrenArr);
252
+ }
253
+ }));
254
+ ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
255
+ function _defineProperty(obj, key, value) {
256
+ if (key in obj) {
257
+ Object.defineProperty(obj, key, {
258
+ value: value,
259
+ enumerable: true,
260
+ configurable: true,
261
+ writable: true
262
+ });
263
+ } else {
264
+ obj[key] = value;
265
+ }
266
+
267
+ return obj;
268
+ }
269
+ ;// CONCATENATED MODULE: ../../packages/form/src/form.tsx
270
+
271
+
272
+
273
+
274
+ var formProps = {
275
+ formType: external_shared_.PropTypes.oneOf(['default', 'vertical']).def('default'),
276
+ labelWidth: external_shared_.PropTypes.oneOfType([Number, String]).def(150),
277
+ labelPosition: external_shared_.PropTypes.oneOf(['left', 'center', 'right']),
278
+ model: external_shared_.PropTypes.object,
279
+ rules: external_shared_.PropTypes.object
280
+ };
281
+ /* harmony default export */ const src_form = ((0,external_vue_.defineComponent)({
282
+ name: 'Form',
283
+ props: formProps,
284
+ emits: ['submit'],
285
+ setup: function setup(props, context) {
286
+ // form-item 列表
287
+ var formItemInstanceList = [];
288
+ /**
289
+ * @desc 注册 form-item
290
+ * @param { IFormItemContext } formItemInstance
291
+ */
292
+
293
+ var register = function register(formItemInstance) {
294
+ formItemInstanceList.push(formItemInstance);
295
+ };
296
+ /**
297
+ * @desc 卸载 form-item
298
+ * @param { IFormItemContext } formItemInstance
299
+ */
300
+
301
+
302
+ var unregister = function unregister(formItemInstance) {
303
+ formItemInstanceList = formItemInstanceList.reduce(function (result, item) {
304
+ if (item !== formItemInstance) {
305
+ result.push(item);
306
+ }
307
+
308
+ return result;
309
+ }, []);
310
+ };
311
+
312
+ (0,external_vue_.provide)(external_shared_.formKey, {
313
+ props: props,
314
+ register: register,
315
+ unregister: unregister
316
+ });
317
+
318
+ var handleSubmit = function handleSubmit(event) {
319
+ event.preventDefault();
320
+ context.emit('submit');
321
+ };
322
+ /**
323
+ * @desc 验证表单
324
+ * @param { string | Array<string> } fields 指定表单字段
325
+ * @returns { Promise<[]> }
326
+ */
327
+
328
+
329
+ var validate = function validate(fields) {
330
+ var fieldMap = {};
331
+
332
+ if (fields) {
333
+ var fieldList = typeof fields === 'string' ? [fields] : fields;
334
+ fieldMap = fieldList.reduce(function (result, item) {
335
+ return Object.assign(Object.assign({}, result), _defineProperty({}, item, true));
336
+ }, {});
337
+ } else {
338
+ fieldMap = formItemInstanceList.reduce(function (result, item) {
339
+ if (item.property) {
340
+ return Object.assign(Object.assign({}, result), _defineProperty({}, item.property, true));
341
+ }
342
+
343
+ return result;
344
+ }, {});
345
+ }
346
+
347
+ return Promise.all(formItemInstanceList.reduce(function (result, formItem) {
348
+ if (fieldMap[formItem.property]) {
349
+ result.push(formItem.validate());
350
+ }
351
+
352
+ return result;
353
+ }, [])).then(function () {
354
+ return Promise.resolve(props.model);
355
+ });
356
+ };
357
+ /**
358
+ * @desc 清除表单验证错误信息
359
+ * @param { string | Array<string> } fields 指定表单字段
360
+ */
361
+
362
+
363
+ var clearValidate = function clearValidate(fields) {
364
+ var fieldMap = {};
365
+
366
+ if (fields) {
367
+ var fieldList = typeof fields === 'string' ? [fields] : fields;
368
+ fieldMap = fieldList.reduce(function (result, item) {
369
+ return Object.assign(Object.assign({}, result), _defineProperty({}, item, true));
370
+ }, {});
371
+ } else {
372
+ fieldMap = formItemInstanceList.reduce(function (result, item) {
373
+ return Object.assign(Object.assign({}, result), _defineProperty({}, item.property, true));
374
+ }, {});
375
+ }
376
+
377
+ formItemInstanceList.forEach(function (formItem) {
378
+ return fieldMap[formItem.property] && formItem.clearValidate();
379
+ });
380
+ };
381
+
382
+ return {
383
+ handleSubmit: handleSubmit,
384
+ validate: validate,
385
+ clearValidate: clearValidate
386
+ };
387
+ },
388
+ render: function render() {
389
+ var _a, _b;
390
+
391
+ var formClasses = (0,external_shared_.classes)(_defineProperty({
392
+ 'bk-form': true
393
+ }, "bk-form--".concat(this.formType), true));
394
+ return (0,external_vue_.createVNode)("form", {
395
+ "class": formClasses,
396
+ "onSubmit": this.handleSubmit
397
+ }, [(_b = (_a = this.$slots)["default"]) === null || _b === void 0 ? void 0 : _b.call(_a)]);
398
+ }
399
+ }));
400
+ ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
401
+ function _arrayLikeToArray(arr, len) {
402
+ if (len == null || len > arr.length) len = arr.length;
403
+
404
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
405
+ arr2[i] = arr[i];
406
+ }
407
+
408
+ return arr2;
409
+ }
410
+ ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
411
+
412
+ function _arrayWithoutHoles(arr) {
413
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
414
+ }
415
+ ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
416
+ function _iterableToArray(iter) {
417
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
418
+ }
419
+ ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
420
+
421
+ function _unsupportedIterableToArray(o, minLen) {
422
+ if (!o) return;
423
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
424
+ var n = Object.prototype.toString.call(o).slice(8, -1);
425
+ if (n === "Object" && o.constructor) n = o.constructor.name;
426
+ if (n === "Map" || n === "Set") return Array.from(o);
427
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
428
+ }
429
+ ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
430
+ function _nonIterableSpread() {
431
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
432
+ }
433
+ ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
434
+
435
+
436
+
437
+
438
+ function _toConsumableArray(arr) {
439
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
440
+ }
441
+ // EXTERNAL MODULE: external "lodash"
442
+ var external_lodash_ = __webpack_require__(467);
443
+ var external_lodash_default = /*#__PURE__*/__webpack_require__.n(external_lodash_);
444
+ // EXTERNAL MODULE: external "../directives"
445
+ var external_directives_ = __webpack_require__(4061);
446
+ // EXTERNAL MODULE: external "../icon"
447
+ var external_icon_ = __webpack_require__(6870);
448
+ ;// CONCATENATED MODULE: ../../packages/form/src/utils.ts
449
+ /*
450
+ * Tencent is pleased to support the open source community by making
451
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
452
+ *
453
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
454
+ *
455
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
456
+ *
457
+ * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
458
+ *
459
+ * ---------------------------------------------------
460
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
461
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
462
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
463
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
464
+ *
465
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
466
+ * the Software.
467
+ *
468
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
469
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
470
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
471
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
472
+ * IN THE SOFTWARE.
473
+ */
474
+ var getRuleMessage = function getRuleMessage(rule) {
475
+ if (typeof rule.message === 'function') {
476
+ return rule.message();
477
+ }
478
+
479
+ return rule.message;
480
+ };
481
+ ;// CONCATENATED MODULE: ../../packages/form/src/validator.ts
482
+ /*
483
+ * Tencent is pleased to support the open source community by making
484
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
485
+ *
486
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
487
+ *
488
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
489
+ *
490
+ * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
491
+ *
492
+ * ---------------------------------------------------
493
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
494
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
495
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
496
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
497
+ *
498
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
499
+ * the Software.
500
+ *
501
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
502
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
503
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
504
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
505
+ * IN THE SOFTWARE.
506
+ */
507
+
508
+ /* harmony default export */ const src_validator = ({
509
+ required: function required(value) {
510
+ if (typeof value === 'number' || typeof value === 'boolean' || external_lodash_default().isDate(value)) {
511
+ return true;
512
+ }
513
+
514
+ return !external_lodash_default().isEmpty(value);
515
+ },
516
+ min: function min(value, _min) {
517
+ return value >= _min;
518
+ },
519
+ max: function max(value, _max) {
520
+ return _max >= value;
521
+ },
522
+ email: function email(value) {
523
+ return /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(value);
524
+ },
525
+ maxlength: function maxlength(value, _maxlength) {
526
+ return value.length <= _maxlength;
527
+ },
528
+ pattern: function pattern(value, _pattern) {
529
+ return _pattern.test(value);
530
+ }
531
+ });
532
+ ;// CONCATENATED MODULE: ../../packages/form/src/form-item.tsx
533
+
534
+
535
+
536
+
537
+ /*
538
+ * Tencent is pleased to support the open source community by making
539
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
540
+ *
541
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
542
+ *
543
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
544
+ *
545
+ * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
546
+ *
547
+ * ---------------------------------------------------
548
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
549
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
550
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
551
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
552
+ *
553
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
554
+ * the Software.
555
+ *
556
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
557
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
558
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
559
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
560
+ * IN THE SOFTWARE.
561
+ */
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+ ;
570
+ var formItemProps = {
571
+ label: external_shared_.PropTypes.string,
572
+ labelWidth: external_shared_.PropTypes.oneOfType([Number, String]),
573
+ labelPosition: external_shared_.PropTypes.oneOf(['left', 'center', 'right']),
574
+ property: external_shared_.PropTypes.string.def(''),
575
+ required: external_shared_.PropTypes.bool.def(false),
576
+ email: external_shared_.PropTypes.bool.def(false),
577
+ max: external_shared_.PropTypes.number,
578
+ min: external_shared_.PropTypes.number,
579
+ maxlength: external_shared_.PropTypes.number,
580
+ rules: external_shared_.PropTypes.array,
581
+ autoCheck: external_shared_.PropTypes.bool.def(false),
582
+ description: external_shared_.PropTypes.string,
583
+ errorDisplayType: external_shared_.PropTypes.oneOf(['tooltips', 'normal']).def('normal')
584
+ };
585
+
586
+ var hasOwn = function hasOwn(obj, key) {
587
+ return Object.prototype.hasOwnProperty.call(obj, key);
588
+ };
589
+
590
+ var getRulesFromProps = function getRulesFromProps(props) {
591
+ var rules = [];
592
+ var label = props.label || '';
593
+
594
+ if (props.required) {
595
+ rules.push({
596
+ required: true,
597
+ validator: src_validator.required,
598
+ message: "".concat(label, "\u4E0D\u80FD\u4E3A\u7A7A"),
599
+ trigger: 'change'
600
+ });
601
+ }
602
+
603
+ if (props.email) {
604
+ rules.push({
605
+ email: true,
606
+ validator: src_validator.email,
607
+ message: "".concat(label, "\u683C\u5F0F\u4E0D\u6B63\u786E"),
608
+ trigger: 'change'
609
+ });
610
+ }
611
+
612
+ if (Number(props.max) > -1) {
613
+ rules.push({
614
+ validator: function validator(value) {
615
+ return src_validator.max(value, props.max);
616
+ },
617
+ message: "".concat(label, "\u6700\u5927\u503C ").concat(props.max),
618
+ trigger: 'change'
619
+ });
620
+ }
621
+
622
+ if (Number(props.min) > -1) {
623
+ rules.push({
624
+ validator: function validator(value) {
625
+ return src_validator.min(value, props.min);
626
+ },
627
+ message: "".concat(label, "\u6700\u5C0F\u503C ").concat(props.min),
628
+ trigger: 'change'
629
+ });
630
+ }
631
+
632
+ if (Number(props.maxlength) > -1) {
633
+ rules.push({
634
+ validator: function validator(value) {
635
+ return src_validator.maxlength(value, props.maxlength);
636
+ },
637
+ message: "".concat(label, "\u6700\u5927\u957F\u5EA6 ").concat(props.maxlength),
638
+ trigger: 'change'
639
+ });
640
+ }
641
+
642
+ return rules;
643
+ };
644
+
645
+ var mergeRules = function mergeRules(configRules, propRules) {
646
+ var customRequired = false;
647
+ var customEmail = false;
648
+ var formatConfigRules = configRules.reduce(function (result, rule) {
649
+ var rulevalidator;
650
+
651
+ if (rule.required) {
652
+ rulevalidator = (0,external_lodash_.isFunction)(rule.validator) ? rule.validator : src_validator.required;
653
+ customRequired = true;
654
+ } else if (rule.email) {
655
+ rulevalidator = (0,external_lodash_.isFunction)(rule.validator) ? rule.validator : src_validator.email;
656
+ customEmail = true;
657
+ } else if (Number(rule.max) > -1) {
658
+ rulevalidator = function rulevalidator(value) {
659
+ return src_validator.max(value, rule.max);
660
+ };
661
+ } else if (Number(rule.min) > -1) {
662
+ rulevalidator = function rulevalidator(value) {
663
+ return src_validator.min(value, rule.max);
664
+ };
665
+ } else if (Number(rule.maxlength) > -1) {
666
+ rulevalidator = function rulevalidator(value) {
667
+ return src_validator.min(value, rule.max);
668
+ };
669
+ } else if (Object.prototype.toString.call(rule.pattern) === '[object RegExp]') {
670
+ rulevalidator = function rulevalidator(value) {
671
+ return src_validator.pattern(value, rule.pattern);
672
+ };
673
+ } else if ((0,external_lodash_.isFunction)(rule.validator)) {
674
+ rulevalidator = rule.validator;
675
+ } else {
676
+ // 不支持的配置规则
677
+ return result;
678
+ }
679
+
680
+ result.push({
681
+ validator: rulevalidator,
682
+ message: rule.message || '验证错误',
683
+ trigger: rule.trigger || 'blur'
684
+ });
685
+ return result;
686
+ }, []); // 自定义配置验证规则覆盖内置验证规则
687
+
688
+ var filterPropRules = propRules.reduce(function (result, ruleItem) {
689
+ if (ruleItem.required && customRequired) {
690
+ return result;
691
+ }
692
+
693
+ if (ruleItem.email && customEmail) {
694
+ return result;
695
+ }
696
+
697
+ result.push(ruleItem);
698
+ return result;
699
+ }, []);
700
+ return [].concat(_toConsumableArray(filterPropRules), _toConsumableArray(formatConfigRules));
701
+ };
702
+
703
+ var getTriggerRules = function getTriggerRules(trigger, rules) {
704
+ return rules.reduce(function (result, rule) {
705
+ if (!rule.trigger || !trigger) {
706
+ result.push(rule);
707
+ return result;
708
+ }
709
+
710
+ var ruleTriggerList = Array.isArray(rule.trigger) ? rule.trigger : [rule.trigger];
711
+
712
+ if (ruleTriggerList.includes(trigger)) {
713
+ result.push(rule);
714
+ }
715
+
716
+ return result;
717
+ }, []);
718
+ };
719
+
720
+ var isValid = function isValid(value) {
721
+ return value !== undefined;
722
+ };
723
+
724
+ /* harmony default export */ const form_item = ((0,external_vue_.defineComponent)({
725
+ name: 'FormItem',
726
+ directives: {
727
+ bkTooltips: external_directives_.bkTooltips
728
+ },
729
+ props: formItemProps,
730
+ setup: function setup(props, context) {
731
+ var form = (0,external_shared_.useForm)();
732
+ var isForm = Boolean(form);
733
+ var parentFormItem = (0,external_shared_.useFormItem)();
734
+ var isNested = Boolean(parentFormItem);
735
+ var currentInstance = (0,external_vue_.getCurrentInstance)();
736
+ var state = (0,external_vue_.reactive)({
737
+ isError: false,
738
+ errorMessage: ''
739
+ });
740
+ var isFormTypeVertical = (0,external_vue_.computed)(function () {
741
+ if (!isForm) {
742
+ return false;
743
+ }
744
+
745
+ return form.props.formType === 'vertical';
746
+ });
747
+ var isShowLabel = (0,external_vue_.computed)(function () {
748
+ if (props.label || context.slots.label) {
749
+ return true;
750
+ }
751
+
752
+ return false;
753
+ });
754
+ var labelStyles = (0,external_vue_.computed)(function () {
755
+ var styles = {
756
+ width: '',
757
+ paddingRight: '',
758
+ textAlign: ''
759
+ };
760
+ var labelPosition = props.labelPosition || isForm && form.props.labelPosition;
761
+
762
+ if (labelPosition) {
763
+ styles['text-align'] = labelPosition;
764
+ }
765
+
766
+ if (form.props.formType === 'vertical' || !props.label && isNested) {
767
+ return styles;
768
+ }
769
+
770
+ var labelWidth = isValid(props.labelWidth) ? props.labelWidth : isForm && form.props.labelWidth;
771
+
772
+ if (isValid(labelWidth)) {
773
+ styles.width = "".concat(labelWidth, "px");
774
+ styles.paddingRight = labelWidth ? '' : '0px';
775
+ }
776
+
777
+ return styles;
778
+ });
779
+ var contentStyles = (0,external_vue_.computed)(function () {
780
+ return _defineProperty({}, 'margin-left', labelStyles.value.width);
781
+ });
782
+ /**
783
+ * @desc 验证字段
784
+ */
785
+
786
+ var validate = function validate(trigger) {
787
+ // 没有设置 property 不进行验证
788
+ if (!props.property || isForm && !form.props.model) {
789
+ return Promise.resolve(true);
790
+ }
791
+
792
+ var rules = []; // 继承 form 的验证规则
793
+
794
+ if (isForm && form.props.rules && hasOwn(form.props.rules, props.property)) {
795
+ rules = form.props.rules[props.property];
796
+ } // form-item 自己的 rules 规则优先级更高
797
+
798
+
799
+ if (props.rules) {
800
+ rules = props.rules;
801
+ } // 合并规则属性配置
802
+
803
+
804
+ rules = getTriggerRules(trigger, mergeRules(rules, getRulesFromProps(props))); // 重新触发验证重置上次的验证状态
805
+
806
+ if (rules.length > 0) {
807
+ state.isError = false;
808
+ state.errorMessage = '';
809
+ }
810
+
811
+ var value = (0,external_lodash_.get)(form.props.model, props.property);
812
+
813
+ var doValidate = function () {
814
+ var stepIndex = -1;
815
+ return function () {
816
+ stepIndex = stepIndex + 1;
817
+
818
+ if (stepIndex >= rules.length) {
819
+ return Promise.resolve(true);
820
+ }
821
+
822
+ var rule = rules[stepIndex];
823
+ return Promise.resolve().then(function () {
824
+ var result = rule.validator(value); // 异步验证
825
+
826
+ if (typeof result !== 'boolean' && typeof result.then === 'function') {
827
+ return result.then(function (data) {
828
+ // 异步验证结果为 false
829
+ if (data === false) {
830
+ return Promise.reject(getRuleMessage(rule));
831
+ }
832
+ }).then(function () {
833
+ return doValidate();
834
+ }, function () {
835
+ state.isError = true;
836
+ state.errorMessage = getRuleMessage(rule);
837
+ return Promise.reject(state.errorMessage);
838
+ });
839
+ } // 验证失败
840
+
841
+
842
+ if (!result) {
843
+ state.isError = true; // 验证结果返回的是 String 表示验证失败,返回结果作为错误信息
844
+
845
+ state.errorMessage = typeof result === 'string' ? result : getRuleMessage(rule);
846
+ return Promise.reject(state.errorMessage);
847
+ } // 下一步
848
+
849
+
850
+ return doValidate();
851
+ });
852
+ };
853
+ }();
854
+
855
+ return doValidate();
856
+ };
857
+ /**
858
+ * @desc 清除验证状态
859
+ */
860
+
861
+
862
+ var clearValidate = function clearValidate() {
863
+ state.isError = false;
864
+ state.errorMessage = '';
865
+ };
866
+
867
+ (0,external_vue_.provide)(external_shared_.formItemKey, Object.assign(Object.assign({}, props), {
868
+ validate: validate,
869
+ clearValidate: clearValidate
870
+ }));
871
+ (0,external_vue_.onMounted)(function () {
872
+ if (isForm) {
873
+ form.register(currentInstance.proxy);
874
+ }
875
+ });
876
+ (0,external_vue_.onBeforeUnmount)(function () {
877
+ if (isForm) {
878
+ form.unregister(currentInstance.proxy);
879
+ }
880
+ });
881
+ return Object.assign(Object.assign({}, (0,external_vue_.toRefs)(state)), {
882
+ isShowLabel: isShowLabel,
883
+ labelStyles: labelStyles,
884
+ contentStyles: contentStyles,
885
+ isFormTypeVertical: isFormTypeVertical,
886
+ validate: validate,
887
+ clearValidate: clearValidate
888
+ });
889
+ },
890
+ render: function render() {
891
+ var _this = this;
892
+
893
+ var _a, _b, _c, _d;
894
+
895
+ var itemClassees = (0,external_shared_.classes)({
896
+ 'bk-form-item': true,
897
+ 'is-error': this.isError,
898
+ 'is-required': this.required
899
+ });
900
+
901
+ var renderLabel = function renderLabel() {
902
+ if (_this.$slots.label) {
903
+ return _this.$slots.label();
904
+ }
905
+
906
+ if (_this.description) {
907
+ return (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("span", {
908
+ "class": {
909
+ 'bk-form-label-description': Boolean(_this.description)
910
+ }
911
+ }, [_this.label]), [[(0,external_vue_.resolveDirective)("bk-tooltips"), _this.description]]);
912
+ }
913
+
914
+ return _this.label;
915
+ };
916
+
917
+ var renderError = function renderError() {
918
+ if (!_this.isError) {
919
+ return null;
920
+ }
921
+
922
+ if (_this.errorDisplayType === 'tooltips') {
923
+ return (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("div", {
924
+ "class": "bk-form-error-tips"
925
+ }, [(0,external_vue_.createVNode)(external_icon_.ExclamationCircleShape, null, null)]), [[(0,external_vue_.resolveDirective)("bk-tooltips"), _this.errorMessage]]);
926
+ }
927
+
928
+ return (0,external_vue_.createVNode)("div", {
929
+ "class": "bk-form-error"
930
+ }, [_this.$slots.error ? _this.$slots.error(_this.errorMessage) : _this.errorMessage]);
931
+ };
932
+
933
+ return (0,external_vue_.createVNode)("div", {
934
+ "class": itemClassees
935
+ }, [this.isShowLabel && (0,external_vue_.createVNode)("div", {
936
+ "class": "bk-form-label",
937
+ "style": this.labelStyles
938
+ }, [renderLabel(), this.isFormTypeVertical && ((_b = (_a = this.$slots).labelAppend) === null || _b === void 0 ? void 0 : _b.call(_a))]), (0,external_vue_.createVNode)("div", {
939
+ "class": "bk-form-content",
940
+ "style": this.contentStyles
941
+ }, [(_d = (_c = this.$slots)["default"]) === null || _d === void 0 ? void 0 : _d.call(_c), renderError()])]);
942
+ }
943
+ }));
944
+ ;// CONCATENATED MODULE: ../../packages/form/src/index.ts
945
+ /*
946
+ * Tencent is pleased to support the open source community by making
947
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
948
+ *
949
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
950
+ *
951
+ * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
952
+ *
953
+ * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
954
+ *
955
+ * ---------------------------------------------------
956
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
957
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
958
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
959
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
960
+ *
961
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
962
+ * the Software.
963
+ *
964
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
965
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
966
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
967
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
968
+ * IN THE SOFTWARE.
969
+ */
970
+
971
+
972
+
973
+
974
+
975
+ var BkForm = (0,external_shared_.withInstallProps)(src_form, {
976
+ FormItem: form_item,
977
+ ComposeFormItem: compose_form_item
978
+ });
979
+ /* harmony default export */ const src = (BkForm);
980
+
981
+ })();
982
+
983
+ /******/ return __webpack_exports__;
984
+ /******/ })()
985
+ ;
986
+ });