@devgateway/dvz-wp-commons 1.2.0 → 1.3.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.cjs +479 -0
- package/build/APIConfig.d.ts +12 -0
- package/build/APIConfig.js +367 -283
- package/build/APIutils.cjs +54 -0
- package/build/APIutils.js +7 -1
- package/build/Blocks.cjs +672 -0
- package/build/Blocks.d.ts +14 -1
- package/build/Blocks.js +523 -330
- package/build/CSVSourceConfig.cjs +99 -0
- package/build/CSVSourceConfig.js +63 -46
- package/build/ChartColors.cjs +593 -0
- package/build/ChartColors.d.ts +0 -1
- package/build/ChartColors.js +430 -366
- package/build/ChartLegends.cjs +157 -0
- package/build/ChartLegends.d.ts +0 -1
- package/build/ChartLegends.js +173 -54
- package/build/ChartMeasures.cjs +192 -0
- package/build/ChartMeasures.d.ts +0 -1
- package/build/ChartMeasures.js +197 -109
- package/build/Constants.cjs +21 -0
- package/build/Constants.js +3 -1
- package/build/DataFilters.cjs +176 -0
- package/build/DataFilters.js +100 -89
- package/build/Format.cjs +1038 -0
- package/build/Format.js +428 -378
- package/build/MapCSVSourceConfig.cjs +36 -0
- package/build/MapCSVSourceConfig.js +19 -8
- package/build/Measures.cjs +196 -0
- package/build/Measures.js +204 -108
- package/build/MobileConfigUtils.cjs +92 -0
- package/build/MobileConfigUtils.js +19 -8
- package/build/Tooltip.cjs +63 -0
- package/build/Tooltip.d.ts +1 -3
- package/build/Tooltip.js +27 -51
- package/build/Util.cjs +29 -0
- package/build/Util.js +7 -7
- package/build/hooks/index.cjs +1 -0
- package/build/hooks/index.js +0 -3
- package/build/icons/Chart.cjs +49 -0
- package/build/icons/Chart.d.ts +1 -2
- package/build/icons/Chart.js +10 -11
- package/build/icons/Generic.cjs +24 -0
- package/build/icons/Generic.d.ts +1 -2
- package/build/icons/Generic.js +25 -4
- package/build/icons/index.cjs +19 -0
- package/build/icons/index.js +2 -2
- package/build/index.cjs +225 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +47 -16
- package/package.json +16 -7
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChartLegends = void 0;
|
|
7
|
+
var _components = require("@wordpress/components");
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
10
|
+
const ChartLegends = props => {
|
|
11
|
+
const {
|
|
12
|
+
setAttributes,
|
|
13
|
+
attributes: {
|
|
14
|
+
showLegends,
|
|
15
|
+
legendPosition,
|
|
16
|
+
marginLeft,
|
|
17
|
+
marginRight,
|
|
18
|
+
marginBottom,
|
|
19
|
+
marginTop,
|
|
20
|
+
legendLabel,
|
|
21
|
+
useLabelBackground,
|
|
22
|
+
useCheckBoxBackground,
|
|
23
|
+
legendLabelColor,
|
|
24
|
+
reverseLegend,
|
|
25
|
+
showLegendsInColumns,
|
|
26
|
+
numberOfLegendColumns
|
|
27
|
+
}
|
|
28
|
+
} = props;
|
|
29
|
+
return [/* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
30
|
+
initialOpen: false,
|
|
31
|
+
title: (0, _i18n.__)("Margins")
|
|
32
|
+
}, /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.RangeControl, {
|
|
33
|
+
label: (0, _i18n.__)("Margin Bottom (Space between chart area and bottom border)"),
|
|
34
|
+
value: marginBottom,
|
|
35
|
+
onChange: marginBottom2 => setAttributes({
|
|
36
|
+
marginBottom: marginBottom2
|
|
37
|
+
}),
|
|
38
|
+
min: 0,
|
|
39
|
+
max: 500
|
|
40
|
+
})), /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.RangeControl, {
|
|
41
|
+
label: (0, _i18n.__)("Margin Left (Space between chart area and left border)"),
|
|
42
|
+
value: marginLeft,
|
|
43
|
+
initialPosition: 0,
|
|
44
|
+
onChange: marginLeft2 => setAttributes({
|
|
45
|
+
marginLeft: marginLeft2
|
|
46
|
+
}),
|
|
47
|
+
step: 1,
|
|
48
|
+
min: 0,
|
|
49
|
+
max: 500
|
|
50
|
+
})), /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.RangeControl, {
|
|
51
|
+
label: (0, _i18n.__)("Margin Right"),
|
|
52
|
+
value: marginRight,
|
|
53
|
+
onChange: marginRight2 => setAttributes({
|
|
54
|
+
marginRight: marginRight2
|
|
55
|
+
}),
|
|
56
|
+
min: 0,
|
|
57
|
+
max: 500
|
|
58
|
+
})), /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.RangeControl, {
|
|
59
|
+
label: (0, _i18n.__)("Margin Top"),
|
|
60
|
+
value: marginTop,
|
|
61
|
+
onChange: marginTop2 => setAttributes({
|
|
62
|
+
marginTop: marginTop2
|
|
63
|
+
}),
|
|
64
|
+
min: 0,
|
|
65
|
+
max: 500
|
|
66
|
+
}))), /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
67
|
+
initialOpen: false,
|
|
68
|
+
title: (0, _i18n.__)("Legends")
|
|
69
|
+
}, /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.ToggleControl, {
|
|
70
|
+
label: (0, _i18n.__)("Show Legends"),
|
|
71
|
+
checked: showLegends,
|
|
72
|
+
onChange: () => setAttributes({
|
|
73
|
+
showLegends: !showLegends
|
|
74
|
+
})
|
|
75
|
+
})), showLegends && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.ToggleControl, {
|
|
76
|
+
label: (0, _i18n.__)("Show Legends in Columns"),
|
|
77
|
+
checked: showLegendsInColumns,
|
|
78
|
+
onChange: () => setAttributes({
|
|
79
|
+
showLegendsInColumns: !showLegendsInColumns
|
|
80
|
+
})
|
|
81
|
+
})), showLegends && showLegendsInColumns && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.TextControl, {
|
|
82
|
+
label: (0, _i18n.__)("Number of Legend Columns"),
|
|
83
|
+
value: numberOfLegendColumns,
|
|
84
|
+
onChange: numberOfLegendColumns2 => setAttributes({
|
|
85
|
+
numberOfLegendColumns: numberOfLegendColumns2
|
|
86
|
+
}),
|
|
87
|
+
type: "number",
|
|
88
|
+
min: 1,
|
|
89
|
+
max: 10
|
|
90
|
+
})), showLegends && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.ToggleControl, {
|
|
91
|
+
label: (0, _i18n.__)("Reverse legend order"),
|
|
92
|
+
checked: reverseLegend,
|
|
93
|
+
onChange: () => setAttributes({
|
|
94
|
+
reverseLegend: !reverseLegend
|
|
95
|
+
})
|
|
96
|
+
})), showLegends && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.ToggleControl, {
|
|
97
|
+
label: (0, _i18n.__)("Use Label Background"),
|
|
98
|
+
checked: useLabelBackground,
|
|
99
|
+
onChange: e => setAttributes({
|
|
100
|
+
useLabelBackground: !useLabelBackground
|
|
101
|
+
})
|
|
102
|
+
})), showLegends && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.ToggleControl, {
|
|
103
|
+
label: (0, _i18n.__)("Use Checkbox Background"),
|
|
104
|
+
checked: useCheckBoxBackground,
|
|
105
|
+
onChange: e => setAttributes({
|
|
106
|
+
useCheckBoxBackground: !useCheckBoxBackground
|
|
107
|
+
})
|
|
108
|
+
})), showLegends && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.ButtonGroup, null, /* @__PURE__ */React.createElement(_components.Button, {
|
|
109
|
+
isPrimary: legendPosition == "left",
|
|
110
|
+
isSecondary: legendPosition != "left",
|
|
111
|
+
onClick: e => setAttributes({
|
|
112
|
+
legendPosition: "left"
|
|
113
|
+
})
|
|
114
|
+
}, (0, _i18n.__)("Left")), /* @__PURE__ */React.createElement(_components.Button, {
|
|
115
|
+
isPrimary: legendPosition == "top",
|
|
116
|
+
isSecondary: legendPosition != "top",
|
|
117
|
+
onClick: e => setAttributes({
|
|
118
|
+
legendPosition: "top"
|
|
119
|
+
})
|
|
120
|
+
}, (0, _i18n.__)("Top")), /* @__PURE__ */React.createElement(_components.Button, {
|
|
121
|
+
isPrimary: legendPosition == "right",
|
|
122
|
+
isSecondary: legendPosition != "right",
|
|
123
|
+
onClick: e => setAttributes({
|
|
124
|
+
legendPosition: "right"
|
|
125
|
+
})
|
|
126
|
+
}, (0, _i18n.__)("Right")), /* @__PURE__ */React.createElement(_components.Button, {
|
|
127
|
+
isPrimary: legendPosition == "bottom",
|
|
128
|
+
isSecondary: legendPosition != "bottom",
|
|
129
|
+
onClick: e => setAttributes({
|
|
130
|
+
legendPosition: "bottom"
|
|
131
|
+
})
|
|
132
|
+
}, (0, _i18n.__)("Bottom")))), showLegends && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.TextControl, {
|
|
133
|
+
label: (0, _i18n.__)("Legends Title"),
|
|
134
|
+
value: legendLabel,
|
|
135
|
+
onChange: legendLabel2 => setAttributes({
|
|
136
|
+
legendLabel: legendLabel2
|
|
137
|
+
})
|
|
138
|
+
})), showLegends && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_blockEditor.PanelColorSettings, {
|
|
139
|
+
title: (0, _i18n.__)("Legends text color"),
|
|
140
|
+
colorSettings: [{
|
|
141
|
+
value: decodeURIComponent(legendLabelColor ? legendLabelColor : "#000000"),
|
|
142
|
+
onChange: color => {
|
|
143
|
+
if (color) {
|
|
144
|
+
setAttributes({
|
|
145
|
+
legendLabelColor: encodeURIComponent(color)
|
|
146
|
+
});
|
|
147
|
+
} else {
|
|
148
|
+
setAttributes({
|
|
149
|
+
legendLabelColor: null
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
label: (0, _i18n.__)("")
|
|
154
|
+
}]
|
|
155
|
+
}), " "))];
|
|
156
|
+
};
|
|
157
|
+
exports.ChartLegends = ChartLegends;
|
package/build/ChartLegends.d.ts
CHANGED
package/build/ChartLegends.js
CHANGED
|
@@ -1,56 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
ButtonGroup,
|
|
4
|
+
PanelBody,
|
|
5
|
+
PanelRow,
|
|
6
|
+
RangeControl,
|
|
7
|
+
TextControl,
|
|
8
|
+
ToggleControl
|
|
9
|
+
} from "@wordpress/components";
|
|
10
|
+
import { __ } from "@wordpress/i18n";
|
|
11
|
+
import { PanelColorSettings } from "@wordpress/block-editor";
|
|
4
12
|
export const ChartLegends = (props) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
13
|
+
const {
|
|
14
|
+
setAttributes,
|
|
15
|
+
attributes: {
|
|
16
|
+
showLegends,
|
|
17
|
+
legendPosition,
|
|
18
|
+
marginLeft,
|
|
19
|
+
marginRight,
|
|
20
|
+
marginBottom,
|
|
21
|
+
marginTop,
|
|
22
|
+
legendLabel,
|
|
23
|
+
useLabelBackground,
|
|
24
|
+
useCheckBoxBackground,
|
|
25
|
+
legendLabelColor,
|
|
26
|
+
reverseLegend,
|
|
27
|
+
showLegendsInColumns,
|
|
28
|
+
numberOfLegendColumns
|
|
29
|
+
}
|
|
30
|
+
} = props;
|
|
31
|
+
return [
|
|
32
|
+
/* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Margins") }, /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
33
|
+
RangeControl,
|
|
34
|
+
{
|
|
35
|
+
label: __("Margin Bottom (Space between chart area and bottom border)"),
|
|
36
|
+
value: marginBottom,
|
|
37
|
+
onChange: (marginBottom2) => setAttributes({ marginBottom: marginBottom2 }),
|
|
38
|
+
min: 0,
|
|
39
|
+
max: 500
|
|
40
|
+
}
|
|
41
|
+
)), /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
42
|
+
RangeControl,
|
|
43
|
+
{
|
|
44
|
+
label: __("Margin Left (Space between chart area and left border)"),
|
|
45
|
+
value: marginLeft,
|
|
46
|
+
initialPosition: 0,
|
|
47
|
+
onChange: (marginLeft2) => setAttributes({ marginLeft: marginLeft2 }),
|
|
48
|
+
step: 1,
|
|
49
|
+
min: 0,
|
|
50
|
+
max: 500
|
|
51
|
+
}
|
|
52
|
+
)), /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
53
|
+
RangeControl,
|
|
54
|
+
{
|
|
55
|
+
label: __("Margin Right"),
|
|
56
|
+
value: marginRight,
|
|
57
|
+
onChange: (marginRight2) => setAttributes({ marginRight: marginRight2 }),
|
|
58
|
+
min: 0,
|
|
59
|
+
max: 500
|
|
60
|
+
}
|
|
61
|
+
)), /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
62
|
+
RangeControl,
|
|
63
|
+
{
|
|
64
|
+
label: __("Margin Top"),
|
|
65
|
+
value: marginTop,
|
|
66
|
+
onChange: (marginTop2) => setAttributes({ marginTop: marginTop2 }),
|
|
67
|
+
min: 0,
|
|
68
|
+
max: 500
|
|
69
|
+
}
|
|
70
|
+
))),
|
|
71
|
+
/* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Legends") }, /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
72
|
+
ToggleControl,
|
|
73
|
+
{
|
|
74
|
+
label: __("Show Legends"),
|
|
75
|
+
checked: showLegends,
|
|
76
|
+
onChange: () => setAttributes({ showLegends: !showLegends })
|
|
77
|
+
}
|
|
78
|
+
)), showLegends && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
79
|
+
ToggleControl,
|
|
80
|
+
{
|
|
81
|
+
label: __("Show Legends in Columns"),
|
|
82
|
+
checked: showLegendsInColumns,
|
|
83
|
+
onChange: () => setAttributes({ showLegendsInColumns: !showLegendsInColumns })
|
|
84
|
+
}
|
|
85
|
+
)), showLegends && showLegendsInColumns && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
86
|
+
TextControl,
|
|
87
|
+
{
|
|
88
|
+
label: __("Number of Legend Columns"),
|
|
89
|
+
value: numberOfLegendColumns,
|
|
90
|
+
onChange: (numberOfLegendColumns2) => setAttributes({ numberOfLegendColumns: numberOfLegendColumns2 }),
|
|
91
|
+
type: "number",
|
|
92
|
+
min: 1,
|
|
93
|
+
max: 10
|
|
94
|
+
}
|
|
95
|
+
)), showLegends && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
96
|
+
ToggleControl,
|
|
97
|
+
{
|
|
98
|
+
label: __("Reverse legend order"),
|
|
99
|
+
checked: reverseLegend,
|
|
100
|
+
onChange: () => setAttributes({ reverseLegend: !reverseLegend })
|
|
101
|
+
}
|
|
102
|
+
)), showLegends && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
103
|
+
ToggleControl,
|
|
104
|
+
{
|
|
105
|
+
label: __("Use Label Background"),
|
|
106
|
+
checked: useLabelBackground,
|
|
107
|
+
onChange: (e) => setAttributes({ useLabelBackground: !useLabelBackground })
|
|
108
|
+
}
|
|
109
|
+
)), showLegends && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
110
|
+
ToggleControl,
|
|
111
|
+
{
|
|
112
|
+
label: __("Use Checkbox Background"),
|
|
113
|
+
checked: useCheckBoxBackground,
|
|
114
|
+
onChange: (e) => setAttributes({ useCheckBoxBackground: !useCheckBoxBackground })
|
|
115
|
+
}
|
|
116
|
+
)), showLegends && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(ButtonGroup, null, /* @__PURE__ */ React.createElement(
|
|
117
|
+
Button,
|
|
118
|
+
{
|
|
119
|
+
isPrimary: legendPosition == "left",
|
|
120
|
+
isSecondary: legendPosition != "left",
|
|
121
|
+
onClick: (e) => setAttributes({ legendPosition: "left" })
|
|
122
|
+
},
|
|
123
|
+
__("Left")
|
|
124
|
+
), /* @__PURE__ */ React.createElement(
|
|
125
|
+
Button,
|
|
126
|
+
{
|
|
127
|
+
isPrimary: legendPosition == "top",
|
|
128
|
+
isSecondary: legendPosition != "top",
|
|
129
|
+
onClick: (e) => setAttributes({ legendPosition: "top" })
|
|
130
|
+
},
|
|
131
|
+
__("Top")
|
|
132
|
+
), /* @__PURE__ */ React.createElement(
|
|
133
|
+
Button,
|
|
134
|
+
{
|
|
135
|
+
isPrimary: legendPosition == "right",
|
|
136
|
+
isSecondary: legendPosition != "right",
|
|
137
|
+
onClick: (e) => setAttributes({ legendPosition: "right" })
|
|
138
|
+
},
|
|
139
|
+
__("Right")
|
|
140
|
+
), /* @__PURE__ */ React.createElement(
|
|
141
|
+
Button,
|
|
142
|
+
{
|
|
143
|
+
isPrimary: legendPosition == "bottom",
|
|
144
|
+
isSecondary: legendPosition != "bottom",
|
|
145
|
+
onClick: (e) => setAttributes({ legendPosition: "bottom" })
|
|
146
|
+
},
|
|
147
|
+
__("Bottom")
|
|
148
|
+
))), showLegends && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
149
|
+
TextControl,
|
|
150
|
+
{
|
|
151
|
+
label: __("Legends Title"),
|
|
152
|
+
value: legendLabel,
|
|
153
|
+
onChange: (legendLabel2) => setAttributes({ legendLabel: legendLabel2 })
|
|
154
|
+
}
|
|
155
|
+
)), showLegends && /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(
|
|
156
|
+
PanelColorSettings,
|
|
157
|
+
{
|
|
158
|
+
title: __("Legends text color"),
|
|
159
|
+
colorSettings: [
|
|
160
|
+
{
|
|
161
|
+
value: decodeURIComponent(legendLabelColor ? legendLabelColor : "#000000"),
|
|
162
|
+
onChange: (color) => {
|
|
163
|
+
if (color) {
|
|
164
|
+
setAttributes({ legendLabelColor: encodeURIComponent(color) });
|
|
165
|
+
} else {
|
|
166
|
+
setAttributes({ legendLabelColor: null });
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
label: __("")
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
), " "))
|
|
174
|
+
];
|
|
55
175
|
};
|
|
56
|
-
export default ChartLegends;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChartMeasures = void 0;
|
|
7
|
+
var _i18n = require("@wordpress/i18n");
|
|
8
|
+
var _components = require("@wordpress/components");
|
|
9
|
+
var _Format = _interopRequireDefault(require("./Format.cjs"));
|
|
10
|
+
var _Util = require("./Util.cjs");
|
|
11
|
+
var _APIutils = require("./APIutils.cjs");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const defaultFormat = {
|
|
14
|
+
"style": "percent",
|
|
15
|
+
"minimumFractionDigits": 1,
|
|
16
|
+
"maximumFractionDigits": 1,
|
|
17
|
+
"currency": "USD"
|
|
18
|
+
};
|
|
19
|
+
const ChartMeasures = props => {
|
|
20
|
+
const {
|
|
21
|
+
onMeasuresChange,
|
|
22
|
+
onFormatChange,
|
|
23
|
+
onUseCustomAxisFormatChange,
|
|
24
|
+
onSetSingleMeasure,
|
|
25
|
+
onCustomLabelToggleChange,
|
|
26
|
+
onCustomLabelChange,
|
|
27
|
+
allMeasures,
|
|
28
|
+
setAttributes,
|
|
29
|
+
title,
|
|
30
|
+
attributes: {
|
|
31
|
+
panelStatus,
|
|
32
|
+
measures,
|
|
33
|
+
dimension1,
|
|
34
|
+
dimension2,
|
|
35
|
+
type,
|
|
36
|
+
app
|
|
37
|
+
}
|
|
38
|
+
} = props;
|
|
39
|
+
const MToggle = ({
|
|
40
|
+
measure
|
|
41
|
+
}) => {
|
|
42
|
+
const userMeasure = measures[app] ? measures[app][measure.value] : {};
|
|
43
|
+
return /* @__PURE__ */React.createElement(_components.ToggleControl, {
|
|
44
|
+
label: (0, _APIutils.getTranslation)(measure),
|
|
45
|
+
checked: userMeasure ? userMeasure.selected : false,
|
|
46
|
+
onChange: value => onMeasuresChange(measure.value)
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const MCheckbox = ({
|
|
50
|
+
measure
|
|
51
|
+
}) => {
|
|
52
|
+
const userMeasure = measures[app] ? measures[app][measure.value] : {};
|
|
53
|
+
return /* @__PURE__ */React.createElement(_components.CheckboxControl, {
|
|
54
|
+
label: (0, _APIutils.getTranslation)(measure),
|
|
55
|
+
checked: userMeasure ? userMeasure.selected : false,
|
|
56
|
+
onChange: value => onSetSingleMeasure(measure.value)
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const MeasureOptions = ({
|
|
60
|
+
measure,
|
|
61
|
+
single
|
|
62
|
+
}) => {
|
|
63
|
+
return /* @__PURE__ */React.createElement(_components.PanelRow, null, single && /* @__PURE__ */React.createElement(MCheckbox, {
|
|
64
|
+
measure
|
|
65
|
+
}), !single && /* @__PURE__ */React.createElement(MToggle, {
|
|
66
|
+
measure
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
const countSelected = g => {
|
|
70
|
+
if (measures[app]) {
|
|
71
|
+
const mG = allMeasures.filter(f => (0, _APIutils.getTranslation)(f.group) === g);
|
|
72
|
+
let count = 0;
|
|
73
|
+
Object.keys(measures[app]).filter(l => mG.map(m => m.value).indexOf(l) > -1).forEach(k => {
|
|
74
|
+
if (measures[app][k].selected) {
|
|
75
|
+
count++;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return count;
|
|
79
|
+
}
|
|
80
|
+
return 0;
|
|
81
|
+
};
|
|
82
|
+
const countTotal = g => {
|
|
83
|
+
if (g) {
|
|
84
|
+
return allMeasures.filter(f => (0, _APIutils.getTranslation)(f.group) === g).length;
|
|
85
|
+
}
|
|
86
|
+
return 0;
|
|
87
|
+
};
|
|
88
|
+
const getSelectedMeasures = () => {
|
|
89
|
+
if (measures[app] && allMeasures) {
|
|
90
|
+
return Object.keys(measures[app]).filter(k => measures[app][k].selected).map(k => {
|
|
91
|
+
return allMeasures.filter(m => m.value === k)[0];
|
|
92
|
+
}).filter(m => m);
|
|
93
|
+
}
|
|
94
|
+
return [];
|
|
95
|
+
};
|
|
96
|
+
const selectedMeasures = getSelectedMeasures();
|
|
97
|
+
return /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
98
|
+
title: title ? title : (0, _i18n.__)("Measures"),
|
|
99
|
+
initialOpen: panelStatus["MEASURES"],
|
|
100
|
+
onToggle: e => (0, _Util.togglePanel)("MEASURES", panelStatus, setAttributes)
|
|
101
|
+
},
|
|
102
|
+
/*
|
|
103
|
+
Multiple measures conditions
|
|
104
|
+
|
|
105
|
+
Bar:
|
|
106
|
+
no dimensions selected
|
|
107
|
+
one dimension is selected
|
|
108
|
+
- not available when second dimension gets selected
|
|
109
|
+
|
|
110
|
+
Line:
|
|
111
|
+
- Always multi measure as measures represents line series, one dimension should always be selected
|
|
112
|
+
|
|
113
|
+
Pie:
|
|
114
|
+
no dimensions selected
|
|
115
|
+
- not available when any dimension is selected
|
|
116
|
+
*/
|
|
117
|
+
(type == "line" || type == "bar" && dimension2 == "none" || type == "pie" && dimension1 == "none" && dimension2 == "none") && allMeasures && [...new Set(allMeasures.map(p => (0, _APIutils.getTranslation)(p.group)))].map(g => {
|
|
118
|
+
return /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
119
|
+
initialOpen: panelStatus[g],
|
|
120
|
+
onToggle: e => (0, _Util.togglePanel)(g, panelStatus, setAttributes),
|
|
121
|
+
title: `${g} (${countSelected(g)} / ${countTotal(g)} ) `
|
|
122
|
+
}, allMeasures.filter(f => (0, _APIutils.getTranslation)(f.group) === g).map(m => /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(MeasureOptions, {
|
|
123
|
+
single: false,
|
|
124
|
+
measure: m
|
|
125
|
+
}))));
|
|
126
|
+
}),
|
|
127
|
+
/*Single measure conditions
|
|
128
|
+
|
|
129
|
+
Bar:
|
|
130
|
+
2 dimensions selected
|
|
131
|
+
Line:
|
|
132
|
+
never
|
|
133
|
+
Pie:
|
|
134
|
+
any dimensions selected
|
|
135
|
+
|
|
136
|
+
*/
|
|
137
|
+
(type == "bar" && dimension2 != "none" || type == "pie" && (dimension1 != "none" || dimension2 != "none")) && allMeasures && [...new Set(allMeasures.map(p => (0, _APIutils.getTranslation)(p.group)))].map(g => {
|
|
138
|
+
return /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
139
|
+
initialOpen: panelStatus[g],
|
|
140
|
+
onToggle: e => (0, _Util.togglePanel)(g, panelStatus, setAttributes),
|
|
141
|
+
title: `${g} (${countSelected(g)} / ${allMeasures.filter(f => f.group === g).length} ) `
|
|
142
|
+
}, allMeasures.filter(f => (0, _APIutils.getTranslation)(f.group) === g).map(m => /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(MeasureOptions, {
|
|
143
|
+
single: true,
|
|
144
|
+
measure: m
|
|
145
|
+
}))));
|
|
146
|
+
}), type == "overlay" && allMeasures && /* @__PURE__ */React.createElement(_components.SelectControl, {
|
|
147
|
+
label: "Measure",
|
|
148
|
+
value: selectedMeasures && selectedMeasures[0] ? selectedMeasures[0].value : null,
|
|
149
|
+
options: [{
|
|
150
|
+
value: "",
|
|
151
|
+
label: "Select Measure"
|
|
152
|
+
}, ...allMeasures],
|
|
153
|
+
onChange: measure => onSetSingleMeasure(measure),
|
|
154
|
+
__nextHasNoMarginBottom: true
|
|
155
|
+
}), type != "overlay" && /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
156
|
+
title: (0, _i18n.__)("Format"),
|
|
157
|
+
initialOpen: panelStatus["FORMAT"],
|
|
158
|
+
onToggle: e => (0, _Util.togglePanel)("FORMAT", panelStatus, setAttributes)
|
|
159
|
+
}, /* @__PURE__ */React.createElement(_Format.default, {
|
|
160
|
+
format: measures[app] && measures[app].format ? measures[app].format : defaultFormat,
|
|
161
|
+
customFormat: measures[app] && measures[app].customFormat ? measures[app].customFormat : defaultFormat,
|
|
162
|
+
useCustomAxisFormat: measures[app] ? measures[app].useCustomAxisFormat : false,
|
|
163
|
+
onFormatChange: (format, field) => {
|
|
164
|
+
onFormatChange(format, field);
|
|
165
|
+
},
|
|
166
|
+
onUseCustomAxisFormatChange: value => {
|
|
167
|
+
onUseCustomAxisFormatChange(value);
|
|
168
|
+
}
|
|
169
|
+
}))), type != "overlay" && selectedMeasures && selectedMeasures.length > 0 && /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
170
|
+
title: (0, _i18n.__)("Measure Label Customization"),
|
|
171
|
+
initialOpen: panelStatus["MEASURES_LABEL_CUSTOMIZATION"],
|
|
172
|
+
onToggle: e => (0, _Util.togglePanel)("MEASURES_LABEL_CUSTOMIZATION", panelStatus, setAttributes)
|
|
173
|
+
}, selectedMeasures && [...new Set(selectedMeasures.map(p => (0, _APIutils.getTranslation)(p.group)))].map(g => {
|
|
174
|
+
return /* @__PURE__ */React.createElement(_components.PanelBody, {
|
|
175
|
+
initialOpen: panelStatus[g + "_LABEL_CUSTOMIZATION"],
|
|
176
|
+
onToggle: e => (0, _Util.togglePanel)(g + "_LABEL_CUSTOMIZATION", panelStatus, setAttributes),
|
|
177
|
+
title: `${g}`
|
|
178
|
+
}, selectedMeasures.filter(f => (0, _APIutils.getTranslation)(f.group) === g).map(m => {
|
|
179
|
+
const userMeasure = measures[app] ? measures[app][m.value] : {};
|
|
180
|
+
return /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.ToggleControl, {
|
|
181
|
+
label: (0, _APIutils.getTranslation)(m),
|
|
182
|
+
checked: userMeasure ? userMeasure.hasCustomLabel : false,
|
|
183
|
+
onChange: value => onCustomLabelToggleChange(m.value)
|
|
184
|
+
}), " "), userMeasure.hasCustomLabel && /* @__PURE__ */React.createElement(_components.PanelRow, null, /* @__PURE__ */React.createElement(_components.TextControl, {
|
|
185
|
+
label: (0, _i18n.__)("Custom Label"),
|
|
186
|
+
value: userMeasure ? userMeasure.customLabel : "",
|
|
187
|
+
onChange: value => onCustomLabelChange(m.value, value)
|
|
188
|
+
})));
|
|
189
|
+
}));
|
|
190
|
+
})));
|
|
191
|
+
};
|
|
192
|
+
exports.ChartMeasures = ChartMeasures;
|
package/build/ChartMeasures.d.ts
CHANGED