@wikimedia/codex
Version:
Codex Design System for Wikimedia
2 lines (1 loc) • 2.62 kB
JavaScript
;var $=Object.defineProperty,j=Object.defineProperties;var B=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var b=(n,l,t)=>l in n?$(n,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[l]=t,p=(n,l)=>{for(var t in l||(l={}))I.call(l,t)&&b(n,t,l[t]);if(_)for(var t of _(l))U.call(l,t)&&b(n,t,l[t]);return n},C=(n,l)=>j(n,B(l));const f=require("./floating-ui.dom.js"),e=require("vue");function k(n){return n!=null&&typeof n=="object"&&"$el"in n}function y(n){if(k(n)){const l=n.$el;return f.isNode(l)&&f.getNodeName(l)==="#comment"?null:l}return n}function z(n){return{name:"arrow",options:n,fn(l){const t=y(e.unref(n.element));return t==null?{}:f.arrow({element:t,padding:n.padding}).fn(l)}}}function S(n){return typeof window=="undefined"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function M(n,l){const t=S(n);return Math.round(l*t)/t}function A(n,l,t){t===void 0&&(t={});const h=t.whileElementsMounted,g=e.computed(()=>{var u;return(u=e.unref(t.open))!=null?u:!0}),R=e.computed(()=>e.unref(t.middleware)),s=e.computed(()=>{var u;return(u=e.unref(t.placement))!=null?u:"bottom"}),d=e.computed(()=>{var u;return(u=e.unref(t.strategy))!=null?u:"absolute"}),N=e.computed(()=>{var u;return(u=e.unref(t.transform))!=null?u:!0}),r=e.computed(()=>y(n.value)),a=e.computed(()=>y(l.value)),m=e.ref(0),v=e.ref(0),o=e.ref(d.value),x=e.ref(s.value),D=e.shallowRef({}),w=e.ref(!1),V=e.computed(()=>{const u={position:o.value,left:"0",top:"0"};if(!a.value)return u;const E=M(a.value,m.value),O=M(a.value,v.value);return N.value?p(C(p({},u),{transform:"translate("+E+"px, "+O+"px)"}),S(a.value)>=1.5&&{willChange:"transform"}):{position:o.value,left:E+"px",top:O+"px"}});let c;function i(){r.value==null||a.value==null||f.computePosition(r.value,a.value,{middleware:R.value,placement:s.value,strategy:d.value}).then(u=>{m.value=u.x,v.value=u.y,o.value=u.strategy,x.value=u.placement,D.value=u.middlewareData,w.value=!0})}function P(){typeof c=="function"&&(c(),c=void 0)}function q(){if(P(),h===void 0){i();return}if(r.value!=null&&a.value!=null){c=h(r.value,a.value,i);return}}function F(){g.value||(w.value=!1)}return e.watch([R,s,d],i,{flush:"sync"}),e.watch([r,a],q,{flush:"sync"}),e.watch(g,F,{flush:"sync"}),e.getCurrentScope()&&e.onScopeDispose(P),{x:e.shallowReadonly(m),y:e.shallowReadonly(v),strategy:e.shallowReadonly(o),placement:e.shallowReadonly(x),middlewareData:e.shallowReadonly(D),isPositioned:e.shallowReadonly(w),floatingStyles:V,update:i}}exports.arrow=z;exports.useFloating=A;