grommet 2.30.0 → 2.32.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/components/Accordion/Accordion.js +4 -2
- package/components/Accordion/index.d.ts +1 -0
- package/components/Accordion/propTypes.js +1 -0
- package/components/AccordionPanel/AccordionPanel.js +2 -1
- package/components/Anchor/Anchor.js +3 -2
- package/components/Box/Box.js +14 -4
- package/components/Box/stories/Border.js +15 -1
- package/components/Button/Badge.js +42 -43
- package/components/Button/BusyAnimation.js +51 -0
- package/components/Button/Button.js +78 -15
- package/components/Button/StyledButton.js +7 -3
- package/components/Button/StyledButtonKind.js +12 -6
- package/components/Button/index.d.ts +9 -0
- package/components/Button/propTypes.js +7 -0
- package/components/Button/stories/Busy.js +45 -0
- package/components/Calendar/stories/Dual.js +4 -6
- package/components/CheckBox/index.d.ts +1 -1
- package/components/Data/DataForm.js +45 -35
- package/components/Data/filter.js +9 -1
- package/components/Data/stories/Complex.js +63 -6
- package/components/Data/stories/Inline.js +19 -2
- package/components/DataFilter/DataFilter.js +11 -1
- package/components/DataFilters/DataFilters.js +13 -10
- package/components/DataTable/Body.js +16 -13
- package/components/DataTable/DataTable.js +4 -1
- package/components/DataTable/GroupedBody.js +1 -0
- package/components/DataTable/Header.js +1 -0
- package/components/DataTable/buildState.js +12 -10
- package/components/DataTable/stories/Controlled.js +2 -1
- package/components/DataTable/stories/ControlledGrouped.js +2 -1
- package/components/DataTable/stories/CustomThemed/Custom.js +0 -1
- package/components/DataTable/stories/CustomThemed/Fill.js +2 -1
- package/components/DataTable/stories/GroupedOnSelect.js +2 -1
- package/components/DataTable/stories/NoPrimary.js +0 -1
- package/components/DataTable/stories/OnUpdate.js +2 -1
- package/components/DataTable/stories/Served.js +2 -1
- package/components/DataTable/stories/Tunable.js +2 -1
- package/components/DataTable/stories/rowDetails.js +2 -1
- package/components/DataTableColumns/DataTableColumns.js +5 -0
- package/components/DataTableColumns/stories/Simple.js +4 -3
- package/components/DataTableGroupBy/DataTableGroupBy.js +67 -0
- package/components/DataTableGroupBy/README.md +2 -0
- package/components/DataTableGroupBy/index.d.ts +20 -0
- package/components/DataTableGroupBy/index.js +6 -0
- package/components/DataTableGroupBy/propTypes.js +17 -0
- package/components/DataTableGroupBy/stories/Simple.js +50 -0
- package/components/DataView/DataView.js +1 -1
- package/components/DateInput/DateInput.js +3 -2
- package/components/Drop/DropContainer.js +2 -2
- package/components/DropButton/DropButton.js +2 -2
- package/components/FileInput/FileInput.js +82 -53
- package/components/Form/Form.js +95 -44
- package/components/Form/stories/TriggerValidationUsingFormField.js +109 -0
- package/components/FormField/FormField.js +4 -3
- package/components/FormField/index.d.ts +1 -0
- package/components/FormField/propTypes.js +2 -1
- package/components/Grid/stories/CustomThemed/Responsive.js +0 -1
- package/components/InfiniteScroll/InfiniteScroll.js +1 -0
- package/components/Layer/Layer.js +1 -1
- package/components/Layer/LayerContainer.js +2 -2
- package/components/List/index.d.ts +2 -2
- package/components/MaskedInput/MaskedInput.js +3 -2
- package/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/components/NameValueList/NameValueList.js +1 -1
- package/components/Notification/Notification.js +7 -3
- package/components/PageHeader/PageHeader.js +6 -4
- package/components/Pagination/StyledPageControl.js +3 -1
- package/components/Paragraph/Paragraph.js +2 -2
- package/components/Paragraph/stories/All.js +5 -1
- package/components/SelectMultiple/SelectMultiple.js +24 -20
- package/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/components/SelectMultiple/SelectMultipleValue.js +1 -1
- package/components/SelectMultiple/stories/Help.js +49 -0
- package/components/Text/Text.js +2 -2
- package/components/TextInput/StyledTextInput.js +2 -1
- package/components/TextInput/TextInput.js +3 -2
- package/components/Tip/stories/HeaderActions.js +0 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +6 -0
- package/es6/components/Accordion/Accordion.js +4 -2
- package/es6/components/Accordion/index.d.ts +1 -0
- package/es6/components/Accordion/propTypes.js +1 -0
- package/es6/components/AccordionPanel/AccordionPanel.js +2 -1
- package/es6/components/Anchor/Anchor.js +4 -3
- package/es6/components/Box/Box.js +14 -4
- package/es6/components/Box/stories/Border.js +15 -1
- package/es6/components/Button/Badge.js +43 -44
- package/es6/components/Button/BusyAnimation.js +41 -0
- package/es6/components/Button/Button.js +79 -17
- package/es6/components/Button/StyledButton.js +8 -4
- package/es6/components/Button/StyledButtonKind.js +13 -7
- package/es6/components/Button/index.d.ts +9 -0
- package/es6/components/Button/propTypes.js +8 -1
- package/es6/components/Button/stories/Busy.js +37 -0
- package/es6/components/Calendar/stories/Dual.js +4 -6
- package/es6/components/CheckBox/index.d.ts +1 -1
- package/es6/components/Data/DataForm.js +43 -34
- package/es6/components/Data/filter.js +9 -1
- package/es6/components/Data/stories/Complex.js +64 -7
- package/es6/components/Data/stories/Inline.js +20 -3
- package/es6/components/DataFilter/DataFilter.js +11 -1
- package/es6/components/DataFilters/DataFilters.js +13 -10
- package/es6/components/DataTable/Body.js +15 -13
- package/es6/components/DataTable/DataTable.js +4 -1
- package/es6/components/DataTable/GroupedBody.js +1 -0
- package/es6/components/DataTable/buildState.js +12 -10
- package/es6/components/DataTableColumns/DataTableColumns.js +5 -0
- package/es6/components/DataTableColumns/stories/Simple.js +5 -4
- package/es6/components/DataTableGroupBy/DataTableGroupBy.js +60 -0
- package/es6/components/DataTableGroupBy/README.md +2 -0
- package/es6/components/DataTableGroupBy/index.d.ts +20 -0
- package/es6/components/DataTableGroupBy/index.js +1 -0
- package/es6/components/DataTableGroupBy/propTypes.js +11 -0
- package/es6/components/DataTableGroupBy/stories/Simple.js +45 -0
- package/es6/components/DataView/DataView.js +1 -1
- package/es6/components/DateInput/DateInput.js +3 -2
- package/es6/components/Drop/DropContainer.js +2 -2
- package/es6/components/DropButton/DropButton.js +2 -2
- package/es6/components/FileInput/FileInput.js +83 -53
- package/es6/components/Form/Form.js +95 -44
- package/es6/components/Form/stories/TriggerValidationUsingFormField.js +102 -0
- package/es6/components/FormField/FormField.js +4 -3
- package/es6/components/FormField/index.d.ts +1 -0
- package/es6/components/FormField/propTypes.js +2 -1
- package/es6/components/InfiniteScroll/InfiniteScroll.js +1 -0
- package/es6/components/Layer/Layer.js +1 -1
- package/es6/components/Layer/LayerContainer.js +2 -2
- package/es6/components/List/index.d.ts +2 -2
- package/es6/components/MaskedInput/MaskedInput.js +4 -3
- package/es6/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/es6/components/NameValueList/NameValueList.js +1 -1
- package/es6/components/Notification/Notification.js +7 -3
- package/es6/components/PageHeader/PageHeader.js +6 -4
- package/es6/components/Pagination/StyledPageControl.js +3 -1
- package/es6/components/Paragraph/Paragraph.js +2 -2
- package/es6/components/Paragraph/stories/All.js +5 -1
- package/es6/components/SelectMultiple/SelectMultiple.js +24 -20
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/es6/components/SelectMultiple/SelectMultipleValue.js +1 -1
- package/es6/components/SelectMultiple/stories/Help.js +42 -0
- package/es6/components/Text/Text.js +2 -2
- package/es6/components/TextInput/StyledTextInput.js +2 -1
- package/es6/components/TextInput/TextInput.js +4 -3
- package/es6/components/index.d.ts +1 -0
- package/es6/components/index.js +1 -0
- package/es6/index.d.ts +1 -0
- package/es6/languages/default.json +15 -2
- package/es6/themes/base.d.ts +3 -0
- package/es6/themes/base.js +7 -1
- package/es6/utils/icon.js +7 -0
- package/es6/utils/index.js +1 -0
- package/es6/utils/styles.js +10 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/languages/default.json +15 -2
- package/package.json +49 -48
- package/themes/base.d.ts +3 -0
- package/themes/base.js +7 -1
- package/utils/icon.js +12 -0
- package/utils/index.js +6 -0
- package/utils/styles.js +12 -1
|
@@ -19,7 +19,7 @@ var radiusStyle = function radiusStyle(props) {
|
|
|
19
19
|
var fontStyle = function fontStyle(props) {
|
|
20
20
|
var size = props.sizeProp || 'medium';
|
|
21
21
|
var data = props.theme.text[size];
|
|
22
|
-
return (0, _styledComponents.css)(["font-size:", ";line-height:", ";"], data.size, data.height);
|
|
22
|
+
return (0, _styledComponents.css)(["font-size:", ";line-height:", ";"], data.size, props.hasIcon && !props.hasLabel ? 0 : data.height);
|
|
23
23
|
};
|
|
24
24
|
var padFromTheme = function padFromTheme(size, theme, themeObj, kind, iconOnly) {
|
|
25
25
|
var _themeObj$size, _themeObj$size$size, _themeObj$size$size$i, _themeObj$size3, _themeObj$size3$size, _themeObj$size3$size$;
|
|
@@ -83,11 +83,13 @@ var adjustPadStyle = function adjustPadStyle(pad, width) {
|
|
|
83
83
|
|
|
84
84
|
// build up CSS from basic to specific based on the supplied sub-object paths
|
|
85
85
|
var kindStyle = function kindStyle(_ref2) {
|
|
86
|
-
var
|
|
86
|
+
var busy = _ref2.busy,
|
|
87
|
+
colorValue = _ref2.colorValue,
|
|
87
88
|
hasIcon = _ref2.hasIcon,
|
|
88
89
|
hasLabel = _ref2.hasLabel,
|
|
89
90
|
kind = _ref2.kind,
|
|
90
91
|
size = _ref2.sizeProp,
|
|
92
|
+
success = _ref2.success,
|
|
91
93
|
themePaths = _ref2.themePaths,
|
|
92
94
|
theme = _ref2.theme;
|
|
93
95
|
var styles = [];
|
|
@@ -134,7 +136,7 @@ var kindStyle = function kindStyle(_ref2) {
|
|
|
134
136
|
// padding in the hover or hover.kind itself for backward compatibility
|
|
135
137
|
adjPadStyles = adjustPadStyle(pad, obj.border.width);
|
|
136
138
|
}
|
|
137
|
-
if (partStyles.length > 0) {
|
|
139
|
+
if (partStyles.length > 0 && !busy && !success) {
|
|
138
140
|
styles.push((0, _styledComponents.css)(["&:hover{", " ", "}"], partStyles, adjPadStyles));
|
|
139
141
|
}
|
|
140
142
|
}
|
|
@@ -166,7 +168,7 @@ var fillStyle = function fillStyle(fillContainer) {
|
|
|
166
168
|
return undefined;
|
|
167
169
|
};
|
|
168
170
|
var plainStyle = function plainStyle(props) {
|
|
169
|
-
return (0, _styledComponents.css)(["outline:none;border:none;padding:0;text-align:inherit;color:inherit;", ""], props.icon && "\n > svg {\n display: flex;\n align-self: center;\n vertical-align: middle;\n }\n ");
|
|
171
|
+
return (0, _styledComponents.css)(["outline:none;border:none;padding:0;text-align:inherit;color:inherit;", " ", ""], props.icon && "\n > svg {\n display: flex;\n align-self: center;\n vertical-align: middle;\n }\n ", props.hasIcon && !props.hasLabel && "line-height: 0;");
|
|
170
172
|
};
|
|
171
173
|
var StyledButtonKind = _styledComponents["default"].button.withConfig({
|
|
172
174
|
// don't let kind attribute leak to DOM
|
|
@@ -177,7 +179,7 @@ var StyledButtonKind = _styledComponents["default"].button.withConfig({
|
|
|
177
179
|
}).withConfig({
|
|
178
180
|
displayName: "StyledButtonKind",
|
|
179
181
|
componentId: "sc-1vhfpnt-0"
|
|
180
|
-
})(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", ""], _utils.genericStyles, function (props) {
|
|
182
|
+
})(["display:inline-block;box-sizing:border-box;cursor:pointer;font:inherit;text-decoration:none;margin:0;background:transparent;overflow:visible;text-transform:none;", " ", " ", " ", " ", " ", " ", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}", " ", " ", " ", ""], _utils.genericStyles, function (props) {
|
|
181
183
|
return props.plain && plainStyle(props);
|
|
182
184
|
}, function (props) {
|
|
183
185
|
return !props.disabled && props.active && _utils.activeStyle;
|
|
@@ -185,10 +187,12 @@ var StyledButtonKind = _styledComponents["default"].button.withConfig({
|
|
|
185
187
|
return !props.plain && basicStyle(props);
|
|
186
188
|
}, function (props) {
|
|
187
189
|
return !props.plain && kindStyle(props);
|
|
190
|
+
}, function (props) {
|
|
191
|
+
return !props.plain && props.pad && (0, _utils.edgeStyle)('padding', props.pad, false, undefined, props.theme);
|
|
188
192
|
}, function (props) {
|
|
189
193
|
return !props.plain && props.align && "\n text-align: " + props.align + ";\n ";
|
|
190
194
|
}, function (props) {
|
|
191
|
-
return !props.disabled && props.hoverIndicator && hoverIndicatorStyle(props);
|
|
195
|
+
return !props.disabled && props.hoverIndicator && !props.busy && !props.success && hoverIndicatorStyle(props);
|
|
192
196
|
}, function (props) {
|
|
193
197
|
return props.disabled && (0, _utils.disabledStyle)(props.theme.button.disabled.opacity);
|
|
194
198
|
}, function (props) {
|
|
@@ -199,6 +203,8 @@ var StyledButtonKind = _styledComponents["default"].button.withConfig({
|
|
|
199
203
|
return props.fillContainer && fillStyle(props.fillContainer);
|
|
200
204
|
}, function (props) {
|
|
201
205
|
return props.theme.button && props.theme.button.extend;
|
|
206
|
+
}, function (props) {
|
|
207
|
+
return (props.busy || props.success) && "\n cursor: default;\n ";
|
|
202
208
|
});
|
|
203
209
|
exports.StyledButtonKind = StyledButtonKind;
|
|
204
210
|
StyledButtonKind.defaultProps = {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { string } from 'prop-types';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import {
|
|
3
4
|
A11yTitleType,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
HoverIndicatorType,
|
|
11
12
|
MarginType,
|
|
12
13
|
Omit,
|
|
14
|
+
PadType,
|
|
13
15
|
PolymorphicType,
|
|
14
16
|
} from '../../utils';
|
|
15
17
|
|
|
@@ -38,6 +40,7 @@ export interface ButtonProps {
|
|
|
38
40
|
hover: boolean;
|
|
39
41
|
focus: boolean;
|
|
40
42
|
}) => React.ReactNode);
|
|
43
|
+
busy?: boolean;
|
|
41
44
|
gridArea?: GridAreaType;
|
|
42
45
|
margin?: MarginType;
|
|
43
46
|
active?: boolean;
|
|
@@ -60,11 +63,17 @@ export interface ButtonProps {
|
|
|
60
63
|
icon?: JSX.Element;
|
|
61
64
|
kind?: string;
|
|
62
65
|
label?: React.ReactNode;
|
|
66
|
+
messages?: {
|
|
67
|
+
busy?: string;
|
|
68
|
+
success?: string;
|
|
69
|
+
};
|
|
70
|
+
pad?: PadType;
|
|
63
71
|
plain?: boolean;
|
|
64
72
|
primary?: boolean;
|
|
65
73
|
reverse?: boolean;
|
|
66
74
|
secondary?: boolean;
|
|
67
75
|
size?: 'small' | 'medium' | 'large' | string;
|
|
76
|
+
success?: boolean;
|
|
68
77
|
tip?: TipProps | string;
|
|
69
78
|
type?: 'button' | 'reset' | 'submit';
|
|
70
79
|
as?: PolymorphicType;
|
|
@@ -17,6 +17,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
17
17
|
max: _propTypes["default"].number,
|
|
18
18
|
value: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].number])
|
|
19
19
|
})]),
|
|
20
|
+
busy: _propTypes["default"].bool,
|
|
20
21
|
color: _generalPropTypes.colorPropType,
|
|
21
22
|
disabled: _propTypes["default"].bool,
|
|
22
23
|
fill: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['horizontal', 'vertical']), _propTypes["default"].bool]),
|
|
@@ -27,12 +28,18 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
27
28
|
icon: _propTypes["default"].element,
|
|
28
29
|
justify: _propTypes["default"].oneOf(['around', 'between', 'center', 'end', 'evenly', 'start', 'stretch']),
|
|
29
30
|
label: _propTypes["default"].node,
|
|
31
|
+
messages: _propTypes["default"].shape({
|
|
32
|
+
busy: _propTypes["default"].string,
|
|
33
|
+
success: _propTypes["default"].string
|
|
34
|
+
}),
|
|
30
35
|
onClick: _propTypes["default"].func,
|
|
36
|
+
pad: _generalPropTypes.padPropType,
|
|
31
37
|
plain: _propTypes["default"].bool,
|
|
32
38
|
primary: _propTypes["default"].bool,
|
|
33
39
|
reverse: _propTypes["default"].bool,
|
|
34
40
|
secondary: _propTypes["default"].bool,
|
|
35
41
|
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['small', 'medium', 'large']), _propTypes["default"].string]),
|
|
42
|
+
success: _propTypes["default"].bool,
|
|
36
43
|
target: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['_self', '_blank', '_parent', '_top']), _propTypes["default"].string]),
|
|
37
44
|
tip: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
38
45
|
content: _propTypes["default"].oneOfType([_propTypes["default"].node, _propTypes["default"].string]),
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Busy = void 0;
|
|
5
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
+
var _grommet = require("grommet");
|
|
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
|
+
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
|
+
var Busy = function Busy() {
|
|
10
|
+
var _useState = (0, _react.useState)(),
|
|
11
|
+
busy = _useState[0],
|
|
12
|
+
setBusy = _useState[1];
|
|
13
|
+
var _useState2 = (0, _react.useState)(),
|
|
14
|
+
success = _useState2[0],
|
|
15
|
+
setSuccess = _useState2[1];
|
|
16
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
17
|
+
align: "center",
|
|
18
|
+
pad: "medium"
|
|
19
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
|
|
20
|
+
primary: true,
|
|
21
|
+
busy: busy,
|
|
22
|
+
success: success,
|
|
23
|
+
label: "Button Busy",
|
|
24
|
+
onClick: function onClick() {
|
|
25
|
+
setBusy(true);
|
|
26
|
+
setTimeout(function () {
|
|
27
|
+
setBusy(false);
|
|
28
|
+
setSuccess(true);
|
|
29
|
+
}, 2000);
|
|
30
|
+
setTimeout(function () {
|
|
31
|
+
setSuccess(false);
|
|
32
|
+
}, 4000);
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
exports.Busy = Busy;
|
|
37
|
+
Busy.parameters = {
|
|
38
|
+
chromatic: {
|
|
39
|
+
disable: true
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var _default = {
|
|
43
|
+
title: 'Controls/Button/Busy'
|
|
44
|
+
};
|
|
45
|
+
exports["default"] = _default;
|
|
@@ -49,11 +49,9 @@ var Dual = function Dual() {
|
|
|
49
49
|
onReference: function onReference(reference) {
|
|
50
50
|
var refDate = new Date(reference);
|
|
51
51
|
var nextDate = new Date(refDate);
|
|
52
|
-
console.log(refDate);
|
|
53
|
-
console.log(nextDate);
|
|
54
52
|
nextDate.setMonth(refDate.getMonth() + 1, 1);
|
|
55
|
-
setReference1(refDate.
|
|
56
|
-
setReference2(nextDate.
|
|
53
|
+
setReference1(refDate.toISOString());
|
|
54
|
+
setReference2(nextDate.toISOString());
|
|
57
55
|
},
|
|
58
56
|
header: function header(_ref) {
|
|
59
57
|
var currentDate = _ref.date,
|
|
@@ -88,8 +86,8 @@ var Dual = function Dual() {
|
|
|
88
86
|
var refDate = new Date(reference);
|
|
89
87
|
var priorDate = new Date(refDate);
|
|
90
88
|
priorDate.setMonth(refDate.getMonth() - 1, 1);
|
|
91
|
-
setReference1(priorDate.
|
|
92
|
-
setReference2(refDate.
|
|
89
|
+
setReference1(priorDate.toISOString());
|
|
90
|
+
setReference2(refDate.toISOString());
|
|
93
91
|
},
|
|
94
92
|
header: function header(_ref2) {
|
|
95
93
|
var currentDate = _ref2.date,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.formViewNameKey = exports.formStepKey = exports.formSortKey = exports.formSearchKey = exports.formRangeKey = exports.formPageKey = exports.formColumnsKey = exports.DataForm = void 0;
|
|
4
|
+
exports.formViewNameKey = exports.formStepKey = exports.formSortKey = exports.formSearchKey = exports.formRangeKey = exports.formPageKey = exports.formGroupByKey = exports.formColumnsKey = exports.DataForm = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
7
|
var _Box = require("../Box");
|
|
@@ -49,6 +49,8 @@ var formPageKey = '_page';
|
|
|
49
49
|
exports.formPageKey = formPageKey;
|
|
50
50
|
var formColumnsKey = '_columns';
|
|
51
51
|
exports.formColumnsKey = formColumnsKey;
|
|
52
|
+
var formGroupByKey = '_groupBy';
|
|
53
|
+
exports.formGroupByKey = formGroupByKey;
|
|
52
54
|
var formViewNameKey = '_view';
|
|
53
55
|
exports.formViewNameKey = formViewNameKey;
|
|
54
56
|
var viewFormKeyMap = {
|
|
@@ -57,6 +59,7 @@ var viewFormKeyMap = {
|
|
|
57
59
|
step: formStepKey,
|
|
58
60
|
page: formPageKey,
|
|
59
61
|
columns: formColumnsKey,
|
|
62
|
+
groupBy: formGroupByKey,
|
|
60
63
|
view: formViewNameKey
|
|
61
64
|
};
|
|
62
65
|
|
|
@@ -119,6 +122,7 @@ var viewToFormValue = function viewToFormValue(view) {
|
|
|
119
122
|
if (view != null && view.sort) result[formSortKey] = view.sort;
|
|
120
123
|
if (view != null && view.name) result[formViewNameKey] = view.name;
|
|
121
124
|
if (view != null && view.columns) result[formColumnsKey] = view.columns;
|
|
125
|
+
if (view != null && view.groupBy) result[formGroupByKey] = view.groupBy;
|
|
122
126
|
return unflatten(result);
|
|
123
127
|
};
|
|
124
128
|
|
|
@@ -266,43 +270,49 @@ var DataForm = function DataForm(_ref) {
|
|
|
266
270
|
(0, _react.useEffect)(function () {
|
|
267
271
|
return setFormValue(viewToFormValue(view));
|
|
268
272
|
}, [view]);
|
|
273
|
+
var content = children;
|
|
274
|
+
if (footer !== false && updateOn === 'submit' || pad) {
|
|
275
|
+
content = /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
276
|
+
fill: "vertical"
|
|
277
|
+
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
278
|
+
flex: true,
|
|
279
|
+
overflow: "auto",
|
|
280
|
+
pad: {
|
|
281
|
+
horizontal: pad,
|
|
282
|
+
top: pad
|
|
283
|
+
}
|
|
284
|
+
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
285
|
+
flex: false
|
|
286
|
+
}, content)), footer !== false && updateOn === 'submit' && /*#__PURE__*/_react["default"].createElement(_Footer.Footer, {
|
|
287
|
+
flex: false,
|
|
288
|
+
margin: {
|
|
289
|
+
top: 'small'
|
|
290
|
+
},
|
|
291
|
+
pad: {
|
|
292
|
+
horizontal: pad,
|
|
293
|
+
bottom: pad
|
|
294
|
+
},
|
|
295
|
+
gap: "small"
|
|
296
|
+
}, /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
297
|
+
label: format({
|
|
298
|
+
id: 'dataForm.submit',
|
|
299
|
+
messages: messages == null ? void 0 : messages.dataForm
|
|
300
|
+
}),
|
|
301
|
+
type: "submit",
|
|
302
|
+
primary: true
|
|
303
|
+
}), /*#__PURE__*/_react["default"].createElement(HideableButton, _extends({
|
|
304
|
+
label: format({
|
|
305
|
+
id: 'dataForm.reset',
|
|
306
|
+
messages: messages == null ? void 0 : messages.dataForm
|
|
307
|
+
}),
|
|
308
|
+
type: "reset",
|
|
309
|
+
onClick: onReset
|
|
310
|
+
}, !changed ? hideButtonProps : {}))));
|
|
311
|
+
}
|
|
269
312
|
return /*#__PURE__*/_react["default"].createElement(MaxForm, _extends({}, rest, {
|
|
270
313
|
value: formValue,
|
|
271
314
|
onSubmit: updateOn === 'submit' ? onSubmit : undefined,
|
|
272
315
|
onChange: onChange
|
|
273
|
-
}),
|
|
274
|
-
fill: "vertical"
|
|
275
|
-
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
276
|
-
flex: true,
|
|
277
|
-
overflow: "auto",
|
|
278
|
-
pad: {
|
|
279
|
-
horizontal: pad,
|
|
280
|
-
top: pad
|
|
281
|
-
}
|
|
282
|
-
}, children), footer !== false && updateOn === 'submit' && /*#__PURE__*/_react["default"].createElement(_Footer.Footer, {
|
|
283
|
-
flex: false,
|
|
284
|
-
margin: {
|
|
285
|
-
top: 'small'
|
|
286
|
-
},
|
|
287
|
-
pad: {
|
|
288
|
-
horizontal: pad,
|
|
289
|
-
bottom: pad
|
|
290
|
-
},
|
|
291
|
-
gap: "small"
|
|
292
|
-
}, /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
293
|
-
label: format({
|
|
294
|
-
id: 'dataForm.submit',
|
|
295
|
-
messages: messages == null ? void 0 : messages.dataForm
|
|
296
|
-
}),
|
|
297
|
-
type: "submit",
|
|
298
|
-
primary: true
|
|
299
|
-
}), /*#__PURE__*/_react["default"].createElement(HideableButton, _extends({
|
|
300
|
-
label: format({
|
|
301
|
-
id: 'dataForm.reset',
|
|
302
|
-
messages: messages == null ? void 0 : messages.dataForm
|
|
303
|
-
}),
|
|
304
|
-
type: "reset",
|
|
305
|
-
onClick: onReset
|
|
306
|
-
}, !changed ? hideButtonProps : {})))));
|
|
316
|
+
}), content);
|
|
307
317
|
};
|
|
308
318
|
exports.DataForm = DataForm;
|
|
@@ -51,7 +51,15 @@ var filter = function filter(data, view, properties) {
|
|
|
51
51
|
if (typeof (filterValue == null ? void 0 : filterValue.min) === 'number' || typeof (filterValue == null ? void 0 : filterValue.max) === 'number') return typeof value !== 'number' || value <= filterValue.min || value >= filterValue.max;
|
|
52
52
|
|
|
53
53
|
// options case
|
|
54
|
-
if (Array.isArray(filterValue))
|
|
54
|
+
if (Array.isArray(filterValue)) {
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
return !filterValue.some(function (f) {
|
|
57
|
+
return typeof f === 'object' ? value.includes(f == null ? void 0 : f.value) // from {label: ___, value: ___}
|
|
58
|
+
: value.includes(f);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return !filterValue.includes(value);
|
|
62
|
+
}
|
|
55
63
|
|
|
56
64
|
// presence case
|
|
57
65
|
if (typeof filterValue === 'boolean') return filterValue === !value;
|
|
@@ -15,7 +15,8 @@ var data = [{
|
|
|
15
15
|
},
|
|
16
16
|
economy: {
|
|
17
17
|
GDP: 100
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
colors: ['white', 'blue']
|
|
19
20
|
}, {
|
|
20
21
|
id: 2,
|
|
21
22
|
name: 'Beta',
|
|
@@ -25,7 +26,19 @@ var data = [{
|
|
|
25
26
|
},
|
|
26
27
|
economy: {
|
|
27
28
|
GDP: 150
|
|
28
|
-
}
|
|
29
|
+
},
|
|
30
|
+
colors: ['red', 'white', 'blue']
|
|
31
|
+
}, {
|
|
32
|
+
id: 3,
|
|
33
|
+
name: 'Theta',
|
|
34
|
+
location: {
|
|
35
|
+
city: 'Berlin',
|
|
36
|
+
country: 'Germany'
|
|
37
|
+
},
|
|
38
|
+
economy: {
|
|
39
|
+
GDP: 200
|
|
40
|
+
},
|
|
41
|
+
colors: ['red', 'yellow', 'black']
|
|
29
42
|
}];
|
|
30
43
|
var properties = {
|
|
31
44
|
name: {
|
|
@@ -37,6 +50,35 @@ var properties = {
|
|
|
37
50
|
},
|
|
38
51
|
'economy.GDP': {
|
|
39
52
|
label: 'GDP'
|
|
53
|
+
},
|
|
54
|
+
colors: {
|
|
55
|
+
label: 'Flag Colors',
|
|
56
|
+
options: [{
|
|
57
|
+
label: 'Red',
|
|
58
|
+
value: 'red'
|
|
59
|
+
}, {
|
|
60
|
+
label: 'White',
|
|
61
|
+
value: 'white'
|
|
62
|
+
}, {
|
|
63
|
+
label: 'Blue',
|
|
64
|
+
value: 'blue'
|
|
65
|
+
}, {
|
|
66
|
+
label: 'Yellow',
|
|
67
|
+
value: 'yellow'
|
|
68
|
+
}, {
|
|
69
|
+
label: 'Black',
|
|
70
|
+
value: 'black'
|
|
71
|
+
}, {
|
|
72
|
+
label: 'Green',
|
|
73
|
+
value: 'green'
|
|
74
|
+
}, {
|
|
75
|
+
label: 'Orange',
|
|
76
|
+
value: 'orange'
|
|
77
|
+
}, {
|
|
78
|
+
label: 'Gray',
|
|
79
|
+
value: 'gray'
|
|
80
|
+
}],
|
|
81
|
+
search: true
|
|
40
82
|
}
|
|
41
83
|
};
|
|
42
84
|
var columns = [{
|
|
@@ -49,6 +91,17 @@ var columns = [{
|
|
|
49
91
|
}, {
|
|
50
92
|
property: 'economy.GDP',
|
|
51
93
|
header: 'GDP'
|
|
94
|
+
}, {
|
|
95
|
+
property: 'colors',
|
|
96
|
+
header: 'Flag Colors',
|
|
97
|
+
// render using map map
|
|
98
|
+
render: function render(datum) {
|
|
99
|
+
return datum.colors.map(function (item) {
|
|
100
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
101
|
+
key: item
|
|
102
|
+
}, item);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
52
105
|
}];
|
|
53
106
|
var Complex = function Complex() {
|
|
54
107
|
return (
|
|
@@ -66,10 +119,14 @@ var Complex = function Complex() {
|
|
|
66
119
|
message: "Data is in 'beta'. The API surface is subject to change."
|
|
67
120
|
}), /*#__PURE__*/_react["default"].createElement(_Data.Data, {
|
|
68
121
|
data: data,
|
|
69
|
-
properties: properties
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
122
|
+
properties: properties
|
|
123
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Toolbar, null, /*#__PURE__*/_react["default"].createElement(_grommet.DataSearch, null), /*#__PURE__*/_react["default"].createElement(_grommet.DataFilters, {
|
|
124
|
+
layer: true
|
|
125
|
+
})), /*#__PURE__*/_react["default"].createElement(_grommet.DataSummary, null), /*#__PURE__*/_react["default"].createElement(_grommet.DataTable, {
|
|
126
|
+
columns: columns,
|
|
127
|
+
verticalAlign: {
|
|
128
|
+
body: 'top'
|
|
129
|
+
}
|
|
73
130
|
})))
|
|
74
131
|
// </Grommet>
|
|
75
132
|
);
|
|
@@ -11,7 +11,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
11
11
|
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; }
|
|
12
12
|
var sizes = ['small', 'medium', 'large'];
|
|
13
13
|
var DATA = [];
|
|
14
|
-
for (var i = 0; i <
|
|
14
|
+
for (var i = 0; i < 11; i += 1) {
|
|
15
15
|
DATA.push({
|
|
16
16
|
id: "x-" + i,
|
|
17
17
|
sub: {
|
|
@@ -21,6 +21,19 @@ for (var i = 0; i < 2; i += 1) {
|
|
|
21
21
|
date: "2022-12-" + (i % 30 + 1)
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
var columns = [{
|
|
25
|
+
property: 'id',
|
|
26
|
+
header: 'ID'
|
|
27
|
+
}, {
|
|
28
|
+
property: 'sub.name',
|
|
29
|
+
header: 'Name'
|
|
30
|
+
}, {
|
|
31
|
+
property: 'size',
|
|
32
|
+
header: 'Size'
|
|
33
|
+
}, {
|
|
34
|
+
property: 'date',
|
|
35
|
+
header: 'Date'
|
|
36
|
+
}];
|
|
24
37
|
var Filters = function Filters(_ref) {
|
|
25
38
|
var search = _ref.search,
|
|
26
39
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -28,6 +41,8 @@ var Filters = function Filters(_ref) {
|
|
|
28
41
|
property: "sub.name"
|
|
29
42
|
}), /*#__PURE__*/_react["default"].createElement(_grommet.DataFilter, {
|
|
30
43
|
property: "size"
|
|
44
|
+
}), /*#__PURE__*/_react["default"].createElement(_grommet.DataTableGroupBy, {
|
|
45
|
+
options: ['size']
|
|
31
46
|
}));
|
|
32
47
|
};
|
|
33
48
|
var Inline = function Inline() {
|
|
@@ -85,7 +100,9 @@ var Inline = function Inline() {
|
|
|
85
100
|
margin: "none"
|
|
86
101
|
}, "People"), toolbar, /*#__PURE__*/_react["default"].createElement(_grommet.DataSummary, null), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
87
102
|
flex: false
|
|
88
|
-
}, /*#__PURE__*/_react["default"].createElement(_grommet.DataTable,
|
|
103
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.DataTable, {
|
|
104
|
+
columns: columns
|
|
105
|
+
})))))
|
|
89
106
|
// </Grommet>
|
|
90
107
|
);
|
|
91
108
|
};
|
|
@@ -4,6 +4,8 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.DataFilter = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _DataContext = require("../../contexts/DataContext");
|
|
7
|
+
var _DataForm = require("../Data/DataForm");
|
|
8
|
+
var _FormContext = require("../Form/FormContext");
|
|
7
9
|
var _FormField = require("../FormField");
|
|
8
10
|
var _CheckBoxGroup = require("../CheckBoxGroup");
|
|
9
11
|
var _RangeSelector = require("../RangeSelector");
|
|
@@ -56,6 +58,8 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
56
58
|
dataId = _useContext.id,
|
|
57
59
|
properties = _useContext.properties,
|
|
58
60
|
unfilteredData = _useContext.unfilteredData;
|
|
61
|
+
var _useContext2 = (0, _react.useContext)(_FormContext.FormContext),
|
|
62
|
+
noForm = _useContext2.noForm;
|
|
59
63
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
60
64
|
var _properties$property, _properties$property2;
|
|
61
65
|
if (children) return [undefined, undefined]; // caller driving
|
|
@@ -118,11 +122,17 @@ var DataFilter = function DataFilter(_ref) {
|
|
|
118
122
|
});
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
|
-
|
|
125
|
+
if (noForm)
|
|
126
|
+
// likely in Toolbar
|
|
127
|
+
content = /*#__PURE__*/_react["default"].createElement(_DataForm.DataForm, {
|
|
128
|
+
footer: false,
|
|
129
|
+
updateOn: "change"
|
|
130
|
+
}, content);else content = /*#__PURE__*/_react["default"].createElement(_FormField.FormField, _extends({
|
|
122
131
|
htmlFor: id,
|
|
123
132
|
name: property,
|
|
124
133
|
label: (properties == null ? void 0 : (_properties$property3 = properties[property]) == null ? void 0 : _properties$property3.label) || property
|
|
125
134
|
}, rest), content);
|
|
135
|
+
return content;
|
|
126
136
|
};
|
|
127
137
|
exports.DataFilter = DataFilter;
|
|
128
138
|
DataFilter.propTypes = _propTypes.DataFilterPropTypes;
|
|
@@ -118,14 +118,14 @@ var DataFilters = function DataFilters(_ref) {
|
|
|
118
118
|
} : undefined
|
|
119
119
|
}, !controlled ? rest : {
|
|
120
120
|
fill: 'vertical'
|
|
121
|
-
}),
|
|
121
|
+
}), layer && /*#__PURE__*/_react["default"].createElement(_Header.Header, null, /*#__PURE__*/_react["default"].createElement(_Heading.Heading, {
|
|
122
122
|
margin: "none",
|
|
123
123
|
level: 2,
|
|
124
124
|
size: "small"
|
|
125
125
|
}, heading || format({
|
|
126
126
|
id: 'dataFilters.heading',
|
|
127
127
|
messages: messages == null ? void 0 : messages.dataFilters
|
|
128
|
-
})), !controlled && clearControl,
|
|
128
|
+
})), !controlled && clearControl, /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
129
129
|
icon: /*#__PURE__*/_react["default"].createElement(_FormClose.FormClose, null),
|
|
130
130
|
hoverIndicator: true,
|
|
131
131
|
onClick: function onClick() {
|
|
@@ -133,14 +133,19 @@ var DataFilters = function DataFilters(_ref) {
|
|
|
133
133
|
}
|
|
134
134
|
})), content);
|
|
135
135
|
if (!controlled) return content;
|
|
136
|
+
var tip = format({
|
|
137
|
+
id: badge ? "dataFilters.openSet." + (badge === 1 ? 'singular' : 'plural') : 'dataFilters.open',
|
|
138
|
+
messages: messages == null ? void 0 : messages.dataFilters,
|
|
139
|
+
values: {
|
|
140
|
+
number: badge
|
|
141
|
+
}
|
|
142
|
+
});
|
|
136
143
|
var control;
|
|
137
144
|
if (drop) {
|
|
138
145
|
control = /*#__PURE__*/_react["default"].createElement(_DropButton.DropButton, {
|
|
139
146
|
id: dataId + "--filters-control",
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
messages: messages == null ? void 0 : messages.dataFilters
|
|
143
|
-
}),
|
|
147
|
+
tip: tip,
|
|
148
|
+
"aria-label": tip,
|
|
144
149
|
kind: "toolbar",
|
|
145
150
|
icon: /*#__PURE__*/_react["default"].createElement(_Filter.Filter, null),
|
|
146
151
|
hoverIndicator: true,
|
|
@@ -158,10 +163,8 @@ var DataFilters = function DataFilters(_ref) {
|
|
|
158
163
|
} else if (layer) {
|
|
159
164
|
control = /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
160
165
|
id: dataId + "--filters-control",
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
messages: messages == null ? void 0 : messages.dataFilters
|
|
164
|
-
}),
|
|
166
|
+
tip: tip,
|
|
167
|
+
"aria-label": tip,
|
|
165
168
|
kind: "toolbar",
|
|
166
169
|
hoverIndicator: true,
|
|
167
170
|
icon: /*#__PURE__*/_react["default"].createElement(_Filter.Filter, null),
|