@telamonjs/ui 1.0.4 → 1.2.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 +79 -0
- package/README.md +2 -2
- package/dist/components/business/CalendarWithEvents.d.ts +7 -1
- package/dist/components/business/CalendarWithEvents.js +8 -9
- package/dist/components/cards/stat-card.js +22 -3
- package/dist/components/charts/BarChart.d.ts +12 -1
- package/dist/components/charts/BarChart.js +11 -2
- package/dist/components/crud/crud-field.js +1 -0
- package/dist/components/data/DataTableActions.js +45 -77
- package/dist/components/data/action-access.d.ts +22 -0
- package/dist/components/data/action-access.js +33 -0
- package/dist/components/data/report-table.d.ts +3 -1
- package/dist/components/data/report-table.js +2 -1
- package/dist/components/dialog/DialogHeaderContent.js +1 -1
- package/dist/components/dialog/confirm-action-dialog.d.ts +86 -0
- package/dist/components/dialog/confirm-action-dialog.js +194 -0
- package/dist/components/dialog/crud-view-dialog.d.ts +7 -3
- package/dist/components/dialog/crud-view-dialog.js +3 -2
- package/dist/components/dialog/view-dialog.d.ts +9 -1
- package/dist/components/dialog/view-dialog.js +8 -3
- package/dist/components/forms/AdminForm.js +2 -1
- package/dist/components/forms/BaseForm.js +4 -3
- package/dist/components/forms/WizardForm.js +3 -2
- package/dist/components/forms/ZustandForm.js +5 -4
- package/dist/components/forms/admin-form/field-group.js +5 -4
- package/dist/components/forms/grid-classes.d.ts +4 -0
- package/dist/components/forms/grid-classes.js +40 -0
- package/dist/components/forms/validators/config-validator.js +2 -1
- package/dist/components/toolbar/TabToolbar.d.ts +6 -1
- package/dist/components/toolbar/TabToolbar.js +5 -3
- package/dist/data/InfiniteList.js +2 -4
- package/dist/data/MobileCard.js +4 -1
- package/dist/data/VirtualDataTable.js +4 -1
- package/dist/data/datatable/TableDesktopView.js +2 -5
- package/dist/data/row-click.d.ts +10 -0
- package/dist/data/row-click.js +11 -0
- package/dist/exports/data-crud.d.ts +1 -1
- package/dist/exports/pages-dialogs.d.ts +3 -1
- package/dist/exports/pages-dialogs.js +2 -0
- package/dist/exports/types-constants.d.ts +2 -2
- package/dist/exports/types-constants.js +1 -1
- package/dist/field-system/mask-presets.d.ts +5 -0
- package/dist/field-system/mask-presets.js +18 -0
- package/dist/field-system/renderers/advanced-renderers.js +2 -4
- package/dist/field-system/renderers/textarea-renderers.js +1 -1
- package/dist/hooks/useCrudMutations.js +28 -16
- package/dist/i18n/messages/en/index.d.ts +1 -0
- package/dist/i18n/messages/en/list.d.ts +1 -0
- package/dist/i18n/messages/en/list.js +1 -0
- package/dist/i18n/messages/en/queue.js +1 -1
- package/dist/i18n/messages/es/index.d.ts +1 -0
- package/dist/i18n/messages/es/list.d.ts +1 -0
- package/dist/i18n/messages/es/list.js +1 -0
- package/dist/i18n/messages/pt-BR/index.d.ts +8 -7
- package/dist/i18n/messages/pt-BR/list.d.ts +1 -0
- package/dist/i18n/messages/pt-BR/list.js +1 -0
- package/dist/i18n/messages/pt-BR/queue.d.ts +7 -7
- package/dist/i18n/messages/pt-BR/queue.js +7 -7
- package/dist/i18n/use-t.d.ts +8 -7
- package/dist/pages/ListPage.js +23 -14
- package/dist/pages/list-page/ListPageDialogs.d.ts +8 -3
- package/dist/pages/list-page/ListPageDialogs.js +36 -7
- package/dist/pages/list-page/ListPageTable.d.ts +1 -1
- package/dist/pages/list-page/ListPageTable.js +1 -1
- package/dist/pages/list-page/ListPageToolbar.js +10 -14
- package/dist/pages/list-page/apply-crud-permissions.d.ts +21 -0
- package/dist/pages/list-page/apply-crud-permissions.js +34 -0
- package/dist/pages/list-page/types.d.ts +21 -2
- package/dist/pages/list-page/useDialogUrlSync.d.ts +10 -4
- package/dist/pages/list-page/useDialogUrlSync.js +7 -11
- package/dist/pages/list-page/useListPageData.d.ts +3 -1
- package/dist/pages/list-page/useListPageData.js +2 -1
- package/dist/pages/list-page/useListPageDialogs.d.ts +1 -0
- package/dist/pages/list-page/useListPageDialogs.js +13 -4
- package/dist/pages/list-page/useListPageToolbar.d.ts +8 -5
- package/dist/pages/list-page/useListPageToolbar.js +14 -10
- package/dist/queue/components/DispatchJobModal.js +5 -2
- package/dist/queue/components/FailureGroupsModal.js +4 -3
- package/dist/queue/components/JobConfigDialog.js +9 -1
- package/dist/queue/components/JobDetailModal.js +3 -2
- package/dist/queue/components/JobDetailPage.d.ts +8 -0
- package/dist/queue/components/JobDetailPage.js +29 -13
- package/dist/queue/components/JobEventModal.js +3 -2
- package/dist/queue/components/QueueDashboard.js +3 -1
- package/dist/queue/components/QueueTabbedDashboard.d.ts +21 -2
- package/dist/queue/components/QueueTabbedDashboard.js +3 -2
- package/dist/queue/components/QueuesTable.d.ts +3 -2
- package/dist/queue/components/QueuesTable.js +357 -286
- package/dist/queue/components/job-shared.d.ts +2 -0
- package/dist/queue/components/job-shared.js +2 -0
- package/dist/queue/components/jobs-history-modal/fullscreen-modal.js +3 -2
- package/dist/queue/components/jobs-history-modal/job-detail-modal.js +3 -2
- package/dist/queue/components/jobs-list-modal/job-row.js +3 -2
- package/dist/queue/components/labels-context.d.ts +39 -0
- package/dist/queue/components/labels-context.js +35 -0
- package/dist/queue/components/labels-provider.d.ts +11 -0
- package/dist/queue/components/labels-provider.js +35 -0
- package/dist/queue/components/module-icon.d.ts +9 -0
- package/dist/queue/components/module-icon.js +14 -0
- package/dist/queue/components/tabs/ConfiguracaoTab.d.ts +2 -1
- package/dist/queue/components/tabs/ConfiguracaoTab.js +16 -12
- package/dist/queue/components/tabs/HistoricoTab.js +4 -3
- package/dist/queue/components/tabs/TempoRealTab.d.ts +3 -2
- package/dist/queue/components/tabs/TempoRealTab.js +5 -4
- package/dist/queue/components/tabs/historico/history-job-row.js +1 -1
- package/dist/queue/lib/action-message.d.ts +3 -2
- package/dist/queue/lib/action-message.js +2 -2
- package/dist/queue/types.d.ts +3 -0
- package/dist/types/actions.d.ts +51 -14
- package/dist/types/crud.d.ts +53 -9
- package/dist/types/dialog-header.d.ts +2 -2
- package/dist/types/forms/admin-form.d.ts +8 -1
- package/dist/utils/with-scope.js +5 -3
- package/package.json +2 -2
package/dist/types/crud.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ import type { ColumnDef, HeaderContext } from '@tanstack/react-table';
|
|
|
60
60
|
import type { z } from 'zod';
|
|
61
61
|
import type { UseQueryOptions, UseMutationOptions, QueryKey } from '@tanstack/react-query';
|
|
62
62
|
import type { ReactNode } from 'react';
|
|
63
|
-
import type { DataTableActionsConfig } from './actions';
|
|
63
|
+
import type { ActionConfig, DataTableActionsConfig } from './actions';
|
|
64
64
|
import type { PaginationParams, PaginatedResponse } from './pagination';
|
|
65
65
|
import type { FormSection } from './forms/admin-form';
|
|
66
66
|
import type { DialogHeaderConfig } from './dialog-header';
|
|
@@ -135,8 +135,18 @@ export interface ToolbarFilterConfig {
|
|
|
135
135
|
label: I18nText;
|
|
136
136
|
/** Filter options */
|
|
137
137
|
options: ToolbarFilterOption[];
|
|
138
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Initial value (default: first option). With `allValue` set it applies even
|
|
140
|
+
* when it is the first option.
|
|
141
|
+
*/
|
|
139
142
|
defaultValue?: string;
|
|
143
|
+
/**
|
|
144
|
+
* The option value that means "no filter" (dropped from the query, shown when
|
|
145
|
+
* nothing is selected). Set it and the first option is an ordinary option and
|
|
146
|
+
* `'todos'`/`'all'` are ordinary values. Without it, the first option is the
|
|
147
|
+
* "all" choice and `''`/`'todos'`/`'all'` mean "no filter".
|
|
148
|
+
*/
|
|
149
|
+
allValue?: string;
|
|
140
150
|
/** Custom className */
|
|
141
151
|
className?: string;
|
|
142
152
|
/** Display mode: 'buttons' (ButtonGroup) or 'select' (compact dropdown). Default: 'buttons' */
|
|
@@ -184,11 +194,14 @@ export interface ListConfig<T> {
|
|
|
184
194
|
/**
|
|
185
195
|
* Empty-state title for a list with no rows. Applies only when no search/filter is active
|
|
186
196
|
* (an active search keeps the localized "no results" text). Works for DataTable and InfiniteList.
|
|
187
|
-
* Default: localized "No items found".
|
|
188
|
-
* invites adding an item.
|
|
197
|
+
* Default: localized "No items found".
|
|
189
198
|
*/
|
|
190
199
|
emptyTitle?: I18nText;
|
|
191
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Empty-state description; same rules as `emptyTitle`. Default: "Start by adding a new item"
|
|
202
|
+
* when the "New" button shows, else a neutral "There are no items to show yet" (no `form`,
|
|
203
|
+
* no `dialogs.create`, or `permissions.create` denied).
|
|
204
|
+
*/
|
|
192
205
|
emptyDescription?: I18nText;
|
|
193
206
|
/** Table columns definition */
|
|
194
207
|
columns: CrudColumnDef<T>[];
|
|
@@ -237,8 +250,8 @@ export interface ListConfig<T> {
|
|
|
237
250
|
export interface FormConfig {
|
|
238
251
|
/** Form sections with fields */
|
|
239
252
|
sections: FormSection | FormSection[];
|
|
240
|
-
/** Zod validation schema */
|
|
241
|
-
validation
|
|
253
|
+
/** Zod validation schema (optional: without it the form submits unvalidated) */
|
|
254
|
+
validation?: z.ZodSchema;
|
|
242
255
|
/** Use tabs for sections (default: false for create, true for edit) */
|
|
243
256
|
useTabs?: boolean;
|
|
244
257
|
/**
|
|
@@ -518,6 +531,27 @@ export interface PagesConfig<T> {
|
|
|
518
531
|
renderContent: (item: T) => React.ReactNode;
|
|
519
532
|
};
|
|
520
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* Permission model of a CrudConfig. Each operation names the permission(s) it
|
|
536
|
+
* needs (any of them, like an action's `permission`); an operation without
|
|
537
|
+
* one stays allowed.
|
|
538
|
+
*
|
|
539
|
+
* Checked with `can` when set (bypass roles, wildcards: pass
|
|
540
|
+
* `perm => checker.can(user, perm)` from `@telamonjs/permissions`), else against
|
|
541
|
+
* `actionsConfig.userPermissions`; with neither, everything is allowed.
|
|
542
|
+
*/
|
|
543
|
+
export interface CrudPermissions {
|
|
544
|
+
/** Permission checker; wins over `actionsConfig.userPermissions` */
|
|
545
|
+
can?: (permission: string) => boolean;
|
|
546
|
+
/** The "New" button and the create dialog */
|
|
547
|
+
create?: ActionConfig['permission'];
|
|
548
|
+
/** The row edit, the view dialog's Edit, the edit dialog and portal section saving */
|
|
549
|
+
edit?: ActionConfig['permission'];
|
|
550
|
+
/** The row delete and the view dialog's Delete */
|
|
551
|
+
delete?: ActionConfig['permission'];
|
|
552
|
+
/** The row view and the view dialog (row click included) */
|
|
553
|
+
view?: ActionConfig['permission'];
|
|
554
|
+
}
|
|
521
555
|
/**
|
|
522
556
|
* Complete CRUD configuration
|
|
523
557
|
*
|
|
@@ -560,8 +594,12 @@ export interface CrudConfig<T = any, TFormData = T> {
|
|
|
560
594
|
module: ModuleMetadata;
|
|
561
595
|
/** List page configuration */
|
|
562
596
|
list: ListConfig<T>;
|
|
563
|
-
/**
|
|
564
|
-
|
|
597
|
+
/**
|
|
598
|
+
* Form configuration (shared by create/edit/dialogs). Optional: a read-only
|
|
599
|
+
* list omits it, and then no create or edit dialog is offered even when
|
|
600
|
+
* `dialogs.create` / `dialogs.edit` are set.
|
|
601
|
+
*/
|
|
602
|
+
form?: FormConfig;
|
|
565
603
|
/**
|
|
566
604
|
* React Query configuration for data fetching
|
|
567
605
|
* REQUIRED - Replaces Server Actions pattern
|
|
@@ -578,6 +616,12 @@ export interface CrudConfig<T = any, TFormData = T> {
|
|
|
578
616
|
dialogs?: DialogsConfig<T>;
|
|
579
617
|
/** Dedicated pages configuration (optional) */
|
|
580
618
|
pages?: PagesConfig<T>;
|
|
619
|
+
/**
|
|
620
|
+
* Who may create, edit, delete and view. Gates the "New" button, the row
|
|
621
|
+
* actions, the view dialog footer, the create/edit dialogs and portal
|
|
622
|
+
* section saving. Omit it and nothing changes.
|
|
623
|
+
*/
|
|
624
|
+
permissions?: CrudPermissions;
|
|
581
625
|
}
|
|
582
626
|
/**
|
|
583
627
|
* CrudConfig with the form-data side erased (existential).
|
|
@@ -70,8 +70,8 @@ export interface HeaderBadgeConfig<T = any> {
|
|
|
70
70
|
labels?: Record<string, I18nText>;
|
|
71
71
|
/** Optional: Custom function to determine badge variant */
|
|
72
72
|
getVariant?: (item: T) => BadgeVariant;
|
|
73
|
-
/** Optional: Custom function to determine badge label */
|
|
74
|
-
getLabel?: (item: T) =>
|
|
73
|
+
/** Optional: Custom function to determine badge label (a `msg()` is resolved) */
|
|
74
|
+
getLabel?: (item: T) => I18nText;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Stats grid configuration
|
|
@@ -121,7 +121,14 @@ export interface FormField<TValue = unknown> {
|
|
|
121
121
|
id: string;
|
|
122
122
|
}) => React.ReactElement;
|
|
123
123
|
mask?: string;
|
|
124
|
-
|
|
124
|
+
/**
|
|
125
|
+
* `masked` fields: a built-in mask that wins over `mask` — `'tel'`
|
|
126
|
+
* (landline/mobile by digit count), `'cpf'`, `'cnpj'`, `'cep'`. Any other
|
|
127
|
+
* value falls back to `mask`
|
|
128
|
+
*/
|
|
129
|
+
maskType?: 'tel' | 'cpf' | 'cnpj' | 'cep' | (string & Record<never, never>);
|
|
130
|
+
/** `textarea` fields: visible text lines. Default: 4 */
|
|
131
|
+
rows?: number;
|
|
125
132
|
dependsOn?: string;
|
|
126
133
|
focus?: boolean;
|
|
127
134
|
readOnly?: boolean;
|
package/dist/utils/with-scope.js
CHANGED
|
@@ -52,9 +52,11 @@ function withScope(config, scope) {
|
|
|
52
52
|
}),
|
|
53
53
|
...toolbar && { toolbar }
|
|
54
54
|
},
|
|
55
|
-
form
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
...config.form && {
|
|
56
|
+
form: {
|
|
57
|
+
...config.form,
|
|
58
|
+
sections: stripFields(config.form.sections, lockedKeys)
|
|
59
|
+
}
|
|
58
60
|
},
|
|
59
61
|
query: {
|
|
60
62
|
...config.query,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telamonjs/ui",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.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",
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"jspdf": "^4.2.1",
|
|
143
143
|
"jspdf-autotable": "^5.0.7",
|
|
144
144
|
"next": "^15.5.29 || ^16.4.6",
|
|
145
|
-
"next-auth": "5.0.0-beta.
|
|
145
|
+
"next-auth": "^5.0.0-beta.20",
|
|
146
146
|
"papaparse": "^5.5.0",
|
|
147
147
|
"react": "^18.0.0 || ^19.0.0",
|
|
148
148
|
"react-dom": "^18.0.0 || ^19.0.0",
|