ng-hub-ui-paginable 22.1.2 → 22.3.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.
package/README.md CHANGED
@@ -119,6 +119,31 @@ import { TableComponent } from 'ng-hub-ui-paginable';
119
119
 
120
120
  ---
121
121
 
122
+ ## Form-controls synergy (optional, agnostic)
123
+
124
+ The table renders its primitive controls (global **search** input and the
125
+ **rows-per-page** selector) as native `<input>` / `<select>` by default — `ng-hub-ui-paginable`
126
+ has **no hard dependency** on a forms library. Provide the adapter shipped by
127
+ `ng-hub-ui-forms` once and those controls upgrade to `hub-input` / `hub-select`
128
+ automatically (dynamic component creation under the hood), with no template
129
+ changes:
130
+
131
+ ```ts
132
+ import { provideHubPaginableFormControls } from 'ng-hub-ui-paginable';
133
+ import { hubFormControlAdapter } from 'ng-hub-ui-forms';
134
+
135
+ export const appConfig: ApplicationConfig = {
136
+ providers: [provideHubPaginableFormControls(hubFormControlAdapter)]
137
+ };
138
+ ```
139
+
140
+ To limit it to one table, provide the `HUB_PAGINABLE_FORM_CONTROLS` token in that
141
+ component's `providers` instead. Remove it and the table falls back to native
142
+ controls. See the ecosystem-wide
143
+ [Synergies & agnosticism](../../README.md#synergies--agnosticism) section.
144
+
145
+ ---
146
+
122
147
  ## ✨ Inspiration
123
148
 
124
149
  This library arises from the need to offer highly configurable, accessible, and modern data visualization components for Angular applications, enabling integrated lists, tables, and pagination with full support for signals, reactive forms, and complete render customization.
@@ -150,7 +175,7 @@ All components are built as standalone Angular components with full Angular Sign
150
175
  - **📋 Smart Sorting**: Ascending/descending column sorting with visual indicators
151
176
  - **☑️ Row Selection**: Single or multiple row selection with batch operations and ControlValueAccessor support
152
177
  - **📈 Expandable Content**: Collapsible row content for detailed views with custom templates
153
- - **📄 Dual Pagination**: Support for both local and remote pagination strategies
178
+ - **📄 Dual Pagination**: Automatic **client-side** pagination for plain arrays (in-memory search, filter, sort & slice) or **server-side** via `PaginationState` / `totalItems`
154
179
  - **🎨 Template Customization**: Extensive custom templates for headers, cells, filters, states (empty, loading, error)
155
180
  - **📱 Responsive Design**: Configurable responsive breakpoints for optimal mobile experience
156
181
  - **♿ Accessibility Ready**: Built-in ARIA support and keyboard navigation
@@ -1012,11 +1037,11 @@ filters = signal({
1012
1037
  | Name | Type | Default | Description |
1013
1038
  | -------------------- | --------------------------------------------- | --------------- | -------------------------------------------------------------------------------------------------------- |
1014
1039
  | `headers` | `PaginableTableHeader[]` | `[]` | Column definitions with titles, sorting, filtering, and actions. |
1015
- | `data` / `rows` | `T[]` or `PaginationState<T>` | `[]` | Table data - can be flat array or paginated object with metadata. |
1016
- | `page` | `number` | `null` | Current page number (1-based, model signal). |
1017
- | `perPage` | `number` | `null` | Number of items per page. |
1018
- | `perPageOptions` | `number[]` | `[20, 50, 100]` | Available options for items per page. |
1019
- | `totalItems` | `number` | `null` | Total number of items across all pages. |
1040
+ | `data` / `rows` | `T[]` or `PaginationState<T>` | `[]` | Table data. A plain array → client-side mode (in-memory pagination); a `PaginationState` → server mode. |
1041
+ | `page` | `number` | `null` | Current page number (1-based, model signal). Defaulted to `1` automatically in client-side mode. |
1042
+ | `perPage` | `number` | `10` | Number of items per page (model signal). |
1043
+ | `perPageOptions` | `number[]` | `[10, 20, 50, 100]` | Available options for items per page. |
1044
+ | `totalItems` | `number` | `null` | Total items across all pages. Setting it selects **server mode** (the table renders `data` as-is). |
1020
1045
  | `searchable` | `boolean` | `true` | Whether to show the global search input. |
1021
1046
  | `searchTerm` | `string` | `''` | Current search term (model signal). |
1022
1047
  | `searchFn` | `(a: T, b: T) => boolean` | `null` | Custom search function for filtering. |
@@ -1027,7 +1052,7 @@ filters = signal({
1027
1052
  | `filters` | `Record<string, any>` | `{}` | Active column filters (model signal). |
1028
1053
  | `debounce` | `number` | `0` | Debounce time in ms for search and filter inputs. |
1029
1054
  | `loading` | `boolean` | `false` | Loading state indicator (model signal). |
1030
- | `paginate` | `boolean` | `true` | Whether to enable pagination. |
1055
+ | `paginate` | `boolean` | `true` | Enables pagination. With a plain array and no `totalItems`, this turns on automatic client-side mode. `false` renders the whole array unpaginated. |
1031
1056
  | `paginationPosition` | `'top' \| 'bottom' \| 'both'` | `'bottom'` | Where to display pagination controls. |
1032
1057
  | `paginationInfo` | `boolean` | `true` | Whether to show pagination info (e.g., "Showing 1 to 10 of 100"). |
1033
1058
  | `stickyActions` | `boolean` | `false` | Whether action buttons should stick during scrolling. |
@@ -2069,11 +2094,21 @@ This allows you to adapt any type of visual filter (date-range, boolean, dropdow
2069
2094
 
2070
2095
  ## 🧠 Pagination and Data Handling
2071
2096
 
2072
- The `hub-ui-table` component can receive data in two different ways:
2097
+ The `hub-ui-table` component supports **three** data / pagination modes:
2098
+
2099
+ #### 1. Client-side (automatic) — pass a plain array
2100
+
2101
+ Hand the table the **full array** and let it paginate, search, sort and filter **entirely in memory** — no parent wiring required. This is the default whenever `[data]` is a plain array, `paginate` is `true` (its default) and you do **not** provide `totalItems`; the table computes the total itself. It mirrors the client-side behaviour of `<hub-ui-list>`.
2102
+
2103
+ ```html
2104
+ <hub-ui-table [data]="allRows()" [headers]="headers" [(page)]="page" [perPage]="20" [searchable]="true"></hub-ui-table>
2105
+ ```
2106
+
2107
+ > The global search box, sortable headers and every per-column filter (inline "row" filters and the advanced "menu" rule engine) all resolve client-side, and the current page resets/clamps automatically as the result set changes. Set `[paginate]="false"` to render the whole array without any pagination.
2073
2108
 
2074
- #### 1. Grouped form (`PaginationState<T>`)
2109
+ #### 2. Grouped form (`PaginationState<T>`) — server-side
2075
2110
 
2076
- Ideal if you manage pagination outside the component. The `data` input can directly accept an object with the full pagination structure:
2111
+ Ideal if you manage pagination outside the component (a service, store or `computed()`). Passing a `PaginationState` keeps the table in **server mode**: it renders `data` as-is and reads `page` / `perPage` / `totalItems` from the object. The `data` input accepts it directly:
2077
2112
 
2078
2113
  ```html
2079
2114
  <hub-ui-table
@@ -2088,17 +2123,17 @@ Ideal if you manage pagination outside the component. The `data` input can direc
2088
2123
 
2089
2124
  > This form is useful when you manage `PaginationState` in a single place (for example, from a service, `computed()`, or store).
2090
2125
 
2091
- #### 2. Split form (individual inputs)
2126
+ #### 3. Split form (individual inputs) — server-side
2092
2127
 
2093
- You can also pass each value separately:
2128
+ You can also pass each value separately, holding only the current page's rows in `data`:
2094
2129
 
2095
2130
  ```html
2096
- <hub-ui-table [data]="data()" [page]="page()" [perPage]="perPage()" [totalItems]="totalItems()"></hub-ui-table>
2131
+ <hub-ui-table [data]="pageRows()" [page]="page()" [perPage]="perPage()" [totalItems]="totalItems()"></hub-ui-table>
2097
2132
  ```
2098
2133
 
2099
- > It is important that if you choose this form, **all inputs are present**. If `page`, `perPage`, or `totalItems` are missing, the component will show an error in the console.
2134
+ > Set **`totalItems`** to opt into server mode — it tells the table you are managing the total yourself, so it renders `data` as-is instead of paginating it in memory. (If you pass a plain array **without** `totalItems`, the table assumes client-side mode #1 and paginates it for you.)
2100
2135
 
2101
- Both forms are compatible with Signals and can be easily integrated with `model()` and `computed()`.
2136
+ All three modes are compatible with Signals and integrate cleanly with `model()` and `computed()`.
2102
2137
 
2103
2138
  ### Advanced Pagination Example
2104
2139