@itwin/imodel-components-react 4.7.2 → 4.8.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 +8 -3
- package/lib/cjs/imodel-components-react/UiIModelComponents.js +4 -2
- package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +2 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +2 -3
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +2 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +10 -6
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +7 -3
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +2 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +2 -2
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +9 -7
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/UiIModelComponents.js +4 -2
- package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +2 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js +2 -3
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +2 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +10 -6
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +7 -3
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +2 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +2 -2
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +9 -7
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/package.json +5 -5
|
@@ -39,6 +39,7 @@ const UiIModelComponents_1 = require("../UiIModelComponents");
|
|
|
39
39
|
* @alpha
|
|
40
40
|
*/
|
|
41
41
|
function FormatUnits(props) {
|
|
42
|
+
var _a, _b, _c;
|
|
42
43
|
const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } = props;
|
|
43
44
|
const initialFormatRef = React.useRef(initialFormat);
|
|
44
45
|
const [formatProps, setFormatProps] = React.useState(initialFormat);
|
|
@@ -132,15 +133,18 @@ function FormatUnits(props) {
|
|
|
132
133
|
}, [formatProps, handleSetFormatProps]);
|
|
133
134
|
const compositeSpacer = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.compositeSpacer"));
|
|
134
135
|
return (React.createElement(React.Fragment, null,
|
|
135
|
-
formatProps.composite
|
|
136
|
-
? formatProps.composite.units.map((value, index) =>
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
((_a = formatProps.composite) === null || _a === void 0 ? void 0 : _a.units)
|
|
137
|
+
? formatProps.composite.units.map((value, index) => {
|
|
138
|
+
var _a;
|
|
139
|
+
return (React.createElement(UnitDescr_1.UnitDescr, { key: value.name, name: value.name, label: (_a = value.label) !== null && _a !== void 0 ? _a : "", parentUnitName: index > 0
|
|
140
|
+
? formatProps.composite.units[index - 1].name
|
|
141
|
+
: undefined, unitsProvider: unitsProvider, index: index, onUnitChange: handleUnitChange, onLabelChange: handleUnitLabelChange, readonly: index < formatProps.composite.units.length - 1 }));
|
|
142
|
+
})
|
|
139
143
|
: persistenceUnit && (React.createElement(UnitDescr_1.UnitDescr, { key: persistenceUnit.name, name: persistenceUnit.name, label: persistenceUnit.label, unitsProvider: unitsProvider, index: 0, onUnitChange: handleUnitChange, onLabelChange: handleUnitLabelChange })),
|
|
140
|
-
formatProps.composite
|
|
144
|
+
((_b = formatProps.composite) === null || _b === void 0 ? void 0 : _b.units) &&
|
|
141
145
|
formatProps.composite.units.length > 1 && (React.createElement(React.Fragment, null,
|
|
142
146
|
React.createElement("span", { key: "composite-spacer-label", className: "uicore-label" }, compositeSpacer.current),
|
|
143
|
-
React.createElement(itwinui_react_1.Input, { key: "composite-spacer", "data-testid": "composite-spacer", value: formatProps.composite.spacer
|
|
147
|
+
React.createElement(itwinui_react_1.Input, { key: "composite-spacer", "data-testid": "composite-spacer", value: (_c = formatProps.composite.spacer) !== null && _c !== void 0 ? _c : "", onChange: handleOnSpacerChange, size: "small" })))));
|
|
144
148
|
}
|
|
145
149
|
exports.FormatUnits = FormatUnits;
|
|
146
150
|
//# sourceMappingURL=FormatUnits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatUnits.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAO/B,wDAA6C;AAC7C,gDAA6C;AAC7C,8DAA2D;AAY3D;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,GACpE,KAAK,CAAC;IACR,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAc,aAAa,CAAC,CAAC;IAClE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEpE,KAAK,CAAC,SAAS,CAAC,GAAG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CAAC,IAAI,EAC1B,KAAK,EAAE,eAAe,CAAC,KAAK,EAC5B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,CAAC,EACR,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,qBAAqB,GACpC,CACH;QAEJ,WAAW,CAAC,SAAS,EAAE,KAAK;YAC3B,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACxC;YACE,8BAAM,GAAG,EAAE,wBAAwB,EAAE,SAAS,EAAE,cAAc,IAC3D,eAAe,CAAC,OAAO,CACnB;YACP,oBAAC,qBAAK,IACJ,GAAG,EAAE,kBAAkB,iBACX,kBAAkB,EAC9B,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,EACzC,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CACF,CACJ,CAAC;AACJ,CAAC;AApKD,kCAoKC","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 {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UnitDescr } from \"./misc/UnitDescr\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties of [[FormatUnits]] component.\n * @alpha\n */\nexport interface FormatUnitsProps extends CommonProps {\n initialFormat: FormatProps;\n persistenceUnit?: UnitProps;\n unitsProvider: UnitsProvider;\n onUnitsChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Units used for Quantity Formatting.\n * @alpha\n */\nexport function FormatUnits(props: FormatUnitsProps) {\n const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } =\n props;\n const initialFormatRef = React.useRef<FormatProps>(initialFormat);\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n\n React.useEffect(() => {\n if (initialFormatRef.current !== initialFormat) {\n initialFormatRef.current = initialFormat;\n setFormatProps(initialFormat);\n }\n }, [initialFormat]);\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n setFormatProps(newProps);\n onUnitsChange && onUnitsChange(newProps);\n },\n [onUnitsChange]\n );\n\n const handleUnitLabelChange = React.useCallback(\n (newLabel: string, index: number) => {\n // istanbul ignore else\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n // istanbul ignore else\n if (index === ndx) return { name: entry.name, label: newLabel };\n else return entry;\n });\n\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUnitChange = React.useCallback(\n (newUnit: string, index: number) => {\n const unitParts = newUnit.split(/:/);\n if (unitParts[0] === \"REMOVEUNIT\") {\n // istanbul ignore else\n if (formatProps.composite && formatProps.composite.units.length > 1) {\n const units = [...formatProps.composite.units];\n units.pop();\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n } else if (unitParts[0] === \"ADDSUBUNIT\") {\n const units =\n formatProps.composite && formatProps.composite.units.length\n ? [\n ...formatProps.composite.units,\n { name: unitParts[1], label: unitParts[2] },\n ]\n : /* istanbul ignore next*/ [\n { name: unitParts[1], label: unitParts[2] },\n ];\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else {\n // istanbul ignore else\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n // istanbul ignore else\n if (index === ndx)\n return { name: unitParts[0], label: unitParts[1] };\n else return entry;\n });\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else if (!formatProps.composite) {\n const composite = {\n units: [{ name: unitParts[0], label: unitParts[1] }],\n };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleOnSpacerChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (formatProps.composite) {\n const spacerValue = e.target.value.length\n ? e.target.value[0]\n : /* istanbul ignore next */ \"\"; // spacer can only be empty or a single character\n const composite = { ...formatProps.composite, spacer: spacerValue };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const compositeSpacer = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.compositeSpacer\")\n );\n\n return (\n <>\n {formatProps.composite?.units\n ? formatProps.composite.units.map((value, index) => (\n <UnitDescr\n key={value.name}\n name={value.name}\n label={value.label ?? \"\"}\n parentUnitName={\n index > 0\n ? formatProps.composite!.units[index - 1].name\n : undefined\n }\n unitsProvider={unitsProvider}\n index={index}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n readonly={index < formatProps.composite!.units.length - 1}\n />\n ))\n : persistenceUnit && (\n <UnitDescr\n key={persistenceUnit.name}\n name={persistenceUnit.name}\n label={persistenceUnit.label}\n unitsProvider={unitsProvider}\n index={0}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n />\n )}\n\n {formatProps.composite?.units &&\n formatProps.composite.units.length > 1 && (\n <>\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>\n {compositeSpacer.current}\n </span>\n <Input\n key={\"composite-spacer\"}\n data-testid=\"composite-spacer\"\n value={formatProps.composite.spacer ?? \"\"}\n onChange={handleOnSpacerChange}\n size=\"small\"\n />\n </>\n )}\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FormatUnits.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAO/B,wDAA6C;AAC7C,gDAA6C;AAC7C,8DAA2D;AAY3D;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAuB;;IACjD,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,GACpE,KAAK,CAAC;IACR,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAc,aAAa,CAAC,CAAC;IAClE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEpE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,gBAAgB,CAAC,OAAO,KAAK,aAAa,EAAE;YAC9C,gBAAgB,CAAC,OAAO,GAAG,aAAa,CAAC;YACzC,cAAc,CAAC,aAAa,CAAC,CAAC;SAC/B;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAC5C,CAAC,QAAqB,EAAE,EAAE;QACxB,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzB,aAAa,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAC7C,CAAC,QAAgB,EAAE,KAAa,EAAE,EAAE;QAClC,uBAAuB;QACvB,IACE,WAAW,CAAC,SAAS;YACrB,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK;YAC1C,KAAK,IAAI,CAAC,EACV;YACA,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CA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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 { CommonProps } from \"@itwin/core-react\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UnitDescr } from \"./misc/UnitDescr\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties of [[FormatUnits]] component.\n * @alpha\n */\nexport interface FormatUnitsProps extends CommonProps {\n initialFormat: FormatProps;\n persistenceUnit?: UnitProps;\n unitsProvider: UnitsProvider;\n onUnitsChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Units used for Quantity Formatting.\n * @alpha\n */\nexport function FormatUnits(props: FormatUnitsProps) {\n const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } =\n props;\n const initialFormatRef = React.useRef<FormatProps>(initialFormat);\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n\n React.useEffect(() => {\n if (initialFormatRef.current !== initialFormat) {\n initialFormatRef.current = initialFormat;\n setFormatProps(initialFormat);\n }\n }, [initialFormat]);\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n setFormatProps(newProps);\n onUnitsChange && onUnitsChange(newProps);\n },\n [onUnitsChange]\n );\n\n const handleUnitLabelChange = React.useCallback(\n (newLabel: string, index: number) => {\n // istanbul ignore else\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n // istanbul ignore else\n if (index === ndx) return { name: entry.name, label: newLabel };\n else return entry;\n });\n\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUnitChange = React.useCallback(\n (newUnit: string, index: number) => {\n const unitParts = newUnit.split(/:/);\n if (unitParts[0] === \"REMOVEUNIT\") {\n // istanbul ignore else\n if (formatProps.composite && formatProps.composite.units.length > 1) {\n const units = [...formatProps.composite.units];\n units.pop();\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n } else if (unitParts[0] === \"ADDSUBUNIT\") {\n const units =\n formatProps.composite && formatProps.composite.units.length\n ? [\n ...formatProps.composite.units,\n { name: unitParts[1], label: unitParts[2] },\n ]\n : /* istanbul ignore next*/ [\n { name: unitParts[1], label: unitParts[2] },\n ];\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else {\n // istanbul ignore else\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n // istanbul ignore else\n if (index === ndx)\n return { name: unitParts[0], label: unitParts[1] };\n else return entry;\n });\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else if (!formatProps.composite) {\n const composite = {\n units: [{ name: unitParts[0], label: unitParts[1] }],\n };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleOnSpacerChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (formatProps.composite) {\n const spacerValue = e.target.value.length\n ? e.target.value[0]\n : /* istanbul ignore next */ \"\"; // spacer can only be empty or a single character\n const composite = { ...formatProps.composite, spacer: spacerValue };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const compositeSpacer = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.compositeSpacer\")\n );\n\n return (\n <>\n {formatProps.composite?.units\n ? formatProps.composite.units.map((value, index) => (\n <UnitDescr\n key={value.name}\n name={value.name}\n label={value.label ?? \"\"}\n parentUnitName={\n index > 0\n ? formatProps.composite!.units[index - 1].name\n : undefined\n }\n unitsProvider={unitsProvider}\n index={index}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n readonly={index < formatProps.composite!.units.length - 1}\n />\n ))\n : persistenceUnit && (\n <UnitDescr\n key={persistenceUnit.name}\n name={persistenceUnit.name}\n label={persistenceUnit.label}\n unitsProvider={unitsProvider}\n index={0}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n />\n )}\n\n {formatProps.composite?.units &&\n formatProps.composite.units.length > 1 && (\n <>\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>\n {compositeSpacer.current}\n </span>\n <Input\n key={\"composite-spacer\"}\n data-testid=\"composite-spacer\"\n value={formatProps.composite.spacer ?? \"\"}\n onChange={handleOnSpacerChange}\n size=\"small\"\n />\n </>\n )}\n </>\n );\n}\n"]}
|
|
@@ -50,6 +50,7 @@ const UiIModelComponents_1 = require("../UiIModelComponents");
|
|
|
50
50
|
* @alpha
|
|
51
51
|
*/
|
|
52
52
|
function MiscFormatOptions(props) {
|
|
53
|
+
var _a, _b;
|
|
53
54
|
const { formatProps, onChange, showOptions, onShowHideOptions, enableMinimumProperties, } = props;
|
|
54
55
|
const handleSetFormatProps = React.useCallback((newFormatProps) => {
|
|
55
56
|
onChange && onChange(newFormatProps);
|
|
@@ -141,7 +142,10 @@ function MiscFormatOptions(props) {
|
|
|
141
142
|
handleSetFormatProps(newFormatProps);
|
|
142
143
|
}, [handleSetFormatProps]);
|
|
143
144
|
const formatType = React.useMemo(() => (0, core_quantity_1.parseFormatType)(formatProps.type, "format"), [formatProps.type]);
|
|
144
|
-
const showSignOption = React.useMemo(() =>
|
|
145
|
+
const showSignOption = React.useMemo(() => {
|
|
146
|
+
var _a;
|
|
147
|
+
return (0, core_quantity_1.parseShowSignOption)((_a = formatProps.showSignOption) !== null && _a !== void 0 ? _a : "onlyNegative", "format");
|
|
148
|
+
}, [formatProps.showSignOption]);
|
|
145
149
|
const handleToggleButtonClick = React.useCallback(() => {
|
|
146
150
|
onShowHideOptions(!showOptions);
|
|
147
151
|
}, [onShowHideOptions, showOptions]);
|
|
@@ -178,14 +182,14 @@ function MiscFormatOptions(props) {
|
|
|
178
182
|
React.createElement("span", { className: "uicore-label" }, signOptionLabel.current),
|
|
179
183
|
React.createElement(SignOption_1.SignOptionSelector, { "data-testid": "sign-option-selector", signOption: showSignOption, onChange: handleShowSignChange }),
|
|
180
184
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", formatType !== core_quantity_1.FormatType.Station && "uicore-disabled") }, stationOffsetLabel.current),
|
|
181
|
-
React.createElement(StationSizeSelector_1.StationSizeSelector, { "data-testid": "station-size-selector", value: formatProps.stationOffsetSize
|
|
185
|
+
React.createElement(StationSizeSelector_1.StationSizeSelector, { "data-testid": "station-size-selector", value: (_a = formatProps.stationOffsetSize) !== null && _a !== void 0 ? _a : 2, disabled: formatType !== core_quantity_1.FormatType.Station, onChange: handleStationOffsetChange }),
|
|
182
186
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", formatType !== core_quantity_1.FormatType.Station && "uicore-disabled") }, stationSeparatorLabel.current),
|
|
183
187
|
React.createElement(StationSeparatorSelector_1.StationSeparatorSelector, { "data-testid": "station-separator-selector", separator: undefined !== formatProps.stationSeparator
|
|
184
188
|
? formatProps.stationSeparator
|
|
185
189
|
: "+", disabled: formatType !== core_quantity_1.FormatType.Station, onChange: handleStationSeparatorChange }),
|
|
186
190
|
React.createElement(ThousandsSeparator_1.ThousandsSeparator, { formatProps: formatProps, onChange: handleFormatChange }),
|
|
187
191
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", formatType === core_quantity_1.FormatType.Fractional && "uicore-disabled") }, decimalSeparatorLabel.current),
|
|
188
|
-
React.createElement(DecimalSeparator_1.DecimalSeparatorSelector, { "data-testid": "decimal-separator-selector", separator: formatProps.decimalSeparator
|
|
192
|
+
React.createElement(DecimalSeparator_1.DecimalSeparatorSelector, { "data-testid": "decimal-separator-selector", separator: (_b = formatProps.decimalSeparator) !== null && _b !== void 0 ? _b : ".", onChange: handleDecimalSeparatorChange, disabled: formatType === core_quantity_1.FormatType.Fractional }),
|
|
189
193
|
React.createElement("span", { className: "uicore-label" }, showTrailZerosLabel.current),
|
|
190
194
|
React.createElement(itwinui_react_1.Checkbox, { "data-testid": "show-trail-zeros", checked: isFormatTraitSet(core_quantity_1.FormatTraits.TrailZeroes), onChange: handleShowTrailingZeroesChange }),
|
|
191
195
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", formatType === core_quantity_1.FormatType.Fractional && "uicore-disabled") }, keepDecimalPointLabel.current),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,6CAAkC;AAElC,wDAAgD;AAEhD,wDAW8B;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,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,uBAAuB,GACxB,GAAG,KAAK,CAAC;IAEV,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAC5C,CAAC,cAA2B,EAAE,EAAE;QAC9B,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAC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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 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\";\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator\";\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator\";\nimport { ScientificTypeSelector } from \"./misc/ScientificType\";\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector\";\nimport { StationSizeSelector } from \"./misc/StationSizeSelector\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties of [[MiscFormatOptions]] component.\n * @alpha\n */\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 */\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\n const {\n formatProps,\n onChange,\n showOptions,\n onShowHideOptions,\n enableMinimumProperties,\n } = props;\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 = 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 // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n // istanbul ignore else\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n // istanbul ignore next\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ 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 // istanbul ignore else\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: 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 // istanbul ignore else\n if (e.key === Key.Enter || 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 const signOptionLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.signOptionLabel\")\n );\n const stationOffsetLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.stationOffsetLabel\")\n );\n const stationSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.stationSeparatorLabel\")\n );\n const decimalSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.decimalSeparatorLabel\")\n );\n const showTrailZerosLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.showTrailZerosLabel\")\n );\n const keepSingleZeroLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.keepSingleZeroLabel\")\n );\n const zeroEmptyLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.zeroEmptyLabel\")\n );\n const moreLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.moreLabel\")\n );\n const lessLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.lessLabel\")\n );\n const keepDecimalPointLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.keepDecimalPointLabel\")\n );\n const fractionDashLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.fractionDashLabel\")\n );\n const scientificTypeLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.scientificTypeLabel\")\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 data-testid=\"quantityFormat-more\"\n tabIndex={0}\n >\n {moreLabel.current}\n </a>\n )}\n {(!enableMinimumProperties || showOptions) && (\n <>\n <span className={\"uicore-label\"}>{signOptionLabel.current}</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 {stationOffsetLabel.current}\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 {stationSeparatorLabel.current}\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 {decimalSeparatorLabel.current}\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\"}>{showTrailZerosLabel.current}</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 {keepDecimalPointLabel.current}\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\"}>{keepSingleZeroLabel.current}</span>\n <Checkbox\n data-testid=\"keep-single-zero\"\n checked={isFormatTraitSet(FormatTraits.KeepSingleZero)}\n onChange={handleKeepSingleZeroChange}\n />\n\n <span className={\"uicore-label\"}>{zeroEmptyLabel.current}</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 {fractionDashLabel.current}\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 {scientificTypeLabel.current}\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 data-testid=\"quantityFormat-less\"\n tabIndex={0}\n >\n {lessLabel.current}\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,4DAAoC;AACpC,6CAA+B;AAC/B,6CAAkC;AAElC,wDAAgD;AAEhD,wDAW8B;AAC9B,kDAAuD;AACvD,kEAA+D;A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,WAAW,CAAC,cAAc,EAAE,QAAQ,CAAC;oBAC3D,CAAC,CAAC,8BAAc,CAAC,UAAU,EAE/B,QAAQ,EAAE,UAAU,KAAK,0BAAU,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,iBACC,qBAAqB,EACjC,QAAQ,EAAE,CAAC,IAEV,SAAS,CAAC,OAAO,CAChB,CACL,CACA,CACJ,CACA,CACJ,CAAC;AACJ,CAAC;AAxYD,8CAwYC","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\";\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator\";\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator\";\nimport { ScientificTypeSelector } from \"./misc/ScientificType\";\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector\";\nimport { StationSizeSelector } from \"./misc/StationSizeSelector\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties of [[MiscFormatOptions]] component.\n * @alpha\n */\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 */\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\n const {\n formatProps,\n onChange,\n showOptions,\n onShowHideOptions,\n enableMinimumProperties,\n } = props;\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 = 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 // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n // istanbul ignore else\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n // istanbul ignore next\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ 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 // istanbul ignore else\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: 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 // istanbul ignore else\n if (e.key === Key.Enter || 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 const signOptionLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.signOptionLabel\")\n );\n const stationOffsetLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.stationOffsetLabel\")\n );\n const stationSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.stationSeparatorLabel\")\n );\n const decimalSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.decimalSeparatorLabel\")\n );\n const showTrailZerosLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.showTrailZerosLabel\")\n );\n const keepSingleZeroLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.keepSingleZeroLabel\")\n );\n const zeroEmptyLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.zeroEmptyLabel\")\n );\n const moreLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.moreLabel\")\n );\n const lessLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.lessLabel\")\n );\n const keepDecimalPointLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.keepDecimalPointLabel\")\n );\n const fractionDashLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.fractionDashLabel\")\n );\n const scientificTypeLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.scientificTypeLabel\")\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 data-testid=\"quantityFormat-more\"\n tabIndex={0}\n >\n {moreLabel.current}\n </a>\n )}\n {(!enableMinimumProperties || showOptions) && (\n <>\n <span className={\"uicore-label\"}>{signOptionLabel.current}</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 {stationOffsetLabel.current}\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 {stationSeparatorLabel.current}\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 {decimalSeparatorLabel.current}\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\"}>{showTrailZerosLabel.current}</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 {keepDecimalPointLabel.current}\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\"}>{keepSingleZeroLabel.current}</span>\n <Checkbox\n data-testid=\"keep-single-zero\"\n checked={isFormatTraitSet(FormatTraits.KeepSingleZero)}\n onChange={handleKeepSingleZeroChange}\n />\n\n <span className={\"uicore-label\"}>{zeroEmptyLabel.current}</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 {fractionDashLabel.current}\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 {scientificTypeLabel.current}\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 data-testid=\"quantityFormat-less\"\n tabIndex={0}\n >\n {lessLabel.current}\n </a>\n )}\n </>\n )}\n </>\n );\n}\n"]}
|
|
@@ -44,6 +44,7 @@ const UiIModelComponents_1 = require("../../UiIModelComponents");
|
|
|
44
44
|
* @internal
|
|
45
45
|
*/
|
|
46
46
|
function ThousandsSeparator(props) {
|
|
47
|
+
var _a;
|
|
47
48
|
const { formatProps, onChange } = props;
|
|
48
49
|
const handleSetFormatProps = React.useCallback((newProps) => {
|
|
49
50
|
onChange && onChange(newProps);
|
|
@@ -104,7 +105,7 @@ function ThousandsSeparator(props) {
|
|
|
104
105
|
React.createElement("span", { className: "uicore-label" }, useThousandSeparatorLabel.current),
|
|
105
106
|
React.createElement(itwinui_react_1.Checkbox, { "data-testid": "use-thousands-separator", checked: isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleUseThousandsSeparatorChange }),
|
|
106
107
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator) && "uicore-disabled") }, thousandSeparatorLabel.current),
|
|
107
|
-
React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator: formatProps.thousandSeparator
|
|
108
|
+
React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator: (_a = formatProps.thousandSeparator) !== null && _a !== void 0 ? _a : ",", disabled: !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleThousandSeparatorChange })));
|
|
108
109
|
}
|
|
109
110
|
exports.ThousandsSeparator = ThousandsSeparator;
|
|
110
111
|
//# sourceMappingURL=ThousandsSeparator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAG/B,wDAA4E;AAC5E,wDAAgD;AAChD,2DAAwD;AACxD,iEAA8D;AAU9D;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAA8B
|
|
1
|
+
{"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAG/B,wDAA4E;AAC5E,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,CAC5C,CAAC,QAAqB,EAAE,EAAE;QACxB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,KAAmB,EAAE,SAAkB,EAAE,EAAE;QAC1C,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,YAAY,GAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE;YACb,gBAAgB;YAChB,uBAAuB;YACvB,IAAI,WAAW,CAAC,YAAY,EAAE;gBAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC;oBACpD,CAAC,CAAC,WAAW,CAAC,YAAY;oBAC1B,CAAC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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 classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { Format, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { ThousandsSelector } from \"./ThousandsSelector\";\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\n\n/** Properties of [[ThousandsSeparator]] component.\n * @internal\n */\nexport interface ThousandsSeparatorProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSeparator(props: ThousandsSeparatorProps) {\n const { formatProps, onChange } = props;\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n onChange && onChange(newProps);\n },\n [onChange]\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 // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = [...traits, traitStr];\n }\n } else {\n // clearing trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUseThousandsSeparatorChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.Use1000Separator, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleThousandSeparatorChange = React.useCallback(\n (thousandSeparator: string) => {\n let decimalSeparator = formatProps.decimalSeparator;\n // make sure 1000 and decimal separator do not match\n // istanbul ignore else\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n if (thousandSeparator === \".\") decimalSeparator = \",\";\n // thousandSeparator === \",\"\n else decimalSeparator = \".\";\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n const useThousandSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\n \"QuantityFormat.labels.useThousandSeparatorLabel\"\n )\n );\n const thousandSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.thousandSeparatorLabel\")\n );\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {useThousandSeparatorLabel.current}\n </span>\n <Checkbox\n data-testid=\"use-thousands-separator\"\n checked={isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleUseThousandsSeparatorChange}\n />\n <span\n className={classnames(\n \"uicore-label\",\n !isFormatTraitSet(FormatTraits.Use1000Separator) && \"uicore-disabled\"\n )}\n >\n {thousandSeparatorLabel.current}\n </span>\n <ThousandsSelector\n data-testid=\"thousands-separator-selector\"\n separator={formatProps.thousandSeparator ?? \",\"}\n disabled={!isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleThousandSeparatorChange}\n />\n </>\n );\n}\n"]}
|
|
@@ -142,14 +142,14 @@ class TimelineComponent extends React.Component {
|
|
|
142
142
|
};
|
|
143
143
|
// set the current duration, which will call the OnChange callback
|
|
144
144
|
this._setDuration = (currentDuration, updatedTotal) => {
|
|
145
|
-
const actualDuration = Math.min(updatedTotal
|
|
145
|
+
const actualDuration = Math.min(updatedTotal !== null && updatedTotal !== void 0 ? updatedTotal : this.state.totalDuration, Math.max(currentDuration, 0));
|
|
146
146
|
this._timeLastCycle = new Date().getTime();
|
|
147
147
|
// istanbul ignore else
|
|
148
148
|
if (!this._unmounted)
|
|
149
149
|
this.setState({ currentDuration: actualDuration });
|
|
150
150
|
// istanbul ignore else
|
|
151
151
|
if (this.props.onChange) {
|
|
152
|
-
const fraction = actualDuration / (updatedTotal
|
|
152
|
+
const fraction = actualDuration / (updatedTotal !== null && updatedTotal !== void 0 ? updatedTotal : this.state.totalDuration);
|
|
153
153
|
this.props.onChange(fraction);
|
|
154
154
|
}
|
|
155
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,0DAAgD;AAEhD,8DAIiC;AACjC,kDAAyC;AACzC,oEAMoC;AACpC,wDAA2E;AAC3E,4DAAoC;AACpC,6CAA+B;AAE/B,8DAA2D;AAC3D,6CAA0C;AAE1C,6CAAuD;AACvD,iDAA0D;AAC1D,yCAAsC;AAEtC,oCAAkC;AAElC,yBAAyB;AAEzB,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9B,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AA4F5B;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,KAAK,CAAC,SAG5C;IAqBC,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QArBP,mBAAc,GAAG,CAAC,CAAC;QACnB,kBAAa,GAAG,CAAC,CAAC;QAClB,eAAU,GAAG,KAAK,CAAC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AE,cAAc,EAAE,iBAAiB,CAAC,CACpD,CACR;oBACA,YAAY,IAAI,CACf,oBAAC,uBAAU,IACT,SAAS,EAAC,mBAAmB,EAC7B,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,IAAI,CAAC,sBAAsB,GACrC,CACH,CACG;gBACL,SAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAChC,CACF,CACP,CAAC;IACJ,CAAC;CACF;AA1jBD,8CA0jBC","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 Timeline\n */\nimport type { GenericUiEventArgs } from \"@itwin/appui-abstract\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport {\n toDateString,\n toTimeString,\n UiComponents,\n} from \"@itwin/components-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport {\n SvgCaretLeft,\n SvgCaretRight,\n SvgCheckmark,\n SvgMoreVertical,\n SvgPlayCircular,\n} from \"@itwin/itwinui-icons-react\";\nimport { DropdownMenu, MenuDivider, MenuItem } from \"@itwin/itwinui-react\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\n\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { InlineEdit } from \"./InlineEdit\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces\";\nimport { TimelinePausePlayAction } from \"./interfaces\";\nimport { PlayButton, PlayerButton } from \"./PlayerButton\";\nimport { Scrubber } from \"./Scrubber\";\n\nimport \"./TimelineComponent.scss\";\n\n// cspell:ignore millisec\n\nconst slowSpeed = 60 * 1000;\nconst mediumSpeed = 20 * 1000;\nconst fastSpeed = 10 * 1000;\n/**\n * [[TimelineMenuItemOption]]: specifies how the app wants the timeline speeds to be installed on the TimelineComponent's ContextMenu\n * \"replace\" : use the app-supplied items in place of the standard items\n * \"append\" : add the app-supplied items following the standard items\n * \"prefix\" : add the app-supplied items before the standard items\n *\n * @public\n */\nexport type TimelineMenuItemOption = \"replace\" | \"append\" | \"prefix\";\n/**\n * [[TimelineMenuItemProps]] specifies playback speed entries in the Timeline's ContextMenu\n * @public\n */\nexport interface TimelineMenuItemProps {\n /** localized label for menu item */\n label: string;\n\n /** duration for the entire timeline to play */\n timelineDuration: number;\n}\n/** TimelineDateMarkerProps: Mark a date on the timeline with an indicator\n * @public\n */\nexport interface TimelineDateMarkerProps {\n /** Date to mark. If undefined, today's date will be used. */\n date?: Date;\n /** ReactNode to use as the marker on the timeline. If undefined, a short vertical bar will mark the date. */\n dateMarker?: React.ReactNode;\n}\n/**\n * [[TimelineComponentProps]] configure the timeline\n * @public\n */\nexport interface TimelineComponentProps {\n /** Start date: beginning of the date range of a date-based timeline. */\n startDate?: Date;\n /** End date: end of the date range of a date-based timeline. */\n endDate?: Date;\n /** Total duration: range of the timeline in milliseconds. */\n totalDuration: number;\n /** Initial value for the current duration (the location of the thumb) in milliseconds */\n initialDuration?: number;\n /** Show in minimized mode (For future use. This prop will always be treated as true.) */\n minimized?: boolean;\n /** When playing, repeat indefinitely */\n repeat?: boolean;\n /** Show duration instead of time */\n showDuration?: boolean;\n /** Callback with current duration value (as a fraction) */\n onChange?: (duration: number) => void;\n /** Callback triggered when play/pause button is pressed */\n onPlayPause?: (playing: boolean) => void;\n /** Callback triggered when backward/forward buttons are pressed */\n onJump?: (forward: boolean) => void;\n /** Callback triggered when a setting is changed */\n onSettingsChange?: (arg: PlaybackSettings) => void;\n /** Always display in miniMode with no expand menu (For future use. This prop will always be treated as true) */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append, replace)*/\n appMenuItemOption?: TimelineMenuItemOption;\n /** Display date and time offset by the number of minutes specified. When undefined - local timezone will be used */\n timeZoneOffset?: number;\n /** Display a marker on the timeline rail to indicate current date - will only work if starDate and endDate are defined */\n markDate?: TimelineDateMarkerProps;\n /** Options used to format date string. If not defined it will user browser default locale settings. */\n dateFormatOptions?: DateFormatOptions;\n /** Options used to format time string. If not defined it will user browser default locale settings. */\n timeFormatOptions?: DateFormatOptions;\n}\n/** @internal */\ninterface TimelineComponentState {\n /** True if timeline is currently playing, false if paused */\n isPlaying: boolean;\n /** Minimized mode (For future use. This will always be true) */\n minimized?: boolean;\n /** Current duration in milliseconds */\n currentDuration: number;\n /** Total duration in milliseconds */\n totalDuration: number;\n /** If true, automatically restart when the timeline is finished playing */\n repeat: boolean;\n /** If true, include the repeat option in the timeline context menu */\n includeRepeat: boolean;\n}\n\n/**\n * [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport class TimelineComponent extends React.Component<\n TimelineComponentProps,\n TimelineComponentState\n> {\n private _timeLastCycle = 0;\n private _requestFrame = 0;\n private _unmounted = false;\n private _repeatLabel: string;\n private _removeListener?: () => void;\n private _standardTimelineMenuItems: TimelineMenuItemProps[] = [\n {\n label: UiIModelComponents.translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: UiIModelComponents.translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: UiIModelComponents.translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ];\n\n constructor(props: TimelineComponentProps) {\n super(props);\n\n this.state = {\n isPlaying: false,\n minimized: true,\n currentDuration: props.initialDuration\n ? props.initialDuration\n : /* istanbul ignore next */ 0,\n totalDuration: this.props.totalDuration,\n repeat: this.props.repeat ? true : false,\n includeRepeat:\n this.props.includeRepeat || this.props.includeRepeat === undefined\n ? true\n : false,\n };\n\n this._repeatLabel = UiIModelComponents.translate(\"timeline.repeat\");\n // istanbul ignore else\n if (this.props.componentId) {\n // can't handle an event if we have no id\n this._removeListener = UiAdmin.onGenericUiEvent.addListener(\n this._handleTimelinePausePlayEvent\n );\n }\n }\n\n public override componentWillUnmount() {\n if (this._removeListener) this._removeListener();\n window.cancelAnimationFrame(this._requestFrame);\n this._unmounted = true;\n }\n\n public override shouldComponentUpdate(\n nextProps: TimelineComponentProps,\n nextState: TimelineComponentState\n ) {\n let result = false;\n\n // istanbul ignore next\n if (\n nextState !== this.state ||\n nextProps !== this.props ||\n nextProps.startDate !== this.props.startDate ||\n nextProps.endDate !== this.props.endDate ||\n nextProps.initialDuration !== this.props.initialDuration ||\n nextProps.repeat !== this.props.repeat\n )\n result = true;\n\n return result;\n }\n\n public override componentDidUpdate(prevProps: TimelineComponentProps) {\n // istanbul ignore else\n if (this.props.initialDuration !== prevProps.initialDuration) {\n this._setDuration(\n this.props.initialDuration\n ? this.props.initialDuration\n : /* istanbul ignore next */ 0,\n this.props.totalDuration !== prevProps.totalDuration\n ? this.props.totalDuration\n : undefined\n );\n }\n\n // istanbul ignore else\n if (this.props.repeat !== prevProps.repeat) {\n this._changeRepeatSetting(this.props.repeat);\n }\n\n // istanbul ignore else\n if (this.props.totalDuration !== prevProps.totalDuration) {\n this._onSetTotalDuration(this.props.totalDuration);\n }\n }\n private _handleTimelinePausePlayEvent = (args: GenericUiEventArgs): void => {\n const timelineArgs = args as TimelinePausePlayArgs;\n // istanbul ignore else\n if (\n !timelineArgs ||\n this.props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n let startPlaying: boolean;\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n startPlaying = true;\n break;\n case TimelinePausePlayAction.Pause:\n startPlaying = false;\n break;\n case TimelinePausePlayAction.Toggle:\n startPlaying = !this.state.isPlaying;\n break;\n // istanbul ignore next\n default:\n return; // throw error?\n }\n if (startPlaying) this._onPlay();\n else this._onPause();\n };\n\n // user clicked backward button\n private _onBackward = () => {\n // istanbul ignore else\n if (this.props.onJump) this.props.onJump(false);\n };\n\n // user clicked forward button\n private _onForward = () => {\n // istanbul ignore else\n if (this.props.onJump) this.props.onJump(true);\n };\n\n // user clicked play button\n private _onPlay = () => {\n // istanbul ignore if\n if (this.state.isPlaying) return;\n\n // timeline was complete, restart from the beginning\n if (this.state.currentDuration >= this.state.totalDuration) {\n this._replay();\n } else this._play();\n\n // istanbul ignore else\n if (this.props.onPlayPause) this.props.onPlayPause(true);\n };\n\n // user clicked pause button\n private _onPause = () => {\n // istanbul ignore if\n if (!this.state.isPlaying) return;\n\n // stop requesting frames\n window.cancelAnimationFrame(this._requestFrame);\n\n // stop playing\n this.setState({ isPlaying: false });\n\n // istanbul ignore else\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n };\n\n // user clicked on timeline rail or dragged scrubber handle\n private _onTimelineChange = (values: ReadonlyArray<number>) => {\n const currentDuration = values[0];\n this._setDuration(currentDuration);\n };\n\n // set the current duration, which will call the OnChange callback\n private _setDuration = (currentDuration: number, updatedTotal?: number) => {\n const actualDuration = Math.min(\n updatedTotal ?? this.state.totalDuration,\n Math.max(currentDuration, 0)\n );\n\n this._timeLastCycle = new Date().getTime();\n // istanbul ignore else\n if (!this._unmounted) this.setState({ currentDuration: actualDuration });\n // istanbul ignore else\n if (this.props.onChange) {\n const fraction =\n actualDuration / (updatedTotal ?? this.state.totalDuration);\n this.props.onChange(fraction);\n }\n };\n\n // recursively update the animation until we hit the end or the pause button is clicked\n private _updateAnimation = (_timestamp: number) => {\n // istanbul ignore else\n if (!this.state.isPlaying && !this._unmounted) {\n return;\n }\n\n // update duration\n const currentTime = new Date().getTime();\n const millisecondsElapsed = currentTime - this._timeLastCycle;\n const duration = this.state.currentDuration + millisecondsElapsed;\n this._setDuration(duration);\n\n // stop the animation!\n if (duration >= this.state.totalDuration) {\n window.cancelAnimationFrame(this._requestFrame);\n this.setState({ isPlaying: false });\n if (this.state.repeat) this._replay();\n else {\n // istanbul ignore else\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n }\n\n return;\n }\n\n // continue the animation - request the next frame\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n };\n\n private _play() {\n // start playing\n this.setState({ isPlaying: true }, () => {\n // request the next frame\n this._timeLastCycle = new Date().getTime();\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n });\n }\n\n private _replay = () => {\n // timeline was complete, restart from the beginning\n this.setState({ currentDuration: 0 }, () => this._play());\n };\n\n private _displayTime(millisec: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(millisec);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n }\n\n private _getMilliseconds(time: string) {\n // istanbul ignore else - WIP\n if (time.indexOf(\":\") !== -1) {\n return (\n (Number(time.split(\":\")[0]) * 60 + Number(time.split(\":\")[1])) * 1000\n );\n } else {\n return Number(time) * 1000;\n }\n }\n\n // user changed the total duration\n private _onTotalDurationChange = (value: string) => {\n // NOTE: we should reset the current duration to 0\n const milliseconds = this._getMilliseconds(value);\n this._onSetTotalDuration(milliseconds);\n };\n\n private _changeRepeatSetting = (newValue?: boolean) => {\n // istanbul ignore else\n if (newValue !== undefined) {\n this.setState(\n () => ({ repeat: newValue }),\n () => {\n // istanbul ignore else\n if (this.props.onSettingsChange) {\n this.props.onSettingsChange({ loop: this.state.repeat });\n }\n }\n );\n }\n };\n\n private _onRepeatChanged = () => {\n this.setState(\n (prevState) => ({ repeat: !prevState.repeat }),\n () => {\n // istanbul ignore else\n if (this.props.onSettingsChange) {\n this.props.onSettingsChange({ loop: this.state.repeat });\n }\n }\n );\n };\n\n private _currentDate = (): Date => {\n const fraction = this.state.currentDuration / this.state.totalDuration;\n if (this.props.endDate && this.props.startDate) {\n const timeElapsed =\n (this.props.endDate.getTime() - this.props.startDate.getTime()) *\n fraction;\n return new Date(this.props.startDate.getTime() + timeElapsed);\n }\n return new Date();\n };\n\n private _onSetTotalDuration = (milliseconds: number) => {\n this.setState({ totalDuration: milliseconds }, () => {\n // istanbul ignore else\n if (this.props.onSettingsChange) {\n this.props.onSettingsChange({ duration: milliseconds });\n }\n });\n };\n\n private _createMenuItemNode(\n item: TimelineMenuItemProps,\n index: number,\n currentTimelineDuration: number,\n close: () => void\n ): React.ReactElement {\n const label = item.label;\n const checked = currentTimelineDuration === item.timelineDuration;\n const icon = checked ? (\n <span className=\"icon\">\n <Icon iconSpec={<SvgCheckmark />} />{\" \"}\n </span>\n ) : (\n <span />\n );\n return (\n <MenuItem\n key={index}\n icon={icon}\n onClick={() => {\n this._onSetTotalDuration(item.timelineDuration);\n close();\n }}\n >\n {label}\n </MenuItem>\n );\n }\n\n private _renderSettings = () => {\n const createMenuItemNodes = (close: () => void): React.ReactElement[] => {\n const { totalDuration } = this.state;\n let contextMenuItems: Array<TimelineMenuItemProps> = [];\n\n if (!this.props.appMenuItems) {\n contextMenuItems = this._standardTimelineMenuItems;\n } else {\n if (this.props.appMenuItemOption === \"append\") {\n contextMenuItems = this._standardTimelineMenuItems.concat(\n this.props.appMenuItems\n );\n } else if (this.props.appMenuItemOption === \"prefix\") {\n contextMenuItems = this.props.appMenuItems.concat(\n this._standardTimelineMenuItems\n );\n } else {\n contextMenuItems = this.props.appMenuItems;\n }\n }\n\n const itemNodes: React.ReactElement[] = [];\n let keyIndex = 0;\n if (this.state.includeRepeat) {\n const checked = this.state.repeat;\n const icon = checked ? (\n <span className=\"icon\">\n <Icon iconSpec={<SvgCheckmark />} />{\" \"}\n </span>\n ) : (\n <span />\n );\n itemNodes.push(\n <MenuItem\n key={++keyIndex}\n onClick={() => {\n this._onRepeatChanged();\n close();\n }}\n icon={icon}\n >\n {this._repeatLabel}\n </MenuItem>\n );\n itemNodes.push(<MenuDivider key={++keyIndex} />);\n }\n\n contextMenuItems.forEach((item: TimelineMenuItemProps, index: number) => {\n itemNodes.push(\n this._createMenuItemNode(\n item,\n index + keyIndex + 1,\n totalDuration,\n close\n )\n );\n });\n\n return itemNodes;\n };\n\n return (\n <DropdownMenu\n menuItems={createMenuItemNodes}\n placement=\"top-start\"\n popperOptions={{\n modifiers: [\n {\n name: \"hide\", // When the timeline is no longer visible, hide the popper.\n },\n {\n name: \"preventOverflow\",\n options: {\n altAxis: true, // Allow the popper to go below the reference element and use as much space as needed.\n },\n },\n {\n name: \"computeStyles\",\n options: {\n roundOffsets: ({ x, y }: { x: number; y: number }) => ({\n x,\n y: Math.max(y, 0), // Ensure that the top of the popper will not go over the top of the document.\n }),\n },\n },\n {\n name: \"setPopperClass\", // Ensure we target only THIS popper with a class\n enabled: true,\n phase: \"beforeWrite\",\n fn({ state }) {\n state.attributes.popper.class =\n \"timeline-component-max-sized-scrolling-menu\";\n },\n },\n ],\n }}\n >\n <span\n data-testid=\"timeline-settings\"\n className=\"timeline-settings icon\"\n role=\"button\"\n tabIndex={-1}\n title={UiComponents.translate(\"button.label.settings\")}\n >\n <Icon iconSpec={<SvgMoreVertical />} />\n </span>\n </DropdownMenu>\n );\n };\n\n public override render() {\n const {\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n } = this.props;\n const { currentDuration, totalDuration, minimized } = this.state;\n const currentDate = this._currentDate();\n const durationString = this._displayTime(currentDuration);\n const totalDurationString = this._displayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n\n return (\n <div\n data-testid=\"timeline-component\"\n className={classnames(\n \"timeline-component\",\n !!minimized && \"minimized\",\n hasDates && \"has-dates\"\n )}\n >\n <div className=\"header\">\n <PlayButton\n className=\"play-button\"\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n data-testid=\"timeline-play\"\n />\n <PlayerButton\n className=\"play-backward\"\n icon={<SvgCaretLeft />}\n onClick={this._onBackward}\n title={UiIModelComponents.translate(\"timeline.backward\")}\n />\n <PlayerButton\n className=\"play-button-step\"\n icon={<SvgPlayCircular />}\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n title={UiIModelComponents.translate(\"timeline.step\")}\n />\n <PlayerButton\n className=\"play-forward\"\n icon={<SvgCaretRight />}\n onClick={this._onForward}\n title={UiIModelComponents.translate(\"timeline.backward\")}\n />\n <span className=\"current-date\">\n {toDateString(currentDate, timeZoneOffset, dateFormatOptions)}\n </span>\n </div>\n <div className=\"scrubber\">\n <PlayButton\n className=\"play-button\"\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n />\n <div className=\"start-time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"start-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"start-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"duration-start-time\">{durationString}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={this.state.currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={this.state.isPlaying}\n inMiniMode={!!minimized}\n showTime={!showDuration}\n onChange={this._onTimelineChange}\n onUpdate={this._onTimelineChange}\n timeZoneOffset={this.props.timeZoneOffset}\n markDate={this.props.markDate}\n />\n <div className=\"end-time-container\">\n {hasDates && (\n <span className=\"end-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"end-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"duration-end-time\"\n defaultValue={totalDurationString}\n onChange={this._onTotalDurationChange}\n />\n )}\n </div>\n {minimized && this._renderSettings()}\n </div>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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AAC,eAAe,EAC3C,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,UAAU,EAAE,CAAC,CAAC,SAAS,EACvB,QAAQ,EAAE,CAAC,YAAY,EACvB,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAChC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAChC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EACzC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAC7B;gBACF,6BAAK,SAAS,EAAC,oBAAoB;oBAChC,QAAQ,IAAI,CACX,8BAAM,SAAS,EAAC,UAAU,IACvB,IAAA,+BAAY,EAAC,OAAO,EAAE,cAAc,CAAC,CACjC,CACR;oBACA,QAAQ,IAAI,CAAC,YAAY,IAAI,CAC5B,8BAAM,SAAS,EAAC,UAAU,IACvB,IAAA,+BAAY,EAAC,OAAO,EAAE,cAAc,EAAE,iBAAiB,CAAC,CACpD,CACR;oBACA,YAAY,IAAI,CACf,oBAAC,uBAAU,IACT,SAAS,EAAC,mBAAmB,EAC7B,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,IAAI,CAAC,sBAAsB,GACrC,CACH,CACG;gBACL,SAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAChC,CACF,CACP,CAAC;IACJ,CAAC;CACF;AA1jBD,8CA0jBC","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 Timeline\n */\nimport type { GenericUiEventArgs } from \"@itwin/appui-abstract\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport {\n toDateString,\n toTimeString,\n UiComponents,\n} from \"@itwin/components-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport {\n SvgCaretLeft,\n SvgCaretRight,\n SvgCheckmark,\n SvgMoreVertical,\n SvgPlayCircular,\n} from \"@itwin/itwinui-icons-react\";\nimport { DropdownMenu, MenuDivider, MenuItem } from \"@itwin/itwinui-react\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\n\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { InlineEdit } from \"./InlineEdit\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces\";\nimport { TimelinePausePlayAction } from \"./interfaces\";\nimport { PlayButton, PlayerButton } from \"./PlayerButton\";\nimport { Scrubber } from \"./Scrubber\";\n\nimport \"./TimelineComponent.scss\";\n\n// cspell:ignore millisec\n\nconst slowSpeed = 60 * 1000;\nconst mediumSpeed = 20 * 1000;\nconst fastSpeed = 10 * 1000;\n/**\n * [[TimelineMenuItemOption]]: specifies how the app wants the timeline speeds to be installed on the TimelineComponent's ContextMenu\n * \"replace\" : use the app-supplied items in place of the standard items\n * \"append\" : add the app-supplied items following the standard items\n * \"prefix\" : add the app-supplied items before the standard items\n *\n * @public\n */\nexport type TimelineMenuItemOption = \"replace\" | \"append\" | \"prefix\";\n/**\n * [[TimelineMenuItemProps]] specifies playback speed entries in the Timeline's ContextMenu\n * @public\n */\nexport interface TimelineMenuItemProps {\n /** localized label for menu item */\n label: string;\n\n /** duration for the entire timeline to play */\n timelineDuration: number;\n}\n/** TimelineDateMarkerProps: Mark a date on the timeline with an indicator\n * @public\n */\nexport interface TimelineDateMarkerProps {\n /** Date to mark. If undefined, today's date will be used. */\n date?: Date;\n /** ReactNode to use as the marker on the timeline. If undefined, a short vertical bar will mark the date. */\n dateMarker?: React.ReactNode;\n}\n/**\n * [[TimelineComponentProps]] configure the timeline\n * @public\n */\nexport interface TimelineComponentProps {\n /** Start date: beginning of the date range of a date-based timeline. */\n startDate?: Date;\n /** End date: end of the date range of a date-based timeline. */\n endDate?: Date;\n /** Total duration: range of the timeline in milliseconds. */\n totalDuration: number;\n /** Initial value for the current duration (the location of the thumb) in milliseconds */\n initialDuration?: number;\n /** Show in minimized mode (For future use. This prop will always be treated as true.) */\n minimized?: boolean;\n /** When playing, repeat indefinitely */\n repeat?: boolean;\n /** Show duration instead of time */\n showDuration?: boolean;\n /** Callback with current duration value (as a fraction) */\n onChange?: (duration: number) => void;\n /** Callback triggered when play/pause button is pressed */\n onPlayPause?: (playing: boolean) => void;\n /** Callback triggered when backward/forward buttons are pressed */\n onJump?: (forward: boolean) => void;\n /** Callback triggered when a setting is changed */\n onSettingsChange?: (arg: PlaybackSettings) => void;\n /** Always display in miniMode with no expand menu (For future use. This prop will always be treated as true) */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append, replace)*/\n appMenuItemOption?: TimelineMenuItemOption;\n /** Display date and time offset by the number of minutes specified. When undefined - local timezone will be used */\n timeZoneOffset?: number;\n /** Display a marker on the timeline rail to indicate current date - will only work if starDate and endDate are defined */\n markDate?: TimelineDateMarkerProps;\n /** Options used to format date string. If not defined it will user browser default locale settings. */\n dateFormatOptions?: DateFormatOptions;\n /** Options used to format time string. If not defined it will user browser default locale settings. */\n timeFormatOptions?: DateFormatOptions;\n}\n/** @internal */\ninterface TimelineComponentState {\n /** True if timeline is currently playing, false if paused */\n isPlaying: boolean;\n /** Minimized mode (For future use. This will always be true) */\n minimized?: boolean;\n /** Current duration in milliseconds */\n currentDuration: number;\n /** Total duration in milliseconds */\n totalDuration: number;\n /** If true, automatically restart when the timeline is finished playing */\n repeat: boolean;\n /** If true, include the repeat option in the timeline context menu */\n includeRepeat: boolean;\n}\n\n/**\n * [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport class TimelineComponent extends React.Component<\n TimelineComponentProps,\n TimelineComponentState\n> {\n private _timeLastCycle = 0;\n private _requestFrame = 0;\n private _unmounted = false;\n private _repeatLabel: string;\n private _removeListener?: () => void;\n private _standardTimelineMenuItems: TimelineMenuItemProps[] = [\n {\n label: UiIModelComponents.translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: UiIModelComponents.translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: UiIModelComponents.translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ];\n\n constructor(props: TimelineComponentProps) {\n super(props);\n\n this.state = {\n isPlaying: false,\n minimized: true,\n currentDuration: props.initialDuration\n ? props.initialDuration\n : /* istanbul ignore next */ 0,\n totalDuration: this.props.totalDuration,\n repeat: this.props.repeat ? true : false,\n includeRepeat:\n this.props.includeRepeat || this.props.includeRepeat === undefined\n ? true\n : false,\n };\n\n this._repeatLabel = UiIModelComponents.translate(\"timeline.repeat\");\n // istanbul ignore else\n if (this.props.componentId) {\n // can't handle an event if we have no id\n this._removeListener = UiAdmin.onGenericUiEvent.addListener(\n this._handleTimelinePausePlayEvent\n );\n }\n }\n\n public override componentWillUnmount() {\n if (this._removeListener) this._removeListener();\n window.cancelAnimationFrame(this._requestFrame);\n this._unmounted = true;\n }\n\n public override shouldComponentUpdate(\n nextProps: TimelineComponentProps,\n nextState: TimelineComponentState\n ) {\n let result = false;\n\n // istanbul ignore next\n if (\n nextState !== this.state ||\n nextProps !== this.props ||\n nextProps.startDate !== this.props.startDate ||\n nextProps.endDate !== this.props.endDate ||\n nextProps.initialDuration !== this.props.initialDuration ||\n nextProps.repeat !== this.props.repeat\n )\n result = true;\n\n return result;\n }\n\n public override componentDidUpdate(prevProps: TimelineComponentProps) {\n // istanbul ignore else\n if (this.props.initialDuration !== prevProps.initialDuration) {\n this._setDuration(\n this.props.initialDuration\n ? this.props.initialDuration\n : /* istanbul ignore next */ 0,\n this.props.totalDuration !== prevProps.totalDuration\n ? this.props.totalDuration\n : undefined\n );\n }\n\n // istanbul ignore else\n if (this.props.repeat !== prevProps.repeat) {\n this._changeRepeatSetting(this.props.repeat);\n }\n\n // istanbul ignore else\n if (this.props.totalDuration !== prevProps.totalDuration) {\n this._onSetTotalDuration(this.props.totalDuration);\n }\n }\n private _handleTimelinePausePlayEvent = (args: GenericUiEventArgs): void => {\n const timelineArgs = args as TimelinePausePlayArgs;\n // istanbul ignore else\n if (\n !timelineArgs ||\n this.props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n let startPlaying: boolean;\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n startPlaying = true;\n break;\n case TimelinePausePlayAction.Pause:\n startPlaying = false;\n break;\n case TimelinePausePlayAction.Toggle:\n startPlaying = !this.state.isPlaying;\n break;\n // istanbul ignore next\n default:\n return; // throw error?\n }\n if (startPlaying) this._onPlay();\n else this._onPause();\n };\n\n // user clicked backward button\n private _onBackward = () => {\n // istanbul ignore else\n if (this.props.onJump) this.props.onJump(false);\n };\n\n // user clicked forward button\n private _onForward = () => {\n // istanbul ignore else\n if (this.props.onJump) this.props.onJump(true);\n };\n\n // user clicked play button\n private _onPlay = () => {\n // istanbul ignore if\n if (this.state.isPlaying) return;\n\n // timeline was complete, restart from the beginning\n if (this.state.currentDuration >= this.state.totalDuration) {\n this._replay();\n } else this._play();\n\n // istanbul ignore else\n if (this.props.onPlayPause) this.props.onPlayPause(true);\n };\n\n // user clicked pause button\n private _onPause = () => {\n // istanbul ignore if\n if (!this.state.isPlaying) return;\n\n // stop requesting frames\n window.cancelAnimationFrame(this._requestFrame);\n\n // stop playing\n this.setState({ isPlaying: false });\n\n // istanbul ignore else\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n };\n\n // user clicked on timeline rail or dragged scrubber handle\n private _onTimelineChange = (values: ReadonlyArray<number>) => {\n const currentDuration = values[0];\n this._setDuration(currentDuration);\n };\n\n // set the current duration, which will call the OnChange callback\n private _setDuration = (currentDuration: number, updatedTotal?: number) => {\n const actualDuration = Math.min(\n updatedTotal ?? this.state.totalDuration,\n Math.max(currentDuration, 0)\n );\n\n this._timeLastCycle = new Date().getTime();\n // istanbul ignore else\n if (!this._unmounted) this.setState({ currentDuration: actualDuration });\n // istanbul ignore else\n if (this.props.onChange) {\n const fraction =\n actualDuration / (updatedTotal ?? this.state.totalDuration);\n this.props.onChange(fraction);\n }\n };\n\n // recursively update the animation until we hit the end or the pause button is clicked\n private _updateAnimation = (_timestamp: number) => {\n // istanbul ignore else\n if (!this.state.isPlaying && !this._unmounted) {\n return;\n }\n\n // update duration\n const currentTime = new Date().getTime();\n const millisecondsElapsed = currentTime - this._timeLastCycle;\n const duration = this.state.currentDuration + millisecondsElapsed;\n this._setDuration(duration);\n\n // stop the animation!\n if (duration >= this.state.totalDuration) {\n window.cancelAnimationFrame(this._requestFrame);\n this.setState({ isPlaying: false });\n if (this.state.repeat) this._replay();\n else {\n // istanbul ignore else\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n }\n\n return;\n }\n\n // continue the animation - request the next frame\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n };\n\n private _play() {\n // start playing\n this.setState({ isPlaying: true }, () => {\n // request the next frame\n this._timeLastCycle = new Date().getTime();\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n });\n }\n\n private _replay = () => {\n // timeline was complete, restart from the beginning\n this.setState({ currentDuration: 0 }, () => this._play());\n };\n\n private _displayTime(millisec: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(millisec);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n }\n\n private _getMilliseconds(time: string) {\n // istanbul ignore else - WIP\n if (time.indexOf(\":\") !== -1) {\n return (\n (Number(time.split(\":\")[0]) * 60 + Number(time.split(\":\")[1])) * 1000\n );\n } else {\n return Number(time) * 1000;\n }\n }\n\n // user changed the total duration\n private _onTotalDurationChange = (value: string) => {\n // NOTE: we should reset the current duration to 0\n const milliseconds = this._getMilliseconds(value);\n this._onSetTotalDuration(milliseconds);\n };\n\n private _changeRepeatSetting = (newValue?: boolean) => {\n // istanbul ignore else\n if (newValue !== undefined) {\n this.setState(\n () => ({ repeat: newValue }),\n () => {\n // istanbul ignore else\n if (this.props.onSettingsChange) {\n this.props.onSettingsChange({ loop: this.state.repeat });\n }\n }\n );\n }\n };\n\n private _onRepeatChanged = () => {\n this.setState(\n (prevState) => ({ repeat: !prevState.repeat }),\n () => {\n // istanbul ignore else\n if (this.props.onSettingsChange) {\n this.props.onSettingsChange({ loop: this.state.repeat });\n }\n }\n );\n };\n\n private _currentDate = (): Date => {\n const fraction = this.state.currentDuration / this.state.totalDuration;\n if (this.props.endDate && this.props.startDate) {\n const timeElapsed =\n (this.props.endDate.getTime() - this.props.startDate.getTime()) *\n fraction;\n return new Date(this.props.startDate.getTime() + timeElapsed);\n }\n return new Date();\n };\n\n private _onSetTotalDuration = (milliseconds: number) => {\n this.setState({ totalDuration: milliseconds }, () => {\n // istanbul ignore else\n if (this.props.onSettingsChange) {\n this.props.onSettingsChange({ duration: milliseconds });\n }\n });\n };\n\n private _createMenuItemNode(\n item: TimelineMenuItemProps,\n index: number,\n currentTimelineDuration: number,\n close: () => void\n ): React.ReactElement {\n const label = item.label;\n const checked = currentTimelineDuration === item.timelineDuration;\n const icon = checked ? (\n <span className=\"icon\">\n <Icon iconSpec={<SvgCheckmark />} />{\" \"}\n </span>\n ) : (\n <span />\n );\n return (\n <MenuItem\n key={index}\n icon={icon}\n onClick={() => {\n this._onSetTotalDuration(item.timelineDuration);\n close();\n }}\n >\n {label}\n </MenuItem>\n );\n }\n\n private _renderSettings = () => {\n const createMenuItemNodes = (close: () => void): React.ReactElement[] => {\n const { totalDuration } = this.state;\n let contextMenuItems: Array<TimelineMenuItemProps> = [];\n\n if (!this.props.appMenuItems) {\n contextMenuItems = this._standardTimelineMenuItems;\n } else {\n if (this.props.appMenuItemOption === \"append\") {\n contextMenuItems = this._standardTimelineMenuItems.concat(\n this.props.appMenuItems\n );\n } else if (this.props.appMenuItemOption === \"prefix\") {\n contextMenuItems = this.props.appMenuItems.concat(\n this._standardTimelineMenuItems\n );\n } else {\n contextMenuItems = this.props.appMenuItems;\n }\n }\n\n const itemNodes: React.ReactElement[] = [];\n let keyIndex = 0;\n if (this.state.includeRepeat) {\n const checked = this.state.repeat;\n const icon = checked ? (\n <span className=\"icon\">\n <Icon iconSpec={<SvgCheckmark />} />{\" \"}\n </span>\n ) : (\n <span />\n );\n itemNodes.push(\n <MenuItem\n key={++keyIndex}\n onClick={() => {\n this._onRepeatChanged();\n close();\n }}\n icon={icon}\n >\n {this._repeatLabel}\n </MenuItem>\n );\n itemNodes.push(<MenuDivider key={++keyIndex} />);\n }\n\n contextMenuItems.forEach((item: TimelineMenuItemProps, index: number) => {\n itemNodes.push(\n this._createMenuItemNode(\n item,\n index + keyIndex + 1,\n totalDuration,\n close\n )\n );\n });\n\n return itemNodes;\n };\n\n return (\n <DropdownMenu\n menuItems={createMenuItemNodes}\n placement=\"top-start\"\n popperOptions={{\n modifiers: [\n {\n name: \"hide\", // When the timeline is no longer visible, hide the popper.\n },\n {\n name: \"preventOverflow\",\n options: {\n altAxis: true, // Allow the popper to go below the reference element and use as much space as needed.\n },\n },\n {\n name: \"computeStyles\",\n options: {\n roundOffsets: ({ x, y }: { x: number; y: number }) => ({\n x,\n y: Math.max(y, 0), // Ensure that the top of the popper will not go over the top of the document.\n }),\n },\n },\n {\n name: \"setPopperClass\", // Ensure we target only THIS popper with a class\n enabled: true,\n phase: \"beforeWrite\",\n fn({ state }) {\n state.attributes.popper.class =\n \"timeline-component-max-sized-scrolling-menu\";\n },\n },\n ],\n }}\n >\n <span\n data-testid=\"timeline-settings\"\n className=\"timeline-settings icon\"\n role=\"button\"\n tabIndex={-1}\n title={UiComponents.translate(\"button.label.settings\")}\n >\n <Icon iconSpec={<SvgMoreVertical />} />\n </span>\n </DropdownMenu>\n );\n };\n\n public override render() {\n const {\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n } = this.props;\n const { currentDuration, totalDuration, minimized } = this.state;\n const currentDate = this._currentDate();\n const durationString = this._displayTime(currentDuration);\n const totalDurationString = this._displayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n\n return (\n <div\n data-testid=\"timeline-component\"\n className={classnames(\n \"timeline-component\",\n !!minimized && \"minimized\",\n hasDates && \"has-dates\"\n )}\n >\n <div className=\"header\">\n <PlayButton\n className=\"play-button\"\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n data-testid=\"timeline-play\"\n />\n <PlayerButton\n className=\"play-backward\"\n icon={<SvgCaretLeft />}\n onClick={this._onBackward}\n title={UiIModelComponents.translate(\"timeline.backward\")}\n />\n <PlayerButton\n className=\"play-button-step\"\n icon={<SvgPlayCircular />}\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n title={UiIModelComponents.translate(\"timeline.step\")}\n />\n <PlayerButton\n className=\"play-forward\"\n icon={<SvgCaretRight />}\n onClick={this._onForward}\n title={UiIModelComponents.translate(\"timeline.backward\")}\n />\n <span className=\"current-date\">\n {toDateString(currentDate, timeZoneOffset, dateFormatOptions)}\n </span>\n </div>\n <div className=\"scrubber\">\n <PlayButton\n className=\"play-button\"\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n />\n <div className=\"start-time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"start-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"start-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"duration-start-time\">{durationString}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={this.state.currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={this.state.isPlaying}\n inMiniMode={!!minimized}\n showTime={!showDuration}\n onChange={this._onTimelineChange}\n onUpdate={this._onTimelineChange}\n timeZoneOffset={this.props.timeZoneOffset}\n markDate={this.props.markDate}\n />\n <div className=\"end-time-container\">\n {hasDates && (\n <span className=\"end-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"end-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"duration-end-time\"\n defaultValue={totalDurationString}\n onChange={this._onTotalDurationChange}\n />\n )}\n </div>\n {minimized && this._renderSettings()}\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -44,7 +44,7 @@ const ViewportComponentEvents_1 = require("./ViewportComponentEvents");
|
|
|
44
44
|
function ViewportComponent(props) {
|
|
45
45
|
const { viewState, imodel, viewDefinitionId, getViewOverlay, viewManagerOverride, tentativePointOverride, onContextMenu, style, className, screenViewportOverride, controlId, viewportRef, } = props;
|
|
46
46
|
// istanbul ignore next
|
|
47
|
-
const viewManagerRef = React.useRef(viewManagerOverride
|
|
47
|
+
const viewManagerRef = React.useRef(viewManagerOverride !== null && viewManagerOverride !== void 0 ? viewManagerOverride : core_frontend_1.IModelApp.viewManager);
|
|
48
48
|
const tentativePointOverrideRef = React.useRef(tentativePointOverride);
|
|
49
49
|
const screenViewportCreated = React.useRef(false);
|
|
50
50
|
const viewportDiv = React.useRef(null);
|
|
@@ -102,9 +102,10 @@ function ViewportComponent(props) {
|
|
|
102
102
|
};
|
|
103
103
|
const targetPoint = React.useRef(null);
|
|
104
104
|
const getRotatePoint = (vp) => {
|
|
105
|
+
var _a, _b;
|
|
105
106
|
const lastTargetPoint = targetPoint.current;
|
|
106
107
|
// istanbul ignore next
|
|
107
|
-
const tentativePoint = tentativePointOverrideRef.current
|
|
108
|
+
const tentativePoint = (_a = tentativePointOverrideRef.current) !== null && _a !== void 0 ? _a : core_frontend_1.IModelApp.tentativePoint;
|
|
108
109
|
// istanbul ignore else
|
|
109
110
|
if (tentativePoint.isActive)
|
|
110
111
|
return tentativePoint.getPoint();
|
|
@@ -122,7 +123,7 @@ function ViewportComponent(props) {
|
|
|
122
123
|
targetPoint.current =
|
|
123
124
|
undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();
|
|
124
125
|
// istanbul ignore next
|
|
125
|
-
return targetPoint.current
|
|
126
|
+
return (_b = targetPoint.current) !== null && _b !== void 0 ? _b : vp.view.getCenter();
|
|
126
127
|
};
|
|
127
128
|
const handleCubeRotationChangeEvent = (args) => {
|
|
128
129
|
const viewManager = viewManagerRef.current;
|
|
@@ -226,8 +227,8 @@ function ViewportComponent(props) {
|
|
|
226
227
|
}
|
|
227
228
|
// istanbul ignore next
|
|
228
229
|
if (isMounted.current &&
|
|
229
|
-
(currentViewState
|
|
230
|
-
setInitialViewState(currentViewState
|
|
230
|
+
((currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.iModel.isOpen) || (currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.iModel.isBlank))) {
|
|
231
|
+
setInitialViewState(currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.clone());
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
if (undefined === initialViewState)
|
|
@@ -236,12 +237,13 @@ function ViewportComponent(props) {
|
|
|
236
237
|
const [viewOverlay, setViewOverlay] = React.useState(null);
|
|
237
238
|
// This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.
|
|
238
239
|
React.useEffect(() => {
|
|
240
|
+
var _a;
|
|
239
241
|
const parentDiv = viewportDiv.current;
|
|
240
242
|
const viewManager = viewManagerRef.current;
|
|
241
243
|
// istanbul ignore next
|
|
242
244
|
if (parentDiv &&
|
|
243
245
|
initialViewState &&
|
|
244
|
-
(initialViewState
|
|
246
|
+
((initialViewState === null || initialViewState === void 0 ? void 0 : initialViewState.iModel.isOpen) || (initialViewState === null || initialViewState === void 0 ? void 0 : initialViewState.iModel.isBlank))) {
|
|
245
247
|
if (!screenViewportCreated.current) {
|
|
246
248
|
const screenViewport = getScreenViewport(parentDiv, initialViewState);
|
|
247
249
|
screenViewportRef.current = screenViewport;
|
|
@@ -254,7 +256,7 @@ function ViewportComponent(props) {
|
|
|
254
256
|
}
|
|
255
257
|
else {
|
|
256
258
|
// istanbul ignore next
|
|
257
|
-
screenViewportRef.current
|
|
259
|
+
(_a = screenViewportRef.current) === null || _a === void 0 ? void 0 : _a.changeView(initialViewState);
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|