@anoki/fse-ui
Version:
FSE UI components library
85 lines (84 loc) • 2.01 kB
JavaScript
import { j as o } from "./index.es278.js";
import './components/ui/Avatars/avatars.css';/* empty css */
import { Tooltip as h } from "./index.es263.js";
import { Col as d } from "./index.es82.js";
const l = [
"#007bff",
// blue
"#28a745",
// green
"#dc3545",
// red
"#17a2b8",
// teal
"#6f42c1",
// purple
"#fd7e14",
// orange
"#20c997"
// emerald
];
function f(e) {
let r = 0;
for (let t = 0; t < e.length; t++)
r = e.charCodeAt(t) + ((r << 5) - r);
return l[Math.abs(r) % l.length];
}
const C = ({
users: e,
maxVisible: r = 5,
size: t = 32
}) => {
const i = e.slice(0, r), s = e.length - i.length;
return /* @__PURE__ */ o.jsx(
h,
{
position: "bottom",
label: /* @__PURE__ */ o.jsx(d, { gap: "x24", children: i.map((a) => /* @__PURE__ */ o.jsxs("p", { className: "text-primary", children: [
a.firstName,
" ",
a.lastName
] }, a.fiscalCode)) }),
children: /* @__PURE__ */ o.jsxs("div", { className: "avatars-group", children: [
i.map((a, n) => {
const c = f(a.firstName), m = a.firstName.charAt(0).toUpperCase();
return /* @__PURE__ */ o.jsx(
"div",
{
className: "avatar",
style: {
width: t,
height: t,
marginLeft: n === 0 ? 0 : -t / 4,
backgroundColor: c,
fontSize: t * 0.45
},
children: m
},
a.fiscalCode
);
}),
s > 0 && /* @__PURE__ */ o.jsxs(
"div",
{
className: "avatar avatar-extra",
style: {
width: t,
height: t,
marginLeft: -t / 4,
fontSize: t * 0.45
},
children: [
"+",
s
]
}
)
] })
}
);
};
export {
C as Avatars
};
//# sourceMappingURL=index.es30.js.map