@itwin/saved-views-react 0.1.0 → 0.2.1
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 +9 -5
- package/lib/SavedViewTile/SavedViewOptions.css +19 -16
- package/lib/SavedViewTile/SavedViewTile.css +72 -69
- package/lib/SavedViewsClient/ITwinSavedViewsClient.d.ts +4 -3
- package/lib/SavedViewsClient/ITwinSavedViewsClient.js +7 -0
- package/lib/SavedViewsClient/SavedViewsClient.d.ts +8 -2
- package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTile.js +1 -1
- package/lib/SavedViewsWidget/SavedViewsExpandableBlockWidget.css +2 -22
- package/lib/SavedViewsWidget/SavedViewsFolderWidget.js +1 -1
- package/lib/StickyExpandableBlock/StickyExpandableBlock.css +14 -11
- package/lib/TileGrid/TileGrid.css +2 -1
- package/lib/api/utilities/translation/SavedViewTranslation.d.ts +7 -7
- package/lib/api/utilities/translation/SavedViewTranslation.js +7 -24
- package/lib/api/utilities/translation/clipVectorsLegacyExtractor.d.ts +3 -0
- package/lib/api/utilities/translation/clipVectorsLegacyExtractor.js +41 -0
- package/lib/api/utilities/translation/displayStyleExtractor.d.ts +4 -5
- package/lib/api/utilities/translation/displayStyleExtractor.js +13 -6
- package/lib/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.d.ts +5 -5
- package/lib/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.js +1 -6
- package/lib/captureSavedViewData.d.ts +13 -0
- package/lib/captureSavedViewData.js +149 -0
- package/lib/captureSavedViewThumbnail.d.ts +3 -0
- package/lib/captureSavedViewThumbnail.js +25 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/useSavedViews.d.ts +2 -1
- package/lib/useSavedViews.js +50 -26
- package/package.json +7 -5
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
@layer itwinui;
|
|
6
|
+
|
|
7
|
+
@layer itwin-svr {
|
|
8
|
+
.svr-layered-dropdown--back {
|
|
9
|
+
display: flex;
|
|
10
|
+
gap: var(--iui-size-s);
|
|
11
|
+
align-items: center;
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
/*# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9MYXllcmVkRHJvcGRvd25NZW51L0xheWVyZWREcm9wZG93bk1lbnUuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIiwiZmlsZSI6IkxheWVyZWREcm9wZG93bk1lbnUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS1cbiogQ29weXJpZ2h0IChjKSBCZW50bGV5IFN5c3RlbXMsIEluY29ycG9yYXRlZC4gQWxsIHJpZ2h0cyByZXNlcnZlZC5cbiogU2VlIExJQ0VOU0UubWQgaW4gdGhlIHByb2plY3Qgcm9vdCBmb3IgbGljZW5zZSB0ZXJtcyBhbmQgZnVsbCBjb3B5cmlnaHQgbm90aWNlLlxuKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi9cbkBsYXllciBpdHdpbnVpO1xuXG5AbGF5ZXIgaXR3aW4tc3ZyIHtcbiAgLnN2ci1sYXllcmVkLWRyb3Bkb3duLS1iYWNrIHtcbiAgICBkaXNwbGF5OiBmbGV4O1xuICAgIGdhcDogdmFyKC0taXVpLXNpemUtcyk7XG4gICAgYWxpZ24taXRlbXM6IGNlbnRlcjtcbiAgfVxufVxuIl19 */
|
|
@@ -2,25 +2,28 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@layer itwinui;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
@layer itwin-svr {
|
|
8
|
+
.svr-searchable-submenu {
|
|
9
|
+
display: grid;
|
|
10
|
+
grid: auto minmax(0, 1fr) / 1fr;
|
|
11
|
+
gap: var(--iui-size-xs);
|
|
12
|
+
height: calc(var(--iui-menu-max-height) - 2 * var(--iui-component-height) - 1px);
|
|
13
|
+
user-select: none;
|
|
14
|
+
}
|
|
13
15
|
|
|
14
|
-
.svr-searchable-submenu > div {
|
|
15
|
-
|
|
16
|
-
}
|
|
16
|
+
.svr-searchable-submenu > div {
|
|
17
|
+
overflow: auto;
|
|
18
|
+
}
|
|
17
19
|
|
|
18
|
-
.svr-searchable-submenu-item {
|
|
19
|
-
|
|
20
|
-
}
|
|
20
|
+
.svr-searchable-submenu-item {
|
|
21
|
+
width: calc(10 * var(--iui-size-l));
|
|
22
|
+
}
|
|
21
23
|
|
|
22
|
-
.svr-semibold {
|
|
23
|
-
|
|
24
|
+
.svr-semibold {
|
|
25
|
+
font-weight: var(--iui-font-weight-semibold);
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
/*# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
/*# sourceMappingURL=data:application/json;base64,eyJ2Z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Gl2IHtcbiAgICBvdmVyZmxvdzogYXV0bztcbiAgfVxuXG4gIC5zdnItc2VhcmNoYWJsZS1zdWJtZW51LWl0ZW0ge1xuICAgIHdpZHRoOiBjYWxjKDEwICogdmFyKC0taXVpLXNpemUtbCkpO1xuICB9XG5cbiAgLnN2ci1zZW1pYm9sZCB7XG4gICAgZm9udC13ZWlnaHQ6IHZhcigtLWl1aS1mb250LXdlaWdodC1zZW1pYm9sZCk7XG4gIH1cbn1cbiJdfQ== */
|
|
@@ -2,88 +2,91 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@layer itwinui;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
@layer itwin-svr {
|
|
8
|
+
.svr-tile {
|
|
9
|
+
width: var(--itwin-svr-tile-width, calc(8 * var(--iui-size-xl)));
|
|
10
|
+
}
|
|
9
11
|
|
|
10
|
-
.svr-tile .svr-tile-thumbnail {
|
|
11
|
-
|
|
12
|
-
}
|
|
12
|
+
.svr-tile .svr-tile-thumbnail {
|
|
13
|
+
height: var(--itwin-svr-thumbnail-height, calc(4 * var(--iui-size-xl)));
|
|
14
|
+
}
|
|
13
15
|
|
|
14
|
-
.svr-tile .svr-tile-name {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
.svr-tile .svr-tile-name {
|
|
17
|
+
height: calc(var(--iui-size-l) + 2px);
|
|
18
|
+
user-select: unset;
|
|
19
|
+
}
|
|
18
20
|
|
|
19
|
-
.svr-tile--metadata {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
21
|
+
.svr-tile--metadata {
|
|
22
|
+
display: grid;
|
|
23
|
+
grid: 1fr / auto minmax(0, 1fr) auto;
|
|
24
|
+
align-items: center;
|
|
25
|
+
}
|
|
24
26
|
|
|
25
|
-
.svr-tile--metadata > svg {
|
|
26
|
-
|
|
27
|
-
}
|
|
27
|
+
.svr-tile--metadata > svg {
|
|
28
|
+
margin-right: var(--iui-size-xs);
|
|
29
|
+
}
|
|
28
30
|
|
|
29
|
-
.svr-tile--tag-container {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
31
|
+
.svr-tile--tag-container {
|
|
32
|
+
display: flex;
|
|
33
|
+
gap: var(--iui-size-s);
|
|
34
|
+
}
|
|
33
35
|
|
|
34
|
-
.svr-tile--tag {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
36
|
+
.svr-tile--tag {
|
|
37
|
+
align-items: center;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
}
|
|
41
43
|
|
|
42
|
-
.svr-tile--tag-overflow {
|
|
43
|
-
|
|
44
|
-
}
|
|
44
|
+
.svr-tile--tag-overflow {
|
|
45
|
+
margin-left: var(--iui-size-s);
|
|
46
|
+
}
|
|
45
47
|
|
|
46
|
-
.svr-tile--more-options {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
48
|
+
.svr-tile--more-options {
|
|
49
|
+
z-index: 2;
|
|
50
|
+
grid-area: 1 / 1 / -1 / -1;
|
|
51
|
+
place-self: end;
|
|
52
|
+
margin: 0;
|
|
53
|
+
margin-inline-end: calc(-1*var(--iui-size-2xs));
|
|
54
|
+
display: grid;
|
|
55
|
+
position: absolute;
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
.svr-tile:not(:hover, :focus-within) .svr-tile--more-options:where(:not(.svr-visible)) {
|
|
57
|
-
|
|
58
|
-
}
|
|
58
|
+
.svr-tile:not(:hover, :focus-within) .svr-tile--more-options:where(:not(.svr-visible)) {
|
|
59
|
+
visibility: hidden;
|
|
60
|
+
}
|
|
59
61
|
|
|
60
|
-
.svr-tile--icon-container {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
62
|
+
.svr-tile--icon-container {
|
|
63
|
+
display: flex;
|
|
64
|
+
margin-top: calc(0.5 * var(--iui-size-s));
|
|
65
|
+
margin-inline: var(--iui-size-xs);
|
|
66
|
+
gap: var(--iui-size-2xs);
|
|
67
|
+
z-index: 1;
|
|
68
|
+
}
|
|
67
69
|
|
|
68
|
-
.svr-tile--icon {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
70
|
+
.svr-tile--icon {
|
|
71
|
+
border-radius: 50%;
|
|
72
|
+
background: rgb(0, 0, 0, var(--iui-opacity-3));
|
|
73
|
+
min-width: var(--iui-component-height-small);
|
|
74
|
+
min-height: var(--iui-component-height-small);
|
|
75
|
+
display: flex;
|
|
76
|
+
place-items: center;
|
|
77
|
+
padding-inline: var(--iui-size-2xs);
|
|
78
|
+
border: 1px solid transparent;
|
|
79
|
+
}
|
|
78
80
|
|
|
79
|
-
.svr-tile--icon svg {
|
|
80
|
-
|
|
81
|
-
}
|
|
81
|
+
.svr-tile--icon svg {
|
|
82
|
+
fill: var(--iui-color-white);
|
|
83
|
+
}
|
|
82
84
|
|
|
83
|
-
.svr-tile--editable-title > span {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
.svr-tile--editable-title > span {
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: var(--iui-size-s);
|
|
89
|
+
}
|
|
87
90
|
}
|
|
88
91
|
|
|
89
|
-
/*# sourceMappingURL=data:application/json;base64,
|
|
92
|
+
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJza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
1
|
-
import { type
|
|
1
|
+
import { type SavedViewRepresentation } from "@itwin/saved-views-client";
|
|
2
2
|
import type { SavedView, SavedViewGroup, SavedViewTag } from "../SavedView.js";
|
|
3
|
-
import type { CreateGroupParams, CreateSavedViewParams, CreateTagParams, DeleteGroupParams, DeleteSavedViewParams, DeleteTagParams, GetSavedViewInfoParams, GetSingularSavedViewParams, GetThumbnailUrlParams, SavedViewInfo, SavedViewsClient, UpdateGroupParams, UpdateSavedViewParams, UpdateTagParams } from "./SavedViewsClient.js";
|
|
3
|
+
import type { CreateGroupParams, CreateSavedViewParams, CreateTagParams, DeleteGroupParams, DeleteSavedViewParams, DeleteTagParams, GetSavedViewInfoParams, GetSingularSavedViewParams, GetThumbnailUrlParams, SavedViewInfo, SavedViewsClient, UpdateGroupParams, UpdateSavedViewParams, UpdateTagParams, UploadThumbnailParams } from "./SavedViewsClient.js";
|
|
4
4
|
interface ITwinSavedViewsClientParams {
|
|
5
5
|
/** @default "https://api.bentley.com/savedviews" */
|
|
6
6
|
getAccessToken: () => Promise<string>;
|
|
@@ -15,8 +15,9 @@ export declare class ITwinSavedViewsClient implements SavedViewsClient {
|
|
|
15
15
|
private client;
|
|
16
16
|
constructor(args: ITwinSavedViewsClientParams);
|
|
17
17
|
getSavedViewInfo(args: GetSavedViewInfoParams): Promise<SavedViewInfo>;
|
|
18
|
-
getSingularSavedView(args: GetSingularSavedViewParams): Promise<
|
|
18
|
+
getSingularSavedView(args: GetSingularSavedViewParams): Promise<SavedViewRepresentation>;
|
|
19
19
|
getThumbnailUrl(args: GetThumbnailUrlParams): Promise<string | undefined>;
|
|
20
|
+
uploadThumbnail(args: UploadThumbnailParams): Promise<void>;
|
|
20
21
|
createSavedView(args: CreateSavedViewParams): Promise<SavedView>;
|
|
21
22
|
updateSavedView(args: UpdateSavedViewParams): Promise<SavedView>;
|
|
22
23
|
deleteSavedView(args: DeleteSavedViewParams): Promise<void>;
|
|
@@ -36,6 +36,13 @@ export class ITwinSavedViewsClient {
|
|
|
36
36
|
});
|
|
37
37
|
return response.href;
|
|
38
38
|
}
|
|
39
|
+
async uploadThumbnail(args) {
|
|
40
|
+
await this.client.updateImage({
|
|
41
|
+
savedViewId: args.savedViewId,
|
|
42
|
+
image: args.image,
|
|
43
|
+
signal: args.signal,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
39
46
|
async createSavedView(args) {
|
|
40
47
|
const { savedView } = await this.client.createSavedView({
|
|
41
48
|
iTwinId: args.iTwinId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionMin, ExtensionSavedViewCreate,
|
|
1
|
+
import type { ExtensionMin, ExtensionSavedViewCreate, SavedViewRepresentation, ViewData } from "@itwin/saved-views-client";
|
|
2
2
|
import type { SavedView, SavedViewGroup, SavedViewTag } from "../SavedView.js";
|
|
3
3
|
export interface SavedViewInfo {
|
|
4
4
|
savedViews: SavedView[];
|
|
@@ -7,8 +7,9 @@ export interface SavedViewInfo {
|
|
|
7
7
|
}
|
|
8
8
|
export interface SavedViewsClient {
|
|
9
9
|
getSavedViewInfo: (args: GetSavedViewInfoParams) => Promise<SavedViewInfo>;
|
|
10
|
-
getSingularSavedView: (args: GetSingularSavedViewParams) => Promise<
|
|
10
|
+
getSingularSavedView: (args: GetSingularSavedViewParams) => Promise<SavedViewRepresentation>;
|
|
11
11
|
getThumbnailUrl: (args: GetThumbnailUrlParams) => Promise<string | undefined>;
|
|
12
|
+
uploadThumbnail: (args: UploadThumbnailParams) => Promise<void>;
|
|
12
13
|
createSavedView: (args: CreateSavedViewParams) => Promise<SavedView>;
|
|
13
14
|
updateSavedView: (args: UpdateSavedViewParams) => Promise<SavedView>;
|
|
14
15
|
deleteSavedView: (args: DeleteSavedViewParams) => Promise<void>;
|
|
@@ -29,6 +30,11 @@ export interface GetSingularSavedViewParams extends CommonParams {
|
|
|
29
30
|
export interface GetThumbnailUrlParams extends CommonParams {
|
|
30
31
|
savedViewId: string;
|
|
31
32
|
}
|
|
33
|
+
export interface UploadThumbnailParams extends CommonParams {
|
|
34
|
+
savedViewId: string;
|
|
35
|
+
/** Image data encoded as base64 data URL. */
|
|
36
|
+
image: string;
|
|
37
|
+
}
|
|
32
38
|
export interface CreateSavedViewParams extends CommonParams {
|
|
33
39
|
iTwinId: string;
|
|
34
40
|
iModelId?: string | undefined;
|
|
@@ -33,5 +33,5 @@ export function SavedViewGroupTile(props) {
|
|
|
33
33
|
props.onRename?.(props.group.id, newName);
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
-
} }), thumbnail:
|
|
36
|
+
} }), thumbnail: _jsx(SvgFolder, { className: "iui-thumbnail-icon" }), isActionable: !props.editable && !editingName, moreOptions: (props.options && props.options.length > 0) ? props.options : undefined, onClick: dispatchOpenGroup, children: _jsxs(Text, { isMuted: true, children: [props.numItems, " items"] }) }) }) }));
|
|
37
37
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@layer itwinui;
|
|
5
6
|
|
|
6
7
|
@layer itwin-svr {
|
|
7
8
|
.svr-saved-views-widget {
|
|
@@ -19,27 +20,6 @@
|
|
|
19
20
|
position: relative;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
.svr-folder-edit.svr-folder-edit {
|
|
23
|
-
width: 100%;
|
|
24
|
-
height: 100%;
|
|
25
|
-
display: grid;
|
|
26
|
-
place-items: center;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.svr-folder-edit.svr-folder-edit > div {
|
|
31
|
-
height: 100%;
|
|
32
|
-
width: 100%;
|
|
33
|
-
visibility: hidden;
|
|
34
|
-
display: grid;
|
|
35
|
-
place-items: center;
|
|
36
|
-
background: var(--iui-color-background-transparent-hover);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.svr-folder .svr-folder-edit.svr-folder-edit:hover > div {
|
|
40
|
-
visibility: visible;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
23
|
.svr-borderless-expandable-block-title {
|
|
44
24
|
display: flex;
|
|
45
25
|
gap: var(--iui-size-xs);
|
|
@@ -47,4 +27,4 @@
|
|
|
47
27
|
}
|
|
48
28
|
}
|
|
49
29
|
|
|
50
|
-
/*# sourceMappingURL=data:application/json;base64,
|
|
30
|
+
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9TYXZlZFZpZXdzV2lkZ2V0L1NhdmVkVmlld3NFeHBhbmRhYmxlQmxvY2tXaWRnZXQuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIiwiZmlsZSI6IlNhdmVkVmlld3NFeHBhbmRhYmxlQmxvY2tXaWRnZXQuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS1cbiogQ29weXJpZ2h0IChjKSBCZW50bGV5IFN5c3RlbXMsIEluY29ycG9yYXRlZC4gQWxsIHJpZ2h0cyByZXNlcnZlZC5cbiogU2VlIExJQ0VOU0UubWQgaW4gdGhlIHByb2plY3Qgcm9vdCBmb3IgbGljZW5zZSB0ZXJtcyBhbmQgZnVsbCBjb3B5cmlnaHQgbm90aWNlLlxuKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi9cbkBsYXllciBpdHdpbnVpO1xuXG5AbGF5ZXIgaXR3aW4tc3ZyIHtcbiAgLnN2ci1zYXZlZC12aWV3cy13aWRnZXQge1xuICAgIC0taXR3aW4tc3ZyLXRpbGUtd2lkdGg6IGNhbGMoOCAqIHZhcigtLWl1aS1zaXplLXhsKSk7XG4gICAgLS1pdHdpbi1zdnItdGh1bWJuYWlsLWhlaWdodDogY2FsYyg0ICogdmFyKC0taXVpLXNpemUteGwpKTtcblxuICAgIG92ZXJmbG93OiBhdXRvO1xuICB9XG5cbiAgLnN2ci1ncm91cC1ncmlkIHtcbiAgICAtLWl0d2luLXN2ci10aWxlLXdpZHRoOiBjYWxjKDMgKiB2YXIoLS1pdWktc2l6ZS0zeGwpKTtcbiAgfVxuXG4gIC5zdnItZm9sZGVyIC5pdWktdGlsZS10aHVtYm5haWwge1xuICAgIHBvc2l0aW9uOiByZWxhdGl2ZTtcbiAgfVxuXG4gIC5zdnItYm9yZGVybGVzcy1leHBhbmRhYmxlLWJsb2NrLXRpdGxlIHtcbiAgICBkaXNwbGF5OiBmbGV4O1xuICAgIGdhcDogdmFyKC0taXVpLXNpemUteHMpO1xuICAgIGFsaWduLWl0ZW1zOiBjZW50ZXI7XG4gIH1cbn1cbiJdfQ== */
|
|
@@ -56,5 +56,5 @@ function SavedViewsGroupScreen(props) {
|
|
|
56
56
|
gap: "var(--iui-size-s)",
|
|
57
57
|
background: "var(--iui-color-background)",
|
|
58
58
|
padding: "var(--iui-size-s)",
|
|
59
|
-
}, children: [_jsx(Button, { startIcon: _jsx(SvgChevronLeft, {}), onClick: () => props.setActiveGroup(undefined), children: "Back" }), _jsxs(Breadcrumbs, { children: [_jsx(IconButton, { onClick: () => props.setActiveGroup(undefined), children: _jsx(SvgHome, {}) }), _jsx(DropdownButton, { menuItems: (close) => groups.map((group) => _jsx(MenuItem, { onClick: () => { close(); props.setActiveGroup(group.id); }, children: group.displayName }, group.id)), children: props.activeGroup.displayName })] })] }), _jsx("div", { style: { overflow: "auto" }, children: _jsx(TileGrid, { gridItems: props.savedViews, children: (savedView) => (_jsx(SavedViewTile, { savedView: savedView, tags: props.tags, editable: props.editable, options: props.options?.(savedView), onClick: props.onTileClick }, savedView.id)) }) })] }));
|
|
59
|
+
}, children: [_jsx(Button, { styleType: "borderless", startIcon: _jsx(SvgChevronLeft, {}), onClick: () => props.setActiveGroup(undefined), children: "Back" }), _jsxs(Breadcrumbs, { children: [_jsx(IconButton, { styleType: "borderless", onClick: () => props.setActiveGroup(undefined), children: _jsx(SvgHome, {}) }), _jsx(DropdownButton, { styleType: "borderless", menuItems: (close) => groups.map((group) => _jsx(MenuItem, { onClick: () => { close(); props.setActiveGroup(group.id); }, children: group.displayName }, group.id)), children: props.activeGroup.displayName })] })] }), _jsx("div", { style: { overflow: "auto" }, children: _jsx(TileGrid, { gridItems: props.savedViews, children: (savedView) => (_jsx(SavedViewTile, { savedView: savedView, tags: props.tags, editable: props.editable, options: props.options?.(savedView), onClick: props.onTileClick }, savedView.id)) }) })] }));
|
|
60
60
|
}
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@layer itwinui;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
@layer itwin-svr {
|
|
8
|
+
.svr-expandable-block-header {
|
|
9
|
+
position: sticky;
|
|
10
|
+
top: 0;
|
|
11
|
+
z-index: 1;
|
|
12
|
+
}
|
|
11
13
|
|
|
12
|
-
.svr-expandable-block-header[data-stuck=true] {
|
|
13
|
-
|
|
14
|
-
}
|
|
14
|
+
.svr-expandable-block-header[data-stuck=true] {
|
|
15
|
+
box-shadow: var(--iui-shadow-1);
|
|
16
|
+
}
|
|
15
17
|
|
|
16
|
-
.svr-expandable-block-header:not(:hover) {
|
|
17
|
-
|
|
18
|
+
.svr-expandable-block-header:not(:hover) {
|
|
19
|
+
background: var(--iui-color-background);
|
|
20
|
+
}
|
|
18
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iAgfVxuXG4gIC5zdnItZXhwYW5kYWJsZS1ibG9jay1oZWFkZXI6bm90KDpob3Zlcikge1xuICAgIGJhY2tncm91bmQ6IHZhcigtLWl1aS1jb2xvci1iYWNrZ3JvdW5kKTtcbiAgfVxufVxuIl19 */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@layer itwinui;
|
|
5
6
|
|
|
6
7
|
@layer itwin-svr {
|
|
7
8
|
.svr-tile-grid {
|
|
@@ -25,4 +26,4 @@
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
/*# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9UaWxlR3JpZC9UaWxlR3JpZC5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEiLCJmaWxlIjoiVGlsZUdyaWQuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiLyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS1cbiogQ29weXJpZ2h0IChjKSBCZW50bGV5IFN5c3RlbXMsIEluY29ycG9yYXRlZC4gQWxsIHJpZ2h0cyByZXNlcnZlZC5cbiogU2VlIExJQ0VOU0UubWQgaW4gdGhlIHByb2plY3Qgcm9vdCBmb3IgbGljZW5zZSB0ZXJtcyBhbmQgZnVsbCBjb3B5cmlnaHQgbm90aWNlLlxuKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi9cbkBsYXllciBpdHdpbnVpO1xuXG5AbGF5ZXIgaXR3aW4tc3ZyIHtcbiAgLnN2ci10aWxlLWdyaWQge1xuICAgIGRpc3BsYXk6IGdyaWQ7XG4gICAgZ3JpZC10ZW1wbGF0ZS1jb2x1bW5zOiByZXBlYXQoYXV0by1maWxsLCB2YXIoLS1pdHdpbi1zdnItdGlsZS13aWR0aCkpO1xuICAgIHBsYWNlLWNvbnRlbnQ6IHN0YXJ0IHNwYWNlLWFyb3VuZDtcbiAgICBwbGFjZS1pdGVtczogY2VudGVyO1xuICAgIGdhcDogdmFyKC0taXVpLXNpemUtbSk7XG4gICAgbWFyZ2luOiB2YXIoLS1pdWktc2l6ZS14cykgdmFyKC0taXVpLXNpemUtcyk7XG4gICAgbWFyZ2luLWJvdHRvbTogdmFyKC0taXVpLXNpemUtbCk7XG4gIH1cblxuICAuc3ZyLXRpbGUtZ3JpZC0tbW9yZS1pdGVtcy10aWxlIHtcbiAgICBwYWRkaW5nOiB2YXIoLS1pdWktc2l6ZS1tKTtcbiAgICBkaXNwbGF5OiBncmlkO1xuICAgIGdhcDogdmFyKC0taXVpLXNpemUtcyk7XG4gICAganVzdGlmeS1pdGVtczogY2VudGVyO1xuICAgIHdpZHRoOiBjYWxjKDAuOCAqIHZhcigtLWl0d2luLXN2ci10aWxlLXdpZHRoKSk7XG4gICAgdGV4dC1hbGlnbjogY2VudGVyO1xuICAgIG1pbi13aWR0aDogbWluLWNvbnRlbnQ7XG4gIH1cbn1cbiJdfQ== */
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { IModelConnection, ScreenViewport, ViewState } from "@itwin/core-frontend";
|
|
2
|
-
import {
|
|
2
|
+
import { type SavedViewRepresentation } from "@itwin/saved-views-client";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a saved view response to a saved view response that includes a legacy view.
|
|
5
5
|
* @param savedViewResponse A saved view response with or without a legacy view.
|
|
6
6
|
* @param iModelConnection The {@link IModelConnection} for the saved view; used to query for additional information.
|
|
7
|
-
* @returns A {@link
|
|
7
|
+
* @returns A {@link SavedViewRepresentation} that contains legacy saved view data.
|
|
8
8
|
*/
|
|
9
|
-
export declare function translateSavedViewResponseToLegacySavedViewResponse(savedViewResponse:
|
|
9
|
+
export declare function translateSavedViewResponseToLegacySavedViewResponse(savedViewResponse: SavedViewRepresentation, iModelConnection: IModelConnection): Promise<SavedViewRepresentation>;
|
|
10
10
|
/**
|
|
11
11
|
* Converts a legacy saved view (response) to an iTwin.js ViewState.
|
|
12
|
-
* @param legacySavedViewResponse A saved view response that includes a legacy view
|
|
12
|
+
* @param legacySavedViewResponse A saved view response that includes a legacy view.
|
|
13
13
|
* @param iModelConnection The {@link IModelConnection} for the saved view; used to query for additional information.
|
|
14
14
|
* @returns A {@link ViewState} with the saved view applied.
|
|
15
15
|
*/
|
|
16
|
-
export declare function translateLegacySavedViewToITwinJsViewState(legacySavedViewResponse:
|
|
16
|
+
export declare function translateLegacySavedViewToITwinJsViewState(legacySavedViewResponse: SavedViewRepresentation, iModelConnection: IModelConnection): Promise<ViewState | undefined>;
|
|
17
17
|
/**
|
|
18
18
|
* Apply extension data (overrides) onto the supplied viewport. Only works with legacy-formatted extension data.
|
|
19
19
|
* @param viewport The {@link ScreenViewport} used to display the saved view and iModel.
|
|
20
|
-
* @param legacySavedViewResponse A saved view response that includes a legacy view
|
|
20
|
+
* @param legacySavedViewResponse A saved view response that includes a legacy view.
|
|
21
21
|
*/
|
|
22
|
-
export declare function applyExtensionsToViewport(viewport: ScreenViewport, legacySavedViewResponse:
|
|
22
|
+
export declare function applyExtensionsToViewport(viewport: ScreenViewport, legacySavedViewResponse: SavedViewRepresentation | undefined): Promise<void>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { IModelReadRpcInterface } from "@itwin/core-common";
|
|
6
6
|
import { DrawingViewState, EmphasizeElements, SheetViewState, SpatialViewState, } from "@itwin/core-frontend";
|
|
7
|
+
import { isViewDataITwin3d, isViewDataITwinDrawing, isViewDataITwinSheet, } from "@itwin/saved-views-client";
|
|
7
8
|
import { isDrawingSavedView, isSheetSavedView, isSpatialSavedView } from "../../clients/ISavedViewsClient.js";
|
|
8
9
|
import { applyHiddenModelsAndCategories } from "./ModelsAndCategoriesHelper.js";
|
|
9
10
|
import { SavedViewsExtensionHandlers } from "./SavedViewsExtensionHandlers.js";
|
|
@@ -14,24 +15,6 @@ var ViewTypes;
|
|
|
14
15
|
ViewTypes[ViewTypes["ViewDefinition3d"] = 1] = "ViewDefinition3d";
|
|
15
16
|
ViewTypes[ViewTypes["DrawingViewDefinition"] = 2] = "DrawingViewDefinition";
|
|
16
17
|
})(ViewTypes || (ViewTypes = {}));
|
|
17
|
-
/**
|
|
18
|
-
* Type-check for {@link ViewDataItwin3d}
|
|
19
|
-
*/
|
|
20
|
-
function isSavedViewItwin3d(savedViewData) {
|
|
21
|
-
return savedViewData.itwin3dView !== undefined;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Type-check for {@link ViewDataITwinSheet}
|
|
25
|
-
*/
|
|
26
|
-
function isSavedViewItwinSheet(savedViewData) {
|
|
27
|
-
return savedViewData.itwinSheetView !== undefined;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Type-check for {@link ViewDataITwinDrawing}
|
|
31
|
-
*/
|
|
32
|
-
function isSavedViewItwinDrawing(savedViewData) {
|
|
33
|
-
return savedViewData.itwinDrawingView !== undefined;
|
|
34
|
-
}
|
|
35
18
|
/**
|
|
36
19
|
* Extract the legacy saved view data from a legacy saved view response
|
|
37
20
|
* @param legacySavedViewResponse
|
|
@@ -44,7 +27,7 @@ function legacyViewFrom(legacySavedViewResponse) {
|
|
|
44
27
|
* Converts a saved view response to a saved view response that includes a legacy view.
|
|
45
28
|
* @param savedViewResponse A saved view response with or without a legacy view.
|
|
46
29
|
* @param iModelConnection The {@link IModelConnection} for the saved view; used to query for additional information.
|
|
47
|
-
* @returns A {@link
|
|
30
|
+
* @returns A {@link SavedViewRepresentation} that contains legacy saved view data.
|
|
48
31
|
*/
|
|
49
32
|
export async function translateSavedViewResponseToLegacySavedViewResponse(savedViewResponse, iModelConnection) {
|
|
50
33
|
const legacySavedView = await translateSavedViewToLegacySavedView(savedViewResponse, iModelConnection);
|
|
@@ -54,7 +37,7 @@ export async function translateSavedViewResponseToLegacySavedViewResponse(savedV
|
|
|
54
37
|
}
|
|
55
38
|
/**
|
|
56
39
|
* Converts a legacy saved view (response) to an iTwin.js ViewState.
|
|
57
|
-
* @param legacySavedViewResponse A saved view response that includes a legacy view
|
|
40
|
+
* @param legacySavedViewResponse A saved view response that includes a legacy view.
|
|
58
41
|
* @param iModelConnection The {@link IModelConnection} for the saved view; used to query for additional information.
|
|
59
42
|
* @returns A {@link ViewState} with the saved view applied.
|
|
60
43
|
*/
|
|
@@ -69,7 +52,7 @@ export async function translateLegacySavedViewToITwinJsViewState(legacySavedView
|
|
|
69
52
|
/**
|
|
70
53
|
* Apply extension data (overrides) onto the supplied viewport. Only works with legacy-formatted extension data.
|
|
71
54
|
* @param viewport The {@link ScreenViewport} used to display the saved view and iModel.
|
|
72
|
-
* @param legacySavedViewResponse A saved view response that includes a legacy view
|
|
55
|
+
* @param legacySavedViewResponse A saved view response that includes a legacy view.
|
|
73
56
|
*/
|
|
74
57
|
export async function applyExtensionsToViewport(viewport, legacySavedViewResponse) {
|
|
75
58
|
if (!legacySavedViewResponse) {
|
|
@@ -93,17 +76,17 @@ async function translateSavedViewToLegacySavedView(savedViewResponse, iModelConn
|
|
|
93
76
|
legacySavedView = savedViewData.legacyView;
|
|
94
77
|
// legacySavedView.id = savedView.id; // Change legacy sv id to comboId
|
|
95
78
|
}
|
|
96
|
-
else if (
|
|
79
|
+
else if (isViewDataITwin3d(savedViewData)) {
|
|
97
80
|
const iModelViewData = await fetchIModelViewData(ViewTypes.ViewDefinition3d, iModelConnection);
|
|
98
81
|
const actual = savedViewITwin3dToLegacy3dSavedView(savedViewResponse, iModelViewData);
|
|
99
82
|
legacySavedView = actual;
|
|
100
83
|
}
|
|
101
|
-
else if (
|
|
84
|
+
else if (isViewDataITwinDrawing(savedViewData)) {
|
|
102
85
|
const iModelViewData = await fetchIModelViewData(ViewTypes.DrawingViewDefinition, iModelConnection);
|
|
103
86
|
const actual = savedViewItwinDrawingToLegacyDrawingView(savedViewResponse, iModelViewData);
|
|
104
87
|
legacySavedView = actual;
|
|
105
88
|
}
|
|
106
|
-
else if (
|
|
89
|
+
else if (isViewDataITwinSheet(savedViewData)) {
|
|
107
90
|
const iModelViewData = await fetchIModelViewData(ViewTypes.SheetViewDefinition, iModelConnection);
|
|
108
91
|
const actual = savedViewItwinSheetToLegacySheetSavedView(savedViewResponse, iModelViewData);
|
|
109
92
|
legacySavedView = actual;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SpatialViewDefinitionProps } from "@itwin/core-common";
|
|
2
|
+
import type { ClipPrimitivePlaneProps, ClipPrimitiveShapeProps } from "@itwin/saved-views-client";
|
|
3
|
+
export declare function extractClipVectorsFromLegacy(input: SpatialViewDefinitionProps): Array<ClipPrimitivePlaneProps | ClipPrimitiveShapeProps> | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { applyExtraction, extractArray2d, extractArrayConditionally, extractBoolean, extractNumber, extractObject, extractSimpleArray, simpleTypeOf, } from "./extractionUtilities.js";
|
|
2
|
+
export function extractClipVectorsFromLegacy(input) {
|
|
3
|
+
const viewDetails = input.jsonProperties?.viewDetails;
|
|
4
|
+
if (!viewDetails || !("clip" in viewDetails)) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const output = {};
|
|
8
|
+
applyExtraction(viewDetails, output, clipVectorLegacyMappings);
|
|
9
|
+
return output.clipVectors;
|
|
10
|
+
}
|
|
11
|
+
const clipPlaneLegacyMappings = [
|
|
12
|
+
extractSimpleArray(simpleTypeOf("number"), "normal"),
|
|
13
|
+
extractNumber("dist", "distance"),
|
|
14
|
+
extractBoolean("invisible"),
|
|
15
|
+
extractBoolean("interior"),
|
|
16
|
+
];
|
|
17
|
+
const clipPrimitivePlaneLegacyMappings = [
|
|
18
|
+
extractObject([extractArray2d(clipPlaneLegacyMappings, "clips"), extractBoolean("invisible")], "planes"),
|
|
19
|
+
];
|
|
20
|
+
const clipPrimitiveShapeLegacyMappings = [
|
|
21
|
+
extractObject([
|
|
22
|
+
extractSimpleArray(isPoint, "points"),
|
|
23
|
+
extractSimpleArray(isTransformRow, "trans", "transform"),
|
|
24
|
+
extractNumber("zlow", "zLow"),
|
|
25
|
+
extractNumber("zhigh", "zHigh"),
|
|
26
|
+
extractBoolean("mask"),
|
|
27
|
+
extractBoolean("invisible"),
|
|
28
|
+
], "shape"),
|
|
29
|
+
];
|
|
30
|
+
const clipVectorLegacyMappings = [
|
|
31
|
+
extractArrayConditionally([
|
|
32
|
+
{ discriminator: "planes", mappings: clipPrimitivePlaneLegacyMappings },
|
|
33
|
+
{ discriminator: "shape", mappings: clipPrimitiveShapeLegacyMappings },
|
|
34
|
+
], "clip", "clipVectors"),
|
|
35
|
+
];
|
|
36
|
+
function isPoint(val) {
|
|
37
|
+
return Array.isArray(val) && val.length === 3 && val.every((num) => typeof num === "number");
|
|
38
|
+
}
|
|
39
|
+
function isTransformRow(value) {
|
|
40
|
+
return Array.isArray(value) && value.length === 4 && value.every((num) => typeof num === "number");
|
|
41
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { DisplayStyle3dProps, DisplayStyleProps } from "@itwin/core-common";
|
|
1
2
|
import type { ViewState } from "@itwin/core-frontend";
|
|
3
|
+
import type { DisplayStyle3dSettingsProps, DisplayStyleSettingsProps } from "@itwin/saved-views-client";
|
|
2
4
|
import { type ExtractionFunc } from "./extractionUtilities.js";
|
|
3
5
|
export declare const featureAppearanceMappings: ExtractionFunc<void, void>[];
|
|
4
6
|
export declare const featureAppearanceLegacyMappings: ExtractionFunc<void, void>[];
|
|
@@ -9,9 +11,6 @@ export declare const featureAppearanceLegacyMappings: ExtractionFunc<void, void>
|
|
|
9
11
|
* @param viewState
|
|
10
12
|
*/
|
|
11
13
|
export declare const extractDisplayStyle: (data: object, viewState?: ViewState) => any;
|
|
12
|
-
|
|
13
|
-
* Extracts the display style 3d from a legacy view displayStyle field
|
|
14
|
-
* And transforms it into our schema
|
|
15
|
-
* @param data
|
|
16
|
-
*/
|
|
14
|
+
export declare function extractDisplayStyle2dFromLegacy(data: DisplayStyleProps): DisplayStyleSettingsProps;
|
|
17
15
|
export declare const extractDisplayStyle3d: (data: object) => any;
|
|
16
|
+
export declare function extractDisplayStyle3dFromLegacy(data: DisplayStyle3dProps): DisplayStyle3dSettingsProps;
|
|
@@ -429,7 +429,7 @@ const displayStyle3dMapping = [
|
|
|
429
429
|
const displayStyle3dLegacyMapping = [
|
|
430
430
|
...displayStylesLegacyMapping,
|
|
431
431
|
extractObject(environmentLegacyMappings, "environment"),
|
|
432
|
-
extractObject(ambientOcclusionMappings, "
|
|
432
|
+
extractObject(ambientOcclusionMappings, "ao", "ambientOcclusion"),
|
|
433
433
|
extractObject(solarShadowMappings, "solarShadows"),
|
|
434
434
|
extractObject(lightsMappings, "lights"),
|
|
435
435
|
extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"),
|
|
@@ -460,11 +460,12 @@ export const extractDisplayStyle = (data, viewState) => {
|
|
|
460
460
|
}
|
|
461
461
|
return output;
|
|
462
462
|
};
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
463
|
+
export function extractDisplayStyle2dFromLegacy(data) {
|
|
464
|
+
const styles = data.jsonProperties?.styles;
|
|
465
|
+
const output = {};
|
|
466
|
+
applyExtraction(styles, output, displayStyle3dLegacyMapping);
|
|
467
|
+
return output;
|
|
468
|
+
}
|
|
468
469
|
export const extractDisplayStyle3d = (data) => {
|
|
469
470
|
let styles;
|
|
470
471
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -482,6 +483,12 @@ export const extractDisplayStyle3d = (data) => {
|
|
|
482
483
|
}
|
|
483
484
|
return output;
|
|
484
485
|
};
|
|
486
|
+
export function extractDisplayStyle3dFromLegacy(data) {
|
|
487
|
+
const output = {};
|
|
488
|
+
const styles = data.jsonProperties?.styles;
|
|
489
|
+
applyExtraction(styles, output, displayStyle3dLegacyMapping);
|
|
490
|
+
return output;
|
|
491
|
+
}
|
|
485
492
|
function appendAcsAndGridViewFlagsToOutput(drawingViewState,
|
|
486
493
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
487
494
|
output) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SheetViewState, type DrawingViewState, type SpatialViewState } from "@itwin/core-frontend";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SavedViewRepresentation } from "@itwin/saved-views-client";
|
|
3
3
|
import type { LegacySavedView, LegacySavedView2d } from "../SavedViewTypes.js";
|
|
4
4
|
/**
|
|
5
5
|
* Extracts id from href
|
|
@@ -12,24 +12,24 @@ export declare const extractIdFromHref: (href: string) => string | undefined;
|
|
|
12
12
|
* @param iModelViewData
|
|
13
13
|
* @returns SavedView2d
|
|
14
14
|
*/
|
|
15
|
-
export declare function savedViewItwinDrawingToLegacyDrawingView(savedViewRsp:
|
|
15
|
+
export declare function savedViewItwinDrawingToLegacyDrawingView(savedViewRsp: SavedViewRepresentation, seedDrawingViewState: DrawingViewState): LegacySavedView2d;
|
|
16
16
|
/**
|
|
17
17
|
* Transform a ViewDataITwinSheet into a legacy SavedView if possible
|
|
18
18
|
* @param savedViewRsp
|
|
19
19
|
* @param seedSheetViewState
|
|
20
20
|
* @returns SavedView2d
|
|
21
21
|
*/
|
|
22
|
-
export declare function savedViewItwinSheetToLegacySheetSavedView(savedViewRsp:
|
|
22
|
+
export declare function savedViewItwinSheetToLegacySheetSavedView(savedViewRsp: SavedViewRepresentation, seedSheetViewState: SheetViewState): LegacySavedView2d;
|
|
23
23
|
/**
|
|
24
24
|
* Transform a ViewDataItwin3d into a legacy SavedView if possible
|
|
25
25
|
* @param savedViewRsp
|
|
26
26
|
* @param seedSpatialViewState
|
|
27
27
|
* @returns SavedView
|
|
28
28
|
*/
|
|
29
|
-
export declare function savedViewITwin3dToLegacy3dSavedView(savedViewRsp:
|
|
29
|
+
export declare function savedViewITwin3dToLegacy3dSavedView(savedViewRsp: SavedViewRepresentation, seedSpatialViewState: SpatialViewState): LegacySavedView;
|
|
30
30
|
/**
|
|
31
31
|
* removes null and undefined from legacy view model selectors props models
|
|
32
32
|
* @param savedView
|
|
33
33
|
* @returns SavedViewWithData
|
|
34
34
|
*/
|
|
35
|
-
export declare const cleanLegacyViewModelSelectorPropsModels: (savedView:
|
|
35
|
+
export declare const cleanLegacyViewModelSelectorPropsModels: (savedView: SavedViewRepresentation) => SavedViewRepresentation;
|
|
@@ -258,12 +258,7 @@ export function savedViewITwin3dToLegacy3dSavedView(savedViewRsp, seedSpatialVie
|
|
|
258
258
|
appendHiddenModelsTo3dLegacySavedView(itwin3dView, legacyView);
|
|
259
259
|
return legacyView;
|
|
260
260
|
}
|
|
261
|
-
/**
|
|
262
|
-
* append Hidden Categories Or Models To Legacy Saved View
|
|
263
|
-
* @param iTwinView new schema
|
|
264
|
-
* @param legacyView
|
|
265
|
-
* @returns iModelViewData
|
|
266
|
-
*/
|
|
261
|
+
/** Append Hidden Categories Or Models To Legacy Saved View. */
|
|
267
262
|
function appendHiddenCategoriesToLegacyView(iTwinView, legacyView) {
|
|
268
263
|
if (iTwinView.categories && iTwinView.categories.disabled) {
|
|
269
264
|
legacyView.hiddenCategories = iTwinView.categories.disabled;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Viewport } from "@itwin/core-frontend";
|
|
2
|
+
import { type ViewData } from "@itwin/saved-views-client";
|
|
3
|
+
interface CaptureSavedViewDataArgs {
|
|
4
|
+
/** Viewport to capture the view from. */
|
|
5
|
+
viewport: Viewport;
|
|
6
|
+
/**
|
|
7
|
+
* Collect a list of models and categories that are currently not enabled in the {@linkcode viewport}.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
captureHiddenModelsAndCategories?: boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function captureSavedViewData(args: CaptureSavedViewDataArgs): Promise<ViewData>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { QueryRowFormat } from "@itwin/core-common";
|
|
2
|
+
import { extractClipVectorsFromLegacy } from "./api/utilities/translation/clipVectorsLegacyExtractor.js";
|
|
3
|
+
import { extractDisplayStyle2dFromLegacy, extractDisplayStyle3dFromLegacy, } from "./api/utilities/translation/displayStyleExtractor.js";
|
|
4
|
+
export async function captureSavedViewData(args) {
|
|
5
|
+
const { captureHiddenModelsAndCategories = true } = args;
|
|
6
|
+
const hiddenCategoriesPromise = captureHiddenModelsAndCategories ? getHiddenCategories(args.viewport) : undefined;
|
|
7
|
+
if (args.viewport.view.isSpatialView()) {
|
|
8
|
+
const [hiddenCategories, hiddenModels] = await Promise.all([
|
|
9
|
+
hiddenCategoriesPromise,
|
|
10
|
+
captureHiddenModelsAndCategories ? getHiddenModels(args.viewport) : undefined,
|
|
11
|
+
]);
|
|
12
|
+
return createSpatialSavedViewObject(args.viewport, hiddenCategories, hiddenModels);
|
|
13
|
+
}
|
|
14
|
+
if (args.viewport.view.isDrawingView()) {
|
|
15
|
+
return createDrawingSavedViewObject(args.viewport, await hiddenCategoriesPromise);
|
|
16
|
+
}
|
|
17
|
+
return createSheetSavedViewObject(args.viewport, await hiddenCategoriesPromise);
|
|
18
|
+
}
|
|
19
|
+
function createSpatialSavedViewObject(vp, hiddenCategories, hiddenModels) {
|
|
20
|
+
const viewState = vp.view;
|
|
21
|
+
const displayStyleProps = viewState.displayStyle.toJSON();
|
|
22
|
+
// Clear the timePoint if no schedule script is available on the viewState
|
|
23
|
+
if (viewState.is3d() && displayStyleProps.jsonProperties?.styles?.timePoint && !viewState.displayStyle.scheduleScript) {
|
|
24
|
+
displayStyleProps.jsonProperties.styles.timePoint = undefined;
|
|
25
|
+
}
|
|
26
|
+
// Omit the schedule script - may cause excessively large JSON.
|
|
27
|
+
if (displayStyleProps.jsonProperties?.styles?.scheduleScript) {
|
|
28
|
+
displayStyleProps.jsonProperties.styles.scheduleScript = undefined;
|
|
29
|
+
}
|
|
30
|
+
const viewDefinitionProps = viewState.toJSON();
|
|
31
|
+
return {
|
|
32
|
+
itwin3dView: {
|
|
33
|
+
origin: toArrayVector3d(viewDefinitionProps.origin),
|
|
34
|
+
extents: toArrayVector3d(viewDefinitionProps.extents),
|
|
35
|
+
angles: viewDefinitionProps.angles && toYawPitchRoll(viewDefinitionProps.angles),
|
|
36
|
+
camera: viewDefinitionProps.cameraOn ? {
|
|
37
|
+
lens: toDegrees(viewDefinitionProps.camera.lens) ?? 0,
|
|
38
|
+
focusDist: viewDefinitionProps.camera.focusDist,
|
|
39
|
+
eye: toArrayVector3d(viewDefinitionProps.camera.eye),
|
|
40
|
+
} : undefined,
|
|
41
|
+
categories: {
|
|
42
|
+
enabled: viewState.categorySelector.toJSON().categories,
|
|
43
|
+
disabled: hiddenCategories,
|
|
44
|
+
},
|
|
45
|
+
models: {
|
|
46
|
+
enabled: viewState.modelSelector.toJSON().models,
|
|
47
|
+
disabled: hiddenModels,
|
|
48
|
+
},
|
|
49
|
+
displayStyle: extractDisplayStyle3dFromLegacy(displayStyleProps),
|
|
50
|
+
clipVectors: extractClipVectorsFromLegacy(viewDefinitionProps),
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function toArrayVector3d(xyzProps) {
|
|
55
|
+
if (Array.isArray(xyzProps)) {
|
|
56
|
+
return [xyzProps[0] ?? 0, xyzProps[1] ?? 0, xyzProps[2] ?? 0];
|
|
57
|
+
}
|
|
58
|
+
return [xyzProps.x ?? 0, xyzProps.y ?? 0, xyzProps.z ?? 0];
|
|
59
|
+
}
|
|
60
|
+
function toYawPitchRoll(angles) {
|
|
61
|
+
return {
|
|
62
|
+
yaw: angles.yaw !== undefined ? toDegrees(angles.yaw) : undefined,
|
|
63
|
+
pitch: angles.pitch !== undefined ? toDegrees(angles.pitch) : undefined,
|
|
64
|
+
roll: angles.roll !== undefined ? toDegrees(angles.roll) : undefined,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function createDrawingSavedViewObject(vp, hiddenCategories) {
|
|
68
|
+
const viewState = vp.view;
|
|
69
|
+
const viewDefinitionProps = viewState.toJSON();
|
|
70
|
+
return {
|
|
71
|
+
itwinDrawingView: {
|
|
72
|
+
modelExtents: {},
|
|
73
|
+
baseModelId: viewDefinitionProps.baseModelId,
|
|
74
|
+
origin: toArrayVector2d(viewDefinitionProps.origin),
|
|
75
|
+
delta: toArrayVector2d(viewDefinitionProps.delta),
|
|
76
|
+
angle: toDegrees(viewDefinitionProps.angle) ?? 0,
|
|
77
|
+
displayStyle: extractDisplayStyle2dFromLegacy(viewState.displayStyle.toJSON()),
|
|
78
|
+
categories: {
|
|
79
|
+
enabled: viewState.categorySelector.toJSON().categories,
|
|
80
|
+
disabled: hiddenCategories,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function createSheetSavedViewObject(vp, hiddenCategories) {
|
|
86
|
+
const viewState = vp.view;
|
|
87
|
+
const viewDefinitionProps = viewState.toJSON();
|
|
88
|
+
return {
|
|
89
|
+
itwinSheetView: {
|
|
90
|
+
baseModelId: viewDefinitionProps.baseModelId,
|
|
91
|
+
origin: toArrayVector2d(viewDefinitionProps.origin),
|
|
92
|
+
delta: toArrayVector2d(viewDefinitionProps.delta),
|
|
93
|
+
angle: toDegrees(viewDefinitionProps.angle) ?? 0,
|
|
94
|
+
displayStyle: extractDisplayStyle2dFromLegacy(viewState.displayStyle.toJSON()),
|
|
95
|
+
categories: {
|
|
96
|
+
enabled: viewState.categorySelector.toJSON().categories,
|
|
97
|
+
disabled: hiddenCategories,
|
|
98
|
+
},
|
|
99
|
+
width: viewState.sheetSize.x,
|
|
100
|
+
height: viewState.sheetSize.y,
|
|
101
|
+
sheetAttachments: viewState.attachmentIds,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function toArrayVector2d(xyzProps) {
|
|
106
|
+
if (Array.isArray(xyzProps)) {
|
|
107
|
+
return [xyzProps[0] ?? 0, xyzProps[1] ?? 0];
|
|
108
|
+
}
|
|
109
|
+
return [xyzProps.x ?? 0, xyzProps.y ?? 0];
|
|
110
|
+
}
|
|
111
|
+
function toDegrees(angle) {
|
|
112
|
+
if (typeof angle === "number") {
|
|
113
|
+
return angle;
|
|
114
|
+
}
|
|
115
|
+
if ("degrees" in angle) {
|
|
116
|
+
return angle.degrees;
|
|
117
|
+
}
|
|
118
|
+
if ("radians" in angle) {
|
|
119
|
+
return angle.radians * (180 / Math.PI);
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
async function getHiddenModels(vp) {
|
|
124
|
+
const allModels = await getAllModels(vp.iModel);
|
|
125
|
+
const visibleModels = new Set(vp.view.modelSelector.toJSON().models);
|
|
126
|
+
return allModels.map(({ id }) => id).filter((model) => !visibleModels.has(model));
|
|
127
|
+
}
|
|
128
|
+
async function getAllModels(iModel) {
|
|
129
|
+
// Note: IsNotSpatiallyLocated was introduced in a later version of the BisCore ECSchema. If the iModel has an earlier
|
|
130
|
+
// version, the statement will throw because the property does not exist. If the iModel was created from an earlier
|
|
131
|
+
// version and later upgraded to a newer version, the property may be NULL for models created prior to the upgrade.
|
|
132
|
+
try {
|
|
133
|
+
return await executeQuery(iModel, "SELECT ECInstanceId FROM Bis.GeometricModel3D WHERE IsPrivate = false AND IsTemplate = false AND (IsNotSpatiallyLocated IS NULL OR IsNotSpatiallyLocated = false)");
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return executeQuery(iModel, "SELECT ECInstanceId FROM Bis.GeometricModel3D WHERE IsPrivate = false AND IsTemplate = false");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function getHiddenCategories(vp) {
|
|
140
|
+
const visibleCategories = new Set(vp.view.categorySelector.toJSON().categories);
|
|
141
|
+
const allCategories = await getAllCategories(vp.iModel);
|
|
142
|
+
return allCategories.map(({ id }) => id).filter((category) => !visibleCategories.has(category));
|
|
143
|
+
}
|
|
144
|
+
async function getAllCategories(iModel) {
|
|
145
|
+
return executeQuery(iModel, "SELECT DISTINCT Category.Id AS id FROM BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId FROM BisCore.SpatialCategory)");
|
|
146
|
+
}
|
|
147
|
+
async function executeQuery(iModel, query) {
|
|
148
|
+
return iModel.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();
|
|
149
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Viewport } from "@itwin/core-frontend";
|
|
2
|
+
/** Generates Saved View thumbnail based on what is currently visible in the {@linkcode viewport}. */
|
|
3
|
+
export declare function captureSavedViewThumbnail(viewport: Viewport, width?: number, height?: number): string | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getCenteredViewRect, imageBufferToCanvas } from "@itwin/core-frontend";
|
|
2
|
+
import { Point2d } from "@itwin/core-geometry";
|
|
3
|
+
/** Generates Saved View thumbnail based on what is currently visible in the {@linkcode viewport}. */
|
|
4
|
+
export function captureSavedViewThumbnail(viewport, width = 280, height = 200) {
|
|
5
|
+
const thumbnail = getThumbnail(viewport, width, height);
|
|
6
|
+
if (!thumbnail) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const canvas = imageBufferToCanvas(thumbnail);
|
|
10
|
+
return canvas?.toDataURL("image/png", 1.0);
|
|
11
|
+
}
|
|
12
|
+
function getThumbnail(vp, width, height) {
|
|
13
|
+
const size = new Point2d(width, height);
|
|
14
|
+
// Passing in vp.target.viewRect instead of vp.viewRect because currently vp.viewRect is not updated correctly in some
|
|
15
|
+
// cases when a new dialog is created. The bottom property would be 2px higher than the renderRect in readImageBuffer
|
|
16
|
+
// which caused the method to return undefined. vp.target.viewRect allows us to have the correct dimensions when
|
|
17
|
+
// creating the thumbnail.
|
|
18
|
+
const thumbnail = vp.readImageBuffer({ rect: getCenteredViewRect(vp.target.viewRect), size });
|
|
19
|
+
if (thumbnail) {
|
|
20
|
+
return thumbnail;
|
|
21
|
+
}
|
|
22
|
+
// Since using vp.target.viewRect while creating thumbnail returns undefined for some, we switch back to using
|
|
23
|
+
// vp.viewRect
|
|
24
|
+
return vp.readImageBuffer({ rect: getCenteredViewRect(vp.viewRect), size });
|
|
25
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,5 +8,7 @@ export type { SavedViewInfo, SavedViewsClient } from "./SavedViewsClient/SavedVi
|
|
|
8
8
|
export { SavedViewsContextProvider, type SavedViewsContext } from "./SavedViewsContext.js";
|
|
9
9
|
export { StickyExpandableBlock } from "./StickyExpandableBlock/StickyExpandableBlock.js";
|
|
10
10
|
export { TileGrid } from "./TileGrid/TileGrid.js";
|
|
11
|
+
export { captureSavedViewData } from "./captureSavedViewData.js";
|
|
12
|
+
export { captureSavedViewThumbnail } from "./captureSavedViewThumbnail.js";
|
|
11
13
|
export { defaultLocalization, type LocalizationStrings } from "./localization.js";
|
|
12
14
|
export { useSavedViews, type SavedViewActions } from "./useSavedViews.js";
|
package/lib/index.js
CHANGED
|
@@ -10,5 +10,7 @@ export { ITwinSavedViewsClient } from "./SavedViewsClient/ITwinSavedViewsClient.
|
|
|
10
10
|
export { SavedViewsContextProvider } from "./SavedViewsContext.js";
|
|
11
11
|
export { StickyExpandableBlock } from "./StickyExpandableBlock/StickyExpandableBlock.js";
|
|
12
12
|
export { TileGrid } from "./TileGrid/TileGrid.js";
|
|
13
|
+
export { captureSavedViewData } from "./captureSavedViewData.js";
|
|
14
|
+
export { captureSavedViewThumbnail } from "./captureSavedViewThumbnail.js";
|
|
13
15
|
export { defaultLocalization } from "./localization.js";
|
|
14
16
|
export { useSavedViews } from "./useSavedViews.js";
|
package/lib/useSavedViews.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface UseSavedViewsResult {
|
|
|
25
25
|
actions: SavedViewActions;
|
|
26
26
|
}
|
|
27
27
|
export interface SavedViewActions {
|
|
28
|
-
createSavedView: (savedViewName: string, savedViewData: ViewData) =>
|
|
28
|
+
createSavedView: (savedViewName: string, savedViewData: ViewData) => Promise<string>;
|
|
29
29
|
renameSavedView: (savedViewId: string, newName: string) => void;
|
|
30
30
|
shareSavedView: (savedViewId: string, share: boolean) => void;
|
|
31
31
|
deleteSavedView: (savedViewId: string) => void;
|
|
@@ -38,6 +38,7 @@ export interface SavedViewActions {
|
|
|
38
38
|
addTag: (savedViewId: string, tagId: string) => void;
|
|
39
39
|
addNewTag: (savedViewId: string, tagName: string) => void;
|
|
40
40
|
removeTag: (savedViewId: string, tagId: string) => void;
|
|
41
|
+
uploadThumbnail: (savedViewId: string, imageDataUrl: string) => void;
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Pulls Saved View data from a store and provides means to update and synchronize the data back to it. Interaction with
|
package/lib/useSavedViews.js
CHANGED
|
@@ -130,6 +130,7 @@ function createSavedViewActions(iTwinId, iModelId, client, setState, ref, onUpda
|
|
|
130
130
|
signal,
|
|
131
131
|
});
|
|
132
132
|
updateSavedViews((savedViews) => savedViews.set(savedView.id, savedView));
|
|
133
|
+
return savedView.id;
|
|
133
134
|
}),
|
|
134
135
|
renameSavedView: actionWrapper(async (savedViewId, newName) => {
|
|
135
136
|
let prevName;
|
|
@@ -395,43 +396,66 @@ function createSavedViewActions(iTwinId, iModelId, client, setState, ref, onUpda
|
|
|
395
396
|
throw error;
|
|
396
397
|
}
|
|
397
398
|
}),
|
|
399
|
+
uploadThumbnail: actionWrapper(async (savedViewId, imageDataUrl) => {
|
|
400
|
+
let prevThumnbnail;
|
|
401
|
+
updateSavedView(savedViewId, (savedView) => {
|
|
402
|
+
prevThumnbnail = savedView.thumbnail;
|
|
403
|
+
savedView.thumbnail = imageDataUrl;
|
|
404
|
+
});
|
|
405
|
+
try {
|
|
406
|
+
await client.uploadThumbnail({ savedViewId, image: imageDataUrl, signal });
|
|
407
|
+
}
|
|
408
|
+
catch (error) {
|
|
409
|
+
if (prevThumnbnail !== undefined) {
|
|
410
|
+
const restoredDisplayName = prevThumnbnail;
|
|
411
|
+
updateSavedView(savedViewId, (savedView) => {
|
|
412
|
+
savedView.thumbnail = restoredDisplayName;
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
throw error;
|
|
416
|
+
}
|
|
417
|
+
}),
|
|
398
418
|
};
|
|
399
|
-
/**
|
|
419
|
+
/**
|
|
420
|
+
* Serializes action execution and notifies when action processing begins and ends. Continues to execute actions
|
|
421
|
+
* after cancellation.
|
|
422
|
+
*/
|
|
400
423
|
function actionWrapper(callback) {
|
|
401
424
|
return async (...args) => {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
catch (error) {
|
|
410
|
-
if (error && typeof error === "object" && "name" in error && error.name === "AbortError") {
|
|
411
|
-
// It's a cancellation error
|
|
425
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
426
|
+
return new Promise(async (resolve, reject) => {
|
|
427
|
+
ref.current.actionQueue.push(async () => {
|
|
428
|
+
if (signal.aborted) {
|
|
429
|
+
reject(signal.reason);
|
|
430
|
+
return;
|
|
412
431
|
}
|
|
413
|
-
else {
|
|
414
|
-
throw error;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
// If there are no other queued actions, start executing the queue
|
|
419
|
-
if (ref.current.actionQueue.length === 1) {
|
|
420
|
-
onUpdateInProgress();
|
|
421
|
-
// By the time the first action completes, other actions may have been queued
|
|
422
|
-
while (ref.current.actionQueue.length > 0) {
|
|
423
432
|
try {
|
|
424
|
-
await
|
|
433
|
+
resolve(await callback(...args));
|
|
425
434
|
}
|
|
426
435
|
catch (error) {
|
|
427
|
-
|
|
436
|
+
reject(error);
|
|
437
|
+
if (error && typeof error === "object" && "name" in error && error.name === "AbortError") {
|
|
438
|
+
// It's a cancellation error, no need to report it
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
try {
|
|
442
|
+
onUpdateError(error);
|
|
443
|
+
}
|
|
444
|
+
catch { }
|
|
445
|
+
}
|
|
428
446
|
}
|
|
429
|
-
|
|
447
|
+
});
|
|
448
|
+
// If there are no other queued actions, start executing the queue
|
|
449
|
+
if (ref.current.actionQueue.length === 1) {
|
|
450
|
+
onUpdateInProgress();
|
|
451
|
+
// By the time the first action completes, other actions may have been queued
|
|
452
|
+
while (ref.current.actionQueue.length > 0) {
|
|
453
|
+
await ref.current.actionQueue[0]();
|
|
430
454
|
ref.current.actionQueue.shift();
|
|
431
455
|
}
|
|
456
|
+
onUpdateComplete();
|
|
432
457
|
}
|
|
433
|
-
|
|
434
|
-
}
|
|
458
|
+
});
|
|
435
459
|
};
|
|
436
460
|
}
|
|
437
461
|
function updateSavedViews(callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/saved-views-react",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "https://www.bentley.com"
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
|
+
"types": "./lib/index.d.ts",
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|
|
18
19
|
"types": "./lib/index.d.ts",
|
|
@@ -45,13 +46,14 @@
|
|
|
45
46
|
"react": "^17.0.0",
|
|
46
47
|
"react-dom": "^17.0.0",
|
|
47
48
|
"recursive-readdir": "^2.2.3",
|
|
48
|
-
"typescript": "^5.
|
|
49
|
-
"vite": "^5.0.
|
|
50
|
-
"vitest": "^1.0
|
|
49
|
+
"typescript": "^5.3.3",
|
|
50
|
+
"vite": "^5.0.13",
|
|
51
|
+
"vitest": "^1.4.0"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
54
|
"@itwin/core-common": "^4.0.6",
|
|
54
55
|
"@itwin/core-frontend": "^4.0.6",
|
|
56
|
+
"@itwin/core-geometry": "^4.0.6",
|
|
55
57
|
"react": "^17.0.0 || ^18.0.0",
|
|
56
58
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
57
59
|
},
|
|
@@ -59,7 +61,7 @@
|
|
|
59
61
|
"@itwin/itwinui-icons-react": "^2.4.0",
|
|
60
62
|
"@itwin/itwinui-react": "^3.0.11",
|
|
61
63
|
"fuse.js": "^6.6.2",
|
|
62
|
-
"@itwin/saved-views-client": "0.
|
|
64
|
+
"@itwin/saved-views-client": "0.2.0"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"build": "run-p build:*",
|