@msbci/form-editor 1.3.0 → 1.3.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.
- package/README.md +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +82 -6
- package/dist/index.d.ts +82 -6
- 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,8 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, IDataSourceConnector, IConditionRule, IRosterVariableRef } from '@msbci/form-core';
|
|
2
|
+
import React, { ReactNode, ComponentType } from 'react';
|
|
3
|
+
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, 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
|
+
import { DragEndEvent } from '@dnd-kit/core';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Editor store types.
|
|
@@ -442,11 +443,25 @@ interface FormEditorProps {
|
|
|
442
443
|
dataSources?: Record<string, IDataSourceConnector>;
|
|
443
444
|
mode?: string;
|
|
444
445
|
}>;
|
|
445
|
-
/**
|
|
446
|
+
/**
|
|
447
|
+
* Override the default DnD-enabled Toolbox. Most consumers should leave
|
|
448
|
+
* this undefined and rely on the default `Toolbox` component, which
|
|
449
|
+
* already supports drag & drop and the click-to-add flow.
|
|
450
|
+
*/
|
|
446
451
|
ToolboxComponent?: ComponentType<any>;
|
|
447
|
-
/**
|
|
452
|
+
/**
|
|
453
|
+
* Override the default DnD-enabled Canvas. Most consumers should leave
|
|
454
|
+
* this undefined; the default `Canvas` component handles reordering and
|
|
455
|
+
* cross-container drops automatically.
|
|
456
|
+
*/
|
|
448
457
|
CanvasComponent?: ComponentType<any>;
|
|
449
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* @deprecated Drag & drop is now provided by `DndManager` internally.
|
|
460
|
+
* If you still pass a `Wrapper`, it is applied AROUND the internal
|
|
461
|
+
* `<DndManager>` so your wrapper keeps running, but you no longer need
|
|
462
|
+
* to mount your own `<DndContext>`. A one-time console warning is
|
|
463
|
+
* emitted to make the deprecation visible.
|
|
464
|
+
*/
|
|
450
465
|
Wrapper?: ComponentType<any>;
|
|
451
466
|
}
|
|
452
467
|
declare function FormEditor({ theme, dataSources, adapter, initialForm, formId, onChange, onSave, labels, PreviewComponent, ToolboxComponent, CanvasComponent, Wrapper, }: FormEditorProps): react_jsx_runtime.JSX.Element;
|
|
@@ -463,6 +478,67 @@ interface EditorToolbarProps {
|
|
|
463
478
|
}
|
|
464
479
|
declare function EditorToolbar({ onSave, onExport, onImport }: EditorToolbarProps): react_jsx_runtime.JSX.Element;
|
|
465
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Toolbox panel (DnD) — left side of the editor.
|
|
483
|
+
* Two tabs:
|
|
484
|
+
* - Champs : variable types + roster variants (draggable).
|
|
485
|
+
* - Variables : reusable templates from the current scope (draggable
|
|
486
|
+
* with data.type='new-variable-from-template').
|
|
487
|
+
*/
|
|
488
|
+
declare function Toolbox(): react_jsx_runtime.JSX.Element;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Canvas panel — center of the editor.
|
|
492
|
+
* Displays the form structure as pages with a unified list of items
|
|
493
|
+
* (variables + rosters). Items share a single SortableContext so the
|
|
494
|
+
* drag & drop reordering works across both kinds.
|
|
495
|
+
*/
|
|
496
|
+
declare function Canvas(): react_jsx_runtime.JSX.Element;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Subset of the editor store the drag-end logic actually needs. Decoupling
|
|
500
|
+
* makes the handler trivially mockable in unit tests.
|
|
501
|
+
*/
|
|
502
|
+
interface DragEndActions {
|
|
503
|
+
addVariable: (pageCode: string, variable: IFormVariable, rosterCode?: string) => void;
|
|
504
|
+
addRoster: (pageCode: string, roster: IFormRoster) => void;
|
|
505
|
+
addVariableFromTemplate: (pageCode: string, template: IVariableTemplate, rosterCode?: string) => void;
|
|
506
|
+
moveItem: (pageCode: string, fromIndex: number, toIndex: number) => void;
|
|
507
|
+
moveVariable: (fromPageCode: string, toPageCode: string, variableCode: string, newOrder: number, fromRosterCode?: string, toRosterCode?: string) => void;
|
|
508
|
+
reorderPages: (orderedCodes: string[]) => void;
|
|
509
|
+
}
|
|
510
|
+
/** Active draggable payload — what Canvas / Toolbox put under `data.current`. */
|
|
511
|
+
interface ActiveDragData {
|
|
512
|
+
type?: 'new-variable' | 'new-roster' | 'new-variable-from-template' | 'variable' | 'roster' | 'page';
|
|
513
|
+
variableType?: VariableType;
|
|
514
|
+
rosterType?: RosterType;
|
|
515
|
+
template?: IVariableTemplate;
|
|
516
|
+
pageCode?: string;
|
|
517
|
+
variableCode?: string;
|
|
518
|
+
rosterCode?: string;
|
|
519
|
+
}
|
|
520
|
+
/** Over (drop-target) payload. */
|
|
521
|
+
interface OverDropData {
|
|
522
|
+
type?: 'page' | 'variable' | 'roster' | 'roster-drop';
|
|
523
|
+
pageCode?: string;
|
|
524
|
+
rosterCode?: string;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Build a pure drag-end handler. Given a snapshot accessor for the form
|
|
528
|
+
* and the store actions, returns a function that translates a DragEndEvent
|
|
529
|
+
* into the right action call. Exported for unit tests.
|
|
530
|
+
*/
|
|
531
|
+
declare function createDragEndHandler(actions: DragEndActions, getForm: () => IFormDefinition): (event: DragEndEvent) => void;
|
|
532
|
+
/**
|
|
533
|
+
* Wraps the editor tree in a `<DndContext>` configured with pointer +
|
|
534
|
+
* keyboard sensors and the drag-end handler returned by
|
|
535
|
+
* {@link createDragEndHandler}. A `<DragOverlay>` shows a label while
|
|
536
|
+
* something is being dragged.
|
|
537
|
+
*/
|
|
538
|
+
declare function DndManager({ children }: {
|
|
539
|
+
children: React.ReactNode;
|
|
540
|
+
}): react_jsx_runtime.JSX.Element;
|
|
541
|
+
|
|
466
542
|
/**
|
|
467
543
|
* Toolbox — left panel. Two tabs:
|
|
468
544
|
* - Champs : variable types + roster variants (original content).
|
|
@@ -528,4 +604,4 @@ interface DataSourceSelectorProps {
|
|
|
528
604
|
}
|
|
529
605
|
declare function DataSourceSelector({ dataSourceId, dependencies, availableConnectors, availableVariables, onConnectorChange, onDependenciesChange, }: DataSourceSelectorProps): react_jsx_runtime.JSX.Element;
|
|
530
606
|
|
|
531
|
-
export {
|
|
607
|
+
export { type ActiveDragData, Canvas, Canvas as CanvasDnd, CanvasSimple, ConditionBuilder, type ConditionBuilderProps, 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,8 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, IDataSourceConnector, IConditionRule, IRosterVariableRef } from '@msbci/form-core';
|
|
2
|
+
import React, { ReactNode, ComponentType } from 'react';
|
|
3
|
+
import { IFormDefinition, IFormPage, IFormRoster, IFormVariable, IVariableTemplate, IVariableTemplateOverrides, IFormType, 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
|
+
import { DragEndEvent } from '@dnd-kit/core';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Editor store types.
|
|
@@ -442,11 +443,25 @@ interface FormEditorProps {
|
|
|
442
443
|
dataSources?: Record<string, IDataSourceConnector>;
|
|
443
444
|
mode?: string;
|
|
444
445
|
}>;
|
|
445
|
-
/**
|
|
446
|
+
/**
|
|
447
|
+
* Override the default DnD-enabled Toolbox. Most consumers should leave
|
|
448
|
+
* this undefined and rely on the default `Toolbox` component, which
|
|
449
|
+
* already supports drag & drop and the click-to-add flow.
|
|
450
|
+
*/
|
|
446
451
|
ToolboxComponent?: ComponentType<any>;
|
|
447
|
-
/**
|
|
452
|
+
/**
|
|
453
|
+
* Override the default DnD-enabled Canvas. Most consumers should leave
|
|
454
|
+
* this undefined; the default `Canvas` component handles reordering and
|
|
455
|
+
* cross-container drops automatically.
|
|
456
|
+
*/
|
|
448
457
|
CanvasComponent?: ComponentType<any>;
|
|
449
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* @deprecated Drag & drop is now provided by `DndManager` internally.
|
|
460
|
+
* If you still pass a `Wrapper`, it is applied AROUND the internal
|
|
461
|
+
* `<DndManager>` so your wrapper keeps running, but you no longer need
|
|
462
|
+
* to mount your own `<DndContext>`. A one-time console warning is
|
|
463
|
+
* emitted to make the deprecation visible.
|
|
464
|
+
*/
|
|
450
465
|
Wrapper?: ComponentType<any>;
|
|
451
466
|
}
|
|
452
467
|
declare function FormEditor({ theme, dataSources, adapter, initialForm, formId, onChange, onSave, labels, PreviewComponent, ToolboxComponent, CanvasComponent, Wrapper, }: FormEditorProps): react_jsx_runtime.JSX.Element;
|
|
@@ -463,6 +478,67 @@ interface EditorToolbarProps {
|
|
|
463
478
|
}
|
|
464
479
|
declare function EditorToolbar({ onSave, onExport, onImport }: EditorToolbarProps): react_jsx_runtime.JSX.Element;
|
|
465
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Toolbox panel (DnD) — left side of the editor.
|
|
483
|
+
* Two tabs:
|
|
484
|
+
* - Champs : variable types + roster variants (draggable).
|
|
485
|
+
* - Variables : reusable templates from the current scope (draggable
|
|
486
|
+
* with data.type='new-variable-from-template').
|
|
487
|
+
*/
|
|
488
|
+
declare function Toolbox(): react_jsx_runtime.JSX.Element;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Canvas panel — center of the editor.
|
|
492
|
+
* Displays the form structure as pages with a unified list of items
|
|
493
|
+
* (variables + rosters). Items share a single SortableContext so the
|
|
494
|
+
* drag & drop reordering works across both kinds.
|
|
495
|
+
*/
|
|
496
|
+
declare function Canvas(): react_jsx_runtime.JSX.Element;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Subset of the editor store the drag-end logic actually needs. Decoupling
|
|
500
|
+
* makes the handler trivially mockable in unit tests.
|
|
501
|
+
*/
|
|
502
|
+
interface DragEndActions {
|
|
503
|
+
addVariable: (pageCode: string, variable: IFormVariable, rosterCode?: string) => void;
|
|
504
|
+
addRoster: (pageCode: string, roster: IFormRoster) => void;
|
|
505
|
+
addVariableFromTemplate: (pageCode: string, template: IVariableTemplate, rosterCode?: string) => void;
|
|
506
|
+
moveItem: (pageCode: string, fromIndex: number, toIndex: number) => void;
|
|
507
|
+
moveVariable: (fromPageCode: string, toPageCode: string, variableCode: string, newOrder: number, fromRosterCode?: string, toRosterCode?: string) => void;
|
|
508
|
+
reorderPages: (orderedCodes: string[]) => void;
|
|
509
|
+
}
|
|
510
|
+
/** Active draggable payload — what Canvas / Toolbox put under `data.current`. */
|
|
511
|
+
interface ActiveDragData {
|
|
512
|
+
type?: 'new-variable' | 'new-roster' | 'new-variable-from-template' | 'variable' | 'roster' | 'page';
|
|
513
|
+
variableType?: VariableType;
|
|
514
|
+
rosterType?: RosterType;
|
|
515
|
+
template?: IVariableTemplate;
|
|
516
|
+
pageCode?: string;
|
|
517
|
+
variableCode?: string;
|
|
518
|
+
rosterCode?: string;
|
|
519
|
+
}
|
|
520
|
+
/** Over (drop-target) payload. */
|
|
521
|
+
interface OverDropData {
|
|
522
|
+
type?: 'page' | 'variable' | 'roster' | 'roster-drop';
|
|
523
|
+
pageCode?: string;
|
|
524
|
+
rosterCode?: string;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Build a pure drag-end handler. Given a snapshot accessor for the form
|
|
528
|
+
* and the store actions, returns a function that translates a DragEndEvent
|
|
529
|
+
* into the right action call. Exported for unit tests.
|
|
530
|
+
*/
|
|
531
|
+
declare function createDragEndHandler(actions: DragEndActions, getForm: () => IFormDefinition): (event: DragEndEvent) => void;
|
|
532
|
+
/**
|
|
533
|
+
* Wraps the editor tree in a `<DndContext>` configured with pointer +
|
|
534
|
+
* keyboard sensors and the drag-end handler returned by
|
|
535
|
+
* {@link createDragEndHandler}. A `<DragOverlay>` shows a label while
|
|
536
|
+
* something is being dragged.
|
|
537
|
+
*/
|
|
538
|
+
declare function DndManager({ children }: {
|
|
539
|
+
children: React.ReactNode;
|
|
540
|
+
}): react_jsx_runtime.JSX.Element;
|
|
541
|
+
|
|
466
542
|
/**
|
|
467
543
|
* Toolbox — left panel. Two tabs:
|
|
468
544
|
* - Champs : variable types + roster variants (original content).
|
|
@@ -528,4 +604,4 @@ interface DataSourceSelectorProps {
|
|
|
528
604
|
}
|
|
529
605
|
declare function DataSourceSelector({ dataSourceId, dependencies, availableConnectors, availableVariables, onConnectorChange, onDependenciesChange, }: DataSourceSelectorProps): react_jsx_runtime.JSX.Element;
|
|
530
606
|
|
|
531
|
-
export {
|
|
607
|
+
export { type ActiveDragData, Canvas, Canvas as CanvasDnd, CanvasSimple, ConditionBuilder, type ConditionBuilderProps, 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 };
|