Angular 数据表格与分页列表 | ng-hub-ui-paginable
Angular 数据表格和分页列表,支持服务端分页、排序、筛选、选择、模板和 CSS 变量。
API 参考
这里是 paginable 的完整契约:你可以绑定、监听、投影和设置主题的一切,都集中在一处。接入你需要的部分,自定义你想要的样式——它是 standalone 的,且对 signal 友好。
输入
通过 10 个输入项精细调校 paginable。像绑定任意 Angular @Input 一样绑定它们。
| 名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
data必填 | T[] | Observable<T[]> | — | 要在表格中显示的数据项数组,或发出数据数组的 Observable |
headers必填 | PaginableTableHeader[] | — | 定义表格列及其属性的配置数组 |
pagination | PaginableTablePagination | — | 分页配置,包括每页大小、当前页和总条目数 |
options | PaginableTableOptions | — | 通用表格选项,包括选择模式、加载状态和响应式行为 |
loading | boolean | — | 通过加载指示器遮罩显示加载状态 |
error | unknown | null | — | DOCS.PAGINABLE.API.INPUT.ERROR.DESCRIPTION |
loadingComponent | PaginableStateDefault | null | — | DOCS.PAGINABLE.API.INPUT.LOADING_COMPONENT.DESCRIPTION |
errorComponent | PaginableStateDefault | null | — | DOCS.PAGINABLE.API.INPUT.ERROR_COMPONENT.DESCRIPTION |
noResultsComponent | PaginableStateDefault | null | — | DOCS.PAGINABLE.API.INPUT.NO_RESULTS_COMPONENT.DESCRIPTION |
selected | T[] | — | 当前选中项的数组(支持双向绑定) |
输出
响应 paginable 的行为——有 5 个事件可供你挂接逻辑。
| 名称 | 类型 | 描述 |
|---|---|---|
rowClick | TableRowEvent<T> | 当表格行被点击时触发,包含行数据和事件详情 |
selectionChange | T[] | 当行选择发生变化时触发,返回选中项的数组 |
sortChange | PaginableTableOrdination[] | 当列排序发生变化时触发,返回当前的排序配置 |
filterChange | FilterChangeEvent | 当筛选条件被应用或更改时触发 |
pageChange | PaginationState | 当分页发生变化时触发(页码或每页大小) |
模板
打造你自己的样式——7 个模板插槽让你可以投影自定义标记。
| 名称 | 描述 | 示例 |
|---|---|---|
*paginableTableHeader | 用于定义自定义列头部的自定义头部模板 | <ng-template *paginableTableHeader="let column">{{ column.title }}</ng-template> |
*paginableTableCell | 用于自定义单元格内容渲染的自定义单元格模板 | <ng-template *paginableTableCell="let value; let row">{{ value }}</ng-template> |
*paginableTableRow | 用于定义整行结构的自定义行模板 | <ng-template *paginableTableRow="let row"><tr>...</tr></ng-template> |
*paginableTableFilter | 用于添加筛选 UI 元素的自定义筛选模板 | <ng-template *paginableTableFilter="let column"><input type="text"></ng-template> |
*paginableTableLoading | 用于自定义加载指示器的加载状态模板 | <ng-template *paginableTableLoading><div class="spinner"></div></ng-template> |
*paginableNoResults | 当没有可用数据时显示的空状态模板 | <ng-template *paginableNoResults><p>No data found</p></ng-template> |
*paginableTableError | 用于处理错误情况的错误状态模板 | <ng-template *paginableTableError="let error"><p>Error: {{ error }}</p></ng-template> |
CSS 变量
用 69 个 CSS 变量为每一个像素设置主题。在 :root 处覆盖它们,或将其限定到某个容器范围内。
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_COLORS.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_COLORS.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-table-container-bg | var(--hub-ref-color-white, #fff) | color | Background of the entire table container. #f8f9favar(--bs-body-bg) |
--hub-table-container-color | var(--hub-sys-text-primary, #212529) | color | Default text colour inside the container. #333inherit |
--hub-table-bg | var(--hub-ref-color-white, #fff) | color | Table element background. transparent#fff |
--hub-table-color | var(--hub-sys-text-primary, #212529) | color | Table text colour. #495057 |
--hub-table-border-color | var(--hub-sys-border-color-default, #dee2e6) | color | Border colour used for table, rows and cells. #ccctransparent |
--hub-table-hover-bg | | color | Row background on hover. rgba(0,0,0,.04)#f0f4f8 |
--hub-table-hover-color | | color | Row text colour on hover. inherit |
--hub-table-striped-bg | | color | Alternating stripe row background. rgba(0,0,0,.03) |
--hub-table-striped-color | | color | Alternating stripe row text colour. inherit |
--hub-table-active-bg | var(--hub-sys-state-active-bg, rgba(0,0,0,.1)) | color | Selected/active row background. #e3f2fd |
--hub-table-active-color | var(--hub-sys-text-primary, #212529) | color | Selected/active row text colour. inherit |
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_LAYOUT.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_LAYOUT.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-table-border-radius | var(--hub-ref-radius-md, 0.375rem) | length | Container corner radius. 00.5rem |
--hub-table-border-width | var(--hub-ref-border-width, 1px) | length | Border width. 02px |
--hub-table-container-gap | var(--hub-ref-space-3, 1rem) | length | Gap between container regions (top bar, table, bottom bar). 0.5rem1.5rem |
--hub-table-cell-padding-x | var(--hub-ref-space-3, 1rem) | length | Horizontal cell padding. 0.75rem1.5rem |
--hub-table-cell-padding-y | var(--hub-ref-space-2, 0.5rem) | length | Vertical cell padding. 0.25rem0.75rem |
--hub-table-cell-padding-x-sm | var(--hub-ref-space-2, 0.5rem) | length | Horizontal cell padding in small/dense mode. 0.5rem |
--hub-table-cell-padding-y-sm | var(--hub-ref-space-1, 0.25rem) | length | Vertical cell padding in small/dense mode. 0.125rem |
--hub-table-cell-vertical-align | middle | string | Vertical alignment of cell content. topbottom |
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_BARS.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_BARS.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-table-top-bar-gap | var(--hub-ref-space-3, 1rem) | length | Gap between items in the top bar. 0.5rem |
--hub-table-top-bar-justify-content | end | string | Flex justify-content for the top bar. space-betweencenter |
--hub-table-bottom-bar-gap | var(--hub-ref-space-3, 1rem) | length | Gap between items in the bottom bar. 0.5rem |
--hub-table-bottom-bar-justify-content | space-around | string | Flex justify-content for the bottom bar. space-between |
--hub-table-bottom-bar-paginator-order | 1 | number | Flex order of the paginator in the bottom bar. 3 |
--hub-table-bottom-bar-settings-order | 2 | number | Flex order of the settings control. 1 |
--hub-table-bottom-bar-info-order | 3 | number | Flex order of the info text. 1 |
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_SEARCH.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.TABLE_SEARCH.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-table-search-border-radius | | length | Search field border radius. 0.375rem9999px |
--hub-table-search-input-bg | | color | Search input background. #fff |
--hub-table-search-input-color | | color | Search input text colour. #212529 |
--hub-table-search-button-bg | | color | Search button background. var(--bs-primary) |
--hub-table-search-button-color | | color | Search button icon/text colour. #fff |
DOCS.PAGINABLE.API.CSS_GROUP.LIST_COLORS.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.LIST_COLORS.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-list-bg | | color | List host background. #ffftransparent |
--hub-list-items-bg | | color | Background of the items container. #f8f9fa |
--hub-list-item-bg | | color | Individual item background. #fff |
--hub-list-item-color | | color | Individual item text colour. #212529 |
--hub-list-item-hover-bg | | color | Item background on hover. rgba(0,0,0,.04) |
--hub-list-item-selected-bg | | color | Selected item background. #e3f2fd |
--hub-list-item-selected-color | | color | Selected item text colour. inherit |
--hub-list-item-border-color | | color | Item border colour. #dee2e6 |
DOCS.PAGINABLE.API.CSS_GROUP.LIST_LAYOUT.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.LIST_LAYOUT.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-list-gap | | length | Gap between list items. 00.5rem |
--hub-list-items-gap | | length | Gap inside the items wrapper. 0.25rem |
--hub-list-padding-x | | length | Horizontal padding of the list host. 01rem |
--hub-list-padding-y | | length | Vertical padding of the list host. 00.5rem |
--hub-list-item-padding-x | | length | Horizontal padding of each item. 1rem1.25rem |
--hub-list-item-padding-y | | length | Vertical padding of each item. 0.5rem0.75rem |
--hub-list-border-radius | | length | Container border radius. 0.375rem |
DOCS.PAGINABLE.API.CSS_GROUP.LIST_CARDS.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.LIST_CARDS.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-list-cards-columns | | number | Number of card columns (auto-fill when unset). 234 |
--hub-list-cards-min-column-width | | length | Minimum column width for auto-fill grid. 200px280px |
--hub-list-cards-gap | | length | Gap between cards. 0.75rem1.5rem |
--hub-list-cards-bg | | color | Card background. #fff |
--hub-list-cards-border-color | | color | Card border colour. #dee2e6 |
--hub-list-cards-border-radius | | length | Card corner radius. 0.5rem |
--hub-list-cards-shadow | | shadow | Card drop shadow. 0 2px 8px rgba(0,0,0,.1) |
--hub-list-cards-hover-shadow | | shadow | Card drop shadow on hover. 0 4px 16px rgba(0,0,0,.15) |
--hub-list-cards-padding-x | | length | Card horizontal padding. 1rem |
--hub-list-cards-padding-y | | length | Card vertical padding. 1rem |
DOCS.PAGINABLE.API.CSS_GROUP.PAGINATOR.TITLE
DOCS.PAGINABLE.API.CSS_GROUP.PAGINATOR.DESCRIPTION
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-paginator-link-bg | | color | Page link background. #ffftransparent |
--hub-paginator-link-color | | color | Page link text colour. var(--bs-primary) |
--hub-paginator-link-border-color | | color | Page link border colour. #dee2e6 |
--hub-paginator-link-border-radius | | length | Page link border radius. 0.375rem9999px |
--hub-paginator-link-active-bg | | color | Active page link background. var(--bs-primary) |
--hub-paginator-link-active-color | | color | Active page link text colour. #fff |
--hub-paginator-link-hover-bg | | color | Hovered page link background. #f0f4f8 |
--hub-paginator-link-padding-x | | length | Page link horizontal padding. 0.625rem |
--hub-paginator-link-padding-y | | length | Page link vertical padding. 0.375rem |
--hub-paginator-font-size | | length | Paginator font size. 0.875rem1rem |
--hub-paginator-gap | | length | Gap between paginator controls. 0.25rem0.5rem |
--hub-paginator-info-color | | color | Pagination info text colour. #6c757d |
--hub-paginator-label-color | | color | Per-page label colour. #6c757d |
样式与主题
尚未记录任何样式示例。本节将包含自定义方案和主题示例。