@telamonjs/ui 1.1.0 → 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 (52) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +2 -2
  3. package/dist/components/charts/BarChart.js +5 -1
  4. package/dist/components/dialog/confirm-action-dialog.d.ts +47 -15
  5. package/dist/components/dialog/confirm-action-dialog.js +33 -21
  6. package/dist/components/forms/AdminForm.js +2 -1
  7. package/dist/data/InfiniteList.js +2 -4
  8. package/dist/data/MobileCard.js +4 -1
  9. package/dist/data/VirtualDataTable.js +4 -1
  10. package/dist/data/datatable/TableDesktopView.js +2 -5
  11. package/dist/data/row-click.d.ts +10 -0
  12. package/dist/data/row-click.js +11 -0
  13. package/dist/exports/types-constants.d.ts +1 -1
  14. package/dist/exports/types-constants.js +1 -1
  15. package/dist/i18n/messages/en/index.d.ts +1 -0
  16. package/dist/i18n/messages/en/list.d.ts +1 -0
  17. package/dist/i18n/messages/en/list.js +1 -0
  18. package/dist/i18n/messages/en/queue.js +1 -1
  19. package/dist/i18n/messages/es/index.d.ts +1 -0
  20. package/dist/i18n/messages/es/list.d.ts +1 -0
  21. package/dist/i18n/messages/es/list.js +1 -0
  22. package/dist/i18n/messages/pt-BR/index.d.ts +8 -7
  23. package/dist/i18n/messages/pt-BR/list.d.ts +1 -0
  24. package/dist/i18n/messages/pt-BR/list.js +1 -0
  25. package/dist/i18n/messages/pt-BR/queue.d.ts +7 -7
  26. package/dist/i18n/messages/pt-BR/queue.js +7 -7
  27. package/dist/i18n/use-t.d.ts +8 -7
  28. package/dist/pages/list-page/ListPageTable.d.ts +1 -1
  29. package/dist/pages/list-page/ListPageTable.js +1 -1
  30. package/dist/pages/list-page/useDialogUrlSync.d.ts +10 -4
  31. package/dist/pages/list-page/useDialogUrlSync.js +7 -11
  32. package/dist/queue/components/DispatchJobModal.js +5 -2
  33. package/dist/queue/components/JobDetailPage.d.ts +8 -0
  34. package/dist/queue/components/JobDetailPage.js +19 -11
  35. package/dist/queue/components/QueueDashboard.js +3 -1
  36. package/dist/queue/components/QueueTabbedDashboard.d.ts +2 -1
  37. package/dist/queue/components/QueueTabbedDashboard.js +2 -24
  38. package/dist/queue/components/QueuesTable.js +342 -275
  39. package/dist/queue/components/jobs-list-modal/job-row.js +1 -1
  40. package/dist/queue/components/labels-context.d.ts +9 -1
  41. package/dist/queue/components/labels-context.js +3 -2
  42. package/dist/queue/components/labels-provider.d.ts +11 -0
  43. package/dist/queue/components/labels-provider.js +35 -0
  44. package/dist/queue/components/tabs/ConfiguracaoTab.js +4 -4
  45. package/dist/queue/components/tabs/TempoRealTab.js +3 -2
  46. package/dist/queue/components/tabs/historico/history-job-row.js +1 -1
  47. package/dist/queue/lib/action-message.d.ts +3 -2
  48. package/dist/queue/lib/action-message.js +2 -2
  49. package/dist/queue/types.d.ts +3 -0
  50. package/dist/types/actions.d.ts +9 -1
  51. package/dist/types/crud.d.ts +6 -3
  52. package/package.json +2 -2
@@ -49,7 +49,7 @@ var JobRow = memo(function JobRow2({
49
49
  /* @__PURE__ */ jsx("div", { className: cn("p-1.5 rounded-lg flex-shrink-0", config.bgColor, config.color), children: status === "active" ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ jsx("span", { className: "h-3.5 w-3.5 flex items-center justify-center", children: config.icon }) }),
50
50
  /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
51
51
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
52
- /* @__PURE__ */ jsx("span", { className: "font-medium text-sm truncate", children: jobLabel(job.queueName) }),
52
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-sm truncate", title: jobLabel(job.queueName), children: jobLabel(job.queueName) }),
53
53
  /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground font-mono flex-shrink-0", children: [
54
54
  "#",
55
55
  truncateId(job.id)
@@ -13,11 +13,19 @@ export interface QueueLabels {
13
13
  jobLabel?: (jobName: string) => I18nText | undefined;
14
14
  /** Job name → the contract's `displayName`, as served by the stats endpoint. */
15
15
  displayNames?: Readonly<Record<string, string>>;
16
+ /** Job name → the contract's `description`, as served by the stats endpoint. */
17
+ descriptions?: Readonly<Record<string, string>>;
16
18
  }
17
19
  export declare const QueueLabelsContext: import("react").Context<QueueLabels>;
18
20
  export interface QueueLabelResolvers {
19
- /** `jobLabel` override → contract display name → `formatQueueName`. */
21
+ /**
22
+ * The one job-name precedence of the dashboard: the app's `jobLabel` →
23
+ * the contract's `displayName` (which the API derives as contract `label`
24
+ * → `description` → raw name) → `formatQueueName`.
25
+ */
20
26
  jobLabel: (jobName: string, displayName?: string) => string;
27
+ /** The contract's `description`, or `undefined` when it has none. */
28
+ jobDescription: (jobName: string) => string | undefined;
21
29
  /** The `moduleLabels` entry, or `undefined` (render the raw key). */
22
30
  moduleLabel: (module: string) => string | undefined;
23
31
  /** `moduleLabels` key order first, then alphabetical by label. */
@@ -6,7 +6,7 @@ import { useText } from "../../i18n/use-t.js";
6
6
  import { formatQueueName } from "../lib/format.js";
7
7
  var QueueLabelsContext = createContext({});
8
8
  function useQueueLabels() {
9
- const { moduleLabels, jobLabel, displayNames } = useContext(QueueLabelsContext);
9
+ const { moduleLabels, jobLabel, displayNames, descriptions } = useContext(QueueLabelsContext);
10
10
  const text = useText();
11
11
  return useMemo(() => {
12
12
  const moduleLabel = (module) => text(moduleLabels?.[module]);
@@ -18,6 +18,7 @@ function useQueueLabels() {
18
18
  return text(jobLabel?.(jobName)) ?? // The backend serves the raw name when the contract has none
19
19
  (contract && contract !== jobName ? contract : formatQueueName(jobName));
20
20
  },
21
+ jobDescription: (jobName) => descriptions?.[jobName] || void 0,
21
22
  moduleLabel,
22
23
  orderModules: (modules) => [...modules].sort(
23
24
  (a, b) => (
@@ -26,7 +27,7 @@ function useQueueLabels() {
26
27
  )
27
28
  )
28
29
  };
29
- }, [moduleLabels, jobLabel, displayNames, text]);
30
+ }, [moduleLabels, jobLabel, displayNames, descriptions, text]);
30
31
  }
31
32
  export {
32
33
  QueueLabelsContext,
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type QueueLabels } from './labels-context';
3
+ /**
4
+ * Provides `moduleLabels`/`jobLabel` plus the contracts' display names and
5
+ * descriptions. Same key as `useQueueStats`: it reads the Real-time tab's
6
+ * cache, fetches once when nothing cached it yet, and never polls on its own.
7
+ * Needs a `QueueApiProvider` above it.
8
+ */
9
+ export declare function QueueLabelsProvider({ moduleLabels, jobLabel, children, }: Pick<QueueLabels, 'moduleLabels' | 'jobLabel'> & {
10
+ children: ReactNode;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use client";
2
+
3
+ // src/queue/components/labels-provider.tsx
4
+ import { useMemo } from "react";
5
+ import { useQuery } from "@tanstack/react-query";
6
+ import { LIB_QUERY_META } from "../../utils/query-meta.js";
7
+ import { useQueueApi } from "../api/provider.js";
8
+ import { QueueLabelsContext } from "./labels-context.js";
9
+ import { jsx } from "react/jsx-runtime";
10
+ var toContractTexts = (stats) => ({
11
+ displayNames: Object.fromEntries(stats.queues.map((q) => [q.name, q.displayName])),
12
+ descriptions: Object.fromEntries(stats.queues.map((q) => [q.name, q.description]))
13
+ });
14
+ function QueueLabelsProvider({
15
+ moduleLabels,
16
+ jobLabel,
17
+ children
18
+ }) {
19
+ const api = useQueueApi();
20
+ const { data } = useQuery({
21
+ meta: LIB_QUERY_META,
22
+ queryKey: ["queue", "stats"],
23
+ queryFn: () => api.getStats(),
24
+ select: toContractTexts,
25
+ staleTime: Infinity
26
+ });
27
+ const value = useMemo(
28
+ () => ({ moduleLabels, jobLabel, ...data }),
29
+ [moduleLabels, jobLabel, data]
30
+ );
31
+ return /* @__PURE__ */ jsx(QueueLabelsContext.Provider, { value, children });
32
+ }
33
+ export {
34
+ QueueLabelsProvider
35
+ };
@@ -122,7 +122,7 @@ function ConfiguracaoTab({
122
122
  enabled: !currentJob.enabled
123
123
  });
124
124
  toast.success(currentJob.enabled ? t("queue.config.jobDeactivated") : t("queue.config.jobActivated"), {
125
- description: jobName
125
+ description: jobLabel(jobName)
126
126
  });
127
127
  } catch (error) {
128
128
  toast.error(t("queue.config.statusChangeError"), {
@@ -158,7 +158,7 @@ function ConfiguracaoTab({
158
158
  const handleUpdateJob = async (jobName, updates) => {
159
159
  try {
160
160
  await updateJobMutation.mutateAsync({ jobName, updates });
161
- toast.success(t("queue.config.settingsUpdated"), { description: jobName });
161
+ toast.success(t("queue.config.settingsUpdated"), { description: jobLabel(jobName) });
162
162
  return true;
163
163
  } catch (error) {
164
164
  toast.error(t("queue.config.updateError"), {
@@ -305,12 +305,12 @@ function ConfiguracaoTab({
305
305
  ),
306
306
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
307
307
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
308
- /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium", children: title }),
308
+ /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium", title, children: title }),
309
309
  job.orphan && /* @__PURE__ */ jsx(
310
310
  Badge,
311
311
  {
312
312
  variant: "outline",
313
- className: "border-yellow-300 px-1 py-0 text-[10px] text-yellow-600",
313
+ className: "shrink-0 border-yellow-300 px-1 py-0 text-[10px] text-yellow-600",
314
314
  title: t("queue.config.orphanHint"),
315
315
  children: t("queue.config.orphan")
316
316
  }
@@ -397,6 +397,7 @@ function TempoRealTab({
397
397
  }) {
398
398
  "use no memo";
399
399
  const t = useTelamonjsT();
400
+ const { jobLabel } = useQueueLabels();
400
401
  const maxItems = 50;
401
402
  const [selectedJobId, setSelectedJobId] = useState(null);
402
403
  const [searchTerm, setSearchTerm] = useState("");
@@ -420,7 +421,7 @@ function TempoRealTab({
420
421
  try {
421
422
  const result = await queueActionMutation.mutateAsync(action);
422
423
  if (result.success) {
423
- toast.success(actionDoneMessage(t, action, result));
424
+ toast.success(actionDoneMessage(t, action, result, jobLabel(action.queueName)));
424
425
  } else {
425
426
  toast.error(result.message || t("queue.dashboard.actionFailed"));
426
427
  }
@@ -431,7 +432,7 @@ function TempoRealTab({
431
432
  });
432
433
  }
433
434
  },
434
- [queueActionMutation, t]
435
+ [queueActionMutation, t, jobLabel]
435
436
  );
436
437
  const allJobs = useMemo(() => {
437
438
  if (!timelineData?.jobs) return [];
@@ -38,7 +38,7 @@ var HistoryJobRow = React.memo(function HistoryJobRow2({
38
38
  ),
39
39
  children: [
40
40
  /* @__PURE__ */ jsx("span", { className: cn("shrink-0", config?.color), children: config?.icon }),
41
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: formatQueueName(job.queueName) }),
41
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium", title: formatQueueName(job.queueName), children: formatQueueName(job.queueName) }),
42
42
  /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground shrink-0 font-mono text-[11px]", children: [
43
43
  "#",
44
44
  truncateId(job.id, 8)
@@ -3,6 +3,7 @@ import type { ActionResponse, QueueActionParams } from '../api/types';
3
3
  /**
4
4
  * Success toast for a queue action, in the active locale. The backend's
5
5
  * `message` is plain English (`"Queue x: 1 waiting jobs removed"`), so it is
6
- * not shown; `removed` (drain/clean) feeds the plural.
6
+ * not shown; `removed` (drain/clean) feeds the plural. `queueLabel` is the
7
+ * name already resolved by `useQueueLabels().jobLabel` — never the raw key.
7
8
  */
8
- export declare function actionDoneMessage(t: ReturnType<typeof useTelamonjsT>, action: QueueActionParams, result: ActionResponse): string;
9
+ export declare function actionDoneMessage(t: ReturnType<typeof useTelamonjsT>, action: QueueActionParams, result: ActionResponse, queueLabel: string): string;
@@ -6,9 +6,9 @@ var DONE_KEY = {
6
6
  drain: "drain",
7
7
  "retry-all": "retryAll"
8
8
  };
9
- function actionDoneMessage(t, action, result) {
9
+ function actionDoneMessage(t, action, result, queueLabel) {
10
10
  return t(`queue.dashboard.actionDone.${DONE_KEY[action.type]}`, {
11
- queue: action.queueName,
11
+ queue: queueLabel,
12
12
  count: result.removed ?? 0
13
13
  });
14
14
  }
@@ -6,6 +6,7 @@
6
6
  export type JobState = 'waiting' | 'active' | 'delayed' | 'completed' | 'failed';
7
7
  export interface QueueStats {
8
8
  name: string;
9
+ /** Served by the API: contract `label` → contract `description` → `name`. */
9
10
  displayName: string;
10
11
  module: string;
11
12
  description: string;
@@ -52,6 +53,7 @@ export type QueueHealthStatus = 'ok' | 'late' | 'failing' | 'paused';
52
53
  /** Per-queue health — mirrors `QueueHealthEntry` from `@telamonjs/queue`. */
53
54
  export interface QueueHealth {
54
55
  name: string;
56
+ /** Served by the API: contract `label` → contract `description` → `name`. */
55
57
  displayName: string;
56
58
  module: string;
57
59
  dispatchable: boolean;
@@ -189,6 +191,7 @@ export interface TimelineData {
189
191
  }
190
192
  export interface DispatchableJob {
191
193
  name: string;
194
+ /** Served by the API: contract `label` → contract `description` → `name`. */
192
195
  displayName: string;
193
196
  module: string;
194
197
  description: string;
@@ -42,12 +42,20 @@ export interface ConfirmDialogInput {
42
42
  /** Key of the value in `inputs` */
43
43
  name: string;
44
44
  label: I18nText;
45
- type: 'text' | 'textarea' | 'select';
45
+ /** `date` is the native date input; its value is `YYYY-MM-DD` (`''` when empty) */
46
+ type: 'text' | 'textarea' | 'select' | 'date';
46
47
  /** Confirming is blocked while it is empty */
47
48
  required?: boolean;
48
49
  /** Choices of a `select` (value = label) */
49
50
  options?: string[];
50
51
  defaultValue?: string;
52
+ /**
53
+ * Custom rule beyond `required`: return a message to mark the field invalid
54
+ * and block the confirm, `undefined` when valid. Runs (pure, on every
55
+ * render) from the first confirm attempt on, also on empty optional fields,
56
+ * with all the values for cross-field rules. `required` is checked first.
57
+ */
58
+ validate?: (value: string, values: Record<string, string>) => I18nText | undefined;
51
59
  }
52
60
  /**
53
61
  * Second argument of an action's `handler`/`onClick`, passed when its
@@ -194,11 +194,14 @@ export interface ListConfig<T> {
194
194
  /**
195
195
  * Empty-state title for a list with no rows. Applies only when no search/filter is active
196
196
  * (an active search keeps the localized "no results" text). Works for DataTable and InfiniteList.
197
- * Default: localized "No items found". Set it for lists without creation, where the default
198
- * invites adding an item.
197
+ * Default: localized "No items found".
199
198
  */
200
199
  emptyTitle?: I18nText;
201
- /** 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
+ */
202
205
  emptyDescription?: I18nText;
203
206
  /** Table columns definition */
204
207
  columns: CrudColumnDef<T>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telamonjs/ui",
3
- "version": "1.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.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",