@asteby/metacore-runtime-react 28.3.6 → 28.4.1

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 (39) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/action-modal-dispatcher.js +1 -1
  3. package/dist/column-visibility.d.ts +0 -14
  4. package/dist/column-visibility.d.ts.map +1 -1
  5. package/dist/column-visibility.js +11 -1
  6. package/dist/dashboard-grid.d.ts.map +1 -1
  7. package/dist/dashboard-grid.js +5 -1
  8. package/dist/dialogs/dynamic-record.d.ts +13 -1
  9. package/dist/dialogs/dynamic-record.d.ts.map +1 -1
  10. package/dist/dialogs/dynamic-record.js +18 -6
  11. package/dist/dynamic-form-schema.d.ts +26 -1
  12. package/dist/dynamic-form-schema.d.ts.map +1 -1
  13. package/dist/dynamic-form-schema.js +41 -0
  14. package/dist/dynamic-form.d.ts.map +1 -1
  15. package/dist/dynamic-form.js +12 -5
  16. package/dist/dynamic-relation.d.ts +12 -0
  17. package/dist/dynamic-relation.d.ts.map +1 -1
  18. package/dist/dynamic-relation.js +12 -6
  19. package/dist/dynamic-relations.d.ts +9 -1
  20. package/dist/dynamic-relations.d.ts.map +1 -1
  21. package/dist/dynamic-relations.js +5 -4
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/types.d.ts +35 -0
  26. package/dist/types.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/__tests__/dynamic-relation-subtable-context.test.tsx +74 -0
  29. package/src/__tests__/visible-when.test.ts +63 -0
  30. package/src/action-modal-dispatcher.tsx +1 -1
  31. package/src/column-visibility.ts +14 -1
  32. package/src/dashboard-grid.tsx +5 -1
  33. package/src/dialogs/dynamic-record.tsx +29 -4
  34. package/src/dynamic-form-schema.ts +47 -1
  35. package/src/dynamic-form.tsx +17 -4
  36. package/src/dynamic-relation.tsx +25 -8
  37. package/src/dynamic-relations.tsx +16 -1
  38. package/src/index.ts +2 -0
  39. package/src/types.ts +36 -0
@@ -11,6 +11,7 @@
11
11
  // { owner_model: "Customer" }) into the panel's `filters` so the child list
12
12
  // is scoped by the FK AND every scope column.
13
13
  import { useMemo } from 'react'
14
+ import { cn } from '@asteby/metacore-ui/lib'
14
15
  import { DynamicRelation, type DynamicRelationStrings } from './dynamic-relation'
15
16
  import type { RelationMeta } from './types'
16
17
 
@@ -40,6 +41,14 @@ export interface DynamicRelationsProps {
40
41
  canEdit?: boolean
41
42
  /** Translatable strings forwarded to each DynamicRelation. */
42
43
  strings?: Partial<DynamicRelationStrings>
44
+ /**
45
+ * True cuando estos paneles se renderizan como sub-tablas de líneas dentro
46
+ * del MODAL de vista de un registro. Propaga `lineSubtable` a cada
47
+ * `<DynamicRelation>` para ocultar por defecto las columnas de auditoría/
48
+ * sistema redundantes bajo el padre. Default false — una página de detalle
49
+ * autónoma conserva todas las columnas.
50
+ */
51
+ lineSubtable?: boolean
43
52
  /** Bubble up when any panel's data changes (create/delete/attach/detach). */
44
53
  onChange?: (relation: RelationMeta) => void
45
54
  }
@@ -96,6 +105,7 @@ export function DynamicRelations({
96
105
  canDelete = true,
97
106
  canEdit = true,
98
107
  strings,
108
+ lineSubtable = false,
99
109
  onChange,
100
110
  }: DynamicRelationsProps) {
101
111
  const parentId = useMemo(
@@ -108,7 +118,10 @@ export function DynamicRelations({
108
118
  }
109
119
 
110
120
  return (
111
- <div className={className} data-dynamic-relations="">
121
+ // `space-y-6` separates stacked relation panels (e.g. "Líneas del
122
+ // pedido" and "Facturas" in the view modal) — without it consecutive
123
+ // panels sat flush against each other with no breathing room.
124
+ <div className={cn('space-y-6', className)} data-dynamic-relations="">
112
125
  {relations.map((rel, idx) => {
113
126
  const filters = buildRelationFilters(rel, parentId)
114
127
  const panelStrings: Partial<DynamicRelationStrings> = {
@@ -135,6 +148,7 @@ export function DynamicRelations({
135
148
  parentId={parentId}
136
149
  filters={filters}
137
150
  className={panelClassName}
151
+ lineSubtable={lineSubtable}
138
152
  canCreate={canCreate}
139
153
  canDelete={canDelete}
140
154
  readonly={relReadonly}
@@ -152,6 +166,7 @@ export function DynamicRelations({
152
166
  parentId={parentId}
153
167
  filters={filters}
154
168
  className={panelClassName}
169
+ lineSubtable={lineSubtable}
155
170
  canCreate={canCreate}
156
171
  canDelete={canDelete}
157
172
  canEdit={canEdit}
package/src/index.ts CHANGED
@@ -307,6 +307,8 @@ export {
307
307
  resolveDependsValue,
308
308
  getOptionsConfig,
309
309
  resolveOptionsSource,
310
+ getVisibleWhen,
311
+ evaluateVisibleWhen,
310
312
  } from './dynamic-form-schema'
311
313
  export {
312
314
  ActivityValueRenderer,
package/src/types.ts CHANGED
@@ -295,6 +295,17 @@ export interface ColumnDefinition {
295
295
  itemFields?: ColumnItemField[]
296
296
  /** snake_case alias served by the kernel for `itemFields`. */
297
297
  item_fields?: ColumnItemField[]
298
+ /**
299
+ * Conditional visibility in the create/edit modal: render this field only
300
+ * when a sibling field's current value matches the predicate. Mirrors the
301
+ * kernel v3 `Column.visible_when` (projected onto the served ColumnDef).
302
+ * Tolerates the camelCase alias. Absent = always visible; a hidden field is
303
+ * skipped by the required-gate so it never blocks submit. See
304
+ * `evaluateVisibleWhen`.
305
+ */
306
+ visible_when?: VisibleWhen
307
+ /** camelCase alias for `visible_when`. */
308
+ visibleWhen?: VisibleWhen
298
309
  }
299
310
 
300
311
  /**
@@ -317,6 +328,21 @@ export interface ActionCondition {
317
328
  value: string | string[]
318
329
  }
319
330
 
331
+ /**
332
+ * Conditional-visibility predicate for a create/edit form field. Mirrors the
333
+ * kernel v3 `visible_when` block (json `visible_when`): the owning field is
334
+ * rendered only when the SIBLING field named by `field` holds a value that
335
+ * matches — either equal to `equals` (exact string) OR a member of `in`
336
+ * (any-of). When both are set `in` wins. Absent = the field is always visible
337
+ * (retrocompat). Evaluated by `evaluateVisibleWhen` against the live form
338
+ * values; a hidden field never gates submit (its required-check is skipped).
339
+ */
340
+ export interface VisibleWhen {
341
+ field: string
342
+ equals?: string
343
+ in?: string[]
344
+ }
345
+
320
346
  // Mirrors `ValidationRule` from packages/sdk/src/generated/manifest.ts. Kept
321
347
  // inline here so runtime-react does not import generated kernel types directly
322
348
  // — apps and addons author ActionFieldDef literals.
@@ -493,6 +519,16 @@ export interface ActionFieldDef {
493
519
  storagePath?: string
494
520
  /** snake_case alias served by the kernel manifest for `storagePath`. */
495
521
  storage_path?: string
522
+ /**
523
+ * Conditional visibility: render this field only when a sibling field's
524
+ * current value matches the predicate. Mirrors the kernel v3
525
+ * `ActionField.visible_when`. Tolerates the camelCase alias. Absent = always
526
+ * visible; a hidden field is skipped by the required-gate so it never blocks
527
+ * submit. See `evaluateVisibleWhen`.
528
+ */
529
+ visible_when?: VisibleWhen
530
+ /** camelCase alias for `visible_when`. */
531
+ visibleWhen?: VisibleWhen
496
532
  }
497
533
 
498
534
  /**