@stonecrop/utilities 0.4.35 → 0.4.36

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.
@@ -1 +1 @@
1
- {"version":"5.8.3"}
1
+ {"version":"5.9.3"}
@@ -1,2 +1,2 @@
1
- (function(h,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(h=typeof globalThis<"u"?globalThis:h||self,f(h["@stonecrop/utilities"]={},h.Vue))})(this,function(h,f){"use strict";function T(e){return f.getCurrentScope()?(f.onScopeDispose(e),!0):!1}const I=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const N=e=>e!=null,W=Object.prototype.toString,K=e=>W.call(e)==="[object Object]",F=()=>{};function v(e){return Array.isArray(e)?e:[e]}function j(e,t,n){return f.watch(e,t,{...n,immediate:!0})}const w=I?window:void 0;function y(e){var t;const n=f.toValue(e);return(t=n?.$el)!=null?t:n}function b(...e){const t=[],n=()=>{t.forEach(o=>o()),t.length=0},l=(o,r,i,a)=>(o.addEventListener(r,i,a),()=>o.removeEventListener(r,i,a)),c=f.computed(()=>{const o=v(f.toValue(e[0])).filter(r=>r!=null);return o.every(r=>typeof r!="string")?o:void 0}),u=j(()=>{var o,r;return[(r=(o=c.value)==null?void 0:o.map(i=>y(i)))!=null?r:[w].filter(i=>i!=null),v(f.toValue(c.value?e[1]:e[0])),v(f.unref(c.value?e[2]:e[1])),f.toValue(c.value?e[3]:e[2])]},([o,r,i,a])=>{if(n(),!o?.length||!r?.length||!i?.length)return;const d=K(a)?{...a}:a;t.push(...o.flatMap(p=>r.flatMap(m=>i.map(g=>l(p,m,g,d)))))},{flush:"post"}),s=()=>{u(),n()};return T(n),s}function B(){const e=f.shallowRef(!1),t=f.getCurrentInstance();return t&&f.onMounted(()=>{e.value=!0},t),e}function q(e){const t=B();return f.computed(()=>(t.value,!!e()))}function G(e,t,n={}){const{window:l=w,...c}=n;let u;const s=q(()=>l&&"MutationObserver"in l),o=()=>{u&&(u.disconnect(),u=void 0)},r=f.computed(()=>{const p=f.toValue(e),m=v(p).map(y).filter(N);return new Set(m)}),i=f.watch(()=>r.value,p=>{o(),s.value&&p.size&&(u=new MutationObserver(t),p.forEach(m=>u.observe(m,c)))},{immediate:!0,flush:"post"}),a=()=>u?.takeRecords(),d=()=>{i(),o()};return T(d),{isSupported:s,stop:d,takeRecords:a}}function z(e,t,n={}){const{window:l=w,document:c=l?.document,flush:u="sync"}=n;if(!l||!c)return F;let s;const o=a=>{s?.(),s=a},r=f.watchEffect(()=>{const a=y(e);if(a){const{stop:d}=G(c,p=>{p.map(g=>[...g.removedNodes]).flat().some(g=>g===a||g.contains(a))&&t(p)},{window:l,childList:!0,subtree:!0});o(d)}},{flush:u}),i=()=>{r(),o()};return T(i),i}function J(e={}){var t;const{window:n=w,deep:l=!0,triggerOnRemoval:c=!1}=e,u=(t=e.document)!=null?t:n?.document,s=()=>{var i;let a=u?.activeElement;if(l)for(;a?.shadowRoot;)a=(i=a?.shadowRoot)==null?void 0:i.activeElement;return a},o=f.shallowRef(),r=()=>{o.value=s()};if(n){const i={capture:!0,passive:!0};b(n,"blur",a=>{a.relatedTarget===null&&r()},i),b(n,"focus",r,i)}return c&&z(o,r,{document:u}),r(),o}const Q="focusin",X="focusout",Y=":focus-within";function Z(e,t={}){const{window:n=w}=t,l=f.computed(()=>y(e)),c=f.shallowRef(!1),u=f.computed(()=>c.value);if(!n||!J(t).value)return{focused:u};const o={passive:!0};return b(l,Q,()=>c.value=!0,o),b(l,X,()=>{var r,i,a;return c.value=(a=(i=(r=l.value)==null?void 0:r.matches)==null?void 0:i.call(r,Y))!=null?a:!1},o),{focused:u}}function ee(e,{window:t=w,scrollTarget:n}={}){const l=f.ref(!1),c=()=>{if(!t)return;const u=t.document,s=y(e);if(!s)l.value=!1;else{const o=s.getBoundingClientRect();l.value=o.top<=(t.innerHeight||u.documentElement.clientHeight)&&o.left<=(t.innerWidth||u.documentElement.clientWidth)&&o.bottom>=0&&o.right>=0}};return f.watch(()=>y(e),()=>c(),{immediate:!0,flush:"post"}),t&&b(n||t,"scroll",c,{capture:!1,passive:!0}),l}const $=e=>{let t=ee(e).value;return t=t&&e.offsetHeight>0,t},E=e=>e.tabIndex>=0,L=e=>{const t=e.target;return R(t)},R=e=>{let t;if(e instanceof HTMLTableCellElement){const n=e.parentElement?.previousElementSibling;if(n){const c=Array.from(n.children)[e.cellIndex];c&&(t=c)}}else if(e instanceof HTMLTableRowElement){const n=e.previousElementSibling;n&&(t=n)}return t&&(!E(t)||!$(t))?R(t):t},te=e=>{const t=e.target;let n;if(t instanceof HTMLTableCellElement){const l=t.parentElement?.parentElement;if(l){const u=l.firstElementChild?.children[t.cellIndex];u&&(n=u)}}else if(t instanceof HTMLTableRowElement){const l=t.parentElement;if(l){const c=l.firstElementChild;c&&(n=c)}}return n&&(!E(n)||!$(n))?M(n):n},x=e=>{const t=e.target;return M(t)},M=e=>{let t;if(e instanceof HTMLTableCellElement){const n=e.parentElement?.nextElementSibling;if(n){const c=Array.from(n.children)[e.cellIndex];c&&(t=c)}}else if(e instanceof HTMLTableRowElement){const n=e.nextElementSibling;n&&(t=n)}return t&&(!E(t)||!$(t))?M(t):t},ne=e=>{const t=e.target;let n;if(t instanceof HTMLTableCellElement){const l=t.parentElement?.parentElement;if(l){const u=l.lastElementChild?.children[t.cellIndex];u&&(n=u)}}else if(t instanceof HTMLTableRowElement){const l=t.parentElement;if(l){const c=l.lastElementChild;c&&(n=c)}}return n&&(!E(n)||!$(n))?R(n):n},D=e=>{const t=e.target;return k(t)},k=e=>{let t;return e.previousElementSibling?t=e.previousElementSibling:t=e.parentElement?.previousElementSibling?.lastElementChild,t&&(!E(t)||!$(t))?k(t):t},P=e=>{const t=e.target;return A(t)},A=e=>{let t;return e.nextElementSibling?t=e.nextElementSibling:t=e.parentElement?.nextElementSibling?.firstElementChild,t&&(!E(t)||!$(t))?A(t):t},O=e=>{const l=e.target.parentElement?.firstElementChild;return l&&(!E(l)||!$(l))?A(l):l},U=e=>{const l=e.target.parentElement?.lastElementChild;return l&&(!E(l)||!$(l))?k(l):l},S=["alt","control","shift","meta"],oe={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},V={"keydown.up":e=>{const t=L(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.down":e=>{const t=x(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.left":e=>{const t=D(e);e.preventDefault(),e.stopPropagation(),t&&t.focus()},"keydown.right":e=>{const t=P(e);e.preventDefault(),e.stopPropagation(),t&&t.focus()},"keydown.control.up":e=>{const t=te(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.control.down":e=>{const t=ne(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.control.left":e=>{const t=O(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.control.right":e=>{const t=U(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.end":e=>{const t=U(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const n=x(e);n&&n.focus()}},"keydown.shift.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const n=L(e);n&&n.focus()}},"keydown.home":e=>{const t=O(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.tab":e=>{const t=P(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.shift.tab":e=>{const t=D(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())}};function le(e){const t=s=>{let o=null;return s.parent&&(typeof s.parent=="string"?o=document.querySelector(s.parent):s.parent instanceof HTMLElement?o=s.parent:o=s.parent.value),o},n=s=>{const o=t(s);let r=[];if(typeof s.selectors=="string")r=o?Array.from(o.querySelectorAll(s.selectors)):Array.from(document.querySelectorAll(s.selectors));else if(Array.isArray(s.selectors))for(const i of s.selectors)i instanceof HTMLElement?r.push(i):r.push(i.$el);else if(s.selectors instanceof HTMLElement)r.push(s.selectors);else if(s.selectors?.value)if(Array.isArray(s.selectors.value))for(const i of s.selectors.value)i instanceof HTMLElement?r.push(i):r.push(i.$el);else r.push(s.selectors.value);return r},l=s=>{const o=t(s);let r=[];return s.selectors?r=n(s):o&&(r=Array.from(o.children).filter(a=>E(a)&&$(a))),r},c=s=>o=>{const r=oe[o.key]||o.key.toLowerCase();if(S.includes(r))return;const i=s.handlers||V;for(const a of Object.keys(i)){const[d,...p]=a.split(".");if(d==="keydown"&&p.includes(r)){const m=i[a],g=p.filter(C=>S.includes(C)),_=S.some(C=>{const H=C.charAt(0).toUpperCase()+C.slice(1);return o.getModifierState(H)});if(g.length>0){if(_){for(const C of S)if(p.includes(C)){const H=C.charAt(0).toUpperCase()+C.slice(1);o.getModifierState(H)&&m(o)}}}else _||m(o)}}},u=[];f.onMounted(()=>{for(const s of e){const o=t(s),r=l(s),i=c(s),a=o?[o]:r;for(const d of a){const{focused:p}=Z(f.ref(d)),m=f.watch(p,g=>{g?d.addEventListener("keydown",i):d.removeEventListener("keydown",i)});u.push(m)}}}),f.onBeforeUnmount(()=>{for(const s of u)s()})}function se(e){}h.defaultKeypressHandlers=V,h.install=se,h.useKeyboardNav=le,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(h,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(h=typeof globalThis<"u"?globalThis:h||self,f(h["@stonecrop/utilities"]={},h.Vue))})(this,(function(h,f){"use strict";function T(e){return f.getCurrentScope()?(f.onScopeDispose(e),!0):!1}const I=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const N=e=>e!=null,W=Object.prototype.toString,K=e=>W.call(e)==="[object Object]",F=()=>{};function v(e){return Array.isArray(e)?e:[e]}function j(e,t,n){return f.watch(e,t,{...n,immediate:!0})}const w=I?window:void 0;function y(e){var t;const n=f.toValue(e);return(t=n?.$el)!=null?t:n}function b(...e){const t=[],n=()=>{t.forEach(o=>o()),t.length=0},l=(o,r,i,a)=>(o.addEventListener(r,i,a),()=>o.removeEventListener(r,i,a)),c=f.computed(()=>{const o=v(f.toValue(e[0])).filter(r=>r!=null);return o.every(r=>typeof r!="string")?o:void 0}),u=j(()=>{var o,r;return[(r=(o=c.value)==null?void 0:o.map(i=>y(i)))!=null?r:[w].filter(i=>i!=null),v(f.toValue(c.value?e[1]:e[0])),v(f.unref(c.value?e[2]:e[1])),f.toValue(c.value?e[3]:e[2])]},([o,r,i,a])=>{if(n(),!o?.length||!r?.length||!i?.length)return;const d=K(a)?{...a}:a;t.push(...o.flatMap(p=>r.flatMap(m=>i.map(g=>l(p,m,g,d)))))},{flush:"post"}),s=()=>{u(),n()};return T(n),s}function B(){const e=f.shallowRef(!1),t=f.getCurrentInstance();return t&&f.onMounted(()=>{e.value=!0},t),e}function q(e){const t=B();return f.computed(()=>(t.value,!!e()))}function G(e,t,n={}){const{window:l=w,...c}=n;let u;const s=q(()=>l&&"MutationObserver"in l),o=()=>{u&&(u.disconnect(),u=void 0)},r=f.computed(()=>{const p=f.toValue(e),m=v(p).map(y).filter(N);return new Set(m)}),i=f.watch(()=>r.value,p=>{o(),s.value&&p.size&&(u=new MutationObserver(t),p.forEach(m=>u.observe(m,c)))},{immediate:!0,flush:"post"}),a=()=>u?.takeRecords(),d=()=>{i(),o()};return T(d),{isSupported:s,stop:d,takeRecords:a}}function z(e,t,n={}){const{window:l=w,document:c=l?.document,flush:u="sync"}=n;if(!l||!c)return F;let s;const o=a=>{s?.(),s=a},r=f.watchEffect(()=>{const a=y(e);if(a){const{stop:d}=G(c,p=>{p.map(g=>[...g.removedNodes]).flat().some(g=>g===a||g.contains(a))&&t(p)},{window:l,childList:!0,subtree:!0});o(d)}},{flush:u}),i=()=>{r(),o()};return T(i),i}function J(e={}){var t;const{window:n=w,deep:l=!0,triggerOnRemoval:c=!1}=e,u=(t=e.document)!=null?t:n?.document,s=()=>{var i;let a=u?.activeElement;if(l)for(;a?.shadowRoot;)a=(i=a?.shadowRoot)==null?void 0:i.activeElement;return a},o=f.shallowRef(),r=()=>{o.value=s()};if(n){const i={capture:!0,passive:!0};b(n,"blur",a=>{a.relatedTarget===null&&r()},i),b(n,"focus",r,i)}return c&&z(o,r,{document:u}),r(),o}const Q="focusin",X="focusout",Y=":focus-within";function Z(e,t={}){const{window:n=w}=t,l=f.computed(()=>y(e)),c=f.shallowRef(!1),u=f.computed(()=>c.value);if(!n||!J(t).value)return{focused:u};const o={passive:!0};return b(l,Q,()=>c.value=!0,o),b(l,X,()=>{var r,i,a;return c.value=(a=(i=(r=l.value)==null?void 0:r.matches)==null?void 0:i.call(r,Y))!=null?a:!1},o),{focused:u}}function ee(e,{window:t=w,scrollTarget:n}={}){const l=f.ref(!1),c=()=>{if(!t)return;const u=t.document,s=y(e);if(!s)l.value=!1;else{const o=s.getBoundingClientRect();l.value=o.top<=(t.innerHeight||u.documentElement.clientHeight)&&o.left<=(t.innerWidth||u.documentElement.clientWidth)&&o.bottom>=0&&o.right>=0}};return f.watch(()=>y(e),()=>c(),{immediate:!0,flush:"post"}),t&&b(n||t,"scroll",c,{capture:!1,passive:!0}),l}const $=e=>{let t=ee(e).value;return t=t&&e.offsetHeight>0,t},E=e=>e.tabIndex>=0,L=e=>{const t=e.target;return R(t)},R=e=>{let t;if(e instanceof HTMLTableCellElement){const n=e.parentElement?.previousElementSibling;if(n){const c=Array.from(n.children)[e.cellIndex];c&&(t=c)}}else if(e instanceof HTMLTableRowElement){const n=e.previousElementSibling;n&&(t=n)}return t&&(!E(t)||!$(t))?R(t):t},te=e=>{const t=e.target;let n;if(t instanceof HTMLTableCellElement){const l=t.parentElement?.parentElement;if(l){const u=l.firstElementChild?.children[t.cellIndex];u&&(n=u)}}else if(t instanceof HTMLTableRowElement){const l=t.parentElement;if(l){const c=l.firstElementChild;c&&(n=c)}}return n&&(!E(n)||!$(n))?M(n):n},x=e=>{const t=e.target;return M(t)},M=e=>{let t;if(e instanceof HTMLTableCellElement){const n=e.parentElement?.nextElementSibling;if(n){const c=Array.from(n.children)[e.cellIndex];c&&(t=c)}}else if(e instanceof HTMLTableRowElement){const n=e.nextElementSibling;n&&(t=n)}return t&&(!E(t)||!$(t))?M(t):t},ne=e=>{const t=e.target;let n;if(t instanceof HTMLTableCellElement){const l=t.parentElement?.parentElement;if(l){const u=l.lastElementChild?.children[t.cellIndex];u&&(n=u)}}else if(t instanceof HTMLTableRowElement){const l=t.parentElement;if(l){const c=l.lastElementChild;c&&(n=c)}}return n&&(!E(n)||!$(n))?R(n):n},D=e=>{const t=e.target;return k(t)},k=e=>{let t;return e.previousElementSibling?t=e.previousElementSibling:t=e.parentElement?.previousElementSibling?.lastElementChild,t&&(!E(t)||!$(t))?k(t):t},P=e=>{const t=e.target;return A(t)},A=e=>{let t;return e.nextElementSibling?t=e.nextElementSibling:t=e.parentElement?.nextElementSibling?.firstElementChild,t&&(!E(t)||!$(t))?A(t):t},O=e=>{const l=e.target.parentElement?.firstElementChild;return l&&(!E(l)||!$(l))?A(l):l},U=e=>{const l=e.target.parentElement?.lastElementChild;return l&&(!E(l)||!$(l))?k(l):l},S=["alt","control","shift","meta"],oe={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},V={"keydown.up":e=>{const t=L(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.down":e=>{const t=x(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.left":e=>{const t=D(e);e.preventDefault(),e.stopPropagation(),t&&t.focus()},"keydown.right":e=>{const t=P(e);e.preventDefault(),e.stopPropagation(),t&&t.focus()},"keydown.control.up":e=>{const t=te(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.control.down":e=>{const t=ne(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.control.left":e=>{const t=O(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.control.right":e=>{const t=U(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.end":e=>{const t=U(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const n=x(e);n&&n.focus()}},"keydown.shift.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const n=L(e);n&&n.focus()}},"keydown.home":e=>{const t=O(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.tab":e=>{const t=P(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())},"keydown.shift.tab":e=>{const t=D(e);t&&(e.preventDefault(),e.stopPropagation(),t.focus())}};function le(e){const t=s=>{let o=null;return s.parent&&(typeof s.parent=="string"?o=document.querySelector(s.parent):s.parent instanceof HTMLElement?o=s.parent:o=s.parent.value),o},n=s=>{const o=t(s);let r=[];if(typeof s.selectors=="string")r=o?Array.from(o.querySelectorAll(s.selectors)):Array.from(document.querySelectorAll(s.selectors));else if(Array.isArray(s.selectors))for(const i of s.selectors)i instanceof HTMLElement?r.push(i):r.push(i.$el);else if(s.selectors instanceof HTMLElement)r.push(s.selectors);else if(s.selectors?.value)if(Array.isArray(s.selectors.value))for(const i of s.selectors.value)i instanceof HTMLElement?r.push(i):r.push(i.$el);else r.push(s.selectors.value);return r},l=s=>{const o=t(s);let r=[];return s.selectors?r=n(s):o&&(r=Array.from(o.children).filter(a=>E(a)&&$(a))),r},c=s=>o=>{const r=oe[o.key]||o.key.toLowerCase();if(S.includes(r))return;const i=s.handlers||V;for(const a of Object.keys(i)){const[d,...p]=a.split(".");if(d==="keydown"&&p.includes(r)){const m=i[a],g=p.filter(C=>S.includes(C)),_=S.some(C=>{const H=C.charAt(0).toUpperCase()+C.slice(1);return o.getModifierState(H)});if(g.length>0){if(_){for(const C of S)if(p.includes(C)){const H=C.charAt(0).toUpperCase()+C.slice(1);o.getModifierState(H)&&m(o)}}}else _||m(o)}}},u=[];f.onMounted(()=>{for(const s of e){const o=t(s),r=l(s),i=c(s),a=o?[o]:r;for(const d of a){const{focused:p}=Z(f.ref(d)),m=f.watch(p,g=>{g?d.addEventListener("keydown",i):d.removeEventListener("keydown",i)});u.push(m)}}}),f.onBeforeUnmount(()=>{for(const s of u)s()})}function se(e){}h.defaultKeypressHandlers=V,h.install=se,h.useKeyboardNav=le,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=utilities.umd.cjs.map