grommet 2.32.2 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all/stories/CustomThemed/ExtendTheme.tsx +2 -4
- package/components/Chart/Chart.js +20 -20
- package/components/Chart/calcs.js +163 -92
- package/components/Chart/index.d.ts +10 -4
- package/components/Chart/propTypes.js +10 -1
- package/components/Chart/stories/{Vertical.js → Horizontal.js} +34 -6
- package/components/Chart/utils.js +68 -64
- package/components/DataChart/DataChart.js +114 -68
- package/components/DataChart/Detail.js +55 -21
- package/components/DataChart/XAxis.js +33 -6
- package/components/DataChart/XGuide.js +14 -1
- package/components/DataChart/YAxis.js +58 -39
- package/components/DataChart/YGuide.js +13 -10
- package/components/DataChart/index.d.ts +2 -0
- package/components/DataChart/propTypes.js +3 -1
- package/components/DataChart/stories/Horizontal.js +63 -0
- package/components/DataChart/utils.js +27 -2
- package/components/DataFilter/DataFilter.js +25 -2
- package/components/DataSort/DataSort.js +1 -1
- package/components/DataTable/buildState.js +6 -1
- package/components/DateInput/DateInput.js +22 -2
- package/components/Footer/stories/DoubleFooter.js +6 -2
- package/components/Footer/stories/Sitemap.js +0 -2
- package/components/Footer/stories/Social.js +2 -2
- package/components/Menu/Menu.js +9 -6
- package/components/Select/Select.js +1 -1
- package/es6/all/stories/CustomThemed/ExtendTheme.tsx +2 -4
- package/es6/components/Chart/Chart.js +20 -20
- package/es6/components/Chart/calcs.js +164 -93
- package/es6/components/Chart/index.d.ts +10 -4
- package/es6/components/Chart/propTypes.js +10 -1
- package/es6/components/Chart/stories/{Vertical.js → Horizontal.js} +32 -4
- package/es6/components/Chart/utils.js +66 -63
- package/es6/components/DataChart/DataChart.js +115 -69
- package/es6/components/DataChart/Detail.js +55 -21
- package/es6/components/DataChart/XAxis.js +33 -6
- package/es6/components/DataChart/XGuide.js +14 -1
- package/es6/components/DataChart/YAxis.js +59 -40
- package/es6/components/DataChart/YGuide.js +13 -10
- package/es6/components/DataChart/index.d.ts +2 -0
- package/es6/components/DataChart/propTypes.js +3 -1
- package/es6/components/DataChart/stories/Horizontal.js +57 -0
- package/es6/components/DataChart/utils.js +22 -0
- package/es6/components/DataFilter/DataFilter.js +27 -3
- package/es6/components/DataSort/DataSort.js +1 -1
- package/es6/components/DataTable/buildState.js +6 -1
- package/es6/components/DateInput/DateInput.js +22 -2
- package/es6/components/Footer/stories/DoubleFooter.js +6 -2
- package/es6/components/Footer/stories/Sitemap.js +0 -2
- package/es6/components/Footer/stories/Social.js +2 -2
- package/es6/components/Menu/Menu.js +9 -6
- package/es6/components/Select/Select.js +1 -1
- package/es6/themes/base.d.ts +5 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +37 -37
- package/themes/base.d.ts +5 -1
|
@@ -5,11 +5,27 @@ exports.XAxis = void 0;
|
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _utils = require("../../utils");
|
|
7
7
|
var _Box = require("../Box");
|
|
8
|
+
var _utils2 = require("./utils");
|
|
8
9
|
var _excluded = ["values", "pad", "renderValue", "serie", "theme", "thickness"];
|
|
9
10
|
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); }
|
|
10
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
12
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
13
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
14
|
+
var onlyHorizontalPad = function onlyHorizontalPad(pad) {
|
|
15
|
+
var result;
|
|
16
|
+
if (pad) {
|
|
17
|
+
if (typeof pad === 'string') result = {
|
|
18
|
+
horizontal: pad
|
|
19
|
+
};else result = {
|
|
20
|
+
horizontal: pad.horizontal,
|
|
21
|
+
start: pad.start,
|
|
22
|
+
end: pad.end,
|
|
23
|
+
left: pad.left,
|
|
24
|
+
right: pad.right
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
13
29
|
var XAxis = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
14
30
|
var values = _ref.values,
|
|
15
31
|
padProp = _ref.pad,
|
|
@@ -18,13 +34,17 @@ var XAxis = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
18
34
|
theme = _ref.theme,
|
|
19
35
|
thickness = _ref.thickness,
|
|
20
36
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
37
|
+
var _ref2 = serie || {},
|
|
38
|
+
render = _ref2.render,
|
|
39
|
+
suffix = _ref2.suffix;
|
|
40
|
+
|
|
21
41
|
// pad to the edge of the thickness, for when padding is more than half
|
|
22
42
|
// the thickness
|
|
23
43
|
var pad = (0, _react.useMemo)(function () {
|
|
24
|
-
return {
|
|
44
|
+
return thickness && padProp && {
|
|
25
45
|
start: (0, _utils.edgeToNum)(padProp.start || padProp.horizontal, theme) - (0, _utils.edgeToNum)(thickness, theme) / 2 + "px",
|
|
26
46
|
end: (0, _utils.edgeToNum)(padProp.end || padProp.horizontal, theme) - (0, _utils.edgeToNum)(thickness, theme) / 2 + "px"
|
|
27
|
-
};
|
|
47
|
+
} || onlyHorizontalPad(padProp);
|
|
28
48
|
}, [padProp, theme, thickness]);
|
|
29
49
|
|
|
30
50
|
// When there are only labels at the end of the axis and there isn't
|
|
@@ -34,9 +54,9 @@ var XAxis = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
34
54
|
// data/guide lines and then let their content overflow that.
|
|
35
55
|
var labelContainerProps = (0, _react.useMemo)(function () {
|
|
36
56
|
// 24px was chosen empirically as 48px is enough to show some simple text
|
|
37
|
-
var centered = values.length !== 2 || (0, _utils.edgeToNum)(padProp.start || padProp.horizontal, theme) >= 24;
|
|
57
|
+
var centered = values.length !== 2 || (0, _utils.edgeToNum)((padProp == null ? void 0 : padProp.start) || (padProp == null ? void 0 : padProp.horizontal), theme) >= 24;
|
|
38
58
|
if (centered) return {
|
|
39
|
-
|
|
59
|
+
basis: thickness || '1px',
|
|
40
60
|
overflow: 'visible',
|
|
41
61
|
align: 'center'
|
|
42
62
|
};
|
|
@@ -48,13 +68,20 @@ var XAxis = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
48
68
|
direction: "row",
|
|
49
69
|
justify: "between",
|
|
50
70
|
pad: pad
|
|
51
|
-
}, rest), values.map(function (
|
|
71
|
+
}, rest), values.map(function (axisValue, i) {
|
|
72
|
+
var content = serie ? renderValue(serie, axisValue) : axisValue;
|
|
73
|
+
if (content === axisValue && !render && !suffix) {
|
|
74
|
+
var maxValue = Math.max.apply(Math, values.map(function (v) {
|
|
75
|
+
return Math.abs(v);
|
|
76
|
+
}));
|
|
77
|
+
content = (0, _utils2.showInUnits)(content, maxValue);
|
|
78
|
+
}
|
|
52
79
|
return (
|
|
53
80
|
/*#__PURE__*/
|
|
54
81
|
// eslint-disable-next-line react/no-array-index-key
|
|
55
82
|
_react["default"].createElement(_Box.Box, _extends({
|
|
56
83
|
key: i
|
|
57
|
-
}, labelContainerProps),
|
|
84
|
+
}, labelContainerProps), content)
|
|
58
85
|
);
|
|
59
86
|
}));
|
|
60
87
|
});
|
|
@@ -6,9 +6,22 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
6
6
|
var _Box = require("../Box");
|
|
7
7
|
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); }
|
|
8
8
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
9
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
9
10
|
var XGuide = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
10
11
|
var guide = _ref.guide,
|
|
11
|
-
|
|
12
|
+
padArg = _ref.pad,
|
|
13
|
+
thickness = _ref.thickness;
|
|
14
|
+
var pad = padArg;
|
|
15
|
+
if (thickness) {
|
|
16
|
+
// omit any horizontal pad so the guides cover the thickness that
|
|
17
|
+
// is within the pad
|
|
18
|
+
if (typeof padArg === 'object') pad = _extends({}, padArg, {
|
|
19
|
+
top: 'none',
|
|
20
|
+
bottom: 'none'
|
|
21
|
+
});else if (typeof padArg === 'string') pad = {
|
|
22
|
+
horizontal: padArg
|
|
23
|
+
};
|
|
24
|
+
}
|
|
12
25
|
return /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
13
26
|
ref: ref,
|
|
14
27
|
fill: true,
|
|
@@ -3,61 +3,80 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.YAxis = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
-
var
|
|
6
|
+
var _utils = require("../../utils");
|
|
7
7
|
var _Box = require("../Box");
|
|
8
|
-
var
|
|
9
|
-
var _utils = require("./utils");
|
|
8
|
+
var _utils2 = require("./utils");
|
|
10
9
|
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); }
|
|
11
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
+
var onlyVerticalPad = function onlyVerticalPad(pad) {
|
|
13
|
+
var result;
|
|
14
|
+
if (pad) {
|
|
15
|
+
if (typeof pad === 'string') result = {
|
|
16
|
+
vertical: pad
|
|
17
|
+
};else result = {
|
|
18
|
+
vertical: pad.vertical,
|
|
19
|
+
top: pad.top,
|
|
20
|
+
bottom: pad.bottom
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
12
25
|
var YAxis = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
13
26
|
var values = _ref.values,
|
|
14
|
-
|
|
27
|
+
padProp = _ref.pad,
|
|
15
28
|
renderValue = _ref.renderValue,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} else if (maxValue > 10000) {
|
|
32
|
-
divideBy = 1000;
|
|
33
|
-
unit = 'K';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
29
|
+
serie = _ref.serie,
|
|
30
|
+
theme = _ref.theme,
|
|
31
|
+
thickness = _ref.thickness;
|
|
32
|
+
var _ref2 = serie || {},
|
|
33
|
+
render = _ref2.render,
|
|
34
|
+
suffix = _ref2.suffix;
|
|
35
|
+
|
|
36
|
+
// pad to the edge of the thickness, for when padding is more than half
|
|
37
|
+
// the thickness
|
|
38
|
+
var pad = (0, _react.useMemo)(function () {
|
|
39
|
+
return padProp && thickness && {
|
|
40
|
+
top: (0, _utils.edgeToNum)(padProp.top || padProp.vertical, theme) - (0, _utils.edgeToNum)(thickness, theme) / 2 + "px",
|
|
41
|
+
bottom: (0, _utils.edgeToNum)(padProp.bottom || padProp.vertical, theme) - (0, _utils.edgeToNum)(thickness, theme) / 2 + "px"
|
|
42
|
+
} || onlyVerticalPad(padProp);
|
|
43
|
+
}, [padProp, theme, thickness]);
|
|
36
44
|
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
// When there are only labels at the end of the axis and there isn't
|
|
46
|
+
// much space for them, let them take as much space as they like
|
|
47
|
+
// flowing in from the edges.
|
|
48
|
+
// Otherwise, align their container to the
|
|
49
|
+
// data/guide lines and then let their content overflow that.
|
|
50
|
+
var labelContainerProps = (0, _react.useMemo)(function () {
|
|
51
|
+
// 24px was chosen empirically as 48px is enough to show some simple text
|
|
52
|
+
var centered = values.length !== 2 || (0, _utils.edgeToNum)((padProp == null ? void 0 : padProp.start) || (padProp == null ? void 0 : padProp.horizontal), theme) >= 24;
|
|
53
|
+
if (centered) return {
|
|
54
|
+
basis: thickness || '1px',
|
|
55
|
+
overflow: 'visible',
|
|
56
|
+
justify: 'center'
|
|
57
|
+
};
|
|
58
|
+
return {};
|
|
59
|
+
}, [padProp, theme, thickness, values]);
|
|
41
60
|
return /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
42
61
|
ref: ref,
|
|
43
62
|
gridArea: "yAxis",
|
|
44
63
|
justify: "between",
|
|
45
|
-
flex: true
|
|
64
|
+
flex: true,
|
|
65
|
+
pad: pad
|
|
46
66
|
}, values.map(function (axisValue, i) {
|
|
47
|
-
var content = renderValue(serie,
|
|
48
|
-
if (content === axisValue) {
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
var content = serie ? renderValue(serie, axisValue, true) : axisValue;
|
|
68
|
+
if (content === axisValue && !render && !suffix) {
|
|
69
|
+
var maxValue = Math.max.apply(Math, values.map(function (v) {
|
|
70
|
+
return Math.abs(v);
|
|
71
|
+
}));
|
|
72
|
+
content = (0, _utils2.showInUnits)(content, maxValue);
|
|
51
73
|
}
|
|
52
74
|
return /*#__PURE__*/_react["default"].createElement(_Box.Box
|
|
53
75
|
// eslint-disable-next-line react/no-array-index-key
|
|
54
|
-
, {
|
|
76
|
+
, _extends({
|
|
55
77
|
key: i,
|
|
56
|
-
align: "end"
|
|
57
|
-
|
|
58
|
-
flex: "shrink",
|
|
59
|
-
justify: basis ? 'center' : undefined
|
|
60
|
-
}, content);
|
|
78
|
+
align: "end"
|
|
79
|
+
}, labelContainerProps), content);
|
|
61
80
|
}));
|
|
62
81
|
});
|
|
63
82
|
exports.YAxis = YAxis;
|
|
@@ -9,16 +9,19 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
9
9
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
10
10
|
var YGuide = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
11
11
|
var guide = _ref.guide,
|
|
12
|
-
padArg = _ref.pad
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
padArg = _ref.pad,
|
|
13
|
+
thickness = _ref.thickness;
|
|
14
|
+
var pad = padArg;
|
|
15
|
+
if (thickness) {
|
|
16
|
+
// omit any horizontal pad so the guides cover the thickness that
|
|
17
|
+
// is within the pad
|
|
18
|
+
if (typeof padArg === 'object') pad = _extends({}, padArg, {
|
|
19
|
+
start: 'none',
|
|
20
|
+
end: 'none'
|
|
21
|
+
});else if (typeof padArg === 'string') pad = {
|
|
22
|
+
vertical: padArg
|
|
23
|
+
};
|
|
24
|
+
}
|
|
22
25
|
return /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
23
26
|
ref: ref,
|
|
24
27
|
fill: true,
|
|
@@ -76,6 +76,7 @@ export interface DataChartProps {
|
|
|
76
76
|
bounds?:
|
|
77
77
|
| 'align'
|
|
78
78
|
| {
|
|
79
|
+
x?: number[];
|
|
79
80
|
y?: number[];
|
|
80
81
|
};
|
|
81
82
|
// chart - if undefined, { type: 'bar', property: <first series property> }
|
|
@@ -84,6 +85,7 @@ export interface DataChartProps {
|
|
|
84
85
|
data: {}[];
|
|
85
86
|
// detail - whether to show details via hover/touch interaction
|
|
86
87
|
detail?: boolean | ((datum: {}, index: number) => React.ReactNode);
|
|
88
|
+
direction?: 'horizontal' | 'vertical';
|
|
87
89
|
gap?: GridProps['gap']; // between axes and guides/visuals
|
|
88
90
|
gridArea?: GridAreaType; // generic
|
|
89
91
|
// guide - when true, {
|
|
@@ -59,11 +59,13 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
59
59
|
})])
|
|
60
60
|
})]),
|
|
61
61
|
bounds: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['align']), _propTypes["default"].shape({
|
|
62
|
+
x: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
62
63
|
y: _propTypes["default"].arrayOf(_propTypes["default"].number)
|
|
63
64
|
})]),
|
|
64
65
|
chart: _propTypes["default"].oneOfType([chartType, _propTypes["default"].arrayOf(chartType)]),
|
|
65
66
|
data: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
|
|
66
67
|
detail: _propTypes["default"].bool,
|
|
68
|
+
direction: _propTypes["default"].oneOf(['horizontal', 'vertical']),
|
|
67
69
|
gap: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['none', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge']), _propTypes["default"].string]),
|
|
68
70
|
guide: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].shape({
|
|
69
71
|
x: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].shape({
|
|
@@ -80,7 +82,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
80
82
|
pad: _generalPropTypes.padPropType,
|
|
81
83
|
placeholder: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]),
|
|
82
84
|
series: _propTypes["default"].oneOfType([seriesType, _propTypes["default"].arrayOf(seriesType)]),
|
|
83
|
-
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['fill']), _propTypes["default"].shape({
|
|
85
|
+
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'fill', 'full']), _propTypes["default"].shape({
|
|
84
86
|
height: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'fill']), _propTypes["default"].string]),
|
|
85
87
|
width: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'fill', 'auto']), _propTypes["default"].string])
|
|
86
88
|
})])
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Horizontal = 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 data = [];
|
|
9
|
+
for (var i = 1; i < 8; i += 1) {
|
|
10
|
+
var v = Math.sin(i / 2.0);
|
|
11
|
+
data.push({
|
|
12
|
+
percent: Math.abs(v * 100),
|
|
13
|
+
label: "Label " + i
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
var Horizontal = function Horizontal() {
|
|
17
|
+
return (
|
|
18
|
+
/*#__PURE__*/
|
|
19
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
20
|
+
// <Grommet theme={grommet}>
|
|
21
|
+
_react["default"].createElement(_grommet.Box, {
|
|
22
|
+
align: "center",
|
|
23
|
+
justify: "start",
|
|
24
|
+
pad: "large"
|
|
25
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.DataChart, {
|
|
26
|
+
data: data,
|
|
27
|
+
series: [{
|
|
28
|
+
property: 'label',
|
|
29
|
+
render: function render(label) {
|
|
30
|
+
return label;
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
property: 'percent',
|
|
34
|
+
suffix: '%'
|
|
35
|
+
}],
|
|
36
|
+
direction: "horizontal",
|
|
37
|
+
size: "medium",
|
|
38
|
+
axis: {
|
|
39
|
+
x: {
|
|
40
|
+
granularity: 'fine'
|
|
41
|
+
},
|
|
42
|
+
y: {
|
|
43
|
+
property: 'label',
|
|
44
|
+
granularity: 'fine'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
guide: {
|
|
48
|
+
x: {
|
|
49
|
+
granularity: 'fine'
|
|
50
|
+
},
|
|
51
|
+
y: {
|
|
52
|
+
granularity: 'fine'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}))
|
|
56
|
+
// </Grommet>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
exports.Horizontal = Horizontal;
|
|
60
|
+
var _default = {
|
|
61
|
+
title: 'Visualizations/DataChart/Horizontal'
|
|
62
|
+
};
|
|
63
|
+
exports["default"] = _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.points = exports.largestSize = exports.heightYGranularity = exports.halfPad = exports.doublePad = exports.createDateFormat = void 0;
|
|
4
|
+
exports.showInUnits = exports.points = exports.minimum = exports.maximum = exports.largestSize = exports.heightYGranularity = exports.halfPad = exports.doublePad = exports.createDateFormat = void 0;
|
|
5
|
+
var _Chart = require("../Chart");
|
|
5
6
|
var points = ['circle', 'diamond', 'square', 'star', 'triangle', 'triangleDown'];
|
|
6
7
|
exports.points = points;
|
|
7
8
|
var heightYGranularity = {
|
|
@@ -48,6 +49,22 @@ var doublePad = {
|
|
|
48
49
|
};
|
|
49
50
|
exports.doublePad = doublePad;
|
|
50
51
|
var orderedSizes = ['xlarge', 'large', 'medium', 'small', 'xsmall', 'xxsmall', 'hair'];
|
|
52
|
+
var showInUnits = function showInUnits(content, maxValue) {
|
|
53
|
+
var divideBy;
|
|
54
|
+
var unit;
|
|
55
|
+
var newContent = content;
|
|
56
|
+
if (maxValue > 10000000) {
|
|
57
|
+
divideBy = 1000000;
|
|
58
|
+
unit = 'M';
|
|
59
|
+
} else if (maxValue > 10000) {
|
|
60
|
+
divideBy = 1000;
|
|
61
|
+
unit = 'K';
|
|
62
|
+
}
|
|
63
|
+
if (divideBy) newContent = (0, _Chart.round)(newContent / divideBy, 0);
|
|
64
|
+
if (unit) newContent = "" + newContent + unit;
|
|
65
|
+
return newContent;
|
|
66
|
+
};
|
|
67
|
+
exports.showInUnits = showInUnits;
|
|
51
68
|
var largestSize = function largestSize(size1, size2) {
|
|
52
69
|
if (size1 && !size2) return size1;
|
|
53
70
|
if (size2 && !size1) return size2;
|
|
@@ -105,4 +122,12 @@ var createDateFormat = function createDateFormat(firstValue, lastValue, full) {
|
|
|
105
122
|
}
|
|
106
123
|
return dateFormat;
|
|
107
124
|
};
|
|
108
|
-
exports.createDateFormat = createDateFormat;
|
|
125
|
+
exports.createDateFormat = createDateFormat;
|
|
126
|
+
var minimum = function minimum(value1, value2) {
|
|
127
|
+
return value1 !== undefined ? Math.min(value1, value2) : value2;
|
|
128
|
+
};
|
|
129
|
+
exports.minimum = minimum;
|
|
130
|
+
var maximum = function maximum(value1, value2) {
|
|
131
|
+
return value1 !== undefined ? Math.max(value1, value2) : value2;
|
|
132
|
+
};
|
|
133
|
+
exports.maximum = maximum;
|
|
@@ -16,6 +16,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
18
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
|
+
// empirical constants for when we change inputs
|
|
20
|
+
var maxCheckBoxGroupOptions = 4;
|
|
21
|
+
var minSelectSearchOptions = 10;
|
|
19
22
|
var getValueAt = function getValueAt(valueObject, pathArg) {
|
|
20
23
|
if (valueObject === undefined) return undefined;
|
|
21
24
|
var path = Array.isArray(pathArg) ? pathArg : pathArg.split('.');
|
|
@@ -60,6 +63,9 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
60
63
|
unfilteredData = _useContext.unfilteredData;
|
|
61
64
|
var _useContext2 = (0, _react.useContext)(_FormContext.FormContext),
|
|
62
65
|
noForm = _useContext2.noForm;
|
|
66
|
+
var _useState = (0, _react.useState)(''),
|
|
67
|
+
searchText = _useState[0],
|
|
68
|
+
setSearchText = _useState[1];
|
|
63
69
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
64
70
|
var _properties$property, _properties$property2;
|
|
65
71
|
if (children) return [undefined, undefined]; // caller driving
|
|
@@ -87,6 +93,19 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
87
93
|
}, [children, data, optionsProp, properties, property, rangeProp, unfilteredData]),
|
|
88
94
|
options = _useMemo[0],
|
|
89
95
|
range = _useMemo[1];
|
|
96
|
+
var searchedOptions = (0, _react.useMemo)(function () {
|
|
97
|
+
if (!searchText) return options;
|
|
98
|
+
// The line below escapes regular expression special characters:
|
|
99
|
+
// [ \ ^ $ . | ? * + ( )
|
|
100
|
+
var escapedText = searchText.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
101
|
+
// Create the regular expression with modified value which
|
|
102
|
+
// handles escaping special characters. Without escaping special
|
|
103
|
+
// characters, errors will appear in the console
|
|
104
|
+
var exp = new RegExp(escapedText, 'i');
|
|
105
|
+
return options.filter(function (o) {
|
|
106
|
+
return typeof o === 'string' ? exp.test(o) : exp.test(o.label);
|
|
107
|
+
});
|
|
108
|
+
}, [options, searchText]);
|
|
90
109
|
var id = dataId + "-" + property;
|
|
91
110
|
var content = children;
|
|
92
111
|
if (!content) {
|
|
@@ -110,7 +129,7 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
110
129
|
name: property,
|
|
111
130
|
options: booleanOptions
|
|
112
131
|
});
|
|
113
|
-
} else if (options.length
|
|
132
|
+
} else if (options.length <= maxCheckBoxGroupOptions) {
|
|
114
133
|
content = /*#__PURE__*/_react["default"].createElement(_CheckBoxGroup.CheckBoxGroup, {
|
|
115
134
|
id: id,
|
|
116
135
|
name: property,
|
|
@@ -121,7 +140,11 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
121
140
|
id: id,
|
|
122
141
|
name: property,
|
|
123
142
|
showSelectedInline: true,
|
|
124
|
-
options:
|
|
143
|
+
options: searchedOptions,
|
|
144
|
+
onSearch: options.length >= minSelectSearchOptions ? setSearchText : undefined,
|
|
145
|
+
onClose: function onClose() {
|
|
146
|
+
return setSearchText('');
|
|
147
|
+
}
|
|
125
148
|
});
|
|
126
149
|
}
|
|
127
150
|
}
|
|
@@ -35,7 +35,7 @@ var Content = function Content(_ref) {
|
|
|
35
35
|
var _useContext2 = (0, _react.useContext)(_MessageContext.MessageContext),
|
|
36
36
|
format = _useContext2.format;
|
|
37
37
|
var options = (0, _react.useMemo)(function () {
|
|
38
|
-
return optionsArg || properties && Object.keys(properties).sort() || Object.keys(data[0]).sort();
|
|
38
|
+
return optionsArg || properties && Object.keys(properties).sort() || data.length > 0 && Object.keys(data[0]).sort() || data;
|
|
39
39
|
}, [data, optionsArg, properties]);
|
|
40
40
|
var directionOptions = [{
|
|
41
41
|
label: format({
|
|
@@ -32,7 +32,12 @@ var datumValue = function datumValue(datum, property) {
|
|
|
32
32
|
// get the primary property name
|
|
33
33
|
exports.datumValue = datumValue;
|
|
34
34
|
var normalizePrimaryProperty = function normalizePrimaryProperty(columns, primaryKey) {
|
|
35
|
-
var result
|
|
35
|
+
var result;
|
|
36
|
+
if (typeof primaryKey === 'string' || typeof primaryKey === 'boolean') {
|
|
37
|
+
result = primaryKey;
|
|
38
|
+
} else if (primaryKey === null) {
|
|
39
|
+
console.warn('null is not a supported value for primaryKey. See supported values: https://v2.grommet.io/datatable#primaryKey');
|
|
40
|
+
}
|
|
36
41
|
if (result === undefined) {
|
|
37
42
|
columns.forEach(function (column) {
|
|
38
43
|
// remember the first key property
|
|
@@ -142,6 +142,26 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
|
142
142
|
}
|
|
143
143
|
}, [range, schema, textValue, reference, value]);
|
|
144
144
|
|
|
145
|
+
// textValue of MaskedInput is controlled.
|
|
146
|
+
// for uncontrolled forms, ensure the reset event
|
|
147
|
+
// resets the textValue
|
|
148
|
+
(0, _react.useEffect)(function () {
|
|
149
|
+
var _ref$current;
|
|
150
|
+
var form = ref == null ? void 0 : (_ref$current = ref.current) == null ? void 0 : _ref$current.form;
|
|
151
|
+
var handleFormReset = function handleFormReset(e) {
|
|
152
|
+
if (schema && ref.current && e.target.contains(ref.current)) {
|
|
153
|
+
setTextValue('');
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
// place the listener on the form directly. if listener is on window,
|
|
157
|
+
// the event could get blocked if caller has e.stopPropagation(), etc. in
|
|
158
|
+
// their form onReset
|
|
159
|
+
form == null ? void 0 : form.addEventListener('reset', handleFormReset);
|
|
160
|
+
return function () {
|
|
161
|
+
return form == null ? void 0 : form.removeEventListener('reset', handleFormReset);
|
|
162
|
+
};
|
|
163
|
+
}, [schema, ref]);
|
|
164
|
+
|
|
145
165
|
// when format and not inline, whether to show the Calendar in a Drop
|
|
146
166
|
var _useState4 = (0, _react.useState)(),
|
|
147
167
|
open = _useState4[0],
|
|
@@ -190,8 +210,8 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
|
190
210
|
if (open && !range) {
|
|
191
211
|
closeCalendar();
|
|
192
212
|
setTimeout(function () {
|
|
193
|
-
var _ref$
|
|
194
|
-
return (_ref$
|
|
213
|
+
var _ref$current2;
|
|
214
|
+
return (_ref$current2 = ref.current) == null ? void 0 : _ref$current2.focus();
|
|
195
215
|
}, 1);
|
|
196
216
|
}
|
|
197
217
|
}
|
|
@@ -54,13 +54,17 @@ var DoubleFooter = function DoubleFooter() {
|
|
|
54
54
|
flex: true
|
|
55
55
|
})), /*#__PURE__*/_react["default"].createElement(_grommet.Footer, {
|
|
56
56
|
background: "dark-1",
|
|
57
|
-
pad: "large"
|
|
57
|
+
pad: "large",
|
|
58
|
+
title: "Links",
|
|
59
|
+
role: "contentinfo"
|
|
58
60
|
}, /*#__PURE__*/_react["default"].createElement(FooterContent, null)), /*#__PURE__*/_react["default"].createElement(_grommet.Footer, {
|
|
59
61
|
background: "dark-2",
|
|
60
62
|
pad: {
|
|
61
63
|
horizontal: 'large',
|
|
62
64
|
vertical: 'small'
|
|
63
|
-
}
|
|
65
|
+
},
|
|
66
|
+
title: "Copyright",
|
|
67
|
+
role: "none"
|
|
64
68
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
65
69
|
direction: "row",
|
|
66
70
|
gap: "small"
|
|
@@ -61,11 +61,9 @@ var Sitemap = function Sitemap() {
|
|
|
61
61
|
align: "center",
|
|
62
62
|
gap: "small"
|
|
63
63
|
}, /*#__PURE__*/_react["default"].createElement(_grommetIcons.Grommet, {
|
|
64
|
-
color: "brand",
|
|
65
64
|
size: "large"
|
|
66
65
|
}), /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
67
66
|
alignSelf: "center",
|
|
68
|
-
color: "brand",
|
|
69
67
|
weight: "bold"
|
|
70
68
|
}, "grommet.io"))), /*#__PURE__*/_react["default"].createElement(FooterContent, null)))
|
|
71
69
|
// </Grommet>
|
|
@@ -37,7 +37,7 @@ var Social = function Social() {
|
|
|
37
37
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
38
38
|
// <Grommet theme={...}>
|
|
39
39
|
_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Main, {
|
|
40
|
-
background: "light-
|
|
40
|
+
background: "light-1",
|
|
41
41
|
elevation: "large",
|
|
42
42
|
pad: "medium",
|
|
43
43
|
gap: "large"
|
|
@@ -47,7 +47,7 @@ var Social = function Social() {
|
|
|
47
47
|
}, "Main Content"), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
48
48
|
flex: true
|
|
49
49
|
})), /*#__PURE__*/_react["default"].createElement(_grommet.Footer, {
|
|
50
|
-
background: "light-
|
|
50
|
+
background: "light-3",
|
|
51
51
|
pad: "small"
|
|
52
52
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
53
53
|
align: "center",
|
package/components/Menu/Menu.js
CHANGED
|
@@ -272,15 +272,15 @@ var Menu = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
272
272
|
}));
|
|
273
273
|
} : content));
|
|
274
274
|
var menuItem = function menuItem(item, index) {
|
|
275
|
-
var _theme$menu$item, _theme$menu$item2, _theme$menu$item3;
|
|
275
|
+
var _theme$menu$item, _theme$menu$item2, _theme$menu$item3, _theme$menu$item4;
|
|
276
276
|
// Determine whether the label is done as a child or
|
|
277
277
|
// as an option Button kind property.
|
|
278
278
|
var child = !theme.button.option ? /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
279
|
-
align:
|
|
279
|
+
align: ((_theme$menu$item = theme.menu.item) == null ? void 0 : _theme$menu$item.align) || 'start',
|
|
280
280
|
pad: "small",
|
|
281
281
|
direction: "row",
|
|
282
|
-
gap: item.gap || ((_theme$menu$
|
|
283
|
-
justify: item.justify || ((_theme$menu$
|
|
282
|
+
gap: item.gap || ((_theme$menu$item2 = theme.menu.item) == null ? void 0 : _theme$menu$item2.gap),
|
|
283
|
+
justify: item.justify || ((_theme$menu$item3 = theme.menu.item) == null ? void 0 : _theme$menu$item3.justify)
|
|
284
284
|
}, item.reverse && item.label, item.icon, !item.reverse && item.label) : undefined;
|
|
285
285
|
|
|
286
286
|
// if we have a child, turn on plain, and hoverIndicator
|
|
@@ -306,7 +306,7 @@ var Menu = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
306
306
|
kind: !child ? 'option' : undefined,
|
|
307
307
|
hoverIndicator: !child ? undefined : 'background'
|
|
308
308
|
}, theme.menu.item, {
|
|
309
|
-
justify: item.justify || ((_theme$menu$
|
|
309
|
+
justify: item.justify || ((_theme$menu$item4 = theme.menu.item) == null ? void 0 : _theme$menu$item4.justify)
|
|
310
310
|
}, !child ? item : _extends({}, item, {
|
|
311
311
|
gap: undefined,
|
|
312
312
|
icon: undefined,
|
|
@@ -391,7 +391,10 @@ var Menu = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
391
391
|
overflow: "auto",
|
|
392
392
|
role: "menu",
|
|
393
393
|
a11yTitle: a11y
|
|
394
|
-
}, menuContent), !initialAlignTop && (
|
|
394
|
+
}, menuContent), !initialAlignTop && (
|
|
395
|
+
// don't show controlMirror if caller is using
|
|
396
|
+
// align.bottom === 'top'
|
|
397
|
+
alignControlMirror === 'bottom' && !align.bottom === 'top' || align.bottom === 'bottom') ? controlMirror : undefined))
|
|
395
398
|
}), content));
|
|
396
399
|
});
|
|
397
400
|
exports.Menu = Menu;
|
|
@@ -223,7 +223,7 @@ var Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
223
223
|
// element to show, trumps inputValue
|
|
224
224
|
var selectValue = (0, _react.useMemo)(function () {
|
|
225
225
|
if (valueLabel instanceof Function) {
|
|
226
|
-
if (value) return valueLabel(value);
|
|
226
|
+
if (value || value === 0 || value === false) return valueLabel(value);
|
|
227
227
|
} else if (valueLabel) return valueLabel;else if ( /*#__PURE__*/_react["default"].isValidElement(value)) return value; // deprecated
|
|
228
228
|
return undefined;
|
|
229
229
|
}, [value, valueLabel]);
|