grommet 2.54.0 → 2.56.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 (177) hide show
  1. package/components/Button/Button.js +7 -4
  2. package/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +86 -0
  3. package/components/Calendar/Calendar.js +24 -16
  4. package/components/Calendar/index.d.ts +1 -1
  5. package/components/Calendar/stories/CustomHeader.stories.js +6 -1
  6. package/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
  7. package/components/Calendar/stories/Dual.stories.js +23 -11
  8. package/components/Calendar/stories/HeaderLevel.stories.js +6 -1
  9. package/components/Calendar/stories/Multiple.stories.js +8 -3
  10. package/components/Calendar/stories/Simple.stories.js +6 -1
  11. package/components/Cards/Cards.js +164 -10
  12. package/components/Cards/StyledCellContainer.js +29 -0
  13. package/components/Cards/index.d.ts +4 -1
  14. package/components/Cards/propTypes.js +2 -0
  15. package/components/Cards/stories/Sizable.stories.js +70 -0
  16. package/components/Cards/stories/onOrder.stories.js +69 -0
  17. package/components/DataFilter/DataFilter.js +21 -28
  18. package/components/DateInput/DateInput.js +57 -24
  19. package/components/DateInput/index.d.ts +1 -0
  20. package/components/DateInput/utils.js +2 -2
  21. package/components/Drop/DropContainer.js +59 -3
  22. package/components/FileInput/FileInput.js +3 -0
  23. package/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
  24. package/components/Form/stories/FieldStates.stories.js +7 -1
  25. package/components/FormField/FormField.js +1 -1
  26. package/components/Grommet/Grommet.js +2 -1
  27. package/components/Grommet/index.d.ts +27 -0
  28. package/components/Grommet/propTypes.js +33 -1
  29. package/components/Layer/LayerContainer.d.ts +40 -0
  30. package/components/Select/stories/ChildrenRender.stories.js +28 -55
  31. package/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
  32. package/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
  33. package/components/Stepper/StepConnector.js +68 -0
  34. package/components/Stepper/Stepper.js +309 -0
  35. package/components/Stepper/StepperContext.js +43 -0
  36. package/components/Stepper/StepperDescription.js +26 -0
  37. package/components/Stepper/StepperHelperText.js +44 -0
  38. package/components/Stepper/StepperIndicator.js +74 -0
  39. package/components/Stepper/StepperLabel.js +41 -0
  40. package/components/Stepper/StepperStep.js +127 -0
  41. package/components/Stepper/StyledStepper.js +124 -0
  42. package/components/Stepper/index.d.ts +80 -0
  43. package/components/Stepper/index.js +18 -0
  44. package/components/Stepper/propTypes.js +35 -0
  45. package/components/Stepper/stories/DisabledSteps.stories.js +45 -0
  46. package/components/Stepper/stories/ErrorStates.stories.js +45 -0
  47. package/components/Stepper/stories/HorizontalSteps.stories.js +50 -0
  48. package/components/Stepper/stories/Interactive.stories.js +60 -0
  49. package/components/Stepper/stories/KeyboardNavigation.stories.js +64 -0
  50. package/components/Stepper/stories/NestedSubSteps.stories.js +70 -0
  51. package/components/Stepper/stories/ReadOnly.stories.js +43 -0
  52. package/components/Stepper/stories/ThemingLightDark.stories.js +58 -0
  53. package/components/Stepper/stories/VerticalSteps.stories.js +67 -0
  54. package/components/Tab/Tab.js +19 -6
  55. package/components/Tabs/Tabs.js +156 -22
  56. package/components/Tag/Tag.js +4 -3
  57. package/components/Tag/index.d.ts +5 -4
  58. package/components/Tag/propTypes.js +3 -2
  59. package/components/TextInput/StyledTextInput.js +4 -2
  60. package/components/TextInput/TextInput.js +1 -0
  61. package/components/TimeInput/README.md +2 -0
  62. package/components/TimeInput/StyledTimeInput.js +73 -0
  63. package/components/TimeInput/TimeInput.js +689 -0
  64. package/components/TimeInput/TimeInputPopup.js +393 -0
  65. package/components/TimeInput/index.d.ts +41 -0
  66. package/components/TimeInput/index.js +6 -0
  67. package/components/TimeInput/propTypes.js +35 -0
  68. package/components/TimeInput/stories/Controlled.stories.tsx +29 -0
  69. package/components/TimeInput/stories/Disabled.stories.tsx +13 -0
  70. package/components/TimeInput/stories/Form.stories.tsx +38 -0
  71. package/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
  72. package/components/TimeInput/stories/Simple.stories.tsx +19 -0
  73. package/components/TimeInput/stories/Step.stories.tsx +14 -0
  74. package/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
  75. package/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
  76. package/components/TimeInput/useSectionedTimeField.js +359 -0
  77. package/components/TimeInput/utils.js +187 -0
  78. package/components/index.d.ts +2 -0
  79. package/components/index.js +12 -0
  80. package/es6/components/Button/Button.js +7 -4
  81. package/es6/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +81 -0
  82. package/es6/components/Calendar/Calendar.js +24 -16
  83. package/es6/components/Calendar/index.d.ts +1 -1
  84. package/es6/components/Calendar/stories/CustomHeader.stories.js +6 -1
  85. package/es6/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
  86. package/es6/components/Calendar/stories/Dual.stories.js +23 -11
  87. package/es6/components/Calendar/stories/HeaderLevel.stories.js +6 -1
  88. package/es6/components/Calendar/stories/Multiple.stories.js +8 -3
  89. package/es6/components/Calendar/stories/Simple.stories.js +6 -1
  90. package/es6/components/Cards/Cards.js +165 -12
  91. package/es6/components/Cards/StyledCellContainer.js +24 -0
  92. package/es6/components/Cards/index.d.ts +4 -1
  93. package/es6/components/Cards/propTypes.js +2 -0
  94. package/es6/components/Cards/stories/Sizable.stories.js +65 -0
  95. package/es6/components/Cards/stories/onOrder.stories.js +64 -0
  96. package/es6/components/DataFilter/DataFilter.js +21 -28
  97. package/es6/components/DateInput/DateInput.js +57 -24
  98. package/es6/components/DateInput/index.d.ts +1 -0
  99. package/es6/components/DateInput/utils.js +2 -2
  100. package/es6/components/Drop/DropContainer.js +59 -3
  101. package/es6/components/FileInput/FileInput.js +3 -0
  102. package/es6/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
  103. package/es6/components/Form/stories/FieldStates.stories.js +7 -1
  104. package/es6/components/FormField/FormField.js +1 -1
  105. package/es6/components/Grommet/Grommet.js +2 -1
  106. package/es6/components/Grommet/index.d.ts +27 -0
  107. package/es6/components/Grommet/propTypes.js +33 -1
  108. package/es6/components/Layer/LayerContainer.d.ts +40 -0
  109. package/es6/components/Select/stories/ChildrenRender.stories.js +29 -56
  110. package/es6/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
  111. package/es6/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
  112. package/es6/components/Stepper/StepConnector.js +63 -0
  113. package/es6/components/Stepper/Stepper.js +306 -0
  114. package/es6/components/Stepper/StepperContext.js +39 -0
  115. package/es6/components/Stepper/StepperDescription.js +21 -0
  116. package/es6/components/Stepper/StepperHelperText.js +39 -0
  117. package/es6/components/Stepper/StepperIndicator.js +69 -0
  118. package/es6/components/Stepper/StepperLabel.js +36 -0
  119. package/es6/components/Stepper/StepperStep.js +122 -0
  120. package/es6/components/Stepper/StyledStepper.js +120 -0
  121. package/es6/components/Stepper/index.d.ts +80 -0
  122. package/es6/components/Stepper/index.js +6 -0
  123. package/es6/components/Stepper/propTypes.js +30 -0
  124. package/es6/components/Stepper/stories/DisabledSteps.stories.js +41 -0
  125. package/es6/components/Stepper/stories/ErrorStates.stories.js +41 -0
  126. package/es6/components/Stepper/stories/HorizontalSteps.stories.js +46 -0
  127. package/es6/components/Stepper/stories/Interactive.stories.js +56 -0
  128. package/es6/components/Stepper/stories/KeyboardNavigation.stories.js +60 -0
  129. package/es6/components/Stepper/stories/NestedSubSteps.stories.js +66 -0
  130. package/es6/components/Stepper/stories/ReadOnly.stories.js +39 -0
  131. package/es6/components/Stepper/stories/ThemingLightDark.stories.js +54 -0
  132. package/es6/components/Stepper/stories/VerticalSteps.stories.js +63 -0
  133. package/es6/components/Tab/Tab.js +19 -6
  134. package/es6/components/Tabs/Tabs.js +157 -23
  135. package/es6/components/Tag/Tag.js +4 -3
  136. package/es6/components/Tag/index.d.ts +5 -4
  137. package/es6/components/Tag/propTypes.js +3 -2
  138. package/es6/components/TextInput/StyledTextInput.js +4 -2
  139. package/es6/components/TextInput/TextInput.js +1 -0
  140. package/es6/components/TimeInput/README.md +2 -0
  141. package/es6/components/TimeInput/StyledTimeInput.js +68 -0
  142. package/es6/components/TimeInput/TimeInput.js +685 -0
  143. package/es6/components/TimeInput/TimeInputPopup.js +389 -0
  144. package/es6/components/TimeInput/index.d.ts +41 -0
  145. package/es6/components/TimeInput/index.js +1 -0
  146. package/es6/components/TimeInput/propTypes.js +30 -0
  147. package/es6/components/TimeInput/stories/Controlled.stories.tsx +29 -0
  148. package/es6/components/TimeInput/stories/Disabled.stories.tsx +13 -0
  149. package/es6/components/TimeInput/stories/Form.stories.tsx +38 -0
  150. package/es6/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
  151. package/es6/components/TimeInput/stories/Simple.stories.tsx +19 -0
  152. package/es6/components/TimeInput/stories/Step.stories.tsx +14 -0
  153. package/es6/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
  154. package/es6/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
  155. package/es6/components/TimeInput/useSectionedTimeField.js +356 -0
  156. package/es6/components/TimeInput/utils.js +183 -0
  157. package/es6/components/index.d.ts +2 -0
  158. package/es6/components/index.js +2 -0
  159. package/es6/index.d.ts +2 -0
  160. package/es6/languages/default.json +27 -1
  161. package/es6/themes/base.d.ts +109 -0
  162. package/es6/themes/base.js +208 -0
  163. package/es6/utils/index.d.ts +1 -0
  164. package/es6/utils/styles.js +23 -12
  165. package/grommet.min.js +1 -1
  166. package/grommet.min.js.map +1 -1
  167. package/index.d.ts +2 -0
  168. package/languages/default.json +27 -1
  169. package/package.json +51 -53
  170. package/themes/base.d.ts +109 -0
  171. package/themes/base.js +208 -0
  172. package/utils/index.d.ts +1 -0
  173. package/utils/styles.js +23 -12
  174. package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
  175. package/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -79
  176. package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
  177. package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -74
package/utils/styles.js CHANGED
@@ -34,9 +34,11 @@ var controlBorderStyle = exports.controlBorderStyle = (0, _styledComponents.css)
34
34
  return props.theme.global.control.border.radius;
35
35
  });
36
36
  var edgeStyle = exports.edgeStyle = function edgeStyle(kind, data, responsive, responsiveBreakpoint, theme) {
37
- var breakpoint = responsiveBreakpoint && theme.global.breakpoints[responsiveBreakpoint];
37
+ var breakpoint = (0, _responsive.getBreakpointStyle)(theme, responsiveBreakpoint);
38
38
  if (typeof data === 'string') {
39
- return (0, _styledComponents.css)(["", ":", ";", ";"], kind, theme.global.edgeSize[data] || data, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + ": " + (breakpoint.edgeSize[data] || data) + ";\n ", responsive) : '');
39
+ var value = theme.global.edgeSize[data] || data;
40
+ var responsiveValue = responsive && breakpoint && breakpoint.edgeSize[data];
41
+ return (0, _styledComponents.css)(["", ":", ";", ";"], kind, value, responsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + ": " + responsiveValue + ";\n ", responsive) : '');
40
42
  }
41
43
  var result = [];
42
44
  var horizontal = data.horizontal,
@@ -54,32 +56,41 @@ var edgeStyle = exports.edgeStyle = function edgeStyle(kind, data, responsive, r
54
56
  if (horizontalVerticalEqual || allSidesEqual) {
55
57
  // since the values will be the same between vertical & horizontal OR
56
58
  // left, right, top, & bottom, we can just choose one
57
- var value = horizontalVerticalEqual ? horizontal : top;
58
- return (0, _styledComponents.css)(["", ":", ";", ";"], kind, theme.global.edgeSize[value] || value, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + ": " + (breakpoint.edgeSize[value] || value) + ";\n ", responsive) : '');
59
+ var allSidesValue = horizontalVerticalEqual ? horizontal : top;
60
+ var allSidesResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[allSidesValue];
61
+ return (0, _styledComponents.css)(["", ":", ";", ";"], kind, theme.global.edgeSize[allSidesValue] || allSidesValue, allSidesResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + ": " + allSidesResponsiveValue + ";\n ", responsive) : '');
59
62
  }
60
63
  if (horizontal) {
61
- result.push((0, _styledComponents.css)(["", "-left:", ";", "-right:", ";", ";"], kind, theme.global.edgeSize[horizontal] || horizontal, kind, theme.global.edgeSize[horizontal] || horizontal, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-left: " + (breakpoint.edgeSize[horizontal] || horizontal) + ";\n " + kind + "-right: " + (breakpoint.edgeSize[horizontal] || horizontal) + ";\n ", responsive) : ''));
64
+ var horizontalResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[horizontal];
65
+ result.push((0, _styledComponents.css)(["", "-left:", ";", "-right:", ";", ";"], kind, theme.global.edgeSize[horizontal] || horizontal, kind, theme.global.edgeSize[horizontal] || horizontal, horizontalResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-left: " + horizontalResponsiveValue + ";\n " + kind + "-right: " + horizontalResponsiveValue + ";\n ", responsive) : ''));
62
66
  }
63
67
  if (vertical) {
64
- result.push((0, _styledComponents.css)(["", "-top:", ";", "-bottom:", ";", ";"], kind, theme.global.edgeSize[vertical] || vertical, kind, theme.global.edgeSize[vertical] || vertical, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-top: " + (breakpoint.edgeSize[vertical] || vertical) + ";\n " + kind + "-bottom: " + (breakpoint.edgeSize[vertical] || vertical) + ";\n ", responsive) : ''));
68
+ var verticalResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[vertical];
69
+ result.push((0, _styledComponents.css)(["", "-top:", ";", "-bottom:", ";", ";"], kind, theme.global.edgeSize[vertical] || vertical, kind, theme.global.edgeSize[vertical] || vertical, verticalResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-top: " + verticalResponsiveValue + ";\n " + kind + "-bottom: " + verticalResponsiveValue + ";\n ", responsive) : ''));
65
70
  }
66
71
  if (top) {
67
- result.push((0, _styledComponents.css)(["", "-top:", ";", ";"], kind, theme.global.edgeSize[top] || top, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-top: " + (breakpoint.edgeSize[top] || top) + ";\n ", responsive) : ''));
72
+ var topResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[top];
73
+ result.push((0, _styledComponents.css)(["", "-top:", ";", ";"], kind, theme.global.edgeSize[top] || top, topResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-top: " + topResponsiveValue + ";\n ", responsive) : ''));
68
74
  }
69
75
  if (bottom) {
70
- result.push((0, _styledComponents.css)(["", "-bottom:", ";", ";"], kind, theme.global.edgeSize[bottom] || bottom, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-bottom: " + (breakpoint.edgeSize[bottom] || bottom) + ";\n ", responsive) : ''));
76
+ var bottomResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[bottom];
77
+ result.push((0, _styledComponents.css)(["", "-bottom:", ";", ";"], kind, theme.global.edgeSize[bottom] || bottom, bottomResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-bottom: " + bottomResponsiveValue + ";\n ", responsive) : ''));
71
78
  }
72
79
  if (left) {
73
- result.push((0, _styledComponents.css)(["", "-left:", ";", ";"], kind, theme.global.edgeSize[left] || left, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-left: " + (breakpoint.edgeSize[left] || left) + ";\n ", responsive) : ''));
80
+ var leftResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[left];
81
+ result.push((0, _styledComponents.css)(["", "-left:", ";", ";"], kind, theme.global.edgeSize[left] || left, leftResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-left: " + leftResponsiveValue + ";\n ", responsive) : ''));
74
82
  }
75
83
  if (right) {
76
- result.push((0, _styledComponents.css)(["", "-right:", ";", ";"], kind, theme.global.edgeSize[right] || right, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-right: " + (breakpoint.edgeSize[right] || right) + ";\n ", responsive) : ''));
84
+ var rightResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[right];
85
+ result.push((0, _styledComponents.css)(["", "-right:", ";", ";"], kind, theme.global.edgeSize[right] || right, rightResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-right: " + rightResponsiveValue + ";\n ", responsive) : ''));
77
86
  }
78
87
  if (data.start) {
79
- result.push((0, _styledComponents.css)(["", "-inline-start:", ";", ";"], kind, theme.global.edgeSize[data.start] || data.start, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-inline-start: " + (breakpoint.edgeSize[data.start] || data.start) + ";\n ", responsive) : ''));
88
+ var startResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[data.start];
89
+ result.push((0, _styledComponents.css)(["", "-inline-start:", ";", ";"], kind, theme.global.edgeSize[data.start] || data.start, startResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-inline-start: " + startResponsiveValue + ";\n ", responsive) : ''));
80
90
  }
81
91
  if (data.end) {
82
- result.push((0, _styledComponents.css)(["", "-inline-end:", ";", ";"], kind, theme.global.edgeSize[data.end] || data.end, responsive && breakpoint ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-inline-end: " + (breakpoint.edgeSize[data.end] || data.end) + ";\n ", responsive) : ''));
92
+ var endResponsiveValue = responsive && breakpoint && breakpoint.edgeSize[data.end];
93
+ result.push((0, _styledComponents.css)(["", "-inline-end:", ";", ";"], kind, theme.global.edgeSize[data.end] || data.end, endResponsiveValue ? (0, _mixins.breakpointStyle)(breakpoint, "\n " + kind + "-inline-end: " + endResponsiveValue + ";\n ", responsive) : ''));
83
94
  }
84
95
  return result;
85
96
  };
@@ -1,180 +0,0 @@
1
- import React, { useCallback, useMemo, useRef, useState } from 'react';
2
-
3
- import { Search } from 'grommet-icons';
4
- import { Box, Grommet, Image, Text, TextInput } from 'grommet';
5
- import { grommet, ThemeType } from 'grommet/themes';
6
- import { deepMerge } from 'grommet/utils';
7
-
8
- // Type annotations can only be used in TypeScript files.
9
- // Remove ': ThemeType' if you are not using Typescript.
10
- const myCustomTheme: ThemeType = deepMerge(grommet, {
11
- global: {
12
- drop: {
13
- background: '#444444',
14
- shadowSize: 'medium',
15
- extend: `
16
- border-bottom-left-radius: 12px;
17
- border-bottom-right-radius: 12px;
18
- overflow: hidden;
19
- `,
20
- },
21
- elevation: {
22
- dark: {
23
- medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
24
- },
25
- light: {
26
- medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
27
- },
28
- },
29
- font: {
30
- size: '14px',
31
- family: 'Arial',
32
- },
33
- input: {
34
- weight: 400,
35
- },
36
- },
37
- });
38
-
39
- const folks = [
40
- {
41
- name: 'Alan Souza',
42
- imageUrl:
43
- 'https://s.gravatar.com/avatar/b226da5c619b18b44eb95c30be393953?s=80',
44
- },
45
- {
46
- name: 'Bryan Jacquot',
47
- imageUrl:
48
- 'https://s.gravatar.com/avatar/10d15019166606cfed23846a7f902660?s=80',
49
- },
50
- {
51
- name: 'Chris Carlozzi',
52
- imageUrl:
53
- 'https://s.gravatar.com/avatar/56ea1e2ecd0d3cc85479b2d09e31d071?s=80',
54
- },
55
- {
56
- name: 'Eric Soderberg',
57
- imageUrl:
58
- 'https://s.gravatar.com/avatar/99020cae7ff399a4fbea19c0634f77c3?s=80',
59
- },
60
- {
61
- name: 'Marlon Parizzotto',
62
- imageUrl:
63
- 'https://s.gravatar.com/avatar/e6684969375a4dcc0aa99f0bfae544c3?s=80',
64
- },
65
- {
66
- name: 'Tales Chaves',
67
- imageUrl:
68
- 'https://s.gravatar.com/avatar/1f80adca55d9f5d97932ff97f631a4e8?s=80',
69
- },
70
- {
71
- name: 'Tracy Barmore',
72
- imageUrl:
73
- 'https://s.gravatar.com/avatar/4ec9c3a91da89f278e4482811caad7f3?s=80',
74
- },
75
- ];
76
-
77
- const formatSuggestions = (suggestedFolks, value) =>
78
- suggestedFolks
79
- .filter(({ name }) => name.toLowerCase().indexOf(value.toLowerCase()) >= 0)
80
- .map(({ name, imageUrl }, index, list) => ({
81
- label: (
82
- <Box
83
- direction="row"
84
- align="center"
85
- gap="small"
86
- border={index < list.length - 1 ? 'bottom' : undefined}
87
- pad="small"
88
- >
89
- <Image width="48px" src={imageUrl} style={{ borderRadius: '100%' }} />
90
- <Text>
91
- <strong>{name}</strong>
92
- </Text>
93
- </Box>
94
- ),
95
- value: name,
96
- }));
97
-
98
- export const CustomSuggestions = () => {
99
- const [value, setValue] = useState('');
100
- const [suggestionOpen, setSuggestionOpen] = useState(false);
101
- const [suggestions, setSuggestions] = useState([]);
102
- const boxRef = useRef(undefined);
103
-
104
- const onChange = useCallback((event) => {
105
- const { value: newValue } = event.target;
106
- setValue(newValue);
107
-
108
- if (!newValue.trim()) {
109
- setSuggestions([]);
110
- } else {
111
- // simulate an async call to the backend
112
- setTimeout(() => {
113
- setSuggestions(formatSuggestions(folks, newValue));
114
- }, 300);
115
- }
116
- }, []);
117
-
118
- const onSuggestionSelect = useCallback(
119
- (event) => setValue(event.suggestion.value),
120
- [],
121
- );
122
-
123
- const onSuggestionsOpen = useCallback(() => {
124
- setSuggestions(formatSuggestions(folks, value));
125
- setSuggestionOpen(true);
126
- }, [value]);
127
-
128
- const onSuggestionsClose = useCallback(() => {
129
- setSuggestions([]);
130
- setSuggestionOpen(false);
131
- }, []);
132
-
133
- return (
134
- <Grommet full theme={myCustomTheme}>
135
- <Box background="dark-1" fill align="center" pad={{ top: 'large' }}>
136
- <Box
137
- ref={boxRef}
138
- width="large"
139
- direction="row"
140
- align="center"
141
- pad={{ horizontal: 'small', vertical: 'xsmall' }}
142
- round="small"
143
- elevation={suggestionOpen ? 'medium' : undefined}
144
- border={{
145
- side: 'all',
146
- color: suggestionOpen ? 'transparent' : 'border',
147
- }}
148
- style={
149
- suggestionOpen
150
- ? {
151
- borderBottomLeftRadius: '0px',
152
- borderBottomRightRadius: '0px',
153
- }
154
- : undefined
155
- }
156
- >
157
- <Search color="brand" />
158
- <TextInput
159
- id="grommet-custom-suggestions"
160
- dropTarget={boxRef.current}
161
- placeholder="Enter your name..."
162
- plain
163
- suggestions={suggestions}
164
- value={value}
165
- onChange={onChange}
166
- onSuggestionsOpen={onSuggestionsOpen}
167
- onSuggestionsClose={onSuggestionsClose}
168
- onSuggestionSelect={onSuggestionSelect}
169
- />
170
- </Box>
171
- </Box>
172
- </Grommet>
173
- );
174
- };
175
-
176
- CustomSuggestions.storyName = 'Custom suggestions';
177
-
178
- export default {
179
- title: 'Input/TextInput/Custom Themed/Custom suggestions',
180
- };
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = exports.Themed = void 0;
5
- var _react = _interopRequireDefault(require("react"));
6
- var _grommet = require("grommet");
7
- var _themes = require("grommet/themes");
8
- var _utils = require("grommet/utils");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
- var suggestions = Array(100).fill().map(function (_, i) {
11
- return "suggestion " + (i + 1);
12
- });
13
- var customTheme = (0, _utils.deepMerge)(_themes.grommet, {
14
- global: {
15
- input: {
16
- padding: {
17
- horizontal: 'small',
18
- vertical: 'medium'
19
- }
20
- }
21
- },
22
- textInput: {
23
- extend: function extend() {
24
- return "\n font-size: 20px;\n background: #c9c19f;\n width: 300px;\n margin: 0 auto;\n\n &:focus {\n box-shadow: none;\n border-color: initial;\n }\n ";
25
- },
26
- container: {
27
- extend: function extend() {
28
- return "\n background: #edf7d2;\n height: 100px;\n width: 400px;\n display: flex;\n flex-flow: column;\n justify-content: center;\n border-radius: 10px;\n ";
29
- }
30
- },
31
- placeholder: {
32
- extend: function extend() {
33
- return "\n width: 100%;\n color: #1e1a11;\n ";
34
- }
35
- },
36
- suggestions: {
37
- extend: function extend() {
38
- return "\n background: #c9c19f;\n color: #3d3522;\n li {\n border-bottom: 1px solid rgba(0, 0, 0, 0.2);\n }\n ";
39
- }
40
- }
41
- }
42
- });
43
- var Themed = exports.Themed = function Themed() {
44
- var _React$useState = _react["default"].useState(''),
45
- value = _React$useState[0],
46
- setValue = _React$useState[1];
47
- var onChange = function onChange(event) {
48
- return setValue(event.target.value);
49
- };
50
- var onSelect = function onSelect(event) {
51
- return setValue(event.suggestion);
52
- };
53
- return /*#__PURE__*/_react["default"].createElement(_grommet.Grommet, {
54
- full: true,
55
- theme: customTheme
56
- }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
57
- fill: true,
58
- align: "center",
59
- justify: "start",
60
- pad: "large"
61
- }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
62
- width: "medium"
63
- }, /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
64
- id: "grommet-password",
65
- type: "password",
66
- value: value,
67
- dropProps: {
68
- height: 'small'
69
- },
70
- onChange: onChange,
71
- onSelect: onSelect,
72
- suggestions: suggestions,
73
- placeholder: /*#__PURE__*/_react["default"].createElement("span", null, "Enter something..."),
74
- "aria-label": "Input Text"
75
- }))));
76
- };
77
- var _default = exports["default"] = {
78
- title: 'Input/TextInput/Custom Themed/Themed'
79
- };
@@ -1,180 +0,0 @@
1
- import React, { useCallback, useMemo, useRef, useState } from 'react';
2
-
3
- import { Search } from 'grommet-icons';
4
- import { Box, Grommet, Image, Text, TextInput } from 'grommet';
5
- import { grommet, ThemeType } from 'grommet/themes';
6
- import { deepMerge } from 'grommet/utils';
7
-
8
- // Type annotations can only be used in TypeScript files.
9
- // Remove ': ThemeType' if you are not using Typescript.
10
- const myCustomTheme: ThemeType = deepMerge(grommet, {
11
- global: {
12
- drop: {
13
- background: '#444444',
14
- shadowSize: 'medium',
15
- extend: `
16
- border-bottom-left-radius: 12px;
17
- border-bottom-right-radius: 12px;
18
- overflow: hidden;
19
- `,
20
- },
21
- elevation: {
22
- dark: {
23
- medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
24
- },
25
- light: {
26
- medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
27
- },
28
- },
29
- font: {
30
- size: '14px',
31
- family: 'Arial',
32
- },
33
- input: {
34
- weight: 400,
35
- },
36
- },
37
- });
38
-
39
- const folks = [
40
- {
41
- name: 'Alan Souza',
42
- imageUrl:
43
- 'https://s.gravatar.com/avatar/b226da5c619b18b44eb95c30be393953?s=80',
44
- },
45
- {
46
- name: 'Bryan Jacquot',
47
- imageUrl:
48
- 'https://s.gravatar.com/avatar/10d15019166606cfed23846a7f902660?s=80',
49
- },
50
- {
51
- name: 'Chris Carlozzi',
52
- imageUrl:
53
- 'https://s.gravatar.com/avatar/56ea1e2ecd0d3cc85479b2d09e31d071?s=80',
54
- },
55
- {
56
- name: 'Eric Soderberg',
57
- imageUrl:
58
- 'https://s.gravatar.com/avatar/99020cae7ff399a4fbea19c0634f77c3?s=80',
59
- },
60
- {
61
- name: 'Marlon Parizzotto',
62
- imageUrl:
63
- 'https://s.gravatar.com/avatar/e6684969375a4dcc0aa99f0bfae544c3?s=80',
64
- },
65
- {
66
- name: 'Tales Chaves',
67
- imageUrl:
68
- 'https://s.gravatar.com/avatar/1f80adca55d9f5d97932ff97f631a4e8?s=80',
69
- },
70
- {
71
- name: 'Tracy Barmore',
72
- imageUrl:
73
- 'https://s.gravatar.com/avatar/4ec9c3a91da89f278e4482811caad7f3?s=80',
74
- },
75
- ];
76
-
77
- const formatSuggestions = (suggestedFolks, value) =>
78
- suggestedFolks
79
- .filter(({ name }) => name.toLowerCase().indexOf(value.toLowerCase()) >= 0)
80
- .map(({ name, imageUrl }, index, list) => ({
81
- label: (
82
- <Box
83
- direction="row"
84
- align="center"
85
- gap="small"
86
- border={index < list.length - 1 ? 'bottom' : undefined}
87
- pad="small"
88
- >
89
- <Image width="48px" src={imageUrl} style={{ borderRadius: '100%' }} />
90
- <Text>
91
- <strong>{name}</strong>
92
- </Text>
93
- </Box>
94
- ),
95
- value: name,
96
- }));
97
-
98
- export const CustomSuggestions = () => {
99
- const [value, setValue] = useState('');
100
- const [suggestionOpen, setSuggestionOpen] = useState(false);
101
- const [suggestions, setSuggestions] = useState([]);
102
- const boxRef = useRef(undefined);
103
-
104
- const onChange = useCallback((event) => {
105
- const { value: newValue } = event.target;
106
- setValue(newValue);
107
-
108
- if (!newValue.trim()) {
109
- setSuggestions([]);
110
- } else {
111
- // simulate an async call to the backend
112
- setTimeout(() => {
113
- setSuggestions(formatSuggestions(folks, newValue));
114
- }, 300);
115
- }
116
- }, []);
117
-
118
- const onSuggestionSelect = useCallback(
119
- (event) => setValue(event.suggestion.value),
120
- [],
121
- );
122
-
123
- const onSuggestionsOpen = useCallback(() => {
124
- setSuggestions(formatSuggestions(folks, value));
125
- setSuggestionOpen(true);
126
- }, [value]);
127
-
128
- const onSuggestionsClose = useCallback(() => {
129
- setSuggestions([]);
130
- setSuggestionOpen(false);
131
- }, []);
132
-
133
- return (
134
- <Grommet full theme={myCustomTheme}>
135
- <Box background="dark-1" fill align="center" pad={{ top: 'large' }}>
136
- <Box
137
- ref={boxRef}
138
- width="large"
139
- direction="row"
140
- align="center"
141
- pad={{ horizontal: 'small', vertical: 'xsmall' }}
142
- round="small"
143
- elevation={suggestionOpen ? 'medium' : undefined}
144
- border={{
145
- side: 'all',
146
- color: suggestionOpen ? 'transparent' : 'border',
147
- }}
148
- style={
149
- suggestionOpen
150
- ? {
151
- borderBottomLeftRadius: '0px',
152
- borderBottomRightRadius: '0px',
153
- }
154
- : undefined
155
- }
156
- >
157
- <Search color="brand" />
158
- <TextInput
159
- id="grommet-custom-suggestions"
160
- dropTarget={boxRef.current}
161
- placeholder="Enter your name..."
162
- plain
163
- suggestions={suggestions}
164
- value={value}
165
- onChange={onChange}
166
- onSuggestionsOpen={onSuggestionsOpen}
167
- onSuggestionsClose={onSuggestionsClose}
168
- onSuggestionSelect={onSuggestionSelect}
169
- />
170
- </Box>
171
- </Box>
172
- </Grommet>
173
- );
174
- };
175
-
176
- CustomSuggestions.storyName = 'Custom suggestions';
177
-
178
- export default {
179
- title: 'Input/TextInput/Custom Themed/Custom suggestions',
180
- };
@@ -1,74 +0,0 @@
1
- import React from 'react';
2
- import { Box, Grommet, TextInput } from 'grommet';
3
- import { grommet } from 'grommet/themes';
4
- import { deepMerge } from 'grommet/utils';
5
- var suggestions = Array(100).fill().map(function (_, i) {
6
- return "suggestion " + (i + 1);
7
- });
8
- var customTheme = deepMerge(grommet, {
9
- global: {
10
- input: {
11
- padding: {
12
- horizontal: 'small',
13
- vertical: 'medium'
14
- }
15
- }
16
- },
17
- textInput: {
18
- extend: function extend() {
19
- return "\n font-size: 20px;\n background: #c9c19f;\n width: 300px;\n margin: 0 auto;\n\n &:focus {\n box-shadow: none;\n border-color: initial;\n }\n ";
20
- },
21
- container: {
22
- extend: function extend() {
23
- return "\n background: #edf7d2;\n height: 100px;\n width: 400px;\n display: flex;\n flex-flow: column;\n justify-content: center;\n border-radius: 10px;\n ";
24
- }
25
- },
26
- placeholder: {
27
- extend: function extend() {
28
- return "\n width: 100%;\n color: #1e1a11;\n ";
29
- }
30
- },
31
- suggestions: {
32
- extend: function extend() {
33
- return "\n background: #c9c19f;\n color: #3d3522;\n li {\n border-bottom: 1px solid rgba(0, 0, 0, 0.2);\n }\n ";
34
- }
35
- }
36
- }
37
- });
38
- export var Themed = function Themed() {
39
- var _React$useState = React.useState(''),
40
- value = _React$useState[0],
41
- setValue = _React$useState[1];
42
- var onChange = function onChange(event) {
43
- return setValue(event.target.value);
44
- };
45
- var onSelect = function onSelect(event) {
46
- return setValue(event.suggestion);
47
- };
48
- return /*#__PURE__*/React.createElement(Grommet, {
49
- full: true,
50
- theme: customTheme
51
- }, /*#__PURE__*/React.createElement(Box, {
52
- fill: true,
53
- align: "center",
54
- justify: "start",
55
- pad: "large"
56
- }, /*#__PURE__*/React.createElement(Box, {
57
- width: "medium"
58
- }, /*#__PURE__*/React.createElement(TextInput, {
59
- id: "grommet-password",
60
- type: "password",
61
- value: value,
62
- dropProps: {
63
- height: 'small'
64
- },
65
- onChange: onChange,
66
- onSelect: onSelect,
67
- suggestions: suggestions,
68
- placeholder: /*#__PURE__*/React.createElement("span", null, "Enter something..."),
69
- "aria-label": "Input Text"
70
- }))));
71
- };
72
- export default {
73
- title: 'Input/TextInput/Custom Themed/Themed'
74
- };