@itwin/saved-views-react 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/LayeredDropdownMenu/LayeredDropdownMenu.css +5 -1
- package/lib/LayeredDropdownMenu/LayeredDropdownMenu.d.ts +3 -1
- package/lib/LayeredDropdownMenu/LayeredDropdownMenu.js +2 -2
- package/lib/SavedView.d.ts +2 -0
- package/lib/SavedViewTile/SavedViewOptions.d.ts +2 -0
- package/lib/SavedViewTile/SavedViewOptions.js +4 -4
- package/lib/SavedViewTile/SavedViewTile.css +8 -1
- package/lib/SavedViewTile/SavedViewTile.d.ts +5 -4
- package/lib/SavedViewTile/SavedViewTile.js +12 -14
- package/lib/SavedViewsClient/ITwinSavedViewsClient.js +6 -2
- package/lib/StickyExpandableBlock/StickyExpandableBlock.js +9 -1
- package/lib/api/clients/ISavedViewsClient.d.ts +5 -5
- package/lib/api/utilities/SavedViewTypes.d.ts +1 -1
- package/lib/api/utilities/translation/SavedViewTranslation.d.ts +19 -15
- package/lib/api/utilities/translation/SavedViewTranslation.js +174 -160
- package/lib/api/utilities/translation/displayStyleExtractor.js +55 -5
- package/lib/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.d.ts +2 -19
- package/lib/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.js +82 -133
- package/lib/captureSavedViewData.d.ts +4 -1
- package/lib/captureSavedViewData.js +12 -10
- package/lib/experimental.d.ts +3 -1
- package/lib/experimental.js +2 -1
- package/lib/useSavedViews.d.ts +2 -2
- package/lib/useSavedViews.js +76 -60
- package/package.json +3 -3
- package/lib/api/clients/IModelQueryClient.d.ts +0 -10
- package/lib/api/clients/IModelQueryClient.js +0 -45
- package/lib/api/utilities/translation/ModelsAndCategoriesHelper.d.ts +0 -3
- package/lib/api/utilities/translation/ModelsAndCategoriesHelper.js +0 -57
- package/lib/api/utilities/translation/urlConverter.d.ts +0 -7
- package/lib/api/utilities/translation/urlConverter.js +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/saved-views-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@itwin/itwinui-icons-react": "^2.4.0",
|
|
62
|
-
"@itwin/itwinui-react": "^3.
|
|
62
|
+
"@itwin/itwinui-react": "^3.8.1",
|
|
63
63
|
"fuse.js": "^6.6.2",
|
|
64
|
-
"@itwin/saved-views-client": "0.1
|
|
64
|
+
"@itwin/saved-views-client": "^0.2.1"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "run-p build:*",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Id64Array } from "@itwin/core-bentley";
|
|
2
|
-
import type { IModelConnection } from "@itwin/core-frontend";
|
|
3
|
-
export declare const IModelQueryClient: {
|
|
4
|
-
getAllModels: (iModel: IModelConnection) => Promise<Id64Array>;
|
|
5
|
-
getAllCategories: (iModel: IModelConnection) => Promise<Id64Array>;
|
|
6
|
-
getAllModelsAndCategories: (iModel: IModelConnection) => Promise<{
|
|
7
|
-
models: Id64Array;
|
|
8
|
-
categories: Id64Array;
|
|
9
|
-
}>;
|
|
10
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { QueryRowFormat } from "@itwin/core-common";
|
|
2
|
-
/**
|
|
3
|
-
* Helper function to execute ECSql queries.
|
|
4
|
-
*/
|
|
5
|
-
const executeQuery = async (iModel, query) => {
|
|
6
|
-
const rows = [];
|
|
7
|
-
const sqlReader = iModel.createQueryReader(query, undefined, {
|
|
8
|
-
rowFormat: QueryRowFormat.UseJsPropertyNames,
|
|
9
|
-
});
|
|
10
|
-
const result = await sqlReader.toArray();
|
|
11
|
-
for (const row of result) {
|
|
12
|
-
rows.push(row.id);
|
|
13
|
-
}
|
|
14
|
-
return rows;
|
|
15
|
-
};
|
|
16
|
-
export const IModelQueryClient = {
|
|
17
|
-
getAllModels: async (iModel) => {
|
|
18
|
-
// Note: IsNotSpatiallyLocated was introduced in a later version of the BisCore ECSchema.
|
|
19
|
-
// If the iModel has an earlier version, the statement will throw because the property does not exist.
|
|
20
|
-
// If the iModel was created from an earlier version and later upgraded to a newer version, the property may be NULL for models created prior to the upgrade.
|
|
21
|
-
let query = "SELECT ECInstanceId FROM Bis.GeometricModel3D WHERE IsPrivate = false AND IsTemplate = false AND (IsNotSpatiallyLocated IS NULL OR IsNotSpatiallyLocated = false)";
|
|
22
|
-
let models = [];
|
|
23
|
-
try {
|
|
24
|
-
models = await executeQuery(iModel, query);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
query =
|
|
28
|
-
"SELECT ECInstanceId FROM Bis.GeometricModel3D WHERE IsPrivate = false AND IsTemplate = false";
|
|
29
|
-
models = await executeQuery(iModel, query);
|
|
30
|
-
}
|
|
31
|
-
return models;
|
|
32
|
-
},
|
|
33
|
-
getAllCategories: async (iModel) => {
|
|
34
|
-
// Only use categories with elements in them
|
|
35
|
-
const query = "SELECT DISTINCT Category.Id AS id FROM BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId FROM BisCore.SpatialCategory)";
|
|
36
|
-
const categories = await executeQuery(iModel, query);
|
|
37
|
-
return categories;
|
|
38
|
-
},
|
|
39
|
-
getAllModelsAndCategories: async (iModel) => {
|
|
40
|
-
return {
|
|
41
|
-
models: await IModelQueryClient.getAllModels(iModel),
|
|
42
|
-
categories: await IModelQueryClient.getAllCategories(iModel),
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { IModelConnection, ViewState } from "@itwin/core-frontend";
|
|
2
|
-
import type { LegacySavedViewBase } from "../SavedViewTypes.js";
|
|
3
|
-
export declare function applyHiddenModelsAndCategories(viewState: ViewState, savedView: LegacySavedViewBase, iModelConnection: IModelConnection): Promise<void>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { IModelQueryClient } from "../../clients/IModelQueryClient.js";
|
|
2
|
-
import { isSavedView3d } from "../../clients/ISavedViewsClient.js";
|
|
3
|
-
function legacyViewHasValidHiddenModelsAndCategories(savedView) {
|
|
4
|
-
if (isSavedView3d(savedView)) {
|
|
5
|
-
return !!(savedView.hiddenCategories && savedView.hiddenModels);
|
|
6
|
-
}
|
|
7
|
-
return !!savedView.hiddenCategories;
|
|
8
|
-
}
|
|
9
|
-
export async function applyHiddenModelsAndCategories(viewState, savedView, iModelConnection) {
|
|
10
|
-
if (legacyViewHasValidHiddenModelsAndCategories(savedView)) {
|
|
11
|
-
const visible = await getVisibleModelsAndCategories(savedView, iModelConnection);
|
|
12
|
-
if (visible.categories) {
|
|
13
|
-
viewState.categorySelector.addCategories(visible.categories);
|
|
14
|
-
}
|
|
15
|
-
if (viewState.isSpatialView() && visible.models) {
|
|
16
|
-
viewState.modelSelector.addModels(visible.models);
|
|
17
|
-
}
|
|
18
|
-
await viewState.load();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
async function getVisibleModelsAndCategories(savedView, iModelConnection) {
|
|
22
|
-
return {
|
|
23
|
-
models: isSavedView3d(savedView)
|
|
24
|
-
? await getVisibleModels(savedView, iModelConnection)
|
|
25
|
-
: undefined,
|
|
26
|
-
categories: await getVisibleCategories(savedView, iModelConnection),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
async function getVisibleModels(savedView, iModelConnection) {
|
|
30
|
-
const hiddenModels = savedView.hiddenModels;
|
|
31
|
-
return hiddenModels ? getMissingModels(hiddenModels, iModelConnection) : undefined;
|
|
32
|
-
}
|
|
33
|
-
async function getVisibleCategories(savedView, iModelConnection) {
|
|
34
|
-
const hiddenCategories = savedView.hiddenCategories;
|
|
35
|
-
return hiddenCategories
|
|
36
|
-
? getMissingCategories(hiddenCategories, iModelConnection)
|
|
37
|
-
: undefined;
|
|
38
|
-
}
|
|
39
|
-
async function getMissingModels(models, iModelConnection) {
|
|
40
|
-
const allModels = await getAllModels(iModelConnection);
|
|
41
|
-
return getDiff(models, allModels);
|
|
42
|
-
}
|
|
43
|
-
async function getMissingCategories(categories, iModelConnection) {
|
|
44
|
-
const allCategories = await getAllCategories(iModelConnection);
|
|
45
|
-
return getDiff(categories, allCategories);
|
|
46
|
-
}
|
|
47
|
-
async function getAllModels(iModelConnection) {
|
|
48
|
-
return IModelQueryClient.getAllModels(iModelConnection);
|
|
49
|
-
}
|
|
50
|
-
async function getAllCategories(iModelConnection) {
|
|
51
|
-
return IModelQueryClient.getAllCategories(iModelConnection);
|
|
52
|
-
}
|
|
53
|
-
const getDiff = (arr1, arr2) => {
|
|
54
|
-
const set1 = new Set([...arr1]);
|
|
55
|
-
const set2 = new Set([...arr2].filter((x) => !set1.has(x)));
|
|
56
|
-
return [...set2];
|
|
57
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ViewData } from "@itwin/saved-views-client";
|
|
2
|
-
/**
|
|
3
|
-
* Convert url that potentially contains subtituted characters ('++and++' or '++dot++') to use restricated characters ('&' or '.')
|
|
4
|
-
* @param extensionData
|
|
5
|
-
*/
|
|
6
|
-
export declare const urlToLegacyUrl: (restrictedUrl: string) => string;
|
|
7
|
-
export declare const convertAllLegacyUrlsToUrls: (savedViewData: ViewData, convert: (url: string) => string) => void;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert url that potentially contains subtituted characters ('++and++' or '++dot++') to use restricated characters ('&' or '.')
|
|
3
|
-
* @param extensionData
|
|
4
|
-
*/
|
|
5
|
-
export const urlToLegacyUrl = (restrictedUrl) => {
|
|
6
|
-
const unrestrictedUrl = restrictedUrl
|
|
7
|
-
.replaceAll("++and++", "&")
|
|
8
|
-
.replaceAll("++dot++", ".");
|
|
9
|
-
return unrestrictedUrl;
|
|
10
|
-
};
|
|
11
|
-
export const convertAllLegacyUrlsToUrls = (savedViewData, convert) => {
|
|
12
|
-
const displayStyle = savedViewData?.itwin3dView.displayStyle ??
|
|
13
|
-
savedViewData?.itwinDrawingView.displayStyle ??
|
|
14
|
-
savedViewData?.itwinSheetView.displayStyle;
|
|
15
|
-
if (displayStyle === undefined) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
// Convert legacy urls to restricted urls
|
|
19
|
-
const baseUrl = displayStyle.mapImagery?.backgroundBase
|
|
20
|
-
?.url;
|
|
21
|
-
if (displayStyle.mapImagery && baseUrl) {
|
|
22
|
-
displayStyle.mapImagery.backgroundBase.url =
|
|
23
|
-
convert(baseUrl);
|
|
24
|
-
}
|
|
25
|
-
for (const layer of (displayStyle.mapImagery?.overlayLayers ??
|
|
26
|
-
[])) {
|
|
27
|
-
if (layer.url) {
|
|
28
|
-
layer.url = convert(layer.url);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
for (const layer of (displayStyle.mapImagery?.backgroundLayers ??
|
|
32
|
-
[])) {
|
|
33
|
-
if (layer.url) {
|
|
34
|
-
layer.url = convert(layer.url);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
for (const model of displayStyle.contextRealityModels ?? []) {
|
|
38
|
-
if (model.tilesetUrl) {
|
|
39
|
-
model.tilesetUrl = convert(model.tilesetUrl);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|