@utogether/utils 1.0.5 → 1.0.8
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 +1 -1
- package/package.json +2 -2
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:i,props:c,optionProps:p={},events:l}=e,{label:u="label",value:s="value",extLabel:d}=p,{code:v,fetchField:g,extParam:a={},loading:_=!1}=c;async function m(h){const x=Object.assign({},{pageSize:20,pageNum:1},a,{[g]:h});let f;try{i.length=0,c.loading=!0,f=await serviceApi(v,x),f&&i.push(...f.list)}finally{c.loading=!1}}function w(h){const{fieldMap:x={}}=c,f=i.find(b=>h===b[s]),y=Object.keys(x);if(y.length){const b=Object.values(x);y.forEach((R,C)=>{r[R]=h?f[b[C]]:""})}l!=null&&l.change&&l.change(h,f,r,o)}function E(){l!=null&&l.clear&&l.clear({data:r,property:o})}function O(){!i.length&&m("")}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":m,loading:_,onFocus:()=>O(),onChange:h=>w(h),onClear:()=>E()}),_isSlot(n=i.map(h=>vue.createVNode(vue.resolveComponent("el-option"),{key:h[s],label:h[u],value:h[s]},{default:()=>[vue.createVNode("span",{style:"float: left"},[h[d]?`${h[s]}-${h[d]}`:h[s]]),s!==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":i=>n[r]=i,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:i,props:c,optionProps:p={},events:l}=e,{label:u="label",value:s="value",extLabel:d}=p,{code:v,fetchField:g,extParam:a={},loading:_=!1,multiple:m,defaultValue:w}=c;w&&Object.keys(w).forEach(y=>{r[y]=r[y]||w[y]}),m&&r[o.field]&&!xeUtils.isArray(r[o.field])&&r[o.field].split(",").forEach(f=>{!i.some(b=>b[u]===f)&&i.push({[s]:f,[u]:f})});async function E(f){const y=Object.assign({},{pageSize:20,pageNum:1},a,{[g||u]:f});let b;try{i.length=0,c.loading=!0,b=await serviceApi(v,y),b&&(b.list?i.push(...b.list):i.push(...b))}finally{c.loading=!1}}function O(f){const{fieldMap:y={}}=c,b=f&&i.find(C=>f===C[s]),R=Object.keys(y);if(R.length){const C=Object.values(y);R.forEach((V,S)=>{r[V]=f?b[C[S]]:""})}l!=null&&l.change&&l.change(t,f,b,o.field)}function h(){l!=null&&l.onClear&&l.onClear({row:r,field:o.field})}function x(){!i.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:()=>x(),onChange:f=>O(f),onClear:()=>h()}),_isSlot(n=i.map(f=>vue.createVNode(vue.resolveComponent("el-option"),{key:f[s],label:f[u],value:f[s]},{default:()=>[vue.createVNode("span",{style:"float: left"},[f[d]?`${f[s]}-${f[d]}`:f[s]]),s!==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:i,props:c,optionProps:p={},events:l}=e,{label:u="label",value:s="value",extLabel:d}=p;c.multiple&&r[o.field]&&!xeUtils.isArray(r[o.field])&&r[o.field].split(",").forEach(a=>{!i.some(m=>m[u]===a)&&i.push({[s]:a,[u]:a})});function v(a){const _=a&&i.find(m=>a===m[s]);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=i.map(a=>vue.createVNode(vue.resolveComponent("el-option"),{key:a[s],label:a[d]?a[s]:a[u],value:a[s]},{default:()=>[vue.createVNode("span",{style:"float: left"},[d&&a[d]?`${a[s]}-${a[d]}`:a[s]]),s!==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:i,props:c,optionProps:p={},events:l}=e,{label:u="label",value:s="value"}=p,{defaultValues:d}=c;d&&(r[o]=d);function v(a){const{fieldMap:_={}}=c,m=i.find(O=>a===O[s]),w=Object.keys(_);if(w.length){const O=Object.values(_);w.forEach((h,x)=>{r[h]=a?m[O[x]]:""})}const E={item:m,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=i.map(a=>vue.createVNode(vue.resolveComponent("el-option"),{key:a[s],label:a[u],value:a[s]},{default:()=>[vue.createVNode("span",{style:"float: left"},[a[u]]),vue.createVNode("span",{class:"su-coSelect-option"},[a[s]])]})))?n:{default:()=>[n]})]}}),VXETable.renderer.add("#tag",{renderDefault(e,t){let n;const{row:r,column:o}=t,{props:{code:i,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(i,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(i=>i.dictCode===t))==null?void 0:o.dictName}return VXETable},hasClass=(e,t)=>{var n;return!!((n=e.className)!=null&&n.match(new RegExp("(\\s|^)"+t+"(\\s|$)")))},addClass=(e,t,n)=>{hasClass(e,t)||(e.className+=" "+t),n&&(hasClass(e,n)||(e.className+=" "+n))},removeClass=(e,t,n)=>{var r,o;if(hasClass(e,t)){const i=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=(r=e.className)==null?void 0:r.replace(i," ").trim()}if(n&&hasClass(e,n)){const i=new RegExp("(\\s|^)"+n+"(\\s|$)");e.className=(o=e.className)==null?void 0:o.replace(i," ").trim()}},toggleClass=(e,t,n)=>{const r=n||document.body;let{className:o}=r;o=o==null?void 0:o.replace(t,""),r.className=o&&e?`${o} ${t} `:o};function useRafThrottle(e){let t=!1;return function(...n){t||(t=!0,window.requestAnimationFrame(()=>{e.apply(this,n),t=!1}))}}const openLink=e=>{const t=document.createElement("a");t.setAttribute("href",e),t.setAttribute("target","_blank"),t.setAttribute("rel","noreferrer noopener"),t.setAttribute("id","external"),document.getElementById("external")&&document.body.removeChild(document.getElementById("external")),document.body.appendChild(t),t.click(),t.remove()};var MapShim=function(){if(typeof Map!="undefined")return Map;function e(t,n){var r=-1;return t.some(function(o,i){return o[0]===n?(r=i,!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,i=this.__entries__;o<i.length;o++){var c=i[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 i(){n&&(n=!1,e()),r&&p()}function c(){requestAnimationFrame$1(i)}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(i){return!!~r.indexOf(i)});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 i=e["border-"+o+"-width"];return r+toFloat(i)},0)}function getPaddings(e){for(var t=["top","right","bottom","left"],n={},r=0,o=t;r<o.length;r++){var i=o[r],c=e["padding-"+i];n[i]=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),i=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+i)!==t&&(p-=getBordersSize(r,"left","right")+i),Math.round(l+c)!==n&&(l-=getBordersSize(r,"top","bottom")+c)),!isDocumentElement(e)){var u=Math.round(p+i)-t,s=Math.round(l+c)-n;Math.abs(u)!==1&&(p-=u),Math.abs(s)!==1&&(l-=s)}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,i=typeof DOMRectReadOnly!="undefined"?DOMRectReadOnly:Object,c=Object.create(i.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:s,clientWidth:d}=u;c({height:s,width:d})}),n=domSymbol.toString(),r=vue.shallowRef(),o=()=>{const u=vue.unref(r);r.value=void 0;const s=vue.unref(e);!s||(u&&s.removeChild(u),removeResizeListener(s,t))};function i(u,s){var _,m;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=(_=s==null?void 0:s.font)!=null?_:"15px Reggae One",a.fillStyle=(m=s==null?void 0:s.fillStyle)!=null?m:"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 s=vue.unref(r);!s||(xeUtils.isUndefined(u.width)||(s.style.width=`${u.width}px`),xeUtils.isUndefined(u.height)||(s.style.height=`${u.height}px`),xeUtils.isUndefined(u.str)||(s.style.background=`url(${i(u.str,u.attr)}) left top repeat`))}const p=(u,s)=>{if(vue.unref(r))return c({str:u,attr:s}),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:s}),v.appendChild(d),n};function l(u,s){p(u,s),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)})}const delay=e=>new Promise(t=>setTimeout(t,e));exports.VxetableRender=VxetableRender,exports.addClass=addClass,exports.addResizeListener=addResizeListener,exports.buildShortUUID=buildShortUUID,exports.buildUUID=buildUUID,exports.delay=delay,exports.hasClass=hasClass,exports.openLink=openLink,exports.removeClass=removeClass,exports.removeResizeListener=removeResizeListener,exports.sleep=sleep,exports.toggleClass=toggleClass,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.
|
|
4
|
+
"version": "1.0.8",
|
|
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
|
},
|