shirkasoft-ui-components 1.3.14 → 1.3.15

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
@@ -406,8 +406,9 @@ interface Column {
406
406
  currency?: string; // template 'currency', default 'USD'
407
407
  image?: (row: any) => string | undefined; // avatar/flag before the text
408
408
  imageWidth?: number; // default 28
409
- required?: boolean; // with validateRequired: flags rows where it's empty
409
+ required?: boolean | ((row: any) => boolean); // with validateRequired: flags rows where it's empty (function = conditional)
410
410
  missingMessage?: string; // text in the empty cell (default "Falta <header>")
411
+ missingSeverity?: 'error' | 'warning'; // mandatory (red) or informative (amber); default: table's missingAsError
411
412
  isMissing?: (row: any) => boolean; // custom rule (default: null/undefined/blank/[])
412
413
  format?: (row: any) => string;
413
414
  tagValue?: (row: any) => string;
@@ -485,7 +486,6 @@ interface FilterChangeEvent {
485
486
  | `showGridlines` | `boolean` | `false` |
486
487
  | `validateRequired` | `boolean` | `false` |
487
488
  | `missingAsError` | `boolean` (with `validateRequired`) | `true` |
488
- | `requiredFields` | `(string \| RequiredField)[]` | `[]` |
489
489
  | `resizableColumns` | `boolean` (only with `showGridlines`) | `true` |
490
490
  | `columnWidths` | `Record<string, number>` (two-way `[(columnWidths)]`) | `{}` |
491
491
  | `stateKey` | `string` (persists column widths) | `''` |
@@ -532,28 +532,32 @@ i18n keys used: `table.selected` (`{{count}}`), `table.selectAll`, `table.select
532
532
  - `boolean`: tri-state checkbox (any → yes → no), applied immediately.
533
533
  - `range`: two-thumb slider between `filterMin` and `filterMax`, applied on release.
534
534
 
535
- **Missing data validation.** Opt-in with `[validateRequired]="true"` and mark the mandatory columns with `required: true`. Rows where one of them is empty (`null`, `undefined`, blank text or empty array; `0` and `false` are valid) get a red (error) background and stripe, an error icon whose tooltip lists the missing fields, and the empty cell shows "Falta <header>" (or `missingMessage`). The caption shows how many rows are incomplete (whole dataset in client mode, current page in server mode). Use `isMissing: (row) => boolean` for custom rules.
535
+ **Missing data validation.** Opt-in with `[validateRequired]="true"` and mark the mandatory columns with `required: true` (or a per-row condition). Each row is checked field by field: the empty cell shows "Falta <header>" (or `missingMessage`) and the whole row is highlighted — red when a field with severity `'error'` is missing, amber when only `'warning'` fields are missing (error wins). Empty means `null`, `undefined`, blank text or empty array; `0` and `false` are valid. Use `isMissing: (row) => boolean` for custom rules.
536
536
 
537
537
  ```typescript
538
538
  cols: Column[] = [
539
539
  { field: 'name', header: 'Nombre', required: true },
540
540
  { field: 'email', header: 'Email', required: true, missingMessage: 'Sin correo' },
541
+ // conditional: mandatory only when the row/payload meets the condition
542
+ { field: 'rfc', header: 'RFC', required: (row) => row.tipo === 'empresa' },
541
543
  ];
542
544
  ```
545
+
546
+ `required` can be a function evaluated per row (and per payload in `validateRow`): when it returns `false` the field is optional for that row; when `true`, it's checked like a regular required field.
543
547
  ```html
544
548
  <shk-table [data]="users" [columns]="cols" [validateRequired]="true" />
545
549
  ```
546
550
 
547
- Fields that aren't columns can be required too with `requiredFields`: a field name (`'phone'`) or `{ field, label?, isMissing? }`. They flag the row the same way and appear in the tooltip (there's no cell to write "Falta…" in), and `validateRow` checks them as well.
551
+ Each column sets the severity of its missing value with `missingSeverity`: `'error'` (red, mandatory) or `'warning'` (amber, informative), so mandatory and informative fields can live in the same `columns` array. Columns without it use the table's `missingAsError` (errors by default; `false` = warnings).
548
552
 
549
- ```html
550
- <shk-table [data]="users()" [columns]="cols" [validateRequired]="true"
551
- [requiredFields]="[{ field: 'phone', label: 'Teléfono' }, 'address.street']" />
553
+ ```typescript
554
+ cols: Column[] = [
555
+ { field: 'email', header: 'Email', required: true }, // error
556
+ { field: 'phone', header: 'Teléfono', required: true, missingSeverity: 'warning' }, // informative
557
+ ];
552
558
  ```
553
559
 
554
- Incomplete rows are shown as errors (red) by default; set `[missingAsError]="false"` to show them as warnings (amber) instead.
555
-
556
- **Validating a modal payload.** `validateRow(obj)` returns the `required` columns and `requiredFields` the object is missing (`[{ field, header }]`, empty when complete); it works even with `validateRequired` off. Combined with the modal's optional `onAccept`, the data coming from a form can be added and flagged:
560
+ **Validating a modal payload.** `validateRow(obj)` returns the `required` columns the object is missing (`[{ field, header, severity }]`, empty when complete); it works even with `validateRequired` off. Combined with the modal's optional `onAccept`, the data coming from a form can be added and flagged:
557
561
 
558
562
  ```typescript
559
563
  table = viewChild.required(TableComponent);
@@ -569,7 +573,7 @@ this.modalSrv.open({
569
573
  });
570
574
  ```
571
575
 
572
- i18n: `table.missing.{summary, row, cell, column}` (Spanish fallbacks).
576
+ i18n: `table.missing.cell` (Spanish fallback).
573
577
 
574
578
  **Resizable columns.** With `[showGridlines]="true"` each header has a handle on its right border: drag it to widen/narrow the column (minimum 60px; the table scrolls horizontally when it no longer fits), use the arrow keys on it (Shift = 50px steps), or double click it to go back to the automatic width. Disable it with `[resizableColumns]="false"`. Every change emits `columnResize`. The row actions column can be resized too (its width is stored under the `actions` key); its automatic width fits the most actions visible in a row of the current page (honouring each action's `isVisible`), not every action defined.
575
579