mirror of
https://github.com/HeyPuter/puter.git
synced 2026-10-15 00:00:04 +00:00
Update viselect.min.js
This commit is contained in:
1 parent
783a0385d3
commit
bc842ad371
1 file changed
+2
-2
Vendored
+2
-2
@@ -1,3 +1,3 @@
|
||||
/*! @viselect/vanilla v3.2.4 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */
|
||||
(function(E,g){typeof exports=="object"&&typeof module<"u"?module.exports=g():typeof define=="function"&&define.amd?define(g):(E=typeof globalThis<"u"?globalThis:E||self,E.SelectionArea=g())})(this,function(){"use strict";var Y=Object.defineProperty;var $=(E,g,v)=>g in E?Y(E,g,{enumerable:!0,configurable:!0,writable:!0,value:v}):E[g]=v;var u=(E,g,v)=>($(E,typeof g!="symbol"?g+"":g,v),v);class E{constructor(){u(this,"_listeners",new Map);u(this,"on",this.addEventListener);u(this,"off",this.removeEventListener);u(this,"emit",this.dispatchEvent)}addEventListener(n,e){const t=this._listeners.get(n)||new Set;return this._listeners.set(n,t),t.add(e),this}removeEventListener(n,e){var t;return(t=this._listeners.get(n))==null||t.delete(e),this}dispatchEvent(n,...e){let t=!0;for(const s of this._listeners.get(n)||[])t=s(...e)!==!1&&t;return t}unbindAllListeners(){this._listeners.clear()}}const g=(r,n="px")=>typeof r=="number"?r+n:r;function v({style:r},n,e){if(typeof n=="object")for(const[t,s]of Object.entries(n))s!==void 0&&(r[t]=g(s));else e!==void 0&&(r[n]=g(e))}function C(r){return(n,e,t,s={})=>{n instanceof HTMLCollection||n instanceof NodeList?n=Array.from(n):Array.isArray(n)||(n=[n]),Array.isArray(e)||(e=[e]);for(const o of n)for(const i of e)o[r](i,t,{capture:!1,...s});return[n,e,t,s]}}const A=C("addEventListener"),b=C("removeEventListener"),w=r=>{const{clientX:n,clientY:e,target:t}=r.touches&&r.touches[0]||r;return{x:n,y:e,target:t}};function M(r,n,e="touch"){switch(e){case"center":{const t=n.left+n.width/2,s=n.top+n.height/2;return t>=r.left&&t<=r.right&&s>=r.top&&s<=r.bottom}case"cover":return n.left>=r.left&&n.top>=r.top&&n.right<=r.right&&n.bottom<=r.bottom;case"touch":return r.right>=n.left&&r.left<=n.right&&r.bottom>=n.top&&r.top<=n.bottom}}function T(r,n=document){const e=Array.isArray(r)?r:[r];let t=[];for(let s=0,o=e.length;s<o;s++){const i=e[s];typeof i=="string"?t=t.concat(Array.from(n.querySelectorAll(i))):i instanceof Element&&t.push(i)}return t}const H=()=>matchMedia("(hover: none), (pointer: coarse)").matches,q=()=>"safari"in window,R=(r,n)=>{for(const[e,t]of Object.entries(r)){const s=n[e];r[e]=s===void 0?r[e]:typeof s=="object"&&typeof t=="object"&&t!==null&&!Array.isArray(t)?R(t,s):s}return r},F=r=>{let n,e=-1,t=!1;return{next(...s){n=s,t||(t=!0,e=requestAnimationFrame(()=>{r(...n),t=!1}))},cancel(){cancelAnimationFrame(e),t=!1}}},{abs:S,max:k,min:D,ceil:j}=Math;class B extends E{constructor(e){super();u(this,"_options");u(this,"_selection",{stored:[],selected:[],touched:[],changed:{added:[],removed:[]}});u(this,"_area");u(this,"_clippingElement");u(this,"_targetElement");u(this,"_targetRect");u(this,"_selectables",[]);u(this,"_latestElement");u(this,"_areaRect",new DOMRect);u(this,"_areaLocation",{y1:0,x2:0,y2:0,x1:0});u(this,"_singleClick",!0);u(this,"_frame");u(this,"_scrollAvailable",!0);u(this,"_scrollingActive",!1);u(this,"_scrollSpeed",{x:0,y:0});u(this,"_scrollDelta",{x:0,y:0});u(this,"disable",this._bindStartEvents.bind(this,!1));u(this,"enable",this._bindStartEvents);this._options=R({selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,behaviour:{overlap:"invert",intersect:"touch",startThreshold:{x:10,y:10},scrolling:{speedDivider:10,manualSpeed:750,startScrollMargins:{x:0,y:0}}},features:{range:!0,touch:!0,singleTap:{allow:!0,intersect:"native"}},startAreas:["html"],boundaries:["html"],container:"body"},e);for(const i of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[i]=="function"&&(this[i]=this[i].bind(this));const{document:t,selectionAreaClass:s,selectionContainerClass:o}=this._options;this._area=t.createElement("div"),this._clippingElement=t.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(s),o&&this._clippingElement.classList.add(o),v(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),v(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=F(i=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",i),this._redrawSelectionArea()}),this.enable()}_bindStartEvents(e=!0){const{document:t,features:s}=this._options,o=e?A:b;o(t,"mousedown",this._onTapStart),s.touch&&o(t,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(e,t=!1){const{x:s,y:o,target:i}=w(e),{_options:l}=this,{document:c}=this._options,d=i.getBoundingClientRect(),_=T(l.startAreas,l.document),m=T(l.boundaries,l.document);this._targetElement=m.find(y=>M(y.getBoundingClientRect(),d));const f=e.composedPath();if(!this._targetElement||!_.find(y=>f.includes(y))||!m.find(y=>f.includes(y))||!t&&this._emitEvent("beforestart",e)===!1)return;this._areaLocation={x1:s,y1:o,x2:0,y2:0};const a=c.scrollingElement||c.body;this._scrollDelta={x:a.scrollLeft,y:a.scrollTop},this._singleClick=!0,this.clearSelection(!1,!0),A(c,["touchmove","mousemove"],thLine truncated
|
||||
/*! @viselect/vanilla v3.9.0 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */
|
||||
(function(A,E){typeof exports=="object"&&typeof module<"u"?module.exports=E():typeof define=="function"&&define.amd?define(E):(A=typeof globalThis<"u"?globalThis:A||self,A.SelectionArea=E())})(this,function(){"use strict";class A{constructor(){this._listeners=new Map,this.on=this.addEventListener,this.off=this.removeEventListener,this.emit=this.dispatchEvent}addEventListener(e,t){const s=this._listeners.get(e)??new Set;return this._listeners.set(e,s),s.add(t),this}removeEventListener(e,t){var s;return(s=this._listeners.get(e))==null||s.delete(t),this}dispatchEvent(e,...t){let s=!0;for(const i of this._listeners.get(e)??[])s=i(...t)!==!1&&s;return s}unbindAllListeners(){this._listeners.clear()}}const E=(l,e="px")=>typeof l=="number"?l+e:l,v=({style:l},e,t)=>{if(typeof e=="object")for(const[s,i]of Object.entries(e))i!==void 0&&(l[s]=E(i));else t!==void 0&&(l[e]=E(t))},k=(l=0,e=0,t=0,s=0)=>{const i={x:l,y:e,width:t,height:s,top:e,left:l,right:l+t,bottom:e+s};return{...i,toJSON:()=>JSON.stringify(i)}},K=l=>{let e,t=-1,s=!1;return{next:(...i)=>{e=i,s||(s=!0,t=requestAnimationFrame(()=>{l(...e),s=!1}))},cancel:()=>{cancelAnimationFrame(t),s=!1}}},C=(l,e,t="touch")=>{switch(t){case"center":{const s=e.left+e.width/2,i=e.top+e.height/2;return s>=l.left&&s<=l.right&&i>=l.top&&i<=l.bottom}case"cover":return e.left>=l.left&&e.top>=l.top&&e.right<=l.right&&e.bottom<=l.bottom;case"touch":return l.right>=e.left&&l.left<=e.right&&l.bottom>=e.top&&l.top<=e.bottom}},X=()=>matchMedia("(hover: none), (pointer: coarse)").matches,Y=()=>"safari"in window,w=l=>Array.isArray(l)?l:[l],B=l=>(e,t,s,i={})=>{(e instanceof HTMLCollection||e instanceof NodeList)&&(e=Array.from(e)),t=w(t),e=w(e);for(const o of e)if(o)for(const n of t)o[l](n,s,{capture:!1,...i})},y=B("addEventListener"),m=B("removeEventListener"),T=l=>{var i;const{clientX:e,clientY:t,target:s}=((i=l.touches)==null?void 0:i[0])??l;return{x:e,y:t,target:s}},x=(l,e=document)=>w(l).map(t=>typeof t=="string"?Array.from(e.querySelectorAll(t)):t instanceof Element?t:null).flat().filter(Boolean),H=(l,e)=>e.some(t=>typeof t=="number"?l.button===t:typeof t=="object"?t.button!==l.button?!1:t.modifiers.every(s=>{switch(s){case"alt":return l.altKey;case"ctrl":return l.ctrlKey||l.metaKey;case"shift":return l.shiftKey}}):!1),{abs:b,max:R,min:D,ceil:P}=Math,O=(l=[])=>({stored:l,selected:[],touched:[],changed:{added:[],removed:[]}}),M=class M extends A{constructor(e){var o,n,r,a,u;super(),this._selection=O(),this._targetBoundaryScrolled=!0,this._selectables=[],this._areaLocation={y1:0,x2:0,y2:0,x1:0},this._areaRect=k(),this._singleClick=!0,this._scrollAvailable=!0,this._scrollingActive=!1,this._scrollSpeed={x:0,y:0},this._scrollDelta={x:0,y:0},this._lastMousePosition={x:0,y:0},this.enable=this._toggleStartEvents,this.disable=this._toggleStartEvents.bind(this,!1),this._options={selectionAreaClass:"selection-area",selectionContainerClass:void 0,selectables:[],document:window.document,startAreas:["html"],boundaries:["html"],container:"body",...e,behaviour:{overlap:"invert",intersect:"touch",triggers:[0],...e.behaviour,startThreshold:(o=e.behaviour)!=null&&o.startThreshold?typeof e.behaviour.startThreshold=="number"?e.behaviour.startThreshold:{x:10,y:10,...e.behaviour.startThreshold}:{x:10,y:10},scrolling:{speedDivider:10,manualSpeed:750,...(n=e.behaviour)==null?void 0:n.scrolling,startScrollMargins:{x:0,y:0,...(a=(r=e.behaviour)==null?void 0:r.scrolling)==null?void 0:a.startScrollMargins}}},features:{range:!0,touch:!0,deselectOnBlur:!1,...e.features,singleTap:{allow:!0,intersect:"native",...(u=e.features)==null?void 0:u.singleTap}}};for(const _ of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))typeof this[_]=="function"&&(this[_]=this[_].bind(this));const{document:t,selectionAreaClass:s,selectionContainerClass:i}=this._options;this._area=t.createElement("div"),this._clippingElement=t.createElement("div"),this._clippingElement.appendChild(this._area),this._area.classList.add(s),i&&this._clippingElement.classList.add(i),v(this._area,{willChange:"top, left, bottom, right, width, height",top:0,left:0,position:"fixed"}),v(this._clippingElement,{overflow:"hidden",position:"fixed",transform:"translate3d(0, 0, 0)",pointerEvents:"none",zIndex:"1"}),this._frame=K(_=>{this._recalculateSelectionAreaRect(),this._updateElementSelection(),this._emitEvent("move",_),this._redrawSelectionArea()}),this.enable()}_toggleStartEvents(e=!0){const{document:t,features:s}=this._options,i=e?y:m;i(t,"mousedown",this._onTapStart),s.touch&&i(t,"touchstart",this._onTapStart,{passive:!1})}_onTapStart(e,t=!1){const{x:s,y:i,target:o}=T(e),{document:n,startAreas:r,boundaries:a,features:u,behaviour:_}=this._options,c=o.getBoundingClientRect();if(e instanceof MouseEvent&&!H(e,_.triggers))return;const p=x(r,n),g=x(a,n);this._targetElement=g.find(S=>C(S.getBoundingClientRect(),c));const f=e.composedPath(),d=p.find(S=>f.includes(S));if(this._targetBoundary=g.find(S=>f.includes(S)),!this._targetElement||!d||!this._targetBounLine truncated
|
||||
//# sourceMappingURL=viselect.umd.js.map
|
||||
Reference in new issue
Block a user