@itwin/saved-views-react 1.1.1 → 1.1.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyExtraction, extractArray, extractArrayConditionally, extractArrayElementsConditionally, extractBoolean, extractColor, extractColorLegacy, extractConditionally, extractLinePixels, extractNumber, extractNumberOrBool, extractObject, extractPlainTypedMap, extractRGB, extractSimpleArray, extractString, extractStringOrArray, extractStringOrNumber, extractStringOrNumberArray, isAnyColorFormat, simpleTypeOf, } from "./extractionUtilities.js";
|
|
1
|
+
import { applyExtraction, extractArray, extractArrayConditionally, extractArrayElementsConditionally, extractBoolean, extractColor, extractColorLegacy, extractConditionally, extractLinePixels, extractNumber, extractNumberOrBool, extractObject, extractPlainTypedMap, extractRGB, extractSimpleArray, extractString, extractStringOrArray, extractStringOrNumber, extractStringOrNumberArray, extractValidPlainTypedMap, isAnyColorFormat, simpleTypeOf, simpleTypeOrArrayOf, } from "./extractionUtilities.js";
|
|
2
2
|
const viewFlagMappings = [
|
|
3
3
|
extractNumber("renderMode"),
|
|
4
4
|
extractBoolean("noConstructions", "noConstruct"),
|
|
@@ -202,6 +202,8 @@ const imageMapLayerPropsMapping = [
|
|
|
202
202
|
extractString("url"),
|
|
203
203
|
extractString("formatId"),
|
|
204
204
|
extractArray(mapSubLayerMappings, "subLayers"),
|
|
205
|
+
extractValidPlainTypedMap(simpleTypeOf("string"), simpleTypeOf("string"), "queryParams"),
|
|
206
|
+
extractValidPlainTypedMap(simpleTypeOrArrayOf(["string", "number", "boolean"]), simpleTypeOf("string"), "properties"),
|
|
205
207
|
];
|
|
206
208
|
const baseMapLayerPropsMapping = [
|
|
207
209
|
...imageMapLayerPropsMapping,
|
|
@@ -5,6 +5,12 @@ import type { Rgba, RgbatColorProps } from "./RgbColor.js";
|
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
7
|
export declare const simpleTypeOf: (typeOfString: string) => (value: unknown) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Returns a function that does determines if a value is of any of the provided types or arrays of those types
|
|
10
|
+
* @param typeOfString Array of strings to compare against type
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare const simpleTypeOrArrayOf: (typeOfString: string[]) => (value: unknown) => boolean;
|
|
8
14
|
/**
|
|
9
15
|
* Returns true if the given value is in any of the color formats that we accept to transform
|
|
10
16
|
* @param value
|
|
@@ -217,6 +223,15 @@ export declare const extractArrayConditionally: (params: ConditionalExtractParam
|
|
|
217
223
|
* @returns
|
|
218
224
|
*/
|
|
219
225
|
export declare const extractPlainTypedMap: (extractionFuncs: ExtractionFunc<void, void>[], isValidKey: (key: unknown) => boolean, from: string, to?: string) => (input: any, output: any) => void;
|
|
226
|
+
/**
|
|
227
|
+
* Creates an extraction function that will extract a plain typed map
|
|
228
|
+
* @param isValidValue Checker for the validity of the values
|
|
229
|
+
* @param isValidKey Checker for the validity of the key
|
|
230
|
+
* @param from Accessor where the plain typed map exists
|
|
231
|
+
* @param to Accessor to store the plain typed map to
|
|
232
|
+
* @returns
|
|
233
|
+
*/
|
|
234
|
+
export declare const extractValidPlainTypedMap: (isValidValue: (value: unknown) => boolean, isValidKey: (key: unknown) => boolean, from: string, to?: string) => (input: any, output: any) => void;
|
|
220
235
|
/**
|
|
221
236
|
* Applies an array of extraction functions to extract the data from the input object
|
|
222
237
|
* into the output object
|
|
@@ -12,6 +12,19 @@ import { LinePixels } from "@itwin/saved-views-client";
|
|
|
12
12
|
export const simpleTypeOf = (typeOfString) => {
|
|
13
13
|
return (value) => typeof value === typeOfString;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Returns a function that does determines if a value is of any of the provided types or arrays of those types
|
|
17
|
+
* @param typeOfString Array of strings to compare against type
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export const simpleTypeOrArrayOf = (typeOfString) => {
|
|
21
|
+
return (value) => typeOfString.some((type) => {
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
return value.every((inner) => typeof inner === type);
|
|
24
|
+
}
|
|
25
|
+
return typeof value === type;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
15
28
|
/**
|
|
16
29
|
* Type check for colors in format {r: number, g: number, b:number}
|
|
17
30
|
* @param value
|
|
@@ -543,6 +556,28 @@ export const extractPlainTypedMap = (extractionFuncs, isValidKey, from, to) => {
|
|
|
543
556
|
}
|
|
544
557
|
};
|
|
545
558
|
};
|
|
559
|
+
/**
|
|
560
|
+
* Creates an extraction function that will extract a plain typed map
|
|
561
|
+
* @param isValidValue Checker for the validity of the values
|
|
562
|
+
* @param isValidKey Checker for the validity of the key
|
|
563
|
+
* @param from Accessor where the plain typed map exists
|
|
564
|
+
* @param to Accessor to store the plain typed map to
|
|
565
|
+
* @returns
|
|
566
|
+
*/
|
|
567
|
+
export const extractValidPlainTypedMap = (isValidValue, isValidKey, from, to) => {
|
|
568
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
569
|
+
return (input, output) => {
|
|
570
|
+
if (input[from] !== undefined) {
|
|
571
|
+
const adjustedTo = to ?? from;
|
|
572
|
+
output[adjustedTo] = {};
|
|
573
|
+
for (const prop in input[from]) {
|
|
574
|
+
if (isValidKey(prop) && isValidValue(input[from][prop])) {
|
|
575
|
+
output[adjustedTo][prop] = input[from][prop];
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
};
|
|
546
581
|
/**
|
|
547
582
|
* Applies an array of extraction functions to extract the data from the input object
|
|
548
583
|
* into the output object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/saved-views-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@itwin/itwinui-icons-react": "^2.9.0",
|
|
69
69
|
"@itwin/itwinui-react": "^3.15.0",
|
|
70
70
|
"fuse.js": "^6.6.2",
|
|
71
|
-
"@itwin/saved-views-client": "^0.5.
|
|
71
|
+
"@itwin/saved-views-client": "^0.5.3"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "run-p build:*",
|