@appquality/unguess-design-system 2.12.45 → 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,31 @@
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
+
15
+ # v2.12.46 (Tue Dec 06 2022)
16
+
17
+ #### 🐛 Bug Fix
18
+
19
+ - Revert bullet fix [#142](https://github.com/AppQuality/unguess-design-system/pull/142) ([@d-beezee](https://github.com/d-beezee) [@cannarocks](https://github.com/cannarocks))
20
+ - revert: Remove resize from bullet chart [#141](https://github.com/AppQuality/unguess-design-system/pull/141) ([@d-beezee](https://github.com/d-beezee))
21
+
22
+ #### Authors: 2
23
+
24
+ - [@d-beezee](https://github.com/d-beezee)
25
+ - Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
26
+
27
+ ---
28
+
1
29
  # v2.12.45 (Mon Dec 05 2022)
2
30
 
3
31
  #### 🐛 Bug Fix
package/build/index.js CHANGED
@@ -1162,22 +1162,9 @@ var CustomTooltip = function (_a) {
1162
1162
  };
1163
1163
 
1164
1164
  var UgBulletChart = styled__default["default"](bullet.ResponsiveBullet)(templateObject_1$19 || (templateObject_1$19 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n"], ["\n width: 100%;\n height: 100%;\n"])));
1165
- var useResizeOfReference = function () {
1166
- var ref = React.createRef();
1167
- var _a = React.useState({ width: 0 }), setDimensions = _a[1];
1168
- React.useEffect(function () {
1169
- if (ref.current) {
1170
- setDimensions({
1171
- width: ref.current.clientWidth,
1172
- });
1173
- }
1174
- }, [ref]);
1175
- return { ref: ref };
1176
- };
1177
1165
  var BulletChart = function (_a) {
1178
1166
  var width = _a.width, height = _a.height, ranges = _a.ranges, values = _a.values;
1179
- var ref = useResizeOfReference().ref;
1180
- return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx("div", __assign({ style: { width: "100%", height: height }, ref: ref }, { children: jsxRuntime.jsx(UgBulletChart, { theme: DEFAULT_CHARTS_THEME, data: [
1167
+ return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx("div", __assign({ style: { width: "100%", height: height } }, { children: jsxRuntime.jsx(UgBulletChart, { theme: DEFAULT_CHARTS_THEME, data: [
1181
1168
  {
1182
1169
  id: "",
1183
1170
  title: "",
@@ -1261,9 +1248,19 @@ var templateObject_1$18, templateObject_2$t, templateObject_3$i, templateObject_
1261
1248
 
1262
1249
  var PieChart = function (_a) {
1263
1250
  var _b;
1264
- 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;
1265
1252
  var themeContext = React.useContext(styled.ThemeContext);
1266
- 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
1267
1264
  ? function (node) {
1268
1265
  var data = node.datum.data;
1269
1266
  var label = (data === null || data === void 0 ? void 0 : data.label) || data.id;
@@ -1278,7 +1275,17 @@ var PieChart = function (_a) {
1278
1275
  ? [
1279
1276
  function (props) { return (jsxRuntime.jsx(CenteredItem, __assign({}, props, { theme: themeContext, label: centerItem.label, value: centerItem.value, fontSizeMultiplier: centerItem.fontSizeMultiplier }))); },
1280
1277
  ]
1281
- : []), 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
1282
1289
  ? legend.columns
1283
1290
  : undefined, width: typeof legend === "object" && legend.width
1284
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.45",
3
+ "version": "2.12.47",
4
4
  "dependencies": {
5
5
  "@nivo/bar": "^0.80.0",
6
6
  "@nivo/bullet": "^0.80.0",