grommet 2.25.0 → 2.25.3

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 (123) hide show
  1. package/components/Anchor/Anchor.js +14 -1
  2. package/components/Button/Button.js +81 -8
  3. package/components/Button/StyledButtonKind.js +9 -3
  4. package/components/Button/index.d.ts +1 -1
  5. package/components/Button/propTypes.js +1 -1
  6. package/components/Calendar/Calendar.js +232 -292
  7. package/components/Calendar/utils.js +16 -129
  8. package/components/Chart/calcs.js +44 -27
  9. package/components/Chart/stories/Scan.js +11 -9
  10. package/components/Chart/stories/data.js +16 -17
  11. package/components/CheckBox/CheckBox.js +3 -2
  12. package/components/DataChart/DataChart.js +14 -28
  13. package/components/DataChart/Detail.js +18 -11
  14. package/components/DataChart/XAxis.js +29 -18
  15. package/components/DataChart/stories/Pad.js +54 -0
  16. package/components/DataTable/DataTable.js +13 -9
  17. package/components/DataTable/buildState.js +2 -2
  18. package/components/DataTable/index.d.ts +4 -1
  19. package/components/DataTable/stories/SpaceX.js +3 -1
  20. package/components/DataTable/stories/SpaceXUngrouped.js +6 -2
  21. package/components/DateInput/DateInput.js +60 -68
  22. package/components/DateInput/utils.js +30 -5
  23. package/components/FileInput/FileInput.js +2 -1
  24. package/components/FileInput/StyledFileInput.js +1 -1
  25. package/components/Form/Form.js +78 -5
  26. package/components/FormField/FormField.js +29 -29
  27. package/components/Grommet/Grommet.js +7 -2
  28. package/components/Grommet/index.d.ts +1 -0
  29. package/components/Grommet/propTypes.js +2 -1
  30. package/components/Heading/Heading.js +4 -2
  31. package/components/Heading/StyledHeading.js +1 -1
  32. package/components/Heading/index.d.ts +1 -0
  33. package/components/Heading/propTypes.js +2 -1
  34. package/components/Image/Image.js +4 -2
  35. package/components/Layer/LayerContainer.js +25 -0
  36. package/components/List/List.js +17 -0
  37. package/components/Menu/Menu.js +7 -4
  38. package/components/Menu/index.d.ts +2 -2
  39. package/components/Menu/stories/CustomThemed/Themed.tsx +6 -0
  40. package/components/Meter/Circle.js +5 -1
  41. package/components/PageHeader/PageHeader.js +22 -13
  42. package/components/PageHeader/index.d.ts +10 -1
  43. package/components/PageHeader/propTypes.js +1 -0
  44. package/components/PageHeader/stories/Size.js +55 -0
  45. package/components/Select/SelectContainer.js +96 -75
  46. package/components/Select/stories/Clear.js +7 -1
  47. package/components/Select/utils.js +1 -0
  48. package/components/Spinner/Spinner.js +1 -0
  49. package/components/Tab/Tab.js +1 -1
  50. package/components/Tabs/Tabs.js +11 -2
  51. package/components/Video/StyledVideo.js +2 -2
  52. package/contexts/AnalyticsContext/AnalyticsContext.js +65 -0
  53. package/contexts/AnalyticsContext/index.d.ts +7 -0
  54. package/contexts/AnalyticsContext/index.js +11 -0
  55. package/contexts/index.js +8 -0
  56. package/es6/components/Anchor/Anchor.js +15 -3
  57. package/es6/components/Button/Button.js +83 -11
  58. package/es6/components/Button/StyledButtonKind.js +9 -3
  59. package/es6/components/Button/index.d.ts +1 -1
  60. package/es6/components/Button/propTypes.js +1 -1
  61. package/es6/components/Calendar/Calendar.js +230 -292
  62. package/es6/components/Calendar/utils.js +13 -114
  63. package/es6/components/Chart/calcs.js +44 -27
  64. package/es6/components/Chart/stories/Scan.js +10 -9
  65. package/es6/components/Chart/stories/data.js +16 -17
  66. package/es6/components/CheckBox/CheckBox.js +3 -2
  67. package/es6/components/DataChart/DataChart.js +15 -28
  68. package/es6/components/DataChart/Detail.js +20 -10
  69. package/es6/components/DataChart/XAxis.js +29 -19
  70. package/es6/components/DataChart/stories/Pad.js +42 -0
  71. package/es6/components/DataTable/DataTable.js +13 -9
  72. package/es6/components/DataTable/buildState.js +2 -2
  73. package/es6/components/DataTable/index.d.ts +4 -1
  74. package/es6/components/DataTable/stories/SpaceX.js +3 -1
  75. package/es6/components/DataTable/stories/SpaceXUngrouped.js +6 -2
  76. package/es6/components/DateInput/DateInput.js +57 -64
  77. package/es6/components/DateInput/utils.js +29 -7
  78. package/es6/components/FileInput/FileInput.js +2 -1
  79. package/es6/components/FileInput/StyledFileInput.js +1 -1
  80. package/es6/components/Form/Form.js +76 -5
  81. package/es6/components/FormField/FormField.js +29 -30
  82. package/es6/components/Grommet/Grommet.js +6 -2
  83. package/es6/components/Grommet/index.d.ts +1 -0
  84. package/es6/components/Grommet/propTypes.js +2 -1
  85. package/es6/components/Heading/Heading.js +4 -2
  86. package/es6/components/Heading/StyledHeading.js +1 -1
  87. package/es6/components/Heading/index.d.ts +1 -0
  88. package/es6/components/Heading/propTypes.js +2 -1
  89. package/es6/components/Image/Image.js +4 -2
  90. package/es6/components/Layer/LayerContainer.js +24 -0
  91. package/es6/components/List/List.js +16 -0
  92. package/es6/components/Menu/Menu.js +7 -4
  93. package/es6/components/Menu/index.d.ts +2 -2
  94. package/es6/components/Menu/stories/CustomThemed/Themed.tsx +6 -0
  95. package/es6/components/Meter/Circle.js +5 -1
  96. package/es6/components/PageHeader/PageHeader.js +24 -14
  97. package/es6/components/PageHeader/index.d.ts +10 -1
  98. package/es6/components/PageHeader/propTypes.js +1 -0
  99. package/es6/components/PageHeader/stories/Size.js +43 -0
  100. package/es6/components/Select/SelectContainer.js +96 -77
  101. package/es6/components/Select/stories/Clear.js +7 -1
  102. package/es6/components/Select/utils.js +1 -0
  103. package/es6/components/Spinner/Spinner.js +1 -0
  104. package/es6/components/Tab/Tab.js +1 -1
  105. package/es6/components/Tabs/Tabs.js +10 -2
  106. package/es6/components/Video/StyledVideo.js +2 -2
  107. package/es6/contexts/AnalyticsContext/AnalyticsContext.js +47 -0
  108. package/es6/contexts/AnalyticsContext/index.d.ts +7 -0
  109. package/es6/contexts/AnalyticsContext/index.js +1 -0
  110. package/es6/contexts/index.js +1 -0
  111. package/es6/themes/base.d.ts +51 -33
  112. package/es6/themes/base.js +49 -1
  113. package/es6/utils/DOM.js +4 -0
  114. package/es6/utils/mixins.js +3 -0
  115. package/grommet.min.js +1 -1
  116. package/grommet.min.js.map +1 -1
  117. package/package.json +56 -48
  118. package/themes/base.d.ts +51 -33
  119. package/themes/base.js +49 -1
  120. package/tools/pack.js +20 -13
  121. package/tools/release-stable.js +2 -4
  122. package/utils/DOM.js +9 -2
  123. package/utils/mixins.js +7 -1
@@ -1,8 +1,12 @@
1
+ var _excluded = ["clear", "onClear", "name", "theme"];
2
+
1
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); }
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, { forwardRef, useCallback, useContext, useEffect, useRef, useState } from 'react';
4
8
  import styled, { ThemeContext } from 'styled-components';
5
- import { selectedStyle, setFocusWithoutScroll } from '../../utils';
9
+ import { getHoverIndicatorStyle, selectedStyle, setFocusWithoutScroll } from '../../utils';
6
10
  import { defaultProps } from '../../default-props';
7
11
  import { Box } from '../Box';
8
12
  import { Button } from '../Button';
@@ -11,7 +15,8 @@ import { Keyboard } from '../Keyboard';
11
15
  import { Text } from '../Text';
12
16
  import { TextInput } from '../TextInput';
13
17
  import { StyledContainer } from './StyledSelect';
14
- import { applyKey } from './utils'; // position relative is so scroll can be managed correctly
18
+ import { applyKey } from './utils';
19
+ import { containsFocus } from '../../utils/DOM'; // position relative is so scroll can be managed correctly
15
20
 
16
21
  var OptionsBox = styled.div.withConfig({
17
22
  displayName: "SelectContainer__OptionsBox",
@@ -20,24 +25,38 @@ var OptionsBox = styled.div.withConfig({
20
25
  var SelectOption = styled(Button).withConfig({
21
26
  displayName: "SelectContainer__SelectOption",
22
27
  componentId: "sc-1wi0ul8-1"
23
- })(["", " display:block;width:100%;"], function (props) {
28
+ })(["", " ", " &:focus{", "}display:block;width:100%;"], function (props) {
24
29
  return props.selected && props.textComponent && selectedStyle;
30
+ }, function (props) {
31
+ return props.active && getHoverIndicatorStyle(!props.children && !props.theme.select.options ? undefined : 'background', props.theme);
32
+ }, function (props) {
33
+ return props.active && getHoverIndicatorStyle(!props.children && !props.theme.select.options ? undefined : 'background', props.theme);
34
+ }); // ensure ClearButton receives visual indication of keyboard
35
+
36
+ var StyledButton = styled(Button).withConfig({
37
+ displayName: "SelectContainer__StyledButton",
38
+ componentId: "sc-1wi0ul8-2"
39
+ })(["&:focus{", "}"], function (props) {
40
+ return getHoverIndicatorStyle('background', props.theme);
25
41
  });
26
42
  var ClearButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
27
43
  var clear = _ref.clear,
28
44
  onClear = _ref.onClear,
29
45
  name = _ref.name,
30
- theme = _ref.theme;
46
+ theme = _ref.theme,
47
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
48
+
31
49
  var label = clear.label,
32
50
  position = clear.position;
33
51
  var align = position !== 'bottom' ? 'start' : 'center';
34
52
  var buttonLabel = label || "Clear " + (name || 'selection');
35
- return /*#__PURE__*/React.createElement(Button, {
53
+ return /*#__PURE__*/React.createElement(StyledButton, _extends({
54
+ a11yTitle: buttonLabel + ". Or, press " + (position === 'bottom' ? 'shift tab' : 'down arrow') + " to move to select options",
36
55
  fill: "horizontal",
37
56
  ref: ref,
38
57
  onClick: onClear,
39
58
  focusIndicator: false
40
- }, /*#__PURE__*/React.createElement(Box, _extends({}, theme.select.clear.container, {
59
+ }, rest), /*#__PURE__*/React.createElement(Box, _extends({}, theme.select.clear.container, {
41
60
  align: align
42
61
  }), /*#__PURE__*/React.createElement(Text, theme.select.clear.text, buttonLabel)));
43
62
  });
@@ -72,29 +91,30 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
72
91
  _ref2$replace = _ref2.replace,
73
92
  replace = _ref2$replace === void 0 ? true : _ref2$replace;
74
93
  var theme = useContext(ThemeContext) || defaultProps.theme;
94
+ var shouldShowClearButton = useCallback(function (position) {
95
+ var hasValue = Boolean(multiple ? value.length : value);
96
+ var showAtPosition = position === 'bottom' ? (clear == null ? void 0 : clear.position) === 'bottom' : (clear == null ? void 0 : clear.position) !== 'bottom';
97
+ return clear && hasValue && showAtPosition;
98
+ }, [clear, multiple, value]);
75
99
 
76
- var _useState = useState(-1),
100
+ var _useState = useState(usingKeyboard && !shouldShowClearButton('top') ? 0 : -1),
77
101
  activeIndex = _useState[0],
78
102
  setActiveIndex = _useState[1];
79
103
 
80
- var _useState2 = useState(),
104
+ var _useState2 = useState(usingKeyboard),
81
105
  keyboardNavigation = _useState2[0],
82
106
  setKeyboardNavigation = _useState2[1];
83
107
 
84
108
  var searchRef = useRef();
85
109
  var optionsRef = useRef();
86
110
  var clearRef = useRef();
111
+ var activeRef = useRef(); // for keyboard/screenreader, keep the active option in focus
112
+
87
113
  useEffect(function () {
88
- var optionsNode = optionsRef.current;
114
+ var _activeRef$current;
89
115
 
90
- if (optionsNode.children) {
91
- var clearButton = clearRef.current;
92
- var index = activeIndex;
93
- if (clear && clear.position !== 'bottom' && clearButton) index += 1;
94
- var optionNode = optionsNode.children[index];
95
- if (optionNode) optionNode.focus();
96
- }
97
- }, [activeIndex, clear]); // set initial focus
116
+ if (activeIndex >= 0) (_activeRef$current = activeRef.current) == null ? void 0 : _activeRef$current.focus();
117
+ }, [activeIndex]); // set initial focus
98
118
 
99
119
  useEffect(function () {
100
120
  // need to wait for Drop to be ready
@@ -110,11 +130,8 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
110
130
  }
111
131
  } else if (clear && clearButton && clearButton.focus && clear.position !== 'bottom') {
112
132
  setFocusWithoutScroll(clearButton);
113
- } else if (optionsNode && optionsNode.children && usingKeyboard) {
114
- // if the user is navigating with the keyboard set the
115
- // first child as the active index when the drop opens
116
- setFocusWithoutScroll(optionsNode.children[0]);
117
- setActiveIndex(0);
133
+ } else if (usingKeyboard && activeRef.current) {
134
+ setFocusWithoutScroll(activeRef.current);
118
135
  } else if (optionsNode) {
119
136
  setFocusWithoutScroll(optionsNode);
120
137
  }
@@ -122,27 +139,13 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
122
139
  return function () {
123
140
  return clearTimeout(timer);
124
141
  };
125
- }, [onSearch, usingKeyboard, clear]); // clear keyboardNavigation after a while
126
-
127
- useEffect(function () {
128
- if (keyboardNavigation) {
129
- // 100ms was empirically determined
130
- var timer = setTimeout(function () {
131
- return setKeyboardNavigation(false);
132
- }, 100);
133
- return function () {
134
- return clearTimeout(timer);
135
- };
136
- }
137
-
138
- return undefined;
139
- }, [keyboardNavigation]);
142
+ }, [onSearch, usingKeyboard, clear]);
140
143
  var optionLabel = useCallback(function (index) {
141
- return applyKey(options[index], labelKey);
142
- }, [labelKey, options]);
144
+ return applyKey(options[index], labelKey || valueKey);
145
+ }, [labelKey, options, valueKey]);
143
146
  var optionValue = useCallback(function (index) {
144
- return applyKey(options[index], valueKey);
145
- }, [options, valueKey]);
147
+ return applyKey(options[index], valueKey || labelKey);
148
+ }, [options, valueKey, labelKey]);
146
149
  var isDisabled = useCallback(function (index) {
147
150
  var option = options[index];
148
151
  var result;
@@ -234,7 +237,6 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
234
237
  var onNextOption = useCallback(function (event) {
235
238
  event.preventDefault();
236
239
  var nextActiveIndex = activeIndex + 1;
237
- var clearButton = clearRef.current;
238
240
 
239
241
  while (nextActiveIndex < options.length && isDisabled(nextActiveIndex)) {
240
242
  nextActiveIndex += 1;
@@ -244,21 +246,19 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
244
246
  setActiveIndex(nextActiveIndex);
245
247
  setKeyboardNavigation(true);
246
248
  }
247
-
248
- if (clear && clear.position === 'bottom' && clearButton && nextActiveIndex >= options.length) {
249
- setActiveIndex(options.length);
250
- setFocusWithoutScroll(clearButton);
251
- }
252
- }, [activeIndex, isDisabled, options, clear]);
249
+ }, [activeIndex, isDisabled, options]);
253
250
  var onPreviousOption = useCallback(function (event) {
254
251
  event.preventDefault();
255
252
  var nextActiveIndex = activeIndex - 1;
256
- var clearButton = clearRef.current;
257
253
 
258
254
  if (nextActiveIndex === -1) {
259
255
  var searchInput = searchRef.current;
256
+ var clearButton = clearRef.current;
260
257
 
261
- if (searchInput && searchInput.focus) {
258
+ if (clearButton && clearButton.focus && shouldShowClearButton('top')) {
259
+ setActiveIndex(nextActiveIndex);
260
+ setFocusWithoutScroll(clearButton);
261
+ } else if (searchInput && searchInput.focus) {
262
262
  setActiveIndex(nextActiveIndex);
263
263
  setFocusWithoutScroll(searchInput);
264
264
  }
@@ -272,11 +272,7 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
272
272
  setActiveIndex(nextActiveIndex);
273
273
  setKeyboardNavigation(true);
274
274
  }
275
-
276
- if (clear && clear.position !== 'bottom' && clearButton && activeIndex === 0) {
277
- setActiveIndex(-1);
278
- }
279
- }, [activeIndex, isDisabled, clear]);
275
+ }, [activeIndex, isDisabled, shouldShowClearButton]);
280
276
  var onKeyDownOption = useCallback(function (event) {
281
277
  if (!onSearch) {
282
278
  var nextActiveIndex = options.findIndex(function (e, index) {
@@ -308,19 +304,18 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
308
304
  };
309
305
  }, [keyboardNavigation]);
310
306
  var onSelectOption = useCallback(function (event) {
311
- if (activeIndex >= 0 && activeIndex < options.length) {
307
+ if ((shouldShowClearButton('bottom') || shouldShowClearButton('top')) && containsFocus(clearRef.current)) {
308
+ onChange(event, {
309
+ option: undefined,
310
+ value: '',
311
+ selected: ''
312
+ });
313
+ } else if (activeIndex >= 0 && activeIndex < options.length) {
312
314
  event.preventDefault(); // prevent submitting forms
313
315
 
314
316
  selectOption(activeIndex)(event);
315
317
  }
316
- }, [activeIndex, selectOption, options]);
317
-
318
- var shouldShowClearButton = function shouldShowClearButton(position) {
319
- var hasValue = Boolean(multiple ? value.length : value);
320
- var showAtPosition = position === 'bottom' ? (clear == null ? void 0 : clear.position) === 'bottom' : (clear == null ? void 0 : clear.position) !== 'bottom';
321
- return clear && hasValue && showAtPosition;
322
- };
323
-
318
+ }, [activeIndex, selectOption, options, onChange, shouldShowClearButton]);
324
319
  var customSearchInput = theme.select.searchInput;
325
320
  var SelectTextInput = customSearchInput || TextInput;
326
321
  var selectOptionsStyle = theme.select.options ? _extends({}, theme.select.options.box, theme.select.options.container) : {};
@@ -351,18 +346,27 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
351
346
  setActiveIndex(-1);
352
347
  onSearch(nextSearch);
353
348
  }
354
- })), /*#__PURE__*/React.createElement(OptionsBox, {
355
- role: "listbox",
356
- tabIndex: "-1",
357
- ref: optionsRef,
358
- "aria-multiselectable": multiple
359
- }, shouldShowClearButton('top') && /*#__PURE__*/React.createElement(ClearButton, {
349
+ })), shouldShowClearButton('top') && /*#__PURE__*/React.createElement(ClearButton, {
360
350
  ref: clearRef,
361
351
  clear: clear,
362
352
  name: name,
363
353
  onClear: onClear,
354
+ onFocus: function onFocus() {
355
+ return setActiveIndex(-1);
356
+ },
357
+ onMouseOver: function onMouseOver() {
358
+ return setActiveIndex(-1);
359
+ },
364
360
  theme: theme
365
- }), options.length > 0 ? /*#__PURE__*/React.createElement(InfiniteScroll, {
361
+ }), /*#__PURE__*/React.createElement(OptionsBox, {
362
+ role: "listbox",
363
+ tabIndex: "-1",
364
+ ref: optionsRef,
365
+ "aria-multiselectable": multiple,
366
+ onMouseMove: function onMouseMove() {
367
+ return setKeyboardNavigation(false);
368
+ }
369
+ }, options.length > 0 ? /*#__PURE__*/React.createElement(InfiniteScroll, {
366
370
  items: options,
367
371
  step: theme.select.step,
368
372
  onMore: onMore,
@@ -392,8 +396,13 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
392
396
 
393
397
  return /*#__PURE__*/React.createElement(SelectOption // eslint-disable-next-line react/no-array-index-key
394
398
  , {
395
- key: index,
396
- ref: optionRef,
399
+ key: index // merge optionRef and activeRef
400
+ ,
401
+ ref: function ref(node) {
402
+ // eslint-disable-next-line no-param-reassign
403
+ if (optionRef) optionRef.current = node;
404
+ if (optionActive) activeRef.current = node;
405
+ },
397
406
  tabIndex: optionSelected ? '0' : '-1',
398
407
  role: "option",
399
408
  "aria-setsize": options.length,
@@ -404,11 +413,15 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
404
413
  plain: !child ? undefined : true,
405
414
  align: "start",
406
415
  kind: !child ? 'option' : undefined,
407
- hoverIndicator: !child ? undefined : 'background',
408
416
  label: !child ? optionLabel(index) : undefined,
409
417
  disabled: optionDisabled || undefined,
410
418
  active: optionActive,
411
- selected: optionSelected,
419
+ selected: optionSelected // allow keyboard navigation to start from
420
+ // selected option after tabbing to it
421
+ ,
422
+ onFocus: function onFocus() {
423
+ return setActiveIndex(index);
424
+ },
412
425
  onMouseOver: !optionDisabled ? onActiveOption(index) : undefined,
413
426
  onClick: !optionDisabled ? selectOption(index) : undefined,
414
427
  textComponent: textComponent
@@ -419,12 +432,18 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
419
432
  role: "menuitem",
420
433
  hoverIndicator: "background",
421
434
  disabled: true
422
- }, /*#__PURE__*/React.createElement(Box, selectOptionsStyle, /*#__PURE__*/React.createElement(Text, theme.select.container.text, emptySearchMessage))), shouldShowClearButton('bottom') && /*#__PURE__*/React.createElement(ClearButton, {
435
+ }, /*#__PURE__*/React.createElement(Box, selectOptionsStyle, /*#__PURE__*/React.createElement(Text, theme.select.container.text, emptySearchMessage)))), shouldShowClearButton('bottom') && /*#__PURE__*/React.createElement(ClearButton, {
423
436
  ref: clearRef,
424
437
  clear: clear,
425
438
  name: name,
426
439
  onClear: onClear,
440
+ onFocus: function onFocus() {
441
+ return setActiveIndex(-1);
442
+ },
443
+ onMouseOver: function onMouseOver() {
444
+ return setActiveIndex(-1);
445
+ },
427
446
  theme: theme
428
- }))));
447
+ })));
429
448
  });
430
449
  export { SelectContainer };
@@ -1,6 +1,10 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Box, Select } from 'grommet';
3
- var options = ['one', 'two', 'three'];
3
+ var options = [];
4
+
5
+ for (var i = 0; i < 500; i += 1) {
6
+ options.push("Number " + i);
7
+ }
4
8
 
5
9
  var ClearTop = function ClearTop() {
6
10
  var _useState = useState(),
@@ -21,6 +25,7 @@ var ClearTop = function ClearTop() {
21
25
  var nextValue = _ref.value;
22
26
  return setValue(nextValue);
23
27
  },
28
+ dropHeight: "large",
24
29
  clear: true
25
30
  }));
26
31
  };
@@ -44,6 +49,7 @@ var ClearBottom = function ClearBottom() {
44
49
  var nextValue = _ref2.value;
45
50
  return setValue(nextValue);
46
51
  },
52
+ dropHeight: "large",
47
53
  clear: {
48
54
  position: 'bottom'
49
55
  }
@@ -3,5 +3,6 @@ export var applyKey = function applyKey(option, key) {
3
3
  if (typeof key === 'object') return applyKey(option, key.key);
4
4
  if (typeof key === 'function') return key(option);
5
5
  if (key !== undefined) return option[key];
6
+ if (typeof option === 'object' && Object.keys(option)) return option[Object.keys(option)[0]];
6
7
  return option;
7
8
  };
@@ -19,6 +19,7 @@ var BasicSpinner = function BasicSpinner(_ref) {
19
19
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
20
20
 
21
21
  return /*#__PURE__*/React.createElement(Box, _extends({
22
+ flex: false,
22
23
  height: size,
23
24
  width: size,
24
25
  ref: ref
@@ -50,7 +50,7 @@ var Tab = /*#__PURE__*/forwardRef(function (_ref, ref) {
50
50
  var tabStyles = {};
51
51
  var tabRef = useForwardedRef(ref);
52
52
  useLayoutEffect(function () {
53
- if (tabRef.current) {
53
+ if (tabRef.current && tabsContextRef) {
54
54
  tabsContextRef.current = tabRef.current;
55
55
  }
56
56
  });
@@ -18,6 +18,7 @@ import { StyledTabPanel, StyledTabs, StyledTabsHeader } from './StyledTabs';
18
18
  import { normalizeColor } from '../../utils';
19
19
  import { MessageContext } from '../../contexts/MessageContext';
20
20
  import { TabsPropTypes } from './propTypes';
21
+ import { useAnalytics } from '../../contexts/AnalyticsContext/AnalyticsContext';
21
22
  var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
22
23
  var alignControls = _ref.alignControls,
23
24
  children = _ref.children,
@@ -67,6 +68,7 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
67
68
 
68
69
  var headerRef = useRef();
69
70
  var size = useContext(ResponsiveContext);
71
+ var sendAnalytics = useAnalytics();
70
72
 
71
73
  if (activeIndex !== propsActiveIndex && propsActiveIndex !== undefined) {
72
74
  setActiveIndex(propsActiveIndex);
@@ -233,6 +235,11 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
233
235
  }, [tabRefs, disableLeftArrow, disableRightArrow, activeIndex, headerRef, overflow, updateArrowState]);
234
236
  var getTabsContext = useCallback(function (index) {
235
237
  var activateTab = function activateTab(nextIndex) {
238
+ sendAnalytics({
239
+ type: 'activateTab',
240
+ element: tabRefs[nextIndex].current
241
+ });
242
+
236
243
  if (propsActiveIndex === undefined) {
237
244
  setActiveIndex(nextIndex);
238
245
  }
@@ -254,7 +261,7 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
254
261
  setActiveTitle: setActiveTitle,
255
262
  setFocusIndex: setFocusIndex
256
263
  };
257
- }, [activeIndex, onActive, propsActiveIndex, tabRefs]);
264
+ }, [activeIndex, onActive, propsActiveIndex, sendAnalytics, tabRefs]);
258
265
  var tabs = React.Children.map(children, function (child, index) {
259
266
  return /*#__PURE__*/React.createElement(TabsContext.Provider, {
260
267
  value: getTabsContext(index)
@@ -293,6 +300,7 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
293
300
  }, rest, {
294
301
  background: theme.tabs.background
295
302
  }), /*#__PURE__*/React.createElement(Box, _extends({
303
+ flex: false,
296
304
  direction: overflow ? 'row' : 'column'
297
305
  }, tabsHeaderStyles), overflow && /*#__PURE__*/React.createElement(Button, {
298
306
  a11yTitle: "Previous Tab",
@@ -313,7 +321,7 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
313
321
  ref: headerRef,
314
322
  as: Box,
315
323
  direction: "row",
316
- justify: justify,
324
+ justify: overflow ? 'start' : justify,
317
325
  alignSelf: alignControls,
318
326
  flex: !!overflow,
319
327
  wrap: false,
@@ -49,9 +49,9 @@ var headStyle = css(["::after{content:'';height:100%;width:", ";background:", ";
49
49
  var StyledVideoScrubber = styled.div.withConfig({
50
50
  displayName: "StyledVideo__StyledVideoScrubber",
51
51
  componentId: "sc-w4v8h9-3"
52
- })(["cursor:pointer;width:100%;height:100%;", ";"], function (props) {
52
+ })(["cursor:pointer;width:100%;height:100%;", ";&:focus{", "}"], function (props) {
53
53
  return props.value && headStyle;
54
- });
54
+ }, focusStyle());
55
55
  StyledVideoScrubber.defaultProps = {};
56
56
  Object.setPrototypeOf(StyledVideoScrubber.defaultProps, defaultProps);
57
57
  export { StyledVideo, StyledVideoContainer, StyledVideoControls, StyledVideoScrubber };
@@ -0,0 +1,47 @@
1
+ import React, { useCallback, useContext, useEffect, useRef } from 'react';
2
+ export var AnalyticsContext = /*#__PURE__*/React.createContext(function () {});
3
+ export var useAnalytics = function useAnalytics() {
4
+ return useContext(AnalyticsContext);
5
+ };
6
+ export var AnalyticsProvider = function AnalyticsProvider(_ref) {
7
+ var onAnalytics = _ref.onAnalytics,
8
+ children = _ref.children;
9
+ var lastUrlRef = useRef();
10
+ var sendAnalytics = useCallback(function (data) {
11
+ return onAnalytics && onAnalytics(data);
12
+ }, [onAnalytics]);
13
+ useEffect(function () {
14
+ var observer;
15
+
16
+ if (onAnalytics) {
17
+ observer = new window.MutationObserver(function () {
18
+ var _window, _window$location;
19
+
20
+ var url = (_window = window) == null ? void 0 : (_window$location = _window.location) == null ? void 0 : _window$location.href;
21
+ var previousUrl = lastUrlRef.current;
22
+
23
+ if (url !== previousUrl) {
24
+ lastUrlRef.current = url;
25
+ sendAnalytics({
26
+ type: 'pageView',
27
+ url: url,
28
+ previousUrl: previousUrl
29
+ });
30
+ }
31
+ });
32
+ observer.observe(document, {
33
+ subtree: true,
34
+ childList: true
35
+ });
36
+ }
37
+
38
+ return function () {
39
+ var _observer;
40
+
41
+ return (_observer = observer) == null ? void 0 : _observer.disconnect();
42
+ };
43
+ }, [sendAnalytics, onAnalytics]);
44
+ return /*#__PURE__*/React.createElement(AnalyticsContext.Provider, {
45
+ value: sendAnalytics
46
+ }, children);
47
+ };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+
3
+ export type AnalyticsValue = Node;
4
+
5
+ declare const AnalyticsContext: React.Context<AnalyticsValue>;
6
+
7
+ export { AnalyticsContext };
@@ -0,0 +1 @@
1
+ export * from './AnalyticsContext';
@@ -1,3 +1,4 @@
1
+ export * from './AnalyticsContext';
1
2
  export * from './AnnounceContext';
2
3
  export * from './ContainerTargetContext';
3
4
  export * from './ResponsiveContext';
@@ -32,7 +32,7 @@ import { Anchor } from '../components/Anchor';
32
32
  import { Box } from '../components/Box';
33
33
  import { Text, TextProps } from '../components/Text';
34
34
  import { LayerPositionType, LayerProps } from '../components/Layer';
35
- import { DropProps } from '../components/Drop';
35
+ import { DropProps, DropType } from '../components/Drop';
36
36
  import {
37
37
  AreasType,
38
38
  GridColumnsType,
@@ -141,16 +141,19 @@ interface ButtonKindType {
141
141
  | {
142
142
  color?: ColorType;
143
143
  width?: string;
144
+ radius?: string;
144
145
  }
145
146
  | boolean;
146
147
  color?: ColorType;
147
148
  font?: {
148
149
  weight?: number | string;
149
150
  };
151
+ icon?: React.ReactNode | Icon;
150
152
  padding?: {
151
153
  vertical?: string;
152
154
  horizontal?: string;
153
155
  };
156
+ reverse?: boolean;
154
157
  extend?: ExtendType;
155
158
  }
156
159
 
@@ -195,7 +198,13 @@ interface ButtonType {
195
198
  secondary?: ButtonKindType;
196
199
  })
197
200
  | { [key: string]: ButtonKindType };
198
- disabled?: ButtonKindType & { opacity?: OpacityType };
201
+ disabled?:
202
+ | (ButtonKindType & {
203
+ default?: ButtonKindType;
204
+ primary?: ButtonKindType;
205
+ secondary?: ButtonKindType;
206
+ })
207
+ | ({ [key: string]: ButtonKindType } & { opacity?: OpacityType });
199
208
  hover?:
200
209
  | (ButtonKindType & {
201
210
  default?: ButtonKindType;
@@ -232,6 +241,7 @@ interface ButtonType {
232
241
  };
233
242
  };
234
243
  };
244
+ style?: Partial<CSSStyleDeclaration>;
235
245
  transition?: {
236
246
  timing?: string;
237
247
  duration?: number;
@@ -242,6 +252,15 @@ interface FormFieldLabelType extends TextProps {
242
252
  requiredIndicator?: boolean | JSX.Element | string;
243
253
  }
244
254
 
255
+ type DigitalTexts =
256
+ | 'xsmall'
257
+ | 'small'
258
+ | 'medium'
259
+ | 'large'
260
+ | 'xlarge'
261
+ | 'xxlarge'
262
+ | string;
263
+
245
264
  export interface ThemeType {
246
265
  global?: {
247
266
  active?: {
@@ -359,10 +378,12 @@ export interface ThemeType {
359
378
  color?: ColorType;
360
379
  size?: string;
361
380
  };
362
- shadow?: {
363
- color?: ColorType;
364
- size?: string;
365
- };
381
+ shadow?:
382
+ | string
383
+ | {
384
+ color?: ColorType;
385
+ size?: string;
386
+ };
366
387
  };
367
388
  font?: {
368
389
  face?: string;
@@ -517,7 +538,7 @@ export interface ThemeType {
517
538
  };
518
539
  };
519
540
  card?: {
520
- container?: BoxProps;
541
+ container?: BoxProps | { extend?: ExtendType };
521
542
  hover?: {
522
543
  container?: {
523
544
  elevation?: ElevationType;
@@ -626,31 +647,7 @@ export interface ThemeType {
626
647
  };
627
648
  digital?: {
628
649
  text?: {
629
- xsmall?: {
630
- size?: string;
631
- height?: number;
632
- };
633
- small?: {
634
- size?: string;
635
- height?: number;
636
- };
637
- medium?: {
638
- size?: string;
639
- height?: number;
640
- };
641
- large?: {
642
- size?: string;
643
- height?: number;
644
- };
645
- xlarge?: {
646
- size?: string;
647
- height?: number;
648
- };
649
- xxlarge?: {
650
- size?: string;
651
- height?: number;
652
- };
653
- [key: string]: {
650
+ [key in DigitalTexts]: {
654
651
  size?: string;
655
652
  height?: number;
656
653
  };
@@ -785,6 +782,9 @@ export interface ThemeType {
785
782
  margin?: MarginType;
786
783
  pad?: PadType;
787
784
  };
785
+ checkBox: {
786
+ pad: PadType;
787
+ };
788
788
  disabled?: {
789
789
  background?: BackgroundType;
790
790
  border?: {
@@ -1039,7 +1039,8 @@ export interface ThemeType {
1039
1039
  };
1040
1040
  menu?: {
1041
1041
  background?: BackgroundType;
1042
- drop?: DropProps;
1042
+ item?: ButtonType;
1043
+ drop?: DropType;
1043
1044
  extend?: ExtendType;
1044
1045
  group?: {
1045
1046
  container?: BoxProps;
@@ -1177,6 +1178,23 @@ export interface ThemeType {
1177
1178
  };
1178
1179
  subtitle?: ParagraphProps;
1179
1180
  title?: HeadingProps;
1181
+ size?: {
1182
+ small?: {
1183
+ pad?: PadType;
1184
+ subtitle?: ParagraphProps;
1185
+ title?: ParagraphProps;
1186
+ };
1187
+ medium?: {
1188
+ pad?: PadType;
1189
+ subtitle?: ParagraphProps;
1190
+ title?: ParagraphProps;
1191
+ };
1192
+ large?: {
1193
+ pad?: PadType;
1194
+ subtitle?: ParagraphProps;
1195
+ title?: ParagraphProps;
1196
+ };
1197
+ };
1180
1198
  small?: {
1181
1199
  areas?: AreasType;
1182
1200
  columns?: GridColumnsType;