@itwin/presentation-hierarchies-react 2.0.0-alpha.49 → 2.0.0-alpha.50

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 (50) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -3
  3. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +2 -2
  4. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -1
  5. package/lib/esm/presentation-hierarchies-react/Renderers.js.map +1 -1
  6. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +3 -3
  7. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  8. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
  9. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +2 -2
  10. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -1
  11. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -1
  12. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +9 -7
  13. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  14. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +6 -14
  15. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  16. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +2 -2
  17. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  18. package/lib/esm/presentation-hierarchies-react/UseTree.js +5 -5
  19. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  20. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +9 -8
  21. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -1
  22. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +9 -10
  23. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
  24. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +8 -20
  25. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -1
  26. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +8 -27
  27. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
  28. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +5 -22
  29. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
  30. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +7 -10
  31. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
  32. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +2 -2
  33. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -1
  34. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
  35. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +8 -8
  36. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
  37. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +1 -1
  38. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
  39. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +2 -2
  40. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
  41. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
  42. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +11 -11
  43. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
  44. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +86 -68
  45. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
  46. package/lib/esm/presentation-hierarchies-react.d.ts +2 -3
  47. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  48. package/lib/esm/presentation-hierarchies-react.js +1 -2
  49. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  50. package/package.json +3 -3
@@ -16,9 +16,8 @@ import { useLocalizationContext } from "./LocalizationContext.js";
16
16
  *
17
17
  * @alpha
18
18
  */
19
- export function ErrorItemRenderer({ errorItem, getHierarchyLevelDetails, onFilterClick, reloadTree, scrollToElement }) {
19
+ export function ErrorItemRenderer({ errorNode, getHierarchyLevelDetails, filterHierarchyLevel, reloadTree, scrollToNode }) {
20
20
  const { localizedStrings } = useLocalizationContext();
21
- const { errorNode, expandTo } = errorItem;
22
21
  if (errorNode.error.type === "ResultSetTooLarge") {
23
22
  const limit = errorNode.error.resultSetSizeLimit;
24
23
  const onOverrideLimit = getHierarchyLevelDetails ? () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE) : undefined;
@@ -33,35 +32,35 @@ export function ErrorItemRenderer({ errorItem, getHierarchyLevelDetails, onFilte
33
32
  {
34
33
  action: () => {
35
34
  const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);
36
- hierarchyLevelDetails && onFilterClick?.(hierarchyLevelDetails);
35
+ hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);
37
36
  },
38
37
  label: localizedStrings.increaseHierarchyLimitWithFiltering,
39
- condition: () => !!onFilterClick && !!errorNode?.isFilterable,
38
+ condition: () => !!filterHierarchyLevel && !!errorNode?.isFilterable,
40
39
  },
41
- ], message: localizedStrings.resultLimitExceeded.replace("{{limit}}", limit.toString()), scrollToElement: () => scrollToElement({ errorNode, expandTo }) }));
40
+ ], message: localizedStrings.resultLimitExceeded.replace("{{limit}}", limit.toString()), scrollToElement: () => scrollToNode(errorNode) }));
42
41
  }
43
42
  if (errorNode.error.type === "NoFilterMatches") {
44
43
  return (_jsx(ErrorItemContainer, { errorNode: errorNode, actions: [
45
44
  {
46
45
  action: () => {
47
46
  const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);
48
- hierarchyLevelDetails && onFilterClick?.(hierarchyLevelDetails);
47
+ hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);
49
48
  },
50
49
  label: localizedStrings.noFilteredChildrenChangeFilter,
51
50
  condition: () => true,
52
51
  },
53
- ], message: localizedStrings.noFilteredChildren, scrollToElement: () => scrollToElement({ errorNode, expandTo }) }));
52
+ ], message: localizedStrings.noFilteredChildren, scrollToElement: () => scrollToNode(errorNode) }));
54
53
  }
55
54
  if (errorNode.error.type === "ChildrenLoad") {
56
55
  return (_jsx(ErrorItemContainer, { errorNode: errorNode, actions: [
57
56
  {
58
- action: () => reloadTree({ parentNodeId: errorNode.id, state: "reset" }),
57
+ action: () => reloadTree({ parentNodeId: errorNode.id }),
59
58
  label: localizedStrings.retry,
60
59
  condition: () => true,
61
60
  },
62
- ], message: localizedStrings.failedToCreateHierarchy, scrollToElement: () => scrollToElement({ errorNode, expandTo }) }));
61
+ ], message: localizedStrings.failedToCreateHierarchy, scrollToElement: () => scrollToNode(errorNode) }));
63
62
  }
64
- return _jsx(ErrorItemContainer, { errorNode: errorNode, message: errorNode.error.message, scrollToElement: () => scrollToElement({ errorNode, expandTo }) });
63
+ return _jsx(ErrorItemContainer, { errorNode: errorNode, message: errorNode.error.message, scrollToElement: () => scrollToNode(errorNode) });
65
64
  }
66
65
  function ErrorItemContainer({ errorNode, message, actions, scrollToElement }) {
67
66
  return (_jsx(ErrorRegion.Item, { message: _jsx(MessageWithLink, { linkLabel: errorNode.label, scrollToElement: scrollToElement, message: message }), messageId: errorNode.id, actions: actions
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorItemRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx"],"names":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AE,eAAe,EAAE,OAAO,EAAwB;IACpF,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,aACjE,YAAY,CAAC,CAAC,CAAC,EAChB,KAAC,MAAM,IAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAU,YACjD,SAAS,GACH,EACR,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IACrC,CACP,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 { Anchor, Text } from \"@stratakit/bricks\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { ErrorItem } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n errorItem: ErrorItem;\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 /** Action to perform when an error occurs and node label is clicked in the error message */\n scrollToElement: (errorNode: ErrorItem) => void;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\n/**\n * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:\n * - `ResultSetTooLarge` - renders `LocalizedStrings.resultLimitExceeded` message with actions to increase limit or apply filtering\n * - `NoFilterMatches` - renders `LocalizedStrings.noFilteredChildren` message with action to change filter\n * - `ChildrenLoad` - renders `LocalizedStrings.failedToCreateHierarchy` message with action to retry loading\n * - `Unknown` - renders message set on error object.\n *\n * @alpha\n */\nexport function ErrorItemRenderer({ errorItem, getHierarchyLevelDetails, onFilterClick, reloadTree, scrollToElement }: ErrorItemRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n\n const { errorNode, expandTo } = errorItem;\n if (errorNode.error.type === \"ResultSetTooLarge\") {\n const limit = errorNode.error.resultSetSizeLimit;\n const onOverrideLimit = getHierarchyLevelDetails ? () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE) : undefined;\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n onOverrideLimit?.();\n },\n label: localizedStrings.increaseHierarchyLimit.replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString()),\n condition: () => !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE,\n },\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);\n hierarchyLevelDetails && onFilterClick?.(hierarchyLevelDetails);\n },\n label: localizedStrings.increaseHierarchyLimitWithFiltering,\n condition: () => !!onFilterClick && !!errorNode?.isFilterable,\n },\n ]}\n message={localizedStrings.resultLimitExceeded.replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToElement({ errorNode, expandTo })}\n />\n );\n }\n if (errorNode.error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);\n hierarchyLevelDetails && onFilterClick?.(hierarchyLevelDetails);\n },\n label: localizedStrings.noFilteredChildrenChangeFilter,\n condition: () => true,\n },\n ]}\n message={localizedStrings.noFilteredChildren}\n scrollToElement={() => scrollToElement({ errorNode, expandTo })}\n />\n );\n }\n if (errorNode.error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: errorNode.id, state: \"reset\" }),\n label: localizedStrings.retry,\n condition: () => true,\n },\n ]}\n message={localizedStrings.failedToCreateHierarchy}\n scrollToElement={() => scrollToElement({ errorNode, expandTo })}\n />\n );\n }\n\n return <ErrorItemContainer errorNode={errorNode} message={errorNode.error.message} scrollToElement={() => scrollToElement({ errorNode, expandTo })} />;\n}\n\ntype ErrorItemContainerProps = {\n errorNode: PresentationHierarchyNode;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ errorNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={errorNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={errorNode.id}\n actions={actions\n ?.filter(({ condition }) => condition())\n .map(({ label, action }) => (\n <Text key={label} variant=\"body-sm\">\n <Anchor onClick={action} render={<button />}>\n {label}\n </Anchor>\n </Text>\n ))}\n />\n );\n}\n\ninterface MessageWithLinkProps {\n scrollToElement: () => void;\n message: string;\n linkLabel?: string;\n}\n\nfunction MessageWithLink({ linkLabel, scrollToElement, message }: MessageWithLinkProps) {\n const splitMessage = message.split(\"{{node}}\", 2);\n return (\n <div style={{ display: \"flex\", whiteSpace: \"pre\", flexWrap: \"wrap\" }}>\n {splitMessage[0]}\n <Anchor onClick={scrollToElement} render={<button />}>\n {linkLabel}\n </Anchor>\n {splitMessage[1] ? splitMessage[1] : null}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"ErrorItemRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE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C,CAAC,CAAC,EAChB,KAAC,MAAM,IAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAU,YACjD,SAAS,GACH,EACR,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IACrC,CACP,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 { Anchor, Text } from \"@stratakit/bricks\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { TreeNode } from \"../TreeNode.js\";\nimport { useErrorNodes } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n /** A node containing an error. */\n errorNode: ReturnType<typeof useErrorNodes>[number];\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined }) => void;\n /** A callback to scroll to the node associated with the error. */\n scrollToNode: (errorNode: TreeNode) => void;\n /** A callback to initiate filtering of the given hierarchy level. */\n filterHierarchyLevel?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\n/**\n * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:\n * - `ResultSetTooLarge` - renders `LocalizedStrings.resultLimitExceeded` message with actions to increase limit or apply filtering\n * - `NoFilterMatches` - renders `LocalizedStrings.noFilteredChildren` message with action to change filter\n * - `ChildrenLoad` - renders `LocalizedStrings.failedToCreateHierarchy` message with action to retry loading\n * - `Unknown` - renders message set on error object.\n *\n * @alpha\n */\nexport function ErrorItemRenderer({ errorNode, getHierarchyLevelDetails, filterHierarchyLevel, reloadTree, scrollToNode }: ErrorItemRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n\n if (errorNode.error.type === \"ResultSetTooLarge\") {\n const limit = errorNode.error.resultSetSizeLimit;\n const onOverrideLimit = getHierarchyLevelDetails ? () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE) : undefined;\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n onOverrideLimit?.();\n },\n label: localizedStrings.increaseHierarchyLimit.replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString()),\n condition: () => !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE,\n },\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: localizedStrings.increaseHierarchyLimitWithFiltering,\n condition: () => !!filterHierarchyLevel && !!errorNode?.isFilterable,\n },\n ]}\n message={localizedStrings.resultLimitExceeded.replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: localizedStrings.noFilteredChildrenChangeFilter,\n condition: () => true,\n },\n ]}\n message={localizedStrings.noFilteredChildren}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: errorNode.id }),\n label: localizedStrings.retry,\n condition: () => true,\n },\n ]}\n message={localizedStrings.failedToCreateHierarchy}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n\n return <ErrorItemContainer errorNode={errorNode} message={errorNode.error.message} scrollToElement={() => scrollToNode(errorNode)} />;\n}\n\ntype ErrorItemContainerProps = {\n errorNode: TreeNode;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ errorNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={errorNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={errorNode.id}\n actions={actions\n ?.filter(({ condition }) => condition())\n .map(({ label, action }) => (\n <Text key={label} variant=\"body-sm\">\n <Anchor onClick={action} render={<button />}>\n {label}\n </Anchor>\n </Text>\n ))}\n />\n );\n}\n\ninterface MessageWithLinkProps {\n scrollToElement: () => void;\n message: string;\n linkLabel?: string;\n}\n\nfunction MessageWithLink({ linkLabel, scrollToElement, message }: MessageWithLinkProps) {\n const splitMessage = message.split(\"{{node}}\", 2);\n return (\n <div style={{ display: \"flex\", whiteSpace: \"pre\", flexWrap: \"wrap\" }}>\n {splitMessage[0]}\n <Anchor onClick={scrollToElement} render={<button />}>\n {linkLabel}\n </Anchor>\n {splitMessage[1] ? splitMessage[1] : null}\n </div>\n );\n}\n"]}
@@ -1,16 +1,16 @@
1
- import { PresentationHierarchyNode } from "../TreeNode.js";
1
+ import { TreeNode } from "../TreeNode.js";
2
2
  /**
3
3
  * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.
4
4
  *
5
5
  * @alpha
6
- * */
6
+ */
7
7
  interface FlatPlaceholderItem {
8
8
  id: string;
9
9
  level: number;
10
10
  placeholder: true;
11
11
  }
12
12
  /**
13
- * An item containing `PresentationHierarchyNode` node with properties needed for a flat tree structure.
13
+ * An item containing `TreeNode` node with properties needed for a flat tree structure.
14
14
  *
15
15
  * @alpha
16
16
  */
@@ -19,17 +19,7 @@ export interface FlatTreeNodeItem {
19
19
  level: number;
20
20
  levelSize: number;
21
21
  posInLevel: number;
22
- node: PresentationHierarchyNode;
23
- }
24
- /**
25
- * An item used to build an error message.
26
- * Returned by `useErrorList`.
27
- *
28
- * @alpha
29
- * */
30
- export interface ErrorItem {
31
- errorNode: PresentationHierarchyNode & Pick<Required<PresentationHierarchyNode>, "error">;
32
- expandTo: (expandNode: (nodeId: string) => void) => void;
22
+ node: TreeNode;
33
23
  }
34
24
  /**
35
25
  * An Item describing single tree item position and its content inside tree.
@@ -41,20 +31,18 @@ export type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;
41
31
  /** @alpha */
42
32
  export declare function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem;
43
33
  /**
44
- * Used to get a list of `FlatTreeItem` objects for the given list of `PresentationHierarchyNode` objects that represent
34
+ * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
45
35
  * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
46
36
  * virtualized list.
47
37
  *
48
38
  * @alpha
49
39
  */
50
- export declare function useFlatTreeItems(rootNodes: PresentationHierarchyNode[]): FlatTreeItem[];
40
+ export declare function useFlatTreeItems(rootNodes: TreeNode[]): FlatTreeItem[];
51
41
  /**
52
- * Finds and returns all items containing errors in a given hierarchy in the form of `ErrorItem[]`.
42
+ * Finds and returns all nodes containing errors in a given hierarchy.
53
43
  *
54
44
  * @alpha
55
45
  */
56
- export declare function useErrorList(rootNodes: PresentationHierarchyNode[]): ErrorItem[];
57
- /** @internal */
58
- export declare function findPathToNode(rootNodes: PresentationHierarchyNode[], predicate: (node: PresentationHierarchyNode) => boolean): PresentationHierarchyNode[] | undefined;
46
+ export declare function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, "error">>;
59
47
  export {};
60
48
  //# sourceMappingURL=FlatTreeNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlatTreeNode.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;;;KAIK;AACL,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,yBAAyB,CAAC;CACjC;AAED;;;;;KAKK;AACL,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,yBAAyB,GAAG,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC,CAAC;IAC1F,QAAQ,EAAE,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAElE,aAAa;AACb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,mBAAmB,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,yBAAyB,EAAE,kBAEtE;AAoBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,yBAAyB,EAAE,GAAG,SAAS,EAAE,CAchF;AAED,gBAAgB;AAChB,wBAAgB,cAAc,CAC5B,SAAS,EAAE,yBAAyB,EAAE,EACtC,SAAS,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,OAAO,GACtD,yBAAyB,EAAE,GAAG,SAAS,CAazC"}
1
+ {"version":3,"file":"FlatTreeNode.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;GAIG;AACH,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAElE,aAAa;AACb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,mBAAmB,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,kBAErD;AAoBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CAcxG"}
@@ -8,7 +8,7 @@ export function isPlaceholderItem(item) {
8
8
  return "placeholder" in item;
9
9
  }
10
10
  /**
11
- * Used to get a list of `FlatTreeItem` objects for the given list of `PresentationHierarchyNode` objects that represent
11
+ * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
12
12
  * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
13
13
  * virtualized list.
14
14
  *
@@ -34,58 +34,39 @@ function getFlatItems(nodes, level) {
34
34
  return flatItems;
35
35
  }
36
36
  /**
37
- * Finds and returns all items containing errors in a given hierarchy in the form of `ErrorItem[]`.
37
+ * Finds and returns all nodes containing errors in a given hierarchy.
38
38
  *
39
39
  * @alpha
40
40
  */
41
- export function useErrorList(rootNodes) {
41
+ export function useErrorNodes(rootNodes) {
42
42
  return useMemo(() => rootNodes.flatMap((rootNode) => {
43
43
  if (isErrorNode(rootNode)) {
44
- return [{ errorNode: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];
44
+ return [rootNode];
45
45
  }
46
46
  if (rootNode.children === true) {
47
47
  return [];
48
48
  }
49
- return getErrorItems(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);
49
+ return getErrorNodes(rootNode);
50
50
  }), [rootNodes]);
51
51
  }
52
- /** @internal */
53
- export function findPathToNode(rootNodes, predicate) {
54
- for (const parent of rootNodes) {
55
- if (predicate(parent)) {
56
- return [parent];
57
- }
58
- if (parent.children && parent.children !== true) {
59
- const childPath = findPathToNode(parent.children, predicate);
60
- if (childPath) {
61
- return [parent, ...childPath];
62
- }
63
- }
64
- }
65
- return undefined;
66
- }
67
- function getErrorItems(parent, path) {
52
+ function getErrorNodes(parent) {
68
53
  const errorList = [];
69
54
  if (parent.children === true) {
70
55
  return [];
71
56
  }
72
- const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];
73
57
  parent.children.forEach((node) => {
74
58
  if (isErrorNode(node)) {
75
- errorList.push({ errorNode: node, expandTo: (expandNode) => expandTo(expandNode, path) });
59
+ errorList.push(node);
76
60
  return;
77
61
  }
78
62
  if (node.children !== true) {
79
- const childErrorList = getErrorItems(node, pathToChild);
63
+ const childErrorList = getErrorNodes(node);
80
64
  errorList.push(...childErrorList);
81
65
  return;
82
66
  }
83
67
  });
84
68
  return errorList;
85
69
  }
86
- function expandTo(expandNode, path) {
87
- path.forEach((nodeId) => expandNode(nodeId));
88
- }
89
70
  function isErrorNode(node) {
90
71
  return node.error !== undefined;
91
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAG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AAC;IAElC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1E,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1F,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACxD,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,UAAoC,EAAE,IAAc;IACpE,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,WAAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;AAClC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n * */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `PresentationHierarchyNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: PresentationHierarchyNode;\n}\n\n/**\n * An item used to build an error message.\n * Returned by `useErrorList`.\n *\n * @alpha\n * */\nexport interface ErrorItem {\n errorNode: PresentationHierarchyNode & Pick<Required<PresentationHierarchyNode>, \"error\">;\n expandTo: (expandNode: (nodeId: string) => void) => void;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `PresentationHierarchyNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: PresentationHierarchyNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: PresentationHierarchyNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded || node.error) {\n return;\n }\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all items containing errors in a given hierarchy in the form of `ErrorItem[]`.\n *\n * @alpha\n */\nexport function useErrorList(rootNodes: PresentationHierarchyNode[]): ErrorItem[] {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [{ errorNode: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorItems(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);\n }),\n [rootNodes],\n );\n}\n\n/** @internal */\nexport function findPathToNode(\n rootNodes: PresentationHierarchyNode[],\n predicate: (node: PresentationHierarchyNode) => boolean,\n): PresentationHierarchyNode[] | undefined {\n for (const parent of rootNodes) {\n if (predicate(parent)) {\n return [parent];\n }\n if (parent.children && parent.children !== true) {\n const childPath = findPathToNode(parent.children, predicate);\n if (childPath) {\n return [parent, ...childPath];\n }\n }\n }\n return undefined;\n}\n\nfunction getErrorItems(parent: PresentationHierarchyNode, path: string[]) {\n const errorList: ErrorItem[] = [];\n\n if (parent.children === true) {\n return [];\n }\n\n const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push({ errorNode: node, expandTo: (expandNode) => expandTo(expandNode, path) });\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorItems(node, pathToChild);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction expandTo(expandNode: (nodeId: string) => void, path: string[]) {\n path.forEach((nodeId) => expandNode(nodeId));\n}\n\nfunction isErrorNode(node: PresentationHierarchyNode): node is PresentationHierarchyNode & Pick<Required<PresentationHierarchyNode>, \"error\"> {\n return node.error !== undefined;\n}\n"]}
1
+ {"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAmChC,aA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,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7B,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpB,CAAC;QACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CAAC,EACJ,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAgB;IACrC,MAAM,SAAS,GAAqC,EAAE,CAAC;IAEvD,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YAC3C,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,IAAc;IACjC,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;AAClC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { TreeNode } from \"../TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `TreeNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: TreeNode;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: TreeNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: TreeNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded || node.error) {\n return;\n }\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all nodes containing errors in a given hierarchy.\n *\n * @alpha\n */\nexport function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, \"error\">> {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [rootNode];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorNodes(rootNode);\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorNodes(parent: TreeNode) {\n const errorList: ReturnType<typeof useErrorNodes> = [];\n\n if (parent.children === true) {\n return [];\n }\n\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push(node);\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction isErrorNode(node: TreeNode): node is TreeNode & Pick<Required<TreeNode>, \"error\"> {\n return node.error !== undefined;\n}\n"]}
@@ -1,23 +1,6 @@
1
1
  import { ReactElement } from "react";
2
- import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
3
2
  import { ErrorItemRendererProps } from "./ErrorItemRenderer.js";
4
- import { ErrorItem } from "./FlatTreeNode.js";
5
- /**
6
- * Interface containing error item related actions.
7
- *
8
- * @alpha
9
- */
10
- interface TreeErrorItemProps {
11
- /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */
12
- reloadTree: (options: {
13
- parentNodeId: string | undefined;
14
- state: "reset";
15
- }) => void;
16
- /** Action to perform when the filter button is clicked for this node. */
17
- onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
18
- /** Action to perform when an error occurs and node label is clicked in the error message */
19
- scrollToElement: (errorNode: ErrorItem) => void;
20
- }
3
+ import { useErrorNodes } from "./FlatTreeNode.js";
21
4
  /**
22
5
  * Interface containing building blocks for `TreeErrorRenderer`.
23
6
  *
@@ -29,19 +12,19 @@ interface TreeErrorRendererOwnProps {
29
12
  * as it's used for creating a unique accessible label for the error region.
30
13
  */
31
14
  treeLabel: string;
32
- /** List of errors to be displayed */
33
- errorList: ErrorItem[];
15
+ /** List of error nodes to render errors for. */
16
+ errorNodes: ReturnType<typeof useErrorNodes>;
34
17
  /** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */
35
18
  renderError?: (props: ErrorItemRendererProps) => ReactElement;
36
19
  }
37
20
  /** @alpha */
38
- export type TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Pick<TreeRendererProps, "getHierarchyLevelDetails">;
21
+ export type TreeErrorRendererProps = TreeErrorRendererOwnProps & Omit<ErrorItemRendererProps, "errorNode">;
39
22
  /**
40
23
  * A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.
41
24
  * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.
42
25
  *
43
26
  * @alpha
44
27
  */
45
- export declare function TreeErrorRenderer({ treeLabel, errorList, reloadTree, scrollToElement, getHierarchyLevelDetails, onFilterClick, renderError, }: TreeErrorRendererProps): import("react/jsx-runtime").JSX.Element;
28
+ export declare function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }: TreeErrorRendererProps): import("react/jsx-runtime").JSX.Element;
46
29
  export {};
47
30
  //# sourceMappingURL=TreeErrorRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAgB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAqB,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;GAIG;AACH,UAAU,kBAAkB;IAC1B,iGAAiG;IACjG,UAAU,EAAE,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACpF,yEAAyE;IACzE,aAAa,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACvE,4FAA4F;IAC5F,eAAe,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CACjD;AACD;;;;GAIG;AACH,UAAU,yBAAyB;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,uIAAuI;IACvI,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,YAAY,CAAC;CAC/D;AAED,aAAa;AACb,MAAM,MAAM,sBAAsB,GAAG,yBAAyB,GAAG,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;AAE1I;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,SAAS,EACT,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,WAAW,GACZ,EAAE,sBAAsB,2CA4BxB"}
1
+ {"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAgB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;;GAIG;AACH,UAAU,yBAAyB;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,UAAU,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;IAC7C,uIAAuI;IACvI,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,YAAY,CAAC;CAC/D;AAED,aAAa;AACb,MAAM,MAAM,sBAAsB,GAAG,yBAAyB,GAAG,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,sBAAsB,EAAE,EAAE,sBAAsB,2CAyB1H"}
@@ -13,21 +13,18 @@ import { useLocalizationContext } from "./LocalizationContext.js";
13
13
  *
14
14
  * @alpha
15
15
  */
16
- export function TreeErrorRenderer({ treeLabel, errorList, reloadTree, scrollToElement, getHierarchyLevelDetails, onFilterClick, renderError, }) {
16
+ export function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }) {
17
17
  const { localizedStrings } = useLocalizationContext();
18
- const errorItems = errorList.map((errorItem) => {
18
+ const errorItems = errorNodes.map((errorNode) => {
19
19
  const errorRendererProps = {
20
- errorItem,
21
- scrollToElement: () => scrollToElement(errorItem),
22
- reloadTree,
23
- getHierarchyLevelDetails,
24
- onFilterClick,
20
+ errorNode,
21
+ ...errorItemRendererProps,
25
22
  };
26
23
  if (renderError) {
27
- return cloneElement(renderError(errorRendererProps), { key: errorItem.errorNode.id });
24
+ return cloneElement(renderError(errorRendererProps), { key: errorNode.id });
28
25
  }
29
- return _jsx(ErrorItemRenderer, { ...errorRendererProps }, errorItem.errorNode.id);
26
+ return _jsx(ErrorItemRenderer, { ...errorRendererProps }, errorNode.id);
30
27
  });
31
- return (_jsx(ErrorRegion.Root, { style: { width: "100%" }, "aria-label": localizedStrings.issuesForTree.replace("{{tree_label}}", treeLabel), label: errorList.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace("{{number_of_issues}}", errorList.length.toString()), items: errorItems }));
28
+ return (_jsx(ErrorRegion.Root, { style: { width: "100%" }, "aria-label": localizedStrings.issuesForTree.replace("{{tree_label}}", treeLabel), label: errorNodes.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace("{{number_of_issues}}", errorNodes.length.toString()), items: errorItems }));
32
29
  }
33
30
  //# sourceMappingURL=TreeErrorRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":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O,CAAC,sBAAsB,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAErJ,KAAK,EAAE,UAAU,GACjB,CACH,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 { cloneElement, ReactElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { ErrorItemRenderer, ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\nimport { ErrorItem } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/**\n * Interface containing error item related actions.\n *\n * @alpha\n */\ninterface TreeErrorItemProps {\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 /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Action to perform when an error occurs and node label is clicked in the error message */\n scrollToElement: (errorNode: ErrorItem) => void;\n}\n/**\n * Interface containing building blocks for `TreeErrorRenderer`.\n *\n * @alpha\n */\ninterface TreeErrorRendererOwnProps {\n /**\n * A user friendly display label of the tree. Should be unique within the consuming application,\n * as it's used for creating a unique accessible label for the error region.\n */\n treeLabel: string;\n /** List of errors to be displayed */\n errorList: ErrorItem[];\n /** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */\n renderError?: (props: ErrorItemRendererProps) => ReactElement;\n}\n\n/** @alpha */\nexport type TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.\n * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.\n *\n * @alpha\n */\nexport function TreeErrorRenderer({\n treeLabel,\n errorList,\n reloadTree,\n scrollToElement,\n getHierarchyLevelDetails,\n onFilterClick,\n renderError,\n}: TreeErrorRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n const errorItems = errorList.map((errorItem) => {\n const errorRendererProps: ErrorItemRendererProps = {\n errorItem,\n scrollToElement: () => scrollToElement(errorItem),\n reloadTree,\n getHierarchyLevelDetails,\n onFilterClick,\n };\n\n if (renderError) {\n return cloneElement(renderError(errorRendererProps), { key: errorItem.errorNode.id });\n }\n\n return <ErrorItemRenderer key={errorItem.errorNode.id} {...errorRendererProps} />;\n });\n\n return (\n <ErrorRegion.Root\n style={{ width: \"100%\" }}\n aria-label={localizedStrings.issuesForTree.replace(\"{{tree_label}}\", treeLabel)}\n label={\n errorList.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace(\"{{number_of_issues}}\", errorList.length.toString())\n }\n items={errorItems}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,YAAY,EAAgB,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,oBAAoB,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAsBlE;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,sBAAsB,EAA0B;IACzH,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC9C,MAAM,kBAAkB,GAA2B;YACjD,SAAS;YACT,GAAG,sBAAsB;SAC1B,CAAC;QAEF,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,YAAY,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,KAAC,iBAAiB,OAAwB,kBAAkB,IAApC,SAAS,CAAC,EAAE,CAA4B,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,WAAW,CAAC,IAAI,IACf,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,gBACZ,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAC/E,KAAK,EACH,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,sBAAsB,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAEvJ,KAAK,EAAE,UAAU,GACjB,CACH,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 { cloneElement, ReactElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { ErrorItemRenderer, ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\nimport { useErrorNodes } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/**\n * Interface containing building blocks for `TreeErrorRenderer`.\n *\n * @alpha\n */\ninterface TreeErrorRendererOwnProps {\n /**\n * A user friendly display label of the tree. Should be unique within the consuming application,\n * as it's used for creating a unique accessible label for the error region.\n */\n treeLabel: string;\n /** List of error nodes to render errors for. */\n errorNodes: ReturnType<typeof useErrorNodes>;\n /** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */\n renderError?: (props: ErrorItemRendererProps) => ReactElement;\n}\n\n/** @alpha */\nexport type TreeErrorRendererProps = TreeErrorRendererOwnProps & Omit<ErrorItemRendererProps, \"errorNode\">;\n\n/**\n * A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.\n * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.\n *\n * @alpha\n */\nexport function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }: TreeErrorRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n const errorItems = errorNodes.map((errorNode) => {\n const errorRendererProps: ErrorItemRendererProps = {\n errorNode,\n ...errorItemRendererProps,\n };\n\n if (renderError) {\n return cloneElement(renderError(errorRendererProps), { key: errorNode.id });\n }\n\n return <ErrorItemRenderer key={errorNode.id} {...errorRendererProps} />;\n });\n\n return (\n <ErrorRegion.Root\n style={{ width: \"100%\" }}\n aria-label={localizedStrings.issuesForTree.replace(\"{{tree_label}}\", treeLabel)}\n label={\n errorNodes.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace(\"{{number_of_issues}}\", errorNodes.length.toString())\n }\n items={errorItems}\n />\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
2
- import { PresentationHierarchyNode } from "../TreeNode.js";
2
+ import { TreeNode } from "../TreeNode.js";
3
3
  import { TreeActionBaseAttributes } from "./TreeAction.js";
4
4
  /**
5
5
  * React component that renders a filter action for a tree item.
@@ -15,6 +15,6 @@ export declare const TreeNodeFilterAction: import("react").NamedExoticComponent<
15
15
  /** Action to perform when the filter button is clicked for this node. */
16
16
  onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
17
17
  } & TreeActionBaseAttributes & Pick<TreeRendererProps, "getHierarchyLevelDetails"> & {
18
- node: PresentationHierarchyNode;
18
+ node: TreeNode;
19
19
  }>;
20
20
  //# 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,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAS3E;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;IAf/B,yEAAyE;eAC9D,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI;;UAmB5B,yBAAyB;EAoB9D,CAAC"}
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 +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,EAC6C;IAChE,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 { PresentationHierarchyNode } 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: PresentationHierarchyNode }) {\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","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,5 +1,5 @@
1
1
  import { PropsWithChildren } from "react";
2
- import { PresentationHierarchyNode } from "../TreeNode.js";
2
+ import { TreeNode } from "../TreeNode.js";
3
3
  import { TreeActionBaseAttributes } from "./TreeAction.js";
4
4
  /**
5
5
  * React component that renders a rename action for a tree item.
@@ -13,7 +13,7 @@ import { TreeActionBaseAttributes } from "./TreeAction.js";
13
13
  * @alpha
14
14
  */
15
15
  export declare const TreeNodeRenameAction: import("react").NamedExoticComponent<TreeActionBaseAttributes & {
16
- node: PresentationHierarchyNode;
16
+ node: TreeNode;
17
17
  }>;
18
18
  /** @alpha */
19
19
  export interface TreeNodeEditingProps {
@@ -34,8 +34,8 @@ export interface RenameParameters {
34
34
  }
35
35
  interface TreeNodeRenameContext {
36
36
  renameParameters?: RenameParameters;
37
- startRename: (node: PresentationHierarchyNode) => void;
38
- canRename: (node: PresentationHierarchyNode) => boolean;
37
+ startRename: (node: TreeNode) => void;
38
+ canRename: (node: TreeNode) => boolean;
39
39
  cancelRename: () => void;
40
40
  }
41
41
  /** @internal */
@@ -45,13 +45,13 @@ export declare function TreeNodeRenameContextProvider({ value, children }: Props
45
45
  value: TreeNodeRenameContext;
46
46
  }>): import("react/jsx-runtime").JSX.Element;
47
47
  /** @internal */
48
- export declare function useTreeNodeRenameContextValue({ getEditingProps, }: {
49
- getEditingProps?: (node: PresentationHierarchyNode) => TreeNodeEditingProps | undefined;
48
+ export declare function useTreeNodeRenameContextValue({ getEditingProps }: {
49
+ getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;
50
50
  }): {
51
51
  renameParameters: RenameParameters | undefined;
52
52
  cancelRename: () => void;
53
- startRename: (node: PresentationHierarchyNode) => void;
54
- canRename: (node: PresentationHierarchyNode) => boolean;
53
+ startRename: (node: TreeNode) => void;
54
+ canRename: (node: TreeNode) => boolean;
55
55
  };
56
56
  export {};
57
57
  //# 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,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAkB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AC,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"}
@@ -39,7 +39,7 @@ export function TreeNodeRenameContextProvider({ value, children }) {
39
39
  return _jsx(treeNodeRenameContext.Provider, { value: value, children: children });
40
40
  }
41
41
  /** @internal */
42
- export function useTreeNodeRenameContextValue({ getEditingProps, }) {
42
+ export function useTreeNodeRenameContextValue({ getEditingProps }) {
43
43
  const [renameParameters, setRenameParameters] = useState(undefined);
44
44
  const startRename = useCallback((node) => {
45
45
  const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};
@@ -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,EACrE,IAAI,EACJ,GAAG,gBAAgB,EAC4C;IAC/D,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAC;IAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;IAEpC,MAAM,SAAS,GAAG,OAAO,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,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,IAA+B,EAAE,EAAE;QAClC,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 { PresentationHierarchyNode } 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({\n node,\n ...actionAttributes\n}: TreeActionBaseAttributes & { node: PresentationHierarchyNode }) {\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: PresentationHierarchyNode) => void;\n canRename: (node: PresentationHierarchyNode) => 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({\n getEditingProps,\n}: {\n getEditingProps?: (node: PresentationHierarchyNode) => TreeNodeEditingProps | undefined;\n}) {\n const [renameParameters, setRenameParameters] = useState<RenameParameters | undefined>(undefined);\n\n const startRename = useCallback(\n (node: PresentationHierarchyNode) => {\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: PresentationHierarchyNode) => {\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","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,EAAE,CAAC;IACtD,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAC;IAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;IAEpC,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;IACpD,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,CAAC;IACzC,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,WAAW,EA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ACL,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"]}
@@ -2,11 +2,11 @@ import "./TreeNodeRenderer.css";
2
2
  import { ComponentPropsWithoutRef, FC, PropsWithRef, ReactNode, RefAttributes } from "react";
3
3
  import { Tree } from "@stratakit/structures";
4
4
  import { TreeRendererProps } from "../Renderers.js";
5
- import { PresentationHierarchyNode } from "../TreeNode.js";
5
+ import { TreeNode } from "../TreeNode.js";
6
6
  /** @internal */
7
7
  interface TreeNodeRendererOwnProps extends Pick<TreeRendererProps, "expandNode" | "reloadTree"> {
8
8
  /** Node that is rendered. */
9
- node: PresentationHierarchyNode;
9
+ node: TreeNode;
10
10
  /**
11
11
  * Menu actions for tree item.
12
12
  * Must be an array of `<TreeActionBase />` or `<Divider />` elements.
@@ -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,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAK3D,gBAAgB;AAChB,UAAU,wBAAyB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,CAAC;IAC7F,6BAA6B;IAC7B,IAAI,EAAE,yBAAyB,CAAC;IAChC;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,EAAE,CA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