laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
35 lines (34 loc) • 874 B
JavaScript
"use client";
import { DefinedInfo as a } from "./util/defined-info.js";
import { Info as p } from "./util/info.js";
import { normalize as f } from "./normalize.js";
const l = /[A-Z]/g, s = /-[a-z]/g, d = /^data[-\w.:]+$/i;
function y(r, t) {
const n = f(t);
let i = t, c = p;
if (n in r.normal)
return r.property[r.normal[n]];
if (n.length > 4 && n.slice(0, 4) === "data" && d.test(t)) {
if (t.charAt(4) === "-") {
const e = t.slice(5).replace(s, h);
i = "data" + e.charAt(0).toUpperCase() + e.slice(1);
} else {
const e = t.slice(4);
if (!s.test(e)) {
let o = e.replace(l, m);
o.charAt(0) !== "-" && (o = "-" + o), t = "data" + o;
}
}
c = a;
}
return new c(i, t);
}
function m(r) {
return "-" + r.toLowerCase();
}
function h(r) {
return r.charAt(1).toUpperCase();
}
export {
y as find
};