@zeedhi/common 1.77.0 → 1.77.2

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.
@@ -1,4 +1,4 @@
1
- import { AccessorManager, Event, KeyMap, Metadata, FormatterParserProvider, Validation, Mask, Accessor, DatasourceFactory, I18n, MethodNotAssignedError, Loader, Config, dayjs, DateHelper, Utils, Router, InstanceNotFoundError, Cookie, Http, URL as URL$1, VersionService } from '@zeedhi/core';
1
+ import { AccessorManager, Event, KeyMap, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, MethodNotAssignedError, Loader, Config, dayjs, DateHelper, Utils, Router, InstanceNotFoundError, Cookie, Http, URL as URL$1, VersionService } from '@zeedhi/core';
2
2
  import merge from 'lodash.merge';
3
3
  import debounce from 'lodash.debounce';
4
4
  import isUndefined from 'lodash.isundefined';
@@ -527,8 +527,8 @@ class ApexChart extends ComponentRender {
527
527
  },
528
528
  };
529
529
  this.chartType = this.getInitValue('chartType', props.chartType, this.chartType);
530
- this.options = merge(this.defaultOptions, this.getInitValue('options', props.options, this.options));
531
- this.series = this.getInitValue('series', props.series, this.series);
530
+ this.options = merge(this.defaultOptions, this.getInitValue('options', this.translateOptions(props.options), this.options));
531
+ this.series = this.getInitValue('series', this.translateSeries(props.series), this.series);
532
532
  this.height = this.getInitValue('height', props.height, this.height);
533
533
  this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
534
534
  this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
@@ -542,6 +542,65 @@ class ApexChart extends ComponentRender {
542
542
  this.createAccessors();
543
543
  this.createObjAccessors(this.options, 'options');
544
544
  }
545
+ getPropValue(value) {
546
+ if (value && !Accessor.isAccessorDefinition(value))
547
+ return value;
548
+ return false;
549
+ }
550
+ translateSeries(series = []) {
551
+ const value = this.getPropValue(series);
552
+ if (value && Array.isArray(value)) {
553
+ return value.map((item) => {
554
+ if (item.name)
555
+ item.name = I18n.translate(item.name);
556
+ return item;
557
+ });
558
+ }
559
+ return series;
560
+ }
561
+ translateOptions(propOptions = {}) {
562
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
563
+ let value;
564
+ value = this.getPropValue((_c = (_b = (_a = propOptions.annotations) === null || _a === void 0 ? void 0 : _a.yaxis) === null || _b === void 0 ? void 0 : _b.label) === null || _c === void 0 ? void 0 : _c.text);
565
+ if (value)
566
+ propOptions.annotations.yaxis.label.text = I18n.translate(value);
567
+ value = this.getPropValue((_f = (_e = (_d = propOptions.annotations) === null || _d === void 0 ? void 0 : _d.xaxis) === null || _e === void 0 ? void 0 : _e.label) === null || _f === void 0 ? void 0 : _f.text);
568
+ if (value)
569
+ propOptions.annotations.xaxis.label.text = I18n.translate(value);
570
+ value = this.getPropValue((_j = (_h = (_g = propOptions.annotations) === null || _g === void 0 ? void 0 : _g.points) === null || _h === void 0 ? void 0 : _h.label) === null || _j === void 0 ? void 0 : _j.text);
571
+ if (value)
572
+ propOptions.annotations.points.label.text = I18n.translate(value);
573
+ value = this.getPropValue((_l = (_k = propOptions.annotations) === null || _k === void 0 ? void 0 : _k.texts) === null || _l === void 0 ? void 0 : _l.text);
574
+ if (value)
575
+ propOptions.annotations.texts.text = I18n.translate(value);
576
+ value = this.getPropValue(propOptions.labels);
577
+ if (value && Array.isArray(value))
578
+ propOptions.labels = value.map((item) => I18n.translate(item));
579
+ value = this.getPropValue((_r = (_q = (_p = (_o = (_m = propOptions.plotOptions) === null || _m === void 0 ? void 0 : _m.pie) === null || _o === void 0 ? void 0 : _o.donut) === null || _p === void 0 ? void 0 : _p.labels) === null || _q === void 0 ? void 0 : _q.total) === null || _r === void 0 ? void 0 : _r.label);
580
+ if (value)
581
+ propOptions.plotOptions.pie.donut.labels.total.label = I18n.translate(value);
582
+ value = this.getPropValue(propOptions.series);
583
+ if (value && Array.isArray(value)) {
584
+ propOptions.series = value.map((item) => {
585
+ if (item.name)
586
+ item.name = I18n.translate(item.name);
587
+ return item;
588
+ });
589
+ }
590
+ value = this.getPropValue((_s = propOptions.subtitle) === null || _s === void 0 ? void 0 : _s.text);
591
+ if (value)
592
+ propOptions.subtitle.text = I18n.translate(value);
593
+ value = this.getPropValue((_t = propOptions.title) === null || _t === void 0 ? void 0 : _t.text);
594
+ if (value)
595
+ propOptions.title.text = I18n.translate(value);
596
+ value = this.getPropValue((_v = (_u = propOptions.xaxis) === null || _u === void 0 ? void 0 : _u.title) === null || _v === void 0 ? void 0 : _v.text);
597
+ if (value)
598
+ propOptions.xaxis.title.text = I18n.translate(value);
599
+ value = this.getPropValue((_x = (_w = propOptions.yaxis) === null || _w === void 0 ? void 0 : _w.title) === null || _x === void 0 ? void 0 : _x.text);
600
+ if (value)
601
+ propOptions.yaxis.title.text = I18n.translate(value);
602
+ return propOptions;
603
+ }
545
604
  /**
546
605
  * Sets view update method.
547
606
  * @param viewUpdate Update method
@@ -534,8 +534,8 @@
534
534
  },
535
535
  };
536
536
  this.chartType = this.getInitValue('chartType', props.chartType, this.chartType);
537
- this.options = merge__default["default"](this.defaultOptions, this.getInitValue('options', props.options, this.options));
538
- this.series = this.getInitValue('series', props.series, this.series);
537
+ this.options = merge__default["default"](this.defaultOptions, this.getInitValue('options', this.translateOptions(props.options), this.options));
538
+ this.series = this.getInitValue('series', this.translateSeries(props.series), this.series);
539
539
  this.height = this.getInitValue('height', props.height, this.height);
540
540
  this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
541
541
  this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
@@ -549,6 +549,65 @@
549
549
  this.createAccessors();
550
550
  this.createObjAccessors(this.options, 'options');
551
551
  }
552
+ getPropValue(value) {
553
+ if (value && !core.Accessor.isAccessorDefinition(value))
554
+ return value;
555
+ return false;
556
+ }
557
+ translateSeries(series = []) {
558
+ const value = this.getPropValue(series);
559
+ if (value && Array.isArray(value)) {
560
+ return value.map((item) => {
561
+ if (item.name)
562
+ item.name = core.I18n.translate(item.name);
563
+ return item;
564
+ });
565
+ }
566
+ return series;
567
+ }
568
+ translateOptions(propOptions = {}) {
569
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
570
+ let value;
571
+ value = this.getPropValue((_c = (_b = (_a = propOptions.annotations) === null || _a === void 0 ? void 0 : _a.yaxis) === null || _b === void 0 ? void 0 : _b.label) === null || _c === void 0 ? void 0 : _c.text);
572
+ if (value)
573
+ propOptions.annotations.yaxis.label.text = core.I18n.translate(value);
574
+ value = this.getPropValue((_f = (_e = (_d = propOptions.annotations) === null || _d === void 0 ? void 0 : _d.xaxis) === null || _e === void 0 ? void 0 : _e.label) === null || _f === void 0 ? void 0 : _f.text);
575
+ if (value)
576
+ propOptions.annotations.xaxis.label.text = core.I18n.translate(value);
577
+ value = this.getPropValue((_j = (_h = (_g = propOptions.annotations) === null || _g === void 0 ? void 0 : _g.points) === null || _h === void 0 ? void 0 : _h.label) === null || _j === void 0 ? void 0 : _j.text);
578
+ if (value)
579
+ propOptions.annotations.points.label.text = core.I18n.translate(value);
580
+ value = this.getPropValue((_l = (_k = propOptions.annotations) === null || _k === void 0 ? void 0 : _k.texts) === null || _l === void 0 ? void 0 : _l.text);
581
+ if (value)
582
+ propOptions.annotations.texts.text = core.I18n.translate(value);
583
+ value = this.getPropValue(propOptions.labels);
584
+ if (value && Array.isArray(value))
585
+ propOptions.labels = value.map((item) => core.I18n.translate(item));
586
+ value = this.getPropValue((_r = (_q = (_p = (_o = (_m = propOptions.plotOptions) === null || _m === void 0 ? void 0 : _m.pie) === null || _o === void 0 ? void 0 : _o.donut) === null || _p === void 0 ? void 0 : _p.labels) === null || _q === void 0 ? void 0 : _q.total) === null || _r === void 0 ? void 0 : _r.label);
587
+ if (value)
588
+ propOptions.plotOptions.pie.donut.labels.total.label = core.I18n.translate(value);
589
+ value = this.getPropValue(propOptions.series);
590
+ if (value && Array.isArray(value)) {
591
+ propOptions.series = value.map((item) => {
592
+ if (item.name)
593
+ item.name = core.I18n.translate(item.name);
594
+ return item;
595
+ });
596
+ }
597
+ value = this.getPropValue((_s = propOptions.subtitle) === null || _s === void 0 ? void 0 : _s.text);
598
+ if (value)
599
+ propOptions.subtitle.text = core.I18n.translate(value);
600
+ value = this.getPropValue((_t = propOptions.title) === null || _t === void 0 ? void 0 : _t.text);
601
+ if (value)
602
+ propOptions.title.text = core.I18n.translate(value);
603
+ value = this.getPropValue((_v = (_u = propOptions.xaxis) === null || _u === void 0 ? void 0 : _u.title) === null || _v === void 0 ? void 0 : _v.text);
604
+ if (value)
605
+ propOptions.xaxis.title.text = core.I18n.translate(value);
606
+ value = this.getPropValue((_x = (_w = propOptions.yaxis) === null || _w === void 0 ? void 0 : _w.title) === null || _x === void 0 ? void 0 : _x.text);
607
+ if (value)
608
+ propOptions.yaxis.title.text = core.I18n.translate(value);
609
+ return propOptions;
610
+ }
552
611
  /**
553
612
  * Sets view update method.
554
613
  * @param viewUpdate Update method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.77.0",
3
+ "version": "1.77.2",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -39,5 +39,5 @@
39
39
  "lodash.times": "4.3.*",
40
40
  "mockdate": "3.0.*"
41
41
  },
42
- "gitHead": "1fe7b109f390ff262afe30d765f812712ab7472c"
42
+ "gitHead": "f6fab5c2263a74fb4e35a8a6ef145b1f196e5b9a"
43
43
  }
@@ -85,6 +85,9 @@ export declare class ApexChart extends ComponentRender implements IApexChart {
85
85
  * @param props ApexChart properties
86
86
  */
87
87
  constructor(props: IApexChart);
88
+ private getPropValue;
89
+ private translateSeries;
90
+ private translateOptions;
88
91
  /**
89
92
  * Sets view update method.
90
93
  * @param viewUpdate Update method