@redvars/peacock 3.15.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sources":["../../src/pagination/pagination.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport type { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport styles from './pagination.scss';\nimport IndividualComponent from '@/IndividualComponent.js';\n\nconst DEFAULT_PAGE_SIZES = [10, 25, 50, 100];\n\n/**\n * @label Pagination\n * @tag wc-pagination\n * @rawTag pagination\n * @summary A pagination control with page size selector, item count display, and previous/next navigation.\n * @overview\n * <p>The pagination component provides controls for navigating through paged data sets.</p>\n *\n * @fires {CustomEvent} page - Dispatched when the page or page size changes. Detail: `{ page, pageSize }`.\n *\n * @example\n * ```html\n * <wc-pagination style=\"width: 100%;\" page=\"1\" page-size=\"10\" total-items=\"100\"></wc-pagination>\n * ```\n * @tags navigation, data\n */\n@IndividualComponent\nexport class Pagination extends LitElement {\n static styles = [styles];\n\n /**\n * The current page number (1-based). Defaults to `1`.\n */\n @property({ type: Number })\n page: number = 1;\n\n /**\n * The number of rows per page. Defaults to `10`.\n */\n @property({ type: Number, attribute: 'page-size' })\n pageSize: number = 10;\n\n /**\n * Total number of items.\n */\n @property({ type: Number, attribute: 'total-items' })\n totalItems: number = 0;\n\n /**\n * Supported page size options.\n */\n @property({ type: Array, attribute: 'page-sizes' })\n pageSizes: number[] = DEFAULT_PAGE_SIZES;\n\n protected override willUpdate(\n changedProperties: PropertyValues<Pagination>,\n ): void {\n // Normalize page-size options so the select always has valid numeric values.\n const normalizedPageSizes = [...new Set(\n this.pageSizes\n .map(size => Number(size))\n .filter(size => Number.isFinite(size) && size > 0)\n .map(size => Math.trunc(size)),\n )];\n\n if (!normalizedPageSizes.length) {\n normalizedPageSizes.push(...DEFAULT_PAGE_SIZES);\n }\n\n if (\n changedProperties.has('pageSizes') &&\n (this.pageSizes.length !== normalizedPageSizes.length ||\n this.pageSizes.some((size, index) => size !== normalizedPageSizes[index]))\n ) {\n this.pageSizes = normalizedPageSizes;\n }\n\n if (!this.pageSizes.includes(this.pageSize)) {\n this.pageSize = this.pageSizes[0] ?? DEFAULT_PAGE_SIZES[0];\n }\n\n if (!Number.isFinite(this.totalItems) || this.totalItems < 0) {\n this.totalItems = 0;\n }\n\n if (!Number.isFinite(this.page) || this.page < 1) {\n this.page = 1;\n }\n\n const maxPage = this.getTotalPages();\n if (this.page > maxPage) {\n this.page = maxPage;\n }\n }\n\n private getTotalPages(): number {\n if (this.totalItems <= 0) return 1;\n return Math.max(1, Math.ceil(this.totalItems / this.pageSize));\n }\n\n private setPage(nextPage: number) {\n const clampedPage = Math.min(Math.max(1, nextPage), this.getTotalPages());\n if (clampedPage === this.page) return;\n this.page = clampedPage;\n this.dispatchPageEvent();\n }\n\n private handlePageSizeChange(event: CustomEvent<{ value?: string }>) {\n const rawValue = event.detail?.value;\n const parsedPageSize = Number.parseInt(rawValue ?? '', 10);\n\n if (!Number.isFinite(parsedPageSize) || parsedPageSize <= 0) {\n return;\n }\n\n this.pageSize = parsedPageSize;\n this.page = 1;\n this.dispatchPageEvent();\n }\n\n private handlePreviousPage = () => {\n this.setPage(this.page - 1);\n };\n\n private handleNextPage = () => {\n this.setPage(this.page + 1);\n };\n\n private dispatchPageEvent() {\n this.dispatchEvent(\n new CustomEvent('page', {\n detail: { page: this.page, pageSize: this.pageSize },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n render() {\n const startItem = this.totalItems === 0 ? 0 : this.pageSize * (this.page - 1) + 1;\n const endItem = Math.min(this.pageSize * this.page, this.totalItems);\n const isFirstPage = this.page === 1;\n const isLastPage = this.pageSize * this.page >= this.totalItems;\n\n return html`\n <div class=\"pagination\">\n <div class=\"page-size\">\n <span class=\"page-size-label\">Items per page:</span>\n <wc-select\n class=\"page-size-select\"\n .value=${String(this.pageSize)}\n aria-label=\"Items per page\"\n @change=${this.handlePageSizeChange}\n >\n ${this.pageSizes.map(\n size => html`<wc-option value=${String(size)}>${size}</wc-option>`,\n )}\n </wc-select>\n </div>\n\n <div class=\"pagination-item-count\">\n <span class=\"pagination-text\">\n ${startItem} - ${endItem} of ${this.totalItems}\n </span>\n </div>\n\n <div class=\"pagination-actions\">\n <wc-icon-button\n class=\"nav-button\"\n color=\"secondary\"\n variant=\"text\"\n size=\"sm\"\n title=\"Previous page\"\n ?disabled=${isFirstPage}\n @click=${this.handlePreviousPage}\n >\n <wc-icon name=\"keyboard_arrow_left\"></wc-icon>\n </wc-icon-button>\n <wc-icon-button\n class=\"nav-button\"\n color=\"secondary\"\n variant=\"text\"\n size=\"sm\"\n title=\"Next page\"\n ?disabled=${isLastPage}\n @click=${this.handleNextPage}\n >\n <wc-icon name=\"keyboard_arrow_right\"></wc-icon>\n </wc-icon-button>\n </div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","styles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;AAE5C;;;;;;;;;;;;;;;AAeG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQA,GAAU,CAAA;AAAnC,IAAA,WAAA,GAAA;;AAGL;;AAEG;QAEH,IAAA,CAAA,IAAI,GAAW,CAAC;AAEhB;;AAEG;QAEH,IAAA,CAAA,QAAQ,GAAW,EAAE;AAErB;;AAEG;QAEH,IAAA,CAAA,UAAU,GAAW,CAAC;AAEtB;;AAEG;QAEH,IAAA,CAAA,SAAS,GAAa,kBAAkB;QAoEhC,IAAA,CAAA,kBAAkB,GAAG,MAAK;YAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;AAC7B,QAAA,CAAC;QAEO,IA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AW;AACd,mBAAA,EAAA,IAAI,CAAC,kBAAkB;;;;;;;;;;wBAUpB,UAAU;AACb,mBAAA,EAAA,IAAI,CAAC,cAAc;;;;;;KAMnC;IACH;;AApKO,UAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAMxB,UAAA,CAAA;AADC,IAAAC,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACT,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAMjB,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE;AAC5B,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAMtB,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE;AAC7B,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AAMvB,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE;AACT,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAzB9B,UAAU,GAAA,UAAA,CAAA;IADtB;AACY,CAAA,EAAA,UAAU,CAsKtB;;;;"}
1
+ {"version":3,"file":"pagination.js","sources":["../../src/pagination/page-items.ts","../../src/pagination/pagination.ts"],"sourcesContent":["/** A slot in the page list: a page number, or a gap shown as an ellipsis. */\nexport type PageItem = number | 'ellipsis';\n\nfunction range(from: number, to: number): number[] {\n return Array.from({ length: to - from + 1 }, (_, index) => from + index);\n}\n\n/**\n * Builds the page list shown by the `full` pagination variant.\n *\n * The list always keeps the first and last page, the current page and `siblings` pages on each\n * side of it, and fills the rest with an ellipsis. It never holds more than\n * `2 * siblings + 5` slots, so the control keeps its width while the user moves through pages.\n *\n * @example\n * getPageItems(5, 24); // [1, 'ellipsis', 4, 5, 6, 'ellipsis', 24]\n * getPageItems(2, 24); // [1, 2, 3, 4, 5, 'ellipsis', 24]\n */\nexport function getPageItems(\n current: number,\n total: number,\n siblings: number = 1,\n): PageItem[] {\n const totalPages = Math.max(1, Math.trunc(total));\n const page = Math.min(Math.max(1, Math.trunc(current)), totalPages);\n const maxSlots = 2 * siblings + 5;\n\n if (totalPages <= maxSlots) {\n return range(1, totalPages);\n }\n\n const start = Math.max(page - siblings, 1);\n const end = Math.min(page + siblings, totalPages);\n // A gap of one page is shown as that page; only a gap of two or more becomes an ellipsis.\n const showStartGap = start > 3;\n const showEndGap = end < totalPages - 2;\n // Pages shown on the side without a gap: the window, the edge page and the slot the\n // ellipsis would have taken.\n const edgeCount = 2 * siblings + 3;\n\n if (!showStartGap && showEndGap) {\n return [...range(1, edgeCount), 'ellipsis', totalPages];\n }\n\n if (showStartGap && !showEndGap) {\n return [1, 'ellipsis', ...range(totalPages - edgeCount + 1, totalPages)];\n }\n\n return [1, 'ellipsis', ...range(start, end), 'ellipsis', totalPages];\n}\n","import { html, LitElement, nothing } from 'lit';\nimport type { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport styles from './pagination.scss';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport { getPageItems } from './page-items.js';\n\nconst DEFAULT_PAGE_SIZES = [10, 25, 50, 100];\n\nexport type PaginationVariant = 'full' | 'compact' | 'simple';\n\n/**\n * @label Pagination\n * @tag wc-pagination\n * @rawTag pagination\n * @summary A pagination control with page numbers, a rows-per-page selector and the current item range.\n * @overview\n * <p>The pagination component moves through paged data. It shows the current item range, the pages and a rows-per-page selector.</p>\n * <p>Three variants cover different data sets: <code>full</code> lists page numbers with ellipses, <code>compact</code> shows \"Page [n] of N\" with a field to jump to a page, and <code>simple</code> shows previous and next only. When <code>total-items</code> is not set, the total is unknown (cursor-based APIs): the control shows previous and next, and <code>has-next</code> says whether another page exists.</p>\n * <p>On a narrow container the <code>full</code> variant collapses to <code>compact</code>.</p>\n *\n * @fires {CustomEvent} page - Dispatched when the page or page size changes. Detail: `{ page, pageSize }`.\n *\n * @cssprop --pagination-background - Background of the control. Defaults to the surface color.\n *\n * @example\n * ```html\n * <wc-pagination style=\"width: 100%;\" page=\"1\" page-size=\"10\" total-items=\"240\"></wc-pagination>\n * ```\n * @tags navigation, data\n */\n@IndividualComponent\nexport class Pagination extends LitElement {\n // ── Static ───────────────────────────────────────────────────────────────\n\n static styles = [styles];\n\n // ── Properties ───────────────────────────────────────────────────────────\n\n /**\n * The current page number (1-based). Defaults to `1`.\n */\n @property({ type: Number })\n page: number = 1;\n\n /**\n * The number of rows per page. Defaults to `10`.\n */\n @property({ type: Number, attribute: 'page-size' })\n pageSize: number = 10;\n\n /**\n * Total number of items. Leave it unset when the total is unknown; the control then shows\n * previous and next only, and `has-next` decides whether next is enabled.\n */\n @property({ type: Number, attribute: 'total-items' })\n totalItems: number | undefined;\n\n /**\n * Supported page size options.\n */\n @property({ type: Array, attribute: 'page-sizes' })\n pageSizes: number[] = DEFAULT_PAGE_SIZES;\n\n /**\n * How the pages are shown: `full` (page numbers), `compact` (\"Page [n] of N\") or `simple`\n * (previous and next only). Defaults to `full`.\n */\n @property({ type: String, reflect: true })\n variant: PaginationVariant = 'full';\n\n /**\n * Whether another page exists after this one. Used only when `total-items` is unset.\n */\n @property({ type: Boolean, attribute: 'has-next' })\n hasNext: boolean = false;\n\n /**\n * Shows buttons that jump to the first and the last page.\n */\n @property({ type: Boolean, attribute: 'show-first-last' })\n showFirstLast: boolean = false;\n\n /**\n * Hides the rows-per-page selector.\n */\n @property({ type: Boolean, attribute: 'hide-page-size' })\n hidePageSize: boolean = false;\n\n /**\n * Accessible name of the navigation landmark. Defaults to `\"Pagination\"`.\n */\n @property({ type: String })\n label: string = 'Pagination';\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n protected override willUpdate(\n changedProperties: PropertyValues<Pagination>,\n ): void {\n // Normalize page-size options so the select always has valid numeric values.\n const normalizedPageSizes = [\n ...new Set(\n this.pageSizes\n .map(size => Number(size))\n .filter(size => Number.isFinite(size) && size > 0)\n .map(size => Math.trunc(size)),\n ),\n ];\n\n if (!normalizedPageSizes.length) {\n normalizedPageSizes.push(...DEFAULT_PAGE_SIZES);\n }\n\n if (\n changedProperties.has('pageSizes') &&\n (this.pageSizes.length !== normalizedPageSizes.length ||\n this.pageSizes.some(\n (size, index) => size !== normalizedPageSizes[index],\n ))\n ) {\n this.pageSizes = normalizedPageSizes;\n }\n\n if (!this.pageSizes.includes(this.pageSize)) {\n this.pageSize = this.pageSizes[0] ?? DEFAULT_PAGE_SIZES[0];\n }\n\n if (\n this.totalItems !== undefined &&\n this.totalItems !== null &&\n (!Number.isFinite(this.totalItems) || this.totalItems < 0)\n ) {\n this.totalItems = 0;\n }\n\n if (!Number.isFinite(this.page) || this.page < 1) {\n this.page = 1;\n }\n\n const totalPages = this.getTotalPages();\n if (totalPages !== undefined && this.page > totalPages) {\n this.page = totalPages;\n }\n }\n\n // ── Private methods ──────────────────────────────────────────────────────\n\n /** True when the total is known. */\n private get hasTotal(): boolean {\n return this.totalItems !== undefined && this.totalItems !== null;\n }\n\n /** The number of pages, or `undefined` when the total is unknown. */\n private getTotalPages(): number | undefined {\n if (!this.hasTotal) return undefined;\n const total = this.totalItems ?? 0;\n if (total <= 0) return 1;\n return Math.max(1, Math.ceil(total / this.pageSize));\n }\n\n private get isFirstPage(): boolean {\n return this.page <= 1;\n }\n\n private get isLastPage(): boolean {\n const totalPages = this.getTotalPages();\n return totalPages === undefined ? !this.hasNext : this.page >= totalPages;\n }\n\n /** The variant actually rendered: an unknown total can only go previous and next. */\n private get effectiveVariant(): PaginationVariant {\n return this.hasTotal ? this.variant : 'simple';\n }\n\n private getRangeText(): string {\n const total = this.totalItems ?? 0;\n if (this.hasTotal && total === 0) return '0 of 0';\n const start = this.pageSize * (this.page - 1) + 1;\n if (!this.hasTotal) return `${start}–${this.pageSize * this.page}`;\n const end = Math.min(this.pageSize * this.page, total);\n return `${start}–${end} of ${total}`;\n }\n\n private setPage(nextPage: number) {\n const totalPages = this.getTotalPages() ?? Number.MAX_SAFE_INTEGER;\n const lastAllowed =\n this.hasTotal || this.hasNext ? totalPages : Math.max(1, this.page);\n const clampedPage = Math.min(\n Math.max(1, Math.trunc(nextPage)),\n lastAllowed,\n );\n if (!Number.isFinite(clampedPage) || clampedPage === this.page) return;\n this.page = clampedPage;\n this.dispatchPageEvent();\n }\n\n private handlePageSizeChange(event: CustomEvent<{ value?: string }>) {\n const rawValue = event.detail?.value;\n const parsedPageSize = Number.parseInt(rawValue ?? '', 10);\n\n if (!Number.isFinite(parsedPageSize) || parsedPageSize <= 0) {\n return;\n }\n if (parsedPageSize === this.pageSize) return;\n\n // Keep the first visible item on screen instead of jumping back to page 1.\n const firstItemIndex = this.pageSize * (this.page - 1);\n this.pageSize = parsedPageSize;\n this.page = Math.floor(firstItemIndex / parsedPageSize) + 1;\n this.dispatchPageEvent();\n }\n\n private handlePageInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n const value = Number.parseInt(input.value, 10);\n if (Number.isFinite(value)) {\n this.setPage(value);\n }\n // Show the page actually used, for example after clamping 99 to the last page.\n input.value = String(this.page);\n };\n\n private handlePageInputKeydown = (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n this.handlePageInput(event);\n }\n };\n\n private dispatchPageEvent() {\n this.dispatchEvent(\n new CustomEvent('page', {\n detail: { page: this.page, pageSize: this.pageSize },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n // ── Render helpers ───────────────────────────────────────────────────────\n\n private renderNavButton(\n icon: string,\n label: string,\n disabled: boolean,\n target: () => number,\n className: string,\n ) {\n return html`\n <wc-icon-button\n class=\"nav-button ${className}\"\n color=\"secondary\"\n variant=\"text\"\n size=\"sm\"\n aria-label=${label}\n title=${label}\n ?disabled=${disabled}\n @click=${() => this.setPage(target())}\n >\n <wc-icon name=${icon}></wc-icon>\n </wc-icon-button>\n `;\n }\n\n private renderPageList(totalPages: number) {\n return html`\n <ol class=\"page-list\">\n ${getPageItems(this.page, totalPages).map(item =>\n item === 'ellipsis'\n ? html`<li class=\"page-ellipsis\" aria-hidden=\"true\">…</li>`\n : html`\n <li>\n <button\n type=\"button\"\n class=${classMap({\n 'page-button': true,\n current: item === this.page,\n })}\n aria-label=\"Page ${item}\"\n aria-current=${item === this.page ? 'page' : nothing}\n @click=${() => this.setPage(item)}\n >\n ${item}\n </button>\n </li>\n `,\n )}\n </ol>\n `;\n }\n\n private renderPageJump(totalPages: number) {\n return html`\n <div class=\"page-jump\">\n <span>Page</span>\n <input\n class=\"page-input\"\n type=\"number\"\n inputmode=\"numeric\"\n min=\"1\"\n max=${totalPages}\n .value=${String(this.page)}\n aria-label=\"Page number, ${totalPages} pages\"\n @change=${this.handlePageInput}\n @keydown=${this.handlePageInputKeydown}\n />\n <span>of ${totalPages}</span>\n </div>\n `;\n }\n\n private renderPageSize() {\n if (this.hidePageSize) return nothing;\n return html`\n <div class=\"page-size\">\n <span class=\"page-size-label\" aria-hidden=\"true\">Rows per page</span>\n <wc-select\n class=\"page-size-select\"\n .value=${String(this.pageSize)}\n aria-label=\"Rows per page\"\n @change=${this.handlePageSizeChange}\n >\n ${this.pageSizes.map(\n size => html`<wc-option value=${String(size)}>${size}</wc-option>`,\n )}\n </wc-select>\n </div>\n `;\n }\n\n // ── Render ───────────────────────────────────────────────────────────────\n\n render() {\n const variant = this.effectiveVariant;\n const totalPages = this.getTotalPages() ?? 1;\n const rangeText = this.getRangeText();\n const showFirstLast = this.showFirstLast && this.hasTotal;\n\n return html`\n <nav\n class=${classMap({ pagination: true, [`variant-${variant}`]: true })}\n aria-label=${this.label}\n >\n <div class=\"range\" aria-hidden=\"true\">${rangeText}</div>\n <span class=\"visually-hidden\" aria-live=\"polite\">\n Showing ${rangeText}\n </span>\n\n ${this.renderPageSize()}\n\n <div class=\"controls\">\n ${showFirstLast\n ? this.renderNavButton(\n 'first_page',\n 'First page',\n this.isFirstPage,\n () => 1,\n 'first',\n )\n : nothing}\n ${this.renderNavButton(\n 'chevron_left',\n 'Previous page',\n this.isFirstPage,\n () => this.page - 1,\n 'previous',\n )}\n ${variant === 'full' ? this.renderPageList(totalPages) : nothing}\n ${variant === 'full' || variant === 'compact'\n ? this.renderPageJump(totalPages)\n : nothing}\n ${this.renderNavButton(\n 'chevron_right',\n 'Next page',\n this.isLastPage,\n () => this.page + 1,\n 'next',\n )}\n ${showFirstLast\n ? this.renderNavButton(\n 'last_page',\n 'Last page',\n this.isLastPage,\n () => totalPages,\n 'last',\n )\n : nothing}\n </div>\n </nav>\n `;\n }\n}\n"],"names":["LitElement","html","classMap","nothing","styles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,KAAK,CAAC,IAAY,EAAE,EAAU,EAAA;IACrC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC;AAC1E;AAEA;;;;;;;;;;AAUG;AACG,SAAU,YAAY,CAC1B,OAAe,EACf,KAAa,EACb,WAAmB,CAAC,EAAA;AAEpB,IAAA,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,C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is';
3
+ /**
4
+ * Builds the page list shown by the `full` pagination variant.
5
+ *
6
+ * The list always keeps the first and last page, the current page and `siblings` pages on each
7
+ * side of it, and fills the rest with an ellipsis. It never holds more than
8
+ * `2 * siblings + 5` slots, so the control keeps its width while the user moves through pages.
9
+ *
10
+ * @example
11
+ * getPageItems(5, 24); // [1, 'ellipsis', 4, 5, 6, 'ellipsis', 24]
12
+ * getPageItems(2, 24); // [1, 2, 3, 4, 5, 'ellipsis', 24]
13
+ */
14
+ export declare function getPageItems(current: number, total: number, siblings?: number): PageItem[];
@@ -1,18 +1,23 @@
1
1
  import { LitElement } from 'lit';
2
2
  import type { PropertyValues } from 'lit';
3
+ export type PaginationVariant = 'full' | 'compact' | 'simple';
3
4
  /**
4
5
  * @label Pagination
5
6
  * @tag wc-pagination
6
7
  * @rawTag pagination
7
- * @summary A pagination control with page size selector, item count display, and previous/next navigation.
8
+ * @summary A pagination control with page numbers, a rows-per-page selector and the current item range.
8
9
  * @overview
9
- * <p>The pagination component provides controls for navigating through paged data sets.</p>
10
+ * <p>The pagination component moves through paged data. It shows the current item range, the pages and a rows-per-page selector.</p>
11
+ * <p>Three variants cover different data sets: <code>full</code> lists page numbers with ellipses, <code>compact</code> shows "Page [n] of N" with a field to jump to a page, and <code>simple</code> shows previous and next only. When <code>total-items</code> is not set, the total is unknown (cursor-based APIs): the control shows previous and next, and <code>has-next</code> says whether another page exists.</p>
12
+ * <p>On a narrow container the <code>full</code> variant collapses to <code>compact</code>.</p>
10
13
  *
11
14
  * @fires {CustomEvent} page - Dispatched when the page or page size changes. Detail: `{ page, pageSize }`.
12
15
  *
16
+ * @cssprop --pagination-background - Background of the control. Defaults to the surface color.
17
+ *
13
18
  * @example
14
19
  * ```html
15
- * <wc-pagination style="width: 100%;" page="1" page-size="10" total-items="100"></wc-pagination>
20
+ * <wc-pagination style="width: 100%;" page="1" page-size="10" total-items="240"></wc-pagination>
16
21
  * ```
17
22
  * @tags navigation, data
18
23
  */
@@ -27,19 +32,53 @@ export declare class Pagination extends LitElement {
27
32
  */
28
33
  pageSize: number;
29
34
  /**
30
- * Total number of items.
35
+ * Total number of items. Leave it unset when the total is unknown; the control then shows
36
+ * previous and next only, and `has-next` decides whether next is enabled.
31
37
  */
32
- totalItems: number;
38
+ totalItems: number | undefined;
33
39
  /**
34
40
  * Supported page size options.
35
41
  */
36
42
  pageSizes: number[];
43
+ /**
44
+ * How the pages are shown: `full` (page numbers), `compact` ("Page [n] of N") or `simple`
45
+ * (previous and next only). Defaults to `full`.
46
+ */
47
+ variant: PaginationVariant;
48
+ /**
49
+ * Whether another page exists after this one. Used only when `total-items` is unset.
50
+ */
51
+ hasNext: boolean;
52
+ /**
53
+ * Shows buttons that jump to the first and the last page.
54
+ */
55
+ showFirstLast: boolean;
56
+ /**
57
+ * Hides the rows-per-page selector.
58
+ */
59
+ hidePageSize: boolean;
60
+ /**
61
+ * Accessible name of the navigation landmark. Defaults to `"Pagination"`.
62
+ */
63
+ label: string;
37
64
  protected willUpdate(changedProperties: PropertyValues<Pagination>): void;
65
+ /** True when the total is known. */
66
+ private get hasTotal();
67
+ /** The number of pages, or `undefined` when the total is unknown. */
38
68
  private getTotalPages;
69
+ private get isFirstPage();
70
+ private get isLastPage();
71
+ /** The variant actually rendered: an unknown total can only go previous and next. */
72
+ private get effectiveVariant();
73
+ private getRangeText;
39
74
  private setPage;
40
75
  private handlePageSizeChange;
41
- private handlePreviousPage;
42
- private handleNextPage;
76
+ private handlePageInput;
77
+ private handlePageInputKeydown;
43
78
  private dispatchPageEvent;
79
+ private renderNavButton;
80
+ private renderPageList;
81
+ private renderPageJump;
82
+ private renderPageSize;
44
83
  render(): import("lit-html").TemplateResult<1>;
45
84
  }
@@ -1,10 +1,33 @@
1
1
  import { LitElement } from 'lit';
2
+ import type { PropertyValues, TemplateResult } from 'lit';
3
+ import type { PaginationVariant } from '../pagination/pagination.js';
4
+ /** A record shown in one row. */
5
+ export type TableRow = Record<string, any>;
2
6
  export interface TableColumn {
7
+ /** Field of the row shown in this column. */
3
8
  name: string;
9
+ /** Header text. */
4
10
  label: string;
11
+ /** Width in rem. Defaults to 16. */
5
12
  width?: number;
6
- fixed?: boolean;
7
- template?: (row: any, column: TableColumn) => string;
13
+ /**
14
+ * Keeps the column in view while the table scrolls sideways. `true` or `"start"` pins it to
15
+ * the start edge, `"end"` to the end edge (for example a row-actions column).
16
+ */
17
+ fixed?: boolean | 'start' | 'end';
18
+ /** Horizontal alignment. Number columns default to `"end"`, others to `"start"`. */
19
+ align?: 'start' | 'center' | 'end';
20
+ /** Data type. `"number"` aligns to the end and uses tabular figures. */
21
+ type?: 'text' | 'number';
22
+ /** Set to `false` to turn sorting off for this column only. */
23
+ sortable?: boolean;
24
+ /** Lets long text wrap instead of truncating with an ellipsis. */
25
+ wrap?: boolean;
26
+ /**
27
+ * Custom cell content. Return a Lit `TemplateResult` (preferred), or a string of trusted
28
+ * HTML. A string is inserted as HTML without escaping, so never build it from user input.
29
+ */
30
+ template?: (row: TableRow, column: TableColumn) => string | TemplateResult;
8
31
  }
9
32
  /**
10
33
  * @label Table
@@ -12,16 +35,25 @@ export interface TableColumn {
12
35
  * @rawTag table
13
36
  * @summary A configurable component for displaying tabular data.
14
37
  * @overview
15
- * <p>The table component displays rows of data with support for sorting, pagination, row selection, and fixed columns.</p>
38
+ * <p>The table displays rows of data with sorting, pagination, row selection, sticky header and sticky start or end columns.</p>
39
+ * <p>It follows the grid keyboard pattern: the table is one tab stop and the arrow keys move between cells. <kbd>Space</kbd> selects the focused row, <kbd>Enter</kbd> activates the focused cell, and <kbd>Ctrl</kbd>+<kbd>C</kbd> copies its text.</p>
40
+ * <p>When rows are selected, a bar over the header shows the count and the actions placed in the <code>bulk-actions</code> slot.</p>
16
41
  *
17
- * @fires {CustomEvent} cell-click - Dispatched when a table cell is clicked.
18
- * @fires {CustomEvent} selection-change - Dispatched when the row selection changes.
19
- * @fires {CustomEvent} sort - Dispatched when the table is sorted.
20
- * @fires {CustomEvent} page - Dispatched when the page or page size changes.
42
+ * @fires {CustomEvent} cell-click - Dispatched when a cell is clicked or activated with Enter. Detail: `{ record, column, altKey, ctrlKey, metaKey, shiftKey }`.
43
+ * @fires {CustomEvent} row-click - Dispatched when a row is clicked or activated with Enter. Detail: `{ record }`.
44
+ * @fires {CustomEvent} selection-change - Dispatched when the row selection changes. Detail: `{ value, isSelectAll, allPages }`.
45
+ * @fires {CustomEvent} sort - Dispatched when the table is sorted. Detail: `{ sortBy, sortOrder }`.
46
+ * @fires {CustomEvent} page - Dispatched when the page or page size changes. Detail: `{ page, pageSize }`.
47
+ *
48
+ * @slot bulk-actions - Actions shown in the selection bar while rows are selected.
49
+ *
50
+ * @cssprop --table-row-height - Minimum height of a row. Set by `density`.
51
+ * @cssprop --table-border-color - Color of the row dividers.
52
+ * @cssprop --table-cell-padding-inline - Horizontal padding of a cell.
21
53
  *
22
54
  * @example
23
55
  * ```html
24
- * <wc-table columns="[{'name': 'name','label': 'Name','width': 16},{'name': 'age','label': 'Age','width': 7}]" data="[{'name': 'John','age': 30},{'name': 'Jane','age': 25}]"></wc-table>
56
+ * <wc-table columns="[{'name': 'name','label': 'Name','width': 16},{'name': 'age','label': 'Age','width': 7,'type': 'number'}]" data="[{'name': 'John','age': 30},{'name': 'Jane','age': 25}]"></wc-table>
25
57
  * ```
26
58
  * @tags display, data
27
59
  */
@@ -29,13 +61,13 @@ export declare class Table extends LitElement {
29
61
  static styles: import("lit").CSSResultGroup[];
30
62
  /**
31
63
  * Grid columns configuration.
32
- * Each column can have: name, label, width (px), fixed (boolean), template (function).
64
+ * Each column can have: name, label, width (rem), fixed, align, type, sortable, wrap, template.
33
65
  */
34
66
  columns: TableColumn[];
35
67
  /**
36
68
  * Grid data to display on table.
37
69
  */
38
- data: any[];
70
+ data: TableRow[];
39
71
  /**
40
72
  * Row selection type. Set to `"checkbox"` to enable checkbox selection.
41
73
  */
@@ -65,7 +97,7 @@ export declare class Table extends LitElement {
65
97
  */
66
98
  sortOrder: 'asc' | 'desc';
67
99
  /**
68
- * If true, pagination is enabled. Defaults to `true`.
100
+ * If true, pagination is enabled. Defaults to `false`.
69
101
  */
70
102
  paginate: boolean;
71
103
  /**
@@ -77,9 +109,39 @@ export declare class Table extends LitElement {
77
109
  */
78
110
  pageSize: number;
79
111
  /**
80
- * Total number of items (used in managed/controlled mode).
112
+ * Supported page size options, passed to the pagination.
113
+ */
114
+ pageSizes: number[] | undefined;
115
+ /**
116
+ * Total number of items (used in managed/controlled mode). Leave it unset when the total is
117
+ * unknown; the pagination then shows previous and next, driven by `has-next`.
81
118
  */
82
119
  totalItems: number | undefined;
120
+ /**
121
+ * Whether another page exists after this one, in managed mode with an unknown total.
122
+ */
123
+ hasNext: boolean;
124
+ /**
125
+ * Pagination variant: `full` (page numbers), `compact` or `simple`. Defaults to `full`.
126
+ */
127
+ paginationVariant: PaginationVariant;
128
+ /**
129
+ * Row height: `compact`, `default` or `comfortable`. Defaults to `default`.
130
+ */
131
+ density: 'compact' | 'default' | 'comfortable';
132
+ /**
133
+ * Shades every other row.
134
+ */
135
+ striped: boolean;
136
+ /**
137
+ * Shows a loading state: skeleton rows while there is no data, otherwise a progress bar
138
+ * under the header so the current rows stay readable.
139
+ */
140
+ loading: boolean;
141
+ /**
142
+ * Accessible name of the table.
143
+ */
144
+ label: string;
83
145
  /**
84
146
  * Headline text shown when the table has no data.
85
147
  */
@@ -88,28 +150,64 @@ export declare class Table extends LitElement {
88
150
  * Description text shown when the table has no data.
89
151
  */
90
152
  emptyStateDescription: string;
91
- /** Tracks the currently hovered row and column for hover-highlight CSS. */
92
- private hoveredCell;
93
- /** True when all rows on the current page are selected. */
94
- private isSelectAll;
95
- /** True when some (but not all) rows on the current page are selected. */
96
- private isSelectAllIntermediate;
97
- /** True when the scroll container has been scrolled horizontally. */
98
- private isHorizontallyScrolled;
99
- /** Throttled version of the cell-mouseover handler to avoid excessive state updates. */
100
- private onCellMouseOverThrottled;
153
+ /** True when every item across all pages is selected, not only the current page. */
154
+ private allPagesSelected;
155
+ /** True when content is scrolled under the start-pinned columns. */
156
+ private scrolledFromStart;
157
+ /** True when more content waits past the end-pinned columns. */
158
+ private scrolledFromEnd;
159
+ /** The cell that holds the grid's single tab stop. Row 0 is the header. */
160
+ private activeCell;
161
+ private scrollContainer?;
162
+ /** Set when a keyboard move must focus the active cell after the next render. */
163
+ private pendingFocus;
164
+ /** Watches the scroll container so the edge shadows follow resizes. */
165
+ private resizeObserver?;
166
+ disconnectedCallback(): void;
167
+ firstUpdated(): void;
168
+ protected willUpdate(changed: PropertyValues<Table>): void;
169
+ protected updated(changed: PropertyValues<Table>): void;
170
+ /** Columns in visual order: checkbox, start-pinned, scrolling, end-pinned. */
171
+ private getGridColumns;
172
+ private static getPlacement;
173
+ private static getAlign;
174
+ private static getWidth;
175
+ private get totalColumnsWidth();
176
+ private isColumnSortable;
177
+ /** Total item count across pages, or `undefined` when it is unknown. */
178
+ private getTotalItems;
179
+ /** Rows shown on the current page, sorted and sliced unless the table is managed. */
180
+ private getPageRows;
181
+ /** Compares numbers by value and everything else as text with natural number order. */
182
+ private static compare;
183
+ private getRowKey;
184
+ private onSortClick;
101
185
  private onSelectAllClick;
102
186
  private onRowSelectClick;
187
+ private selectAllPages;
188
+ private clearSelection;
103
189
  private onSelectChange;
104
190
  private onCellClick;
191
+ private dispatchCellEvents;
192
+ private onPage;
105
193
  private onScrollContainer;
106
- private get totalColumnsWidth();
107
- private getTotalItems;
108
- private getSortIcon;
109
- private onSortClick;
194
+ private updateScrollEdges;
195
+ private getCell;
196
+ /** The element that takes focus for a cell: its sort button, or the cell itself. */
197
+ private getFocusTarget;
198
+ private tabIndexFor;
199
+ private onGridFocusIn;
200
+ private onGridKeydown;
201
+ private renderCellContent;
202
+ private cellClasses;
203
+ private cellStyle;
204
+ /** Splits a row's cells into the start-pinned, scrolling and end-pinned groups. */
205
+ private renderRowGroups;
110
206
  private renderHeader;
111
207
  private renderBody;
208
+ private renderSkeletonBody;
112
209
  private renderEmptyState;
210
+ private renderBulkBar;
113
211
  private renderPagination;
114
- render(): import("lit-html").TemplateResult<1>;
212
+ render(): TemplateResult<1>;
115
213
  }