@itwin/imodel-components-react 5.11.2 → 5.12.1
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 +20 -0
- package/lib/imodel-components-react/UiIModelComponents.json +32 -1
- package/lib/imodel-components-react/quantityformat/FormatPanel.d.ts +3 -1
- package/lib/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/FormatPanel.js +2 -1
- package/lib/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/FormatPrecision.js +4 -2
- package/lib/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/FormatType.js +60 -17
- package/lib/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/FormatUnitLabel.js +6 -5
- package/lib/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/MiscFormatOptions.js +54 -27
- package/lib/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/QuantityFormatPanel.js +2 -2
- package/lib/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/AzimuthOptions.d.ts +15 -0
- package/lib/imodel-components-react/quantityformat/misc/AzimuthOptions.d.ts.map +1 -0
- package/lib/imodel-components-react/quantityformat/misc/AzimuthOptions.js +53 -0
- package/lib/imodel-components-react/quantityformat/misc/AzimuthOptions.js.map +1 -0
- package/lib/imodel-components-react/quantityformat/misc/DecimalPrecision.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/DecimalSeparator.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/FractionPrecision.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/RatioType.d.ts +15 -0
- package/lib/imodel-components-react/quantityformat/misc/RatioType.d.ts.map +1 -0
- package/lib/imodel-components-react/quantityformat/misc/RatioType.js +45 -0
- package/lib/imodel-components-react/quantityformat/misc/RatioType.js.map +1 -0
- package/lib/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/ScientificType.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/SignOption.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/StationSizeSelector.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/ThousandsSelector.js +2 -2
- package/lib/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +7 -5
- package/lib/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/public/locales/en/UiIModelComponents.json +32 -1
- package/package.json +5 -5
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import classnames from "classnames";
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
import { Key } from "ts-key-enum";
|
|
11
|
-
import { Checkbox } from "@itwin/itwinui-react";
|
|
12
|
-
import { Format, FormatTraits, FormatType, getTraitString, parseFormatType, parseScientificType, parseShowSignOption,
|
|
11
|
+
import { Checkbox, IconButton, Label } from "@itwin/itwinui-react";
|
|
12
|
+
import { Format, FormatTraits, FormatType, getTraitString, parseFormatType, parseRatioType, parseScientificType, parseShowSignOption, RatioType, ScientificType, } from "@itwin/core-quantity";
|
|
13
13
|
import { SignOptionSelector } from "./misc/SignOption.js";
|
|
14
14
|
import { ThousandsSeparator } from "./misc/ThousandsSeparator.js";
|
|
15
15
|
import { DecimalSeparatorSelector } from "./misc/DecimalSeparator.js";
|
|
@@ -17,6 +17,9 @@ import { ScientificTypeSelector } from "./misc/ScientificType.js";
|
|
|
17
17
|
import { StationSeparatorSelector } from "./misc/StationSeparatorSelector.js";
|
|
18
18
|
import { StationSizeSelector } from "./misc/StationSizeSelector.js";
|
|
19
19
|
import { useTranslation } from "../useTranslation.js";
|
|
20
|
+
import { RatioTypeSelector } from "./misc/RatioType.js";
|
|
21
|
+
import { SvgHelpCircularHollow } from "@itwin/itwinui-icons-react";
|
|
22
|
+
import { AzimuthOptions } from "./misc/AzimuthOptions.js";
|
|
20
23
|
/** Component use to set miscellaneous properties is a Formatted Quantity.
|
|
21
24
|
* @alpha
|
|
22
25
|
*/
|
|
@@ -24,6 +27,17 @@ import { useTranslation } from "../useTranslation.js";
|
|
|
24
27
|
export function MiscFormatOptions(props) {
|
|
25
28
|
const { formatProps, onChange, showOptions, onShowHideOptions, enableMinimumProperties, } = props;
|
|
26
29
|
const { translate } = useTranslation();
|
|
30
|
+
const signOptionSelectorId = React.useId();
|
|
31
|
+
const stationSizeSelectorId = React.useId();
|
|
32
|
+
const stationSeparatorSelectorId = React.useId();
|
|
33
|
+
const decimalSeparatorSelectorId = React.useId();
|
|
34
|
+
const showTrailZerosId = React.useId();
|
|
35
|
+
const keepDecimalPointId = React.useId();
|
|
36
|
+
const keepSingleZeroId = React.useId();
|
|
37
|
+
const keepZeroEmptyId = React.useId();
|
|
38
|
+
const fractionDashId = React.useId();
|
|
39
|
+
const scientificTypeSelectorId = React.useId();
|
|
40
|
+
const ratioTypeSelectorId = React.useId();
|
|
27
41
|
const handleSetFormatProps = React.useCallback((newFormatProps) => {
|
|
28
42
|
onChange && onChange(newFormatProps);
|
|
29
43
|
}, [onChange]);
|
|
@@ -31,8 +45,7 @@ export function MiscFormatOptions(props) {
|
|
|
31
45
|
return Format.isFormatTraitSetInProps(formatProps, trait);
|
|
32
46
|
}, [formatProps]);
|
|
33
47
|
const handleShowSignChange = React.useCallback((option) => {
|
|
34
|
-
|
|
35
|
-
const newShowSignOption = showSignOptionToString(option);
|
|
48
|
+
const newShowSignOption = option;
|
|
36
49
|
const newFormatProps = {
|
|
37
50
|
...formatProps,
|
|
38
51
|
showSignOption: newShowSignOption,
|
|
@@ -103,8 +116,14 @@ export function MiscFormatOptions(props) {
|
|
|
103
116
|
const handleScientificTypeChange = React.useCallback((type) => {
|
|
104
117
|
const newFormatProps = {
|
|
105
118
|
...formatProps,
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
scientificType: type,
|
|
120
|
+
};
|
|
121
|
+
handleSetFormatProps(newFormatProps);
|
|
122
|
+
}, [formatProps, handleSetFormatProps]);
|
|
123
|
+
const handleRatioTypeChange = React.useCallback((type) => {
|
|
124
|
+
const newFormatProps = {
|
|
125
|
+
...formatProps,
|
|
126
|
+
ratioType: parseRatioType(type, "format"),
|
|
108
127
|
};
|
|
109
128
|
handleSetFormatProps(newFormatProps);
|
|
110
129
|
}, [formatProps, handleSetFormatProps]);
|
|
@@ -133,32 +152,40 @@ export function MiscFormatOptions(props) {
|
|
|
133
152
|
return (React.createElement(React.Fragment, null,
|
|
134
153
|
enableMinimumProperties && !showOptions && (React.createElement("a", { onClick: handleToggleButtonClick, onKeyUp: handleKeyUpOnLink, className: "components-quantityFormat-more-less", role: "link", tabIndex: 0 }, translate("QuantityFormat.labels.moreLabel"))),
|
|
135
154
|
(!enableMinimumProperties || showOptions) && (React.createElement(React.Fragment, null,
|
|
136
|
-
React.createElement(
|
|
137
|
-
React.createElement(SignOptionSelector, { "
|
|
138
|
-
React.createElement(
|
|
139
|
-
React.createElement(StationSizeSelector, { "
|
|
140
|
-
React.createElement(
|
|
141
|
-
React.createElement(StationSeparatorSelector, { "
|
|
155
|
+
React.createElement(Label, { className: "uicore-label", id: signOptionSelectorId, as: "div", displayStyle: "inline" }, translate("QuantityFormat.labels.signOptionLabel")),
|
|
156
|
+
React.createElement(SignOptionSelector, { "aria-labelledby": signOptionSelectorId, signOption: showSignOption, onChange: handleShowSignChange }),
|
|
157
|
+
React.createElement(Label, { className: classnames("uicore-label", formatType !== FormatType.Station && "uicore-disabled"), as: "div", displayStyle: "inline", id: stationSizeSelectorId }, translate("QuantityFormat.labels.stationOffsetLabel")),
|
|
158
|
+
React.createElement(StationSizeSelector, { "aria-labelledby": stationSizeSelectorId, value: formatProps.stationOffsetSize ?? 2, disabled: formatType !== FormatType.Station, onChange: handleStationOffsetChange }),
|
|
159
|
+
React.createElement(Label, { className: classnames("uicore-label", formatType !== FormatType.Station && "uicore-disabled"), as: "div", displayStyle: "inline", id: stationSeparatorSelectorId }, translate("QuantityFormat.labels.stationSeparatorLabel")),
|
|
160
|
+
React.createElement(StationSeparatorSelector, { "aria-labelledby": stationSeparatorSelectorId, separator: undefined !== formatProps.stationSeparator
|
|
142
161
|
? formatProps.stationSeparator
|
|
143
162
|
: "+", disabled: formatType !== FormatType.Station, onChange: handleStationSeparatorChange }),
|
|
144
163
|
React.createElement(ThousandsSeparator, { formatProps: formatProps, onChange: handleFormatChange }),
|
|
145
|
-
React.createElement(
|
|
146
|
-
React.createElement(DecimalSeparatorSelector, { "
|
|
147
|
-
React.createElement(
|
|
148
|
-
React.createElement(Checkbox, { "
|
|
149
|
-
React.createElement(
|
|
150
|
-
React.createElement(Checkbox, { "
|
|
151
|
-
React.createElement(
|
|
152
|
-
React.createElement(Checkbox, { "
|
|
153
|
-
React.createElement(
|
|
154
|
-
React.createElement(Checkbox, { "
|
|
155
|
-
React.createElement(
|
|
156
|
-
React.createElement(Checkbox, { "
|
|
157
|
-
React.createElement(
|
|
158
|
-
React.createElement(ScientificTypeSelector, {
|
|
164
|
+
React.createElement(Label, { className: classnames("uicore-label", formatType === FormatType.Fractional && "uicore-disabled"), as: "div", displayStyle: "inline", id: decimalSeparatorSelectorId }, translate("QuantityFormat.labels.decimalSeparatorLabel")),
|
|
165
|
+
React.createElement(DecimalSeparatorSelector, { "aria-labelledby": decimalSeparatorSelectorId, separator: formatProps.decimalSeparator ?? ".", onChange: handleDecimalSeparatorChange, disabled: formatType === FormatType.Fractional }),
|
|
166
|
+
React.createElement(Label, { className: "uicore-label", as: "div", displayStyle: "inline", id: showTrailZerosId }, translate("QuantityFormat.labels.showTrailZerosLabel")),
|
|
167
|
+
React.createElement(Checkbox, { "aria-labelledby": showTrailZerosId, checked: isFormatTraitSet(FormatTraits.TrailZeroes), onChange: handleShowTrailingZeroesChange }),
|
|
168
|
+
React.createElement(Label, { className: classnames("uicore-label", formatType === FormatType.Fractional && "uicore-disabled"), as: "div", displayStyle: "inline", id: keepDecimalPointId }, translate("QuantityFormat.labels.keepDecimalPointLabel")),
|
|
169
|
+
React.createElement(Checkbox, { "aria-labelledby": keepDecimalPointId, checked: isFormatTraitSet(FormatTraits.KeepDecimalPoint), onChange: handleKeepDecimalPointChange }),
|
|
170
|
+
React.createElement(Label, { className: "uicore-label", as: "div", displayStyle: "inline", id: keepSingleZeroId }, translate("QuantityFormat.labels.keepSingleZeroLabel")),
|
|
171
|
+
React.createElement(Checkbox, { "aria-labelledby": keepSingleZeroId, checked: isFormatTraitSet(FormatTraits.KeepSingleZero), onChange: handleKeepSingleZeroChange }),
|
|
172
|
+
React.createElement(Label, { className: "uicore-label", as: "div", displayStyle: "inline", id: keepZeroEmptyId }, translate("QuantityFormat.labels.zeroEmptyLabel")),
|
|
173
|
+
React.createElement(Checkbox, { "aria-labelledby": keepZeroEmptyId, checked: isFormatTraitSet(FormatTraits.ZeroEmpty), onChange: handleZeroEmptyChange }),
|
|
174
|
+
React.createElement(Label, { className: classnames("uicore-label", formatType !== FormatType.Fractional && "uicore-disabled"), as: "div", displayStyle: "inline", id: fractionDashId }, translate("QuantityFormat.labels.fractionDashLabel")),
|
|
175
|
+
React.createElement(Checkbox, { "aria-labelledby": fractionDashId, checked: isFormatTraitSet(FormatTraits.FractionDash), onChange: handleUseFractionDashChange, disabled: formatType !== FormatType.Fractional }),
|
|
176
|
+
React.createElement(Label, { className: classnames("uicore-label", formatType !== FormatType.Scientific && "uicore-disabled"), as: "div", displayStyle: "inline", id: scientificTypeSelectorId }, translate("QuantityFormat.labels.scientificTypeLabel")),
|
|
177
|
+
React.createElement(ScientificTypeSelector, { type: formatProps.scientificType &&
|
|
159
178
|
formatProps.scientificType.length > 0
|
|
160
179
|
? parseScientificType(formatProps.scientificType, "custom")
|
|
161
|
-
: ScientificType.Normalized, disabled: formatType !== FormatType.Scientific, onChange: handleScientificTypeChange }),
|
|
180
|
+
: ScientificType.Normalized, "aria-labelledby": scientificTypeSelectorId, disabled: formatType !== FormatType.Scientific, onChange: handleScientificTypeChange }),
|
|
181
|
+
React.createElement(Label, { className: classnames("uicore-label", formatType !== FormatType.Ratio && "uicore-disabled"), id: ratioTypeSelectorId },
|
|
182
|
+
translate("QuantityFormat.labels.ratioTypeLabel"),
|
|
183
|
+
React.createElement(IconButton, { size: "small", styleType: "borderless", label: translate("QuantityFormat.ratio-type.default.description") },
|
|
184
|
+
React.createElement(SvgHelpCircularHollow, null))),
|
|
185
|
+
React.createElement(RatioTypeSelector, { type: formatProps.ratioType && formatProps.ratioType.length > 0
|
|
186
|
+
? parseRatioType(formatProps.ratioType, "custom")
|
|
187
|
+
: RatioType.NToOne, disabled: formatType !== FormatType.Ratio, onChange: handleRatioTypeChange, "aria-labelledby": ratioTypeSelectorId }),
|
|
188
|
+
React.createElement(AzimuthOptions, { formatProps: formatProps, onChange: handleFormatChange, disabled: formatType !== FormatType.Azimuth }),
|
|
162
189
|
props.children,
|
|
163
190
|
enableMinimumProperties && showOptions && (React.createElement("a", { onClick: handleToggleButtonClick, onKeyUp: handleKeyUpOnLink, className: "components-quantityFormat-more-less", role: "link", tabIndex: 0 }, translate("QuantityFormat.labels.lessLabel")))))));
|
|
164
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgBtD;;GAEG;AACH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AE/B,QAAQ,EAAE,UAAU,KAAK,UAAU,CAAC,UAAU,EAC9C,QAAQ,EAAE,0BAA0B,GACpC;YAED,KAAK,CAAC,QAAQ;YAEd,uBAAuB,IAAI,WAAW,IAAI,CACzC,2BACE,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,qCAAqC,EAChD,IAAI,EAAC,MAAM,EACX,QAAQ,EAAE,CAAC,IAEV,SAAS,CAAC,iCAAiC,CAAC,CAC3C,CACL,CACA,CACJ,CACA,CACJ,CAAC;AACJ,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 QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport type { FormatProps, ShowSignOption } from \"@itwin/core-quantity\";\nimport {\n Format,\n FormatTraits,\n FormatType,\n getTraitString,\n parseFormatType,\n parseScientificType,\n parseShowSignOption,\n ScientificType,\n scientificTypeToString,\n showSignOptionToString,\n} from \"@itwin/core-quantity\";\nimport { SignOptionSelector } from \"./misc/SignOption.js\";\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator.js\";\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator.js\";\nimport { ScientificTypeSelector } from \"./misc/ScientificType.js\";\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector.js\";\nimport { StationSizeSelector } from \"./misc/StationSizeSelector.js\";\nimport { useTranslation } from \"../useTranslation.js\";\n\n/** Properties of [[MiscFormatOptions]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof MiscFormatOptions>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface MiscFormatOptionsProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n enableMinimumProperties?: boolean;\n showOptions: boolean;\n onShowHideOptions: (show: boolean) => void;\n children?: React.ReactNode;\n}\n\n/** Component use to set miscellaneous properties is a Formatted Quantity.\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\n const {\n formatProps,\n onChange,\n showOptions,\n onShowHideOptions,\n enableMinimumProperties,\n } = props;\n const { translate } = useTranslation();\n\n const handleSetFormatProps = React.useCallback(\n (newFormatProps: FormatProps) => {\n onChange && onChange(newFormatProps);\n },\n [onChange]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleShowSignChange = React.useCallback(\n (option: ShowSignOption) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const newShowSignOption = showSignOptionToString(option);\n const newFormatProps = {\n ...formatProps,\n showSignOption: newShowSignOption,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleShowTrailingZeroesChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepDecimalPointChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepSingleZeroChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleZeroEmptyChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleUseFractionDashChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleDecimalSeparatorChange = React.useCallback(\n (decimalSeparator: string) => {\n let thousandSeparator = formatProps.thousandSeparator;\n // make sure 1000 and decimal separator do not match\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n switch (decimalSeparator) {\n case \".\":\n thousandSeparator = \",\";\n break;\n case \",\":\n thousandSeparator = \".\";\n break;\n }\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n const handleScientificTypeChange = React.useCallback(\n (type: ScientificType) => {\n const newFormatProps = {\n ...formatProps,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n scientificType: scientificTypeToString(type),\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleFormatChange = React.useCallback(\n (newFormatProps: FormatProps) => {\n handleSetFormatProps(newFormatProps);\n },\n [handleSetFormatProps]\n );\n\n const formatType = React.useMemo(\n () => parseFormatType(formatProps.type, \"format\"),\n [formatProps.type]\n );\n const showSignOption = React.useMemo(\n () =>\n parseShowSignOption(\n formatProps.showSignOption ?? \"onlyNegative\",\n \"format\"\n ),\n [formatProps.showSignOption]\n );\n\n const handleToggleButtonClick = React.useCallback(() => {\n onShowHideOptions(!showOptions);\n }, [onShowHideOptions, showOptions]);\n\n const handleKeyUpOnLink = React.useCallback(\n (e: React.KeyboardEvent<HTMLAnchorElement>) => {\n if (e.key === Key.Enter.valueOf() || e.key === \" \") {\n onShowHideOptions(!showOptions);\n e.preventDefault();\n }\n },\n [onShowHideOptions, showOptions]\n );\n\n const handleStationSeparatorChange = React.useCallback(\n (value: string) => {\n const newFormatProps = { ...formatProps, stationSeparator: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleStationOffsetChange = React.useCallback(\n (value: number) => {\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {enableMinimumProperties && !showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.moreLabel\")}\n </a>\n )}\n {(!enableMinimumProperties || showOptions) && (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.signOptionLabel\")}\n </span>\n <SignOptionSelector\n data-testid=\"sign-option-selector\"\n signOption={showSignOption}\n onChange={handleShowSignChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.stationOffsetLabel\")}\n </span>\n <StationSizeSelector\n data-testid=\"station-size-selector\"\n value={formatProps.stationOffsetSize ?? 2}\n disabled={formatType !== FormatType.Station}\n onChange={handleStationOffsetChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.stationSeparatorLabel\")}\n </span>\n <StationSeparatorSelector\n data-testid=\"station-separator-selector\"\n separator={\n undefined !== formatProps.stationSeparator\n ? formatProps.stationSeparator\n : \"+\"\n }\n disabled={formatType !== FormatType.Station}\n onChange={handleStationSeparatorChange}\n />\n\n <ThousandsSeparator\n formatProps={formatProps}\n onChange={handleFormatChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.decimalSeparatorLabel\")}\n </span>\n <DecimalSeparatorSelector\n data-testid=\"decimal-separator-selector\"\n separator={formatProps.decimalSeparator ?? \".\"}\n onChange={handleDecimalSeparatorChange}\n disabled={formatType === FormatType.Fractional}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.showTrailZerosLabel\")}\n </span>\n <Checkbox\n data-testid=\"show-trail-zeros\"\n checked={isFormatTraitSet(FormatTraits.TrailZeroes)}\n onChange={handleShowTrailingZeroesChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.keepDecimalPointLabel\")}\n </span>\n <Checkbox\n data-testid=\"keep-decimal-point\"\n checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)}\n onChange={handleKeepDecimalPointChange}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.keepSingleZeroLabel\")}\n </span>\n <Checkbox\n data-testid=\"keep-single-zero\"\n checked={isFormatTraitSet(FormatTraits.KeepSingleZero)}\n onChange={handleKeepSingleZeroChange}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.zeroEmptyLabel\")}\n </span>\n <Checkbox\n data-testid=\"zero-empty\"\n checked={isFormatTraitSet(FormatTraits.ZeroEmpty)}\n onChange={handleZeroEmptyChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.fractionDashLabel\")}\n </span>\n <Checkbox\n data-testid=\"fraction-dash\"\n checked={isFormatTraitSet(FormatTraits.FractionDash)}\n onChange={handleUseFractionDashChange}\n disabled={formatType !== FormatType.Fractional}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Scientific && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.scientificTypeLabel\")}\n </span>\n <ScientificTypeSelector\n data-testid=\"scientific-type-selector\"\n type={\n formatProps.scientificType &&\n formatProps.scientificType.length > 0\n ? parseScientificType(formatProps.scientificType, \"custom\")\n : ScientificType.Normalized\n }\n disabled={formatType !== FormatType.Scientific}\n onChange={handleScientificTypeChange}\n />\n\n {props.children}\n\n {enableMinimumProperties && showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.lessLabel\")}\n </a>\n )}\n </>\n )}\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,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,UAAU,CAAC,KAAK,IAAI,iBAAiB,CACrD,EACD,EAAE,EAAE,mBAAmB;gBAEtB,SAAS,CAAC,sCAAsC,CAAC;gBAClD,oBAAC,UAAU,IACT,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,SAAS,CAAC,+CAA+C,CAAC;oBAEjE,oBAAC,qBAAqB,OAAG,CACd,CACP;YACR,oBAAC,iBAAiB,IAChB,IAAI,EACF,WAAW,CAAC,SAAS,IAAI,WAAW,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;oBACvD,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC;oBACjD,CAAC,CAAC,SAAS,CAAC,MAAM,EAEtB,QAAQ,EAAE,UAAU,KAAK,UAAU,CAAC,KAAK,EACzC,QAAQ,EAAE,qBAAqB,qBACd,mBAAmB,GACpC;YAEF,oBAAC,cAAc,IACb,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,UAAU,KAAK,UAAU,CAAC,OAAO,GAC3C;YAED,KAAK,CAAC,QAAQ;YAEd,uBAAuB,IAAI,WAAW,IAAI,CACzC,2BACE,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,qCAAqC,EAChD,IAAI,EAAC,MAAM,EACX,QAAQ,EAAE,CAAC,IAEV,SAAS,CAAC,iCAAiC,CAAC,CAC3C,CACL,CACA,CACJ,CACA,CACJ,CAAC;AACJ,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 QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox, IconButton, Label } from \"@itwin/itwinui-react\";\nimport type { FormatProps, ShowSignOption } from \"@itwin/core-quantity\";\nimport {\n Format,\n FormatTraits,\n FormatType,\n getTraitString,\n parseFormatType,\n parseRatioType,\n parseScientificType,\n parseShowSignOption,\n RatioType,\n ScientificType,\n} from \"@itwin/core-quantity\";\nimport { SignOptionSelector } from \"./misc/SignOption.js\";\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator.js\";\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator.js\";\nimport { ScientificTypeSelector } from \"./misc/ScientificType.js\";\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector.js\";\nimport { StationSizeSelector } from \"./misc/StationSizeSelector.js\";\nimport { useTranslation } from \"../useTranslation.js\";\nimport { RatioTypeSelector } from \"./misc/RatioType.js\";\nimport { SvgHelpCircularHollow } from \"@itwin/itwinui-icons-react\";\nimport { AzimuthOptions } from \"./misc/AzimuthOptions.js\";\n\n/** Properties of [[MiscFormatOptions]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof MiscFormatOptions>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface MiscFormatOptionsProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n enableMinimumProperties?: boolean;\n showOptions: boolean;\n onShowHideOptions: (show: boolean) => void;\n children?: React.ReactNode;\n}\n\n/** Component use to set miscellaneous properties is a Formatted Quantity.\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\n const {\n formatProps,\n onChange,\n showOptions,\n onShowHideOptions,\n enableMinimumProperties,\n } = props;\n const { translate } = useTranslation();\n\n const signOptionSelectorId = React.useId();\n const stationSizeSelectorId = React.useId();\n const stationSeparatorSelectorId = React.useId();\n const decimalSeparatorSelectorId = React.useId();\n const showTrailZerosId = React.useId();\n const keepDecimalPointId = React.useId();\n const keepSingleZeroId = React.useId();\n const keepZeroEmptyId = React.useId();\n const fractionDashId = React.useId();\n const scientificTypeSelectorId = React.useId();\n const ratioTypeSelectorId = React.useId();\n\n const handleSetFormatProps = React.useCallback(\n (newFormatProps: FormatProps) => {\n onChange && onChange(newFormatProps);\n },\n [onChange]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleShowSignChange = React.useCallback(\n (option: ShowSignOption) => {\n const newShowSignOption = option;\n const newFormatProps = {\n ...formatProps,\n showSignOption: newShowSignOption,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleShowTrailingZeroesChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepDecimalPointChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepSingleZeroChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleZeroEmptyChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleUseFractionDashChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleDecimalSeparatorChange = React.useCallback(\n (decimalSeparator: string) => {\n let thousandSeparator = formatProps.thousandSeparator;\n // make sure 1000 and decimal separator do not match\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n switch (decimalSeparator) {\n case \".\":\n thousandSeparator = \",\";\n break;\n case \",\":\n thousandSeparator = \".\";\n break;\n }\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n const handleScientificTypeChange = React.useCallback(\n (type: ScientificType) => {\n const newFormatProps = {\n ...formatProps,\n scientificType: type,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleRatioTypeChange = React.useCallback(\n (type: RatioType) => {\n const newFormatProps = {\n ...formatProps,\n ratioType: parseRatioType(type, \"format\"),\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleFormatChange = React.useCallback(\n (newFormatProps: FormatProps) => {\n handleSetFormatProps(newFormatProps);\n },\n [handleSetFormatProps]\n );\n\n const formatType = React.useMemo(\n () => parseFormatType(formatProps.type, \"format\"),\n [formatProps.type]\n );\n const showSignOption = React.useMemo(\n () =>\n parseShowSignOption(\n formatProps.showSignOption ?? \"onlyNegative\",\n \"format\"\n ),\n [formatProps.showSignOption]\n );\n\n const handleToggleButtonClick = React.useCallback(() => {\n onShowHideOptions(!showOptions);\n }, [onShowHideOptions, showOptions]);\n\n const handleKeyUpOnLink = React.useCallback(\n (e: React.KeyboardEvent<HTMLAnchorElement>) => {\n if (e.key === Key.Enter.valueOf() || e.key === \" \") {\n onShowHideOptions(!showOptions);\n e.preventDefault();\n }\n },\n [onShowHideOptions, showOptions]\n );\n\n const handleStationSeparatorChange = React.useCallback(\n (value: string) => {\n const newFormatProps = { ...formatProps, stationSeparator: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleStationOffsetChange = React.useCallback(\n (value: number) => {\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {enableMinimumProperties && !showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.moreLabel\")}\n </a>\n )}\n {(!enableMinimumProperties || showOptions) && (\n <>\n <Label\n className={\"uicore-label\"}\n id={signOptionSelectorId}\n as=\"div\"\n displayStyle=\"inline\"\n >\n {translate(\"QuantityFormat.labels.signOptionLabel\")}\n </Label>\n <SignOptionSelector\n aria-labelledby={signOptionSelectorId}\n signOption={showSignOption}\n onChange={handleShowSignChange}\n />\n\n <Label\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n as=\"div\"\n displayStyle=\"inline\"\n id={stationSizeSelectorId}\n >\n {translate(\"QuantityFormat.labels.stationOffsetLabel\")}\n </Label>\n <StationSizeSelector\n aria-labelledby={stationSizeSelectorId}\n value={formatProps.stationOffsetSize ?? 2}\n disabled={formatType !== FormatType.Station}\n onChange={handleStationOffsetChange}\n />\n\n <Label\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n as=\"div\"\n displayStyle=\"inline\"\n id={stationSeparatorSelectorId}\n >\n {translate(\"QuantityFormat.labels.stationSeparatorLabel\")}\n </Label>\n <StationSeparatorSelector\n aria-labelledby={stationSeparatorSelectorId}\n separator={\n undefined !== formatProps.stationSeparator\n ? formatProps.stationSeparator\n : \"+\"\n }\n disabled={formatType !== FormatType.Station}\n onChange={handleStationSeparatorChange}\n />\n\n <ThousandsSeparator\n formatProps={formatProps}\n onChange={handleFormatChange}\n />\n\n <Label\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n as=\"div\"\n displayStyle=\"inline\"\n id={decimalSeparatorSelectorId}\n >\n {translate(\"QuantityFormat.labels.decimalSeparatorLabel\")}\n </Label>\n <DecimalSeparatorSelector\n aria-labelledby={decimalSeparatorSelectorId}\n separator={formatProps.decimalSeparator ?? \".\"}\n onChange={handleDecimalSeparatorChange}\n disabled={formatType === FormatType.Fractional}\n />\n\n <Label\n className={\"uicore-label\"}\n as=\"div\"\n displayStyle=\"inline\"\n id={showTrailZerosId}\n >\n {translate(\"QuantityFormat.labels.showTrailZerosLabel\")}\n </Label>\n <Checkbox\n aria-labelledby={showTrailZerosId}\n checked={isFormatTraitSet(FormatTraits.TrailZeroes)}\n onChange={handleShowTrailingZeroesChange}\n />\n\n <Label\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n as=\"div\"\n displayStyle=\"inline\"\n id={keepDecimalPointId}\n >\n {translate(\"QuantityFormat.labels.keepDecimalPointLabel\")}\n </Label>\n <Checkbox\n aria-labelledby={keepDecimalPointId}\n checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)}\n onChange={handleKeepDecimalPointChange}\n />\n\n <Label\n className={\"uicore-label\"}\n as=\"div\"\n displayStyle=\"inline\"\n id={keepSingleZeroId}\n >\n {translate(\"QuantityFormat.labels.keepSingleZeroLabel\")}\n </Label>\n <Checkbox\n aria-labelledby={keepSingleZeroId}\n checked={isFormatTraitSet(FormatTraits.KeepSingleZero)}\n onChange={handleKeepSingleZeroChange}\n />\n\n <Label\n className={\"uicore-label\"}\n as=\"div\"\n displayStyle=\"inline\"\n id={keepZeroEmptyId}\n >\n {translate(\"QuantityFormat.labels.zeroEmptyLabel\")}\n </Label>\n <Checkbox\n aria-labelledby={keepZeroEmptyId}\n checked={isFormatTraitSet(FormatTraits.ZeroEmpty)}\n onChange={handleZeroEmptyChange}\n />\n\n <Label\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Fractional && \"uicore-disabled\"\n )}\n as=\"div\"\n displayStyle=\"inline\"\n id={fractionDashId}\n >\n {translate(\"QuantityFormat.labels.fractionDashLabel\")}\n </Label>\n <Checkbox\n aria-labelledby={fractionDashId}\n checked={isFormatTraitSet(FormatTraits.FractionDash)}\n onChange={handleUseFractionDashChange}\n disabled={formatType !== FormatType.Fractional}\n />\n\n <Label\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Scientific && \"uicore-disabled\"\n )}\n as=\"div\"\n displayStyle=\"inline\"\n id={scientificTypeSelectorId}\n >\n {translate(\"QuantityFormat.labels.scientificTypeLabel\")}\n </Label>\n <ScientificTypeSelector\n type={\n formatProps.scientificType &&\n formatProps.scientificType.length > 0\n ? parseScientificType(formatProps.scientificType, \"custom\")\n : ScientificType.Normalized\n }\n aria-labelledby={scientificTypeSelectorId}\n disabled={formatType !== FormatType.Scientific}\n onChange={handleScientificTypeChange}\n />\n\n <Label\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Ratio && \"uicore-disabled\"\n )}\n id={ratioTypeSelectorId}\n >\n {translate(\"QuantityFormat.labels.ratioTypeLabel\")}\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n label={translate(\"QuantityFormat.ratio-type.default.description\")}\n >\n <SvgHelpCircularHollow />\n </IconButton>\n </Label>\n <RatioTypeSelector\n type={\n formatProps.ratioType && formatProps.ratioType.length > 0\n ? parseRatioType(formatProps.ratioType, \"custom\")\n : RatioType.NToOne\n }\n disabled={formatType !== FormatType.Ratio}\n onChange={handleRatioTypeChange}\n aria-labelledby={ratioTypeSelectorId}\n />\n\n <AzimuthOptions\n formatProps={formatProps}\n onChange={handleFormatChange}\n disabled={formatType !== FormatType.Azimuth}\n />\n\n {props.children}\n\n {enableMinimumProperties && showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.lessLabel\")}\n </a>\n )}\n </>\n )}\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuantityFormatPanel.d.ts","sourceRoot":"","sources":["../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA8FrD;;;GAGG;AAEH,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,YAAY,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"QuantityFormatPanel.d.ts","sourceRoot":"","sources":["../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA8FrD;;;GAGG;AAEH,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,YAAY,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qBAgLlE"}
|
|
@@ -46,7 +46,7 @@ function formatAreEqual(obj1, obj2) {
|
|
|
46
46
|
*/
|
|
47
47
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
48
48
|
export function QuantityFormatPanel(props) {
|
|
49
|
-
const { quantityType, onFormatChange, ...
|
|
49
|
+
const { quantityType, onFormatChange, showSample, initialMagnitude, enableMinimumProperties, ...rest } = props;
|
|
50
50
|
const [formatProps, setFormatProps] = React.useState();
|
|
51
51
|
const initialFormatProps = React.useRef();
|
|
52
52
|
const [persistenceUnit, setPersistenceUnit] = React.useState();
|
|
@@ -113,6 +113,6 @@ export function QuantityFormatPanel(props) {
|
|
|
113
113
|
const provideFormatSpec = React.useCallback(async (inProps, _persistenceUnit, _unitsProvider) => {
|
|
114
114
|
return IModelApp.quantityFormatter.generateFormatterSpecByType(quantityType, inProps);
|
|
115
115
|
}, [quantityType]);
|
|
116
|
-
return (React.createElement("div", { className: "components-quantityFormat-quantityPanel" }, persistenceUnit && formatProps && (React.createElement(FormatPanel, { onFormatChange: handleOnFormatChanged,
|
|
116
|
+
return (React.createElement("div", { className: "components-quantityFormat-quantityPanel" }, persistenceUnit && formatProps && (React.createElement(FormatPanel, { ...rest, onFormatChange: handleOnFormatChanged, showSample: showSample, initialMagnitude: initialMagnitude, enableMinimumProperties: enableMinimumProperties, initialFormat: formatProps, unitsProvider: IModelApp.quantityFormatter.unitsProvider, persistenceUnit: persistenceUnit, providePrimaryChildren: providePrimaryChildren, provideSecondaryChildren: provideSecondaryChildren, provideFormatSpec: provideFormatSpec }))));
|
|
117
117
|
}
|
|
118
118
|
//# sourceMappingURL=QuantityFormatPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuantityFormatPanel.js","sourceRoot":"","sources":["../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,8BAA8B,EAC9B,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,SAAS,+BAA+B,CACtC,GAAW,EACX,KAAa,EACb,OAAoB,EACpB,SAAyC,EACzC,SAA6D,EAC7D,gBAAiD;IAEjD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,GAAG,EAAE;QAC3B,8BAAM,GAAG,EAAE,GAAG,GAAG,QAAQ,EAAE,SAAS,EAAE,cAAc,IACjD,KAAK,CACD;QACP,oBAAC,KAAK,mBACS,GAAG,GA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------------------------------------------------------------------------------------\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 QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type {\n CustomFormatPropEditorSpec,\n QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport {\n getQuantityTypeKey,\n IModelApp,\n isCheckboxFormatPropEditorSpec,\n isCustomQuantityTypeDefinition,\n isTextInputFormatPropEditorSpec,\n isTextSelectFormatPropEditorSpec,\n} from \"@itwin/core-frontend\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox, Input, Select } from \"@itwin/itwinui-react\";\nimport { FormatPanel } from \"./FormatPanel.js\";\nimport { DeepCompare } from \"@itwin/core-geometry\";\n\nfunction createTextInputFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Input\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n size=\"small\"\n onChange={(e) => {\n const newProps = setString(inProps, e.currentTarget.value);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\nfunction createSelectFormatPropEditor(\n key: string,\n label: string,\n options: { label: string; value: string }[],\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Select\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n options={options}\n size={\"small\"}\n onChange={(newValue) => {\n const newProps = setString(inProps, newValue);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction createCheckboxFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getBool: (props: FormatProps) => boolean,\n setBool: (props: FormatProps, isChecked: boolean) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const isChecked = getBool(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Checkbox\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n checked={isChecked}\n onChange={(e) => {\n const newProps = setBool(inProps, e.target.checked);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction formatAreEqual(obj1: FormatProps, obj2: FormatProps) {\n const compare = new DeepCompare();\n return compare.compare(obj1, obj2);\n}\n\n/** Properties of [[QuantityFormatPanel]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof QuantityFormatPanel>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface QuantityFormatPanelProps extends CommonProps {\n quantityType: QuantityTypeArg;\n onFormatChange?: (format: FormatProps) => void;\n /** props below are to be passed on to FormatPanel */\n showSample?: boolean;\n initialMagnitude?: number;\n enableMinimumProperties?: boolean;\n}\n\n/** Component to set properties that control Quantity Formatting.\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function QuantityFormatPanel(props: QuantityFormatPanelProps) {\n const { quantityType, onFormatChange, ...otherProps } = props;\n const [formatProps, setFormatProps] = React.useState<FormatProps>();\n const initialFormatProps = React.useRef<FormatProps>();\n\n const [persistenceUnit, setPersistenceUnit] = React.useState<UnitProps>();\n\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (!initialFormatProps.current)\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (quantityTypeDefinition)\n setPersistenceUnit(quantityTypeDefinition.persistenceUnit);\n else\n throw Error(`Unable to locate a quantity type with type ${quantityType}`);\n }, [quantityType]); // no dependencies defined as we want this to run on every render\n\n // handle case where quantityType does not change but the formatProps for that quantity type has (ie after a Set or Clear)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (initialFormatProps.current && newFormatProps) {\n if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n }\n }\n }); // no dependencies defined as we want this to run on every render\n\n const handleOnFormatChanged = React.useCallback(\n async (newProps: FormatProps) => {\n setFormatProps(newProps);\n onFormatChange && onFormatChange(newProps);\n },\n [onFormatChange]\n );\n\n const createCustomPropEditors = React.useCallback(\n (\n specs: CustomFormatPropEditorSpec[],\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n return specs.map((spec, index) => {\n if (isCheckboxFormatPropEditorSpec(spec))\n return createCheckboxFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getBool,\n spec.setBool,\n fireFormatChange\n );\n if (isTextSelectFormatPropEditorSpec(spec))\n return createSelectFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n spec.selectOptions,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n if (isTextInputFormatPropEditorSpec(spec))\n return createTextInputFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n return <div key={index} />;\n });\n },\n []\n );\n\n const providePrimaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.primaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.primaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideSecondaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.secondaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideFormatSpec = React.useCallback(\n async (\n inProps: FormatProps,\n _persistenceUnit: UnitProps,\n _unitsProvider: UnitsProvider\n ) => {\n return IModelApp.quantityFormatter.generateFormatterSpecByType(\n quantityType,\n inProps\n );\n },\n [quantityType]\n );\n\n return (\n <div className=\"components-quantityFormat-quantityPanel\">\n {persistenceUnit && formatProps && (\n <FormatPanel\n onFormatChange={handleOnFormatChanged}\n {...otherProps}\n initialFormat={formatProps}\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\n persistenceUnit={persistenceUnit}\n providePrimaryChildren={providePrimaryChildren}\n provideSecondaryChildren={provideSecondaryChildren}\n provideFormatSpec={provideFormatSpec}\n />\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QuantityFormatPanel.js","sour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,CAAC;YACD,IAAI,sBAAsB,CAAC,wBAAwB;gBACjD,OAAO,uBAAuB,CAC5B,sBAAsB,CAAC,wBAAwB,EAC/C,OAAO,EACP,gBAAgB,CACjB,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EACD,CAAC,uBAAuB,EAAE,YAAY,CAAC,CACxC,CAAC;IAEF,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,KAAK,EACH,OAAoB,EACpB,gBAA2B,EAC3B,cAA6B,EAC7B,EAAE;QACF,OAAO,SAAS,CAAC,iBAAiB,CAAC,2BAA2B,CAC5D,YAAY,EACZ,OAAO,CACR,CAAC;IACJ,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,yCAAyC,IACrD,eAAe,IAAI,WAAW,IAAI,CACjC,oBAAC,WAAW,OACN,IAAI,EACR,cAAc,EAAE,qBAAqB,EACrC,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,uBAAuB,EAChD,aAAa,EAAE,WAAW,EAC1B,aAAa,EAAE,SAAS,CAAC,iBAAiB,CAAC,aAAa,EACxD,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CACG,CACP,CAAC;AACJ,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 QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type {\n CustomFormatPropEditorSpec,\n QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport {\n getQuantityTypeKey,\n IModelApp,\n isCheckboxFormatPropEditorSpec,\n isCustomQuantityTypeDefinition,\n isTextInputFormatPropEditorSpec,\n isTextSelectFormatPropEditorSpec,\n} from \"@itwin/core-frontend\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox, Input, Select } from \"@itwin/itwinui-react\";\nimport { FormatPanel } from \"./FormatPanel.js\";\nimport { DeepCompare } from \"@itwin/core-geometry\";\n\nfunction createTextInputFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Input\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n size=\"small\"\n onChange={(e) => {\n const newProps = setString(inProps, e.currentTarget.value);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\nfunction createSelectFormatPropEditor(\n key: string,\n label: string,\n options: { label: string; value: string }[],\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Select\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n options={options}\n size={\"small\"}\n onChange={(newValue) => {\n const newProps = setString(inProps, newValue);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction createCheckboxFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getBool: (props: FormatProps) => boolean,\n setBool: (props: FormatProps, isChecked: boolean) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const isChecked = getBool(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Checkbox\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n checked={isChecked}\n onChange={(e) => {\n const newProps = setBool(inProps, e.target.checked);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction formatAreEqual(obj1: FormatProps, obj2: FormatProps) {\n const compare = new DeepCompare();\n return compare.compare(obj1, obj2);\n}\n\n/** Properties of [[QuantityFormatPanel]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof QuantityFormatPanel>`\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface QuantityFormatPanelProps extends CommonProps {\n quantityType: QuantityTypeArg;\n onFormatChange?: (format: FormatProps) => void;\n /** props below are to be passed on to FormatPanel */\n showSample?: boolean;\n initialMagnitude?: number;\n enableMinimumProperties?: boolean;\n}\n\n/** Component to set properties that control Quantity Formatting.\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function QuantityFormatPanel(props: QuantityFormatPanelProps) {\n const {\n quantityType,\n onFormatChange,\n showSample,\n initialMagnitude,\n enableMinimumProperties,\n ...rest\n } = props;\n const [formatProps, setFormatProps] = React.useState<FormatProps>();\n const initialFormatProps = React.useRef<FormatProps>();\n\n const [persistenceUnit, setPersistenceUnit] = React.useState<UnitProps>();\n\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (!initialFormatProps.current)\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (quantityTypeDefinition)\n setPersistenceUnit(quantityTypeDefinition.persistenceUnit);\n else\n throw Error(`Unable to locate a quantity type with type ${quantityType}`);\n }, [quantityType]); // no dependencies defined as we want this to run on every render\n\n // handle case where quantityType does not change but the formatProps for that quantity type has (ie after a Set or Clear)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (initialFormatProps.current && newFormatProps) {\n if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n }\n }\n }); // no dependencies defined as we want this to run on every render\n\n const handleOnFormatChanged = React.useCallback(\n async (newProps: FormatProps) => {\n setFormatProps(newProps);\n onFormatChange && onFormatChange(newProps);\n },\n [onFormatChange]\n );\n\n const createCustomPropEditors = React.useCallback(\n (\n specs: CustomFormatPropEditorSpec[],\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n return specs.map((spec, index) => {\n if (isCheckboxFormatPropEditorSpec(spec))\n return createCheckboxFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getBool,\n spec.setBool,\n fireFormatChange\n );\n if (isTextSelectFormatPropEditorSpec(spec))\n return createSelectFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n spec.selectOptions,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n if (isTextInputFormatPropEditorSpec(spec))\n return createTextInputFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n return <div key={index} />;\n });\n },\n []\n );\n\n const providePrimaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.primaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.primaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideSecondaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.secondaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideFormatSpec = React.useCallback(\n async (\n inProps: FormatProps,\n _persistenceUnit: UnitProps,\n _unitsProvider: UnitsProvider\n ) => {\n return IModelApp.quantityFormatter.generateFormatterSpecByType(\n quantityType,\n inProps\n );\n },\n [quantityType]\n );\n\n return (\n <div className=\"components-quantityFormat-quantityPanel\">\n {persistenceUnit && formatProps && (\n <FormatPanel\n {...rest}\n onFormatChange={handleOnFormatChanged}\n showSample={showSample}\n initialMagnitude={initialMagnitude}\n enableMinimumProperties={enableMinimumProperties}\n initialFormat={formatProps}\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\n persistenceUnit={persistenceUnit}\n providePrimaryChildren={providePrimaryChildren}\n provideSecondaryChildren={provideSecondaryChildren}\n provideFormatSpec={provideFormatSpec}\n />\n )}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module QuantityFormat
|
|
3
|
+
*/
|
|
4
|
+
import type { FormatProps } from "@itwin/core-quantity";
|
|
5
|
+
import React from "react";
|
|
6
|
+
/**
|
|
7
|
+
* Component used to customize Azimuth options of a Format.
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export declare function AzimuthOptions(props: {
|
|
11
|
+
formatProps: FormatProps;
|
|
12
|
+
onChange?: (format: FormatProps) => void;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
//# sourceMappingURL=AzimuthOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AzimuthOptions.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/AzimuthOptions.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,OAAO,CAAC;CACnB,qBA+FA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { useTranslation } from "../../useTranslation.js";
|
|
4
|
+
import { SvgHelpCircularHollow } from "@itwin/itwinui-icons-react";
|
|
5
|
+
import { Checkbox, IconButton, Input, Label } from "@itwin/itwinui-react";
|
|
6
|
+
/**
|
|
7
|
+
* Component used to customize Azimuth options of a Format.
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export function AzimuthOptions(props) {
|
|
11
|
+
const { formatProps, onChange, disabled } = props;
|
|
12
|
+
const { translate } = useTranslation();
|
|
13
|
+
const baseInputId = React.useId();
|
|
14
|
+
const ccwCheckboxId = React.useId();
|
|
15
|
+
const handleAzimuthBaseChange = React.useCallback((value) => {
|
|
16
|
+
const newFormatProps = { ...formatProps, azimuthBase: value };
|
|
17
|
+
onChange && onChange(newFormatProps);
|
|
18
|
+
}, [formatProps, onChange]);
|
|
19
|
+
const handleAzimuthCCWChange = React.useCallback((event) => {
|
|
20
|
+
const newFormatProps = {
|
|
21
|
+
...formatProps,
|
|
22
|
+
azimuthCounterClockwise: event.target.checked,
|
|
23
|
+
};
|
|
24
|
+
onChange && onChange(newFormatProps);
|
|
25
|
+
}, [formatProps, onChange]);
|
|
26
|
+
/** Disable commas and letters */
|
|
27
|
+
const onKeyDown = (event) => {
|
|
28
|
+
const isLetter = /^[a-zA-Z]$/.test(event.key);
|
|
29
|
+
if (event.key === "," || isLetter) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const handleInputChange = React.useCallback((e) => {
|
|
34
|
+
const numValue = Number(e.target.value);
|
|
35
|
+
if (isNaN(numValue)) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
handleAzimuthBaseChange(numValue);
|
|
40
|
+
}, [handleAzimuthBaseChange]);
|
|
41
|
+
return (React.createElement(React.Fragment, null,
|
|
42
|
+
React.createElement(Label, { className: classnames("uicore-label", disabled && "uicore-disabled"), id: ccwCheckboxId, as: "div", displayStyle: "inline" },
|
|
43
|
+
translate("QuantityFormat.labels.azimuthCounterClockwise"),
|
|
44
|
+
React.createElement(IconButton, { size: "small", styleType: "borderless", label: translate("QuantityFormat.azimuthType.ccwFlagTooltip") },
|
|
45
|
+
React.createElement(SvgHelpCircularHollow, null))),
|
|
46
|
+
React.createElement(Checkbox, { "aria-labelledby": ccwCheckboxId, checked: formatProps.azimuthCounterClockwise ?? false, onChange: handleAzimuthCCWChange, disabled: disabled }),
|
|
47
|
+
React.createElement(Label, { id: baseInputId, className: classnames("uicore-label", disabled && "uicore-disabled"), as: "div", displayStyle: "inline" },
|
|
48
|
+
translate("QuantityFormat.labels.azimuthBase"),
|
|
49
|
+
React.createElement(IconButton, { size: "small", styleType: "borderless", label: translate("QuantityFormat.azimuthType.baseTooltip") },
|
|
50
|
+
React.createElement(SvgHelpCircularHollow, null))),
|
|
51
|
+
React.createElement(Input, { "aria-labelledby": baseInputId, type: "number", value: formatProps.azimuthBase?.toString() ?? "0", onKeyDown: onKeyDown, onChange: handleInputChange, size: "small", disabled: disabled })));
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=AzimuthOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AzimuthOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/AzimuthOptions.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE1E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAI9B;IACC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAClD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IAEvC,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAClC,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IACpC,MAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAC/C,CAAC,KAAa,EAAE,EAAE;QAChB,MAAM,cAAc,GAAG,EAAE,GAAG,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;QAC9D,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,WAAW,EAAE,QAAQ,CAAC,CACxB,CAAC;IAEF,MAAM,sBAAsB,GAAG,KAAK,CAAC,WAAW,CAC9C,CAAC,KAA0C,EAAE,EAAE;QAC7C,MAAM,cAAc,GAAG;YACrB,GAAG,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uBAAuB,IAAI,KAAK,EACrD,QAAQ,EAAE,sBAAsB,EAChC,QAAQ,EAAE,QAAQ,GAClB;QAEF,oBAAC,KAAK,IACJ,EAAE,EAAE,WAAW,EACf,SAAS,EAAE,UAAU,CAAC,cAAc,EAAE,QAAQ,IAAI,iBAAiB,CAAC,EACpE,EAAE,EAAC,KAAK,EACR,YAAY,EAAC,QAAQ;YAEpB,SAAS,CAAC,mCAAmC,CAAC;YAC/C,oBAAC,UAAU,IACT,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;gBAE1D,oBAAC,qBAAqB,OAAG,CACd,CACP;QACR,oBAAC,KAAK,uBACa,WAAW,EAC5B,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,WAAW,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,GAAG,EACjD,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,QAAQ,GAClB,CACD,CACJ,CAAC;AACJ,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 QuantityFormat\n */\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport React from \"react\";\nimport classnames from \"classnames\";\nimport { useTranslation } from \"../../useTranslation.js\";\nimport { SvgHelpCircularHollow } from \"@itwin/itwinui-icons-react\";\nimport { Checkbox, IconButton, Input, Label } from \"@itwin/itwinui-react\";\n\n/**\n * Component used to customize Azimuth options of a Format.\n * @alpha\n */\nexport function AzimuthOptions(props: {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n disabled: boolean;\n}) {\n const { formatProps, onChange, disabled } = props;\n const { translate } = useTranslation();\n\n const baseInputId = React.useId();\n const ccwCheckboxId = React.useId();\n const handleAzimuthBaseChange = React.useCallback(\n (value: number) => {\n const newFormatProps = { ...formatProps, azimuthBase: value };\n onChange && onChange(newFormatProps);\n },\n [formatProps, onChange]\n );\n\n const handleAzimuthCCWChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newFormatProps = {\n ...formatProps,\n azimuthCounterClockwise: event.target.checked,\n };\n onChange && onChange(newFormatProps);\n },\n [formatProps, onChange]\n );\n\n /** Disable commas and letters */\n const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const isLetter = /^[a-zA-Z]$/.test(event.key);\n if (event.key === \",\" || isLetter) {\n event.preventDefault();\n }\n };\n\n const handleInputChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const numValue = Number(e.target.value);\n if (isNaN(numValue)) {\n e.preventDefault();\n return;\n }\n handleAzimuthBaseChange(numValue);\n },\n [handleAzimuthBaseChange]\n );\n\n return (\n <>\n <Label\n className={classnames(\"uicore-label\", disabled && \"uicore-disabled\")}\n id={ccwCheckboxId}\n as=\"div\"\n displayStyle=\"inline\"\n >\n {translate(\"QuantityFormat.labels.azimuthCounterClockwise\")}\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n label={translate(\"QuantityFormat.azimuthType.ccwFlagTooltip\")}\n >\n <SvgHelpCircularHollow />\n </IconButton>\n </Label>\n <Checkbox\n aria-labelledby={ccwCheckboxId}\n checked={formatProps.azimuthCounterClockwise ?? false}\n onChange={handleAzimuthCCWChange}\n disabled={disabled}\n />\n\n <Label\n id={baseInputId}\n className={classnames(\"uicore-label\", disabled && \"uicore-disabled\")}\n as=\"div\"\n displayStyle=\"inline\"\n >\n {translate(\"QuantityFormat.labels.azimuthBase\")}\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n label={translate(\"QuantityFormat.azimuthType.baseTooltip\")}\n >\n <SvgHelpCircularHollow />\n </IconButton>\n </Label>\n <Input\n aria-labelledby={baseInputId}\n type=\"number\"\n value={formatProps.azimuthBase?.toString() ?? \"0\"}\n onKeyDown={onKeyDown}\n onChange={handleInputChange}\n size=\"small\"\n disabled={disabled}\n />\n </>\n );\n}\n"]}
|
|
@@ -13,7 +13,7 @@ import { useTranslation } from "../../useTranslation.js";
|
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
export function DecimalPrecisionSelector(props) {
|
|
16
|
-
const { precision, onChange, ...
|
|
16
|
+
const { precision, onChange, ...rest } = props;
|
|
17
17
|
const { translate } = useTranslation();
|
|
18
18
|
const options = [
|
|
19
19
|
{
|
|
@@ -72,6 +72,6 @@ export function DecimalPrecisionSelector(props) {
|
|
|
72
72
|
const handleOnChange = React.useCallback((newValue) => {
|
|
73
73
|
onChange && onChange(newValue);
|
|
74
74
|
}, [onChange]);
|
|
75
|
-
return (React.createElement(Select, { options: options, value: precision, onChange: handleOnChange, size: "small", ...
|
|
75
|
+
return (React.createElement(Select, { options: options, value: precision, onChange: handleOnChange, size: "small", ...rest }));
|
|
76
76
|
}
|
|
77
77
|
//# sourceMappingURL=DecimalPrecision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/DecimalPrecision.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAWzD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"DecimalPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/DecimalPrecision.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK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,EAAE,SAAS,CAAC,yCAAyC,CAAC;SAC5D;QACD;YACE,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;SAC5D;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,KACR,IAAI,GACR,CACH,CAAC;AACJ,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 QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation.js\";\n\n/** Properties of [[DecimalPrecisionSelector]] component.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface DecimalPrecisionSelectorProps extends CommonProps {\n precision: number;\n onChange: (value: number) => void;\n}\n\n/** Component use to set Decimal Precision\n * the unit label.\n * @internal\n */\nexport function DecimalPrecisionSelector(props: DecimalPrecisionSelectorProps) {\n const { precision, onChange, ...rest } = props;\n const { translate } = useTranslation();\n const options: SelectOption<number>[] = [\n {\n value: 0,\n label: translate(\"QuantityFormat.decimal_precision.zero\"),\n },\n {\n value: 1,\n label: translate(\"QuantityFormat.decimal_precision.one\"),\n },\n {\n value: 2,\n label: translate(\"QuantityFormat.decimal_precision.two\"),\n },\n {\n value: 3,\n label: translate(\"QuantityFormat.decimal_precision.three\"),\n },\n {\n value: 4,\n label: translate(\"QuantityFormat.decimal_precision.four\"),\n },\n {\n value: 5,\n label: translate(\"QuantityFormat.decimal_precision.five\"),\n },\n {\n value: 6,\n label: translate(\"QuantityFormat.decimal_precision.six\"),\n },\n {\n value: 7,\n label: translate(\"QuantityFormat.decimal_precision.seven\"),\n },\n {\n value: 8,\n label: translate(\"QuantityFormat.decimal_precision.eight\"),\n },\n {\n value: 9,\n label: translate(\"QuantityFormat.decimal_precision.nine\"),\n },\n {\n value: 10,\n label: translate(\"QuantityFormat.decimal_precision.ten\"),\n },\n {\n value: 11,\n label: translate(\"QuantityFormat.decimal_precision.eleven\"),\n },\n {\n value: 12,\n label: translate(\"QuantityFormat.decimal_precision.twelve\"),\n },\n ];\n\n const handleOnChange = React.useCallback(\n (newValue: number) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <Select\n options={options}\n value={precision}\n onChange={handleOnChange}\n size=\"small\"\n {...rest}\n />\n );\n}\n"]}
|
|
@@ -12,7 +12,7 @@ import { useTranslation } from "../../useTranslation.js";
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export function DecimalSeparatorSelector(props) {
|
|
15
|
-
const { separator, onChange, ...
|
|
15
|
+
const { separator, onChange, ...rest } = props;
|
|
16
16
|
const { translate } = useTranslation();
|
|
17
17
|
const options = [
|
|
18
18
|
{
|
|
@@ -27,6 +27,6 @@ export function DecimalSeparatorSelector(props) {
|
|
|
27
27
|
const handleOnChange = React.useCallback((newValue) => {
|
|
28
28
|
onChange && onChange(newValue);
|
|
29
29
|
}, [onChange]);
|
|
30
|
-
return (React.createElement(Select, { options: options, value: separator, onChange: handleOnChange, size: "small", ...
|
|
30
|
+
return (React.createElement(Select, { options: options, value: separator, onChange: handleOnChange, size: "small", ...rest }));
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=DecimalSeparator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalSeparator.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/DecimalSeparator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAYzD;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"DecimalSeparator.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/DecimalSeparator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAYzD;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC/C,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,OAAO,GAA2B;QACtC;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;SAC3D;QACD;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;SAC3D;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,KACR,IAAI,GACR,CACH,CAAC;AACJ,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 QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation.js\";\n\n/** Properties of [[DecimalSeparatorSelector]] component.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface DecimalSeparatorSelectorProps extends CommonProps {\n separator: string;\n disabled?: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to set Decimal Separator\n * @internal\n */\nexport function DecimalSeparatorSelector(props: DecimalSeparatorSelectorProps) {\n const { separator, onChange, ...rest } = props;\n const { translate } = useTranslation();\n const options: SelectOption<string>[] = [\n {\n value: \".\",\n label: translate(\"QuantityFormat.decimal_separator.point\"),\n },\n {\n value: \",\",\n label: translate(\"QuantityFormat.decimal_separator.comma\"),\n },\n ];\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <Select\n options={options}\n value={separator}\n onChange={handleOnChange}\n size=\"small\"\n {...rest}\n />\n );\n}\n"]}
|
|
@@ -12,7 +12,7 @@ import { useTranslation } from "../../useTranslation.js";
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export function FractionPrecisionSelector(props) {
|
|
15
|
-
const { precision, onChange, ...
|
|
15
|
+
const { precision, onChange, ...rest } = props;
|
|
16
16
|
const { translate } = useTranslation();
|
|
17
17
|
const options = [
|
|
18
18
|
{
|
|
@@ -55,6 +55,6 @@ export function FractionPrecisionSelector(props) {
|
|
|
55
55
|
const handleOnChange = React.useCallback((newValue) => {
|
|
56
56
|
onChange && onChange(newValue);
|
|
57
57
|
}, [onChange]);
|
|
58
|
-
return (React.createElement(Select, { options: options, value: precision, onChange: handleOnChange, size: "small", ...
|
|
58
|
+
return (React.createElement(Select, { options: options, value: precision, onChange: handleOnChange, size: "small", ...rest }));
|
|
59
59
|
}
|
|
60
60
|
//# sourceMappingURL=FractionPrecision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FractionPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/FractionPrecision.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAWzD;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"FractionPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/misc/FractionPrecision.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAWzD;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAqC;IAErC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC/C,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,OAAO,GAA2B;QACtC;YACE,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;SAC5D;QACD;YACE,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;SAC3D;QACD;YACE,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,SAAS,CAAC,2CAA2C,CAAC;SAC9D;QACD;YACE,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,SAAS,CAAC,0CAA0C,CAAC;SAC7D;QACD;YACE,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,SAAS,CAAC,6CAA6C,CAAC;SAChE;QACD;YACE,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,SAAS,CAAC,0CAA0C,CAAC;SAC7D;QACD;YACE,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,SAAS,CAAC,0CAA0C,CAAC;SAC7D;QACD;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,SAAS,CAAC,2CAA2C,CAAC;SAC9D;QACD;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,SAAS,CAAC,2CAA2C,CAAC;SAC9D;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,KACR,IAAI,GACR,CACH,CAAC;AACJ,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 QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation.js\";\n\n/** Properties of [[FractionPrecisionSelector]] component.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface FractionPrecisionSelectorProps extends CommonProps {\n precision: number;\n onChange: (value: number) => void;\n}\n\n/** Component use to set Fraction precision\n * @internal\n */\nexport function FractionPrecisionSelector(\n props: FractionPrecisionSelectorProps\n) {\n const { precision, onChange, ...rest } = props;\n const { translate } = useTranslation();\n const options: SelectOption<number>[] = [\n {\n value: 1,\n label: translate(\"QuantityFormat.fraction_precision.whole\"),\n },\n {\n value: 2,\n label: translate(\"QuantityFormat.fraction_precision.half\"),\n },\n {\n value: 4,\n label: translate(\"QuantityFormat.fraction_precision.quarter\"),\n },\n {\n value: 8,\n label: translate(\"QuantityFormat.fraction_precision.eighth\"),\n },\n {\n value: 16,\n label: translate(\"QuantityFormat.fraction_precision.sixteenth\"),\n },\n {\n value: 32,\n label: translate(\"QuantityFormat.fraction_precision.over32\"),\n },\n {\n value: 64,\n label: translate(\"QuantityFormat.fraction_precision.over64\"),\n },\n {\n value: 128,\n label: translate(\"QuantityFormat.fraction_precision.over128\"),\n },\n {\n value: 256,\n label: translate(\"QuantityFormat.fraction_precision.over256\"),\n },\n ];\n\n const handleOnChange = React.useCallback(\n (newValue: number) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <Select\n options={options}\n value={precision}\n onChange={handleOnChange}\n size=\"small\"\n {...rest}\n />\n );\n}\n"]}
|