@adyen/adyen-platform-experience-web
Version:

98 lines (97 loc) • 3.15 kB
JavaScript
import { jsx as e } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useMemo as S, useCallback as T } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { ButtonVariant as m } from "../Button/types.js";
/* empty css */
import C from "../../../core/Context/preact/useCoreContext.js";
import { Translation as N } from "../Translation/Translation.js";
import x from "../FormFields/Select/Select.js";
import d from "../Button/Button.js";
import { Icon as p } from "../Icon/Icon.js";
import { isNullish as A } from "../../../utils/value/is.js";
import { EMPTY_ARRAY as f } from "../../../utils/value/constants.js";
const a = "adyen-pe-pagination", i = {
base: a,
context: a + "__context",
controls: a + "__controls",
limit: a + "__limit",
limitSelector: a + "__limit-selector"
};
function q({
next: u,
hasNext: r,
hasPrev: c,
prev: g,
limit: b,
limitOptions: l,
onLimitSelection: n,
ariaLabelKey: h,
limitSelectAriaLabelKey: _
}) {
const { i18n: t } = C(), s = S(
() => l && Object.freeze(
l.map(
(o) => ({
name: o.toLocaleString(t.locale, { style: "decimal" }),
id: String(o)
})
)
),
[t, l]
), v = T(
({ target: o }) => {
A(o?.value) || n?.(+o.value);
},
[n]
);
return /* @__PURE__ */ e("div", { role: "group", "aria-label": t.get(h ?? "common.pagination.label"), className: i.base, children: [
/* @__PURE__ */ e("div", { className: i.context, children: s && n && /* @__PURE__ */ e("div", { className: i.limit, role: "presentation", children: /* @__PURE__ */ e(
N,
{
translationKey: "common.pagination.controls.limitSelect",
fills: {
pageLimit: /* @__PURE__ */ e("div", { className: i.limitSelector, children: /* @__PURE__ */ e(
x,
{
setToTargetWidth: !0,
filterable: !1,
multiSelect: !1,
items: s,
onChange: v,
selected: `${b ?? ""}`,
"aria-label": t.get(_ ?? "common.pagination.controls.limitSelect.label")
}
) })
}
}
) }) }),
/* @__PURE__ */ e("div", { className: i.controls, children: [
/* @__PURE__ */ e(
d,
{
variant: m.TERTIARY,
disabled: !c,
iconButton: !0,
"aria-label": t.get("common.pagination.controls.previousPage.label"),
classNameModifiers: ["circle"].concat(c ? f : "disabled"),
onClick: g,
children: /* @__PURE__ */ e(p, { name: "chevron-left" })
}
),
/* @__PURE__ */ e(
d,
{
variant: m.TERTIARY,
disabled: !r,
iconButton: !0,
"aria-label": t.get("common.pagination.controls.nextPage.label"),
classNameModifiers: ["circle"].concat(r ? f : "disabled"),
onClick: u,
children: /* @__PURE__ */ e(p, { name: "chevron-right" })
}
)
] })
] });
}
export {
q as default
};