@dialpad/dialtone-vue
Version:
Vue component library for Dialpad's design system Dialtone
3 lines (2 loc) • 5.57 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../constants/index.cjs"),v=require("vue");let D=0,u;const $="input:not([type=hidden]):not(:disabled)",M="select:not(:disabled),textarea:not(:disabled),button:not(:disabled)",j=`${$},${M}`,k=`a,frame,iframe,${j},*[tabindex]`,V=typeof setImmediate=="function"?setImmediate:setTimeout;function l(e=o.DEFAULT_PREFIX){return`${e}${D++}`}function d(e,t){if(t){const n=f(t);return e[Math.abs(n)%e.length]}else return e[s(e.length)]}function f(e){let t;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return t}function s(e){return Math.floor(Math.random()*e)}function m(e){return e?e.map(t=>typeof t=="string"?{message:t,type:o.DEFAULT_VALIDATION_MESSAGE_TYPE}:t):[]}function E(e){const t=c(e);return!e||!t?[]:e.filter(n=>!!n.message&&n.type===t)}function c(e){return e?r(e,o.VALIDATION_MESSAGE_TYPES.ERROR)?o.VALIDATION_MESSAGE_TYPES.ERROR:r(e,o.VALIDATION_MESSAGE_TYPES.WARNING)?o.VALIDATION_MESSAGE_TYPES.WARNING:r(e,o.VALIDATION_MESSAGE_TYPES.SUCCESS)?o.VALIDATION_MESSAGE_TYPES.SUCCESS:null:null}function r(e,t){return!e||!t?!1:e.some(n=>(n==null?void 0:n.type)===t)}function W(e){return e==null?void 0:e.querySelector(k)}const b={name:"html-fragment",functional:!0,props:["html"],render(e,t){return new v({name:"Inner",beforeCreate(){this.$createElement=e},template:`<div>${t.props.html}</div>`}).$mount()._vnode.children}},g=()=>new Promise(e=>{V(e)}),h=e=>e==null?void 0:e.toLowerCase().split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),z=e=>e.replace(/\.?([A-Z0-9]+)/g,(t,n)=>"-"+n.toLowerCase()).replace(/^-/,"");function S(e,t=300){clearTimeout(u),u=setTimeout(e,t)}function p(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(i=>i),n.all=Object.values(n).every(i=>i),n}const G=/(?:(?:[^\s!@#$%^&*()_=+[\]{}\\|;:'",.<>/?]+)\.)/,B=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)"),H=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])"),R=new RegExp("(?:"+[[G.source,B.source].join("+"),H.source].join("|")+")"),Y=/(?:(?:[;/][^#?<>\s]*)?)/,A=/(?:(?:\?[^#<>\s]+)?(?:#[^<>\s]+)?)/,_=new RegExp("\\b"+[R.source,Y.source,A.source,"(?!\\w)"].join("+")),T=/\b[a-z\d.-]+:\/\/[^<>\s]+/,C=new RegExp("(?:mailto:)?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+[R.source,A.source].join("+")+"(?!\\w)");function a(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 O=a(),I=new RegExp([_.source,T.source,C.source,O.source].join("|"),"gi");function x(e){var t;return!e||!["string","number"].includes(typeof e)?!1:(e=e.toString(),((t=O.exec(e))==null?void 0:t[0])===e)}function L(e){var t,n;return!e||typeof e!="string"?!1:((t=_.exec(e))==null?void 0:t[0])===e||((n=T.exec(e))==null?void 0:n[0])===e}function N(e){var t;return!e||typeof e!="string"?!1:((t=C.exec(e))==null?void 0:t[0])===e}function w(e){return e.filter(t=>!!t).join(", ")}function y(e,t="en-US"){return e.replace(new RegExp("^\\p{CWU}","u"),n=>n.toLocaleUpperCase(t))}function q(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 P(e=document.documentElement){return!!e.hasAttribute("data-overlayscrollbars")}function U(e=document.documentElement){P(e)?e.classList.add("d-scrollbar-disabled"):e.classList.add("d-of-hidden")}function F(e=document.documentElement){P(e)?e.classList.remove("d-scrollbar-disabled"):e.classList.remove("d-of-hidden")}function K(e){return e.replaceAll(/[ -]/g,"_").replaceAll(/\W/g,"").toUpperCase()}const Q={getUniqueString:l,getRandomElement:d,getRandomInt:s,formatMessages:m,filterFormattedMessages:E,hasFormattedMessageOfType:r,getValidationState:c,htmlFragment:b,flushPromises:g,kebabCaseToPascalCase:h,debounce:S,isOutOfViewPort:p,getPhoneNumberRegex:a,linkRegex:I,isEmailAddress:N,isPhoneNumber:x,isURL:L,safeConcatStrings:w,capitalizeFirstLetter:y,disableRootScrolling:U,enableRootScrolling:F};exports.capitalizeFirstLetter=y;exports.debounce=S;exports.default=Q;exports.disableRootScrolling=U;exports.enableRootScrolling=F;exports.filterFormattedMessages=E;exports.findFirstFocusableNode=W;exports.flushPromises=g;exports.formatMessages=m;exports.getPhoneNumberRegex=a;exports.getRandomElement=d;exports.getRandomInt=s;exports.getUniqueString=l;exports.getValidationState=c;exports.hasFormattedMessageOfType=r;exports.htmlFragment=b;exports.isEmailAddress=N;exports.isOutOfViewPort=p;exports.isPhoneNumber=x;exports.isURL=L;exports.javaHashCode=f;exports.kebabCaseToPascalCase=h;exports.linkRegex=I;exports.pascalCaseToKebabCase=z;exports.safeConcatStrings=w;exports.toFluentKeyString=K;exports.warnIfUnmounted=q;
//# sourceMappingURL=index.cjs.map