grommet 2.35.0 → 2.36.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 +1 -4
- package/components/Anchor/StyledAnchor.js +1 -1
- package/components/Box/Box.js +2 -2
- package/components/Box/StyledBox.js +18 -1
- package/components/Box/index.d.ts +1 -1
- package/components/Box/propTypes.js +4 -1
- package/components/Cards/stories/Simple.js +1 -4
- package/components/Data/stories/Cards.js +9 -19
- package/components/Data/stories/Complex.js +1 -4
- package/components/Data/stories/ComposedToolbar.js +74 -0
- package/components/Data/stories/Infinite.js +29 -64
- package/components/Data/stories/Inline.js +1 -9
- package/components/Data/stories/List.js +3 -9
- package/components/Data/stories/Properties.js +17 -22
- package/components/Data/stories/Simple.js +4 -10
- package/components/Data/stories/SpaceX.js +8 -7
- package/components/Data/stories/StarWars.js +6 -12
- package/components/Data/stories/Views.js +4 -11
- package/components/DataFilter/DataFilter.js +1 -0
- package/components/DataFilter/stories/Simple.js +2 -6
- package/components/DataFilters/stories/Drop.js +2 -6
- package/components/DataFilters/stories/Layer.js +2 -6
- package/components/DataFilters/stories/Simple.js +2 -6
- package/components/DataSearch/stories/Drop.js +6 -11
- package/components/DataSearch/stories/Responsive.js +6 -12
- package/components/DataSearch/stories/Simple.js +5 -10
- package/components/DataSearch/stories/UpdateOnSubmit.js +5 -7
- package/components/DataSort/stories/Drop.js +2 -6
- package/components/DataSort/stories/Simple.js +2 -6
- package/components/DataSummary/stories/Simple.js +2 -6
- package/components/DataTableColumns/stories/Simple.js +2 -6
- package/components/DataTableGroupBy/stories/Simple.js +5 -7
- package/components/DataView/stories/Simple.js +4 -6
- package/components/DateInput/DateInput.js +61 -17
- package/components/DateInput/index.d.ts +1 -0
- package/components/DateInput/propTypes.js +1 -0
- package/components/DateInput/stories/ReadOnly.js +36 -0
- package/components/DateInput/utils.js +2 -2
- package/components/Form/Form.js +34 -1
- package/components/FormField/FormField.js +20 -1
- package/components/FormField/README.md +1 -644
- package/components/FormField/index.d.ts +5 -1
- package/components/FormField/propTypes.js +4 -1
- package/components/FormField/stories/ThresholdValidation.js +51 -0
- package/components/Grommet/Grommet.js +1 -1
- package/components/Grommet/index.d.ts +12 -0
- package/components/Grommet/propTypes.js +12 -0
- package/components/Layer/LayerContainer.js +1 -1
- package/components/List/List.js +33 -30
- package/components/Pagination/Pagination.js +52 -9
- package/components/Pagination/PaginationStep.js +41 -0
- package/components/Pagination/PaginationSummary.js +33 -0
- package/components/Pagination/index.d.ts +2 -0
- package/components/Pagination/propTypes.js +3 -1
- package/components/Pagination/stories/Steps.js +40 -0
- package/components/RangeInput/RangeInput.js +19 -12
- package/components/TextInput/CopyButton.js +53 -0
- package/components/TextInput/StyledTextInput.js +13 -2
- package/components/TextInput/TextInput.js +46 -12
- package/components/TextInput/index.d.ts +1 -0
- package/components/TextInput/propTypes.js +1 -0
- package/components/TextInput/stories/ReadOnly.js +43 -0
- package/components/Toolbar/stories/Simple.js +1 -4
- package/es6/components/Anchor/Anchor.js +1 -4
- package/es6/components/Anchor/StyledAnchor.js +1 -1
- package/es6/components/Box/Box.js +2 -2
- package/es6/components/Box/StyledBox.js +18 -1
- package/es6/components/Box/index.d.ts +1 -1
- package/es6/components/Box/propTypes.js +4 -1
- package/es6/components/Cards/stories/Simple.js +2 -5
- package/es6/components/Data/stories/Cards.js +10 -20
- package/es6/components/Data/stories/Complex.js +2 -5
- package/es6/components/Data/stories/ComposedToolbar.js +69 -0
- package/es6/components/Data/stories/Infinite.js +32 -66
- package/es6/components/Data/stories/Inline.js +2 -10
- package/es6/components/Data/stories/List.js +4 -10
- package/es6/components/Data/stories/Properties.js +18 -23
- package/es6/components/Data/stories/Simple.js +5 -11
- package/es6/components/Data/stories/SpaceX.js +9 -8
- package/es6/components/Data/stories/StarWars.js +7 -13
- package/es6/components/Data/stories/Views.js +5 -12
- package/es6/components/DataFilter/DataFilter.js +1 -0
- package/es6/components/DataFilter/stories/Simple.js +2 -6
- package/es6/components/DataFilters/stories/Drop.js +2 -6
- package/es6/components/DataFilters/stories/Layer.js +2 -6
- package/es6/components/DataFilters/stories/Simple.js +2 -6
- package/es6/components/DataSearch/stories/Drop.js +7 -12
- package/es6/components/DataSearch/stories/Responsive.js +7 -13
- package/es6/components/DataSearch/stories/Simple.js +6 -11
- package/es6/components/DataSearch/stories/UpdateOnSubmit.js +6 -8
- package/es6/components/DataSort/stories/Drop.js +2 -6
- package/es6/components/DataSort/stories/Simple.js +2 -6
- package/es6/components/DataSummary/stories/Simple.js +2 -6
- package/es6/components/DataTableColumns/stories/Simple.js +2 -6
- package/es6/components/DataTableGroupBy/stories/Simple.js +5 -7
- package/es6/components/DataView/stories/Simple.js +6 -8
- package/es6/components/DateInput/DateInput.js +61 -17
- package/es6/components/DateInput/index.d.ts +1 -0
- package/es6/components/DateInput/propTypes.js +1 -0
- package/es6/components/DateInput/stories/ReadOnly.js +31 -0
- package/es6/components/DateInput/utils.js +2 -2
- package/es6/components/Form/Form.js +34 -1
- package/es6/components/FormField/FormField.js +21 -2
- package/es6/components/FormField/README.md +1 -644
- package/es6/components/FormField/index.d.ts +5 -1
- package/es6/components/FormField/propTypes.js +4 -1
- package/es6/components/FormField/stories/ThresholdValidation.js +46 -0
- package/es6/components/Grommet/Grommet.js +1 -1
- package/es6/components/Grommet/index.d.ts +12 -0
- package/es6/components/Grommet/propTypes.js +12 -0
- package/es6/components/Layer/LayerContainer.js +1 -1
- package/es6/components/List/List.js +33 -30
- package/es6/components/Pagination/Pagination.js +52 -9
- package/es6/components/Pagination/PaginationStep.js +35 -0
- package/es6/components/Pagination/PaginationSummary.js +27 -0
- package/es6/components/Pagination/index.d.ts +2 -0
- package/es6/components/Pagination/propTypes.js +3 -1
- package/es6/components/Pagination/stories/Steps.js +35 -0
- package/es6/components/RangeInput/RangeInput.js +19 -12
- package/es6/components/TextInput/CopyButton.js +48 -0
- package/es6/components/TextInput/StyledTextInput.js +14 -3
- package/es6/components/TextInput/TextInput.js +46 -12
- package/es6/components/TextInput/index.d.ts +1 -0
- package/es6/components/TextInput/propTypes.js +1 -0
- package/es6/components/TextInput/stories/ReadOnly.js +38 -0
- package/es6/components/Toolbar/stories/Simple.js +2 -5
- package/es6/languages/default.json +23 -0
- package/es6/themes/base.d.ts +8 -0
- package/es6/themes/base.js +12 -1
- package/es6/utils/index.js +1 -0
- package/es6/utils/readOnly.js +10 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +23 -0
- package/package.json +31 -32
- package/themes/base.d.ts +8 -0
- package/themes/base.js +12 -1
- package/utils/index.js +6 -0
- package/utils/readOnly.js +14 -0
- package/components/Data/stories/Controlled.js +0 -92
- package/components/Data/stories/DataTable.js +0 -49
- package/components/DataFilters/stories/Inline.js +0 -53
- package/es6/components/Data/stories/Controlled.js +0 -86
- package/es6/components/Data/stories/DataTable.js +0 -44
- package/es6/components/DataFilters/stories/Inline.js +0 -48
|
@@ -16,7 +16,8 @@ var _utils = require("../../utils");
|
|
|
16
16
|
var _StyledTextInput = require("./StyledTextInput");
|
|
17
17
|
var _MessageContext = require("../../contexts/MessageContext");
|
|
18
18
|
var _propTypes = require("./propTypes");
|
|
19
|
-
var
|
|
19
|
+
var _CopyButton = require("./CopyButton");
|
|
20
|
+
var _excluded = ["a11yTitle", "defaultSuggestion", "defaultValue", "dropAlign", "dropHeight", "dropTarget", "dropProps", "focusIndicator", "icon", "id", "messages", "name", "onBlur", "onChange", "onFocus", "onKeyDown", "onSelect", "onSuggestionSelect", "onSuggestionsClose", "onSuggestionsOpen", "placeholder", "plain", "readOnly", "readOnlyCopy", "reverse", "suggestions", "textAlign", "value", "width"];
|
|
20
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
22
23
|
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); }
|
|
@@ -72,7 +73,8 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
72
73
|
onSuggestionsOpen = _ref.onSuggestionsOpen,
|
|
73
74
|
placeholder = _ref.placeholder,
|
|
74
75
|
plain = _ref.plain,
|
|
75
|
-
|
|
76
|
+
readOnlyProp = _ref.readOnly,
|
|
77
|
+
readOnlyCopy = _ref.readOnlyCopy,
|
|
76
78
|
reverse = _ref.reverse,
|
|
77
79
|
suggestions = _ref.suggestions,
|
|
78
80
|
textAlign = _ref.textAlign,
|
|
@@ -87,6 +89,7 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
87
89
|
var inputRef = (0, _utils.useForwardedRef)(ref);
|
|
88
90
|
var dropRef = (0, _react.useRef)();
|
|
89
91
|
var suggestionsRef = (0, _react.useRef)();
|
|
92
|
+
var readOnly = readOnlyProp || readOnlyCopy;
|
|
90
93
|
// if this is a readOnly property, don't set a name with the form context
|
|
91
94
|
// this allows Select to control the form context for the name.
|
|
92
95
|
var _formContext$useFormI = formContext.useFormInput({
|
|
@@ -110,6 +113,25 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
110
113
|
var _useState3 = (0, _react.useState)(),
|
|
111
114
|
suggestionsAtClose = _useState3[0],
|
|
112
115
|
setSuggestionsAtClose = _useState3[1];
|
|
116
|
+
var readOnlyCopyValidation = format({
|
|
117
|
+
id: 'input.readOnlyCopy.validation',
|
|
118
|
+
messages: messages
|
|
119
|
+
});
|
|
120
|
+
var readOnlyCopyPrompt = format({
|
|
121
|
+
id: 'input.readOnlyCopy.prompt',
|
|
122
|
+
messages: messages
|
|
123
|
+
});
|
|
124
|
+
var _useState4 = (0, _react.useState)(readOnlyCopyPrompt),
|
|
125
|
+
tip = _useState4[0],
|
|
126
|
+
setTip = _useState4[1];
|
|
127
|
+
var onClickCopy = function onClickCopy() {
|
|
128
|
+
global.navigator.clipboard.writeText(value);
|
|
129
|
+
announce(readOnlyCopyValidation, 'assertive');
|
|
130
|
+
setTip(readOnlyCopyValidation);
|
|
131
|
+
};
|
|
132
|
+
var onBlurCopy = function onBlurCopy() {
|
|
133
|
+
if (tip === readOnlyCopyValidation) setTip(readOnlyCopyPrompt);
|
|
134
|
+
};
|
|
113
135
|
var openDrop = (0, _react.useCallback)(function () {
|
|
114
136
|
setShowDrop(true);
|
|
115
137
|
announce(format({
|
|
@@ -166,15 +188,15 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
166
188
|
|
|
167
189
|
// activeSuggestionIndex unifies mouse and keyboard interaction of
|
|
168
190
|
// the suggestions
|
|
169
|
-
var
|
|
170
|
-
activeSuggestionIndex =
|
|
171
|
-
setActiveSuggestionIndex =
|
|
191
|
+
var _useState5 = (0, _react.useState)(resetSuggestionIndex),
|
|
192
|
+
activeSuggestionIndex = _useState5[0],
|
|
193
|
+
setActiveSuggestionIndex = _useState5[1];
|
|
172
194
|
|
|
173
195
|
// Only update active suggestion index when the mouse actually moves,
|
|
174
196
|
// not when suggestions are moving under the mouse.
|
|
175
|
-
var
|
|
176
|
-
mouseMovedSinceLastKey =
|
|
177
|
-
setMouseMovedSinceLastKey =
|
|
197
|
+
var _useState6 = (0, _react.useState)(),
|
|
198
|
+
mouseMovedSinceLastKey = _useState6[0],
|
|
199
|
+
setMouseMovedSinceLastKey = _useState6[1];
|
|
178
200
|
|
|
179
201
|
// set activeSuggestionIndex when value changes
|
|
180
202
|
(0, _react.useEffect)(function () {
|
|
@@ -352,9 +374,20 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
352
374
|
// primarily for tests.
|
|
353
375
|
|
|
354
376
|
var textInputIcon = (0, _utils.useSizedIcon)(icon, rest.size, theme);
|
|
377
|
+
var ReadOnlyCopyButton = /*#__PURE__*/_react["default"].createElement(_CopyButton.CopyButton, {
|
|
378
|
+
onBlurCopy: onBlurCopy,
|
|
379
|
+
onClickCopy: onClickCopy,
|
|
380
|
+
readOnlyCopyPrompt: readOnlyCopyPrompt,
|
|
381
|
+
tip: tip,
|
|
382
|
+
value: value
|
|
383
|
+
});
|
|
355
384
|
return /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledTextInputContainer, {
|
|
356
|
-
|
|
357
|
-
|
|
385
|
+
readOnlyProp: readOnly // readOnlyProp to avoid passing to DOM
|
|
386
|
+
,
|
|
387
|
+
readOnlyCopy: readOnlyCopy,
|
|
388
|
+
plain: plain,
|
|
389
|
+
border: !plain
|
|
390
|
+
}, reverse && readOnlyCopy && ReadOnlyCopyButton, showStyledPlaceholder && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledPlaceholder, null, placeholder), textInputIcon && !readOnly && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledIcon, {
|
|
358
391
|
reverse: reverse,
|
|
359
392
|
theme: theme
|
|
360
393
|
}, textInputIcon), /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, _extends({
|
|
@@ -367,7 +400,7 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
367
400
|
autoComplete: "off",
|
|
368
401
|
plain: plain,
|
|
369
402
|
placeholder: typeof placeholder === 'string' ? placeholder : undefined,
|
|
370
|
-
icon: icon,
|
|
403
|
+
icon: !readOnly && icon,
|
|
371
404
|
reverse: reverse,
|
|
372
405
|
focus: focus,
|
|
373
406
|
focusIndicator: focusIndicator,
|
|
@@ -377,6 +410,7 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
377
410
|
defaultValue: renderLabel(defaultValue),
|
|
378
411
|
value: renderLabel(value),
|
|
379
412
|
readOnly: readOnly,
|
|
413
|
+
readOnlyCopy: readOnlyCopy,
|
|
380
414
|
onFocus: function onFocus(event) {
|
|
381
415
|
// Don't do anything if we are acting like we already have
|
|
382
416
|
// focus. This can happen when this input loses focus temporarily
|
|
@@ -415,7 +449,7 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
415
449
|
setActiveSuggestionIndex(resetSuggestionIndex);
|
|
416
450
|
if (onChange) onChange(event);
|
|
417
451
|
}
|
|
418
|
-
}))), drop);
|
|
452
|
+
}))), !reverse && readOnlyCopy && ReadOnlyCopyButton, !readOnly && drop);
|
|
419
453
|
});
|
|
420
454
|
TextInput.displayName = 'TextInput';
|
|
421
455
|
TextInput.propTypes = _propTypes.TextInputPropTypes;
|
|
@@ -46,6 +46,7 @@ export interface TextInputProps
|
|
|
46
46
|
onSuggestionsClose?: () => void;
|
|
47
47
|
placeholder?: PlaceHolderType;
|
|
48
48
|
plain?: boolean | 'full';
|
|
49
|
+
readOnlyCopy?: boolean;
|
|
49
50
|
reverse?: boolean;
|
|
50
51
|
size?: 'small' | 'medium' | 'large' | 'xlarge' | string;
|
|
51
52
|
suggestions?: ({ label?: React.ReactNode; value?: any } | string)[];
|
|
@@ -36,6 +36,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
36
36
|
onSuggestionsClose: _propTypes["default"].func,
|
|
37
37
|
placeholder: _propTypes["default"].node,
|
|
38
38
|
plain: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].oneOf(['full'])]),
|
|
39
|
+
readOnlyCopy: _propTypes["default"].bool,
|
|
39
40
|
reverse: _propTypes["default"].bool,
|
|
40
41
|
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge', '2xl', '3xl', '4xl', '5xl', '6xl']), _propTypes["default"].string]),
|
|
41
42
|
suggestions: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.ReadOnly = void 0;
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _grommet = require("grommet");
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
+
var ReadOnly = exports.ReadOnly = function ReadOnly() {
|
|
9
|
+
return (
|
|
10
|
+
/*#__PURE__*/
|
|
11
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
12
|
+
// <Grommet theme={...}>
|
|
13
|
+
_react["default"].createElement(_grommet.Box, {
|
|
14
|
+
fill: true,
|
|
15
|
+
align: "center",
|
|
16
|
+
justify: "start",
|
|
17
|
+
pad: "large"
|
|
18
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
19
|
+
width: "medium",
|
|
20
|
+
gap: "medium"
|
|
21
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Form, null, /*#__PURE__*/_react["default"].createElement(_grommet.FormField, null, /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
|
|
22
|
+
readOnlyCopy: true,
|
|
23
|
+
value: "Read only with copy button",
|
|
24
|
+
"aria-label": "read only"
|
|
25
|
+
})), /*#__PURE__*/_react["default"].createElement(_grommet.FormField, null, /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
|
|
26
|
+
readOnly: true,
|
|
27
|
+
value: "Read only",
|
|
28
|
+
"aria-label": "read only"
|
|
29
|
+
}))), /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
|
|
30
|
+
readOnlyCopy: true,
|
|
31
|
+
value: "Read only with copy button",
|
|
32
|
+
"aria-label": "read only"
|
|
33
|
+
}), /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
|
|
34
|
+
readOnly: true,
|
|
35
|
+
value: "Read only",
|
|
36
|
+
"aria-label": "read only"
|
|
37
|
+
})))
|
|
38
|
+
// </Grommet>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
var _default = exports["default"] = {
|
|
42
|
+
title: 'Input/TextInput/ReadOnly'
|
|
43
|
+
};
|
|
@@ -18,10 +18,7 @@ var Simple = exports.Simple = function Simple() {
|
|
|
18
18
|
justify: "start",
|
|
19
19
|
pad: "large",
|
|
20
20
|
gap: "large"
|
|
21
|
-
}, /*#__PURE__*/_react["default"].createElement(_grommet.
|
|
22
|
-
status: "info",
|
|
23
|
-
message: "Toolbar is in 'beta'. The API surface is subject to change."
|
|
24
|
-
}), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
21
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
25
22
|
width: "large"
|
|
26
23
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Data, {
|
|
27
24
|
data: _data.DATA
|
|
@@ -83,10 +83,7 @@ var Anchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
83
83
|
direction: "row",
|
|
84
84
|
align: "center",
|
|
85
85
|
gap: gap || theme.anchor.gap,
|
|
86
|
-
responsive: false
|
|
87
|
-
style: {
|
|
88
|
-
display: 'inline-flex'
|
|
89
|
-
}
|
|
86
|
+
responsive: false
|
|
90
87
|
}, first, second) : first || second || children);
|
|
91
88
|
});
|
|
92
89
|
Anchor.displayName = 'Anchor';
|
|
@@ -19,7 +19,7 @@ var StyledAnchor = styled.a.withConfig({
|
|
|
19
19
|
}).withConfig({
|
|
20
20
|
displayName: "StyledAnchor",
|
|
21
21
|
componentId: "sc-1rp7lwl-0"
|
|
22
|
-
})(["box-sizing:border-box;", " color:", ";", " text-decoration:", ";cursor:pointer;", " ", " ", " ", " ", " ", ""], function (props) {
|
|
22
|
+
})(["box-sizing:border-box;display:inline-flex;", " color:", ";", " text-decoration:", ";cursor:pointer;", " ", " ", " ", " ", " ", ""], function (props) {
|
|
23
23
|
return sizeStyle(props);
|
|
24
24
|
}, function (props) {
|
|
25
25
|
var _props$theme$anchor;
|
|
@@ -91,7 +91,7 @@ var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
91
91
|
console.warn('Box must have a gap to use border between');
|
|
92
92
|
}
|
|
93
93
|
var contents = children;
|
|
94
|
-
if (gap && gap !== 'none' && (!(boxOptions != null && boxOptions.cssGap || cssGap) ||
|
|
94
|
+
if (gap && gap !== 'none' && (!(boxOptions != null && boxOptions.cssGap || cssGap || typeof gap === 'object') ||
|
|
95
95
|
// need this approach to show border between
|
|
96
96
|
border === 'between' || (border == null ? void 0 : border.side) === 'between' || Array.isArray(border) && border.find(function (b) {
|
|
97
97
|
return b.side === 'between';
|
|
@@ -185,7 +185,7 @@ var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
185
185
|
elevationProp: elevation,
|
|
186
186
|
fillProp: fill,
|
|
187
187
|
focus: focus,
|
|
188
|
-
gap: ((boxOptions == null ? void 0 : boxOptions.cssGap) || cssGap) && gap && gap !== 'none' && border !== 'between' && (border == null ? void 0 : border.side) !== 'between' && (!Array.isArray(border) || !border.find(function (b) {
|
|
188
|
+
gap: ((boxOptions == null ? void 0 : boxOptions.cssGap) || cssGap || typeof gap === 'object') && gap && gap !== 'none' && border !== 'between' && (border == null ? void 0 : border.side) !== 'between' && (!Array.isArray(border) || !border.find(function (b) {
|
|
189
189
|
return b.side === 'between';
|
|
190
190
|
})) && gap,
|
|
191
191
|
kindProp: kind,
|
|
@@ -127,7 +127,24 @@ var gapStyle = function gapStyle(directionProp, gap, responsive, wrap, theme) {
|
|
|
127
127
|
var breakpoint = getBreakpointStyle(theme, theme.box.responsiveBreakpoint);
|
|
128
128
|
var responsiveMetric = responsive && breakpoint && breakpoint.edgeSize[gap];
|
|
129
129
|
var styles = [];
|
|
130
|
-
if (
|
|
130
|
+
if (typeof gap === 'object') {
|
|
131
|
+
if (gap.row !== undefined && gap.column !== undefined) {
|
|
132
|
+
styles.push("gap: " + (theme.global.edgeSize[gap.row] || gap.row) + " " + (theme.global.edgeSize[gap.column] || gap.column) + ";");
|
|
133
|
+
if (responsiveMetric) {
|
|
134
|
+
styles.push(breakpointStyle(breakpoint, "gap: " + responsiveMetric + ";"));
|
|
135
|
+
}
|
|
136
|
+
} else if (gap.row !== undefined) {
|
|
137
|
+
styles.push("row-gap: " + (theme.global.edgeSize[gap.row] || gap.row) + ";");
|
|
138
|
+
if (responsiveMetric) {
|
|
139
|
+
styles.push(breakpointStyle(breakpoint, "row-gap: " + responsiveMetric + ";"));
|
|
140
|
+
}
|
|
141
|
+
} else if (gap.column !== undefined) {
|
|
142
|
+
styles.push("column-gap: " + (theme.global.edgeSize[gap.column] || gap.column) + ";");
|
|
143
|
+
if (responsiveMetric) {
|
|
144
|
+
styles.push(breakpointStyle(breakpoint, "column-gap: " + responsiveMetric + ";"));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} else if (directionProp === 'column' || directionProp === 'column-reverse') {
|
|
131
148
|
styles.push("row-gap: " + metric + ";");
|
|
132
149
|
if (responsiveMetric) {
|
|
133
150
|
styles.push(breakpointStyle(breakpoint, "row-gap: " + responsiveMetric + ";"));
|
|
@@ -38,7 +38,7 @@ export interface BoxProps {
|
|
|
38
38
|
flex?: 'grow' | 'shrink' | boolean | { grow?: number; shrink?: number };
|
|
39
39
|
fill?: FillType;
|
|
40
40
|
focusIndicator?: boolean;
|
|
41
|
-
gap?: GapType;
|
|
41
|
+
gap?: GapType | { row?: GapType; column?: GapType };
|
|
42
42
|
height?: HeightType;
|
|
43
43
|
hoverIndicator?:
|
|
44
44
|
| { background?: BackgroundType; elevation?: ElevationType }
|
|
@@ -34,7 +34,10 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
34
34
|
})]),
|
|
35
35
|
fill: PropTypes.oneOfType([PropTypes.oneOf(['horizontal', 'vertical']), PropTypes.bool]),
|
|
36
36
|
focusIndicator: PropTypes.bool,
|
|
37
|
-
gap: PropTypes.oneOfType([PropTypes.oneOf(['none', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge']), PropTypes.string
|
|
37
|
+
gap: PropTypes.oneOfType([PropTypes.oneOf(['none', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge']), PropTypes.string, PropTypes.shape({
|
|
38
|
+
row: PropTypes.string,
|
|
39
|
+
column: PropTypes.string
|
|
40
|
+
})]),
|
|
38
41
|
height: heightPropType,
|
|
39
42
|
hoverIndicator: hoverIndicatorPropType,
|
|
40
43
|
justify: PropTypes.oneOf(['around', 'between', 'center', 'end', 'evenly', 'start', 'stretch']),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Grid
|
|
2
|
+
import { Grid } from 'grommet';
|
|
3
3
|
import { Cards } from '../Cards';
|
|
4
4
|
var locations = ['Boise', 'Fort Collins', 'Los Gatos', 'Palo Alto', 'San Francisco'];
|
|
5
5
|
export var Simple = function Simple() {
|
|
@@ -8,10 +8,7 @@ export var Simple = function Simple() {
|
|
|
8
8
|
columns: [['medium', 'large']],
|
|
9
9
|
justifyContent: "center",
|
|
10
10
|
gap: "large"
|
|
11
|
-
}, /*#__PURE__*/React.createElement(
|
|
12
|
-
status: "info",
|
|
13
|
-
message: "Cards is in 'beta'. The API surface is subject to change."
|
|
14
|
-
}), /*#__PURE__*/React.createElement(Cards, {
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Cards, {
|
|
15
12
|
a11yTitle: "Locations",
|
|
16
13
|
data: locations
|
|
17
14
|
}));
|
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Card, CardBody, CardFooter, Cards,
|
|
3
|
-
import { Data } from '../Data';
|
|
2
|
+
import { Box, Card, CardBody, CardFooter, Cards, Data, Heading } from 'grommet';
|
|
4
3
|
import { DATA } from '../../DataTable/stories/data';
|
|
5
4
|
export var Example = function Example() {
|
|
6
5
|
return (
|
|
7
6
|
/*#__PURE__*/
|
|
8
7
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
8
|
// <Grommet theme={...}>
|
|
10
|
-
React.createElement(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
message: "Data is in 'beta'. The API surface is subject to change."
|
|
19
|
-
}), /*#__PURE__*/React.createElement(Data, {
|
|
20
|
-
data: DATA
|
|
21
|
-
}, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataSearch, null), /*#__PURE__*/React.createElement(DataFilters, {
|
|
22
|
-
drop: true
|
|
23
|
-
}, /*#__PURE__*/React.createElement(DataFilter, {
|
|
24
|
-
property: "location"
|
|
25
|
-
}))), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(Cards, null, function (item) {
|
|
9
|
+
React.createElement(Box, {
|
|
10
|
+
pad: "large"
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Data, {
|
|
12
|
+
data: DATA,
|
|
13
|
+
toolbar: true
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Cards, {
|
|
15
|
+
size: "medium"
|
|
16
|
+
}, function (item) {
|
|
26
17
|
return /*#__PURE__*/React.createElement(Card, {
|
|
27
18
|
key: item.name,
|
|
28
19
|
pad: "small"
|
|
29
20
|
}, /*#__PURE__*/React.createElement(CardBody, null, /*#__PURE__*/React.createElement(Heading, {
|
|
30
21
|
level: 2,
|
|
31
|
-
size: "small",
|
|
32
22
|
margin: "none"
|
|
33
|
-
}, item.name)), /*#__PURE__*/React.createElement(CardFooter, null, item.location));
|
|
23
|
+
}, item.name)), /*#__PURE__*/React.createElement(CardFooter, null, item.location || '--'));
|
|
34
24
|
})))
|
|
35
25
|
// </Grommet>
|
|
36
26
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Grid, DataTable, DataFilters, DataSearch, DataSummary,
|
|
2
|
+
import { Grid, DataTable, DataFilters, DataSearch, DataSummary, Text, Toolbar } from 'grommet';
|
|
3
3
|
import { Data } from '../Data';
|
|
4
4
|
var data = [{
|
|
5
5
|
id: 1,
|
|
@@ -109,10 +109,7 @@ export var Complex = function Complex() {
|
|
|
109
109
|
columns: [['small', 'large']],
|
|
110
110
|
justifyContent: "center",
|
|
111
111
|
gap: "large"
|
|
112
|
-
}, /*#__PURE__*/React.createElement(
|
|
113
|
-
status: "info",
|
|
114
|
-
message: "Data is in 'beta'. The API surface is subject to change."
|
|
115
|
-
}), /*#__PURE__*/React.createElement(Data, {
|
|
112
|
+
}, /*#__PURE__*/React.createElement(Data, {
|
|
116
113
|
data: data,
|
|
117
114
|
properties: properties
|
|
118
115
|
}, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataSearch, null), /*#__PURE__*/React.createElement(DataFilters, {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, DataFilters, DataFilter, DataSearch, DataSort, DataSummary, DataTable, DataTableColumns, DataView, Toolbar } from 'grommet';
|
|
3
|
+
import { Data } from '../Data';
|
|
4
|
+
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var ComposedToolbar = function ComposedToolbar() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Box, {
|
|
11
|
+
pad: "large"
|
|
12
|
+
}, /*#__PURE__*/React.createElement(Data, {
|
|
13
|
+
data: DATA,
|
|
14
|
+
properties: {
|
|
15
|
+
date: {
|
|
16
|
+
filter: false
|
|
17
|
+
},
|
|
18
|
+
location: {
|
|
19
|
+
label: 'Location'
|
|
20
|
+
},
|
|
21
|
+
name: {
|
|
22
|
+
filter: false
|
|
23
|
+
},
|
|
24
|
+
percent: {
|
|
25
|
+
filter: false
|
|
26
|
+
},
|
|
27
|
+
paid: {
|
|
28
|
+
filter: false
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
views: [{
|
|
32
|
+
name: 'My location',
|
|
33
|
+
properties: {
|
|
34
|
+
location: ['San Francisco']
|
|
35
|
+
}
|
|
36
|
+
}]
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
38
|
+
gap: "medium"
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataSearch, null), /*#__PURE__*/React.createElement(DataSort, {
|
|
40
|
+
drop: true
|
|
41
|
+
}), /*#__PURE__*/React.createElement(DataFilters, {
|
|
42
|
+
drop: true
|
|
43
|
+
}, /*#__PURE__*/React.createElement(DataFilter, {
|
|
44
|
+
property: "location"
|
|
45
|
+
}))), /*#__PURE__*/React.createElement(DataView, null), /*#__PURE__*/React.createElement(DataTableColumns, {
|
|
46
|
+
options: columns.map(function (column) {
|
|
47
|
+
return {
|
|
48
|
+
property: column.property,
|
|
49
|
+
label: column.header
|
|
50
|
+
};
|
|
51
|
+
}),
|
|
52
|
+
drop: true
|
|
53
|
+
})), /*#__PURE__*/React.createElement(DataSummary, null), /*#__PURE__*/React.createElement(Box, {
|
|
54
|
+
overflow: "auto"
|
|
55
|
+
}, /*#__PURE__*/React.createElement(DataTable, {
|
|
56
|
+
alignSelf: "start",
|
|
57
|
+
columns: columns,
|
|
58
|
+
sortable: true
|
|
59
|
+
}))))
|
|
60
|
+
// </Grommet>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
ComposedToolbar.storyName = 'Composed Toolbar';
|
|
64
|
+
ComposedToolbar.args = {
|
|
65
|
+
full: true
|
|
66
|
+
};
|
|
67
|
+
export default {
|
|
68
|
+
title: 'Data/Data/Composed Toolbar'
|
|
69
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
2
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
3
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
4
|
import React, { useEffect, useState } from 'react';
|
|
6
|
-
import { Box, DataTable, Data,
|
|
7
|
-
import {
|
|
5
|
+
import { Box, DataTable, Data, Text } from 'grommet';
|
|
6
|
+
import { StatusCriticalSmall } from "grommet-icons/es6/icons/StatusCriticalSmall";
|
|
7
|
+
import { StatusGoodSmall } from "grommet-icons/es6/icons/StatusGoodSmall";
|
|
8
8
|
var buildQuery = function buildQuery(view) {
|
|
9
9
|
var query = {};
|
|
10
10
|
var properties = (view == null ? void 0 : view.properties) || [];
|
|
@@ -111,41 +111,20 @@ var columns = [{
|
|
|
111
111
|
primary: true
|
|
112
112
|
}, {
|
|
113
113
|
property: 'rocket.name',
|
|
114
|
-
header: 'Rocket'
|
|
115
|
-
size: 'xsmall',
|
|
116
|
-
sortable: false
|
|
114
|
+
header: 'Rocket'
|
|
117
115
|
}, {
|
|
118
116
|
property: 'success',
|
|
119
117
|
header: 'Success',
|
|
120
|
-
size: 'xsmall',
|
|
121
|
-
align: 'center',
|
|
122
|
-
sortable: false,
|
|
123
118
|
render: function render(datum) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
key: reason
|
|
134
|
-
}, reason);
|
|
135
|
-
}));
|
|
136
|
-
return /*#__PURE__*/React.createElement(Tip, {
|
|
137
|
-
plain: true,
|
|
138
|
-
content: content,
|
|
139
|
-
dropProps: {
|
|
140
|
-
round: 'medium',
|
|
141
|
-
pad: 'small',
|
|
142
|
-
background: 'background-back'
|
|
143
|
-
}
|
|
144
|
-
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(StatusCritical, {
|
|
145
|
-
color: "red"
|
|
146
|
-
})));
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
119
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
120
|
+
align: "center",
|
|
121
|
+
direction: "row",
|
|
122
|
+
gap: "xsmall"
|
|
123
|
+
}, datum.success ? /*#__PURE__*/React.createElement(StatusGoodSmall, {
|
|
124
|
+
color: "status-ok"
|
|
125
|
+
}) : /*#__PURE__*/React.createElement(StatusCriticalSmall, {
|
|
126
|
+
color: "status-critical"
|
|
127
|
+
}), /*#__PURE__*/React.createElement(Text, null, datum.success ? 'Successful' : 'Failed'));
|
|
149
128
|
}
|
|
150
129
|
}];
|
|
151
130
|
var STEP = 10;
|
|
@@ -158,19 +137,17 @@ export var Table = function Table() {
|
|
|
158
137
|
rockets = _useState2[0],
|
|
159
138
|
setRockets = _useState2[1];
|
|
160
139
|
var _useState3 = useState({
|
|
161
|
-
search: ''
|
|
140
|
+
search: '',
|
|
141
|
+
sort: {
|
|
142
|
+
property: 'name',
|
|
143
|
+
direction: 'asc'
|
|
144
|
+
}
|
|
162
145
|
}),
|
|
163
146
|
view = _useState3[0],
|
|
164
147
|
setView = _useState3[1];
|
|
165
|
-
var _useState4 = useState(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}),
|
|
169
|
-
sort = _useState4[0],
|
|
170
|
-
setSort = _useState4[1];
|
|
171
|
-
var _useState5 = useState(STEP),
|
|
172
|
-
limit = _useState5[0],
|
|
173
|
-
setLimit = _useState5[1];
|
|
148
|
+
var _useState4 = useState(STEP),
|
|
149
|
+
limit = _useState4[0],
|
|
150
|
+
setLimit = _useState4[1];
|
|
174
151
|
var search = view.search || '';
|
|
175
152
|
useEffect(function () {
|
|
176
153
|
fetchRockets().then(function (d) {
|
|
@@ -181,16 +158,16 @@ export var Table = function Table() {
|
|
|
181
158
|
fetchLaunches({
|
|
182
159
|
search: search,
|
|
183
160
|
limit: limit,
|
|
184
|
-
sort: sort,
|
|
161
|
+
sort: view.sort,
|
|
185
162
|
properties: view.properties
|
|
186
163
|
}).then(function (d) {
|
|
187
164
|
return setData(d);
|
|
188
165
|
});
|
|
189
|
-
}, [search, limit, sort, view.properties]);
|
|
166
|
+
}, [search, limit, view.sort, view.properties]);
|
|
190
167
|
var numberItems = (data == null ? void 0 : data.totalDocs) || 0;
|
|
191
|
-
var rocketOptions = (rockets == null || (_rockets$docs = rockets.docs) == null ? void 0 : _rockets$docs.map(function (
|
|
192
|
-
var name =
|
|
193
|
-
id =
|
|
168
|
+
var rocketOptions = (rockets == null || (_rockets$docs = rockets.docs) == null ? void 0 : _rockets$docs.map(function (_ref3) {
|
|
169
|
+
var name = _ref3.name,
|
|
170
|
+
id = _ref3.id;
|
|
194
171
|
return {
|
|
195
172
|
value: id,
|
|
196
173
|
label: name
|
|
@@ -201,16 +178,9 @@ export var Table = function Table() {
|
|
|
201
178
|
/*#__PURE__*/
|
|
202
179
|
// Uncomment <Grommet> lines when using outside of storybook
|
|
203
180
|
// <Grommet theme={...}>
|
|
204
|
-
React.createElement(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
columns: [['small', 'large']],
|
|
208
|
-
justifyContent: "center",
|
|
209
|
-
gap: "large"
|
|
210
|
-
}, /*#__PURE__*/React.createElement(Notification, {
|
|
211
|
-
status: "info",
|
|
212
|
-
message: "Data is in 'beta'. The API surface is subject to change."
|
|
213
|
-
}), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Data, {
|
|
181
|
+
React.createElement(Box, {
|
|
182
|
+
pad: "large"
|
|
183
|
+
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Data, {
|
|
214
184
|
properties: {
|
|
215
185
|
rocket: {
|
|
216
186
|
label: 'Rocket',
|
|
@@ -229,19 +199,15 @@ export var Table = function Table() {
|
|
|
229
199
|
},
|
|
230
200
|
toolbar: true
|
|
231
201
|
}, /*#__PURE__*/React.createElement(DataTable, {
|
|
202
|
+
alignSelf: "start",
|
|
232
203
|
columns: columns,
|
|
233
|
-
sort: _extends({}, sort, {
|
|
234
|
-
external: true
|
|
235
|
-
}),
|
|
236
|
-
onSort: function onSort(opts) {
|
|
237
|
-
return setSort(opts);
|
|
238
|
-
},
|
|
239
204
|
step: STEP,
|
|
240
205
|
onMore: function onMore() {
|
|
241
206
|
if (limit < numberItems) {
|
|
242
207
|
setLimit(limit + STEP);
|
|
243
208
|
}
|
|
244
|
-
}
|
|
209
|
+
},
|
|
210
|
+
sortable: true
|
|
245
211
|
}))))
|
|
246
212
|
// </Grommet>
|
|
247
213
|
);
|