geoiq-frontend-ui-kit
Version:
This project is a UI kit for GeoIQ's frontend. It's built with React, TypeScript, and Vite.
73 lines (72 loc) • 2.43 kB
JavaScript
import * as e from "react";
import { useRef as f, useCallback as y, useEffect as N } from "react";
import { Spinner as h } from "./index.es56.js";
import { SheetPrimary as b } from "./index.es38.js";
import x from "./index.es148.js";
import g from "./index.es149.js";
const P = ({
isOpen: i,
onOpenChange: u,
containerId: d,
notifications: n,
nextPage: s,
isLoading: c,
hasMore: a,
onReachScrollTop: m
}) => {
const o = f(), l = f(null), p = y(
(t) => {
c || (o.current && o.current.disconnect(), o.current = new IntersectionObserver((r) => {
r[0].isIntersecting && a && s();
}), t && o.current.observe(t));
},
[c, s, a]
);
N(() => {
const t = () => {
if (!l.current) return;
const { scrollTop: v } = l.current;
v === 0 && m();
}, r = l.current;
return r && r.addEventListener("scroll", t), () => {
r && r.removeEventListener("scroll", t);
};
}, [m, l.current]);
const E = () => c ? /* @__PURE__ */ e.createElement("div", { className: "flex justify-center py-4" }, /* @__PURE__ */ e.createElement(h, { className: "stroke-brand" })) : null;
return /* @__PURE__ */ e.createElement(
b,
{
open: i,
onOpenChange: u,
trigger: null,
contentProps: {
className: "bg-light-1 md:!left-[66px] pb-12 inset-y-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
side: "custom"
},
bodyProps: {
className: "p-0 h-full"
},
title: "Notifications",
content: n.length || c ? /* @__PURE__ */ e.createElement("div", { className: "flex flex-col h-full min-h-0 left-60" }, n.length !== 0 && /* @__PURE__ */ e.createElement(
"div",
{
ref: l,
className: "flex flex-col flex-grow min-h-0 overflow-y-auto"
},
n?.map((t, r) => /* @__PURE__ */ e.createElement(
"div",
{
key: t.id,
ref: r === n.length - 1 ? p : void 0
},
/* @__PURE__ */ e.createElement(x, { ...t })
))
), E()) : /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center h-full" }, /* @__PURE__ */ e.createElement(g, null)),
container: typeof document < "u" ? document.getElementById(d || "") : void 0
}
);
};
export {
P as default
};
//# sourceMappingURL=index.es66.js.map