vxe-table 3.9.0-rc.9 → 3.9.1

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 (222) hide show
  1. package/README.md +80 -9
  2. package/es/grid/src/grid.js +116 -62
  3. package/es/grid/style.css +0 -1
  4. package/es/grid/style.min.css +1 -1
  5. package/es/index.esm.js +22 -3
  6. package/es/locale/lang/en-US.js +6 -2
  7. package/es/locale/lang/es-ES.js +5 -1
  8. package/es/locale/lang/hu-HU.js +5 -1
  9. package/es/locale/lang/ja-JP.js +5 -1
  10. package/es/locale/lang/ko-KR.js +5 -1
  11. package/es/locale/lang/pt-BR.js +5 -1
  12. package/es/locale/lang/ru-RU.js +5 -1
  13. package/es/locale/lang/uk-UA.js +5 -1
  14. package/es/locale/lang/vi-VN.js +5 -1
  15. package/es/locale/lang/zh-CHT.js +5 -1
  16. package/es/locale/lang/zh-CN.js +5 -1
  17. package/es/style.css +1 -1
  18. package/es/style.min.css +1 -1
  19. package/es/table/module/custom/panel.js +183 -173
  20. package/es/table/module/edit/mixin.js +35 -40
  21. package/es/table/module/export/export-panel.js +32 -4
  22. package/es/table/module/export/import-panel.js +25 -6
  23. package/es/table/module/export/mixin.js +11 -11
  24. package/es/table/module/menu/mixin.js +2 -2
  25. package/es/table/module/validator/mixin.js +4 -4
  26. package/es/table/render/index.js +17 -11
  27. package/es/table/src/body.js +1 -0
  28. package/es/table/src/columnInfo.js +3 -3
  29. package/es/table/src/methods.js +69 -55
  30. package/es/table/src/props.js +65 -15
  31. package/es/table/src/table.js +63 -29
  32. package/es/table/src/util.js +3 -2
  33. package/es/table/style.css +37 -48
  34. package/es/table/style.min.css +1 -1
  35. package/es/toolbar/src/toolbar.js +21 -7
  36. package/es/toolbar/style.css +0 -1
  37. package/es/toolbar/style.min.css +1 -1
  38. package/es/ui/index.js +5 -3
  39. package/es/ui/src/log.js +1 -1
  40. package/es/vxe-grid/style.css +0 -1
  41. package/es/vxe-grid/style.min.css +1 -1
  42. package/es/vxe-table/style.css +37 -48
  43. package/es/vxe-table/style.min.css +1 -1
  44. package/es/vxe-toolbar/style.css +0 -1
  45. package/es/vxe-toolbar/style.min.css +1 -1
  46. package/lib/colgroup/index.js +3 -3
  47. package/lib/colgroup/index.min.js +1 -1
  48. package/lib/column/index.js +3 -3
  49. package/lib/column/index.min.js +1 -1
  50. package/lib/components.js +9 -11
  51. package/lib/components.min.js +1 -1
  52. package/lib/grid/index.js +3 -3
  53. package/lib/grid/index.min.js +1 -1
  54. package/lib/grid/src/grid.js +577 -487
  55. package/lib/grid/src/grid.min.js +1 -1
  56. package/lib/grid/style/style.css +0 -1
  57. package/lib/grid/style/style.min.css +1 -1
  58. package/lib/index.common.js +3 -4
  59. package/lib/index.umd.js +9148 -17246
  60. package/lib/index.umd.min.js +1 -1
  61. package/lib/locale/lang/en-US.js +6 -2
  62. package/lib/locale/lang/en-US.min.js +1 -1
  63. package/lib/locale/lang/en-US.umd.js +6 -2
  64. package/lib/locale/lang/es-ES.js +5 -1
  65. package/lib/locale/lang/es-ES.min.js +1 -1
  66. package/lib/locale/lang/es-ES.umd.js +5 -1
  67. package/lib/locale/lang/hu-HU.js +5 -1
  68. package/lib/locale/lang/hu-HU.min.js +1 -1
  69. package/lib/locale/lang/hu-HU.umd.js +5 -1
  70. package/lib/locale/lang/ja-JP.js +5 -1
  71. package/lib/locale/lang/ja-JP.min.js +1 -1
  72. package/lib/locale/lang/ja-JP.umd.js +5 -1
  73. package/lib/locale/lang/ko-KR.js +5 -1
  74. package/lib/locale/lang/ko-KR.min.js +1 -1
  75. package/lib/locale/lang/ko-KR.umd.js +5 -1
  76. package/lib/locale/lang/pt-BR.js +5 -1
  77. package/lib/locale/lang/pt-BR.min.js +1 -1
  78. package/lib/locale/lang/pt-BR.umd.js +5 -1
  79. package/lib/locale/lang/ru-RU.js +5 -1
  80. package/lib/locale/lang/ru-RU.min.js +1 -1
  81. package/lib/locale/lang/ru-RU.umd.js +5 -1
  82. package/lib/locale/lang/uk-UA.js +5 -1
  83. package/lib/locale/lang/uk-UA.min.js +1 -1
  84. package/lib/locale/lang/uk-UA.umd.js +5 -1
  85. package/lib/locale/lang/vi-VN.js +5 -1
  86. package/lib/locale/lang/vi-VN.min.js +1 -1
  87. package/lib/locale/lang/zh-CHT.js +5 -1
  88. package/lib/locale/lang/zh-CHT.min.js +1 -1
  89. package/lib/locale/lang/zh-CHT.umd.js +5 -1
  90. package/lib/locale/lang/zh-CN.js +5 -1
  91. package/lib/locale/lang/zh-CN.min.js +1 -1
  92. package/lib/locale/lang/zh-CN.umd.js +5 -1
  93. package/lib/style.css +1 -1
  94. package/lib/style.min.css +1 -1
  95. package/lib/table/index.js +4 -4
  96. package/lib/table/index.min.js +1 -1
  97. package/lib/table/module/custom/mixin.js +53 -44
  98. package/lib/table/module/custom/mixin.min.js +1 -1
  99. package/lib/table/module/custom/panel.js +310 -239
  100. package/lib/table/module/custom/panel.min.js +1 -1
  101. package/lib/table/module/edit/mixin.js +434 -383
  102. package/lib/table/module/edit/mixin.min.js +1 -1
  103. package/lib/table/module/export/export-panel.js +136 -106
  104. package/lib/table/module/export/export-panel.min.js +1 -1
  105. package/lib/table/module/export/import-panel.js +75 -54
  106. package/lib/table/module/export/import-panel.min.js +1 -1
  107. package/lib/table/module/export/mixin.js +592 -597
  108. package/lib/table/module/export/mixin.min.js +1 -1
  109. package/lib/table/module/export/util.js +6 -4
  110. package/lib/table/module/export/util.min.js +1 -1
  111. package/lib/table/module/filter/mixin.js +147 -118
  112. package/lib/table/module/filter/mixin.min.js +1 -1
  113. package/lib/table/module/filter/panel.js +86 -65
  114. package/lib/table/module/filter/panel.min.js +1 -1
  115. package/lib/table/module/keyboard/mixin.js +163 -151
  116. package/lib/table/module/keyboard/mixin.min.js +1 -1
  117. package/lib/table/module/menu/mixin.js +125 -114
  118. package/lib/table/module/menu/mixin.min.js +1 -1
  119. package/lib/table/module/menu/panel.js +36 -34
  120. package/lib/table/module/menu/panel.min.js +1 -1
  121. package/lib/table/module/validator/mixin.js +225 -214
  122. package/lib/table/module/validator/mixin.min.js +1 -1
  123. package/lib/table/render/index.js +401 -297
  124. package/lib/table/render/index.min.js +1 -1
  125. package/lib/table/src/body.js +411 -349
  126. package/lib/table/src/body.min.js +1 -1
  127. package/lib/table/src/cell.js +470 -344
  128. package/lib/table/src/cell.min.js +1 -1
  129. package/lib/table/src/column.js +10 -10
  130. package/lib/table/src/column.min.js +1 -1
  131. package/lib/table/src/columnInfo.js +46 -55
  132. package/lib/table/src/columnInfo.min.js +1 -1
  133. package/lib/table/src/footer.js +157 -132
  134. package/lib/table/src/footer.min.js +1 -1
  135. package/lib/table/src/group.js +1 -1
  136. package/lib/table/src/group.min.js +1 -1
  137. package/lib/table/src/header.js +170 -153
  138. package/lib/table/src/header.min.js +1 -1
  139. package/lib/table/src/methods.js +2770 -2491
  140. package/lib/table/src/methods.min.js +1 -1
  141. package/lib/table/src/props.js +33 -74
  142. package/lib/table/src/props.min.js +1 -1
  143. package/lib/table/src/table.js +436 -395
  144. package/lib/table/src/table.min.js +1 -1
  145. package/lib/table/src/util.js +143 -131
  146. package/lib/table/src/util.min.js +1 -1
  147. package/lib/table/style/style.css +37 -48
  148. package/lib/table/style/style.min.css +1 -1
  149. package/lib/toolbar/index.js +3 -3
  150. package/lib/toolbar/index.min.js +1 -1
  151. package/lib/toolbar/src/toolbar.js +332 -284
  152. package/lib/toolbar/src/toolbar.min.js +1 -1
  153. package/lib/toolbar/style/style.css +0 -1
  154. package/lib/toolbar/style/style.min.css +1 -1
  155. package/lib/ui/index.js +50 -41
  156. package/lib/ui/index.min.js +1 -1
  157. package/lib/ui/src/comp.js +2 -3
  158. package/lib/ui/src/comp.min.js +1 -1
  159. package/lib/ui/src/dom.js +29 -28
  160. package/lib/ui/src/dom.min.js +1 -1
  161. package/lib/ui/src/log.js +6 -4
  162. package/lib/ui/src/log.min.js +1 -1
  163. package/lib/ui/src/utils.js +7 -7
  164. package/lib/v-x-e-table/index.js +3 -4
  165. package/lib/v-x-e-table/index.min.js +1 -1
  166. package/lib/vxe-colgroup/index.js +3 -4
  167. package/lib/vxe-colgroup/index.min.js +1 -1
  168. package/lib/vxe-column/index.js +3 -4
  169. package/lib/vxe-column/index.min.js +1 -1
  170. package/lib/vxe-grid/index.js +3 -4
  171. package/lib/vxe-grid/index.min.js +1 -1
  172. package/lib/vxe-grid/style/style.css +0 -1
  173. package/lib/vxe-grid/style/style.min.css +1 -1
  174. package/lib/vxe-table/index.js +3 -4
  175. package/lib/vxe-table/index.min.js +1 -1
  176. package/lib/vxe-table/style/style.css +37 -48
  177. package/lib/vxe-table/style/style.min.css +1 -1
  178. package/lib/vxe-toolbar/index.js +3 -4
  179. package/lib/vxe-toolbar/index.min.js +1 -1
  180. package/lib/vxe-toolbar/style/style.css +0 -1
  181. package/lib/vxe-toolbar/style/style.min.css +1 -1
  182. package/lib/vxe-ui/index.js +3 -4
  183. package/lib/vxe-ui/index.min.js +1 -1
  184. package/lib/vxe-v-x-e-table/index.js +3 -4
  185. package/lib/vxe-v-x-e-table/index.min.js +1 -1
  186. package/package.json +5 -4
  187. package/packages/grid/src/grid.ts +123 -61
  188. package/packages/locale/lang/en-US.ts +6 -2
  189. package/packages/locale/lang/es-ES.ts +5 -1
  190. package/packages/locale/lang/hu-HU.ts +5 -1
  191. package/packages/locale/lang/ja-JP.ts +5 -1
  192. package/packages/locale/lang/ko-KR.ts +5 -1
  193. package/packages/locale/lang/pt-BR.ts +5 -1
  194. package/packages/locale/lang/ru-RU.ts +5 -1
  195. package/packages/locale/lang/uk-UA.ts +5 -1
  196. package/packages/locale/lang/vi-VN.ts +5 -1
  197. package/packages/locale/lang/zh-CHT.ts +5 -1
  198. package/packages/locale/lang/zh-CN.ts +5 -1
  199. package/packages/table/module/custom/panel.ts +186 -175
  200. package/packages/table/module/edit/mixin.ts +34 -39
  201. package/packages/table/module/export/export-panel.ts +36 -4
  202. package/packages/table/module/export/import-panel.ts +29 -6
  203. package/packages/table/module/export/mixin.ts +11 -11
  204. package/packages/table/module/menu/mixin.ts +2 -2
  205. package/packages/table/module/validator/mixin.ts +4 -4
  206. package/packages/table/render/index.ts +20 -11
  207. package/packages/table/src/body.ts +1 -0
  208. package/packages/table/src/columnInfo.ts +3 -3
  209. package/packages/table/src/methods.ts +70 -55
  210. package/packages/table/src/props.ts +68 -15
  211. package/packages/table/src/table.ts +71 -26
  212. package/packages/table/src/util.ts +3 -2
  213. package/packages/toolbar/src/toolbar.ts +21 -7
  214. package/packages/ui/index.ts +3 -1
  215. package/styles/components/table.scss +82 -17
  216. package/types/all.d.ts +1 -0
  217. /package/es/{iconfont.1726453742001.ttf → iconfont.1728483486168.ttf} +0 -0
  218. /package/es/{iconfont.1726453742001.woff → iconfont.1728483486168.woff} +0 -0
  219. /package/es/{iconfont.1726453742001.woff2 → iconfont.1728483486168.woff2} +0 -0
  220. /package/lib/{iconfont.1726453742001.ttf → iconfont.1728483486168.ttf} +0 -0
  221. /package/lib/{iconfont.1726453742001.woff → iconfont.1728483486168.woff} +0 -0
  222. /package/lib/{iconfont.1726453742001.woff2 → iconfont.1728483486168.woff2} +0 -0
@@ -1 +1 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../../ui"),_utils=require("../../../ui/src/utils"),_dom=require("../../../ui/src/dom"),_util=require("../../src/util"),_log=require("../../../ui/src/log");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _typeof(e){return(_typeof="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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}var getConfig=_ui.VxeUI.getConfig,validators=_ui.VxeUI.validators,Rule=(()=>_createClass(function e(t){_classCallCheck(this,e),Object.defineProperty(this,"$options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.assign(this,{$options:t,required:t.required,min:t.min,max:t.max,type:t.type,pattern:t.pattern,validator:t.validator,trigger:t.trigger,maxWidth:t.maxWidth})},[{key:"content",get:function(){return(0,_utils.getFuncText)(this.$options.content||this.$options.message)}},{key:"message",get:function(){return this.content}}]))();function validErrorRuleValue(e,t){var r=e.type,i=e.min,l=e.max,e=e.pattern,r="number"===r,n=r?_xeUtils.default.toNumber(t):_xeUtils.default.getSize(t);return!(!r||!isNaN(t))||!_xeUtils.default.eqNull(i)&&n<_xeUtils.default.toNumber(i)||!_xeUtils.default.eqNull(l)&&n>_xeUtils.default.toNumber(l)||!(!e||(_xeUtils.default.isRegExp(e)?e:new RegExp(e)).test(t))}var _default=exports.default={methods:{_fullValidate:function(e,t){return"development"===process.env.VUE_APP_VXE_TABLE_ENV&&_xeUtils.default.isFunction(t)&&(0,_log.warnLog)("vxe.error.notValidators",["fullValidate(rows, callback)","fullValidate(rows)"]),this.beginValidate(e,t,!0)},_validate:function(e,t){return"development"===process.env.VUE_APP_VXE_TABLE_ENV&&_xeUtils.default.isFunction(t)&&(0,_log.warnLog)("vxe.error.notValidators",["validate(rows, callback)","validate(rows)"]),this.beginValidate(e,t)},handleValidError:function(t){var r=this,i=this.validOpts;return new Promise(function(e){!1===i.autoPos?(r.emitEvent("valid-error",t),e()):r.handleEdit(t,{type:"valid-error",trigger:"call"}).then(function(){setTimeout(function(){e(r.showValidTooltip(t))},10)})})},handleErrMsgMode:function(e){var t,r;return"single"===this.validOpts.msgMode?(t=e,(r=Object.keys(e)).length&&(t[r=r[0]]=e[r]),t):e},beginValidate:function(e,s,l){var t,r,u=this,c={},n=this.editRules,d=this.afterFullData,f=this.visibleColumn,i=this.treeConfig,o=this.treeOpts,o=o.children||o.childrenField,a=(!0===e?t=d:e&&(_xeUtils.default.isFunction(e)?s=e:t=_xeUtils.default.isArray(e)?e:[e]),t=t||this.getInsertRecords().concat(this.getUpdateRecords()),[]),h=(this.lastCallTime=Date.now(),this.validRuleErr=!1,this.clearValidate(),{});return n?(r=this.getColumns(),e=function(i){var e;!l&&u.validRuleErr||(e=[],r.forEach(function(r){!l&&u.validRuleErr||!_xeUtils.default.has(n,r.property)||e.push(u.validCellRules("all",i,r).catch(function(e){var t=e.rule,e={rule:t,rules:e.rules,rowIndex:u.getRowIndex(i),row:i,columnIndex:u.getColumnIndex(r),column:r,field:r.property,$table:u};if(c[r.property]||(c[r.property]=[]),h["".concat((0,_util.getRowid)(u,i),":").concat(r.id)]={column:r,row:i,rule:t,content:t.content},c[r.property].push(e),!l)return u.validRuleErr=!0,Promise.reject(e)}))}),a.push(Promise.all(e)))},i?_xeUtils.default.eachTree(t,e,{children:o}):t.forEach(e),Promise.all(a).then(function(){var e=Object.keys(c);return u.validErrorMaps=u.handleErrMsgMode(h),u.$nextTick().then(function(){if(e.length)return Promise.reject(c[e[0]][0]);s&&s()})}).catch(function(a){return new Promise(function(e,t){function r(){u.$nextTick(function(){s?(s(c),e()):("obsolete"===getConfig().validToReject?t:e)(c)})}var i,l,n,o;!1===u.validOpts.autoPos?r():(o=a.row,i=a.column,n=d.indexOf(o),l=f.indexOf(i),n=0<n?d[n-1]:o,o=0<l?f[l-1]:i,u.scrollToRow(n,o).then(function(){a.cell=u.getCellElement(a.row,a.column),(0,_dom.scrollToView)(a.cell),u.handleValidError(a).then(r)}))})})):(this.validErrorMaps={},this.$nextTick().then(function(){s&&s()}))},hasCellRules:function(t,e,r){var i=this.editRules,r=r.property;return!(!r||!i)&&(i=_xeUtils.default.get(i,r))&&_xeUtils.default.find(i,function(e){return"all"===t||!e.trigger||t===e.trigger})},validCellRules:function(s,u,c,e){var d,f,h=this,t=this.editRules,r=c.property,p=[],g=[];return r&&t&&(d=_xeUtils.default.get(t,r))&&(f=_xeUtils.default.isUndefined(e)?_xeUtils.default.get(u,r):e,d.forEach(function(t){var e,r,i,l=t.type,n=t.trigger,o=t.required,a=t.validator;"all"!==s&&n&&s!==n||(a?(i={cellValue:f,rule:t,rules:d,row:u,rowIndex:h.getRowIndex(u),column:c,columnIndex:h.getColumnIndex(c),field:c.property,$table:h},_xeUtils.default.isString(a)?(r=validators.get(a))?r.cellValidatorMethod?e=r.cellValidatorMethod(i):"development"===process.env.VUE_APP_VXE_TABLE_ENV&&(0,_log.warnLog)("vxe.error.notValidators",[a]):"development"===process.env.VUE_APP_VXE_TABLE_ENV&&(0,_log.errLog)("vxe.error.notValidators",[a]):e=a(i),e&&(_xeUtils.default.isError(e)?(h.validRuleErr=!0,p.push(new Rule({type:"custom",trigger:n,content:e.message,rule:new Rule(t)}))):e.catch&&g.push(e.catch(function(e){h.validRuleErr=!0,p.push(new Rule({type:"custom",trigger:n,content:e&&e.message?e.message:t.content||t.message,rule:new Rule(t)}))})))):(r="array"===l,a=_xeUtils.default.isArray(f),i=!0,i=r||a?!a||!f.length:_xeUtils.default.isString(f)?(0,_utils.eqEmptyValue)(f.trim()):(0,_utils.eqEmptyValue)(f),(o?i||validErrorRuleValue(t,f):!i&&validErrorRuleValue(t,f))&&(h.validRuleErr=!0,p.push(new Rule(t)))))})),Promise.all(g).then(function(){if(p.length)return Promise.reject({rules:p,rule:p[0]})})},_clearValidate:function(e,t){var r,i,l=this,n=this.validOpts,o=this.validErrorMaps,a=this.$refs.validTip,e=_xeUtils.default.isArray(e)?e:e?[e]:[],s=_xeUtils.default.isArray(t)?t:(t?[t]:[]).map(function(e){return(0,_util.handleFieldOrColumn)(l,e)}),u={};return a&&a.visible&&a.close(),"single"===n.msgMode?this.validErrorMaps={}:(e.length&&s.length?(u=Object.assign({},o),e.forEach(function(t){s.forEach(function(e){e="".concat((0,_util.getRowid)(l,t),":").concat(e.id);u[e]&&delete u[e]})})):e.length?(r=e.map(function(e){return"".concat((0,_util.getRowid)(l,e))}),_xeUtils.default.each(o,function(e,t){-1<r.indexOf(t.split(":")[0])&&(u[t]=e)})):s.length&&(i=s.map(function(e){return"".concat(e.id)}),_xeUtils.default.each(o,function(e,t){-1<i.indexOf(t.split(":")[1])&&(u[t]=e)})),this.validErrorMaps=u),this.$nextTick()},triggerValidate:function(t){var r=this,e=this.editConfig,i=this.editStore,l=this.editRules,n=this.editOpts,o=this.validOpts,i=i.actived;if(l&&"single"===o.msgMode&&(this.validErrorMaps={}),e&&l&&i.row){var o=i.args,a=o.row,s=o.column,u=o.cell;if(this.hasCellRules(t,a,s))return this.validCellRules(t,a,s).then(function(){"row"===n.mode&&r.clearValidate(a,s)}).catch(function(e){var e=e.rule;return e.trigger&&t!==e.trigger?Promise.resolve():(r.showValidTooltip(e={rule:e,row:a,column:s,cell:u}),Promise.reject(e))})}return Promise.resolve()},showValidTooltip:function(e){var t=this.$refs,r=this.height,i=this.validStore,l=this.validErrorMaps,n=this.tableData,o=this.validOpts,a=e.rule,s=e.row,u=e.column,c=e.cell,t=t.validTip,d=a.content;return i.visible=!0,"single"===o.msgMode?this.validErrorMaps=_defineProperty({},"".concat((0,_util.getRowid)(this,s),":").concat(u.id),{column:u,row:s,rule:a,content:d}):this.validErrorMaps=Object.assign({},l,_defineProperty({},"".concat((0,_util.getRowid)(this,s),":").concat(u.id),{column:u,row:s,rule:a,content:d})),this.emitEvent("valid-error",e,null),t&&("tooltip"===o.message||"default"===o.message&&!r&&n.length<2)?t.open(c,d):this.$nextTick()}}};
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../../ui"),_utils=require("../../../ui/src/utils"),_dom=require("../../../ui/src/dom"),_util=require("../../src/util"),_log=require("../../../ui/src/log");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let{getConfig,validators}=_ui.VxeUI;class Rule{constructor(e){Object.defineProperty(this,"$options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.assign(this,{$options:e,required:e.required,min:e.min,max:e.max,type:e.type,pattern:e.pattern,validator:e.validator,trigger:e.trigger,maxWidth:e.maxWidth})}get content(){return(0,_utils.getFuncText)(this.$options.content||this.$options.message)}get message(){return this.content}}function validErrorRuleValue(e,t){var{type:e,min:l,max:i,pattern:r}=e,e="number"===e,s=e?_xeUtils.default.toNumber(t):_xeUtils.default.getSize(t);return!(!e||!isNaN(t))||!_xeUtils.default.eqNull(l)&&s<_xeUtils.default.toNumber(l)||!_xeUtils.default.eqNull(i)&&s>_xeUtils.default.toNumber(i)||!(!r||(_xeUtils.default.isRegExp(r)?r:new RegExp(r)).test(t))}var _default=exports.default={methods:{_fullValidate(e,t){return"development"===process.env.NODE_ENV&&_xeUtils.default.isFunction(t)&&(0,_log.warnLog)("vxe.error.notValidators",["fullValidate(rows, callback)","fullValidate(rows)"]),this.beginValidate(e,t,!0)},_validate(e,t){return"development"===process.env.NODE_ENV&&_xeUtils.default.isFunction(t)&&(0,_log.warnLog)("vxe.error.notValidators",["validate(rows, callback)","validate(rows)"]),this.beginValidate(e,t)},handleValidError(t){let l=this.validOpts;return new Promise(e=>{!1===l.autoPos?(this.emitEvent("valid-error",t),e()):this.handleEdit(t,{type:"valid-error",trigger:"call"}).then(()=>{setTimeout(()=>{e(this.showValidTooltip(t))},10)})})},handleErrMsgMode(e){var t,l=this.validOpts;return"single"===l.msgMode?(l=e,(t=Object.keys(e)).length&&(l[t=t[0]]=e[t]),l):e},beginValidate(e,n,r){let d={},{editRules:s,afterFullData:h,visibleColumn:c,treeConfig:l,treeOpts:t}=this;var i=t.children||t.childrenField;let a,o=(!0===e?a=h:e&&(_xeUtils.default.isFunction(e)?n=e:a=_xeUtils.default.isArray(e)?e:[e]),a=a||this.getInsertRecords().concat(this.getUpdateRecords()),[]),u=(this.lastCallTime=Date.now(),this.validRuleErr=!1,this.clearValidate(),{});if(s){let t=this.getColumns();e=i=>{if(r||!this.validRuleErr){let e=[];t.forEach(l=>{!r&&this.validRuleErr||!_xeUtils.default.has(s,l.property)||e.push(this.validCellRules("all",i,l).catch(({rule:e,rules:t})=>{t={rule:e,rules:t,rowIndex:this.getRowIndex(i),row:i,columnIndex:this.getColumnIndex(l),column:l,field:l.property,$table:this};if(d[l.property]||(d[l.property]=[]),u[(0,_util.getRowid)(this,i)+":"+l.id]={column:l,row:i,rule:e,content:e.content},d[l.property].push(t),!r)return this.validRuleErr=!0,Promise.reject(t)}))}),o.push(Promise.all(e))}};return l?_xeUtils.default.eachTree(a,e,{children:i}):a.forEach(e),Promise.all(o).then(()=>{let e=Object.keys(d);return this.validErrorMaps=this.handleErrMsgMode(u),this.$nextTick().then(()=>{if(e.length)return Promise.reject(d[e[0]][0]);n&&n()})}).catch(u=>new Promise((e,t)=>{let l=()=>{this.$nextTick(()=>{n?(n(d),e()):("obsolete"===getConfig().validToReject?t:e)(d)})};var i,r,s,a,o=()=>{u.cell=this.getCellElement(u.row,u.column),(0,_dom.scrollToView)(u.cell),this.handleValidError(u).then(l)};!1===this.validOpts.autoPos?l():(a=u.row,i=u.column,s=h.indexOf(a),r=c.indexOf(i),s=0<s?h[s-1]:a,a=0<r?c[r-1]:i,this.scrollToRow(s,a).then(o))}))}return this.validErrorMaps={},this.$nextTick().then(()=>{n&&n()})},hasCellRules(t,e,l){var i=this.editRules,l=l.property;return!(!l||!i)&&(i=_xeUtils.default.get(i,l))&&_xeUtils.default.find(i,e=>"all"===t||!e.trigger||t===e.trigger)},validCellRules(e,d,h,t){var l=this.editRules,i=h.property;let c=[],g=[];if(i&&l){let n=_xeUtils.default.get(l,i);if(n){let u=_xeUtils.default.isUndefined(t)?_xeUtils.default.get(d,i):t;n.forEach(t=>{let{type:l,trigger:i,required:r,validator:s}=t;if("all"===e||!i||e===i)if(s){var a={cellValue:u,rule:t,rules:n,row:d,rowIndex:this.getRowIndex(d),column:h,columnIndex:this.getColumnIndex(h),field:h.property,$table:this};let e;_xeUtils.default.isString(s)?(o=validators.get(s))?o.cellValidatorMethod?e=o.cellValidatorMethod(a):"development"===process.env.NODE_ENV&&(0,_log.warnLog)("vxe.error.notValidators",[s]):"development"===process.env.NODE_ENV&&(0,_log.errLog)("vxe.error.notValidators",[s]):e=s(a),e&&(_xeUtils.default.isError(e)?(this.validRuleErr=!0,c.push(new Rule({type:"custom",trigger:i,content:e.message,rule:new Rule(t)}))):e.catch&&g.push(e.catch(e=>{this.validRuleErr=!0,c.push(new Rule({type:"custom",trigger:i,content:e&&e.message?e.message:t.content||t.message,rule:new Rule(t)}))})))}else{var o="array"===l,a=_xeUtils.default.isArray(u);let e=!0;e=o||a?!a||!u.length:_xeUtils.default.isString(u)?(0,_utils.eqEmptyValue)(u.trim()):(0,_utils.eqEmptyValue)(u),(r?e||validErrorRuleValue(t,u):!e&&validErrorRuleValue(t,u))&&(this.validRuleErr=!0,c.push(new Rule(t)))}})}}return Promise.all(g).then(()=>{var e;if(c.length)return e={rules:c,rule:c[0]},Promise.reject(e)})},_clearValidate(e,t){var{validOpts:l,validErrorMaps:i}=this,r=this.$refs.validTip,e=_xeUtils.default.isArray(e)?e:e?[e]:[];let s=_xeUtils.default.isArray(t)?t:(t?[t]:[]).map(e=>(0,_util.handleFieldOrColumn)(this,e)),a={};if(r&&r.visible&&r.close(),"single"===l.msgMode)this.validErrorMaps={};else{if(e.length&&s.length)a=Object.assign({},i),e.forEach(t=>{s.forEach(e=>{e=(0,_util.getRowid)(this,t)+":"+e.id;a[e]&&delete a[e]})});else if(e.length){let l=e.map(e=>""+(0,_util.getRowid)(this,e));_xeUtils.default.each(i,(e,t)=>{-1<l.indexOf(t.split(":")[0])&&(a[t]=e)})}else if(s.length){let l=s.map(e=>""+e.id);_xeUtils.default.each(i,(e,t)=>{-1<l.indexOf(t.split(":")[1])&&(a[t]=e)})}this.validErrorMaps=a}return this.$nextTick()},triggerValidate(r){let{editConfig:e,editStore:t,editRules:l,editOpts:s,validOpts:i}=this;var a=t.actived;if(l&&"single"===i.msgMode&&(this.validErrorMaps={}),e&&l&&a.row){let{row:t,column:l,cell:i}=a.args;if(this.hasCellRules(r,t,l))return this.validCellRules(r,t,l).then(()=>{"row"===s.mode&&this.clearValidate(t,l)}).catch(({rule:e})=>e.trigger&&r!==e.trigger?Promise.resolve():(e={rule:e,row:t,column:l,cell:i},this.showValidTooltip(e),Promise.reject(e)))}return Promise.resolve()},showValidTooltip(e){var{$refs:t,height:l,validStore:i,validErrorMaps:r,tableData:s,validOpts:a}=this,{rule:o,row:u,column:n,cell:d}=e,t=t.validTip,h=o.content;return i.visible=!0,"single"===a.msgMode?this.validErrorMaps={[(0,_util.getRowid)(this,u)+":"+n.id]:{column:n,row:u,rule:o,content:h}}:this.validErrorMaps=Object.assign({},r,{[(0,_util.getRowid)(this,u)+":"+n.id]:{column:n,row:u,rule:o,content:h}}),this.emitEvent("valid-error",e,null),t&&("tooltip"===a.message||"default"===a.message&&!l&&s.length<2)?t.open(d,h):this.$nextTick()}}};