@abgin/abgin 0.1.0 → 0.1.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/README.md +7 -8
- package/dist/abgin.js +2 -2
- package/dist/abgin.js.map +1 -1
- package/dist/chunks/{appbar-LLcnVLph.js → appbar-qrxjDiTR.js} +3 -3
- package/dist/chunks/{appbar-LLcnVLph.js.map → appbar-qrxjDiTR.js.map} +1 -1
- package/dist/chunks/{behavior-PpBNSUmo.js → behavior-DcTSsbjM.js} +2 -2
- package/dist/chunks/{behavior-PpBNSUmo.js.map → behavior-DcTSsbjM.js.map} +1 -1
- package/dist/chunks/{dialog-wNqzWPiS.js → dialog-YuGr7AZw.js} +3 -3
- package/dist/chunks/{dialog-wNqzWPiS.js.map → dialog-YuGr7AZw.js.map} +1 -1
- package/dist/chunks/{direction-BDKiHYas.js → direction-JCXVGRGq.js} +2 -2
- package/dist/chunks/{direction-BDKiHYas.js.map → direction-JCXVGRGq.js.map} +1 -1
- package/dist/chunks/drawer-V2-RJZaj.js +3 -0
- package/dist/chunks/{drawer-ZmlA-nWk.js.map → drawer-V2-RJZaj.js.map} +1 -1
- package/dist/chunks/{dropdown-BAvgXY5r.js → dropdown-BsSoDo4Z.js} +3 -3
- package/dist/chunks/{dropdown-BAvgXY5r.js.map → dropdown-BsSoDo4Z.js.map} +1 -1
- package/dist/chunks/{engine-CLGg6TrP.js → engine-DOFQfCtE.js} +3 -3
- package/dist/chunks/{engine-CLGg6TrP.js.map → engine-DOFQfCtE.js.map} +1 -1
- package/dist/chunks/{focus-BezZcM_N.js → focus-BNE6ytl8.js} +3 -3
- package/dist/chunks/{focus-BezZcM_N.js.map → focus-BNE6ytl8.js.map} +1 -1
- package/dist/chunks/{glass-CrY_zpD7.js → glass-9XMne6tP.js} +3 -3
- package/dist/chunks/{glass-CrY_zpD7.js.map → glass-9XMne6tP.js.map} +1 -1
- package/dist/chunks/modal-GUayszcw.js +3 -0
- package/dist/chunks/{modal-COcRYmWk.js.map → modal-GUayszcw.js.map} +1 -1
- package/dist/chunks/{motion-scene-BDU70ceZ.js → motion-scene-BNPBmw5W.js} +3 -3
- package/dist/chunks/{motion-scene-BDU70ceZ.js.map → motion-scene-BNPBmw5W.js.map} +1 -1
- package/dist/chunks/{optics-Dfs-jab-.js → optics-BSQ3SSNg.js} +2 -2
- package/dist/chunks/{optics-Dfs-jab-.js.map → optics-BSQ3SSNg.js.map} +1 -1
- package/dist/chunks/{overlay-C7vi0Jzf.js → overlay-CKgXnT5J.js} +3 -3
- package/dist/chunks/{overlay-C7vi0Jzf.js.map → overlay-CKgXnT5J.js.map} +1 -1
- package/dist/chunks/popover-CMbdxv9C.js +3 -0
- package/dist/chunks/{popover-CEIndATO.js.map → popover-CMbdxv9C.js.map} +1 -1
- package/dist/chunks/{position-Bf9Bk3ZK.js → position-Bx0n9Xgs.js} +3 -3
- package/dist/chunks/{position-Bf9Bk3ZK.js.map → position-Bx0n9Xgs.js.map} +1 -1
- package/dist/chunks/{sheet-C6pSKe8a.js → sheet-Dje0MQib.js} +3 -3
- package/dist/chunks/{sheet-C6pSKe8a.js.map → sheet-Dje0MQib.js.map} +1 -1
- package/dist/chunks/{sidebar-CF_I9jqC.js → sidebar-DA1aYsdf.js} +3 -3
- package/dist/chunks/{sidebar-CF_I9jqC.js.map → sidebar-DA1aYsdf.js.map} +1 -1
- package/dist/chunks/{tabbar-CRHZitw_.js → tabbar-B2BkNJJw.js} +3 -3
- package/dist/chunks/{tabbar-CRHZitw_.js.map → tabbar-B2BkNJJw.js.map} +1 -1
- package/dist/chunks/{tabs-1jFkGW6D.js → tabs-CUFBy_Bw.js} +3 -3
- package/dist/chunks/{tabs-1jFkGW6D.js.map → tabs-CUFBy_Bw.js.map} +1 -1
- package/dist/chunks/{toast-Cazk1MoR.js → toast-YwwbcxDG.js} +3 -3
- package/dist/chunks/{toast-Cazk1MoR.js.map → toast-YwwbcxDG.js.map} +1 -1
- package/dist/chunks/{toolbar-DJnAyNIW.js → toolbar-BxJFkGlB.js} +3 -3
- package/dist/chunks/{toolbar-DJnAyNIW.js.map → toolbar-BxJFkGlB.js.map} +1 -1
- package/dist/chunks/{tooltip-D-ySWdJM.js → tooltip-COC1Ta6M.js} +3 -3
- package/dist/chunks/{tooltip-D-ySWdJM.js.map → tooltip-COC1Ta6M.js.map} +1 -1
- package/dist/chunks/{webgl-backend-aGPldzh7.js → webgl-backend-BE1U7Yp0.js} +3 -3
- package/dist/chunks/{webgl-backend-aGPldzh7.js.map → webgl-backend-BE1U7Yp0.js.map} +1 -1
- package/dist/css/abgin.css +1 -1
- package/dist/css/background.css +1 -1
- package/dist/css/base.css +1 -1
- package/dist/css/components/accordion.css +1 -1
- package/dist/css/components/alert.css +1 -1
- package/dist/css/components/appbar.css +1 -1
- package/dist/css/components/badge.css +1 -1
- package/dist/css/components/breadcrumbs.css +1 -1
- package/dist/css/components/button.css +1 -1
- package/dist/css/components/card.css +1 -1
- package/dist/css/components/checkbox.css +1 -1
- package/dist/css/components/code.css +1 -1
- package/dist/css/components/divider.css +1 -1
- package/dist/css/components/drawer.css +1 -1
- package/dist/css/components/dropdown.css +1 -1
- package/dist/css/components/field.css +1 -1
- package/dist/css/components/icon.css +1 -1
- package/dist/css/components/input.css +1 -1
- package/dist/css/components/join.css +1 -1
- package/dist/css/components/kbd.css +1 -1
- package/dist/css/components/link.css +1 -1
- package/dist/css/components/list.css +1 -1
- package/dist/css/components/menu.css +1 -1
- package/dist/css/components/modal.css +1 -1
- package/dist/css/components/navbar.css +1 -1
- package/dist/css/components/pagination.css +1 -1
- package/dist/css/components/popover.css +1 -1
- package/dist/css/components/progress.css +1 -1
- package/dist/css/components/radio.css +1 -1
- package/dist/css/components/range.css +1 -1
- package/dist/css/components/search.css +1 -1
- package/dist/css/components/segmented.css +1 -1
- package/dist/css/components/select.css +1 -1
- package/dist/css/components/sheet.css +1 -1
- package/dist/css/components/shell.css +1 -1
- package/dist/css/components/sidebar.css +1 -1
- package/dist/css/components/spinner.css +1 -1
- package/dist/css/components/tabbar.css +1 -1
- package/dist/css/components/table.css +1 -1
- package/dist/css/components/tabs.css +1 -1
- package/dist/css/components/textarea.css +1 -1
- package/dist/css/components/toast.css +1 -1
- package/dist/css/components/toggle.css +1 -1
- package/dist/css/components/toolbar.css +1 -1
- package/dist/css/components/tooltip.css +1 -1
- package/dist/css/glass/appbar.css +1 -1
- package/dist/css/glass/base.css +1 -1
- package/dist/css/glass/button.css +1 -1
- package/dist/css/glass/card.css +1 -1
- package/dist/css/glass/checkbox.css +1 -1
- package/dist/css/glass/drawer.css +1 -1
- package/dist/css/glass/dropdown.css +1 -1
- package/dist/css/glass/join.css +1 -1
- package/dist/css/glass/modal.css +1 -1
- package/dist/css/glass/navbar.css +1 -1
- package/dist/css/glass/popover.css +1 -1
- package/dist/css/glass/radio.css +1 -1
- package/dist/css/glass/range.css +1 -1
- package/dist/css/glass/search.css +1 -1
- package/dist/css/glass/segmented.css +1 -1
- package/dist/css/glass/sheet.css +1 -1
- package/dist/css/glass/sidebar.css +1 -1
- package/dist/css/glass/tabbar.css +1 -1
- package/dist/css/glass/tabs.css +1 -1
- package/dist/css/glass/toast.css +1 -1
- package/dist/css/glass/toggle.css +1 -1
- package/dist/css/glass/toolbar.css +1 -1
- package/dist/css/glass/tooltip.css +1 -1
- package/dist/css/glass/vivid.css +1 -1
- package/dist/css/glass.css +1 -1
- package/dist/css/layers.css +1 -1
- package/dist/css/prose.css +1 -1
- package/dist/css/standard.css +1 -1
- package/dist/css/themes/dark.css +1 -1
- package/dist/css/themes/light.css +1 -1
- package/dist/css/tokens.css +1 -1
- package/dist/css/utilities.css +1 -1
- package/dist/manifest.json +380 -379
- package/package.json +5 -5
- package/dist/chunks/drawer-ZmlA-nWk.js +0 -3
- package/dist/chunks/modal-COcRYmWk.js +0 -3
- package/dist/chunks/popover-CEIndATO.js +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @abgin/abgin 0.1.
|
|
2
|
-
import{t as e}from"./direction-
|
|
3
|
-
//# sourceMappingURL=focus-
|
|
1
|
+
/*! @abgin/abgin 0.1.2 | MIT License */
|
|
2
|
+
import{t as e}from"./direction-JCXVGRGq.js";function t(e,t={}){if(e.defaultPrevented||e.isComposing||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)return null;let{orientation:n=`horizontal`,direction:r=`ltr`}=t;switch(e.key){case`Home`:return`first`;case`End`:return`last`;case`ArrowDown`:return n===`horizontal`?null:`next`;case`ArrowUp`:return n===`horizontal`?null:`previous`;case`ArrowRight`:return n===`vertical`?null:r===`rtl`?`previous`:`next`;case`ArrowLeft`:return n===`vertical`?null:r===`rtl`?`next`:`previous`;default:return null}}function n(e,t,n,r=!0){if(n<=0)return-1;if(e===`first`)return 0;if(e===`last`)return n-1;let i=e===`next`?1:-1;if(t<0||t>=n)return e===`next`?0:n-1;let a=t+i;return a>=0&&a<n?a:r?(a+n)%n:t}function r(e){return e.matches(`input:not([type="button"], [type="submit"], [type="reset"], [type="image"], [type="checkbox"], [type="color"], [type="file"]), textarea, select, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="searchbox"], [role="spinbutton"], [role="slider"], [role="combobox"]`)}const i=`a[href], area[href], button, input:not([type="hidden"]), select, textarea, summary, iframe, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]`;function a(e){return typeof e.checkVisibility==`function`?e.checkVisibility({visibilityProperty:!0,contentVisibilityAuto:!1}):e.getClientRects().length>0&&getComputedStyle(e).visibility===`visible`}function o(e){if(!e.matches(i)||e.matches(`:disabled`)||e.closest(`[inert]`))return!1;if(e.localName===`summary`&&!e.hasAttribute(`tabindex`)){let t=e.parentElement;if(t?.localName!==`details`||t.querySelector(`:scope > summary`)!==e)return!1}return a(e)}function s(e){return o(e)?e.tabIndex>=0||e.isContentEditable&&!e.hasAttribute(`tabindex`):!1}function c(e){return[...e.querySelectorAll(i)].filter(s)}function l(e=document){let t=e.activeElement instanceof HTMLElement?e.activeElement:null,n=[];for(let r=t?.parentElement??null;r&&r!==e.body;r=r.parentElement)n.push(r);let r=t=>(t.focus(),e.activeElement===t);return{restore({fallback:i=null,force:s=!1}={}){let c=e.activeElement,l=c===null||c===e.body||!a(c);if(!s&&!l)return!1;if(t&&t!==e.body&&t.isConnected&&o(t)&&r(t)||i?.isConnected&&o(i)&&r(i))return!0;for(let e of n)if(e.isConnected&&o(e)&&r(e))return!0;return!1}}}function u(i,o,s){let{items:c,orientation:l=`horizontal`,owns:u=()=>!0,wrap:d=!0,onMove:f}=s,p=/* @__PURE__ */ new Map,m=null,h=()=>[...i.querySelectorAll(c)].filter(e=>u(e)&&!e.matches(`:disabled`)&&!e.closest(`[inert]`)&&a(e)),g=e=>{let t=e.composedPath().find(e=>e instanceof HTMLElement)?.closest(c)??null;return t&&i.contains(t)&&u(t)?t:null},_=(e,t)=>{p.has(e)||p.set(e,e.getAttribute(`tabindex`)),e.getAttribute(`tabindex`)!==t&&e.setAttribute(`tabindex`,t)},v=e=>{let t=i.ownerDocument.activeElement;return e.find(e=>e===t)??e.find(e=>e===m)??e.find(e=>e.matches(`[aria-selected="true"], [aria-checked="true"], [aria-current]:not([aria-current="false"])`))??e[0]??null},y=(e,t)=>{m=e;for(let n of t)_(n,n===e?`0`:`-1`);for(let t of[...p.keys()])t.isConnected?t!==e&&_(t,`-1`):p.delete(t)},b=()=>{let e=h();y(v(e),e)};return o.listen(i,`keydown`,a=>{let o=a,s=g(o);if(!s||o.target instanceof Element&&r(o.target))return;let c=t(o,{orientation:typeof l==`function`?l():l,direction:e(i)});if(!c)return;let u=h(),p=u[n(c,u.indexOf(s),u.length,d)];p&&(o.preventDefault(),p!==s&&(y(p,u),p.focus(),f?.(p)))}),o.listen(i,`focusin`,e=>{let t=g(e);if(t&&t!==m){let e=h();e.includes(t)&&y(t,e)}}),o.track(new MutationObserver(b)).observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`disabled`,`hidden`,`inert`]}),o.onDispose(()=>{for(let[e,t]of p)t===null?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,t);p.clear(),m=null}),b(),{get current(){return m},set(e){let t=h();t.includes(e)&&y(e,t)},update:b}}export{u as n,c as r,l as t};
|
|
3
|
+
//# sourceMappingURL=focus-BNE6ytl8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-BezZcM_N.js","names":["directionOf","navigationIntent","event","options","orientation","direction","navigationIndex","intent","current","count","wrap","step","next","usesArrowKeys","element","CANDIDATES","isRendered","isFocusable","parent","isTabbable","tabbable","container","rememberFocus","doc","ancestors","e","focus","target","fallback","force","active","lost","ancestor","rovingFocus","scope","items","owns","onMove","original","list","item","itemOf","node","write","value","preferred","all","focused","apply","other","known","update"],"sources":["../../../ui/dist/keyboard.js","../../../ui/dist/focus.js"],"sourcesContent":["// Keyboard navigation (COMPONENT_STANDARD.md section 8): which way a key moves inside a composite widget. The arrow that\n// points toward the inline end moves to the next item, so ArrowLeft is \"next\" in RTL. Vertical arrows never reverse.\n/**\n * What a key means for navigation, or `null`: not a navigation key, a key with a modifier (those belong to the browser,\n * the platform, or assistive technology), a key handled already, or one that composes text (IME).\n */\nexport function navigationIntent(event, options = {}) {\n if (event.defaultPrevented || event.isComposing)\n return null;\n if (event.ctrlKey || event.altKey || event.metaKey || event.shiftKey)\n return null;\n const { orientation = \"horizontal\", direction = \"ltr\" } = options;\n switch (event.key) {\n case \"Home\":\n return \"first\";\n case \"End\":\n return \"last\";\n case \"ArrowDown\":\n return orientation === \"horizontal\" ? null : \"next\";\n case \"ArrowUp\":\n return orientation === \"horizontal\" ? null : \"previous\";\n case \"ArrowRight\":\n return orientation === \"vertical\" ? null : direction === \"rtl\" ? \"previous\" : \"next\";\n case \"ArrowLeft\":\n return orientation === \"vertical\" ? null : direction === \"rtl\" ? \"next\" : \"previous\";\n default:\n return null;\n }\n}\n/** Index of the item an intent leads to, `-1` without items. `wrap`: past the end continues at the other end. */\nexport function navigationIndex(intent, current, count, wrap = true) {\n if (count <= 0)\n return -1;\n if (intent === \"first\")\n return 0;\n if (intent === \"last\")\n return count - 1;\n const step = intent === \"next\" ? 1 : -1;\n // Nothing is current yet: enter at the near end.\n if (current < 0 || current >= count)\n return intent === \"next\" ? 0 : count - 1;\n const next = current + step;\n if (next >= 0 && next < count)\n return next;\n return wrap ? (next + count) % count : current;\n}\nconst TEXT_INPUT = 'input:not([type=\"button\"], [type=\"submit\"], [type=\"reset\"], [type=\"image\"], [type=\"checkbox\"], [type=\"color\"], [type=\"file\"])';\n/** Whether an element uses arrow keys, Home, or End itself: text fields, selects, radio groups, sliders, and editors. */\nexport function usesArrowKeys(element) {\n return element.matches(`${TEXT_INPUT}, textarea, select, audio[controls], video[controls], [contenteditable]:not([contenteditable=\"false\"]), ` +\n '[role=\"textbox\"], [role=\"searchbox\"], [role=\"spinbutton\"], [role=\"slider\"], [role=\"combobox\"]');\n}\n//# sourceMappingURL=keyboard.js.map","// Focus utilities for composite widgets and overlays. They follow the platform: native focus order, native `:focus-visible`,\n// native modality (`<dialog>.showModal()` makes the rest of the page inert and returns focus; nothing here traps focus).\n// No state is kept outside the given scope, and nothing runs until a function is called.\nimport { directionOf } from \"./direction.js\";\nimport { navigationIndex, navigationIntent, usesArrowKeys } from \"./keyboard.js\";\nconst CANDIDATES = 'a[href], area[href], button, input:not([type=\"hidden\"]), select, textarea, summary, iframe, audio[controls], ' +\n 'video[controls], [contenteditable]:not([contenteditable=\"false\"]), [tabindex]';\n/** Whether an element is rendered: not hidden by `display`, `visibility`, or `content-visibility`. */\nfunction isRendered(element) {\n if (typeof element.checkVisibility === \"function\")\n return element.checkVisibility({ visibilityProperty: true, contentVisibilityAuto: false });\n return element.getClientRects().length > 0 && getComputedStyle(element).visibility === \"visible\";\n}\n/** Whether `focus()` on the element would focus it now. */\nexport function isFocusable(element) {\n if (!element.matches(CANDIDATES) || element.matches(\":disabled\") || element.closest(\"[inert]\"))\n return false;\n // Only the first `summary` of a `details` is a control.\n if (element.localName === \"summary\" && !element.hasAttribute(\"tabindex\")) {\n const parent = element.parentElement;\n if (parent?.localName !== \"details\" || parent.querySelector(\":scope > summary\") !== element)\n return false;\n }\n return isRendered(element);\n}\n/** Whether Tab reaches the element: focusable, and not taken out of the order by a negative `tabindex`. */\nexport function isTabbable(element) {\n if (!isFocusable(element))\n return false;\n // Browsers report `tabIndex` -1 for editing hosts, which Tab reaches.\n return element.tabIndex >= 0 || (element.isContentEditable && !element.hasAttribute(\"tabindex\"));\n}\n/** The elements inside `container` that Tab reaches, in document order. */\nexport function tabbable(container) {\n return [...container.querySelectorAll(CANDIDATES)].filter(isTabbable);\n}\n/**\n * Remembers the focused element before content that takes focus opens, or before focused content is removed. Native\n * dialogs and popovers do this themselves; use it where they are not involved.\n */\nexport function rememberFocus(doc = document) {\n const element = doc.activeElement instanceof HTMLElement ? doc.activeElement : null;\n const ancestors = [];\n for (let e = element?.parentElement ?? null; e && e !== doc.body; e = e.parentElement)\n ancestors.push(e);\n const focus = (target) => {\n target.focus();\n return doc.activeElement === target;\n };\n return {\n restore({ fallback = null, force = false } = {}) {\n const active = doc.activeElement;\n // Focus rests on the body (or nothing) when its element was removed or hidden; anything else is the user's choice.\n const lost = active === null || active === doc.body || !isRendered(active);\n if (!force && !lost)\n return false;\n if (element && element !== doc.body && element.isConnected && isFocusable(element) && focus(element))\n return true;\n if (fallback?.isConnected && isFocusable(fallback) && focus(fallback))\n return true;\n for (const ancestor of ancestors)\n if (ancestor.isConnected && isFocusable(ancestor) && focus(ancestor))\n return true;\n return false;\n },\n };\n}\n/**\n * Roving focus for a composite widget (toolbar, tab list, menu): the widget is one Tab stop, and arrow keys, Home, and\n * End move between its items. The direction is read per key press. Items keep their own keys (arrow keys in a text field\n * stay there). Everything is released with the scope, and `tabindex` attributes are restored.\n */\nexport function rovingFocus(container, scope, options) {\n const { items, orientation = \"horizontal\", owns = () => true, wrap = true, onMove } = options;\n const original = new Map();\n let current = null;\n const list = () => [...container.querySelectorAll(items)].filter((item) => owns(item) && !item.matches(\":disabled\") && !item.closest(\"[inert]\") && isRendered(item));\n const itemOf = (event) => {\n const target = event.composedPath().find((node) => node instanceof HTMLElement);\n const item = target?.closest(items) ?? null;\n return item && container.contains(item) && owns(item) ? item : null;\n };\n const write = (item, value) => {\n if (!original.has(item))\n original.set(item, item.getAttribute(\"tabindex\"));\n if (item.getAttribute(\"tabindex\") !== value)\n item.setAttribute(\"tabindex\", value);\n };\n const preferred = (all) => {\n const focused = container.ownerDocument.activeElement;\n return (all.find((item) => item === focused) ??\n all.find((item) => item === current) ??\n all.find((item) => item.matches('[aria-selected=\"true\"], [aria-checked=\"true\"], [aria-current]:not([aria-current=\"false\"])')) ??\n all[0] ??\n null);\n };\n const apply = (item, all) => {\n current = item;\n for (const other of all)\n write(other, other === item ? \"0\" : \"-1\");\n // Items that cannot be reached now (disabled, hidden) must not come back as a second Tab stop.\n for (const known of [...original.keys()]) {\n if (!known.isConnected)\n original.delete(known);\n else if (known !== item)\n write(known, \"-1\");\n }\n };\n const update = () => {\n const all = list();\n apply(preferred(all), all);\n };\n scope.listen(container, \"keydown\", (event) => {\n const e = event;\n const item = itemOf(e);\n if (!item || (e.target instanceof Element && usesArrowKeys(e.target)))\n return;\n const axis = typeof orientation === \"function\" ? orientation() : orientation;\n const intent = navigationIntent(e, { orientation: axis, direction: directionOf(container) });\n if (!intent)\n return;\n const all = list();\n const target = all[navigationIndex(intent, all.indexOf(item), all.length, wrap)];\n if (!target)\n return;\n e.preventDefault();\n if (target === item)\n return;\n apply(target, all);\n target.focus();\n onMove?.(target);\n });\n scope.listen(container, \"focusin\", (event) => {\n const item = itemOf(event);\n if (item && item !== current) {\n const all = list();\n if (all.includes(item))\n apply(item, all);\n }\n });\n // Without it, removing or disabling the current item would leave the widget without a Tab stop.\n const observer = scope.track(new MutationObserver(update));\n observer.observe(container, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"disabled\", \"hidden\", \"inert\"],\n });\n scope.onDispose(() => {\n for (const [item, value] of original) {\n if (value === null)\n item.removeAttribute(\"tabindex\");\n else\n item.setAttribute(\"tabindex\", value);\n }\n original.clear();\n current = null;\n });\n update();\n return {\n get current() {\n return current;\n },\n set(item) {\n const all = list();\n if (all.includes(item))\n apply(item, all);\n },\n update,\n };\n}\n//# sourceMappingURL=focus.js.map"],"mappings":";A,4CAMA,SAAgBC,EAAiBC,EAAOC,EAAU,CAAC,EAAG,CAGlD,GAFID,EAAM,kBAAoBA,EAAM,aAEhCA,EAAM,SAAWA,EAAM,QAAUA,EAAM,SAAWA,EAAM,SACxD,OAAO,KACX,GAAM,CAAEE,cAAc,aAAcC,YAAY,OAAUF,EAC1D,OAAQD,EAAM,IAAd,CACI,IAAK,OACD,MAAO,QACX,IAAK,MACD,MAAO,OACX,IAAK,YACD,OAAOE,IAAgB,aAAe,KAAO,OACjD,IAAK,UACD,OAAOA,IAAgB,aAAe,KAAO,WACjD,IAAK,aACD,OAAOA,IAAgB,WAAa,KAAOC,IAAc,MAAQ,WAAa,OAClF,IAAK,YACD,OAAOD,IAAgB,WAAa,KAAOC,IAAc,MAAQ,OAAS,WAC9E,QACI,OAAO,IACf,CACJ,CAEA,SAAgBC,EAAgBC,EAAQC,EAASC,EAAOC,EAAO,GAAM,CACjE,GAAID,GAAS,EACT,MAAO,GACX,GAAIF,IAAW,QACX,MAAO,GACX,GAAIA,IAAW,OACX,OAAOE,EAAQ,EACnB,IAAME,EAAOJ,IAAW,OAAS,EAAI,GAErC,GAAIC,EAAU,GAAKA,GAAWC,EAC1B,OAAOF,IAAW,OAAS,EAAIE,EAAQ,EAC3C,IAAMG,EAAOJ,EAAUG,EAGvB,OAFIC,GAAQ,GAAKA,EAAOH,EACbG,EACJF,GAAQE,EAAOH,GAASA,EAAQD,CAC3C,CAGA,SAAgBK,EAAcC,EAAS,CACnC,OAAOA,EAAQ,QAAQ,oUAC4E,CACvG,CC9CA,MAAMC,EAAa,6LAGnB,SAASC,EAAWF,EAAS,CAGzB,OAF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B,UAAW,GACX,QAAS,GACT,WAAY,GACZ,gBAAiB,CAAC,WAAY,SAAU,OAAO,CACnD,CAAC,EACDa,EAAM,cAAgB,CAClB,IAAK,GAAM,CAACM,EAAMI,KAAUN,EACpBM,IAAU,KACVJ,EAAK,gBAAgB,UAAU,EAE/BA,EAAK,aAAa,WAAYI,CAAK,EAE3CN,EAAS,MAAM,EACf9B,EAAU,IACd,CAAC,EACD2C,EAAO,EACA,CACH,IAAI,SAAU,CACV,OAAO3C,CACX,EACA,IAAIgC,EAAM,CACN,IAAMM,EAAMP,EAAK,EACbO,EAAI,SAASN,CAAI,GACjBQ,EAAMR,EAAMM,CAAG,CACvB,EACAK,QACJ,CACJ,C"}
|
|
1
|
+
{"version":3,"file":"focus-BNE6ytl8.js","names":["directionOf","navigationIntent","event","options","orientation","direction","navigationIndex","intent","current","count","wrap","step","next","usesArrowKeys","element","CANDIDATES","isRendered","isFocusable","parent","isTabbable","tabbable","container","rememberFocus","doc","ancestors","e","focus","target","fallback","force","active","lost","ancestor","rovingFocus","scope","items","owns","onMove","original","list","item","itemOf","node","write","value","preferred","all","focused","apply","other","known","update"],"sources":["../../../ui/dist/keyboard.js","../../../ui/dist/focus.js"],"sourcesContent":["// Keyboard navigation (COMPONENT_STANDARD.md section 8): which way a key moves inside a composite widget. The arrow that\n// points toward the inline end moves to the next item, so ArrowLeft is \"next\" in RTL. Vertical arrows never reverse.\n/**\n * What a key means for navigation, or `null`: not a navigation key, a key with a modifier (those belong to the browser,\n * the platform, or assistive technology), a key handled already, or one that composes text (IME).\n */\nexport function navigationIntent(event, options = {}) {\n if (event.defaultPrevented || event.isComposing)\n return null;\n if (event.ctrlKey || event.altKey || event.metaKey || event.shiftKey)\n return null;\n const { orientation = \"horizontal\", direction = \"ltr\" } = options;\n switch (event.key) {\n case \"Home\":\n return \"first\";\n case \"End\":\n return \"last\";\n case \"ArrowDown\":\n return orientation === \"horizontal\" ? null : \"next\";\n case \"ArrowUp\":\n return orientation === \"horizontal\" ? null : \"previous\";\n case \"ArrowRight\":\n return orientation === \"vertical\" ? null : direction === \"rtl\" ? \"previous\" : \"next\";\n case \"ArrowLeft\":\n return orientation === \"vertical\" ? null : direction === \"rtl\" ? \"next\" : \"previous\";\n default:\n return null;\n }\n}\n/** Index of the item an intent leads to, `-1` without items. `wrap`: past the end continues at the other end. */\nexport function navigationIndex(intent, current, count, wrap = true) {\n if (count <= 0)\n return -1;\n if (intent === \"first\")\n return 0;\n if (intent === \"last\")\n return count - 1;\n const step = intent === \"next\" ? 1 : -1;\n // Nothing is current yet: enter at the near end.\n if (current < 0 || current >= count)\n return intent === \"next\" ? 0 : count - 1;\n const next = current + step;\n if (next >= 0 && next < count)\n return next;\n return wrap ? (next + count) % count : current;\n}\nconst TEXT_INPUT = 'input:not([type=\"button\"], [type=\"submit\"], [type=\"reset\"], [type=\"image\"], [type=\"checkbox\"], [type=\"color\"], [type=\"file\"])';\n/** Whether an element uses arrow keys, Home, or End itself: text fields, selects, radio groups, sliders, and editors. */\nexport function usesArrowKeys(element) {\n return element.matches(`${TEXT_INPUT}, textarea, select, audio[controls], video[controls], [contenteditable]:not([contenteditable=\"false\"]), ` +\n '[role=\"textbox\"], [role=\"searchbox\"], [role=\"spinbutton\"], [role=\"slider\"], [role=\"combobox\"]');\n}\n//# sourceMappingURL=keyboard.js.map","// Focus utilities for composite widgets and overlays. They follow the platform: native focus order, native `:focus-visible`,\n// native modality (`<dialog>.showModal()` makes the rest of the page inert and returns focus; nothing here traps focus).\n// No state is kept outside the given scope, and nothing runs until a function is called.\nimport { directionOf } from \"./direction.js\";\nimport { navigationIndex, navigationIntent, usesArrowKeys } from \"./keyboard.js\";\nconst CANDIDATES = 'a[href], area[href], button, input:not([type=\"hidden\"]), select, textarea, summary, iframe, audio[controls], ' +\n 'video[controls], [contenteditable]:not([contenteditable=\"false\"]), [tabindex]';\n/** Whether an element is rendered: not hidden by `display`, `visibility`, or `content-visibility`. */\nfunction isRendered(element) {\n if (typeof element.checkVisibility === \"function\")\n return element.checkVisibility({ visibilityProperty: true, contentVisibilityAuto: false });\n return element.getClientRects().length > 0 && getComputedStyle(element).visibility === \"visible\";\n}\n/** Whether `focus()` on the element would focus it now. */\nexport function isFocusable(element) {\n if (!element.matches(CANDIDATES) || element.matches(\":disabled\") || element.closest(\"[inert]\"))\n return false;\n // Only the first `summary` of a `details` is a control.\n if (element.localName === \"summary\" && !element.hasAttribute(\"tabindex\")) {\n const parent = element.parentElement;\n if (parent?.localName !== \"details\" || parent.querySelector(\":scope > summary\") !== element)\n return false;\n }\n return isRendered(element);\n}\n/** Whether Tab reaches the element: focusable, and not taken out of the order by a negative `tabindex`. */\nexport function isTabbable(element) {\n if (!isFocusable(element))\n return false;\n // Browsers report `tabIndex` -1 for editing hosts, which Tab reaches.\n return element.tabIndex >= 0 || (element.isContentEditable && !element.hasAttribute(\"tabindex\"));\n}\n/** The elements inside `container` that Tab reaches, in document order. */\nexport function tabbable(container) {\n return [...container.querySelectorAll(CANDIDATES)].filter(isTabbable);\n}\n/**\n * Remembers the focused element before content that takes focus opens, or before focused content is removed. Native\n * dialogs and popovers do this themselves; use it where they are not involved.\n */\nexport function rememberFocus(doc = document) {\n const element = doc.activeElement instanceof HTMLElement ? doc.activeElement : null;\n const ancestors = [];\n for (let e = element?.parentElement ?? null; e && e !== doc.body; e = e.parentElement)\n ancestors.push(e);\n const focus = (target) => {\n target.focus();\n return doc.activeElement === target;\n };\n return {\n restore({ fallback = null, force = false } = {}) {\n const active = doc.activeElement;\n // Focus rests on the body (or nothing) when its element was removed or hidden; anything else is the user's choice.\n const lost = active === null || active === doc.body || !isRendered(active);\n if (!force && !lost)\n return false;\n if (element && element !== doc.body && element.isConnected && isFocusable(element) && focus(element))\n return true;\n if (fallback?.isConnected && isFocusable(fallback) && focus(fallback))\n return true;\n for (const ancestor of ancestors)\n if (ancestor.isConnected && isFocusable(ancestor) && focus(ancestor))\n return true;\n return false;\n },\n };\n}\n/**\n * Roving focus for a composite widget (toolbar, tab list, menu): the widget is one Tab stop, and arrow keys, Home, and\n * End move between its items. The direction is read per key press. Items keep their own keys (arrow keys in a text field\n * stay there). Everything is released with the scope, and `tabindex` attributes are restored.\n */\nexport function rovingFocus(container, scope, options) {\n const { items, orientation = \"horizontal\", owns = () => true, wrap = true, onMove } = options;\n const original = new Map();\n let current = null;\n const list = () => [...container.querySelectorAll(items)].filter((item) => owns(item) && !item.matches(\":disabled\") && !item.closest(\"[inert]\") && isRendered(item));\n const itemOf = (event) => {\n const target = event.composedPath().find((node) => node instanceof HTMLElement);\n const item = target?.closest(items) ?? null;\n return item && container.contains(item) && owns(item) ? item : null;\n };\n const write = (item, value) => {\n if (!original.has(item))\n original.set(item, item.getAttribute(\"tabindex\"));\n if (item.getAttribute(\"tabindex\") !== value)\n item.setAttribute(\"tabindex\", value);\n };\n const preferred = (all) => {\n const focused = container.ownerDocument.activeElement;\n return (all.find((item) => item === focused) ??\n all.find((item) => item === current) ??\n all.find((item) => item.matches('[aria-selected=\"true\"], [aria-checked=\"true\"], [aria-current]:not([aria-current=\"false\"])')) ??\n all[0] ??\n null);\n };\n const apply = (item, all) => {\n current = item;\n for (const other of all)\n write(other, other === item ? \"0\" : \"-1\");\n // Items that cannot be reached now (disabled, hidden) must not come back as a second Tab stop.\n for (const known of [...original.keys()]) {\n if (!known.isConnected)\n original.delete(known);\n else if (known !== item)\n write(known, \"-1\");\n }\n };\n const update = () => {\n const all = list();\n apply(preferred(all), all);\n };\n scope.listen(container, \"keydown\", (event) => {\n const e = event;\n const item = itemOf(e);\n if (!item || (e.target instanceof Element && usesArrowKeys(e.target)))\n return;\n const axis = typeof orientation === \"function\" ? orientation() : orientation;\n const intent = navigationIntent(e, { orientation: axis, direction: directionOf(container) });\n if (!intent)\n return;\n const all = list();\n const target = all[navigationIndex(intent, all.indexOf(item), all.length, wrap)];\n if (!target)\n return;\n e.preventDefault();\n if (target === item)\n return;\n apply(target, all);\n target.focus();\n onMove?.(target);\n });\n scope.listen(container, \"focusin\", (event) => {\n const item = itemOf(event);\n if (item && item !== current) {\n const all = list();\n if (all.includes(item))\n apply(item, all);\n }\n });\n // Without it, removing or disabling the current item would leave the widget without a Tab stop.\n const observer = scope.track(new MutationObserver(update));\n observer.observe(container, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"disabled\", \"hidden\", \"inert\"],\n });\n scope.onDispose(() => {\n for (const [item, value] of original) {\n if (value === null)\n item.removeAttribute(\"tabindex\");\n else\n item.setAttribute(\"tabindex\", value);\n }\n original.clear();\n current = null;\n });\n update();\n return {\n get current() {\n return current;\n },\n set(item) {\n const all = list();\n if (all.includes(item))\n apply(item, all);\n },\n update,\n };\n}\n//# sourceMappingURL=focus.js.map"],"mappings":";A,4CAMA,SAAgBC,EAAiBC,EAAOC,EAAU,CAAC,EAAG,CAGlD,GAFID,EAAM,kBAAoBA,EAAM,aAEhCA,EAAM,SAAWA,EAAM,QAAUA,EAAM,SAAWA,EAAM,SACxD,OAAO,KACX,GAAM,CAAEE,cAAc,aAAcC,YAAY,OAAUF,EAC1D,OAAQD,EAAM,IAAd,CACI,IAAK,OACD,MAAO,QACX,IAAK,MACD,MAAO,OACX,IAAK,YACD,OAAOE,IAAgB,aAAe,KAAO,OACjD,IAAK,UACD,OAAOA,IAAgB,aAAe,KAAO,WACjD,IAAK,aACD,OAAOA,IAAgB,WAAa,KAAOC,IAAc,MAAQ,WAAa,OAClF,IAAK,YACD,OAAOD,IAAgB,WAAa,KAAOC,IAAc,MAAQ,OAAS,WAC9E,QACI,OAAO,IACf,CACJ,CAEA,SAAgBC,EAAgBC,EAAQC,EAASC,EAAOC,EAAO,GAAM,CACjE,GAAID,GAAS,EACT,MAAO,GACX,GAAIF,IAAW,QACX,MAAO,GACX,GAAIA,IAAW,OACX,OAAOE,EAAQ,EACnB,IAAME,EAAOJ,IAAW,OAAS,EAAI,GAErC,GAAIC,EAAU,GAAKA,GAAWC,EAC1B,OAAOF,IAAW,OAAS,EAAIE,EAAQ,EAC3C,IAAMG,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OvC,CAAK,EACzB,GAAIsC,GAAQA,IAAShC,EAAS,CAC1B,IAAMsC,EAAMP,EAAK,EACbO,EAAI,SAASN,CAAI,GACjBQ,EAAMR,EAAMM,CAAG,CACvB,CACJ,CAAC,EAEgBZ,EAAM,MAAM,IAAI,iBAAiBiB,CAAM,CACjD,CAAC,CAAC,QAAQ9B,EAAW,CACxB,UAAW,GACX,QAAS,GACT,WAAY,GACZ,gBAAiB,CAAC,WAAY,SAAU,OAAO,CACnD,CAAC,EACDa,EAAM,cAAgB,CAClB,IAAK,GAAM,CAACM,EAAMI,KAAUN,EACpBM,IAAU,KACVJ,EAAK,gBAAgB,UAAU,EAE/BA,EAAK,aAAa,WAAYI,CAAK,EAE3CN,EAAS,MAAM,EACf9B,EAAU,IACd,CAAC,EACD2C,EAAO,EACA,CACH,IAAI,SAAU,CACV,OAAO3C,CACX,EACA,IAAIgC,EAAM,CACN,IAAMM,EAAMP,EAAK,EACbO,EAAI,SAASN,CAAI,GACjBQ,EAAMR,EAAMM,CAAG,CACvB,EACAK,QACJ,CACJ,C"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @abgin/abgin 0.1.
|
|
2
|
-
import{a as e,c as t,i as n,l as r,n as i,r as a,t as o}from"../abgin.js";var s=Object.defineProperty,c=(e,t)=>{let n=Object.setPrototypeOf({},null);for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t&1||s(n,Symbol.toStringTag,{value:`Module`}),t&2?n:Object.preventExtensions(n)},l=[{selector:`.accordion`,role:`container`},{selector:`.alert`,role:`container`},{selector:`.appbar-button`,role:`control`},{selector:`.appbar-group`,role:`bar`},{selector:`.btn`,role:`control`},{selector:`.card`,role:`container`},{selector:`.checkbox`,role:`control`,layer:!1},{selector:`.drawer`,role:`overlay`},{selector:`.dropdown-menu`,role:`overlay`},{selector:`.input`,role:`container`},{selector:`.modal-box`,role:`overlay`},{selector:`.navbar`,role:`bar`},{selector:`.popover`,role:`overlay`},{selector:`.radio`,role:`control`,layer:!1},{selector:`.range`,role:`control`,layer:!1},{selector:`.search`,role:`bar`},{selector:`.segmented`,role:`bar`},{selector:`.select`,role:`container`},{selector:`.sheet`,role:`overlay`},{selector:`.sheet-button`,role:`control`},{selector:`.sidebar`,role:`bar`},{selector:`.tabbar`,role:`bar`},{selector:`.tabbar-accessory`,role:`bar`},{selector:`.tabbar-search`,role:`bar`},{selector:`.table`,role:`container`},{selector:`.tabs-indicator`,role:`control`},{selector:`.tabs-list`,role:`bar`},{selector:`.textarea`,role:`container`},{selector:`.toast`,role:`overlay`},{selector:`.toggle`,role:`control`,layer:!1},{selector:`.toolbar`,role:`bar`},{selector:`.tooltip`,role:`overlay`}];const u=`data-abgin-layer`,d=`data-abgin-shared`,f=`data-abgin-motion`,p=`data-abgin-fits`,m=`input, select, textarea, progress, meter, img, video, canvas, iframe, object, embed`;function h(e){let t=i(e);return{prefix:t,appearance:a(`appearance`,t),quality:a(`quality`,t),transparency:a(`transparency`,t),material:a(`material`,t),motion:a(`motion`,t),theme:a(`theme`,t),surface:`data-${t}surface`,source:`data-${t}backdrop-source`,group:`data-${t}glass-group`,merge:`data-${t}glass-merge`,morph:`data-${t}glass-morph`,shape:`data-${t}glass-shape`,glassMotion:`data-${t}glass-motion`,drag:`data-${t}glass-drag`}}function g(e,t){return t?e.replace(/\.(-?[_a-zA-Z][\w-]*)/g,(e,n)=>`.${t}${n}`):e}function _(e){return typeof e==`object`&&!!e&&e.nodeType===1}function v(e){return _(e)&&e.hasAttribute(`data-abgin-layer`)}function y(e){return e.nodeType===11&&`host`in e?e.host:null}function b(e){return e.parentElement?e.parentElement:y(e.getRootNode())}function x(e,t){for(let n=t;n;n=y(n.getRootNode()))if(e.contains(n))return!0;return!1}function S(e,t,r={}){let i=r.root??document,a=i.ownerDocument??i,o=a.defaultView;if(!o)return;let s=n(a.documentElement),c=h(s);t.listen(i,`abgin:select`,t=>{let{tab:n,previous:r}=t.detail,i=e(),a=(n?.closest(`[role="tablist"]`))?.querySelector(`:scope > .${s}tabs-indicator`)??null;if(!i||!n||!r?.isConnected||!a)return;let o=i.motion.inspect(a);if(!o?.managed||o.reduced)return;let c=r.getBoundingClientRect(),l=n.getBoundingClientRect(),u=c.left-l.left+o.x,d=c.top-l.top+o.y;i.motion.animate(a,{x:u,y:d},{instant:!0}),i.motion.animate(a,{x:0,y:0})}),t.listen(i,`beforetoggle`,n=>{let r=n,i=r.target,a=e();if(!a||!i.hasAttribute(c.morph)||a.inspect(i)===null||a.motion.inspect(i)?.reduced)return;if(r.newState!==`open`){a.inspect(i)?.path===`layer`&&a.motion.animate(i,{morph:0});return}if(a.stats().backend.state!==`ready`)return;a.morph(i,0),i.style.transitionProperty=`opacity`;let s=()=>{i.style.removeProperty(`transition-property`),i.getAttribute(`style`)||i.removeAttribute(`style`)},l=0,u=()=>{if(t.disposed||a.stopped)s();else if(a.inspect(i)?.path===`layer`){a.morph(i,null),a.motion.animate(i,{morph:0},{instant:!0}),a.motion.animate(i,{morph:1}).then(s);for(let e of i.children)e.hasAttribute(`data-abgin-layer`)||e.animate({opacity:[0,0,1],offset:[0,.4,1]},{duration:280})}else++l>12||!i.isConnected?(a.morph(i,null),s()):o.requestAnimationFrame(u)};o.requestAnimationFrame(u)},!0);let l=t=>{t.isConnected&&t.matches(`:popover-open`)||(e()?.morph(t,null),e()?.motion.cancel(t))};t.listen(i,`toggle`,e=>{let t=e.target;if(e.newState!==`closed`||!t.hasAttribute(c.morph))return;let n=t.getAnimations().map(e=>e.finished);n.length?Promise.allSettled(n).then(()=>{l(t)}):l(t)},!0)}function C(e,t){return e!==`lite`&&t!==`lite`}function w(i){let s=i.document??globalThis.document,c=s?.defaultView??void 0,l=i.gracePeriod??2e3,u=i.importEngine??(()=>import(`./engine-
|
|
3
|
-
//# sourceMappingURL=glass-
|
|
1
|
+
/*! @abgin/abgin 0.1.2 | MIT License */
|
|
2
|
+
import{a as e,c as t,i as n,l as r,n as i,r as a,t as o}from"../abgin.js";var s=Object.defineProperty,c=(e,t)=>{let n=Object.setPrototypeOf({},null);for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t&1||s(n,Symbol.toStringTag,{value:`Module`}),t&2?n:Object.preventExtensions(n)},l=[{selector:`.accordion`,role:`container`},{selector:`.alert`,role:`container`},{selector:`.appbar-button`,role:`control`},{selector:`.appbar-group`,role:`bar`},{selector:`.btn`,role:`control`},{selector:`.card`,role:`container`},{selector:`.checkbox`,role:`control`,layer:!1},{selector:`.drawer`,role:`overlay`},{selector:`.dropdown-menu`,role:`overlay`},{selector:`.input`,role:`container`},{selector:`.modal-box`,role:`overlay`},{selector:`.navbar`,role:`bar`},{selector:`.popover`,role:`overlay`},{selector:`.radio`,role:`control`,layer:!1},{selector:`.range`,role:`control`,layer:!1},{selector:`.search`,role:`bar`},{selector:`.segmented`,role:`bar`},{selector:`.select`,role:`container`},{selector:`.sheet`,role:`overlay`},{selector:`.sheet-button`,role:`control`},{selector:`.sidebar`,role:`bar`},{selector:`.tabbar`,role:`bar`},{selector:`.tabbar-accessory`,role:`bar`},{selector:`.tabbar-search`,role:`bar`},{selector:`.table`,role:`container`},{selector:`.tabs-indicator`,role:`control`},{selector:`.tabs-list`,role:`bar`},{selector:`.textarea`,role:`container`},{selector:`.toast`,role:`overlay`},{selector:`.toggle`,role:`control`,layer:!1},{selector:`.toolbar`,role:`bar`},{selector:`.tooltip`,role:`overlay`}];const u=`data-abgin-layer`,d=`data-abgin-shared`,f=`data-abgin-motion`,p=`data-abgin-fits`,m=`input, select, textarea, progress, meter, img, video, canvas, iframe, object, embed`;function h(e){let t=i(e);return{prefix:t,appearance:a(`appearance`,t),quality:a(`quality`,t),transparency:a(`transparency`,t),material:a(`material`,t),motion:a(`motion`,t),theme:a(`theme`,t),surface:`data-${t}surface`,source:`data-${t}backdrop-source`,group:`data-${t}glass-group`,merge:`data-${t}glass-merge`,morph:`data-${t}glass-morph`,shape:`data-${t}glass-shape`,glassMotion:`data-${t}glass-motion`,drag:`data-${t}glass-drag`}}function g(e,t){return t?e.replace(/\.(-?[_a-zA-Z][\w-]*)/g,(e,n)=>`.${t}${n}`):e}function _(e){return typeof e==`object`&&!!e&&e.nodeType===1}function v(e){return _(e)&&e.hasAttribute(`data-abgin-layer`)}function y(e){return e.nodeType===11&&`host`in e?e.host:null}function b(e){return e.parentElement?e.parentElement:y(e.getRootNode())}function x(e,t){for(let n=t;n;n=y(n.getRootNode()))if(e.contains(n))return!0;return!1}function S(e,t,r={}){let i=r.root??document,a=i.ownerDocument??i,o=a.defaultView;if(!o)return;let s=n(a.documentElement),c=h(s);t.listen(i,`abgin:select`,t=>{let{tab:n,previous:r}=t.detail,i=e(),a=(n?.closest(`[role="tablist"]`))?.querySelector(`:scope > .${s}tabs-indicator`)??null;if(!i||!n||!r?.isConnected||!a)return;let o=i.motion.inspect(a);if(!o?.managed||o.reduced)return;let c=r.getBoundingClientRect(),l=n.getBoundingClientRect(),u=c.left-l.left+o.x,d=c.top-l.top+o.y;i.motion.animate(a,{x:u,y:d},{instant:!0}),i.motion.animate(a,{x:0,y:0})}),t.listen(i,`beforetoggle`,n=>{let r=n,i=r.target,a=e();if(!a||!i.hasAttribute(c.morph)||a.inspect(i)===null||a.motion.inspect(i)?.reduced)return;if(r.newState!==`open`){a.inspect(i)?.path===`layer`&&a.motion.animate(i,{morph:0});return}if(a.stats().backend.state!==`ready`)return;a.morph(i,0),i.style.transitionProperty=`opacity`;let s=()=>{i.style.removeProperty(`transition-property`),i.getAttribute(`style`)||i.removeAttribute(`style`)},l=0,u=()=>{if(t.disposed||a.stopped)s();else if(a.inspect(i)?.path===`layer`){a.morph(i,null),a.motion.animate(i,{morph:0},{instant:!0}),a.motion.animate(i,{morph:1}).then(s);for(let e of i.children)e.hasAttribute(`data-abgin-layer`)||e.animate({opacity:[0,0,1],offset:[0,.4,1]},{duration:280})}else++l>12||!i.isConnected?(a.morph(i,null),s()):o.requestAnimationFrame(u)};o.requestAnimationFrame(u)},!0);let l=t=>{t.isConnected&&t.matches(`:popover-open`)||(e()?.morph(t,null),e()?.motion.cancel(t))};t.listen(i,`toggle`,e=>{let t=e.target;if(e.newState!==`closed`||!t.hasAttribute(c.morph))return;let n=t.getAnimations().map(e=>e.finished);n.length?Promise.allSettled(n).then(()=>{l(t)}):l(t)},!0)}function C(e,t){return e!==`lite`&&t!==`lite`}function w(i){let s=i.document??globalThis.document,c=s?.defaultView??void 0,l=i.gracePeriod??2e3,u=i.importEngine??(()=>import(`./engine-DOFQfCtE.js`).then(e=>e.t)),d=e=>{i.onError?i.onError(e):console.error(`Abgin glass loader:`,e)},f=t(),p=`idle`,m=null,h=null,g=null,_=null,v=!0,y=!1,b=s?i.prefix??n(s.documentElement):``,x=a(`appearance`,b),S=a(`quality`,b),w=a(`transparency`,b),T=`[${x}="glass"], [${S}]`,E=`:is(${[...i.surfaces.filter(e=>e.role!==`container`&&e.layer!==!1).map(e=>e.selector.replace(/\.(-?[_a-zA-Z][\w-]*)/g,`.${b}$1`)),`[data-${b}surface]`].join(`, `)}):not(input, select, textarea, progress, meter, img, video, canvas, iframe, object, embed)`,D=/* @__PURE__ */ new Set,O=/* @__PURE__ */ new Set,k=null,A=!1,j=()=>i.backends?.find(e=>e.supported());function M(){if(i.demand)return i.demand();if(!s||!c||!j()||c.matchMedia(o.forcedColors).matches)return!1;for(let t of D){if(!t.isConnected||!O.has(t))continue;let n=e(t,{prefix:b});if(n.appearance===`glass`&&C(n.quality,i.maxQuality)&&!n.reducedTransparency&&(t.matches(E)||t.querySelector(E)))return!0}return!1}function N(e){e&&(y=!1),A||(A=!0,queueMicrotask(()=>{A=!1,V.update()}))}function P(e,t){D.has(e)||(D.add(e),t.observe(e))}function F(){if(!s||!c||k||p===`closed`)return;let e=f.child();k=e,D.clear(),O.clear();let t=e.track(new c.IntersectionObserver(e=>{for(let t of e)t.isIntersecting?O.add(t.target):O.delete(t.target);N(!1)},{rootMargin:`100px`}));e.track(new c.MutationObserver(e=>{let n=!1;for(let r of e){if(r.type===`attributes`&&r.target.nodeType===1){n=!0;let e=r.target;e.matches(T)&&P(e,t)}for(let e of r.addedNodes){if(e.nodeType!==1)continue;let r=e;r.matches(T)&&P(r,t);for(let e of r.querySelectorAll(T))P(e,t);(r.matches(E)||r.matches(T)||r.querySelector(`${T}, ${E}`))&&(n=!0)}if(r.removedNodes.length)for(let e of[...D])e.isConnected||D.delete(e)}N(n)})).observe(s.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[x,S,w]});for(let e of s.querySelectorAll(T))P(e,t);for(let t of[o.forcedColors,o.reducedTransparency,o.moreContrast])e.listen(c.matchMedia(t),`change`,()=>{N(!0)})}function I(){k?.dispose(),k=null,D.clear(),O.clear()}function L(){_!==null&&clearTimeout(_),_=null}function R(){L();let e=m;m=null,p!==`closed`&&(p=`idle`);try{e?.stop()}catch(e){d(e)}}function z(e){v=e,e?L():_===null&&(_=setTimeout(()=>{_=null,p!==`running`||v||(R(),y=!0,F())},l))}async function B(){p=`loading`;let e=f.child();g=e;try{let t=(await e.settle(u())).createEngine({surfaces:i.surfaces,...s?{document:s}:{},...i.maxQuality?{maxQuality:i.maxQuality}:{},...i.prefix===void 0?{}:{prefix:i.prefix},...i.gracePeriod===void 0?{}:{gracePeriod:i.gracePeriod},...j()?{backend:j()}:{},onDemand:z});await e.settle(t.start(),{discard:()=>{t.stop()}}),m=t,v=!0,p=`running`,I()}catch(e){if(r(e))return;p===`loading`&&(p=`idle`),d(e)}finally{g===e&&(g=null),e.dispose()}}let V={get state(){return p},get engine(){return m},get controller(){return m?.controller??null},update(){return p===`closed`?Promise.resolve():h||(p===`running`?(v&&L(),Promise.resolve()):y||!M()?Promise.resolve():(h=B().finally(()=>{h=null}),h))},close(){if(p===`closed`)return;p=`closed`,L(),g?.dispose(),g=null;let e=m;m=null;try{f.dispose()}catch(e){d(e)}try{e?.stop()}catch(e){d(e)}}};return F(),V}function T(e={}){return{name:`webgl2`,supported:()=>typeof document<`u`&&typeof globalThis.WebGL2RenderingContext==`function`,load:async()=>{let{createWebGLBackend:t}=await import(`./webgl-backend-BE1U7Yp0.js`);return()=>t(e)}}}var E=/* @__PURE__ */ c({startGlass:()=>D});function D(e,t,n,r){let i=t.ownerDocument??t,a=w({surfaces:l,backends:[T({allowSoftware:n.allowSoftware??!1})],document:i,onError:r});e.onDispose(()=>{a.close()}),n.componentMotion!==!1&&S(()=>a.controller,e,{root:t})}export{f as a,_ as c,b as d,g as f,u as i,v as l,p as n,d as o,c as p,m as r,x as s,D as startGlass,E as t,h as u};
|
|
3
|
+
//# sourceMappingURL=glass-9XMne6tP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glass-CrY_zpD7.js","names":["HOSTLESS","(surfaces as SurfaceManifest).surfaces","resolve","createScope","readPrefix","isDisposedError","assertPrefix","attributeName","MEDIA","__defProp","__exportAll","all","flags","target","name","surfaces","\"selector\"","\"role\"","\"layer\"","LAYER_ATTRIBUTE","SHARED_ATTRIBUTE","MOTION_ATTRIBUTE","FITS_ATTRIBUTE","HOSTLESS$1","names","prefix","p","prefixSelector","selector","_","isElement","node","isLayer","hostOf","root","parentOf","element","containsFlat","ancestor","componentMotion","controller","scope","options","doc","view","N","event","tab","previous","engine","mark","before","from","to","x","y","e","panel","opened","frames","wait","child","closed","running","a","qualityAllows","quality","max","createGlassLoader","grace","importEngine","n","report","error","state","starting","startAttempt","stopTimer","engineDemand","suppressed","appearance","transparency","tracked","surfaceSelector","s","regions","visible","observation","queued","backend","b","conditions","el","config","changed","relevant","loader","track","io","resumeObservation","own","entries","entry","records","record","inner","query","pauseObservation","clearStopTimer","stopEngine","current","onDemand","demand","start","attempt","created","createWebGLDescriptor","createWebGLBackend","glass_exports","startGlass","onError"],"sources":["../../../css/dist/surfaces.json","../../../glass/dist/dom.js","../../../glass/dist/components.js","../../../glass/dist/loader.js","../../../glass/dist/webgl.js","../../src/glass.ts"],"sourcesContent":["","// Attribute names and small DOM helpers shared by the engine modules. Nothing here runs at import time.\nimport { assertPrefix, attributeName } from \"@abgin/core/config\";\n/** Marks engine-owned layer elements; mutation records about them are ignored. Never prefixed. */\nexport const LAYER_ATTRIBUTE = \"data-abgin-layer\";\n/**\n * Set by the engine on a surface whose material it draws itself (a glass group member or a morphing surface,\n * D-76); glass CSS hides the surface's CSS material while it is present. Never prefixed, never observed.\n */\nexport const SHARED_ATTRIBUTE = \"data-abgin-shared\";\n/**\n * Set by the engine on a surface whose motion it drives (D-79), with what it does: `press`, `drag`, `drag-x`, `drag-y`,\n * `dragging`. Glass CSS uses it to leave the press response and touch dragging to the engine. Never prefixed, never\n * observed.\n */\nexport const MOTION_ATTRIBUTE = \"data-abgin-motion\";\n/**\n * Set by the engine on a drawn surface that could scroll and whose content fits (D-96): glass CSS takes the scrollbars away, so\n * that the layer is no scrollable overflow of its own. Never prefixed, never observed.\n */\nexport const FITS_ATTRIBUTE = \"data-abgin-fits\";\n/**\n * Elements that draw no child elements, so they cannot host a layer: form controls and replaced elements. They keep the\n * CSS material in every quality (D-90). The loader has its own copy: it must not load this module.\n */\nexport const HOSTLESS = \"input, select, textarea, progress, meter, img, video, canvas, iframe, object, embed\";\nexport function names(prefix) {\n const p = assertPrefix(prefix);\n return {\n prefix: p,\n appearance: attributeName(\"appearance\", p),\n quality: attributeName(\"quality\", p),\n transparency: attributeName(\"transparency\", p),\n material: attributeName(\"material\", p),\n motion: attributeName(\"motion\", p),\n theme: attributeName(\"theme\", p),\n surface: `data-${p}surface`,\n source: `data-${p}backdrop-source`,\n group: `data-${p}glass-group`,\n merge: `data-${p}glass-merge`,\n morph: `data-${p}glass-morph`,\n shape: `data-${p}glass-shape`,\n glassMotion: `data-${p}glass-motion`,\n drag: `data-${p}glass-drag`,\n };\n}\n/** Applies the class prefix to the class selectors of a manifest selector (`.btn` becomes `.ab-btn`). */\nexport function prefixSelector(selector, prefix) {\n return prefix ? selector.replace(/\\.(-?[_a-zA-Z][\\w-]*)/g, (_, name) => `.${prefix}${name}`) : selector;\n}\nexport function isElement(node) {\n return typeof node === \"object\" && node !== null && node.nodeType === 1;\n}\nexport function isLayer(node) {\n return isElement(node) && node.hasAttribute(LAYER_ATTRIBUTE);\n}\n/** The host of a shadow root; null for a document or the root of a detached tree (whose `host` can be a URL part). */\nfunction hostOf(root) {\n return root.nodeType === 11 && \"host\" in root ? root.host : null;\n}\n/** The parent in the flat tree: shadow roots continue at their host. */\nexport function parentOf(element) {\n if (element.parentElement)\n return element.parentElement;\n return hostOf(element.getRootNode());\n}\n/** `ancestor` contains `node` in the flat tree (shadow-including). */\nexport function containsFlat(ancestor, node) {\n for (let n = node; n; n = hostOf(n.getRootNode()))\n if (ancestor.contains(n))\n return true;\n return false;\n}\n//# sourceMappingURL=dom.js.map","// `@abgin/glass/components`: motion of components whose surfaces the engine draws (D-97). Optional: without it, and wherever the\n// engine draws nothing, components move with the CSS springs of their stylesheets. It reads component state as it is in the\n// document (the tab that is selected, the panel that opens), starts engine motion from real geometry, and writes no state, no\n// focus, and no ARIA. One set of listeners; nothing runs while nothing happens.\nimport { LAYER_ATTRIBUTE, names } from \"./dom.js\";\nimport { readPrefix } from \"@abgin/core/config\";\n/** Frames an opened panel may take until the engine draws it; after that it opens without expanding. */\nconst WAIT = 12;\n/** Time in which the content of an expanding panel appears, in milliseconds. */\nconst REVEAL = 280;\n/**\n * Moves the glass mark of tabs (`data-surface=\"container\"` on the list) and expands panels with `data-glass-morph` from their\n * origin shape. `controller` is read when something happens: `() => loader.controller`.\n */\nexport function componentMotion(controller, scope, options = {}) {\n const root = options.root ?? document;\n const doc = root.ownerDocument ?? root;\n const view = doc.defaultView;\n if (!view)\n return;\n const prefix = readPrefix(doc.documentElement);\n const N = names(prefix);\n // Tabs (`@abgin/ui/tabs`): the mark is laid out at the selected tab at once; it is shown on its way from the previous one.\n scope.listen(root, \"abgin:select\", (event) => {\n const { tab, previous } = event.detail;\n const engine = controller();\n const list = tab?.closest('[role=\"tablist\"]');\n const mark = list?.querySelector(`:scope > .${prefix}tabs-indicator`) ?? null;\n if (!engine || !tab || !previous?.isConnected || !mark)\n return;\n const before = engine.motion.inspect(mark);\n if (!before?.managed || before.reduced)\n return;\n const from = previous.getBoundingClientRect();\n const to = tab.getBoundingClientRect();\n // On its way already: from where it is now.\n const x = from.left - to.left + before.x;\n const y = from.top - to.top + before.y;\n void engine.motion.animate(mark, { x, y }, { instant: true });\n void engine.motion.animate(mark, { x: 0, y: 0 });\n });\n // Panels: a popover with a morph origin grows out of it, if the engine draws it before it can be seen much.\n scope.listen(root, \"beforetoggle\", (e) => {\n const event = e;\n const panel = event.target;\n const engine = controller();\n if (!engine || !panel.hasAttribute(N.morph))\n return;\n if (engine.inspect(panel) === null || engine.motion.inspect(panel)?.reduced)\n return;\n if (event.newState !== \"open\") {\n if (engine.inspect(panel)?.path === \"layer\")\n void engine.motion.animate(panel, { morph: 0 });\n return;\n }\n // A panel that is the first thing the engine draws opens like any other.\n if (engine.stats().backend.state !== \"ready\")\n return;\n engine.morph(panel, 0);\n // The shape moves instead of the box: a moving box keeps the CSS material until it rests.\n panel.style.transitionProperty = \"opacity\";\n const opened = () => {\n panel.style.removeProperty(\"transition-property\");\n if (!panel.getAttribute(\"style\"))\n panel.removeAttribute(\"style\");\n };\n let frames = 0;\n const wait = () => {\n if (scope.disposed || engine.stopped) {\n opened();\n return;\n }\n if (engine.inspect(panel)?.path === \"layer\") {\n // From the fixed progress to the springs, at the same value.\n engine.morph(panel, null);\n void engine.motion.animate(panel, { morph: 0 }, { instant: true });\n void engine.motion.animate(panel, { morph: 1 }).then(opened);\n // Content appears where the shape already is: text is never without its surface.\n for (const child of panel.children)\n if (!child.hasAttribute(LAYER_ATTRIBUTE))\n child.animate({ opacity: [0, 0, 1], offset: [0, 0.4, 1] }, { duration: REVEAL });\n }\n else if (++frames > WAIT || !panel.isConnected) {\n engine.morph(panel, null);\n opened();\n }\n else\n view.requestAnimationFrame(wait);\n };\n view.requestAnimationFrame(wait);\n }, true);\n // It contracts while it fades out, where the browser keeps it on screen meanwhile.\n const closed = (panel) => {\n if (panel.isConnected && panel.matches(\":popover-open\"))\n return;\n controller()?.morph(panel, null);\n controller()?.motion.cancel(panel);\n };\n scope.listen(root, \"toggle\", (e) => {\n const panel = e.target;\n if (e.newState !== \"closed\" || !panel.hasAttribute(N.morph))\n return;\n const running = panel.getAnimations().map((a) => a.finished);\n if (running.length)\n void Promise.allSettled(running).then(() => {\n closed(panel);\n });\n else\n closed(panel);\n }, true);\n}\n//# sourceMappingURL=components.js.map","// `@abgin/glass/loader` (BUILD_AND_DISTRIBUTION.md sections 8.1 to 8.3, D-60). Small and dependent on\n// `@abgin/core` only: it watches glass regions with a reduced observer set and imports the engine only when the\n// load conditions hold. While the engine runs, the loader's document observers are disconnected (the engine\n// observes instead), and the engine reports whether any surface still needs it; when none does, the loader stops\n// the engine after the grace period. Every asynchronous step runs in a lifecycle scope, so `close()` during an\n// import or startup releases any engine that arrives after closure.\nimport { MEDIA, readPrefix, resolve, attributeName } from \"@abgin/core/config\";\nimport { createScope, isDisposedError } from \"@abgin/core/lifecycle\";\n/** Elements that cannot host a layer (the same list as in dom.ts; a test compares them). */\nconst HOSTLESS = \"input, select, textarea, progress, meter, img, video, canvas, iframe, object, embed\";\nfunction qualityAllows(quality, max) {\n return quality !== \"lite\" && max !== \"lite\";\n}\nexport function createGlassLoader(options) {\n const doc = options.document ?? globalThis.document;\n const view = doc?.defaultView ?? undefined;\n const grace = options.gracePeriod ?? 2000;\n const importEngine = options.importEngine ?? (() => import(\"./engine.js\"));\n const report = (error) => {\n if (options.onError)\n options.onError(error);\n else\n console.error(\"Abgin glass loader:\", error);\n };\n const scope = createScope();\n let state = \"idle\";\n let engine = null;\n let starting = null;\n let startAttempt = null;\n let stopTimer = null;\n let engineDemand = true;\n /** After the engine was stopped for lack of demand, wait for a change before evaluating again. */\n let suppressed = false;\n // Reduced observer set (glass regions, three attributes, three media queries).\n const prefix = doc ? (options.prefix ?? readPrefix(doc.documentElement)) : \"\";\n const appearance = attributeName(\"appearance\", prefix);\n const quality = attributeName(\"quality\", prefix);\n const transparency = attributeName(\"transparency\", prefix);\n const tracked = `[${appearance}=\"glass\"], [${quality}]`;\n // Containers are opaque content, and native controls have a CSS material only: neither needs the engine.\n const surfaceSelector = `:is(${[\n ...options.surfaces\n .filter((s) => s.role !== \"container\" && s.layer !== false)\n .map((s) => s.selector.replace(/\\.(-?[_a-zA-Z][\\w-]*)/g, `.${prefix}$1`)),\n `[data-${prefix}surface]`,\n ].join(\", \")}):not(${HOSTLESS})`;\n const regions = new Set();\n const visible = new Set();\n let observation = null;\n let queued = false;\n const backend = () => options.backends?.find((b) => b.supported());\n function conditions() {\n if (options.demand)\n return options.demand();\n if (!doc || !view || !backend())\n return false;\n if (view.matchMedia(MEDIA.forcedColors).matches)\n return false;\n for (const el of regions) {\n if (!el.isConnected || !visible.has(el))\n continue;\n const config = resolve(el, { prefix });\n if (config.appearance !== \"glass\" ||\n !qualityAllows(config.quality, options.maxQuality) ||\n config.reducedTransparency)\n continue;\n if (el.matches(surfaceSelector) || el.querySelector(surfaceSelector))\n return true;\n }\n return false;\n }\n /**\n * Queues an evaluation. `relevant` changes (a glass region or surface inserted, a tracked attribute or media\n * preference changed) also lift the suppression; visibility reports alone do not, so resuming observation after\n * an idle stop cannot restart the engine in a loop.\n */\n function changed(relevant) {\n if (relevant)\n suppressed = false;\n if (queued)\n return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n void loader.update();\n });\n }\n function track(el, io) {\n if (regions.has(el))\n return;\n regions.add(el);\n io.observe(el);\n }\n function resumeObservation() {\n if (!doc || !view || observation || state === \"closed\")\n return;\n const own = scope.child();\n observation = own;\n regions.clear();\n visible.clear();\n const io = own.track(new view.IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting)\n visible.add(entry.target);\n else\n visible.delete(entry.target);\n }\n changed(false);\n }, { rootMargin: \"100px\" }));\n const mo = own.track(new view.MutationObserver((records) => {\n let relevant = false;\n for (const record of records) {\n if (record.type === \"attributes\" && record.target.nodeType === 1) {\n relevant = true;\n const target = record.target;\n if (target.matches(tracked))\n track(target, io);\n }\n for (const node of record.addedNodes) {\n if (node.nodeType !== 1)\n continue;\n const el = node;\n if (el.matches(tracked))\n track(el, io);\n for (const inner of el.querySelectorAll(tracked))\n track(inner, io);\n if (el.matches(surfaceSelector) ||\n el.matches(tracked) ||\n el.querySelector(`${tracked}, ${surfaceSelector}`))\n relevant = true;\n }\n if (record.removedNodes.length)\n for (const el of [...regions])\n if (!el.isConnected)\n regions.delete(el);\n }\n changed(relevant);\n }));\n mo.observe(doc.documentElement, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [appearance, quality, transparency],\n });\n for (const el of doc.querySelectorAll(tracked))\n track(el, io);\n for (const query of [MEDIA.forcedColors, MEDIA.reducedTransparency, MEDIA.moreContrast]) {\n own.listen(view.matchMedia(query), \"change\", () => {\n changed(true);\n });\n }\n }\n function pauseObservation() {\n observation?.dispose();\n observation = null;\n regions.clear();\n visible.clear();\n }\n function clearStopTimer() {\n if (stopTimer !== null)\n clearTimeout(stopTimer);\n stopTimer = null;\n }\n function stopEngine() {\n clearStopTimer();\n const current = engine;\n engine = null;\n if (state !== \"closed\")\n state = \"idle\";\n try {\n current?.stop();\n }\n catch (error) {\n report(error);\n }\n }\n function onDemand(demand) {\n engineDemand = demand;\n if (demand) {\n clearStopTimer();\n return;\n }\n if (stopTimer !== null)\n return;\n stopTimer = setTimeout(() => {\n stopTimer = null;\n if (state !== \"running\" || engineDemand)\n return;\n stopEngine();\n suppressed = true;\n resumeObservation();\n }, grace);\n }\n async function start() {\n state = \"loading\";\n const attempt = scope.child();\n startAttempt = attempt;\n try {\n const module = await attempt.settle(importEngine());\n const created = module.createEngine({\n surfaces: options.surfaces,\n ...(doc ? { document: doc } : {}),\n ...(options.maxQuality ? { maxQuality: options.maxQuality } : {}),\n ...(options.prefix !== undefined ? { prefix: options.prefix } : {}),\n ...(options.gracePeriod !== undefined ? { gracePeriod: options.gracePeriod } : {}),\n ...(backend() ? { backend: backend() } : {}),\n onDemand,\n });\n await attempt.settle(created.start(), {\n discard: () => {\n created.stop();\n },\n });\n engine = created;\n engineDemand = true;\n state = \"running\";\n // The engine observes the document now; the loader's observers would only duplicate the work.\n pauseObservation();\n }\n catch (error) {\n if (isDisposedError(error))\n return;\n if (state === \"loading\")\n state = \"idle\";\n report(error);\n }\n finally {\n if (startAttempt === attempt)\n startAttempt = null;\n attempt.dispose();\n }\n }\n const loader = {\n get state() {\n return state;\n },\n get engine() {\n return engine;\n },\n get controller() {\n return engine?.controller ?? null;\n },\n update() {\n if (state === \"closed\")\n return Promise.resolve();\n if (starting)\n return starting;\n if (state === \"running\") {\n if (engineDemand)\n clearStopTimer();\n return Promise.resolve();\n }\n if (suppressed || !conditions())\n return Promise.resolve();\n starting = start().finally(() => {\n starting = null;\n });\n return starting;\n },\n close() {\n if (state === \"closed\")\n return;\n state = \"closed\";\n clearStopTimer();\n startAttempt?.dispose();\n startAttempt = null;\n const current = engine;\n engine = null;\n try {\n scope.dispose();\n }\n catch (error) {\n report(error);\n }\n try {\n current?.stop();\n }\n catch (error) {\n report(error);\n }\n },\n };\n resumeObservation();\n return loader;\n}\n//# sourceMappingURL=loader.js.map","// `@abgin/glass/webgl`: the descriptor of the WebGL 2 optical backend (D-74). It is small and SSR-safe: the\n// capability check reads globals only, and the backend itself (shaders, context, textures) is a separate module\n// that is imported when the engine first needs it. Nothing here creates a context. Usage: pass `webglBackend` to\n// the loader, as in `createGlassLoader({ surfaces, backends: [webglBackend] })`.\n/** A descriptor with options (software renderers, a diagnostic output, the texture size bound). */\nexport function createWebGLDescriptor(options = {}) {\n return {\n name: \"webgl2\",\n // Cheap and side-effect free: whether a context can really be created is decided in `init()`, and a failure\n // there keeps the CSS material (the backend is not retried).\n supported: () => typeof document !== \"undefined\" &&\n typeof globalThis.WebGL2RenderingContext === \"function\",\n load: async () => {\n const { createWebGLBackend } = await import(\"./webgl-backend.js\");\n return () => createWebGLBackend(options);\n },\n };\n}\n/** The default WebGL 2 backend: hardware rendering only, production material output. */\nexport const webglBackend = createWebGLDescriptor();\n//# sourceMappingURL=webgl.js.map","// The glass part of the standalone distribution: a lazy chunk that only `start({ glass })` loads. The loader in it imports\n// the engine, the WebGL 2 backend, and motion only when a glass surface needs them (BUILD_AND_DISTRIBUTION.md section 8).\n\nimport type { Scope } from \"@abgin/core/lifecycle\";\nimport surfaces from \"@abgin/css/surfaces.json\" with { type: \"json\" };\nimport { componentMotion } from \"@abgin/glass/components\";\nimport { createGlassLoader } from \"@abgin/glass/loader\";\nimport { createWebGLDescriptor } from \"@abgin/glass/webgl\";\nimport type { SurfaceManifest } from \"@abgin/glass\";\nimport type { GlassStartOptions } from \"./index.ts\";\n\nexport function startGlass(\n scope: Scope,\n root: Document | ShadowRoot,\n options: GlassStartOptions,\n onError: (error: unknown) => void,\n): void {\n const doc = root.ownerDocument ?? root;\n const loader = createGlassLoader({\n surfaces: (surfaces as SurfaceManifest).surfaces,\n backends: [createWebGLDescriptor({ allowSoftware: options.allowSoftware ?? false })],\n document: doc,\n onError,\n });\n scope.onDispose(() => {\n loader.close();\n });\n if (options.componentMotion !== false) componentMotion(() => loader.controller, scope, { root });\n}\n"],"mappings":";A,q+CCGA,MAAamB,EAAkB,mBAKlBC,EAAmB,oBAMnBC,EAAmB,oBAKnBC,EAAiB,kBAKjBtB,EAAW,sFACxB,SAAgBwB,EAAMC,EAAQ,CAC1B,IAAMC,EAAIpB,EAAamB,CAAM,EAC7B,MAAO,CACH,OAAQC,EACR,WAAYnB,EAAc,aAAcmB,CAAC,EACzC,QAASnB,EAAc,UAAWmB,CAAC,EACnC,aAAcnB,EAAc,eAAgBmB,CAAC,EAC7C,SAAUnB,EAAc,WAAYmB,CAAC,EACrC,OAAQnB,EAAc,SAAUmB,CAAC,EACjC,MAAOnB,EAAc,QAASmB,CAAC,EAC/B,QAAS,QAAQA,EAAE,SACnB,OAAQ,QAAQA,EAAE,iBAClB,MAAO,QAAQA,EAAE,aACjB,MAAO,QAAQA,EAAE,aACjB,MAA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CAAC,YAAc,CAC7BtC,EAAW,IACf,CAAC,EACMA,GACX,EACA,OAAQ,CACJ,GAAID,IAAU,SACV,OACJA,EAAQ,SACRkC,EAAe,EACfhC,GAAc,QAAQ,EACtBA,EAAe,KACf,IAAMkC,EAAU7D,EAChBA,EAAS,KACT,GAAI,CACAR,EAAM,QAAQ,CAClB,OACOgC,EAAO,CACVD,EAAOC,CAAK,CAChB,CACA,GAAI,CACAqC,GAAS,KAAK,CAClB,OACOrC,EAAO,CACVD,EAAOC,CAAK,CAChB,CACJ,CACJ,EAEA,OADA0B,EAAkB,EACXH,CACX,CCvRA,SAAgBoB,EAAsB1E,EAAU,CAAC,EAAG,CAChD,MAAO,CACH,KAAM,SAGN,cAAiB,OAAO,SAAa,KACjC,OAAO,WAAW,wBAA2B,WACjD,KAAM,SAAY,CACd,GAAM,CAAE2E,sBAAuB,MAAM,OAAO,+BAC5C,UAAaA,EAAmB3E,CAAO,CAC3C,CACJ,CACJ,C,4CCNA,SAAgB6E,EACd9E,EACAP,EACAQ,EACA8E,EACM,CACN,IAAM7E,EAAMT,EAAK,eAAiBA,EAC5B8D,EAAS5B,EAAkB,CACrBnE,WACV,SAAU,CAACmH,EAAsB,CAAE,cAAe1E,EAAQ,eAAiB,EAAM,CAAC,CAAC,EACnF,SAAUC,EACV6E,SACF,CAAC,EACD/E,EAAM,cAAgB,CACpBuD,EAAO,MAAM,CACf,CAAC,EACGtD,EAAQ,kBAAoB,IAAOH,MAAsByD,EAAO,WAAYvD,EAAO,CAAEP,MAAK,CAAC,CACjG,C"}
|
|
1
|
+
{"version":3,"file":"glass-9XMne6tP.js","names":["HOSTLESS","(surfaces as SurfaceManifest).surfaces","resolve","createScope","readPrefix","isDisposedError","assertPrefix","attributeName","MEDIA","__defProp","__exportAll","all","flags","target","name","surfaces","\"selector\"","\"role\"","\"layer\"","LAYER_ATTRIBUTE","SHARED_ATTRIBUTE","MOTION_ATTRIBUTE","FITS_ATTRIBUTE","HOSTLESS$1","names","prefix","p","prefixSelector","selector","_","isElement","node","isLayer","hostOf","root","parentOf","element","containsFlat","ancestor","componentMotion","controller","scope","options","doc","view","N","event","tab","previous","engine","mark","before","from","to","x","y","e","panel","opened","frames","wait","child","closed","running","a","qualityAllows","quality","max","createGlassLoader","grace","importEngine","n","report","error","state","starting","startAttempt","stopTimer","engineDemand","suppressed","appearance","transparency","tracked","surfaceSelector","s","regions","visible","observation","queued","backend","b","conditions","el","config","changed","relevant","loader","track","io","resumeObservation","own","entries","entry","records","record","inner","query","pauseObservation","clearStopTimer","stopEngine","current","onDemand","demand","start","attempt","created","createWebGLDescriptor","createWebGLBackend","glass_exports","startGlass","onError"],"sources":["../../../css/dist/surfaces.json","../../../glass/dist/dom.js","../../../glass/dist/components.js","../../../glass/dist/loader.js","../../../glass/dist/webgl.js","../../src/glass.ts"],"sourcesContent":["","// Attribute names and small DOM helpers shared by the engine modules. Nothing here runs at import time.\nimport { assertPrefix, attributeName } from \"@abgin/core/config\";\n/** Marks engine-owned layer elements; mutation records about them are ignored. Never prefixed. */\nexport const LAYER_ATTRIBUTE = \"data-abgin-layer\";\n/**\n * Set by the engine on a surface whose material it draws itself (a glass group member or a morphing surface,\n * D-76); glass CSS hides the surface's CSS material while it is present. Never prefixed, never observed.\n */\nexport const SHARED_ATTRIBUTE = \"data-abgin-shared\";\n/**\n * Set by the engine on a surface whose motion it drives (D-79), with what it does: `press`, `drag`, `drag-x`, `drag-y`,\n * `dragging`. Glass CSS uses it to leave the press response and touch dragging to the engine. Never prefixed, never\n * observed.\n */\nexport const MOTION_ATTRIBUTE = \"data-abgin-motion\";\n/**\n * Set by the engine on a drawn surface that could scroll and whose content fits (D-96): glass CSS takes the scrollbars away, so\n * that the layer is no scrollable overflow of its own. Never prefixed, never observed.\n */\nexport const FITS_ATTRIBUTE = \"data-abgin-fits\";\n/**\n * Elements that draw no child elements, so they cannot host a layer: form controls and replaced elements. They keep the\n * CSS material in every quality (D-90). The loader has its own copy: it must not load this module.\n */\nexport const HOSTLESS = \"input, select, textarea, progress, meter, img, video, canvas, iframe, object, embed\";\nexport function names(prefix) {\n const p = assertPrefix(prefix);\n return {\n prefix: p,\n appearance: attributeName(\"appearance\", p),\n quality: attributeName(\"quality\", p),\n transparency: attributeName(\"transparency\", p),\n material: attributeName(\"material\", p),\n motion: attributeName(\"motion\", p),\n theme: attributeName(\"theme\", p),\n surface: `data-${p}surface`,\n source: `data-${p}backdrop-source`,\n group: `data-${p}glass-group`,\n merge: `data-${p}glass-merge`,\n morph: `data-${p}glass-morph`,\n shape: `data-${p}glass-shape`,\n glassMotion: `data-${p}glass-motion`,\n drag: `data-${p}glass-drag`,\n };\n}\n/** Applies the class prefix to the class selectors of a manifest selector (`.btn` becomes `.ab-btn`). */\nexport function prefixSelector(selector, prefix) {\n return prefix ? selector.replace(/\\.(-?[_a-zA-Z][\\w-]*)/g, (_, name) => `.${prefix}${name}`) : selector;\n}\nexport function isElement(node) {\n return typeof node === \"object\" && node !== null && node.nodeType === 1;\n}\nexport function isLayer(node) {\n return isElement(node) && node.hasAttribute(LAYER_ATTRIBUTE);\n}\n/** The host of a shadow root; null for a document or the root of a detached tree (whose `host` can be a URL part). */\nfunction hostOf(root) {\n return root.nodeType === 11 && \"host\" in root ? root.host : null;\n}\n/** The parent in the flat tree: shadow roots continue at their host. */\nexport function parentOf(element) {\n if (element.parentElement)\n return element.parentElement;\n return hostOf(element.getRootNode());\n}\n/** `ancestor` contains `node` in the flat tree (shadow-including). */\nexport function containsFlat(ancestor, node) {\n for (let n = node; n; n = hostOf(n.getRootNode()))\n if (ancestor.contains(n))\n return true;\n return false;\n}\n//# sourceMappingURL=dom.js.map","// `@abgin/glass/components`: motion of components whose surfaces the engine draws (D-97). Optional: without it, and wherever the\n// engine draws nothing, components move with the CSS springs of their stylesheets. It reads component state as it is in the\n// document (the tab that is selected, the panel that opens), starts engine motion from real geometry, and writes no state, no\n// focus, and no ARIA. One set of listeners; nothing runs while nothing happens.\nimport { LAYER_ATTRIBUTE, names } from \"./dom.js\";\nimport { readPrefix } from \"@abgin/core/config\";\n/** Frames an opened panel may take until the engine draws it; after that it opens without expanding. */\nconst WAIT = 12;\n/** Time in which the content of an expanding panel appears, in milliseconds. */\nconst REVEAL = 280;\n/**\n * Moves the glass mark of tabs (`data-surface=\"container\"` on the list) and expands panels with `data-glass-morph` from their\n * origin shape. `controller` is read when something happens: `() => loader.controller`.\n */\nexport function componentMotion(controller, scope, options = {}) {\n const root = options.root ?? document;\n const doc = root.ownerDocument ?? root;\n const view = doc.defaultView;\n if (!view)\n return;\n const prefix = readPrefix(doc.documentElement);\n const N = names(prefix);\n // Tabs (`@abgin/ui/tabs`): the mark is laid out at the selected tab at once; it is shown on its way from the previous one.\n scope.listen(root, \"abgin:select\", (event) => {\n const { tab, previous } = event.detail;\n const engine = controller();\n const list = tab?.closest('[role=\"tablist\"]');\n const mark = list?.querySelector(`:scope > .${prefix}tabs-indicator`) ?? null;\n if (!engine || !tab || !previous?.isConnected || !mark)\n return;\n const before = engine.motion.inspect(mark);\n if (!before?.managed || before.reduced)\n return;\n const from = previous.getBoundingClientRect();\n const to = tab.getBoundingClientRect();\n // On its way already: from where it is now.\n const x = from.left - to.left + before.x;\n const y = from.top - to.top + before.y;\n void engine.motion.animate(mark, { x, y }, { instant: true });\n void engine.motion.animate(mark, { x: 0, y: 0 });\n });\n // Panels: a popover with a morph origin grows out of it, if the engine draws it before it can be seen much.\n scope.listen(root, \"beforetoggle\", (e) => {\n const event = e;\n const panel = event.target;\n const engine = controller();\n if (!engine || !panel.hasAttribute(N.morph))\n return;\n if (engine.inspect(panel) === null || engine.motion.inspect(panel)?.reduced)\n return;\n if (event.newState !== \"open\") {\n if (engine.inspect(panel)?.path === \"layer\")\n void engine.motion.animate(panel, { morph: 0 });\n return;\n }\n // A panel that is the first thing the engine draws opens like any other.\n if (engine.stats().backend.state !== \"ready\")\n return;\n engine.morph(panel, 0);\n // The shape moves instead of the box: a moving box keeps the CSS material until it rests.\n panel.style.transitionProperty = \"opacity\";\n const opened = () => {\n panel.style.removeProperty(\"transition-property\");\n if (!panel.getAttribute(\"style\"))\n panel.removeAttribute(\"style\");\n };\n let frames = 0;\n const wait = () => {\n if (scope.disposed || engine.stopped) {\n opened();\n return;\n }\n if (engine.inspect(panel)?.path === \"layer\") {\n // From the fixed progress to the springs, at the same value.\n engine.morph(panel, null);\n void engine.motion.animate(panel, { morph: 0 }, { instant: true });\n void engine.motion.animate(panel, { morph: 1 }).then(opened);\n // Content appears where the shape already is: text is never without its surface.\n for (const child of panel.children)\n if (!child.hasAttribute(LAYER_ATTRIBUTE))\n child.animate({ opacity: [0, 0, 1], offset: [0, 0.4, 1] }, { duration: REVEAL });\n }\n else if (++frames > WAIT || !panel.isConnected) {\n engine.morph(panel, null);\n opened();\n }\n else\n view.requestAnimationFrame(wait);\n };\n view.requestAnimationFrame(wait);\n }, true);\n // It contracts while it fades out, where the browser keeps it on screen meanwhile.\n const closed = (panel) => {\n if (panel.isConnected && panel.matches(\":popover-open\"))\n return;\n controller()?.morph(panel, null);\n controller()?.motion.cancel(panel);\n };\n scope.listen(root, \"toggle\", (e) => {\n const panel = e.target;\n if (e.newState !== \"closed\" || !panel.hasAttribute(N.morph))\n return;\n const running = panel.getAnimations().map((a) => a.finished);\n if (running.length)\n void Promise.allSettled(running).then(() => {\n closed(panel);\n });\n else\n closed(panel);\n }, true);\n}\n//# sourceMappingURL=components.js.map","// `@abgin/glass/loader` (BUILD_AND_DISTRIBUTION.md sections 8.1 to 8.3, D-60). Small and dependent on\n// `@abgin/core` only: it watches glass regions with a reduced observer set and imports the engine only when the\n// load conditions hold. While the engine runs, the loader's document observers are disconnected (the engine\n// observes instead), and the engine reports whether any surface still needs it; when none does, the loader stops\n// the engine after the grace period. Every asynchronous step runs in a lifecycle scope, so `close()` during an\n// import or startup releases any engine that arrives after closure.\nimport { MEDIA, readPrefix, resolve, attributeName } from \"@abgin/core/config\";\nimport { createScope, isDisposedError } from \"@abgin/core/lifecycle\";\n/** Elements that cannot host a layer (the same list as in dom.ts; a test compares them). */\nconst HOSTLESS = \"input, select, textarea, progress, meter, img, video, canvas, iframe, object, embed\";\nfunction qualityAllows(quality, max) {\n return quality !== \"lite\" && max !== \"lite\";\n}\nexport function createGlassLoader(options) {\n const doc = options.document ?? globalThis.document;\n const view = doc?.defaultView ?? undefined;\n const grace = options.gracePeriod ?? 2000;\n const importEngine = options.importEngine ?? (() => import(\"./engine.js\"));\n const report = (error) => {\n if (options.onError)\n options.onError(error);\n else\n console.error(\"Abgin glass loader:\", error);\n };\n const scope = createScope();\n let state = \"idle\";\n let engine = null;\n let starting = null;\n let startAttempt = null;\n let stopTimer = null;\n let engineDemand = true;\n /** After the engine was stopped for lack of demand, wait for a change before evaluating again. */\n let suppressed = false;\n // Reduced observer set (glass regions, three attributes, three media queries).\n const prefix = doc ? (options.prefix ?? readPrefix(doc.documentElement)) : \"\";\n const appearance = attributeName(\"appearance\", prefix);\n const quality = attributeName(\"quality\", prefix);\n const transparency = attributeName(\"transparency\", prefix);\n const tracked = `[${appearance}=\"glass\"], [${quality}]`;\n // Containers are opaque content, and native controls have a CSS material only: neither needs the engine.\n const surfaceSelector = `:is(${[\n ...options.surfaces\n .filter((s) => s.role !== \"container\" && s.layer !== false)\n .map((s) => s.selector.replace(/\\.(-?[_a-zA-Z][\\w-]*)/g, `.${prefix}$1`)),\n `[data-${prefix}surface]`,\n ].join(\", \")}):not(${HOSTLESS})`;\n const regions = new Set();\n const visible = new Set();\n let observation = null;\n let queued = false;\n const backend = () => options.backends?.find((b) => b.supported());\n function conditions() {\n if (options.demand)\n return options.demand();\n if (!doc || !view || !backend())\n return false;\n if (view.matchMedia(MEDIA.forcedColors).matches)\n return false;\n for (const el of regions) {\n if (!el.isConnected || !visible.has(el))\n continue;\n const config = resolve(el, { prefix });\n if (config.appearance !== \"glass\" ||\n !qualityAllows(config.quality, options.maxQuality) ||\n config.reducedTransparency)\n continue;\n if (el.matches(surfaceSelector) || el.querySelector(surfaceSelector))\n return true;\n }\n return false;\n }\n /**\n * Queues an evaluation. `relevant` changes (a glass region or surface inserted, a tracked attribute or media\n * preference changed) also lift the suppression; visibility reports alone do not, so resuming observation after\n * an idle stop cannot restart the engine in a loop.\n */\n function changed(relevant) {\n if (relevant)\n suppressed = false;\n if (queued)\n return;\n queued = true;\n queueMicrotask(() => {\n queued = false;\n void loader.update();\n });\n }\n function track(el, io) {\n if (regions.has(el))\n return;\n regions.add(el);\n io.observe(el);\n }\n function resumeObservation() {\n if (!doc || !view || observation || state === \"closed\")\n return;\n const own = scope.child();\n observation = own;\n regions.clear();\n visible.clear();\n const io = own.track(new view.IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting)\n visible.add(entry.target);\n else\n visible.delete(entry.target);\n }\n changed(false);\n }, { rootMargin: \"100px\" }));\n const mo = own.track(new view.MutationObserver((records) => {\n let relevant = false;\n for (const record of records) {\n if (record.type === \"attributes\" && record.target.nodeType === 1) {\n relevant = true;\n const target = record.target;\n if (target.matches(tracked))\n track(target, io);\n }\n for (const node of record.addedNodes) {\n if (node.nodeType !== 1)\n continue;\n const el = node;\n if (el.matches(tracked))\n track(el, io);\n for (const inner of el.querySelectorAll(tracked))\n track(inner, io);\n if (el.matches(surfaceSelector) ||\n el.matches(tracked) ||\n el.querySelector(`${tracked}, ${surfaceSelector}`))\n relevant = true;\n }\n if (record.removedNodes.length)\n for (const el of [...regions])\n if (!el.isConnected)\n regions.delete(el);\n }\n changed(relevant);\n }));\n mo.observe(doc.documentElement, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [appearance, quality, transparency],\n });\n for (const el of doc.querySelectorAll(tracked))\n track(el, io);\n for (const query of [MEDIA.forcedColors, MEDIA.reducedTransparency, MEDIA.moreContrast]) {\n own.listen(view.matchMedia(query), \"change\", () => {\n changed(true);\n });\n }\n }\n function pauseObservation() {\n observation?.dispose();\n observation = null;\n regions.clear();\n visible.clear();\n }\n function clearStopTimer() {\n if (stopTimer !== null)\n clearTimeout(stopTimer);\n stopTimer = null;\n }\n function stopEngine() {\n clearStopTimer();\n const current = engine;\n engine = null;\n if (state !== \"closed\")\n state = \"idle\";\n try {\n current?.stop();\n }\n catch (error) {\n report(error);\n }\n }\n function onDemand(demand) {\n engineDemand = demand;\n if (demand) {\n clearStopTimer();\n return;\n }\n if (stopTimer !== null)\n return;\n stopTimer = setTimeout(() => {\n stopTimer = null;\n if (state !== \"running\" || engineDemand)\n return;\n stopEngine();\n suppressed = true;\n resumeObservation();\n }, grace);\n }\n async function start() {\n state = \"loading\";\n const attempt = scope.child();\n startAttempt = attempt;\n try {\n const module = await attempt.settle(importEngine());\n const created = module.createEngine({\n surfaces: options.surfaces,\n ...(doc ? { document: doc } : {}),\n ...(options.maxQuality ? { maxQuality: options.maxQuality } : {}),\n ...(options.prefix !== undefined ? { prefix: options.prefix } : {}),\n ...(options.gracePeriod !== undefined ? { gracePeriod: options.gracePeriod } : {}),\n ...(backend() ? { backend: backend() } : {}),\n onDemand,\n });\n await attempt.settle(created.start(), {\n discard: () => {\n created.stop();\n },\n });\n engine = created;\n engineDemand = true;\n state = \"running\";\n // The engine observes the document now; the loader's observers would only duplicate the work.\n pauseObservation();\n }\n catch (error) {\n if (isDisposedError(error))\n return;\n if (state === \"loading\")\n state = \"idle\";\n report(error);\n }\n finally {\n if (startAttempt === attempt)\n startAttempt = null;\n attempt.dispose();\n }\n }\n const loader = {\n get state() {\n return state;\n },\n get engine() {\n return engine;\n },\n get controller() {\n return engine?.controller ?? null;\n },\n update() {\n if (state === \"closed\")\n return Promise.resolve();\n if (starting)\n return starting;\n if (state === \"running\") {\n if (engineDemand)\n clearStopTimer();\n return Promise.resolve();\n }\n if (suppressed || !conditions())\n return Promise.resolve();\n starting = start().finally(() => {\n starting = null;\n });\n return starting;\n },\n close() {\n if (state === \"closed\")\n return;\n state = \"closed\";\n clearStopTimer();\n startAttempt?.dispose();\n startAttempt = null;\n const current = engine;\n engine = null;\n try {\n scope.dispose();\n }\n catch (error) {\n report(error);\n }\n try {\n current?.stop();\n }\n catch (error) {\n report(error);\n }\n },\n };\n resumeObservation();\n return loader;\n}\n//# sourceMappingURL=loader.js.map","// `@abgin/glass/webgl`: the descriptor of the WebGL 2 optical backend (D-74). It is small and SSR-safe: the\n// capability check reads globals only, and the backend itself (shaders, context, textures) is a separate module\n// that is imported when the engine first needs it. Nothing here creates a context. Usage: pass `webglBackend` to\n// the loader, as in `createGlassLoader({ surfaces, backends: [webglBackend] })`.\n/** A descriptor with options (software renderers, a diagnostic output, the texture size bound). */\nexport function createWebGLDescriptor(options = {}) {\n return {\n name: \"webgl2\",\n // Cheap and side-effect free: whether a context can really be created is decided in `init()`, and a failure\n // there keeps the CSS material (the backend is not retried).\n supported: () => typeof document !== \"undefined\" &&\n typeof globalThis.WebGL2RenderingContext === \"function\",\n load: async () => {\n const { createWebGLBackend } = await import(\"./webgl-backend.js\");\n return () => createWebGLBackend(options);\n },\n };\n}\n/** The default WebGL 2 backend: hardware rendering only, production material output. */\nexport const webglBackend = createWebGLDescriptor();\n//# sourceMappingURL=webgl.js.map","// The glass part of the standalone distribution: a lazy chunk that only `start({ glass })` loads. The loader in it imports\n// the engine, the WebGL 2 backend, and motion only when a glass surface needs them (BUILD_AND_DISTRIBUTION.md section 8).\n\nimport type { Scope } from \"@abgin/core/lifecycle\";\nimport surfaces from \"@abgin/css/surfaces.json\" with { type: \"json\" };\nimport { componentMotion } from \"@abgin/glass/components\";\nimport { createGlassLoader } from \"@abgin/glass/loader\";\nimport { createWebGLDescriptor } from \"@abgin/glass/webgl\";\nimport type { SurfaceManifest } from \"@abgin/glass\";\nimport type { GlassStartOptions } from \"./index.ts\";\n\nexport function startGlass(\n scope: Scope,\n root: Document | ShadowRoot,\n options: GlassStartOptions,\n onError: (error: unknown) => void,\n): void {\n const doc = root.ownerDocument ?? root;\n const loader = createGlassLoader({\n surfaces: (surfaces as SurfaceManifest).surfaces,\n backends: [createWebGLDescriptor({ allowSoftware: options.allowSoftware ?? false })],\n document: doc,\n onError,\n });\n scope.onDispose(() => {\n loader.close();\n });\n if (options.componentMotion !== false) componentMotion(() => loader.controller, scope, { root });\n}\n"],"mappings":";A,q+CCGA,MAAamB,EAAkB,mBAKlBC,EAAmB,oBAMnBC,EAAmB,oBAKnBC,EAAiB,kBAKjBtB,EAAW,sFACxB,SAAgBwB,EAAMC,EAAQ,CAC1B,IAAMC,EAAIpB,EAAamB,CAAM,EAC7B,MAAO,CACH,OAAQC,EACR,WAAYnB,EAAc,aAAcmB,CAAC,EACzC,QAASnB,EAAc,UAAWmB,CAAC,EACnC,aAAcnB,EAAc,eAAgBmB,CAAC,EAC7C,SAAUnB,EAAc,WAAYmB,CAAC,EACrC,OAAQnB,EAAc,SAAUmB,CAAC,EACjC,MAAOnB,EAAc,QAASmB,CAAC,EAC/B,QAAS,QAAQA,EAAE,SACnB,OAAQ,QAAQA,EAAE,iBAClB,MAAO,QAAQA,EAAE,aACjB,MAAO,QAAQA,EAAE,aACjB,MAAO,QAAQA,EAAE,aACjB,MAAO,QAAQA,EAAE,aACjB,YAAa,QAAQA,EAAE,cACvB,KAAM,QAAQA,EAAE,WACpB,CACJ,CAEA,SAAgBC,EAAeC,EAAUH,EAAQ,CAC7C,OAAOA,EAASG,EAAS,QAAQ,0BAA2BC,EAAGf,IAAS,IAAIW,IAASX,GAAM,EAAIc,CACnG,CACA,SAAgBE,EAAUC,EAAM,CAC5B,OAAO,OAAOA,GAAS,YAAYA,GAAiBA,EAAK,WAAa,CAC1E,CACA,SAAgBC,EAAQD,EAAM,CAC1B,OAAOD,EAAUC,CAAI,GAAKA,EAAK,aAAA,kBAA4B,CAC/D,CAEA,SAASE,EAAOC,EAAM,CAClB,OAAOA,EAAK,WAAa,IAAM,SAAUA,EAAOA,EAAK,KAAO,IAChE,CAEA,SAAgBC,EAASC,EAAS,CAG9B,OAFIA,EAAQ,cACDA,EAAQ,cACZH,EAAOG,EAAQ,YAAY,CAAC,CACvC,CAEA,SAAgBC,EAAaC,EAAUP,EAAM,C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,EACAQ,EACA8E,EACM,CACN,IAAM7E,EAAMT,EAAK,eAAiBA,EAC5B8D,EAAS5B,EAAkB,CACrBnE,WACV,SAAU,CAACmH,EAAsB,CAAE,cAAe1E,EAAQ,eAAiB,EAAM,CAAC,CAAC,EACnF,SAAUC,EACV6E,SACF,CAAC,EACD/E,EAAM,cAAgB,CACpBuD,EAAO,MAAM,CACf,CAAC,EACGtD,EAAQ,kBAAoB,IAAOH,MAAsByD,EAAO,WAAYvD,EAAO,CAAEP,MAAK,CAAC,CACjG,C"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! @abgin/abgin 0.1.2 | MIT License */
|
|
2
|
+
import{i as e}from"../abgin.js";import{t}from"./behavior-DcTSsbjM.js";import{t as n}from"./dialog-YuGr7AZw.js";import{t as r}from"./overlay-CKgXnT5J.js";const i=/* @__PURE__ */ t({name:`modal`,setup(t,i){n(t,i,`.${e(r(t).documentElement)}modal`)}});export{i as modal};
|
|
3
|
+
//# sourceMappingURL=modal-GUayszcw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-
|
|
1
|
+
{"version":3,"file":"modal-GUayszcw.js","names":["readPrefix","dialogs","documentOf","modal","defineBehavior","root","scope"],"sources":["../../../ui/dist/modal.js"],"sourcesContent":["// Modal (COMPONENT_STANDARD.md section 10.6). Optional: a dialog works without it where the browser has invoker commands.\nimport { readPrefix } from \"@abgin/core/config\";\nimport { defineBehavior } from \"./behavior.js\";\nimport { dialogs } from \"./dialog.js\";\nimport { documentOf } from \"./overlay.js\";\n/** Mount it on a document once; dialogs that are inserted later need nothing. */\nexport const modal = /* @__PURE__ */ defineBehavior({\n name: \"modal\",\n setup(root, scope) {\n dialogs(root, scope, `.${readPrefix(documentOf(root).documentElement)}modal`);\n },\n});\n//# sourceMappingURL=modal.js.map"],"mappings":";A,yJAMA,MAAaG,EAAwBC,kBAAe,CAChD,KAAM,QACN,MAAMC,EAAMC,EAAO,CACfL,EAAQI,EAAMC,EAAO,IAAIN,EAAWE,EAAWG,CAAI,CAAC,CAAC,eAAe,EAAE,MAAM,CAChF,CACJ,CAAC,E"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @abgin/abgin 0.1.
|
|
2
|
-
import{a as e,c as t}from"./glass-CrY_zpD7.js";import{a as n,i as r,n as i,o as a,r as o}from"./engine-CLGg6TrP.js";const s={mouse:4,pen:6,touch:10},c=`input, textarea, select, option, [contenteditable=""], [contenteditable="true"], video, audio`;function l(e,t){let n=e.filter(e=>t-e.t<=100),r=n[0],i=n[n.length-1];if(!r||!i||t-i.t>60)return[0,0];let a=(i.t-r.t)/1e3;if(!(a>0))return[0,0];let o=e=>Math.min(4e3,Math.max(-4e3,e));return[o((i.x-r.x)/a),o((i.y-r.y)/a)]}function u(e,t,n){if(!(t>0)||!(n>0)||!Number.isFinite(e))return 0;let r=Math.abs(e)*n;return Math.sign(e)*t*(1-1/(r/t+1))}function d(e,n,r){let i=e.defaultView,a=n.child(),o=/* @__PURE__ */ new Map,u=null,d=null,f=null,p=null,m=null,h=null,g=e=>e.composedPath().filter(t),_=e=>{for(let t of g(e)){let e=r.find(t);if(e)return e}return null},v=e=>e.matches(`:disabled, [aria-disabled="true"]`),y=e=>({x:e.clientX,y:e.clientY});function b(e,t){if(u&&u.element!==e?.element){let e=u;u=null,r.hover(e,null)}u=e,e&&r.hover(e,t),x()}function x(){let t=u!==null||o.size>0;t&&!h?h=a.listen(e,`pointermove`,T,{capture:!0,passive:!0}):!t&&h&&(h(),h=null)}function S(e,t,n){e.down!==t&&(e.down=t,e.target.interactive&&r.press(e.target,t,n))}function C(e,t,n,i){if(o.delete(e.id),e.dragging){e.dragging=!1,m=t?null:{element:e.target.element,time:i};let[n,a]=t?[0,0]:l(e.samples,i),o=e.target.drag;r.dragEnd(e.target,o===`y`?0:n,o===`x`?0:a,t);try{e.target.element.releasePointerCapture(e.id)}catch{}}S(e,!1,n),x()}function w(t){t.dragging=!0,S(t,!1,null);try{t.target.element.setPointerCapture(t.id)}catch{}let n=e.getSelection();n?.anchorNode&&t.target.element.contains(n.anchorNode)&&n.removeAllRanges(),r.dragStart(t.target)}function T(e){let t=e,n=o.get(t.pointerId);if(n){let e=t.clientX-n.x,i=t.clientY-n.y;n.samples.push({t:t.timeStamp,x:t.clientX,y:t.clientY}),n.samples.length>32&&n.samples.shift();let a=n.target.drag;if(n.draggable&&a&&!n.dragging&&(a===`x`?Math.abs(e):a===`y`?Math.abs(i):Math.hypot(e,i))>=s[n.type]&&w(n),n.dragging)r.dragMove(n.target,a===`y`?0:e,a===`x`?0:i);else{let e=n.target.element.getBoundingClientRect();S(n,t.clientX>=e.left-12&&t.clientX<=e.right+12&&t.clientY>=e.top-12&&t.clientY<=e.bottom+12,y(t))}}u&&t.pointerType!==`touch`&&r.hover(u,y(t))}a.listen(e,`pointerover`,e=>{let t=e;if(t.pointerType===`touch`)return;let n=_(t);b(n?.interactive&&!v(n.element)?n:null,y(t))},{capture:!0,passive:!0}),a.listen(e,`pointerout`,e=>{e.relatedTarget===null&&u&&b(null,null)},{capture:!0,passive:!0}),a.listen(e,`pointerdown`,e=>{let t=e;if(m=null,t.button!==0||!t.isPrimary)return;let n=_(t);if(!n||v(n.element))return;let r=o.get(t.pointerId);r&&C(r,!0,null,t.timeStamp);let i=!1;for(let e of g(t)){if(e===n.element)break;e.matches(`${c}, a[href], button`)&&(i=!0)}let a={id:t.pointerId,target:n,x:t.clientX,y:t.clientY,type:t.pointerType===`touch`||t.pointerType===`pen`?t.pointerType:`mouse`,draggable:n.drag!==null&&!i&&!n.element.matches(c),down:!1,dragging:!1,samples:[{t:t.timeStamp,x:t.clientX,y:t.clientY}]};o.set(t.pointerId,a),S(a,!0,y(t)),x()},{capture:!0,passive:!0});let E=e=>t=>{let n=t,r=o.get(n.pointerId);r&&(e||r.samples.push({t:n.timeStamp,x:n.clientX,y:n.clientY}),C(r,e,e?null:y(n),n.timeStamp))};a.listen(e,`pointerup`,E(!1),{capture:!0,passive:!0}),a.listen(e,`pointercancel`,E(!0),{capture:!0,passive:!0}),a.listen(e,`lostpointercapture`,e=>{let t=o.get(e.pointerId);t?.dragging&&e.target!==t.target.element||E(!0)(e)},{capture:!0,passive:!0}),a.listen(e,`contextmenu`,()=>{for(let e of[...o.values()])e.dragging||C(e,!0,null,0)},{capture:!0,passive:!0}),a.listen(e,`dragstart`,e=>{for(let t of o.values())t.draggable&&t.target.element.contains(e.target)&&e.preventDefault()},{capture:!0}),a.listen(e,`keydown`,e=>{let t=e;if(t.key===`Escape`){for(let e of[...o.values()])e.dragging&&C(e,!0,null,t.timeStamp);return}if(t.key!==` `||t.repeat||f)return;let n=g(t)[0],i=n?r.find(n):null;i?.interactive&&!v(i.element)&&i.element.matches(`button, [role=button], summary`)&&(f=i,r.press(i,!0,null))},{capture:!0,passive:!0});let D=e=>{let t=f;f=null,t&&(p=e?t.element:null,r.press(t,!1,null))};a.listen(e,`keyup`,e=>{e.key===` `&&D(!0)},{capture:!0,passive:!0}),a.listen(e,`click`,e=>{let t=e;if(t.detail!==0){let e=m;if(m=null,!e||t.timeStamp-e.time>500||!g(t).includes(e.element))return;t.preventDefault(),t.stopPropagation();return}let n=_(t);n&&(p===n.element?p=null:n.interactive&&!v(n.element)&&r.activate(n))},{capture:!0}),a.listen(e,`focusin`,e=>{let t=g(e)[0],n=t?r.find(t):null;n?.interactive&&n.element.matches(`:focus-visible`)&&(d=n,r.focus(n,!0))},{capture:!0,passive:!0}),a.listen(e,`focusout`,()=>{let e=d;d=null,e&&r.focus(e,!1),D(!1)},{capture:!0,passive:!0});let O={cancel(e){for(let t of[...o.values()])e&&t.target.element!==e||C(t,!0,null,0);if(f&&(!e||f.element===e)&&D(!1),u&&(!e||u.element===e)&&b(null,null),d&&(!e||d.element===e)){let e=d;d=null,r.focus(e,!1)}},dragging(e){for(let t of o.values())if(t.dragging&&t.target.element===e)return!0;return!1},dispose(){O.cancel(),a.dispose()}};return a.listen(i,`blur`,()=>{for(let e of[...o.values()])C(e,!0,null,0);D(!1)}),a.listen(e,`visibilitychange`,()=>{e.hidden&&O.cancel()}),O}const f={press:{delta:.002,speed:.02},glow:{delta:.004,speed:.04},x:{delta:.02,speed:.5},y:{delta:.02,speed:.5},scale:{delta:5e-4,speed:.005},morph:{delta:5e-4,speed:.005},merge:{delta:.02,speed:.5}},p=Object.freeze({press:0,glow:0,x:0,y:0,scale:1,morph:1,merge:0}),m=1/15;function h(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,a=null,s=!1,c={updates:0,lastUpdateMs:0,maxUpdateMs:0},l=(e,n,i)=>{let a=t.get(e);if(!a){if(!i)return;t.set(e,a=/* @__PURE__ */ new Map)}let o=a.get(n);if(!o&&i){let e=f[n];o={spring:r({value:p[n],restDelta:e.delta,restSpeed:e.speed}),resolve:null},a.set(n,o)}return o},u=(e,t)=>{let r=n.get(e)??/* @__PURE__ */ new Set;r.add(t),n.set(e,r)},d=(e,t)=>{let{resolve:n}=e;e.resolve=null,n?.(t)},h=e=>e.spring.settled,g=()=>{for(let e of t.values())for(let t of e.values())if(!t.spring.settled)return!0;return!1};return{value:(e,t)=>l(e,t,!1)?.spring.value,velocity:(e,t)=>l(e,t,!1)?.spring.velocity??0,target:(e,t)=>l(e,t,!1)?.spring.target,moving(e,n){let r=t.get(e);if(!r)return!1;if(n)return r.get(n)?.spring.settled===!1;for(let e of r.values())if(!e.spring.settled)return!0;return!1},to(t,n,r,a={}){if(s||!Number.isFinite(r))return Promise.resolve(!1);let c=l(t,n,!0);if(d(c,!1),a.from!==void 0&&Number.isFinite(a.from)&&(c.spring.set(a.from),u(t,n)),a.instant)return c.spring.set(r),u(t,n),e.request(),Promise.resolve(!0);let f=o(a.spring??{},i);return c.spring.to(r,{parameters:f,...a.velocity===void 0?{}:{velocity:a.velocity}}),c.spring.settled?(u(t,n),e.request(),Promise.resolve(!0)):(e.request(),new Promise(e=>{c.resolve=e}))},set(t,n,r){if(s||!Number.isFinite(r))return;let i=l(t,n,!0);d(i,!1),i.spring.set(r),u(t,n),e.request()},release(e,r){let i=t.get(e);if(i){for(let[t,a]of[...i])r&&t!==r||(i.delete(t),n.get(e)?.delete(t),d(a,!1));i.size||(t.delete(e),n.delete(e))}},finish(n){if(s)return;let r=!1;for(let[e,i]of t)if(!(n&&e!==n))for(let[t,n]of i)n.spring.settled||(n.spring.finish(),u(e,t),d(n,!0),r=!0);r&&e.request()},update(r){if(s)return;if(!g()&&!n.size){a=null;return}let i=performance.now();c.updates++;let o=a===null?.016666666666666666:(r-a)/1e3,l=Math.min(m,Math.max(0,Number.isFinite(o)?o:0));a=Number.isFinite(r)?r:a;let u=/* @__PURE__ */ new Map;for(let[e,t]of n)u.set(e,new Set(t));n.clear();let f=[];for(let[e,n]of t)for(let[t,r]of n){if(r.spring.settled||!r.spring.step(l))continue;let n=u.get(e)??/* @__PURE__ */ new Set;n.add(t),u.set(e,n),h(r)&&f.push(r)}let p=[];for(let[n,r]of u)if(r.size&&t.has(n))try{e.changed(n,r)}catch(e){p.push(e)}for(let e of f)d(e,!0);if(g()||(a=null),c.lastUpdateMs=performance.now()-i,c.maxUpdateMs=Math.max(c.maxUpdateMs,c.lastUpdateMs),p.length)throw p[0]},get active(){return!s&&(g()||n.size>0)},stats(){let e=0,n=0;for(let r of t.values()){let t=0;for(let e of r.values())e.spring.settled||t++;e+=t,t&&n++}return{targets:n,channels:e,...c}},dispose(){if(!s){s=!0;for(let e of t.values())for(let t of e.values())d(t,!1);t.clear(),n.clear(),a=null}}}}const g={hover:.65,focus:.5,press:1},_=Object.freeze({snappy:n(.3,.86),smooth:n(.45,1),bouncy:n(.5,.7)});function v(e,t){let n=t.transitionProperty.split(`,`).map(e=>e.trim()),r=e=>e.split(`,`).map(e=>Number.parseFloat(e)*(e.trim().endsWith(`ms`)?.001:1)||0),i=r(t.transitionDuration),a=r(t.transitionDelay);for(let[e,t]of n.entries())if((t===`all`||t===`translate`||t===`scale`)&&(i[e%i.length]??0)+(a[e%a.length]??0)>0)return`transition`;for(let t of e.getAnimations()){if(t.playState!==`running`||`transitionProperty`in t)continue;let e=t.effect;for(let t of typeof e?.getKeyframes==`function`?e.getKeyframes():[])if(`translate`in t||`scale`in t)return`animation`}return null}const y=/* @__PURE__ */ new WeakSet,b=e=>Math.round(e*1e3)/1e3;function x(e){if(!e||e===`none`)return[`0px`,`0px`];let t=e.match(/(?:[^\s(]|\([^)]*\))+/g)??[`0px`];return[t[0],t[1]??`0px`,...t.slice(2)]}const S=(e,t)=>e===`0px`?`${b(t)}px`:`calc(${e} + ${b(t)}px)`;function C(t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set,i=null,o=!1,s=h({changed(e,n){`motion`in e?C(e,n):t.remerge(e)},request:()=>{t.request()}}),c=e=>{let t=n.get(e);return t||(t={managed:!1,attribute:``,hover:!1,pressed:!1,focused:!1,pulse:null,dragging:!1,elastic:!1,dragX:0,dragY:0,conflict:null,saved:null},n.set(e,t)),t},l=(e,t)=>s.value(e,t)??p[t],f=(e,t)=>e===void 0?t.spring:typeof e==`string`?_[e]??t.spring:{...t.spring,...e};function C(e,n){let r=c(e);(n.has(`x`)||n.has(`y`)||n.has(`scale`))&&(r.elastic&&!r.dragging&&!s.moving(e,`x`)&&!s.moving(e,`y`)&&(r.elastic=!1),T(e,r),t.moved(e,r.conflict===`transition`)),(n.has(`press`)||n.has(`x`)||n.has(`y`))&&w(e,r),n.has(`glow`)&&(e.glow=e.motion.glow*Math.max(0,l(e,`glow`)),t.relight(e)),n.has(`morph`)&&t.remorph(e)}function w(e,n){let r=e.motion.press*l(e,`press`),i=0,a=0;if(n.elastic&&e.motion.dragLimit>0){let t=l(e,`x`)/e.motion.dragLimit,n=l(e,`y`)/e.motion.dragLimit;i=e.motion.stretch*Math.min(1,Math.abs(t)),a=e.motion.stretch*Math.min(1,Math.abs(n))}let o=Math.abs(r)<1e-5&&i<1e-5&&a<1e-5?null:{press:r,stretchX:i,stretchY:a,maxInset:4};(o!==null||e.deformation!==null)&&(e.deformation=o,t.reshape(e))}function T(e,n){let{element:r}=e,i=l(e,`x`),o=l(e,`y`),s=l(e,`scale`);if(i===0&&o===0&&s===1&&!n.dragging){k(e,n);return}if(n.saved)E(e,n.saved);else{let e=r.ownerDocument.defaultView?.getComputedStyle(r);n.saved={translate:r.style.translate,scale:r.style.scale,hadStyle:r.hasAttribute(`style`),baseTranslate:x(e?.translate??`none`),baseScale:a(e?.scale??`none`)??[1,1],wroteTranslate:r.style.translate,wroteScale:r.style.scale}}let{saved:c}=n,[u=`0px`,d=`0px`,...f]=c.baseTranslate;r.style.translate=[S(u,i),S(d,o),...f].join(` `);let[p,m]=c.baseScale;s===1?r.style.scale=c.scale:r.style.scale=p===m?`${b(p*s)}`:`${b(p*s)} ${b(m*s)}`,c.wroteTranslate=r.style.translate,c.wroteScale=r.style.scale,t.wrote(r)}function E(e,t){let{element:r}=e,i=r.style.translate!==t.wroteTranslate,o=r.style.scale!==t.wroteScale;if(!i&&!o)return;i&&(t.translate=r.style.translate),o&&(t.scale=r.style.scale),t.hadStyle=!0;let s=r.ownerDocument.defaultView?.getComputedStyle(r);if(!s)return;let c=n.get(e)?.conflict===`transition`;i&&(t.baseTranslate=x(c&&t.translate?t.translate:s.translate)),o&&(t.baseScale=a(c&&t.scale?t.scale:s.scale)??[1,1])}function D(e,t){let{style:n}=e.element;n.translate=t.translate,n.scale=t.scale;let r=e.element.ownerDocument.defaultView?.getComputedStyle(e.element);r&&(t.baseTranslate=x(r.translate),t.baseScale=a(r.scale)??[1,1],t.wroteTranslate=n.translate,t.wroteScale=n.scale)}function O(e,t){if(t.saved)return t.conflict;let{element:n}=e,r=n.ownerDocument.defaultView?.getComputedStyle(n);return t.conflict=r?v(n,r):null,t.conflict&&!y.has(n)&&(y.add(n),console.warn(`Abgin: this element has a CSS ${t.conflict} of "translate" or "scale". The motion engine moves elements with these properties, so it applies its target at once instead of animating it. Animate other properties, or wrap the element (see the motion documentation of @abgin/glass).`,n)),t.conflict}function k(e,n){let{saved:r}=n;if(!r)return;E(e,r),n.saved=null;let{style:i}=e.element;i.translate=r.translate,i.scale=r.scale,!r.hadStyle&&i.length===0&&e.element.removeAttribute(`style`),t.wrote(e.element)}function A(e,t){let n=Math.max(t.pressed?g.press:0,t.hover?g.hover:0,t.focused?g.focus:0),r=e.motion.reduced&&!e.motion.reducedLight?0:n;s.target(e,`glow`)!==r&&(s.value(e,`glow`)!==void 0||r!==0)&&s.to(e,`glow`,r,{spring:e.motion.spring,instant:e.motion.reduced})}function j(e,t){let n=c(e);n.pressed=t,e.motion.reduced||(t||s.value(e,`press`)!==void 0)&&s.to(e,`press`,+!!t,{spring:e.motion.spring}),A(e,n)}let M=e=>{let r=t.surface(e.element);return r&&n.get(r)?.managed?r:null},N={find(e){let r=t.surface(e),i=r&&n.get(r);if(!r||!i?.managed)return null;let a=t.drawn(r)&&t.control(r),o=r.motion.reduced?null:r.motion.drag;return a||o?{element:r.element,interactive:a,drag:o}:null},hover(e,n){let r=M(e);if(!r)return;let i=c(r);i.hover=n!==null,n&&!r.motion.reduced&&(r.pointer=n,r.glow>0&&t.relight(r)),A(r,i)},press(e,t,n){let r=M(e);r&&(n&&!r.motion.reduced?r.pointer=n:t&&(r.pointer=null),j(r,t))},focus(e,t){let n=M(e);if(!n)return;let r=c(n);r.focused=t,t&&!r.hover&&(n.pointer=null),A(n,r)},activate(e){let t=M(e);t&&P(t)},dragStart(e){let t=M(e);if(!t)return;let n=c(t);n.dragging=!0,n.elastic=!0,O(t,n),n.dragX=l(t,`x`),n.dragY=l(t,`y`),s.set(t,`x`,n.dragX),s.set(t,`y`,n.dragY),F(t,n)},dragMove(e,n,r){let i=M(e),a=i&&c(i);if(!i||!a?.dragging)return;let o=t.translationScale(i),{dragLimit:l,dragElasticity:d}=i.motion,f=(e,t)=>Math.min(l,Math.max(-l,e+u(t,l,d)));s.set(i,`x`,f(a.dragX,n/o.x)),s.set(i,`y`,f(a.dragY,r/o.y))},dragEnd(e,r,i,a){let o=t.surface(e.element),c=o&&n.get(o);if(!o||!c?.dragging)return;c.dragging=!1,F(o,c);let l=t.translationScale(o),u=e=>a?0:e*o.motion.dragElasticity,d=e=>({spring:o.motion.spring,velocity:u(e),instant:o.motion.reduced||c.conflict!==null});s.to(o,`x`,0,d(r/l.x)),s.to(o,`y`,0,d(i/l.y))}};function P(e){if(e.motion.reduced)return;let n=c(e);e.pointer=null,j(e,!0),n.pulse={remaining:90,last:null},t.request()}function F(n,r){let i=[];r.managed&&(t.drawn(n)&&t.control(n)&&i.push(`press`),n.motion.drag&&!n.motion.reduced&&i.push(n.motion.drag===`both`?`drag`:`drag-${n.motion.drag}`),r.dragging&&i.push(`dragging`));let a=i.join(` `);(a!==r.attribute||(n.element.getAttribute(`data-abgin-motion`)??``)!==a)&&(r.attribute=a,a?n.element.setAttribute(e,a):n.element.removeAttribute(e))}function I(e,n){n.managed=!1,i?.cancel(e.element),s.release(e),k(e,n),n.hover=n.pressed=n.focused=n.dragging=n.elastic=!1,n.pulse=null,F(e,n),e.pointer=null,e.glow=0,e.deformation&&(e.deformation=null,t.reshape(e))}return{get active(){if(o)return!1;if(s.active)return!0;for(let e of n.values())if(e.pulse!==null)return!0;return!1},update(e){if(!o){for(let[t,r]of n){let n=r.pulse;n&&(n.last!==null&&(n.remaining-=Math.min(m*1e3,Math.max(0,e-n.last))),n.last=e,n.remaining>0||(r.pulse=null,j(t,!1)))}s.update(e)}},sync(e){if(!o){for(let r of e){let e=n.get(r);if(!t.eligible(r)){e?.managed&&I(r,e);continue}let a=e??c(r);a.managed||(a.managed=!0,i??=d(t.document,t.scope,N)),r.motion.reduced&&(a.dragging&&i?.cancel(r.element),s.moving(r)&&s.finish(r),s.value(r,`press`)&&s.set(r,`press`,0)),F(r,a)}for(let e of r)s.moving(e)&&t.mergeConfig(e).motion.reduced&&s.finish(e)}},morph:e=>s.value(e,`morph`),merge:e=>s.value(e,`merge`),morphTo(e,t,n){s.to(e,`morph`,n,{...s.value(e,`morph`)===void 0?{from:t}:{},spring:e.motion.spring,instant:e.motion.reduced})},mergeTo(e,n,i){let{motion:a}=t.mergeConfig(e);r.add(e),s.to(e,`merge`,i,{...s.value(e,`merge`)===void 0?{from:n}:{},spring:a.spring,instant:a.reduced})},moving(e){return s.moving(e,`x`)||s.moving(e,`y`)||s.moving(e,`scale`)||n.get(e)?.dragging===!0},authored(e){let r=n.get(e);r?.saved&&(E(e,r.saved),r.conflict===null&&D(e,r.saved),T(e,r),t.moved(e,r.conflict===`transition`))},stopMorph(e){s.release(e,`morph`)},release(e){if(`motion`in e){let t=n.get(e);t&&I(e,t),n.delete(e)}else r.delete(e);s.release(e)},finish(){s.finish()},dispose(){if(!o){for(let[e,t]of n)I(e,t);o=!0,i?.dispose(),i=null,s.dispose(),n.clear(),r.clear()}},controller:{async animate(e,n,r={}){let i=o?null:t.surface(e);if(!i||!t.eligible(i))return!1;let a=c(i),l=e.ownerDocument.defaultView?.getComputedStyle(e).direction===`rtl`,u=[[`x`,n.inline===void 0?n.x:n.inline*(l?-1:1)],[`y`,n.y],[`scale`,n.scale===void 0?void 0:Math.min(8,Math.max(.05,n.scale))],[`morph`,n.morph===void 0?void 0:Math.min(1,Math.max(0,n.morph))]],d=[],p=u.some(([e,t])=>t!==void 0&&(e===`x`||e===`y`||e===`scale`))&&O(i,a)!==null;for(let[e,n]of u)if(n!==void 0&&Number.isFinite(n)){if(e===`x`||e===`y`){if(Math.abs(n)>1e4)continue;a.dragging||(a.elastic=!1)}d.push(s.to(i,e,n,{...e===`morph`&&s.value(i,`morph`)===void 0?{from:t.progress(i)}:{},spring:f(r.spring,i.motion),...r.velocity===void 0?{}:{velocity:r.velocity},instant:i.motion.reduced||r.instant===!0||p&&e!==`morph`}))}return d.length?(await Promise.all(d)).every(Boolean):!1},merge(e,n,i={}){let a=o?null:t.group(e);if(!a||!Number.isFinite(n))return Promise.resolve(!1);let{distance:c,motion:l}=t.mergeConfig(a);return r.add(a),s.to(a,`merge`,Math.min(128,Math.max(0,n)),{...s.value(a,`merge`)===void 0?{from:c}:{},spring:f(i.spring,l),...i.velocity===void 0?{}:{velocity:i.velocity},instant:l.reduced||i.instant===!0||!l.enabled})},press(e,r){let i=o?null:t.surface(e);i&&n.get(i)?.managed&&t.drawn(i)&&(i.pointer=null,j(i,r))},pulse(e){let r=o?null:t.surface(e);r&&n.get(r)?.managed&&t.drawn(r)&&P(r)},cancel(e){if(!o){for(let[t,r]of n)if(!(e&&t.element!==e)){i?.cancel(t.element),r.pulse=null,r.pressed=!1;for(let e of[`x`,`y`,`scale`,`press`])s.value(t,e)!==void 0&&s.set(t,e,p[e]);s.moving(t,`morph`)&&s.finish(t),A(t,r)}for(let t of r)e&&t.element!==e||s.finish(t)}},inspect(e){let r=t.surface(e),i=r&&n.get(r);return r?{enabled:r.motion.enabled,reduced:r.motion.reduced,managed:i?.managed??!1,moving:s.moving(r),pressed:i?.pressed??!1,hovered:i?.hover??!1,focused:i?.focused??!1,dragging:i?.dragging??!1,conflict:i?.conflict??null,press:l(r,`press`),glow:l(r,`glow`),x:l(r,`x`),y:l(r,`y`),scale:l(r,`scale`),morph:s.value(r,`morph`)??null,velocity:{x:s.velocity(r,`x`),y:s.velocity(r,`y`),scale:s.velocity(r,`scale`)}}:null},stats(){let e=0,t=0;for(let r of n.values())r.managed&&e++,r.pressed&&t++;return{managed:e,pressed:t,listening:i!==null,...s.stats()}}}}}export{C as createMotionScene};
|
|
3
|
-
//# sourceMappingURL=motion-scene-
|
|
1
|
+
/*! @abgin/abgin 0.1.2 | MIT License */
|
|
2
|
+
import{a as e,c as t}from"./glass-9XMne6tP.js";import{a as n,i as r,n as i,o as a,r as o}from"./engine-DOFQfCtE.js";const s={mouse:4,pen:6,touch:10},c=`input, textarea, select, option, [contenteditable=""], [contenteditable="true"], video, audio`;function l(e,t){let n=e.filter(e=>t-e.t<=100),r=n[0],i=n[n.length-1];if(!r||!i||t-i.t>60)return[0,0];let a=(i.t-r.t)/1e3;if(!(a>0))return[0,0];let o=e=>Math.min(4e3,Math.max(-4e3,e));return[o((i.x-r.x)/a),o((i.y-r.y)/a)]}function u(e,t,n){if(!(t>0)||!(n>0)||!Number.isFinite(e))return 0;let r=Math.abs(e)*n;return Math.sign(e)*t*(1-1/(r/t+1))}function d(e,n,r){let i=e.defaultView,a=n.child(),o=/* @__PURE__ */ new Map,u=null,d=null,f=null,p=null,m=null,h=null,g=e=>e.composedPath().filter(t),_=e=>{for(let t of g(e)){let e=r.find(t);if(e)return e}return null},v=e=>e.matches(`:disabled, [aria-disabled="true"]`),y=e=>({x:e.clientX,y:e.clientY});function b(e,t){if(u&&u.element!==e?.element){let e=u;u=null,r.hover(e,null)}u=e,e&&r.hover(e,t),x()}function x(){let t=u!==null||o.size>0;t&&!h?h=a.listen(e,`pointermove`,T,{capture:!0,passive:!0}):!t&&h&&(h(),h=null)}function S(e,t,n){e.down!==t&&(e.down=t,e.target.interactive&&r.press(e.target,t,n))}function C(e,t,n,i){if(o.delete(e.id),e.dragging){e.dragging=!1,m=t?null:{element:e.target.element,time:i};let[n,a]=t?[0,0]:l(e.samples,i),o=e.target.drag;r.dragEnd(e.target,o===`y`?0:n,o===`x`?0:a,t);try{e.target.element.releasePointerCapture(e.id)}catch{}}S(e,!1,n),x()}function w(t){t.dragging=!0,S(t,!1,null);try{t.target.element.setPointerCapture(t.id)}catch{}let n=e.getSelection();n?.anchorNode&&t.target.element.contains(n.anchorNode)&&n.removeAllRanges(),r.dragStart(t.target)}function T(e){let t=e,n=o.get(t.pointerId);if(n){let e=t.clientX-n.x,i=t.clientY-n.y;n.samples.push({t:t.timeStamp,x:t.clientX,y:t.clientY}),n.samples.length>32&&n.samples.shift();let a=n.target.drag;if(n.draggable&&a&&!n.dragging&&(a===`x`?Math.abs(e):a===`y`?Math.abs(i):Math.hypot(e,i))>=s[n.type]&&w(n),n.dragging)r.dragMove(n.target,a===`y`?0:e,a===`x`?0:i);else{let e=n.target.element.getBoundingClientRect();S(n,t.clientX>=e.left-12&&t.clientX<=e.right+12&&t.clientY>=e.top-12&&t.clientY<=e.bottom+12,y(t))}}u&&t.pointerType!==`touch`&&r.hover(u,y(t))}a.listen(e,`pointerover`,e=>{let t=e;if(t.pointerType===`touch`)return;let n=_(t);b(n?.interactive&&!v(n.element)?n:null,y(t))},{capture:!0,passive:!0}),a.listen(e,`pointerout`,e=>{e.relatedTarget===null&&u&&b(null,null)},{capture:!0,passive:!0}),a.listen(e,`pointerdown`,e=>{let t=e;if(m=null,t.button!==0||!t.isPrimary)return;let n=_(t);if(!n||v(n.element))return;let r=o.get(t.pointerId);r&&C(r,!0,null,t.timeStamp);let i=!1;for(let e of g(t)){if(e===n.element)break;e.matches(`${c}, a[href], button`)&&(i=!0)}let a={id:t.pointerId,target:n,x:t.clientX,y:t.clientY,type:t.pointerType===`touch`||t.pointerType===`pen`?t.pointerType:`mouse`,draggable:n.drag!==null&&!i&&!n.element.matches(c),down:!1,dragging:!1,samples:[{t:t.timeStamp,x:t.clientX,y:t.clientY}]};o.set(t.pointerId,a),S(a,!0,y(t)),x()},{capture:!0,passive:!0});let E=e=>t=>{let n=t,r=o.get(n.pointerId);r&&(e||r.samples.push({t:n.timeStamp,x:n.clientX,y:n.clientY}),C(r,e,e?null:y(n),n.timeStamp))};a.listen(e,`pointerup`,E(!1),{capture:!0,passive:!0}),a.listen(e,`pointercancel`,E(!0),{capture:!0,passive:!0}),a.listen(e,`lostpointercapture`,e=>{let t=o.get(e.pointerId);t?.dragging&&e.target!==t.target.element||E(!0)(e)},{capture:!0,passive:!0}),a.listen(e,`contextmenu`,()=>{for(let e of[...o.values()])e.dragging||C(e,!0,null,0)},{capture:!0,passive:!0}),a.listen(e,`dragstart`,e=>{for(let t of o.values())t.draggable&&t.target.element.contains(e.target)&&e.preventDefault()},{capture:!0}),a.listen(e,`keydown`,e=>{let t=e;if(t.key===`Escape`){for(let e of[...o.values()])e.dragging&&C(e,!0,null,t.timeStamp);return}if(t.key!==` `||t.repeat||f)return;let n=g(t)[0],i=n?r.find(n):null;i?.interactive&&!v(i.element)&&i.element.matches(`button, [role=button], summary`)&&(f=i,r.press(i,!0,null))},{capture:!0,passive:!0});let D=e=>{let t=f;f=null,t&&(p=e?t.element:null,r.press(t,!1,null))};a.listen(e,`keyup`,e=>{e.key===` `&&D(!0)},{capture:!0,passive:!0}),a.listen(e,`click`,e=>{let t=e;if(t.detail!==0){let e=m;if(m=null,!e||t.timeStamp-e.time>500||!g(t).includes(e.element))return;t.preventDefault(),t.stopPropagation();return}let n=_(t);n&&(p===n.element?p=null:n.interactive&&!v(n.element)&&r.activate(n))},{capture:!0}),a.listen(e,`focusin`,e=>{let t=g(e)[0],n=t?r.find(t):null;n?.interactive&&n.element.matches(`:focus-visible`)&&(d=n,r.focus(n,!0))},{capture:!0,passive:!0}),a.listen(e,`focusout`,()=>{let e=d;d=null,e&&r.focus(e,!1),D(!1)},{capture:!0,passive:!0});let O={cancel(e){for(let t of[...o.values()])e&&t.target.element!==e||C(t,!0,null,0);if(f&&(!e||f.element===e)&&D(!1),u&&(!e||u.element===e)&&b(null,null),d&&(!e||d.element===e)){let e=d;d=null,r.focus(e,!1)}},dragging(e){for(let t of o.values())if(t.dragging&&t.target.element===e)return!0;return!1},dispose(){O.cancel(),a.dispose()}};return a.listen(i,`blur`,()=>{for(let e of[...o.values()])C(e,!0,null,0);D(!1)}),a.listen(e,`visibilitychange`,()=>{e.hidden&&O.cancel()}),O}const f={press:{delta:.002,speed:.02},glow:{delta:.004,speed:.04},x:{delta:.02,speed:.5},y:{delta:.02,speed:.5},scale:{delta:5e-4,speed:.005},morph:{delta:5e-4,speed:.005},merge:{delta:.02,speed:.5}},p=Object.freeze({press:0,glow:0,x:0,y:0,scale:1,morph:1,merge:0}),m=1/15;function h(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,a=null,s=!1,c={updates:0,lastUpdateMs:0,maxUpdateMs:0},l=(e,n,i)=>{let a=t.get(e);if(!a){if(!i)return;t.set(e,a=/* @__PURE__ */ new Map)}let o=a.get(n);if(!o&&i){let e=f[n];o={spring:r({value:p[n],restDelta:e.delta,restSpeed:e.speed}),resolve:null},a.set(n,o)}return o},u=(e,t)=>{let r=n.get(e)??/* @__PURE__ */ new Set;r.add(t),n.set(e,r)},d=(e,t)=>{let{resolve:n}=e;e.resolve=null,n?.(t)},h=e=>e.spring.settled,g=()=>{for(let e of t.values())for(let t of e.values())if(!t.spring.settled)return!0;return!1};return{value:(e,t)=>l(e,t,!1)?.spring.value,velocity:(e,t)=>l(e,t,!1)?.spring.velocity??0,target:(e,t)=>l(e,t,!1)?.spring.target,moving(e,n){let r=t.get(e);if(!r)return!1;if(n)return r.get(n)?.spring.settled===!1;for(let e of r.values())if(!e.spring.settled)return!0;return!1},to(t,n,r,a={}){if(s||!Number.isFinite(r))return Promise.resolve(!1);let c=l(t,n,!0);if(d(c,!1),a.from!==void 0&&Number.isFinite(a.from)&&(c.spring.set(a.from),u(t,n)),a.instant)return c.spring.set(r),u(t,n),e.request(),Promise.resolve(!0);let f=o(a.spring??{},i);return c.spring.to(r,{parameters:f,...a.velocity===void 0?{}:{velocity:a.velocity}}),c.spring.settled?(u(t,n),e.request(),Promise.resolve(!0)):(e.request(),new Promise(e=>{c.resolve=e}))},set(t,n,r){if(s||!Number.isFinite(r))return;let i=l(t,n,!0);d(i,!1),i.spring.set(r),u(t,n),e.request()},release(e,r){let i=t.get(e);if(i){for(let[t,a]of[...i])r&&t!==r||(i.delete(t),n.get(e)?.delete(t),d(a,!1));i.size||(t.delete(e),n.delete(e))}},finish(n){if(s)return;let r=!1;for(let[e,i]of t)if(!(n&&e!==n))for(let[t,n]of i)n.spring.settled||(n.spring.finish(),u(e,t),d(n,!0),r=!0);r&&e.request()},update(r){if(s)return;if(!g()&&!n.size){a=null;return}let i=performance.now();c.updates++;let o=a===null?.016666666666666666:(r-a)/1e3,l=Math.min(m,Math.max(0,Number.isFinite(o)?o:0));a=Number.isFinite(r)?r:a;let u=/* @__PURE__ */ new Map;for(let[e,t]of n)u.set(e,new Set(t));n.clear();let f=[];for(let[e,n]of t)for(let[t,r]of n){if(r.spring.settled||!r.spring.step(l))continue;let n=u.get(e)??/* @__PURE__ */ new Set;n.add(t),u.set(e,n),h(r)&&f.push(r)}let p=[];for(let[n,r]of u)if(r.size&&t.has(n))try{e.changed(n,r)}catch(e){p.push(e)}for(let e of f)d(e,!0);if(g()||(a=null),c.lastUpdateMs=performance.now()-i,c.maxUpdateMs=Math.max(c.maxUpdateMs,c.lastUpdateMs),p.length)throw p[0]},get active(){return!s&&(g()||n.size>0)},stats(){let e=0,n=0;for(let r of t.values()){let t=0;for(let e of r.values())e.spring.settled||t++;e+=t,t&&n++}return{targets:n,channels:e,...c}},dispose(){if(!s){s=!0;for(let e of t.values())for(let t of e.values())d(t,!1);t.clear(),n.clear(),a=null}}}}const g={hover:.65,focus:.5,press:1},_=Object.freeze({snappy:n(.3,.86),smooth:n(.45,1),bouncy:n(.5,.7)});function v(e,t){let n=t.transitionProperty.split(`,`).map(e=>e.trim()),r=e=>e.split(`,`).map(e=>Number.parseFloat(e)*(e.trim().endsWith(`ms`)?.001:1)||0),i=r(t.transitionDuration),a=r(t.transitionDelay);for(let[e,t]of n.entries())if((t===`all`||t===`translate`||t===`scale`)&&(i[e%i.length]??0)+(a[e%a.length]??0)>0)return`transition`;for(let t of e.getAnimations()){if(t.playState!==`running`||`transitionProperty`in t)continue;let e=t.effect;for(let t of typeof e?.getKeyframes==`function`?e.getKeyframes():[])if(`translate`in t||`scale`in t)return`animation`}return null}const y=/* @__PURE__ */ new WeakSet,b=e=>Math.round(e*1e3)/1e3;function x(e){if(!e||e===`none`)return[`0px`,`0px`];let t=e.match(/(?:[^\s(]|\([^)]*\))+/g)??[`0px`];return[t[0],t[1]??`0px`,...t.slice(2)]}const S=(e,t)=>e===`0px`?`${b(t)}px`:`calc(${e} + ${b(t)}px)`;function C(t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set,i=null,o=!1,s=h({changed(e,n){`motion`in e?C(e,n):t.remerge(e)},request:()=>{t.request()}}),c=e=>{let t=n.get(e);return t||(t={managed:!1,attribute:``,hover:!1,pressed:!1,focused:!1,pulse:null,dragging:!1,elastic:!1,dragX:0,dragY:0,conflict:null,saved:null},n.set(e,t)),t},l=(e,t)=>s.value(e,t)??p[t],f=(e,t)=>e===void 0?t.spring:typeof e==`string`?_[e]??t.spring:{...t.spring,...e};function C(e,n){let r=c(e);(n.has(`x`)||n.has(`y`)||n.has(`scale`))&&(r.elastic&&!r.dragging&&!s.moving(e,`x`)&&!s.moving(e,`y`)&&(r.elastic=!1),T(e,r),t.moved(e,r.conflict===`transition`)),(n.has(`press`)||n.has(`x`)||n.has(`y`))&&w(e,r),n.has(`glow`)&&(e.glow=e.motion.glow*Math.max(0,l(e,`glow`)),t.relight(e)),n.has(`morph`)&&t.remorph(e)}function w(e,n){let r=e.motion.press*l(e,`press`),i=0,a=0;if(n.elastic&&e.motion.dragLimit>0){let t=l(e,`x`)/e.motion.dragLimit,n=l(e,`y`)/e.motion.dragLimit;i=e.motion.stretch*Math.min(1,Math.abs(t)),a=e.motion.stretch*Math.min(1,Math.abs(n))}let o=Math.abs(r)<1e-5&&i<1e-5&&a<1e-5?null:{press:r,stretchX:i,stretchY:a,maxInset:4};(o!==null||e.deformation!==null)&&(e.deformation=o,t.reshape(e))}function T(e,n){let{element:r}=e,i=l(e,`x`),o=l(e,`y`),s=l(e,`scale`);if(i===0&&o===0&&s===1&&!n.dragging){k(e,n);return}if(n.saved)E(e,n.saved);else{let e=r.ownerDocument.defaultView?.getComputedStyle(r);n.saved={translate:r.style.translate,scale:r.style.scale,hadStyle:r.hasAttribute(`style`),baseTranslate:x(e?.translate??`none`),baseScale:a(e?.scale??`none`)??[1,1],wroteTranslate:r.style.translate,wroteScale:r.style.scale}}let{saved:c}=n,[u=`0px`,d=`0px`,...f]=c.baseTranslate;r.style.translate=[S(u,i),S(d,o),...f].join(` `);let[p,m]=c.baseScale;s===1?r.style.scale=c.scale:r.style.scale=p===m?`${b(p*s)}`:`${b(p*s)} ${b(m*s)}`,c.wroteTranslate=r.style.translate,c.wroteScale=r.style.scale,t.wrote(r)}function E(e,t){let{element:r}=e,i=r.style.translate!==t.wroteTranslate,o=r.style.scale!==t.wroteScale;if(!i&&!o)return;i&&(t.translate=r.style.translate),o&&(t.scale=r.style.scale),t.hadStyle=!0;let s=r.ownerDocument.defaultView?.getComputedStyle(r);if(!s)return;let c=n.get(e)?.conflict===`transition`;i&&(t.baseTranslate=x(c&&t.translate?t.translate:s.translate)),o&&(t.baseScale=a(c&&t.scale?t.scale:s.scale)??[1,1])}function D(e,t){let{style:n}=e.element;n.translate=t.translate,n.scale=t.scale;let r=e.element.ownerDocument.defaultView?.getComputedStyle(e.element);r&&(t.baseTranslate=x(r.translate),t.baseScale=a(r.scale)??[1,1],t.wroteTranslate=n.translate,t.wroteScale=n.scale)}function O(e,t){if(t.saved)return t.conflict;let{element:n}=e,r=n.ownerDocument.defaultView?.getComputedStyle(n);return t.conflict=r?v(n,r):null,t.conflict&&!y.has(n)&&(y.add(n),console.warn(`Abgin: this element has a CSS ${t.conflict} of "translate" or "scale". The motion engine moves elements with these properties, so it applies its target at once instead of animating it. Animate other properties, or wrap the element (see the motion documentation of @abgin/glass).`,n)),t.conflict}function k(e,n){let{saved:r}=n;if(!r)return;E(e,r),n.saved=null;let{style:i}=e.element;i.translate=r.translate,i.scale=r.scale,!r.hadStyle&&i.length===0&&e.element.removeAttribute(`style`),t.wrote(e.element)}function A(e,t){let n=Math.max(t.pressed?g.press:0,t.hover?g.hover:0,t.focused?g.focus:0),r=e.motion.reduced&&!e.motion.reducedLight?0:n;s.target(e,`glow`)!==r&&(s.value(e,`glow`)!==void 0||r!==0)&&s.to(e,`glow`,r,{spring:e.motion.spring,instant:e.motion.reduced})}function j(e,t){let n=c(e);n.pressed=t,e.motion.reduced||(t||s.value(e,`press`)!==void 0)&&s.to(e,`press`,+!!t,{spring:e.motion.spring}),A(e,n)}let M=e=>{let r=t.surface(e.element);return r&&n.get(r)?.managed?r:null},N={find(e){let r=t.surface(e),i=r&&n.get(r);if(!r||!i?.managed)return null;let a=t.drawn(r)&&t.control(r),o=r.motion.reduced?null:r.motion.drag;return a||o?{element:r.element,interactive:a,drag:o}:null},hover(e,n){let r=M(e);if(!r)return;let i=c(r);i.hover=n!==null,n&&!r.motion.reduced&&(r.pointer=n,r.glow>0&&t.relight(r)),A(r,i)},press(e,t,n){let r=M(e);r&&(n&&!r.motion.reduced?r.pointer=n:t&&(r.pointer=null),j(r,t))},focus(e,t){let n=M(e);if(!n)return;let r=c(n);r.focused=t,t&&!r.hover&&(n.pointer=null),A(n,r)},activate(e){let t=M(e);t&&P(t)},dragStart(e){let t=M(e);if(!t)return;let n=c(t);n.dragging=!0,n.elastic=!0,O(t,n),n.dragX=l(t,`x`),n.dragY=l(t,`y`),s.set(t,`x`,n.dragX),s.set(t,`y`,n.dragY),F(t,n)},dragMove(e,n,r){let i=M(e),a=i&&c(i);if(!i||!a?.dragging)return;let o=t.translationScale(i),{dragLimit:l,dragElasticity:d}=i.motion,f=(e,t)=>Math.min(l,Math.max(-l,e+u(t,l,d)));s.set(i,`x`,f(a.dragX,n/o.x)),s.set(i,`y`,f(a.dragY,r/o.y))},dragEnd(e,r,i,a){let o=t.surface(e.element),c=o&&n.get(o);if(!o||!c?.dragging)return;c.dragging=!1,F(o,c);let l=t.translationScale(o),u=e=>a?0:e*o.motion.dragElasticity,d=e=>({spring:o.motion.spring,velocity:u(e),instant:o.motion.reduced||c.conflict!==null});s.to(o,`x`,0,d(r/l.x)),s.to(o,`y`,0,d(i/l.y))}};function P(e){if(e.motion.reduced)return;let n=c(e);e.pointer=null,j(e,!0),n.pulse={remaining:90,last:null},t.request()}function F(n,r){let i=[];r.managed&&(t.drawn(n)&&t.control(n)&&i.push(`press`),n.motion.drag&&!n.motion.reduced&&i.push(n.motion.drag===`both`?`drag`:`drag-${n.motion.drag}`),r.dragging&&i.push(`dragging`));let a=i.join(` `);(a!==r.attribute||(n.element.getAttribute(`data-abgin-motion`)??``)!==a)&&(r.attribute=a,a?n.element.setAttribute(e,a):n.element.removeAttribute(e))}function I(e,n){n.managed=!1,i?.cancel(e.element),s.release(e),k(e,n),n.hover=n.pressed=n.focused=n.dragging=n.elastic=!1,n.pulse=null,F(e,n),e.pointer=null,e.glow=0,e.deformation&&(e.deformation=null,t.reshape(e))}return{get active(){if(o)return!1;if(s.active)return!0;for(let e of n.values())if(e.pulse!==null)return!0;return!1},update(e){if(!o){for(let[t,r]of n){let n=r.pulse;n&&(n.last!==null&&(n.remaining-=Math.min(m*1e3,Math.max(0,e-n.last))),n.last=e,n.remaining>0||(r.pulse=null,j(t,!1)))}s.update(e)}},sync(e){if(!o){for(let r of e){let e=n.get(r);if(!t.eligible(r)){e?.managed&&I(r,e);continue}let a=e??c(r);a.managed||(a.managed=!0,i??=d(t.document,t.scope,N)),r.motion.reduced&&(a.dragging&&i?.cancel(r.element),s.moving(r)&&s.finish(r),s.value(r,`press`)&&s.set(r,`press`,0)),F(r,a)}for(let e of r)s.moving(e)&&t.mergeConfig(e).motion.reduced&&s.finish(e)}},morph:e=>s.value(e,`morph`),merge:e=>s.value(e,`merge`),morphTo(e,t,n){s.to(e,`morph`,n,{...s.value(e,`morph`)===void 0?{from:t}:{},spring:e.motion.spring,instant:e.motion.reduced})},mergeTo(e,n,i){let{motion:a}=t.mergeConfig(e);r.add(e),s.to(e,`merge`,i,{...s.value(e,`merge`)===void 0?{from:n}:{},spring:a.spring,instant:a.reduced})},moving(e){return s.moving(e,`x`)||s.moving(e,`y`)||s.moving(e,`scale`)||n.get(e)?.dragging===!0},authored(e){let r=n.get(e);r?.saved&&(E(e,r.saved),r.conflict===null&&D(e,r.saved),T(e,r),t.moved(e,r.conflict===`transition`))},stopMorph(e){s.release(e,`morph`)},release(e){if(`motion`in e){let t=n.get(e);t&&I(e,t),n.delete(e)}else r.delete(e);s.release(e)},finish(){s.finish()},dispose(){if(!o){for(let[e,t]of n)I(e,t);o=!0,i?.dispose(),i=null,s.dispose(),n.clear(),r.clear()}},controller:{async animate(e,n,r={}){let i=o?null:t.surface(e);if(!i||!t.eligible(i))return!1;let a=c(i),l=e.ownerDocument.defaultView?.getComputedStyle(e).direction===`rtl`,u=[[`x`,n.inline===void 0?n.x:n.inline*(l?-1:1)],[`y`,n.y],[`scale`,n.scale===void 0?void 0:Math.min(8,Math.max(.05,n.scale))],[`morph`,n.morph===void 0?void 0:Math.min(1,Math.max(0,n.morph))]],d=[],p=u.some(([e,t])=>t!==void 0&&(e===`x`||e===`y`||e===`scale`))&&O(i,a)!==null;for(let[e,n]of u)if(n!==void 0&&Number.isFinite(n)){if(e===`x`||e===`y`){if(Math.abs(n)>1e4)continue;a.dragging||(a.elastic=!1)}d.push(s.to(i,e,n,{...e===`morph`&&s.value(i,`morph`)===void 0?{from:t.progress(i)}:{},spring:f(r.spring,i.motion),...r.velocity===void 0?{}:{velocity:r.velocity},instant:i.motion.reduced||r.instant===!0||p&&e!==`morph`}))}return d.length?(await Promise.all(d)).every(Boolean):!1},merge(e,n,i={}){let a=o?null:t.group(e);if(!a||!Number.isFinite(n))return Promise.resolve(!1);let{distance:c,motion:l}=t.mergeConfig(a);return r.add(a),s.to(a,`merge`,Math.min(128,Math.max(0,n)),{...s.value(a,`merge`)===void 0?{from:c}:{},spring:f(i.spring,l),...i.velocity===void 0?{}:{velocity:i.velocity},instant:l.reduced||i.instant===!0||!l.enabled})},press(e,r){let i=o?null:t.surface(e);i&&n.get(i)?.managed&&t.drawn(i)&&(i.pointer=null,j(i,r))},pulse(e){let r=o?null:t.surface(e);r&&n.get(r)?.managed&&t.drawn(r)&&P(r)},cancel(e){if(!o){for(let[t,r]of n)if(!(e&&t.element!==e)){i?.cancel(t.element),r.pulse=null,r.pressed=!1;for(let e of[`x`,`y`,`scale`,`press`])s.value(t,e)!==void 0&&s.set(t,e,p[e]);s.moving(t,`morph`)&&s.finish(t),A(t,r)}for(let t of r)e&&t.element!==e||s.finish(t)}},inspect(e){let r=t.surface(e),i=r&&n.get(r);return r?{enabled:r.motion.enabled,reduced:r.motion.reduced,managed:i?.managed??!1,moving:s.moving(r),pressed:i?.pressed??!1,hovered:i?.hover??!1,focused:i?.focused??!1,dragging:i?.dragging??!1,conflict:i?.conflict??null,press:l(r,`press`),glow:l(r,`glow`),x:l(r,`x`),y:l(r,`y`),scale:l(r,`scale`),morph:s.value(r,`morph`)??null,velocity:{x:s.velocity(r,`x`),y:s.velocity(r,`y`),scale:s.velocity(r,`scale`)}}:null},stats(){let e=0,t=0;for(let r of n.values())r.managed&&e++,r.pressed&&t++;return{managed:e,pressed:t,listening:i!==null,...s.stats()}}}}}export{C as createMotionScene};
|
|
3
|
+
//# sourceMappingURL=motion-scene-BNPBmw5W.js.map
|