@majoo-ui/react 1.57.3 → 1.57.4

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,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { LabelProps } from 'recharts';
2
3
  import { CSS } from '../../config/stitches.config';
3
4
  import './styles.css';
4
5
  interface PieChartData {
@@ -15,6 +16,13 @@ interface PieChartTooltip {
15
16
  label?: (number: any) => string;
16
17
  render?: () => JSX.Element;
17
18
  }
19
+ interface PieChartLabel {
20
+ show?: boolean;
21
+ dataKey?: string;
22
+ position?: LabelProps['position'];
23
+ formatter?: (string: any) => string;
24
+ render?: (any: any) => JSX.Element;
25
+ }
18
26
  interface PieChartProps {
19
27
  /**
20
28
  * Section title of the chart.
@@ -57,18 +65,20 @@ interface PieChartProps {
57
65
  */
58
66
  tooltip?: PieChartTooltip;
59
67
  /**
60
- * Show datasets percentage.
68
+ * Label config of chart.
61
69
  */
62
- showPercentage?: boolean;
70
+ label?: PieChartLabel;
63
71
  }
64
72
  declare const PieChartComponent: {
65
- ({ data, css, avatarURL, avatarAcronym, validAvatar, legend, isMobile, tooltip, showPercentage, title, subtitle, }: PieChartProps): JSX.Element;
73
+ ({ data, css, avatarURL, avatarAcronym, validAvatar, legend, isMobile, tooltip, title, subtitle, label, }: PieChartProps): JSX.Element;
66
74
  defaultProps: {
67
75
  data: never[];
68
76
  avatarURL: undefined;
69
77
  avatarAcronym: string;
70
78
  validAvatar: boolean;
71
79
  legend: {
80
+ show: boolean;
81
+ showTotal: boolean;
72
82
  data: never[];
73
83
  position: string;
74
84
  };
package/index.esm.js CHANGED
@@ -16365,44 +16365,29 @@ const MobileCalendarBox = ({
16365
16365
  children: [allowReset ? jsx(Button$4, Object.assign({
16366
16366
  buttonType: "ghost",
16367
16367
  size: "md",
16368
- css: {
16369
- width: '160px',
16370
- fontWeight: 600,
16371
- display: 'flex',
16372
- flex: 1
16373
- },
16374
16368
  onClick: onReset,
16375
16369
  disabled: disabled || !selected || selected.length <= 1,
16376
- type: "button"
16370
+ type: "button",
16371
+ block: true
16377
16372
  }, {
16378
16373
  children: "Reset"
16379
16374
  }), void 0) : jsx(Button$4, Object.assign({
16380
16375
  buttonType: "ghost",
16381
16376
  size: "md",
16382
- css: {
16383
- width: '160px',
16384
- fontWeight: 600,
16385
- display: 'flex',
16386
- flex: 1
16387
- },
16388
16377
  onClick: onCancel,
16389
16378
  disabled: disabled,
16390
- type: "button"
16379
+ type: "button",
16380
+ block: true
16391
16381
  }, {
16392
16382
  children: t('label.cancel', 'Batal', {
16393
16383
  ns: 'translation'
16394
16384
  })
16395
16385
  }), void 0), jsx(Button$4, Object.assign({
16396
16386
  size: "md",
16397
- css: {
16398
- width: '160px',
16399
- fontWeight: 600,
16400
- display: 'flex',
16401
- flex: 1
16402
- },
16403
16387
  onClick: onUpdate,
16404
16388
  disabled: disabled || !selected || selected.length <= 1,
16405
- type: "button"
16389
+ type: "button",
16390
+ block: true
16406
16391
  }, {
16407
16392
  children: t('label.process', 'Proses', {
16408
16393
  ns: 'translation'
@@ -47730,6 +47715,7 @@ function LoadingBar(props) {
47730
47715
  setProgress(0);
47731
47716
  }, 1000);
47732
47717
  }
47718
+ return () => setProgress(0);
47733
47719
  }, [show, intervalTime]);
47734
47720
  useEffect(() => {
47735
47721
  if (progress === 100) {
@@ -50388,16 +50374,14 @@ function BarChartComponent({
50388
50374
  };
50389
50375
  return jsxs(Box, {
50390
50376
  children: [title && jsx(Heading, Object.assign({
50391
- css: {
50392
- marginBottom: '$spacing-07'
50393
- },
50394
50377
  heading: "sectionTitle"
50395
50378
  }, {
50396
50379
  children: title
50397
50380
  }), void 0), jsx(Box, Object.assign({
50398
50381
  css: Object.assign({
50399
50382
  width: MIN_WIDTH,
50400
- height: MIN_HEIGHT
50383
+ height: MIN_HEIGHT,
50384
+ marginTop: '$spacing-07'
50401
50385
  }, css)
50402
50386
  }, {
50403
50387
  children: jsx(ResponsiveContainer, {
@@ -50486,8 +50470,8 @@ const renderActiveShape = (props, avatar, acronym, validAvatar, activeRef) => {
50486
50470
  endAngle,
50487
50471
  fill
50488
50472
  } = props;
50489
- const IMG_WIDHT = 40;
50490
- const IMG_HEIGHT = 40;
50473
+ const IMG_WIDHT = 75;
50474
+ const IMG_HEIGHT = 75;
50491
50475
  return jsx(React__default.Fragment, {
50492
50476
  children: jsxs("g", {
50493
50477
  children: [jsx("clipPath", Object.assign({
@@ -50526,7 +50510,7 @@ const renderActiveShape = (props, avatar, acronym, validAvatar, activeRef) => {
50526
50510
  cx: cx,
50527
50511
  cy: cy,
50528
50512
  innerRadius: innerRadius,
50529
- outerRadius: activeRef.current ? outerRadius + 10 : outerRadius,
50513
+ outerRadius: activeRef.current ? outerRadius + 12 : outerRadius,
50530
50514
  startAngle: startAngle,
50531
50515
  endAngle: endAngle,
50532
50516
  fill: fill,
@@ -50540,7 +50524,7 @@ const renderActiveShape = (props, avatar, acronym, validAvatar, activeRef) => {
50540
50524
  const renderLegend = (formattedData, legend, subtitle) => jsxs(Box, {
50541
50525
  children: [subtitle && jsx(Flex$1, Object.assign({
50542
50526
  css: {
50543
- margin: '$spacing-06'
50527
+ marginTop: '$spacing-06'
50544
50528
  },
50545
50529
  justify: "center"
50546
50530
  }, {
@@ -50550,6 +50534,9 @@ const renderLegend = (formattedData, legend, subtitle) => jsxs(Box, {
50550
50534
  children: subtitle
50551
50535
  }), void 0)
50552
50536
  }), void 0), formattedData.length > 0 && jsx(Flex$1, Object.assign({
50537
+ css: {
50538
+ marginTop: '$spacing-06'
50539
+ },
50553
50540
  direction: "column",
50554
50541
  gap: 5
50555
50542
  }, {
@@ -50607,9 +50594,9 @@ const PieChartComponent = ({
50607
50594
  legend,
50608
50595
  isMobile,
50609
50596
  tooltip,
50610
- showPercentage,
50611
50597
  title,
50612
- subtitle
50598
+ subtitle,
50599
+ label
50613
50600
  }) => {
50614
50601
  var _a;
50615
50602
  const emptyData = [{
@@ -50624,7 +50611,7 @@ const PieChartComponent = ({
50624
50611
  const activeRef = useRef();
50625
50612
  const formattedData = data.length > 0 ? dataChart : emptyData;
50626
50613
  const [activeIndex, setActiveIndex] = useState(0);
50627
- const CONTAINER_HEIGHT = (legend === null || legend === void 0 ? void 0 : legend.position) === 'bottom' ? 350 : 180;
50614
+ const CONTAINER_HEIGHT = (legend === null || legend === void 0 ? void 0 : legend.position) === 'bottom' ? subtitle ? 420 : 380 : 230;
50628
50615
  const CONTAINER_WIDTH = isMobile ? 350 : 450;
50629
50616
  const CHART_HEIGHT = 150;
50630
50617
  const CHART_WIDTH = 450;
@@ -50668,34 +50655,8 @@ const PieChartComponent = ({
50668
50655
  }
50669
50656
  return null;
50670
50657
  };
50671
- const RADIAN = Math.PI / 180;
50672
- const renderCustomizedLabel = ({
50673
- cx,
50674
- cy,
50675
- midAngle,
50676
- innerRadius,
50677
- outerRadius,
50678
- percent,
50679
- index
50680
- }) => {
50681
- const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
50682
- const x = cx + radius * Math.cos(-midAngle * RADIAN);
50683
- const y = cy + radius * Math.sin(-midAngle * RADIAN);
50684
- return jsx("text", Object.assign({
50685
- x: x,
50686
- y: y,
50687
- fill: "white",
50688
- textAnchor: x > cx ? 'start' : 'end',
50689
- dominantBaseline: "central"
50690
- }, {
50691
- children: `${(percent * 100).toFixed(0)}%`
50692
- }), void 0);
50693
- };
50694
50658
  return jsxs(Box, {
50695
50659
  children: [title && jsx(Heading, Object.assign({
50696
- css: {
50697
- marginBottom: '$spacing-06'
50698
- },
50699
50660
  heading: "sectionTitle"
50700
50661
  }, {
50701
50662
  children: title
@@ -50703,7 +50664,8 @@ const PieChartComponent = ({
50703
50664
  css: Object.assign({
50704
50665
  position: 'relative',
50705
50666
  width: CONTAINER_WIDTH,
50706
- height: CONTAINER_HEIGHT
50667
+ height: CONTAINER_HEIGHT,
50668
+ marginTop: '$spacing-07'
50707
50669
  }, css)
50708
50670
  }, {
50709
50671
  children: jsx(ResponsiveContainer, Object.assign({
@@ -50714,27 +50676,36 @@ const PieChartComponent = ({
50714
50676
  width: CHART_WIDTH,
50715
50677
  height: CHART_HEIGHT
50716
50678
  }, {
50717
- children: [jsx(Pie, Object.assign({
50679
+ children: [jsxs(Pie, Object.assign({
50718
50680
  activeIndex: activeIndex,
50719
50681
  activeShape: shape => renderActiveShape(shape, avatarURL, avatarAcronym, validAvatar, activeRef),
50720
50682
  data: formattedData,
50721
50683
  cx: "50%",
50722
50684
  cy: "50%",
50723
- innerRadius: 50,
50724
- outerRadius: 80,
50685
+ innerRadius: 70,
50686
+ outerRadius: 100,
50725
50687
  dataKey: "total",
50726
50688
  onMouseEnter: x => {
50727
50689
  setActiveIndex(formattedData.findIndex(y => y.name === x.name));
50728
50690
  activeRef.current = true;
50729
50691
  },
50730
50692
  blendStroke: true
50731
- }, showPercentage && {
50732
- label: renderCustomizedLabel,
50693
+ }, (label === null || label === void 0 ? void 0 : label.show) && (label === null || label === void 0 ? void 0 : label.render) && {
50694
+ label: e => {
50695
+ var _a;
50696
+ return (_a = label === null || label === void 0 ? void 0 : label.render) === null || _a === void 0 ? void 0 : _a.call(label, e);
50697
+ },
50733
50698
  labelLine: false
50734
50699
  }, {
50735
- children: formattedData.map(item => jsx(Cell, {
50700
+ children: [formattedData.map(item => jsx(Cell, {
50736
50701
  fill: item.color || colors.chartGreen
50737
- }, item.name))
50702
+ }, item.name)), (label === null || label === void 0 ? void 0 : label.show) && !label.render && jsx(LabelList, {
50703
+ stroke: "0",
50704
+ fill: colors.textWhite,
50705
+ dataKey: (label === null || label === void 0 ? void 0 : label.dataKey) || 'total',
50706
+ formatter: label === null || label === void 0 ? void 0 : label.formatter,
50707
+ position: label === null || label === void 0 ? void 0 : label.position
50708
+ }, void 0)]
50738
50709
  }), void 0), data.length > 0 && jsx(Tooltip$2, {
50739
50710
  wrapperStyle: {
50740
50711
  outline: 'none'
@@ -50759,6 +50730,8 @@ PieChartComponent.defaultProps = {
50759
50730
  avatarAcronym: '',
50760
50731
  validAvatar: false,
50761
50732
  legend: {
50733
+ show: true,
50734
+ showTotal: true,
50762
50735
  data: [],
50763
50736
  position: 'right'
50764
50737
  },
package/index.umd.js CHANGED
@@ -16612,44 +16612,29 @@
16612
16612
  children: [allowReset ? jsxRuntime.jsx(Button$4, __assign({
16613
16613
  buttonType: "ghost",
16614
16614
  size: "md",
16615
- css: {
16616
- width: '160px',
16617
- fontWeight: 600,
16618
- display: 'flex',
16619
- flex: 1
16620
- },
16621
16615
  onClick: onReset,
16622
16616
  disabled: disabled || !selected || selected.length <= 1,
16623
- type: "button"
16617
+ type: "button",
16618
+ block: true
16624
16619
  }, {
16625
16620
  children: "Reset"
16626
16621
  }), void 0) : jsxRuntime.jsx(Button$4, __assign({
16627
16622
  buttonType: "ghost",
16628
16623
  size: "md",
16629
- css: {
16630
- width: '160px',
16631
- fontWeight: 600,
16632
- display: 'flex',
16633
- flex: 1
16634
- },
16635
16624
  onClick: onCancel,
16636
16625
  disabled: disabled,
16637
- type: "button"
16626
+ type: "button",
16627
+ block: true
16638
16628
  }, {
16639
16629
  children: t('label.cancel', 'Batal', {
16640
16630
  ns: 'translation'
16641
16631
  })
16642
16632
  }), void 0), jsxRuntime.jsx(Button$4, __assign({
16643
16633
  size: "md",
16644
- css: {
16645
- width: '160px',
16646
- fontWeight: 600,
16647
- display: 'flex',
16648
- flex: 1
16649
- },
16650
16634
  onClick: onUpdate,
16651
16635
  disabled: disabled || !selected || selected.length <= 1,
16652
- type: "button"
16636
+ type: "button",
16637
+ block: true
16653
16638
  }, {
16654
16639
  children: t('label.process', 'Proses', {
16655
16640
  ns: 'translation'
@@ -48150,6 +48135,9 @@
48150
48135
  setProgress(0);
48151
48136
  }, 1000);
48152
48137
  }
48138
+ return function () {
48139
+ return setProgress(0);
48140
+ };
48153
48141
  }, [show, intervalTime]);
48154
48142
  React.useEffect(function () {
48155
48143
  if (progress === 100) {
@@ -50909,16 +50897,14 @@
50909
50897
  };
50910
50898
  return jsxRuntime.jsxs(Box, {
50911
50899
  children: [title && jsxRuntime.jsx(Heading, __assign({
50912
- css: {
50913
- marginBottom: '$spacing-07'
50914
- },
50915
50900
  heading: "sectionTitle"
50916
50901
  }, {
50917
50902
  children: title
50918
50903
  }), void 0), jsxRuntime.jsx(Box, __assign({
50919
50904
  css: __assign({
50920
50905
  width: MIN_WIDTH,
50921
- height: MIN_HEIGHT
50906
+ height: MIN_HEIGHT,
50907
+ marginTop: '$spacing-07'
50922
50908
  }, css)
50923
50909
  }, {
50924
50910
  children: jsxRuntime.jsx(recharts.ResponsiveContainer, {
@@ -51005,8 +50991,8 @@
51005
50991
  startAngle = props.startAngle,
51006
50992
  endAngle = props.endAngle,
51007
50993
  fill = props.fill;
51008
- var IMG_WIDHT = 40;
51009
- var IMG_HEIGHT = 40;
50994
+ var IMG_WIDHT = 75;
50995
+ var IMG_HEIGHT = 75;
51010
50996
  return jsxRuntime.jsx(React__default["default"].Fragment, {
51011
50997
  children: jsxRuntime.jsxs("g", {
51012
50998
  children: [jsxRuntime.jsx("clipPath", __assign({
@@ -51045,7 +51031,7 @@
51045
51031
  cx: cx,
51046
51032
  cy: cy,
51047
51033
  innerRadius: innerRadius,
51048
- outerRadius: activeRef.current ? outerRadius + 10 : outerRadius,
51034
+ outerRadius: activeRef.current ? outerRadius + 12 : outerRadius,
51049
51035
  startAngle: startAngle,
51050
51036
  endAngle: endAngle,
51051
51037
  fill: fill,
@@ -51060,7 +51046,7 @@
51060
51046
  return jsxRuntime.jsxs(Box, {
51061
51047
  children: [subtitle && jsxRuntime.jsx(Flex$1, __assign({
51062
51048
  css: {
51063
- margin: '$spacing-06'
51049
+ marginTop: '$spacing-06'
51064
51050
  },
51065
51051
  justify: "center"
51066
51052
  }, {
@@ -51070,6 +51056,9 @@
51070
51056
  children: subtitle
51071
51057
  }), void 0)
51072
51058
  }), void 0), formattedData.length > 0 && jsxRuntime.jsx(Flex$1, __assign({
51059
+ css: {
51060
+ marginTop: '$spacing-06'
51061
+ },
51073
51062
  direction: "column",
51074
51063
  gap: 5
51075
51064
  }, {
@@ -51129,9 +51118,9 @@
51129
51118
  legend = _a.legend,
51130
51119
  isMobile = _a.isMobile,
51131
51120
  tooltip = _a.tooltip,
51132
- showPercentage = _a.showPercentage,
51133
51121
  title = _a.title,
51134
- subtitle = _a.subtitle;
51122
+ subtitle = _a.subtitle,
51123
+ label = _a.label;
51135
51124
  var emptyData = [{
51136
51125
  id: '0',
51137
51126
  name: '',
@@ -51148,7 +51137,7 @@
51148
51137
  var _c = React.useState(0),
51149
51138
  activeIndex = _c[0],
51150
51139
  setActiveIndex = _c[1];
51151
- var CONTAINER_HEIGHT = (legend === null || legend === void 0 ? void 0 : legend.position) === 'bottom' ? 350 : 180;
51140
+ var CONTAINER_HEIGHT = (legend === null || legend === void 0 ? void 0 : legend.position) === 'bottom' ? subtitle ? 420 : 380 : 230;
51152
51141
  var CONTAINER_WIDTH = isMobile ? 350 : 450;
51153
51142
  var CHART_HEIGHT = 150;
51154
51143
  var CHART_WIDTH = 450;
@@ -51192,33 +51181,8 @@
51192
51181
  }
51193
51182
  return null;
51194
51183
  };
51195
- var RADIAN = Math.PI / 180;
51196
- var renderCustomizedLabel = function renderCustomizedLabel(_a) {
51197
- var cx = _a.cx,
51198
- cy = _a.cy,
51199
- midAngle = _a.midAngle,
51200
- innerRadius = _a.innerRadius,
51201
- outerRadius = _a.outerRadius,
51202
- percent = _a.percent;
51203
- _a.index;
51204
- var radius = innerRadius + (outerRadius - innerRadius) * 0.5;
51205
- var x = cx + radius * Math.cos(-midAngle * RADIAN);
51206
- var y = cy + radius * Math.sin(-midAngle * RADIAN);
51207
- return jsxRuntime.jsx("text", __assign({
51208
- x: x,
51209
- y: y,
51210
- fill: "white",
51211
- textAnchor: x > cx ? 'start' : 'end',
51212
- dominantBaseline: "central"
51213
- }, {
51214
- children: "".concat((percent * 100).toFixed(0), "%")
51215
- }), void 0);
51216
- };
51217
51184
  return jsxRuntime.jsxs(Box, {
51218
51185
  children: [title && jsxRuntime.jsx(Heading, __assign({
51219
- css: {
51220
- marginBottom: '$spacing-06'
51221
- },
51222
51186
  heading: "sectionTitle"
51223
51187
  }, {
51224
51188
  children: title
@@ -51226,7 +51190,8 @@
51226
51190
  css: __assign({
51227
51191
  position: 'relative',
51228
51192
  width: CONTAINER_WIDTH,
51229
- height: CONTAINER_HEIGHT
51193
+ height: CONTAINER_HEIGHT,
51194
+ marginTop: '$spacing-07'
51230
51195
  }, css)
51231
51196
  }, {
51232
51197
  children: jsxRuntime.jsx(recharts.ResponsiveContainer, __assign({
@@ -51237,7 +51202,7 @@
51237
51202
  width: CHART_WIDTH,
51238
51203
  height: CHART_HEIGHT
51239
51204
  }, {
51240
- children: [jsxRuntime.jsx(recharts.Pie, __assign({
51205
+ children: [jsxRuntime.jsxs(recharts.Pie, __assign({
51241
51206
  activeIndex: activeIndex,
51242
51207
  activeShape: function (shape) {
51243
51208
  return renderActiveShape(shape, avatarURL, avatarAcronym, validAvatar, activeRef);
@@ -51245,8 +51210,8 @@
51245
51210
  data: formattedData,
51246
51211
  cx: "50%",
51247
51212
  cy: "50%",
51248
- innerRadius: 50,
51249
- outerRadius: 80,
51213
+ innerRadius: 70,
51214
+ outerRadius: 100,
51250
51215
  dataKey: "total",
51251
51216
  onMouseEnter: function (x) {
51252
51217
  setActiveIndex(formattedData.findIndex(function (y) {
@@ -51255,15 +51220,24 @@
51255
51220
  activeRef.current = true;
51256
51221
  },
51257
51222
  blendStroke: true
51258
- }, showPercentage && {
51259
- label: renderCustomizedLabel,
51223
+ }, (label === null || label === void 0 ? void 0 : label.show) && (label === null || label === void 0 ? void 0 : label.render) && {
51224
+ label: function (e) {
51225
+ var _a;
51226
+ return (_a = label === null || label === void 0 ? void 0 : label.render) === null || _a === void 0 ? void 0 : _a.call(label, e);
51227
+ },
51260
51228
  labelLine: false
51261
51229
  }, {
51262
- children: formattedData.map(function (item) {
51230
+ children: [formattedData.map(function (item) {
51263
51231
  return jsxRuntime.jsx(recharts.Cell, {
51264
51232
  fill: item.color || colors.chartGreen
51265
51233
  }, item.name);
51266
- })
51234
+ }), (label === null || label === void 0 ? void 0 : label.show) && !label.render && jsxRuntime.jsx(recharts.LabelList, {
51235
+ stroke: "0",
51236
+ fill: colors.textWhite,
51237
+ dataKey: (label === null || label === void 0 ? void 0 : label.dataKey) || 'total',
51238
+ formatter: label === null || label === void 0 ? void 0 : label.formatter,
51239
+ position: label === null || label === void 0 ? void 0 : label.position
51240
+ }, void 0)]
51267
51241
  }), void 0), data.length > 0 && jsxRuntime.jsx(recharts.Tooltip, {
51268
51242
  wrapperStyle: {
51269
51243
  outline: 'none'
@@ -51288,6 +51262,8 @@
51288
51262
  avatarAcronym: '',
51289
51263
  validAvatar: false,
51290
51264
  legend: {
51265
+ show: true,
51266
+ showTotal: true,
51291
51267
  data: [],
51292
51268
  position: 'right'
51293
51269
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@majoo-ui/react",
3
- "version": "1.57.3",
3
+ "version": "1.57.4",
4
4
  "dependencies": {
5
5
  "@majoo-ui/core": "^1.31.3",
6
6
  "@majoo-ui/helpers": "^1.30.5",