@devgateway/dvz-wp-commons 1.0.5 → 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.
@@ -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, attributes } = props;
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({ ...attributes, showLegends: !showLegends }) })),
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({ ...attributes, reverseLegend: !reverseLegend }) })),
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: () => setAttributes({ ...attributes, useLabelBackground: !useLabelBackground }) })),
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: () => setAttributes({ ...attributes, useCheckBoxBackground: !useCheckBoxBackground }) })),
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, { 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")))),
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({ ...attributes, legendLabel }) })),
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
- // Ensure legendLabelColor is encoded before decoding to avoid runtime errors.
56
- value: decodeURIComponent(legendLabelColor ? encodeURIComponent(decodeURIComponent(legendLabelColor)) : "#000000"),
41
+ value: decodeURIComponent(legendLabelColor ? legendLabelColor : "#000000"),
57
42
  onChange: (color) => {
58
43
  if (color) {
59
- setAttributes({ ...attributes, legendLabelColor: encodeURIComponent(color) });
44
+ setAttributes({ legendLabelColor: encodeURIComponent(color) });
60
45
  }
61
46
  else {
62
- setAttributes({ ...attributes, legendLabelColor: null });
47
+ setAttributes({ legendLabelColor: null });
63
48
  }
64
49
  },
65
50
  label: __("")
@@ -1,23 +1,2 @@
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;
1
+ export function ChartMeasures(props: any): import("react").JSX.Element;
23
2
  export default ChartMeasures;
@@ -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.js";
6
- import { getTranslation } from "./APIutils.js";
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 => getTranslation(f.group) === g).length} ) ` }, allMeasures.filter(f => getTranslation(f.group) === g)
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
  }),
@@ -1,15 +1,18 @@
1
- export declare const DEFAULT_FORMAT_SETTINGS: {
2
- format: {
3
- style: string;
4
- minimumFractionDigits: number;
5
- maximumFractionDigits: number;
6
- };
7
- customFormat: {
8
- style: string;
9
- minimumFractionDigits: number;
10
- maximumFractionDigits: number;
11
- };
12
- useCustomAxisFormat: boolean;
13
- };
14
- export declare const BLOCKS_CATEGORY = "wp-react-lib-blocks";
15
- export declare const BLOCKS_NS = "viz";
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";
@@ -1,13 +1,2 @@
1
- import React from 'react';
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;
@@ -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 && 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 => { onUpdateFilterValue(v.id, index); } })));
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.length > 0 && filters.map((f, index) => {
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
- import React from 'react';
2
- export type FormatProps = {
1
+ export function Format({ format, title, onFormatChange, onUseCustomAxisFormatChange, customFormat, hiddenCustomAxisFormat, useCustomAxisFormat }: {
3
2
  format: any;
4
- title?: string;
5
- onFormatChange: (format: any, field: string) => void;
6
- onUseCustomAxisFormatChange?: (value: boolean) => void;
7
- customFormat?: any;
8
- hiddenCustomAxisFormat?: boolean;
9
- useCustomAxisFormat?: boolean;
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, { multiple: true, label: __('Style', "dg"), value: [format.style], onChange: (value) => {
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: "number", label: __("Decimal Points", "dg"), onChange: (value) => {
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?.(value) }))),
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, { multiple: true, label: __('Style', "dg"), value: [customFormat.style], onChange: (value) => {
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: "number", label: __("Decimal Points", "dg"), onChange: (value) => {
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
  ];
@@ -1,12 +1,10 @@
1
- import React from 'react';
2
- export type MapCSVSourceConfigProps = {
1
+ export function MapCSVSourceConfig({ attributes: { app, csv, hasMultipleMeasures, enableSummaryView }, setAttributes }: {
3
2
  attributes: {
4
- app: string;
5
- csv: string;
6
- hasMultipleMeasures: boolean;
7
- enableSummaryView: boolean;
3
+ app: any;
4
+ csv: any;
5
+ hasMultipleMeasures: any;
6
+ enableSummaryView: any;
8
7
  };
9
- setAttributes: (attributes: any) => void;
10
- };
11
- export declare const MapCSVSourceConfig: ({ attributes: { app, csv, hasMultipleMeasures, enableSummaryView }, setAttributes }: MapCSVSourceConfigProps) => React.JSX.Element[];
8
+ setAttributes: any;
9
+ }): import("react").JSX.Element[];
12
10
  export default MapCSVSourceConfig;
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import { PanelBody, PanelRow, ToggleControl, TextareaControl } from '@wordpress/components';
1
+ import { PanelBody, PanelRow, ToggleControl, TextareaControl, SelectControl } from '@wordpress/components';
3
2
  import { __ } from '@wordpress/i18n';
4
3
  export const MapCSVSourceConfig = ({ attributes: { app, csv, hasMultipleMeasures, enableSummaryView }, setAttributes }) => {
5
4
  return ([React.createElement(PanelBody, { initialOpen: false, title: __("CSV Configuration") },
@@ -1,25 +1,2 @@
1
- import React from 'react';
2
- import { Measure } from './types';
3
- export type MeasuresProps = {
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: Measure[];
11
- setAttributes: (attributes: any) => void;
12
- title?: string;
13
- format?: any;
14
- currentType?: string;
15
- attributes: {
16
- panelStatus?: any;
17
- measures: Measure[];
18
- dimension1: string;
19
- dimension2?: string;
20
- type: string;
21
- app: string;
22
- };
23
- };
24
- export declare const Measures: (props: MeasuresProps) => React.JSX.Element;
1
+ export function Measures(props: any): import("react").JSX.Element;
25
2
  export default Measures;
package/build/Measures.js CHANGED
@@ -1,4 +1,3 @@
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';
@@ -14,7 +13,7 @@ export const Measures = (props) => {
14
13
  const { onMeasuresChange, onFormatChange, onUseCustomAxisFormatChange, onSetSingleMeasure, onCustomLabelToggleChange, onCustomLabelChange, allMeasures, setAttributes, title, format, attributes: { panelStatus, measures, dimension1, dimension2, type, app } } = props;
15
14
  const MToggle = ({ measure }) => {
16
15
  const userMeasure = measures[app] ? measures[app][measure.value] : {};
17
- return (React.createElement(ToggleControl, { label: getTranslation(measure), checked: userMeasure ? userMeasure.selected : false, onChange: (value) => onMeasuresChange?.(measure.value) }));
16
+ return (React.createElement(ToggleControl, { label: getTranslation(measure), checked: userMeasure ? userMeasure.selected : false, onChange: (value) => onMeasuresChange(measure.value) }));
18
17
  };
19
18
  const MCheckbox = ({ measure }) => {
20
19
  const userMeasure = measures[app] ? measures[app][measure.value] : {};
@@ -65,19 +64,17 @@ export const Measures = (props) => {
65
64
  /*
66
65
  Multiple measures conditions
67
66
 
68
- Bar:
69
- no dimensions selected
70
- one dimension is selected
71
- - not available when second dimension gets selected
72
-
73
- Line:
74
- - Always multi measure as measures represents line series, one dimension should always be selected
67
+ Bar & Line:
68
+ no dimensions selected
69
+ one dimension is selected
70
+ - not available when second dimension gets selected
75
71
 
76
72
  Pie:
77
73
  no dimensions selected
78
74
  - not available when any dimension is selected
79
75
  */
80
- ((type == 'line') || (type == 'radar') ||
76
+ ((type == 'radar') ||
77
+ (type == 'line' && dimension2 == 'none') ||
81
78
  (type == 'bar' && dimension2 == 'none') ||
82
79
  (type == 'pie' && dimension1 == 'none' && dimension2 == 'none')) && allMeasures && [...new Set(allMeasures.map(p => getTranslation(p.group)))].map(g => {
83
80
  return (React.createElement(PanelBody, { initialOpen: panelStatus[g], onToggle: e => togglePanel(g, panelStatus, setAttributes), title: `${g} (${countSelected(g)} / ${countTotal(g)} ) ` }, allMeasures.filter(f => getTranslation(f.group) === g)
@@ -86,27 +83,23 @@ export const Measures = (props) => {
86
83
  }),
87
84
  /*Single measure conditions
88
85
 
89
- Bar:
90
- 2 dimensions selected
91
- Line:
92
- never
93
- Pie:
94
- any dimensions selected
86
+ Bar & Lie:
87
+ 2 dimensions selected
88
+ Pie:
89
+ any dimensions selected
95
90
 
96
- */
97
- ((type == 'big-number') || (type == 'bar' && dimension2 != 'none') || (type == 'pie' && (dimension1 != 'none' || dimension2 != 'none'))) && allMeasures && [...new Set(allMeasures.map(p => getTranslation(p.group)))].map(g => {
91
+ */
92
+ ((type == 'big-number') || (type == 'line' && dimension2 != 'none') || (type == 'bar' && dimension2 != 'none') || (type == 'pie' && (dimension1 != 'none' || dimension2 != 'none'))) && allMeasures && [...new Set(allMeasures.map(p => getTranslation(p.group)))].map(g => {
98
93
  return (React.createElement(PanelBody, { initialOpen: panelStatus[g], onToggle: e => togglePanel(g, panelStatus, setAttributes), title: `${g} (${countSelected(g)} / ${countTotal(g)} ) ` }, allMeasures.filter(f => getTranslation(f.group) === g)
99
94
  .map(m => React.createElement(PanelRow, null,
100
95
  React.createElement(MeasureOptions, { single: true, measure: m })))));
101
96
  }),
102
- (type == 'overlay') && allMeasures && React.createElement(SelectControl, { label: "Measure",
103
- // @ts-ignore
104
- value: selectedMeasures && selectedMeasures[0] ? selectedMeasures[0].value : null, options: [{ value: '', label: 'Select Measure' }, ...allMeasures], onChange: (measure) => onSetSingleMeasure(measure), __nextHasNoMarginBottom: true }),
97
+ (type == 'overlay') && allMeasures && React.createElement(SelectControl, { label: "Measure", value: selectedMeasures && selectedMeasures[0] ? selectedMeasures[0].value : null, options: [{ value: '', label: 'Select Measure' }, ...allMeasures], onChange: (measure) => onSetSingleMeasure(measure), __nextHasNoMarginBottom: true }),
105
98
  (type != 'overlay') && React.createElement(PanelBody, { title: __("Format"), initialOpen: panelStatus["FORMAT"], onToggle: e => togglePanel("FORMAT", panelStatus, setAttributes) },
106
99
  React.createElement(Format, { hiddenCustomAxisFormat: type == 'radar' || type == 'big-number', format: format || (measures[app] && measures[app].format ? measures[app].format : defaultFormat), customFormat: measures[app] && measures[app].customFormat ? measures[app].customFormat : defaultFormat, useCustomAxisFormat: measures[app] ? measures[app].useCustomAxisFormat : false, onFormatChange: (format, field) => {
107
100
  onFormatChange(format, field);
108
101
  }, onUseCustomAxisFormatChange: value => {
109
- onUseCustomAxisFormatChange?.(value);
102
+ onUseCustomAxisFormatChange(value);
110
103
  } }))),
111
104
  (type != 'overlay') && selectedMeasures && selectedMeasures.length > 0 &&
112
105
  React.createElement(PanelBody, { title: __("Measure Label Customization"), initialOpen: panelStatus["MEASURES_LABEL_CUSTOMIZATION"], onToggle: e => togglePanel("MEASURES_LABEL_CUSTOMIZATION", panelStatus, setAttributes) }, selectedMeasures && [...new Set(selectedMeasures.map(p => getTranslation(p.group)))].map(g => {
@@ -115,11 +108,11 @@ export const Measures = (props) => {
115
108
  const userMeasure = measures[app] ? measures[app][m.value] : {};
116
109
  return (React.createElement(React.Fragment, null,
117
110
  React.createElement(PanelRow, null,
118
- React.createElement(ToggleControl, { label: getTranslation(m), checked: userMeasure ? userMeasure.hasCustomLabel : false, onChange: (value) => onCustomLabelToggleChange?.(m.value) }),
111
+ React.createElement(ToggleControl, { label: getTranslation(m), checked: userMeasure ? userMeasure.hasCustomLabel : false, onChange: (value) => onCustomLabelToggleChange(m.value) }),
119
112
  " "),
120
113
  userMeasure.hasCustomLabel &&
121
114
  React.createElement(PanelRow, null,
122
- React.createElement(TextControl, { label: __("Custom Label"), value: userMeasure ? userMeasure.customLabel : "", onChange: (value) => onCustomLabelChange?.(m.value, value) }))));
115
+ React.createElement(TextControl, { label: __("Custom Label"), value: userMeasure ? userMeasure.customLabel : "", onChange: (value) => onCustomLabelChange(m.value, value) }))));
123
116
  })));
124
117
  })));
125
118
  };
@@ -1,6 +1,6 @@
1
- export declare function extractAxisValues(csvData: string): string[];
2
- export declare function transformDataToAppObject(data: any[], appName: string, existingObject?: any): any;
3
- export declare function getSelectedItemsForApp(config: Record<string, any>, appName: string): {};
4
- export declare function getSelectedLabelsForApp(data: any, appName: string): any[];
5
- export declare function updateMeasureLabels(data: any, measures: any, app: string): void;
6
- export declare function getStoredOrSetItem(key: any, fallback: any, overwrite?: boolean): any;
1
+ export function extractAxisValues(csvData: any): any;
2
+ export function transformDataToAppObject(data: any, appName: any, existingObject?: {}): {};
3
+ export function getSelectedItemsForApp(config: any, appName: any): {};
4
+ export function getSelectedLabelsForApp(data: any, appName: any): any[];
5
+ export function updateMeasureLabels(data: any, measures: any, app: any): void;
6
+ export function getStoredOrSetItem(key: any, fallback: any, overwrite?: boolean): any;
@@ -1,4 +1,4 @@
1
- import isEmpty from 'lodash.isempty';
1
+ import _ from 'lodash';
2
2
  import { getTranslatedOptions } from "./APIutils";
3
3
  export function extractAxisValues(csvData) {
4
4
  const lines = csvData.split("\n");
@@ -12,20 +12,22 @@ export function transformDataToAppObject(data, appName, existingObject = {}) {
12
12
  return existingObject;
13
13
  }
14
14
  existingObject[appName] = {};
15
- data?.forEach((item) => {
16
- const key = item.value;
17
- existingObject[appName][key] = {
18
- selected: false,
19
- format: {
20
- style: "percent",
21
- minimumFractionDigits: 1,
22
- maximumFractionDigits: 1,
23
- currency: "USD",
24
- },
25
- hasCustomLabel: false,
26
- customLabel: item.label || key,
27
- };
28
- });
15
+ if (data) {
16
+ data.forEach((item) => {
17
+ const key = item.value;
18
+ existingObject[appName][key] = {
19
+ selected: false,
20
+ format: {
21
+ style: "percent",
22
+ minimumFractionDigits: 1,
23
+ maximumFractionDigits: 1,
24
+ currency: "USD",
25
+ },
26
+ hasCustomLabel: false,
27
+ customLabel: item.label || key,
28
+ };
29
+ });
30
+ }
29
31
  return existingObject;
30
32
  }
31
33
  export function getSelectedItemsForApp(config, appName) {
@@ -42,7 +44,7 @@ export function getSelectedItemsForApp(config, appName) {
42
44
  return selectedEntries;
43
45
  }
44
46
  export function getSelectedLabelsForApp(data, appName) {
45
- const appData = data[appName];
47
+ const appData = data;
46
48
  if (!appData) {
47
49
  return [];
48
50
  }
@@ -66,20 +68,14 @@ export function updateMeasureLabels(data, measures, app) {
66
68
  }
67
69
  });
68
70
  }
69
- ;
70
71
  export function getStoredOrSetItem(key, fallback, overwrite = false) {
71
72
  const fallbackValue = fallback || [];
72
- if (overwrite && !isEmpty(fallbackValue)) {
73
+ if (overwrite && !_.isEmpty(fallbackValue)) {
73
74
  sessionStorage
74
75
  .setItem(key, JSON.stringify(fallbackValue));
75
76
  return fallbackValue;
76
77
  }
77
- const storedItem = sessionStorage.getItem(key);
78
- if (storedItem === null) {
79
- sessionStorage.setItem(key, JSON.stringify(fallbackValue));
80
- return fallbackValue;
81
- }
82
- const stored = JSON.parse(storedItem);
78
+ const stored = JSON.parse(sessionStorage.getItem(key));
83
79
  if (!stored) {
84
80
  sessionStorage.setItem(key, JSON.stringify(fallbackValue));
85
81
  return fallbackValue;
@@ -1,3 +1,3 @@
1
- import React from 'react';
2
- export declare const Tooltip: (props: any) => React.JSX.Element[];
1
+ export function Tooltip(props: any): React.JSX.Element[];
3
2
  export default Tooltip;
3
+ import React from 'react';
package/build/Util.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- export declare const togglePanel: <T extends Record<string, any> = Record<string, any>>(name: string, panelStatus: Record<string, boolean>, setAttributes: (attributes: T) => void) => void;
2
- export declare const panelFocus: <T extends Record<string, any> = Record<string, any>>(name: string, panelStatus: Record<string, boolean>, setAttributes: (attributes: T) => void) => void;
3
- declare const _default: {
4
- togglePanel: <T extends Record<string, any> = Record<string, any>>(name: string, panelStatus: Record<string, boolean>, setAttributes: (attributes: T) => void) => void;
5
- panelFocus: <T extends Record<string, any> = Record<string, any>>(name: string, panelStatus: Record<string, boolean>, setAttributes: (attributes: T) => void) => void;
6
- };
1
+ export function togglePanel(name: any, panelStatus: any, setAttributes: any): void;
2
+ export function panelFocus(name: any): void;
3
+ declare namespace _default {
4
+ export { togglePanel };
5
+ }
7
6
  export default _default;
package/build/Util.js CHANGED
@@ -3,9 +3,9 @@ export const togglePanel = (name, panelStatus, setAttributes) => {
3
3
  newStatus[name] = newStatus[name] == true ? false : true;
4
4
  setAttributes({ panelStatus: newStatus });
5
5
  };
6
- export const panelFocus = (name, panelStatus, setAttributes) => {
6
+ export const panelFocus = (name) => {
7
7
  const newStatus = { ...panelStatus };
8
8
  newStatus[name] = newStatus[name] == true ? false : true;
9
9
  setAttributes({ panelFocus: newStatus });
10
10
  };
11
- export default { togglePanel, panelFocus };
11
+ export default { togglePanel };
@@ -1,3 +1,3 @@
1
- import React from 'react';
2
- export declare const ChartIcon: () => React.JSX.Element;
1
+ export function ChartIcon(): React.JSX.Element;
3
2
  export default ChartIcon;
3
+ import React from 'react';
@@ -1,3 +1,3 @@
1
- import React from 'react';
2
- export declare const GenericIcon: () => React.JSX.Element;
1
+ export function GenericIcon(): React.JSX.Element;
3
2
  export default GenericIcon;
3
+ import React from 'react';
@@ -1,2 +1,2 @@
1
- export { GenericIcon } from './Generic';
2
- export { ChartIcon } from './Chart';
1
+ export { GenericIcon } from "./Generic";
2
+ export { ChartIcon } from "./Chart";