@seip/bluebird-js 0.2.0 → 0.2.1

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.
@@ -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 {
@@ -227,6 +229,69 @@ export function Drawer(props: {
227
229
  className?: string;
228
230
  children?: ReactNode;
229
231
  }): ReactNode;
232
+ export interface DataTableColumn<T = any> {
233
+ key: string;
234
+ label: ReactNode;
235
+ sortable?: boolean;
236
+ /** Include in the search (default true). */
237
+ searchable?: boolean;
238
+ /** Card title on narrow screens (defaults to the first column). */
239
+ primary?: boolean;
240
+ /** `false` hides it on cards, `"details"` moves it behind "Show details". */
241
+ mobile?: boolean | "details";
242
+ align?: "left" | "right" | "center";
243
+ /** Right-aligned monospace tabular numbers. */
244
+ numeric?: boolean;
245
+ render?: (row: T, index: number) => ReactNode;
246
+ /** Raw value for search and sorting when it differs from `row[key]`. */
247
+ value?: (row: T) => any;
248
+ className?: string;
249
+ }
250
+
251
+ export interface DataTableAction<T = any> {
252
+ key?: string;
253
+ label: string;
254
+ /** Icon-only button when set; text button otherwise. */
255
+ icon?: ReactNode;
256
+ onClick?: (row: T) => any;
257
+ /** Link pattern (`"/users/:id"`) or builder. */
258
+ href?: string | ((row: T) => string);
259
+ variant?: "default" | "danger";
260
+ /** Ask in a dialog first (`true` or custom text). */
261
+ confirm?: boolean | string;
262
+ hidden?: (row: T) => boolean;
263
+ }
264
+
265
+ export interface DataTableProps<T = any> {
266
+ rows?: T[];
267
+ /** Server endpoint returning `res.paginate()` or `Model.paginate()` results; receives `?page&limit&search&sort&order`. */
268
+ url?: string;
269
+ params?: Record<string, any>;
270
+ columns: DataTableColumn<T>[];
271
+ searchable?: boolean;
272
+ searchPlaceholder?: string;
273
+ pageSize?: number;
274
+ pageSizes?: number[];
275
+ defaultSort?: { key: string; dir?: "asc" | "desc" };
276
+ onView?: ((row: T) => any) | string;
277
+ onEdit?: ((row: T) => any) | string;
278
+ onDelete?: (row: T) => any;
279
+ deleteConfirm?: boolean | string;
280
+ actions?: DataTableAction<T>[];
281
+ onRowClick?: (row: T) => void;
282
+ rowKey?: (row: T, index: number) => string | number;
283
+ loading?: boolean;
284
+ empty?: ReactNode;
285
+ toolbar?: ReactNode;
286
+ caption?: string;
287
+ className?: string;
288
+ ref?: import("react").Ref<{ reload: () => void }>;
289
+ }
290
+
291
+ /** Responsive data table: search, sort, pagination, row actions with delete confirmation, cards on narrow screens, local or server data. */
292
+ export function DataTable<T = any>(props: DataTableProps<T>): ReactNode;
293
+ export function normalizeTableResponse(body: any): { rows: any[]; total: number };
294
+
230
295
  export function Skeleton(props?: { className?: string; style?: Record<string, any> }): ReactNode;
231
296
  export function PageSkeleton(): ReactNode;
232
297
  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.0",
3
+ "version": "0.2.1",
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",