@diamondlightsource/davidia 1.0.0 → 1.0.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.
package/dist/index.d.ts CHANGED
@@ -3,14 +3,17 @@ import { AxisScaleType } from '@h5web/lib';
3
3
  import { ColorMap } from '@h5web/lib';
4
4
  import { ColorScaleType } from '@h5web/lib';
5
5
  import { CustomDomain } from '@h5web/lib';
6
+ import { Dispatch } from 'react';
6
7
  import { Domain } from '@h5web/lib';
7
8
  import { GlyphType } from '@h5web/lib';
8
9
  import { HistogramParams } from '@h5web/lib';
9
10
  import { JSX as JSX_2 } from 'react/jsx-runtime';
10
11
  import { Matrix3 } from 'three';
12
+ import { MutableRefObject } from 'react';
11
13
  import { NdArray } from 'ndarray';
12
14
  import { PropsWithChildren } from 'react';
13
15
  import { ScaleType } from '@h5web/lib';
16
+ import { SetStateAction } from 'react';
14
17
  import { TypedArray } from 'ndarray';
15
18
  import { Vector3 } from 'three';
16
19
 
@@ -480,6 +483,8 @@ export declare interface PlotSelectionProps {
480
483
  selections?: SelectionBase[];
481
484
  /** The baton props */
482
485
  batonProps?: BatonProps;
486
+ /** Selections event listener */
487
+ selectionsListener?: SelectionsEventListener;
483
488
  }
484
489
 
485
490
  /**
@@ -601,11 +606,29 @@ export declare interface SelectionBase {
601
606
  * @returns ID of changed selection
602
607
  */
603
608
  export declare type SelectionHandler = (selection: SelectionBase | null,
604
- /** if true, update server with selection */
605
- broadcast?: boolean,
609
+ /** if true, selection is being dragged */
610
+ dragging?: boolean,
606
611
  /** if true, remove selection */
607
612
  clear?: boolean) => string | null;
608
613
 
614
+ /**
615
+ * Selections event listener
616
+ */
617
+ export declare type SelectionsEventListener = (type: SelectionsEventType,
618
+ /** if true, selection is being dragged */
619
+ dragging: boolean,
620
+ /** can be undefined for removing all selections */
621
+ selection?: SelectionBase) => void;
622
+
623
+ /**
624
+ * Selections event type
625
+ */
626
+ export declare enum SelectionsEventType {
627
+ created = "created",
628
+ removed = "removed",
629
+ updated = "updated"
630
+ }
631
+
609
632
  /**
610
633
  * Supported types of selections
611
634
  */
@@ -705,6 +728,21 @@ export declare type TableDisplayType = 'scientific' | 'standard';
705
728
  */
706
729
  export declare function usePlotCustomizationContext(): PlotCustomizationContextValue;
707
730
 
731
+ /**
732
+ * Custom hook to handle selection changes
733
+ * @param initSelections initial selections
734
+ * @param listener event listener
735
+ * @returns selections, selections setter, new selection reference, updateSelection, canSelect, enableSelect
736
+ */
737
+ export declare function useSelections(initSelections?: SelectionBase[], listener?: SelectionsEventListener): {
738
+ selections: SelectionBase[];
739
+ setSelections: Dispatch<SetStateAction<SelectionBase[]>>;
740
+ isNewSelection: MutableRefObject<boolean>;
741
+ updateSelection: SelectionHandler;
742
+ canSelect: boolean;
743
+ enableSelect: Dispatch<SetStateAction<boolean>>;
744
+ };
745
+
708
746
  export { }
709
747
 
710
748