UNPKG

@wordpress/block-editor

Version:
133 lines (131 loc) 5.7 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; 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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/block-editor/src/components/block-patterns-paging/index.js var block_patterns_paging_exports = {}; __export(block_patterns_paging_exports, { default: () => Pagination }); module.exports = __toCommonJS(block_patterns_paging_exports); var import_components = require("@wordpress/components"); var import_i18n = require("@wordpress/i18n"); var import_jsx_runtime = require("react/jsx-runtime"); function Pagination({ currentPage, numPages, changePage, totalItems }) { return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { className: "block-editor-patterns__grid-pagination-wrapper", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { variant: "muted", children: (0, import_i18n.sprintf)( // translators: %s: Total number of patterns. (0, import_i18n._n)("%s item", "%s items", totalItems), totalItems ) }), numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( import_components.__experimentalHStack, { expanded: false, spacing: 3, justify: "flex-start", className: "block-editor-patterns__grid-pagination", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( import_components.__experimentalHStack, { expanded: false, spacing: 1, className: "block-editor-patterns__grid-pagination-previous", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.Button, { variant: "tertiary", onClick: () => changePage(1), disabled: currentPage === 1, "aria-label": (0, import_i18n.__)("First page"), size: "compact", accessibleWhenDisabled: true, className: "block-editor-patterns__grid-pagination-button", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xAB" }) } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.Button, { variant: "tertiary", onClick: () => changePage(currentPage - 1), disabled: currentPage === 1, "aria-label": (0, import_i18n.__)("Previous page"), size: "compact", accessibleWhenDisabled: true, className: "block-editor-patterns__grid-pagination-button", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2039" }) } ) ] } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { variant: "muted", children: (0, import_i18n.sprintf)( // translators: 1: Current page number. 2: Total number of pages. (0, import_i18n._x)("%1$s of %2$s", "paging"), currentPage, numPages ) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( import_components.__experimentalHStack, { expanded: false, spacing: 1, className: "block-editor-patterns__grid-pagination-next", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.Button, { variant: "tertiary", onClick: () => changePage(currentPage + 1), disabled: currentPage === numPages, "aria-label": (0, import_i18n.__)("Next page"), size: "compact", accessibleWhenDisabled: true, className: "block-editor-patterns__grid-pagination-button", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u203A" }) } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_components.Button, { variant: "tertiary", onClick: () => changePage(numPages), disabled: currentPage === numPages, "aria-label": (0, import_i18n.__)("Last page"), size: "compact", accessibleWhenDisabled: true, className: "block-editor-patterns__grid-pagination-button", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xBB" }) } ) ] } ) ] } ) ] }); } //# sourceMappingURL=index.js.map