@datarailsshared/dr_renderer 1.5.66 → 1.5.74

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.
@@ -37,10 +37,9 @@ jobs:
37
37
  publish-gh-packages:
38
38
  name: Publish to GitHub Packages
39
39
  needs: publish-npm
40
- uses: datarails/dr_github_reusable/.github/workflows/npm-publish-gh-packages.yml@DEVOPS-628
40
+ uses: datarails/dr_github_reusable/.github/workflows/npm-publish-gh-packages.yml@main
41
41
  with:
42
42
  node_version: '14.16.1'
43
43
  package_scope: '@datarails'
44
- use_auto_increment: true
45
- version_prefix: '1.5'
44
+ version: ${{ needs.publish-npm.outputs.version }}
46
45
  secrets: inherit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.5.66",
3
+ "version": "1.5.74",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -3738,6 +3738,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3738
3738
  }
3739
3739
 
3740
3740
  highchartsRenderer.rhPivotCount = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
3741
+ render_options = lodash.cloneDeep(render_options);
3741
3742
  var attr = arg[0];
3742
3743
  return function (data, rowKey, colKey) {
3743
3744
  return {
@@ -3819,6 +3820,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3819
3820
  };
3820
3821
 
3821
3822
  highchartsRenderer.rhPivotAggregatorUniqValues = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
3823
+ render_options = lodash.cloneDeep(render_options);
3822
3824
  var attr;
3823
3825
  attr = arg[0];
3824
3826
  var sep = '<br>';
@@ -3894,6 +3896,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3894
3896
  };
3895
3897
 
3896
3898
  highchartsRenderer.rhPivotAggregatorSum = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
3899
+ render_options = lodash.cloneDeep(render_options);
3897
3900
  var attr = arg[0];
3898
3901
  return function (data, rowKey, colKey) {
3899
3902
  return {
@@ -3987,6 +3990,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3987
3990
  };
3988
3991
 
3989
3992
  highchartsRenderer.rhPivotAggregatorMin = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
3993
+ render_options = lodash.cloneDeep(render_options);
3990
3994
  var attr = arg[0];
3991
3995
  return function (data, rowKey, colKey) {
3992
3996
  return {
@@ -4079,6 +4083,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4079
4083
  };
4080
4084
 
4081
4085
  highchartsRenderer.rhPivotAggregatorMax = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4086
+ render_options = lodash.cloneDeep(render_options);
4082
4087
  var attr = arg[0];
4083
4088
  return function (data, rowKey, colKey) {
4084
4089
  return {
@@ -4171,6 +4176,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4171
4176
  };
4172
4177
 
4173
4178
  highchartsRenderer.rhPivotAggregatorAverage = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4179
+ render_options = lodash.cloneDeep(render_options);
4174
4180
  var attr = arg[0];
4175
4181
  return function (data, rowKey, colKey) {
4176
4182
  return {
@@ -4458,30 +4464,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4458
4464
  return to_return;
4459
4465
  };
4460
4466
 
4461
- highchartsRenderer.checkFreezePanesAvaliable = function (pivotView) {
4462
- if (!pivotView || !pivotView.querySelector) {
4463
- return;
4464
- }
4465
-
4466
- const tableContainer = pivotView.querySelector('.pivot-div');
4467
- const tableHead = pivotView.querySelector('table.pvtTable thead');
4468
- const tableHeadChildren = tableHead ? tableHead.children[0] : null;
4469
- const trChildren = tableHeadChildren ? tableHeadChildren.children : [];
4470
- let thWidth = 0;
4471
-
4472
- for (let th of trChildren) {
4473
- if (th.classList.contains('axis-freeze-pane') || th.classList.contains('horizontal-freeze-pane')) {
4474
- thWidth += th.offsetWidth;
4475
- }
4476
- }
4477
-
4478
- if (thWidth >= tableContainer.offsetWidth) {
4479
- tableContainer.dataset.canFreezePanes = 'false';
4480
- } else if (thWidth < tableContainer.offsetWidth && tableContainer.dataset.canFreezePanes) {
4481
- delete tableContainer.dataset.canFreezePanes;
4482
- }
4483
- };
4484
-
4485
4467
  /**
4486
4468
  * Support rhPivotViewV2 version
4487
4469
  */
@@ -5171,19 +5153,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5171
5153
  }
5172
5154
  };
5173
5155
 
5174
- highchartsRenderer.setWidgetRawData = function (selectedTemplate) {
5175
- if (!selectedTemplate.widget_raw_data) {
5176
- selectedTemplate.widget_raw_data = lodash.map(selectedTemplate.raw_data,
5177
- function (row) {
5178
- var ob = {};
5179
- lodash.forEach(selectedTemplate.fields, function (value, key) {
5180
- ob[value.name] = row[value.name]; //highchartsRenderer.returnRawDataValue(value.type, row[value.name], value.format)+"";
5181
- });
5182
- return ob;
5183
- });
5184
- }
5185
- };
5186
-
5187
5156
  highchartsRenderer.updateBackwardCompatibleWidgetOptions = function(options, type) {
5188
5157
  if (lodash.get(options, 'chartOptions.chart.hideLegends', false)) {
5189
5158
  options.chartOptions.legends_position = { value: 'none' };
@@ -1501,53 +1501,6 @@ describe('highcharts_renderer', () => {
1501
1501
  });
1502
1502
  });
1503
1503
 
1504
- describe('function checkFreezePanesAvaliable', () => {
1505
- let pivotView;
1506
-
1507
- beforeEach(() => {
1508
- pivotView = document.createElement('div');
1509
- pivotView.innerHTML = `
1510
- <div class="pivot-div">
1511
- <table class="pvtTable">
1512
- <thead>
1513
- <tr>
1514
- <th class="axis-freeze-pane" style="width: 100px;"></th>
1515
- <th class="horizontal-freeze-pane" style="width: 100px;"></th>
1516
- <th style="width: 500px;"></th>
1517
- </tr>
1518
- </thead>
1519
- </table>
1520
- </div>
1521
- `;
1522
- });
1523
-
1524
- it('should set dataset.canFreezePanes to false when total width of frozen columns exceeds table width', () => {
1525
- const tableContainer = pivotView.querySelector('.pivot-div');
1526
- const expectedDataset = { canFreezePanes: 'false' };
1527
-
1528
- highchartsRenderer.checkFreezePanesAvaliable(pivotView);
1529
- expect(tableContainer.dataset.canFreezePanes).toEqual(expectedDataset.canFreezePanes);
1530
- });
1531
-
1532
- it('should remove dataset.canFreezePanes when total width of frozen columns is less than table width', () => {
1533
- const tableContainer ={
1534
- dataset: { canFreezePanes: "false" },
1535
- offsetWidth: 1000
1536
- };
1537
-
1538
- const _pivotView = {
1539
- querySelector: (p) => p === '.pivot-div' ? tableContainer : null
1540
- };
1541
- highchartsRenderer.checkFreezePanesAvaliable(_pivotView);
1542
-
1543
- expect(tableContainer.dataset.canFreezePanes).toEqual(undefined);
1544
- });
1545
-
1546
- it('should not set dataset.canFreezePanes when pivotView or pivotView.querySelector is undefined', () => {
1547
- expect(highchartsRenderer.checkFreezePanesAvaliable(null)).toEqual(undefined);
1548
- });
1549
- });
1550
-
1551
1504
  describe('function getOnlyIncludedOfField', () => {
1552
1505
  it('returns includes array if it exists', () => {
1553
1506
  const fieldObj = {
@@ -1773,56 +1726,6 @@ describe('highcharts_renderer', () => {
1773
1726
  });
1774
1727
  });
1775
1728
 
1776
- describe('function setWidgetRawData', () => {
1777
- it('should create widget_raw_data property if it does not exist', () => {
1778
- const selectedTemplate = {
1779
- raw_data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }],
1780
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '' }]
1781
- };
1782
-
1783
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1784
-
1785
- expect(selectedTemplate.widget_raw_data).toBeDefined();
1786
- });
1787
-
1788
- it('should map raw_data to widget_raw_data property', () => {
1789
- const selectedTemplate = {
1790
- raw_data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }],
1791
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '' }]
1792
- };
1793
-
1794
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1795
-
1796
- expect(selectedTemplate.widget_raw_data).toEqual([{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }]);
1797
- });
1798
-
1799
- it('should return raw_data values formatted based on their type and format', () => {
1800
- const selectedTemplate = {
1801
- raw_data: [{ name: 'John', age: 30.5 }, { name: 'Jane', age: 25 }],
1802
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '0.00' }]
1803
- };
1804
-
1805
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1806
-
1807
- expect(selectedTemplate.widget_raw_data[0].name).toBe('John');
1808
- expect(selectedTemplate.widget_raw_data[0].age).toBe(30.5);
1809
- expect(selectedTemplate.widget_raw_data[1].name).toBe('Jane');
1810
- expect(selectedTemplate.widget_raw_data[1].age).toBe(25);
1811
- });
1812
-
1813
- it('shouldn\'t create widget_raw_data if it exists', () => {
1814
- const selectedTemplate = {
1815
- widget_raw_data: [{}],
1816
- raw_data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }],
1817
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '' }]
1818
- };
1819
-
1820
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1821
-
1822
- expect(selectedTemplate.widget_raw_data.length).toBe(1);
1823
- });
1824
- });
1825
-
1826
1729
  describe("function updateBackwardCompatibleWidgetOptions", () => {
1827
1730
  it("should delete chart 'hideLegends' option if exists and true", () => {
1828
1731
  const options = {
@@ -2361,6 +2264,30 @@ describe('highcharts_renderer', () => {
2361
2264
  });
2362
2265
 
2363
2266
  describe('Aggregators functions', () => {
2267
+ const testMutationIsolation = (factory) => {
2268
+ // Use mockImplementationOnce to override the mock only for this test
2269
+ let appliedOptions = null;
2270
+ getAggregatorPercentageValueIfRequiredMock
2271
+ .mockImplementationOnce((value, opts) => {
2272
+ appliedOptions = lodash.cloneDeep(opts);
2273
+ return 'INITIAL';
2274
+ })
2275
+ .mockImplementationOnce((value, opts) => {
2276
+ const mutated = !lodash.isEqual(opts, appliedOptions);
2277
+ return mutated ? 'MUTATED' : 'INITIAL';
2278
+ });
2279
+
2280
+ const render_options = { chartOptions: { delta_column: { is_percentage: true } } };
2281
+ const aggregatorFn = factory([], '#,###%', true, render_options, {});
2282
+ const agg = aggregatorFn({}, [], []);
2283
+ const before = agg.format(100, false);
2284
+ render_options.chartOptions.delta_column.is_percentage = false;
2285
+ const after = agg.format(100, false);
2286
+
2287
+ expect(before).toBe('INITIAL');
2288
+ expect(after).toBe('INITIAL');
2289
+ };
2290
+
2364
2291
  describe('Sum aggregator', () => {
2365
2292
  let arg;
2366
2293
  let widget_values_format;
@@ -2415,6 +2342,10 @@ describe('highcharts_renderer', () => {
2415
2342
  expect(aggObject.numInputs).toBe(1);
2416
2343
  });
2417
2344
 
2345
+ it('Should ignore external mutations after initialization', () => {
2346
+ testMutationIsolation(highchartsRenderer.rhPivotAggregatorSum);
2347
+ });
2348
+
2418
2349
  describe('Push method', () => {
2419
2350
  beforeEach(() => {
2420
2351
  aggregator = highchartsRenderer.rhPivotAggregatorSum(arg, widget_values_format, is_graph, render_options, calculated_info);
@@ -2620,6 +2551,10 @@ describe('highcharts_renderer', () => {
2620
2551
  expect(aggObject.numInputs).toBe(1);
2621
2552
  });
2622
2553
 
2554
+ it('Should ignore external mutations after initialization', () => {
2555
+ testMutationIsolation(highchartsRenderer.rhPivotCount);
2556
+ });
2557
+
2623
2558
  describe('Push method', () => {
2624
2559
  beforeEach(() => {
2625
2560
  aggregator = highchartsRenderer.rhPivotCount(arg, widget_values_format, is_graph, render_options, calculated_info);
@@ -2822,6 +2757,10 @@ describe('highcharts_renderer', () => {
2822
2757
  expect(aggObject.numInputs).toBe(1);
2823
2758
  });
2824
2759
 
2760
+ it('Should ignore external mutations after initialization', () => {
2761
+ testMutationIsolation(highchartsRenderer.rhPivotAggregatorUniqValues);
2762
+ });
2763
+
2825
2764
  describe('Push method', () => {
2826
2765
  beforeEach(() => {
2827
2766
  aggregator = highchartsRenderer.rhPivotAggregatorUniqValues(arg, widget_values_format, is_graph, render_options, calculated_info);
@@ -2975,6 +2914,10 @@ describe('highcharts_renderer', () => {
2975
2914
  expect(aggObject.numInputs).toBe(1);
2976
2915
  });
2977
2916
 
2917
+ it('Should ignore external mutations after initialization', () => {
2918
+ testMutationIsolation(highchartsRenderer.rhPivotAggregatorAverage);
2919
+ });
2920
+
2978
2921
  describe('Push method', () => {
2979
2922
  beforeEach(() => {
2980
2923
  aggregator = highchartsRenderer.rhPivotAggregatorAverage(arg, widget_values_format, is_graph, render_options, calculated_info);
@@ -3183,6 +3126,10 @@ describe('highcharts_renderer', () => {
3183
3126
  expect(aggObject.numInputs).toBe(1);
3184
3127
  });
3185
3128
 
3129
+ it('Should ignore external mutations after initialization', () => {
3130
+ testMutationIsolation(highchartsRenderer.rhPivotAggregatorMin);
3131
+ });
3132
+
3186
3133
  describe('Push method', () => {
3187
3134
  beforeEach(() => {
3188
3135
  aggregator = highchartsRenderer.rhPivotAggregatorMin(arg, widget_values_format, is_graph, render_options, calculated_info);
@@ -3389,6 +3336,10 @@ describe('highcharts_renderer', () => {
3389
3336
  expect(aggObject.numInputs).toBe(1);
3390
3337
  });
3391
3338
 
3339
+ it('Should ignore external mutations after initialization', () => {
3340
+ testMutationIsolation(highchartsRenderer.rhPivotAggregatorMax);
3341
+ });
3342
+
3392
3343
  describe('Push method', () => {
3393
3344
  beforeEach(() => {
3394
3345
  aggregator = highchartsRenderer.rhPivotAggregatorMax(arg, widget_values_format, is_graph, render_options, calculated_info);