@devgateway/dvz-wp-commons 1.1.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.
Files changed (65) hide show
  1. package/build/APIConfig.cjs +479 -0
  2. package/build/APIConfig.d.ts +31 -42
  3. package/build/APIConfig.js +366 -277
  4. package/build/APIutils.cjs +54 -0
  5. package/build/APIutils.d.ts +3 -3
  6. package/build/APIutils.js +11 -1
  7. package/build/Blocks.cjs +672 -0
  8. package/build/Blocks.d.ts +42 -65
  9. package/build/Blocks.js +524 -346
  10. package/build/CSVSourceConfig.cjs +99 -0
  11. package/build/CSVSourceConfig.d.ts +2 -3
  12. package/build/CSVSourceConfig.js +63 -41
  13. package/build/ChartColors.cjs +593 -0
  14. package/build/ChartColors.d.ts +4 -46
  15. package/build/ChartColors.js +431 -380
  16. package/build/ChartLegends.cjs +157 -0
  17. package/build/ChartLegends.d.ts +1 -33
  18. package/build/ChartLegends.js +173 -69
  19. package/build/ChartMeasures.cjs +192 -0
  20. package/build/ChartMeasures.d.ts +1 -23
  21. package/build/ChartMeasures.js +195 -108
  22. package/build/Constants.cjs +21 -0
  23. package/build/Constants.d.ts +18 -15
  24. package/build/Constants.js +3 -1
  25. package/build/DataFilters.cjs +176 -0
  26. package/build/DataFilters.d.ts +1 -12
  27. package/build/DataFilters.js +100 -93
  28. package/build/Format.cjs +1038 -0
  29. package/build/Format.d.ts +8 -10
  30. package/build/Format.js +428 -379
  31. package/build/MapCSVSourceConfig.cjs +36 -0
  32. package/build/MapCSVSourceConfig.d.ts +7 -9
  33. package/build/MapCSVSourceConfig.js +19 -9
  34. package/build/Measures.cjs +196 -0
  35. package/build/Measures.d.ts +1 -24
  36. package/build/Measures.js +208 -119
  37. package/build/MobileConfigUtils.cjs +92 -0
  38. package/build/MobileConfigUtils.d.ts +6 -6
  39. package/build/MobileConfigUtils.js +39 -32
  40. package/build/Tooltip.cjs +63 -0
  41. package/build/Tooltip.d.ts +1 -3
  42. package/build/Tooltip.js +27 -51
  43. package/build/Util.cjs +29 -0
  44. package/build/Util.d.ts +5 -6
  45. package/build/Util.js +9 -9
  46. package/build/hooks/index.cjs +1 -0
  47. package/build/hooks/index.js +0 -3
  48. package/build/icons/Chart.cjs +49 -0
  49. package/build/icons/Chart.d.ts +1 -2
  50. package/build/icons/Chart.js +10 -11
  51. package/build/icons/Generic.cjs +24 -0
  52. package/build/icons/Generic.d.ts +1 -2
  53. package/build/icons/Generic.js +25 -4
  54. package/build/icons/index.cjs +19 -0
  55. package/build/icons/index.d.ts +2 -2
  56. package/build/icons/index.js +2 -2
  57. package/build/index.cjs +225 -0
  58. package/build/index.d.ts +16 -18
  59. package/build/index.js +47 -19
  60. package/package.json +39 -30
  61. package/build/post-type.d.ts +0 -193
  62. package/build/post-type.js +0 -12
  63. package/build/tsconfig.tsbuildinfo +0 -1
  64. package/build/types.d.ts +0 -349
  65. package/build/types.js +0 -33
@@ -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;
@@ -1,33 +1 @@
1
- import React from 'react';
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[];
33
- export default ChartLegends;
1
+ export function ChartLegends(props: any): import("react").JSX.Element[];
@@ -1,71 +1,175 @@
1
- import React from 'react';
2
- import { Button, ButtonGroup, PanelBody, PanelRow, RangeControl, TextControl, ToggleControl } from '@wordpress/components';
3
- import { __ } from '@wordpress/i18n';
4
- import { PanelColorSettings } from '@wordpress/block-editor';
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";
5
12
  export const ChartLegends = (props) => {
6
- const { setAttributes, legendPosition, attributes } = props;
7
- const { showLegends, marginLeft, marginRight, marginBottom, marginTop, legendLabel, useLabelBackground, useCheckBoxBackground, legendLabelColor, reverseLegend } = attributes;
8
- return [
9
- React.createElement(PanelBody, { initialOpen: false, title: __("Margins") },
10
- 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 })),
16
- 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 })),
22
- 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 })),
28
- 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 }))),
34
- React.createElement(PanelBody, { initialOpen: false, title: __("Legends") },
35
- React.createElement(PanelRow, null,
36
- React.createElement(ToggleControl, { label: __("Show Legends"), checked: showLegends, onChange: () => setAttributes({ ...attributes, showLegends: !showLegends }) })),
37
- showLegends &&
38
- React.createElement(PanelRow, null,
39
- React.createElement(ToggleControl, { label: __("Reverse legend order"), checked: reverseLegend, onChange: () => setAttributes({ ...attributes, reverseLegend: !reverseLegend }) })),
40
- showLegends && React.createElement(PanelRow, null,
41
- React.createElement(ToggleControl, { label: __("Use Label Background"), checked: useLabelBackground, onChange: () => setAttributes({ ...attributes, useLabelBackground: !useLabelBackground }) })),
42
- showLegends && React.createElement(PanelRow, null,
43
- React.createElement(ToggleControl, { label: __("Use Checkbox Background"), checked: useCheckBoxBackground, onChange: () => setAttributes({ ...attributes, useCheckBoxBackground: !useCheckBoxBackground }) })),
44
- showLegends && React.createElement(PanelRow, null,
45
- React.createElement(ButtonGroup, null,
46
- React.createElement(Button, { variant: legendPosition == 'left' ? 'primary' : 'secondary', onClick: () => setAttributes({ ...attributes, legendPosition: "left" }) }, __("Left")),
47
- React.createElement(Button, { variant: legendPosition == 'top' ? 'primary' : 'secondary', onClick: () => setAttributes({ ...attributes, legendPosition: "top" }) }, __("Top")),
48
- React.createElement(Button, { variant: legendPosition == 'right' ? 'primary' : 'secondary', onClick: () => setAttributes({ ...attributes, legendPosition: "right" }) }, __("Right")),
49
- React.createElement(Button, { variant: legendPosition == 'bottom' ? 'primary' : 'secondary', onClick: () => setAttributes({ ...attributes, legendPosition: "bottom" }) }, __("Bottom")))),
50
- showLegends && React.createElement(PanelRow, null,
51
- React.createElement(TextControl, { label: __('Legends Title'), value: legendLabel, onChange: (legendLabel) => setAttributes({ ...attributes, legendLabel }) })),
52
- showLegends && React.createElement(PanelRow, null,
53
- React.createElement(PanelColorSettings, { title: __('Legends text color'), colorSettings: [
54
- {
55
- // Ensure legendLabelColor is encoded before decoding to avoid runtime errors.
56
- value: decodeURIComponent(legendLabelColor ? encodeURIComponent(decodeURIComponent(legendLabelColor)) : "#000000"),
57
- onChange: (color) => {
58
- if (color) {
59
- setAttributes({ ...attributes, legendLabelColor: encodeURIComponent(color) });
60
- }
61
- else {
62
- setAttributes({ ...attributes, legendLabelColor: null });
63
- }
64
- },
65
- label: __("")
66
- }
67
- ] }),
68
- " ")),
69
- ];
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
+ ];
70
175
  };
71
- 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;
@@ -1,23 +1 @@
1
- import React from 'react';
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;
23
- export default ChartMeasures;
1
+ export function ChartMeasures(props: any): import("react").JSX.Element;