@conterra/ct-mapapps-typings 4.19.2-next.20250402042452 → 4.19.2-next.20250403042107

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.
Files changed (2) hide show
  1. package/ct/tools/Tool.d.ts +68 -69
  2. package/package.json +1 -1
@@ -27,209 +27,207 @@
27
27
  *
28
28
  * @see https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
29
29
  */
30
- type WatchCallbackParams<T, P extends keyof T> = P extends unknown
31
- ? [name: P, oldValue: T[P], newValue: T[P]]
32
- : never
33
- ;
30
+ type WatchCallbackParams<T, P extends keyof T> = P extends unknown ? [name: P, oldValue: T[P], newValue: T[P]] : never;
34
31
 
35
32
  type Stateful<T> = T & {
36
- watch: <Prop extends keyof T | '*'>(
33
+ watch: <Prop extends keyof T | "*">(
37
34
  property: Prop,
38
- handler: (...args: WatchCallbackParams<T, Prop extends '*' ? keyof T : Prop>) => void
39
- ) => void
35
+ handler: (...args: WatchCallbackParams<T, Prop extends "*" ? keyof T : Prop>) => void
36
+ ) => void;
40
37
 
41
- set: <Prop extends keyof T>(
42
- property: Prop,
43
- value: T[Prop]
44
- ) => void
38
+ set: <Prop extends keyof T>(property: Prop, value: T[Prop]) => void;
45
39
 
46
- get: <Prop extends keyof T>(
47
- property: Prop
48
- ) => T[Prop]
40
+ get: <Prop extends keyof T>(property: Prop) => T[Prop];
49
41
  };
50
42
 
51
43
  /** Placeholder type for parameters to all the Evented functions. */
52
- type Event = unknown;
44
+ type UnknownEvent = unknown;
53
45
 
54
46
  /** Utility type for all the handler functions in Tool. */
55
- type HandlerFn<This, Event, Result> = ((this: This, event: Event) => Result) | undefined;
47
+ type HandlerFn<This, Event, Result = void> = ((this: This, event: Event) => Result) | undefined;
48
+
49
+ type TooltipPosition = "above" | "below" | "after" | "before";
56
50
 
57
51
  /** A partial copy of the declaration in ct/tools/Tool adapted for TypeScript. The types are mostly educated guesses. */
58
52
  interface ToolProperties {
59
53
  /**
60
54
  * Given tool id.
61
55
  */
62
- id: string
56
+ id: string;
63
57
  /**
64
58
  * The title of the tool.
65
59
  */
66
- title: string | undefined
60
+ title: string | undefined;
67
61
  /**
68
62
  * A description of the tool.
69
63
  */
70
- description: string | undefined
64
+ description: string | undefined;
71
65
  /**
72
66
  * A tool tip.
73
67
  */
74
- tooltip: string | undefined
68
+ tooltip: string | undefined;
75
69
  /**
76
70
  * The tooltip positions.
77
71
  * e.g. ["above","below","after","before"]
78
72
  */
79
- tooltipPositions: ("above" | "below" | "after" | "before")[] | undefined
73
+ tooltipPositions: TooltipPosition[] | undefined;
80
74
  /**
81
75
  * Priority is used to ensure an ordering of tools.
82
76
  * Tools with high priority are first, equal priority means sort by id.
83
77
  */
84
- priority: number
78
+ priority: number;
85
79
  /**
86
80
  * A tool group this information is also added as css class to the root node of the created button or menu.
87
81
  */
88
- toolGroup: string
82
+ toolGroup: string;
89
83
  /**
90
84
  * A tool class appended to the root node of the created button or menu.
91
85
  * Note that ctTool_${id} is always added
92
86
  */
93
- toolClass: string
87
+ toolClass: string;
94
88
  /**
95
89
  * A tool icon class appended to the icon node of the created button or menu.
96
90
  * Note that ctToolIcon_${id} is always added
97
91
  */
98
- iconClass: string
92
+ iconClass: string;
99
93
  /**
100
94
  * The visible state of the tool.
101
95
  * On change the onShow/onHide events are fired.
102
96
  */
103
- visibility: boolean
97
+ visibility: boolean;
104
98
  /**
105
99
  * The enabled state of the tool.
106
100
  * On change the onDisabled, onEnabled events are fired.
107
101
  */
108
- enabled: boolean
102
+ enabled: boolean;
109
103
  /**
110
104
  * The active state of the tool, this is only of interest if the tool is togglable.
111
105
  * On change the onActivate, onDeactivate events are fired.
112
106
  */
113
- active: boolean
107
+ active: boolean;
114
108
  /**
115
109
  * The togglable state of the tool, this marks that the tool can be toggled.
116
110
  * It should be set in the constructor and the state value should never dynamically change.
117
111
  */
118
- togglable: boolean
112
+ togglable: boolean;
119
113
  /**
120
114
  * The processing state of the tool, this marks that the tool is currently processing something.
121
115
  * The state is toggled by the fireProcess* methods and independent from any other state of the tool.
122
116
  */
123
- processing: boolean
117
+ processing: boolean;
124
118
  /**
125
119
  * The self reference. Please see the ToolReference class to note that this property allows
126
120
  * to handle a tool like a tool reference, which makes code expecting references to be used with tools directly.
127
121
  */
128
- tool: Tool
122
+ tool: Tool;
129
123
  /**
130
124
  * Flag auto disables the tool if it becomes hidden.
131
125
  * default: true.
132
126
  */
133
- disableOnHide: boolean
127
+ disableOnHide: boolean;
134
128
  /**
135
129
  * Flag auto enables the tool if it becomes visible.
136
130
  * default: true.
137
131
  */
138
- enableOnShow: boolean
132
+ enableOnShow: boolean;
139
133
  /**
140
134
  * Flag auto deactivates the tool if it is disabled.
141
135
  * default: true.
142
136
  */
143
- deactivateOnDisable: boolean
137
+ deactivateOnDisable: boolean;
144
138
  /**
145
139
  * Flag auto activates the tool if it is enabled.
146
140
  * default: false.
147
141
  */
148
- activateOnEnable: boolean
142
+ activateOnEnable: boolean;
149
143
  /**
150
144
  * Flag auto enables the tool if set("active",true) is called.
151
145
  */
152
- enableOnActivate: boolean
146
+ enableOnActivate: boolean;
153
147
  /**
154
148
  * The scope of the default handler functions.
155
149
  */
156
- handlerScope: object | null
150
+ handlerScope: object | null;
157
151
  /**
158
152
  * The handler function called if the tool is clicked.
159
153
  */
160
- clickHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
154
+ clickHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
161
155
  /**
162
156
  * The handler function called if the tool is double clicked.
163
157
  */
164
- dblClickHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
158
+ dblClickHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
165
159
  /**
166
160
  * The handler function called before the onActivate event is fired.
167
161
  */
168
- beforeActivateHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
162
+ beforeActivateHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
169
163
  /**
170
164
  * The handler function called if the tool is activated.
171
165
  */
172
- activateHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
166
+ activateHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
173
167
  /**
174
168
  * The handler function called before the onDeactivate event is fired.
175
169
  */
176
- beforeDeactivateHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
170
+ beforeDeactivateHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
177
171
  /**
178
172
  * The handler function called if the tool is deactivated.
179
173
  */
180
- deactivateHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
174
+ deactivateHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
181
175
  /**
182
176
  * The handler function called if the tool becomes enabled.
183
177
  */
184
- enabledHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
178
+ enabledHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
185
179
  /**
186
180
  * The handler function called if the tool becomes disabled.
187
181
  */
188
- disabledHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
182
+ disabledHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
189
183
  /**
190
184
  * The handler function called if the tool becomes visible.
191
185
  */
192
- showHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
186
+ showHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
193
187
  /**
194
188
  * The handler function called if the tool becomes hidden.
195
189
  */
196
- hideHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
190
+ hideHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
197
191
  /**
198
192
  * The handler function called if the tool starts a processing task.
199
193
  */
200
- processStartHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
194
+ processStartHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
201
195
  /**
202
196
  * The handler function called if the tool ends a processing task.
203
197
  */
204
- processEndHandler: HandlerFn<ToolProperties["handlerScope"], Event, void>
198
+ processEndHandler: HandlerFn<ToolProperties["handlerScope"], UnknownEvent>;
205
199
  /**
206
200
  * Rules flag read by the toolrules bundle (optional).
207
201
  */
208
- rules: object | null
202
+ rules: object | null;
209
203
  /**
210
204
  * The handler function called to check a condition before activating a togglable tool.
211
205
  * The function has to return true if condition is fulfilled and false if not.
212
206
  */
213
- activationConditionHandler: HandlerFn<ToolProperties["activationConditionHandlerScope"] | Tool, Event, boolean>
207
+ activationConditionHandler: HandlerFn<
208
+ ToolProperties["activationConditionHandlerScope"] | Tool,
209
+ UnknownEvent,
210
+ boolean
211
+ >;
214
212
  /**
215
213
  * The scope of the activation condition handler function.
216
214
  */
217
- activationConditionHandlerScope: object | null
215
+ activationConditionHandlerScope: object | null;
218
216
  /**
219
217
  * If true real click,check/uncheck,dblclick events are delegated async into the tool model,
220
218
  * so that the browser event flow is not broken.
221
219
  */
222
- async: boolean
220
+ async: boolean;
223
221
  /**
224
222
  * Simulates a click on the tool.
225
223
  * Please note that this does not change the active state.
226
224
  * A client have to call set("active",true|false) to change the state.
227
225
  */
228
- click(evt: Event): void;
226
+ click(evt: UnknownEvent): void;
229
227
  /**
230
228
  * Simulates a dbl click on the tool.
231
229
  */
232
- dblClick(evt: Event): void;
230
+ dblClick(evt: UnknownEvent): void;
233
231
  /**
234
232
  * Sends a info message to the tool. It simple fires the onInfoMessage() event.
235
233
  * Such a message is normally produced in the backend, to indicate a "please click me" state on the tool.
@@ -238,59 +236,59 @@ interface ToolProperties {
238
236
  /**
239
237
  * The onClick event
240
238
  */
241
- onClick(event: Event): void;
239
+ onClick(event: UnknownEvent): void;
242
240
  /**
243
241
  * The onDoubleClick event
244
242
  **/
245
- onDblClick(event: Event): void;
243
+ onDblClick(event: UnknownEvent): void;
246
244
  /**
247
245
  * The onInfoMessage event, transports a message from the backend to the tool widget.
248
246
  **/
249
- onInfoMessage(event: Event): void;
247
+ onInfoMessage(event: UnknownEvent): void;
250
248
  /**
251
249
  * The onBeforeActivate event, it is called short before onActivate.
252
250
  **/
253
- onBeforeActivate(event: Event): void;
251
+ onBeforeActivate(event: UnknownEvent): void;
254
252
  /**
255
253
  * The onActivate event
256
254
  **/
257
- onActivate(event: Event): void;
255
+ onActivate(event: UnknownEvent): void;
258
256
  /**
259
257
  * The onDeactivate event
260
258
  **/
261
- onDeactivate(event: Event): void;
259
+ onDeactivate(event: UnknownEvent): void;
262
260
  /**
263
261
  * The onBeforeDeactivate event, it is called short before onDeactivate.
264
262
  **/
265
- onBeforeDeactivate(event: Event): void;
263
+ onBeforeDeactivate(event: UnknownEvent): void;
266
264
  /**
267
265
  * The onEnabled event, if the tool becomes enabled (available for pressing)
268
266
  **/
269
- onEnabled(event: Event): void;
267
+ onEnabled(event: UnknownEvent): void;
270
268
  /**
271
269
  * The onDisabled event, if the tool becomes disabled (not available for pressing)
272
270
  **/
273
- onDisabled(event: Event): void;
271
+ onDisabled(event: UnknownEvent): void;
274
272
  /**
275
273
  * The onShow event, if the tool becomes visible (allowed to show on screen)
276
274
  **/
277
- onShow(event: Event): void;
275
+ onShow(event: UnknownEvent): void;
278
276
  /**
279
277
  * The onHide event, if the tool becomes hidden (not allowed to show on screen)
280
278
  **/
281
- onHide(event: Event): void;
279
+ onHide(event: UnknownEvent): void;
282
280
  /**
283
281
  * `onProcessStart` is called when an external process is started
284
282
  */
285
- onProcessStart(event: Event): void;
283
+ onProcessStart(event: UnknownEvent): void;
286
284
  /**
287
285
  * `onProcessEnd` is called when an external process is stopped
288
286
  */
289
- onProcessEnd(event: Event): void;
287
+ onProcessEnd(event: UnknownEvent): void;
290
288
  }
291
289
 
292
290
  interface ToolConstructor {
293
- new(props?: Partial<ToolProperties>): Tool;
291
+ new (props?: Partial<ToolProperties>): Tool;
294
292
  }
295
293
 
296
294
  type Tool = Stateful<ToolProperties>;
@@ -300,3 +298,4 @@ type Tool = Stateful<ToolProperties>;
300
298
  declare const Tool: ToolConstructor;
301
299
 
302
300
  export { Tool as default };
301
+ export type { TooltipPosition };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conterra/ct-mapapps-typings",
3
- "version": "4.19.2-next.20250402042452",
3
+ "version": "4.19.2-next.20250403042107",
4
4
  "description": "TypeDefinitions for ct-mapapps",
5
5
  "author": "conterra",
6
6
  "license": "Apache-2.0"