vim-web 0.3.27-dev.1 → 0.3.27-dev.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.
@@ -1,40 +1,100 @@
1
+ /**
2
+ * @fileoverview This file exports types and a React hook for customizing the rendering
3
+ * and data handling of a BIM info panel. The hook provides references for customizing
4
+ * how data is processed and rendered in different sections of the BIM info panel.
5
+ */
1
6
  import * as VIM from '../../core-viewers/webgl/index';
7
+ /**
8
+ * Represents an entry in the BIM info panel, such as a key-value pair in a header or body section.
9
+ */
2
10
  export type Entry = {
11
+ /**
12
+ * The key of the entry, often used as a label or an identifier for the data.
13
+ */
3
14
  key: string | undefined;
15
+ /**
16
+ * The label or display name for the entry, shown to the user.
17
+ */
4
18
  label: string | undefined;
19
+ /**
20
+ * The value of the entry, displayed to the user.
21
+ */
5
22
  value: string | undefined;
6
23
  };
24
+ /**
25
+ * Represents a group of entries within a body section of the BIM info panel.
26
+ */
7
27
  export type Group = {
28
+ /**
29
+ * The unique identifier for this group.
30
+ */
8
31
  key: string | undefined;
32
+ /**
33
+ * The title or name displayed for this group.
34
+ */
9
35
  title: string | undefined;
36
+ /**
37
+ * An array of entries that belong to this group.
38
+ */
10
39
  content: Entry[];
11
40
  };
41
+ /**
42
+ * Represents a section of the body, containing one or more groups of entries.
43
+ */
12
44
  export type Section = {
45
+ /**
46
+ * The unique identifier for this section.
47
+ */
13
48
  key: string | undefined;
49
+ /**
50
+ * The title displayed for this section.
51
+ */
14
52
  title: string;
53
+ /**
54
+ * An array of groups that this section contains.
55
+ */
15
56
  content: Group[];
16
57
  };
58
+ /**
59
+ * Represents the entire data set for the BIM info panel, including the header and body sections.
60
+ */
17
61
  export type Data = {
62
+ /**
63
+ * The header of the BIM info panel, typically a list of entries summarizing key information.
64
+ */
18
65
  header: Entry[] | undefined;
66
+ /**
67
+ * The body of the BIM info panel, typically containing one or more sections of grouped entries.
68
+ */
19
69
  body: Section[] | undefined;
20
70
  };
21
71
  /**
22
- * Data customization function for the BIM info panel.
23
- * @data The data to customize.
24
- * @source The VIM.Object or VIM.Vim from which the data was pulled.
72
+ * A customization function for modifying the panel data before rendering. It allows
73
+ * developers to transform, filter, or augment the data pulled from a VIM source.
74
+ *
75
+ * @param data - The data to customize.
76
+ * @param source - The VIM.Object or VIM.Vim instance from which the data was originally extracted.
77
+ * @returns A promise that resolves to the modified Data object.
25
78
  */
26
79
  export type DataCustomization = (data: Data, source: VIM.Vim | VIM.Object3D) => Promise<Data>;
27
80
  /**
28
- * Rendering customization function for the BIM info panel.
29
- * @data The data to render.
30
- * @standard The standard rendering function for the data.
81
+ * A rendering customization function that takes props containing data and a standard
82
+ * rendering function, and returns a custom JSX element. This function enables developers
83
+ * to override how data is rendered in different parts of the BIM info panel.
84
+ *
85
+ * @typeParam T - The type of data to render.
86
+ * @param props.data - The data to render.
87
+ * @param props.standard - The standard rendering function for the data.
88
+ * @returns A custom JSX element to render, or `undefined` to use the default rendering.
31
89
  */
32
90
  export type DataRender<T> = ((props: {
33
91
  data: T;
34
92
  standard: () => JSX.Element;
35
93
  }) => JSX.Element) | undefined;
36
94
  /**
37
- * Reference object for customizing the rendering of the BIM info panel.
95
+ * A reference object exposing multiple customization callbacks for transforming data and rendering
96
+ * different parts of the BIM info panel. These callbacks can be updated at runtime and will be used
97
+ * the next time the panel re-renders.
38
98
  */
39
99
  export type BimInfoPanelRef = {
40
100
  /**
@@ -74,4 +134,11 @@ export type BimInfoPanelRef = {
74
134
  */
75
135
  onRenderBodyEntryValue: DataRender<Entry>;
76
136
  };
77
- export declare function createBimInfoState(): BimInfoPanelRef;
137
+ /**
138
+ * A React hook that provides a reference object for customizing the data and rendering
139
+ * of a BIM info panel. This hook maintains internal state for each customization callback,
140
+ * allowing dynamic updates at runtime.
141
+ *
142
+ * @returns A {@link BimInfoPanelRef} object containing getters and setters for each customization callback.
143
+ */
144
+ export declare function useBimInfo(): BimInfoPanelRef;
@@ -4,7 +4,7 @@
4
4
  /**
5
5
  * Basic HTML structure that the webgl component expects
6
6
  */
7
- export type VimComponentContainer = {
7
+ export type Container = {
8
8
  /**
9
9
  * Root of the viewer, all component ui should have this as an acestor.
10
10
  */
@@ -24,4 +24,4 @@ export type VimComponentContainer = {
24
24
  * The element is created if not provided. The element will be made position:absolute.
25
25
  * @element optional HTML element to use as root
26
26
  */
27
- export declare function createContainer(element?: HTMLElement): VimComponentContainer;
27
+ export declare function createContainer(element?: HTMLElement): Container;
@@ -7,8 +7,7 @@ import { Isolation } from '../helpers/isolation';
7
7
  import { ComponentCamera } from '../helpers/camera';
8
8
  import { TreeActionRef } from '../bim/bimTree';
9
9
  import { ModalRef } from './modal';
10
- export declare const VIM_CONTEXT_MENU_ID = "vim-context-menu-id";
11
- export type ClickCallback = React.MouseEvent<HTMLDivElement, MouseEvent>;
10
+ type ClickCallback = React.MouseEvent<HTMLDivElement, MouseEvent>;
12
11
  export declare function showContextMenu(position: {
13
12
  x: number;
14
13
  y: number;
@@ -73,3 +72,4 @@ export declare function VimContextMenu(props: {
73
72
  customization?: (e: ContextMenuElement[]) => ContextMenuElement[];
74
73
  treeRef: React.MutableRefObject<TreeActionRef | undefined>;
75
74
  }): import("react/jsx-runtime").JSX.Element;
75
+ export {};
@@ -1,22 +1,35 @@
1
1
  /**
2
2
  * @module viw-webgl-react
3
+ * Contains settings and type definitions for the Vim web component
3
4
  */
4
5
  /**
5
6
  * Makes all fields optional recursively
6
- * https://stackoverflow.com/questions/41980195/recursive-partialt-in-typescript
7
+ * @template T - The type to make recursively partial
8
+ * @returns A type with all nested properties made optional
7
9
  */
8
10
  export type RecursivePartial<T> = {
9
11
  [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
10
12
  };
11
13
  /**
12
- * true, false or restricted
13
- * Restricted: is false and cannot be changed by the user.
14
+ * Represents a boolean value that can also be locked to always true or false
15
+ * @typedef {boolean | 'AlwaysTrue' | 'AlwaysFalse'} UserBoolean
14
16
  */
15
17
  export type UserBoolean = boolean | 'AlwaysTrue' | 'AlwaysFalse';
18
+ /**
19
+ * Checks if a UserBoolean value is effectively true
20
+ * @param {UserBoolean | boolean} value - The value to check
21
+ * @returns {boolean} True if the value is true or 'AlwaysTrue'
22
+ */
16
23
  export declare function isTrue(value: UserBoolean | boolean): value is true | "AlwaysTrue";
24
+ /**
25
+ * Checks if a UserBoolean value is effectively false
26
+ * @param {UserBoolean | boolean} value - The value to check
27
+ * @returns {boolean} True if the value is false or 'AlwaysFalse'
28
+ */
17
29
  export declare function isFalse(value: UserBoolean | boolean): value is false | "AlwaysFalse";
18
30
  /**
19
- * Vim component settings, can either be set at component intialization or by user using UI.
31
+ * Complete settings configuration for the Vim component
32
+ * @interface ComponentSettings
20
33
  */
21
34
  export type ComponentSettings = {
22
35
  peformance: {
@@ -57,9 +70,37 @@ export type ComponentSettings = {
57
70
  maximise: UserBoolean;
58
71
  };
59
72
  };
73
+ /**
74
+ * Partial version of ComponentSettings where all properties are optional
75
+ */
60
76
  export type PartialComponentSettings = RecursivePartial<ComponentSettings>;
77
+ /**
78
+ * Checks if any axes-related UI buttons are enabled
79
+ * @param {ComponentSettings} settings - The component settings to check
80
+ * @returns {boolean} True if any axes buttons are enabled
81
+ */
61
82
  export declare function anyUiAxesButton(settings: ComponentSettings): UserBoolean;
83
+ /**
84
+ * Checks if any cursor-related UI buttons are enabled
85
+ * @param {ComponentSettings} settings - The component settings to check
86
+ * @returns {boolean} True if any cursor buttons are enabled
87
+ */
62
88
  export declare function anyUiCursorButton(settings: ComponentSettings): boolean;
89
+ /**
90
+ * Checks if any tool-related UI buttons are enabled
91
+ * @param {ComponentSettings} settings - The component settings to check
92
+ * @returns {boolean} True if any tool buttons are enabled
93
+ */
63
94
  export declare function anyUiToolButton(settings: ComponentSettings): boolean;
95
+ /**
96
+ * Checks if any settings-related UI buttons are enabled
97
+ * @param {ComponentSettings} settings - The component settings to check
98
+ * @returns {boolean} True if any settings buttons are enabled
99
+ */
64
100
  export declare function anyUiSettingButton(settings: ComponentSettings): boolean;
101
+ /**
102
+ * Default settings configuration for the Vim component
103
+ * @constant
104
+ * @type {ComponentSettings}
105
+ */
65
106
  export declare const defaultSettings: ComponentSettings;
@@ -2,5 +2,14 @@
2
2
  * @module viw-webgl-react
3
3
  */
4
4
  import { ComponentSettings, PartialComponentSettings } from './settings';
5
+ /**
6
+ * Retrieves component settings from localStorage and applies permissions
7
+ * @param settings - Partial component settings to apply permissions from
8
+ * @returns The stored settings with applied permissions, or empty object if retrieval fails
9
+ */
5
10
  export declare function getLocalSettings(settings?: PartialComponentSettings): {};
11
+ /**
12
+ * Saves component settings to localStorage after removing permissions
13
+ * @param value - Component settings to save
14
+ */
6
15
  export declare function saveSettingsToLocal(value: ComponentSettings): void;
@@ -4,7 +4,7 @@
4
4
  import React from 'react';
5
5
  import * as VIM from '../../core-viewers/webgl/index';
6
6
  import { SideState } from './sideState';
7
- import { VimComponentContainer } from '../container';
7
+ import { Container } from '../container';
8
8
  /**
9
9
  * Memoized version of the SidePanel.
10
10
  */
@@ -13,7 +13,7 @@ export declare const SidePanelMemo: React.MemoExoticComponent<typeof SidePanel>;
13
13
  * JSX Component for collapsible and resizable side panel.
14
14
  */
15
15
  export declare function SidePanel(props: {
16
- container: VimComponentContainer;
16
+ container: Container;
17
17
  side: SideState;
18
18
  viewer: VIM.Viewer;
19
19
  content: () => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import * as Ultra from '../../core-viewers/ultra/index';
2
- import { VimComponentContainer } from '../container';
2
+ import { Container } from '../container';
3
3
  import { ModalRef } from '../panels/modal';
4
4
  export type UltraComponentRef = {
5
5
  viewer: Ultra.Viewer;
@@ -14,7 +14,7 @@ export type UltraComponentRef = {
14
14
  * @param viewerSettings Viewer settings.
15
15
  * @returns An object containing the resulting container, reactRoot, and viewer.
16
16
  */
17
- export declare function createUltraComponent(container?: VimComponentContainer | HTMLElement): Promise<UltraComponentRef>;
17
+ export declare function createUltraComponent(container?: Container | HTMLElement): Promise<UltraComponentRef>;
18
18
  /**
19
19
  * Represents a React component providing UI for the Vim viewer.
20
20
  * @param container The container object containing root, gfx, and UI elements for the Vim viewer.
@@ -23,7 +23,7 @@ export declare function createUltraComponent(container?: VimComponentContainer |
23
23
  * @param settings Optional settings for configuring the Vim component's behavior.
24
24
  */
25
25
  export declare function UltraComponent(props: {
26
- container: VimComponentContainer;
26
+ container: Container;
27
27
  viewer: Ultra.Viewer;
28
28
  onMount: (component: UltraComponentRef) => void;
29
29
  }): import("react/jsx-runtime").JSX.Element;
@@ -4,8 +4,8 @@ export * as ContextMenu from '../panels/contextMenu';
4
4
  export * as BimInfo from '../bim/bimInfoData';
5
5
  export * as ControlBar from '../controlbar/controlBar';
6
6
  export * as Icons from '../panels/icons';
7
- export * from '../helpers/loadRequest';
8
- export * from './webglComponentRef';
7
+ export { LoadRequest } from '../helpers/loadRequest';
8
+ export * as Refs from './webglComponentRef';
9
9
  export { getLocalSettings as getLocalSettings } from '../settings/settingsStorage';
10
10
  export { type ComponentSettings as Settings, type PartialComponentSettings as PartialSettings, defaultSettings } from '../settings/settings';
11
11
  export * from '../container';
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as VIM from '../../core-viewers/webgl/index';
5
5
  import { PartialComponentSettings } from '../settings/settings';
6
- import { VimComponentContainer } from '../container';
6
+ import { Container } from '../container';
7
7
  import { VimComponentRef } from './webglComponentRef';
8
8
  /**
9
9
  * Creates a UI container along with a VIM.Viewer and its associated React component.
@@ -12,7 +12,7 @@ import { VimComponentRef } from './webglComponentRef';
12
12
  * @param viewerSettings Viewer settings.
13
13
  * @returns An object containing the resulting container, reactRoot, and viewer.
14
14
  */
15
- export declare function createWebglComponent(container?: VimComponentContainer | HTMLElement, componentSettings?: PartialComponentSettings, viewerSettings?: VIM.PartialViewerSettings): Promise<VimComponentRef>;
15
+ export declare function createWebglComponent(container?: Container | HTMLElement, componentSettings?: PartialComponentSettings, viewerSettings?: VIM.PartialViewerSettings): Promise<VimComponentRef>;
16
16
  /**
17
17
  * Represents a React component providing UI for the Vim viewer.
18
18
  * @param container The container object containing root, gfx, and UI elements for the Vim viewer.
@@ -21,7 +21,7 @@ export declare function createWebglComponent(container?: VimComponentContainer |
21
21
  * @param settings Optional settings for configuring the Vim component's behavior.
22
22
  */
23
23
  export declare function VimComponent(props: {
24
- container: VimComponentContainer;
24
+ container: Container;
25
25
  viewer: VIM.Viewer;
26
26
  onMount: (component: VimComponentRef) => void;
27
27
  settings?: PartialComponentSettings;
@@ -6,7 +6,7 @@ import { ContextMenuCustomization } from '../panels/contextMenu';
6
6
  import { ComponentSettings } from '../settings/settings';
7
7
  import { Isolation } from '../helpers/isolation';
8
8
  import { ComponentCamera } from '../helpers/camera';
9
- import { VimComponentContainer } from '../container';
9
+ import { Container } from '../container';
10
10
  import { BimInfoPanelRef } from '../bim/bimInfoData';
11
11
  import { ControlBarCustomization } from '../controlbar/controlBar';
12
12
  import { ComponentLoader } from './webglLoading';
@@ -26,30 +26,41 @@ export type SettingsRef = {
26
26
  */
27
27
  register: (callback: (settings: ComponentSettings) => void) => void;
28
28
  };
29
+ /**
30
+ * Reference to manage context menu functionality in the component.
31
+ */
29
32
  export type ContextMenuRef = {
30
33
  /**
31
- * Defines a callback function to dynamically customize the context menu.
32
- * @param customization The configuration object specifying the customization options for the context menu.
33
- */
34
+ * Defines a callback function to dynamically customize the context menu.
35
+ * @param customization The configuration object specifying the customization options for the context menu.
36
+ */
34
37
  customize: (customization: ContextMenuCustomization) => void;
35
38
  };
39
+ /**
40
+ * Reference to manage control bar functionality in the component.
41
+ */
36
42
  export type ControlBarRef = {
37
43
  /**
38
- * Defines a callback function to dynamically customize the control bar.
39
- * @param customization The configuration object specifying the customization options for the control bar.
40
- */
44
+ * Defines a callback function to dynamically customize the control bar.
45
+ * @param customization The configuration object specifying the customization options for the control bar.
46
+ */
41
47
  customize: (customization: ControlBarCustomization) => void;
42
48
  };
49
+ /**
50
+ * Reference to manage help message functionality in the component.
51
+ */
43
52
  export type HelpRef = {
44
53
  /**
45
54
  * Displays the help message.
46
55
  * @param value Boolean value to show or hide the help message.
56
+ * @returns void
47
57
  */
48
- show(value: boolean): any;
58
+ show(value: boolean): void;
49
59
  /**
50
60
  * Returns the current state of the help message.
61
+ * @returns boolean indicating if help message is currently shown
51
62
  */
52
- isShow(): any;
63
+ isShow(): boolean;
53
64
  };
54
65
  /**
55
66
  * Root-level API of the Vim component.
@@ -58,42 +69,45 @@ export type VimComponentRef = {
58
69
  /**
59
70
  * HTML structure containing the component.
60
71
  */
61
- container: VimComponentContainer;
72
+ container: Container;
62
73
  /**
63
- * Vim WebGL viewer around which the WebGL component is built.
64
- */
74
+ * Vim WebGL viewer around which the WebGL component is built.
75
+ */
65
76
  viewer: VIM.Viewer;
66
77
  /**
67
- * Vim WebGL loader to download VIMs.
68
- */
78
+ * Vim WebGL loader to download VIMs.
79
+ */
69
80
  loader: ComponentLoader;
70
81
  /**
71
- * Isolation API managing isolation state in the component.
72
- */
82
+ * Isolation API managing isolation state in the component.
83
+ */
73
84
  isolation: Isolation;
74
85
  /**
75
- * Context menu API managing the content and behavior of the context menu.
76
- */
86
+ * Context menu API managing the content and behavior of the context menu.
87
+ */
77
88
  contextMenu: ContextMenuRef;
78
89
  /**
79
- * Context menu API managing the content and behavior of the context menu.
80
- */
90
+ * Control bar API managing the content and behavior of the control bar.
91
+ */
81
92
  controlBar: ControlBarRef;
82
93
  /**
83
- * Settings API managing settings applied to the component.
84
- */
94
+ * Settings API managing settings applied to the component.
95
+ */
85
96
  settings: SettingsRef;
86
97
  /**
87
- * Message API to interact with the loading box.
88
- */
98
+ * Message API to interact with the loading box.
99
+ */
89
100
  modal: ModalRef;
90
101
  /**
91
- * Camera API to interact with the viewer camera at a higher level.
92
- */
102
+ * Camera API to interact with the viewer camera at a higher level.
103
+ */
93
104
  camera: ComponentCamera;
94
105
  /**
95
106
  * API To interact with the BIM info panel.
96
107
  */
97
108
  bimInfo: BimInfoPanelRef;
109
+ /**
110
+ * Cleans up and releases resources used by the component.
111
+ */
98
112
  dispose: () => void;
99
113
  };