@telamonjs/ui 1.3.1 → 1.4.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +7 -8
  3. package/dist/components/data/DataTableActions.js +4 -3
  4. package/dist/data/ExportMenu.js +6 -3
  5. package/dist/data/InfiniteList.js +6 -2
  6. package/dist/data/datatable/sort-field.d.ts +14 -0
  7. package/dist/data/datatable/sort-field.js +24 -0
  8. package/dist/data/datatable/useDataTableInstance.js +3 -2
  9. package/dist/data/exportUtils.d.ts +14 -9
  10. package/dist/data/exportUtils.js +56 -56
  11. package/dist/data/missing-peer.d.ts +17 -0
  12. package/dist/data/missing-peer.js +22 -0
  13. package/dist/data/xlsx-writer.d.ts +24 -0
  14. package/dist/data/xlsx-writer.js +141 -0
  15. package/dist/exports/types-constants.d.ts +1 -1
  16. package/dist/exports/types-constants.js +1 -1
  17. package/dist/i18n/messages/en/data.d.ts +1 -0
  18. package/dist/i18n/messages/en/data.js +1 -0
  19. package/dist/i18n/messages/en/index.d.ts +3 -0
  20. package/dist/i18n/messages/en/queue.d.ts +2 -0
  21. package/dist/i18n/messages/en/queue.js +3 -1
  22. package/dist/i18n/messages/es/data.d.ts +1 -0
  23. package/dist/i18n/messages/es/data.js +1 -0
  24. package/dist/i18n/messages/es/index.d.ts +3 -0
  25. package/dist/i18n/messages/es/queue.d.ts +2 -0
  26. package/dist/i18n/messages/es/queue.js +3 -1
  27. package/dist/i18n/messages/pt-BR/data.d.ts +1 -0
  28. package/dist/i18n/messages/pt-BR/data.js +1 -0
  29. package/dist/i18n/messages/pt-BR/index.d.ts +3 -0
  30. package/dist/i18n/messages/pt-BR/queue.d.ts +2 -0
  31. package/dist/i18n/messages/pt-BR/queue.js +3 -1
  32. package/dist/i18n/use-t.d.ts +3 -0
  33. package/dist/pages/ListPage.js +6 -1
  34. package/dist/queue/components/DispatchJobModal.js +157 -115
  35. package/dist/queue/components/JobEventTimeline.js +321 -210
  36. package/dist/queue/hooks/use-queue-events-timeline.d.ts +7 -1
  37. package/dist/queue/hooks/use-queue-events-timeline.js +14 -43
  38. package/dist/queue/hooks/use-queue-sse.js +3 -1
  39. package/dist/queue/types.d.ts +2 -0
  40. package/dist/server/pagination/factory.js +5 -1
  41. package/dist/server/pagination/types.d.ts +6 -2
  42. package/dist/server/pagination/utils.d.ts +6 -3
  43. package/dist/server/pagination/utils.js +13 -7
  44. package/dist/server/prisma-helpers.d.ts +27 -19
  45. package/dist/server/prisma-helpers.js +37 -19
  46. package/dist/stores/datatable-store.d.ts +0 -4
  47. package/dist/stores/datatable-store.js +0 -5
  48. package/dist/stores/form-store.d.ts +5 -0
  49. package/dist/stores/form-store.js +8 -4
  50. package/dist/stores/index.d.ts +1 -1
  51. package/dist/stores/index.js +1 -3
  52. package/dist/stores/sidebar-store.d.ts +1 -1
  53. package/dist/types/actions.d.ts +4 -1
  54. package/dist/types/crud.d.ts +14 -1
  55. package/dist/types/system-config.d.ts +5 -0
  56. package/dist/ui/chart.d.ts +22 -27
  57. package/dist/ui/chart.js +2 -8
  58. package/dist/ui/form.d.ts +1 -1
  59. package/package.json +67 -64
@@ -0,0 +1,141 @@
1
+ // src/data/xlsx-writer.ts
2
+ var MAX_CELL_LENGTH = 32767;
3
+ var NS = "http://schemas.openxmlformats.org";
4
+ var REL = `${NS}/officeDocument/2006/relationships`;
5
+ var XML_HEAD = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
6
+ var INVALID_XML = /[\u0000-\u0008\u000B\u000C\u000E-\u001F￾￿]/g;
7
+ function escapeXml(value) {
8
+ return value.replace(INVALID_XML, "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
9
+ }
10
+ function sanitizeSheetName(name) {
11
+ const clean = name.replace(/[\\/?*[\]:]/g, " ").trim().slice(0, 31).replace(/^'+|'+$/g, "").trim();
12
+ return clean || "Sheet1";
13
+ }
14
+ function columnName(index) {
15
+ let name = "";
16
+ for (let n = index + 1; n > 0; n = Math.floor((n - 1) / 26)) {
17
+ name = String.fromCharCode(65 + (n - 1) % 26) + name;
18
+ }
19
+ return name;
20
+ }
21
+ function cellXml(value, ref, style) {
22
+ if (typeof value === "number" && Number.isFinite(value)) {
23
+ return `<c r="${ref}"${style}><v>${value}</v></c>`;
24
+ }
25
+ const text = String(value).slice(0, MAX_CELL_LENGTH);
26
+ if (text === "") return "";
27
+ return `<c r="${ref}"${style} t="inlineStr"><is><t xml:space="preserve">${escapeXml(text)}</t></is></c>`;
28
+ }
29
+ function sheetXml({ headers, rows, widths }) {
30
+ const cols = widths?.length ? `<cols>${widths.map((w, i) => `<col min="${i + 1}" max="${i + 1}" width="${w + 1}" customWidth="1"/>`).join("")}</cols>` : "";
31
+ const rowXml = (cells, r, style) => `<row r="${r}">${cells.map((v, c) => cellXml(v, `${columnName(c)}${r}`, style)).join("")}</row>`;
32
+ const body = [rowXml(headers, 1, ' s="1"'), ...rows.map((row, i) => rowXml(row, i + 2, ""))];
33
+ return `${XML_HEAD}<worksheet xmlns="${NS}/spreadsheetml/2006/main">${cols}<sheetData>${body.join("")}</sheetData></worksheet>`;
34
+ }
35
+ var STYLES = `${XML_HEAD}<styleSheet xmlns="${NS}/spreadsheetml/2006/main"><fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font></fonts><fills count="3"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill><fill><patternFill patternType="solid"><fgColor rgb="FFF3F4F6"/></patternFill></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`;
36
+ function parts(sheet) {
37
+ const ct = "application/vnd.openxmlformats";
38
+ return [
39
+ [
40
+ "[Content_Types].xml",
41
+ `${XML_HEAD}<Types xmlns="${NS}/package/2006/content-types"><Default Extension="rels" ContentType="${ct}-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="${ct}-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="${ct}-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="${ct}-officedocument.spreadsheetml.styles+xml"/></Types>`
42
+ ],
43
+ [
44
+ "_rels/.rels",
45
+ `${XML_HEAD}<Relationships xmlns="${NS}/package/2006/relationships"><Relationship Id="rId1" Type="${REL}/officeDocument" Target="xl/workbook.xml"/></Relationships>`
46
+ ],
47
+ [
48
+ "xl/workbook.xml",
49
+ `${XML_HEAD}<workbook xmlns="${NS}/spreadsheetml/2006/main" xmlns:r="${REL}"><sheets><sheet name="${escapeXml(sanitizeSheetName(sheet.name))}" sheetId="1" r:id="rId1"/></sheets></workbook>`
50
+ ],
51
+ [
52
+ "xl/_rels/workbook.xml.rels",
53
+ `${XML_HEAD}<Relationships xmlns="${NS}/package/2006/relationships"><Relationship Id="rId1" Type="${REL}/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="${REL}/styles" Target="styles.xml"/></Relationships>`
54
+ ],
55
+ ["xl/styles.xml", STYLES],
56
+ ["xl/worksheets/sheet1.xml", sheetXml(sheet)]
57
+ ];
58
+ }
59
+ var CRC_TABLE = Uint32Array.from({ length: 256 }, (_, n) => {
60
+ let c = n;
61
+ for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
62
+ return c >>> 0;
63
+ });
64
+ function crc32(data) {
65
+ let c = 4294967295;
66
+ for (const byte of data) c = CRC_TABLE[(c ^ byte) & 255] ^ c >>> 8;
67
+ return (c ^ 4294967295) >>> 0;
68
+ }
69
+ async function deflateRaw(data) {
70
+ if (typeof CompressionStream === "undefined") return null;
71
+ try {
72
+ const stream = new CompressionStream("deflate-raw");
73
+ const writer = stream.writable.getWriter();
74
+ const [buffer] = await Promise.all([
75
+ new Response(stream.readable).arrayBuffer(),
76
+ writer.write(data).then(() => writer.close())
77
+ ]);
78
+ return new Uint8Array(buffer);
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+ async function zip(files) {
84
+ const encoder = new TextEncoder();
85
+ const chunks = [];
86
+ const central = [];
87
+ let offset = 0;
88
+ for (const [path, content] of files) {
89
+ const name = encoder.encode(path);
90
+ const raw = encoder.encode(content);
91
+ const deflated = await deflateRaw(raw);
92
+ const data = deflated && deflated.length < raw.length ? deflated : raw;
93
+ const method = data === raw ? 0 : 8;
94
+ const crc = crc32(raw);
95
+ const local = new DataView(new ArrayBuffer(30));
96
+ local.setUint32(0, 67324752, true);
97
+ local.setUint16(4, 20, true);
98
+ local.setUint16(8, method, true);
99
+ local.setUint16(12, 33, true);
100
+ local.setUint32(14, crc, true);
101
+ local.setUint32(18, data.length, true);
102
+ local.setUint32(22, raw.length, true);
103
+ local.setUint16(26, name.length, true);
104
+ const dir = new DataView(new ArrayBuffer(46));
105
+ dir.setUint32(0, 33639248, true);
106
+ dir.setUint16(4, 20, true);
107
+ dir.setUint16(6, 20, true);
108
+ dir.setUint16(10, method, true);
109
+ dir.setUint16(14, 33, true);
110
+ dir.setUint32(16, crc, true);
111
+ dir.setUint32(20, data.length, true);
112
+ dir.setUint32(24, raw.length, true);
113
+ dir.setUint16(28, name.length, true);
114
+ dir.setUint32(42, offset, true);
115
+ chunks.push(new Uint8Array(local.buffer), name, data);
116
+ central.push(new Uint8Array(dir.buffer), name);
117
+ offset += 30 + name.length + data.length;
118
+ }
119
+ const centralSize = central.reduce((sum, c) => sum + c.length, 0);
120
+ const end = new DataView(new ArrayBuffer(22));
121
+ end.setUint32(0, 101010256, true);
122
+ end.setUint16(8, files.length, true);
123
+ end.setUint16(10, files.length, true);
124
+ end.setUint32(12, centralSize, true);
125
+ end.setUint32(16, offset, true);
126
+ const all = [...chunks, ...central, new Uint8Array(end.buffer)];
127
+ const out = new Uint8Array(all.reduce((sum, c) => sum + c.length, 0));
128
+ let at = 0;
129
+ for (const c of all) {
130
+ out.set(c, at);
131
+ at += c.length;
132
+ }
133
+ return out;
134
+ }
135
+ function writeXlsx(sheet) {
136
+ return zip(parts(sheet));
137
+ }
138
+ export {
139
+ sanitizeSheetName,
140
+ writeXlsx
141
+ };
@@ -7,4 +7,4 @@ export type { ModuleMetadata, ListConfig, ExportAllOptions, CrudColumnDef, FormC
7
7
  export type { ColorPreset, StatItem, HeaderBadgeConfig, HeaderStatsConfig, DialogHeaderConfig, DialogHeaderProps, StatsGridProps, } from '../types/dialog-header';
8
8
  export type { MenuItem, SingleMenuItem, GroupMenuItem, SeparatorMenuItem, MenuItemType, MenuVariant, IconComponent, } from '../types/menu';
9
9
  export type { Density, GapSize, DialogSize, DialogHeight, FieldLayout, CardFieldLayout, } from '../utils/spacing';
10
- export declare const version = "1.3.1";
10
+ export declare const version = "1.4.0";
@@ -1,6 +1,6 @@
1
1
  // src/exports/types-constants.ts
2
2
  import { createPaginatedResponse, asQueryFn } from "../types/pagination.js";
3
- var version = "1.3.1";
3
+ var version = "1.4.0";
4
4
  export {
5
5
  asQueryFn,
6
6
  createPaginatedResponse,
@@ -15,6 +15,7 @@ export declare const data: {
15
15
  noDataToExport: string;
16
16
  exportSuccess: string;
17
17
  exportError: string;
18
+ exportMissingPeer: string;
18
19
  exportFetching: string;
19
20
  exportCancelled: string;
20
21
  exportTruncated: string;
@@ -16,6 +16,7 @@ var data = {
16
16
  noDataToExport: "No data to export",
17
17
  exportSuccess: "{format} exported successfully ({scope})",
18
18
  exportError: "Error exporting data",
19
+ exportMissingPeer: "This export needs packages the app has not installed: {packages}",
19
20
  exportFetching: "Fetching records to export: {loaded, number} of {total, number}",
20
21
  exportCancelled: "Export cancelled",
21
22
  exportTruncated: "Exported the first {count, number} of {total, number} records (export limit)",
@@ -211,6 +211,7 @@ export declare const en: {
211
211
  noDataToExport: string;
212
212
  exportSuccess: string;
213
213
  exportError: string;
214
+ exportMissingPeer: string;
214
215
  exportFetching: string;
215
216
  exportCancelled: string;
216
217
  exportTruncated: string;
@@ -732,6 +733,8 @@ export declare const en: {
732
733
  removeJob: string;
733
734
  noJobsProcessing: string;
734
735
  statusInProgress: string;
736
+ repeat: string;
737
+ repeatHint: string;
735
738
  };
736
739
  history: {
737
740
  title: string;
@@ -145,6 +145,8 @@ export declare const queue: {
145
145
  removeJob: string;
146
146
  noJobsProcessing: string;
147
147
  statusInProgress: string;
148
+ repeat: string;
149
+ repeatHint: string;
148
150
  };
149
151
  history: {
150
152
  title: string;
@@ -145,7 +145,9 @@ var queue = {
145
145
  retryJob: "Retry job",
146
146
  removeJob: "Remove job",
147
147
  noJobsProcessing: "No jobs processing",
148
- statusInProgress: "In progress"
148
+ statusInProgress: "In progress",
149
+ repeat: "Recurring",
150
+ repeatHint: "Iteration of a scheduled (repeating) job"
149
151
  },
150
152
  history: {
151
153
  title: "Execution History",
@@ -15,6 +15,7 @@ export declare const data: {
15
15
  noDataToExport: string;
16
16
  exportSuccess: string;
17
17
  exportError: string;
18
+ exportMissingPeer: string;
18
19
  exportFetching: string;
19
20
  exportCancelled: string;
20
21
  exportTruncated: string;
@@ -16,6 +16,7 @@ var data = {
16
16
  noDataToExport: "Sin datos para exportar",
17
17
  exportSuccess: "{format} exportado con \xE9xito ({scope})",
18
18
  exportError: "Error al exportar datos",
19
+ exportMissingPeer: "Esta exportaci\xF3n necesita paquetes que la app no instal\xF3: {packages}",
19
20
  exportFetching: "Buscando registros para exportar: {loaded, number} de {total, number}",
20
21
  exportCancelled: "Exportaci\xF3n cancelada",
21
22
  exportTruncated: "Se exportaron los primeros {count, number} de {total, number} registros (l\xEDmite de exportaci\xF3n)",
@@ -211,6 +211,7 @@ export declare const es: {
211
211
  noDataToExport: string;
212
212
  exportSuccess: string;
213
213
  exportError: string;
214
+ exportMissingPeer: string;
214
215
  exportFetching: string;
215
216
  exportCancelled: string;
216
217
  exportTruncated: string;
@@ -732,6 +733,8 @@ export declare const es: {
732
733
  removeJob: string;
733
734
  noJobsProcessing: string;
734
735
  statusInProgress: string;
736
+ repeat: string;
737
+ repeatHint: string;
735
738
  };
736
739
  history: {
737
740
  title: string;
@@ -145,6 +145,8 @@ export declare const queue: {
145
145
  removeJob: string;
146
146
  noJobsProcessing: string;
147
147
  statusInProgress: string;
148
+ repeat: string;
149
+ repeatHint: string;
148
150
  };
149
151
  history: {
150
152
  title: string;
@@ -145,7 +145,9 @@ var queue = {
145
145
  retryJob: "Reprocesar job",
146
146
  removeJob: "Quitar job",
147
147
  noJobsProcessing: "No hay jobs en procesamiento",
148
- statusInProgress: "En curso"
148
+ statusInProgress: "En curso",
149
+ repeat: "Recurrente",
150
+ repeatHint: "Iteraci\xF3n de un job programado (recurrente)"
149
151
  },
150
152
  history: {
151
153
  title: "Historial de Ejecuciones",
@@ -15,6 +15,7 @@ export declare const data: {
15
15
  readonly noDataToExport: "Nenhum dado para exportar";
16
16
  readonly exportSuccess: "{format} exportado com sucesso ({scope})";
17
17
  readonly exportError: "Erro ao exportar dados";
18
+ readonly exportMissingPeer: "Esta exportação precisa de pacotes que o app não instalou: {packages}";
18
19
  readonly exportFetching: "Buscando registros para exportar: {loaded, number} de {total, number}";
19
20
  readonly exportCancelled: "Exportação cancelada";
20
21
  readonly exportTruncated: "Exportados os primeiros {count, number} de {total, number} registros (limite da exportação)";
@@ -16,6 +16,7 @@ var data = {
16
16
  noDataToExport: "Nenhum dado para exportar",
17
17
  exportSuccess: "{format} exportado com sucesso ({scope})",
18
18
  exportError: "Erro ao exportar dados",
19
+ exportMissingPeer: "Esta exporta\xE7\xE3o precisa de pacotes que o app n\xE3o instalou: {packages}",
19
20
  exportFetching: "Buscando registros para exportar: {loaded, number} de {total, number}",
20
21
  exportCancelled: "Exporta\xE7\xE3o cancelada",
21
22
  exportTruncated: "Exportados os primeiros {count, number} de {total, number} registros (limite da exporta\xE7\xE3o)",
@@ -211,6 +211,7 @@ export declare const ptBR: {
211
211
  readonly noDataToExport: "Nenhum dado para exportar";
212
212
  readonly exportSuccess: "{format} exportado com sucesso ({scope})";
213
213
  readonly exportError: "Erro ao exportar dados";
214
+ readonly exportMissingPeer: "Esta exportação precisa de pacotes que o app não instalou: {packages}";
214
215
  readonly exportFetching: "Buscando registros para exportar: {loaded, number} de {total, number}";
215
216
  readonly exportCancelled: "Exportação cancelada";
216
217
  readonly exportTruncated: "Exportados os primeiros {count, number} de {total, number} registros (limite da exportação)";
@@ -732,6 +733,8 @@ export declare const ptBR: {
732
733
  readonly removeJob: "Remover job";
733
734
  readonly noJobsProcessing: "Nenhum job em processamento";
734
735
  readonly statusInProgress: "Em andamento";
736
+ readonly repeat: "Recorrente";
737
+ readonly repeatHint: "Iteração de um job agendado (recorrente)";
735
738
  };
736
739
  readonly history: {
737
740
  readonly title: "Histórico de Execuções";
@@ -145,6 +145,8 @@ export declare const queue: {
145
145
  readonly removeJob: "Remover job";
146
146
  readonly noJobsProcessing: "Nenhum job em processamento";
147
147
  readonly statusInProgress: "Em andamento";
148
+ readonly repeat: "Recorrente";
149
+ readonly repeatHint: "Iteração de um job agendado (recorrente)";
148
150
  };
149
151
  readonly history: {
150
152
  readonly title: "Histórico de Execuções";
@@ -145,7 +145,9 @@ var queue = {
145
145
  retryJob: "Reprocessar job",
146
146
  removeJob: "Remover job",
147
147
  noJobsProcessing: "Nenhum job em processamento",
148
- statusInProgress: "Em andamento"
148
+ statusInProgress: "Em andamento",
149
+ repeat: "Recorrente",
150
+ repeatHint: "Itera\xE7\xE3o de um job agendado (recorrente)"
149
151
  },
150
152
  history: {
151
153
  title: "Hist\xF3rico de Execu\xE7\xF5es",
@@ -213,6 +213,7 @@ export declare function useTelamonjsT(): import("next-intl")._Translator<import(
213
213
  readonly noDataToExport: "Nenhum dado para exportar";
214
214
  readonly exportSuccess: "{format} exportado com sucesso ({scope})";
215
215
  readonly exportError: "Erro ao exportar dados";
216
+ readonly exportMissingPeer: "Esta exportação precisa de pacotes que o app não instalou: {packages}";
216
217
  readonly exportFetching: "Buscando registros para exportar: {loaded, number} de {total, number}";
217
218
  readonly exportCancelled: "Exportação cancelada";
218
219
  readonly exportTruncated: "Exportados os primeiros {count, number} de {total, number} registros (limite da exportação)";
@@ -734,6 +735,8 @@ export declare function useTelamonjsT(): import("next-intl")._Translator<import(
734
735
  readonly removeJob: "Remover job";
735
736
  readonly noJobsProcessing: "Nenhum job em processamento";
736
737
  readonly statusInProgress: "Em andamento";
738
+ readonly repeat: "Recorrente";
739
+ readonly repeatHint: "Iteração de um job agendado (recorrente)";
737
740
  };
738
741
  readonly history: {
739
742
  readonly title: "Histórico de Execuções";
@@ -24,6 +24,7 @@ import { ListPageTable } from "./list-page/ListPageTable.js";
24
24
  import { ListPageDialogs } from "./list-page/ListPageDialogs.js";
25
25
  import { useListPageExport } from "./list-page/useListPageExport.js";
26
26
  import { applyCrudPermissions } from "./list-page/apply-crud-permissions.js";
27
+ import { toSortParam } from "../data/datatable/sort-field.js";
27
28
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
29
  var logger = withComponent("ListPage");
29
30
  function ListPage({
@@ -89,7 +90,11 @@ function ListPage({
89
90
  list.defaultSortOrder
90
91
  ]);
91
92
  const columnFilters = useTableColumnFilters(tableId);
92
- const sorting = useTableSorting(tableId);
93
+ const storeSorting = useTableSorting(tableId);
94
+ const sorting = useMemo(
95
+ () => toSortParam(storeSorting, list.columns, list.sortParam),
96
+ [storeSorting, list.columns, list.sortParam]
97
+ );
93
98
  const search = useTableGlobalFilter(tableId);
94
99
  const page = useTablePage(tableId);
95
100
  const pageSize = useTablePageSize(tableId);