@cashub/ui 0.21.0 → 0.21.1
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/Tab/Tab.js +9 -13
- package/Tab/TabList.js +14 -32
- package/Tab/TabPanel.js +21 -58
- package/Tab/TabTab.js +20 -40
- package/Tab/index.js +2 -10
- package/Tab/subComponent/TabContext.js +2 -5
- package/animate/Collapse.js +26 -53
- package/animate/Loader.js +21 -26
- package/animate/NumberCounter.js +22 -44
- package/animate/PulseRing.js +9 -21
- package/animate/Spinner.js +2 -10
- package/animate/index.js +5 -11
- package/backdrop/BaseBackdrop.js +2 -9
- package/backdrop/LoadingBackdrop.js +2 -9
- package/backdrop/ModalBackdrop.js +2 -9
- package/backdrop/index.js +3 -7
- package/badge/Badge.js +2 -11
- package/badge/BadgeDot.js +2 -10
- package/badge/BadgeFill.js +15 -20
- package/badge/BadgeWithText.js +6 -13
- package/badge/index.js +4 -9
- package/billing/BarChart.js +10 -17
- package/billing/Grid.js +11 -15
- package/billing/Header2.js +6 -9
- package/billing/Header3.js +9 -16
- package/billing/Paragraph.js +8 -14
- package/billing/ParagraphGroup.js +6 -9
- package/billing/ParagraphText.js +7 -12
- package/billing/Section.js +13 -23
- package/billing/SectionBody.js +5 -8
- package/billing/SectionHeader.js +7 -12
- package/breadcrumb/Breadcrumb.js +11 -21
- package/breadcrumb/index.js +1 -3
- package/button/Button.js +41 -38
- package/button/ButtonGroup.js +21 -18
- package/button/IconButton.js +29 -29
- package/button/ScrollToTopButton.js +12 -39
- package/button/index.js +4 -9
- package/callout/Callout.js +13 -26
- package/callout/index.js +1 -3
- package/chart/BarChart.js +28 -53
- package/chart/DoughnutChart.js +23 -62
- package/chart/LineChart.js +33 -55
- package/chart/SingleBarChart.js +11 -17
- package/chart/index.js +5 -12
- package/chart/utils/customTooltip.js +26 -43
- package/chart/utils/htmlLegendPlugin.js +24 -30
- package/chart/utils/index.js +3 -7
- package/chart/utils/padEmptyChartBar.js +24 -22
- package/container/FlexContainer.js +9 -12
- package/container/index.js +1 -3
- package/cropper/Cropper.js +21 -34
- package/cropper/CropperModalHandler.js +15 -21
- package/cropper/index.js +2 -5
- package/cropper/subComponent/CropImageModal.js +23 -58
- package/datetimePicker/DatePicker.js +103 -217
- package/datetimePicker/DatePickerV2.js +116 -221
- package/datetimePicker/DatetimePicker.js +27 -48
- package/datetimePicker/DatetimePickerV2.js +115 -231
- package/datetimePicker/TimeInput.js +9 -22
- package/datetimePicker/TimePicker.js +94 -151
- package/datetimePicker/TimePickerStyle.js +2 -9
- package/datetimePicker/accordion/Month.js +70 -90
- package/datetimePicker/accordion/Year.js +91 -135
- package/datetimePicker/hooks/index.js +3 -7
- package/datetimePicker/hooks/useChangeNumber.js +14 -27
- package/datetimePicker/hooks/useDecrease.js +19 -35
- package/datetimePicker/hooks/useIncrease.js +19 -35
- package/datetimePicker/index.js +7 -15
- package/datetimePicker/provider/constant.js +2 -3
- package/datetimePicker/subComponent/Accordion.js +108 -158
- package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
- package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
- package/datetimePicker/utils/GMTDate.js +3 -7
- package/datetimePicker/utils/pad.js +2 -6
- package/datetimePicker/utils/toUTC0.js +3 -6
- package/descriptionList/DescriptionDetail.js +5 -10
- package/descriptionList/DescriptionList.js +5 -10
- package/descriptionList/DescriptionTerm.js +2 -9
- package/descriptionList/index.js +3 -7
- package/divider/Divider.js +9 -12
- package/divider/index.js +1 -3
- package/dropdown/Dropdown.js +28 -65
- package/dropdown/DropdownButtonOption.js +2 -9
- package/dropdown/DropdownContent.js +33 -64
- package/dropdown/DropdownDivOption.js +2 -9
- package/dropdown/DropdownItem.js +10 -16
- package/dropdown/DropdownLinkOption.js +2 -9
- package/dropdown/DropdownToggle.js +18 -38
- package/dropdown/index.js +6 -17
- package/dropdown/subComponent/DropdownContext.js +2 -5
- package/dropzone/FileDropzone.js +148 -302
- package/dropzone/ImageDropzone.js +96 -171
- package/dropzone/index.js +2 -5
- package/dropzone/subComponent/Message.js +7 -14
- package/figure/IconFigure.js +9 -16
- package/figure/ImageFigure.js +11 -17
- package/figure/index.js +2 -5
- package/file/HiddenFileInput.js +5 -14
- package/file/index.js +1 -3
- package/form/Checkbox.js +34 -43
- package/form/FormItem.js +2 -9
- package/form/Input.js +13 -15
- package/form/Label.js +10 -13
- package/form/MutedText.js +5 -10
- package/form/RadioButton.js +20 -32
- package/form/Searchbox.js +21 -65
- package/form/Slider.js +14 -0
- package/form/SwitchButton.js +34 -39
- package/form/Textarea.js +2 -11
- package/form/index.js +9 -19
- package/grid/Column.js +17 -17
- package/grid/Grid.js +13 -14
- package/grid/index.js +2 -5
- package/heading/Heading1.js +5 -10
- package/heading/Heading2.js +9 -12
- package/heading/Heading3.js +21 -18
- package/heading/index.js +3 -7
- package/helmet/Helmet.js +6 -9
- package/helmet/index.js +2 -5
- package/iconbox/ApplicationIconBox.js +25 -31
- package/iconbox/IconBox.js +11 -24
- package/iconbox/IconBoxV2.js +14 -26
- package/iconbox/index.js +3 -7
- package/iconbox/subComponent/IconBoxFigure.js +25 -20
- package/iconbox/subComponent/IconBoxImage.js +15 -18
- package/image/ImageFluid.js +2 -10
- package/image/UploadImage.js +65 -113
- package/image/index.js +2 -5
- package/index.js +44 -130
- package/jsoneditor/JsonEditor.js +10 -32
- package/jsoneditor/index.js +1 -3
- package/keyframe/Pulse.js +2 -7
- package/keyframe/Spin.js +2 -7
- package/link/LinkSpan.js +22 -35
- package/link/index.js +1 -3
- package/map/GoogleMap.js +122 -175
- package/map/GoogleReverseGeolocation.js +79 -186
- package/map/LeafletMap.js +78 -132
- package/map/LeafletReverseGeolocation.js +49 -121
- package/map/index.js +4 -9
- package/map/subComponent/BasicLeafletMap.js +8 -14
- package/map/subComponent/GoogleMapContainer.js +5 -10
- package/map/subComponent/GoogleMapPopup.js +66 -123
- package/map/subComponent/GoogleMapWrapper.js +13 -32
- package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
- package/map/subComponent/LeafletDrawControl.js +47 -84
- package/map/subComponent/LeafletMapContainer.js +5 -10
- package/map/subComponent/MapSearchBoxControl.js +24 -70
- package/modal/StateModal.js +41 -100
- package/modal/TitleModal.js +89 -190
- package/modal/index.js +2 -5
- package/package.json +1 -1
- package/paginate/Paginate.js +40 -54
- package/paginate/index.js +1 -3
- package/popover/Popover.js +39 -87
- package/popover/index.js +1 -3
- package/qrcode/QRCode.js +10 -23
- package/qrcode/QRCodeContainter.js +8 -16
- package/qrcode/index.js +2 -5
- package/ribbon/Ribbon.js +4 -15
- package/ribbon/index.js +1 -3
- package/section/Section.js +57 -39
- package/section/SectionBody.js +15 -22
- package/section/SectionHeader.js +27 -27
- package/section/SectionToolbar.js +2 -9
- package/section/SectionToolbarItem.js +2 -9
- package/section/index.js +5 -11
- package/select/InputSelect.js +103 -215
- package/select/Select.js +204 -362
- package/select/index.js +2 -5
- package/select/subComponent/ListBox.js +9 -12
- package/select/subComponent/Option.js +8 -16
- package/select/subComponent/OptionGroup.js +2 -9
- package/select/subComponent/Options.js +5 -11
- package/select/subComponent/SearchBox.js +9 -29
- package/select/subComponent/SelectedMultiple.js +8 -16
- package/select/subComponent/SelectedSingle.js +2 -9
- package/styles/GlobalStyle.js +169 -91
- package/styles/config/breakpoint.style.js +2 -3
- package/styles/config/header.style.js +2 -3
- package/styles/config/sidebar.style.js +2 -3
- package/styles/index.js +2 -5
- package/styles/mixin/backgroundColor.js +17 -14
- package/styles/mixin/borderColor.js +17 -14
- package/styles/mixin/color.js +17 -14
- package/styles/mixin/colorOnBackground.js +17 -14
- package/styles/mixin/inputPlaceholder.js +3 -9
- package/styles/mixin/media.js +3 -11
- package/styles/mixin/rounded.js +13 -12
- package/styles/mixin/scrollbar.js +7 -13
- package/styles/theme/dark.theme.js +20 -20
- package/styles/theme/light.theme.js +20 -20
- package/styles/theme/white.theme.js +20 -20
- package/styles/themes.js +2 -8
- package/table/GridTable.js +105 -143
- package/table/ImageBox.js +8 -18
- package/table/PermissionTable.js +25 -25
- package/table/Table.js +137 -153
- package/table/__mock__/columns.js +2 -3
- package/table/__mock__/data.js +2 -3
- package/table/hooks/index.js +2 -5
- package/table/hooks/useCalculateDataRange.js +9 -36
- package/table/hooks/useGenerateSort.js +6 -17
- package/table/index.js +4 -9
- package/table/subComponent/BaseTableHeadCell.js +15 -21
- package/table/subComponent/GridTableFooter.js +5 -10
- package/table/subComponent/GridTableHeadCell.js +5 -10
- package/table/subComponent/Resizer.js +17 -44
- package/table/subComponent/TableFooter.js +5 -10
- package/table/subComponent/TableFooterInfo.js +2 -9
- package/table/subComponent/TableFooterPager.js +5 -12
- package/table/subComponent/TableHeadCell.js +2 -9
- package/table/subComponent/TableSort.js +13 -19
- package/tagify/TagifyStyle.js +2 -9
- package/tagify/Tags.js +15 -37
- package/tagify/index.js +2 -5
- package/text/Paragraph.js +25 -20
- package/text/index.js +1 -3
- package/timeline/Timeline.js +28 -37
- package/timeline/index.js +1 -3
- package/toast/CustomToastContainer.js +2 -9
- package/toast/MessageContainer.js +9 -18
- package/toast/index.js +3 -8
- package/toast/show.js +18 -28
- package/tooltip/Tooltip.js +48 -97
- package/tooltip/index.js +1 -3
- package/wizard/Wizard.js +63 -133
- package/wizard/index.js +1 -3
package/chart/BarChart.js
CHANGED
|
@@ -4,48 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _styledComponents = require("styled-components");
|
|
11
|
-
|
|
12
9
|
var _reactChartjs = require("react-chartjs-2");
|
|
13
|
-
|
|
14
10
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
15
|
-
|
|
16
11
|
var _padEmptyChartBar = _interopRequireDefault(require("./utils/padEmptyChartBar"));
|
|
17
|
-
|
|
18
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
|
|
20
|
-
var _excluded = ["height", "data", "options"];
|
|
21
|
-
|
|
22
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var BarChart = function BarChart(_ref) {
|
|
35
|
-
var _ref$height = _ref.height,
|
|
36
|
-
height = _ref$height === void 0 ? 300 : _ref$height,
|
|
37
|
-
data = _ref.data,
|
|
38
|
-
_ref$options = _ref.options,
|
|
39
|
-
options = _ref$options === void 0 ? {} : _ref$options,
|
|
40
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
-
|
|
42
|
-
var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
|
|
43
|
-
|
|
14
|
+
const BarChart = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
height = 300,
|
|
17
|
+
data,
|
|
18
|
+
options = {},
|
|
19
|
+
...props
|
|
20
|
+
} = _ref;
|
|
21
|
+
const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
|
|
22
|
+
|
|
23
|
+
// fix: read value from theme
|
|
44
24
|
_reactChartjs.defaults.font.family = theme.fontFamily;
|
|
45
25
|
_reactChartjs.defaults.font.size = 16;
|
|
46
26
|
_reactChartjs.defaults.color = theme.fontOnBg;
|
|
47
27
|
_reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
|
|
48
|
-
|
|
28
|
+
const customOptions = (0, _react.useMemo)(() => {
|
|
49
29
|
return {
|
|
50
30
|
onlyFirstTooltips: options.onlyFirstTooltips === undefined ? true : options.onlyFirstTooltips,
|
|
51
31
|
maxBarNumber: options.maxBarNumber === undefined ? 5 : options.maxBarNumber,
|
|
@@ -55,7 +35,7 @@ var BarChart = function BarChart(_ref) {
|
|
|
55
35
|
rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel
|
|
56
36
|
};
|
|
57
37
|
}, [options]);
|
|
58
|
-
|
|
38
|
+
const defaultOptions = (0, _react.useMemo)(() => {
|
|
59
39
|
return {
|
|
60
40
|
responsive: true,
|
|
61
41
|
maintainAspectRatio: false,
|
|
@@ -71,33 +51,30 @@ var BarChart = function BarChart(_ref) {
|
|
|
71
51
|
tooltip: {
|
|
72
52
|
enabled: false,
|
|
73
53
|
intersect: false,
|
|
74
|
-
filter
|
|
54
|
+
filter(context) {
|
|
75
55
|
return !customOptions.onlyFirstTooltips || context.datasetIndex === 0 && context.label !== 'null';
|
|
76
56
|
},
|
|
77
57
|
callbacks: {
|
|
78
|
-
title
|
|
58
|
+
title(context) {
|
|
79
59
|
return context[0] ? context[0].label.match(/(.{1,20})/g) : '';
|
|
80
60
|
},
|
|
81
|
-
label
|
|
82
|
-
|
|
83
|
-
|
|
61
|
+
label(context) {
|
|
62
|
+
const label = context.dataset.data[context.dataIndex];
|
|
84
63
|
if (context.dataset.customLabel) {
|
|
85
64
|
return context.dataset.customLabel[context.dataIndex].toString();
|
|
86
65
|
}
|
|
87
|
-
|
|
88
66
|
return label.toString();
|
|
89
67
|
},
|
|
90
|
-
labelTextColor
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
labelTextColor(context) {
|
|
69
|
+
const {
|
|
70
|
+
color
|
|
71
|
+
} = context.dataset;
|
|
93
72
|
if (!color) {
|
|
94
73
|
return theme.fontOnPrimary;
|
|
95
74
|
}
|
|
96
|
-
|
|
97
75
|
if (color && Array.isArray(color)) {
|
|
98
76
|
return color[context.dataIndex % color.length];
|
|
99
77
|
}
|
|
100
|
-
|
|
101
78
|
return color;
|
|
102
79
|
}
|
|
103
80
|
}
|
|
@@ -112,8 +89,8 @@ var BarChart = function BarChart(_ref) {
|
|
|
112
89
|
},
|
|
113
90
|
ticks: {
|
|
114
91
|
minRotation: customOptions.rotateLabel ? 15 : 0,
|
|
115
|
-
callback
|
|
116
|
-
|
|
92
|
+
callback(value) {
|
|
93
|
+
const label = this.getLabelForValue(value);
|
|
117
94
|
return label && label.length > 11 ? "".concat(label.substr(0, 11), "...") : label;
|
|
118
95
|
}
|
|
119
96
|
}
|
|
@@ -126,11 +103,10 @@ var BarChart = function BarChart(_ref) {
|
|
|
126
103
|
drawBorder: false
|
|
127
104
|
},
|
|
128
105
|
ticks: {
|
|
129
|
-
callback
|
|
106
|
+
callback(value) {
|
|
130
107
|
if (value % 1 === 0) {
|
|
131
108
|
return value;
|
|
132
109
|
}
|
|
133
|
-
|
|
134
110
|
return null;
|
|
135
111
|
}
|
|
136
112
|
}
|
|
@@ -138,13 +114,12 @@ var BarChart = function BarChart(_ref) {
|
|
|
138
114
|
}
|
|
139
115
|
};
|
|
140
116
|
}, [customOptions, theme.fontOnPrimary]);
|
|
141
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Bar,
|
|
117
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Bar, {
|
|
142
118
|
height: height,
|
|
143
119
|
data: data,
|
|
144
120
|
options: defaultOptions,
|
|
145
|
-
plugins: [_padEmptyChartBar.default]
|
|
146
|
-
|
|
121
|
+
plugins: [_padEmptyChartBar.default],
|
|
122
|
+
...props
|
|
123
|
+
});
|
|
147
124
|
};
|
|
148
|
-
|
|
149
|
-
var _default = BarChart;
|
|
150
|
-
exports.default = _default;
|
|
125
|
+
var _default = exports.default = BarChart;
|
package/chart/DoughnutChart.js
CHANGED
|
@@ -4,64 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _styledComponents = require("styled-components");
|
|
11
|
-
|
|
12
9
|
var _reactChartjs = require("react-chartjs-2");
|
|
13
|
-
|
|
14
10
|
var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
|
|
15
|
-
|
|
16
11
|
var _htmlLegendPlugin = _interopRequireDefault(require("./utils/htmlLegendPlugin"));
|
|
17
|
-
|
|
18
12
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
19
|
-
|
|
20
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
|
|
22
|
-
var _excluded = ["height", "data"];
|
|
23
|
-
|
|
24
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
-
|
|
38
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
39
|
-
|
|
40
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
41
|
-
|
|
42
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
|
-
|
|
44
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
45
|
-
|
|
46
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
47
|
-
|
|
48
|
-
var DoughnutChart = function DoughnutChart(_ref) {
|
|
49
|
-
var _ref$height = _ref.height,
|
|
50
|
-
height = _ref$height === void 0 ? 300 : _ref$height,
|
|
51
|
-
data = _ref.data,
|
|
52
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
53
|
-
|
|
54
|
-
var _useState = (0, _react.useState)((0, _lodash.default)('legend-container-')),
|
|
55
|
-
_useState2 = _slicedToArray(_useState, 1),
|
|
56
|
-
legendContainerId = _useState2[0];
|
|
57
|
-
|
|
58
|
-
var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
|
|
59
|
-
|
|
15
|
+
const DoughnutChart = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
height = 300,
|
|
18
|
+
data,
|
|
19
|
+
...props
|
|
20
|
+
} = _ref;
|
|
21
|
+
const [legendContainerId] = (0, _react.useState)((0, _lodash.default)('legend-container-'));
|
|
22
|
+
const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
|
|
23
|
+
|
|
24
|
+
// fix: read value from theme
|
|
60
25
|
_reactChartjs.defaults.font.family = theme.fontFamily;
|
|
61
26
|
_reactChartjs.defaults.font.size = 16;
|
|
62
27
|
_reactChartjs.defaults.color = theme.fontOnBg;
|
|
63
28
|
_reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
|
|
64
|
-
|
|
29
|
+
const defaultOptions = (0, _react.useMemo)(() => {
|
|
65
30
|
return {
|
|
66
31
|
responsive: true,
|
|
67
32
|
maintainAspectRatio: false,
|
|
@@ -76,29 +41,26 @@ var DoughnutChart = function DoughnutChart(_ref) {
|
|
|
76
41
|
tooltip: {
|
|
77
42
|
enabled: false,
|
|
78
43
|
callbacks: {
|
|
79
|
-
title
|
|
44
|
+
title(context) {
|
|
80
45
|
return context[0] ? context[0].label.match(/(.{1,20})/g) : '';
|
|
81
46
|
},
|
|
82
|
-
label
|
|
83
|
-
|
|
84
|
-
|
|
47
|
+
label(context) {
|
|
48
|
+
const label = context.dataset.data[context.dataIndex];
|
|
85
49
|
if (context.dataset.customLabel) {
|
|
86
50
|
return context.dataset.customLabel[context.dataIndex].toString();
|
|
87
51
|
}
|
|
88
|
-
|
|
89
52
|
return label.toString();
|
|
90
53
|
},
|
|
91
|
-
labelTextColor
|
|
92
|
-
|
|
93
|
-
|
|
54
|
+
labelTextColor(context) {
|
|
55
|
+
const {
|
|
56
|
+
color
|
|
57
|
+
} = context.dataset;
|
|
94
58
|
if (!color) {
|
|
95
59
|
return theme.fontOnPrimary;
|
|
96
60
|
}
|
|
97
|
-
|
|
98
61
|
if (color && Array.isArray(color)) {
|
|
99
62
|
return color[context.dataIndex % color.length];
|
|
100
63
|
}
|
|
101
|
-
|
|
102
64
|
return color;
|
|
103
65
|
}
|
|
104
66
|
}
|
|
@@ -108,17 +70,16 @@ var DoughnutChart = function DoughnutChart(_ref) {
|
|
|
108
70
|
}, [legendContainerId, theme.fontOnPrimary]);
|
|
109
71
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
110
72
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
111
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut,
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut, {
|
|
112
74
|
height: height,
|
|
113
75
|
data: data,
|
|
114
76
|
options: defaultOptions,
|
|
115
|
-
plugins: [_htmlLegendPlugin.default]
|
|
116
|
-
|
|
77
|
+
plugins: [_htmlLegendPlugin.default],
|
|
78
|
+
...props
|
|
79
|
+
})
|
|
117
80
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
118
81
|
id: legendContainerId
|
|
119
82
|
})]
|
|
120
83
|
});
|
|
121
84
|
};
|
|
122
|
-
|
|
123
|
-
var _default = DoughnutChart;
|
|
124
|
-
exports.default = _default;
|
|
85
|
+
var _default = exports.default = DoughnutChart;
|
package/chart/LineChart.js
CHANGED
|
@@ -4,60 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _styledComponents = require("styled-components");
|
|
11
|
-
|
|
12
9
|
var _reactChartjs = require("react-chartjs-2");
|
|
13
|
-
|
|
14
10
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
15
|
-
|
|
16
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
|
|
18
|
-
var _excluded = ["height", "data", "options"];
|
|
19
|
-
|
|
20
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var LineChart = function LineChart(_ref) {
|
|
33
|
-
var _ref$height = _ref.height,
|
|
34
|
-
height = _ref$height === void 0 ? 300 : _ref$height,
|
|
35
|
-
data = _ref.data,
|
|
36
|
-
_ref$options = _ref.options,
|
|
37
|
-
options = _ref$options === void 0 ? {} : _ref$options,
|
|
38
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
-
|
|
40
|
-
var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
|
|
41
|
-
|
|
13
|
+
const LineChart = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
height = 300,
|
|
16
|
+
data,
|
|
17
|
+
options = {},
|
|
18
|
+
...props
|
|
19
|
+
} = _ref;
|
|
20
|
+
const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
|
|
21
|
+
|
|
22
|
+
// fix: read value from theme
|
|
42
23
|
_reactChartjs.defaults.font.family = theme.fontFamily;
|
|
43
24
|
_reactChartjs.defaults.font.size = 16;
|
|
44
25
|
_reactChartjs.defaults.color = theme.fontOnBg;
|
|
45
26
|
_reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
|
|
46
|
-
|
|
27
|
+
const customOptions = (0, _react.useMemo)(() => {
|
|
47
28
|
return {
|
|
48
29
|
suggestedMax: options.suggestedMax ? options.suggestedMax : 10,
|
|
49
30
|
tooltipTitlePrefix: '',
|
|
50
31
|
tooltipLabelPrefix: ''
|
|
51
32
|
};
|
|
52
33
|
}, [options]);
|
|
53
|
-
|
|
54
34
|
if (options.tooltips) {
|
|
55
|
-
|
|
35
|
+
const tooltipsOptions = options.tooltips;
|
|
56
36
|
customOptions.tooltipTitlePrefix = tooltipsOptions.titlePrefix || '';
|
|
57
37
|
customOptions.tooltipLabelPrefix = tooltipsOptions.labelPrefix || '';
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
var defaultOptions = (0, _react.useMemo)(function () {
|
|
39
|
+
const defaultOptions = (0, _react.useMemo)(() => {
|
|
61
40
|
return {
|
|
62
41
|
responsive: true,
|
|
63
42
|
maintainAspectRatio: false,
|
|
@@ -69,36 +48,37 @@ var LineChart = function LineChart(_ref) {
|
|
|
69
48
|
tooltip: {
|
|
70
49
|
enabled: false,
|
|
71
50
|
intersect: false,
|
|
72
|
-
filter
|
|
51
|
+
filter(context) {
|
|
73
52
|
return context.datasetIndex === 0 && context.label !== 'null';
|
|
74
53
|
},
|
|
75
54
|
callbacks: {
|
|
76
|
-
title
|
|
77
|
-
|
|
55
|
+
title(context) {
|
|
56
|
+
const content = context[0] ? context[0].label.match(/(.{1,20})/g) : '';
|
|
78
57
|
return "".concat(customOptions.tooltipTitlePrefix).concat(content);
|
|
79
58
|
},
|
|
80
|
-
label
|
|
81
|
-
|
|
59
|
+
label(context) {
|
|
60
|
+
const content = context.dataset.data[context.dataIndex].toString();
|
|
82
61
|
return "".concat(customOptions.tooltipLabelPrefix).concat(content);
|
|
83
62
|
},
|
|
84
|
-
labelColor
|
|
85
|
-
|
|
63
|
+
labelColor(context) {
|
|
64
|
+
const {
|
|
65
|
+
borderColor
|
|
66
|
+
} = context.dataset;
|
|
86
67
|
return {
|
|
87
|
-
borderColor
|
|
68
|
+
borderColor,
|
|
88
69
|
backgroundColor: borderColor
|
|
89
70
|
};
|
|
90
71
|
},
|
|
91
|
-
labelTextColor
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
labelTextColor(context) {
|
|
73
|
+
const {
|
|
74
|
+
color
|
|
75
|
+
} = context.dataset;
|
|
94
76
|
if (!color) {
|
|
95
77
|
return theme.fontOnPrimary;
|
|
96
78
|
}
|
|
97
|
-
|
|
98
79
|
if (color && Array.isArray(color)) {
|
|
99
80
|
return color[context.dataIndex % color.length];
|
|
100
81
|
}
|
|
101
|
-
|
|
102
82
|
return color;
|
|
103
83
|
}
|
|
104
84
|
}
|
|
@@ -119,11 +99,10 @@ var LineChart = function LineChart(_ref) {
|
|
|
119
99
|
drawBorder: false
|
|
120
100
|
},
|
|
121
101
|
ticks: {
|
|
122
|
-
callback
|
|
102
|
+
callback(value) {
|
|
123
103
|
if (value % 1 === 0) {
|
|
124
104
|
return value;
|
|
125
105
|
}
|
|
126
|
-
|
|
127
106
|
return null;
|
|
128
107
|
}
|
|
129
108
|
}
|
|
@@ -131,12 +110,11 @@ var LineChart = function LineChart(_ref) {
|
|
|
131
110
|
}
|
|
132
111
|
};
|
|
133
112
|
}, [customOptions, theme.fontOnPrimary]);
|
|
134
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Line,
|
|
113
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Line, {
|
|
135
114
|
height: height,
|
|
136
115
|
data: data,
|
|
137
|
-
options: defaultOptions
|
|
138
|
-
|
|
116
|
+
options: defaultOptions,
|
|
117
|
+
...props
|
|
118
|
+
});
|
|
139
119
|
};
|
|
140
|
-
|
|
141
|
-
var _default = LineChart;
|
|
142
|
-
exports.default = _default;
|
|
120
|
+
var _default = exports.default = LineChart;
|
package/chart/SingleBarChart.js
CHANGED
|
@@ -4,28 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
|
|
10
8
|
var _backgroundColor = _interopRequireDefault(require("../styles/mixin/backgroundColor"));
|
|
11
|
-
|
|
12
9
|
var _templateObject;
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
var percentage = _ref.percentage;
|
|
12
|
+
const SingleBarChart = _styledComponents.default.div.attrs(() => ({
|
|
13
|
+
primary: true
|
|
14
|
+
}))(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n height: 1rem;\n border-radius: var(--border-radius);\n background: var(--color-background3);\n\n &::before {\n position: absolute;\n content: '';\n width: ", "%;\n border-radius: var(--border-radius);\n top: 0;\n bottom: 0;\n\n ", "\n }\n\n ", "\n"])), _ref => {
|
|
15
|
+
let {
|
|
16
|
+
percentage
|
|
17
|
+
} = _ref;
|
|
24
18
|
return percentage;
|
|
25
|
-
}, _backgroundColor.default,
|
|
26
|
-
|
|
19
|
+
}, _backgroundColor.default, _ref2 => {
|
|
20
|
+
let {
|
|
21
|
+
marginTop
|
|
22
|
+
} = _ref2;
|
|
27
23
|
return marginTop && 'margin-top: var(--spacing-s)';
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
var _default = SingleBarChart;
|
|
31
|
-
exports.default = _default;
|
|
25
|
+
var _default = exports.default = SingleBarChart;
|
package/chart/index.js
CHANGED
|
@@ -11,49 +11,42 @@ var _exportNames = {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "BarChart", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _BarChart.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "DoughnutChart", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _DoughnutChart.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "LineChart", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _LineChart.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "SingleBarChart", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _SingleBarChart.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
|
|
37
36
|
var _BarChart = _interopRequireDefault(require("./BarChart"));
|
|
38
|
-
|
|
39
37
|
var _DoughnutChart = _interopRequireDefault(require("./DoughnutChart"));
|
|
40
|
-
|
|
41
38
|
var _LineChart = _interopRequireDefault(require("./LineChart"));
|
|
42
|
-
|
|
43
39
|
var _SingleBarChart = _interopRequireDefault(require("./SingleBarChart"));
|
|
44
|
-
|
|
45
40
|
var _utils = require("./utils");
|
|
46
|
-
|
|
47
41
|
Object.keys(_utils).forEach(function (key) {
|
|
48
42
|
if (key === "default" || key === "__esModule") return;
|
|
49
43
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
50
44
|
if (key in exports && exports[key] === _utils[key]) return;
|
|
51
45
|
Object.defineProperty(exports, key, {
|
|
52
46
|
enumerable: true,
|
|
53
|
-
get: function
|
|
47
|
+
get: function () {
|
|
54
48
|
return _utils[key];
|
|
55
49
|
}
|
|
56
50
|
});
|
|
57
51
|
});
|
|
58
|
-
|
|
59
52
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|