@itwin/core-react 5.4.0 → 5.6.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.
@@ -61,7 +61,7 @@ buttonText = useTranslation("dialog.ok");
61
61
  ```
62
62
 
63
63
  - Run `npm run extract-api` to update the `*api.md` file for the package
64
- - Write unit tests for the new component or class. The tests should cover as many code statements, branches, functions and lines as possible (100% is the goal). To run the tests, run `npm run test` or `rush test`. To run coverage, run `npm run cover`. To see the coverage report, open the report from one of the following directories in your browser:
64
+ - Write unit tests for the new component or class. The tests should cover as many code statements, branches, functions and lines as possible (100% is the goal). To run the tests, run `npm run test` or `pnpm test`. To run coverage, run `npm run cover`. To see the coverage report, open the report from one of the following directories in your browser:
65
65
  - appui/ui/appui-react/lib/test/coverage/lcov-report/index.html
66
66
  - appui/ui/components-react/lib/test/coverage/lcov-report/index.html
67
67
  - appui/ui/core-react/lib/test/coverage/lcov-report/index.html
@@ -54,7 +54,7 @@ export class UiCore {
54
54
  Logger.logError(UiCore.loggerCategory("UiCore"), `translate: UiCore must be initialize with a localization provider. Returning blank string.`);
55
55
  return "";
56
56
  }
57
- return UiCore._localization.getLocalizedString(`${UiCore.localizationNamespace}:${key}`);
57
+ return UiCore._localization.getLocalizedString(`${UiCore.localizationNamespace}:${String(key)}`);
58
58
  }
59
59
  /** @internal */
60
60
  static get packageName() {
@@ -1 +1 @@
1
- {"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,qDAAqD;AAErD;;;GAGG;AACH,MAAM,OAAO,MAAM;IAIjB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,MAAM,CAAC,OAAO,CACZ,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC/B,kCAAkC,CACnC,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,CAAC,aAAa,GAAG,YAAY,CAAC;QACpC,MAAM,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAE3E,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,oDAAoD;IAC7C,MAAM,CAAC,SAAS;QACrB,IAAI,MAAM,CAAC,aAAa;YACtB,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACzE,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;QAEjC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,gDAAgD;IACzC,MAAM,KAAK,WAAW;QAC3B,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC1B,MAAM,CAAC,QAAQ,CACb,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC/B,4FAA4F,CAC7F,CAAC;YACF,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAC5C,GAAG,MAAM,CAAC,qBAAqB,IAAI,GAAG,EAAE,CACzC,CAAC;IACJ,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,IAAY;QACvC,OAAO,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;IACzC,CAAC;;AAlEc,mBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\n/** Import color variables, layout variables and Sass classes barrel file */\nimport \"./colorthemes.scss\";\nimport \"./colorvariables.scss\";\nimport \"./layout-variables.scss\";\nimport \"./classes.scss\";\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Manages the Localization service for the core-react package.\n * @public\n * @deprecated in 4.16.0. `@itwin/core-react` package is deprecated, see used modules for suggested replacements.\n */\nexport class UiCore {\n private static _initialized = false;\n private static _localization?: Localization;\n\n /**\n * Registers the Localization service namespace for UiCore.\n * @param localization The internationalization service created by the host application.\n */\n public static async initialize(localization: Localization): Promise<void> {\n if (UiCore._initialized) {\n Logger.logInfo(\n UiCore.loggerCategory(\"UiCore\"),\n `UiCore.initialize already called`\n );\n return;\n }\n\n UiCore._localization = localization;\n await UiCore._localization.registerNamespace(UiCore.localizationNamespace);\n\n UiCore._initialized = true;\n }\n\n /** Unregisters the UiCore localization namespace */\n public static terminate() {\n if (UiCore._localization)\n UiCore._localization.unregisterNamespace(UiCore.localizationNamespace);\n UiCore._localization = undefined;\n\n UiCore._initialized = false;\n }\n\n /** Determines if UiCore has been initialized */\n public static get initialized(): boolean {\n return UiCore._initialized;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiCore\";\n }\n\n /** Calls localization.getLocalizedString with the \"UiCore\" namespace. Do NOT include the namespace in the key.\n * @deprecated in 4.12.0. Do not use this internally, this is replaced by `useTranslation`.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiCore._localization) {\n Logger.logError(\n UiCore.loggerCategory(\"UiCore\"),\n `translate: UiCore must be initialize with a localization provider. Returning blank string.`\n );\n return \"\";\n }\n return UiCore._localization.getLocalizedString(\n `${UiCore.localizationNamespace}:${key}`\n );\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"core-react\";\n }\n\n /** @internal */\n public static loggerCategory(name: string): string {\n return `${UiCore.packageName}.${name}`;\n }\n}\n"]}
1
+ {"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,qDAAqD;AAErD;;;GAGG;AACH,MAAM,OAAO,MAAM;IAIjB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,MAAM,CAAC,OAAO,CACZ,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC/B,kCAAkC,CACnC,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,CAAC,aAAa,GAAG,YAAY,CAAC;QACpC,MAAM,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAE3E,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,oDAAoD;IAC7C,MAAM,CAAC,SAAS;QACrB,IAAI,MAAM,CAAC,aAAa;YACtB,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACzE,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;QAEjC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,gDAAgD;IACzC,MAAM,KAAK,WAAW;QAC3B,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC1B,MAAM,CAAC,QAAQ,CACb,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC/B,4FAA4F,CAC7F,CAAC;YACF,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAC5C,GAAG,MAAM,CAAC,qBAAqB,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CACjD,CAAC;IACJ,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,IAAY;QACvC,OAAO,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;IACzC,CAAC;;AAlEc,mBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\n/** Import color variables, layout variables and Sass classes barrel file */\nimport \"./colorthemes.scss\";\nimport \"./colorvariables.scss\";\nimport \"./layout-variables.scss\";\nimport \"./classes.scss\";\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Manages the Localization service for the core-react package.\n * @public\n * @deprecated in 4.16.0. `@itwin/core-react` package is deprecated, see used modules for suggested replacements.\n */\nexport class UiCore {\n private static _initialized = false;\n private static _localization?: Localization;\n\n /**\n * Registers the Localization service namespace for UiCore.\n * @param localization The internationalization service created by the host application.\n */\n public static async initialize(localization: Localization): Promise<void> {\n if (UiCore._initialized) {\n Logger.logInfo(\n UiCore.loggerCategory(\"UiCore\"),\n `UiCore.initialize already called`\n );\n return;\n }\n\n UiCore._localization = localization;\n await UiCore._localization.registerNamespace(UiCore.localizationNamespace);\n\n UiCore._initialized = true;\n }\n\n /** Unregisters the UiCore localization namespace */\n public static terminate() {\n if (UiCore._localization)\n UiCore._localization.unregisterNamespace(UiCore.localizationNamespace);\n UiCore._localization = undefined;\n\n UiCore._initialized = false;\n }\n\n /** Determines if UiCore has been initialized */\n public static get initialized(): boolean {\n return UiCore._initialized;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiCore\";\n }\n\n /** Calls localization.getLocalizedString with the \"UiCore\" namespace. Do NOT include the namespace in the key.\n * @deprecated in 4.12.0. Do not use this internally, this is replaced by `useTranslation`.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiCore._localization) {\n Logger.logError(\n UiCore.loggerCategory(\"UiCore\"),\n `translate: UiCore must be initialize with a localization provider. Returning blank string.`\n );\n return \"\";\n }\n return UiCore._localization.getLocalizedString(\n `${UiCore.localizationNamespace}:${String(key)}`\n );\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"core-react\";\n }\n\n /** @internal */\n public static loggerCategory(name: string): string {\n return `${UiCore.packageName}.${name}`;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollPositionMaintainer.d.ts","sourceRoot":"","sources":["../../../src/core-react/utils/ScrollPositionMaintainer.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAyB,YAAW,WAAW;IAC1D,OAAO,CAAC,QAAQ,CAAuB;gBACpB,EAAE,EAAE,OAAO;IAKvB,OAAO;IAId,OAAO,CAAC,MAAM,CAAC,mBAAmB;IASlC,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAGtC"}
1
+ {"version":3,"file":"ScrollPositionMaintainer.d.ts","sourceRoot":"","sources":["../../../src/core-react/utils/ScrollPositionMaintainer.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AAEH,qBAAa,wBAAyB,YAAW,WAAW;IAC1D,OAAO,CAAC,QAAQ,CAAuB;gBACpB,EAAE,EAAE,OAAO;IAKvB,OAAO;IAId,OAAO,CAAC,MAAM,CAAC,mBAAmB;IASlC,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAGtC"}
@@ -11,6 +11,7 @@
11
11
  * @public
12
12
  * @deprecated in 4.15.0. Not use by AppUI.
13
13
  */
14
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
14
15
  export class ScrollPositionMaintainer {
15
16
  constructor(el) {
16
17
  this._storage = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollPositionMaintainer.js","sourceRoot":"","sources":["../../../src/core-react/utils/ScrollPositionMaintainer.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,wBAAwB;IAEnC,YAAmB,EAAW;QAC5B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,4DAA4D;QAC5D,wBAAwB,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IACM,OAAO;QACZ,4DAA4D;QAC5D,wBAAwB,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IACO,MAAM,CAAC,mBAAmB,CAChC,QAAoC,EACpC,OAA6B;QAE7B,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC1B,IAAI,EAAE,CAAC,SAAS;gBAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;YAChD,IAAI,EAAE,CAAC,QAAQ;gBAAE,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IACO,MAAM,CAAC,sBAAsB,CAAC,OAA6B;QACjE,OAAO,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport type { IDisposable } from \"@itwin/core-bentley\";\n\n/**\n * A helper class to recursively save and restore scroll positions.\n * Usage:\n * ```ts\n * // scroll positions are saved when `ScrollPositionMaintainer` object is created\n * const maintainer = new ScrollPositionMaintainer(element);\n * // can do something with `element` here\n * // disposing the `maintainer` object restores scroll positions\n * maintainer.dispose();\n * ```\n * @public\n * @deprecated in 4.15.0. Not use by AppUI.\n */\nexport class ScrollPositionMaintainer implements IDisposable {\n private _storage: Map<Element, number>;\n public constructor(el: Element) {\n this._storage = new Map();\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ScrollPositionMaintainer.saveScrollPositions([el], this._storage);\n }\n public dispose() {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ScrollPositionMaintainer.restoreScrollPositions(this._storage);\n }\n private static saveScrollPositions(\n elements: Element[] | HTMLCollection,\n storage: Map<Element, number>\n ) {\n for (const el of elements) {\n if (el.scrollTop) storage.set(el, el.scrollTop);\n if (el.children) this.saveScrollPositions(el.children, storage);\n }\n }\n private static restoreScrollPositions(storage: Map<Element, number>) {\n storage.forEach((scrollTop, el) => (el.scrollTop = scrollTop));\n }\n}\n"]}
1
+ {"version":3,"file":"ScrollPositionMaintainer.js","sourceRoot":"","sources":["../../../src/core-react/utils/ScrollPositionMaintainer.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,4DAA4D;AAC5D,MAAM,OAAO,wBAAwB;IAEnC,YAAmB,EAAW;QAC5B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,4DAA4D;QAC5D,wBAAwB,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IACM,OAAO;QACZ,4DAA4D;QAC5D,wBAAwB,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IACO,MAAM,CAAC,mBAAmB,CAChC,QAAoC,EACpC,OAA6B;QAE7B,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC1B,IAAI,EAAE,CAAC,SAAS;gBAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;YAChD,IAAI,EAAE,CAAC,QAAQ;gBAAE,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IACO,MAAM,CAAC,sBAAsB,CAAC,OAA6B;QACjE,OAAO,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport type { IDisposable } from \"@itwin/core-bentley\";\n\n/**\n * A helper class to recursively save and restore scroll positions.\n * Usage:\n * ```ts\n * // scroll positions are saved when `ScrollPositionMaintainer` object is created\n * const maintainer = new ScrollPositionMaintainer(element);\n * // can do something with `element` here\n * // disposing the `maintainer` object restores scroll positions\n * maintainer.dispose();\n * ```\n * @public\n * @deprecated in 4.15.0. Not use by AppUI.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class ScrollPositionMaintainer implements IDisposable {\n private _storage: Map<Element, number>;\n public constructor(el: Element) {\n this._storage = new Map();\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ScrollPositionMaintainer.saveScrollPositions([el], this._storage);\n }\n public dispose() {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ScrollPositionMaintainer.restoreScrollPositions(this._storage);\n }\n private static saveScrollPositions(\n elements: Element[] | HTMLCollection,\n storage: Map<Element, number>\n ) {\n for (const el of elements) {\n if (el.scrollTop) storage.set(el, el.scrollTop);\n if (el.children) this.saveScrollPositions(el.children, storage);\n }\n }\n private static restoreScrollPositions(storage: Map<Element, number>) {\n storage.forEach((scrollTop, el) => (el.scrollTop = scrollTop));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useDisposable.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useDisposable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,WAAW,SAAS,WAAW,EAC3D,gBAAgB,EAAE,MAAM,WAAW,GAClC,WAAW,CAoBb;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,SAAS,WAAW,EACnE,gBAAgB,EAAE,MAAM,WAAW,GAAG,SAAS,GAC9C,WAAW,GAAG,SAAS,CAYzB"}
1
+ {"version":3,"file":"useDisposable.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useDisposable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,WAAW,SAAS,WAAW,EAC3D,gBAAgB,EAAE,MAAM,WAAW,GAClC,WAAW,CAoBb;AAED;;;;;;GAMG;AAEH,wBAAgB,qBAAqB,CAAC,WAAW,SAAS,WAAW,EACnE,gBAAgB,EAAE,MAAM,WAAW,GAAG,SAAS,GAC9C,WAAW,GAAG,SAAS,CAYzB"}
@@ -13,6 +13,7 @@ import { useEffect, useRef, useState } from "react";
13
13
  * @deprecated in 4.9.0. This hook is not compatible with React 18 Strict mode. Use [[useOptionalDisposable]] or `useState` + `useEffect` for
14
14
  * creating and disposing disposable resources.
15
15
  */
16
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
16
17
  export function useDisposable(createDisposable) {
17
18
  const [value, setValue] = useState(() => createDisposable());
18
19
  // need to capture initial disposable created during render loop in order to dispose later
@@ -38,6 +39,7 @@ export function useDisposable(createDisposable) {
38
39
  * @public
39
40
  * @deprecated in 4.15.0. Use `useState` + `useEffect` for creating and disposing disposable resources.
40
41
  */
42
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
41
43
  export function useOptionalDisposable(createDisposable) {
42
44
  const [value, setValue] = useState();
43
45
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"useDisposable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useDisposable.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,gBAAmC;IAEnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7D,0FAA0F;IAC1F,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAErC,SAAS,CAAC,GAAG,EAAE;QACb,qFAAqF;QACrF,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;YAC7B,SAAS,CAAC,OAAO,GAAG,gBAAgB,EAAE,CAAC;YACvC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,eAAe,CAAC,OAAO,GAAG,KAAK,CAAC;QAChC,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,gBAA+C;IAE/C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC;QACtC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACrB,OAAO,GAAG,EAAE;YACV,UAAU,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { IDisposable } from \"@itwin/core-bentley\";\n\n/**\n * A custom hook which creates a disposable object and manages its disposal on unmount\n * or factory method change.\n * @public\n * @deprecated in 4.9.0. This hook is not compatible with React 18 Strict mode. Use [[useOptionalDisposable]] or `useState` + `useEffect` for\n * creating and disposing disposable resources.\n */\nexport function useDisposable<TDisposable extends IDisposable>(\n createDisposable: () => TDisposable\n): TDisposable {\n const [value, setValue] = useState(() => createDisposable());\n // need to capture initial disposable created during render loop in order to dispose later\n const prevValue = useRef(value);\n const useInitialValue = useRef(true);\n\n useEffect(() => {\n // do not create new disposable on initial render. It was created during render loop.\n if (!useInitialValue.current) {\n prevValue.current = createDisposable();\n setValue(prevValue.current);\n }\n\n useInitialValue.current = false;\n return () => {\n prevValue.current.dispose();\n };\n }, [createDisposable]);\n\n return value;\n}\n\n/**\n * A custom hook which calls the factory method to create a disposable object\n * which might as well be undefined. If the result was a disposable object, the\n * hook takes care of disposing it when necessary.\n * @public\n * @deprecated in 4.15.0. Use `useState` + `useEffect` for creating and disposing disposable resources.\n */\nexport function useOptionalDisposable<TDisposable extends IDisposable>(\n createDisposable: () => TDisposable | undefined\n): TDisposable | undefined {\n const [value, setValue] = useState<TDisposable | undefined>();\n\n useEffect(() => {\n const disposable = createDisposable();\n setValue(disposable);\n return () => {\n disposable && disposable.dispose();\n };\n }, [createDisposable]);\n\n return value;\n}\n"]}
1
+ {"version":3,"file":"useDisposable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useDisposable.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD;;;;;;GAMG;AACH,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAC3B,gBAAmC;IAEnC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7D,0FAA0F;IAC1F,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAErC,SAAS,CAAC,GAAG,EAAE;QACb,qFAAqF;QACrF,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;YAC7B,SAAS,CAAC,OAAO,GAAG,gBAAgB,EAAE,CAAC;YACvC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,eAAe,CAAC,OAAO,GAAG,KAAK,CAAC;QAChC,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,4DAA4D;AAC5D,MAAM,UAAU,qBAAqB,CACnC,gBAA+C;IAE/C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC;QACtC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACrB,OAAO,GAAG,EAAE;YACV,UAAU,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { IDisposable } from \"@itwin/core-bentley\";\n\n/**\n * A custom hook which creates a disposable object and manages its disposal on unmount\n * or factory method change.\n * @public\n * @deprecated in 4.9.0. This hook is not compatible with React 18 Strict mode. Use [[useOptionalDisposable]] or `useState` + `useEffect` for\n * creating and disposing disposable resources.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function useDisposable<TDisposable extends IDisposable>(\n createDisposable: () => TDisposable\n): TDisposable {\n const [value, setValue] = useState(() => createDisposable());\n // need to capture initial disposable created during render loop in order to dispose later\n const prevValue = useRef(value);\n const useInitialValue = useRef(true);\n\n useEffect(() => {\n // do not create new disposable on initial render. It was created during render loop.\n if (!useInitialValue.current) {\n prevValue.current = createDisposable();\n setValue(prevValue.current);\n }\n\n useInitialValue.current = false;\n return () => {\n prevValue.current.dispose();\n };\n }, [createDisposable]);\n\n return value;\n}\n\n/**\n * A custom hook which calls the factory method to create a disposable object\n * which might as well be undefined. If the result was a disposable object, the\n * hook takes care of disposing it when necessary.\n * @public\n * @deprecated in 4.15.0. Use `useState` + `useEffect` for creating and disposing disposable resources.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function useOptionalDisposable<TDisposable extends IDisposable>(\n createDisposable: () => TDisposable | undefined\n): TDisposable | undefined {\n const [value, setValue] = useState<TDisposable | undefined>();\n\n useEffect(() => {\n const disposable = createDisposable();\n setValue(disposable);\n return () => {\n disposable && disposable.dispose();\n };\n }, [createDisposable]);\n\n return value;\n}\n"]}
@@ -12,5 +12,5 @@ export interface ThrottleSettings {
12
12
  /** Used to throttle function calls
13
13
  * @internal
14
14
  */
15
- export declare function useThrottledFn<T extends (...args: any) => any>(functionToThrottle: T, waitTime: number, dependencies: React.DependencyList, options?: ThrottleSettings): import("lodash").DebouncedFunc<T>;
15
+ export declare function useThrottledFn<T extends (...args: any) => any>(functionToThrottle: T, waitTime: number, dependencies: React.DependencyList, options?: ThrottleSettings): import("lodash").DebouncedFuncLeading<T>;
16
16
  //# sourceMappingURL=useThrottledFn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useThrottledFn.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useThrottledFn.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAOD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAC5D,kBAAkB,EAAE,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,KAAK,CAAC,cAAc,EAClC,OAAO,GAAE,gBAAiC,qCAK3C"}
1
+ {"version":3,"file":"useThrottledFn.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/hooks/useThrottledFn.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAOD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAC5D,kBAAkB,EAAE,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,KAAK,CAAC,cAAc,EAClC,OAAO,GAAE,gBAAiC,4CAK3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-react",
3
- "version": "5.4.0",
3
+ "version": "5.6.0",
4
4
  "description": "A react component library of iTwin.js UI general purpose components",
5
5
  "type": "module",
6
6
  "types": "./lib/core-react.d.ts",
@@ -37,20 +37,20 @@
37
37
  "url": "http://www.bentley.com"
38
38
  },
39
39
  "peerDependencies": {
40
- "@itwin/appui-abstract": "^4.0.0",
41
- "@itwin/core-bentley": "^4.0.0",
40
+ "@itwin/appui-abstract": "^4.0.0 || ^5.0.0",
41
+ "@itwin/core-bentley": "^4.0.0 || ^5.0.0",
42
42
  "@itwin/itwinui-react": "^3.15.0",
43
43
  "react": "^18.0.0",
44
44
  "react-dom": "^18.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@itwin/appui-abstract": "^4.0.0",
47
+ "@itwin/appui-abstract": "rc",
48
48
  "@itwin/build-tools": "4.10.2",
49
- "@itwin/core-bentley": "^4.0.0",
50
- "@itwin/core-common": "^4.0.0",
51
- "@itwin/core-geometry": "^4.0.0",
52
- "@itwin/core-i18n": "^4.0.0",
53
- "@itwin/eslint-plugin": "5.0.0-dev.2",
49
+ "@itwin/core-bentley": "rc",
50
+ "@itwin/core-common": "rc",
51
+ "@itwin/core-geometry": "rc",
52
+ "@itwin/core-i18n": "rc",
53
+ "@itwin/eslint-plugin": "5.1.0",
54
54
  "@itwin/itwinui-react": "^3.17.0",
55
55
  "@testing-library/dom": "^10.1.0",
56
56
  "@testing-library/react": "^15.0.7",
@@ -62,6 +62,7 @@
62
62
  "@types/react-dom": "^18.3.1",
63
63
  "@vitest/coverage-v8": "^3.0.6",
64
64
  "cpx2": "^3.0.0",
65
+ "cross-env": "^5.1.4",
65
66
  "eslint": "^8.57.1",
66
67
  "eslint-config-prettier": "~8.8.0",
67
68
  "ignore-styles": "^5.0.1",
@@ -93,14 +94,14 @@
93
94
  "compat:css": "npm run compat:cjs && npm run compat:esm",
94
95
  "compat:cjs": "cpx \"./src/**/*.{*css,svg}\" ./lib/cjs",
95
96
  "compat:esm": "cpx \"./src/**/*.{*css,svg}\" ./lib/esm",
96
- "clean": "rimraf -g lib .rush/temp/package-deps*.json",
97
+ "clean": "rimraf -g lib",
97
98
  "cover": "vitest run --coverage",
98
- "lint": "eslint -f visualstudio \"./src/**/*.{ts,tsx}\" 1>&2",
99
+ "lint": "eslint \"./src/**/*.{ts,tsx}\"",
99
100
  "lint:fix": "npm run -s lint -- --fix",
100
- "extract-api": "betools extract-api --entry=./lib/core-react",
101
+ "extract-api": "betools extract-api --entry=./lib/core-react --apiReportFolder=../../common/api --apiReportTempFolder=../../common/temp/api --apiSummaryFolder=../../common/api/summary",
101
102
  "test": "vitest",
102
103
  "docs": "npm run -s docs:reference && npm run -s docs:changelog",
103
104
  "docs:changelog": "cpx ./CHANGELOG.md ../../generated-docs/reference/core-react",
104
- "docs:reference": "betools docs --includes=../../generated-docs/extract --json=../../generated-docs/reference/core-react/file.json --tsIndexFile=./core-react.ts --onlyJson"
105
+ "docs:reference": "cross-env NODE_PROJECT_ROOT_DIRECTORY=../../ betools docs --includes=../../generated-docs/extract --json=../../generated-docs/reference/core-react/file.json --tsIndexFile=./core-react.ts --onlyJson"
105
106
  }
106
107
  }