@msbci/form-editor 1.3.3 → 1.3.5
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/README.md +21 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +246 -3
- package/dist/index.d.ts +246 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, IScope, IDataSourceConnector, VariableType, RosterType, IConditionRule, IRosterVariableRef } from '@msbci/form-core';
|
|
3
|
+
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, IScope, IDataSourceConfig, IDataSourceConnector, VariableType, RosterType, IConditionRule, IRosterVariableRef } from '@msbci/form-core';
|
|
4
4
|
export { IDataSourceConnector, IFormDefinition, IFormPage, IFormRoster, IFormVariable, IMosobiThemeBase } from '@msbci/form-core';
|
|
5
5
|
import * as zustand from 'zustand';
|
|
6
6
|
import { DragEndEvent } from '@dnd-kit/core';
|
|
@@ -53,6 +53,38 @@ 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>;
|
|
75
|
+
/**
|
|
76
|
+
* Optional — fetch the {@link IDataSourceConfig} list of a scope.
|
|
77
|
+
* Called once per scope when `FormEditor` mounts and whenever
|
|
78
|
+
* `form.scopeIds` changes. The editor merges results across scopes
|
|
79
|
+
* (first scope wins on `code` conflicts).
|
|
80
|
+
*/
|
|
81
|
+
loadDataSources?: (scopeId: string) => Promise<IDataSourceConfig[]>;
|
|
82
|
+
/** Optional — create a {@link IDataSourceConfig} within a scope. */
|
|
83
|
+
createDataSource?: (scopeId: string, data: Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>) => Promise<IDataSourceConfig>;
|
|
84
|
+
/** Optional — update an existing {@link IDataSourceConfig}. */
|
|
85
|
+
updateDataSource?: (id: string, data: Partial<Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>>) => Promise<IDataSourceConfig>;
|
|
86
|
+
/** Optional — hard-delete a {@link IDataSourceConfig}. */
|
|
87
|
+
deleteDataSource?: (id: string) => Promise<void>;
|
|
56
88
|
}
|
|
57
89
|
/** Complete editor state */
|
|
58
90
|
interface EditorState {
|
|
@@ -78,6 +110,13 @@ interface EditorState {
|
|
|
78
110
|
* `adapter.loadScopes()`). Out of the undo/redo history.
|
|
79
111
|
*/
|
|
80
112
|
availableScopes: IScope[];
|
|
113
|
+
/**
|
|
114
|
+
* Data source configs available for the current form's scopes.
|
|
115
|
+
* Each entry keeps its `scopeId` so the manager can surface provenance.
|
|
116
|
+
* Deduplicated by `code` (first scope of `form.scopeIds` wins) when
|
|
117
|
+
* populated by `FormEditor`. Out of the undo/redo history.
|
|
118
|
+
*/
|
|
119
|
+
availableDataSources: IDataSourceConfig[];
|
|
81
120
|
}
|
|
82
121
|
/** Editor actions */
|
|
83
122
|
interface EditorActions {
|
|
@@ -134,6 +173,8 @@ interface EditorActions {
|
|
|
134
173
|
setAvailableTemplates: (templates: IVariableTemplate[]) => void;
|
|
135
174
|
/** Replace the scope list shown in the FormProperties scope picker. */
|
|
136
175
|
setAvailableScopes: (scopes: IScope[]) => void;
|
|
176
|
+
/** Replace the data-source list surfaced to the DataSourceConfigManager. */
|
|
177
|
+
setAvailableDataSources: (configs: IDataSourceConfig[]) => void;
|
|
137
178
|
setAdapter: (adapter: IEditorAdapter) => void;
|
|
138
179
|
save: () => Promise<void>;
|
|
139
180
|
load: (formId: string) => Promise<void>;
|
|
@@ -165,6 +206,14 @@ interface IEditorLabels {
|
|
|
165
206
|
formProperties: string;
|
|
166
207
|
types: string;
|
|
167
208
|
manageFormTypesTitle: string;
|
|
209
|
+
/** Header button that opens the DataSourceConfigManager dialog. */
|
|
210
|
+
dataSources: string;
|
|
211
|
+
/** Tooltip on the DataSources header button. */
|
|
212
|
+
manageDataSourcesTitle: string;
|
|
213
|
+
/** Header button that opens the ScopeManagerDialog. */
|
|
214
|
+
scopes: string;
|
|
215
|
+
/** Tooltip on the Scopes header button. */
|
|
216
|
+
manageScopesTitle: string;
|
|
168
217
|
undo: string;
|
|
169
218
|
redo: string;
|
|
170
219
|
save: string;
|
|
@@ -413,6 +462,123 @@ interface IEditorLabels {
|
|
|
413
462
|
dependencyKeyPlaceholder: string;
|
|
414
463
|
addDependency: string;
|
|
415
464
|
};
|
|
465
|
+
scopeManager: {
|
|
466
|
+
dialogAriaLabel: string;
|
|
467
|
+
title: string;
|
|
468
|
+
closeAriaLabel: string;
|
|
469
|
+
addScope: string;
|
|
470
|
+
newScopeName: string;
|
|
471
|
+
newScopeCodePlaceholder: string;
|
|
472
|
+
manageVariables: string;
|
|
473
|
+
confirmDelete: string;
|
|
474
|
+
deleteConfirm: string;
|
|
475
|
+
deleteCancel: string;
|
|
476
|
+
noScopes: string;
|
|
477
|
+
saveButton: string;
|
|
478
|
+
cancelButton: string;
|
|
479
|
+
/** Inline error shown when the server returns 409 on delete. */
|
|
480
|
+
deleteError: string;
|
|
481
|
+
/** ARIA labels for row actions. */
|
|
482
|
+
editScopeAria: (code: string) => string;
|
|
483
|
+
removeScopeAria: (code: string) => string;
|
|
484
|
+
manageVariablesAria: (code: string) => string;
|
|
485
|
+
};
|
|
486
|
+
variableTemplateManager: {
|
|
487
|
+
dialogAriaLabel: string;
|
|
488
|
+
title: (scopeName: string) => string;
|
|
489
|
+
closeAriaLabel: string;
|
|
490
|
+
addTemplate: string;
|
|
491
|
+
code: string;
|
|
492
|
+
name: string;
|
|
493
|
+
type: string;
|
|
494
|
+
description: string;
|
|
495
|
+
placeholder: string;
|
|
496
|
+
required: string;
|
|
497
|
+
readonly: string;
|
|
498
|
+
hidden: string;
|
|
499
|
+
options: string;
|
|
500
|
+
expression: string;
|
|
501
|
+
dataSourceId: string;
|
|
502
|
+
advancedSection: string;
|
|
503
|
+
validationRules: string;
|
|
504
|
+
conditions: string;
|
|
505
|
+
style: string;
|
|
506
|
+
confirmDelete: string;
|
|
507
|
+
deleteConfirm: string;
|
|
508
|
+
deleteCancel: string;
|
|
509
|
+
noTemplates: string;
|
|
510
|
+
saveButton: string;
|
|
511
|
+
cancelButton: string;
|
|
512
|
+
/** Inline error when the new code already exists in the scope. */
|
|
513
|
+
duplicateCodeError: string;
|
|
514
|
+
/** Read-only badge label for code field. */
|
|
515
|
+
readonlyCode: string;
|
|
516
|
+
/** Read-only badge label for name field. */
|
|
517
|
+
readonlyName: string;
|
|
518
|
+
/** ARIA labels for row actions. */
|
|
519
|
+
editTemplateAria: (code: string) => string;
|
|
520
|
+
removeTemplateAria: (code: string) => string;
|
|
521
|
+
/** Back to scope list button (header). */
|
|
522
|
+
backToScopes: string;
|
|
523
|
+
};
|
|
524
|
+
dataSourceManager: {
|
|
525
|
+
/** ARIA label of the dialog root. */
|
|
526
|
+
dialogAriaLabel: string;
|
|
527
|
+
/** Visible dialog title. */
|
|
528
|
+
title: string;
|
|
529
|
+
/** Close button aria-label. */
|
|
530
|
+
closeAriaLabel: string;
|
|
531
|
+
/** "+ Ajouter une source" CTA. */
|
|
532
|
+
addButton: string;
|
|
533
|
+
/** Empty-state message when the scope has no sources yet. */
|
|
534
|
+
noSources: string;
|
|
535
|
+
/** Empty-state message when the form has no scope at all. */
|
|
536
|
+
noScope: string;
|
|
537
|
+
/** Filter label when multiple scopes are linked to the form. */
|
|
538
|
+
scopeFilterLabel: string;
|
|
539
|
+
/** Inline form: code field label. */
|
|
540
|
+
fieldCode: string;
|
|
541
|
+
/** Inline form: name field label. */
|
|
542
|
+
fieldName: string;
|
|
543
|
+
/** Inline form: url field label. */
|
|
544
|
+
fieldUrl: string;
|
|
545
|
+
/** Inline form: method field label. */
|
|
546
|
+
fieldMethod: string;
|
|
547
|
+
/** Inline form: queryParam field label. */
|
|
548
|
+
fieldQueryParam: string;
|
|
549
|
+
/** Inline form: valueField label. */
|
|
550
|
+
fieldValueField: string;
|
|
551
|
+
/** Inline form: labelField label. */
|
|
552
|
+
fieldLabelField: string;
|
|
553
|
+
/** Inline form: headers section label. */
|
|
554
|
+
fieldHeaders: string;
|
|
555
|
+
/** Header row: key placeholder. */
|
|
556
|
+
headerKeyPlaceholder: string;
|
|
557
|
+
/** Header row: value placeholder. */
|
|
558
|
+
headerValuePlaceholder: string;
|
|
559
|
+
/** Add-header button. */
|
|
560
|
+
addHeader: string;
|
|
561
|
+
/** Inline form: dependencies section label. */
|
|
562
|
+
fieldDependencies: string;
|
|
563
|
+
/** Dep row: url param placeholder. */
|
|
564
|
+
dependencyParamPlaceholder: string;
|
|
565
|
+
/** Dep row: variable code placeholder. */
|
|
566
|
+
dependencyVarPlaceholder: string;
|
|
567
|
+
/** Add-dependency button. */
|
|
568
|
+
addDependency: string;
|
|
569
|
+
/** Submit button (create or update). */
|
|
570
|
+
save: string;
|
|
571
|
+
/** Cancel button. */
|
|
572
|
+
cancel: string;
|
|
573
|
+
/** Edit row pencil button aria-label. */
|
|
574
|
+
editAria: (code: string) => string;
|
|
575
|
+
/** Delete row × button aria-label. */
|
|
576
|
+
deleteAria: (code: string) => string;
|
|
577
|
+
/** Provenance badge: which scope the source belongs to. */
|
|
578
|
+
scopeBadge: (scopeCode: string) => string;
|
|
579
|
+
/** Confirm message before deletion. */
|
|
580
|
+
confirmDelete: (code: string) => string;
|
|
581
|
+
};
|
|
416
582
|
formTypesDialog: {
|
|
417
583
|
dialogAriaLabel: string;
|
|
418
584
|
title: string;
|
|
@@ -626,7 +792,11 @@ interface DataSourceSelectorProps {
|
|
|
626
792
|
dataSourceId?: string;
|
|
627
793
|
/** Current dependency mapping: { depKey: variableCode } */
|
|
628
794
|
dependencies?: Record<string, string>;
|
|
629
|
-
/**
|
|
795
|
+
/**
|
|
796
|
+
* Legacy connectors injected by the host code. Merged with the
|
|
797
|
+
* admin-managed configs from the store (the store wins on `id` clash —
|
|
798
|
+
* the editor surfaces what admins actually configured).
|
|
799
|
+
*/
|
|
630
800
|
availableConnectors: IDataSourceConnector[];
|
|
631
801
|
/** All variable codes available for dependency mapping */
|
|
632
802
|
availableVariables: Array<{
|
|
@@ -640,4 +810,77 @@ interface DataSourceSelectorProps {
|
|
|
640
810
|
}
|
|
641
811
|
declare function DataSourceSelector({ dataSourceId, dependencies, availableConnectors, availableVariables, onConnectorChange, onDependenciesChange, }: DataSourceSelectorProps): react_jsx_runtime.JSX.Element;
|
|
642
812
|
|
|
643
|
-
|
|
813
|
+
/**
|
|
814
|
+
* DataSourceConfigManager — admin CRUD for IDataSourceConfig within
|
|
815
|
+
* the scope(s) linked to the current form.
|
|
816
|
+
*
|
|
817
|
+
* Renders a native React modal (same pattern as FormTypesDialog) with:
|
|
818
|
+
* - A scope filter (visible only when the form has more than one scope)
|
|
819
|
+
* - The list of `availableDataSources` filtered by selected scope
|
|
820
|
+
* - An inline add/edit form for code, name, url, method, queryParam,
|
|
821
|
+
* value/label fields, headers (key/value rows), and dependencies
|
|
822
|
+
* (urlParam → variable code rows)
|
|
823
|
+
*
|
|
824
|
+
* Persistence goes through the adapter's CRUD methods; the store is
|
|
825
|
+
* refreshed by mutating `availableDataSources` locally (optimistic — the
|
|
826
|
+
* server is the source of truth). FormEditor's effect will re-load on
|
|
827
|
+
* the next scope change.
|
|
828
|
+
*/
|
|
829
|
+
interface DataSourceConfigManagerProps {
|
|
830
|
+
open: boolean;
|
|
831
|
+
onClose: () => void;
|
|
832
|
+
}
|
|
833
|
+
declare function DataSourceConfigManager({ open, onClose }: DataSourceConfigManagerProps): react_jsx_runtime.JSX.Element | null;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* ScopeManagerDialog — admin CRUD for {@link IScope} entries.
|
|
837
|
+
*
|
|
838
|
+
* Mirrors the `FormTypesDialog` visual pattern (native modal, inline
|
|
839
|
+
* edit, delete-with-confirm) but persists through the editor adapter:
|
|
840
|
+
* - `adapter.createScope(data)`
|
|
841
|
+
* - `adapter.updateScope(id, data)`
|
|
842
|
+
* - `adapter.deleteScope(id)` — server returns 409 if forms, templates,
|
|
843
|
+
* or data sources still reference the scope; the dialog surfaces the
|
|
844
|
+
* message inline in red.
|
|
845
|
+
*
|
|
846
|
+
* Provides a "Gérer les variables →" affordance per row that opens
|
|
847
|
+
* `VariableTemplateManager` scoped to that scope.
|
|
848
|
+
*/
|
|
849
|
+
interface ScopeManagerDialogProps {
|
|
850
|
+
open: boolean;
|
|
851
|
+
onClose: () => void;
|
|
852
|
+
}
|
|
853
|
+
declare function ScopeManagerDialog({ open, onClose }: ScopeManagerDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* VariableTemplateManager — admin CRUD for {@link IVariableTemplate}
|
|
857
|
+
* entries within a single scope.
|
|
858
|
+
*
|
|
859
|
+
* Flow:
|
|
860
|
+
* 1. Mount: re-fetch `adapter.loadTemplates(scopeId)` to get an
|
|
861
|
+
* authoritative list (the store may only carry templates of scopes
|
|
862
|
+
* attached to the current form).
|
|
863
|
+
* 2. CRUD via adapter; optimistic updates on the local list, no refetch.
|
|
864
|
+
*
|
|
865
|
+
* Identity:
|
|
866
|
+
* - `code` and `name` are immutable after creation (server enforces).
|
|
867
|
+
* The edit form shows them disabled, with a "(immuable)" badge.
|
|
868
|
+
*
|
|
869
|
+
* Conditional fields:
|
|
870
|
+
* - `options` editor surfaces only for select/multiselect/radio/checkbox/listradio.
|
|
871
|
+
* - `expression` only for `calculated`.
|
|
872
|
+
* - `dataSourceId` only for select/multiselect.
|
|
873
|
+
*
|
|
874
|
+
* Advanced section (collapsed by default): validationRules, conditions, style.
|
|
875
|
+
* These are surfaced as JSON textareas so admins can paste configurations
|
|
876
|
+
* already produced by the visual condition builder if needed.
|
|
877
|
+
*/
|
|
878
|
+
interface VariableTemplateManagerProps {
|
|
879
|
+
open: boolean;
|
|
880
|
+
onClose: () => void;
|
|
881
|
+
scopeId: string;
|
|
882
|
+
scopeName: string;
|
|
883
|
+
}
|
|
884
|
+
declare function VariableTemplateManager({ open, onClose, scopeId, scopeName, }: VariableTemplateManagerProps): react_jsx_runtime.JSX.Element | null;
|
|
885
|
+
|
|
886
|
+
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, IScope, IDataSourceConnector, VariableType, RosterType, IConditionRule, IRosterVariableRef } from '@msbci/form-core';
|
|
3
|
+
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, IScope, IDataSourceConfig, IDataSourceConnector, VariableType, RosterType, IConditionRule, IRosterVariableRef } from '@msbci/form-core';
|
|
4
4
|
export { IDataSourceConnector, IFormDefinition, IFormPage, IFormRoster, IFormVariable, IMosobiThemeBase } from '@msbci/form-core';
|
|
5
5
|
import * as zustand from 'zustand';
|
|
6
6
|
import { DragEndEvent } from '@dnd-kit/core';
|
|
@@ -53,6 +53,38 @@ 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>;
|
|
75
|
+
/**
|
|
76
|
+
* Optional — fetch the {@link IDataSourceConfig} list of a scope.
|
|
77
|
+
* Called once per scope when `FormEditor` mounts and whenever
|
|
78
|
+
* `form.scopeIds` changes. The editor merges results across scopes
|
|
79
|
+
* (first scope wins on `code` conflicts).
|
|
80
|
+
*/
|
|
81
|
+
loadDataSources?: (scopeId: string) => Promise<IDataSourceConfig[]>;
|
|
82
|
+
/** Optional — create a {@link IDataSourceConfig} within a scope. */
|
|
83
|
+
createDataSource?: (scopeId: string, data: Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>) => Promise<IDataSourceConfig>;
|
|
84
|
+
/** Optional — update an existing {@link IDataSourceConfig}. */
|
|
85
|
+
updateDataSource?: (id: string, data: Partial<Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>>) => Promise<IDataSourceConfig>;
|
|
86
|
+
/** Optional — hard-delete a {@link IDataSourceConfig}. */
|
|
87
|
+
deleteDataSource?: (id: string) => Promise<void>;
|
|
56
88
|
}
|
|
57
89
|
/** Complete editor state */
|
|
58
90
|
interface EditorState {
|
|
@@ -78,6 +110,13 @@ interface EditorState {
|
|
|
78
110
|
* `adapter.loadScopes()`). Out of the undo/redo history.
|
|
79
111
|
*/
|
|
80
112
|
availableScopes: IScope[];
|
|
113
|
+
/**
|
|
114
|
+
* Data source configs available for the current form's scopes.
|
|
115
|
+
* Each entry keeps its `scopeId` so the manager can surface provenance.
|
|
116
|
+
* Deduplicated by `code` (first scope of `form.scopeIds` wins) when
|
|
117
|
+
* populated by `FormEditor`. Out of the undo/redo history.
|
|
118
|
+
*/
|
|
119
|
+
availableDataSources: IDataSourceConfig[];
|
|
81
120
|
}
|
|
82
121
|
/** Editor actions */
|
|
83
122
|
interface EditorActions {
|
|
@@ -134,6 +173,8 @@ interface EditorActions {
|
|
|
134
173
|
setAvailableTemplates: (templates: IVariableTemplate[]) => void;
|
|
135
174
|
/** Replace the scope list shown in the FormProperties scope picker. */
|
|
136
175
|
setAvailableScopes: (scopes: IScope[]) => void;
|
|
176
|
+
/** Replace the data-source list surfaced to the DataSourceConfigManager. */
|
|
177
|
+
setAvailableDataSources: (configs: IDataSourceConfig[]) => void;
|
|
137
178
|
setAdapter: (adapter: IEditorAdapter) => void;
|
|
138
179
|
save: () => Promise<void>;
|
|
139
180
|
load: (formId: string) => Promise<void>;
|
|
@@ -165,6 +206,14 @@ interface IEditorLabels {
|
|
|
165
206
|
formProperties: string;
|
|
166
207
|
types: string;
|
|
167
208
|
manageFormTypesTitle: string;
|
|
209
|
+
/** Header button that opens the DataSourceConfigManager dialog. */
|
|
210
|
+
dataSources: string;
|
|
211
|
+
/** Tooltip on the DataSources header button. */
|
|
212
|
+
manageDataSourcesTitle: string;
|
|
213
|
+
/** Header button that opens the ScopeManagerDialog. */
|
|
214
|
+
scopes: string;
|
|
215
|
+
/** Tooltip on the Scopes header button. */
|
|
216
|
+
manageScopesTitle: string;
|
|
168
217
|
undo: string;
|
|
169
218
|
redo: string;
|
|
170
219
|
save: string;
|
|
@@ -413,6 +462,123 @@ interface IEditorLabels {
|
|
|
413
462
|
dependencyKeyPlaceholder: string;
|
|
414
463
|
addDependency: string;
|
|
415
464
|
};
|
|
465
|
+
scopeManager: {
|
|
466
|
+
dialogAriaLabel: string;
|
|
467
|
+
title: string;
|
|
468
|
+
closeAriaLabel: string;
|
|
469
|
+
addScope: string;
|
|
470
|
+
newScopeName: string;
|
|
471
|
+
newScopeCodePlaceholder: string;
|
|
472
|
+
manageVariables: string;
|
|
473
|
+
confirmDelete: string;
|
|
474
|
+
deleteConfirm: string;
|
|
475
|
+
deleteCancel: string;
|
|
476
|
+
noScopes: string;
|
|
477
|
+
saveButton: string;
|
|
478
|
+
cancelButton: string;
|
|
479
|
+
/** Inline error shown when the server returns 409 on delete. */
|
|
480
|
+
deleteError: string;
|
|
481
|
+
/** ARIA labels for row actions. */
|
|
482
|
+
editScopeAria: (code: string) => string;
|
|
483
|
+
removeScopeAria: (code: string) => string;
|
|
484
|
+
manageVariablesAria: (code: string) => string;
|
|
485
|
+
};
|
|
486
|
+
variableTemplateManager: {
|
|
487
|
+
dialogAriaLabel: string;
|
|
488
|
+
title: (scopeName: string) => string;
|
|
489
|
+
closeAriaLabel: string;
|
|
490
|
+
addTemplate: string;
|
|
491
|
+
code: string;
|
|
492
|
+
name: string;
|
|
493
|
+
type: string;
|
|
494
|
+
description: string;
|
|
495
|
+
placeholder: string;
|
|
496
|
+
required: string;
|
|
497
|
+
readonly: string;
|
|
498
|
+
hidden: string;
|
|
499
|
+
options: string;
|
|
500
|
+
expression: string;
|
|
501
|
+
dataSourceId: string;
|
|
502
|
+
advancedSection: string;
|
|
503
|
+
validationRules: string;
|
|
504
|
+
conditions: string;
|
|
505
|
+
style: string;
|
|
506
|
+
confirmDelete: string;
|
|
507
|
+
deleteConfirm: string;
|
|
508
|
+
deleteCancel: string;
|
|
509
|
+
noTemplates: string;
|
|
510
|
+
saveButton: string;
|
|
511
|
+
cancelButton: string;
|
|
512
|
+
/** Inline error when the new code already exists in the scope. */
|
|
513
|
+
duplicateCodeError: string;
|
|
514
|
+
/** Read-only badge label for code field. */
|
|
515
|
+
readonlyCode: string;
|
|
516
|
+
/** Read-only badge label for name field. */
|
|
517
|
+
readonlyName: string;
|
|
518
|
+
/** ARIA labels for row actions. */
|
|
519
|
+
editTemplateAria: (code: string) => string;
|
|
520
|
+
removeTemplateAria: (code: string) => string;
|
|
521
|
+
/** Back to scope list button (header). */
|
|
522
|
+
backToScopes: string;
|
|
523
|
+
};
|
|
524
|
+
dataSourceManager: {
|
|
525
|
+
/** ARIA label of the dialog root. */
|
|
526
|
+
dialogAriaLabel: string;
|
|
527
|
+
/** Visible dialog title. */
|
|
528
|
+
title: string;
|
|
529
|
+
/** Close button aria-label. */
|
|
530
|
+
closeAriaLabel: string;
|
|
531
|
+
/** "+ Ajouter une source" CTA. */
|
|
532
|
+
addButton: string;
|
|
533
|
+
/** Empty-state message when the scope has no sources yet. */
|
|
534
|
+
noSources: string;
|
|
535
|
+
/** Empty-state message when the form has no scope at all. */
|
|
536
|
+
noScope: string;
|
|
537
|
+
/** Filter label when multiple scopes are linked to the form. */
|
|
538
|
+
scopeFilterLabel: string;
|
|
539
|
+
/** Inline form: code field label. */
|
|
540
|
+
fieldCode: string;
|
|
541
|
+
/** Inline form: name field label. */
|
|
542
|
+
fieldName: string;
|
|
543
|
+
/** Inline form: url field label. */
|
|
544
|
+
fieldUrl: string;
|
|
545
|
+
/** Inline form: method field label. */
|
|
546
|
+
fieldMethod: string;
|
|
547
|
+
/** Inline form: queryParam field label. */
|
|
548
|
+
fieldQueryParam: string;
|
|
549
|
+
/** Inline form: valueField label. */
|
|
550
|
+
fieldValueField: string;
|
|
551
|
+
/** Inline form: labelField label. */
|
|
552
|
+
fieldLabelField: string;
|
|
553
|
+
/** Inline form: headers section label. */
|
|
554
|
+
fieldHeaders: string;
|
|
555
|
+
/** Header row: key placeholder. */
|
|
556
|
+
headerKeyPlaceholder: string;
|
|
557
|
+
/** Header row: value placeholder. */
|
|
558
|
+
headerValuePlaceholder: string;
|
|
559
|
+
/** Add-header button. */
|
|
560
|
+
addHeader: string;
|
|
561
|
+
/** Inline form: dependencies section label. */
|
|
562
|
+
fieldDependencies: string;
|
|
563
|
+
/** Dep row: url param placeholder. */
|
|
564
|
+
dependencyParamPlaceholder: string;
|
|
565
|
+
/** Dep row: variable code placeholder. */
|
|
566
|
+
dependencyVarPlaceholder: string;
|
|
567
|
+
/** Add-dependency button. */
|
|
568
|
+
addDependency: string;
|
|
569
|
+
/** Submit button (create or update). */
|
|
570
|
+
save: string;
|
|
571
|
+
/** Cancel button. */
|
|
572
|
+
cancel: string;
|
|
573
|
+
/** Edit row pencil button aria-label. */
|
|
574
|
+
editAria: (code: string) => string;
|
|
575
|
+
/** Delete row × button aria-label. */
|
|
576
|
+
deleteAria: (code: string) => string;
|
|
577
|
+
/** Provenance badge: which scope the source belongs to. */
|
|
578
|
+
scopeBadge: (scopeCode: string) => string;
|
|
579
|
+
/** Confirm message before deletion. */
|
|
580
|
+
confirmDelete: (code: string) => string;
|
|
581
|
+
};
|
|
416
582
|
formTypesDialog: {
|
|
417
583
|
dialogAriaLabel: string;
|
|
418
584
|
title: string;
|
|
@@ -626,7 +792,11 @@ interface DataSourceSelectorProps {
|
|
|
626
792
|
dataSourceId?: string;
|
|
627
793
|
/** Current dependency mapping: { depKey: variableCode } */
|
|
628
794
|
dependencies?: Record<string, string>;
|
|
629
|
-
/**
|
|
795
|
+
/**
|
|
796
|
+
* Legacy connectors injected by the host code. Merged with the
|
|
797
|
+
* admin-managed configs from the store (the store wins on `id` clash —
|
|
798
|
+
* the editor surfaces what admins actually configured).
|
|
799
|
+
*/
|
|
630
800
|
availableConnectors: IDataSourceConnector[];
|
|
631
801
|
/** All variable codes available for dependency mapping */
|
|
632
802
|
availableVariables: Array<{
|
|
@@ -640,4 +810,77 @@ interface DataSourceSelectorProps {
|
|
|
640
810
|
}
|
|
641
811
|
declare function DataSourceSelector({ dataSourceId, dependencies, availableConnectors, availableVariables, onConnectorChange, onDependenciesChange, }: DataSourceSelectorProps): react_jsx_runtime.JSX.Element;
|
|
642
812
|
|
|
643
|
-
|
|
813
|
+
/**
|
|
814
|
+
* DataSourceConfigManager — admin CRUD for IDataSourceConfig within
|
|
815
|
+
* the scope(s) linked to the current form.
|
|
816
|
+
*
|
|
817
|
+
* Renders a native React modal (same pattern as FormTypesDialog) with:
|
|
818
|
+
* - A scope filter (visible only when the form has more than one scope)
|
|
819
|
+
* - The list of `availableDataSources` filtered by selected scope
|
|
820
|
+
* - An inline add/edit form for code, name, url, method, queryParam,
|
|
821
|
+
* value/label fields, headers (key/value rows), and dependencies
|
|
822
|
+
* (urlParam → variable code rows)
|
|
823
|
+
*
|
|
824
|
+
* Persistence goes through the adapter's CRUD methods; the store is
|
|
825
|
+
* refreshed by mutating `availableDataSources` locally (optimistic — the
|
|
826
|
+
* server is the source of truth). FormEditor's effect will re-load on
|
|
827
|
+
* the next scope change.
|
|
828
|
+
*/
|
|
829
|
+
interface DataSourceConfigManagerProps {
|
|
830
|
+
open: boolean;
|
|
831
|
+
onClose: () => void;
|
|
832
|
+
}
|
|
833
|
+
declare function DataSourceConfigManager({ open, onClose }: DataSourceConfigManagerProps): react_jsx_runtime.JSX.Element | null;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* ScopeManagerDialog — admin CRUD for {@link IScope} entries.
|
|
837
|
+
*
|
|
838
|
+
* Mirrors the `FormTypesDialog` visual pattern (native modal, inline
|
|
839
|
+
* edit, delete-with-confirm) but persists through the editor adapter:
|
|
840
|
+
* - `adapter.createScope(data)`
|
|
841
|
+
* - `adapter.updateScope(id, data)`
|
|
842
|
+
* - `adapter.deleteScope(id)` — server returns 409 if forms, templates,
|
|
843
|
+
* or data sources still reference the scope; the dialog surfaces the
|
|
844
|
+
* message inline in red.
|
|
845
|
+
*
|
|
846
|
+
* Provides a "Gérer les variables →" affordance per row that opens
|
|
847
|
+
* `VariableTemplateManager` scoped to that scope.
|
|
848
|
+
*/
|
|
849
|
+
interface ScopeManagerDialogProps {
|
|
850
|
+
open: boolean;
|
|
851
|
+
onClose: () => void;
|
|
852
|
+
}
|
|
853
|
+
declare function ScopeManagerDialog({ open, onClose }: ScopeManagerDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* VariableTemplateManager — admin CRUD for {@link IVariableTemplate}
|
|
857
|
+
* entries within a single scope.
|
|
858
|
+
*
|
|
859
|
+
* Flow:
|
|
860
|
+
* 1. Mount: re-fetch `adapter.loadTemplates(scopeId)` to get an
|
|
861
|
+
* authoritative list (the store may only carry templates of scopes
|
|
862
|
+
* attached to the current form).
|
|
863
|
+
* 2. CRUD via adapter; optimistic updates on the local list, no refetch.
|
|
864
|
+
*
|
|
865
|
+
* Identity:
|
|
866
|
+
* - `code` and `name` are immutable after creation (server enforces).
|
|
867
|
+
* The edit form shows them disabled, with a "(immuable)" badge.
|
|
868
|
+
*
|
|
869
|
+
* Conditional fields:
|
|
870
|
+
* - `options` editor surfaces only for select/multiselect/radio/checkbox/listradio.
|
|
871
|
+
* - `expression` only for `calculated`.
|
|
872
|
+
* - `dataSourceId` only for select/multiselect.
|
|
873
|
+
*
|
|
874
|
+
* Advanced section (collapsed by default): validationRules, conditions, style.
|
|
875
|
+
* These are surfaced as JSON textareas so admins can paste configurations
|
|
876
|
+
* already produced by the visual condition builder if needed.
|
|
877
|
+
*/
|
|
878
|
+
interface VariableTemplateManagerProps {
|
|
879
|
+
open: boolean;
|
|
880
|
+
onClose: () => void;
|
|
881
|
+
scopeId: string;
|
|
882
|
+
scopeName: string;
|
|
883
|
+
}
|
|
884
|
+
declare function VariableTemplateManager({ open, onClose, scopeId, scopeName, }: VariableTemplateManagerProps): react_jsx_runtime.JSX.Element | null;
|
|
885
|
+
|
|
886
|
+
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 };
|