@react-magma/charts 16.0.0-next.1 → 16.0.0-v6-next.3
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 +1517 -114
- package/dist/charts.js.map +1 -1
- package/dist/charts.modern.module.js +1519 -117
- package/dist/charts.modern.module.js.map +1 -1
- package/dist/charts.umd.js +49860 -28910
- 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 +21 -24
- package/src/components/CarbonChart/CarbonChart.test.js +257 -173
- package/src/components/CarbonChart/CarbonChart.tsx +44 -39
- 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
|
@@ -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, ButtonColor, 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,66 +1291,124 @@ 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;
|
|
607
|
-
|
|
608
1324
|
var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
|
609
|
-
|
|
610
1325
|
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
611
|
-
|
|
612
1326
|
if (!_hslRgbMatched) {
|
|
613
1327
|
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
614
1328
|
}
|
|
615
|
-
|
|
616
1329
|
return {
|
|
617
1330
|
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
618
1331
|
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
619
1332
|
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
620
|
-
alpha: parseFloat("" + hslaMatched[4])
|
|
1333
|
+
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
621
1334
|
};
|
|
622
1335
|
}
|
|
623
|
-
|
|
624
1336
|
throw new PolishedError(5);
|
|
625
1337
|
}
|
|
626
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
|
+
|
|
627
1412
|
/**
|
|
628
1413
|
* Reduces hex values if possible e.g. #ff8866 to #f86
|
|
629
1414
|
* @private
|
|
@@ -632,15 +1417,88 @@ var reduceHexValue = function reduceHexValue(value) {
|
|
|
632
1417
|
if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
633
1418
|
return "#" + value[1] + value[3] + value[5];
|
|
634
1419
|
}
|
|
635
|
-
|
|
636
1420
|
return value;
|
|
637
1421
|
};
|
|
1422
|
+
var reduceHexValue$1 = reduceHexValue;
|
|
638
1423
|
|
|
639
1424
|
function numberToHex(value) {
|
|
640
1425
|
var hex = value.toString(16);
|
|
641
1426
|
return hex.length === 1 ? "0" + hex : hex;
|
|
642
1427
|
}
|
|
643
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
|
+
|
|
644
1502
|
/**
|
|
645
1503
|
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
646
1504
|
*
|
|
@@ -666,11 +1524,10 @@ function numberToHex(value) {
|
|
|
666
1524
|
*/
|
|
667
1525
|
function rgb(value, green, blue) {
|
|
668
1526
|
if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
|
|
669
|
-
return reduceHexValue("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
1527
|
+
return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
670
1528
|
} else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
|
671
|
-
return reduceHexValue("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
1529
|
+
return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
672
1530
|
}
|
|
673
|
-
|
|
674
1531
|
throw new PolishedError(6);
|
|
675
1532
|
}
|
|
676
1533
|
|
|
@@ -712,10 +1569,62 @@ function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
|
|
712
1569
|
if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
713
1570
|
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
714
1571
|
}
|
|
715
|
-
|
|
716
1572
|
throw new PolishedError(7);
|
|
717
1573
|
}
|
|
718
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
|
+
|
|
719
1628
|
// Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
|
|
720
1629
|
// eslint-disable-next-line no-unused-vars
|
|
721
1630
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -726,18 +1635,453 @@ function curried(f, length, acc) {
|
|
|
726
1635
|
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
727
1636
|
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
728
1637
|
};
|
|
729
|
-
}
|
|
730
|
-
|
|
1638
|
+
}
|
|
731
1639
|
|
|
1640
|
+
// eslint-disable-next-line no-redeclare
|
|
732
1641
|
function curry(f) {
|
|
733
1642
|
// eslint-disable-line no-redeclare
|
|
734
1643
|
return curried(f, f.length, []);
|
|
735
1644
|
}
|
|
736
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
|
+
|
|
737
1681
|
function guard(lowerBoundary, upperBoundary, value) {
|
|
738
1682
|
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
739
1683
|
}
|
|
740
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
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// prettier-ignore
|
|
1752
|
+
curry /* ::<number | string, string, string> */(desaturate);
|
|
1753
|
+
|
|
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
|
+
}
|
|
1784
|
+
|
|
1785
|
+
// prettier-ignore
|
|
1786
|
+
curry /* ::<number | string, string, string> */(lighten);
|
|
1787
|
+
|
|
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
|
+
});
|
|
1826
|
+
|
|
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);
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
// prettier-ignore
|
|
1845
|
+
var curriedMix = curry /* ::<number | string, string, string, string> */(mix);
|
|
1846
|
+
var mix$1 = curriedMix;
|
|
1847
|
+
|
|
1848
|
+
/**
|
|
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
|
+
* }
|
|
1874
|
+
*/
|
|
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
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// prettier-ignore
|
|
1886
|
+
curry /* ::<number | string, string, string> */(opacify);
|
|
1887
|
+
|
|
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
|
+
}));
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
// prettier-ignore
|
|
1922
|
+
curry /* ::<number | string, string, string> */(saturate);
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Sets the hue of a color to the provided value. The hue range can be
|
|
1926
|
+
* from 0 and 359.
|
|
1927
|
+
*
|
|
1928
|
+
* @example
|
|
1929
|
+
* // Styles as object usage
|
|
1930
|
+
* const styles = {
|
|
1931
|
+
* background: setHue(42, '#CCCD64'),
|
|
1932
|
+
* background: setHue('244', 'rgba(204,205,100,0.7)'),
|
|
1933
|
+
* }
|
|
1934
|
+
*
|
|
1935
|
+
* // styled-components usage
|
|
1936
|
+
* const div = styled.div`
|
|
1937
|
+
* background: ${setHue(42, '#CCCD64')};
|
|
1938
|
+
* background: ${setHue('244', 'rgba(204,205,100,0.7)')};
|
|
1939
|
+
* `
|
|
1940
|
+
*
|
|
1941
|
+
* // CSS in JS Output
|
|
1942
|
+
* element {
|
|
1943
|
+
* background: "#cdae64";
|
|
1944
|
+
* background: "rgba(107,100,205,0.7)";
|
|
1945
|
+
* }
|
|
1946
|
+
*/
|
|
1947
|
+
function setHue(hue, color) {
|
|
1948
|
+
if (color === 'transparent') return color;
|
|
1949
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
1950
|
+
hue: parseFloat(hue)
|
|
1951
|
+
}));
|
|
1952
|
+
}
|
|
1953
|
+
|
|
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
|
+
}));
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
// prettier-ignore
|
|
1988
|
+
curry /* ::<number | string, string, string> */(setLightness);
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* Sets the saturation of a color to the provided value. The saturation range can be
|
|
1992
|
+
* from 0 and 1.
|
|
1993
|
+
*
|
|
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.
|
|
2027
|
+
*
|
|
2028
|
+
* @example
|
|
2029
|
+
* // Styles as object usage
|
|
2030
|
+
* const styles = {
|
|
2031
|
+
* background: shade(0.25, '#00f')
|
|
2032
|
+
* }
|
|
2033
|
+
*
|
|
2034
|
+
* // styled-components usage
|
|
2035
|
+
* const div = styled.div`
|
|
2036
|
+
* background: ${shade(0.25, '#00f')};
|
|
2037
|
+
* `
|
|
2038
|
+
*
|
|
2039
|
+
* // CSS in JS Output
|
|
2040
|
+
*
|
|
2041
|
+
* element {
|
|
2042
|
+
* background: "#00003f";
|
|
2043
|
+
* }
|
|
2044
|
+
*/
|
|
2045
|
+
|
|
2046
|
+
function shade(percentage, color) {
|
|
2047
|
+
if (color === 'transparent') return color;
|
|
2048
|
+
return mix$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
// prettier-ignore
|
|
2052
|
+
curry /* ::<number | string, string, string> */(shade);
|
|
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
|
+
*/
|
|
2076
|
+
|
|
2077
|
+
function tint(percentage, color) {
|
|
2078
|
+
if (color === 'transparent') return color;
|
|
2079
|
+
return mix$1(parseFloat(percentage), 'rgb(255, 255, 255)', color);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// prettier-ignore
|
|
2083
|
+
curry /* ::<number | string, string, string> */(tint);
|
|
2084
|
+
|
|
741
2085
|
/**
|
|
742
2086
|
* Decreases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
743
2087
|
*
|
|
@@ -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.brand.navy;
|
|
@@ -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.indigo700
|
|
1109
2453
|
: props.theme.colors.neutral100;
|
|
@@ -1112,7 +2456,52 @@ 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 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--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ", ";\n }\n\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--axes g.axis g.tick text {\n fill: ", " !important;\n }\n\n .cds--cc--title p.title {\n color: ", " !important;\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 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--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ", ";\n }\n\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--axes g.axis g.tick text {\n fill: ", " !important;\n }\n\n .cds--cc--title p.title {\n color: ", " !important;\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 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--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ", ";\n }\n\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--axes g.axis g.tick text {\n fill: ", " !important;\n }\n\n .cds--cc--title p.title {\n color: ", " !important;\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 th {\n color: ",
|
|
2463
|
+
";\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: ",
|
|
2464
|
+
";\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: ",
|
|
2465
|
+
";\n .cds--data-table th {\n background: ",
|
|
2466
|
+
";\n }\n .cds--data-table td {\n border-top: 1px solid\n ",
|
|
2467
|
+
";\n border-bottom: 1px solid\n ",
|
|
2468
|
+
";\n background: ", ";\n }\n .cds--data-table tr:hover td {\n background: ",
|
|
2469
|
+
";\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--axes g.axis g.tick text {\n font-family: ", " !important;\n color: ",
|
|
2470
|
+
";\n }\n\n .chart-holder text,\n .cds--cc--axes g.axis .axis-title,\n .cds--cc--axes g.axis g.tick text {\n fill: ",
|
|
2471
|
+
" !important;\n }\n\n .cds--cc--title p.title {\n color: ",
|
|
2472
|
+
" !important;\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: ",
|
|
2473
|
+
";\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 ",
|
|
2474
|
+
";\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: ",
|
|
2475
|
+
";\n }\n .cds--cc--grid g.x.grid g.tick line,\n .cds--cc--grid g.y.grid g.tick line {\n stroke: ",
|
|
2476
|
+
";\n }\n .cds--cc--grid rect.chart-grid-backdrop.stroked {\n stroke: ",
|
|
2477
|
+
";\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 ",
|
|
2478
|
+
"\n )\n drop-shadow(\n -1px 0px 0px\n ",
|
|
2479
|
+
"\n )\n drop-shadow(\n 0px 1px 0px\n ",
|
|
2480
|
+
"\n )\n drop-shadow(\n 0px -1px 0px\n ",
|
|
2481
|
+
"\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 ",
|
|
2482
|
+
"\n )\n drop-shadow(\n -1px 0px 0px\n ",
|
|
2483
|
+
"\n )\n drop-shadow(\n 0px 1px 0px\n ",
|
|
2484
|
+
"\n )\n drop-shadow(\n 0px -1px 0px\n ",
|
|
2485
|
+
"\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 ",
|
|
2486
|
+
"\n )\n drop-shadow(\n -1px 0px 0px\n ",
|
|
2487
|
+
"\n )\n drop-shadow(\n 0px 1px 0px\n ",
|
|
2488
|
+
"\n )\n drop-shadow(\n 0px -1px 0px\n ",
|
|
2489
|
+
"\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 ",
|
|
2490
|
+
"\n }\n\n .cds--overflow-menu-options__btn:focus {\n outline-color: ",
|
|
2491
|
+
";\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: ",
|
|
2492
|
+
";\n color: ", ";\n }\n\n *:focus {\n outline: 2px solid\n ",
|
|
2493
|
+
" !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 ",
|
|
2494
|
+
" !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: ",
|
|
2495
|
+
";\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 ",
|
|
2496
|
+
" !important;\n }\n\n .cds--btn--primary {\n &:focus {\n outline: 2px solid\n ",
|
|
2497
|
+
";\n }\n outline-offset: 2px;\n border: none;\n box-shadow: none;\n }\n .cds--modal-header {\n background: ",
|
|
2498
|
+
";\n margin-bottom: 0;\n border-bottom: 1px solid\n ",
|
|
2499
|
+
";\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 ",
|
|
2500
|
+
";\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 ",
|
|
2501
|
+
";\n background: ",
|
|
2502
|
+
" !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: ",
|
|
2503
|
+
" !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: ",
|
|
2504
|
+
";\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
2505
|
return props.isInverse
|
|
1117
2506
|
? props.theme.colors.indigo700
|
|
1118
2507
|
: props.theme.colors.neutral100;
|
|
@@ -1136,11 +2525,11 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1136
2525
|
return props.isInverse ? props.theme.colors.indigo600 : '';
|
|
1137
2526
|
}, function (props) {
|
|
1138
2527
|
return props.isInverse
|
|
1139
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2528
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1140
2529
|
: 'inherit';
|
|
1141
2530
|
}, function (props) {
|
|
1142
2531
|
return props.isInverse
|
|
1143
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2532
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1144
2533
|
: 'inherit';
|
|
1145
2534
|
}, function (props) { return (props.isInverse ? '#202565' : ''); }, function (props) {
|
|
1146
2535
|
return props.isInverse ? props.theme.colors.indigo600 : '';
|
|
@@ -1168,7 +2557,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1168
2557
|
return props.isInverse ? props.theme.colors.neutral100 : '';
|
|
1169
2558
|
}, function (props) {
|
|
1170
2559
|
return props.isInverse
|
|
1171
|
-
? curriedTransparentize(0.5, props.theme.colors.neutral100)
|
|
2560
|
+
? curriedTransparentize$1(0.5, props.theme.colors.neutral100)
|
|
1172
2561
|
: '';
|
|
1173
2562
|
}, function (props) {
|
|
1174
2563
|
return props.isInverse ? props.theme.colors.neutral100 : '';
|
|
@@ -1226,9 +2615,8 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1226
2615
|
: props.theme.chartColors) || [];
|
|
1227
2616
|
return chartColors.reduce(function (result, color, index) {
|
|
1228
2617
|
var indexNum = index + 1;
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
return newResult;
|
|
2618
|
+
result += ".tooltip-" + props.groupsLength + "-1-" + indexNum + " { background-color: " + color + "; }";
|
|
2619
|
+
return result;
|
|
1232
2620
|
}, '');
|
|
1233
2621
|
}, function (props) {
|
|
1234
2622
|
return props.isInverse ? props.theme.colors.focusInverse : '';
|
|
@@ -1245,7 +2633,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1245
2633
|
? props.theme.colors.focusInverse
|
|
1246
2634
|
: props.theme.colors.focus;
|
|
1247
2635
|
}, function (props) {
|
|
1248
|
-
return props.isInverse ? "1px solid "
|
|
2636
|
+
return props.isInverse ? "1px solid " + props.theme.colors.focusInverse : '';
|
|
1249
2637
|
}, function (props) {
|
|
1250
2638
|
return props.isInverse
|
|
1251
2639
|
? props.theme.colors.focusInverse
|
|
@@ -1260,7 +2648,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1260
2648
|
: props.theme.colors.neutral100;
|
|
1261
2649
|
}, function (props) {
|
|
1262
2650
|
return props.isInverse
|
|
1263
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2651
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1264
2652
|
: props.theme.colors.neutral300;
|
|
1265
2653
|
}, function (props) {
|
|
1266
2654
|
return props.isInverse
|
|
@@ -1268,7 +2656,7 @@ var CarbonChartWrapper = styled.div(templateObject_3 || (templateObject_3 = __ma
|
|
|
1268
2656
|
: props.theme.colors.focus;
|
|
1269
2657
|
}, function (props) {
|
|
1270
2658
|
return props.isInverse
|
|
1271
|
-
? curriedTransparentize(0.8, props.theme.colors.neutral100)
|
|
2659
|
+
? curriedTransparentize$1(0.8, props.theme.colors.neutral100)
|
|
1272
2660
|
: props.theme.colors.neutral300;
|
|
1273
2661
|
}, function (props) {
|
|
1274
2662
|
return props.isInverse
|
|
@@ -1293,12 +2681,14 @@ var ChartTheme;
|
|
|
1293
2681
|
ChartTheme["G90"] = "g90";
|
|
1294
2682
|
ChartTheme["G10"] = "g10";
|
|
1295
2683
|
})(ChartTheme || (ChartTheme = {}));
|
|
1296
|
-
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 align-items: center;\n display: flex;\n justify-content: space-between;\n z-index: 2;\n\n ",
|
|
2684
|
+
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 align-items: center;\n display: flex;\n justify-content: space-between;\n z-index: 2;\n\n ",
|
|
2685
|
+
"\n"])), function (props) {
|
|
1297
2686
|
return props.isFlowLayout
|
|
1298
2687
|
? "\n position: relative;\n "
|
|
1299
|
-
: "\n left: "
|
|
2688
|
+
: "\n left: " + (props.isFullscreen ? '2em' : '0') + ";\n position: absolute;\n right: " + (props.isFullscreen ? '2em' : '0') + ";\n top: " + (props.isFullscreen ? '2em' : '0') + ";\n ";
|
|
1300
2689
|
});
|
|
1301
|
-
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: ",
|
|
2690
|
+
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: ",
|
|
2691
|
+
" !important;\n"])), function (props) { return props.theme.bodyFont; }, function (props) {
|
|
1302
2692
|
return props.isInverse
|
|
1303
2693
|
? props.theme.colors.neutral100
|
|
1304
2694
|
: props.theme.colors.brand.navy;
|
|
@@ -1310,7 +2700,7 @@ var ToolbarActions = styled.div(templateObject_9 || (templateObject_9 = __makeTe
|
|
|
1310
2700
|
function sanitizeCsvValue(value) {
|
|
1311
2701
|
var trimmed = value.trimStart();
|
|
1312
2702
|
if (/^[=+\-@\t\r]/.test(trimmed)) {
|
|
1313
|
-
return "'"
|
|
2703
|
+
return "'" + value;
|
|
1314
2704
|
}
|
|
1315
2705
|
return value;
|
|
1316
2706
|
}
|
|
@@ -1325,17 +2715,17 @@ function downloadCsv(dataSet, title) {
|
|
|
1325
2715
|
var v = row[k];
|
|
1326
2716
|
var s = sanitizeCsvValue(String(v !== null && v !== void 0 ? v : ''));
|
|
1327
2717
|
return s.includes(',') || s.includes('"') || s.includes('\n')
|
|
1328
|
-
? "\""
|
|
2718
|
+
? "\"" + s.replace(/"/g, '""') + "\""
|
|
1329
2719
|
: s;
|
|
1330
2720
|
})
|
|
1331
2721
|
.join(',');
|
|
1332
2722
|
});
|
|
1333
|
-
var csv =
|
|
2723
|
+
var csv = __spreadArrays([header], rows).join('\n');
|
|
1334
2724
|
var blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
1335
2725
|
var url = URL.createObjectURL(blob);
|
|
1336
2726
|
var a = document.createElement('a');
|
|
1337
2727
|
a.href = url;
|
|
1338
|
-
a.download =
|
|
2728
|
+
a.download = (title || 'chart-data') + ".csv";
|
|
1339
2729
|
a.click();
|
|
1340
2730
|
URL.revokeObjectURL(url);
|
|
1341
2731
|
}
|
|
@@ -1344,8 +2734,7 @@ function exportCarbonChartImage(chart, toolbarWrapper, format) {
|
|
|
1344
2734
|
var domUtils = (_a = chart === null || chart === void 0 ? void 0 : chart.services) === null || _a === void 0 ? void 0 : _a.domUtils;
|
|
1345
2735
|
if (!domUtils)
|
|
1346
2736
|
return;
|
|
1347
|
-
var magmaWrapper = (toolbarWrapper === null || toolbarWrapper === void 0 ? void 0 : toolbarWrapper.classList.contains('has-magma-toolbar'))
|
|
1348
|
-
? toolbarWrapper
|
|
2737
|
+
var magmaWrapper = (toolbarWrapper === null || toolbarWrapper === void 0 ? void 0 : toolbarWrapper.classList.contains('has-magma-toolbar')) ? toolbarWrapper
|
|
1349
2738
|
: null;
|
|
1350
2739
|
magmaWrapper === null || magmaWrapper === void 0 ? void 0 : magmaWrapper.classList.remove('has-magma-toolbar');
|
|
1351
2740
|
var restored = false;
|
|
@@ -1383,7 +2772,7 @@ var ALL_CHARTS = {
|
|
|
1383
2772
|
barGrouped: GroupedBarChart,
|
|
1384
2773
|
barStacked: StackedBarChart,
|
|
1385
2774
|
donut: DonutChart,
|
|
1386
|
-
line: LineChart,
|
|
2775
|
+
line: LineChart$1,
|
|
1387
2776
|
lollipop: LollipopChart,
|
|
1388
2777
|
pie: PieChart,
|
|
1389
2778
|
radar: RadarChart,
|
|
@@ -1426,11 +2815,11 @@ function CarbonChartToolbar(_a) {
|
|
|
1426
2815
|
return (React.createElement(ToolbarWrapper, { isFlowLayout: isFlowLayout, isFullscreen: isFullscreen, isInverse: isInverse, theme: theme },
|
|
1427
2816
|
React.createElement(TitleGroup, { theme: theme },
|
|
1428
2817
|
config.titlePrefix ? (React.createElement(TitleSlot, null, config.titlePrefix)) : null,
|
|
1429
|
-
React.createElement(ChartTitle, { as: "h"
|
|
2818
|
+
React.createElement(ChartTitle, { as: "h" + ((_b = config.titleLevel) !== null && _b !== void 0 ? _b : 2), isInverse: isInverse, theme: theme }, resolvedTitle),
|
|
1430
2819
|
config.titleSuffix ? (React.createElement(TitleSlot, null, config.titleSuffix)) : null),
|
|
1431
2820
|
React.createElement(ToolbarActions, { theme: theme },
|
|
1432
2821
|
showTable && (React.createElement(ChartTableButton, { ariaLabel: resolvedTitle, icon: React.createElement(TableIcon, { size: 20 }), isInverse: isInverse, isTableOpen: isTableOpen, onClick: onOpenTable })),
|
|
1433
|
-
showFullscreen && (React.createElement(ChartFullscreenButton, { ariaLabel:
|
|
2822
|
+
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 })),
|
|
1434
2823
|
React.createElement(ChartMoreOptionsButton, { icon: React.createElement(MoreVertIcon, { size: 20 }), isInverse: isInverse }, moreOptionsContent))));
|
|
1435
2824
|
}
|
|
1436
2825
|
var CarbonChart = React.forwardRef(function (props, ref) {
|
|
@@ -1486,7 +2875,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1486
2875
|
document.removeEventListener('fullscreenchange', onFullscreenChange);
|
|
1487
2876
|
// Restore height if the component unmounts while in fullscreen.
|
|
1488
2877
|
var chartHolder = (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.cds--chart-holder');
|
|
1489
|
-
if (chartHolder && document.fullscreenElement) {
|
|
2878
|
+
if (chartHolder && document.fullscreenElement && !isFlowLayout) {
|
|
1490
2879
|
chartHolder.style.height = savedHeightRef.current;
|
|
1491
2880
|
}
|
|
1492
2881
|
};
|
|
@@ -1515,7 +2904,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1515
2904
|
}
|
|
1516
2905
|
}, []);
|
|
1517
2906
|
var chartTitle = options.title || toolbarI18n.defaultTitle;
|
|
1518
|
-
var legendLabel =
|
|
2907
|
+
var legendLabel = (ariaLabel || chartTitle) + ". " + toolbarI18n.legendInstructions;
|
|
1519
2908
|
React.useEffect(function () {
|
|
1520
2909
|
var container = internalRef.current;
|
|
1521
2910
|
if (!container)
|
|
@@ -1637,8 +3026,8 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1637
3026
|
var colorScale = React.useMemo(function () {
|
|
1638
3027
|
var scaleColorsObj = {};
|
|
1639
3028
|
var customColors = options.colors || [];
|
|
1640
|
-
var allColors =
|
|
1641
|
-
var allInverseColors =
|
|
3029
|
+
var allColors = __spreadArrays(customColors, theme.chartColors);
|
|
3030
|
+
var allInverseColors = __spreadArrays(customColors, theme.chartColorsInverse);
|
|
1642
3031
|
var allGroups = dataSet.map(function (item) {
|
|
1643
3032
|
return 'group' in item ? item['group'] : null;
|
|
1644
3033
|
});
|
|
@@ -1659,15 +3048,28 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1659
3048
|
theme.chartColorsInverse,
|
|
1660
3049
|
isInverse,
|
|
1661
3050
|
]);
|
|
1662
|
-
var
|
|
3051
|
+
var hasChartToolbar = Boolean(chartToolbar);
|
|
3052
|
+
var newOptions = React.useMemo(function () { return (__assign(__assign(__assign({}, options), { theme: isInverse ? ChartTheme.G100 : ChartTheme.WHITE, color: {
|
|
1663
3053
|
scale: colorScale,
|
|
1664
3054
|
}, tooltip: __assign(__assign({}, ((options === null || options === void 0 ? void 0 : options.tooltip) || {})), { truncation: {
|
|
1665
3055
|
type: 'none',
|
|
1666
|
-
} }) }), (
|
|
3056
|
+
} }) }), (hasChartToolbar
|
|
1667
3057
|
? __assign({ toolbar: { enabled: false }, title: chartTitle }, (options.fileDownload
|
|
1668
3058
|
? {}
|
|
1669
|
-
: { fileDownload: { fileName: chartTitle } })) : {}));
|
|
3059
|
+
: { fileDownload: { fileName: chartTitle } })) : {}))); }, [options, isInverse, colorScale, hasChartToolbar, chartTitle]);
|
|
1670
3060
|
var ChartType = ALL_CHARTS[type];
|
|
3061
|
+
React.useEffect(function () {
|
|
3062
|
+
if (!ariaLabel)
|
|
3063
|
+
return;
|
|
3064
|
+
var rafId = requestAnimationFrame(function () {
|
|
3065
|
+
var _a;
|
|
3066
|
+
var svgEl = (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.graph-frame');
|
|
3067
|
+
if (!svgEl)
|
|
3068
|
+
return;
|
|
3069
|
+
svgEl.setAttribute('aria-label', ariaLabel);
|
|
3070
|
+
});
|
|
3071
|
+
return function () { return cancelAnimationFrame(rafId); };
|
|
3072
|
+
}, [ariaLabel]);
|
|
1671
3073
|
React.useEffect(function () {
|
|
1672
3074
|
var timer = setTimeout(function () {
|
|
1673
3075
|
if (internalRef.current) {
|
|
@@ -1730,7 +3132,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1730
3132
|
// render, which still triggers this observer. Only announce when the
|
|
1731
3133
|
// selection actually changed, otherwise unrelated re-renders (e.g.
|
|
1732
3134
|
// the legend group announcement) cause phantom announcements.
|
|
1733
|
-
var selectionSignature =
|
|
3135
|
+
var selectionSignature = activeLabels.join('|') + "::" + allItems.length;
|
|
1734
3136
|
if (selectionSignatureRef.current === selectionSignature)
|
|
1735
3137
|
return;
|
|
1736
3138
|
var isFirstRun = selectionSignatureRef.current === undefined;
|
|
@@ -1740,7 +3142,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1740
3142
|
if (activeLabels.length === 1) {
|
|
1741
3143
|
if (!legendAnnouncedRef.current) {
|
|
1742
3144
|
legendAnnouncedRef.current = true;
|
|
1743
|
-
setLegendAnnouncement("Only "
|
|
3145
|
+
setLegendAnnouncement("Only " + activeLabels[0] + " is selected");
|
|
1744
3146
|
}
|
|
1745
3147
|
}
|
|
1746
3148
|
else if (activeLabels.length === allItems.length) {
|
|
@@ -1859,7 +3261,7 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1859
3261
|
React.createElement(Announce, null, legendAnnouncement)),
|
|
1860
3262
|
React.createElement(VisuallyHidden, null,
|
|
1861
3263
|
React.createElement("div", { "aria-live": "polite", ref: legendGroupAnnounceRef })),
|
|
1862
|
-
React.createElement(CarbonChartWrapper, __assign({ "data-testid": testId, isInverse: isInverse, theme: theme, className: "carbon-chart-wrapper"
|
|
3264
|
+
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),
|
|
1863
3265
|
React.createElement(ChartContentWrapper, { className: "carbon-chart-content" },
|
|
1864
3266
|
chartToolbar && (
|
|
1865
3267
|
/*
|
|
@@ -1876,5 +3278,5 @@ var CarbonChart = React.forwardRef(function (props, ref) {
|
|
|
1876
3278
|
});
|
|
1877
3279
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
1878
3280
|
|
|
1879
|
-
export { CarbonChart, CarbonChartType, ChartDataTable, ChartFullscreenButton, ChartMoreOptionsButton, ChartTableButton, ChartTableModal, ChartToolbar, useChartToolbarI18n };
|
|
3281
|
+
export { CarbonChart, CarbonChartType, Chart, ChartDataTable, ChartFullscreenButton, ChartMoreOptionsButton, ChartTableButton, ChartTableModal, ChartToolbar, useChartToolbarI18n };
|
|
1880
3282
|
//# sourceMappingURL=charts.modern.module.js.map
|