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
|
@@ -28,7 +28,6 @@ var defaultAlign = {
|
|
|
28
28
|
top: 'top',
|
|
29
29
|
left: 'left'
|
|
30
30
|
};
|
|
31
|
-
var defaultPortalContext = [];
|
|
32
31
|
var DropContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
33
32
|
var a11yTitle = _ref.a11yTitle,
|
|
34
33
|
ariaLabel = _ref['aria-label'],
|
|
@@ -53,7 +52,7 @@ var DropContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
53
52
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
54
53
|
var containerTarget = (0, _react.useContext)(_ContainerTargetContext.ContainerTargetContext);
|
|
55
54
|
var theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _defaultProps.defaultProps.theme;
|
|
56
|
-
var portalContext = (0, _react.useContext)(_utils.PortalContext)
|
|
55
|
+
var portalContext = (0, _react.useContext)(_utils.PortalContext);
|
|
57
56
|
var portalId = (0, _react.useMemo)(function () {
|
|
58
57
|
return portalContext.length;
|
|
59
58
|
}, [portalContext]);
|
|
@@ -61,6 +60,29 @@ var DropContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
61
60
|
return [].concat(portalContext, [portalId]);
|
|
62
61
|
}, [portalContext, portalId]);
|
|
63
62
|
var dropRef = (0, _react.useRef)();
|
|
63
|
+
(0, _react.useEffect)(function () {
|
|
64
|
+
var onClickDocument = function onClickDocument(event) {
|
|
65
|
+
// determine which portal id the target is in, if any
|
|
66
|
+
var clickedPortalId = null;
|
|
67
|
+
var node = containerTarget === document.body ? event.target : event == null ? void 0 : event.composedPath()[0];
|
|
68
|
+
while (clickedPortalId === null && node !== document) {
|
|
69
|
+
var attr = node.getAttribute('data-g-portal-id');
|
|
70
|
+
if (attr !== null) clickedPortalId = parseInt(attr, 10);
|
|
71
|
+
node = node.parentNode;
|
|
72
|
+
}
|
|
73
|
+
if (clickedPortalId === null || portalContext.indexOf(clickedPortalId) !== -1) {
|
|
74
|
+
onClickOutside(event);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
if (onClickOutside) {
|
|
78
|
+
document.addEventListener('mousedown', onClickDocument);
|
|
79
|
+
}
|
|
80
|
+
return function () {
|
|
81
|
+
if (onClickOutside) {
|
|
82
|
+
document.removeEventListener('mousedown', onClickDocument);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}, [onClickOutside, containerTarget, portalContext]);
|
|
64
86
|
(0, _react.useEffect)(function () {
|
|
65
87
|
var notifyAlign = function notifyAlign() {
|
|
66
88
|
var styleCurrent = (ref || dropRef).current.style;
|
|
@@ -233,19 +255,6 @@ var DropContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
233
255
|
});
|
|
234
256
|
scrollParents = [];
|
|
235
257
|
};
|
|
236
|
-
var onClickDocument = function onClickDocument(event) {
|
|
237
|
-
// determine which portal id the target is in, if any
|
|
238
|
-
var clickedPortalId = null;
|
|
239
|
-
var node = containerTarget === document.body ? event.target : event == null ? void 0 : event.composedPath()[0];
|
|
240
|
-
while (clickedPortalId === null && node !== document) {
|
|
241
|
-
var attr = node.getAttribute('data-g-portal-id');
|
|
242
|
-
if (attr !== null) clickedPortalId = parseInt(attr, 10);
|
|
243
|
-
node = node.parentNode;
|
|
244
|
-
}
|
|
245
|
-
if (clickedPortalId === null || portalContext.indexOf(clickedPortalId) !== -1) {
|
|
246
|
-
onClickOutside(event);
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
258
|
var onResize = function onResize() {
|
|
250
259
|
removeScrollListeners();
|
|
251
260
|
addScrollListeners();
|
|
@@ -253,18 +262,12 @@ var DropContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
253
262
|
};
|
|
254
263
|
addScrollListeners();
|
|
255
264
|
window.addEventListener('resize', onResize);
|
|
256
|
-
if (onClickOutside) {
|
|
257
|
-
document.addEventListener('mousedown', onClickDocument);
|
|
258
|
-
}
|
|
259
265
|
place(false);
|
|
260
266
|
return function () {
|
|
261
267
|
removeScrollListeners();
|
|
262
268
|
window.removeEventListener('resize', onResize);
|
|
263
|
-
if (onClickOutside) {
|
|
264
|
-
document.removeEventListener('mousedown', onClickDocument);
|
|
265
|
-
}
|
|
266
269
|
};
|
|
267
|
-
}, [align, containerTarget, onAlign, dropTarget,
|
|
270
|
+
}, [align, containerTarget, onAlign, dropTarget, portalContext, portalId, ref, responsive, restrictFocus, stretch, theme.drop]);
|
|
268
271
|
(0, _react.useEffect)(function () {
|
|
269
272
|
if (restrictFocus) {
|
|
270
273
|
(ref || dropRef).current.focus();
|
|
@@ -53,6 +53,24 @@ var ValidateOnBlur = function ValidateOnBlur() {
|
|
|
53
53
|
name: "email",
|
|
54
54
|
"aria-label": "email",
|
|
55
55
|
type: "email"
|
|
56
|
+
})), /*#__PURE__*/_react["default"].createElement(_grommet.FormField, {
|
|
57
|
+
label: "Size",
|
|
58
|
+
name: "select-size",
|
|
59
|
+
htmlFor: "select-size__input",
|
|
60
|
+
required: true,
|
|
61
|
+
validate: function validate(val) {
|
|
62
|
+
if (val === 'small') {
|
|
63
|
+
return {
|
|
64
|
+
message: 'Only 10 left in stock!',
|
|
65
|
+
status: 'info'
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Select, {
|
|
71
|
+
name: "select-size",
|
|
72
|
+
id: "select-size",
|
|
73
|
+
options: ['small', 'medium', 'large']
|
|
56
74
|
})), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
57
75
|
direction: "row",
|
|
58
76
|
justify: "between",
|
|
@@ -5,7 +5,7 @@ exports.FormField = void 0;
|
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
7
7
|
var _defaultProps = require("../../default-props");
|
|
8
|
-
var
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
9
|
var _styles = require("../../utils/styles");
|
|
10
10
|
var _mixins = require("../../utils/mixins");
|
|
11
11
|
var _refs = require("../../utils/refs");
|
|
@@ -183,6 +183,7 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
183
183
|
var formFieldTheme = theme.formField;
|
|
184
184
|
var themeBorder = formFieldTheme.border;
|
|
185
185
|
var debounce = useDebounce();
|
|
186
|
+
var portalContext = (0, _react.useContext)(_utils.PortalContext);
|
|
186
187
|
|
|
187
188
|
// This is here for backwards compatibility. In case the child is a grommet
|
|
188
189
|
// input component, set plain and focusIndicator props, if they aren't
|
|
@@ -342,13 +343,22 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
342
343
|
}, outerProps, {
|
|
343
344
|
style: outerStyle,
|
|
344
345
|
onFocus: function onFocus(event) {
|
|
345
|
-
var
|
|
346
|
-
|
|
346
|
+
var _formFieldRef$current;
|
|
347
|
+
var root = (_formFieldRef$current = formFieldRef.current) == null ? void 0 : _formFieldRef$current.getRootNode();
|
|
348
|
+
if (root) {
|
|
349
|
+
setFocus((0, _utils.containsFocus)(formFieldRef.current) && (0, _utils.shouldKeepFocus)(root));
|
|
350
|
+
}
|
|
347
351
|
if (_onFocus) _onFocus(event);
|
|
348
352
|
},
|
|
349
353
|
onBlur: function onBlur(event) {
|
|
350
354
|
setFocus(false);
|
|
351
|
-
|
|
355
|
+
|
|
356
|
+
// if input has a drop and focus is within drop
|
|
357
|
+
// prevent onBlur validation from running until
|
|
358
|
+
// focus is no longer within the drop or input
|
|
359
|
+
if (contextOnBlur && !formFieldRef.current.contains(event.relatedTarget) && !(0, _utils.withinDropPortal)(event.relatedTarget, portalContext)) {
|
|
360
|
+
contextOnBlur(event);
|
|
361
|
+
}
|
|
352
362
|
if (_onBlur) _onBlur(event);
|
|
353
363
|
},
|
|
354
364
|
onChange: contextOnChange || onChange ? function (event) {
|
|
@@ -22,7 +22,6 @@ var HiddenAnchor = _styledComponents["default"].a.withConfig({
|
|
|
22
22
|
displayName: "LayerContainer__HiddenAnchor",
|
|
23
23
|
componentId: "sc-1srj14c-0"
|
|
24
24
|
})(["width:0;height:0;overflow:hidden;position:absolute;"]);
|
|
25
|
-
var defaultPortalContext = [];
|
|
26
25
|
var LayerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
27
26
|
var background = _ref.background,
|
|
28
27
|
children = _ref.children,
|
|
@@ -52,7 +51,7 @@ var LayerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
52
51
|
var anchorRef = (0, _react.useRef)();
|
|
53
52
|
var containerRef = (0, _react.useRef)();
|
|
54
53
|
var layerRef = (0, _react.useRef)();
|
|
55
|
-
var portalContext = (0, _react.useContext)(_utils.PortalContext)
|
|
54
|
+
var portalContext = (0, _react.useContext)(_utils.PortalContext);
|
|
56
55
|
var portalId = (0, _react.useMemo)(function () {
|
|
57
56
|
return portalContext.length;
|
|
58
57
|
}, [portalContext]);
|
|
@@ -4,5 +4,5 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.PortalContext = void 0;
|
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
7
|
-
var PortalContext = /*#__PURE__*/_react["default"].createContext(
|
|
7
|
+
var PortalContext = /*#__PURE__*/_react["default"].createContext([]);
|
|
8
8
|
exports.PortalContext = PortalContext;
|
|
@@ -6,14 +6,10 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
6
6
|
var _grommetIcons = require("grommet-icons");
|
|
7
7
|
var _grommet = require("grommet");
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
|
-
var suggestions = ['alpha', 'beta'];
|
|
10
9
|
var FormLayer = function FormLayer() {
|
|
11
10
|
var _React$useState = _react["default"].useState(false),
|
|
12
11
|
open = _React$useState[0],
|
|
13
12
|
setOpen = _React$useState[1];
|
|
14
|
-
var _React$useState2 = _react["default"].useState(''),
|
|
15
|
-
select = _React$useState2[0],
|
|
16
|
-
setSelect = _React$useState2[1];
|
|
17
13
|
var onOpen = function onOpen() {
|
|
18
14
|
return setOpen(true);
|
|
19
15
|
};
|
|
@@ -39,12 +35,19 @@ var FormLayer = function FormLayer() {
|
|
|
39
35
|
onClickOutside: onClose,
|
|
40
36
|
onEsc: onClose
|
|
41
37
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
42
|
-
as: "form",
|
|
43
38
|
fill: "vertical",
|
|
44
39
|
overflow: "auto",
|
|
45
40
|
width: "medium",
|
|
46
|
-
pad: "medium"
|
|
47
|
-
|
|
41
|
+
pad: "medium"
|
|
42
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Form, {
|
|
43
|
+
validate: "blur",
|
|
44
|
+
onReset: function onReset(event) {
|
|
45
|
+
return console.log(event);
|
|
46
|
+
},
|
|
47
|
+
onSubmit: function onSubmit(_ref) {
|
|
48
|
+
var value = _ref.value;
|
|
49
|
+
return console.log('Submit', value);
|
|
50
|
+
}
|
|
48
51
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
49
52
|
flex: false,
|
|
50
53
|
direction: "row",
|
|
@@ -55,29 +58,52 @@ var FormLayer = function FormLayer() {
|
|
|
55
58
|
}, "Add"), /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
|
|
56
59
|
icon: /*#__PURE__*/_react["default"].createElement(_grommetIcons.Close, null),
|
|
57
60
|
onClick: onClose
|
|
58
|
-
})), /*#__PURE__*/_react["default"].createElement(_grommet.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
})), /*#__PURE__*/_react["default"].createElement(_grommet.FormField, {
|
|
62
|
+
label: "Name",
|
|
63
|
+
"aria-label": "name",
|
|
64
|
+
name: "name",
|
|
65
|
+
required: true,
|
|
66
|
+
validate: [{
|
|
67
|
+
regexp: /^[a-z]/i
|
|
68
|
+
}, function (name) {
|
|
69
|
+
if (name && name.length === 1) return 'must be >1 character';
|
|
70
|
+
return undefined;
|
|
71
|
+
}, function (name) {
|
|
72
|
+
if (name === 'good') return {
|
|
73
|
+
message: /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
74
|
+
align: "end"
|
|
75
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommetIcons.StatusGood, null)),
|
|
76
|
+
status: 'info'
|
|
77
|
+
};
|
|
78
|
+
return undefined;
|
|
79
|
+
}]
|
|
80
|
+
}), /*#__PURE__*/_react["default"].createElement(_grommet.FormField, {
|
|
81
|
+
label: "Email",
|
|
82
|
+
name: "email",
|
|
83
|
+
required: true
|
|
66
84
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
|
|
67
|
-
|
|
85
|
+
name: "email",
|
|
86
|
+
"aria-label": "email",
|
|
87
|
+
type: "email"
|
|
68
88
|
})), /*#__PURE__*/_react["default"].createElement(_grommet.FormField, {
|
|
69
|
-
label: "
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
label: "Size",
|
|
90
|
+
name: "select-size",
|
|
91
|
+
htmlFor: "select-size__input",
|
|
92
|
+
required: true,
|
|
93
|
+
validate: function validate(val) {
|
|
94
|
+
if (val === 'small') {
|
|
95
|
+
return {
|
|
96
|
+
message: 'Only 10 left in stock!',
|
|
97
|
+
status: 'info'
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
77
101
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Select, {
|
|
103
|
+
name: "select-size",
|
|
104
|
+
id: "select-size",
|
|
105
|
+
options: ['small', 'medium', 'large']
|
|
106
|
+
})), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
81
107
|
flex: false,
|
|
82
108
|
as: "footer",
|
|
83
109
|
align: "start"
|
|
@@ -86,7 +112,7 @@ var FormLayer = function FormLayer() {
|
|
|
86
112
|
label: "Submit",
|
|
87
113
|
onClick: onClose,
|
|
88
114
|
primary: true
|
|
89
|
-
})))))
|
|
115
|
+
}))))))
|
|
90
116
|
// </Grommet>
|
|
91
117
|
);
|
|
92
118
|
};
|
package/components/List/List.js
CHANGED
|
@@ -83,11 +83,7 @@ var getValue = function getValue(item, index, key) {
|
|
|
83
83
|
var reorder = function reorder(array, pinnedArray, source, target) {
|
|
84
84
|
var result = array.slice(0);
|
|
85
85
|
var tmp = result[source];
|
|
86
|
-
if (source < target) for (var i = source; i < target; i += 1)
|
|
87
|
-
result[i] = result[i + 1];
|
|
88
|
-
} else for (var _i = source; _i > target; _i -= 1) {
|
|
89
|
-
result[_i] = result[_i - 1];
|
|
90
|
-
}
|
|
86
|
+
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];
|
|
91
87
|
result[target] = tmp;
|
|
92
88
|
|
|
93
89
|
// insert pinned items into their proper index within the orderable
|
|
@@ -400,9 +396,6 @@ var List = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
400
396
|
adjustedEvent.item = item;
|
|
401
397
|
adjustedEvent.index = index;
|
|
402
398
|
onClickItem(adjustedEvent);
|
|
403
|
-
// put focus on the List container to meet WCAG
|
|
404
|
-
// accessibility guidelines that focus remains on `ul`
|
|
405
|
-
listRef.current.focus();
|
|
406
399
|
sendAnalytics({
|
|
407
400
|
type: 'listItemClick',
|
|
408
401
|
element: listRef.current,
|
|
@@ -5,6 +5,7 @@ exports.Pagination = void 0;
|
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
7
7
|
var _defaultProps = require("../../default-props");
|
|
8
|
+
var _DataContext = require("../../contexts/DataContext");
|
|
8
9
|
var _Box = require("../Box");
|
|
9
10
|
var _Nav = require("../Nav");
|
|
10
11
|
var _PageControl = require("./PageControl");
|
|
@@ -28,6 +29,7 @@ var getPageIndices = function getPageIndices(begin, end) {
|
|
|
28
29
|
return indices;
|
|
29
30
|
};
|
|
30
31
|
var Pagination = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
32
|
+
var _ref2;
|
|
31
33
|
var a11yTitle = _ref.a11yTitle,
|
|
32
34
|
ariaLabel = _ref['aria-label'],
|
|
33
35
|
numberItems = _ref.numberItems,
|
|
@@ -38,19 +40,25 @@ var Pagination = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
38
40
|
onChange = _ref.onChange,
|
|
39
41
|
pageProp = _ref.page,
|
|
40
42
|
size = _ref.size,
|
|
41
|
-
|
|
42
|
-
step = _ref$step === void 0 ? 10 : _ref$step,
|
|
43
|
+
stepProp = _ref.step,
|
|
43
44
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
44
45
|
var theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _defaultProps.defaultProps.theme;
|
|
46
|
+
var _useContext = (0, _react.useContext)(_DataContext.DataContext),
|
|
47
|
+
onView = _useContext.onView,
|
|
48
|
+
filteredTotal = _useContext.filteredTotal,
|
|
49
|
+
view = _useContext.view;
|
|
50
|
+
var step = stepProp || (view == null ? void 0 : view.step) || 10;
|
|
51
|
+
var total = (_ref2 = numberItems != null ? numberItems : filteredTotal) != null ? _ref2 : 0;
|
|
52
|
+
var page = pageProp || (view == null ? void 0 : view.page) || 1;
|
|
45
53
|
|
|
46
54
|
/* Calculate total number pages */
|
|
47
|
-
var totalPages = Math.ceil(
|
|
48
|
-
var _useState = (0, _react.useState)(Math.min(
|
|
55
|
+
var totalPages = Math.ceil(total / step);
|
|
56
|
+
var _useState = (0, _react.useState)(Math.min(page, totalPages) || 1),
|
|
49
57
|
activePage = _useState[0],
|
|
50
58
|
setActivePage = _useState[1];
|
|
51
59
|
(0, _react.useEffect)(function () {
|
|
52
|
-
setActivePage(
|
|
53
|
-
}, [
|
|
60
|
+
return setActivePage(page);
|
|
61
|
+
}, [page]);
|
|
54
62
|
|
|
55
63
|
/* Define page indices to display */
|
|
56
64
|
var beginPages = getPageIndices(1, Math.min(numberEdgePages, totalPages));
|
|
@@ -84,6 +92,9 @@ var Pagination = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
84
92
|
};
|
|
85
93
|
var handleClick = function handleClick(event, nextPage) {
|
|
86
94
|
setActivePage(nextPage);
|
|
95
|
+
if (onView) onView(_extends({}, view, {
|
|
96
|
+
page: nextPage
|
|
97
|
+
}));
|
|
87
98
|
if (onChange) {
|
|
88
99
|
event.persist();
|
|
89
100
|
var adjustedEvent = event;
|
|
@@ -106,7 +117,7 @@ var Pagination = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
106
117
|
next: {
|
|
107
118
|
// https://a11y-style-guide.com/style-guide/section-navigation.html#kssref-navigation-pagination
|
|
108
119
|
'aria-disabled': activePage === totalPages ? 'true' : undefined,
|
|
109
|
-
disabled: activePage === totalPages || !
|
|
120
|
+
disabled: activePage === totalPages || !total,
|
|
110
121
|
icon: /*#__PURE__*/_react["default"].createElement(NextIcon, {
|
|
111
122
|
color: iconColor
|
|
112
123
|
}),
|
|
@@ -118,7 +129,7 @@ var Pagination = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
118
129
|
},
|
|
119
130
|
previous: {
|
|
120
131
|
'aria-disabled': activePage === 1 ? 'true' : undefined,
|
|
121
|
-
disabled: activePage === 1 || !
|
|
132
|
+
disabled: activePage === 1 || !total,
|
|
122
133
|
icon: /*#__PURE__*/_react["default"].createElement(PreviousIcon, {
|
|
123
134
|
color: iconColor
|
|
124
135
|
}),
|
|
@@ -8,7 +8,7 @@ var applyKey = function applyKey(option, key) {
|
|
|
8
8
|
if (option === undefined || option === null) return undefined;
|
|
9
9
|
if (typeof key === 'object') return applyKey(option, key.key);
|
|
10
10
|
if (typeof key === 'function') return key(option);
|
|
11
|
-
if (key !== undefined) return option[key];
|
|
11
|
+
if (key !== undefined && typeof option === 'object') return option[key];
|
|
12
12
|
if (typeof option === 'object' && Object.keys(option)) return option[Object.keys(option)[0]];
|
|
13
13
|
return option;
|
|
14
14
|
};
|
|
@@ -11,9 +11,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
13
|
var labels = [];
|
|
14
|
-
for (var i = 0; i < 10; i += 1)
|
|
15
|
-
labels.push("Item " + i);
|
|
16
|
-
}
|
|
14
|
+
for (var i = 0; i < 10; i += 1) labels.push("Item " + i);
|
|
17
15
|
var skeleton = {
|
|
18
16
|
message: {
|
|
19
17
|
start: 'Loading',
|
|
@@ -178,7 +178,7 @@ var Video = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
178
178
|
var nextCaptions = [];
|
|
179
179
|
var set = false;
|
|
180
180
|
// iterate through all of the tracks provided
|
|
181
|
-
var _loop = function _loop(
|
|
181
|
+
var _loop = function _loop() {
|
|
182
182
|
var track = textTracks[i];
|
|
183
183
|
var active = track.mode === 'showing';
|
|
184
184
|
var getActiveTrack = function getActiveTrack(currentVideoTime) {
|
|
@@ -223,7 +223,7 @@ var Video = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
for (var i = 0; i < textTracks.length; i += 1) {
|
|
226
|
-
_loop(
|
|
226
|
+
_loop();
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
}, [activeTrack, announce, announceAudioDescription, captions, height, videoRef, width]);
|
|
@@ -263,9 +263,7 @@ var Video = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
263
263
|
}, [videoRef]);
|
|
264
264
|
var showCaptions = (0, _react.useCallback)(function (index) {
|
|
265
265
|
var textTracks = videoRef.current.textTracks;
|
|
266
|
-
for (var i = 0; i < textTracks.length; i += 1)
|
|
267
|
-
textTracks[i].mode = i === index ? 'showing' : 'hidden';
|
|
268
|
-
}
|
|
266
|
+
for (var i = 0; i < textTracks.length; i += 1) textTracks[i].mode = i === index ? 'showing' : 'hidden';
|
|
269
267
|
}, [videoRef]);
|
|
270
268
|
var fullscreen = (0, _react.useCallback)(function () {
|
|
271
269
|
var video = videoRef.current;
|
|
@@ -409,9 +407,7 @@ var Video = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
409
407
|
return undefined;
|
|
410
408
|
}
|
|
411
409
|
if (item === 'captions' && typeof buttonProps[item] === 'object') {
|
|
412
|
-
for (var i = 0; i < buttonProps[item].length; i += 1)
|
|
413
|
-
controlsMenuItems.push(buttonProps[item][i]);
|
|
414
|
-
}
|
|
410
|
+
for (var i = 0; i < buttonProps[item].length; i += 1) controlsMenuItems.push(buttonProps[item][i]);
|
|
415
411
|
return undefined;
|
|
416
412
|
}
|
|
417
413
|
if (item === 'descriptions') {
|
|
@@ -117,9 +117,7 @@ var buildContinent = function buildContinent(_ref3) {
|
|
|
117
117
|
var dots = dotsProp.map(function (segment) {
|
|
118
118
|
var count = segment[2];
|
|
119
119
|
var spots = [];
|
|
120
|
-
for (var i = 0; i < count; i += 1)
|
|
121
|
-
spots.push('h0');
|
|
122
|
-
}
|
|
120
|
+
for (var i = 0; i < count; i += 1) spots.push('h0');
|
|
123
121
|
var dotCommands = spots.join(' m10,0 ');
|
|
124
122
|
var x = FACTOR * (origin[0] + segment[0] + 1);
|
|
125
123
|
var y = FACTOR * (origin[1] + segment[1] + 1);
|
package/components/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export * from './DataSearch';
|
|
|
24
24
|
export * from './DataSort';
|
|
25
25
|
export * from './DataSummary';
|
|
26
26
|
export * from './DataTable';
|
|
27
|
+
export * from './DataTableColumns';
|
|
28
|
+
export * from './DataView';
|
|
27
29
|
export * from './DateInput';
|
|
28
30
|
export * from './Diagram';
|
|
29
31
|
export * from './Distribution';
|
package/components/index.js
CHANGED
|
@@ -133,12 +133,6 @@ Object.keys(_DataFilters).forEach(function (key) {
|
|
|
133
133
|
if (key in exports && exports[key] === _DataFilters[key]) return;
|
|
134
134
|
exports[key] = _DataFilters[key];
|
|
135
135
|
});
|
|
136
|
-
var _DataTable = require("./DataTable");
|
|
137
|
-
Object.keys(_DataTable).forEach(function (key) {
|
|
138
|
-
if (key === "default" || key === "__esModule") return;
|
|
139
|
-
if (key in exports && exports[key] === _DataTable[key]) return;
|
|
140
|
-
exports[key] = _DataTable[key];
|
|
141
|
-
});
|
|
142
136
|
var _DataSearch = require("./DataSearch");
|
|
143
137
|
Object.keys(_DataSearch).forEach(function (key) {
|
|
144
138
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -157,6 +151,24 @@ Object.keys(_DataSummary).forEach(function (key) {
|
|
|
157
151
|
if (key in exports && exports[key] === _DataSummary[key]) return;
|
|
158
152
|
exports[key] = _DataSummary[key];
|
|
159
153
|
});
|
|
154
|
+
var _DataTable = require("./DataTable");
|
|
155
|
+
Object.keys(_DataTable).forEach(function (key) {
|
|
156
|
+
if (key === "default" || key === "__esModule") return;
|
|
157
|
+
if (key in exports && exports[key] === _DataTable[key]) return;
|
|
158
|
+
exports[key] = _DataTable[key];
|
|
159
|
+
});
|
|
160
|
+
var _DataTableColumns = require("./DataTableColumns");
|
|
161
|
+
Object.keys(_DataTableColumns).forEach(function (key) {
|
|
162
|
+
if (key === "default" || key === "__esModule") return;
|
|
163
|
+
if (key in exports && exports[key] === _DataTableColumns[key]) return;
|
|
164
|
+
exports[key] = _DataTableColumns[key];
|
|
165
|
+
});
|
|
166
|
+
var _DataView = require("./DataView");
|
|
167
|
+
Object.keys(_DataView).forEach(function (key) {
|
|
168
|
+
if (key === "default" || key === "__esModule") return;
|
|
169
|
+
if (key in exports && exports[key] === _DataView[key]) return;
|
|
170
|
+
exports[key] = _DataView[key];
|
|
171
|
+
});
|
|
160
172
|
var _DateInput = require("./DateInput");
|
|
161
173
|
Object.keys(_DateInput).forEach(function (key) {
|
|
162
174
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -54,9 +54,7 @@ var getIconColor = function getIconColor(paths, theme, colorProp, kind) {
|
|
|
54
54
|
// for example: 'active.primary'
|
|
55
55
|
if (paths[index]) {
|
|
56
56
|
var parts = paths[index].split('.');
|
|
57
|
-
while (obj && parts.length)
|
|
58
|
-
obj = obj[parts.shift()];
|
|
59
|
-
}
|
|
57
|
+
while (obj && parts.length) obj = obj[parts.shift()];
|
|
60
58
|
}
|
|
61
59
|
if (obj) {
|
|
62
60
|
var _obj, _obj$icon, _obj$icon$props;
|
|
@@ -73,9 +71,7 @@ var getIconColor = function getIconColor(paths, theme, colorProp, kind) {
|
|
|
73
71
|
else if (paths[index + 1]) {
|
|
74
72
|
var _obj2, _obj2$icon, _obj2$icon$props;
|
|
75
73
|
var _parts = paths[index + 1].split('.');
|
|
76
|
-
while (baseObj && _parts.length)
|
|
77
|
-
obj = baseObj[_parts.shift()];
|
|
78
|
-
}
|
|
74
|
+
while (baseObj && _parts.length) obj = baseObj[_parts.shift()];
|
|
79
75
|
if ((_obj2 = obj) != null && (_obj2$icon = _obj2.icon) != null && (_obj2$icon$props = _obj2$icon.props) != null && _obj2$icon$props.color) color = obj.icon.props.color;
|
|
80
76
|
}
|
|
81
77
|
// use passed in color for text if the theme doesn't have
|
|
@@ -106,9 +102,7 @@ var getKindIcon = function getKindIcon(paths, theme, kind) {
|
|
|
106
102
|
// for example: 'active.primary'
|
|
107
103
|
if (paths[index]) {
|
|
108
104
|
var parts = paths[index].split('.');
|
|
109
|
-
while (obj && parts.length)
|
|
110
|
-
obj = obj[parts.shift()];
|
|
111
|
-
}
|
|
105
|
+
while (obj && parts.length) obj = obj[parts.shift()];
|
|
112
106
|
}
|
|
113
107
|
if ((_obj3 = obj) != null && _obj3.icon) result = obj.icon;
|
|
114
108
|
index -= 1;
|
|
@@ -125,9 +119,7 @@ var getPropertyColor = function getPropertyColor(property, paths, theme, kind, p
|
|
|
125
119
|
// index 0 is default state
|
|
126
120
|
if (paths[0]) {
|
|
127
121
|
var parts = paths[0].split('.');
|
|
128
|
-
while (obj && parts.length)
|
|
129
|
-
obj = obj[parts.shift()];
|
|
130
|
-
}
|
|
122
|
+
while (obj && parts.length) obj = obj[parts.shift()];
|
|
131
123
|
}
|
|
132
124
|
if (obj) {
|
|
133
125
|
result = obj[property] || obj[property] && obj[property].color;
|
|
@@ -55,9 +55,7 @@ var getPath = function getPath(theme, path) {
|
|
|
55
55
|
if (path) {
|
|
56
56
|
obj = theme;
|
|
57
57
|
var parts = path.split('.');
|
|
58
|
-
while (obj && parts.length)
|
|
59
|
-
obj = obj[parts.shift()];
|
|
60
|
-
}
|
|
58
|
+
while (obj && parts.length) obj = obj[parts.shift()];
|
|
61
59
|
}
|
|
62
60
|
return obj;
|
|
63
61
|
};
|