@itwin/saved-views-react 0.5.0 → 0.7.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.
Files changed (40) hide show
  1. package/README.md +38 -4
  2. package/lib/SavedView.d.ts +41 -11
  3. package/lib/SavedViewTile/SavedViewOptions.js +10 -10
  4. package/lib/SavedViewTile/SavedViewTile.css +8 -1
  5. package/lib/SavedViewTile/SavedViewTile.d.ts +4 -3
  6. package/lib/SavedViewTile/SavedViewTile.js +5 -9
  7. package/lib/SavedViewTile/SavedViewTileContext.d.ts +0 -1
  8. package/lib/SavedViewTile/SavedViewTileContext.js +1 -1
  9. package/lib/SavedViewsClient/ITwinSavedViewsClient.d.ts +21 -23
  10. package/lib/SavedViewsClient/ITwinSavedViewsClient.js +120 -57
  11. package/lib/SavedViewsClient/SavedViewsClient.d.ts +68 -45
  12. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTile.js +2 -3
  13. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTileContext.d.ts +0 -1
  14. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTileContext.js +1 -1
  15. package/lib/SavedViewsWidget/SavedViewsExpandableBlockWidget.d.ts +5 -3
  16. package/lib/SavedViewsWidget/SavedViewsExpandableBlockWidget.js +3 -3
  17. package/lib/SavedViewsWidget/SavedViewsFolderWidget.d.ts +5 -4
  18. package/lib/SavedViewsWidget/SavedViewsFolderWidget.js +7 -7
  19. package/lib/applySavedView.d.ts +36 -31
  20. package/lib/applySavedView.js +61 -26
  21. package/lib/captureSavedViewData.d.ts +31 -5
  22. package/lib/captureSavedViewData.js +103 -63
  23. package/lib/captureSavedViewThumbnail.d.ts +8 -1
  24. package/lib/captureSavedViewThumbnail.js +15 -7
  25. package/lib/createViewState.d.ts +22 -5
  26. package/lib/createViewState.js +28 -25
  27. package/lib/index.d.ts +10 -10
  28. package/lib/index.js +7 -7
  29. package/lib/translation/SavedViewTypes.d.ts +1 -1
  30. package/lib/translation/SavedViewsExtensionHandlers.d.ts +3 -0
  31. package/lib/translation/SavedViewsExtensionHandlers.js +14 -0
  32. package/lib/translation/clipVectorsLegacyExtractor.js +4 -0
  33. package/lib/translation/displayStyleExtractor.js +80 -3
  34. package/lib/translation/extractionUtilities.d.ts +9 -1
  35. package/lib/translation/extractionUtilities.js +16 -0
  36. package/lib/useSavedViews.d.ts +172 -34
  37. package/lib/useSavedViews.js +475 -503
  38. package/lib/utils.d.ts +8 -0
  39. package/lib/utils.js +13 -0
  40. package/package.json +9 -9
@@ -1,4 +1,4 @@
1
- import { applyExtraction, extractArray, extractArrayConditionally, extractBoolean, extractColor, extractColorLegacy, extractConditionally, extractNumber, extractNumberOrBool, extractObject, extractPlainTypedMap, extractRGB, extractSimpleArray, extractString, extractStringOrArray, extractStringOrNumber, extractStringOrNumberArray, isAnyColorFormat, simpleTypeOf, } from "./extractionUtilities.js";
1
+ import { applyExtraction, extractArray, extractArrayConditionally, extractBoolean, extractColor, extractColorLegacy, extractConditionally, extractLinePixels, extractNumber, extractNumberOrBool, extractObject, extractPlainTypedMap, extractRGB, extractSimpleArray, extractString, extractStringOrArray, extractStringOrNumber, extractStringOrNumberArray, isAnyColorFormat, simpleTypeOf, } from "./extractionUtilities.js";
2
2
  const viewFlagMappings = [
3
3
  extractNumber("renderMode"),
4
4
  extractBoolean("noConstructions", "noConstruct"),
@@ -14,9 +14,18 @@ const viewFlagMappings = [
14
14
  extractBoolean("hiddenEdges", "hidEdges"),
15
15
  extractBoolean("shadows"),
16
16
  extractBoolean("clipVolume", "clipVol"),
17
+ extractBoolean("hiddenLineMaterialColors", "hlMatColors"),
17
18
  extractBoolean("monochrome"),
18
19
  extractBoolean("backgroundMap"),
19
20
  extractBoolean("ambientOcclusion"),
21
+ extractBoolean("acs"),
22
+ extractBoolean("thematicDisplay"),
23
+ extractBoolean("wiremesh"),
24
+ extractBoolean("forceSurfaceDiscard"),
25
+ extractBoolean("noWhiteOnWhiteReversal"),
26
+ extractBoolean("noSolarLight"),
27
+ extractBoolean("noSourceLights"),
28
+ extractBoolean("noCameraLights"),
20
29
  ];
21
30
  const viewFlagLegacyMappings = [
22
31
  extractNumber("renderMode"),
@@ -33,9 +42,18 @@ const viewFlagLegacyMappings = [
33
42
  extractBoolean("hidEdges", "hiddenEdges"),
34
43
  extractBoolean("shadows"),
35
44
  extractBoolean("clipVol", "clipVolume"),
45
+ extractBoolean("hlMatColors", "hiddenLineMaterialColors"),
36
46
  extractBoolean("monochrome"),
37
47
  extractBoolean("backgroundMap"),
38
48
  extractBoolean("ambientOcclusion"),
49
+ extractBoolean("acs"),
50
+ extractBoolean("thematicDisplay"),
51
+ extractBoolean("wiremesh"),
52
+ extractBoolean("forceSurfaceDiscard"),
53
+ extractBoolean("noWhiteOnWhiteReversal"),
54
+ extractBoolean("noSolarLight"),
55
+ extractBoolean("noSourceLights"),
56
+ extractBoolean("noCameraLights"),
39
57
  ];
40
58
  const planarClipMaskMappings = [
41
59
  extractNumber("mode"),
@@ -93,7 +111,7 @@ export const featureAppearanceMappings = [
93
111
  extractRGB("rgb"),
94
112
  extractNumber("weight"),
95
113
  extractNumber("transparency"),
96
- extractNumber("linePixels"),
114
+ extractLinePixels("linePixels"),
97
115
  extractBoolean("ignoresMaterial"),
98
116
  extractBoolean("nonLocatable"),
99
117
  extractBoolean("emphasized"),
@@ -102,7 +120,7 @@ export const featureAppearanceLegacyMappings = [
102
120
  extractColorLegacy("rgb"),
103
121
  extractNumber("weight"),
104
122
  extractNumber("transparency"),
105
- extractNumber("linePixels"),
123
+ extractLinePixels("linePixels"),
106
124
  extractBoolean("ignoresMaterial"),
107
125
  extractBoolean("nonLocatable"),
108
126
  extractBoolean("emphasized"),
@@ -284,6 +302,56 @@ const hiddenLineSettingsLegacyMappings = [
284
302
  extractObject(hiddenLineStyleLegacyMappings, "hidden"),
285
303
  extractNumber("transThreshold", "transparencyThreshold"),
286
304
  ];
305
+ const keyColorPropsMappings = [
306
+ extractNumber("value"),
307
+ extractColor("color"),
308
+ ];
309
+ const keyColorPropsLegacyMappings = [
310
+ extractNumber("value"),
311
+ extractColorLegacy("color"),
312
+ ];
313
+ const thematicGradientSettingsPropsMappings = [
314
+ extractNumber("mode"),
315
+ extractNumber("stepCount"),
316
+ extractColor("marginColor"),
317
+ extractNumber("colorScheme"),
318
+ extractArray(keyColorPropsMappings, "customKeys"),
319
+ extractNumber("colorMix"),
320
+ extractNumber("transparencyMode"),
321
+ ];
322
+ const thematicGradientSettingsPropsLegacyMappings = [
323
+ extractNumber("mode"),
324
+ extractNumber("stepCount"),
325
+ extractColorLegacy("marginColor"),
326
+ extractNumber("colorScheme"),
327
+ extractArray(keyColorPropsLegacyMappings, "customKeys"),
328
+ extractNumber("colorMix"),
329
+ extractNumber("transparencyMode"),
330
+ ];
331
+ const thematicDisplaySensorPropsMappings = [
332
+ extractSimpleArray(simpleTypeOf("number"), "position"),
333
+ extractNumber("value"),
334
+ ];
335
+ const thematicDisplaySensorSettingsPropsMappings = [
336
+ extractArray(thematicDisplaySensorPropsMappings, "sensors"),
337
+ extractNumber("distanceCutoff"),
338
+ ];
339
+ const thematicDisplaySettingsMappings = [
340
+ extractNumber("displayMode"),
341
+ extractObject(thematicGradientSettingsPropsMappings, "gradientSettings"),
342
+ extractSimpleArray(simpleTypeOf("number"), "range"),
343
+ extractSimpleArray(simpleTypeOf("number"), "axis"),
344
+ extractSimpleArray(simpleTypeOf("number"), "sunDirection"),
345
+ extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"),
346
+ ];
347
+ const thematicDisplaySettingsLegacyMappings = [
348
+ extractNumber("displayMode"),
349
+ extractObject(thematicGradientSettingsPropsLegacyMappings, "gradientSettings"),
350
+ extractSimpleArray(simpleTypeOf("number"), "range"),
351
+ extractSimpleArray(simpleTypeOf("number"), "axis"),
352
+ extractSimpleArray(simpleTypeOf("number"), "sunDirection"),
353
+ extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"),
354
+ ];
287
355
  const cutStyleMappings = [
288
356
  extractObject(viewFlagOverridesMapping, "viewflags"),
289
357
  extractObject(hiddenLineSettingsMappings, "hiddenLine"),
@@ -475,6 +543,8 @@ const displayStyle3dMapping = [
475
543
  extractObject(solarShadowMappings, "solarShadows"),
476
544
  extractObject(lightsMappings, "lights"),
477
545
  extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"),
546
+ extractObject(thematicDisplaySettingsMappings, "thematic"),
547
+ extractObject(hiddenLineSettingsMappings, "hiddenLine", "hline"),
478
548
  ];
479
549
  const displayStyle3dLegacyMapping = [
480
550
  ...displayStylesLegacyMapping,
@@ -483,6 +553,8 @@ const displayStyle3dLegacyMapping = [
483
553
  extractObject(solarShadowLegacyMappings, "solarShadows"),
484
554
  extractObject(lightsLegacyMappings, "lights"),
485
555
  extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"),
556
+ extractObject(thematicDisplaySettingsLegacyMappings, "thematic"),
557
+ extractObject(hiddenLineSettingsLegacyMappings, "hline", "hiddenLine"),
486
558
  ];
487
559
  /**
488
560
  * Extracts the display style from a legacy view displayStyle field
@@ -528,6 +600,11 @@ export const extractDisplayStyle3d = (data) => {
528
600
  styles = data.displayStyleProps.jsonProperties?.styles;
529
601
  applyExtraction(styles, output, displayStyle3dLegacyMapping);
530
602
  }
603
+ const range = output?.thematic?.range;
604
+ if (range && Array.isArray(range) && range.length === 0) {
605
+ // Range is optional, so delete it if it's empty
606
+ output.thematic.range = undefined;
607
+ }
531
608
  if (styles === undefined) {
532
609
  return undefined;
533
610
  }
@@ -38,7 +38,7 @@ export declare const transformRGB: (value: unknown) => Rgba | undefined;
38
38
  * @param transform Transform function of the value to be put in the output
39
39
  * @returns Function that does the extraction
40
40
  */
41
- export declare const createExtractionFunc: (from: string, to: string, typeCheck?: ((value: unknown) => boolean) | undefined, transform?: ((value: unknown) => unknown) | undefined) => (input: any, output: any) => void;
41
+ export declare const createExtractionFunc: (from: string, to: string, typeCheck?: (value: unknown) => boolean, transform?: (value: unknown) => unknown) => (input: any, output: any) => void;
42
42
  /** Type for a extraction function generator */
43
43
  export type ExtractionFunc<InputType, OutputType> = (input: InputType, output: OutputType) => OutputType;
44
44
  /** Type for a function that creates a extraction function */
@@ -51,6 +51,14 @@ export type ExtractionFuncCreator = (from: string, to: string) => ExtractionFunc
51
51
  * @returns Function that extracts a number value and type checks it
52
52
  */
53
53
  export declare const extractNumber: (from: string, to?: string) => ExtractionFunc<void, void>;
54
+ /**
55
+ * Creates a extraction function that will extract a number from the given accessor, transform it into a LinePixels enum, and put it
56
+ * in the given accessor if provided
57
+ * @param from Accessor that will be used on input to access value
58
+ * @param to Accessor that will be used to stored the value in the output object
59
+ * @returns Function that extracts a number value and type checks it
60
+ */
61
+ export declare const extractLinePixels: (from: string, to?: string) => ExtractionFunc<void, void>;
54
62
  /**
55
63
  * Creates a extraction function that will extract a boolean from the given accessor and put it
56
64
  * in the given accessor if provided
@@ -3,6 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { ColorDef } from "@itwin/core-common";
6
+ import { LinePixels } from "@itwin/saved-views-client";
6
7
  /**
7
8
  * Returns a function that does a simple typeof check on a value
8
9
  * @param typeOfString String to compare against
@@ -231,6 +232,21 @@ export const createExtractionFunc = (from, to, typeCheck, transform) => {
231
232
  export const extractNumber = (from, to) => {
232
233
  return createExtractionFunc(from, to ?? from, simpleTypeOf("number"));
233
234
  };
235
+ /**
236
+ * Creates a extraction function that will extract a number from the given accessor, transform it into a LinePixels enum, and put it
237
+ * in the given accessor if provided
238
+ * @param from Accessor that will be used on input to access value
239
+ * @param to Accessor that will be used to stored the value in the output object
240
+ * @returns Function that extracts a number value and type checks it
241
+ */
242
+ export const extractLinePixels = (from, to) => {
243
+ return createExtractionFunc(from, to ?? from, simpleTypeOf("number"), (value) => {
244
+ if (typeof value !== "number" ||
245
+ !Object.keys(LinePixels).includes(value.toString()))
246
+ return LinePixels.Invalid;
247
+ return value;
248
+ });
249
+ };
234
250
  /**
235
251
  * Creates a extraction function that will extract a boolean from the given accessor and put it
236
252
  * in the given accessor if provided
@@ -1,53 +1,191 @@
1
- import type { ViewData } from "@itwin/saved-views-client";
2
- import type { SavedView, SavedViewGroup, SavedViewTag } from "./SavedView.js";
1
+ import { type ReactNode, type SetStateAction } from "react";
2
+ import type { SavedView, SavedViewData, SavedViewGroup, SavedViewTag, WriteableSavedViewProperties } from "./SavedView.js";
3
3
  import type { SavedViewsClient } from "./SavedViewsClient/SavedViewsClient.js";
4
- interface UseSavedViewsParams {
4
+ import { type AllOrNone } from "./utils.js";
5
+ type UseSavedViewsArgs = {
5
6
  /** iTwin identifier. */
6
7
  iTwinId: string;
7
8
  /** iModel identifier. */
8
9
  iModelId: string;
9
10
  /** Implements communication with Saved Views store. */
10
11
  client: SavedViewsClient;
12
+ } & AllOrNone<ExternalState>;
13
+ interface ExternalState {
11
14
  /**
12
- * Invoked when any of {@linkcode SavedViewActions} is triggered. Does not get called again until either
13
- * {@linkcode onUpdateComplete} or {@linkcode onUpdateError} is invoked.
15
+ * Current immutable value of Saved Views store. If provided, it is returned as
16
+ * {@linkcode UseSavedViewsResult.store}; otherwise an internal store is used.
17
+ *
18
+ * @example
19
+ * const [state, setState] = useState(useSavedViews.emptyState);
20
+ * const { store } = useSavedViews({ iTwinId, iModelId, client, state, setState });
21
+ * console.log(store === state); // true
14
22
  */
15
- onUpdateInProgress?: (() => void) | undefined;
16
- /** Invoked once after {@linkcode onUpdateInProgress} when the data is successfully synchronised with the store. */
17
- onUpdateComplete?: (() => void) | undefined;
18
- /** Invoked once after {@linkcode onUpdateInProgress} when data synchronisation with the store fails. */
19
- onUpdateError?: ((error: unknown) => void) | undefined;
23
+ state: SavedViewsState;
24
+ /**
25
+ * Function which updates Saved Views store. It should behave the same as `setState` callback
26
+ * that is returned by `React.useState`.
27
+ *
28
+ * @remarks
29
+ * When hook arguments change, the state is not cleared automatically.
30
+ *
31
+ * @example
32
+ * const [state, setState] = useState(useSavedViews.emptyState);
33
+ * const savedViews = useSavedViews({ iTwinId, iModelId, client, state, setState });
34
+ */
35
+ setState: (action: SetStateAction<SavedViewsState>) => void;
20
36
  }
21
- interface UseSavedViewsResult {
37
+ export interface SavedViewsState {
38
+ /** Maps `savedViewId` to {@link SavedView}. */
22
39
  savedViews: Map<string, SavedView>;
40
+ /** Maps `savedViewId` to {@link SavedViewData}. */
41
+ savedViewData: Map<string, SavedViewData>;
42
+ /** Maps `groupId` to {@link SavedViewGroup}. */
23
43
  groups: Map<string, SavedViewGroup>;
44
+ /** Maps `tagId` to {@link SavedViewTag}. */
24
45
  tags: Map<string, SavedViewTag>;
25
- actions: SavedViewActions;
46
+ /** Maps `savedViewId` to {@link ReactNode} representing Saved View thumbnail. */
47
+ thumbnails: Map<string, ReactNode>;
26
48
  }
27
- export interface SavedViewActions {
28
- submitSavedView: (savedView: string | Partial<SavedView> & Pick<SavedView, "displayName">, savedViewData: ViewData) => Promise<string>;
29
- renameSavedView: (savedViewId: string, newName: string | undefined) => void;
30
- shareSavedView: (savedViewId: string, share: boolean) => void;
31
- deleteSavedView: (savedViewId: string) => void;
32
- createGroup: (groupName: string) => void;
33
- renameGroup: (groupId: string, newName: string) => void;
34
- shareGroup: (groupId: string, share: boolean) => void;
35
- moveToGroup: (savedViewId: string, groupId: string) => void;
36
- moveToNewGroup: (savedViewId: string, groupName: string) => void;
37
- deleteGroup: (groupId: string) => void;
38
- addTag: (savedViewId: string, tagId: string) => void;
39
- addNewTag: (savedViewId: string, tagName: string) => void;
40
- removeTag: (savedViewId: string, tagId: string) => void;
41
- uploadThumbnail: (savedViewId: string, imageDataUrl: string) => void;
49
+ interface UseSavedViewsResult extends SavedViewsActions {
50
+ /**
51
+ * Immutable state which holds Saved Views data. If {@linkcode UseSavedViewsArgs.state} is not
52
+ * specified, an internal state is returned; otherwise its value is the same as the provided
53
+ * `state` argument.
54
+ */
55
+ store: SavedViewsState;
56
+ /**
57
+ * When invoked, {@link SavedViewsClient} is queried for all available Saved Views, Groups, and
58
+ * Tags. When the operation ends, all obtained entities are inserted into Saved Views store.
59
+ *
60
+ * @param callback Optional callback that is invoked when the operation ends. If an error occurs,
61
+ * the operation gets cancelled and the error object is passed as the argument.
62
+ * @returns Callback that cancels the operation.
63
+ *
64
+ * @example
65
+ * const { startLoadingData } = useSavedViews({ iTwinId, iModelId, client });
66
+ * const [isLoading, setIsLoading] = useState(true);
67
+ * useEffect(
68
+ * () => {
69
+ * return startLoadingData((error) => {
70
+ * setIsLoading(false);
71
+ * if (error) {
72
+ * console.error(error);
73
+ * }
74
+ * });
75
+ * },
76
+ * [],
77
+ * );
78
+ */
79
+ startLoadingData: (callback?: (error?: unknown) => void) => () => void;
80
+ }
81
+ export interface SavedViewsActions {
82
+ /**
83
+ * Creates a new {@link SavedView} entity using {@link SavedViewsClient} and stores the result in
84
+ * Saved Views store.
85
+ * @returns Identifier of the newly created Saved View.
86
+ */
87
+ createSavedView: (savedView: WriteableSavedViewProperties, savedViewData: SavedViewData) => Promise<string>;
88
+ /**
89
+ * Retrieves {@link SavedViewData} associated with given {@linkcode savedViewId} from the Saved
90
+ * Views store if the data is present; otherwise it is queried from {@link SavedViewsClient} and the
91
+ * store is updated to include the new data.
92
+ */
93
+ lookupSavedViewData: (savedViewId: string) => Promise<SavedViewData>;
94
+ /**
95
+ * Uses {@link SavedViewsClient} to update {@link SavedView} entity. On success, updates
96
+ * {@link SavedView} in Saved Views store with provided values.
97
+ */
98
+ updateSavedView: (savedViewId: string, savedView: Partial<WriteableSavedViewProperties>, savedViewData?: SavedViewData | undefined) => Promise<void>;
99
+ /**
100
+ * Uses {@link SavedViewsClient} to update {@link SavedView} entity associated with given {@linkcode savedViewId}.
101
+ * On success, updates {@link SavedView} in Saved Views store with provided name.
102
+ */
103
+ renameSavedView: (savedViewId: string, newName: string) => Promise<void>;
104
+ /**
105
+ * Uses {@link SavedViewsClient} to mark {@link SavedView} entity as shared or unshared. On
106
+ * success, updates {@link SavedView} in Saved Views store with provided status.
107
+ */
108
+ shareSavedView: (savedViewId: string, shared: boolean) => Promise<void>;
109
+ /**
110
+ * Uses {@link SavedViewsClient} to delete {@link SavedView} entity. On success, removes
111
+ * {@link SavedView} from Saved Views store.
112
+ */
113
+ deleteSavedView: (savedViewId: string) => Promise<void>;
114
+ /**
115
+ * Creates a new {@link SavedViewGroup} entity using {@link SavedViewsClient} and stores the
116
+ * result in Saved Views store.
117
+ * @returns Identifier of the newly created Saved View Group.
118
+ */
119
+ createGroup: (groupName: string) => Promise<string>;
120
+ /**
121
+ * Uses {@link SavedViewsClient} to update {@link SavedViewGroup} entity. On success, updates
122
+ * {@link SavedViewGroup} in Saved Views store with provided name.
123
+ */
124
+ renameGroup: (groupId: string, newName: string) => Promise<void>;
125
+ /**
126
+ * Uses {@link SavedViewsClient} to mark {@link SavedViewGroup} entity as shared or unshared. On
127
+ * success, updates {@link SavedViewGroup} in Saved Views store with provided status.
128
+ */
129
+ shareGroup: (groupId: string, shared: boolean) => Promise<void>;
130
+ /**
131
+ * Uses {@link SavedViewsClient} to move {@link SavedView} entity to the specified Saved View group.
132
+ */
133
+ moveToGroup: (savedViewId: string, groupId: string | undefined) => Promise<void>;
134
+ /**
135
+ * Uses {@link SavedViewsClient} to delete {@link SavedViewGroup} entity. On success, removes
136
+ * {@link SavedViewGroup} from Saved Views store.
137
+ */
138
+ deleteGroup: (groupId: string) => Promise<void>;
139
+ /**
140
+ * Creates a new {@link SavedViewTag} entity using {@link SavedViewsClient} and stores the result
141
+ * in Saved Views store.
142
+ * @returns Identifier of the newly created Saved View Tag.
143
+ */
144
+ createTag: (tagName: string) => Promise<string>;
145
+ /** Uses {@link SavedViewsClient} to add {@link SavedViewTag} to {@link SavedView} entity. */
146
+ addTag: (savedViewId: string, tagId: string) => Promise<void>;
147
+ /** Uses {@link SavedViewsClient} to remove {@link SavedViewTag} from {@link SavedView} entity. */
148
+ removeTag: (savedViewId: string, tagId: string) => Promise<void>;
149
+ /**
150
+ * Uses {@link SavedViewsClient} to delete {@link SavedViewTag} entity. On success, removes
151
+ * {@link SavedViewTag} from Saved Views store.
152
+ */
153
+ deleteTag: (tagId: string) => Promise<void>;
154
+ /** Uses {@link SavedViewsClient} to change thumbnail image for {@link SavedView} entity. */
155
+ uploadThumbnail: (savedViewId: string, imageDataUrl: string) => Promise<void>;
42
156
  }
43
157
  /**
44
- * Pulls Saved View data from a store and provides means to update and synchronize the data back to it. Interaction with
45
- * the store is performed via {@linkcode SavedViewsClient} interface which could communicate, for instance, with
46
- * [iTwin Saved Views API](https://developer.bentley.com/apis/savedviews/overview/) using `ITwinSavedViewsClient`.
158
+ * Provides basic functionality to help get started with Saved Views.
159
+ *
160
+ * @remarks
161
+ * When hook arguments change, it does not automatically clear the {@linkcode UseSavedViewsResult.store}.
162
+ * If you want more control over the state, provide an external store via {@linkcode UseSavedViewsArgs.state}
163
+ * and {@linkcode UseSavedViewsArgs.setState} arguments.
164
+ *
165
+ * @example
166
+ * const { iTwinId, iModelId, client, viewport } = props;
167
+ * const savedViews = useSavedViews({ iTwinId, iModelId, client });
168
+ * const [isLoading, setIsLoading] = useState(true);
169
+ * useEffect(
170
+ * () => {
171
+ * return savedViews.startLoadingData(() => { setIsLoading(false); });
172
+ * },
173
+ * [],
174
+ * );
175
+ *
176
+ * if (isLoading) {
177
+ * return <MyLoadingState />;
178
+ * }
179
+ *
180
+ * const handleOpenSavedView = async (savedViewId) => {
181
+ * const savedViewData = await savedViews.lookupSavedViewData(savedViewId);
182
+ * await applySavedView(iModel, viewport, savedViewData);
183
+ * };
47
184
  *
48
- * Note on the current implementation limitations. While the result of the first update action is reflected immediately,
49
- * subsequent actions are put in a queue and executed serially. This may cause the UI to feel sluggish when user makes
50
- * changes to Saved Views faster than the Saved Views store can be updated.
185
+ * return <MySavedViewsWidget savedViews={savedViews} onOpenSavedView={handleOpenSavedView} />;
51
186
  */
52
- export declare function useSavedViews(args: UseSavedViewsParams): UseSavedViewsResult | undefined;
187
+ export declare const useSavedViews: ((args: UseSavedViewsArgs) => UseSavedViewsResult) & ((args: UseSavedViewsArgs) => UseSavedViewsResult) & {
188
+ /** Suggested initial state of custom Saved View stores. Immutable. */
189
+ emptyState: SavedViewsState;
190
+ };
53
191
  export {};