grommet 2.29.1 → 2.31.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/Anchor/Anchor.js +12 -5
- package/components/Anchor/StyledAnchor.js +6 -3
- package/components/Button/Badge.js +42 -43
- package/components/Button/Button.js +21 -14
- package/components/Button/StyledButton.js +4 -2
- package/components/Button/StyledButtonKind.js +25 -9
- package/components/Button/index.d.ts +2 -0
- package/components/Button/propTypes.js +1 -0
- package/components/Calendar/Calendar.js +14 -6
- package/components/CheckBox/index.d.ts +1 -1
- package/components/Data/DataForm.js +97 -26
- package/components/Data/stories/Cards.js +1 -1
- package/components/Data/stories/Complex.js +84 -0
- package/components/Data/stories/Controlled.js +1 -1
- package/components/Data/stories/DataTable.js +11 -4
- package/components/Data/stories/Infinite.js +1 -1
- package/components/Data/stories/Inline.js +7 -2
- package/components/Data/stories/List.js +1 -1
- package/components/Data/stories/Simple.js +1 -1
- package/components/Data/stories/SpaceX.js +1 -1
- package/components/Data/stories/StarWars.js +18 -24
- package/components/Data/stories/Views.js +1 -1
- package/components/DataFilter/DataFilter.js +32 -42
- package/components/DataFilter/stories/Simple.js +7 -4
- package/components/DataFilters/DataFilters.js +76 -32
- package/components/DataFilters/index.d.ts +1 -0
- package/components/DataFilters/propTypes.js +2 -1
- package/components/DataFilters/stories/Drop.js +7 -4
- package/components/DataFilters/stories/Inline.js +24 -6
- package/components/DataFilters/stories/Layer.js +46 -0
- package/components/DataFilters/stories/Simple.js +7 -4
- package/components/DataSearch/DataSearch.js +57 -9
- package/components/DataSearch/index.d.ts +10 -1
- package/components/DataSearch/propTypes.js +6 -1
- package/components/DataSearch/stories/Drop.js +42 -0
- package/components/DataSearch/stories/Responsive.js +42 -0
- package/components/DataSearch/stories/Simple.js +5 -2
- package/components/DataSort/DataSort.js +61 -12
- package/components/DataSort/index.d.ts +4 -8
- package/components/DataSort/propTypes.js +9 -2
- package/components/DataSort/stories/Drop.js +41 -0
- package/components/DataSort/stories/Simple.js +9 -5
- package/components/DataSummary/stories/Simple.js +7 -4
- package/components/DataTable/GroupedBody.js +1 -0
- package/components/DataTable/StyledDataTable.js +2 -2
- package/components/DataTableColumns/DataTableColumns.js +2 -1
- package/components/DataTableColumns/stories/Simple.js +9 -5
- package/components/DataView/DataView.js +22 -7
- package/components/DataView/stories/Simple.js +8 -5
- package/components/DateInput/DateInput.js +2 -1
- package/components/Distribution/Distribution.js +1 -1
- package/components/Drop/DropContainer.js +32 -79
- package/components/Drop/stories/Overflow.js +1 -0
- package/components/DropButton/DropButton.js +1 -1
- package/components/Form/stories/Controlled.js +11 -2
- package/components/Form/stories/ControlledInput.js +13 -2
- package/components/Form/stories/ControlledInputLazy.js +13 -2
- package/components/Form/stories/ControlledLazy.js +13 -2
- package/components/Form/stories/FieldWithChildren.js +13 -2
- package/components/Form/stories/FieldWithComponentProp.js +17 -1
- package/components/Form/stories/Uncontrolled.js +15 -2
- package/components/Form/stories/ValidateOnChange.js +6 -0
- package/components/Form/stories/ValidateOnMount.js +4 -0
- package/components/Form/stories/typescript/TypedForm.tsx +25 -3
- package/components/Layer/LayerContainer.js +1 -1
- package/components/Layer/StyledLayer.js +3 -1
- package/components/MaskedInput/MaskedInput.js +3 -2
- package/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/components/Notification/Notification.js +7 -3
- package/components/PageHeader/PageHeader.js +6 -4
- package/components/Pagination/Pagination.js +8 -0
- package/components/Pagination/StyledPageControl.js +3 -1
- package/components/Paragraph/Paragraph.js +18 -6
- package/components/Paragraph/stories/All.js +5 -1
- package/components/SelectMultiple/SelectMultiple.js +11 -10
- package/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/components/SelectMultiple/stories/Help.js +49 -0
- package/components/Tabs/Tabs.js +2 -1
- package/components/Text/Text.js +9 -1
- package/components/Text/TextContext.js +8 -0
- package/components/TextInput/StyledTextInput.js +5 -2
- package/components/TextInput/TextInput.js +7 -4
- package/components/TextInput/index.d.ts +3 -1
- package/components/TextInput/propTypes.js +3 -1
- package/components/Toolbar/stories/Simple.js +1 -1
- package/components/WorldMap/WorldMap.js +17 -14
- package/es6/components/Anchor/Anchor.js +13 -6
- package/es6/components/Anchor/StyledAnchor.js +6 -3
- package/es6/components/Button/Badge.js +43 -44
- package/es6/components/Button/Button.js +22 -15
- package/es6/components/Button/StyledButton.js +5 -3
- package/es6/components/Button/StyledButtonKind.js +26 -10
- package/es6/components/Button/index.d.ts +2 -0
- package/es6/components/Button/propTypes.js +2 -1
- package/es6/components/Calendar/Calendar.js +14 -6
- package/es6/components/CheckBox/index.d.ts +1 -1
- package/es6/components/Data/DataForm.js +97 -26
- package/es6/components/Data/stories/Cards.js +1 -1
- package/es6/components/Data/stories/Complex.js +78 -0
- package/es6/components/Data/stories/Controlled.js +1 -1
- package/es6/components/Data/stories/DataTable.js +12 -5
- package/es6/components/Data/stories/Infinite.js +1 -1
- package/es6/components/Data/stories/Inline.js +7 -2
- package/es6/components/Data/stories/List.js +1 -1
- package/es6/components/Data/stories/Simple.js +1 -1
- package/es6/components/Data/stories/SpaceX.js +1 -1
- package/es6/components/Data/stories/StarWars.js +18 -24
- package/es6/components/Data/stories/Views.js +1 -1
- package/es6/components/DataFilter/DataFilter.js +32 -42
- package/es6/components/DataFilter/stories/Simple.js +8 -5
- package/es6/components/DataFilters/DataFilters.js +76 -32
- package/es6/components/DataFilters/index.d.ts +1 -0
- package/es6/components/DataFilters/propTypes.js +2 -1
- package/es6/components/DataFilters/stories/Drop.js +8 -5
- package/es6/components/DataFilters/stories/Inline.js +25 -7
- package/es6/components/DataFilters/stories/Layer.js +40 -0
- package/es6/components/DataFilters/stories/Simple.js +8 -5
- package/es6/components/DataSearch/DataSearch.js +58 -10
- package/es6/components/DataSearch/index.d.ts +10 -1
- package/es6/components/DataSearch/propTypes.js +5 -1
- package/es6/components/DataSearch/stories/Drop.js +36 -0
- package/es6/components/DataSearch/stories/Responsive.js +36 -0
- package/es6/components/DataSearch/stories/Simple.js +6 -3
- package/es6/components/DataSort/DataSort.js +62 -13
- package/es6/components/DataSort/index.d.ts +4 -8
- package/es6/components/DataSort/propTypes.js +8 -2
- package/es6/components/DataSort/stories/Drop.js +35 -0
- package/es6/components/DataSort/stories/Simple.js +10 -6
- package/es6/components/DataSummary/stories/Simple.js +8 -5
- package/es6/components/DataTable/GroupedBody.js +1 -0
- package/es6/components/DataTable/StyledDataTable.js +2 -2
- package/es6/components/DataTableColumns/DataTableColumns.js +2 -1
- package/es6/components/DataTableColumns/stories/Simple.js +10 -6
- package/es6/components/DataView/DataView.js +22 -7
- package/es6/components/DataView/stories/Simple.js +9 -6
- package/es6/components/DateInput/DateInput.js +2 -1
- package/es6/components/Distribution/Distribution.js +1 -1
- package/es6/components/Drop/DropContainer.js +34 -81
- package/es6/components/Drop/stories/Overflow.js +1 -0
- package/es6/components/DropButton/DropButton.js +1 -1
- package/es6/components/Form/stories/Controlled.js +11 -2
- package/es6/components/Form/stories/ControlledInput.js +13 -2
- package/es6/components/Form/stories/ControlledInputLazy.js +13 -2
- package/es6/components/Form/stories/ControlledLazy.js +13 -2
- package/es6/components/Form/stories/FieldWithChildren.js +13 -2
- package/es6/components/Form/stories/FieldWithComponentProp.js +17 -1
- package/es6/components/Form/stories/Uncontrolled.js +15 -2
- package/es6/components/Form/stories/ValidateOnChange.js +6 -0
- package/es6/components/Form/stories/ValidateOnMount.js +4 -0
- package/es6/components/Form/stories/typescript/TypedForm.tsx +25 -3
- package/es6/components/Layer/LayerContainer.js +1 -1
- package/es6/components/Layer/StyledLayer.js +3 -1
- package/es6/components/MaskedInput/MaskedInput.js +4 -3
- package/es6/components/MaskedInput/StyledMaskedInput.js +2 -1
- package/es6/components/Notification/Notification.js +7 -3
- package/es6/components/PageHeader/PageHeader.js +6 -4
- package/es6/components/Pagination/Pagination.js +8 -0
- package/es6/components/Pagination/StyledPageControl.js +3 -1
- package/es6/components/Paragraph/Paragraph.js +19 -7
- package/es6/components/Paragraph/stories/All.js +5 -1
- package/es6/components/SelectMultiple/SelectMultiple.js +11 -10
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +16 -13
- package/es6/components/SelectMultiple/stories/Help.js +42 -0
- package/es6/components/Tabs/Tabs.js +2 -1
- package/es6/components/Text/Text.js +10 -2
- package/es6/components/Text/TextContext.js +2 -0
- package/es6/components/TextInput/StyledTextInput.js +6 -3
- package/es6/components/TextInput/TextInput.js +8 -5
- package/es6/components/TextInput/index.d.ts +3 -1
- package/es6/components/TextInput/propTypes.js +3 -1
- package/es6/components/Toolbar/stories/Simple.js +1 -1
- package/es6/components/WorldMap/WorldMap.js +17 -14
- package/es6/languages/default.json +7 -2
- package/es6/themes/base.d.ts +34 -0
- package/es6/themes/base.js +37 -1
- package/es6/utils/DOM.js +1 -1
- package/es6/utils/background.js +9 -1
- package/es6/utils/colors.js +2 -2
- package/es6/utils/general-prop-types.js +1 -1
- package/es6/utils/icon.js +7 -0
- package/es6/utils/index.d.ts +7 -1
- 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/languages/default.json +7 -2
- package/package.json +41 -39
- package/themes/base.d.ts +34 -0
- package/themes/base.js +37 -1
- package/utils/DOM.js +1 -1
- package/utils/background.js +8 -0
- package/utils/colors.js +3 -1
- package/utils/general-prop-types.js +1 -1
- package/utils/icon.js +12 -0
- package/utils/index.d.ts +7 -1
- package/utils/index.js +6 -0
- package/utils/styles.js +12 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
var _excluded = ["drop", "children", "heading"];
|
|
1
|
+
var _excluded = ["drop", "children", "heading", "layer"];
|
|
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
4
|
import React, { Children, useContext, useMemo, useState } from 'react';
|
|
5
5
|
import { Filter } from 'grommet-icons/icons/Filter';
|
|
6
|
+
import { FormClose } from 'grommet-icons/icons/FormClose';
|
|
6
7
|
import { Box } from '../Box';
|
|
7
8
|
import { Button } from '../Button';
|
|
8
9
|
import { DataFilter } from '../DataFilter';
|
|
@@ -11,6 +12,7 @@ import { DataSort } from '../DataSort';
|
|
|
11
12
|
import { DropButton } from '../DropButton';
|
|
12
13
|
import { Header } from '../Header';
|
|
13
14
|
import { Heading } from '../Heading';
|
|
15
|
+
import { Layer } from '../Layer';
|
|
14
16
|
import { DataContext } from '../../contexts/DataContext';
|
|
15
17
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
16
18
|
import { DataFiltersPropTypes } from './propTypes';
|
|
@@ -20,14 +22,20 @@ var dropProps = {
|
|
|
20
22
|
right: 'right'
|
|
21
23
|
}
|
|
22
24
|
};
|
|
25
|
+
var layerProps = {
|
|
26
|
+
full: 'vertical',
|
|
27
|
+
position: 'right'
|
|
28
|
+
};
|
|
23
29
|
export var DataFilters = function DataFilters(_ref) {
|
|
24
30
|
var drop = _ref.drop,
|
|
25
31
|
children = _ref.children,
|
|
26
32
|
heading = _ref.heading,
|
|
33
|
+
layer = _ref.layer,
|
|
27
34
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
28
35
|
var _useContext = useContext(DataContext),
|
|
29
36
|
clearFilters = _useContext.clearFilters,
|
|
30
37
|
data = _useContext.data,
|
|
38
|
+
dataId = _useContext.id,
|
|
31
39
|
messages = _useContext.messages,
|
|
32
40
|
properties = _useContext.properties,
|
|
33
41
|
view = _useContext.view;
|
|
@@ -44,8 +52,8 @@ export var DataFilters = function DataFilters(_ref) {
|
|
|
44
52
|
touched = _useState2[0],
|
|
45
53
|
setTouched = _useState2[1];
|
|
46
54
|
var controlled = useMemo(function () {
|
|
47
|
-
return drop;
|
|
48
|
-
}, [drop]);
|
|
55
|
+
return drop || layer;
|
|
56
|
+
}, [drop, layer]);
|
|
49
57
|
// generate the badge value based on touched fields that have a value
|
|
50
58
|
var badge = useMemo(function () {
|
|
51
59
|
return controlled && Object.keys(touched).filter(function (k) {
|
|
@@ -53,7 +61,10 @@ export var DataFilters = function DataFilters(_ref) {
|
|
|
53
61
|
}).length || undefined;
|
|
54
62
|
}, [controlled, touched]);
|
|
55
63
|
var clearControl = badge && /*#__PURE__*/React.createElement(Box, {
|
|
56
|
-
flex: false
|
|
64
|
+
flex: false,
|
|
65
|
+
margin: {
|
|
66
|
+
start: 'small'
|
|
67
|
+
}
|
|
57
68
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
58
69
|
label: format({
|
|
59
70
|
id: 'dataFilters.clear',
|
|
@@ -64,7 +75,7 @@ export var DataFilters = function DataFilters(_ref) {
|
|
|
64
75
|
clearFilters();
|
|
65
76
|
}
|
|
66
77
|
}));
|
|
67
|
-
var
|
|
78
|
+
var content = children;
|
|
68
79
|
if (Children.count(children) === 0) {
|
|
69
80
|
var filtersFor;
|
|
70
81
|
if (!properties && data && data.length)
|
|
@@ -72,21 +83,20 @@ export var DataFilters = function DataFilters(_ref) {
|
|
|
72
83
|
filtersFor = Object.keys(data[0]).filter(function (k) {
|
|
73
84
|
return typeof data[0][k] !== 'object';
|
|
74
85
|
});else if (Array.isArray(properties)) filtersFor = properties;else if (typeof properties === 'object') filtersFor = Object.keys(properties);else filtersFor = [];
|
|
75
|
-
|
|
86
|
+
content = filtersFor.map(function (property) {
|
|
76
87
|
return /*#__PURE__*/React.createElement(DataFilter, {
|
|
77
88
|
key: property,
|
|
78
89
|
property: property
|
|
79
90
|
});
|
|
80
91
|
});
|
|
81
92
|
if (view != null && view.sort) {
|
|
82
|
-
|
|
93
|
+
content.push( /*#__PURE__*/React.createElement(DataSort, {
|
|
83
94
|
key: "_sort"
|
|
84
95
|
}));
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
|
-
|
|
98
|
+
content = /*#__PURE__*/React.createElement(DataForm, _extends({
|
|
88
99
|
pad: controlled ? 'medium' : undefined,
|
|
89
|
-
gap: "small",
|
|
90
100
|
onDone: function onDone() {
|
|
91
101
|
return setShowContent(false);
|
|
92
102
|
},
|
|
@@ -100,39 +110,73 @@ export var DataFilters = function DataFilters(_ref) {
|
|
|
100
110
|
})
|
|
101
111
|
);
|
|
102
112
|
} : undefined
|
|
103
|
-
}, !controlled ? rest : {
|
|
113
|
+
}, !controlled ? rest : {
|
|
114
|
+
fill: 'vertical'
|
|
115
|
+
}), !drop && /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(Heading, {
|
|
104
116
|
margin: "none",
|
|
105
117
|
level: 2,
|
|
106
118
|
size: "small"
|
|
107
119
|
}, heading || format({
|
|
108
120
|
id: 'dataFilters.heading',
|
|
109
121
|
messages: messages == null ? void 0 : messages.dataFilters
|
|
110
|
-
})), !controlled && clearControl
|
|
122
|
+
})), !controlled && clearControl, layer && /*#__PURE__*/React.createElement(Button, {
|
|
123
|
+
icon: /*#__PURE__*/React.createElement(FormClose, null),
|
|
124
|
+
hoverIndicator: true,
|
|
125
|
+
onClick: function onClick() {
|
|
126
|
+
return setShowContent(undefined);
|
|
127
|
+
}
|
|
128
|
+
})), content);
|
|
111
129
|
if (!controlled) return content;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
var control;
|
|
131
|
+
if (drop) {
|
|
132
|
+
control = /*#__PURE__*/React.createElement(DropButton, {
|
|
133
|
+
id: dataId + "--filters-control",
|
|
134
|
+
"aria-label": format({
|
|
135
|
+
id: 'dataFilters.open',
|
|
136
|
+
messages: messages == null ? void 0 : messages.dataFilters
|
|
137
|
+
}),
|
|
138
|
+
kind: "toolbar",
|
|
139
|
+
icon: /*#__PURE__*/React.createElement(Filter, null),
|
|
140
|
+
hoverIndicator: true,
|
|
141
|
+
dropProps: dropProps,
|
|
142
|
+
dropContent: content,
|
|
143
|
+
badge: badge,
|
|
144
|
+
open: showContent,
|
|
145
|
+
onOpen: function onOpen() {
|
|
146
|
+
return setShowContent(undefined);
|
|
147
|
+
},
|
|
148
|
+
onClose: function onClose() {
|
|
149
|
+
return setShowContent(undefined);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
} else if (layer) {
|
|
153
|
+
control = /*#__PURE__*/React.createElement(Button, {
|
|
154
|
+
id: dataId + "--filters-control",
|
|
155
|
+
"aria-label": format({
|
|
156
|
+
id: 'dataFilters.open',
|
|
157
|
+
messages: messages == null ? void 0 : messages.dataFilters
|
|
158
|
+
}),
|
|
159
|
+
kind: "toolbar",
|
|
160
|
+
hoverIndicator: true,
|
|
161
|
+
icon: /*#__PURE__*/React.createElement(Filter, null),
|
|
162
|
+
badge: badge,
|
|
163
|
+
onClick: function onClick() {
|
|
164
|
+
return setShowContent(true);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
169
|
+
flex: false,
|
|
170
|
+
direction: "row"
|
|
171
|
+
}, rest), control, clearControl, layer && showContent && /*#__PURE__*/React.createElement(Layer, _extends({
|
|
172
|
+
id: dataId + "--filters-layer"
|
|
173
|
+
}, typeof layer === 'object' ? layer : layerProps, {
|
|
174
|
+
onClickOutside: function onClickOutside() {
|
|
126
175
|
return setShowContent(undefined);
|
|
127
176
|
},
|
|
128
|
-
|
|
177
|
+
onEsc: function onEsc() {
|
|
129
178
|
return setShowContent(undefined);
|
|
130
179
|
}
|
|
131
|
-
});
|
|
132
|
-
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
133
|
-
flex: false,
|
|
134
|
-
direction: "row",
|
|
135
|
-
gap: "small"
|
|
136
|
-
}, rest), control, clearControl);
|
|
180
|
+
}), content));
|
|
137
181
|
};
|
|
138
182
|
DataFilters.propTypes = DataFiltersPropTypes;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Box, Data, DataFilter } from 'grommet';
|
|
2
|
+
import { Box, Data, DataFilter, Notification } from 'grommet';
|
|
3
3
|
import { DataFilters } from '../DataFilters';
|
|
4
4
|
import { DATA } from '../../DataTable/stories/data';
|
|
5
5
|
export var Drop = function Drop() {
|
|
@@ -8,11 +8,14 @@ export var Drop = function Drop() {
|
|
|
8
8
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
9
|
// <Grommet theme={...}>
|
|
10
10
|
React.createElement(Box, {
|
|
11
|
-
fill: true,
|
|
12
11
|
align: "center",
|
|
13
12
|
justify: "start",
|
|
14
|
-
pad: "large"
|
|
15
|
-
|
|
13
|
+
pad: "large",
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
16
|
+
status: "info",
|
|
17
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Data, {
|
|
16
19
|
data: DATA
|
|
17
20
|
}, /*#__PURE__*/React.createElement(DataFilters, {
|
|
18
21
|
drop: true
|
|
@@ -27,5 +30,5 @@ Drop.args = {
|
|
|
27
30
|
full: true
|
|
28
31
|
};
|
|
29
32
|
export default {
|
|
30
|
-
title: '
|
|
33
|
+
title: 'Data/DataFilters/Drop'
|
|
31
34
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Box, Data, DataFilter, DataSearch, DataSort } from 'grommet';
|
|
2
|
+
import { Box, Data, DataFilter, DataSearch, DataSort, DataView, Notification } from 'grommet';
|
|
3
3
|
import { DataFilters } from '../DataFilters';
|
|
4
4
|
import { DATA } from '../../DataTable/stories/data';
|
|
5
5
|
export var Inline = function Inline() {
|
|
@@ -8,13 +8,31 @@ export var Inline = function Inline() {
|
|
|
8
8
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
9
|
// <Grommet theme={...}>
|
|
10
10
|
React.createElement(Box, {
|
|
11
|
-
fill: true,
|
|
12
11
|
align: "center",
|
|
13
12
|
justify: "start",
|
|
14
|
-
pad: "large"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
pad: "large",
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
16
|
+
status: "info",
|
|
17
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Data, {
|
|
19
|
+
data: DATA,
|
|
20
|
+
views: [{
|
|
21
|
+
name: 'latest',
|
|
22
|
+
sort: {
|
|
23
|
+
property: 'date',
|
|
24
|
+
direction: 'desc'
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
name: 'behind',
|
|
28
|
+
properties: {
|
|
29
|
+
percent: {
|
|
30
|
+
min: 0,
|
|
31
|
+
max: 30
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}]
|
|
35
|
+
}, /*#__PURE__*/React.createElement(DataFilters, null, /*#__PURE__*/React.createElement(DataView, null), /*#__PURE__*/React.createElement(DataSearch, null), /*#__PURE__*/React.createElement(DataFilter, {
|
|
18
36
|
property: "location"
|
|
19
37
|
}), /*#__PURE__*/React.createElement(DataFilter, {
|
|
20
38
|
property: "percent"
|
|
@@ -27,5 +45,5 @@ Inline.args = {
|
|
|
27
45
|
full: true
|
|
28
46
|
};
|
|
29
47
|
export default {
|
|
30
|
-
title: '
|
|
48
|
+
title: 'Data/DataFilters/Inline'
|
|
31
49
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Data, DataFilter, Notification } from 'grommet';
|
|
3
|
+
import { DataFilters } from '../DataFilters';
|
|
4
|
+
import { DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var Layer = function Layer() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Box, {
|
|
11
|
+
align: "center",
|
|
12
|
+
justify: "start",
|
|
13
|
+
pad: "large",
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
16
|
+
status: "info",
|
|
17
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Data, {
|
|
19
|
+
data: DATA
|
|
20
|
+
}, /*#__PURE__*/React.createElement(DataFilters, {
|
|
21
|
+
layer: true
|
|
22
|
+
}, /*#__PURE__*/React.createElement(DataFilter, {
|
|
23
|
+
property: "name"
|
|
24
|
+
}), /*#__PURE__*/React.createElement(DataFilter, {
|
|
25
|
+
property: "location"
|
|
26
|
+
}), /*#__PURE__*/React.createElement(DataFilter, {
|
|
27
|
+
property: "percent"
|
|
28
|
+
}), /*#__PURE__*/React.createElement(DataFilter, {
|
|
29
|
+
property: "paid"
|
|
30
|
+
}))))
|
|
31
|
+
// </Grommet>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
Layer.args = {
|
|
36
|
+
full: true
|
|
37
|
+
};
|
|
38
|
+
export default {
|
|
39
|
+
title: 'Data/DataFilters/Layer'
|
|
40
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Box, Data } from 'grommet';
|
|
2
|
+
import { Box, Data, Notification } from 'grommet';
|
|
3
3
|
import { DataFilters } from '../DataFilters';
|
|
4
4
|
import { DATA } from '../../DataTable/stories/data';
|
|
5
5
|
export var Simple = function Simple() {
|
|
@@ -8,11 +8,14 @@ export var Simple = function Simple() {
|
|
|
8
8
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
9
|
// <Grommet theme={...}>
|
|
10
10
|
React.createElement(Box, {
|
|
11
|
-
fill: true,
|
|
12
11
|
align: "center",
|
|
13
12
|
justify: "start",
|
|
14
|
-
pad: "large"
|
|
15
|
-
|
|
13
|
+
pad: "large",
|
|
14
|
+
gap: "medium"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
16
|
+
status: "info",
|
|
17
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Data, {
|
|
16
19
|
data: DATA
|
|
17
20
|
}, /*#__PURE__*/React.createElement(DataFilters, null)))
|
|
18
21
|
// </Grommet>
|
|
@@ -23,5 +26,5 @@ Simple.args = {
|
|
|
23
26
|
full: true
|
|
24
27
|
};
|
|
25
28
|
export default {
|
|
26
|
-
title: '
|
|
29
|
+
title: 'Data/DataFilters/Simple'
|
|
27
30
|
};
|
|
@@ -1,42 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["drop", "id", "responsive"];
|
|
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, useEffect, useState } from 'react';
|
|
4
5
|
import { Search } from 'grommet-icons/icons/Search';
|
|
6
|
+
import { Box } from '../Box';
|
|
5
7
|
import { DataContext } from '../../contexts/DataContext';
|
|
6
8
|
import { DataForm } from '../Data/DataForm';
|
|
9
|
+
import { DropButton } from '../DropButton';
|
|
7
10
|
import { FormContext } from '../Form/FormContext';
|
|
11
|
+
import { FormField } from '../FormField';
|
|
8
12
|
import { useSkeleton } from '../Skeleton';
|
|
9
13
|
import { TextInput } from '../TextInput';
|
|
10
14
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
15
|
+
import { ResponsiveContext } from '../../contexts/ResponsiveContext';
|
|
11
16
|
import { DataSearchPropTypes } from './propTypes';
|
|
17
|
+
var dropProps = {
|
|
18
|
+
align: {
|
|
19
|
+
top: 'bottom',
|
|
20
|
+
left: 'left'
|
|
21
|
+
}
|
|
22
|
+
};
|
|
12
23
|
export var DataSearch = function DataSearch(_ref) {
|
|
13
|
-
var
|
|
24
|
+
var drop = _ref.drop,
|
|
25
|
+
idProp = _ref.id,
|
|
26
|
+
responsive = _ref.responsive,
|
|
27
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
14
28
|
var _useContext = useContext(DataContext),
|
|
15
29
|
dataId = _useContext.id,
|
|
16
30
|
messages = _useContext.messages,
|
|
17
31
|
addToolbarKey = _useContext.addToolbarKey;
|
|
18
32
|
var _useContext2 = useContext(FormContext),
|
|
19
33
|
noForm = _useContext2.noForm;
|
|
20
|
-
var skeleton = useSkeleton();
|
|
21
34
|
var _useContext3 = useContext(MessageContext),
|
|
22
35
|
format = _useContext3.format;
|
|
36
|
+
var size = useContext(ResponsiveContext);
|
|
37
|
+
var skeleton = useSkeleton();
|
|
38
|
+
var _useState = useState(),
|
|
39
|
+
showContent = _useState[0],
|
|
40
|
+
setShowContent = _useState[1];
|
|
41
|
+
var id = idProp || dataId + "--search";
|
|
23
42
|
useEffect(function () {
|
|
24
43
|
if (noForm) addToolbarKey('_search');
|
|
25
44
|
}, [addToolbarKey, noForm]);
|
|
26
45
|
var content = skeleton ? null : /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
27
46
|
"aria-label": format({
|
|
28
47
|
id: 'dataSearch.label',
|
|
29
|
-
messages: messages == null ? void 0 : messages.
|
|
48
|
+
messages: messages == null ? void 0 : messages.dataSearch
|
|
30
49
|
}),
|
|
31
|
-
id:
|
|
50
|
+
id: id,
|
|
32
51
|
name: "_search",
|
|
33
52
|
icon: /*#__PURE__*/React.createElement(Search, null),
|
|
34
53
|
type: "search"
|
|
35
54
|
}, rest));
|
|
36
|
-
if (noForm)
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
if (noForm)
|
|
56
|
+
// likely in Toolbar
|
|
57
|
+
content = /*#__PURE__*/React.createElement(DataForm, {
|
|
58
|
+
footer: false,
|
|
59
|
+
updateOn: "change"
|
|
60
|
+
}, content);else content = /*#__PURE__*/React.createElement(FormField, {
|
|
61
|
+
htmlFor: id,
|
|
62
|
+
label: format({
|
|
63
|
+
id: 'dataSearch.label',
|
|
64
|
+
messages: messages == null ? void 0 : messages.dataSearch
|
|
65
|
+
})
|
|
39
66
|
}, content);
|
|
40
|
-
return content;
|
|
67
|
+
if (!drop && (!responsive || size !== 'small' && size !== 'xsmall')) return content;
|
|
68
|
+
var control = /*#__PURE__*/React.createElement(DropButton, _extends({
|
|
69
|
+
id: dataId + "--search-control",
|
|
70
|
+
"aria-label": format({
|
|
71
|
+
id: 'dataSearch.open',
|
|
72
|
+
messages: messages == null ? void 0 : messages.dataSort
|
|
73
|
+
}),
|
|
74
|
+
kind: "toolbar",
|
|
75
|
+
icon: /*#__PURE__*/React.createElement(Search, null),
|
|
76
|
+
dropProps: dropProps,
|
|
77
|
+
dropContent: /*#__PURE__*/React.createElement(Box, {
|
|
78
|
+
pad: "small"
|
|
79
|
+
}, content),
|
|
80
|
+
open: showContent,
|
|
81
|
+
onOpen: function onOpen() {
|
|
82
|
+
return setShowContent(undefined);
|
|
83
|
+
},
|
|
84
|
+
onClose: function onClose() {
|
|
85
|
+
return setShowContent(undefined);
|
|
86
|
+
}
|
|
87
|
+
}, rest));
|
|
88
|
+
return control;
|
|
41
89
|
};
|
|
42
90
|
DataSearch.propTypes = DataSearchPropTypes;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextInputProps } from '../TextInput/index';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export interface DataSearchProps {
|
|
5
|
+
drop?: boolean;
|
|
6
|
+
responsive?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface DataSearchExtendedProps
|
|
10
|
+
extends TextInputProps,
|
|
11
|
+
DataSearchProps {}
|
|
12
|
+
|
|
13
|
+
declare const DataSearch: React.FC<DataSearchExtendedProps>;
|
|
5
14
|
|
|
6
15
|
export { DataSearch };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Data, DataSummary, DataTable, Grid, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { DataSearch } from '../DataSearch';
|
|
4
|
+
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var Drop = function Drop() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Grid, {
|
|
11
|
+
pad: "large",
|
|
12
|
+
columns: ['large'],
|
|
13
|
+
justifyContent: "center"
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
15
|
+
status: "info",
|
|
16
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Paragraph, {
|
|
18
|
+
color: "text-weak"
|
|
19
|
+
}, "Note: Results are filtered as you type, checking all fields."), /*#__PURE__*/React.createElement(Data, {
|
|
20
|
+
data: DATA,
|
|
21
|
+
updateOn: "change"
|
|
22
|
+
}, /*#__PURE__*/React.createElement(DataSearch, {
|
|
23
|
+
drop: true
|
|
24
|
+
}), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(DataTable, {
|
|
25
|
+
columns: columns
|
|
26
|
+
})))
|
|
27
|
+
// </Grommet>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Drop.args = {
|
|
32
|
+
full: true
|
|
33
|
+
};
|
|
34
|
+
export default {
|
|
35
|
+
title: 'Data/DataSearch/Drop'
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Data, DataSummary, DataTable, Grid, Notification, Paragraph } from 'grommet';
|
|
3
|
+
import { DataSearch } from '../DataSearch';
|
|
4
|
+
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var Responsive = function Responsive() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Grid, {
|
|
11
|
+
pad: "large",
|
|
12
|
+
columns: [['medium', 'large']],
|
|
13
|
+
justifyContent: "center"
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
15
|
+
status: "info",
|
|
16
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Paragraph, {
|
|
18
|
+
color: "text-weak"
|
|
19
|
+
}, "Note: Results are filtered as you type, checking all fields."), /*#__PURE__*/React.createElement(Data, {
|
|
20
|
+
data: DATA,
|
|
21
|
+
updateOn: "change"
|
|
22
|
+
}, /*#__PURE__*/React.createElement(DataSearch, {
|
|
23
|
+
responsive: true
|
|
24
|
+
}), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(DataTable, {
|
|
25
|
+
columns: columns
|
|
26
|
+
})))
|
|
27
|
+
// </Grommet>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Responsive.args = {
|
|
32
|
+
full: true
|
|
33
|
+
};
|
|
34
|
+
export default {
|
|
35
|
+
title: 'Data/DataSearch/Responsive'
|
|
36
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Data, DataSummary, DataTable, Grid, Paragraph } from 'grommet';
|
|
2
|
+
import { Data, DataSummary, DataTable, Grid, Notification, Paragraph } from 'grommet';
|
|
3
3
|
import { DataSearch } from '../DataSearch';
|
|
4
4
|
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
5
|
export var Simple = function Simple() {
|
|
@@ -11,7 +11,10 @@ export var Simple = function Simple() {
|
|
|
11
11
|
pad: "large",
|
|
12
12
|
columns: ['large'],
|
|
13
13
|
justifyContent: "center"
|
|
14
|
-
}, /*#__PURE__*/React.createElement(
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Notification, {
|
|
15
|
+
status: "info",
|
|
16
|
+
message: "Data is in 'beta'. The API surface is subject to change."
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Paragraph, {
|
|
15
18
|
color: "text-weak"
|
|
16
19
|
}, "Note: Results are filtered as you type, checking all fields."), /*#__PURE__*/React.createElement(Data, {
|
|
17
20
|
data: DATA,
|
|
@@ -27,5 +30,5 @@ Simple.args = {
|
|
|
27
30
|
full: true
|
|
28
31
|
};
|
|
29
32
|
export default {
|
|
30
|
-
title: '
|
|
33
|
+
title: 'Data/DataSearch/Simple'
|
|
31
34
|
};
|