grommet 2.50.0 → 2.52.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 (41) hide show
  1. package/components/Anchor/stories/Gap.stories.js +6 -0
  2. package/components/Box/Box.js +19 -0
  3. package/components/Button/Button.js +10 -1
  4. package/components/Calendar/Calendar.js +8 -5
  5. package/components/Grommet/index.d.ts +3 -0
  6. package/components/Grommet/propTypes.js +3 -0
  7. package/components/List/List.js +6 -4
  8. package/components/Meter/Meter.js +3 -6
  9. package/components/Select/Select.js +1 -0
  10. package/components/Select/SelectContainer.js +19 -2
  11. package/components/Select/index.d.ts +6 -1
  12. package/components/Select/propTypes.js +4 -1
  13. package/components/SelectMultiple/SelectMultipleContainer.js +11 -2
  14. package/components/SelectMultiple/index.d.ts +1 -0
  15. package/components/SelectMultiple/propTypes.js +1 -0
  16. package/es6/components/Anchor/stories/Gap.stories.js +6 -0
  17. package/es6/components/Box/Box.js +19 -0
  18. package/es6/components/Button/Button.js +10 -1
  19. package/es6/components/Calendar/Calendar.js +8 -5
  20. package/es6/components/Grommet/index.d.ts +3 -0
  21. package/es6/components/Grommet/propTypes.js +3 -0
  22. package/es6/components/List/List.js +6 -4
  23. package/es6/components/Meter/Meter.js +3 -6
  24. package/es6/components/Select/Select.js +1 -0
  25. package/es6/components/Select/SelectContainer.js +20 -3
  26. package/es6/components/Select/index.d.ts +6 -1
  27. package/es6/components/Select/propTypes.js +4 -1
  28. package/es6/components/SelectMultiple/SelectMultipleContainer.js +11 -2
  29. package/es6/components/SelectMultiple/index.d.ts +1 -0
  30. package/es6/components/SelectMultiple/propTypes.js +1 -0
  31. package/es6/languages/default.json +3 -0
  32. package/es6/themes/base.d.ts +9 -0
  33. package/es6/themes/base.js +27 -1
  34. package/es6/utils/colors.js +29 -0
  35. package/grommet.min.js +1 -1
  36. package/grommet.min.js.map +1 -1
  37. package/languages/default.json +3 -0
  38. package/package.json +43 -43
  39. package/themes/base.d.ts +9 -0
  40. package/themes/base.js +27 -1
  41. package/utils/colors.js +29 -0
@@ -1,9 +1,11 @@
1
1
  var _excluded = ["clear", "onClear", "name", "theme"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
4
+ import React, { forwardRef, useCallback, useEffect, useRef, useState, useContext } from 'react';
5
5
  import styled from 'styled-components';
6
+ import { Search } from 'grommet-icons/icons/Search';
6
7
  import { setFocusWithoutScroll, getHoverIndicatorStyle, containsFocus } from '../../utils';
8
+ import { MessageContext } from '../../contexts/MessageContext';
7
9
  import { Box } from '../Box';
8
10
  import { Button } from '../Button';
9
11
  import { InfiniteScroll } from '../InfiniteScroll';
@@ -71,7 +73,7 @@ var ClearButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
71
73
  });
72
74
  });
73
75
  var SelectContainer = /*#__PURE__*/forwardRef(function (_ref3, ref) {
74
- var _theme$select;
76
+ var _theme$select$icons, _theme$select;
75
77
  var clear = _ref3.clear,
76
78
  _ref3$children = _ref3.children,
77
79
  children = _ref3$children === void 0 ? null : _ref3$children,
@@ -82,6 +84,7 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref3, ref) {
82
84
  emptySearchMessage = _ref3$emptySearchMess === void 0 ? 'No matches found' : _ref3$emptySearchMess,
83
85
  id = _ref3.id,
84
86
  labelKey = _ref3.labelKey,
87
+ messages = _ref3.messages,
85
88
  multiple = _ref3.multiple,
86
89
  name = _ref3.name,
87
90
  onChange = _ref3.onChange,
@@ -120,6 +123,11 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref3, ref) {
120
123
  var optionsRef = useRef();
121
124
  var clearRef = useRef();
122
125
  var activeRef = useRef();
126
+ var _useContext = useContext(MessageContext),
127
+ format = _useContext.format;
128
+ var searchIcon = ((_theme$select$icons = theme.select.icons) == null ? void 0 : _theme$select$icons.search) || /*#__PURE__*/React.createElement(Search, {
129
+ "aria-hidden": true
130
+ });
123
131
 
124
132
  // for keyboard/screenreader, keep the active option in focus
125
133
  useEffect(function () {
@@ -302,6 +310,10 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref3, ref) {
302
310
  pad: !customSearchInput ? (_theme$select = theme.select) == null || (_theme$select = _theme$select.search) == null ? void 0 : _theme$select.pad : undefined,
303
311
  flex: false
304
312
  }, /*#__PURE__*/React.createElement(SelectTextInput, {
313
+ "aria-label": format({
314
+ id: 'select.searchA11y',
315
+ messages: messages
316
+ }),
305
317
  focusIndicator: !customSearchInput,
306
318
  size: "small",
307
319
  ref: searchRef,
@@ -316,7 +328,8 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref3, ref) {
316
328
  },
317
329
  onFocus: function onFocus() {
318
330
  return setActiveIndex(-1);
319
- }
331
+ },
332
+ icon: searchIcon
320
333
  })), shouldShowClearButton('top') && /*#__PURE__*/React.createElement(ClearButton, {
321
334
  ref: clearRef,
322
335
  clear: clear,
@@ -330,6 +343,10 @@ var SelectContainer = /*#__PURE__*/forwardRef(function (_ref3, ref) {
330
343
  },
331
344
  theme: theme
332
345
  }), options.length > 0 ? /*#__PURE__*/React.createElement(OptionsContainer, {
346
+ "aria-label": format({
347
+ id: 'select.optionsA11y',
348
+ messages: messages
349
+ }),
333
350
  role: "listbox",
334
351
  tabIndex: "-1",
335
352
  ref: optionsRef,
@@ -30,7 +30,12 @@ export interface BasicSelectProps {
30
30
  id?: string;
31
31
  labelKey?: string | ((...args: any[]) => string | React.ReactNode);
32
32
  margin?: MarginType;
33
- messages?: { multiple?: string };
33
+ messages?: {
34
+ optionsA11y?: string;
35
+ multiple?: string;
36
+ searchA11y?: string;
37
+ selected?: string;
38
+ };
34
39
  name?: string;
35
40
  onChange?: (...args: any[]) => void;
36
41
  onClose?: (...args: any[]) => any;
@@ -19,7 +19,10 @@ export var genericSelectProps = _extends({}, genericProps, {
19
19
  icon: PropTypes.oneOfType([PropTypes.bool, PropTypes.func, PropTypes.node, PropTypes.elementType]),
20
20
  labelKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
21
21
  messages: PropTypes.shape({
22
- multiple: PropTypes.string
22
+ optionsA11y: PropTypes.string,
23
+ multiple: PropTypes.string,
24
+ searchA11y: PropTypes.string,
25
+ selected: PropTypes.string
23
26
  }),
24
27
  name: PropTypes.string,
25
28
  onChange: PropTypes.func,
@@ -1,5 +1,6 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { forwardRef, useCallback, useContext, useEffect, useRef, useState } from 'react';
3
+ import { Search } from 'grommet-icons/icons/Search';
3
4
  import { setFocusWithoutScroll } from '../../utils';
4
5
  import { Box } from '../Box';
5
6
  import { Button } from '../Button';
@@ -15,7 +16,7 @@ import { EmptySearchOption } from '../Select/EmptySearchOption';
15
16
  import { MessageContext } from '../../contexts/MessageContext';
16
17
  import { useThemeValue } from '../../utils/useThemeValue';
17
18
  var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
- var _theme$selectMultiple2;
19
+ var _theme$select$icons, _theme$selectMultiple2;
19
20
  var allOptions = _ref.allOptions,
20
21
  _ref$children = _ref.children,
21
22
  children = _ref$children === void 0 ? null : _ref$children,
@@ -74,6 +75,9 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
74
75
  setShowA11yLimit = _useState4[1];
75
76
  var clearRef = useRef();
76
77
  var isDisabled = useDisabled(disabled, disabledKey, options, valueKey || labelKey);
78
+ var searchIcon = ((_theme$select$icons = theme.select.icons) == null ? void 0 : _theme$select$icons.search) || /*#__PURE__*/React.createElement(Search, {
79
+ "aria-hidden": true
80
+ });
77
81
 
78
82
  // for keyboard/screenreader, keep the active option in focus
79
83
  useEffect(function () {
@@ -331,8 +335,13 @@ var SelectMultipleContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
331
335
  },
332
336
  onFocus: function onFocus() {
333
337
  return setActiveIndex(-1);
334
- }
338
+ },
339
+ icon: searchIcon
335
340
  }))), helpContent, (options == null ? void 0 : options.length) > 0 ? /*#__PURE__*/React.createElement(OptionsContainer, {
341
+ "aria-label": format({
342
+ id: 'selectMultiple.optionsA11y',
343
+ messages: messages
344
+ }),
336
345
  role: "listbox",
337
346
  tabIndex: "-1",
338
347
  ref: optionsRef,
@@ -15,6 +15,7 @@ export interface SelectMultipleProps extends BasicSelectProps {
15
15
  open?: string;
16
16
  optionNotSelected?: string;
17
17
  optionSelected?: string;
18
+ optionsA11y?: string;
18
19
  search?: string;
19
20
  selectAll?: string;
20
21
  selectAllA11y?: string;
@@ -16,6 +16,7 @@ if (process.env.NODE_ENV !== 'production') {
16
16
  open: PropTypes.string,
17
17
  optionNotSelected: PropTypes.string,
18
18
  optionSelected: PropTypes.string,
19
+ optionsA11y: PropTypes.string,
19
20
  search: PropTypes.string,
20
21
  selectAll: PropTypes.string,
21
22
  selectAllA11y: PropTypes.string,
@@ -166,7 +166,9 @@
166
166
  "upper": "Upper Bounds"
167
167
  },
168
168
  "select": {
169
+ "optionsA11y": "list of options",
169
170
  "multiple": "multiple",
171
+ "searchA11y": "Search options",
170
172
  "selected": "; Selected: {currentSelectedValue}"
171
173
  },
172
174
  "selectMultiple": {
@@ -174,6 +176,7 @@
174
176
  "clearAllA11y": "{selected} options selected. Clear all?",
175
177
  "open": "Open drop",
176
178
  "optionNotSelected": "{optionLabel} not selected",
179
+ "optionsA11y": "list of options",
177
180
  "optionSelected": "{optionLabel} selected",
178
181
  "search": "Search to filter options",
179
182
  "selectAll": "Select All",
@@ -356,6 +356,13 @@ export interface ThemeType {
356
356
  }
357
357
  | undefined;
358
358
  };
359
+ deprecated?: {
360
+ backgrounds?: { name: string; message?: string }[];
361
+ colors?: { name: string; message?: string }[];
362
+ button?: {
363
+ kind?: { name: string; message?: string }[];
364
+ };
365
+ };
359
366
  deviceBreakpoints?: {
360
367
  phone?: string;
361
368
  tablet?: string;
@@ -1466,6 +1473,7 @@ export interface ThemeType {
1466
1473
  };
1467
1474
  };
1468
1475
  meter?: {
1476
+ background?: BackgroundType;
1469
1477
  color?: ColorType;
1470
1478
  colors?: GraphColorsType;
1471
1479
  extend?: ExtendType;
@@ -1928,6 +1936,7 @@ export interface ThemeType {
1928
1936
  down?: React.ReactNode | Icon;
1929
1937
  up?: React.ReactNode | Icon;
1930
1938
  margin?: MarginType;
1939
+ search?: React.ReactNode | Icon;
1931
1940
  };
1932
1941
  listbox?: {
1933
1942
  extend?: ExtendType;
@@ -233,6 +233,28 @@ export var generate = function generate(baseSpacing, scale) {
233
233
  // might be too long depending on how fast people type, and 200ms
234
234
  // would be an eye blink
235
235
  debounceDelay: 500,
236
+ // deprecated: {
237
+ // backgrounds: [
238
+ // {
239
+ // name: string,
240
+ // message: string,
241
+ // },
242
+ // ],
243
+ // colors: [
244
+ // {
245
+ // name: string,
246
+ // message: string,
247
+ // },
248
+ // ],
249
+ // button: {
250
+ // kind: [
251
+ // {
252
+ // name: string,
253
+ // message: string,
254
+ // },
255
+ // ],
256
+ // },
257
+ // },
236
258
  drop: {
237
259
  // intelligentMargin: undefined,
238
260
  background: {
@@ -369,7 +391,7 @@ export var generate = function generate(baseSpacing, scale) {
369
391
  }
370
392
  },
371
393
  // icon: {
372
- // extennd: undefined,
394
+ // extend: undefined,
373
395
  // matchSize: undefined,
374
396
  // size: undefined,
375
397
  // },
@@ -1595,6 +1617,10 @@ export var generate = function generate(baseSpacing, scale) {
1595
1617
  }
1596
1618
  },
1597
1619
  meter: {
1620
+ background: {
1621
+ color: 'light-2',
1622
+ opacity: 'medium'
1623
+ },
1598
1624
  color: 'graph-0'
1599
1625
  // colors: [] || colors: ['graph-0', 'graph-1', 'graph-2', 'graph-3'],
1600
1626
  // extend: undefined,
@@ -1,7 +1,36 @@
1
+ // Track which deprecated colors have already been warned about
2
+ var warnedColors = new Set();
3
+ var checkColorDeprecation = function checkColorDeprecation(color, theme, dark) {
4
+ var _theme$global$depreca;
5
+ if ((_theme$global$depreca = theme.global.deprecated) != null && _theme$global$depreca.colors && process.env.NODE_ENV !== 'production') {
6
+ var colorKey = color;
7
+ if (typeof color === 'object') {
8
+ if (dark === true || dark === undefined && theme.dark) colorKey = color.dark;else colorKey = color.light;
9
+ }
10
+ if (!warnedColors.has(colorKey)) {
11
+ var deprecatedColor;
12
+ if (typeof color === 'string') {
13
+ deprecatedColor = theme.global.deprecated.colors.find(function (item) {
14
+ return item.name === color;
15
+ });
16
+ } else if (typeof color === 'object') {
17
+ deprecatedColor = theme.global.deprecated.colors.find(function (item) {
18
+ return item.name === color.light || item.name === color.dark;
19
+ });
20
+ }
21
+ if (deprecatedColor) {
22
+ warnedColors.add(colorKey);
23
+ console.warn(deprecatedColor.message || colorKey + " is deprecated.");
24
+ }
25
+ }
26
+ }
27
+ };
28
+
1
29
  // Returns the specific color that should be used according to the theme.
2
30
  // If 'dark' is supplied, it takes precedence over 'theme.dark'.
3
31
  // Can return undefined.
4
32
  var _normalizeColor = function normalizeColor(color, theme, dark) {
33
+ checkColorDeprecation(color, theme, dark);
5
34
  var colorSpec = theme.global && theme.global.colors[color] !== undefined ? theme.global.colors[color] : color;
6
35
  // If the color has a light or dark object, use that
7
36
  var result = colorSpec;