grommet 2.54.0 → 2.55.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 (79) hide show
  1. package/components/Calendar/Calendar.js +24 -16
  2. package/components/Calendar/index.d.ts +1 -1
  3. package/components/Calendar/stories/CustomHeader.stories.js +6 -1
  4. package/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
  5. package/components/Calendar/stories/Dual.stories.js +23 -11
  6. package/components/Calendar/stories/HeaderLevel.stories.js +6 -1
  7. package/components/Calendar/stories/Multiple.stories.js +8 -3
  8. package/components/Calendar/stories/Simple.stories.js +6 -1
  9. package/components/Cards/Cards.js +164 -10
  10. package/components/Cards/StyledCellContainer.js +29 -0
  11. package/components/Cards/index.d.ts +4 -1
  12. package/components/Cards/propTypes.js +2 -0
  13. package/components/Cards/stories/Sizable.stories.js +70 -0
  14. package/components/Cards/stories/onOrder.stories.js +69 -0
  15. package/components/DataFilter/DataFilter.js +21 -28
  16. package/components/DateInput/DateInput.js +57 -24
  17. package/components/DateInput/index.d.ts +1 -0
  18. package/components/DateInput/utils.js +2 -2
  19. package/components/Drop/DropContainer.js +59 -3
  20. package/components/FileInput/FileInput.js +3 -0
  21. package/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
  22. package/components/Form/stories/FieldStates.stories.js +7 -1
  23. package/components/Grommet/Grommet.js +2 -1
  24. package/components/Grommet/index.d.ts +6 -0
  25. package/components/Grommet/propTypes.js +7 -1
  26. package/components/Layer/LayerContainer.d.ts +40 -0
  27. package/components/Select/stories/ChildrenRender.stories.js +28 -55
  28. package/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
  29. package/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
  30. package/components/Tag/Tag.js +4 -3
  31. package/components/Tag/index.d.ts +5 -4
  32. package/components/Tag/propTypes.js +3 -2
  33. package/components/TextInput/StyledTextInput.js +4 -2
  34. package/components/TextInput/TextInput.js +1 -0
  35. package/es6/components/Calendar/Calendar.js +24 -16
  36. package/es6/components/Calendar/index.d.ts +1 -1
  37. package/es6/components/Calendar/stories/CustomHeader.stories.js +6 -1
  38. package/es6/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
  39. package/es6/components/Calendar/stories/Dual.stories.js +23 -11
  40. package/es6/components/Calendar/stories/HeaderLevel.stories.js +6 -1
  41. package/es6/components/Calendar/stories/Multiple.stories.js +8 -3
  42. package/es6/components/Calendar/stories/Simple.stories.js +6 -1
  43. package/es6/components/Cards/Cards.js +165 -12
  44. package/es6/components/Cards/StyledCellContainer.js +24 -0
  45. package/es6/components/Cards/index.d.ts +4 -1
  46. package/es6/components/Cards/propTypes.js +2 -0
  47. package/es6/components/Cards/stories/Sizable.stories.js +65 -0
  48. package/es6/components/Cards/stories/onOrder.stories.js +64 -0
  49. package/es6/components/DataFilter/DataFilter.js +21 -28
  50. package/es6/components/DateInput/DateInput.js +57 -24
  51. package/es6/components/DateInput/index.d.ts +1 -0
  52. package/es6/components/DateInput/utils.js +2 -2
  53. package/es6/components/Drop/DropContainer.js +59 -3
  54. package/es6/components/FileInput/FileInput.js +3 -0
  55. package/es6/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
  56. package/es6/components/Form/stories/FieldStates.stories.js +7 -1
  57. package/es6/components/Grommet/Grommet.js +2 -1
  58. package/es6/components/Grommet/index.d.ts +6 -0
  59. package/es6/components/Grommet/propTypes.js +7 -1
  60. package/es6/components/Layer/LayerContainer.d.ts +40 -0
  61. package/es6/components/Select/stories/ChildrenRender.stories.js +29 -56
  62. package/es6/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
  63. package/es6/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
  64. package/es6/components/Tag/Tag.js +4 -3
  65. package/es6/components/Tag/index.d.ts +5 -4
  66. package/es6/components/Tag/propTypes.js +3 -2
  67. package/es6/components/TextInput/StyledTextInput.js +4 -2
  68. package/es6/components/TextInput/TextInput.js +1 -0
  69. package/es6/languages/default.json +7 -1
  70. package/es6/themes/base.d.ts +1 -0
  71. package/es6/utils/index.d.ts +1 -0
  72. package/es6/utils/styles.js +23 -12
  73. package/grommet.min.js +1 -1
  74. package/grommet.min.js.map +1 -1
  75. package/languages/default.json +7 -1
  76. package/package.json +29 -32
  77. package/themes/base.d.ts +1 -0
  78. package/utils/index.d.ts +1 -0
  79. package/utils/styles.js +23 -12
@@ -0,0 +1,88 @@
1
+ import React, { useRef, useState } from 'react';
2
+
3
+ import { Box, Tag, Text } from 'grommet';
4
+ import { SelectMultiple } from '../../SelectMultiple.js';
5
+
6
+ const tags = [
7
+ 'Production',
8
+ 'Test',
9
+ 'Integration',
10
+ 'Analytics',
11
+ 'Development',
12
+ 'Staging',
13
+ 'QA',
14
+ 'UAT',
15
+ 'Performance',
16
+ 'Crash and bash',
17
+ ].sort();
18
+
19
+ export const ValueLabel = () => {
20
+ const [selected, setSelected] = useState(tags.slice(0, 3));
21
+ const valuesRef = useRef(undefined as unknown as HTMLDivElement);
22
+ const onRemoveTag = (tag: string) => {
23
+ const nextSelected = selected.filter((selectedTag) => selectedTag !== tag);
24
+ if (nextSelected.length > 0) {
25
+ const index = selected.indexOf(tag);
26
+ // update focus to the next tag's remove button
27
+ // if there is one, otherwise the previous one
28
+ const nextFocusIndex = index < nextSelected.length ? index : index - 1;
29
+ if (nextFocusIndex >= 0 && valuesRef.current) {
30
+ setTimeout(() => {
31
+ const element = valuesRef.current as HTMLElement;
32
+ const buttons = element?.querySelectorAll('button');
33
+ buttons[nextFocusIndex].focus();
34
+ }, 200);
35
+ }
36
+ }
37
+ setSelected(nextSelected);
38
+ };
39
+
40
+ return (
41
+ // Uncomment <Grommet> lines when using outside of storybook
42
+ // <Grommet theme={...}>
43
+ <Box fill align="center" pad="large" gap="large">
44
+ <Text>SelectMultiple with custom valueLabel</Text>
45
+ <SelectMultiple
46
+ showSelectedInline
47
+ placeholder="Select tag"
48
+ width="medium"
49
+ valueLabel={(options: any[]) => (
50
+ <Box
51
+ ref={valuesRef}
52
+ wrap
53
+ direction="row"
54
+ pad="xsmall"
55
+ gap="xsmall"
56
+ cssGap
57
+ >
58
+ {options && options.length &&
59
+ options.map((tag) => (
60
+ <Tag
61
+ key={`tag_${tag}`}
62
+ value={tag}
63
+ onRemove={() => onRemoveTag(tag)}
64
+ />
65
+ ))
66
+ }
67
+ </Box>
68
+ )}
69
+ options={tags}
70
+ value={selected}
71
+ onChange={({ value }: { value: string[] }) => setSelected([...value])}
72
+ />
73
+ </Box>
74
+ // </Grommet>
75
+ );
76
+ };
77
+
78
+ ValueLabel.parameters = {
79
+ chromatic: { disable: true },
80
+ };
81
+
82
+ ValueLabel.args = {
83
+ full: true,
84
+ };
85
+
86
+ export default {
87
+ title: 'Input/SelectMultiple/Value Label',
88
+ };
@@ -1,4 +1,4 @@
1
- var _excluded = ["name", "value", "size", "onRemove", "onClick", "messages"];
1
+ var _excluded = ["children", "name", "value", "size", "onRemove", "onClick", "messages"];
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
4
  import React, { useContext, forwardRef } from 'react';
@@ -11,7 +11,8 @@ import { useThemeValue } from '../../utils/useThemeValue';
11
11
  import { MessageContext } from '../../contexts/MessageContext';
12
12
  var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
13
13
  var _theme$tag$icons, _theme$tag$size, _theme$tag$size2, _theme$tag$size3, _theme$tag$size4, _theme$tag$size5;
14
- var name = _ref.name,
14
+ var children = _ref.children,
15
+ name = _ref.name,
15
16
  value = _ref.value,
16
17
  _ref$size = _ref.size,
17
18
  size = _ref$size === void 0 ? 'medium' : _ref$size,
@@ -41,7 +42,7 @@ var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
41
42
  border: theme.tag.border,
42
43
  round: ((_theme$tag$size = theme.tag.size) == null || (_theme$tag$size = _theme$tag$size[size]) == null ? void 0 : _theme$tag$size.round) || theme.tag.round
43
44
  }, rest);
44
- var contents = /*#__PURE__*/React.createElement(Box, {
45
+ var contents = children || /*#__PURE__*/React.createElement(Box, {
45
46
  width: {
46
47
  min: 'min-content'
47
48
  },
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
- import { BoxProps } from '../Box';
2
+ import { BoxExtendedProps } from '../Box';
3
3
 
4
4
  export interface TagProps {
5
- name?: string;
5
+ children?: React.ReactNode;
6
+ name?: string | React.ReactNode;
6
7
  onClick?: (...args: any[]) => any;
7
8
  onRemove?: (...args: any[]) => any;
8
9
  messages?: {
@@ -19,10 +20,10 @@ export interface TagProps {
19
20
  | 'xlarge'
20
21
  | 'xxlarge'
21
22
  | string;
22
- value: string | number;
23
+ value?: string | number | React.ReactNode;
23
24
  }
24
25
 
25
- export interface TagExtendedProps extends BoxProps, TagProps {}
26
+ export interface TagExtendedProps extends Omit<BoxExtendedProps, keyof TagProps>, TagProps {}
26
27
 
27
28
  // Keep type alias for backwards compatibility.
28
29
  export type TagType = TagProps;
@@ -2,8 +2,9 @@ import PropTypes from 'prop-types';
2
2
  var PropType = {};
3
3
  if (process.env.NODE_ENV !== 'production') {
4
4
  PropType = {
5
- name: PropTypes.string,
6
- value: PropTypes.string.isRequired,
5
+ children: PropTypes.node,
6
+ name: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
7
+ value: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
7
8
  onClick: PropTypes.func,
8
9
  onRemove: PropTypes.func,
9
10
  messages: PropTypes.shape({
@@ -24,14 +24,16 @@ var StyledTextInput = styled.input.withConfig(styledComponentsConfig).withConfig
24
24
  }, function (props) {
25
25
  return props.textAlign && textAlignStyle;
26
26
  }, function (props) {
27
- return props.widthProp && widthStyle(props.widthProp, props.theme);
27
+ return props.widthProp && !props.readOnly && widthStyle(props.widthProp, props.theme);
28
28
  }, function (props) {
29
29
  return props.theme.textInput && props.theme.textInput.extend;
30
30
  });
31
31
  var StyledTextInputContainer = styled.div.withConfig(styledComponentsConfig).withConfig({
32
32
  displayName: "StyledTextInput__StyledTextInputContainer",
33
33
  componentId: "sc-1x30a0s-1"
34
- })(["position:relative;width:100%;", ";", ";", " ", ";"], function (props) {
34
+ })(["position:relative;width:100%;", " ", ";", ";", " ", ";"], function (props) {
35
+ return props.widthProp && props.readOnlyProp && widthStyle(props.widthProp, props.theme);
36
+ }, function (props) {
35
37
  return props.readOnlyProp && !props.plain && controlBorderStyle;
36
38
  }, function (props) {
37
39
  return props.readOnlyCopy && "\n box-sizing: border-box;\n flex-direction: row;\n display: flex;\n ";
@@ -399,6 +399,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
399
399
  readOnlyCopy: readOnlyCopy,
400
400
  plain: plain,
401
401
  border: !plain,
402
+ widthProp: widthProp,
402
403
  onMouseMove: function onMouseMove() {
403
404
  return setMouseMovedSinceLastKey(true);
404
405
  }
@@ -9,6 +9,11 @@
9
9
  "nextMove": "Moved to {date}",
10
10
  "next": "Go to {date}"
11
11
  },
12
+ "cards": {
13
+ "moved": "Card moved to position {source} of {target}",
14
+ "reorderHint": "Use arrow keys to reorder cards. Changes are applied immediately.",
15
+ "description": "sortable card"
16
+ },
12
17
  "carousel": {
13
18
  "previous": "Go to slide {slide}",
14
19
  "next": "Go to slide {slide}",
@@ -17,7 +22,8 @@
17
22
  "dateInput": {
18
23
  "openCalendar": "Press space to open calendar",
19
24
  "enterCalendar": "Calendar is open, use arrow keys and enter to select a date.",
20
- "exitCalendar": "Exited calendar dialog"
25
+ "exitCalendar": "Exited calendar dialog",
26
+ "outOfBounds": "Date is out of the allowed range. Enter a date between {start} and {end}."
21
27
  },
22
28
  "dataChart": {
23
29
  "detailTitle": "Data chart",
@@ -401,6 +401,7 @@ export interface ThemeType {
401
401
  large?: string;
402
402
  xlarge?: string;
403
403
  responsiveBreakpoint?: string;
404
+ [x: string]: string | undefined;
404
405
  };
405
406
  elevation?: {
406
407
  light?: {
@@ -280,6 +280,7 @@ declare const breakpointEdgeSize: {
280
280
  medium?: string;
281
281
  large?: string;
282
282
  xlarge?: string;
283
+ [x: string]: string | undefined;
283
284
  };
284
285
  export type BreakpointEdgeSize = typeof breakpointEdgeSize;
285
286
 
@@ -30,9 +30,11 @@ export var controlBorderStyle = css(["border:", " solid ", ";border-radius:", ";
30
30
  return props.theme.global.control.border.radius;
31
31
  });
32
32
  export var edgeStyle = function edgeStyle(kind, data, responsive, responsiveBreakpoint, theme) {
33
- var breakpoint = responsiveBreakpoint && theme.global.breakpoints[responsiveBreakpoint];
33
+ var breakpoint = getBreakpointStyle(theme, responsiveBreakpoint);
34
34
  if (typeof data === 'string') {
35
- return css(["", ":", ";", ";"], kind, theme.global.edgeSize[data] || data, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + ": " + (breakpoint.edgeSize[data] || data) + ";\n ", responsive) : '');
35
+ var value = theme.global.edgeSize[data] || data;
36
+ var responsiveValue = responsive && breakpoint && breakpoint.edgeSize[data];
37
+ return css(["", ":", ";", ";"], kind, value, responsiveValue ? breakpointStyle(breakpoint, "\n " + kind + ": " + responsiveValue + ";\n ", responsive) : '');
36
38
  }
37
39
  var result = [];
38
40
  var horizontal = data.horizontal,
@@ -50,32 +52,41 @@ export var edgeStyle = function edgeStyle(kind, data, responsive, responsiveBrea
50
52
  if (horizontalVerticalEqual || allSidesEqual) {
51
53
  // since the values will be the same between vertical & horizontal OR
52
54
  // left, right, top, & bottom, we can just choose one
53
- var value = horizontalVerticalEqual ? horizontal : top;
54
- return css(["", ":", ";", ";"], kind, theme.global.edgeSize[value] || value, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + ": " + (breakpoint.edgeSize[value] || value) + ";\n ", responsive) : '');
55
+ var allSidesValue = horizontalVerticalEqual ? horizontal : top;
56
+ var allSidesResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[allSidesValue];
57
+ return css(["", ":", ";", ";"], kind, theme.global.edgeSize[allSidesValue] || allSidesValue, allSidesResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + ": " + allSidesResponsiveValue + ";\n ", responsive) : '');
55
58
  }
56
59
  if (horizontal) {
57
- result.push(css(["", "-left:", ";", "-right:", ";", ";"], kind, theme.global.edgeSize[horizontal] || horizontal, kind, theme.global.edgeSize[horizontal] || horizontal, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-left: " + (breakpoint.edgeSize[horizontal] || horizontal) + ";\n " + kind + "-right: " + (breakpoint.edgeSize[horizontal] || horizontal) + ";\n ", responsive) : ''));
60
+ var horizontalResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[horizontal];
61
+ result.push(css(["", "-left:", ";", "-right:", ";", ";"], kind, theme.global.edgeSize[horizontal] || horizontal, kind, theme.global.edgeSize[horizontal] || horizontal, horizontalResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-left: " + horizontalResponsiveValue + ";\n " + kind + "-right: " + horizontalResponsiveValue + ";\n ", responsive) : ''));
58
62
  }
59
63
  if (vertical) {
60
- result.push(css(["", "-top:", ";", "-bottom:", ";", ";"], kind, theme.global.edgeSize[vertical] || vertical, kind, theme.global.edgeSize[vertical] || vertical, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-top: " + (breakpoint.edgeSize[vertical] || vertical) + ";\n " + kind + "-bottom: " + (breakpoint.edgeSize[vertical] || vertical) + ";\n ", responsive) : ''));
64
+ var verticalResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[vertical];
65
+ result.push(css(["", "-top:", ";", "-bottom:", ";", ";"], kind, theme.global.edgeSize[vertical] || vertical, kind, theme.global.edgeSize[vertical] || vertical, verticalResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-top: " + verticalResponsiveValue + ";\n " + kind + "-bottom: " + verticalResponsiveValue + ";\n ", responsive) : ''));
61
66
  }
62
67
  if (top) {
63
- result.push(css(["", "-top:", ";", ";"], kind, theme.global.edgeSize[top] || top, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-top: " + (breakpoint.edgeSize[top] || top) + ";\n ", responsive) : ''));
68
+ var topResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[top];
69
+ result.push(css(["", "-top:", ";", ";"], kind, theme.global.edgeSize[top] || top, topResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-top: " + topResponsiveValue + ";\n ", responsive) : ''));
64
70
  }
65
71
  if (bottom) {
66
- result.push(css(["", "-bottom:", ";", ";"], kind, theme.global.edgeSize[bottom] || bottom, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-bottom: " + (breakpoint.edgeSize[bottom] || bottom) + ";\n ", responsive) : ''));
72
+ var bottomResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[bottom];
73
+ result.push(css(["", "-bottom:", ";", ";"], kind, theme.global.edgeSize[bottom] || bottom, bottomResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-bottom: " + bottomResponsiveValue + ";\n ", responsive) : ''));
67
74
  }
68
75
  if (left) {
69
- result.push(css(["", "-left:", ";", ";"], kind, theme.global.edgeSize[left] || left, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-left: " + (breakpoint.edgeSize[left] || left) + ";\n ", responsive) : ''));
76
+ var leftResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[left];
77
+ result.push(css(["", "-left:", ";", ";"], kind, theme.global.edgeSize[left] || left, leftResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-left: " + leftResponsiveValue + ";\n ", responsive) : ''));
70
78
  }
71
79
  if (right) {
72
- result.push(css(["", "-right:", ";", ";"], kind, theme.global.edgeSize[right] || right, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-right: " + (breakpoint.edgeSize[right] || right) + ";\n ", responsive) : ''));
80
+ var rightResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[right];
81
+ result.push(css(["", "-right:", ";", ";"], kind, theme.global.edgeSize[right] || right, rightResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-right: " + rightResponsiveValue + ";\n ", responsive) : ''));
73
82
  }
74
83
  if (data.start) {
75
- result.push(css(["", "-inline-start:", ";", ";"], kind, theme.global.edgeSize[data.start] || data.start, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-inline-start: " + (breakpoint.edgeSize[data.start] || data.start) + ";\n ", responsive) : ''));
84
+ var startResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[data.start];
85
+ result.push(css(["", "-inline-start:", ";", ";"], kind, theme.global.edgeSize[data.start] || data.start, startResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-inline-start: " + startResponsiveValue + ";\n ", responsive) : ''));
76
86
  }
77
87
  if (data.end) {
78
- result.push(css(["", "-inline-end:", ";", ";"], kind, theme.global.edgeSize[data.end] || data.end, responsive && breakpoint ? breakpointStyle(breakpoint, "\n " + kind + "-inline-end: " + (breakpoint.edgeSize[data.end] || data.end) + ";\n ", responsive) : ''));
88
+ var endResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[data.end];
89
+ result.push(css(["", "-inline-end:", ";", ";"], kind, theme.global.edgeSize[data.end] || data.end, endResponsiveValue ? breakpointStyle(breakpoint, "\n " + kind + "-inline-end: " + endResponsiveValue + ";\n ", responsive) : ''));
79
90
  }
80
91
  return result;
81
92
  };