@appquality/unguess-design-system 2.12.46 → 2.12.47

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # v2.12.47 (Wed Dec 07 2022)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Allow custom label on pie [#144](https://github.com/AppQuality/unguess-design-system/pull/144) ([@d-beezee](https://github.com/d-beezee) [@cannarocks](https://github.com/cannarocks))
6
+ - feat: Allow custom label for arclink and legend [#143](https://github.com/AppQuality/unguess-design-system/pull/143) ([@d-beezee](https://github.com/d-beezee))
7
+
8
+ #### Authors: 2
9
+
10
+ - [@d-beezee](https://github.com/d-beezee)
11
+ - Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
12
+
13
+ ---
14
+
1
15
  # v2.12.46 (Tue Dec 06 2022)
2
16
 
3
17
  #### 🐛 Bug Fix
package/build/index.js CHANGED
@@ -1248,9 +1248,19 @@ var templateObject_1$18, templateObject_2$t, templateObject_3$i, templateObject_
1248
1248
 
1249
1249
  var PieChart = function (_a) {
1250
1250
  var _b;
1251
- var theme = _a.theme, colors = _a.colors, width = _a.width, height = _a.height, data = _a.data, centerItem = _a.centerItem, margin = _a.margin, tooltip = _a.tooltip, legend = _a.legend, arcLinkLabelsSkipAngle = _a.arcLinkLabelsSkipAngle;
1251
+ var theme = _a.theme, colors = _a.colors, width = _a.width, height = _a.height, data = _a.data, centerItem = _a.centerItem, margin = _a.margin, tooltip = _a.tooltip, legend = _a.legend, arcLinkLabelsSkipAngle = _a.arcLinkLabelsSkipAngle, labelFormatter = _a.labelFormatter;
1252
1252
  var themeContext = React.useContext(styled.ThemeContext);
1253
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(pie.ResponsivePie, { theme: __assign({}, __assign(__assign(__assign({}, DEFAULT_CHARTS_THEME), theme), { labels: __assign(__assign({}, theme === null || theme === void 0 ? void 0 : theme.labels), { text: __assign({ fontWeight: themeContext.fontWeights.semibold, fill: themeContext.palette.grey[800] }, (_b = theme === null || theme === void 0 ? void 0 : theme.labels) === null || _b === void 0 ? void 0 : _b.text) }) })), arcLinkLabel: function (d) { return (d.label || d.id).toString(); }, colors: colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_8_A, enableArcLabels: false, arcLinkLabelsColor: { from: "color" }, arcLinkLabelsSkipAngle: arcLinkLabelsSkipAngle !== null && arcLinkLabelsSkipAngle !== void 0 ? arcLinkLabelsSkipAngle : 10, padAngle: 2, data: data, margin: __assign({ top: 40, bottom: 40 }, margin), tooltip: tooltip
1253
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(pie.ResponsivePie, { theme: __assign({}, __assign(__assign(__assign({}, DEFAULT_CHARTS_THEME), theme), { labels: __assign(__assign({}, theme === null || theme === void 0 ? void 0 : theme.labels), { text: __assign({ fontWeight: themeContext.fontWeights.semibold, fill: themeContext.palette.grey[800] }, (_b = theme === null || theme === void 0 ? void 0 : theme.labels) === null || _b === void 0 ? void 0 : _b.text) }) })), arcLinkLabel: function (d) {
1254
+ return labelFormatter
1255
+ ? labelFormatter({
1256
+ label: d.label,
1257
+ id: d.id,
1258
+ value: d.value,
1259
+ data: d.data,
1260
+ labelPosition: "arclink",
1261
+ })
1262
+ : (d.label || d.id).toString();
1263
+ }, colors: colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_8_A, enableArcLabels: false, arcLinkLabelsColor: { from: "color" }, arcLinkLabelsSkipAngle: arcLinkLabelsSkipAngle !== null && arcLinkLabelsSkipAngle !== void 0 ? arcLinkLabelsSkipAngle : 10, padAngle: 2, data: data, margin: __assign({ top: 40, bottom: 40 }, margin), tooltip: tooltip
1254
1264
  ? function (node) {
1255
1265
  var data = node.datum.data;
1256
1266
  var label = (data === null || data === void 0 ? void 0 : data.label) || data.id;
@@ -1265,7 +1275,17 @@ var PieChart = function (_a) {
1265
1275
  ? [
1266
1276
  function (props) { return (jsxRuntime.jsx(CenteredItem, __assign({}, props, { theme: themeContext, label: centerItem.label, value: centerItem.value, fontSizeMultiplier: centerItem.fontSizeMultiplier }))); },
1267
1277
  ]
1268
- : []), true), activeOuterRadiusOffset: 12 }) })), jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: "auto" }, { children: legend ? (jsxRuntime.jsx(Legend, { colors: colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_8_A, data: data.map(function (d) { return d.id; }), columns: typeof legend === "object" && legend.columns
1278
+ : []), true), activeOuterRadiusOffset: 12 }) })), jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: "auto" }, { children: legend ? (jsxRuntime.jsx(Legend, { colors: colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_8_A, data: data.map(function (d) {
1279
+ return labelFormatter
1280
+ ? labelFormatter({
1281
+ label: d.label,
1282
+ id: d.id,
1283
+ value: d.value,
1284
+ data: d,
1285
+ labelPosition: "legend",
1286
+ })
1287
+ : d.id.toString();
1288
+ }), columns: typeof legend === "object" && legend.columns
1269
1289
  ? legend.columns
1270
1290
  : undefined, width: typeof legend === "object" && legend.width
1271
1291
  ? legend.width
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  export declare type ChartTooltipFunction = ({ value, label, data, }: {
3
3
  value: number;
4
- label: string;
4
+ label: string | number;
5
5
  data?: Record<string, string | number | undefined>;
6
6
  }) => React.ReactNode;
@@ -1,9 +1,14 @@
1
1
  import { PieSvgProps } from "@nivo/pie";
2
2
  import { ChartTooltipFunction } from "../_types";
3
3
  import { LegendType } from "../Legend";
4
+ declare type BasicPieDatum = {
5
+ id: string | number;
6
+ label?: string | number;
7
+ value: number;
8
+ };
4
9
  declare type PieDatum = {
5
- id: string;
6
- label?: string;
10
+ id: string | number;
11
+ label?: string | number;
7
12
  value: number;
8
13
  } & {
9
14
  [key: string]: string | number | undefined;
@@ -23,5 +28,9 @@ export interface PieChartProps {
23
28
  tooltip?: ChartTooltipFunction;
24
29
  legend?: LegendType | true;
25
30
  arcLinkLabelsSkipAngle?: number;
31
+ labelFormatter?: (data: BasicPieDatum & {
32
+ labelPosition: "arclink" | "legend";
33
+ data?: PieDatum;
34
+ }) => string;
26
35
  }
27
36
  export {};
@@ -1,3 +1,3 @@
1
1
  import { PieChartProps } from "./_types";
2
- declare const PieChart: ({ theme, colors, width, height, data, centerItem, margin, tooltip, legend, arcLinkLabelsSkipAngle, }: PieChartProps) => JSX.Element;
2
+ declare const PieChart: ({ theme, colors, width, height, data, centerItem, margin, tooltip, legend, arcLinkLabelsSkipAngle, labelFormatter, }: PieChartProps) => JSX.Element;
3
3
  export { PieChart };
@@ -2,5 +2,6 @@ import { ComponentMeta, Story } from "@storybook/react";
2
2
  import { PieChartProps } from "./_types";
3
3
  export declare const Default: Story<PieChartProps>;
4
4
  export declare const WithCustomTooltip: Story<PieChartProps>;
5
- declare const _default: ComponentMeta<({ theme, colors, width, height, data, centerItem, margin, tooltip, legend, arcLinkLabelsSkipAngle, }: PieChartProps) => JSX.Element>;
5
+ export declare const WithCustomLabel: Story<PieChartProps>;
6
+ declare const _default: ComponentMeta<({ theme, colors, width, height, data, centerItem, margin, tooltip, legend, arcLinkLabelsSkipAngle, labelFormatter, }: PieChartProps) => JSX.Element>;
6
7
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "2.12.46",
3
+ "version": "2.12.47",
4
4
  "dependencies": {
5
5
  "@nivo/bar": "^0.80.0",
6
6
  "@nivo/bullet": "^0.80.0",