grommet 2.25.3 → 2.27.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 (160) hide show
  1. package/all/stories/AllComponents.js +19 -126
  2. package/components/Accordion/stories/CustomHeader.js +3 -1
  3. package/components/Avatar/Avatar.js +22 -9
  4. package/components/Box/stories/BackgroundThemed.js +54 -0
  5. package/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
  6. package/components/Calendar/Calendar.js +2 -1
  7. package/components/CheckBox/StyledCheckBox.js +9 -5
  8. package/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
  9. package/components/CheckBoxGroup/index.d.ts +2 -1
  10. package/components/CheckBoxGroup/propTypes.js +1 -0
  11. package/components/DataChart/Detail.js +3 -1
  12. package/components/DataTable/index.d.ts +6 -6
  13. package/components/DateInput/DateInput.js +1 -1
  14. package/components/Diagram/Diagram.js +2 -1
  15. package/components/Drop/stories/Inline.js +1 -1
  16. package/components/Drop/stories/Overflow.js +1 -1
  17. package/components/Drop/stories/Plain.js +1 -1
  18. package/components/Drop/stories/Simple.js +1 -1
  19. package/components/Drop/stories/Styled.js +1 -1
  20. package/components/FormField/FormField.js +1 -1
  21. package/components/Heading/Heading.js +31 -2
  22. package/components/Heading/StyledHeading.js +1 -1
  23. package/components/Heading/index.d.ts +1 -0
  24. package/components/Heading/propTypes.js +1 -0
  25. package/components/Heading/stories/All.js +4 -1
  26. package/components/List/List.js +125 -41
  27. package/components/List/index.d.ts +1 -0
  28. package/components/List/propTypes.js +1 -0
  29. package/components/List/stories/Order.js +1 -0
  30. package/components/List/stories/Pinned.js +37 -0
  31. package/components/List/stories/Selection.js +1 -0
  32. package/components/List/stories/onClickItem.js +1 -0
  33. package/components/Notification/Notification.js +2 -2
  34. package/components/Notification/index.d.ts +1 -1
  35. package/components/Notification/propTypes.js +1 -1
  36. package/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
  37. package/components/RadioButton/README.md +1 -279
  38. package/components/RadioButton/RadioButton.js +1 -0
  39. package/components/Select/DefaultSelectTextInput.js +43 -0
  40. package/components/Select/EmptySearchOption.js +34 -0
  41. package/components/Select/Select.js +38 -99
  42. package/components/Select/SelectContainer.js +20 -60
  43. package/components/Select/StyledSelect.js +58 -2
  44. package/components/Select/index.d.ts +11 -9
  45. package/components/Select/propTypes.js +44 -40
  46. package/components/Select/utils.js +129 -3
  47. package/components/SelectMultiple/README.md +2 -0
  48. package/components/SelectMultiple/SelectMultiple.js +476 -0
  49. package/components/SelectMultiple/SelectMultipleContainer.js +483 -0
  50. package/components/SelectMultiple/SelectMultipleValue.js +163 -0
  51. package/components/SelectMultiple/SelectionSummary.js +104 -0
  52. package/components/SelectMultiple/index.d.ts +21 -0
  53. package/components/SelectMultiple/index.js +8 -0
  54. package/components/SelectMultiple/propTypes.js +28 -0
  55. package/components/SelectMultiple/stories/Default.js +76 -0
  56. package/components/SelectMultiple/stories/Disabled.js +84 -0
  57. package/components/SelectMultiple/stories/FormField.js +66 -0
  58. package/components/SelectMultiple/stories/Limited.js +68 -0
  59. package/components/SelectMultiple/stories/LongList.js +76 -0
  60. package/components/SelectMultiple/stories/ObjectOptions.js +104 -0
  61. package/components/SelectMultiple/stories/ShowSelectedInline.js +76 -0
  62. package/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
  63. package/components/Sidebar/stories/Labels.js +4 -1
  64. package/components/TextArea/stories/NonResizable.js +1 -0
  65. package/components/TextArea/stories/Simple.js +1 -0
  66. package/components/index.d.ts +1 -0
  67. package/components/index.js +8 -0
  68. package/es6/all/stories/AllComponents.js +21 -121
  69. package/es6/components/Accordion/stories/CustomHeader.js +3 -1
  70. package/es6/components/Avatar/Avatar.js +21 -9
  71. package/es6/components/Box/stories/BackgroundThemed.js +39 -0
  72. package/es6/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
  73. package/es6/components/Calendar/Calendar.js +2 -1
  74. package/es6/components/CheckBox/StyledCheckBox.js +9 -5
  75. package/es6/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
  76. package/es6/components/CheckBoxGroup/index.d.ts +2 -1
  77. package/es6/components/CheckBoxGroup/propTypes.js +1 -0
  78. package/es6/components/DataChart/Detail.js +3 -1
  79. package/es6/components/DataTable/index.d.ts +6 -6
  80. package/es6/components/DateInput/DateInput.js +1 -1
  81. package/es6/components/Diagram/Diagram.js +2 -1
  82. package/es6/components/Drop/stories/Inline.js +1 -1
  83. package/es6/components/Drop/stories/Overflow.js +1 -1
  84. package/es6/components/Drop/stories/Plain.js +1 -1
  85. package/es6/components/Drop/stories/Simple.js +1 -1
  86. package/es6/components/Drop/stories/Styled.js +1 -1
  87. package/es6/components/FormField/FormField.js +1 -1
  88. package/es6/components/Heading/Heading.js +30 -3
  89. package/es6/components/Heading/StyledHeading.js +1 -1
  90. package/es6/components/Heading/index.d.ts +1 -0
  91. package/es6/components/Heading/propTypes.js +1 -0
  92. package/es6/components/Heading/stories/All.js +4 -1
  93. package/es6/components/List/List.js +126 -42
  94. package/es6/components/List/index.d.ts +1 -0
  95. package/es6/components/List/propTypes.js +1 -0
  96. package/es6/components/List/stories/Order.js +1 -0
  97. package/es6/components/List/stories/Pinned.js +22 -0
  98. package/es6/components/List/stories/Selection.js +1 -0
  99. package/es6/components/List/stories/onClickItem.js +1 -0
  100. package/es6/components/Notification/Notification.js +2 -2
  101. package/es6/components/Notification/index.d.ts +1 -1
  102. package/es6/components/Notification/propTypes.js +1 -1
  103. package/es6/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
  104. package/es6/components/RadioButton/README.md +1 -279
  105. package/es6/components/RadioButton/RadioButton.js +1 -0
  106. package/es6/components/Select/DefaultSelectTextInput.js +31 -0
  107. package/es6/components/Select/EmptySearchOption.js +21 -0
  108. package/es6/components/Select/Select.js +34 -93
  109. package/es6/components/Select/SelectContainer.js +20 -59
  110. package/es6/components/Select/StyledSelect.js +45 -1
  111. package/es6/components/Select/index.d.ts +11 -9
  112. package/es6/components/Select/propTypes.js +41 -39
  113. package/es6/components/Select/utils.js +95 -1
  114. package/es6/components/SelectMultiple/README.md +2 -0
  115. package/es6/components/SelectMultiple/SelectMultiple.js +447 -0
  116. package/es6/components/SelectMultiple/SelectMultipleContainer.js +455 -0
  117. package/es6/components/SelectMultiple/SelectMultipleValue.js +149 -0
  118. package/es6/components/SelectMultiple/SelectionSummary.js +91 -0
  119. package/es6/components/SelectMultiple/index.d.ts +21 -0
  120. package/es6/components/SelectMultiple/index.js +1 -0
  121. package/es6/components/SelectMultiple/propTypes.js +18 -0
  122. package/es6/components/SelectMultiple/stories/Default.js +60 -0
  123. package/es6/components/SelectMultiple/stories/Disabled.js +68 -0
  124. package/es6/components/SelectMultiple/stories/FormField.js +50 -0
  125. package/es6/components/SelectMultiple/stories/Limited.js +53 -0
  126. package/es6/components/SelectMultiple/stories/LongList.js +63 -0
  127. package/es6/components/SelectMultiple/stories/ObjectOptions.js +88 -0
  128. package/es6/components/SelectMultiple/stories/ShowSelectedInline.js +61 -0
  129. package/es6/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
  130. package/es6/components/Sidebar/stories/Labels.js +4 -1
  131. package/es6/components/TextArea/stories/NonResizable.js +1 -0
  132. package/es6/components/TextArea/stories/Simple.js +1 -0
  133. package/es6/components/index.d.ts +1 -0
  134. package/es6/components/index.js +1 -0
  135. package/es6/index.d.ts +1 -0
  136. package/es6/themes/base.d.ts +16 -5
  137. package/es6/themes/base.js +60 -39
  138. package/es6/themes/grommet.js +15 -0
  139. package/es6/themes/hacktoberfest2022.js +129 -0
  140. package/es6/themes/index.js +2 -1
  141. package/es6/utils/background.js +65 -12
  142. package/es6/utils/general-prop-types.js +2 -0
  143. package/es6/utils/index.d.ts +2 -0
  144. package/es6/utils/styles.js +3 -1
  145. package/grommet.min.js +1 -1
  146. package/grommet.min.js.map +1 -1
  147. package/index.d.ts +1 -0
  148. package/package.json +44 -41
  149. package/themes/base.d.ts +16 -5
  150. package/themes/base.js +61 -39
  151. package/themes/grommet.js +15 -0
  152. package/themes/hacktoberfest2022.js +137 -0
  153. package/themes/index.js +6 -2
  154. package/tools/grommet-babel-preset-es2015.js +1 -12
  155. package/tools/pack.js +1 -94
  156. package/tools/release-stable.js +1 -27
  157. package/utils/background.js +64 -12
  158. package/utils/general-prop-types.js +2 -0
  159. package/utils/index.d.ts +2 -0
  160. package/utils/styles.js +3 -1
@@ -1,10 +1,10 @@
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"];
1
+ var _excluded = ["a11yTitle", "aria-label", "action", "as", "background", "border", "children", "data", "defaultItemProps", "disabled", "focus", "itemKey", "itemProps", "onActive", "onClickItem", "onKeyDown", "onMore", "onOrder", "pad", "paginate", "pinned", "primaryKey", "secondaryKey", "show", "step"];
2
2
 
3
3
  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); }
4
4
 
5
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
6
 
7
- import React, { Fragment, useContext, useRef, useState } from 'react';
7
+ import React, { Fragment, useContext, useMemo, useRef, useState } from 'react';
8
8
  import styled, { ThemeContext } from 'styled-components';
9
9
  import { Box } from '../Box';
10
10
  import { Button } from '../Button';
@@ -80,7 +80,7 @@ var normalize = function normalize(item, index, property) {
80
80
  return item[property];
81
81
  };
82
82
 
83
- var reorder = function reorder(array, source, target) {
83
+ var reorder = function reorder(array, pinnedArray, source, target) {
84
84
  var result = array.slice(0);
85
85
  var tmp = result[source];
86
86
  if (source < target) for (var i = source; i < target; i += 1) {
@@ -88,7 +88,15 @@ var reorder = function reorder(array, source, target) {
88
88
  } else for (var _i = source; _i > target; _i -= 1) {
89
89
  result[_i] = result[_i - 1];
90
90
  }
91
- result[target] = tmp;
91
+ result[target] = tmp; // insert pinned items into their proper index within the orderable
92
+ // data object to make the complete data set again
93
+
94
+ if (pinnedArray.data.length > 0) {
95
+ pinnedArray.data.forEach(function (pinnedItem, index) {
96
+ result.splice(pinnedArray.indexes[index], 0, pinnedItem);
97
+ });
98
+ }
99
+
92
100
  return result;
93
101
  }; // Determine the primary content for a row. If the List
94
102
  // has a primaryKey defined this returns the item data
@@ -137,7 +145,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
137
145
  defaultItemProps = _ref.defaultItemProps,
138
146
  disabledItems = _ref.disabled,
139
147
  focus = _ref.focus,
140
- itemKey = _ref.itemKey,
148
+ defaultItemKey = _ref.itemKey,
141
149
  itemProps = _ref.itemProps,
142
150
  onActive = _ref.onActive,
143
151
  onClickItem = _ref.onClickItem,
@@ -146,6 +154,8 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
146
154
  onOrder = _ref.onOrder,
147
155
  pad = _ref.pad,
148
156
  paginate = _ref.paginate,
157
+ _ref$pinned = _ref.pinned,
158
+ pinned = _ref$pinned === void 0 ? [] : _ref$pinned,
149
159
  primaryKey = _ref.primaryKey,
150
160
  secondaryKey = _ref.secondaryKey,
151
161
  showProp = _ref.show,
@@ -154,7 +164,9 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
154
164
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
155
165
 
156
166
  var listRef = useForwardedRef(ref);
157
- var theme = useContext(ThemeContext); // active will be the index of the current 'active'
167
+ var theme = useContext(ThemeContext); // fixes issue where itemKey is undefined when only primaryKey is provided
168
+
169
+ var itemKey = defaultItemKey || primaryKey || null; // active will be the index of the current 'active'
158
170
  // control in the list. If the onOrder property is defined
159
171
  // this will be the index of up or down control for ordering
160
172
  // items in the list. In this case the item index of that
@@ -186,6 +198,38 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
186
198
  dragging = _useState4[0],
187
199
  setDragging = _useState4[1];
188
200
 
201
+ var _useState5 = useState(),
202
+ orderingData = _useState5[0],
203
+ setOrderingData = _useState5[1]; // store a reference to the pinned and the data that is orderable
204
+
205
+
206
+ var _useMemo = useMemo(function () {
207
+ var orderable = [];
208
+ var pinnedData = [];
209
+ var pinnedIndexes = [];
210
+ var currentData = orderingData || data;
211
+ if (pinned.length === 0) return [currentData, {
212
+ data: pinnedData,
213
+ indexes: pinnedIndexes
214
+ }];
215
+ currentData.forEach(function (item, index) {
216
+ var key = typeof item === 'object' ? item[itemKey] : item;
217
+
218
+ if (pinned.includes(key)) {
219
+ pinnedData.push(item);
220
+ pinnedIndexes.push(index);
221
+ } else {
222
+ orderable.push(item);
223
+ }
224
+ });
225
+ return [orderable, {
226
+ data: pinnedData,
227
+ indexes: pinnedIndexes
228
+ }];
229
+ }, [data, orderingData, itemKey, pinned]),
230
+ orderableData = _useMemo[0],
231
+ pinnedInfo = _useMemo[1];
232
+
189
233
  var _usePagination = usePagination(_extends({
190
234
  data: data,
191
235
  page: normalizeShow(showProp, step),
@@ -196,11 +240,6 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
196
240
 
197
241
  var Container = paginate ? StyledContainer : Fragment;
198
242
  var containterProps = paginate ? _extends({}, theme.list.container) : undefined;
199
-
200
- var _useState5 = useState(),
201
- orderingData = _useState5[0],
202
- setOrderingData = _useState5[1];
203
-
204
243
  var draggingRef = useRef();
205
244
  var sendAnalytics = useAnalytics();
206
245
  var ariaProps = {
@@ -216,10 +255,10 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
216
255
  // figure out which arrow button will be the active one.
217
256
  var buttonId = active % 2 ? 'MoveDown' : 'MoveUp';
218
257
  var itemIndex = Math.trunc(active / 2);
219
- activeId = "" + getItemId(data[itemIndex], itemIndex, primaryKey) + buttonId;
258
+ activeId = "" + getItemId(orderableData[itemIndex], itemIndex, primaryKey) + buttonId;
220
259
  } else if (onClickItem) {
221
260
  // The whole list item is active. Figure out an id
222
- activeId = getItemId(data[active], active, primaryKey);
261
+ activeId = getItemId(orderableData[active], active, primaryKey);
223
262
  }
224
263
 
225
264
  ariaProps['aria-activedescendant'] = activeId;
@@ -234,10 +273,10 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
234
273
  // even though it moved up or down.
235
274
 
236
275
  if (active % 2) {
237
- onOrder(reorder(data, index, index + 1));
238
- updateActive(Math.min(active + 2, data.length * 2 - 2));
276
+ onOrder(reorder(orderableData, pinnedInfo, index, index + 1));
277
+ updateActive(Math.min(active + 2, orderableData.length * 2 - 2));
239
278
  } else {
240
- onOrder(reorder(data, index, index - 1));
279
+ onOrder(reorder(orderableData, pinnedInfo, index, index - 1));
241
280
  updateActive(Math.max(active - 2, 1));
242
281
  }
243
282
  } else if (disabledItems != null && disabledItems.includes(typeof itemKey === 'function' ? itemKey(data[active]) : data[active])) {
@@ -261,9 +300,9 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
261
300
  var min = onOrder ? 1 : 0;
262
301
  updateActive(Math.max(active - 1, min));
263
302
  } : undefined,
264
- onDown: (onClickItem || onOrder) && data && data.length ? function () {
303
+ onDown: (onClickItem || onOrder) && orderableData && orderableData.length ? function () {
265
304
  var min = onOrder ? 1 : 0;
266
- var max = onOrder ? data.length * 2 - 2 : data.length - 1;
305
+ var max = onOrder ? orderableData.length * 2 - 2 : data.length - 1;
267
306
  updateActive(active >= min ? Math.min(active + 1, max) : min);
268
307
  } : undefined,
269
308
  onKeyDown: onKeyDown
@@ -348,6 +387,10 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
348
387
  }
349
388
 
350
389
  var key = itemKey ? itemId : getKey(item, index, itemId);
390
+ var orderableIndex = orderableData.findIndex(function (ordItem) {
391
+ var ordItemKey = typeof ordItem === 'object' ? ordItem[itemKey] : ordItem;
392
+ return ordItemKey === key;
393
+ });
351
394
  var isDisabled;
352
395
 
353
396
  if (disabledItems) {
@@ -359,6 +402,17 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
359
402
  isDisabled = disabledItems == null ? void 0 : disabledItems.includes(key);
360
403
  }
361
404
 
405
+ var isPinned;
406
+
407
+ if (pinned.length > 0) {
408
+ if (typeof item === 'object' && !itemKey) {
409
+ console.error( // eslint-disable-next-line max-len
410
+ "Warning: Missing prop itemKey. Prop pin requires itemKey to be specified when data is of type 'object'.");
411
+ }
412
+
413
+ isPinned = pinned == null ? void 0 : pinned.includes(key);
414
+ }
415
+
362
416
  if (action) {
363
417
  content = [/*#__PURE__*/React.createElement(Box, {
364
418
  align: "start",
@@ -378,6 +432,8 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
378
432
  adjustedBackground = theme.global.hover.background;
379
433
  } else if (Array.isArray(adjustedBackground)) {
380
434
  adjustedBackground = adjustedBackground[index % adjustedBackground.length];
435
+ } else if (isPinned) {
436
+ adjustedBackground = theme.list.item.pinned.background;
381
437
  }
382
438
 
383
439
  var adjustedBorder = border !== undefined ? border : theme.list.item.border;
@@ -438,7 +494,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
438
494
  var orderProps;
439
495
  var orderControls;
440
496
 
441
- if (onOrder) {
497
+ if (onOrder && !isPinned) {
442
498
  orderProps = {
443
499
  draggable: true,
444
500
  onDragStart: function onDragStart(event) {
@@ -447,7 +503,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
447
503
  // eslint-disable-next-line no-param-reassign
448
504
 
449
505
  event.dataTransfer.effectAllowed = 'move';
450
- setDragging(index);
506
+ setDragging(orderableIndex);
451
507
  updateActive(undefined);
452
508
  },
453
509
  onDragEnd: function onDragEnd() {
@@ -458,11 +514,11 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
458
514
  if (dragging !== undefined) {
459
515
  event.preventDefault();
460
516
 
461
- if (dragging !== index) {
517
+ if (dragging !== orderableIndex) {
462
518
  // eslint-disable-next-line no-param-reassign
463
519
  event.dataTransfer.dropEffect = 'move';
464
- setOrderingData(reorder(orderingData || data, dragging, index));
465
- setDragging(index);
520
+ setOrderingData(reorder(orderableData, pinnedInfo, dragging, orderableIndex));
521
+ setDragging(orderableIndex);
466
522
  }
467
523
  }
468
524
  },
@@ -471,35 +527,35 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
471
527
  onOrder(orderingData);
472
528
  }
473
529
  },
474
- ref: dragging === index ? draggingRef : undefined
530
+ ref: dragging === orderableIndex ? draggingRef : undefined
475
531
  };
476
532
  var Up = theme.list.icons.up;
477
533
  var Down = theme.list.icons.down;
478
- orderControls = /*#__PURE__*/React.createElement(Box, {
534
+ orderControls = !isPinned && /*#__PURE__*/React.createElement(Box, {
479
535
  direction: "row",
480
536
  align: "center",
481
537
  justify: "end"
482
538
  }, /*#__PURE__*/React.createElement(Button, {
483
539
  id: key + "MoveUp",
484
- a11yTitle: index + 1 + " " + key + " move up",
540
+ a11yTitle: orderableIndex + 1 + " " + key + " move up",
485
541
  icon: /*#__PURE__*/React.createElement(Up, null),
486
542
  hoverIndicator: true,
487
543
  focusIndicator: false,
488
- disabled: !index,
489
- active: active === index * 2,
544
+ disabled: !orderableIndex,
545
+ active: active === orderableIndex * 2,
490
546
  onClick: function onClick(event) {
491
547
  event.stopPropagation();
492
- onOrder(reorder(data, index, index - 1));
548
+ onOrder(reorder(orderableData, pinnedInfo, orderableIndex, orderableIndex - 1));
493
549
  },
494
550
  tabIndex: -1,
495
551
  onMouseOver: function onMouseOver() {
496
- return updateActive(index * 2);
552
+ return updateActive(orderableIndex * 2);
497
553
  },
498
554
  onMouseOut: function onMouseOut() {
499
555
  return updateActive(undefined);
500
556
  },
501
557
  onFocus: function onFocus() {
502
- updateActive(index * 2);
558
+ updateActive(orderableIndex * 2);
503
559
  setItemFocus(true);
504
560
  },
505
561
  onBlur: function onBlur() {
@@ -508,40 +564,43 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
508
564
  }
509
565
  }), /*#__PURE__*/React.createElement(Button, {
510
566
  id: key + "MoveDown",
511
- a11yTitle: index + 1 + " " + key + " move down",
567
+ a11yTitle: orderableIndex + 1 + " " + key + " move down",
512
568
  icon: /*#__PURE__*/React.createElement(Down, null),
513
569
  hoverIndicator: true,
514
570
  focusIndicator: false,
515
- disabled: index >= data.length - 1,
516
- active: active === index * 2 + 1,
571
+ disabled: orderableIndex >= orderableData.length - 1,
572
+ active: active === orderableIndex * 2 + 1,
517
573
  onClick: function onClick(event) {
518
574
  event.stopPropagation();
519
- onOrder(reorder(data, index, index + 1));
575
+ onOrder(reorder(orderableData, pinnedInfo, orderableIndex, orderableIndex + 1));
520
576
  },
521
577
  tabIndex: -1,
522
578
  onMouseOver: function onMouseOver() {
523
- return updateActive(index * 2 + 1);
579
+ return updateActive(orderableIndex * 2 + 1);
524
580
  },
525
581
  onMouseOut: function onMouseOut() {
526
582
  return updateActive(undefined);
527
583
  },
528
584
  onFocus: function onFocus() {
529
- updateActive(index * 2 + 1);
585
+ updateActive(orderableIndex * 2 + 1);
530
586
  setItemFocus(true);
531
587
  },
532
588
  onBlur: function onBlur() {
533
589
  updateActive(undefined);
534
590
  setItemFocus(false);
535
591
  }
536
- }));
592
+ })); // wrap the main content and use
593
+ // the boxProps defined for the content
594
+
595
+ content = /*#__PURE__*/React.createElement(Box, _extends({
596
+ flex: true
597
+ }, boxProps), content); // Adjust the boxProps to account for the order controls
598
+
537
599
  boxProps = {
538
600
  direction: 'row',
539
601
  align: defaultItemProps && defaultItemProps.align || 'center',
540
602
  gap: 'medium'
541
603
  };
542
- content = /*#__PURE__*/React.createElement(Box, {
543
- flex: true
544
- }, content);
545
604
  }
546
605
 
547
606
  var itemAriaProps;
@@ -558,6 +617,31 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
558
617
  }
559
618
  }
560
619
 
620
+ var displayPinned;
621
+
622
+ if (isPinned) {
623
+ // Pinned icon and settings
624
+ var Pin = theme.list.icons.pin;
625
+ var pinSize = theme.list.item.pinned.icon.size;
626
+ var pinPad = theme.list.item.pinned.icon.pad;
627
+ boxProps = {
628
+ direction: 'row',
629
+ align: defaultItemProps && defaultItemProps.align || 'center',
630
+ gap: 'medium'
631
+ };
632
+ displayPinned = /*#__PURE__*/React.createElement(Box, {
633
+ direction: "row",
634
+ align: "center",
635
+ justify: "end",
636
+ pad: pinPad
637
+ }, /*#__PURE__*/React.createElement(Pin, {
638
+ size: pinSize
639
+ }));
640
+ content = /*#__PURE__*/React.createElement(Box, {
641
+ flex: true
642
+ }, content);
643
+ }
644
+
561
645
  if (itemProps && itemProps[index]) {
562
646
  boxProps = _extends({}, boxProps, itemProps[index]);
563
647
  }
@@ -570,7 +654,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
570
654
  isDisabled: isDisabled,
571
655
  flex: false,
572
656
  pad: pad || theme.list.item.pad
573
- }, defaultItemProps, boxProps, clickProps, orderProps, itemAriaProps), onOrder && /*#__PURE__*/React.createElement(Text, null, index + 1), content, orderControls);
657
+ }, defaultItemProps, boxProps, clickProps, orderProps, itemAriaProps), onOrder && /*#__PURE__*/React.createElement(Text, null, index + 1), content, displayPinned, orderControls);
574
658
  }))), paginate && data.length > step && items && items.length ? /*#__PURE__*/React.createElement(Pagination, _extends({
575
659
  alignSelf: "end"
576
660
  }, paginationProps)) : null);
@@ -61,6 +61,7 @@ export interface ListProps<ListItemType> {
61
61
  onOrder?: (orderedData: ListItemType[]) => void;
62
62
  pad?: PadType;
63
63
  paginate?: boolean | PaginationType;
64
+ pinned?: (string | number)[];
64
65
  primaryKey?: string | ((item: ListItemType) => React.ReactElement);
65
66
  secondaryKey?: string | ((item: ListItemType) => React.ReactElement);
66
67
  show?: number | { page?: number };
@@ -37,6 +37,7 @@ if (process.env.NODE_ENV !== 'production') {
37
37
  onOrder: PropTypes.func,
38
38
  pad: PropTypes.oneOfType([padPropType]),
39
39
  paginate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
40
+ pinned: PropTypes.arrayOf(PropTypes.string),
40
41
  primaryKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
41
42
  secondaryKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
42
43
  show: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
@@ -10,6 +10,7 @@ export var Order = function Order() {
10
10
  align: "center",
11
11
  pad: "large"
12
12
  }, /*#__PURE__*/React.createElement(List, {
13
+ "aria-label": "order list",
13
14
  data: ordered,
14
15
  onOrder: setOrder
15
16
  }));
@@ -0,0 +1,22 @@
1
+ import React, { useState } from 'react';
2
+ import { Box, List } from 'grommet';
3
+ var locations = ['Los Angelos', 'Boise', 'Fort Collins', 'Los Gatos', 'Palo Alto', 'Pheonix', 'San Francisco', 'Trenton'];
4
+ var pinnedLocations = ['Los Angelos', 'Fort Collins', 'Palo Alto', 'Pheonix', 'Trenton'];
5
+ export var Pinned = function Pinned() {
6
+ var _useState = useState(locations),
7
+ ordered = _useState[0],
8
+ setOrder = _useState[1];
9
+
10
+ return /*#__PURE__*/React.createElement(Box, {
11
+ align: "center",
12
+ pad: "large"
13
+ }, /*#__PURE__*/React.createElement(List, {
14
+ "aria-label": "pinned list",
15
+ data: ordered,
16
+ onOrder: setOrder,
17
+ pinned: pinnedLocations
18
+ }));
19
+ };
20
+ export default {
21
+ title: 'Visualizations/List/Pinned'
22
+ };
@@ -20,6 +20,7 @@ export var Selection = function Selection() {
20
20
  pad: "large",
21
21
  gap: "large"
22
22
  }, /*#__PURE__*/React.createElement(List, {
23
+ "aria-label": "selection list",
23
24
  data: data.slice(0, 10),
24
25
  itemProps: selected >= 0 ? (_ref = {}, _ref[selected] = {
25
26
  background: 'brand'
@@ -27,6 +27,7 @@ export var OnClickItemList = function OnClickItemList() {
27
27
  pad: "large",
28
28
  gap: "large"
29
29
  }, /*#__PURE__*/React.createElement(List, {
30
+ "aria-label": "onClickItem list",
30
31
  data: data.slice(0, 10),
31
32
  onClickItem: function onClickItem(event) {
32
33
  setShow(true);
@@ -142,11 +142,11 @@ var Notification = function Notification(_ref) {
142
142
  }, action, theme.notification.actions)), ' ');
143
143
  });
144
144
  var Message = direction !== 'row' ? Paragraph : Text;
145
- if (message || actions) message = /*#__PURE__*/React.createElement(Message, theme.notification.message, /*#__PURE__*/React.createElement(Text, {
145
+ if (message || actions) message = typeof message === 'string' ? /*#__PURE__*/React.createElement(Message, theme.notification.message, /*#__PURE__*/React.createElement(Text, {
146
146
  margin: {
147
147
  right: 'xsmall'
148
148
  }
149
- }, message), actions);
149
+ }, message), actions) : message;
150
150
  var content = /*#__PURE__*/React.createElement(Box, _extends({}, theme.notification.container, global ? _extends({}, theme.notification.global.container) : {}, toast ? _extends({}, theme.notification.toast.container) : {}, {
151
151
  background: background // let internal box control pad
152
152
  ,
@@ -7,7 +7,7 @@ export interface NotificationProps {
7
7
  actions?: AnchorType[];
8
8
  global?: boolean;
9
9
  title?: string;
10
- message?: string;
10
+ message?: string | React.ReactNode;
11
11
  status?: StatusType;
12
12
  toast?:
13
13
  | boolean
@@ -7,7 +7,7 @@ if (process.env.NODE_ENV !== 'production') {
7
7
  actions: PropTypes.arrayOf(PropTypes.shape(AnchorPropTypes)),
8
8
  global: PropTypes.bool,
9
9
  title: PropTypes.string,
10
- message: PropTypes.string,
10
+ message: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
11
11
  status: PropTypes.oneOf(['critical', 'warning', 'normal', 'info', 'unknown']),
12
12
  toast: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
13
13
  autoClose: PropTypes.bool,
@@ -4,7 +4,7 @@ import { Box, Grommet, Notification } from 'grommet';
4
4
 
5
5
  import { deepMerge } from 'grommet/utils';
6
6
  import { grommet, ThemeType } from 'grommet/themes';
7
- import { DisabledOutline, CircleQuestion } from 'grommet-icons';
7
+ import { CircleQuestion } from 'grommet-icons';
8
8
 
9
9
  // Type annotations can only be used in TypeScript files.
10
10
  // Remove ': ThemeType' if you are not using Typescript.
@@ -18,7 +18,6 @@ const customTheme: ThemeType = deepMerge(grommet, {
18
18
  container: {
19
19
  // any BoxProps
20
20
  pad: { horizontal: 'large', vertical: '36px' },
21
- background: '#87a200',
22
21
  border: { color: '#000000', size: 'large' },
23
22
  },
24
23
  iconContainer: {
@@ -46,6 +45,7 @@ const customTheme: ThemeType = deepMerge(grommet, {
46
45
  },
47
46
  unknown: {
48
47
  icon: CircleQuestion,
48
+ background: '#87a200',
49
49
  },
50
50
  },
51
51
  });