@itwin/saved-views-react 1.1.0 → 1.1.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.
@@ -1,4 +1,4 @@
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";
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";
2
2
  const viewFlagMappings = [
3
3
  extractNumber("renderMode"),
4
4
  extractBoolean("noConstructions", "noConstruct"),
@@ -411,7 +411,7 @@ const displayStylesLegacyMapping = [
411
411
  extractNumber("timePoint"),
412
412
  extractArray(displayStyleSubCategoryLegacyMappings, "subCategoryOvr", "subCategoryOverrides"),
413
413
  extractObject(backgroundMapMappings, "backgroundMap"),
414
- extractArray(contextRealityModelsLegacyMappings, "contextRealityModels"),
414
+ extractArrayElementsConditionally((value) => value && !value.invisible, contextRealityModelsLegacyMappings, "contextRealityModels"),
415
415
  extractStringOrArray("excludedElements"),
416
416
  extractObject(mapImageryLegacyMapping, "mapImagery"),
417
417
  extractArray(displayStyleModelAppearanceLegacyMappings, "modelOvr", "modelOverrides"),
@@ -185,6 +185,16 @@ export declare const extractConditionally: (params: ConditionalExtractParams[],
185
185
  * @param extractionFunc
186
186
  */
187
187
  export declare const extractArray: (extractionFunc: ExtractionFunc<void, void>[], from: string, to?: string) => (input: any, output: any) => void;
188
+ /**
189
+ * Creates an extraction function that will extract each value of an array if it meets the given condition
190
+ * by using a single extraction function on each of the array values
191
+ * @param condition Function that checks if the value should be extracted
192
+ * @param extractionFunc Array of extraction functions to apply to each value in the array that meets the condition
193
+ * @param from Accessor string where the array is in the input object
194
+ * @param to Accessor string to store it in the output object
195
+ * @returns Function that extracts an array of values conditionally
196
+ */
197
+ export declare const extractArrayElementsConditionally: (condition: (value: any) => boolean, extractionFunc: ExtractionFunc<void, void>[], from: string, to?: string) => (input: any, output: any) => void;
188
198
  /**
189
199
  * Creates an extraction function that will extract the values inside a 2D array from the given accessor
190
200
  * @param extractionFunc Extraction functions to apply to each entry in the array
@@ -439,6 +439,34 @@ export const extractArray = (extractionFunc, from, to) => {
439
439
  }
440
440
  };
441
441
  };
442
+ /**
443
+ * Creates an extraction function that will extract each value of an array if it meets the given condition
444
+ * by using a single extraction function on each of the array values
445
+ * @param condition Function that checks if the value should be extracted
446
+ * @param extractionFunc Array of extraction functions to apply to each value in the array that meets the condition
447
+ * @param from Accessor string where the array is in the input object
448
+ * @param to Accessor string to store it in the output object
449
+ * @returns Function that extracts an array of values conditionally
450
+ */
451
+ export const extractArrayElementsConditionally = (
452
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
453
+ condition, extractionFunc, from, to) => {
454
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
455
+ return (input, output) => {
456
+ const adjustedTo = to ?? from;
457
+ if (input[from] !== undefined && Array.isArray(input[from])) {
458
+ output[adjustedTo] = [];
459
+ let outputIndex = 0;
460
+ input[from].forEach((_, index) => {
461
+ if (condition(input[from][index])) {
462
+ output[adjustedTo].push({});
463
+ extractionFunc.forEach((func) => func(input[from][index], output[adjustedTo][outputIndex]));
464
+ outputIndex++;
465
+ }
466
+ });
467
+ }
468
+ };
469
+ };
442
470
  /**
443
471
  * Creates an extraction function that will extract the values inside a 2D array from the given accessor
444
472
  * @param extractionFunc Extraction functions to apply to each entry in the array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/saved-views-react",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",