@praxisui/table 1.0.0-beta.18 → 1.0.0-beta.20
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 +8 -0
- package/fesm2022/praxisui-table.mjs +65 -3
- package/fesm2022/praxisui-table.mjs.map +1 -1
- package/index.d.ts +7 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -430,6 +430,10 @@ Quando `behavior.virtualization.enabled` estiver ativo, as linhas da tabela são
|
|
|
430
430
|
- `behavior.pagination.position`: `top` | `bottom` | `both`.
|
|
431
431
|
- `behavior.pagination.style`: `default` | `compact` (aplica classe de estilo no paginator).
|
|
432
432
|
|
|
433
|
+
Nota sobre estratégia (client vs server)
|
|
434
|
+
- Se `behavior.pagination.strategy` não estiver definido, a tabela assume `server` automaticamente quando há `resourcePath` (dados remotos). Caso contrário, usa `client`.
|
|
435
|
+
- O mesmo vale para `behavior.sorting.strategy`.
|
|
436
|
+
|
|
433
437
|
## Duplo clique na linha
|
|
434
438
|
|
|
435
439
|
Ative em Comportamento → Interação.
|
|
@@ -491,6 +495,8 @@ Observação: quando informado, o defaultSort é aplicado na carga inicial se n
|
|
|
491
495
|
|
|
492
496
|
## Coluna de ações (sticky)
|
|
493
497
|
|
|
498
|
+
Nota: por padrão a coluna de ações vem desabilitada. Habilite explicitamente em `actions.row.enabled` e defina as ações desejadas.
|
|
499
|
+
|
|
494
500
|
- Fixe a coluna de ações no início/fim configurando `actions.row.sticky`:
|
|
495
501
|
|
|
496
502
|
```ts
|
|
@@ -759,6 +765,8 @@ export class ExampleComponent {
|
|
|
759
765
|
|
|
760
766
|
Quando a `<praxis-table>` é conectada a um `resourcePath`, as operações de paginação, ordenação e filtro são delegadas ao backend. Isso garante alta performance, pois apenas os dados visíveis na tela são trafegados pela rede.
|
|
761
767
|
|
|
768
|
+
Importante: se você não configurar explicitamente as estratégias de paginação/ordenação no `TableConfig`, a tabela resolve automaticamente como `server` quando há `resourcePath`. Se preferir operar no cliente, defina `behavior.pagination.strategy = 'client'` e/ou `behavior.sorting.strategy = 'client'` conscientemente.
|
|
769
|
+
|
|
762
770
|
O diagrama abaixo detalha a sequência de eventos, desde a interação do usuário na UI até a construção da consulta JPA no servidor.
|
|
763
771
|
|
|
764
772
|
```mermaid
|
|
@@ -22812,9 +22812,23 @@ class PraxisTable {
|
|
|
22812
22812
|
}
|
|
22813
22813
|
catch { }
|
|
22814
22814
|
}
|
|
22815
|
+
resolvePagingStrategy() {
|
|
22816
|
+
const raw = this.config.behavior?.pagination?.strategy;
|
|
22817
|
+
if (raw === 'client' || raw === 'server')
|
|
22818
|
+
return raw;
|
|
22819
|
+
// Default to server when using remote resource and not explicitly configured
|
|
22820
|
+
return this.resourcePath ? 'server' : 'client';
|
|
22821
|
+
}
|
|
22822
|
+
resolveSortingStrategy() {
|
|
22823
|
+
const raw = this.config.behavior?.sorting?.strategy;
|
|
22824
|
+
if (raw === 'client' || raw === 'server')
|
|
22825
|
+
return raw;
|
|
22826
|
+
// Default to server when using remote resource and not explicitly configured
|
|
22827
|
+
return this.resourcePath ? 'server' : 'client';
|
|
22828
|
+
}
|
|
22815
22829
|
applyDataSourceSettings() {
|
|
22816
|
-
const paginationStrategy = this.
|
|
22817
|
-
const sortingStrategy = this.
|
|
22830
|
+
const paginationStrategy = this.resolvePagingStrategy();
|
|
22831
|
+
const sortingStrategy = this.resolveSortingStrategy();
|
|
22818
22832
|
const isServerPaging = paginationStrategy === 'server';
|
|
22819
22833
|
const isServerSorting = sortingStrategy === 'server';
|
|
22820
22834
|
if (this.paginator) {
|
|
@@ -23023,7 +23037,7 @@ class PraxisTable {
|
|
|
23023
23037
|
// Fall back to inference only if API type is not available or invalid
|
|
23024
23038
|
apiType = this.inferFieldTypeFromFieldName(field.name);
|
|
23025
23039
|
}
|
|
23026
|
-
|
|
23040
|
+
const col = {
|
|
23027
23041
|
field: field.name,
|
|
23028
23042
|
header: field.label ?? field.name,
|
|
23029
23043
|
order: field.order,
|
|
@@ -23034,6 +23048,47 @@ class PraxisTable {
|
|
|
23034
23048
|
_originalApiType: apiType,
|
|
23035
23049
|
_isApiField: true,
|
|
23036
23050
|
};
|
|
23051
|
+
// Auto-renderers: map known UI controls to richer cell renderers on first bootstrap
|
|
23052
|
+
// - Avatar: when backend marks controlType 'avatar' (x-ui) or field name matches avatar-like patterns
|
|
23053
|
+
try {
|
|
23054
|
+
this.applyAutoRenderer(field, col);
|
|
23055
|
+
}
|
|
23056
|
+
catch { }
|
|
23057
|
+
return col;
|
|
23058
|
+
}
|
|
23059
|
+
/**
|
|
23060
|
+
* Apply automatic renderer hints based on schema field metadata.
|
|
23061
|
+
* Runs only on initial bootstrap (when columns are derived from schema).
|
|
23062
|
+
*/
|
|
23063
|
+
applyAutoRenderer(field, col) {
|
|
23064
|
+
if (!field || !col)
|
|
23065
|
+
return;
|
|
23066
|
+
// Do not override explicit renderer if any (defensive; initial columns have none)
|
|
23067
|
+
if (col.renderer && col.renderer.type)
|
|
23068
|
+
return;
|
|
23069
|
+
const ctl = (field.controlType || '').toString().trim().toLowerCase();
|
|
23070
|
+
const fname = (field.name || '').toString();
|
|
23071
|
+
const lname = fname.toLowerCase();
|
|
23072
|
+
const isAvatarByControl = ctl === 'avatar';
|
|
23073
|
+
if (isAvatarByControl) {
|
|
23074
|
+
// Derive initials from common name fields; leave altField undefined to avoid brittle coupling
|
|
23075
|
+
const initialsExpr = "= (row.nomeCompleto || row.nome || row.fullName || row.name || row.title || '').trim().split(/\\s+/).slice(0,2).map(p => p[0] || '').join('').toUpperCase()";
|
|
23076
|
+
col.renderer = {
|
|
23077
|
+
type: 'avatar',
|
|
23078
|
+
avatar: {
|
|
23079
|
+
srcField: fname,
|
|
23080
|
+
// altField intentionally omitted; rely on initialsExpr + title attr if provided later
|
|
23081
|
+
initialsExpr,
|
|
23082
|
+
shape: 'circle',
|
|
23083
|
+
size: 28,
|
|
23084
|
+
},
|
|
23085
|
+
};
|
|
23086
|
+
// Sensible defaults for avatar column
|
|
23087
|
+
col.align = col.align || 'center';
|
|
23088
|
+
if (!col.width)
|
|
23089
|
+
col.width = '56px';
|
|
23090
|
+
return;
|
|
23091
|
+
}
|
|
23037
23092
|
}
|
|
23038
23093
|
/**
|
|
23039
23094
|
* Check if a value is a valid ColumnDataType
|
|
@@ -23170,6 +23225,13 @@ class PraxisTable {
|
|
|
23170
23225
|
if (this.paginator) {
|
|
23171
23226
|
this.paginator.length = page.totalElements;
|
|
23172
23227
|
}
|
|
23228
|
+
// Keep config pagination length in sync for template bindings
|
|
23229
|
+
try {
|
|
23230
|
+
const beh = this.config.behavior || (this.config.behavior = {});
|
|
23231
|
+
const pag = beh.pagination || (beh.pagination = {});
|
|
23232
|
+
pag.totalItems = page.totalElements;
|
|
23233
|
+
}
|
|
23234
|
+
catch { }
|
|
23173
23235
|
},
|
|
23174
23236
|
error: (err) => {
|
|
23175
23237
|
console.error('[PraxisTable] Data load error', err);
|