spiderly 19.11.8 → 19.11.9
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/agent/docs/angular-customization/index.md +34 -1
- package/agent/docs/angular-customization/references/helper-functions.generated.md +1 -0
- package/fesm2022/spiderly.mjs +396 -75
- package/fesm2022/spiderly.mjs.map +1 -1
- package/lib/components/spiderly-data-table/spiderly-data-table.component.d.ts +160 -14
- package/lib/components/spiderly-data-view/spiderly-data-view.component.d.ts +8 -1
- package/lib/services/helper-functions.d.ts +6 -0
- package/package.json +1 -1
- package/styles/components/spiderly-data-table/spiderly-data-table.component.scss +34 -0
- package/styles/components/spiderly-data-view/spiderly-data-view.component.scss +16 -0
- package/styles/styles/layout/_content.scss +1 -1
- package/styles/styles/layout/_main.scss +15 -1
- package/styles/styles/layout/_menu.scss +1 -1
- package/styles/styles/layout/_mixins.scss +33 -0
- package/styles/styles/layout/_topbar.scss +4 -4
|
@@ -207,7 +207,26 @@ cols: Column<ProductDTO>[] = [
|
|
|
207
207
|
|
|
208
208
|
Headers are click-to-sort by default; disable with `sortable: false`. Columns whose `field` ends in `CommaSeparated` are auto-disabled — the backend generates no sort case for collection columns and rejects unknown sort fields with a 400, so the table never offers the click.
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
The table lays its columns out from their **declared widths, never from the rows on screen** (`table-layout: fixed`). The browser default would size every column from the content of the page currently rendered, so a column is one width on this page and another on the next, and a filter — which narrows the variety of values in the column it filters — shifts the whole grid under an operator who is scanning it.
|
|
211
|
+
|
|
212
|
+
Widths default per `filterType` and are sized for the **header** — the filter input plus its match-mode dropdown — so a column of short values (an amount, a status code) reserves more than it uses. `width: '8rem'` overrides the default for one column.
|
|
213
|
+
|
|
214
|
+
Declared widths behave as **ratios**, not caps: the table shares its surplus in proportion to them, so a column carrying long values wants the larger number. A table whose columns need more room than its container gets is widened to their sum and scrolls horizontally, rather than crushing the columns.
|
|
215
|
+
|
|
216
|
+
Because a column no longer widens to fit its text, long values wrap and would grow the row instead. The default cell clamps to one line with an ellipsis. **A column rendering its own `spiderlyCellTemplate` clamps its own lines** — the library's rule cannot reach markup that carries the consumer's style encapsulation. Two traps when you write that rule: a flex item needs `min-width: 0` (its default `min-width: auto` floors it at the content width and the ellipsis never fires), and any pill or badge sitting beside the text needs `flex: none` so the text is what gives way.
|
|
217
|
+
|
|
218
|
+
`matchModes` narrows the match modes a column offers: declaration order is display order, and the **first entry becomes the column's default** match mode. Use it when a mode can only mislead — e.g. a datetime column, where an exact-equals match on a timestamp can never hit:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
new Column({ field: 'createdAt', name: 'Created', filterType: 'date', showTime: true,
|
|
222
|
+
showMatchModes: true, matchModes: [MatchModeCodes.GreaterThan, MatchModeCodes.LessThan] }),
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Three things to know:
|
|
226
|
+
|
|
227
|
+
- The offered list is only *visible* with `showMatchModes: true`, but the **default applies either way** — declaring `matchModes` on a column with no picker is the supported way to change just that column's default mode.
|
|
228
|
+
- It is read at **declaration time**. PrimeNG builds the dropdown once, so reassigning `col.matchModes` later never reaches the rendered menu.
|
|
229
|
+
- Only modes the filter type actually offers are honored (`text`: starts-with / contains / equals; `numeric` and `date`: their three each). Anything else is logged to the console and ignored, and a narrowing that leaves nothing falls back to the full list — the alternative is an empty dropdown you cannot pick from, plus a match mode the backend rejects with a 400.
|
|
211
230
|
|
|
212
231
|
### Column chooser (show/hide columns)
|
|
213
232
|
|
|
@@ -292,6 +311,20 @@ Project an `<ng-template spiderlyDataTableActions>` to add your own buttons (or
|
|
|
292
311
|
|
|
293
312
|
**Shift+click selects a range**: click one checkbox, hold Shift, click another — every row between receives the *clicked checkbox's new state* (shift-checking selects the range, shift-unchecking clears it). The anchor is the last clicked checkbox, and a range only ever spans rows visible on the current page: if the anchor is no longer among them, the shift-click degrades to a plain toggle. (A client-side sort that keeps both rows on screen ranges over the *new* visual order, which is what the user sees and expects.) Rows already in the target state are skipped; each actual change emits `onRowSelect`/`onRowUnselect` exactly as a single click would, so delta-based consumers (`newlySelectedItems`/`unselectedItems`) need no changes.
|
|
294
313
|
|
|
314
|
+
### Paging scrolls the list back into view
|
|
315
|
+
|
|
316
|
+
Changing the page or the page size scrolls the table's wrapper back under the top of the viewport, so the new rows are what you land on rather than the paginator you just clicked. It is instant, never animated, and it does nothing when the table's top is already visible — a table placed below other content on a details page will not push that content off-screen.
|
|
317
|
+
|
|
318
|
+
The amount of fixed chrome to clear comes from the `--spiderly-viewport-top-inset` CSS variable, which `spiderly`'s own layout declares on `html` (defaulting to `--spiderly-topbar-height`). If you run your own fixed header, or pin a second bar below spiderly's topbar, declare the inset to match:
|
|
319
|
+
|
|
320
|
+
```css
|
|
321
|
+
html {
|
|
322
|
+
--spiderly-viewport-top-inset: 8rem;
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Set the inset rather than stretching `--spiderly-topbar-height`, which is the topbar's actual height. Leave it undeclared and the table scrolls to the true top of the viewport, which is correct when nothing is pinned there.
|
|
327
|
+
|
|
295
328
|
### Key Inputs
|
|
296
329
|
|
|
297
330
|
| Input | Type | Default | Purpose |
|
|
@@ -33,6 +33,7 @@ Reusable helpers exported from `helper-functions.ts`. Import the one you need in
|
|
|
33
33
|
| `parseDateOnlyLocal(s: string): Date \| null` | |
|
|
34
34
|
| `pushAction(cols: Column[], action: Action)` | |
|
|
35
35
|
| `saveResponseAsFile(res: HttpResponse<Blob>, fallbackName: string): void` | |
|
|
36
|
+
| `scrollElementIntoViewIfAboveViewport(element: HTMLElement): void` | Scrolls `element` back under the top of the viewport, but only when it has already scrolled above it. Set the element's `scroll-margin-top` to whatever fixed chrome must stay clear. Assumes the element's nearest scroll container is the viewport itself. |
|
|
36
37
|
| `selectedTab(tabs: SpiderlyTab[]): number` | |
|
|
37
38
|
| `singleOrDefault<T>(array: T[], predicate: (item: T) => boolean): T \| undefined` | |
|
|
38
39
|
| `splitPascalCase(input: string)` | |
|