@deviceinsight/ng-ui-components 7.22.0 → 7.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -35,32 +35,9 @@ import Dropzone from "react-dropzone";
35
35
  import { AsyncPaginate } from "react-select-async-paginate";
36
36
  import { SVG } from "@svgdotjs/svg.js";
37
37
  import Highcharts from "highcharts";
38
- import HighchartsReact from "highcharts-react-official";
38
+ import { HighchartsReact } from "highcharts-react-official";
39
39
  import Slider$1 from "@rc-component/slider";
40
40
  import Tooltip from "@rc-component/tooltip";
41
- //#region \0rolldown/runtime.js
42
- var __create = Object.create;
43
- var __defProp = Object.defineProperty;
44
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
45
- var __getOwnPropNames = Object.getOwnPropertyNames;
46
- var __getProtoOf = Object.getPrototypeOf;
47
- var __hasOwnProp = Object.prototype.hasOwnProperty;
48
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
49
- var __copyProps = (to, from, except, desc) => {
50
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
51
- key = keys[i];
52
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
53
- get: ((k) => from[k]).bind(null, key),
54
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
55
- });
56
- }
57
- return to;
58
- };
59
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
60
- value: mod,
61
- enumerable: true
62
- }) : target, mod));
63
- //#endregion
64
41
  //#region src/modules/messageBox/messageBox.tsx
65
42
  var groupNamesToToastIds = {};
66
43
  var DEFAULT_AUTO_CLOSE_MS = 3e3;
@@ -3309,9 +3286,10 @@ var getClickConfiguration = (onClick) => {
3309
3286
  var Chart = class extends Component {
3310
3287
  constructor(..._args) {
3311
3288
  super(..._args);
3312
- this.state = {};
3289
+ this.state = { titleApplied: false };
3313
3290
  this.chart = null;
3314
3291
  this.ro = null;
3292
+ this.titleTimeoutId = void 0;
3315
3293
  this.handleChart = (chart) => {
3316
3294
  this.chart = chart;
3317
3295
  this.ro = new ResizeObserver(() => {
@@ -3321,8 +3299,16 @@ var Chart = class extends Component {
3321
3299
  };
3322
3300
  }
3323
3301
  componentDidMount() {
3302
+ this.titleTimeoutId = setTimeout(() => this.setState({ titleApplied: true }), 0);
3303
+ }
3304
+ /**
3305
+ * Builds the Highcharts configuration from the props. Everything here is derived, so it is
3306
+ * rebuilt while rendering rather than mirrored into state.
3307
+ */
3308
+ buildOptions() {
3324
3309
  const { type, title, items, tooltipTitle, valueFormatter, onClick } = this.props;
3325
- this.setState({
3310
+ const { titleApplied } = this.state;
3311
+ return {
3326
3312
  ...initialOptions,
3327
3313
  plotOptions: {
3328
3314
  ...initialOptions.plotOptions,
@@ -3339,44 +3325,12 @@ var Chart = class extends Component {
3339
3325
  ...initialOptions.legend,
3340
3326
  enabled: type === "pie"
3341
3327
  },
3342
- yAxis: {
3343
- ...initialOptions.yAxis,
3344
- enabled: type === "column",
3345
- title: { text: title || "" }
3346
- },
3347
- series: [{
3348
- type,
3349
- innerSize: "50%",
3350
- data: items.map(({ label, value }) => [label, value])
3351
- }]
3352
- });
3353
- setTimeout(() => {
3354
- this.setState({ title: {
3355
- ...initialOptions.title,
3356
- text: type === "column" ? "" : title || ""
3357
- } });
3358
- }, 0);
3359
- }
3360
- componentDidUpdate(prevProps) {
3361
- const { type, title, items, tooltipTitle, valueFormatter, onClick } = this.props;
3362
- if (title !== prevProps.title) this.setState({
3363
3328
  title: {
3364
- ...this.state.title,
3365
- text: type === "column" ? "" : title || ""
3366
- },
3367
- yAxis: {
3368
- ...this.state.yAxis,
3369
- title: { text: title || "" }
3370
- }
3371
- });
3372
- if (type !== prevProps.type) this.setState({
3373
- legend: {
3374
- ...this.state.legend,
3375
- enabled: type === "pie"
3329
+ ...initialOptions.title,
3330
+ text: titleApplied && type !== "column" ? title || "" : ""
3376
3331
  },
3377
- title: { text: type === "column" ? "" : title || "" },
3378
3332
  yAxis: {
3379
- ...this.state.yAxis,
3333
+ ...initialOptions.yAxis,
3380
3334
  enabled: type === "column",
3381
3335
  title: { text: type === "column" ? title || "" : "" }
3382
3336
  },
@@ -3385,35 +3339,19 @@ var Chart = class extends Component {
3385
3339
  innerSize: "50%",
3386
3340
  data: items.map(({ label, value }) => [label, value])
3387
3341
  }]
3388
- });
3389
- if (!isEqual(items, prevProps.items)) this.setState({ series: [{
3390
- type,
3391
- innerSize: "50%",
3392
- data: items.map(({ label, value }) => [label, value])
3393
- }] });
3394
- if (tooltipTitle !== prevProps.tooltipTitle || valueFormatter !== prevProps.valueFormatter || onClick !== prevProps.onClick) this.setState({
3395
- tooltip: {
3396
- ...initialOptions.tooltip,
3397
- formatter() {
3398
- const format = valueFormatter || ((value) => value);
3399
- return createTooltip(tooltipTitle || "", this.point.name, format(this.point.y));
3400
- }
3401
- },
3402
- plotOptions: {
3403
- ...initialOptions.plotOptions,
3404
- ...getClickConfiguration(onClick)
3405
- }
3406
- });
3342
+ };
3407
3343
  }
3408
3344
  componentWillUnmount() {
3345
+ clearTimeout(this.titleTimeoutId);
3409
3346
  if (this.ro && this.chart?.renderTo) this.ro.unobserve(this.chart.renderTo);
3410
3347
  this.chart = null;
3411
3348
  this.ro = null;
3412
3349
  }
3413
3350
  render() {
3351
+ const built = this.buildOptions();
3414
3352
  return /* @__PURE__ */ jsx(HighchartsReact, {
3415
3353
  highcharts: Highcharts,
3416
- options: this.props.updateOptions ? this.props.updateOptions(this.state) : this.state,
3354
+ options: this.props.updateOptions ? this.props.updateOptions(built) : built,
3417
3355
  containerProps: { className: this.props.className },
3418
3356
  callback: this.handleChart
3419
3357
  });
@@ -3421,54 +3359,15 @@ var Chart = class extends Component {
3421
3359
  };
3422
3360
  //#endregion
3423
3361
  //#region src/components/slider/RcSliderWithTooltip.tsx
3424
- var import_raf = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports) => {
3425
- Object.defineProperty(exports, "__esModule", { value: true });
3426
- exports.default = void 0;
3427
- var raf = (callback) => +setTimeout(callback, 16);
3428
- var caf = (num) => clearTimeout(num);
3429
- if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
3430
- raf = (callback) => window.requestAnimationFrame(callback);
3431
- caf = (handle) => window.cancelAnimationFrame(handle);
3432
- }
3433
- var rafUUID = 0;
3434
- var rafIds = /* @__PURE__ */ new Map();
3435
- function cleanup(id) {
3436
- rafIds.delete(id);
3437
- }
3438
- var wrapperRaf = (callback, times = 1) => {
3439
- rafUUID += 1;
3440
- const id = rafUUID;
3441
- function callRef(leftTimes) {
3442
- if (leftTimes === 0) {
3443
- cleanup(id);
3444
- callback();
3445
- } else {
3446
- const realId = raf(() => {
3447
- callRef(leftTimes - 1);
3448
- });
3449
- rafIds.set(id, realId);
3450
- }
3451
- }
3452
- callRef(times);
3453
- return id;
3454
- };
3455
- wrapperRaf.cancel = (id) => {
3456
- const realId = rafIds.get(id);
3457
- cleanup(id);
3458
- return caf(realId);
3459
- };
3460
- if (process.env.NODE_ENV !== "production") wrapperRaf.ids = () => rafIds;
3461
- exports.default = wrapperRaf;
3462
- })))(), 1);
3463
3362
  var HandleTooltip = (props) => {
3464
3363
  const { value, children, visible, tipFormatter = (val) => `${val}`, ...restProps } = props;
3465
3364
  const tooltipRef = useRef(null);
3466
3365
  const rafRef = useRef(null);
3467
3366
  function cancelKeepAlign() {
3468
- if (rafRef.current) import_raf.default.cancel(rafRef.current);
3367
+ if (rafRef.current) cancelAnimationFrame(rafRef.current);
3469
3368
  }
3470
3369
  function keepAlign() {
3471
- rafRef.current = (0, import_raf.default)(() => {
3370
+ rafRef.current = requestAnimationFrame(() => {
3472
3371
  tooltipRef.current?.forceAlign();
3473
3372
  });
3474
3373
  }