@itwin/imodel-components-react 4.0.0-dev.15 → 4.0.0-dev.17

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.
Files changed (172) hide show
  1. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  2. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +2 -2
  3. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +1 -1
  4. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +63 -63
  6. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +90 -90
  8. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  9. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  10. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  11. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  12. package/lib/cjs/imodel-components-react/color/HueSlider.scss +61 -61
  13. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  14. package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +35 -35
  15. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  16. package/lib/cjs/imodel-components-react/color/Swatch.scss +22 -22
  17. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  18. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  19. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
  20. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  21. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
  22. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  23. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  24. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  25. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  26. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
  27. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  28. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +51 -51
  29. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  30. package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
  31. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +0 -21
  32. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  33. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +1 -25
  34. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  35. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  36. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  37. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  38. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  39. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +59 -59
  40. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  41. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  43. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  44. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  45. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  46. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  47. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  48. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  49. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  50. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  51. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  52. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  53. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  54. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  55. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  56. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  57. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  58. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  59. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  60. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +26 -26
  61. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +28 -28
  63. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  64. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +105 -105
  65. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  66. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  67. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  68. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  69. package/lib/cjs/imodel-components-react/timeline/Timeline.scss +164 -164
  70. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  71. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +177 -177
  72. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +0 -29
  73. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  74. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  75. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  76. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  77. package/lib/cjs/imodel-components-react.d.ts +0 -1
  78. package/lib/cjs/imodel-components-react.d.ts.map +1 -1
  79. package/lib/cjs/imodel-components-react.js +0 -1
  80. package/lib/cjs/imodel-components-react.js.map +1 -1
  81. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  82. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +2 -2
  83. package/lib/esm/imodel-components-react/color/AlphaSlider.js +1 -1
  84. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  85. package/lib/esm/imodel-components-react/color/AlphaSlider.scss +63 -63
  86. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  87. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +90 -90
  88. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  89. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  90. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  91. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  92. package/lib/esm/imodel-components-react/color/HueSlider.scss +61 -61
  93. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  94. package/lib/esm/imodel-components-react/color/SaturationPicker.scss +35 -35
  95. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  96. package/lib/esm/imodel-components-react/color/Swatch.scss +22 -22
  97. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  98. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  99. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
  100. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  101. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
  102. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  103. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  104. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  105. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  106. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
  107. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  108. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +51 -51
  109. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  110. package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
  111. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +0 -21
  112. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  113. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +0 -24
  114. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  115. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  116. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  117. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  118. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  119. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +59 -59
  120. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  121. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  122. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  123. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  124. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  125. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  126. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  127. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  128. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  129. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  130. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  131. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  132. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  133. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  134. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  135. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  136. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  137. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  138. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  139. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  140. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +26 -26
  141. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  142. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +28 -28
  143. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  144. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +105 -105
  145. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  146. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  147. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  148. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  149. package/lib/esm/imodel-components-react/timeline/Timeline.scss +164 -164
  150. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  151. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +177 -177
  152. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +0 -29
  153. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  154. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  155. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  156. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  157. package/lib/esm/imodel-components-react.d.ts +0 -1
  158. package/lib/esm/imodel-components-react.d.ts.map +1 -1
  159. package/lib/esm/imodel-components-react.js +0 -1
  160. package/lib/esm/imodel-components-react.js.map +1 -1
  161. package/lib/public/locales/en/UiIModelComponents.json +139 -139
  162. package/package.json +5 -5
  163. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +0 -22
  164. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts.map +0 -1
  165. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +0 -150
  166. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +0 -1
  167. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +0 -94
  168. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +0 -22
  169. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts.map +0 -1
  170. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +0 -123
  171. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +0 -1
  172. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +0 -94
@@ -1 +1 @@
1
- {"version":3,"file":"WeightEditor.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/editors/WeightEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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,0BAA0B,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EAC1G,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,iBAC5B,0BAA0B,GAAG,CACvC,CACP,CAAC;IACJ,CAAC;CACF;AAxID,oCAwIC;AAED;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,qCAAkB;IAC1D,uBAAuB;IACvB,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,CAAC;CACF;AALD,oDAKC;AAED,wCAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,oBAAoB,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\nimport \"./WeightEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { PropertyRecord, PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames } from \"@itwin/appui-abstract\";\r\nimport { PropertyEditorBase, PropertyEditorManager, PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\r\nimport { WeightPickerButton } from \"../lineweight/WeightPickerButton\";\r\n\r\n// cspell:ignore lineweight\r\n\r\n/** @internal */\r\ninterface WeightEditorState {\r\n weightValue: number;\r\n readonly: boolean;\r\n isDisabled?: boolean;\r\n}\r\n\r\n/** WeightEditor React component that is a property editor for picking a weight using a [[WeightPickerButton]] component\r\n * @public\r\n */\r\nexport class WeightEditor extends React.PureComponent<PropertyEditorProps, WeightEditorState> implements TypeEditor {\r\n private _control: any | null = null;\r\n private _isMounted = false;\r\n private _availableWeights: number[] = [];\r\n private _divElement = React.createRef<HTMLDivElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<WeightEditorState> = {\r\n weightValue: 0,\r\n readonly: false,\r\n };\r\n\r\n constructor(props: PropertyEditorProps) {\r\n super(props);\r\n\r\n // TODO: add support for following if we need to specify set of weights to display\r\n // const record = this.props.propertyRecord;\r\n // if (record && record.property && record.property.editor && record.property.editor.params) {\r\n // const weightParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ColorData) as WeightEditorParams;\r\n // // istanbul ignore else\r\n // if (weightParams) {\r\n // weightParams.weightValues.forEach((weight: number) => {\r\n // this._availableWeights.push(weight);\r\n // });\r\n // }\r\n // }\r\n }\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: this.state.weightValue,\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._divElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n let containsFocus = false;\r\n // istanbul ignore else\r\n if (this._divElement.current)\r\n containsFocus = this._divElement.current.contains(document.activeElement);\r\n return containsFocus;\r\n }\r\n\r\n private setFocus(): void {\r\n // istanbul ignore else\r\n if (this._control && !this.state.isDisabled) {\r\n this._control.setFocus();\r\n }\r\n }\r\n\r\n private _onLineWeightPick = (weight: number) => {\r\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\r\n\r\n this.setState({\r\n weightValue: weight,\r\n }, async () => {\r\n // istanbul ignore else\r\n if (propertyRecord && this.props.onCommit) {\r\n const propertyValue = await this.getPropertyValue();\r\n // istanbul ignore else\r\n if (propertyValue !== undefined) {\r\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\r\n }\r\n }\r\n });\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 async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n let initialValue = 0;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n initialValue = record.value.value as number;\r\n }\r\n\r\n const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;\r\n const isDisabled = record ? record.isDisabled : undefined;\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState(\r\n { weightValue: initialValue, readonly, isDisabled },\r\n () => {\r\n if (this.props.setFocus) {\r\n this.setFocus();\r\n }\r\n },\r\n );\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <div className={classnames(\"components-weight-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\r\n <WeightPickerButton ref={(control) => this._control = control}\r\n activeWeight={this.state.weightValue}\r\n weights={this._availableWeights.length > 0 ? /* istanbul ignore next */ this._availableWeights : undefined}\r\n disabled={this.state.isDisabled ? true : false}\r\n readonly={this.state.readonly}\r\n onLineWeightPick={this._onLineWeightPick}\r\n data-testid=\"components-weight-editor\" />\r\n </div>\r\n );\r\n }\r\n}\r\n\r\n/** Weight Property Editor registered for the \"number\" type name and \"weight-picker\" editor name.\r\n * It uses the [[WeightEditor]] React component.\r\n * @public\r\n */\r\nexport class WeightPropertyEditor extends PropertyEditorBase {\r\n // istanbul ignore next\r\n public get reactNode(): React.ReactNode {\r\n return <WeightEditor />;\r\n }\r\n}\r\n\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, WeightPropertyEditor, StandardEditorNames.WeightPicker);\r\n"]}
1
+ {"version":3,"file":"WeightEditor.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/editors/WeightEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+BAA6B;AAC7B,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAmI;AACnI,8DAAqH;AACrH,yEAAsE;AAWtE;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,aAAqD;IAY3F,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAZP,aAAQ,GAAe,IAAI,CAAC;QAC5B,eAAU,GAAG,KAAK,CAAC;QACnB,sBAAiB,GAAa,EAAE,CAAC;QACjC,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAgC;YAC5D,WAAW,EAAE,CAAC;YACd,QAAQ,EAAE,KAAK;SAChB,CAAC;QAqDM,sBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAgC,CAAC;YAEnE,IAAI,CAAC,QAAQ,CAAC;gBACZ,WAAW,EAAE,MAAM;aACpB,EAAE,KAAK,IAAI,EAAE;gBACZ,uBAAuB;gBACvB,IAAI,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACzC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACpD,uBAAuB;oBACvB,IAAI,aAAa,KAAK,SAAS,EAAE;wBAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,C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,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW;YAC1H,oBAAC,uCAAkB,IAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,EAC3D,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACpC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EAC1G,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,iBAC5B,0BAA0B,GAAG,CACvC,CACP,CAAC;IACJ,CAAC;CACF;AAxID,oCAwIC;AAED;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,qCAAkB;IAC1D,uBAAuB;IACvB,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,CAAC;CACF;AALD,oDAKC;AAED,wCAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,oBAAoB,EAAE,oCAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./WeightEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { PropertyRecord, PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { PropertyEditorBase, PropertyEditorManager, PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { WeightPickerButton } from \"../lineweight/WeightPickerButton\";\n\n// cspell:ignore lineweight\n\n/** @internal */\ninterface WeightEditorState {\n weightValue: number;\n readonly: boolean;\n isDisabled?: boolean;\n}\n\n/** WeightEditor React component that is a property editor for picking a weight using a [[WeightPickerButton]] component\n * @public\n */\nexport class WeightEditor extends React.PureComponent<PropertyEditorProps, WeightEditorState> implements TypeEditor {\n private _control: any | null = null;\n private _isMounted = false;\n private _availableWeights: number[] = [];\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<WeightEditorState> = {\n weightValue: 0,\n readonly: false,\n };\n\n constructor(props: PropertyEditorProps) {\n super(props);\n\n // TODO: add support for following if we need to specify set of weights to display\n // const record = this.props.propertyRecord;\n // if (record && record.property && record.property.editor && record.property.editor.params) {\n // const weightParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ColorData) as WeightEditorParams;\n // // istanbul ignore else\n // if (weightParams) {\n // weightParams.weightValues.forEach((weight: number) => {\n // this._availableWeights.push(weight);\n // });\n // }\n // }\n }\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.weightValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private setFocus(): void {\n // istanbul ignore else\n if (this._control && !this.state.isDisabled) {\n this._control.setFocus();\n }\n }\n\n private _onLineWeightPick = (weight: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState({\n weightValue: weight,\n }, async () => {\n // istanbul ignore else\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n });\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState(\n { weightValue: initialValue, readonly, isDisabled },\n () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n },\n );\n }\n\n /** @internal */\n public override render() {\n return (\n <div className={classnames(\"components-weight-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\n <WeightPickerButton ref={(control) => this._control = control}\n activeWeight={this.state.weightValue}\n weights={this._availableWeights.length > 0 ? /* istanbul ignore next */ this._availableWeights : undefined}\n disabled={this.state.isDisabled ? true : false}\n readonly={this.state.readonly}\n onLineWeightPick={this._onLineWeightPick}\n data-testid=\"components-weight-editor\" />\n </div>\n );\n }\n}\n\n/** Weight Property Editor registered for the \"number\" type name and \"weight-picker\" editor name.\n * It uses the [[WeightEditor]] React component.\n * @public\n */\nexport class WeightPropertyEditor extends PropertyEditorBase {\n // istanbul ignore next\n public get reactNode(): React.ReactNode {\n return <WeightEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, WeightPropertyEditor, StandardEditorNames.WeightPicker);\n"]}
@@ -1,16 +1,16 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
6
-
7
- $components-weight-editor-item-height: 100%;
8
-
9
- .components-weight-editor {
10
- font-family: var(--iui-font-sans);
11
- font-size: var(--iui-font-size-1);
12
- color: var(--iui-color-text);
13
- border: none;
14
- box-sizing: border-box;
15
- height: $components-weight-editor-item-height;
16
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
6
+
7
+ $components-weight-editor-item-height: 100%;
8
+
9
+ .components-weight-editor {
10
+ font-family: var(--iui-font-sans);
11
+ font-size: var(--iui-font-size-1);
12
+ color: var(--iui-color-text);
13
+ border: none;
14
+ box-sizing: border-box;
15
+ height: $components-weight-editor-item-height;
16
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityInput.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/QuantityInput.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,wDAA8F;AAC9F,wDAA8C;AAG9C,8DAA2D;AAC3D,8DAAsD;AAkBtD;;GAEG;AACH,SAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAiB;IAC5H,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,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,GAAG,EAAE;YACV,yBAAS,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;QAC/F,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,oBAAC,8BAAW,mBAAa,2BAA2B,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EACvG,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAI,CAAC;AACvI,CAAC;AA7DD,sCA6DC","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 Inputs\r\n */\r\n\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { IModelApp, QuantityFormatsChangedArgs, QuantityTypeArg } from \"@itwin/core-frontend\";\r\nimport { Parser } from \"@itwin/core-quantity\";\r\nimport { ParseResults } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\nimport { ParsedInput } from \"@itwin/components-react\";\r\n\r\n/** Props for [[QuantityInput]] control\r\n * @beta\r\n */\r\nexport interface QuantityProps extends CommonProps {\r\n /** Initial magnitude in 'persistence' units. See `getPersistenceUnitByQuantityType` in [QuantityFormatter]($core-frontend) */\r\n initialValue: number;\r\n /** Type of quantity being input. */\r\n quantityType: QuantityTypeArg;\r\n /** Function to call in the quantity value is changed. The value returned will be in 'persistence' units. */\r\n onQuantityChange: (newQuantityValue: number) => void;\r\n /** Set to `true` if value is for display only */\r\n readonly?: boolean;\r\n /** Provides ability to return reference to HTMLInputElement */\r\n ref?: React.Ref<HTMLInputElement>;\r\n}\r\n\r\n/** Input control that allows users to input a quantity and show the formatted string that represents the value.\r\n * @beta\r\n */\r\nexport function QuantityInput({ initialValue, quantityType, readonly, className, style, onQuantityChange, ref }: QuantityProps) {\r\n const [formatterSpec, setFormatterSpec] = React.useState(() => IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType));\r\n const [parserSpec, setParserSpec] = React.useState(() => IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n\r\n const formatValue = React.useCallback((value: number) => {\r\n // istanbul ignore else\r\n if (formatterSpec) {\r\n return formatterSpec.applyFormatting(value);\r\n }\r\n // istanbul ignore next\r\n return value.toFixed(2);\r\n }, [formatterSpec]);\r\n\r\n const parseString = React.useCallback((userInput: string): ParseResults => {\r\n // istanbul ignore else\r\n if (parserSpec) {\r\n const parseResult = IModelApp.quantityFormatter.parseToQuantityValue(userInput, parserSpec);\r\n // istanbul ignore else\r\n if (Parser.isParsedQuantity(parseResult)) {\r\n return { value: parseResult.value };\r\n } else {\r\n const statusId = Parser.isParseError(parseResult) ? parseResult.error.toString() : \"Unknown\";\r\n return { parseError: `${UiIModelComponents.translate(\"QuantityInput.NoParserDefined\")}${statusId}` };\r\n }\r\n }\r\n // istanbul ignore next\r\n return { parseError: UiIModelComponents.translate(\"QuantityInput.NoParserDefined\") };\r\n }, [parserSpec]);\r\n\r\n const classNames = classnames(className, \"components-quantity-input\");\r\n\r\n React.useEffect(() => {\r\n const handleUnitSystemChanged = ((): void => {\r\n setFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType));\r\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n });\r\n\r\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(handleUnitSystemChanged);\r\n return () => {\r\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.removeListener(handleUnitSystemChanged);\r\n };\r\n }, [quantityType]);\r\n\r\n React.useEffect(() => {\r\n const handleUnitSystemChanged = ((args: QuantityFormatsChangedArgs): void => {\r\n const quantityKey = IModelApp.quantityFormatter.getQuantityTypeKey(quantityType);\r\n // istanbul ignore else\r\n if (args.quantityType === quantityKey) {\r\n setFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType));\r\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n }\r\n });\r\n\r\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(handleUnitSystemChanged);\r\n return () => {\r\n IModelApp.quantityFormatter.onQuantityFormatsChanged.removeListener(handleUnitSystemChanged);\r\n };\r\n }, [quantityType]);\r\n\r\n return <ParsedInput data-testid=\"components-quantity-input\" ref={ref} style={style} className={classNames}\r\n onChange={onQuantityChange} initialValue={initialValue} readonly={readonly} formatValue={formatValue} parseString={parseString} />;\r\n}\r\n"]}
1
+ {"version":3,"file":"QuantityInput.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/QuantityInput.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,wDAA8F;AAC9F,wDAA8C;AAG9C,8DAA2D;AAC3D,8DAAsD;AAkBtD;;GAEG;AACH,SAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAiB;IAC5H,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,yBAAS,CAAC,iBAAiB,CAAC,+BAA+B,CAAC,YAAY,CAAC,CAAC,CAAC;IAC1I,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,yBAAS,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,YAAY,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G,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EACvG,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAI,CAAC;AACvI,CAAC;AA7DD,sCA6DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Inputs\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { IModelApp, QuantityFormatsChangedArgs, QuantityTypeArg } from \"@itwin/core-frontend\";\nimport { Parser } from \"@itwin/core-quantity\";\nimport { ParseResults } from \"@itwin/appui-abstract\";\nimport { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { ParsedInput } from \"@itwin/components-react\";\n\n/** Props for [[QuantityInput]] control\n * @beta\n */\nexport interface QuantityProps extends CommonProps {\n /** Initial magnitude in 'persistence' units. See `getPersistenceUnitByQuantityType` in [QuantityFormatter]($core-frontend) */\n initialValue: number;\n /** Type of quantity being input. */\n quantityType: QuantityTypeArg;\n /** Function to call in the quantity value is changed. The value returned will be in 'persistence' units. */\n onQuantityChange: (newQuantityValue: number) => void;\n /** Set to `true` if value is for display only */\n readonly?: boolean;\n /** Provides ability to return reference to HTMLInputElement */\n ref?: React.Ref<HTMLInputElement>;\n}\n\n/** Input control that allows users to input a quantity and show the formatted string that represents the value.\n * @beta\n */\nexport function QuantityInput({ initialValue, quantityType, readonly, className, style, onQuantityChange, ref }: QuantityProps) {\n const [formatterSpec, setFormatterSpec] = React.useState(() => IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType));\n const [parserSpec, setParserSpec] = React.useState(() => IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\n\n const formatValue = React.useCallback((value: number) => {\n // istanbul ignore else\n if (formatterSpec) {\n return formatterSpec.applyFormatting(value);\n }\n // istanbul ignore next\n return value.toFixed(2);\n }, [formatterSpec]);\n\n const parseString = React.useCallback((userInput: string): ParseResults => {\n // istanbul ignore else\n if (parserSpec) {\n const parseResult = IModelApp.quantityFormatter.parseToQuantityValue(userInput, parserSpec);\n // istanbul ignore else\n if (Parser.isParsedQuantity(parseResult)) {\n return { value: parseResult.value };\n } else {\n const statusId = Parser.isParseError(parseResult) ? parseResult.error.toString() : \"Unknown\";\n return { parseError: `${UiIModelComponents.translate(\"QuantityInput.NoParserDefined\")}${statusId}` };\n }\n }\n // istanbul ignore next\n return { parseError: UiIModelComponents.translate(\"QuantityInput.NoParserDefined\") };\n }, [parserSpec]);\n\n const classNames = classnames(className, \"components-quantity-input\");\n\n React.useEffect(() => {\n const handleUnitSystemChanged = ((): void => {\n setFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType));\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\n });\n\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(handleUnitSystemChanged);\n return () => {\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.removeListener(handleUnitSystemChanged);\n };\n }, [quantityType]);\n\n React.useEffect(() => {\n const handleUnitSystemChanged = ((args: QuantityFormatsChangedArgs): void => {\n const quantityKey = IModelApp.quantityFormatter.getQuantityTypeKey(quantityType);\n // istanbul ignore else\n if (args.quantityType === quantityKey) {\n setFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType));\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\n }\n });\n\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(handleUnitSystemChanged);\n return () => {\n IModelApp.quantityFormatter.onQuantityFormatsChanged.removeListener(handleUnitSystemChanged);\n };\n }, [quantityType]);\n\n return <ParsedInput data-testid=\"components-quantity-input\" ref={ref} style={style} className={classNames}\n onChange={onQuantityChange} initialValue={initialValue} readonly={readonly} formatValue={formatValue} parseString={parseString} />;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityNumberInput.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/QuantityNumberInput.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAC/B,kDAAyC;AACzC,0DAAmD;AACnD,wDAA8F;AAC9F,wDAAoJ;AACpJ,wDAAyD;AACzD,oEAA0G;AAkC1G,wEAAwE;AACxE,SAAS,mBAAmB,CAAC,aAAwC;IACnE,IAAI,SAAS,KAAK,aAAa;QAC7B,OAAO,aAAa,CAAC;IACvB,MAAM,oBAAoB,GAAyB,EAAE,CAAC;IACtD,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC;QAC3C,mBAAmB,EAAE,IAAI;QACzB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,4BAAY,CAAC,aAAa;QACvE,IAAI,EAAE,0BAAU,CAAC,OAAO;QACxB,SAAS,EAAE,0BAAU,CAAC,OAAO,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,gCAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS;KACrH,CAAC,CAAC;IACH,OAAO,IAAI,6BAAa,CAAC,cAAc,EAAE,SAAS,EAAE,oBAAoB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;AAC3G,CAAC;AAED,SAAS,oCAAoC,CAAC,KAAa,EAAE,eAAiD,EAAE,IAAe;IAC7H,uBAAuB;IACvB,IAAI,CAAC,eAAe,IAAI,CAAC,KAA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OAAG,CAAC,CAAC,CAAC,oBAAC,uCAAiB,OAAG,CAAC;IAE9E,OAAO,CACL,6BAAK,SAAS,EAAE,gBAAgB;QAC9B,6BAAK,SAAS,EAAC,6DAA6D;YAC1E,oBAAC,qBAAK,IAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,wBAAwB,EAAE,SAAS,EAAE,aAAa,EAClG,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAC,OAAO,KAAK,UAAU,GAAI;YAC3E,6BAAK,SAAS,EAAE,IAAA,oBAAU,EAAC,mDAAmD,EAAE,gBAAgB,IAAI,oCAAoC,CAAC;gBAEvI,6BAAK,SAAS,EAAC,kFAAkF,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa;oBACpI,oBAAC,iBAAI,IAAC,QAAQ,EAAE,OAAO,GAAI,CACvB;gBAEN,6BAAK,SAAS,EAAC,oFAAoF,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe;oBACxI,oBAAC,iBAAI,IAAC,QAAQ,EAAE,SAAS,GAAI,CACzB,CACF,CACF;QACN,8BAAM,SAAS,EAAC,wCAAwC,IAAE,SAAS,CAAQ,CACtE,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACU,QAAA,mBAAmB,GAA4D,6BAA6B,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 Inputs\r\n */\r\n\r\nimport \"./QuantityNumberInput.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Icon } from \"@itwin/core-react\";\r\nimport { SpecialKey } from \"@itwin/appui-abstract\";\r\nimport { IModelApp, QuantityFormatsChangedArgs, QuantityTypeArg } from \"@itwin/core-frontend\";\r\nimport { DecimalPrecision, FormatterSpec, FormatTraits, FormatType, Parser, ParserSpec, UnitConversionSpec, UnitProps } from \"@itwin/core-quantity\";\r\nimport { Input, InputProps } from \"@itwin/itwinui-react\";\r\nimport { SvgCaretDown, SvgCaretDownSmall, SvgCaretUp, SvgCaretUpSmall } from \"@itwin/itwinui-icons-react\";\r\n\r\n/** Step function prototype for [[QuantityNumberInput]] component\r\n * @beta\r\n */\r\nexport type StepFunctionProp = number | ((direction: string) => number | undefined);\r\n\r\n/** Properties for the [[QuantityNumberInput]] component\r\n * @beta\r\n */\r\nexport interface QuantityNumberInputProps extends Omit<InputProps, \"value\" | \"min\" | \"max\" | \"step\" | \"onFocus\" | \"onChange\"> {\r\n /** Initial magnitude in 'persistence' units. See `getPersistenceUnitByQuantityType` in [QuantityFormatter]($core-frontend).\r\n * Set to `undefined` to show placeholder text */\r\n persistenceValue?: number;\r\n /** CSS class name for the QuantityNumberInput component container div */\r\n containerClassName?: string;\r\n /** number or function\tNumber.MIN_SAFE_INTEGER */\r\n min?: number;\r\n /** number or function\tdefaults to Number.MAX_SAFE_INTEGER */\r\n max?: number;\r\n /** increment step value used while incrementing or decrementing (up/down buttons or arrow keys) defaults to 1. */\r\n step?: StepFunctionProp;\r\n /** Set to true to \"snap\" to the closest step value while incrementing or decrementing (up/down buttons or arrow keys). */\r\n snap?: boolean;\r\n /** Function to call when the quantity value is changed. The value returned will be in 'persistence' units. */\r\n onChange?: (value: number) => void;\r\n /** if true up/down buttons are shown larger and side by side */\r\n showTouchButtons?: boolean;\r\n /** Provides ability to return reference to HTMLInputElement */\r\n ref?: React.Ref<HTMLInputElement>;\r\n /** Type of quantity being input. */\r\n quantityType: QuantityTypeArg;\r\n}\r\n\r\n/** adjust formatter spec to show only primary unit without a label. */\r\nfunction adjustFormatterSpec(formatterSpec: FormatterSpec | undefined) {\r\n if (undefined === formatterSpec)\r\n return formatterSpec;\r\n const singleUnitConversion: UnitConversionSpec[] = [];\r\n singleUnitConversion.push(formatterSpec.unitConversions[0]);\r\n const newFormat = formatterSpec.format.clone({\r\n showOnlyPrimaryUnit: true,\r\n traits: formatterSpec.format.formatTraits & ~FormatTraits.ShowUnitLabel,\r\n type: FormatType.Decimal,\r\n precision: FormatType.Decimal !== formatterSpec.format.type ? DecimalPrecision.Four : formatterSpec.format.precision,\r\n });\r\n return new FormatterSpec(\"single-value\", newFormat, singleUnitConversion, formatterSpec.persistenceUnit);\r\n}\r\n\r\nfunction convertValueFromDisplayToPersistence(value: number, unitConversions: UnitConversionSpec[] | undefined, unit: UnitProps) {\r\n // istanbul ignore next\r\n if (!unitConversions || 0 === unitConversions.length)\r\n return value;\r\n\r\n const unitConversion = unitConversions.find((spec) => spec.name === unit.name);\r\n // istanbul ignore next\r\n if (!unitConversion)\r\n return value;\r\n\r\n const convertedValue = (value * unitConversion.conversion.factor) + unitConversion.conversion.offset;\r\n return convertedValue;\r\n}\r\n\r\nfunction getUnitLabel(parserSpec: ParserSpec | undefined) {\r\n if (undefined === parserSpec)\r\n return \"\";\r\n\r\n const format = parserSpec.format;\r\n // istanbul ignore else\r\n if (!format.units || !format.units[0])\r\n return parserSpec.outUnit.label;\r\n const [unit, label] = format.units[0];\r\n // istanbul ignore next\r\n return label ?? unit.label;\r\n}\r\n\r\nconst ForwardRefQuantityNumberInput = React.forwardRef<HTMLInputElement, QuantityNumberInputProps>(\r\n function ForwardRefQuantityNumberInput(props, ref) {\r\n\r\n const { containerClassName, persistenceValue, min, max,\r\n onChange, onBlur, onKeyDown, step, snap, showTouchButtons, quantityType, ...otherProps } = props;\r\n const rawValueRef = React.useRef(persistenceValue);\r\n\r\n const [formatterSpec, setFormatterSpec] = React.useState(() => adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\r\n const [parserSpec, setParserSpec] = React.useState(() => IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n\r\n const formatValue = React.useCallback((value: number | undefined) => {\r\n if (undefined === value)\r\n return \"\";\r\n\r\n // istanbul ignore else\r\n if (formatterSpec) {\r\n return formatterSpec.applyFormatting(value);\r\n }\r\n // istanbul ignore next\r\n return value.toFixed(2);\r\n }, [formatterSpec]);\r\n\r\n const lastFormattedValueRef = React.useRef(formatValue(persistenceValue));\r\n const [formattedValue, setFormattedValue] = React.useState(() => lastFormattedValueRef.current);\r\n\r\n React.useEffect(() => {\r\n const handleUnitSystemChanged = ((): void => {\r\n setFormatterSpec(adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\r\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n });\r\n\r\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(handleUnitSystemChanged);\r\n return () => {\r\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.removeListener(handleUnitSystemChanged);\r\n };\r\n }, [quantityType]);\r\n\r\n React.useEffect(() => {\r\n const handleUnitSystemChanged = ((args: QuantityFormatsChangedArgs): void => {\r\n const quantityKey = IModelApp.quantityFormatter.getQuantityTypeKey(quantityType);\r\n // istanbul ignore else\r\n if (args.quantityType === quantityKey) {\r\n setFormatterSpec(adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\r\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n }\r\n });\r\n\r\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(handleUnitSystemChanged);\r\n return () => {\r\n IModelApp.quantityFormatter.onQuantityFormatsChanged.removeListener(handleUnitSystemChanged);\r\n };\r\n }, [quantityType]);\r\n\r\n const unitLabel = getUnitLabel(parserSpec);\r\n\r\n // See if new initialValue props have changed since component mounted\r\n React.useEffect(() => {\r\n rawValueRef.current = persistenceValue;\r\n const currentFormattedValue = formatValue(rawValueRef.current);\r\n setFormattedValue(currentFormattedValue);\r\n }, [formatValue, persistenceValue]);\r\n\r\n // this is the unprocessed input from user, it is not processed until blur or enter key press\r\n const handleDisplayValueChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormattedValue(event.currentTarget.value);\r\n }, []);\r\n\r\n const updateValue = React.useCallback((newValue: number) => {\r\n let persistedValue = newValue;\r\n // istanbul ignore else\r\n if (parserSpec) {\r\n // convert value from display unit to persistence unit\r\n const [unit] = parserSpec.format.units ? parserSpec.format.units[0] : /* istanbul ignore next */[parserSpec.outUnit];\r\n persistedValue = convertValueFromDisplayToPersistence(newValue, parserSpec.unitConversions, unit);\r\n rawValueRef.current = persistedValue;\r\n }\r\n const newFormattedVal = formatValue(persistedValue);\r\n onChange && onChange(persistedValue);\r\n setFormattedValue(newFormattedVal);\r\n\r\n }, [formatValue, onChange, parserSpec]);\r\n\r\n /**\r\n * Used internally to parse the argument x to it's numeric representation.\r\n * If the argument cannot be converted to finite number returns 0; If a\r\n * \"precision\" prop is specified uses it round the number with that\r\n * precision (no fixed precision here because the return value is float, not\r\n * string).\r\n */\r\n const parseInternal = React.useCallback((x: string | undefined) => {\r\n if (!x)\r\n return 0;\r\n\r\n let n = parseFloat(x);\r\n // istanbul ignore next\r\n if (isNaN(n) || !isFinite(n)) {\r\n n = 0;\r\n }\r\n\r\n const localPrecision = 6; // TODO get a reasonable value from format\r\n const q = Math.pow(10, localPrecision);\r\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\r\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\r\n n = Math.min(Math.max(n, localMin), localMax);\r\n n = Math.round(n * q) / q;\r\n\r\n return n;\r\n }, [min, max]);\r\n\r\n const updateValueFromString = React.useCallback((strValue: string) => {\r\n // istanbul ignore else\r\n if (parserSpec) {\r\n const parseResult = IModelApp.quantityFormatter.parseToQuantityValue(strValue, parserSpec);\r\n // at this point we should have a string value in persistence units without a label\r\n if (Parser.isParsedQuantity(parseResult)) {\r\n const persistedValue = parseResult.value; // in persistence units\r\n // set strValue and let it go through parseInternal which will ensure min/max limits are observed\r\n strValue = formatValue(persistedValue)!;\r\n } else {\r\n // istanbul ignore else\r\n if (rawValueRef.current) { // restore last known good value\r\n const lastKnownFormattedVal = formatValue(rawValueRef.current);\r\n setFormattedValue(lastKnownFormattedVal);\r\n return;\r\n }\r\n }\r\n }\r\n const newValue = parseInternal(strValue);\r\n // istanbul ignore else\r\n if (undefined !== newValue)\r\n updateValue(newValue);\r\n }, [formatValue, parseInternal, parserSpec, updateValue]);\r\n\r\n const handleBlur = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\r\n const newVal = parseInternal(event.target.value);\r\n onBlur && onBlur(event);\r\n updateValue(newVal);\r\n }, [parseInternal, updateValue, onBlur]);\r\n\r\n const getIncrementValue = React.useCallback((increment: boolean) => {\r\n if (typeof step === \"function\") {\r\n const stepVal = step(increment ? \"up\" : \"down\");\r\n return stepVal ? stepVal : 1;\r\n }\r\n\r\n return !step ? 1 : step;\r\n }, [step]);\r\n\r\n /**\r\n * The internal method that actually sets the new value on the input\r\n */\r\n const applyStep = React.useCallback((increment: boolean) => {\r\n const incrementValue = getIncrementValue(increment);\r\n\r\n let num = parseInternal(formattedValue) + (increment ? incrementValue : -incrementValue);\r\n if (snap) {\r\n num = Math.round(num / incrementValue) * incrementValue;\r\n }\r\n\r\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\r\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\r\n num = Math.min(Math.max(num, localMin), localMax);\r\n\r\n updateValue(num);\r\n }, [formattedValue, getIncrementValue, max, min, parseInternal, snap, updateValue]);\r\n\r\n const handleKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.Enter) {\r\n updateValueFromString(event.currentTarget.value);\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Escape) {\r\n setFormattedValue(formatValue(rawValueRef.current));\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowDown) {\r\n applyStep(false);\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp) {\r\n applyStep(true);\r\n event.preventDefault();\r\n }\r\n onKeyDown && onKeyDown(event);\r\n }, [onKeyDown, updateValueFromString, formatValue, applyStep]);\r\n\r\n const handleDownClick = React.useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\r\n applyStep(false);\r\n event.preventDefault();\r\n }, [applyStep]);\r\n\r\n const handleUpClick = React.useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\r\n applyStep(true);\r\n event.preventDefault();\r\n }, [applyStep]);\r\n\r\n // istanbul ignore next\r\n const handleFocus = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\r\n event.currentTarget.select();\r\n }, []);\r\n\r\n const isDisabled = !!otherProps.disabled;\r\n const containerClasses = classnames(\"component-quantity-number-input-container\",\r\n containerClassName, showTouchButtons && \"component-number-buttons-for-touch\",\r\n isDisabled && \"component-quantity-number-input-disabled\",\r\n );\r\n\r\n const caretUp = showTouchButtons ? <SvgCaretUp /> : <SvgCaretUpSmall />;\r\n const caretDown = showTouchButtons ? <SvgCaretDown /> : <SvgCaretDownSmall />;\r\n\r\n return (\r\n <div className={containerClasses} >\r\n <div className=\"component-quantity-number-input-value-and-buttons-container\">\r\n <Input ref={ref} value={formattedValue} onChange={handleDisplayValueChange} onKeyDown={handleKeyDown}\r\n onBlur={handleBlur} onFocus={handleFocus} size=\"small\" {...otherProps} />\r\n <div className={classnames(\"component-quantity-number-input-buttons-container\", showTouchButtons && \"component-number-buttons-for-touch\")}>\r\n { /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\r\n <div className=\"component-quantity-number-input-button component-quantity-number-input-button-up\" tabIndex={-1} onClick={handleUpClick}>\r\n <Icon iconSpec={caretUp} />\r\n </div>\r\n { /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\r\n <div className=\"component-quantity-number-input-button component-quantity-number-input-button-down\" tabIndex={-1} onClick={handleDownClick}>\r\n <Icon iconSpec={caretDown} />\r\n </div>\r\n </div>\r\n </div>\r\n <span className=\"component-quantity-number-input-suffix\">{unitLabel}</span>\r\n </div >\r\n );\r\n }\r\n);\r\n\r\n/** The QuantityNumberInput component accepts input for quantity values. The quantity value is shown as a single numeric value and the quantity's\r\n * \"display\" unit is shown next to the input control. The \"display\" unit is determined by the active unit system as defined by the [QuantityFormatter]($frontend).\r\n * The control also display buttons to increment and decrement the \"displayed\" value. The value reported by via the onChange function is in \"persistence\"\r\n * units that can be stored in the iModel.\r\n * @beta\r\n */\r\nexport const QuantityNumberInput: (props: QuantityNumberInputProps) => JSX.Element | null = ForwardRefQuantityNumberInput;\r\n"]}
1
+ {"version":3,"file":"QuantityNumberInput.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/QuantityNumberInput.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAC/B,kDAAyC;AACzC,0DAAmD;AACnD,wDAA8F;AAC9F,wDAAoJ;AACpJ,wDAAyD;AACzD,oEAA0G;AAkC1G,wEAAwE;AACxE,SAAS,mBAAmB,CAAC,aAAwC;IACnE,IAAI,SAAS,KAAK,aAAa;QAC7B,OAAO,aAAa,CAAC;IACvB,MAAM,oBAAoB,GAAyB,EAAE,CAAC;IACtD,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC;QAC3C,mBAAmB,EAAE,IAAI;QACzB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,4BAAY,CAAC,aAAa;QACvE,IAAI,EAAE,0BAAU,CAAC,OAAO;QACxB,SAAS,EAAE,0BAAU,CAAC,OAAO,KAAK,aA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,6BAA6B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Inputs\n */\n\nimport \"./QuantityNumberInput.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\nimport { IModelApp, QuantityFormatsChangedArgs, QuantityTypeArg } from \"@itwin/core-frontend\";\nimport { DecimalPrecision, FormatterSpec, FormatTraits, FormatType, Parser, ParserSpec, UnitConversionSpec, UnitProps } from \"@itwin/core-quantity\";\nimport { Input, InputProps } from \"@itwin/itwinui-react\";\nimport { SvgCaretDown, SvgCaretDownSmall, SvgCaretUp, SvgCaretUpSmall } from \"@itwin/itwinui-icons-react\";\n\n/** Step function prototype for [[QuantityNumberInput]] component\n * @beta\n */\nexport type StepFunctionProp = number | ((direction: string) => number | undefined);\n\n/** Properties for the [[QuantityNumberInput]] component\n * @beta\n */\nexport interface QuantityNumberInputProps extends Omit<InputProps, \"value\" | \"min\" | \"max\" | \"step\" | \"onFocus\" | \"onChange\"> {\n /** Initial magnitude in 'persistence' units. See `getPersistenceUnitByQuantityType` in [QuantityFormatter]($core-frontend).\n * Set to `undefined` to show placeholder text */\n persistenceValue?: number;\n /** CSS class name for the QuantityNumberInput component container div */\n containerClassName?: string;\n /** number or function\tNumber.MIN_SAFE_INTEGER */\n min?: number;\n /** number or function\tdefaults to Number.MAX_SAFE_INTEGER */\n max?: number;\n /** increment step value used while incrementing or decrementing (up/down buttons or arrow keys) defaults to 1. */\n step?: StepFunctionProp;\n /** Set to true to \"snap\" to the closest step value while incrementing or decrementing (up/down buttons or arrow keys). */\n snap?: boolean;\n /** Function to call when the quantity value is changed. The value returned will be in 'persistence' units. */\n onChange?: (value: number) => void;\n /** if true up/down buttons are shown larger and side by side */\n showTouchButtons?: boolean;\n /** Provides ability to return reference to HTMLInputElement */\n ref?: React.Ref<HTMLInputElement>;\n /** Type of quantity being input. */\n quantityType: QuantityTypeArg;\n}\n\n/** adjust formatter spec to show only primary unit without a label. */\nfunction adjustFormatterSpec(formatterSpec: FormatterSpec | undefined) {\n if (undefined === formatterSpec)\n return formatterSpec;\n const singleUnitConversion: UnitConversionSpec[] = [];\n singleUnitConversion.push(formatterSpec.unitConversions[0]);\n const newFormat = formatterSpec.format.clone({\n showOnlyPrimaryUnit: true,\n traits: formatterSpec.format.formatTraits & ~FormatTraits.ShowUnitLabel,\n type: FormatType.Decimal,\n precision: FormatType.Decimal !== formatterSpec.format.type ? DecimalPrecision.Four : formatterSpec.format.precision,\n });\n return new FormatterSpec(\"single-value\", newFormat, singleUnitConversion, formatterSpec.persistenceUnit);\n}\n\nfunction convertValueFromDisplayToPersistence(value: number, unitConversions: UnitConversionSpec[] | undefined, unit: UnitProps) {\n // istanbul ignore next\n if (!unitConversions || 0 === unitConversions.length)\n return value;\n\n const unitConversion = unitConversions.find((spec) => spec.name === unit.name);\n // istanbul ignore next\n if (!unitConversion)\n return value;\n\n const convertedValue = (value * unitConversion.conversion.factor) + unitConversion.conversion.offset;\n return convertedValue;\n}\n\nfunction getUnitLabel(parserSpec: ParserSpec | undefined) {\n if (undefined === parserSpec)\n return \"\";\n\n const format = parserSpec.format;\n // istanbul ignore else\n if (!format.units || !format.units[0])\n return parserSpec.outUnit.label;\n const [unit, label] = format.units[0];\n // istanbul ignore next\n return label ?? unit.label;\n}\n\nconst ForwardRefQuantityNumberInput = React.forwardRef<HTMLInputElement, QuantityNumberInputProps>(\n function ForwardRefQuantityNumberInput(props, ref) {\n\n const { containerClassName, persistenceValue, min, max,\n onChange, onBlur, onKeyDown, step, snap, showTouchButtons, quantityType, ...otherProps } = props;\n const rawValueRef = React.useRef(persistenceValue);\n\n const [formatterSpec, setFormatterSpec] = React.useState(() => adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\n const [parserSpec, setParserSpec] = React.useState(() => IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\n\n const formatValue = React.useCallback((value: number | undefined) => {\n if (undefined === value)\n return \"\";\n\n // istanbul ignore else\n if (formatterSpec) {\n return formatterSpec.applyFormatting(value);\n }\n // istanbul ignore next\n return value.toFixed(2);\n }, [formatterSpec]);\n\n const lastFormattedValueRef = React.useRef(formatValue(persistenceValue));\n const [formattedValue, setFormattedValue] = React.useState(() => lastFormattedValueRef.current);\n\n React.useEffect(() => {\n const handleUnitSystemChanged = ((): void => {\n setFormatterSpec(adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\n });\n\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(handleUnitSystemChanged);\n return () => {\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.removeListener(handleUnitSystemChanged);\n };\n }, [quantityType]);\n\n React.useEffect(() => {\n const handleUnitSystemChanged = ((args: QuantityFormatsChangedArgs): void => {\n const quantityKey = IModelApp.quantityFormatter.getQuantityTypeKey(quantityType);\n // istanbul ignore else\n if (args.quantityType === quantityKey) {\n setFormatterSpec(adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\n }\n });\n\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(handleUnitSystemChanged);\n return () => {\n IModelApp.quantityFormatter.onQuantityFormatsChanged.removeListener(handleUnitSystemChanged);\n };\n }, [quantityType]);\n\n const unitLabel = getUnitLabel(parserSpec);\n\n // See if new initialValue props have changed since component mounted\n React.useEffect(() => {\n rawValueRef.current = persistenceValue;\n const currentFormattedValue = formatValue(rawValueRef.current);\n setFormattedValue(currentFormattedValue);\n }, [formatValue, persistenceValue]);\n\n // this is the unprocessed input from user, it is not processed until blur or enter key press\n const handleDisplayValueChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n setFormattedValue(event.currentTarget.value);\n }, []);\n\n const updateValue = React.useCallback((newValue: number) => {\n let persistedValue = newValue;\n // istanbul ignore else\n if (parserSpec) {\n // convert value from display unit to persistence unit\n const [unit] = parserSpec.format.units ? parserSpec.format.units[0] : /* istanbul ignore next */[parserSpec.outUnit];\n persistedValue = convertValueFromDisplayToPersistence(newValue, parserSpec.unitConversions, unit);\n rawValueRef.current = persistedValue;\n }\n const newFormattedVal = formatValue(persistedValue);\n onChange && onChange(persistedValue);\n setFormattedValue(newFormattedVal);\n\n }, [formatValue, onChange, parserSpec]);\n\n /**\n * Used internally to parse the argument x to it's numeric representation.\n * If the argument cannot be converted to finite number returns 0; If a\n * \"precision\" prop is specified uses it round the number with that\n * precision (no fixed precision here because the return value is float, not\n * string).\n */\n const parseInternal = React.useCallback((x: string | undefined) => {\n if (!x)\n return 0;\n\n let n = parseFloat(x);\n // istanbul ignore next\n if (isNaN(n) || !isFinite(n)) {\n n = 0;\n }\n\n const localPrecision = 6; // TODO get a reasonable value from format\n const q = Math.pow(10, localPrecision);\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\n n = Math.min(Math.max(n, localMin), localMax);\n n = Math.round(n * q) / q;\n\n return n;\n }, [min, max]);\n\n const updateValueFromString = React.useCallback((strValue: string) => {\n // istanbul ignore else\n if (parserSpec) {\n const parseResult = IModelApp.quantityFormatter.parseToQuantityValue(strValue, parserSpec);\n // at this point we should have a string value in persistence units without a label\n if (Parser.isParsedQuantity(parseResult)) {\n const persistedValue = parseResult.value; // in persistence units\n // set strValue and let it go through parseInternal which will ensure min/max limits are observed\n strValue = formatValue(persistedValue)!;\n } else {\n // istanbul ignore else\n if (rawValueRef.current) { // restore last known good value\n const lastKnownFormattedVal = formatValue(rawValueRef.current);\n setFormattedValue(lastKnownFormattedVal);\n return;\n }\n }\n }\n const newValue = parseInternal(strValue);\n // istanbul ignore else\n if (undefined !== newValue)\n updateValue(newValue);\n }, [formatValue, parseInternal, parserSpec, updateValue]);\n\n const handleBlur = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\n const newVal = parseInternal(event.target.value);\n onBlur && onBlur(event);\n updateValue(newVal);\n }, [parseInternal, updateValue, onBlur]);\n\n const getIncrementValue = React.useCallback((increment: boolean) => {\n if (typeof step === \"function\") {\n const stepVal = step(increment ? \"up\" : \"down\");\n return stepVal ? stepVal : 1;\n }\n\n return !step ? 1 : step;\n }, [step]);\n\n /**\n * The internal method that actually sets the new value on the input\n */\n const applyStep = React.useCallback((increment: boolean) => {\n const incrementValue = getIncrementValue(increment);\n\n let num = parseInternal(formattedValue) + (increment ? incrementValue : -incrementValue);\n if (snap) {\n num = Math.round(num / incrementValue) * incrementValue;\n }\n\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\n num = Math.min(Math.max(num, localMin), localMax);\n\n updateValue(num);\n }, [formattedValue, getIncrementValue, max, min, parseInternal, snap, updateValue]);\n\n const handleKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (event.key === SpecialKey.Enter) {\n updateValueFromString(event.currentTarget.value);\n event.preventDefault();\n } else if (event.key === SpecialKey.Escape) {\n setFormattedValue(formatValue(rawValueRef.current));\n event.preventDefault();\n } else if (event.key === SpecialKey.ArrowDown) {\n applyStep(false);\n event.preventDefault();\n } else if (event.key === SpecialKey.ArrowUp) {\n applyStep(true);\n event.preventDefault();\n }\n onKeyDown && onKeyDown(event);\n }, [onKeyDown, updateValueFromString, formatValue, applyStep]);\n\n const handleDownClick = React.useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n applyStep(false);\n event.preventDefault();\n }, [applyStep]);\n\n const handleUpClick = React.useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n applyStep(true);\n event.preventDefault();\n }, [applyStep]);\n\n // istanbul ignore next\n const handleFocus = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\n event.currentTarget.select();\n }, []);\n\n const isDisabled = !!otherProps.disabled;\n const containerClasses = classnames(\"component-quantity-number-input-container\",\n containerClassName, showTouchButtons && \"component-number-buttons-for-touch\",\n isDisabled && \"component-quantity-number-input-disabled\",\n );\n\n const caretUp = showTouchButtons ? <SvgCaretUp /> : <SvgCaretUpSmall />;\n const caretDown = showTouchButtons ? <SvgCaretDown /> : <SvgCaretDownSmall />;\n\n return (\n <div className={containerClasses} >\n <div className=\"component-quantity-number-input-value-and-buttons-container\">\n <Input ref={ref} value={formattedValue} onChange={handleDisplayValueChange} onKeyDown={handleKeyDown}\n onBlur={handleBlur} onFocus={handleFocus} size=\"small\" {...otherProps} />\n <div className={classnames(\"component-quantity-number-input-buttons-container\", showTouchButtons && \"component-number-buttons-for-touch\")}>\n { /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div className=\"component-quantity-number-input-button component-quantity-number-input-button-up\" tabIndex={-1} onClick={handleUpClick}>\n <Icon iconSpec={caretUp} />\n </div>\n { /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div className=\"component-quantity-number-input-button component-quantity-number-input-button-down\" tabIndex={-1} onClick={handleDownClick}>\n <Icon iconSpec={caretDown} />\n </div>\n </div>\n </div>\n <span className=\"component-quantity-number-input-suffix\">{unitLabel}</span>\n </div >\n );\n }\n);\n\n/** The QuantityNumberInput component accepts input for quantity values. The quantity value is shown as a single numeric value and the quantity's\n * \"display\" unit is shown next to the input control. The \"display\" unit is determined by the active unit system as defined by the [QuantityFormatter]($frontend).\n * The control also display buttons to increment and decrement the \"displayed\" value. The value reported by via the onChange function is in \"persistence\"\n * units that can be stored in the iModel.\n * @beta\n */\nexport const QuantityNumberInput: (props: QuantityNumberInputProps) => JSX.Element | null = ForwardRefQuantityNumberInput;\n"]}
@@ -1,106 +1,106 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/base/base";
6
-
7
- .component-quantity-number-input-container {
8
- display: flex;
9
- align-items: center;
10
- position: relative;
11
- padding: 0;
12
- margin: 0;
13
- box-sizing: border-box;
14
-
15
- .component-quantity-number-input-suffix {
16
- padding-left: 0.25em;
17
- }
18
-
19
- .component-quantity-number-input-value-and-buttons-container {
20
- position: relative;
21
- padding: 0;
22
- margin: 0;
23
- box-sizing: border-box;
24
-
25
- input {
26
- margin: 0;
27
- padding-right: 1.5em;
28
- }
29
-
30
- &.component-number-buttons-for-touch {
31
- input {
32
- padding-right: 3.5em;
33
- }
34
- }
35
-
36
- .component-quantity-number-input-buttons-container {
37
- position: absolute;
38
- top: 0;
39
- right: 0;
40
- width: 20px;
41
- height: 100%;
42
- @include uicore-centered;
43
- flex-direction: column;
44
-
45
- .component-quantity-number-input-button {
46
- font-size: 8px;
47
- outline: none;
48
- height: 100%;
49
- width: 100%;
50
- @include uicore-centered;
51
-
52
- &:hover {
53
- color: var(--iui-color-text-accent-hover);
54
- transition-duration: 150ms;
55
- }
56
-
57
- &.component-quantity-number-input-button-up {
58
- padding-top: 1px;
59
- }
60
-
61
- &.component-quantity-number-input-button-down {
62
- padding-top: 1px;
63
- }
64
- }
65
-
66
- &.component-number-buttons-for-touch {
67
- width: 3.5em;
68
- flex-direction: row-reverse;
69
-
70
- .component-quantity-number-input-button {
71
- font-size: 1em;
72
-
73
- &:hover {
74
- color: unset;
75
- transition-duration: unset;
76
- }
77
-
78
- &.component-quantity-number-input-button-up {
79
- padding-top: 2px;
80
- }
81
-
82
- &.component-quantity-number-input-button-down {
83
- padding-top: 2px;
84
- }
85
- }
86
- }
87
- }
88
- }
89
-
90
- &.component-quantity-number-input-disabled {
91
- .component-quantity-number-input-suffix {
92
- -webkit-user-select: none;
93
- user-select: none;
94
- color: var(--iui-color-text-disabled);
95
- }
96
- .component-quantity-number-input-button-up {
97
- pointer-events: none;
98
- color: var(--iui-color-text-disabled);
99
- }
100
-
101
- .component-quantity-number-input-button-down {
102
- pointer-events: none;
103
- color: var(--iui-color-text-disabled);
104
- }
105
- }
106
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/core-react/lib/cjs/core-react/base/base";
6
+
7
+ .component-quantity-number-input-container {
8
+ display: flex;
9
+ align-items: center;
10
+ position: relative;
11
+ padding: 0;
12
+ margin: 0;
13
+ box-sizing: border-box;
14
+
15
+ .component-quantity-number-input-suffix {
16
+ padding-left: 0.25em;
17
+ }
18
+
19
+ .component-quantity-number-input-value-and-buttons-container {
20
+ position: relative;
21
+ padding: 0;
22
+ margin: 0;
23
+ box-sizing: border-box;
24
+
25
+ input {
26
+ margin: 0;
27
+ padding-right: 1.5em;
28
+ }
29
+
30
+ &.component-number-buttons-for-touch {
31
+ input {
32
+ padding-right: 3.5em;
33
+ }
34
+ }
35
+
36
+ .component-quantity-number-input-buttons-container {
37
+ position: absolute;
38
+ top: 0;
39
+ right: 0;
40
+ width: 20px;
41
+ height: 100%;
42
+ @include uicore-centered;
43
+ flex-direction: column;
44
+
45
+ .component-quantity-number-input-button {
46
+ font-size: 8px;
47
+ outline: none;
48
+ height: 100%;
49
+ width: 100%;
50
+ @include uicore-centered;
51
+
52
+ &:hover {
53
+ color: var(--iui-color-text-accent-hover);
54
+ transition-duration: 150ms;
55
+ }
56
+
57
+ &.component-quantity-number-input-button-up {
58
+ padding-top: 1px;
59
+ }
60
+
61
+ &.component-quantity-number-input-button-down {
62
+ padding-top: 1px;
63
+ }
64
+ }
65
+
66
+ &.component-number-buttons-for-touch {
67
+ width: 3.5em;
68
+ flex-direction: row-reverse;
69
+
70
+ .component-quantity-number-input-button {
71
+ font-size: 1em;
72
+
73
+ &:hover {
74
+ color: unset;
75
+ transition-duration: unset;
76
+ }
77
+
78
+ &.component-quantity-number-input-button-up {
79
+ padding-top: 2px;
80
+ }
81
+
82
+ &.component-quantity-number-input-button-down {
83
+ padding-top: 2px;
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+
90
+ &.component-quantity-number-input-disabled {
91
+ .component-quantity-number-input-suffix {
92
+ -webkit-user-select: none;
93
+ user-select: none;
94
+ color: var(--iui-color-text-disabled);
95
+ }
96
+ .component-quantity-number-input-button-up {
97
+ pointer-events: none;
98
+ color: var(--iui-color-text-disabled);
99
+ }
100
+
101
+ .component-quantity-number-input-button-down {
102
+ pointer-events: none;
103
+ color: var(--iui-color-text-disabled);
104
+ }
105
+ }
106
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"Swatch.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/lineweight/Swatch.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yBAAuB;AACvB,4DAAoC;AACpC,6CAA+B;AAG/B,oEAAiE;AAoBjE;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK,CAAC,aAAoC;IAC9E,gBAAgB;IAChB,YAAY,KAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,iBAAiB;QAC/B,sCAAsC;QACtC,iLAAiL;IACnL,CAAC;IAEe,MAAM;QACpB,MAAM,EACJ,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,6CAA6C;QAC9F,wCAAwC;QACxC,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,qBAAqB;UACxD,GAAG,IAAI,CAAC,KAAK,CAAC;QAEf,IAAI,UAAU,GAAG,EAAE,CAAC;QAEpB,IAAI,QAAQ,EAAE;YACZ,UAAU,GAAG,IAAA,uCAAkB,EAAC,QAAQ,CAAC,CAAC;SAC3C;QAED,MAAM,WAAW,GAAwB,QAAQ,CAAC,CAAC;YACjD;gBACE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;gBACnB,KAAK,EAAE,UAAU;aAClB,CAAC,CAAC;YACH;gBACE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;aACpB,CAAC;QAEJ,MAAM,QAAQ,GAAwB,QAAQ,CAAC,CAAC;YAC9C;gBACE,MAAM,EAAE,GAAG,MAAM,IAAI;gBACrB,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;YACH;gBACE,MAAM,EAAE,GAAG,MAAM,IAAI;aACtB,CAAC;QAEJ,MAAM,WAAW,GAAG,CAAC,EAAoB,EAAE,EAAE;YAC3C,uBAAuB;YACvB,IAAI,OAAO;gBACT,OAAO,EAAE,CAAC;QACd,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,oBAAU,EACxB,8BAA8B,EAC9B,SAAS,IAAI,YAAY,EACzB,QAAQ,IAAI,UAAU,EACtB,SAAS,CACV,CAAC;QAEF,OAAO,CACL,mCAAY,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ;YACrG,CAAC,SAAS,IAAI,kCAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ;YAC/C,6BAAK,KAAK,EAAE,QAAQ,GAAI,CACjB,CACV,CAAC;IACJ,CAAC;CACF;AA9DD,4CA8DC","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 LineWeight\r\n */\r\n\r\nimport \"./Swatch.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ColorDef } from \"@itwin/core-common\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { getCSSColorFromDef } from \"../color/getCSSColorFromDef\";\r\n\r\n/** Properties for the [[LineWeightSwatch]] React component\r\n * @public\r\n */\r\nexport interface LineWeightSwatchProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** color specification */\r\n weight: number;\r\n /** color specification */\r\n colorDef?: ColorDef;\r\n /** hide the weight label */\r\n hideLabel?: boolean;\r\n /** Disabled or not */\r\n disabled?: boolean;\r\n /** Readonly or not */\r\n readonly?: boolean;\r\n /** function to run when user selects a line weight swatch */\r\n onClick?: () => void;\r\n}\r\n\r\n/** LineWeightSwatch Functional component\r\n * @public\r\n */\r\nexport class LineWeightSwatch extends React.PureComponent<LineWeightSwatchProps> {\r\n /** @internal */\r\n constructor(props: LineWeightSwatchProps) {\r\n super(props);\r\n }\r\n\r\n public override componentDidMount() {\r\n // eslint-disable-next-line no-console\r\n // console.log(`LineWeightSwatchProps.componentDidMount setFocusRef=${this.props.setFocusRef} focusRef=${this.props.focusRef && this.props.focusRef.current ? \"set\" : \"unset\"}`);\r\n }\r\n\r\n public override render() {\r\n const {\r\n onClick, colorDef, weight, hideLabel, className, // do not pass on color swatch specific props\r\n // eslint-disable-next-line comma-dangle\r\n disabled, readonly, ...otherProps // pass-through props\r\n } = this.props;\r\n\r\n let rgbaString = \"\";\r\n\r\n if (colorDef) {\r\n rgbaString = getCSSColorFromDef(colorDef);\r\n }\r\n\r\n const buttonStyle: React.CSSProperties = colorDef ?\r\n {\r\n ...this.props.style,\r\n color: rgbaString,\r\n } :\r\n {\r\n ...this.props.style,\r\n };\r\n\r\n const svgStyle: React.CSSProperties = colorDef ?\r\n {\r\n height: `${weight}px`,\r\n background: rgbaString,\r\n } :\r\n {\r\n height: `${weight}px`,\r\n };\r\n\r\n const handleClick = (_e: React.MouseEvent) => {\r\n // istanbul ignore else\r\n if (onClick)\r\n onClick();\r\n };\r\n\r\n const classes = classnames(\r\n \"components-lineweight-swatch\",\r\n hideLabel && \"hide-label\",\r\n readonly && \"readonly\",\r\n className,\r\n );\r\n\r\n return (\r\n <button {...otherProps} style={buttonStyle} className={classes} onClick={handleClick} disabled={disabled}>\r\n {!hideLabel && <span>{weight.toFixed(0)}</span>}\r\n <div style={svgStyle} />\r\n </button>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Swatch.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/lineweight/Swatch.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yBAAuB;AACvB,4DAAoC;AACpC,6CAA+B;AAG/B,oEAAiE;AAoBjE;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK,CAAC,aAAoC;IAC9E,gBAAgB;IAChB,YAAY,KAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,iBAAiB;QAC/B,sCAAsC;QACtC,iLAAiL;IACnL,CAAC;IAEe,MAAM;QACpB,MAAM,EACJ,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,6CAA6C;QAC9F,wCAAwC;QACxC,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,qBAAqB;UACxD,GAAG,IAAI,CAAC,KAAK,CAAC;QAEf,IAAI,UAAU,GAAG,EAAE,CAAC;QAEpB,IAAI,QAAQ,EAAE;YACZ,UAAU,GAAG,IAAA,uCAAkB,EAAC,QAAQ,CAAC,CAAC;SAC3C;QAED,MAAM,WAAW,GAAwB,QAAQ,CAAC,CAAC;YACjD;gBACE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;gBACnB,KAAK,EAAE,UAAU;aAClB,CAAC,CAAC;YACH;gBACE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;aACpB,CAAC;QAEJ,MAAM,QAAQ,GAAwB,QAAQ,CAAC,CAAC;YAC9C;gBACE,MAAM,EAAE,GAAG,MAAM,IAAI;gBACrB,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;YACH;gBACE,MAAM,EAAE,GAAG,MAAM,IAAI;aACtB,CAAC;QAEJ,MAAM,WAAW,GAAG,CAAC,EAAoB,EAAE,EAAE;YAC3C,uBAAuB;YACvB,IAAI,OAAO;gBACT,OAAO,EAAE,CAAC;QACd,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,oBAAU,EACxB,8BAA8B,EAC9B,SAAS,IAAI,YAAY,EACzB,QAAQ,IAAI,UAAU,EACtB,SAAS,CACV,CAAC;QAEF,OAAO,CACL,mCAAY,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ;YACrG,CAAC,SAAS,IAAI,kCAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ;YAC/C,6BAAK,KAAK,EAAE,QAAQ,GAAI,CACjB,CACV,CAAC;IACJ,CAAC;CACF;AA9DD,4CA8DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module LineWeight\n */\n\nimport \"./Swatch.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorDef } from \"@itwin/core-common\";\nimport { CommonProps } from \"@itwin/core-react\";\nimport { getCSSColorFromDef } from \"../color/getCSSColorFromDef\";\n\n/** Properties for the [[LineWeightSwatch]] React component\n * @public\n */\nexport interface LineWeightSwatchProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\n /** color specification */\n weight: number;\n /** color specification */\n colorDef?: ColorDef;\n /** hide the weight label */\n hideLabel?: boolean;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: boolean;\n /** function to run when user selects a line weight swatch */\n onClick?: () => void;\n}\n\n/** LineWeightSwatch Functional component\n * @public\n */\nexport class LineWeightSwatch extends React.PureComponent<LineWeightSwatchProps> {\n /** @internal */\n constructor(props: LineWeightSwatchProps) {\n super(props);\n }\n\n public override componentDidMount() {\n // eslint-disable-next-line no-console\n // console.log(`LineWeightSwatchProps.componentDidMount setFocusRef=${this.props.setFocusRef} focusRef=${this.props.focusRef && this.props.focusRef.current ? \"set\" : \"unset\"}`);\n }\n\n public override render() {\n const {\n onClick, colorDef, weight, hideLabel, className, // do not pass on color swatch specific props\n // eslint-disable-next-line comma-dangle\n disabled, readonly, ...otherProps // pass-through props\n } = this.props;\n\n let rgbaString = \"\";\n\n if (colorDef) {\n rgbaString = getCSSColorFromDef(colorDef);\n }\n\n const buttonStyle: React.CSSProperties = colorDef ?\n {\n ...this.props.style,\n color: rgbaString,\n } :\n {\n ...this.props.style,\n };\n\n const svgStyle: React.CSSProperties = colorDef ?\n {\n height: `${weight}px`,\n background: rgbaString,\n } :\n {\n height: `${weight}px`,\n };\n\n const handleClick = (_e: React.MouseEvent) => {\n // istanbul ignore else\n if (onClick)\n onClick();\n };\n\n const classes = classnames(\n \"components-lineweight-swatch\",\n hideLabel && \"hide-label\",\n readonly && \"readonly\",\n className,\n );\n\n return (\n <button {...otherProps} style={buttonStyle} className={classes} onClick={handleClick} disabled={disabled}>\n {!hideLabel && <span>{weight.toFixed(0)}</span>}\n <div style={svgStyle} />\n </button>\n );\n }\n}\n"]}
@@ -1,48 +1,48 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
6
-
7
- .components-lineweight-swatch {
8
- font-size: var(--iui-font-size-1);
9
- color: var(--iui-color-text);
10
- border: none;
11
- background: inherit;
12
- width: 100%;
13
- display: flex;
14
- flex-direction: row;
15
- align-items: center;
16
- padding: 3px 15px 3px 0;
17
- min-height: 22px;
18
- box-sizing: border-box;
19
-
20
- // remove inner focus ring that is specific to Firefox.
21
- &::-moz-focus-inner {
22
- border: 0px;
23
- }
24
-
25
- &:focus {
26
- outline: 1px solid $buic-row-selection;
27
- }
28
-
29
- &[disabled] {
30
- opacity: 0.2;
31
- cursor: default;
32
- }
33
-
34
- > span {
35
- width: 1.5em;
36
- text-align: right;
37
- }
38
-
39
- > div {
40
- flex: 1;
41
- background: $buic-foreground-body;
42
- margin-left: 15px;
43
- }
44
- }
45
-
46
- .components-lineweight-swatch.hide-label > span {
47
- display: none;
48
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
6
+
7
+ .components-lineweight-swatch {
8
+ font-size: var(--iui-font-size-1);
9
+ color: var(--iui-color-text);
10
+ border: none;
11
+ background: inherit;
12
+ width: 100%;
13
+ display: flex;
14
+ flex-direction: row;
15
+ align-items: center;
16
+ padding: 3px 15px 3px 0;
17
+ min-height: 22px;
18
+ box-sizing: border-box;
19
+
20
+ // remove inner focus ring that is specific to Firefox.
21
+ &::-moz-focus-inner {
22
+ border: 0px;
23
+ }
24
+
25
+ &:focus {
26
+ outline: 1px solid $buic-row-selection;
27
+ }
28
+
29
+ &[disabled] {
30
+ opacity: 0.2;
31
+ cursor: default;
32
+ }
33
+
34
+ > span {
35
+ width: 1.5em;
36
+ text-align: right;
37
+ }
38
+
39
+ > div {
40
+ flex: 1;
41
+ background: $buic-foreground-body;
42
+ margin-left: 15px;
43
+ }
44
+ }
45
+
46
+ .components-lineweight-swatch.hide-label > span {
47
+ display: none;
48
+ }