@telamonjs/ui 1.0.3 → 1.1.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 (87) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/components/business/CalendarWithEvents.d.ts +7 -1
  3. package/dist/components/business/CalendarWithEvents.js +8 -9
  4. package/dist/components/cards/stat-card.js +22 -3
  5. package/dist/components/charts/BarChart.d.ts +12 -1
  6. package/dist/components/charts/BarChart.js +6 -1
  7. package/dist/components/crud/crud-field.js +1 -0
  8. package/dist/components/data/DataTableActions.js +89 -85
  9. package/dist/components/data/action-access.d.ts +22 -0
  10. package/dist/components/data/action-access.js +33 -0
  11. package/dist/components/data/report-table.d.ts +3 -1
  12. package/dist/components/data/report-table.js +2 -1
  13. package/dist/components/dialog/DialogHeaderContent.js +1 -1
  14. package/dist/components/dialog/confirm-action-dialog.d.ts +54 -0
  15. package/dist/components/dialog/confirm-action-dialog.js +182 -0
  16. package/dist/components/dialog/crud-view-dialog.d.ts +7 -3
  17. package/dist/components/dialog/crud-view-dialog.js +3 -2
  18. package/dist/components/dialog/view-dialog.d.ts +9 -1
  19. package/dist/components/dialog/view-dialog.js +8 -3
  20. package/dist/components/forms/BaseForm.js +4 -3
  21. package/dist/components/forms/WizardForm.js +3 -2
  22. package/dist/components/forms/ZustandForm.js +5 -4
  23. package/dist/components/forms/admin-form/field-group.js +5 -4
  24. package/dist/components/forms/admin-form/visibility.js +2 -0
  25. package/dist/components/forms/grid-classes.d.ts +4 -0
  26. package/dist/components/forms/grid-classes.js +40 -0
  27. package/dist/components/forms/validators/config-validator.js +2 -1
  28. package/dist/components/toolbar/TabToolbar.d.ts +6 -1
  29. package/dist/components/toolbar/TabToolbar.js +5 -3
  30. package/dist/exports/data-crud.d.ts +1 -1
  31. package/dist/exports/pages-dialogs.d.ts +3 -1
  32. package/dist/exports/pages-dialogs.js +2 -0
  33. package/dist/exports/types-constants.d.ts +2 -2
  34. package/dist/exports/types-constants.js +1 -1
  35. package/dist/field-system/mask-presets.d.ts +5 -0
  36. package/dist/field-system/mask-presets.js +18 -0
  37. package/dist/field-system/renderers/advanced-renderers.js +2 -4
  38. package/dist/field-system/renderers/textarea-renderers.js +1 -1
  39. package/dist/hooks/useCrudMutations.js +28 -16
  40. package/dist/pages/ListPage.js +23 -14
  41. package/dist/pages/list-page/ListPageDialogs.d.ts +8 -3
  42. package/dist/pages/list-page/ListPageDialogs.js +36 -7
  43. package/dist/pages/list-page/ListPageToolbar.js +10 -14
  44. package/dist/pages/list-page/apply-crud-permissions.d.ts +21 -0
  45. package/dist/pages/list-page/apply-crud-permissions.js +34 -0
  46. package/dist/pages/list-page/types.d.ts +21 -2
  47. package/dist/pages/list-page/useListPageData.d.ts +3 -1
  48. package/dist/pages/list-page/useListPageData.js +2 -1
  49. package/dist/pages/list-page/useListPageDialogs.d.ts +1 -0
  50. package/dist/pages/list-page/useListPageDialogs.js +13 -4
  51. package/dist/pages/list-page/useListPageToolbar.d.ts +8 -5
  52. package/dist/pages/list-page/useListPageToolbar.js +14 -10
  53. package/dist/queue/components/FailureGroupsModal.js +4 -3
  54. package/dist/queue/components/JobConfigDialog.js +9 -1
  55. package/dist/queue/components/JobDetailModal.js +3 -2
  56. package/dist/queue/components/JobDetailPage.js +10 -2
  57. package/dist/queue/components/JobEventModal.js +3 -2
  58. package/dist/queue/components/QueueTabbedDashboard.d.ts +25 -2
  59. package/dist/queue/components/QueueTabbedDashboard.js +37 -5
  60. package/dist/queue/components/QueuesTable.d.ts +3 -2
  61. package/dist/queue/components/QueuesTable.js +31 -27
  62. package/dist/queue/components/job-shared.d.ts +2 -0
  63. package/dist/queue/components/job-shared.js +2 -0
  64. package/dist/queue/components/jobs-history-modal/fullscreen-modal.js +3 -2
  65. package/dist/queue/components/jobs-history-modal/job-detail-modal.js +3 -2
  66. package/dist/queue/components/jobs-list-modal/job-row.js +3 -2
  67. package/dist/queue/components/labels-context.d.ts +31 -0
  68. package/dist/queue/components/labels-context.js +34 -0
  69. package/dist/queue/components/module-icon.d.ts +9 -0
  70. package/dist/queue/components/module-icon.js +14 -0
  71. package/dist/queue/components/tabs/ConfiguracaoTab.d.ts +2 -1
  72. package/dist/queue/components/tabs/ConfiguracaoTab.js +13 -9
  73. package/dist/queue/components/tabs/HistoricoTab.js +4 -3
  74. package/dist/queue/components/tabs/TempoRealTab.d.ts +8 -3
  75. package/dist/queue/components/tabs/TempoRealTab.js +13 -7
  76. package/dist/queue/hooks/use-queue-events-timeline.d.ts +19 -1
  77. package/dist/queue/hooks/use-queue-events-timeline.js +23 -3
  78. package/dist/server/pagination/factory.js +8 -1
  79. package/dist/server/pagination/types.d.ts +6 -0
  80. package/dist/server/pagination/utils.d.ts +13 -0
  81. package/dist/server/pagination/utils.js +27 -16
  82. package/dist/types/actions.d.ts +43 -14
  83. package/dist/types/crud.d.ts +47 -6
  84. package/dist/types/dialog-header.d.ts +2 -2
  85. package/dist/types/forms/admin-form.d.ts +8 -1
  86. package/dist/utils/with-scope.js +5 -3
  87. 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' */
@@ -237,8 +247,8 @@ export interface ListConfig<T> {
237
247
  export interface FormConfig {
238
248
  /** Form sections with fields */
239
249
  sections: FormSection | FormSection[];
240
- /** Zod validation schema */
241
- validation: z.ZodSchema;
250
+ /** Zod validation schema (optional: without it the form submits unvalidated) */
251
+ validation?: z.ZodSchema;
242
252
  /** Use tabs for sections (default: false for create, true for edit) */
243
253
  useTabs?: boolean;
244
254
  /**
@@ -518,6 +528,27 @@ export interface PagesConfig<T> {
518
528
  renderContent: (item: T) => React.ReactNode;
519
529
  };
520
530
  }
531
+ /**
532
+ * Permission model of a CrudConfig. Each operation names the permission(s) it
533
+ * needs (any of them, like an action's `permission`); an operation without
534
+ * one stays allowed.
535
+ *
536
+ * Checked with `can` when set (bypass roles, wildcards: pass
537
+ * `perm => checker.can(user, perm)` from `@telamonjs/permissions`), else against
538
+ * `actionsConfig.userPermissions`; with neither, everything is allowed.
539
+ */
540
+ export interface CrudPermissions {
541
+ /** Permission checker; wins over `actionsConfig.userPermissions` */
542
+ can?: (permission: string) => boolean;
543
+ /** The "New" button and the create dialog */
544
+ create?: ActionConfig['permission'];
545
+ /** The row edit, the view dialog's Edit, the edit dialog and portal section saving */
546
+ edit?: ActionConfig['permission'];
547
+ /** The row delete and the view dialog's Delete */
548
+ delete?: ActionConfig['permission'];
549
+ /** The row view and the view dialog (row click included) */
550
+ view?: ActionConfig['permission'];
551
+ }
521
552
  /**
522
553
  * Complete CRUD configuration
523
554
  *
@@ -560,8 +591,12 @@ export interface CrudConfig<T = any, TFormData = T> {
560
591
  module: ModuleMetadata;
561
592
  /** List page configuration */
562
593
  list: ListConfig<T>;
563
- /** Form configuration (shared by create/edit/dialogs) */
564
- form: FormConfig;
594
+ /**
595
+ * Form configuration (shared by create/edit/dialogs). Optional: a read-only
596
+ * list omits it, and then no create or edit dialog is offered even when
597
+ * `dialogs.create` / `dialogs.edit` are set.
598
+ */
599
+ form?: FormConfig;
565
600
  /**
566
601
  * React Query configuration for data fetching
567
602
  * REQUIRED - Replaces Server Actions pattern
@@ -578,6 +613,12 @@ export interface CrudConfig<T = any, TFormData = T> {
578
613
  dialogs?: DialogsConfig<T>;
579
614
  /** Dedicated pages configuration (optional) */
580
615
  pages?: PagesConfig<T>;
616
+ /**
617
+ * Who may create, edit, delete and view. Gates the "New" button, the row
618
+ * actions, the view dialog footer, the create/edit dialogs and portal
619
+ * section saving. Omit it and nothing changes.
620
+ */
621
+ permissions?: CrudPermissions;
581
622
  }
582
623
  /**
583
624
  * 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.3",
3
+ "version": "1.1.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",
@@ -134,7 +134,7 @@
134
134
  "tailwind-merge": "^3.3.1",
135
135
  "tailwindcss-animate": "^1.0.7",
136
136
  "zustand": "^5.0.8",
137
- "@telamonjs/logger": "^1.0.1"
137
+ "@telamonjs/logger": "^1.0.2"
138
138
  },
139
139
  "peerDependencies": {
140
140
  "@prisma/client": "^5.0.0 || ^6.0.0",