@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
3 lines (2 loc) • 6.31 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../constants/index.cjs"),f=require("../config/index.cjs"),i=require("vue");let k=0,d;const W="input:not([type=hidden]):not(:disabled)",z="select:not(:disabled),textarea:not(:disabled),button:not(:disabled)",G=`${W},${z}`,H=`a,frame,iframe,${G},*[tabindex]`,B=typeof setImmediate=="function"?setImmediate:setTimeout;function E(e=r.DEFAULT_PREFIX){return`${e}${k++}`}function m(e,t){if(t){const n=g(t);return e[Math.abs(n)%e.length]}else return e[c(e.length)]}function g(e){let t;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return t}function c(e){return Math.floor(Math.random()*e)}function S(e){return e?e.map(t=>typeof t=="string"?{message:t,type:r.DEFAULT_VALIDATION_MESSAGE_TYPE}:t):[]}function b(e){const t=u(e);return!e||!t?[]:e.filter(n=>!!n.message&&n.type===t)}function u(e){return e?o(e,r.VALIDATION_MESSAGE_TYPES.ERROR)?r.VALIDATION_MESSAGE_TYPES.ERROR:o(e,r.VALIDATION_MESSAGE_TYPES.WARNING)?r.VALIDATION_MESSAGE_TYPES.WARNING:o(e,r.VALIDATION_MESSAGE_TYPES.SUCCESS)?r.VALIDATION_MESSAGE_TYPES.SUCCESS:null:null}function o(e,t){return!e||!t?!1:e.some(n=>(n==null?void 0:n.type)===t)}function Y(e){return e==null?void 0:e.querySelector(H)}const h=e=>i.h("div",{innerHTML:e.html}),p=()=>new Promise(e=>{B(e)});function q(e,t={}){return e?e(t).some(n=>n.type===i.Comment||Array.isArray(n.children)&&!n.children.length?!1:n.type!==i.Text||typeof n.children=="string"&&n.children.trim()!==""):!1}const A=e=>e==null?void 0:e.toLowerCase().split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),K=e=>e.replace(/\.?([A-Z0-9]+)/g,(t,n)=>"-"+n.toLowerCase()).replace(/^-/,""),R=e=>{const t=Object.entries(e).filter(([n])=>n.match(/on[A-Z]/));return Object.fromEntries(t)},a=e=>(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:e!=null&&e.nodeType?a(e==null?void 0:e.nextSibling):null;function T(e){if(!f.configVue2StyleClassAttrs)return e;const t=Object.entries(e).filter(([n])=>!["class","style"].includes(n));return Object.fromEntries(t)}function C(e){return f.configVue2StyleClassAttrs?{class:e.class,style:e.style}:{}}function _(e,t=300){clearTimeout(d),d=setTimeout(e,t)}function y(e){const t=e.getBoundingClientRect(),n={top:t.top<0,left:t.left<0,bottom:t.bottom>(window.innerHeight||document.documentElement.clientHeight),right:t.right>(window.innerWidth||document.documentElement.clientWidth)};return n.any=Object.values(n).some(s=>s),n.all=Object.values(n).every(s=>s),n}const Q=/(?:(?:[^\s!@#$%^&*()_=+[\]{}\\|;:'",.<>/?]+)\.)/,Z=new RegExp("(?:com|ru|org|net|de|jp|uk|br|it|pl|fr|in|au|ir|info|nl|cn|es|cz|kr|ca|eu|ua|co|gr|za|ro|biz|ch|se|tw|mx|vn|hu|be|tr|at|dk|tv|me|ar|sk|no|us|fi|id|cl|xyz|io|pt|by|il|ie|nz|kz|hk|lt|cc|my|sg|club|bg|edu|рф|pk|su|top|th|hr|rs|pe|pro|si|az|lv|pw|ae|ph|online|ng|ee|ws|ve|cat)"),X=new RegExp("(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])"),O=new RegExp("(?:"+[[Q.source,Z.source].join("+"),X.source].join("|")+")"),J=/(?:(?:[;/][^#?<>\s]*)?)/,x=/(?:(?:\?[^#<>\s]+)?(?:#[^<>\s]+)?)/,L=new RegExp("\\b"+[O.source,J.source,x.source,"(?!\\w)"].join("+")),I=/\b[a-z\d.-]+:\/\/[^<>\s]+/,N=new RegExp("(?:mailto:)?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+[O.source,x.source].join("+")+"(?!\\w)");function l(e=7,t=15){try{return new RegExp(`(?:^|(?<=\\W))(?![\\s\\-])\\+?(?:[0-9()\\- \\t]{${e},${t}})(?=\\b)(?=\\W(?=\\W|$)|\\s|$)`)}catch{console.warn("This browser doesn't support regex lookahead/lookbehind")}return new RegExp(`(?![\\s\\-])\\+?(?:[0-9()\\- \\t]{${e},${t}})(?=\\b)(?=\\W(?=\\W|$)|\\s|$)`)}const w=l(),F=new RegExp([L.source,I.source,N.source,w.source].join("|"),"gi");function P(e){var t;return!e||!["string","number"].includes(typeof e)?!1:(e=e.toString(),((t=w.exec(e))==null?void 0:t[0])===e)}function U(e){var t,n;return!e||typeof e!="string"?!1:((t=L.exec(e))==null?void 0:t[0])===e||((n=I.exec(e))==null?void 0:n[0])===e}function D(e){var t;return!e||typeof e!="string"?!1:((t=N.exec(e))==null?void 0:t[0])===e}function j(e){return e.filter(t=>!!t).join(", ")}function M(e,t="en-US"){return e.replace(new RegExp("^\\p{CWU}","u"),n=>n.toLocaleUpperCase(t))}function ee(e,t){typeof process>"u"||process.env.NODE_ENV==="test"&&(!e||!(e instanceof HTMLElement)||!(document!=null&&document.body)||document.body.contains(e)||console.warn(`The ${t} component is not attached to the document body. This may cause issues.`))}function $(e=document.documentElement){return!!e.hasAttribute("data-overlayscrollbars")}function v(e=document.documentElement){$(e)?e.classList.add("d-scrollbar-disabled"):e.classList.add("d-of-hidden")}function V(e=document.documentElement){$(e)?e.classList.remove("d-scrollbar-disabled"):e.classList.remove("d-of-hidden")}function te(e){return e.replaceAll(/[ -]/g,"_").replaceAll(/\W/g,"").toUpperCase()}const ne={getUniqueString:E,getRandomElement:m,getRandomInt:c,formatMessages:S,filterFormattedMessages:b,hasFormattedMessageOfType:o,getValidationState:u,htmlFragment:h,flushPromises:p,kebabCaseToPascalCase:A,extractVueListeners:R,removeClassStyleAttrs:T,addClassStyleAttrs:C,returnFirstEl:a,debounce:_,isOutOfViewPort:y,getPhoneNumberRegex:l,linkRegex:F,isEmailAddress:D,isPhoneNumber:P,isURL:U,safeConcatStrings:j,capitalizeFirstLetter:M,disableRootScrolling:v,enableRootScrolling:V};exports.addClassStyleAttrs=C;exports.capitalizeFirstLetter=M;exports.debounce=_;exports.default=ne;exports.disableRootScrolling=v;exports.enableRootScrolling=V;exports.extractVueListeners=R;exports.filterFormattedMessages=b;exports.findFirstFocusableNode=Y;exports.flushPromises=p;exports.formatMessages=S;exports.getPhoneNumberRegex=l;exports.getRandomElement=m;exports.getRandomInt=c;exports.getUniqueString=E;exports.getValidationState=u;exports.hasFormattedMessageOfType=o;exports.hasSlotContent=q;exports.htmlFragment=h;exports.isEmailAddress=D;exports.isOutOfViewPort=y;exports.isPhoneNumber=P;exports.isURL=U;exports.javaHashCode=g;exports.kebabCaseToPascalCase=A;exports.linkRegex=F;exports.pascalCaseToKebabCase=K;exports.removeClassStyleAttrs=T;exports.returnFirstEl=a;exports.safeConcatStrings=j;exports.toFluentKeyString=te;exports.warnIfUnmounted=ee;
//# sourceMappingURL=index.cjs.map