grommet 2.32.1 → 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/CheckBox/StyledCheckBox.js +2 -2
- 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/Layer/LayerContainer.js +1 -1
- package/components/Menu/Menu.js +9 -6
- 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/Select/EmptySearchOption.js +3 -9
- package/components/Select/Select.js +1 -1
- 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/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/CheckBox/StyledCheckBox.js +2 -2
- 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/Layer/LayerContainer.js +1 -1
- package/es6/components/Menu/Menu.js +9 -6
- 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/Select/EmptySearchOption.js +3 -9
- package/es6/components/Select/Select.js +1 -1
- 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/themes/base.d.ts +9 -1
- package/es6/themes/base.js +4 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +39 -39
- package/themes/base.d.ts +9 -1
- package/themes/base.js +4 -0
|
@@ -1,57 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
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); }
|
|
2
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
3
|
+
import { edgeToNum } from '../../utils';
|
|
3
4
|
import { Box } from '../Box';
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { showInUnits } from './utils';
|
|
6
|
+
var onlyVerticalPad = function onlyVerticalPad(pad) {
|
|
7
|
+
var result;
|
|
8
|
+
if (pad) {
|
|
9
|
+
if (typeof pad === 'string') result = {
|
|
10
|
+
vertical: pad
|
|
11
|
+
};else result = {
|
|
12
|
+
vertical: pad.vertical,
|
|
13
|
+
top: pad.top,
|
|
14
|
+
bottom: pad.bottom
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
6
19
|
var YAxis = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
7
20
|
var values = _ref.values,
|
|
8
|
-
|
|
21
|
+
padProp = _ref.pad,
|
|
9
22
|
renderValue = _ref.renderValue,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} else if (maxValue > 10000) {
|
|
26
|
-
divideBy = 1000;
|
|
27
|
-
unit = 'K';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
23
|
+
serie = _ref.serie,
|
|
24
|
+
theme = _ref.theme,
|
|
25
|
+
thickness = _ref.thickness;
|
|
26
|
+
var _ref2 = serie || {},
|
|
27
|
+
render = _ref2.render,
|
|
28
|
+
suffix = _ref2.suffix;
|
|
29
|
+
|
|
30
|
+
// pad to the edge of the thickness, for when padding is more than half
|
|
31
|
+
// the thickness
|
|
32
|
+
var pad = useMemo(function () {
|
|
33
|
+
return padProp && thickness && {
|
|
34
|
+
top: edgeToNum(padProp.top || padProp.vertical, theme) - edgeToNum(thickness, theme) / 2 + "px",
|
|
35
|
+
bottom: edgeToNum(padProp.bottom || padProp.vertical, theme) - edgeToNum(thickness, theme) / 2 + "px"
|
|
36
|
+
} || onlyVerticalPad(padProp);
|
|
37
|
+
}, [padProp, theme, thickness]);
|
|
30
38
|
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
// When there are only labels at the end of the axis and there isn't
|
|
40
|
+
// much space for them, let them take as much space as they like
|
|
41
|
+
// flowing in from the edges.
|
|
42
|
+
// Otherwise, align their container to the
|
|
43
|
+
// data/guide lines and then let their content overflow that.
|
|
44
|
+
var labelContainerProps = useMemo(function () {
|
|
45
|
+
// 24px was chosen empirically as 48px is enough to show some simple text
|
|
46
|
+
var centered = values.length !== 2 || edgeToNum((padProp == null ? void 0 : padProp.start) || (padProp == null ? void 0 : padProp.horizontal), theme) >= 24;
|
|
47
|
+
if (centered) return {
|
|
48
|
+
basis: thickness || '1px',
|
|
49
|
+
overflow: 'visible',
|
|
50
|
+
justify: 'center'
|
|
51
|
+
};
|
|
52
|
+
return {};
|
|
53
|
+
}, [padProp, theme, thickness, values]);
|
|
35
54
|
return /*#__PURE__*/React.createElement(Box, {
|
|
36
55
|
ref: ref,
|
|
37
56
|
gridArea: "yAxis",
|
|
38
57
|
justify: "between",
|
|
39
|
-
flex: true
|
|
58
|
+
flex: true,
|
|
59
|
+
pad: pad
|
|
40
60
|
}, values.map(function (axisValue, i) {
|
|
41
|
-
var content = renderValue(serie,
|
|
42
|
-
if (content === axisValue) {
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
var content = serie ? renderValue(serie, axisValue, true) : axisValue;
|
|
62
|
+
if (content === axisValue && !render && !suffix) {
|
|
63
|
+
var maxValue = Math.max.apply(Math, values.map(function (v) {
|
|
64
|
+
return Math.abs(v);
|
|
65
|
+
}));
|
|
66
|
+
content = showInUnits(content, maxValue);
|
|
45
67
|
}
|
|
46
68
|
return /*#__PURE__*/React.createElement(Box
|
|
47
69
|
// eslint-disable-next-line react/no-array-index-key
|
|
48
|
-
, {
|
|
70
|
+
, _extends({
|
|
49
71
|
key: i,
|
|
50
|
-
align: "end"
|
|
51
|
-
|
|
52
|
-
flex: "shrink",
|
|
53
|
-
justify: basis ? 'center' : undefined
|
|
54
|
-
}, content);
|
|
72
|
+
align: "end"
|
|
73
|
+
}, labelContainerProps), content);
|
|
55
74
|
}));
|
|
56
75
|
});
|
|
57
76
|
export { YAxis };
|
|
@@ -3,16 +3,19 @@ import React, { forwardRef } from 'react';
|
|
|
3
3
|
import { Box } from '../Box';
|
|
4
4
|
var YGuide = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
5
5
|
var guide = _ref.guide,
|
|
6
|
-
padArg = _ref.pad
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
padArg = _ref.pad,
|
|
7
|
+
thickness = _ref.thickness;
|
|
8
|
+
var pad = padArg;
|
|
9
|
+
if (thickness) {
|
|
10
|
+
// omit any horizontal pad so the guides cover the thickness that
|
|
11
|
+
// is within the pad
|
|
12
|
+
if (typeof padArg === 'object') pad = _extends({}, padArg, {
|
|
13
|
+
start: 'none',
|
|
14
|
+
end: 'none'
|
|
15
|
+
});else if (typeof padArg === 'string') pad = {
|
|
16
|
+
vertical: padArg
|
|
17
|
+
};
|
|
18
|
+
}
|
|
16
19
|
return /*#__PURE__*/React.createElement(Box, {
|
|
17
20
|
ref: ref,
|
|
18
21
|
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, {
|
|
@@ -54,11 +54,13 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
54
54
|
})])
|
|
55
55
|
})]),
|
|
56
56
|
bounds: PropTypes.oneOfType([PropTypes.oneOf(['align']), PropTypes.shape({
|
|
57
|
+
x: PropTypes.arrayOf(PropTypes.number),
|
|
57
58
|
y: PropTypes.arrayOf(PropTypes.number)
|
|
58
59
|
})]),
|
|
59
60
|
chart: PropTypes.oneOfType([chartType, PropTypes.arrayOf(chartType)]),
|
|
60
61
|
data: PropTypes.arrayOf(PropTypes.shape({})),
|
|
61
62
|
detail: PropTypes.bool,
|
|
63
|
+
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
62
64
|
gap: PropTypes.oneOfType([PropTypes.oneOf(['none', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge']), PropTypes.string]),
|
|
63
65
|
guide: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
|
64
66
|
x: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
|
@@ -75,7 +77,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
75
77
|
pad: padPropType,
|
|
76
78
|
placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
77
79
|
series: PropTypes.oneOfType([seriesType, PropTypes.arrayOf(seriesType)]),
|
|
78
|
-
size: PropTypes.oneOfType([PropTypes.oneOf(['fill']), PropTypes.shape({
|
|
80
|
+
size: PropTypes.oneOfType([PropTypes.oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'fill', 'full']), PropTypes.shape({
|
|
79
81
|
height: PropTypes.oneOfType([PropTypes.oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'fill']), PropTypes.string]),
|
|
80
82
|
width: PropTypes.oneOfType([PropTypes.oneOf(['xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'fill', 'auto']), PropTypes.string])
|
|
81
83
|
})])
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, DataChart } from 'grommet';
|
|
3
|
+
var data = [];
|
|
4
|
+
for (var i = 1; i < 8; i += 1) {
|
|
5
|
+
var v = Math.sin(i / 2.0);
|
|
6
|
+
data.push({
|
|
7
|
+
percent: Math.abs(v * 100),
|
|
8
|
+
label: "Label " + i
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export var Horizontal = function Horizontal() {
|
|
12
|
+
return (
|
|
13
|
+
/*#__PURE__*/
|
|
14
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
15
|
+
// <Grommet theme={grommet}>
|
|
16
|
+
React.createElement(Box, {
|
|
17
|
+
align: "center",
|
|
18
|
+
justify: "start",
|
|
19
|
+
pad: "large"
|
|
20
|
+
}, /*#__PURE__*/React.createElement(DataChart, {
|
|
21
|
+
data: data,
|
|
22
|
+
series: [{
|
|
23
|
+
property: 'label',
|
|
24
|
+
render: function render(label) {
|
|
25
|
+
return label;
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
property: 'percent',
|
|
29
|
+
suffix: '%'
|
|
30
|
+
}],
|
|
31
|
+
direction: "horizontal",
|
|
32
|
+
size: "medium",
|
|
33
|
+
axis: {
|
|
34
|
+
x: {
|
|
35
|
+
granularity: 'fine'
|
|
36
|
+
},
|
|
37
|
+
y: {
|
|
38
|
+
property: 'label',
|
|
39
|
+
granularity: 'fine'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
guide: {
|
|
43
|
+
x: {
|
|
44
|
+
granularity: 'fine'
|
|
45
|
+
},
|
|
46
|
+
y: {
|
|
47
|
+
granularity: 'fine'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}))
|
|
51
|
+
// </Grommet>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
title: 'Visualizations/DataChart/Horizontal'
|
|
57
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { round } from '../Chart';
|
|
1
2
|
export var points = ['circle', 'diamond', 'square', 'star', 'triangle', 'triangleDown'];
|
|
2
3
|
export var heightYGranularity = {
|
|
3
4
|
xxsmall: {
|
|
@@ -40,6 +41,21 @@ export var doublePad = {
|
|
|
40
41
|
xxsmall: 'xsmall'
|
|
41
42
|
};
|
|
42
43
|
var orderedSizes = ['xlarge', 'large', 'medium', 'small', 'xsmall', 'xxsmall', 'hair'];
|
|
44
|
+
export var showInUnits = function showInUnits(content, maxValue) {
|
|
45
|
+
var divideBy;
|
|
46
|
+
var unit;
|
|
47
|
+
var newContent = content;
|
|
48
|
+
if (maxValue > 10000000) {
|
|
49
|
+
divideBy = 1000000;
|
|
50
|
+
unit = 'M';
|
|
51
|
+
} else if (maxValue > 10000) {
|
|
52
|
+
divideBy = 1000;
|
|
53
|
+
unit = 'K';
|
|
54
|
+
}
|
|
55
|
+
if (divideBy) newContent = round(newContent / divideBy, 0);
|
|
56
|
+
if (unit) newContent = "" + newContent + unit;
|
|
57
|
+
return newContent;
|
|
58
|
+
};
|
|
43
59
|
export var largestSize = function largestSize(size1, size2) {
|
|
44
60
|
if (size1 && !size2) return size1;
|
|
45
61
|
if (size2 && !size1) return size2;
|
|
@@ -95,4 +111,10 @@ export var createDateFormat = function createDateFormat(firstValue, lastValue, f
|
|
|
95
111
|
if (options) dateFormat = new Intl.DateTimeFormat(undefined, options).format;
|
|
96
112
|
}
|
|
97
113
|
return dateFormat;
|
|
114
|
+
};
|
|
115
|
+
export var minimum = function minimum(value1, value2) {
|
|
116
|
+
return value1 !== undefined ? Math.min(value1, value2) : value2;
|
|
117
|
+
};
|
|
118
|
+
export var maximum = function maximum(value1, value2) {
|
|
119
|
+
return value1 !== undefined ? Math.max(value1, value2) : value2;
|
|
98
120
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _excluded = ["children", "options", "property", "range"];
|
|
2
2
|
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); }
|
|
3
3
|
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; }
|
|
4
|
-
import React, { useContext, useMemo } from 'react';
|
|
4
|
+
import React, { useContext, useMemo, useState } from 'react';
|
|
5
5
|
import { DataContext } from '../../contexts/DataContext';
|
|
6
6
|
import { DataForm } from '../Data/DataForm';
|
|
7
7
|
import { FormContext } from '../Form/FormContext';
|
|
@@ -10,6 +10,10 @@ import { CheckBoxGroup } from '../CheckBoxGroup';
|
|
|
10
10
|
import { RangeSelector } from '../RangeSelector';
|
|
11
11
|
import { SelectMultiple } from '../SelectMultiple';
|
|
12
12
|
import { DataFilterPropTypes } from './propTypes';
|
|
13
|
+
|
|
14
|
+
// empirical constants for when we change inputs
|
|
15
|
+
var maxCheckBoxGroupOptions = 4;
|
|
16
|
+
var minSelectSearchOptions = 10;
|
|
13
17
|
var getValueAt = function getValueAt(valueObject, pathArg) {
|
|
14
18
|
if (valueObject === undefined) return undefined;
|
|
15
19
|
var path = Array.isArray(pathArg) ? pathArg : pathArg.split('.');
|
|
@@ -54,6 +58,9 @@ export var DataFilter = function DataFilter(_ref) {
|
|
|
54
58
|
unfilteredData = _useContext.unfilteredData;
|
|
55
59
|
var _useContext2 = useContext(FormContext),
|
|
56
60
|
noForm = _useContext2.noForm;
|
|
61
|
+
var _useState = useState(''),
|
|
62
|
+
searchText = _useState[0],
|
|
63
|
+
setSearchText = _useState[1];
|
|
57
64
|
var _useMemo = useMemo(function () {
|
|
58
65
|
var _properties$property, _properties$property2;
|
|
59
66
|
if (children) return [undefined, undefined]; // caller driving
|
|
@@ -81,6 +88,19 @@ export var DataFilter = function DataFilter(_ref) {
|
|
|
81
88
|
}, [children, data, optionsProp, properties, property, rangeProp, unfilteredData]),
|
|
82
89
|
options = _useMemo[0],
|
|
83
90
|
range = _useMemo[1];
|
|
91
|
+
var searchedOptions = useMemo(function () {
|
|
92
|
+
if (!searchText) return options;
|
|
93
|
+
// The line below escapes regular expression special characters:
|
|
94
|
+
// [ \ ^ $ . | ? * + ( )
|
|
95
|
+
var escapedText = searchText.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
96
|
+
// Create the regular expression with modified value which
|
|
97
|
+
// handles escaping special characters. Without escaping special
|
|
98
|
+
// characters, errors will appear in the console
|
|
99
|
+
var exp = new RegExp(escapedText, 'i');
|
|
100
|
+
return options.filter(function (o) {
|
|
101
|
+
return typeof o === 'string' ? exp.test(o) : exp.test(o.label);
|
|
102
|
+
});
|
|
103
|
+
}, [options, searchText]);
|
|
84
104
|
var id = dataId + "-" + property;
|
|
85
105
|
var content = children;
|
|
86
106
|
if (!content) {
|
|
@@ -104,7 +124,7 @@ export var DataFilter = function DataFilter(_ref) {
|
|
|
104
124
|
name: property,
|
|
105
125
|
options: booleanOptions
|
|
106
126
|
});
|
|
107
|
-
} else if (options.length
|
|
127
|
+
} else if (options.length <= maxCheckBoxGroupOptions) {
|
|
108
128
|
content = /*#__PURE__*/React.createElement(CheckBoxGroup, {
|
|
109
129
|
id: id,
|
|
110
130
|
name: property,
|
|
@@ -115,7 +135,11 @@ export var DataFilter = function DataFilter(_ref) {
|
|
|
115
135
|
id: id,
|
|
116
136
|
name: property,
|
|
117
137
|
showSelectedInline: true,
|
|
118
|
-
options:
|
|
138
|
+
options: searchedOptions,
|
|
139
|
+
onSearch: options.length >= minSelectSearchOptions ? setSearchText : undefined,
|
|
140
|
+
onClose: function onClose() {
|
|
141
|
+
return setSearchText('');
|
|
142
|
+
}
|
|
119
143
|
});
|
|
120
144
|
}
|
|
121
145
|
}
|
|
@@ -29,7 +29,7 @@ var Content = function Content(_ref) {
|
|
|
29
29
|
var _useContext2 = useContext(MessageContext),
|
|
30
30
|
format = _useContext2.format;
|
|
31
31
|
var options = useMemo(function () {
|
|
32
|
-
return optionsArg || properties && Object.keys(properties).sort() || Object.keys(data[0]).sort();
|
|
32
|
+
return optionsArg || properties && Object.keys(properties).sort() || data.length > 0 && Object.keys(data[0]).sort() || data;
|
|
33
33
|
}, [data, optionsArg, properties]);
|
|
34
34
|
var directionOptions = [{
|
|
35
35
|
label: format({
|
|
@@ -26,7 +26,12 @@ export var datumValue = function datumValue(datum, property) {
|
|
|
26
26
|
|
|
27
27
|
// get the primary property name
|
|
28
28
|
export var normalizePrimaryProperty = function normalizePrimaryProperty(columns, primaryKey) {
|
|
29
|
-
var result
|
|
29
|
+
var result;
|
|
30
|
+
if (typeof primaryKey === 'string' || typeof primaryKey === 'boolean') {
|
|
31
|
+
result = primaryKey;
|
|
32
|
+
} else if (primaryKey === null) {
|
|
33
|
+
console.warn('null is not a supported value for primaryKey. See supported values: https://v2.grommet.io/datatable#primaryKey');
|
|
34
|
+
}
|
|
30
35
|
if (result === undefined) {
|
|
31
36
|
columns.forEach(function (column) {
|
|
32
37
|
// remember the first key property
|
|
@@ -136,6 +136,26 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
136
136
|
}
|
|
137
137
|
}, [range, schema, textValue, reference, value]);
|
|
138
138
|
|
|
139
|
+
// textValue of MaskedInput is controlled.
|
|
140
|
+
// for uncontrolled forms, ensure the reset event
|
|
141
|
+
// resets the textValue
|
|
142
|
+
useEffect(function () {
|
|
143
|
+
var _ref$current;
|
|
144
|
+
var form = ref == null ? void 0 : (_ref$current = ref.current) == null ? void 0 : _ref$current.form;
|
|
145
|
+
var handleFormReset = function handleFormReset(e) {
|
|
146
|
+
if (schema && ref.current && e.target.contains(ref.current)) {
|
|
147
|
+
setTextValue('');
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
// place the listener on the form directly. if listener is on window,
|
|
151
|
+
// the event could get blocked if caller has e.stopPropagation(), etc. in
|
|
152
|
+
// their form onReset
|
|
153
|
+
form == null ? void 0 : form.addEventListener('reset', handleFormReset);
|
|
154
|
+
return function () {
|
|
155
|
+
return form == null ? void 0 : form.removeEventListener('reset', handleFormReset);
|
|
156
|
+
};
|
|
157
|
+
}, [schema, ref]);
|
|
158
|
+
|
|
139
159
|
// when format and not inline, whether to show the Calendar in a Drop
|
|
140
160
|
var _useState4 = useState(),
|
|
141
161
|
open = _useState4[0],
|
|
@@ -184,8 +204,8 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
|
|
|
184
204
|
if (open && !range) {
|
|
185
205
|
closeCalendar();
|
|
186
206
|
setTimeout(function () {
|
|
187
|
-
var _ref$
|
|
188
|
-
return (_ref$
|
|
207
|
+
var _ref$current2;
|
|
208
|
+
return (_ref$current2 = ref.current) == null ? void 0 : _ref$current2.focus();
|
|
189
209
|
}, 1);
|
|
190
210
|
}
|
|
191
211
|
}
|
|
@@ -49,13 +49,17 @@ export var DoubleFooter = function DoubleFooter() {
|
|
|
49
49
|
flex: true
|
|
50
50
|
})), /*#__PURE__*/React.createElement(Footer, {
|
|
51
51
|
background: "dark-1",
|
|
52
|
-
pad: "large"
|
|
52
|
+
pad: "large",
|
|
53
|
+
title: "Links",
|
|
54
|
+
role: "contentinfo"
|
|
53
55
|
}, /*#__PURE__*/React.createElement(FooterContent, null)), /*#__PURE__*/React.createElement(Footer, {
|
|
54
56
|
background: "dark-2",
|
|
55
57
|
pad: {
|
|
56
58
|
horizontal: 'large',
|
|
57
59
|
vertical: 'small'
|
|
58
|
-
}
|
|
60
|
+
},
|
|
61
|
+
title: "Copyright",
|
|
62
|
+
role: "none"
|
|
59
63
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
60
64
|
direction: "row",
|
|
61
65
|
gap: "small"
|
|
@@ -56,11 +56,9 @@ export var Sitemap = function Sitemap() {
|
|
|
56
56
|
align: "center",
|
|
57
57
|
gap: "small"
|
|
58
58
|
}, /*#__PURE__*/React.createElement(GrommetIcon, {
|
|
59
|
-
color: "brand",
|
|
60
59
|
size: "large"
|
|
61
60
|
}), /*#__PURE__*/React.createElement(Text, {
|
|
62
61
|
alignSelf: "center",
|
|
63
|
-
color: "brand",
|
|
64
62
|
weight: "bold"
|
|
65
63
|
}, "grommet.io"))), /*#__PURE__*/React.createElement(FooterContent, null)))
|
|
66
64
|
// </Grommet>
|
|
@@ -35,7 +35,7 @@ export var Social = function Social() {
|
|
|
35
35
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
36
36
|
// <Grommet theme={...}>
|
|
37
37
|
React.createElement(Box, null, /*#__PURE__*/React.createElement(Main, {
|
|
38
|
-
background: "light-
|
|
38
|
+
background: "light-1",
|
|
39
39
|
elevation: "large",
|
|
40
40
|
pad: "medium",
|
|
41
41
|
gap: "large"
|
|
@@ -45,7 +45,7 @@ export var Social = function Social() {
|
|
|
45
45
|
}, "Main Content"), /*#__PURE__*/React.createElement(Box, {
|
|
46
46
|
flex: true
|
|
47
47
|
})), /*#__PURE__*/React.createElement(Footer, {
|
|
48
|
-
background: "light-
|
|
48
|
+
background: "light-3",
|
|
49
49
|
pad: "small"
|
|
50
50
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
51
51
|
align: "center",
|
|
@@ -250,7 +250,7 @@ var LayerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
250
250
|
// restricting scroll could inhibit the user's
|
|
251
251
|
// ability to scroll the page while the layer is open.
|
|
252
252
|
,
|
|
253
|
-
restrictScroll: !layerTarget && hitResponsiveBreakpoint ? true : undefined,
|
|
253
|
+
restrictScroll: !layerTarget && (modal || hitResponsiveBreakpoint) ? true : undefined,
|
|
254
254
|
trapFocus: true
|
|
255
255
|
}, content);
|
|
256
256
|
}
|
|
@@ -266,15 +266,15 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
266
266
|
}));
|
|
267
267
|
} : content));
|
|
268
268
|
var menuItem = function menuItem(item, index) {
|
|
269
|
-
var _theme$menu$item, _theme$menu$item2, _theme$menu$item3;
|
|
269
|
+
var _theme$menu$item, _theme$menu$item2, _theme$menu$item3, _theme$menu$item4;
|
|
270
270
|
// Determine whether the label is done as a child or
|
|
271
271
|
// as an option Button kind property.
|
|
272
272
|
var child = !theme.button.option ? /*#__PURE__*/React.createElement(Box, {
|
|
273
|
-
align:
|
|
273
|
+
align: ((_theme$menu$item = theme.menu.item) == null ? void 0 : _theme$menu$item.align) || 'start',
|
|
274
274
|
pad: "small",
|
|
275
275
|
direction: "row",
|
|
276
|
-
gap: item.gap || ((_theme$menu$
|
|
277
|
-
justify: item.justify || ((_theme$menu$
|
|
276
|
+
gap: item.gap || ((_theme$menu$item2 = theme.menu.item) == null ? void 0 : _theme$menu$item2.gap),
|
|
277
|
+
justify: item.justify || ((_theme$menu$item3 = theme.menu.item) == null ? void 0 : _theme$menu$item3.justify)
|
|
278
278
|
}, item.reverse && item.label, item.icon, !item.reverse && item.label) : undefined;
|
|
279
279
|
|
|
280
280
|
// if we have a child, turn on plain, and hoverIndicator
|
|
@@ -300,7 +300,7 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
300
300
|
kind: !child ? 'option' : undefined,
|
|
301
301
|
hoverIndicator: !child ? undefined : 'background'
|
|
302
302
|
}, theme.menu.item, {
|
|
303
|
-
justify: item.justify || ((_theme$menu$
|
|
303
|
+
justify: item.justify || ((_theme$menu$item4 = theme.menu.item) == null ? void 0 : _theme$menu$item4.justify)
|
|
304
304
|
}, !child ? item : _extends({}, item, {
|
|
305
305
|
gap: undefined,
|
|
306
306
|
icon: undefined,
|
|
@@ -385,7 +385,10 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
385
385
|
overflow: "auto",
|
|
386
386
|
role: "menu",
|
|
387
387
|
a11yTitle: a11y
|
|
388
|
-
}, menuContent), !initialAlignTop && (
|
|
388
|
+
}, menuContent), !initialAlignTop && (
|
|
389
|
+
// don't show controlMirror if caller is using
|
|
390
|
+
// align.bottom === 'top'
|
|
391
|
+
alignControlMirror === 'bottom' && !align.bottom === 'top' || align.bottom === 'bottom') ? controlMirror : undefined))
|
|
389
392
|
}), content));
|
|
390
393
|
});
|
|
391
394
|
Menu.defaultProps = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["background", "max", "round", "size", "thickness", "direction", "values"],
|
|
1
|
+
var _excluded = ["background", "max", "round", "size", "thickness", "direction", "values", "reverse"],
|
|
2
2
|
_excluded2 = ["color", "highlight", "label", "onHover", "value"];
|
|
3
3
|
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); }
|
|
4
4
|
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; }
|
|
@@ -16,6 +16,7 @@ var Bar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
16
16
|
thicknessProp = props.thickness,
|
|
17
17
|
direction = props.direction,
|
|
18
18
|
values = props.values,
|
|
19
|
+
reverse = props.reverse,
|
|
19
20
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
20
21
|
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
21
22
|
var length = size === 'full' ? 288 : parseMetricToNum(theme.global.size[size] || size);
|
|
@@ -84,7 +85,9 @@ var Bar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
84
85
|
round: round ? {
|
|
85
86
|
size: thicknessProp
|
|
86
87
|
} : undefined
|
|
87
|
-
}, rest
|
|
88
|
+
}, rest, {
|
|
89
|
+
reverse: reverse
|
|
90
|
+
}), /*#__PURE__*/React.createElement("path", _extends({
|
|
88
91
|
d: backgroundPath,
|
|
89
92
|
fill: "none"
|
|
90
93
|
}, strokeProps(background, theme), {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
var _excluded = ["background", "color", "direction", "size", "thickness", "type", "value", "values"];
|
|
1
|
+
var _excluded = ["background", "color", "direction", "size", "thickness", "type", "reverse", "value", "values"];
|
|
2
2
|
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); }
|
|
3
3
|
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; }
|
|
4
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
4
|
+
import React, { forwardRef, useMemo, useContext } from 'react';
|
|
5
|
+
import { ThemeContext } from 'styled-components';
|
|
6
|
+
import { defaultProps } from '../../default-props';
|
|
5
7
|
import { Bar } from './Bar';
|
|
6
8
|
import { Circle } from './Circle';
|
|
7
9
|
import { MeterPropTypes } from './propTypes';
|
|
@@ -30,9 +32,12 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
30
32
|
thickness = _ref$thickness === void 0 ? 'medium' : _ref$thickness,
|
|
31
33
|
_ref$type = _ref.type,
|
|
32
34
|
type = _ref$type === void 0 ? 'bar' : _ref$type,
|
|
35
|
+
reverseProp = _ref.reverse,
|
|
33
36
|
value = _ref.value,
|
|
34
37
|
valuesProp = _ref.values,
|
|
35
38
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
39
|
+
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
40
|
+
|
|
36
41
|
// normalize values to an array of objects
|
|
37
42
|
var values = useMemo(function () {
|
|
38
43
|
if (valuesProp) return valuesProp;
|
|
@@ -42,6 +47,7 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
42
47
|
}];
|
|
43
48
|
return [];
|
|
44
49
|
}, [color, value, valuesProp]);
|
|
50
|
+
var reverse = direction === 'horizontal' && (theme.dir === 'rtl' || reverseProp) && !(theme.dir === 'rtl' && reverseProp);
|
|
45
51
|
var memoizedMax = useMemo(function () {
|
|
46
52
|
return deriveMax(values);
|
|
47
53
|
}, [values]);
|
|
@@ -54,7 +60,8 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
54
60
|
size: size,
|
|
55
61
|
thickness: thickness,
|
|
56
62
|
background: background,
|
|
57
|
-
direction: direction
|
|
63
|
+
direction: direction,
|
|
64
|
+
reverse: reverse
|
|
58
65
|
}, rest));
|
|
59
66
|
} else if (type === 'circle' || type === 'pie' || type === 'semicircle') {
|
|
60
67
|
content = /*#__PURE__*/React.createElement(Circle, _extends({
|
|
@@ -64,7 +71,8 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
64
71
|
size: size,
|
|
65
72
|
thickness: thickness,
|
|
66
73
|
type: type,
|
|
67
|
-
background: background
|
|
74
|
+
background: background,
|
|
75
|
+
reverse: reverse
|
|
68
76
|
}, rest));
|
|
69
77
|
}
|
|
70
78
|
return content;
|
|
@@ -9,7 +9,9 @@ var roundStyle = css(["border-radius:", ";"], function (props) {
|
|
|
9
9
|
var StyledMeter = styled.svg.withConfig({
|
|
10
10
|
displayName: "StyledMeter",
|
|
11
11
|
componentId: "sc-nsxarx-0"
|
|
12
|
-
})(["max-width:100%;overflow:hidden;", " ", " path{transition:stroke 0.3s,stroke-width 0.3s;}", ";"],
|
|
12
|
+
})(["max-width:100%;overflow:hidden;", " ", " ", " path{transition:stroke 0.3s,stroke-width 0.3s;}", ";"], function (props) {
|
|
13
|
+
return props.reverse && css(["transform:scale(-1,1);"]);
|
|
14
|
+
}, genericStyles, function (props) {
|
|
13
15
|
return props.round && roundStyle;
|
|
14
16
|
}, function (props) {
|
|
15
17
|
return props.theme.meter && props.theme.meter.extend;
|
|
@@ -16,6 +16,7 @@ export interface MeterProps {
|
|
|
16
16
|
gridArea?: GridAreaType;
|
|
17
17
|
margin?: MarginType;
|
|
18
18
|
max?: number;
|
|
19
|
+
reverse?: boolean;
|
|
19
20
|
round?: boolean;
|
|
20
21
|
size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'full' | string;
|
|
21
22
|
thickness?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | string;
|
|
@@ -10,6 +10,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
10
10
|
})]),
|
|
11
11
|
color: PropTypes.string,
|
|
12
12
|
max: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
13
|
+
reverse: PropTypes.bool,
|
|
13
14
|
round: PropTypes.bool,
|
|
14
15
|
size: PropTypes.oneOfType([PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'full']), PropTypes.string]),
|
|
15
16
|
thickness: PropTypes.oneOfType([PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge']), PropTypes.string]),
|