@utogether/utils 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.umd.js CHANGED
@@ -1 +1 @@
1
- (function(s,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("vue"),require("xe-utils")):typeof define=="function"&&define.amd?define(["exports","vue","xe-utils"],i):(s=typeof globalThis!="undefined"?globalThis:s||self,i(s["@utogether/utils"]={},s.Vue,s.xeUtils))})(this,function(exports,vue,xeUtils){"use strict";function _isSlot(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!vue.isVNode(s)}const VxetableRender=(VXETable,{serviceApi,dict,i18n})=>{VXETable.renderer.add("#SuSelect",{renderItemContent(s,i){let u;const{data:e,property:t}=i,{options:n,props:d,optionProps:m={},events:o}=s,{label:p="label",value:r="value",extLabel:f}=m,{code:C,fetchField:x,extParam:l={},loading:V=!1}=d;async function h(c){const y=Object.assign({},{pageSize:20,pageNum:1},l,{[x]:c});let a;try{n.length=0,d.loading=!0,a=await serviceApi(C,y),a&&n.push(...a.list)}finally{d.loading=!1}}function b(c){const{fieldMap:y={}}=d,a=n.find(v=>c===v[r]),g=Object.keys(y);if(g.length){const v=Object.values(y);g.forEach((w,S)=>{e[w]=c?a[v[S]]:""})}o!=null&&o.change&&o.change(c,a,e,t)}function E(){o!=null&&o.clear&&o.clear({data:e,property:t})}function N(){!n.length&&h("")}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:e[t],"onUpdate:modelValue":c=>e[t]=c},d,{filterable:!0,remote:!0,clearable:!0,size:"small",style:"width: 100%",placeholder:"\u8BF7\u5F55\u5165\u5173\u952E\u5B57\u641C\u7D22","remote-method":h,loading:V,onFocus:()=>N(),onChange:c=>b(c),onClear:()=>E()}),_isSlot(u=n.map(c=>vue.createVNode(vue.resolveComponent("el-option"),{key:c[r],label:c[p],value:c[r]},{default:()=>[vue.createVNode("span",{style:"float: left"},[c[f]?`${c[r]}-${c[f]}`:c[r]]),r!==p&&!c[f]?vue.createVNode("span",{class:"su-coSelect-option"},[c[p]]):null]})))?u:{default:()=>[u]})]}}),VXETable.renderer.add("#SuDateRange",{renderItemContent(s,i){const{data:u,property:e}=i,{props:t}=s;return[vue.createVNode(vue.resolveComponent("el-date-picker"),{modelValue:u[e],"onUpdate:modelValue":n=>u[e]=n,type:(t==null?void 0:t.type)||"daterange",size:"small",style:"width: 100%","range-separator":i18n("message.to"),"start-placeholder":i18n("message.startDate"),"end-placeholder":i18n("message.endDate")},null)]}}),VXETable.renderer.add("#SuSelect",{renderEdit(s,i){let u;const{row:e,column:t}=i,{options:n,props:d,optionProps:m={},events:o}=s,{label:p="label",value:r="value",extLabel:f}=m,{code:C,fetchField:x,extParam:l={},loading:V=!1,multiple:h,defaultValue:b}=d;b&&Object.keys(b).forEach(g=>{e[g]=e[g]||b[g]}),h&&e[t.field]&&!xeUtils.isArray(e[t.field])&&e[t.field].split(",").forEach(a=>{!n.some(v=>v[p]===a)&&n.push({[r]:a,[p]:a})});async function E(a){const g=Object.assign({},{pageSize:20,pageNum:1},l,{[x||p]:a});let v;try{n.length=0,d.loading=!0,v=await serviceApi(C,g),v&&(v.list?n.push(...v.list):n.push(...v))}finally{d.loading=!1}}function N(a){const{fieldMap:g={}}=d,v=a&&n.find(S=>a===S[r]),w=Object.keys(g);if(w.length){const S=Object.values(g);w.forEach((j,O)=>{e[j]=a?v[S[O]]:""})}o!=null&&o.change&&o.change(i,a,v,t.field)}function c(){o!=null&&o.onClear&&o.onClear({row:e,field:t.field})}function y(){!n.length&&E("")}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:e[t.field],"onUpdate:modelValue":a=>e[t.field]=a},d,{filterable:!0,remote:!0,clearable:!0,size:"small",placeholder:"\u8BF7\u5F55\u5165\u5173\u952E\u5B57\u641C\u7D22",style:"width: 100%","remote-method":E,loading:V,onFocus:()=>y(),onChange:a=>N(a),onClear:()=>c()}),_isSlot(u=n.map(a=>vue.createVNode(vue.resolveComponent("el-option"),{key:a[r],label:a[p],value:a[r]},{default:()=>[vue.createVNode("span",{style:"float: left"},[a[f]?`${a[r]}-${a[f]}`:a[r]]),r!==p&&!a[f]?vue.createVNode("span",{class:"su-coSelect-option"},[a[p]]):null]})))?u:{default:()=>[u]})]},renderCell(renderOpts,params){const{row,column}=params,{props}=renderOpts,{textValue,multiple}=props;let val=row[column.field];return textValue&&(val=eval(`row.${textValue}`)||row[column.field]),val&&multiple&&xeUtils.isArray(val)&&(val=val&&val.join(",")),[vue.createVNode("span",null,[val])]}}),VXETable.renderer.add("#select",{renderEdit(s,i){let u;const{row:e,column:t}=i,{options:n,props:d,optionProps:m={},events:o}=s,{label:p="label",value:r="value",extLabel:f}=m;d.multiple&&e[t.field]&&!xeUtils.isArray(e[t.field])&&e[t.field].split(",").forEach(l=>{!n.some(h=>h[p]===l)&&n.push({[r]:l,[p]:l})});function C(l){const V=l&&n.find(h=>l===h[r]);o!=null&&o.change&&o.change(i,l,V,t.field)}function x(){o!=null&&o.onClear&&o.onClear({row:e,field:t.field})}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:e[t.field],"onUpdate:modelValue":l=>e[t.field]=l,filterable:!0,clearable:!0},d,{size:"small",style:"width: 100%",onChange:l=>C(l),onClear:()=>x()}),_isSlot(u=n.map(l=>vue.createVNode(vue.resolveComponent("el-option"),{key:l[r],label:l[f]?l[r]:l[p],value:l[r]},{default:()=>[vue.createVNode("span",{style:"float: left"},[f&&l[f]?`${l[r]}-${l[f]}`:l[r]]),r!==p&&!l[f]?vue.createVNode("span",{class:"su-coSelect-option"},[l[p]]):null]})))?u:{default:()=>[u]})]},renderCell(renderOpts,params){const{row,column}=params,{props,options,optionProps}=renderOpts,{label="label",value="value",extLabel}=optionProps,{textValue}=props;let val=row[column.field];const item=options.find(s=>s[value]===val);return textValue&&(val=eval(`row.${textValue}`)||row[column.field]),item&&(val=extLabel?item[value]:item[label]),val&&(props==null?void 0:props.multiple)&&xeUtils.isArray(val)&&(val=val&&val.join(",")),[vue.createVNode("span",null,[val])]}}),VXETable.renderer.add("#select",{renderItemContent(s,i){let u;const{data:e,property:t}=i,{options:n,props:d,optionProps:m={},events:o}=s,{label:p="label",value:r="value"}=m,{defaultValues:f}=d;f&&(e[t]=f);function C(l){const{fieldMap:V={}}=d,h=n.find(N=>l===N[r]),b=Object.keys(V);if(b.length){const N=Object.values(V);b.forEach((c,y)=>{e[c]=l?h[N[y]]:""})}const E={item:h,row:e,property:t};o!=null&&o.change&&o.change(E)}function x(){o!=null&&o.onClear&&o.onClear({data:e,field:t})}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:e[t],"onUpdate:modelValue":l=>e[t]=l},d,{filterable:!0,clearable:!0,size:"small",style:"width: 100%",onChange:l=>C(l),onClear:()=>x()}),_isSlot(u=n.map(l=>vue.createVNode(vue.resolveComponent("el-option"),{key:l[r],label:l[p],value:l[r]},{default:()=>[vue.createVNode("span",{style:"float: left"},[l[p]]),vue.createVNode("span",{class:"su-coSelect-option"},[l[r]])]})))?u:{default:()=>[u]})]}}),VXETable.renderer.add("#tag",{renderDefault(s,i){let u;const{row:e,column:t}=i,{props:{code:n,tagMap:d}}=s;function m(){return e[t.field]?d[e[t.field]]:""}return[e[t.field]?vue.createVNode(vue.resolveComponent("el-tag"),{type:m()},_isSlot(u=getValue(n,e[t.field]))?u:{default:()=>[u]}):null]}});function getValue(s,i){var u,e,t;return!i||!s||!dict?i:(t=(e=(u=dict[s])==null?void 0:u.children)==null?void 0:e.find(n=>n.dictCode===i))==null?void 0:t.dictName}return VXETable};exports.VxetableRender=VxetableRender,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue"),require("xe-utils")):typeof define=="function"&&define.amd?define(["exports","vue","xe-utils"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@utogether/utils"]={},e.Vue,e.xeUtils))})(this,function(exports,vue,xeUtils){"use strict";function _isSlot(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!vue.isVNode(e)}const VxetableRender=(VXETable,{serviceApi,dict,i18n})=>{VXETable.renderer.add("#SuSelect",{renderItemContent(e,t){let n;const{data:r,property:o}=t,{options:s,props:c,optionProps:p={},events:l}=e,{label:u="label",value:i="value",extLabel:d}=p,{code:v,fetchField:g,extParam:a={},loading:_=!1}=c;async function b(h){const O=Object.assign({},{pageSize:20,pageNum:1},a,{[g]:h});let f;try{s.length=0,c.loading=!0,f=await serviceApi(v,O),f&&s.push(...f.list)}finally{c.loading=!1}}function w(h){const{fieldMap:O={}}=c,f=s.find(m=>h===m[i]),y=Object.keys(O);if(y.length){const m=Object.values(O);y.forEach((C,R)=>{r[C]=h?f[m[R]]:""})}l!=null&&l.change&&l.change(h,f,r,o)}function E(){l!=null&&l.clear&&l.clear({data:r,property:o})}function x(){!s.length&&b("")}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:r[o],"onUpdate:modelValue":h=>r[o]=h},c,{filterable:!0,remote:!0,clearable:!0,size:"small",style:"width: 100%",placeholder:"\u8BF7\u5F55\u5165\u5173\u952E\u5B57\u641C\u7D22","remote-method":b,loading:_,onFocus:()=>x(),onChange:h=>w(h),onClear:()=>E()}),_isSlot(n=s.map(h=>vue.createVNode(vue.resolveComponent("el-option"),{key:h[i],label:h[u],value:h[i]},{default:()=>[vue.createVNode("span",{style:"float: left"},[h[d]?`${h[i]}-${h[d]}`:h[i]]),i!==u&&!h[d]?vue.createVNode("span",{class:"su-coSelect-option"},[h[u]]):null]})))?n:{default:()=>[n]})]}}),VXETable.renderer.add("#SuDateRange",{renderItemContent(e,t){const{data:n,property:r}=t,{props:o}=e;return[vue.createVNode(vue.resolveComponent("el-date-picker"),{modelValue:n[r],"onUpdate:modelValue":s=>n[r]=s,type:(o==null?void 0:o.type)||"daterange",size:"small",style:"width: 100%","range-separator":i18n("message.to",!0),"start-placeholder":i18n("message.startDate",!0),"end-placeholder":i18n("message.endDate",!0)},null)]}}),VXETable.renderer.add("#SuSelect",{renderEdit(e,t){let n;const{row:r,column:o}=t,{options:s,props:c,optionProps:p={},events:l}=e,{label:u="label",value:i="value",extLabel:d}=p,{code:v,fetchField:g,extParam:a={},loading:_=!1,multiple:b,defaultValue:w}=c;w&&Object.keys(w).forEach(y=>{r[y]=r[y]||w[y]}),b&&r[o.field]&&!xeUtils.isArray(r[o.field])&&r[o.field].split(",").forEach(f=>{!s.some(m=>m[u]===f)&&s.push({[i]:f,[u]:f})});async function E(f){const y=Object.assign({},{pageSize:20,pageNum:1},a,{[g||u]:f});let m;try{s.length=0,c.loading=!0,m=await serviceApi(v,y),m&&(m.list?s.push(...m.list):s.push(...m))}finally{c.loading=!1}}function x(f){const{fieldMap:y={}}=c,m=f&&s.find(R=>f===R[i]),C=Object.keys(y);if(C.length){const R=Object.values(y);C.forEach((V,S)=>{r[V]=f?m[R[S]]:""})}l!=null&&l.change&&l.change(t,f,m,o.field)}function h(){l!=null&&l.onClear&&l.onClear({row:r,field:o.field})}function O(){!s.length&&E("")}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:r[o.field],"onUpdate:modelValue":f=>r[o.field]=f},c,{filterable:!0,remote:!0,clearable:!0,size:"small",placeholder:"\u8BF7\u5F55\u5165\u5173\u952E\u5B57\u641C\u7D22",style:"width: 100%","remote-method":E,loading:_,onFocus:()=>O(),onChange:f=>x(f),onClear:()=>h()}),_isSlot(n=s.map(f=>vue.createVNode(vue.resolveComponent("el-option"),{key:f[i],label:f[u],value:f[i]},{default:()=>[vue.createVNode("span",{style:"float: left"},[f[d]?`${f[i]}-${f[d]}`:f[i]]),i!==u&&!f[d]?vue.createVNode("span",{class:"su-coSelect-option"},[f[u]]):null]})))?n:{default:()=>[n]})]},renderCell(renderOpts,params){const{row,column}=params,{props}=renderOpts,{textValue,multiple}=props;let val=row[column.field];return textValue&&(val=eval(`row.${textValue}`)||row[column.field]),val&&multiple&&xeUtils.isArray(val)&&(val=val&&val.join(",")),[vue.createVNode("span",null,[val])]}}),VXETable.renderer.add("#select",{renderEdit(e,t){let n;const{row:r,column:o}=t,{options:s,props:c,optionProps:p={},events:l}=e,{label:u="label",value:i="value",extLabel:d}=p;c.multiple&&r[o.field]&&!xeUtils.isArray(r[o.field])&&r[o.field].split(",").forEach(a=>{!s.some(b=>b[u]===a)&&s.push({[i]:a,[u]:a})});function v(a){const _=a&&s.find(b=>a===b[i]);l!=null&&l.change&&l.change(t,a,_,o.field)}function g(){l!=null&&l.onClear&&l.onClear({row:r,field:o.field})}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:r[o.field],"onUpdate:modelValue":a=>r[o.field]=a,filterable:!0,clearable:!0},c,{size:"small",style:"width: 100%",onChange:a=>v(a),onClear:()=>g()}),_isSlot(n=s.map(a=>vue.createVNode(vue.resolveComponent("el-option"),{key:a[i],label:a[d]?a[i]:a[u],value:a[i]},{default:()=>[vue.createVNode("span",{style:"float: left"},[d&&a[d]?`${a[i]}-${a[d]}`:a[i]]),i!==u&&!a[d]?vue.createVNode("span",{class:"su-coSelect-option"},[a[u]]):null]})))?n:{default:()=>[n]})]},renderCell(renderOpts,params){const{row,column}=params,{props,options,optionProps}=renderOpts,{label="label",value="value",extLabel}=optionProps,{textValue}=props;let val=row[column.field];const item=options.find(e=>e[value]===val);return textValue&&(val=eval(`row.${textValue}`)||row[column.field]),item&&(val=extLabel?item[value]:item[label]),val&&(props==null?void 0:props.multiple)&&xeUtils.isArray(val)&&(val=val&&val.join(",")),[vue.createVNode("span",null,[val])]}}),VXETable.renderer.add("#select",{renderItemContent(e,t){let n;const{data:r,property:o}=t,{options:s,props:c,optionProps:p={},events:l}=e,{label:u="label",value:i="value"}=p,{defaultValues:d}=c;d&&(r[o]=d);function v(a){const{fieldMap:_={}}=c,b=s.find(x=>a===x[i]),w=Object.keys(_);if(w.length){const x=Object.values(_);w.forEach((h,O)=>{r[h]=a?b[x[O]]:""})}const E={item:b,row:r,property:o};l!=null&&l.change&&l.change(E)}function g(){l!=null&&l.onClear&&l.onClear({data:r,field:o})}return[vue.createVNode(vue.resolveComponent("el-select"),vue.mergeProps({modelValue:r[o],"onUpdate:modelValue":a=>r[o]=a},c,{filterable:!0,clearable:!0,size:"small",style:"width: 100%",onChange:a=>v(a),onClear:()=>g()}),_isSlot(n=s.map(a=>vue.createVNode(vue.resolveComponent("el-option"),{key:a[i],label:a[u],value:a[i]},{default:()=>[vue.createVNode("span",{style:"float: left"},[a[u]]),vue.createVNode("span",{class:"su-coSelect-option"},[a[i]])]})))?n:{default:()=>[n]})]}}),VXETable.renderer.add("#tag",{renderDefault(e,t){let n;const{row:r,column:o}=t,{props:{code:s,tagMap:c}}=e;function p(){return r[o.field]?c[r[o.field]]:""}return[r[o.field]?vue.createVNode(vue.resolveComponent("el-tag"),{type:p()},_isSlot(n=getValue(s,r[o.field]))?n:{default:()=>[n]}):null]}});function getValue(e,t){var n,r,o;return!t||!e||!dict?t:(o=(r=(n=dict[e])==null?void 0:n.children)==null?void 0:r.find(s=>s.dictCode===t))==null?void 0:o.dictName}return VXETable};function useRafThrottle(e){let t=!1;return function(...n){t||(t=!0,window.requestAnimationFrame(()=>{e.apply(this,n),t=!1}))}}var MapShim=function(){if(typeof Map!="undefined")return Map;function e(t,n){var r=-1;return t.some(function(o,s){return o[0]===n?(r=s,!0):!1}),r}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),o=this.__entries__[r];return o&&o[1]},t.prototype.set=function(n,r){var o=e(this.__entries__,n);~o?this.__entries__[o][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,o=e(r,n);~o&&r.splice(o,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var o=0,s=this.__entries__;o<s.length;o++){var c=s[o];n.call(r,c[1],c[0])}},t}()}(),isBrowser=typeof window!="undefined"&&typeof document!="undefined"&&window.document===document,global$1=function(){return typeof global!="undefined"&&global.Math===Math?global:typeof self!="undefined"&&self.Math===Math?self:typeof window!="undefined"&&window.Math===Math?window:Function("return this")()}(),requestAnimationFrame$1=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(global$1):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),trailingTimeout=2;function throttle(e,t){var n=!1,r=!1,o=0;function s(){n&&(n=!1,e()),r&&p()}function c(){requestAnimationFrame$1(s)}function p(){var l=Date.now();if(n){if(l-o<trailingTimeout)return;r=!0}else n=!0,r=!1,setTimeout(c,t);o=l}return p}var REFRESH_DELAY=20,transitionKeys=["top","right","bottom","left","width","height","size","weight"],mutationObserverSupported=typeof MutationObserver!="undefined",ResizeObserverController=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=throttle(this.refresh.bind(this),REFRESH_DELAY)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!isBrowser||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),mutationObserverSupported?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!isBrowser||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,o=transitionKeys.some(function(s){return!!~r.indexOf(s)});o&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),defineConfigurable=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var o=r[n];Object.defineProperty(e,o,{value:t[o],enumerable:!1,writable:!1,configurable:!0})}return e},getWindowOf=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||global$1},emptyRect=createRectInit(0,0,0,0);function toFloat(e){return parseFloat(e)||0}function getBordersSize(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,o){var s=e["border-"+o+"-width"];return r+toFloat(s)},0)}function getPaddings(e){for(var t=["top","right","bottom","left"],n={},r=0,o=t;r<o.length;r++){var s=o[r],c=e["padding-"+s];n[s]=toFloat(c)}return n}function getSVGContentRect(e){var t=e.getBBox();return createRectInit(0,0,t.width,t.height)}function getHTMLElementContentRect(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return emptyRect;var r=getWindowOf(e).getComputedStyle(e),o=getPaddings(r),s=o.left+o.right,c=o.top+o.bottom,p=toFloat(r.width),l=toFloat(r.height);if(r.boxSizing==="border-box"&&(Math.round(p+s)!==t&&(p-=getBordersSize(r,"left","right")+s),Math.round(l+c)!==n&&(l-=getBordersSize(r,"top","bottom")+c)),!isDocumentElement(e)){var u=Math.round(p+s)-t,i=Math.round(l+c)-n;Math.abs(u)!==1&&(p-=u),Math.abs(i)!==1&&(l-=i)}return createRectInit(o.left,o.top,p,l)}var isSVGGraphicsElement=function(){return typeof SVGGraphicsElement!="undefined"?function(e){return e instanceof getWindowOf(e).SVGGraphicsElement}:function(e){return e instanceof getWindowOf(e).SVGElement&&typeof e.getBBox=="function"}}();function isDocumentElement(e){return e===getWindowOf(e).document.documentElement}function getContentRect(e){return isBrowser?isSVGGraphicsElement(e)?getSVGContentRect(e):getHTMLElementContentRect(e):emptyRect}function createReadOnlyRect(e){var t=e.x,n=e.y,r=e.width,o=e.height,s=typeof DOMRectReadOnly!="undefined"?DOMRectReadOnly:Object,c=Object.create(s.prototype);return defineConfigurable(c,{x:t,y:n,width:r,height:o,top:n,right:t+r,bottom:o+n,left:t}),c}function createRectInit(e,t,n,r){return{x:e,y:t,width:n,height:r}}var ResizeObservation=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=createRectInit(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=getContentRect(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e}(),ResizeObserverEntry=function(){function e(t,n){var r=createReadOnlyRect(n);defineConfigurable(this,{target:t,contentRect:r})}return e}(),ResizeObserverSPI=function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new MapShim,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(t instanceof getWindowOf(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new ResizeObservation(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(t instanceof getWindowOf(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;!n.has(t)||(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(!!this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new ResizeObserverEntry(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),observers=typeof WeakMap!="undefined"?new WeakMap:new MapShim,ResizeObserver=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=ResizeObserverController.getInstance(),r=new ResizeObserverSPI(t,n,this);observers.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){ResizeObserver.prototype[e]=function(){var t;return(t=observers.get(this))[e].apply(t,arguments)}});var index=function(){return typeof global$1.ResizeObserver!="undefined"?global$1.ResizeObserver:ResizeObserver}();const isServer=typeof window=="undefined",resizeHandler=e=>{for(const t of e){const n=t.target.__resizeListeners__||[];n.length&&n.forEach(r=>{r()})}},addResizeListener=(e,t)=>{isServer||(e.__resizeListeners__||(e.__resizeListeners__=[],e.__ro__=new index(resizeHandler),e.__ro__.observe(e)),e.__resizeListeners__.push(t))},removeResizeListener=(e,t)=>{!e||!e.__resizeListeners__||(e.__resizeListeners__.splice(e.__resizeListeners__.indexOf(t),1),e.__resizeListeners__.length||e.__ro__.disconnect())},domSymbol=Symbol("watermark-dom");function useWatermark(e=vue.ref(document.body)){const t=useRafThrottle(function(){const u=vue.unref(e);if(!u)return;const{clientHeight:i,clientWidth:d}=u;c({height:i,width:d})}),n=domSymbol.toString(),r=vue.shallowRef(),o=()=>{const u=vue.unref(r);r.value=void 0;const i=vue.unref(e);!i||(u&&i.removeChild(u),removeResizeListener(i,t))};function s(u,i){var _,b;const d=document.createElement("canvas"),v=260,g=180;Object.assign(d,{width:v,height:g});const a=d.getContext("2d");return a&&(a.rotate(-20*Math.PI/120),a.font=(_=i==null?void 0:i.font)!=null?_:"15px Reggae One",a.fillStyle=(b=i==null?void 0:i.fillStyle)!=null?b:"rgba(180, 180, 180, 0.75)",a.textAlign="left",a.textBaseline="middle",a.fillText(u,v/20,g)),d.toDataURL("image/png")}function c(u={}){const i=vue.unref(r);!i||(xeUtils.isUndefined(u.width)&&(i.style.width=`${u.width}px`),xeUtils.isUndefined(u.height)&&(i.style.height=`${u.height}px`),xeUtils.isUndefined(u.str)&&(i.style.background=`url(${s(u.str,u.attr)}) left top repeat`))}const p=(u,i)=>{if(vue.unref(r))return c({str:u,attr:i}),n;const d=document.createElement("div");r.value=d,d.id=n,d.style.pointerEvents="none",d.style.top="0px",d.style.left="0px",d.style.position="absolute",d.style.zIndex="100000";const v=vue.unref(e);if(!v)return n;const{clientHeight:g,clientWidth:a}=v;return c({str:u,width:a,height:g,attr:i}),v.appendChild(d),n};function l(u,i){p(u,i),addResizeListener(document.documentElement,t),vue.getCurrentInstance()&&vue.onBeforeUnmount(()=>{o()})}return{setWatermark:l,clear:o}}const hexList=[];for(let e=0;e<=15;e++)hexList[e]=e.toString(16);function buildUUID(){let e="";for(let t=1;t<=36;t++)t===9||t===14||t===19||t===24?e+="-":t===15?e+=4:t===20?e+=hexList[Math.random()*4|8]:e+=hexList[Math.random()*16|0];return e.replace(/-/g,"")}let unique=0;function buildShortUUID(e=""){const t=Date.now(),n=Math.floor(Math.random()*1e9);return unique++,e+"_"+n+unique+String(t)}const withInstall=e=>{const t=e;return t.install=n=>{n.component(t.name,e)},e};function sleep(e){return new Promise(t=>{const n=setTimeout(()=>{window.clearTimeout(n),t(e)},e)})}exports.VxetableRender=VxetableRender,exports.addResizeListener=addResizeListener,exports.buildShortUUID=buildShortUUID,exports.buildUUID=buildUUID,exports.removeResizeListener=removeResizeListener,exports.sleep=sleep,exports.useWatermark=useWatermark,exports.withInstall=withInstall,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@utogether/utils",
3
3
  "private": false,
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "files": [
6
6
  "dist/utils.umd.js"
7
7
  ],
@@ -21,8 +21,8 @@
21
21
  "preview": "vite preview"
22
22
  },
23
23
  "dependencies": {
24
+ "resize-observer-polyfill": "^1.5.1",
24
25
  "vue": "^3.2.25",
25
- "vue-i18n": "^9.1.10",
26
26
  "vxe-table": "^4.2.3",
27
27
  "xe-utils": "^3.5.4"
28
28
  },