@telamonjs/ui 1.2.0 → 1.3.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.
- package/CHANGELOG.md +41 -0
- package/README.md +1 -1
- package/dist/components/data/DataTableActions.js +1 -0
- package/dist/components/data/action-access.d.ts +9 -2
- package/dist/components/data/action-access.js +10 -3
- package/dist/components/dialog/CrudDialogShell.d.ts +2 -0
- package/dist/components/dialog/CrudDialogShell.js +9 -7
- package/dist/components/dialog/DialogLoadingState.d.ts +16 -0
- package/dist/components/dialog/DialogLoadingState.js +16 -0
- package/dist/components/dialog/confirm-action-dialog.d.ts +12 -4
- package/dist/components/dialog/confirm-action-dialog.js +75 -14
- package/dist/components/dialog/create-dialog.js +1 -12
- package/dist/components/dialog/edit-dialog.js +5 -4
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/index.js +1 -2
- package/dist/components/dialog/view-dialog.js +5 -4
- package/dist/components/utilities/QueryErrorState.d.ts +47 -0
- package/dist/components/utilities/QueryErrorState.js +85 -0
- package/dist/data/DataTable.d.ts +2 -2
- package/dist/data/DataTable.js +2 -0
- package/dist/data/ExportMenu.d.ts +30 -3
- package/dist/data/ExportMenu.js +69 -5
- package/dist/data/datatable/TableToolbar.d.ts +3 -2
- package/dist/data/datatable/TableToolbar.js +30 -13
- package/dist/data/datatable/types.d.ts +9 -0
- package/dist/data/fetch-all-pages.d.ts +30 -0
- package/dist/data/fetch-all-pages.js +44 -0
- package/dist/exports/data-crud.d.ts +7 -3
- package/dist/exports/data-crud.js +4 -0
- package/dist/exports/types-constants.d.ts +2 -2
- package/dist/exports/types-constants.js +1 -1
- package/dist/i18n/messages/en/data.d.ts +3 -0
- package/dist/i18n/messages/en/data.js +3 -0
- package/dist/i18n/messages/en/index.d.ts +5 -0
- package/dist/i18n/messages/en/validation.d.ts +2 -0
- package/dist/i18n/messages/en/validation.js +2 -0
- package/dist/i18n/messages/es/data.d.ts +3 -0
- package/dist/i18n/messages/es/data.js +3 -0
- package/dist/i18n/messages/es/index.d.ts +5 -0
- package/dist/i18n/messages/es/validation.d.ts +2 -0
- package/dist/i18n/messages/es/validation.js +2 -0
- package/dist/i18n/messages/pt-BR/data.d.ts +3 -0
- package/dist/i18n/messages/pt-BR/data.js +3 -0
- package/dist/i18n/messages/pt-BR/index.d.ts +5 -0
- package/dist/i18n/messages/pt-BR/validation.d.ts +2 -0
- package/dist/i18n/messages/pt-BR/validation.js +2 -0
- package/dist/i18n/use-t.d.ts +5 -0
- package/dist/pages/ListPage.js +9 -13
- package/dist/pages/list-page/ListPageTable.d.ts +4 -2
- package/dist/pages/list-page/ListPageTable.js +3 -3
- package/dist/pages/list-page/ListPageToolbar.d.ts +4 -1
- package/dist/pages/list-page/ListPageToolbar.js +10 -4
- package/dist/pages/list-page/apply-crud-permissions.d.ts +4 -1
- package/dist/pages/list-page/apply-crud-permissions.js +20 -3
- package/dist/pages/list-page/types.d.ts +2 -16
- package/dist/pages/list-page/useListPageExport.d.ts +24 -0
- package/dist/pages/list-page/useListPageExport.js +54 -0
- package/dist/queue/components/tabs/TempoRealTab.js +21 -4
- package/dist/types/actions.d.ts +43 -4
- package/dist/types/crud.d.ts +48 -2
- package/package.json +1 -1
- package/dist/components/dialog/DialogErrorState.d.ts +0 -44
- package/dist/components/dialog/DialogErrorState.js +0 -57
package/dist/types/crud.d.ts
CHANGED
|
@@ -61,7 +61,8 @@ import type { z } from 'zod';
|
|
|
61
61
|
import type { UseQueryOptions, UseMutationOptions, QueryKey } from '@tanstack/react-query';
|
|
62
62
|
import type { ReactNode } from 'react';
|
|
63
63
|
import type { ActionConfig, DataTableActionsConfig } from './actions';
|
|
64
|
-
import type { PaginationParams, PaginatedResponse } from './pagination';
|
|
64
|
+
import type { PaginationParams, PaginatedResponse, SortField } from './pagination';
|
|
65
|
+
import type { ExportFormat } from '../data/ExportMenu';
|
|
65
66
|
import type { FormSection } from './forms/admin-form';
|
|
66
67
|
import type { DialogHeaderConfig } from './dialog-header';
|
|
67
68
|
import type { DialogSize, DialogHeight } from '../utils/spacing';
|
|
@@ -184,6 +185,27 @@ export interface ToolbarConfig {
|
|
|
184
185
|
/**
|
|
185
186
|
* List page configuration
|
|
186
187
|
*/
|
|
188
|
+
/** Current query of a ListPage, handed to `toolbarContent` (as a function) and `list.onExport` */
|
|
189
|
+
export interface ListQueryState {
|
|
190
|
+
/** Search box value, as typed */
|
|
191
|
+
search: string;
|
|
192
|
+
/** Every active filter: toolbar filters (resets dropped), column filters and `urlFilters` */
|
|
193
|
+
filters: Record<string, unknown>;
|
|
194
|
+
/** Current sort */
|
|
195
|
+
sorting: SortField[];
|
|
196
|
+
/**
|
|
197
|
+
* The params the list passes to `query.queryFn` (debounced search). `page`/`pageSize` are the
|
|
198
|
+
* paginated view's; set your own when fetching everything for an export.
|
|
199
|
+
*/
|
|
200
|
+
params: PaginationParams;
|
|
201
|
+
}
|
|
202
|
+
/** Options of `list.exportAll` */
|
|
203
|
+
export interface ExportAllOptions {
|
|
204
|
+
/** Rows per request (default: `list.defaultPageSize` or 50, what the list itself requests) */
|
|
205
|
+
pageSize?: number;
|
|
206
|
+
/** Row cap (default 10 000): past it the file holds the first rows and a warning says so */
|
|
207
|
+
maxRows?: number;
|
|
208
|
+
}
|
|
187
209
|
export interface ListConfig<T> {
|
|
188
210
|
/** Page title */
|
|
189
211
|
title: I18nText;
|
|
@@ -217,6 +239,22 @@ export interface ListConfig<T> {
|
|
|
217
239
|
enableExport?: boolean;
|
|
218
240
|
/** Export filename */
|
|
219
241
|
exportFilename?: string;
|
|
242
|
+
/**
|
|
243
|
+
* What "Export all" exports. By default, the rows already loaded in the browser — with
|
|
244
|
+
* infinite scroll, only the pages scrolled so far. `true` fetches every row matching the
|
|
245
|
+
* current search, filters and sort through `query.queryFn`, page by page, with a progress
|
|
246
|
+
* toast and Cancel, up to `maxRows` (10 000). For bigger exports, use `onExport`.
|
|
247
|
+
*/
|
|
248
|
+
exportAll?: boolean | ExportAllOptions;
|
|
249
|
+
/** Formats the export menu offers (default: Excel, CSV, PDF) */
|
|
250
|
+
exportFormats?: ExportFormat[];
|
|
251
|
+
/**
|
|
252
|
+
* App-side export, e.g. a file the server generates from the same query: the menu lists
|
|
253
|
+
* `exportFormats` only and calls this with the list's current query. Wins over `exportAll`;
|
|
254
|
+
* shows the export menu even without `enableExport`. Throw to show the export error toast;
|
|
255
|
+
* announcing success (or a queued job) is up to you.
|
|
256
|
+
*/
|
|
257
|
+
onExport?: (state: ListQueryState, format: ExportFormat) => unknown;
|
|
220
258
|
/** Toolbar config for embedded mode */
|
|
221
259
|
toolbar?: ToolbarConfig;
|
|
222
260
|
/**
|
|
@@ -538,11 +576,19 @@ export interface PagesConfig<T> {
|
|
|
538
576
|
*
|
|
539
577
|
* Checked with `can` when set (bypass roles, wildcards: pass
|
|
540
578
|
* `perm => checker.can(user, perm)` from `@telamonjs/permissions`), else against
|
|
541
|
-
* `actionsConfig.userPermissions`; with neither, everything is allowed
|
|
579
|
+
* `actionsConfig.userPermissions`; with neither, everything is allowed (and a
|
|
580
|
+
* development warning says so) — unless `failClosed` is set.
|
|
542
581
|
*/
|
|
543
582
|
export interface CrudPermissions {
|
|
544
583
|
/** Permission checker; wins over `actionsConfig.userPermissions` */
|
|
545
584
|
can?: (permission: string) => boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Deny instead of allow when there is no way to check: with neither `can` nor
|
|
587
|
+
* `actionsConfig.userPermissions` (a missing hook, a session still loading),
|
|
588
|
+
* every declared operation and every action `permission` is denied. Same name
|
|
589
|
+
* and meaning as `failClosed` in `@telamonjs/permissions`. Default `false`.
|
|
590
|
+
*/
|
|
591
|
+
failClosed?: boolean;
|
|
546
592
|
/** The "New" button and the create dialog */
|
|
547
593
|
create?: ActionConfig['permission'];
|
|
548
594
|
/** The row edit, the view dialog's Edit, the edit dialog and portal section saving */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telamonjs/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Admin framework for Next.js + React: declarative CRUD (CrudConfig + TanStack Query), 36-type field system, rich dialogs, app shell, dashboards and charts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface DialogErrorStateProps {
|
|
2
|
-
/** Error message to display */
|
|
3
|
-
error: string | null;
|
|
4
|
-
/** Optional retry callback */
|
|
5
|
-
onRetry?: () => void;
|
|
6
|
-
/** Optional dismiss callback */
|
|
7
|
-
onDismiss?: () => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* DialogErrorState - Renders error state with optional retry/dismiss actions
|
|
11
|
-
*
|
|
12
|
-
* Provides consistent error UI across dialogs (view, edit, create).
|
|
13
|
-
* Replaces duplicated error Alert rendering logic.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* // Simple error display
|
|
18
|
-
* {error && <DialogErrorState error={error} />}
|
|
19
|
-
*
|
|
20
|
-
* // With retry callback
|
|
21
|
-
* <DialogErrorState
|
|
22
|
-
* error={error}
|
|
23
|
-
* onRetry={refetch}
|
|
24
|
-
* onDismiss={() => setError(null)}
|
|
25
|
-
* />
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function DialogErrorState({ error, onRetry, onDismiss, }: DialogErrorStateProps): import("react").JSX.Element | null;
|
|
29
|
-
export interface DialogLoadingStateProps {
|
|
30
|
-
/** Loading message */
|
|
31
|
-
message?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* DialogLoadingState - Renders loading spinner with optional message.
|
|
35
|
-
*
|
|
36
|
-
* Consolidates the duplicated loading spinner rendering from EditDialog and ViewDialog.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* {isLoading && <DialogLoadingState />}
|
|
41
|
-
* {isLoading && <DialogLoadingState message="Buscando dados..." />}
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare function DialogLoadingState({ message }: DialogLoadingStateProps): import("react").JSX.Element;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// src/components/dialog/DialogErrorState.tsx
|
|
4
|
-
import { AlertCircle, Loader2 } from "lucide-react";
|
|
5
|
-
import { useTelamonjsT } from "../../i18n/use-t.js";
|
|
6
|
-
import { Alert, AlertDescription } from "../../ui/alert.js";
|
|
7
|
-
import { Button } from "../../ui/button.js";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
function DialogErrorState({
|
|
10
|
-
error,
|
|
11
|
-
onRetry,
|
|
12
|
-
onDismiss
|
|
13
|
-
}) {
|
|
14
|
-
const t = useTelamonjsT();
|
|
15
|
-
if (!error) return null;
|
|
16
|
-
return /* @__PURE__ */ jsx("div", { className: "py-8", children: /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
17
|
-
/* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
|
|
18
|
-
/* @__PURE__ */ jsxs(AlertDescription, { className: "flex items-center justify-between gap-4", children: [
|
|
19
|
-
/* @__PURE__ */ jsx("span", { children: error }),
|
|
20
|
-
(onRetry || onDismiss) && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
21
|
-
onRetry && /* @__PURE__ */ jsx(
|
|
22
|
-
Button,
|
|
23
|
-
{
|
|
24
|
-
variant: "outline",
|
|
25
|
-
size: "sm",
|
|
26
|
-
onClick: onRetry,
|
|
27
|
-
className: "bg-card hover:bg-muted/50",
|
|
28
|
-
"data-testid": "dialog-error-retry-button",
|
|
29
|
-
children: t("dialog.retryLabel")
|
|
30
|
-
}
|
|
31
|
-
),
|
|
32
|
-
onDismiss && /* @__PURE__ */ jsx(
|
|
33
|
-
Button,
|
|
34
|
-
{
|
|
35
|
-
variant: "outline",
|
|
36
|
-
size: "sm",
|
|
37
|
-
onClick: onDismiss,
|
|
38
|
-
className: "bg-card hover:bg-muted/50",
|
|
39
|
-
"data-testid": "dialog-error-dismiss-button",
|
|
40
|
-
children: t("common.close")
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
] })
|
|
44
|
-
] })
|
|
45
|
-
] }) });
|
|
46
|
-
}
|
|
47
|
-
function DialogLoadingState({ message }) {
|
|
48
|
-
const t = useTelamonjsT();
|
|
49
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 space-y-4", children: [
|
|
50
|
-
/* @__PURE__ */ jsx(Loader2, { className: "h-8 w-8 animate-spin text-primary" }),
|
|
51
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: message ?? t("dialog.loadingData") })
|
|
52
|
-
] });
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
DialogErrorState,
|
|
56
|
-
DialogLoadingState
|
|
57
|
-
};
|