@itwin/components-react 3.0.0-dev.94 → 3.0.0-dev.98

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.
@@ -11,14 +11,16 @@ export declare class UiComponents {
11
11
  private static _localization?;
12
12
  /**
13
13
  * Registers the localization service namespace for UiComponents. Also initializes UiCore.
14
- * @param localization The internationalization service created by the application.
14
+ * @param localization The internationalization service created by the host application.
15
15
  */
16
16
  static initialize(localization: Localization): Promise<void>;
17
17
  /** Unregisters the UiComponents localization namespace */
18
18
  static terminate(): void;
19
19
  /** Determines if UiComponents has been initialized */
20
20
  static get initialized(): boolean;
21
- /** The internationalization service created by the application. */
21
+ /** The internationalization service created by the host application.
22
+ * @internal
23
+ */
22
24
  static get localization(): Localization;
23
25
  /** The internationalization service namespace. */
24
26
  static get localizationNamespace(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAczE,0DAA0D;WAC5C,SAAS;IASvB,sDAAsD;IACtD,WAAkB,WAAW,IAAI,OAAO,CAAsC;IAE9E,mEAAmE;IACnE,WAAkB,YAAY,IAAI,YAAY,CAI7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAQvD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
1
+ {"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAczE,0DAA0D;WAC5C,SAAS;IASvB,sDAAsD;IACtD,WAAkB,WAAW,IAAI,OAAO,CAAsC;IAE9E;;OAEG;IACH,WAAkB,YAAY,IAAI,YAAY,CAI7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAQvD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
@@ -19,7 +19,7 @@ const core_react_1 = require("@itwin/core-react");
19
19
  class UiComponents {
20
20
  /**
21
21
  * Registers the localization service namespace for UiComponents. Also initializes UiCore.
22
- * @param localization The internationalization service created by the application.
22
+ * @param localization The internationalization service created by the host application.
23
23
  */
24
24
  static async initialize(localization) {
25
25
  if (UiComponents._initialized) {
@@ -42,7 +42,9 @@ class UiComponents {
42
42
  }
43
43
  /** Determines if UiComponents has been initialized */
44
44
  static get initialized() { return UiComponents._initialized; }
45
- /** The internationalization service created by the application. */
45
+ /** The internationalization service created by the host application.
46
+ * @internal
47
+ */
46
48
  static get localization() {
47
49
  if (!UiComponents._localization)
48
50
  throw new appui_abstract_1.UiError(UiComponents.loggerCategory(this), "_localization: UiComponents.initialize has not been called. Unable to return Localization object.");
@@ -1 +1 @@
1
- {"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iCAAsC;AACtC,sDAA6C;AAE7C,0DAA8D;AAC9D,kDAA2C;AAE3C;;;GAGG;AACH,MAAa,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE;YAC7B,qBAAM,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,wCAAwC,CAAC,CAAC;YACpG,OAAO;SACR;QAED,IAAA,qBAAa,GAAE,CAAC;QAChB,YAAY,CAAC,aAAa,GAAG,YAAY,CAAC;QAC1C,MAAM,YAAY,CAAC,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAEvF,MAAM,mBAAM,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACpD,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,0DAA0D;IACnD,MAAM,CAAC,SAAS;QACrB,IAAI,YAAY,CAAC,aAAa;YAC5B,YAAY,CAAC,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QACrF,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC;QAEvC,mBAAM,CAAC,SAAS,EAAE,CAAC;QACnB,YAAY,CAAC,YAAY,GAAG,KAAK,CAAC;IACpC,CAAC;IAED,sDAAsD;IAC/C,MAAM,KAAK,WAAW,KAAc,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;IAE9E,mEAAmE;IAC5D,MAAM,KAAK,YAAY;QAC5B,IAAI,CAAC,YAAY,CAAC,aAAa;YAC7B,MAAM,IAAI,wBAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,mGAAmG,CAAC,CAAC;QAC5J,OAAO,YAAY,CAAC,aAAa,CAAC;IACpC,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YAC7B,qBAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,iFAAiF,CAAC,CAAC;YACtI,OAAO,EAAE,CAAC;SACX;QACD,OAAO,YAAY,CAAC,YAAY,CAAC,+BAA+B,CAAC,YAAY,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IAC5G,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/E,OAAO,QAAQ,CAAC;IAClB,CAAC;;AApEH,oCAsEC;AArEgB,yBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { enablePatches } from \"immer\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { getClassName, UiError } from \"@itwin/appui-abstract\";\r\nimport { UiCore } from \"@itwin/core-react\";\r\n\r\n/**\r\n * Manages the localization service for the components-react package.\r\n * @public\r\n */\r\nexport class UiComponents {\r\n private static _initialized = false;\r\n private static _localization?: Localization;\r\n\r\n /**\r\n * Registers the localization service namespace for UiComponents. Also initializes UiCore.\r\n * @param localization The internationalization service created by the application.\r\n */\r\n public static async initialize(localization: Localization): Promise<void> {\r\n if (UiComponents._initialized) {\r\n Logger.logInfo(UiComponents.loggerCategory(UiComponents), `UiComponents.initialize already called`);\r\n return;\r\n }\r\n\r\n enablePatches();\r\n UiComponents._localization = localization;\r\n await UiComponents._localization.registerNamespace(UiComponents.localizationNamespace);\r\n\r\n await UiCore.initialize(UiComponents._localization);\r\n UiComponents._initialized = true;\r\n }\r\n\r\n /** Unregisters the UiComponents localization namespace */\r\n public static terminate() {\r\n if (UiComponents._localization)\r\n UiComponents._localization.unregisterNamespace(UiComponents.localizationNamespace);\r\n UiComponents._localization = undefined;\r\n\r\n UiCore.terminate();\r\n UiComponents._initialized = false;\r\n }\r\n\r\n /** Determines if UiComponents has been initialized */\r\n public static get initialized(): boolean { return UiComponents._initialized; }\r\n\r\n /** The internationalization service created by the application. */\r\n public static get localization(): Localization {\r\n if (!UiComponents._localization)\r\n throw new UiError(UiComponents.loggerCategory(this), \"_localization: UiComponents.initialize has not been called. Unable to return Localization object.\");\r\n return UiComponents._localization;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return \"UiComponents\";\r\n }\r\n\r\n /** @internal */\r\n public static get packageName(): string {\r\n return \"components-react\";\r\n }\r\n\r\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiComponents\" namespace. Do NOT include the namespace in the key.\r\n * @internal\r\n */\r\n public static translate(key: string | string[]): string {\r\n if (!UiComponents.initialized) {\r\n Logger.logError(UiComponents.loggerCategory(this), `translate: UiComponents.initialize has not been called. Returning blank string.`);\r\n return \"\";\r\n }\r\n return UiComponents.localization.getLocalizedStringWithNamespace(UiComponents.localizationNamespace, key);\r\n }\r\n\r\n /** @internal */\r\n public static loggerCategory(obj: any): string {\r\n const className = getClassName(obj);\r\n const category = UiComponents.packageName + (className ? `.${className}` : \"\");\r\n return category;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iCAAsC;AACtC,sDAA6C;AAE7C,0DAA8D;AAC9D,kDAA2C;AAE3C;;;GAGG;AACH,MAAa,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE;YAC7B,qBAAM,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,wCAAwC,CAAC,CAAC;YACpG,OAAO;SACR;QAED,IAAA,qBAAa,GAAE,CAAC;QAChB,YAAY,CAAC,aAAa,GAAG,YAAY,CAAC;QAC1C,MAAM,YAAY,CAAC,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAEvF,MAAM,mBAAM,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACpD,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,0DAA0D;IACnD,MAAM,CAAC,SAAS;QACrB,IAAI,YAAY,CAAC,aAAa;YAC5B,YAAY,CAAC,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QACrF,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC;QAEvC,mBAAM,CAAC,SAAS,EAAE,CAAC;QACnB,YAAY,CAAC,YAAY,GAAG,KAAK,CAAC;IACpC,CAAC;IAED,sDAAsD;IAC/C,MAAM,KAAK,WAAW,KAAc,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;IAE9E;;OAEG;IACI,MAAM,KAAK,YAAY;QAC5B,IAAI,CAAC,YAAY,CAAC,aAAa;YAC7B,MAAM,IAAI,wBAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,mGAAmG,CAAC,CAAC;QAC5J,OAAO,YAAY,CAAC,aAAa,CAAC;IACpC,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YAC7B,qBAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,iFAAiF,CAAC,CAAC;YACtI,OAAO,EAAE,CAAC;SACX;QACD,OAAO,YAAY,CAAC,YAAY,CAAC,+BAA+B,CAAC,YAAY,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IAC5G,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/E,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAtEH,oCAwEC;AAvEgB,yBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { enablePatches } from \"immer\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { getClassName, UiError } from \"@itwin/appui-abstract\";\r\nimport { UiCore } from \"@itwin/core-react\";\r\n\r\n/**\r\n * Manages the localization service for the components-react package.\r\n * @public\r\n */\r\nexport class UiComponents {\r\n private static _initialized = false;\r\n private static _localization?: Localization;\r\n\r\n /**\r\n * Registers the localization service namespace for UiComponents. Also initializes UiCore.\r\n * @param localization The internationalization service created by the host application.\r\n */\r\n public static async initialize(localization: Localization): Promise<void> {\r\n if (UiComponents._initialized) {\r\n Logger.logInfo(UiComponents.loggerCategory(UiComponents), `UiComponents.initialize already called`);\r\n return;\r\n }\r\n\r\n enablePatches();\r\n UiComponents._localization = localization;\r\n await UiComponents._localization.registerNamespace(UiComponents.localizationNamespace);\r\n\r\n await UiCore.initialize(UiComponents._localization);\r\n UiComponents._initialized = true;\r\n }\r\n\r\n /** Unregisters the UiComponents localization namespace */\r\n public static terminate() {\r\n if (UiComponents._localization)\r\n UiComponents._localization.unregisterNamespace(UiComponents.localizationNamespace);\r\n UiComponents._localization = undefined;\r\n\r\n UiCore.terminate();\r\n UiComponents._initialized = false;\r\n }\r\n\r\n /** Determines if UiComponents has been initialized */\r\n public static get initialized(): boolean { return UiComponents._initialized; }\r\n\r\n /** The internationalization service created by the host application.\r\n * @internal\r\n */\r\n public static get localization(): Localization {\r\n if (!UiComponents._localization)\r\n throw new UiError(UiComponents.loggerCategory(this), \"_localization: UiComponents.initialize has not been called. Unable to return Localization object.\");\r\n return UiComponents._localization;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return \"UiComponents\";\r\n }\r\n\r\n /** @internal */\r\n public static get packageName(): string {\r\n return \"components-react\";\r\n }\r\n\r\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiComponents\" namespace. Do NOT include the namespace in the key.\r\n * @internal\r\n */\r\n public static translate(key: string | string[]): string {\r\n if (!UiComponents.initialized) {\r\n Logger.logError(UiComponents.loggerCategory(this), `translate: UiComponents.initialize has not been called. Returning blank string.`);\r\n return \"\";\r\n }\r\n return UiComponents.localization.getLocalizedStringWithNamespace(UiComponents.localizationNamespace, key);\r\n }\r\n\r\n /** @internal */\r\n public static loggerCategory(obj: any): string {\r\n const className = getClassName(obj);\r\n const category = UiComponents.packageName + (className ? `.${className}` : \"\");\r\n return category;\r\n }\r\n\r\n}\r\n"]}
@@ -71,7 +71,7 @@ class CustomNumberEditor extends React.PureComponent {
71
71
  }
72
72
  // istanbul ignore else
73
73
  if (e.key !== appui_abstract_1.SpecialKey.Enter) {
74
- appui_abstract_1.UiAbstract.messagePresenter.closeInputFieldMessage();
74
+ appui_abstract_1.UiAdmin.messagePresenter.closeInputFieldMessage();
75
75
  }
76
76
  };
77
77
  // istanbul ignore next
@@ -108,9 +108,9 @@ class CustomNumberEditor extends React.PureComponent {
108
108
  else {
109
109
  // istanbul ignore else
110
110
  if (this.htmlElement)
111
- appui_abstract_1.UiAbstract.messagePresenter.displayInputFieldMessage(this.htmlElement, appui_abstract_1.MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents_1.UiComponents.translate("errors.unable-to-parse-quantity"));
111
+ appui_abstract_1.UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, appui_abstract_1.MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents_1.UiComponents.translate("errors.unable-to-parse-quantity"));
112
112
  else
113
- appui_abstract_1.UiAbstract.messagePresenter.displayMessage(appui_abstract_1.MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents_1.UiComponents.translate("errors.unable-to-parse-quantity"));
113
+ appui_abstract_1.UiAdmin.messagePresenter.displayMessage(appui_abstract_1.MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents_1.UiComponents.translate("errors.unable-to-parse-quantity"));
114
114
  const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ this._formatParams.formatFunction(record.value.value);
115
115
  propertyValue = {
116
116
  valueFormat: appui_abstract_1.PropertyValueFormat.Primitive,
@@ -1 +1 @@
1
- {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oCAAoC;AAEpC,qCAAmC;AACnC,4DAAoC;AACpC,6CAA+B;AAC/B,sDAA6C;AAC7C,0DAG+B;AAC/B,kDAAuE;AACvE,kDAA+C;AAE/C,mEAAoF;AAUpF;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK,CAAC,aAA2D;IAAzG;;QACU,eAAU,GAAG,KAAK,CAAC;QAEnB,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAE5D,gBAAgB;QACS,UAAK,GAAsC;YAClE,UAAU,EAAE,EAAE;SACf,CAAC;QAiFM,sBAAiB,GAAG,CAAC,CAAsC,EAAE,EAAE;YACrE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC;QAiGM,gBAAW,GAAG,CAAC,CAAwC,EAAE,EAAE;YACjE,uBAAuB;YACvB,IAAI,CAAC,CAAC,GAAG,KAAK,2BAAU,CAAC,MAAM,EAAE;gBAC/B,MAAM,mBAAmB,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC3D,IAAI,mBAAmB,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;oBACjD,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,IAAI,CAAC,qBAAqB,EAAE,CAAC;iBAC9B;qBAAM;oBACL,uBAAuB;oBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ;wBACrB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,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CAAC;IACf,CAAC;CACF;AAPD,gEAOC;AACD,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,oCAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\n// cSpell:ignore customnumber testid\r\n\r\nimport \"./CustomNumberEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\r\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAbstract,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon, IconInput, Input, InputProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** @internal */\r\ninterface CustomNumberEditorState {\r\n inputValue: string;\r\n size?: number;\r\n maxLength?: number;\r\n iconSpec?: string;\r\n}\r\n\r\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\r\n * @alpha\r\n */\r\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _formatParams: CustomFormattedNumberParams | undefined;\r\n private _inputElement = React.createRef<HTMLInputElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<CustomNumberEditorState> = {\r\n inputValue: \"\",\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n if (record.isReadonly) {\r\n return {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: (record.value as PrimitiveValue).value,\r\n displayValue: (record.value as PrimitiveValue).displayValue,\r\n };\r\n }\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\r\n if (!parseResults.parseError && undefined !== parseResults.value) {\r\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: parseResults.value,\r\n displayValue: newDisplayValue,\r\n };\r\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\r\n // istanbul ignore else\r\n if (newDisplayValue !== this.state.inputValue) {\r\n this.setState({ inputValue: newDisplayValue });\r\n }\r\n } else {\r\n // istanbul ignore else\r\n if (this.htmlElement)\r\n UiAbstract.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n else\r\n UiAbstract.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n\r\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: record.value.value,\r\n displayValue,\r\n };\r\n }\r\n }\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._inputElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n return document.activeElement === this._inputElement.current;\r\n }\r\n\r\n private shouldSetFocus(): boolean {\r\n if (!this.props.setFocus)\r\n return false;\r\n\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n\r\n return (!disabled && !readonly);\r\n }\r\n\r\n private _applyUpdatedValue(userInput: string) {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n\r\n if (readonly || disabled)\r\n return;\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n inputValue: userInput,\r\n });\r\n }\r\n\r\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n this._applyUpdatedValue(e.target.value);\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private _getInitialDisplayValue(): string {\r\n const record = this.props.propertyRecord;\r\n let initialDisplayValue = \"\";\r\n let numberValue = 0;\r\n // istanbul ignore else\r\n if (record) {\r\n // istanbul ignore else\r\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = record.value;\r\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\r\n // istanbul ignore else\r\n if (primitiveValue.displayValue)\r\n initialDisplayValue = primitiveValue.displayValue;\r\n else\r\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\r\n }\r\n }\r\n\r\n return initialDisplayValue;\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n // istanbul ignore next\r\n if (!record || !record.property) {\r\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n // eslint-disable-next-line no-console\r\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n return;\r\n }\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\r\n }\r\n\r\n if (!this._formatParams) {\r\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\r\n // eslint-disable-next-line no-console\r\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\r\n return;\r\n }\r\n\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n let size: number | undefined;\r\n let maxLength: number | undefined;\r\n let iconSpec: string | undefined;\r\n\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\r\n // istanbul ignore else\r\n if (editorSizeParams) {\r\n // istanbul ignore else\r\n if (editorSizeParams.size)\r\n size = editorSizeParams.size;\r\n // istanbul ignore else\r\n if (editorSizeParams.maxLength)\r\n maxLength = editorSizeParams.maxLength;\r\n }\r\n\r\n const iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\r\n if (iconParams) {\r\n iconSpec = iconParams.definition.iconSpec;\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\r\n }\r\n\r\n private _resetToOriginalValue() {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n\r\n this.setState({ inputValue: initialDisplayValue });\r\n }\r\n\r\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Escape) {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n if (initialDisplayValue !== this.state.inputValue) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n this._resetToOriginalValue();\r\n } else {\r\n // istanbul ignore else\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (e.key !== SpecialKey.Enter) {\r\n UiAbstract.messagePresenter.closeInputFieldMessage();\r\n }\r\n };\r\n\r\n // istanbul ignore next\r\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\r\n e.target.select();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const minSize = this.state.size ? this.state.size : 8;\r\n const minWidthStyle: React.CSSProperties = {\r\n minWidth: `${minSize * 0.75}em`,\r\n };\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n if (!record || !this._formatParams)\r\n return null;\r\n\r\n const readOnly = !record.isReadonly ? false : true;\r\n const disabled = !record.isDisabled ? false : true;\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\r\n\r\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\r\n className,\r\n style: this.props.style ? this.props.style : minWidthStyle,\r\n readOnly,\r\n disabled,\r\n maxLength: this.state.maxLength,\r\n value: this.state.inputValue,\r\n onChange: this._updateInputValue,\r\n onBlur: this.props.onBlur,\r\n onFocus: this._onFocus,\r\n setFocus: this.shouldSetFocus(),\r\n onKeyDown: this._onKeyPress,\r\n };\r\n\r\n let reactNode: React.ReactNode;\r\n if (this.state.iconSpec) {\r\n const icon = <Icon iconSpec={this.state.iconSpec} />;\r\n reactNode = (\r\n <IconInput\r\n {...inputProps}\r\n ref={this._inputElement}\r\n icon={icon}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n } else {\r\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\r\n reactNode = (\r\n // eslint-disable-next-line deprecation/deprecation\r\n <Input\r\n {...inputProps}\r\n ref={this._inputElement}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n }\r\n\r\n return reactNode;\r\n }\r\n}\r\n\r\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\r\n * It uses the [[CustomNumberEditor]] React component.\r\n * @alpha\r\n */\r\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <CustomNumberEditor />;\r\n }\r\n public override get containerHandlesEscape(): boolean {\r\n return false;\r\n }\r\n}\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\r\n"]}
1
+ {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oCAAoC;AAEpC,qCAAmC;AACnC,4DAAoC;AACpC,6CAA+B;AAC/B,sDAA6C;AAC7C,0DAG+B;AAC/B,kDAAuE;AACvE,kDAA+C;AAE/C,mEAAoF;AAUpF;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK,CAAC,aAA2D;IAAzG;;QACU,eAAU,GAAG,KAAK,CAAC;QAEnB,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAE5D,gBAAgB;QACS,UAAK,GAAsC;YAClE,UAAU,EAAE,EAAE;SACf,CAAC;QAiFM,sBAAiB,GAAG,CAAC,CAAsC,EAAE,EAAE;YACrE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC;QAiGM,gBAAW,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AAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,gCAAgC,GAC5C,CACH,CAAC;SACH;aAAM;YACL,uFAAuF;YACvF,SAAS,GAAG;YACV,mDAAmD;YACnD,oBAAC,kBAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,GAC5C,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA5QD,gDA4QC;AAED;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,0CAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAPD,gEAOC;AACD,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,oCAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\n// cSpell:ignore customnumber testid\r\n\r\nimport \"./CustomNumberEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\r\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon, IconInput, Input, InputProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** @internal */\r\ninterface CustomNumberEditorState {\r\n inputValue: string;\r\n size?: number;\r\n maxLength?: number;\r\n iconSpec?: string;\r\n}\r\n\r\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\r\n * @alpha\r\n */\r\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _formatParams: CustomFormattedNumberParams | undefined;\r\n private _inputElement = React.createRef<HTMLInputElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<CustomNumberEditorState> = {\r\n inputValue: \"\",\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n if (record.isReadonly) {\r\n return {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: (record.value as PrimitiveValue).value,\r\n displayValue: (record.value as PrimitiveValue).displayValue,\r\n };\r\n }\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\r\n if (!parseResults.parseError && undefined !== parseResults.value) {\r\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: parseResults.value,\r\n displayValue: newDisplayValue,\r\n };\r\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\r\n // istanbul ignore else\r\n if (newDisplayValue !== this.state.inputValue) {\r\n this.setState({ inputValue: newDisplayValue });\r\n }\r\n } else {\r\n // istanbul ignore else\r\n if (this.htmlElement)\r\n UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n else\r\n UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n\r\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: record.value.value,\r\n displayValue,\r\n };\r\n }\r\n }\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._inputElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n return document.activeElement === this._inputElement.current;\r\n }\r\n\r\n private shouldSetFocus(): boolean {\r\n if (!this.props.setFocus)\r\n return false;\r\n\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n\r\n return (!disabled && !readonly);\r\n }\r\n\r\n private _applyUpdatedValue(userInput: string) {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n\r\n if (readonly || disabled)\r\n return;\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n inputValue: userInput,\r\n });\r\n }\r\n\r\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n this._applyUpdatedValue(e.target.value);\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private _getInitialDisplayValue(): string {\r\n const record = this.props.propertyRecord;\r\n let initialDisplayValue = \"\";\r\n let numberValue = 0;\r\n // istanbul ignore else\r\n if (record) {\r\n // istanbul ignore else\r\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = record.value;\r\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\r\n // istanbul ignore else\r\n if (primitiveValue.displayValue)\r\n initialDisplayValue = primitiveValue.displayValue;\r\n else\r\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\r\n }\r\n }\r\n\r\n return initialDisplayValue;\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n // istanbul ignore next\r\n if (!record || !record.property) {\r\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n // eslint-disable-next-line no-console\r\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n return;\r\n }\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\r\n }\r\n\r\n if (!this._formatParams) {\r\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\r\n // eslint-disable-next-line no-console\r\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\r\n return;\r\n }\r\n\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n let size: number | undefined;\r\n let maxLength: number | undefined;\r\n let iconSpec: string | undefined;\r\n\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\r\n // istanbul ignore else\r\n if (editorSizeParams) {\r\n // istanbul ignore else\r\n if (editorSizeParams.size)\r\n size = editorSizeParams.size;\r\n // istanbul ignore else\r\n if (editorSizeParams.maxLength)\r\n maxLength = editorSizeParams.maxLength;\r\n }\r\n\r\n const iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\r\n if (iconParams) {\r\n iconSpec = iconParams.definition.iconSpec;\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\r\n }\r\n\r\n private _resetToOriginalValue() {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n\r\n this.setState({ inputValue: initialDisplayValue });\r\n }\r\n\r\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Escape) {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n if (initialDisplayValue !== this.state.inputValue) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n this._resetToOriginalValue();\r\n } else {\r\n // istanbul ignore else\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (e.key !== SpecialKey.Enter) {\r\n UiAdmin.messagePresenter.closeInputFieldMessage();\r\n }\r\n };\r\n\r\n // istanbul ignore next\r\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\r\n e.target.select();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const minSize = this.state.size ? this.state.size : 8;\r\n const minWidthStyle: React.CSSProperties = {\r\n minWidth: `${minSize * 0.75}em`,\r\n };\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n if (!record || !this._formatParams)\r\n return null;\r\n\r\n const readOnly = !record.isReadonly ? false : true;\r\n const disabled = !record.isDisabled ? false : true;\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\r\n\r\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\r\n className,\r\n style: this.props.style ? this.props.style : minWidthStyle,\r\n readOnly,\r\n disabled,\r\n maxLength: this.state.maxLength,\r\n value: this.state.inputValue,\r\n onChange: this._updateInputValue,\r\n onBlur: this.props.onBlur,\r\n onFocus: this._onFocus,\r\n setFocus: this.shouldSetFocus(),\r\n onKeyDown: this._onKeyPress,\r\n };\r\n\r\n let reactNode: React.ReactNode;\r\n if (this.state.iconSpec) {\r\n const icon = <Icon iconSpec={this.state.iconSpec} />;\r\n reactNode = (\r\n <IconInput\r\n {...inputProps}\r\n ref={this._inputElement}\r\n icon={icon}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n } else {\r\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\r\n reactNode = (\r\n // eslint-disable-next-line deprecation/deprecation\r\n <Input\r\n {...inputProps}\r\n ref={this._inputElement}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n }\r\n\r\n return reactNode;\r\n }\r\n}\r\n\r\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\r\n * It uses the [[CustomNumberEditor]] React component.\r\n * @alpha\r\n */\r\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <CustomNumberEditor />;\r\n }\r\n public override get containerHandlesEscape(): boolean {\r\n return false;\r\n }\r\n}\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAA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Yd,eAAe;IAkB7B,OAAO,CAAC,mBAAmB,CAEzB;IAEF,OAAO,CAAC,sBAAsB,CAM5B;IAEF,OAAO,CAAC,OAAO,CAkBb;IAEF,OAAO,CAAC,mBAAmB,CAEzB;IAEF,OAAO,CAAC,aAAa,CAEnB;IAEF,gBAAgB;IACA,MAAM;CAevB"}
@@ -154,9 +154,9 @@ class EditorContainer extends React.PureComponent {
154
154
  const htmlElement = this._editorRef && this._editorRef.htmlElement;
155
155
  // istanbul ignore else
156
156
  if (htmlElement)
157
- appui_abstract_1.UiAbstract.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);
157
+ appui_abstract_1.UiAdmin.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);
158
158
  else
159
- appui_abstract_1.UiAbstract.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);
159
+ appui_abstract_1.UiAdmin.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);
160
160
  }
161
161
  }
162
162
  async isNewValueValid(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContainer.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,kCAAgC;AAChC,6CAA+B;AAC/B,0DAA8F;AAE9F,mEAAuG;AA6DvG;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK,CAAC,aAAmC;IAA9E;;QAkCU,sBAAiB,GAAG,CAAC,EAAoB,EAAE,EAAE;YACnD,uBAAuB;YACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,oBAAoB;gBACnG,IAAI,CAAC,sBAA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ACnC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;gBACvD,OAAO,GAAG,KAAK,CAAC;aACjB;SACF;aAAM;YACL,OAAO,GAAG,KAAK,CAAC;SACjB;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IA0CD,gBAAgB;IACA,MAAM;QACpB,OAAO,CACL,8BAAM,SAAS,EAAC,6BAA6B,EAC3C,MAAM,EAAE,IAAI,CAAC,oBAAoB,EACjC,SAAS,EAAE,IAAI,CAAC,cAAc,EAC9B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,iBAAiB,EACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACX,kBAAkB,EAC9B,IAAI,EAAC,cAAc,IAElB,IAAI,CAAC,YAAY,EAAE,CACf,CACR,CAAC;IACJ,CAAC;CACF;AApLD,0CAoLC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EditorContainer.scss\";\r\nimport * as React from \"react\";\r\nimport { PropertyRecord, PropertyValue, SpecialKey, UiAbstract } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { AsyncErrorMessage, PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** Arguments for the Property Updated event callback\r\n * @public\r\n */\r\nexport interface PropertyUpdatedArgs {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** The new value for the property. */\r\n newValue: PropertyValue;\r\n}\r\n\r\n/** Properties for a property editor component\r\n * @public\r\n */\r\nexport interface PropertyEditorProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord?: PropertyRecord;\r\n /** Handler for commit */\r\n onCommit?: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel?: () => void;\r\n /** Handler for blur */\r\n onBlur?: (event: React.FocusEvent) => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n}\r\n\r\n/** [[EditorContainer]] React component properties\r\n * @public\r\n */\r\nexport interface EditorContainerProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** Tooltip text */\r\n title?: string;\r\n /** Handler for commit */\r\n onCommit: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel: () => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n\r\n /** @internal */\r\n ignoreEditorBlur?: boolean;\r\n}\r\n\r\n/** @internal */\r\ninterface CloneProps extends PropertyEditorProps {\r\n ref: (ref: any) => void;\r\n}\r\n\r\n/** Interface implemented by React based type editors\r\n * @public\r\n */\r\nexport interface TypeEditor {\r\n getPropertyValue: () => Promise<PropertyValue | undefined>;\r\n htmlElement: HTMLElement | null;\r\n hasFocus: boolean;\r\n}\r\n\r\n/**\r\n * EditorContainer React component used by the Table, Tree and PropertyGrid for cell editing.\r\n * @public\r\n */\r\nexport class EditorContainer extends React.PureComponent<EditorContainerProps> {\r\n\r\n private _editorRef: TypeEditor | undefined;\r\n private _propertyEditor: PropertyEditorBase | undefined;\r\n\r\n private createEditor(): React.ReactNode {\r\n const editorRef = (ref: TypeEditor | undefined) => this._editorRef = ref;\r\n\r\n const editorProps: CloneProps = {\r\n ref: editorRef,\r\n onCommit: this._handleEditorCommit,\r\n onCancel: this._handleEditorCancel,\r\n onBlur: this._handleEditorBlur,\r\n propertyRecord: this.props.propertyRecord,\r\n setFocus: this.props.setFocus !== undefined ? this.props.setFocus : true,\r\n className: this.props.className,\r\n style: this.props.style,\r\n };\r\n\r\n const propDescription = this.props.propertyRecord.property;\r\n\r\n const editorName = propDescription.editor !== undefined ? propDescription.editor.name : undefined;\r\n this._propertyEditor = PropertyEditorManager.createEditor(propDescription.typename, editorName, propDescription.dataController);\r\n const editorNode: React.ReactNode = this._propertyEditor.reactNode;\r\n\r\n let clonedNode: React.ReactNode = null;\r\n // istanbul ignore else\r\n if (React.isValidElement(editorNode)) {\r\n clonedNode = React.cloneElement(editorNode, editorProps);\r\n }\r\n\r\n return clonedNode;\r\n }\r\n\r\n private _handleEditorBlur = (_e: React.FocusEvent) => {\r\n // istanbul ignore else\r\n if (!this.props.ignoreEditorBlur && this._propertyEditor && this._propertyEditor.containerHandlesBlur)\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerBlur = (e: React.FocusEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleKeyDown = (e: React.KeyboardEvent) => {\r\n switch (e.key) {\r\n case SpecialKey.Escape:\r\n this.onPressEscape(e);\r\n break;\r\n case SpecialKey.Enter:\r\n this.onPressEnter(e);\r\n break;\r\n case SpecialKey.Tab:\r\n this.onPressTab(e);\r\n break;\r\n default:\r\n if (this._propertyEditor && this._propertyEditor.containerStopsKeydownPropagation)\r\n e.stopPropagation();\r\n }\r\n };\r\n\r\n private _handleRightClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private onPressEscape(_e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEscape) {\r\n this._commitCancel();\r\n }\r\n }\r\n\r\n private onPressEnter(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEnter) {\r\n // istanbul ignore else\r\n if (this._editorRef && this._editorRef.hasFocus)\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private onPressTab(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesTab) {\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private displayOutputMessage(errorMessage: AsyncErrorMessage | undefined) {\r\n // istanbul ignore else\r\n if (errorMessage && this._editorRef) {\r\n const htmlElement = this._editorRef && this._editorRef.htmlElement;\r\n // istanbul ignore else\r\n if (htmlElement)\r\n UiAbstract.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);\r\n else\r\n UiAbstract.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);\r\n }\r\n }\r\n\r\n private async isNewValueValid(value: PropertyValue): Promise<boolean> {\r\n let isValid = true;\r\n\r\n // istanbul ignore else\r\n if (this._propertyEditor && this.props.propertyRecord) {\r\n const validateResult = await this._propertyEditor.validateValue(value, this.props.propertyRecord);\r\n\r\n if (validateResult.encounteredError) {\r\n this.displayOutputMessage(validateResult.errorMessage);\r\n isValid = false;\r\n }\r\n } else {\r\n isValid = false;\r\n }\r\n\r\n return isValid;\r\n }\r\n\r\n private _handleEditorCommit = (args: PropertyUpdatedArgs): void => {\r\n this._commit(args); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerCommit = async (): Promise<void> => {\r\n const newValue = this._editorRef && await this._editorRef.getPropertyValue();\r\n // istanbul ignore else\r\n if (newValue !== undefined) {\r\n this._commit({ propertyRecord: this.props.propertyRecord, newValue }); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n };\r\n\r\n private _commit = async (args: PropertyUpdatedArgs) => {\r\n const newValue = args.newValue;\r\n const isValid = await this.isNewValueValid(newValue);\r\n if (isValid) {\r\n let doCommit = true;\r\n // istanbul ignore else\r\n if (this._propertyEditor && args.propertyRecord) {\r\n const commitResult = await this._propertyEditor.commitValue(newValue, args.propertyRecord);\r\n if (commitResult.encounteredError) {\r\n this.displayOutputMessage(commitResult.errorMessage);\r\n doCommit = false;\r\n }\r\n }\r\n\r\n if (doCommit) {\r\n this.props.onCommit(args);\r\n }\r\n }\r\n };\r\n\r\n private _handleEditorCancel = () => {\r\n this._commitCancel();\r\n };\r\n\r\n private _commitCancel = () => {\r\n this.props.onCancel();\r\n };\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <span className=\"components-editor-container\"\r\n onBlur={this._handleContainerBlur}\r\n onKeyDown={this._handleKeyDown}\r\n onClick={this._handleClick}\r\n onContextMenu={this._handleRightClick}\r\n title={this.props.title}\r\n data-testid=\"editor-container\"\r\n role=\"presentation\"\r\n >\r\n {this.createEditor()}\r\n </span>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"EditorContainer.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,kCAAgC;AAChC,6CAA+B;AAC/B,0DAA2F;AAE3F,mEAAuG;AA6DvG;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK,CAAC,aAAmC;IAA9E;;QAkCU,sBAAiB,GAAG,CAAC,EAAoB,EAAE,EAAE;YACnD,uBAAuB;YACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,oBAAoB;gBACnG,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,8DAA8D;QACjG,CAAC,CAAC;QAEM,yBAAoB,GAAG,CAAC,CAAmB,EAAE,EAAE;YACrD,CAAC,CAAC,eAAe,EAAE,CAAC;QACtB,CAAC,CAAC;QAEM,iBAAY,GAAG,CAAC,CAAmB,EAAE,EAAE;YAC7C,CAAC,CAAC,eAAe,EAAE,CAAC;QACtB,CAAC,CAAC;QAEM,mBAAc,GAAG,CAAC,CAAsB,EAAE,EAAE;Y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C,SAAS,EAAE,IAAI,CAAC,cAAc,EAC9B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,iBAAiB,EACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACX,kBAAkB,EAC9B,IAAI,EAAC,cAAc,IAElB,IAAI,CAAC,YAAY,EAAE,CACf,CACR,CAAC;IACJ,CAAC;CACF;AApLD,0CAoLC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EditorContainer.scss\";\r\nimport * as React from \"react\";\r\nimport { PropertyRecord, PropertyValue, SpecialKey, UiAdmin } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { AsyncErrorMessage, PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** Arguments for the Property Updated event callback\r\n * @public\r\n */\r\nexport interface PropertyUpdatedArgs {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** The new value for the property. */\r\n newValue: PropertyValue;\r\n}\r\n\r\n/** Properties for a property editor component\r\n * @public\r\n */\r\nexport interface PropertyEditorProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord?: PropertyRecord;\r\n /** Handler for commit */\r\n onCommit?: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel?: () => void;\r\n /** Handler for blur */\r\n onBlur?: (event: React.FocusEvent) => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n}\r\n\r\n/** [[EditorContainer]] React component properties\r\n * @public\r\n */\r\nexport interface EditorContainerProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** Tooltip text */\r\n title?: string;\r\n /** Handler for commit */\r\n onCommit: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel: () => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n\r\n /** @internal */\r\n ignoreEditorBlur?: boolean;\r\n}\r\n\r\n/** @internal */\r\ninterface CloneProps extends PropertyEditorProps {\r\n ref: (ref: any) => void;\r\n}\r\n\r\n/** Interface implemented by React based type editors\r\n * @public\r\n */\r\nexport interface TypeEditor {\r\n getPropertyValue: () => Promise<PropertyValue | undefined>;\r\n htmlElement: HTMLElement | null;\r\n hasFocus: boolean;\r\n}\r\n\r\n/**\r\n * EditorContainer React component used by the Table, Tree and PropertyGrid for cell editing.\r\n * @public\r\n */\r\nexport class EditorContainer extends React.PureComponent<EditorContainerProps> {\r\n\r\n private _editorRef: TypeEditor | undefined;\r\n private _propertyEditor: PropertyEditorBase | undefined;\r\n\r\n private createEditor(): React.ReactNode {\r\n const editorRef = (ref: TypeEditor | undefined) => this._editorRef = ref;\r\n\r\n const editorProps: CloneProps = {\r\n ref: editorRef,\r\n onCommit: this._handleEditorCommit,\r\n onCancel: this._handleEditorCancel,\r\n onBlur: this._handleEditorBlur,\r\n propertyRecord: this.props.propertyRecord,\r\n setFocus: this.props.setFocus !== undefined ? this.props.setFocus : true,\r\n className: this.props.className,\r\n style: this.props.style,\r\n };\r\n\r\n const propDescription = this.props.propertyRecord.property;\r\n\r\n const editorName = propDescription.editor !== undefined ? propDescription.editor.name : undefined;\r\n this._propertyEditor = PropertyEditorManager.createEditor(propDescription.typename, editorName, propDescription.dataController);\r\n const editorNode: React.ReactNode = this._propertyEditor.reactNode;\r\n\r\n let clonedNode: React.ReactNode = null;\r\n // istanbul ignore else\r\n if (React.isValidElement(editorNode)) {\r\n clonedNode = React.cloneElement(editorNode, editorProps);\r\n }\r\n\r\n return clonedNode;\r\n }\r\n\r\n private _handleEditorBlur = (_e: React.FocusEvent) => {\r\n // istanbul ignore else\r\n if (!this.props.ignoreEditorBlur && this._propertyEditor && this._propertyEditor.containerHandlesBlur)\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerBlur = (e: React.FocusEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleKeyDown = (e: React.KeyboardEvent) => {\r\n switch (e.key) {\r\n case SpecialKey.Escape:\r\n this.onPressEscape(e);\r\n break;\r\n case SpecialKey.Enter:\r\n this.onPressEnter(e);\r\n break;\r\n case SpecialKey.Tab:\r\n this.onPressTab(e);\r\n break;\r\n default:\r\n if (this._propertyEditor && this._propertyEditor.containerStopsKeydownPropagation)\r\n e.stopPropagation();\r\n }\r\n };\r\n\r\n private _handleRightClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private onPressEscape(_e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEscape) {\r\n this._commitCancel();\r\n }\r\n }\r\n\r\n private onPressEnter(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEnter) {\r\n // istanbul ignore else\r\n if (this._editorRef && this._editorRef.hasFocus)\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private onPressTab(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesTab) {\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private displayOutputMessage(errorMessage: AsyncErrorMessage | undefined) {\r\n // istanbul ignore else\r\n if (errorMessage && this._editorRef) {\r\n const htmlElement = this._editorRef && this._editorRef.htmlElement;\r\n // istanbul ignore else\r\n if (htmlElement)\r\n UiAdmin.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);\r\n else\r\n UiAdmin.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);\r\n }\r\n }\r\n\r\n private async isNewValueValid(value: PropertyValue): Promise<boolean> {\r\n let isValid = true;\r\n\r\n // istanbul ignore else\r\n if (this._propertyEditor && this.props.propertyRecord) {\r\n const validateResult = await this._propertyEditor.validateValue(value, this.props.propertyRecord);\r\n\r\n if (validateResult.encounteredError) {\r\n this.displayOutputMessage(validateResult.errorMessage);\r\n isValid = false;\r\n }\r\n } else {\r\n isValid = false;\r\n }\r\n\r\n return isValid;\r\n }\r\n\r\n private _handleEditorCommit = (args: PropertyUpdatedArgs): void => {\r\n this._commit(args); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerCommit = async (): Promise<void> => {\r\n const newValue = this._editorRef && await this._editorRef.getPropertyValue();\r\n // istanbul ignore else\r\n if (newValue !== undefined) {\r\n this._commit({ propertyRecord: this.props.propertyRecord, newValue }); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n };\r\n\r\n private _commit = async (args: PropertyUpdatedArgs) => {\r\n const newValue = args.newValue;\r\n const isValid = await this.isNewValueValid(newValue);\r\n if (isValid) {\r\n let doCommit = true;\r\n // istanbul ignore else\r\n if (this._propertyEditor && args.propertyRecord) {\r\n const commitResult = await this._propertyEditor.commitValue(newValue, args.propertyRecord);\r\n if (commitResult.encounteredError) {\r\n this.displayOutputMessage(commitResult.errorMessage);\r\n doCommit = false;\r\n }\r\n }\r\n\r\n if (doCommit) {\r\n this.props.onCommit(args);\r\n }\r\n }\r\n };\r\n\r\n private _handleEditorCancel = () => {\r\n this._commitCancel();\r\n };\r\n\r\n private _commitCancel = () => {\r\n this.props.onCancel();\r\n };\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <span className=\"components-editor-container\"\r\n onBlur={this._handleContainerBlur}\r\n onKeyDown={this._handleKeyDown}\r\n onClick={this._handleClick}\r\n onContextMenu={this._handleRightClick}\r\n title={this.props.title}\r\n data-testid=\"editor-container\"\r\n role=\"presentation\"\r\n >\r\n {this.createEditor()}\r\n </span>\r\n );\r\n }\r\n}\r\n"]}
@@ -11,14 +11,16 @@ export declare class UiComponents {
11
11
  private static _localization?;
12
12
  /**
13
13
  * Registers the localization service namespace for UiComponents. Also initializes UiCore.
14
- * @param localization The internationalization service created by the application.
14
+ * @param localization The internationalization service created by the host application.
15
15
  */
16
16
  static initialize(localization: Localization): Promise<void>;
17
17
  /** Unregisters the UiComponents localization namespace */
18
18
  static terminate(): void;
19
19
  /** Determines if UiComponents has been initialized */
20
20
  static get initialized(): boolean;
21
- /** The internationalization service created by the application. */
21
+ /** The internationalization service created by the host application.
22
+ * @internal
23
+ */
22
24
  static get localization(): Localization;
23
25
  /** The internationalization service namespace. */
24
26
  static get localizationNamespace(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAczE,0DAA0D;WAC5C,SAAS;IASvB,sDAAsD;IACtD,WAAkB,WAAW,IAAI,OAAO,CAAsC;IAE9E,mEAAmE;IACnE,WAAkB,YAAY,IAAI,YAAY,CAI7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAQvD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
1
+ {"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAczE,0DAA0D;WAC5C,SAAS;IASvB,sDAAsD;IACtD,WAAkB,WAAW,IAAI,OAAO,CAAsC;IAE9E;;OAEG;IACH,WAAkB,YAAY,IAAI,YAAY,CAI7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAQvD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
@@ -16,7 +16,7 @@ import { UiCore } from "@itwin/core-react";
16
16
  export class UiComponents {
17
17
  /**
18
18
  * Registers the localization service namespace for UiComponents. Also initializes UiCore.
19
- * @param localization The internationalization service created by the application.
19
+ * @param localization The internationalization service created by the host application.
20
20
  */
21
21
  static async initialize(localization) {
22
22
  if (UiComponents._initialized) {
@@ -39,7 +39,9 @@ export class UiComponents {
39
39
  }
40
40
  /** Determines if UiComponents has been initialized */
41
41
  static get initialized() { return UiComponents._initialized; }
42
- /** The internationalization service created by the application. */
42
+ /** The internationalization service created by the host application.
43
+ * @internal
44
+ */
43
45
  static get localization() {
44
46
  if (!UiComponents._localization)
45
47
  throw new UiError(UiComponents.loggerCategory(this), "_localization: UiComponents.initialize has not been called. Unable to return Localization object.");
@@ -1 +1 @@
1
- {"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE;YAC7B,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,wCAAwC,CAAC,CAAC;YACpG,OAAO;SACR;QAED,aAAa,EAAE,CAAC;QAChB,YAAY,CAAC,aAAa,GAAG,YAAY,CAAC;QAC1C,MAAM,YAAY,CAAC,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAEvF,MAAM,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACpD,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,0DAA0D;IACnD,MAAM,CAAC,SAAS;QACrB,IAAI,YAAY,CAAC,aAAa;YAC5B,YAAY,CAAC,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QACrF,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC;QAEvC,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,YAAY,CAAC,YAAY,GAAG,KAAK,CAAC;IACpC,CAAC;IAED,sDAAsD;IAC/C,MAAM,KAAK,WAAW,KAAc,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;IAE9E,mEAAmE;IAC5D,MAAM,KAAK,YAAY;QAC5B,IAAI,CAAC,YAAY,CAAC,aAAa;YAC7B,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,mGAAmG,CAAC,CAAC;QAC5J,OAAO,YAAY,CAAC,aAAa,CAAC;IACpC,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YAC7B,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,iFAAiF,CAAC,CAAC;YACtI,OAAO,EAAE,CAAC;SACX;QACD,OAAO,YAAY,CAAC,YAAY,CAAC,+BAA+B,CAAC,YAAY,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IAC5G,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/E,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAnEc,yBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { enablePatches } from \"immer\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { getClassName, UiError } from \"@itwin/appui-abstract\";\r\nimport { UiCore } from \"@itwin/core-react\";\r\n\r\n/**\r\n * Manages the localization service for the components-react package.\r\n * @public\r\n */\r\nexport class UiComponents {\r\n private static _initialized = false;\r\n private static _localization?: Localization;\r\n\r\n /**\r\n * Registers the localization service namespace for UiComponents. Also initializes UiCore.\r\n * @param localization The internationalization service created by the application.\r\n */\r\n public static async initialize(localization: Localization): Promise<void> {\r\n if (UiComponents._initialized) {\r\n Logger.logInfo(UiComponents.loggerCategory(UiComponents), `UiComponents.initialize already called`);\r\n return;\r\n }\r\n\r\n enablePatches();\r\n UiComponents._localization = localization;\r\n await UiComponents._localization.registerNamespace(UiComponents.localizationNamespace);\r\n\r\n await UiCore.initialize(UiComponents._localization);\r\n UiComponents._initialized = true;\r\n }\r\n\r\n /** Unregisters the UiComponents localization namespace */\r\n public static terminate() {\r\n if (UiComponents._localization)\r\n UiComponents._localization.unregisterNamespace(UiComponents.localizationNamespace);\r\n UiComponents._localization = undefined;\r\n\r\n UiCore.terminate();\r\n UiComponents._initialized = false;\r\n }\r\n\r\n /** Determines if UiComponents has been initialized */\r\n public static get initialized(): boolean { return UiComponents._initialized; }\r\n\r\n /** The internationalization service created by the application. */\r\n public static get localization(): Localization {\r\n if (!UiComponents._localization)\r\n throw new UiError(UiComponents.loggerCategory(this), \"_localization: UiComponents.initialize has not been called. Unable to return Localization object.\");\r\n return UiComponents._localization;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return \"UiComponents\";\r\n }\r\n\r\n /** @internal */\r\n public static get packageName(): string {\r\n return \"components-react\";\r\n }\r\n\r\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiComponents\" namespace. Do NOT include the namespace in the key.\r\n * @internal\r\n */\r\n public static translate(key: string | string[]): string {\r\n if (!UiComponents.initialized) {\r\n Logger.logError(UiComponents.loggerCategory(this), `translate: UiComponents.initialize has not been called. Returning blank string.`);\r\n return \"\";\r\n }\r\n return UiComponents.localization.getLocalizedStringWithNamespace(UiComponents.localizationNamespace, key);\r\n }\r\n\r\n /** @internal */\r\n public static loggerCategory(obj: any): string {\r\n const className = getClassName(obj);\r\n const category = UiComponents.packageName + (className ? `.${className}` : \"\");\r\n return category;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE;YAC7B,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,wCAAwC,CAAC,CAAC;YACpG,OAAO;SACR;QAED,aAAa,EAAE,CAAC;QAChB,YAAY,CAAC,aAAa,GAAG,YAAY,CAAC;QAC1C,MAAM,YAAY,CAAC,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAEvF,MAAM,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACpD,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,0DAA0D;IACnD,MAAM,CAAC,SAAS;QACrB,IAAI,YAAY,CAAC,aAAa;YAC5B,YAAY,CAAC,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AAC;IAClB,CAAC;;AArEc,yBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { enablePatches } from \"immer\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { getClassName, UiError } from \"@itwin/appui-abstract\";\r\nimport { UiCore } from \"@itwin/core-react\";\r\n\r\n/**\r\n * Manages the localization service for the components-react package.\r\n * @public\r\n */\r\nexport class UiComponents {\r\n private static _initialized = false;\r\n private static _localization?: Localization;\r\n\r\n /**\r\n * Registers the localization service namespace for UiComponents. Also initializes UiCore.\r\n * @param localization The internationalization service created by the host application.\r\n */\r\n public static async initialize(localization: Localization): Promise<void> {\r\n if (UiComponents._initialized) {\r\n Logger.logInfo(UiComponents.loggerCategory(UiComponents), `UiComponents.initialize already called`);\r\n return;\r\n }\r\n\r\n enablePatches();\r\n UiComponents._localization = localization;\r\n await UiComponents._localization.registerNamespace(UiComponents.localizationNamespace);\r\n\r\n await UiCore.initialize(UiComponents._localization);\r\n UiComponents._initialized = true;\r\n }\r\n\r\n /** Unregisters the UiComponents localization namespace */\r\n public static terminate() {\r\n if (UiComponents._localization)\r\n UiComponents._localization.unregisterNamespace(UiComponents.localizationNamespace);\r\n UiComponents._localization = undefined;\r\n\r\n UiCore.terminate();\r\n UiComponents._initialized = false;\r\n }\r\n\r\n /** Determines if UiComponents has been initialized */\r\n public static get initialized(): boolean { return UiComponents._initialized; }\r\n\r\n /** The internationalization service created by the host application.\r\n * @internal\r\n */\r\n public static get localization(): Localization {\r\n if (!UiComponents._localization)\r\n throw new UiError(UiComponents.loggerCategory(this), \"_localization: UiComponents.initialize has not been called. Unable to return Localization object.\");\r\n return UiComponents._localization;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return \"UiComponents\";\r\n }\r\n\r\n /** @internal */\r\n public static get packageName(): string {\r\n return \"components-react\";\r\n }\r\n\r\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiComponents\" namespace. Do NOT include the namespace in the key.\r\n * @internal\r\n */\r\n public static translate(key: string | string[]): string {\r\n if (!UiComponents.initialized) {\r\n Logger.logError(UiComponents.loggerCategory(this), `translate: UiComponents.initialize has not been called. Returning blank string.`);\r\n return \"\";\r\n }\r\n return UiComponents.localization.getLocalizedStringWithNamespace(UiComponents.localizationNamespace, key);\r\n }\r\n\r\n /** @internal */\r\n public static loggerCategory(obj: any): string {\r\n const className = getClassName(obj);\r\n const category = UiComponents.packageName + (className ? `.${className}` : \"\");\r\n return category;\r\n }\r\n\r\n}\r\n"]}
@@ -10,7 +10,7 @@ import "./CustomNumberEditor.scss";
10
10
  import classnames from "classnames";
11
11
  import * as React from "react";
12
12
  import { Logger } from "@itwin/core-bentley";
13
- import { MessageSeverity, PropertyEditorParamTypes, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAbstract, } from "@itwin/appui-abstract";
13
+ import { MessageSeverity, PropertyEditorParamTypes, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin, } from "@itwin/appui-abstract";
14
14
  import { Icon, IconInput, Input } from "@itwin/core-react";
15
15
  import { UiComponents } from "../UiComponents";
16
16
  import { PropertyEditorBase, PropertyEditorManager } from "./PropertyEditorManager";
@@ -46,7 +46,7 @@ export class CustomNumberEditor extends React.PureComponent {
46
46
  }
47
47
  // istanbul ignore else
48
48
  if (e.key !== SpecialKey.Enter) {
49
- UiAbstract.messagePresenter.closeInputFieldMessage();
49
+ UiAdmin.messagePresenter.closeInputFieldMessage();
50
50
  }
51
51
  };
52
52
  // istanbul ignore next
@@ -83,9 +83,9 @@ export class CustomNumberEditor extends React.PureComponent {
83
83
  else {
84
84
  // istanbul ignore else
85
85
  if (this.htmlElement)
86
- UiAbstract.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate("errors.unable-to-parse-quantity"));
86
+ UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate("errors.unable-to-parse-quantity"));
87
87
  else
88
- UiAbstract.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate("errors.unable-to-parse-quantity"));
88
+ UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate("errors.unable-to-parse-quantity"));
89
89
  const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ this._formatParams.formatFunction(record.value.value);
90
90
  propertyValue = {
91
91
  valueFormat: PropertyValueFormat.Primitive,
@@ -1 +1 @@
1
- {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACiE,eAAe,EAAwC,wBAAwB,EACtH,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,GACnH,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAA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AAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE;YAC/B,SAAS,EAAE,IAAI,CAAC,WAAW;SAC5B,CAAC;QAEF,IAAI,SAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,gCAAgC,GAC5C,CACH,CAAC;SACH;aAAM;YACL,uFAAuF;YACvF,SAAS,GAAG;YACV,mDAAmD;YACnD,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,GAC5C,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\n// cSpell:ignore customnumber testid\r\n\r\nimport \"./CustomNumberEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\r\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAbstract,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon, IconInput, Input, InputProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** @internal */\r\ninterface CustomNumberEditorState {\r\n inputValue: string;\r\n size?: number;\r\n maxLength?: number;\r\n iconSpec?: string;\r\n}\r\n\r\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\r\n * @alpha\r\n */\r\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _formatParams: CustomFormattedNumberParams | undefined;\r\n private _inputElement = React.createRef<HTMLInputElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<CustomNumberEditorState> = {\r\n inputValue: \"\",\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n if (record.isReadonly) {\r\n return {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: (record.value as PrimitiveValue).value,\r\n displayValue: (record.value as PrimitiveValue).displayValue,\r\n };\r\n }\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\r\n if (!parseResults.parseError && undefined !== parseResults.value) {\r\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: parseResults.value,\r\n displayValue: newDisplayValue,\r\n };\r\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\r\n // istanbul ignore else\r\n if (newDisplayValue !== this.state.inputValue) {\r\n this.setState({ inputValue: newDisplayValue });\r\n }\r\n } else {\r\n // istanbul ignore else\r\n if (this.htmlElement)\r\n UiAbstract.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n else\r\n UiAbstract.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n\r\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: record.value.value,\r\n displayValue,\r\n };\r\n }\r\n }\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._inputElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n return document.activeElement === this._inputElement.current;\r\n }\r\n\r\n private shouldSetFocus(): boolean {\r\n if (!this.props.setFocus)\r\n return false;\r\n\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n\r\n return (!disabled && !readonly);\r\n }\r\n\r\n private _applyUpdatedValue(userInput: string) {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n\r\n if (readonly || disabled)\r\n return;\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n inputValue: userInput,\r\n });\r\n }\r\n\r\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n this._applyUpdatedValue(e.target.value);\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private _getInitialDisplayValue(): string {\r\n const record = this.props.propertyRecord;\r\n let initialDisplayValue = \"\";\r\n let numberValue = 0;\r\n // istanbul ignore else\r\n if (record) {\r\n // istanbul ignore else\r\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = record.value;\r\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\r\n // istanbul ignore else\r\n if (primitiveValue.displayValue)\r\n initialDisplayValue = primitiveValue.displayValue;\r\n else\r\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\r\n }\r\n }\r\n\r\n return initialDisplayValue;\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n // istanbul ignore next\r\n if (!record || !record.property) {\r\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n // eslint-disable-next-line no-console\r\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n return;\r\n }\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\r\n }\r\n\r\n if (!this._formatParams) {\r\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\r\n // eslint-disable-next-line no-console\r\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\r\n return;\r\n }\r\n\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n let size: number | undefined;\r\n let maxLength: number | undefined;\r\n let iconSpec: string | undefined;\r\n\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\r\n // istanbul ignore else\r\n if (editorSizeParams) {\r\n // istanbul ignore else\r\n if (editorSizeParams.size)\r\n size = editorSizeParams.size;\r\n // istanbul ignore else\r\n if (editorSizeParams.maxLength)\r\n maxLength = editorSizeParams.maxLength;\r\n }\r\n\r\n const iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\r\n if (iconParams) {\r\n iconSpec = iconParams.definition.iconSpec;\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\r\n }\r\n\r\n private _resetToOriginalValue() {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n\r\n this.setState({ inputValue: initialDisplayValue });\r\n }\r\n\r\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Escape) {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n if (initialDisplayValue !== this.state.inputValue) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n this._resetToOriginalValue();\r\n } else {\r\n // istanbul ignore else\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (e.key !== SpecialKey.Enter) {\r\n UiAbstract.messagePresenter.closeInputFieldMessage();\r\n }\r\n };\r\n\r\n // istanbul ignore next\r\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\r\n e.target.select();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const minSize = this.state.size ? this.state.size : 8;\r\n const minWidthStyle: React.CSSProperties = {\r\n minWidth: `${minSize * 0.75}em`,\r\n };\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n if (!record || !this._formatParams)\r\n return null;\r\n\r\n const readOnly = !record.isReadonly ? false : true;\r\n const disabled = !record.isDisabled ? false : true;\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\r\n\r\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\r\n className,\r\n style: this.props.style ? this.props.style : minWidthStyle,\r\n readOnly,\r\n disabled,\r\n maxLength: this.state.maxLength,\r\n value: this.state.inputValue,\r\n onChange: this._updateInputValue,\r\n onBlur: this.props.onBlur,\r\n onFocus: this._onFocus,\r\n setFocus: this.shouldSetFocus(),\r\n onKeyDown: this._onKeyPress,\r\n };\r\n\r\n let reactNode: React.ReactNode;\r\n if (this.state.iconSpec) {\r\n const icon = <Icon iconSpec={this.state.iconSpec} />;\r\n reactNode = (\r\n <IconInput\r\n {...inputProps}\r\n ref={this._inputElement}\r\n icon={icon}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n } else {\r\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\r\n reactNode = (\r\n // eslint-disable-next-line deprecation/deprecation\r\n <Input\r\n {...inputProps}\r\n ref={this._inputElement}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n }\r\n\r\n return reactNode;\r\n }\r\n}\r\n\r\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\r\n * It uses the [[CustomNumberEditor]] React component.\r\n * @alpha\r\n */\r\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <CustomNumberEditor />;\r\n }\r\n public override get containerHandlesEscape(): boolean {\r\n return false;\r\n }\r\n}\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\r\n"]}
1
+ {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACiE,eAAe,EAAwC,wBAAwB,EACtH,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,GAChH,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAUpF;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,aAA2D;IAAzG;;QACU,eAAU,GAAG,KAAK,CAAC;QAEnB,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAE5D,gBAAgB;QACS,UAAK,GAAsC;YAClE,UAAU,EAAE,EAAE;SACf,CAAC;QAiFM,sBAAiB,GAAG,CAAC,CAAsC,EAAE,EAAE;YACrE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC;QAiGM,gBAAW,GAAG,CAAC,CAAwC,EAAE,EAAE;YACjE,uBAAuB;YACvB,IAA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C5C,CACH,CAAC;SACH;aAAM;YACL,uFAAuF;YACvF,SAAS,GAAG;YACV,mDAAmD;YACnD,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,GAC5C,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\n// cSpell:ignore customnumber testid\r\n\r\nimport \"./CustomNumberEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\r\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon, IconInput, Input, InputProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** @internal */\r\ninterface CustomNumberEditorState {\r\n inputValue: string;\r\n size?: number;\r\n maxLength?: number;\r\n iconSpec?: string;\r\n}\r\n\r\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\r\n * @alpha\r\n */\r\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _formatParams: CustomFormattedNumberParams | undefined;\r\n private _inputElement = React.createRef<HTMLInputElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<CustomNumberEditorState> = {\r\n inputValue: \"\",\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n if (record.isReadonly) {\r\n return {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: (record.value as PrimitiveValue).value,\r\n displayValue: (record.value as PrimitiveValue).displayValue,\r\n };\r\n }\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\r\n if (!parseResults.parseError && undefined !== parseResults.value) {\r\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: parseResults.value,\r\n displayValue: newDisplayValue,\r\n };\r\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\r\n // istanbul ignore else\r\n if (newDisplayValue !== this.state.inputValue) {\r\n this.setState({ inputValue: newDisplayValue });\r\n }\r\n } else {\r\n // istanbul ignore else\r\n if (this.htmlElement)\r\n UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n else\r\n UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n\r\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: record.value.value,\r\n displayValue,\r\n };\r\n }\r\n }\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._inputElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n return document.activeElement === this._inputElement.current;\r\n }\r\n\r\n private shouldSetFocus(): boolean {\r\n if (!this.props.setFocus)\r\n return false;\r\n\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n\r\n return (!disabled && !readonly);\r\n }\r\n\r\n private _applyUpdatedValue(userInput: string) {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n\r\n if (readonly || disabled)\r\n return;\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n inputValue: userInput,\r\n });\r\n }\r\n\r\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n this._applyUpdatedValue(e.target.value);\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private _getInitialDisplayValue(): string {\r\n const record = this.props.propertyRecord;\r\n let initialDisplayValue = \"\";\r\n let numberValue = 0;\r\n // istanbul ignore else\r\n if (record) {\r\n // istanbul ignore else\r\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = record.value;\r\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\r\n // istanbul ignore else\r\n if (primitiveValue.displayValue)\r\n initialDisplayValue = primitiveValue.displayValue;\r\n else\r\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\r\n }\r\n }\r\n\r\n return initialDisplayValue;\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n // istanbul ignore next\r\n if (!record || !record.property) {\r\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n // eslint-disable-next-line no-console\r\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n return;\r\n }\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\r\n }\r\n\r\n if (!this._formatParams) {\r\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\r\n // eslint-disable-next-line no-console\r\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\r\n return;\r\n }\r\n\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n let size: number | undefined;\r\n let maxLength: number | undefined;\r\n let iconSpec: string | undefined;\r\n\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\r\n // istanbul ignore else\r\n if (editorSizeParams) {\r\n // istanbul ignore else\r\n if (editorSizeParams.size)\r\n size = editorSizeParams.size;\r\n // istanbul ignore else\r\n if (editorSizeParams.maxLength)\r\n maxLength = editorSizeParams.maxLength;\r\n }\r\n\r\n const iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\r\n if (iconParams) {\r\n iconSpec = iconParams.definition.iconSpec;\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\r\n }\r\n\r\n private _resetToOriginalValue() {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n\r\n this.setState({ inputValue: initialDisplayValue });\r\n }\r\n\r\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Escape) {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n if (initialDisplayValue !== this.state.inputValue) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n this._resetToOriginalValue();\r\n } else {\r\n // istanbul ignore else\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (e.key !== SpecialKey.Enter) {\r\n UiAdmin.messagePresenter.closeInputFieldMessage();\r\n }\r\n };\r\n\r\n // istanbul ignore next\r\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\r\n e.target.select();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const minSize = this.state.size ? this.state.size : 8;\r\n const minWidthStyle: React.CSSProperties = {\r\n minWidth: `${minSize * 0.75}em`,\r\n };\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n if (!record || !this._formatParams)\r\n return null;\r\n\r\n const readOnly = !record.isReadonly ? false : true;\r\n const disabled = !record.isDisabled ? false : true;\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\r\n\r\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\r\n className,\r\n style: this.props.style ? this.props.style : minWidthStyle,\r\n readOnly,\r\n disabled,\r\n maxLength: this.state.maxLength,\r\n value: this.state.inputValue,\r\n onChange: this._updateInputValue,\r\n onBlur: this.props.onBlur,\r\n onFocus: this._onFocus,\r\n setFocus: this.shouldSetFocus(),\r\n onKeyDown: this._onKeyPress,\r\n };\r\n\r\n let reactNode: React.ReactNode;\r\n if (this.state.iconSpec) {\r\n const icon = <Icon iconSpec={this.state.iconSpec} />;\r\n reactNode = (\r\n <IconInput\r\n {...inputProps}\r\n ref={this._inputElement}\r\n icon={icon}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n } else {\r\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\r\n reactNode = (\r\n // eslint-disable-next-line deprecation/deprecation\r\n <Input\r\n {...inputProps}\r\n ref={this._inputElement}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n }\r\n\r\n return reactNode;\r\n }\r\n}\r\n\r\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\r\n * It uses the [[CustomNumberEditor]] React component.\r\n * @alpha\r\n */\r\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <CustomNumberEditor />;\r\n }\r\n public override get containerHandlesEscape(): boolean {\r\n return false;\r\n }\r\n}\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC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AkBb;IAEF,OAAO,CAAC,mBAAmB,CAEzB;IAEF,OAAO,CAAC,aAAa,CAEnB;IAEF,gBAAgB;IACA,MAAM;CAevB"}
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import "./EditorContainer.scss";
9
9
  import * as React from "react";
10
- import { SpecialKey, UiAbstract } from "@itwin/appui-abstract";
10
+ import { SpecialKey, UiAdmin } from "@itwin/appui-abstract";
11
11
  import { PropertyEditorManager } from "./PropertyEditorManager";
12
12
  /**
13
13
  * EditorContainer React component used by the Table, Tree and PropertyGrid for cell editing.
@@ -132,9 +132,9 @@ export class EditorContainer extends React.PureComponent {
132
132
  const htmlElement = this._editorRef && this._editorRef.htmlElement;
133
133
  // istanbul ignore else
134
134
  if (htmlElement)
135
- UiAbstract.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);
135
+ UiAdmin.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);
136
136
  else
137
- UiAbstract.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);
137
+ UiAdmin.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);
138
138
  }
139
139
  }
140
140
  async isNewValueValid(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContainer.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAiC,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE9F,OAAO,EAAyC,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA6DvG;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,aAAmC;I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I,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YACrD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAElG,IAAI,cAAc,CAAC,gBAAgB,EAAE;gBACnC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;gBACvD,OAAO,GAAG,KAAK,CAAC;aACjB;SACF;aAAM;YACL,OAAO,GAAG,KAAK,CAAC;SACjB;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IA0CD,gBAAgB;IACA,MAAM;QACpB,OAAO,CACL,8BAAM,SAAS,EAAC,6BAA6B,EAC3C,MAAM,EAAE,IAAI,CAAC,oBAAoB,EACjC,SAAS,EAAE,IAAI,CAAC,cAAc,EAC9B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,iBAAiB,EACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACX,kBAAkB,EAC9B,IAAI,EAAC,cAAc,IAElB,IAAI,CAAC,YAAY,EAAE,CACf,CACR,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EditorContainer.scss\";\r\nimport * as React from \"react\";\r\nimport { PropertyRecord, PropertyValue, SpecialKey, UiAbstract } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { AsyncErrorMessage, PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** Arguments for the Property Updated event callback\r\n * @public\r\n */\r\nexport interface PropertyUpdatedArgs {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** The new value for the property. */\r\n newValue: PropertyValue;\r\n}\r\n\r\n/** Properties for a property editor component\r\n * @public\r\n */\r\nexport interface PropertyEditorProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord?: PropertyRecord;\r\n /** Handler for commit */\r\n onCommit?: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel?: () => void;\r\n /** Handler for blur */\r\n onBlur?: (event: React.FocusEvent) => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n}\r\n\r\n/** [[EditorContainer]] React component properties\r\n * @public\r\n */\r\nexport interface EditorContainerProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** Tooltip text */\r\n title?: string;\r\n /** Handler for commit */\r\n onCommit: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel: () => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n\r\n /** @internal */\r\n ignoreEditorBlur?: boolean;\r\n}\r\n\r\n/** @internal */\r\ninterface CloneProps extends PropertyEditorProps {\r\n ref: (ref: any) => void;\r\n}\r\n\r\n/** Interface implemented by React based type editors\r\n * @public\r\n */\r\nexport interface TypeEditor {\r\n getPropertyValue: () => Promise<PropertyValue | undefined>;\r\n htmlElement: HTMLElement | null;\r\n hasFocus: boolean;\r\n}\r\n\r\n/**\r\n * EditorContainer React component used by the Table, Tree and PropertyGrid for cell editing.\r\n * @public\r\n */\r\nexport class EditorContainer extends React.PureComponent<EditorContainerProps> {\r\n\r\n private _editorRef: TypeEditor | undefined;\r\n private _propertyEditor: PropertyEditorBase | undefined;\r\n\r\n private createEditor(): React.ReactNode {\r\n const editorRef = (ref: TypeEditor | undefined) => this._editorRef = ref;\r\n\r\n const editorProps: CloneProps = {\r\n ref: editorRef,\r\n onCommit: this._handleEditorCommit,\r\n onCancel: this._handleEditorCancel,\r\n onBlur: this._handleEditorBlur,\r\n propertyRecord: this.props.propertyRecord,\r\n setFocus: this.props.setFocus !== undefined ? this.props.setFocus : true,\r\n className: this.props.className,\r\n style: this.props.style,\r\n };\r\n\r\n const propDescription = this.props.propertyRecord.property;\r\n\r\n const editorName = propDescription.editor !== undefined ? propDescription.editor.name : undefined;\r\n this._propertyEditor = PropertyEditorManager.createEditor(propDescription.typename, editorName, propDescription.dataController);\r\n const editorNode: React.ReactNode = this._propertyEditor.reactNode;\r\n\r\n let clonedNode: React.ReactNode = null;\r\n // istanbul ignore else\r\n if (React.isValidElement(editorNode)) {\r\n clonedNode = React.cloneElement(editorNode, editorProps);\r\n }\r\n\r\n return clonedNode;\r\n }\r\n\r\n private _handleEditorBlur = (_e: React.FocusEvent) => {\r\n // istanbul ignore else\r\n if (!this.props.ignoreEditorBlur && this._propertyEditor && this._propertyEditor.containerHandlesBlur)\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerBlur = (e: React.FocusEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleKeyDown = (e: React.KeyboardEvent) => {\r\n switch (e.key) {\r\n case SpecialKey.Escape:\r\n this.onPressEscape(e);\r\n break;\r\n case SpecialKey.Enter:\r\n this.onPressEnter(e);\r\n break;\r\n case SpecialKey.Tab:\r\n this.onPressTab(e);\r\n break;\r\n default:\r\n if (this._propertyEditor && this._propertyEditor.containerStopsKeydownPropagation)\r\n e.stopPropagation();\r\n }\r\n };\r\n\r\n private _handleRightClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private onPressEscape(_e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEscape) {\r\n this._commitCancel();\r\n }\r\n }\r\n\r\n private onPressEnter(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEnter) {\r\n // istanbul ignore else\r\n if (this._editorRef && this._editorRef.hasFocus)\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private onPressTab(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesTab) {\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private displayOutputMessage(errorMessage: AsyncErrorMessage | undefined) {\r\n // istanbul ignore else\r\n if (errorMessage && this._editorRef) {\r\n const htmlElement = this._editorRef && this._editorRef.htmlElement;\r\n // istanbul ignore else\r\n if (htmlElement)\r\n UiAbstract.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);\r\n else\r\n UiAbstract.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);\r\n }\r\n }\r\n\r\n private async isNewValueValid(value: PropertyValue): Promise<boolean> {\r\n let isValid = true;\r\n\r\n // istanbul ignore else\r\n if (this._propertyEditor && this.props.propertyRecord) {\r\n const validateResult = await this._propertyEditor.validateValue(value, this.props.propertyRecord);\r\n\r\n if (validateResult.encounteredError) {\r\n this.displayOutputMessage(validateResult.errorMessage);\r\n isValid = false;\r\n }\r\n } else {\r\n isValid = false;\r\n }\r\n\r\n return isValid;\r\n }\r\n\r\n private _handleEditorCommit = (args: PropertyUpdatedArgs): void => {\r\n this._commit(args); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerCommit = async (): Promise<void> => {\r\n const newValue = this._editorRef && await this._editorRef.getPropertyValue();\r\n // istanbul ignore else\r\n if (newValue !== undefined) {\r\n this._commit({ propertyRecord: this.props.propertyRecord, newValue }); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n };\r\n\r\n private _commit = async (args: PropertyUpdatedArgs) => {\r\n const newValue = args.newValue;\r\n const isValid = await this.isNewValueValid(newValue);\r\n if (isValid) {\r\n let doCommit = true;\r\n // istanbul ignore else\r\n if (this._propertyEditor && args.propertyRecord) {\r\n const commitResult = await this._propertyEditor.commitValue(newValue, args.propertyRecord);\r\n if (commitResult.encounteredError) {\r\n this.displayOutputMessage(commitResult.errorMessage);\r\n doCommit = false;\r\n }\r\n }\r\n\r\n if (doCommit) {\r\n this.props.onCommit(args);\r\n }\r\n }\r\n };\r\n\r\n private _handleEditorCancel = () => {\r\n this._commitCancel();\r\n };\r\n\r\n private _commitCancel = () => {\r\n this.props.onCancel();\r\n };\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <span className=\"components-editor-container\"\r\n onBlur={this._handleContainerBlur}\r\n onKeyDown={this._handleKeyDown}\r\n onClick={this._handleClick}\r\n onContextMenu={this._handleRightClick}\r\n title={this.props.title}\r\n data-testid=\"editor-container\"\r\n role=\"presentation\"\r\n >\r\n {this.createEditor()}\r\n </span>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"EditorContainer.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAiC,UAAU,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAyC,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA6DvG;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,aAAmC;IAA9E;;QAkCU,sBAAiB,GAAG,CAAC,EAAoB,EAAE,EAAE;YACnD,uBAAuB;YACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,oBAAoB;gBACnG,IAAI,CAAC,sBA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IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;gBACvD,OAAO,GAAG,KAAK,CAAC;aACjB;SACF;aAAM;YACL,OAAO,GAAG,KAAK,CAAC;SACjB;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IA0CD,gBAAgB;IACA,MAAM;QACpB,OAAO,CACL,8BAAM,SAAS,EAAC,6BAA6B,EAC3C,MAAM,EAAE,IAAI,CAAC,oBAAoB,EACjC,SAAS,EAAE,IAAI,CAAC,cAAc,EAC9B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,iBAAiB,EACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACX,kBAAkB,EAC9B,IAAI,EAAC,cAAc,IAElB,IAAI,CAAC,YAAY,EAAE,CACf,CACR,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EditorContainer.scss\";\r\nimport * as React from \"react\";\r\nimport { PropertyRecord, PropertyValue, SpecialKey, UiAdmin } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { AsyncErrorMessage, PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** Arguments for the Property Updated event callback\r\n * @public\r\n */\r\nexport interface PropertyUpdatedArgs {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** The new value for the property. */\r\n newValue: PropertyValue;\r\n}\r\n\r\n/** Properties for a property editor component\r\n * @public\r\n */\r\nexport interface PropertyEditorProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord?: PropertyRecord;\r\n /** Handler for commit */\r\n onCommit?: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel?: () => void;\r\n /** Handler for blur */\r\n onBlur?: (event: React.FocusEvent) => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n}\r\n\r\n/** [[EditorContainer]] React component properties\r\n * @public\r\n */\r\nexport interface EditorContainerProps extends CommonProps {\r\n /** The property being updated. */\r\n propertyRecord: PropertyRecord;\r\n /** Tooltip text */\r\n title?: string;\r\n /** Handler for commit */\r\n onCommit: (args: PropertyUpdatedArgs) => void;\r\n /** Handler for cancel */\r\n onCancel: () => void;\r\n /** Indicates whether the Property Editor should set focus */\r\n setFocus?: boolean;\r\n\r\n /** @internal */\r\n ignoreEditorBlur?: boolean;\r\n}\r\n\r\n/** @internal */\r\ninterface CloneProps extends PropertyEditorProps {\r\n ref: (ref: any) => void;\r\n}\r\n\r\n/** Interface implemented by React based type editors\r\n * @public\r\n */\r\nexport interface TypeEditor {\r\n getPropertyValue: () => Promise<PropertyValue | undefined>;\r\n htmlElement: HTMLElement | null;\r\n hasFocus: boolean;\r\n}\r\n\r\n/**\r\n * EditorContainer React component used by the Table, Tree and PropertyGrid for cell editing.\r\n * @public\r\n */\r\nexport class EditorContainer extends React.PureComponent<EditorContainerProps> {\r\n\r\n private _editorRef: TypeEditor | undefined;\r\n private _propertyEditor: PropertyEditorBase | undefined;\r\n\r\n private createEditor(): React.ReactNode {\r\n const editorRef = (ref: TypeEditor | undefined) => this._editorRef = ref;\r\n\r\n const editorProps: CloneProps = {\r\n ref: editorRef,\r\n onCommit: this._handleEditorCommit,\r\n onCancel: this._handleEditorCancel,\r\n onBlur: this._handleEditorBlur,\r\n propertyRecord: this.props.propertyRecord,\r\n setFocus: this.props.setFocus !== undefined ? this.props.setFocus : true,\r\n className: this.props.className,\r\n style: this.props.style,\r\n };\r\n\r\n const propDescription = this.props.propertyRecord.property;\r\n\r\n const editorName = propDescription.editor !== undefined ? propDescription.editor.name : undefined;\r\n this._propertyEditor = PropertyEditorManager.createEditor(propDescription.typename, editorName, propDescription.dataController);\r\n const editorNode: React.ReactNode = this._propertyEditor.reactNode;\r\n\r\n let clonedNode: React.ReactNode = null;\r\n // istanbul ignore else\r\n if (React.isValidElement(editorNode)) {\r\n clonedNode = React.cloneElement(editorNode, editorProps);\r\n }\r\n\r\n return clonedNode;\r\n }\r\n\r\n private _handleEditorBlur = (_e: React.FocusEvent) => {\r\n // istanbul ignore else\r\n if (!this.props.ignoreEditorBlur && this._propertyEditor && this._propertyEditor.containerHandlesBlur)\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerBlur = (e: React.FocusEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private _handleKeyDown = (e: React.KeyboardEvent) => {\r\n switch (e.key) {\r\n case SpecialKey.Escape:\r\n this.onPressEscape(e);\r\n break;\r\n case SpecialKey.Enter:\r\n this.onPressEnter(e);\r\n break;\r\n case SpecialKey.Tab:\r\n this.onPressTab(e);\r\n break;\r\n default:\r\n if (this._propertyEditor && this._propertyEditor.containerStopsKeydownPropagation)\r\n e.stopPropagation();\r\n }\r\n };\r\n\r\n private _handleRightClick = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n };\r\n\r\n private onPressEscape(_e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEscape) {\r\n this._commitCancel();\r\n }\r\n }\r\n\r\n private onPressEnter(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesEnter) {\r\n // istanbul ignore else\r\n if (this._editorRef && this._editorRef.hasFocus)\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private onPressTab(e: React.KeyboardEvent): void {\r\n // istanbul ignore else\r\n if (this._propertyEditor && this._propertyEditor.containerHandlesTab) {\r\n e.stopPropagation();\r\n this._handleContainerCommit(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private displayOutputMessage(errorMessage: AsyncErrorMessage | undefined) {\r\n // istanbul ignore else\r\n if (errorMessage && this._editorRef) {\r\n const htmlElement = this._editorRef && this._editorRef.htmlElement;\r\n // istanbul ignore else\r\n if (htmlElement)\r\n UiAdmin.messagePresenter.displayInputFieldMessage(htmlElement, errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage);\r\n else\r\n UiAdmin.messagePresenter.displayMessage(errorMessage.severity, errorMessage.briefMessage, errorMessage.detailedMessage, errorMessage.messageType);\r\n }\r\n }\r\n\r\n private async isNewValueValid(value: PropertyValue): Promise<boolean> {\r\n let isValid = true;\r\n\r\n // istanbul ignore else\r\n if (this._propertyEditor && this.props.propertyRecord) {\r\n const validateResult = await this._propertyEditor.validateValue(value, this.props.propertyRecord);\r\n\r\n if (validateResult.encounteredError) {\r\n this.displayOutputMessage(validateResult.errorMessage);\r\n isValid = false;\r\n }\r\n } else {\r\n isValid = false;\r\n }\r\n\r\n return isValid;\r\n }\r\n\r\n private _handleEditorCommit = (args: PropertyUpdatedArgs): void => {\r\n this._commit(args); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n };\r\n\r\n private _handleContainerCommit = async (): Promise<void> => {\r\n const newValue = this._editorRef && await this._editorRef.getPropertyValue();\r\n // istanbul ignore else\r\n if (newValue !== undefined) {\r\n this._commit({ propertyRecord: this.props.propertyRecord, newValue }); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n };\r\n\r\n private _commit = async (args: PropertyUpdatedArgs) => {\r\n const newValue = args.newValue;\r\n const isValid = await this.isNewValueValid(newValue);\r\n if (isValid) {\r\n let doCommit = true;\r\n // istanbul ignore else\r\n if (this._propertyEditor && args.propertyRecord) {\r\n const commitResult = await this._propertyEditor.commitValue(newValue, args.propertyRecord);\r\n if (commitResult.encounteredError) {\r\n this.displayOutputMessage(commitResult.errorMessage);\r\n doCommit = false;\r\n }\r\n }\r\n\r\n if (doCommit) {\r\n this.props.onCommit(args);\r\n }\r\n }\r\n };\r\n\r\n private _handleEditorCancel = () => {\r\n this._commitCancel();\r\n };\r\n\r\n private _commitCancel = () => {\r\n this.props.onCancel();\r\n };\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <span className=\"components-editor-container\"\r\n onBlur={this._handleContainerBlur}\r\n onKeyDown={this._handleKeyDown}\r\n onClick={this._handleClick}\r\n onContextMenu={this._handleRightClick}\r\n title={this.props.title}\r\n data-testid=\"editor-container\"\r\n role=\"presentation\"\r\n >\r\n {this.createEditor()}\r\n </span>\r\n );\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/components-react",
3
- "version": "3.0.0-dev.94",
3
+ "version": "3.0.0-dev.98",
4
4
  "description": "iModel.js UI complex components",
5
5
  "main": "lib/cjs/components-react.js",
6
6
  "module": "lib/esm/components-react.js",
@@ -21,10 +21,10 @@
21
21
  "url": "http://www.bentley.com"
22
22
  },
23
23
  "peerDependencies": {
24
- "@itwin/core-bentley": "^3.0.0-dev.94",
25
- "@itwin/core-i18n": "^3.0.0-dev.94",
26
- "@itwin/appui-abstract": "^3.0.0-dev.94",
27
- "@itwin/core-react": "^3.0.0-dev.94",
24
+ "@itwin/core-bentley": "^3.0.0-dev.98",
25
+ "@itwin/core-i18n": "^3.0.0-dev.98",
26
+ "@itwin/appui-abstract": "^3.0.0-dev.98",
27
+ "@itwin/core-react": "^3.0.0-dev.98",
28
28
  "react": "^17.0.0",
29
29
  "react-dom": "^17.0.0"
30
30
  },
@@ -33,13 +33,13 @@
33
33
  "NOTE: All tools used by scripts in this package must be listed as devDependencies"
34
34
  ],
35
35
  "devDependencies": {
36
- "@itwin/core-bentley": "3.0.0-dev.94",
37
- "@itwin/core-common": "3.0.0-dev.94",
38
- "@itwin/build-tools": "3.0.0-dev.94",
39
- "@itwin/eslint-plugin": "3.0.0-dev.94",
40
- "@itwin/core-i18n": "3.0.0-dev.94",
41
- "@itwin/appui-abstract": "3.0.0-dev.94",
42
- "@itwin/core-react": "3.0.0-dev.94",
36
+ "@itwin/core-bentley": "3.0.0-dev.98",
37
+ "@itwin/core-common": "3.0.0-dev.98",
38
+ "@itwin/build-tools": "3.0.0-dev.98",
39
+ "@itwin/eslint-plugin": "3.0.0-dev.98",
40
+ "@itwin/core-i18n": "3.0.0-dev.98",
41
+ "@itwin/appui-abstract": "3.0.0-dev.98",
42
+ "@itwin/core-react": "3.0.0-dev.98",
43
43
  "@testing-library/react": "^12.0.0",
44
44
  "@testing-library/react-hooks": "^3.2.1",
45
45
  "@testing-library/user-event": "^13.2.1",