dap-design-system
Version:
Official design system for the DÁP (dap.gov.hu)
90 lines (89 loc) • 2.41 kB
JavaScript
var a = Object.defineProperty;
var s = Object.getOwnPropertySymbols;
var l = Object.prototype.hasOwnProperty, f = Object.prototype.propertyIsEnumerable;
var i = (t, r, e) => r in t ? a(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e, c = (t, r) => {
for (var e in r || (r = {}))
l.call(r, e) && i(t, e, r[e]);
if (s)
for (var e of s(r))
f.call(r, e) && i(t, e, r[e]);
return t;
};
window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
function p(t) {
var e;
const r = (e = t.closest("dap-ds-card")) == null ? void 0 : e.getAttribute("size");
t.setAttribute("size", r != null ? r : "sm");
}
const m = (t) => {
let r = {};
try {
r = JSON.parse(t != null ? t : "");
} catch (e) {
console.error("Incorrect Json string data", {
data: t
});
}
return r;
};
function u(t) {
return t == null || t === "null" || t === "undefined" ? "" : t;
}
const b = {
fromAttribute: (t) => u(t),
toAttribute: (t) => !t || t === "null" || t === "undefined" ? null : t
};
function g(t) {
const r = (n) => {
if (n instanceof Element && n.assignedSlot)
return n.assignedSlot;
const o = n.parentNode;
return o instanceof ShadowRoot ? o.host : o;
};
let e = r(t);
for (; e instanceof HTMLElement; ) {
const { overflowY: n } = getComputedStyle(e);
if (/(auto|scroll|overlay)/.test(n) && e.scrollHeight > e.clientHeight)
return e;
e = r(e);
}
return null;
}
function h(t) {
const r = g(t);
if (!r)
return;
const e = r.getBoundingClientRect(), n = t.getBoundingClientRect();
n.top < e.top ? r.scrollTop -= e.top - n.top : n.bottom > e.bottom && (r.scrollTop += n.bottom - e.bottom);
}
function S(t) {
return c({
badInput: !1,
customError: !1,
patternMismatch: !1,
rangeOverflow: !1,
rangeUnderflow: !1,
stepMismatch: !1,
tooLong: !1,
tooShort: !1,
typeMismatch: !1,
valid: !0,
valueMissing: !1
}, t);
}
function w(t) {
return t.trim().toLowerCase().replace(/\./g, "-").replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/--+/g, "-").replace(/^-+|-+$/g, "");
}
export {
m as JSONAttributeParser,
g as getScrollParent,
S as getValidityStateObject,
w as kebabCase,
u as normalizeStringProperty,
h as scrollIntoContainer,
p as setFromParentSize,
b as stringPropertyConverter
};
//# sourceMappingURL=utils.js.map