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