@itwin/presentation-hierarchies-react 1.6.0 → 2.0.0-alpha.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -21
  3. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.d.ts +14 -0
  4. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.d.ts.map +1 -0
  5. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.js +27 -0
  6. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.js.map +1 -0
  7. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +12 -0
  8. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +1 -0
  9. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +72 -0
  10. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +1 -0
  11. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts +12 -0
  12. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts.map +1 -0
  13. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js +10 -0
  14. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js.map +1 -0
  15. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +14 -28
  16. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
  17. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +21 -84
  18. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
  19. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +10 -40
  20. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
  21. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +5 -73
  22. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
  23. package/lib/esm/presentation-hierarchies-react.d.ts +3 -1
  24. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  25. package/lib/esm/presentation-hierarchies-react.js +3 -1
  26. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  27. package/package.json +10 -14
  28. package/lib/cjs/package.json +0 -1
  29. package/lib/cjs/presentation-hierarchies-react/TreeNode.d.ts +0 -75
  30. package/lib/cjs/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
  31. package/lib/cjs/presentation-hierarchies-react/TreeNode.js +0 -15
  32. package/lib/cjs/presentation-hierarchies-react/TreeNode.js.map +0 -1
  33. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
  34. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
  35. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -26
  36. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
  37. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts +0 -55
  38. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
  39. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js +0 -66
  40. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
  41. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -46
  42. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
  43. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js +0 -101
  44. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
  45. package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts +0 -132
  46. package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
  47. package/lib/cjs/presentation-hierarchies-react/UseTree.js +0 -246
  48. package/lib/cjs/presentation-hierarchies-react/UseTree.js.map +0 -1
  49. package/lib/cjs/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -1
  50. package/lib/cjs/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
  51. package/lib/cjs/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
  52. package/lib/cjs/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
  53. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
  54. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
  55. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js +0 -311
  56. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
  57. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -44
  58. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
  59. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js +0 -98
  60. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
  61. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -70
  62. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
  63. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.js +0 -158
  64. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
  65. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -28
  66. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
  67. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -131
  68. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
  69. package/lib/cjs/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
  70. package/lib/cjs/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
  71. package/lib/cjs/presentation-hierarchies-react/internal/Utils.js +0 -64
  72. package/lib/cjs/presentation-hierarchies-react/internal/Utils.js.map +0 -1
  73. package/lib/cjs/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +0 -73
  74. package/lib/cjs/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
  75. package/lib/cjs/presentation-hierarchies-react/itwinui/LocalizationContext.js +0 -38
  76. package/lib/cjs/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
  77. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.css +0 -29
  78. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -56
  79. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
  80. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -126
  81. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
  82. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -60
  83. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
  84. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -94
  85. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
  86. package/lib/cjs/presentation-hierarchies-react.d.ts +0 -11
  87. package/lib/cjs/presentation-hierarchies-react.d.ts.map +0 -1
  88. package/lib/cjs/presentation-hierarchies-react.js +0 -30
  89. package/lib/cjs/presentation-hierarchies-react.js.map +0 -1
  90. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.css +0 -29
@@ -1,64 +0,0 @@
1
- "use strict";
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
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.MAX_LIMIT_OVERRIDE = void 0;
8
- exports.createNodeId = createNodeId;
9
- exports.sameNodes = sameNodes;
10
- exports.safeDispose = safeDispose;
11
- require("./DisposePolyfill.js");
12
- const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
13
- /** @internal */
14
- function createNodeId(node) {
15
- return [...node.parentKeys.map(serializeNodeKey), serializeNodeKey(node.key)].join(";");
16
- }
17
- function serializeNodeKey(key) {
18
- return convertObjectValuesToString(key);
19
- }
20
- function convertObjectValuesToString(obj) {
21
- return Object.entries(obj)
22
- .map(([, value]) => {
23
- if (typeof value === "object") {
24
- return convertObjectValuesToString(value);
25
- }
26
- return String(value);
27
- })
28
- .join(",");
29
- }
30
- /** @internal */
31
- function sameNodes(lhs, rhs) {
32
- if (presentation_hierarchies_1.HierarchyNodeKey.compare(lhs.key, rhs.key) !== 0) {
33
- return false;
34
- }
35
- if (lhs.parentKeys.length !== rhs.parentKeys.length) {
36
- return false;
37
- }
38
- for (let i = lhs.parentKeys.length - 1; i >= 0; --i) {
39
- if (presentation_hierarchies_1.HierarchyNodeKey.compare(lhs.parentKeys[i], rhs.parentKeys[i]) !== 0) {
40
- return false;
41
- }
42
- }
43
- return true;
44
- }
45
- /** @internal */
46
- exports.MAX_LIMIT_OVERRIDE = 10000;
47
- /**
48
- * A helper that disposes the given object, if it's disposable.
49
- *
50
- * The first option is to dispose using the deprecated `dispose` method if it exists on the object.
51
- * If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is
52
- * considered as non-disposable and nothing is done with it.
53
- *
54
- * @internal
55
- */
56
- function safeDispose(disposable) {
57
- if ("dispose" in disposable) {
58
- disposable.dispose();
59
- }
60
- else if (Symbol.dispose in disposable) {
61
- disposable[Symbol.dispose]();
62
- }
63
- }
64
- //# sourceMappingURL=Utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/Utils.ts"],"names":[],"mappings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AAgB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACzE,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gBAAgB;AACH,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAExC;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,UAA2E;IACrG,IAAI,SAAS,IAAI,UAAU,EAAE,CAAC;QAC5B,UAAU,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;SAAM,IAAI,MAAM,CAAC,OAAO,IAAI,UAAU,EAAE,CAAC;QACxC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/B,CAAC;AACH,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 \"./DisposePolyfill.js\";\nimport { HierarchyNode, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport function createNodeId(node: Pick<HierarchyNode, \"key\" | \"parentKeys\">) {\n return [...node.parentKeys.map(serializeNodeKey), serializeNodeKey(node.key)].join(\";\");\n}\n\nfunction serializeNodeKey(key: HierarchyNodeKey): string {\n return convertObjectValuesToString(key);\n}\n\nfunction convertObjectValuesToString(obj: object): string {\n return Object.entries(obj)\n .map(([, value]) => {\n if (typeof value === \"object\") {\n return convertObjectValuesToString(value);\n }\n return String(value);\n })\n .join(\",\");\n}\n\n/** @internal */\nexport function sameNodes(lhs: HierarchyNode, rhs: HierarchyNode): boolean {\n if (HierarchyNodeKey.compare(lhs.key, rhs.key) !== 0) {\n return false;\n }\n\n if (lhs.parentKeys.length !== rhs.parentKeys.length) {\n return false;\n }\n\n for (let i = lhs.parentKeys.length - 1; i >= 0; --i) {\n if (HierarchyNodeKey.compare(lhs.parentKeys[i], rhs.parentKeys[i]) !== 0) {\n return false;\n }\n }\n return true;\n}\n\n/** @internal */\nexport const MAX_LIMIT_OVERRIDE = 10000;\n\n/**\n * A helper that disposes the given object, if it's disposable.\n *\n * The first option is to dispose using the deprecated `dispose` method if it exists on the object.\n * If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is\n * considered as non-disposable and nothing is done with it.\n *\n * @internal\n */\nexport function safeDispose(disposable: {} | { [Symbol.dispose]: () => void } | { dispose: () => void }) {\n if (\"dispose\" in disposable) {\n disposable.dispose();\n } else if (Symbol.dispose in disposable) {\n disposable[Symbol.dispose]();\n }\n}\n"]}
@@ -1,73 +0,0 @@
1
- import { PropsWithChildren } from "react";
2
- /**
3
- * Localized strings used in the components.
4
- * @public
5
- */
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
- * Title for clear hierarchy filter button.
19
- * Default value: `Clear active filter`.
20
- */
21
- clearHierarchyLevelFilter: string;
22
- /**
23
- * Message displayed when no nodes matching filter are found.
24
- * Default value: `No child nodes match current filter`.
25
- */
26
- noFilteredChildren: string;
27
- /**
28
- * Message displayed when result limit exceeds hierarchy size limit.
29
- * Default value: `There are more items than allowed limit of {{limit}}.`.
30
- */
31
- resultLimitExceeded: string;
32
- /**
33
- * Message displayed when result limit exceeds hierarchy size limit and hierarchy filtering is enabled.
34
- * Default value: `Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.`.
35
- */
36
- resultLimitExceededWithFiltering: string;
37
- /**
38
- * Message displayed when hierarchy size limit can be overridden.
39
- * Default value: `<link>Increase the hierarchy level size limit to {{limit}}.</link>`.
40
- */
41
- increaseHierarchyLimit: string;
42
- /**
43
- * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.
44
- * Default value: `Or, <link>increase the hierarchy level size limit to {{limit}}.</link>`.
45
- */
46
- increaseHierarchyLimitWithFiltering: string;
47
- /**
48
- * Label for retry action.
49
- * Default value: `Retry`.
50
- */
51
- retry: string;
52
- }
53
- /** @internal */
54
- export interface LocalizationContext {
55
- localizedStrings: LocalizedStrings;
56
- }
57
- /**
58
- * Properties for `LocalizationContextProvider`.
59
- * @public
60
- */
61
- interface LocalizationContextProviderProps {
62
- /** Localized strings used in the components. */
63
- localizedStrings?: Partial<LocalizedStrings>;
64
- }
65
- /**
66
- * Context provider for localized strings used in the components.
67
- * @public
68
- */
69
- export declare function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>): import("react/jsx-runtime").JSX.Element;
70
- /** @internal */
71
- export declare function useLocalizationContext(): LocalizationContext;
72
- export {};
73
- //# sourceMappingURL=LocalizationContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/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,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,gCAAgC,EAAE,MAAM,CAAC;IACzC;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAgBD;;;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,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalizationContextProvider = LocalizationContextProvider;
4
- exports.useLocalizationContext = useLocalizationContext;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- /*---------------------------------------------------------------------------------------------
7
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
8
- * See LICENSE.md in the project root for license terms and full copyright notice.
9
- *--------------------------------------------------------------------------------------------*/
10
- const react_1 = require("react");
11
- const defaultLocalizedStrings = {
12
- loading: "Loading...",
13
- filterHierarchyLevel: "Apply filter",
14
- clearHierarchyLevelFilter: "Clear active filter",
15
- noFilteredChildren: "No child nodes match current filter",
16
- resultLimitExceeded: "There are more items than allowed limit of {{limit}}.",
17
- resultLimitExceededWithFiltering: "Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.",
18
- increaseHierarchyLimit: "<link>Increase the hierarchy level size limit to {{limit}}.</link>",
19
- increaseHierarchyLimitWithFiltering: "Or, <link>increase the hierarchy level size limit to {{limit}}.</link>",
20
- retry: "Retry",
21
- };
22
- const localizationContext = (0, react_1.createContext)({ localizedStrings: defaultLocalizedStrings });
23
- /**
24
- * Context provider for localized strings used in the components.
25
- * @public
26
- */
27
- function LocalizationContextProvider({ localizedStrings, children }) {
28
- const [state, setState] = (0, react_1.useState)({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
29
- (0, react_1.useEffect)(() => {
30
- setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
31
- }, [localizedStrings]);
32
- return (0, jsx_runtime_1.jsx)(localizationContext.Provider, { value: state, children: children });
33
- }
34
- /** @internal */
35
- function useLocalizationContext() {
36
- return (0, react_1.useContext)(localizationContext);
37
- }
38
- //# sourceMappingURL=LocalizationContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/LocalizationContext.tsx"],"names":[],"mappings":";;AA2FA,kEAQC;AAGD,wDAEC;;AAxGD;;;gGAGgG;AAEhG,iCAA0F;AA2D1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,qCAAqC;IACzD,mBAAmB,EAAE,uDAAuD;IAC5E,gCAAgC,EAAE,0GAA0G;IAC5I,sBAAsB,EAAE,oEAAoE;IAC5F,mCAAmC,EAAE,wEAAwE;IAC7G,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,mBAAmB,GAAG,IAAA,qBAAa,EAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAuD;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,IAAA,iBAAS,EAAC,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,uBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,SAAgB,sBAAsB;IACpC,OAAO,IAAA,kBAAU,EAAC,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 * 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 child nodes match current filter`.\n */\n noFilteredChildren: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `There are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit and hierarchy filtering is enabled.\n * Default value: `Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.`.\n */\n resultLimitExceededWithFiltering: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `<link>Increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Or, <link>increase the hierarchy level size limit to {{limit}}.</link>`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No child nodes match current filter\",\n resultLimitExceeded: \"There are more items than allowed limit of {{limit}}.\",\n resultLimitExceededWithFiltering: \"Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.\",\n increaseHierarchyLimit: \"<link>Increase the hierarchy level size limit to {{limit}}.</link>\",\n increaseHierarchyLimitWithFiltering: \"Or, <link>increase the hierarchy level size limit to {{limit}}.</link>\",\n retry: \"Retry\",\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,29 +0,0 @@
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
-
6
- .stateless-tree-node {
7
- user-select: none;
8
- }
9
-
10
- .stateless-tree-node .action-buttons {
11
- visibility: hidden;
12
- }
13
-
14
- .stateless-tree-node:hover .action-buttons,
15
- .stateless-tree-node.filtered .action-buttons,
16
- .stateless-tree-node:focus-within .action-buttons {
17
- visibility: visible;
18
- }
19
-
20
- .stateless-tree-node:focus-within {
21
- outline: 1px solid var(--iui-color-border-accent);
22
- outline-offset: -1px;
23
- border-radius: var(--iui-border-radius-1);
24
- }
25
-
26
- .stateless-tree-node-small-spinner {
27
- height: var(--iui-size-s);
28
- width: var(--iui-size-s);
29
- }
@@ -1,56 +0,0 @@
1
- import "./TreeNodeRenderer.css";
2
- import { ComponentPropsWithoutRef, ReactElement, RefAttributes } from "react";
3
- import { TreeNode } from "@itwin/itwinui-react";
4
- import { PresentationHierarchyNode } from "../TreeNode.js";
5
- import { HierarchyLevelDetails, UseTreeResult } from "../UseTree.js";
6
- import { RenderedTreeNode } from "./TreeRenderer.js";
7
- /** @public */
8
- type TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;
9
- /** @public */
10
- interface TreeNodeRendererOwnProps {
11
- /** Node that is rendered. */
12
- node: RenderedTreeNode;
13
- /** Action to perform when the filter button is clicked for this node. */
14
- onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
15
- /** Returns an icon for a given node. */
16
- getIcon?: (node: PresentationHierarchyNode) => ReactElement | undefined;
17
- /** Returns a label for a given node. */
18
- getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;
19
- /** Returns sublabel for a given node. */
20
- getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;
21
- /** Action to perform when the node is clicked. */
22
- onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
23
- /** Action to perform when a key is pressed when the node is hovered on. */
24
- onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;
25
- /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */
26
- reloadTree?: (options: {
27
- parentNodeId: string | undefined;
28
- state: "reset";
29
- }) => void;
30
- /** CSS class name for the action buttons. */
31
- actionButtonsClassName?: string;
32
- /** Tree node size. Should match the size passed to `TreeRenderer` component. */
33
- size?: "default" | "small";
34
- /**
35
- * Configures filter buttons visibility.
36
- *
37
- * Options:
38
- * - `show-on-hover` - show filter buttons when hovering over node, or the node is in focus.
39
- * - `hide` - hide filter buttons, but will show them if the filter is applied.
40
- *
41
- * Default value: `show-on-hover`
42
- */
43
- filterButtonsVisibility?: "show-on-hover" | "hide";
44
- }
45
- /** @public */
46
- type TreeNodeRendererProps = Pick<UseTreeResult, "expandNode"> & Partial<Pick<UseTreeResult, "getHierarchyLevelDetails">> & Omit<TreeNodeProps, "label" | "onExpanded" | "onSelected" | "icon"> & TreeNodeRendererOwnProps;
47
- /**
48
- * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
49
- *
50
- * @see `TreeRenderer`
51
- * @see https://itwinui.bentley.com/docs/tree
52
- * @public
53
- */
54
- export declare const TreeNodeRenderer: React.ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLDivElement>>;
55
- export {};
56
- //# sourceMappingURL=TreeNodeRenderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,wBAAwB,EAA2C,YAAY,EAAO,aAAa,EAAuB,MAAM,OAAO,CAAC;AAEjJ,OAAO,EAA+D,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE7G,OAAO,EAA+B,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,cAAc;AACd,KAAK,aAAa,GAAG,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE/D,cAAc;AACd,UAAU,wBAAwB;IAChC,6BAA6B;IAC7B,IAAI,EAAE,gBAAgB,CAAC;IACvB,yEAAyE;IACzE,aAAa,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MAAM,CAAC,GACnE,wBAAwB,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,yBAAyB,CAAC,qBAAqB,GAAG,aAAa,CAAC,cAAc,CAAC,CA2HnH,CAAC"}
@@ -1,126 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TreeNodeRenderer = void 0;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- /*---------------------------------------------------------------------------------------------
9
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
10
- * See LICENSE.md in the project root for license terms and full copyright notice.
11
- *--------------------------------------------------------------------------------------------*/
12
- require("./TreeNodeRenderer.css");
13
- const classnames_1 = __importDefault(require("classnames"));
14
- const react_1 = require("react");
15
- const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
16
- const itwinui_react_1 = require("@itwin/itwinui-react");
17
- const Utils_js_1 = require("../internal/Utils.js");
18
- const TreeNode_js_1 = require("../TreeNode.js");
19
- const LocalizationContext_js_1 = require("./LocalizationContext.js");
20
- /**
21
- * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
22
- *
23
- * @see `TreeRenderer`
24
- * @see https://itwinui.bentley.com/docs/tree
25
- * @public
26
- */
27
- exports.TreeNodeRenderer = (0, react_1.forwardRef)(({ node, expandNode, getIcon, getLabel, getSublabel, onFilterClick, onNodeClick, onNodeKeyDown, isSelected, isDisabled, actionButtonsClassName, getHierarchyLevelDetails, reloadTree, size, filterButtonsVisibility, ...treeNodeProps }, forwardedRef) => {
28
- const { localizedStrings } = (0, LocalizationContext_js_1.useLocalizationContext)();
29
- const applyFilterButtonRef = (0, react_1.useRef)(null);
30
- const nodeRef = (0, react_1.useRef)(null);
31
- const ref = useMergedRefs(forwardedRef, nodeRef);
32
- if ("type" in node && node.type === "ChildrenPlaceholder") {
33
- return (0, jsx_runtime_1.jsx)(PlaceholderNode, { ...treeNodeProps, ref: ref, size: size });
34
- }
35
- if ((0, TreeNode_js_1.isPresentationHierarchyNode)(node)) {
36
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, ref: ref, isSelected: isSelected, isDisabled: isDisabled, className: (0, classnames_1.default)(treeNodeProps.className, "stateless-tree-node", { filtered: node.isFiltered }), onClick: (event) => !isDisabled && onNodeClick?.(node, !isSelected, event), onKeyDown: (event) => {
37
- // Ignore if it is called on the element inside, e.g. checkbox or expander
38
- if (!isDisabled && event.target === nodeRef.current) {
39
- onNodeKeyDown?.(node, !isSelected, event);
40
- }
41
- }, onExpanded: (_, isExpanded) => {
42
- expandNode(node.id, isExpanded);
43
- }, icon: getIcon ? getIcon(node) : undefined, label: getLabel ? getLabel(node) : node.label, sublabel: getSublabel ? getSublabel(node) : undefined, children: (0, jsx_runtime_1.jsxs)(itwinui_react_1.ButtonGroup, { className: (0, classnames_1.default)("action-buttons", actionButtonsClassName), children: [getHierarchyLevelDetails && node.isFiltered ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { className: "filtering-action-button", styleType: "borderless", size: "small", label: localizedStrings.clearHierarchyLevelFilter, onClick: (e) => {
44
- e.stopPropagation();
45
- getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);
46
- applyFilterButtonRef.current?.focus();
47
- }, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgRemove, {}) })) : null, onFilterClick && node.isFilterable && (filterButtonsVisibility !== "hide" || node.isFiltered) ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { ref: applyFilterButtonRef, className: "filtering-action-button", styleType: "borderless", size: "small", label: localizedStrings.filterHierarchyLevel, onClick: (e) => {
48
- e.stopPropagation();
49
- const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);
50
- hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);
51
- }, children: node.isFiltered ? (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgFilter, {}) : (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgFilterHollow, {}) })) : null] }) }));
52
- }
53
- if (node.type === "ResultSetTooLarge") {
54
- return ((0, jsx_runtime_1.jsx)(ResultSetTooLargeNode, { ...treeNodeProps, ref: ref, limit: node.resultSetSizeLimit, onOverrideLimit: getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(node.parentNodeId)?.setSizeLimit(limit) : undefined, onFilterClick: onFilterClick
55
- ? () => {
56
- const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);
57
- hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);
58
- }
59
- : undefined }));
60
- }
61
- if (node.type === "NoFilterMatches") {
62
- return (0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, ref: ref, label: localizedStrings.noFilteredChildren, isDisabled: true, onExpanded: /* c8 ignore next */ () => { } });
63
- }
64
- const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: "reset" }) : undefined;
65
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, ref: ref, label: (0, jsx_runtime_1.jsx)(ErrorNodeLabel, { message: node.message, onRetry: onRetry }), isDisabled: true, onExpanded: /* c8 ignore next */ () => { } }));
66
- });
67
- exports.TreeNodeRenderer.displayName = "TreeNodeRenderer";
68
- const PlaceholderNode = (0, react_1.forwardRef)(({ size, ...props }, forwardedRef) => {
69
- const { localizedStrings } = (0, LocalizationContext_js_1.useLocalizationContext)();
70
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...props, ref: forwardedRef, label: localizedStrings.loading, icon: (0, jsx_runtime_1.jsx)(itwinui_react_1.ProgressRadial, { size: "x-small", indeterminate: true, title: localizedStrings.loading, className: (0, classnames_1.default)(props.className, { "stateless-tree-node-small-spinner": size === "small" }) }), onExpanded: /* c8 ignore next */ () => { } }));
71
- });
72
- PlaceholderNode.displayName = "PlaceholderNode";
73
- const ResultSetTooLargeNode = (0, react_1.forwardRef)(({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {
74
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...props, ref: forwardedRef, className: "stateless-tree-node", label: (0, jsx_runtime_1.jsx)(ResultSetTooLargeNodeLabel, { limit: limit, onFilterClick: onFilterClick, onOverrideLimit: onOverrideLimit }), onExpanded: /* c8 ignore next */ () => { } }));
75
- });
76
- ResultSetTooLargeNode.displayName = "ResultSetTooLargeNode";
77
- function ErrorNodeLabel({ message, onRetry }) {
78
- const { localizedStrings } = (0, LocalizationContext_js_1.useLocalizationContext)();
79
- return ((0, jsx_runtime_1.jsxs)(itwinui_react_1.Flex, { flexDirection: "row", gap: "xs", title: message, alignItems: "start", children: [(0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: message }), onRetry ? (0, jsx_runtime_1.jsx)(itwinui_react_1.Anchor, { onClick: onRetry, children: localizedStrings?.retry }) : null] }));
80
- }
81
- function ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }) {
82
- const { localizedStrings } = (0, LocalizationContext_js_1.useLocalizationContext)();
83
- const supportsFiltering = !!onFilterClick;
84
- const supportsLimitOverride = !!onOverrideLimit && limit < Utils_js_1.MAX_LIMIT_OVERRIDE;
85
- const limitExceededMessage = createLocalizedMessage(supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded, limit, onFilterClick);
86
- const increaseLimitMessage = supportsLimitOverride
87
- ? createLocalizedMessage(supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit, Utils_js_1.MAX_LIMIT_OVERRIDE, () => onOverrideLimit(Utils_js_1.MAX_LIMIT_OVERRIDE))
88
- : { title: "", element: null };
89
- const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;
90
- return ((0, jsx_runtime_1.jsxs)(itwinui_react_1.Flex, { flexDirection: "column", gap: "3xs", title: title, alignItems: "start", children: [limitExceededMessage.element, increaseLimitMessage.element] }));
91
- }
92
- function createLocalizedMessage(message, limit, onClick) {
93
- const limitStr = limit.toLocaleString(undefined, { useGrouping: true });
94
- const messageWithLimit = message.replace("{{limit}}", limitStr);
95
- const exp = new RegExp("<link>(.*)</link>");
96
- const match = messageWithLimit.match(exp);
97
- if (!match) {
98
- return {
99
- title: messageWithLimit,
100
- element: ((0, jsx_runtime_1.jsx)(itwinui_react_1.Flex, { flexDirection: "row", gap: "3xs", children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: messageWithLimit }) })),
101
- };
102
- }
103
- const [fullText, innerText] = match;
104
- const [textBefore, textAfter] = messageWithLimit.split(fullText);
105
- return {
106
- title: messageWithLimit.replace(fullText, innerText),
107
- element: ((0, jsx_runtime_1.jsxs)(itwinui_react_1.Flex, { flexDirection: "row", gap: "3xs", children: [textBefore ? (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: textBefore }) : null, (0, jsx_runtime_1.jsx)(itwinui_react_1.Anchor, { underline: true, onClick: (e) => {
108
- e.stopPropagation();
109
- onClick?.();
110
- }, children: innerText }), textAfter ? (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: textAfter }) : null] })),
111
- };
112
- }
113
- function useMergedRefs(...refs) {
114
- return (0, react_1.useCallback)((instance) => {
115
- refs.forEach((ref) => {
116
- if (typeof ref === "function") {
117
- ref(instance);
118
- }
119
- else if (ref) {
120
- ref.current = instance;
121
- }
122
- });
123
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
124
- [...refs]);
125
- }
126
- //# sourceMappingURL=TreeNodeRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,kCAAgC;AAChC,4DAA4B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CAAC;gBAC9B,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,GAAG,EAAE,CAAC;gBACd,GAAkC,CAAC,OAAO,GAAG,QAAQ,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,uDAAuD;IAC1D,CAAC,GAAG,IAAI,CAAC,CACV,CAAC;AACJ,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 \"./TreeNodeRenderer.css\";\nimport cx from \"classnames\";\nimport { ComponentPropsWithoutRef, forwardRef, LegacyRef, MutableRefObject, ReactElement, Ref, RefAttributes, useCallback, useRef } from \"react\";\nimport { SvgFilter, SvgFilterHollow, SvgRemove } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, ButtonGroup, Flex, IconButton, ProgressRadial, Text, TreeNode } from \"@itwin/itwinui-react\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, UseTreeResult } from \"../UseTree.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { RenderedTreeNode } from \"./TreeRenderer.js\";\n\n/** @public */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;\n\n/** @public */\ninterface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: RenderedTreeNode;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Returns an icon for a given node. */\n getIcon?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns a label for a given node. */\n getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns sublabel for a given node. */\n getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Action to perform when the node is clicked. */\n onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Action to perform when a key is pressed when the node is hovered on. */\n onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree?: (options: { parentNodeId: string | undefined; state: \"reset\" }) => void;\n /** CSS class name for the action buttons. */\n actionButtonsClassName?: string;\n /** Tree node size. Should match the size passed to `TreeRenderer` component. */\n size?: \"default\" | \"small\";\n /**\n * Configures filter buttons visibility.\n *\n * Options:\n * - `show-on-hover` - show filter buttons when hovering over node, or the node is in focus.\n * - `hide` - hide filter buttons, but will show them if the filter is applied.\n *\n * Default value: `show-on-hover`\n */\n filterButtonsVisibility?: \"show-on-hover\" | \"hide\";\n}\n\n/** @public */\ntype TreeNodeRendererProps = Pick<UseTreeResult, \"expandNode\"> &\n Partial<Pick<UseTreeResult, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"label\" | \"onExpanded\" | \"onSelected\" | \"icon\"> &\n TreeNodeRendererOwnProps;\n\n/**\n * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.\n *\n * @see `TreeRenderer`\n * @see https://itwinui.bentley.com/docs/tree\n * @public\n */\nexport const TreeNodeRenderer: React.ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLDivElement>> = forwardRef(\n (\n {\n node,\n expandNode,\n getIcon,\n getLabel,\n getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isSelected,\n isDisabled,\n actionButtonsClassName,\n getHierarchyLevelDetails,\n reloadTree,\n size,\n filterButtonsVisibility,\n ...treeNodeProps\n },\n forwardedRef,\n ) => {\n const { localizedStrings } = useLocalizationContext();\n const applyFilterButtonRef = useRef<HTMLButtonElement>(null);\n const nodeRef = useRef<HTMLDivElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n if (\"type\" in node && node.type === \"ChildrenPlaceholder\") {\n return <PlaceholderNode {...treeNodeProps} ref={ref} size={size} />;\n }\n\n if (isPresentationHierarchyNode(node)) {\n return (\n <TreeNode\n {...treeNodeProps}\n ref={ref}\n isSelected={isSelected}\n isDisabled={isDisabled}\n className={cx(treeNodeProps.className, \"stateless-tree-node\", { filtered: node.isFiltered })}\n onClick={(event) => !isDisabled && onNodeClick?.(node, !isSelected, event)}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!isDisabled && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !isSelected, event);\n }\n }}\n onExpanded={(_, isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n icon={getIcon ? getIcon(node) : undefined}\n label={getLabel ? getLabel(node) : node.label}\n sublabel={getSublabel ? getSublabel(node) : undefined}\n >\n <ButtonGroup className={cx(\"action-buttons\", actionButtonsClassName)}>\n {getHierarchyLevelDetails && node.isFiltered ? (\n <IconButton\n className=\"filtering-action-button\"\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.clearHierarchyLevelFilter}\n onClick={(e) => {\n e.stopPropagation();\n getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);\n applyFilterButtonRef.current?.focus();\n }}\n >\n <SvgRemove />\n </IconButton>\n ) : null}\n {onFilterClick && node.isFilterable && (filterButtonsVisibility !== \"hide\" || node.isFiltered) ? (\n <IconButton\n ref={applyFilterButtonRef}\n className=\"filtering-action-button\"\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.filterHierarchyLevel}\n onClick={(e) => {\n e.stopPropagation();\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }}\n >\n {node.isFiltered ? <SvgFilter /> : <SvgFilterHollow />}\n </IconButton>\n ) : null}\n </ButtonGroup>\n </TreeNode>\n );\n }\n\n if (node.type === \"ResultSetTooLarge\") {\n return (\n <ResultSetTooLargeNode\n {...treeNodeProps}\n ref={ref}\n limit={node.resultSetSizeLimit}\n onOverrideLimit={getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(node.parentNodeId)?.setSizeLimit(limit) : undefined}\n onFilterClick={\n onFilterClick\n ? () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }\n : undefined\n }\n />\n );\n }\n\n if (node.type === \"NoFilterMatches\") {\n return <TreeNode {...treeNodeProps} ref={ref} label={localizedStrings.noFilteredChildren} isDisabled={true} onExpanded={/* c8 ignore next */ () => {}} />;\n }\n\n const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: \"reset\" }) : undefined;\n return (\n <TreeNode\n {...treeNodeProps}\n ref={ref}\n label={<ErrorNodeLabel message={node.message} onRetry={onRetry} />}\n isDisabled={true}\n onExpanded={/* c8 ignore next */ () => {}}\n />\n );\n },\n);\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<\n HTMLDivElement,\n Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & {\n size?: \"default\" | \"small\";\n }\n>(({ size, ...props }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n label={localizedStrings.loading}\n icon={\n <ProgressRadial\n size=\"x-small\"\n indeterminate\n title={localizedStrings.loading}\n className={cx(props.className, { \"stateless-tree-node-small-spinner\": size === \"small\" })}\n />\n }\n onExpanded={/* c8 ignore next */ () => {}}\n />\n );\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\n\nconst ResultSetTooLargeNode = forwardRef<HTMLDivElement, Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & ResultSetTooLargeNodeLabelProps>(\n ({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n className=\"stateless-tree-node\"\n label={<ResultSetTooLargeNodeLabel limit={limit} onFilterClick={onFilterClick} onOverrideLimit={onOverrideLimit} />}\n onExpanded={/* c8 ignore next */ () => {}}\n />\n );\n },\n);\nResultSetTooLargeNode.displayName = \"ResultSetTooLargeNode\";\n\nfunction ErrorNodeLabel({ message, onRetry }: { message: string; onRetry?: () => void }) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Flex flexDirection=\"row\" gap=\"xs\" title={message} alignItems=\"start\">\n <Text>{message}</Text>\n {onRetry ? <Anchor onClick={onRetry}>{localizedStrings?.retry}</Anchor> : null}\n </Flex>\n );\n}\n\ninterface ResultSetTooLargeNodeLabelProps {\n limit: number;\n onFilterClick?: () => void;\n onOverrideLimit?: (limit: number) => void;\n}\n\nfunction ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }: ResultSetTooLargeNodeLabelProps) {\n const { localizedStrings } = useLocalizationContext();\n const supportsFiltering = !!onFilterClick;\n const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;\n\n const limitExceededMessage = createLocalizedMessage(\n supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded,\n limit,\n onFilterClick,\n );\n const increaseLimitMessage = supportsLimitOverride\n ? createLocalizedMessage(\n supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit,\n MAX_LIMIT_OVERRIDE,\n () => onOverrideLimit(MAX_LIMIT_OVERRIDE),\n )\n : { title: \"\", element: null };\n\n const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;\n\n return (\n <Flex flexDirection=\"column\" gap=\"3xs\" title={title} alignItems=\"start\">\n {limitExceededMessage.element}\n {increaseLimitMessage.element}\n </Flex>\n );\n}\n\nfunction createLocalizedMessage(message: string, limit: number, onClick?: () => void) {\n const limitStr = limit.toLocaleString(undefined, { useGrouping: true });\n const messageWithLimit = message.replace(\"{{limit}}\", limitStr);\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = messageWithLimit.match(exp);\n\n if (!match) {\n return {\n title: messageWithLimit,\n element: (\n <Flex flexDirection=\"row\" gap=\"3xs\">\n <Text>{messageWithLimit}</Text>\n </Flex>\n ),\n };\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = messageWithLimit.split(fullText);\n\n return {\n title: messageWithLimit.replace(fullText, innerText),\n element: (\n <Flex flexDirection=\"row\" gap=\"3xs\">\n {textBefore ? <Text>{textBefore}</Text> : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? <Text>{textAfter}</Text> : null}\n </Flex>\n ),\n };\n}\n\nfunction useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(instance);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = instance;\n }\n });\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs],\n );\n}\n"]}
@@ -1,60 +0,0 @@
1
- import { ComponentPropsWithoutRef } from "react";
2
- import { NodeData, Tree } from "@itwin/itwinui-react";
3
- import { PresentationTreeNode } from "../TreeNode.js";
4
- import { SelectionMode } from "../UseSelectionHandler.js";
5
- import { useTree } from "../UseTree.js";
6
- import { LocalizationContextProvider } from "./LocalizationContext.js";
7
- import { TreeNodeRenderer } from "./TreeNodeRenderer.js";
8
- /** @public */
9
- type TreeProps = ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>;
10
- /** @public */
11
- type TreeNodeRendererProps = ComponentPropsWithoutRef<typeof TreeNodeRenderer>;
12
- /** @public */
13
- interface TreeRendererOwnProps {
14
- /** Root nodes of the tree. */
15
- rootNodes: PresentationTreeNode[];
16
- /** Active selection mode used by the tree. Defaults to `"single"`. */
17
- selectionMode?: SelectionMode;
18
- }
19
- /** @public */
20
- type TreeRendererProps = Pick<ReturnType<typeof useTree>, "rootNodes" | "expandNode"> & Partial<Pick<ReturnType<typeof useTree>, "selectNodes" | "isNodeSelected" | "getHierarchyLevelDetails" | "reloadTree">> & Pick<TreeNodeRendererProps, "onFilterClick" | "getIcon" | "getLabel" | "getSublabel" | "filterButtonsVisibility"> & TreeRendererOwnProps & Omit<TreeProps, "data" | "nodeRenderer" | "getNode" | "enableVirtualization"> & ComponentPropsWithoutRef<typeof LocalizationContextProvider>;
21
- /**
22
- * A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes
23
- * are rendered using `TreeNodeRenderer` component from this package.
24
- *
25
- * @see https://itwinui.bentley.com/docs/tree
26
- * @public
27
- */
28
- export declare function TreeRenderer({ rootNodes, expandNode, selectNodes, isNodeSelected, onFilterClick, getIcon, getLabel, getSublabel, getHierarchyLevelDetails, reloadTree, selectionMode, localizedStrings, size, filterButtonsVisibility, ...treeProps }: TreeRendererProps): import("react/jsx-runtime.js").JSX.Element;
29
- /**
30
- * A data structure for a tree node that is rendered using the `TreeRenderer` component.
31
- *
32
- * In addition to the `PresentationTreeNode` union, this type may have one additional variation - an informational
33
- * type of node with `ChildrenPlaceholder` type. This type of node is returned as the single child node of a parent
34
- * while its children are being loaded. This allows the node renderer to show a placeholder under the parent during
35
- * the process.
36
- *
37
- * @public
38
- */
39
- export type RenderedTreeNode = PresentationTreeNode | {
40
- id: string;
41
- parentNodeId: string | undefined;
42
- type: "ChildrenPlaceholder";
43
- };
44
- /**
45
- * An utility function that creates an `@itwin/itwinui-react` `NodeData` object for the `Tree` component from a
46
- * `RenderedTreeNode` object.
47
- *
48
- * Usage example:
49
- * ```tsx
50
- * function MyComponent({ rootNodes, nodeRenderer }: MyComponentProps) {
51
- * const getNode = useCallback<TreeProps["getNode"]>((node) => createRenderedTreeNodeData(node, () => false), []);
52
- * return <Tree<RenderedTreeNode> data={rootNodes} getNode={getNode} nodeRenderer={nodeRenderer} />;
53
- * }
54
- * ```
55
- *
56
- * @public
57
- */
58
- export declare function createRenderedTreeNodeData(node: RenderedTreeNode, isNodeSelected: (nodeId: string) => boolean): NodeData<RenderedTreeNode>;
59
- export {};
60
- //# sourceMappingURL=TreeRenderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAe,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAuB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,cAAc;AACd,KAAK,SAAS,GAAG,wBAAwB,CAAC,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAEzE,cAAc;AACd,KAAK,qBAAqB,GAAG,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/E,cAAc;AACd,UAAU,oBAAoB;IAC5B,8BAA8B;IAC9B,SAAS,EAAE,oBAAoB,EAAE,CAAC;IAClC,sEAAsE;IACtE,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,cAAc;AACd,KAAK,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC,GACnF,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,aAAa,GAAG,gBAAgB,GAAG,0BAA0B,GAAG,YAAY,CAAC,CAAC,GACvH,IAAI,CAAC,qBAAqB,EAAE,eAAe,GAAG,SA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