@babylonjs/accessibility 6.24.0 → 6.25.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.
@@ -1,8 +1,20 @@
1
1
 
2
+ declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinAccessibilityItem" {
3
+ import { ReactElement } from "react";
4
+ import { HTMLTwinItem } from "@babylonjs/accessibility/HtmlTwin/htmlTwinItem";
5
+ export interface IHTMLTwinItemComponentProps {
6
+ description: string | undefined;
7
+ children: ReactElement[];
8
+ a11yItem: HTMLTwinItem;
9
+ }
10
+ export function HTMLTwinAccessibilityItem(props: IHTMLTwinItemComponentProps): JSX.Element;
11
+
12
+ }
2
13
  declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinGUIItem" {
3
14
  import { Scene } from "@babylonjs/core/scene";
4
15
  import { Control } from "@babylonjs/gui/2D/controls/control";
5
16
  import { HTMLTwinItem } from "@babylonjs/accessibility/HtmlTwin/htmlTwinItem";
17
+ import { IHTMLTwinRendererOptions } from "@babylonjs/accessibility/HtmlTwin/htmlTwinRenderer";
6
18
  /**
7
19
  * A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
8
20
  */
@@ -11,15 +23,12 @@ export class HTMLTwinGUIItem extends HTMLTwinItem {
11
23
  * The corresponding BabylonJS entity. Can be a Node or a Control.
12
24
  */
13
25
  entity: Control;
14
- /**
15
- * The children of this item in the html twin tree.
16
- */
17
- children: HTMLTwinGUIItem[];
18
- constructor(entity: Control, scene: Scene, children: HTMLTwinGUIItem[]);
26
+ constructor(entity: Control, scene: Scene);
19
27
  /**
20
28
  * The text content displayed in HTML element.
29
+ * @param options - Options to render HTML twin tree where this element is contained.
21
30
  */
22
- get description(): string;
31
+ getDescription(options: IHTMLTwinRendererOptions): string;
23
32
  /**
24
33
  * If this entity is actionable (can be clicked).
25
34
  */
@@ -58,24 +67,9 @@ interface IHTMLTwinHostComponentState {
58
67
  a11yTreeItems: HTMLTwinItem[];
59
68
  }
60
69
  export class HTMLTwinHostComponent extends React.Component<IHTMLTwinHostComponentProps, IHTMLTwinHostComponentState> {
61
- private _observersMap;
62
70
  private _options;
63
71
  constructor(props: IHTMLTwinHostComponentProps);
64
- componentDidUpdate(prevProps: Readonly<IHTMLTwinHostComponentProps>, prevState: Readonly<IHTMLTwinHostComponentState>, snapshot?: any): void;
65
- /**
66
- * Adds observables to update the tree if any of the scene's nodes or GUI controls change.
67
- */
68
- _addSceneObservers: () => void;
69
- componentDidMount(): void;
70
- componentWillUnmount(): void;
71
72
  render(): JSX.Element;
72
- private _updateHTMLTwinItems;
73
- private _getHTMLTwinItemsFromNodes;
74
- private _hasChildrenWithA11yTag;
75
- private _emptyTree;
76
- private _getHTMLTwinItemsFromGUI;
77
- private _isFullscreenGUI;
78
- private _isMeshGUI;
79
73
  }
80
74
  export {};
81
75
 
@@ -83,8 +77,31 @@ export {};
83
77
  declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinItem" {
84
78
  import { Node } from "@babylonjs/core/node";
85
79
  import { Scene } from "@babylonjs/core/scene";
80
+ import { AdvancedDynamicTexture } from "@babylonjs/gui/2D/advancedDynamicTexture";
86
81
  import { Control } from "@babylonjs/gui/2D/controls/control";
82
+ import { IHTMLTwinRendererOptions } from "@babylonjs/accessibility/HtmlTwin/htmlTwinRenderer";
83
+ /**
84
+ * The BabylonJS entities that can be accessible. It can be a Node or a Control.
85
+ */
87
86
  export type AccessibilityEntity = Node | Control;
87
+ /**
88
+ * Retrieve an instance of texture with accessible elements (AdvancedDynamicTexture)
89
+ * @param item the item to retrieve the texture from
90
+ * @returns an accessible texture if found, undefined otherwise
91
+ */
92
+ export function getAccessibleTexture(item: AccessibilityEntity): AdvancedDynamicTexture | undefined;
93
+ /**
94
+ * Get the direct children of an accessible item.
95
+ * @param item an accessible item
96
+ * @returns a list of accessible items
97
+ */
98
+ export function getDirectChildrenOf(item: AccessibilityEntity): AccessibilityEntity[];
99
+ /**
100
+ * Given an accessible item, return if it's visible or not.
101
+ * @param item an accessible item
102
+ * @returns its visibility status
103
+ */
104
+ export function isVisible(item: AccessibilityEntity): boolean;
88
105
  /**
89
106
  * A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
90
107
  */
@@ -97,16 +114,13 @@ export class HTMLTwinItem {
97
114
  * The BabylonJS scene that the corresponding BabylonJS entity is in.
98
115
  */
99
116
  scene: Scene;
100
- /**
101
- * The children of this item in the html twin tree.
102
- */
103
- children: HTMLTwinItem[];
104
- constructor(entity: AccessibilityEntity, scene: Scene, children: HTMLTwinItem[]);
117
+ constructor(entity: AccessibilityEntity, scene: Scene);
105
118
  /**
106
119
  * The text content displayed in HTML element.
107
120
  * Returns the description in accessibilityTag, if defined (returns "" by default).
121
+ * @param _options - The options to render the HTML twin tree where this item is contained. Not used in this class, but in its children.
108
122
  */
109
- get description(): string;
123
+ getDescription(_options: IHTMLTwinRendererOptions): string;
110
124
  /**
111
125
  * If this entity is actionable (can be clicked).
112
126
  * Implemented by child classes
@@ -137,6 +151,24 @@ export class HTMLTwinItem {
137
151
  protected _isFocusable: boolean;
138
152
  }
139
153
 
154
+ }
155
+ declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinItemAdapter" {
156
+ /// <reference types="react" />
157
+ import { AccessibilityEntity } from "@babylonjs/accessibility/HtmlTwin/htmlTwinItem";
158
+ import { Scene } from "@babylonjs/core/scene";
159
+ import { IHTMLTwinRendererOptions } from "@babylonjs/accessibility/HtmlTwin/htmlTwinRenderer";
160
+ /**
161
+ * An adapter that transforms a Accessible entity in a React element. Contains observables for the events that can
162
+ * change the state of the entity or the accesible tree.
163
+ * @param props the props of the adapter
164
+ * @returns
165
+ */
166
+ export function HTMLTwinItemAdapter(props: {
167
+ node: AccessibilityEntity;
168
+ scene: Scene;
169
+ options: IHTMLTwinRendererOptions;
170
+ }): JSX.Element | null;
171
+
140
172
  }
141
173
  declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinNodeItem" {
142
174
  import { Node } from "@babylonjs/core/node";
@@ -150,11 +182,7 @@ export class HTMLTwinNodeItem extends HTMLTwinItem {
150
182
  * The corresponding BabylonJS entity. Can be a Node or a Control.
151
183
  */
152
184
  entity: Node;
153
- /**
154
- * The children of this item in the html twin tree.
155
- */
156
- children: HTMLTwinItem[];
157
- constructor(entity: Node, scene: Scene, children: HTMLTwinItem[]);
185
+ constructor(entity: Node, scene: Scene);
158
186
  /**
159
187
  * If this entity is actionable (can be clicked).
160
188
  */
@@ -208,21 +236,30 @@ export class HTMLTwinRenderer {
208
236
  }
209
237
 
210
238
  }
211
- declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinTreeComponent" {
212
- import * as React from "react";
213
- import { HTMLTwinItem } from "@babylonjs/accessibility/HtmlTwin/htmlTwinItem";
214
- interface IHTMLTwinItemComponentProps {
215
- a11yItem: HTMLTwinItem;
216
- level: number;
239
+ declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinSceneContext" {
240
+ /// <reference types="react" />
241
+ /**
242
+ * Context used to update a scene when an entity is added or removed from the accessibility tree.
243
+ */
244
+ export interface ISceneContext {
245
+ updateScene: () => void;
217
246
  }
218
- export class HTMLTwinItemComponent extends React.Component<IHTMLTwinItemComponentProps> {
219
- constructor(props: IHTMLTwinItemComponentProps);
220
- render(): JSX.Element;
221
- private _renderLeafNode;
222
- private _renderParentNode;
223
- private _renderChildren;
247
+ export const SceneContext: import("react").Context<ISceneContext>;
248
+
224
249
  }
225
- export {};
250
+ declare module "@babylonjs/accessibility/HtmlTwin/htmlTwinSceneTree" {
251
+ /// <reference types="react" />
252
+ import { Scene } from "@babylonjs/core/scene";
253
+ import { IHTMLTwinRendererOptions } from "@babylonjs/accessibility/HtmlTwin/htmlTwinRenderer";
254
+ /**
255
+ * The scene tree of the HTML twin. It contain all the top level nodes
256
+ * @param props
257
+ * @returns
258
+ */
259
+ export function HTMLTwinSceneTree(props: {
260
+ scene: Scene;
261
+ options: IHTMLTwinRendererOptions;
262
+ }): JSX.Element;
226
263
 
227
264
  }
228
265
  declare module "@babylonjs/accessibility/HtmlTwin/index" {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/accessibility",
3
- "version": "6.24.0",
3
+ "version": "6.25.1",
4
4
  "main": "dist/babylon.accessibility.max.js",
5
5
  "module": "dist/babylon.accessibility.max.js",
6
6
  "esnext": "dist/babylon.accessibility.max.js",
@@ -24,8 +24,8 @@
24
24
  "@types/react-dom": ">=16.0.9"
25
25
  },
26
26
  "devDependencies": {
27
- "@babylonjs/core": "^6.24.0",
28
- "@babylonjs/gui": "^6.24.0",
27
+ "@babylonjs/core": "^6.25.1",
28
+ "@babylonjs/gui": "^6.25.1",
29
29
  "react": "^17.0.2",
30
30
  "react-dom": "^17.0.2"
31
31
  },