@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
package/build/DataFilters.js
CHANGED
|
@@ -1,94 +1,105 @@
|
|
|
1
1
|
import { Button, PanelBody, PanelRow, SelectControl, ToggleControl } from "@wordpress/components";
|
|
2
|
-
import { __ } from
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
3
|
export const DataFilters = (props) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
const updateFilterParam = (param, idx) => {
|
|
5
|
+
const { attributes: { filters: filters2 }, setAttributes, allFilters: allFilters2 } = props;
|
|
6
|
+
const newFilters = filters2.slice();
|
|
7
|
+
const selected = allFilters2.filter((f) => f.param === param)[0];
|
|
8
|
+
newFilters[idx] = { ...selected, value: [] };
|
|
9
|
+
setAttributes({ filters: newFilters });
|
|
10
|
+
};
|
|
11
|
+
const updateFilterValue = (value, idx) => {
|
|
12
|
+
const { attributes: { filters: filters2 }, setAttributes, onChange } = props;
|
|
13
|
+
const selected = filters2[idx];
|
|
14
|
+
let values = selected.value;
|
|
15
|
+
if (values.indexOf(value) > -1) {
|
|
16
|
+
values = values.filter((v) => v != value);
|
|
17
|
+
} else {
|
|
18
|
+
values.push(value);
|
|
19
|
+
}
|
|
20
|
+
const newFilters = filters2.slice();
|
|
21
|
+
newFilters[idx].value = values;
|
|
22
|
+
setAttributes({ filters: newFilters });
|
|
23
|
+
onChange();
|
|
24
|
+
};
|
|
25
|
+
const addFilter = () => {
|
|
26
|
+
const { attributes: { filters: filters2 }, setAttributes, allFilters: allFilters2 } = props;
|
|
27
|
+
let index = filters2.length > allFilters2.length ? allFilters2.length : filters2.length;
|
|
28
|
+
const newFilter = allFilters2 && allFilters2.length > 0 ? {
|
|
29
|
+
...allFilters2[index],
|
|
30
|
+
"value": []
|
|
31
|
+
} : null;
|
|
32
|
+
let newFilters = filters2.slice();
|
|
33
|
+
newFilters.push(newFilter);
|
|
34
|
+
setAttributes({ filters: newFilters });
|
|
35
|
+
};
|
|
36
|
+
const removeFilter = (f) => {
|
|
37
|
+
const { attributes: { filters: filters2 }, setAttributes } = props;
|
|
38
|
+
let newFilters = filters2.slice(0, -1);
|
|
39
|
+
setAttributes({ filters: newFilters });
|
|
40
|
+
};
|
|
41
|
+
const items = (type) => {
|
|
42
|
+
const values = props.allCategories ? props.allCategories.filter((c) => c.type === type) : [];
|
|
43
|
+
const cat = values.length > 0 ? values[0] : null;
|
|
44
|
+
let items2 = null;
|
|
45
|
+
if (type === "Boolean") {
|
|
46
|
+
items2 = [{ "value": "Yes", id: true }, { "value": "No", id: false }];
|
|
47
|
+
} else if (cat) {
|
|
48
|
+
items2 = cat.items;
|
|
49
|
+
}
|
|
50
|
+
return items2;
|
|
51
|
+
};
|
|
52
|
+
const FilterSelector = ({ param, index, options, onUpdateFilterParam }) => {
|
|
53
|
+
const sortedOptions = options.sort(function(a, b) {
|
|
54
|
+
var aLabel = a.label ? a.label.toLowerCase() : "";
|
|
55
|
+
var bLabel = b.label ? b.label.toLowerCase() : "";
|
|
56
|
+
return aLabel < bLabel ? -1 : aLabel > bLabel ? 1 : 0;
|
|
57
|
+
});
|
|
58
|
+
return /* @__PURE__ */ React.createElement(SelectControl, { onChange: (value) => {
|
|
59
|
+
onUpdateFilterParam(value, index);
|
|
60
|
+
}, value: param, options: sortedOptions });
|
|
61
|
+
};
|
|
62
|
+
const CategoricalFilter = ({ value, index, items: items2, onUpdateFilterValue }) => {
|
|
63
|
+
if (items2) {
|
|
64
|
+
const sortedItems = items2.sort(function(a, b) {
|
|
65
|
+
if (a.position !== void 0 && b.position !== void 0 && a.position !== b.position) {
|
|
66
|
+
return a.position - b.position;
|
|
17
67
|
}
|
|
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
|
-
const FilterSelector = ({ param, index, options, onUpdateFilterParam }) => {
|
|
55
|
-
const sortedOptions = options.sort(function (a, b) {
|
|
56
|
-
var aLabel = a.label ? a.label.toLowerCase() : "";
|
|
57
|
-
var bLabel = b.label ? b.label.toLowerCase() : "";
|
|
58
|
-
return aLabel < bLabel ? -1 : aLabel > bLabel ? 1 : 0;
|
|
59
|
-
});
|
|
60
|
-
return React.createElement(SelectControl, { onChange: (value) => {
|
|
61
|
-
onUpdateFilterParam(value, index);
|
|
62
|
-
}, value: param, options: sortedOptions });
|
|
63
|
-
};
|
|
64
|
-
const CategoricalFilter = ({ value, index, items, onUpdateFilterValue }) => {
|
|
65
|
-
if (items) {
|
|
66
|
-
const sortedItems = items.sort(function (a, b) {
|
|
67
|
-
if (a.position !== undefined && b.position !== undefined && a.position !== b.position) {
|
|
68
|
-
return a.position - b.position;
|
|
69
|
-
}
|
|
70
|
-
let aValue = a.value ? a.value.toLowerCase() : "";
|
|
71
|
-
let bValue = b.value ? b.value.toLowerCase() : "";
|
|
72
|
-
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
|
|
73
|
-
});
|
|
74
|
-
return sortedItems.map(v => React.createElement(PanelRow, null,
|
|
75
|
-
React.createElement(ToggleControl, { label: v.value, checked: value.indexOf(v.id) > -1, onChange: e => {
|
|
76
|
-
onUpdateFilterValue(v.id, index);
|
|
77
|
-
} })));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const { allFilters, attributes: { filters, } } = props;
|
|
84
|
-
return React.createElement(PanelBody, { initialOpen: false, title: __("Filters") },
|
|
85
|
-
filters.map((f, index) => {
|
|
86
|
-
return (React.createElement(PanelBody, { initialOpen: true, title: __(`Filter - ${f.label}`) },
|
|
87
|
-
React.createElement(FilterSelector, { param: f.param, index: index, options: allFilters, onUpdateFilterParam: updateFilterParam }),
|
|
88
|
-
React.createElement(CategoricalFilter, { value: f.value, index: index, items: items(f.type), onUpdateFilterValue: updateFilterValue })));
|
|
89
|
-
}),
|
|
90
|
-
React.createElement(PanelRow, null,
|
|
91
|
-
React.createElement(Button, { variant: "link", onClick: addFilter }, __("Add Filter")),
|
|
92
|
-
React.createElement(Button, { variant: "link", onClick: removeFilter }, __("Remove"))));
|
|
68
|
+
let aValue = a.value ? a.value.toLowerCase() : "";
|
|
69
|
+
let bValue = b.value ? b.value.toLowerCase() : "";
|
|
70
|
+
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
|
|
71
|
+
});
|
|
72
|
+
return sortedItems.map((v) => /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(ToggleControl, { label: v.value, checked: value.indexOf(v.id) > -1, onChange: (e) => {
|
|
73
|
+
onUpdateFilterValue(v.id, index);
|
|
74
|
+
} })));
|
|
75
|
+
} else {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const {
|
|
80
|
+
allFilters,
|
|
81
|
+
attributes: {
|
|
82
|
+
filters
|
|
83
|
+
}
|
|
84
|
+
} = props;
|
|
85
|
+
return /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: false, title: __("Filters") }, filters.map((f, index) => {
|
|
86
|
+
return /* @__PURE__ */ React.createElement(PanelBody, { initialOpen: true, title: __(`Filter - ${f.label}`) }, /* @__PURE__ */ React.createElement(
|
|
87
|
+
FilterSelector,
|
|
88
|
+
{
|
|
89
|
+
param: f.param,
|
|
90
|
+
index,
|
|
91
|
+
options: allFilters,
|
|
92
|
+
onUpdateFilterParam: updateFilterParam
|
|
93
|
+
}
|
|
94
|
+
), /* @__PURE__ */ React.createElement(
|
|
95
|
+
CategoricalFilter,
|
|
96
|
+
{
|
|
97
|
+
value: f.value,
|
|
98
|
+
index,
|
|
99
|
+
items: items(f.type),
|
|
100
|
+
onUpdateFilterValue: updateFilterValue
|
|
101
|
+
}
|
|
102
|
+
));
|
|
103
|
+
}), /* @__PURE__ */ React.createElement(PanelRow, null, /* @__PURE__ */ React.createElement(Button, { variant: "link", onClick: addFilter }, __("Add Filter")), /* @__PURE__ */ React.createElement(Button, { variant: "link", onClick: removeFilter }, __("Remove"))));
|
|
93
104
|
};
|
|
94
105
|
export default DataFilters;
|