@msbci/form-editor 1.3.3 → 1.3.4
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 +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +113 -3
- package/dist/index.d.ts +113 -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,19 @@ interface IEditorAdapter {
|
|
|
53
53
|
* empty list (the user can no longer pick from existing scopes).
|
|
54
54
|
*/
|
|
55
55
|
loadScopes?: () => Promise<IScope[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Optional — fetch the {@link IDataSourceConfig} list of a scope.
|
|
58
|
+
* Called once per scope when `FormEditor` mounts and whenever
|
|
59
|
+
* `form.scopeIds` changes. The editor merges results across scopes
|
|
60
|
+
* (first scope wins on `code` conflicts).
|
|
61
|
+
*/
|
|
62
|
+
loadDataSources?: (scopeId: string) => Promise<IDataSourceConfig[]>;
|
|
63
|
+
/** Optional — create a {@link IDataSourceConfig} within a scope. */
|
|
64
|
+
createDataSource?: (scopeId: string, data: Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>) => Promise<IDataSourceConfig>;
|
|
65
|
+
/** Optional — update an existing {@link IDataSourceConfig}. */
|
|
66
|
+
updateDataSource?: (id: string, data: Partial<Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>>) => Promise<IDataSourceConfig>;
|
|
67
|
+
/** Optional — hard-delete a {@link IDataSourceConfig}. */
|
|
68
|
+
deleteDataSource?: (id: string) => Promise<void>;
|
|
56
69
|
}
|
|
57
70
|
/** Complete editor state */
|
|
58
71
|
interface EditorState {
|
|
@@ -78,6 +91,13 @@ interface EditorState {
|
|
|
78
91
|
* `adapter.loadScopes()`). Out of the undo/redo history.
|
|
79
92
|
*/
|
|
80
93
|
availableScopes: IScope[];
|
|
94
|
+
/**
|
|
95
|
+
* Data source configs available for the current form's scopes.
|
|
96
|
+
* Each entry keeps its `scopeId` so the manager can surface provenance.
|
|
97
|
+
* Deduplicated by `code` (first scope of `form.scopeIds` wins) when
|
|
98
|
+
* populated by `FormEditor`. Out of the undo/redo history.
|
|
99
|
+
*/
|
|
100
|
+
availableDataSources: IDataSourceConfig[];
|
|
81
101
|
}
|
|
82
102
|
/** Editor actions */
|
|
83
103
|
interface EditorActions {
|
|
@@ -134,6 +154,8 @@ interface EditorActions {
|
|
|
134
154
|
setAvailableTemplates: (templates: IVariableTemplate[]) => void;
|
|
135
155
|
/** Replace the scope list shown in the FormProperties scope picker. */
|
|
136
156
|
setAvailableScopes: (scopes: IScope[]) => void;
|
|
157
|
+
/** Replace the data-source list surfaced to the DataSourceConfigManager. */
|
|
158
|
+
setAvailableDataSources: (configs: IDataSourceConfig[]) => void;
|
|
137
159
|
setAdapter: (adapter: IEditorAdapter) => void;
|
|
138
160
|
save: () => Promise<void>;
|
|
139
161
|
load: (formId: string) => Promise<void>;
|
|
@@ -165,6 +187,10 @@ interface IEditorLabels {
|
|
|
165
187
|
formProperties: string;
|
|
166
188
|
types: string;
|
|
167
189
|
manageFormTypesTitle: string;
|
|
190
|
+
/** Header button that opens the DataSourceConfigManager dialog. */
|
|
191
|
+
dataSources: string;
|
|
192
|
+
/** Tooltip on the DataSources header button. */
|
|
193
|
+
manageDataSourcesTitle: string;
|
|
168
194
|
undo: string;
|
|
169
195
|
redo: string;
|
|
170
196
|
save: string;
|
|
@@ -413,6 +439,64 @@ interface IEditorLabels {
|
|
|
413
439
|
dependencyKeyPlaceholder: string;
|
|
414
440
|
addDependency: string;
|
|
415
441
|
};
|
|
442
|
+
dataSourceManager: {
|
|
443
|
+
/** ARIA label of the dialog root. */
|
|
444
|
+
dialogAriaLabel: string;
|
|
445
|
+
/** Visible dialog title. */
|
|
446
|
+
title: string;
|
|
447
|
+
/** Close button aria-label. */
|
|
448
|
+
closeAriaLabel: string;
|
|
449
|
+
/** "+ Ajouter une source" CTA. */
|
|
450
|
+
addButton: string;
|
|
451
|
+
/** Empty-state message when the scope has no sources yet. */
|
|
452
|
+
noSources: string;
|
|
453
|
+
/** Empty-state message when the form has no scope at all. */
|
|
454
|
+
noScope: string;
|
|
455
|
+
/** Filter label when multiple scopes are linked to the form. */
|
|
456
|
+
scopeFilterLabel: string;
|
|
457
|
+
/** Inline form: code field label. */
|
|
458
|
+
fieldCode: string;
|
|
459
|
+
/** Inline form: name field label. */
|
|
460
|
+
fieldName: string;
|
|
461
|
+
/** Inline form: url field label. */
|
|
462
|
+
fieldUrl: string;
|
|
463
|
+
/** Inline form: method field label. */
|
|
464
|
+
fieldMethod: string;
|
|
465
|
+
/** Inline form: queryParam field label. */
|
|
466
|
+
fieldQueryParam: string;
|
|
467
|
+
/** Inline form: valueField label. */
|
|
468
|
+
fieldValueField: string;
|
|
469
|
+
/** Inline form: labelField label. */
|
|
470
|
+
fieldLabelField: string;
|
|
471
|
+
/** Inline form: headers section label. */
|
|
472
|
+
fieldHeaders: string;
|
|
473
|
+
/** Header row: key placeholder. */
|
|
474
|
+
headerKeyPlaceholder: string;
|
|
475
|
+
/** Header row: value placeholder. */
|
|
476
|
+
headerValuePlaceholder: string;
|
|
477
|
+
/** Add-header button. */
|
|
478
|
+
addHeader: string;
|
|
479
|
+
/** Inline form: dependencies section label. */
|
|
480
|
+
fieldDependencies: string;
|
|
481
|
+
/** Dep row: url param placeholder. */
|
|
482
|
+
dependencyParamPlaceholder: string;
|
|
483
|
+
/** Dep row: variable code placeholder. */
|
|
484
|
+
dependencyVarPlaceholder: string;
|
|
485
|
+
/** Add-dependency button. */
|
|
486
|
+
addDependency: string;
|
|
487
|
+
/** Submit button (create or update). */
|
|
488
|
+
save: string;
|
|
489
|
+
/** Cancel button. */
|
|
490
|
+
cancel: string;
|
|
491
|
+
/** Edit row pencil button aria-label. */
|
|
492
|
+
editAria: (code: string) => string;
|
|
493
|
+
/** Delete row × button aria-label. */
|
|
494
|
+
deleteAria: (code: string) => string;
|
|
495
|
+
/** Provenance badge: which scope the source belongs to. */
|
|
496
|
+
scopeBadge: (scopeCode: string) => string;
|
|
497
|
+
/** Confirm message before deletion. */
|
|
498
|
+
confirmDelete: (code: string) => string;
|
|
499
|
+
};
|
|
416
500
|
formTypesDialog: {
|
|
417
501
|
dialogAriaLabel: string;
|
|
418
502
|
title: string;
|
|
@@ -626,7 +710,11 @@ interface DataSourceSelectorProps {
|
|
|
626
710
|
dataSourceId?: string;
|
|
627
711
|
/** Current dependency mapping: { depKey: variableCode } */
|
|
628
712
|
dependencies?: Record<string, string>;
|
|
629
|
-
/**
|
|
713
|
+
/**
|
|
714
|
+
* Legacy connectors injected by the host code. Merged with the
|
|
715
|
+
* admin-managed configs from the store (the store wins on `id` clash —
|
|
716
|
+
* the editor surfaces what admins actually configured).
|
|
717
|
+
*/
|
|
630
718
|
availableConnectors: IDataSourceConnector[];
|
|
631
719
|
/** All variable codes available for dependency mapping */
|
|
632
720
|
availableVariables: Array<{
|
|
@@ -640,4 +728,26 @@ interface DataSourceSelectorProps {
|
|
|
640
728
|
}
|
|
641
729
|
declare function DataSourceSelector({ dataSourceId, dependencies, availableConnectors, availableVariables, onConnectorChange, onDependenciesChange, }: DataSourceSelectorProps): react_jsx_runtime.JSX.Element;
|
|
642
730
|
|
|
643
|
-
|
|
731
|
+
/**
|
|
732
|
+
* DataSourceConfigManager — admin CRUD for IDataSourceConfig within
|
|
733
|
+
* the scope(s) linked to the current form.
|
|
734
|
+
*
|
|
735
|
+
* Renders a native React modal (same pattern as FormTypesDialog) with:
|
|
736
|
+
* - A scope filter (visible only when the form has more than one scope)
|
|
737
|
+
* - The list of `availableDataSources` filtered by selected scope
|
|
738
|
+
* - An inline add/edit form for code, name, url, method, queryParam,
|
|
739
|
+
* value/label fields, headers (key/value rows), and dependencies
|
|
740
|
+
* (urlParam → variable code rows)
|
|
741
|
+
*
|
|
742
|
+
* Persistence goes through the adapter's CRUD methods; the store is
|
|
743
|
+
* refreshed by mutating `availableDataSources` locally (optimistic — the
|
|
744
|
+
* server is the source of truth). FormEditor's effect will re-load on
|
|
745
|
+
* the next scope change.
|
|
746
|
+
*/
|
|
747
|
+
interface DataSourceConfigManagerProps {
|
|
748
|
+
open: boolean;
|
|
749
|
+
onClose: () => void;
|
|
750
|
+
}
|
|
751
|
+
declare function DataSourceConfigManager({ open, onClose }: DataSourceConfigManagerProps): react_jsx_runtime.JSX.Element | null;
|
|
752
|
+
|
|
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 };
|
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,19 @@ interface IEditorAdapter {
|
|
|
53
53
|
* empty list (the user can no longer pick from existing scopes).
|
|
54
54
|
*/
|
|
55
55
|
loadScopes?: () => Promise<IScope[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Optional — fetch the {@link IDataSourceConfig} list of a scope.
|
|
58
|
+
* Called once per scope when `FormEditor` mounts and whenever
|
|
59
|
+
* `form.scopeIds` changes. The editor merges results across scopes
|
|
60
|
+
* (first scope wins on `code` conflicts).
|
|
61
|
+
*/
|
|
62
|
+
loadDataSources?: (scopeId: string) => Promise<IDataSourceConfig[]>;
|
|
63
|
+
/** Optional — create a {@link IDataSourceConfig} within a scope. */
|
|
64
|
+
createDataSource?: (scopeId: string, data: Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>) => Promise<IDataSourceConfig>;
|
|
65
|
+
/** Optional — update an existing {@link IDataSourceConfig}. */
|
|
66
|
+
updateDataSource?: (id: string, data: Partial<Omit<IDataSourceConfig, 'id' | 'scopeId' | 'createdAt' | 'updatedAt'>>) => Promise<IDataSourceConfig>;
|
|
67
|
+
/** Optional — hard-delete a {@link IDataSourceConfig}. */
|
|
68
|
+
deleteDataSource?: (id: string) => Promise<void>;
|
|
56
69
|
}
|
|
57
70
|
/** Complete editor state */
|
|
58
71
|
interface EditorState {
|
|
@@ -78,6 +91,13 @@ interface EditorState {
|
|
|
78
91
|
* `adapter.loadScopes()`). Out of the undo/redo history.
|
|
79
92
|
*/
|
|
80
93
|
availableScopes: IScope[];
|
|
94
|
+
/**
|
|
95
|
+
* Data source configs available for the current form's scopes.
|
|
96
|
+
* Each entry keeps its `scopeId` so the manager can surface provenance.
|
|
97
|
+
* Deduplicated by `code` (first scope of `form.scopeIds` wins) when
|
|
98
|
+
* populated by `FormEditor`. Out of the undo/redo history.
|
|
99
|
+
*/
|
|
100
|
+
availableDataSources: IDataSourceConfig[];
|
|
81
101
|
}
|
|
82
102
|
/** Editor actions */
|
|
83
103
|
interface EditorActions {
|
|
@@ -134,6 +154,8 @@ interface EditorActions {
|
|
|
134
154
|
setAvailableTemplates: (templates: IVariableTemplate[]) => void;
|
|
135
155
|
/** Replace the scope list shown in the FormProperties scope picker. */
|
|
136
156
|
setAvailableScopes: (scopes: IScope[]) => void;
|
|
157
|
+
/** Replace the data-source list surfaced to the DataSourceConfigManager. */
|
|
158
|
+
setAvailableDataSources: (configs: IDataSourceConfig[]) => void;
|
|
137
159
|
setAdapter: (adapter: IEditorAdapter) => void;
|
|
138
160
|
save: () => Promise<void>;
|
|
139
161
|
load: (formId: string) => Promise<void>;
|
|
@@ -165,6 +187,10 @@ interface IEditorLabels {
|
|
|
165
187
|
formProperties: string;
|
|
166
188
|
types: string;
|
|
167
189
|
manageFormTypesTitle: string;
|
|
190
|
+
/** Header button that opens the DataSourceConfigManager dialog. */
|
|
191
|
+
dataSources: string;
|
|
192
|
+
/** Tooltip on the DataSources header button. */
|
|
193
|
+
manageDataSourcesTitle: string;
|
|
168
194
|
undo: string;
|
|
169
195
|
redo: string;
|
|
170
196
|
save: string;
|
|
@@ -413,6 +439,64 @@ interface IEditorLabels {
|
|
|
413
439
|
dependencyKeyPlaceholder: string;
|
|
414
440
|
addDependency: string;
|
|
415
441
|
};
|
|
442
|
+
dataSourceManager: {
|
|
443
|
+
/** ARIA label of the dialog root. */
|
|
444
|
+
dialogAriaLabel: string;
|
|
445
|
+
/** Visible dialog title. */
|
|
446
|
+
title: string;
|
|
447
|
+
/** Close button aria-label. */
|
|
448
|
+
closeAriaLabel: string;
|
|
449
|
+
/** "+ Ajouter une source" CTA. */
|
|
450
|
+
addButton: string;
|
|
451
|
+
/** Empty-state message when the scope has no sources yet. */
|
|
452
|
+
noSources: string;
|
|
453
|
+
/** Empty-state message when the form has no scope at all. */
|
|
454
|
+
noScope: string;
|
|
455
|
+
/** Filter label when multiple scopes are linked to the form. */
|
|
456
|
+
scopeFilterLabel: string;
|
|
457
|
+
/** Inline form: code field label. */
|
|
458
|
+
fieldCode: string;
|
|
459
|
+
/** Inline form: name field label. */
|
|
460
|
+
fieldName: string;
|
|
461
|
+
/** Inline form: url field label. */
|
|
462
|
+
fieldUrl: string;
|
|
463
|
+
/** Inline form: method field label. */
|
|
464
|
+
fieldMethod: string;
|
|
465
|
+
/** Inline form: queryParam field label. */
|
|
466
|
+
fieldQueryParam: string;
|
|
467
|
+
/** Inline form: valueField label. */
|
|
468
|
+
fieldValueField: string;
|
|
469
|
+
/** Inline form: labelField label. */
|
|
470
|
+
fieldLabelField: string;
|
|
471
|
+
/** Inline form: headers section label. */
|
|
472
|
+
fieldHeaders: string;
|
|
473
|
+
/** Header row: key placeholder. */
|
|
474
|
+
headerKeyPlaceholder: string;
|
|
475
|
+
/** Header row: value placeholder. */
|
|
476
|
+
headerValuePlaceholder: string;
|
|
477
|
+
/** Add-header button. */
|
|
478
|
+
addHeader: string;
|
|
479
|
+
/** Inline form: dependencies section label. */
|
|
480
|
+
fieldDependencies: string;
|
|
481
|
+
/** Dep row: url param placeholder. */
|
|
482
|
+
dependencyParamPlaceholder: string;
|
|
483
|
+
/** Dep row: variable code placeholder. */
|
|
484
|
+
dependencyVarPlaceholder: string;
|
|
485
|
+
/** Add-dependency button. */
|
|
486
|
+
addDependency: string;
|
|
487
|
+
/** Submit button (create or update). */
|
|
488
|
+
save: string;
|
|
489
|
+
/** Cancel button. */
|
|
490
|
+
cancel: string;
|
|
491
|
+
/** Edit row pencil button aria-label. */
|
|
492
|
+
editAria: (code: string) => string;
|
|
493
|
+
/** Delete row × button aria-label. */
|
|
494
|
+
deleteAria: (code: string) => string;
|
|
495
|
+
/** Provenance badge: which scope the source belongs to. */
|
|
496
|
+
scopeBadge: (scopeCode: string) => string;
|
|
497
|
+
/** Confirm message before deletion. */
|
|
498
|
+
confirmDelete: (code: string) => string;
|
|
499
|
+
};
|
|
416
500
|
formTypesDialog: {
|
|
417
501
|
dialogAriaLabel: string;
|
|
418
502
|
title: string;
|
|
@@ -626,7 +710,11 @@ interface DataSourceSelectorProps {
|
|
|
626
710
|
dataSourceId?: string;
|
|
627
711
|
/** Current dependency mapping: { depKey: variableCode } */
|
|
628
712
|
dependencies?: Record<string, string>;
|
|
629
|
-
/**
|
|
713
|
+
/**
|
|
714
|
+
* Legacy connectors injected by the host code. Merged with the
|
|
715
|
+
* admin-managed configs from the store (the store wins on `id` clash —
|
|
716
|
+
* the editor surfaces what admins actually configured).
|
|
717
|
+
*/
|
|
630
718
|
availableConnectors: IDataSourceConnector[];
|
|
631
719
|
/** All variable codes available for dependency mapping */
|
|
632
720
|
availableVariables: Array<{
|
|
@@ -640,4 +728,26 @@ interface DataSourceSelectorProps {
|
|
|
640
728
|
}
|
|
641
729
|
declare function DataSourceSelector({ dataSourceId, dependencies, availableConnectors, availableVariables, onConnectorChange, onDependenciesChange, }: DataSourceSelectorProps): react_jsx_runtime.JSX.Element;
|
|
642
730
|
|
|
643
|
-
|
|
731
|
+
/**
|
|
732
|
+
* DataSourceConfigManager — admin CRUD for IDataSourceConfig within
|
|
733
|
+
* the scope(s) linked to the current form.
|
|
734
|
+
*
|
|
735
|
+
* Renders a native React modal (same pattern as FormTypesDialog) with:
|
|
736
|
+
* - A scope filter (visible only when the form has more than one scope)
|
|
737
|
+
* - The list of `availableDataSources` filtered by selected scope
|
|
738
|
+
* - An inline add/edit form for code, name, url, method, queryParam,
|
|
739
|
+
* value/label fields, headers (key/value rows), and dependencies
|
|
740
|
+
* (urlParam → variable code rows)
|
|
741
|
+
*
|
|
742
|
+
* Persistence goes through the adapter's CRUD methods; the store is
|
|
743
|
+
* refreshed by mutating `availableDataSources` locally (optimistic — the
|
|
744
|
+
* server is the source of truth). FormEditor's effect will re-load on
|
|
745
|
+
* the next scope change.
|
|
746
|
+
*/
|
|
747
|
+
interface DataSourceConfigManagerProps {
|
|
748
|
+
open: boolean;
|
|
749
|
+
onClose: () => void;
|
|
750
|
+
}
|
|
751
|
+
declare function DataSourceConfigManager({ open, onClose }: DataSourceConfigManagerProps): react_jsx_runtime.JSX.Element | null;
|
|
752
|
+
|
|
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 };
|