grommet 2.19.1 → 2.20.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 (388) hide show
  1. package/components/Accordion/Accordion.js +26 -23
  2. package/components/Accordion/stories/CustomHeader.js +36 -34
  3. package/components/Accordion/stories/CustomThemed/Custom.js +2 -9
  4. package/components/Accordion/stories/{typescript → CustomThemed}/Rich.tsx +2 -2
  5. package/components/Accordion/stories/DarkNoAnimation.js +34 -32
  6. package/components/Accordion/stories/Multiple.js +32 -30
  7. package/components/Accordion/stories/Simple.js +33 -31
  8. package/components/Anchor/propTypes.js +1 -1
  9. package/components/Anchor/stories/Color.js +1 -5
  10. package/components/Anchor/stories/Default.js +2 -6
  11. package/components/Anchor/stories/Disabled.js +2 -6
  12. package/components/Anchor/stories/Gap.js +2 -6
  13. package/components/Anchor/stories/Inline.js +2 -6
  14. package/components/Anchor/stories/Size.js +2 -6
  15. package/components/Anchor/stories/Weight.js +2 -6
  16. package/components/Avatar/Avatar.js +12 -11
  17. package/components/Avatar/stories/Basic.js +23 -21
  18. package/components/Avatar/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
  19. package/components/Avatar/stories/Round.js +35 -33
  20. package/components/Avatar/stories/Sizes.js +80 -78
  21. package/components/Avatar/stories/typescript/Stacked.tsx +10 -11
  22. package/components/Button/Button.js +1 -0
  23. package/components/Button/StyledButton.js +3 -1
  24. package/components/Button/StyledButtonKind.js +5 -11
  25. package/components/Calendar/Calendar.js +113 -87
  26. package/components/Calendar/StyledCalendar.js +1 -1
  27. package/components/Calendar/index.d.ts +4 -0
  28. package/components/Calendar/stories/ActiveDate.js +35 -34
  29. package/components/Calendar/stories/CustomDay.js +69 -67
  30. package/components/Calendar/stories/CustomHeader.js +39 -37
  31. package/{es6/components/Calendar/stories/typescript → components/Calendar/stories/CustomThemed}/CustomDate.tsx +1 -1
  32. package/components/Calendar/stories/{CustomSizeHeading.js → CustomThemed/CustomSizeHeading.js} +1 -1
  33. package/components/Calendar/stories/DaylightSavings.js +55 -53
  34. package/components/Calendar/stories/Dual.js +86 -84
  35. package/components/Calendar/stories/Fill.js +16 -14
  36. package/components/Calendar/stories/Multiple.js +26 -24
  37. package/components/Calendar/stories/Range.js +13 -11
  38. package/components/Calendar/stories/ShowAdjacentDays.js +36 -34
  39. package/components/Calendar/stories/Simple.js +24 -22
  40. package/components/Calendar/stories/SundayFirstDay.js +13 -11
  41. package/components/Calendar/utils.js +60 -10
  42. package/components/Card/stories/{Clickable.js → CustomThemed/Clickable.js} +2 -2
  43. package/components/Card/stories/{Stacked.js → CustomThemed/Stacked.js} +2 -2
  44. package/components/Card/stories/{Themed.js → CustomThemed/Themed.js} +2 -2
  45. package/components/Card/stories/Simple.js +26 -23
  46. package/components/Carousel/Carousel.js +145 -93
  47. package/components/Carousel/CarouselChild.js +17 -27
  48. package/components/Carousel/StyledCarousel.js +44 -0
  49. package/components/Carousel/index.d.ts +5 -0
  50. package/components/Carousel/propTypes.js +13 -9
  51. package/components/Carousel/stories/Autoplay.js +52 -0
  52. package/components/Carousel/stories/ControlVariations.js +170 -0
  53. package/components/Carousel/stories/Controlled.js +43 -37
  54. package/components/Carousel/stories/{Custom.js → CustomThemed/Custom.js} +1 -1
  55. package/components/Carousel/stories/CustomThemed/Icons.tsx +50 -0
  56. package/components/Carousel/stories/InteractiveChild.js +73 -0
  57. package/components/Carousel/stories/Multiple.js +7 -1
  58. package/components/Carousel/stories/Simple.js +25 -19
  59. package/components/Chart/Chart.js +2 -1
  60. package/components/Chart/calcs.js +1 -1
  61. package/components/Chart/utils.js +1 -1
  62. package/components/CheckBox/StyledCheckBox.js +1 -1
  63. package/components/Clock/Clock.js +1 -1
  64. package/components/Clock/StyledClock.js +1 -1
  65. package/components/Collapsible/stories/Horizontal.js +54 -50
  66. package/components/Collapsible/stories/Nested.js +78 -76
  67. package/components/Collapsible/stories/Simple.js +24 -22
  68. package/components/DataChart/utils.js +1 -1
  69. package/components/DataTable/DataTable.js +1 -1
  70. package/components/DataTable/StyledDataTable.js +1 -1
  71. package/components/DataTable/buildState.js +3 -2
  72. package/components/DataTable/index.d.ts +3 -3
  73. package/components/DataTable/stories/ColumnSize.js +63 -61
  74. package/components/DataTable/stories/Controlled.js +34 -32
  75. package/components/DataTable/stories/ControlledGrouped.js +16 -14
  76. package/components/DataTable/stories/{Fill.js → CustomThemed/Fill.js} +2 -2
  77. package/components/DataTable/stories/Grouped.js +15 -13
  78. package/components/DataTable/stories/GroupedOnSelect.js +16 -14
  79. package/components/DataTable/stories/InfiniteScrollDataTable.js +22 -20
  80. package/components/DataTable/stories/MultiplePin.js +48 -44
  81. package/components/DataTable/stories/NoPrimary.js +15 -13
  82. package/components/DataTable/stories/OnUpdate.js +24 -22
  83. package/components/DataTable/stories/Placeholder.js +27 -25
  84. package/components/DataTable/stories/ResizableColumns.js +17 -15
  85. package/components/DataTable/stories/Served.js +18 -16
  86. package/components/DataTable/stories/Show.js +29 -23
  87. package/components/DataTable/stories/Simple.js +14 -12
  88. package/components/DataTable/stories/Sized.js +14 -12
  89. package/components/DataTable/stories/Sort.js +20 -18
  90. package/components/DataTable/stories/SpaceX.js +36 -34
  91. package/components/DataTable/stories/SpaceXUngrouped.js +26 -24
  92. package/components/DataTable/stories/Styled.js +43 -41
  93. package/components/DataTable/stories/Tunable.js +19 -17
  94. package/components/DataTable/stories/Units.js +16 -14
  95. package/components/DataTable/stories/data.js +1 -1
  96. package/components/DataTable/stories/rowDetails.js +40 -38
  97. package/components/DataTable/stories/typescript/Clickable.tsx +30 -29
  98. package/components/DataTable/stories/typescript/OnSelect.tsx +13 -13
  99. package/components/DataTable/stories/typescript/Paginated.tsx +15 -15
  100. package/components/DateInput/DateInput.js +68 -25
  101. package/components/DateInput/stories/FormatInline.js +172 -16
  102. package/components/DateInput/stories/ResetDate.js +1 -1
  103. package/components/DateInput/utils.js +11 -15
  104. package/components/Drop/DropContainer.js +16 -9
  105. package/components/Drop/stories/AllNotStretched.js +166 -164
  106. package/components/Drop/stories/{Lazy.js → CustomThemed/Lazy.js} +1 -1
  107. package/components/Drop/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
  108. package/components/Drop/stories/Meter.js +35 -30
  109. package/components/Drop/stories/Multiple.js +56 -52
  110. package/components/Drop/stories/Overflow.js +54 -50
  111. package/components/Drop/stories/Plain.js +30 -26
  112. package/components/Drop/stories/Progressive.js +52 -48
  113. package/components/Drop/stories/Simple.js +28 -24
  114. package/components/Drop/stories/Styled.js +45 -41
  115. package/components/Drop/stories/TrapFocus.js +21 -16
  116. package/components/DropButton/stories/Menu.js +5 -7
  117. package/components/DropButton/stories/Simple.js +2 -6
  118. package/components/DropButton/stories/typescript/Calendar.tsx +17 -20
  119. package/components/FileInput/stories/CustomThemed/Custom.js +5 -7
  120. package/components/Footer/stories/data.js +1 -1
  121. package/components/Form/Form.js +240 -183
  122. package/components/Form/stories/ArrayOfFormFields.js +161 -0
  123. package/components/Form/stories/FieldWithChildren.js +4 -4
  124. package/components/FormField/FormField.js +1 -1
  125. package/components/Grommet/Grommet.js +8 -1
  126. package/components/Layer/LayerContainer.js +9 -4
  127. package/components/Layer/StyledLayer.js +1 -1
  128. package/components/MaskedInput/StyledMaskedInput.js +1 -1
  129. package/components/Menu/stories/BottomControlButton.js +2 -6
  130. package/components/Menu/stories/{typescript → CustomThemed}/Themed.tsx +1 -1
  131. package/components/Menu/stories/ItemWithIcon.js +2 -6
  132. package/components/Menu/stories/Justify.js +2 -6
  133. package/components/Menu/stories/Reverse.js +2 -6
  134. package/components/Menu/stories/Simple.js +2 -6
  135. package/components/Menu/stories/typescript/Children.tsx +10 -13
  136. package/components/Meter/utils.js +1 -1
  137. package/components/NameValueList/NameValueList.js +8 -5
  138. package/components/NameValueList/stories/CustomValue.js +1 -1
  139. package/components/NameValueList/stories/data.js +1 -1
  140. package/components/NameValuePair/NameValuePair.js +1 -4
  141. package/components/Nav/stories/Collapsable.js +39 -37
  142. package/components/Nav/stories/{CustomAnchor.js → CustomThemed/CustomAnchor.js} +2 -2
  143. package/components/Nav/stories/{JustifySidebar.js → CustomThemed/JustifySidebar.js} +1 -1
  144. package/components/Nav/stories/OnHeader.js +29 -27
  145. package/components/Nav/stories/Sidebar.js +24 -18
  146. package/components/Nav/stories/Simple.js +15 -13
  147. package/components/Notification/Notification.js +2 -2
  148. package/components/Pagination/StyledPageControl.js +2 -2
  149. package/components/RadioButton/StyledRadioButton.js +1 -1
  150. package/components/RadioButtonGroup/RadioButtonGroup.js +3 -1
  151. package/components/Select/Select.js +1 -0
  152. package/components/Stack/stories/Fill.js +15 -11
  153. package/components/Stack/stories/Simple.js +15 -9
  154. package/components/Table/StyledTable.js +1 -1
  155. package/components/Table/stories/data.js +1 -1
  156. package/components/Tabs/StyledTabs.js +1 -1
  157. package/components/Tabs/Tabs.js +23 -19
  158. package/components/Tabs/stories/{AlignControls.js → CustomThemed/AlignControls.js} +1 -1
  159. package/components/Tabs/stories/{Custom.js → CustomThemed/Custom.js} +3 -3
  160. package/components/Tabs/stories/{Icon.js → CustomThemed/Icon.js} +1 -1
  161. package/components/Tabs/stories/{States.js → CustomThemed/States.js} +1 -1
  162. package/components/Tabs/stories/Plain.js +45 -41
  163. package/components/Tabs/stories/Responsive.js +191 -189
  164. package/components/Tabs/stories/Rich.js +30 -28
  165. package/components/Tabs/stories/Scrollable.js +32 -28
  166. package/components/Tabs/stories/Uncontrolled.js +45 -41
  167. package/components/Tabs/stories/typescript/Controlled.tsx +21 -21
  168. package/components/Tag/README.md +2 -0
  169. package/components/Tag/StyledTag.js +35 -0
  170. package/components/Tag/Tag.js +83 -0
  171. package/components/Tag/index.d.ts +27 -0
  172. package/components/Tag/index.js +8 -0
  173. package/components/Tag/propTypes.js +27 -0
  174. package/components/Tag/stories/OnClick.js +34 -0
  175. package/components/Tag/stories/OnRemove.js +38 -0
  176. package/components/Tag/stories/Simple.js +32 -0
  177. package/components/Text/Text.js +23 -9
  178. package/components/TextInput/StyledTextInput.js +1 -1
  179. package/components/TextInput/TextInput.js +14 -2
  180. package/components/TextInput/index.d.ts +6 -1
  181. package/components/Video/Video.js +98 -38
  182. package/components/Video/index.d.ts +15 -2
  183. package/components/Video/propTypes.js +8 -1
  184. package/components/Video/stories/typescript/TheaterMode.tsx +46 -0
  185. package/components/index.d.ts +1 -0
  186. package/components/index.js +8 -0
  187. package/contexts/MessageContext/MessageContext.js +3 -2
  188. package/contexts/MessageContext/index.js +1 -1
  189. package/es6/components/Accordion/Accordion.js +26 -23
  190. package/es6/components/Accordion/stories/CustomHeader.js +37 -34
  191. package/es6/components/Accordion/stories/CustomThemed/Custom.js +2 -9
  192. package/es6/components/Accordion/stories/{typescript → CustomThemed}/Rich.tsx +2 -2
  193. package/es6/components/Accordion/stories/DarkNoAnimation.js +35 -32
  194. package/es6/components/Accordion/stories/Multiple.js +33 -30
  195. package/es6/components/Accordion/stories/Simple.js +34 -31
  196. package/es6/components/Anchor/propTypes.js +1 -1
  197. package/es6/components/Anchor/stories/Color.js +2 -5
  198. package/es6/components/Anchor/stories/Default.js +3 -6
  199. package/es6/components/Anchor/stories/Disabled.js +3 -6
  200. package/es6/components/Anchor/stories/Gap.js +3 -6
  201. package/es6/components/Anchor/stories/Inline.js +3 -6
  202. package/es6/components/Anchor/stories/Size.js +3 -6
  203. package/es6/components/Anchor/stories/Weight.js +3 -6
  204. package/es6/components/Avatar/Avatar.js +13 -12
  205. package/es6/components/Avatar/stories/Basic.js +24 -21
  206. package/es6/components/Avatar/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
  207. package/es6/components/Avatar/stories/Round.js +36 -33
  208. package/es6/components/Avatar/stories/Sizes.js +81 -78
  209. package/es6/components/Avatar/stories/typescript/Stacked.tsx +10 -11
  210. package/es6/components/Button/Button.js +1 -0
  211. package/es6/components/Button/StyledButton.js +3 -1
  212. package/es6/components/Button/StyledButtonKind.js +4 -11
  213. package/es6/components/Calendar/Calendar.js +114 -88
  214. package/es6/components/Calendar/index.d.ts +4 -0
  215. package/es6/components/Calendar/stories/ActiveDate.js +36 -34
  216. package/es6/components/Calendar/stories/CustomDay.js +70 -67
  217. package/es6/components/Calendar/stories/CustomHeader.js +40 -37
  218. package/{components/Calendar/stories/typescript → es6/components/Calendar/stories/CustomThemed}/CustomDate.tsx +1 -1
  219. package/es6/components/Calendar/stories/{CustomSizeHeading.js → CustomThemed/CustomSizeHeading.js} +1 -1
  220. package/es6/components/Calendar/stories/DaylightSavings.js +56 -53
  221. package/es6/components/Calendar/stories/Dual.js +87 -84
  222. package/es6/components/Calendar/stories/Fill.js +17 -14
  223. package/es6/components/Calendar/stories/Multiple.js +25 -22
  224. package/es6/components/Calendar/stories/Range.js +14 -11
  225. package/es6/components/Calendar/stories/ShowAdjacentDays.js +37 -34
  226. package/es6/components/Calendar/stories/Simple.js +25 -22
  227. package/es6/components/Calendar/stories/SundayFirstDay.js +14 -11
  228. package/es6/components/Calendar/utils.js +48 -4
  229. package/es6/components/Card/stories/{Clickable.js → CustomThemed/Clickable.js} +2 -2
  230. package/es6/components/Card/stories/{Stacked.js → CustomThemed/Stacked.js} +2 -2
  231. package/es6/components/Card/stories/{Themed.js → CustomThemed/Themed.js} +2 -2
  232. package/es6/components/Card/stories/Simple.js +27 -24
  233. package/es6/components/Carousel/Carousel.js +145 -94
  234. package/es6/components/Carousel/CarouselChild.js +17 -25
  235. package/es6/components/Carousel/StyledCarousel.js +31 -0
  236. package/es6/components/Carousel/index.d.ts +5 -0
  237. package/es6/components/Carousel/propTypes.js +13 -9
  238. package/es6/components/Carousel/stories/Autoplay.js +41 -0
  239. package/es6/components/Carousel/stories/ControlVariations.js +161 -0
  240. package/es6/components/Carousel/stories/Controlled.js +44 -38
  241. package/es6/components/Carousel/stories/{Custom.js → CustomThemed/Custom.js} +1 -1
  242. package/es6/components/Carousel/stories/CustomThemed/Icons.tsx +50 -0
  243. package/es6/components/Carousel/stories/InteractiveChild.js +61 -0
  244. package/es6/components/Carousel/stories/Multiple.js +8 -2
  245. package/es6/components/Carousel/stories/Simple.js +26 -20
  246. package/es6/components/Chart/Chart.js +2 -1
  247. package/es6/components/Clock/Clock.js +1 -1
  248. package/es6/components/Collapsible/stories/Horizontal.js +55 -50
  249. package/es6/components/Collapsible/stories/Nested.js +79 -76
  250. package/es6/components/Collapsible/stories/Simple.js +25 -22
  251. package/es6/components/DataTable/DataTable.js +1 -1
  252. package/es6/components/DataTable/buildState.js +2 -1
  253. package/es6/components/DataTable/index.d.ts +3 -3
  254. package/es6/components/DataTable/stories/ColumnSize.js +64 -61
  255. package/es6/components/DataTable/stories/Controlled.js +35 -32
  256. package/es6/components/DataTable/stories/ControlledGrouped.js +17 -14
  257. package/es6/components/DataTable/stories/{Fill.js → CustomThemed/Fill.js} +2 -2
  258. package/es6/components/DataTable/stories/Grouped.js +16 -13
  259. package/es6/components/DataTable/stories/GroupedOnSelect.js +17 -14
  260. package/es6/components/DataTable/stories/InfiniteScrollDataTable.js +23 -20
  261. package/es6/components/DataTable/stories/MultiplePin.js +49 -45
  262. package/es6/components/DataTable/stories/NoPrimary.js +16 -13
  263. package/es6/components/DataTable/stories/OnUpdate.js +25 -22
  264. package/es6/components/DataTable/stories/Placeholder.js +28 -25
  265. package/es6/components/DataTable/stories/ResizableColumns.js +18 -15
  266. package/es6/components/DataTable/stories/Served.js +19 -16
  267. package/es6/components/DataTable/stories/Show.js +27 -21
  268. package/es6/components/DataTable/stories/Simple.js +15 -12
  269. package/es6/components/DataTable/stories/Sized.js +15 -12
  270. package/es6/components/DataTable/stories/Sort.js +21 -18
  271. package/es6/components/DataTable/stories/SpaceX.js +37 -34
  272. package/es6/components/DataTable/stories/SpaceXUngrouped.js +27 -24
  273. package/es6/components/DataTable/stories/Styled.js +44 -41
  274. package/es6/components/DataTable/stories/Tunable.js +20 -17
  275. package/es6/components/DataTable/stories/Units.js +17 -14
  276. package/es6/components/DataTable/stories/rowDetails.js +41 -38
  277. package/es6/components/DataTable/stories/typescript/Clickable.tsx +30 -29
  278. package/es6/components/DataTable/stories/typescript/OnSelect.tsx +13 -13
  279. package/es6/components/DataTable/stories/typescript/Paginated.tsx +15 -15
  280. package/es6/components/DateInput/DateInput.js +63 -23
  281. package/es6/components/DateInput/stories/FormatInline.js +169 -16
  282. package/es6/components/DateInput/utils.js +9 -11
  283. package/es6/components/Drop/DropContainer.js +15 -9
  284. package/es6/components/Drop/stories/AllNotStretched.js +167 -164
  285. package/es6/components/Drop/stories/{Lazy.js → CustomThemed/Lazy.js} +1 -1
  286. package/es6/components/Drop/stories/{Themed.js → CustomThemed/Themed.js} +1 -1
  287. package/es6/components/Drop/stories/Meter.js +36 -30
  288. package/es6/components/Drop/stories/Multiple.js +57 -52
  289. package/es6/components/Drop/stories/Overflow.js +55 -50
  290. package/es6/components/Drop/stories/Plain.js +31 -26
  291. package/es6/components/Drop/stories/Progressive.js +53 -48
  292. package/es6/components/Drop/stories/Simple.js +29 -24
  293. package/es6/components/Drop/stories/Styled.js +46 -41
  294. package/es6/components/Drop/stories/TrapFocus.js +22 -17
  295. package/es6/components/DropButton/stories/Menu.js +6 -7
  296. package/es6/components/DropButton/stories/Simple.js +3 -6
  297. package/es6/components/DropButton/stories/typescript/Calendar.tsx +17 -20
  298. package/es6/components/FileInput/stories/CustomThemed/Custom.js +5 -7
  299. package/es6/components/Form/Form.js +240 -183
  300. package/es6/components/Form/stories/ArrayOfFormFields.js +147 -0
  301. package/es6/components/Form/stories/FieldWithChildren.js +4 -4
  302. package/es6/components/FormField/FormField.js +2 -2
  303. package/es6/components/Grommet/Grommet.js +8 -1
  304. package/es6/components/Layer/LayerContainer.js +9 -4
  305. package/es6/components/Menu/stories/BottomControlButton.js +3 -6
  306. package/es6/components/Menu/stories/{typescript → CustomThemed}/Themed.tsx +1 -1
  307. package/es6/components/Menu/stories/ItemWithIcon.js +3 -6
  308. package/es6/components/Menu/stories/Justify.js +3 -6
  309. package/es6/components/Menu/stories/Reverse.js +3 -6
  310. package/es6/components/Menu/stories/Simple.js +3 -6
  311. package/es6/components/Menu/stories/typescript/Children.tsx +10 -13
  312. package/es6/components/NameValueList/NameValueList.js +9 -6
  313. package/es6/components/NameValueList/stories/CustomValue.js +1 -1
  314. package/es6/components/NameValuePair/NameValuePair.js +1 -4
  315. package/es6/components/Nav/stories/Collapsable.js +40 -37
  316. package/es6/components/Nav/stories/{CustomAnchor.js → CustomThemed/CustomAnchor.js} +2 -2
  317. package/es6/components/Nav/stories/{JustifySidebar.js → CustomThemed/JustifySidebar.js} +1 -1
  318. package/es6/components/Nav/stories/OnHeader.js +30 -27
  319. package/es6/components/Nav/stories/Sidebar.js +25 -19
  320. package/es6/components/Nav/stories/Simple.js +16 -13
  321. package/es6/components/Notification/Notification.js +2 -2
  322. package/es6/components/Pagination/StyledPageControl.js +1 -1
  323. package/es6/components/RadioButtonGroup/RadioButtonGroup.js +3 -1
  324. package/es6/components/Select/Select.js +1 -0
  325. package/es6/components/Stack/stories/Fill.js +16 -11
  326. package/es6/components/Stack/stories/Simple.js +16 -10
  327. package/es6/components/Tabs/Tabs.js +23 -20
  328. package/es6/components/Tabs/stories/{AlignControls.js → CustomThemed/AlignControls.js} +1 -1
  329. package/es6/components/Tabs/stories/{Custom.js → CustomThemed/Custom.js} +3 -3
  330. package/es6/components/Tabs/stories/{Icon.js → CustomThemed/Icon.js} +1 -1
  331. package/es6/components/Tabs/stories/{States.js → CustomThemed/States.js} +1 -1
  332. package/es6/components/Tabs/stories/Plain.js +45 -40
  333. package/es6/components/Tabs/stories/Responsive.js +191 -188
  334. package/es6/components/Tabs/stories/Rich.js +30 -27
  335. package/es6/components/Tabs/stories/Scrollable.js +32 -27
  336. package/es6/components/Tabs/stories/Uncontrolled.js +45 -40
  337. package/es6/components/Tabs/stories/typescript/Controlled.tsx +21 -21
  338. package/es6/components/Tag/README.md +2 -0
  339. package/es6/components/Tag/StyledTag.js +22 -0
  340. package/es6/components/Tag/Tag.js +66 -0
  341. package/es6/components/Tag/index.d.ts +27 -0
  342. package/es6/components/Tag/index.js +1 -0
  343. package/es6/components/Tag/propTypes.js +17 -0
  344. package/es6/components/Tag/stories/OnClick.js +22 -0
  345. package/es6/components/Tag/stories/OnRemove.js +26 -0
  346. package/es6/components/Tag/stories/Simple.js +20 -0
  347. package/es6/components/Text/Text.js +23 -10
  348. package/es6/components/TextInput/TextInput.js +14 -2
  349. package/es6/components/TextInput/index.d.ts +6 -1
  350. package/es6/components/Video/Video.js +99 -39
  351. package/es6/components/Video/index.d.ts +15 -2
  352. package/es6/components/Video/propTypes.js +8 -1
  353. package/es6/components/Video/stories/typescript/TheaterMode.tsx +46 -0
  354. package/es6/components/index.d.ts +1 -0
  355. package/es6/components/index.js +1 -0
  356. package/es6/contexts/MessageContext/MessageContext.js +2 -1
  357. package/es6/index.d.ts +1 -0
  358. package/es6/languages/default.json +9 -2
  359. package/es6/themes/base.d.ts +25 -11
  360. package/es6/themes/base.js +21 -2
  361. package/es6/utils/DOM.js +13 -3
  362. package/es6/utils/background.js +2 -1
  363. package/grommet.min.js +1 -1
  364. package/grommet.min.js.map +1 -1
  365. package/index.d.ts +1 -0
  366. package/languages/default.json +9 -2
  367. package/package.json +53 -52
  368. package/themes/base.d.ts +25 -11
  369. package/themes/base.js +22 -3
  370. package/themes/index.js +1 -1
  371. package/utils/DOM.js +20 -4
  372. package/utils/animation.js +1 -1
  373. package/utils/background.js +3 -2
  374. package/utils/border.js +1 -1
  375. package/utils/colors.js +1 -1
  376. package/utils/general-prop-types.js +1 -1
  377. package/utils/graphics.js +1 -1
  378. package/utils/mixins.js +1 -1
  379. package/utils/object.js +1 -1
  380. package/utils/responsive.js +1 -1
  381. package/utils/styles.js +1 -1
  382. package/utils/use-isomorphic-layout-effect.js +1 -1
  383. package/components/Carousel/stories/InitialChild.js +0 -43
  384. package/components/Carousel/stories/WithClickableChild.js +0 -51
  385. package/components/Carousel/stories/WithoutControls.js +0 -44
  386. package/es6/components/Carousel/stories/InitialChild.js +0 -32
  387. package/es6/components/Carousel/stories/WithClickableChild.js +0 -40
  388. package/es6/components/Carousel/stories/WithoutControls.js +0 -33
@@ -1,36 +1,33 @@
1
1
  import React, { useState } from 'react';
2
2
  import { FormDown } from 'grommet-icons';
3
3
 
4
- import { Grommet, Box, Calendar, DropButton, Text } from 'grommet';
5
- import { grommet } from 'grommet/themes';
4
+ import { Box, Calendar, DropButton, Text } from 'grommet';
6
5
 
7
6
  const CalendarDropButton = () => {
8
7
  const [date, setDate] = useState('');
9
8
  const [open, setOpen] = useState(false);
10
9
 
11
- const onSelect = selectedDate => {
10
+ const onSelect = (selectedDate) => {
12
11
  setDate(selectedDate);
13
12
  setOpen(false);
14
13
  };
15
14
 
16
15
  return (
17
- <Grommet theme={grommet}>
18
- <Box align="center" pad="large">
19
- <DropButton
20
- open={open}
21
- onClose={() => setOpen(false)}
22
- onOpen={() => setOpen(true)}
23
- dropContent={<Calendar date={date} onSelect={onSelect} />}
24
- >
25
- <Box direction="row" gap="medium" align="center" pad="small">
26
- <Text>
27
- {date ? new Date(date).toLocaleDateString() : 'Select date'}
28
- </Text>
29
- <FormDown color="brand" />
30
- </Box>
31
- </DropButton>
32
- </Box>
33
- </Grommet>
16
+ <Box align="center" pad="large">
17
+ <DropButton
18
+ open={open}
19
+ onClose={() => setOpen(false)}
20
+ onOpen={() => setOpen(true)}
21
+ dropContent={<Calendar date={date} onSelect={onSelect} />}
22
+ >
23
+ <Box direction="row" gap="medium" align="center" pad="small">
24
+ <Text>
25
+ {date ? new Date(date).toLocaleDateString() : 'Select date'}
26
+ </Text>
27
+ <FormDown color="brand" />
28
+ </Box>
29
+ </DropButton>
30
+ </Box>
34
31
  );
35
32
  };
36
33
 
@@ -35,8 +35,8 @@ var customTheme = {
35
35
  size: 'medium'
36
36
  },
37
37
  pad: {
38
- horizontal: 'large',
39
- vertical: 'medium'
38
+ horizontal: 'medium',
39
+ vertical: 'small'
40
40
  },
41
41
  round: 'small',
42
42
  label: {
@@ -72,11 +72,9 @@ var Custom = function Custom() {
72
72
  width: "medium"
73
73
  }, /*#__PURE__*/_react["default"].createElement(_grommet.FileInput, {
74
74
  renderFile: function renderFile(file) {
75
- return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
76
- direction: "row",
77
- gap: "small"
78
- }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
79
- weight: "bold"
75
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Box, null, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
76
+ weight: "bold",
77
+ truncate: true
80
78
  }, file.name), /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
81
79
  color: "text-weak"
82
80
  }, file.size, " bytes"));
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.fiveColumns = exports.threeColumns = void 0;
4
+ exports.threeColumns = exports.fiveColumns = void 0;
5
5
  var threeColumns = [['App', 'home', 'beta', 'sponsors'], ['Legal', 'terms', 'privacy', 'security'], ['Company', 'about', 'press', 'jobs']];
6
6
  exports.threeColumns = threeColumns;
7
7
  var fiveColumns = [['App', 'home', 'beta', 'sponsor', 'login'], ['Legal', 'terms', 'privacy', 'security', 'resource library'], ['Company', 'about', 'press', 'jobs', 'email signup'], ['Partners', 'partner programs', 'find a partner', 'certifications', 'be a partner'], ['Customers', 'how to buy', 'financial services', 'enterprise glossary', 'briefing center']];
@@ -17,33 +17,91 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
17
17
 
18
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
19
 
20
- function _extends() { _extends = Object.assign || 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); }
21
-
22
20
  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; }
23
21
 
22
+ function _extends() { _extends = Object.assign || 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); }
23
+
24
24
  var defaultValue = {};
25
25
  var defaultTouched = {};
26
26
  var defaultValidationResults = {
27
27
  errors: {},
28
28
  infos: {}
29
- }; // Validating nameValues with the validator and sending correct messaging
29
+ };
30
+
31
+ var stringToArray = function stringToArray(string) {
32
+ var match = string == null ? void 0 : string.match(/^(.+)\[([0-9]+)\]\.(.*)$/);
33
+
34
+ if (match) {
35
+ var arrayName = match[1],
36
+ indexOfArray = match[2],
37
+ arrayObjName = match[3];
38
+ return {
39
+ indexOfArray: indexOfArray,
40
+ arrayName: arrayName,
41
+ arrayObjName: arrayObjName
42
+ };
43
+ }
44
+
45
+ return undefined;
46
+ };
47
+
48
+ var getFieldValue = function getFieldValue(name, value) {
49
+ var isArrayField = stringToArray(name);
50
+
51
+ if (isArrayField) {
52
+ var _value$arrayName;
53
+
54
+ var indexOfArray = isArrayField.indexOfArray,
55
+ arrayName = isArrayField.arrayName,
56
+ arrayObjName = isArrayField.arrayObjName;
57
+ var obj = (_value$arrayName = value[arrayName]) == null ? void 0 : _value$arrayName[indexOfArray];
58
+ return arrayObjName ? obj == null ? void 0 : obj[arrayObjName] : obj;
59
+ }
30
60
 
31
- var validate = function validate(validator, nameValue, formValue, format, messages) {
61
+ return value[name];
62
+ };
63
+
64
+ var setFieldValue = function setFieldValue(name, componentValue, prevValue) {
65
+ var nextValue = _extends({}, prevValue);
66
+
67
+ var isArrayField = stringToArray(name);
68
+
69
+ if (isArrayField) {
70
+ var indexOfArray = isArrayField.indexOfArray,
71
+ arrayName = isArrayField.arrayName,
72
+ arrayObjName = isArrayField.arrayObjName;
73
+ if (!nextValue[arrayName]) nextValue[arrayName] = [];
74
+
75
+ if (arrayObjName) {
76
+ var _nextValue$arrayName$;
77
+
78
+ if (!nextValue[arrayName][indexOfArray]) nextValue[arrayName][indexOfArray] = (_nextValue$arrayName$ = {}, _nextValue$arrayName$[arrayObjName] = componentValue, _nextValue$arrayName$);
79
+ nextValue[arrayName][indexOfArray][arrayObjName] = componentValue;
80
+ } else nextValue[arrayName][indexOfArray] = componentValue;
81
+ } else {
82
+ nextValue[name] = componentValue;
83
+ }
84
+
85
+ return nextValue;
86
+ }; // Apply validation rule to field value and send correct messaging.
87
+
88
+
89
+ var validate = function validate(rule, fieldValue, formValue, format, messages) {
32
90
  var result;
33
91
 
34
- if (typeof validator === 'function') {
35
- result = validator(nameValue, formValue);
36
- } else if (validator.regexp) {
37
- if (!validator.regexp.test(nameValue)) {
38
- result = validator.message || format({
92
+ if (typeof rule === 'function') {
93
+ result = rule(fieldValue, formValue);
94
+ } else if (rule.regexp) {
95
+ if (!rule.regexp.test(fieldValue)) {
96
+ result = rule.message || format({
39
97
  id: 'form.invalid',
40
98
  messages: messages
41
99
  });
42
100
 
43
- if (validator.status) {
101
+ if (rule.status) {
44
102
  result = {
45
103
  message: result,
46
- status: validator.status
104
+ status: rule.status
47
105
  };
48
106
  }
49
107
  }
@@ -53,39 +111,40 @@ var validate = function validate(validator, nameValue, formValue, format, messag
53
111
  }; // Validates particular key in formValue
54
112
 
55
113
 
56
- var validateName = function validateName(nameValidators, required) {
114
+ var validateName = function validateName(validationRules, required) {
57
115
  return function (name, formValue, format, messages) {
58
- var nameValue = formValue[name];
59
- var result; // ValidateArg is something that gets passed in from a FormField component
116
+ var fieldValue = getFieldValue(name, formValue);
117
+ var validationResult; // ValidateArg is something that gets passed in from a FormField component
60
118
  // See 'validate' prop in FormField
61
119
 
62
- if (required && (nameValue === undefined || nameValue === '' || nameValue === false || Array.isArray(nameValue) && !nameValue.length)) {
120
+ if (required && ( // false is for CheckBox
121
+ fieldValue === undefined || fieldValue === '' || fieldValue === false || Array.isArray(fieldValue) && !fieldValue.length)) {
63
122
  // There is no value at that name, and one is required
64
- result = format({
123
+ validationResult = format({
65
124
  id: 'form.required',
66
125
  messages: messages
67
126
  });
68
- } else if (nameValidators) {
69
- if (Array.isArray(nameValidators)) {
70
- nameValidators.some(function (validator) {
71
- result = validate(validator, nameValue, formValue, format, messages);
72
- return !!result;
127
+ } else if (validationRules) {
128
+ if (Array.isArray(validationRules)) {
129
+ validationRules.some(function (validator) {
130
+ validationResult = validate(validator, fieldValue, formValue, format, messages);
131
+ return !!validationResult;
73
132
  });
74
133
  } else {
75
- result = validate(nameValidators, nameValue, formValue, format, messages);
134
+ validationResult = validate(validationRules, fieldValue, formValue, format, messages);
76
135
  }
77
136
  }
78
137
 
79
- return result;
138
+ return validationResult;
80
139
  };
81
140
  }; // validations is an array from Object.entries()
82
141
  // Validates all keys in formValue
83
142
 
84
143
 
85
- var validateForm = function validateForm(validations, formValue, format, messages, omitValid) {
144
+ var validateForm = function validateForm(validationRules, formValue, format, messages, omitValid) {
86
145
  var nextErrors = {};
87
146
  var nextInfos = {};
88
- validations.forEach(function (_ref) {
147
+ validationRules.forEach(function (_ref) {
89
148
  var name = _ref[0],
90
149
  _ref$ = _ref[1],
91
150
  field = _ref$.field,
@@ -99,12 +158,12 @@ var validateForm = function validateForm(validations, formValue, format, message
99
158
  var result;
100
159
 
101
160
  if (input) {
102
- // input() are validations supplied through useFormInput()
161
+ // input() a validation function supplied through useFormInput()
103
162
  result = input(name, formValue, format, messages);
104
163
  }
105
164
 
106
165
  if (field && !result) {
107
- // field() are validations supplied through useFormField()
166
+ // field() a validation function supplied through useFormField()
108
167
  result = field(name, formValue, format, messages);
109
168
  } // typeof error === 'object' is implied for both cases of error with
110
169
  // a status message and for an error object that is a react node
@@ -176,35 +235,27 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
176
235
  infos: infosProp
177
236
  });
178
237
  }, [errorsProp, infosProp]);
179
- var validations = (0, _react.useRef)({});
238
+ var validationRulesRef = (0, _react.useRef)({});
180
239
  var requiredFields = (0, _react.useRef)([]);
181
240
  var buildValid = (0, _react.useCallback)(function (nextErrors) {
182
241
  var valid = false;
183
242
  valid = requiredFields.current.filter(function (n) {
184
- return Object.keys(validations.current).includes(n);
243
+ return Object.keys(validationRulesRef.current).includes(n);
185
244
  }).every(function (field) {
186
245
  return value[field] && (value[field] !== '' || value[field] !== false);
187
246
  });
188
247
  if (Object.keys(nextErrors).length > 0) valid = false;
189
248
  return valid;
190
- }, [value]); // Remove any errors that we don't have any validations for anymore.
191
-
192
- var filterErrorValidations = function filterErrorValidations(errors) {
193
- var nextErrors = errors;
194
- return Object.keys(nextErrors).filter(function (n) {
195
- return !validations.current[n] || nextErrors[n] === undefined;
196
- }).forEach(function (n) {
197
- return delete nextErrors[n];
198
- });
199
- }; // Remove any infos that we don't have any validations for anymore.
200
-
201
-
202
- var filterInfoValidations = function filterInfoValidations(infos) {
203
- var nextInfos = infos;
204
- return Object.keys(nextInfos).filter(function (n) {
205
- return !validations.current[n] || nextInfos[n] === undefined;
249
+ }, [value]); // Only keep validation results for current form fields. In the case of a
250
+ // dynamic form, a field possessing an error may have been removed from the
251
+ // form; need to clean up any previous related validation results.
252
+
253
+ var filterRemovedFields = function filterRemovedFields(prevValidations) {
254
+ var nextValidations = prevValidations;
255
+ return Object.keys(nextValidations).filter(function (n) {
256
+ return !validationRulesRef.current[n] || nextValidations[n] === undefined;
206
257
  }).forEach(function (n) {
207
- return delete nextInfos[n];
258
+ return delete nextValidations[n];
208
259
  });
209
260
  }; // On initial mount, when validateOn is change or blur,
210
261
  // set validation results for any set fields and calculate whether
@@ -212,9 +263,9 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
212
263
 
213
264
 
214
265
  (0, _react.useEffect)(function () {
215
- var validationsForSetFields = Object.entries(validations.current).filter(function (_ref3) {
266
+ var validationsForSetFields = Object.entries(validationRulesRef.current).filter(function (_ref3) {
216
267
  var n = _ref3[0];
217
- return value[n];
268
+ return getFieldValue(n, value);
218
269
  });
219
270
 
220
271
  if (validationsForSetFields.length > 0 && validateOn !== 'submit') {
@@ -222,8 +273,8 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
222
273
  errors = _validateForm[0],
223
274
  infos = _validateForm[1];
224
275
 
225
- filterErrorValidations(errors);
226
- filterInfoValidations(infos);
276
+ filterRemovedFields(errors);
277
+ filterRemovedFields(infos);
227
278
  var nextValidationResults = {
228
279
  errors: errors,
229
280
  infos: infos,
@@ -241,7 +292,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
241
292
  var timer = setTimeout(function () {
242
293
  if (pendingValidation) {
243
294
  // run validations on the pending one and any other touched fields
244
- var _validateForm2 = validateForm(Object.entries(validations.current).filter(function (_ref4) {
295
+ var _validateForm2 = validateForm(Object.entries(validationRulesRef.current).filter(function (_ref4) {
245
296
  var n = _ref4[0];
246
297
  return touched[n] || pendingValidation.includes(n);
247
298
  }), value, format, messages),
@@ -256,8 +307,8 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
256
307
 
257
308
  var nextInfos = _extends({}, prevValidationResults.infos, validatedInfos);
258
309
 
259
- filterErrorValidations(nextErrors);
260
- filterInfoValidations(nextInfos);
310
+ filterRemovedFields(nextErrors);
311
+ filterRemovedFields(nextInfos);
261
312
  var nextValidationResults = {
262
313
  errors: nextErrors,
263
314
  infos: nextInfos,
@@ -282,7 +333,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
282
333
  (0, _react.useEffect)(function () {
283
334
  if (validateOn !== 'change') setPendingValidation(undefined);
284
335
  setValidationResults(function (prevValidationResults) {
285
- var _validateForm3 = validateForm(Object.entries(validations.current).filter(function (_ref5) {
336
+ var _validateForm3 = validateForm(Object.entries(validationRulesRef.current).filter(function (_ref5) {
286
337
  var n = _ref5[0];
287
338
  return prevValidationResults.errors[n] || prevValidationResults.infos[n];
288
339
  }), value, format, messages),
@@ -327,144 +378,153 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
327
378
  // they can have access to it.
328
379
  //
329
380
 
330
- var useFormInput = function useFormInput(_ref6) {
331
- var name = _ref6.name,
332
- componentValue = _ref6.value,
333
- initialValue = _ref6.initialValue,
334
- validateArg = _ref6.validate;
335
-
336
- var _useState5 = (0, _react.useState)(initialValue),
337
- inputValue = _useState5[0],
338
- setInputValue = _useState5[1];
339
-
340
- var formValue = name ? value[name] : undefined; // for dynamic forms, we need to track when an input has been added to
341
- // the form value. if the input is unmounted, we will delete its key/value
342
- // from the form value.
343
-
344
- var keyCreated = (0, _react.useRef)(false); // This effect is for pattern #2, where the controlled input
345
- // component is driving the value via componentValue.
346
-
347
- (0, _react.useEffect)(function () {
348
- if (name && // we have somewhere to put this
349
- componentValue !== undefined && // input driving
350
- componentValue !== formValue // don't already have it
351
- ) {
352
- setValueState(function (prevValue) {
353
- var nextValue = _extends({}, prevValue);
354
-
355
- nextValue[name] = componentValue;
356
- return nextValue;
357
- }); // don't onChange on programmatic changes
358
- }
359
- }, [componentValue, formValue, name]); // on unmount, if the form is uncontrolled, remove the key/value
360
- // from the form value
361
-
362
- (0, _react.useEffect)(function () {
363
- return function () {
364
- if (keyCreated.current) {
365
- keyCreated.current = false;
381
+ var formContextValue = (0, _react.useMemo)(function () {
382
+ var useFormInput = function useFormInput(_ref6) {
383
+ var name = _ref6.name,
384
+ componentValue = _ref6.value,
385
+ initialValue = _ref6.initialValue,
386
+ validateArg = _ref6.validate;
387
+
388
+ var _useState5 = (0, _react.useState)(initialValue),
389
+ inputValue = _useState5[0],
390
+ setInputValue = _useState5[1];
391
+
392
+ var formValue = name ? getFieldValue(name, value) : undefined; // for dynamic forms, we need to track when an input has been added to
393
+ // the form value. if the input is unmounted, we will delete its
394
+ // key/value from the form value.
395
+
396
+ var keyCreated = (0, _react.useRef)(false); // This effect is for pattern #2, where the controlled input
397
+ // component is driving the value via componentValue.
398
+
399
+ (0, _react.useEffect)(function () {
400
+ if (name && // we have somewhere to put this
401
+ componentValue !== undefined && // input driving
402
+ componentValue !== formValue // don't already have it
403
+ ) {
366
404
  setValueState(function (prevValue) {
367
- var nextValue = _extends({}, prevValue);
368
-
369
- delete nextValue[name];
370
- return nextValue;
371
- });
372
- }
373
- };
374
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
375
- [] // only run onmount and unmount
376
- );
377
- (0, _react.useEffect)(function () {
378
- if (validateArg) {
379
- if (!validations.current[name]) {
380
- validations.current[name] = {};
405
+ return setFieldValue(name, componentValue, prevValue);
406
+ }); // don't onChange on programmatic changes
381
407
  }
408
+ }, [componentValue, formValue, name]); // on unmount, if the form is uncontrolled, remove the key/value
409
+ // from the form value
382
410
 
383
- validations.current[name].input = validateName(validateArg);
411
+ (0, _react.useEffect)(function () {
384
412
  return function () {
385
- return delete validations.current[name].input;
413
+ if (keyCreated.current) {
414
+ keyCreated.current = false;
415
+ setValueState(function (prevValue) {
416
+ var nextValue = _extends({}, prevValue);
417
+
418
+ var isArrayField = stringToArray(name);
419
+
420
+ if (isArrayField) {
421
+ var arrayName = isArrayField.arrayName;
422
+ delete nextValue[arrayName];
423
+ } else {
424
+ delete nextValue[name];
425
+ }
426
+
427
+ return nextValue;
428
+ });
429
+ }
386
430
  };
387
- }
388
-
389
- return undefined;
390
- }, [validateArg, name]);
391
- var useValue;
392
- if (componentValue !== undefined) // input component drives, pattern #2
393
- useValue = componentValue;else if (valueProp && name && formValue !== undefined) // form drives, pattern #1
394
- useValue = formValue;else if (formValue === undefined && name) // form has reset, so reset input value as well
395
- useValue = initialValue;else useValue = inputValue;
396
- return [useValue, function (nextComponentValue) {
397
- if (name) {
398
- // we have somewhere to put this
399
- var nextTouched = _extends({}, touched);
400
-
401
- nextTouched[name] = true;
402
-
403
- if (!touched[name]) {
404
- // don't update if not needed
405
- setTouched(nextTouched);
431
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
432
+ [] // only run onmount and unmount
433
+ );
434
+ (0, _react.useEffect)(function () {
435
+ if (validateArg) {
436
+ if (!validationRulesRef.current[name]) {
437
+ validationRulesRef.current[name] = {};
438
+ }
439
+
440
+ validationRulesRef.current[name].input = validateName(validateArg);
441
+ return function () {
442
+ return delete validationRulesRef.current[name].input;
443
+ };
406
444
  }
407
445
 
408
- var nextValue = _extends({}, value); // if nextValue doesn't have a key for name, this must be
409
- // uncontrolled form. we will flag this field was added so
410
- // we know to remove its value from the form if it is dynamically
411
- // removed
412
-
413
-
414
- if (!(name in nextValue)) keyCreated.current = true;
415
- nextValue[name] = nextComponentValue;
416
- setValueState(nextValue);
417
- if (onChange) onChange(nextValue, {
418
- touched: nextTouched
419
- });
420
- }
446
+ return undefined;
447
+ }, [validateArg, name]);
448
+ var useValue;
449
+ if (componentValue !== undefined) // input component drives, pattern #2
450
+ useValue = componentValue;else if (valueProp && name && formValue !== undefined) // form drives, pattern #1
451
+ useValue = formValue;else if (formValue === undefined && name) // form has reset, so reset input value as well
452
+ useValue = initialValue;else useValue = inputValue;
453
+ return [useValue, function (nextComponentValue) {
454
+ if (name) {
455
+ // we have somewhere to put this
456
+ var nextTouched = _extends({}, touched);
457
+
458
+ nextTouched[name] = true;
459
+
460
+ if (!touched[name]) {
461
+ // don't update if not needed
462
+ setTouched(nextTouched);
463
+ } // if nextValue doesn't have a key for name, this must be
464
+ // uncontrolled form. we will flag this field was added so
465
+ // we know to remove its value from the form if it is dynamically
466
+ // removed
467
+
468
+
469
+ if (!(name in value)) keyCreated.current = true;
470
+ var nextValue = setFieldValue(name, nextComponentValue, value);
471
+ setValueState(nextValue);
472
+ if (onChange) onChange(nextValue, {
473
+ touched: nextTouched
474
+ });
475
+ }
421
476
 
422
- if (initialValue !== undefined) setInputValue(nextComponentValue);
423
- }];
424
- };
477
+ if (initialValue !== undefined) setInputValue(nextComponentValue);
478
+ }];
479
+ };
425
480
 
426
- var useFormField = function useFormField(_ref7) {
427
- var errorArg = _ref7.error,
428
- infoArg = _ref7.info,
429
- name = _ref7.name,
430
- required = _ref7.required,
431
- disabled = _ref7.disabled,
432
- validateArg = _ref7.validate;
433
- var error = disabled ? undefined : errorArg || validationResults.errors[name];
434
- var info = infoArg || validationResults.infos[name];
435
- (0, _react.useEffect)(function () {
436
- var index = requiredFields.current.indexOf(name);
437
-
438
- if (required) {
439
- if (index === -1) requiredFields.current.push(name);
440
- } else if (index !== -1) requiredFields.current.splice(index, 1);
441
-
442
- if (validateArg || required) {
443
- if (!validations.current[name]) {
444
- validations.current[name] = {};
481
+ var useFormField = function useFormField(_ref7) {
482
+ var errorArg = _ref7.error,
483
+ infoArg = _ref7.info,
484
+ name = _ref7.name,
485
+ required = _ref7.required,
486
+ disabled = _ref7.disabled,
487
+ validateArg = _ref7.validate;
488
+ var error = disabled ? undefined : errorArg || validationResults.errors[name];
489
+ var info = infoArg || validationResults.infos[name];
490
+ (0, _react.useEffect)(function () {
491
+ var index = requiredFields.current.indexOf(name);
492
+
493
+ if (required) {
494
+ if (index === -1) requiredFields.current.push(name);
495
+ } else if (index !== -1) requiredFields.current.splice(index, 1);
496
+
497
+ if (validateArg || required) {
498
+ if (!validationRulesRef.current[name]) {
499
+ validationRulesRef.current[name] = {};
500
+ }
501
+
502
+ validationRulesRef.current[name].field = validateName(validateArg, required);
503
+ return function () {
504
+ return delete validationRulesRef.current[name].field;
505
+ };
445
506
  }
446
507
 
447
- validations.current[name].field = validateName(validateArg, required);
448
- return function () {
449
- return delete validations.current[name].field;
450
- };
451
- }
508
+ return undefined;
509
+ }, [error, name, required, validateArg, disabled]);
510
+ return {
511
+ error: error,
512
+ info: info,
513
+ inForm: true,
514
+ onBlur: validateOn === 'blur' ? function () {
515
+ return setPendingValidation(pendingValidation ? [].concat(pendingValidation, [name]) : [name]);
516
+ } : undefined,
517
+ onChange: validateOn === 'change' ? function () {
518
+ return setPendingValidation(pendingValidation ? [].concat(pendingValidation, [name]) : [name]);
519
+ } : undefined
520
+ };
521
+ };
452
522
 
453
- return undefined;
454
- }, [error, name, required, validateArg, disabled]);
455
523
  return {
456
- error: error,
457
- info: info,
458
- inForm: true,
459
- onBlur: validateOn === 'blur' ? function () {
460
- return setPendingValidation(pendingValidation ? [].concat(pendingValidation, [name]) : [name]);
461
- } : undefined,
462
- onChange: validateOn === 'change' ? function () {
463
- return setPendingValidation(pendingValidation ? [].concat(pendingValidation, [name]) : [name]);
464
- } : undefined
524
+ useFormField: useFormField,
525
+ useFormInput: useFormInput
465
526
  };
466
- };
467
-
527
+ }, [onChange, pendingValidation, touched, validateOn, validationResults.errors, validationResults.infos, value, valueProp]);
468
528
  return /*#__PURE__*/_react["default"].createElement("form", _extends({
469
529
  ref: ref
470
530
  }, rest, {
@@ -497,7 +557,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
497
557
  event.preventDefault();
498
558
  setPendingValidation(undefined);
499
559
 
500
- var _validateForm4 = validateForm(Object.entries(validations.current), value, format, messages, true),
560
+ var _validateForm4 = validateForm(Object.entries(validationRulesRef.current), value, format, messages, true),
501
561
  nextErrors = _validateForm4[0],
502
562
  nextInfos = _validateForm4[1];
503
563
 
@@ -523,10 +583,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
523
583
  }
524
584
  }
525
585
  }), /*#__PURE__*/_react["default"].createElement(_FormContext.FormContext.Provider, {
526
- value: {
527
- useFormField: useFormField,
528
- useFormInput: useFormInput
529
- }
586
+ value: formContextValue
530
587
  }, children));
531
588
  });
532
589
  exports.Form = Form;