@seip/bluebird-js 0.2.0 → 0.2.2
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/AGENTS.md +5 -1
- package/README.md +64 -0
- package/app/resources/html/layouts/main.html +2 -1
- package/app/resources/html/table.html +15 -0
- package/app/resources/layouts/AppLayout.jsx +4 -1
- package/app/resources/pages/Dashboard.jsx +27 -32
- package/app/resources/pages/TableDemo.jsx +85 -0
- package/app/resources/routes.jsx +5 -0
- package/app/resources/spa.js +6 -0
- package/app/routes/api.js +44 -0
- package/app/routes/web.js +31 -1
- package/core/cache.js +17 -0
- package/core/cli/migrate.js +57 -31
- package/core/cli/route.js +8 -7
- package/core/index.d.ts +1288 -1286
- package/core/react/client/api.js +2 -0
- package/core/react/client/components.js +4 -1
- package/core/react/client/datatable.js +595 -0
- package/core/react/client/i18n.js +102 -0
- package/core/react/client/index.d.ts +66 -0
- package/core/react/client/index.js +1 -0
- package/package.json +1 -1
- package/public/js/bluebird.js +732 -6
- package/templates/_base/app/resources/html/layouts/main.html +1 -1
|
@@ -42,6 +42,23 @@ export const MESSAGES = {
|
|
|
42
42
|
"copy.done": "Copied to clipboard",
|
|
43
43
|
"auth.deniedTitle": "Access denied",
|
|
44
44
|
"auth.deniedText": "You do not have permission to view this section.",
|
|
45
|
+
"table.search": "Search...",
|
|
46
|
+
"table.empty": "No results",
|
|
47
|
+
"table.rowsPerPage": "Rows per page",
|
|
48
|
+
"table.range": "{from}-{to} of {total}",
|
|
49
|
+
"table.prev": "Previous page",
|
|
50
|
+
"table.next": "Next page",
|
|
51
|
+
"table.page": "Page {n} of {total}",
|
|
52
|
+
"table.actions": "Actions",
|
|
53
|
+
"table.view": "View",
|
|
54
|
+
"table.edit": "Edit",
|
|
55
|
+
"table.delete": "Delete",
|
|
56
|
+
"table.confirmTitle": "Delete this record?",
|
|
57
|
+
"table.confirmText": "This action cannot be undone.",
|
|
58
|
+
"table.cancel": "Cancel",
|
|
59
|
+
"table.more": "Show details",
|
|
60
|
+
"table.less": "Hide details",
|
|
61
|
+
"table.sortBy": "Sort by {column}",
|
|
45
62
|
},
|
|
46
63
|
es: {
|
|
47
64
|
"toast.info": "Info",
|
|
@@ -79,6 +96,23 @@ export const MESSAGES = {
|
|
|
79
96
|
"copy.done": "Copiado al portapapeles",
|
|
80
97
|
"auth.deniedTitle": "Acceso denegado",
|
|
81
98
|
"auth.deniedText": "No tienes permiso para ver esta sección.",
|
|
99
|
+
"table.search": "Buscar...",
|
|
100
|
+
"table.empty": "Sin resultados",
|
|
101
|
+
"table.rowsPerPage": "Filas por página",
|
|
102
|
+
"table.range": "{from}-{to} de {total}",
|
|
103
|
+
"table.prev": "Página anterior",
|
|
104
|
+
"table.next": "Página siguiente",
|
|
105
|
+
"table.page": "Página {n} de {total}",
|
|
106
|
+
"table.actions": "Acciones",
|
|
107
|
+
"table.view": "Ver",
|
|
108
|
+
"table.edit": "Editar",
|
|
109
|
+
"table.delete": "Eliminar",
|
|
110
|
+
"table.confirmTitle": "¿Eliminar este registro?",
|
|
111
|
+
"table.confirmText": "Esta acción no se puede deshacer.",
|
|
112
|
+
"table.cancel": "Cancelar",
|
|
113
|
+
"table.more": "Ver detalles",
|
|
114
|
+
"table.less": "Ocultar detalles",
|
|
115
|
+
"table.sortBy": "Ordenar por {column}",
|
|
82
116
|
},
|
|
83
117
|
pt: {
|
|
84
118
|
"toast.info": "Info",
|
|
@@ -116,6 +150,23 @@ export const MESSAGES = {
|
|
|
116
150
|
"copy.done": "Copiado para a área de transferência",
|
|
117
151
|
"auth.deniedTitle": "Acesso negado",
|
|
118
152
|
"auth.deniedText": "Você não tem permissão para ver esta seção.",
|
|
153
|
+
"table.search": "Pesquisar...",
|
|
154
|
+
"table.empty": "Nenhum resultado",
|
|
155
|
+
"table.rowsPerPage": "Linhas por página",
|
|
156
|
+
"table.range": "{from}-{to} de {total}",
|
|
157
|
+
"table.prev": "Página anterior",
|
|
158
|
+
"table.next": "Próxima página",
|
|
159
|
+
"table.page": "Página {n} de {total}",
|
|
160
|
+
"table.actions": "Ações",
|
|
161
|
+
"table.view": "Ver",
|
|
162
|
+
"table.edit": "Editar",
|
|
163
|
+
"table.delete": "Excluir",
|
|
164
|
+
"table.confirmTitle": "Excluir este registro?",
|
|
165
|
+
"table.confirmText": "Esta ação não pode ser desfeita.",
|
|
166
|
+
"table.cancel": "Cancelar",
|
|
167
|
+
"table.more": "Ver detalhes",
|
|
168
|
+
"table.less": "Ocultar detalhes",
|
|
169
|
+
"table.sortBy": "Ordenar por {column}",
|
|
119
170
|
},
|
|
120
171
|
fr: {
|
|
121
172
|
"toast.info": "Info",
|
|
@@ -153,6 +204,23 @@ export const MESSAGES = {
|
|
|
153
204
|
"copy.done": "Copié dans le presse-papiers",
|
|
154
205
|
"auth.deniedTitle": "Accès refusé",
|
|
155
206
|
"auth.deniedText": "Vous n'avez pas l'autorisation de voir cette section.",
|
|
207
|
+
"table.search": "Rechercher...",
|
|
208
|
+
"table.empty": "Aucun résultat",
|
|
209
|
+
"table.rowsPerPage": "Lignes par page",
|
|
210
|
+
"table.range": "{from}-{to} sur {total}",
|
|
211
|
+
"table.prev": "Page précédente",
|
|
212
|
+
"table.next": "Page suivante",
|
|
213
|
+
"table.page": "Page {n} sur {total}",
|
|
214
|
+
"table.actions": "Actions",
|
|
215
|
+
"table.view": "Voir",
|
|
216
|
+
"table.edit": "Modifier",
|
|
217
|
+
"table.delete": "Supprimer",
|
|
218
|
+
"table.confirmTitle": "Supprimer cet enregistrement ?",
|
|
219
|
+
"table.confirmText": "Cette action est irréversible.",
|
|
220
|
+
"table.cancel": "Annuler",
|
|
221
|
+
"table.more": "Voir les détails",
|
|
222
|
+
"table.less": "Masquer les détails",
|
|
223
|
+
"table.sortBy": "Trier par {column}",
|
|
156
224
|
},
|
|
157
225
|
de: {
|
|
158
226
|
"toast.info": "Info",
|
|
@@ -190,6 +258,23 @@ export const MESSAGES = {
|
|
|
190
258
|
"copy.done": "In die Zwischenablage kopiert",
|
|
191
259
|
"auth.deniedTitle": "Zugriff verweigert",
|
|
192
260
|
"auth.deniedText": "Du hast keine Berechtigung, diesen Bereich zu sehen.",
|
|
261
|
+
"table.search": "Suchen...",
|
|
262
|
+
"table.empty": "Keine Ergebnisse",
|
|
263
|
+
"table.rowsPerPage": "Zeilen pro Seite",
|
|
264
|
+
"table.range": "{from}-{to} von {total}",
|
|
265
|
+
"table.prev": "Vorherige Seite",
|
|
266
|
+
"table.next": "Nächste Seite",
|
|
267
|
+
"table.page": "Seite {n} von {total}",
|
|
268
|
+
"table.actions": "Aktionen",
|
|
269
|
+
"table.view": "Ansehen",
|
|
270
|
+
"table.edit": "Bearbeiten",
|
|
271
|
+
"table.delete": "Löschen",
|
|
272
|
+
"table.confirmTitle": "Diesen Eintrag löschen?",
|
|
273
|
+
"table.confirmText": "Diese Aktion kann nicht rückgängig gemacht werden.",
|
|
274
|
+
"table.cancel": "Abbrechen",
|
|
275
|
+
"table.more": "Details anzeigen",
|
|
276
|
+
"table.less": "Details ausblenden",
|
|
277
|
+
"table.sortBy": "Nach {column} sortieren",
|
|
193
278
|
},
|
|
194
279
|
it: {
|
|
195
280
|
"toast.info": "Info",
|
|
@@ -227,6 +312,23 @@ export const MESSAGES = {
|
|
|
227
312
|
"copy.done": "Copiato negli appunti",
|
|
228
313
|
"auth.deniedTitle": "Accesso negato",
|
|
229
314
|
"auth.deniedText": "Non hai il permesso di vedere questa sezione.",
|
|
315
|
+
"table.search": "Cerca...",
|
|
316
|
+
"table.empty": "Nessun risultato",
|
|
317
|
+
"table.rowsPerPage": "Righe per pagina",
|
|
318
|
+
"table.range": "{from}-{to} di {total}",
|
|
319
|
+
"table.prev": "Pagina precedente",
|
|
320
|
+
"table.next": "Pagina successiva",
|
|
321
|
+
"table.page": "Pagina {n} di {total}",
|
|
322
|
+
"table.actions": "Azioni",
|
|
323
|
+
"table.view": "Vedi",
|
|
324
|
+
"table.edit": "Modifica",
|
|
325
|
+
"table.delete": "Elimina",
|
|
326
|
+
"table.confirmTitle": "Eliminare questo record?",
|
|
327
|
+
"table.confirmText": "Questa azione non può essere annullata.",
|
|
328
|
+
"table.cancel": "Annulla",
|
|
329
|
+
"table.more": "Mostra dettagli",
|
|
330
|
+
"table.less": "Nascondi dettagli",
|
|
331
|
+
"table.sortBy": "Ordina per {column}",
|
|
230
332
|
},
|
|
231
333
|
};
|
|
232
334
|
|
|
@@ -44,6 +44,8 @@ export interface ApiRequestOptions {
|
|
|
44
44
|
headers?: Record<string, string>;
|
|
45
45
|
credentials?: RequestCredentials;
|
|
46
46
|
signal?: AbortSignal;
|
|
47
|
+
/** Return the whole JSON body (e.g. `{ data, pagination }` from `res.paginate`) instead of only `data`. */
|
|
48
|
+
raw?: boolean;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
export interface ApiClient {
|
|
@@ -157,6 +159,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
157
159
|
url?: string;
|
|
158
160
|
method?: string;
|
|
159
161
|
payload?: Record<string, any>;
|
|
162
|
+
/** Asks with `window.confirm()` first; nothing runs (neither `onClick` nor the `url` request) when cancelled. */
|
|
160
163
|
confirm?: string;
|
|
161
164
|
onSuccess?: (data: any) => void;
|
|
162
165
|
onError?: (error: ApiError) => void;
|
|
@@ -227,6 +230,69 @@ export function Drawer(props: {
|
|
|
227
230
|
className?: string;
|
|
228
231
|
children?: ReactNode;
|
|
229
232
|
}): ReactNode;
|
|
233
|
+
export interface DataTableColumn<T = any> {
|
|
234
|
+
key: string;
|
|
235
|
+
label: ReactNode;
|
|
236
|
+
sortable?: boolean;
|
|
237
|
+
/** Include in the search (default true). */
|
|
238
|
+
searchable?: boolean;
|
|
239
|
+
/** Card title on narrow screens (defaults to the first column). */
|
|
240
|
+
primary?: boolean;
|
|
241
|
+
/** `false` hides it on cards, `"details"` moves it behind "Show details". */
|
|
242
|
+
mobile?: boolean | "details";
|
|
243
|
+
align?: "left" | "right" | "center";
|
|
244
|
+
/** Right-aligned monospace tabular numbers. */
|
|
245
|
+
numeric?: boolean;
|
|
246
|
+
render?: (row: T, index: number) => ReactNode;
|
|
247
|
+
/** Raw value for search and sorting when it differs from `row[key]`. */
|
|
248
|
+
value?: (row: T) => any;
|
|
249
|
+
className?: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface DataTableAction<T = any> {
|
|
253
|
+
key?: string;
|
|
254
|
+
label: string;
|
|
255
|
+
/** Icon-only button when set; text button otherwise. */
|
|
256
|
+
icon?: ReactNode;
|
|
257
|
+
onClick?: (row: T) => any;
|
|
258
|
+
/** Link pattern (`"/users/:id"`) or builder. */
|
|
259
|
+
href?: string | ((row: T) => string);
|
|
260
|
+
variant?: "default" | "danger";
|
|
261
|
+
/** Ask in a dialog first (`true` or custom text). */
|
|
262
|
+
confirm?: boolean | string;
|
|
263
|
+
hidden?: (row: T) => boolean;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface DataTableProps<T = any> {
|
|
267
|
+
rows?: T[];
|
|
268
|
+
/** Server endpoint returning `res.paginate()` or `Model.paginate()` results; receives `?page&limit&search&sort&order`. */
|
|
269
|
+
url?: string;
|
|
270
|
+
params?: Record<string, any>;
|
|
271
|
+
columns: DataTableColumn<T>[];
|
|
272
|
+
searchable?: boolean;
|
|
273
|
+
searchPlaceholder?: string;
|
|
274
|
+
pageSize?: number;
|
|
275
|
+
pageSizes?: number[];
|
|
276
|
+
defaultSort?: { key: string; dir?: "asc" | "desc" };
|
|
277
|
+
onView?: ((row: T) => any) | string;
|
|
278
|
+
onEdit?: ((row: T) => any) | string;
|
|
279
|
+
onDelete?: (row: T) => any;
|
|
280
|
+
deleteConfirm?: boolean | string;
|
|
281
|
+
actions?: DataTableAction<T>[];
|
|
282
|
+
onRowClick?: (row: T) => void;
|
|
283
|
+
rowKey?: (row: T, index: number) => string | number;
|
|
284
|
+
loading?: boolean;
|
|
285
|
+
empty?: ReactNode;
|
|
286
|
+
toolbar?: ReactNode;
|
|
287
|
+
caption?: string;
|
|
288
|
+
className?: string;
|
|
289
|
+
ref?: import("react").Ref<{ reload: () => void }>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Responsive data table: search, sort, pagination, row actions with delete confirmation, cards on narrow screens, local or server data. */
|
|
293
|
+
export function DataTable<T = any>(props: DataTableProps<T>): ReactNode;
|
|
294
|
+
export function normalizeTableResponse(body: any): { rows: any[]; total: number };
|
|
295
|
+
|
|
230
296
|
export function Skeleton(props?: { className?: string; style?: Record<string, any> }): ReactNode;
|
|
231
297
|
export function PageSkeleton(): ReactNode;
|
|
232
298
|
export function ProgressBar(props?: { active?: boolean }): ReactNode;
|
|
@@ -13,6 +13,7 @@ export {
|
|
|
13
13
|
setAuthToken,
|
|
14
14
|
} from "./api.js";
|
|
15
15
|
export { createRouter } from "./router.js";
|
|
16
|
+
export { DataTable, normalizeTableResponse } from "./datatable.js";
|
|
16
17
|
export { MESSAGES, addMessages, getLocale, setLocale, t, useLocale } from "./i18n.js";
|
|
17
18
|
export {
|
|
18
19
|
AuthProvider,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seip/bluebird-js",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Performance-first Node.js framework: Express + HTML {{ }} SSR templates + React Router SPA with Vite, Tailwind CSS, JWT auth, BaseModel, smart migrations, and multi-level caching",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "core/app.js",
|