grommet 2.25.1 → 2.25.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/Anchor/Anchor.js +14 -1
- package/components/Button/Button.js +82 -9
- package/components/Button/StyledButtonKind.js +9 -3
- package/components/Button/index.d.ts +1 -1
- package/components/Button/propTypes.js +1 -1
- package/components/DataChart/DataChart.js +11 -13
- package/components/DataChart/XAxis.js +29 -18
- package/components/DataTable/DataTable.js +13 -9
- package/components/DataTable/buildState.js +2 -2
- package/components/DataTable/index.d.ts +4 -1
- package/components/DataTable/stories/SpaceX.js +3 -1
- package/components/DataTable/stories/SpaceXUngrouped.js +6 -2
- package/components/Form/Form.js +72 -4
- package/components/FormField/FormField.js +4 -1
- package/components/Grommet/Grommet.js +7 -2
- package/components/Grommet/index.d.ts +1 -0
- package/components/Grommet/propTypes.js +2 -1
- package/components/Heading/Heading.js +4 -2
- package/components/Heading/StyledHeading.js +1 -1
- package/components/Heading/index.d.ts +1 -0
- package/components/Heading/propTypes.js +2 -1
- package/components/Layer/LayerContainer.js +18 -0
- package/components/Menu/Menu.js +7 -4
- package/components/Menu/stories/CustomThemed/Themed.tsx +6 -0
- package/components/Meter/Circle.js +5 -1
- package/components/PageHeader/PageHeader.js +22 -13
- package/components/PageHeader/index.d.ts +10 -1
- package/components/PageHeader/propTypes.js +1 -0
- package/components/PageHeader/stories/Size.js +55 -0
- package/components/Select/SelectContainer.js +77 -44
- package/components/Select/stories/Clear.js +7 -1
- package/components/Select/utils.js +1 -0
- package/components/Spinner/Spinner.js +1 -0
- package/components/Tab/Tab.js +1 -1
- package/components/Tabs/Tabs.js +9 -1
- package/contexts/AnalyticsContext/AnalyticsContext.js +65 -0
- package/contexts/AnalyticsContext/index.d.ts +7 -0
- package/contexts/AnalyticsContext/index.js +11 -0
- package/contexts/index.js +8 -0
- package/es6/components/Anchor/Anchor.js +14 -2
- package/es6/components/Button/Button.js +83 -11
- package/es6/components/Button/StyledButtonKind.js +9 -3
- package/es6/components/Button/index.d.ts +1 -1
- package/es6/components/Button/propTypes.js +1 -1
- package/es6/components/DataChart/DataChart.js +11 -13
- package/es6/components/DataChart/XAxis.js +29 -19
- package/es6/components/DataTable/DataTable.js +13 -9
- package/es6/components/DataTable/buildState.js +2 -2
- package/es6/components/DataTable/index.d.ts +4 -1
- package/es6/components/DataTable/stories/SpaceX.js +3 -1
- package/es6/components/DataTable/stories/SpaceXUngrouped.js +6 -2
- package/es6/components/Form/Form.js +70 -4
- package/es6/components/FormField/FormField.js +4 -1
- package/es6/components/Grommet/Grommet.js +6 -2
- package/es6/components/Grommet/index.d.ts +1 -0
- package/es6/components/Grommet/propTypes.js +2 -1
- package/es6/components/Heading/Heading.js +4 -2
- package/es6/components/Heading/StyledHeading.js +1 -1
- package/es6/components/Heading/index.d.ts +1 -0
- package/es6/components/Heading/propTypes.js +2 -1
- package/es6/components/Layer/LayerContainer.js +17 -0
- package/es6/components/Menu/Menu.js +7 -4
- package/es6/components/Menu/stories/CustomThemed/Themed.tsx +6 -0
- package/es6/components/Meter/Circle.js +5 -1
- package/es6/components/PageHeader/PageHeader.js +24 -14
- package/es6/components/PageHeader/index.d.ts +10 -1
- package/es6/components/PageHeader/propTypes.js +1 -0
- package/es6/components/PageHeader/stories/Size.js +43 -0
- package/es6/components/Select/SelectContainer.js +76 -45
- package/es6/components/Select/stories/Clear.js +7 -1
- package/es6/components/Select/utils.js +1 -0
- package/es6/components/Spinner/Spinner.js +1 -0
- package/es6/components/Tab/Tab.js +1 -1
- package/es6/components/Tabs/Tabs.js +8 -1
- package/es6/contexts/AnalyticsContext/AnalyticsContext.js +47 -0
- package/es6/contexts/AnalyticsContext/index.d.ts +7 -0
- package/es6/contexts/AnalyticsContext/index.js +1 -0
- package/es6/contexts/index.js +1 -0
- package/es6/themes/base.d.ts +40 -8
- package/es6/themes/base.js +43 -0
- package/es6/utils/mixins.js +3 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +36 -30
- package/themes/base.d.ts +40 -8
- package/themes/base.js +43 -0
- package/tools/pack.js +20 -13
- package/tools/release-stable.js +2 -4
- package/utils/mixins.js +7 -1
|
@@ -17,6 +17,8 @@ var _StyledAnchor = require("./StyledAnchor");
|
|
|
17
17
|
|
|
18
18
|
var _propTypes = require("./propTypes");
|
|
19
19
|
|
|
20
|
+
var _AnalyticsContext = require("../../contexts/AnalyticsContext");
|
|
21
|
+
|
|
20
22
|
var _excluded = ["a11yTitle", "aria-label", "children", "color", "disabled", "gap", "href", "icon", "label", "onBlur", "onClick", "onFocus", "reverse"];
|
|
21
23
|
|
|
22
24
|
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); }
|
|
@@ -38,7 +40,7 @@ var Anchor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
38
40
|
icon = _ref.icon,
|
|
39
41
|
label = _ref.label,
|
|
40
42
|
_onBlur = _ref.onBlur,
|
|
41
|
-
|
|
43
|
+
onClickProp = _ref.onClick,
|
|
42
44
|
_onFocus = _ref.onFocus,
|
|
43
45
|
reverse = _ref.reverse,
|
|
44
46
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -49,6 +51,17 @@ var Anchor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
49
51
|
focus = _useState[0],
|
|
50
52
|
setFocus = _useState[1];
|
|
51
53
|
|
|
54
|
+
var sendAnalytics = (0, _AnalyticsContext.useAnalytics)();
|
|
55
|
+
var onClick = (0, _react.useCallback)(function (event) {
|
|
56
|
+
sendAnalytics({
|
|
57
|
+
type: 'anchorClick',
|
|
58
|
+
element: event.target,
|
|
59
|
+
event: event,
|
|
60
|
+
href: href,
|
|
61
|
+
label: typeof label === 'string' ? label : undefined
|
|
62
|
+
});
|
|
63
|
+
if (onClickProp) onClickProp(event);
|
|
64
|
+
}, [onClickProp, sendAnalytics, label, href]);
|
|
52
65
|
(0, _react.useEffect)(function () {
|
|
53
66
|
if ((icon || label) && children) {
|
|
54
67
|
console.warn('Anchor should not have children if icon or label is provided');
|
|
@@ -23,6 +23,8 @@ var _StyledButton = require("./StyledButton");
|
|
|
23
23
|
|
|
24
24
|
var _StyledButtonKind = require("./StyledButtonKind");
|
|
25
25
|
|
|
26
|
+
var _AnalyticsContext = require("../../contexts/AnalyticsContext");
|
|
27
|
+
|
|
26
28
|
var _excluded = ["active", "align", "aria-label", "badge", "color", "children", "disabled", "icon", "focusIndicator", "gap", "fill", "href", "justify", "kind", "label", "onBlur", "onClick", "onFocus", "onMouseOut", "onMouseOver", "plain", "primary", "reverse", "secondary", "selected", "size", "tip", "type", "a11yTitle", "as"];
|
|
27
29
|
|
|
28
30
|
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); }
|
|
@@ -67,7 +69,8 @@ var getIconColor = function getIconColor(paths, theme, colorProp, kind) {
|
|
|
67
69
|
if (typeof kind === 'object') index = 0; // stop when we have a color or no more paths
|
|
68
70
|
|
|
69
71
|
while (index >= 0 && !result[1]) {
|
|
70
|
-
var
|
|
72
|
+
var baseObj = typeof kind === 'object' && kind || theme.button;
|
|
73
|
+
var obj = baseObj; // find sub-object under the button theme that corresponds with this path
|
|
71
74
|
// for example: 'active.primary'
|
|
72
75
|
|
|
73
76
|
if (paths[index]) {
|
|
@@ -79,14 +82,30 @@ var getIconColor = function getIconColor(paths, theme, colorProp, kind) {
|
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
if (obj) {
|
|
85
|
+
var _obj, _obj$icon, _obj$icon$props;
|
|
86
|
+
|
|
82
87
|
// use passed in color for background if the theme has a background color
|
|
83
88
|
var background = colorProp && obj.background && obj.background.color ? colorProp : obj.background; // if theme object explicitly sets the color to undefined, pass false
|
|
84
89
|
// to indicate that the theme doesn't want any text color
|
|
85
90
|
|
|
86
|
-
var objColor = obj.color || (Object.prototype.hasOwnProperty.call(obj, 'color') && obj.color === undefined ? false : undefined);
|
|
91
|
+
var objColor = obj.color || (Object.prototype.hasOwnProperty.call(obj, 'color') && obj.color === undefined ? false : undefined);
|
|
92
|
+
var color = void 0;
|
|
93
|
+
if ((_obj = obj) != null && (_obj$icon = _obj.icon) != null && (_obj$icon$props = _obj$icon.props) != null && _obj$icon$props.color) color = obj.icon.props.color; // if no icon defined for this state, see if there is an icon
|
|
94
|
+
// with color defined at one higher level
|
|
95
|
+
else if (paths[index + 1]) {
|
|
96
|
+
var _obj2, _obj2$icon, _obj2$icon$props;
|
|
97
|
+
|
|
98
|
+
var _parts = paths[index + 1].split('.');
|
|
99
|
+
|
|
100
|
+
while (baseObj && _parts.length) {
|
|
101
|
+
obj = baseObj[_parts.shift()];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if ((_obj2 = obj) != null && (_obj2$icon = _obj2.icon) != null && (_obj2$icon$props = _obj2$icon.props) != null && _obj2$icon$props.color) color = obj.icon.props.color;
|
|
105
|
+
} // use passed in color for text if the theme doesn't have
|
|
87
106
|
// background or border color
|
|
88
107
|
|
|
89
|
-
|
|
108
|
+
if (!color) color = colorProp && (!obj.background || !obj.background.color) && (!obj.border || !obj.border.color) ? colorProp : objColor;
|
|
90
109
|
result = (0, _utils.backgroundAndTextColors)(background, color, theme);
|
|
91
110
|
}
|
|
92
111
|
|
|
@@ -94,6 +113,39 @@ var getIconColor = function getIconColor(paths, theme, colorProp, kind) {
|
|
|
94
113
|
}
|
|
95
114
|
|
|
96
115
|
return result[1] || undefined;
|
|
116
|
+
}; // get the icon for the current button state
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
var getKindIcon = function getKindIcon(paths, theme, kind) {
|
|
120
|
+
if (paths === void 0) {
|
|
121
|
+
paths = [];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var result;
|
|
125
|
+
var index = paths.length - 1; // caller has specified a themeObj to use for styling
|
|
126
|
+
// relevant for cases like pagination which looks to theme.pagination.button
|
|
127
|
+
|
|
128
|
+
if (typeof kind === 'object') index = 0; // stop when we have a color or no more paths
|
|
129
|
+
|
|
130
|
+
while (index >= 0 && !result) {
|
|
131
|
+
var _obj3;
|
|
132
|
+
|
|
133
|
+
var obj = typeof kind === 'object' && kind || theme.button; // find sub-object under the button theme that corresponds with this path
|
|
134
|
+
// for example: 'active.primary'
|
|
135
|
+
|
|
136
|
+
if (paths[index]) {
|
|
137
|
+
var parts = paths[index].split('.');
|
|
138
|
+
|
|
139
|
+
while (obj && parts.length) {
|
|
140
|
+
obj = obj[parts.shift()];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if ((_obj3 = obj) != null && _obj3.icon) result = obj.icon;
|
|
145
|
+
index -= 1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return result || undefined;
|
|
97
149
|
};
|
|
98
150
|
|
|
99
151
|
var getPropertyColor = function getPropertyColor(property, paths, theme, kind, primary) {
|
|
@@ -127,6 +179,8 @@ var getPropertyColor = function getPropertyColor(property, paths, theme, kind, p
|
|
|
127
179
|
};
|
|
128
180
|
|
|
129
181
|
var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
182
|
+
var _theme$button$kind;
|
|
183
|
+
|
|
130
184
|
var active = _ref.active,
|
|
131
185
|
_ref$align = _ref.align,
|
|
132
186
|
align = _ref$align === void 0 ? 'center' : _ref$align,
|
|
@@ -145,13 +199,13 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
145
199
|
kindArg = _ref.kind,
|
|
146
200
|
label = _ref.label,
|
|
147
201
|
_onBlur = _ref.onBlur,
|
|
148
|
-
|
|
202
|
+
onClickProp = _ref.onClick,
|
|
149
203
|
_onFocus = _ref.onFocus,
|
|
150
204
|
onMouseOut = _ref.onMouseOut,
|
|
151
205
|
onMouseOver = _ref.onMouseOver,
|
|
152
206
|
plain = _ref.plain,
|
|
153
207
|
primary = _ref.primary,
|
|
154
|
-
|
|
208
|
+
reverseProp = _ref.reverse,
|
|
155
209
|
secondary = _ref.secondary,
|
|
156
210
|
selected = _ref.selected,
|
|
157
211
|
size = _ref.size,
|
|
@@ -175,9 +229,20 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
175
229
|
|
|
176
230
|
if ((icon || label) && children) {
|
|
177
231
|
console.warn('Button should not have children if icon or label is provided');
|
|
178
|
-
}
|
|
179
|
-
// outside of theme.button
|
|
232
|
+
}
|
|
180
233
|
|
|
234
|
+
var sendAnalytics = (0, _AnalyticsContext.useAnalytics)();
|
|
235
|
+
var onClick = (0, _react.useCallback)(function (event) {
|
|
236
|
+
sendAnalytics({
|
|
237
|
+
type: 'buttonClick',
|
|
238
|
+
element: event.target,
|
|
239
|
+
event: event,
|
|
240
|
+
href: href,
|
|
241
|
+
label: typeof label === 'string' ? label : undefined
|
|
242
|
+
});
|
|
243
|
+
if (onClickProp) onClickProp(event);
|
|
244
|
+
}, [onClickProp, sendAnalytics, href, label]); // kindArg is object if we are referencing a theme object
|
|
245
|
+
// outside of theme.button
|
|
181
246
|
|
|
182
247
|
var kindObj = (0, _react.useMemo)(function () {
|
|
183
248
|
return typeof kindArg === 'object';
|
|
@@ -255,7 +320,8 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
255
320
|
}
|
|
256
321
|
};
|
|
257
322
|
|
|
258
|
-
var
|
|
323
|
+
var kindIcon = hover && getKindIcon(themePaths == null ? void 0 : themePaths.hover, theme, kind) || getKindIcon(themePaths == null ? void 0 : themePaths.base, theme, kind);
|
|
324
|
+
var buttonIcon = icon || kindIcon; // only change color if user did not specify the color themselves...
|
|
259
325
|
|
|
260
326
|
if (icon && !icon.props.color) {
|
|
261
327
|
if (kind) {
|
|
@@ -271,8 +337,15 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
271
337
|
color: theme.global.colors.text[isDarkBackground() ? 'dark' : 'light']
|
|
272
338
|
});
|
|
273
339
|
}
|
|
340
|
+
} else if (kindIcon && !plain) {
|
|
341
|
+
var _iconColor = hover && getIconColor(themePaths.hover, theme) || getIconColor(themePaths.base, theme, color, kind);
|
|
342
|
+
|
|
343
|
+
if (_iconColor) buttonIcon = /*#__PURE__*/(0, _react.cloneElement)(kindIcon, {
|
|
344
|
+
color: _iconColor
|
|
345
|
+
});
|
|
274
346
|
}
|
|
275
347
|
|
|
348
|
+
var reverse = reverseProp != null ? reverseProp : (_theme$button$kind = theme.button[kind]) == null ? void 0 : _theme$button$kind.reverse;
|
|
276
349
|
var domTag = !as && href ? 'a' : as;
|
|
277
350
|
var first = reverse ? label : buttonIcon;
|
|
278
351
|
var second = reverse ? buttonIcon : label;
|
|
@@ -367,7 +440,7 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
367
440
|
href: href,
|
|
368
441
|
kind: kind,
|
|
369
442
|
themePaths: themePaths,
|
|
370
|
-
onClick: onClick,
|
|
443
|
+
onClick: onClickProp ? onClick : undefined,
|
|
371
444
|
onFocus: function onFocus(event) {
|
|
372
445
|
setFocus(true);
|
|
373
446
|
if (_onFocus) _onFocus(event);
|
|
@@ -29,11 +29,17 @@ var fontStyle = function fontStyle(props) {
|
|
|
29
29
|
return (0, _styledComponents.css)(["font-size:", ";line-height:", ";"], data.size, data.height);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
var padFromTheme = function padFromTheme(size, theme, themeObj) {
|
|
32
|
+
var padFromTheme = function padFromTheme(size, theme, themeObj, kind) {
|
|
33
|
+
var _themeObj$size, _themeObj$size$size, _themeObj$size$size$k;
|
|
34
|
+
|
|
33
35
|
if (size === void 0) {
|
|
34
36
|
size = 'medium';
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
if (size && themeObj != null && (_themeObj$size = themeObj.size) != null && (_themeObj$size$size = _themeObj$size[size]) != null && (_themeObj$size$size$k = _themeObj$size$size[kind]) != null && _themeObj$size$size$k.pad) {
|
|
40
|
+
return themeObj.size[size][kind].pad;
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
if (size && themeObj.size && themeObj.size[size] && themeObj.size[size].pad) {
|
|
38
44
|
return {
|
|
39
45
|
vertical: themeObj.size[size].pad.vertical,
|
|
@@ -58,7 +64,7 @@ var padStyle = function padStyle(_ref) {
|
|
|
58
64
|
// caller has specified a themeObj to use for styling
|
|
59
65
|
// relevant for cases like pagination which looks to theme.pagination.button
|
|
60
66
|
var themeObj = typeof kind === 'object' ? kind : theme.button;
|
|
61
|
-
var pad = padFromTheme(size, theme, themeObj);
|
|
67
|
+
var pad = padFromTheme(size, theme, themeObj, kind);
|
|
62
68
|
return pad ? (0, _styledComponents.css)(["padding:", " ", ";"], pad.vertical, pad.horizontal) : '';
|
|
63
69
|
};
|
|
64
70
|
|
|
@@ -97,7 +103,7 @@ var kindStyle = function kindStyle(_ref2) {
|
|
|
97
103
|
// relevant for cases like pagination which looks to theme.pagination.button
|
|
98
104
|
|
|
99
105
|
var themeObj = typeof kind === 'object' ? kind : theme.button;
|
|
100
|
-
var pad = padFromTheme(size, theme, themeObj);
|
|
106
|
+
var pad = padFromTheme(size, theme, themeObj, kind);
|
|
101
107
|
themePaths.base.forEach(function (themePath) {
|
|
102
108
|
var obj = getPath(themeObj, themePath);
|
|
103
109
|
|
|
@@ -64,7 +64,7 @@ export interface ButtonProps {
|
|
|
64
64
|
primary?: boolean;
|
|
65
65
|
reverse?: boolean;
|
|
66
66
|
secondary?: boolean;
|
|
67
|
-
size?: 'small' | 'medium' | 'large';
|
|
67
|
+
size?: 'small' | 'medium' | 'large' | string;
|
|
68
68
|
tip?: TipProps | string;
|
|
69
69
|
type?: 'button' | 'reset' | 'submit';
|
|
70
70
|
as?: PolymorphicType;
|
|
@@ -38,7 +38,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
38
38
|
primary: _propTypes["default"].bool,
|
|
39
39
|
reverse: _propTypes["default"].bool,
|
|
40
40
|
secondary: _propTypes["default"].bool,
|
|
41
|
-
size: _propTypes["default"].oneOf(['small', 'medium', 'large']),
|
|
41
|
+
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['small', 'medium', 'large']), _propTypes["default"].string]),
|
|
42
42
|
target: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['_self', '_blank', '_parent', '_top']), _propTypes["default"].string]),
|
|
43
43
|
tip: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
44
44
|
content: _propTypes["default"].oneOfType([_propTypes["default"].node, _propTypes["default"].string]),
|
|
@@ -514,22 +514,18 @@ var DataChart = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
514
514
|
|
|
515
515
|
var offsetPad = (0, _react.useMemo)(function () {
|
|
516
516
|
return offsets ? offsets[offsets.length - 1] + thicknesses[thicknesses.length - 1] + "px" : undefined;
|
|
517
|
-
}, [offsets, thicknesses]); // The thickness of the
|
|
517
|
+
}, [offsets, thicknesses]); // The thickness of the segments. We need to convert to numbers
|
|
518
518
|
// to be able to compare across charts where some might be using T-shirt
|
|
519
519
|
// labels and others might be pixel values.
|
|
520
520
|
|
|
521
|
-
var
|
|
521
|
+
var segmentThickness = (0, _react.useMemo)(function () {
|
|
522
522
|
var result = 0;
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
result = Math.max(result, (0, _utils.parseMetricToNum)(theme.global.edgeSize[thickness] || thickness));
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
|
|
523
|
+
charts.forEach(function (_, index) {
|
|
524
|
+
var thickness = chartProps[index].thickness;
|
|
525
|
+
result = Math.max(result, (0, _utils.parseMetricToNum)(theme.global.edgeSize[thickness] || thickness));
|
|
526
|
+
});
|
|
531
527
|
return result + "px";
|
|
532
|
-
}, [charts, chartProps,
|
|
528
|
+
}, [charts, chartProps, theme]);
|
|
533
529
|
var dateFormats = (0, _react.useMemo)(function () {
|
|
534
530
|
var result = {};
|
|
535
531
|
var full = axis && axis.x && axis.x.granularity === 'coarse';
|
|
@@ -574,10 +570,12 @@ var DataChart = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
574
570
|
end: offsetPad
|
|
575
571
|
}) : pad,
|
|
576
572
|
renderValue: renderValue,
|
|
573
|
+
thickness: segmentThickness,
|
|
577
574
|
serie: axis.x.property && getPropertySeries(axis.x.property),
|
|
578
575
|
style: offsetPad ? {
|
|
579
576
|
transform: "translate(" + offsets[Math.floor(offsets.length / 2)] + "px, 0px)"
|
|
580
|
-
} : {}
|
|
577
|
+
} : {},
|
|
578
|
+
theme: theme
|
|
581
579
|
}) : null;
|
|
582
580
|
var yAxisElement = axis && axis.y && (chartProps.length || boundsProp != null && boundsProp.y) ? /*#__PURE__*/_react["default"].createElement(_YAxis.YAxis, {
|
|
583
581
|
axis: axis,
|
|
@@ -682,7 +680,7 @@ var DataChart = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
682
680
|
series: series,
|
|
683
681
|
seriesStyles: seriesStyles,
|
|
684
682
|
renderValue: renderValue,
|
|
685
|
-
thickness:
|
|
683
|
+
thickness: segmentThickness
|
|
686
684
|
}));
|
|
687
685
|
|
|
688
686
|
var legendElement = legend ? /*#__PURE__*/_react["default"].createElement(_Legend.Legend, {
|
|
@@ -5,9 +5,11 @@ exports.XAxis = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
|
+
|
|
8
10
|
var _Box = require("../Box");
|
|
9
11
|
|
|
10
|
-
var _excluded = ["values", "pad", "renderValue", "serie"];
|
|
12
|
+
var _excluded = ["values", "pad", "renderValue", "serie", "theme", "thickness"];
|
|
11
13
|
|
|
12
14
|
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); }
|
|
13
15
|
|
|
@@ -19,40 +21,49 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
19
21
|
|
|
20
22
|
var XAxis = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
21
23
|
var values = _ref.values,
|
|
22
|
-
|
|
24
|
+
padProp = _ref.pad,
|
|
23
25
|
renderValue = _ref.renderValue,
|
|
24
26
|
serie = _ref.serie,
|
|
27
|
+
theme = _ref.theme,
|
|
28
|
+
thickness = _ref.thickness,
|
|
25
29
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
26
30
|
|
|
27
|
-
//
|
|
28
|
-
//
|
|
31
|
+
// pad to the edge of the thickness, for when padding is more than half
|
|
32
|
+
// the thickness
|
|
33
|
+
var pad = (0, _react.useMemo)(function () {
|
|
34
|
+
return {
|
|
35
|
+
start: (0, _utils.edgeToNum)(padProp.start || padProp.horizontal, theme) - (0, _utils.edgeToNum)(thickness, theme) / 2 + "px",
|
|
36
|
+
end: (0, _utils.edgeToNum)(padProp.end || padProp.horizontal, theme) - (0, _utils.edgeToNum)(thickness, theme) / 2 + "px"
|
|
37
|
+
};
|
|
38
|
+
}, [padProp, theme, thickness]); // When there are only labels at the end of the axis and there isn't
|
|
39
|
+
// much space for them, let them take as much space as they like
|
|
40
|
+
// flowing in from the edges.
|
|
41
|
+
// Otherwise, align their container to the
|
|
29
42
|
// data/guide lines and then let their content overflow that.
|
|
30
|
-
var itemProps = values.length === 2 ? {} : {
|
|
31
|
-
width: '1px',
|
|
32
|
-
overflow: 'visible',
|
|
33
|
-
align: 'center'
|
|
34
|
-
};
|
|
35
|
-
var horizontal = pad.horizontal,
|
|
36
|
-
start = pad.start,
|
|
37
|
-
end = pad.end; // ignore vertical parts
|
|
38
43
|
|
|
44
|
+
var labelContainerProps = (0, _react.useMemo)(function () {
|
|
45
|
+
// 24px was chosen empirically as 48px is enough to show some simple text
|
|
46
|
+
var centered = values.length !== 2 || (0, _utils.edgeToNum)(padProp.start || padProp.horizontal, theme) >= 24;
|
|
47
|
+
if (centered) return {
|
|
48
|
+
width: thickness,
|
|
49
|
+
overflow: 'visible',
|
|
50
|
+
align: 'center'
|
|
51
|
+
};
|
|
52
|
+
return {};
|
|
53
|
+
}, [padProp, theme, thickness, values]);
|
|
39
54
|
return /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
|
|
40
55
|
ref: ref,
|
|
41
56
|
gridArea: "xAxis",
|
|
42
57
|
direction: "row",
|
|
43
58
|
justify: "between",
|
|
44
|
-
pad:
|
|
45
|
-
horizontal: horizontal,
|
|
46
|
-
start: start,
|
|
47
|
-
end: end
|
|
48
|
-
}
|
|
59
|
+
pad: pad
|
|
49
60
|
}, rest), values.map(function (dataIndex, i) {
|
|
50
61
|
return (
|
|
51
62
|
/*#__PURE__*/
|
|
52
63
|
// eslint-disable-next-line react/no-array-index-key
|
|
53
64
|
_react["default"].createElement(_Box.Box, _extends({
|
|
54
65
|
key: i
|
|
55
|
-
},
|
|
66
|
+
}, labelContainerProps), serie ? renderValue(serie, dataIndex) : dataIndex)
|
|
56
67
|
);
|
|
57
68
|
}));
|
|
58
69
|
});
|
|
@@ -135,11 +135,14 @@ var DataTable = function DataTable(_ref) {
|
|
|
135
135
|
|
|
136
136
|
var _useState5 = (0, _react.useState)(sortProp || {}),
|
|
137
137
|
sort = _useState5[0],
|
|
138
|
-
setSort = _useState5[1];
|
|
138
|
+
setSort = _useState5[1];
|
|
139
|
+
|
|
140
|
+
(0, _react.useEffect)(function () {
|
|
141
|
+
if (sortProp) setSort(sortProp);
|
|
142
|
+
}, [sortProp]); // the data filtered and sorted, if needed
|
|
139
143
|
// Note: onUpdate mode expects the data to be passed
|
|
140
144
|
// in completely filtered and sorted already.
|
|
141
145
|
|
|
142
|
-
|
|
143
146
|
var adjustedData = (0, _react.useMemo)(function () {
|
|
144
147
|
return onUpdate ? data : (0, _buildState.filterAndSortData)(data, filters, onSearch, sort);
|
|
145
148
|
}, [data, filters, onSearch, onUpdate, sort]); // the values to put in the footer cells
|
|
@@ -393,6 +396,7 @@ var DataTable = function DataTable(_ref) {
|
|
|
393
396
|
items = _usePagination[0],
|
|
394
397
|
paginationProps = _usePagination[1];
|
|
395
398
|
|
|
399
|
+
var paginationStep = paginationProps.step;
|
|
396
400
|
var Container = paginate ? _StyledDataTable.StyledContainer : _react.Fragment;
|
|
397
401
|
var containterProps = paginate ? _extends({}, theme.dataTable.container, {
|
|
398
402
|
fill: fill
|
|
@@ -446,13 +450,13 @@ var DataTable = function DataTable(_ref) {
|
|
|
446
450
|
expanded: Object.keys(groupState).filter(function (k) {
|
|
447
451
|
return groupState[k].expanded;
|
|
448
452
|
}),
|
|
449
|
-
count: limit +
|
|
453
|
+
count: limit + paginationStep
|
|
450
454
|
};
|
|
451
455
|
if (sort != null && sort.property) opts.sort = sort;
|
|
452
456
|
if (showProp) opts.show = showProp;
|
|
453
457
|
onUpdate(opts);
|
|
454
458
|
setLimit(function (prev) {
|
|
455
|
-
return prev +
|
|
459
|
+
return prev + paginationStep;
|
|
456
460
|
});
|
|
457
461
|
}
|
|
458
462
|
} : onMore,
|
|
@@ -466,7 +470,7 @@ var DataTable = function DataTable(_ref) {
|
|
|
466
470
|
rowProps: rowProps,
|
|
467
471
|
selected: selected,
|
|
468
472
|
size: size,
|
|
469
|
-
step:
|
|
473
|
+
step: paginationStep,
|
|
470
474
|
verticalAlign: typeof verticalAlign === 'string' ? verticalAlign : verticalAlign == null ? void 0 : verticalAlign.body
|
|
471
475
|
}) : /*#__PURE__*/_react["default"].createElement(_Body.Body, {
|
|
472
476
|
ref: bodyRef,
|
|
@@ -477,13 +481,13 @@ var DataTable = function DataTable(_ref) {
|
|
|
477
481
|
onMore: onUpdate ? function () {
|
|
478
482
|
if (adjustedData.length === limit) {
|
|
479
483
|
var opts = {
|
|
480
|
-
count: limit +
|
|
484
|
+
count: limit + paginationStep
|
|
481
485
|
};
|
|
482
486
|
if (sort != null && sort.property) opts.sort = sort;
|
|
483
487
|
if (showProp) opts.show = showProp;
|
|
484
488
|
onUpdate(opts);
|
|
485
489
|
setLimit(function (prev) {
|
|
486
|
-
return prev +
|
|
490
|
+
return prev + paginationStep;
|
|
487
491
|
});
|
|
488
492
|
}
|
|
489
493
|
} : onMore,
|
|
@@ -500,7 +504,7 @@ var DataTable = function DataTable(_ref) {
|
|
|
500
504
|
selected: selected,
|
|
501
505
|
show: !paginate ? showProp : undefined,
|
|
502
506
|
size: size,
|
|
503
|
-
step:
|
|
507
|
+
step: paginationStep,
|
|
504
508
|
rowDetails: rowDetails,
|
|
505
509
|
rowExpand: rowExpand,
|
|
506
510
|
setRowExpand: setRowExpand,
|
|
@@ -562,7 +566,7 @@ var DataTable = function DataTable(_ref) {
|
|
|
562
566
|
}), placeholder && items && items.length > 0 && /*#__PURE__*/_react["default"].createElement(_StyledDataTable.StyledPlaceholder, {
|
|
563
567
|
top: headerHeight,
|
|
564
568
|
bottom: footerHeight
|
|
565
|
-
}, placeholderContent))), paginate && adjustedData.length >
|
|
569
|
+
}, placeholderContent))), paginate && adjustedData.length > paginationStep && items && items.length ? /*#__PURE__*/_react["default"].createElement(_Pagination.Pagination, _extends({
|
|
566
570
|
alignSelf: "end"
|
|
567
571
|
}, paginationProps)) : null);
|
|
568
572
|
};
|
|
@@ -110,8 +110,8 @@ var filterAndSortData = function filterAndSortData(data, filters, onSearch, sort
|
|
|
110
110
|
var d1Val = datumValue(d1, property);
|
|
111
111
|
var d2Val = datumValue(d2, property);
|
|
112
112
|
|
|
113
|
-
if (typeof d1Val === 'string' && typeof d2Val === 'string') {
|
|
114
|
-
var sortResult = d1Val.localeCompare(d2Val, undefined, {
|
|
113
|
+
if (typeof d1Val === 'string' && typeof d2Val === 'string' || typeof d1Val === 'string' && !d2Val || typeof d2Val === 'string' && !d1Val) {
|
|
114
|
+
var sortResult = (d1Val || '').localeCompare(d2Val || '', undefined, {
|
|
115
115
|
sensitivity: 'base'
|
|
116
116
|
});
|
|
117
117
|
return sortAsc ? sortResult : -sortResult;
|
|
@@ -129,7 +129,10 @@ export interface DataTableProps<TRowType = any> {
|
|
|
129
129
|
|
|
130
130
|
export interface DataTableExtendedProps<TRowType = any>
|
|
131
131
|
extends DataTableProps<TRowType>,
|
|
132
|
-
Omit<
|
|
132
|
+
Omit<
|
|
133
|
+
JSX.IntrinsicElements['table'],
|
|
134
|
+
'onSelect' | 'placeholder' | 'border'
|
|
135
|
+
> {}
|
|
133
136
|
|
|
134
137
|
declare class DataTable<TRowType = any> extends React.Component<
|
|
135
138
|
DataTableExtendedProps<TRowType>
|
|
@@ -41,7 +41,9 @@ var columns = [{
|
|
|
41
41
|
}
|
|
42
42
|
}, (_datum$failures = datum.failures) == null ? void 0 : _datum$failures.map(function (_ref) {
|
|
43
43
|
var reason = _ref.reason;
|
|
44
|
-
return /*#__PURE__*/_react["default"].createElement(_grommet.Text,
|
|
44
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
45
|
+
key: reason
|
|
46
|
+
}, reason);
|
|
45
47
|
}));
|
|
46
48
|
|
|
47
49
|
return /*#__PURE__*/_react["default"].createElement(_grommet.Tip, {
|
|
@@ -28,7 +28,9 @@ var columns = [{
|
|
|
28
28
|
header: 'Rocket',
|
|
29
29
|
size: 'small',
|
|
30
30
|
render: function render(datum) {
|
|
31
|
-
return /*#__PURE__*/_react["default"].createElement(_grommet.Text,
|
|
31
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
32
|
+
key: datum.rocket.name
|
|
33
|
+
}, datum.rocket.name);
|
|
32
34
|
}
|
|
33
35
|
}, {
|
|
34
36
|
property: 'success',
|
|
@@ -44,7 +46,9 @@ var columns = [{
|
|
|
44
46
|
}
|
|
45
47
|
}, (_datum$failures = datum.failures) == null ? void 0 : _datum$failures.map(function (_ref) {
|
|
46
48
|
var reason = _ref.reason;
|
|
47
|
-
return /*#__PURE__*/_react["default"].createElement(_grommet.Text,
|
|
49
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
50
|
+
key: reason
|
|
51
|
+
}, reason);
|
|
48
52
|
}));
|
|
49
53
|
|
|
50
54
|
return /*#__PURE__*/_react["default"].createElement(_grommet.Tip, {
|