@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,6 +1,16 @@
1
- import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
2
1
  import { TreeNode } from "../TreeNode.js";
2
+ import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
3
3
  import { TreeActionBaseAttributes } from "./TreeAction.js";
4
+ import { NamedExoticComponent } from "react";
5
+
6
+ //#region src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts
7
+ /** @alpha */
8
+ type TreeNodeFilterActionProps = {
9
+ /**
10
+ * Action to perform when the filter button is clicked for this node.
11
+ */
12
+ onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
13
+ } & TreeActionBaseAttributes & Pick<TreeRendererProps, "getHierarchyLevelDetails">;
4
14
  /**
5
15
  * React component that renders a filter action for a tree item.
6
16
  *
@@ -11,10 +21,9 @@ import { TreeActionBaseAttributes } from "./TreeAction.js";
11
21
  *
12
22
  * @alpha
13
23
  */
14
- export declare const TreeNodeFilterAction: import("react").NamedExoticComponent<{
15
- /** Action to perform when the filter button is clicked for this node. */
16
- onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
17
- } & TreeActionBaseAttributes & Pick<TreeRendererProps, "getHierarchyLevelDetails"> & {
18
- node: TreeNode;
24
+ declare const TreeNodeFilterAction: NamedExoticComponent<TreeNodeFilterActionProps & {
25
+ node: TreeNode;
19
26
  }>;
27
+ //#endregion
28
+ export { TreeNodeFilterAction };
20
29
  //# sourceMappingURL=TreeNodeFilterAction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeFilterAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAS3E;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;IAf/B,yEAAyE;eAC9D,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI;;UAmB5B,QAAQ;EAoB7C,CAAC"}
1
+ {"version":3,"file":"TreeNodeFilterAction.d.ts","names":[],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"mappings":";;;;;;;KAgBK,yBAAA;EAAA;;;EAIH,QAAA,IAAY,qBAAA,EAAuB,qBAAA;AAAA,IACjC,wBAAA,GACF,IAAA,CAAK,iBAAA;;;;;;;;;;;cAYM,oBAAA,EAAsB,oBAAA,CAAqB,yBAAA;EAA8B,IAAA,EAAM,QAAA;AAAA"}
@@ -1,29 +1,79 @@
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 { memo, useCallback } from "react";
7
- import filterSvg from "@stratakit/icons/filter.svg";
8
- import { useLocalizationContext } from "./LocalizationContext.js";
9
1
  import { TreeActionBase } from "./TreeAction.js";
2
+ import { useLocalizationContext } from "./LocalizationContext.js";
3
+ import { c } from "react-compiler-runtime";
4
+ import { memo } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import filterSvg from "@stratakit/icons/filter.svg";
7
+
8
+ //#region src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx
10
9
  /**
11
- * React component that renders a filter action for a tree item.
12
- *
13
- * The action calls the `onFilter` callback prop when clicked.
14
- *
15
- * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
16
- * to tree items.
17
- *
18
- * @alpha
19
- */
20
- export const TreeNodeFilterAction = memo(function TreeNodeFilterAction({ node, onFilter, getHierarchyLevelDetails, ...actionAttributes }) {
21
- const { localizedStrings } = useLocalizationContext();
22
- const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;
23
- const handleClick = useCallback(() => {
24
- const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);
25
- hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);
26
- }, [node, getHierarchyLevelDetails, onFilter]);
27
- return (_jsx(TreeActionBase, { ...actionAttributes, label: filterHierarchyLevel, onClick: handleClick, icon: filterSvg, visible: node.isFiltered ? true : undefined, dot: node.isFiltered ? filterHierarchyLevelActiveDescription : undefined, hide: !onFilter || !node.isFilterable }));
10
+ * React component that renders a filter action for a tree item.
11
+ *
12
+ * The action calls the `onFilter` callback prop when clicked.
13
+ *
14
+ * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
15
+ * to tree items.
16
+ *
17
+ * @alpha
18
+ */
19
+ const TreeNodeFilterAction = memo(function TreeNodeFilterAction(t0) {
20
+ const $ = c(16);
21
+ let actionAttributes;
22
+ let getHierarchyLevelDetails;
23
+ let node;
24
+ let onFilter;
25
+ if ($[0] !== t0) {
26
+ ({node, onFilter, getHierarchyLevelDetails, ...actionAttributes} = t0);
27
+ $[0] = t0;
28
+ $[1] = actionAttributes;
29
+ $[2] = getHierarchyLevelDetails;
30
+ $[3] = node;
31
+ $[4] = onFilter;
32
+ } else {
33
+ actionAttributes = $[1];
34
+ getHierarchyLevelDetails = $[2];
35
+ node = $[3];
36
+ onFilter = $[4];
37
+ }
38
+ const { localizedStrings } = useLocalizationContext();
39
+ const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;
40
+ let t1;
41
+ if ($[5] !== getHierarchyLevelDetails || $[6] !== node.id || $[7] !== onFilter) {
42
+ t1 = () => {
43
+ const hierarchyLevelDetails = getHierarchyLevelDetails(node.id);
44
+ hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);
45
+ };
46
+ $[5] = getHierarchyLevelDetails;
47
+ $[6] = node.id;
48
+ $[7] = onFilter;
49
+ $[8] = t1;
50
+ } else t1 = $[8];
51
+ const handleClick = t1;
52
+ const t2 = node.isFiltered ? true : void 0;
53
+ const t3 = node.isFiltered ? filterHierarchyLevelActiveDescription : void 0;
54
+ const t4 = !onFilter || !node.isFilterable;
55
+ let t5;
56
+ if ($[9] !== actionAttributes || $[10] !== filterHierarchyLevel || $[11] !== handleClick || $[12] !== t2 || $[13] !== t3 || $[14] !== t4) {
57
+ t5 = /* @__PURE__ */ jsx(TreeActionBase, {
58
+ ...actionAttributes,
59
+ label: filterHierarchyLevel,
60
+ onClick: handleClick,
61
+ icon: filterSvg,
62
+ visible: t2,
63
+ dot: t3,
64
+ hide: t4
65
+ });
66
+ $[9] = actionAttributes;
67
+ $[10] = filterHierarchyLevel;
68
+ $[11] = handleClick;
69
+ $[12] = t2;
70
+ $[13] = t3;
71
+ $[14] = t4;
72
+ $[15] = t5;
73
+ } else t5 = $[15];
74
+ return t5;
28
75
  });
76
+
77
+ //#endregion
78
+ export { TreeNodeFilterAction };
29
79
  //# sourceMappingURL=TreeNodeFilterAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeFilterAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAS3E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,oBAAoB,CAAC,EACrE,IAAI,EACJ,QAAQ,EACR,wBAAwB,EACxB,GAAG,gBAAgB,EAC4B;IAC/C,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,EAAE,oBAAoB,EAAE,qCAAqC,EAAE,GAAG,gBAAgB,CAAC;IAEzF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClE,qBAAqB,IAAI,QAAQ,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAC7D,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE/C,OAAO,CACL,KAAC,cAAc,OACT,gBAAgB,EACpB,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC3C,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,SAAS,EACxE,IAAI,EAAE,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,GACrC,CACH,CAAC;AACJ,CAAC,CAAC,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 { memo, useCallback } from \"react\";\nimport filterSvg from \"@stratakit/icons/filter.svg\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { TreeNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /** Action to perform when the filter button is clicked for this node. */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & TreeActionBaseAttributes &\n Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n *\n * The action calls the `onFilter` callback prop when clicked.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeFilterAction = memo(function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n}: TreeNodeFilterActionProps & { node: TreeNode }) {\n const { localizedStrings } = useLocalizationContext();\n const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;\n\n const handleClick = useCallback(() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n }, [node, getHierarchyLevelDetails, onFilter]);\n\n return (\n <TreeActionBase\n {...actionAttributes}\n label={filterHierarchyLevel}\n onClick={handleClick}\n icon={filterSvg}\n visible={node.isFiltered ? true : undefined}\n dot={node.isFiltered ? filterHierarchyLevelActiveDescription : undefined}\n hide={!onFilter || !node.isFilterable}\n />\n );\n});\n"]}
1
+ {"version":3,"file":"TreeNodeFilterAction.js","names":["memo","useCallback","filterSvg","useLocalizationContext","TreeActionBase","NamedExoticComponent","HierarchyLevelDetails","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeFilterActionProps","onFilter","hierarchyLevelDetails","Pick","TreeNodeFilterAction","node","t0","$","_c","actionAttributes","getHierarchyLevelDetails","localizedStrings","filterHierarchyLevel","filterHierarchyLevelActiveDescription","t1","id","handleClick","t2","isFiltered","undefined","t3","t4","isFilterable","t5"],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.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 { memo, useCallback } from \"react\";\nimport filterSvg from \"@stratakit/icons/filter.svg\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport type { NamedExoticComponent } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /**\n * Action to perform when the filter button is clicked for this node.\n */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & TreeActionBaseAttributes &\n Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n *\n * The action calls the `onFilter` callback prop when clicked.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeFilterAction: NamedExoticComponent<TreeNodeFilterActionProps & { node: TreeNode }> = memo(function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n}: TreeNodeFilterActionProps & { node: TreeNode }) {\n const { localizedStrings } = useLocalizationContext();\n const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;\n\n const handleClick = useCallback(() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n }, [node, getHierarchyLevelDetails, onFilter]);\n\n return (\n <TreeActionBase\n {...actionAttributes}\n label={filterHierarchyLevel}\n onClick={handleClick}\n icon={filterSvg}\n visible={node.isFiltered ? true : undefined}\n dot={node.isFiltered ? filterHierarchyLevelActive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A;GACEI,SAAAA;GACHxB,MAAAA;GACG,SAAAyB;GACJ,KAAAG;GACC,MAAAC;IACN;AAAAd,IAAA,KAAAE;AAAAF,IAAA,MAAAK;AAAAL,IAAA,MAAAS;AAAAT,IAAA,MAAAU;AAAAV,IAAA,MAAAa;AAAAb,IAAA,MAAAc;AAAAd,IAAA,MAAAgB;OAAAA,MAAAhB,EAAA;AAAA,QARFgB;EAUF"}
@@ -1,6 +1,9 @@
1
- import { PropsWithChildren } from "react";
2
1
  import { TreeNode } from "../TreeNode.js";
3
2
  import { TreeActionBaseAttributes } from "./TreeAction.js";
3
+ import { NamedExoticComponent, PropsWithChildren } from "react";
4
+ import "react/jsx-runtime";
5
+
6
+ //#region src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts
4
7
  /**
5
8
  * React component that renders a rename action for a tree item.
6
9
  *
@@ -12,46 +15,19 @@ import { TreeActionBaseAttributes } from "./TreeAction.js";
12
15
  *
13
16
  * @alpha
14
17
  */
15
- export declare const TreeNodeRenameAction: import("react").NamedExoticComponent<TreeActionBaseAttributes & {
16
- node: TreeNode;
18
+ declare const TreeNodeRenameAction: NamedExoticComponent<TreeActionBaseAttributes & {
19
+ node: TreeNode;
17
20
  }>;
18
21
  /** @alpha */
19
- export interface TreeNodeEditingProps {
20
- /**
21
- * A callback that is invoked when node label is changed. Should be used together
22
- * with `<TreeNodeRenameAction />` to enter label editing mode.
23
- */
24
- onLabelChanged: (newLabel: string) => void;
25
- labelValidationHint?: string;
26
- validate?: (newLabel: string) => boolean;
22
+ interface TreeNodeEditingProps {
23
+ /**
24
+ * A callback that is invoked when node label is changed. Should be used together
25
+ * with `<TreeNodeRenameAction />` to enter label editing mode.
26
+ */
27
+ onLabelChanged: (newLabel: string) => void;
28
+ labelValidationHint?: string;
29
+ validate?: (newLabel: string) => boolean;
27
30
  }
28
- /** @internal */
29
- export interface RenameParameters {
30
- nodeId: string;
31
- commit: (newLabel: string) => void;
32
- labelValidationHint?: string;
33
- validate?: (newLabel: string) => boolean;
34
- }
35
- interface TreeNodeRenameContext {
36
- renameParameters?: RenameParameters;
37
- startRename: (node: TreeNode) => void;
38
- canRename: (node: TreeNode) => boolean;
39
- cancelRename: () => void;
40
- }
41
- /** @internal */
42
- export declare const useTreeNodeRenameContext: () => TreeNodeRenameContext | undefined;
43
- /** @internal */
44
- export declare function TreeNodeRenameContextProvider({ value, children }: PropsWithChildren<{
45
- value: TreeNodeRenameContext;
46
- }>): import("react/jsx-runtime").JSX.Element;
47
- /** @internal */
48
- export declare function useTreeNodeRenameContextValue({ getEditingProps }: {
49
- getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;
50
- }): {
51
- renameParameters: RenameParameters | undefined;
52
- cancelRename: () => void;
53
- startRename: (node: TreeNode) => void;
54
- canRename: (node: TreeNode) => boolean;
55
- };
56
- export {};
31
+ //#endregion
32
+ export { TreeNodeEditingProps, TreeNodeRenameAction };
57
33
  //# sourceMappingURL=TreeNodeRenameAction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenameAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAuB,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAE3G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB;UAAwG,QAAQ;EAY/I,CAAC;AAEH,aAAa;AACb,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C;AAED,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C;AAED,UAAU,qBAAqB;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACtC,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;IACvC,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAID,gBAAgB;AAChB,eAAO,MAAM,wBAAwB,yCAEpC,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,6BAA6B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC;IAAE,KAAK,EAAE,qBAAqB,CAAA;CAAE,CAAC,2CAErH;AAED,gBAAgB;AAChB,wBAAgB,6BAA6B,CAAC,EAAE,eAAe,EAAE,EAAE;IAAE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,oBAAoB,GAAG,SAAS,CAAA;CAAE;;;wBAIlI,QAAQ;sBAsBR,QAAQ;EAelB"}
1
+ {"version":3,"file":"TreeNodeRenameAction.d.ts","names":[],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"mappings":";;;;;;;;;AAyBA;;;;;;;;cAAa,oBAAA,EAAsB,oBAAA,CAAqB,wBAAA;EAA6B,IAAA,EAAM,QAAA;AAAA;;UAkB1E,oBAAA;EAlBkF;AAkBnG;;;EAKE,cAAA,GAAiB,QAAA;EACjB,mBAAA;EACA,QAAA,IAAY,QAAA;AAAA"}
@@ -1,71 +1,150 @@
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, memo, useCallback, useContext, useMemo, useState } from "react";
7
- import renameSvg from "@stratakit/icons/rename.svg";
8
- import { useLocalizationContext } from "./LocalizationContext.js";
9
1
  import { TreeActionBase } from "./TreeAction.js";
2
+ import { useLocalizationContext } from "./LocalizationContext.js";
3
+ import { c } from "react-compiler-runtime";
4
+ import { createContext, memo, useContext, useState } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import renameSvg from "@stratakit/icons/rename.svg";
7
+
8
+ //#region src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx
10
9
  /**
11
- * React component that renders a rename action for a tree item.
12
- *
13
- * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When
14
- * rename is completed, the `onLabelChanged` function is called to make the actual data update.
15
- *
16
- * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
17
- * to tree items.
18
- *
19
- * @alpha
20
- */
21
- export const TreeNodeRenameAction = memo(function TreeNodeRenameAction({ node, ...actionAttributes }) {
22
- const { localizedStrings } = useLocalizationContext();
23
- const context = useTreeNodeRenameContext();
24
- const { rename } = localizedStrings;
25
- const canRename = context?.canRename(node) ?? false;
26
- const startRename = context?.startRename;
27
- const handleClick = useCallback(() => {
28
- startRename?.(node);
29
- }, [startRename, node]);
30
- return _jsx(TreeActionBase, { ...actionAttributes, label: rename, onClick: handleClick, icon: renameSvg, hide: !canRename });
10
+ * React component that renders a rename action for a tree item.
11
+ *
12
+ * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When
13
+ * rename is completed, the `onLabelChanged` function is called to make the actual data update.
14
+ *
15
+ * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
16
+ * to tree items.
17
+ *
18
+ * @alpha
19
+ */
20
+ const TreeNodeRenameAction = memo(function TreeNodeRenameAction(t0) {
21
+ const $ = c(14);
22
+ let actionAttributes;
23
+ let node;
24
+ if ($[0] !== t0) {
25
+ ({node, ...actionAttributes} = t0);
26
+ $[0] = t0;
27
+ $[1] = actionAttributes;
28
+ $[2] = node;
29
+ } else {
30
+ actionAttributes = $[1];
31
+ node = $[2];
32
+ }
33
+ const { localizedStrings } = useLocalizationContext();
34
+ const context = useTreeNodeRenameContext();
35
+ const { rename } = localizedStrings;
36
+ let t1;
37
+ if ($[3] !== context || $[4] !== node) {
38
+ t1 = context?.canRename(node) ?? false;
39
+ $[3] = context;
40
+ $[4] = node;
41
+ $[5] = t1;
42
+ } else t1 = $[5];
43
+ const canRename = t1;
44
+ const startRename = context?.startRename;
45
+ let t2;
46
+ if ($[6] !== node || $[7] !== startRename) {
47
+ t2 = () => {
48
+ startRename?.(node);
49
+ };
50
+ $[6] = node;
51
+ $[7] = startRename;
52
+ $[8] = t2;
53
+ } else t2 = $[8];
54
+ const handleClick = t2;
55
+ const t3 = !canRename;
56
+ let t4;
57
+ if ($[9] !== actionAttributes || $[10] !== handleClick || $[11] !== rename || $[12] !== t3) {
58
+ t4 = /* @__PURE__ */ jsx(TreeActionBase, {
59
+ ...actionAttributes,
60
+ label: rename,
61
+ onClick: handleClick,
62
+ icon: renameSvg,
63
+ hide: t3
64
+ });
65
+ $[9] = actionAttributes;
66
+ $[10] = handleClick;
67
+ $[11] = rename;
68
+ $[12] = t3;
69
+ $[13] = t4;
70
+ } else t4 = $[13];
71
+ return t4;
31
72
  });
32
- const treeNodeRenameContext = createContext(undefined);
73
+ const treeNodeRenameContext = createContext(void 0);
33
74
  /** @internal */
34
- export const useTreeNodeRenameContext = () => {
35
- return useContext(treeNodeRenameContext);
75
+ const useTreeNodeRenameContext = () => {
76
+ return useContext(treeNodeRenameContext);
36
77
  };
37
78
  /** @internal */
38
- export function TreeNodeRenameContextProvider({ value, children }) {
39
- return _jsx(treeNodeRenameContext.Provider, { value: value, children: children });
79
+ function TreeNodeRenameContextProvider(t0) {
80
+ const $ = c(3);
81
+ const { value, children } = t0;
82
+ let t1;
83
+ if ($[0] !== children || $[1] !== value) {
84
+ t1 = /* @__PURE__ */ jsx(treeNodeRenameContext.Provider, {
85
+ value,
86
+ children
87
+ });
88
+ $[0] = children;
89
+ $[1] = value;
90
+ $[2] = t1;
91
+ } else t1 = $[2];
92
+ return t1;
40
93
  }
41
94
  /** @internal */
42
- export function useTreeNodeRenameContextValue({ getEditingProps }) {
43
- const [renameParameters, setRenameParameters] = useState(undefined);
44
- const startRename = useCallback((node) => {
45
- const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};
46
- if (onLabelChanged) {
47
- setRenameParameters({
48
- nodeId: node.id,
49
- commit: (newLabel) => {
50
- onLabelChanged(newLabel);
51
- setRenameParameters(undefined);
52
- },
53
- labelValidationHint,
54
- validate,
55
- });
56
- }
57
- }, [getEditingProps]);
58
- const cancelRename = useCallback(() => {
59
- setRenameParameters(undefined);
60
- }, []);
61
- const canRename = useCallback((node) => {
62
- return getEditingProps?.(node)?.onLabelChanged !== undefined;
63
- }, [getEditingProps]);
64
- return useMemo(() => ({
65
- renameParameters,
66
- cancelRename,
67
- startRename,
68
- canRename,
69
- }), [renameParameters, canRename, startRename, cancelRename]);
95
+ function useTreeNodeRenameContextValue(t0) {
96
+ const $ = c(9);
97
+ const { getEditingProps } = t0;
98
+ const [renameParameters, setRenameParameters] = useState(void 0);
99
+ let t1;
100
+ if ($[0] !== getEditingProps) {
101
+ t1 = (node) => {
102
+ const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};
103
+ if (onLabelChanged) setRenameParameters({
104
+ nodeId: node.id,
105
+ commit: (newLabel) => {
106
+ onLabelChanged(newLabel);
107
+ setRenameParameters(void 0);
108
+ },
109
+ labelValidationHint,
110
+ validate
111
+ });
112
+ };
113
+ $[0] = getEditingProps;
114
+ $[1] = t1;
115
+ } else t1 = $[1];
116
+ const startRename = t1;
117
+ let t2;
118
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
119
+ t2 = () => {
120
+ setRenameParameters(void 0);
121
+ };
122
+ $[2] = t2;
123
+ } else t2 = $[2];
124
+ const cancelRename = t2;
125
+ let t3;
126
+ if ($[3] !== getEditingProps) {
127
+ t3 = (node_0) => getEditingProps?.(node_0)?.onLabelChanged !== void 0;
128
+ $[3] = getEditingProps;
129
+ $[4] = t3;
130
+ } else t3 = $[4];
131
+ const canRename = t3;
132
+ let t4;
133
+ if ($[5] !== canRename || $[6] !== renameParameters || $[7] !== startRename) {
134
+ t4 = {
135
+ renameParameters,
136
+ cancelRename,
137
+ startRename,
138
+ canRename
139
+ };
140
+ $[5] = canRename;
141
+ $[6] = renameParameters;
142
+ $[7] = startRename;
143
+ $[8] = t4;
144
+ } else t4 = $[8];
145
+ return t4;
70
146
  }
147
+
148
+ //#endregion
149
+ export { TreeNodeRenameAction, TreeNodeRenameContextProvider, useTreeNodeRenameContext, useTreeNodeRenameContextValue };
71
150
  //# sourceMappingURL=TreeNodeRenameAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenameAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,IAAI,EAAqB,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3G,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,oBAAoB,CAAC,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAiD;IACjJ,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,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AAI,CAAC,IAAI,EAAE,CAAC;QACxF,IAAI,cAAc,EAAE,CAAC;YACnB,mBAAmB,CAAC;gBAClB,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE;oBACnB,cAAc,CAAC,QAAQ,CAAC,CAAC;oBACzB,mBAAmB,CAAC,SAAS,CAAC,CAAC;gBACjC,CAAC;gBACD,mBAAmB;gBACnB,QAAQ;aACT,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EACD,CAAC,eAAe,CAAC,CAClB,CAAC;IAEF,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;QACpC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,IAAc,EAAE,EAAE;QACjB,OAAO,eAAe,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,SAAS,CAAC;IAC/D,CAAC,EACD,CAAC,eAAe,CAAC,CAClB,CAAC;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,gBAAgB;QAChB,YAAY;QACZ,WAAW;QACX,SAAS;KACV,CAAC,EACF,CAAC,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,CAAC,CACzD,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 { createContext, memo, PropsWithChildren, useCallback, useContext, useMemo, useState } from \"react\";\nimport renameSvg from \"@stratakit/icons/rename.svg\";\nimport { TreeNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/**\n * React component that renders a rename action for a tree item.\n *\n * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When\n * rename is completed, the `onLabelChanged` function is called to make the actual data update.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeRenameAction = memo(function TreeNodeRenameAction({ node, ...actionAttributes }: TreeActionBaseAttributes & { node: TreeNode }) {\n const { localizedStrings } = useLocalizationContext();\n const context = useTreeNodeRenameContext();\n const { rename } = localizedStrings;\n\n const canRename = context?.canRename(node) ?? false;\n const startRename = context?.startRename;\n const handleClick = useCallback(() => {\n startRename?.(node);\n }, [startRename, node]);\n\n return <TreeActionBase {...actionAttributes} label={rename} onClick={handleClick} icon={renameSvg} hide={!canRename} />;\n});\n\n/** @alpha */\nexport interface TreeNodeEditingProps {\n /**\n * A callback that is invoked when node label is changed. Should be used together\n * with `<TreeNodeRenameAction />` to enter label editing mode.\n */\n onLabelChanged: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\n/** @internal */\nexport interface RenameParameters {\n nodeId: string;\n commit: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\ninterface TreeNodeRenameContext {\n renameParameters?: RenameParameters;\n startRename: (node: TreeNode) => void;\n canRename: (node: TreeNode) => boolean;\n cancelRename: () => void;\n}\n\nconst treeNodeRenameContext = createContext<TreeNodeRenameContext | undefined>(undefined);\n\n/** @internal */\nexport const useTreeNodeRenameContext = () => {\n return useContext(treeNodeRenameContext);\n};\n\n/** @internal */\nexport function TreeNodeRenameContextProvider({ value, children }: PropsWithChildren<{ value: TreeNodeRenameContext }>) {\n return <treeNodeRenameContext.Provider value={value}>{children}</treeNodeRenameContext.Provider>;\n}\n\n/** @internal */\nexport function useTreeNodeRenameContextValue({ getEditingProps }: { getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined }) {\n const [renameParameters, setRenameParameters] = useState<RenameParameters | undefined>(undefined);\n\n const startRename = useCallback(\n (node: TreeNode) => {\n const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};\n if (onLabelChanged) {\n setRenameParameters({\n nodeId: node.id,\n commit: (newLabel) => {\n onLabelChanged(newLabel);\n setRenameParameters(undefined);\n },\n labelValidationHint,\n validate,\n });\n }\n },\n [getEditingProps],\n );\n\n const cancelRename = useCallback(() => {\n setRenameParameters(undefined);\n }, []);\n\n const canRename = useCallback(\n (node: TreeNode) => {\n return getEditingProps?.(node)?.onLabelChanged !== undefined;\n },\n [getEditingProps],\n );\n\n return useMemo(\n () => ({\n renameParameters,\n cancelRename,\n startRename,\n canRename,\n }),\n [renameParameters, canRename, startRename, cancelRename],\n );\n}\n"]}
1
+ {"version":3,"file":"TreeNodeRenameAction.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","renameSvg","useLocalizationContext","TreeActionBase","NamedExoticComponent","PropsWithChildren","TreeNode","TreeActionBaseAttributes","TreeNodeRenameAction","node","t0","$","_c","actionAttributes","localizedStrings","context","useTreeNodeRenameContext","rename","t1","canRename","startRename","t2","handleClick","t3","t4","TreeNodeEditingProps","onLabelChanged","newLabel","labelValidationHint","validate","RenameParameters","nodeId","commit","TreeNodeRenameContext","renameParameters","cancelRename","treeNodeRenameContext","undefined","TreeNodeRenameContextProvider","value","children","useTreeNodeRenameContextValue","getEditingProps","setRenameParameters","id","Symbol","for","node_0"],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.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, memo, useCallback, useContext, useMemo, useState } from \"react\";\nimport renameSvg from \"@stratakit/icons/rename.svg\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport type { NamedExoticComponent, PropsWithChildren } from \"react\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/**\n * React component that renders a rename action for a tree item.\n *\n * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When\n * rename is completed, the `onLabelChanged` function is called to make the actual data update.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeRenameAction: NamedExoticComponent<TreeActionBaseAttributes & { node: TreeNode }> = memo(function TreeNodeRenameAction({\n node,\n ...actionAttributes\n}: TreeActionBaseAttributes & { node: TreeNode }) {\n const { localizedStrings } = useLocalizationContext();\n const context = useTreeNodeRenameContext();\n const { rename } = localizedStrings;\n\n const canRename = context?.canRename(node) ?? false;\n const startRename = context?.startRename;\n const handleClick = useCallback(() => {\n startRename?.(node);\n }, [startRename, node]);\n\n return <TreeActionBase {...actionAttributes} label={rename} onClick={handleClick} icon={renameSvg} hide={!canRename} />;\n});\n\n/** @alpha */\nexport interface TreeNodeEditingProps {\n /**\n * A callback that is invoked when node label is changed. Should be used together\n * with `<TreeNodeRenameAction />` to enter label editing mode.\n */\n onLabelChanged: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\n/** @internal */\nexport interface RenameParameters {\n nodeId: string;\n commit: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\ninterface TreeNodeRenameContext {\n renameParameters?: RenameParameters;\n startRename: (node: TreeNode) => void;\n canRename: (node: TreeNode) => boolean;\n cancelRename: () => void;\n}\n\nconst treeNodeRenameContext = createContext<TreeNodeRenameContext | undefined>(undefined);\n\n/** @internal */\nexport const useTreeNodeRenameContext = () => {\n return useContext(treeNodeRenameContext);\n};\n\n/** @internal */\nexport function TreeNodeRenameContextProvider({ value, children }: PropsWithChildren<{ value: TreeNodeRenameContext }>) {\n return <treeNodeRenameContext.Provider value={value}>{children}</treeNodeRenameContext.Provider>;\n}\n\n/** @internal */\nexport function useTreeNodeRenameContextValue({ getEditingProps }: { getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined }) {\n const [renameParameters, setRenameParameters] = useState<RenameParameters | undefined>(undefined);\n\n const startRename = useCallback(\n (node: TreeNode) => {\n const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};\n if (onLabelChanged) {\n setRenameParameters({\n nodeId: node.id,\n commit: (newLabel) => {\n onLabelChanged(newLabel);\n setRenameParameters(undefined);\n },\n labelValidationHint,\n validate,\n });\n }\n },\n [getEditingProps],\n );\n\n const cancelRename = useCallback(() => {\n setRenameParameters(undefined);\n }, []);\n\n const canRename = useCallback(\n (node: TreeNode) => {\n return getEditingProps?.(node)?.onLabelChanged !== undefined;\n },\n [getEditingProps],\n );\n\n return useMemo(\n () => ({\n renameParameters,\n cancelRename,\n startRename,\n canRename,\n }),\n [renameParameters, canRename, startRename, cancelRename],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,MAAaa,uBAA4FZ,KAAK,SAAAY,qBAAAE,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;CAAA,IAAAJ;AAAA,KAAAE,EAAA,OAAAD,IAAA;AAA8B,GAAA,CAAAD,SAAAI,oBAAAH;AAG5FC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;AAAAF,IAAA,KAAAF;QAAA;AAAAI,qBAAAF,EAAA;AAAAF,SAAAE,EAAA;;CAC9C,MAAA,EAAAG,qBAA6BZ,wBAAwB;CACrD,MAAAa,UAAgBC,0BAA0B;CAC1C,MAAA,EAAAC,WAAmBH;CAAiB,IAAAI;AAAA,KAAAP,EAAA,OAAAI,WAAAJ,EAAA,OAAAF,MAAA;AAElBS,OAAAH,SAAOI,UAAYV,KAAc,IAAjC;AAAiCE,IAAA,KAAAI;AAAAJ,IAAA,KAAAF;AAAAE,IAAA,KAAAO;OAAAA,MAAAP,EAAA;CAAnD,MAAAQ,YAA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,EAAA,OAAA+B,iBAAA;AAGhGxB,QAAAT,SAAA;GACE,MAAA,EAAAiB,gBAAAE,qBAAAC,aAA0Da,kBAAkBjC,KAAW,IAA7B,EAA6B;AACvF,OAAIiB,eACFiB,qBAAoB;IAAAZ,QACVtB,KAAImC;IAAGZ,SACPL,aAAA;AACND,oBAAeC,SAAS;AACxBgB,yBAAoBN,OAAU;;IAC/BT;IAAAC;IAGF,CAAC;;AAELlB,IAAA,KAAA+B;AAAA/B,IAAA,KAAAO;OAAAA,MAAAP,EAAA;CAdH,MAAAS,cAAoBF;CAgBlB,IAAAG;AAAA,KAAAV,EAAA,OAAAkC,OAAAC,IAAA,4BAAA,EAAA;AAE+BzB,aAAA;AAC/BsB,uBAAoBN,OAAU;;AAC/B1B,IAAA,KAAAU;OAAAA,MAAAV,EAAA;CAFD,MAAAwB,eAAqBd;CAEd,IAAAE;AAAA,KAAAZ,EAAA,OAAA+B,iBAAA;AAGLnB,QAAAwB,WACSL,kBAAkBjC,OAAqB,EAAAiB,mBAAKW;AACpD1B,IAAA,KAAA+B;AAAA/B,IAAA,KAAAY;OAAAA,MAAAZ,EAAA;CAHH,MAAAQ,YAAkBI;CAKhB,IAAAC;AAAA,KAAAb,EAAA,OAAAQ,aAAAR,EAAA,OAAAuB,oBAAAvB,EAAA,OAAAS,aAAA;AAGOI,OAAA;GAAAU;GAAAC;GAAAf;GAAAD;GAKN;AAAAR,IAAA,KAAAQ;AAAAR,IAAA,KAAAuB;AAAAvB,IAAA,KAAAS;AAAAT,IAAA,KAAAa;OAAAA,MAAAb,EAAA;AAAA,QALMa"}
@@ -1,46 +1,18 @@
1
- import "./TreeNodeRenderer.css";
2
- import { ComponentPropsWithoutRef, FC, PropsWithRef, ReactNode, RefAttributes } from "react";
1
+ import "../TreeNode.js";
2
+ import "../Renderers.js";
3
+ import { ComponentPropsWithoutRef, FC, ReactNode, RefAttributes } from "react";
3
4
  import { Tree } from "@stratakit/structures";
4
- import { TreeRendererProps } from "../Renderers.js";
5
- import { TreeNode } from "../TreeNode.js";
6
- /** @internal */
7
- interface TreeNodeRendererOwnProps extends Pick<TreeRendererProps, "expandNode" | "reloadTree"> {
8
- /** Node that is rendered. */
9
- node: TreeNode;
10
- /**
11
- * Menu actions for tree item.
12
- * Must be an array of `<TreeActionBase />` or `<Divider />` elements.
13
- */
14
- menuActions?: ReactNode[];
15
- /**
16
- * Inline actions for tree item.
17
- * Must be an array of `<TreeActionBase />` elements.
18
- * Max 2 items.
19
- */
20
- inlineActions?: ReactNode[];
21
- /**
22
- * Context menu actions for tree item.
23
- * Must be an array of `<TreeActionBase />` or `<Divider />` elements.
24
- */
25
- contextMenuActions?: ReactNode[];
26
- }
5
+ import "./TreeNodeRenderer.css";
6
+
7
+ //#region src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts
27
8
  /** @alpha */
28
- export type StrataKitTreeItemProps = Omit<ComponentPropsWithoutRef<typeof Tree.Item>, "actions" | "inlineActions" | "expanded" | "onExpandedChange" | "icon" | "unstable_decorations" | "error"> & {
29
- /**
30
- * Used to render elements between expander and label.
31
- * E.g. icons, color picker, etc.
32
- */
33
- decorations?: ReactNode;
9
+ type StrataKitTreeItemProps = Omit<ComponentPropsWithoutRef<typeof Tree.Item>, "actions" | "inlineActions" | "expanded" | "onExpandedChange" | "icon" | "unstable_decorations" | "error"> & {
10
+ /**
11
+ * Used to render elements between expander and label.
12
+ * E.g. icons, color picker, etc.
13
+ */
14
+ decorations?: ReactNode;
34
15
  };
35
- /** @internal */
36
- export type TreeNodeRendererProps = StrataKitTreeItemProps & TreeNodeRendererOwnProps;
37
- /**
38
- * A component that renders given `FlatTreeNode` using the `Tree.Item` component from `@itwin/itwinui-react`. The
39
- * `FlatTreeNode` objects for this renderer are generally created using the `useFlatTreeNodeList` hook.
40
- *
41
- * @internal
42
- */
43
- export declare const StrataKitTreeNodeRenderer: FC<PropsWithRef<TreeNodeRendererProps & RefAttributes<HTMLElement>>>;
44
- export declare const PlaceholderNode: FC<PropsWithRef<Pick<StrataKitTreeItemProps, "style" | "aria-level" | "aria-posinset" | "aria-setsize"> & RefAttributes<HTMLElement>>>;
45
- export {};
16
+ //#endregion
17
+ export { StrataKitTreeItemProps };
46
18
  //# sourceMappingURL=TreeNodeRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAEL,wBAAwB,EACxB,EAAE,EAIF,YAAY,EACZ,SAAS,EACT,aAAa,EAOd,MAAM,OAAO,CAAC;AAKf,OAAO,EAA6C,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,gBAAgB;AAChB,UAAU,wBAAyB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,CAAC;IAC7F,6BAA6B;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAC;CAClC;AAED,aAAa;AACb,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,wBAAwB,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,EAC1C,SAAS,GAAG,eAAe,GAAG,UAAU,GAAG,kBAAkB,GAAG,MAAM,GAAG,sBAAsB,GAAG,OAAO,CAC1G,GAAG;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,GAAG,wBAAwB,CAA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