@telamonjs/ui 1.3.1 → 1.4.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 (59) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +7 -8
  3. package/dist/components/data/DataTableActions.js +4 -3
  4. package/dist/data/ExportMenu.js +6 -3
  5. package/dist/data/InfiniteList.js +6 -2
  6. package/dist/data/datatable/sort-field.d.ts +14 -0
  7. package/dist/data/datatable/sort-field.js +24 -0
  8. package/dist/data/datatable/useDataTableInstance.js +3 -2
  9. package/dist/data/exportUtils.d.ts +14 -9
  10. package/dist/data/exportUtils.js +56 -56
  11. package/dist/data/missing-peer.d.ts +17 -0
  12. package/dist/data/missing-peer.js +22 -0
  13. package/dist/data/xlsx-writer.d.ts +24 -0
  14. package/dist/data/xlsx-writer.js +141 -0
  15. package/dist/exports/types-constants.d.ts +1 -1
  16. package/dist/exports/types-constants.js +1 -1
  17. package/dist/i18n/messages/en/data.d.ts +1 -0
  18. package/dist/i18n/messages/en/data.js +1 -0
  19. package/dist/i18n/messages/en/index.d.ts +3 -0
  20. package/dist/i18n/messages/en/queue.d.ts +2 -0
  21. package/dist/i18n/messages/en/queue.js +3 -1
  22. package/dist/i18n/messages/es/data.d.ts +1 -0
  23. package/dist/i18n/messages/es/data.js +1 -0
  24. package/dist/i18n/messages/es/index.d.ts +3 -0
  25. package/dist/i18n/messages/es/queue.d.ts +2 -0
  26. package/dist/i18n/messages/es/queue.js +3 -1
  27. package/dist/i18n/messages/pt-BR/data.d.ts +1 -0
  28. package/dist/i18n/messages/pt-BR/data.js +1 -0
  29. package/dist/i18n/messages/pt-BR/index.d.ts +3 -0
  30. package/dist/i18n/messages/pt-BR/queue.d.ts +2 -0
  31. package/dist/i18n/messages/pt-BR/queue.js +3 -1
  32. package/dist/i18n/use-t.d.ts +3 -0
  33. package/dist/pages/ListPage.js +6 -1
  34. package/dist/queue/components/DispatchJobModal.js +157 -115
  35. package/dist/queue/components/JobEventTimeline.js +321 -210
  36. package/dist/queue/hooks/use-queue-events-timeline.d.ts +7 -1
  37. package/dist/queue/hooks/use-queue-events-timeline.js +14 -43
  38. package/dist/queue/hooks/use-queue-sse.js +3 -1
  39. package/dist/queue/types.d.ts +2 -0
  40. package/dist/server/pagination/factory.js +5 -1
  41. package/dist/server/pagination/types.d.ts +6 -2
  42. package/dist/server/pagination/utils.d.ts +6 -3
  43. package/dist/server/pagination/utils.js +13 -7
  44. package/dist/server/prisma-helpers.d.ts +27 -19
  45. package/dist/server/prisma-helpers.js +37 -19
  46. package/dist/stores/datatable-store.d.ts +0 -4
  47. package/dist/stores/datatable-store.js +0 -5
  48. package/dist/stores/form-store.d.ts +5 -0
  49. package/dist/stores/form-store.js +8 -4
  50. package/dist/stores/index.d.ts +1 -1
  51. package/dist/stores/index.js +1 -3
  52. package/dist/stores/sidebar-store.d.ts +1 -1
  53. package/dist/types/actions.d.ts +4 -1
  54. package/dist/types/crud.d.ts +14 -1
  55. package/dist/types/system-config.d.ts +5 -0
  56. package/dist/ui/chart.d.ts +22 -27
  57. package/dist/ui/chart.js +2 -8
  58. package/dist/ui/form.d.ts +1 -1
  59. package/package.json +67 -64
@@ -5,6 +5,9 @@ import { usePageVisibility } from "../../hooks/usePageVisibility.js";
5
5
  import { LIB_QUERY_META } from "../../utils/query-meta.js";
6
6
  var SSE_SAFETY_NET_INTERVAL = 3e4;
7
7
  var DEFAULT_POLL_INTERVAL = 2e3;
8
+ function isRepeatJob(job) {
9
+ return Boolean(job.opts?.repeatJobKey || job.opts?.repeat) || job.id.startsWith("repeat:");
10
+ }
8
11
  function timelinePollInterval({
9
12
  isVisible,
10
13
  active,
@@ -46,61 +49,28 @@ function useQueueEventsTimeline({
46
49
  )
47
50
  ]);
48
51
  const jobsMap = /* @__PURE__ */ new Map();
49
- if (activeJobsResp?.jobs) {
50
- for (const job of activeJobsResp.jobs) {
52
+ const add = (jobs, status) => {
53
+ for (const job of jobs ?? []) {
54
+ if (jobsMap.has(job.id)) continue;
51
55
  jobsMap.set(job.id, {
52
56
  id: job.id,
53
57
  name: job.name,
54
58
  queueName: job.queueName,
55
59
  queueDisplayName: job.queueName,
56
- status: "active",
60
+ status,
57
61
  timestamp: job.timestamp,
58
62
  processedOn: job.processedOn,
59
63
  finishedOn: job.finishedOn,
60
64
  attemptsMade: job.attemptsMade,
61
65
  failedReason: job.failedReason,
62
- returnvalue: job.returnvalue
66
+ returnvalue: job.returnvalue,
67
+ repeat: isRepeatJob(job)
63
68
  });
64
69
  }
65
- }
66
- if (completedJobsResp?.jobs) {
67
- for (const job of completedJobsResp.jobs) {
68
- if (!jobsMap.has(job.id)) {
69
- jobsMap.set(job.id, {
70
- id: job.id,
71
- name: job.name,
72
- queueName: job.queueName,
73
- queueDisplayName: job.queueName,
74
- status: "completed",
75
- timestamp: job.timestamp,
76
- processedOn: job.processedOn,
77
- finishedOn: job.finishedOn,
78
- attemptsMade: job.attemptsMade,
79
- failedReason: job.failedReason,
80
- returnvalue: job.returnvalue
81
- });
82
- }
83
- }
84
- }
85
- if (failedJobsResp?.jobs) {
86
- for (const job of failedJobsResp.jobs) {
87
- if (!jobsMap.has(job.id)) {
88
- jobsMap.set(job.id, {
89
- id: job.id,
90
- name: job.name,
91
- queueName: job.queueName,
92
- queueDisplayName: job.queueName,
93
- status: "failed",
94
- timestamp: job.timestamp,
95
- processedOn: job.processedOn,
96
- finishedOn: job.finishedOn,
97
- attemptsMade: job.attemptsMade,
98
- failedReason: job.failedReason,
99
- returnvalue: job.returnvalue
100
- });
101
- }
102
- }
103
- }
70
+ };
71
+ add(activeJobsResp?.jobs, "active");
72
+ add(completedJobsResp?.jobs, "completed");
73
+ add(failedJobsResp?.jobs, "failed");
104
74
  const allJobs = Array.from(jobsMap.values());
105
75
  return {
106
76
  jobs: allJobs.sort(
@@ -118,6 +88,7 @@ function useQueueEventsTimeline({
118
88
  });
119
89
  }
120
90
  export {
91
+ isRepeatJob,
121
92
  timelinePollInterval,
122
93
  useQueueEventsTimeline
123
94
  };
@@ -5,6 +5,7 @@ import { useEffect, useRef, useState, useCallback } from "react";
5
5
  import { useQueryClient } from "@tanstack/react-query";
6
6
  import { useQueueConfigApi } from "../api/provider.js";
7
7
  import { logger } from "../../utils/logger.js";
8
+ import { isRepeatJob } from "./use-queue-events-timeline.js";
8
9
  function handleJobEventImpl(event, queryClient, refreshStats) {
9
10
  const statusMap = {
10
11
  "job:started": "active",
@@ -46,7 +47,8 @@ function handleJobEventImpl(event, queryClient, refreshStats) {
46
47
  processedOn: jobStatus === "active" ? ts : void 0,
47
48
  finishedOn: jobStatus !== "active" ? ts : void 0,
48
49
  failedReason: event.error,
49
- returnvalue: event.result
50
+ returnvalue: event.result,
51
+ repeat: isRepeatJob({ id: event.jobId })
50
52
  };
51
53
  return { jobs: [newJob, ...prev.jobs].slice(0, 100) };
52
54
  }
@@ -132,6 +132,8 @@ export interface TimelineJob {
132
132
  attemptsMade?: number;
133
133
  failedReason?: string;
134
134
  returnvalue?: unknown;
135
+ /** Iteration of a job scheduler / repeatable (BullMQ `opts.repeatJobKey`) */
136
+ repeat?: boolean;
135
137
  }
136
138
  export interface RedisMetrics {
137
139
  connected_clients: number;
@@ -86,7 +86,11 @@ function createPaginationContext(context) {
86
86
  defaultOrderDirection,
87
87
  sortableFields
88
88
  });
89
- const orderBy = buildOrderByClause(sort.sortBy, sort.sortOrder);
89
+ const orderBy = buildOrderByClause(
90
+ sort.sortBy,
91
+ sort.sortOrder,
92
+ sortableFields
93
+ );
90
94
  const includeClause = buildIncludeClause(include, counts);
91
95
  const queryOptions = {
92
96
  where,
@@ -56,9 +56,13 @@ export interface PaginatedServiceConfig<TModel extends string = string> {
56
56
  defaultOrderBy?: string | string[];
57
57
  defaultOrderDirection?: 'asc' | 'desc';
58
58
  /**
59
- * Fields the client may sort by (as sent in `sortBy`, e.g. `'customer.name'`).
59
+ * Fields the client may sort by, as data paths (`'customer.name'`,
60
+ * `'created_at'`, `'_count.items'`). A legacy TanStack column id
61
+ * (`'customer_name'`, the default wire format) passes when its dotted form
62
+ * is listed; a listed value always wins, so `'created_at'` stays a scalar.
60
63
  * When set, any other `sortBy` is ignored and the default sort applies.
61
- * When absent, any field is accepted.
64
+ * When absent, any field is accepted and underscores are decoded as
65
+ * legacy ids (`created_at` → `created.at`): list snake_case fields.
62
66
  */
63
67
  sortableFields?: string[];
64
68
  visibility?: (user: AuthUser) => PrismaWhereClause;
@@ -23,7 +23,9 @@ export declare function buildWhereClause(searchConditions: SearchCondition | und
23
23
  /**
24
24
  * Sanitize a client-supplied sort: an invalid direction becomes the default
25
25
  * one, and with `sortableFields` set, fields outside it are dropped (an empty
26
- * result falls back to the default sort).
26
+ * result falls back to the default sort). A field passes when it is listed
27
+ * as sent or, for a legacy TanStack id (`customer_name`), when its dotted
28
+ * form (`customer.name`) is listed; the returned field is the listed form.
27
29
  */
28
30
  export declare function resolveSort(sortBy: string | string[] | SortField[], sortOrder: unknown, defaults: {
29
31
  defaultOrderBy: string | string[];
@@ -34,9 +36,10 @@ export declare function resolveSort(sortBy: string | string[] | SortField[], sor
34
36
  sortOrder: 'asc' | 'desc';
35
37
  };
36
38
  /**
37
- * Build orderBy clause from sortBy and sortOrder
39
+ * Build orderBy clause from sortBy and sortOrder (`sortableFields`: see
40
+ * `buildPrismaOrderBy`)
38
41
  */
39
- export declare function buildOrderByClause(sortBy?: string | string[] | SortField[], sortOrder?: string): PrismaWhereClause | PrismaWhereClause[] | undefined;
42
+ export declare function buildOrderByClause(sortBy?: string | string[] | SortField[], sortOrder?: string, sortableFields?: readonly string[]): PrismaWhereClause | PrismaWhereClause[] | undefined;
40
43
  /**
41
44
  * Get unique values for filter options with counts
42
45
  * Requires prisma client to be passed as parameter
@@ -1,6 +1,10 @@
1
1
  // src/server/pagination/utils.ts
2
2
  import { createTranslator } from "next-intl";
3
- import { buildPrismaOrderBy, buildPrismaOrderByMulti } from "../prisma-helpers.js";
3
+ import {
4
+ buildPrismaOrderBy,
5
+ buildPrismaOrderByMulti,
6
+ resolveSortPath
7
+ } from "../prisma-helpers.js";
4
8
  import { DEFAULT_LOCALE } from "../../i18n/locales.js";
5
9
  import { telamonjsMessages } from "../../i18n/messages/index.js";
6
10
  function buildSearchConditions(search, searchFields, mode = "insensitive") {
@@ -108,30 +112,32 @@ var isSortOrder = (value) => value === "asc" || value === "desc";
108
112
  function resolveSort(sortBy, sortOrder, defaults) {
109
113
  const { defaultOrderBy, defaultOrderDirection, sortableFields } = defaults;
110
114
  const fallback = { sortBy: defaultOrderBy, sortOrder: defaultOrderDirection };
111
- const allowed = (field) => !sortableFields || sortableFields.includes(field);
115
+ const resolve = (field) => sortableFields ? resolveSortPath(field, sortableFields) : field;
116
+ const allowed = (field) => !sortableFields || sortableFields.includes(resolve(field));
112
117
  const order = isSortOrder(sortOrder) ? sortOrder : defaultOrderDirection;
113
118
  if (sortBy === defaultOrderBy) return { sortBy, sortOrder: order };
114
119
  if (typeof sortBy === "string") {
115
- return allowed(sortBy) ? { sortBy, sortOrder: order } : fallback;
120
+ return allowed(sortBy) ? { sortBy: resolve(sortBy), sortOrder: order } : fallback;
116
121
  }
117
122
  const fields = sortBy.filter(
118
123
  (s) => !!s && typeof s === "object" && typeof s.field === "string" && allowed(s.field)
119
124
  ).map((s) => ({
120
- field: s.field,
125
+ field: resolve(s.field),
121
126
  order: isSortOrder(s.order) ? s.order : defaultOrderDirection
122
127
  }));
123
128
  return fields.length > 0 ? { sortBy: fields, sortOrder: order } : fallback;
124
129
  }
125
- function buildOrderByClause(sortBy, sortOrder) {
130
+ function buildOrderByClause(sortBy, sortOrder, sortableFields) {
126
131
  if (!sortBy) {
127
132
  return void 0;
128
133
  }
129
134
  if (Array.isArray(sortBy)) {
130
- return buildPrismaOrderByMulti(sortBy);
135
+ return buildPrismaOrderByMulti(sortBy, sortableFields);
131
136
  }
132
137
  return buildPrismaOrderBy(
133
138
  sortBy,
134
- sortOrder || "asc"
139
+ sortOrder || "asc",
140
+ sortableFields
135
141
  );
136
142
  }
137
143
  async function getFilterOptionsForField(prismaClient, modelName, field, baseWhere, visibilityWhere, locale = DEFAULT_LOCALE) {
@@ -1,32 +1,40 @@
1
1
  import { SortField } from '../types/pagination';
2
2
  /**
3
- * Converts a sortBy string from accessorKey format (e.g. "campo.subcampo" or "campo_subcampo")
4
- * to Prisma orderBy format { campo: { subcampo: sortOrder } }
3
+ * The dotted data path a client sort field names.
5
4
  *
6
- * TanStack Table converts dots to underscores in column IDs, so we handle both formats.
5
+ * - A value with a dot is a data path (`list.sortParam: 'path'`): used as-is.
6
+ * - A value listed in `sortableFields` is used as-is (`created_at` stays a scalar).
7
+ * - Otherwise an underscored value is a legacy TanStack id (`customer_name`) and is
8
+ * decoded — with `sortableFields`, only when the decoded path is listed.
7
9
  *
8
- * @example
9
- * buildPrismaOrderBy("categoria.nome", "asc")
10
- * // Returns: { categoria: { nome: "asc" } }
10
+ * @internal shared by the orderBy builders and `resolveSort`
11
+ */
12
+ export declare function resolveSortPath(field: string, sortableFields?: readonly string[]): string;
13
+ /**
14
+ * Converts a client `sortBy` to Prisma `orderBy`.
11
15
  *
12
- * buildPrismaOrderBy("categoria_nome", "asc") // TanStack Table format
13
- * // Returns: { categoria: { nome: "asc" } }
16
+ * Accepts the column's data path (`customer.name`, sent with
17
+ * `list.sortParam: 'path'`) and the legacy TanStack column id (`customer_name`,
18
+ * the default wire format). `_count.<relation>` orders by a relation count.
19
+ * Pass the endpoint's `sortableFields` so a listed snake_case field
20
+ * (`created_at`) is not mistaken for a legacy id.
14
21
  *
15
- * buildPrismaOrderBy("createdAt", "desc")
16
- * // Returns: { createdAt: "desc" }
22
+ * @example
23
+ * buildPrismaOrderBy('customer.name', 'asc') // { customer: { name: 'asc' } }
24
+ * buildPrismaOrderBy('customer_name', 'asc') // { customer: { name: 'asc' } }
25
+ * buildPrismaOrderBy('_count.items', 'desc') // { items: { _count: 'desc' } }
26
+ * buildPrismaOrderBy('created_at', 'asc', ['created_at']) // { created_at: 'asc' }
17
27
  */
18
- export declare function buildPrismaOrderBy(sortBy: string, sortOrder?: 'asc' | 'desc'): any;
28
+ export declare function buildPrismaOrderBy(sortBy: string, sortOrder?: 'asc' | 'desc', sortableFields?: readonly string[]): any;
19
29
  /**
20
- * Converts an array of SortField to Prisma orderBy array format for multi-column sorting
30
+ * Multi-column version of {@link buildPrismaOrderBy}: one Prisma `orderBy`
31
+ * entry per `SortField`, same field rules.
21
32
  *
22
33
  * @example
23
34
  * buildPrismaOrderByMulti([
24
- * { field: "categoria.nome", order: "asc" },
25
- * { field: "vigenciaInicio", order: "desc" }
35
+ * { field: 'categoria.nome', order: 'asc' },
36
+ * { field: 'vigenciaInicio', order: 'desc' },
26
37
  * ])
27
- * // Returns: [
28
- * // { categoria: { nome: "asc" } },
29
- * // { vigenciaInicio: "desc" }
30
- * // ]
38
+ * // [{ categoria: { nome: 'asc' } }, { vigenciaInicio: 'desc' }]
31
39
  */
32
- export declare function buildPrismaOrderByMulti(sorting: SortField[]): any[];
40
+ export declare function buildPrismaOrderByMulti(sorting: SortField[], sortableFields?: readonly string[]): any[];
@@ -1,29 +1,47 @@
1
1
  // src/server/prisma-helpers.ts
2
- function buildPrismaOrderBy(sortBy, sortOrder = "desc") {
3
- const normalizedSortBy = sortBy.replace(/_/g, ".");
4
- if (!normalizedSortBy.includes(".")) {
5
- return { [normalizedSortBy]: sortOrder };
2
+ function decodeColumnId(id) {
3
+ let path = "";
4
+ let segmentStart = true;
5
+ for (const ch of id) {
6
+ if (ch === "_" && !segmentStart) {
7
+ path += ".";
8
+ segmentStart = true;
9
+ } else {
10
+ path += ch;
11
+ segmentStart = false;
12
+ }
13
+ }
14
+ return path;
15
+ }
16
+ function resolveSortPath(field, sortableFields) {
17
+ if (field.includes(".") || !field.includes("_")) return field;
18
+ if (sortableFields?.includes(field)) return field;
19
+ const decoded = decodeColumnId(field);
20
+ return !sortableFields || sortableFields.includes(decoded) ? decoded : field;
21
+ }
22
+ function toPrismaOrderBy(path, order) {
23
+ const keys = path.split(".");
24
+ const i = keys.indexOf("_count");
25
+ if (i >= 0 && i === keys.length - 2) {
26
+ keys[i] = keys[i + 1];
27
+ keys[i + 1] = "_count";
6
28
  }
7
- return normalizedSortBy.split(".").reduceRight(
29
+ return keys.reduceRight(
8
30
  (acc, key) => ({ [key]: acc }),
9
31
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- sortOrder
32
+ order
11
33
  );
12
34
  }
13
- function buildPrismaOrderByMulti(sorting) {
14
- return sorting.map((sort) => {
15
- const normalizedField = sort.field.replace(/_/g, ".");
16
- if (!normalizedField.includes(".")) {
17
- return { [normalizedField]: sort.order };
18
- }
19
- return normalizedField.split(".").reduceRight(
20
- (acc, key) => ({ [key]: acc }),
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- sort.order
23
- );
24
- });
35
+ function buildPrismaOrderBy(sortBy, sortOrder = "desc", sortableFields) {
36
+ return toPrismaOrderBy(resolveSortPath(sortBy, sortableFields), sortOrder);
37
+ }
38
+ function buildPrismaOrderByMulti(sorting, sortableFields) {
39
+ return sorting.map(
40
+ (sort) => toPrismaOrderBy(resolveSortPath(sort.field, sortableFields), sort.order)
41
+ );
25
42
  }
26
43
  export {
27
44
  buildPrismaOrderBy,
28
- buildPrismaOrderByMulti
45
+ buildPrismaOrderByMulti,
46
+ resolveSortPath
29
47
  };
@@ -81,8 +81,4 @@ export declare const useDataTableActions: (tableId: string) => {
81
81
  resetTable: () => void;
82
82
  initTable: (initialState?: Partial<TableState>) => void;
83
83
  };
84
- export declare const useDataTableDebug: (tableId: string) => {
85
- tableState: TableState;
86
- allTables: string[];
87
- };
88
84
  export {};
@@ -371,13 +371,8 @@ var useDataTableActions = (tableId) => {
371
371
  };
372
372
  }, [tableId]);
373
373
  };
374
- var useDataTableDebug = (tableId) => useDataTableStore((state) => ({
375
- tableState: state.tables[tableId],
376
- allTables: Object.keys(state.tables)
377
- }));
378
374
  export {
379
375
  useDataTableActions,
380
- useDataTableDebug,
381
376
  useDataTableStore,
382
377
  useTableColumnFilter,
383
378
  useTableColumnFilters,
@@ -19,6 +19,11 @@ interface FormMeta {
19
19
  interface FormState {
20
20
  forms: Record<string, FormData>;
21
21
  formMeta: Record<string, FormMeta>;
22
+ /**
23
+ * Loads (or resets to) a full data set: the new baseline, so the form is
24
+ * pristine afterwards (`isDirty: false`, no errors, nothing touched) — like
25
+ * react-hook-form's `reset()`. User edits go through `updateField`.
26
+ */
22
27
  setFormData: (formId: string, data: FormData) => void;
23
28
  updateField: (formId: string, field: string, value: unknown) => void;
24
29
  setSubmitting: (formId: string, isSubmitting: boolean) => void;
@@ -22,7 +22,8 @@ var useFormStore = create()(
22
22
  ...state.formMeta,
23
23
  [formId]: {
24
24
  ...state.formMeta[formId],
25
- isDirty: true,
25
+ // A load is the baseline, not an edit: only updateField dirties
26
+ isDirty: false,
26
27
  isSubmitting: false,
27
28
  errors: {},
28
29
  touched: {},
@@ -117,7 +118,9 @@ var useFormStore = create()(
117
118
  });
118
119
  sections?.forEach((section) => {
119
120
  section.fields?.forEach((field) => {
120
- if (field.required && (!formData[field.name] || formData[field.name] === "")) {
121
+ const value = formData[field.name];
122
+ const missing = value === void 0 || value === null || value === "" || value === false || Array.isArray(value) && value.length === 0;
123
+ if (field.required && missing) {
121
124
  errors[field.name] = requiredMessage(field.label);
122
125
  }
123
126
  });
@@ -224,13 +227,14 @@ var useForms = (formIds) => {
224
227
  anyDirty: formIds.some((id) => store.isFormDirty(id)),
225
228
  // Actions em batch
226
229
  resetAll: () => formIds.forEach((id) => store.resetForm(id)),
227
- validateAll: (sectionsMap) => formIds.every(
230
+ // map, then every: each form gets its errors, not only up to the first invalid one
231
+ validateAll: (sectionsMap) => formIds.map(
228
232
  (id) => store.validateForm(
229
233
  id,
230
234
  sectionsMap[id] || [],
231
235
  (label) => t("form.fieldRequired", { label })
232
236
  )
233
- ),
237
+ ).every(Boolean),
234
238
  // Getters por form
235
239
  getForm: (formId) => ({
236
240
  data: store.getFormData(formId),
@@ -6,4 +6,4 @@ export { useSidebarState, useIsMobileOpen, useIsCompact, useIsExpanded, useIsHid
6
6
  export { useMenuStore } from './menu-store';
7
7
  export type { MenuState, MenuLevel, MenuStackItem } from './menu-store';
8
8
  export { useMenuStack, useCurrentSection, useIsNavigating, useMenuActions, useMenuDebug, } from './menu-store';
9
- export { useDataTableStore, useTableColumnFilters, useTableColumnFilter, useTableGlobalFilter, useTableSorting, useTablePage, useTablePageSize, useTableState, useTableColumnVisibility, useTableRowSelection, useTableViewMode, useTableCurrentViewMode, useTableIsFullscreen, useTableShowFilters, useDataTableActions, useDataTableDebug, } from './datatable-store';
9
+ export { useDataTableStore, useTableColumnFilters, useTableColumnFilter, useTableGlobalFilter, useTableSorting, useTablePage, useTablePageSize, useTableState, useTableColumnVisibility, useTableRowSelection, useTableViewMode, useTableCurrentViewMode, useTableIsFullscreen, useTableShowFilters, useDataTableActions, } from './datatable-store';
@@ -37,8 +37,7 @@ import {
37
37
  useTableCurrentViewMode,
38
38
  useTableIsFullscreen,
39
39
  useTableShowFilters,
40
- useDataTableActions,
41
- useDataTableDebug
40
+ useDataTableActions
42
41
  } from "./datatable-store.js";
43
42
  export {
44
43
  appStore,
@@ -47,7 +46,6 @@ export {
47
46
  useAppStore,
48
47
  useCurrentSection,
49
48
  useDataTableActions,
50
- useDataTableDebug,
51
49
  useDataTableStore,
52
50
  useIsCompact,
53
51
  useIsExpanded,
@@ -56,7 +56,7 @@ export declare const useSidebarStore: import("zustand").UseBoundStore<Omit<Omit<
56
56
  sidebarState: SidebarState;
57
57
  }, unknown>>) => void;
58
58
  clearStorage: () => void;
59
- rehydrate: () => Promise<void> | void;
59
+ rehydrate: () => Promise<void>;
60
60
  hasHydrated: () => boolean;
61
61
  onHydrate: (fn: (state: SidebarStoreState) => void) => () => void;
62
62
  onFinishHydration: (fn: (state: SidebarStoreState) => void) => () => void;
@@ -163,7 +163,10 @@ export interface ActionConfig<TData = any> {
163
163
  * Display configuration for actions
164
164
  */
165
165
  export interface ActionsDisplayConfig {
166
- /** Display mode for actions */
166
+ /**
167
+ * Display mode for actions. `'auto'`: everything in the "⋯" menu on mobile
168
+ * (< 768px, `useIsMobile`), `'inline'` (with `maxInline`) elsewhere.
169
+ */
167
170
  mode?: 'inline' | 'dropdown' | 'auto';
168
171
  /** Maximum number of inline actions before grouping */
169
172
  maxInline?: number;
@@ -227,10 +227,23 @@ export interface ListConfig<T> {
227
227
  emptyDescription?: I18nText;
228
228
  /** Table columns definition */
229
229
  columns: CrudColumnDef<T>[];
230
- /** Default sort field */
230
+ /** Default sort field: the column id or its data path (`'customer.name'`) */
231
231
  defaultSortBy?: string;
232
232
  /** Default sort order (default: 'asc') */
233
233
  defaultSortOrder?: 'asc' | 'desc';
234
+ /**
235
+ * What the list sends as `sortBy` to `query.queryFn` (and `list.onExport`,
236
+ * `toolbarContent`, the URL with `urlSync`, `exportAll`).
237
+ * - `'id'` (default): the TanStack column id. A dotted `accessorKey` arrives
238
+ * with every `.` turned into `_` (`customer.name` → `customer_name`).
239
+ * - `'path'`: the column's `accessorKey` with its dots (`customer.name`,
240
+ * `_count.items`); a column without one (`accessorFn`, display) sends its `id`.
241
+ *
242
+ * Stored sorts (saved views, `defaultSortBy`) work in either form in both modes.
243
+ * `'path'` becomes the default in the next major.
244
+ * @default 'id'
245
+ */
246
+ sortParam?: 'id' | 'path';
234
247
  /** Default page size */
235
248
  defaultPageSize?: number;
236
249
  /** Enable server-side pagination */
@@ -24,6 +24,11 @@ export interface SystemTheme {
24
24
  mode: 'light' | 'dark' | 'system';
25
25
  customCSS?: string;
26
26
  }
27
+ /**
28
+ * Roles are deliberately absent: the app defines them, and they reach the UI
29
+ * through the session (`session.user.role`, materialized by
30
+ * `@telamonjs/permissions`), not through this config.
31
+ */
27
32
  export interface SystemAuth {
28
33
  enabled: boolean;
29
34
  redirectPath: string;
@@ -16,15 +16,6 @@ export type ChartConfig = {
16
16
  theme: Record<keyof typeof THEMES, string>;
17
17
  });
18
18
  };
19
- export interface ChartPayloadItem {
20
- dataKey?: string;
21
- name?: string;
22
- value?: number | string;
23
- color?: string;
24
- payload?: Record<string, unknown>;
25
- fill?: string;
26
- [key: string]: unknown;
27
- }
28
19
  declare const ChartContainer: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
29
20
  config: ChartConfig;
30
21
  children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
@@ -34,42 +25,46 @@ declare const ChartStyle: ({ id, config }: {
34
25
  config: ChartConfig;
35
26
  }) => React.JSX.Element | null;
36
27
  declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
37
- declare const ChartTooltipContent: React.ForwardRefExoticComponent<Omit<Omit<RechartsPrimitive.DefaultTooltipContentProps<import("recharts/types/component/DefaultTooltipContent").ValueType, import("recharts/types/component/DefaultTooltipContent").NameType>, "active" | "label" | "viewBox" | "payload" | "coordinate" | "accessibilityLayer"> & {
28
+ declare const ChartTooltipContent: React.ForwardRefExoticComponent<Omit<Omit<RechartsPrimitive.DefaultTooltipContentProps<RechartsPrimitive.TooltipValueType, import("recharts/types/component/DefaultTooltipContent").NameType>, "active" | "label" | "viewBox" | "payload" | "coordinate" | "accessibilityLayer"> & {
38
29
  active?: boolean;
39
- includeHidden?: boolean | undefined;
40
30
  allowEscapeViewBox?: import("recharts/types/util/types").AllowInDimension;
41
31
  animationDuration?: import("recharts/types/util/types").AnimationDuration;
42
- animationEasing?: import("recharts/types/util/types").AnimationTiming;
43
- content?: import("recharts/types/component/Tooltip").ContentType<import("recharts/types/component/DefaultTooltipContent").ValueType, import("recharts/types/component/DefaultTooltipContent").NameType> | undefined;
44
- cursor?: import("recharts/types/component/Cursor").CursorDefinition;
32
+ animationEasing?: RechartsPrimitive.EasingInput;
33
+ axisId?: RechartsPrimitive.AxisId;
34
+ content?: RechartsPrimitive.TooltipContentType<RechartsPrimitive.TooltipValueType, import("recharts/types/component/DefaultTooltipContent").NameType> | undefined;
35
+ contentStyle?: React.CSSProperties;
36
+ cursor?: RechartsPrimitive.CursorDefinition;
37
+ defaultIndex?: number | RechartsPrimitive.TooltipIndex;
45
38
  filterNull?: boolean;
46
- defaultIndex?: number | import("recharts/types/state/tooltipSlice").TooltipIndex;
47
- isAnimationActive?: boolean;
48
- offset?: number;
49
- payloadUniqBy?: import("recharts/types/util/payload/getUniqPayload").UniqueOption<import("recharts/types/component/DefaultTooltipContent").Payload<import("recharts/types/component/DefaultTooltipContent").ValueType, import("recharts/types/component/DefaultTooltipContent").NameType>> | undefined;
39
+ formatter?: ((value: RechartsPrimitive.TooltipValueType, name: import("recharts/types/component/DefaultTooltipContent").NameType, item: import("recharts/types/state/tooltipSlice").TooltipPayloadEntry, index: number, payload: RechartsPrimitive.TooltipPayload) => React.ReactNode | [React.ReactNode, React.ReactNode]) | undefined;
40
+ includeHidden?: boolean | undefined;
41
+ isAnimationActive?: boolean | "auto";
42
+ itemSorter?: RechartsPrimitive.TooltipItemSorter;
43
+ itemStyle?: React.CSSProperties;
44
+ labelFormatter?: (label: React.ReactNode, payload: RechartsPrimitive.TooltipPayload) => React.ReactNode;
45
+ labelStyle?: React.CSSProperties;
46
+ offset?: number | RechartsPrimitive.Coordinate;
47
+ payloadUniqBy?: RechartsPrimitive.UniqueOption<import("recharts/types/state/tooltipSlice").TooltipPayloadEntry>;
50
48
  portal?: HTMLElement | null;
51
- position?: Partial<import("recharts/types/util/types").Coordinate>;
49
+ position?: Partial<RechartsPrimitive.Coordinate>;
52
50
  reverseDirection?: import("recharts/types/util/types").AllowInDimension;
51
+ separator?: string;
53
52
  shared?: boolean;
54
- trigger?: import("recharts/types/chart/types").TooltipTrigger;
53
+ trigger?: RechartsPrimitive.TooltipTrigger;
55
54
  useTranslate3d?: boolean;
56
55
  wrapperStyle?: React.CSSProperties;
57
- axisId?: import("recharts/types/state/cartesianAxisSlice").AxisId;
58
56
  } & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
59
57
  hideLabel?: boolean;
60
58
  hideIndicator?: boolean;
61
59
  indicator?: "line" | "dot" | "dashed";
62
60
  nameKey?: string;
63
61
  labelKey?: string;
64
- active?: boolean;
65
- payload?: ChartPayloadItem[];
66
- label?: string | number;
67
- }, "ref"> & React.RefAttributes<HTMLDivElement>>;
68
- declare const ChartLegend: typeof RechartsPrimitive.Legend;
62
+ } & Partial<Pick<RechartsPrimitive.TooltipContentProps, "active" | "label" | "payload">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
63
+ declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
69
64
  declare const ChartLegendContent: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
70
65
  hideIcon?: boolean;
71
66
  nameKey?: string;
72
- payload?: ChartPayloadItem[];
67
+ payload?: ReadonlyArray<RechartsPrimitive.LegendPayload>;
73
68
  verticalAlign?: "top" | "bottom" | "middle";
74
69
  }, "ref"> & React.RefAttributes<HTMLDivElement>>;
75
70
  export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
package/dist/ui/chart.js CHANGED
@@ -127,13 +127,7 @@ var ChartTooltipContent = React.forwardRef(
127
127
  "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
128
128
  indicator === "dot" && "items-center"
129
129
  ),
130
- children: formatter && item?.value !== void 0 && item.name ? formatter(
131
- item.value,
132
- item.name,
133
- item,
134
- index,
135
- item.payload || {}
136
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
130
+ children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
137
131
  itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
138
132
  "div",
139
133
  {
@@ -170,7 +164,7 @@ var ChartTooltipContent = React.forwardRef(
170
164
  )
171
165
  ] })
172
166
  },
173
- item.dataKey
167
+ index
174
168
  );
175
169
  }) })
176
170
  ]
package/dist/ui/form.d.ts CHANGED
@@ -18,7 +18,7 @@ declare const useFormField: () => {
18
18
  declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
19
19
  declare const FormLabel: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
20
20
  declare const FormControl: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLElement> & {
21
- children?: React.ReactNode;
21
+ children?: React.ReactNode | undefined;
22
22
  } & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
23
23
  declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
24
24
  declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;