@itwin/presentation-hierarchies-react 2.0.0-alpha.52 → 2.0.0-alpha.54

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 (98) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +62 -55
  3. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -1
  4. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +33 -29
  5. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  6. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +27 -16
  7. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  8. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +181 -54
  9. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  10. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +12 -6
  11. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -1
  12. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +54 -49
  13. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -1
  14. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +7 -30
  15. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  16. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +116 -74
  17. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  18. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +67 -54
  19. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  20. package/lib/esm/presentation-hierarchies-react/UseTree.js +283 -226
  21. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  22. package/lib/esm/presentation-hierarchies-react/Utils.js +44 -27
  23. package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -1
  24. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +6 -7
  25. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -1
  26. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +271 -298
  27. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  28. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +91 -82
  29. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  30. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -47
  31. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +114 -151
  32. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  33. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +32 -37
  34. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  35. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +128 -101
  36. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  37. package/lib/esm/presentation-hierarchies-react/internal/Utils.js +29 -44
  38. package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +1 -1
  39. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +24 -13
  40. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -1
  41. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +344 -67
  42. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
  43. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +16 -15
  44. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -1
  45. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +78 -60
  46. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
  47. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +122 -117
  48. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -1
  49. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +59 -38
  50. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -1
  51. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -5
  52. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -1
  53. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +161 -35
  54. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -1
  55. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +21 -17
  56. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -1
  57. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +84 -31
  58. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -1
  59. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +22 -14
  60. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
  61. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +61 -26
  62. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
  63. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +15 -6
  64. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -1
  65. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +75 -25
  66. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
  67. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +16 -40
  68. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
  69. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +140 -61
  70. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
  71. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -42
  72. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
  73. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +489 -121
  74. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
  75. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +58 -55
  76. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
  77. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +412 -181
  78. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
  79. package/lib/esm/presentation-hierarchies-react.d.ts +17 -17
  80. package/lib/esm/presentation-hierarchies-react.js +15 -18
  81. package/package.json +17 -14
  82. package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
  83. package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
  84. package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
  85. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
  86. package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
  87. package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
  88. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
  89. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
  90. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
  91. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
  92. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
  93. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
  94. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
  95. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
  96. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
  97. package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
  98. package/lib/esm/presentation-hierarchies-react.js.map +0 -1
@@ -1,73 +1,91 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- import { useMemo } from "react";
1
+ import { c } from "react-compiler-runtime";
2
+
3
+ //#region src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts
6
4
  /** @alpha */
7
- export function isPlaceholderItem(item) {
8
- return "placeholder" in item;
5
+ function isPlaceholderItem(item) {
6
+ return "placeholder" in item;
9
7
  }
10
8
  /**
11
- * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
12
- * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
13
- * virtualized list.
14
- *
15
- * @alpha
16
- */
17
- export function useFlatTreeItems(rootNodes) {
18
- return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);
9
+ * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
10
+ * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
11
+ * virtualized list.
12
+ *
13
+ * @alpha
14
+ */
15
+ function useFlatTreeItems(rootNodes) {
16
+ const $ = c(2);
17
+ let t0;
18
+ if ($[0] !== rootNodes) {
19
+ t0 = getFlatItems(rootNodes, 1);
20
+ $[0] = rootNodes;
21
+ $[1] = t0;
22
+ } else t0 = $[1];
23
+ return t0;
19
24
  }
20
25
  function getFlatItems(nodes, level) {
21
- const flatItems = [];
22
- nodes.forEach((node, index) => {
23
- flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });
24
- if (!node.isExpanded || node.error) {
25
- return;
26
- }
27
- if (node.children !== true) {
28
- const childNodes = getFlatItems(node.children, level + 1);
29
- flatItems.push(...childNodes);
30
- return;
31
- }
32
- flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true });
33
- });
34
- return flatItems;
26
+ const flatItems = [];
27
+ nodes.forEach((node, index) => {
28
+ flatItems.push({
29
+ node,
30
+ id: node.id,
31
+ level,
32
+ levelSize: nodes.length,
33
+ posInLevel: index + 1
34
+ });
35
+ if (!node.isExpanded || node.error) return;
36
+ if (node.children !== true) {
37
+ const childNodes = getFlatItems(node.children, level + 1);
38
+ flatItems.push(...childNodes);
39
+ return;
40
+ }
41
+ flatItems.push({
42
+ id: `${node.id}-children-placeholder`,
43
+ level: level + 1,
44
+ placeholder: true
45
+ });
46
+ });
47
+ return flatItems;
35
48
  }
36
49
  /**
37
- * Finds and returns all nodes containing errors in a given hierarchy.
38
- *
39
- * @alpha
40
- */
41
- export function useErrorNodes(rootNodes) {
42
- return useMemo(() => rootNodes.flatMap((rootNode) => {
43
- if (isErrorNode(rootNode)) {
44
- return [rootNode];
45
- }
46
- if (rootNode.children === true) {
47
- return [];
48
- }
49
- return getErrorNodes(rootNode);
50
- }), [rootNodes]);
50
+ * Finds and returns all nodes containing errors in a given hierarchy.
51
+ *
52
+ * @alpha
53
+ */
54
+ function useErrorNodes(rootNodes) {
55
+ const $ = c(2);
56
+ let t0;
57
+ if ($[0] !== rootNodes) {
58
+ t0 = rootNodes.flatMap(_temp);
59
+ $[0] = rootNodes;
60
+ $[1] = t0;
61
+ } else t0 = $[1];
62
+ return t0;
63
+ }
64
+ function _temp(rootNode) {
65
+ if (isErrorNode(rootNode)) return [rootNode];
66
+ if (rootNode.children === true) return [];
67
+ return getErrorNodes(rootNode);
51
68
  }
52
69
  function getErrorNodes(parent) {
53
- const errorList = [];
54
- if (parent.children === true) {
55
- return [];
56
- }
57
- parent.children.forEach((node) => {
58
- if (isErrorNode(node)) {
59
- errorList.push(node);
60
- return;
61
- }
62
- if (node.children !== true) {
63
- const childErrorList = getErrorNodes(node);
64
- errorList.push(...childErrorList);
65
- return;
66
- }
67
- });
68
- return errorList;
70
+ const errorList = [];
71
+ if (parent.children === true) return [];
72
+ parent.children.forEach((node) => {
73
+ if (isErrorNode(node)) {
74
+ errorList.push(node);
75
+ return;
76
+ }
77
+ if (node.children !== true) {
78
+ const childErrorList = getErrorNodes(node);
79
+ errorList.push(...childErrorList);
80
+ return;
81
+ }
82
+ });
83
+ return errorList;
69
84
  }
70
85
  function isErrorNode(node) {
71
- return node.error !== undefined;
86
+ return node.error !== void 0;
72
87
  }
88
+
89
+ //#endregion
90
+ export { isPlaceholderItem, useErrorNodes, useFlatTreeItems };
73
91
  //# sourceMappingURL=FlatTreeNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAmChC,aAAa;AACb,MAAM,UAAU,iBAAiB,CAAC,IAAkB;IAClD,OAAO,aAAa,IAAI,IAAI,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAqB;IACpD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CAAC,KAAiB,EAAE,KAAa;IACpD,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7F,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC1D,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAAgC,CAAC,CAAC;IAC/H,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAqB;IACjD,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7B,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpB,CAAC;QACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CAAC,EACJ,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAgB;IACrC,MAAM,SAAS,GAAqC,EAAE,CAAC;IAEvD,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YAC3C,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,IAAc;IACjC,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;AAClC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { TreeNode } from \"../TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `TreeNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: TreeNode;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: TreeNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: TreeNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded || node.error) {\n return;\n }\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all nodes containing errors in a given hierarchy.\n *\n * @alpha\n */\nexport function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, \"error\">> {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [rootNode];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorNodes(rootNode);\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorNodes(parent: TreeNode) {\n const errorList: ReturnType<typeof useErrorNodes> = [];\n\n if (parent.children === true) {\n return [];\n }\n\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push(node);\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction isErrorNode(node: TreeNode): node is TreeNode & Pick<Required<TreeNode>, \"error\"> {\n return node.error !== undefined;\n}\n"]}
1
+ {"version":3,"file":"FlatTreeNode.js","names":["useMemo","TreeNode","FlatPlaceholderItem","id","level","placeholder","FlatTreeNodeItem","levelSize","posInLevel","node","FlatTreeItem","isPlaceholderItem","item","useFlatTreeItems","rootNodes","$","_c","t0","getFlatItems","nodes","flatItems","forEach","index","push","length","isExpanded","error","children","childNodes","useErrorNodes","flatMap","_temp","rootNode","isErrorNode","getErrorNodes","parent","errorList","ReturnType","childErrorList","Pick","Required","undefined"],"sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\n\nimport type { TreeNode } from \"../TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `TreeNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: TreeNode;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: TreeNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: TreeNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded || node.error) {\n return;\n }\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all nodes containing errors in a given hierarchy.\n *\n * @alpha\n */\nexport function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, \"error\">> {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [rootNode];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorNodes(rootNode);\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorNodes(parent: TreeNode) {\n const errorList: ReturnType<typeof useErrorNodes> = [];\n\n if (parent.children === true) {\n return [];\n }\n\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push(node);\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction isErrorNode(node: TreeNode): node is TreeNode & Pick<Required<TreeNode>, \"error\"> {\n return node.error !== undefined;\n}\n"],"mappings":";;;;AA0CA,SAAgBW,kBAAkBC,MAAiD;AACjF,QAAO,iBAAiBA;;;;;;;;;AAU1B,SAAOC,iBAAAC,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AACgBG,OAAAC,aAAaJ,WAAW,EAAE;AAAAC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QAA1BE;;AAGvB,SAASC,aAAaC,OAAmBf,OAAe;CACtD,MAAMgB,YAA4B,EAAE;AACpCD,OAAME,SAASZ,MAAMa,UAAU;AAC7BF,YAAUG,KAAK;GAAEd;GAAMN,IAAIM,KAAKN;GAAIC;GAAOG,WAAWY,MAAMK;GAAQhB,YAAYc,QAAQ;GAAG,CAAC;AAC5F,MAAI,CAACb,KAAKgB,cAAchB,KAAKiB,MAC3B;AAEF,MAAIjB,KAAKkB,aAAa,MAAM;GAC1B,MAAMC,aAAaV,aAAaT,KAAKkB,UAAUvB,QAAQ,EAAE;AACzDgB,aAAUG,KAAK,GAAGK,WAAW;AAC7B;;AAGFR,YAAUG,KAAK;GAAEpB,IAAI,GAAGM,KAAKN,GAAE;GAAyBC,OAAOA,QAAQ;GAAGC,aAAa;GAAM,CAA+B;GAC5H;AACF,QAAOe;;;;;;;AAQT,SAAOS,cAAAf,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AAGDG,OAAAH,UAASgB,QAASC,MAQhB;AAAAhB,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QARFE;;AAHC,SAAAc,MAAAC,UAAA;AAIC,KAAIC,YAAYD,SAAS,CAAA,QAChB,CAACA,SAAS;AAEnB,KAAIA,SAAQL,aAAc,KAAI,QACrB,EAAE;AACV,QACMO,cAAcF,SAAS;;AAMtC,SAASE,cAAcC,QAAkB;CACvC,MAAMC,YAA8C,EAAE;AAEtD,KAAID,OAAOR,aAAa,KACtB,QAAO,EAAE;AAGXQ,QAAOR,SAASN,SAASZ,SAAS;AAChC,MAAIwB,YAAYxB,KAAK,EAAE;AACrB2B,aAAUb,KAAKd,KAAK;AACpB;;AAGF,MAAIA,KAAKkB,aAAa,MAAM;GAC1B,MAAMW,iBAAiBJ,cAAczB,KAAK;AAC1C2B,aAAUb,KAAK,GAAGe,eAAe;AACjC;;GAEF;AACF,QAAOF;;AAGT,SAASH,YAAYxB,MAAsE;AACzF,QAAOA,KAAKiB,UAAUe"}
@@ -1,133 +1,138 @@
1
- import { PropsWithChildren } from "react";
1
+ import { JSX, PropsWithChildren } from "react";
2
+
3
+ //#region src/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts
2
4
  /**
3
5
  * Localized strings used in the components.
4
6
  * @public
5
7
  */
6
- export interface LocalizedStrings {
7
- /**
8
- * Message displayed when nodes are loading.
9
- * Default value: `Loading...`.
10
- */
11
- loading: string;
12
- /**
13
- * Title for apply hierarchy filter button.
14
- * Default value: `Apply filter`.
15
- */
16
- filterHierarchyLevel: string;
17
- /**
18
- * Accessible description for applied hierarchy filter button.
19
- * Default value: `Filter is applied`.
20
- */
21
- filterHierarchyLevelActiveDescription: string;
22
- /**
23
- * Title for clear hierarchy filter button.
24
- * Default value: `Clear active filter`.
25
- */
26
- clearHierarchyLevelFilter: string;
27
- /**
28
- * Message displayed when no nodes matching filter are found.
29
- * Default value: `No matches for current filter for {{node}}.`.
30
- */
31
- noFilteredChildren: string;
32
- /**
33
- * Label for change filter action.
34
- * Default value: `Change filter`.
35
- */
36
- noFilteredChildrenChangeFilter: string;
37
- /**
38
- * Message displayed when hierarchy creation for a node failed.
39
- * Default value: `Failed to create hierarchy for {{node}}.`.
40
- */
41
- failedToCreateHierarchy: string;
42
- /**
43
- * Message displayed when hierarchy creation for a node failed.
44
- * Default value: `Failed to load tree.`.
45
- */
46
- failedToCreateRootHierarchy: string;
47
- /**
48
- * Message displayed when result limit exceeds hierarchy size limit.
49
- * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.
50
- */
51
- resultLimitExceeded: string;
52
- /**
53
- * Message displayed when result limit exceeds hierarchy size limit.
54
- * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.
55
- */
56
- rootResultLimitExceeded: string;
57
- /**
58
- * Name for the error region landmark.
59
- * Default value: `Issues for {{tree_label}}.`.
60
- */
61
- issuesForTree: string;
62
- /**
63
- * Label displayed on the error region, when errors are detected.
64
- * Default value: `{{number_of_issues}} issue(s) found.`.
65
- */
66
- issuesFound: string;
67
- /**
68
- * Label displayed on the error region, when no issues are found.
69
- * Default value: `No issues found.`.
70
- */
71
- noIssuesFound: string;
72
- /**
73
- * Message displayed when hierarchy size limit can be overridden.
74
- * Default value: `Increase limit to {{limit}}`.
75
- */
76
- increaseHierarchyLimit: string;
77
- /**
78
- * Message displayed when hierarchy size limit can be overridden.
79
- * Default value: `Remove limit`.
80
- */
81
- increaseHierarchyLimitToUnlimited: string;
82
- /**
83
- * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.
84
- * Default value: `Add Filter`.
85
- */
86
- increaseHierarchyLimitWithFiltering: string;
87
- /**
88
- * Label for retry action.
89
- * Default value: `Retry`.
90
- */
91
- retry: string;
92
- /**
93
- * Label for rename action.
94
- * Default value: `Rename`.
95
- */
96
- rename: string;
97
- /**
98
- * Label for more actions button.
99
- * Default value: `More`.
100
- */
101
- more: string;
102
- /**
103
- * Label for confirm button.
104
- * Default value: `Confirm`.
105
- */
106
- confirm: string;
107
- /**
108
- * Label for cancel button.
109
- * Default value: `Cancel`.
110
- */
111
- cancel: string;
112
- }
113
- /** @internal */
114
- export interface LocalizationContext {
115
- localizedStrings: LocalizedStrings;
8
+ interface LocalizedStrings {
9
+ /**
10
+ * Message displayed when nodes are loading.
11
+ * Default value: `Loading...`.
12
+ */
13
+ loading: string;
14
+ /**
15
+ * Title for apply hierarchy filter button.
16
+ * Default value: `Apply filter`.
17
+ */
18
+ filterHierarchyLevel: string;
19
+ /**
20
+ * Accessible description for applied hierarchy filter button.
21
+ * Default value: `Filter is applied`.
22
+ */
23
+ filterHierarchyLevelActiveDescription: string;
24
+ /**
25
+ * Title for clear hierarchy filter button.
26
+ * Default value: `Clear active filter`.
27
+ */
28
+ clearHierarchyLevelFilter: string;
29
+ /**
30
+ * Message displayed when no nodes matching filter are found.
31
+ * Default value: `No matches for current filter for {{node}}.`.
32
+ */
33
+ noFilteredChildren: string;
34
+ /**
35
+ * Label for change filter action.
36
+ * Default value: `Change filter`.
37
+ */
38
+ noFilteredChildrenChangeFilter: string;
39
+ /**
40
+ * Message displayed when hierarchy creation for a node failed.
41
+ * Default value: `Failed to create hierarchy for {{node}}.`.
42
+ */
43
+ failedToCreateHierarchy: string;
44
+ /**
45
+ * Message displayed when hierarchy creation for a node failed.
46
+ * Default value: `Failed to load tree.`.
47
+ */
48
+ failedToCreateRootHierarchy: string;
49
+ /**
50
+ * Message displayed when result limit exceeds hierarchy size limit.
51
+ * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.
52
+ */
53
+ resultLimitExceeded: string;
54
+ /**
55
+ * Message displayed when result limit exceeds hierarchy size limit.
56
+ * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.
57
+ */
58
+ rootResultLimitExceeded: string;
59
+ /**
60
+ * Name for the error region landmark.
61
+ * Default value: `Issues for {{tree_label}}.`.
62
+ */
63
+ issuesForTree: string;
64
+ /**
65
+ * Label displayed on the error region, when errors are detected.
66
+ * Default value: `{{number_of_issues}} issue(s) found.`.
67
+ */
68
+ issuesFound: string;
69
+ /**
70
+ * Label displayed on the error region, when no issues are found.
71
+ * Default value: `No issues found.`.
72
+ */
73
+ noIssuesFound: string;
74
+ /**
75
+ * Message displayed when hierarchy size limit can be overridden.
76
+ * Default value: `Increase limit to {{limit}}`.
77
+ */
78
+ increaseHierarchyLimit: string;
79
+ /**
80
+ * Message displayed when hierarchy size limit can be overridden.
81
+ * Default value: `Remove limit`.
82
+ */
83
+ increaseHierarchyLimitToUnlimited: string;
84
+ /**
85
+ * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.
86
+ * Default value: `Add Filter`.
87
+ */
88
+ increaseHierarchyLimitWithFiltering: string;
89
+ /**
90
+ * Label for retry action.
91
+ * Default value: `Retry`.
92
+ */
93
+ retry: string;
94
+ /**
95
+ * Label for rename action.
96
+ * Default value: `Rename`.
97
+ */
98
+ rename: string;
99
+ /**
100
+ * Label for more actions button.
101
+ * Default value: `More`.
102
+ */
103
+ more: string;
104
+ /**
105
+ * Label for confirm button.
106
+ * Default value: `Confirm`.
107
+ */
108
+ confirm: string;
109
+ /**
110
+ * Label for cancel button.
111
+ * Default value: `Cancel`.
112
+ */
113
+ cancel: string;
114
+ /**
115
+ * Label for tree node rename input.
116
+ * Default value: `New label`.
117
+ */
118
+ newLabel: string;
116
119
  }
117
120
  /**
118
121
  * Properties for `LocalizationContextProvider`.
119
122
  * @public
120
123
  */
121
124
  interface LocalizationContextProviderProps {
122
- /** Localized strings used in the components. */
123
- localizedStrings?: Partial<LocalizedStrings>;
125
+ /** Localized strings used in the components. */
126
+ localizedStrings?: Partial<LocalizedStrings>;
124
127
  }
125
128
  /**
126
129
  * Context provider for localized strings used in the components.
127
130
  * @public
128
131
  */
129
- export declare function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>): import("react/jsx-runtime").JSX.Element;
130
- /** @internal */
131
- export declare function useLocalizationContext(): LocalizationContext;
132
- export {};
132
+ declare function LocalizationContextProvider({
133
+ localizedStrings,
134
+ children
135
+ }: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element;
136
+ //#endregion
137
+ export { LocalizationContextProvider };
133
138
  //# sourceMappingURL=LocalizationContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qCAAqC,EAAE,MAAM,CAAC;IAC9C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,8BAA8B,EAAE,MAAM,CAAC;IACvC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,iCAAiC,EAAE,MAAM,CAAC;IAC1C;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AA4BD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
1
+ {"version":3,"file":"LocalizationContext.d.ts","names":[],"sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"mappings":";;;;;AAaA;;UAAiB,gBAAA;EAAgB;;;;EAK/B,OAAA;EAoBA;;;;EAfA,oBAAA;EAwCA;;;;EAnCA,qCAAA;EA4DA;;;;EAvDA,yBAAA;EAgFA;;;;EA3EA,kBAAA;EA4HQ;;;;EAvHR,8BAAA;EAyHmB;;;;EApHnB,uBAAA;EA2HyC;;;;EAtHzC,2BAAA;EAsH0E;;;;EAjH1E,mBAAA;EAiH4C;;;;EA5G5C,uBAAA;EA4GgI;;;;EAvGhI,aAAA;;;;;EAKA,WAAA;;;;;EAKA,aAAA;;;;;EAKA,sBAAA;;;;;EAKA,iCAAA;;;;;EAKA,mCAAA;;;;;EAKA,KAAA;;;;;EAKA,MAAA;;;;;EAKA,IAAA;;;;;EAKA,OAAA;;;;;EAKA,MAAA;;;;;EAKA,QAAA;AAAA;;;;;UAuCQ,gCAAA;;EAER,gBAAA,GAAmB,OAAA,CAAQ,gBAAA;AAAA;;;;;iBAOb,2BAAA,CAAA;EAA8B,gBAAA;EAAkB;AAAA,GAAY,iBAAA,CAAkB,gCAAA,IAAoC,GAAA,CAAI,OAAA"}
@@ -1,46 +1,67 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- import { createContext, useContext, useEffect, useState } from "react";
1
+ import { c } from "react-compiler-runtime";
2
+ import { createContext, useContext } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ //#region src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx
7
6
  const defaultLocalizedStrings = {
8
- loading: "Loading...",
9
- filterHierarchyLevel: "Apply filter",
10
- filterHierarchyLevelActiveDescription: "Filter is applied",
11
- clearHierarchyLevelFilter: "Clear active filter",
12
- noFilteredChildren: "No matches for current filter for {{node}}.",
13
- noFilteredChildrenChangeFilter: "Change filter",
14
- failedToCreateHierarchy: "Failed to create hierarchy for {{node}}.",
15
- failedToCreateRootHierarchy: "Failed to load tree.",
16
- resultLimitExceeded: "The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.",
17
- rootResultLimitExceeded: "The root item hierarchy contains {{limit}}+ items. Try increasing the limit.",
18
- issuesForTree: "Issues for {{tree_label}}.",
19
- issuesFound: "{{number_of_issues}} issue(s) found.",
20
- noIssuesFound: "No issues found.",
21
- increaseHierarchyLimit: "Increase limit to {{limit}}",
22
- increaseHierarchyLimitToUnlimited: "Remove limit",
23
- increaseHierarchyLimitWithFiltering: "Add Filter",
24
- retry: "Retry",
25
- rename: "Rename",
26
- more: "More",
27
- confirm: "Confirm",
28
- cancel: "Cancel",
7
+ loading: "Loading...",
8
+ filterHierarchyLevel: "Apply filter",
9
+ filterHierarchyLevelActiveDescription: "Filter is applied",
10
+ clearHierarchyLevelFilter: "Clear active filter",
11
+ noFilteredChildren: "No matches for current filter for {{node}}.",
12
+ noFilteredChildrenChangeFilter: "Change filter",
13
+ failedToCreateHierarchy: "Failed to create hierarchy for {{node}}.",
14
+ failedToCreateRootHierarchy: "Failed to load tree.",
15
+ resultLimitExceeded: "The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.",
16
+ rootResultLimitExceeded: "The root item hierarchy contains {{limit}}+ items. Try increasing the limit.",
17
+ issuesForTree: "Issues for {{tree_label}}.",
18
+ issuesFound: "{{number_of_issues}} issue(s) found.",
19
+ noIssuesFound: "No issues found.",
20
+ increaseHierarchyLimit: "Increase limit to {{limit}}",
21
+ increaseHierarchyLimitToUnlimited: "Remove limit",
22
+ increaseHierarchyLimitWithFiltering: "Add Filter",
23
+ retry: "Retry",
24
+ rename: "Rename",
25
+ more: "More",
26
+ confirm: "Confirm",
27
+ cancel: "Cancel",
28
+ newLabel: "New label"
29
29
  };
30
30
  const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
31
31
  /**
32
- * Context provider for localized strings used in the components.
33
- * @public
34
- */
35
- export function LocalizationContextProvider({ localizedStrings, children }) {
36
- const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
37
- useEffect(() => {
38
- setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
39
- }, [localizedStrings]);
40
- return _jsx(localizationContext.Provider, { value: state, children: children });
32
+ * Context provider for localized strings used in the components.
33
+ * @public
34
+ */
35
+ function LocalizationContextProvider(t0) {
36
+ const $ = c(5);
37
+ const { localizedStrings, children } = t0;
38
+ let t1;
39
+ if ($[0] !== localizedStrings) {
40
+ t1 = { localizedStrings: {
41
+ ...defaultLocalizedStrings,
42
+ ...localizedStrings
43
+ } };
44
+ $[0] = localizedStrings;
45
+ $[1] = t1;
46
+ } else t1 = $[1];
47
+ const state = t1;
48
+ let t2;
49
+ if ($[2] !== children || $[3] !== state) {
50
+ t2 = /* @__PURE__ */ jsx(localizationContext.Provider, {
51
+ value: state,
52
+ children
53
+ });
54
+ $[2] = children;
55
+ $[3] = state;
56
+ $[4] = t2;
57
+ } else t2 = $[4];
58
+ return t2;
41
59
  }
42
60
  /** @internal */
43
- export function useLocalizationContext() {
44
- return useContext(localizationContext);
61
+ function useLocalizationContext() {
62
+ return useContext(localizationContext);
45
63
  }
64
+
65
+ //#endregion
66
+ export { LocalizationContextProvider, useLocalizationContext };
46
67
  //# sourceMappingURL=LocalizationContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAuH1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,qCAAqC,EAAE,mBAAmB;IAC1D,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,6CAA6C;IACjE,8BAA8B,EAAE,eAAe;IAC/C,uBAAuB,EAAE,0CAA0C;IACnE,2BAA2B,EAAE,sBAAsB;IACnD,mBAAmB,EAAE,gGAAgG;IACrH,uBAAuB,EAAE,8EAA8E;IACvG,aAAa,EAAE,4BAA4B;IAC3C,WAAW,EAAE,sCAAsC;IACnD,aAAa,EAAE,kBAAkB;IACjC,sBAAsB,EAAE,6BAA6B;IACrD,iCAAiC,EAAE,cAAc;IACjD,mCAAmC,EAAE,YAAY;IACjD,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAuD;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Accessible description for applied hierarchy filter button.\n * Default value: `Filter is applied`.\n */\n filterHierarchyLevelActiveDescription: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No matches for current filter for {{node}}.`.\n */\n noFilteredChildren: string;\n /**\n * Label for change filter action.\n * Default value: `Change filter`.\n */\n noFilteredChildrenChangeFilter: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to create hierarchy for {{node}}.`.\n */\n failedToCreateHierarchy: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to load tree.`.\n */\n failedToCreateRootHierarchy: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.\n */\n rootResultLimitExceeded: string;\n /**\n * Name for the error region landmark.\n * Default value: `Issues for {{tree_label}}.`.\n */\n issuesForTree: string;\n /**\n * Label displayed on the error region, when errors are detected.\n * Default value: `{{number_of_issues}} issue(s) found.`.\n */\n issuesFound: string;\n /**\n * Label displayed on the error region, when no issues are found.\n * Default value: `No issues found.`.\n */\n noIssuesFound: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Increase limit to {{limit}}`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Remove limit`.\n */\n increaseHierarchyLimitToUnlimited: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Add Filter`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for rename action.\n * Default value: `Rename`.\n */\n rename: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n /**\n * Label for confirm button.\n * Default value: `Confirm`.\n */\n confirm: string;\n /**\n * Label for cancel button.\n * Default value: `Cancel`.\n */\n cancel: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n filterHierarchyLevelActiveDescription: \"Filter is applied\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No matches for current filter for {{node}}.\",\n noFilteredChildrenChangeFilter: \"Change filter\",\n failedToCreateHierarchy: \"Failed to create hierarchy for {{node}}.\",\n failedToCreateRootHierarchy: \"Failed to load tree.\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.\",\n rootResultLimitExceeded: \"The root item hierarchy contains {{limit}}+ items. Try increasing the limit.\",\n issuesForTree: \"Issues for {{tree_label}}.\",\n issuesFound: \"{{number_of_issues}} issue(s) found.\",\n noIssuesFound: \"No issues found.\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitToUnlimited: \"Remove limit\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n rename: \"Rename\",\n more: \"More\",\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
1
+ {"version":3,"file":"LocalizationContext.js","names":["createContext","useContext","useMemo","JSX","PropsWithChildren","LocalizedStrings","loading","filterHierarchyLevel","filterHierarchyLevelActiveDescription","clearHierarchyLevelFilter","noFilteredChildren","noFilteredChildrenChangeFilter","failedToCreateHierarchy","failedToCreateRootHierarchy","resultLimitExceeded","rootResultLimitExceeded","issuesForTree","issuesFound","noIssuesFound","increaseHierarchyLimit","increaseHierarchyLimitToUnlimited","increaseHierarchyLimitWithFiltering","retry","rename","more","confirm","cancel","newLabel","LocalizationContext","localizedStrings","defaultLocalizedStrings","localizationContext","LocalizationContextProviderProps","Partial","LocalizationContextProvider","t0","$","_c","children","t1","state","t2","useLocalizationContext"],"sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, useContext, useMemo } from \"react\";\n\nimport type { JSX, PropsWithChildren } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Accessible description for applied hierarchy filter button.\n * Default value: `Filter is applied`.\n */\n filterHierarchyLevelActiveDescription: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No matches for current filter for {{node}}.`.\n */\n noFilteredChildren: string;\n /**\n * Label for change filter action.\n * Default value: `Change filter`.\n */\n noFilteredChildrenChangeFilter: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to create hierarchy for {{node}}.`.\n */\n failedToCreateHierarchy: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to load tree.`.\n */\n failedToCreateRootHierarchy: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.\n */\n rootResultLimitExceeded: string;\n /**\n * Name for the error region landmark.\n * Default value: `Issues for {{tree_label}}.`.\n */\n issuesForTree: string;\n /**\n * Label displayed on the error region, when errors are detected.\n * Default value: `{{number_of_issues}} issue(s) found.`.\n */\n issuesFound: string;\n /**\n * Label displayed on the error region, when no issues are found.\n * Default value: `No issues found.`.\n */\n noIssuesFound: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Increase limit to {{limit}}`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Remove limit`.\n */\n increaseHierarchyLimitToUnlimited: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Add Filter`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for rename action.\n * Default value: `Rename`.\n */\n rename: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n /**\n * Label for confirm button.\n * Default value: `Confirm`.\n */\n confirm: string;\n /**\n * Label for cancel button.\n * Default value: `Cancel`.\n */\n cancel: string;\n /**\n * Label for tree node rename input.\n * Default value: `New label`.\n */\n newLabel: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n filterHierarchyLevelActiveDescription: \"Filter is applied\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No matches for current filter for {{node}}.\",\n noFilteredChildrenChangeFilter: \"Change filter\",\n failedToCreateHierarchy: \"Failed to create hierarchy for {{node}}.\",\n failedToCreateRootHierarchy: \"Failed to load tree.\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.\",\n rootResultLimitExceeded: \"The root item hierarchy contains {{limit}}+ items. Try increasing the limit.\",\n issuesForTree: \"Issues for {{tree_label}}.\",\n issuesFound: \"{{number_of_issues}} issue(s) found.\",\n noIssuesFound: \"No issues found.\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitToUnlimited: \"Remove limit\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n rename: \"Rename\",\n more: \"More\",\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n newLabel: \"New label\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element {\n const state = useMemo(() => ({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } }), [localizedStrings]);\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"],"mappings":";;;;;AAmIA,MAAM8B,0BAA4C;CAChDxB,SAAS;CACTC,sBAAsB;CACtBC,uCAAuC;CACvCC,2BAA2B;CAC3BC,oBAAoB;CACpBC,gCAAgC;CAChCC,yBAAyB;CACzBC,6BAA6B;CAC7BC,qBAAqB;CACrBC,yBAAyB;CACzBC,eAAe;CACfC,aAAa;CACbC,eAAe;CACfC,wBAAwB;CACxBC,mCAAmC;CACnCC,qCAAqC;CACrCC,OAAO;CACPC,QAAQ;CACRC,MAAM;CACNC,SAAS;CACTC,QAAQ;CACRC,UAAU;CACX;AAED,MAAMI,sBAAsB/B,cAAmC,EAAE6B,kBAAkBC,yBAAyB,CAAC;;;;;AAe7G,SAAOI,4BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqC,MAAA,EAAAR,kBAAAS,aAAAH;CAAmF,IAAAI;AAAA,KAAAH,EAAA,OAAAP,kBAAA;AAChGU,OAAA,EAAAV,kBAAoB;GAAA,GAAKC;GAAuB,GAAKD;GAAiB,EAAG;AAAAO,IAAA,KAAAP;AAAAO,IAAA,KAAAG;OAAAA,MAAAH,EAAA;CAAtG,MAAAI,QAA6BD;CAAgG,IAAAE;AAAA,KAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,OAAA;AACtHC,OAAA,oBAAA,oBAAA;GAAqCD,OAAAA;GAAQF;IAAwC;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAI;AAAAJ,IAAA,KAAAK;OAAAA,MAAAL,EAAA;AAAA,QAArFK;;;AAIT,SAAOC,yBAAA;AAAA,QACEzC,WAAW8B,oBAAoB"}
@@ -1,16 +1,27 @@
1
- import { RootErrorRendererProps } from "../Renderers.js";
2
1
  import { ErrorInfo } from "../TreeNode.js";
2
+ import { RootErrorRendererProps } from "../Renderers.js";
3
+ import { JSX } from "react";
4
+
5
+ //#region src/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts
3
6
  /**
4
7
  * @alpha
5
8
  */
6
- export type StrataKitRootErrorRendererProps = {
7
- /** Root error to be displayed */
8
- error: ErrorInfo;
9
+ type StrataKitRootErrorRendererProps = {
10
+ /**
11
+ * Root error to be displayed
12
+ */
13
+ error: ErrorInfo;
9
14
  } & RootErrorRendererProps;
10
15
  /**
11
16
  * A component that renders root node error state.
12
17
  *
13
18
  * @alpha
14
19
  */
15
- export declare function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }: StrataKitRootErrorRendererProps): import("react/jsx-runtime").JSX.Element;
20
+ declare function StrataKitRootErrorRenderer({
21
+ error,
22
+ getHierarchyLevelDetails,
23
+ reloadTree
24
+ }: StrataKitRootErrorRendererProps): JSX.Element;
25
+ //#endregion
26
+ export { StrataKitRootErrorRenderer };
16
27
  //# sourceMappingURL=RootErrorRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RootErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,sBAAsB,CAAC;AAE3B;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,EAAE,+BAA+B,2CA+B1H"}
1
+ {"version":3,"file":"RootErrorRenderer.d.ts","names":[],"sources":["../../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"mappings":";;;;;;;AAiBA;KAAY,+BAAA;;;;EAIV,KAAA,EAAO,SAAA;AAAA,IACL,sBAAA;;;AAOJ;;;iBAAgB,0BAAA,CAAA;EAA6B,KAAA;EAAO,wBAAA;EAA0B;AAAA,GAAc,+BAAA,GAAkC,GAAA,CAAI,OAAA"}