@devgateway/dvz-ui-react
Version:
A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.
73 lines (72 loc) • 2.23 kB
JavaScript
import { jsxs as i, jsx as r } from "react/jsx-runtime";
import I, { useState as g, useEffect as u } from "react";
import { useDispatch as x, useSelector as m } from "react-redux";
import { Container as y, Dropdown as b, Icon as p } from "semantic-ui-react";
import { injectIntl as j } from "react-intl";
const k = (f) => {
const {
"data-group": c
} = f, h = x(), n = m((e) => e.getIn(["data", "postsPagination", c])), t = m((e) => e.getIn(["data", "posts", c])), s = n && (n != null && n.totalPages) ? n.totalPages : 1, [o, d] = g((t == null ? void 0 : t.page) ?? 1), [P, v] = g([]), C = () => {
const e = [];
for (let a = 1; a <= s; a++)
e.push({ key: a, text: a, value: a });
v(e);
}, l = (e) => {
e !== o && (e < 1 || e > s || (d(e), h({
type: "SET_POSTS_FILTER",
group: c,
...t,
page: e
})));
};
return u(() => {
C();
}, [n == null ? void 0 : n.totalPages]), u(() => {
const e = (t == null ? void 0 : t.page) ?? 1;
e !== o && d(e);
}, [t == null ? void 0 : t.page]), /* @__PURE__ */ i(y, { fluid: !0, className: "posts-pagination", children: [
/* @__PURE__ */ i("div", { className: "posts-pagination-dropdown", children: [
/* @__PURE__ */ r("span", { children: "Page" }),
/* @__PURE__ */ r(
b,
{
options: P,
placeholder: "Select Item",
selection: !0,
compact: !0,
value: o,
onChange: (e, a) => l(Number(a.value))
}
),
/* @__PURE__ */ r("div", { children: /* @__PURE__ */ i("span", { children: [
"of ",
n && (n == null ? void 0 : n.totalPages)
] }) })
] }),
/* @__PURE__ */ i("div", { children: [
/* @__PURE__ */ r(
p,
{
size: "large",
style: { cursor: "pointer" },
onClick: () => l(o - 1),
name: "angle left",
disabled: o === 1
}
),
/* @__PURE__ */ r(
p,
{
size: "large",
style: { cursor: "pointer" },
onClick: () => l(o + 1),
name: "angle right",
disabled: o === s
}
)
] })
] });
}, z = j(I.memo(k));
export {
z as default
};