grommet 2.23.0 → 2.24.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.
Files changed (87) hide show
  1. package/components/Anchor/Anchor.js +2 -3
  2. package/components/CheckBoxGroup/index.d.ts +1 -3
  3. package/components/DataTable/stories/SpaceX.js +6 -4
  4. package/components/DataTable/stories/SpaceXUngrouped.js +4 -2
  5. package/components/Drop/DropContainer.js +6 -2
  6. package/components/FileInput/index.d.ts +6 -1
  7. package/components/Form/stories/HelpAndError.js +1 -1
  8. package/components/Grid/index.d.ts +6 -2
  9. package/components/Layer/Layer.js +1 -1
  10. package/components/Layer/LayerContainer.js +6 -2
  11. package/components/List/List.js +103 -40
  12. package/components/List/index.d.ts +3 -1
  13. package/components/List/propTypes.js +3 -1
  14. package/components/List/stories/Disabled.js +33 -0
  15. package/components/Notification/Notification.js +17 -8
  16. package/components/Notification/index.d.ts +1 -0
  17. package/components/Notification/propTypes.js +1 -0
  18. package/components/PageHeader/PageHeader.js +80 -0
  19. package/components/PageHeader/index.d.ts +26 -0
  20. package/components/PageHeader/index.js +8 -0
  21. package/components/PageHeader/propTypes.js +30 -0
  22. package/components/PageHeader/stories/Custom.js +47 -0
  23. package/components/PageHeader/stories/MultipleActions.js +79 -0
  24. package/components/PageHeader/stories/Responsive.js +37 -0
  25. package/components/PageHeader/stories/Simple.js +36 -0
  26. package/components/RadioButtonGroup/index.d.ts +2 -1
  27. package/components/Select/Select.js +0 -2
  28. package/components/Select/SelectContainer.js +9 -0
  29. package/components/Table/StyledTable.js +1 -1
  30. package/components/TextInput/TextInput.js +32 -3
  31. package/components/TextInput/stories/DefaultSuggestion.js +1 -0
  32. package/components/TextInput/stories/Suggestions.js +1 -0
  33. package/components/Tip/Tip.js +18 -6
  34. package/components/Video/Video.js +100 -46
  35. package/components/Video/index.d.ts +1 -0
  36. package/components/Video/propTypes.js +1 -1
  37. package/components/Video/stories/typescript/ControlsBelow.tsx +6 -2
  38. package/components/index.d.ts +1 -0
  39. package/components/index.js +8 -0
  40. package/es6/components/Anchor/Anchor.js +2 -3
  41. package/es6/components/CheckBoxGroup/index.d.ts +1 -3
  42. package/es6/components/DataTable/stories/SpaceX.js +6 -4
  43. package/es6/components/DataTable/stories/SpaceXUngrouped.js +4 -2
  44. package/es6/components/Drop/DropContainer.js +4 -2
  45. package/es6/components/FileInput/index.d.ts +6 -1
  46. package/es6/components/Form/stories/HelpAndError.js +1 -1
  47. package/es6/components/Grid/index.d.ts +6 -2
  48. package/es6/components/Layer/Layer.js +1 -1
  49. package/es6/components/Layer/LayerContainer.js +4 -2
  50. package/es6/components/List/List.js +104 -41
  51. package/es6/components/List/index.d.ts +3 -1
  52. package/es6/components/List/propTypes.js +3 -1
  53. package/es6/components/List/stories/Disabled.js +20 -0
  54. package/es6/components/Notification/Notification.js +17 -8
  55. package/es6/components/Notification/index.d.ts +1 -0
  56. package/es6/components/Notification/propTypes.js +1 -0
  57. package/es6/components/PageHeader/PageHeader.js +63 -0
  58. package/es6/components/PageHeader/index.d.ts +26 -0
  59. package/es6/components/PageHeader/index.js +1 -0
  60. package/es6/components/PageHeader/propTypes.js +19 -0
  61. package/es6/components/PageHeader/stories/Custom.js +32 -0
  62. package/es6/components/PageHeader/stories/MultipleActions.js +63 -0
  63. package/es6/components/PageHeader/stories/Responsive.js +25 -0
  64. package/es6/components/PageHeader/stories/Simple.js +24 -0
  65. package/es6/components/RadioButtonGroup/index.d.ts +2 -1
  66. package/es6/components/Select/Select.js +0 -2
  67. package/es6/components/Select/SelectContainer.js +9 -0
  68. package/es6/components/Table/StyledTable.js +1 -1
  69. package/es6/components/TextInput/TextInput.js +32 -3
  70. package/es6/components/TextInput/stories/DefaultSuggestion.js +1 -0
  71. package/es6/components/TextInput/stories/Suggestions.js +1 -0
  72. package/es6/components/Tip/Tip.js +18 -6
  73. package/es6/components/Video/Video.js +99 -46
  74. package/es6/components/Video/index.d.ts +1 -0
  75. package/es6/components/Video/propTypes.js +1 -1
  76. package/es6/components/Video/stories/typescript/ControlsBelow.tsx +6 -2
  77. package/es6/components/index.d.ts +1 -0
  78. package/es6/components/index.js +1 -0
  79. package/es6/languages/default.json +4 -1
  80. package/es6/themes/base.d.ts +47 -7
  81. package/es6/themes/base.js +72 -1
  82. package/grommet.min.js +1 -1
  83. package/grommet.min.js.map +1 -1
  84. package/languages/default.json +4 -1
  85. package/package.json +30 -26
  86. package/themes/base.d.ts +47 -7
  87. package/themes/base.js +73 -1
@@ -1,4 +1,4 @@
1
- var _excluded = ["a11yTitle", "aria-label", "action", "as", "background", "border", "children", "data", "defaultItemProps", "focus", "itemKey", "itemProps", "onOrder", "pad", "paginate", "primaryKey", "secondaryKey", "show", "step", "onClickItem", "onMore"];
1
+ var _excluded = ["a11yTitle", "aria-label", "action", "as", "background", "border", "children", "data", "defaultItemProps", "disabled", "focus", "itemKey", "itemProps", "onActive", "onClickItem", "onKeyDown", "onMore", "onOrder", "pad", "paginate", "primaryKey", "secondaryKey", "show", "step"];
2
2
 
3
3
  function _extends() { _extends = Object.assign || 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); }
4
4
 
@@ -12,7 +12,7 @@ import { InfiniteScroll } from '../InfiniteScroll';
12
12
  import { Keyboard } from '../Keyboard';
13
13
  import { Pagination } from '../Pagination';
14
14
  import { Text } from '../Text';
15
- import { focusStyle, genericStyles, normalizeShow, unfocusStyle, useForwardedRef, usePagination } from '../../utils';
15
+ import { focusStyle, genericStyles, normalizeColor, normalizeShow, unfocusStyle, useForwardedRef, usePagination } from '../../utils';
16
16
  import { ListPropTypes } from './propTypes';
17
17
  var StyledList = styled.ul.withConfig({
18
18
  displayName: "List__StyledList",
@@ -35,14 +35,32 @@ var StyledList = styled.ul.withConfig({
35
35
  var StyledItem = styled(Box).withConfig({
36
36
  displayName: "List__StyledItem",
37
37
  componentId: "sc-130gdqg-1"
38
- })(["", " ", " &:focus{", "}", ""], function (props) {
39
- return props.onClick && "cursor: pointer;";
38
+ })(["", " ", " &:focus{", "}", " &:hover{", "}", ""], function (props) {
39
+ return props.onClick && !props.isDisabled && "cursor: pointer;";
40
40
  }, function (props) {
41
- return props.draggable && "cursor: move;";
41
+ return props.draggable && !props.isDisabled && "cursor: move;";
42
42
  }, unfocusStyle({
43
43
  forceOutline: true,
44
44
  skipSvgChildren: true
45
45
  }), function (props) {
46
+ var _props$theme$list, _props$theme$list$ite;
47
+
48
+ var disabledStyle;
49
+
50
+ if (props.isDisabled && (_props$theme$list = props.theme.list) != null && (_props$theme$list$ite = _props$theme$list.item) != null && _props$theme$list$ite.disabled) {
51
+ var _props$theme$list$ite2 = props.theme.list.item.disabled,
52
+ color = _props$theme$list$ite2.color,
53
+ cursor = _props$theme$list$ite2.cursor;
54
+ disabledStyle = {
55
+ color: normalizeColor(color, props.theme),
56
+ cursor: cursor
57
+ };
58
+ }
59
+
60
+ return disabledStyle;
61
+ }, function (props) {
62
+ return props.isDisabled && "background-color: unset;";
63
+ }, function (props) {
46
64
  return props.theme.list && props.theme.list.item && props.theme.list.item.extend;
47
65
  }); // when paginated, this wraps the data table and pagination component
48
66
 
@@ -116,9 +134,14 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
116
134
  children = _ref.children,
117
135
  data = _ref.data,
118
136
  defaultItemProps = _ref.defaultItemProps,
137
+ disabledItems = _ref.disabled,
119
138
  focus = _ref.focus,
120
139
  itemKey = _ref.itemKey,
121
140
  itemProps = _ref.itemProps,
141
+ onActive = _ref.onActive,
142
+ onClickItem = _ref.onClickItem,
143
+ onKeyDown = _ref.onKeyDown,
144
+ onMore = _ref.onMore,
122
145
  onOrder = _ref.onOrder,
123
146
  pad = _ref.pad,
124
147
  paginate = _ref.paginate,
@@ -127,8 +150,6 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
127
150
  showProp = _ref.show,
128
151
  _ref$step = _ref.step,
129
152
  step = _ref$step === void 0 ? paginate ? 50 : undefined : _ref$step,
130
- onClickItem = _ref.onClickItem,
131
- onMore = _ref.onMore,
132
153
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
133
154
 
134
155
  var listRef = useForwardedRef(ref);
@@ -149,6 +170,13 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
149
170
  lastActive = _useState2[0],
150
171
  setLastActive = _useState2[1];
151
172
 
173
+ var updateActive = function updateActive(nextActive) {
174
+ setActive(nextActive); // we occasionally call updateActive with undefined when it already is so,
175
+ // no need to call onActive in that case
176
+
177
+ if (onActive && onClickItem && nextActive !== active) onActive(nextActive);
178
+ };
179
+
152
180
  var _useState3 = useState(),
153
181
  itemFocus = _useState3[0],
154
182
  setItemFocus = _useState3[1];
@@ -205,12 +233,14 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
205
233
 
206
234
  if (active % 2) {
207
235
  onOrder(reorder(data, index, index + 1));
208
- setActive(Math.min(active + 2, data.length * 2 - 2));
236
+ updateActive(Math.min(active + 2, data.length * 2 - 2));
209
237
  } else {
210
238
  onOrder(reorder(data, index, index - 1));
211
- setActive(Math.max(active - 2, 1));
239
+ updateActive(Math.max(active - 2, 1));
212
240
  }
213
- } else {
241
+ } else if (disabledItems != null && disabledItems.includes(typeof itemKey === 'function' ? itemKey(data[active]) : data[active])) {
242
+ event.preventDefault();
243
+ } else if (onClickItem) {
214
244
  event.persist();
215
245
  var adjustedEvent = event;
216
246
  adjustedEvent.item = data[active];
@@ -220,13 +250,14 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
220
250
  } : undefined,
221
251
  onUp: (onClickItem || onOrder) && active ? function () {
222
252
  var min = onOrder ? 1 : 0;
223
- setActive(Math.max(active - 1, min));
253
+ updateActive(Math.max(active - 1, min));
224
254
  } : undefined,
225
255
  onDown: (onClickItem || onOrder) && data && data.length ? function () {
226
256
  var min = onOrder ? 1 : 0;
227
257
  var max = onOrder ? data.length * 2 - 2 : data.length - 1;
228
- setActive(active >= min ? Math.min(active + 1, max) : min);
229
- } : undefined
258
+ updateActive(active >= min ? Math.min(active + 1, max) : min);
259
+ } : undefined,
260
+ onKeyDown: onKeyDown
230
261
  }, /*#__PURE__*/React.createElement(StyledList, _extends({
231
262
  "aria-label": ariaLabel || a11yTitle,
232
263
  ref: listRef,
@@ -238,12 +269,12 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
238
269
  // Checks for active variable to stop bug where activeStyle
239
270
  // gets applied to lastActive instead of the item the user
240
271
  // is currently clicking on
241
- !active && active !== 0 ? setActive(lastActive) : setActive(active)
272
+ !active && active !== 0 ? updateActive(lastActive) : updateActive(active)
242
273
  );
243
274
  },
244
275
  onBlur: function onBlur() {
245
276
  setLastActive(active);
246
- setActive(undefined);
277
+ updateActive(undefined);
247
278
  }
248
279
  }, ariaProps, rest), /*#__PURE__*/React.createElement(InfiniteScroll, {
249
280
  items: !paginate ? orderingData || data : items,
@@ -308,6 +339,16 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
308
339
  }
309
340
 
310
341
  var key = itemKey ? itemId : getKey(item, index, itemId);
342
+ var isDisabled;
343
+
344
+ if (disabledItems) {
345
+ if (typeof item === 'object' && !itemKey) {
346
+ console.error( // eslint-disable-next-line max-len
347
+ "Warning: Missing prop itemKey. Prop disabled requires itemKey to be specified when data is of type 'object'.");
348
+ }
349
+
350
+ isDisabled = disabledItems == null ? void 0 : disabledItems.includes(key);
351
+ }
311
352
 
312
353
  if (action) {
313
354
  content = [/*#__PURE__*/React.createElement(Box, {
@@ -344,28 +385,35 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
344
385
  tabIndex: -1,
345
386
  active: active === index,
346
387
  onClick: function onClick(event) {
347
- // extract from React's synthetic event pool
348
- event.persist();
349
- var adjustedEvent = event;
350
- adjustedEvent.item = item;
351
- adjustedEvent.index = index;
352
- onClickItem(adjustedEvent); // put focus on the List container to meet WCAG
353
- // accessibility guidelines that focus remains on `ul`
354
-
355
- listRef.current.focus();
388
+ // Only prevent event when disabled. We still want screen
389
+ // readers to be aware that an option exists, but is in a
390
+ // disabled state.
391
+ if (isDisabled) {
392
+ event.preventDefault();
393
+ } else {
394
+ // extract from React's synthetic event pool
395
+ event.persist();
396
+ var adjustedEvent = event;
397
+ adjustedEvent.item = item;
398
+ adjustedEvent.index = index;
399
+ onClickItem(adjustedEvent); // put focus on the List container to meet WCAG
400
+ // accessibility guidelines that focus remains on `ul`
401
+
402
+ listRef.current.focus();
403
+ }
356
404
  },
357
405
  onMouseOver: function onMouseOver() {
358
- return setActive(index);
406
+ return updateActive(index);
359
407
  },
360
408
  onMouseOut: function onMouseOut() {
361
- return setActive(undefined);
409
+ return updateActive(undefined);
362
410
  },
363
411
  onFocus: function onFocus() {
364
- setActive(index);
412
+ updateActive(index);
365
413
  setItemFocus(true);
366
414
  },
367
415
  onBlur: function onBlur() {
368
- setActive(undefined);
416
+ updateActive(undefined);
369
417
  setItemFocus(false);
370
418
  }
371
419
  };
@@ -384,7 +432,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
384
432
 
385
433
  event.dataTransfer.effectAllowed = 'move';
386
434
  setDragging(index);
387
- setActive(undefined);
435
+ updateActive(undefined);
388
436
  },
389
437
  onDragEnd: function onDragEnd() {
390
438
  setDragging(undefined);
@@ -429,17 +477,17 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
429
477
  },
430
478
  tabIndex: -1,
431
479
  onMouseOver: function onMouseOver() {
432
- return setActive(index * 2);
480
+ return updateActive(index * 2);
433
481
  },
434
482
  onMouseOut: function onMouseOut() {
435
- return setActive(undefined);
483
+ return updateActive(undefined);
436
484
  },
437
485
  onFocus: function onFocus() {
438
- setActive(index * 2);
486
+ updateActive(index * 2);
439
487
  setItemFocus(true);
440
488
  },
441
489
  onBlur: function onBlur() {
442
- setActive(undefined);
490
+ updateActive(undefined);
443
491
  setItemFocus(false);
444
492
  }
445
493
  }), /*#__PURE__*/React.createElement(Button, {
@@ -456,17 +504,17 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
456
504
  },
457
505
  tabIndex: -1,
458
506
  onMouseOver: function onMouseOver() {
459
- return setActive(index * 2 + 1);
507
+ return updateActive(index * 2 + 1);
460
508
  },
461
509
  onMouseOut: function onMouseOut() {
462
- return setActive(undefined);
510
+ return updateActive(undefined);
463
511
  },
464
512
  onFocus: function onFocus() {
465
- setActive(index * 2 + 1);
513
+ updateActive(index * 2 + 1);
466
514
  setItemFocus(true);
467
515
  },
468
516
  onBlur: function onBlur() {
469
- setActive(undefined);
517
+ updateActive(undefined);
470
518
  setItemFocus(false);
471
519
  }
472
520
  }));
@@ -480,6 +528,20 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
480
528
  }, content);
481
529
  }
482
530
 
531
+ var itemAriaProps;
532
+
533
+ if (isDisabled) {
534
+ itemAriaProps = {
535
+ 'aria-disabled': true
536
+ };
537
+
538
+ if (onClickItem) {
539
+ itemAriaProps = _extends({}, itemAriaProps, {
540
+ 'aria-selected': false
541
+ });
542
+ }
543
+ }
544
+
483
545
  if (itemProps && itemProps[index]) {
484
546
  boxProps = _extends({}, boxProps, itemProps[index]);
485
547
  }
@@ -487,11 +549,12 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
487
549
  return /*#__PURE__*/React.createElement(StyledItem, _extends({
488
550
  key: key,
489
551
  tag: "li",
490
- flex: false,
491
- pad: pad || theme.list.item.pad,
492
552
  background: adjustedBackground,
493
- border: adjustedBorder
494
- }, defaultItemProps, boxProps, clickProps, orderProps), onOrder && /*#__PURE__*/React.createElement(Text, null, index + 1), content, orderControls);
553
+ border: adjustedBorder,
554
+ isDisabled: isDisabled,
555
+ flex: false,
556
+ pad: pad || theme.list.item.pad
557
+ }, defaultItemProps, boxProps, clickProps, orderProps, itemAriaProps), onOrder && /*#__PURE__*/React.createElement(Text, null, index + 1), content, orderControls);
495
558
  }))), paginate && data.length > step && items && items.length ? /*#__PURE__*/React.createElement(Pagination, _extends({
496
559
  alignSelf: "end"
497
560
  }, paginationProps)) : null);
@@ -45,6 +45,7 @@ export interface ListProps<ListItemType> {
45
45
  border?: BorderType;
46
46
  children?: React.ReactNode;
47
47
  data?: ListItemType[];
48
+ disabled?: string[];
48
49
  gridArea?: GridAreaType;
49
50
  defaultItemProps?: BoxTypes;
50
51
  itemKey?: string | ((item: ListItemType) => string | number);
@@ -52,10 +53,11 @@ export interface ListProps<ListItemType> {
52
53
  [_: string]: { background?: string; border?: BorderType; pad?: PadType };
53
54
  };
54
55
  margin?: MarginType;
55
- onMore?: () => void;
56
+ onActive?: (index: number) => void;
56
57
  onClickItem?:
57
58
  | ((event: React.MouseEvent) => void)
58
59
  | ((event: { item?: ListItemType; index?: number }) => void);
60
+ onMore?: () => void;
59
61
  onOrder?: (orderedData: ListItemType[]) => void;
60
62
  pad?: PadType;
61
63
  paginate?: boolean | PaginationType;
@@ -28,10 +28,12 @@ if (process.env.NODE_ENV !== 'production') {
28
28
  data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.shape({})])),
29
29
  children: PropTypes.func,
30
30
  defaultItemProps: PropTypes.shape(BoxPropTypes),
31
+ disabled: PropTypes.arrayOf(PropTypes.string),
31
32
  itemKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
32
33
  itemProps: PropTypes.shape({}),
33
- onMore: PropTypes.func,
34
+ onActive: PropTypes.func,
34
35
  onClickItem: PropTypes.func,
36
+ onMore: PropTypes.func,
35
37
  onOrder: PropTypes.func,
36
38
  pad: PropTypes.oneOfType([padPropType]),
37
39
  paginate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { Box, List } from 'grommet';
3
+ var locations = ['Boise', 'Fort Collins', 'Los Gatos', 'Palo Alto', 'San Francisco'];
4
+ var disabledLocations = ['Fort Collins', 'Palo Alto'];
5
+ export var Disabled = function Disabled() {
6
+ return /*#__PURE__*/React.createElement(Box, {
7
+ align: "center",
8
+ pad: "large"
9
+ }, /*#__PURE__*/React.createElement(List, {
10
+ a11yTitle: "Locations",
11
+ data: locations,
12
+ disabled: disabledLocations,
13
+ onClickItem: function onClickItem(e) {
14
+ console.log(e);
15
+ }
16
+ }));
17
+ };
18
+ export default {
19
+ title: 'Visualizations/List/Disabled'
20
+ };
@@ -1,5 +1,9 @@
1
+ var _excluded = ["actions", "message", "onClose", "id", "global", "status", "title", "toast"];
2
+
1
3
  function _extends() { _extends = Object.assign || 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
4
 
5
+ 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; }
6
+
3
7
  import React, { useCallback, useContext, useEffect, useState, useMemo, Fragment } from 'react';
4
8
  import styled, { ThemeContext } from 'styled-components';
5
9
  import { defaultProps } from '../../default-props';
@@ -54,7 +58,7 @@ var NotificationAnchor = styled(Anchor).withConfig({
54
58
  })(["white-space:nowrap;"]);
55
59
 
56
60
  var Notification = function Notification(_ref) {
57
- var _theme$notification, _theme$notification$s2, _theme$notification$s3, _theme$notification2, _theme$notification2$, _theme$notification3, _theme$notification3$, _theme$notification3$2;
61
+ var _theme$notification, _theme$notification2, _theme$notification2$, _theme$notification2$2, _theme$notification3, _theme$notification3$, _theme$notification4, _theme$notification4$, _theme$notification4$2;
58
62
 
59
63
  var actionsProp = _ref.actions,
60
64
  messageProp = _ref.message,
@@ -63,7 +67,9 @@ var Notification = function Notification(_ref) {
63
67
  global = _ref.global,
64
68
  status = _ref.status,
65
69
  title = _ref.title,
66
- toast = _ref.toast;
70
+ toast = _ref.toast,
71
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
72
+
67
73
  var autoClose = toast && (toast == null ? void 0 : toast.autoClose) === undefined ? true : toast.autoClose;
68
74
  var theme = useContext(ThemeContext) || defaultProps.theme;
69
75
 
@@ -89,9 +95,11 @@ var Notification = function Notification(_ref) {
89
95
  return undefined;
90
96
  }, [autoClose, close, theme.notification.toast.time, theme.notification.time]);
91
97
  var CloseIcon = theme.notification.close.icon;
92
- var _theme$notification$s = theme.notification[status],
93
- StatusIcon = _theme$notification$s.icon,
94
- color = _theme$notification$s.color;
98
+
99
+ var _ref2 = ((_theme$notification = theme.notification) == null ? void 0 : _theme$notification[status]) || theme.notification.unknown,
100
+ StatusIcon = _ref2.icon,
101
+ color = _ref2.color;
102
+
95
103
  var closeIconColor = theme.notification.close.color;
96
104
  var kind = useMemo(function () {
97
105
  if (toast) return 'toast';
@@ -101,7 +109,7 @@ var Notification = function Notification(_ref) {
101
109
  var direction;
102
110
  if (kind && theme.notification[kind].direction) direction = theme.notification[kind].direction;else direction = theme.notification.direction;
103
111
  var background;
104
- if (kind && (_theme$notification = theme.notification) != null && (_theme$notification$s2 = _theme$notification[status]) != null && (_theme$notification$s3 = _theme$notification$s2[kind]) != null && _theme$notification$s3.background) background = theme.notification[status][kind].background;else if ((_theme$notification2 = theme.notification) != null && (_theme$notification2$ = _theme$notification2[status]) != null && _theme$notification2$.background) background = theme.notification[status].background;else background = ((_theme$notification3 = theme.notification) == null ? void 0 : (_theme$notification3$ = _theme$notification3[kind]) == null ? void 0 : (_theme$notification3$2 = _theme$notification3$.container) == null ? void 0 : _theme$notification3$2.background) || theme.notification.container.background;
112
+ if (kind && (_theme$notification2 = theme.notification) != null && (_theme$notification2$ = _theme$notification2[status]) != null && (_theme$notification2$2 = _theme$notification2$[kind]) != null && _theme$notification2$2.background) background = theme.notification[status][kind].background;else if ((_theme$notification3 = theme.notification) != null && (_theme$notification3$ = _theme$notification3[status]) != null && _theme$notification3$.background) background = theme.notification[status].background;else background = ((_theme$notification4 = theme.notification) == null ? void 0 : (_theme$notification4$ = _theme$notification4[kind]) == null ? void 0 : (_theme$notification4$2 = _theme$notification4$.container) == null ? void 0 : _theme$notification4$2.background) || theme.notification.container.background;
105
113
  var TextWrapper = direction === 'row' ? Text : Fragment; // notification is built with two child boxes that contain:
106
114
  // 1. icon + text (wrapped in button when clickable)
107
115
  // 2. close button
@@ -144,8 +152,9 @@ var Notification = function Notification(_ref) {
144
152
  ,
145
153
  pad: undefined,
146
154
  direction: "row",
147
- gap: "small"
148
- }), /*#__PURE__*/React.createElement(Box, {
155
+ gap: "small",
156
+ id: toast ? undefined : id
157
+ }, rest), /*#__PURE__*/React.createElement(Box, {
149
158
  direction: "row",
150
159
  pad: textPad,
151
160
  flex: true
@@ -5,6 +5,7 @@ export type StatusType = 'critical' | 'warning' | 'normal' | 'unknown';
5
5
 
6
6
  export interface NotificationProps {
7
7
  actions?: AnchorType[];
8
+ global?: boolean;
8
9
  title?: string;
9
10
  message?: string;
10
11
  status?: StatusType;
@@ -5,6 +5,7 @@ var PropType = {};
5
5
  if (process.env.NODE_ENV !== 'production') {
6
6
  PropType = {
7
7
  actions: PropTypes.arrayOf(PropTypes.shape(AnchorPropTypes)),
8
+ global: PropTypes.bool,
8
9
  title: PropTypes.string,
9
10
  message: PropTypes.string,
10
11
  status: PropTypes.oneOf(['critical', 'warning', 'normal', 'unknown']),
@@ -0,0 +1,63 @@
1
+ var _excluded = ["actions", "gridProps", "parent", "responsive", "subtitle", "title"];
2
+
3
+ function _extends() { _extends = Object.assign || 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); }
4
+
5
+ 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; }
6
+
7
+ import React, { forwardRef, useContext } from 'react';
8
+ import { ThemeContext } from 'styled-components';
9
+ import { Box } from '../Box';
10
+ import { Header } from '../Header';
11
+ import { Heading } from '../Heading';
12
+ import { Grid } from '../Grid';
13
+ import { Paragraph } from '../Paragraph';
14
+ import { ResponsiveContext } from '../../contexts/ResponsiveContext';
15
+ var PageHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
16
+ var actions = _ref.actions,
17
+ gridPropsProp = _ref.gridProps,
18
+ parent = _ref.parent,
19
+ responsive = _ref.responsive,
20
+ subtitle = _ref.subtitle,
21
+ title = _ref.title,
22
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
23
+
24
+ var theme = useContext(ThemeContext);
25
+ var breakpoint = useContext(ResponsiveContext);
26
+
27
+ var actionsProps = _extends({}, theme.pageHeader.actions);
28
+
29
+ var gridProps = theme.pageHeader[breakpoint] || theme.pageHeader.medium;
30
+
31
+ if (responsive && theme.pageHeader.responsive.breakpoints.includes(breakpoint)) {
32
+ gridProps = _extends({}, gridProps, theme.pageHeader.responsive);
33
+ actionsProps = _extends({}, actionsProps, theme.pageHeader.responsive.actions);
34
+ }
35
+
36
+ var _gridProps = gridProps,
37
+ areas = _gridProps.areas,
38
+ columns = _gridProps.columns,
39
+ gap = _gridProps.gap,
40
+ rows = _gridProps.rows;
41
+ return /*#__PURE__*/React.createElement(Header, _extends({
42
+ ref: ref,
43
+ direction: "column",
44
+ gap: "none",
45
+ pad: theme.pageHeader.pad
46
+ }, rest), /*#__PURE__*/React.createElement(Grid, _extends({
47
+ columns: columns,
48
+ rows: rows,
49
+ areas: areas,
50
+ gap: gap,
51
+ fill: "horizontal"
52
+ }, gridPropsProp), /*#__PURE__*/React.createElement(Box, _extends({
53
+ gridArea: "parent"
54
+ }, theme.pageHeader.parent), parent), /*#__PURE__*/React.createElement(Box, {
55
+ gridArea: "title"
56
+ }, typeof title === 'string' ? /*#__PURE__*/React.createElement(Heading, theme.pageHeader.title, title) : title), /*#__PURE__*/React.createElement(Box, {
57
+ gridArea: "subtitle"
58
+ }, typeof subtitle === 'string' ? /*#__PURE__*/React.createElement(Paragraph, theme.pageHeader.subtitle, subtitle) : subtitle), /*#__PURE__*/React.createElement(Box, _extends({
59
+ gridArea: "actions"
60
+ }, actionsProps), actions)));
61
+ });
62
+ PageHeader.displayName = 'PageHeader';
63
+ export { PageHeader };
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import {
3
+ A11yTitleType,
4
+ AlignSelfType,
5
+ GridAreaType,
6
+ MarginType,
7
+ } from '../../utils';
8
+
9
+ import { GridProps } from '../Grid';
10
+ export interface PageHeaderProps {
11
+ a11yTitle?: A11yTitleType;
12
+ alignSelf?: AlignSelfType;
13
+ gridArea?: GridAreaType;
14
+ margin?: MarginType;
15
+ actions?: JSX.Element;
16
+ gridProps?: GridProps;
17
+ parent?: JSX.Element;
18
+ responsive?: boolean;
19
+ subtitle?: string | JSX.Element;
20
+ title?: string | JSX.Element;
21
+ }
22
+
23
+ declare const PageHeader: React.FC<PageHeaderProps>;
24
+ export type PageHeaderType = PageHeaderProps;
25
+
26
+ export { PageHeader };
@@ -0,0 +1 @@
1
+ export { PageHeader } from './PageHeader';
@@ -0,0 +1,19 @@
1
+ function _extends() { _extends = Object.assign || 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
+
3
+ import PropTypes from 'prop-types';
4
+ import { genericProps } from '../../utils/general-prop-types';
5
+ import { GridPropTypes } from '../Grid/propTypes';
6
+ var PropType = {};
7
+
8
+ if (process.env.NODE_ENV !== 'production') {
9
+ PropType = _extends({}, genericProps, {
10
+ actions: PropTypes.element,
11
+ gridProps: GridPropTypes,
12
+ parent: PropTypes.element,
13
+ responsive: PropTypes.bool,
14
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
15
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
16
+ });
17
+ }
18
+
19
+ export var PageHeaderPropTypes = PropType;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { Anchor, Box, Button, grommet, Grommet, PageHeader, Page, PageContent } from 'grommet';
3
+ import { deepMerge } from 'grommet/utils';
4
+ import { FormPrevious } from "grommet-icons/es6/icons/FormPrevious";
5
+ var customTheme = deepMerge(grommet, {
6
+ pageHeader: {
7
+ medium: {
8
+ areas: [['parent', 'parent'], ['title', 'null'], ['subtitle', 'null'], ['actions', 'actions']]
9
+ }
10
+ }
11
+ });
12
+ export var Custom = function Custom() {
13
+ return /*#__PURE__*/React.createElement(Grommet, {
14
+ theme: customTheme
15
+ }, /*#__PURE__*/React.createElement(Page, null, /*#__PURE__*/React.createElement(PageContent, null, /*#__PURE__*/React.createElement(PageHeader, {
16
+ title: "Permissions",
17
+ subtitle: "View and assign permissions.",
18
+ actions: /*#__PURE__*/React.createElement(Box, {
19
+ alignSelf: "start"
20
+ }, /*#__PURE__*/React.createElement(Button, {
21
+ label: "Edit",
22
+ primary: true
23
+ })),
24
+ parent: /*#__PURE__*/React.createElement(Anchor, {
25
+ icon: /*#__PURE__*/React.createElement(FormPrevious, null),
26
+ label: "Settings"
27
+ })
28
+ }))));
29
+ };
30
+ export default {
31
+ title: 'Layout/PageHeader/Custom Themed/Custom'
32
+ };
@@ -0,0 +1,63 @@
1
+ import React, { useContext } from 'react';
2
+ import { Anchor, Box, Button, Menu, PageHeader, Page, PageContent, ResponsiveContext } from 'grommet';
3
+ import { More } from "grommet-icons/es6/icons/More";
4
+ var actions = [{
5
+ label: 'Get Started',
6
+ primary: true
7
+ }, {
8
+ label: 'Follow',
9
+ secondary: true
10
+ }, {
11
+ label: 'File Issue',
12
+ secondary: true
13
+ }];
14
+ var controls = {
15
+ small: /*#__PURE__*/React.createElement(Menu, {
16
+ dropAlign: {
17
+ top: 'bottom',
18
+ right: 'right'
19
+ },
20
+ items: actions.map(function (action) {
21
+ return {
22
+ label: action.label
23
+ };
24
+ }),
25
+ icon: /*#__PURE__*/React.createElement(More, null)
26
+ }),
27
+ medium: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, actions[0]), /*#__PURE__*/React.createElement(Menu, {
28
+ dropAlign: {
29
+ top: 'bottom',
30
+ right: 'right'
31
+ },
32
+ items: actions.slice(1),
33
+ icon: /*#__PURE__*/React.createElement(More, null)
34
+ })),
35
+ large: actions.map(function (action) {
36
+ return /*#__PURE__*/React.createElement(Button, action);
37
+ })
38
+ };
39
+ export var MultipleActions = function MultipleActions() {
40
+ var size = useContext(ResponsiveContext);
41
+ return (
42
+ /*#__PURE__*/
43
+ // Uncomment <Grommet> lines when using outside of storybook
44
+ // <Grommet theme={...}>
45
+ React.createElement(Page, null, /*#__PURE__*/React.createElement(PageContent, null, /*#__PURE__*/React.createElement(PageHeader, {
46
+ title: "Grommet",
47
+ subtitle: "Grommet helps you build responsive and accessible \n mobile-first projects for the web with an easy to use component \n library.",
48
+ actions: /*#__PURE__*/React.createElement(Box, {
49
+ direction: "row",
50
+ gap: "small",
51
+ align: "center"
52
+ }, controls[size]),
53
+ parent: /*#__PURE__*/React.createElement(Anchor, {
54
+ label: "Parent Page"
55
+ })
56
+ }))) // </Grommet>
57
+
58
+ );
59
+ };
60
+ MultipleActions.storyName = 'Multiple Actions';
61
+ export default {
62
+ title: 'Layout/PageHeader/Multiple Actions'
63
+ };