@@ -5,7 +5,16 @@ import { Vector } from './core';
5
5
import { CustomActionController } from './custom-action-controller' ;
6
6
import { ComponentType , Sequence , Step } from './definition' ;
7
7
import { I18n } from './designer-configuration' ;
8
- import { Badge , Component , Placeholder , PlaceholderDirection , SequenceComponent , StepComponentView } from './workspace' ;
8
+ import {
9
+ Badge ,
10
+ ClickCommand ,
11
+ ClickDetails ,
12
+ Component ,
13
+ Placeholder ,
14
+ PlaceholderDirection ,
15
+ SequenceComponent ,
16
+ StepComponentView
17
+ } from './workspace' ;
9
18
10
19
export interface DesignerExtension {
11
20
steps ?: StepExtension [ ] ;
@@ -17,6 +26,7 @@ export interface DesignerExtension {
17
26
viewportController ?: ViewportControllerExtension ;
18
27
placeholderController ?: PlaceholderControllerExtension ;
19
28
placeholder ?: PlaceholderExtension ;
29
+ regionComponentView ?: RegionComponentViewExtension ;
20
30
grid ?: GridExtension ;
21
31
rootComponent ?: RootComponentExtension ;
22
32
sequenceComponent ?: SequenceComponentExtension ;
@@ -34,6 +44,7 @@ export interface StepExtension<S extends Step = Step> {
34
44
export type StepComponentViewFactory = StepExtension [ 'createComponentView' ] ;
35
45
36
46
export interface StepComponentViewContext {
47
+ i18n : I18n ;
37
48
getStepName ( ) : string ;
38
49
getStepIconUrl ( ) : string | null ;
39
50
createSequenceComponent ( parentElement : SVGElement , sequence : Sequence ) : SequenceComponent ;
@@ -44,7 +55,13 @@ export interface StepComponentViewContext {
44
55
sequence : Sequence ,
45
56
index : number
46
57
) : Placeholder ;
47
- i18n : I18n ;
58
+ createRegionComponentView (
59
+ parentElement : SVGElement ,
60
+ componentClassName : string ,
61
+ contentFactory : RegionComponentViewContentFactory
62
+ ) : StepComponentView ;
63
+ getPreference ( key : string ) : string | null ;
64
+ setPreference ( key : string , value : string ) : void ;
48
65
}
49
66
50
67
export interface StepContext < S extends Step = Step > {
@@ -71,7 +88,7 @@ export interface StepComponentViewWrapperExtension {
71
88
72
89
export interface BadgeExtension {
73
90
id : string ;
74
- createForStep ( parentElement : SVGElement , stepContext : StepContext , componentContext : ComponentContext ) : Badge ;
91
+ createForStep ( parentElement : SVGElement , view : StepComponentView , stepContext : StepContext , componentContext : ComponentContext ) : Badge ;
75
92
createForRoot ?: ( parentElement : SVGElement , componentContext : ComponentContext ) => Badge ;
76
93
createStartValue ( ) : unknown ;
77
94
}
@@ -202,3 +219,28 @@ export interface DaemonExtension {
202
219
export interface Daemon {
203
220
destroy ( ) : void ;
204
221
}
222
+
223
+ // RegionComponentViewExtension
224
+
225
+ export interface RegionView {
226
+ getClientPosition ( ) : Vector ;
227
+ /**
228
+ * @returns `true` if the click is inside the region, `null` if it's outside. The view may return a command to be executed.
229
+ */
230
+ resolveClick ( click : ClickDetails ) : true | ClickCommand | null ;
231
+ setIsSelected ( isSelected : boolean ) : void ;
232
+ }
233
+
234
+ export type RegionViewFactory = ( parent : SVGElement , widths : number [ ] , height : number ) => RegionView ;
235
+
236
+ export type RegionComponentViewContentFactory = ( g : SVGGElement , regionViewFactory : RegionViewFactory ) => StepComponentView ;
237
+
238
+ export interface RegionComponentViewExtension {
239
+ create (
240
+ parentElement : SVGElement ,
241
+ componentClassName : string ,
242
+ stepContext : StepContext ,
243
+ viewContext : StepComponentViewContext ,
244
+ contentFactory : RegionComponentViewContentFactory
245
+ ) : StepComponentView ;
246
+ }
0 commit comments