td-stylekit 28.19.0 → 28.21.0
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
|
+
# [28.21.0](https://github.com/treasure-data/td-stylekit/compare/v28.20.0...v28.21.0) (2023-05-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **CON-12722:** Add a custom legend renderer to the PieChart component ([#1467](https://github.com/treasure-data/td-stylekit/issues/1467)) ([f812110](https://github.com/treasure-data/td-stylekit/commit/f812110))
|
|
7
|
+
|
|
8
|
+
# [28.20.0](https://github.com/treasure-data/td-stylekit/compare/v28.19.0...v28.20.0) (2023-04-13)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **CON-12768:** Add an icon for inviting users ([#1460](https://github.com/treasure-data/td-stylekit/issues/1460)) ([976c541](https://github.com/treasure-data/td-stylekit/commit/976c541))
|
|
14
|
+
|
|
1
15
|
# [28.19.0](https://github.com/treasure-data/td-stylekit/compare/v28.18.0...v28.19.0) (2023-04-13)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -522,6 +522,8 @@ export type IconTypes = {
|
|
|
522
522
|
IdServiceDraftIcon: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
|
523
523
|
Integration: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
|
524
524
|
IntegrationIcon: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
|
525
|
+
InviteUser: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
|
526
|
+
InviteUserIcon: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
|
525
527
|
Journey: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
|
526
528
|
JourneyIcon: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
|
527
529
|
JourneyDraft: React.ComponentType<JSX.IntrinsicElements['svg']>;
|
package/dist/es/Icon/types.js
CHANGED
|
@@ -1035,6 +1035,9 @@ React.createElement("path", {
|
|
|
1035
1035
|
}),Integration: /*#__PURE__*/
|
|
1036
1036
|
React.createElement("path", {
|
|
1037
1037
|
d: "M18.627 5.373a4.686 4.686 0 00-6.627 0l-1.506 1.506a.682.682 0 000 .964l.843.843-1.218 1.219a.937.937 0 101.325 1.325l1.219-1.218 1.325 1.325-1.218 1.219a.937.937 0 101.325 1.325l1.219-1.218.843.843a.682.682 0 00.964 0L18.627 12a4.686 4.686 0 000-6.627zM5.373 18.627a4.686 4.686 0 006.627 0l1.506-1.506a.682.682 0 000-.964l-5.663-5.663a.682.682 0 00-.964 0L5.373 12a4.686 4.686 0 000 6.627z"
|
|
1038
|
+
}),InviteUser: /*#__PURE__*/
|
|
1039
|
+
React.createElement("path", {
|
|
1040
|
+
d: "M14.874 7.923a3.817 3.817 0 10-7.635 0v.636a3.817 3.817 0 107.635 0v-.636zM11.057 14.166c.473 0 .972.051 1.476.144a4.674 4.674 0 00-.59 2.28c0 .774.187 1.505.519 2.149h-7.24c-.954 0-1.508-1.095-.927-1.852.941-1.223 4.213-2.721 6.762-2.721zM16.638 13.286a1 1 0 011 1v1.304h1.304a1 1 0 110 2h-1.304v1.305a1 1 0 11-2 0V17.59h-1.305a1 1 0 110-2h1.305v-1.304a1 1 0 011-1z"
|
|
1038
1041
|
}),Jobs: /*#__PURE__*/
|
|
1039
1042
|
React.createElement("path", {
|
|
1040
1043
|
d: "M2.11 6.688c0-2.015 1.426-3.89 3.461-3.89H18.43c2.035 0 3.461 1.875 3.461 3.89 0 2.014-1.426 3.89-3.461 3.89H5.57c-2.035 0-3.461-1.876-3.461-3.89zm16.319 2.11H16v-4.22h2.429c.804 0 1.68.81 1.68 2.11 0 1.298-.876 2.11-1.68 2.11zM2.11 17.313c0-2.015 1.426-3.89 3.461-3.89H18.43c2.035 0 3.461 1.875 3.461 3.89 0 2.014-1.426 3.89-3.461 3.89H5.57c-2.035 0-3.461-1.876-3.461-3.89zm16.319 2.11H9.5v-4.22h8.929c.804 0 1.68.81 1.68 2.11 0 1.298-.876 2.11-1.68 2.11z",
|
|
@@ -5,6 +5,18 @@ export type PieChartData = {
|
|
|
5
5
|
percent?: string;
|
|
6
6
|
index?: number;
|
|
7
7
|
} & chartUtils.Datum;
|
|
8
|
+
export interface CustomLegendRendererArguments {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
colorScale: string[];
|
|
12
|
+
data: {
|
|
13
|
+
name: string;
|
|
14
|
+
symbol: {
|
|
15
|
+
type: string;
|
|
16
|
+
fill: string;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
8
20
|
export type PieChartProps = {
|
|
9
21
|
width?: number;
|
|
10
22
|
height?: number;
|
|
@@ -12,12 +24,14 @@ export type PieChartProps = {
|
|
|
12
24
|
fixed?: number;
|
|
13
25
|
hoverTitle?: string;
|
|
14
26
|
hoverText?: string;
|
|
27
|
+
constrainTooltipSide?: ('left' | 'right' | 'top' | 'bottom')[];
|
|
28
|
+
customLegendRenderer?: (args: CustomLegendRendererArguments) => ReactElement;
|
|
15
29
|
numFormat?: (x: string | number) => string;
|
|
16
30
|
replaceToken?: string;
|
|
17
31
|
isRatioChart?: boolean;
|
|
18
32
|
chartColor?: ChartColors;
|
|
19
33
|
};
|
|
20
|
-
export declare function PieChart({ width, height, data, fixed, hoverText, hoverTitle, replaceToken, isRatioChart, chartColor, numFormat }: PieChartProps): ReactElement;
|
|
34
|
+
export declare function PieChart({ width, height, data, fixed, hoverText, hoverTitle, replaceToken, isRatioChart, chartColor, constrainTooltipSide, customLegendRenderer, numFormat }: PieChartProps): ReactElement;
|
|
21
35
|
export declare namespace PieChart {
|
|
22
36
|
var displayName: string;
|
|
23
37
|
}
|
|
@@ -70,6 +70,8 @@ function PieChart(_ref) {
|
|
|
70
70
|
_ref$isRatioChart = _ref.isRatioChart,
|
|
71
71
|
isRatioChart = _ref$isRatioChart === void 0 ? false : _ref$isRatioChart,
|
|
72
72
|
chartColor = _ref.chartColor,
|
|
73
|
+
constrainTooltipSide = _ref.constrainTooltipSide,
|
|
74
|
+
customLegendRenderer = _ref.customLegendRenderer,
|
|
73
75
|
_ref$numFormat = _ref.numFormat,
|
|
74
76
|
numFormat = _ref$numFormat === void 0 ? function (x) {
|
|
75
77
|
return new Intl.NumberFormat(undefined, {
|
|
@@ -194,13 +196,14 @@ function PieChart(_ref) {
|
|
|
194
196
|
// Need to cast to Record to prevent TS from complaining about incompatible types
|
|
195
197
|
|
|
196
198
|
var labelsStyle = (_theme$legend = theme.legend) === null || _theme$legend === void 0 ? void 0 : (_theme$legend$style = _theme$legend.style) === null || _theme$legend$style === void 0 ? void 0 : _theme$legend$style.labels;
|
|
197
|
-
return (0, _jsxRuntime.
|
|
199
|
+
return (0, _jsxRuntime.jsxs)(_Box["default"], {
|
|
198
200
|
"data-gs": gs("src", "piechart", "piechart.tsx", "pie-chart", "box"),
|
|
199
201
|
direction: "row",
|
|
202
|
+
align: "center",
|
|
200
203
|
padding: providerTheme.space[2],
|
|
201
|
-
children: (0, _jsxRuntime.jsxs)(_victory.VictoryContainer, {
|
|
204
|
+
children: [(0, _jsxRuntime.jsxs)(_victory.VictoryContainer, {
|
|
202
205
|
"data-gs": gs("src", "piechart", "piechart.tsx", "pie-chart", "box", "victory-container"),
|
|
203
|
-
width: containerWidth,
|
|
206
|
+
width: customLegendRenderer ? width : containerWidth,
|
|
204
207
|
height: height,
|
|
205
208
|
children: [(0, _jsxRuntime.jsx)(_victory.VictoryPie, {
|
|
206
209
|
"data-gs-c": gsC("pie"),
|
|
@@ -241,7 +244,7 @@ function PieChart(_ref) {
|
|
|
241
244
|
labels: function labels(_ref5) {
|
|
242
245
|
var datum = _ref5.datum;
|
|
243
246
|
return isRatioChart ? datum.index === 0 // only show the value label and hide total label
|
|
244
|
-
? [datum.y === 0 ? '-' : numFormat(Math.floor(datum.y)), datum.percent] : null : [datum.grey ? datum.x : hoverTitle ? hoverTitle.replace(replaceToken, datum.x) : datum.x, datum.percent
|
|
247
|
+
? [datum.y === 0 ? '-' : numFormat(Math.floor(datum.y)), datum.percent] : null : !hoverText ? [datum.grey ? datum.x : hoverTitle ? hoverTitle.replace(replaceToken, datum.x) : datum.x, datum.percent] : [datum.grey ? datum.x : hoverTitle ? hoverTitle.replace(replaceToken, datum.x) : datum.x, datum.percent, hoverText.replace(replaceToken, numFormat(Math.floor(parseFloat(datum.y))))];
|
|
245
248
|
},
|
|
246
249
|
labelComponent: isRatioChart ? (0, _jsxRuntime.jsx)(_victory.VictoryLabel, {
|
|
247
250
|
"data-gs": gs("src", "piechart", "piechart.tsx", "pie-chart", "box", "victory-container", "victory-pie", "victory-label"),
|
|
@@ -262,6 +265,25 @@ function PieChart(_ref) {
|
|
|
262
265
|
}]
|
|
263
266
|
}) : (0, _jsxRuntime.jsx)(_victory.VictoryTooltip, {
|
|
264
267
|
"data-gs": gs("src", "piechart", "piechart.tsx", "pie-chart", "box", "victory-container", "victory-pie", "victory-tooltip"),
|
|
268
|
+
orientation: constrainTooltipSide ? function () {
|
|
269
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
270
|
+
args[_key] = arguments[_key];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var averageAngle = (Number(args[0].datum.startAngle) + Number(args[0].datum.endAngle)) / 2;
|
|
274
|
+
|
|
275
|
+
if (averageAngle < 45) {
|
|
276
|
+
return constrainTooltipSide !== null && constrainTooltipSide !== void 0 && constrainTooltipSide.includes('top') ? 'bottom' : 'top';
|
|
277
|
+
} else if (averageAngle < 135) {
|
|
278
|
+
return constrainTooltipSide !== null && constrainTooltipSide !== void 0 && constrainTooltipSide.includes('right') ? 'left' : 'right';
|
|
279
|
+
} else if (averageAngle < 225) {
|
|
280
|
+
return constrainTooltipSide !== null && constrainTooltipSide !== void 0 && constrainTooltipSide.includes('bottom') ? 'top' : 'bottom';
|
|
281
|
+
} else if (averageAngle < 315) {
|
|
282
|
+
return constrainTooltipSide !== null && constrainTooltipSide !== void 0 && constrainTooltipSide.includes('left') ? 'right' : 'left';
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return constrainTooltipSide !== null && constrainTooltipSide !== void 0 && constrainTooltipSide.includes('top') ? 'bottom' : 'top';
|
|
286
|
+
} : undefined,
|
|
265
287
|
cornerRadius: 4,
|
|
266
288
|
pointerLength: 10,
|
|
267
289
|
flyoutStyle: {
|
|
@@ -294,7 +316,7 @@ function PieChart(_ref) {
|
|
|
294
316
|
})
|
|
295
317
|
}),
|
|
296
318
|
events: pieChartEvents
|
|
297
|
-
}), isRatioChart
|
|
319
|
+
}), !isRatioChart && !customLegendRenderer ? (0, _jsxRuntime.jsx)(_victory.VictoryLegend, {
|
|
298
320
|
"data-gs-c": gsC("legend"),
|
|
299
321
|
"data-gs": gs("src", "piechart", "piechart.tsx", "pie-chart", "box", "victory-container", "victory-legend"),
|
|
300
322
|
name: "legend",
|
|
@@ -313,8 +335,13 @@ function PieChart(_ref) {
|
|
|
313
335
|
labelComponent: (0, _jsxRuntime.jsx)(PieLegendLabel, {
|
|
314
336
|
"data-gs": gs("src", "piechart", "piechart.tsx", "pie-chart", "box", "victory-container", "victory-legend", "pie-legend-label")
|
|
315
337
|
})
|
|
316
|
-
})]
|
|
317
|
-
})
|
|
338
|
+
}) : (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {})]
|
|
339
|
+
}), customLegendRenderer && customLegendRenderer({
|
|
340
|
+
width: width,
|
|
341
|
+
height: legendHeight,
|
|
342
|
+
colorScale: _ChartPrimitives.chartUtils.DEFAULT_COLORS,
|
|
343
|
+
data: legend
|
|
344
|
+
})]
|
|
318
345
|
});
|
|
319
346
|
}
|
|
320
347
|
|