@itwin/tree-widget-react 4.0.0-alpha.13 → 4.0.0-alpha.14
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.
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.css +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js +13 -8
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +4 -3
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +10 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +268 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +46 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +16 -3
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +74 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js +69 -6
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.d.ts +37 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js +193 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.d.ts +18 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js +51 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +8 -1
- package/package.json +1 -1
package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { FilterLimitExceededError } from "../../common/TreeErrors.js";
|
|
7
|
+
import { useTelemetryContext } from "../../common/UseTelemetryContext.js";
|
|
8
|
+
import { ClassificationsTreeDefinition } from "../ClassificationsTreeDefinition.js";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export function useFilteredPaths({ filter, hierarchyConfiguration, getClassificationsTreeIdsCache, onFilteredPathsChanged, }) {
|
|
11
|
+
const [filteringError, setFilteringError] = useState();
|
|
12
|
+
const { onFeatureUsed } = useTelemetryContext();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setFilteringError(undefined);
|
|
15
|
+
if (!filter) {
|
|
16
|
+
onFilteredPathsChanged(undefined);
|
|
17
|
+
}
|
|
18
|
+
}, [filter, onFilteredPathsChanged]);
|
|
19
|
+
const getFilteredPaths = useMemo(() => {
|
|
20
|
+
if (!filter) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return async ({ imodelAccess }) => {
|
|
24
|
+
onFeatureUsed({ featureId: "filtering", reportInteraction: true });
|
|
25
|
+
try {
|
|
26
|
+
const paths = await ClassificationsTreeDefinition.createInstanceKeyPaths({
|
|
27
|
+
imodelAccess,
|
|
28
|
+
label: filter,
|
|
29
|
+
idsCache: getClassificationsTreeIdsCache(),
|
|
30
|
+
hierarchyConfig: hierarchyConfiguration,
|
|
31
|
+
});
|
|
32
|
+
onFilteredPathsChanged(paths);
|
|
33
|
+
return paths;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
const newError = e instanceof FilterLimitExceededError ? "tooManyFilterMatches" : "unknownFilterError";
|
|
37
|
+
if (newError !== "tooManyFilterMatches") {
|
|
38
|
+
const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
|
|
39
|
+
onFeatureUsed({ featureId: feature, reportInteraction: false });
|
|
40
|
+
}
|
|
41
|
+
setFilteringError(newError);
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}, [filter, onFilteredPathsChanged, onFeatureUsed, getClassificationsTreeIdsCache, hierarchyConfiguration]);
|
|
46
|
+
return {
|
|
47
|
+
getPaths: getFilteredPaths,
|
|
48
|
+
filteringError,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=UseFilteredPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseFilteredPaths.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAWpF,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,GAMvB;IAIC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAAiD,CAAC;IACtG,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAChD,SAAS,CAAC,GAAG,EAAE;QACb,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,sBAAsB,CAAC,SAAS,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,sBAAsB,CAAC,CAAC,CAAC;IAE5G,OAAO;QACL,QAAQ,EAAE,gBAAgB;QAC1B,cAAc;KACf,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 { useEffect, useMemo, useState } from \"react\";\nimport { FilterLimitExceededError } from \"../../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../../common/UseTelemetryContext.js\";\nimport { ClassificationsTreeDefinition } from \"../ClassificationsTreeDefinition.js\";\n\nimport type { ClassificationsTreeHierarchyConfiguration } from \"../ClassificationsTreeDefinition.js\";\nimport type { ClassificationsTreeIdsCache } from \"./ClassificationsTreeIdsCache.js\";\n\nimport type { VisibilityTreeProps } from \"../../common/components/VisibilityTree.js\";\n/** @internal */\nexport type ClassificationsTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\n\ntype HierarchyFilteringPaths = Awaited<ReturnType<Required<VisibilityTreeProps>[\"getFilteredPaths\"]>>;\n\n/** @internal */\nexport function useFilteredPaths({\n filter,\n hierarchyConfiguration,\n getClassificationsTreeIdsCache,\n onFilteredPathsChanged,\n}: {\n filter?: string;\n hierarchyConfiguration: ClassificationsTreeHierarchyConfiguration;\n getClassificationsTreeIdsCache: () => ClassificationsTreeIdsCache;\n onFilteredPathsChanged: (paths: HierarchyFilteringPaths | undefined) => void;\n}): {\n getPaths: VisibilityTreeProps[\"getFilteredPaths\"] | undefined;\n filteringError: ClassificationsTreeFilteringError | undefined;\n} {\n const [filteringError, setFilteringError] = useState<ClassificationsTreeFilteringError | undefined>();\n const { onFeatureUsed } = useTelemetryContext();\n useEffect(() => {\n setFilteringError(undefined);\n if (!filter) {\n onFilteredPathsChanged(undefined);\n }\n }, [filter, onFilteredPathsChanged]);\n\n const getFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n if (!filter) {\n return undefined;\n }\n\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n const paths = await ClassificationsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getClassificationsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n });\n onFilteredPathsChanged(paths);\n return paths;\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, onFilteredPathsChanged, onFeatureUsed, getClassificationsTreeIdsCache, hierarchyConfiguration]);\n\n return {\n getPaths: getFilteredPaths,\n filteringError,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/EmptyTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAM3E,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,EAAE,IAAI,EAAwB;IACjE,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,iCAAiC,CAAC,GAAQ,EACjG,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,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AAED,gBAAgB;AAChB,MAAM,UAAU,yBAAyB,CAAC,EAAE,IAAI,EAAwB;IACtE,MAAM,EAAE,MAAM,EAAE,GAAG,0BAA0B,EAAE,CAAC;IAChD,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,sCAAsC,CAAC,GAAQ,EACtG,KAAC,MAAM,IACL,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EACtC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,MAAM,EAAE,CAAC;gBACX,CAAC,YAEA,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,qCAAqC,CAAC,GAC5D,IACL,CACP,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"EmptyTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/EmptyTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAM3E,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,EAAE,IAAI,EAAwB;IACjE,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,iCAAiC,CAAC,GAAQ,EACjG,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,sCAAsC,CAAC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I,EAAwB;IACtE,MAAM,EAAE,MAAM,EAAE,GAAG,0BAA0B,EAAE,CAAC;IAChD,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,sCAAsC,CAAC,GAAQ,EACtG,KAAC,MAAM,IACL,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EACtC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,MAAM,EAAE,CAAC;gBACX,CAAC,YAEA,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,qCAAqC,CAAC,GAC5D,IACL,CACP,CAAC;AACJ,CAAC;AAMD,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAyB;IAC9D,OAAO,CACL,eAAK,SAAS,EAAE,yBAAyB,aACtC,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,EAChD,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,YACrD,UAAU,CAAC,SAAS,CAAC,6BAA6B,CAAC,GAC/C,IACH,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 \"./EmptyTree.css\";\nimport { Anchor, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../FocusedInstancesContext.js\";\n\ninterface FilterEmptyTreeProps {\n base: string;\n}\n\n/** @internal */\nexport function TooManyFilterMatches({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyFilterMatches`)}</Text>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyFilterMatchesRetry`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function NoFilterMatches({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.noMatches`)}</Text>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.noMatchesRetry`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function FilterUnknownError({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.unknownFilterError`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function TooManyInstancesFocused({ base }: FilterEmptyTreeProps) {\n const { toggle } = useFocusedInstancesContext();\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyInstancesFocused`)}</Text>\n <Anchor\n style={{ textDecoration: \"underline\" }}\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n >\n {TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`)}\n </Anchor>\n </div>\n );\n}\n\n/** @internal */\nexport function UnknownInstanceFocusError({ base }: FilterEmptyTreeProps) {\n const { toggle } = useFocusedInstancesContext();\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.unknownInstanceFocusError`)}</Text>\n <Anchor\n style={{ textDecoration: \"underline\" }}\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n >\n {TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`)}\n </Anchor>\n </div>\n );\n}\n\ninterface EmptyTreeContentProps {\n icon?: string;\n}\n\n/** @internal */\nexport function EmptyTreeContent({ icon }: EmptyTreeContentProps) {\n return (\n <div className={\"tw-empty-tree-container\"}>\n {icon ? <Icon size=\"large\" href={icon} /> : null}\n <Text variant={\"body-sm\"} style={{ textAlign: \"center\" }}>\n {TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}\n </Text>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseIModelAccess.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/UseIModelAccess.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAehD,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAwB;IAIrI,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IACvE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,UAAU,CAAC,MAAM,CAAC,OAAO,CACvB,GAAG,iBAAiB,IAAI,QAAQ,EAAE,EAClC,6BAA6B,oBAAoB,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,EAAE,CACpG,CAAC;QACF,OAAO,oBAAoB,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,CAAC,CAAC;IACzH,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,8BAA8B,CAAC,CAAC,CAAC;IAE7E,OAAO;QACL,YAAY;QACZ,8BAA8B,EAAE,8BAA8B;KAC/D,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAiE;IAC5H,MAAM,cAAc,GAAG,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACpE,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,GAAG;QACrB,GAAG,cAAc;QACjB,GAAG,sCAAsC,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QAC7E,GAAG,gCAAgC,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;KAC/F,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 { useMemo } from \"react\";\nimport { createECSchemaProvider, createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { createLimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { LOGGING_NAMESPACE } from \"../Utils.js\";\n\nimport type { FunctionProps} from \"../Utils.js\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { useIModelTree } from \"@itwin/presentation-hierarchies-react\";\n\ntype IModelAccess = FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n\nexport interface UseIModelAccessProps {\n imodel: IModelConnection;\n treeName: string;\n imodelAccess?: IModelAccess;\n hierarchyLevelSizeLimit?: number;\n}\n\n/** @internal */\nexport function useIModelAccess({ imodel, treeName, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }: UseIModelAccessProps): {\n imodelAccess: IModelAccess;\n currentHierarchyLevelSizeLimit: number;\n} {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n const imodelAccess = useMemo(() => {\n TreeWidget.logger.logInfo(\n `${LOGGING_NAMESPACE}.${treeName}`,\n `iModel changed, now using ${providedIModelAccess ? \"provided imodel access\" : `\"${imodel.name}\"`}`,\n );\n return providedIModelAccess ?? createIModelAccess({ imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });\n }, [providedIModelAccess, imodel, treeName, defaultHierarchyLevelSizeLimit]);\n\n return {\n imodelAccess,\n currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,\n };\n}\n\nfunction createIModelAccess({ imodel, hierarchyLevelSizeLimit }: { imodel: IModelConnection; hierarchyLevelSizeLimit: number }) {\n const schemaProvider = createECSchemaProvider(imodel.schemaContext);\n return {\n imodelKey: imodel.key,\n ...schemaProvider,\n ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),\n ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseIModelAccess.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/UseIModelAccess.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAehD,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAwB;IAIrI,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IACvE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,UAAU,CAAC,MAAM,CAAC,OAAO,CACvB,GAAG,iBAAiB,IAAI,QAAQ,EAAE,EAClC,6BAA6B,oBAAoB,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,EAAE,CACpG,CAAC;QACF,OAAO,oBAAoB,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,CAAC,CAAC;IACzH,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,8BAA8B,CAAC,CAAC,CAAC;IAE7E,OAAO;QACL,YAAY;QACZ,8BAA8B,EAAE,8BAA8B;KAC/D,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAiE;IAC5H,MAAM,cAAc,GAAG,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACpE,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,GAAG;QACrB,GAAG,cAAc;QACjB,GAAG,sCAAsC,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QAC7E,GAAG,gCAAgC,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;KAC/F,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 { useMemo } from \"react\";\nimport { createECSchemaProvider, createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { createLimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { LOGGING_NAMESPACE } from \"../Utils.js\";\n\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { useIModelTree } from \"@itwin/presentation-hierarchies-react\";\n\ntype IModelAccess = FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n\nexport interface UseIModelAccessProps {\n imodel: IModelConnection;\n treeName: string;\n imodelAccess?: IModelAccess;\n hierarchyLevelSizeLimit?: number;\n}\n\n/** @internal */\nexport function useIModelAccess({ imodel, treeName, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }: UseIModelAccessProps): {\n imodelAccess: IModelAccess;\n currentHierarchyLevelSizeLimit: number;\n} {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n const imodelAccess = useMemo(() => {\n TreeWidget.logger.logInfo(\n `${LOGGING_NAMESPACE}.${treeName}`,\n `iModel changed, now using ${providedIModelAccess ? \"provided imodel access\" : `\"${imodel.name}\"`}`,\n );\n return providedIModelAccess ?? createIModelAccess({ imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });\n }, [providedIModelAccess, imodel, treeName, defaultHierarchyLevelSizeLimit]);\n\n return {\n imodelAccess,\n currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,\n };\n}\n\nfunction createIModelAccess({ imodel, hierarchyLevelSizeLimit }: { imodel: IModelConnection; hierarchyLevelSizeLimit: number }) {\n const schemaProvider = createECSchemaProvider(imodel.schemaContext);\n return {\n imodelKey: imodel.key,\n ...schemaProvider,\n ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),\n ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),\n };\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAC/D,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AACtD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,gBAAgB,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAC/D,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AACtD,OAAO,UAAU,M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C,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAC3B,KAAC,YAAY,OAAK,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAC,qBAAqB,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC,GAAI,CAC7I,GACD,CACH,CAAC;AACJ,CAAC;AAED,YAAY;AACZ,MAAM,UAAU,qBAAqB,CAAC,EAAE,IAAI,EAAuC;IACjF,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;QACtD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,QAAQ,IAAI,CAAC,QAAQ,CAAC,YAAa,CAAC,OAAO,EAAE,CAAC;YAC5C,KAAK,aAAa;gBAChB,OAAO,WAAW,CAAC;YACrB,KAAK,WAAW;gBACd,OAAO,UAAU,CAAC;YACpB,KAAK,eAAe;gBAClB,OAAO,QAAQ,CAAC;YAClB,KAAK,aAAa;gBAChB,OAAO,UAAU,CAAC;YACpB,KAAK,YAAY;gBACf,OAAO,QAAQ,CAAC;YAClB,KAAK,qBAAqB;gBACxB,OAAO,gBAAgB,CAAC;YAC1B,KAAK,YAAY;gBACf,OAAO,QAAQ,CAAC;YAClB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,EAAE,GAAI,CAAC;AACnC,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 { useCallback } from \"react\";\nimport { Icon } from \"@stratakit/foundations\";\nimport categorySvg from \"@stratakit/icons/bis-category-3d.svg\";\nimport classSvg from \"@stratakit/icons/bis-class.svg\";\nimport elementSvg from \"@stratakit/icons/bis-element.svg\";\nimport subjectSvg from \"@stratakit/icons/bis-subject.svg\";\nimport groupSvg from \"@stratakit/icons/group.svg\";\nimport modelSvg from \"@stratakit/icons/model-cube.svg\";\nimport hierarchyTreeSvg from \"@stratakit/icons/selection-children.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTree.js\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent.js\";\nimport { defaultHierarchyConfiguration, IModelContentTreeDefinition } from \"./IModelContentTreeDefinition.js\";\nimport { IModelContentTreeIdsCache } from \"./internal/IModelContentTreeIdsCache.js\";\n\nimport type { IModelContentTreeHierarchyConfiguration } from \"./IModelContentTreeDefinition.js\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { BaseTreeRendererProps } from \"../common/components/BaseTreeRenderer.js\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\n\n/** @beta */\nexport type IModelContentTreeProps = Pick<TreeProps, \"imodel\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> &\n Pick<BaseTreeRendererProps, \"getActions\" | \"getDecorations\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;\n };\n\n/** @beta */\nexport function IModelContentTree({ getActions, getDecorations, selectionMode, hierarchyConfig: hierarchyConfigProp, ...rest }: IModelContentTreeProps) {\n const getHierarchyDefinition = useCallback<TreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => {\n const hierarchyConfig = {\n ...defaultHierarchyConfiguration,\n ...hierarchyConfigProp,\n };\n return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess), hierarchyConfig });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfigProp ?? {}),\n );\n\n return (\n <Tree\n emptyTreeContent={<EmptyTreeContent icon={modelSvg} />}\n {...rest}\n treeName={IModelContentTreeComponent.id}\n getHierarchyDefinition={getHierarchyDefinition}\n selectionMode={selectionMode ?? \"extended\"}\n treeRenderer={(treeProps) => (\n <TreeRenderer {...treeProps} getActions={getActions} getDecorations={getDecorations ?? ((node) => <IModelContentTreeIcon node={node} />)} />\n )}\n />\n );\n}\n\n/** @beta */\nexport function IModelContentTreeIcon({ node }: { node: PresentationHierarchyNode }) {\n if (node.nodeData.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n const getIcon = () => {\n switch (node.nodeData.extendedData!.imageId) {\n case \"icon-layers\":\n return categorySvg;\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n case \"icon-folder\":\n return subjectSvg;\n case \"icon-model\":\n return modelSvg;\n case \"icon-hierarchy-tree\":\n return hierarchyTreeSvg;\n case \"icon-group\":\n return groupSvg;\n default:\n return undefined;\n }\n };\n\n return <Icon href={getIcon()} />;\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseFilteredPaths.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAChH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E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E,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAChF,CAAC,CAAC,EAAE,IAAI,EAAE,UAAmB,EAAE,GAAG,EAAE,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE;QAC/F,YAAY;KACb,CAAC,CAAC,CACJ,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,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 type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { HierarchyNodeIdentifier, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { useFocusedInstancesContext } from \"../../common/FocusedInstancesContext.js\";\nimport { CLASS_NAME_GeometricModel3d, CLASS_NAME_Subject } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { FilterLimitExceededError } from \"../../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../../common/UseTelemetryContext.js\";\nimport { ModelsTreeDefinition } from \"../ModelsTreeDefinition.js\";\n\nimport type { GroupingHierarchyNode, HierarchyFilteringPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { VisibilityTreeProps } from \"../../common/components/VisibilityTree.js\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"../ModelsTreeDefinition.js\";\nimport type { ModelsTreeIdsCache } from \"./ModelsTreeIdsCache.js\";\n\n/** @internal */\nexport type ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\n\n/** @internal */\nexport function useFilteredPaths({\n hierarchyConfiguration,\n filter,\n getFilteredPaths,\n getModelsTreeIdsCache,\n onModelsFiltered,\n onFilteredPathsChanged,\n}: {\n hierarchyConfiguration: ModelsTreeHierarchyConfiguration;\n filter?: string;\n getFilteredPaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<HierarchyFilteringPath[]>;\n /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */\n filter?: string;\n }) => Promise<HierarchyFilteringPath[]>;\n getModelsTreeIdsCache: () => ModelsTreeIdsCache;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n onFilteredPathsChanged: (paths: HierarchyFilteringPath[] | undefined) => void;\n}): {\n getPaths: VisibilityTreeProps[\"getFilteredPaths\"] | undefined;\n filteringError: ModelsTreeFilteringError | undefined;\n} {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n\n const { onFeatureUsed } = useTelemetryContext();\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n useEffect(() => {\n setFilteringError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset filtered paths if there is no filters applied. This allows to keep current filtered paths until new paths are loaded.\n if (!loadFocusedItems && !getFilteredPaths && !filter) {\n onFilteredPathsChanged(undefined);\n }\n }, [loadFocusedItems, getFilteredPaths, filter, onModelsFiltered, onFilteredPathsChanged]);\n\n const getPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n const handlePaths = async (filteredPaths: HierarchyFilteringPath[], classInspector: ECClassHierarchyInspector) => {\n onFilteredPathsChanged(filteredPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = await getModels(filteredPaths, getModelsTreeIdsCache(), classInspector);\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n });\n void handlePaths(paths, imodelAccess);\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (getFilteredPaths) {\n return async ({ imodelAccess }) => {\n try {\n const paths = await getFilteredPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n }),\n filter,\n });\n void handlePaths(paths, imodelAccess);\n return paths;\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n });\n void handlePaths(paths, imodelAccess);\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return undefined;\n }, [filter, loadFocusedItems, getModelsTreeIdsCache, onFeatureUsed, getFilteredPaths, hierarchyConfiguration, onModelsFiltered, onFilteredPathsChanged]);\n\n return {\n getPaths,\n filteringError,\n };\n}\n\nasync function getModels(paths: HierarchyFilteringPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModelIds = new Set<Id64String>();\n const targetSubjectIds = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === CLASS_NAME_Subject) {\n targetSubjectIds.add(currStep.id);\n break;\n }\n\n // collect all the models from the filtered path\n if (await classInspector.classDerivesFrom(currStep.className, CLASS_NAME_GeometricModel3d)) {\n targetModelIds.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await idsCache.getSubjectModelIds([...targetSubjectIds]);\n return [...targetModelIds, ...matchingModels];\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64Array;\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseFilteredPaths.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAChH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAWlE,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAC/B,sBAAsB,EACtB,MAAM,EACN,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,GAavB;IAIC,MAAM,CAAC,cAAc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EAAE;QAC/F,YAAY;KACb,CAAC,CAAC,CACJ,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,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 type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { HierarchyNodeIdentifier, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { useFocusedInstancesContext } from \"../../common/FocusedInstancesContext.js\";\nimport { CLASS_NAME_GeometricModel3d, CLASS_NAME_Subject } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { FilterLimitExceededError } from \"../../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../../common/UseTelemetryContext.js\";\nimport { ModelsTreeDefinition } from \"../ModelsTreeDefinition.js\";\n\nimport type { GroupingHierarchyNode, HierarchyFilteringPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { VisibilityTreeProps } from \"../../common/components/VisibilityTree.js\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"../ModelsTreeDefinition.js\";\nimport type { ModelsTreeIdsCache } from \"./ModelsTreeIdsCache.js\";\n\n/** @internal */\nexport type ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\n\n/** @internal */\nexport function useFilteredPaths({\n hierarchyConfiguration,\n filter,\n getFilteredPaths,\n getModelsTreeIdsCache,\n onModelsFiltered,\n onFilteredPathsChanged,\n}: {\n hierarchyConfiguration: ModelsTreeHierarchyConfiguration;\n filter?: string;\n getFilteredPaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<HierarchyFilteringPath[]>;\n /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */\n filter?: string;\n }) => Promise<HierarchyFilteringPath[]>;\n getModelsTreeIdsCache: () => ModelsTreeIdsCache;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n onFilteredPathsChanged: (paths: HierarchyFilteringPath[] | undefined) => void;\n}): {\n getPaths: VisibilityTreeProps[\"getFilteredPaths\"] | undefined;\n filteringError: ModelsTreeFilteringError | undefined;\n} {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n\n const { onFeatureUsed } = useTelemetryContext();\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n useEffect(() => {\n setFilteringError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset filtered paths if there is no filters applied. This allows to keep current filtered paths until new paths are loaded.\n if (!loadFocusedItems && !getFilteredPaths && !filter) {\n onFilteredPathsChanged(undefined);\n }\n }, [loadFocusedItems, getFilteredPaths, filter, onModelsFiltered, onFilteredPathsChanged]);\n\n const getPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n const handlePaths = async (filteredPaths: HierarchyFilteringPath[], classInspector: ECClassHierarchyInspector) => {\n onFilteredPathsChanged(filteredPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = await getModels(filteredPaths, getModelsTreeIdsCache(), classInspector);\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n });\n void handlePaths(paths, imodelAccess);\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (getFilteredPaths) {\n return async ({ imodelAccess }) => {\n try {\n const paths = await getFilteredPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n }),\n filter,\n });\n void handlePaths(paths, imodelAccess);\n return paths;\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n });\n void handlePaths(paths, imodelAccess);\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return undefined;\n }, [filter, loadFocusedItems, getModelsTreeIdsCache, onFeatureUsed, getFilteredPaths, hierarchyConfiguration, onModelsFiltered, onFilteredPathsChanged]);\n\n return {\n getPaths,\n filteringError,\n };\n}\n\nasync function getModels(paths: HierarchyFilteringPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModelIds = new Set<Id64String>();\n const targetSubjectIds = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === CLASS_NAME_Subject) {\n targetSubjectIds.add(currStep.id);\n break;\n }\n\n // collect all the models from the filtered path\n if (await classInspector.classDerivesFrom(currStep.className, CLASS_NAME_GeometricModel3d)) {\n targetModelIds.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await idsCache.getSubjectModelIds([...targetSubjectIds]);\n return [...targetModelIds, ...matchingModels];\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64Array;\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n"]}
|
|
@@ -56,7 +56,14 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"classificationsTree": {
|
|
59
|
-
"label": "Classifications"
|
|
59
|
+
"label": "Classifications",
|
|
60
|
+
"filtering": {
|
|
61
|
+
"noMatches": "No results were found for your search query.",
|
|
62
|
+
"noMatchesRetry": "Please modify your search and try again.",
|
|
63
|
+
"unknownFilterError": "An unknown error occurred while filtering the tree.",
|
|
64
|
+
"tooManyFilterMatches": "There are too many matches for your search query.",
|
|
65
|
+
"tooManyFilterMatchesRetry": "Please refine your search and try again."
|
|
66
|
+
}
|
|
60
67
|
},
|
|
61
68
|
"modelsTree": {
|
|
62
69
|
"label": "Models",
|