@buerli.io/core 1.0.1 → 1.1.0-beta.7

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 (74) hide show
  1. package/README.md +19 -19
  2. package/build/cjs/geometry/ThreeGeometryCreator.js +320 -320
  3. package/build/cjs/geometry/index.js +17 -17
  4. package/build/cjs/graphic/filters.js +25 -25
  5. package/build/cjs/index.js +26 -26
  6. package/build/cjs/re-export.js +29 -29
  7. package/build/cjs/store/index.js +41 -37
  8. package/build/cjs/store/states/buerli.js +98 -98
  9. package/build/cjs/store/states/cad.js +47 -47
  10. package/build/cjs/store/states/drawing.js +49 -49
  11. package/build/cjs/store/states/geometry.js +157 -157
  12. package/build/cjs/store/states/graphic.js +115 -115
  13. package/build/cjs/store/states/interaction.js +55 -55
  14. package/build/cjs/store/states/message.js +32 -25
  15. package/build/cjs/store/states/plugin.js +115 -115
  16. package/build/cjs/store/states/selection.js +267 -267
  17. package/build/cjs/store/states/structure.js +250 -250
  18. package/build/cjs/store/store.js +9 -9
  19. package/build/cjs/store/subscribtion/selection.js +49 -49
  20. package/build/cjs/store/subscribtion/subscribeToDrawing.js +13 -13
  21. package/build/cjs/types/InteractionInfo.js +11 -11
  22. package/build/cjs/types/index.js +34 -34
  23. package/build/cjs/utils/Math.js +91 -91
  24. package/build/cjs/utils/Measure.js +576 -576
  25. package/build/cjs/utils/Timing.js +34 -34
  26. package/build/esm/geometry/ThreeGeometryCreator.js +291 -291
  27. package/build/esm/geometry/index.js +1 -1
  28. package/build/esm/graphic/filters.js +12 -12
  29. package/build/esm/index.js +10 -10
  30. package/build/esm/re-export.js +23 -23
  31. package/build/esm/store/index.js +29 -26
  32. package/build/esm/store/states/buerli.js +92 -92
  33. package/build/esm/store/states/cad.js +42 -42
  34. package/build/esm/store/states/drawing.js +45 -45
  35. package/build/esm/store/states/geometry.js +129 -129
  36. package/build/esm/store/states/graphic.js +110 -110
  37. package/build/esm/store/states/interaction.js +50 -50
  38. package/build/esm/store/states/message.js +28 -21
  39. package/build/esm/store/states/plugin.js +109 -109
  40. package/build/esm/store/states/selection.js +261 -261
  41. package/build/esm/store/states/structure.js +219 -219
  42. package/build/esm/store/store.js +3 -3
  43. package/build/esm/store/subscribtion/selection.js +44 -44
  44. package/build/esm/store/subscribtion/subscribeToDrawing.js +9 -9
  45. package/build/esm/types/InteractionInfo.js +6 -6
  46. package/build/esm/types/index.js +16 -16
  47. package/build/esm/utils/Math.js +65 -65
  48. package/build/esm/utils/Measure.js +550 -550
  49. package/build/esm/utils/Timing.js +31 -31
  50. package/build/types/geometry/ThreeGeometryCreator.d.ts +256 -256
  51. package/build/types/geometry/index.d.ts +1 -1
  52. package/build/types/graphic/filters.d.ts +11 -11
  53. package/build/types/index.d.ts +38 -38
  54. package/build/types/re-export.d.ts +70 -70
  55. package/build/types/store/index.d.ts +17 -16
  56. package/build/types/store/states/buerli.d.ts +41 -41
  57. package/build/types/store/states/cad.d.ts +56 -56
  58. package/build/types/store/states/drawing.d.ts +45 -45
  59. package/build/types/store/states/geometry.d.ts +64 -64
  60. package/build/types/store/states/graphic.d.ts +21 -21
  61. package/build/types/store/states/interaction.d.ts +34 -34
  62. package/build/types/store/states/message.d.ts +32 -30
  63. package/build/types/store/states/plugin.d.ts +53 -53
  64. package/build/types/store/states/selection.d.ts +69 -69
  65. package/build/types/store/states/structure.d.ts +47 -47
  66. package/build/types/store/store.d.ts +2 -2
  67. package/build/types/store/subscribtion/selection.d.ts +7 -7
  68. package/build/types/store/subscribtion/subscribeToDrawing.d.ts +4 -4
  69. package/build/types/types/InteractionInfo.d.ts +42 -42
  70. package/build/types/types/index.d.ts +7 -7
  71. package/build/types/utils/Math.d.ts +21 -21
  72. package/build/types/utils/Measure.d.ts +64 -64
  73. package/build/types/utils/Timing.d.ts +8 -8
  74. package/package.json +2 -2
@@ -1,64 +1,64 @@
1
- import * as THREE from 'three';
2
- import { StoreApi } from 'zustand';
3
- import { ContainerGeometryT, GeometryElement } from '../../geometry/ThreeGeometryCreator';
4
- import { GraphicID, ObjectID } from '../../re-export';
5
- import { BuerliState } from './buerli';
6
- import { DrawingState } from './drawing';
7
- export declare type GeometryBounds = {
8
- center: THREE.Vector3;
9
- radius: number;
10
- max: THREE.Vector3;
11
- min: THREE.Vector3;
12
- };
13
- declare type ElementConfig = {
14
- hidden?: boolean;
15
- color?: any;
16
- opacity?: number;
17
- };
18
- export declare type GeometryConfig = {
19
- disabled?: boolean;
20
- meshes?: ElementConfig & {
21
- wireframe?: boolean;
22
- depthWrite?: boolean;
23
- };
24
- edges?: ElementConfig;
25
- points?: ElementConfig;
26
- };
27
- export declare type GeometryData = {
28
- cache: Record<ObjectID, // The id of the CADEntity
29
- // The id of the CADEntity
30
- ContainerGeometryT & {
31
- /**
32
- * The dirty stamp will be updated, as soon as a client side modification of the geometry will happen!
33
- * Examples: 'setColor' or 'setOpacity'
34
- *
35
- * Can for example be used to trigger the render process for this container.
36
- */
37
- dirtyStamp?: number;
38
- }>;
39
- stamp: number;
40
- bounds: GeometryBounds;
41
- config: {
42
- product: Record<ObjectID, GeometryConfig>;
43
- };
44
- };
45
- export declare type GeometryApi = ReturnType<typeof geometryApi>;
46
- export declare const geometryData: () => GeometryData;
47
- export declare const geometryApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
48
- /**
49
- * Updates the @see geometry.bounds depending on all products of the model.
50
- * The update will only happen, if at least one solid of one product is available.
51
- */
52
- updateBounds: () => void;
53
- createGeometryIfNotCached: (containerId: ObjectID, color?: number[]) => ContainerGeometryT | undefined;
54
- setGraphicColor: (containerId: ObjectID, graphicId: GraphicID, r: number, g: number, b: number) => void;
55
- setContainerColor: (containerId: ObjectID, r: number, g: number, b: number) => void;
56
- setOpacity: (containerId: ObjectID, opacity: number) => void;
57
- setConfig: (objId: ObjectID, config: Partial<GeometryConfig> | null) => void;
58
- findDecorated: () => GeometryElement[];
59
- filter: (cb: (elem: GeometryElement) => boolean, options?: {
60
- onlyOne?: boolean;
61
- containerId?: ObjectID;
62
- }) => GeometryElement[];
63
- };
64
- export {};
1
+ import * as THREE from 'three';
2
+ import { StoreApi } from 'zustand';
3
+ import { ContainerGeometryT, GeometryElement } from '../../geometry/ThreeGeometryCreator';
4
+ import { GraphicID, ObjectID } from '../../re-export';
5
+ import { BuerliState } from './buerli';
6
+ import { DrawingState } from './drawing';
7
+ export declare type GeometryBounds = {
8
+ center: THREE.Vector3;
9
+ radius: number;
10
+ max: THREE.Vector3;
11
+ min: THREE.Vector3;
12
+ };
13
+ declare type ElementConfig = {
14
+ hidden?: boolean;
15
+ color?: any;
16
+ opacity?: number;
17
+ };
18
+ export declare type GeometryConfig = {
19
+ disabled?: boolean;
20
+ meshes?: ElementConfig & {
21
+ wireframe?: boolean;
22
+ depthWrite?: boolean;
23
+ };
24
+ edges?: ElementConfig;
25
+ points?: ElementConfig;
26
+ };
27
+ export declare type GeometryData = {
28
+ cache: Record<ObjectID, // The id of the CADEntity
29
+ // The id of the CADEntity
30
+ ContainerGeometryT & {
31
+ /**
32
+ * The dirty stamp will be updated, as soon as a client side modification of the geometry will happen!
33
+ * Examples: 'setColor' or 'setOpacity'
34
+ *
35
+ * Can for example be used to trigger the render process for this container.
36
+ */
37
+ dirtyStamp?: number;
38
+ }>;
39
+ stamp: number;
40
+ bounds: GeometryBounds;
41
+ config: {
42
+ product: Record<ObjectID, GeometryConfig>;
43
+ };
44
+ };
45
+ export declare type GeometryApi = ReturnType<typeof geometryApi>;
46
+ export declare const geometryData: () => GeometryData;
47
+ export declare const geometryApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
48
+ /**
49
+ * Updates the @see geometry.bounds depending on all products of the model.
50
+ * The update will only happen, if at least one solid of one product is available.
51
+ */
52
+ updateBounds: () => void;
53
+ createGeometryIfNotCached: (containerId: ObjectID, color?: number[]) => ContainerGeometryT | undefined;
54
+ setGraphicColor: (containerId: ObjectID, graphicId: GraphicID, r: number, g: number, b: number) => void;
55
+ setContainerColor: (containerId: ObjectID, r: number, g: number, b: number) => void;
56
+ setOpacity: (containerId: ObjectID, opacity: number) => void;
57
+ setConfig: (objId: ObjectID, config: Partial<GeometryConfig> | null) => void;
58
+ findDecorated: () => GeometryElement[];
59
+ filter: (cb: (elem: GeometryElement) => boolean, options?: {
60
+ onlyOne?: boolean;
61
+ containerId?: ObjectID;
62
+ }) => GeometryElement[];
63
+ };
64
+ export {};
@@ -1,21 +1,21 @@
1
- import { StoreApi } from 'zustand';
2
- import { IGraphicContainer, IGraphicElement, IGraphicPackage, ObjectID } from '../../re-export';
3
- import { BuerliState } from './buerli';
4
- import { DrawingState } from './drawing';
5
- export declare type GraphicData = {
6
- containers: Record<number, IGraphicContainer>;
7
- };
8
- export declare type GraphicApi = ReturnType<typeof graphicApi>;
9
- export declare const graphicData: () => GraphicData;
10
- export declare const graphicApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
11
- addPackages: (packages: IGraphicPackage | IGraphicPackage[]) => void;
12
- cleanupGraphicRecords: () => void;
13
- filter: (cb: (elem: IGraphicElement) => boolean, options?: {
14
- onlyOne?: boolean;
15
- containerId?: ObjectID;
16
- }) => {
17
- elem: IGraphicElement;
18
- containerId: ObjectID;
19
- solidId: ObjectID;
20
- }[];
21
- };
1
+ import { StoreApi } from 'zustand';
2
+ import { IGraphicContainer, IGraphicElement, IGraphicPackage, ObjectID } from '../../re-export';
3
+ import { BuerliState } from './buerli';
4
+ import { DrawingState } from './drawing';
5
+ export declare type GraphicData = {
6
+ containers: Record<number, IGraphicContainer>;
7
+ };
8
+ export declare type GraphicApi = ReturnType<typeof graphicApi>;
9
+ export declare const graphicData: () => GraphicData;
10
+ export declare const graphicApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
11
+ addPackages: (packages: IGraphicPackage | IGraphicPackage[]) => void;
12
+ cleanupGraphicRecords: () => void;
13
+ filter: (cb: (elem: IGraphicElement) => boolean, options?: {
14
+ onlyOne?: boolean;
15
+ containerId?: ObjectID;
16
+ }) => {
17
+ elem: IGraphicElement;
18
+ containerId: ObjectID;
19
+ solidId: ObjectID;
20
+ }[];
21
+ };
@@ -1,34 +1,34 @@
1
- import { StoreApi } from 'zustand';
2
- import { InteractionInfo } from '../../types';
3
- import { BuerliState } from './buerli';
4
- import { DrawingState } from './drawing';
5
- export declare type InteractionData = {
6
- hovered?: InteractionInfo | null;
7
- selected?: InteractionInfo[];
8
- };
9
- export declare type InteractionApi = ReturnType<typeof interactionApi>;
10
- export declare const interactionData: () => InteractionData;
11
- export declare const interactionApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
12
- /**
13
- * Sets the hovered item in the store to the given item.
14
- *
15
- * @param item The item.
16
- */
17
- setHovered: (item: InteractionInfo | null) => void;
18
- /**
19
- * Reset the 'selected' array to the given items.
20
- *
21
- * @param items The items.
22
- */
23
- setSelected: (items: InteractionInfo[]) => void;
24
- /**
25
- * Adds the given item to the 'selected' array if it is not yet selected.
26
- * If the item is already selected, it will be removed from the 'selected' array.
27
- *
28
- * With 'multi' enabled, the already selected items will remain selected.
29
- *
30
- * @param item The item to select.
31
- * @param multi Do multi select.
32
- */
33
- select: (item: InteractionInfo, multi?: boolean) => void;
34
- };
1
+ import { StoreApi } from 'zustand';
2
+ import { InteractionInfo } from '../../types';
3
+ import { BuerliState } from './buerli';
4
+ import { DrawingState } from './drawing';
5
+ export declare type InteractionData = {
6
+ hovered?: InteractionInfo | null;
7
+ selected?: InteractionInfo[];
8
+ };
9
+ export declare type InteractionApi = ReturnType<typeof interactionApi>;
10
+ export declare const interactionData: () => InteractionData;
11
+ export declare const interactionApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
12
+ /**
13
+ * Sets the hovered item in the store to the given item.
14
+ *
15
+ * @param item The item.
16
+ */
17
+ setHovered: (item: InteractionInfo | null) => void;
18
+ /**
19
+ * Reset the 'selected' array to the given items.
20
+ *
21
+ * @param items The items.
22
+ */
23
+ setSelected: (items: InteractionInfo[]) => void;
24
+ /**
25
+ * Adds the given item to the 'selected' array if it is not yet selected.
26
+ * If the item is already selected, it will be removed from the 'selected' array.
27
+ *
28
+ * With 'multi' enabled, the already selected items will remain selected.
29
+ *
30
+ * @param item The item to select.
31
+ * @param multi Do multi select.
32
+ */
33
+ select: (item: InteractionInfo, multi?: boolean) => void;
34
+ };
@@ -1,30 +1,32 @@
1
- import { StoreApi } from 'zustand';
2
- import { BuerliState } from './buerli';
3
- import { DrawingID } from './drawing';
4
- export declare type MessageScope = string | number;
5
- export declare type MessageID = string;
6
- export declare const BuerliMessageScope: MessageScope;
7
- export declare type Message = {
8
- text: string;
9
- title?: string;
10
- scope?: MessageScope;
11
- code?: number;
12
- type?: 'error' | 'success' | 'info' | 'warning' | 'busy';
13
- source?: 'client' | 'server';
14
- drawingId?: DrawingID;
15
- };
16
- export declare type MessageState = {
17
- message: {
18
- data: (Message & {
19
- id: MessageID;
20
- }) | null;
21
- timestamp: number;
22
- api: ReturnType<typeof messageApi>;
23
- };
24
- };
25
- export declare const getInitialMessageState: (set: StoreApi<BuerliState>['setState'], get: StoreApi<BuerliState>['getState'], api: StoreApi<BuerliState>) => MessageState;
26
- declare const messageApi: (set: StoreApi<BuerliState>['setState'], get: StoreApi<BuerliState>['getState'], api: StoreApi<BuerliState>) => {
27
- show(message: Message): MessageID;
28
- update(id: MessageID, message: Message): void;
29
- };
30
- export {};
1
+ import { StoreApi } from 'zustand';
2
+ import { BuerliState } from './buerli';
3
+ import { DrawingID } from './drawing';
4
+ export declare type MessageScope = string | number;
5
+ export declare type MessageID = string;
6
+ export declare const BuerliMessageScope: MessageScope;
7
+ export declare type Message = {
8
+ text: string;
9
+ title?: string;
10
+ scope?: MessageScope;
11
+ code?: number;
12
+ type?: 'error' | 'success' | 'info' | 'warning' | 'busy';
13
+ source?: 'client' | 'server';
14
+ drawingId?: DrawingID;
15
+ duration?: number;
16
+ };
17
+ export declare type MessageState = {
18
+ message: {
19
+ data: (Message & {
20
+ id: MessageID;
21
+ }) | null;
22
+ timestamp: number;
23
+ api: ReturnType<typeof messageApi>;
24
+ };
25
+ };
26
+ export declare const getInitialMessageState: (set: StoreApi<BuerliState>['setState'], get: StoreApi<BuerliState>['getState'], api: StoreApi<BuerliState>) => MessageState;
27
+ declare const messageApi: (set: StoreApi<BuerliState>['setState'], get: StoreApi<BuerliState>['getState'], api: StoreApi<BuerliState>) => {
28
+ show(message: Message): MessageID;
29
+ update(id: MessageID, message: Message): void;
30
+ close(id: MessageID): void;
31
+ };
32
+ export {};
@@ -1,53 +1,53 @@
1
- import { StoreApi } from 'zustand';
2
- import { ObjectID } from '../../re-export';
3
- import { BuerliState } from './buerli';
4
- import { DrawingID, DrawingState } from './drawing';
5
- export declare type PluginDescription<InternalState = any> = {
6
- name: string;
7
- version: string;
8
- author: string;
9
- persistent?: boolean;
10
- global?: boolean;
11
- initialState?: ((drawingId: DrawingID, objectId: ObjectID) => InternalState) | InternalState;
12
- [key: string]: any;
13
- };
14
- declare type StateData<InternalState extends Record<any, any>> = PluginDescription<InternalState> & {
15
- id: PluginID;
16
- Root: ((options?: any) => any) | null;
17
- View: ((options?: any) => any) | null;
18
- drawingId?: DrawingID;
19
- objectId?: ObjectID;
20
- state: InternalState;
21
- set: (sel: Partial<InternalState> | ((state: InternalState) => Partial<InternalState>)) => void;
22
- };
23
- export declare type Plugin = {
24
- Root?: ((options?: any) => any) | null;
25
- View?: ((options?: any) => any) | null;
26
- description: PluginDescription;
27
- };
28
- export declare type PluginDef = Plugin | Promise<Plugin>;
29
- export declare type PluginImpl = PluginDef | (() => Plugin) | (() => Promise<Plugin>);
30
- export declare type PluginID = ObjectID | string;
31
- export declare type PluginState<InternalState extends Record<any, any> = any> = Readonly<StateData<InternalState>>;
32
- export declare type PluginData = {
33
- /** Contains ids of feature-plugins */
34
- feature: PluginID[];
35
- /** Contains ids of global-plugins */
36
- global: PluginID[];
37
- refs: Record<PluginID, PluginState>;
38
- active: {
39
- feature: PluginID | null;
40
- global: PluginID[];
41
- };
42
- visible: PluginID[];
43
- };
44
- export declare type PluginApi = ReturnType<typeof pluginApi>;
45
- export declare const pluginData: () => PluginData;
46
- export declare const pluginApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
47
- setActiveFeature: (id: ObjectID | null) => void;
48
- setVisiblePlugin: (id: PluginID, visible: boolean) => void;
49
- setActiveGlobal: (id: PluginID, active: boolean) => void;
50
- createPlugin: (def: PluginDef, defaultId?: ObjectID | string, drawingId?: DrawingID, objectId?: ObjectID) => (deactivate?: boolean) => void;
51
- };
52
- export declare function isPromisePlugin(def: PluginDef): def is Promise<Plugin>;
53
- export {};
1
+ import { StoreApi } from 'zustand';
2
+ import { ObjectID } from '../../re-export';
3
+ import { BuerliState } from './buerli';
4
+ import { DrawingID, DrawingState } from './drawing';
5
+ export declare type PluginDescription<InternalState = any> = {
6
+ name: string;
7
+ version: string;
8
+ author: string;
9
+ persistent?: boolean;
10
+ global?: boolean;
11
+ initialState?: ((drawingId: DrawingID, objectId: ObjectID) => InternalState) | InternalState;
12
+ [key: string]: any;
13
+ };
14
+ declare type StateData<InternalState extends Record<any, any>> = PluginDescription<InternalState> & {
15
+ id: PluginID;
16
+ Root: ((options?: any) => any) | null;
17
+ View: ((options?: any) => any) | null;
18
+ drawingId?: DrawingID;
19
+ objectId?: ObjectID;
20
+ state: InternalState;
21
+ set: (sel: Partial<InternalState> | ((state: InternalState) => Partial<InternalState>)) => void;
22
+ };
23
+ export declare type Plugin = {
24
+ Root?: ((options?: any) => any) | null;
25
+ View?: ((options?: any) => any) | null;
26
+ description: PluginDescription;
27
+ };
28
+ export declare type PluginDef = Plugin | Promise<Plugin>;
29
+ export declare type PluginImpl = PluginDef | (() => Plugin) | (() => Promise<Plugin>);
30
+ export declare type PluginID = ObjectID | string;
31
+ export declare type PluginState<InternalState extends Record<any, any> = any> = Readonly<StateData<InternalState>>;
32
+ export declare type PluginData = {
33
+ /** Contains ids of feature-plugins */
34
+ feature: PluginID[];
35
+ /** Contains ids of global-plugins */
36
+ global: PluginID[];
37
+ refs: Record<PluginID, PluginState>;
38
+ active: {
39
+ feature: PluginID | null;
40
+ global: PluginID[];
41
+ };
42
+ visible: PluginID[];
43
+ };
44
+ export declare type PluginApi = ReturnType<typeof pluginApi>;
45
+ export declare const pluginData: () => PluginData;
46
+ export declare const pluginApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
47
+ setActiveFeature: (id: ObjectID | null) => void;
48
+ setVisiblePlugin: (id: PluginID, visible: boolean) => void;
49
+ setActiveGlobal: (id: PluginID, active: boolean) => void;
50
+ createPlugin: (def: PluginDef, defaultId?: ObjectID | string, drawingId?: DrawingID, objectId?: ObjectID) => (deactivate?: boolean) => void;
51
+ };
52
+ export declare function isPromisePlugin(def: PluginDef): def is Promise<Plugin>;
53
+ export {};
@@ -1,69 +1,69 @@
1
- import { StoreApi } from 'zustand';
2
- import { GraphicID, ObjectID } from '../../re-export';
3
- import { GeometryElement, ProductElement } from './../../geometry/ThreeGeometryCreator';
4
- import { BuerliState } from './buerli';
5
- import { DrawingState } from './drawing';
6
- export declare const BuerliScope = "ClassCAD";
7
- export declare type SelectorID = string | number;
8
- export declare type SeletedItemData<T> = Record<string, T>;
9
- export declare type SelectionScope = string | number;
10
- export declare type SelectedItem<T extends SeletedItemData<any> = any> = {
11
- readonly id: any;
12
- readonly scope: SelectionScope;
13
- readonly data: T;
14
- readonly label?: any;
15
- readonly removeCondition?: (d: DrawingState) => boolean;
16
- };
17
- export declare type SelectionFilter<T = any> = (scope: SelectionScope, data: T) => boolean;
18
- export declare type CustomSelect = (selectorId: SelectorID, newItems: SelectedItem[], diff: SelectedItem[], options?: {
19
- [key: string]: any;
20
- }) => void;
21
- /**
22
- * Type for selector.
23
- *
24
- * @property {SelectionFilter} isSelectable - this function will be called for all potentially selectable objects. If it returns true for an object, this object can be selected by this selector.
25
- * @property {Array<SelectedItem<T>>} items - selected items.
26
- * @property {number} maxLen - maximum number of selected items.
27
- * @property {(selectorId: SelectorID, items: SelectedItem[]) => void} customSelect - if customSelect is provided, it overrides setting of new items in select(..) api method. In this case user is responsible to update selector.items via setItems.
28
- * @property {(selectorId: SelectorID, items: SelectedItem[]) => void} customUnSelect - if customSelect is provided, it overrides setting of new items in unselect(..) api method. In this case user is responsible to update selector.items via setItems.
29
- */
30
- export declare type Selector<T extends SeletedItemData<any> = any> = {
31
- readonly isSelectable: SelectionFilter;
32
- readonly items: Array<SelectedItem<T>>;
33
- readonly hoveredItem: SelectedItem<T> | null;
34
- readonly maxLen: number;
35
- readonly customSelect?: CustomSelect;
36
- readonly customUnSelect?: CustomSelect;
37
- };
38
- export declare type SelectionData = {
39
- readonly refs: Record<SelectorID, Selector>;
40
- readonly active: SelectorID | null;
41
- };
42
- export declare type SelectionApi = ReturnType<typeof selectionApi>;
43
- export declare const selectionData: () => SelectionData;
44
- export declare const selectionApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
45
- unselectAll(selectorId?: SelectorID, options?: {
46
- [key: string]: any;
47
- } | undefined): void;
48
- unselect(items: SelectedItem | SelectedItem[], selectorId?: SelectorID, options?: {
49
- [key: string]: any;
50
- } | undefined): void;
51
- select(items: SelectedItem | SelectedItem[], selectorId?: SelectorID, options?: {
52
- [key: string]: any;
53
- } | undefined): void;
54
- setHovered(item: SelectedItem | null, selectorId?: SelectorID): void;
55
- activateSelector(selectorId: SelectorID | null): void;
56
- createSelector(selectorId: SelectorID, filter: SelectionFilter, activate?: boolean, initialItems?: SelectedItem[], maxLen?: number, customSelect?: CustomSelect, customUnSelect?: CustomSelect): () => void;
57
- areItemsSelected: (items: SelectedItem[], selectorId?: SelectorID) => boolean;
58
- isItemSelected: (item: SelectedItem, selectorId?: SelectorID) => boolean;
59
- setItems(id: SelectorID, items: SelectedItem[]): void;
60
- selectGraphic: (selectorId: SelectorID, items: {
61
- productId: ObjectID;
62
- containerId: GraphicID;
63
- graphicId?: GraphicID;
64
- }[], options?: {
65
- unselectExisting?: boolean;
66
- }) => void;
67
- getGraphicItem: (productId: ObjectID, containerId: GraphicID, graphicId?: GraphicID) => SelectedItem<ProductElement> | null;
68
- };
69
- export declare const createGraphicItem: (productId: ObjectID, el: GeometryElement) => SelectedItem<ProductElement>;
1
+ import { StoreApi } from 'zustand';
2
+ import { GraphicID, ObjectID } from '../../re-export';
3
+ import { GeometryElement, ProductElement } from './../../geometry/ThreeGeometryCreator';
4
+ import { BuerliState } from './buerli';
5
+ import { DrawingState } from './drawing';
6
+ export declare const BuerliScope = "ClassCAD";
7
+ export declare type SelectorID = string | number;
8
+ export declare type SeletedItemData<T> = Record<string, T>;
9
+ export declare type SelectionScope = string | number;
10
+ export declare type SelectedItem<T extends SeletedItemData<any> = any> = {
11
+ readonly id: any;
12
+ readonly scope: SelectionScope;
13
+ readonly data: T;
14
+ readonly label?: any;
15
+ readonly removeCondition?: (d: DrawingState) => boolean;
16
+ };
17
+ export declare type SelectionFilter<T = any> = (scope: SelectionScope, data: T) => boolean;
18
+ export declare type CustomSelect = (selectorId: SelectorID, newItems: SelectedItem[], diff: SelectedItem[], options?: {
19
+ [key: string]: any;
20
+ }) => void;
21
+ /**
22
+ * Type for selector.
23
+ *
24
+ * @property {SelectionFilter} isSelectable - this function will be called for all potentially selectable objects. If it returns true for an object, this object can be selected by this selector.
25
+ * @property {Array<SelectedItem<T>>} items - selected items.
26
+ * @property {number} maxLen - maximum number of selected items.
27
+ * @property {(selectorId: SelectorID, items: SelectedItem[]) => void} customSelect - if customSelect is provided, it overrides setting of new items in select(..) api method. In this case user is responsible to update selector.items via setItems.
28
+ * @property {(selectorId: SelectorID, items: SelectedItem[]) => void} customUnSelect - if customSelect is provided, it overrides setting of new items in unselect(..) api method. In this case user is responsible to update selector.items via setItems.
29
+ */
30
+ export declare type Selector<T extends SeletedItemData<any> = any> = {
31
+ readonly isSelectable: SelectionFilter;
32
+ readonly items: Array<SelectedItem<T>>;
33
+ readonly hoveredItem: SelectedItem<T> | null;
34
+ readonly maxLen: number;
35
+ readonly customSelect?: CustomSelect;
36
+ readonly customUnSelect?: CustomSelect;
37
+ };
38
+ export declare type SelectionData = {
39
+ readonly refs: Record<SelectorID, Selector>;
40
+ readonly active: SelectorID | null;
41
+ };
42
+ export declare type SelectionApi = ReturnType<typeof selectionApi>;
43
+ export declare const selectionData: () => SelectionData;
44
+ export declare const selectionApi: (set: StoreApi<DrawingState>['setState'], get: StoreApi<DrawingState>['getState'], buerliApi: StoreApi<BuerliState>) => {
45
+ unselectAll(selectorId?: SelectorID, options?: {
46
+ [key: string]: any;
47
+ } | undefined): void;
48
+ unselect(items: SelectedItem | SelectedItem[], selectorId?: SelectorID, options?: {
49
+ [key: string]: any;
50
+ } | undefined): void;
51
+ select(items: SelectedItem | SelectedItem[], selectorId?: SelectorID, options?: {
52
+ [key: string]: any;
53
+ } | undefined): void;
54
+ setHovered(item: SelectedItem | null, selectorId?: SelectorID): void;
55
+ activateSelector(selectorId: SelectorID | null): void;
56
+ createSelector(selectorId: SelectorID, filter: SelectionFilter, activate?: boolean, initialItems?: SelectedItem[], maxLen?: number, customSelect?: CustomSelect, customUnSelect?: CustomSelect): () => void;
57
+ areItemsSelected: (items: SelectedItem[], selectorId?: SelectorID) => boolean;
58
+ isItemSelected: (item: SelectedItem, selectorId?: SelectorID) => boolean;
59
+ setItems(id: SelectorID, items: SelectedItem[]): void;
60
+ selectGraphic: (selectorId: SelectorID, items: {
61
+ productId: ObjectID;
62
+ containerId: GraphicID;
63
+ graphicId?: GraphicID;
64
+ }[], options?: {
65
+ unselectExisting?: boolean;
66
+ }) => void;
67
+ getGraphicItem: (productId: ObjectID, containerId: GraphicID, graphicId?: GraphicID) => SelectedItem<ProductElement> | null;
68
+ };
69
+ export declare const createGraphicItem: (productId: ObjectID, el: GeometryElement) => SelectedItem<ProductElement>;