@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,84 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 575bf56: `ConfirmActionDialog` covers what apps kept local copies for. All additions are optional; `children` is still the trigger.
8
+
9
+ - `body`: free content between the description and the buttons.
10
+ - `confirmDisabled`: disables only the confirm button, from the caller's state.
11
+ - `pending` + `pendingText`: caller-controlled pending. Passing `pending` (even `false`) means confirming never closes the dialog; the caller closes it when its mutation settles. While `true`, both buttons are disabled, the confirm shows a spinner and `pendingText`, and the dialog cannot be dismissed. Without `pending` the dialog keeps awaiting `onConfirm` and closing on success; `pendingText` labels that pending state too.
12
+ - `title` / `description` accept JSX as well as text or `msg()`.
13
+ - `ConfirmDialogInput` (also used by `confirmDialog.inputs` on row and menu actions) gains `type: 'date'` (native input, `YYYY-MM-DD`) and `validate(value, values) => I18nText | undefined`, shown as the field error and blocking the confirm.
14
+
15
+ Migrating a local `ConfirmActionDialog` / `ConfirmFormDialog` copy (open/onOpenChange, pending, JSX title):
16
+
17
+ | Local prop | Public prop |
18
+ | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
19
+ | `open`, `onOpenChange`, `title`, `description`, `confirmText`, `pendingText`, `pending`, `variant`, `confirmDisabled`, `onConfirm` | same name, same meaning |
20
+ | `children` (content between description and buttons) | `body` |
21
+ | hard-coded "Confirmar" / "Cancelar" | localized defaults (or `confirmText` / `cancelText`) |
22
+
23
+ Behaviour differences: with `pending` set, ESC and the overlay no longer dismiss the dialog while pending (the local copies only disabled Cancel), and a promise rejected by `onConfirm` is shown inside the dialog.
24
+
25
+ - 3276e93: `JobDetailPage` takes `moduleLabels` and `jobLabel`, like `QueueTabbedDashboard`. Its title and module badge now resolve through the dashboard's label precedence (`jobLabel` > contract `displayName` > formatted name), and the contract's `description` shows below the title. The page's enable switch also gets an accessible name.
26
+
27
+ ### Patch Changes
28
+
29
+ - b44aa68: Four fixes reported by consumer apps:
30
+
31
+ - `BarChart` rounds the bar's end in `layout='vertical'` (horizontal bars): `[0, 4, 4, 0]` instead of the top corners.
32
+ - `ListPage`'s empty state no longer says "Start by adding a new item" when the "New" button is hidden (no `form`, no `dialogs.create`, or `permissions.create` denied). It shows the neutral `list.emptyDescriptionNoCreate` message instead; an explicit `list.emptyDescription` still wins and the search/filter "no results" copy is unchanged.
33
+ - The `next-auth` peer is widened from exactly `5.0.0-beta.31` to `^5.0.0-beta.20`, the first v5 beta that accepts Next 15 and React 19 and already has every `next-auth/react` API the package uses.
34
+ - `AdminForm` now spaces its sections in the non-flush layout without tabs (a `display: contents` wrapper kept the form's `space-y-6` from reaching them).
35
+
36
+ - 48df933: ListPage: closing a deep-linked dialog (`?view=<id>`) no longer reopens it when the
37
+ set of dialog URL params changes during the close — e.g. `permissions` enabling
38
+ `edit`/`create` as the session arrives. The first Escape now always closes the dialog
39
+ and clears the param. The URL ↔ dialog sync compares what the URL asks for, not the
40
+ spelling of the configured params.
41
+ - 1a6d140: Queue dashboard polish. The Real-time queue tables fit their panel: they no longer force a 704px minimum width (horizontal scroll, "Actions" cut off, job name hidden next to the "Late" badge); the job name truncates with a tooltip, status badges wrap below it and the action buttons wrap inside their column. Toasts and the Run Job dialog name the job through `jobLabel` instead of the raw id (enable/disable, settings saved, queue actions, dispatch). pt-BR: missing accents in the Run Job dialog messages.
42
+ - 339b47f: Clicking inside a row action's confirm dialog (its title, an `inputs` field) no longer opens the row's view dialog behind it, which left the confirm buttons unclickable. React bubbles clicks from portaled content (dialogs, the "..." menu, popovers) through the component tree, so they reached the row's click handler. `InfiniteList`, `DataTable` (table rows), `VirtualDataTable` and `MobileCard` now only treat clicks inside the row's own DOM as row clicks, and ignore links and form fields as well as buttons and checkboxes. `VirtualDataTable` rows previously reacted to every click, buttons included.
43
+
44
+ ## 1.1.0
45
+
46
+ ### Minor Changes
47
+
48
+ - c3537bb: New public `ConfirmActionDialog`: the confirmation behind `confirmDialog` on row and menu actions, now exported for any button. It stays open while `onConfirm` is pending (spinner, disabled buttons, no dismiss), closes when it resolves, and stays open showing the error when it rejects (resolve `false` to stay open without a message). It also renders optional `inputs`.
49
+
50
+ `confirmDialog.inputs` (`ConfirmDialogInput`: `text`, `textarea`, `select`) were typed but never rendered; they now render, required ones block the confirm while empty, and their values reach the action as a second argument — `handler(row, { inputs })` / `onClick(row, { inputs })` (`ActionContext`), passed only when inputs are declared so existing handlers keep receiving the row alone. `ConfirmDialogInput.label` accepts `I18nText`. A row action whose confirmed run fails keeps its error toast and now leaves the dialog open for a retry instead of closing it.
51
+
52
+ - 500114c: `CrudConfig` gains an optional `permissions` model (`CrudPermissions`): `create`, `edit`, `delete` and `view` name the permission each operation needs, checked with `can` (e.g. `perm => checker.can(user, perm)` from `@telamonjs/permissions`, so bypass roles and wildcards work) or, without it, against `actionsConfig.userPermissions`. It gates the "New" button and the create dialog, the row view/edit/delete (including the edit/view actions `ListPage` injects for `dialogs.edit`/`dialogs.view`), the view dialog footer, the edit dialog, the `?create`/`?edit`/`?view` deep links and `dialogs.view.portal.onSaveSection` (also in `CrudViewDialog`). `DataTableActionsConfig` gains `can`, which decides every action `permission` instead of the exact lookup in `userPermissions`.
53
+
54
+ `CrudConfig.form` and `FormConfig.validation` are now optional. A read-only list drops `form` (no more `validation: undefined as any`): `ListPage` then offers no "New" button and no create or edit dialog. Configs without `permissions` and with a `form` behave exactly as before.
55
+
56
+ - a936899: Queue dashboard: module and job labels (#7).
57
+
58
+ - `QueueTabbedDashboard` takes `moduleLabels` (module key → `I18nText`), used as the group titles in the Real-time and Configuration tabs. Its key order is the group order.
59
+ - Job labels prefer the job contract's `displayName` over the formatted job name, in queue rows, timeline and history rows, job details and modal titles. A new `jobLabel` prop overrides both.
60
+ - `moduleIcons` also accepts React nodes and icon components (e.g. Lucide icons), not only emoji strings.
61
+ - Both tabs now order module groups the same way (`moduleLabels` order, then alphabetically). The queues table has fixed column widths, so columns line up across groups.
62
+ - The "Disabled"/"Inactive" job badges are neutral instead of the blue `secondary` variant.
63
+
64
+ - c5bf250: `ListPage`'s `toolbarContent` also accepts a function that receives the list's current query (`ListQueryState`: `search`, `filters`, `sorting` and the `params` the list passes to `query.queryFn`), so an app's own export/PDF button can fetch exactly what the list shows. The plain `ReactNode` form keeps working.
65
+ - dd1a1a4: Toolbar filters (`list.toolbar.filters`) gain `allValue`, the explicit "no filter" value: it is dropped from the query, shown when nothing is selected and targeted by resets (chips, toggling a button off). With it, the first option is an ordinary option (rendered as a button), `'todos'`/`'all'` are ordinary values, and `defaultValue` applies even when it equals the first option. `TabToolbar.FilterButtons` accepts the same `allValue`. Filters without `allValue` keep the previous rules.
66
+ - bcb74d5: Close small component gaps found in consumer workarounds:
67
+
68
+ - `masked` fields: `maskType` gains the `'cpf'`, `'cnpj'` and `'cep'` presets next to `'tel'` and is typed as that union (any other string still falls back to `mask`).
69
+ - `textarea` fields: optional `rows` (default 4).
70
+ - `StatCard`: truncated label, subtitle and `tinted` value carry their full text in a `title` tooltip.
71
+ - `BarChart`: `allowDecimals` for the value axis and `categoryAxisWidth` for the category axis in `vertical` layout.
72
+ - `CalendarWithEvents`: `onMonthChange(month)` fires with the first day of the month the user navigates to.
73
+ - `ReportTable`: `showFooter` (default `true`) hides the "Showing X of Y records" line.
74
+ - Form grids (`AdminForm`, `BaseForm`, `ZustandForm`, `WizardForm`) collapse to one column below `sm`, and every `grid`/`span` value now ships as a static class (`col-span-3`/`col-span-4` were never generated). Desktop layout is unchanged.
75
+ - `useCrudMutations`: the mutation resolves after the invalidated list's first refetch attempt, so dialogs close over a fresh list; a failing refetch still settles on its first failure instead of waiting for retries.
76
+ - Dialog header `badge.getLabel` may return an `I18nText` (a `msg()` is resolved), like `badge.labels`.
77
+
78
+ ### Patch Changes
79
+
80
+ - a461d05: The view dialog footer now follows the row actions: **Edit** is hidden when `standard.edit` is `false`, and both **Edit** and **Delete** honor the action's `permission` (against `userPermissions`) and its `visible`/`enabled` for the record — evaluated against the list row, or the fetched record on a deep link. Before, the footer offered Edit whenever `dialogs.edit` existed and Delete whenever `standard.delete` was set, so users who could not edit or delete a row from the table still got the buttons in the dialog. `ViewDialog` gains the optional `canEdit`/`canDelete` gates (also accepted by `CrudViewDialog`'s `footer`).
81
+
3
82
  ## 1.0.4
4
83
 
5
84
  ### Patch Changes
package/README.md CHANGED
@@ -24,7 +24,7 @@ pnpm add @telamonjs/ui framer-motion jspdf jspdf-autotable next next-auth papapa
24
24
  | `jspdf` | `^4.2.1` |
25
25
  | `jspdf-autotable` | `^5.0.7` |
26
26
  | `next` | `^15.5.29 \|\| ^16.4.6` |
27
- | `next-auth` | `5.0.0-beta.31` |
27
+ | `next-auth` | `^5.0.0-beta.20` |
28
28
  | `papaparse` | `^5.5.0` |
29
29
  | `react` | `^18.0.0 \|\| ^19.0.0` |
30
30
  | `react-dom` | `^18.0.0 \|\| ^19.0.0` |
@@ -85,7 +85,7 @@ async `loadField`), `'multiselect'`, `'richtext'` and 31 more; there is no
85
85
  | Area | Highlights |
86
86
  | --- | --- |
87
87
  | Pages | `ListPage`, `DetailPage`, `CreatePage`, `EditPage` |
88
- | Dialogs | `CreateDialog`, `EditDialog`, `ViewDialog`, `ViewPortalDialog` (launcher grid, inline per-section editing), `DialogFrame`, `SplitDialogFrame` |
88
+ | Dialogs | `CreateDialog`, `EditDialog`, `ViewDialog`, `ViewPortalDialog` (launcher grid, inline per-section editing), `DialogFrame`, `SplitDialogFrame`, `ConfirmActionDialog` (validated inputs incl. dates, free `body`, dialog- or caller-controlled `pending`) |
89
89
  | Forms | `AdminForm`, `CreateForm`, `EditForm`, `Stepper`, `FileUpload`, `useUnsavedChangesGuard` |
90
90
  | Field system | 36 field types; `registerFieldRenderer` adds your own |
91
91
  | Shell | `AdminShell` (sidebar, breadcrumb, header, Cmd+K palette fed from your menu), `ShellPage`, `AdminTabs`, `ImpersonationBanner` |
@@ -18,6 +18,12 @@ export interface CalendarWithEventsProps {
18
18
  onEventClick?: (event: CalendarEvent) => void;
19
19
  className?: string;
20
20
  defaultDate?: Date;
21
+ /**
22
+ * Called with the first day of the newly shown month whenever the user
23
+ * navigates (previous/next/today) — fetch that month's events here. Not
24
+ * called on mount: load the `defaultDate` month yourself
25
+ */
26
+ onMonthChange?: (month: Date) => void;
21
27
  }
22
28
  /**
23
29
  * CalendarWithEvents - Calendar with events and navigation
@@ -37,4 +43,4 @@ export interface CalendarWithEventsProps {
37
43
  * />
38
44
  * ```
39
45
  */
40
- export declare function CalendarWithEvents({ events, onDateClick, onEventClick, className, defaultDate, }: CalendarWithEventsProps): import("react").JSX.Element;
46
+ export declare function CalendarWithEvents({ events, onDateClick, onEventClick, className, defaultDate, onMonthChange, }: CalendarWithEventsProps): import("react").JSX.Element;
@@ -28,7 +28,8 @@ function CalendarWithEvents({
28
28
  onDateClick,
29
29
  onEventClick,
30
30
  className,
31
- defaultDate = /* @__PURE__ */ new Date()
31
+ defaultDate = /* @__PURE__ */ new Date(),
32
+ onMonthChange
32
33
  }) {
33
34
  const t = useTelamonjsT();
34
35
  const dateFnsLocale = useDateFnsLocale();
@@ -53,15 +54,13 @@ function CalendarWithEvents({
53
54
  const getEventsForDay = (date) => {
54
55
  return events.filter((event) => isSameDay(event.date, date));
55
56
  };
56
- const handlePrevMonth = () => {
57
- setCurrentMonth(subMonths(currentMonth, 1));
58
- };
59
- const handleNextMonth = () => {
60
- setCurrentMonth(addMonths(currentMonth, 1));
61
- };
62
- const handleToday = () => {
63
- setCurrentMonth(/* @__PURE__ */ new Date());
57
+ const goToMonth = (month) => {
58
+ setCurrentMonth(month);
59
+ if (!isSameMonth(month, currentMonth)) onMonthChange?.(startOfMonth(month));
64
60
  };
61
+ const handlePrevMonth = () => goToMonth(subMonths(currentMonth, 1));
62
+ const handleNextMonth = () => goToMonth(addMonths(currentMonth, 1));
63
+ const handleToday = () => goToMonth(/* @__PURE__ */ new Date());
65
64
  return /* @__PURE__ */ jsxs(Card, { className, children: [
66
65
  /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
67
66
  /* @__PURE__ */ jsx(CardTitle, { className: "text-xl", children: format(currentMonth, "MMMM yyyy", { locale: dateFnsLocale }) }),
@@ -35,6 +35,7 @@ var TintedCard = memo(function TintedCard2({
35
35
  const { number } = useFormat();
36
36
  const Icon = resolveIcon(icon);
37
37
  const styles = cardColors.tinted[color];
38
+ const shownValue = formatValue(value, formatNumber, number);
38
39
  const isMini = size === "mini";
39
40
  const isCompact = size === "compact" || isMini;
40
41
  return /* @__PURE__ */ jsxs(
@@ -86,7 +87,8 @@ var TintedCard = memo(function TintedCard2({
86
87
  styles.value,
87
88
  isMini ? "text-xs" : isCompact ? "text-sm" : "text-lg"
88
89
  ),
89
- children: formatValue(value, formatNumber, number)
90
+ title: shownValue,
91
+ children: shownValue
90
92
  }
91
93
  ),
92
94
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
@@ -102,7 +104,14 @@ var TintedCard = memo(function TintedCard2({
102
104
  ),
103
105
  pulse && Number(value) > 0 && /* @__PURE__ */ jsx(PulseDot, {})
104
106
  ] }),
105
- subtitle && !isMini && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground truncate", children: subtitle })
107
+ subtitle && !isMini && /* @__PURE__ */ jsx(
108
+ "p",
109
+ {
110
+ className: "text-[10px] text-muted-foreground truncate",
111
+ title: subtitle,
112
+ children: subtitle
113
+ }
114
+ )
106
115
  ] })
107
116
  ]
108
117
  }
@@ -158,13 +167,21 @@ var OutlinedCard = memo(function OutlinedCard2({
158
167
  "text-[11px] font-medium text-muted-foreground",
159
168
  wrapLabel ? "break-words" : "truncate"
160
169
  ),
170
+ title: wrapLabel ? void 0 : label,
161
171
  children: label
162
172
  }
163
173
  ),
164
174
  pulse && Number(value) > 0 && /* @__PURE__ */ jsx(PulseDot, {})
165
175
  ] }),
166
176
  /* @__PURE__ */ jsx("p", { className: "text-lg font-bold tabular-nums leading-tight text-foreground", children: formatValue(value, formatNumber, number) }),
167
- subtitle && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground truncate", children: subtitle }),
177
+ subtitle && /* @__PURE__ */ jsx(
178
+ "p",
179
+ {
180
+ className: "text-xs text-muted-foreground truncate",
181
+ title: subtitle,
182
+ children: subtitle
183
+ }
184
+ ),
168
185
  badge && /* @__PURE__ */ jsx(
169
186
  Badge,
170
187
  {
@@ -259,6 +276,7 @@ var AccentCard = memo(function AccentCard2({
259
276
  wrapLabel ? "break-words" : "truncate",
260
277
  isCompact ? "text-[11px]" : "text-sm"
261
278
  ),
279
+ title: wrapLabel ? void 0 : label,
262
280
  children: label
263
281
  }
264
282
  ),
@@ -271,6 +289,7 @@ var AccentCard = memo(function AccentCard2({
271
289
  "text-muted-foreground truncate",
272
290
  isCompact ? "text-[10px]" : "text-xs"
273
291
  ),
292
+ title: subtitle,
274
293
  children: subtitle
275
294
  }
276
295
  ),
@@ -13,6 +13,17 @@ export interface BarChartProps {
13
13
  xAxisLabel?: string;
14
14
  yAxisLabel?: string;
15
15
  layout?: 'horizontal' | 'vertical';
16
+ /**
17
+ * Whether the value axis may show fractional ticks (recharts
18
+ * `allowDecimals`). Pass `false` for counts. Default: `true`
19
+ */
20
+ allowDecimals?: boolean;
21
+ /**
22
+ * Width in px of the category axis (the `name` labels) in `vertical`
23
+ * layout — widen it for long labels. In `horizontal` layout the category
24
+ * axis is the X axis and this is ignored. Default: recharts' 60
25
+ */
26
+ categoryAxisWidth?: number;
16
27
  }
17
28
  /**
18
29
  * BarChart - Responsive bar chart
@@ -29,4 +40,4 @@ export interface BarChartProps {
29
40
  * />
30
41
  * ```
31
42
  */
32
- export declare function BarChart({ data, dataKeys, colors, height, showGrid, showLegend, className, xAxisLabel, yAxisLabel, layout, }: BarChartProps): import("react").JSX.Element;
43
+ export declare function BarChart({ data, dataKeys, colors, height, showGrid, showLegend, className, xAxisLabel, yAxisLabel, layout, allowDecimals, categoryAxisWidth, }: BarChartProps): import("react").JSX.Element;
@@ -13,6 +13,10 @@ import {
13
13
  } from "recharts";
14
14
  import { cn } from "../../utils/index.js";
15
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
+ var BAR_RADIUS = {
17
+ horizontal: [4, 4, 0, 0],
18
+ vertical: [0, 4, 4, 0]
19
+ };
16
20
  var DEFAULT_COLORS = [
17
21
  "#3b82f6",
18
22
  // blue
@@ -37,7 +41,9 @@ function BarChart({
37
41
  className,
38
42
  xAxisLabel,
39
43
  yAxisLabel,
40
- layout = "horizontal"
44
+ layout = "horizontal",
45
+ allowDecimals = true,
46
+ categoryAxisWidth
41
47
  }) {
42
48
  return /* @__PURE__ */ jsx("div", { className: cn("w-full", className), children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(
43
49
  RechartsBarChart,
@@ -67,6 +73,7 @@ function BarChart({
67
73
  /* @__PURE__ */ jsx(
68
74
  YAxis,
69
75
  {
76
+ allowDecimals,
70
77
  label: yAxisLabel ? { value: yAxisLabel, angle: -90, position: "insideLeft" } : void 0
71
78
  }
72
79
  )
@@ -75,6 +82,7 @@ function BarChart({
75
82
  XAxis,
76
83
  {
77
84
  type: "number",
85
+ allowDecimals,
78
86
  label: xAxisLabel ? {
79
87
  value: xAxisLabel,
80
88
  position: "insideBottom",
@@ -87,6 +95,7 @@ function BarChart({
87
95
  {
88
96
  dataKey: "name",
89
97
  type: "category",
98
+ width: categoryAxisWidth,
90
99
  label: yAxisLabel ? { value: yAxisLabel, angle: -90, position: "insideLeft" } : void 0
91
100
  }
92
101
  )
@@ -107,7 +116,7 @@ function BarChart({
107
116
  {
108
117
  dataKey: key,
109
118
  fill: colors[index % colors.length],
110
- radius: [4, 4, 0, 0]
119
+ radius: BAR_RADIUS[layout]
111
120
  },
112
121
  key
113
122
  ))
@@ -59,6 +59,7 @@ function convertSingleField(field) {
59
59
  if (fieldObj.dependsOn) converted.dependsOn = fieldObj.dependsOn;
60
60
  if (fieldObj.mask) converted.mask = fieldObj.mask;
61
61
  if (fieldObj.maskType) converted.maskType = fieldObj.maskType;
62
+ if (fieldObj.rows) converted.rows = fieldObj.rows;
62
63
  if (fieldObj.uploadFn)
63
64
  converted.uploadFn = fieldObj.uploadFn;
64
65
  if (fieldObj.path) converted.path = fieldObj.path;
@@ -4,17 +4,7 @@
4
4
  import { MoreHorizontal } from "lucide-react";
5
5
  import { usePathname, useRouter } from "next/navigation";
6
6
  import React, { useCallback, useMemo, useState } from "react";
7
- import {
8
- AlertDialog,
9
- AlertDialogAction,
10
- AlertDialogCancel,
11
- AlertDialogContent,
12
- AlertDialogDescription,
13
- AlertDialogFooter,
14
- AlertDialogHeader,
15
- AlertDialogTitle,
16
- AlertDialogTrigger
17
- } from "../../ui/alert-dialog.js";
7
+ import { ConfirmActionDialog } from "../dialog/confirm-action-dialog.js";
18
8
  import { Badge } from "../../ui/badge.js";
19
9
  import { Button } from "../../ui/button.js";
20
10
  import {
@@ -26,6 +16,7 @@ import {
26
16
  } from "../../ui/dropdown-menu.js";
27
17
  import { toast } from "sonner";
28
18
  import { wasToasted } from "../../utils/toasted-error.js";
19
+ import { actionEnabled, actionGranted, actionVisible } from "./action-access.js";
29
20
  import { getIconFromName } from "../../utils/icon.js";
30
21
  import { TEST_IDS, getActionAccessibilityAttrs } from "../../utils/test-ids.js";
31
22
  import { useTelamonjsT, useText } from "../../i18n/use-t.js";
@@ -42,22 +33,23 @@ async function runAction({
42
33
  router,
43
34
  onActionComplete,
44
35
  onLoadingChange,
45
- onSettled,
36
+ ctx,
46
37
  text,
47
38
  fallbackError
48
39
  }) {
49
40
  onLoadingChange?.(true);
41
+ const args = (arg) => ctx ? [arg, ctx] : [arg];
50
42
  try {
51
43
  let result;
52
44
  if (action.href) {
53
45
  const href = typeof action.href === "function" ? action.href(row) : action.href;
54
46
  router.push(href);
55
- return;
47
+ return true;
56
48
  } else if (action.onClick) {
57
- result = await action.onClick(row);
49
+ result = await action.onClick(...args(row));
58
50
  } else if (action.handler) {
59
51
  const handlerArg = actionId === "delete" ? row.id : row;
60
- result = await action.handler(handlerArg);
52
+ result = await action.handler(...args(handlerArg));
61
53
  }
62
54
  if (action.onSuccess) {
63
55
  action.onSuccess(row, result);
@@ -69,6 +61,7 @@ async function runAction({
69
61
  if (onActionComplete) {
70
62
  await onActionComplete(actionId, row, result);
71
63
  }
64
+ return true;
72
65
  } catch (error) {
73
66
  const err = error;
74
67
  if (action.onError) {
@@ -76,53 +69,38 @@ async function runAction({
76
69
  }
77
70
  const errorMessage = action.errorMessage ? typeof action.errorMessage === "function" ? action.errorMessage(row, err) : action.errorMessage : err.message || fallbackError;
78
71
  if (action.errorMessage || !wasToasted(err)) toast.error(text(errorMessage));
72
+ return false;
79
73
  } finally {
80
74
  onLoadingChange?.(false);
81
- onSettled?.();
82
75
  }
83
76
  }
84
- function ConfirmActionDialog({
77
+ function RowConfirmDialog({
85
78
  action,
86
79
  row,
87
80
  open,
88
81
  onOpenChange,
89
- onConfirm,
82
+ onRun,
90
83
  children
91
84
  }) {
92
85
  const t = useTelamonjsT();
93
- const text = useText();
94
- const confirmConfig = action.confirmDialog === true ? {
95
- title: t("dialog.confirmActionTitle"),
96
- description: t("dialog.confirmActionDescription"),
97
- confirmText: t("common.confirm"),
98
- cancelText: t("common.cancel"),
99
- variant: "default"
100
- } : action.confirmDialog || {};
101
- return /* @__PURE__ */ jsxs(AlertDialog, { open, onOpenChange, children: [
102
- children && /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: true, children }),
103
- /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
104
- /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
105
- /* @__PURE__ */ jsx(AlertDialogTitle, { children: text(
106
- typeof confirmConfig.title === "function" ? confirmConfig.title(row) : confirmConfig.title
107
- ) }),
108
- confirmConfig.description && /* @__PURE__ */ jsx(AlertDialogDescription, { children: text(
109
- typeof confirmConfig.description === "function" ? confirmConfig.description(row) : confirmConfig.description
110
- ) })
111
- ] }),
112
- /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
113
- /* @__PURE__ */ jsx(AlertDialogCancel, { "data-testid": "modal-cancel", children: text(confirmConfig.cancelText) || t("common.cancel") }),
114
- /* @__PURE__ */ jsx(
115
- AlertDialogAction,
116
- {
117
- "data-testid": "modal-confirm",
118
- className: confirmConfig.variant === "destructive" ? "bg-red-500 text-white hover:bg-red-600" : "",
119
- onClick: onConfirm,
120
- children: text(confirmConfig.confirmText) || t("common.confirm")
121
- }
122
- )
123
- ] })
124
- ] })
125
- ] });
86
+ const config = typeof action.confirmDialog === "object" ? action.confirmDialog : void 0;
87
+ const inputs = config?.inputs?.length ? config.inputs : void 0;
88
+ const ofRow = (v) => typeof v === "function" ? v(row) : v;
89
+ return /* @__PURE__ */ jsx(
90
+ ConfirmActionDialog,
91
+ {
92
+ open,
93
+ onOpenChange,
94
+ title: ofRow(config?.title),
95
+ description: config ? ofRow(config.description) : t("dialog.confirmActionDescription"),
96
+ confirmText: config?.confirmText,
97
+ cancelText: config?.cancelText,
98
+ variant: config?.variant,
99
+ inputs,
100
+ onConfirm: (values) => onRun(inputs ? { inputs: values } : void 0),
101
+ children
102
+ }
103
+ );
126
104
  }
127
105
  function ActionButton({
128
106
  action,
@@ -137,14 +115,8 @@ function ActionButton({
137
115
  const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
138
116
  const { visible, enabled, loading, tooltip, badge } = action;
139
117
  const resolvedLabel = text(action.label);
140
- const isVisible = useMemo(() => {
141
- if (visible === void 0) return true;
142
- return typeof visible === "function" ? visible(row) : visible;
143
- }, [visible, row]);
144
- const isEnabled = useMemo(() => {
145
- if (enabled === void 0) return true;
146
- return typeof enabled === "function" ? enabled(row) : enabled;
147
- }, [enabled, row]);
118
+ const isVisible = useMemo(() => actionVisible({ visible }, row), [visible, row]);
119
+ const isEnabled = useMemo(() => actionEnabled({ enabled }, row), [enabled, row]);
148
120
  const isActionLoading = useMemo(() => {
149
121
  if (loading === void 0) return isLoading;
150
122
  return typeof loading === "function" ? loading(row) : loading;
@@ -181,14 +153,14 @@ function ActionButton({
181
153
  });
182
154
  }, [actionId, accessibleName, resolvedLabel, row, isActionLoading]);
183
155
  const executeAction = useCallback(
184
- () => runAction({
156
+ (ctx) => runAction({
185
157
  action,
186
158
  row,
187
159
  actionId,
188
160
  router,
189
161
  onActionComplete,
190
162
  onLoadingChange: setIsLoading,
191
- onSettled: () => setConfirmDialogOpen(false),
163
+ ctx,
192
164
  text,
193
165
  fallbackError: t("toast.unknownError")
194
166
  }),
@@ -233,13 +205,13 @@ function ActionButton({
233
205
  if (action.confirmDialog) {
234
206
  return withDisabledHint(
235
207
  /* @__PURE__ */ jsx(
236
- ConfirmActionDialog,
208
+ RowConfirmDialog,
237
209
  {
238
210
  action,
239
211
  row,
240
212
  open: confirmDialogOpen,
241
213
  onOpenChange: setConfirmDialogOpen,
242
- onConfirm: executeAction,
214
+ onRun: executeAction,
243
215
  children: button
244
216
  }
245
217
  )
@@ -333,27 +305,24 @@ function DataTableActions({
333
305
  [config]
334
306
  );
335
307
  const { filteredInlineActions, filteredDropdownActions } = useMemo(() => {
336
- const granted = config.userPermissions ? new Set(config.userPermissions) : null;
337
- const allowed = (action) => {
338
- if (!action.permission || !granted) return true;
339
- const required = Array.isArray(action.permission) ? action.permission : [action.permission];
340
- return required.some((perm) => granted.has(perm));
341
- };
308
+ const granted = config.userPermissions ? new Set(config.userPermissions) : void 0;
309
+ const allowed = (action) => actionGranted(action.permission, granted, config.can);
342
310
  return {
343
311
  filteredInlineActions: allActions.inline.filter((a) => allowed(a.config)),
344
312
  filteredDropdownActions: allActions.dropdown.filter(
345
313
  (a) => allowed(a.config)
346
314
  )
347
315
  };
348
- }, [allActions, config.userPermissions]);
316
+ }, [allActions, config.userPermissions, config.can]);
349
317
  const [pendingConfirm, setPendingConfirm] = useState(null);
350
318
  const runMenuAction = useCallback(
351
- (actionId, action) => void runAction({
319
+ (actionId, action, ctx) => runAction({
352
320
  action,
353
321
  row: row.original,
354
322
  actionId,
355
323
  router,
356
324
  onActionComplete: handleActionComplete,
325
+ ctx,
357
326
  text,
358
327
  fallbackError: t("toast.unknownError")
359
328
  }),
@@ -407,9 +376,8 @@ function DataTableActions({
407
376
  }
408
377
  ) }),
409
378
  /* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", children: overflowActions.map(({ id, config: actionConfig }, index) => {
410
- const isVisible = actionConfig.visible === void 0 || (typeof actionConfig.visible === "function" ? actionConfig.visible(row.original) : actionConfig.visible);
411
- if (!isVisible) return null;
412
- const isEnabled = actionConfig.enabled === void 0 || (typeof actionConfig.enabled === "function" ? actionConfig.enabled(row.original) : actionConfig.enabled);
379
+ if (!actionVisible(actionConfig, row.original)) return null;
380
+ const isEnabled = actionEnabled(actionConfig, row.original);
413
381
  const tooltip = actionConfig.tooltip;
414
382
  const tooltipText = typeof tooltip === "function" ? tooltip(row.original) : typeof tooltip === "string" || isMessageRef(tooltip) ? text(tooltip) : tooltip ? text(tooltip.content) : "";
415
383
  const label = text(actionConfig.label) || tooltipText || id;
@@ -426,7 +394,7 @@ function DataTableActions({
426
394
  if (actionConfig.confirmDialog) {
427
395
  setPendingConfirm({ id, config: actionConfig });
428
396
  } else {
429
- runMenuAction(id, actionConfig);
397
+ void runMenuAction(id, actionConfig);
430
398
  }
431
399
  },
432
400
  children: [
@@ -447,7 +415,7 @@ function DataTableActions({
447
415
  }) })
448
416
  ] }),
449
417
  pendingConfirm && /* @__PURE__ */ jsx(
450
- ConfirmActionDialog,
418
+ RowConfirmDialog,
451
419
  {
452
420
  action: pendingConfirm.config,
453
421
  row: row.original,
@@ -455,7 +423,7 @@ function DataTableActions({
455
423
  onOpenChange: (open) => {
456
424
  if (!open) setPendingConfirm(null);
457
425
  },
458
- onConfirm: () => runMenuAction(pendingConfirm.id, pendingConfirm.config)
426
+ onRun: (ctx) => runMenuAction(pendingConfirm.id, pendingConfirm.config, ctx)
459
427
  }
460
428
  )
461
429
  ] });
@@ -0,0 +1,22 @@
1
+ import type { ActionConfig } from '../../types/actions';
2
+ import type { CrudConfig, CrudPermissions } from '../../types/crud';
3
+ /**
4
+ * Access rules of a row action, shared by every surface that offers it: the row
5
+ * buttons and menu (`DataTableActions`) and the view dialog footer (`ListPage`).
6
+ * One rule, so the footer never offers what the row hides.
7
+ */
8
+ /**
9
+ * `permission` (any of them) against `can` when given, else against
10
+ * `userPermissions`. Neither = everything allowed.
11
+ */
12
+ export declare function actionGranted(permission: ActionConfig['permission'], userPermissions: readonly string[] | ReadonlySet<string> | undefined, can?: (permission: string) => boolean): boolean;
13
+ /**
14
+ * A CrudConfig operation (`permissions.create`, …) against the same checker the
15
+ * row actions use: `permissions.can` or `actionsConfig.can`, else
16
+ * `actionsConfig.userPermissions`.
17
+ */
18
+ export declare function crudGranted(config: Pick<CrudConfig, 'permissions' | 'actionsConfig'>, operation: keyof Omit<CrudPermissions, 'can'>): boolean;
19
+ /** `visible` for this row (`undefined` = visible). */
20
+ export declare function actionVisible<TData>(action: Pick<ActionConfig<TData>, 'visible'>, row: TData): boolean;
21
+ /** `enabled` for this row (`undefined` = enabled). */
22
+ export declare function actionEnabled<TData>(action: Pick<ActionConfig<TData>, 'enabled'>, row: TData): boolean;
@@ -0,0 +1,33 @@
1
+ // src/components/data/action-access.ts
2
+ function actionGranted(permission, userPermissions, can) {
3
+ if (!permission) return true;
4
+ const required = Array.isArray(permission) ? permission : [permission];
5
+ if (can) return required.some((perm) => can(perm));
6
+ if (!userPermissions) return true;
7
+ const granted = userPermissions instanceof Set ? userPermissions : new Set(userPermissions);
8
+ return required.some((perm) => granted.has(perm));
9
+ }
10
+ function crudGranted(config, operation) {
11
+ const actions = config.actionsConfig || void 0;
12
+ return actionGranted(
13
+ config.permissions?.[operation],
14
+ actions?.userPermissions,
15
+ actions?.can ?? config.permissions?.can
16
+ );
17
+ }
18
+ function actionVisible(action, row) {
19
+ const { visible } = action;
20
+ if (visible === void 0) return true;
21
+ return typeof visible === "function" ? visible(row) : visible;
22
+ }
23
+ function actionEnabled(action, row) {
24
+ const { enabled } = action;
25
+ if (enabled === void 0) return true;
26
+ return typeof enabled === "function" ? enabled(row) : enabled;
27
+ }
28
+ export {
29
+ actionEnabled,
30
+ actionGranted,
31
+ actionVisible,
32
+ crudGranted
33
+ };
@@ -21,6 +21,8 @@ export interface ReportTableProps<T> {
21
21
  className?: string;
22
22
  stickyHeader?: boolean;
23
23
  labels?: Partial<ReportTableLabels>;
24
+ /** Show the "Showing X of Y records" line under the table. Default: `true` */
25
+ showFooter?: boolean;
24
26
  /**
25
27
  * Attributes for the scroll box (the `maxHeight` container). Pass
26
28
  * `{ tabIndex: 0, role: 'region', 'aria-label': '…' }` so keyboard users
@@ -38,5 +40,5 @@ export interface ReportTableProps<T> {
38
40
  *
39
41
  * @category Data
40
42
  */
41
- export declare function ReportTable<T extends Record<string, unknown>>({ data, columns, pageSize, maxHeight, emptyMessage, className, stickyHeader, labels: labelOverrides, scrollProps, }: ReportTableProps<T>): import("react").JSX.Element;
43
+ export declare function ReportTable<T extends Record<string, unknown>>({ data, columns, pageSize, maxHeight, emptyMessage, className, stickyHeader, labels: labelOverrides, showFooter, scrollProps, }: ReportTableProps<T>): import("react").JSX.Element;
42
44
  export { ReportTable as SimpleTable };