@aevantec/litevue 0.6.0 → 0.6.2
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/LICENSE +2 -1
- package/dist/litevue-devtools.iife.js +1 -1
- package/dist/litevue-devtools.mjs +1 -1
- package/dist/litevue-devtools.umd.js +1 -1
- package/dist/litevue-plugins.dev.iife.js +120 -81
- package/dist/litevue-plugins.dev.mjs +120 -80
- package/dist/litevue-plugins.iife.js +1 -1
- package/dist/litevue-plugins.mjs +1 -1
- package/dist/litevue-plugins.umd.js +1 -1
- package/dist/litevue.dev.iife.js +132 -48
- package/dist/litevue.dev.mjs +132 -47
- package/dist/litevue.iife.js +1 -1
- package/dist/litevue.mjs +1 -1
- package/dist/litevue.umd.js +1 -1
- package/dist/plugins/collapse.iife.js +1 -1
- package/dist/plugins/collapse.mjs +1 -1
- package/dist/plugins/collapse.umd.js +1 -1
- package/dist/plugins/focus.iife.js +1 -1
- package/dist/plugins/focus.mjs +1 -1
- package/dist/plugins/focus.umd.js +1 -1
- package/dist/plugins/intersect.iife.js +1 -1
- package/dist/plugins/intersect.umd.js +1 -1
- package/dist/plugins/mask.iife.js +1 -1
- package/dist/plugins/mask.mjs +1 -1
- package/dist/plugins/mask.umd.js +1 -1
- package/dist/plugins/media.dev.iife.js +3 -4
- package/dist/plugins/media.dev.mjs +3 -3
- package/dist/plugins/media.iife.js +1 -1
- package/dist/plugins/media.mjs +1 -1
- package/dist/plugins/media.umd.js +1 -1
- package/dist/plugins/morph.dev.iife.js +58 -19
- package/dist/plugins/morph.dev.mjs +58 -18
- package/dist/plugins/morph.iife.js +1 -1
- package/dist/plugins/morph.mjs +1 -1
- package/dist/plugins/morph.umd.js +1 -1
- package/dist/plugins/navigate.dev.iife.js +49 -36
- package/dist/plugins/navigate.dev.mjs +49 -35
- package/dist/plugins/navigate.iife.js +1 -1
- package/dist/plugins/navigate.mjs +1 -1
- package/dist/plugins/navigate.umd.js +1 -1
- package/dist/plugins/persist.dev.iife.js +8 -11
- package/dist/plugins/persist.dev.mjs +8 -10
- package/dist/plugins/persist.iife.js +1 -1
- package/dist/plugins/persist.mjs +1 -1
- package/dist/plugins/persist.umd.js +1 -1
- package/dist/plugins/popover.iife.js +1 -1
- package/dist/plugins/popover.mjs +1 -1
- package/dist/plugins/popover.umd.js +1 -1
- package/dist/plugins/resize.iife.js +1 -1
- package/dist/plugins/resize.umd.js +1 -1
- package/dist/plugins/transition.iife.js +1 -1
- package/dist/plugins/transition.mjs +1 -1
- package/dist/plugins/transition.umd.js +1 -1
- package/dist/types/app.d.mts +3 -1
- package/dist/types/app.d.ts +3 -1
- package/dist/types/context.d.mts +1 -1
- package/dist/types/context.d.ts +1 -1
- package/dist/types/devtools-panel/chrome.d.mts +6 -5
- package/dist/types/devtools-panel/chrome.d.ts +6 -5
- package/dist/types/devtools-panel/menu.d.mts +12 -0
- package/dist/types/devtools-panel/menu.d.ts +12 -0
- package/dist/types/devtools-panel/styles.d.mts +5 -2
- package/dist/types/devtools-panel/styles.d.ts +5 -2
- package/dist/types/devtools-panel/values.d.mts +17 -5
- package/dist/types/devtools-panel/values.d.ts +17 -5
- package/dist/types/directives/show.d.mts +1 -0
- package/dist/types/directives/show.d.ts +1 -0
- package/dist/types/errors.d.mts +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/plugins/focus/index.d.mts +1 -1
- package/dist/types/plugins/focus/index.d.ts +1 -1
- package/dist/types/plugins/morph/index.d.mts +6 -0
- package/dist/types/plugins/morph/index.d.ts +6 -0
- package/dist/types/store.d.mts +5 -1
- package/dist/types/store.d.ts +5 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@aevantec/litevue")):"function"==typeof define&&define.amd?define(["exports","@aevantec/litevue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVuePlugins={},e.LiteVue)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var n={9:/\d/,a:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},i=(e,t)=>{let i="",r="",o=0;for(let s=0;s<t.length;s++){const a=n[t[s]];if(a){for(;o<e.length&&!a.test(e[o]);)o++;if(o>=e.length)break;i+=r+e[o++],r=""}else r+=t[s],e[o]===t[s]&&o++}return i},r=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),o=(e,t)=>{const n=e.split(","),i=t.split(",");let o=0;for(let s=0;s<n.length;s++)o=Math.max(o,r(n[s])+r(i[s%i.length]));return o},s="litevue:",a=Object.create(null),l="local",c=e=>{const t=e??l;return"string"!=typeof t?t:a[t]??(e=>{try{if("local"===e||"localStorage"===e)return localStorage;if("session"===e||"sessionStorage"===e)return sessionStorage}catch{}})(t)},d=(e,t,n,i,r)=>{if(!i)return r(()=>{});const o=((e,t)=>(t??Object.keys(e)).filter(t=>{if("$"===t[0])return!1;const n=Object.getOwnPropertyDescriptor(e,t);if(n&&n.get&&!n.set)return!1;const i=n&&n.value;return(!i||!0!==i.__v_isRef||!0!==i.__v_isReadonly)&&"function"!=typeof e[t]}))(e,n);try{const n=JSON.parse(i.getItem(t)||"null");if(n)for(const t of o)t in n&&(e[t]=n[t])}catch{}return r(()=>{const n={};for(const t of o)n[t]=e[t];try{i.setItem(t,JSON.stringify(n))}catch{}})},f=[],u=(e,t,n)=>"radio"!==e.type||!e.name||e===(n.find(t=>"radio"===t.type&&t.name===e.name&&t.checked)||n.find(t=>"radio"===t.type&&t.name===e.name)),m=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||!!t.preserve?.(e)),p=/^(?:v-|:|@)/,h=/^(?::|v-bind:)/,v=/^v-(?!scope|on:)/,b=["id","data-key","data-id"],g=e=>{for(const t of b){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},y=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},k=e=>e.__ctx||[...e.children||[]].map(k).find(Boolean),w=(e,t)=>(t||k(e))?.dispose?.(e),x=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),E=(e,t)=>{const n=(e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)h.test(n)?t.add(n.replace(h,"").split(".")[0]):"v-model"===n?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):v.test(n)&&t.add("style");return t})(t),i=Object(e.__bound);for(const{name:r,value:o}of t.attributes)p.test(r)||n.has(r)||r in i||e.getAttribute(r)!==o&&e.setAttribute(r,o);for(const{name:r}of[...e.attributes])n.has("*")||n.has(r)||t.hasAttribute(r)||e.removeAttribute(r)},S=(e,t,n,i)=>{if(e.nodeType!==t.nodeType)return O(e,t,n,i);if(3===e.nodeType||8===e.nodeType){const i=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(i,n))return;return void(e.data!==i&&(e.data=i))}if(1!==e.nodeType)return;const r=e,o=t;if(r.tagName!==o.tagName)return O(e,t,n,i);i.skip?.(r,o)||r.hasAttribute("data-morph-skip")||(E(r,o),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||x(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(x(t))return!0;return!1})(o)||L(r,o,r.__ctx||n,i))},O=(e,t,n,i)=>{if(m(e,i))return;const r=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(r)&&(w(e,n),e.parentNode.replaceChild(r,e),i.afterNodeRemoved?.(e),A(r,n))},A=(e,t)=>{const n=t||y(e.parentNode);n?.walk?.(e,n)},L=(e,t,n,i)=>{const r=i.key||g,o=new Map;for(let d=e.firstChild;d;d=d.nextSibling)if(1===d.nodeType){const e=r(d);if(null==e)continue;o.set(e,d)}const s=e=>e&&1===e.nodeType?r(e):null;let a=e.firstChild,l=t.firstChild;const c=t=>{const r=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(r)&&(e.insertBefore(r,a),A(r,n))};for(;l;){const t=l.nextSibling,r=s(l);if(null!=r){const t=o.get(r);t?(t===a?a=a.nextSibling:e.insertBefore(t,a),o.delete(r),S(t,l,n,i)):c(l)}else if(a&&null==s(a)){if(m(a,i)&&!m(l,i)){a=a.nextSibling;continue}const e=a.nextSibling;S(a,l,n,i),a=e}else c(l);l=t}for(;a;){const t=a.nextSibling;m(a,i)||(w(a,n),e.removeChild(a),i.afterNodeRemoved?.(a)),a=t}},T=(e,t,n={})=>{let i;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const r=n.content;i=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(r),t})()}else i=t;if(i){const t=()=>{const t=_();S(e,i,y(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},_=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,i=null;try{n=t.selectionStart,i=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,i)}catch{}}},$={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},j=Object.freeze({...$}),N={mobile:"base",tablet:"md",desktop:"lg"},P=/^\d+$/,q=(0,t.reactive)({bp:"base",tick:0}),C={...$},D=["base"],M=!1,z=[],R=new Map,B=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia,I=(e,t)=>e.addEventListener?(e.addEventListener("change",t),{mql:e,off:()=>e.removeEventListener("change",t)}):(e.addListener(t),{mql:e,off:()=>e.removeListener(t)}),V=()=>{for(let e=z.length-1;e>=0;e--)if(z[e].mql.matches)return D[e+1];return"base"},H=()=>{z.forEach(e=>e.off()),z=[];const e=Object.keys(C).filter(e=>C[e]>0).sort((e,t)=>C[e]-C[t]);D=["base",...e],B()&&(z=e.map(e=>{const t=window.matchMedia(`(min-width: ${C[e]}px)`);return I(t,()=>{q.bp=V()})}),q.bp=V())},J=()=>{M||(M=!0,H()),q.tick},K=e=>{if(!B())return!1;let t=R.get(e);t?R.delete(e):t=I(window.matchMedia(e),()=>q.tick++),R.set(e,t);for(const[n,i]of R){if(R.size<=64)break;i.off(),R.delete(n)}return t.mql.matches},W=e=>{if("number"==typeof e)return e;if("base"===e)return 0;if(P.test(e))return Number(e);const t=void 0===C[e]?N[e]:void 0;return void 0!==t?"base"===t?0:C[t]:C[e]},Z=e=>{if(e<=0)return!0;const t=D.findIndex(t=>"base"!==t&&C[t]===e);return-1!==t?D.indexOf(q.bp)>=t:(q.tick,K(`(min-width: ${e}px)`))},F=new Set,G=(e,t)=>{if(J(),!e||"object"!=typeof e)return t;let n,i=-1;for(const r of Object.keys(e)){const t=W(r);void 0!==t?t>=i&&Z(t)&&(i=t,n=e[r]):(D.join(", "),Object.keys(N).join(", "))}return void 0!==n?n:t},Q=e=>{const t=N[e],n=C[t];return void 0!==n?n:$[t]},U=Object.defineProperties((e,t)=>G(e,t),{props:{value:e=>{J();const t={};for(const n of Object.keys(e))t[n]=G(e[n]);return t}},breakpoint:{get:()=>(J(),q.bp),enumerable:!0},device:{get:()=>(J(),Z(Q("tablet"))?Z(Q("desktop"))?"desktop":"tablet":"mobile"),enumerable:!0},atLeast:{value:e=>{J();const t=W(e);return void 0!==t&&Z(t)}},match:{value:e=>(J(),K(e))},configure:{value:({breakpoints:e})=>{e&&(C={...e},M&&(H(),q.tick++))}}}),X=()=>{z.forEach(e=>e.off()),R.forEach(e=>e.off()),z=[],R.clear(),M=!1};e.collapse=e=>{e.directive("collapse",({el:e,get:t,effect:n,modifiers:i})=>{const r=e;let o=250;for(const m in i||{}){const e=/^duration-(\d+)$/.exec(m);e&&(o=+e[1])}const s=["overflow","height","transition","visibility"],a=s.map(e=>r.style[e]),l=e=>r.style.visibility=e?"hidden":a[3];r.style.overflow="hidden";let c=!0,d=0;const f=new Set,u=(e,t)=>{const n=setTimeout(()=>{f.delete(n),e()},t);f.add(n)};return n(()=>{const e=!!t(),n=++d;if(c)return c=!1,e||(r.style.height="0px"),l(!e),void u(()=>{r.style.transition=`height ${o}ms ease, visibility ${o}ms`});l(!e),e?(r.style.height=r.scrollHeight+"px",u(()=>{n===d&&(r.style.height="")},o)):(r.style.height=r.scrollHeight+"px",r.offsetHeight,r.style.height="0px")}),()=>{f.forEach(clearTimeout),s.forEach((e,t)=>r.style[e]=a[t])}})},e.defaultBreakpoints=j,e.focus=e=>{e.directive("focus",({el:e,get:t,effect:n,modifiers:i})=>{let r=!0;return n(()=>{const n=!!t();Promise.resolve().then(()=>{r&&n&&(e.focus(),i?.select&&e.select&&e.select())})}),()=>{r=!1}}),e.directive("trap",({el:e,get:t,effect:n})=>{let i=!1,r=null;const o=()=>[...e.querySelectorAll("a[href],area[href],button,input:not([type=hidden]),select,textarea,summary,iframe,audio[controls],video[controls],[contenteditable],[tabindex]")].filter(e=>e.tabIndex>=0&&!e.matches(":disabled,[inert] *")&&!1!==e.checkVisibility?.({visibilityProperty:!0})).filter(u),s=t=>{if("Tab"!==t.key||f.at(-1)!==s)return;const n=o();if(!n.length)return void t.preventDefault();const i=n[0],r=n[n.length-1],a=document.activeElement;e.contains(a)?!t.shiftKey||a!==i&&a!==e?t.shiftKey||a!==r||(t.preventDefault(),i.focus()):(t.preventDefault(),r.focus()):(t.preventDefault(),i.focus())},a=()=>{i=!1,f.splice(f.indexOf(s),1),document.removeEventListener("keydown",s,!0),r&&r.focus&&r.focus()};return n(()=>{const n=!!t();n&&!i?(i=!0,r=document.activeElement,f.push(s),document.addEventListener("keydown",s,!0),Promise.resolve().then(()=>{i&&(o()[0]||e).focus()})):!n&&i&&a()}),()=>{i&&a()}})},e.intersect=e=>{e.directive("intersect",({el:e,get:t,modifiers:n})=>{let i=!1;const r=new IntersectionObserver(e=>{for(const o of e){const e=n?.full?o.intersectionRatio>=1:o.isIntersecting,s=n?.leave?i&&!e:e&&!i;i=e,s&&(t(),n?.once&&r.disconnect())}},{threshold:n?.full?1:0});return r.observe(e),()=>r.disconnect()})},e.mask=e=>{e.directive("mask",({el:e,exp:t})=>{const r=e,o=()=>{const{value:e,selectionStart:o}=r,s=i(e,t);if(s===e)return!1;if(r.value=s,null!=o&&document.activeElement===r){let a=i(e.slice(0,o),t).length;for(;a<s.length&&!n[t[a]];)a++;r.setSelectionRange(a,a)}return!0};e.addEventListener("input",o),o();let s=!0;return Promise.resolve().then(()=>{s&&o()&&e.dispatchEvent(new Event("input"))}),()=>{s=!1,e.removeEventListener("input",o)}})},e.media=(e,t)=>(t?.breakpoints&&JSON.stringify(t.breakpoints),t&&U.configure(t),e.scope.$mq=U,e.scope.$mqProps=U.props,e.scope.$mqAtLeast=U.atLeast,e.scope.$mqMatch=U.match,Object.defineProperty(e.scope,"$mqBreakpoint",{get:()=>U.breakpoint,enumerable:!0,configurable:!0}),Object.defineProperty(e.scope,"$mqDevice",{get:()=>U.device,enumerable:!0,configurable:!0}),()=>{X(),q.tick++}),e.morph=T,e.morphPlugin=e=>{e.scope.$morph=T},e.mq=U,e.persist=e=>{e.directive("persist",({ctx:e,el:t,exp:n,arg:i,modifiers:r,effect:o})=>{const a=s+(n||t.id);let l;for(const s in r||{})if(c(s)){l=s;break}const f=i?i.split(",").map(e=>e.trim()).filter(Boolean):void 0;d(e.scope,a,f,c(l),o)})},e.persistStore=(e,n={})=>{const i=(0,t.store)(e);if(!i)return()=>{};const r=c(n.storage);return d(i,s+(n.key??e),n.keys,r,t.watchEffect)},e.registerStorage=(e,t)=>{a[e]=t},e.resetMedia=()=>{X(),C={...$},D=["base",...Object.keys(C).sort((e,t)=>C[e]-C[t])],M=!1,F.clear(),q.bp="base",q.tick=0},e.resize=e=>{e.directive("resize",({el:e,get:t,exp:n,modifiers:i})=>{const r=t(`(($width, $height) => { ${n} })`);if(i?.window||i?.visual){const e=i.visual&&window.visualViewport||window,t=()=>r(e.width||innerWidth,e.height||innerHeight);return e.addEventListener("resize",t),t(),()=>e.removeEventListener("resize",t)}const o=new ResizeObserver(e=>{for(const t of e){const e=t.contentRect;r(e.width,e.height)}});return o.observe(e),()=>o.disconnect()})},e.setDefaultStorage=e=>{l=e},e.transition=e=>{e.directive("transition",({el:e,get:t,effect:n,arg:i,modifiers:r,exp:s})=>{const a=e,l=i||"v",c=e=>`${l}-${e}`;let d,f=0,u=!0;const m=()=>{a.classList.remove(c("enter-from"),c("enter-active"),c("enter-to"),c("leave-from"),c("leave-active"),c("leave-to"))},p=(e,t)=>{const n=++f;m(),a.classList.add(c(e+"-from"),c(e+"-active")),a.offsetWidth,a.classList.remove(c(e+"-from")),a.classList.add(c(e+"-to")),clearTimeout(d),d=setTimeout(()=>{n===f&&(m(),t&&t())},(e=>{const t=getComputedStyle(e);return Math.max(o(t.transitionDuration,t.transitionDelay),o(t.animationDuration,t.animationDelay))})(a))};if(!s){let e=!0;return Promise.resolve().then(()=>{e&&p("enter")}),a.__leave=()=>new Promise(e=>p("leave",e)),()=>{e=!1,clearTimeout(d),m(),delete a.__leave}}const h="none"==a.style.display?"":a.style.display;return n(()=>{const e=!!t();if(u)return u=!1,a.style.display=e?h:"none",void(e&&r?.appear&&p("enter"));e?(a.style.display=h,p("enter")):p("leave",()=>{a.style.display="none"})}),()=>{clearTimeout(d),m()}})}});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@aevantec/litevue")):"function"==typeof define&&define.amd?define(["exports","@aevantec/litevue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVuePlugins={},e.LiteVue)}(this,function(e,t){var n={9:/\d/,a:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},i=(e,t,i)=>{let o="",r="",s=0;for(let a=0;a<t.length;a++){const i=n[t[a]];if(i){for(;s<e.length&&!i.test(e[s]);)s++;if(s>=e.length)return o;o+=r+e[s++],r=""}else r+=t[a],e[s]===t[a]&&s++}return i?o+r:o},o=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),r=(e,t)=>{const n=e.split(","),i=t.split(",");let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,o(n[s])+o(i[s%i.length]));return r},s="litevue:",a=Object.create(null),c="local",l=e=>{const t=e??c;return"string"!=typeof t?t:a[t.toLowerCase()]??(e=>{try{if("local"===e||"localStorage"===e)return localStorage;if("session"===e||"sessionStorage"===e)return sessionStorage}catch{}})(t)},d=(e,t,n,i,o)=>{if(!i)return o(()=>{});const r=((e,t)=>(t??Object.keys(e)).filter(t=>{if("$"===t[0])return!1;const n=Object.getOwnPropertyDescriptor(e,t);if(n&&n.get&&!n.set)return!1;const i=n&&n.value;return(!i||!0!==i.__v_isRef||!0!==i.__v_isReadonly)&&"function"!=typeof e[t]}))(e,n);try{const n=JSON.parse(i.getItem(t)||"null");if(n)for(const t of r)({}).hasOwnProperty.call(n,t)&&(e[t]=n[t])}catch{}return o(()=>{const n={};for(const t of r)n[t]=e[t];try{i.setItem(t,JSON.stringify(n))}catch{}})},f=[],u=(e,t,n)=>"radio"!==e.type||!e.name||e===(n.find(t=>"radio"===t.type&&t.name===e.name&&t.checked)||n.find(t=>"radio"===t.type&&t.name===e.name)),p=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||e.__marker||!!t.preserve?.(e)),m="[v-scope\\.visible],[v-scope\\.idle],[v-scope\\.interaction]",v=/^(?:v-|:|@)/,h=/^(?::|v-bind:)/,b=/^v-(?!scope|on:)/,g=["id","data-key","data-id"],y=e=>{for(const t of g){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},w=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},x=e=>e.__ctx||[...e.children||[]].map(x).find(Boolean),k=(e,t)=>(t||x(e))?.dispose?.(e),E=e=>{const t=new Set;e.matches("details,dialog")&&t.add("open");for(const{name:n}of e.attributes)if(h.test(n)){const e=n.replace(h,"").split(".")[0];t.add(/\.camel\b/.test(n)?e.replace(/-(\w)/g,(e,t)=>t.toUpperCase()):e)}else/^v-model\b/.test(n)?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):b.test(n)&&(t.add("style"),"v-popover"==n&&t.add("popover"));return t},S=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),_=["Value","Checked","Selected"],L=(e,t,n)=>{const i=E(t);e.__anchor&&i.add("style"),n&&((e,t,n)=>{const i=E(t.closest("select")||t);if(!(n.has("*")||i.has("*")||i.has("value")||"output"==e.type||"textarea"==e.type&&t.value.includes("{{")))for(const o of _){const i=o.toLowerCase(),r="default"+o,s="Selected"==o?r:i;!n.has(i)&&r in e&&e[i]!==t[s]&&(e[i]=t[s])}})(e,t,i);const o=Object(e.__bound);for(const{name:r,value:s}of t.attributes)v.test(r)||i.has(r)||r in o||e.getAttribute(r)!==s&&e.setAttribute(r,s);for(const{name:r}of[...e.attributes])i.has("*")||i.has(r)||t.hasAttribute(r)||e.removeAttribute(r)},T=(e,t,n,i)=>{if(e.nodeType!==t.nodeType)return A(e,t,n,i);if(3===e.nodeType||8===e.nodeType){const o=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(o,n)&&"SCRIPT"!=e.parentNode?.nodeName)return;return e.data?void(e.data!==o&&(e.data=o)):A(e,t,n,i)}if(1!==e.nodeType)return;const o=e,r=t;if(o.tagName!==r.tagName)return A(e,t,n,i);if(!i.skip?.(o,r)&&!o.hasAttribute("data-morph-skip")){if(o.matches(m))return o.isEqualNode(r)?void 0:A(e,t,n,i);L(o,r,i.values),"TEMPLATE"!=o.tagName||o.content.isEqualNode(r.content)||(o.innerHTML=r.innerHTML),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||S(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(S(t))return!0;return!1})(r)||Object.getOwnPropertyDescriptor(Object(o.__ctx?.scope),"$template")||N(o,r,o.__ctx||n,i)}},A=(e,t,n,i)=>{if(p(e,i))return;const o=t.cloneNode(!0);return!1!==i.beforeNodeAdded?.(o)?(k(e,n),e.parentNode.replaceChild(o,e),i.afterNodeRemoved?.(e),O(o,n),o):void 0},O=(e,t)=>{if(e.parentElement?.closest(m))return;const n=t||w(e.parentNode);n?.walk?.(e,n)},N=(e,t,n,i)=>{const o=i.key||y,r=new Map;for(let u=e.firstChild;u;u=u.nextSibling)if(1===u.nodeType){const e=o(u);if(null==e)continue;r.set(e,u)}const s=e=>e&&1===e.nodeType?o(e):null,a=new Set;for(let u=t.firstChild;u;u=u.nextSibling)a.add(s(u));const c=t=>{p(t,i)||(k(t,n),e.removeChild(t),i.afterNodeRemoved?.(t))};let l=e.firstChild,d=t.firstChild;const f=t=>{const o=t.cloneNode(!0);!1!==i.beforeNodeAdded?.(o)&&(e.insertBefore(o,l),O(o,n))};for(;d;){const t=d.nextSibling,o=s(d);if(""===l?.data&&d.hasAttribute?.("v-teleport"))l=l.nextSibling;else if(null!=o){const t=r.get(o);t?(t===l?l=l.nextSibling:e.insertBefore(t,l),r.delete(o),T(t,d,n,i)):f(d)}else if(l&&null==s(l)){if(p(l,i)&&!p(d,i)){l=l.nextSibling;continue}const e=l.nextSibling;T(l,d,n,i),l=e}else{if(l&&!a.has(s(l))){const e=l.nextSibling;c(l),l=e;continue}f(d)}d=t}for(;l;){const e=l.nextSibling;c(l),l=e}},$=(e,t,n={})=>{let i;if("string"==typeof t){const n=document.createElement("template"),o=e instanceof SVGElement;n.innerHTML=o?`<svg>${t.trim()}</svg>`:t.trim();const r=o?n.content.firstChild:n.content;i=1===r.childNodes.length&&r.firstElementChild?r.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.append(...r.childNodes),t})()}else i=t;if(i){const t=()=>{const t=C();e=T(e,i,w(e.parentNode),n)||e,t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},C=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,i=null;try{n=t.selectionStart,i=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,i)}catch{}}},P={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},j=Object.freeze({...P}),q={mobile:"base",tablet:"md",desktop:"lg"},M=/^\d+$/,D=(0,t.reactive)({bp:"base",tick:0}),R={...P},z=["base"],I=!1,V=[],B=new Map,H=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia,W=(e,t)=>e.addEventListener?(e.addEventListener("change",t),{mql:e,off:()=>e.removeEventListener("change",t)}):(e.addListener(t),{mql:e,off:()=>e.removeListener(t)}),K=()=>{for(let e=V.length-1;e>=0;e--)if(V[e].mql.matches)return z[e+1];return"base"},J=()=>{V.forEach(e=>e.off()),V=[];const e=Object.keys(R).filter(e=>R[e]>0).sort((e,t)=>R[e]-R[t]);z=["base",...e],H()&&(V=e.map(e=>{const t=window.matchMedia(`(min-width: ${R[e]}px)`);return W(t,()=>{D.bp=K()})}),D.bp=K())},Z=()=>{I||(I=!0,J()),D.tick},F=e=>{if(!H())return!1;let t=B.get(e);t?B.delete(e):t=W(window.matchMedia(e),()=>D.tick++),B.set(e,t);for(const[n,i]of B){if(B.size<=64)break;i.off(),B.delete(n)}return t.mql.matches},G=e=>{if("number"==typeof e)return e;if("base"===e)return 0;if(M.test(e))return Number(e);const t=void 0===R[e]?q[e]:void 0;return void 0!==t?"base"===t?0:R[t]:R[e]},U=e=>{if(e<=0)return!0;const t=z.findIndex(t=>"base"!==t&&R[t]===e);return-1!==t?z.indexOf(D.bp)>=t:(D.tick,F(`(min-width: ${e}px)`))},Q=(e,t)=>{if(Z(),!e||"object"!=typeof e)return t;let n,i=-1;for(const o of Object.keys(e)){const t=G(o);void 0!==t&&(t>=i&&U(t)&&(i=t,n=e[o]))}return void 0!==n?n:t},X=e=>{const t=q[e],n=R[t];return void 0!==n?n:P[t]},Y=(e,t)=>Q(e,t),ee=Object.defineProperties(Y,{props:{value:e=>{Z();const t={};for(const n of Object.keys(e))t[n]=Q(e[n]);return t}},breakpoint:{get:()=>(Z(),D.bp),enumerable:!0},device:{get:()=>(Z(),U(X("tablet"))?U(X("desktop"))?"desktop":"tablet":"mobile"),enumerable:!0},atLeast:{value:e=>{Z();const t=G(e);return void 0!==t&&U(t)}},match:{value:e=>(Z(),F(e))},configure:{value:({breakpoints:e})=>{e&&(R={...e},I&&(J(),D.tick++))}}}),te=()=>{V.forEach(e=>e.off()),B.forEach(e=>e.off()),V=[],B.clear(),I=!1};e.collapse=e=>{e.directive("collapse",({el:e,get:t,effect:n,modifiers:i})=>{const o=e;let r=250;for(const u in i||{}){const e=/^duration-(\d+)$/.exec(u);e&&(r=+e[1])}const s=["overflow","height","transition","visibility"],a=s.map(e=>o.style[e]);let c,l=0;const d=new Set,f=(e,t)=>{const n=setTimeout(()=>{d.delete(n),e()},t);d.add(n)};return n(()=>{const e=!!t();if(e===c)return;const n=++l;var i;i=!e,o.style.visibility=i?"hidden":a[3],o.style.overflow=e&&null==c?a[0]:"hidden",null==c?f(()=>{o.style.transition=`height ${r}ms ease, visibility ${r}ms`}):(o.style.height=a[1]||o.scrollHeight+"px",e?f(()=>{n===l&&(o.style.height=a[1],o.style.overflow=a[0])},r):o.offsetHeight),e||(o.style.height="0px"),c=e}),()=>{d.forEach(clearTimeout),s.forEach((e,t)=>o.style[e]=a[t])}})},e.defaultBreakpoints=j,e.focus=e=>{e.directive("focus",({el:e,get:t,effect:n,modifiers:i})=>{let o=!0,r=!1;return n(()=>{r!==(r=!!t())&&Promise.resolve().then(()=>{o&&r&&(e.focus(),i?.select&&e.select&&e.select())})}),()=>{o=!1}}),e.directive("trap",({el:e,get:t,effect:n})=>{let i=!1,o=null;const r=()=>[...e.querySelectorAll("a[href],area[href],button,input:not([type=hidden]),select,textarea,summary,iframe,audio[controls],video[controls],[contenteditable],[tabindex]")].filter(e=>e.tabIndex>=0&&!e.matches(":disabled,[inert],[inert] *")&&!1!==e.checkVisibility?.({visibilityProperty:!0})).filter(u),s=t=>{if("Tab"!==t.key||f.at(-1)!==e)return;const n=r();if(!n.length)return void t.preventDefault();const i=n[0],o=n[n.length-1],s=document.activeElement;e.contains(s)?(t.shiftKey?i:o).compareDocumentPosition(s)&(t.shiftKey?4:2)||(t.preventDefault(),(t.shiftKey?o:i).focus()):(t.preventDefault(),i.focus())},a=()=>{i=!1,f.splice(f.indexOf(e),1),document.removeEventListener("keydown",s,!0),o&&o.focus&&o.focus()};return n(()=>{const n=!!t();n&&!i?(i=!0,o=document.activeElement,f.splice(f.findIndex(t=>e.contains(t))>>>0,0,e),document.addEventListener("keydown",s,!0),Promise.resolve().then(()=>{i&&f.at(-1)===e&&(r()[0]||e).focus()})):!n&&i&&a()}),()=>{i&&a()}})},e.intersect=e=>{e.directive("intersect",({el:e,get:t,modifiers:n})=>{let i=!1;const o=new IntersectionObserver(e=>{for(const r of e){const e=n?.full?r.intersectionRatio>=1:r.isIntersecting,s=n?.leave?i&&!e:e&&!i;i=e,s&&(t(),n?.once&&o.disconnect())}},{threshold:n?.full?1:0});return o.observe(e),()=>o.disconnect()})},e.mask=e=>{e.directive("mask",({el:e,exp:t})=>{const o=e,r=e=>{const{value:r,selectionStart:s}=o,a=e?.inputType,c=i(r,t,!a?.startsWith("del"));if(c===r)return!1;if(o.value=c,null!=s&&document.activeElement===o){let e=i(r.slice(0,s),t).length;if(!e||!a?.endsWith("Backward"))for(;e<c.length&&!n[t[e]];)e++;o.setSelectionRange(e,e)}return!0};e.addEventListener("input",r);const s=r();let a=!0;return Promise.resolve().then(()=>{a&&(r()||s)&&(e.dispatchEvent(new Event("input")),e.dispatchEvent(new Event("change")))}),()=>{a=!1,e.removeEventListener("input",r)}})},e.media=(e,t)=>(t&&ee.configure(t),e.scope.$mq=ee,e.scope.$mqProps=ee.props,e.scope.$mqAtLeast=ee.atLeast,e.scope.$mqMatch=ee.match,Object.defineProperty(e.scope,"$mqBreakpoint",{get:()=>ee.breakpoint,enumerable:!0,configurable:!0}),Object.defineProperty(e.scope,"$mqDevice",{get:()=>ee.device,enumerable:!0,configurable:!0}),()=>{te(),D.tick++}),e.morph=$,e.morphPlugin=e=>{e.scope.$morph=$},e.mq=ee,e.persist=e=>{e.directive("persist",({ctx:e,el:t,exp:n,arg:i,modifiers:o,effect:r})=>{const a=s+(n||t.id);let c=o?void 0:l();for(const s in o)if(c=l(s))break;const f=i?i.split(",").map(e=>e.trim()).filter(Boolean):void 0;d(e.scope,a,f,c,r)})},e.persistStore=(e,n={})=>{const i=(0,t.store)(e);if(!i)return()=>{};const o=l(n.storage);return d(i,s+(n.key??e),n.keys,o,t.watchEffect)},e.registerStorage=(e,t)=>{a[e.toLowerCase()]=t},e.resetMedia=()=>{te(),R={...P},z=["base",...Object.keys(R).sort((e,t)=>R[e]-R[t])],I=!1,D.bp="base",D.tick=0},e.resize=e=>{e.directive("resize",({el:e,get:t,exp:n,modifiers:i})=>{const o=t(`(($width, $height) => { ${n} })`);if(i?.window||i?.visual){const e=i.visual&&window.visualViewport||window,t=()=>o(e.width||innerWidth,e.height||innerHeight);return e.addEventListener("resize",t),t(),()=>e.removeEventListener("resize",t)}const r=new ResizeObserver(e=>{for(const t of e){const e=t.contentRect;o(e.width,e.height)}});return r.observe(e),()=>r.disconnect()})},e.setDefaultStorage=e=>{c=e},e.transition=e=>{e.directive("transition",({el:e,get:t,effect:n,arg:i,modifiers:o,exp:s})=>{const a=e,c=i||"v",l=e=>`${c}-${e}`;let d,f=0;const u=()=>{a.classList.remove(l("enter-from"),l("enter-active"),l("enter-to"),l("leave-from"),l("leave-active"),l("leave-to"))},p=(e,t)=>{const n=++f;u(),a.classList.add(l(e+"-from"),l(e+"-active")),a.offsetWidth,a.classList.remove(l(e+"-from")),a.classList.add(l(e+"-to")),clearTimeout(d),d=setTimeout(()=>{n===f&&(u(),t&&t())},(e=>{const t=getComputedStyle(e);return Math.max(r(t.transitionDuration,t.transitionDelay),r(t.animationDuration,t.animationDelay))})(a))};if(!s){let e=!0;return Promise.resolve().then(()=>{e&&p("enter")}),a.__leave=()=>(e=!1,a.__leaving=1,new Promise(e=>p("leave",e))),()=>{e=!1,clearTimeout(d),u(),delete a.__leave}}const m="none"==a.style.display?"":a.style.display;let v;return n(()=>{const e=!!t();if(e===v)return;const n=null!=v;v=e,e?(a.style.display=m,(n||o?.appear)&&p("enter")):n?p("leave",()=>{a.style.display="none"}):a.style.display="none"}),()=>{clearTimeout(d),u(),!1===v&&(a.style.display="none")}})}});
|
package/dist/litevue.dev.iife.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var LiteVue = (function(exports) {
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
// node_modules/.pnpm/@vue+shared@3.4.38/node_modules/@vue/shared/dist/shared.esm-bundler.js
|
|
4
3
|
/**
|
|
5
4
|
* @vue/shared v3.4.38
|
|
@@ -33,7 +32,6 @@ var LiteVue = (function(exports) {
|
|
|
33
32
|
var toRawType = (value) => {
|
|
34
33
|
return toTypeString(value).slice(8, -1);
|
|
35
34
|
};
|
|
36
|
-
var isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
37
35
|
var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
38
36
|
var cacheStringFunction = (fn) => {
|
|
39
37
|
const cache = /* @__PURE__ */ Object.create(null);
|
|
@@ -615,7 +613,13 @@ getter: `, this.getter);
|
|
|
615
613
|
flush: /* @__PURE__ */ new Set()
|
|
616
614
|
};
|
|
617
615
|
var emit = (event, ...args) => {
|
|
618
|
-
listeners[event].forEach((fn) =>
|
|
616
|
+
listeners[event].forEach((fn) => {
|
|
617
|
+
try {
|
|
618
|
+
fn(...args);
|
|
619
|
+
} catch (e) {
|
|
620
|
+
console.error(`[litevue] a devtools "${event}" listener threw:`, e);
|
|
621
|
+
}
|
|
622
|
+
});
|
|
619
623
|
};
|
|
620
624
|
var registerScope = (el, scope, exp, name) => {
|
|
621
625
|
if (isDisabled()) return NOOP;
|
|
@@ -669,7 +673,7 @@ getter: `, this.getter);
|
|
|
669
673
|
while (el) {
|
|
670
674
|
const scope = scopes.get(el);
|
|
671
675
|
if (scope) return scope;
|
|
672
|
-
el = el.parentElement;
|
|
676
|
+
el = el.__marker?.parentElement || el.parentElement;
|
|
673
677
|
}
|
|
674
678
|
},
|
|
675
679
|
on(event, fn) {
|
|
@@ -871,6 +875,7 @@ getter: `, this.getter);
|
|
|
871
875
|
cb(value, previous);
|
|
872
876
|
} finally {
|
|
873
877
|
resetTracking();
|
|
878
|
+
oldValue = getter();
|
|
874
879
|
}
|
|
875
880
|
}
|
|
876
881
|
init = true;
|
|
@@ -882,23 +887,30 @@ getter: `, this.getter);
|
|
|
882
887
|
};
|
|
883
888
|
// src/directives/bind.ts
|
|
884
889
|
var forceAttrRE = /^(spellcheck|draggable|translate|form|list|type)$/;
|
|
890
|
+
var mediaSizeRE = /^(img|video|canvas|source)(width|height)$/;
|
|
885
891
|
var booleanAttrRE = /^(readonly|novalidate|formnovalidate|allowfullscreen|playsinline)$/;
|
|
886
892
|
var bind = ({ el, get, effect, arg, modifiers }) => {
|
|
887
|
-
let prevValue;
|
|
893
|
+
let prevValue = {};
|
|
888
894
|
if ((!arg || arg === "class") && !("_class" in el)) el._class = el.getAttribute("class");
|
|
889
895
|
effect(() => {
|
|
890
896
|
let value = get();
|
|
891
897
|
if (arg) {
|
|
892
898
|
if (modifiers?.camel) arg = camelize(arg);
|
|
893
|
-
|
|
899
|
+
patch(el, arg, value, prevValue);
|
|
894
900
|
} else {
|
|
895
|
-
|
|
901
|
+
const prev = Object(prevValue);
|
|
902
|
+
for (const key in value) (key in prev ? patch : setProp)(el, key, value[key], prev[key]);
|
|
896
903
|
for (const key in prevValue) if (!value || !(key in value)) setProp(el, key, null, prevValue[key]);
|
|
897
904
|
}
|
|
898
|
-
prevValue =
|
|
905
|
+
prevValue = snapshot(value);
|
|
906
|
+
if (!arg && prevValue?.style) prevValue.style = snapshot(prevValue.style);
|
|
899
907
|
if (!arg) el.__bound = prevValue;
|
|
900
908
|
});
|
|
901
909
|
};
|
|
910
|
+
var snapshot = (value) => isObject(value) ? { ...toStyle(value) } : value;
|
|
911
|
+
var patch = (el, key, value, prevValue) => {
|
|
912
|
+
if (value !== prevValue || isObject(value) || key === "value") setProp(el, key, value, prevValue);
|
|
913
|
+
};
|
|
902
914
|
var setProp = (el, key, value, prevValue) => {
|
|
903
915
|
if (key === "class") el.setAttribute("class", normalizeClass(el._class ? [el._class, value] : value) || "");
|
|
904
916
|
else if (key === "style") {
|
|
@@ -912,8 +924,13 @@ getter: `, this.getter);
|
|
|
912
924
|
if (el._vsh) style.display = "none";
|
|
913
925
|
}
|
|
914
926
|
if (!style.cssText) el.removeAttribute("style");
|
|
915
|
-
} else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key)) {
|
|
916
|
-
|
|
927
|
+
} else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key) && !mediaSizeRE.test(el.localName + key)) {
|
|
928
|
+
try {
|
|
929
|
+
const type = typeof el[key];
|
|
930
|
+
el[key] = value == null && type == "string" ? "" : value === "" && type == "boolean" || value;
|
|
931
|
+
} catch (e) {
|
|
932
|
+
if (value != null) throw e;
|
|
933
|
+
}
|
|
917
934
|
if (value == null) el.removeAttribute(key);
|
|
918
935
|
if (key === "value") el._value = value;
|
|
919
936
|
} else if (key === "true-value") el._trueValue = value;
|
|
@@ -1054,7 +1071,9 @@ getter: `, this.getter);
|
|
|
1054
1071
|
return;
|
|
1055
1072
|
}
|
|
1056
1073
|
const a = /\bawait\b/.test(exp) ? "async " : "";
|
|
1057
|
-
|
|
1074
|
+
const body = exp.replace(/;\s*$/, "");
|
|
1075
|
+
let handler = simplePathRE.test(exp) || fnExpRE.test(exp) ? get(`(e => (${body})(e))`) : isExpression(body) ? get(`(${a}$event => (${body}))`) : get(`(${a}$event => { ${exp} })`);
|
|
1076
|
+
if (!handler) return;
|
|
1058
1077
|
if (arg === "vue:mounted" || arg === "vue:unmounted") console.warn(`@${arg} is deprecated in LiteVue - use @${arg.slice(4)} instead.`);
|
|
1059
1078
|
if (arg === "mounted" || arg === "vue:mounted") {
|
|
1060
1079
|
let live = true;
|
|
@@ -1104,9 +1123,9 @@ getter: `, this.getter);
|
|
|
1104
1123
|
warnOnce(`modifier:${arg}.${k}`, `@${arg}.${k}: .${k} is not a modifier LiteVue knows, so it is ignored.` + (ms ? ` Timings are written with a dash — .debounce-${ms[1]} or .throttle-${ms[1]}.` : ` Key names only filter keyboard events.`));
|
|
1105
1124
|
}
|
|
1106
1125
|
handler = (e) => {
|
|
1107
|
-
if (modifiers.outside && el.
|
|
1108
|
-
if ("key" in e
|
|
1109
|
-
const key = hyphenate(e.key);
|
|
1126
|
+
if (modifiers.outside && (e.composedPath().includes(el) || el._vsh || e.timeStamp < el._vts)) return;
|
|
1127
|
+
if (keyFilter.length && ("key" in e || e.type.startsWith("key"))) {
|
|
1128
|
+
const key = hyphenate(e.key || "");
|
|
1110
1129
|
if (!keyFilter.some((k) => k === key || keyAliases[k] === key)) return;
|
|
1111
1130
|
}
|
|
1112
1131
|
for (const key in modifiers) {
|
|
@@ -1121,6 +1140,7 @@ getter: `, this.getter);
|
|
|
1121
1140
|
}
|
|
1122
1141
|
const target = modifiers?.window ? window : modifiers?.document || modifiers?.outside ? document : el;
|
|
1123
1142
|
const event = arg;
|
|
1143
|
+
if (modifiers?.outside) el._vts = performance.now();
|
|
1124
1144
|
target.addEventListener(event, handler, {
|
|
1125
1145
|
...modifiers,
|
|
1126
1146
|
once: false
|
|
@@ -1134,19 +1154,23 @@ getter: `, this.getter);
|
|
|
1134
1154
|
var show = ({ el, get, effect }) => {
|
|
1135
1155
|
el._vod = el.style.display == "none" ? "" : el.style.display;
|
|
1136
1156
|
effect(() => {
|
|
1137
|
-
|
|
1138
|
-
|
|
1157
|
+
const hidden = !get();
|
|
1158
|
+
if (el._vsh && !hidden) el._vts = performance.now();
|
|
1159
|
+
el._vsh = hidden;
|
|
1160
|
+
el.style.display = hidden ? "none" : el._vod;
|
|
1139
1161
|
});
|
|
1140
1162
|
};
|
|
1141
1163
|
// src/directives/text.ts
|
|
1142
1164
|
var text = ({ el, get, effect }) => {
|
|
1165
|
+
el.__r = 1;
|
|
1143
1166
|
effect(() => {
|
|
1144
1167
|
el.textContent = toDisplayString(get());
|
|
1145
1168
|
});
|
|
1146
1169
|
};
|
|
1147
|
-
var toDisplayString = (value) => value == null ? "" : isObject(value) ? JSON.stringify(value, null, 2) : String(value);
|
|
1170
|
+
var toDisplayString = (value) => value == null ? "" : isArray(value) || isObject(value) && (value.toString === objectToString || !isFunction(value.toString)) ? JSON.stringify(value, null, 2) : String(value);
|
|
1148
1171
|
// src/directives/html.ts
|
|
1149
1172
|
var html = ({ el, get, effect }) => {
|
|
1173
|
+
el.__r = 1;
|
|
1150
1174
|
effect(() => {
|
|
1151
1175
|
el.innerHTML = get() ?? "";
|
|
1152
1176
|
});
|
|
@@ -1416,7 +1440,10 @@ getter: `, this.getter);
|
|
|
1416
1440
|
}
|
|
1417
1441
|
};
|
|
1418
1442
|
let branchEffect;
|
|
1419
|
-
const stopBranches = () =>
|
|
1443
|
+
const stopBranches = () => {
|
|
1444
|
+
stopEffect(branchEffect);
|
|
1445
|
+
remove(ctx.effects, branchEffect);
|
|
1446
|
+
};
|
|
1420
1447
|
branchEffect = ctx.effect(() => {
|
|
1421
1448
|
for (let i = 0; i < branches.length; i++) {
|
|
1422
1449
|
const { exp, el } = branches[i];
|
|
@@ -1487,11 +1514,21 @@ getter: `, this.getter);
|
|
|
1487
1514
|
const createRows = (source) => {
|
|
1488
1515
|
const map = /* @__PURE__ */ new Map();
|
|
1489
1516
|
const rows = [];
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1517
|
+
try {
|
|
1518
|
+
if (isArray(source) || isString(source)) for (let i = 0; i < source.length; i++) rows.push(createRow(map, source[i], i));
|
|
1519
|
+
else if (typeof source === "number") for (let i = 0; i < source; i++) rows.push(createRow(map, i + 1, i));
|
|
1520
|
+
else if (isObject(source)) {
|
|
1521
|
+
let i = 0;
|
|
1522
|
+
for (const key in source) rows.push(createRow(map, source[key], i++, key));
|
|
1523
|
+
}
|
|
1524
|
+
} catch (e) {
|
|
1525
|
+
handleError(e, {
|
|
1526
|
+
phase: "expression",
|
|
1527
|
+
source: "v-for",
|
|
1528
|
+
el,
|
|
1529
|
+
expression: sourceExp
|
|
1530
|
+
});
|
|
1531
|
+
return [[], /* @__PURE__ */ new Map()];
|
|
1495
1532
|
}
|
|
1496
1533
|
return [rows, map];
|
|
1497
1534
|
};
|
|
@@ -1499,7 +1536,7 @@ getter: `, this.getter);
|
|
|
1499
1536
|
const data = {};
|
|
1500
1537
|
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value?.[isArrayDestructure ? i : b]);
|
|
1501
1538
|
else data[valueExp] = value;
|
|
1502
|
-
if (objKey) {
|
|
1539
|
+
if (objKey != null) {
|
|
1503
1540
|
indexExp && (data[indexExp] = objKey);
|
|
1504
1541
|
objIndexExp && (data[objIndexExp] = index);
|
|
1505
1542
|
} else indexExp && (data[indexExp] = index);
|
|
@@ -1514,7 +1551,10 @@ getter: `, this.getter);
|
|
|
1514
1551
|
};
|
|
1515
1552
|
};
|
|
1516
1553
|
const mountBlock = (row, ref) => {
|
|
1517
|
-
const block = new Block(el, createScopedContext(ctx, row.data));
|
|
1554
|
+
const block = new Block(el, createScopedContext(ctx, row.data, true));
|
|
1555
|
+
const t = block.template;
|
|
1556
|
+
t.__ctx ??= block.ctx;
|
|
1557
|
+
block.ctx.cleanups.push(() => delete t.__ctx);
|
|
1518
1558
|
block.key = row.key;
|
|
1519
1559
|
block.insert(parent(), ref);
|
|
1520
1560
|
return block;
|
|
@@ -1568,7 +1608,9 @@ getter: `, this.getter);
|
|
|
1568
1608
|
else {
|
|
1569
1609
|
block = blocks[oldIndex];
|
|
1570
1610
|
Object.assign(block.ctx.scope, row.data);
|
|
1571
|
-
|
|
1611
|
+
let next = (block.end || block.el).nextSibling;
|
|
1612
|
+
while (next?.__leaving) next = next.nextSibling;
|
|
1613
|
+
if (oldIndex !== i && next !== ref) block.insert(parent(), ref);
|
|
1572
1614
|
}
|
|
1573
1615
|
nextBlocks[i] = nextBlock = block;
|
|
1574
1616
|
}
|
|
@@ -1579,19 +1621,20 @@ getter: `, this.getter);
|
|
|
1579
1621
|
};
|
|
1580
1622
|
// src/directives/ref.ts
|
|
1581
1623
|
var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
|
|
1624
|
+
const refs = toRaw($refs);
|
|
1582
1625
|
let prevRef;
|
|
1583
1626
|
effect(() => {
|
|
1584
1627
|
const ref = get();
|
|
1585
1628
|
{
|
|
1586
|
-
const existing =
|
|
1587
|
-
if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
|
|
1629
|
+
const existing = hasOwn(refs, ref) && refs[ref];
|
|
1630
|
+
if (existing && existing !== el && existing.isConnected && !existing.__leaving) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
|
|
1588
1631
|
}
|
|
1589
1632
|
$refs[ref] = el;
|
|
1590
|
-
if (prevRef && ref !== prevRef) delete $refs[prevRef];
|
|
1633
|
+
if (prevRef && ref !== prevRef && refs[prevRef] === el) delete $refs[prevRef];
|
|
1591
1634
|
prevRef = ref;
|
|
1592
1635
|
});
|
|
1593
1636
|
return () => {
|
|
1594
|
-
prevRef && delete $refs[prevRef];
|
|
1637
|
+
refs[prevRef] === el && delete $refs[prevRef];
|
|
1595
1638
|
};
|
|
1596
1639
|
};
|
|
1597
1640
|
// src/lazy.ts
|
|
@@ -1622,7 +1665,11 @@ getter: `, this.getter);
|
|
|
1622
1665
|
let stop = NOOP;
|
|
1623
1666
|
if (mode === "visible" && typeof IntersectionObserver == "function") {
|
|
1624
1667
|
const io = new IntersectionObserver((entries) => {
|
|
1625
|
-
|
|
1668
|
+
for (const e of entries) {
|
|
1669
|
+
if (e.isIntersecting) return once();
|
|
1670
|
+
const parent = e.target.parentElement;
|
|
1671
|
+
if (!e.boundingClientRect.width && parent) io.observe(parent);
|
|
1672
|
+
}
|
|
1626
1673
|
});
|
|
1627
1674
|
io.observe(el);
|
|
1628
1675
|
stop = () => io.disconnect();
|
|
@@ -1705,16 +1752,17 @@ getter: `, this.getter);
|
|
|
1705
1752
|
}
|
|
1706
1753
|
};
|
|
1707
1754
|
var walkNode = (node, ctx) => {
|
|
1755
|
+
if (node.__r) return;
|
|
1708
1756
|
const type = node.nodeType;
|
|
1709
1757
|
if (type === 1) {
|
|
1710
1758
|
const el = node;
|
|
1711
1759
|
if (!el.hasAttributes()) return walkChildren(el, ctx);
|
|
1712
1760
|
if (el.hasAttribute("v-pre")) return;
|
|
1713
|
-
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1714
|
-
checkAttr(el, "v-cloak");
|
|
1715
1761
|
let exp;
|
|
1716
1762
|
if ((exp = checkAttr(el, "v-if")) != null) return _if(el, exp, ctx);
|
|
1717
1763
|
if (exp = checkAttr(el, "v-for")) return _for(el, exp, ctx);
|
|
1764
|
+
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1765
|
+
checkAttr(el, "v-cloak");
|
|
1718
1766
|
const name = checkAttr(el, "v-name");
|
|
1719
1767
|
let teleportNext;
|
|
1720
1768
|
if (exp = checkAttr(el, "v-teleport")) {
|
|
@@ -1723,7 +1771,16 @@ getter: `, this.getter);
|
|
|
1723
1771
|
teleportNext = el.nextSibling;
|
|
1724
1772
|
const marker = el.__marker = new Text("");
|
|
1725
1773
|
el.before(marker);
|
|
1726
|
-
|
|
1774
|
+
try {
|
|
1775
|
+
target.appendChild(el);
|
|
1776
|
+
} catch (e) {
|
|
1777
|
+
handleError(e, {
|
|
1778
|
+
phase: "directive",
|
|
1779
|
+
source: "v-teleport",
|
|
1780
|
+
el,
|
|
1781
|
+
expression: exp
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1727
1784
|
addCleanup(ctx, () => {
|
|
1728
1785
|
disposeSubtree(el);
|
|
1729
1786
|
el.remove();
|
|
@@ -1747,7 +1804,7 @@ getter: `, this.getter);
|
|
|
1747
1804
|
const wasOnce = inOnce;
|
|
1748
1805
|
if (checkAttr(el, "v-once") != null) inOnce = true;
|
|
1749
1806
|
if (exp = checkAttr(el, "ref")) applyDirective(el, ref, `"${exp}"`, ctx);
|
|
1750
|
-
walkChildren(el, ctx);
|
|
1807
|
+
if (!el.hasAttribute("v-text") && !el.hasAttribute("v-html")) walkChildren(el, ctx);
|
|
1751
1808
|
const deferred = [];
|
|
1752
1809
|
for (const { name, value } of [...el.attributes]) if (dirRE.test(name) && name !== "v-cloak") {
|
|
1753
1810
|
if (name === "v-model" || name.startsWith("v-model.")) deferred.unshift([name, value]);
|
|
@@ -1759,7 +1816,7 @@ getter: `, this.getter);
|
|
|
1759
1816
|
return teleportNext;
|
|
1760
1817
|
} else if (type === 3) {
|
|
1761
1818
|
const data = node.data;
|
|
1762
|
-
if (data.includes(ctx.delimiters[0])) {
|
|
1819
|
+
if (data.includes(ctx.delimiters[0]) && node.parentNode?.localName != "script") {
|
|
1763
1820
|
let segments = [];
|
|
1764
1821
|
let lastIndex = 0;
|
|
1765
1822
|
let match;
|
|
@@ -1817,7 +1874,7 @@ getter: `, this.getter);
|
|
|
1817
1874
|
const meta = {
|
|
1818
1875
|
source,
|
|
1819
1876
|
el,
|
|
1820
|
-
expression: displayExp
|
|
1877
|
+
expression: displayExp || exp
|
|
1821
1878
|
};
|
|
1822
1879
|
const report = (err) => handleError(err, {
|
|
1823
1880
|
phase: "handler",
|
|
@@ -1861,7 +1918,18 @@ getter: `, this.getter);
|
|
|
1861
1918
|
});
|
|
1862
1919
|
return;
|
|
1863
1920
|
}
|
|
1864
|
-
if (cleanup) addCleanup(ctx,
|
|
1921
|
+
if (cleanup) addCleanup(ctx, () => {
|
|
1922
|
+
try {
|
|
1923
|
+
cleanup();
|
|
1924
|
+
} catch (e) {
|
|
1925
|
+
handleError(e, {
|
|
1926
|
+
phase: "teardown",
|
|
1927
|
+
source,
|
|
1928
|
+
el,
|
|
1929
|
+
expression: exp
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
});
|
|
1865
1933
|
};
|
|
1866
1934
|
/**
|
|
1867
1935
|
* `querySelector` for a selector written in markup. One that does not parse is
|
|
@@ -1933,7 +2001,7 @@ getter: `, this.getter);
|
|
|
1933
2001
|
writable: true,
|
|
1934
2002
|
configurable: true
|
|
1935
2003
|
});
|
|
1936
|
-
var createScopedContext = (ctx, data = {}) => {
|
|
2004
|
+
var createScopedContext = (ctx, data = {}, isRow) => {
|
|
1937
2005
|
const parentScope = ctx.scope;
|
|
1938
2006
|
const mergedScope = Object.create(parentScope);
|
|
1939
2007
|
Object.defineProperties(mergedScope, Object.getOwnPropertyDescriptors(data));
|
|
@@ -1948,16 +2016,20 @@ getter: `, this.getter);
|
|
|
1948
2016
|
};
|
|
1949
2017
|
hide(mergedScope, "$watch", createWatch(scopedCtx));
|
|
1950
2018
|
hide(mergedScope, "$id", createId());
|
|
1951
|
-
bindContextMethods(reactiveProxy, mergedScope);
|
|
2019
|
+
if (!isRow) bindContextMethods(reactiveProxy, mergedScope);
|
|
1952
2020
|
return scopedCtx;
|
|
1953
2021
|
};
|
|
1954
2022
|
var bindContextMethods = (scope, raw = scope) => {
|
|
1955
2023
|
for (const key of Object.keys(raw)) {
|
|
1956
|
-
const fn = Object.getOwnPropertyDescriptor(raw, key)
|
|
1957
|
-
if (typeof fn === "function") scope[key] = fn.bind(scope);
|
|
2024
|
+
const { value: fn, writable } = Object.getOwnPropertyDescriptor(raw, key);
|
|
2025
|
+
if (typeof fn === "function" && writable) scope[key] = Object.setPrototypeOf(fn.bind(scope), fn);
|
|
1958
2026
|
}
|
|
1959
2027
|
};
|
|
1960
2028
|
// src/block.ts
|
|
2029
|
+
var stopEffects = (block) => {
|
|
2030
|
+
block.ctx.blocks.forEach(stopEffects);
|
|
2031
|
+
block.ctx.effects.splice(0).forEach(stopEffect);
|
|
2032
|
+
};
|
|
1961
2033
|
var Block = class {
|
|
1962
2034
|
get el() {
|
|
1963
2035
|
return this.start || this.template.__marker || this.template;
|
|
@@ -1965,7 +2037,10 @@ getter: `, this.getter);
|
|
|
1965
2037
|
constructor(template, parentCtx, isRoot = false) {
|
|
1966
2038
|
this.isFragment = template instanceof HTMLTemplateElement;
|
|
1967
2039
|
if (isRoot) this.template = template;
|
|
1968
|
-
else if (
|
|
2040
|
+
else if (template.hasAttribute("v-for")) {
|
|
2041
|
+
this.isFragment = true;
|
|
2042
|
+
(this.template = new DocumentFragment()).append(template.cloneNode(true));
|
|
2043
|
+
} else if (this.isFragment) this.template = template.content.cloneNode(true);
|
|
1969
2044
|
else this.template = template.cloneNode(true);
|
|
1970
2045
|
if (isRoot) this.ctx = createContext(parentCtx);
|
|
1971
2046
|
else {
|
|
@@ -2000,7 +2075,10 @@ getter: `, this.getter);
|
|
|
2000
2075
|
}
|
|
2001
2076
|
}
|
|
2002
2077
|
remove() {
|
|
2003
|
-
if (this.parentCtx)
|
|
2078
|
+
if (this.parentCtx) {
|
|
2079
|
+
remove(this.parentCtx.blocks, this);
|
|
2080
|
+
this.parentCtx = void 0;
|
|
2081
|
+
}
|
|
2004
2082
|
const removeNow = () => {
|
|
2005
2083
|
const parent = this.start ? this.start.parentNode : this.template.parentNode;
|
|
2006
2084
|
if (parent) {
|
|
@@ -2022,9 +2100,11 @@ getter: `, this.getter);
|
|
|
2022
2100
|
this.template.__marker?.remove();
|
|
2023
2101
|
this.teardown();
|
|
2024
2102
|
};
|
|
2103
|
+
stopEffects(this);
|
|
2025
2104
|
const leaves = [];
|
|
2026
2105
|
let node = this.start || this.template;
|
|
2027
2106
|
while (node) {
|
|
2107
|
+
node.__leaving = 1;
|
|
2028
2108
|
const leave = node.__leave;
|
|
2029
2109
|
if (leave) leaves.push(leave());
|
|
2030
2110
|
if (!this.start || node === this.end) break;
|
|
@@ -2067,7 +2147,7 @@ getter: `, this.getter);
|
|
|
2067
2147
|
var registry = Object.create(null);
|
|
2068
2148
|
var target = registry;
|
|
2069
2149
|
target = new Proxy(registry, { get(obj, key, receiver) {
|
|
2070
|
-
if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj)) setTimeout(() => {
|
|
2150
|
+
if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj) && !(key in Object.prototype)) setTimeout(() => {
|
|
2071
2151
|
if (key in obj) return;
|
|
2072
2152
|
warnOnce(`store-missing:${key}`, `$store.${key} is not registered, so it reads as undefined. Register it with store('${key}', { … }) before mounting, or check the spelling.`);
|
|
2073
2153
|
});
|
|
@@ -2090,6 +2170,7 @@ getter: `, this.getter);
|
|
|
2090
2170
|
// src/app.ts
|
|
2091
2171
|
var mountedRoots = /* @__PURE__ */ new WeakMap();
|
|
2092
2172
|
var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
|
|
2173
|
+
var isInert = (el) => el && (el.__r || el.hasAttribute("v-pre") || isInert(el.parentElement));
|
|
2093
2174
|
var createApp = (initialData) => {
|
|
2094
2175
|
const ctx = createContext();
|
|
2095
2176
|
if (typeof initialData === "function") {
|
|
@@ -2156,7 +2237,7 @@ getter: `, this.getter);
|
|
|
2156
2237
|
const watched = pluginsWatched();
|
|
2157
2238
|
const dirsBefore = watched ? Object.keys(ctx.dirs) : [];
|
|
2158
2239
|
const scopeBefore = watched ? Object.keys(ctx.scope) : [];
|
|
2159
|
-
const teardown =
|
|
2240
|
+
const teardown = typeof plugin === "function" ? plugin(app, options) : plugin.install(app, options);
|
|
2160
2241
|
if (typeof teardown === "function") pluginTeardowns.push(teardown);
|
|
2161
2242
|
if (watched) {
|
|
2162
2243
|
const off = registerPlugin({
|
|
@@ -2184,18 +2265,21 @@ getter: `, this.getter);
|
|
|
2184
2265
|
if (el.matches(SCOPE_SELECTOR)) roots = [el];
|
|
2185
2266
|
else roots = [...el.querySelectorAll(SCOPE_SELECTOR)].filter((root) => !root.matches(`:where(${SCOPE_SELECTOR}) *`));
|
|
2186
2267
|
if (!roots.length) roots = [el];
|
|
2268
|
+
roots = roots.filter((root) => !isInert(root));
|
|
2187
2269
|
if (roots.length === 1 && roots[0] === document.documentElement) console.warn("Mounting on documentElement - this is non-optimal as LiteVue will be forced to crawl the entire page's DOM. Consider explicitly marking elements controlled by LiteVue with `v-scope`.");
|
|
2188
2270
|
ctx.walk ??= walk;
|
|
2189
2271
|
ctx.dispose ??= disposeSubtree;
|
|
2190
2272
|
for (const el of roots) {
|
|
2191
2273
|
if (mountedRoots.has(el) && mountedRoots.get(el) === el.firstChild) warn("mount() was called again on an element that has already been mounted, so its directives were consumed by the first walk and nothing was bound this time. To re-activate a region, insert fresh markup and mount that instead.");
|
|
2192
2274
|
const name = el.getAttribute("v-name");
|
|
2275
|
+
const host = el.parentNode;
|
|
2193
2276
|
const block = new Block(el, ctx, true);
|
|
2277
|
+
block.host = host;
|
|
2194
2278
|
mountedRoots.set(el, el.firstChild);
|
|
2195
2279
|
el.__ctx ??= block.ctx;
|
|
2196
2280
|
if (!devtools.scopes.has(el) && !el.matches(SCOPE_SELECTOR)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
|
|
2197
2281
|
rootBlocks.push(block);
|
|
2198
|
-
own(() => remove(rootBlocks, block), el);
|
|
2282
|
+
own(() => (remove(rootBlocks, block), block.teardown()), el);
|
|
2199
2283
|
block.ctx.cleanups.push(() => delete el.__ctx);
|
|
2200
2284
|
}
|
|
2201
2285
|
return this;
|
|
@@ -2234,7 +2318,7 @@ getter: `, this.getter);
|
|
|
2234
2318
|
const kept = [];
|
|
2235
2319
|
for (const block of rootBlocks) {
|
|
2236
2320
|
const root = block.template;
|
|
2237
|
-
if (target.contains(root)) block.teardown();
|
|
2321
|
+
if (target.contains(root) || target.contains(block.host)) block.teardown();
|
|
2238
2322
|
else kept.push(block);
|
|
2239
2323
|
}
|
|
2240
2324
|
if (kept.length === rootBlocks.length) console.warn("unmount: no mounted region found at or inside the given element. Pass the same element that was mounted, or one containing it.");
|