@appquality/unguess-design-system 2.12.43 → 2.12.45

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,33 @@
1
+ # v2.12.45 (Mon Dec 05 2022)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Change sunburst and pie cornerradius, expose skiparclabel and rerender bullet on resize [#140](https://github.com/AppQuality/unguess-design-system/pull/140) ([@d-beezee](https://github.com/d-beezee) [@marcbon](https://github.com/marcbon) [@iacopolea](https://github.com/iacopolea))
6
+ - feat: Rerender bullet on resize to prevent invalid positioning [#139](https://github.com/AppQuality/unguess-design-system/pull/139) ([@d-beezee](https://github.com/d-beezee))
7
+ - feat: Change pie and sunburst corner radius [#137](https://github.com/AppQuality/unguess-design-system/pull/137) ([@d-beezee](https://github.com/d-beezee))
8
+ - feat(pie): add arcLinkLabelsSkipAngle props [#138](https://github.com/AppQuality/unguess-design-system/pull/138) ([@marcbon](https://github.com/marcbon))
9
+
10
+ #### Authors: 3
11
+
12
+ - [@d-beezee](https://github.com/d-beezee)
13
+ - Iacopo Leardini ([@iacopolea](https://github.com/iacopolea))
14
+ - Marco Bonomo ([@marcbon](https://github.com/marcbon))
15
+
16
+ ---
17
+
18
+ # v2.12.44 (Fri Dec 02 2022)
19
+
20
+ #### 🐛 Bug Fix
21
+
22
+ - Update sunburst [#136](https://github.com/AppQuality/unguess-design-system/pull/136) ([@d-beezee](https://github.com/d-beezee))
23
+ - feat(sunburst): Allow passing custom data to tooltip [#135](https://github.com/AppQuality/unguess-design-system/pull/135) ([@d-beezee](https://github.com/d-beezee))
24
+
25
+ #### Authors: 1
26
+
27
+ - [@d-beezee](https://github.com/d-beezee)
28
+
29
+ ---
30
+
1
31
  # v2.12.43 (Fri Dec 02 2022)
2
32
 
3
33
  #### 🐛 Bug Fix
package/build/index.js CHANGED
@@ -1162,20 +1162,33 @@ 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
+ };
1165
1177
  var BulletChart = function (_a) {
1166
1178
  var width = _a.width, height = _a.height, ranges = _a.ranges, values = _a.values;
1167
- return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(UgBulletChart, { theme: DEFAULT_CHARTS_THEME, data: [
1168
- {
1169
- id: "",
1170
- title: "",
1171
- ranges: ranges,
1172
- measures: values,
1173
- markers: values,
1174
- },
1175
- ], animate: false, measureComponent: CustomMeasure, markerColors: CHARTS_COLOR_PALETTE.darkPine, markerComponent: function (_a) {
1176
- _a.size; var markerProps = __rest(_a, ["size"]);
1177
- return (jsxRuntime.jsx(CustomBulletChartMarkers, __assign({}, markerProps, { size: 4 })));
1178
- }, tooltip: CustomTooltip, rangeColors: CHARTS_COLOR_PALETTE.lightGrey, rangeBorderColor: "white", rangeBorderWidth: 2, margin: { top: 0, right: 5, bottom: -1, left: 0 } }) })));
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: [
1181
+ {
1182
+ id: "",
1183
+ title: "",
1184
+ ranges: ranges,
1185
+ measures: values,
1186
+ markers: values,
1187
+ },
1188
+ ], animate: false, measureComponent: CustomMeasure, markerColors: CHARTS_COLOR_PALETTE.darkPine, markerComponent: function (_a) {
1189
+ _a.size; var markerProps = __rest(_a, ["size"]);
1190
+ return (jsxRuntime.jsx(CustomBulletChartMarkers, __assign({}, markerProps, { size: 4 })));
1191
+ }, tooltip: CustomTooltip, rangeColors: CHARTS_COLOR_PALETTE.lightGrey, rangeBorderColor: "white", rangeBorderWidth: 2, margin: { top: 0, right: 5, bottom: -1, left: 0 } }) })) })));
1179
1192
  };
1180
1193
  var templateObject_1$19;
1181
1194
 
@@ -1248,16 +1261,16 @@ var templateObject_1$18, templateObject_2$t, templateObject_3$i, templateObject_
1248
1261
 
1249
1262
  var PieChart = function (_a) {
1250
1263
  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;
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;
1252
1265
  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" }, padAngle: 2, data: data, margin: __assign({ top: 40, bottom: 40 }, margin), tooltip: tooltip
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
1254
1267
  ? function (node) {
1255
1268
  var data = node.datum.data;
1256
1269
  var label = (data === null || data === void 0 ? void 0 : data.label) || data.id;
1257
1270
  var value = data.value;
1258
1271
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: tooltip({ label: label, value: value, data: data }) });
1259
1272
  }
1260
- : undefined, cornerRadius: 3, innerRadius: 0.8, arcLinkLabelsThickness: 2, layers: __spreadArray([
1273
+ : undefined, cornerRadius: 2, innerRadius: 0.8, arcLinkLabelsThickness: 2, layers: __spreadArray([
1261
1274
  "arcs",
1262
1275
  "arcLabels",
1263
1276
  "arcLinkLabels"
@@ -1367,9 +1380,11 @@ var SunburstChart = function (_a) {
1367
1380
  var data = _a.data, color = _a.color;
1368
1381
  setCurrentData(data);
1369
1382
  setCurrentColor(color);
1383
+ };
1384
+ React.useEffect(function () {
1370
1385
  if (onChange)
1371
1386
  onChange(currentData);
1372
- };
1387
+ }, [currentData]);
1373
1388
  if (!data.children)
1374
1389
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "No data" });
1375
1390
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height, style: isHovering ? { cursor: "pointer" } : undefined }, { children: jsxRuntime.jsx(sunburst.ResponsiveSunburst, { theme: tooltip
@@ -1377,7 +1392,7 @@ var SunburstChart = function (_a) {
1377
1392
  padding: 0,
1378
1393
  } }) }) : DEFAULT_CHARTS_THEME, colors: currentColor
1379
1394
  ? function () { return currentColor; }
1380
- : colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_8_A, borderWidth: 4, cornerRadius: 3, onMouseEnter: function (node) {
1395
+ : colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_8_A, borderWidth: 4, cornerRadius: 4, onMouseEnter: function (node) {
1381
1396
  if (node.data.children) {
1382
1397
  setIsHovering(true);
1383
1398
  }
@@ -1389,6 +1404,7 @@ var SunburstChart = function (_a) {
1389
1404
  ? function (node) { return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: tooltip({
1390
1405
  label: node.data.label || node.data.name,
1391
1406
  value: getChildrenValue(node.data),
1407
+ data: __assign(__assign({}, node.data), { children: undefined }),
1392
1408
  }) })); }
1393
1409
  : undefined, layers: __spreadArray(__spreadArray([
1394
1410
  "arcs"
@@ -1412,7 +1428,7 @@ var SunburstChart = function (_a) {
1412
1428
  color: clickedData.color,
1413
1429
  });
1414
1430
  }
1415
- } }) })), 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.children.map(function (d) { return d.name; }), columns: typeof legend === "object" && legend.columns
1431
+ } }) })), 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.children.map(function (d) { return d.label || d.name; }), columns: typeof legend === "object" && legend.columns
1416
1432
  ? legend.columns
1417
1433
  : undefined, width: typeof legend === "object" && legend.width
1418
1434
  ? legend.width
@@ -22,5 +22,6 @@ export interface PieChartProps {
22
22
  };
23
23
  tooltip?: ChartTooltipFunction;
24
24
  legend?: LegendType | true;
25
+ arcLinkLabelsSkipAngle?: number;
25
26
  }
26
27
  export {};
@@ -1,3 +1,3 @@
1
1
  import { PieChartProps } from "./_types";
2
- declare const PieChart: ({ theme, colors, width, height, data, centerItem, margin, tooltip, legend, }: PieChartProps) => JSX.Element;
2
+ declare const PieChart: ({ theme, colors, width, height, data, centerItem, margin, tooltip, legend, arcLinkLabelsSkipAngle, }: PieChartProps) => JSX.Element;
3
3
  export { PieChart };
@@ -2,5 +2,5 @@ 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, }: PieChartProps) => JSX.Element>;
5
+ declare const _default: ComponentMeta<({ theme, colors, width, height, data, centerItem, margin, tooltip, legend, arcLinkLabelsSkipAngle, }: PieChartProps) => JSX.Element>;
6
6
  export default _default;
@@ -6,6 +6,7 @@ export interface SunburstData {
6
6
  label?: string;
7
7
  children?: SunburstData[];
8
8
  value?: number;
9
+ [key: string]: SunburstData[keyof SunburstData] | string | number | boolean;
9
10
  }
10
11
  export interface SunburstChartProps {
11
12
  data: SunburstData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "2.12.43",
3
+ "version": "2.12.45",
4
4
  "dependencies": {
5
5
  "@nivo/bar": "^0.80.0",
6
6
  "@nivo/bullet": "^0.80.0",