qwc2 2025.10.9 → 2025.10.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/actions/display.js +30 -1
  2. package/actions/editing.js +22 -1
  3. package/actions/layerinfo.js +13 -1
  4. package/actions/layers.js +213 -3
  5. package/actions/localConfig.js +58 -1
  6. package/actions/locale.js +21 -1
  7. package/actions/locate.js +26 -1
  8. package/actions/logging.js +10 -1
  9. package/actions/map.js +105 -2
  10. package/actions/measurement.js +12 -1
  11. package/actions/processNotifications.js +37 -1
  12. package/actions/redlining.js +18 -1
  13. package/actions/redliningPick.js +12 -1
  14. package/actions/search.js +12 -1
  15. package/actions/serviceinfo.js +12 -1
  16. package/actions/task.js +55 -3
  17. package/actions/theme.js +339 -19
  18. package/actions/windows.js +164 -5
  19. package/components/AppMenu.js +435 -3
  20. package/components/AttributeForm.js +928 -32
  21. package/components/AttributeTableWidget.js +1105 -13
  22. package/components/AutoEditForm.js +189 -3
  23. package/components/CoordinateDisplayer.js +78 -2
  24. package/components/EditComboField.js +190 -6
  25. package/components/EditUploadField.js +315 -3
  26. package/components/ExportSelection.js +203 -2
  27. package/components/FullscreenSwitcher.js +90 -3
  28. package/components/Icon.js +81 -2
  29. package/components/IdentifyViewer.js +1161 -6
  30. package/components/ImportLayer.js +718 -20
  31. package/components/LayerInfoWindow.js +145 -2
  32. package/components/LinkFeatureForm.js +246 -5
  33. package/components/MapButton.js +88 -2
  34. package/components/MapSelection.js +287 -8
  35. package/components/MessageBar.js +68 -2
  36. package/components/NumericInputWindow.js +359 -2
  37. package/components/PickFeature.js +266 -2
  38. package/components/PluginsContainer.js +227 -8
  39. package/components/PrintSelection.js +620 -49
  40. package/components/ProcessNotifications.js +104 -2
  41. package/components/QtDesignerForm.js +1137 -18
  42. package/components/ResizeableWindow.js +591 -8
  43. package/components/SearchBox.js +1307 -20
  44. package/components/ServiceInfoWindow.js +107 -2
  45. package/components/SideBar.js +204 -4
  46. package/components/StandardApp.js +381 -20
  47. package/components/Swipeable.js +15 -1
  48. package/components/TaskBar.js +85 -2
  49. package/components/ThemeLayersListWindow.js +216 -4
  50. package/components/ThemeList.js +381 -7
  51. package/components/Toolbar.js +106 -2
  52. package/components/WindowManager.js +178 -2
  53. package/components/map/OlLayer.js +257 -6
  54. package/components/map/OlMap.js +405 -5
  55. package/components/map/layers/BingLayer.js +31 -2
  56. package/components/map/layers/GoogleLayer.js +222 -19
  57. package/components/map/layers/GraticuleLayer.js +21 -1
  58. package/components/map/layers/ImageLayer.js +15 -1
  59. package/components/map/layers/MVTLayer.js +52 -2
  60. package/components/map/layers/OSMLayer.js +24 -2
  61. package/components/map/layers/OverlayLayer.js +55 -3
  62. package/components/map/layers/VectorLayer.js +173 -8
  63. package/components/map/layers/WFSLayer.js +220 -6
  64. package/components/map/layers/WMSLayer.js +180 -6
  65. package/components/map/layers/WMTSLayer.js +67 -3
  66. package/components/map/layers/XYZLayer.js +24 -2
  67. package/components/map/layers/index.js +28 -1
  68. package/components/map3d/EditDataset3D.js +190 -3
  69. package/components/map3d/HeightProfile3D.js +402 -3
  70. package/components/map3d/ImportObjects3D.js +162 -2
  71. package/components/map3d/Map3D.js +1304 -38
  72. package/components/map3d/MapControls3D.js +392 -7
  73. package/components/map3d/SearchField3D.js +183 -11
  74. package/components/map3d/View3DSwitcher.js +98 -2
  75. package/components/map3d/drawtool/CreateTool3D.js +174 -4
  76. package/components/map3d/drawtool/EditTool3D.js +590 -6
  77. package/components/map3d/drawtool/NumericInput3D.js +336 -4
  78. package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
  79. package/components/map3d/layers/VectorLayer3D.js +53 -2
  80. package/components/map3d/layers/WFSLayer3D.js +109 -3
  81. package/components/map3d/layers/WMSLayer3D.js +70 -2
  82. package/components/map3d/layers/WMTSLayer3D.js +27 -3
  83. package/components/map3d/layers/index.js +14 -1
  84. package/components/map3d/utils/FirstPersonControls3D.js +423 -16
  85. package/components/map3d/utils/MiscUtils3D.js +221 -13
  86. package/components/map3d/utils/OrbitControls3D.js +176 -5
  87. package/components/map3d/utils/Tiles3DStyle.js +238 -9
  88. package/components/share/ShareLink.js +54 -2
  89. package/components/share/ShareQRCode.js +62 -2
  90. package/components/share/ShareSocials.js +125 -3
  91. package/components/timeline/FixedTimeline.js +236 -5
  92. package/components/timeline/InfiniteTimeline.js +347 -8
  93. package/components/timeline/TimelineFeaturesSlider.js +439 -5
  94. package/components/widgets/AccordeonWidget.js +96 -2
  95. package/components/widgets/ButtonBar.js +124 -2
  96. package/components/widgets/ColorButton.js +201 -3
  97. package/components/widgets/ComboBox.js +166 -2
  98. package/components/widgets/CopyButton.js +110 -2
  99. package/components/widgets/DateTimeInput.js +100 -3
  100. package/components/widgets/EditableSelect.js +230 -3
  101. package/components/widgets/FileSelector.js +128 -4
  102. package/components/widgets/Input.js +124 -2
  103. package/components/widgets/InputContainer.js +96 -2
  104. package/components/widgets/LayerCatalogWidget.js +219 -3
  105. package/components/widgets/MenuButton.js +157 -1
  106. package/components/widgets/ModalDialog.js +64 -2
  107. package/components/widgets/NavBar.js +119 -2
  108. package/components/widgets/NumberInput.js +226 -4
  109. package/components/widgets/PopupMenu.js +72 -1
  110. package/components/widgets/Primitives.js +6 -1
  111. package/components/widgets/ReCaptchaWidget.js +55 -1
  112. package/components/widgets/SearchWidget.js +255 -2
  113. package/components/widgets/Spinner.js +44 -2
  114. package/components/widgets/SuggestionInput.js +77 -2
  115. package/components/widgets/TextInput.js +308 -2
  116. package/components/widgets/ToggleSwitch.js +85 -2
  117. package/components/widgets/VectorLayerPicker.js +85 -3
  118. package/libs/openlayers.js +225 -5
  119. package/package.json +1 -1
  120. package/plugins/API.js +358 -15
  121. package/plugins/AttributeTable.js +109 -3
  122. package/plugins/Authentication.js +130 -5
  123. package/plugins/BackgroundSwitcher.js +218 -4
  124. package/plugins/Bookmark.js +289 -3
  125. package/plugins/BottomBar.js +298 -4
  126. package/plugins/CookiePopup.js +67 -3
  127. package/plugins/Cyclomedia.js +442 -5
  128. package/plugins/Editing.js +497 -9
  129. package/plugins/FeatureForm.js +366 -4
  130. package/plugins/FeatureSearch.js +458 -3
  131. package/plugins/GeometryDigitizer.js +664 -7
  132. package/plugins/HeightProfile.js +763 -15
  133. package/plugins/Help.js +102 -3
  134. package/plugins/HomeButton.js +80 -3
  135. package/plugins/Identify.js +543 -5
  136. package/plugins/LayerCatalog.js +215 -4
  137. package/plugins/LayerTree.js +1194 -6
  138. package/plugins/LocateButton.js +94 -3
  139. package/plugins/Map.js +320 -16
  140. package/plugins/MapCompare.js +94 -3
  141. package/plugins/MapCopyright.js +127 -5
  142. package/plugins/MapExport.js +613 -20
  143. package/plugins/MapFilter.js +868 -12
  144. package/plugins/MapInfoTooltip.js +277 -3
  145. package/plugins/MapLegend.js +253 -4
  146. package/plugins/MapTip.js +290 -4
  147. package/plugins/Measure.js +220 -4
  148. package/plugins/NewsPopup.js +137 -3
  149. package/plugins/OverviewMap.js +167 -7
  150. package/plugins/Panoramax.js +340 -2
  151. package/plugins/Portal.js +199 -4
  152. package/plugins/Print.js +1231 -15
  153. package/plugins/Redlining.js +750 -6
  154. package/plugins/Reports.js +332 -3
  155. package/plugins/Routing.js +1278 -15
  156. package/plugins/ScratchDrawing.js +173 -5
  157. package/plugins/Settings.js +241 -4
  158. package/plugins/Share.js +198 -3
  159. package/plugins/StartupMarker.js +84 -4
  160. package/plugins/TaskButton.js +88 -3
  161. package/plugins/ThemeSwitcher.js +164 -4
  162. package/plugins/TimeManager.js +971 -10
  163. package/plugins/TopBar.js +300 -7
  164. package/plugins/TourGuide.js +213 -2
  165. package/plugins/ValueTool.js +419 -4
  166. package/plugins/View3D.js +519 -14
  167. package/plugins/ZoomButtons.js +165 -3
  168. package/plugins/map/EditingSupport.js +199 -7
  169. package/plugins/map/LocateSupport.js +260 -4
  170. package/plugins/map/MeasurementSupport.js +216 -8
  171. package/plugins/map/RedliningPickSupport.js +201 -7
  172. package/plugins/map/RedliningSupport.js +726 -17
  173. package/plugins/map/SnapInteraction.js +101 -1
  174. package/plugins/map/SnapSupport.js +210 -2
  175. package/plugins/map/SnappingSupport.js +356 -17
  176. package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
  177. package/plugins/map3d/BottomBar3D.js +118 -3
  178. package/plugins/map3d/Compare3D.js +422 -8
  179. package/plugins/map3d/Draw3D.js +353 -6
  180. package/plugins/map3d/ExportObjects3D.js +393 -18
  181. package/plugins/map3d/HideObjects3D.js +313 -12
  182. package/plugins/map3d/Identify3D.js +283 -12
  183. package/plugins/map3d/LayerTree3D.js +323 -3
  184. package/plugins/map3d/MapCopyright3D.js +128 -5
  185. package/plugins/map3d/MapExport3D.js +590 -10
  186. package/plugins/map3d/MapLight3D.js +553 -6
  187. package/plugins/map3d/Measure3D.js +571 -20
  188. package/plugins/map3d/OverviewMap3D.js +169 -3
  189. package/plugins/map3d/Settings3D.js +73 -3
  190. package/plugins/map3d/TopBar3D.js +207 -9
  191. package/plugins/redlining/RedliningBufferSupport.js +206 -3
  192. package/reducers/display.js +34 -2
  193. package/reducers/editing.js +68 -3
  194. package/reducers/index.js +9 -1
  195. package/reducers/layerinfo.js +26 -2
  196. package/reducers/layers.js +456 -9
  197. package/reducers/localConfig.js +122 -2
  198. package/reducers/locale.js +38 -2
  199. package/reducers/locate.js +40 -2
  200. package/reducers/map.js +176 -5
  201. package/reducers/measurement.js +42 -2
  202. package/reducers/processNotifications.js +49 -2
  203. package/reducers/redlining.js +50 -2
  204. package/reducers/redliningPick.js +27 -2
  205. package/reducers/search.js +20 -1
  206. package/reducers/serviceinfo.js +25 -2
  207. package/reducers/task.js +45 -2
  208. package/reducers/theme.js +51 -2
  209. package/reducers/windows.js +203 -2
  210. package/scripts/dist.sh +1 -1
  211. package/scripts/gen-plugin-docs.js +152 -2
  212. package/scripts/makeIconkit.js +85 -6
  213. package/scripts/themesConfig.js +742 -40
  214. package/scripts/updateTranslations.js +251 -10
  215. package/selectors/searchproviders.js +44 -2
  216. package/stores/StandardStore.js +42 -2
  217. package/utils/ConfigUtils.js +84 -3
  218. package/utils/CoordinatesUtils.js +234 -23
  219. package/utils/DxfUtils.js +237 -11
  220. package/utils/EditingInterface.js +421 -87
  221. package/utils/EditingUtils.js +357 -13
  222. package/utils/ElevationInterface.js +83 -22
  223. package/utils/FeatureStyles.js +429 -5
  224. package/utils/IdentifyUtils.js +443 -7
  225. package/utils/ImageEditor.js +79 -9
  226. package/utils/LayerUtils.js +1516 -50
  227. package/utils/LocaleUtils.js +117 -7
  228. package/utils/MapUtils.js +241 -59
  229. package/utils/MeasureUtils.js +323 -2
  230. package/utils/MiscUtils.js +189 -11
  231. package/utils/PermaLinkUtils.js +429 -6
  232. package/utils/PluginStore.js +27 -1
  233. package/utils/ResourceRegistry.js +15 -1
  234. package/utils/RoutingInterface.js +307 -7
  235. package/utils/SearchProviders.js +722 -19
  236. package/utils/ServiceLayerUtils.js +669 -14
  237. package/utils/Signal.js +32 -2
  238. package/utils/ThemeUtils.js +341 -7
  239. package/utils/VectorLayerUtils.js +589 -15
  240. package/utils/expr_grammar/grammar.js +2239 -2
  241. package/utils/expr_grammar/test.js +65 -3
@@ -1,10 +1,241 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/**
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
6
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
7
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
8
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
10
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
11
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ /**
2
16
  * Copyright 2024 Sourcepole AG
3
17
  * All rights reserved.
4
18
  *
5
19
  * This source code is licensed under the BSD-style license found in the
6
20
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import dayjs from"dayjs";import PropTypes from"prop-types";import LocaleUtils from"../../utils/LocaleUtils";import MiscUtils from"../../utils/MiscUtils";import Icon from"../Icon";import ButtonBar from"../widgets/ButtonBar";import Input from"../widgets/Input";import"./style/FixedTimeline.css";var FixedTimeline=/*#__PURE__*/function(_React$Component){function FixedTimeline(){var _this;_classCallCheck(this,FixedTimeline);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,FixedTimeline,[].concat(args));_defineProperty(_this,"state",{ticksContainerEl:null,timelineWidth:0});_defineProperty(_this,"navButtonClicked",function(key){if(key==="home"){_this.props.setStartTime(null);_this.props.setEndTime(null)}else if(key==="zoomin"){var mid=0.5*(_this.props.startTime+_this.props.endTime);_this.props.setStartTime(mid-0.25*_this.props.timeSpan);_this.props.setEndTime(mid+0.25*_this.props.timeSpan)}else if(key==="zoomout"){var _mid=0.5*(_this.props.startTime+_this.props.endTime);var newStartTime=Math.max(_this.props.dataStartTime,_mid-_this.props.timeSpan);_this.props.setStartTime(newStartTime);_this.props.setEndTime(Math.min(_this.props.dataEndTime,newStartTime+2*_this.props.timeSpan))}});_defineProperty(_this,"pan",function(dir){var delta=0.1*_this.props.timeSpan;if(dir>0){if(_this.props.dataEndTime-_this.props.endTime>0){var newEndTime=Math.min(_this.props.dataEndTime,_this.props.endTime+delta);_this.props.setStartTime(newEndTime-_this.props.timeSpan);_this.props.setEndTime(newEndTime)}}else{if(_this.props.startTime-_this.props.dataStartTime>0){var newStartTime=Math.max(_this.props.dataStartTime,_this.props.startTime-delta);_this.props.setStartTime(newStartTime);_this.props.setEndTime(newStartTime+_this.props.timeSpan)}}});_defineProperty(_this,"startPan",function(dir){_this.pan(dir);var panInterval=null;var panTimeout=setTimeout(function(){_this.pan(dir);panInterval=setInterval(function(){_this.pan(dir)},50)},250);document.addEventListener("pointerup",function(){clearInterval(panInterval);clearTimeout(panTimeout)},{once:true,capture:true})});_defineProperty(_this,"setTicksContainerRef",function(instance){if(_this.state.ticksContainerEl!==instance){_this.setState({ticksContainerEl:instance})}});_defineProperty(_this,"renderTicks",function(){// Render approx 1 tick every 100 px
8
- var nTicks=Math.round(_this.state.timelineWidth/100);var tickInterval=_this.state.timelineWidth/nTicks;var ticks=[];for(var x=0;x<_this.state.timelineWidth-0.5*tickInterval;x+=tickInterval){ticks.push({pixel:x,time:FixedTimeline.computeTimeFromPixel(_this,x)})}ticks.push({pixel:_this.state.timelineWidth,time:_this.props.endTime});// Render ticks
9
- return ticks.map(function(tick){var style={left:tick.pixel-1+"px"};return/*#__PURE__*/React.createElement("span",{className:tick.time?"fixtimeline-ltick":"fixtimeline-tick",key:"tick"+tick.pixel,style:style},tick.time?/*#__PURE__*/React.createElement("span",null,dayjs(tick.time).format(_this.props.dateFormat)):null)})});return _this}_inherits(FixedTimeline,_React$Component);return _createClass(FixedTimeline,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.state.ticksContainerEl&&(this.props.dialogWidth!==prevProps.dialogWidth||!prevState.ticksContainerEl)){this.setState(function(state){return{timelineWidth:state.ticksContainerEl.getBoundingClientRect().width}})}// Automatically pan if nearing the start/end of timeline
10
- if(this.props.currentTimestamp>this.props.endTime-0.1*this.props.timeSpan){if(this.props.endTime-this.props.currentTimestamp>0){this.pan(+1)}}else if(this.props.currentTimestamp<this.props.startTime+0.1*this.props.timeSpan){if(this.props.currentTimestamp-this.props.startTime>0){this.pan(-1)}}}},{key:"render",value:function render(){var _this2=this;var navButtons=[{key:"home",tooltip:LocaleUtils.tr("timemanager.home"),icon:"home"},{key:"zoomout",tooltip:LocaleUtils.tr("timemanager.zoomout"),icon:"zoomout"},{key:"zoomin",tooltip:LocaleUtils.tr("timemanager.zoomin"),icon:"zoomin"}];return/*#__PURE__*/React.createElement("div",{className:"fixtimeline"},/*#__PURE__*/React.createElement("div",{className:"fixtimeline-toolbar"},/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement(Input,{onChange:this.props.setStartTime,type:"date",value:this.props.startTime.format("YYYY-MM-DD")})),/*#__PURE__*/React.createElement("div",{className:"fixtimeline-toolbar-spacer"}),/*#__PURE__*/React.createElement(ButtonBar,{buttons:navButtons,onClick:this.navButtonClicked}),/*#__PURE__*/React.createElement("div",{className:"fixtimeline-toolbar-spacer"}),/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement(Input,{onChange:this.props.setEndTime,type:"date",value:this.props.endTime.format("YYYY-MM-DD")}))),/*#__PURE__*/React.createElement("div",{className:"fixtimeline-slider"},/*#__PURE__*/React.createElement("button",{className:"button fixtimeline-pan-left",disabled:this.props.startTime.isSame(this.props.dataStartTime),onContextMenu:MiscUtils.killEvent,onPointerDown:function onPointerDown(){return _this2.startPan(-1)}},/*#__PURE__*/React.createElement(Icon,{icon:"chevron-left"})),/*#__PURE__*/React.createElement("div",{className:"fixtimeline-ticks",ref:this.setTicksContainerRef},this.renderTicks()),/*#__PURE__*/React.createElement("button",{className:"button fixtimeline-pan-right",disabled:this.props.endTime.isSame(this.props.dataEndTime),onContextMenu:MiscUtils.killEvent,onPointerDown:function onPointerDown(){return _this2.startPan(1)}},/*#__PURE__*/React.createElement(Icon,{icon:"chevron-right"}))),this.props.children(function(time){return FixedTimeline.computePixelFromTime(_this2,time)},function(pixel){return FixedTimeline.computeTimeFromPixel(_this2,pixel)}))}}],[{key:"computeTimeFromPixel",value:function computeTimeFromPixel(self,pixel){return self.props.startTime+pixel/self.state.timelineWidth*self.props.timeSpan}},{key:"computePixelFromTime",value:function computePixelFromTime(self,time){return(time-self.props.startTime)/self.props.timeSpan*self.state.timelineWidth}}])}(React.Component);_defineProperty(FixedTimeline,"propTypes",{children:PropTypes.func,currentTimestamp:PropTypes.number,dataEndTime:PropTypes.object,dataStartTime:PropTypes.object,dateFormat:PropTypes.string,dialogWidth:PropTypes.number,endTime:PropTypes.object,setEndTime:PropTypes.func,setStartTime:PropTypes.func,startTime:PropTypes.object,timeSpan:PropTypes.number});export{FixedTimeline as default};
21
+ */
22
+
23
+ import React from 'react';
24
+ import dayjs from 'dayjs';
25
+ import PropTypes from 'prop-types';
26
+ import LocaleUtils from '../../utils/LocaleUtils';
27
+ import MiscUtils from '../../utils/MiscUtils';
28
+ import Icon from '../Icon';
29
+ import ButtonBar from '../widgets/ButtonBar';
30
+ import Input from '../widgets/Input';
31
+ import './style/FixedTimeline.css';
32
+ var FixedTimeline = /*#__PURE__*/function (_React$Component) {
33
+ function FixedTimeline() {
34
+ var _this;
35
+ _classCallCheck(this, FixedTimeline);
36
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
37
+ args[_key] = arguments[_key];
38
+ }
39
+ _this = _callSuper(this, FixedTimeline, [].concat(args));
40
+ _defineProperty(_this, "state", {
41
+ ticksContainerEl: null,
42
+ timelineWidth: 0
43
+ });
44
+ _defineProperty(_this, "navButtonClicked", function (key) {
45
+ if (key === "home") {
46
+ _this.props.setStartTime(null);
47
+ _this.props.setEndTime(null);
48
+ } else if (key === "zoomin") {
49
+ var mid = 0.5 * (_this.props.startTime + _this.props.endTime);
50
+ _this.props.setStartTime(mid - 0.25 * _this.props.timeSpan);
51
+ _this.props.setEndTime(mid + 0.25 * _this.props.timeSpan);
52
+ } else if (key === "zoomout") {
53
+ var _mid = 0.5 * (_this.props.startTime + _this.props.endTime);
54
+ var newStartTime = Math.max(_this.props.dataStartTime, _mid - _this.props.timeSpan);
55
+ _this.props.setStartTime(newStartTime);
56
+ _this.props.setEndTime(Math.min(_this.props.dataEndTime, newStartTime + 2 * _this.props.timeSpan));
57
+ }
58
+ });
59
+ _defineProperty(_this, "pan", function (dir) {
60
+ var delta = 0.1 * _this.props.timeSpan;
61
+ if (dir > 0) {
62
+ if (_this.props.dataEndTime - _this.props.endTime > 0) {
63
+ var newEndTime = Math.min(_this.props.dataEndTime, _this.props.endTime + delta);
64
+ _this.props.setStartTime(newEndTime - _this.props.timeSpan);
65
+ _this.props.setEndTime(newEndTime);
66
+ }
67
+ } else {
68
+ if (_this.props.startTime - _this.props.dataStartTime > 0) {
69
+ var newStartTime = Math.max(_this.props.dataStartTime, _this.props.startTime - delta);
70
+ _this.props.setStartTime(newStartTime);
71
+ _this.props.setEndTime(newStartTime + _this.props.timeSpan);
72
+ }
73
+ }
74
+ });
75
+ _defineProperty(_this, "startPan", function (dir) {
76
+ _this.pan(dir);
77
+ var panInterval = null;
78
+ var panTimeout = setTimeout(function () {
79
+ _this.pan(dir);
80
+ panInterval = setInterval(function () {
81
+ _this.pan(dir);
82
+ }, 50);
83
+ }, 250);
84
+ document.addEventListener("pointerup", function () {
85
+ clearInterval(panInterval);
86
+ clearTimeout(panTimeout);
87
+ }, {
88
+ once: true,
89
+ capture: true
90
+ });
91
+ });
92
+ _defineProperty(_this, "setTicksContainerRef", function (instance) {
93
+ if (_this.state.ticksContainerEl !== instance) {
94
+ _this.setState({
95
+ ticksContainerEl: instance
96
+ });
97
+ }
98
+ });
99
+ _defineProperty(_this, "renderTicks", function () {
100
+ // Render approx 1 tick every 100 px
101
+ var nTicks = Math.round(_this.state.timelineWidth / 100);
102
+ var tickInterval = _this.state.timelineWidth / nTicks;
103
+ var ticks = [];
104
+ for (var x = 0; x < _this.state.timelineWidth - 0.5 * tickInterval; x += tickInterval) {
105
+ ticks.push({
106
+ pixel: x,
107
+ time: FixedTimeline.computeTimeFromPixel(_this, x)
108
+ });
109
+ }
110
+ ticks.push({
111
+ pixel: _this.state.timelineWidth,
112
+ time: _this.props.endTime
113
+ });
114
+
115
+ // Render ticks
116
+ return ticks.map(function (tick) {
117
+ var style = {
118
+ left: tick.pixel - 1 + "px"
119
+ };
120
+ return /*#__PURE__*/React.createElement("span", {
121
+ className: tick.time ? "fixtimeline-ltick" : "fixtimeline-tick",
122
+ key: "tick" + tick.pixel,
123
+ style: style
124
+ }, tick.time ? /*#__PURE__*/React.createElement("span", null, dayjs(tick.time).format(_this.props.dateFormat)) : null);
125
+ });
126
+ });
127
+ return _this;
128
+ }
129
+ _inherits(FixedTimeline, _React$Component);
130
+ return _createClass(FixedTimeline, [{
131
+ key: "componentDidUpdate",
132
+ value: function componentDidUpdate(prevProps, prevState) {
133
+ if (this.state.ticksContainerEl && (this.props.dialogWidth !== prevProps.dialogWidth || !prevState.ticksContainerEl)) {
134
+ this.setState(function (state) {
135
+ return {
136
+ timelineWidth: state.ticksContainerEl.getBoundingClientRect().width
137
+ };
138
+ });
139
+ }
140
+ // Automatically pan if nearing the start/end of timeline
141
+ if (this.props.currentTimestamp > this.props.endTime - 0.1 * this.props.timeSpan) {
142
+ if (this.props.endTime - this.props.currentTimestamp > 0) {
143
+ this.pan(+1);
144
+ }
145
+ } else if (this.props.currentTimestamp < this.props.startTime + 0.1 * this.props.timeSpan) {
146
+ if (this.props.currentTimestamp - this.props.startTime > 0) {
147
+ this.pan(-1);
148
+ }
149
+ }
150
+ }
151
+ }, {
152
+ key: "render",
153
+ value: function render() {
154
+ var _this2 = this;
155
+ var navButtons = [{
156
+ key: "home",
157
+ tooltip: LocaleUtils.tr("timemanager.home"),
158
+ icon: "home"
159
+ }, {
160
+ key: "zoomout",
161
+ tooltip: LocaleUtils.tr("timemanager.zoomout"),
162
+ icon: "zoomout"
163
+ }, {
164
+ key: "zoomin",
165
+ tooltip: LocaleUtils.tr("timemanager.zoomin"),
166
+ icon: "zoomin"
167
+ }];
168
+ return /*#__PURE__*/React.createElement("div", {
169
+ className: "fixtimeline"
170
+ }, /*#__PURE__*/React.createElement("div", {
171
+ className: "fixtimeline-toolbar"
172
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Input, {
173
+ onChange: this.props.setStartTime,
174
+ type: "date",
175
+ value: this.props.startTime.format('YYYY-MM-DD')
176
+ })), /*#__PURE__*/React.createElement("div", {
177
+ className: "fixtimeline-toolbar-spacer"
178
+ }), /*#__PURE__*/React.createElement(ButtonBar, {
179
+ buttons: navButtons,
180
+ onClick: this.navButtonClicked
181
+ }), /*#__PURE__*/React.createElement("div", {
182
+ className: "fixtimeline-toolbar-spacer"
183
+ }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Input, {
184
+ onChange: this.props.setEndTime,
185
+ type: "date",
186
+ value: this.props.endTime.format('YYYY-MM-DD')
187
+ }))), /*#__PURE__*/React.createElement("div", {
188
+ className: "fixtimeline-slider"
189
+ }, /*#__PURE__*/React.createElement("button", {
190
+ className: "button fixtimeline-pan-left",
191
+ disabled: this.props.startTime.isSame(this.props.dataStartTime),
192
+ onContextMenu: MiscUtils.killEvent,
193
+ onPointerDown: function onPointerDown() {
194
+ return _this2.startPan(-1);
195
+ }
196
+ }, /*#__PURE__*/React.createElement(Icon, {
197
+ icon: "chevron-left"
198
+ })), /*#__PURE__*/React.createElement("div", {
199
+ className: "fixtimeline-ticks",
200
+ ref: this.setTicksContainerRef
201
+ }, this.renderTicks()), /*#__PURE__*/React.createElement("button", {
202
+ className: "button fixtimeline-pan-right",
203
+ disabled: this.props.endTime.isSame(this.props.dataEndTime),
204
+ onContextMenu: MiscUtils.killEvent,
205
+ onPointerDown: function onPointerDown() {
206
+ return _this2.startPan(1);
207
+ }
208
+ }, /*#__PURE__*/React.createElement(Icon, {
209
+ icon: "chevron-right"
210
+ }))), this.props.children(function (time) {
211
+ return FixedTimeline.computePixelFromTime(_this2, time);
212
+ }, function (pixel) {
213
+ return FixedTimeline.computeTimeFromPixel(_this2, pixel);
214
+ }));
215
+ }
216
+ }], [{
217
+ key: "computeTimeFromPixel",
218
+ value: function computeTimeFromPixel(self, pixel) {
219
+ return self.props.startTime + pixel / self.state.timelineWidth * self.props.timeSpan;
220
+ }
221
+ }, {
222
+ key: "computePixelFromTime",
223
+ value: function computePixelFromTime(self, time) {
224
+ return (time - self.props.startTime) / self.props.timeSpan * self.state.timelineWidth;
225
+ }
226
+ }]);
227
+ }(React.Component);
228
+ _defineProperty(FixedTimeline, "propTypes", {
229
+ children: PropTypes.func,
230
+ currentTimestamp: PropTypes.number,
231
+ dataEndTime: PropTypes.object,
232
+ dataStartTime: PropTypes.object,
233
+ dateFormat: PropTypes.string,
234
+ dialogWidth: PropTypes.number,
235
+ endTime: PropTypes.object,
236
+ setEndTime: PropTypes.func,
237
+ setStartTime: PropTypes.func,
238
+ startTime: PropTypes.object,
239
+ timeSpan: PropTypes.number
240
+ });
241
+ export { FixedTimeline as default };
@@ -1,13 +1,352 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/**
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
6
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
7
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
8
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
10
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
11
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ /**
2
16
  * Copyright 2024 Sourcepole AG
3
17
  * All rights reserved.
4
18
  *
5
19
  * This source code is licensed under the BSD-style license found in the
6
20
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import dayjs from"dayjs";import PropTypes from"prop-types";import LocaleUtils from"../../utils/LocaleUtils";import MiscUtils from"../../utils/MiscUtils";import Icon from"../Icon";import ButtonBar from"../widgets/ButtonBar";import NumberInput from"../widgets/NumberInput";import"./style/InfiniteTimeline.css";var InfiniteTimeline=/*#__PURE__*/function(_React$Component){function InfiniteTimeline(){var _this;_classCallCheck(this,InfiniteTimeline);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,InfiniteTimeline,[].concat(args));_defineProperty(_this,"state",{timelineContainerEl:null,timelineWidth:0,timeScalePast:1,timeScaleFuture:1,panOffset:0,zoomFactor:1// 1 = [startTime, endTime] fits dialog width in linear scale,
8
- });_defineProperty(_this,"setTimelineContainerRef",function(instance){if(_this.state.timelineContainerEl!==instance){_this.setState({timelineContainerEl:instance})}});_defineProperty(_this,"renderTicks",function(){var width=_this.state.timelineWidth;var now=dayjs(_this.props.currentTimestamp);var xnow=0.5*width-_this.state.panOffset;// Render one tick every 100px
9
- var ticks=[{pixel:xnow,time:now}];// Compute ticks before current time
10
- var x=xnow;x-=100;while(x>=0){if(x<width){ticks.push({pixel:x,time:InfiniteTimeline.computeTimeFromPixel(_this,x)})}x-=100}// Compute ticks after current time
11
- x=xnow;x+=100;while(x<=width){if(x>0){ticks.push({pixel:x,time:InfiniteTimeline.computeTimeFromPixel(_this,x)})}x+=100}// Intermediate ticks (lines only)
12
- var tickPos=[20,40,60,80].map(function(p){return Math.pow(p/100,1/_this.state.timeScalePast)*100});var i=0;for(x=xnow;x-tickPos[i]>=0;){if(x-tickPos[i]<width){ticks.push({pixel:x-tickPos[i]})}i+=1;if(i>=tickPos.length){x-=100;i=0}}i=0;tickPos=[20,40,60,80].map(function(p){return Math.pow(p/100,1/_this.state.timeScaleFuture)*100});for(x=xnow;x+tickPos[i]<=width;){if(x+tickPos[i]>0){ticks.push({pixel:x+tickPos[i]})}i+=1;if(i>=tickPos.length){x+=100;i=0}}// Render ticks
13
- return ticks.map(function(tick){var style={left:tick.pixel-1+"px"};return/*#__PURE__*/React.createElement("span",{className:tick.time?"inftimeline-ltick":"inftimeline-tick",key:"tick"+tick.pixel,style:style},tick.time?/*#__PURE__*/React.createElement("span",null,dayjs(tick.time).format(_this.props.dateFormat)):null)})});_defineProperty(_this,"onSliderWheel",function(ev){if(ev.shiftKey){if(ev.deltaY<0){_this.setState(function(state){return{zoomFactor:state.zoomFactor*0.5}})}else if(ev.deltaY>0){_this.setState(function(state){return{zoomFactor:state.zoomFactor*2}})}}else{if(ev.deltaX<0){_this.setState(function(state){return{panOffset:state.panOffset-20}})}else if(ev.deltaX>0){_this.setState(function(state){return{panOffset:state.panOffset+20}})}}ev.preventDefault();ev.stopPropagation()});_defineProperty(_this,"navButtonClicked",function(key){if(key==="home"){_this.setState({panOffset:0,zoomFactor:1})}else if(key==="zoomin"){_this.setState(function(state){return{zoomFactor:state.zoomFactor*0.5}})}else if(key==="zoomout"){_this.setState(function(state){return{zoomFactor:state.zoomFactor*2}})}});_defineProperty(_this,"setTimeScalePast",function(value){_this.props.setMarkersCanBeEnabled(value===1&&_this.state.timeScaleFuture===1);_this.setState({timeScalePast:value})});_defineProperty(_this,"setTimeScaleFuture",function(value){_this.props.setMarkersCanBeEnabled(_this.state.timeScalePast===1&&value===1);_this.setState({timeScaleFuture:value})});_defineProperty(_this,"pan",function(offset){_this.setState(function(state){return{panOffset:state.panOffset+offset}});var panInterval=null;var panTimeout=setTimeout(function(){_this.setState(function(state){return{panOffset:state.panOffset+offset}});panInterval=setInterval(function(){_this.setState(function(state){return{panOffset:state.panOffset+offset}})},50)},250);document.addEventListener("pointerup",function(){clearInterval(panInterval);clearTimeout(panTimeout)},{once:true,capture:true})});return _this}_inherits(InfiniteTimeline,_React$Component);return _createClass(InfiniteTimeline,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.state.timelineContainerEl&&(this.props.dialogWidth!==prevProps.dialogWidth||!prevState.timelineContainerEl)){this.setState(function(state){return{timelineWidth:state.timelineContainerEl.getBoundingClientRect().width}})}if(this.props.currentTimestamp!==prevProps.currentTimestamp){var pixel=InfiniteTimeline.computePixelFromTime(this,this.props.currentTimestamp);if(pixel<0||pixel>=this.state.timelineWidth){this.setState({panOffset:0})}}}},{key:"render",value:function render(){var _this2=this;var navButtons=[{key:"home",tooltip:LocaleUtils.tr("timemanager.home"),icon:"home"},{key:"zoomout",tooltip:LocaleUtils.tr("timemanager.zoomout"),icon:"zoomout"},{key:"zoomin",tooltip:LocaleUtils.tr("timemanager.zoomin"),icon:"zoomin"}];return/*#__PURE__*/React.createElement("div",{className:"inftimeline",onWheel:this.onSliderWheel,ref:this.setTimelineContainerRef},/*#__PURE__*/React.createElement("div",{className:"inftimeline-toolbar"},/*#__PURE__*/React.createElement(ButtonBar,{buttons:navButtons,onClick:this.navButtonClicked}),/*#__PURE__*/React.createElement("div",{className:"inftimeline-toolbar-block"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("timemanager.timelinescale"),": \xA0"),/*#__PURE__*/React.createElement(NumberInput,{decimals:2,max:10,min:0.01,mobile:true,onChange:this.setTimeScalePast,value:this.state.timeScalePast}),/*#__PURE__*/React.createElement(Icon,{icon:"before",title:LocaleUtils.tr("timemanager.past")}),/*#__PURE__*/React.createElement(Icon,{icon:"after",title:LocaleUtils.tr("timemanager.future")}),/*#__PURE__*/React.createElement(NumberInput,{decimals:2,max:10,min:0.01,mobile:true,onChange:this.setTimeScaleFuture,value:this.state.timeScaleFuture})),/*#__PURE__*/React.createElement("div",{className:"inftimeline-toolbar-spacer"})),/*#__PURE__*/React.createElement("div",{className:"inftimeline-clip"},/*#__PURE__*/React.createElement("button",{className:"button inftimeline-pan-left",onContextMenu:MiscUtils.killEvent,onPointerDown:function onPointerDown(){return _this2.pan(-20)}},/*#__PURE__*/React.createElement(Icon,{icon:"chevron-left"})),/*#__PURE__*/React.createElement("div",{className:"inftimeline-ticks"},this.renderTicks()),/*#__PURE__*/React.createElement("button",{className:"button inftimeline-pan-right",onContextMenu:MiscUtils.killEvent,onPointerDown:function onPointerDown(){return _this2.pan(20)}},/*#__PURE__*/React.createElement(Icon,{icon:"chevron-right"}))),this.props.children(function(time){return InfiniteTimeline.computePixelFromTime(_this2,time)},function(pixel){return InfiniteTimeline.computeTimeFromPixel(_this2,pixel)}))}}],[{key:"computeTimeFromPixel",value:function computeTimeFromPixel(self,pixel){var dpx=self.state.panOffset+pixel-0.5*self.state.timelineWidth;var exp=pixel-0.5*self.state.timelineWidth<0?self.state.timeScalePast:self.state.timeScaleFuture;return self.props.currentTimestamp+Math.sign(dpx)*Math.pow(Math.abs(dpx)/(0.5*self.state.timelineWidth),exp)*0.5*self.props.timeSpan*self.state.zoomFactor}},{key:"computePixelFromTime",value:function computePixelFromTime(self,time){var dt=time-self.props.currentTimestamp;var iexp=dt<0?1/self.state.timeScalePast:1/self.state.timeScaleFuture;return 0.5*self.state.timelineWidth*(1+Math.sign(dt)*Math.pow(Math.abs(dt)/(0.5*self.props.timeSpan*self.state.zoomFactor),iexp))-self.state.panOffset}}])}(React.Component);_defineProperty(InfiniteTimeline,"propTypes",{children:PropTypes.func,currentTimestamp:PropTypes.number,dateFormat:PropTypes.string,dialogWidth:PropTypes.number,endTime:PropTypes.object,setMarkersCanBeEnabled:PropTypes.func,startTime:PropTypes.object,timeSpan:PropTypes.number});export{InfiniteTimeline as default};
21
+ */
22
+
23
+ import React from 'react';
24
+ import dayjs from 'dayjs';
25
+ import PropTypes from 'prop-types';
26
+ import LocaleUtils from '../../utils/LocaleUtils';
27
+ import MiscUtils from '../../utils/MiscUtils';
28
+ import Icon from '../Icon';
29
+ import ButtonBar from '../widgets/ButtonBar';
30
+ import NumberInput from '../widgets/NumberInput';
31
+ import './style/InfiniteTimeline.css';
32
+ var InfiniteTimeline = /*#__PURE__*/function (_React$Component) {
33
+ function InfiniteTimeline() {
34
+ var _this;
35
+ _classCallCheck(this, InfiniteTimeline);
36
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
37
+ args[_key] = arguments[_key];
38
+ }
39
+ _this = _callSuper(this, InfiniteTimeline, [].concat(args));
40
+ _defineProperty(_this, "state", {
41
+ timelineContainerEl: null,
42
+ timelineWidth: 0,
43
+ timeScalePast: 1,
44
+ timeScaleFuture: 1,
45
+ panOffset: 0,
46
+ zoomFactor: 1 // 1 = [startTime, endTime] fits dialog width in linear scale,
47
+ });
48
+ _defineProperty(_this, "setTimelineContainerRef", function (instance) {
49
+ if (_this.state.timelineContainerEl !== instance) {
50
+ _this.setState({
51
+ timelineContainerEl: instance
52
+ });
53
+ }
54
+ });
55
+ _defineProperty(_this, "renderTicks", function () {
56
+ var width = _this.state.timelineWidth;
57
+ var now = dayjs(_this.props.currentTimestamp);
58
+ var xnow = 0.5 * width - _this.state.panOffset;
59
+
60
+ // Render one tick every 100px
61
+ var ticks = [{
62
+ pixel: xnow,
63
+ time: now
64
+ }];
65
+ // Compute ticks before current time
66
+ var x = xnow;
67
+ x -= 100;
68
+ while (x >= 0) {
69
+ if (x < width) {
70
+ ticks.push({
71
+ pixel: x,
72
+ time: InfiniteTimeline.computeTimeFromPixel(_this, x)
73
+ });
74
+ }
75
+ x -= 100;
76
+ }
77
+ // Compute ticks after current time
78
+ x = xnow;
79
+ x += 100;
80
+ while (x <= width) {
81
+ if (x > 0) {
82
+ ticks.push({
83
+ pixel: x,
84
+ time: InfiniteTimeline.computeTimeFromPixel(_this, x)
85
+ });
86
+ }
87
+ x += 100;
88
+ }
89
+ // Intermediate ticks (lines only)
90
+ var tickPos = [20, 40, 60, 80].map(function (p) {
91
+ return Math.pow(p / 100, 1 / _this.state.timeScalePast) * 100;
92
+ });
93
+ var i = 0;
94
+ for (x = xnow; x - tickPos[i] >= 0;) {
95
+ if (x - tickPos[i] < width) {
96
+ ticks.push({
97
+ pixel: x - tickPos[i]
98
+ });
99
+ }
100
+ i += 1;
101
+ if (i >= tickPos.length) {
102
+ x -= 100;
103
+ i = 0;
104
+ }
105
+ }
106
+ i = 0;
107
+ tickPos = [20, 40, 60, 80].map(function (p) {
108
+ return Math.pow(p / 100, 1 / _this.state.timeScaleFuture) * 100;
109
+ });
110
+ for (x = xnow; x + tickPos[i] <= width;) {
111
+ if (x + tickPos[i] > 0) {
112
+ ticks.push({
113
+ pixel: x + tickPos[i]
114
+ });
115
+ }
116
+ i += 1;
117
+ if (i >= tickPos.length) {
118
+ x += 100;
119
+ i = 0;
120
+ }
121
+ }
122
+ // Render ticks
123
+ return ticks.map(function (tick) {
124
+ var style = {
125
+ left: tick.pixel - 1 + "px"
126
+ };
127
+ return /*#__PURE__*/React.createElement("span", {
128
+ className: tick.time ? "inftimeline-ltick" : "inftimeline-tick",
129
+ key: "tick" + tick.pixel,
130
+ style: style
131
+ }, tick.time ? /*#__PURE__*/React.createElement("span", null, dayjs(tick.time).format(_this.props.dateFormat)) : null);
132
+ });
133
+ });
134
+ _defineProperty(_this, "onSliderWheel", function (ev) {
135
+ if (ev.shiftKey) {
136
+ if (ev.deltaY < 0) {
137
+ _this.setState(function (state) {
138
+ return {
139
+ zoomFactor: state.zoomFactor * 0.5
140
+ };
141
+ });
142
+ } else if (ev.deltaY > 0) {
143
+ _this.setState(function (state) {
144
+ return {
145
+ zoomFactor: state.zoomFactor * 2
146
+ };
147
+ });
148
+ }
149
+ } else {
150
+ if (ev.deltaX < 0) {
151
+ _this.setState(function (state) {
152
+ return {
153
+ panOffset: state.panOffset - 20
154
+ };
155
+ });
156
+ } else if (ev.deltaX > 0) {
157
+ _this.setState(function (state) {
158
+ return {
159
+ panOffset: state.panOffset + 20
160
+ };
161
+ });
162
+ }
163
+ }
164
+ ev.preventDefault();
165
+ ev.stopPropagation();
166
+ });
167
+ _defineProperty(_this, "navButtonClicked", function (key) {
168
+ if (key === "home") {
169
+ _this.setState({
170
+ panOffset: 0,
171
+ zoomFactor: 1
172
+ });
173
+ } else if (key === "zoomin") {
174
+ _this.setState(function (state) {
175
+ return {
176
+ zoomFactor: state.zoomFactor * 0.5
177
+ };
178
+ });
179
+ } else if (key === "zoomout") {
180
+ _this.setState(function (state) {
181
+ return {
182
+ zoomFactor: state.zoomFactor * 2
183
+ };
184
+ });
185
+ }
186
+ });
187
+ _defineProperty(_this, "setTimeScalePast", function (value) {
188
+ _this.props.setMarkersCanBeEnabled(value === 1 && _this.state.timeScaleFuture === 1);
189
+ _this.setState({
190
+ timeScalePast: value
191
+ });
192
+ });
193
+ _defineProperty(_this, "setTimeScaleFuture", function (value) {
194
+ _this.props.setMarkersCanBeEnabled(_this.state.timeScalePast === 1 && value === 1);
195
+ _this.setState({
196
+ timeScaleFuture: value
197
+ });
198
+ });
199
+ _defineProperty(_this, "pan", function (offset) {
200
+ _this.setState(function (state) {
201
+ return {
202
+ panOffset: state.panOffset + offset
203
+ };
204
+ });
205
+ var panInterval = null;
206
+ var panTimeout = setTimeout(function () {
207
+ _this.setState(function (state) {
208
+ return {
209
+ panOffset: state.panOffset + offset
210
+ };
211
+ });
212
+ panInterval = setInterval(function () {
213
+ _this.setState(function (state) {
214
+ return {
215
+ panOffset: state.panOffset + offset
216
+ };
217
+ });
218
+ }, 50);
219
+ }, 250);
220
+ document.addEventListener("pointerup", function () {
221
+ clearInterval(panInterval);
222
+ clearTimeout(panTimeout);
223
+ }, {
224
+ once: true,
225
+ capture: true
226
+ });
227
+ });
228
+ return _this;
229
+ }
230
+ _inherits(InfiniteTimeline, _React$Component);
231
+ return _createClass(InfiniteTimeline, [{
232
+ key: "componentDidUpdate",
233
+ value: function componentDidUpdate(prevProps, prevState) {
234
+ if (this.state.timelineContainerEl && (this.props.dialogWidth !== prevProps.dialogWidth || !prevState.timelineContainerEl)) {
235
+ this.setState(function (state) {
236
+ return {
237
+ timelineWidth: state.timelineContainerEl.getBoundingClientRect().width
238
+ };
239
+ });
240
+ }
241
+ if (this.props.currentTimestamp !== prevProps.currentTimestamp) {
242
+ var pixel = InfiniteTimeline.computePixelFromTime(this, this.props.currentTimestamp);
243
+ if (pixel < 0 || pixel >= this.state.timelineWidth) {
244
+ this.setState({
245
+ panOffset: 0
246
+ });
247
+ }
248
+ }
249
+ }
250
+ }, {
251
+ key: "render",
252
+ value: function render() {
253
+ var _this2 = this;
254
+ var navButtons = [{
255
+ key: "home",
256
+ tooltip: LocaleUtils.tr("timemanager.home"),
257
+ icon: "home"
258
+ }, {
259
+ key: "zoomout",
260
+ tooltip: LocaleUtils.tr("timemanager.zoomout"),
261
+ icon: "zoomout"
262
+ }, {
263
+ key: "zoomin",
264
+ tooltip: LocaleUtils.tr("timemanager.zoomin"),
265
+ icon: "zoomin"
266
+ }];
267
+ return /*#__PURE__*/React.createElement("div", {
268
+ className: "inftimeline",
269
+ onWheel: this.onSliderWheel,
270
+ ref: this.setTimelineContainerRef
271
+ }, /*#__PURE__*/React.createElement("div", {
272
+ className: "inftimeline-toolbar"
273
+ }, /*#__PURE__*/React.createElement(ButtonBar, {
274
+ buttons: navButtons,
275
+ onClick: this.navButtonClicked
276
+ }), /*#__PURE__*/React.createElement("div", {
277
+ className: "inftimeline-toolbar-block"
278
+ }, /*#__PURE__*/React.createElement("span", null, LocaleUtils.tr("timemanager.timelinescale"), ": \xA0"), /*#__PURE__*/React.createElement(NumberInput, {
279
+ decimals: 2,
280
+ max: 10,
281
+ min: 0.01,
282
+ mobile: true,
283
+ onChange: this.setTimeScalePast,
284
+ value: this.state.timeScalePast
285
+ }), /*#__PURE__*/React.createElement(Icon, {
286
+ icon: "before",
287
+ title: LocaleUtils.tr("timemanager.past")
288
+ }), /*#__PURE__*/React.createElement(Icon, {
289
+ icon: "after",
290
+ title: LocaleUtils.tr("timemanager.future")
291
+ }), /*#__PURE__*/React.createElement(NumberInput, {
292
+ decimals: 2,
293
+ max: 10,
294
+ min: 0.01,
295
+ mobile: true,
296
+ onChange: this.setTimeScaleFuture,
297
+ value: this.state.timeScaleFuture
298
+ })), /*#__PURE__*/React.createElement("div", {
299
+ className: "inftimeline-toolbar-spacer"
300
+ })), /*#__PURE__*/React.createElement("div", {
301
+ className: "inftimeline-clip"
302
+ }, /*#__PURE__*/React.createElement("button", {
303
+ className: "button inftimeline-pan-left",
304
+ onContextMenu: MiscUtils.killEvent,
305
+ onPointerDown: function onPointerDown() {
306
+ return _this2.pan(-20);
307
+ }
308
+ }, /*#__PURE__*/React.createElement(Icon, {
309
+ icon: "chevron-left"
310
+ })), /*#__PURE__*/React.createElement("div", {
311
+ className: "inftimeline-ticks"
312
+ }, this.renderTicks()), /*#__PURE__*/React.createElement("button", {
313
+ className: "button inftimeline-pan-right",
314
+ onContextMenu: MiscUtils.killEvent,
315
+ onPointerDown: function onPointerDown() {
316
+ return _this2.pan(20);
317
+ }
318
+ }, /*#__PURE__*/React.createElement(Icon, {
319
+ icon: "chevron-right"
320
+ }))), this.props.children(function (time) {
321
+ return InfiniteTimeline.computePixelFromTime(_this2, time);
322
+ }, function (pixel) {
323
+ return InfiniteTimeline.computeTimeFromPixel(_this2, pixel);
324
+ }));
325
+ }
326
+ }], [{
327
+ key: "computeTimeFromPixel",
328
+ value: function computeTimeFromPixel(self, pixel) {
329
+ var dpx = self.state.panOffset + pixel - 0.5 * self.state.timelineWidth;
330
+ var exp = pixel - 0.5 * self.state.timelineWidth < 0 ? self.state.timeScalePast : self.state.timeScaleFuture;
331
+ return self.props.currentTimestamp + Math.sign(dpx) * Math.pow(Math.abs(dpx) / (0.5 * self.state.timelineWidth), exp) * 0.5 * self.props.timeSpan * self.state.zoomFactor;
332
+ }
333
+ }, {
334
+ key: "computePixelFromTime",
335
+ value: function computePixelFromTime(self, time) {
336
+ var dt = time - self.props.currentTimestamp;
337
+ var iexp = dt < 0 ? 1 / self.state.timeScalePast : 1 / self.state.timeScaleFuture;
338
+ return 0.5 * self.state.timelineWidth * (1 + Math.sign(dt) * Math.pow(Math.abs(dt) / (0.5 * self.props.timeSpan * self.state.zoomFactor), iexp)) - self.state.panOffset;
339
+ }
340
+ }]);
341
+ }(React.Component);
342
+ _defineProperty(InfiniteTimeline, "propTypes", {
343
+ children: PropTypes.func,
344
+ currentTimestamp: PropTypes.number,
345
+ dateFormat: PropTypes.string,
346
+ dialogWidth: PropTypes.number,
347
+ endTime: PropTypes.object,
348
+ setMarkersCanBeEnabled: PropTypes.func,
349
+ startTime: PropTypes.object,
350
+ timeSpan: PropTypes.number
351
+ });
352
+ export { InfiniteTimeline as default };