@livx.cc/bare-v3 0.1.0-alpha.116 → 0.1.0-alpha.117
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/components.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/references/motion.md +1 -1
- package/package.json +1 -1
package/dist/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var nt=typeof HTMLElement==="function"?HTMLElement:class{};function x(t,a){if(typeof customElements>"u"||customElements.get?.(t))return;try{customElements.define(t,a)}catch(b){console.warn(`bare-v3: ${t} was not registered`,b)}}class w extends nt{#t=null;#n=null;#e=null;target(){return this}connectedCallback(){let t=this.ownerDocument;if(t.readyState==="loading"){t.addEventListener("DOMContentLoaded",()=>{if(this.isConnected)this.#r()},{once:!0});return}this.#r()}disconnectedCallback(){this.#o(),this.#e?.disconnect(),this.#e=null}#r(){if(this.#t)return;let t=this.target();if(t!==this&&!this.#e)this.#e=new MutationObserver(()=>{if(this.target()!==this.#n)this.#o(),this.#r()}),this.#e.observe(this,{childList:!0});if(!t)return;this.#t=new AbortController,this.#n=t,this.mount(t,this.#t.signal)}#o(){this.#t?.abort(),this.#t=null,this.#n=null}}function k(t,a,b={},i=[]){let l=()=>{for(let u of i)if(!t.classList.contains(u))t.classList.add(u);for(let[u,f]of Object.entries(b))if(!t.hasAttribute(u))t.setAttribute(u,f)};l();let o=new MutationObserver(l);o.observe(t,{attributes:!0,attributeFilter:["class",...Object.keys(b)]}),a.addEventListener("abort",()=>o.disconnect(),{once:!0})}function P(t,a){let b=t.ownerDocument,i=(p)=>p.closest(t.localName)===t,l=(p)=>[...p.querySelectorAll('[role="tab"]')].filter((e)=>e.closest('[role="tablist"]')===p),o=new WeakMap,u=(p,e,n)=>{if(p.getAttribute(e)!==n)p.setAttribute(e,n)},f=()=>[...t.querySelectorAll('[role="tablist"]')].filter(i);function s(p,e){o.set(p,e);for(let n of l(p))u(n,"aria-selected",String(n===e)),u(n,"tabindex",n===e?"0":"-1")}function r(){let p=new Map;for(let e of f()){let n=o.get(e);if(!n)continue;for(let d of l(e)){let E=d.getAttribute("aria-controls"),g=E?b.getElementById(E):null;if(g)p.set(g,d===n||!!p.get(g))}}for(let[e,n]of p)if(e.hidden===n)e.hidden=!n}function c(p,e=!1){let n=p.closest('[role="tablist"]');if(!n||p.disabled)return;if(s(n,p),r(),e)p.focus({preventScroll:!0}),p.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"})}function h(){for(let p of f()){let e=l(p).filter((g)=>!g.disabled),n=o.get(p),E=e.filter((g)=>g.getAttribute("aria-selected")==="true").find((g)=>g!==n)??(n&&e.includes(n)?n:e[0]);if(E)s(p,E)}r()}h();let m=new b.defaultView.MutationObserver(h);m.observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["aria-selected","tabindex","hidden"]}),a.addEventListener("abort",()=>m.disconnect(),{once:!0}),t.addEventListener("click",(p)=>{let e=p.target.closest?.('[role="tab"]'),n=e?.closest('[role="tablist"]');if(e&&n&&i(n)&&!e.disabled)c(e)},{signal:a}),t.addEventListener("keydown",(p)=>{let e=p.target.closest?.('[role="tab"]'),n=e?.closest('[role="tablist"]');if(!e||!n||!i(n))return;let d=l(n).filter((v)=>!v.disabled),E=d.indexOf(e),g=n.getAttribute("aria-orientation")==="vertical",y=b.defaultView.getComputedStyle(n).direction==="rtl",A=g?"ArrowDown":y?"ArrowLeft":"ArrowRight",L=g?"ArrowUp":y?"ArrowRight":"ArrowLeft",M;if(p.key===A)M=d[(E+1)%d.length];if(p.key===L)M=d[(E-1+d.length)%d.length];if(p.key==="Home")M=d[0];if(p.key==="End")M=d.at(-1);if(M)p.preventDefault(),c(M,!0)},{signal:a})}function N(t,a){let b=t.ownerDocument,i=b.defaultView,l=()=>i.getComputedStyle(t).direction==="rtl",o=()=>[...t.children].filter((n)=>n.getClientRects().length>0),u=(n)=>{let d=t.getBoundingClientRect(),E=n.getBoundingClientRect();return l()?d.right-E.right:E.left-d.left},f=()=>{let n=-1,d=1/0;return o().forEach((E,g)=>{let y=Math.abs(u(E));if(y<d-1)d=y,n=g}),n},s=(n)=>Math.max(0,Math.min(o().length-1,Math.trunc(n)||0)),r=()=>t.id?[...b.querySelectorAll("[data-b3-reel-to]")].filter((n)=>n.getAttribute("aria-controls")===t.id):[],c=(n=!0)=>{let d=f(),E=t.dataset.b3ReelIndex;if(d<0)delete t.dataset.b3ReelIndex;else if(E!==String(d))t.dataset.b3ReelIndex=String(d);for(let g of r()){let y=g.dataset.b3ReelTo;if(String(d)===y){if(g.getAttribute("aria-current")!=="true")g.setAttribute("aria-current","true")}else if(Number.isInteger(Number(y)))g.removeAttribute("aria-current")}if(n&&E!==void 0&&E!==String(d))t.dispatchEvent(new CustomEvent("b3-reel-change",{bubbles:!0,detail:{index:d,count:o().length}}))},h=(n,d="smooth")=>{let E=o()[s(n)];if(!E)return;let g=u(E);t.scrollBy({left:l()?-g:g,behavior:d})},m=new i.ResizeObserver(()=>c(!1));m.observe(t);let p=new i.MutationObserver(()=>c(!1));p.observe(t,{attributes:!0,attributeFilter:["data-b3-reel-index"]}),a.addEventListener("abort",()=>{m.disconnect(),p.disconnect()},{once:!0});let e=0;return t.addEventListener("scroll",()=>{i.cancelAnimationFrame(e),e=i.requestAnimationFrame(()=>c())},{signal:a}),b.addEventListener("click",(n)=>{let d=n.target.closest?.("[data-b3-reel-to]");if(!d||!t.id||d.getAttribute("aria-controls")!==t.id)return;let E=d.dataset.b3ReelTo,g=f();h(E==="next"?g+1:E==="previous"?g-1:Number(E))},{signal:a}),t.addEventListener("keydown",(n)=>{if(n.target!==t)return;let d=f(),E=l()?"ArrowLeft":"ArrowRight",g=l()?"ArrowRight":"ArrowLeft",y;if(n.key===E)y=d+1;if(n.key===g)y=d-1;if(n.key==="Home")y=0;if(n.key==="End")y=o().length-1;if(y===void 0)return;n.preventDefault(),h(y)},{signal:a}),c(!1),{get index(){return f()},get count(){return o().length},to:h}}var rt=["transform","inset-block-start","inset-block-end","max-block-size","max-inline-size","min-inline-size"];function F(t,a){let b=t.ownerDocument,i=b.defaultView,l=null,o=()=>t.querySelector(".b3-dropdown-panel");function u(s){if(!l)return;for(let[r,c,h]of l)if(c)s.style.setProperty(r,c,h);else s.style.removeProperty(r)}a.addEventListener("abort",()=>{let s=o();if(s)u(s);l=null},{once:!0});function f(){let s=o();if(!s)return;if(u(s),!t.open){l=null;return}l??=rt.map((L)=>[L,s.style.getPropertyValue(L),s.style.getPropertyPriority(L)]);let r={left:0,right:i.innerWidth,top:0,bottom:i.innerHeight};for(let L=t.parentElement;L;L=L.parentElement){let M=i.getComputedStyle(L),v=L.getBoundingClientRect(),S=L.offsetWidth?v.width/L.offsetWidth:1,R=L.offsetHeight?v.height/L.offsetHeight:1,O=v.left+L.clientLeft*S,q=v.top+L.clientTop*R;if(/^(auto|scroll|hidden|clip)$/.test(M.overflowX))r.left=Math.max(r.left,O),r.right=Math.min(r.right,O+L.clientWidth*S);if(/^(auto|scroll|hidden|clip)$/.test(M.overflowY))r.top=Math.max(r.top,q),r.bottom=Math.min(r.bottom,q+L.clientHeight*R)}let c=t.getBoundingClientRect();if(c.bottom<=r.top||c.top>=r.bottom||c.right<=r.left||c.left>=r.right){t.open=!1;return}let h=Math.max(0,r.right-r.left-16),m=s.getBoundingClientRect(),p=s.offsetWidth?m.width/s.offsetWidth:1,e=s.offsetHeight?m.height/s.offsetHeight:1;if(!(p>0&&e>0))return;if(m.width>h)s.style.minInlineSize="0",s.style.maxInlineSize=`${h/p}px`;let n=s.getBoundingClientRect(),d=n.left<r.left+8?r.left+8-n.left:n.right>r.right-8?r.right-8-n.right:0;s.style.transform=`translateX(${d/p}px)`;let E=Math.max(0,n.top-c.bottom),g=Math.max(0,r.bottom-c.bottom-E-8),y=Math.max(0,c.top-r.top-E-8),A=n.height>g&&y>g;if(s.style.maxBlockSize=`${Math.min(n.height,A?y:g)/e}px`,A)s.style.insetBlockStart="auto",s.style.insetBlockEnd="calc(100% + .5rem)"}t.addEventListener("toggle",f,{signal:a}),i.addEventListener("resize",()=>{if(t.open)f()},{signal:a}),i.addEventListener("scroll",(s)=>{if(!t.open||s.target?.nodeType&&o()?.contains(s.target))return;f()},{signal:a,capture:!0,passive:!0}),t.addEventListener("keydown",(s)=>{if(s.key!=="Escape"||s.target.closest?.("details[open]")!==t)return;t.open=!1,t.querySelector("summary")?.focus()},{signal:a}),b.addEventListener("click",(s)=>{if(t.open&&!t.contains(s.target))t.open=!1},{signal:a})}var T=new WeakMap;var ot={enter:{keyframes:[{opacity:0,transform:"translateY(12px) scale(.985)"},{opacity:1,transform:"none"}],duration:320},exit:{keyframes:[{opacity:1,transform:"none"},{opacity:0,transform:"translateY(-6px) scale(.98)"}],duration:180,easing:"cubic-bezier(.4,0,1,1)"},update:{keyframes:[{opacity:0.35},{opacity:1}],duration:180},confirm:{keyframes:[{transform:"scale(.9)"},{transform:"scale(1.08)",offset:0.5},{transform:"scale(.985)",offset:0.8},{transform:"scale(1)"}],duration:380},reveal:{keyframes:[{opacity:0,clipPath:"inset(0 0 100%)",transform:"translateY(8px)"},{opacity:1,clipPath:"inset(0)",transform:"none"}],duration:440}},H=(t)=>!!(t.ownerDocument?.defaultView?.matchMedia("(prefers-reduced-motion: reduce)").matches||t.closest('[data-b3-motion="reduce"]'));function D(t,a,b){if(T.get(t)?.cancel(),!t.isConnected||!t.animate||H(t))return null;let i=t.animate(a,{easing:"cubic-bezier(.16,1,.3,1)",fill:"backwards",...b});T.set(t,i);let l=t.ownerDocument.defaultView.matchMedia("(prefers-reduced-motion: reduce)"),o=()=>{if(l.matches)i.cancel()};l.addEventListener("change",o);let u=()=>{if(l.removeEventListener("change",o),T.get(t)===i)T.delete(t)};return i.addEventListener("finish",u,{once:!0}),i.addEventListener("cancel",u,{once:!0}),i}function I(t,a="update",b={}){let i=ot[a];if(!i)throw TypeError(`Unknown motion intent: ${a}`);return D(t,i.keyframes,{duration:i.duration,easing:i.easing||"cubic-bezier(.16,1,.3,1)",delay:Math.min(200,Math.max(0,b.delay||0))})}function it(t,a="enter"){return Array.from(t,(b,i)=>I(b,a,{delay:Math.min(i*45,180)})).filter((b)=>!!b)}function st(t,a){let b=()=>{let o=new Map;for(let u of t.querySelectorAll("[data-b3-layout]")){let f=u.dataset.b3Layout;if(!f||o.has(f))throw Error("Layout motion requires unique, non-empty data-b3-layout keys");o.set(f,{element:u,rect:u.getBoundingClientRect()})}return o},i=b();for(let{element:o}of i.values())T.get(o)?.cancel();a();let l=[];for(let[o,{element:u,rect:f}]of b()){let s=i.get(o);if(!s||s.element!==u){let n=I(u,"enter");if(n)l.push(n);continue}let r=s.rect;if(!f.width||!f.height||!r.width||!r.height)continue;let c=r.x-f.x,h=r.y-f.y,m=r.width/f.width,p=r.height/f.height;if(Math.abs(c)+Math.abs(h)+Math.abs(m-1)+Math.abs(p-1)<0.01)continue;let e=D(u,[{transformOrigin:"top left",transform:`translate(${c}px,${h}px) scale(${m},${p})`},{transformOrigin:"top left",transform:"none"}],{duration:420});if(e)l.push(e)}return l}function B(t,{x:a=0,y:b=0}={}){if(!Number.isFinite(a)||!Number.isFinite(b))throw TypeError("Settle displacement must be finite");let i=Array.from({length:41},(l,o)=>{let u=o/40,f=o===40?0:Math.exp(-7*u)*(Math.cos(11*u)+0.6*Math.sin(11*u));return{offset:u,transform:`translate(${a*f}px,${b*f}px)`}});return D(t,i,{duration:460,easing:"linear"})}function V(t,{signal:a,backdrop:b}){let i=t.ownerDocument,l=i.defaultView,o={signal:a},u=null,f=null,s=null,r=!1,c=(e)=>{let n=t.getBoundingClientRect();return e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom},h=()=>{f=null,delete t.dataset.b3Closing},m=()=>{if(!t.open||f)return!1;if(!t.dispatchEvent(new Event("cancel",{cancelable:!0})))return!1;if(H(t)||!t.animate)return t.close(),!0;let e=l.getComputedStyle(t),n=t.matches(".b3-sheet")?"translateY(100%)":t.dataset.b3Placement==="end"?`translateX(${e.direction==="rtl"?"-":""}100%)`:"scale(.985)",d=t.animate([{transform:e.transform,opacity:1},{transform:n,opacity:0}],{duration:160,easing:"cubic-bezier(.4, 0, 1, 1)"});return f=d,t.dataset.b3Closing="",d.finished.then(()=>{if(t.open)t.close()},()=>{}).finally(()=>{if(f===d)h()}),!0},p=(e=null)=>{if(u=e,!t.open)t.showModal()};return t.addEventListener("cancel",(e)=>{if(!e.cancelable||e.defaultPrevented||!e.isTrusted||e.target!==t)return;e.preventDefault(),e.stopImmediatePropagation(),m()},{...o,capture:!0}),a.addEventListener("abort",()=>{f?.cancel(),h()},{once:!0}),t.addEventListener("pointerdown",(e)=>{r=!1,s=e.isPrimary&&e.button===0&&e.target===t&&b()&&t.matches(":modal")&&c(e)?e.pointerId:null},o),t.addEventListener("pointerup",(e)=>{let n=s;if(s=null,n!==null&&n===e.pointerId&&e.target===t&&c(e))r=!0},o),t.addEventListener("pointercancel",()=>{s=null,r=!1},o),t.addEventListener("click",(e)=>{let n=r;if(r=!1,!n||e.target!==t||!c(e))return;e.preventDefault(),e.stopImmediatePropagation(),m()},{...o,capture:!0}),t.addEventListener("close",(e)=>{if(e.target!==t)return;f?.cancel(),h();let n=u;if(u=null,n?.isConnected&&!n.disabled)n.focus()},{...o,capture:!0}),t.addEventListener("click",(e)=>{let n=e.target.closest?.("[data-b3-close]");if(n&&!n.disabled&&n.closest("dialog")===t)m()},o),i.addEventListener("click",(e)=>{let n=e.target.closest?.("[data-b3-open]");if(n&&!n.disabled&&t.id&&n.dataset.b3Open===t.id)p(n)},o),{dismiss:m,show:p}}var at=["tabindex","autofocus","data-b3-initial-focus"];function Y(t,a){let b=t.ownerDocument,i=null,l=()=>{if(!i)return;let{title:u,original:f}=i;for(let[s,r]of Object.entries(f)){let c=s==="tabindex"?"-1":"";if(u.getAttribute(s)!==c)continue;if(r===null)u.removeAttribute(s);else u.setAttribute(s,r)}i=null},o=()=>{if([...t.querySelectorAll("[autofocus]")].find((r)=>r!==i?.title))return l();let f=t.getAttribute("aria-labelledby")?.trim().split(/\s+/)[0],s=f?b.getElementById(f):null;if(!s||!t.contains(s)||i?.title===s)return;l(),i={title:s,original:Object.fromEntries(at.map((r)=>[r,s.getAttribute(r)]))},s.setAttribute("tabindex","-1"),s.setAttribute("autofocus",""),s.setAttribute("data-b3-initial-focus","")};o(),t.addEventListener("beforetoggle",(u)=>{if(u.newState==="open")o()},{signal:a}),a.addEventListener("abort",l,{once:!0})}function W(t,a,b){let i={signal:b},l=null,o=null,u=null,f=(r,c=!0)=>{let{handle:h,pointerId:m,distance:p}=r;if(l=null,delete t.dataset.b3Dragging,t.style.removeProperty("transform"),h.hasPointerCapture(m))h.releasePointerCapture(m);if(c&&p&&t.open&&!H(t)){let e=B(t,{y:p});if(!e)return;u=e,e.finished.catch(()=>{}).finally(()=>{if(u===e)u=null})}};t.addEventListener("pointerdown",(r)=>{o=null;let c=r.target.closest?.(".b3-sheet-handle");if(!c||c.closest("dialog")!==t||!t.matches(":modal"))return;if(l||!r.isPrimary||r.button!==0||t.hasAttribute("data-b3-closing"))return;u?.cancel();for(let h of t.getAnimations())h.cancel();l={handle:c,pointerId:r.pointerId,y:r.clientY,distance:0,moved:!1},t.dataset.b3Dragging="",c.setPointerCapture(r.pointerId)},i),t.addEventListener("pointermove",(r)=>{if(!l||r.pointerId!==l.pointerId)return;l.distance=Math.max(0,r.clientY-l.y),l.moved||=Math.abs(r.clientY-l.y)>6,t.style.transform=`translateY(${l.distance}px)`},i),t.addEventListener("pointerup",(r)=>{if(!l||r.pointerId!==l.pointerId)return;let c=l;if(c.moved)o={pointerId:c.pointerId,handle:c.handle};let h=Math.min(120,t.offsetHeight*0.25);if(c.moved&&c.distance>=h){let m=a();f(c,!m)}else f(c)},i);let s=(r)=>{if(l&&r.pointerId===l.pointerId)f(l)};t.addEventListener("pointercancel",s,i),t.addEventListener("lostpointercapture",s,i),t.addEventListener("click",(r)=>{let c=o;if(o=null,c&&r.detail!==0&&(r.pointerId===c.pointerId||c.handle.contains(r.target)))r.preventDefault(),r.stopImmediatePropagation()},{...i,capture:!0}),t.addEventListener("close",()=>{if(l)f(l,!1);u?.cancel()},{...i,capture:!0}),b.addEventListener("abort",()=>{if(l)f(l,!1);u?.cancel(),u=null},{once:!0})}function z(t,a){let b={signal:a},i=()=>{let e=t.querySelector('input[role="combobox"]'),n=t.querySelector('[role="listbox"]');if(!e||!n?.id||e.getAttribute("aria-controls")!==n.id)return null;return{input:e,list:n,empty:t.querySelector("[data-b3-command-empty]"),status:t.querySelector("[data-b3-command-status]")}},l=null,o=[],u=(e)=>[...e.querySelectorAll('[role="option"]')];function f(e,n=!0){let d=i();if(!d)return;l=e||null;for(let E of u(d.list))E.setAttribute("aria-selected",String(E===l));if(l){if(d.input.setAttribute("aria-activedescendant",l.id),n)l.scrollIntoView({block:"nearest"})}else d.input.removeAttribute("aria-activedescendant")}function s(){let e=i();if(!e)return;let{input:n,list:d,empty:E,status:g}=e,y=n.value.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean),A=u(d);for(let M of A){let v=`${M.textContent} ${M.dataset.b3Keywords||""}`.toLocaleLowerCase();M.hidden=!y.every((S)=>v.includes(S))}for(let M of d.querySelectorAll('[role="group"]'))M.hidden=![...M.querySelectorAll('[role="option"]')].some((v)=>!v.hidden);let L=A.filter((M)=>!M.hidden);if(o=L.filter((M)=>M.id&&M.getAttribute("aria-disabled")!=="true"),d.hidden=!L.length,n.setAttribute("aria-expanded",String(t.open&&!!L.length)),E)E.hidden=!!L.length;if(g)g.textContent=`${o.length} ${o.length===1?"action":"actions"} available.`;f(o[0],t.open&&!!d.parentElement?.classList.contains("b3-scroll"))}let r=()=>{if(!o.every((e)=>e.isConnected)||l&&!l.isConnected)s();return i()};function c(e){let n=r();if(!n||!e||!o.includes(e)||e.hidden||e.getAttribute("aria-disabled")==="true"||!n.list.contains(e))return;if(t.dispatchEvent(new CustomEvent("b3:command",{bubbles:!0,cancelable:!0,detail:{value:e.dataset.b3Value,item:e}})))t.close()}let h=(e)=>e.target===i()?.input;t.addEventListener("input",(e)=>{if(h(e))s()},b),t.addEventListener("keydown",(e)=>{if(!h(e)||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),r(),!o.length)return;let n=o.indexOf(l),d=e.key==="ArrowDown"?Math.min(n+1,o.length-1):Math.max(n-1,0);f(o[d])}else if(e.key==="Enter")e.preventDefault(),r(),c(l)},b);let m=(e)=>{let n=e.target.closest?.('[role="option"]');return n&&i()?.list.contains(n)?n:null};t.addEventListener("pointerdown",(e)=>{if(m(e))e.preventDefault()},b),t.addEventListener("click",(e)=>{let n=m(e);if(n)c(n)},b);let p=new MutationObserver(()=>{let e=i();if(t.open){if(e)e.input.value="";s()}else if(e)e.input.setAttribute("aria-expanded","false"),e.input.removeAttribute("aria-activedescendant")});p.observe(t,{attributes:!0,attributeFilter:["open"]}),a.addEventListener("abort",()=>p.disconnect(),{once:!0}),s()}function K(t,a){let b=t.ownerDocument;t.addEventListener("click",(i)=>{let l=i.target.closest?.("[data-b3-dismiss]"),o=l?.closest(".b3-toast");if(!l||!o||l.disabled||!t.contains(o))return;let u=o.contains(b.activeElement),f=[...t.querySelectorAll(".b3-toast")],s=f.indexOf(o),r=o.dataset.b3ReturnFocus||t.dataset.b3ReturnFocus,c=r?b.getElementById(r):null;if(o.remove(),!u)return;let h=[...f.slice(s+1),...f.slice(0,s).reverse()].flatMap((m)=>[...m.querySelectorAll("[data-b3-dismiss]")]);if(c)h.push(c);if(t.hasAttribute("tabindex"))h.push(t);for(let m of h){if(!m.isConnected||m.matches(":disabled")||m.closest("[inert]")||!m.getClientRects().length)continue;if(m.focus(),b.activeElement===m)break}},{signal:a})}function X(t,a){let b=t.ownerDocument,i=b.defaultView,l=()=>[...t.querySelectorAll('a[href^="#"]')].flatMap((c)=>{let h;try{h=decodeURIComponent(c.getAttribute("href").slice(1))}catch{return[]}let m=b.getElementById(h);if(!m)c.removeAttribute("aria-current");return m?[{link:c,heading:m}]:[]});function o(c){for(let h=c.parentElement;h&&h!==b.body;h=h.parentElement)if(h.scrollHeight>h.clientHeight+1&&/(auto|scroll)/.test(i.getComputedStyle(h).overflowY))return h;return null}let u=0;function f(){u=0;let c=l(),h=c.filter(({heading:g})=>g.getClientRects().length).sort((g,y)=>g.heading.getBoundingClientRect().top-y.heading.getBoundingClientRect().top),m=h.length?o(h[0].heading):null,p=m?m.getBoundingClientRect().top+m.clientTop:0,e=h[0];for(let g of h){let y=parseFloat(i.getComputedStyle(g.heading).scrollMarginBlockStart)||0;if(g.heading.getBoundingClientRect().top<=p+y+1)e=g}let n=m?m.scrollTop:i.scrollY,d=m?m.clientHeight:i.innerHeight,E=m?m.scrollHeight:b.documentElement.scrollHeight;if(n>0&&n+d>=E-2)e=h.at(-1);for(let g of c)if(g!==e)g.link.removeAttribute("aria-current");else if(g.link.getAttribute("aria-current")!=="location")g.link.setAttribute("aria-current","location")}let s=()=>{if(!u)u=i.requestAnimationFrame(f)};i.addEventListener("scroll",s,{signal:a,capture:!0,passive:!0}),i.addEventListener("resize",s,{signal:a}),i.addEventListener("hashchange",s,{signal:a});let r=new i.MutationObserver(s);r.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-current","href"]}),r.observe(b.body,{childList:!0,subtree:!0}),a.addEventListener("abort",()=>{i.cancelAnimationFrame(u),r.disconnect()},{once:!0}),f()}function lt(t,a){let b=t.ownerDocument||t,i=b.defaultView,l={signal:a},o=null,u=null,f=0,s=null,r=0,c=null,h=new i.MutationObserver((e)=>{if(!o.isConnected||e.some(({target:n})=>u.contains(n)&&!c.contains(n)))m()});function m(){if(!o)return;i.clearTimeout(r),h.disconnect();let e=o.dataset.b3Confirm;if(s&&e&&o.textContent===e)o.replaceChildren(...s);o.removeAttribute("data-b3-armed"),o=u=s=null,c.textContent=""}function p(e){if(!c?.isConnected)c=b.createElement("span"),c.className="b3-visually-hidden",c.setAttribute("role","status"),b.body.append(c);let n=c;o=e,f=i.performance.now(),u=e.parentElement.closest("li, tr, article, [data-id], .b3-row, .b3-card")||e.parentElement;let d=e.dataset.b3Confirm;if(d)s=[...e.childNodes],e.replaceChildren(d);e.setAttribute("data-b3-armed",""),h.observe(t,{childList:!0,subtree:!0}),h.observe(u,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),r=i.setTimeout(m,4000),i.requestAnimationFrame(()=>{if(o===e)n.textContent=d||"Press again to confirm"})}t.addEventListener("click",(e)=>{let n=e.target.closest?.("[data-b3-confirm]");if(o&&n!==o)m();if(!n||n.disabled||!t.contains(n))return;if(n===o&&i.performance.now()-f>=350)return m();if(e.preventDefault(),e.stopImmediatePropagation(),n!==o)p(n)},{...l,capture:!0}),t.addEventListener("focusout",({target:e})=>{if(e===o)i.queueMicrotask(()=>e===o&&m())},l),t.addEventListener("keydown",(e)=>{let n=e;if(n.key==="Escape")m();else if(n.repeat&&(n.key==="Enter"||n.key===" ")&&n.target.closest?.("[data-b3-confirm]"))n.preventDefault()},{...l,capture:!0}),a?.addEventListener("abort",()=>{m(),c?.remove()},{once:!0})}var j=Symbol.for("bare-v3.confirm");function U(){if(typeof document>"u"||!document.defaultView?.MutationObserver)return;let t=document;if(t[j])return;t[j]=!0,lt(document)}class G extends w{mount(t,a){P(t,a)}}class _ extends w{#t=null;get index(){return this.#t?.index??-1}set index(t){this.#t?.to(t)}get count(){return this.#t?.count??0}to(t,a){this.#t?.to(t,a)}mount(t,a){k(t,a,{tabindex:"0"},["b3-reel"]),this.#t=N(t,a),a.addEventListener("abort",()=>{this.#t=null},{once:!0})}}class J extends w{target(){return this.querySelector(":scope > details")}mount(t,a){F(t,a)}}class C extends w{#t=null;target(){return this.querySelector(":scope > dialog")}mount(t,a){this.#t=V(t,{signal:a,backdrop:()=>this.getAttribute("backdrop")==="dismiss"}),a.addEventListener("abort",()=>{this.#t=null},{once:!0})}show(t){if(this.#t)this.#t.show(t??null);else if(!this.target()?.open)this.target()?.showModal()}close(){if(this.#t)return this.#t.dismiss();return this.target()?.close(),!0}}class Q extends C{mount(t,a){super.mount(t,a),Y(t,a),W(t,()=>this.close(),a)}}class Z extends C{mount(t,a){super.mount(t,a),z(t,a)}}class tt extends w{mount(t,a){k(t,a,{},["b3-toast-region"]),K(t,a)}}class et extends w{mount(t,a){k(t,a,{role:"navigation"},["b3-toc"]),X(t,a)}}x("b3-tabs",G);x("b3-reel",_);x("b3-dropdown",J);x("b3-dialog",C);x("b3-sheet",Q);x("b3-command",Z);x("b3-toast-region",tt);x("b3-toc",et);U();export{Z as B3Command,C as B3Dialog,J as B3Dropdown,_ as B3Reel,Q as B3Sheet,G as B3Tabs,tt as B3ToastRegion,et as B3Toc,st as layout,I as motion,it as sequence,B as settle};
|
|
1
|
+
var nt=typeof HTMLElement==="function"?HTMLElement:class{};function x(t,s){if(typeof customElements>"u"||customElements.get?.(t))return;try{customElements.define(t,s)}catch(b){console.warn(`bare-v3: ${t} was not registered`,b)}}class w extends nt{#t=null;#n=null;#e=null;target(){return this}connectedCallback(){let t=this.ownerDocument;if(t.readyState==="loading"){t.addEventListener("DOMContentLoaded",()=>{if(this.isConnected)this.#r()},{once:!0});return}this.#r()}disconnectedCallback(){this.#o(),this.#e?.disconnect(),this.#e=null}#r(){if(this.#t)return;let t=this.target();if(t!==this&&!this.#e)this.#e=new MutationObserver(()=>{if(this.target()!==this.#n)this.#o(),this.#r()}),this.#e.observe(this,{childList:!0});if(!t)return;this.#t=new AbortController,this.#n=t,this.mount(t,this.#t.signal)}#o(){this.#t?.abort(),this.#t=null,this.#n=null}}function k(t,s,b={},i=[]){let l=()=>{for(let u of i)if(!t.classList.contains(u))t.classList.add(u);for(let[u,f]of Object.entries(b))if(!t.hasAttribute(u))t.setAttribute(u,f)};l();let r=new MutationObserver(l);r.observe(t,{attributes:!0,attributeFilter:["class",...Object.keys(b)]}),s.addEventListener("abort",()=>r.disconnect(),{once:!0})}function P(t,s){let b=t.ownerDocument,i=(p)=>p.closest(t.localName)===t,l=(p)=>[...p.querySelectorAll('[role="tab"]')].filter((e)=>e.closest('[role="tablist"]')===p),r=new WeakMap,u=(p,e,n)=>{if(p.getAttribute(e)!==n)p.setAttribute(e,n)},f=()=>[...t.querySelectorAll('[role="tablist"]')].filter(i);function a(p,e){r.set(p,e);for(let n of l(p))u(n,"aria-selected",String(n===e)),u(n,"tabindex",n===e?"0":"-1")}function o(){let p=new Map;for(let e of f()){let n=r.get(e);if(!n)continue;for(let d of l(e)){let E=d.getAttribute("aria-controls"),g=E?b.getElementById(E):null;if(g)p.set(g,d===n||!!p.get(g))}}for(let[e,n]of p)if(e.hidden===n)e.hidden=!n}function c(p,e=!1){let n=p.closest('[role="tablist"]');if(!n||p.disabled)return;if(a(n,p),o(),e)p.focus({preventScroll:!0}),p.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"})}function h(){for(let p of f()){let e=l(p).filter((g)=>!g.disabled),n=r.get(p),E=e.filter((g)=>g.getAttribute("aria-selected")==="true").find((g)=>g!==n)??(n&&e.includes(n)?n:e[0]);if(E)a(p,E)}o()}h();let m=new b.defaultView.MutationObserver(h);m.observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["aria-selected","tabindex","hidden"]}),s.addEventListener("abort",()=>m.disconnect(),{once:!0}),t.addEventListener("click",(p)=>{let e=p.target.closest?.('[role="tab"]'),n=e?.closest('[role="tablist"]');if(e&&n&&i(n)&&!e.disabled)c(e)},{signal:s}),t.addEventListener("keydown",(p)=>{let e=p.target.closest?.('[role="tab"]'),n=e?.closest('[role="tablist"]');if(!e||!n||!i(n))return;let d=l(n).filter((v)=>!v.disabled),E=d.indexOf(e),g=n.getAttribute("aria-orientation")==="vertical",y=b.defaultView.getComputedStyle(n).direction==="rtl",A=g?"ArrowDown":y?"ArrowLeft":"ArrowRight",L=g?"ArrowUp":y?"ArrowRight":"ArrowLeft",M;if(p.key===A)M=d[(E+1)%d.length];if(p.key===L)M=d[(E-1+d.length)%d.length];if(p.key==="Home")M=d[0];if(p.key==="End")M=d.at(-1);if(M)p.preventDefault(),c(M,!0)},{signal:s})}function N(t,s){let b=t.ownerDocument,i=b.defaultView,l=()=>i.getComputedStyle(t).direction==="rtl",r=()=>[...t.children].filter((n)=>n.getClientRects().length>0),u=(n)=>{let d=t.getBoundingClientRect(),E=n.getBoundingClientRect();return l()?d.right-E.right:E.left-d.left},f=()=>{let n=-1,d=1/0;return r().forEach((E,g)=>{let y=Math.abs(u(E));if(y<d-1)d=y,n=g}),n},a=(n)=>Math.max(0,Math.min(r().length-1,Math.trunc(n)||0)),o=()=>t.id?[...b.querySelectorAll("[data-b3-reel-to]")].filter((n)=>n.getAttribute("aria-controls")===t.id):[],c=(n=!0)=>{let d=f(),E=t.dataset.b3ReelIndex;if(d<0)delete t.dataset.b3ReelIndex;else if(E!==String(d))t.dataset.b3ReelIndex=String(d);for(let g of o()){let y=g.dataset.b3ReelTo;if(String(d)===y){if(g.getAttribute("aria-current")!=="true")g.setAttribute("aria-current","true")}else if(Number.isInteger(Number(y)))g.removeAttribute("aria-current")}if(n&&E!==void 0&&E!==String(d))t.dispatchEvent(new CustomEvent("b3-reel-change",{bubbles:!0,detail:{index:d,count:r().length}}))},h=(n,d="smooth")=>{let E=r()[a(n)];if(!E)return;let g=u(E);t.scrollBy({left:l()?-g:g,behavior:d})},m=new i.ResizeObserver(()=>c(!1));m.observe(t);let p=new i.MutationObserver(()=>c(!1));p.observe(t,{attributes:!0,attributeFilter:["data-b3-reel-index"]}),s.addEventListener("abort",()=>{m.disconnect(),p.disconnect()},{once:!0});let e=0;return t.addEventListener("scroll",()=>{i.cancelAnimationFrame(e),e=i.requestAnimationFrame(()=>c())},{signal:s}),b.addEventListener("click",(n)=>{let d=n.target.closest?.("[data-b3-reel-to]");if(!d||!t.id||d.getAttribute("aria-controls")!==t.id)return;let E=d.dataset.b3ReelTo,g=f();h(E==="next"?g+1:E==="previous"?g-1:Number(E))},{signal:s}),t.addEventListener("keydown",(n)=>{if(n.target!==t)return;let d=f(),E=l()?"ArrowLeft":"ArrowRight",g=l()?"ArrowRight":"ArrowLeft",y;if(n.key===E)y=d+1;if(n.key===g)y=d-1;if(n.key==="Home")y=0;if(n.key==="End")y=r().length-1;if(y===void 0)return;n.preventDefault(),h(y)},{signal:s}),c(!1),{get index(){return f()},get count(){return r().length},to:h}}var rt=["transform","inset-block-start","inset-block-end","max-block-size","max-inline-size","min-inline-size"];function F(t,s){let b=t.ownerDocument,i=b.defaultView,l=null,r=()=>t.querySelector(".b3-dropdown-panel");function u(a){if(!l)return;for(let[o,c,h]of l)if(c)a.style.setProperty(o,c,h);else a.style.removeProperty(o)}s.addEventListener("abort",()=>{let a=r();if(a)u(a);l=null},{once:!0});function f(){let a=r();if(!a)return;if(u(a),!t.open){l=null;return}l??=rt.map((L)=>[L,a.style.getPropertyValue(L),a.style.getPropertyPriority(L)]);let o={left:0,right:i.innerWidth,top:0,bottom:i.innerHeight};for(let L=t.parentElement;L;L=L.parentElement){let M=i.getComputedStyle(L),v=L.getBoundingClientRect(),S=L.offsetWidth?v.width/L.offsetWidth:1,R=L.offsetHeight?v.height/L.offsetHeight:1,O=v.left+L.clientLeft*S,q=v.top+L.clientTop*R;if(/^(auto|scroll|hidden|clip)$/.test(M.overflowX))o.left=Math.max(o.left,O),o.right=Math.min(o.right,O+L.clientWidth*S);if(/^(auto|scroll|hidden|clip)$/.test(M.overflowY))o.top=Math.max(o.top,q),o.bottom=Math.min(o.bottom,q+L.clientHeight*R)}let c=t.getBoundingClientRect();if(c.bottom<=o.top||c.top>=o.bottom||c.right<=o.left||c.left>=o.right){t.open=!1;return}let h=Math.max(0,o.right-o.left-16),m=a.getBoundingClientRect(),p=a.offsetWidth?m.width/a.offsetWidth:1,e=a.offsetHeight?m.height/a.offsetHeight:1;if(!(p>0&&e>0))return;if(m.width>h)a.style.minInlineSize="0",a.style.maxInlineSize=`${h/p}px`;let n=a.getBoundingClientRect(),d=n.left<o.left+8?o.left+8-n.left:n.right>o.right-8?o.right-8-n.right:0;a.style.transform=`translateX(${d/p}px)`;let E=Math.max(0,n.top-c.bottom),g=Math.max(0,o.bottom-c.bottom-E-8),y=Math.max(0,c.top-o.top-E-8),A=n.height>g&&y>g;if(a.style.maxBlockSize=`${Math.min(n.height,A?y:g)/e}px`,A)a.style.insetBlockStart="auto",a.style.insetBlockEnd="calc(100% + .5rem)"}t.addEventListener("toggle",f,{signal:s}),i.addEventListener("resize",()=>{if(t.open)f()},{signal:s}),i.addEventListener("scroll",(a)=>{if(!t.open||a.target?.nodeType&&r()?.contains(a.target))return;f()},{signal:s,capture:!0,passive:!0}),t.addEventListener("keydown",(a)=>{if(a.key!=="Escape"||a.target.closest?.("details[open]")!==t)return;t.open=!1,t.querySelector("summary")?.focus()},{signal:s}),b.addEventListener("click",(a)=>{if(t.open&&!t.contains(a.target))t.open=!1},{signal:s})}var T=new WeakMap;var ot={enter:{keyframes:[{opacity:0,transform:"translateY(12px) scale(.985)"},{opacity:1,transform:"none"}],duration:320},exit:{keyframes:[{opacity:1,transform:"none"},{opacity:0,transform:"translateY(-6px) scale(.98)"}],duration:180,easing:"cubic-bezier(.4,0,1,1)"},update:{keyframes:[{opacity:0.35},{opacity:1}],duration:180},confirm:{keyframes:[{transform:"scale(.9)"},{transform:"scale(1.08)",offset:0.5},{transform:"scale(.985)",offset:0.8},{transform:"scale(1)"}],duration:380},reveal:{keyframes:[{opacity:0,clipPath:"inset(0 0 100%)",transform:"translateY(8px)"},{opacity:1,clipPath:"inset(0)",transform:"none"}],duration:440}},H=(t)=>!!(t.ownerDocument?.defaultView?.matchMedia("(prefers-reduced-motion: reduce)").matches||t.closest('[data-b3-motion="reduce"]'));function D(t,s,b){if(T.get(t)?.cancel(),!t.isConnected||!t.animate||H(t))return null;let i=t.animate(s,{easing:"cubic-bezier(.16,1,.3,1)",fill:"backwards",...b});T.set(t,i);let l=t.ownerDocument.defaultView.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{if(l.matches)i.cancel()};l.addEventListener("change",r);let u=()=>{if(l.removeEventListener("change",r),T.get(t)===i)T.delete(t)};return i.addEventListener("finish",u,{once:!0}),i.addEventListener("cancel",u,{once:!0}),i}function I(t,s="update",b={}){let i=ot[s];if(!i)throw TypeError(`Unknown motion intent: ${s}`);let l=i.keyframes,r=T.get(t);if((s==="enter"||s==="exit")&&r&&(r.playState==="running"||r.playState==="paused")){let u=t.ownerDocument.defaultView.getComputedStyle(t);l=[{...i.keyframes[0],opacity:u.opacity,transform:u.transform},...i.keyframes.slice(1)]}return D(t,l,{duration:i.duration,easing:i.easing||"cubic-bezier(.16,1,.3,1)",delay:Math.min(200,Math.max(0,b.delay||0))})}function it(t,s="enter"){return Array.from(t,(b,i)=>I(b,s,{delay:Math.min(i*45,180)})).filter((b)=>!!b)}function st(t,s){let b=()=>{let r=new Map;for(let u of t.querySelectorAll("[data-b3-layout]")){let f=u.dataset.b3Layout;if(!f||r.has(f))throw Error("Layout motion requires unique, non-empty data-b3-layout keys");r.set(f,{element:u,rect:u.getBoundingClientRect()})}return r},i=b();for(let{element:r}of i.values())T.get(r)?.cancel();s();let l=[];for(let[r,{element:u,rect:f}]of b()){let a=i.get(r);if(!a||a.element!==u){let n=I(u,"enter");if(n)l.push(n);continue}let o=a.rect;if(!f.width||!f.height||!o.width||!o.height)continue;let c=o.x-f.x,h=o.y-f.y,m=o.width/f.width,p=o.height/f.height;if(Math.abs(c)+Math.abs(h)+Math.abs(m-1)+Math.abs(p-1)<0.01)continue;let e=D(u,[{transformOrigin:"top left",transform:`translate(${c}px,${h}px) scale(${m},${p})`},{transformOrigin:"top left",transform:"none"}],{duration:420});if(e)l.push(e)}return l}function B(t,{x:s=0,y:b=0}={}){if(!Number.isFinite(s)||!Number.isFinite(b))throw TypeError("Settle displacement must be finite");let i=Array.from({length:41},(l,r)=>{let u=r/40,f=r===40?0:Math.exp(-7*u)*(Math.cos(11*u)+0.6*Math.sin(11*u));return{offset:u,transform:`translate(${s*f}px,${b*f}px)`}});return D(t,i,{duration:460,easing:"linear"})}function V(t,{signal:s,backdrop:b}){let i=t.ownerDocument,l=i.defaultView,r={signal:s},u=null,f=null,a=null,o=!1,c=(e)=>{let n=t.getBoundingClientRect();return e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom},h=()=>{f=null,delete t.dataset.b3Closing},m=()=>{if(!t.open||f)return!1;if(!t.dispatchEvent(new Event("cancel",{cancelable:!0})))return!1;if(H(t)||!t.animate)return t.close(),!0;let e=l.getComputedStyle(t),n=t.matches(".b3-sheet")?"translateY(100%)":t.dataset.b3Placement==="end"?`translateX(${e.direction==="rtl"?"-":""}100%)`:"scale(.985)",d=t.animate([{transform:e.transform,opacity:1},{transform:n,opacity:0}],{duration:160,easing:"cubic-bezier(.4, 0, 1, 1)"});return f=d,t.dataset.b3Closing="",d.finished.then(()=>{if(t.open)t.close()},()=>{}).finally(()=>{if(f===d)h()}),!0},p=(e=null)=>{if(u=e,!t.open)t.showModal()};return t.addEventListener("cancel",(e)=>{if(!e.cancelable||e.defaultPrevented||!e.isTrusted||e.target!==t)return;e.preventDefault(),e.stopImmediatePropagation(),m()},{...r,capture:!0}),s.addEventListener("abort",()=>{f?.cancel(),h()},{once:!0}),t.addEventListener("pointerdown",(e)=>{o=!1,a=e.isPrimary&&e.button===0&&e.target===t&&b()&&t.matches(":modal")&&c(e)?e.pointerId:null},r),t.addEventListener("pointerup",(e)=>{let n=a;if(a=null,n!==null&&n===e.pointerId&&e.target===t&&c(e))o=!0},r),t.addEventListener("pointercancel",()=>{a=null,o=!1},r),t.addEventListener("click",(e)=>{let n=o;if(o=!1,!n||e.target!==t||!c(e))return;e.preventDefault(),e.stopImmediatePropagation(),m()},{...r,capture:!0}),t.addEventListener("close",(e)=>{if(e.target!==t)return;f?.cancel(),h();let n=u;if(u=null,n?.isConnected&&!n.disabled)n.focus()},{...r,capture:!0}),t.addEventListener("click",(e)=>{let n=e.target.closest?.("[data-b3-close]");if(n&&!n.disabled&&n.closest("dialog")===t)m()},r),i.addEventListener("click",(e)=>{let n=e.target.closest?.("[data-b3-open]");if(n&&!n.disabled&&t.id&&n.dataset.b3Open===t.id)p(n)},r),{dismiss:m,show:p}}var at=["tabindex","autofocus","data-b3-initial-focus"];function Y(t,s){let b=t.ownerDocument,i=null,l=()=>{if(!i)return;let{title:u,original:f}=i;for(let[a,o]of Object.entries(f)){let c=a==="tabindex"?"-1":"";if(u.getAttribute(a)!==c)continue;if(o===null)u.removeAttribute(a);else u.setAttribute(a,o)}i=null},r=()=>{if([...t.querySelectorAll("[autofocus]")].find((o)=>o!==i?.title))return l();let f=t.getAttribute("aria-labelledby")?.trim().split(/\s+/)[0],a=f?b.getElementById(f):null;if(!a||!t.contains(a)||i?.title===a)return;l(),i={title:a,original:Object.fromEntries(at.map((o)=>[o,a.getAttribute(o)]))},a.setAttribute("tabindex","-1"),a.setAttribute("autofocus",""),a.setAttribute("data-b3-initial-focus","")};r(),t.addEventListener("beforetoggle",(u)=>{if(u.newState==="open")r()},{signal:s}),s.addEventListener("abort",l,{once:!0})}function W(t,s,b){let i={signal:b},l=null,r=null,u=null,f=(o,c=!0)=>{let{handle:h,pointerId:m,distance:p}=o;if(l=null,delete t.dataset.b3Dragging,t.style.removeProperty("transform"),h.hasPointerCapture(m))h.releasePointerCapture(m);if(c&&p&&t.open&&!H(t)){let e=B(t,{y:p});if(!e)return;u=e,e.finished.catch(()=>{}).finally(()=>{if(u===e)u=null})}};t.addEventListener("pointerdown",(o)=>{r=null;let c=o.target.closest?.(".b3-sheet-handle");if(!c||c.closest("dialog")!==t||!t.matches(":modal"))return;if(l||!o.isPrimary||o.button!==0||t.hasAttribute("data-b3-closing"))return;u?.cancel();for(let h of t.getAnimations())h.cancel();l={handle:c,pointerId:o.pointerId,y:o.clientY,distance:0,moved:!1},t.dataset.b3Dragging="",c.setPointerCapture(o.pointerId)},i),t.addEventListener("pointermove",(o)=>{if(!l||o.pointerId!==l.pointerId)return;l.distance=Math.max(0,o.clientY-l.y),l.moved||=Math.abs(o.clientY-l.y)>6,t.style.transform=`translateY(${l.distance}px)`},i),t.addEventListener("pointerup",(o)=>{if(!l||o.pointerId!==l.pointerId)return;let c=l;if(c.moved)r={pointerId:c.pointerId,handle:c.handle};let h=Math.min(120,t.offsetHeight*0.25);if(c.moved&&c.distance>=h){let m=s();f(c,!m)}else f(c)},i);let a=(o)=>{if(l&&o.pointerId===l.pointerId)f(l)};t.addEventListener("pointercancel",a,i),t.addEventListener("lostpointercapture",a,i),t.addEventListener("click",(o)=>{let c=r;if(r=null,c&&o.detail!==0&&(o.pointerId===c.pointerId||c.handle.contains(o.target)))o.preventDefault(),o.stopImmediatePropagation()},{...i,capture:!0}),t.addEventListener("close",()=>{if(l)f(l,!1);u?.cancel()},{...i,capture:!0}),b.addEventListener("abort",()=>{if(l)f(l,!1);u?.cancel(),u=null},{once:!0})}function z(t,s){let b={signal:s},i=()=>{let e=t.querySelector('input[role="combobox"]'),n=t.querySelector('[role="listbox"]');if(!e||!n?.id||e.getAttribute("aria-controls")!==n.id)return null;return{input:e,list:n,empty:t.querySelector("[data-b3-command-empty]"),status:t.querySelector("[data-b3-command-status]")}},l=null,r=[],u=(e)=>[...e.querySelectorAll('[role="option"]')];function f(e,n=!0){let d=i();if(!d)return;l=e||null;for(let E of u(d.list))E.setAttribute("aria-selected",String(E===l));if(l){if(d.input.setAttribute("aria-activedescendant",l.id),n)l.scrollIntoView({block:"nearest"})}else d.input.removeAttribute("aria-activedescendant")}function a(){let e=i();if(!e)return;let{input:n,list:d,empty:E,status:g}=e,y=n.value.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean),A=u(d);for(let M of A){let v=`${M.textContent} ${M.dataset.b3Keywords||""}`.toLocaleLowerCase();M.hidden=!y.every((S)=>v.includes(S))}for(let M of d.querySelectorAll('[role="group"]'))M.hidden=![...M.querySelectorAll('[role="option"]')].some((v)=>!v.hidden);let L=A.filter((M)=>!M.hidden);if(r=L.filter((M)=>M.id&&M.getAttribute("aria-disabled")!=="true"),d.hidden=!L.length,n.setAttribute("aria-expanded",String(t.open&&!!L.length)),E)E.hidden=!!L.length;if(g)g.textContent=`${r.length} ${r.length===1?"action":"actions"} available.`;f(r[0],t.open&&!!d.parentElement?.classList.contains("b3-scroll"))}let o=()=>{if(!r.every((e)=>e.isConnected)||l&&!l.isConnected)a();return i()};function c(e){let n=o();if(!n||!e||!r.includes(e)||e.hidden||e.getAttribute("aria-disabled")==="true"||!n.list.contains(e))return;if(t.dispatchEvent(new CustomEvent("b3:command",{bubbles:!0,cancelable:!0,detail:{value:e.dataset.b3Value,item:e}})))t.close()}let h=(e)=>e.target===i()?.input;t.addEventListener("input",(e)=>{if(h(e))a()},b),t.addEventListener("keydown",(e)=>{if(!h(e)||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),o(),!r.length)return;let n=r.indexOf(l),d=e.key==="ArrowDown"?Math.min(n+1,r.length-1):Math.max(n-1,0);f(r[d])}else if(e.key==="Enter")e.preventDefault(),o(),c(l)},b);let m=(e)=>{let n=e.target.closest?.('[role="option"]');return n&&i()?.list.contains(n)?n:null};t.addEventListener("pointerdown",(e)=>{if(m(e))e.preventDefault()},b),t.addEventListener("click",(e)=>{let n=m(e);if(n)c(n)},b);let p=new MutationObserver(()=>{let e=i();if(t.open){if(e)e.input.value="";a()}else if(e)e.input.setAttribute("aria-expanded","false"),e.input.removeAttribute("aria-activedescendant")});p.observe(t,{attributes:!0,attributeFilter:["open"]}),s.addEventListener("abort",()=>p.disconnect(),{once:!0}),a()}function K(t,s){let b=t.ownerDocument;t.addEventListener("click",(i)=>{let l=i.target.closest?.("[data-b3-dismiss]"),r=l?.closest(".b3-toast");if(!l||!r||l.disabled||!t.contains(r))return;let u=r.contains(b.activeElement),f=[...t.querySelectorAll(".b3-toast")],a=f.indexOf(r),o=r.dataset.b3ReturnFocus||t.dataset.b3ReturnFocus,c=o?b.getElementById(o):null;if(r.remove(),!u)return;let h=[...f.slice(a+1),...f.slice(0,a).reverse()].flatMap((m)=>[...m.querySelectorAll("[data-b3-dismiss]")]);if(c)h.push(c);if(t.hasAttribute("tabindex"))h.push(t);for(let m of h){if(!m.isConnected||m.matches(":disabled")||m.closest("[inert]")||!m.getClientRects().length)continue;if(m.focus(),b.activeElement===m)break}},{signal:s})}function X(t,s){let b=t.ownerDocument,i=b.defaultView,l=()=>[...t.querySelectorAll('a[href^="#"]')].flatMap((c)=>{let h;try{h=decodeURIComponent(c.getAttribute("href").slice(1))}catch{return[]}let m=b.getElementById(h);if(!m)c.removeAttribute("aria-current");return m?[{link:c,heading:m}]:[]});function r(c){for(let h=c.parentElement;h&&h!==b.body;h=h.parentElement)if(h.scrollHeight>h.clientHeight+1&&/(auto|scroll)/.test(i.getComputedStyle(h).overflowY))return h;return null}let u=0;function f(){u=0;let c=l(),h=c.filter(({heading:g})=>g.getClientRects().length).sort((g,y)=>g.heading.getBoundingClientRect().top-y.heading.getBoundingClientRect().top),m=h.length?r(h[0].heading):null,p=m?m.getBoundingClientRect().top+m.clientTop:0,e=h[0];for(let g of h){let y=parseFloat(i.getComputedStyle(g.heading).scrollMarginBlockStart)||0;if(g.heading.getBoundingClientRect().top<=p+y+1)e=g}let n=m?m.scrollTop:i.scrollY,d=m?m.clientHeight:i.innerHeight,E=m?m.scrollHeight:b.documentElement.scrollHeight;if(n>0&&n+d>=E-2)e=h.at(-1);for(let g of c)if(g!==e)g.link.removeAttribute("aria-current");else if(g.link.getAttribute("aria-current")!=="location")g.link.setAttribute("aria-current","location")}let a=()=>{if(!u)u=i.requestAnimationFrame(f)};i.addEventListener("scroll",a,{signal:s,capture:!0,passive:!0}),i.addEventListener("resize",a,{signal:s}),i.addEventListener("hashchange",a,{signal:s});let o=new i.MutationObserver(a);o.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-current","href"]}),o.observe(b.body,{childList:!0,subtree:!0}),s.addEventListener("abort",()=>{i.cancelAnimationFrame(u),o.disconnect()},{once:!0}),f()}function lt(t,s){let b=t.ownerDocument||t,i=b.defaultView,l={signal:s},r=null,u=null,f=0,a=null,o=0,c=null,h=new i.MutationObserver((e)=>{if(!r.isConnected||e.some(({target:n})=>u.contains(n)&&!c.contains(n)))m()});function m(){if(!r)return;i.clearTimeout(o),h.disconnect();let e=r.dataset.b3Confirm;if(a&&e&&r.textContent===e)r.replaceChildren(...a);r.removeAttribute("data-b3-armed"),r=u=a=null,c.textContent=""}function p(e){if(!c?.isConnected)c=b.createElement("span"),c.className="b3-visually-hidden",c.setAttribute("role","status"),b.body.append(c);let n=c;r=e,f=i.performance.now(),u=e.parentElement.closest("li, tr, article, [data-id], .b3-row, .b3-card")||e.parentElement;let d=e.dataset.b3Confirm;if(d)a=[...e.childNodes],e.replaceChildren(d);e.setAttribute("data-b3-armed",""),h.observe(t,{childList:!0,subtree:!0}),h.observe(u,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),o=i.setTimeout(m,4000),i.requestAnimationFrame(()=>{if(r===e)n.textContent=d||"Press again to confirm"})}t.addEventListener("click",(e)=>{let n=e.target.closest?.("[data-b3-confirm]");if(r&&n!==r)m();if(!n||n.disabled||!t.contains(n))return;if(n===r&&i.performance.now()-f>=350)return m();if(e.preventDefault(),e.stopImmediatePropagation(),n!==r)p(n)},{...l,capture:!0}),t.addEventListener("focusout",({target:e})=>{if(e===r)i.queueMicrotask(()=>e===r&&m())},l),t.addEventListener("keydown",(e)=>{let n=e;if(n.key==="Escape")m();else if(n.repeat&&(n.key==="Enter"||n.key===" ")&&n.target.closest?.("[data-b3-confirm]"))n.preventDefault()},{...l,capture:!0}),s?.addEventListener("abort",()=>{m(),c?.remove()},{once:!0})}var j=Symbol.for("bare-v3.confirm");function U(){if(typeof document>"u"||!document.defaultView?.MutationObserver)return;let t=document;if(t[j])return;t[j]=!0,lt(document)}class G extends w{mount(t,s){P(t,s)}}class _ extends w{#t=null;get index(){return this.#t?.index??-1}set index(t){this.#t?.to(t)}get count(){return this.#t?.count??0}to(t,s){this.#t?.to(t,s)}mount(t,s){k(t,s,{tabindex:"0"},["b3-reel"]),this.#t=N(t,s),s.addEventListener("abort",()=>{this.#t=null},{once:!0})}}class J extends w{target(){return this.querySelector(":scope > details")}mount(t,s){F(t,s)}}class C extends w{#t=null;target(){return this.querySelector(":scope > dialog")}mount(t,s){this.#t=V(t,{signal:s,backdrop:()=>this.getAttribute("backdrop")==="dismiss"}),s.addEventListener("abort",()=>{this.#t=null},{once:!0})}show(t){if(this.#t)this.#t.show(t??null);else if(!this.target()?.open)this.target()?.showModal()}close(){if(this.#t)return this.#t.dismiss();return this.target()?.close(),!0}}class Q extends C{mount(t,s){super.mount(t,s),Y(t,s),W(t,()=>this.close(),s)}}class Z extends C{mount(t,s){super.mount(t,s),z(t,s)}}class tt extends w{mount(t,s){k(t,s,{},["b3-toast-region"]),K(t,s)}}class et extends w{mount(t,s){k(t,s,{role:"navigation"},["b3-toc"]),X(t,s)}}x("b3-tabs",G);x("b3-reel",_);x("b3-dropdown",J);x("b3-dialog",C);x("b3-sheet",Q);x("b3-command",Z);x("b3-toast-region",tt);x("b3-toc",et);U();export{Z as B3Command,C as B3Dialog,J as B3Dropdown,_ as B3Reel,Q as B3Sheet,G as B3Tabs,tt as B3ToastRegion,et as B3Toc,st as layout,I as motion,it as sequence,B as settle};
|
package/dist/manifest.json
CHANGED
|
@@ -27,7 +27,7 @@ In Blank these functions are already installed as `window.BareV3UI`; do not impo
|
|
|
27
27
|
| `layout(root, synchronousUpdate)` | Measure and animate stable nodes marked with unique, non-empty `data-b3-layout="key"`. Keeps DOM identity, focus and listeners; no clones or snapshots. |
|
|
28
28
|
| `settle(element, {x?, y?})` | A 460ms damped spring from a pointer displacement to untransformed resting layout. Gesture recognition and bounds remain caller-owned; sheets already provide handle dragging. |
|
|
29
29
|
|
|
30
|
-
Animation helpers cancel their previous animation on the same element. Interrupted layout changes begin at the currently visible positions. Cancellation exposes the committed final state. Individual motion/settle calls return Animation or null; layout/sequence return arrays. OS reduced motion, or an ancestor `data-b3-motion="reduce"`, preserves final state while removing motion. OS changes cancel running helper animations. Use an inner wrapper if the element has a custom resting transform; these presets assume an untransformed rest state.
|
|
30
|
+
Animation helpers cancel their previous animation on the same element. Interrupted enter/exit transitions begin at the currently visible opacity and transform; interrupted layout changes begin at the currently visible positions. Cancellation exposes the committed final state. Individual motion/settle calls return Animation or null; layout/sequence return arrays. OS reduced motion, or an ancestor `data-b3-motion="reduce"`, preserves final state while removing motion. OS changes cancel running helper animations. Use an inner wrapper if the element has a custom resting transform; these presets assume an untransformed rest state.
|
|
31
31
|
|
|
32
32
|
## Overlays and gesture ownership
|
|
33
33
|
|