@react-magma/charts 14.2.0 → 15.0.0-next.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/dist/charts.js +1625 -187
- package/dist/charts.js.map +1 -1
- package/dist/charts.modern.module.js +1627 -190
- package/dist/charts.modern.module.js.map +1 -1
- package/dist/charts.umd.js +49219 -28201
- package/dist/charts.umd.js.map +1 -1
- package/dist/components/CarbonChart/CarbonChart.d.ts +1 -1
- package/dist/components/CarbonChart/CarbonChartArea.stories.d.ts +310 -0
- package/dist/components/CarbonChart/CarbonChartAreaStacked.stories.d.ts +136 -0
- package/dist/components/CarbonChart/CarbonChartBar.stories.d.ts +232 -0
- package/dist/components/CarbonChart/CarbonChartBarFloating.stories.d.ts +82 -0
- package/dist/components/CarbonChart/CarbonChartBarGrouped.stories.d.ts +234 -0
- package/dist/components/CarbonChart/CarbonChartBarStacked.stories.d.ts +266 -0
- package/dist/components/CarbonChart/CarbonChartBoxplot.stories.d.ts +53 -0
- package/dist/components/CarbonChart/CarbonChartBubble.stories.d.ts +196 -0
- package/dist/components/CarbonChart/CarbonChartBullet.stories.d.ts +35 -0
- package/dist/components/CarbonChart/CarbonChartCombo.stories.d.ts +580 -0
- package/dist/components/CarbonChart/CarbonChartDonut.stories.d.ts +120 -0
- package/dist/components/CarbonChart/CarbonChartGauge.stories.d.ts +43 -0
- package/dist/components/CarbonChart/CarbonChartHistogram.stories.d.ts +89 -0
- package/dist/components/CarbonChart/CarbonChartLine.stories.d.ts +577 -0
- package/dist/components/CarbonChart/CarbonChartLollipop.stories.d.ts +55 -0
- package/dist/components/CarbonChart/CarbonChartMeter.stories.d.ts +127 -0
- package/dist/components/CarbonChart/CarbonChartPie.stories.d.ts +101 -0
- package/dist/components/CarbonChart/CarbonChartRadar.stories.d.ts +98 -0
- package/dist/components/CarbonChart/CarbonChartScatter.stories.d.ts +173 -0
- package/dist/components/CarbonChart/CarbonChartSparkline.stories.d.ts +51 -0
- package/dist/components/CarbonChart/CarbonChartStep.stories.d.ts +38 -0
- package/dist/components/ChartTable/ChartTable.stories.d.ts +166 -0
- package/dist/components/LineChart/Chart.d.ts +27 -0
- package/dist/components/LineChart/ChartDataTable.d.ts +17 -0
- package/dist/components/LineChart/CustomAxisComponent.d.ts +3 -0
- package/dist/components/LineChart/CustomPointComponent.d.ts +17 -0
- package/dist/components/LineChart/DataTable.d.ts +5 -0
- package/dist/components/LineChart/GraphTooltip.d.ts +3 -0
- package/dist/components/LineChart/LegendButton.d.ts +6 -0
- package/dist/components/LineChart/LineChart.d.ts +67 -0
- package/dist/components/LineChart/LineChart.stories.d.ts +113 -0
- package/dist/components/LineChart/index.d.ts +1 -0
- package/dist/components/LineChart/magma-charts.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +19 -22
- package/src/components/CarbonChart/CarbonChart.test.js +185 -164
- package/src/components/CarbonChart/CarbonChart.tsx +79 -29
- package/src/components/CarbonChart/CarbonChartArea.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartAreaStacked.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartBar.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartBarFloating.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartBarGrouped.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartBarStacked.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartBoxplot.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartBubble.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartBullet.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartCombo.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartDonut.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartGauge.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartHistogram.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartLine.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartLollipop.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartMeter.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartPie.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartRadar.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartScatter.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartSparkline.stories.tsx +5 -3
- package/src/components/CarbonChart/CarbonChartStep.stories.tsx +5 -3
- package/src/components/ChartTable/ChartDataTable.tsx +0 -3
- package/src/components/ChartTable/ChartMoreOptionsButton.tsx +0 -1
- package/src/components/ChartTable/ChartTable.test.js +0 -8
- package/src/components/ChartTable/ChartTableButton.tsx +0 -1
- package/src/components/ChartTable/ChartToolbar.tsx +0 -1
- package/src/components/ChartTable/chartToolbarI18n.ts +1 -1
- package/src/components/LineChart/Chart.tsx +241 -0
- package/src/components/LineChart/ChartDataTable.test.js +165 -0
- package/src/components/LineChart/ChartDataTable.tsx +135 -0
- package/src/components/LineChart/CustomAxisComponent.tsx +30 -0
- package/src/components/LineChart/CustomPointComponent.tsx +93 -0
- package/src/components/LineChart/DataTable.tsx +57 -0
- package/src/components/LineChart/GraphTooltip.tsx +100 -0
- package/src/components/LineChart/LegendButton.tsx +77 -0
- package/src/components/LineChart/LineChart.stories.tsx +399 -0
- package/src/components/LineChart/LineChart.test.js +501 -0
- package/src/components/LineChart/LineChart.tsx +669 -0
- package/src/components/LineChart/index.ts +1 -0
- package/src/components/LineChart/magma-charts.ts +279 -0
- package/src/components/LineChart/test/exampleChartData.js +289 -0
- package/src/hooks/useCarbonModalFocusManagement.ts +0 -12
- package/src/index.ts +1 -0
- package/dist/components/ChartTable/ChartTable.test.d.ts +0 -1
- package/src/components/ChartTable/ChartTable.test.tsx +0 -452
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { Card, Datagrid, Spinner, useForceUpdate, StyledTooltip, ThemeContext, TooltipPosition, TooltipArrow, Checkbox, I18nContext, styled as styled$1, Paragraph, TabsContainer, TabPanel, useDescendants, TypographyVisualStyle, Tabs, Tab, Tooltip, IconButton, ButtonVariant, Announce, TabPanelsContainer, Table, TableHead, TableRow, TableHeaderCell, TableBody, TableCell, Dropdown, DropdownButton, DropdownContent, ModalSize, Modal, Button, Heading, useIsInverse, useDeviceDetect, VisuallyHidden, InverseContext, DropdownMenuItem, DropdownDivider } from 'react-magma-dom';
|
|
4
|
+
import { KeyboardIcon, TableIcon, FullscreenExitIcon, FullscreenIcon, MoreVertIcon } from 'react-magma-icons';
|
|
3
5
|
import styled from '@emotion/styled';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
+
import { LineSegment, Point, VictoryChart, VictoryVoronoiContainer, VictoryTooltip, VictoryAxis, VictoryLine, VictoryScatter } from 'victory';
|
|
7
|
+
import { ComboChart, ScatterChart, MeterChart, HistogramChart, GaugeChart, BulletChart, BubbleChart, BoxplotChart, RadarChart, PieChart, LollipopChart, LineChart as LineChart$1, DonutChart, StackedBarChart, GroupedBarChart, SimpleBarChart, StackedAreaChart, AreaChart } from '@carbon/charts-react';
|
|
6
8
|
|
|
7
9
|
/******************************************************************************
|
|
8
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -44,14 +46,13 @@ function __rest(s, e) {
|
|
|
44
46
|
return t;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
49
|
+
/** @deprecated */
|
|
50
|
+
function __spreadArrays() {
|
|
51
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
52
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
53
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
54
|
+
r[k] = a[j];
|
|
55
|
+
return r;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
function __makeTemplateObject(cooked, raw) {
|
|
@@ -63,6 +64,752 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
63
64
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
64
65
|
};
|
|
65
66
|
|
|
67
|
+
function toCamelCase(str) {
|
|
68
|
+
return str
|
|
69
|
+
.toLowerCase()
|
|
70
|
+
.replace(/[^a-z 0-9]/gi, '')
|
|
71
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (ltr, index) {
|
|
72
|
+
return index === 0 ? ltr.toLowerCase() : ltr.toUpperCase();
|
|
73
|
+
})
|
|
74
|
+
.replace(/\s+/g, '');
|
|
75
|
+
}
|
|
76
|
+
var ChartDataTable$1 = function (props) {
|
|
77
|
+
var _a = props.data, data = _a === void 0 ? [] : _a, _b = props.xData, xKeyValue = _b.keyValue, xAxisLabel = _b.label, xTickFormat = _b.tickFormat, xTickValues = _b.tickValues, _c = props.yData, yKeyValue = _c.keyValue, yTickFormat = _c.tickFormat;
|
|
78
|
+
var _d = React.useState({
|
|
79
|
+
columns: [],
|
|
80
|
+
rows: [],
|
|
81
|
+
}), dataForTable = _d[0], setDataForTable = _d[1];
|
|
82
|
+
React.useEffect(function () {
|
|
83
|
+
setDataForTable(convertData());
|
|
84
|
+
}, [data]);
|
|
85
|
+
function convertData() {
|
|
86
|
+
var xField = toCamelCase((xKeyValue || xAxisLabel || 'x'));
|
|
87
|
+
var xTickValuesArray = data.reduce(function (valuesArray, _a) {
|
|
88
|
+
var dataset = _a.data;
|
|
89
|
+
dataset.forEach(function (datum) {
|
|
90
|
+
var value = datum.x || (xKeyValue && datum[xKeyValue]);
|
|
91
|
+
!valuesArray.includes(value) && valuesArray.push(value);
|
|
92
|
+
});
|
|
93
|
+
return valuesArray;
|
|
94
|
+
}, []);
|
|
95
|
+
var baseTableData = {
|
|
96
|
+
columns: xTickValuesArray.length > 0
|
|
97
|
+
? [
|
|
98
|
+
{
|
|
99
|
+
field: xField,
|
|
100
|
+
header: xAxisLabel || xKeyValue || 'X',
|
|
101
|
+
isRowHeader: true,
|
|
102
|
+
},
|
|
103
|
+
]
|
|
104
|
+
: [],
|
|
105
|
+
rows: xTickValuesArray.reduce(function (agg, tick, index) {
|
|
106
|
+
var _a;
|
|
107
|
+
var tickValue = xTickValues &&
|
|
108
|
+
typeof tick === 'number' &&
|
|
109
|
+
xTickValues.length === xTickValuesArray.length
|
|
110
|
+
? xTickFormat && typeof xTickFormat === 'function'
|
|
111
|
+
? xTickFormat(xTickValues[tick - 1])
|
|
112
|
+
: xTickValues[tick - 1]
|
|
113
|
+
: xTickFormat && Array.isArray(xTickFormat)
|
|
114
|
+
? xTickFormat[tick - 1]
|
|
115
|
+
: xTickFormat && typeof xTickFormat === 'function'
|
|
116
|
+
? xTickFormat(tick)
|
|
117
|
+
: tick;
|
|
118
|
+
agg.push((_a = {},
|
|
119
|
+
_a[xField] = tickValue,
|
|
120
|
+
_a.id = index,
|
|
121
|
+
_a));
|
|
122
|
+
return agg;
|
|
123
|
+
}, []),
|
|
124
|
+
};
|
|
125
|
+
return data.reduce(function (tableData, datum) {
|
|
126
|
+
var header = datum.name, dataset = datum.data;
|
|
127
|
+
var field = toCamelCase(header);
|
|
128
|
+
tableData.columns.push({
|
|
129
|
+
field: field,
|
|
130
|
+
header: header,
|
|
131
|
+
});
|
|
132
|
+
dataset.forEach(function (d, i) {
|
|
133
|
+
var _a;
|
|
134
|
+
var yValue = d.y !== undefined ? d.y : yKeyValue && d[yKeyValue];
|
|
135
|
+
tableData.rows[i] = __assign(__assign({}, tableData.rows[i]), (_a = { id: baseTableData.rows.length > 0 ? i + 1 : i }, _a[field] = yTickFormat && typeof yTickFormat === 'function'
|
|
136
|
+
? yTickFormat(yValue)
|
|
137
|
+
: yValue, _a));
|
|
138
|
+
});
|
|
139
|
+
return tableData;
|
|
140
|
+
}, baseTableData);
|
|
141
|
+
}
|
|
142
|
+
return (React.createElement(Card, null, dataForTable.rows.length > 0 ? (React.createElement(Datagrid, { hasPagination: false, columns: dataForTable.columns, rows: dataForTable.rows })) : (React.createElement(Spinner, null))));
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
var CustomAxisComponent = function (_a) {
|
|
146
|
+
var events = _a.events, props = __rest(_a, ["events"]);
|
|
147
|
+
return (React.createElement("g", null,
|
|
148
|
+
React.createElement(LineSegment, __assign({}, props, { events: events, style: {
|
|
149
|
+
strokeWidth: '50px',
|
|
150
|
+
stroke: 'transparent',
|
|
151
|
+
} })),
|
|
152
|
+
React.createElement(LineSegment, __assign({}, props, { events: events, style: {
|
|
153
|
+
strokeWidth: '1px',
|
|
154
|
+
stroke: 'black',
|
|
155
|
+
strokeOpacity: '0.2',
|
|
156
|
+
} }))));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
var CustomScatterDataComponent = function (props) {
|
|
160
|
+
var datum = props.datum, pointIndex = props.index, lineIndex = props.lineIndex, pointRefArray = props.pointRefArray, registerPoint = props.registerPoint, unregisterPoint = props.unregisterPoint, other = __rest(props, ["datum", "index", "lineIndex", "pointRefArray", "registerPoint", "unregisterPoint"]);
|
|
161
|
+
return (React.createElement(Point, __assign({}, other, { ariaLabel: datum.label, pathComponent: React.createElement(CustomPointComponent, { lineIndex: lineIndex, pointIndex: pointIndex, pointRefArray: pointRefArray, registerPoint: registerPoint, unregisterPoint: unregisterPoint }), role: "button", tabIndex: 0 })));
|
|
162
|
+
};
|
|
163
|
+
var CustomPointComponent = function (props) {
|
|
164
|
+
var lineIndex = props.lineIndex, pointRefArray = props.pointRefArray, pointIndex = props.pointIndex, registerPoint = props.registerPoint, unregisterPoint = props.unregisterPoint, other = __rest(props, ["lineIndex", "pointRefArray", "pointIndex", "registerPoint", "unregisterPoint"]);
|
|
165
|
+
var forceUpdate = useForceUpdate();
|
|
166
|
+
var ref = React.useRef(null);
|
|
167
|
+
React.useEffect(function () {
|
|
168
|
+
registerPoint(pointRefArray, ref);
|
|
169
|
+
forceUpdate();
|
|
170
|
+
return function () {
|
|
171
|
+
return unregisterPoint(pointRefArray, ref);
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
174
|
+
return (React.createElement("path", __assign({ ref: ref, "data-line-index": lineIndex, "data-point-index": pointIndex }, other)));
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
var StyledGraphTooltip = styled(StyledTooltip)(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n background: ", ";\n border: 1px solid ", ";\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);\n box-sizing: border-box;\n color: ", ";\n font-size: ", ";\n font-weight: normal;\n line-height: ", ";\n margin: 0;\n padding: 8px;\n width: fit-content;\n div {\n margin-bottom: 8px;\n display: flex;\n align-items: flex-start;\n &:last-of-type {\n margin-bottom: 0;\n }\n }\n"], ["\n background: ", ";\n border: 1px solid ", ";\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);\n box-sizing: border-box;\n color: ", ";\n font-size: ", ";\n font-weight: normal;\n line-height: ", ";\n margin: 0;\n padding: 8px;\n width: fit-content;\n div {\n margin-bottom: 8px;\n display: flex;\n align-items: flex-start;\n &:last-of-type {\n margin-bottom: 0;\n }\n }\n"])), function (props) { return props.theme.colors.neutral100; }, function (props) { return props.theme.colors.neutral300; }, function (props) { return props.theme.colors.neutral; }, function (props) { return props.theme.typeScale.size02.fontSize; }, function (props) { return props.theme.typeScale.size02.lineHeight; });
|
|
178
|
+
var TooltipColorSwatch = styled.span(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n background: ", ";\n border: ", ";\n border-radius: 4px;\n height: 20px;\n width: 20px;\n margin-right: 8px;\n"], ["\n background: ", ";\n border: ", ";\n border-radius: 4px;\n height: 20px;\n width: 20px;\n margin-right: 8px;\n"])), function (props) { return props.color; }, function (props) { return (props.color ? 'none' : '3px solid black'); });
|
|
179
|
+
var GraphTooltip = function (props) {
|
|
180
|
+
var datum = props.datum, index = props.index, showTooltip = props.showTooltip, x = props.x, y = props.y;
|
|
181
|
+
var theme = React.useContext(ThemeContext);
|
|
182
|
+
var linePointIndex = index + "-" + datum.index;
|
|
183
|
+
return showTooltip === linePointIndex ? (React.createElement("g", { style: { pointerEvents: 'none' } },
|
|
184
|
+
React.createElement("foreignObject", { x: x, y: y, width: "275", height: "100%" },
|
|
185
|
+
React.createElement(StyledGraphTooltip, { position: TooltipPosition.top, role: "tooltip", theme: theme },
|
|
186
|
+
React.createElement("div", null,
|
|
187
|
+
React.createElement(TooltipColorSwatch, { color: theme.iterableColors[index] }),
|
|
188
|
+
React.createElement("span", null, datum.label)),
|
|
189
|
+
React.createElement(TooltipArrow, { theme: theme }))))) : null;
|
|
190
|
+
};
|
|
191
|
+
var AxisTooltip = function (props) {
|
|
192
|
+
var x = props.x, y = props.y, activePoints = props.activePoints, hiddenData = props.hiddenData, dataLength = props.dataLength;
|
|
193
|
+
var pointsIndexes = Array.from(Array(dataLength - 0), function (_, i) { return i + 0; }).filter(function (i) { return !hiddenData.includes(i); });
|
|
194
|
+
var theme = React.useContext(ThemeContext);
|
|
195
|
+
return (React.createElement("g", { style: { pointerEvents: 'none' } },
|
|
196
|
+
React.createElement("foreignObject", { x: x, y: y, width: "275", height: "100%" },
|
|
197
|
+
React.createElement(StyledGraphTooltip, { "data-testid": "axis-tooltip", position: TooltipPosition.top, role: "tooltip", theme: theme },
|
|
198
|
+
activePoints.map(function (point, i) { return (React.createElement("div", { key: i },
|
|
199
|
+
React.createElement(TooltipColorSwatch, { color: theme.iterableColors[pointsIndexes[i]] }),
|
|
200
|
+
React.createElement("span", null, point.label))); }),
|
|
201
|
+
React.createElement(TooltipArrow, { theme: theme })))));
|
|
202
|
+
};
|
|
203
|
+
var templateObject_1$5, templateObject_2$5;
|
|
204
|
+
|
|
205
|
+
var LegendButton = React.forwardRef(function (props, ref) {
|
|
206
|
+
props.children; var color = props.color, dataIndex = props.dataIndex, isHidden = props.isHidden, onClick = props.onClick, name = props.name, focusCurrentLine = props.focusCurrentLine, resetLineFocus = props.resetLineFocus, other = __rest(props, ["children", "color", "dataIndex", "isHidden", "onClick", "name", "focusCurrentLine", "resetLineFocus"]);
|
|
207
|
+
function handleClick() {
|
|
208
|
+
onClick && typeof onClick === 'function' && onClick(dataIndex);
|
|
209
|
+
if (!isHidden) {
|
|
210
|
+
resetLineFocus &&
|
|
211
|
+
typeof resetLineFocus === 'function' &&
|
|
212
|
+
resetLineFocus();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function handleOnMouseEnterOrFocus() {
|
|
216
|
+
if (!isHidden) {
|
|
217
|
+
focusCurrentLine &&
|
|
218
|
+
typeof focusCurrentLine === 'function' &&
|
|
219
|
+
focusCurrentLine(dataIndex);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
var theme = React.useContext(ThemeContext);
|
|
223
|
+
return (React.createElement("div", { style: { display: 'inline-flex' }, onMouseEnter: handleOnMouseEnterOrFocus, onMouseLeave: resetLineFocus },
|
|
224
|
+
React.createElement(Checkbox, __assign({ checked: !isHidden, color: color, containerStyle: {
|
|
225
|
+
alignItems: 'center',
|
|
226
|
+
border: '0',
|
|
227
|
+
boxShadow: '0 0 0',
|
|
228
|
+
color: theme.colors.neutral,
|
|
229
|
+
display: 'inline-flex',
|
|
230
|
+
margin: '0 36px 20px 0',
|
|
231
|
+
padding: '0',
|
|
232
|
+
}, inputStyle: {
|
|
233
|
+
border: color ? "none" : "2px solid " + theme.colors.neutral800,
|
|
234
|
+
borderRadius: '4px',
|
|
235
|
+
}, labelText: name, onBlur: resetLineFocus, onClick: handleClick, onFocus: handleOnMouseEnterOrFocus, ref: ref, theme: theme }, other))));
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// *
|
|
239
|
+
// * Colors
|
|
240
|
+
// *
|
|
241
|
+
// const yellow200 = '#FFF59D';
|
|
242
|
+
// const deepOrange600 = '#F4511E';
|
|
243
|
+
// const lime300 = '#DCE775';
|
|
244
|
+
// const lightGreen500 = '#8BC34A';
|
|
245
|
+
// const teal700 = '#00796B';
|
|
246
|
+
// const cyan900 = '#006064';
|
|
247
|
+
// const colors = [
|
|
248
|
+
// '#0085CC',
|
|
249
|
+
// '#E0004D',
|
|
250
|
+
// '#FA6600',
|
|
251
|
+
// '#48A200',
|
|
252
|
+
// '#B12FAD',
|
|
253
|
+
// '#00A393',
|
|
254
|
+
// ];
|
|
255
|
+
var colors = [
|
|
256
|
+
'#00507A',
|
|
257
|
+
'#8F0033',
|
|
258
|
+
'#B84900',
|
|
259
|
+
'#255200',
|
|
260
|
+
'#711E6E',
|
|
261
|
+
'#005249',
|
|
262
|
+
];
|
|
263
|
+
var blueGrey50 = '#DFDFDF';
|
|
264
|
+
var blueGrey300 = '#8F8F8F';
|
|
265
|
+
var blueGrey700 = '#3F3F3F';
|
|
266
|
+
var grey900 = 'pink';
|
|
267
|
+
// *
|
|
268
|
+
// * Typography
|
|
269
|
+
// *
|
|
270
|
+
var sansSerif = '"Work Sans",Helvetica,sans-serif';
|
|
271
|
+
var letterSpacing = 'normal';
|
|
272
|
+
var fontSize = 12;
|
|
273
|
+
// *
|
|
274
|
+
// * Layout
|
|
275
|
+
// *
|
|
276
|
+
var padding = 8;
|
|
277
|
+
var baseProps = {
|
|
278
|
+
width: 350,
|
|
279
|
+
height: 350,
|
|
280
|
+
padding: 50,
|
|
281
|
+
};
|
|
282
|
+
// *
|
|
283
|
+
// * Labels
|
|
284
|
+
// *
|
|
285
|
+
var baseLabelStyles = {
|
|
286
|
+
fontFamily: sansSerif,
|
|
287
|
+
fontSize: fontSize,
|
|
288
|
+
letterSpacing: letterSpacing,
|
|
289
|
+
padding: padding,
|
|
290
|
+
fill: blueGrey700,
|
|
291
|
+
stroke: 'transparent',
|
|
292
|
+
strokeWidth: 0,
|
|
293
|
+
};
|
|
294
|
+
var centeredLabelStyles = __assign({ textAnchor: 'middle' }, baseLabelStyles);
|
|
295
|
+
// *
|
|
296
|
+
// * Strokes
|
|
297
|
+
// *
|
|
298
|
+
// const strokeDasharray = '10, 5';
|
|
299
|
+
var strokeLinecap = 'round';
|
|
300
|
+
var strokeLinejoin = 'round';
|
|
301
|
+
var magmaTheme = {
|
|
302
|
+
area: __assign({ style: {
|
|
303
|
+
data: {
|
|
304
|
+
fill: grey900,
|
|
305
|
+
},
|
|
306
|
+
labels: baseLabelStyles,
|
|
307
|
+
} }, baseProps),
|
|
308
|
+
axis: __assign({ style: {
|
|
309
|
+
axis: {
|
|
310
|
+
fill: 'transparent',
|
|
311
|
+
stroke: blueGrey300,
|
|
312
|
+
strokeWidth: 1,
|
|
313
|
+
strokeLinecap: strokeLinecap,
|
|
314
|
+
strokeLinejoin: strokeLinejoin,
|
|
315
|
+
},
|
|
316
|
+
axisLabel: __assign(__assign({}, centeredLabelStyles), { padding: padding, stroke: 'transparent' }),
|
|
317
|
+
grid: {
|
|
318
|
+
fill: 'none',
|
|
319
|
+
stroke: '#dfdfdf',
|
|
320
|
+
//strokeDasharray,
|
|
321
|
+
strokeLinecap: strokeLinecap,
|
|
322
|
+
strokeLinejoin: strokeLinejoin,
|
|
323
|
+
pointerEvents: 'painted',
|
|
324
|
+
},
|
|
325
|
+
ticks: {
|
|
326
|
+
fill: 'transparent',
|
|
327
|
+
size: 0,
|
|
328
|
+
stroke: blueGrey300,
|
|
329
|
+
strokeWidth: 0,
|
|
330
|
+
strokeLinecap: strokeLinecap,
|
|
331
|
+
strokeLinejoin: strokeLinejoin,
|
|
332
|
+
},
|
|
333
|
+
tickLabels: __assign(__assign({}, baseLabelStyles), { fill: blueGrey700 }),
|
|
334
|
+
} }, baseProps),
|
|
335
|
+
polarDependentAxis: {
|
|
336
|
+
style: {
|
|
337
|
+
ticks: {
|
|
338
|
+
fill: 'transparent',
|
|
339
|
+
size: 1,
|
|
340
|
+
stroke: 'transparent',
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
bar: __assign({ style: {
|
|
345
|
+
data: {
|
|
346
|
+
fill: blueGrey700,
|
|
347
|
+
padding: padding,
|
|
348
|
+
strokeWidth: 0,
|
|
349
|
+
},
|
|
350
|
+
labels: baseLabelStyles,
|
|
351
|
+
} }, baseProps),
|
|
352
|
+
boxplot: __assign({ style: {
|
|
353
|
+
max: { padding: padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
354
|
+
maxLabels: __assign(__assign({}, baseLabelStyles), { padding: 3 }),
|
|
355
|
+
median: { padding: padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
356
|
+
medianLabels: __assign(__assign({}, baseLabelStyles), { padding: 3 }),
|
|
357
|
+
min: { padding: padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
358
|
+
minLabels: __assign(__assign({}, baseLabelStyles), { padding: 3 }),
|
|
359
|
+
q1: { padding: padding, fill: blueGrey700 },
|
|
360
|
+
q1Labels: __assign(__assign({}, baseLabelStyles), { padding: 3 }),
|
|
361
|
+
q3: { padding: padding, fill: blueGrey700 },
|
|
362
|
+
q3Labels: __assign(__assign({}, baseLabelStyles), { padding: 3 }),
|
|
363
|
+
}, boxWidth: 20 }, baseProps),
|
|
364
|
+
candlestick: __assign({ style: {
|
|
365
|
+
data: {
|
|
366
|
+
stroke: blueGrey700,
|
|
367
|
+
},
|
|
368
|
+
labels: __assign(__assign({}, baseLabelStyles), { padding: 5 }),
|
|
369
|
+
}, candleColors: {
|
|
370
|
+
positive: '#ffffff',
|
|
371
|
+
negative: blueGrey700,
|
|
372
|
+
} }, baseProps),
|
|
373
|
+
chart: baseProps,
|
|
374
|
+
errorbar: __assign({ borderWidth: 8, style: {
|
|
375
|
+
data: {
|
|
376
|
+
fill: 'transparent',
|
|
377
|
+
opacity: 1,
|
|
378
|
+
stroke: blueGrey700,
|
|
379
|
+
strokeWidth: 2,
|
|
380
|
+
},
|
|
381
|
+
labels: baseLabelStyles,
|
|
382
|
+
} }, baseProps),
|
|
383
|
+
group: __assign({ colorScale: colors }, baseProps),
|
|
384
|
+
histogram: __assign({ style: {
|
|
385
|
+
data: {
|
|
386
|
+
fill: blueGrey700,
|
|
387
|
+
stroke: grey900,
|
|
388
|
+
strokeWidth: 2,
|
|
389
|
+
},
|
|
390
|
+
labels: baseLabelStyles,
|
|
391
|
+
} }, baseProps),
|
|
392
|
+
legend: {
|
|
393
|
+
colorScale: colors,
|
|
394
|
+
gutter: 10,
|
|
395
|
+
orientation: 'vertical',
|
|
396
|
+
titleOrientation: 'top',
|
|
397
|
+
style: {
|
|
398
|
+
data: {
|
|
399
|
+
type: 'circle',
|
|
400
|
+
},
|
|
401
|
+
labels: baseLabelStyles,
|
|
402
|
+
title: __assign(__assign({}, baseLabelStyles), { padding: 5 }),
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
line: __assign({ style: {
|
|
406
|
+
data: {
|
|
407
|
+
fill: 'transparent',
|
|
408
|
+
opacity: 1,
|
|
409
|
+
stroke: blueGrey700,
|
|
410
|
+
strokeWidth: 2,
|
|
411
|
+
},
|
|
412
|
+
labels: baseLabelStyles,
|
|
413
|
+
} }, baseProps),
|
|
414
|
+
pie: __assign({ colorScale: colors, style: {
|
|
415
|
+
data: {
|
|
416
|
+
padding: padding,
|
|
417
|
+
stroke: blueGrey50,
|
|
418
|
+
strokeWidth: 1,
|
|
419
|
+
},
|
|
420
|
+
labels: __assign(__assign({}, baseLabelStyles), { padding: 20 }),
|
|
421
|
+
} }, baseProps),
|
|
422
|
+
scatter: __assign({ style: {
|
|
423
|
+
data: {
|
|
424
|
+
fill: blueGrey700,
|
|
425
|
+
opacity: 1,
|
|
426
|
+
stroke: 'transparent',
|
|
427
|
+
strokeWidth: 0,
|
|
428
|
+
},
|
|
429
|
+
labels: baseLabelStyles,
|
|
430
|
+
} }, baseProps),
|
|
431
|
+
stack: __assign({ colorScale: colors }, baseProps),
|
|
432
|
+
tooltip: {
|
|
433
|
+
style: __assign(__assign({}, baseLabelStyles), { padding: 0, pointerEvents: 'none' }),
|
|
434
|
+
flyoutStyle: {
|
|
435
|
+
stroke: grey900,
|
|
436
|
+
strokeWidth: 1,
|
|
437
|
+
fill: '#f0f0f0',
|
|
438
|
+
pointerEvents: 'none',
|
|
439
|
+
},
|
|
440
|
+
flyoutPadding: 5,
|
|
441
|
+
cornerRadius: 5,
|
|
442
|
+
pointerLength: 10,
|
|
443
|
+
},
|
|
444
|
+
voronoi: __assign({ style: {
|
|
445
|
+
data: {
|
|
446
|
+
fill: 'transparent',
|
|
447
|
+
stroke: 'transparent',
|
|
448
|
+
strokeWidth: 0,
|
|
449
|
+
},
|
|
450
|
+
labels: __assign(__assign({}, baseLabelStyles), { padding: 5, pointerEvents: 'none' }),
|
|
451
|
+
flyout: {
|
|
452
|
+
stroke: grey900,
|
|
453
|
+
strokeWidth: 1,
|
|
454
|
+
fill: '#f0f0f0',
|
|
455
|
+
pointerEvents: 'none',
|
|
456
|
+
},
|
|
457
|
+
} }, baseProps),
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
var LineChartContainer = styled.div(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n max-height: 600px;\n max-width: 800px;\n svg {\n overflow: visible;\n }\n"], ["\n max-height: 600px;\n max-width: 800px;\n svg {\n overflow: visible;\n }\n"])));
|
|
461
|
+
var VictoryChartContainer = styled.div(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject([""], [""])));
|
|
462
|
+
var DataLegendsContainer = styled.div(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n padding-bottom: 24px;\n"], ["\n padding-bottom: 24px;\n"])));
|
|
463
|
+
var DataLegendsDescription = styled.p(templateObject_4$2 || (templateObject_4$2 = __makeTemplateObject(["\n color: ", ";\n font-size: ", ";\n"], ["\n color: ", ";\n font-size: ", ";\n"])), function (props) { return props.theme.colors.neutral; }, function (props) { return props.theme.typeScale.size02.fontSize; });
|
|
464
|
+
function LineChart(props) {
|
|
465
|
+
var _a = props.componentProps, _b = _a === void 0 ? {} : _a, _c = _b.chart, chart = _c === void 0 ? {} : _c, _d = _b.line, line = _d === void 0 ? {} : _d, _e = _b.scatter, scatter = _e === void 0 ? {} : _e, _f = _b.xAxis, _g = _f === void 0 ? { style: {} } : _f, _h = _g.style, _j = _h === void 0 ? {} : _h, _k = _j.axisLabel, xAxisLabel = _k === void 0 ? undefined : _k, _l = _j.tickLabels, xTickLabels = _l === void 0 ? undefined : _l, xRest = __rest(_j, ["axisLabel", "tickLabels"]), xAxisOther = __rest(_g, ["style"]), _m = _b.yAxis, _o = _m === void 0 ? { style: {} } : _m, _p = _o.style, _q = _p === void 0 ? {} : _p, _r = _q.axisLabel, yAxisLabel = _r === void 0 ? undefined : _r, _s = _q.tickLabels, yTickLabels = _s === void 0 ? undefined : _s, yRest = __rest(_q, ["axisLabel", "tickLabels"]), yAxisOther = __rest(_o, ["style"]), _t = props.data, data = _t === void 0 ? [] : _t, lastFocusedScatterPoint = props.lastFocusedScatterPoint, pointRefArray = props.pointRefArray, registerPoint = props.registerPoint, unregisterPoint = props.unregisterPoint, tabRef = props.tabRef, x = props.x, y = props.y;
|
|
466
|
+
var theme = React.useContext(ThemeContext);
|
|
467
|
+
var i18n = React.useContext(I18nContext);
|
|
468
|
+
var _u = React.useState([]), hiddenData = _u[0], setHiddenData = _u[1];
|
|
469
|
+
var _v = React.useState(800), width = _v[0], setWidth = _v[1];
|
|
470
|
+
var _w = React.useState(null), focusedLine = _w[0], setFocusedLine = _w[1];
|
|
471
|
+
var _x = React.useState(null), showTooltip = _x[0], setShowTooltip = _x[1];
|
|
472
|
+
var _y = React.useState(true), showXAxisLabel = _y[0], setShowXAxisLabel = _y[1];
|
|
473
|
+
var _z = React.useState(false), hoveringOnXAxisLine = _z[0], setHoveringOnXAxisLine = _z[1];
|
|
474
|
+
var containerRef = React.useRef(null);
|
|
475
|
+
var firstLegendButtonRef = React.useRef(null);
|
|
476
|
+
React.useEffect(function () {
|
|
477
|
+
updateWidth();
|
|
478
|
+
window.addEventListener('resize', updateWidth);
|
|
479
|
+
window.addEventListener('keydown', handleEsc);
|
|
480
|
+
return function () {
|
|
481
|
+
window.removeEventListener('resize', updateWidth);
|
|
482
|
+
window.removeEventListener('keydown', handleEsc);
|
|
483
|
+
};
|
|
484
|
+
}, []);
|
|
485
|
+
React.useEffect(function () {
|
|
486
|
+
window.addEventListener('mousemove', handleMouseMove);
|
|
487
|
+
return function () {
|
|
488
|
+
window.removeEventListener('mousemove', handleMouseMove);
|
|
489
|
+
};
|
|
490
|
+
}, [showTooltip]);
|
|
491
|
+
var scatterNames = data.map(function (_, i) { return "scatter-" + i; });
|
|
492
|
+
var xAxisStyles = __assign({ tickLabels: __assign({ color: '#3f3f3f', fontSize: 12 }, xTickLabels), axisLabel: __assign({ color: '#3f3f3f', padding: 44, fontSize: 14, fontWeight: 'bold' }, xAxisLabel) }, xRest);
|
|
493
|
+
var yAxisStyles = __assign({ tickLabels: __assign({ fontSize: 12 }, yTickLabels), axisLabel: __assign({ color: '#3f3f3f', padding: 64, fontSize: 14, fontWeight: 'bold' }, yAxisLabel) }, yRest);
|
|
494
|
+
function updateWidth() {
|
|
495
|
+
containerRef.current && setWidth(containerRef.current.clientWidth);
|
|
496
|
+
}
|
|
497
|
+
function handleEsc(event) {
|
|
498
|
+
if (event.key === 'Escape') {
|
|
499
|
+
setShowTooltip(null);
|
|
500
|
+
setShowXAxisLabel(false);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function handleMouseMove() {
|
|
504
|
+
!showTooltip && setShowXAxisLabel(true);
|
|
505
|
+
}
|
|
506
|
+
function setLineOpacity(index) {
|
|
507
|
+
return focusedLine === null ? 1 : focusedLine === index ? 1 : 0.1;
|
|
508
|
+
}
|
|
509
|
+
function handleLegendClick(dataIndex) {
|
|
510
|
+
if (hiddenData.includes(dataIndex)) {
|
|
511
|
+
setHiddenData(hiddenData.filter(function (item) { return item !== dataIndex; }));
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
setHiddenData(hiddenData.concat([dataIndex]));
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function focusCurrentLine(dataIndex) {
|
|
518
|
+
setFocusedLine(dataIndex);
|
|
519
|
+
}
|
|
520
|
+
function resetLineFocus() {
|
|
521
|
+
setFocusedLine(null);
|
|
522
|
+
}
|
|
523
|
+
var buildLineIndexes = function (acc, point) {
|
|
524
|
+
if (point.current) {
|
|
525
|
+
var currentLineIndex = parseInt(point.current.getAttribute('data-line-index'), 10);
|
|
526
|
+
!acc.includes(currentLineIndex) &&
|
|
527
|
+
acc.push(parseInt(point.current.getAttribute('data-line-index'), 10));
|
|
528
|
+
}
|
|
529
|
+
return acc;
|
|
530
|
+
};
|
|
531
|
+
var buildLineIndexData = function (point) {
|
|
532
|
+
var currentLineIndex = parseInt(point.current.getAttribute('data-line-index'), 10);
|
|
533
|
+
var currentPointIndex = parseInt(point.current.getAttribute('data-point-index'), 10);
|
|
534
|
+
var lineIndexes = pointRefArray.current.reduce(buildLineIndexes, []);
|
|
535
|
+
var lowestLineIndex = lineIndexes[0];
|
|
536
|
+
var highestLineIndex = lineIndexes[lineIndexes.length - 1];
|
|
537
|
+
return {
|
|
538
|
+
currentLineIndex: currentLineIndex,
|
|
539
|
+
currentPointIndex: currentPointIndex,
|
|
540
|
+
lineIndexes: lineIndexes,
|
|
541
|
+
lowestLineIndex: lowestLineIndex,
|
|
542
|
+
highestLineIndex: highestLineIndex,
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
var findPointToFocus = function (lineIndex, pointIndex) {
|
|
546
|
+
return function (point) {
|
|
547
|
+
return point.current &&
|
|
548
|
+
parseInt(point.current.getAttribute('data-line-index'), 10) ===
|
|
549
|
+
lineIndex &&
|
|
550
|
+
parseInt(point.current.getAttribute('data-point-index'), 10) ===
|
|
551
|
+
pointIndex;
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
// eslint-disable-next-line complexity
|
|
555
|
+
function handleChartContainerKeyDown(event) {
|
|
556
|
+
var _a, _b;
|
|
557
|
+
var key = event.key, shiftKey = event.shiftKey;
|
|
558
|
+
switch (key) {
|
|
559
|
+
case 'Tab': {
|
|
560
|
+
event.preventDefault();
|
|
561
|
+
lastFocusedScatterPoint.current = pointRefArray.current.find(function (point) { return point.current === document.activeElement; }).current;
|
|
562
|
+
shiftKey
|
|
563
|
+
? tabRef.current && tabRef.current.focus()
|
|
564
|
+
: firstLegendButtonRef.current &&
|
|
565
|
+
firstLegendButtonRef.current.focus();
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
case 'ArrowRight': {
|
|
569
|
+
var focusedPointIndex = pointRefArray.current.findIndex(function (point) { return point.current === document.activeElement; });
|
|
570
|
+
if (focusedPointIndex !== undefined) {
|
|
571
|
+
focusedPointIndex === pointRefArray.current.length - 1
|
|
572
|
+
? (_b = (_a = pointRefArray.current[0]) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.focus() : pointRefArray.current[focusedPointIndex + 1]
|
|
573
|
+
.current.focus();
|
|
574
|
+
}
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
case 'ArrowLeft': {
|
|
578
|
+
var focusedPointIndex = pointRefArray.current.findIndex(function (point) { return point.current === document.activeElement; });
|
|
579
|
+
if (focusedPointIndex !== undefined) {
|
|
580
|
+
focusedPointIndex === 0
|
|
581
|
+
? pointRefArray.current[pointRefArray.current.length - 1]
|
|
582
|
+
.current.focus()
|
|
583
|
+
: pointRefArray.current[focusedPointIndex - 1]
|
|
584
|
+
.current.focus();
|
|
585
|
+
}
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
case 'ArrowUp': {
|
|
589
|
+
event.preventDefault();
|
|
590
|
+
var focusedPoint = pointRefArray.current.find(function (point) { return point.current === document.activeElement; });
|
|
591
|
+
if (focusedPoint && focusedPoint.current) {
|
|
592
|
+
var _c = buildLineIndexData(focusedPoint), currentLineIndex = _c.currentLineIndex, currentPointIndex = _c.currentPointIndex, lineIndexes = _c.lineIndexes, lowestLineIndex = _c.lowestLineIndex, highestLineIndex = _c.highestLineIndex;
|
|
593
|
+
switch (currentLineIndex) {
|
|
594
|
+
case lowestLineIndex: {
|
|
595
|
+
pointRefArray.current.find(findPointToFocus(highestLineIndex, currentPointIndex)).current.focus();
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
default: {
|
|
599
|
+
var nextLowestLineIndex = lineIndexes[lineIndexes.indexOf(currentLineIndex) - 1];
|
|
600
|
+
pointRefArray.current.find(findPointToFocus(nextLowestLineIndex, currentPointIndex)).current.focus();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
case 'ArrowDown': {
|
|
607
|
+
event.preventDefault();
|
|
608
|
+
var focusedPoint = pointRefArray.current.find(function (point) { return point.current === document.activeElement; });
|
|
609
|
+
if (focusedPoint && focusedPoint.current) {
|
|
610
|
+
var _d = buildLineIndexData(focusedPoint), currentLineIndex = _d.currentLineIndex, currentPointIndex = _d.currentPointIndex, lineIndexes = _d.lineIndexes, lowestLineIndex = _d.lowestLineIndex, highestLineIndex = _d.highestLineIndex;
|
|
611
|
+
switch (currentLineIndex) {
|
|
612
|
+
case highestLineIndex: {
|
|
613
|
+
pointRefArray.current.find(findPointToFocus(lowestLineIndex, currentPointIndex)).current.focus();
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
default: {
|
|
617
|
+
var nextHighestLineIndex = lineIndexes[lineIndexes.indexOf(currentLineIndex) + 1];
|
|
618
|
+
pointRefArray.current.find(findPointToFocus(nextHighestLineIndex, currentPointIndex)).current.focus();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function handleFirstLegendButtonKeydown(event) {
|
|
627
|
+
var key = event.key, shiftKey = event.shiftKey;
|
|
628
|
+
switch (key) {
|
|
629
|
+
case 'Tab': {
|
|
630
|
+
if (shiftKey &&
|
|
631
|
+
lastFocusedScatterPoint &&
|
|
632
|
+
lastFocusedScatterPoint.current &&
|
|
633
|
+
pointRefArray.current.find(function (point) { return point.current === lastFocusedScatterPoint.current; })) {
|
|
634
|
+
event.preventDefault();
|
|
635
|
+
lastFocusedScatterPoint.current.focus();
|
|
636
|
+
}
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return (React.createElement(LineChartContainer, { ref: containerRef },
|
|
642
|
+
React.createElement(VictoryChartContainer, { onKeyDown: handleChartContainerKeyDown },
|
|
643
|
+
React.createElement(VictoryChart, __assign({ domainPadding: 32, height: 400, padding: { top: 0, left: 80, right: 0, bottom: 62 }, theme: magmaTheme, width: width, containerComponent: React.createElement(VictoryVoronoiContainer, { name: "xAxisGroupLabel", voronoiBlacklist: scatterNames, voronoiDimension: "x", labels: hoveringOnXAxisLine && showXAxisLabel ? function () { return " "; } : undefined, labelComponent: showXAxisLabel ? (React.createElement(VictoryTooltip, { flyoutComponent: React.createElement(AxisTooltip, { dataLength: data.length, hiddenData: hiddenData }) })) : undefined, role: "presentation", voronoiPadding: 32 }) }, chart),
|
|
644
|
+
React.createElement(VictoryAxis, __assign({}, yAxisOther, { dependentAxis: true, style: yAxisStyles })),
|
|
645
|
+
data.map(function (_a, i) {
|
|
646
|
+
var dataset = _a.data;
|
|
647
|
+
return !hiddenData.includes(i) && (React.createElement(VictoryLine, __assign({ style: {
|
|
648
|
+
data: {
|
|
649
|
+
opacity: setLineOpacity(i),
|
|
650
|
+
stroke: theme.iterableColors[i],
|
|
651
|
+
strokeWidth: '3',
|
|
652
|
+
},
|
|
653
|
+
parent: { border: theme.colors.neutral400 },
|
|
654
|
+
}, key: "line" + i, data: dataset, labelComponent: React.createElement(React.Fragment, null), x: x, y: y }, line)));
|
|
655
|
+
}),
|
|
656
|
+
React.createElement(VictoryAxis, __assign({}, xAxisOther, { style: xAxisStyles, gridComponent: React.createElement(CustomAxisComponent, { events: {
|
|
657
|
+
onMouseEnter: function () { return setHoveringOnXAxisLine(true); },
|
|
658
|
+
onMouseLeave: function () { return setHoveringOnXAxisLine(false); },
|
|
659
|
+
} }) })),
|
|
660
|
+
data.map(function (_a, i) {
|
|
661
|
+
var dataset = _a.data;
|
|
662
|
+
return !hiddenData.includes(i) && (React.createElement(VictoryScatter, __assign({ name: "scatter-" + i, events: [
|
|
663
|
+
{
|
|
664
|
+
target: 'data',
|
|
665
|
+
eventHandlers: {
|
|
666
|
+
onBlur: function () {
|
|
667
|
+
setShowXAxisLabel(true);
|
|
668
|
+
setShowTooltip(null);
|
|
669
|
+
return [
|
|
670
|
+
{
|
|
671
|
+
target: 'labels',
|
|
672
|
+
mutation: function () { return ({ active: undefined }); },
|
|
673
|
+
},
|
|
674
|
+
];
|
|
675
|
+
},
|
|
676
|
+
onClick: function () {
|
|
677
|
+
return [
|
|
678
|
+
{
|
|
679
|
+
target: 'labels',
|
|
680
|
+
mutation: function (props) {
|
|
681
|
+
setShowTooltip(props.datum.lineIndex + "-" + props.datum.index);
|
|
682
|
+
return { active: true };
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
];
|
|
686
|
+
},
|
|
687
|
+
onFocus: function () {
|
|
688
|
+
setShowXAxisLabel(false);
|
|
689
|
+
return [
|
|
690
|
+
{
|
|
691
|
+
target: 'labels',
|
|
692
|
+
mutation: function (props) {
|
|
693
|
+
setShowTooltip(props.datum.lineIndex + "-" + props.datum.index);
|
|
694
|
+
return { active: true };
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
];
|
|
698
|
+
},
|
|
699
|
+
onMouseEnter: function () {
|
|
700
|
+
setShowXAxisLabel(false);
|
|
701
|
+
return [
|
|
702
|
+
{
|
|
703
|
+
target: 'labels',
|
|
704
|
+
mutation: function (props) {
|
|
705
|
+
setShowTooltip(props.datum.lineIndex + "-" + props.datum.index);
|
|
706
|
+
return { active: true };
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
];
|
|
710
|
+
},
|
|
711
|
+
onMouseLeave: function () {
|
|
712
|
+
setShowTooltip(null);
|
|
713
|
+
setShowXAxisLabel(true);
|
|
714
|
+
},
|
|
715
|
+
},
|
|
716
|
+
},
|
|
717
|
+
], style: {
|
|
718
|
+
data: {
|
|
719
|
+
fill: theme.colors.neutral100,
|
|
720
|
+
opacity: setLineOpacity(i),
|
|
721
|
+
stroke: theme.iterableColors[i],
|
|
722
|
+
strokeWidth: 2,
|
|
723
|
+
},
|
|
724
|
+
}, size: 5, data: dataset.map(function (datum, index) { return (__assign({ index: index, lineIndex: i }, datum)); }), dataComponent: React.createElement(CustomScatterDataComponent, { lineIndex: i, pointRefArray: pointRefArray, registerPoint: registerPoint, unregisterPoint: unregisterPoint }), labels: function () { return ''; }, labelComponent: React.createElement(VictoryTooltip, { text: "", flyoutComponent: React.createElement(GraphTooltip, { index: i, showTooltip: showTooltip }) }), key: "scatter" + i, x: x, y: y }, scatter)));
|
|
725
|
+
}))),
|
|
726
|
+
React.createElement(DataLegendsContainer, null,
|
|
727
|
+
React.createElement(DataLegendsDescription, { theme: theme }, i18n.charts.line.dataLegendsLabel),
|
|
728
|
+
data.map(function (_a, i) {
|
|
729
|
+
var name = _a.name;
|
|
730
|
+
var legendButtonAriaLabel = i18n.charts.line.legendButtonAriaLabel.replace(/\{name\}/g, name);
|
|
731
|
+
return (React.createElement(LegendButton, { "aria-label": legendButtonAriaLabel, color: theme.iterableColors[i], dataIndex: i, isHidden: hiddenData.includes(i), key: name, name: name, onClick: handleLegendClick, onKeyDown: i === 0 ? handleFirstLegendButtonKeydown : undefined, focusCurrentLine: focusCurrentLine, ref: i === 0 ? firstLegendButtonRef : undefined, resetLineFocus: resetLineFocus }));
|
|
732
|
+
}))));
|
|
733
|
+
}
|
|
734
|
+
var templateObject_1$4, templateObject_2$4, templateObject_3$3, templateObject_4$2;
|
|
735
|
+
|
|
736
|
+
var StyledTitle = styled$1.span(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n color: ", ";\n font-size: ", ";\n font-weight: 600;\n font-family: ", ";\n line-height: ", ";\n margin: 0 0 12px 0;\n"], ["\n color: ", ";\n font-size: ", ";\n font-weight: 600;\n font-family: ", ";\n line-height: ", ";\n margin: 0 0 12px 0;\n"])), function (props) { return props.theme.colors.neutral; }, function (props) { return props.theme.typeScale.size04.fontSize; }, function (props) { return props.theme.bodyFont; }, function (props) { return props.theme.typeScale.size04.lineHeight; });
|
|
737
|
+
var StyledParagraph = styled$1(Paragraph)(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n font-size: ", ";\n margin: 0 0 18px 0;\n"], ["\n font-size: ", ";\n margin: 0 0 18px 0;\n"])), function (props) { return props.theme.typeScale.size02.fontSize; });
|
|
738
|
+
var StyledTabsContainer = styled$1(TabsContainer)(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n width: 800px;\n ul {\n box-shadow: inset 0 -1px 0 ", ";\n }\n"], ["\n width: 800px;\n ul {\n box-shadow: inset 0 -1px 0 ", ";\n }\n"])), function (props) { return props.theme.colors.neutral300; });
|
|
739
|
+
var StyledTabPanel = styled$1(TabPanel)(templateObject_4$1 || (templateObject_4$1 = __makeTemplateObject(["\n padding: 22px 0;\n"], ["\n padding: 22px 0;\n"])));
|
|
740
|
+
var KeyboardInstructionsCard = styled$1(Card)(templateObject_6$1 || (templateObject_6$1 = __makeTemplateObject(["\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);\n display: ", ";\n right: ", ";\n max-height: ", ";\n opacity: ", ";\n outline: 0;\n overflow-y: auto;\n padding: ", "\n ", ";\n position: absolute;\n transition: opacity 0.3s;\n white-space: nowrap;\n z-index: 2;\n\n ", "\n"], ["\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);\n display: ", ";\n right: ", ";\n max-height: ",
|
|
741
|
+
";\n opacity: ", ";\n outline: 0;\n overflow-y: auto;\n padding: ", "\n ", ";\n position: absolute;\n transition: opacity 0.3s;\n white-space: nowrap;\n z-index: 2;\n\n ",
|
|
742
|
+
"\n"])), function (props) { return (props.isOpen ? 'block' : 'none'); }, function (props) { return props.theme.spaceScale.spacing02; }, function (props) {
|
|
743
|
+
return props.maxHeight ? props.maxHeight : props.theme.dropdown.content.maxHeight;
|
|
744
|
+
}, function (props) { return (props.isOpen ? '1' : '0'); }, function (props) { return props.theme.spaceScale.spacing05; }, function (props) { return props.theme.spaceScale.spacing05; }, function (props) {
|
|
745
|
+
return props.width && css(templateObject_5$1 || (templateObject_5$1 = __makeTemplateObject(["\n white-space: normal;\n width: ", ";\n "], ["\n white-space: normal;\n width: ", ";\n "])), props.width);
|
|
746
|
+
});
|
|
747
|
+
function BaseChart(props, ref) {
|
|
748
|
+
var _a, _b, _c, _d, _e, _f;
|
|
749
|
+
var description = props.description, title = props.title; props.testId; var type = props.type, other = __rest(props, ["description", "title", "testId", "type"]);
|
|
750
|
+
var keyboardInstructionsRef = React.useRef(null);
|
|
751
|
+
var lastFocusedScatterPoint = React.useRef(null);
|
|
752
|
+
var theme = React.useContext(ThemeContext);
|
|
753
|
+
var i18n = React.useContext(I18nContext);
|
|
754
|
+
var _g = useDescendants(), pointRefArray = _g[0], registerPoint = _g[1], unregisterPoint = _g[2];
|
|
755
|
+
var _h = React.useState(false), isKeyboardInstructionsOpen = _h[0], setIsKeyboardInstructionsOpen = _h[1];
|
|
756
|
+
function handleKeyboardInstructionsButtonBlur() {
|
|
757
|
+
setIsKeyboardInstructionsOpen(false);
|
|
758
|
+
}
|
|
759
|
+
function handleKeyboardInstructionsButtonClick() {
|
|
760
|
+
setIsKeyboardInstructionsOpen(function (prevOpen) { return !prevOpen; });
|
|
761
|
+
}
|
|
762
|
+
function handleKeyboardInstructionsButtonKeydown(event) {
|
|
763
|
+
var key = event.key, shiftKey = event.shiftKey;
|
|
764
|
+
switch (key) {
|
|
765
|
+
case 'Escape': {
|
|
766
|
+
setIsKeyboardInstructionsOpen(false);
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
case 'Tab': {
|
|
770
|
+
if (!shiftKey &&
|
|
771
|
+
lastFocusedScatterPoint &&
|
|
772
|
+
lastFocusedScatterPoint.current &&
|
|
773
|
+
pointRefArray.current.find(function (point) { return point.current === lastFocusedScatterPoint.current; })) {
|
|
774
|
+
event.preventDefault();
|
|
775
|
+
lastFocusedScatterPoint.current.focus();
|
|
776
|
+
}
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return (React.createElement("div", { ref: ref },
|
|
782
|
+
React.createElement(StyledTitle, { theme: theme }, title),
|
|
783
|
+
description && (React.createElement(StyledParagraph, { theme: theme, visualStyle: TypographyVisualStyle.bodySmall }, description)),
|
|
784
|
+
React.createElement(StyledTabsContainer, { theme: theme },
|
|
785
|
+
React.createElement(Tabs, null,
|
|
786
|
+
React.createElement(Tab, null, i18n.charts.line.chartTabLabel),
|
|
787
|
+
React.createElement(Tab, null, i18n.charts.line.dataTabLabel),
|
|
788
|
+
React.createElement("div", { onBlur: handleKeyboardInstructionsButtonBlur, style: {
|
|
789
|
+
display: 'inline-block',
|
|
790
|
+
marginLeft: 'auto',
|
|
791
|
+
} },
|
|
792
|
+
React.createElement(Tooltip, { content: i18n.charts.line.keyboardInstructionsTooltip, ref: keyboardInstructionsRef },
|
|
793
|
+
React.createElement(IconButton, { "aria-controls": "keyboardInstructions", "aria-label": i18n.charts.line.keyboardInstructionsTooltip, "aria-expanded": Boolean(isKeyboardInstructionsOpen), icon: React.createElement(KeyboardIcon, null), onClick: handleKeyboardInstructionsButtonClick, onKeyDown: handleKeyboardInstructionsButtonKeydown, variant: ButtonVariant.link })),
|
|
794
|
+
React.createElement(Announce, null,
|
|
795
|
+
React.createElement(KeyboardInstructionsCard, { id: "keyboardInstructions", isOpen: isKeyboardInstructionsOpen, theme: theme, width: "350px" },
|
|
796
|
+
React.createElement(Paragraph, { visualStyle: TypographyVisualStyle.headingXSmall, style: { margin: '0 0 16px' } }, i18n.charts.line.keyboardInstructionsHeader),
|
|
797
|
+
i18n.charts.line.keyboardInstructions)))),
|
|
798
|
+
React.createElement(TabPanelsContainer, null,
|
|
799
|
+
React.createElement(StyledTabPanel, { theme: theme }, type === 'line' && (React.createElement(LineChart, __assign({}, other, { lastFocusedScatterPoint: lastFocusedScatterPoint, pointRefArray: pointRefArray, registerPoint: registerPoint, tabRef: keyboardInstructionsRef, unregisterPoint: unregisterPoint })))),
|
|
800
|
+
React.createElement(StyledTabPanel, { theme: theme },
|
|
801
|
+
React.createElement(ChartDataTable$1, { data: other.data, xData: {
|
|
802
|
+
keyValue: other.x,
|
|
803
|
+
label: (_b = (_a = other.componentProps) === null || _a === void 0 ? void 0 : _a.xAxis) === null || _b === void 0 ? void 0 : _b.label,
|
|
804
|
+
tickFormat: (_d = (_c = other.componentProps) === null || _c === void 0 ? void 0 : _c.xAxis) === null || _d === void 0 ? void 0 : _d.tickFormat,
|
|
805
|
+
}, yData: {
|
|
806
|
+
keyValue: other.y,
|
|
807
|
+
tickFormat: (_f = (_e = other.componentProps) === null || _e === void 0 ? void 0 : _e.yAxis) === null || _f === void 0 ? void 0 : _f.tickFormat,
|
|
808
|
+
} }))))));
|
|
809
|
+
}
|
|
810
|
+
var Chart = React.forwardRef(BaseChart);
|
|
811
|
+
var templateObject_1$3, templateObject_2$3, templateObject_3$2, templateObject_4$1, templateObject_5$1, templateObject_6$1;
|
|
812
|
+
|
|
66
813
|
function _extends() {
|
|
67
814
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
68
815
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -143,7 +890,6 @@ function _wrapNativeSuper(t) {
|
|
|
143
890
|
}
|
|
144
891
|
|
|
145
892
|
// based on https://github.com/styled-components/styled-components/blob/fcf6f3804c57a14dd7984dfab7bc06ee2edca044/src/utils/error.js
|
|
146
|
-
|
|
147
893
|
/**
|
|
148
894
|
* Parse errors.md and turn it into a simple hash of code: message
|
|
149
895
|
* @private
|
|
@@ -222,87 +968,77 @@ var ERRORS = {
|
|
|
222
968
|
"71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
223
969
|
"72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
224
970
|
"73": "Please provide a valid CSS variable.\n\n",
|
|
225
|
-
"74": "CSS variable not found.\n\n",
|
|
226
|
-
"75": "
|
|
971
|
+
"74": "CSS variable not found and no default was provided.\n\n",
|
|
972
|
+
"75": "important requires a valid style object, got a %s instead.\n\n",
|
|
973
|
+
"76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
|
|
974
|
+
"77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
|
|
975
|
+
"78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
|
|
227
976
|
};
|
|
977
|
+
|
|
228
978
|
/**
|
|
229
979
|
* super basic version of sprintf
|
|
230
980
|
* @private
|
|
231
981
|
*/
|
|
232
|
-
|
|
233
982
|
function format() {
|
|
234
983
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
235
984
|
args[_key] = arguments[_key];
|
|
236
985
|
}
|
|
237
|
-
|
|
238
986
|
var a = args[0];
|
|
239
987
|
var b = [];
|
|
240
988
|
var c;
|
|
241
|
-
|
|
242
989
|
for (c = 1; c < args.length; c += 1) {
|
|
243
990
|
b.push(args[c]);
|
|
244
991
|
}
|
|
245
|
-
|
|
246
992
|
b.forEach(function (d) {
|
|
247
993
|
a = a.replace(/%[a-z]/, d);
|
|
248
994
|
});
|
|
249
995
|
return a;
|
|
250
996
|
}
|
|
997
|
+
|
|
251
998
|
/**
|
|
252
999
|
* Create an error file out of errors.md for development and a simple web link to the full errors
|
|
253
1000
|
* in production mode.
|
|
254
1001
|
* @private
|
|
255
1002
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
1003
|
var PolishedError = /*#__PURE__*/function (_Error) {
|
|
259
1004
|
_inheritsLoose(PolishedError, _Error);
|
|
260
|
-
|
|
261
1005
|
function PolishedError(code) {
|
|
262
1006
|
var _this;
|
|
263
|
-
|
|
264
1007
|
if (process.env.NODE_ENV === 'production') {
|
|
265
1008
|
_this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
|
266
1009
|
} else {
|
|
267
1010
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
268
1011
|
args[_key2 - 1] = arguments[_key2];
|
|
269
1012
|
}
|
|
270
|
-
|
|
271
1013
|
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
272
1014
|
}
|
|
273
|
-
|
|
274
1015
|
return _assertThisInitialized(_this);
|
|
275
1016
|
}
|
|
276
|
-
|
|
277
1017
|
return PolishedError;
|
|
278
1018
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
279
1019
|
|
|
280
1020
|
function colorToInt(color) {
|
|
281
1021
|
return Math.round(color * 255);
|
|
282
1022
|
}
|
|
283
|
-
|
|
284
1023
|
function convertToInt(red, green, blue) {
|
|
285
1024
|
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
286
1025
|
}
|
|
287
|
-
|
|
288
1026
|
function hslToRgb(hue, saturation, lightness, convert) {
|
|
289
1027
|
if (convert === void 0) {
|
|
290
1028
|
convert = convertToInt;
|
|
291
1029
|
}
|
|
292
|
-
|
|
293
1030
|
if (saturation === 0) {
|
|
294
1031
|
// achromatic
|
|
295
1032
|
return convert(lightness, lightness, lightness);
|
|
296
|
-
}
|
|
297
|
-
|
|
1033
|
+
}
|
|
298
1034
|
|
|
1035
|
+
// formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
299
1036
|
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
300
1037
|
var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
301
1038
|
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
302
1039
|
var red = 0;
|
|
303
1040
|
var green = 0;
|
|
304
1041
|
var blue = 0;
|
|
305
|
-
|
|
306
1042
|
if (huePrime >= 0 && huePrime < 1) {
|
|
307
1043
|
red = chroma;
|
|
308
1044
|
green = secondComponent;
|
|
@@ -322,7 +1058,6 @@ function hslToRgb(hue, saturation, lightness, convert) {
|
|
|
322
1058
|
red = chroma;
|
|
323
1059
|
blue = secondComponent;
|
|
324
1060
|
}
|
|
325
|
-
|
|
326
1061
|
var lightnessModification = lightness - chroma / 2;
|
|
327
1062
|
var finalRed = red + lightnessModification;
|
|
328
1063
|
var finalGreen = green + lightnessModification;
|
|
@@ -480,11 +1215,11 @@ var namedColorMap = {
|
|
|
480
1215
|
yellow: 'ff0',
|
|
481
1216
|
yellowgreen: '9acd32'
|
|
482
1217
|
};
|
|
1218
|
+
|
|
483
1219
|
/**
|
|
484
1220
|
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
485
1221
|
* @private
|
|
486
1222
|
*/
|
|
487
|
-
|
|
488
1223
|
function nameToHex(color) {
|
|
489
1224
|
if (typeof color !== 'string') return color;
|
|
490
1225
|
var normalizedColorName = color.toLowerCase();
|
|
@@ -495,10 +1230,11 @@ var hexRegex = /^#[a-fA-F0-9]{6}$/;
|
|
|
495
1230
|
var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
|
496
1231
|
var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
|
497
1232
|
var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
|
498
|
-
var rgbRegex = /^rgb\(\s*(\d{1,3})\s
|
|
499
|
-
var rgbaRegex = /^
|
|
500
|
-
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s
|
|
501
|
-
var hslaRegex = /^
|
|
1233
|
+
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
|
|
1234
|
+
var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
1235
|
+
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
|
1236
|
+
var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
1237
|
+
|
|
502
1238
|
/**
|
|
503
1239
|
* Returns an RgbColor or RgbaColor object. This utility function is only useful
|
|
504
1240
|
* if want to extract a color component. With the color util `toColorString` you
|
|
@@ -510,14 +1246,11 @@ var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*
|
|
|
510
1246
|
* // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
|
|
511
1247
|
* const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
|
|
512
1248
|
*/
|
|
513
|
-
|
|
514
1249
|
function parseToRgb(color) {
|
|
515
1250
|
if (typeof color !== 'string') {
|
|
516
1251
|
throw new PolishedError(3);
|
|
517
1252
|
}
|
|
518
|
-
|
|
519
1253
|
var normalizedColor = nameToHex(color);
|
|
520
|
-
|
|
521
1254
|
if (normalizedColor.match(hexRegex)) {
|
|
522
1255
|
return {
|
|
523
1256
|
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
@@ -525,7 +1258,6 @@ function parseToRgb(color) {
|
|
|
525
1258
|
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
|
526
1259
|
};
|
|
527
1260
|
}
|
|
528
|
-
|
|
529
1261
|
if (normalizedColor.match(hexRgbaRegex)) {
|
|
530
1262
|
var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
|
531
1263
|
return {
|
|
@@ -535,7 +1267,6 @@ function parseToRgb(color) {
|
|
|
535
1267
|
alpha: alpha
|
|
536
1268
|
};
|
|
537
1269
|
}
|
|
538
|
-
|
|
539
1270
|
if (normalizedColor.match(reducedHexRegex)) {
|
|
540
1271
|
return {
|
|
541
1272
|
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
@@ -543,10 +1274,8 @@ function parseToRgb(color) {
|
|
|
543
1274
|
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
|
544
1275
|
};
|
|
545
1276
|
}
|
|
546
|
-
|
|
547
1277
|
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
548
1278
|
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
549
|
-
|
|
550
1279
|
return {
|
|
551
1280
|
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
552
1281
|
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
@@ -554,9 +1283,7 @@ function parseToRgb(color) {
|
|
|
554
1283
|
alpha: _alpha
|
|
555
1284
|
};
|
|
556
1285
|
}
|
|
557
|
-
|
|
558
1286
|
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
559
|
-
|
|
560
1287
|
if (rgbMatched) {
|
|
561
1288
|
return {
|
|
562
1289
|
red: parseInt("" + rgbMatched[1], 10),
|
|
@@ -564,179 +1291,796 @@ function parseToRgb(color) {
|
|
|
564
1291
|
blue: parseInt("" + rgbMatched[3], 10)
|
|
565
1292
|
};
|
|
566
1293
|
}
|
|
567
|
-
|
|
568
1294
|
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
569
|
-
|
|
570
1295
|
if (rgbaMatched) {
|
|
571
1296
|
return {
|
|
572
1297
|
red: parseInt("" + rgbaMatched[1], 10),
|
|
573
1298
|
green: parseInt("" + rgbaMatched[2], 10),
|
|
574
1299
|
blue: parseInt("" + rgbaMatched[3], 10),
|
|
575
|
-
alpha: parseFloat("" + rgbaMatched[4])
|
|
1300
|
+
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
|
|
576
1301
|
};
|
|
577
1302
|
}
|
|
578
|
-
|
|
579
1303
|
var hslMatched = hslRegex.exec(normalizedColor);
|
|
580
|
-
|
|
581
1304
|
if (hslMatched) {
|
|
582
1305
|
var hue = parseInt("" + hslMatched[1], 10);
|
|
583
1306
|
var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
|
584
1307
|
var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
|
585
1308
|
var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
|
|
586
1309
|
var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
|
587
|
-
|
|
588
1310
|
if (!hslRgbMatched) {
|
|
589
1311
|
throw new PolishedError(4, normalizedColor, rgbColorString);
|
|
590
1312
|
}
|
|
591
|
-
|
|
592
1313
|
return {
|
|
593
1314
|
red: parseInt("" + hslRgbMatched[1], 10),
|
|
594
1315
|
green: parseInt("" + hslRgbMatched[2], 10),
|
|
595
1316
|
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
596
1317
|
};
|
|
597
1318
|
}
|
|
598
|
-
|
|
599
1319
|
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
600
|
-
|
|
601
1320
|
if (hslaMatched) {
|
|
602
1321
|
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
603
|
-
|
|
604
1322
|
var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
|
605
|
-
|
|
606
1323
|
var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
|
1324
|
+
var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
|
1325
|
+
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
1326
|
+
if (!_hslRgbMatched) {
|
|
1327
|
+
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
1328
|
+
}
|
|
1329
|
+
return {
|
|
1330
|
+
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
1331
|
+
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
1332
|
+
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
1333
|
+
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
throw new PolishedError(5);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
function rgbToHsl(color) {
|
|
1340
|
+
// make sure rgb are contained in a set of [0, 255]
|
|
1341
|
+
var red = color.red / 255;
|
|
1342
|
+
var green = color.green / 255;
|
|
1343
|
+
var blue = color.blue / 255;
|
|
1344
|
+
var max = Math.max(red, green, blue);
|
|
1345
|
+
var min = Math.min(red, green, blue);
|
|
1346
|
+
var lightness = (max + min) / 2;
|
|
1347
|
+
if (max === min) {
|
|
1348
|
+
// achromatic
|
|
1349
|
+
if (color.alpha !== undefined) {
|
|
1350
|
+
return {
|
|
1351
|
+
hue: 0,
|
|
1352
|
+
saturation: 0,
|
|
1353
|
+
lightness: lightness,
|
|
1354
|
+
alpha: color.alpha
|
|
1355
|
+
};
|
|
1356
|
+
} else {
|
|
1357
|
+
return {
|
|
1358
|
+
hue: 0,
|
|
1359
|
+
saturation: 0,
|
|
1360
|
+
lightness: lightness
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
var hue;
|
|
1365
|
+
var delta = max - min;
|
|
1366
|
+
var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
1367
|
+
switch (max) {
|
|
1368
|
+
case red:
|
|
1369
|
+
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
|
1370
|
+
break;
|
|
1371
|
+
case green:
|
|
1372
|
+
hue = (blue - red) / delta + 2;
|
|
1373
|
+
break;
|
|
1374
|
+
default:
|
|
1375
|
+
// blue case
|
|
1376
|
+
hue = (red - green) / delta + 4;
|
|
1377
|
+
break;
|
|
1378
|
+
}
|
|
1379
|
+
hue *= 60;
|
|
1380
|
+
if (color.alpha !== undefined) {
|
|
1381
|
+
return {
|
|
1382
|
+
hue: hue,
|
|
1383
|
+
saturation: saturation,
|
|
1384
|
+
lightness: lightness,
|
|
1385
|
+
alpha: color.alpha
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
return {
|
|
1389
|
+
hue: hue,
|
|
1390
|
+
saturation: saturation,
|
|
1391
|
+
lightness: lightness
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* Returns an HslColor or HslaColor object. This utility function is only useful
|
|
1397
|
+
* if want to extract a color component. With the color util `toColorString` you
|
|
1398
|
+
* can convert a HslColor or HslaColor object back to a string.
|
|
1399
|
+
*
|
|
1400
|
+
* @example
|
|
1401
|
+
* // Assigns `{ hue: 0, saturation: 1, lightness: 0.5 }` to color1
|
|
1402
|
+
* const color1 = parseToHsl('rgb(255, 0, 0)');
|
|
1403
|
+
* // Assigns `{ hue: 128, saturation: 1, lightness: 0.5, alpha: 0.75 }` to color2
|
|
1404
|
+
* const color2 = parseToHsl('hsla(128, 100%, 50%, 0.75)');
|
|
1405
|
+
*/
|
|
1406
|
+
function parseToHsl(color) {
|
|
1407
|
+
// Note: At a later stage we can optimize this function as right now a hsl
|
|
1408
|
+
// color would be parsed converted to rgb values and converted back to hsl.
|
|
1409
|
+
return rgbToHsl(parseToRgb(color));
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Reduces hex values if possible e.g. #ff8866 to #f86
|
|
1414
|
+
* @private
|
|
1415
|
+
*/
|
|
1416
|
+
var reduceHexValue = function reduceHexValue(value) {
|
|
1417
|
+
if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
1418
|
+
return "#" + value[1] + value[3] + value[5];
|
|
1419
|
+
}
|
|
1420
|
+
return value;
|
|
1421
|
+
};
|
|
1422
|
+
var reduceHexValue$1 = reduceHexValue;
|
|
1423
|
+
|
|
1424
|
+
function numberToHex(value) {
|
|
1425
|
+
var hex = value.toString(16);
|
|
1426
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
function colorToHex(color) {
|
|
1430
|
+
return numberToHex(Math.round(color * 255));
|
|
1431
|
+
}
|
|
1432
|
+
function convertToHex(red, green, blue) {
|
|
1433
|
+
return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
|
1434
|
+
}
|
|
1435
|
+
function hslToHex(hue, saturation, lightness) {
|
|
1436
|
+
return hslToRgb(hue, saturation, lightness, convertToHex);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
1441
|
+
*
|
|
1442
|
+
* @example
|
|
1443
|
+
* // Styles as object usage
|
|
1444
|
+
* const styles = {
|
|
1445
|
+
* background: hsl(359, 0.75, 0.4),
|
|
1446
|
+
* background: hsl({ hue: 360, saturation: 0.75, lightness: 0.4 }),
|
|
1447
|
+
* }
|
|
1448
|
+
*
|
|
1449
|
+
* // styled-components usage
|
|
1450
|
+
* const div = styled.div`
|
|
1451
|
+
* background: ${hsl(359, 0.75, 0.4)};
|
|
1452
|
+
* background: ${hsl({ hue: 360, saturation: 0.75, lightness: 0.4 })};
|
|
1453
|
+
* `
|
|
1454
|
+
*
|
|
1455
|
+
* // CSS in JS Output
|
|
1456
|
+
*
|
|
1457
|
+
* element {
|
|
1458
|
+
* background: "#b3191c";
|
|
1459
|
+
* background: "#b3191c";
|
|
1460
|
+
* }
|
|
1461
|
+
*/
|
|
1462
|
+
function hsl(value, saturation, lightness) {
|
|
1463
|
+
if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
|
|
1464
|
+
return hslToHex(value.hue, value.saturation, value.lightness);
|
|
1465
|
+
}
|
|
1466
|
+
throw new PolishedError(1);
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
1471
|
+
*
|
|
1472
|
+
* @example
|
|
1473
|
+
* // Styles as object usage
|
|
1474
|
+
* const styles = {
|
|
1475
|
+
* background: hsla(359, 0.75, 0.4, 0.7),
|
|
1476
|
+
* background: hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 }),
|
|
1477
|
+
* background: hsla(359, 0.75, 0.4, 1),
|
|
1478
|
+
* }
|
|
1479
|
+
*
|
|
1480
|
+
* // styled-components usage
|
|
1481
|
+
* const div = styled.div`
|
|
1482
|
+
* background: ${hsla(359, 0.75, 0.4, 0.7)};
|
|
1483
|
+
* background: ${hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 })};
|
|
1484
|
+
* background: ${hsla(359, 0.75, 0.4, 1)};
|
|
1485
|
+
* `
|
|
1486
|
+
*
|
|
1487
|
+
* // CSS in JS Output
|
|
1488
|
+
*
|
|
1489
|
+
* element {
|
|
1490
|
+
* background: "rgba(179,25,28,0.7)";
|
|
1491
|
+
* background: "rgba(179,25,28,0.7)";
|
|
1492
|
+
* background: "#b3191c";
|
|
1493
|
+
* }
|
|
1494
|
+
*/
|
|
1495
|
+
function hsla(value, saturation, lightness, alpha) {
|
|
1496
|
+
if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
|
|
1497
|
+
return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
|
1498
|
+
}
|
|
1499
|
+
throw new PolishedError(2);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
1504
|
+
*
|
|
1505
|
+
* @example
|
|
1506
|
+
* // Styles as object usage
|
|
1507
|
+
* const styles = {
|
|
1508
|
+
* background: rgb(255, 205, 100),
|
|
1509
|
+
* background: rgb({ red: 255, green: 205, blue: 100 }),
|
|
1510
|
+
* }
|
|
1511
|
+
*
|
|
1512
|
+
* // styled-components usage
|
|
1513
|
+
* const div = styled.div`
|
|
1514
|
+
* background: ${rgb(255, 205, 100)};
|
|
1515
|
+
* background: ${rgb({ red: 255, green: 205, blue: 100 })};
|
|
1516
|
+
* `
|
|
1517
|
+
*
|
|
1518
|
+
* // CSS in JS Output
|
|
1519
|
+
*
|
|
1520
|
+
* element {
|
|
1521
|
+
* background: "#ffcd64";
|
|
1522
|
+
* background: "#ffcd64";
|
|
1523
|
+
* }
|
|
1524
|
+
*/
|
|
1525
|
+
function rgb(value, green, blue) {
|
|
1526
|
+
if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
|
|
1527
|
+
return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
1528
|
+
} else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
|
1529
|
+
return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
1530
|
+
}
|
|
1531
|
+
throw new PolishedError(6);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
/**
|
|
1535
|
+
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
1536
|
+
*
|
|
1537
|
+
* Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
|
|
1538
|
+
*
|
|
1539
|
+
* @example
|
|
1540
|
+
* // Styles as object usage
|
|
1541
|
+
* const styles = {
|
|
1542
|
+
* background: rgba(255, 205, 100, 0.7),
|
|
1543
|
+
* background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
|
|
1544
|
+
* background: rgba(255, 205, 100, 1),
|
|
1545
|
+
* background: rgba('#ffffff', 0.4),
|
|
1546
|
+
* background: rgba('black', 0.7),
|
|
1547
|
+
* }
|
|
1548
|
+
*
|
|
1549
|
+
* // styled-components usage
|
|
1550
|
+
* const div = styled.div`
|
|
1551
|
+
* background: ${rgba(255, 205, 100, 0.7)};
|
|
1552
|
+
* background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
|
|
1553
|
+
* background: ${rgba(255, 205, 100, 1)};
|
|
1554
|
+
* background: ${rgba('#ffffff', 0.4)};
|
|
1555
|
+
* background: ${rgba('black', 0.7)};
|
|
1556
|
+
* `
|
|
1557
|
+
*
|
|
1558
|
+
* // CSS in JS Output
|
|
1559
|
+
*
|
|
1560
|
+
* element {
|
|
1561
|
+
* background: "rgba(255,205,100,0.7)";
|
|
1562
|
+
* background: "rgba(255,205,100,0.7)";
|
|
1563
|
+
* background: "#ffcd64";
|
|
1564
|
+
* background: "rgba(255,255,255,0.4)";
|
|
1565
|
+
* background: "rgba(0,0,0,0.7)";
|
|
1566
|
+
* }
|
|
1567
|
+
*/
|
|
1568
|
+
function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
|
1569
|
+
if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
1570
|
+
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
1571
|
+
}
|
|
1572
|
+
throw new PolishedError(7);
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
var isRgb = function isRgb(color) {
|
|
1576
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
1577
|
+
};
|
|
1578
|
+
var isRgba = function isRgba(color) {
|
|
1579
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
|
|
1580
|
+
};
|
|
1581
|
+
var isHsl = function isHsl(color) {
|
|
1582
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
1583
|
+
};
|
|
1584
|
+
var isHsla = function isHsla(color) {
|
|
1585
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Converts a RgbColor, RgbaColor, HslColor or HslaColor object to a color string.
|
|
1590
|
+
* This util is useful in case you only know on runtime which color object is
|
|
1591
|
+
* used. Otherwise we recommend to rely on `rgb`, `rgba`, `hsl` or `hsla`.
|
|
1592
|
+
*
|
|
1593
|
+
* @example
|
|
1594
|
+
* // Styles as object usage
|
|
1595
|
+
* const styles = {
|
|
1596
|
+
* background: toColorString({ red: 255, green: 205, blue: 100 }),
|
|
1597
|
+
* background: toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
|
|
1598
|
+
* background: toColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
|
|
1599
|
+
* background: toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
|
|
1600
|
+
* }
|
|
1601
|
+
*
|
|
1602
|
+
* // styled-components usage
|
|
1603
|
+
* const div = styled.div`
|
|
1604
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100 })};
|
|
1605
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
|
|
1606
|
+
* background: ${toColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
|
|
1607
|
+
* background: ${toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
|
|
1608
|
+
* `
|
|
1609
|
+
*
|
|
1610
|
+
* // CSS in JS Output
|
|
1611
|
+
* element {
|
|
1612
|
+
* background: "#ffcd64";
|
|
1613
|
+
* background: "rgba(255,205,100,0.72)";
|
|
1614
|
+
* background: "#00f";
|
|
1615
|
+
* background: "rgba(179,25,25,0.72)";
|
|
1616
|
+
* }
|
|
1617
|
+
*/
|
|
1618
|
+
|
|
1619
|
+
function toColorString(color) {
|
|
1620
|
+
if (typeof color !== 'object') throw new PolishedError(8);
|
|
1621
|
+
if (isRgba(color)) return rgba(color);
|
|
1622
|
+
if (isRgb(color)) return rgb(color);
|
|
1623
|
+
if (isHsla(color)) return hsla(color);
|
|
1624
|
+
if (isHsl(color)) return hsl(color);
|
|
1625
|
+
throw new PolishedError(8);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
|
|
1629
|
+
// eslint-disable-next-line no-unused-vars
|
|
1630
|
+
// eslint-disable-next-line no-unused-vars
|
|
1631
|
+
// eslint-disable-next-line no-redeclare
|
|
1632
|
+
function curried(f, length, acc) {
|
|
1633
|
+
return function fn() {
|
|
1634
|
+
// eslint-disable-next-line prefer-rest-params
|
|
1635
|
+
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
1636
|
+
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// eslint-disable-next-line no-redeclare
|
|
1641
|
+
function curry(f) {
|
|
1642
|
+
// eslint-disable-line no-redeclare
|
|
1643
|
+
return curried(f, f.length, []);
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* Changes the hue of the color. Hue is a number between 0 to 360. The first
|
|
1648
|
+
* argument for adjustHue is the amount of degrees the color is rotated around
|
|
1649
|
+
* the color wheel, always producing a positive hue value.
|
|
1650
|
+
*
|
|
1651
|
+
* @example
|
|
1652
|
+
* // Styles as object usage
|
|
1653
|
+
* const styles = {
|
|
1654
|
+
* background: adjustHue(180, '#448'),
|
|
1655
|
+
* background: adjustHue('180', 'rgba(101,100,205,0.7)'),
|
|
1656
|
+
* }
|
|
1657
|
+
*
|
|
1658
|
+
* // styled-components usage
|
|
1659
|
+
* const div = styled.div`
|
|
1660
|
+
* background: ${adjustHue(180, '#448')};
|
|
1661
|
+
* background: ${adjustHue('180', 'rgba(101,100,205,0.7)')};
|
|
1662
|
+
* `
|
|
1663
|
+
*
|
|
1664
|
+
* // CSS in JS Output
|
|
1665
|
+
* element {
|
|
1666
|
+
* background: "#888844";
|
|
1667
|
+
* background: "rgba(136,136,68,0.7)";
|
|
1668
|
+
* }
|
|
1669
|
+
*/
|
|
1670
|
+
function adjustHue(degree, color) {
|
|
1671
|
+
if (color === 'transparent') return color;
|
|
1672
|
+
var hslColor = parseToHsl(color);
|
|
1673
|
+
return toColorString(_extends({}, hslColor, {
|
|
1674
|
+
hue: hslColor.hue + parseFloat(degree)
|
|
1675
|
+
}));
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
// prettier-ignore
|
|
1679
|
+
curry /* ::<number | string, string, string> */(adjustHue);
|
|
1680
|
+
|
|
1681
|
+
function guard(lowerBoundary, upperBoundary, value) {
|
|
1682
|
+
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* Returns a string value for the darkened color.
|
|
1687
|
+
*
|
|
1688
|
+
* @example
|
|
1689
|
+
* // Styles as object usage
|
|
1690
|
+
* const styles = {
|
|
1691
|
+
* background: darken(0.2, '#FFCD64'),
|
|
1692
|
+
* background: darken('0.2', 'rgba(255,205,100,0.7)'),
|
|
1693
|
+
* }
|
|
1694
|
+
*
|
|
1695
|
+
* // styled-components usage
|
|
1696
|
+
* const div = styled.div`
|
|
1697
|
+
* background: ${darken(0.2, '#FFCD64')};
|
|
1698
|
+
* background: ${darken('0.2', 'rgba(255,205,100,0.7)')};
|
|
1699
|
+
* `
|
|
1700
|
+
*
|
|
1701
|
+
* // CSS in JS Output
|
|
1702
|
+
*
|
|
1703
|
+
* element {
|
|
1704
|
+
* background: "#ffbd31";
|
|
1705
|
+
* background: "rgba(255,189,49,0.7)";
|
|
1706
|
+
* }
|
|
1707
|
+
*/
|
|
1708
|
+
function darken(amount, color) {
|
|
1709
|
+
if (color === 'transparent') return color;
|
|
1710
|
+
var hslColor = parseToHsl(color);
|
|
1711
|
+
return toColorString(_extends({}, hslColor, {
|
|
1712
|
+
lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
|
|
1713
|
+
}));
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
// prettier-ignore
|
|
1717
|
+
curry /* ::<number | string, string, string> */(darken);
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* Decreases the intensity of a color. Its range is between 0 to 1. The first
|
|
1721
|
+
* argument of the desaturate function is the amount by how much the color
|
|
1722
|
+
* intensity should be decreased.
|
|
1723
|
+
*
|
|
1724
|
+
* @example
|
|
1725
|
+
* // Styles as object usage
|
|
1726
|
+
* const styles = {
|
|
1727
|
+
* background: desaturate(0.2, '#CCCD64'),
|
|
1728
|
+
* background: desaturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
1729
|
+
* }
|
|
1730
|
+
*
|
|
1731
|
+
* // styled-components usage
|
|
1732
|
+
* const div = styled.div`
|
|
1733
|
+
* background: ${desaturate(0.2, '#CCCD64')};
|
|
1734
|
+
* background: ${desaturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
1735
|
+
* `
|
|
1736
|
+
*
|
|
1737
|
+
* // CSS in JS Output
|
|
1738
|
+
* element {
|
|
1739
|
+
* background: "#b8b979";
|
|
1740
|
+
* background: "rgba(184,185,121,0.7)";
|
|
1741
|
+
* }
|
|
1742
|
+
*/
|
|
1743
|
+
function desaturate(amount, color) {
|
|
1744
|
+
if (color === 'transparent') return color;
|
|
1745
|
+
var hslColor = parseToHsl(color);
|
|
1746
|
+
return toColorString(_extends({}, hslColor, {
|
|
1747
|
+
saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
|
|
1748
|
+
}));
|
|
1749
|
+
}
|
|
607
1750
|
|
|
608
|
-
|
|
1751
|
+
// prettier-ignore
|
|
1752
|
+
curry /* ::<number | string, string, string> */(desaturate);
|
|
609
1753
|
|
|
610
|
-
|
|
1754
|
+
/**
|
|
1755
|
+
* Returns a string value for the lightened color.
|
|
1756
|
+
*
|
|
1757
|
+
* @example
|
|
1758
|
+
* // Styles as object usage
|
|
1759
|
+
* const styles = {
|
|
1760
|
+
* background: lighten(0.2, '#CCCD64'),
|
|
1761
|
+
* background: lighten('0.2', 'rgba(204,205,100,0.7)'),
|
|
1762
|
+
* }
|
|
1763
|
+
*
|
|
1764
|
+
* // styled-components usage
|
|
1765
|
+
* const div = styled.div`
|
|
1766
|
+
* background: ${lighten(0.2, '#FFCD64')};
|
|
1767
|
+
* background: ${lighten('0.2', 'rgba(204,205,100,0.7)')};
|
|
1768
|
+
* `
|
|
1769
|
+
*
|
|
1770
|
+
* // CSS in JS Output
|
|
1771
|
+
*
|
|
1772
|
+
* element {
|
|
1773
|
+
* background: "#e5e6b1";
|
|
1774
|
+
* background: "rgba(229,230,177,0.7)";
|
|
1775
|
+
* }
|
|
1776
|
+
*/
|
|
1777
|
+
function lighten(amount, color) {
|
|
1778
|
+
if (color === 'transparent') return color;
|
|
1779
|
+
var hslColor = parseToHsl(color);
|
|
1780
|
+
return toColorString(_extends({}, hslColor, {
|
|
1781
|
+
lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
|
|
1782
|
+
}));
|
|
1783
|
+
}
|
|
611
1784
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
1785
|
+
// prettier-ignore
|
|
1786
|
+
curry /* ::<number | string, string, string> */(lighten);
|
|
615
1787
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
1788
|
+
/**
|
|
1789
|
+
* Mixes the two provided colors together by calculating the average of each of the RGB components weighted to the first color by the provided weight.
|
|
1790
|
+
*
|
|
1791
|
+
* @example
|
|
1792
|
+
* // Styles as object usage
|
|
1793
|
+
* const styles = {
|
|
1794
|
+
* background: mix(0.5, '#f00', '#00f')
|
|
1795
|
+
* background: mix(0.25, '#f00', '#00f')
|
|
1796
|
+
* background: mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')
|
|
1797
|
+
* }
|
|
1798
|
+
*
|
|
1799
|
+
* // styled-components usage
|
|
1800
|
+
* const div = styled.div`
|
|
1801
|
+
* background: ${mix(0.5, '#f00', '#00f')};
|
|
1802
|
+
* background: ${mix(0.25, '#f00', '#00f')};
|
|
1803
|
+
* background: ${mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')};
|
|
1804
|
+
* `
|
|
1805
|
+
*
|
|
1806
|
+
* // CSS in JS Output
|
|
1807
|
+
*
|
|
1808
|
+
* element {
|
|
1809
|
+
* background: "#7f007f";
|
|
1810
|
+
* background: "#3f00bf";
|
|
1811
|
+
* background: "rgba(63, 0, 191, 0.75)";
|
|
1812
|
+
* }
|
|
1813
|
+
*/
|
|
1814
|
+
function mix(weight, color, otherColor) {
|
|
1815
|
+
if (color === 'transparent') return otherColor;
|
|
1816
|
+
if (otherColor === 'transparent') return color;
|
|
1817
|
+
if (weight === 0) return otherColor;
|
|
1818
|
+
var parsedColor1 = parseToRgb(color);
|
|
1819
|
+
var color1 = _extends({}, parsedColor1, {
|
|
1820
|
+
alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
|
|
1821
|
+
});
|
|
1822
|
+
var parsedColor2 = parseToRgb(otherColor);
|
|
1823
|
+
var color2 = _extends({}, parsedColor2, {
|
|
1824
|
+
alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
|
|
1825
|
+
});
|
|
623
1826
|
|
|
624
|
-
|
|
1827
|
+
// The formula is copied from the original Sass implementation:
|
|
1828
|
+
// http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
|
|
1829
|
+
var alphaDelta = color1.alpha - color2.alpha;
|
|
1830
|
+
var x = parseFloat(weight) * 2 - 1;
|
|
1831
|
+
var y = x * alphaDelta === -1 ? x : x + alphaDelta;
|
|
1832
|
+
var z = 1 + x * alphaDelta;
|
|
1833
|
+
var weight1 = (y / z + 1) / 2.0;
|
|
1834
|
+
var weight2 = 1 - weight1;
|
|
1835
|
+
var mixedColor = {
|
|
1836
|
+
red: Math.floor(color1.red * weight1 + color2.red * weight2),
|
|
1837
|
+
green: Math.floor(color1.green * weight1 + color2.green * weight2),
|
|
1838
|
+
blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
|
|
1839
|
+
alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
|
|
1840
|
+
};
|
|
1841
|
+
return rgba(mixedColor);
|
|
625
1842
|
}
|
|
626
1843
|
|
|
1844
|
+
// prettier-ignore
|
|
1845
|
+
var curriedMix = curry /* ::<number | string, string, string, string> */(mix);
|
|
1846
|
+
var mix$1 = curriedMix;
|
|
1847
|
+
|
|
627
1848
|
/**
|
|
628
|
-
*
|
|
629
|
-
*
|
|
1849
|
+
* Increases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
1850
|
+
*
|
|
1851
|
+
*
|
|
1852
|
+
* @example
|
|
1853
|
+
* // Styles as object usage
|
|
1854
|
+
* const styles = {
|
|
1855
|
+
* background: opacify(0.1, 'rgba(255, 255, 255, 0.9)');
|
|
1856
|
+
* background: opacify(0.2, 'hsla(0, 0%, 100%, 0.5)'),
|
|
1857
|
+
* background: opacify('0.5', 'rgba(255, 0, 0, 0.2)'),
|
|
1858
|
+
* }
|
|
1859
|
+
*
|
|
1860
|
+
* // styled-components usage
|
|
1861
|
+
* const div = styled.div`
|
|
1862
|
+
* background: ${opacify(0.1, 'rgba(255, 255, 255, 0.9)')};
|
|
1863
|
+
* background: ${opacify(0.2, 'hsla(0, 0%, 100%, 0.5)')},
|
|
1864
|
+
* background: ${opacify('0.5', 'rgba(255, 0, 0, 0.2)')},
|
|
1865
|
+
* `
|
|
1866
|
+
*
|
|
1867
|
+
* // CSS in JS Output
|
|
1868
|
+
*
|
|
1869
|
+
* element {
|
|
1870
|
+
* background: "#fff";
|
|
1871
|
+
* background: "rgba(255,255,255,0.7)";
|
|
1872
|
+
* background: "rgba(255,0,0,0.7)";
|
|
1873
|
+
* }
|
|
630
1874
|
*/
|
|
631
|
-
|
|
632
|
-
if (
|
|
633
|
-
|
|
634
|
-
|
|
1875
|
+
function opacify(amount, color) {
|
|
1876
|
+
if (color === 'transparent') return color;
|
|
1877
|
+
var parsedColor = parseToRgb(color);
|
|
1878
|
+
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
1879
|
+
var colorWithAlpha = _extends({}, parsedColor, {
|
|
1880
|
+
alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
|
|
1881
|
+
});
|
|
1882
|
+
return rgba(colorWithAlpha);
|
|
1883
|
+
}
|
|
635
1884
|
|
|
636
|
-
|
|
637
|
-
|
|
1885
|
+
// prettier-ignore
|
|
1886
|
+
curry /* ::<number | string, string, string> */(opacify);
|
|
638
1887
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
1888
|
+
/**
|
|
1889
|
+
* Increases the intensity of a color. Its range is between 0 to 1. The first
|
|
1890
|
+
* argument of the saturate function is the amount by how much the color
|
|
1891
|
+
* intensity should be increased.
|
|
1892
|
+
*
|
|
1893
|
+
* @example
|
|
1894
|
+
* // Styles as object usage
|
|
1895
|
+
* const styles = {
|
|
1896
|
+
* background: saturate(0.2, '#CCCD64'),
|
|
1897
|
+
* background: saturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
1898
|
+
* }
|
|
1899
|
+
*
|
|
1900
|
+
* // styled-components usage
|
|
1901
|
+
* const div = styled.div`
|
|
1902
|
+
* background: ${saturate(0.2, '#FFCD64')};
|
|
1903
|
+
* background: ${saturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
1904
|
+
* `
|
|
1905
|
+
*
|
|
1906
|
+
* // CSS in JS Output
|
|
1907
|
+
*
|
|
1908
|
+
* element {
|
|
1909
|
+
* background: "#e0e250";
|
|
1910
|
+
* background: "rgba(224,226,80,0.7)";
|
|
1911
|
+
* }
|
|
1912
|
+
*/
|
|
1913
|
+
function saturate(amount, color) {
|
|
1914
|
+
if (color === 'transparent') return color;
|
|
1915
|
+
var hslColor = parseToHsl(color);
|
|
1916
|
+
return toColorString(_extends({}, hslColor, {
|
|
1917
|
+
saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
|
|
1918
|
+
}));
|
|
642
1919
|
}
|
|
643
1920
|
|
|
1921
|
+
// prettier-ignore
|
|
1922
|
+
curry /* ::<number | string, string, string> */(saturate);
|
|
1923
|
+
|
|
644
1924
|
/**
|
|
645
|
-
*
|
|
1925
|
+
* Sets the hue of a color to the provided value. The hue range can be
|
|
1926
|
+
* from 0 and 359.
|
|
646
1927
|
*
|
|
647
1928
|
* @example
|
|
648
1929
|
* // Styles as object usage
|
|
649
1930
|
* const styles = {
|
|
650
|
-
* background:
|
|
651
|
-
* background:
|
|
1931
|
+
* background: setHue(42, '#CCCD64'),
|
|
1932
|
+
* background: setHue('244', 'rgba(204,205,100,0.7)'),
|
|
652
1933
|
* }
|
|
653
1934
|
*
|
|
654
1935
|
* // styled-components usage
|
|
655
1936
|
* const div = styled.div`
|
|
656
|
-
* background: ${
|
|
657
|
-
* background: ${
|
|
1937
|
+
* background: ${setHue(42, '#CCCD64')};
|
|
1938
|
+
* background: ${setHue('244', 'rgba(204,205,100,0.7)')};
|
|
658
1939
|
* `
|
|
659
1940
|
*
|
|
660
1941
|
* // CSS in JS Output
|
|
661
|
-
*
|
|
662
1942
|
* element {
|
|
663
|
-
* background: "#
|
|
664
|
-
* background: "
|
|
1943
|
+
* background: "#cdae64";
|
|
1944
|
+
* background: "rgba(107,100,205,0.7)";
|
|
665
1945
|
* }
|
|
666
1946
|
*/
|
|
667
|
-
function
|
|
668
|
-
if (
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
1947
|
+
function setHue(hue, color) {
|
|
1948
|
+
if (color === 'transparent') return color;
|
|
1949
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
1950
|
+
hue: parseFloat(hue)
|
|
1951
|
+
}));
|
|
1952
|
+
}
|
|
673
1953
|
|
|
674
|
-
|
|
1954
|
+
// prettier-ignore
|
|
1955
|
+
curry /* ::<number | string, string, string> */(setHue);
|
|
1956
|
+
|
|
1957
|
+
/**
|
|
1958
|
+
* Sets the lightness of a color to the provided value. The lightness range can be
|
|
1959
|
+
* from 0 and 1.
|
|
1960
|
+
*
|
|
1961
|
+
* @example
|
|
1962
|
+
* // Styles as object usage
|
|
1963
|
+
* const styles = {
|
|
1964
|
+
* background: setLightness(0.2, '#CCCD64'),
|
|
1965
|
+
* background: setLightness('0.75', 'rgba(204,205,100,0.7)'),
|
|
1966
|
+
* }
|
|
1967
|
+
*
|
|
1968
|
+
* // styled-components usage
|
|
1969
|
+
* const div = styled.div`
|
|
1970
|
+
* background: ${setLightness(0.2, '#CCCD64')};
|
|
1971
|
+
* background: ${setLightness('0.75', 'rgba(204,205,100,0.7)')};
|
|
1972
|
+
* `
|
|
1973
|
+
*
|
|
1974
|
+
* // CSS in JS Output
|
|
1975
|
+
* element {
|
|
1976
|
+
* background: "#4d4d19";
|
|
1977
|
+
* background: "rgba(223,224,159,0.7)";
|
|
1978
|
+
* }
|
|
1979
|
+
*/
|
|
1980
|
+
function setLightness(lightness, color) {
|
|
1981
|
+
if (color === 'transparent') return color;
|
|
1982
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
1983
|
+
lightness: parseFloat(lightness)
|
|
1984
|
+
}));
|
|
675
1985
|
}
|
|
676
1986
|
|
|
1987
|
+
// prettier-ignore
|
|
1988
|
+
curry /* ::<number | string, string, string> */(setLightness);
|
|
1989
|
+
|
|
677
1990
|
/**
|
|
678
|
-
*
|
|
1991
|
+
* Sets the saturation of a color to the provided value. The saturation range can be
|
|
1992
|
+
* from 0 and 1.
|
|
679
1993
|
*
|
|
680
|
-
*
|
|
1994
|
+
* @example
|
|
1995
|
+
* // Styles as object usage
|
|
1996
|
+
* const styles = {
|
|
1997
|
+
* background: setSaturation(0.2, '#CCCD64'),
|
|
1998
|
+
* background: setSaturation('0.75', 'rgba(204,205,100,0.7)'),
|
|
1999
|
+
* }
|
|
2000
|
+
*
|
|
2001
|
+
* // styled-components usage
|
|
2002
|
+
* const div = styled.div`
|
|
2003
|
+
* background: ${setSaturation(0.2, '#CCCD64')};
|
|
2004
|
+
* background: ${setSaturation('0.75', 'rgba(204,205,100,0.7)')};
|
|
2005
|
+
* `
|
|
2006
|
+
*
|
|
2007
|
+
* // CSS in JS Output
|
|
2008
|
+
* element {
|
|
2009
|
+
* background: "#adad84";
|
|
2010
|
+
* background: "rgba(228,229,76,0.7)";
|
|
2011
|
+
* }
|
|
2012
|
+
*/
|
|
2013
|
+
function setSaturation(saturation, color) {
|
|
2014
|
+
if (color === 'transparent') return color;
|
|
2015
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
2016
|
+
saturation: parseFloat(saturation)
|
|
2017
|
+
}));
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
// prettier-ignore
|
|
2021
|
+
curry /* ::<number | string, string, string> */(setSaturation);
|
|
2022
|
+
|
|
2023
|
+
/**
|
|
2024
|
+
* Shades a color by mixing it with black. `shade` can produce
|
|
2025
|
+
* hue shifts, where as `darken` manipulates the luminance channel and therefore
|
|
2026
|
+
* doesn't produce hue shifts.
|
|
681
2027
|
*
|
|
682
2028
|
* @example
|
|
683
2029
|
* // Styles as object usage
|
|
684
2030
|
* const styles = {
|
|
685
|
-
* background:
|
|
686
|
-
* background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
|
|
687
|
-
* background: rgba(255, 205, 100, 1),
|
|
688
|
-
* background: rgba('#ffffff', 0.4),
|
|
689
|
-
* background: rgba('black', 0.7),
|
|
2031
|
+
* background: shade(0.25, '#00f')
|
|
690
2032
|
* }
|
|
691
2033
|
*
|
|
692
2034
|
* // styled-components usage
|
|
693
2035
|
* const div = styled.div`
|
|
694
|
-
* background: ${
|
|
695
|
-
* background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
|
|
696
|
-
* background: ${rgba(255, 205, 100, 1)};
|
|
697
|
-
* background: ${rgba('#ffffff', 0.4)};
|
|
698
|
-
* background: ${rgba('black', 0.7)};
|
|
2036
|
+
* background: ${shade(0.25, '#00f')};
|
|
699
2037
|
* `
|
|
700
2038
|
*
|
|
701
2039
|
* // CSS in JS Output
|
|
702
2040
|
*
|
|
703
2041
|
* element {
|
|
704
|
-
* background: "
|
|
705
|
-
* background: "rgba(255,205,100,0.7)";
|
|
706
|
-
* background: "#ffcd64";
|
|
707
|
-
* background: "rgba(255,255,255,0.4)";
|
|
708
|
-
* background: "rgba(0,0,0,0.7)";
|
|
2042
|
+
* background: "#00003f";
|
|
709
2043
|
* }
|
|
710
2044
|
*/
|
|
711
|
-
function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
|
712
|
-
if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
713
|
-
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
714
|
-
}
|
|
715
2045
|
|
|
716
|
-
|
|
2046
|
+
function shade(percentage, color) {
|
|
2047
|
+
if (color === 'transparent') return color;
|
|
2048
|
+
return mix$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
|
|
717
2049
|
}
|
|
718
2050
|
|
|
719
|
-
//
|
|
720
|
-
|
|
721
|
-
// eslint-disable-next-line no-unused-vars
|
|
722
|
-
// eslint-disable-next-line no-redeclare
|
|
723
|
-
function curried(f, length, acc) {
|
|
724
|
-
return function fn() {
|
|
725
|
-
// eslint-disable-next-line prefer-rest-params
|
|
726
|
-
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
727
|
-
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
728
|
-
};
|
|
729
|
-
} // eslint-disable-next-line no-redeclare
|
|
2051
|
+
// prettier-ignore
|
|
2052
|
+
curry /* ::<number | string, string, string> */(shade);
|
|
730
2053
|
|
|
2054
|
+
/**
|
|
2055
|
+
* Tints a color by mixing it with white. `tint` can produce
|
|
2056
|
+
* hue shifts, where as `lighten` manipulates the luminance channel and therefore
|
|
2057
|
+
* doesn't produce hue shifts.
|
|
2058
|
+
*
|
|
2059
|
+
* @example
|
|
2060
|
+
* // Styles as object usage
|
|
2061
|
+
* const styles = {
|
|
2062
|
+
* background: tint(0.25, '#00f')
|
|
2063
|
+
* }
|
|
2064
|
+
*
|
|
2065
|
+
* // styled-components usage
|
|
2066
|
+
* const div = styled.div`
|
|
2067
|
+
* background: ${tint(0.25, '#00f')};
|
|
2068
|
+
* `
|
|
2069
|
+
*
|
|
2070
|
+
* // CSS in JS Output
|
|
2071
|
+
*
|
|
2072
|
+
* element {
|
|
2073
|
+
* background: "#bfbfff";
|
|
2074
|
+
* }
|
|
2075
|
+
*/
|
|
731
2076
|
|
|
732
|
-
function
|
|
733
|
-
|
|
734
|
-
return
|
|
2077
|
+
function tint(percentage, color) {
|
|
2078
|
+
if (color === 'transparent') return color;
|
|
2079
|
+
return mix$1(parseFloat(percentage), 'rgb(255, 255, 255)', color);
|
|
735
2080
|
}
|
|
736
2081
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
2082
|
+
// prettier-ignore
|
|
2083
|
+
curry /* ::<number | string, string, string> */(tint);
|
|
740
2084
|
|
|
741
2085
|
/**
|
|
742
2086
|
* Decreases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
@@ -745,7 +2089,7 @@ function guard(lowerBoundary, upperBoundary, value) {
|
|
|
745
2089
|
* @example
|
|
746
2090
|
* // Styles as object usage
|
|
747
2091
|
* const styles = {
|
|
748
|
-
* background: transparentize(0.1, '#fff')
|
|
2092
|
+
* background: transparentize(0.1, '#fff'),
|
|
749
2093
|
* background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
|
|
750
2094
|
* background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
|
|
751
2095
|
* }
|
|
@@ -753,8 +2097,8 @@ function guard(lowerBoundary, upperBoundary, value) {
|
|
|
753
2097
|
* // styled-components usage
|
|
754
2098
|
* const div = styled.div`
|
|
755
2099
|
* background: ${transparentize(0.1, '#fff')};
|
|
756
|
-
* background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')}
|
|
757
|
-
* background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')}
|
|
2100
|
+
* background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')};
|
|
2101
|
+
* background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')};
|
|
758
2102
|
* `
|
|
759
2103
|
*
|
|
760
2104
|
* // CSS in JS Output
|
|
@@ -765,23 +2109,19 @@ function guard(lowerBoundary, upperBoundary, value) {
|
|
|
765
2109
|
* background: "rgba(255,0,0,0.3)";
|
|
766
2110
|
* }
|
|
767
2111
|
*/
|
|
768
|
-
|
|
769
2112
|
function transparentize(amount, color) {
|
|
770
2113
|
if (color === 'transparent') return color;
|
|
771
2114
|
var parsedColor = parseToRgb(color);
|
|
772
2115
|
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
773
|
-
|
|
774
2116
|
var colorWithAlpha = _extends({}, parsedColor, {
|
|
775
2117
|
alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
|
|
776
2118
|
});
|
|
777
|
-
|
|
778
2119
|
return rgba(colorWithAlpha);
|
|
779
|
-
}
|
|
780
|
-
|
|
2120
|
+
}
|
|
781
2121
|
|
|
782
|
-
|
|
783
|
-
/* ::<number | string, string, string> */
|
|
784
|
-
|
|
2122
|
+
// prettier-ignore
|
|
2123
|
+
var curriedTransparentize = curry /* ::<number | string, string, string> */(transparentize);
|
|
2124
|
+
var curriedTransparentize$1 = curriedTransparentize;
|
|
785
2125
|
|
|
786
2126
|
var FOCUSABLE_SELECTOR = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
787
2127
|
function getFocusableElements(container) {
|
|
@@ -973,7 +2313,7 @@ function ChartDataTable(_a) {
|
|
|
973
2313
|
var rowKey = resolvedColumns
|
|
974
2314
|
.map(function (col) { var _a; return String((_a = row[col.key]) !== null && _a !== void 0 ? _a : ''); })
|
|
975
2315
|
.join('-');
|
|
976
|
-
return (React.createElement(TableRow, { key:
|
|
2316
|
+
return (React.createElement(TableRow, { key: rowKey + "-" + index }, resolvedColumns.map(function (col) { return (React.createElement(TableCell, { key: col.key }, row[col.key])); })));
|
|
977
2317
|
}))));
|
|
978
2318
|
}
|
|
979
2319
|
|
|
@@ -993,6 +2333,7 @@ var defaults = {
|
|
|
993
2333
|
* Reads chart toolbar i18n strings from the I18nContext if available,
|
|
994
2334
|
* falling back to English defaults.
|
|
995
2335
|
*/
|
|
2336
|
+
// eslint-disable-next-line complexity
|
|
996
2337
|
function useChartToolbarI18n() {
|
|
997
2338
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
998
2339
|
var i18n = React.useContext(I18nContext);
|
|
@@ -1040,7 +2381,8 @@ function ChartTableButton(_a) {
|
|
|
1040
2381
|
}
|
|
1041
2382
|
|
|
1042
2383
|
var ModalFooter = styled.div(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-end;\n padding-top: ", ";\n"], ["\n display: flex;\n justify-content: flex-end;\n padding-top: ", ";\n"])), function (props) { return props.theme.spaceScale.spacing05; });
|
|
1043
|
-
var HeaderLabel = styled.span(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n display: block;\n font-size: ", ";\n font-weight: normal;\n color: ", ";\n line-height: ", ";\n"], ["\n display: block;\n font-size: ", ";\n font-weight: normal;\n color: ",
|
|
2384
|
+
var HeaderLabel = styled.span(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n display: block;\n font-size: ", ";\n font-weight: normal;\n color: ", ";\n line-height: ", ";\n"], ["\n display: block;\n font-size: ", ";\n font-weight: normal;\n color: ",
|
|
2385
|
+
";\n line-height: ", ";\n"])), function (props) { return props.theme.typeScale.size02.fontSize; }, function (props) {
|
|
1044
2386
|
return props.isInverse
|
|
1045
2387
|
? props.theme.colors.neutral100
|
|
1046
2388
|
: props.theme.colors.neutral500;
|
|
@@ -1103,7 +2445,9 @@ var CarbonChartType;
|
|
|
1103
2445
|
CarbonChartType["combo"] = "combo";
|
|
1104
2446
|
})(CarbonChartType || (CarbonChartType = {}));
|
|
1105
2447
|
var ChartContentWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: 100%;\n position: relative;\n"], ["\n height: 100%;\n position: relative;\n"])));
|
|
1106
|
-
var FullscreenRoot = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 100%;\n width: 100%;\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ", ";\n\n ", "\n }\n"], ["\n height: 100%;\n width: 100%;\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ",
|
|
2448
|
+
var FullscreenRoot = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 100%;\n width: 100%;\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ", ";\n\n ", "\n }\n"], ["\n height: 100%;\n width: 100%;\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ",
|
|
2449
|
+
";\n\n ",
|
|
2450
|
+
"\n }\n"])), function (props) {
|
|
1107
2451
|
return props.isInverse
|
|
1108
2452
|
? props.theme.colors.primary700
|
|
1109
2453
|
: props.theme.colors.neutral100;
|
|
@@ -1112,7 +2456,48 @@ var FullscreenRoot = styled.div(templateObject_2 || (templateObject_2 = __makeTe
|
|
|
1112
2456
|
? "\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n padding: 2em;\n\n .carbon-chart-wrapper,\n .carbon-chart-content {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n min-height: 0;\n }\n\n .cds--chart-holder {\n flex: 1 1 auto;\n height: auto !important;\n min-height: 0;\n }\n "
|
|
1113
2457
|
: "\n .cds--chart-holder {\n height: 100vh !important;\n }\n ";
|
|
1114
2458
|
});
|
|
1115
|
-
var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n .cds--cc--legend-fieldset {\n border: 0;\n margin: 0;\n min-inline-size: 0;\n padding: 0;\n }\n\n .cds--cc--legend-fieldset > legend {\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n position: absolute;\n top: auto;\n white-space: nowrap;\n width: 1px;\n }\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ", ";\n\n .cds--chart-holder {\n height: 100vh !important;\n }\n }\n\n .cds--chart-holder.filled,\n .cds--chart-holder.filled .cds--cc--chart-wrapper {\n background-color: ", ";\n }\n\n .cds--data-table thead tr th {\n background: ", " !important;\n }\n .cds--data-table td,\n .cds--data-table tbody th {\n color: ", ";\n }\n .cds--data-table tbody tr,\n .cds--data-table tbody tr td,\n .cds--data-table tbody tr th {\n color: ", ";\n }\n .cds--data-table tr {\n block-size: 2.5rem;\n }\n\n .cds--cc--tooltip .content-box .datapoint-tooltip p {\n font-size: ", ";\n padding: ", ";\n color: ", ";\n max-width: 142px;\n white-space: normal;\n }\n\n .cds--modal-container {\n clip-path: inset(0% 0% 0% 0% round ", ");\n background: ", ";\n .cds--data-table th {\n background: ", ";\n }\n .cds--data-table td {\n border-top: 1px solid\n ", ";\n border-bottom: 1px solid\n ", ";\n background: ", ";\n }\n .cds--data-table tr:hover td {\n background: ", ";\n }\n }\n\n .chart-holder p,\n .chart-holder div,\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--title p.title,\n .cds--cc--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ", ";\n }\n\n .cds--cc--axes {\n overflow: visible;\n }\n\n div.cds--cc--legend {\n div.legend-item {\n div.checkbox {\n background: ", ";\n border: none;\n width: ", ";\n height: ", ";\n svg {\n left: 2px;\n position: relative;\n }\n }\n p {\n font-size: ", ";\n margin: 0 ", " 0 0;\n }\n }\n }\n div.cds--cc--legend.has-deactivated-items {\n div.legend-item {\n div.checkbox {\n border: 1px solid\n ", ";\n }\n div.checkbox.active {\n border: 1px solid transparent;\n }\n }\n }\n .chart-holder {\n .cds--cc--axes g.axis g.tick text {\n fill: ", ";\n }\n .cds--cc--axes g.axis path.domain {\n stroke: ", ";\n }\n .cds--cc--grid g.x.grid g.tick line,\n .cds--cc--grid g.y.grid g.tick line {\n stroke: ", ";\n }\n .cds--cc--grid rect.chart-grid-backdrop.stroked {\n stroke: ", ";\n }\n .cds--cc--skeleton .shimmer-effect-lines {\n filter: ", ";\n }\n /* .chart-holder.cds--chart-holder.filled,\n .cds--cc--skeleton rect.chart-skeleton-backdrop,\n .cds--cc--grid rect.chart-grid-backdrop {\n } */\n\n .cds--cc--grid rect.chart-grid-backdrop {\n fill: transparent;\n }\n .cds--cc--scatter circle.dot,\n .cds--cc--scatter circle.dot.hovered {\n padding: 10px;\n }\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled {\n stroke-width: 6px;\n transition: 0.1s all linear;\n }\n .cds--cc--scatter circle.dot {\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--scatter circle.dot.hovered {\n stroke-width: 0.5em;\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot.hovered {\n stroke-width: 15px;\n }\n .cds--cc--scatter-stacked circle.dot,\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.hovered {\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--lollipop .cds--cc--scatter circle.dot.hovered {\n transition: 0.1s all linear;\n stroke-width: 1.1em;\n }\n\n .cds--cc--tooltip {\n ", "\n }\n\n .cds--overflow-menu-options__btn:focus {\n outline-color: ", ";\n }\n\n .cds--btn {\n min-height: auto;\n display: flex;\n flex: 0 auto;\n align-items: center;\n text-align: center;\n padding: 20px;\n margin: 0;\n line-height: ", ";\n margin: 0;\n min-width: ", ";\n overflow: hidden;\n position: relative;\n right: ", ";\n text-align: center;\n height: 40px;\n font-family: ", ";\n font-size: ", ";\n border-radius: ", ";\n font-weight: 500;\n }\n\n .cds--btn--primary {\n background: ", ";\n color: ", ";\n }\n\n *:focus {\n outline: 2px solid\n ", " !important;\n outline-offset: 0;\n }\n circle.dot:focus {\n outline: none !important;\n }\n .cds--overflow-menu-options__btn:focus,\n .cds--overflow-menu:focus,\n .cds--overflow-menu__trigger:focus,\n .toolbar-control:focus {\n outline: 2px solid\n ", " !important;\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):focus\n div.checkbox,\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n border: ", ";\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n box-shadow: 0 0 0 2px\n ", " !important;\n }\n\n .cds--btn--primary {\n &:focus {\n outline: 2px solid\n ", ";\n }\n outline-offset: 2px;\n border: none;\n box-shadow: none;\n }\n .cds--modal-header {\n background: ", ";\n margin-bottom: 0;\n border-bottom: 1px solid\n ", ";\n }\n .cds--modal-header__heading {\n font-weight: 600;\n }\n\n .cds--modal-close {\n position: absolute;\n top: 0;\n right: 0;\n &:focus {\n outline: 2px solid\n ", ";\n border-color: none;\n }\n outline-offset: 0;\n border: none;\n }\n }\n\n .cds--modal-footer.cds--modal-footer {\n display: flex;\n align-items: center;\n border-top: 1px solid\n ", ";\n background: ", " !important;\n }\n .layout-child.header {\n height: auto !important;\n p {\n text-overflow: inherit;\n overflow: auto;\n white-space: normal;\n }\n }\n\n &.has-magma-toolbar .cds--cc--title p.title {\n visibility: hidden;\n }\n\n svg:not(:root) {\n overflow: visible;\n }\n\n circle.dot:focus {\n outline: none;\n stroke: ", " !important;\n stroke-width: 6px !important;\n stroke-opacity: 1 !important;\n paint-order: stroke fill;\n }\n\n .cds--cc--chart-wrapper text {\n font-size: ", ";\n }\n\n g.center text,\n .pie-label {\n fill: ", ";\n }\n\n // Zoom responsive tweaks\n\n @media screen and (max-width: 760px) {\n .cds--modal-container {\n overflow-y: auto;\n }\n .cds--chart-holder .cds--modal .cds--modal-container .cds--modal-content {\n overflow: visible;\n }\n .cds--chart-holder\n .cds--modal\n .cds--modal-container\n .cds--modal-content\n table\n th {\n position: relative;\n }\n }\n"], ["\n .cds--cc--legend-fieldset {\n border: 0;\n margin: 0;\n min-inline-size: 0;\n padding: 0;\n }\n\n .cds--cc--legend-fieldset > legend {\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n position: absolute;\n top: auto;\n white-space: nowrap;\n width: 1px;\n }\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ", ";\n\n .cds--chart-holder {\n height: 100vh !important;\n }\n }\n\n .cds--chart-holder.filled,\n .cds--chart-holder.filled .cds--cc--chart-wrapper {\n background-color: ", ";\n }\n\n .cds--data-table thead tr th {\n background: ", " !important;\n }\n .cds--data-table td,\n .cds--data-table tbody th {\n color: ", ";\n }\n .cds--data-table tbody tr,\n .cds--data-table tbody tr td,\n .cds--data-table tbody tr th {\n color: ", ";\n }\n .cds--data-table tr {\n block-size: 2.5rem;\n }\n\n .cds--cc--tooltip .content-box .datapoint-tooltip p {\n font-size: ", ";\n padding: ", ";\n color: ", ";\n max-width: 142px;\n white-space: normal;\n }\n\n .cds--modal-container {\n clip-path: inset(0% 0% 0% 0% round ", ");\n background: ", ";\n .cds--data-table th {\n background: ", ";\n }\n .cds--data-table td {\n border-top: 1px solid\n ", ";\n border-bottom: 1px solid\n ", ";\n background: ", ";\n }\n .cds--data-table tr:hover td {\n background: ", ";\n }\n }\n\n .chart-holder p,\n .chart-holder div,\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--title p.title,\n .cds--cc--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ", ";\n }\n\n .cds--cc--axes {\n overflow: visible;\n }\n\n div.cds--cc--legend {\n div.legend-item {\n div.checkbox {\n background: ", ";\n border: none;\n width: ", ";\n height: ", ";\n svg {\n left: 2px;\n position: relative;\n }\n }\n p {\n font-size: ", ";\n margin: 0 ", " 0 0;\n }\n }\n }\n div.cds--cc--legend.has-deactivated-items {\n div.legend-item {\n div.checkbox {\n border: 1px solid\n ", ";\n }\n div.checkbox.active {\n border: 1px solid transparent;\n }\n }\n }\n .chart-holder {\n .cds--cc--axes g.axis g.tick text {\n fill: ", ";\n }\n .cds--cc--axes g.axis path.domain {\n stroke: ", ";\n }\n .cds--cc--grid g.x.grid g.tick line,\n .cds--cc--grid g.y.grid g.tick line {\n stroke: ", ";\n }\n .cds--cc--grid rect.chart-grid-backdrop.stroked {\n stroke: ", ";\n }\n .cds--cc--skeleton .shimmer-effect-lines {\n filter: ", ";\n }\n /* .chart-holder.cds--chart-holder.filled,\n .cds--cc--skeleton rect.chart-skeleton-backdrop,\n .cds--cc--grid rect.chart-grid-backdrop {\n } */\n\n .cds--cc--grid rect.chart-grid-backdrop {\n fill: transparent;\n }\n .cds--cc--scatter circle.dot,\n .cds--cc--scatter circle.dot.hovered {\n padding: 10px;\n }\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled {\n stroke-width: 6px;\n transition: 0.1s all linear;\n }\n .cds--cc--scatter circle.dot {\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--scatter circle.dot.hovered {\n stroke-width: 0.5em;\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot.hovered {\n stroke-width: 15px;\n }\n .cds--cc--scatter-stacked circle.dot,\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.hovered {\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--lollipop .cds--cc--scatter circle.dot.hovered {\n transition: 0.1s all linear;\n stroke-width: 1.1em;\n }\n\n .cds--cc--tooltip {\n ", "\n }\n\n .cds--overflow-menu-options__btn:focus {\n outline-color: ", ";\n }\n\n .cds--btn {\n min-height: auto;\n display: flex;\n flex: 0 auto;\n align-items: center;\n text-align: center;\n padding: 20px;\n margin: 0;\n line-height: ", ";\n margin: 0;\n min-width: ", ";\n overflow: hidden;\n position: relative;\n right: ", ";\n text-align: center;\n height: 40px;\n font-family: ", ";\n font-size: ", ";\n border-radius: ", ";\n font-weight: 500;\n }\n\n .cds--btn--primary {\n background: ", ";\n color: ", ";\n }\n\n *:focus {\n outline: 2px solid\n ", " !important;\n outline-offset: 0;\n }\n circle.dot:focus {\n outline: none !important;\n }\n .cds--overflow-menu-options__btn:focus,\n .cds--overflow-menu:focus,\n .cds--overflow-menu__trigger:focus,\n .toolbar-control:focus {\n outline: 2px solid\n ", " !important;\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):focus\n div.checkbox,\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n border: ", ";\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n box-shadow: 0 0 0 2px\n ", " !important;\n }\n\n .cds--btn--primary {\n &:focus {\n outline: 2px solid\n ", ";\n }\n outline-offset: 2px;\n border: none;\n box-shadow: none;\n }\n .cds--modal-header {\n background: ", ";\n margin-bottom: 0;\n border-bottom: 1px solid\n ", ";\n }\n .cds--modal-header__heading {\n font-weight: 600;\n }\n\n .cds--modal-close {\n position: absolute;\n top: 0;\n right: 0;\n &:focus {\n outline: 2px solid\n ", ";\n border-color: none;\n }\n outline-offset: 0;\n border: none;\n }\n }\n\n .cds--modal-footer.cds--modal-footer {\n display: flex;\n align-items: center;\n border-top: 1px solid\n ", ";\n background: ", " !important;\n }\n .layout-child.header {\n height: auto !important;\n p {\n text-overflow: inherit;\n overflow: auto;\n white-space: normal;\n }\n }\n\n &.has-magma-toolbar .cds--cc--title p.title {\n visibility: hidden;\n }\n\n svg:not(:root) {\n overflow: visible;\n }\n\n circle.dot:focus {\n outline: none;\n stroke: ", " !important;\n stroke-width: 6px !important;\n stroke-opacity: 1 !important;\n paint-order: stroke fill;\n }\n\n .cds--cc--chart-wrapper text {\n font-size: ", ";\n }\n\n g.center text,\n .pie-label {\n fill: ", ";\n }\n\n // Zoom responsive tweaks\n\n @media screen and (max-width: 760px) {\n .cds--modal-container {\n overflow-y: auto;\n }\n .cds--chart-holder .cds--modal .cds--modal-container .cds--modal-content {\n overflow: visible;\n }\n .cds--chart-holder\n .cds--modal\n .cds--modal-container\n .cds--modal-content\n table\n th {\n position: relative;\n }\n }\n"])), function (props) {
|
|
2459
|
+
var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n .cds--cc--legend-fieldset {\n border: 0;\n margin: 0;\n min-inline-size: 0;\n padding: 0;\n }\n\n .cds--cc--legend-fieldset > legend {\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n position: absolute;\n top: auto;\n white-space: nowrap;\n width: 1px;\n }\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ", ";\n\n .cds--chart-holder {\n height: 100vh !important;\n }\n }\n\n .cds--chart-holder.filled,\n .cds--chart-holder.filled .cds--cc--chart-wrapper {\n background-color: ", ";\n }\n\n .cds--data-table thead tr th {\n background: ", " !important;\n }\n .cds--data-table td,\n .cds--data-table tbody th {\n color: ", ";\n }\n .cds--data-table tbody tr,\n .cds--data-table tbody tr td,\n .cds--data-table tbody tr th {\n color: ", ";\n }\n .cds--data-table tr {\n block-size: 2.5rem;\n }\n\n .cds--cc--tooltip .content-box .datapoint-tooltip p {\n font-size: ", ";\n padding: ", ";\n color: ", ";\n max-width: 142px;\n white-space: normal;\n }\n\n .cds--modal-container {\n clip-path: inset(0% 0% 0% 0% round ", ");\n background: ", ";\n .cds--data-table th {\n background: ", ";\n }\n .cds--data-table td {\n border-top: 1px solid\n ", ";\n border-bottom: 1px solid\n ", ";\n background: ", ";\n }\n .cds--data-table tr:hover td {\n background: ", ";\n }\n }\n\n .chart-holder p,\n .chart-holder div,\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--title p.title,\n .cds--cc--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ", ";\n }\n\n .cds--cc--axes {\n overflow: visible;\n }\n\n div.cds--cc--legend {\n div.legend-item {\n div.checkbox {\n background: ", ";\n border: none;\n width: ", ";\n height: ", ";\n svg {\n left: 2px;\n position: relative;\n }\n }\n p {\n font-size: ", ";\n margin: 0 ", " 0 0;\n }\n }\n }\n div.cds--cc--legend.has-deactivated-items {\n div.legend-item {\n div.checkbox {\n border: 1px solid\n ", ";\n }\n div.checkbox.active {\n border: 1px solid transparent;\n }\n }\n }\n .chart-holder {\n .cds--cc--axes g.axis g.tick text {\n fill: ", ";\n }\n .cds--cc--axes g.axis path.domain {\n stroke: ", ";\n }\n .cds--cc--grid g.x.grid g.tick line,\n .cds--cc--grid g.y.grid g.tick line {\n stroke: ", ";\n }\n .cds--cc--grid rect.chart-grid-backdrop.stroked {\n stroke: ", ";\n }\n .cds--cc--skeleton .shimmer-effect-lines {\n filter: ", ";\n }\n /* .chart-holder.cds--chart-holder.filled,\n .cds--cc--skeleton rect.chart-skeleton-backdrop,\n .cds--cc--grid rect.chart-grid-backdrop {\n } */\n\n .cds--cc--grid rect.chart-grid-backdrop {\n fill: transparent;\n }\n .cds--cc--scatter circle.dot,\n .cds--cc--scatter circle.dot.hovered {\n padding: 10px;\n }\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled {\n stroke-width: 6px;\n transition: 0.1s all linear;\n }\n .cds--cc--scatter circle.dot {\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--scatter circle.dot.hovered {\n stroke-width: 0.5em;\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot.hovered {\n stroke-width: 15px;\n }\n .cds--cc--scatter-stacked circle.dot,\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.hovered {\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ", "\n )\n drop-shadow(\n -1px 0px 0px\n ", "\n )\n drop-shadow(\n 0px 1px 0px\n ", "\n )\n drop-shadow(\n 0px -1px 0px\n ", "\n );\n }\n .cds--cc--lollipop .cds--cc--scatter circle.dot.hovered {\n transition: 0.1s all linear;\n stroke-width: 1.1em;\n }\n\n .cds--cc--tooltip {\n ", "\n }\n\n .cds--overflow-menu-options__btn:focus {\n outline-color: ", ";\n }\n\n .cds--btn {\n min-height: auto;\n display: flex;\n flex: 0 auto;\n align-items: center;\n text-align: center;\n padding: 20px;\n margin: 0;\n line-height: ", ";\n margin: 0;\n min-width: ", ";\n overflow: hidden;\n position: relative;\n right: ", ";\n text-align: center;\n height: 40px;\n font-family: ", ";\n font-size: ", ";\n border-radius: ", ";\n font-weight: 500;\n }\n\n .cds--btn--primary {\n background: ", ";\n color: ", ";\n }\n\n *:focus {\n outline: 2px solid\n ", " !important;\n outline-offset: 0;\n }\n circle.dot:focus {\n outline: none !important;\n }\n .cds--overflow-menu-options__btn:focus,\n .cds--overflow-menu:focus,\n .cds--overflow-menu__trigger:focus,\n .toolbar-control:focus {\n outline: 2px solid\n ", " !important;\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):focus\n div.checkbox,\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n border: ", ";\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n box-shadow: 0 0 0 2px\n ", " !important;\n }\n\n .cds--btn--primary {\n &:focus {\n outline: 2px solid\n ", ";\n }\n outline-offset: 2px;\n border: none;\n box-shadow: none;\n }\n .cds--modal-header {\n background: ", ";\n margin-bottom: 0;\n border-bottom: 1px solid\n ", ";\n }\n .cds--modal-header__heading {\n font-weight: 600;\n }\n\n .cds--modal-close {\n position: absolute;\n top: 0;\n right: 0;\n &:focus {\n outline: 2px solid\n ", ";\n border-color: none;\n }\n outline-offset: 0;\n border: none;\n }\n }\n\n .cds--modal-footer.cds--modal-footer {\n display: flex;\n align-items: center;\n border-top: 1px solid\n ", ";\n background: ", " !important;\n }\n .layout-child.header {\n height: auto !important;\n p {\n text-overflow: inherit;\n overflow: auto;\n white-space: normal;\n }\n }\n\n &.has-magma-toolbar .cds--cc--title p.title {\n visibility: hidden;\n }\n\n svg:not(:root) {\n overflow: visible;\n }\n\n circle.dot:focus {\n outline: none;\n stroke: ", " !important;\n stroke-width: 6px !important;\n stroke-opacity: 1 !important;\n paint-order: stroke fill;\n }\n\n .cds--cc--chart-wrapper text {\n font-size: ", ";\n }\n\n g.center text,\n .pie-label {\n fill: ", ";\n }\n\n // Zoom responsive tweaks\n\n @media screen and (max-width: 760px) {\n .cds--modal-container {\n overflow-y: auto;\n }\n .cds--chart-holder .cds--modal .cds--modal-container .cds--modal-content {\n overflow: visible;\n }\n .cds--chart-holder\n .cds--modal\n .cds--modal-container\n .cds--modal-content\n table\n th {\n position: relative;\n }\n }\n"], ["\n .cds--cc--legend-fieldset {\n border: 0;\n margin: 0;\n min-inline-size: 0;\n padding: 0;\n }\n\n .cds--cc--legend-fieldset > legend {\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n position: absolute;\n top: auto;\n white-space: nowrap;\n width: 1px;\n }\n\n &:fullscreen,\n &:-webkit-full-screen {\n background: ",
|
|
2460
|
+
";\n\n .cds--chart-holder {\n height: 100vh !important;\n }\n }\n\n .cds--chart-holder.filled,\n .cds--chart-holder.filled .cds--cc--chart-wrapper {\n background-color: ",
|
|
2461
|
+
";\n }\n\n .cds--data-table thead tr th {\n background: ",
|
|
2462
|
+
" !important;\n }\n .cds--data-table td,\n .cds--data-table tbody th {\n color: ", ";\n }\n .cds--data-table tbody tr,\n .cds--data-table tbody tr td,\n .cds--data-table tbody tr th {\n color: ", ";\n }\n .cds--data-table tr {\n block-size: 2.5rem;\n }\n\n .cds--cc--tooltip .content-box .datapoint-tooltip p {\n font-size: ", ";\n padding: ", ";\n color: ",
|
|
2463
|
+
";\n max-width: 142px;\n white-space: normal;\n }\n\n .cds--modal-container {\n clip-path: inset(0% 0% 0% 0% round ", ");\n background: ",
|
|
2464
|
+
";\n .cds--data-table th {\n background: ",
|
|
2465
|
+
";\n }\n .cds--data-table td {\n border-top: 1px solid\n ",
|
|
2466
|
+
";\n border-bottom: 1px solid\n ",
|
|
2467
|
+
";\n background: ", ";\n }\n .cds--data-table tr:hover td {\n background: ",
|
|
2468
|
+
";\n }\n }\n\n .chart-holder p,\n .chart-holder div,\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--title p.title,\n .cds--cc--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ",
|
|
2469
|
+
";\n }\n\n .cds--cc--axes {\n overflow: visible;\n }\n\n div.cds--cc--legend {\n div.legend-item {\n div.checkbox {\n background: ",
|
|
2470
|
+
";\n border: none;\n width: ", ";\n height: ", ";\n svg {\n left: 2px;\n position: relative;\n }\n }\n p {\n font-size: ", ";\n margin: 0 ", " 0 0;\n }\n }\n }\n div.cds--cc--legend.has-deactivated-items {\n div.legend-item {\n div.checkbox {\n border: 1px solid\n ",
|
|
2471
|
+
";\n }\n div.checkbox.active {\n border: 1px solid transparent;\n }\n }\n }\n .chart-holder {\n .cds--cc--axes g.axis g.tick text {\n fill: ", ";\n }\n .cds--cc--axes g.axis path.domain {\n stroke: ",
|
|
2472
|
+
";\n }\n .cds--cc--grid g.x.grid g.tick line,\n .cds--cc--grid g.y.grid g.tick line {\n stroke: ",
|
|
2473
|
+
";\n }\n .cds--cc--grid rect.chart-grid-backdrop.stroked {\n stroke: ",
|
|
2474
|
+
";\n }\n .cds--cc--skeleton .shimmer-effect-lines {\n filter: ", ";\n }\n /* .chart-holder.cds--chart-holder.filled,\n .cds--cc--skeleton rect.chart-skeleton-backdrop,\n .cds--cc--grid rect.chart-grid-backdrop {\n } */\n\n .cds--cc--grid rect.chart-grid-backdrop {\n fill: transparent;\n }\n .cds--cc--scatter circle.dot,\n .cds--cc--scatter circle.dot.hovered {\n padding: 10px;\n }\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled {\n stroke-width: 6px;\n transition: 0.1s all linear;\n }\n .cds--cc--scatter circle.dot {\n filter: drop-shadow(\n 1px 0px 0px\n ",
|
|
2475
|
+
"\n )\n drop-shadow(\n -1px 0px 0px\n ",
|
|
2476
|
+
"\n )\n drop-shadow(\n 0px 1px 0px\n ",
|
|
2477
|
+
"\n )\n drop-shadow(\n 0px -1px 0px\n ",
|
|
2478
|
+
"\n );\n }\n .cds--cc--scatter circle.dot.hovered {\n stroke-width: 0.5em;\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ",
|
|
2479
|
+
"\n )\n drop-shadow(\n -1px 0px 0px\n ",
|
|
2480
|
+
"\n )\n drop-shadow(\n 0px 1px 0px\n ",
|
|
2481
|
+
"\n )\n drop-shadow(\n 0px -1px 0px\n ",
|
|
2482
|
+
"\n );\n }\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot.hovered {\n stroke-width: 15px;\n }\n .cds--cc--scatter-stacked circle.dot,\n .cds--cc--scatter-stacked circle.dot.hovered,\n .cds--cc--scatter-stacked circle.dot.unfilled,\n .cds--cc--scatter circle.dot.unfilled,\n .cds--cc--lollipop circle.dot.filled,\n .cds--cc--lollipop circle.dot,\n .cds--cc--lollipop circle.dot.hovered {\n transition: 0.1s all linear;\n filter: drop-shadow(\n 1px 0px 0px\n ",
|
|
2483
|
+
"\n )\n drop-shadow(\n -1px 0px 0px\n ",
|
|
2484
|
+
"\n )\n drop-shadow(\n 0px 1px 0px\n ",
|
|
2485
|
+
"\n )\n drop-shadow(\n 0px -1px 0px\n ",
|
|
2486
|
+
"\n );\n }\n .cds--cc--lollipop .cds--cc--scatter circle.dot.hovered {\n transition: 0.1s all linear;\n stroke-width: 1.1em;\n }\n\n .cds--cc--tooltip {\n ",
|
|
2487
|
+
"\n }\n\n .cds--overflow-menu-options__btn:focus {\n outline-color: ",
|
|
2488
|
+
";\n }\n\n .cds--btn {\n min-height: auto;\n display: flex;\n flex: 0 auto;\n align-items: center;\n text-align: center;\n padding: 20px;\n margin: 0;\n line-height: ", ";\n margin: 0;\n min-width: ", ";\n overflow: hidden;\n position: relative;\n right: ", ";\n text-align: center;\n height: 40px;\n font-family: ", ";\n font-size: ", ";\n border-radius: ", ";\n font-weight: 500;\n }\n\n .cds--btn--primary {\n background: ",
|
|
2489
|
+
";\n color: ", ";\n }\n\n *:focus {\n outline: 2px solid\n ",
|
|
2490
|
+
" !important;\n outline-offset: 0;\n }\n circle.dot:focus {\n outline: none !important;\n }\n .cds--overflow-menu-options__btn:focus,\n .cds--overflow-menu:focus,\n .cds--overflow-menu__trigger:focus,\n .toolbar-control:focus {\n outline: 2px solid\n ",
|
|
2491
|
+
" !important;\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):focus\n div.checkbox,\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n border: ",
|
|
2492
|
+
";\n }\n div.cds--cc--legend.clickable\n div.legend-item:not(.additional):hover\n div.checkbox {\n box-shadow: 0 0 0 2px\n ",
|
|
2493
|
+
" !important;\n }\n\n .cds--btn--primary {\n &:focus {\n outline: 2px solid\n ",
|
|
2494
|
+
";\n }\n outline-offset: 2px;\n border: none;\n box-shadow: none;\n }\n .cds--modal-header {\n background: ",
|
|
2495
|
+
";\n margin-bottom: 0;\n border-bottom: 1px solid\n ",
|
|
2496
|
+
";\n }\n .cds--modal-header__heading {\n font-weight: 600;\n }\n\n .cds--modal-close {\n position: absolute;\n top: 0;\n right: 0;\n &:focus {\n outline: 2px solid\n ",
|
|
2497
|
+
";\n border-color: none;\n }\n outline-offset: 0;\n border: none;\n }\n }\n\n .cds--modal-footer.cds--modal-footer {\n display: flex;\n align-items: center;\n border-top: 1px solid\n ",
|
|
2498
|
+
";\n background: ",
|
|
2499
|
+
" !important;\n }\n .layout-child.header {\n height: auto !important;\n p {\n text-overflow: inherit;\n overflow: auto;\n white-space: normal;\n }\n }\n\n &.has-magma-toolbar .cds--cc--title p.title {\n visibility: hidden;\n }\n\n svg:not(:root) {\n overflow: visible;\n }\n\n circle.dot:focus {\n outline: none;\n stroke: ",
|
|
2500
|
+
" !important;\n stroke-width: 6px !important;\n stroke-opacity: 1 !important;\n paint-order: stroke fill;\n }\n\n .cds--cc--chart-wrapper text {\n font-size: ", ";\n }\n\n g.center text,\n .pie-label {\n fill: ", ";\n }\n\n // Zoom responsive tweaks\n\n @media screen and (max-width: 760px) {\n .cds--modal-container {\n overflow-y: auto;\n }\n .cds--chart-holder .cds--modal .cds--modal-container .cds--modal-content {\n overflow: visible;\n }\n .cds--chart-holder\n .cds--modal\n .cds--modal-container\n .cds--modal-content\n table\n th {\n position: relative;\n }\n }\n"])), function (props) {
|
|
1116
2501
|
return props.isInverse
|
|
1117
2502
|
? props.theme.colors.primary700
|
|
1118
2503
|
: props.theme.colors.neutral100;
|
|
@@ -1132,11 +2517,11 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1132
2517
|
return props.isInverse ? props.theme.colors.primary600 : '';
|
|
1133
2518
|
}, function (props) {
|
|
1134
2519
|
return props.isInverse
|
|
1135
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2520
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1136
2521
|
: 'inherit';
|
|
1137
2522
|
}, function (props) {
|
|
1138
2523
|
return props.isInverse
|
|
1139
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2524
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1140
2525
|
: 'inherit';
|
|
1141
2526
|
}, function (props) { return (props.isInverse ? '#202565' : ''); }, function (props) {
|
|
1142
2527
|
return props.isInverse ? props.theme.colors.primary600 : '';
|
|
@@ -1156,7 +2541,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1156
2541
|
return props.isInverse ? props.theme.colors.neutral100 : '';
|
|
1157
2542
|
}, function (props) {
|
|
1158
2543
|
return props.isInverse
|
|
1159
|
-
? curriedTransparentize(0.5, props.theme.colors.neutral100)
|
|
2544
|
+
? curriedTransparentize$1(0.5, props.theme.colors.neutral100)
|
|
1160
2545
|
: '';
|
|
1161
2546
|
}, function (props) {
|
|
1162
2547
|
return props.isInverse ? props.theme.colors.neutral100 : '';
|
|
@@ -1214,9 +2599,8 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1214
2599
|
: props.theme.chartColors) || [];
|
|
1215
2600
|
return chartColors.reduce(function (result, color, index) {
|
|
1216
2601
|
var indexNum = index + 1;
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
return newResult;
|
|
2602
|
+
result += ".tooltip-" + props.groupsLength + "-1-" + indexNum + " { background-color: " + color + "; }";
|
|
2603
|
+
return result;
|
|
1220
2604
|
}, '');
|
|
1221
2605
|
}, function (props) {
|
|
1222
2606
|
return props.isInverse ? props.theme.colors.focusInverse : '';
|
|
@@ -1233,7 +2617,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1233
2617
|
? props.theme.colors.focusInverse
|
|
1234
2618
|
: props.theme.colors.focus;
|
|
1235
2619
|
}, function (props) {
|
|
1236
|
-
return props.isInverse ? "1px solid "
|
|
2620
|
+
return props.isInverse ? "1px solid " + props.theme.colors.focusInverse : '';
|
|
1237
2621
|
}, function (props) {
|
|
1238
2622
|
return props.isInverse
|
|
1239
2623
|
? props.theme.colors.focusInverse
|
|
@@ -1248,7 +2632,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1248
2632
|
: props.theme.colors.neutral100;
|
|
1249
2633
|
}, function (props) {
|
|
1250
2634
|
return props.isInverse
|
|
1251
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2635
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1252
2636
|
: props.theme.colors.neutral300;
|
|
1253
2637
|
}, function (props) {
|
|
1254
2638
|
return props.isInverse
|
|
@@ -1256,7 +2640,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1256
2640
|
: props.theme.colors.focus;
|
|
1257
2641
|
}, function (props) {
|
|
1258
2642
|
return props.isInverse
|
|
1259
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2643
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1260
2644
|
: props.theme.colors.neutral300;
|
|
1261
2645
|
}, function (props) {
|
|
1262
2646
|
return props.isInverse
|
|
@@ -1277,10 +2661,13 @@ var ChartTheme;
|
|
|
1277
2661
|
ChartTheme["G90"] = "g90";
|
|
1278
2662
|
ChartTheme["G10"] = "g10";
|
|
1279
2663
|
})(ChartTheme || (ChartTheme = {}));
|
|
1280
|
-
var ToolbarWrapper = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n justify-content: space-between;\n z-index: 2;\n\n ", "\n\n button {\n color: ", ";\n\n &:focus {\n outline: 2px solid\n ", ";\n outline-offset: 0;\n }\n }\n"], ["\n align-items: center;\n display: flex;\n justify-content: space-between;\n z-index: 2;\n\n ",
|
|
2664
|
+
var ToolbarWrapper = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n justify-content: space-between;\n z-index: 2;\n\n ", "\n\n button {\n color: ", ";\n\n &:focus {\n outline: 2px solid\n ", ";\n outline-offset: 0;\n }\n }\n"], ["\n align-items: center;\n display: flex;\n justify-content: space-between;\n z-index: 2;\n\n ",
|
|
2665
|
+
"\n\n button {\n color: ",
|
|
2666
|
+
";\n\n &:focus {\n outline: 2px solid\n ",
|
|
2667
|
+
";\n outline-offset: 0;\n }\n }\n"])), function (props) {
|
|
1281
2668
|
return props.isFlowLayout
|
|
1282
2669
|
? "\n position: relative;\n "
|
|
1283
|
-
: "\n left: "
|
|
2670
|
+
: "\n left: " + (props.isFullscreen ? '2em' : '0') + ";\n position: absolute;\n right: " + (props.isFullscreen ? '2em' : '0') + ";\n top: " + (props.isFullscreen ? '2em' : '0') + ";\n ";
|
|
1284
2671
|
}, function (props) {
|
|
1285
2672
|
return props.isInverse
|
|
1286
2673
|
? props.theme.colors.neutral100
|
|
@@ -1290,7 +2677,8 @@ var ToolbarWrapper = styled.div(templateObject_4 || (templateObject_4 = __makeTe
|
|
|
1290
2677
|
? props.theme.colors.focusInverse
|
|
1291
2678
|
: props.theme.colors.focus;
|
|
1292
2679
|
});
|
|
1293
|
-
var ChartTitle = styled.h2(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-family: ", " !important;\n font-size: 16px !important;\n font-weight: 700 !important;\n letter-spacing: normal !important;\n line-height: 1.25 !important;\n margin: 0 !important;\n color: ", " !important;\n"], ["\n font-family: ", " !important;\n font-size: 16px !important;\n font-weight: 700 !important;\n letter-spacing: normal !important;\n line-height: 1.25 !important;\n margin: 0 !important;\n color: ",
|
|
2680
|
+
var ChartTitle = styled.h2(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-family: ", " !important;\n font-size: 16px !important;\n font-weight: 700 !important;\n letter-spacing: normal !important;\n line-height: 1.25 !important;\n margin: 0 !important;\n color: ", " !important;\n"], ["\n font-family: ", " !important;\n font-size: 16px !important;\n font-weight: 700 !important;\n letter-spacing: normal !important;\n line-height: 1.25 !important;\n margin: 0 !important;\n color: ",
|
|
2681
|
+
" !important;\n"])), function (props) { return props.theme.bodyFont; }, function (props) {
|
|
1294
2682
|
return props.isInverse
|
|
1295
2683
|
? props.theme.colors.neutral100
|
|
1296
2684
|
: props.theme.colors.neutral700;
|
|
@@ -1302,7 +2690,7 @@ var ToolbarActions = styled.div(templateObject_9 || (templateObject_9 = __makeTe
|
|
|
1302
2690
|
function sanitizeCsvValue(value) {
|
|
1303
2691
|
var trimmed = value.trimStart();
|
|
1304
2692
|
if (/^[=+\-@\t\r]/.test(trimmed)) {
|
|
1305
|
-
return "'"
|
|
2693
|
+
return "'" + value;
|
|
1306
2694
|
}
|
|
1307
2695
|
return value;
|
|
1308
2696
|
}
|
|
@@ -1317,17 +2705,17 @@ function downloadCsv(dataSet, title) {
|
|
|
1317
2705
|
var v = row[k];
|
|
1318
2706
|
var s = sanitizeCsvValue(String(v !== null && v !== void 0 ? v : ''));
|
|
1319
2707
|
return s.includes(',') || s.includes('"') || s.includes('\n')
|
|
1320
|
-
? "\""
|
|
2708
|
+
? "\"" + s.replace(/"/g, '""') + "\""
|
|
1321
2709
|
: s;
|
|
1322
2710
|
})
|
|
1323
2711
|
.join(',');
|
|
1324
2712
|
});
|
|
1325
|
-
var csv =
|
|
2713
|
+
var csv = __spreadArrays([header], rows).join('\n');
|
|
1326
2714
|
var blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
1327
2715
|
var url = URL.createObjectURL(blob);
|
|
1328
2716
|
var a = document.createElement('a');
|
|
1329
2717
|
a.href = url;
|
|
1330
|
-
a.download =
|
|
2718
|
+
a.download = (title || 'chart-data') + ".csv";
|
|
1331
2719
|
a.click();
|
|
1332
2720
|
URL.revokeObjectURL(url);
|
|
1333
2721
|
}
|
|
@@ -1336,8 +2724,7 @@ function exportCarbonChartImage(chart, toolbarWrapper, format) {
|
|
|
1336
2724
|
var domUtils = (_a = chart === null || chart === void 0 ? void 0 : chart.services) === null || _a === void 0 ? void 0 : _a.domUtils;
|
|
1337
2725
|
if (!domUtils)
|
|
1338
2726
|
return;
|
|
1339
|
-
var magmaWrapper = (toolbarWrapper === null || toolbarWrapper === void 0 ? void 0 : toolbarWrapper.classList.contains('has-magma-toolbar'))
|
|
1340
|
-
? toolbarWrapper
|
|
2727
|
+
var magmaWrapper = (toolbarWrapper === null || toolbarWrapper === void 0 ? void 0 : toolbarWrapper.classList.contains('has-magma-toolbar')) ? toolbarWrapper
|
|
1341
2728
|
: null;
|
|
1342
2729
|
magmaWrapper === null || magmaWrapper === void 0 ? void 0 : magmaWrapper.classList.remove('has-magma-toolbar');
|
|
1343
2730
|
var restored = false;
|
|
@@ -1375,7 +2762,7 @@ var ALL_CHARTS = {
|
|
|
1375
2762
|
barGrouped: GroupedBarChart,
|
|
1376
2763
|
barStacked: StackedBarChart,
|
|
1377
2764
|
donut: DonutChart,
|
|
1378
|
-
line: LineChart,
|
|
2765
|
+
line: LineChart$1,
|
|
1379
2766
|
lollipop: LollipopChart,
|
|
1380
2767
|
pie: PieChart,
|
|
1381
2768
|
radar: RadarChart,
|
|
@@ -1418,11 +2805,11 @@ function CarbonChartToolbar(_a) {
|
|
|
1418
2805
|
return (React.createElement(ToolbarWrapper, { isFlowLayout: isFlowLayout, isFullscreen: isFullscreen, isInverse: isInverse, theme: theme },
|
|
1419
2806
|
React.createElement(TitleGroup, { theme: theme },
|
|
1420
2807
|
config.titlePrefix ? (React.createElement(TitleSlot, null, config.titlePrefix)) : null,
|
|
1421
|
-
React.createElement(ChartTitle, { as: "h"
|
|
2808
|
+
React.createElement(ChartTitle, { as: "h" + ((_b = config.titleLevel) !== null && _b !== void 0 ? _b : 2), isInverse: isInverse, theme: theme }, resolvedTitle),
|
|
1422
2809
|
config.titleSuffix ? (React.createElement(TitleSlot, null, config.titleSuffix)) : null),
|
|
1423
2810
|
React.createElement(ToolbarActions, { theme: theme },
|
|
1424
2811
|
showTable && (React.createElement(ChartTableButton, { ariaLabel: resolvedTitle, icon: React.createElement(TableIcon, { size: 20 }), isInverse: isInverse, isTableOpen: isTableOpen, onClick: onOpenTable })),
|
|
1425
|
-
showFullscreen && (React.createElement(ChartFullscreenButton, { ariaLabel:
|
|
2812
|
+
showFullscreen && (React.createElement(ChartFullscreenButton, { ariaLabel: (isFullscreen ? 'Exit' : 'View') + " " + resolvedTitle + " full screen", icon: React.createElement(FullscreenIcon, { size: 20 }), exitIcon: React.createElement(FullscreenExitIcon, { size: 20 }), isInverse: isInverse, isFullscreen: isFullscreen, onClick: onToggleFullscreen })),
|
|
1426
2813
|
React.createElement(ChartMoreOptionsButton, { icon: React.createElement(MoreVertIcon, { size: 20 }), isInverse: isInverse }, moreOptionsContent))));
|
|
1427
2814
|
}
|
|
1428
2815
|
var CarbonChart = React.forwardRef(function (props, ref) {
|
|
@@ -1478,7 +2865,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1478
2865
|
document.removeEventListener('fullscreenchange', onFullscreenChange);
|
|
1479
2866
|
// Restore height if the component unmounts while in fullscreen.
|
|
1480
2867
|
var chartHolder = (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.cds--chart-holder');
|
|
1481
|
-
if (chartHolder && document.fullscreenElement) {
|
|
2868
|
+
if (chartHolder && document.fullscreenElement && !isFlowLayout) {
|
|
1482
2869
|
chartHolder.style.height = savedHeightRef.current;
|
|
1483
2870
|
}
|
|
1484
2871
|
};
|
|
@@ -1507,7 +2894,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1507
2894
|
}
|
|
1508
2895
|
}, []);
|
|
1509
2896
|
var chartTitle = options.title || toolbarI18n.defaultTitle;
|
|
1510
|
-
var legendLabel =
|
|
2897
|
+
var legendLabel = (ariaLabel || chartTitle) + ". " + toolbarI18n.legendInstructions;
|
|
1511
2898
|
React.useEffect(function () {
|
|
1512
2899
|
var container = internalRef.current;
|
|
1513
2900
|
if (!container)
|
|
@@ -1629,8 +3016,8 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1629
3016
|
var colorScale = React.useMemo(function () {
|
|
1630
3017
|
var scaleColorsObj = {};
|
|
1631
3018
|
var customColors = options.colors || [];
|
|
1632
|
-
var allColors =
|
|
1633
|
-
var allInverseColors =
|
|
3019
|
+
var allColors = __spreadArrays(customColors, theme.chartColors);
|
|
3020
|
+
var allInverseColors = __spreadArrays(customColors, theme.chartColorsInverse);
|
|
1634
3021
|
var allGroups = dataSet.map(function (item) {
|
|
1635
3022
|
return 'group' in item ? item['group'] : null;
|
|
1636
3023
|
});
|
|
@@ -1660,11 +3047,28 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1660
3047
|
? {}
|
|
1661
3048
|
: { fileDownload: { fileName: chartTitle } })) : {}));
|
|
1662
3049
|
var ChartType = ALL_CHARTS[type];
|
|
3050
|
+
React.useEffect(function () {
|
|
3051
|
+
if (!ariaLabel)
|
|
3052
|
+
return;
|
|
3053
|
+
var rafId = requestAnimationFrame(function () {
|
|
3054
|
+
var _a;
|
|
3055
|
+
var svgEl = (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.graph-frame');
|
|
3056
|
+
if (!svgEl)
|
|
3057
|
+
return;
|
|
3058
|
+
svgEl.setAttribute('aria-label', ariaLabel);
|
|
3059
|
+
});
|
|
3060
|
+
return function () { return cancelAnimationFrame(rafId); };
|
|
3061
|
+
}, [ariaLabel]);
|
|
1663
3062
|
React.useEffect(function () {
|
|
1664
3063
|
var timer = setTimeout(function () {
|
|
1665
3064
|
if (internalRef.current) {
|
|
1666
3065
|
internalRef.current
|
|
1667
|
-
.querySelectorAll('g[aria-label]')
|
|
3066
|
+
.querySelectorAll('g.ruler[aria-label]')
|
|
3067
|
+
.forEach(function (g) {
|
|
3068
|
+
g.setAttribute('aria-hidden', 'true');
|
|
3069
|
+
});
|
|
3070
|
+
internalRef.current
|
|
3071
|
+
.querySelectorAll('g[aria-label]:not(.ruler)')
|
|
1668
3072
|
.forEach(function (g) {
|
|
1669
3073
|
var role = g.getAttribute('role');
|
|
1670
3074
|
if (!role) {
|
|
@@ -1678,6 +3082,24 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1678
3082
|
}, 0);
|
|
1679
3083
|
return function () { return clearTimeout(timer); };
|
|
1680
3084
|
}, [type, dataSet]);
|
|
3085
|
+
React.useEffect(function () {
|
|
3086
|
+
var container = internalRef.current;
|
|
3087
|
+
if (!container)
|
|
3088
|
+
return;
|
|
3089
|
+
var hideRulerFromAT = function () {
|
|
3090
|
+
container
|
|
3091
|
+
.querySelectorAll('g.ruler[aria-label]')
|
|
3092
|
+
.forEach(function (g) {
|
|
3093
|
+
if (!g.hasAttribute('aria-hidden')) {
|
|
3094
|
+
g.setAttribute('aria-hidden', 'true');
|
|
3095
|
+
}
|
|
3096
|
+
});
|
|
3097
|
+
};
|
|
3098
|
+
hideRulerFromAT();
|
|
3099
|
+
var observer = new MutationObserver(hideRulerFromAT);
|
|
3100
|
+
observer.observe(container, { childList: true, subtree: true });
|
|
3101
|
+
return function () { return observer.disconnect(); };
|
|
3102
|
+
}, [type, dataSet]);
|
|
1681
3103
|
React.useEffect(function () {
|
|
1682
3104
|
var wrapper = internalRef.current;
|
|
1683
3105
|
if (!wrapper)
|
|
@@ -1699,7 +3121,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1699
3121
|
// render, which still triggers this observer. Only announce when the
|
|
1700
3122
|
// selection actually changed, otherwise unrelated re-renders (e.g.
|
|
1701
3123
|
// the legend group announcement) cause phantom announcements.
|
|
1702
|
-
var selectionSignature =
|
|
3124
|
+
var selectionSignature = activeLabels.join('|') + "::" + allItems.length;
|
|
1703
3125
|
if (selectionSignatureRef.current === selectionSignature)
|
|
1704
3126
|
return;
|
|
1705
3127
|
var isFirstRun = selectionSignatureRef.current === undefined;
|
|
@@ -1709,7 +3131,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1709
3131
|
if (activeLabels.length === 1) {
|
|
1710
3132
|
if (!legendAnnouncedRef.current) {
|
|
1711
3133
|
legendAnnouncedRef.current = true;
|
|
1712
|
-
setLegendAnnouncement("Only "
|
|
3134
|
+
setLegendAnnouncement("Only " + activeLabels[0] + " is selected");
|
|
1713
3135
|
}
|
|
1714
3136
|
}
|
|
1715
3137
|
else if (activeLabels.length === allItems.length) {
|
|
@@ -1734,6 +3156,15 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1734
3156
|
var wrapper = internalRef.current;
|
|
1735
3157
|
if (!wrapper)
|
|
1736
3158
|
return;
|
|
3159
|
+
var stampDotTabIndex = function () {
|
|
3160
|
+
wrapper
|
|
3161
|
+
.querySelectorAll('circle.dot')
|
|
3162
|
+
.forEach(function (dot) {
|
|
3163
|
+
if (!dot.hasAttribute('tabindex')) {
|
|
3164
|
+
dot.setAttribute('tabindex', '0');
|
|
3165
|
+
}
|
|
3166
|
+
});
|
|
3167
|
+
};
|
|
1737
3168
|
var isDot = function (el) {
|
|
1738
3169
|
return el instanceof Element &&
|
|
1739
3170
|
el.nodeName.toLowerCase() === 'circle' &&
|
|
@@ -1743,7 +3174,6 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1743
3174
|
if (!isDot(e.target))
|
|
1744
3175
|
return;
|
|
1745
3176
|
var dot = e.target;
|
|
1746
|
-
dot.style.opacity = '1';
|
|
1747
3177
|
var _a = dot.getBoundingClientRect(), left = _a.left, top = _a.top, width = _a.width, height = _a.height;
|
|
1748
3178
|
var cx = left + width / 2;
|
|
1749
3179
|
var cy = top + height / 2;
|
|
@@ -1766,7 +3196,10 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1766
3196
|
if (!isDot(e.target))
|
|
1767
3197
|
return;
|
|
1768
3198
|
var dot = e.target;
|
|
1769
|
-
|
|
3199
|
+
// Keep tooltip context while Tab focus moves between chart points.
|
|
3200
|
+
if (isDot(e.relatedTarget)) {
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
1770
3203
|
dot.dispatchEvent(new MouseEvent('mouseout', { bubbles: true }));
|
|
1771
3204
|
};
|
|
1772
3205
|
var onKeyDown = function (e) {
|
|
@@ -1786,24 +3219,28 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1786
3219
|
}));
|
|
1787
3220
|
};
|
|
1788
3221
|
var rafId = requestAnimationFrame(function () {
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
3222
|
+
stampDotTabIndex();
|
|
3223
|
+
});
|
|
3224
|
+
var dotObserver = new MutationObserver(function () {
|
|
3225
|
+
stampDotTabIndex();
|
|
3226
|
+
});
|
|
3227
|
+
dotObserver.observe(wrapper, {
|
|
3228
|
+
childList: true,
|
|
3229
|
+
subtree: true,
|
|
3230
|
+
attributes: true,
|
|
3231
|
+
attributeFilter: ['class', 'style', 'tabindex'],
|
|
1796
3232
|
});
|
|
1797
3233
|
wrapper.addEventListener('focusin', onFocusIn);
|
|
1798
3234
|
wrapper.addEventListener('focusout', onFocusOut);
|
|
1799
3235
|
wrapper.addEventListener('keydown', onKeyDown);
|
|
1800
3236
|
return function () {
|
|
1801
3237
|
cancelAnimationFrame(rafId);
|
|
3238
|
+
dotObserver.disconnect();
|
|
1802
3239
|
wrapper.removeEventListener('focusin', onFocusIn);
|
|
1803
3240
|
wrapper.removeEventListener('focusout', onFocusOut);
|
|
1804
3241
|
wrapper.removeEventListener('keydown', onKeyDown);
|
|
1805
3242
|
};
|
|
1806
|
-
}, [type]);
|
|
3243
|
+
}, [type, dataSet]);
|
|
1807
3244
|
var groupsLength = Object.keys(colorScale).length;
|
|
1808
3245
|
var showTable = (chartToolbar === null || chartToolbar === void 0 ? void 0 : chartToolbar.showAsTable) !== false;
|
|
1809
3246
|
if (!ChartType)
|
|
@@ -1813,7 +3250,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1813
3250
|
React.createElement(Announce, null, legendAnnouncement)),
|
|
1814
3251
|
React.createElement(VisuallyHidden, null,
|
|
1815
3252
|
React.createElement("div", { "aria-live": "polite", ref: legendGroupAnnounceRef })),
|
|
1816
|
-
React.createElement(CarbonChartWrapper, __assign({ "data-testid": testId, isInverse: isInverse, theme: theme, className: "carbon-chart-wrapper"
|
|
3253
|
+
React.createElement(CarbonChartWrapper, __assign({ "data-testid": testId, isInverse: isInverse, theme: theme, className: "carbon-chart-wrapper" + (chartToolbar ? ' has-magma-toolbar' : ''), groupsLength: groupsLength < 6 ? groupsLength : 14, role: "region", "aria-label": ariaLabel || chartTitle, "aria-roledescription": "chart" }, rest),
|
|
1817
3254
|
React.createElement(ChartContentWrapper, { className: "carbon-chart-content" },
|
|
1818
3255
|
chartToolbar && (
|
|
1819
3256
|
/*
|
|
@@ -1830,5 +3267,5 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1830
3267
|
});
|
|
1831
3268
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
1832
3269
|
|
|
1833
|
-
export { CarbonChart, CarbonChartType, ChartDataTable, ChartFullscreenButton, ChartMoreOptionsButton, ChartTableButton, ChartTableModal, ChartToolbar, useChartToolbarI18n };
|
|
3270
|
+
export { CarbonChart, CarbonChartType, Chart, ChartDataTable, ChartFullscreenButton, ChartMoreOptionsButton, ChartTableButton, ChartTableModal, ChartToolbar, useChartToolbarI18n };
|
|
1834
3271
|
//# sourceMappingURL=charts.modern.module.js.map
|