@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.
Files changed (114) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +2 -2
  3. package/dist/components/business/CalendarWithEvents.d.ts +7 -1
  4. package/dist/components/business/CalendarWithEvents.js +8 -9
  5. package/dist/components/cards/stat-card.js +22 -3
  6. package/dist/components/charts/BarChart.d.ts +12 -1
  7. package/dist/components/charts/BarChart.js +11 -2
  8. package/dist/components/crud/crud-field.js +1 -0
  9. package/dist/components/data/DataTableActions.js +45 -77
  10. package/dist/components/data/action-access.d.ts +22 -0
  11. package/dist/components/data/action-access.js +33 -0
  12. package/dist/components/data/report-table.d.ts +3 -1
  13. package/dist/components/data/report-table.js +2 -1
  14. package/dist/components/dialog/DialogHeaderContent.js +1 -1
  15. package/dist/components/dialog/confirm-action-dialog.d.ts +86 -0
  16. package/dist/components/dialog/confirm-action-dialog.js +194 -0
  17. package/dist/components/dialog/crud-view-dialog.d.ts +7 -3
  18. package/dist/components/dialog/crud-view-dialog.js +3 -2
  19. package/dist/components/dialog/view-dialog.d.ts +9 -1
  20. package/dist/components/dialog/view-dialog.js +8 -3
  21. package/dist/components/forms/AdminForm.js +2 -1
  22. package/dist/components/forms/BaseForm.js +4 -3
  23. package/dist/components/forms/WizardForm.js +3 -2
  24. package/dist/components/forms/ZustandForm.js +5 -4
  25. package/dist/components/forms/admin-form/field-group.js +5 -4
  26. package/dist/components/forms/grid-classes.d.ts +4 -0
  27. package/dist/components/forms/grid-classes.js +40 -0
  28. package/dist/components/forms/validators/config-validator.js +2 -1
  29. package/dist/components/toolbar/TabToolbar.d.ts +6 -1
  30. package/dist/components/toolbar/TabToolbar.js +5 -3
  31. package/dist/data/InfiniteList.js +2 -4
  32. package/dist/data/MobileCard.js +4 -1
  33. package/dist/data/VirtualDataTable.js +4 -1
  34. package/dist/data/datatable/TableDesktopView.js +2 -5
  35. package/dist/data/row-click.d.ts +10 -0
  36. package/dist/data/row-click.js +11 -0
  37. package/dist/exports/data-crud.d.ts +1 -1
  38. package/dist/exports/pages-dialogs.d.ts +3 -1
  39. package/dist/exports/pages-dialogs.js +2 -0
  40. package/dist/exports/types-constants.d.ts +2 -2
  41. package/dist/exports/types-constants.js +1 -1
  42. package/dist/field-system/mask-presets.d.ts +5 -0
  43. package/dist/field-system/mask-presets.js +18 -0
  44. package/dist/field-system/renderers/advanced-renderers.js +2 -4
  45. package/dist/field-system/renderers/textarea-renderers.js +1 -1
  46. package/dist/hooks/useCrudMutations.js +28 -16
  47. package/dist/i18n/messages/en/index.d.ts +1 -0
  48. package/dist/i18n/messages/en/list.d.ts +1 -0
  49. package/dist/i18n/messages/en/list.js +1 -0
  50. package/dist/i18n/messages/en/queue.js +1 -1
  51. package/dist/i18n/messages/es/index.d.ts +1 -0
  52. package/dist/i18n/messages/es/list.d.ts +1 -0
  53. package/dist/i18n/messages/es/list.js +1 -0
  54. package/dist/i18n/messages/pt-BR/index.d.ts +8 -7
  55. package/dist/i18n/messages/pt-BR/list.d.ts +1 -0
  56. package/dist/i18n/messages/pt-BR/list.js +1 -0
  57. package/dist/i18n/messages/pt-BR/queue.d.ts +7 -7
  58. package/dist/i18n/messages/pt-BR/queue.js +7 -7
  59. package/dist/i18n/use-t.d.ts +8 -7
  60. package/dist/pages/ListPage.js +23 -14
  61. package/dist/pages/list-page/ListPageDialogs.d.ts +8 -3
  62. package/dist/pages/list-page/ListPageDialogs.js +36 -7
  63. package/dist/pages/list-page/ListPageTable.d.ts +1 -1
  64. package/dist/pages/list-page/ListPageTable.js +1 -1
  65. package/dist/pages/list-page/ListPageToolbar.js +10 -14
  66. package/dist/pages/list-page/apply-crud-permissions.d.ts +21 -0
  67. package/dist/pages/list-page/apply-crud-permissions.js +34 -0
  68. package/dist/pages/list-page/types.d.ts +21 -2
  69. package/dist/pages/list-page/useDialogUrlSync.d.ts +10 -4
  70. package/dist/pages/list-page/useDialogUrlSync.js +7 -11
  71. package/dist/pages/list-page/useListPageData.d.ts +3 -1
  72. package/dist/pages/list-page/useListPageData.js +2 -1
  73. package/dist/pages/list-page/useListPageDialogs.d.ts +1 -0
  74. package/dist/pages/list-page/useListPageDialogs.js +13 -4
  75. package/dist/pages/list-page/useListPageToolbar.d.ts +8 -5
  76. package/dist/pages/list-page/useListPageToolbar.js +14 -10
  77. package/dist/queue/components/DispatchJobModal.js +5 -2
  78. package/dist/queue/components/FailureGroupsModal.js +4 -3
  79. package/dist/queue/components/JobConfigDialog.js +9 -1
  80. package/dist/queue/components/JobDetailModal.js +3 -2
  81. package/dist/queue/components/JobDetailPage.d.ts +8 -0
  82. package/dist/queue/components/JobDetailPage.js +29 -13
  83. package/dist/queue/components/JobEventModal.js +3 -2
  84. package/dist/queue/components/QueueDashboard.js +3 -1
  85. package/dist/queue/components/QueueTabbedDashboard.d.ts +21 -2
  86. package/dist/queue/components/QueueTabbedDashboard.js +3 -2
  87. package/dist/queue/components/QueuesTable.d.ts +3 -2
  88. package/dist/queue/components/QueuesTable.js +357 -286
  89. package/dist/queue/components/job-shared.d.ts +2 -0
  90. package/dist/queue/components/job-shared.js +2 -0
  91. package/dist/queue/components/jobs-history-modal/fullscreen-modal.js +3 -2
  92. package/dist/queue/components/jobs-history-modal/job-detail-modal.js +3 -2
  93. package/dist/queue/components/jobs-list-modal/job-row.js +3 -2
  94. package/dist/queue/components/labels-context.d.ts +39 -0
  95. package/dist/queue/components/labels-context.js +35 -0
  96. package/dist/queue/components/labels-provider.d.ts +11 -0
  97. package/dist/queue/components/labels-provider.js +35 -0
  98. package/dist/queue/components/module-icon.d.ts +9 -0
  99. package/dist/queue/components/module-icon.js +14 -0
  100. package/dist/queue/components/tabs/ConfiguracaoTab.d.ts +2 -1
  101. package/dist/queue/components/tabs/ConfiguracaoTab.js +16 -12
  102. package/dist/queue/components/tabs/HistoricoTab.js +4 -3
  103. package/dist/queue/components/tabs/TempoRealTab.d.ts +3 -2
  104. package/dist/queue/components/tabs/TempoRealTab.js +5 -4
  105. package/dist/queue/components/tabs/historico/history-job-row.js +1 -1
  106. package/dist/queue/lib/action-message.d.ts +3 -2
  107. package/dist/queue/lib/action-message.js +2 -2
  108. package/dist/queue/types.d.ts +3 -0
  109. package/dist/types/actions.d.ts +51 -14
  110. package/dist/types/crud.d.ts +53 -9
  111. package/dist/types/dialog-header.d.ts +2 -2
  112. package/dist/types/forms/admin-form.d.ts +8 -1
  113. package/dist/utils/with-scope.js +5 -3
  114. package/package.json +2 -2
@@ -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
- /** Initial value (default: first option) */
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". Set it for lists without creation, where the default
188
- * invites adding an item.
197
+ * Default: localized "No items found".
189
198
  */
190
199
  emptyTitle?: I18nText;
191
- /** Empty-state description; same rules as `emptyTitle`. Default: "Start by adding a new item". */
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: z.ZodSchema;
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
- /** Form configuration (shared by create/edit/dialogs) */
564
- form: FormConfig;
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) => string;
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
- maskType?: string;
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;
@@ -52,9 +52,11 @@ function withScope(config, scope) {
52
52
  }),
53
53
  ...toolbar && { toolbar }
54
54
  },
55
- form: {
56
- ...config.form,
57
- sections: stripFields(config.form.sections, lockedKeys)
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.4",
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.31",
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",