@devgateway/dvz-wp-commons 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/APIConfig.d.ts +19 -42
- package/build/APIConfig.js +17 -12
- package/build/APIutils.d.ts +3 -3
- package/build/APIutils.js +4 -0
- package/build/Blocks.d.ts +29 -65
- package/build/Blocks.js +32 -47
- package/build/CSVSourceConfig.d.ts +2 -3
- package/build/CSVSourceConfig.js +14 -9
- package/build/ChartColors.d.ts +4 -45
- package/build/ChartColors.js +49 -62
- package/build/ChartLegends.d.ts +1 -32
- package/build/ChartLegends.js +21 -36
- package/build/ChartMeasures.d.ts +1 -22
- package/build/ChartMeasures.js +3 -4
- package/build/Constants.d.ts +18 -15
- package/build/DataFilters.d.ts +1 -12
- package/build/DataFilters.js +11 -15
- package/build/Format.d.ts +8 -10
- package/build/Format.js +5 -6
- package/build/MapCSVSourceConfig.d.ts +7 -9
- package/build/MapCSVSourceConfig.js +1 -2
- package/build/Measures.d.ts +1 -24
- package/build/Measures.js +17 -24
- package/build/MobileConfigUtils.d.ts +6 -6
- package/build/MobileConfigUtils.js +20 -24
- package/build/Tooltip.d.ts +2 -2
- package/build/Util.d.ts +5 -6
- package/build/Util.js +2 -2
- package/build/icons/Chart.d.ts +2 -2
- package/build/icons/Generic.d.ts +2 -2
- package/build/icons/index.d.ts +2 -2
- package/build/index.d.ts +16 -18
- package/build/index.js +7 -10
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -26
- package/build/post-type.d.ts +0 -193
- package/build/post-type.js +0 -12
- package/build/types.d.ts +0 -349
- package/build/types.js +0 -33
package/build/ChartColors.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
1
|
import { PanelBody, PanelRow, SelectControl } from '@wordpress/components';
|
|
2
|
+
import { PanelColorSettings } from '@wordpress/block-editor';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { useEffect } from "react";
|
|
4
5
|
import Papa from 'papaparse';
|
|
5
6
|
import { useRef, useState } from "@wordpress/element";
|
|
6
7
|
import { getTranslation } from "./APIutils";
|
|
7
|
-
import { PanelColorSettings } from "@wordpress/block-editor";
|
|
8
8
|
const OVERALL = 'Overall';
|
|
9
9
|
const system = [{ value: "system", label: 'System Colors' }, { value: "manual", label: 'Manual Colors' }];
|
|
10
10
|
export const categorical = [{ value: "nivo", label: 'nivo' }, {
|
|
@@ -41,11 +41,10 @@ export const diverging = [{ value: "brown_blueGreen", label: 'brown_blueGreen' }
|
|
|
41
41
|
];
|
|
42
42
|
const plainColor = { value: "plain_color", label: 'Use Plain color' };
|
|
43
43
|
export const ChartColors = (props) => {
|
|
44
|
-
const { allDimensions, allFilters, allMeasures, allCategories, allApps, setAttributes, attributes } = props;
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
let
|
|
48
|
-
let d3Label = null;
|
|
44
|
+
const { allDimensions, allFilters, allMeasures, allCategories, allApps, setAttributes, attributes: { swap, measures, manualColors, scheme, colorBy, dimension1, dimension2, barColor, type, app, csv, includeOverall } } = props;
|
|
45
|
+
let l1Label;
|
|
46
|
+
let d2Label;
|
|
47
|
+
let d3Label;
|
|
49
48
|
const selectedMeasures = measures[app] ? Object.keys(measures[app]).map(k => measures[app][k]).filter(m => m.selected) : [];
|
|
50
49
|
let colorOptions = [];
|
|
51
50
|
if (app !== "csv") {
|
|
@@ -64,23 +63,19 @@ export const ChartColors = (props) => {
|
|
|
64
63
|
else {
|
|
65
64
|
//CSV Color Options
|
|
66
65
|
const data = Papa.parse(csv, { header: true, dynamicTyping: true });
|
|
67
|
-
l1Label = data.meta.fields
|
|
66
|
+
l1Label = data.meta.fields.length > 0 ? '1st Column Values ' : null;
|
|
68
67
|
d2Label = __("Measure Columns Labels");
|
|
69
68
|
d3Label = __("Measure Columns Values");
|
|
70
69
|
}
|
|
71
|
-
if (type == 'bar') {
|
|
70
|
+
if (type == 'bar' || type == 'line') {
|
|
72
71
|
if (swap && dimension2 == "none" && selectedMeasures.length > 0) {
|
|
73
72
|
colorOptions = [];
|
|
74
73
|
if (l1Label) {
|
|
75
74
|
colorOptions.push({ label: l1Label, value: 'id' });
|
|
76
|
-
|
|
77
|
-
colorOptions.push({ label: d2Label, value: 'index' });
|
|
78
|
-
}
|
|
75
|
+
colorOptions.push({ label: d2Label, value: 'index' });
|
|
79
76
|
}
|
|
80
77
|
else {
|
|
81
|
-
|
|
82
|
-
colorOptions.push({ label: d2Label, value: 'id' });
|
|
83
|
-
}
|
|
78
|
+
colorOptions.push({ label: d2Label, value: 'id' });
|
|
84
79
|
colorOptions.push({ label: "Measure Values", value: 'values' });
|
|
85
80
|
}
|
|
86
81
|
}
|
|
@@ -99,11 +94,11 @@ export const ChartColors = (props) => {
|
|
|
99
94
|
}
|
|
100
95
|
if (type == 'pie') {
|
|
101
96
|
if (dimension1 != 'none' && dimension2 == 'none' && colorBy != 'index') {
|
|
102
|
-
setAttributes({
|
|
97
|
+
setAttributes({ colorBy: 'index' });
|
|
103
98
|
return null;
|
|
104
99
|
}
|
|
105
100
|
if (dimension1 != 'none' && dimension2 != 'none' && colorBy != 'id') {
|
|
106
|
-
setAttributes({
|
|
101
|
+
setAttributes({ colorBy: 'id' });
|
|
107
102
|
return null;
|
|
108
103
|
}
|
|
109
104
|
}
|
|
@@ -128,7 +123,6 @@ export const ChartColors = (props) => {
|
|
|
128
123
|
if (app != "csv") {
|
|
129
124
|
// All conditions for coloring by measures
|
|
130
125
|
if ((dimension2 == "none" && colorBy === "index" && swap) ||
|
|
131
|
-
(type == 'line') ||
|
|
132
126
|
(dimension1 == "none" && dimension2 == "none")) { //Multi measure colored by first dimension but swapped (Colored by Measure) or dimensionless bar charts
|
|
133
127
|
nextUseColors = "measure";
|
|
134
128
|
}
|
|
@@ -159,34 +153,34 @@ export const ChartColors = (props) => {
|
|
|
159
153
|
}
|
|
160
154
|
else {
|
|
161
155
|
if (!manualColors["csv"]) {
|
|
162
|
-
setAttributes({
|
|
156
|
+
setAttributes({ manualColors: { "csv": {} } });
|
|
163
157
|
}
|
|
164
158
|
}
|
|
165
|
-
prevStatus.current = { scheme, colorBy
|
|
159
|
+
prevStatus.current = { scheme, colorBy, dimension1, dimension2, useColors, app };
|
|
166
160
|
}, [scheme, dimension1, dimension2, colorBy, swap, app, type]);
|
|
167
|
-
const prevStatus = useRef(
|
|
161
|
+
const prevStatus = useRef();
|
|
168
162
|
const updateColor = (value, color) => {
|
|
169
163
|
const newColors = Object.assign({}, manualColors);
|
|
170
164
|
newColors[app][value] = color;
|
|
171
|
-
setAttributes({
|
|
165
|
+
setAttributes({ manualColors: newColors });
|
|
172
166
|
};
|
|
173
167
|
const initColors = (dimension) => {
|
|
174
|
-
const ds = allDimensions
|
|
168
|
+
const ds = allDimensions.filter(d => d.value == dimension);
|
|
175
169
|
const newColors = Object.assign({}, manualColors);
|
|
176
170
|
if (!newColors[app]) {
|
|
177
171
|
newColors[app] = {};
|
|
178
172
|
}
|
|
179
|
-
if (ds
|
|
173
|
+
if (ds.length > 0) {
|
|
180
174
|
const { type } = ds[0];
|
|
181
|
-
const cat = allCategories
|
|
182
|
-
if (cat
|
|
175
|
+
const cat = allCategories.filter(a => a.type === type);
|
|
176
|
+
if (cat.length > 0) {
|
|
183
177
|
cat[0].items.forEach(item => {
|
|
184
178
|
if (!newColors[app][item.code]) {
|
|
185
179
|
newColors[app][item.code] = item.categoryStyle ? item.categoryStyle.color : "#eeeeee";
|
|
186
180
|
}
|
|
187
181
|
});
|
|
188
182
|
}
|
|
189
|
-
setAttributes({
|
|
183
|
+
setAttributes({ manualColors: newColors });
|
|
190
184
|
}
|
|
191
185
|
};
|
|
192
186
|
const initMeasuresColors = () => {
|
|
@@ -203,20 +197,20 @@ export const ChartColors = (props) => {
|
|
|
203
197
|
}
|
|
204
198
|
});
|
|
205
199
|
}
|
|
206
|
-
setAttributes({
|
|
200
|
+
setAttributes({ manualColors: newColors });
|
|
207
201
|
};
|
|
208
202
|
const combinedCatColors = (dimension1, dimension2) => {
|
|
209
203
|
if (manualColors[app]) {
|
|
210
|
-
const ds1 = allDimensions
|
|
211
|
-
const ds2 = allDimensions
|
|
212
|
-
if (ds1
|
|
204
|
+
const ds1 = allDimensions.filter(d => d.value == dimension1);
|
|
205
|
+
const ds2 = allDimensions.filter(d => d.value == dimension2);
|
|
206
|
+
if (ds1.length > 0 && ds2.length > 0) {
|
|
213
207
|
const { type } = ds1[0];
|
|
214
208
|
const { type: type2 } = ds2[0];
|
|
215
|
-
const cat = allCategories
|
|
216
|
-
const cat2 = allCategories
|
|
209
|
+
const cat = allCategories.filter(a => a.type === type);
|
|
210
|
+
const cat2 = allCategories.filter(a => a.type === type2);
|
|
217
211
|
const list = [];
|
|
218
|
-
cat
|
|
219
|
-
cat2
|
|
212
|
+
cat[0].items.sort((a, b) => a.position - b.position).forEach(c1 => {
|
|
213
|
+
cat2[0].items.sort((a, b) => a.position - b.position).forEach(c2 => {
|
|
220
214
|
list.push(React.createElement(PanelColorSettings, { colorSettings: [{
|
|
221
215
|
value: manualColors[app][c1.value + ' - ' + c2.value],
|
|
222
216
|
onChange: (color) => {
|
|
@@ -238,12 +232,12 @@ export const ChartColors = (props) => {
|
|
|
238
232
|
};
|
|
239
233
|
const catColors = (dimension) => {
|
|
240
234
|
if (manualColors[app]) {
|
|
241
|
-
const ds = allDimensions
|
|
242
|
-
if (ds
|
|
235
|
+
const ds = allDimensions.filter(d => d.value == dimension);
|
|
236
|
+
if (ds.length > 0) {
|
|
243
237
|
const { type } = ds[0];
|
|
244
|
-
const cat = allCategories
|
|
238
|
+
const cat = allCategories.filter(a => a.type === type);
|
|
245
239
|
if (cat && cat.length > 0) {
|
|
246
|
-
const list = cat[0].items.sort((a, b) =>
|
|
240
|
+
const list = cat[0].items.filter(c => c.code !== null && c.code !== undefined && c.code !== "").sort((a, b) => b.position - a.position).map(item => {
|
|
247
241
|
return React.createElement(PanelColorSettings, { colorSettings: [{
|
|
248
242
|
value: manualColors[app][item.code],
|
|
249
243
|
onChange: (color) => {
|
|
@@ -258,7 +252,7 @@ export const ChartColors = (props) => {
|
|
|
258
252
|
});
|
|
259
253
|
const dimensions = [dimension1, dimension2].filter(f => f != '' && f != "none");
|
|
260
254
|
let selectedMeasures = [];
|
|
261
|
-
allMeasures
|
|
255
|
+
allMeasures.forEach(m => {
|
|
262
256
|
if (measures[app] && measures[app][m.value] && measures[app][m.value].selected) {
|
|
263
257
|
selectedMeasures.push(m.value);
|
|
264
258
|
}
|
|
@@ -319,22 +313,15 @@ export const ChartColors = (props) => {
|
|
|
319
313
|
}
|
|
320
314
|
return null;
|
|
321
315
|
};
|
|
322
|
-
const csvColors = (
|
|
316
|
+
const csvColors = () => {
|
|
323
317
|
const data = Papa.parse(csv, { header: true, dynamicTyping: true });
|
|
324
318
|
const values = [];
|
|
325
319
|
if (colorBy === "index" && type != 'line') {
|
|
326
|
-
const field = data.meta
|
|
327
|
-
|
|
328
|
-
values.push(...data.data.map((d) => d[field]));
|
|
329
|
-
}
|
|
320
|
+
const field = data.meta.fields[0];
|
|
321
|
+
values.push(...data.data.map(d => d[field]));
|
|
330
322
|
}
|
|
331
323
|
if (colorBy === "id" || type == 'line') {
|
|
332
|
-
|
|
333
|
-
if (fields) {
|
|
334
|
-
// Convert string fields to numbers before pushing to values array
|
|
335
|
-
const numericFields = fields.map(field => Number(field));
|
|
336
|
-
values.push(...numericFields);
|
|
337
|
-
}
|
|
324
|
+
values.push(...data.meta.fields.slice(1));
|
|
338
325
|
}
|
|
339
326
|
if (colorBy === "values") {
|
|
340
327
|
values.push(0, 100);
|
|
@@ -345,41 +332,41 @@ export const ChartColors = (props) => {
|
|
|
345
332
|
value: manualColors[app][v],
|
|
346
333
|
onChange: (color) => {
|
|
347
334
|
if (color) {
|
|
348
|
-
updateColor(v
|
|
335
|
+
updateColor(v, color);
|
|
349
336
|
}
|
|
350
|
-
}, label: __(v
|
|
337
|
+
}, label: __(v)
|
|
351
338
|
}] });
|
|
352
339
|
});
|
|
353
340
|
}
|
|
354
341
|
return null;
|
|
355
342
|
};
|
|
356
343
|
const elements = [];
|
|
357
|
-
if (type == 'bar') {
|
|
344
|
+
if (type == 'bar' || type == 'line') {
|
|
358
345
|
elements.push(React.createElement(PanelRow, null,
|
|
359
|
-
React.createElement(SelectControl, {
|
|
360
|
-
setAttributes({
|
|
346
|
+
React.createElement(SelectControl, { label: __('Color By'), value: [colorBy], onChange: (colorBy) => {
|
|
347
|
+
setAttributes({ colorBy });
|
|
361
348
|
if (colorBy === 'index' || colorBy === 'id') {
|
|
362
|
-
setAttributes({
|
|
349
|
+
setAttributes({ colorBy });
|
|
363
350
|
}
|
|
364
351
|
if (colorBy === 'values') {
|
|
365
|
-
setAttributes({
|
|
352
|
+
setAttributes({ scheme: "blues", colorBy });
|
|
366
353
|
}
|
|
367
354
|
}, options: colorOptions })));
|
|
368
355
|
}
|
|
369
356
|
return [
|
|
370
357
|
...elements,
|
|
371
358
|
React.createElement(PanelRow, null,
|
|
372
|
-
React.createElement(SelectControl, {
|
|
373
|
-
setAttributes({
|
|
359
|
+
React.createElement(SelectControl, { label: __('Color Scheme'), value: [scheme], onChange: (value) => {
|
|
360
|
+
setAttributes({ scheme: value });
|
|
374
361
|
}, options: options })),
|
|
375
362
|
(scheme == "plain_color") && React.createElement(PanelRow, null,
|
|
376
363
|
React.createElement(PanelColorSettings, { title: __('Color settings'), colorSettings: [{
|
|
377
364
|
value: decodeURIComponent(barColor), onChange: (color) => {
|
|
378
365
|
if (color) {
|
|
379
|
-
setAttributes({
|
|
366
|
+
setAttributes({ barColor: encodeURIComponent(color) });
|
|
380
367
|
}
|
|
381
368
|
else {
|
|
382
|
-
setAttributes({
|
|
369
|
+
setAttributes({ barColor: null });
|
|
383
370
|
}
|
|
384
371
|
}, label: __('Plain color')
|
|
385
372
|
}] })),
|
package/build/ChartLegends.d.ts
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type LegendPosition = 'left' | 'top' | 'right' | 'bottom';
|
|
3
|
-
export type LegendProps = {
|
|
4
|
-
legendPosition?: LegendPosition;
|
|
5
|
-
setAttributes: (attributes: {
|
|
6
|
-
showLegends: boolean;
|
|
7
|
-
legendPosition: LegendPosition;
|
|
8
|
-
marginLeft: number;
|
|
9
|
-
marginRight: number;
|
|
10
|
-
marginBottom: number;
|
|
11
|
-
marginTop: number;
|
|
12
|
-
legendLabel: string;
|
|
13
|
-
useLabelBackground: boolean;
|
|
14
|
-
useCheckBoxBackground: boolean;
|
|
15
|
-
legendLabelColor: string | null;
|
|
16
|
-
reverseLegend: boolean;
|
|
17
|
-
}) => void;
|
|
18
|
-
attributes: {
|
|
19
|
-
showLegends: boolean;
|
|
20
|
-
legendPosition: LegendPosition;
|
|
21
|
-
marginLeft: number;
|
|
22
|
-
marginRight: number;
|
|
23
|
-
marginBottom: number;
|
|
24
|
-
marginTop: number;
|
|
25
|
-
legendLabel: string;
|
|
26
|
-
useLabelBackground: boolean;
|
|
27
|
-
useCheckBoxBackground: boolean;
|
|
28
|
-
legendLabelColor: string;
|
|
29
|
-
reverseLegend: boolean;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export declare const ChartLegends: (props: LegendProps) => React.JSX.Element[];
|
|
1
|
+
export function ChartLegends(props: any): import("react").JSX.Element[];
|
|
33
2
|
export default ChartLegends;
|
package/build/ChartLegends.js
CHANGED
|
@@ -1,65 +1,50 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { Button, ButtonGroup, PanelBody, PanelRow, RangeControl, TextControl, ToggleControl } from '@wordpress/components';
|
|
3
2
|
import { __ } from '@wordpress/i18n';
|
|
4
3
|
import { PanelColorSettings } from '@wordpress/block-editor';
|
|
5
4
|
export const ChartLegends = (props) => {
|
|
6
|
-
const { setAttributes, legendPosition,
|
|
7
|
-
const { showLegends, marginLeft, marginRight, marginBottom, marginTop, legendLabel, useLabelBackground, useCheckBoxBackground, legendLabelColor, reverseLegend } = attributes;
|
|
5
|
+
const { setAttributes, attributes: { showLegends, legendPosition, marginLeft, marginRight, marginBottom, marginTop, legendLabel, useLabelBackground, useCheckBoxBackground, legendLabelColor, reverseLegend, showLegendsInColumns, numberOfLegendColumns } } = props;
|
|
8
6
|
return [
|
|
9
7
|
React.createElement(PanelBody, { initialOpen: false, title: __("Margins") },
|
|
10
8
|
React.createElement(PanelRow, null,
|
|
11
|
-
React.createElement(RangeControl, { label: __('Margin Bottom (Space between chart area and bottom border)'), value: marginBottom, onChange: (marginBottom) => {
|
|
12
|
-
if (marginBottom) {
|
|
13
|
-
setAttributes({ ...attributes, marginBottom });
|
|
14
|
-
}
|
|
15
|
-
}, min: 0, max: 500 })),
|
|
9
|
+
React.createElement(RangeControl, { label: __('Margin Bottom (Space between chart area and bottom border)'), value: marginBottom, onChange: (marginBottom) => setAttributes({ marginBottom }), min: 0, max: 500 })),
|
|
16
10
|
React.createElement(PanelRow, null,
|
|
17
|
-
React.createElement(RangeControl, { label: __('Margin Left (Space between chart area and left border)'), value: marginLeft, initialPosition: 0, onChange: (marginLeft) => {
|
|
18
|
-
if (marginLeft) {
|
|
19
|
-
setAttributes({ ...attributes, marginLeft });
|
|
20
|
-
}
|
|
21
|
-
}, step: 1, min: 0, max: 500 })),
|
|
11
|
+
React.createElement(RangeControl, { label: __('Margin Left (Space between chart area and left border)'), value: marginLeft, initialPosition: 0, onChange: (marginLeft) => setAttributes({ marginLeft }), step: 1, min: 0, max: 500 })),
|
|
22
12
|
React.createElement(PanelRow, null,
|
|
23
|
-
React.createElement(RangeControl, { label: __('Margin Right'), value: marginRight, onChange: (marginRight) => {
|
|
24
|
-
if (marginRight) {
|
|
25
|
-
setAttributes({ ...attributes, marginRight });
|
|
26
|
-
}
|
|
27
|
-
}, min: 0, max: 500 })),
|
|
13
|
+
React.createElement(RangeControl, { label: __('Margin Right'), value: marginRight, onChange: (marginRight) => setAttributes({ marginRight }), min: 0, max: 500 })),
|
|
28
14
|
React.createElement(PanelRow, null,
|
|
29
|
-
React.createElement(RangeControl, { label: __('Margin Top'), value: marginTop, onChange: (marginTop) => {
|
|
30
|
-
if (marginTop) {
|
|
31
|
-
setAttributes({ ...attributes, marginTop });
|
|
32
|
-
}
|
|
33
|
-
}, min: 0, max: 500 }))),
|
|
15
|
+
React.createElement(RangeControl, { label: __('Margin Top'), value: marginTop, onChange: (marginTop) => setAttributes({ marginTop }), min: 0, max: 500 }))),
|
|
34
16
|
React.createElement(PanelBody, { initialOpen: false, title: __("Legends") },
|
|
35
17
|
React.createElement(PanelRow, null,
|
|
36
|
-
React.createElement(ToggleControl, { label: __("Show Legends"), checked: showLegends, onChange: () => setAttributes({
|
|
18
|
+
React.createElement(ToggleControl, { label: __("Show Legends"), checked: showLegends, onChange: () => setAttributes({ showLegends: !showLegends }) })),
|
|
19
|
+
showLegends && React.createElement(PanelRow, null,
|
|
20
|
+
React.createElement(ToggleControl, { label: __("Show Legends in Columns"), checked: showLegendsInColumns, onChange: () => setAttributes({ showLegendsInColumns: !showLegendsInColumns }) })),
|
|
21
|
+
showLegends && showLegendsInColumns && React.createElement(PanelRow, null,
|
|
22
|
+
React.createElement(TextControl, { label: __('Number of Legend Columns'), value: numberOfLegendColumns, onChange: (numberOfLegendColumns) => setAttributes({ numberOfLegendColumns }), type: "number", min: 1, max: 10 })),
|
|
37
23
|
showLegends &&
|
|
38
24
|
React.createElement(PanelRow, null,
|
|
39
|
-
React.createElement(ToggleControl, { label: __("Reverse legend order"), checked: reverseLegend, onChange: () => setAttributes({
|
|
25
|
+
React.createElement(ToggleControl, { label: __("Reverse legend order"), checked: reverseLegend, onChange: () => setAttributes({ reverseLegend: !reverseLegend }) })),
|
|
40
26
|
showLegends && React.createElement(PanelRow, null,
|
|
41
|
-
React.createElement(ToggleControl, { label: __("Use Label Background"), checked: useLabelBackground, onChange:
|
|
27
|
+
React.createElement(ToggleControl, { label: __("Use Label Background"), checked: useLabelBackground, onChange: e => setAttributes({ useLabelBackground: !useLabelBackground }) })),
|
|
42
28
|
showLegends && React.createElement(PanelRow, null,
|
|
43
|
-
React.createElement(ToggleControl, { label: __("Use Checkbox Background"), checked: useCheckBoxBackground, onChange:
|
|
29
|
+
React.createElement(ToggleControl, { label: __("Use Checkbox Background"), checked: useCheckBoxBackground, onChange: e => setAttributes({ useCheckBoxBackground: !useCheckBoxBackground }) })),
|
|
44
30
|
showLegends && React.createElement(PanelRow, null,
|
|
45
31
|
React.createElement(ButtonGroup, null,
|
|
46
|
-
React.createElement(Button, {
|
|
47
|
-
React.createElement(Button, {
|
|
48
|
-
React.createElement(Button, {
|
|
49
|
-
React.createElement(Button, {
|
|
32
|
+
React.createElement(Button, { isPrimary: legendPosition == 'left', isSecondary: legendPosition != 'left', onClick: e => setAttributes({ legendPosition: "left" }) }, __("Left")),
|
|
33
|
+
React.createElement(Button, { isPrimary: legendPosition == 'top', isSecondary: legendPosition != 'top', onClick: e => setAttributes({ legendPosition: "top" }) }, __("Top")),
|
|
34
|
+
React.createElement(Button, { isPrimary: legendPosition == 'right', isSecondary: legendPosition != 'right', onClick: e => setAttributes({ legendPosition: "right" }) }, __("Right")),
|
|
35
|
+
React.createElement(Button, { isPrimary: legendPosition == 'bottom', isSecondary: legendPosition != 'bottom', onClick: e => setAttributes({ legendPosition: "bottom" }) }, __("Bottom")))),
|
|
50
36
|
showLegends && React.createElement(PanelRow, null,
|
|
51
|
-
React.createElement(TextControl, { label: __('Legends Title'), value: legendLabel, onChange: (legendLabel) => setAttributes({
|
|
37
|
+
React.createElement(TextControl, { label: __('Legends Title'), value: legendLabel, onChange: (legendLabel) => setAttributes({ legendLabel }) })),
|
|
52
38
|
showLegends && React.createElement(PanelRow, null,
|
|
53
39
|
React.createElement(PanelColorSettings, { title: __('Legends text color'), colorSettings: [
|
|
54
40
|
{
|
|
55
|
-
|
|
56
|
-
value: decodeURIComponent(legendLabelColor ? encodeURIComponent(decodeURIComponent(legendLabelColor)) : "#000000"),
|
|
41
|
+
value: decodeURIComponent(legendLabelColor ? legendLabelColor : "#000000"),
|
|
57
42
|
onChange: (color) => {
|
|
58
43
|
if (color) {
|
|
59
|
-
setAttributes({
|
|
44
|
+
setAttributes({ legendLabelColor: encodeURIComponent(color) });
|
|
60
45
|
}
|
|
61
46
|
else {
|
|
62
|
-
setAttributes({
|
|
47
|
+
setAttributes({ legendLabelColor: null });
|
|
63
48
|
}
|
|
64
49
|
},
|
|
65
50
|
label: __("")
|
package/build/ChartMeasures.d.ts
CHANGED
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Measure } from './types.js';
|
|
3
|
-
export type ChartMeasuresProps = {
|
|
4
|
-
onMeasuresChange: (measure: string) => void;
|
|
5
|
-
onFormatChange: (format: string, field: string) => void;
|
|
6
|
-
onUseCustomAxisFormatChange: (value: boolean) => void;
|
|
7
|
-
onSetSingleMeasure: (measure: string) => void;
|
|
8
|
-
onCustomLabelToggleChange: (measure: string) => void;
|
|
9
|
-
onCustomLabelChange: (measure: string, value: string) => void;
|
|
10
|
-
allMeasures: any[];
|
|
11
|
-
setAttributes: (attributes: any) => void;
|
|
12
|
-
title: string;
|
|
13
|
-
attributes: {
|
|
14
|
-
panelStatus: any;
|
|
15
|
-
measures: Measure[];
|
|
16
|
-
dimension1: string | null;
|
|
17
|
-
dimension2: string | null;
|
|
18
|
-
type: string;
|
|
19
|
-
app: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export declare const ChartMeasures: (props: ChartMeasuresProps) => React.JSX.Element;
|
|
1
|
+
export function ChartMeasures(props: any): import("react").JSX.Element;
|
|
23
2
|
export default ChartMeasures;
|
package/build/ChartMeasures.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { __ } from '@wordpress/i18n';
|
|
3
2
|
import { CheckboxControl, PanelBody, PanelRow, SelectControl, ToggleControl, TextControl } from '@wordpress/components';
|
|
4
3
|
import Format from './Format';
|
|
5
|
-
import { togglePanel } from "./Util
|
|
6
|
-
import { getTranslation } from "./APIutils
|
|
4
|
+
import { togglePanel } from "./Util";
|
|
5
|
+
import { getTranslation } from "./APIutils";
|
|
7
6
|
const defaultFormat = {
|
|
8
7
|
"style": "percent",
|
|
9
8
|
"minimumFractionDigits": 1,
|
|
@@ -88,7 +87,7 @@ export const ChartMeasures = (props) => {
|
|
|
88
87
|
|
|
89
88
|
*/
|
|
90
89
|
((type == 'bar' && dimension2 != 'none') || (type == 'pie' && (dimension1 != 'none' || dimension2 != 'none'))) && allMeasures && [...new Set(allMeasures.map(p => getTranslation(p.group)))].map(g => {
|
|
91
|
-
return (React.createElement(PanelBody, { initialOpen: panelStatus[g], onToggle: e => togglePanel(g, panelStatus, setAttributes), title: `${g} (${countSelected(g)} / ${allMeasures.filter(f =>
|
|
90
|
+
return (React.createElement(PanelBody, { initialOpen: panelStatus[g], onToggle: e => togglePanel(g, panelStatus, setAttributes), title: `${g} (${countSelected(g)} / ${allMeasures.filter(f => f.group === g).length} ) ` }, allMeasures.filter(f => getTranslation(f.group) === g)
|
|
92
91
|
.map(m => React.createElement(PanelRow, null,
|
|
93
92
|
React.createElement(MeasureOptions, { single: true, measure: m })))));
|
|
94
93
|
}),
|
package/build/Constants.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
export
|
|
2
|
-
format
|
|
3
|
-
style: string;
|
|
4
|
-
minimumFractionDigits: number;
|
|
5
|
-
maximumFractionDigits: number;
|
|
6
|
-
}
|
|
7
|
-
customFormat
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
export namespace DEFAULT_FORMAT_SETTINGS {
|
|
2
|
+
namespace format {
|
|
3
|
+
let style: string;
|
|
4
|
+
let minimumFractionDigits: number;
|
|
5
|
+
let maximumFractionDigits: number;
|
|
6
|
+
}
|
|
7
|
+
namespace customFormat {
|
|
8
|
+
let style_1: string;
|
|
9
|
+
export { style_1 as style };
|
|
10
|
+
let minimumFractionDigits_1: number;
|
|
11
|
+
export { minimumFractionDigits_1 as minimumFractionDigits };
|
|
12
|
+
let maximumFractionDigits_1: number;
|
|
13
|
+
export { maximumFractionDigits_1 as maximumFractionDigits };
|
|
14
|
+
}
|
|
15
|
+
let useCustomAxisFormat: boolean;
|
|
16
|
+
}
|
|
17
|
+
export const BLOCKS_CATEGORY: "wp-react-lib-blocks";
|
|
18
|
+
export const BLOCKS_NS: "viz";
|
package/build/DataFilters.d.ts
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Filter } from './types';
|
|
3
|
-
export type DataFiltersProps = {
|
|
4
|
-
allCategories: any[];
|
|
5
|
-
allFilters: any[];
|
|
6
|
-
onChange?: () => void;
|
|
7
|
-
attributes?: {
|
|
8
|
-
filters: Filter[];
|
|
9
|
-
};
|
|
10
|
-
setAttributes: (attributes: any) => void;
|
|
11
|
-
};
|
|
12
|
-
export declare const DataFilters: (props: DataFiltersProps) => React.JSX.Element;
|
|
1
|
+
export function DataFilters(props: any): import("react").JSX.Element;
|
|
13
2
|
export default DataFilters;
|
package/build/DataFilters.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { Button, PanelBody, PanelRow, SelectControl, ToggleControl } from "@wordpress/components";
|
|
3
2
|
import { __ } from '@wordpress/i18n';
|
|
4
3
|
export const DataFilters = (props) => {
|
|
5
4
|
const updateFilterParam = (param, idx) => {
|
|
6
|
-
const { attributes, setAttributes, allFilters } = props;
|
|
7
|
-
const filters = attributes?.filters || [];
|
|
5
|
+
const { attributes: { filters }, setAttributes, allFilters } = props;
|
|
8
6
|
const newFilters = filters.slice();
|
|
9
7
|
const selected = allFilters.filter(f => f.param === param)[0];
|
|
10
8
|
newFilters[idx] = { ...selected, value: [] };
|
|
11
9
|
setAttributes({ filters: newFilters });
|
|
12
10
|
};
|
|
13
11
|
const updateFilterValue = (value, idx) => {
|
|
14
|
-
const { attributes, setAttributes, onChange } = props;
|
|
15
|
-
const filters = attributes?.filters || [];
|
|
12
|
+
const { attributes: { filters }, setAttributes, onChange } = props;
|
|
16
13
|
const selected = filters[idx];
|
|
17
14
|
let values = selected.value;
|
|
18
15
|
if (values.indexOf(value) > -1) {
|
|
@@ -24,11 +21,10 @@ export const DataFilters = (props) => {
|
|
|
24
21
|
const newFilters = filters.slice();
|
|
25
22
|
newFilters[idx].value = values;
|
|
26
23
|
setAttributes({ filters: newFilters });
|
|
27
|
-
onChange
|
|
24
|
+
onChange();
|
|
28
25
|
};
|
|
29
26
|
const addFilter = () => {
|
|
30
|
-
const { attributes, setAttributes, allFilters } = props;
|
|
31
|
-
const filters = attributes?.filters || [];
|
|
27
|
+
const { attributes: { filters }, setAttributes, allFilters } = props;
|
|
32
28
|
let index = filters.length > allFilters.length ? allFilters.length : filters.length;
|
|
33
29
|
const newFilter = (allFilters && allFilters.length > 0) ? {
|
|
34
30
|
...allFilters[index],
|
|
@@ -39,8 +35,7 @@ export const DataFilters = (props) => {
|
|
|
39
35
|
setAttributes({ filters: newFilters });
|
|
40
36
|
};
|
|
41
37
|
const removeFilter = (f) => {
|
|
42
|
-
const { attributes, setAttributes } = props;
|
|
43
|
-
const filters = attributes?.filters || [];
|
|
38
|
+
const { attributes: { filters }, setAttributes } = props;
|
|
44
39
|
let newFilters = filters.slice(0, -1);
|
|
45
40
|
setAttributes({ filters: newFilters });
|
|
46
41
|
};
|
|
@@ -69,7 +64,7 @@ export const DataFilters = (props) => {
|
|
|
69
64
|
const CategoricalFilter = ({ value, index, items, onUpdateFilterValue }) => {
|
|
70
65
|
if (items) {
|
|
71
66
|
const sortedItems = items.sort(function (a, b) {
|
|
72
|
-
if (a.position !== undefined && b.position !== undefined) {
|
|
67
|
+
if (a.position !== undefined && b.position !== undefined && a.position !== b.position) {
|
|
73
68
|
return a.position - b.position;
|
|
74
69
|
}
|
|
75
70
|
let aValue = a.value ? a.value.toLowerCase() : "";
|
|
@@ -77,16 +72,17 @@ export const DataFilters = (props) => {
|
|
|
77
72
|
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
|
|
78
73
|
});
|
|
79
74
|
return sortedItems.map(v => React.createElement(PanelRow, null,
|
|
80
|
-
React.createElement(ToggleControl, { label: v.value, checked: value.indexOf(v.id) > -1, onChange: e => {
|
|
75
|
+
React.createElement(ToggleControl, { label: v.value, checked: value.indexOf(v.id) > -1, onChange: e => {
|
|
76
|
+
onUpdateFilterValue(v.id, index);
|
|
77
|
+
} })));
|
|
81
78
|
}
|
|
82
79
|
else {
|
|
83
80
|
return null;
|
|
84
81
|
}
|
|
85
82
|
};
|
|
86
|
-
const { allFilters, attributes } = props;
|
|
87
|
-
const filters = attributes?.filters || [];
|
|
83
|
+
const { allFilters, attributes: { filters, } } = props;
|
|
88
84
|
return React.createElement(PanelBody, { initialOpen: false, title: __("Filters") },
|
|
89
|
-
filters.
|
|
85
|
+
filters.map((f, index) => {
|
|
90
86
|
return (React.createElement(PanelBody, { initialOpen: true, title: __(`Filter - ${f.label}`) },
|
|
91
87
|
React.createElement(FilterSelector, { param: f.param, index: index, options: allFilters, onUpdateFilterParam: updateFilterParam }),
|
|
92
88
|
React.createElement(CategoricalFilter, { value: f.value, index: index, items: items(f.type), onUpdateFilterValue: updateFilterValue })));
|
package/build/Format.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export type FormatProps = {
|
|
1
|
+
export function Format({ format, title, onFormatChange, onUseCustomAxisFormatChange, customFormat, hiddenCustomAxisFormat, useCustomAxisFormat }: {
|
|
3
2
|
format: any;
|
|
4
|
-
title
|
|
5
|
-
onFormatChange:
|
|
6
|
-
onUseCustomAxisFormatChange
|
|
7
|
-
customFormat
|
|
8
|
-
hiddenCustomAxisFormat
|
|
9
|
-
useCustomAxisFormat
|
|
10
|
-
};
|
|
11
|
-
export declare const Format: ({ format, title, onFormatChange, onUseCustomAxisFormatChange, customFormat, hiddenCustomAxisFormat, useCustomAxisFormat }: FormatProps) => React.JSX.Element[];
|
|
3
|
+
title: any;
|
|
4
|
+
onFormatChange: any;
|
|
5
|
+
onUseCustomAxisFormatChange: any;
|
|
6
|
+
customFormat: any;
|
|
7
|
+
hiddenCustomAxisFormat: any;
|
|
8
|
+
useCustomAxisFormat: any;
|
|
9
|
+
}): import("react").JSX.Element[];
|
|
12
10
|
export default Format;
|
package/build/Format.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { PanelRow, SelectControl, TextControl, ToggleControl, PanelBody } from '@wordpress/components';
|
|
3
2
|
import { __ } from '@wordpress/i18n';
|
|
4
3
|
const styles = [
|
|
@@ -354,7 +353,7 @@ export const Format = ({ format, title, onFormatChange, onUseCustomAxisFormatCha
|
|
|
354
353
|
return [
|
|
355
354
|
React.createElement(PanelBody, { initialOpen: true, title: __("Default Format") },
|
|
356
355
|
React.createElement(PanelRow, null,
|
|
357
|
-
React.createElement(SelectControl, {
|
|
356
|
+
React.createElement(SelectControl, { label: __('Style', "dg"), value: [format.style], onChange: (value) => {
|
|
358
357
|
onChangeFormat(value, DEFAULT_FORMAT);
|
|
359
358
|
}, options: styles })),
|
|
360
359
|
React.createElement(React.Fragment, null, format.style === "currency" && React.createElement(PanelRow, null,
|
|
@@ -362,14 +361,14 @@ export const Format = ({ format, title, onFormatChange, onUseCustomAxisFormatCha
|
|
|
362
361
|
onCurrencyChange(value, DEFAULT_FORMAT);
|
|
363
362
|
}, value: format.currency, options: currencies }))),
|
|
364
363
|
React.createElement(PanelRow, null,
|
|
365
|
-
React.createElement(TextControl, { type: "
|
|
364
|
+
React.createElement(TextControl, { type: "Number", label: __("Decimal Points", "dg"), onChange: (value) => {
|
|
366
365
|
onDecimalChange(value, DEFAULT_FORMAT);
|
|
367
366
|
}, value: format.minimumFractionDigits }))),
|
|
368
367
|
React.createElement(React.Fragment, null, !hiddenCustomAxisFormat && React.createElement(PanelRow, null,
|
|
369
|
-
React.createElement(ToggleControl, { label: __("Use Custom Axis Format", "dg"), checked: useCustomAxisFormat, onChange: (value) => onUseCustomAxisFormatChange
|
|
368
|
+
React.createElement(ToggleControl, { label: __("Use Custom Axis Format", "dg"), checked: useCustomAxisFormat, onChange: (value) => onUseCustomAxisFormatChange(value) }))),
|
|
370
369
|
React.createElement(React.Fragment, null, useCustomAxisFormat && React.createElement(PanelBody, { initialOpen: true, title: __("Custom Axis Format") },
|
|
371
370
|
React.createElement(PanelRow, null,
|
|
372
|
-
React.createElement(SelectControl, {
|
|
371
|
+
React.createElement(SelectControl, { label: __('Style', "dg"), value: [customFormat.style], onChange: (value) => {
|
|
373
372
|
onChangeFormat(value, CUSTOM_FORMAT);
|
|
374
373
|
}, options: styles })),
|
|
375
374
|
React.createElement(React.Fragment, null, customFormat.style === "currency" && React.createElement(PanelRow, null,
|
|
@@ -377,7 +376,7 @@ export const Format = ({ format, title, onFormatChange, onUseCustomAxisFormatCha
|
|
|
377
376
|
onCurrencyChange(value, CUSTOM_FORMAT);
|
|
378
377
|
}, value: customFormat.currency, options: currencies }))),
|
|
379
378
|
React.createElement(PanelRow, null,
|
|
380
|
-
React.createElement(TextControl, { type: "
|
|
379
|
+
React.createElement(TextControl, { type: "Number", label: __("Decimal Points", "dg"), onChange: (value) => {
|
|
381
380
|
onDecimalChange(value, CUSTOM_FORMAT);
|
|
382
381
|
}, value: customFormat.minimumFractionDigits }))))
|
|
383
382
|
];
|