@nebula.js/stardust 2.3.1 → 2.4.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.
@@ -0,0 +1,698 @@
1
+ // File generated automatically by "@scriptappy/to-dts"; DO NOT EDIT.
2
+ /// <reference types="qlik-engineapi" />
3
+ /**
4
+ * Initiates a new `Embed` instance using the specified enigma `app`.
5
+ * @param app
6
+ * @param instanceConfig
7
+ */
8
+ export function embed(app: EngineAPI.IApp, instanceConfig?: stardust.Configuration): stardust.Embed;
9
+
10
+ export namespace embed {
11
+ /**
12
+ * Creates a new `embed` scope bound to the specified `configuration`.
13
+ *
14
+ * The configuration is merged with all previous scopes.
15
+ * @param configuration The configuration object
16
+ */
17
+ function createConfiguration(configuration: stardust.Configuration): typeof embed;
18
+
19
+ }
20
+
21
+ /**
22
+ * Creates a stateful value.
23
+ * @param initialState The initial state.
24
+ */
25
+ export function useState<S>(initialState: S | (()=>S)): [S, stardust.SetStateFn<S>];
26
+
27
+ /**
28
+ * Triggers a callback function when a dependent value changes.
29
+ * @param effect The callback.
30
+ * @param deps The dependencies that should trigger the callback.
31
+ */
32
+ export function useEffect(effect: stardust.EffectCallback, deps?: any[]): void;
33
+
34
+ /**
35
+ * Creates a stateful value when a dependent changes.
36
+ * @param factory The factory function.
37
+ * @param deps The dependencies.
38
+ */
39
+ export function useMemo<T>(factory: ()=>T, deps: any[]): T;
40
+
41
+ /**
42
+ * Runs a callback function when a dependent changes.
43
+ * @param factory The factory function that calls the promise.
44
+ * @param deps The dependencies.
45
+ */
46
+ export function usePromise<P>(factory: ()=>Promise<P>, deps?: any[]): [P, Error];
47
+
48
+ /**
49
+ * Gets the HTMLElement this visualization is rendered into.
50
+ */
51
+ export function useElement(): HTMLElement;
52
+
53
+ /**
54
+ * Gets the size of the HTMLElement the visualization is rendered into.
55
+ */
56
+ export function useRect(): stardust.Rect;
57
+
58
+ /**
59
+ * Gets the layout of the generic object associated with this visualization.
60
+ */
61
+ export function useLayout(): EngineAPI.IGenericObjectLayout;
62
+
63
+ /**
64
+ * Gets the layout of the generic object associated with this visualization.
65
+ *
66
+ * Unlike the regular layout, a _stale_ layout is not changed when a generic object enters
67
+ * the modal state. This is mostly notable in that `qSelectionInfo.qInSelections` in the layout is
68
+ * always `false`.
69
+ * The returned value from `useStaleLayout()` and `useLayout()` are identical when the object
70
+ * is not in a modal state.
71
+ */
72
+ export function useStaleLayout(): EngineAPI.IGenericObjectLayout;
73
+
74
+ /**
75
+ * Gets the layout of the app associated with this visualization.
76
+ */
77
+ export function useAppLayout(): EngineAPI.INxAppLayout;
78
+
79
+ /**
80
+ * Gets the generic object API of the generic object connected to this visualization.
81
+ */
82
+ export function useModel(): EngineAPI.IGenericObject | undefined;
83
+
84
+ /**
85
+ * Gets the doc API.
86
+ */
87
+ export function useApp(): EngineAPI.IApp | undefined;
88
+
89
+ /**
90
+ * Gets the global API.
91
+ */
92
+ export function useGlobal(): EngineAPI.IGlobal | undefined;
93
+
94
+ /**
95
+ * Gets the object selections.
96
+ */
97
+ export function useSelections(): stardust.ObjectSelections;
98
+
99
+ /**
100
+ * Gets the theme.
101
+ */
102
+ export function useTheme(): stardust.Theme;
103
+
104
+ /**
105
+ * Gets the embed instance used.
106
+ */
107
+ export function useEmbed(): stardust.Embed;
108
+
109
+ /**
110
+ * Gets the translator.
111
+ */
112
+ export function useTranslator(): stardust.Translator;
113
+
114
+ /**
115
+ * Gets the device type. ('touch' or 'desktop')
116
+ */
117
+ export function useDeviceType(): string;
118
+
119
+ /**
120
+ * Gets the array of plugins provided when rendering the visualization.
121
+ */
122
+ export function usePlugins(): stardust.Plugin[];
123
+
124
+ /**
125
+ * Registers a custom action.
126
+ * @param factory
127
+ * @param deps
128
+ */
129
+ export function useAction<A>(factory: ()=>stardust.ActionDefinition<A>, deps?: any[]): A;
130
+
131
+ /**
132
+ * Gets the desired constraints that should be applied when rendering the visualization.
133
+ *
134
+ * The constraints are set on the embed configuration before the visualization is rendered
135
+ * and should respected by you when implementing the visualization.
136
+ */
137
+ export function useConstraints(): stardust.Constraints;
138
+
139
+ /**
140
+ * Gets the options object provided when rendering the visualization.
141
+ *
142
+ * This is an empty object by default but enables customization of the visualization through this object.
143
+ * Options are different from setting properties on the generic object in that options
144
+ * are only temporary settings applied to the visualization when rendered.
145
+ *
146
+ * You have the responsibility to provide documentation of the options you support, if any.
147
+ */
148
+ export function useOptions(): object;
149
+
150
+ /**
151
+ * Registers a callback that is called when a snapshot is taken.
152
+ * @param snapshotCallback
153
+ */
154
+ export function onTakeSnapshot(snapshotCallback: ($: EngineAPI.IGenericObjectLayout)=>Promise<EngineAPI.IGenericObjectLayout>): void;
155
+
156
+ /**
157
+ * Gets render state instance.
158
+ *
159
+ * Used to update properties and get a new layout without triggering onInitialRender.
160
+ */
161
+ export function useRenderState(): stardust.RenderState;
162
+
163
+ /**
164
+ * Gets the desired keyboard settings and status to applied when rendering the visualization.
165
+ * A visualization should in general only have tab stops if either `keyboard.enabled` is false or if active is true.
166
+ * This means that either Nebula isn't configured to handle keyboard input or the chart is currently focused.
167
+ * Enabling or disabling keyboardNavigation are set on the embed configuration and
168
+ * should be respected by the visualization.
169
+ */
170
+ export function useKeyboard(): stardust.Keyboard;
171
+
172
+ declare namespace stardust {
173
+ interface Context {
174
+ keyboardNavigation?: boolean;
175
+ constraints?: {
176
+ active?: boolean;
177
+ passive?: boolean;
178
+ select?: boolean;
179
+ };
180
+ theme?: string;
181
+ language?: string;
182
+ deviceType?: string;
183
+ }
184
+
185
+ interface Configuration {
186
+ context?: stardust.Context;
187
+ types?: stardust.TypeInfo[];
188
+ themes?: stardust.ThemeInfo[];
189
+ anything?: object;
190
+ }
191
+
192
+ interface Galaxy {
193
+ translator: stardust.Translator;
194
+ flags: stardust.Flags;
195
+ deviceType: string;
196
+ anything: object;
197
+ }
198
+
199
+ class Embed {
200
+ constructor();
201
+
202
+ /**
203
+ * Renders a visualization into an HTMLElement.
204
+ * @param cfg The render configuration.
205
+ */
206
+ render(cfg: stardust.CreateConfig | stardust.GetConfig): Promise<stardust.Viz>;
207
+
208
+ /**
209
+ * Updates the current context of this embed instance.
210
+ * Use this when you want to change some part of the current context, like theme.
211
+ * @param ctx The context to update.
212
+ */
213
+ context(ctx: stardust.Context): Promise<undefined>;
214
+
215
+ /**
216
+ * Gets the app selections of this instance.
217
+ */
218
+ selections(): Promise<stardust.AppSelections>;
219
+
220
+ /**
221
+ * Gets the listbox instance of the specified field
222
+ * @param fieldIdentifier Fieldname as a string or a Library dimension
223
+ */
224
+ field(fieldIdentifier: string | stardust.LibraryField): Promise<stardust.FieldInstance>;
225
+
226
+ /**
227
+ * Gets a list of registered visualization types and versions
228
+ */
229
+ getRegisteredTypes(): Object[];
230
+
231
+ }
232
+
233
+ /**
234
+ * A callback function which receives another function as input.
235
+ */
236
+ type ReceiverFunction = ($: ()=>void)=>void;
237
+
238
+ class FieldInstance {
239
+ constructor();
240
+
241
+ /**
242
+ * Mounts the field as a listbox into the provided HTMLElement.
243
+ * @param element
244
+ * @param options Settings for the embedded listbox
245
+ */
246
+ static mount(element: HTMLElement, options?: {
247
+ title?: string;
248
+ direction?: string;
249
+ listLayout?: string;
250
+ search?: boolean;
251
+ toolbar?: boolean;
252
+ stateName?: boolean;
253
+ properties?: object;
254
+ sessionModel?: object;
255
+ selectionsApi?: object;
256
+ update?: stardust.ReceiverFunction;
257
+ }): void;
258
+
259
+ /**
260
+ * Unmounts the field listbox from the DOM.
261
+ */
262
+ static unmount(): void;
263
+
264
+ }
265
+
266
+ type ThemeJSON = any;
267
+
268
+ interface ThemeInfo {
269
+ id: string;
270
+ /**
271
+ * A function that should return a Promise that resolves to a raw JSON theme.
272
+ */
273
+ load(): Promise<stardust.ThemeJSON>;
274
+ }
275
+
276
+ /**
277
+ * A controller to further modify a visualization after it has been rendered.
278
+ */
279
+ class Viz {
280
+ constructor();
281
+
282
+ id: string;
283
+
284
+ /**
285
+ * Destroys the visualization and removes it from the the DOM.
286
+ */
287
+ destroy(): void;
288
+
289
+ /**
290
+ * Converts the visualization to a different registered type
291
+ * @param newType Which registered type to convert to.
292
+ * @param forceUpdate Whether to run setProperties or not, defaults to true.
293
+ */
294
+ convertTo(newType: string, forceUpdate?: boolean): Promise<object>;
295
+
296
+ }
297
+
298
+ interface Flags {
299
+ /**
300
+ * Checks whether the specified flag is enabled.
301
+ * @param flag The value flag to check.
302
+ */
303
+ isEnabled(flag: string): boolean;
304
+ }
305
+
306
+ class AppSelections {
307
+ constructor();
308
+
309
+ /**
310
+ * Mounts the app selection UI into the provided HTMLElement.
311
+ * @param element
312
+ */
313
+ mount(element: HTMLElement): void;
314
+
315
+ /**
316
+ * Unmounts the app selection UI from the DOM.
317
+ */
318
+ unmount(): void;
319
+
320
+ }
321
+
322
+ class ObjectSelections {
323
+ constructor();
324
+
325
+ /**
326
+ * @param paths
327
+ */
328
+ begin(paths: string[]): Promise<undefined>;
329
+
330
+ clear(): Promise<undefined>;
331
+
332
+ confirm(): Promise<undefined>;
333
+
334
+ cancel(): Promise<undefined>;
335
+
336
+ /**
337
+ * @param s
338
+ */
339
+ select(s: {
340
+ method: string;
341
+ params: any[];
342
+ }): Promise<boolean>;
343
+
344
+ canClear(): boolean;
345
+
346
+ canConfirm(): boolean;
347
+
348
+ canCancel(): boolean;
349
+
350
+ isActive(): boolean;
351
+
352
+ isModal(): boolean;
353
+
354
+ /**
355
+ * @param paths
356
+ */
357
+ goModal(paths: string[]): Promise<undefined>;
358
+
359
+ /**
360
+ * @param accept
361
+ */
362
+ noModal(accept?: boolean): Promise<undefined>;
363
+
364
+ }
365
+
366
+ type Field = string | EngineAPI.INxDimension | EngineAPI.INxMeasure | stardust.LibraryField;
367
+
368
+ /**
369
+ * Rendering configuration for creating and rendering a new object
370
+ */
371
+ interface CreateConfig extends stardust.BaseConfig{
372
+ type: string;
373
+ version: string;
374
+ fields?: stardust.Field[];
375
+ properties?: EngineAPI.IGenericObjectProperties;
376
+ }
377
+
378
+ /**
379
+ * Basic rendering configuration for rendering an object
380
+ */
381
+ interface BaseConfig {
382
+ element: HTMLElement;
383
+ options?: object;
384
+ plugins?: stardust.Plugin[];
385
+ }
386
+
387
+ /**
388
+ * Rendering configuration for rendering an existing object
389
+ */
390
+ interface GetConfig extends stardust.BaseConfig{
391
+ id: string;
392
+ }
393
+
394
+ interface LibraryField {
395
+ qLibraryId: string;
396
+ type: "dimension" | "measure";
397
+ }
398
+
399
+ /**
400
+ * An object literal containing meta information about the plugin and a function containing the plugin implementation.
401
+ */
402
+ interface Plugin {
403
+ info: {
404
+ name: string;
405
+ };
406
+ fn: ()=>void;
407
+ }
408
+
409
+ interface LoadType {
410
+ (type: {
411
+ name: string;
412
+ version: string;
413
+ }): Promise<stardust.Visualization>;
414
+ }
415
+
416
+ interface TypeInfo {
417
+ name: string;
418
+ version: string;
419
+ load: stardust.LoadType;
420
+ meta?: object;
421
+ }
422
+
423
+ type MinMaxResult = {
424
+ };
425
+
426
+ /**
427
+ * Returns the min and max indices of elemNumbersOrdered which contains
428
+ * all numbers in elementNbrs.
429
+ */
430
+ type getMinMax = (elementNbrs: number[], elemNumbersOrdered: number[])=>stardust.MinMaxResult;
431
+
432
+ interface ActionToolbarElement extends HTMLElement{
433
+ className: "njs-action-toolbar-popover";
434
+ }
435
+
436
+ interface ActionElement extends HTMLElement{
437
+ className: "njs-cell-action";
438
+ }
439
+
440
+ interface CellElement extends HTMLElement{
441
+ className: "njs-cell";
442
+ }
443
+
444
+ interface CellFooter extends HTMLElement{
445
+ className: "njs-cell-footer";
446
+ }
447
+
448
+ interface CellTitle extends HTMLElement{
449
+ className: "njs-cell-title";
450
+ }
451
+
452
+ interface CellSubTitle extends HTMLElement{
453
+ className: "njs-cell-sub-title";
454
+ }
455
+
456
+ interface VizElementAttributes extends NamedNodeMap{
457
+ "data-render-count": string;
458
+ }
459
+
460
+ interface VizElement extends HTMLElement{
461
+ attributes: stardust.VizElementAttributes;
462
+ className: "njs-viz";
463
+ }
464
+
465
+ /**
466
+ * The entry point for defining a visualization.
467
+ */
468
+ interface Visualization {
469
+ (galaxy: stardust.Galaxy): stardust.VisualizationDefinition;
470
+ }
471
+
472
+ interface VisualizationDefinition {
473
+ qae: stardust.QAEDefinition;
474
+ component(): void;
475
+ }
476
+
477
+ interface SetStateFn<S> {
478
+ (newState: S | (($: S)=>S)): void;
479
+ }
480
+
481
+ type EffectCallback = ()=>void | (()=>void);
482
+
483
+ interface Rect {
484
+ top: number;
485
+ left: number;
486
+ width: number;
487
+ height: number;
488
+ }
489
+
490
+ interface ActionDefinition<A> {
491
+ action: A;
492
+ hidden?: boolean;
493
+ disabled?: boolean;
494
+ icon?: {
495
+ viewBox?: string;
496
+ shapes: {
497
+ }[];
498
+ };
499
+ }
500
+
501
+ interface Constraints {
502
+ passive?: boolean;
503
+ active?: boolean;
504
+ select?: boolean;
505
+ }
506
+
507
+ interface RenderState {
508
+ pending: any;
509
+ restore: any;
510
+ }
511
+
512
+ interface Keyboard {
513
+ enabled: boolean;
514
+ active: boolean;
515
+ /**
516
+ * Function used by the visualization to tell Nebula to it wants to relinquish focus
517
+ */
518
+ blur?(): void;
519
+ /**
520
+ * Function used by the visualization to tell Nebula to it wants focus
521
+ */
522
+ focus?(): void;
523
+ /**
524
+ * Function used by the visualization to tell Nebula to focus the selection toolbar
525
+ */
526
+ focusSelection?(): void;
527
+ }
528
+
529
+ /**
530
+ * Imports properties for a chart with a hypercube.
531
+ */
532
+ type importProperties = (args: {
533
+ exportFormat: stardust.ExportFormat;
534
+ initialProperties?: Object;
535
+ dataDefinition?: Object;
536
+ defaultPropertyValues?: Object;
537
+ hypercubePath: string;
538
+ })=>Object;
539
+
540
+ /**
541
+ * Exports properties for a chart with a hypercube.
542
+ */
543
+ type exportProperties = (args: {
544
+ propertyTree: Object;
545
+ hypercubePath: string;
546
+ })=>stardust.ExportFormat;
547
+
548
+ interface QAEDefinition {
549
+ properties?: EngineAPI.IGenericObjectProperties;
550
+ data?: {
551
+ targets: stardust.DataTarget[];
552
+ };
553
+ importProperties?: stardust.importProperties;
554
+ exportProperties?: stardust.exportProperties;
555
+ }
556
+
557
+ interface DataTarget {
558
+ path: string;
559
+ dimensions?: stardust.FieldTarget<EngineAPI.INxDimension>;
560
+ measures?: stardust.FieldTarget<EngineAPI.INxMeasure>;
561
+ }
562
+
563
+ type fieldTargetAddedCallback<T> = (field: T, properties: EngineAPI.IGenericObjectProperties)=>void;
564
+
565
+ type fieldTargetRemovedCallback<T> = (field: T, properties: EngineAPI.IGenericObjectProperties, index: number)=>void;
566
+
567
+ interface FieldTarget<T> {
568
+ min?(): number;
569
+ max?(): number;
570
+ added?: stardust.fieldTargetAddedCallback<T>;
571
+ removed?: stardust.fieldTargetRemovedCallback<T>;
572
+ }
573
+
574
+ class Translator {
575
+ constructor();
576
+
577
+ /**
578
+ * Registers a string in multiple locales
579
+ * @param item
580
+ */
581
+ add(item: {
582
+ id: string;
583
+ locale: object;
584
+ }): void;
585
+
586
+ /**
587
+ * Translates a string for current locale.
588
+ * @param str ID of the registered string.
589
+ * @param args Values passed down for string interpolation.
590
+ */
591
+ get(str: string, args?: string[]): string;
592
+
593
+ }
594
+
595
+ class Theme {
596
+ constructor();
597
+
598
+ getDataColorScales(): stardust.Theme.ScalePalette[];
599
+
600
+ getDataColorPalettes(): stardust.Theme.DataPalette[];
601
+
602
+ getDataColorPickerPalettes(): stardust.Theme.ColorPickerPalette[];
603
+
604
+ getDataColorSpecials(): stardust.Theme.DataColorSpecials;
605
+
606
+ /**
607
+ * Resolve a color object using the color picker palette from the provided JSON theme.
608
+ * @param c
609
+ */
610
+ getColorPickerColor(c: {
611
+ index?: number;
612
+ color?: string;
613
+ }): string;
614
+
615
+ /**
616
+ * Get the best contrasting color against the specified `color`.
617
+ * This is typically used to find a suitable text color for a label placed on an arbitrarily colored background.
618
+ *
619
+ * The returned colors are derived from the theme.
620
+ * @param color A color to measure the contrast against
621
+ */
622
+ getContrastingColorTo(color: string): string;
623
+
624
+ /**
625
+ * Get the value of a style attribute in the theme by searching in the theme's JSON structure.
626
+ * The search starts at the specified base path and continues upwards until the value is found.
627
+ * If possible it will get the attribute's value using the given path.
628
+ * @param basePath Base path in the theme's JSON structure to start the search in (specified as a name path separated by dots).
629
+ * @param path Expected path for the attribute (specified as a name path separated by dots).
630
+ * @param attribute Name of the style attribute.
631
+ */
632
+ getStyle(basePath: string, path: string, attribute: string): string;
633
+
634
+ }
635
+
636
+ namespace Theme {
637
+ interface ScalePalette {
638
+ key: string;
639
+ type: "gradient" | "class-pyramid";
640
+ colors: string[] | (string[])[];
641
+ }
642
+
643
+ interface DataPalette {
644
+ key: string;
645
+ type: "pyramid" | "row";
646
+ colors: string[] | (string[])[];
647
+ }
648
+
649
+ interface ColorPickerPalette {
650
+ key: string;
651
+ colors: string[];
652
+ }
653
+
654
+ interface DataColorSpecials {
655
+ primary: string;
656
+ nil: string;
657
+ others: string;
658
+ }
659
+
660
+ }
661
+
662
+ /**
663
+ * Used for exporting and importing properties between backend models. An object that exports to
664
+ * ExportFormat should put dimensions and measures inside one data group. If an object has two hypercubes,
665
+ * each of the cubes should export dimensions and measures in two separate data groups.
666
+ * An object that imports from this structure is responsible for putting the existing properties where they should be
667
+ * in the new model.
668
+ */
669
+ interface ExportFormat {
670
+ data?: stardust.ExportDataDef[];
671
+ properties?: object;
672
+ }
673
+
674
+ interface ExportDataDef {
675
+ dimensions: EngineAPI.INxDimension[];
676
+ measures: EngineAPI.INxMeasure[];
677
+ excludedDimensions: EngineAPI.INxDimension[];
678
+ excludedMeasures: EngineAPI.INxMeasure[];
679
+ interColumnSortOrder: number[];
680
+ }
681
+
682
+ interface ConversionType {
683
+ importProperties: stardust.importProperties;
684
+ exportProperties: stardust.exportProperties;
685
+ }
686
+
687
+ /**
688
+ * Provides conversion functionality to extensions.
689
+ */
690
+ interface Conversion {
691
+ hypercube: stardust.hyperCubeConversion;
692
+ }
693
+
694
+ interface hyperCubeConversion {
695
+ }
696
+
697
+ }
698
+