Socket
Socket
Sign inDemoInstall

@finsweet/attributes-a11y

Package Overview
Dependencies
3
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

10

a11y.js

@@ -1,1 +0,9 @@

"use strict";(()=>{var X=Object.create;var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var J=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Z=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of W(t))!Q.call(e,r)&&r!==o&&v(e,r,{get:()=>t[r],enumerable:!(s=G(t,r))||s.enumerable});return e};var tt=(e,t,o)=>(o=e!=null?X(z(e)):{},Z(t||!e||!e.__esModule?v(o,"default",{value:e,enumerable:!0}):o,e));var M=J((Ft,D)=>{D.exports=ct;function ct(e,t,o,s){var r,i,n;return function(){if(n=this,i=Array.prototype.slice.call(arguments),r&&(o||s))return;if(!o)return u(),r=setTimeout(a,t),r;r=setTimeout(u,t),e.apply(n,i);function a(){u(),e.apply(n,i)}function u(){clearTimeout(r),r=null}}}});var m="fs-attributes";var p="a11y",g="accordion";var U="cmsattribute";var w="inputcounter";var B="modal";var I="support";var C=async(...e)=>{var o;let t=[];for(let s of e){let r=await((o=window.fsAttributes[s])==null?void 0:o.loading);t.push(r)}return t};var T=()=>{};function R(e,t,o,s){return e?(e.addEventListener(t,o,s),()=>e.removeEventListener(t,o,s)):T}var y=(e,t)=>(Array.isArray(t)||(t=[t]),t.map(s=>e.dispatchEvent(new Event(s,{bubbles:!0}))).every(s=>s));var b=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length);function N(e,t,o){var r;let s=window.fsAttributes[e];return s.destroy=o||T,(r=s.resolve)==null||r.call(s,t),t}var K=(e,t="1",o="iife")=>{let r=`${e}${o==="esm"?".esm":""}.js`;return`https://cdn.jsdelivr.net/npm/@finsweet/attributes-${e}@${t}/${r}`};var et=`${m}-${I}`,h=async()=>{var r;let{fsAttributes:e,location:t}=window,{host:o,searchParams:s}=new URL(t.href);return!o.includes("webflow.io")||!s.has(et)?!1:(r=e.import)==null?void 0:r.call(e,I,"1")};var d=e=>{let t=(r,i,n)=>{let c=e[r],{key:a,values:u}=c,l;if(!i)return`[${a}]`;let x=u==null?void 0:u[i];typeof x=="string"?l=x:l=x(n&&"instanceIndex"in n?n.instanceIndex:void 0);let E=n&&"caseInsensitive"in n&&n.caseInsensitive?"i":"";if(!(n!=null&&n.operator))return`[${a}="${l}"${E}]`;switch(n.operator){case"prefixed":return`[${a}^="${l}"${E}]`;case"suffixed":return`[${a}$="${l}"${E}]`;case"contains":return`[${a}*="${l}"${E}]`}};function o(r,i){let n=t("element",r,i),c=(i==null?void 0:i.scope)||document;return i!=null&&i.all?[...c.querySelectorAll(n)]:c.querySelector(n)}return[t,o,(r,i)=>{let n=e[i];return n?r.getAttribute(n.key):null}]};var A={preventLoad:{key:`${m}-preventload`},debugMode:{key:`${m}-debug`},src:{key:"src",values:{finsweet:"@finsweet/attributes"}},dev:{key:`${m}-dev`}},[_,Ot]=d(A);var O=e=>{let{currentScript:t}=document,o={};if(!t)return{attributes:o,preventsLoad:!1};let r={preventsLoad:typeof t.getAttribute(A.preventLoad.key)=="string",attributes:o};for(let i in e){let n=t.getAttribute(e[i]);r.attributes[i]=n}return r};var P=({scriptAttributes:e,attributeKey:t,version:o,init:s})=>{var c;rt(),(c=window.fsAttributes)[t]||(c[t]={});let{preventsLoad:r,attributes:i}=O(e),n=window.fsAttributes[t];n.version=o,n.init=s,r||(window.Webflow||(window.Webflow=[]),window.Webflow.push(()=>s(i)))},rt=()=>{let e=st();if(window.fsAttributes&&!Array.isArray(window.fsAttributes)){S(window.fsAttributes,e);return}let t=ot(e);S(t,e),nt(t),window.fsAttributes=t,window.FsAttributes=window.fsAttributes,h()},ot=e=>{let t={cms:{},push(...o){var s,r;for(let[i,n]of o)(r=(s=this[i])==null?void 0:s.loading)==null||r.then(n)},async import(o,s){let r=t[o];return r||new Promise(i=>{let n=document.createElement("script");n.src=K(o,s),n.async=!0,n.onload=()=>{let[c]=S(t,[o]);i(c)},document.head.append(n)})},destroy(){var o,s;for(let r of e)(s=(o=window.fsAttributes[r])==null?void 0:o.destroy)==null||s.call(o)}};return t},st=()=>{let e=_("src","finsweet",{operator:"contains"}),t=_("dev");return[...document.querySelectorAll(`script${e}, script${t}`)].reduce((r,i)=>{var c;let n=i.getAttribute(A.dev.key)||((c=i.src.match(/[\w-. ]+(?=(\.js)$)/))==null?void 0:c[0]);return n&&!r.includes(n)&&r.push(n),r},[])},S=(e,t)=>t.map(s=>{let r=e[s];return r||(e[s]={},r=e[s],r.loading=new Promise(i=>{r.resolve=n=>{i(n),delete r.resolve}}),r)}),nt=e=>{let t=Array.isArray(window.fsAttributes)?window.fsAttributes:[];e.push(...t)};var L="1.0.0";var F=tt(M(),1);var k="tabindex";var $="aria-expanded";var f="aria-controls";var at=`fs-${p}`,ut="autofocus",lt={element:{key:`${at}-element`,values:{autoFocus:ut}}},[Xt,V]=d(lt);var H=()=>{let t=[...document.querySelectorAll(`[${f}]`)].map(mt);return()=>{for(let o of t)o==null||o.disconnect()}},mt=e=>{let t=e.getAttribute(f);if(!t)return;let o=document.getElementById(t);if(!o){e.removeAttribute(f);return}let s=V("autoFocus",{operator:"prefixed",scope:o}),r=b(o);Y(e,r);let n=(0,F.default)(()=>{let a=b(o);Y(e,a),s&&!r&&a&&s.focus(),r=a},100),c=new MutationObserver(n);return c.observe(o,{attributes:!0,attributeFilter:["style","class"]}),c},Y=(e,t)=>{e.setAttribute($,String(t))};var pt=[HTMLAnchorElement,HTMLButtonElement,HTMLInputElement,HTMLTextAreaElement,HTMLSelectElement,HTMLVideoElement,HTMLAudioElement],j=()=>{let t=R(window,"keydown",o=>{var i;let{target:s,key:r}=o;r!=="Enter"&&r!==" "||!s||!((i=s.getAttribute)!=null&&i.call(s,k))||pt.some(n=>s instanceof n)||(o.preventDefault(),y(s,"click"))});return()=>{t()}};var q=async()=>{await C(U,B,w,g);let e=j(),t=H();return N(p,void 0,()=>{e(),t()})};P({init:q,version:L,attributeKey:p});})();
"use strict";(()=>{var $e=Object.create;var te=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var qe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Ge=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ve(e))!je.call(r,n)&&n!==t&&te(r,n,{get:()=>e[n],enumerable:!(o=He(e,n))||o.enumerable});return r};var Xe=(r,e,t)=>(t=r!=null?$e(Ye(r)):{},Ge(e||!r||!r.__esModule?te(t,"default",{value:r,enumerable:!0}):t,r));var Ce=qe((ur,_e)=>{_e.exports=Et;function Et(r,e,t,o){var n,a,i;return function(){if(i=this,a=Array.prototype.slice.call(arguments),n&&(t||o))return;if(!t)return d(),n=setTimeout(f,e),n;n=setTimeout(d,e),r.apply(i,a);function f(){d(),r.apply(i,a)}function d(){clearTimeout(n),n=null}}}});var x="fs-attributes";var O="a11y",re="accordion";var ne="cmsattribute";var oe="inputcounter";var ae="modal";var H="support";var ie=async(...r)=>{var t;let e=[];for(let o of r){let n=await((t=window.fsAttributes[o])==null?void 0:t.loading);e.push(n)}return e};var w=()=>{};function V(r,e,t,o){return r?(r.addEventListener(e,t,o),()=>r.removeEventListener(e,t,o)):w}var Y=(r,e)=>(Array.isArray(e)||(e=[e]),e.map(o=>r.dispatchEvent(new Event(o,{bubbles:!0}))).every(o=>o));var j=r=>r instanceof Element;var q=r=>r!=null;var L=r=>!!(r.offsetWidth||r.offsetHeight||r.getClientRects().length);function se(r,e,t){var n;let o=window.fsAttributes[r];return o.destroy=t||w,(n=o.resolve)==null||n.call(o,e),e}var ce=(r,e="1",t="iife")=>{let n=`${r}${t==="esm"?".esm":""}.js`;return`https://cdn.jsdelivr.net/npm/@finsweet/attributes-${r}@${e}/${n}`};var We=`${x}-${H}`,ue=async()=>{var n;let{fsAttributes:r,location:e}=window,{host:t,searchParams:o}=new URL(e.href);return!t.includes("webflow.io")||!o.has(We)?!1:(n=r.import)==null?void 0:n.call(r,H,"1")};var le=r=>{let e=(n,a,i)=>{let l=r[n],{key:f,values:d}=l,v;if(!a)return`[${f}]`;let E=d==null?void 0:d[a];typeof E=="string"?v=E:v=E(i&&"instanceIndex"in i?i.instanceIndex:void 0);let A=i&&"caseInsensitive"in i&&i.caseInsensitive?"i":"";if(!(i!=null&&i.operator))return`[${f}="${v}"${A}]`;switch(i.operator){case"prefixed":return`[${f}^="${v}"${A}]`;case"suffixed":return`[${f}$="${v}"${A}]`;case"contains":return`[${f}*="${v}"${A}]`}};function t(n,a){let i=e("element",n,a),l=(a==null?void 0:a.scope)||document;return a!=null&&a.all?[...l.querySelectorAll(i)]:l.querySelector(i)}return[e,t,(n,a)=>{let i=r[a];return i?n.getAttribute(i.key):null}]};var N={preventLoad:{key:`${x}-preventload`},debugMode:{key:`${x}-debug`},src:{key:"src",values:{finsweet:"@finsweet/attributes"}},dev:{key:`${x}-dev`}},[G,Qt]=le(N);var fe=r=>{let{currentScript:e}=document,t={};if(!e)return{attributes:t,preventsLoad:!1};let n={preventsLoad:typeof e.getAttribute(N.preventLoad.key)=="string",attributes:t};for(let a in r){let i=e.getAttribute(r[a]);n.attributes[a]=i}return n};var de=({scriptAttributes:r,attributeKey:e,version:t,init:o})=>{var l;ze(),(l=window.fsAttributes)[e]||(l[e]={});let{preventsLoad:n,attributes:a}=fe(r),i=window.fsAttributes[e];i.version=t,i.init=o,n||(window.Webflow||(window.Webflow=[]),window.Webflow.push(()=>o(a)))},ze=()=>{let r=Ze();if(window.fsAttributes&&!Array.isArray(window.fsAttributes)){X(window.fsAttributes,r);return}let e=Qe(r);X(e,r),Je(e),window.fsAttributes=e,window.FsAttributes=window.fsAttributes,ue()},Qe=r=>{let e={cms:{},push(...t){var o,n;for(let[a,i]of t)(n=(o=this[a])==null?void 0:o.loading)==null||n.then(i)},async import(t,o){let n=e[t];return n||new Promise(a=>{let i=document.createElement("script");i.src=ce(t,o),i.async=!0,i.onload=()=>{let[l]=X(e,[t]);a(l)},document.head.append(i)})},destroy(){var t,o;for(let n of r)(o=(t=window.fsAttributes[n])==null?void 0:t.destroy)==null||o.call(t)}};return e},Ze=()=>{let r=G("src","finsweet",{operator:"contains"}),e=G("dev");return[...document.querySelectorAll(`script${r}, script${e}`)].reduce((n,a)=>{var l;let i=a.getAttribute(N.dev.key)||((l=a.src.match(/[\w-. ]+(?=(\.js)$)/))==null?void 0:l[0]);return i&&!n.includes(i)&&n.push(i),n},[])},X=(r,e)=>e.map(o=>{let n=r[o];return n||(r[o]={},n=r[o],n.loading=new Promise(a=>{n.resolve=i=>{a(i),delete n.resolve}}),n)}),Je=r=>{let e=Array.isArray(window.fsAttributes)?window.fsAttributes:[];r.push(...e)};var be="1.1.0";var me=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],B=me.join(","),Te=typeof Element=="undefined",g=Te?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,U=!Te&&Element.prototype.getRootNode?function(r){return r.getRootNode()}:function(r){return r.ownerDocument},ve=function(e,t,o){var n=Array.prototype.slice.apply(e.querySelectorAll(B));return t&&g.call(e,B)&&n.unshift(e),n=n.filter(o),n},Ee=function r(e,t,o){for(var n=[],a=Array.from(e);a.length;){var i=a.shift();if(i.tagName==="SLOT"){var l=i.assignedElements(),f=l.length?l:i.children,d=r(f,!0,o);o.flatten?n.push.apply(n,d):n.push({scopeParent:i,candidates:d})}else{var v=g.call(i,B);v&&o.filter(i)&&(t||!e.includes(i))&&n.push(i);var E=i.shadowRoot||typeof o.getShadowRoot=="function"&&o.getShadowRoot(i),A=!o.shadowRootFilter||o.shadowRootFilter(i);if(E&&A){var I=r(E===!0?i.children:E.children,!0,o);o.flatten?n.push.apply(n,I):n.push({scopeParent:i,candidates:I})}else a.unshift.apply(a,i.children)}}return n},Ae=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},tt=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},ye=function(e){return e.tagName==="INPUT"},rt=function(e){return ye(e)&&e.type==="hidden"},nt=function(e){var t=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(o){return o.tagName==="SUMMARY"});return t},ot=function(e,t){for(var o=0;o<e.length;o++)if(e[o].checked&&e[o].form===t)return e[o]},at=function(e){if(!e.name)return!0;var t=e.form||U(e),o=function(l){return t.querySelectorAll('input[type="radio"][name="'+l+'"]')},n;if(typeof window!="undefined"&&typeof window.CSS!="undefined"&&typeof window.CSS.escape=="function")n=o(window.CSS.escape(e.name));else try{n=o(e.name)}catch(i){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",i.message),!1}var a=ot(n,e.form);return!a||a===e},it=function(e){return ye(e)&&e.type==="radio"},st=function(e){return it(e)&&!at(e)},ct=function(e){for(var t,o=U(e).host,n=!!((t=o)!==null&&t!==void 0&&t.ownerDocument.contains(o)||e.ownerDocument.contains(e));!n&&o;){var a;o=U(o).host,n=!!((a=o)!==null&&a!==void 0&&a.ownerDocument.contains(o))}return n},pe=function(e){var t=e.getBoundingClientRect(),o=t.width,n=t.height;return o===0&&n===0},ut=function(e,t){var o=t.displayCheck,n=t.getShadowRoot;if(getComputedStyle(e).visibility==="hidden")return!0;var a=g.call(e,"details>summary:first-of-type"),i=a?e.parentElement:e;if(g.call(i,"details:not([open]) *"))return!0;if(!o||o==="full"||o==="legacy-full"){if(typeof n=="function"){for(var l=e;e;){var f=e.parentElement,d=U(e);if(f&&!f.shadowRoot&&n(f)===!0)return pe(e);e.assignedSlot?e=e.assignedSlot:!f&&d!==e.ownerDocument?e=d.host:e=f}e=l}if(ct(e))return!e.getClientRects().length;if(o!=="legacy-full")return!0}else if(o==="non-zero-area")return pe(e);return!1},lt=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if(t.tagName==="FIELDSET"&&t.disabled){for(var o=0;o<t.children.length;o++){var n=t.children.item(o);if(n.tagName==="LEGEND")return g.call(t,"fieldset[disabled] *")?!0:!n.contains(e)}return!0}t=t.parentElement}return!1},F=function(e,t){return!(t.disabled||rt(t)||ut(t,e)||nt(t)||lt(t))},W=function(e,t){return!(st(t)||Ae(t)<0||!F(e,t))},ft=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},dt=function r(e){var t=[],o=[];return e.forEach(function(n,a){var i=!!n.scopeParent,l=i?n.scopeParent:n,f=Ae(l,i),d=i?r(n.candidates):l;f===0?i?t.push.apply(t,d):t.push(l):o.push({documentOrder:a,tabIndex:f,item:n,isScope:i,content:d})}),o.sort(tt).reduce(function(n,a){return a.isScope?n.push.apply(n,a.content):n.push(a.content),n},[]).concat(t)},he=function(e,t){t=t||{};var o;return t.getShadowRoot?o=Ee([e],t.includeContainer,{filter:W.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:ft}):o=ve(e,t.includeContainer,W.bind(null,t)),dt(o)},ge=function(e,t){t=t||{};var o;return t.getShadowRoot?o=Ee([e],t.includeContainer,{filter:F.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):o=ve(e,t.includeContainer,F.bind(null,t)),o},_=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return g.call(e,B)===!1?!1:W(t,e)},bt=me.concat("iframe").join(","),P=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return g.call(e,bt)===!1?!1:F(t,e)};function xe(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);e&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,o)}return t}function Re(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?xe(Object(t),!0).forEach(function(o){pt(r,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):xe(Object(t)).forEach(function(o){Object.defineProperty(r,o,Object.getOwnPropertyDescriptor(t,o))})}return r}function pt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var Ie=function(){var r=[];return{activateTrap:function(t){if(r.length>0){var o=r[r.length-1];o!==t&&o.pause()}var n=r.indexOf(t);n===-1||r.splice(n,1),r.push(t)},deactivateTrap:function(t){var o=r.indexOf(t);o!==-1&&r.splice(o,1),r.length>0&&r[r.length-1].unpause()}}}(),mt=function(e){return e.tagName&&e.tagName.toLowerCase()==="input"&&typeof e.select=="function"},Tt=function(e){return e.key==="Escape"||e.key==="Esc"||e.keyCode===27},vt=function(e){return e.key==="Tab"||e.keyCode===9},Se=function(e){return setTimeout(e,0)},we=function(e,t){var o=-1;return e.every(function(n,a){return t(n)?(o=a,!1):!0}),o},C=function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return typeof e=="function"?e.apply(void 0,o):e},k=function(e){return e.target.shadowRoot&&typeof e.composedPath=="function"?e.composedPath()[0]:e.target},Ne=function(e,t){var o=(t==null?void 0:t.document)||document,n=Re({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},t),a={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},i,l=function(s,c,u){return s&&s[c]!==void 0?s[c]:n[u||c]},f=function(s){return a.containerGroups.findIndex(function(c){var u=c.container,m=c.tabbableNodes;return u.contains(s)||m.find(function(b){return b===s})})},d=function(s){var c=n[s];if(typeof c=="function"){for(var u=arguments.length,m=new Array(u>1?u-1:0),b=1;b<u;b++)m[b-1]=arguments[b];c=c.apply(void 0,m)}if(c===!0&&(c=void 0),!c){if(c===void 0||c===!1)return c;throw new Error("`".concat(s,"` was specified but was not a node, or did not return a node"))}var T=c;if(typeof c=="string"&&(T=o.querySelector(c),!T))throw new Error("`".concat(s,"` as selector refers to no known node"));return T},v=function(){var s=d("initialFocus");if(s===!1)return!1;if(s===void 0)if(f(o.activeElement)>=0)s=o.activeElement;else{var c=a.tabbableGroups[0],u=c&&c.firstTabbableNode;s=u||d("fallbackFocus")}if(!s)throw new Error("Your focus-trap needs to have at least one focusable element");return s},E=function(){if(a.containerGroups=a.containers.map(function(s){var c=he(s,n.tabbableOptions),u=ge(s,n.tabbableOptions);return{container:s,tabbableNodes:c,focusableNodes:u,firstTabbableNode:c.length>0?c[0]:null,lastTabbableNode:c.length>0?c[c.length-1]:null,nextTabbableNode:function(b){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,y=u.findIndex(function(h){return h===b});if(!(y<0))return T?u.slice(y+1).find(function(h){return _(h,n.tabbableOptions)}):u.slice(0,y).reverse().find(function(h){return _(h,n.tabbableOptions)})}}}),a.tabbableGroups=a.containerGroups.filter(function(s){return s.tabbableNodes.length>0}),a.tabbableGroups.length<=0&&!d("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},A=function p(s){if(s!==!1&&s!==o.activeElement){if(!s||!s.focus){p(v());return}s.focus({preventScroll:!!n.preventScroll}),a.mostRecentlyFocusedNode=s,mt(s)&&s.select()}},I=function(s){var c=d("setReturnFocus",s);return c||(c===!1?!1:s)},D=function(s){var c=k(s);if(!(f(c)>=0)){if(C(n.clickOutsideDeactivates,s)){i.deactivate({returnFocus:n.returnFocusOnDeactivate&&!P(c,n.tabbableOptions)});return}C(n.allowOutsideClick,s)||s.preventDefault()}},z=function(s){var c=k(s),u=f(c)>=0;u||c instanceof Document?u&&(a.mostRecentlyFocusedNode=c):(s.stopImmediatePropagation(),A(a.mostRecentlyFocusedNode||v()))},ke=function(s){var c=k(s);E();var u=null;if(a.tabbableGroups.length>0){var m=f(c),b=m>=0?a.containerGroups[m]:void 0;if(m<0)s.shiftKey?u=a.tabbableGroups[a.tabbableGroups.length-1].lastTabbableNode:u=a.tabbableGroups[0].firstTabbableNode;else if(s.shiftKey){var T=we(a.tabbableGroups,function(M){var $=M.firstTabbableNode;return c===$});if(T<0&&(b.container===c||P(c,n.tabbableOptions)&&!_(c,n.tabbableOptions)&&!b.nextTabbableNode(c,!1))&&(T=m),T>=0){var y=T===0?a.tabbableGroups.length-1:T-1,h=a.tabbableGroups[y];u=h.lastTabbableNode}}else{var S=we(a.tabbableGroups,function(M){var $=M.lastTabbableNode;return c===$});if(S<0&&(b.container===c||P(c,n.tabbableOptions)&&!_(c,n.tabbableOptions)&&!b.nextTabbableNode(c))&&(S=m),S>=0){var Ke=S===a.tabbableGroups.length-1?0:S+1,Me=a.tabbableGroups[Ke];u=Me.firstTabbableNode}}}else u=d("fallbackFocus");u&&(s.preventDefault(),A(u))},Q=function(s){if(Tt(s)&&C(n.escapeDeactivates,s)!==!1){s.preventDefault(),i.deactivate();return}if(vt(s)){ke(s);return}},Z=function(s){var c=k(s);f(c)>=0||C(n.clickOutsideDeactivates,s)||C(n.allowOutsideClick,s)||(s.preventDefault(),s.stopImmediatePropagation())},J=function(){if(!!a.active)return Ie.activateTrap(i),a.delayInitialFocusTimer=n.delayInitialFocus?Se(function(){A(v())}):A(v()),o.addEventListener("focusin",z,!0),o.addEventListener("mousedown",D,{capture:!0,passive:!1}),o.addEventListener("touchstart",D,{capture:!0,passive:!1}),o.addEventListener("click",Z,{capture:!0,passive:!1}),o.addEventListener("keydown",Q,{capture:!0,passive:!1}),i},ee=function(){if(!!a.active)return o.removeEventListener("focusin",z,!0),o.removeEventListener("mousedown",D,!0),o.removeEventListener("touchstart",D,!0),o.removeEventListener("click",Z,!0),o.removeEventListener("keydown",Q,!0),i};return i={get active(){return a.active},get paused(){return a.paused},activate:function(s){if(a.active)return this;var c=l(s,"onActivate"),u=l(s,"onPostActivate"),m=l(s,"checkCanFocusTrap");m||E(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=o.activeElement,c&&c();var b=function(){m&&E(),J(),u&&u()};return m?(m(a.containers.concat()).then(b,b),this):(b(),this)},deactivate:function(s){if(!a.active)return this;var c=Re({onDeactivate:n.onDeactivate,onPostDeactivate:n.onPostDeactivate,checkCanReturnFocus:n.checkCanReturnFocus},s);clearTimeout(a.delayInitialFocusTimer),a.delayInitialFocusTimer=void 0,ee(),a.active=!1,a.paused=!1,Ie.deactivateTrap(i);var u=l(c,"onDeactivate"),m=l(c,"onPostDeactivate"),b=l(c,"checkCanReturnFocus"),T=l(c,"returnFocus","returnFocusOnDeactivate");u&&u();var y=function(){Se(function(){T&&A(I(a.nodeFocusedBeforeActivation)),m&&m()})};return T&&b?(b(I(a.nodeFocusedBeforeActivation)).then(y,y),this):(y(),this)},pause:function(){return a.paused||!a.active?this:(a.paused=!0,ee(),this)},unpause:function(){return!a.paused||!a.active?this:(a.paused=!1,E(),J(),this)},updateContainerElements:function(s){var c=[].concat(s).filter(Boolean);return a.containers=c.map(function(u){return typeof u=="string"?o.querySelector(u):u}),a.active&&E(),this}},i.updateContainerElements(e),i};var Be=Xe(Ce(),1);var K="role";var De="tabindex";var Oe="aria-expanded";var R="aria-controls";var Ue=()=>{let e=[...document.querySelectorAll(`[${R}]`)].map(yt).filter(q);return()=>{for(let t of e)t()}},yt=r=>{let e=r.getAttribute(R);if(!e)return;let t=document.getElementById(e);if(!t){r.removeAttribute(R);return}let n=t.getAttribute(K)==="dialog"?Ne(t,{returnFocusOnDeactivate:!0}):null,a=L(t);Le(r,a);let l=(0,Be.default)(()=>{let d=L(t);Le(r,d),d?n==null||n.activate():n==null||n.deactivate(),a=d},100),f=new MutationObserver(l);return f.observe(t,{attributes:!0,attributeFilter:["style","class"]}),()=>{f.disconnect(),n==null||n.deactivate()}},Le=(r,e)=>{r.setAttribute(Oe,String(e))};var ht=[HTMLAnchorElement,HTMLButtonElement,HTMLInputElement,HTMLTextAreaElement,HTMLSelectElement,HTMLVideoElement,HTMLAudioElement],Fe=()=>{let r=V(window,"keydown",e=>{let{key:t}=e;if(t==="Escape")return xt(e);if(t==="Enter"||t===" ")return gt(e)});return()=>{r()}},gt=r=>{let{target:e}=r;!j(e)||!e.getAttribute(De)||ht.some(t=>e instanceof t)||(r.preventDefault(),Y(e,"click"))},xt=r=>{let{target:e}=r;if(!j(e))return;let t=e.closest(`[${K}="${"dialog"}"]`);if(!t||!t.id)return;let o=`[${R}="${t.id}"]`,n=t.querySelector(o)||document.querySelector(o);!n||(r.preventDefault(),n.click())};var Pe=async()=>{await ie(ne,ae,oe,re);let r=Fe(),e=Ue();return se(O,void 0,()=>{r(),e()})};de({init:Pe,version:be,attributeKey:O});})();
/*!
* focus-trap 7.0.0
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
/*!
* tabbable 6.0.1
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/

2

changesets.json

@@ -1,1 +0,1 @@

[{"version":"1.0.0","markdown":"- 1eb9c91e: Added support for `fs-accordion` + released official v1.0.0"},{"version":"0.2.1","markdown":"- 460f73c6: Ensure compatibility with modal and inputcounter"},{"version":"0.2.0","markdown":"- e4b3b680: Created new `window.fsAttributes.destroy()` method to support SPA environments.\n This new method allows users to destroy all Attributes instances, cleaning up event listeners, observers, states, global variables, etc.\n\n Websites that use a client-side router that simulates an SPA environment like [barba.js](https://barba.js.org/) or [Swup](https://swup.js.org/) can now properly init and destroy Attributes.\n After destroying, Attributes can be manually re-initted by calling `window.fsAttribute[ATTRIBUTE_KEY].init()`.\n\n Updated changesets system, now all updates will be correctly reflected in [the official updates page](https://www.finsweet.com/attributes/updates)."},{"version":"0.1.3","markdown":"- Updated dependencies [4792998a]\n - @global/constants@1.2.0\n - @global/factory@1.1.5"},{"version":"0.1.2","markdown":"- Updated dependencies [07f32375]\n - @global/constants@1.1.0\n - @global/factory@1.1.4"},{"version":"0.1.1","markdown":"- 62a2d7f3: Ensured aria-expanded is always set for aria-controls controllers"},{"version":"0.1.0","markdown":"- a14e67a5: Added aria-controls and keyboard-clicks functionalities."}]
[{"version":"1.1.0","markdown":"- 59aa74dd: Improved keyboard accessibility for modals/dialogs"},{"version":"1.0.0","markdown":"- 1eb9c91e: Added support for `fs-accordion` + released official v1.0.0"},{"version":"0.2.1","markdown":"- 460f73c6: Ensure compatibility with modal and inputcounter"},{"version":"0.2.0","markdown":"- e4b3b680: Created new `window.fsAttributes.destroy()` method to support SPA environments.\n This new method allows users to destroy all Attributes instances, cleaning up event listeners, observers, states, global variables, etc.\n\n Websites that use a client-side router that simulates an SPA environment like [barba.js](https://barba.js.org/) or [Swup](https://swup.js.org/) can now properly init and destroy Attributes.\n After destroying, Attributes can be manually re-initted by calling `window.fsAttribute[ATTRIBUTE_KEY].init()`.\n\n Updated changesets system, now all updates will be correctly reflected in [the official updates page](https://www.finsweet.com/attributes/updates)."},{"version":"0.1.3","markdown":"- Updated dependencies [4792998a]\n - @global/constants@1.2.0\n - @global/factory@1.1.5"},{"version":"0.1.2","markdown":"- Updated dependencies [07f32375]\n - @global/constants@1.1.0\n - @global/factory@1.1.4"},{"version":"0.1.1","markdown":"- 62a2d7f3: Ensured aria-expanded is always set for aria-controls controllers"},{"version":"0.1.0","markdown":"- a14e67a5: Added aria-controls and keyboard-clicks functionalities."}]
{
"name": "@finsweet/attributes-a11y",
"version": "1.0.0",
"version": "1.1.0",
"description": "Accessibility JS solutions for Webflow.",

@@ -34,2 +34,3 @@ "homepage": "https://www.finsweet.com/attributes",

"dependencies": {
"focus-trap": "^7.0.0",
"just-debounce": "^1.1.0"

@@ -36,0 +37,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc