@spaced-out/ui-design-system 0.6.8 → 0.6.10
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 +14 -0
- package/lib/components/Charts/UniversalChart/UniversalChart.d.ts +22 -0
- package/lib/components/Charts/UniversalChart/UniversalChart.d.ts.map +1 -0
- package/lib/components/Charts/UniversalChart/UniversalChart.js +278 -0
- package/lib/components/Charts/UniversalChart/UniversalChart.module.css +7 -0
- package/lib/components/Charts/UniversalChart/UniversalChart.types.d.ts +37 -0
- package/lib/components/Charts/UniversalChart/UniversalChart.types.d.ts.map +1 -0
- package/lib/components/Charts/UniversalChart/UniversalChart.types.js +5 -0
- package/lib/components/Charts/UniversalChart/index.d.ts +2 -0
- package/lib/components/Charts/UniversalChart/index.d.ts.map +1 -0
- package/lib/components/Charts/UniversalChart/index.js +16 -0
- package/lib/components/Charts/index.d.ts +1 -0
- package/lib/components/Charts/index.d.ts.map +1 -1
- package/lib/components/Charts/index.js +11 -0
- package/lib/components/Pagination/Pagination.d.ts.map +1 -1
- package/lib/components/Pagination/Pagination.js +22 -9
- package/lib/components/Pagination/Pagination.module.css +5 -0
- package/lib/components/ProgressDonut/ProgressDonut.d.ts +9 -3
- package/lib/components/ProgressDonut/ProgressDonut.d.ts.map +1 -1
- package/lib/components/ProgressDonut/ProgressDonut.js +43 -17
- package/lib/components/ProgressDonut/ProgressDonut.module.css +5 -0
- package/mcp/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.6.10](https://github.com/spaced-out/ui-design-system/compare/v0.6.9...v0.6.10) (2026-04-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* rating prop in Progressdonut, responsiveness in Pagination ([#474](https://github.com/spaced-out/ui-design-system/issues/474)) ([0516ad4](https://github.com/spaced-out/ui-design-system/commit/0516ad4ba28995df31c3427cdfc8da15dae3e6ab))
|
|
11
|
+
|
|
12
|
+
### [0.6.9](https://github.com/spaced-out/ui-design-system/compare/v0.6.8...v0.6.9) (2026-04-10)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* [GDS-559]added universal chart to follow chart transitions ([#473](https://github.com/spaced-out/ui-design-system/issues/473)) ([b88cbba](https://github.com/spaced-out/ui-design-system/commit/b88cbba3293d4cfa86e2daff178769f1b94a7a83))
|
|
18
|
+
|
|
5
19
|
### [0.6.8](https://github.com/spaced-out/ui-design-system/compare/v0.6.7...v0.6.8) (2026-04-09)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { CategoricalChartKind, ChartKindOptionType, FlowChartKind, ProportionChartKind, UniversalChartProps } from '../../../components/Charts/UniversalChart/UniversalChart.types';
|
|
3
|
+
export declare const CHART_KIND_OPTIONS: Readonly<{
|
|
4
|
+
column: ChartKindOptionType<"column">;
|
|
5
|
+
line: ChartKindOptionType<"line">;
|
|
6
|
+
donut: ChartKindOptionType<"donut">;
|
|
7
|
+
funnel: ChartKindOptionType<"funnel">;
|
|
8
|
+
sankey: ChartKindOptionType<"sankey">;
|
|
9
|
+
spider: ChartKindOptionType<"spider">;
|
|
10
|
+
stackedBar: ChartKindOptionType<"stackedBar">;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const CHART_KIND_GROUPS: Readonly<{
|
|
13
|
+
CATEGORICAL: Array<ChartKindOptionType<CategoricalChartKind>>;
|
|
14
|
+
PROPORTION: Array<ChartKindOptionType<ProportionChartKind>>;
|
|
15
|
+
FLOW: Array<ChartKindOptionType<FlowChartKind>>;
|
|
16
|
+
}>;
|
|
17
|
+
export type { UniversalChartProps, ChartKind, ChartKindOptionType, ChartKindSelectorProps, CategoricalChartKind, ProportionChartKind, FlowChartKind, } from '../../../components/Charts/UniversalChart/UniversalChart.types';
|
|
18
|
+
export declare const UniversalChart: {
|
|
19
|
+
(props: UniversalChartProps): React.JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=UniversalChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniversalChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Charts/UniversalChart/UniversalChart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,OAAO,KAAK,EACV,oBAAoB,EAEpB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,2DAA2D,CAAC;AAOnE,eAAO,MAAM,kBAAkB;YAIxB,mBAAmB,CAAC,QAAQ,CAAC;UACU,mBAAmB,CAAC,MAAM,CAAC;WACxB,mBAAmB,CAAC,OAAO,CAAC;YAItE,mBAAmB,CAAC,QAAQ,CAAC;YAI7B,mBAAmB,CAAC,QAAQ,CAAC;YAI7B,mBAAmB,CAAC,QAAQ,CAAC;gBAI7B,mBAAmB,CAAC,YAAY,CAAC;EACtC,CAAC;AAEH,eAAO,MAAM,iBAAiB;iBAMvB,KAAK,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;gBACgB,KAAK,CACxE,mBAAmB,CAAC,mBAAmB,CAAC,CACzC;UACoC,KAAK,CACxC,mBAAmB,CAAC,aAAa,CAAC,CACnC;EACD,CAAC;AAmBH,YAAY,EACV,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,GACd,MAAM,2DAA2D,CAAC;AAEnE,eAAO,MAAM,cAAc;YAAW,mBAAmB;;CA6OxD,CAAC"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UniversalChart = exports.CHART_KIND_OPTIONS = exports.CHART_KIND_GROUPS = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _size = require("../../../styles/variables/_size");
|
|
9
|
+
var _classify = _interopRequireDefault(require("../../../utils/classify"));
|
|
10
|
+
var _qa = require("../../../utils/qa");
|
|
11
|
+
var _ButtonDropdown = require("../../ButtonDropdown");
|
|
12
|
+
var _ChartWrapper = require("../ChartWrapper");
|
|
13
|
+
var _ColumnChart = require("../ColumnChart");
|
|
14
|
+
var _DonutChart = require("../DonutChart");
|
|
15
|
+
var _FunnelChart = require("../FunnelChart");
|
|
16
|
+
var _LineChart = require("../LineChart");
|
|
17
|
+
var _SankeyChart = require("../SankeyChart");
|
|
18
|
+
var _SpiderChart = require("../SpiderChart");
|
|
19
|
+
var _StackedBarChart = require("../StackedBarChart");
|
|
20
|
+
var _EmptyState = require("../../EmptyState");
|
|
21
|
+
var _UniversalChartModule = _interopRequireDefault(require("./UniversalChart.module.css"));
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
25
|
+
const CHART_KIND_OPTIONS = exports.CHART_KIND_OPTIONS = Object.freeze({
|
|
26
|
+
column: {
|
|
27
|
+
key: 'column',
|
|
28
|
+
label: 'Column Chart'
|
|
29
|
+
},
|
|
30
|
+
line: {
|
|
31
|
+
key: 'line',
|
|
32
|
+
label: 'Line Chart'
|
|
33
|
+
},
|
|
34
|
+
donut: {
|
|
35
|
+
key: 'donut',
|
|
36
|
+
label: 'Donut Chart'
|
|
37
|
+
},
|
|
38
|
+
funnel: {
|
|
39
|
+
key: 'funnel',
|
|
40
|
+
label: 'Funnel Chart'
|
|
41
|
+
},
|
|
42
|
+
sankey: {
|
|
43
|
+
key: 'sankey',
|
|
44
|
+
label: 'Sankey Chart'
|
|
45
|
+
},
|
|
46
|
+
spider: {
|
|
47
|
+
key: 'spider',
|
|
48
|
+
label: 'Spider Chart'
|
|
49
|
+
},
|
|
50
|
+
stackedBar: {
|
|
51
|
+
key: 'stackedBar',
|
|
52
|
+
label: 'Stacked Bar Chart'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const CHART_KIND_GROUPS = exports.CHART_KIND_GROUPS = Object.freeze({
|
|
56
|
+
CATEGORICAL: [CHART_KIND_OPTIONS.column, CHART_KIND_OPTIONS.line, CHART_KIND_OPTIONS.stackedBar, CHART_KIND_OPTIONS.spider],
|
|
57
|
+
PROPORTION: [CHART_KIND_OPTIONS.donut, CHART_KIND_OPTIONS.funnel],
|
|
58
|
+
FLOW: [CHART_KIND_OPTIONS.sankey]
|
|
59
|
+
});
|
|
60
|
+
const sortSeriesDescending = series => series.map(item => ({
|
|
61
|
+
...item,
|
|
62
|
+
data: [...item.data].sort((a, b) => (b.y ?? 0) - (a.y ?? 0))
|
|
63
|
+
}));
|
|
64
|
+
const getGroupForKind = kind => {
|
|
65
|
+
for (const group of Object.values(CHART_KIND_GROUPS)) {
|
|
66
|
+
if (group.some(opt => opt.key === kind)) {
|
|
67
|
+
return group.map(opt => opt.key);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [kind];
|
|
71
|
+
};
|
|
72
|
+
const UniversalChart = props => {
|
|
73
|
+
const {
|
|
74
|
+
chartKind,
|
|
75
|
+
showChartKindSwitcher = false,
|
|
76
|
+
chartKindOptions,
|
|
77
|
+
onChartKindChange,
|
|
78
|
+
responsive = true
|
|
79
|
+
} = props;
|
|
80
|
+
const classNames = 'classNames' in props ? props.classNames : undefined;
|
|
81
|
+
const responsiveClassNames = responsive ? {
|
|
82
|
+
...classNames,
|
|
83
|
+
highChart: (0, _classify.default)(classNames?.highChart, _UniversalChartModule.default.responsiveChart)
|
|
84
|
+
} : classNames;
|
|
85
|
+
const testId = 'testId' in props ? props.testId : undefined;
|
|
86
|
+
const cardTitle = 'cardTitle' in props ? props.cardTitle : undefined;
|
|
87
|
+
const headerActions = 'headerActions' in props ? props.headerActions : undefined;
|
|
88
|
+
const chartKindMenuOptions = React.useMemo(() => {
|
|
89
|
+
if (!showChartKindSwitcher) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const compatibleGroup = getGroupForKind(chartKind);
|
|
93
|
+
const source = chartKindOptions ? chartKindOptions.filter(option => compatibleGroup.includes(option.key)) : compatibleGroup.map(kind => CHART_KIND_OPTIONS[kind]);
|
|
94
|
+
const options = source.map(_ref => {
|
|
95
|
+
let {
|
|
96
|
+
key,
|
|
97
|
+
label
|
|
98
|
+
} = _ref;
|
|
99
|
+
return {
|
|
100
|
+
key,
|
|
101
|
+
label
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
return options.length > 0 ? options : undefined;
|
|
105
|
+
}, [showChartKindSwitcher, chartKindOptions, chartKind]);
|
|
106
|
+
const handleChartKindSelect = React.useCallback(option => {
|
|
107
|
+
onChartKindChange?.(option.key);
|
|
108
|
+
}, [onChartKindChange]);
|
|
109
|
+
const switcherElement = showChartKindSwitcher && chartKindMenuOptions ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonDropdown.ButtonDropdown, {
|
|
110
|
+
ariaLabel: "Switch Chart Type",
|
|
111
|
+
menu: {
|
|
112
|
+
isFluid: false,
|
|
113
|
+
menuDisabled: false,
|
|
114
|
+
options: chartKindMenuOptions,
|
|
115
|
+
selectedKeys: [chartKind],
|
|
116
|
+
size: 'medium',
|
|
117
|
+
width: _size.size180
|
|
118
|
+
},
|
|
119
|
+
iconLeftName: "chart-mixed",
|
|
120
|
+
onOptionSelect: handleChartKindSelect,
|
|
121
|
+
size: "small",
|
|
122
|
+
type: "ghost",
|
|
123
|
+
anchorPosition: _ButtonDropdown.ANCHOR_POSITION_TYPE.bottomEnd,
|
|
124
|
+
testId: (0, _qa.generateTestId)({
|
|
125
|
+
base: testId,
|
|
126
|
+
slot: 'chart-kind-selector'
|
|
127
|
+
})
|
|
128
|
+
}) : null;
|
|
129
|
+
const combinedHeaderActions = switcherElement || headerActions ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
130
|
+
children: [switcherElement, headerActions]
|
|
131
|
+
}) : undefined;
|
|
132
|
+
const consumerChart = 'chart' in props ? props.chart : undefined;
|
|
133
|
+
const responsiveChart = responsive ? {
|
|
134
|
+
...consumerChart,
|
|
135
|
+
height: '60%'
|
|
136
|
+
} : consumerChart;
|
|
137
|
+
switch (props.chartKind) {
|
|
138
|
+
case 'column':
|
|
139
|
+
{
|
|
140
|
+
const {
|
|
141
|
+
chartKind: _chartKind,
|
|
142
|
+
showChartKindSwitcher: _showChartKindSwitcher,
|
|
143
|
+
chartKindOptions: _chartKindOptions,
|
|
144
|
+
onChartKindChange: _onChartKindChange,
|
|
145
|
+
responsive: _responsive,
|
|
146
|
+
...rest
|
|
147
|
+
} = props;
|
|
148
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColumnChart.ColumnChart, {
|
|
149
|
+
...rest,
|
|
150
|
+
chart: responsiveChart,
|
|
151
|
+
headerActions: combinedHeaderActions,
|
|
152
|
+
classNames: responsiveClassNames
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
case 'line':
|
|
156
|
+
{
|
|
157
|
+
const {
|
|
158
|
+
chartKind: _chartKind,
|
|
159
|
+
showChartKindSwitcher: _showChartKindSwitcher,
|
|
160
|
+
chartKindOptions: _chartKindOptions,
|
|
161
|
+
onChartKindChange: _onChartKindChange,
|
|
162
|
+
responsive: _responsive,
|
|
163
|
+
...rest
|
|
164
|
+
} = props;
|
|
165
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineChart.LineChart, {
|
|
166
|
+
...rest,
|
|
167
|
+
chart: responsiveChart,
|
|
168
|
+
headerActions: combinedHeaderActions,
|
|
169
|
+
classNames: responsiveClassNames
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
case 'donut':
|
|
173
|
+
{
|
|
174
|
+
const {
|
|
175
|
+
chartKind: _chartKind,
|
|
176
|
+
showChartKindSwitcher: _showChartKindSwitcher,
|
|
177
|
+
chartKindOptions: _chartKindOptions,
|
|
178
|
+
onChartKindChange: _onChartKindChange,
|
|
179
|
+
responsive: _responsive,
|
|
180
|
+
...rest
|
|
181
|
+
} = props;
|
|
182
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DonutChart.DonutChart, {
|
|
183
|
+
...rest,
|
|
184
|
+
headerActions: combinedHeaderActions,
|
|
185
|
+
classNames: responsiveClassNames
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
case 'funnel':
|
|
189
|
+
{
|
|
190
|
+
const {
|
|
191
|
+
chartKind: _chartKind,
|
|
192
|
+
showChartKindSwitcher: _showChartKindSwitcher,
|
|
193
|
+
chartKindOptions: _chartKindOptions,
|
|
194
|
+
onChartKindChange: _onChartKindChange,
|
|
195
|
+
responsive: _responsive,
|
|
196
|
+
...rest
|
|
197
|
+
} = props;
|
|
198
|
+
const sortedSeries = sortSeriesDescending(rest.series);
|
|
199
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FunnelChart.FunnelChart, {
|
|
200
|
+
...rest,
|
|
201
|
+
chart: responsiveChart,
|
|
202
|
+
series: sortedSeries,
|
|
203
|
+
headerActions: combinedHeaderActions,
|
|
204
|
+
classNames: responsiveClassNames
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
case 'sankey':
|
|
208
|
+
{
|
|
209
|
+
const {
|
|
210
|
+
chartKind: _chartKind,
|
|
211
|
+
showChartKindSwitcher: _showChartKindSwitcher,
|
|
212
|
+
chartKindOptions: _chartKindOptions,
|
|
213
|
+
onChartKindChange: _onChartKindChange,
|
|
214
|
+
responsive: _responsive,
|
|
215
|
+
...rest
|
|
216
|
+
} = props;
|
|
217
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SankeyChart.SankeyChart, {
|
|
218
|
+
...rest,
|
|
219
|
+
chart: responsiveChart,
|
|
220
|
+
headerActions: combinedHeaderActions,
|
|
221
|
+
classNames: responsiveClassNames
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
case 'spider':
|
|
225
|
+
{
|
|
226
|
+
const {
|
|
227
|
+
chartKind: _chartKind,
|
|
228
|
+
showChartKindSwitcher: _showChartKindSwitcher,
|
|
229
|
+
chartKindOptions: _chartKindOptions,
|
|
230
|
+
onChartKindChange: _onChartKindChange,
|
|
231
|
+
responsive: _responsive,
|
|
232
|
+
...rest
|
|
233
|
+
} = props;
|
|
234
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpiderChart.SpiderChart, {
|
|
235
|
+
...rest,
|
|
236
|
+
chart: responsiveChart,
|
|
237
|
+
headerActions: combinedHeaderActions,
|
|
238
|
+
classNames: responsiveClassNames
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
case 'stackedBar':
|
|
242
|
+
{
|
|
243
|
+
const {
|
|
244
|
+
chartKind: _chartKind,
|
|
245
|
+
showChartKindSwitcher: _showChartKindSwitcher,
|
|
246
|
+
chartKindOptions: _chartKindOptions,
|
|
247
|
+
onChartKindChange: _onChartKindChange,
|
|
248
|
+
responsive: _responsive,
|
|
249
|
+
...rest
|
|
250
|
+
} = props;
|
|
251
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackedBarChart.StackedBarChart, {
|
|
252
|
+
...rest,
|
|
253
|
+
chart: responsiveChart,
|
|
254
|
+
headerActions: combinedHeaderActions,
|
|
255
|
+
classNames: responsiveClassNames
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
default:
|
|
259
|
+
{
|
|
260
|
+
const _exhaustive = props;
|
|
261
|
+
const unsupportedKind = _exhaustive.chartKind;
|
|
262
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartWrapper.ChartWrapper, {
|
|
263
|
+
title: cardTitle,
|
|
264
|
+
headerActions: combinedHeaderActions,
|
|
265
|
+
classNames: responsiveClassNames,
|
|
266
|
+
testId: testId,
|
|
267
|
+
hasEmptyData: true,
|
|
268
|
+
emptyText: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmptyState.EmptyState, {
|
|
269
|
+
imageVariant: "chart",
|
|
270
|
+
title: "Unsupported chart type",
|
|
271
|
+
description: `Chart kind "${unsupportedKind}" is not supported.`
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
exports.UniversalChart = UniversalChart;
|
|
278
|
+
UniversalChart.displayName = 'UniversalChart';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ColumnChartProps } from '../../../components/Charts/ColumnChart';
|
|
2
|
+
import type { DonutChartProps } from '../../../components/Charts/DonutChart';
|
|
3
|
+
import type { FunnelChartProps } from '../../../components/Charts/FunnelChart';
|
|
4
|
+
import type { LineChartProps } from '../../../components/Charts/LineChart';
|
|
5
|
+
import type { SankeyChartProps } from '../../../components/Charts/SankeyChart';
|
|
6
|
+
import type { SpiderChartProps } from '../../../components/Charts/SpiderChart';
|
|
7
|
+
import type { StackedBarChartProps } from '../../../components/Charts/StackedBarChart';
|
|
8
|
+
export type ChartKind = 'column' | 'line' | 'donut' | 'funnel' | 'sankey' | 'spider' | 'stackedBar';
|
|
9
|
+
export type CategoricalChartKind = 'column' | 'line' | 'stackedBar' | 'spider';
|
|
10
|
+
export type ProportionChartKind = 'donut' | 'funnel';
|
|
11
|
+
export type FlowChartKind = 'sankey';
|
|
12
|
+
export interface ChartKindOptionType<K extends ChartKind = ChartKind> {
|
|
13
|
+
key: K;
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ChartKindSelectorProps {
|
|
17
|
+
showChartKindSwitcher?: boolean;
|
|
18
|
+
chartKindOptions?: Array<ChartKindOptionType<CategoricalChartKind>> | Array<ChartKindOptionType<ProportionChartKind>> | Array<ChartKindOptionType<FlowChartKind>>;
|
|
19
|
+
onChartKindChange?: (chartKind: ChartKind) => void;
|
|
20
|
+
responsive?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type UniversalChartProps = (({
|
|
23
|
+
chartKind: 'column';
|
|
24
|
+
} & ColumnChartProps) | ({
|
|
25
|
+
chartKind: 'line';
|
|
26
|
+
} & LineChartProps) | ({
|
|
27
|
+
chartKind: 'donut';
|
|
28
|
+
} & DonutChartProps) | ({
|
|
29
|
+
chartKind: 'funnel';
|
|
30
|
+
} & FunnelChartProps) | ({
|
|
31
|
+
chartKind: 'sankey';
|
|
32
|
+
} & SankeyChartProps) | ({
|
|
33
|
+
chartKind: 'spider';
|
|
34
|
+
} & SpiderChartProps) | ({
|
|
35
|
+
chartKind: 'stackedBar';
|
|
36
|
+
} & StackedBarChartProps)) & ChartKindSelectorProps;
|
|
37
|
+
//# sourceMappingURL=UniversalChart.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniversalChart.types.d.ts","sourceRoot":"","sources":["../../../../src/components/Charts/UniversalChart/UniversalChart.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAC;AAGhF,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,YAAY,CAAC;AAEjB,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,MAAM,GAAG,YAAY,GAAG,QAAQ,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,CAAC;AACrD,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;AAErC,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAClE,GAAG,EAAE,CAAC,CAAC;IACP,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EACb,KAAK,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,GAChD,KAAK,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,GAC/C,KAAK,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9C,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAC9B,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAA;CAAC,GAAG,gBAAgB,CAAC,GAC1C,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,GAAG,cAAc,CAAC,GACtC,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAC,GAAG,eAAe,CAAC,GACxC,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAA;CAAC,GAAG,gBAAgB,CAAC,GAC1C,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAA;CAAC,GAAG,gBAAgB,CAAC,GAC1C,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAA;CAAC,GAAG,gBAAgB,CAAC,GAC1C,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAC,GAAG,oBAAoB,CAAC,CACrD,GACC,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Charts/UniversalChart/index.ts"],"names":[],"mappings":"AAAA,cAAc,qDAAqD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _UniversalChart = require("./UniversalChart");
|
|
7
|
+
Object.keys(_UniversalChart).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _UniversalChart[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _UniversalChart[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -7,4 +7,5 @@ export * from '../../components/Charts/LineChart';
|
|
|
7
7
|
export * from '../../components/Charts/SankeyChart';
|
|
8
8
|
export * from '../../components/Charts/SpiderChart';
|
|
9
9
|
export * from '../../components/Charts/StackedBarChart';
|
|
10
|
+
export * from '../../components/Charts/UniversalChart';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Charts/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Charts/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC"}
|
|
@@ -101,4 +101,15 @@ Object.keys(_StackedBarChart).forEach(function (key) {
|
|
|
101
101
|
return _StackedBarChart[key];
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
+
});
|
|
105
|
+
var _UniversalChart = require("./UniversalChart");
|
|
106
|
+
Object.keys(_UniversalChart).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _UniversalChart[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _UniversalChart[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
104
115
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/Pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/Pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAgBrD,KAAK,UAAU,GAAG,QAAQ,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,KAAK,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,UAAU,GACV,MAAM,GACN,gBAAgB,GAChB,cAAc,GACd,MAAM,GACN,MAAM,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CACT,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,KAClC,IAAI,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,eACf,SAAQ,IAAI,CACR;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAC,EAC5B,MAAM,mBAAmB,GAAG,MAAM;IAAC,UAAU,CAAC,EAAE,UAAU,CAAA;CAAC,CAC5D,EACD,mBAAmB;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC5D,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD,eAAO,MAAM,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAC7C,eAAe,EACf,cAAc,CAoIf,CAAC"}
|
|
@@ -10,6 +10,7 @@ var _useWindowSize = require("../../hooks/useWindowSize");
|
|
|
10
10
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
11
11
|
var _helpers = require("../../utils/helpers");
|
|
12
12
|
var _qa = require("../../utils/qa");
|
|
13
|
+
var _string = require("../../utils/string");
|
|
13
14
|
var _Dropdown = require("../Dropdown");
|
|
14
15
|
var _PaginationItem = require("./PaginationItem");
|
|
15
16
|
var _Text = require("../Text");
|
|
@@ -18,12 +19,12 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
21
|
const LARGE_LIST_DROPDOWN_OPTIONS = 50;
|
|
21
|
-
const
|
|
22
|
+
const COMPACT_BREAKPOINT = 500;
|
|
22
23
|
const Pagination = exports.Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
23
24
|
const {
|
|
24
25
|
width
|
|
25
26
|
} = (0, _useWindowSize.useWindowSize)();
|
|
26
|
-
const
|
|
27
|
+
const isCompact = width <= COMPACT_BREAKPOINT;
|
|
27
28
|
const {
|
|
28
29
|
classNames,
|
|
29
30
|
style = 'primary',
|
|
@@ -31,13 +32,15 @@ const Pagination = exports.Pagination = /*#__PURE__*/React.forwardRef((props, re
|
|
|
31
32
|
currentPage = 1,
|
|
32
33
|
totalPages = 1,
|
|
33
34
|
onChange,
|
|
34
|
-
showFirstButton = style !== 'primary' &&
|
|
35
|
-
showLastButton = style !== 'primary' &&
|
|
35
|
+
showFirstButton = style !== 'primary' && !isCompact,
|
|
36
|
+
showLastButton = style !== 'primary' && !isCompact,
|
|
36
37
|
staticPaginationLabel,
|
|
37
38
|
testId,
|
|
38
39
|
...restPaginationProps
|
|
39
40
|
} = props;
|
|
40
|
-
const
|
|
41
|
+
const isNotPrimary = style !== 'primary';
|
|
42
|
+
const showPageSelectionDropDown = isNotPrimary && !isCompact;
|
|
43
|
+
const showChildren = !(style === 'primary' && isCompact);
|
|
41
44
|
const {
|
|
42
45
|
items
|
|
43
46
|
} = (0, _usePagination.usePagination)({
|
|
@@ -63,8 +66,10 @@ const Pagination = exports.Pagination = /*#__PURE__*/React.forwardRef((props, re
|
|
|
63
66
|
base: testId,
|
|
64
67
|
slot: 'root'
|
|
65
68
|
}),
|
|
66
|
-
className: (0, _classify.default)(_PaginationModule.default.wrapper,
|
|
67
|
-
|
|
69
|
+
className: (0, _classify.default)(_PaginationModule.default.wrapper, {
|
|
70
|
+
[_PaginationModule.default.wrapperCompact]: style === 'primary' && isCompact
|
|
71
|
+
}, classNames?.wrapper),
|
|
72
|
+
children: [showChildren && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
68
73
|
className: (0, _classify.default)(_PaginationModule.default.childrenSlot, classNames?.children),
|
|
69
74
|
"data-testid": (0, _qa.generateTestId)({
|
|
70
75
|
base: testId,
|
|
@@ -77,7 +82,7 @@ const Pagination = exports.Pagination = /*#__PURE__*/React.forwardRef((props, re
|
|
|
77
82
|
base: testId,
|
|
78
83
|
slot: 'paginator-slots'
|
|
79
84
|
}),
|
|
80
|
-
children: [
|
|
85
|
+
children: [isNotPrimary && showPageSelectionDropDown && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
81
86
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Dropdown.Dropdown, {
|
|
82
87
|
size: "small",
|
|
83
88
|
classNames: {
|
|
@@ -105,8 +110,16 @@ const Pagination = exports.Pagination = /*#__PURE__*/React.forwardRef((props, re
|
|
|
105
110
|
base: testId,
|
|
106
111
|
slot: 'label'
|
|
107
112
|
}),
|
|
108
|
-
children: staticPaginationLabel ? staticPaginationLabel : `of ${totalPages} ${
|
|
113
|
+
children: staticPaginationLabel ? staticPaginationLabel : `of ${totalPages} ${(0, _string.formatWord)('Page', totalPages)}`
|
|
109
114
|
})]
|
|
115
|
+
}), isNotPrimary && isCompact && !!totalPages && !!currentPage && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.SubTitleExtraSmall, {
|
|
116
|
+
color: "tertiary",
|
|
117
|
+
className: _PaginationModule.default.secondaryLabel,
|
|
118
|
+
testId: (0, _qa.generateTestId)({
|
|
119
|
+
base: testId,
|
|
120
|
+
slot: 'label'
|
|
121
|
+
}),
|
|
122
|
+
children: staticPaginationLabel ? staticPaginationLabel : `${currentPage} of ${totalPages} ${(0, _string.formatWord)('Page', totalPages)}`
|
|
110
123
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
111
124
|
className: (0, _classify.default)(_PaginationModule.default.paginatorSlot, classNames?.paginator),
|
|
112
125
|
"data-testid": (0, _qa.generateTestId)({
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
justify-content: space-between;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.wrapperCompact {
|
|
14
|
+
justify-content: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
.childrenSlot {
|
|
14
18
|
display: flex;
|
|
15
19
|
}
|
|
@@ -21,6 +25,7 @@
|
|
|
21
25
|
|
|
22
26
|
.paginatorSlots {
|
|
23
27
|
display: flex;
|
|
28
|
+
align-items: center;
|
|
24
29
|
gap: spaceSmall;
|
|
25
30
|
}
|
|
26
31
|
|
|
@@ -4,12 +4,18 @@ type ClassNames = Readonly<{
|
|
|
4
4
|
wrapper?: string;
|
|
5
5
|
donutChart?: string;
|
|
6
6
|
}>;
|
|
7
|
-
export
|
|
7
|
+
export type ProgressDonutProps = {
|
|
8
8
|
classNames?: ClassNames;
|
|
9
9
|
color?: keyof typeof COLORS;
|
|
10
|
-
|
|
10
|
+
size?: 'small' | 'medium';
|
|
11
11
|
testId?: string;
|
|
12
|
-
}
|
|
12
|
+
} & ({
|
|
13
|
+
percentage?: number;
|
|
14
|
+
rating?: never;
|
|
15
|
+
} | {
|
|
16
|
+
rating: number;
|
|
17
|
+
percentage?: never;
|
|
18
|
+
});
|
|
13
19
|
export declare const ProgressDonut: Flow.AbstractComponent<ProgressDonutProps, HTMLDivElement>;
|
|
14
20
|
export {};
|
|
15
21
|
//# sourceMappingURL=ProgressDonut.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressDonut.d.ts","sourceRoot":"","sources":["../../../src/components/ProgressDonut/ProgressDonut.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"ProgressDonut.d.ts","sourceRoot":"","sources":["../../../src/components/ProgressDonut/ProgressDonut.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAuBtD,KAAK,UAAU,GAAG,QAAQ,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,CACA;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAC,GACrC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAC,CACvC,CAAC;AAcF,eAAO,MAAM,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAChD,kBAAkB,EAClB,cAAc,CAsGf,CAAC"}
|
|
@@ -13,14 +13,24 @@ var _ProgressDonutModule = _interopRequireDefault(require("./ProgressDonut.modul
|
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
-
const STROKE_WIDTH = 8;
|
|
17
16
|
const MIN_PERCENTAGE = 0;
|
|
18
17
|
const DIVISOR_TWO = 2;
|
|
19
18
|
const MAX_PERCENTAGE = 100;
|
|
19
|
+
const MAX_RATING = 10;
|
|
20
|
+
const MIN_RATING = 0;
|
|
20
21
|
const SUCCESS_THRESHOLD = 80;
|
|
21
|
-
const LARGE_DONUT_SIZE = 72;
|
|
22
22
|
const INFO_THRESHOLD = 50;
|
|
23
23
|
const WARNING_THRESHOLD = 30;
|
|
24
|
+
const DONUT_CONFIG = {
|
|
25
|
+
small: {
|
|
26
|
+
size: 34,
|
|
27
|
+
strokeWidth: 4
|
|
28
|
+
},
|
|
29
|
+
medium: {
|
|
30
|
+
size: 72,
|
|
31
|
+
strokeWidth: 8
|
|
32
|
+
}
|
|
33
|
+
};
|
|
24
34
|
const getProgressDonutColor = percentage => {
|
|
25
35
|
if (percentage >= SUCCESS_THRESHOLD) {
|
|
26
36
|
return COLORS.colorSuccess;
|
|
@@ -35,15 +45,29 @@ const getProgressDonutColor = percentage => {
|
|
|
35
45
|
const ProgressDonut = exports.ProgressDonut = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
36
46
|
let {
|
|
37
47
|
classNames,
|
|
38
|
-
percentage
|
|
48
|
+
percentage,
|
|
49
|
+
rating,
|
|
39
50
|
color,
|
|
51
|
+
size = 'medium',
|
|
40
52
|
testId
|
|
41
53
|
} = _ref;
|
|
42
|
-
const
|
|
54
|
+
const clampedRating = rating != null ? Math.min(Math.max(Math.round(rating), MIN_RATING), MAX_RATING) : undefined;
|
|
55
|
+
const donutPercentage = React.useMemo(() => {
|
|
56
|
+
if (clampedRating != null) {
|
|
57
|
+
return clampedRating / MAX_RATING * MAX_PERCENTAGE;
|
|
58
|
+
}
|
|
59
|
+
return Math.min(Math.max(percentage ?? 0, MIN_PERCENTAGE), MAX_PERCENTAGE);
|
|
60
|
+
}, [percentage, clampedRating]);
|
|
43
61
|
const donutColor = React.useMemo(() => getProgressDonutColor(donutPercentage), [donutPercentage]);
|
|
44
|
-
const
|
|
62
|
+
const {
|
|
63
|
+
size: donutSize,
|
|
64
|
+
strokeWidth
|
|
65
|
+
} = DONUT_CONFIG[size];
|
|
66
|
+
const radius = React.useMemo(() => (donutSize - strokeWidth) / DIVISOR_TWO, [donutSize, strokeWidth]);
|
|
45
67
|
const circumference = React.useMemo(() => DIVISOR_TWO * Math.PI * radius, [radius]);
|
|
46
68
|
const offset = React.useMemo(() => circumference - donutPercentage / MAX_PERCENTAGE * circumference, [circumference, donutPercentage]);
|
|
69
|
+
const displayValue = clampedRating != null ? `${clampedRating}` : `${donutPercentage}%`;
|
|
70
|
+
const TextComponent = size === 'small' ? _Text.BodyMediumBold : _Text.BodyLargeBold;
|
|
47
71
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
48
72
|
ref: ref,
|
|
49
73
|
"data-testid": (0, _qa.generateTestId)({
|
|
@@ -54,34 +78,36 @@ const ProgressDonut = exports.ProgressDonut = /*#__PURE__*/React.forwardRef((_re
|
|
|
54
78
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
55
79
|
className: (0, _classify.default)(_ProgressDonutModule.default.donutChart, classNames?.donutChart),
|
|
56
80
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
|
|
57
|
-
width:
|
|
58
|
-
height:
|
|
59
|
-
viewBox: `0 0 ${
|
|
81
|
+
width: donutSize,
|
|
82
|
+
height: donutSize,
|
|
83
|
+
viewBox: `0 0 ${donutSize} ${donutSize}`,
|
|
60
84
|
className: _ProgressDonutModule.default.donutChartSvg,
|
|
61
85
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("circle", {
|
|
62
86
|
className: _ProgressDonutModule.default.donutChartBackground,
|
|
63
|
-
cx:
|
|
64
|
-
cy:
|
|
87
|
+
cx: donutSize / DIVISOR_TWO,
|
|
88
|
+
cy: donutSize / DIVISOR_TWO,
|
|
65
89
|
r: radius,
|
|
66
|
-
strokeWidth:
|
|
90
|
+
strokeWidth: strokeWidth
|
|
67
91
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", {
|
|
68
92
|
className: _ProgressDonutModule.default.donutChartForeground,
|
|
69
|
-
cx:
|
|
70
|
-
cy:
|
|
93
|
+
cx: donutSize / DIVISOR_TWO,
|
|
94
|
+
cy: donutSize / DIVISOR_TWO,
|
|
71
95
|
r: radius,
|
|
72
|
-
strokeWidth:
|
|
96
|
+
strokeWidth: strokeWidth,
|
|
73
97
|
strokeDasharray: circumference,
|
|
74
98
|
strokeDashoffset: donutPercentage === MIN_PERCENTAGE ? circumference : offset,
|
|
75
99
|
stroke: COLORS[color || ''] || donutColor,
|
|
76
100
|
strokeLinecap: "round"
|
|
77
101
|
})]
|
|
78
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
79
|
-
className: _ProgressDonutModule.default.donutChartPercentage,
|
|
102
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(TextComponent, {
|
|
103
|
+
className: (0, _classify.default)(_ProgressDonutModule.default.donutChartPercentage, {
|
|
104
|
+
[_ProgressDonutModule.default.donutChartPercentageSmallPercent]: size === 'small' && rating == null
|
|
105
|
+
}),
|
|
80
106
|
testId: (0, _qa.generateTestId)({
|
|
81
107
|
base: testId,
|
|
82
108
|
slot: 'percentage'
|
|
83
109
|
}),
|
|
84
|
-
children:
|
|
110
|
+
children: displayValue
|
|
85
111
|
})]
|
|
86
112
|
})
|
|
87
113
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
borderRadiusSmall
|
|
3
3
|
) from '../../styles/variables/_border.css';
|
|
4
4
|
@value (spaceHalfFluid, spaceNegHalfFluid) from '../../styles/variables/_space.css';
|
|
5
|
+
@value (fontSize10) from '../../styles/variables/_font.css';
|
|
5
6
|
@value (size10, size20, sizeFluid) from
|
|
6
7
|
'../../styles/variables/_size.css';
|
|
7
8
|
@value (
|
|
@@ -41,3 +42,7 @@
|
|
|
41
42
|
.donutChartPercentage {
|
|
42
43
|
position: absolute;
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
.donutChartPercentageSmallPercent {
|
|
47
|
+
font-size: fontSize10;
|
|
48
|
+
}
|
package/mcp/package.json
CHANGED