@msbci/form-editor 1.3.4 → 1.3.6

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.
package/dist/index.d.mts CHANGED
@@ -53,6 +53,25 @@ interface IEditorAdapter {
53
53
  * empty list (the user can no longer pick from existing scopes).
54
54
  */
55
55
  loadScopes?: () => Promise<IScope[]>;
56
+ /** Optional — create a new {@link IScope}. */
57
+ createScope?: (data: Omit<IScope, 'id' | 'createdAt' | 'updatedAt'>) => Promise<IScope>;
58
+ /** Optional — update an existing {@link IScope}. */
59
+ updateScope?: (id: string, data: Partial<Omit<IScope, 'id' | 'code' | 'tenantId' | 'createdAt' | 'updatedAt'>>) => Promise<IScope>;
60
+ /** Optional — hard-delete a scope (server returns 409 if still in use). */
61
+ deleteScope?: (id: string) => Promise<void>;
62
+ /**
63
+ * Optional — create a {@link IVariableTemplate} within a scope.
64
+ * `code` and `name` are immutable identity fields enforced by the server.
65
+ */
66
+ createTemplate?: (scopeId: string, data: Omit<IVariableTemplate, 'id' | 'scopeId' | 'tenantId' | 'createdAt' | 'updatedAt'>) => Promise<IVariableTemplate>;
67
+ /**
68
+ * Optional — update a {@link IVariableTemplate}. `code` and `name` are
69
+ * not in the payload type because the server rejects any attempt to
70
+ * change them.
71
+ */
72
+ updateTemplate?: (id: string, data: Partial<Omit<IVariableTemplate, 'id' | 'code' | 'name' | 'scopeId' | 'tenantId' | 'createdAt' | 'updatedAt'>>) => Promise<IVariableTemplate>;
73
+ /** Optional — hard-delete a {@link IVariableTemplate}. */
74
+ deleteTemplate?: (id: string) => Promise<void>;
56
75
  /**
57
76
  * Optional — fetch the {@link IDataSourceConfig} list of a scope.
58
77
  * Called once per scope when `FormEditor` mounts and whenever
@@ -191,6 +210,10 @@ interface IEditorLabels {
191
210
  dataSources: string;
192
211
  /** Tooltip on the DataSources header button. */
193
212
  manageDataSourcesTitle: string;
213
+ /** Header button that opens the ScopeManagerDialog. */
214
+ scopes: string;
215
+ /** Tooltip on the Scopes header button. */
216
+ manageScopesTitle: string;
194
217
  undo: string;
195
218
  redo: string;
196
219
  save: string;
@@ -336,6 +359,16 @@ interface IEditorLabels {
336
359
  readonly: string;
337
360
  hidden: string;
338
361
  expression: string;
362
+ fileConfig: string;
363
+ fileConfigMax: string;
364
+ fileConfigMin: string;
365
+ fileConfigAccept: string;
366
+ fileConfigAcceptPlaceholder: string;
367
+ fileConfigUnlimited: string;
368
+ imageConfig: string;
369
+ imageConfigMax: string;
370
+ imageConfigMin: string;
371
+ imageConfigCamera: string;
339
372
  scopes: string;
340
373
  scopesHint: string;
341
374
  noScopesAvailable: string;
@@ -439,6 +472,65 @@ interface IEditorLabels {
439
472
  dependencyKeyPlaceholder: string;
440
473
  addDependency: string;
441
474
  };
475
+ scopeManager: {
476
+ dialogAriaLabel: string;
477
+ title: string;
478
+ closeAriaLabel: string;
479
+ addScope: string;
480
+ newScopeName: string;
481
+ newScopeCodePlaceholder: string;
482
+ manageVariables: string;
483
+ confirmDelete: string;
484
+ deleteConfirm: string;
485
+ deleteCancel: string;
486
+ noScopes: string;
487
+ saveButton: string;
488
+ cancelButton: string;
489
+ /** Inline error shown when the server returns 409 on delete. */
490
+ deleteError: string;
491
+ /** ARIA labels for row actions. */
492
+ editScopeAria: (code: string) => string;
493
+ removeScopeAria: (code: string) => string;
494
+ manageVariablesAria: (code: string) => string;
495
+ };
496
+ variableTemplateManager: {
497
+ dialogAriaLabel: string;
498
+ title: (scopeName: string) => string;
499
+ closeAriaLabel: string;
500
+ addTemplate: string;
501
+ code: string;
502
+ name: string;
503
+ type: string;
504
+ description: string;
505
+ placeholder: string;
506
+ required: string;
507
+ readonly: string;
508
+ hidden: string;
509
+ options: string;
510
+ expression: string;
511
+ dataSourceId: string;
512
+ advancedSection: string;
513
+ validationRules: string;
514
+ conditions: string;
515
+ style: string;
516
+ confirmDelete: string;
517
+ deleteConfirm: string;
518
+ deleteCancel: string;
519
+ noTemplates: string;
520
+ saveButton: string;
521
+ cancelButton: string;
522
+ /** Inline error when the new code already exists in the scope. */
523
+ duplicateCodeError: string;
524
+ /** Read-only badge label for code field. */
525
+ readonlyCode: string;
526
+ /** Read-only badge label for name field. */
527
+ readonlyName: string;
528
+ /** ARIA labels for row actions. */
529
+ editTemplateAria: (code: string) => string;
530
+ removeTemplateAria: (code: string) => string;
531
+ /** Back to scope list button (header). */
532
+ backToScopes: string;
533
+ };
442
534
  dataSourceManager: {
443
535
  /** ARIA label of the dialog root. */
444
536
  dialogAriaLabel: string;
@@ -750,4 +842,55 @@ interface DataSourceConfigManagerProps {
750
842
  }
751
843
  declare function DataSourceConfigManager({ open, onClose }: DataSourceConfigManagerProps): react_jsx_runtime.JSX.Element | null;
752
844
 
753
- export { type ActiveDragData, Canvas, Canvas as CanvasDnd, CanvasSimple, ConditionBuilder, type ConditionBuilderProps, DataSourceConfigManager, type DataSourceConfigManagerProps, DataSourceSelector, type DataSourceSelectorProps, type DeepPartial, DndManager, type DragEndActions, type EditorActions, EditorLabelsProvider, type EditorSelection, type EditorState, type EditorStore, EditorToolbar, type EditorView, FormEditor, type FormEditorProps, type HistoryEntry, type IEditorAdapter, type IEditorLabels, type OverDropData, PropertiesPanel, Toolbox, Toolbox as ToolboxDnd, ToolboxSimple, createDragEndHandler, frLabels as defaultLabels, enLabels, frLabels, mergeLabels, useEditorStore, useLabels };
845
+ /**
846
+ * ScopeManagerDialog — admin CRUD for {@link IScope} entries.
847
+ *
848
+ * Mirrors the `FormTypesDialog` visual pattern (native modal, inline
849
+ * edit, delete-with-confirm) but persists through the editor adapter:
850
+ * - `adapter.createScope(data)`
851
+ * - `adapter.updateScope(id, data)`
852
+ * - `adapter.deleteScope(id)` — server returns 409 if forms, templates,
853
+ * or data sources still reference the scope; the dialog surfaces the
854
+ * message inline in red.
855
+ *
856
+ * Provides a "Gérer les variables →" affordance per row that opens
857
+ * `VariableTemplateManager` scoped to that scope.
858
+ */
859
+ interface ScopeManagerDialogProps {
860
+ open: boolean;
861
+ onClose: () => void;
862
+ }
863
+ declare function ScopeManagerDialog({ open, onClose }: ScopeManagerDialogProps): react_jsx_runtime.JSX.Element | null;
864
+
865
+ /**
866
+ * VariableTemplateManager — admin CRUD for {@link IVariableTemplate}
867
+ * entries within a single scope.
868
+ *
869
+ * Flow:
870
+ * 1. Mount: re-fetch `adapter.loadTemplates(scopeId)` to get an
871
+ * authoritative list (the store may only carry templates of scopes
872
+ * attached to the current form).
873
+ * 2. CRUD via adapter; optimistic updates on the local list, no refetch.
874
+ *
875
+ * Identity:
876
+ * - `code` and `name` are immutable after creation (server enforces).
877
+ * The edit form shows them disabled, with a "(immuable)" badge.
878
+ *
879
+ * Conditional fields:
880
+ * - `options` editor surfaces only for select/multiselect/radio/checkbox/listradio.
881
+ * - `expression` only for `calculated`.
882
+ * - `dataSourceId` only for select/multiselect.
883
+ *
884
+ * Advanced section (collapsed by default): validationRules, conditions, style.
885
+ * These are surfaced as JSON textareas so admins can paste configurations
886
+ * already produced by the visual condition builder if needed.
887
+ */
888
+ interface VariableTemplateManagerProps {
889
+ open: boolean;
890
+ onClose: () => void;
891
+ scopeId: string;
892
+ scopeName: string;
893
+ }
894
+ declare function VariableTemplateManager({ open, onClose, scopeId, scopeName, }: VariableTemplateManagerProps): react_jsx_runtime.JSX.Element | null;
895
+
896
+ export { type ActiveDragData, Canvas, Canvas as CanvasDnd, CanvasSimple, ConditionBuilder, type ConditionBuilderProps, DataSourceConfigManager, type DataSourceConfigManagerProps, DataSourceSelector, type DataSourceSelectorProps, type DeepPartial, DndManager, type DragEndActions, type EditorActions, EditorLabelsProvider, type EditorSelection, type EditorState, type EditorStore, EditorToolbar, type EditorView, FormEditor, type FormEditorProps, type HistoryEntry, type IEditorAdapter, type IEditorLabels, type OverDropData, PropertiesPanel, ScopeManagerDialog, type ScopeManagerDialogProps, Toolbox, Toolbox as ToolboxDnd, ToolboxSimple, VariableTemplateManager, type VariableTemplateManagerProps, createDragEndHandler, frLabels as defaultLabels, enLabels, frLabels, mergeLabels, useEditorStore, useLabels };
package/dist/index.d.ts CHANGED
@@ -53,6 +53,25 @@ interface IEditorAdapter {
53
53
  * empty list (the user can no longer pick from existing scopes).
54
54
  */
55
55
  loadScopes?: () => Promise<IScope[]>;
56
+ /** Optional — create a new {@link IScope}. */
57
+ createScope?: (data: Omit<IScope, 'id' | 'createdAt' | 'updatedAt'>) => Promise<IScope>;
58
+ /** Optional — update an existing {@link IScope}. */
59
+ updateScope?: (id: string, data: Partial<Omit<IScope, 'id' | 'code' | 'tenantId' | 'createdAt' | 'updatedAt'>>) => Promise<IScope>;
60
+ /** Optional — hard-delete a scope (server returns 409 if still in use). */
61
+ deleteScope?: (id: string) => Promise<void>;
62
+ /**
63
+ * Optional — create a {@link IVariableTemplate} within a scope.
64
+ * `code` and `name` are immutable identity fields enforced by the server.
65
+ */
66
+ createTemplate?: (scopeId: string, data: Omit<IVariableTemplate, 'id' | 'scopeId' | 'tenantId' | 'createdAt' | 'updatedAt'>) => Promise<IVariableTemplate>;
67
+ /**
68
+ * Optional — update a {@link IVariableTemplate}. `code` and `name` are
69
+ * not in the payload type because the server rejects any attempt to
70
+ * change them.
71
+ */
72
+ updateTemplate?: (id: string, data: Partial<Omit<IVariableTemplate, 'id' | 'code' | 'name' | 'scopeId' | 'tenantId' | 'createdAt' | 'updatedAt'>>) => Promise<IVariableTemplate>;
73
+ /** Optional — hard-delete a {@link IVariableTemplate}. */
74
+ deleteTemplate?: (id: string) => Promise<void>;
56
75
  /**
57
76
  * Optional — fetch the {@link IDataSourceConfig} list of a scope.
58
77
  * Called once per scope when `FormEditor` mounts and whenever
@@ -191,6 +210,10 @@ interface IEditorLabels {
191
210
  dataSources: string;
192
211
  /** Tooltip on the DataSources header button. */
193
212
  manageDataSourcesTitle: string;
213
+ /** Header button that opens the ScopeManagerDialog. */
214
+ scopes: string;
215
+ /** Tooltip on the Scopes header button. */
216
+ manageScopesTitle: string;
194
217
  undo: string;
195
218
  redo: string;
196
219
  save: string;
@@ -336,6 +359,16 @@ interface IEditorLabels {
336
359
  readonly: string;
337
360
  hidden: string;
338
361
  expression: string;
362
+ fileConfig: string;
363
+ fileConfigMax: string;
364
+ fileConfigMin: string;
365
+ fileConfigAccept: string;
366
+ fileConfigAcceptPlaceholder: string;
367
+ fileConfigUnlimited: string;
368
+ imageConfig: string;
369
+ imageConfigMax: string;
370
+ imageConfigMin: string;
371
+ imageConfigCamera: string;
339
372
  scopes: string;
340
373
  scopesHint: string;
341
374
  noScopesAvailable: string;
@@ -439,6 +472,65 @@ interface IEditorLabels {
439
472
  dependencyKeyPlaceholder: string;
440
473
  addDependency: string;
441
474
  };
475
+ scopeManager: {
476
+ dialogAriaLabel: string;
477
+ title: string;
478
+ closeAriaLabel: string;
479
+ addScope: string;
480
+ newScopeName: string;
481
+ newScopeCodePlaceholder: string;
482
+ manageVariables: string;
483
+ confirmDelete: string;
484
+ deleteConfirm: string;
485
+ deleteCancel: string;
486
+ noScopes: string;
487
+ saveButton: string;
488
+ cancelButton: string;
489
+ /** Inline error shown when the server returns 409 on delete. */
490
+ deleteError: string;
491
+ /** ARIA labels for row actions. */
492
+ editScopeAria: (code: string) => string;
493
+ removeScopeAria: (code: string) => string;
494
+ manageVariablesAria: (code: string) => string;
495
+ };
496
+ variableTemplateManager: {
497
+ dialogAriaLabel: string;
498
+ title: (scopeName: string) => string;
499
+ closeAriaLabel: string;
500
+ addTemplate: string;
501
+ code: string;
502
+ name: string;
503
+ type: string;
504
+ description: string;
505
+ placeholder: string;
506
+ required: string;
507
+ readonly: string;
508
+ hidden: string;
509
+ options: string;
510
+ expression: string;
511
+ dataSourceId: string;
512
+ advancedSection: string;
513
+ validationRules: string;
514
+ conditions: string;
515
+ style: string;
516
+ confirmDelete: string;
517
+ deleteConfirm: string;
518
+ deleteCancel: string;
519
+ noTemplates: string;
520
+ saveButton: string;
521
+ cancelButton: string;
522
+ /** Inline error when the new code already exists in the scope. */
523
+ duplicateCodeError: string;
524
+ /** Read-only badge label for code field. */
525
+ readonlyCode: string;
526
+ /** Read-only badge label for name field. */
527
+ readonlyName: string;
528
+ /** ARIA labels for row actions. */
529
+ editTemplateAria: (code: string) => string;
530
+ removeTemplateAria: (code: string) => string;
531
+ /** Back to scope list button (header). */
532
+ backToScopes: string;
533
+ };
442
534
  dataSourceManager: {
443
535
  /** ARIA label of the dialog root. */
444
536
  dialogAriaLabel: string;
@@ -750,4 +842,55 @@ interface DataSourceConfigManagerProps {
750
842
  }
751
843
  declare function DataSourceConfigManager({ open, onClose }: DataSourceConfigManagerProps): react_jsx_runtime.JSX.Element | null;
752
844
 
753
- export { type ActiveDragData, Canvas, Canvas as CanvasDnd, CanvasSimple, ConditionBuilder, type ConditionBuilderProps, DataSourceConfigManager, type DataSourceConfigManagerProps, DataSourceSelector, type DataSourceSelectorProps, type DeepPartial, DndManager, type DragEndActions, type EditorActions, EditorLabelsProvider, type EditorSelection, type EditorState, type EditorStore, EditorToolbar, type EditorView, FormEditor, type FormEditorProps, type HistoryEntry, type IEditorAdapter, type IEditorLabels, type OverDropData, PropertiesPanel, Toolbox, Toolbox as ToolboxDnd, ToolboxSimple, createDragEndHandler, frLabels as defaultLabels, enLabels, frLabels, mergeLabels, useEditorStore, useLabels };
845
+ /**
846
+ * ScopeManagerDialog — admin CRUD for {@link IScope} entries.
847
+ *
848
+ * Mirrors the `FormTypesDialog` visual pattern (native modal, inline
849
+ * edit, delete-with-confirm) but persists through the editor adapter:
850
+ * - `adapter.createScope(data)`
851
+ * - `adapter.updateScope(id, data)`
852
+ * - `adapter.deleteScope(id)` — server returns 409 if forms, templates,
853
+ * or data sources still reference the scope; the dialog surfaces the
854
+ * message inline in red.
855
+ *
856
+ * Provides a "Gérer les variables →" affordance per row that opens
857
+ * `VariableTemplateManager` scoped to that scope.
858
+ */
859
+ interface ScopeManagerDialogProps {
860
+ open: boolean;
861
+ onClose: () => void;
862
+ }
863
+ declare function ScopeManagerDialog({ open, onClose }: ScopeManagerDialogProps): react_jsx_runtime.JSX.Element | null;
864
+
865
+ /**
866
+ * VariableTemplateManager — admin CRUD for {@link IVariableTemplate}
867
+ * entries within a single scope.
868
+ *
869
+ * Flow:
870
+ * 1. Mount: re-fetch `adapter.loadTemplates(scopeId)` to get an
871
+ * authoritative list (the store may only carry templates of scopes
872
+ * attached to the current form).
873
+ * 2. CRUD via adapter; optimistic updates on the local list, no refetch.
874
+ *
875
+ * Identity:
876
+ * - `code` and `name` are immutable after creation (server enforces).
877
+ * The edit form shows them disabled, with a "(immuable)" badge.
878
+ *
879
+ * Conditional fields:
880
+ * - `options` editor surfaces only for select/multiselect/radio/checkbox/listradio.
881
+ * - `expression` only for `calculated`.
882
+ * - `dataSourceId` only for select/multiselect.
883
+ *
884
+ * Advanced section (collapsed by default): validationRules, conditions, style.
885
+ * These are surfaced as JSON textareas so admins can paste configurations
886
+ * already produced by the visual condition builder if needed.
887
+ */
888
+ interface VariableTemplateManagerProps {
889
+ open: boolean;
890
+ onClose: () => void;
891
+ scopeId: string;
892
+ scopeName: string;
893
+ }
894
+ declare function VariableTemplateManager({ open, onClose, scopeId, scopeName, }: VariableTemplateManagerProps): react_jsx_runtime.JSX.Element | null;
895
+
896
+ export { type ActiveDragData, Canvas, Canvas as CanvasDnd, CanvasSimple, ConditionBuilder, type ConditionBuilderProps, DataSourceConfigManager, type DataSourceConfigManagerProps, DataSourceSelector, type DataSourceSelectorProps, type DeepPartial, DndManager, type DragEndActions, type EditorActions, EditorLabelsProvider, type EditorSelection, type EditorState, type EditorStore, EditorToolbar, type EditorView, FormEditor, type FormEditorProps, type HistoryEntry, type IEditorAdapter, type IEditorLabels, type OverDropData, PropertiesPanel, ScopeManagerDialog, type ScopeManagerDialogProps, Toolbox, Toolbox as ToolboxDnd, ToolboxSimple, VariableTemplateManager, type VariableTemplateManagerProps, createDragEndHandler, frLabels as defaultLabels, enLabels, frLabels, mergeLabels, useEditorStore, useLabels };