UNPKG

@helpwave/hightide

Version:

helpwave's component and theming library

102 lines (96 loc) 5.14 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/components/Pagination.tsx var Pagination_exports = {}; __export(Pagination_exports, { Pagination: () => Pagination }); module.exports = __toCommonJS(Pagination_exports); var import_lucide_react = require("lucide-react"); var import_clsx = __toESM(require("clsx")); // src/hooks/useLanguage.tsx var import_react2 = require("react"); // src/hooks/useLocalStorage.tsx var import_react = require("react"); // src/hooks/useLanguage.tsx var import_jsx_runtime = require("react/jsx-runtime"); var DEFAULT_LANGUAGE = "en"; var LanguageContext = (0, import_react2.createContext)({ language: DEFAULT_LANGUAGE, setLanguage: (v) => v }); var useLanguage = () => (0, import_react2.useContext)(LanguageContext); // src/hooks/useTranslation.ts var useTranslation = (defaults, translationOverwrite = {}) => { const { language: languageProp, translation: overwrite } = translationOverwrite; const { language: inferredLanguage } = useLanguage(); const usedLanguage = languageProp ?? inferredLanguage; let defaultValues = defaults[usedLanguage]; if (overwrite && overwrite[usedLanguage]) { defaultValues = { ...defaultValues, ...overwrite[usedLanguage] }; } return defaultValues; }; // src/components/Pagination.tsx var import_jsx_runtime2 = require("react/jsx-runtime"); var defaultPaginationTranslations = { en: { of: "of" }, de: { of: "von" } }; var Pagination = ({ overwriteTranslation, page, numberOfPages, onPageChanged }) => { const translation = useTranslation(defaultPaginationTranslations, overwriteTranslation); const changePage = (page2) => { onPageChanged(page2); }; const noPages = numberOfPages === 0; const onFirstPage = page === 0 && !noPages; const onLastPage = page === numberOfPages - 1; return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: (0, import_clsx.default)("row", { "opacity-30": noPages }), children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => changePage(0), disabled: onFirstPage, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronFirst, { className: (0, import_clsx.default)({ "opacity-30": onFirstPage }) }) }), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => changePage(page - 1), disabled: onFirstPage, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronLeft, { className: (0, import_clsx.default)({ "opacity-30": onFirstPage }) }) }), /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "min-w-[80px] justify-center mx-2", children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "select-none text-right flex-1", children: noPages ? 0 : page + 1 }), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "select-none mx-2", children: translation.of }), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "select-none text-left flex-1", children: numberOfPages }) ] }), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => changePage(page + 1), disabled: onLastPage || noPages, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronRight, { className: (0, import_clsx.default)({ "opacity-30": onLastPage }) }) }), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => changePage(numberOfPages - 1), disabled: onLastPage || noPages, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronLast, { className: (0, import_clsx.default)({ "opacity-30": onLastPage }) }) }) ] }); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Pagination }); //# sourceMappingURL=Pagination.js.map