grommet 2.29.0 → 2.29.1
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/Button/Button.js +4 -12
- package/components/Button/StyledButtonKind.js +1 -3
- package/components/Calendar/Calendar.js +66 -65
- package/components/Data/Data.js +48 -26
- package/components/Data/DataForm.js +132 -42
- package/components/Data/filter.js +17 -6
- package/components/Data/index.d.ts +12 -7
- package/components/Data/index.js +6 -2
- package/components/Data/propTypes.js +3 -2
- package/components/Data/stories/Infinite.js +52 -56
- package/components/Data/stories/SpaceX.js +113 -139
- package/components/Data/stories/StarWars.js +133 -0
- package/components/Data/stories/Views.js +56 -0
- package/components/DataFilter/DataFilter.js +5 -4
- package/components/DataFilters/DataFilters.js +45 -12
- package/components/DataSearch/DataSearch.js +17 -8
- package/components/DataSort/DataSort.js +6 -6
- package/components/DataSummary/DataSummary.js +4 -4
- package/components/DataSummary/index.d.ts +1 -1
- package/components/DataSummary/propTypes.js +2 -2
- package/components/DataTable/Cell.js +1 -1
- package/components/DataTable/DataTable.js +23 -9
- package/components/DataTable/Resizer.js +1 -3
- package/components/DataTable/index.d.ts +23 -6
- package/components/DataTable/stories/SpaceX.js +72 -76
- package/components/DataTable/stories/SpaceXUngrouped.js +33 -35
- package/components/DataTableColumns/DataTableColumns.js +225 -0
- package/components/DataTableColumns/README.md +2 -0
- package/components/DataTableColumns/index.d.ts +10 -0
- package/components/DataTableColumns/index.js +6 -0
- package/components/DataTableColumns/propTypes.js +18 -0
- package/components/DataTableColumns/stories/Simple.js +47 -0
- package/components/DataView/DataView.js +58 -0
- package/components/DataView/README.md +2 -0
- package/components/DataView/index.d.ts +15 -0
- package/components/DataView/index.js +6 -0
- package/components/DataView/propTypes.js +10 -0
- package/components/DataView/stories/Simple.js +48 -0
- package/components/DateInput/utils.js +1 -3
- package/components/Drop/DropContainer.js +25 -22
- package/components/Form/stories/ValidateOnBlur.js +18 -0
- package/components/FormField/FormField.js +14 -4
- package/components/Layer/LayerContainer.js +1 -2
- package/components/Layer/PortalContext.js +1 -1
- package/components/Layer/stories/Form.js +54 -28
- package/components/List/List.js +1 -8
- package/components/Pagination/Pagination.js +19 -8
- package/components/Select/utils.js +1 -1
- package/components/Skeleton/stories/GridContainer.js +1 -3
- package/components/Video/Video.js +4 -8
- package/components/WorldMap/WorldMap.js +1 -3
- package/components/index.d.ts +2 -0
- package/components/index.js +18 -6
- package/es6/components/Button/Button.js +4 -12
- package/es6/components/Button/StyledButtonKind.js +1 -3
- package/es6/components/Calendar/Calendar.js +66 -65
- package/es6/components/Data/Data.js +48 -26
- package/es6/components/Data/DataForm.js +128 -45
- package/es6/components/Data/filter.js +17 -6
- package/es6/components/Data/index.d.ts +12 -7
- package/es6/components/Data/index.js +1 -1
- package/es6/components/Data/propTypes.js +3 -2
- package/es6/components/Data/stories/Infinite.js +52 -56
- package/es6/components/Data/stories/SpaceX.js +113 -139
- package/es6/components/Data/stories/StarWars.js +127 -0
- package/es6/components/Data/stories/Views.js +50 -0
- package/es6/components/DataFilter/DataFilter.js +5 -4
- package/es6/components/DataFilters/DataFilters.js +45 -12
- package/es6/components/DataSearch/DataSearch.js +17 -8
- package/es6/components/DataSort/DataSort.js +5 -5
- package/es6/components/DataSummary/DataSummary.js +4 -4
- package/es6/components/DataSummary/index.d.ts +1 -1
- package/es6/components/DataSummary/propTypes.js +2 -2
- package/es6/components/DataTable/Cell.js +2 -2
- package/es6/components/DataTable/DataTable.js +23 -9
- package/es6/components/DataTable/Resizer.js +1 -3
- package/es6/components/DataTable/index.d.ts +23 -6
- package/es6/components/DataTable/stories/SpaceX.js +72 -76
- package/es6/components/DataTable/stories/SpaceXUngrouped.js +33 -35
- package/es6/components/DataTableColumns/DataTableColumns.js +218 -0
- package/es6/components/DataTableColumns/README.md +2 -0
- package/es6/components/DataTableColumns/index.d.ts +10 -0
- package/es6/components/DataTableColumns/index.js +1 -0
- package/es6/components/DataTableColumns/propTypes.js +12 -0
- package/es6/components/DataTableColumns/stories/Simple.js +42 -0
- package/es6/components/DataView/DataView.js +51 -0
- package/es6/components/DataView/README.md +2 -0
- package/es6/components/DataView/index.d.ts +15 -0
- package/es6/components/DataView/index.js +1 -0
- package/es6/components/DataView/propTypes.js +5 -0
- package/es6/components/DataView/stories/Simple.js +42 -0
- package/es6/components/DateInput/utils.js +1 -3
- package/es6/components/Drop/DropContainer.js +25 -22
- package/es6/components/Form/stories/ValidateOnBlur.js +19 -1
- package/es6/components/FormField/FormField.js +14 -4
- package/es6/components/Layer/LayerContainer.js +1 -2
- package/es6/components/Layer/PortalContext.js +1 -1
- package/es6/components/Layer/stories/Form.js +56 -29
- package/es6/components/List/List.js +1 -8
- package/es6/components/Pagination/Pagination.js +19 -8
- package/es6/components/Select/utils.js +1 -1
- package/es6/components/Skeleton/stories/GridContainer.js +1 -3
- package/es6/components/Video/Video.js +4 -8
- package/es6/components/WorldMap/WorldMap.js +1 -3
- package/es6/components/index.d.ts +2 -0
- package/es6/components/index.js +3 -1
- package/es6/languages/default.json +7 -2
- package/es6/utils/DOM.js +17 -0
- package/es6/utils/PortalContext.js +1 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +7 -2
- package/package.json +31 -31
- package/utils/DOM.js +20 -2
- package/utils/PortalContext.js +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Data, DataTable, Grid, Toolbar } from 'grommet';
|
|
3
|
+
import { DataTableColumns } from '../DataTableColumns';
|
|
4
|
+
import { columns, DATA } from '../../DataTable/stories/data';
|
|
5
|
+
|
|
6
|
+
// simplify option label for name property
|
|
7
|
+
var options = columns.map(function (_ref) {
|
|
8
|
+
var header = _ref.header,
|
|
9
|
+
property = _ref.property;
|
|
10
|
+
return {
|
|
11
|
+
property: property,
|
|
12
|
+
label: property === 'name' ? 'Name' : header
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
export var Simple = function Simple() {
|
|
16
|
+
return (
|
|
17
|
+
/*#__PURE__*/
|
|
18
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
19
|
+
// <Grommet theme={...}>
|
|
20
|
+
React.createElement(Grid, {
|
|
21
|
+
pad: "large",
|
|
22
|
+
columns: ['large'],
|
|
23
|
+
justifyContent: "center"
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Data, {
|
|
25
|
+
data: DATA,
|
|
26
|
+
updateOn: "change"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(DataTableColumns, {
|
|
28
|
+
drop: true,
|
|
29
|
+
options: options
|
|
30
|
+
})), /*#__PURE__*/React.createElement(DataTable, {
|
|
31
|
+
columns: columns
|
|
32
|
+
})))
|
|
33
|
+
// </Grommet>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Simple.args = {
|
|
38
|
+
full: true
|
|
39
|
+
};
|
|
40
|
+
export default {
|
|
41
|
+
title: 'Layout/Data/DataTableColumns/Simple'
|
|
42
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
|
|
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
|
+
import React, { useContext, useEffect } from 'react';
|
|
4
|
+
import { DataForm } from '../Data/DataForm';
|
|
5
|
+
import { DataContext } from '../../contexts/DataContext';
|
|
6
|
+
import { FormContext } from '../Form/FormContext';
|
|
7
|
+
import { RadioButtonGroup } from '../RadioButtonGroup';
|
|
8
|
+
import { Select } from '../Select';
|
|
9
|
+
import { DataViewPropTypes } from './propTypes';
|
|
10
|
+
export var DataView = function DataView(_ref) {
|
|
11
|
+
var rest = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
12
|
+
var _useContext = useContext(DataContext),
|
|
13
|
+
dataId = _useContext.id,
|
|
14
|
+
view = _useContext.view,
|
|
15
|
+
views = _useContext.views,
|
|
16
|
+
addToolbarKey = _useContext.addToolbarKey;
|
|
17
|
+
var _useContext2 = useContext(FormContext),
|
|
18
|
+
noForm = _useContext2.noForm;
|
|
19
|
+
useEffect(function () {
|
|
20
|
+
if (noForm) addToolbarKey('_view');
|
|
21
|
+
}, [addToolbarKey, noForm]);
|
|
22
|
+
if (!views) return null;
|
|
23
|
+
var names = views.map(function (v) {
|
|
24
|
+
return v.name;
|
|
25
|
+
});
|
|
26
|
+
var id = dataId + "-view";
|
|
27
|
+
var content;
|
|
28
|
+
if (!noForm && names.length < 7) {
|
|
29
|
+
content = /*#__PURE__*/React.createElement(RadioButtonGroup, _extends({
|
|
30
|
+
id: id,
|
|
31
|
+
name: "_view",
|
|
32
|
+
options: names,
|
|
33
|
+
value: view == null ? void 0 : view.name
|
|
34
|
+
}, rest));
|
|
35
|
+
} else {
|
|
36
|
+
content = /*#__PURE__*/React.createElement(Select, _extends({
|
|
37
|
+
id: id,
|
|
38
|
+
name: "_view",
|
|
39
|
+
showSelectedInline: true,
|
|
40
|
+
placeholder: noForm ? 'Select view ...' : undefined,
|
|
41
|
+
options: names,
|
|
42
|
+
value: view == null ? void 0 : view.name
|
|
43
|
+
}, rest));
|
|
44
|
+
}
|
|
45
|
+
if (noForm) content = /*#__PURE__*/React.createElement(DataForm, {
|
|
46
|
+
footer: false,
|
|
47
|
+
updateOn: "change"
|
|
48
|
+
}, content);
|
|
49
|
+
return content;
|
|
50
|
+
};
|
|
51
|
+
DataView.propTypes = DataViewPropTypes;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BoxProps } from '../Box/index';
|
|
3
|
+
|
|
4
|
+
export interface DataViewProps {}
|
|
5
|
+
|
|
6
|
+
type divProps = Omit<JSX.IntrinsicElements['div'], 'onClick' | 'property'>;
|
|
7
|
+
|
|
8
|
+
export interface DataViewExtendedProps
|
|
9
|
+
extends BoxProps,
|
|
10
|
+
DataViewProps,
|
|
11
|
+
divProps {}
|
|
12
|
+
|
|
13
|
+
declare const DataView: React.FC<DataViewExtendedProps>;
|
|
14
|
+
|
|
15
|
+
export { DataView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataView } from './DataView';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Data } from 'grommet';
|
|
3
|
+
import { DataView } from '../DataView';
|
|
4
|
+
import { DATA } from '../../DataTable/stories/data';
|
|
5
|
+
export var Simple = function Simple() {
|
|
6
|
+
return (
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
9
|
+
// <Grommet theme={...}>
|
|
10
|
+
React.createElement(Box, {
|
|
11
|
+
fill: true,
|
|
12
|
+
align: "center",
|
|
13
|
+
justify: "start",
|
|
14
|
+
pad: "large"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Data, {
|
|
16
|
+
data: DATA,
|
|
17
|
+
views: [{
|
|
18
|
+
name: 'latest',
|
|
19
|
+
sort: {
|
|
20
|
+
property: 'date',
|
|
21
|
+
direction: 'desc'
|
|
22
|
+
}
|
|
23
|
+
}, {
|
|
24
|
+
name: 'behind',
|
|
25
|
+
properties: {
|
|
26
|
+
percent: {
|
|
27
|
+
min: 0,
|
|
28
|
+
max: 30
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}]
|
|
32
|
+
}, /*#__PURE__*/React.createElement(DataView, null)))
|
|
33
|
+
// </Grommet>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Simple.args = {
|
|
38
|
+
full: true
|
|
39
|
+
};
|
|
40
|
+
export default {
|
|
41
|
+
title: 'Layout/Data/DataView/Simple'
|
|
42
|
+
};
|
|
@@ -115,9 +115,7 @@ var charCodeZero = '0'.charCodeAt(0);
|
|
|
115
115
|
var charCodeNine = '9'.charCodeAt(0);
|
|
116
116
|
var pullDigits = function pullDigits(text, index) {
|
|
117
117
|
var end = index;
|
|
118
|
-
while (text.charCodeAt(end) >= charCodeZero && text.charCodeAt(end) <= charCodeNine)
|
|
119
|
-
end += 1;
|
|
120
|
-
}
|
|
118
|
+
while (text.charCodeAt(end) >= charCodeZero && text.charCodeAt(end) <= charCodeNine) end += 1;
|
|
121
119
|
return text.slice(index, end);
|
|
122
120
|
};
|
|
123
121
|
export var validateBounds = function validateBounds(dateBounds, selectedDate) {
|
|
@@ -23,7 +23,6 @@ var defaultAlign = {
|
|
|
23
23
|
top: 'top',
|
|
24
24
|
left: 'left'
|
|
25
25
|
};
|
|
26
|
-
var defaultPortalContext = [];
|
|
27
26
|
var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
28
27
|
var a11yTitle = _ref.a11yTitle,
|
|
29
28
|
ariaLabel = _ref['aria-label'],
|
|
@@ -48,7 +47,7 @@ var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
48
47
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
49
48
|
var containerTarget = useContext(ContainerTargetContext);
|
|
50
49
|
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
51
|
-
var portalContext = useContext(PortalContext)
|
|
50
|
+
var portalContext = useContext(PortalContext);
|
|
52
51
|
var portalId = useMemo(function () {
|
|
53
52
|
return portalContext.length;
|
|
54
53
|
}, [portalContext]);
|
|
@@ -56,6 +55,29 @@ var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
56
55
|
return [].concat(portalContext, [portalId]);
|
|
57
56
|
}, [portalContext, portalId]);
|
|
58
57
|
var dropRef = useRef();
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
var onClickDocument = function onClickDocument(event) {
|
|
60
|
+
// determine which portal id the target is in, if any
|
|
61
|
+
var clickedPortalId = null;
|
|
62
|
+
var node = containerTarget === document.body ? event.target : event == null ? void 0 : event.composedPath()[0];
|
|
63
|
+
while (clickedPortalId === null && node !== document) {
|
|
64
|
+
var attr = node.getAttribute('data-g-portal-id');
|
|
65
|
+
if (attr !== null) clickedPortalId = parseInt(attr, 10);
|
|
66
|
+
node = node.parentNode;
|
|
67
|
+
}
|
|
68
|
+
if (clickedPortalId === null || portalContext.indexOf(clickedPortalId) !== -1) {
|
|
69
|
+
onClickOutside(event);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
if (onClickOutside) {
|
|
73
|
+
document.addEventListener('mousedown', onClickDocument);
|
|
74
|
+
}
|
|
75
|
+
return function () {
|
|
76
|
+
if (onClickOutside) {
|
|
77
|
+
document.removeEventListener('mousedown', onClickDocument);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [onClickOutside, containerTarget, portalContext]);
|
|
59
81
|
useEffect(function () {
|
|
60
82
|
var notifyAlign = function notifyAlign() {
|
|
61
83
|
var styleCurrent = (ref || dropRef).current.style;
|
|
@@ -228,19 +250,6 @@ var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
228
250
|
});
|
|
229
251
|
scrollParents = [];
|
|
230
252
|
};
|
|
231
|
-
var onClickDocument = function onClickDocument(event) {
|
|
232
|
-
// determine which portal id the target is in, if any
|
|
233
|
-
var clickedPortalId = null;
|
|
234
|
-
var node = containerTarget === document.body ? event.target : event == null ? void 0 : event.composedPath()[0];
|
|
235
|
-
while (clickedPortalId === null && node !== document) {
|
|
236
|
-
var attr = node.getAttribute('data-g-portal-id');
|
|
237
|
-
if (attr !== null) clickedPortalId = parseInt(attr, 10);
|
|
238
|
-
node = node.parentNode;
|
|
239
|
-
}
|
|
240
|
-
if (clickedPortalId === null || portalContext.indexOf(clickedPortalId) !== -1) {
|
|
241
|
-
onClickOutside(event);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
253
|
var onResize = function onResize() {
|
|
245
254
|
removeScrollListeners();
|
|
246
255
|
addScrollListeners();
|
|
@@ -248,18 +257,12 @@ var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
248
257
|
};
|
|
249
258
|
addScrollListeners();
|
|
250
259
|
window.addEventListener('resize', onResize);
|
|
251
|
-
if (onClickOutside) {
|
|
252
|
-
document.addEventListener('mousedown', onClickDocument);
|
|
253
|
-
}
|
|
254
260
|
place(false);
|
|
255
261
|
return function () {
|
|
256
262
|
removeScrollListeners();
|
|
257
263
|
window.removeEventListener('resize', onResize);
|
|
258
|
-
if (onClickOutside) {
|
|
259
|
-
document.removeEventListener('mousedown', onClickDocument);
|
|
260
|
-
}
|
|
261
264
|
};
|
|
262
|
-
}, [align, containerTarget, onAlign, dropTarget,
|
|
265
|
+
}, [align, containerTarget, onAlign, dropTarget, portalContext, portalId, ref, responsive, restrictFocus, stretch, theme.drop]);
|
|
263
266
|
useEffect(function () {
|
|
264
267
|
if (restrictFocus) {
|
|
265
268
|
(ref || dropRef).current.focus();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StatusGood } from "grommet-icons/es6/icons/StatusGood";
|
|
3
|
-
import { Box, Button, Form, FormField, TextInput } from 'grommet';
|
|
3
|
+
import { Box, Button, Form, FormField, Select, TextInput } from 'grommet';
|
|
4
4
|
export var ValidateOnBlur = function ValidateOnBlur() {
|
|
5
5
|
return (
|
|
6
6
|
/*#__PURE__*/
|
|
@@ -48,6 +48,24 @@ export var ValidateOnBlur = function ValidateOnBlur() {
|
|
|
48
48
|
name: "email",
|
|
49
49
|
"aria-label": "email",
|
|
50
50
|
type: "email"
|
|
51
|
+
})), /*#__PURE__*/React.createElement(FormField, {
|
|
52
|
+
label: "Size",
|
|
53
|
+
name: "select-size",
|
|
54
|
+
htmlFor: "select-size__input",
|
|
55
|
+
required: true,
|
|
56
|
+
validate: function validate(val) {
|
|
57
|
+
if (val === 'small') {
|
|
58
|
+
return {
|
|
59
|
+
message: 'Only 10 left in stock!',
|
|
60
|
+
status: 'info'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
66
|
+
name: "select-size",
|
|
67
|
+
id: "select-size",
|
|
68
|
+
options: ['small', 'medium', 'large']
|
|
51
69
|
})), /*#__PURE__*/React.createElement(Box, {
|
|
52
70
|
direction: "row",
|
|
53
71
|
justify: "between",
|
|
@@ -6,7 +6,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
6
6
|
import React, { Children, cloneElement, forwardRef, useContext, useState, useEffect } from 'react';
|
|
7
7
|
import styled, { ThemeContext } from 'styled-components';
|
|
8
8
|
import { defaultProps } from '../../default-props';
|
|
9
|
-
import { containsFocus, shouldKeepFocus } from '../../utils
|
|
9
|
+
import { containsFocus, shouldKeepFocus, withinDropPortal, PortalContext } from '../../utils';
|
|
10
10
|
import { focusStyle } from '../../utils/styles';
|
|
11
11
|
import { parseMetricToNum } from '../../utils/mixins';
|
|
12
12
|
import { useForwardedRef } from '../../utils/refs';
|
|
@@ -177,6 +177,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
177
177
|
var formFieldTheme = theme.formField;
|
|
178
178
|
var themeBorder = formFieldTheme.border;
|
|
179
179
|
var debounce = useDebounce();
|
|
180
|
+
var portalContext = useContext(PortalContext);
|
|
180
181
|
|
|
181
182
|
// This is here for backwards compatibility. In case the child is a grommet
|
|
182
183
|
// input component, set plain and focusIndicator props, if they aren't
|
|
@@ -336,13 +337,22 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
336
337
|
}, outerProps, {
|
|
337
338
|
style: outerStyle,
|
|
338
339
|
onFocus: function onFocus(event) {
|
|
339
|
-
var
|
|
340
|
-
|
|
340
|
+
var _formFieldRef$current;
|
|
341
|
+
var root = (_formFieldRef$current = formFieldRef.current) == null ? void 0 : _formFieldRef$current.getRootNode();
|
|
342
|
+
if (root) {
|
|
343
|
+
setFocus(containsFocus(formFieldRef.current) && shouldKeepFocus(root));
|
|
344
|
+
}
|
|
341
345
|
if (_onFocus) _onFocus(event);
|
|
342
346
|
},
|
|
343
347
|
onBlur: function onBlur(event) {
|
|
344
348
|
setFocus(false);
|
|
345
|
-
|
|
349
|
+
|
|
350
|
+
// if input has a drop and focus is within drop
|
|
351
|
+
// prevent onBlur validation from running until
|
|
352
|
+
// focus is no longer within the drop or input
|
|
353
|
+
if (contextOnBlur && !formFieldRef.current.contains(event.relatedTarget) && !withinDropPortal(event.relatedTarget, portalContext)) {
|
|
354
|
+
contextOnBlur(event);
|
|
355
|
+
}
|
|
346
356
|
if (_onBlur) _onBlur(event);
|
|
347
357
|
},
|
|
348
358
|
onChange: contextOnChange || onChange ? function (event) {
|
|
@@ -16,7 +16,6 @@ var HiddenAnchor = styled.a.withConfig({
|
|
|
16
16
|
displayName: "LayerContainer__HiddenAnchor",
|
|
17
17
|
componentId: "sc-1srj14c-0"
|
|
18
18
|
})(["width:0;height:0;overflow:hidden;position:absolute;"]);
|
|
19
|
-
var defaultPortalContext = [];
|
|
20
19
|
var LayerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
21
20
|
var background = _ref.background,
|
|
22
21
|
children = _ref.children,
|
|
@@ -46,7 +45,7 @@ var LayerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
46
45
|
var anchorRef = useRef();
|
|
47
46
|
var containerRef = useRef();
|
|
48
47
|
var layerRef = useRef();
|
|
49
|
-
var portalContext = useContext(PortalContext)
|
|
48
|
+
var portalContext = useContext(PortalContext);
|
|
50
49
|
var portalId = useMemo(function () {
|
|
51
50
|
return portalContext.length;
|
|
52
51
|
}, [portalContext]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export var PortalContext = /*#__PURE__*/React.createContext(
|
|
2
|
+
export var PortalContext = /*#__PURE__*/React.createContext([]);
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Add } from "grommet-icons/es6/icons/Add";
|
|
3
3
|
import { Close } from "grommet-icons/es6/icons/Close";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { StatusGood } from "grommet-icons/es6/icons/StatusGood";
|
|
5
|
+
import { Box, Button, Form, FormField, Heading, Layer, Select, TextInput } from 'grommet';
|
|
6
6
|
export var FormLayer = function FormLayer() {
|
|
7
7
|
var _React$useState = React.useState(false),
|
|
8
8
|
open = _React$useState[0],
|
|
9
9
|
setOpen = _React$useState[1];
|
|
10
|
-
var _React$useState2 = React.useState(''),
|
|
11
|
-
select = _React$useState2[0],
|
|
12
|
-
setSelect = _React$useState2[1];
|
|
13
10
|
var onOpen = function onOpen() {
|
|
14
11
|
return setOpen(true);
|
|
15
12
|
};
|
|
@@ -35,12 +32,19 @@ export var FormLayer = function FormLayer() {
|
|
|
35
32
|
onClickOutside: onClose,
|
|
36
33
|
onEsc: onClose
|
|
37
34
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
38
|
-
as: "form",
|
|
39
35
|
fill: "vertical",
|
|
40
36
|
overflow: "auto",
|
|
41
37
|
width: "medium",
|
|
42
|
-
pad: "medium"
|
|
43
|
-
|
|
38
|
+
pad: "medium"
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Form, {
|
|
40
|
+
validate: "blur",
|
|
41
|
+
onReset: function onReset(event) {
|
|
42
|
+
return console.log(event);
|
|
43
|
+
},
|
|
44
|
+
onSubmit: function onSubmit(_ref) {
|
|
45
|
+
var value = _ref.value;
|
|
46
|
+
return console.log('Submit', value);
|
|
47
|
+
}
|
|
44
48
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
45
49
|
flex: false,
|
|
46
50
|
direction: "row",
|
|
@@ -51,29 +55,52 @@ export var FormLayer = function FormLayer() {
|
|
|
51
55
|
}, "Add"), /*#__PURE__*/React.createElement(Button, {
|
|
52
56
|
icon: /*#__PURE__*/React.createElement(Close, null),
|
|
53
57
|
onClick: onClose
|
|
54
|
-
})), /*#__PURE__*/React.createElement(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
})), /*#__PURE__*/React.createElement(FormField, {
|
|
59
|
+
label: "Name",
|
|
60
|
+
"aria-label": "name",
|
|
61
|
+
name: "name",
|
|
62
|
+
required: true,
|
|
63
|
+
validate: [{
|
|
64
|
+
regexp: /^[a-z]/i
|
|
65
|
+
}, function (name) {
|
|
66
|
+
if (name && name.length === 1) return 'must be >1 character';
|
|
67
|
+
return undefined;
|
|
68
|
+
}, function (name) {
|
|
69
|
+
if (name === 'good') return {
|
|
70
|
+
message: /*#__PURE__*/React.createElement(Box, {
|
|
71
|
+
align: "end"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(StatusGood, null)),
|
|
73
|
+
status: 'info'
|
|
74
|
+
};
|
|
75
|
+
return undefined;
|
|
76
|
+
}]
|
|
77
|
+
}), /*#__PURE__*/React.createElement(FormField, {
|
|
78
|
+
label: "Email",
|
|
79
|
+
name: "email",
|
|
80
|
+
required: true
|
|
62
81
|
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
63
|
-
|
|
82
|
+
name: "email",
|
|
83
|
+
"aria-label": "email",
|
|
84
|
+
type: "email"
|
|
64
85
|
})), /*#__PURE__*/React.createElement(FormField, {
|
|
65
|
-
label: "
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
label: "Size",
|
|
87
|
+
name: "select-size",
|
|
88
|
+
htmlFor: "select-size__input",
|
|
89
|
+
required: true,
|
|
90
|
+
validate: function validate(val) {
|
|
91
|
+
if (val === 'small') {
|
|
92
|
+
return {
|
|
93
|
+
message: 'Only 10 left in stock!',
|
|
94
|
+
status: 'info'
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
73
98
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
99
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
100
|
+
name: "select-size",
|
|
101
|
+
id: "select-size",
|
|
102
|
+
options: ['small', 'medium', 'large']
|
|
103
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
77
104
|
flex: false,
|
|
78
105
|
as: "footer",
|
|
79
106
|
align: "start"
|
|
@@ -82,7 +109,7 @@ export var FormLayer = function FormLayer() {
|
|
|
82
109
|
label: "Submit",
|
|
83
110
|
onClick: onClose,
|
|
84
111
|
primary: true
|
|
85
|
-
})))))
|
|
112
|
+
}))))))
|
|
86
113
|
// </Grommet>
|
|
87
114
|
);
|
|
88
115
|
};
|
|
@@ -77,11 +77,7 @@ var getValue = function getValue(item, index, key) {
|
|
|
77
77
|
var reorder = function reorder(array, pinnedArray, source, target) {
|
|
78
78
|
var result = array.slice(0);
|
|
79
79
|
var tmp = result[source];
|
|
80
|
-
if (source < target) for (var i = source; i < target; i += 1)
|
|
81
|
-
result[i] = result[i + 1];
|
|
82
|
-
} else for (var _i = source; _i > target; _i -= 1) {
|
|
83
|
-
result[_i] = result[_i - 1];
|
|
84
|
-
}
|
|
80
|
+
if (source < target) for (var i = source; i < target; i += 1) result[i] = result[i + 1];else for (var _i = source; _i > target; _i -= 1) result[_i] = result[_i - 1];
|
|
85
81
|
result[target] = tmp;
|
|
86
82
|
|
|
87
83
|
// insert pinned items into their proper index within the orderable
|
|
@@ -394,9 +390,6 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
394
390
|
adjustedEvent.item = item;
|
|
395
391
|
adjustedEvent.index = index;
|
|
396
392
|
onClickItem(adjustedEvent);
|
|
397
|
-
// put focus on the List container to meet WCAG
|
|
398
|
-
// accessibility guidelines that focus remains on `ul`
|
|
399
|
-
listRef.current.focus();
|
|
400
393
|
sendAnalytics({
|
|
401
394
|
type: 'listItemClick',
|
|
402
395
|
element: listRef.current,
|
|
@@ -4,6 +4,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
4
4
|
import React, { forwardRef, useContext, useEffect, useState } from 'react';
|
|
5
5
|
import styled, { ThemeContext } from 'styled-components';
|
|
6
6
|
import { defaultProps } from '../../default-props';
|
|
7
|
+
import { DataContext } from '../../contexts/DataContext';
|
|
7
8
|
import { Box } from '../Box';
|
|
8
9
|
import { Nav } from '../Nav';
|
|
9
10
|
import { PageControl } from './PageControl';
|
|
@@ -22,6 +23,7 @@ var getPageIndices = function getPageIndices(begin, end) {
|
|
|
22
23
|
return indices;
|
|
23
24
|
};
|
|
24
25
|
var Pagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
26
|
+
var _ref2;
|
|
25
27
|
var a11yTitle = _ref.a11yTitle,
|
|
26
28
|
ariaLabel = _ref['aria-label'],
|
|
27
29
|
numberItems = _ref.numberItems,
|
|
@@ -32,19 +34,25 @@ var Pagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
32
34
|
onChange = _ref.onChange,
|
|
33
35
|
pageProp = _ref.page,
|
|
34
36
|
size = _ref.size,
|
|
35
|
-
|
|
36
|
-
step = _ref$step === void 0 ? 10 : _ref$step,
|
|
37
|
+
stepProp = _ref.step,
|
|
37
38
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
38
39
|
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
40
|
+
var _useContext = useContext(DataContext),
|
|
41
|
+
onView = _useContext.onView,
|
|
42
|
+
filteredTotal = _useContext.filteredTotal,
|
|
43
|
+
view = _useContext.view;
|
|
44
|
+
var step = stepProp || (view == null ? void 0 : view.step) || 10;
|
|
45
|
+
var total = (_ref2 = numberItems != null ? numberItems : filteredTotal) != null ? _ref2 : 0;
|
|
46
|
+
var page = pageProp || (view == null ? void 0 : view.page) || 1;
|
|
39
47
|
|
|
40
48
|
/* Calculate total number pages */
|
|
41
|
-
var totalPages = Math.ceil(
|
|
42
|
-
var _useState = useState(Math.min(
|
|
49
|
+
var totalPages = Math.ceil(total / step);
|
|
50
|
+
var _useState = useState(Math.min(page, totalPages) || 1),
|
|
43
51
|
activePage = _useState[0],
|
|
44
52
|
setActivePage = _useState[1];
|
|
45
53
|
useEffect(function () {
|
|
46
|
-
setActivePage(
|
|
47
|
-
}, [
|
|
54
|
+
return setActivePage(page);
|
|
55
|
+
}, [page]);
|
|
48
56
|
|
|
49
57
|
/* Define page indices to display */
|
|
50
58
|
var beginPages = getPageIndices(1, Math.min(numberEdgePages, totalPages));
|
|
@@ -78,6 +86,9 @@ var Pagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
78
86
|
};
|
|
79
87
|
var handleClick = function handleClick(event, nextPage) {
|
|
80
88
|
setActivePage(nextPage);
|
|
89
|
+
if (onView) onView(_extends({}, view, {
|
|
90
|
+
page: nextPage
|
|
91
|
+
}));
|
|
81
92
|
if (onChange) {
|
|
82
93
|
event.persist();
|
|
83
94
|
var adjustedEvent = event;
|
|
@@ -100,7 +111,7 @@ var Pagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
100
111
|
next: {
|
|
101
112
|
// https://a11y-style-guide.com/style-guide/section-navigation.html#kssref-navigation-pagination
|
|
102
113
|
'aria-disabled': activePage === totalPages ? 'true' : undefined,
|
|
103
|
-
disabled: activePage === totalPages || !
|
|
114
|
+
disabled: activePage === totalPages || !total,
|
|
104
115
|
icon: /*#__PURE__*/React.createElement(NextIcon, {
|
|
105
116
|
color: iconColor
|
|
106
117
|
}),
|
|
@@ -112,7 +123,7 @@ var Pagination = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
112
123
|
},
|
|
113
124
|
previous: {
|
|
114
125
|
'aria-disabled': activePage === 1 ? 'true' : undefined,
|
|
115
|
-
disabled: activePage === 1 || !
|
|
126
|
+
disabled: activePage === 1 || !total,
|
|
116
127
|
icon: /*#__PURE__*/React.createElement(PreviousIcon, {
|
|
117
128
|
color: iconColor
|
|
118
129
|
}),
|
|
@@ -4,7 +4,7 @@ export var applyKey = function applyKey(option, key) {
|
|
|
4
4
|
if (option === undefined || option === null) return undefined;
|
|
5
5
|
if (typeof key === 'object') return applyKey(option, key.key);
|
|
6
6
|
if (typeof key === 'function') return key(option);
|
|
7
|
-
if (key !== undefined) return option[key];
|
|
7
|
+
if (key !== undefined && typeof option === 'object') return option[key];
|
|
8
8
|
if (typeof option === 'object' && Object.keys(option)) return option[Object.keys(option)[0]];
|
|
9
9
|
return option;
|
|
10
10
|
};
|
|
@@ -5,9 +5,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
5
5
|
import { Box, Button, Card, Grid, Image, Text } from 'grommet';
|
|
6
6
|
import { FormAdd } from "grommet-icons/es6/icons/FormAdd";
|
|
7
7
|
var labels = [];
|
|
8
|
-
for (var i = 0; i < 10; i += 1)
|
|
9
|
-
labels.push("Item " + i);
|
|
10
|
-
}
|
|
8
|
+
for (var i = 0; i < 10; i += 1) labels.push("Item " + i);
|
|
11
9
|
var skeleton = {
|
|
12
10
|
message: {
|
|
13
11
|
start: 'Loading',
|
|
@@ -173,7 +173,7 @@ var Video = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
173
173
|
var nextCaptions = [];
|
|
174
174
|
var set = false;
|
|
175
175
|
// iterate through all of the tracks provided
|
|
176
|
-
var _loop = function _loop(
|
|
176
|
+
var _loop = function _loop() {
|
|
177
177
|
var track = textTracks[i];
|
|
178
178
|
var active = track.mode === 'showing';
|
|
179
179
|
var getActiveTrack = function getActiveTrack(currentVideoTime) {
|
|
@@ -218,7 +218,7 @@ var Video = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
for (var i = 0; i < textTracks.length; i += 1) {
|
|
221
|
-
_loop(
|
|
221
|
+
_loop();
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}, [activeTrack, announce, announceAudioDescription, captions, height, videoRef, width]);
|
|
@@ -258,9 +258,7 @@ var Video = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
258
258
|
}, [videoRef]);
|
|
259
259
|
var showCaptions = useCallback(function (index) {
|
|
260
260
|
var textTracks = videoRef.current.textTracks;
|
|
261
|
-
for (var i = 0; i < textTracks.length; i += 1)
|
|
262
|
-
textTracks[i].mode = i === index ? 'showing' : 'hidden';
|
|
263
|
-
}
|
|
261
|
+
for (var i = 0; i < textTracks.length; i += 1) textTracks[i].mode = i === index ? 'showing' : 'hidden';
|
|
264
262
|
}, [videoRef]);
|
|
265
263
|
var fullscreen = useCallback(function () {
|
|
266
264
|
var video = videoRef.current;
|
|
@@ -404,9 +402,7 @@ var Video = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
404
402
|
return undefined;
|
|
405
403
|
}
|
|
406
404
|
if (item === 'captions' && typeof buttonProps[item] === 'object') {
|
|
407
|
-
for (var i = 0; i < buttonProps[item].length; i += 1)
|
|
408
|
-
controlsMenuItems.push(buttonProps[item][i]);
|
|
409
|
-
}
|
|
405
|
+
for (var i = 0; i < buttonProps[item].length; i += 1) controlsMenuItems.push(buttonProps[item][i]);
|
|
410
406
|
return undefined;
|
|
411
407
|
}
|
|
412
408
|
if (item === 'descriptions') {
|
|
@@ -112,9 +112,7 @@ var buildContinent = function buildContinent(_ref3) {
|
|
|
112
112
|
var dots = dotsProp.map(function (segment) {
|
|
113
113
|
var count = segment[2];
|
|
114
114
|
var spots = [];
|
|
115
|
-
for (var i = 0; i < count; i += 1)
|
|
116
|
-
spots.push('h0');
|
|
117
|
-
}
|
|
115
|
+
for (var i = 0; i < count; i += 1) spots.push('h0');
|
|
118
116
|
var dotCommands = spots.join(' m10,0 ');
|
|
119
117
|
var x = FACTOR * (origin[0] + segment[0] + 1);
|
|
120
118
|
var y = FACTOR * (origin[1] + segment[1] + 1);
|