@esrf/daiquiri-lib 0.0.2-alpha.1 → 0.0.2-alpha.2

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.
@@ -0,0 +1,387 @@
1
+ /// <reference types="react" />
2
+ import * as react from 'react';
3
+ import { ReactElement, PropsWithChildren, ReactChild, ChangeEvent, KeyboardEvent } from 'react';
4
+
5
+ interface HardwareError {
6
+ property: string;
7
+ exception: string;
8
+ traceback: string;
9
+ }
10
+ interface HardwareSchemaDescription {
11
+ properties: {
12
+ additionalProperties?: boolean;
13
+ properties: {
14
+ [property: string]: any;
15
+ };
16
+ type: string;
17
+ uischema: {
18
+ position: [Record<string, unknown>];
19
+ };
20
+ uiorder?: string[];
21
+ };
22
+ callables: {
23
+ additionalProperties?: boolean;
24
+ properties: {
25
+ [property: string]: any;
26
+ };
27
+ type: string;
28
+ uischema: {
29
+ position: [Record<string, unknown>];
30
+ };
31
+ uiorder?: string[];
32
+ };
33
+ }
34
+ interface Hardware {
35
+ /** Object name */
36
+ name: string;
37
+ /** Object id */
38
+ id: string;
39
+ /** An optional object alias */
40
+ alias: string | null;
41
+ /** The object properties as defined in the relevant schema */
42
+ properties: {
43
+ [name: string]: any;
44
+ };
45
+ /** Whether the device is available */
46
+ online: boolean;
47
+ /** The object type as defined by the REST API */
48
+ type: string;
49
+ /** Any potential errors initialising this object */
50
+ errors?: HardwareError[];
51
+ }
52
+ interface HardwareChangeAction {
53
+ property?: string;
54
+ function?: string;
55
+ value?: any;
56
+ }
57
+ declare type HardwareChangeHandler = (action: HardwareChangeAction) => Promise<void> | null;
58
+ /**
59
+ * Common options exposed to user as yaml configuration for hardware widgets
60
+ */
61
+ interface HardwareWidgetOptions {
62
+ /** Whether to show the extended popup */
63
+ extended?: boolean;
64
+ /** Kind of header displayed */
65
+ header?: string;
66
+ }
67
+ declare type EditableHardware<H extends Hardware = Hardware> = H & {
68
+ /** Call the API to make a change on the hardware object */
69
+ requestChange: HardwareChangeHandler;
70
+ };
71
+ /**
72
+ * Properties which are passed to the widgets
73
+ */
74
+ interface HardwareWidgetProps<H extends Hardware = Hardware, O extends HardwareWidgetOptions = HardwareWidgetOptions> {
75
+ /** Dynamic state of the hardware */
76
+ hardware: EditableHardware<H>;
77
+ /** Static schema describing the hardware */
78
+ schema: HardwareSchemaDescription;
79
+ /** Options passed to the widget by the yaml configuration */
80
+ options: O;
81
+ /** Add temporary message on the Daiquiri top level interface */
82
+ addToast: (props: {
83
+ type: string;
84
+ title: string;
85
+ text: string;
86
+ }) => void;
87
+ /** Global state of the widget (aggregating scan/operator/hardware states) */
88
+ disabled: boolean;
89
+ /** True if the session have the control */
90
+ operator: boolean;
91
+ }
92
+
93
+ type types_d_EditableHardware<H extends Hardware = Hardware> = EditableHardware<H>;
94
+ type types_d_Hardware = Hardware;
95
+ type types_d_HardwareChangeAction = HardwareChangeAction;
96
+ type types_d_HardwareChangeHandler = HardwareChangeHandler;
97
+ type types_d_HardwareSchemaDescription = HardwareSchemaDescription;
98
+ type types_d_HardwareWidgetOptions = HardwareWidgetOptions;
99
+ type types_d_HardwareWidgetProps<H extends Hardware = Hardware, O extends HardwareWidgetOptions = HardwareWidgetOptions> = HardwareWidgetProps<H, O>;
100
+ declare namespace types_d {
101
+ export type { types_d_EditableHardware as EditableHardware, types_d_Hardware as Hardware, types_d_HardwareChangeAction as HardwareChangeAction, types_d_HardwareChangeHandler as HardwareChangeHandler, types_d_HardwareSchemaDescription as HardwareSchemaDescription, types_d_HardwareWidgetOptions as HardwareWidgetOptions, types_d_HardwareWidgetProps as HardwareWidgetProps };
102
+ }
103
+
104
+ interface GenericSchema extends Hardware {
105
+ properties: {
106
+ state: string;
107
+ };
108
+ }
109
+ interface MotorSchema extends Hardware {
110
+ properties: {
111
+ position: number;
112
+ target: number;
113
+ tolerance: number;
114
+ acceleration: number;
115
+ velocity: number;
116
+ limits: number[];
117
+ state: string[];
118
+ unit: string;
119
+ offset: number;
120
+ sign: number;
121
+ };
122
+ }
123
+ interface MultipositionSchema extends Hardware {
124
+ properties: {
125
+ position: string;
126
+ positions: {
127
+ position: string;
128
+ description: string;
129
+ target: {
130
+ axis: string;
131
+ destination: number;
132
+ tolerance: number;
133
+ }[];
134
+ }[];
135
+ state: string;
136
+ };
137
+ }
138
+ interface ShutterSchema extends Hardware {
139
+ properties: {
140
+ state: string;
141
+ status: string;
142
+ valid: boolean;
143
+ open_text: string;
144
+ closed_text: string;
145
+ };
146
+ }
147
+ interface FrontendSchema extends Hardware {
148
+ properties: {
149
+ state: string;
150
+ status: string;
151
+ automatic: boolean;
152
+ frontend: string;
153
+ current: number;
154
+ refill: number;
155
+ mode: string;
156
+ message: string;
157
+ feitlk: string;
158
+ pssitlk: string;
159
+ expitlk: string;
160
+ };
161
+ }
162
+
163
+ type schema_d_FrontendSchema = FrontendSchema;
164
+ type schema_d_GenericSchema = GenericSchema;
165
+ type schema_d_MotorSchema = MotorSchema;
166
+ type schema_d_MultipositionSchema = MultipositionSchema;
167
+ type schema_d_ShutterSchema = ShutterSchema;
168
+ declare namespace schema_d {
169
+ export type { schema_d_FrontendSchema as FrontendSchema, schema_d_GenericSchema as GenericSchema, schema_d_MotorSchema as MotorSchema, schema_d_MultipositionSchema as MultipositionSchema, schema_d_ShutterSchema as ShutterSchema };
170
+ }
171
+
172
+ declare function Frontend(props: HardwareWidgetProps<FrontendSchema>): JSX.Element;
173
+
174
+ interface InfoOptions extends HardwareWidgetOptions {
175
+ /** The property */
176
+ property?: string;
177
+ /** Unit for the property */
178
+ unit?: string;
179
+ }
180
+ declare function Info(props: HardwareWidgetProps<Hardware, InfoOptions>): JSX.Element;
181
+
182
+ interface MotorDefaultOptions extends HardwareWidgetOptions {
183
+ /** Default step size to use for up / down arrows */
184
+ step?: number;
185
+ /** Array of selectable step sizes */
186
+ steps?: number[];
187
+ /** Number of decimals to show */
188
+ precision?: number;
189
+ /** Whether to show popup to configure extended parameters */
190
+ extended?: boolean;
191
+ /** Whether this widget is read only */
192
+ readOnly?: boolean;
193
+ /** Kind of header displayed */
194
+ header?: string;
195
+ /** Specify a fontawesome to inc the value */
196
+ incicon?: string;
197
+ /** Specify a fontawesome to dec the value */
198
+ decicon?: string;
199
+ /** If true inc and dec icon are swapped */
200
+ swapincdec?: boolean;
201
+ /** Show the step arrows horizontally instead of vertically */
202
+ horizontalarrows?: boolean;
203
+ /** Show large step arrows */
204
+ largearrows?: boolean;
205
+ }
206
+ /**
207
+ * The default motor widget
208
+ */
209
+ declare function MotorDefault(props: HardwareWidgetProps<MotorSchema, MotorDefaultOptions>): JSX.Element;
210
+
211
+ declare function Multiposition(props: HardwareWidgetProps<MultipositionSchema>): JSX.Element;
212
+
213
+ interface NoObjectProps {
214
+ id: string;
215
+ name?: string;
216
+ options: {
217
+ header?: string;
218
+ emptyifnone?: boolean;
219
+ };
220
+ }
221
+ declare function NoObject(props: NoObjectProps): JSX.Element;
222
+
223
+ interface PropertyWidgetOptions extends HardwareWidgetOptions {
224
+ header?: string;
225
+ property?: string;
226
+ unit?: string;
227
+ }
228
+ declare function Property(props: HardwareWidgetProps<GenericSchema, PropertyWidgetOptions>): JSX.Element;
229
+
230
+ declare function ShutterDefault(props: HardwareWidgetProps<ShutterSchema, HardwareWidgetOptions>): JSX.Element;
231
+
232
+ interface Props$3 {
233
+ online: boolean;
234
+ activeMessage?: string;
235
+ inactiveMessage?: string;
236
+ message?: string;
237
+ icon: string;
238
+ name: string;
239
+ }
240
+ declare function TypeIcon(props: Props$3): JSX.Element;
241
+
242
+ interface Props$2 {
243
+ hardware: Hardware;
244
+ headerMode?: string;
245
+ widgetIcon: ReactElement;
246
+ widgetState: ReactElement;
247
+ widgetContent: ReactElement;
248
+ }
249
+ /**
250
+ * Normalized way to compose hardware component in order to provide the same
251
+ * kind of layout
252
+ */
253
+ declare function HardwareTemplate(props: Props$2): JSX.Element;
254
+
255
+ /**
256
+ * Input number synchronized with a hardware.
257
+ *
258
+ * Input related to hardware have specificities because the hardware state can
259
+ * change during the user interaction.
260
+ *
261
+ * TODO: Maybe normalize `precision` and `step` together
262
+ */
263
+ declare function HardwareInputNumber(props: {
264
+ hardwareValue: number;
265
+ hardwareIsDisabled: boolean;
266
+ hardwareIsMoving?: boolean;
267
+ hardwareIsReady?: boolean;
268
+ onMoveRequested: (value: number) => Promise<void> | null;
269
+ onAbortRequested?: () => void;
270
+ readOnly?: boolean;
271
+ precision?: number;
272
+ step?: number;
273
+ }): JSX.Element;
274
+
275
+ /**
276
+ * NumericStep handled hardware properties.
277
+ *
278
+ * Input related to hardware have specificities because the hardware state can
279
+ * change during the user interaction.
280
+ */
281
+ declare function HardwareNumericStep(props: {
282
+ hardwareValue: number | null;
283
+ hardwareIsDisabled: boolean;
284
+ hardwareIsMoving: boolean;
285
+ hardwareIsReady: boolean;
286
+ onMoveRequested: (value: number) => Promise<void> | null;
287
+ onAbortRequested: () => void;
288
+ /** Default step size to use for up / down arrows */
289
+ step?: number;
290
+ /** Array of selectable step sizes */
291
+ steps?: number[];
292
+ /** Number of decimals to show */
293
+ precision?: number;
294
+ /** Whether this widget is read only */
295
+ readOnly?: boolean;
296
+ /** Specify a fontawesome to inc the value */
297
+ incIcon?: string;
298
+ /** Specify a fontawesome to dec the value */
299
+ decIcon?: string;
300
+ /** If true inc and dec icon are swapped */
301
+ swapIncDec?: boolean;
302
+ /** Show the step arrows horizontally instead of vertically */
303
+ horizontalArrows?: boolean;
304
+ /** Show large step arrows */
305
+ largeArrows?: boolean;
306
+ /** Identifier passed to the input element */
307
+ id?: string;
308
+ }): JSX.Element;
309
+
310
+ /**
311
+ * Normalize the way to display an hardware state.
312
+ *
313
+ * If `minWidth` is pecified (in `em`) it ensure the widget width will stay the
314
+ * same when the state change
315
+ */
316
+ declare function HardwareState(props: {
317
+ state: string;
318
+ variant: string;
319
+ minWidth?: number;
320
+ }): JSX.Element;
321
+ declare function MotorState(props: {
322
+ hardware: MotorSchema;
323
+ }): JSX.Element;
324
+ declare function ShutterState(props: {
325
+ hardware: ShutterSchema;
326
+ useReadyState?: boolean;
327
+ }): JSX.Element;
328
+
329
+ declare const State_d_HardwareState: typeof HardwareState;
330
+ declare const State_d_MotorState: typeof MotorState;
331
+ declare const State_d_ShutterState: typeof ShutterState;
332
+ declare namespace State_d {
333
+ export { State_d_HardwareState as HardwareState, State_d_MotorState as MotorState, State_d_ShutterState as ShutterState };
334
+ }
335
+
336
+ declare function formatEng(scalar: number): {
337
+ scalar: number;
338
+ prefix: string;
339
+ multiplier: number;
340
+ };
341
+ /**
342
+ * Returns the argument as capitalized string.
343
+ */
344
+ declare function ucfirst(str: string): string;
345
+ declare function toHoursMins(seconds: number): string;
346
+ declare function toEnergy(wavelength: number): string | 0;
347
+ declare function round(value: number, digits: number): number;
348
+
349
+ declare const formatting_d_formatEng: typeof formatEng;
350
+ declare const formatting_d_round: typeof round;
351
+ declare const formatting_d_toEnergy: typeof toEnergy;
352
+ declare const formatting_d_toHoursMins: typeof toHoursMins;
353
+ declare const formatting_d_ucfirst: typeof ucfirst;
354
+ declare namespace formatting_d {
355
+ export { formatting_d_formatEng as formatEng, formatting_d_round as round, formatting_d_toEnergy as toEnergy, formatting_d_toHoursMins as toHoursMins, formatting_d_ucfirst as ucfirst };
356
+ }
357
+
358
+ interface Props$1 {
359
+ className?: string;
360
+ }
361
+ declare function FullSizer(props: PropsWithChildren<Props$1>): JSX.Element;
362
+
363
+ interface Props {
364
+ step?: number;
365
+ steps?: number[];
366
+ disabled: boolean;
367
+ id?: string;
368
+ unit?: string;
369
+ overlay?: ReactChild | null;
370
+ incIcon?: string;
371
+ decIcon?: string;
372
+ swapIncDec?: boolean;
373
+ className?: string;
374
+ type?: 'number' | 'text';
375
+ precision?: number;
376
+ horizontalArrows?: boolean;
377
+ largeArrows?: boolean;
378
+ onBlur: () => void;
379
+ onChange: (e: ChangeEvent<HTMLInputElement>) => void;
380
+ onStep: (params: {
381
+ target: HTMLInputElement;
382
+ }) => void;
383
+ onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;
384
+ }
385
+ declare const NumericStep: react.ForwardRefExoticComponent<Props & react.RefAttributes<HTMLInputElement>>;
386
+
387
+ export { formatting_d as Formatting, Frontend, FullSizer, HardwareInputNumber, HardwareNumericStep, schema_d as HardwareSchema, State_d as HardwareState, HardwareTemplate, types_d as HardwareTypes, Info, MotorDefault, type MotorDefaultOptions, Multiposition, NoObject, NumericStep, Property, ShutterDefault, TypeIcon };