@appquality/unguess-design-system 2.12.30 → 2.12.32

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,28 @@
1
+ # v2.12.32 (Wed Nov 16 2022)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Add custom tooltip to waffle and fix pie padangle [#107](https://github.com/AppQuality/unguess-design-system/pull/107) ([@d-beezee](https://github.com/d-beezee))
6
+
7
+ #### Authors: 1
8
+
9
+ - [@d-beezee](https://github.com/d-beezee)
10
+
11
+ ---
12
+
13
+ # v2.12.31 (Tue Nov 15 2022)
14
+
15
+ #### 🐛 Bug Fix
16
+
17
+ - fix(bullet chart): tooltip & theme [#105](https://github.com/AppQuality/unguess-design-system/pull/105) ([@iacopolea](https://github.com/iacopolea) [@marcbon](https://github.com/marcbon))
18
+
19
+ #### Authors: 2
20
+
21
+ - Iacopo Leardini ([@iacopolea](https://github.com/iacopolea))
22
+ - Marco Bonomo ([@marcbon](https://github.com/marcbon))
23
+
24
+ ---
25
+
1
26
  # v2.12.30 (Tue Nov 15 2022)
2
27
 
3
28
  #### 🐛 Bug Fix
package/build/index.js CHANGED
@@ -18,6 +18,7 @@ var reactLoaders = require('@zendeskgarden/react-loaders');
18
18
  var reactTypography = require('@zendeskgarden/react-typography');
19
19
  var bar = require('@nivo/bar');
20
20
  var bullet = require('@nivo/bullet');
21
+ var web = require('@react-spring/web');
21
22
  var pie = require('@nivo/pie');
22
23
  var stream = require('@nivo/stream');
23
24
  var sunburst = require('@nivo/sunburst');
@@ -1124,34 +1125,39 @@ var BarChart = function (_a) {
1124
1125
  return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(bar.ResponsiveBar, __assign({ theme: __assign(__assign({}, DEFAULT_CHARTS_THEME), theme), colors: colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_5, enableLabel: false }, props)) })));
1125
1126
  };
1126
1127
 
1127
- var CustomBulletChartMarker = function (_a) {
1128
- var x = _a.x, y = _a.y, bulletRadius = _a.bulletRadius, fill = _a.fill, size = _a.size;
1129
- return (jsxRuntime.jsx("circle", { r: bulletRadius, fill: fill, transform: "translate(".concat(x, ",").concat(y, ") scale(").concat(size, ")") }));
1128
+ var CustomBulletChartMarkers = function (_a) {
1129
+ var x = _a.x, y = _a.y, size = _a.size, _b = _a.animatedProps, color = _b.color, transform = _b.transform, data = _a.data, onMouseEnter = _a.onMouseEnter, onMouseMove = _a.onMouseMove, onMouseLeave = _a.onMouseLeave, onClick = _a.onClick;
1130
+ return (jsxRuntime.jsx(web.animated.circle, { transform: transform, cx: x, cy: y, fill: color, stroke: color, r: size,
1131
+ // @ts-ignore onMouseMove event for circle is not supported, but it works
1132
+ onMouseMove: function (event) { return onMouseMove(data, event); },
1133
+ // @ts-ignore onMouseEnter event for circle is not supported, but it works
1134
+ onMouseEnter: function (event) { return onMouseEnter(data, event); },
1135
+ // @ts-ignore onMouseLeave event for circle is not supported, but it works
1136
+ onMouseLeave: function (event) { return onMouseLeave(data, event); },
1137
+ // @ts-ignore onClick event for circle is not supported, but it works
1138
+ onClick: function (event) { return onClick(data, event); } }));
1130
1139
  };
1131
1140
 
1132
- var CustomBulletChartRange = function (_a) {
1133
- var x = _a.x, y = _a.y, width = _a.width, height = _a.height, fill = _a.fill;
1134
- return (jsxRuntime.jsx("rect", { x: x, y: y, width: width - 2, height: height, fill: fill }));
1141
+ var CustomMeasure = function (_a) {
1142
+ var x = _a.x, y = _a.y, width = _a.width, height = _a.height; _a.color;
1143
+ return (jsxRuntime.jsx("rect", { x: x + 2, y: y + 2, width: width - 4, height: height - 4, fill: chartColors.darkGrey }));
1135
1144
  };
1136
1145
 
1137
1146
  var UgBulletChart = styled__default["default"](bullet.ResponsiveBullet)(templateObject_1$15 || (templateObject_1$15 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n"], ["\n width: 100%;\n height: 100%;\n"])));
1138
1147
  var BulletChart = function (_a) {
1139
- var width = _a.width, height = _a.height, ranges = _a.ranges, values = _a.values, markerColor = _a.markerColor, markerSize = _a.markerSize, rangeColor = _a.rangeColor, measureSize = _a.measureSize, measureColor = _a.measureColor, props = __rest(_a, ["width", "height", "ranges", "values", "markerColor", "markerSize", "rangeColor", "measureSize", "measureColor"]);
1140
- var rangesCount = ranges.length;
1141
- return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(UgBulletChart, __assign({ data: [{
1148
+ var width = _a.width, height = _a.height, ranges = _a.ranges, values = _a.values;
1149
+ return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height, id: "ciolla" }, { children: jsxRuntime.jsx(UgBulletChart, { theme: DEFAULT_CHARTS_THEME, data: [
1150
+ {
1142
1151
  id: "",
1143
1152
  title: "",
1144
1153
  ranges: ranges,
1145
1154
  measures: values,
1146
1155
  markers: values,
1147
- }], measureColors: measureColor !== null && measureColor !== void 0 ? measureColor : chartColors.darkGrey, measureSize: measureSize !== null && measureSize !== void 0 ? measureSize : 0.2, markerComponent: function (_a) {
1156
+ },
1157
+ ], measureComponent: CustomMeasure, markerColors: chartColors.darkPine, markerComponent: function (_a) {
1148
1158
  _a.size; var markerProps = __rest(_a, ["size"]);
1149
- return (jsxRuntime.jsx(CustomBulletChartMarker, __assign({ bulletRadius: 4, fill: markerColor !== null && markerColor !== void 0 ? markerColor : chartColors.darkPine, size: markerSize !== null && markerSize !== void 0 ? markerSize : 1 }, markerProps)));
1150
- }, rangeComponent: function (_a) {
1151
- var index = _a.index, width = _a.width, rangeProps = __rest(_a, ["index", "width"]);
1152
- var isLast = index === rangesCount - 1;
1153
- return (jsxRuntime.jsx(CustomBulletChartRange, __assign({ fill: rangeColor !== null && rangeColor !== void 0 ? rangeColor : chartColors.lightGrey }, rangeProps, { width: isLast ? width + 2 : width })));
1154
- }, margin: { top: 0, right: 10, bottom: -1, left: 10 } }, props)) })));
1159
+ return (jsxRuntime.jsx(CustomBulletChartMarkers, __assign({}, markerProps, { size: 4 })));
1160
+ }, rangeColors: chartColors.lightGrey, rangeBorderColor: "white", rangeBorderWidth: 2, margin: { top: 0, right: 10, bottom: -1, left: 10 } }) })));
1155
1161
  };
1156
1162
  var templateObject_1$15;
1157
1163
 
@@ -1173,7 +1179,7 @@ var CenteredItem = function (_a) {
1173
1179
  var PieChart = function (_a) {
1174
1180
  var theme = _a.theme, colors = _a.colors, width = _a.width, height = _a.height, data = _a.data, centerItem = _a.centerItem, margin = _a.margin;
1175
1181
  var themeContext = React.useContext(styled.ThemeContext);
1176
- return (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(pie.ResponsivePie, { theme: __assign(__assign({}, DEFAULT_CHARTS_THEME), theme), colors: colors !== null && colors !== void 0 ? colors : CHARTS_COLOR_SCHEME_CATEGORICAL_8_A, enableArcLabels: false, arcLinkLabelsColor: { from: "color" }, padAngle: 1, data: data, margin: __assign({ top: 40, bottom: 40 }, margin), innerRadius: 0.8, arcLinkLabelsThickness: 2, arcLinkLabelsTextColor: themeContext.palette.grey[600], layers: __spreadArray([
1182
+ return (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(pie.ResponsivePie, { theme: __assign(__assign({}, DEFAULT_CHARTS_THEME), theme), 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), innerRadius: 0.8, arcLinkLabelsThickness: 2, arcLinkLabelsTextColor: themeContext.palette.grey[600], layers: __spreadArray([
1177
1183
  "arcs",
1178
1184
  "arcLabels",
1179
1185
  "arcLinkLabels"
@@ -1253,8 +1259,11 @@ var CustomCell = function (_a) {
1253
1259
  };
1254
1260
 
1255
1261
  var WaffleChart = function (_a) {
1256
- var height = _a.height, width = _a.width, data = _a.data, total = _a.total;
1257
- return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(waffle.ResponsiveWaffle, { theme: DEFAULT_CHARTS_THEME, data: [
1262
+ var height = _a.height, width = _a.width, data = _a.data, total = _a.total, tooltip = _a.tooltip;
1263
+ return (jsxRuntime.jsx(ChartContainer, __assign({ width: width, height: height }, { children: jsxRuntime.jsx(waffle.ResponsiveWaffle, { theme: tooltip
1264
+ ? __assign(__assign({}, DEFAULT_CHARTS_THEME), { tooltip: __assign(__assign({}, tooltip), { container: {
1265
+ padding: 0,
1266
+ } }) }) : DEFAULT_CHARTS_THEME, data: [
1258
1267
  {
1259
1268
  id: "green-circles",
1260
1269
  label: data.label,
@@ -1265,7 +1274,10 @@ var WaffleChart = function (_a) {
1265
1274
  label: total.label,
1266
1275
  value: total.value,
1267
1276
  },
1268
- ], fillDirection: "bottom", total: total.value, rows: 8, columns: 8, colors: CHARTS_COLOR_SCHEME_MONO,
1277
+ ], tooltip: function (_a) {
1278
+ var value = _a.value, label = _a.label;
1279
+ return tooltip ? tooltip({ label: label, value: value }) : jsxRuntime.jsx(jsxRuntime.Fragment, { children: "".concat(label, ": ").concat(value) });
1280
+ }, fillDirection: "bottom", total: total.value, rows: 8, columns: 8, colors: CHARTS_COLOR_SCHEME_MONO,
1269
1281
  // @ts-ignore property cellComponent does not exist, but it does
1270
1282
  cellComponent: function (_a) {
1271
1283
  _a.borderWidth; _a.borderColor; var rest = __rest(_a, ["borderWidth", "borderColor"]);
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ export declare type ChartTooltipFunction = ({ value, label, }: {
3
+ value: number;
4
+ label: string;
5
+ }) => React.ReactNode;
@@ -1,9 +1,2 @@
1
- interface CustomBulletChartMarkerProps {
2
- x: number;
3
- y: number;
4
- bulletRadius: number;
5
- fill: string;
6
- size: number;
7
- }
8
- export declare const CustomBulletChartMarker: ({ x, y, bulletRadius, fill, size, }: CustomBulletChartMarkerProps) => JSX.Element;
9
- export {};
1
+ import { BulletMarkersItemProps } from "@nivo/bullet";
2
+ export declare const CustomBulletChartMarkers: ({ x, y, size, animatedProps: { color, transform }, data, onMouseEnter, onMouseMove, onMouseLeave, onClick, }: BulletMarkersItemProps) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ export interface CustomBulletChartMeasureProps {
2
+ x: number;
3
+ y: number;
4
+ color: string;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare const CustomMeasure: ({ x, y, width, height, color }: CustomBulletChartMeasureProps) => JSX.Element;
@@ -3,9 +3,4 @@ export interface BulletChartProps {
3
3
  values: number[];
4
4
  width?: string;
5
5
  height?: string;
6
- markerColor?: string;
7
- markerSize?: number;
8
- rangeColor?: string;
9
- measureSize?: number;
10
- measureColor?: string;
11
6
  }
@@ -1,3 +1,3 @@
1
1
  import { BulletChartProps } from "./_types";
2
- declare const BulletChart: ({ width, height, ranges, values, markerColor, markerSize, rangeColor, measureSize, measureColor, ...props }: BulletChartProps) => JSX.Element;
2
+ declare const BulletChart: ({ width, height, ranges, values }: BulletChartProps) => JSX.Element;
3
3
  export { BulletChart };
@@ -2,5 +2,5 @@ import { ComponentMeta, Story } from "@storybook/react";
2
2
  import { BulletChartProps } from "./_types";
3
3
  export declare const Default: Story<BulletChartProps>;
4
4
  export declare const Widget: Story<BulletChartProps>;
5
- declare const _default: ComponentMeta<({ width, height, ranges, values, markerColor, markerSize, rangeColor, measureSize, measureColor, ...props }: BulletChartProps) => JSX.Element>;
5
+ declare const _default: ComponentMeta<({ width, height, ranges, values }: BulletChartProps) => JSX.Element>;
6
6
  export default _default;
@@ -1,3 +1,4 @@
1
+ import { ChartTooltipFunction } from "../_types";
1
2
  interface WaffleDataItem {
2
3
  label: string;
3
4
  value: number;
@@ -7,5 +8,6 @@ export interface WaffleChartProps {
7
8
  total: WaffleDataItem;
8
9
  width?: string;
9
10
  height?: string;
11
+ tooltip?: ChartTooltipFunction;
10
12
  }
11
13
  export {};
@@ -1,3 +1,3 @@
1
1
  import { WaffleChartProps } from "./_types";
2
- declare const WaffleChart: ({ height, width, data, total }: WaffleChartProps) => JSX.Element;
2
+ declare const WaffleChart: ({ height, width, data, total, tooltip, }: WaffleChartProps) => JSX.Element;
3
3
  export { WaffleChart };
@@ -1,5 +1,6 @@
1
1
  import { ComponentMeta, Story } from "@storybook/react";
2
2
  import { WaffleChartProps } from "./_types";
3
3
  export declare const Default: Story<WaffleChartProps>;
4
- declare const _default: ComponentMeta<({ height, width, data, total }: WaffleChartProps) => JSX.Element>;
4
+ export declare const WithCustomTooltip: Story<WaffleChartProps>;
5
+ declare const _default: ComponentMeta<({ height, width, data, total, tooltip, }: WaffleChartProps) => JSX.Element>;
5
6
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "2.12.30",
3
+ "version": "2.12.32",
4
4
  "dependencies": {
5
5
  "@nivo/bar": "^0.80.0",
6
6
  "@nivo/bullet": "^0.80.0",
@@ -1,8 +0,0 @@
1
- export interface CustomBulletChartRangeProps {
2
- x: number;
3
- y: number;
4
- width: number;
5
- height: number;
6
- fill: string;
7
- }
8
- export declare const CustomBulletChartRange: ({ x, y, width, height, fill }: CustomBulletChartRangeProps) => JSX.Element;