@diamondlightsource/davidia 1.3.0-rc.1 → 1.3.1-rc.3

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 CHANGED
@@ -10,8 +10,6 @@ Currently, only React 18 is supported.
10
10
 
11
11
  ## Vite configuration
12
12
 
13
- Use `vite < 8` in your devDependencies.
14
-
15
13
  Some davidia dependencies require a global object to be defined when used in Vite applications. Add the following to your vite.config.ts:
16
14
 
17
15
  ```js
package/dist/index.css CHANGED
@@ -1,2 +1,2 @@
1
- ._top_cq7uz_1{grid-template-columns:70px 50px 100px 70px;display:grid}._error_cq7uz_6{color:red;flex-direction:row;align-items:center;padding-right:10px;display:flex}._label_cq7uz_14{flex-direction:row;align-items:center;display:flex}._modal_ftojl_1{z-index:1000;position:fixed;left:45%}._modal_content_ftojl_7{background-color:#fff;border:2px solid #ffffffe6;display:grid;box-shadow:0 0 0 1px #0000001a,0 4px 11px #0000001a}._modal_header_ftojl_16,._modal_footer_ftojl_17{padding:10px;position:relative}._modal_title_ftojl_22{margin:0}._modal_body_ftojl_26{border-top:1px solid gray;padding:10px;position:relative}._close_button_ftojl_32{position:absolute;top:1ex;right:1ex}._aspect_ftojl_38{justify-content:left;padding-top:10px;position:relative}._btn_ftojl_44{background-color:var(--h5w-toolbar--bgColor,aliceblue);cursor:pointer;box-shadow:-1px -1px 2px inset var(--h5w-btnRaised--shadowColor,gray);border-radius:.8rem;justify-content:center;padding:0 .5rem}._btn_ftojl_44:hover{background-color:var(--h5w-btn-hover--bgColor,whitesmoke)}._root_h18us_1{flex-direction:column;align-items:center;display:flex;position:relative}._sliderContainer_h18us_8{flex:1;margin-right:-.375rem;padding:0 .375rem;display:flex}._slider_h18us_8{cursor:pointer;--track-width:var(--h5w-domainSlider-track--width,8rem);--track-height:var(--h5w-domainSlider-track--height,.625rem);--thumb-size:calc(var(--track-height) * 2.5);--thumb-size-auto:calc(var(--thumb-size) * .9);margin-right:-.25rem;font-size:.75rem;display:flex}._tools_h18us_27{padding-bottom:2rem;padding-left:2rem;padding-right:2rem}._toolsInner_h18us_37{align-items:center;padding:1rem .375rem 1rem .75rem;display:flex}._modeless_1im3t_1{z-index:1000;position:fixed;left:45%}._modeless_content_1im3t_7{background-color:#fff;border:2px solid #ffffffe6;display:grid;box-shadow:0 0 0 1px #0000001a,0 4px 11px #0000001a}._modeless_header_1im3t_16,._modeless_footer_1im3t_17{padding:10px;position:relative}._modeless_title_1im3t_22{margin:0}._modeless_body_1im3t_26{border-top:1px solid gray;row-gap:4px;padding:10px;display:grid;position:relative}._close_button_1im3t_34{position:absolute;top:1ex;right:1ex}._aspect_1im3t_40{justify-content:left;padding-top:10px;position:relative}._btn_1im3t_46{background-color:var(--h5w-toolbar--bgColor,aliceblue);cursor:pointer;box-shadow:-1px -1px 2px inset var(--h5w-btnRaised--shadowColor,gray);border-radius:.8rem;justify-content:center;padding:0 .5rem}._btn_1im3t_46:hover{background-color:var(--h5w-btn-hover--bgColor,whitesmoke)}._colourLabel_1evqd_1{border-left:24px solid #000;margin-top:20px;padding-left:10px}._option_1qhtz_1{align-items:center;display:flex}._icon_1qhtz_6{padding-top:1px;font-size:1.5em}._scrollContainer_a4950_1{max-height:24ex;overflow-y:scroll}
1
+ ._top_cq7uz_1{grid-template-columns:70px 50px 100px 70px;display:grid}._error_cq7uz_6{color:red;flex-direction:row;align-items:center;padding-right:10px;display:flex}._label_cq7uz_14{flex-direction:row;align-items:center;display:flex}._modal_1tg1a_1{z-index:1000;position:fixed;left:45%}._modal_content_1tg1a_7{background-color:#fff;border:2px solid #ffffffe6;display:grid;box-shadow:0 0 0 1px #0000001a,0 4px 11px #0000001a}._modal_header_1tg1a_16,._modal_footer_1tg1a_17{padding:10px;position:relative}._modal_title_1tg1a_22{margin:0}._modal_body_1tg1a_26{border-top:1px solid gray;padding:10px;position:relative}._modal_body_1tg1a_26 [role=listbox]{z-index:10}._close_button_1tg1a_36{position:absolute;top:1ex;right:1ex}._aspect_1tg1a_42{justify-content:left;padding-top:10px;position:relative}._btn_1tg1a_48{background-color:var(--h5w-toolbar--bgColor,aliceblue);cursor:pointer;box-shadow:-1px -1px 2px inset var(--h5w-btnRaised--shadowColor,gray);border-radius:.8rem;justify-content:center;padding:0 .5rem}._btn_1tg1a_48:hover{background-color:var(--h5w-btn-hover--bgColor,whitesmoke)}._root_h18us_1{flex-direction:column;align-items:center;display:flex;position:relative}._sliderContainer_h18us_8{flex:1;margin-right:-.375rem;padding:0 .375rem;display:flex}._slider_h18us_8{cursor:pointer;--track-width:var(--h5w-domainSlider-track--width,8rem);--track-height:var(--h5w-domainSlider-track--height,.625rem);--thumb-size:calc(var(--track-height) * 2.5);--thumb-size-auto:calc(var(--thumb-size) * .9);margin-right:-.25rem;font-size:.75rem;display:flex}._tools_h18us_27{padding-bottom:2rem;padding-left:2rem;padding-right:2rem}._toolsInner_h18us_37{align-items:center;padding:1rem .375rem 1rem .75rem;display:flex}._modeless_1im3t_1{z-index:1000;position:fixed;left:45%}._modeless_content_1im3t_7{background-color:#fff;border:2px solid #ffffffe6;display:grid;box-shadow:0 0 0 1px #0000001a,0 4px 11px #0000001a}._modeless_header_1im3t_16,._modeless_footer_1im3t_17{padding:10px;position:relative}._modeless_title_1im3t_22{margin:0}._modeless_body_1im3t_26{border-top:1px solid gray;row-gap:4px;padding:10px;display:grid;position:relative}._close_button_1im3t_34{position:absolute;top:1ex;right:1ex}._aspect_1im3t_40{justify-content:left;padding-top:10px;position:relative}._btn_1im3t_46{background-color:var(--h5w-toolbar--bgColor,aliceblue);cursor:pointer;box-shadow:-1px -1px 2px inset var(--h5w-btnRaised--shadowColor,gray);border-radius:.8rem;justify-content:center;padding:0 .5rem}._btn_1im3t_46:hover{background-color:var(--h5w-btn-hover--bgColor,whitesmoke)}._colourLabel_1evqd_1{border-left:24px solid #000;margin-top:20px;padding-left:10px}._option_1qhtz_1{align-items:center;display:flex}._icon_1qhtz_6{padding-top:1px;font-size:1.5em}._scrollContainer_a4950_1{max-height:24ex;overflow-y:scroll}._any_plot_v4794_1{grid-template-rows:minmax(0,1fr);width:100%;height:100%;min-height:0;display:grid;position:relative}._any_plot_v4794_1:has(>:nth-child(2)){grid-template-rows:auto minmax(0,1fr)}._plot_container_v4794_14{grid-template-rows:minmax(0,1fr);min-width:0;max-width:100%;height:100%;min-height:0;max-height:100%;display:grid;position:relative}._plot_container_v4794_14:has(>:nth-child(2)){grid-template-rows:auto minmax(0,1fr)}._table_container_v4794_29{grid-template-rows:auto minmax(0,1fr)}
2
2
  /*$vite$:1*/
package/dist/index.d.ts CHANGED
@@ -24,9 +24,6 @@ import { Vector3 } from 'three';
24
24
  */
25
25
  export declare function AnyPlot(props: AnyPlotProps): JSX_2.Element;
26
26
 
27
- export declare interface AnyPlotCustomizationProps extends LinePlotCustomizationProps, ImagePlotCustomizationProps, HeatmapPlotCustomizationProps, ScatterPlotCustomizationProps, SurfacePlotCustomizationProps {
28
- }
29
-
30
27
  export declare type AnyPlotProps = AnyPlotVisProps | TableDisplayProps;
31
28
 
32
29
  export declare type AnyPlotVisProps = LinePlotProps | ImagePlotProps | HeatmapPlotProps | ScatterPlotProps | SurfacePlotProps;
@@ -72,6 +69,7 @@ export declare class BaseSelection implements SelectionBase {
72
69
  colour?: string;
73
70
  alpha: number;
74
71
  fixed: boolean;
72
+ permanent: boolean;
75
73
  start: [number, number];
76
74
  _asDashed?: boolean;
77
75
  /** Vector3 copy of start coordinate */
@@ -86,6 +84,23 @@ export declare class BaseSelection implements SelectionBase {
86
84
  static isShape(s: BaseSelection | SelectionBase): s is BaseSelection;
87
85
  }
88
86
 
87
+ /**
88
+ * Context provider of baton properties
89
+ * @param props children
90
+ * @returns context provider
91
+ */
92
+ export declare function BatonContextProvider(props: PropsWithChildren): JSX_2.Element;
93
+
94
+ /**
95
+ * Value for a `Baton` context.
96
+ */
97
+ export declare interface BatonContextValue {
98
+ /** The baton properties */
99
+ batonProps: BatonProps;
100
+ /** A function that sets the baton properties */
101
+ setBatonProps?: (bp: BatonProps) => void;
102
+ }
103
+
89
104
  /**
90
105
  * Baton props
91
106
  */
@@ -135,29 +150,34 @@ export { ColorMap }
135
150
  export { ColorScaleType }
136
151
 
137
152
  /**
138
- *
139
153
  * Renders a connected plot
154
+ *
155
+ * Note, wrap this in a BatonContextProvider (at the highest level to contain
156
+ * all connected plots) to support baton handling, otherwise the component
157
+ * always has the baton
140
158
  * @param {ConnectedPlotProps} props - component props
141
159
  * @returns {JSX.Element} The rendered component
142
160
  */
143
- export declare function ConnectedPlot({ plotId, hostname, port, source, events, uuid, tightAxes, customToolbarChildren, depends_on, }: ConnectedPlotProps): JSX_2.Element | undefined;
161
+ export declare function ConnectedPlot({ uuid, plotId, hostname, port, baseUrl, source, events, tightAxes, customToolbarChildren, depends_on, canEditSelections, selections, selectionsListener, selectionOptions, initialSelections, }: ConnectedPlotProps): JSX_2.Element;
144
162
 
145
163
  /**
146
164
  * Props for the `ConnectedPlot` component
147
165
  */
148
166
  export declare interface ConnectedPlotProps {
167
+ /** The universally unique identifier */
168
+ uuid: string;
149
169
  /** The plot ID */
150
170
  plotId: string;
151
171
  /** The hostname */
152
172
  hostname?: string;
153
173
  /** The port */
154
174
  port?: string;
175
+ /** Optional WebSocket base URL */
176
+ baseUrl?: string;
155
177
  /** Possible source configuration */
156
178
  source?: SourceConfig;
157
179
  /** Any event configuration */
158
180
  events?: EventConfig[];
159
- /** The universally unique identifier */
160
- uuid: string;
161
181
  /**
162
182
  * If enabled, forces the plot to shrink or expand to keep the image flush with the axes.
163
183
  * Has no effect if the aspect is not equal.
@@ -170,6 +190,16 @@ export declare interface ConnectedPlotProps {
170
190
  customToolbarChildren?: React.ReactNode;
171
191
  /** The plot ID that this plot depends on */
172
192
  depends_on?: string;
193
+ /** If true (default), can edit selections */
194
+ canEditSelections?: boolean;
195
+ /** The selections */
196
+ selections?: SelectionBase[];
197
+ /** Selections event listener */
198
+ selectionsListener?: SelectionsEventListener;
199
+ /** Selection type options and limits (0 = limitless) */
200
+ selectionOptions?: SelectionOptions;
201
+ /** Creates selections when the first plot configuration is received */
202
+ initialSelections?: (config: PlotConfig) => SelectionBase[];
173
203
  }
174
204
 
175
205
  export { Domain }
@@ -223,8 +253,6 @@ export declare interface HeatmapData extends ImageData_2 {
223
253
  */
224
254
  export declare function HeatmapPlot(props: HeatmapPlotProps): JSX_2.Element;
225
255
 
226
- declare type HeatmapPlotCustomizationProps = Omit<HeatmapPlotProps, 'values'>;
227
-
228
256
  /**
229
257
  * Props for `HeatmapPlot` component
230
258
  */
@@ -249,8 +277,6 @@ export { ImageData_2 as ImageData }
249
277
  */
250
278
  export declare function ImagePlot(props: ImagePlotProps): JSX_2.Element;
251
279
 
252
- declare type ImagePlotCustomizationProps = Omit<ImagePlotProps, 'values'>;
253
-
254
280
  /**
255
281
  * Props for the `ImagePlot` component
256
282
  */
@@ -330,8 +356,6 @@ export declare interface LineParams {
330
356
  */
331
357
  export declare function LinePlot(props: LinePlotProps): JSX_2.Element;
332
358
 
333
- declare type LinePlotCustomizationProps = Omit<LinePlotProps, 'lineData'>;
334
-
335
359
  /**
336
360
  * Props for the `LinePlot` component.
337
361
  */
@@ -363,7 +387,7 @@ export declare class OrientableSelection extends BaseSelection {
363
387
  /**
364
388
  * Props for selections, baton and configuration in a plot component
365
389
  */
366
- export declare interface PlotBaseProps extends PlotSelectionProps {
390
+ export declare interface PlotBaseProps extends PlotSelectionProps, PlotBatonProps {
367
391
  /** The plot configuration */
368
392
  plotConfig: PlotConfig;
369
393
  /**
@@ -373,6 +397,14 @@ export declare interface PlotBaseProps extends PlotSelectionProps {
373
397
  customToolbarChildren?: React.ReactNode;
374
398
  }
375
399
 
400
+ /**
401
+ * Props for a baton in a plot component
402
+ */
403
+ export declare interface PlotBatonProps {
404
+ /** The baton props */
405
+ batonProps?: BatonProps;
406
+ }
407
+
376
408
  /**
377
409
  * Represent plot configuration
378
410
  */
@@ -393,7 +425,7 @@ export declare interface PlotConfig {
393
425
  title?: string;
394
426
  }
395
427
 
396
- export declare function PlotCustomizationContextProvider(props: PropsWithChildren<AnyPlotCustomizationProps>): JSX_2.Element;
428
+ export declare function PlotCustomizationContextProvider(props: PropsWithChildren): JSX_2.Element;
397
429
 
398
430
  /**
399
431
  * Value for a `PlotCustomization` context.
@@ -413,6 +445,8 @@ export declare interface PlotCustomizationContextValue {
413
445
  setMode: (m: InteractionModeType) => void;
414
446
  /** A domain value for the x-axis */
415
447
  xDomain: Domain;
448
+ /** A function that sets the domain value for the x-axis */
449
+ setXDomain: (d: Domain) => void;
416
450
  /** A custom domain value for the x-axis */
417
451
  xCustomDomain: CustomDomain;
418
452
  /** A function that sets the custom domain value for the x-axis */
@@ -427,6 +461,8 @@ export declare interface PlotCustomizationContextValue {
427
461
  setXScaleType: (s: AxisScaleType) => void;
428
462
  /** A domain value for the y-axis */
429
463
  yDomain: Domain;
464
+ /** A function that sets the domain value for the y-axis */
465
+ setYDomain: (d: Domain) => void;
430
466
  /** A custom domain value for the y-axis */
431
467
  yCustomDomain: CustomDomain;
432
468
  /** A function that sets the custom domain value for the y-axis */
@@ -435,8 +471,6 @@ export declare interface PlotCustomizationContextValue {
435
471
  yLabel: string;
436
472
  /** A function that sets the label for the y-axis */
437
473
  setYLabel: (l: string) => void;
438
- /** The baton properties */
439
- batonProps: BatonProps;
440
474
  /** An axis scale type for the y-axis */
441
475
  yScaleType: AxisScaleType;
442
476
  /** A function that sets the axis scale type for the y-axis */
@@ -453,6 +487,8 @@ export declare interface PlotCustomizationContextValue {
453
487
  setSelectionType: (s: SelectionType) => void;
454
488
  /** A domain value for the d-axis */
455
489
  dDomain: Domain;
490
+ /** A function that sets the domain value for the d-axis */
491
+ setDDomain: (d: Domain) => void;
456
492
  /** A custom domain value for the d-axis */
457
493
  dCustomDomain: CustomDomain;
458
494
  /** A function that sets the custom domain value for the d-axis */
@@ -474,7 +510,9 @@ export declare interface PlotCustomizationContextValue {
474
510
  /** Selections */
475
511
  selections: SelectionBase[];
476
512
  /** A function that sets the selections */
477
- setSelections: (s: SelectionBase[]) => void;
513
+ setSelections: Dispatch<SetStateAction<SelectionBase[]>>;
514
+ /** A function that sets the selections listener */
515
+ setSelectionsListener: (l: SelectionsEventListener) => void;
478
516
  /** A function that updates the selections */
479
517
  updateSelection: SelectionHandler;
480
518
  /** Map of line parameters */
@@ -499,22 +537,30 @@ export declare interface PlotCustomizationContextValue {
499
537
  histogramGetter?: () => HistogramParams;
500
538
  /** Update heatmap histogram getter */
501
539
  updateHistogramGetter: (getter: () => HistogramParams) => void;
540
+ updateLineContext: (xDomain?: Domain, yDomain?: Domain, plotConfig?: PlotConfig) => void;
541
+ updateHeatmapContext: (data: HeatmapData, plotConfig: PlotConfig) => void;
542
+ updateImageContext: (data: ImageData_2, plotConfig: PlotConfig) => void;
543
+ updateScatterContext: (data: ScatterData, plotConfig: PlotConfig) => void;
544
+ updateSurfaceContext: (data: SurfaceData, plotConfig: PlotConfig) => void;
545
+ updateSelectionContext: (selectionProps: PlotSelectionProps) => void;
502
546
  /** Can select */
503
547
  canSelect: boolean;
504
548
  /** Type of plot */
505
549
  plotType: PlotType;
550
+ /** Can edit selections */
551
+ canEditSelections: boolean;
506
552
  }
507
553
 
508
554
  /**
509
- * Props for selections (and baton) in a plot component
555
+ * Props for selections in a plot component
510
556
  */
511
557
  export declare interface PlotSelectionProps {
512
- /** Handles adding selection (set null to disable editing) */
513
- updateSelection?: SelectionHandler | null;
558
+ /** Handles adding selection */
559
+ updateSelection?: SelectionHandler;
560
+ /** If true (default), can edit selections */
561
+ canEditSelections?: boolean;
514
562
  /** The selections */
515
563
  selections?: SelectionBase[];
516
- /** The baton props */
517
- batonProps?: BatonProps;
518
564
  /** Selections event listener */
519
565
  selectionsListener?: SelectionsEventListener;
520
566
  /** Selection type options and limits (0 = limitless) */
@@ -573,7 +619,7 @@ export { ScaleType }
573
619
  /**
574
620
  * Represent scatter data.
575
621
  */
576
- declare interface ScatterData {
622
+ export declare interface ScatterData {
577
623
  /** The x values for the scatter plot */
578
624
  x: NDT;
579
625
  /** The y values for the scatter plot */
@@ -595,8 +641,6 @@ declare interface ScatterData {
595
641
  */
596
642
  export declare function ScatterPlot(props: ScatterPlotProps): JSX_2.Element;
597
643
 
598
- declare type ScatterPlotCustomizationProps = Omit<ScatterPlotProps, 'pointValues' | 'x' | 'y'>;
599
-
600
644
  /**
601
645
  * Props for the `ScatterPlotProps` component.
602
646
  */
@@ -621,6 +665,8 @@ export declare interface SelectionBase {
621
665
  alpha: number;
622
666
  /** if true, not moveable */
623
667
  fixed: boolean;
668
+ /** if true, not deletable */
669
+ permanent: boolean;
624
670
  /** start (or centre) point coordinate */
625
671
  start: [number, number];
626
672
  /** if true, outline is dashed */
@@ -645,7 +691,7 @@ dragging?: boolean,
645
691
  /** if true, remove selection */
646
692
  clear?: boolean) => string | null;
647
693
 
648
- declare type SelectionOptions = {
694
+ export declare type SelectionOptions = {
649
695
  [K in SelectionType]?: number;
650
696
  };
651
697
 
@@ -714,14 +760,10 @@ export declare interface SurfaceData {
714
760
  */
715
761
  export declare function SurfacePlot(props: SurfacePlotProps): JSX_2.Element;
716
762
 
717
- declare type SurfacePlotCustomizationProps = Omit<SurfacePlotProps, 'heightValues'>;
718
-
719
763
  /**
720
764
  * Props for the `SurfacePlot` component.
721
765
  */
722
- export declare interface SurfacePlotProps extends SurfaceData {
723
- /** The baton props */
724
- batonProps?: BatonProps;
766
+ export declare interface SurfacePlotProps extends SurfaceData, PlotBatonProps {
725
767
  /** The plot configuration */
726
768
  plotConfig: PlotConfig;
727
769
  /**
@@ -761,14 +803,17 @@ export declare interface TableDisplayParams {
761
803
  /**
762
804
  * Props for the `TableDisplay` component.
763
805
  */
764
- export declare interface TableDisplayProps extends TableData {
765
- /** The baton props */
766
- batonProps?: BatonProps;
806
+ export declare interface TableDisplayProps extends TableData, PlotBatonProps {
767
807
  }
768
808
 
769
809
  /** Number represent in table */
770
810
  export declare type TableDisplayType = 'scientific' | 'standard';
771
811
 
812
+ /**
813
+ * @returns context for baton
814
+ */
815
+ export declare function useBatonContext(): BatonContextValue;
816
+
772
817
  /**
773
818
  * @returns context for customizing a plot
774
819
  */
@@ -778,7 +823,8 @@ export declare function usePlotCustomizationContext(): PlotCustomizationContextV
778
823
  * Custom hook to handle selection changes
779
824
  * @param initSelections initial selections
780
825
  * @param listener event listener
781
- * @returns selections, selections setter, new selection reference, updateSelection, canSelect, enableSelect
826
+ * @returns selections, selections setter, new selection reference, updateSelection,
827
+ * canSelect, enableSelect, setSelectionsListener, editable, setEditable,
782
828
  */
783
829
  export declare function useSelections(initSelections?: SelectionBase[], listener?: SelectionsEventListener): {
784
830
  selections: SelectionBase[];
@@ -787,6 +833,9 @@ export declare function useSelections(initSelections?: SelectionBase[], listener
787
833
  updateSelection: SelectionHandler;
788
834
  canSelect: boolean;
789
835
  enableSelect: Dispatch<SetStateAction<boolean>>;
836
+ setSelectionsListener: (listener: SelectionsEventListener) => void;
837
+ editable: boolean;
838
+ setEditable: Dispatch<SetStateAction<boolean>>;
790
839
  };
791
840
 
792
841
  /**