@itwin/imodel-components-react 3.1.0-dev.25 → 3.1.0-dev.29
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 +39 -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.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/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.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 +19 -19
- 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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Change Log - @itwin/imodel-components-react
|
|
2
|
+
|
|
3
|
+
This log was last generated on Mon, 24 Jan 2022 14:00:52 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.0.0
|
|
6
|
+
Mon, 24 Jan 2022 14:00:52 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- The Cartographic creation API now takes an interface as an argument with named properties. This will avoid callers mixing up the order of longitude, latitude, and height.
|
|
11
|
+
- Update colorpicker to support RGB input
|
|
12
|
+
- Upgrade target to ES2019 and deliver both a CommonJs and ESModule version of package
|
|
13
|
+
- rename to @itwin/imodel-components-react
|
|
14
|
+
- Replace usage of I18N with generic Localization interface.
|
|
15
|
+
- Remove deprecate QuantityFormatter methods
|
|
16
|
+
- Update snapshots
|
|
17
|
+
- tool.run and tool.parseAndRun are now async methods
|
|
18
|
+
- Deprecate obsolete code.
|
|
19
|
+
- Create empty frontstage and UiItemsProviders to populate it and update how ContentGroups are defined.
|
|
20
|
+
- update immer to fix security warning
|
|
21
|
+
- Deprecate and promote apis
|
|
22
|
+
- Deprecate obsolete APIs. Publish beta APIs from last release.
|
|
23
|
+
- Upgraded itwinui-react to 1.16.2. Fixed editor sizes.
|
|
24
|
+
- Remove files generated by bad merge
|
|
25
|
+
- Update disabled styling for QuantityNumberInput.
|
|
26
|
+
- Allow widgets supplied by a UiItemsProvider to specify a default state of floating.
|
|
27
|
+
- Replace ColorPickerPanel with ColorPicker from itwinui-react
|
|
28
|
+
- Clean up css for status bar entries to avoid unwanted text wrapping
|
|
29
|
+
- Rename ui directories to match new package names.
|
|
30
|
+
- Deprecated Task/Workflow. Promoted AccuDraw UI to @beta. Added AccuDraw and NavigationAids learning docs.
|
|
31
|
+
- Created imodel-components folder & package and moved color, lineweight, navigationaids, quantity, timeline & viewport. Deprecated MessageSeverity in ui-core & added it ui-abstract. Added MessagePresenter interface to ui-abstract.
|
|
32
|
+
- Remove react 16 peer dependency.
|
|
33
|
+
- Remove itwinUi css overrides.
|
|
34
|
+
- UiFramework and UiIModelComponent initialize method no longer take localization argument, uses IModelApp.localization internally.
|
|
35
|
+
- Add the ability for an app to mark a specific date on the rail of a TimelineComponent.
|
|
36
|
+
- Update to latest types/react package
|
|
37
|
+
- Update ViewportComponent to function component that properly processes async method to get viewstate.
|
|
38
|
+
- Lock down and update version numbers so docs will build.
|
|
39
|
+
|
|
@@ -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"}
|
|
@@ -42,7 +42,7 @@ function FormatPrecision(props) {
|
|
|
42
42
|
const newFormatProps = { ...formatProps, precision };
|
|
43
43
|
onChange && onChange(newFormatProps);
|
|
44
44
|
}, [formatProps, onChange]);
|
|
45
|
-
const formatType = core_quantity_1.
|
|
45
|
+
const formatType = (0, core_quantity_1.parseFormatType)(formatProps.type, "format");
|
|
46
46
|
const label = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.precision"));
|
|
47
47
|
return (React.createElement(React.Fragment, null,
|
|
48
48
|
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,6CAA+B;AAE/B,
|
|
1
|
+
{"version":3,"file":"FormatPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,wDAAgF;AAChF,8DAAmE;AACnE,gEAAqE;AACrE,8DAA2D;AAU3D;;GAEG;AACH,SAAgB,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,IAAA,+BAAe,EAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,uCAAkB,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC5F,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAAG,KAAK,CAAC,OAAO,CAAQ;QACtD,UAAU,KAAK,0BAAU,CAAC,UAAU,CAAC,CAAC;YACrC,oBAAC,6CAAyB,mBAAa,6BAA6B,EAAC,SAAS,EAAE,MAAA,WAAW,CAAC,SAAS,mCAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAAC,CAAC;YACjJ,oBAAC,2CAAwB,mBAAa,4BAA4B,EAAC,SAAS,EAAE,MAAA,WAAW,CAAC,SAAS,mCAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAE9I,CACJ,CAAC;AACJ,CAAC;AApBD,0CAoBC","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"}
|
|
@@ -54,14 +54,14 @@ function FormatTypeOption(props) {
|
|
|
54
54
|
const { formatProps, onChange } = props;
|
|
55
55
|
const handleFormatTypeChange = React.useCallback((newType) => {
|
|
56
56
|
var _a;
|
|
57
|
-
const type = core_quantity_1.
|
|
57
|
+
const type = (0, core_quantity_1.formatTypeToString)(newType);
|
|
58
58
|
let precision;
|
|
59
59
|
let stationOffsetSize;
|
|
60
60
|
let scientificType;
|
|
61
61
|
switch (newType) { // type must be decimal, fractional, scientific, or station
|
|
62
62
|
case core_quantity_1.FormatType.Scientific:
|
|
63
63
|
precision = core_quantity_1.DecimalPrecision.Six;
|
|
64
|
-
scientificType = core_quantity_1.
|
|
64
|
+
scientificType = (0, core_quantity_1.scientificTypeToString)(core_quantity_1.ScientificType.Normalized);
|
|
65
65
|
break;
|
|
66
66
|
case core_quantity_1.FormatType.Decimal:
|
|
67
67
|
precision = core_quantity_1.DecimalPrecision.Four;
|
|
@@ -77,7 +77,7 @@ function FormatTypeOption(props) {
|
|
|
77
77
|
const newFormatProps = { ...formatProps, type, precision, scientificType, stationOffsetSize };
|
|
78
78
|
onChange && onChange(newFormatProps);
|
|
79
79
|
}, [formatProps, onChange]);
|
|
80
|
-
const formatType = core_quantity_1.
|
|
80
|
+
const formatType = (0, core_quantity_1.parseFormatType)(formatProps.type, "format");
|
|
81
81
|
const label = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.type"));
|
|
82
82
|
return (React.createElement(React.Fragment, null,
|
|
83
83
|
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,6CAA+B;AAE/B,8DAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"FormatType.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CA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AM,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;AApCD,4CAoCC","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"}
|
|
@@ -69,7 +69,7 @@ function FormatUnitLabel(props) {
|
|
|
69
69
|
return core_quantity_1.Format.isFormatTraitSetInProps(formatProps, trait);
|
|
70
70
|
}, [formatProps]);
|
|
71
71
|
const setFormatTrait = React.useCallback((trait, setActive) => {
|
|
72
|
-
const traitStr = core_quantity_1.
|
|
72
|
+
const traitStr = (0, core_quantity_1.getTraitString)(trait);
|
|
73
73
|
let formatTraits = [traitStr];
|
|
74
74
|
if (setActive) { // setting trait
|
|
75
75
|
// 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,4DAAoC;AACpC,6CAA+B;AAE/B,
|
|
1
|
+
{"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,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;IAC5G,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,uCAAkB,CAAC,SAAS,CAAC,sCAAsC,CAAC,CAAC,CAAC;IAE1G,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAAG,eAAe,CAAC,OAAO,CAAQ;QACjE,oBAAC,wBAAQ,mBAAa,0BAA0B,EAAC,OAAO,EAAE,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,yBAAyB,GAAI;QAC/I,8BAAM,SAAS,EAAE,IAAA,oBAAU,EAAC,cAAc,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,IAAI,iBAAiB,CAAC,IAAG,cAAc,CAAC,OAAO,CAAQ;QAChJ,oBAAC,oBAAoB,mBAAa,sBAAsB,EAAC,SAAS,EAAE,MAAA,WAAW,CAAC,YAAY,mCAAI,EAAE,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,GAAI,CAClM,CACJ,CAAC;AACJ,CAAC;AAtDD,0CAsDC","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"}
|
|
@@ -55,12 +55,12 @@ function MiscFormatOptions(props) {
|
|
|
55
55
|
return core_quantity_1.Format.isFormatTraitSetInProps(formatProps, trait);
|
|
56
56
|
}, [formatProps]);
|
|
57
57
|
const handleShowSignChange = React.useCallback((option) => {
|
|
58
|
-
const newShowSignOption = core_quantity_1.
|
|
58
|
+
const newShowSignOption = (0, core_quantity_1.showSignOptionToString)(option);
|
|
59
59
|
const newFormatProps = { ...formatProps, showSignOption: newShowSignOption };
|
|
60
60
|
handleSetFormatProps(newFormatProps);
|
|
61
61
|
}, [formatProps, handleSetFormatProps]);
|
|
62
62
|
const setFormatTrait = React.useCallback((trait, setActive) => {
|
|
63
|
-
const traitStr = core_quantity_1.
|
|
63
|
+
const traitStr = (0, core_quantity_1.getTraitString)(trait);
|
|
64
64
|
let formatTraits = [traitStr];
|
|
65
65
|
if (setActive) { // setting trait
|
|
66
66
|
// istanbul ignore else
|
|
@@ -115,14 +115,14 @@ function MiscFormatOptions(props) {
|
|
|
115
115
|
handleSetFormatProps(newFormatProps);
|
|
116
116
|
}, [formatProps, isFormatTraitSet, handleSetFormatProps]);
|
|
117
117
|
const handleScientificTypeChange = React.useCallback((type) => {
|
|
118
|
-
const newFormatProps = { ...formatProps, scientificType: core_quantity_1.
|
|
118
|
+
const newFormatProps = { ...formatProps, scientificType: (0, core_quantity_1.scientificTypeToString)(type) };
|
|
119
119
|
handleSetFormatProps(newFormatProps);
|
|
120
120
|
}, [formatProps, handleSetFormatProps]);
|
|
121
121
|
const handleFormatChange = React.useCallback((newFormatProps) => {
|
|
122
122
|
handleSetFormatProps(newFormatProps);
|
|
123
123
|
}, [handleSetFormatProps]);
|
|
124
|
-
const formatType = React.useMemo(() => core_quantity_1.
|
|
125
|
-
const showSignOption = React.useMemo(() => { var _a; return core_quantity_1.
|
|
124
|
+
const formatType = React.useMemo(() => (0, core_quantity_1.parseFormatType)(formatProps.type, "format"), [formatProps.type]);
|
|
125
|
+
const showSignOption = React.useMemo(() => { var _a; return (0, core_quantity_1.parseShowSignOption)((_a = formatProps.showSignOption) !== null && _a !== void 0 ? _a : "onlyNegative", "format"); }, [formatProps.showSignOption]);
|
|
126
126
|
const handleToggleButtonClick = React.useCallback(() => {
|
|
127
127
|
onShowHideOptions(!showOptions);
|
|
128
128
|
}, [onShowHideOptions, showOptions]);
|
|
@@ -177,7 +177,7 @@ function MiscFormatOptions(props) {
|
|
|
177
177
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", formatType !== core_quantity_1.FormatType.Fractional && "uicore-disabled") }, fractionDashLabel.current),
|
|
178
178
|
React.createElement(itwinui_react_1.Checkbox, { "data-testid": "fraction-dash", checked: isFormatTraitSet(core_quantity_1.FormatTraits.FractionDash), onChange: handleUseFractionDashChange, disabled: formatType !== core_quantity_1.FormatType.Fractional }),
|
|
179
179
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", formatType !== core_quantity_1.FormatType.Scientific && "uicore-disabled") }, scientificTypeLabel.current),
|
|
180
|
-
React.createElement(ScientificType_1.ScientificTypeSelector, { "data-testid": "scientific-type-selector", type: (formatProps.scientificType && formatProps.scientificType.length > 0) ? core_quantity_1.
|
|
180
|
+
React.createElement(ScientificType_1.ScientificTypeSelector, { "data-testid": "scientific-type-selector", type: (formatProps.scientificType && formatProps.scientificType.length > 0) ? (0, core_quantity_1.parseScientificType)(formatProps.scientificType, "custom") : core_quantity_1.ScientificType.Normalized, disabled: formatType !== core_quantity_1.FormatType.Scientific, onChange: handleScientificTypeChange }),
|
|
181
181
|
props.children,
|
|
182
182
|
enableMinimumProperties && showOptions && React.createElement("a", { onClick: handleToggleButtonClick, onKeyUp: handleKeyUpOnLink, className: "components-quantityFormat-more-less", role: "link", "data-testid": "quantityFormat-less", tabIndex: 0 }, lessLabel.current))));
|
|
183
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAmD;AAEnD,wDAAgD;AAChD,wDAAqH;AACrH,kDAAuD;AACvD,kEAA+D;AAC/D,8DAAmE;AACnE,0DAA+D;AAC/D,8EAA2E;AAC3E,oEAAiE;AACjE,8DAA2D;AA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cAAc,IAAI,WAAW,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,8BAAc,CAAC,UAAU,EACvO,QAAQ,EAAE,UAAU,KAAK,0BAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,0BAA0B,GAAI;gBAEzF,KAAK,CAAC,QAAQ;gBAGb,uBAAuB,IAAI,WAAW,IAAI,2BAAG,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,iBAAiB,EACvG,SAAS,EAAE,qCAAqC,EAAE,IAAI,EAAC,MAAM,iBAAa,qBAAqB,EAAC,QAAQ,EAAE,CAAC,IAAG,SAAS,CAAC,OAAO,CAAK,CACvI,CAEJ,CACJ,CAAC;AACJ,CAAC;AAjLD,8CAiLC","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 { SpecialKey } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\nimport { Format, FormatProps, FormatTraits, FormatType, ScientificType, ShowSignOption } from \"@itwin/core-quantity\";\r\nimport { SignOptionSelector } from \"./misc/SignOption\";\r\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator\";\r\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator\";\r\nimport { ScientificTypeSelector } from \"./misc/ScientificType\";\r\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector\";\r\nimport { StationSizeSelector } from \"./misc/StationSizeSelector\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties of [[MiscFormatOptions]] component.\r\n * @alpha\r\n */\r\nexport interface MiscFormatOptionsProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n enableMinimumProperties?: boolean;\r\n showOptions: boolean;\r\n onShowHideOptions: (show: boolean) => void;\r\n children?: React.ReactNode;\r\n}\r\n\r\n/** Component use to set miscellaneous properties is a Formatted Quantity.\r\n * @alpha\r\n */\r\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\r\n const { formatProps, onChange, showOptions, onShowHideOptions, enableMinimumProperties } = props;\r\n\r\n const handleSetFormatProps = React.useCallback((newFormatProps: FormatProps) => {\r\n onChange && onChange(newFormatProps);\r\n }, [onChange]);\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 handleShowSignChange = React.useCallback((option: ShowSignOption) => {\r\n const newShowSignOption = Format.showSignOptionToString(option);\r\n const newFormatProps = { ...formatProps, showSignOption: newShowSignOption };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const setFormatTrait = React.useCallback((trait: FormatTraits, setActive: boolean) => {\r\n const traitStr = Format.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 handleShowTrailingZeroesChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleKeepDecimalPointChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleKeepSingleZeroChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleZeroEmptyChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleUseFractionDashChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleDecimalSeparatorChange = React.useCallback((decimalSeparator: string) => {\r\n let thousandSeparator = formatProps.thousandSeparator;\r\n // make sure 1000 and decimal separator do not match\r\n // istanbul ignore else\r\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\r\n switch (decimalSeparator) {\r\n case \".\":\r\n thousandSeparator = \",\";\r\n break;\r\n case \",\":\r\n thousandSeparator = \".\";\r\n break;\r\n }\r\n }\r\n const newFormatProps = { ...formatProps, thousandSeparator, decimalSeparator };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, isFormatTraitSet, handleSetFormatProps]);\r\n\r\n const handleScientificTypeChange = React.useCallback((type: ScientificType) => {\r\n const newFormatProps = { ...formatProps, scientificType: Format.scientificTypeToString(type) };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleFormatChange = React.useCallback((newFormatProps: FormatProps) => {\r\n handleSetFormatProps(newFormatProps);\r\n }, [handleSetFormatProps]);\r\n\r\n const formatType = React.useMemo(() => Format.parseFormatType(formatProps.type, \"format\"), [formatProps.type]);\r\n const showSignOption = React.useMemo(() => Format.parseShowSignOption(formatProps.showSignOption ?? \"onlyNegative\", \"format\"), [formatProps.showSignOption]);\r\n\r\n const handleToggleButtonClick = React.useCallback(() => {\r\n onShowHideOptions(!showOptions);\r\n }, [onShowHideOptions, showOptions]);\r\n\r\n const handleKeyUpOnLink = React.useCallback((e: React.KeyboardEvent<HTMLAnchorElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Enter || e.key === SpecialKey.Space) {\r\n onShowHideOptions(!showOptions);\r\n e.preventDefault();\r\n }\r\n }, [onShowHideOptions, showOptions]);\r\n\r\n const handleStationSeparatorChange = React.useCallback((value: string) => {\r\n const newFormatProps = { ...formatProps, stationSeparator: value };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleStationOffsetChange = React.useCallback((value: number) => {\r\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const signOptionLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.signOptionLabel\"));\r\n const stationOffsetLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationOffsetLabel\"));\r\n const stationSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationSeparatorLabel\"));\r\n const decimalSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.decimalSeparatorLabel\"));\r\n const showTrailZerosLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.showTrailZerosLabel\"));\r\n const keepSingleZeroLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepSingleZeroLabel\"));\r\n const zeroEmptyLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.zeroEmptyLabel\"));\r\n const moreLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.moreLabel\"));\r\n const lessLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.lessLabel\"));\r\n const keepDecimalPointLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepDecimalPointLabel\"));\r\n const fractionDashLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.fractionDashLabel\"));\r\n const scientificTypeLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.scientificTypeLabel\"));\r\n\r\n return (\r\n <>\r\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\r\n enableMinimumProperties && !showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\r\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-more\" tabIndex={0} >{moreLabel.current}</a>}\r\n {\r\n (!enableMinimumProperties || showOptions) &&\r\n <>\r\n <span className={\"uicore-label\"}>{signOptionLabel.current}</span>\r\n <SignOptionSelector data-testid=\"sign-option-selector\" signOption={showSignOption} onChange={handleShowSignChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationOffsetLabel.current}</span>\r\n <StationSizeSelector data-testid=\"station-size-selector\" value={(formatProps.stationOffsetSize ?? 2)}\r\n disabled={formatType !== FormatType.Station} onChange={handleStationOffsetChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationSeparatorLabel.current}</span>\r\n <StationSeparatorSelector data-testid=\"station-separator-selector\" separator={(undefined !== formatProps.stationSeparator ? formatProps.stationSeparator : \"+\")}\r\n disabled={formatType !== FormatType.Station} onChange={handleStationSeparatorChange} />\r\n\r\n <ThousandsSeparator formatProps={formatProps} onChange={handleFormatChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{decimalSeparatorLabel.current}</span>\r\n <DecimalSeparatorSelector data-testid=\"decimal-separator-selector\" separator={formatProps.decimalSeparator ?? \".\"} onChange={handleDecimalSeparatorChange} disabled={formatType === FormatType.Fractional} />\r\n\r\n <span className={\"uicore-label\"}>{showTrailZerosLabel.current}</span>\r\n <Checkbox data-testid=\"show-trail-zeros\" checked={isFormatTraitSet(FormatTraits.TrailZeroes)} onChange={handleShowTrailingZeroesChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{keepDecimalPointLabel.current}</span>\r\n <Checkbox data-testid=\"keep-decimal-point\" checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)} onChange={handleKeepDecimalPointChange} />\r\n\r\n <span className={\"uicore-label\"}>{keepSingleZeroLabel.current}</span>\r\n <Checkbox data-testid=\"keep-single-zero\" checked={isFormatTraitSet(FormatTraits.KeepSingleZero)} onChange={handleKeepSingleZeroChange} />\r\n\r\n <span className={\"uicore-label\"}>{zeroEmptyLabel.current}</span>\r\n <Checkbox data-testid=\"zero-empty\" checked={isFormatTraitSet(FormatTraits.ZeroEmpty)} onChange={handleZeroEmptyChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Fractional && \"uicore-disabled\")}>{fractionDashLabel.current}</span>\r\n <Checkbox data-testid=\"fraction-dash\" checked={isFormatTraitSet(FormatTraits.FractionDash)} onChange={handleUseFractionDashChange} disabled={formatType !== FormatType.Fractional} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Scientific && \"uicore-disabled\")}>{scientificTypeLabel.current}</span>\r\n <ScientificTypeSelector data-testid=\"scientific-type-selector\" type={(formatProps.scientificType && formatProps.scientificType.length > 0) ? Format.parseScientificType(formatProps.scientificType, \"custom\") : ScientificType.Normalized}\r\n disabled={formatType !== FormatType.Scientific} onChange={handleScientificTypeChange} />\r\n\r\n {props.children}\r\n\r\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\r\n enableMinimumProperties && showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\r\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-less\" tabIndex={0}>{lessLabel.current}</a>}\r\n </>\r\n }\r\n </>\r\n );\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAmD;AAEnD,wDAAgD;AAChD,wDAE8B;AAC9B,kDAAuD;AACvD,kEAA+D;AAC/D,8DAAmE;AACnE,0DAA+D;AAC/D,8EAA2E;AAC3E,oEAAiE;AACjE,8DAA2D;AAc3D;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;;IAC7D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,GAAG,KAAK,CAAC;IAEjG,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,cAA2B,EAAE,EAAE;QAC7E,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAmB,EAAE,EAAE;QACjE,OAAO,sBAAM,CAAC,uBAAuB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,MAAsB,EAAE,EAAE;QACxE,MAAM,iBAAiB,GAAG,IAAA,sCAAsB,EAAC,MAAM,CAA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AEzH,8BAAM,SAAS,EAAE,IAAA,oBAAU,EAAC,cAAc,EAAE,UAAU,KAAK,0BAAU,CAAC,UAAU,IAAI,iBAAiB,CAAC,IAAG,iBAAiB,CAAC,OAAO,CAAQ;gBAC1I,oBAAC,wBAAQ,mBAAa,eAAe,EAAC,OAAO,EAAE,gBAAgB,CAAC,4BAAY,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,2BAA2B,EAAE,QAAQ,EAAE,UAAU,KAAK,0BAAU,CAAC,UAAU,GAAI;gBAErL,8BAAM,SAAS,EAAE,IAAA,oBAAU,EAAC,cAAc,EAAE,UAAU,KAAK,0BAAU,CAAC,UAAU,IAAI,iBAAiB,CAAC,IAAG,mBAAmB,CAAC,OAAO,CAAQ;gBAC5I,oBAAC,uCAAsB,mBAAa,0BAA0B,EAAC,IAAI,EAAE,CAAC,WAAW,CAAC,cAAc,IAAI,WAAW,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mCAAmB,EAAC,WAAW,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,8BAAc,CAAC,UAAU,EAChO,QAAQ,EAAE,UAAU,KAAK,0BAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,0BAA0B,GAAI;gBAEzF,KAAK,CAAC,QAAQ;gBAGb,uBAAuB,IAAI,WAAW,IAAI,2BAAG,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,iBAAiB,EACvG,SAAS,EAAE,qCAAqC,EAAE,IAAI,EAAC,MAAM,iBAAa,qBAAqB,EAAC,QAAQ,EAAE,CAAC,IAAG,SAAS,CAAC,OAAO,CAAK,CACvI,CAEJ,CACJ,CAAC;AACJ,CAAC;AAjLD,8CAiLC","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 { SpecialKey } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\nimport { Format, FormatProps, FormatTraits, FormatType, getTraitString, parseFormatType, parseScientificType,\r\n parseShowSignOption, ScientificType, scientificTypeToString, ShowSignOption, showSignOptionToString,\r\n} from \"@itwin/core-quantity\";\r\nimport { SignOptionSelector } from \"./misc/SignOption\";\r\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator\";\r\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator\";\r\nimport { ScientificTypeSelector } from \"./misc/ScientificType\";\r\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector\";\r\nimport { StationSizeSelector } from \"./misc/StationSizeSelector\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties of [[MiscFormatOptions]] component.\r\n * @alpha\r\n */\r\nexport interface MiscFormatOptionsProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n enableMinimumProperties?: boolean;\r\n showOptions: boolean;\r\n onShowHideOptions: (show: boolean) => void;\r\n children?: React.ReactNode;\r\n}\r\n\r\n/** Component use to set miscellaneous properties is a Formatted Quantity.\r\n * @alpha\r\n */\r\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\r\n const { formatProps, onChange, showOptions, onShowHideOptions, enableMinimumProperties } = props;\r\n\r\n const handleSetFormatProps = React.useCallback((newFormatProps: FormatProps) => {\r\n onChange && onChange(newFormatProps);\r\n }, [onChange]);\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 handleShowSignChange = React.useCallback((option: ShowSignOption) => {\r\n const newShowSignOption = showSignOptionToString(option);\r\n const newFormatProps = { ...formatProps, showSignOption: newShowSignOption };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\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 handleShowTrailingZeroesChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleKeepDecimalPointChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleKeepSingleZeroChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleZeroEmptyChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleUseFractionDashChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleDecimalSeparatorChange = React.useCallback((decimalSeparator: string) => {\r\n let thousandSeparator = formatProps.thousandSeparator;\r\n // make sure 1000 and decimal separator do not match\r\n // istanbul ignore else\r\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\r\n switch (decimalSeparator) {\r\n case \".\":\r\n thousandSeparator = \",\";\r\n break;\r\n case \",\":\r\n thousandSeparator = \".\";\r\n break;\r\n }\r\n }\r\n const newFormatProps = { ...formatProps, thousandSeparator, decimalSeparator };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, isFormatTraitSet, handleSetFormatProps]);\r\n\r\n const handleScientificTypeChange = React.useCallback((type: ScientificType) => {\r\n const newFormatProps = { ...formatProps, scientificType: scientificTypeToString(type) };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleFormatChange = React.useCallback((newFormatProps: FormatProps) => {\r\n handleSetFormatProps(newFormatProps);\r\n }, [handleSetFormatProps]);\r\n\r\n const formatType = React.useMemo(() => parseFormatType(formatProps.type, \"format\"), [formatProps.type]);\r\n const showSignOption = React.useMemo(() => parseShowSignOption(formatProps.showSignOption ?? \"onlyNegative\", \"format\"), [formatProps.showSignOption]);\r\n\r\n const handleToggleButtonClick = React.useCallback(() => {\r\n onShowHideOptions(!showOptions);\r\n }, [onShowHideOptions, showOptions]);\r\n\r\n const handleKeyUpOnLink = React.useCallback((e: React.KeyboardEvent<HTMLAnchorElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Enter || e.key === SpecialKey.Space) {\r\n onShowHideOptions(!showOptions);\r\n e.preventDefault();\r\n }\r\n }, [onShowHideOptions, showOptions]);\r\n\r\n const handleStationSeparatorChange = React.useCallback((value: string) => {\r\n const newFormatProps = { ...formatProps, stationSeparator: value };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleStationOffsetChange = React.useCallback((value: number) => {\r\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const signOptionLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.signOptionLabel\"));\r\n const stationOffsetLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationOffsetLabel\"));\r\n const stationSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationSeparatorLabel\"));\r\n const decimalSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.decimalSeparatorLabel\"));\r\n const showTrailZerosLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.showTrailZerosLabel\"));\r\n const keepSingleZeroLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepSingleZeroLabel\"));\r\n const zeroEmptyLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.zeroEmptyLabel\"));\r\n const moreLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.moreLabel\"));\r\n const lessLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.lessLabel\"));\r\n const keepDecimalPointLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepDecimalPointLabel\"));\r\n const fractionDashLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.fractionDashLabel\"));\r\n const scientificTypeLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.scientificTypeLabel\"));\r\n\r\n return (\r\n <>\r\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\r\n enableMinimumProperties && !showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\r\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-more\" tabIndex={0} >{moreLabel.current}</a>}\r\n {\r\n (!enableMinimumProperties || showOptions) &&\r\n <>\r\n <span className={\"uicore-label\"}>{signOptionLabel.current}</span>\r\n <SignOptionSelector data-testid=\"sign-option-selector\" signOption={showSignOption} onChange={handleShowSignChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationOffsetLabel.current}</span>\r\n <StationSizeSelector data-testid=\"station-size-selector\" value={(formatProps.stationOffsetSize ?? 2)}\r\n disabled={formatType !== FormatType.Station} onChange={handleStationOffsetChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationSeparatorLabel.current}</span>\r\n <StationSeparatorSelector data-testid=\"station-separator-selector\" separator={(undefined !== formatProps.stationSeparator ? formatProps.stationSeparator : \"+\")}\r\n disabled={formatType !== FormatType.Station} onChange={handleStationSeparatorChange} />\r\n\r\n <ThousandsSeparator formatProps={formatProps} onChange={handleFormatChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{decimalSeparatorLabel.current}</span>\r\n <DecimalSeparatorSelector data-testid=\"decimal-separator-selector\" separator={formatProps.decimalSeparator ?? \".\"} onChange={handleDecimalSeparatorChange} disabled={formatType === FormatType.Fractional} />\r\n\r\n <span className={\"uicore-label\"}>{showTrailZerosLabel.current}</span>\r\n <Checkbox data-testid=\"show-trail-zeros\" checked={isFormatTraitSet(FormatTraits.TrailZeroes)} onChange={handleShowTrailingZeroesChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{keepDecimalPointLabel.current}</span>\r\n <Checkbox data-testid=\"keep-decimal-point\" checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)} onChange={handleKeepDecimalPointChange} />\r\n\r\n <span className={\"uicore-label\"}>{keepSingleZeroLabel.current}</span>\r\n <Checkbox data-testid=\"keep-single-zero\" checked={isFormatTraitSet(FormatTraits.KeepSingleZero)} onChange={handleKeepSingleZeroChange} />\r\n\r\n <span className={\"uicore-label\"}>{zeroEmptyLabel.current}</span>\r\n <Checkbox data-testid=\"zero-empty\" checked={isFormatTraitSet(FormatTraits.ZeroEmpty)} onChange={handleZeroEmptyChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Fractional && \"uicore-disabled\")}>{fractionDashLabel.current}</span>\r\n <Checkbox data-testid=\"fraction-dash\" checked={isFormatTraitSet(FormatTraits.FractionDash)} onChange={handleUseFractionDashChange} disabled={formatType !== FormatType.Fractional} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Scientific && \"uicore-disabled\")}>{scientificTypeLabel.current}</span>\r\n <ScientificTypeSelector data-testid=\"scientific-type-selector\" type={(formatProps.scientificType && formatProps.scientificType.length > 0) ? parseScientificType(formatProps.scientificType, \"custom\") : ScientificType.Normalized}\r\n disabled={formatType !== FormatType.Scientific} onChange={handleScientificTypeChange} />\r\n\r\n {props.children}\r\n\r\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\r\n enableMinimumProperties && showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\r\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-less\" tabIndex={0}>{lessLabel.current}</a>}\r\n </>\r\n }\r\n </>\r\n );\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAU,WAAW,EAAgC,MAAM,sBAAsB,CAAC;AAKzF;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,eA4DhE"}
|
|
@@ -46,7 +46,7 @@ function ThousandsSeparator(props) {
|
|
|
46
46
|
onChange && onChange(newProps);
|
|
47
47
|
}, [onChange]);
|
|
48
48
|
const setFormatTrait = React.useCallback((trait, setActive) => {
|
|
49
|
-
const traitStr = core_quantity_1.
|
|
49
|
+
const traitStr = (0, core_quantity_1.getTraitString)(trait);
|
|
50
50
|
let formatTraits = [traitStr];
|
|
51
51
|
if (setActive) { // setting trait
|
|
52
52
|
// istanbul ignore else
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAE/B,
|
|
1
|
+
{"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAE/B,wDAAyF;AACzF,wDAAgD;AAChD,2DAAwD;AACxD,iEAA8D;AAU9D;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAA8B;;IAC/D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAExC,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,QAAqB,E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;QAC3E,oBAAC,wBAAQ,mBAAa,yBAAyB,EAAC,OAAO,EAAE,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,iCAAiC,GAAI;QACzJ,8BAAM,SAAS,EAAE,IAAA,oBAAU,EAAC,cAAc,EAAE,CAAC,CAAC,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,CAAC,IAAI,iBAAiB,CAAC,IAAG,sBAAsB,CAAC,OAAO,CAAQ;QAC7J,oBAAC,qCAAiB,mBAAa,8BAA8B,EAAC,SAAS,EAAE,MAAA,WAAW,CAAC,iBAAiB,mCAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,6BAA6B,GAAI,CACrN,CACJ,CAAC;AACJ,CAAC;AA5DD,gDA4DC","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 } from \"@itwin/itwinui-react\";\r\nimport { ThousandsSelector } from \"./ThousandsSelector\";\r\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\r\n\r\n/** Properties of [[ThousandsSeparator]] component.\r\n * @internal\r\n */\r\nexport interface ThousandsSeparatorProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component use to set Quantity Format thousand group separator.\r\n * @internal\r\n */\r\nexport function ThousandsSeparator(props: ThousandsSeparatorProps) {\r\n const { formatProps, onChange } = props;\r\n\r\n const handleSetFormatProps = React.useCallback((newProps: FormatProps) => {\r\n onChange && onChange(newProps);\r\n }, [onChange]);\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 formatTraits = [...traits, traitStr];\r\n }\r\n } else { // clearing 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 formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\r\n }\r\n }\r\n const newFormatProps = { ...formatProps, formatTraits };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleUseThousandsSeparatorChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.Use1000Separator, e.target.checked);\r\n }, [setFormatTrait]);\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 handleThousandSeparatorChange = React.useCallback((thousandSeparator: string) => {\r\n let decimalSeparator = formatProps.decimalSeparator;\r\n // make sure 1000 and decimal separator do not match\r\n // istanbul ignore else\r\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\r\n if (thousandSeparator === \".\")\r\n decimalSeparator = \",\";\r\n else // thousandSeparator === \",\"\r\n decimalSeparator = \".\";\r\n }\r\n const newFormatProps = { ...formatProps, thousandSeparator, decimalSeparator };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, isFormatTraitSet, handleSetFormatProps]);\r\n\r\n const useThousandSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.useThousandSeparatorLabel\"));\r\n const thousandSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.thousandSeparatorLabel\"));\r\n\r\n return (\r\n <>\r\n <span className={\"uicore-label\"}>{useThousandSeparatorLabel.current}</span>\r\n <Checkbox data-testid=\"use-thousands-separator\" checked={isFormatTraitSet(FormatTraits.Use1000Separator)} onChange={handleUseThousandsSeparatorChange} />\r\n <span className={classnames(\"uicore-label\", !(isFormatTraitSet(FormatTraits.Use1000Separator)) && \"uicore-disabled\")}>{thousandSeparatorLabel.current}</span>\r\n <ThousandsSelector data-testid=\"thousands-separator-selector\" separator={formatProps.thousandSeparator ?? \",\"} disabled={!isFormatTraitSet(FormatTraits.Use1000Separator)} onChange={handleThousandSeparatorChange} />\r\n </>\r\n );\r\n}\r\n"]}
|
|
@@ -76,8 +76,6 @@ export interface TimelineComponentProps {
|
|
|
76
76
|
}
|
|
77
77
|
/** @internal */
|
|
78
78
|
interface TimelineComponentState {
|
|
79
|
-
/** Settings popup is opened or closed */
|
|
80
|
-
isSettingsOpen: boolean;
|
|
81
79
|
/** True if timeline is currently playing, false if paused */
|
|
82
80
|
isPlaying: boolean;
|
|
83
81
|
/** Minimized mode (For future use. This will always be true) */
|
|
@@ -99,7 +97,6 @@ export declare class TimelineComponent extends React.Component<TimelineComponent
|
|
|
99
97
|
private _timeLastCycle;
|
|
100
98
|
private _requestFrame;
|
|
101
99
|
private _unmounted;
|
|
102
|
-
private _settings;
|
|
103
100
|
private _repeatLabel;
|
|
104
101
|
private _removeListener?;
|
|
105
102
|
private _standardTimelineMenuItems;
|
|
@@ -120,13 +117,10 @@ export declare class TimelineComponent extends React.Component<TimelineComponent
|
|
|
120
117
|
private _displayTime;
|
|
121
118
|
private _getMilliseconds;
|
|
122
119
|
private _onTotalDurationChange;
|
|
123
|
-
private _onSettingsClick;
|
|
124
|
-
private _onCloseSettings;
|
|
125
120
|
private _changeRepeatSetting;
|
|
126
121
|
private _onRepeatChanged;
|
|
127
122
|
private _currentDate;
|
|
128
123
|
private _onSetTotalDuration;
|
|
129
|
-
private _createMenuItemNodes;
|
|
130
124
|
private _createMenuItemNode;
|
|
131
125
|
private _renderSettings;
|
|
132
126
|
render(): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelineComponent.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TimelineComponent.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,gBAAgB,EAAkD,MAAM,cAAc,CAAC;AAUhG;;;;;;;GAOG;AACH,oBAAY,sBAAsB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACrE;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AACD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,6GAA6G;IAC7G,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AACD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,gEAAgE;IAChE,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,eAAe,CAAC,EAAE,MAAM,CAAC;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