@telamonjs/ui 1.0.4 → 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 (80) hide show
  1. package/CHANGELOG.md +38 -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 +45 -77
  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/grid-classes.d.ts +4 -0
  25. package/dist/components/forms/grid-classes.js +40 -0
  26. package/dist/components/forms/validators/config-validator.js +2 -1
  27. package/dist/components/toolbar/TabToolbar.d.ts +6 -1
  28. package/dist/components/toolbar/TabToolbar.js +5 -3
  29. package/dist/exports/data-crud.d.ts +1 -1
  30. package/dist/exports/pages-dialogs.d.ts +3 -1
  31. package/dist/exports/pages-dialogs.js +2 -0
  32. package/dist/exports/types-constants.d.ts +2 -2
  33. package/dist/exports/types-constants.js +1 -1
  34. package/dist/field-system/mask-presets.d.ts +5 -0
  35. package/dist/field-system/mask-presets.js +18 -0
  36. package/dist/field-system/renderers/advanced-renderers.js +2 -4
  37. package/dist/field-system/renderers/textarea-renderers.js +1 -1
  38. package/dist/hooks/useCrudMutations.js +28 -16
  39. package/dist/pages/ListPage.js +23 -14
  40. package/dist/pages/list-page/ListPageDialogs.d.ts +8 -3
  41. package/dist/pages/list-page/ListPageDialogs.js +36 -7
  42. package/dist/pages/list-page/ListPageToolbar.js +10 -14
  43. package/dist/pages/list-page/apply-crud-permissions.d.ts +21 -0
  44. package/dist/pages/list-page/apply-crud-permissions.js +34 -0
  45. package/dist/pages/list-page/types.d.ts +21 -2
  46. package/dist/pages/list-page/useListPageData.d.ts +3 -1
  47. package/dist/pages/list-page/useListPageData.js +2 -1
  48. package/dist/pages/list-page/useListPageDialogs.d.ts +1 -0
  49. package/dist/pages/list-page/useListPageDialogs.js +13 -4
  50. package/dist/pages/list-page/useListPageToolbar.d.ts +8 -5
  51. package/dist/pages/list-page/useListPageToolbar.js +14 -10
  52. package/dist/queue/components/FailureGroupsModal.js +4 -3
  53. package/dist/queue/components/JobConfigDialog.js +9 -1
  54. package/dist/queue/components/JobDetailModal.js +3 -2
  55. package/dist/queue/components/JobDetailPage.js +10 -2
  56. package/dist/queue/components/JobEventModal.js +3 -2
  57. package/dist/queue/components/QueueTabbedDashboard.d.ts +20 -2
  58. package/dist/queue/components/QueueTabbedDashboard.js +26 -3
  59. package/dist/queue/components/QueuesTable.d.ts +3 -2
  60. package/dist/queue/components/QueuesTable.js +31 -27
  61. package/dist/queue/components/job-shared.d.ts +2 -0
  62. package/dist/queue/components/job-shared.js +2 -0
  63. package/dist/queue/components/jobs-history-modal/fullscreen-modal.js +3 -2
  64. package/dist/queue/components/jobs-history-modal/job-detail-modal.js +3 -2
  65. package/dist/queue/components/jobs-list-modal/job-row.js +3 -2
  66. package/dist/queue/components/labels-context.d.ts +31 -0
  67. package/dist/queue/components/labels-context.js +34 -0
  68. package/dist/queue/components/module-icon.d.ts +9 -0
  69. package/dist/queue/components/module-icon.js +14 -0
  70. package/dist/queue/components/tabs/ConfiguracaoTab.d.ts +2 -1
  71. package/dist/queue/components/tabs/ConfiguracaoTab.js +13 -9
  72. package/dist/queue/components/tabs/HistoricoTab.js +4 -3
  73. package/dist/queue/components/tabs/TempoRealTab.d.ts +3 -2
  74. package/dist/queue/components/tabs/TempoRealTab.js +2 -2
  75. package/dist/types/actions.d.ts +43 -14
  76. package/dist/types/crud.d.ts +47 -6
  77. package/dist/types/dialog-header.d.ts +2 -2
  78. package/dist/types/forms/admin-form.d.ts +8 -1
  79. package/dist/utils/with-scope.js +5 -3
  80. package/package.json +1 -1
@@ -0,0 +1,182 @@
1
+ "use client";
2
+
3
+ // src/components/dialog/confirm-action-dialog.tsx
4
+ import { Loader2 } from "lucide-react";
5
+ import { useId, useState } from "react";
6
+ import {
7
+ AlertDialog,
8
+ AlertDialogAction,
9
+ AlertDialogCancel,
10
+ AlertDialogContent,
11
+ AlertDialogDescription,
12
+ AlertDialogFooter,
13
+ AlertDialogHeader,
14
+ AlertDialogTitle,
15
+ AlertDialogTrigger
16
+ } from "../../ui/alert-dialog.js";
17
+ import { Input } from "../../ui/input.js";
18
+ import { Label } from "../../ui/label.js";
19
+ import {
20
+ Select,
21
+ SelectContent,
22
+ SelectItem,
23
+ SelectTrigger,
24
+ SelectValue
25
+ } from "../../ui/select.js";
26
+ import { Textarea } from "../../ui/textarea.js";
27
+ import { useTelamonjsT, useText } from "../../i18n/use-t.js";
28
+ import { jsx, jsxs } from "react/jsx-runtime";
29
+ var initialValues = (inputs = []) => Object.fromEntries(inputs.map((i) => [i.name, i.defaultValue ?? ""]));
30
+ function ConfirmActionDialog({
31
+ open: openProp,
32
+ onOpenChange,
33
+ children,
34
+ title,
35
+ description,
36
+ confirmText,
37
+ cancelText,
38
+ variant = "default",
39
+ inputs,
40
+ onConfirm
41
+ }) {
42
+ const t = useTelamonjsT();
43
+ const text = useText();
44
+ const idPrefix = useId();
45
+ const [innerOpen, setInnerOpen] = useState(false);
46
+ const open = openProp ?? innerOpen;
47
+ const [values, setValues] = useState(() => initialValues(inputs));
48
+ const [missing, setMissing] = useState([]);
49
+ const [error, setError] = useState(null);
50
+ const [pending, setPending] = useState(false);
51
+ const [wasOpen, setWasOpen] = useState(open);
52
+ if (open !== wasOpen) {
53
+ setWasOpen(open);
54
+ if (open) {
55
+ setValues(initialValues(inputs));
56
+ setMissing([]);
57
+ setError(null);
58
+ }
59
+ }
60
+ const setOpen = (next) => {
61
+ if (openProp === void 0) setInnerOpen(next);
62
+ onOpenChange?.(next);
63
+ };
64
+ const handleOpenChange = (next) => {
65
+ if (!next && pending) return;
66
+ setOpen(next);
67
+ };
68
+ const handleConfirm = async (event) => {
69
+ event.preventDefault();
70
+ const empty = (inputs ?? []).filter((i) => i.required && !values[i.name]?.trim()).map((i) => i.name);
71
+ setMissing(empty);
72
+ if (empty.length > 0) return;
73
+ setError(null);
74
+ setPending(true);
75
+ try {
76
+ const result = await onConfirm(values);
77
+ setPending(false);
78
+ if (result !== false) setOpen(false);
79
+ } catch (err) {
80
+ setPending(false);
81
+ setError(
82
+ err instanceof Error && err.message ? err.message : t("toast.unknownError")
83
+ );
84
+ }
85
+ };
86
+ const setValue = (name, value) => {
87
+ setValues((prev) => ({ ...prev, [name]: value }));
88
+ if (missing.includes(name)) setMissing((prev) => prev.filter((n) => n !== name));
89
+ };
90
+ return /* @__PURE__ */ jsxs(AlertDialog, { open, onOpenChange: handleOpenChange, children: [
91
+ children && /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: true, children }),
92
+ /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
93
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
94
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: text(title) || t("dialog.confirmActionTitle") }),
95
+ description && /* @__PURE__ */ jsx(AlertDialogDescription, { children: text(description) })
96
+ ] }),
97
+ inputs && inputs.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: inputs.map((input) => {
98
+ const id = `${idPrefix}-${input.name}`;
99
+ const errorId = `${id}-error`;
100
+ const invalid = missing.includes(input.name);
101
+ const common = {
102
+ id,
103
+ name: input.name,
104
+ required: input.required,
105
+ disabled: pending,
106
+ "aria-invalid": invalid || void 0,
107
+ "aria-describedby": invalid ? errorId : void 0
108
+ };
109
+ return /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
110
+ /* @__PURE__ */ jsxs(Label, { htmlFor: id, children: [
111
+ text(input.label),
112
+ input.required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-destructive", children: " *" })
113
+ ] }),
114
+ input.type === "textarea" ? /* @__PURE__ */ jsx(
115
+ Textarea,
116
+ {
117
+ ...common,
118
+ value: values[input.name] ?? "",
119
+ onChange: (e) => setValue(input.name, e.target.value)
120
+ }
121
+ ) : input.type === "select" ? /* @__PURE__ */ jsxs(
122
+ Select,
123
+ {
124
+ value: values[input.name] ?? "",
125
+ onValueChange: (v) => setValue(input.name, v),
126
+ disabled: pending,
127
+ children: [
128
+ /* @__PURE__ */ jsx(
129
+ SelectTrigger,
130
+ {
131
+ id,
132
+ "aria-invalid": common["aria-invalid"],
133
+ "aria-describedby": common["aria-describedby"],
134
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t("common.select") })
135
+ }
136
+ ),
137
+ /* @__PURE__ */ jsx(SelectContent, { children: (input.options ?? []).map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option, children: option }, option)) })
138
+ ]
139
+ }
140
+ ) : /* @__PURE__ */ jsx(
141
+ Input,
142
+ {
143
+ ...common,
144
+ value: values[input.name] ?? "",
145
+ onChange: (e) => setValue(input.name, e.target.value)
146
+ }
147
+ ),
148
+ invalid && /* @__PURE__ */ jsx("p", { id: errorId, className: "text-sm text-destructive", children: t("validation.required") })
149
+ ] }, input.name);
150
+ }) }),
151
+ error && /* @__PURE__ */ jsx(
152
+ "p",
153
+ {
154
+ role: "alert",
155
+ "data-testid": "confirm-action-error",
156
+ className: "text-sm text-destructive",
157
+ children: error
158
+ }
159
+ ),
160
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
161
+ /* @__PURE__ */ jsx(AlertDialogCancel, { "data-testid": "modal-cancel", disabled: pending, children: text(cancelText) || t("common.cancel") }),
162
+ /* @__PURE__ */ jsxs(
163
+ AlertDialogAction,
164
+ {
165
+ "data-testid": "modal-confirm",
166
+ disabled: pending,
167
+ "aria-busy": pending || void 0,
168
+ className: variant === "destructive" ? "bg-red-500 text-white hover:bg-red-600" : "",
169
+ onClick: handleConfirm,
170
+ children: [
171
+ pending && /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": "true" }),
172
+ text(confirmText) || t("common.confirm")
173
+ ]
174
+ }
175
+ )
176
+ ] })
177
+ ] })
178
+ ] });
179
+ }
180
+ export {
181
+ ConfirmActionDialog
182
+ };
@@ -2,13 +2,17 @@ import type { CrudConfigWithAnyForm } from '../../types/crud';
2
2
  import type { ViewDialogProps } from './view-dialog';
3
3
  type DialogData<T> = T & Record<string, unknown>;
4
4
  export interface CrudViewDialogProps<TData> {
5
- /** The module's CrudConfig — uses `dialogs.view`, `mutations.getForView ?? getForEdit` and `form.validation` */
6
- config: Pick<CrudConfigWithAnyForm<TData>, 'dialogs' | 'mutations' | 'form'>;
5
+ /**
6
+ * The module's CrudConfig — uses `dialogs.view`, `mutations.getForView ?? getForEdit`,
7
+ * `form.validation`, and `permissions.edit` (checked like the row actions) to
8
+ * gate `portal.onSaveSection`
9
+ */
10
+ config: Pick<CrudConfigWithAnyForm<TData>, 'dialogs' | 'mutations' | 'form' | 'permissions' | 'actionsConfig'>;
7
11
  id: string | null;
8
12
  open: boolean;
9
13
  onOpenChange: (open: boolean) => void;
10
14
  /** Footer actions of the classic ViewDialog (the portal variant has no footer) */
11
- footer?: Pick<ViewDialogProps<DialogData<TData>>, 'onEdit' | 'onDelete' | 'deleteLabel' | 'deleteIcon' | 'deleteConfirmation'>;
15
+ footer?: Pick<ViewDialogProps<DialogData<TData>>, 'onEdit' | 'canEdit' | 'onDelete' | 'canDelete' | 'deleteLabel' | 'deleteIcon' | 'deleteConfirmation'>;
12
16
  }
13
17
  /**
14
18
  * CrudViewDialog - the view dialog a CrudConfig declares (`dialogs.view`),
@@ -5,6 +5,7 @@ import { Suspense, lazy, useCallback } from "react";
5
5
  import { useText } from "../../i18n/use-t.js";
6
6
  import { withComponent } from "../../utils/logger.js";
7
7
  import { resolveDialogTitle } from "./resolve-dialog-title.js";
8
+ import { crudGranted } from "../data/action-access.js";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
  var logger = withComponent("CrudViewDialog");
10
11
  var ViewDialog = lazy(
@@ -61,8 +62,8 @@ function CrudViewDialog({
61
62
  sections: view.portal.sections,
62
63
  defaultSection: view.portal.defaultSection,
63
64
  columns: view.portal.columns,
64
- validation: form.validation,
65
- onSaveSection: view.portal.onSaveSection
65
+ validation: form?.validation,
66
+ onSaveSection: crudGranted(config, "edit") ? view.portal.onSaveSection : void 0
66
67
  }
67
68
  ) : /* @__PURE__ */ jsx(
68
69
  ViewDialog,
@@ -68,8 +68,16 @@ export interface ViewDialogProps<T extends Record<string, unknown>> {
68
68
  forceDesktopMode?: boolean;
69
69
  /** Optional edit action - opens EditDialog and closes ViewDialog */
70
70
  onEdit?: () => void;
71
+ /**
72
+ * Per-record gate for the Edit button (with `onEdit`): it shows only when this
73
+ * returns true for the viewed item, and stays hidden while it loads. The
74
+ * ListPage passes the row edit action's `visible`/`enabled` here.
75
+ */
76
+ canEdit?: (item: T) => boolean;
71
77
  /** Optional delete action - shows confirmation before deleting */
72
78
  onDelete?: () => Promise<void>;
79
+ /** Per-record gate for the Delete button (with `onDelete`), like `canEdit` */
80
+ canDelete?: (item: T) => boolean;
73
81
  /** Delete confirmation config (if onDelete is provided) */
74
82
  deleteConfirmation?: {
75
83
  /** String, or a function that receives the viewed item */
@@ -132,4 +140,4 @@ export interface ViewDialogProps<T extends Record<string, unknown>> {
132
140
  * />
133
141
  * ```
134
142
  */
135
- export declare function ViewDialog<T extends Record<string, unknown>>({ id, open, onOpenChange, fetchAction, title, description, renderContent, renderHeader: renderHeaderProp, headerConfig, dialogClassName, dialogHeight, size, forceDesktopMode, onEdit, onDelete, deleteConfirmation, deleteLabel, deleteIcon: DeleteIcon, }: ViewDialogProps<T>): React.JSX.Element;
143
+ export declare function ViewDialog<T extends Record<string, unknown>>({ id, open, onOpenChange, fetchAction, title, description, renderContent, renderHeader: renderHeaderProp, headerConfig, dialogClassName, dialogHeight, size, forceDesktopMode, onEdit, canEdit, onDelete, canDelete, deleteConfirmation, deleteLabel, deleteIcon: DeleteIcon, }: ViewDialogProps<T>): React.JSX.Element;
@@ -42,7 +42,9 @@ function ViewDialog({
42
42
  size = "full",
43
43
  forceDesktopMode = false,
44
44
  onEdit,
45
+ canEdit,
45
46
  onDelete,
47
+ canDelete,
46
48
  deleteConfirmation,
47
49
  deleteLabel,
48
50
  deleteIcon: DeleteIcon = Trash2
@@ -62,6 +64,9 @@ function ViewDialog({
62
64
  }
63
65
  return title;
64
66
  }, [title, data, t]);
67
+ const gate = (can) => !can || (data ? can(data) : false);
68
+ const showEdit = Boolean(onEdit) && gate(canEdit);
69
+ const showDelete = Boolean(onDelete) && gate(canDelete);
65
70
  const handleEdit = () => {
66
71
  if (onEdit) {
67
72
  onOpenChange(false);
@@ -104,7 +109,7 @@ function ViewDialog({
104
109
  return /* @__PURE__ */ jsx(RecordRefreshProvider, { refresh: refetchSilent, children: renderContent(data) });
105
110
  };
106
111
  const renderFooter = () => {
107
- if (!onDelete && !onEdit) {
112
+ if (!showDelete && !showEdit) {
108
113
  return null;
109
114
  }
110
115
  const resolve = (v) => typeof v === "function" ? data ? v(data) : "" : v;
@@ -112,7 +117,7 @@ function ViewDialog({
112
117
  const confirmDescription = resolve(deleteConfirmation?.description) || t("dialog.confirmDeleteDescription");
113
118
  const deleteText = resolve(deleteLabel) || t("common.delete");
114
119
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-t bg-muted/50 px-6 py-4", children: [
115
- /* @__PURE__ */ jsx("div", { children: onDelete ? /* @__PURE__ */ jsxs(
120
+ /* @__PURE__ */ jsx("div", { children: showDelete ? /* @__PURE__ */ jsxs(
116
121
  AlertDialog,
117
122
  {
118
123
  open: confirmDialogOpen,
@@ -167,7 +172,7 @@ function ViewDialog({
167
172
  ]
168
173
  }
169
174
  ),
170
- onEdit && /* @__PURE__ */ jsxs(Button, { onClick: handleEdit, "data-testid": "view-dialog-edit-button", children: [
175
+ showEdit && /* @__PURE__ */ jsxs(Button, { onClick: handleEdit, "data-testid": "view-dialog-edit-button", children: [
171
176
  /* @__PURE__ */ jsx(Pencil, { className: "mr-2 h-4 w-4" }),
172
177
  t("common.edit")
173
178
  ] })
@@ -19,6 +19,7 @@ import {
19
19
  import { getFieldRenderer } from "../../field-system/field-registry.js";
20
20
  import { Button } from "../../ui/button.js";
21
21
  import { cn } from "../../utils/index.js";
22
+ import { colSpanClass, gridColsClass } from "./grid-classes.js";
22
23
  import { ValidationErrors } from "./ValidationErrors.js";
23
24
  import { ChevronLeft, ChevronRight, Loader2, Save, X } from "lucide-react";
24
25
  import { useTelamonjsT, useText } from "../../i18n/use-t.js";
@@ -153,7 +154,7 @@ var FieldRenderer = memo(({ field, form, id }) => {
153
154
  return /* @__PURE__ */ jsx(
154
155
  "div",
155
156
  {
156
- className: cn("space-y-2", field.span && `col-span-${field.span}`),
157
+ className: cn("space-y-2", field.span && colSpanClass(field.span)),
157
158
  children: /* @__PURE__ */ jsx(
158
159
  Controller,
159
160
  {
@@ -374,7 +375,7 @@ function BaseForm({
374
375
  {
375
376
  className: cn(
376
377
  "grid gap-4",
377
- `grid-cols-${currentSection.grid || grid}`
378
+ gridColsClass(currentSection.grid || grid)
378
379
  ),
379
380
  role: "group",
380
381
  "aria-label": currentSection.label || void 0,
@@ -407,7 +408,7 @@ function BaseForm({
407
408
  {
408
409
  className: cn(
409
410
  "grid gap-4",
410
- `grid-cols-${currentSection2.grid || grid}`
411
+ gridColsClass(currentSection2.grid || grid)
411
412
  ),
412
413
  role: "group",
413
414
  "aria-label": currentSection2.label || void 0,
@@ -7,6 +7,7 @@ import { useForm, FormProvider } from "react-hook-form";
7
7
  import { Button } from "../../ui/button.js";
8
8
  import { Label } from "../../ui/label.js";
9
9
  import { cn } from "../../utils/index.js";
10
+ import { colSpanClass, gridColsClass } from "./grid-classes.js";
10
11
  import { ChevronLeft, ChevronRight, Loader2, CheckCircle2 } from "lucide-react";
11
12
  import { Stepper } from "./Stepper.js";
12
13
  import { ReviewStep } from "./ReviewStep.js";
@@ -26,12 +27,12 @@ function WizardStepFields({
26
27
  }) {
27
28
  const text = useText();
28
29
  const flatFields = Array.isArray(fields[0]) ? fields.flat() : fields;
29
- return /* @__PURE__ */ jsx("div", { className: cn("grid gap-4", `grid-cols-${grid}`), role: "group", children: flatFields.map((field) => {
30
+ return /* @__PURE__ */ jsx("div", { className: cn("grid gap-4", gridColsClass(grid)), role: "group", children: flatFields.map((field) => {
30
31
  const error = form.formState.errors[field.name];
31
32
  return /* @__PURE__ */ jsxs(
32
33
  "div",
33
34
  {
34
- className: cn("space-y-2", field.span && `col-span-${field.span}`),
35
+ className: cn("space-y-2", field.span && colSpanClass(field.span)),
35
36
  children: [
36
37
  field.type !== "space" && /* @__PURE__ */ jsxs(Label, { htmlFor: field.name, children: [
37
38
  text(field.label),
@@ -6,6 +6,7 @@ import { useForm } from "../../stores/form-store.js";
6
6
  import { Button } from "../../ui/button.js";
7
7
  import { Label } from "../../ui/label.js";
8
8
  import { cn } from "../../utils/index.js";
9
+ import { colSpanClass, gridColsClass } from "./grid-classes.js";
9
10
  import {
10
11
  Save,
11
12
  X,
@@ -105,10 +106,10 @@ var SectionRenderer = memo(({ section, form, recordId }) => {
105
106
  const filteredRow = filterFields(row);
106
107
  if (filteredRow.length === 0) return null;
107
108
  const useFlexbox = filteredRow.length > 6;
108
- const gridCols2 = useFlexbox ? "" : `grid-cols-${Math.min(filteredRow.length, 6)}`;
109
+ const gridCols2 = useFlexbox ? "" : gridColsClass(Math.min(filteredRow.length, 6));
109
110
  const containerClass = useFlexbox ? "flex flex-wrap gap-3" : cn("grid gap-3", gridCols2);
110
111
  return /* @__PURE__ */ jsx("div", { className: containerClass, children: filteredRow.map((field) => {
111
- const spanClass = field.span ? `col-span-${field.span}` : field.type === "space" || field.type === "crud" ? useFlexbox ? "w-full" : `col-span-${row.length}` : useFlexbox ? "flex-1 min-w-0" : "";
112
+ const spanClass = field.span ? colSpanClass(field.span) : field.type === "space" || field.type === "crud" ? useFlexbox ? "w-full" : colSpanClass(row.length) : useFlexbox ? "flex-1 min-w-0" : "";
112
113
  return /* @__PURE__ */ jsx("div", { className: cn("space-y-1", spanClass), children: /* @__PURE__ */ jsx(
113
114
  FieldRenderer,
114
115
  {
@@ -123,9 +124,9 @@ var SectionRenderer = memo(({ section, form, recordId }) => {
123
124
  const fields = filterFields(section.fields);
124
125
  if (fields.length === 0) return null;
125
126
  const gridValue = section.grid || "2";
126
- const gridCols = `grid-cols-${gridValue}`;
127
+ const gridCols = gridColsClass(gridValue);
127
128
  return /* @__PURE__ */ jsx("div", { className: cn("grid gap-4", gridCols), children: fields.map((field) => {
128
- const spanClass = field.span ? `col-span-${field.span}` : field.type === "space" || field.type === "crud" ? `col-span-${gridValue}` : "";
129
+ const spanClass = field.span ? colSpanClass(field.span) : field.type === "space" || field.type === "crud" ? colSpanClass(gridValue) : "";
129
130
  return /* @__PURE__ */ jsx("div", { className: cn("space-y-2", spanClass), children: /* @__PURE__ */ jsx(FieldRenderer, { field, form, recordId }) }, field.name);
130
131
  }) });
131
132
  });
@@ -2,6 +2,7 @@
2
2
 
3
3
  // src/components/forms/admin-form/field-group.tsx
4
4
  import { cn } from "../../../utils/index.js";
5
+ import { colSpanClass, gridColsClass } from "../grid-classes.js";
5
6
  import { Label } from "../../../ui/label.js";
6
7
  import { TEST_IDS } from "../../../utils/test-ids.js";
7
8
  import { hasCrudFields, getFieldError as lookupFieldError } from "./helpers.js";
@@ -60,11 +61,11 @@ function renderFieldGroup(ctx, fieldsToRender, section) {
60
61
  const filteredRow = filterFields(row);
61
62
  if (filteredRow.length === 0) return null;
62
63
  const useFlexbox = filteredRow.length > 6;
63
- const gridCols2 = useFlexbox ? "" : `grid-cols-${Math.min(filteredRow.length, 6)}`;
64
+ const gridCols2 = useFlexbox ? "" : gridColsClass(Math.min(filteredRow.length, 6));
64
65
  const containerClass = useFlexbox ? "flex flex-wrap gap-3" : cn("grid gap-3", gridCols2);
65
66
  return /* @__PURE__ */ jsx("div", { className: containerClass, children: filteredRow.map((field) => {
66
67
  const hasError = !!getFieldError(field.name);
67
- const spanClass = field.span ? `col-span-${field.span}` : field.type === "space" || field.type === "crud" ? useFlexbox ? "w-full" : `col-span-${row.length}` : useFlexbox ? "flex-1 min-w-0" : "";
68
+ const spanClass = field.span ? colSpanClass(field.span) : field.type === "space" || field.type === "crud" ? useFlexbox ? "w-full" : colSpanClass(row.length) : useFlexbox ? "flex-1 min-w-0" : "";
68
69
  return gate(
69
70
  field,
70
71
  /* @__PURE__ */ jsxs("div", { className: cn("space-y-1", spanClass), children: [
@@ -144,7 +145,7 @@ function renderFieldGroup(ctx, fieldsToRender, section) {
144
145
  );
145
146
  }
146
147
  const gridValue = section?.grid || ctx.grid || "2";
147
- const gridCols = `grid-cols-${gridValue}`;
148
+ const gridCols = gridColsClass(gridValue);
148
149
  return /* @__PURE__ */ jsx(
149
150
  "div",
150
151
  {
@@ -153,7 +154,7 @@ function renderFieldGroup(ctx, fieldsToRender, section) {
153
154
  "aria-label": section?.label || ctx.t("form.fieldsAriaLabel"),
154
155
  children: fields.map((field) => {
155
156
  const hasError = !!getFieldError(field.name);
156
- const spanClass = field.span ? `col-span-${field.span}` : field.type === "space" || field.type === "crud" ? `col-span-${gridValue}` : "";
157
+ const spanClass = field.span ? colSpanClass(field.span) : field.type === "space" || field.type === "crud" ? colSpanClass(gridValue) : "";
157
158
  return gate(
158
159
  field,
159
160
  /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", spanClass), children: [
@@ -0,0 +1,4 @@
1
+ /** Responsive grid columns for a form grid of `cols` columns. */
2
+ export declare function gridColsClass(cols: string | number): string;
3
+ /** Responsive column span for a field's `span` (`'1'`–`'12'` or `'full'`). */
4
+ export declare function colSpanClass(span: string | number): string;
@@ -0,0 +1,40 @@
1
+ // src/components/forms/grid-classes.ts
2
+ var GRID_COLS = {
3
+ "1": "grid-cols-1",
4
+ "2": "grid-cols-1 sm:grid-cols-2",
5
+ "3": "grid-cols-1 sm:grid-cols-3",
6
+ "4": "grid-cols-1 sm:grid-cols-4",
7
+ "5": "grid-cols-1 sm:grid-cols-5",
8
+ "6": "grid-cols-1 sm:grid-cols-6",
9
+ "7": "grid-cols-1 sm:grid-cols-7",
10
+ "8": "grid-cols-1 sm:grid-cols-8",
11
+ "9": "grid-cols-1 sm:grid-cols-9",
12
+ "10": "grid-cols-1 sm:grid-cols-10",
13
+ "11": "grid-cols-1 sm:grid-cols-11",
14
+ "12": "grid-cols-1 sm:grid-cols-12"
15
+ };
16
+ var COL_SPAN = {
17
+ "1": "sm:col-span-1",
18
+ "2": "sm:col-span-2",
19
+ "3": "sm:col-span-3",
20
+ "4": "sm:col-span-4",
21
+ "5": "sm:col-span-5",
22
+ "6": "sm:col-span-6",
23
+ "7": "sm:col-span-7",
24
+ "8": "sm:col-span-8",
25
+ "9": "sm:col-span-9",
26
+ "10": "sm:col-span-10",
27
+ "11": "sm:col-span-11",
28
+ "12": "sm:col-span-12",
29
+ full: "col-span-full"
30
+ };
31
+ function gridColsClass(cols) {
32
+ return GRID_COLS[String(cols)] ?? `grid-cols-${cols}`;
33
+ }
34
+ function colSpanClass(span) {
35
+ return COL_SPAN[String(span)] ?? `col-span-${span}`;
36
+ }
37
+ export {
38
+ colSpanClass,
39
+ gridColsClass
40
+ };
@@ -1,6 +1,7 @@
1
1
  // src/components/forms/validators/config-validator.ts
2
2
  import { logger } from "../../../utils/logger.js";
3
3
  import { fieldRegistry } from "../../../field-system/field-registry.js";
4
+ import { isMaskPreset } from "../../../field-system/mask-presets.js";
4
5
  function validateFormField(field) {
5
6
  const errors = [];
6
7
  const warnings = [];
@@ -37,7 +38,7 @@ function validateFormField(field) {
37
38
  }
38
39
  if (field.type === "masked") {
39
40
  if (!field.mask) {
40
- if (field.maskType !== "tel") {
41
+ if (!isMaskPreset(field.maskType)) {
41
42
  errors.push(
42
43
  `Field '${field.name}' with type 'masked' requires 'mask' prop`
43
44
  );
@@ -89,11 +89,16 @@ export interface FilterButtonOption {
89
89
  /** CSS class applied when active */
90
90
  activeClass?: string;
91
91
  }
92
- declare function TabToolbarFilterButtons({ options, value, onChange, className, }: {
92
+ declare function TabToolbarFilterButtons({ options, value, onChange, className, allValue, }: {
93
93
  options: FilterButtonOption[];
94
94
  value: string;
95
95
  onChange: (value: string) => void;
96
96
  className?: string;
97
+ /**
98
+ * Value meaning "no filter": its option is not rendered and an active button
99
+ * toggles back to it. Default: the first option's value.
100
+ */
101
+ allValue?: string;
97
102
  }): React.JSX.Element | null;
98
103
  export interface FilterSelectOption {
99
104
  value: string;
@@ -272,9 +272,11 @@ function TabToolbarFilterButtons({
272
272
  options,
273
273
  value,
274
274
  onChange,
275
- className
275
+ className,
276
+ allValue
276
277
  }) {
277
- const toggleOptions = options.slice(1);
278
+ const resetValue = allValue ?? options[0]?.value ?? "";
279
+ const toggleOptions = allValue === void 0 ? options.slice(1) : options.filter((o) => o.value !== allValue);
278
280
  if (toggleOptions.length === 0) return null;
279
281
  return /* @__PURE__ */ jsx(
280
282
  "div",
@@ -290,7 +292,7 @@ function TabToolbarFilterButtons({
290
292
  {
291
293
  variant: "outline",
292
294
  size: "sm",
293
- onClick: () => onChange(isActive ? options[0].value : opt.value),
295
+ onClick: () => onChange(isActive ? resetValue : opt.value),
294
296
  className: cn(
295
297
  "h-8 rounded-none gap-1.5",
296
298
  isFirst && "rounded-l-md",
@@ -12,7 +12,7 @@ export { ExportMenu } from '../data/ExportMenu';
12
12
  export type { ExportMenuProps } from '../data/ExportMenu';
13
13
  export { exportToExcel, exportToCSV, exportToPDF, exportTableData, } from '../data/exportUtils';
14
14
  export type { ExportOptions, PDFExportOptions } from '../data/exportUtils';
15
- export type { DataTableActionsConfig, ActionConfig, CustomAction, StandardActionsConfig, ActionsDisplayConfig, ConfirmDialogConfig, TooltipConfig, ButtonVariant, BadgeVariant, } from '../types/actions';
15
+ export type { DataTableActionsConfig, ActionConfig, CustomAction, StandardActionsConfig, ActionsDisplayConfig, ConfirmDialogConfig, ConfirmDialogInput, ActionContext, TooltipConfig, ButtonVariant, BadgeVariant, } from '../types/actions';
16
16
  export { VirtualDataTable } from '../data/VirtualDataTable';
17
17
  export { withScope } from '../utils/with-scope';
18
18
  export type { CrudScope } from '../utils/with-scope';
@@ -2,7 +2,7 @@ export { BaseFormPage } from '../pages/BaseFormPage';
2
2
  export type { BaseFormPageProps } from '../pages/BaseFormPage';
3
3
  export { DetailPage } from '../pages/DetailPage';
4
4
  export { ListPage } from '../pages/ListPage';
5
- export type { ActiveFilterChip } from '../pages/list-page/types';
5
+ export type { ActiveFilterChip, ListQueryState } from '../pages/list-page/types';
6
6
  export { EditPage } from '../pages/EditPage';
7
7
  export type { EditPageProps } from '../pages/EditPage';
8
8
  export { CreatePage } from '../pages/CreatePage';
@@ -15,6 +15,8 @@ export { CreateDialog } from '../components/dialog/create-dialog';
15
15
  export type { CreateDialogProps } from '../components/dialog/create-dialog';
16
16
  export { ViewPortalDialog } from '../components/dialog/view-portal-dialog';
17
17
  export { CrudViewDialog } from '../components/dialog/crud-view-dialog';
18
+ export { ConfirmActionDialog } from '../components/dialog/confirm-action-dialog';
19
+ export type { ConfirmActionDialogProps } from '../components/dialog/confirm-action-dialog';
18
20
  export type { CrudViewDialogProps } from '../components/dialog/crud-view-dialog';
19
21
  export type { ViewPortalDialogProps, ViewPortalSection, PortalSectionEdit, } from '../components/dialog/view-portal-dialog';
20
22
  export { DialogHeaderContent } from '../components/dialog';
@@ -9,6 +9,7 @@ import { ViewDialog } from "../components/dialog/view-dialog.js";
9
9
  import { CreateDialog } from "../components/dialog/create-dialog.js";
10
10
  import { ViewPortalDialog } from "../components/dialog/view-portal-dialog.js";
11
11
  import { CrudViewDialog } from "../components/dialog/crud-view-dialog.js";
12
+ import { ConfirmActionDialog } from "../components/dialog/confirm-action-dialog.js";
12
13
  import { DialogHeaderContent } from "../components/dialog/index.js";
13
14
  import { StatsGrid } from "../components/dialog/index.js";
14
15
  import { DialogFrame } from "../components/dialog/index.js";
@@ -16,6 +17,7 @@ import { SplitDialogFrame } from "../components/dialog/index.js";
16
17
  import { PageContent } from "../layouts/PageContent.js";
17
18
  export {
18
19
  BaseFormPage,
20
+ ConfirmActionDialog,
19
21
  CreateDialog,
20
22
  CreatePage,
21
23
  CrudViewDialog,
@@ -3,8 +3,8 @@ export type { IconName } from '../utils/icon';
3
3
  export type { PaginationParams, PaginatedResponse, SortField, } from '../types/pagination';
4
4
  export { createPaginatedResponse, asQueryFn } from '../types/pagination';
5
5
  export type { FilterOption, ColumnFilterConfig } from '../types/filters';
6
- export type { ModuleMetadata, ListConfig, CrudColumnDef, FormConfig, QueryConfig, MutationConfig, MutationsConfig, DialogConfig, DialogsConfig, PagesConfig, CrudConfig, CrudConfigWithAnyForm, ToolbarFilterOption, ToolbarFilterConfig, ToolbarConfig, } from '../types/crud';
6
+ export type { ModuleMetadata, ListConfig, CrudColumnDef, FormConfig, QueryConfig, MutationConfig, MutationsConfig, DialogConfig, DialogsConfig, PagesConfig, CrudConfig, CrudConfigWithAnyForm, CrudPermissions, ToolbarFilterOption, ToolbarFilterConfig, ToolbarConfig, } from '../types/crud';
7
7
  export type { ColorPreset, StatItem, HeaderBadgeConfig, HeaderStatsConfig, DialogHeaderConfig, DialogHeaderProps, StatsGridProps, } from '../types/dialog-header';
8
8
  export type { MenuItem, SingleMenuItem, GroupMenuItem, SeparatorMenuItem, MenuItemType, MenuVariant, IconComponent, } from '../types/menu';
9
9
  export type { Density, GapSize, DialogSize, DialogHeight, FieldLayout, CardFieldLayout, } from '../utils/spacing';
10
- export declare const version = "1.0.4";
10
+ export declare const version = "1.1.0";
@@ -1,6 +1,6 @@
1
1
  // src/exports/types-constants.ts
2
2
  import { createPaginatedResponse, asQueryFn } from "../types/pagination.js";
3
- var version = "1.0.4";
3
+ var version = "1.1.0";
4
4
  export {
5
5
  asQueryFn,
6
6
  createPaginatedResponse,
@@ -0,0 +1,5 @@
1
+ /** Built-in masks for `maskType` (`_` = one digit). */
2
+ export type MaskPreset = 'tel' | 'cpf' | 'cnpj' | 'cep';
3
+ export declare function isMaskPreset(maskType: unknown): maskType is MaskPreset;
4
+ /** Mask for `digitCount` raw digits: the `maskType` preset when there is one, else `mask`. */
5
+ export declare function resolveMask(maskType: string | undefined, mask: string | undefined, digitCount: number): string;
@@ -0,0 +1,18 @@
1
+ // src/field-system/mask-presets.ts
2
+ var telMaskFor = (digitCount) => digitCount > 10 ? "(__) _____-____" : "(__) ____-____";
3
+ var MASK_PRESETS = {
4
+ tel: telMaskFor,
5
+ cpf: () => "___.___.___-__",
6
+ cnpj: () => "__.___.___/____-__",
7
+ cep: () => "_____-___"
8
+ };
9
+ function isMaskPreset(maskType) {
10
+ return typeof maskType === "string" && Object.hasOwn(MASK_PRESETS, maskType);
11
+ }
12
+ function resolveMask(maskType, mask, digitCount) {
13
+ return isMaskPreset(maskType) ? MASK_PRESETS[maskType](digitCount) : mask || "";
14
+ }
15
+ export {
16
+ isMaskPreset,
17
+ resolveMask
18
+ };