@itwin/imodel-components-react 4.12.0 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/lib/cjs/imodel-components-react/UiIModelComponents.js +2 -4
- 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/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.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 +7 -11
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +2 -1
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.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 +1 -2
- 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 +3 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +6 -10
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +3 -7
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +1 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/PlayButton.js +2 -2
- package/lib/cjs/imodel-components-react/timeline/PlayButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +1 -2
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +9 -10
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +12 -11
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +12 -0
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +12 -5
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/esm/imodel-components-react/UiIModelComponents.js +2 -4
- 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/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.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 +7 -11
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +2 -1
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.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 +1 -2
- 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 +3 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +6 -10
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +3 -7
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +1 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/PlayButton.js +2 -2
- package/lib/esm/imodel-components-react/timeline/PlayButton.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.js +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +1 -2
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +9 -10
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +12 -11
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +12 -0
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +12 -5
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/package.json +10 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolarTimeline.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/SolarTimeline.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gCAA8B;AAC9B,4DAAoC;AACpC,6CAA+B;AAC/B,oDAA2D;AAE3D,8DAA6E;AAC7E,wDAiB8B;AAC9B,oEAMoC;AAEpC,8DAA2D;AAC3D,6CAA0C;AAC1C,sDAAmD;AAEnD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAC9B,MAAM,SAAS,GAAG,WAAW,GAAG,EAAE,CAAC;AACnC,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C,MAAM,MAAM,GAAG,CAAC,CAAC;AAcjB,SAAS,QAAQ,CAAC,KAAoB;IACpC,MAAM,EACJ,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,GAAG,KAAK,CAAC;IAEV,MAAM,cAAc,GAAG,UAAU,CAAC,UAAU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AG;YAER,8BAAM,SAAS,EAAC,0BAA0B,IAAE,QAAQ,CAAQ,CACrD,CACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\n\nimport \"./SolarTimeline.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { adjustDateToTimezone, UiComponents } from \"@itwin/components-react\";\nimport {\n Button,\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n DatePicker,\n Flex,\n Icon,\n IconButton,\n Label,\n Popover,\n Select,\n Slider,\n Text,\n Tooltip,\n VisuallyHidden,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgCalendar,\n SvgLoop,\n SvgMoon,\n SvgSettings,\n SvgSun,\n} from \"@itwin/itwinui-icons-react\";\nimport type { SolarDataProvider } from \"./interfaces\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { PlayButton } from \"./PlayButton\";\nimport { useTranslation } from \"../useTranslation\";\n\nconst msPerMinute = 1000 * 60;\nconst msPerHour = msPerMinute * 60;\nconst defaultPlaybackDuration = 40 * 1000;\n\nconst offset = 6;\n\ninterface TimelineProps extends CommonProps {\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n currentTimeOffsetMs: number;\n isPlaying: boolean;\n formatTick?: (ms: number) => string;\n formatTime: (ms: number) => string;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n}\n\nfunction Timeline(props: TimelineProps) {\n const {\n formatTick,\n formatTime,\n onChange,\n onUpdate,\n dayStartMs,\n sunSetOffsetMs,\n sunRiseOffsetMs,\n currentTimeOffsetMs,\n } = props;\n\n const tooltipContent = formatTime(dayStartMs + currentTimeOffsetMs);\n\n const className = classnames(\n \"solar-timeline\",\n props.className,\n formatTick && \"showticks\"\n );\n const sunRiseStr = formatTime(dayStartMs + sunRiseOffsetMs);\n const sunSetStr = formatTime(dayStartMs + sunSetOffsetMs);\n return (\n <div className={className}>\n <VisuallyHidden>Solar timeline</VisuallyHidden>\n <Slider\n thumbProps={() => ({ \"aria-labelledby\": \"timeline\" })}\n step={msPerMinute}\n min={sunRiseOffsetMs}\n max={sunSetOffsetMs}\n minLabel={\n <Tooltip content={sunRiseStr}>\n <Icon>\n <SvgSun />\n </Icon>\n </Tooltip>\n }\n maxLabel={\n <Tooltip content={sunSetStr}>\n <Icon>\n <SvgMoon />\n </Icon>\n </Tooltip>\n }\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentTimeOffsetMs]}\n tooltipProps={() => ({\n content: tooltipContent,\n })}\n />\n </div>\n );\n}\n\ninterface SolarTimelineComponentProps {\n dataProvider: SolarDataProvider; // provides date, sunrise, sunset in ms, also contains timezone offset from UTC, and updates the display style to current time.\n onPlayPause?: (playing: boolean) => void; // callback triggered when play/pause button is pressed\n duration?: number; // playback duration in milliseconds\n speed?: number;\n}\n\ninterface SolarTimelineComponentState {\n isPlaying: boolean; // timeline is currently playing or paused\n isDateOpened: boolean; // date picker is opened\n isSettingsOpened: boolean; // settings popup is opened\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n sunDeltaMs: number;\n currentTimeOffsetMs: number;\n speed: number;\n loop: boolean;\n shadowColor: ColorDef;\n duration: number; // playback duration in milliseconds\n adjustedDuration: number; // playback duration in milliseconds/ speed\n}\n\n/** Solar Timeline\n * @alpha\n */\nexport class SolarTimeline extends React.PureComponent<\n SolarTimelineComponentProps,\n SolarTimelineComponentState\n> {\n private _requestFrame = 0;\n private _unmounted = false;\n private _timeLastCycle = 0;\n private _totalPlayTime = 0;\n\n private readonly _presetColors = [\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ];\n\n private readonly _speeds = [1, 2, 3, 4, 5, 6];\n\n constructor(props: SolarTimelineComponentProps) {\n super(props);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n const sunOffsetMs =\n this.props.dataProvider.timeOfDay.getTime() - dayStartMs;\n const currentTimeOffsetMs = this.ensureRange(\n sunOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n const shadowColor = this.props.dataProvider.shadowColor;\n const duration = this.props.duration\n ? this.props.duration\n : defaultPlaybackDuration;\n const speed = this.props.speed ? this.props.speed : 2;\n const adjustedDuration = duration / speed;\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs,\n adjustedDuration\n );\n\n this.state = {\n isDateOpened: false,\n isSettingsOpened: false,\n isPlaying: false,\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n sunDeltaMs,\n currentTimeOffsetMs,\n speed,\n loop: false,\n shadowColor,\n duration,\n adjustedDuration,\n };\n }\n\n public override componentWillUnmount() {\n window.cancelAnimationFrame(this._requestFrame);\n this._unmounted = true;\n }\n\n // recursively update the animation until we hit the end or the pause button is clicked\n private _updateAnimation = (_timestamp: number) => {\n if (!this.state.isPlaying || this._unmounted) {\n window.cancelAnimationFrame(this._requestFrame);\n return;\n }\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n this._timeLastCycle = currentTime;\n let percentComplete = this._totalPlayTime / this.state.adjustedDuration;\n if (percentComplete > 1) percentComplete = 1;\n\n let newPlayingState = true;\n\n // calculate the next sun time base on the percentage playback complete - should be int value as that is step amount for slider\n let nextSunOffset = Math.floor(\n this.state.sunRiseOffsetMs + percentComplete * this.state.sunDeltaMs\n );\n\n if (percentComplete > 0.99) {\n if (!this.state.loop) {\n newPlayingState = false;\n nextSunOffset = this.state.sunSetOffsetMs;\n window.cancelAnimationFrame(this._requestFrame);\n } else {\n nextSunOffset = this.state.sunRiseOffsetMs;\n this._totalPlayTime = 0;\n }\n }\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(this.state.dayStartMs + nextSunOffset);\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState(\n { isPlaying: newPlayingState, currentTimeOffsetMs: nextSunOffset },\n () => {\n if (newPlayingState)\n this._requestFrame = window.requestAnimationFrame(\n this._updateAnimation\n );\n }\n );\n };\n\n private _play(sunTimeMs: number) {\n this._timeLastCycle = new Date().getTime();\n\n // start playing\n this.setState({ isPlaying: true, currentTimeOffsetMs: sunTimeMs }, () => {\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n if (this.props.onPlayPause) this.props.onPlayPause(true);\n });\n }\n\n // user clicked pause button\n private _onPause = () => {\n if (!this.state.isPlaying) return;\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n\n // stop requesting frames\n window.cancelAnimationFrame(this._requestFrame);\n\n // stop playing\n this.setState({ isPlaying: false });\n\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n };\n\n // user clicked play button\n private _onPlay = () => {\n if (this.state.isPlaying) return;\n\n if (\n this.state.currentTimeOffsetMs >= this.state.sunSetOffsetMs ||\n this.state.currentTimeOffsetMs <= this.state.sunRiseOffsetMs\n ) {\n this._totalPlayTime = 0;\n this._play(this.state.sunRiseOffsetMs);\n } else {\n this._play(this.state.currentTimeOffsetMs);\n }\n };\n\n private setPlaybackTimeBySunTime(\n sunOffsetMs: number,\n sunRiseOffsetMs: number,\n sunDeltaMs: number,\n adjustedDuration?: number\n ) {\n this._totalPlayTime =\n ((sunOffsetMs - sunRiseOffsetMs) / sunDeltaMs) *\n (adjustedDuration ? adjustedDuration : this.state.adjustedDuration);\n }\n\n private _onDateChange = (newDate: Date) => {\n this.props.dataProvider.setDateAndTime(newDate);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n\n /** call dataProvider to update display style */\n // this.props.dataProvider.onTimeChanged?.(this.props.dataProvider.timeOfDay);\n\n // Update time\n const newHours = newDate.getHours();\n const newMinutes = newDate.getMinutes();\n const newSunTime = newHours * msPerHour + newMinutes * msPerMinute;\n const dateWithNewTime = new Date(dayStartMs + newSunTime);\n // this.props.dataProvider.setDateAndTime(dateWithNewTime, true);\n\n const currentTimeOffsetMs = this.ensureRange(\n newSunTime,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs\n );\n this._timeLastCycle = new Date().getTime();\n\n this.props.dataProvider.onTimeChanged?.(dateWithNewTime);\n this.setState({\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n currentTimeOffsetMs,\n sunDeltaMs,\n isDateOpened: false,\n });\n };\n\n private _onCloseSettingsPopup = () => {\n this.setState({ isSettingsOpened: false });\n };\n\n private _onOpenSettingsPopup = () => {\n this.setState((prevState) => ({\n isSettingsOpened: !prevState.isSettingsOpened,\n }));\n };\n\n private ensureRange(value: number, min: number, max: number): number {\n return Math.max(Math.min(value, max), min);\n }\n\n private processSunTimeChange(sunTime: number) {\n if (sunTime === this.state.currentTimeOffsetMs) return;\n\n const currentTimeOffsetMs = this.ensureRange(\n sunTime,\n this.state.sunRiseOffsetMs,\n this.state.sunSetOffsetMs\n );\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(\n this.state.dayStartMs + currentTimeOffsetMs\n );\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState({ currentTimeOffsetMs }, () => {\n const currentTime = new Date().getTime();\n this._timeLastCycle = currentTime;\n const percentComplete =\n (currentTimeOffsetMs - this.state.sunRiseOffsetMs) /\n this.state.sunDeltaMs;\n this._totalPlayTime = percentComplete * this.state.adjustedDuration;\n });\n }\n\n private _onUpdate = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onChange = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onSpeedChange = (value: number) => {\n const adjustedDuration = this.state.duration / value;\n this.setState({ speed: value, adjustedDuration });\n };\n\n private _onToggleLoop = () => {\n this.setState((prevState) => ({ loop: !prevState.loop }));\n };\n\n private _formatTime = (ms: number) => {\n const date = new Date(ms);\n const amLabel = UiComponents.translate(\"time.am\");\n const pmLabel = UiComponents.translate(\"time.pm\");\n // convert project date to browser locale date\n const localTime = adjustDateToTimezone(\n date,\n this.props.dataProvider.timeZoneOffset * 60\n );\n let hours = localTime.getHours();\n const minutes = date.getMinutes();\n const abbrev = hours < 12 ? amLabel : hours === 24 ? amLabel : pmLabel;\n hours = hours > 12 ? hours - 12 : hours;\n const hoursStr = hours.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n const minutesStr = minutes.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n return `${hoursStr}:${minutesStr} ${abbrev}`;\n };\n\n public getLocalTime(ticks: number): Date {\n const projectTime = new Date(ticks);\n // convert project date to browser locale date\n return adjustDateToTimezone(\n projectTime,\n this.props.dataProvider.timeZoneOffset * 60\n );\n }\n\n public override render() {\n const { dataProvider } = this.props;\n const {\n speed: currentSpeed,\n loop,\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n } = this.state;\n const months = [\n UiComponents.translate(\"month.short.january\"),\n UiComponents.translate(\"month.short.february\"),\n UiComponents.translate(\"month.short.march\"),\n UiComponents.translate(\"month.short.april\"),\n UiComponents.translate(\"month.short.may\"),\n UiComponents.translate(\"month.short.june\"),\n UiComponents.translate(\"month.short.july\"),\n UiComponents.translate(\"month.short.august\"),\n UiComponents.translate(\"month.short.september\"),\n UiComponents.translate(\"month.short.october\"),\n UiComponents.translate(\"month.short.november\"),\n UiComponents.translate(\"month.short.december\"),\n ];\n\n const localTime = this.getLocalTime(\n this.state.dayStartMs + this.state.currentTimeOffsetMs\n );\n const formattedTime = this._formatTime(\n dataProvider.dayStartMs + currentTimeOffsetMs\n );\n const formattedDate = `${\n months[localTime.getMonth()]\n }, ${localTime.getDate()}`;\n\n return (\n <div className=\"solar-timeline-wrapper\">\n <Flex flexWrap=\"wrap\" gap=\"none\" className=\"solar-timeline-start\">\n <PlayButton\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n />\n <Popover\n content={\n <DatePicker\n date={localTime}\n onChange={this._onDateChange}\n showTime\n use12Hours\n />\n }\n visible={this.state.isDateOpened}\n onVisibleChange={(isDateOpened) => {\n this.setState({ isDateOpened });\n }}\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <CalendarButton\n onClick={() => {\n const isDateOpened = !this.state.isDateOpened;\n this.setState({ isDateOpened });\n }}\n >\n {formattedDate} @ {formattedTime}\n </CalendarButton>\n </Popover>\n </Flex>\n\n <Timeline\n dayStartMs={dataProvider.dayStartMs}\n sunSetOffsetMs={sunSetOffsetMs}\n sunRiseOffsetMs={sunRiseOffsetMs}\n currentTimeOffsetMs={currentTimeOffsetMs}\n onChange={this._onChange}\n onUpdate={this._onUpdate}\n formatTime={this._formatTime}\n isPlaying={this.state.isPlaying}\n />\n\n <Flex\n justifyContent=\"flex-end\"\n flexWrap=\"wrap\"\n gap=\"none\"\n className=\"solar-timeline-end\"\n >\n <VisuallyHidden>\n <Label htmlFor=\"speed\">Timeline speed</Label>\n </VisuallyHidden>\n <Tooltip\n content={UiIModelComponents.translate(\"solartimeline.speed\")}\n >\n <Select\n native\n styleType=\"borderless\"\n triggerProps={{\n name: \"speed\",\n }}\n onChange={(newValue) => this._onSpeedChange(Number(newValue))}\n value={currentSpeed.toString()}\n options={this._speeds.map((speed) => ({\n value: speed.toString(),\n label: `${speed}x`,\n }))}\n />\n </Tooltip>\n\n <IconButton\n styleType=\"borderless\"\n label={UiIModelComponents.translate(\"timeline.repeat\")}\n onClick={this._onToggleLoop}\n isActive={loop}\n >\n <SvgLoop />\n </IconButton>\n\n <Popover\n content={\n <ColorPicker\n selectedColor={this.state.shadowColor.colors}\n onChangeComplete={(color) => {\n const colorDef = ColorDef.create(color.toTbgr());\n this.setState(\n { shadowColor: colorDef },\n () => (this.props.dataProvider.shadowColor = colorDef)\n );\n }}\n >\n <Text variant=\"title\" as=\"h2\" style={{ textAlign: \"center\" }}>\n {UiIModelComponents.translate(\"solarsettings.shadowcolor\")}\n </Text>\n <ColorBuilder />\n <ColorInputPanel defaultColorFormat=\"hsl\" />\n <ColorPalette\n colors={this._presetColors.map((color) => color.colors)}\n />\n </ColorPicker>\n }\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <IconButton\n styleType=\"borderless\"\n data-testid=\"shadow-settings-button\"\n label={UiIModelComponents.translate(\"solartimeline.settings\")}\n onClick={this._onOpenSettingsPopup}\n >\n <SvgSettings />\n </IconButton>\n </Popover>\n </Flex>\n </div>\n );\n }\n}\n\ninterface CalendarButtonProps {\n children?: React.ReactNode;\n onClick?: () => void;\n}\n\nconst CalendarButton = React.forwardRef<HTMLButtonElement, CalendarButtonProps>(\n function CalendarButton({ children, onClick }, ref) {\n const { translate } = useTranslation();\n const tooltip = translate(\"solartimeline.dateTime\");\n\n return (\n <Tooltip content={tooltip}>\n <Button\n styleType=\"borderless\"\n startIcon={<SvgCalendar />}\n data-testid=\"solar-date-time-button\"\n title={tooltip}\n onClick={onClick}\n ref={ref}\n >\n <span className=\"solar-timeline-date-time\">{children}</span>\n </Button>\n </Tooltip>\n );\n }\n);\n"]}
|
|
1
|
+
{"version":3,"file":"SolarTimeline.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/SolarTimeline.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gCAA8B;AAC9B,4DAAoC;AACpC,6CAA+B;AAC/B,oDAA2D;AAE3D,8DAA6E;AAC7E,wDAiB8B;AAC9B,oEAMoC;AAEpC,8DAA2D;AAC3D,6CAA0C;AAC1C,sDAAmD;AAEnD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAC9B,MAAM,SAAS,GAAG,WAAW,GAAG,EAAE,CAAC;AACnC,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C,MAAM,MAAM,GAAG,CAAC,CAAC;AAcjB,SAAS,QAAQ,CAAC,KAAoB;IACpC,MAAM,EACJ,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,GAAG,KAAK,CAAC;IAEV,MAAM,cAAc,GAAG,UAAU,CAAC,UAAU,GAAG,mBAAmB,CAAC,CAAC;IAEpE,MAAM,SAAS,GAAG,IAAA,oBAAU,EAC1B,gBAAgB,EAChB,KAAK,CAAC,SAAS,EACf,UAAU,IAAI,WAAW,CAC1B,CAAC;IACF,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,GAAG,eAAe,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC;IAC1D,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS;QACvB,oBAAC,8BAAc,yBAAgC;QAC/C,oBAAC,sBAAM,IACL,UAAU,EAAE,GAAG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,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GACvD,CACU,EAEhB,SAAS,EAAC,KAAK,EACf,UAAU,EAAE;wBACV,MAAM;qBACP;oBAED,oBAAC,0BAAU,IACT,SAAS,EAAC,YAAY,iBACV,wBAAwB,EACpC,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,wBAAwB,CAAC,EAC7D,OAAO,EAAE,IAAI,CAAC,oBAAoB;wBAElC,oBAAC,iCAAW,OAAG,CACJ,CACL,CACL,CACH,CACP,CAAC;IACJ,CAAC;CACF;AA7cD,sCA6cC;AAOD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,SAAS,cAAc,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG;IAChD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAEpD,OAAO,CACL,oBAAC,uBAAO,IAAC,OAAO,EAAE,OAAO;QACvB,oBAAC,sBAAM,IACL,SAAS,EAAC,YAAY,EACtB,SAAS,EAAE,oBAAC,iCAAW,OAAG,iBACd,wBAAwB,EACpC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG;YAER,8BAAM,SAAS,EAAC,0BAA0B,IAAE,QAAQ,CAAQ,CACrD,CACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\n\nimport \"./SolarTimeline.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { adjustDateToTimezone, UiComponents } from \"@itwin/components-react\";\nimport {\n Button,\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n DatePicker,\n Flex,\n Icon,\n IconButton,\n Label,\n Popover,\n Select,\n Slider,\n Text,\n Tooltip,\n VisuallyHidden,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgCalendar,\n SvgLoop,\n SvgMoon,\n SvgSettings,\n SvgSun,\n} from \"@itwin/itwinui-icons-react\";\nimport type { SolarDataProvider } from \"./interfaces\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { PlayButton } from \"./PlayButton\";\nimport { useTranslation } from \"../useTranslation\";\n\nconst msPerMinute = 1000 * 60;\nconst msPerHour = msPerMinute * 60;\nconst defaultPlaybackDuration = 40 * 1000;\n\nconst offset = 6;\n\ninterface TimelineProps extends CommonProps {\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n currentTimeOffsetMs: number;\n isPlaying: boolean;\n formatTick?: (ms: number) => string;\n formatTime: (ms: number) => string;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n}\n\nfunction Timeline(props: TimelineProps) {\n const {\n formatTick,\n formatTime,\n onChange,\n onUpdate,\n dayStartMs,\n sunSetOffsetMs,\n sunRiseOffsetMs,\n currentTimeOffsetMs,\n } = props;\n\n const tooltipContent = formatTime(dayStartMs + currentTimeOffsetMs);\n\n const className = classnames(\n \"solar-timeline\",\n props.className,\n formatTick && \"showticks\"\n );\n const sunRiseStr = formatTime(dayStartMs + sunRiseOffsetMs);\n const sunSetStr = formatTime(dayStartMs + sunSetOffsetMs);\n return (\n <div className={className}>\n <VisuallyHidden>Solar timeline</VisuallyHidden>\n <Slider\n thumbProps={() => ({ \"aria-labelledby\": \"timeline\" })}\n step={msPerMinute}\n min={sunRiseOffsetMs}\n max={sunSetOffsetMs}\n minLabel={\n <Tooltip content={sunRiseStr}>\n <Icon>\n <SvgSun />\n </Icon>\n </Tooltip>\n }\n maxLabel={\n <Tooltip content={sunSetStr}>\n <Icon>\n <SvgMoon />\n </Icon>\n </Tooltip>\n }\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentTimeOffsetMs]}\n tooltipProps={() => ({\n content: tooltipContent,\n })}\n />\n </div>\n );\n}\n\ninterface SolarTimelineComponentProps {\n dataProvider: SolarDataProvider; // provides date, sunrise, sunset in ms, also contains timezone offset from UTC, and updates the display style to current time.\n onPlayPause?: (playing: boolean) => void; // callback triggered when play/pause button is pressed\n duration?: number; // playback duration in milliseconds\n speed?: number;\n}\n\ninterface SolarTimelineComponentState {\n isPlaying: boolean; // timeline is currently playing or paused\n isDateOpened: boolean; // date picker is opened\n isSettingsOpened: boolean; // settings popup is opened\n dayStartMs: number;\n sunRiseOffsetMs: number;\n sunSetOffsetMs: number;\n sunDeltaMs: number;\n currentTimeOffsetMs: number;\n speed: number;\n loop: boolean;\n shadowColor: ColorDef;\n duration: number; // playback duration in milliseconds\n adjustedDuration: number; // playback duration in milliseconds/ speed\n}\n\n/** Solar Timeline\n * @alpha\n */\nexport class SolarTimeline extends React.PureComponent<\n SolarTimelineComponentProps,\n SolarTimelineComponentState\n> {\n private _requestFrame = 0;\n private _unmounted = false;\n private _timeLastCycle = 0;\n private _totalPlayTime = 0;\n\n private readonly _presetColors = [\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ];\n\n private readonly _speeds = [1, 2, 3, 4, 5, 6];\n\n constructor(props: SolarTimelineComponentProps) {\n super(props);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n const sunOffsetMs =\n this.props.dataProvider.timeOfDay.getTime() - dayStartMs;\n const currentTimeOffsetMs = this.ensureRange(\n sunOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n const shadowColor = this.props.dataProvider.shadowColor;\n const duration = this.props.duration\n ? this.props.duration\n : defaultPlaybackDuration;\n const speed = this.props.speed ? this.props.speed : 2;\n const adjustedDuration = duration / speed;\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs,\n adjustedDuration\n );\n\n this.state = {\n isDateOpened: false,\n isSettingsOpened: false,\n isPlaying: false,\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n sunDeltaMs,\n currentTimeOffsetMs,\n speed,\n loop: false,\n shadowColor,\n duration,\n adjustedDuration,\n };\n }\n\n public override componentWillUnmount() {\n window.cancelAnimationFrame(this._requestFrame);\n this._unmounted = true;\n }\n\n // recursively update the animation until we hit the end or the pause button is clicked\n private _updateAnimation = (_timestamp: number) => {\n if (!this.state.isPlaying || this._unmounted) {\n window.cancelAnimationFrame(this._requestFrame);\n return;\n }\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n this._timeLastCycle = currentTime;\n let percentComplete = this._totalPlayTime / this.state.adjustedDuration;\n if (percentComplete > 1) percentComplete = 1;\n\n let newPlayingState = true;\n\n // calculate the next sun time base on the percentage playback complete - should be int value as that is step amount for slider\n let nextSunOffset = Math.floor(\n this.state.sunRiseOffsetMs + percentComplete * this.state.sunDeltaMs\n );\n\n if (percentComplete > 0.99) {\n if (!this.state.loop) {\n newPlayingState = false;\n nextSunOffset = this.state.sunSetOffsetMs;\n window.cancelAnimationFrame(this._requestFrame);\n } else {\n nextSunOffset = this.state.sunRiseOffsetMs;\n this._totalPlayTime = 0;\n }\n }\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(this.state.dayStartMs + nextSunOffset);\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState(\n { isPlaying: newPlayingState, currentTimeOffsetMs: nextSunOffset },\n () => {\n if (newPlayingState)\n this._requestFrame = window.requestAnimationFrame(\n this._updateAnimation\n );\n }\n );\n };\n\n private _play(sunTimeMs: number) {\n this._timeLastCycle = new Date().getTime();\n\n // start playing\n this.setState({ isPlaying: true, currentTimeOffsetMs: sunTimeMs }, () => {\n this._requestFrame = window.requestAnimationFrame(this._updateAnimation);\n if (this.props.onPlayPause) this.props.onPlayPause(true);\n });\n }\n\n // user clicked pause button\n private _onPause = () => {\n if (!this.state.isPlaying) return;\n\n const currentTime = new Date().getTime();\n this._totalPlayTime += currentTime - this._timeLastCycle;\n\n // stop requesting frames\n window.cancelAnimationFrame(this._requestFrame);\n\n // stop playing\n this.setState({ isPlaying: false });\n\n if (this.props.onPlayPause) this.props.onPlayPause(false);\n };\n\n // user clicked play button\n private _onPlay = () => {\n if (this.state.isPlaying) return;\n\n if (\n this.state.currentTimeOffsetMs >= this.state.sunSetOffsetMs ||\n this.state.currentTimeOffsetMs <= this.state.sunRiseOffsetMs\n ) {\n this._totalPlayTime = 0;\n this._play(this.state.sunRiseOffsetMs);\n } else {\n this._play(this.state.currentTimeOffsetMs);\n }\n };\n\n private setPlaybackTimeBySunTime(\n sunOffsetMs: number,\n sunRiseOffsetMs: number,\n sunDeltaMs: number,\n adjustedDuration?: number\n ) {\n this._totalPlayTime =\n ((sunOffsetMs - sunRiseOffsetMs) / sunDeltaMs) *\n (adjustedDuration ? adjustedDuration : this.state.adjustedDuration);\n }\n\n private _onDateChange = (newDate: Date) => {\n this.props.dataProvider.setDateAndTime(newDate);\n\n const dayStartMs = this.props.dataProvider.dayStartMs;\n const sunRiseOffsetMs =\n this.props.dataProvider.sunrise.getTime() - dayStartMs;\n const sunSetOffsetMs =\n this.props.dataProvider.sunset.getTime() - dayStartMs;\n const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;\n\n /** call dataProvider to update display style */\n // this.props.dataProvider.onTimeChanged?.(this.props.dataProvider.timeOfDay);\n\n // Update time\n const newHours = newDate.getHours();\n const newMinutes = newDate.getMinutes();\n const newSunTime = newHours * msPerHour + newMinutes * msPerMinute;\n const dateWithNewTime = new Date(dayStartMs + newSunTime);\n // this.props.dataProvider.setDateAndTime(dateWithNewTime, true);\n\n const currentTimeOffsetMs = this.ensureRange(\n newSunTime,\n sunRiseOffsetMs,\n sunSetOffsetMs\n );\n this.setPlaybackTimeBySunTime(\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunDeltaMs\n );\n this._timeLastCycle = new Date().getTime();\n\n this.props.dataProvider.onTimeChanged?.(dateWithNewTime);\n this.setState({\n dayStartMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n currentTimeOffsetMs,\n sunDeltaMs,\n isDateOpened: false,\n });\n };\n\n private _onCloseSettingsPopup = () => {\n this.setState({ isSettingsOpened: false });\n };\n\n private _onOpenSettingsPopup = () => {\n this.setState((prevState) => ({\n isSettingsOpened: !prevState.isSettingsOpened,\n }));\n };\n\n private ensureRange(value: number, min: number, max: number): number {\n return Math.max(Math.min(value, max), min);\n }\n\n private processSunTimeChange(sunTime: number) {\n if (sunTime === this.state.currentTimeOffsetMs) return;\n\n const currentTimeOffsetMs = this.ensureRange(\n sunTime,\n this.state.sunRiseOffsetMs,\n this.state.sunSetOffsetMs\n );\n\n if (this.props.dataProvider.onTimeChanged) {\n const currentSunTime = new Date(\n this.state.dayStartMs + currentTimeOffsetMs\n );\n this.props.dataProvider.onTimeChanged(currentSunTime);\n }\n\n this.setState({ currentTimeOffsetMs }, () => {\n const currentTime = new Date().getTime();\n this._timeLastCycle = currentTime;\n const percentComplete =\n (currentTimeOffsetMs - this.state.sunRiseOffsetMs) /\n this.state.sunDeltaMs;\n this._totalPlayTime = percentComplete * this.state.adjustedDuration;\n });\n }\n\n private _onUpdate = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onChange = (values: ReadonlyArray<number>) => {\n if (!this.state.isPlaying) this.processSunTimeChange(values[0]);\n };\n\n private _onSpeedChange = (value: number) => {\n const adjustedDuration = this.state.duration / value;\n this.setState({ speed: value, adjustedDuration });\n };\n\n private _onToggleLoop = () => {\n this.setState((prevState) => ({ loop: !prevState.loop }));\n };\n\n private _formatTime = (ms: number) => {\n const date = new Date(ms);\n const amLabel = UiComponents.translate(\"time.am\");\n const pmLabel = UiComponents.translate(\"time.pm\");\n // convert project date to browser locale date\n const localTime = adjustDateToTimezone(\n date,\n this.props.dataProvider.timeZoneOffset * 60\n );\n let hours = localTime.getHours();\n const minutes = date.getMinutes();\n const abbrev = hours < 12 ? amLabel : hours === 24 ? amLabel : pmLabel;\n hours = hours > 12 ? hours - 12 : hours;\n const hoursStr = hours.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n const minutesStr = minutes.toLocaleString(undefined, {\n minimumIntegerDigits: 2,\n });\n return `${hoursStr}:${minutesStr} ${abbrev}`;\n };\n\n public getLocalTime(ticks: number): Date {\n const projectTime = new Date(ticks);\n // convert project date to browser locale date\n return adjustDateToTimezone(\n projectTime,\n this.props.dataProvider.timeZoneOffset * 60\n );\n }\n\n public override render() {\n const { dataProvider } = this.props;\n const {\n speed: currentSpeed,\n loop,\n currentTimeOffsetMs,\n sunRiseOffsetMs,\n sunSetOffsetMs,\n } = this.state;\n const months = [\n UiComponents.translate(\"month.short.january\"),\n UiComponents.translate(\"month.short.february\"),\n UiComponents.translate(\"month.short.march\"),\n UiComponents.translate(\"month.short.april\"),\n UiComponents.translate(\"month.short.may\"),\n UiComponents.translate(\"month.short.june\"),\n UiComponents.translate(\"month.short.july\"),\n UiComponents.translate(\"month.short.august\"),\n UiComponents.translate(\"month.short.september\"),\n UiComponents.translate(\"month.short.october\"),\n UiComponents.translate(\"month.short.november\"),\n UiComponents.translate(\"month.short.december\"),\n ];\n\n const localTime = this.getLocalTime(\n this.state.dayStartMs + this.state.currentTimeOffsetMs\n );\n const formattedTime = this._formatTime(\n dataProvider.dayStartMs + currentTimeOffsetMs\n );\n const formattedDate = `${\n months[localTime.getMonth()]\n }, ${localTime.getDate()}`;\n\n return (\n <div className=\"solar-timeline-wrapper\">\n <Flex flexWrap=\"wrap\" gap=\"none\" className=\"solar-timeline-start\">\n <PlayButton\n isPlaying={this.state.isPlaying}\n onPlay={this._onPlay}\n onPause={this._onPause}\n />\n <Popover\n content={\n <DatePicker\n date={localTime}\n onChange={this._onDateChange}\n showTime\n use12Hours\n />\n }\n visible={this.state.isDateOpened}\n onVisibleChange={(isDateOpened) => {\n this.setState({ isDateOpened });\n }}\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <CalendarButton\n onClick={() => {\n const isDateOpened = !this.state.isDateOpened;\n this.setState({ isDateOpened });\n }}\n >\n {formattedDate} @ {formattedTime}\n </CalendarButton>\n </Popover>\n </Flex>\n\n <Timeline\n dayStartMs={dataProvider.dayStartMs}\n sunSetOffsetMs={sunSetOffsetMs}\n sunRiseOffsetMs={sunRiseOffsetMs}\n currentTimeOffsetMs={currentTimeOffsetMs}\n onChange={this._onChange}\n onUpdate={this._onUpdate}\n formatTime={this._formatTime}\n isPlaying={this.state.isPlaying}\n />\n\n <Flex\n justifyContent=\"flex-end\"\n flexWrap=\"wrap\"\n gap=\"none\"\n className=\"solar-timeline-end\"\n >\n <VisuallyHidden>\n <Label htmlFor=\"speed\">Timeline speed</Label>\n </VisuallyHidden>\n <Tooltip\n content={UiIModelComponents.translate(\"solartimeline.speed\")}\n >\n <Select\n native\n styleType=\"borderless\"\n triggerProps={{\n name: \"speed\",\n }}\n onChange={(newValue) => this._onSpeedChange(Number(newValue))}\n value={currentSpeed.toString()}\n options={this._speeds.map((speed) => ({\n value: speed.toString(),\n label: `${speed}x`,\n }))}\n />\n </Tooltip>\n\n <IconButton\n styleType=\"borderless\"\n label={UiIModelComponents.translate(\"timeline.repeat\")}\n onClick={this._onToggleLoop}\n isActive={loop}\n >\n <SvgLoop />\n </IconButton>\n\n <Popover\n content={\n <ColorPicker\n selectedColor={this.state.shadowColor.colors}\n onChangeComplete={(color) => {\n const colorDef = ColorDef.create(color.toTbgr());\n this.setState(\n { shadowColor: colorDef },\n () => (this.props.dataProvider.shadowColor = colorDef)\n );\n }}\n >\n <Text variant=\"title\" as=\"h2\" style={{ textAlign: \"center\" }}>\n {UiIModelComponents.translate(\"solarsettings.shadowcolor\")}\n </Text>\n <ColorBuilder />\n <ColorInputPanel defaultColorFormat=\"hsl\" />\n <ColorPalette\n colors={this._presetColors.map((color) => color.colors)}\n />\n </ColorPicker>\n }\n placement=\"top\"\n middleware={{\n offset,\n }}\n >\n <IconButton\n styleType=\"borderless\"\n data-testid=\"shadow-settings-button\"\n label={UiIModelComponents.translate(\"solartimeline.settings\")}\n onClick={this._onOpenSettingsPopup}\n >\n <SvgSettings />\n </IconButton>\n </Popover>\n </Flex>\n </div>\n );\n }\n}\n\ninterface CalendarButtonProps {\n children?: React.ReactNode;\n onClick?: () => void;\n}\n\nconst CalendarButton = React.forwardRef<HTMLButtonElement, CalendarButtonProps>(\n function CalendarButton({ children, onClick }, ref) {\n const { translate } = useTranslation();\n const tooltip = translate(\"solartimeline.dateTime\");\n\n return (\n <Tooltip content={tooltip}>\n <Button\n styleType=\"borderless\"\n startIcon={<SvgCalendar />}\n data-testid=\"solar-date-time-button\"\n title={tooltip}\n onClick={onClick}\n ref={ref}\n >\n <span className=\"solar-timeline-date-time\">{children}</span>\n </Button>\n </Tooltip>\n );\n }\n);\n"]}
|
|
@@ -49,12 +49,11 @@ const fastSpeed = 10 * 1000;
|
|
|
49
49
|
* @public
|
|
50
50
|
*/
|
|
51
51
|
function TimelineComponent(props) {
|
|
52
|
-
var _a, _b, _c, _d;
|
|
53
52
|
const { appMenuItemOption = "replace", startDate, endDate, showDuration, timeZoneOffset, dateFormatOptions, timeFormatOptions, includeRepeat = true, onSettingsChange, onChange, onPlayPause, } = props;
|
|
54
53
|
const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);
|
|
55
|
-
const [currentDuration, setCurrentDuration] = React.useState(
|
|
54
|
+
const [currentDuration, setCurrentDuration] = React.useState(props.initialDuration ?? 0);
|
|
56
55
|
const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);
|
|
57
|
-
const [repeat, setRepeat] = React.useState(
|
|
56
|
+
const [repeat, setRepeat] = React.useState(props.repeat ?? false);
|
|
58
57
|
const playOrReplay = React.useCallback(() => {
|
|
59
58
|
if (isPlaying)
|
|
60
59
|
return;
|
|
@@ -62,13 +61,13 @@ function TimelineComponent(props) {
|
|
|
62
61
|
setCurrentDuration(0);
|
|
63
62
|
}
|
|
64
63
|
setIsPlaying(true);
|
|
65
|
-
onPlayPause
|
|
64
|
+
onPlayPause?.(true);
|
|
66
65
|
}, [isPlaying, onPlayPause, currentDuration, totalDuration]);
|
|
67
66
|
const pause = React.useCallback(() => {
|
|
68
67
|
if (!isPlaying)
|
|
69
68
|
return;
|
|
70
69
|
setIsPlaying(false);
|
|
71
|
-
onPlayPause
|
|
70
|
+
onPlayPause?.(false);
|
|
72
71
|
}, [isPlaying, onPlayPause]);
|
|
73
72
|
const updateTotalDuration = (newTotalDuration) => {
|
|
74
73
|
if (newTotalDuration === totalDuration)
|
|
@@ -77,7 +76,7 @@ function TimelineComponent(props) {
|
|
|
77
76
|
const newCurrentDuration = fraction * newTotalDuration;
|
|
78
77
|
setTotalDuration(newTotalDuration);
|
|
79
78
|
setCurrentDuration(newCurrentDuration);
|
|
80
|
-
onSettingsChange
|
|
79
|
+
onSettingsChange?.({ duration: newTotalDuration });
|
|
81
80
|
};
|
|
82
81
|
const updateDuration = (newDuration, currentTotalDuration = totalDuration) => {
|
|
83
82
|
newDuration = Math.max(newDuration, 0);
|
|
@@ -86,13 +85,13 @@ function TimelineComponent(props) {
|
|
|
86
85
|
return;
|
|
87
86
|
setCurrentDuration(newDuration);
|
|
88
87
|
const fraction = newDuration / currentTotalDuration;
|
|
89
|
-
onChange
|
|
88
|
+
onChange?.(fraction);
|
|
90
89
|
};
|
|
91
90
|
const updateRepeat = (newRepeat) => {
|
|
92
91
|
if (newRepeat === repeat)
|
|
93
92
|
return;
|
|
94
93
|
setRepeat(newRepeat);
|
|
95
|
-
onSettingsChange
|
|
94
|
+
onSettingsChange?.({ loop: newRepeat });
|
|
96
95
|
};
|
|
97
96
|
const [prevTotalDuration, setPrevTotalDuration] = React.useState(props.totalDuration);
|
|
98
97
|
if (prevTotalDuration !== props.totalDuration) {
|
|
@@ -102,12 +101,12 @@ function TimelineComponent(props) {
|
|
|
102
101
|
const [prevInitialDuration, setPrevInitialDuration] = React.useState(props.initialDuration);
|
|
103
102
|
if (prevInitialDuration !== props.initialDuration) {
|
|
104
103
|
setPrevInitialDuration(props.initialDuration);
|
|
105
|
-
updateDuration(
|
|
104
|
+
updateDuration(props.initialDuration ?? 0, props.totalDuration);
|
|
106
105
|
}
|
|
107
106
|
const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);
|
|
108
107
|
if (prevRepeat !== props.repeat) {
|
|
109
108
|
setPrevRepeat(props.repeat);
|
|
110
|
-
updateRepeat(
|
|
109
|
+
updateRepeat(props.repeat ?? repeat);
|
|
111
110
|
}
|
|
112
111
|
React.useEffect(() => {
|
|
113
112
|
// eslint-disable-next-line deprecation/deprecation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,oCAAkC;AAClC,6CAA+B;AAC/B,0DAAgD;AAEhD,8DAAqE;AACrE,oEAA2E;AAC3E,wDAK8B;AAC9B,6CAA0C;AAE1C,6CAAuD;AACvD,6CAA0C;AAC1C,yCAAsC;AACtC,sDAAmD;AAEnD,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MA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AO,CAAC,CAAC;QAC/C,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,WAAW,CAAC,OAAO,GAAG,SAAS,CAAC;YAChC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAC5B,OAAO,CACL,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CACtE,CAAC;KACH;SAAM;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC5B;AACH,CAAC;AAED,SAAS,aAAa,CAAC,EAAU;IAC/B,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1B,oCAAoC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACnD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\nimport \"./TimelineComponent.scss\";\nimport * as React from \"react\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport { SvgCheckmark, SvgMoreVertical } from \"@itwin/itwinui-icons-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuDivider,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport { InlineEdit } from \"./InlineEdit\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces\";\nimport { TimelinePausePlayAction } from \"./interfaces\";\nimport { PlayButton } from \"./PlayButton\";\nimport { Scrubber } from \"./Scrubber\";\nimport { useTranslation } from \"../useTranslation\";\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\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 * @note This can be changed by user interaction. See {@link TimelineComponentProps.appMenuItems}.\n */\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 * @deprecated in 4.10.x. Has no effect.\n */\n minimized?: boolean;\n /** When playing, repeat indefinitely. Defaults to `false`.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.includeRepeat}.\n */\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 * @deprecated in 4.10.x. Has no effect.\n */\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 * @deprecated in 4.10.x. Has no effect.\n */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents\n * @deprecated in 4.11.x. Use the isPlaying prop instead.\n */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu. Defaults to `true`. */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu. Defaults to `[Slow, Medium, Fast]` items. */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append or replace). Defaults to `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 /** Used to control the play/pause state of the Timeline.*/\n isPlaying?: boolean;\n}\n\n/** [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport function TimelineComponent(props: TimelineComponentProps) {\n const {\n appMenuItemOption = \"replace\",\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n includeRepeat = true,\n onSettingsChange,\n onChange,\n onPlayPause,\n } = props;\n const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);\n const [currentDuration, setCurrentDuration] = React.useState(\n props.initialDuration ?? 0\n );\n const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);\n const [repeat, setRepeat] = React.useState(props.repeat ?? false);\n\n const playOrReplay = React.useCallback(() => {\n if (isPlaying) return;\n\n if (currentDuration >= totalDuration) {\n setCurrentDuration(0);\n }\n\n setIsPlaying(true);\n onPlayPause?.(true);\n }, [isPlaying, onPlayPause, currentDuration, totalDuration]);\n const pause = React.useCallback(() => {\n if (!isPlaying) return;\n setIsPlaying(false);\n onPlayPause?.(false);\n }, [isPlaying, onPlayPause]);\n const updateTotalDuration = (newTotalDuration: number) => {\n if (newTotalDuration === totalDuration) return;\n\n const fraction = currentDuration / totalDuration;\n const newCurrentDuration = fraction * newTotalDuration;\n\n setTotalDuration(newTotalDuration);\n setCurrentDuration(newCurrentDuration);\n onSettingsChange?.({ duration: newTotalDuration });\n };\n const updateDuration = (\n newDuration: number,\n currentTotalDuration = totalDuration\n ) => {\n newDuration = Math.max(newDuration, 0);\n newDuration = Math.min(newDuration, currentTotalDuration);\n\n if (newDuration === currentDuration) return;\n setCurrentDuration(newDuration);\n\n const fraction = newDuration / currentTotalDuration;\n onChange?.(fraction);\n };\n const updateRepeat = (newRepeat: boolean) => {\n if (newRepeat === repeat) return;\n\n setRepeat(newRepeat);\n onSettingsChange?.({ loop: newRepeat });\n };\n\n const [prevTotalDuration, setPrevTotalDuration] = React.useState(\n props.totalDuration\n );\n if (prevTotalDuration !== props.totalDuration) {\n setPrevTotalDuration(props.totalDuration);\n updateTotalDuration(props.totalDuration);\n }\n\n const [prevInitialDuration, setPrevInitialDuration] = React.useState(\n props.initialDuration\n );\n if (prevInitialDuration !== props.initialDuration) {\n setPrevInitialDuration(props.initialDuration);\n updateDuration(props.initialDuration ?? 0, props.totalDuration);\n }\n\n const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);\n if (prevRepeat !== props.repeat) {\n setPrevRepeat(props.repeat);\n updateRepeat(props.repeat ?? repeat);\n }\n\n React.useEffect(() => {\n // eslint-disable-next-line deprecation/deprecation\n if (!props.componentId) return;\n return UiAdmin.onGenericUiEvent.addListener((args) => {\n const timelineArgs = args as TimelinePausePlayArgs;\n if (\n !timelineArgs ||\n // eslint-disable-next-line deprecation/deprecation\n props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n playOrReplay();\n break;\n case TimelinePausePlayAction.Pause:\n pause();\n break;\n case TimelinePausePlayAction.Toggle:\n if (isPlaying) {\n pause();\n } else {\n playOrReplay();\n }\n break;\n }\n });\n // eslint-disable-next-line deprecation/deprecation\n }, [isPlaying, pause, playOrReplay, props.componentId]);\n useAnimation(({ delta }) => {\n const duration = currentDuration + delta;\n updateDuration(duration);\n\n if (duration >= totalDuration) {\n if (repeat) {\n setCurrentDuration(0);\n return;\n }\n\n pause();\n }\n }, isPlaying);\n\n React.useEffect(() => {\n if (props.isPlaying) playOrReplay();\n\n if (props.isPlaying === false) pause();\n }, [props.isPlaying, playOrReplay, pause]);\n\n const onTimelineChange = (values: ReadonlyArray<number>) => {\n const newDuration = values[0];\n updateDuration(newDuration);\n };\n\n const currentDurationStr = toDisplayTime(currentDuration);\n const totalDurationStr = toDisplayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n return (\n <div data-testid=\"timeline-component\" className=\"timeline-component\">\n <PlayButton isPlaying={isPlaying} onPlay={playOrReplay} onPause={pause} />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"timeline-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"timeline-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"timeline-duration-time\">{currentDurationStr}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={isPlaying}\n showTime={!showDuration}\n onChange={onTimelineChange}\n onUpdate={onTimelineChange}\n timeZoneOffset={props.timeZoneOffset}\n markDate={props.markDate}\n />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-end-date\" className=\"timeline-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"timeline-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"timeline-duration-time\"\n defaultValue={totalDurationStr}\n onChange={(value) => {\n const newTotalDuration = timeToMs(value);\n updateTotalDuration(newTotalDuration);\n }}\n />\n )}\n </div>\n <SettingsMenu\n appMenuItems={props.appMenuItems}\n appMenuItemOption={appMenuItemOption}\n includeRepeat={includeRepeat}\n repeat={repeat}\n totalDuration={totalDuration}\n onRepeatClick={() => {\n updateRepeat(!repeat);\n }}\n onTotalDurationChange={(newTotalDuration) => {\n updateTotalDuration(newTotalDuration);\n }}\n />\n </div>\n );\n}\n\ntype SettingsMenuProps = Pick<\n TimelineComponentProps,\n \"appMenuItems\" | \"totalDuration\"\n> &\n Pick<\n Required<TimelineComponentProps>,\n \"appMenuItemOption\" | \"includeRepeat\" | \"repeat\"\n > & {\n onRepeatClick: () => void;\n onTotalDurationChange: (totalDuration: number) => void;\n };\n\nfunction SettingsMenu({\n appMenuItems,\n appMenuItemOption,\n includeRepeat,\n repeat,\n totalDuration,\n onRepeatClick,\n onTotalDurationChange,\n}: SettingsMenuProps) {\n const { translate } = useTranslation();\n\n const menuItems = React.useMemo(() => {\n const standardItems: TimelineMenuItemProps[] = [\n {\n label: translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ];\n\n if (!appMenuItems) {\n return standardItems;\n }\n\n if (appMenuItemOption === \"append\") {\n return [...standardItems, ...appMenuItems];\n }\n if (appMenuItemOption === \"prefix\") {\n return [...appMenuItems, ...standardItems];\n }\n // Replace\n return appMenuItems;\n }, [appMenuItemOption, appMenuItems, translate]);\n\n return (\n <DropdownMenu\n menuItems={(close) => {\n return [\n ...(includeRepeat\n ? [\n <MenuItem\n key=\"repeat\"\n onClick={() => {\n onRepeatClick();\n close();\n }}\n startIcon={repeat ? <SvgCheckmark /> : <></>}\n >\n {translate(\"timeline.repeat\")}\n </MenuItem>,\n <MenuDivider key=\"divider\" />,\n ]\n : []),\n ...menuItems.map((item, index) => {\n const checked = totalDuration === item.timelineDuration;\n return (\n <MenuItem\n key={index}\n startIcon={checked ? <SvgCheckmark /> : <></>}\n onClick={() => {\n onTotalDurationChange(item.timelineDuration);\n close();\n }}\n >\n {item.label}\n </MenuItem>\n );\n }),\n ];\n }}\n placement=\"top-start\"\n >\n <IconButton\n data-testid=\"timeline-settings\"\n label={translate(\"button.label.settings\")}\n styleType=\"borderless\"\n >\n <SvgMoreVertical />\n </IconButton>\n </DropdownMenu>\n );\n}\n\nfunction useAnimation(\n onAnimate: (args: { delta: number }) => void,\n playing = true\n) {\n const onAnimateRef = React.useRef(onAnimate);\n onAnimateRef.current = onAnimate;\n\n const lastTimeRef = React.useRef<number | undefined>();\n\n React.useEffect(() => {\n if (!playing) return;\n\n let handle = 0;\n let didCancel = false;\n\n const animate = (time: number) => {\n if (lastTimeRef.current === undefined) {\n lastTimeRef.current = time;\n }\n\n const delta = time - lastTimeRef.current;\n lastTimeRef.current = time;\n\n onAnimateRef.current({\n delta,\n });\n\n if (didCancel) return;\n\n handle = window.requestAnimationFrame(animate);\n };\n\n handle = window.requestAnimationFrame(animate);\n return () => {\n didCancel = true;\n lastTimeRef.current = undefined;\n window.cancelAnimationFrame(handle);\n };\n }, [playing]);\n}\n\nfunction timeToMs(time: string) {\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\nfunction toDisplayTime(ms: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(ms);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,oCAAkC;AAClC,6CAA+B;AAC/B,0DAAgD;AAEhD,8DAAqE;AACrE,oEAA2E;AAC3E,wDAK8B;AAC9B,6CAA0C;AAE1C,6CAAuD;AACvD,6CAA0C;AAC1C,yCAAsC;AACtC,sDAAmD;AAEnD,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9B,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AA4F5B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EACJ,iBAAiB,GAAG,SAAS,EAC7B,SAAS,EACT,OAAO,EACP,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GAAG,IAAI,EACpB,gBAAgB,EACh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C,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CACtE,CAAC;KACH;SAAM;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC5B;AACH,CAAC;AAED,SAAS,aAAa,CAAC,EAAU;IAC/B,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1B,oCAAoC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACnD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\nimport \"./TimelineComponent.scss\";\nimport * as React from \"react\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport { SvgCheckmark, SvgMoreVertical } from \"@itwin/itwinui-icons-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuDivider,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport { InlineEdit } from \"./InlineEdit\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces\";\nimport { TimelinePausePlayAction } from \"./interfaces\";\nimport { PlayButton } from \"./PlayButton\";\nimport { Scrubber } from \"./Scrubber\";\nimport { useTranslation } from \"../useTranslation\";\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\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 * @note This can be changed by user interaction. See {@link TimelineComponentProps.appMenuItems}.\n */\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 * @deprecated in 4.10.x. Has no effect.\n */\n minimized?: boolean;\n /** When playing, repeat indefinitely. Defaults to `false`.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.includeRepeat}.\n */\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 * @deprecated in 4.10.x. Has no effect.\n */\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 * @deprecated in 4.10.x. Has no effect.\n */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents\n * @deprecated in 4.11.x. Use the isPlaying prop instead.\n */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu. Defaults to `true`. */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu. Defaults to `[Slow, Medium, Fast]` items. */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append or replace). Defaults to `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 /** Used to control the play/pause state of the Timeline.*/\n isPlaying?: boolean;\n}\n\n/** [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport function TimelineComponent(props: TimelineComponentProps) {\n const {\n appMenuItemOption = \"replace\",\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n includeRepeat = true,\n onSettingsChange,\n onChange,\n onPlayPause,\n } = props;\n const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);\n const [currentDuration, setCurrentDuration] = React.useState(\n props.initialDuration ?? 0\n );\n const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);\n const [repeat, setRepeat] = React.useState(props.repeat ?? false);\n\n const playOrReplay = React.useCallback(() => {\n if (isPlaying) return;\n\n if (currentDuration >= totalDuration) {\n setCurrentDuration(0);\n }\n\n setIsPlaying(true);\n onPlayPause?.(true);\n }, [isPlaying, onPlayPause, currentDuration, totalDuration]);\n const pause = React.useCallback(() => {\n if (!isPlaying) return;\n setIsPlaying(false);\n onPlayPause?.(false);\n }, [isPlaying, onPlayPause]);\n const updateTotalDuration = (newTotalDuration: number) => {\n if (newTotalDuration === totalDuration) return;\n\n const fraction = currentDuration / totalDuration;\n const newCurrentDuration = fraction * newTotalDuration;\n\n setTotalDuration(newTotalDuration);\n setCurrentDuration(newCurrentDuration);\n onSettingsChange?.({ duration: newTotalDuration });\n };\n const updateDuration = (\n newDuration: number,\n currentTotalDuration = totalDuration\n ) => {\n newDuration = Math.max(newDuration, 0);\n newDuration = Math.min(newDuration, currentTotalDuration);\n\n if (newDuration === currentDuration) return;\n setCurrentDuration(newDuration);\n\n const fraction = newDuration / currentTotalDuration;\n onChange?.(fraction);\n };\n const updateRepeat = (newRepeat: boolean) => {\n if (newRepeat === repeat) return;\n\n setRepeat(newRepeat);\n onSettingsChange?.({ loop: newRepeat });\n };\n\n const [prevTotalDuration, setPrevTotalDuration] = React.useState(\n props.totalDuration\n );\n if (prevTotalDuration !== props.totalDuration) {\n setPrevTotalDuration(props.totalDuration);\n updateTotalDuration(props.totalDuration);\n }\n\n const [prevInitialDuration, setPrevInitialDuration] = React.useState(\n props.initialDuration\n );\n if (prevInitialDuration !== props.initialDuration) {\n setPrevInitialDuration(props.initialDuration);\n updateDuration(props.initialDuration ?? 0, props.totalDuration);\n }\n\n const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);\n if (prevRepeat !== props.repeat) {\n setPrevRepeat(props.repeat);\n updateRepeat(props.repeat ?? repeat);\n }\n\n React.useEffect(() => {\n // eslint-disable-next-line deprecation/deprecation\n if (!props.componentId) return;\n return UiAdmin.onGenericUiEvent.addListener((args) => {\n const timelineArgs = args as TimelinePausePlayArgs;\n if (\n !timelineArgs ||\n // eslint-disable-next-line deprecation/deprecation\n props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n playOrReplay();\n break;\n case TimelinePausePlayAction.Pause:\n pause();\n break;\n case TimelinePausePlayAction.Toggle:\n if (isPlaying) {\n pause();\n } else {\n playOrReplay();\n }\n break;\n }\n });\n // eslint-disable-next-line deprecation/deprecation\n }, [isPlaying, pause, playOrReplay, props.componentId]);\n useAnimation(({ delta }) => {\n const duration = currentDuration + delta;\n updateDuration(duration);\n\n if (duration >= totalDuration) {\n if (repeat) {\n setCurrentDuration(0);\n return;\n }\n\n pause();\n }\n }, isPlaying);\n\n React.useEffect(() => {\n if (props.isPlaying) playOrReplay();\n\n if (props.isPlaying === false) pause();\n }, [props.isPlaying, playOrReplay, pause]);\n\n const onTimelineChange = (values: ReadonlyArray<number>) => {\n const newDuration = values[0];\n updateDuration(newDuration);\n };\n\n const currentDurationStr = toDisplayTime(currentDuration);\n const totalDurationStr = toDisplayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n return (\n <div data-testid=\"timeline-component\" className=\"timeline-component\">\n <PlayButton isPlaying={isPlaying} onPlay={playOrReplay} onPause={pause} />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"timeline-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"timeline-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"timeline-duration-time\">{currentDurationStr}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={isPlaying}\n showTime={!showDuration}\n onChange={onTimelineChange}\n onUpdate={onTimelineChange}\n timeZoneOffset={props.timeZoneOffset}\n markDate={props.markDate}\n />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-end-date\" className=\"timeline-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"timeline-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"timeline-duration-time\"\n defaultValue={totalDurationStr}\n onChange={(value) => {\n const newTotalDuration = timeToMs(value);\n updateTotalDuration(newTotalDuration);\n }}\n />\n )}\n </div>\n <SettingsMenu\n appMenuItems={props.appMenuItems}\n appMenuItemOption={appMenuItemOption}\n includeRepeat={includeRepeat}\n repeat={repeat}\n totalDuration={totalDuration}\n onRepeatClick={() => {\n updateRepeat(!repeat);\n }}\n onTotalDurationChange={(newTotalDuration) => {\n updateTotalDuration(newTotalDuration);\n }}\n />\n </div>\n );\n}\n\ntype SettingsMenuProps = Pick<\n TimelineComponentProps,\n \"appMenuItems\" | \"totalDuration\"\n> &\n Pick<\n Required<TimelineComponentProps>,\n \"appMenuItemOption\" | \"includeRepeat\" | \"repeat\"\n > & {\n onRepeatClick: () => void;\n onTotalDurationChange: (totalDuration: number) => void;\n };\n\nfunction SettingsMenu({\n appMenuItems,\n appMenuItemOption,\n includeRepeat,\n repeat,\n totalDuration,\n onRepeatClick,\n onTotalDurationChange,\n}: SettingsMenuProps) {\n const { translate } = useTranslation();\n\n const menuItems = React.useMemo(() => {\n const standardItems: TimelineMenuItemProps[] = [\n {\n label: translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ];\n\n if (!appMenuItems) {\n return standardItems;\n }\n\n if (appMenuItemOption === \"append\") {\n return [...standardItems, ...appMenuItems];\n }\n if (appMenuItemOption === \"prefix\") {\n return [...appMenuItems, ...standardItems];\n }\n // Replace\n return appMenuItems;\n }, [appMenuItemOption, appMenuItems, translate]);\n\n return (\n <DropdownMenu\n menuItems={(close) => {\n return [\n ...(includeRepeat\n ? [\n <MenuItem\n key=\"repeat\"\n onClick={() => {\n onRepeatClick();\n close();\n }}\n startIcon={repeat ? <SvgCheckmark /> : <></>}\n >\n {translate(\"timeline.repeat\")}\n </MenuItem>,\n <MenuDivider key=\"divider\" />,\n ]\n : []),\n ...menuItems.map((item, index) => {\n const checked = totalDuration === item.timelineDuration;\n return (\n <MenuItem\n key={index}\n startIcon={checked ? <SvgCheckmark /> : <></>}\n onClick={() => {\n onTotalDurationChange(item.timelineDuration);\n close();\n }}\n >\n {item.label}\n </MenuItem>\n );\n }),\n ];\n }}\n placement=\"top-start\"\n >\n <IconButton\n data-testid=\"timeline-settings\"\n label={translate(\"button.label.settings\")}\n styleType=\"borderless\"\n >\n <SvgMoreVertical />\n </IconButton>\n </DropdownMenu>\n );\n}\n\nfunction useAnimation(\n onAnimate: (args: { delta: number }) => void,\n playing = true\n) {\n const onAnimateRef = React.useRef(onAnimate);\n onAnimateRef.current = onAnimate;\n\n const lastTimeRef = React.useRef<number | undefined>();\n\n React.useEffect(() => {\n if (!playing) return;\n\n let handle = 0;\n let didCancel = false;\n\n const animate = (time: number) => {\n if (lastTimeRef.current === undefined) {\n lastTimeRef.current = time;\n }\n\n const delta = time - lastTimeRef.current;\n lastTimeRef.current = time;\n\n onAnimateRef.current({\n delta,\n });\n\n if (didCancel) return;\n\n handle = window.requestAnimationFrame(animate);\n };\n\n handle = window.requestAnimationFrame(animate);\n return () => {\n didCancel = true;\n lastTimeRef.current = undefined;\n window.cancelAnimationFrame(handle);\n };\n }, [playing]);\n}\n\nfunction timeToMs(time: string) {\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\nfunction toDisplayTime(ms: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(ms);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportComponent.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EAEX,SAAS,EACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,cAAc,EAGf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,wBAAwB;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,wDAAwD;IACxD,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC;IACjD,gBAAgB;IAChB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/D,sCAAsC;IACtC,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,OAAO,cAAc,CAAC;IAC/C,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,cAAc,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"ViewportComponent.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EAEX,SAAS,EACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,cAAc,EAGf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,wBAAwB;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,wDAAwD;IACxD,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC;IACjD,gBAAgB;IAChB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/D,sCAAsC;IACtC,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,OAAO,cAAc,CAAC;IAC/C,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,cAAc,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,qBA4UrD"}
|
|
@@ -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 ?? 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);
|
|
@@ -79,7 +79,8 @@ function ViewportComponent(props) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
const handleStandardRotationChangeEvent = (args
|
|
82
|
+
const handleStandardRotationChangeEvent = (args // eslint-disable-line deprecation/deprecation
|
|
83
|
+
) => {
|
|
83
84
|
const viewManager = viewManagerRef.current;
|
|
84
85
|
const currentScreenViewport = screenViewportRef.current;
|
|
85
86
|
if (currentScreenViewport &&
|
|
@@ -88,7 +89,8 @@ function ViewportComponent(props) {
|
|
|
88
89
|
currentScreenViewport.synchWithView();
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
|
-
const handleDrawingViewportChangeEvent = (args
|
|
92
|
+
const handleDrawingViewportChangeEvent = (args // eslint-disable-line deprecation/deprecation
|
|
93
|
+
) => {
|
|
92
94
|
const viewManager = viewManagerRef.current;
|
|
93
95
|
const currentScreenViewport = screenViewportRef.current;
|
|
94
96
|
if (currentScreenViewport &&
|
|
@@ -102,10 +104,9 @@ function ViewportComponent(props) {
|
|
|
102
104
|
};
|
|
103
105
|
const targetPoint = React.useRef(null);
|
|
104
106
|
const getRotatePoint = (vp) => {
|
|
105
|
-
var _a, _b;
|
|
106
107
|
const lastTargetPoint = targetPoint.current;
|
|
107
108
|
// istanbul ignore next
|
|
108
|
-
const tentativePoint =
|
|
109
|
+
const tentativePoint = tentativePointOverrideRef.current ?? core_frontend_1.IModelApp.tentativePoint;
|
|
109
110
|
// istanbul ignore else
|
|
110
111
|
if (tentativePoint.isActive)
|
|
111
112
|
return tentativePoint.getPoint();
|
|
@@ -123,8 +124,9 @@ function ViewportComponent(props) {
|
|
|
123
124
|
targetPoint.current =
|
|
124
125
|
undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();
|
|
125
126
|
// istanbul ignore next
|
|
126
|
-
return
|
|
127
|
+
return targetPoint.current ?? vp.view.getCenter();
|
|
127
128
|
};
|
|
129
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
128
130
|
const handleCubeRotationChangeEvent = (args) => {
|
|
129
131
|
const viewManager = viewManagerRef.current;
|
|
130
132
|
const currentScreenViewport = screenViewportRef.current;
|
|
@@ -230,8 +232,8 @@ function ViewportComponent(props) {
|
|
|
230
232
|
}
|
|
231
233
|
// istanbul ignore next
|
|
232
234
|
if (isMounted.current &&
|
|
233
|
-
(
|
|
234
|
-
setInitialViewState(currentViewState
|
|
235
|
+
(currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)) {
|
|
236
|
+
setInitialViewState(currentViewState?.clone());
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
239
|
if (undefined === initialViewState)
|
|
@@ -240,13 +242,12 @@ function ViewportComponent(props) {
|
|
|
240
242
|
const [viewOverlay, setViewOverlay] = React.useState(null);
|
|
241
243
|
// This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.
|
|
242
244
|
React.useEffect(() => {
|
|
243
|
-
var _a;
|
|
244
245
|
const parentDiv = viewportDiv.current;
|
|
245
246
|
const viewManager = viewManagerRef.current;
|
|
246
247
|
// istanbul ignore next
|
|
247
248
|
if (parentDiv &&
|
|
248
249
|
initialViewState &&
|
|
249
|
-
(
|
|
250
|
+
(initialViewState?.iModel.isOpen || initialViewState?.iModel.isBlank)) {
|
|
250
251
|
if (!screenViewportCreated.current) {
|
|
251
252
|
const screenViewport = getScreenViewport(parentDiv, initialViewState);
|
|
252
253
|
screenViewportRef.current = screenViewport;
|
|
@@ -259,7 +260,7 @@ function ViewportComponent(props) {
|
|
|
259
260
|
}
|
|
260
261
|
else {
|
|
261
262
|
// istanbul ignore next
|
|
262
|
-
|
|
263
|
+
screenViewportRef.current?.changeView(initialViewState);
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,sDAA6C;AAE7C,wDAAiD;AACjD,oDAA+C;AAQ/C,wDAK8B;AAQ9B,uEAAoE;AAkCpE;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,KAAoB;IACpD,MAAM,EACJ,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,KAAK,EACL,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,WAAW,GACZ,GAAG,KAAK,CAAC;IACV,uBAAuB;IACvB,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CACjC,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,yBAAS,CAAC,WAAW,CAC7C,CAAC;IACF,MAAM,yBAAyB,GAAG,KAAK,CAAC,MAAM,CAAC,sBA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BAAiB,GAChC;QACD,WAAW,CACR,CACP,CAAC;AACJ,CAAC;AA3UD,8CA2UC","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 Viewport\n */\n\nimport * as React from \"react\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Point3d } from \"@itwin/core-geometry\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport { NpcCenter } from \"@itwin/core-common\";\nimport type {\n IModelConnection,\n TentativePoint,\n ViewManager,\n Viewport,\n ViewState,\n} from \"@itwin/core-frontend\";\nimport {\n IModelApp,\n ScreenViewport,\n StandardView,\n ToolSettings,\n} from \"@itwin/core-frontend\";\n\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n CubeRotationChangeEventArgs,\n DrawingViewportChangeEventArgs,\n StandardRotationChangeEventArgs,\n} from \"./ViewportComponentEvents\";\nimport { ViewportComponentEvents } from \"./ViewportComponentEvents\";\n\n/** Type for a ViewState prop\n * @public\n */\nexport type ViewStateProp = ViewState | (() => ViewState);\n\n/**\n * Properties for [[ViewportComponent]] component.\n * @public\n */\nexport interface ViewportProps extends CommonProps {\n /** IModel to display */\n imodel: IModelConnection;\n /** Id of a default view definition to load as a starting point */\n viewDefinitionId?: Id64String;\n /** ViewState to use as a starting point */\n viewState?: ViewStateProp;\n /** Function to get a reference to the ScreenViewport */\n viewportRef?: (v: ScreenViewport) => void;\n /** controlId for this content component @internal */\n controlId?: string;\n /** @internal */\n onContextMenu?: (e: React.MouseEvent) => boolean;\n /** @internal */\n getViewOverlay?: (viewport: ScreenViewport) => React.ReactNode;\n /** @internal used only for testing */\n viewManagerOverride?: ViewManager;\n /** @internal used only for testing */\n screenViewportOverride?: typeof ScreenViewport;\n /** @internal used only for testing */\n tentativePointOverride?: TentativePoint;\n}\n\n/**\n * A viewport React component that creates a ScreenViewport.\n * @public\n */\nexport function ViewportComponent(props: ViewportProps) {\n const {\n viewState,\n imodel,\n viewDefinitionId,\n getViewOverlay,\n viewManagerOverride,\n tentativePointOverride,\n onContextMenu,\n style,\n className,\n screenViewportOverride,\n controlId,\n viewportRef,\n } = props;\n // istanbul ignore next\n const viewManagerRef = React.useRef(\n viewManagerOverride ?? IModelApp.viewManager\n );\n const tentativePointOverrideRef = React.useRef(tentativePointOverride);\n const screenViewportCreated = React.useRef(false);\n const viewportDiv = React.useRef<HTMLDivElement>(null);\n const screenViewportRef = React.useRef<ScreenViewport | null>(null);\n const isMounted = React.useRef(false);\n const viewClassFullName = React.useRef(\"\");\n const viewId = React.useRef(\"0\");\n\n // istanbul ignore next\n const handleViewChanged = (vp: Viewport) => {\n // istanbul ignore next\n if (!(vp.iModel.isOpen || vp.iModel.isBlank)) return;\n ViewportComponentEvents.setViewMatrix(vp);\n if (viewClassFullName.current !== vp.view.classFullName) {\n setTimeout(() => {\n ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({\n viewport: vp,\n oldName: viewClassFullName.current,\n newName: vp.view.classFullName,\n });\n viewClassFullName.current = vp.view.classFullName;\n });\n }\n if (viewId.current !== vp.view.id) {\n setTimeout(() => {\n ViewportComponentEvents.onViewIdChangedEvent.emit({\n viewport: vp,\n oldId: viewId.current,\n newId: vp.view.id,\n });\n viewId.current = vp.view.id;\n });\n }\n };\n\n const handleStandardRotationChangeEvent = (\n args: StandardRotationChangeEventArgs\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setRotationAboutPoint(\n StandardView.getStandardRotation(args.standardRotation)\n );\n currentScreenViewport.synchWithView();\n }\n };\n\n const handleDrawingViewportChangeEvent = (\n args: DrawingViewportChangeEventArgs\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setOrigin(args.origin);\n currentScreenViewport.view.setRotation(args.rotation);\n currentScreenViewport.synchWithView({\n noSaveInUndo: args.complete !== true,\n });\n }\n };\n\n const targetPoint = React.useRef<Point3d | null>(null);\n\n const getRotatePoint = (vp: ScreenViewport): Point3d => {\n const lastTargetPoint = targetPoint.current;\n // istanbul ignore next\n const tentativePoint =\n tentativePointOverrideRef.current ?? IModelApp.tentativePoint;\n // istanbul ignore else\n if (tentativePoint.isActive) return tentativePoint.getPoint();\n\n // istanbul ignore else\n if (null !== lastTargetPoint) {\n const testPt = vp.worldToView(lastTargetPoint);\n const viewRect = vp.viewRect.clone();\n viewRect.scaleAboutCenter(0.25, 0.25);\n // istanbul ignore next hard to reach because of mocks\n if (viewRect.containsPoint(testPt)) return lastTargetPoint;\n targetPoint.current = null;\n }\n\n const visiblePoint = vp.pickNearestVisibleGeometry(\n vp.npcToWorld(NpcCenter),\n vp.pixelsFromInches(ToolSettings.viewToolPickRadiusInches)\n );\n targetPoint.current =\n undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();\n // istanbul ignore next\n return targetPoint.current ?? vp.view.getCenter();\n };\n\n const handleCubeRotationChangeEvent = (args: CubeRotationChangeEventArgs) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n // istanbul ignore else\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n const rotMatrix = args.rotMatrix;\n // istanbul ignore else\n if (currentScreenViewport.rotation !== rotMatrix) {\n const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...\n const center = getRotatePoint(currentScreenViewport);\n const targetMatrix = inverse.multiplyMatrixMatrix(\n currentScreenViewport.view.getRotation()\n );\n const worldTransform = Transform.createFixedPointAndMatrix(\n center,\n targetMatrix\n );\n const frustum = currentScreenViewport.getWorldFrustum();\n frustum.multiply(worldTransform);\n currentScreenViewport.view.setupFromFrustum(frustum);\n currentScreenViewport.synchWithView({ noSaveInUndo: !args.complete });\n }\n }\n };\n\n const handleDisconnectFromViewManager = () => {\n const screenViewport = screenViewportRef.current;\n if (screenViewport) {\n const viewManager = IModelApp.viewManager;\n screenViewport.onViewChanged.removeListener(handleViewChanged);\n screenViewportRef.current = null;\n screenViewportCreated.current = false;\n ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(\n handleStandardRotationChangeEvent\n );\n viewManager.dropViewport(screenViewport, true);\n }\n };\n\n // istanbul ignore next\n const handleWindowUnload = () => {\n const parentDiv = viewportDiv.current;\n if (parentDiv) {\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n if (parentWindow !== window) {\n handleDisconnectFromViewManager();\n }\n }\n };\n\n const getScreenViewport = (\n parentDiv: HTMLDivElement,\n inViewState: ViewState\n ) => {\n // istanbul ignore next\n const screenViewportFactory = screenViewportOverride\n ? screenViewportOverride\n : ScreenViewport;\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n parentWindow.addEventListener(\"unload\", handleWindowUnload, {\n once: true,\n capture: true,\n }); // by specifying 'once', listener clears after being called\n ViewportComponentEvents.initialize();\n ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.addListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.addListener(\n handleStandardRotationChangeEvent\n );\n const screenViewport = screenViewportFactory.create(parentDiv, inViewState);\n screenViewportCreated.current = true;\n viewClassFullName.current = screenViewport.view.classFullName;\n viewId.current = screenViewport.view.id;\n screenViewport.onViewChanged.addListener(handleViewChanged);\n return screenViewport;\n };\n\n React.useEffect(() => {\n isMounted.current = true;\n Logger.logInfo(\n \"ViewportComponent\",\n `mounting ViewportComponent for controlId=${controlId}`\n );\n\n return () => {\n isMounted.current = false;\n Logger.logInfo(\n \"ViewportComponent\",\n `un-mounting ViewportComponent for controlId=${controlId}`\n );\n handleDisconnectFromViewManager();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const [initialViewState, setInitialViewState] = React.useState<\n ViewState | undefined\n >(undefined);\n React.useEffect(() => {\n setInitialViewState(undefined);\n }, [viewDefinitionId, viewState]);\n React.useEffect(() => {\n async function fetchInitialViewstate() {\n let currentViewState: ViewState | undefined;\n if (viewState) {\n if (typeof viewState === \"function\") currentViewState = viewState();\n else currentViewState = viewState;\n } else if (viewDefinitionId && imodel) {\n try {\n currentViewState = await imodel.views.load(viewDefinitionId);\n // istanbul ignore next\n if (!currentViewState) {\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } catch (_e) {\n // istanbul ignore next\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } else {\n Logger.logError(\n \"ViewportComponent\",\n `A Viewstate or a viewId and imodel must be provided`\n );\n }\n // istanbul ignore next\n if (\n isMounted.current &&\n (currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)\n ) {\n setInitialViewState(currentViewState?.clone());\n }\n }\n if (undefined === initialViewState) void fetchInitialViewstate();\n }, [imodel, initialViewState, viewDefinitionId, viewState]);\n\n const [viewOverlay, setViewOverlay] = React.useState<React.ReactNode>(null);\n\n // This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.\n React.useEffect(() => {\n const parentDiv = viewportDiv.current;\n const viewManager = viewManagerRef.current;\n // istanbul ignore next\n if (\n parentDiv &&\n initialViewState &&\n (initialViewState?.iModel.isOpen || initialViewState?.iModel.isBlank)\n ) {\n if (!screenViewportCreated.current) {\n const screenViewport = getScreenViewport(parentDiv, initialViewState);\n screenViewportRef.current = screenViewport;\n\n if (viewportRef) viewportRef(screenViewport);\n\n Logger.logInfo(\n \"ViewportComponent\",\n `processing viewManager.addViewport for controlId=${controlId}`\n );\n viewManager.addViewport(screenViewport);\n\n // overlay component is set up once a ScreenViewport is available. The overlay component must handle any view changes itself.\n setViewOverlay(getViewOverlay ? getViewOverlay(screenViewport) : null);\n } else {\n // istanbul ignore next\n screenViewportRef.current?.changeView(initialViewState);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [controlId, initialViewState, viewportRef]);\n\n const handleContextMenu = React.useCallback(\n (e: React.MouseEvent) => {\n e.preventDefault();\n if (onContextMenu) onContextMenu(e);\n },\n [onContextMenu]\n );\n\n const parentDivStyle: React.CSSProperties = {\n height: \"100%\",\n width: \"100%\",\n position: \"relative\",\n };\n\n const viewportDivStyle: React.CSSProperties = {\n ...style,\n height: \"100%\",\n width: \"100%\",\n };\n\n return (\n <div style={parentDivStyle} data-item-id={controlId}>\n <div\n ref={viewportDiv}\n data-testid=\"viewport-component\"\n className={className}\n style={viewportDivStyle}\n onContextMenu={handleContextMenu}\n />\n {viewOverlay}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ViewportComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,sDAA6C;AAE7C,wDAAiD;AACjD,oDAA+C;AAQ/C,wDAK8B;AAQ9B,uEAAoE;AAkCpE;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,KAAoB;IACpD,MAAM,EACJ,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,KAAK,EACL,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,WAAW,GACZ,GAAG,KAAK,CAAC;IACV,uBAAuB;IACvB,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CACjC,mBAAmB,IAAI,yBAAS,CAAC,WAAW,CAC7C,CAAC;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,GAAG,cAAc,CAAC;gBAE3C,IAAI,WAAW;oBAAE,WAAW,CAAC,cAAc,CAAC,CAAC;gBAE7C,qBAAM,CAAC,OAAO,CACZ,mBAAmB,EACnB,oDAAoD,SAAS,EAAE,CAChE,CAAC;gBACF,WAAW,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBAExC,6HAA6H;gBAC7H,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;aACxE;iBAAM;gBACL,uBAAuB;gBACvB,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;aACzD;SACF;QACD,uDAAuD;IACzD,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC,CAAC;IAE/C,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,CAAC,CAAmB,EAAE,EAAE;QACtB,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,IAAI,aAAa;YAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,MAAM,cAAc,GAAwB;QAC1C,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,UAAU;KACrB,CAAC;IAEF,MAAM,gBAAgB,GAAwB;QAC5C,GAAG,KAAK;QACR,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;KACd,CAAC;IAEF,OAAO,CACL,6BAAK,KAAK,EAAE,cAAc,kBAAgB,SAAS;QACjD,6BACE,GAAG,EAAE,WAAW,iBACJ,oBAAoB,EAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,gBAAgB,EACvB,aAAa,EAAE,iBAAiB,GAChC;QACD,WAAW,CACR,CACP,CAAC;AACJ,CAAC;AA5UD,8CA4UC","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 Viewport\n */\n\nimport * as React from \"react\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Point3d } from \"@itwin/core-geometry\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport { NpcCenter } from \"@itwin/core-common\";\nimport type {\n IModelConnection,\n TentativePoint,\n ViewManager,\n Viewport,\n ViewState,\n} from \"@itwin/core-frontend\";\nimport {\n IModelApp,\n ScreenViewport,\n StandardView,\n ToolSettings,\n} from \"@itwin/core-frontend\";\n\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n CubeRotationChangeEventArgs,\n DrawingViewportChangeEventArgs,\n StandardRotationChangeEventArgs,\n} from \"./ViewportComponentEvents\";\nimport { ViewportComponentEvents } from \"./ViewportComponentEvents\";\n\n/** Type for a ViewState prop\n * @public\n */\nexport type ViewStateProp = ViewState | (() => ViewState);\n\n/**\n * Properties for [[ViewportComponent]] component.\n * @public\n */\nexport interface ViewportProps extends CommonProps {\n /** IModel to display */\n imodel: IModelConnection;\n /** Id of a default view definition to load as a starting point */\n viewDefinitionId?: Id64String;\n /** ViewState to use as a starting point */\n viewState?: ViewStateProp;\n /** Function to get a reference to the ScreenViewport */\n viewportRef?: (v: ScreenViewport) => void;\n /** controlId for this content component @internal */\n controlId?: string;\n /** @internal */\n onContextMenu?: (e: React.MouseEvent) => boolean;\n /** @internal */\n getViewOverlay?: (viewport: ScreenViewport) => React.ReactNode;\n /** @internal used only for testing */\n viewManagerOverride?: ViewManager;\n /** @internal used only for testing */\n screenViewportOverride?: typeof ScreenViewport;\n /** @internal used only for testing */\n tentativePointOverride?: TentativePoint;\n}\n\n/**\n * A viewport React component that creates a ScreenViewport.\n * @public\n */\nexport function ViewportComponent(props: ViewportProps) {\n const {\n viewState,\n imodel,\n viewDefinitionId,\n getViewOverlay,\n viewManagerOverride,\n tentativePointOverride,\n onContextMenu,\n style,\n className,\n screenViewportOverride,\n controlId,\n viewportRef,\n } = props;\n // istanbul ignore next\n const viewManagerRef = React.useRef(\n viewManagerOverride ?? IModelApp.viewManager\n );\n const tentativePointOverrideRef = React.useRef(tentativePointOverride);\n const screenViewportCreated = React.useRef(false);\n const viewportDiv = React.useRef<HTMLDivElement>(null);\n const screenViewportRef = React.useRef<ScreenViewport | null>(null);\n const isMounted = React.useRef(false);\n const viewClassFullName = React.useRef(\"\");\n const viewId = React.useRef(\"0\");\n\n // istanbul ignore next\n const handleViewChanged = (vp: Viewport) => {\n // istanbul ignore next\n if (!(vp.iModel.isOpen || vp.iModel.isBlank)) return;\n ViewportComponentEvents.setViewMatrix(vp);\n if (viewClassFullName.current !== vp.view.classFullName) {\n setTimeout(() => {\n ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({\n viewport: vp,\n oldName: viewClassFullName.current,\n newName: vp.view.classFullName,\n });\n viewClassFullName.current = vp.view.classFullName;\n });\n }\n if (viewId.current !== vp.view.id) {\n setTimeout(() => {\n ViewportComponentEvents.onViewIdChangedEvent.emit({\n viewport: vp,\n oldId: viewId.current,\n newId: vp.view.id,\n });\n viewId.current = vp.view.id;\n });\n }\n };\n\n const handleStandardRotationChangeEvent = (\n args: StandardRotationChangeEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setRotationAboutPoint(\n StandardView.getStandardRotation(args.standardRotation)\n );\n currentScreenViewport.synchWithView();\n }\n };\n\n const handleDrawingViewportChangeEvent = (\n args: DrawingViewportChangeEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setOrigin(args.origin);\n currentScreenViewport.view.setRotation(args.rotation);\n currentScreenViewport.synchWithView({\n noSaveInUndo: args.complete !== true,\n });\n }\n };\n\n const targetPoint = React.useRef<Point3d | null>(null);\n\n const getRotatePoint = (vp: ScreenViewport): Point3d => {\n const lastTargetPoint = targetPoint.current;\n // istanbul ignore next\n const tentativePoint =\n tentativePointOverrideRef.current ?? IModelApp.tentativePoint;\n // istanbul ignore else\n if (tentativePoint.isActive) return tentativePoint.getPoint();\n\n // istanbul ignore else\n if (null !== lastTargetPoint) {\n const testPt = vp.worldToView(lastTargetPoint);\n const viewRect = vp.viewRect.clone();\n viewRect.scaleAboutCenter(0.25, 0.25);\n // istanbul ignore next hard to reach because of mocks\n if (viewRect.containsPoint(testPt)) return lastTargetPoint;\n targetPoint.current = null;\n }\n\n const visiblePoint = vp.pickNearestVisibleGeometry(\n vp.npcToWorld(NpcCenter),\n vp.pixelsFromInches(ToolSettings.viewToolPickRadiusInches)\n );\n targetPoint.current =\n undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();\n // istanbul ignore next\n return targetPoint.current ?? vp.view.getCenter();\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const handleCubeRotationChangeEvent = (args: CubeRotationChangeEventArgs) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n // istanbul ignore else\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n const rotMatrix = args.rotMatrix;\n // istanbul ignore else\n if (currentScreenViewport.rotation !== rotMatrix) {\n const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...\n const center = getRotatePoint(currentScreenViewport);\n const targetMatrix = inverse.multiplyMatrixMatrix(\n currentScreenViewport.view.getRotation()\n );\n const worldTransform = Transform.createFixedPointAndMatrix(\n center,\n targetMatrix\n );\n const frustum = currentScreenViewport.getWorldFrustum();\n frustum.multiply(worldTransform);\n currentScreenViewport.view.setupFromFrustum(frustum);\n currentScreenViewport.synchWithView({ noSaveInUndo: !args.complete });\n }\n }\n };\n\n const handleDisconnectFromViewManager = () => {\n const screenViewport = screenViewportRef.current;\n if (screenViewport) {\n const viewManager = IModelApp.viewManager;\n screenViewport.onViewChanged.removeListener(handleViewChanged);\n screenViewportRef.current = null;\n screenViewportCreated.current = false;\n ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(\n handleStandardRotationChangeEvent\n );\n viewManager.dropViewport(screenViewport, true);\n }\n };\n\n // istanbul ignore next\n const handleWindowUnload = () => {\n const parentDiv = viewportDiv.current;\n if (parentDiv) {\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n if (parentWindow !== window) {\n handleDisconnectFromViewManager();\n }\n }\n };\n\n const getScreenViewport = (\n parentDiv: HTMLDivElement,\n inViewState: ViewState\n ) => {\n // istanbul ignore next\n const screenViewportFactory = screenViewportOverride\n ? screenViewportOverride\n : ScreenViewport;\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n parentWindow.addEventListener(\"unload\", handleWindowUnload, {\n once: true,\n capture: true,\n }); // by specifying 'once', listener clears after being called\n ViewportComponentEvents.initialize();\n ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.addListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.addListener(\n handleStandardRotationChangeEvent\n );\n const screenViewport = screenViewportFactory.create(parentDiv, inViewState);\n screenViewportCreated.current = true;\n viewClassFullName.current = screenViewport.view.classFullName;\n viewId.current = screenViewport.view.id;\n screenViewport.onViewChanged.addListener(handleViewChanged);\n return screenViewport;\n };\n\n React.useEffect(() => {\n isMounted.current = true;\n Logger.logInfo(\n \"ViewportComponent\",\n `mounting ViewportComponent for controlId=${controlId}`\n );\n\n return () => {\n isMounted.current = false;\n Logger.logInfo(\n \"ViewportComponent\",\n `un-mounting ViewportComponent for controlId=${controlId}`\n );\n handleDisconnectFromViewManager();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const [initialViewState, setInitialViewState] = React.useState<\n ViewState | undefined\n >(undefined);\n React.useEffect(() => {\n setInitialViewState(undefined);\n }, [viewDefinitionId, viewState]);\n React.useEffect(() => {\n async function fetchInitialViewstate() {\n let currentViewState: ViewState | undefined;\n if (viewState) {\n if (typeof viewState === \"function\") currentViewState = viewState();\n else currentViewState = viewState;\n } else if (viewDefinitionId && imodel) {\n try {\n currentViewState = await imodel.views.load(viewDefinitionId);\n // istanbul ignore next\n if (!currentViewState) {\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } catch (_e) {\n // istanbul ignore next\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } else {\n Logger.logError(\n \"ViewportComponent\",\n `A Viewstate or a viewId and imodel must be provided`\n );\n }\n // istanbul ignore next\n if (\n isMounted.current &&\n (currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)\n ) {\n setInitialViewState(currentViewState?.clone());\n }\n }\n if (undefined === initialViewState) void fetchInitialViewstate();\n }, [imodel, initialViewState, viewDefinitionId, viewState]);\n\n const [viewOverlay, setViewOverlay] = React.useState<React.ReactNode>(null);\n\n // This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.\n React.useEffect(() => {\n const parentDiv = viewportDiv.current;\n const viewManager = viewManagerRef.current;\n // istanbul ignore next\n if (\n parentDiv &&\n initialViewState &&\n (initialViewState?.iModel.isOpen || initialViewState?.iModel.isBlank)\n ) {\n if (!screenViewportCreated.current) {\n const screenViewport = getScreenViewport(parentDiv, initialViewState);\n screenViewportRef.current = screenViewport;\n\n if (viewportRef) viewportRef(screenViewport);\n\n Logger.logInfo(\n \"ViewportComponent\",\n `processing viewManager.addViewport for controlId=${controlId}`\n );\n viewManager.addViewport(screenViewport);\n\n // overlay component is set up once a ScreenViewport is available. The overlay component must handle any view changes itself.\n setViewOverlay(getViewOverlay ? getViewOverlay(screenViewport) : null);\n } else {\n // istanbul ignore next\n screenViewportRef.current?.changeView(initialViewState);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [controlId, initialViewState, viewportRef]);\n\n const handleContextMenu = React.useCallback(\n (e: React.MouseEvent) => {\n e.preventDefault();\n if (onContextMenu) onContextMenu(e);\n },\n [onContextMenu]\n );\n\n const parentDivStyle: React.CSSProperties = {\n height: \"100%\",\n width: \"100%\",\n position: \"relative\",\n };\n\n const viewportDivStyle: React.CSSProperties = {\n ...style,\n height: \"100%\",\n width: \"100%\",\n };\n\n return (\n <div style={parentDivStyle} data-item-id={controlId}>\n <div\n ref={viewportDiv}\n data-testid=\"viewport-component\"\n className={className}\n style={viewportDivStyle}\n onContextMenu={handleContextMenu}\n />\n {viewOverlay}\n </div>\n );\n}\n"]}
|