grommet 2.32.0 → 2.32.2
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/components/Chart/Chart.js +113 -57
- package/components/Chart/index.d.ts +3 -0
- package/components/Chart/propTypes.js +1 -0
- package/components/Chart/stories/Layout.js +6 -3
- package/components/Chart/stories/Pattern.js +1 -0
- package/components/Chart/stories/Vertical.js +41 -0
- package/components/Chart/utils.js +57 -10
- package/components/CheckBox/StyledCheckBox.js +2 -2
- package/components/Data/Data.js +2 -1
- package/components/Data/filter.js +10 -7
- package/components/DataFilter/DataFilter.js +26 -21
- package/components/DataTable/GroupedBody.js +1 -1
- package/components/DataTable/buildState.js +1 -1
- package/components/Drop/DropContainer.js +3 -2
- package/components/Layer/LayerContainer.js +1 -1
- package/components/Meter/Bar.js +5 -2
- package/components/Meter/Meter.js +11 -3
- package/components/Meter/StyledMeter.js +3 -1
- package/components/Meter/index.d.ts +1 -0
- package/components/Meter/propTypes.js +1 -0
- package/components/Meter/stories/ReverseBar.js +29 -0
- package/components/Pagination/Pagination.js +3 -1
- package/components/RadioButtonGroup/RadioButtonGroup.js +19 -4
- package/components/RadioButtonGroup/stories/typescript/Simple.tsx +6 -4
- package/components/Select/EmptySearchOption.js +3 -9
- package/components/Select/SelectContainer.js +4 -4
- package/components/Select/index.d.ts +1 -1
- package/components/Select/propTypes.js +1 -1
- package/components/SelectMultiple/SelectMultipleContainer.js +4 -4
- package/components/Text/Text.js +3 -1
- package/components/index.d.ts +2 -1
- package/contexts/DataContext.js +2 -1
- package/es6/components/Chart/Chart.js +113 -57
- package/es6/components/Chart/index.d.ts +3 -0
- package/es6/components/Chart/propTypes.js +1 -0
- package/es6/components/Chart/stories/Layout.js +6 -3
- package/es6/components/Chart/stories/Pattern.js +1 -0
- package/es6/components/Chart/stories/Vertical.js +35 -0
- package/es6/components/Chart/utils.js +57 -10
- package/es6/components/CheckBox/StyledCheckBox.js +2 -2
- package/es6/components/Data/Data.js +2 -1
- package/es6/components/Data/filter.js +10 -7
- package/es6/components/DataFilter/DataFilter.js +26 -21
- package/es6/components/DataTable/GroupedBody.js +1 -1
- package/es6/components/DataTable/buildState.js +1 -1
- package/es6/components/Drop/DropContainer.js +3 -2
- package/es6/components/Layer/LayerContainer.js +1 -1
- package/es6/components/Meter/Bar.js +5 -2
- package/es6/components/Meter/Meter.js +12 -4
- package/es6/components/Meter/StyledMeter.js +3 -1
- package/es6/components/Meter/index.d.ts +1 -0
- package/es6/components/Meter/propTypes.js +1 -0
- package/es6/components/Meter/stories/ReverseBar.js +23 -0
- package/es6/components/Pagination/Pagination.js +3 -1
- package/es6/components/RadioButtonGroup/RadioButtonGroup.js +19 -4
- package/es6/components/RadioButtonGroup/stories/typescript/Simple.tsx +6 -4
- package/es6/components/Select/EmptySearchOption.js +3 -9
- package/es6/components/Select/SelectContainer.js +4 -4
- package/es6/components/Select/index.d.ts +1 -1
- package/es6/components/Select/propTypes.js +1 -1
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +4 -4
- package/es6/components/Text/Text.js +3 -1
- package/es6/components/index.d.ts +2 -1
- package/es6/contexts/DataContext.js +2 -1
- package/es6/index.d.ts +11 -0
- package/es6/index.js +2 -0
- package/es6/themes/base.d.ts +4 -0
- package/es6/themes/base.js +4 -0
- package/es6/utils/index.d.ts +1 -1
- package/es6/utils/refs.js +1 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +11 -0
- package/index.js +1 -0
- package/package.json +36 -36
- package/themes/base.d.ts +4 -0
- package/themes/base.js +4 -0
- package/utils/index.d.ts +1 -1
- package/utils/refs.js +1 -1
|
@@ -10,7 +10,7 @@ var _utils = require("../../utils");
|
|
|
10
10
|
var _StyledChart = require("./StyledChart");
|
|
11
11
|
var _utils2 = require("./utils");
|
|
12
12
|
var _propTypes = require("./propTypes");
|
|
13
|
-
var _excluded = ["a11yTitle", "bounds", "color", "dash", "gap", "id", "onClick", "onHover", "opacity", "overflow", "pad", "pattern", "point", "round", "size", "thickness", "type", "values"],
|
|
13
|
+
var _excluded = ["a11yTitle", "bounds", "color", "dash", "direction", "gap", "id", "onClick", "onHover", "opacity", "overflow", "pad", "pattern", "point", "round", "size", "thickness", "type", "values"],
|
|
14
14
|
_excluded2 = ["color", "label", "onHover", "opacity", "thickness", "value"],
|
|
15
15
|
_excluded3 = ["color", "label", "onHover", "opacity", "thickness", "value"];
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -27,14 +27,15 @@ var defaultSize = {
|
|
|
27
27
|
var defaultValues = [];
|
|
28
28
|
var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
29
29
|
var a11yTitle = _ref.a11yTitle,
|
|
30
|
-
|
|
30
|
+
boundsProp = _ref.bounds,
|
|
31
31
|
color = _ref.color,
|
|
32
32
|
dash = _ref.dash,
|
|
33
|
+
direction = _ref.direction,
|
|
33
34
|
gap = _ref.gap,
|
|
34
35
|
id = _ref.id,
|
|
35
36
|
onClick = _ref.onClick,
|
|
36
37
|
onHover = _ref.onHover,
|
|
37
|
-
|
|
38
|
+
opacityProp = _ref.opacity,
|
|
38
39
|
_ref$overflow = _ref.overflow,
|
|
39
40
|
overflow = _ref$overflow === void 0 ? false : _ref$overflow,
|
|
40
41
|
pad = _ref.pad,
|
|
@@ -42,50 +43,62 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
42
43
|
point = _ref.point,
|
|
43
44
|
round = _ref.round,
|
|
44
45
|
_ref$size = _ref.size,
|
|
45
|
-
|
|
46
|
+
sizeProp = _ref$size === void 0 ? defaultSize : _ref$size,
|
|
46
47
|
_ref$thickness = _ref.thickness,
|
|
47
48
|
thickness = _ref$thickness === void 0 ? 'medium' : _ref$thickness,
|
|
48
49
|
_ref$type = _ref.type,
|
|
49
50
|
type = _ref$type === void 0 ? 'bar' : _ref$type,
|
|
50
51
|
_ref$values = _ref.values,
|
|
51
|
-
|
|
52
|
+
valuesProp = _ref$values === void 0 ? defaultValues : _ref$values,
|
|
52
53
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
53
54
|
var containerRef = (0, _utils.useForwardedRef)(ref);
|
|
54
55
|
var theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _defaultProps.defaultProps.theme;
|
|
55
|
-
|
|
56
|
-
// normalize variables
|
|
57
|
-
|
|
58
56
|
var values = (0, _react.useMemo)(function () {
|
|
59
|
-
return (0, _utils2.normalizeValues)(
|
|
60
|
-
}, [
|
|
57
|
+
return (0, _utils2.normalizeValues)(valuesProp);
|
|
58
|
+
}, [valuesProp]);
|
|
59
|
+
var vertical = (0, _react.useMemo)(function () {
|
|
60
|
+
return direction === 'vertical';
|
|
61
|
+
}, [direction]);
|
|
62
|
+
|
|
63
|
+
// bounds is { x: { min, max }, y: { min, max } }, accounting for direction
|
|
61
64
|
var bounds = (0, _react.useMemo)(function () {
|
|
62
|
-
return (0, _utils2.normalizeBounds)(
|
|
63
|
-
}, [
|
|
65
|
+
return (0, _utils2.normalizeBounds)(boundsProp, values, direction);
|
|
66
|
+
}, [direction, boundsProp, values]);
|
|
64
67
|
var strokeWidth = (0, _react.useMemo)(function () {
|
|
65
68
|
return (0, _utils.parseMetricToNum)(theme.global.edgeSize[thickness] || thickness);
|
|
66
69
|
}, [theme.global.edgeSize, thickness]);
|
|
70
|
+
|
|
71
|
+
// inset is { top, left, bottom, right }
|
|
67
72
|
var inset = (0, _react.useMemo)(function () {
|
|
68
|
-
var result =
|
|
73
|
+
var result = {
|
|
74
|
+
top: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
bottom: 0,
|
|
77
|
+
right: 0
|
|
78
|
+
};
|
|
69
79
|
if (pad) {
|
|
70
80
|
if (pad.horizontal) {
|
|
71
81
|
var padSize = (0, _utils.parseMetricToNum)(theme.global.edgeSize[pad.horizontal] || pad.horizontal);
|
|
72
|
-
result
|
|
73
|
-
result
|
|
82
|
+
result.left = padSize;
|
|
83
|
+
result.right = padSize;
|
|
74
84
|
}
|
|
75
85
|
if (pad.vertical) {
|
|
76
86
|
var _padSize = (0, _utils.parseMetricToNum)(theme.global.edgeSize[pad.vertical] || pad.vertical);
|
|
77
|
-
result
|
|
78
|
-
result
|
|
87
|
+
result.top = _padSize;
|
|
88
|
+
result.bottom = _padSize;
|
|
79
89
|
}
|
|
80
90
|
if (pad.start) {
|
|
81
|
-
result
|
|
91
|
+
result.left = (0, _utils.parseMetricToNum)(theme.global.edgeSize[pad.start] || pad.start);
|
|
82
92
|
}
|
|
83
93
|
if (pad.end) {
|
|
84
|
-
result
|
|
94
|
+
result.right = (0, _utils.parseMetricToNum)(theme.global.edgeSize[pad.end] || pad.end);
|
|
85
95
|
}
|
|
86
96
|
if (typeof pad === 'string') {
|
|
87
97
|
var _padSize2 = (0, _utils.parseMetricToNum)(theme.global.edgeSize[pad]);
|
|
88
|
-
result =
|
|
98
|
+
result.top = _padSize2;
|
|
99
|
+
result.left = _padSize2;
|
|
100
|
+
result.bottom = _padSize2;
|
|
101
|
+
result.right = _padSize2;
|
|
89
102
|
}
|
|
90
103
|
}
|
|
91
104
|
return result;
|
|
@@ -104,36 +117,51 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
104
117
|
containerSize = _useState[0],
|
|
105
118
|
setContainerSize = _useState[1];
|
|
106
119
|
var needContainerSize = (0, _react.useMemo)(function () {
|
|
107
|
-
return
|
|
108
|
-
}, [
|
|
120
|
+
return sizeProp && (sizeProp === 'full' || sizeProp === 'fill' || sizeProp.height === 'full' || sizeProp.height === 'fill' || sizeProp.width === 'full' || sizeProp.width === 'fill');
|
|
121
|
+
}, [sizeProp]);
|
|
122
|
+
|
|
123
|
+
// size is { width, height }
|
|
109
124
|
var size = (0, _react.useMemo)(function () {
|
|
110
125
|
var gapWidth = gap ? (0, _utils.parseMetricToNum)(theme.global.edgeSize[gap] || gap) : strokeWidth;
|
|
111
126
|
|
|
112
|
-
//
|
|
113
|
-
var
|
|
114
|
-
var sizeWidth = typeof
|
|
127
|
+
// autoSize is how wide or tall we'd pefer based on the number of values
|
|
128
|
+
var autoSize = strokeWidth * values.length + (values.length - 1) * gapWidth;
|
|
129
|
+
var sizeWidth = typeof sizeProp === 'string' ? sizeProp : sizeProp.width || defaultSize.width;
|
|
115
130
|
var width;
|
|
116
131
|
if (sizeWidth === 'full' || sizeWidth === 'fill') {
|
|
117
132
|
width = containerSize[0];
|
|
118
133
|
} else if (sizeWidth === 'auto') {
|
|
119
|
-
width =
|
|
134
|
+
width = autoSize;
|
|
120
135
|
} else {
|
|
121
136
|
width = (0, _utils.parseMetricToNum)(theme.global.size[sizeWidth] || sizeWidth);
|
|
122
137
|
}
|
|
123
|
-
var sizeHeight = typeof
|
|
138
|
+
var sizeHeight = typeof sizeProp === 'string' ? sizeProp : sizeProp.height || defaultSize.height;
|
|
124
139
|
var height;
|
|
125
140
|
if (sizeHeight === 'full' || sizeHeight === 'fill') {
|
|
126
141
|
height = containerSize[1];
|
|
142
|
+
} else if (sizeHeight === 'auto') {
|
|
143
|
+
height = autoSize;
|
|
127
144
|
} else {
|
|
128
145
|
height = (0, _utils.parseMetricToNum)(theme.global.size[sizeHeight] || sizeHeight);
|
|
129
146
|
}
|
|
130
|
-
return
|
|
131
|
-
|
|
147
|
+
return {
|
|
148
|
+
width: width,
|
|
149
|
+
height: height
|
|
150
|
+
};
|
|
151
|
+
}, [containerSize, gap, sizeProp, strokeWidth, theme.global.edgeSize, theme.global.size, values]);
|
|
152
|
+
|
|
153
|
+
// scale is { x, y }
|
|
132
154
|
var scale = (0, _react.useMemo)(function () {
|
|
133
|
-
return
|
|
155
|
+
return {
|
|
156
|
+
x: (size.width - (inset.left + inset.right)) / (bounds.x.max - bounds.x.min),
|
|
157
|
+
y: (size.height - (inset.top + inset.bottom)) / (bounds.y.max - bounds.y.min)
|
|
158
|
+
};
|
|
134
159
|
}, [bounds, inset, size]);
|
|
135
|
-
var
|
|
136
|
-
|
|
160
|
+
var viewBoxBounds = (0, _react.useMemo)(function () {
|
|
161
|
+
if (overflow) {
|
|
162
|
+
return [0, 0, size.width, size.height];
|
|
163
|
+
}
|
|
164
|
+
return [-(strokeWidth / 2), -(strokeWidth / 2), size.width + strokeWidth, size.height + strokeWidth];
|
|
137
165
|
}, [overflow, size, strokeWidth]);
|
|
138
166
|
|
|
139
167
|
// set container size when we get ref or when size changes
|
|
@@ -168,10 +196,19 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
168
196
|
return undefined;
|
|
169
197
|
}, [containerRef, needContainerSize]);
|
|
170
198
|
|
|
199
|
+
// rendering helpers, to make rendering code easier to understand
|
|
200
|
+
|
|
201
|
+
var valueCoords = function valueCoords(x, y) {
|
|
202
|
+
return vertical ? [y, x] : [x, y];
|
|
203
|
+
};
|
|
204
|
+
|
|
171
205
|
// Converts values to drawing coordinates.
|
|
172
206
|
// Takes into account the bounds, any inset, and the scale.
|
|
173
207
|
var valueToCoordinate = function valueToCoordinate(xValue, yValue) {
|
|
174
|
-
|
|
208
|
+
var y = (yValue - bounds.y.min) * scale.y + inset.top;
|
|
209
|
+
return [(xValue - bounds.x.min) * scale.x + inset.left,
|
|
210
|
+
// vertical grows y top down, horizontal grows y bottom up
|
|
211
|
+
vertical ? y : size.height - y];
|
|
175
212
|
};
|
|
176
213
|
var useGradient = color && Array.isArray(color);
|
|
177
214
|
var patternId;
|
|
@@ -194,9 +231,13 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
194
231
|
valueRest = _objectWithoutPropertiesLoose(valueArg, _excluded2);
|
|
195
232
|
var key = "p-" + index;
|
|
196
233
|
// Math.min/max are to handle negative values
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
|
|
234
|
+
var _valueCoords = valueCoords(value[0], value.length === 2 ? Math.min(Math.max(0, vertical ? bounds.x.min : bounds.y.min), value[1]) : Math.min(value[1], value[2])),
|
|
235
|
+
startX = _valueCoords[0],
|
|
236
|
+
startY = _valueCoords[1];
|
|
237
|
+
var _valueCoords2 = valueCoords(value[0], value.length === 2 ? Math.max(Math.min(0, vertical ? bounds.x.max : bounds.y.max), value[1]) : Math.max(value[1], value[2])),
|
|
238
|
+
endX = _valueCoords2[0],
|
|
239
|
+
endY = _valueCoords2[1];
|
|
240
|
+
var d = "M " + valueToCoordinate(startX, startY).join(',') + (" L " + valueToCoordinate(endX, endY).join(','));
|
|
200
241
|
var hoverProps;
|
|
201
242
|
if (valueOnHover) {
|
|
202
243
|
hoverProps = {
|
|
@@ -235,9 +276,15 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
235
276
|
return value[1] !== undefined;
|
|
236
277
|
}).forEach(function (_ref4) {
|
|
237
278
|
var value = _ref4.value;
|
|
238
|
-
|
|
279
|
+
var _valueCoords3 = valueCoords(value[0], value[1]),
|
|
280
|
+
x = _valueCoords3[0],
|
|
281
|
+
y = _valueCoords3[1];
|
|
282
|
+
d += (d ? ' L' : 'M') + " " + valueToCoordinate(x, y).join(',');
|
|
239
283
|
if (value[2] !== undefined) {
|
|
240
|
-
|
|
284
|
+
var _valueCoords4 = valueCoords(value[0], value[2]),
|
|
285
|
+
x2 = _valueCoords4[0],
|
|
286
|
+
y2 = _valueCoords4[1];
|
|
287
|
+
d2 += (d2 ? ' L' : 'M') + " " + valueToCoordinate(x2, y2).join(',');
|
|
241
288
|
}
|
|
242
289
|
});
|
|
243
290
|
var hoverProps;
|
|
@@ -276,16 +323,24 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
276
323
|
return value[1] !== undefined;
|
|
277
324
|
}).forEach(function (_ref6, index) {
|
|
278
325
|
var value = _ref6.value;
|
|
279
|
-
|
|
326
|
+
var _valueCoords5 = valueCoords(value[0],
|
|
327
|
+
// when a range, second value is on top
|
|
328
|
+
value[value.length === 2 ? 1 : 2]),
|
|
329
|
+
x = _valueCoords5[0],
|
|
330
|
+
y = _valueCoords5[1];
|
|
331
|
+
d += (!index ? 'M' : ' L') + " " + valueToCoordinate(x, y).join(',');
|
|
280
332
|
});
|
|
281
333
|
(values || []).filter(function (_ref7) {
|
|
282
334
|
var value = _ref7.value;
|
|
283
335
|
return value[1] !== undefined;
|
|
284
336
|
}).reverse().forEach(function (_ref8) {
|
|
285
337
|
var value = _ref8.value;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
338
|
+
var _valueCoords6 = valueCoords(value[0],
|
|
339
|
+
// Math.max() is to account for value[1] being negative
|
|
340
|
+
value.length === 2 ? Math.max(0, vertical ? bounds.x.min : bounds.y.min) : value[1]),
|
|
341
|
+
x = _valueCoords6[0],
|
|
342
|
+
y = _valueCoords6[1];
|
|
343
|
+
d += " L " + valueToCoordinate(x, y).join(',');
|
|
289
344
|
});
|
|
290
345
|
if (d.length > 0) {
|
|
291
346
|
d += ' Z';
|
|
@@ -346,7 +401,10 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
346
401
|
var width = valueThickness ? (0, _utils.parseMetricToNum)(theme.global.edgeSize[valueThickness] || valueThickness) : strokeWidth;
|
|
347
402
|
var renderPoint = function renderPoint(valueX, valueY) {
|
|
348
403
|
var props = _extends({}, hoverProps, clickProps, valueRest);
|
|
349
|
-
var
|
|
404
|
+
var _valueCoords7 = valueCoords(valueX, valueY),
|
|
405
|
+
x = _valueCoords7[0],
|
|
406
|
+
y = _valueCoords7[1];
|
|
407
|
+
var _valueToCoordinate = valueToCoordinate(x, y),
|
|
350
408
|
cx = _valueToCoordinate[0],
|
|
351
409
|
cy = _valueToCoordinate[1];
|
|
352
410
|
var off = width / 2;
|
|
@@ -385,16 +443,16 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
385
443
|
} else if (type === 'point') {
|
|
386
444
|
contents = renderPoints();
|
|
387
445
|
}
|
|
388
|
-
var viewBox =
|
|
446
|
+
var viewBox = viewBoxBounds.join(' ');
|
|
389
447
|
var colorName;
|
|
390
448
|
if (!useGradient) {
|
|
391
449
|
if (color && color.color) colorName = color.color;else if (color) colorName = color;else if (theme.chart && theme.chart.color) colorName = theme.chart.color;
|
|
392
450
|
}
|
|
393
451
|
var opacity;
|
|
394
|
-
if (
|
|
452
|
+
if (opacityProp === true) {
|
|
395
453
|
opacity = theme.global.opacity.medium;
|
|
396
|
-
} else if (
|
|
397
|
-
opacity = theme.global.opacity[
|
|
454
|
+
} else if (opacityProp) {
|
|
455
|
+
opacity = theme.global.opacity[opacityProp] ? theme.global.opacity[opacityProp] : opacityProp;
|
|
398
456
|
} else if (color && color.opacity) {
|
|
399
457
|
opacity = theme.global.opacity[color.opacity] ? theme.global.opacity[color.opacity] : color.opacity;
|
|
400
458
|
} else opacity = undefined;
|
|
@@ -416,7 +474,7 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
416
474
|
}, contents);
|
|
417
475
|
var defs = [];
|
|
418
476
|
var gradientRect;
|
|
419
|
-
if (useGradient && size
|
|
477
|
+
if (useGradient && size.height) {
|
|
420
478
|
var uniqueGradientId = color.map(function (element) {
|
|
421
479
|
return element.color;
|
|
422
480
|
}).join('-');
|
|
@@ -436,9 +494,7 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
436
494
|
gradientColor = _ref10.color;
|
|
437
495
|
return /*#__PURE__*/_react["default"].createElement("stop", {
|
|
438
496
|
key: value,
|
|
439
|
-
offset:
|
|
440
|
-
// TODO:
|
|
441
|
-
(size[1] - (value - bounds[1][0]) * scale[1]) / size[1],
|
|
497
|
+
offset: (size.height - (value - bounds.y.min) * scale.y) / size.height,
|
|
442
498
|
stopColor: (0, _utils.normalizeColor)(gradientColor, theme)
|
|
443
499
|
});
|
|
444
500
|
})));
|
|
@@ -447,10 +503,10 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
447
503
|
id: maskId
|
|
448
504
|
}, drawing));
|
|
449
505
|
gradientRect = /*#__PURE__*/_react["default"].createElement("rect", {
|
|
450
|
-
x:
|
|
451
|
-
y:
|
|
452
|
-
width:
|
|
453
|
-
height:
|
|
506
|
+
x: viewBoxBounds[0],
|
|
507
|
+
y: viewBoxBounds[1],
|
|
508
|
+
width: viewBoxBounds[2],
|
|
509
|
+
height: viewBoxBounds[3],
|
|
454
510
|
fill: "url(#" + gradientId + ")",
|
|
455
511
|
mask: "url(#" + maskId + ")"
|
|
456
512
|
});
|
|
@@ -515,8 +571,8 @@ var Chart = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
515
571
|
"aria-label": a11yTitle,
|
|
516
572
|
viewBox: viewBox,
|
|
517
573
|
preserveAspectRatio: "none",
|
|
518
|
-
width: size === 'full' ? '100%' : size
|
|
519
|
-
height: size === 'full' ? '100%' : size
|
|
574
|
+
width: size === 'full' ? '100%' : size.width,
|
|
575
|
+
height: size === 'full' ? '100%' : size.height,
|
|
520
576
|
typeProp: type // prevent adding to DOM
|
|
521
577
|
}, rest), defs.length && /*#__PURE__*/_react["default"].createElement("defs", null, defs), useGradient ? gradientRect : drawing);
|
|
522
578
|
});
|
|
@@ -26,6 +26,7 @@ export interface ChartProps {
|
|
|
26
26
|
opacity?: 'weak' | 'medium' | 'strong' | boolean | number;
|
|
27
27
|
};
|
|
28
28
|
dash?: boolean;
|
|
29
|
+
direction?: 'horizontal' | 'vertical';
|
|
29
30
|
gap?: GapType;
|
|
30
31
|
onClick?: (...args: any[]) => any;
|
|
31
32
|
onHover?: (...args: any[]) => any;
|
|
@@ -66,6 +67,7 @@ export interface ChartProps {
|
|
|
66
67
|
| 'xlarge'
|
|
67
68
|
| 'fill'
|
|
68
69
|
| 'full'
|
|
70
|
+
| 'auto'
|
|
69
71
|
| string;
|
|
70
72
|
width?:
|
|
71
73
|
| 'xxsmall'
|
|
@@ -76,6 +78,7 @@ export interface ChartProps {
|
|
|
76
78
|
| 'xlarge'
|
|
77
79
|
| 'fill'
|
|
78
80
|
| 'full'
|
|
81
|
+
| 'auto'
|
|
79
82
|
| string;
|
|
80
83
|
}
|
|
81
84
|
| string;
|
|
@@ -22,6 +22,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
22
22
|
}))]),
|
|
23
23
|
id: _propTypes["default"].string,
|
|
24
24
|
dash: _propTypes["default"].bool,
|
|
25
|
+
direction: _propTypes["default"].oneOf(['horizontal', 'vertical']),
|
|
25
26
|
gap: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['none', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge']), _propTypes["default"].string]),
|
|
26
27
|
onClick: _propTypes["default"].func,
|
|
27
28
|
onHover: _propTypes["default"].func,
|
|
@@ -23,7 +23,8 @@ var Layout = function Layout() {
|
|
|
23
23
|
level: 2
|
|
24
24
|
}, "full"), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
25
25
|
pad: "medium",
|
|
26
|
-
border: true
|
|
26
|
+
border: true,
|
|
27
|
+
alignSelf: "stretch"
|
|
27
28
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Chart, {
|
|
28
29
|
type: type,
|
|
29
30
|
values: values,
|
|
@@ -35,7 +36,8 @@ var Layout = function Layout() {
|
|
|
35
36
|
level: 2
|
|
36
37
|
}, "auto, gap"), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
37
38
|
pad: "medium",
|
|
38
|
-
border: true
|
|
39
|
+
border: true,
|
|
40
|
+
alignSelf: "start"
|
|
39
41
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Chart, {
|
|
40
42
|
type: type,
|
|
41
43
|
values: values,
|
|
@@ -48,7 +50,8 @@ var Layout = function Layout() {
|
|
|
48
50
|
level: 2
|
|
49
51
|
}, "default"), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
50
52
|
pad: "medium",
|
|
51
|
-
|
|
53
|
+
borde: true,
|
|
54
|
+
alignSelf: "start"
|
|
52
55
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Chart, {
|
|
53
56
|
type: type,
|
|
54
57
|
values: values,
|
|
@@ -16,6 +16,7 @@ var Pattern = function Pattern() {
|
|
|
16
16
|
gap: "medium"
|
|
17
17
|
}, ['squares', 'circles', 'stripesHorizontal', 'stripesVertical', 'stripesDiagonalDown', 'stripesDiagonalUp'].map(function (pattern) {
|
|
18
18
|
return /*#__PURE__*/_react["default"].createElement(_grommet.Chart, {
|
|
19
|
+
key: pattern,
|
|
19
20
|
id: "area-" + pattern,
|
|
20
21
|
type: "area",
|
|
21
22
|
pattern: pattern,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Vertical = void 0;
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _grommet = require("grommet");
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
+
var Vertical = function Vertical() {
|
|
9
|
+
return (
|
|
10
|
+
/*#__PURE__*/
|
|
11
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
12
|
+
// <Grommet theme={grommet}>
|
|
13
|
+
_react["default"].createElement(_grommet.Box, {
|
|
14
|
+
align: "center",
|
|
15
|
+
pad: "large",
|
|
16
|
+
gap: "large"
|
|
17
|
+
}, ['bar', 'line', 'area', 'point'].map(function (type) {
|
|
18
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
19
|
+
key: type,
|
|
20
|
+
direction: "row",
|
|
21
|
+
gap: "medium"
|
|
22
|
+
}, ['horizontal', 'vertical'].map(function (direction) {
|
|
23
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
24
|
+
key: direction,
|
|
25
|
+
border: true
|
|
26
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Chart, {
|
|
27
|
+
type: type,
|
|
28
|
+
direction: direction,
|
|
29
|
+
size: "small",
|
|
30
|
+
values: [[10, 20], [20, 30], [30, 15]]
|
|
31
|
+
}));
|
|
32
|
+
}));
|
|
33
|
+
}))
|
|
34
|
+
// </Grommet>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
exports.Vertical = Vertical;
|
|
38
|
+
var _default = {
|
|
39
|
+
title: 'Visualizations/Chart/Vertical'
|
|
40
|
+
};
|
|
41
|
+
exports["default"] = _default;
|
|
@@ -17,24 +17,71 @@ var normalizeValues = function normalizeValues(values) {
|
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
exports.normalizeValues = normalizeValues;
|
|
20
|
-
var normalizeBounds = function normalizeBounds(
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
var normalizeBounds = function normalizeBounds(boundsProp, values, direction) {
|
|
21
|
+
var vertical = direction === 'vertical';
|
|
22
|
+
var result;
|
|
23
|
+
if (boundsProp) {
|
|
24
|
+
if (vertical) result = {
|
|
25
|
+
x: {
|
|
26
|
+
min: boundsProp[1][0],
|
|
27
|
+
max: boundsProp[1][1]
|
|
28
|
+
},
|
|
29
|
+
y: {
|
|
30
|
+
min: boundsProp[0][0],
|
|
31
|
+
max: boundsProp[0][1]
|
|
32
|
+
}
|
|
33
|
+
};else result = {
|
|
34
|
+
x: {
|
|
35
|
+
min: boundsProp[0][0],
|
|
36
|
+
max: boundsProp[0][1]
|
|
37
|
+
},
|
|
38
|
+
y: {
|
|
39
|
+
min: boundsProp[1][0],
|
|
40
|
+
max: boundsProp[1][1]
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
var min0 = 0;
|
|
45
|
+
var max0 = 1;
|
|
46
|
+
var min1 = 0;
|
|
47
|
+
var max1 = 1;
|
|
24
48
|
(values || []).forEach(function (value) {
|
|
25
49
|
if (value.value[0] !== undefined) {
|
|
26
|
-
|
|
27
|
-
|
|
50
|
+
min0 = Math.min(min0, value.value[0]);
|
|
51
|
+
max0 = Math.max(max0, value.value[0]);
|
|
28
52
|
}
|
|
29
53
|
if (value.value[1] !== undefined) {
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
min1 = Math.min(min1, value.value[1]);
|
|
55
|
+
max1 = Math.max(max1, value.value[1]);
|
|
32
56
|
}
|
|
33
57
|
if (value.value[2] !== undefined) {
|
|
34
|
-
|
|
35
|
-
|
|
58
|
+
min1 = Math.min(min1, value.value[2]);
|
|
59
|
+
max1 = Math.max(max1, value.value[2]);
|
|
36
60
|
}
|
|
37
61
|
});
|
|
62
|
+
if (vertical) {
|
|
63
|
+
result = {
|
|
64
|
+
x: {
|
|
65
|
+
min: min1,
|
|
66
|
+
max: max1
|
|
67
|
+
},
|
|
68
|
+
y: {
|
|
69
|
+
min: min0,
|
|
70
|
+
max: max0
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
} else {
|
|
74
|
+
result = {
|
|
75
|
+
x: {
|
|
76
|
+
min: min0,
|
|
77
|
+
max: max0
|
|
78
|
+
},
|
|
79
|
+
y: {
|
|
80
|
+
min: min1,
|
|
81
|
+
max: max1
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
38
85
|
}
|
|
39
86
|
return result;
|
|
40
87
|
};
|
|
@@ -11,7 +11,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
11
11
|
// added to it to simplify its logic. If this is ever reused somewhere else,
|
|
12
12
|
// consider the need of separating those once again.
|
|
13
13
|
var fillStyle = function fillStyle() {
|
|
14
|
-
return "\n width:
|
|
14
|
+
return "\n width: auto;\n height: 100%;\n max-width: none;\n flex: 1 0 auto;\n justify-content: space-between;\n ";
|
|
15
15
|
};
|
|
16
16
|
var disabledStyle = "\n opacity: 0.5;\n cursor: default;\n";
|
|
17
17
|
var hoverStyle = (0, _styledComponents.css)([":hover input:not([disabled]) + div,:hover input:not([disabled]) + span{border-color:", ";", "}:hover{background-color:", ";}"], function (props) {
|
|
@@ -56,7 +56,7 @@ var StyledCheckBoxContainer = _styledComponents["default"].label.withConfig({
|
|
|
56
56
|
return !props.disabled && 'cursor: pointer;';
|
|
57
57
|
}, hoverStyle, function (props) {
|
|
58
58
|
var _props$theme$checkBox6, _props$theme$checkBox7, _props$theme$checkBox8, _props$theme$checkBox9;
|
|
59
|
-
return props.focus && !props.focusIndicator && "\n input:not([disabled]) + div,\n input:not([disabled]) + span {\n border-color: " + (0, _utils.normalizeColor)((_props$theme$checkBox6 = props.theme.checkBox.hover) == null ? void 0 : (_props$theme$checkBox7 = _props$theme$checkBox6.border) == null ? void 0 : _props$theme$checkBox7.color, props.theme) + ";\n }\n
|
|
59
|
+
return props.focus && !props.focusIndicator && "\n input:not([disabled]) + div,\n input:not([disabled]) + span {\n border-color: " + (0, _utils.normalizeColor)((_props$theme$checkBox6 = props.theme.checkBox.hover) == null ? void 0 : (_props$theme$checkBox7 = _props$theme$checkBox6.border) == null ? void 0 : _props$theme$checkBox7.color, props.theme) + ";\n }\n\n background-color: " + (0, _utils.normalizeColor)(!props.disabled && ((_props$theme$checkBox8 = props.theme.checkBox.hover) == null ? void 0 : (_props$theme$checkBox9 = _props$theme$checkBox8.background) == null ? void 0 : _props$theme$checkBox9.color), props.theme) + ";";
|
|
60
60
|
}, function (props) {
|
|
61
61
|
return props.theme.checkBox.extend;
|
|
62
62
|
});
|
package/components/Data/Data.js
CHANGED
|
@@ -27,7 +27,8 @@ var normalizeView = function normalizeView(viewProp, views) {
|
|
|
27
27
|
};
|
|
28
28
|
var Data = function Data(_ref) {
|
|
29
29
|
var children = _ref.children,
|
|
30
|
-
|
|
30
|
+
_ref$data = _ref.data,
|
|
31
|
+
dataProp = _ref$data === void 0 ? [] : _ref$data,
|
|
31
32
|
_ref$defaultView = _ref.defaultView,
|
|
32
33
|
defaultView = _ref$defaultView === void 0 ? defaultDefaultView : _ref$defaultView,
|
|
33
34
|
filteredTotal = _ref.filteredTotal,
|
|
@@ -52,13 +52,16 @@ var filter = function filter(data, view, properties) {
|
|
|
52
52
|
|
|
53
53
|
// options case
|
|
54
54
|
if (Array.isArray(filterValue)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
return !filterValue.some(function (f) {
|
|
56
|
+
// f may be an object with form {label: __, value: __}
|
|
57
|
+
var isObject = typeof f === 'object';
|
|
58
|
+
// match f within data value array using .includes()
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
return isObject ? value.includes(f == null ? void 0 : f.value) : value.includes(f);
|
|
61
|
+
}
|
|
62
|
+
// match f with data value using ===
|
|
63
|
+
return isObject ? (f == null ? void 0 : f.value) === value : f === value;
|
|
64
|
+
});
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
// presence case
|
|
@@ -71,9 +71,11 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
71
71
|
|
|
72
72
|
// generate options from all values for property
|
|
73
73
|
var uniqueValues = generateOptions(unfilteredData || data, property);
|
|
74
|
+
// if less than two values, nothing to filter
|
|
75
|
+
if (uniqueValues.length < 2) return [undefined, undefined];
|
|
74
76
|
// if any values aren't numeric, treat as options
|
|
75
77
|
if (uniqueValues.some(function (v) {
|
|
76
|
-
return v && typeof v !== 'number';
|
|
78
|
+
return v !== undefined && typeof v !== 'number';
|
|
77
79
|
})) return [uniqueValues, undefined];
|
|
78
80
|
// all values are numeric, treat as range
|
|
79
81
|
// normalize to make it friendler, so [1.3, 4.895] becomes [1, 5]
|
|
@@ -100,28 +102,31 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
100
102
|
size: "full",
|
|
101
103
|
round: "small"
|
|
102
104
|
});
|
|
103
|
-
} else if (options
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
105
|
+
} else if (options) {
|
|
106
|
+
if (options.length === 2 && options[1] === true && options[0] === false) {
|
|
107
|
+
// special case boolean properties
|
|
108
|
+
content = /*#__PURE__*/_react["default"].createElement(_CheckBoxGroup.CheckBoxGroup, {
|
|
109
|
+
id: id,
|
|
110
|
+
name: property,
|
|
111
|
+
options: booleanOptions
|
|
112
|
+
});
|
|
113
|
+
} else if (options.length < 7) {
|
|
114
|
+
content = /*#__PURE__*/_react["default"].createElement(_CheckBoxGroup.CheckBoxGroup, {
|
|
115
|
+
id: id,
|
|
116
|
+
name: property,
|
|
117
|
+
options: options
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
content = /*#__PURE__*/_react["default"].createElement(_SelectMultiple.SelectMultiple, {
|
|
121
|
+
id: id,
|
|
122
|
+
name: property,
|
|
123
|
+
showSelectedInline: true,
|
|
124
|
+
options: options
|
|
125
|
+
});
|
|
126
|
+
}
|
|
123
127
|
}
|
|
124
128
|
}
|
|
129
|
+
if (!content) return null;
|
|
125
130
|
if (noForm)
|
|
126
131
|
// likely in Toolbar
|
|
127
132
|
content = /*#__PURE__*/_react["default"].createElement(_DataForm.DataForm, {
|