@refinitiv-ui/elements 7.10.10 → 7.11.0

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,5 +1,6 @@
1
- import type { CollectionComposer } from '@refinitiv-ui/utils/collection.js';
1
+ import { CollectionComposer } from '@refinitiv-ui/utils/collection.js';
2
2
  import type { TreeDataItem } from '../helpers/types';
3
+ import { TreeNode } from './tree-node.js';
3
4
  export declare enum CheckedState {
4
5
  CHECKED = 1,
5
6
  UNCHECKED = 0,
@@ -16,10 +17,11 @@ export declare enum TreeManagerMode {
16
17
  INDEPENDENT = 0
17
18
  }
18
19
  export declare class TreeManager<T extends TreeDataItem> {
20
+ private _composer;
19
21
  /**
20
- * Internal composer used for managing the data
22
+ * Collection composer used for managing the data
21
23
  */
22
- private composer;
24
+ get composer(): CollectionComposer<T>;
23
25
  /**
24
26
  * Mode (algorithm) the tree manage is using
25
27
  */
@@ -28,11 +30,27 @@ export declare class TreeManager<T extends TreeDataItem> {
28
30
  * Last selected item timestamp
29
31
  */
30
32
  private lastSelectedAt?;
33
+ /** Cache map of TreeNode improving performance */
34
+ private treeNodeCache;
31
35
  /**
32
- * @param composer CollectionComposer to be managed.
33
- * @param mode TreeManager mode which is Relational or Independent.
36
+ * Most of the time, there is no need to create a new instance of Tree Manager manually.
37
+ * Use the existing instance in components instead.
38
+ * @param input Items or CollectionComposer to be managed.
39
+ * @param mode A mode describing how items are managed either relationally or independently.
34
40
  */
35
- constructor(composer: CollectionComposer<T>, mode?: TreeManagerMode);
41
+ constructor(input: T[] | CollectionComposer<T>, mode?: TreeManagerMode);
42
+ /**
43
+ * Returns all items as an array of `TreeNode`.
44
+ * @returns Array of `TreeNode` representing all items
45
+ */
46
+ getTreeNodes(): TreeNode<T>[];
47
+ /**
48
+ * Returns a `TreeNode` of the original data item.
49
+ * If the item doesn't exist, returns `null`.
50
+ * @param item Original data item
51
+ * @returns `TreeNode` of the original data item or `null`
52
+ */
53
+ getTreeNode(item: T): TreeNode<T> | null;
36
54
  /**
37
55
  * Is the manager maintaining parent/child relationships
38
56
  */
@@ -42,11 +60,11 @@ export declare class TreeManager<T extends TreeDataItem> {
42
60
  */
43
61
  private get items();
44
62
  /**
45
- * Return all items which have children
63
+ * Returns all items with children
46
64
  */
47
65
  private get parentItems();
48
66
  /**
49
- * Returns all checked items.
67
+ * Returns all selected items.
50
68
  * When managing relationships, this excludes groups/parents from the result.
51
69
  */
52
70
  get checkedItems(): readonly T[];
@@ -55,8 +73,8 @@ export declare class TreeManager<T extends TreeDataItem> {
55
73
  */
56
74
  protected get orderBySelectedAt(): (itemA: T, itemB: T) => number;
57
75
  /**
58
- * Items which should be visibly displayed.
59
- * This can be used to render items.
76
+ * Returns items which their selected state can be changed.
77
+ * Hidden, disabled or readonly items are not included.
60
78
  */
61
79
  get editableItems(): readonly T[];
62
80
  /**
@@ -67,8 +85,8 @@ export declare class TreeManager<T extends TreeDataItem> {
67
85
  */
68
86
  private getEditableItems;
69
87
  /**
70
- * Items which should be visibly displayed.
71
- * This can be used to render items.
88
+ * Returns currently displayed items.
89
+ * Hidden and children of unexpanded items are not included.
72
90
  */
73
91
  get visibleItems(): readonly T[];
74
92
  /**
@@ -127,133 +145,138 @@ export declare class TreeManager<T extends TreeDataItem> {
127
145
  */
128
146
  private forceUpdateOnPath;
129
147
  /**
148
+ * TODO: find a way to keep `noRelation` of Tree & Tree Select component in-sync
130
149
  * Sets the mode (algorithm) the manager should use
150
+ * @hidden Mode updating doesn't sync back up Tree component.
131
151
  * @param mode Tree manager mode
132
152
  * @returns {void}
133
153
  */
134
154
  setMode(mode: TreeManagerMode): void;
135
155
  /**
136
- * Updates the data item, forcing a render
156
+ * Requests the item to be rerendered manually.
157
+ * Typically, this is not required. The render is triggered automatically when item's properties are updated.
137
158
  * @param item Original data item
138
159
  * @returns {void}
139
160
  */
140
161
  updateItem(item: T): void;
141
162
  /**
142
- * Includes an item as part of the tree.
143
- * @param item Item to include
163
+ * Shows the item.
164
+ * @hidden `hidden` usage in filterItems of Tree & Tree Select component conflicts with this API
165
+ * @param item Original data item
144
166
  * @returns `True` if the item is newly included
145
167
  */
146
168
  includeItem(item: T): boolean;
147
169
  /**
148
- * Excludes an item as part of the tree.
149
- * @param item Item to exclude
170
+ * Hides the item.
171
+ * @hidden `hidden` usage in filterItems of Tree & Tree Select component conflicts with this API
172
+ * @param item Original data item
150
173
  * @returns `True` if the item is newly excluded
151
174
  */
152
175
  excludeItem(item: T): boolean;
153
176
  /**
154
- * Is the item checkable?
177
+ * Returns whether the selected state of item can be changed or not.
155
178
  * @param item Original data item
156
179
  * @returns `True` if the item is not disabled or readonly
157
180
  */
158
181
  isItemCheckable(item: T): boolean;
159
182
  /**
160
- * Is the item expanded?
183
+ * Returns the current expanded state of the item.
161
184
  * @param item Original data item
162
- * @returns `True` if the item is expanded and its children should be visible
185
+ * @returns `True` if the item is currently expanded so its children are visible.
163
186
  */
164
187
  isItemExpanded(item: T): boolean;
165
188
  /**
166
- * Is the item a parent?
189
+ * Returns whether the item contains any children or not.
167
190
  * @param item Original data item
168
191
  * @returns `True` if the item has children
169
192
  */
170
193
  isItemParent(item: T): boolean;
171
194
  /**
172
- * Is the item a child?
195
+ * Returns whether the item has a parent or not.
173
196
  * @param item Original data item
174
197
  * @returns `True` if the item has a parent
175
198
  */
176
199
  isItemChild(item: T): boolean;
177
200
  /**
178
- * Calculates the checked stated of the item
201
+ * Return checked state of the item.
179
202
  * @param item Original data item
180
- * @returns Checked state of the item
203
+ * @returns item checked state: CHECKED (1), UNCHECKED (0), INDETERMINATE (-1)
181
204
  */
182
205
  getItemCheckedState(item: T): CheckedState;
183
206
  /**
184
- * Gets an item's ancestors
207
+ * Returns all ancestors of the item.
185
208
  * @param item Original data item
186
- * @returns A list of ancestors
209
+ * @returns An array of ancestors
187
210
  */
188
211
  getItemAncestors(item: T): readonly T[];
189
212
  /**
190
- * Gets an item's descendants
213
+ * Returns all descendants of the item.
191
214
  * @param item Original data item
192
- * @param depth Depth to retrieve
193
- * @returns A list of descendants
215
+ * @param depth Depth of descendants to get. If it's `undefined`, get all descendants.
216
+ * @returns An array of descendants
194
217
  */
195
218
  getItemDescendants(item: T, depth?: number): readonly T[];
196
219
  /**
197
- * Gets an item's parent, if it has one.
220
+ * Returns the parent of the item, if it has one.
198
221
  * @param item Original data item
199
222
  * @returns Item parent or `null`
200
223
  */
201
224
  getItemParent(item: T): T | null;
202
225
  /**
203
- * Gets an item's child collection
226
+ * Returns the children of the item as an array.
204
227
  * @param item Original data item
205
- * @returns A list of children
228
+ * @returns An array of children
206
229
  */
207
230
  getItemChildren(item: T): readonly T[];
208
231
  /**
209
- * Expand an item to show its children
232
+ * Expands the item to show its children.
210
233
  * @param item Original data item
211
234
  * @returns {void}
212
235
  */
213
236
  expandItem(item: T): void;
214
237
  /**
215
- * Collapse an item to hide its children
238
+ * Collapses the item to hide its children.
216
239
  * @param item Original data item
217
240
  * @returns {void}
218
241
  */
219
242
  collapseItem(item: T): void;
220
243
  /**
221
- * Expands all items in the tree
244
+ * Expands all items.
222
245
  * @returns {void}
223
246
  */
224
247
  expandAllItems(): void;
225
248
  /**
226
- * Collapses all items in the tree
249
+ * Collapses all items.
227
250
  * @returns {void}
228
251
  */
229
252
  collapseAllItems(): void;
230
253
  /**
231
- * Checks the item
254
+ * Selects the item.
232
255
  * @param item Original data item
233
256
  * @returns `True` if the item is modified
234
257
  */
235
258
  checkItem(item: T): boolean;
236
259
  private _checkItem;
237
260
  /**
238
- * Unchecks the item
261
+ * Deselects the item.
239
262
  * @param item Original data item
240
263
  * @returns `True` if the item is modified
241
264
  */
242
265
  uncheckItem(item: T): boolean;
243
266
  private _uncheckItem;
244
267
  /**
245
- * Toggles the item checked state
268
+ * Toggle the selected state of the item.
246
269
  * @param item Original data item
247
- * @returns `True` if the item is modified
270
+ * @returns `true` if the item is modified successfully.
248
271
  */
249
272
  toggleItem(item: T): boolean;
250
273
  /**
251
- * Checks all items
274
+ * Selects all items.
252
275
  * @returns {void}
253
276
  */
254
277
  checkAllItems(): void;
255
278
  /**
256
- * Unchecks all items
279
+ * Deselects all items.
257
280
  * @returns {void}
258
281
  */
259
282
  uncheckAllItems(): void;