bkui-vue 0.0.2-beta.36 → 0.0.2-beta.37

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