@itwin/imodel-components-react 3.1.0-dev.6 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +3 -3
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +6 -6
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +0 -6
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +37 -46
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +10 -6
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +1 -0
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/cjs/imodel-components-react.d.ts +0 -1
- package/lib/cjs/imodel-components-react.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react.js +0 -1
- package/lib/cjs/imodel-components-react.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js +4 -4
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +7 -7
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +0 -6
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +37 -46
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +10 -6
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +1 -0
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/esm/imodel-components-react.d.ts +0 -1
- package/lib/esm/imodel-components-react.d.ts.map +1 -1
- package/lib/esm/imodel-components-react.js +0 -1
- package/lib/esm/imodel-components-react.js.map +1 -1
- package/package.json +21 -21
- package/lib/cjs/imodel-components-react/timeline/ContextMenu.d.ts +0 -55
- package/lib/cjs/imodel-components-react/timeline/ContextMenu.d.ts.map +0 -1
- package/lib/cjs/imodel-components-react/timeline/ContextMenu.js +0 -82
- package/lib/cjs/imodel-components-react/timeline/ContextMenu.js.map +0 -1
- package/lib/cjs/imodel-components-react/timeline/ContextMenu.scss +0 -81
- package/lib/esm/imodel-components-react/timeline/ContextMenu.d.ts +0 -55
- package/lib/esm/imodel-components-react/timeline/ContextMenu.d.ts.map +0 -1
- package/lib/esm/imodel-components-react/timeline/ContextMenu.js +0 -55
- package/lib/esm/imodel-components-react/timeline/ContextMenu.js.map +0 -1
- package/lib/esm/imodel-components-react/timeline/ContextMenu.scss +0 -81
|
@@ -82,6 +82,7 @@ class ViewportComponentEvents {
|
|
|
82
82
|
static setViewMatrix(viewport, animationTime) {
|
|
83
83
|
// When handling onViewChanged, use setTimeout
|
|
84
84
|
setTimeout(() => {
|
|
85
|
+
// istanbul ignore next
|
|
85
86
|
if (viewport.view) {
|
|
86
87
|
this.origin.setFrom(viewport.view.getOrigin());
|
|
87
88
|
this.extents.setFrom(viewport.view.getExtents());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportComponentEvents.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAmE;AACnE,wDAAwG;AACxG,0DAAgD;AAChD,iDAA8C;AAW9C;;GAEG;AACH,MAAa,0BAA2B,SAAQ,wBAAuC;CAAI;AAA3F,gEAA2F;AAW3F;;GAEG;AACH,MAAa,uBAAwB,SAAQ,wBAAoC;CAAI;AAArF,0DAAqF;AASrF;;GAEG;AACH,MAAa,2BAA4B,SAAQ,wBAAwC;CAAI;AAA7F,kEAA6F;AAU7F;;GAEG;AACH,MAAa,uBAAwB,SAAQ,wBAAoC;CAAI;AAArF,0DAAqF;AAWrF;;GAEG;AACH,MAAa,6BAA8B,SAAQ,wBAA0C;CAAI;AAAjG,sEAAiG;AAWjG;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wBAA+B;CAAI;AAA3E,gDAA2E;AAE3E;;GAEG;AACH,MAAa,uBAAuB;IAG3B,MAAM,CAAC,UAAU;QACtB,IAAI,SAAS,KAAK,IAAI,CAAC,eAAe;YACpC,OAAO;QAET,IAAI,CAAC,eAAe,GAAG,yBAAS,CAAC,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAAC,uBAAuB,CAAC,6BAA6B,CAAC,CAAC;IAC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I,CAAC,UAAU,EAAE,CAAC,CAAC;aAClD;YACD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAE/C,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;;
|
|
1
|
+
{"version":3,"file":"ViewportComponentEvents.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAmE;AACnE,wDAAwG;AACxG,0DAAgD;AAChD,iDAA8C;AAW9C;;GAEG;AACH,MAAa,0BAA2B,SAAQ,wBAAuC;CAAI;AAA3F,gEAA2F;AAW3F;;GAEG;AACH,MAAa,uBAAwB,SAAQ,wBAAoC;CAAI;AAArF,0DAAqF;AASrF;;GAEG;AACH,MAAa,2BAA4B,SAAQ,wBAAwC;CAAI;AAA7F,kEAA6F;AAU7F;;GAEG;AACH,MAAa,uBAAwB,SAAQ,wBAAoC;CAAI;AAArF,0DAAqF;AAWrF;;GAEG;AACH,MAAa,6BAA8B,SAAQ,wBAA0C;CAAI;AAAjG,sEAAiG;AAWjG;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wBAA+B;CAAI;AAA3E,gDAA2E;AAE3E;;GAEG;AACH,MAAa,uBAAuB;IAG3B,MAAM,CAAC,UAAU;QACtB,IAAI,SAAS,KAAK,IAAI,CAAC,eAAe;YACpC,OAAO;QAET,IAAI,CAAC,eAAe,GAAG,yBAAS,CAAC,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAAC,uBAAuB,CAAC,6BAA6B,CAAC,CAAC;IAC5I,CAAC;IAED,mCAAmC;IAC5B,MAAM,CAAC,SAAS;QACrB,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,e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CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;;AA5DH,0DA6DC;AA3Ce,4BAAI,GAAG,WAAI,CAAC,IAAI,CAAC;AACR,8BAAM,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAC9B,+BAAO,GAAG,wBAAQ,CAAC,UAAU,EAAE,CAAC;AAChC,sCAAc,GAAG,wBAAQ,CAAC,cAAc,EAAE,CAAC;AAC3C,oDAA4B,GAAG,IAAI,0BAA0B,EAAE,CAAC;AAChE,iDAAyB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC1D,qDAA6B,GAAG,IAAI,2BAA2B,EAAE,CAAC;AAClE,iDAAyB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC1D,uDAA+B,GAAG,IAAI,6BAA6B,EAAE,CAAC;AACtE,4CAAoB,GAAG,IAAI,kBAAkB,EAAE,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 Viewport\r\n */\r\n\r\nimport { Matrix3d, Point3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { IModelApp, SelectedViewportChangedArgs, StandardViewId, Viewport } from \"@itwin/core-frontend\";\r\nimport { UiEvent } from \"@itwin/appui-abstract\";\r\nimport { Face } from \"../navigationaids/Cube\";\r\n\r\n/** Arguments for [[DrawingViewportChangeEvent]]\r\n * @public\r\n */\r\nexport interface DrawingViewportChangeEventArgs {\r\n rotation: Matrix3d;\r\n origin: Point3d;\r\n complete: boolean;\r\n}\r\n\r\n/** Drawing View Change event\r\n * @public\r\n */\r\nexport class DrawingViewportChangeEvent extends UiEvent<DrawingViewportChangeEventArgs> { }\r\n\r\n/** Arguments for [[CubeRotationChangeEvent]]\r\n * @public\r\n */\r\nexport interface CubeRotationChangeEventArgs {\r\n rotMatrix: Matrix3d;\r\n face: Face;\r\n complete?: boolean;\r\n}\r\n\r\n/** 3d Cube Rotation Change event\r\n * @public\r\n */\r\nexport class CubeRotationChangeEvent extends UiEvent<CubeRotationChangeEventArgs> { }\r\n\r\n/** Arguments for [[StandardRotationChangeEvent]]\r\n * @public\r\n */\r\nexport interface StandardRotationChangeEventArgs {\r\n standardRotation: StandardViewId;\r\n}\r\n\r\n/** Standard Rotation Change event\r\n * @public\r\n */\r\nexport class StandardRotationChangeEvent extends UiEvent<StandardRotationChangeEventArgs> { }\r\n\r\n/** Arguments for [[ViewRotationChangeEvent]]\r\n * @public\r\n */\r\nexport interface ViewRotationChangeEventArgs {\r\n viewport: Viewport;\r\n animationTime?: number;\r\n}\r\n\r\n/** View Rotation Change event\r\n * @public\r\n */\r\nexport class ViewRotationChangeEvent extends UiEvent<ViewRotationChangeEventArgs> { }\r\n\r\n/** Arguments for [[ViewClassFullNameChangedEvent]]\r\n * @public\r\n */\r\nexport interface ViewClassFullNameChangedEventArgs {\r\n viewport: Viewport;\r\n oldName: string;\r\n newName: string;\r\n}\r\n\r\n/** View Class Full Name Change event\r\n * @public\r\n */\r\nexport class ViewClassFullNameChangedEvent extends UiEvent<ViewClassFullNameChangedEventArgs> { }\r\n\r\n/** Arguments for [[ViewIdChangedEvent]]\r\n * @public\r\n */\r\nexport interface ViewIdChangedEventArgs {\r\n viewport: Viewport;\r\n oldId: string;\r\n newId: string;\r\n}\r\n\r\n/** View Id Change event\r\n * @public\r\n */\r\nexport class ViewIdChangedEvent extends UiEvent<ViewIdChangedEventArgs> { }\r\n\r\n/** Viewport Rotation events and methods\r\n * @public\r\n */\r\nexport class ViewportComponentEvents {\r\n private static _removeListener?: () => void;\r\n\r\n public static initialize() {\r\n if (undefined !== this._removeListener)\r\n return;\r\n\r\n this._removeListener = IModelApp.viewManager.onSelectedViewportChanged.addListener(ViewportComponentEvents.handleSelectedViewportChanged);\r\n }\r\n\r\n /** @internal - for unit testing */\r\n public static terminate() {\r\n if (this._removeListener) {\r\n this._removeListener();\r\n this._removeListener = undefined;\r\n }\r\n }\r\n\r\n public static face = Face.None;\r\n public static readonly origin = Point3d.createZero();\r\n public static readonly extents = Vector3d.createZero();\r\n public static readonly rotationMatrix = Matrix3d.createIdentity();\r\n public static readonly onDrawingViewportChangeEvent = new DrawingViewportChangeEvent();\r\n public static readonly onCubeRotationChangeEvent = new CubeRotationChangeEvent();\r\n public static readonly onStandardRotationChangeEvent = new StandardRotationChangeEvent();\r\n public static readonly onViewRotationChangeEvent = new ViewRotationChangeEvent();\r\n public static readonly onViewClassFullNameChangedEvent = new ViewClassFullNameChangedEvent();\r\n public static readonly onViewIdChangedEvent = new ViewIdChangedEvent();\r\n\r\n private static handleSelectedViewportChanged(args: SelectedViewportChangedArgs): void {\r\n if (args.current)\r\n ViewportComponentEvents.setViewMatrix(args.current);\r\n }\r\n\r\n public static setCubeMatrix(rotMatrix: Matrix3d, face = Face.None, complete: boolean = false): void {\r\n this.rotationMatrix.setFrom(rotMatrix);\r\n this.face = face;\r\n this.onCubeRotationChangeEvent.emit({ rotMatrix, complete, face });\r\n }\r\n\r\n public static setDrawingViewportState(origin: Point3d, rotation: Matrix3d, complete: boolean = false): void {\r\n this.onDrawingViewportChangeEvent.emit({ origin, rotation, complete });\r\n }\r\n\r\n public static setStandardRotation(standardRotation: StandardViewId): void {\r\n this.onStandardRotationChangeEvent.emit({ standardRotation });\r\n }\r\n\r\n public static setViewMatrix(viewport: Viewport, animationTime?: number): void {\r\n // When handling onViewChanged, use setTimeout\r\n setTimeout(() => {\r\n // istanbul ignore next\r\n if (viewport.view) {\r\n this.origin.setFrom(viewport.view.getOrigin());\r\n this.extents.setFrom(viewport.view.getExtents());\r\n }\r\n this.rotationMatrix.setFrom(viewport.rotation);\r\n\r\n this.onViewRotationChangeEvent.emit({ viewport, animationTime });\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -27,7 +27,6 @@ export * from "./imodel-components-react/quantityformat/MiscFormatOptions";
|
|
|
27
27
|
export * from "./imodel-components-react/quantityformat/QuantityFormatPanel";
|
|
28
28
|
export * from "./imodel-components-react/timeline/interfaces";
|
|
29
29
|
export * from "./imodel-components-react/timeline/BaseTimelineDataProvider";
|
|
30
|
-
export * from "./imodel-components-react/timeline/ContextMenu";
|
|
31
30
|
export * from "./imodel-components-react/timeline/InlineEdit";
|
|
32
31
|
export * from "./imodel-components-react/timeline/PlayerButton";
|
|
33
32
|
export * from "./imodel-components-react/timeline/Scrubber";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imodel-components-react.d.ts","sourceRoot":"","sources":["../../src/imodel-components-react.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAElF,cAAc,6CAA6C,CAAC;AAC5D,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,kDAAkD,CAAC;AACjE,cAAc,kDAAkD,CAAC;AACjE,cAAc,oDAAoD,CAAC;AACnE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wCAAwC,CAAC;AAEvD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,gDAAgD,CAAC;AAE/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,sDAAsD,CAAC;AAErE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yDAAyD,CAAC;AAExE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,4DAA4D,CAAC;AAC3E,cAAc,+DAA+D,CAAC;AAE9E,cAAc,sDAAsD,CAAC;AACrE,cAAc,0DAA0D,CAAC;AACzE,cAAc,uDAAuD,CAAC;AACtE,cAAc,qDAAqD,CAAC;AACpE,cAAc,0DAA0D,CAAC;AACzE,cAAc,sDAAsD,CAAC;AACrE,cAAc,4DAA4D,CAAC;AAC3E,cAAc,8DAA8D,CAAC;AAE7E,cAAc,+CAA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G;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
@@ -46,7 +46,6 @@ __exportStar(require("./imodel-components-react/quantityformat/MiscFormatOptions
|
|
|
46
46
|
__exportStar(require("./imodel-components-react/quantityformat/QuantityFormatPanel"), exports);
|
|
47
47
|
__exportStar(require("./imodel-components-react/timeline/interfaces"), exports);
|
|
48
48
|
__exportStar(require("./imodel-components-react/timeline/BaseTimelineDataProvider"), exports);
|
|
49
|
-
__exportStar(require("./imodel-components-react/timeline/ContextMenu"), exports);
|
|
50
49
|
__exportStar(require("./imodel-components-react/timeline/InlineEdit"), exports);
|
|
51
50
|
__exportStar(require("./imodel-components-react/timeline/PlayerButton"), exports);
|
|
52
51
|
__exportStar(require("./imodel-components-react/timeline/Scrubber"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imodel-components-react.js","sourceRoot":"","sources":["../../src/imodel-components-react.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;AAE/F,qEAAqE;AAErE,mFAAkF;AAAzE,wHAAA,kBAAkB,OAAA;AAE3B,8EAA4D;AAC5D,oFAAkE;AAClE,oFAAkE;AAClE,mFAAiE;AACjE,mFAAiE;AACjE,qFAAmE;AACnE,4EAA0D;AAC1D,mFAAiE;AACjE,yEAAuD;AAEvD,gFAA8D;AAC9D,iFAA+D;AAE/D,iFAA+D;AAC/D,uFAAqE;AAErE,8EAA4D;AAC5D,0FAAwE;AAExE,gFAA8D;AAC9D,6FAA2E;AAC3E,gGAA8E;AAE9E,uFAAqE;AACrE,2FAAyE;AACzE,wFAAsE;AACtE,sFAAoE;AACpE,2FAAyE;AACzE,uFAAqE;AACrE,6FAA2E;AAC3E,+FAA6E;AAE7E,gFAA8D;AAC9D,8FAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"imodel-components-react.js","sourceRoot":"","sources":["../../src/imodel-components-react.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;AAE/F,qEAAqE;AAErE,mFAAkF;AAAzE,wHAAA,kBAAkB,OAAA;AAE3B,8EAA4D;AAC5D,oFAAkE;AAClE,oFAAkE;AAClE,mFAAiE;AACjE,mFAAiE;AACjE,qFAAmE;AACnE,4EAA0D;AAC1D,mFAAiE;AACjE,yEAAuD;AAEvD,gFAA8D;AAC9D,iFAA+D;AAE/D,iFAA+D;AAC/D,uFAAqE;AAErE,8EAA4D;AAC5D,0FAAwE;AAExE,gFAA8D;AAC9D,6FAA2E;AAC3E,gGAA8E;AAE9E,uFAAqE;AACrE,2FAAyE;AACzE,wFAAsE;AACtE,sFAAoE;AACpE,2FAAyE;AACzE,uFAAqE;AACrE,6FAA2E;AAC3E,+FAA6E;AAE7E,gFAA8D;AAC9D,8FAA4E;AAC5E,gFAA8D;AAC9D,kFAAgE;AAChE,8EAA4D;AAC5D,uFAAqE;AACrE,mFAAiE;AACjE,2FAAyE;AAEzE,uFAAqE;AACrE,6FAA2E;AAE3E;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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\r\n// cSpell:ignore iconpicker lineweight hocs datepicker quantityformat\r\n\r\nexport { UiIModelComponents } from \"./imodel-components-react/UiIModelComponents\";\r\n\r\nexport * from \"./imodel-components-react/color/AlphaSlider\";\r\nexport * from \"./imodel-components-react/color/ColorPickerButton\";\r\nexport * from \"./imodel-components-react/color/ColorPickerDialog\";\r\nexport * from \"./imodel-components-react/color/ColorPickerPanel\";\r\nexport * from \"./imodel-components-react/color/ColorPickerPopup\";\r\nexport * from \"./imodel-components-react/color/getCSSColorFromDef\";\r\nexport * from \"./imodel-components-react/color/HueSlider\";\r\nexport * from \"./imodel-components-react/color/SaturationPicker\";\r\nexport * from \"./imodel-components-react/color/Swatch\";\r\n\r\nexport * from \"./imodel-components-react/editors/ColorEditor\";\r\nexport * from \"./imodel-components-react/editors/WeightEditor\";\r\n\r\nexport * from \"./imodel-components-react/inputs/QuantityInput\";\r\nexport * from \"./imodel-components-react/inputs/QuantityNumberInput\";\r\n\r\nexport * from \"./imodel-components-react/lineweight/Swatch\";\r\nexport * from \"./imodel-components-react/lineweight/WeightPickerButton\";\r\n\r\nexport * from \"./imodel-components-react/navigationaids/Cube\";\r\nexport * from \"./imodel-components-react/navigationaids/CubeNavigationAid\";\r\nexport * from \"./imodel-components-react/navigationaids/DrawingNavigationAid\";\r\n\r\nexport * from \"./imodel-components-react/quantityformat/FormatPanel\";\r\nexport * from \"./imodel-components-react/quantityformat/FormatPrecision\";\r\nexport * from \"./imodel-components-react/quantityformat/FormatSample\";\r\nexport * from \"./imodel-components-react/quantityformat/FormatType\";\r\nexport * from \"./imodel-components-react/quantityformat/FormatUnitLabel\";\r\nexport * from \"./imodel-components-react/quantityformat/FormatUnits\";\r\nexport * from \"./imodel-components-react/quantityformat/MiscFormatOptions\";\r\nexport * from \"./imodel-components-react/quantityformat/QuantityFormatPanel\";\r\n\r\nexport * from \"./imodel-components-react/timeline/interfaces\";\r\nexport * from \"./imodel-components-react/timeline/BaseTimelineDataProvider\";\r\nexport * from \"./imodel-components-react/timeline/InlineEdit\";\r\nexport * from \"./imodel-components-react/timeline/PlayerButton\";\r\nexport * from \"./imodel-components-react/timeline/Scrubber\";\r\nexport * from \"./imodel-components-react/timeline/TimelineComponent\";\r\nexport * from \"./imodel-components-react/timeline/SolarTimeline\";\r\nexport * from \"./imodel-components-react/timeline/BaseSolarDataProvider\";\r\n\r\nexport * from \"./imodel-components-react/viewport/ViewportComponent\";\r\nexport * from \"./imodel-components-react/viewport/ViewportComponentEvents\";\r\n\r\n/** @docs-package-description\r\n * The imodel-components-react package contains React components that depend on the core-frontend, core-common or core-quantity packages.\r\n * The components pertain to Color, Cube, LineWeight, Navigation Aids, Quantity Inputs, Timeline and Viewport.\r\n * For more information, see [learning about imodel-components-react]($docs/learning/ui/imodel-components/index.md).\r\n */\r\n/**\r\n * @docs-group-description Color\r\n * Classes and components for working with and picking a Color.\r\n */\r\n/**\r\n * @docs-group-description Common\r\n * Common classes used across various UI components.\r\n */\r\n/**\r\n * @docs-group-description Cube\r\n * Component for 3D Cube.\r\n */\r\n/**\r\n * @docs-group-description Inputs\r\n * Input Components that format and parse input for IModelApps.\r\n */\r\n/**\r\n * @docs-group-description LineWeight\r\n * Classes and components for working with and picking a Line Weight.\r\n */\r\n/**\r\n * @docs-group-description NavigationAids\r\n * Classes and components for working with Navigation Aids.\r\n */\r\n/**\r\n * @docs-group-description PropertyEditors\r\n * Classes and components for working with Property Editors.\r\n */\r\n/**\r\n * @docs-group-description QuantityFormat\r\n * Classes and components for working with a Quantity Formats.\r\n */\r\n/**\r\n * @docs-group-description Timeline\r\n * Classes and components that provide a timeline\r\n */\r\n/**\r\n * @docs-group-description Viewport\r\n * Classes and components for working with a Viewport.\r\n */\r\n"]}
|
|
@@ -22,7 +22,7 @@ function ColorOptions({ handleColorPicked, options, numColumns, round, title })
|
|
|
22
22
|
}
|
|
23
23
|
// Defined using following pattern (const ColorPickerButton at bottom) to ensure useful API documentation is extracted
|
|
24
24
|
const ForwardRefColorPickerButton = React.forwardRef(function ForwardRefColorPickerButton({ className, colorDefs, disabled, dropDownTitle, initialColor, numColumns, onColorPick, readonly, round, showCaret, style }, ref) {
|
|
25
|
-
const target = React.useRef();
|
|
25
|
+
const target = React.useRef(null);
|
|
26
26
|
const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.
|
|
27
27
|
const [showPopup, setShowPopup] = React.useState(false);
|
|
28
28
|
const [colorDef, setColorDef] = React.useState(initialColor);
|
|
@@ -1 +1 @@
|
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,SAAS,CACV,CAAC;IAEF,MAAM,YAAY,GAAG,SAAS,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC;IACvF,OAAO,CACL;QACE,+CAAoB,+BAA+B,gBAAa,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAC3H,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI;YACjD,6BAAK,SAAS,EAAC,yCAAyC;gBACtD,6BAAK,SAAS,EAAC,4CAA4C,EAAC,KAAK,EAAE,WAAW,GAAI;gBACjF,SAAS,IAAI,oBAAC,WAAW,IAAC,SAAS,EAAC,kBAAkB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,EAAE,QAAQ,EAAC,SAAS,GAAG,CACpI,CACC;QACT,oBAAC,KAAK,IACJ,SAAS,EAAC,8BAA8B,EACxC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,EACrC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,CAAC,OAAO,EACtB,8BAA8B;YAE9B,oBAAC,YAAY,IAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,GAAI,CAC1I,CACP,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAoD,2BAA2B,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 Color\r\n */\r\n\r\nimport \"./ColorPickerButton.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, Popup, useRefs, WebFontIcon } from \"@itwin/core-react\";\r\nimport { ColorSwatch } from \"./Swatch\";\r\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\r\n\r\n// cSpell:ignore colorpicker\r\n\r\nfunction ColorOptions({ handleColorPicked, options, numColumns, round, title }: { handleColorPicked: ((color: ColorDef) => void), options: ColorDef[], numColumns: number, round: boolean, title?: string }) {\r\n const containerStyle: React.CSSProperties = { gridTemplateColumns: `repeat(${numColumns}, 1fr)` };\r\n return (\r\n <div className=\"components-colorpicker-popup-container\">\r\n {title && <h4>{title}</h4>}\r\n <div data-testid=\"components-colorpicker-popup-colors\" className=\"components-colorpicker-popup-colors\" style={containerStyle}>\r\n {options.map((color, index) => <ColorSwatch className=\"components-colorpicker-swatch\" key={index} colorDef={color}\r\n onColorPick={handleColorPicked} round={round} />)}\r\n </div>\r\n </div>\r\n );\r\n}\r\n\r\n/** Properties for the [[ColorPickerButton]] React component\r\n * @beta\r\n */\r\nexport interface ColorPickerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** Active color */\r\n initialColor: ColorDef;\r\n /** Available colors */\r\n colorDefs?: ColorDef[];\r\n /** Function to run when user selects color swatch */\r\n onColorPick?: ((color: ColorDef) => void) | undefined;\r\n /** Show swatches as squares unless round is set to true */\r\n round?: boolean;\r\n /** Disabled or not */\r\n disabled?: boolean;\r\n /** Readonly or not */\r\n readonly?: boolean;\r\n /** Title to show at top of DropDown */\r\n dropDownTitle?: string;\r\n /** Number of columns */\r\n numColumns?: number;\r\n /** Provides ability to return reference to HTMLButtonElement */\r\n ref?: React.Ref<HTMLButtonElement>;\r\n /** If true show up/down caret next to color */\r\n showCaret?: boolean;\r\n}\r\n\r\n// Defined using following pattern (const ColorPickerButton at bottom) to ensure useful API documentation is extracted\r\nconst ForwardRefColorPickerButton = React.forwardRef<HTMLButtonElement, ColorPickerProps>(\r\n function ForwardRefColorPickerButton({ className, colorDefs, disabled, dropDownTitle, initialColor, numColumns, onColorPick, readonly, round, showCaret, style }, ref) {\r\n const target = React.useRef<HTMLButtonElement>();\r\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\r\n const [showPopup, setShowPopup] = React.useState(false);\r\n const [colorDef, setColorDef] = React.useState(initialColor);\r\n\r\n // See if new initialColor props have changed since component mounted\r\n React.useEffect(() => {\r\n setColorDef(initialColor);\r\n }, [initialColor]);\r\n\r\n const defaultColors = React.useRef(\r\n [\r\n ColorDef.create(ColorByName.red),\r\n ColorDef.create(ColorByName.orange),\r\n ColorDef.create(ColorByName.yellow),\r\n ColorDef.create(ColorByName.green),\r\n ColorDef.create(ColorByName.blue),\r\n ColorDef.create(ColorByName.indigo),\r\n ColorDef.create(ColorByName.violet),\r\n ColorDef.create(ColorByName.black),\r\n ColorDef.create(ColorByName.white),\r\n ColorDef.create(ColorByName.cyan),\r\n ColorDef.create(ColorByName.fuchsia),\r\n ColorDef.create(ColorByName.tan),\r\n ColorDef.create(ColorByName.gray),\r\n ColorDef.create(ColorByName.brown),\r\n ColorDef.create(ColorByName.purple),\r\n ColorDef.create(ColorByName.olive),\r\n ]);\r\n\r\n const closePopup = React.useCallback(() => {\r\n setShowPopup(false);\r\n }, []);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setShowPopup(!showPopup);\r\n }, [showPopup]);\r\n\r\n const handleColorPicked = React.useCallback((color: ColorDef) => {\r\n closePopup();\r\n\r\n // istanbul ignore else\r\n if (!color.equals(colorDef)) {\r\n setColorDef(color);\r\n onColorPick && onColorPick(color);\r\n }\r\n }, [closePopup, colorDef, onColorPick]);\r\n\r\n const rgbaString = getCSSColorFromDef(colorDef);\r\n\r\n const buttonStyle = { ...style } as React.CSSProperties;\r\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\r\n\r\n const buttonClassNames = classnames(\"components-colorpicker-button\",\r\n round && \"round\",\r\n readonly && \"readonly\",\r\n className,\r\n );\r\n\r\n const colorOptions = colorDefs && colorDefs.length ? colorDefs : defaultColors.current;\r\n return (\r\n <>\r\n <button data-testid=\"components-colorpicker-button\" data-value={rgbaString} onClick={togglePopup} className={buttonClassNames}\r\n style={buttonStyle} disabled={disabled} ref={refs} >\r\n <div className=\"components-colorpicker-button-container\">\r\n <div className=\"components-colorpicker-button-color-swatch\" style={swatchStyle} />\r\n {showCaret && <WebFontIcon className=\"components-caret\" iconName={showPopup ? \"icon-caret-up\" : \"icon-caret-down\"} iconSize=\"x-small\" />}\r\n </div>\r\n </button>\r\n <Popup\r\n className=\"components-colorpicker-popup\"\r\n isOpen={showPopup}\r\n position={RelativePosition.BottomLeft}\r\n onClose={closePopup}\r\n target={target.current}\r\n closeOnNestedPopupOutsideClick\r\n >\r\n <ColorOptions handleColorPicked={handleColorPicked} options={colorOptions} numColumns={numColumns ?? 4} round={!!round} title={dropDownTitle} />\r\n </Popup>\r\n </>\r\n );\r\n }\r\n);\r\n\r\n/** ColorPickerButton component\r\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\r\n * @beta\r\n */\r\nexport const ColorPickerButton: (props: ColorPickerProps) => JSX.Element | null = ForwardRefColorPickerButton;\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"ColorPickerButton.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAClC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,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EAAE,IAAI;YACjD,6BAAK,SAAS,EAAC,yCAAyC;gBACtD,6BAAK,SAAS,EAAC,4CAA4C,EAAC,KAAK,EAAE,WAAW,GAAI;gBACjF,SAAS,IAAI,oBAAC,WAAW,IAAC,SAAS,EAAC,kBAAkB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,EAAE,QAAQ,EAAC,SAAS,GAAG,CACpI,CACC;QACT,oBAAC,KAAK,IACJ,SAAS,EAAC,8BAA8B,EACxC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,EACrC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,CAAC,OAAO,EACtB,8BAA8B;YAE9B,oBAAC,YAAY,IAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,GAAI,CAC1I,CACP,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAoD,2BAA2B,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 Color\r\n */\r\n\r\nimport \"./ColorPickerButton.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, Popup, useRefs, WebFontIcon } from \"@itwin/core-react\";\r\nimport { ColorSwatch } from \"./Swatch\";\r\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\r\n\r\n// cSpell:ignore colorpicker\r\n\r\nfunction ColorOptions({ handleColorPicked, options, numColumns, round, title }: { handleColorPicked: ((color: ColorDef) => void), options: ColorDef[], numColumns: number, round: boolean, title?: string }) {\r\n const containerStyle: React.CSSProperties = { gridTemplateColumns: `repeat(${numColumns}, 1fr)` };\r\n return (\r\n <div className=\"components-colorpicker-popup-container\">\r\n {title && <h4>{title}</h4>}\r\n <div data-testid=\"components-colorpicker-popup-colors\" className=\"components-colorpicker-popup-colors\" style={containerStyle}>\r\n {options.map((color, index) => <ColorSwatch className=\"components-colorpicker-swatch\" key={index} colorDef={color}\r\n onColorPick={handleColorPicked} round={round} />)}\r\n </div>\r\n </div>\r\n );\r\n}\r\n\r\n/** Properties for the [[ColorPickerButton]] React component\r\n * @beta\r\n */\r\nexport interface ColorPickerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** Active color */\r\n initialColor: ColorDef;\r\n /** Available colors */\r\n colorDefs?: ColorDef[];\r\n /** Function to run when user selects color swatch */\r\n onColorPick?: ((color: ColorDef) => void) | undefined;\r\n /** Show swatches as squares unless round is set to true */\r\n round?: boolean;\r\n /** Disabled or not */\r\n disabled?: boolean;\r\n /** Readonly or not */\r\n readonly?: boolean;\r\n /** Title to show at top of DropDown */\r\n dropDownTitle?: string;\r\n /** Number of columns */\r\n numColumns?: number;\r\n /** Provides ability to return reference to HTMLButtonElement */\r\n ref?: React.Ref<HTMLButtonElement>;\r\n /** If true show up/down caret next to color */\r\n showCaret?: boolean;\r\n}\r\n\r\n// Defined using following pattern (const ColorPickerButton at bottom) to ensure useful API documentation is extracted\r\nconst ForwardRefColorPickerButton = React.forwardRef<HTMLButtonElement, ColorPickerProps>(\r\n function ForwardRefColorPickerButton({ className, colorDefs, disabled, dropDownTitle, initialColor, numColumns, onColorPick, readonly, round, showCaret, style }, ref) {\r\n const target = React.useRef<HTMLButtonElement>(null);\r\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\r\n const [showPopup, setShowPopup] = React.useState(false);\r\n const [colorDef, setColorDef] = React.useState(initialColor);\r\n\r\n // See if new initialColor props have changed since component mounted\r\n React.useEffect(() => {\r\n setColorDef(initialColor);\r\n }, [initialColor]);\r\n\r\n const defaultColors = React.useRef(\r\n [\r\n ColorDef.create(ColorByName.red),\r\n ColorDef.create(ColorByName.orange),\r\n ColorDef.create(ColorByName.yellow),\r\n ColorDef.create(ColorByName.green),\r\n ColorDef.create(ColorByName.blue),\r\n ColorDef.create(ColorByName.indigo),\r\n ColorDef.create(ColorByName.violet),\r\n ColorDef.create(ColorByName.black),\r\n ColorDef.create(ColorByName.white),\r\n ColorDef.create(ColorByName.cyan),\r\n ColorDef.create(ColorByName.fuchsia),\r\n ColorDef.create(ColorByName.tan),\r\n ColorDef.create(ColorByName.gray),\r\n ColorDef.create(ColorByName.brown),\r\n ColorDef.create(ColorByName.purple),\r\n ColorDef.create(ColorByName.olive),\r\n ]);\r\n\r\n const closePopup = React.useCallback(() => {\r\n setShowPopup(false);\r\n }, []);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setShowPopup(!showPopup);\r\n }, [showPopup]);\r\n\r\n const handleColorPicked = React.useCallback((color: ColorDef) => {\r\n closePopup();\r\n\r\n // istanbul ignore else\r\n if (!color.equals(colorDef)) {\r\n setColorDef(color);\r\n onColorPick && onColorPick(color);\r\n }\r\n }, [closePopup, colorDef, onColorPick]);\r\n\r\n const rgbaString = getCSSColorFromDef(colorDef);\r\n\r\n const buttonStyle = { ...style } as React.CSSProperties;\r\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\r\n\r\n const buttonClassNames = classnames(\"components-colorpicker-button\",\r\n round && \"round\",\r\n readonly && \"readonly\",\r\n className,\r\n );\r\n\r\n const colorOptions = colorDefs && colorDefs.length ? colorDefs : defaultColors.current;\r\n return (\r\n <>\r\n <button data-testid=\"components-colorpicker-button\" data-value={rgbaString} onClick={togglePopup} className={buttonClassNames}\r\n style={buttonStyle} disabled={disabled} ref={refs} >\r\n <div className=\"components-colorpicker-button-container\">\r\n <div className=\"components-colorpicker-button-color-swatch\" style={swatchStyle} />\r\n {showCaret && <WebFontIcon className=\"components-caret\" iconName={showPopup ? \"icon-caret-up\" : \"icon-caret-down\"} iconSize=\"x-small\" />}\r\n </div>\r\n </button>\r\n <Popup\r\n className=\"components-colorpicker-popup\"\r\n isOpen={showPopup}\r\n position={RelativePosition.BottomLeft}\r\n onClose={closePopup}\r\n target={target.current}\r\n closeOnNestedPopupOutsideClick\r\n >\r\n <ColorOptions handleColorPicked={handleColorPicked} options={colorOptions} numColumns={numColumns ?? 4} round={!!round} title={dropDownTitle} />\r\n </Popup>\r\n </>\r\n );\r\n }\r\n);\r\n\r\n/** ColorPickerButton component\r\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\r\n * @beta\r\n */\r\nexport const ColorPickerButton: (props: ColorPickerProps) => JSX.Element | null = ForwardRefColorPickerButton;\r\n\r\n"]}
|
|
@@ -18,7 +18,7 @@ import { getCSSColorFromDef } from "./getCSSColorFromDef";
|
|
|
18
18
|
import { UiIModelComponents } from "../UiIModelComponents";
|
|
19
19
|
// Defined using following pattern (const ColorPickerPopup at bottom) to ensure useful API documentation is extracted
|
|
20
20
|
const ForwardRefColorPickerPopup = React.forwardRef(function ForwardRefColorPickerPopup(props, ref) {
|
|
21
|
-
const target = React.useRef();
|
|
21
|
+
const target = React.useRef(null);
|
|
22
22
|
const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.
|
|
23
23
|
const [showPopup, setShowPopup] = React.useState(false);
|
|
24
24
|
const [colorDef, setColorDef] = React.useState(props.initialColor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerPopup.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerPopup.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,4BAA4B;AAE5B,OAA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AAW,IAAC,SAAS,EAAC,kBAAkB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,EAAE,QAAQ,EAAC,SAAS,GAAG,CAC1I,CACC;QACT,oBAAC,KAAK,IACJ,SAAS,EAAC,8BAA8B,EACxC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,CAAC,OAAO,EACtB,8BAA8B;YAE9B,6BAAK,SAAS,EAAC,4CAA4C;gBACxD,CAAC,KAAK,CAAC,eAAe;oBACrB,gCAAQ,KAAK,EAAE,UAAU,EACvB,SAAS,EAAE,kEAAkE,iBACjE,mBAAmB,EAC/B,OAAO,EAAE,WAAW,GACpB;gBACJ,oBAAC,WAAW,IAAC,aAAa,EAAE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,kBAAkB;oBAClG,oBAAC,YAAY,OAAG;oBACf,KAAK,CAAC,cAAc;wBACnB,oBAAC,eAAe,IAAC,kBAAkB,EAAE,KAAK,CAAC,cAAc,GAAI;oBAC9D,YAAY;wBACX,oBAAC,YAAY,IAAC,MAAM,EAAE,YAAY,GAAI,CAC5B,CACV,CACA,CACJ,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAyD,0BAA0B,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 Color\r\n */\r\n\r\n// cSpell:ignore colorpicker\r\n\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, Popup, useRefs, WebFontIcon } from \"@itwin/core-react\";\r\n// import { ColorPickerPanel } from \"./ColorPickerPanel\";\r\nimport { ColorBuilder, ColorInputPanel, ColorPalette, ColorPicker, ColorValue } from \"@itwin/itwinui-react\";\r\nimport \"./ColorPickerPopup.scss\";\r\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties for the [[ColorPickerPopup]] React component\r\n * @public\r\n */\r\nexport interface ColorPickerPopupProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** Current color */\r\n initialColor: ColorDef;\r\n /** Preset colors. Pass undefined to show default preset colors. Pass empty array to show no presets.\r\n * Displayed in rows of 9 items */\r\n colorDefs?: ColorDef[];\r\n /** Function to call when the color value is changed */\r\n onColorChange?: ((newColor: ColorDef) => void) | undefined;\r\n /** Function to call when the popup is closed */\r\n onClose?: ((colorValue: ColorDef) => void) | undefined;\r\n /** Disabled or not */\r\n disabled?: boolean;\r\n /** Readonly or not, color displayed on button but button will not trigger pop-up */\r\n readonly?: boolean;\r\n /** popup position. If not set RelativePosition.BottomLeft is used */\r\n popupPosition?: RelativePosition;\r\n /** Provides ability to return reference to HTMLButtonElement */\r\n ref?: React.Ref<HTMLButtonElement>;\r\n /** If true show up/down caret next to color */\r\n showCaret?: boolean;\r\n /** If true, don't propagate clicks out of the ColorPicker */\r\n captureClicks?: boolean;\r\n /** If true, don't show close button at top */\r\n hideCloseButton?: boolean;\r\n /** If set show input values */\r\n colorInputType?: \"hsl\" | \"rgb\" | \"hex\";\r\n}\r\n\r\n// Defined using following pattern (const ColorPickerPopup at bottom) to ensure useful API documentation is extracted\r\n\r\nconst ForwardRefColorPickerPopup = React.forwardRef<HTMLButtonElement, ColorPickerPopupProps>(\r\n function ForwardRefColorPickerPopup(props, ref) {\r\n const target = React.useRef<HTMLButtonElement>();\r\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\r\n const [showPopup, setShowPopup] = React.useState(false);\r\n const [colorDef, setColorDef] = React.useState(props.initialColor);\r\n const initialColorRef = React.useRef(props.initialColor);\r\n\r\n React.useEffect(() => {\r\n if (props.initialColor !== initialColorRef.current) {\r\n initialColorRef.current = props.initialColor;\r\n setColorDef(props.initialColor);\r\n }\r\n }, [props.initialColor]);\r\n\r\n const defaultColors = React.useRef(\r\n [\r\n ColorValue.fromTbgr(ColorByName.red),\r\n ColorValue.fromTbgr(ColorByName.orange),\r\n ColorValue.fromTbgr(ColorByName.yellow),\r\n ColorValue.fromTbgr(ColorByName.green),\r\n ColorValue.fromTbgr(ColorByName.blue),\r\n ColorValue.fromTbgr(ColorByName.mediumBlue),\r\n ColorValue.fromTbgr(ColorByName.indigo),\r\n ColorValue.fromTbgr(ColorByName.violet),\r\n ColorValue.fromTbgr(ColorByName.black),\r\n ColorValue.fromTbgr(ColorByName.white),\r\n ColorValue.fromTbgr(ColorByName.cyan),\r\n ColorValue.fromTbgr(ColorByName.fuchsia),\r\n ColorValue.fromTbgr(ColorByName.tan),\r\n ColorValue.fromTbgr(ColorByName.gray),\r\n ColorValue.fromTbgr(ColorByName.brown),\r\n ColorValue.fromTbgr(ColorByName.purple),\r\n ColorValue.fromTbgr(ColorByName.olive),\r\n ColorValue.fromTbgr(ColorByName.darkGreen),\r\n ]);\r\n\r\n // istanbul ignore next\r\n const closePopup = React.useCallback(() => {\r\n props.onClose && props.onClose(colorDef);\r\n setShowPopup(false);\r\n }, [colorDef, props]);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setShowPopup(!showPopup);\r\n }, [showPopup]);\r\n\r\n const handleColorChanged = React.useCallback((newColorValue: ColorValue) => {\r\n const newColor = ColorDef.fromTbgr(newColorValue.toTbgr());\r\n // istanbul ignore else\r\n if (!newColor.equals(colorDef)) {\r\n setColorDef(newColor);\r\n\r\n // istanbul ignore else\r\n props.onColorChange && props.onColorChange(newColor);\r\n }\r\n }, [colorDef, props]);\r\n\r\n const rgbaString = getCSSColorFromDef(colorDef);\r\n\r\n const buttonStyle = { ...props.style } as React.CSSProperties;\r\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\r\n const buttonClassNames = classnames(\"components-colorpicker-popup-button\",\r\n props.readonly && \"readonly\",\r\n props.className,\r\n );\r\n\r\n const clickHandler = (event: React.MouseEvent) => {\r\n // istanbul ignore else\r\n if (props.captureClicks)\r\n event.stopPropagation();\r\n };\r\n\r\n const colorOptions = React.useMemo(() => {\r\n if (props.colorDefs && props.colorDefs.length) {\r\n return props.colorDefs.map((def) => ColorValue.fromTbgr(def.tbgr));\r\n }\r\n if (props.colorDefs && 0 === props.colorDefs.length)\r\n return undefined;\r\n return defaultColors.current;\r\n }, [props.colorDefs]);\r\n const popupPosition = undefined !== props.popupPosition ? props.popupPosition : RelativePosition.BottomLeft;\r\n\r\n const [closeLabel] = React.useState(() => UiIModelComponents.translate(\"color.close\"));\r\n const [togglePopupLabel] = React.useState(() => UiIModelComponents.translate(\"color.toggleColorPopup\"));\r\n\r\n return (\r\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\r\n <div onClick={clickHandler}>\r\n <button data-testid=\"components-colorpicker-popup-button\" onClick={togglePopup} className={buttonClassNames} style={buttonStyle}\r\n disabled={props.disabled} ref={refs} title={togglePopupLabel} >\r\n <div className=\"components-colorpicker-button-container\">\r\n <div className=\"components-colorpicker-button-color-swatch\" style={swatchStyle} />\r\n {props.showCaret && <WebFontIcon className=\"components-caret\" iconName={showPopup ? \"icon-caret-up\" : \"icon-caret-down\"} iconSize=\"x-small\" />}\r\n </div>\r\n </button>\r\n <Popup\r\n className=\"components-colorpicker-popup\"\r\n isOpen={showPopup}\r\n position={popupPosition}\r\n onClose={closePopup}\r\n target={target.current}\r\n closeOnNestedPopupOutsideClick\r\n >\r\n <div className=\"components-colorpicker-popup-panel-padding\">\r\n {!props.hideCloseButton &&\r\n <button title={closeLabel}\r\n className={\"core-focus-trap-ignore-initial core-dialog-close icon icon-close\"}\r\n data-testid=\"core-dialog-close\"\r\n onClick={togglePopup}\r\n />}\r\n <ColorPicker selectedColor={ColorValue.fromTbgr(colorDef.tbgr)} onChangeComplete={handleColorChanged} >\r\n <ColorBuilder />\r\n {props.colorInputType &&\r\n <ColorInputPanel defaultColorFormat={props.colorInputType} />}\r\n {colorOptions &&\r\n <ColorPalette colors={colorOptions} />}\r\n </ColorPicker>\r\n </div>\r\n </Popup>\r\n </div>\r\n );\r\n }\r\n);\r\n\r\n/**\r\n * ColorPickerButton component that allows user to select a color from a set of color swatches or to define a new color.\r\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\r\n * @public\r\n */\r\nexport const ColorPickerPopup: (props: ColorPickerPopupProps) => JSX.Element | null = ForwardRefColorPickerPopup;\r\n"]}
|
|
1
|
+
{"version":3,"file":"ColorPickerPopup.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerPopup.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,4BAA4B;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAe,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7E,yDAAyD;AACzD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAiC3D,qHAAqH;AAErH,MAAM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AE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,kBAAkB;oBAClG,oBAAC,YAAY,OAAG;oBACf,KAAK,CAAC,cAAc;wBACnB,oBAAC,eAAe,IAAC,kBAAkB,EAAE,KAAK,CAAC,cAAc,GAAI;oBAC9D,YAAY;wBACX,oBAAC,YAAY,IAAC,MAAM,EAAE,YAAY,GAAI,CAC5B,CACV,CACA,CACJ,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAyD,0BAA0B,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 Color\r\n */\r\n\r\n// cSpell:ignore colorpicker\r\n\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, Popup, useRefs, WebFontIcon } from \"@itwin/core-react\";\r\n// import { ColorPickerPanel } from \"./ColorPickerPanel\";\r\nimport { ColorBuilder, ColorInputPanel, ColorPalette, ColorPicker, ColorValue } from \"@itwin/itwinui-react\";\r\nimport \"./ColorPickerPopup.scss\";\r\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties for the [[ColorPickerPopup]] React component\r\n * @public\r\n */\r\nexport interface ColorPickerPopupProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** Current color */\r\n initialColor: ColorDef;\r\n /** Preset colors. Pass undefined to show default preset colors. Pass empty array to show no presets.\r\n * Displayed in rows of 9 items */\r\n colorDefs?: ColorDef[];\r\n /** Function to call when the color value is changed */\r\n onColorChange?: ((newColor: ColorDef) => void) | undefined;\r\n /** Function to call when the popup is closed */\r\n onClose?: ((colorValue: ColorDef) => void) | undefined;\r\n /** Disabled or not */\r\n disabled?: boolean;\r\n /** Readonly or not, color displayed on button but button will not trigger pop-up */\r\n readonly?: boolean;\r\n /** popup position. If not set RelativePosition.BottomLeft is used */\r\n popupPosition?: RelativePosition;\r\n /** Provides ability to return reference to HTMLButtonElement */\r\n ref?: React.Ref<HTMLButtonElement>;\r\n /** If true show up/down caret next to color */\r\n showCaret?: boolean;\r\n /** If true, don't propagate clicks out of the ColorPicker */\r\n captureClicks?: boolean;\r\n /** If true, don't show close button at top */\r\n hideCloseButton?: boolean;\r\n /** If set show input values */\r\n colorInputType?: \"hsl\" | \"rgb\" | \"hex\";\r\n}\r\n\r\n// Defined using following pattern (const ColorPickerPopup at bottom) to ensure useful API documentation is extracted\r\n\r\nconst ForwardRefColorPickerPopup = React.forwardRef<HTMLButtonElement, ColorPickerPopupProps>(\r\n function ForwardRefColorPickerPopup(props, ref) {\r\n const target = React.useRef<HTMLButtonElement>(null);\r\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\r\n const [showPopup, setShowPopup] = React.useState(false);\r\n const [colorDef, setColorDef] = React.useState(props.initialColor);\r\n const initialColorRef = React.useRef(props.initialColor);\r\n\r\n React.useEffect(() => {\r\n if (props.initialColor !== initialColorRef.current) {\r\n initialColorRef.current = props.initialColor;\r\n setColorDef(props.initialColor);\r\n }\r\n }, [props.initialColor]);\r\n\r\n const defaultColors = React.useRef(\r\n [\r\n ColorValue.fromTbgr(ColorByName.red),\r\n ColorValue.fromTbgr(ColorByName.orange),\r\n ColorValue.fromTbgr(ColorByName.yellow),\r\n ColorValue.fromTbgr(ColorByName.green),\r\n ColorValue.fromTbgr(ColorByName.blue),\r\n ColorValue.fromTbgr(ColorByName.mediumBlue),\r\n ColorValue.fromTbgr(ColorByName.indigo),\r\n ColorValue.fromTbgr(ColorByName.violet),\r\n ColorValue.fromTbgr(ColorByName.black),\r\n ColorValue.fromTbgr(ColorByName.white),\r\n ColorValue.fromTbgr(ColorByName.cyan),\r\n ColorValue.fromTbgr(ColorByName.fuchsia),\r\n ColorValue.fromTbgr(ColorByName.tan),\r\n ColorValue.fromTbgr(ColorByName.gray),\r\n ColorValue.fromTbgr(ColorByName.brown),\r\n ColorValue.fromTbgr(ColorByName.purple),\r\n ColorValue.fromTbgr(ColorByName.olive),\r\n ColorValue.fromTbgr(ColorByName.darkGreen),\r\n ]);\r\n\r\n // istanbul ignore next\r\n const closePopup = React.useCallback(() => {\r\n props.onClose && props.onClose(colorDef);\r\n setShowPopup(false);\r\n }, [colorDef, props]);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setShowPopup(!showPopup);\r\n }, [showPopup]);\r\n\r\n const handleColorChanged = React.useCallback((newColorValue: ColorValue) => {\r\n const newColor = ColorDef.fromTbgr(newColorValue.toTbgr());\r\n // istanbul ignore else\r\n if (!newColor.equals(colorDef)) {\r\n setColorDef(newColor);\r\n\r\n // istanbul ignore else\r\n props.onColorChange && props.onColorChange(newColor);\r\n }\r\n }, [colorDef, props]);\r\n\r\n const rgbaString = getCSSColorFromDef(colorDef);\r\n\r\n const buttonStyle = { ...props.style } as React.CSSProperties;\r\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\r\n const buttonClassNames = classnames(\"components-colorpicker-popup-button\",\r\n props.readonly && \"readonly\",\r\n props.className,\r\n );\r\n\r\n const clickHandler = (event: React.MouseEvent) => {\r\n // istanbul ignore else\r\n if (props.captureClicks)\r\n event.stopPropagation();\r\n };\r\n\r\n const colorOptions = React.useMemo(() => {\r\n if (props.colorDefs && props.colorDefs.length) {\r\n return props.colorDefs.map((def) => ColorValue.fromTbgr(def.tbgr));\r\n }\r\n if (props.colorDefs && 0 === props.colorDefs.length)\r\n return undefined;\r\n return defaultColors.current;\r\n }, [props.colorDefs]);\r\n const popupPosition = undefined !== props.popupPosition ? props.popupPosition : RelativePosition.BottomLeft;\r\n\r\n const [closeLabel] = React.useState(() => UiIModelComponents.translate(\"color.close\"));\r\n const [togglePopupLabel] = React.useState(() => UiIModelComponents.translate(\"color.toggleColorPopup\"));\r\n\r\n return (\r\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\r\n <div onClick={clickHandler}>\r\n <button data-testid=\"components-colorpicker-popup-button\" onClick={togglePopup} className={buttonClassNames} style={buttonStyle}\r\n disabled={props.disabled} ref={refs} title={togglePopupLabel} >\r\n <div className=\"components-colorpicker-button-container\">\r\n <div className=\"components-colorpicker-button-color-swatch\" style={swatchStyle} />\r\n {props.showCaret && <WebFontIcon className=\"components-caret\" iconName={showPopup ? \"icon-caret-up\" : \"icon-caret-down\"} iconSize=\"x-small\" />}\r\n </div>\r\n </button>\r\n <Popup\r\n className=\"components-colorpicker-popup\"\r\n isOpen={showPopup}\r\n position={popupPosition}\r\n onClose={closePopup}\r\n target={target.current}\r\n closeOnNestedPopupOutsideClick\r\n >\r\n <div className=\"components-colorpicker-popup-panel-padding\">\r\n {!props.hideCloseButton &&\r\n <button title={closeLabel}\r\n className={\"core-focus-trap-ignore-initial core-dialog-close icon icon-close\"}\r\n data-testid=\"core-dialog-close\"\r\n onClick={togglePopup}\r\n />}\r\n <ColorPicker selectedColor={ColorValue.fromTbgr(colorDef.tbgr)} onChangeComplete={handleColorChanged} >\r\n <ColorBuilder />\r\n {props.colorInputType &&\r\n <ColorInputPanel defaultColorFormat={props.colorInputType} />}\r\n {colorOptions &&\r\n <ColorPalette colors={colorOptions} />}\r\n </ColorPicker>\r\n </div>\r\n </Popup>\r\n </div>\r\n );\r\n }\r\n);\r\n\r\n/**\r\n * ColorPickerButton component that allows user to select a color from a set of color swatches or to define a new color.\r\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\r\n * @public\r\n */\r\nexport const ColorPickerPopup: (props: ColorPickerPopupProps) => JSX.Element | null = ForwardRefColorPickerPopup;\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatPrecision.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"FormatPrecision.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAA+B,MAAM,sBAAsB,CAAC;AAKhF;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAoB1D"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module QuantityFormat
|
|
7
7
|
*/
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { FormatType, parseFormatType } from "@itwin/core-quantity";
|
|
10
10
|
import { DecimalPrecisionSelector } from "./misc/DecimalPrecision";
|
|
11
11
|
import { FractionPrecisionSelector } from "./misc/FractionPrecision";
|
|
12
12
|
import { UiIModelComponents } from "../UiIModelComponents";
|
|
@@ -20,7 +20,7 @@ export function FormatPrecision(props) {
|
|
|
20
20
|
const newFormatProps = { ...formatProps, precision };
|
|
21
21
|
onChange && onChange(newFormatProps);
|
|
22
22
|
}, [formatProps, onChange]);
|
|
23
|
-
const formatType =
|
|
23
|
+
const formatType = parseFormatType(formatProps.type, "format");
|
|
24
24
|
const label = React.useRef(UiIModelComponents.translate("QuantityFormat.labels.precision"));
|
|
25
25
|
return (React.createElement(React.Fragment, null,
|
|
26
26
|
React.createElement("span", { className: "uicore-label" }, label.current),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"FormatPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAe,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAU3D;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;;IACzD,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAExC,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,SAAiB,EAAE,EAAE;QACpE,MAAM,cAAc,GAAG,EAAE,GAAG,WAAW,EAAE,SAAS,EAAE,CAAC;QACrD,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5B,MAAM,UAAU,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC5F,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAAG,KAAK,CAAC,OAAO,CAAQ;QACtD,UAAU,KAAK,UAAU,CAAC,UAAU,CAAC,CAAC;YACrC,oBAAC,yBAAyB,mBAAa,6BAA6B,EAAC,SAAS,EAAE,MAAA,WAAW,CAAC,SAAS,mCAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAAC,CAAC;YACjJ,oBAAC,wBAAwB,mBAAa,4BAA4B,EAAC,SAAS,EAAE,MAAA,WAAW,CAAC,SAAS,mCAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAE9I,CACJ,CAAC;AACJ,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 QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { FormatProps, FormatType, parseFormatType } from \"@itwin/core-quantity\";\r\nimport { DecimalPrecisionSelector } from \"./misc/DecimalPrecision\";\r\nimport { FractionPrecisionSelector } from \"./misc/FractionPrecision\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties of [[FormatPrecision]] component.\r\n * @alpha\r\n */\r\nexport interface FormatPrecisionProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component to show/edit Quantity Format Precision.\r\n * @alpha\r\n */\r\nexport function FormatPrecision(props: FormatPrecisionProps) {\r\n const { formatProps, onChange } = props;\r\n\r\n const handlePrecisionChange = React.useCallback((precision: number) => {\r\n const newFormatProps = { ...formatProps, precision };\r\n onChange && onChange(newFormatProps);\r\n }, [formatProps, onChange]);\r\n\r\n const formatType = parseFormatType(formatProps.type, \"format\");\r\n\r\n const label = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.precision\"));\r\n return (\r\n <>\r\n <span className={\"uicore-label\"}>{label.current}</span>\r\n {formatType === FormatType.Fractional ?\r\n <FractionPrecisionSelector data-testid=\"fraction-precision-selector\" precision={formatProps.precision ?? 0} onChange={handlePrecisionChange} /> :\r\n <DecimalPrecisionSelector data-testid=\"decimal-precision-selector\" precision={formatProps.precision ?? 0} onChange={handlePrecisionChange} />\r\n }\r\n </>\r\n );\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatType.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"FormatType.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAoB,WAAW,EAErC,MAAM,sBAAsB,CAAC;AAgC9B;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAoC5D"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { UiIModelComponents } from "../UiIModelComponents";
|
|
10
|
-
import { DecimalPrecision,
|
|
10
|
+
import { DecimalPrecision, FormatType, formatTypeToString, FractionalPrecision, parseFormatType, ScientificType, scientificTypeToString, } from "@itwin/core-quantity";
|
|
11
11
|
import { Select } from "@itwin/itwinui-react";
|
|
12
12
|
/** Component to select the format type.
|
|
13
13
|
* @alpha
|
|
@@ -32,14 +32,14 @@ export function FormatTypeOption(props) {
|
|
|
32
32
|
const { formatProps, onChange } = props;
|
|
33
33
|
const handleFormatTypeChange = React.useCallback((newType) => {
|
|
34
34
|
var _a;
|
|
35
|
-
const type =
|
|
35
|
+
const type = formatTypeToString(newType);
|
|
36
36
|
let precision;
|
|
37
37
|
let stationOffsetSize;
|
|
38
38
|
let scientificType;
|
|
39
39
|
switch (newType) { // type must be decimal, fractional, scientific, or station
|
|
40
40
|
case FormatType.Scientific:
|
|
41
41
|
precision = DecimalPrecision.Six;
|
|
42
|
-
scientificType =
|
|
42
|
+
scientificType = scientificTypeToString(ScientificType.Normalized);
|
|
43
43
|
break;
|
|
44
44
|
case FormatType.Decimal:
|
|
45
45
|
precision = DecimalPrecision.Four;
|
|
@@ -55,7 +55,7 @@ export function FormatTypeOption(props) {
|
|
|
55
55
|
const newFormatProps = { ...formatProps, type, precision, scientificType, stationOffsetSize };
|
|
56
56
|
onChange && onChange(newFormatProps);
|
|
57
57
|
}, [formatProps, onChange]);
|
|
58
|
-
const formatType =
|
|
58
|
+
const formatType = parseFormatType(formatProps.type, "format");
|
|
59
59
|
const label = React.useRef(UiIModelComponents.translate("QuantityFormat.labels.type"));
|
|
60
60
|
return (React.createElement(React.Fragment, null,
|
|
61
61
|
React.createElement("span", { className: "uicore-label.current" }, label.current),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatType.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"FormatType.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAAA;;;+F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AAC,CAAC,CAAC;IAE5B,MAAM,UAAU,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC,CAAC;IAEvF,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,sBAAsB,IAAG,KAAK,CAAC,OAAO,CAAQ;QAC/D,oBAAC,kBAAkB,mBAAa,sBAAsB,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,sBAAsB,GAAI,CAC5G,CACJ,CAAC;AACJ,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 QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\nimport { DecimalPrecision, FormatProps, FormatType, formatTypeToString, FractionalPrecision, parseFormatType,\r\n ScientificType, scientificTypeToString,\r\n} from \"@itwin/core-quantity\";\r\nimport { Select, SelectOption } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties of [[FormatTypeSelector]] component.\r\n * @alpha\r\n */\r\ninterface FormatTypeSelectorProps extends CommonProps {\r\n type: FormatType;\r\n onChange: (value: FormatType) => void;\r\n}\r\n\r\n/** Component to select the format type.\r\n * @alpha\r\n */\r\nfunction FormatTypeSelector(props: FormatTypeSelectorProps) {\r\n const { type, onChange, ...otherProps } = props;\r\n const formatOptions = React.useRef<SelectOption<FormatType>[]>([\r\n { value: FormatType.Decimal, label: UiIModelComponents.translate(\"QuantityFormat.decimal\") },\r\n { value: FormatType.Scientific, label: UiIModelComponents.translate(\"QuantityFormat.scientific\") },\r\n { value: FormatType.Station, label: UiIModelComponents.translate(\"QuantityFormat.station\") },\r\n { value: FormatType.Fractional, label: UiIModelComponents.translate(\"QuantityFormat.fractional\") },\r\n ]);\r\n\r\n const handleOnChange = React.useCallback((newValue: FormatType) => {\r\n onChange && onChange(newValue);\r\n }, [onChange]);\r\n\r\n return (\r\n <Select options={formatOptions.current} value={type} onChange={handleOnChange} size=\"small\" {...otherProps} />\r\n );\r\n}\r\n\r\n/** Properties of [[FormatTypeOptionProps]] component.\r\n * @alpha\r\n */\r\nexport interface FormatTypeOptionProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component to set the Quantity Format type.\r\n * @alpha\r\n */\r\nexport function FormatTypeOption(props: FormatTypeOptionProps) {\r\n const { formatProps, onChange } = props;\r\n const handleFormatTypeChange = React.useCallback((newType: FormatType) => {\r\n const type = formatTypeToString(newType);\r\n let precision: number | undefined;\r\n let stationOffsetSize: number | undefined;\r\n let scientificType: string | undefined;\r\n switch (newType) { // type must be decimal, fractional, scientific, or station\r\n case FormatType.Scientific:\r\n precision = DecimalPrecision.Six;\r\n scientificType = scientificTypeToString(ScientificType.Normalized);\r\n break;\r\n case FormatType.Decimal:\r\n precision = DecimalPrecision.Four;\r\n break;\r\n case FormatType.Station:\r\n precision = DecimalPrecision.Two;\r\n stationOffsetSize = formatProps.composite?.units[0].name.toLocaleLowerCase().endsWith(\"m\") ? 3 : 2;\r\n break;\r\n case FormatType.Fractional:\r\n precision = FractionalPrecision.Eight;\r\n break;\r\n }\r\n const newFormatProps = { ...formatProps, type, precision, scientificType, stationOffsetSize };\r\n onChange && onChange(newFormatProps);\r\n }, [formatProps, onChange]);\r\n\r\n const formatType = parseFormatType(formatProps.type, \"format\");\r\n const label = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.type\"));\r\n\r\n return (\r\n <>\r\n <span className={\"uicore-label.current\"}>{label.current}</span>\r\n <FormatTypeSelector data-testid=\"format-type-selector\" type={formatType} onChange={handleFormatTypeChange} />\r\n </>\r\n );\r\n}\r\n\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatUnitLabel.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"FormatUnitLabel.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAU,WAAW,EAAgC,MAAM,sBAAsB,CAAC;AAqCzF;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAsD1D"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import classnames from "classnames";
|
|
9
9
|
import * as React from "react";
|
|
10
|
-
import { Format, FormatTraits } from "@itwin/core-quantity";
|
|
10
|
+
import { Format, FormatTraits, getTraitString } from "@itwin/core-quantity";
|
|
11
11
|
import { Checkbox, Select } from "@itwin/itwinui-react";
|
|
12
12
|
import { UiIModelComponents } from "../UiIModelComponents";
|
|
13
13
|
function UomSeparatorSelector(props) {
|
|
@@ -44,7 +44,7 @@ export function FormatUnitLabel(props) {
|
|
|
44
44
|
return Format.isFormatTraitSetInProps(formatProps, trait);
|
|
45
45
|
}, [formatProps]);
|
|
46
46
|
const setFormatTrait = React.useCallback((trait, setActive) => {
|
|
47
|
-
const traitStr =
|
|
47
|
+
const traitStr = getTraitString(trait);
|
|
48
48
|
let formatTraits = [traitStr];
|
|
49
49
|
if (setActive) { // setting trait
|
|
50
50
|
// istanbul ignore else
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAe,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAe,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAgB,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQ3D,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAyB;QAC7D,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,qBAAqB,CAAC,EAAE;QACzE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,sBAAsB,CAAC,EAAE;QAC3E,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,qBA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MAAA,WAAW,CAAC,YAAY,mCAAI,EAAE,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,YAAY,CAAC,aAAa,CAAC,GAAI,CAClM,CACJ,CAAC;AACJ,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 QuantityFormat\r\n */\r\n\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Format, FormatProps, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\r\nimport { Checkbox, Select, SelectOption } from \"@itwin/itwinui-react\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\ninterface UomSeparatorSelectorProps extends CommonProps {\r\n separator: string;\r\n disabled?: boolean;\r\n onChange: (value: string) => void;\r\n}\r\n\r\nfunction UomSeparatorSelector(props: UomSeparatorSelectorProps) {\r\n const { separator, onChange, ...otherProps } = props;\r\n const uomDefaultEntries = React.useRef<SelectOption<string>[]>([\r\n { value: \"\", label: UiIModelComponents.translate(\"QuantityFormat.none\") },\r\n { value: \" \", label: UiIModelComponents.translate(\"QuantityFormat.space\") },\r\n { value: \"-\", label: UiIModelComponents.translate(\"QuantityFormat.dash\") },\r\n ]);\r\n\r\n const handleOnChange = React.useCallback((newValue: string) => {\r\n onChange && onChange(newValue);\r\n }, [onChange]);\r\n\r\n const separatorOptions = React.useMemo(() => {\r\n const completeListOfEntries: SelectOption<string>[] = [];\r\n // istanbul ignore next (only used if format already has a character that does not match standard options)\r\n if (undefined === uomDefaultEntries.current.find((option) => option.value === separator)) {\r\n completeListOfEntries.push({ value: separator, label: separator });\r\n }\r\n completeListOfEntries.push(...uomDefaultEntries.current);\r\n return completeListOfEntries;\r\n }, [separator]);\r\n\r\n return (\r\n <Select options={separatorOptions} value={separator} onChange={handleOnChange} size=\"small\" {...otherProps} />\r\n );\r\n}\r\n\r\n/** Properties of [[FormatUnitLabel]] component.\r\n * @alpha\r\n */\r\nexport interface FormatUnitLabelProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onUnitLabelChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component to set the label separator definition in a Quantity Format and if it the label is to be displayed.\r\n * @alpha\r\n */\r\nexport function FormatUnitLabel(props: FormatUnitLabelProps) {\r\n const { formatProps, onUnitLabelChange } = props;\r\n\r\n const handleSetFormatProps = React.useCallback((newProps: FormatProps) => {\r\n onUnitLabelChange && onUnitLabelChange(newProps);\r\n }, [onUnitLabelChange]);\r\n\r\n const isFormatTraitSet = React.useCallback((trait: FormatTraits) => {\r\n return Format.isFormatTraitSetInProps(formatProps, trait);\r\n }, [formatProps]);\r\n\r\n const setFormatTrait = React.useCallback((trait: FormatTraits, setActive: boolean) => {\r\n const traitStr = getTraitString(trait);\r\n let formatTraits: string[] = [traitStr];\r\n if (setActive) {// setting trait\r\n // istanbul ignore else\r\n if (formatProps.formatTraits) {\r\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\r\n // istanbul ignore else\r\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\r\n formatTraits = [...traits, traitStr];\r\n }\r\n }\r\n } else {// clearing trait\r\n // istanbul ignore next\r\n if (!formatProps.formatTraits)\r\n return;\r\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\r\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\r\n }\r\n const newFormatProps = { ...formatProps, formatTraits };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleUomSeparatorChange = React.useCallback((newSeparator: string) => {\r\n const newFormatProps = { ...formatProps, uomSeparator: newSeparator };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleShowUnitLabelChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.ShowUnitLabel, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const appendUnitLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.appendUnitLabel\"));\r\n const labelSeparator = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.labelSeparator\"));\r\n\r\n return (\r\n <>\r\n <span className={\"uicore-label\"}>{appendUnitLabel.current}</span>\r\n <Checkbox data-testid=\"show-unit-label-checkbox\" checked={isFormatTraitSet(FormatTraits.ShowUnitLabel)} onChange={handleShowUnitLabelChange} />\r\n <span className={classnames(\"uicore-label\", !isFormatTraitSet(FormatTraits.ShowUnitLabel) && \"uicore-disabled\")}>{labelSeparator.current}</span>\r\n <UomSeparatorSelector data-testid=\"uom-separator-select\" separator={formatProps.uomSeparator ?? \"\"} onChange={handleUomSeparatorChange} disabled={!isFormatTraitSet(FormatTraits.ShowUnitLabel)} />\r\n </>\r\n );\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiscFormatOptions.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"MiscFormatOptions.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAU,WAAW,EAE3B,MAAM,sBAAsB,CAAC;AAS9B;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAiL9D"}
|
|
@@ -9,7 +9,7 @@ import classnames from "classnames";
|
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
import { SpecialKey } from "@itwin/appui-abstract";
|
|
11
11
|
import { Checkbox } from "@itwin/itwinui-react";
|
|
12
|
-
import { Format, FormatTraits, FormatType, ScientificType } from "@itwin/core-quantity";
|
|
12
|
+
import { Format, FormatTraits, FormatType, getTraitString, parseFormatType, parseScientificType, parseShowSignOption, ScientificType, scientificTypeToString, showSignOptionToString, } from "@itwin/core-quantity";
|
|
13
13
|
import { SignOptionSelector } from "./misc/SignOption";
|
|
14
14
|
import { ThousandsSeparator } from "./misc/ThousandsSeparator";
|
|
15
15
|
import { DecimalSeparatorSelector } from "./misc/DecimalSeparator";
|
|
@@ -30,12 +30,12 @@ export function MiscFormatOptions(props) {
|
|
|
30
30
|
return Format.isFormatTraitSetInProps(formatProps, trait);
|
|
31
31
|
}, [formatProps]);
|
|
32
32
|
const handleShowSignChange = React.useCallback((option) => {
|
|
33
|
-
const newShowSignOption =
|
|
33
|
+
const newShowSignOption = showSignOptionToString(option);
|
|
34
34
|
const newFormatProps = { ...formatProps, showSignOption: newShowSignOption };
|
|
35
35
|
handleSetFormatProps(newFormatProps);
|
|
36
36
|
}, [formatProps, handleSetFormatProps]);
|
|
37
37
|
const setFormatTrait = React.useCallback((trait, setActive) => {
|
|
38
|
-
const traitStr =
|
|
38
|
+
const traitStr = getTraitString(trait);
|
|
39
39
|
let formatTraits = [traitStr];
|
|
40
40
|
if (setActive) { // setting trait
|
|
41
41
|
// istanbul ignore else
|
|
@@ -90,14 +90,14 @@ export function MiscFormatOptions(props) {
|
|
|
90
90
|
handleSetFormatProps(newFormatProps);
|
|
91
91
|
}, [formatProps, isFormatTraitSet, handleSetFormatProps]);
|
|
92
92
|
const handleScientificTypeChange = React.useCallback((type) => {
|
|
93
|
-
const newFormatProps = { ...formatProps, scientificType:
|
|
93
|
+
const newFormatProps = { ...formatProps, scientificType: scientificTypeToString(type) };
|
|
94
94
|
handleSetFormatProps(newFormatProps);
|
|
95
95
|
}, [formatProps, handleSetFormatProps]);
|
|
96
96
|
const handleFormatChange = React.useCallback((newFormatProps) => {
|
|
97
97
|
handleSetFormatProps(newFormatProps);
|
|
98
98
|
}, [handleSetFormatProps]);
|
|
99
|
-
const formatType = React.useMemo(() =>
|
|
100
|
-
const showSignOption = React.useMemo(() => { var _a; return
|
|
99
|
+
const formatType = React.useMemo(() => parseFormatType(formatProps.type, "format"), [formatProps.type]);
|
|
100
|
+
const showSignOption = React.useMemo(() => { var _a; return parseShowSignOption((_a = formatProps.showSignOption) !== null && _a !== void 0 ? _a : "onlyNegative", "format"); }, [formatProps.showSignOption]);
|
|
101
101
|
const handleToggleButtonClick = React.useCallback(() => {
|
|
102
102
|
onShowHideOptions(!showOptions);
|
|
103
103
|
}, [onShowHideOptions, showOptions]);
|
|
@@ -152,7 +152,7 @@ export function MiscFormatOptions(props) {
|
|
|
152
152
|
React.createElement("span", { className: classnames("uicore-label", formatType !== FormatType.Fractional && "uicore-disabled") }, fractionDashLabel.current),
|
|
153
153
|
React.createElement(Checkbox, { "data-testid": "fraction-dash", checked: isFormatTraitSet(FormatTraits.FractionDash), onChange: handleUseFractionDashChange, disabled: formatType !== FormatType.Fractional }),
|
|
154
154
|
React.createElement("span", { className: classnames("uicore-label", formatType !== FormatType.Scientific && "uicore-disabled") }, scientificTypeLabel.current),
|
|
155
|
-
React.createElement(ScientificTypeSelector, { "data-testid": "scientific-type-selector", type: (formatProps.scientificType && formatProps.scientificType.length > 0) ?
|
|
155
|
+
React.createElement(ScientificTypeSelector, { "data-testid": "scientific-type-selector", type: (formatProps.scientificType && formatProps.scientificType.length > 0) ? parseScientificType(formatProps.scientificType, "custom") : ScientificType.Normalized, disabled: formatType !== FormatType.Scientific, onChange: handleScientificTypeChange }),
|
|
156
156
|
props.children,
|
|
157
157
|
enableMinimumProperties && showOptions && React.createElement("a", { onClick: handleToggleButtonClick, onKeyUp: handleKeyUpOnLink, className: "components-quantityFormat-more-less", role: "link", "data-testid": "quantityFormat-less", tabIndex: 0 }, lessLabel.current))));
|
|
158
158
|
}
|