@spothero/ui 15.10.9 → 16.0.0-beta.1

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 (317) hide show
  1. package/.eslintignore +1 -1
  2. package/babel.config.js +1 -0
  3. package/dex.config.js +1 -1
  4. package/jest.config.json +4 -2
  5. package/package.json +11 -26
  6. package/v2/index.js +1 -1
  7. package/v2/index.js.map +1 -1
  8. package/backlog/Alert/Alert.js +0 -37
  9. package/backlog/AutoSuggestInput/AutoSuggestInput.js +0 -474
  10. package/backlog/AutoSuggestInput/AutoSuggestItem.js +0 -99
  11. package/backlog/AutoSuggestInput/AutoSuggestList.js +0 -126
  12. package/backlog/Badge/Badge.js +0 -28
  13. package/backlog/Chart/Chart.js +0 -211
  14. package/backlog/Checkbox/Checkbox.js +0 -167
  15. package/backlog/DateTime/DatePicker.js +0 -279
  16. package/backlog/DateTime/DatePickerCalendar.js +0 -199
  17. package/backlog/DateTime/DatePickerCalendarNavigation.js +0 -102
  18. package/backlog/DateTime/DatePickerCalendarWithRange.js +0 -241
  19. package/backlog/DateTime/DateTimePicker.js +0 -216
  20. package/backlog/DateTime/DateTimeRangePicker.js +0 -530
  21. package/backlog/DateTime/TimePicker.js +0 -180
  22. package/backlog/DateTime/date-time-assertions.js +0 -66
  23. package/backlog/DateTime/index.js +0 -55
  24. package/backlog/ErrorBoundary/ErrorBoundary.js +0 -125
  25. package/backlog/Flyout/Flyout.js +0 -198
  26. package/backlog/Form/Form.js +0 -193
  27. package/backlog/Form/FormElementError.js +0 -24
  28. package/backlog/Form/FormGroup.js +0 -30
  29. package/backlog/Form/FormGroupError.js +0 -28
  30. package/backlog/Form/index.js +0 -39
  31. package/backlog/GooglePlacesSearchInput/GooglePlacesSearchInput.js +0 -253
  32. package/backlog/GooglePlacesSearchInput/PoweredByGoogle.js +0 -38
  33. package/backlog/GooglePlacesSearchInput/index.js +0 -23
  34. package/backlog/HorizontalRule/HorizontalRule.js +0 -30
  35. package/backlog/Label/Label.js +0 -31
  36. package/backlog/Notification/Notification.js +0 -178
  37. package/backlog/Notification/NotificationContainer.js +0 -131
  38. package/backlog/Notification/NotificationPropTypes.js +0 -37
  39. package/backlog/Notification/index.js +0 -23
  40. package/backlog/PasswordControl/PasswordControl.js +0 -201
  41. package/backlog/Portal/Portal.js +0 -110
  42. package/backlog/PulseLoader/PulseLoader.js +0 -62
  43. package/backlog/Radio/Radio.js +0 -135
  44. package/backlog/Radio/RadioGroup.js +0 -123
  45. package/backlog/Radio/index.js +0 -23
  46. package/backlog/RenderInBody/RenderInBody.js +0 -103
  47. package/backlog/Select/Select.js +0 -275
  48. package/backlog/Select/SelectItemPropTypes.js +0 -32
  49. package/backlog/Select/index.js +0 -23
  50. package/backlog/SelectControlled/SelectControlled.js +0 -270
  51. package/backlog/SelectControlled/index.js +0 -15
  52. package/backlog/Sprite/Sprite.js +0 -24
  53. package/backlog/Tabs/Tab.js +0 -94
  54. package/backlog/Tabs/TabContent.js +0 -56
  55. package/backlog/Tabs/TabNavigation.js +0 -108
  56. package/backlog/Tabs/TabPanel.js +0 -29
  57. package/backlog/Tabs/Tabs.js +0 -126
  58. package/backlog/Tabs/index.js +0 -47
  59. package/backlog/TextArea/TextArea.js +0 -155
  60. package/backlog/TextInput/TextInput.js +0 -230
  61. package/backlog/TextInput/TextInputPropTypes.js +0 -114
  62. package/backlog/TextInput/index.js +0 -23
  63. package/backlog/Tooltip/Tooltip.js +0 -249
  64. package/backlog/index.js +0 -393
  65. package/backlog/v1/components/Button/Button.js +0 -64
  66. package/backlog/v1/components/Button/button-props.js +0 -48
  67. package/backlog/v1/components/Image/Image.js +0 -193
  68. package/backlog/v1/components/Loader/Loader.js +0 -51
  69. package/backlog/v1/components/Modal/Modal.js +0 -325
  70. package/backlog/v1/components/Modal/ModalContent.js +0 -154
  71. package/backlog/v1/components/Modal/ModalFooter.js +0 -89
  72. package/backlog/v1/components/Modal/index.js +0 -31
  73. package/backlog/v1/components/Panel/Panel.js +0 -209
  74. package/backlog/v1/components/Table/Table.js +0 -336
  75. package/backlog/v1/components/Table/TableCell.js +0 -28
  76. package/backlog/v1/components/Table/TableCellPropTypes.js +0 -22
  77. package/backlog/v1/components/Table/TableControls.js +0 -56
  78. package/backlog/v1/components/Table/TableFooter.js +0 -63
  79. package/backlog/v1/components/Table/TableHeading.js +0 -126
  80. package/backlog/v1/components/Table/TableHeadingPropTypes.js +0 -35
  81. package/backlog/v1/components/Table/TableSortSelector.js +0 -125
  82. package/backlog/v1/components/Table/TableSortType.js +0 -11
  83. package/backlog/v1/components/Table/index.js +0 -47
  84. package/backlog/v1/components/TextButton/TextButton.js +0 -74
  85. package/backlog/v1/components/index.js +0 -75
  86. package/backlog/v1/utils/deprecate.js +0 -61
  87. package/styles/Alert/_Alert.scss +0 -51
  88. package/styles/AutoSuggestInput/_AutoSuggestInput.scss +0 -116
  89. package/styles/Badge/_Badge.scss +0 -33
  90. package/styles/Chart/_Chart.scss +0 -105
  91. package/styles/Chart/_chartist-settings.scss +0 -131
  92. package/styles/Chart/_chartist.scss +0 -295
  93. package/styles/Checkbox/_Checkbox.scss +0 -173
  94. package/styles/DateTime/_DatePicker.scss +0 -61
  95. package/styles/DateTime/_DatePickerCalendar.scss +0 -159
  96. package/styles/DateTime/_DateTime.scss +0 -4
  97. package/styles/DateTime/_DateTimePicker.scss +0 -46
  98. package/styles/DateTime/_TimePicker.scss +0 -30
  99. package/styles/ErrorBoundary/_ErrorBoundary.scss +0 -18
  100. package/styles/Flyout/_Flyout.scss +0 -73
  101. package/styles/Form/_Form.scss +0 -53
  102. package/styles/GooglePlacesSearchInput/_GooglePlacesSearchInput.scss +0 -3
  103. package/styles/GooglePlacesSearchInput/_PoweredByGoogle.scss +0 -21
  104. package/styles/HorizontalRule/_HorizontalRule.scss +0 -48
  105. package/styles/Label/_Label.scss +0 -6
  106. package/styles/Notification/_Notification.scss +0 -113
  107. package/styles/PasswordControl/_PasswordControl.scss +0 -86
  108. package/styles/PulseLoader/_PulseLoader.scss +0 -60
  109. package/styles/Radio/_Radio.scss +0 -93
  110. package/styles/Select/_Select.scss +0 -94
  111. package/styles/Tabs/_Tabs.scss +0 -57
  112. package/styles/TextArea/_TextArea.scss +0 -26
  113. package/styles/TextInput/_TextInput.scss +0 -43
  114. package/styles/Tooltip/_Tooltip.scss +0 -108
  115. package/styles/_index.scss +0 -34
  116. package/styles/common/sass/_control-sizing.scss +0 -5
  117. package/styles/common/sass/_disable-scrolling.scss +0 -7
  118. package/styles/common/sass/_forms.scss +0 -72
  119. package/styles/index.js +0 -50
  120. package/styles/v1/components/Button/Button.jsx +0 -48
  121. package/styles/v1/components/Button/Button.spec.js +0 -76
  122. package/styles/v1/components/Button/_Button.scss +0 -178
  123. package/styles/v1/components/Button/button-props.js +0 -30
  124. package/styles/v1/components/Button/stories/button.js +0 -20
  125. package/styles/v1/components/Button/stories/index.stories.js +0 -92
  126. package/styles/v1/components/Button/stories/overview.js +0 -87
  127. package/styles/v1/components/Button/stories/types.js +0 -31
  128. package/styles/v1/components/Image/Image.jsx +0 -175
  129. package/styles/v1/components/Image/Image.spec.js +0 -113
  130. package/styles/v1/components/Image/_Image.scss +0 -24
  131. package/styles/v1/components/Image/stories/Cloudinary.stories.js +0 -39
  132. package/styles/v1/components/Image/stories/Display.stories.js +0 -92
  133. package/styles/v1/components/Loader/Loader.jsx +0 -54
  134. package/styles/v1/components/Loader/Loader.spec.js +0 -67
  135. package/styles/v1/components/Loader/_Loader.scss +0 -18
  136. package/styles/v1/components/Loader/stories/Display.stories.js +0 -55
  137. package/styles/v1/components/Modal/Modal.jsx +0 -315
  138. package/styles/v1/components/Modal/Modal.spec.js +0 -293
  139. package/styles/v1/components/Modal/ModalContent.jsx +0 -126
  140. package/styles/v1/components/Modal/ModalFooter.jsx +0 -53
  141. package/styles/v1/components/Modal/_Modal.scss +0 -262
  142. package/styles/v1/components/Modal/index.js +0 -3
  143. package/styles/v1/components/Modal/stories/Content.stories.js +0 -314
  144. package/styles/v1/components/Modal/stories/Display.stories.js +0 -208
  145. package/styles/v1/components/Modal/stories/Methods.stories.js +0 -44
  146. package/styles/v1/components/Modal/stories/Width.stories.js +0 -82
  147. package/styles/v1/components/Modal/stories/helpers/ReduxConsumer.jsx +0 -21
  148. package/styles/v1/components/Panel/Panel.jsx +0 -202
  149. package/styles/v1/components/Panel/Panel.spec.js +0 -196
  150. package/styles/v1/components/Panel/_Panel.scss +0 -55
  151. package/styles/v1/components/Panel/stories/Display.stories.js +0 -82
  152. package/styles/v1/components/Panel/stories/Methods.stories.js +0 -76
  153. package/styles/v1/components/Table/Table.jsx +0 -367
  154. package/styles/v1/components/Table/Table.spec.js +0 -526
  155. package/styles/v1/components/Table/TableCell.jsx +0 -17
  156. package/styles/v1/components/Table/TableCellPropTypes.js +0 -10
  157. package/styles/v1/components/Table/TableControls.jsx +0 -61
  158. package/styles/v1/components/Table/TableFooter.jsx +0 -72
  159. package/styles/v1/components/Table/TableHeading.jsx +0 -58
  160. package/styles/v1/components/Table/TableHeadingPropTypes.js +0 -20
  161. package/styles/v1/components/Table/TableSortSelector.jsx +0 -63
  162. package/styles/v1/components/Table/TableSortType.js +0 -4
  163. package/styles/v1/components/Table/_Table.scss +0 -263
  164. package/styles/v1/components/Table/index.js +0 -5
  165. package/styles/v1/components/Table/stories/Display.stories.js +0 -194
  166. package/styles/v1/components/Table/stories/Methods.stories.js +0 -141
  167. package/styles/v1/components/Table/stories/helpers/TableCellEmail.jsx +0 -25
  168. package/styles/v1/components/Table/stories/helpers/TableCustomRow.jsx +0 -35
  169. package/styles/v1/components/Table/stories/helpers/TableHeadingEmail.jsx +0 -20
  170. package/styles/v1/components/Table/stories/helpers/table-data.js +0 -26
  171. package/styles/v1/components/Table/stories/helpers/table-headers.js +0 -14
  172. package/styles/v1/components/TextButton/TextButton.jsx +0 -78
  173. package/styles/v1/components/TextButton/TextButton.spec.js +0 -95
  174. package/styles/v1/components/TextButton/_TextButton.scss +0 -114
  175. package/styles/v1/components/TextButton/stories/Display.stories.js +0 -46
  176. package/styles/v1/components/index.js +0 -7
  177. package/styles/v1/utils/deprecate.js +0 -45
  178. package/styles/v2/components/Accordion/Accordion.jsx +0 -1
  179. package/styles/v2/components/Accordion/Accordion.stories.js +0 -103
  180. package/styles/v2/components/Accordion/index.js +0 -7
  181. package/styles/v2/components/Accordion/styles/button.js +0 -16
  182. package/styles/v2/components/Accordion/styles/container.js +0 -9
  183. package/styles/v2/components/Accordion/styles/index.js +0 -19
  184. package/styles/v2/components/Accordion/styles/panel.js +0 -7
  185. package/styles/v2/components/Alert/Alert.jsx +0 -121
  186. package/styles/v2/components/Alert/Alert.stories.js +0 -50
  187. package/styles/v2/components/Alert/index.js +0 -1
  188. package/styles/v2/components/Alert/styles/index.js +0 -166
  189. package/styles/v2/components/AutoSuggestSelect/AutoSuggestSelect.jsx +0 -187
  190. package/styles/v2/components/AutoSuggestSelect/index.js +0 -1
  191. package/styles/v2/components/Badge/Badge.jsx +0 -1
  192. package/styles/v2/components/Badge/Badge.stories.js +0 -32
  193. package/styles/v2/components/Badge/styles/index.js +0 -29
  194. package/styles/v2/components/Button/Button.jsx +0 -31
  195. package/styles/v2/components/Button/Button.spec.js +0 -29
  196. package/styles/v2/components/Button/Button.styles.js +0 -156
  197. package/styles/v2/components/Button/button-props.js +0 -66
  198. package/styles/v2/components/Button/index.js +0 -2
  199. package/styles/v2/components/Button/stories/button.js +0 -59
  200. package/styles/v2/components/Button/stories/index.stories.js +0 -82
  201. package/styles/v2/components/Button/stories/overview.js +0 -73
  202. package/styles/v2/components/Card/Card.jsx +0 -16
  203. package/styles/v2/components/Card/Card.stories.js +0 -33
  204. package/styles/v2/components/Checkbox/Checkbox.jsx +0 -1
  205. package/styles/v2/components/Checkbox/Checkbox.stories.js +0 -41
  206. package/styles/v2/components/Checkbox/index.js +0 -1
  207. package/styles/v2/components/Checkbox/styles/index.js +0 -31
  208. package/styles/v2/components/Container/Container.jsx +0 -10
  209. package/styles/v2/components/Container/Container.stories.js +0 -52
  210. package/styles/v2/components/Container/Container.styles.js +0 -11
  211. package/styles/v2/components/Divider/Divider.jsx +0 -31
  212. package/styles/v2/components/Divider/Divider.stories.js +0 -41
  213. package/styles/v2/components/Divider/Divider.styles.js +0 -15
  214. package/styles/v2/components/FormControl/FormControl.jsx +0 -77
  215. package/styles/v2/components/Grid/Grid.jsx +0 -25
  216. package/styles/v2/components/Grid/Grid.stories.js +0 -128
  217. package/styles/v2/components/Grid/Grid.styles.js +0 -12
  218. package/styles/v2/components/Grid/GridItem.jsx +0 -10
  219. package/styles/v2/components/Grid/GridItem.styles.js +0 -8
  220. package/styles/v2/components/Grid/index.js +0 -2
  221. package/styles/v2/components/Heading/Heading.jsx +0 -23
  222. package/styles/v2/components/Heading/Heading.stories.js +0 -40
  223. package/styles/v2/components/Heading/Heading.styles.js +0 -61
  224. package/styles/v2/components/Icon/Icon.jsx +0 -1
  225. package/styles/v2/components/Icon/Icon.stories.js +0 -38
  226. package/styles/v2/components/Image/Image.jsx +0 -97
  227. package/styles/v2/components/Image/Image.spec.js +0 -100
  228. package/styles/v2/components/Image/Image.stories.js +0 -142
  229. package/styles/v2/components/Input/Input.jsx +0 -51
  230. package/styles/v2/components/Input/Input.stories.js +0 -60
  231. package/styles/v2/components/Input/index.js +0 -1
  232. package/styles/v2/components/Input/styles/index.js +0 -49
  233. package/styles/v2/components/Link/Link.jsx +0 -1
  234. package/styles/v2/components/Link/Link.stories.js +0 -82
  235. package/styles/v2/components/Link/Link.styles.js +0 -38
  236. package/styles/v2/components/List/List.jsx +0 -57
  237. package/styles/v2/components/List/List.stories.js +0 -96
  238. package/styles/v2/components/List/index.js +0 -2
  239. package/styles/v2/components/List/styles/index.js +0 -12
  240. package/styles/v2/components/List/styles/item.styles.js +0 -5
  241. package/styles/v2/components/Loader/Loader.jsx +0 -75
  242. package/styles/v2/components/Loader/Loader.stories.js +0 -145
  243. package/styles/v2/components/Modal/Modal.jsx +0 -71
  244. package/styles/v2/components/Modal/Modal.stories.js +0 -278
  245. package/styles/v2/components/Modal/index.js +0 -1
  246. package/styles/v2/components/Modal/styles/body.js +0 -24
  247. package/styles/v2/components/Modal/styles/closeButton.js +0 -17
  248. package/styles/v2/components/Modal/styles/dialog.js +0 -10
  249. package/styles/v2/components/Modal/styles/dialogContainer.js +0 -10
  250. package/styles/v2/components/Modal/styles/footer.js +0 -5
  251. package/styles/v2/components/Modal/styles/header.js +0 -7
  252. package/styles/v2/components/Modal/styles/index.js +0 -47
  253. package/styles/v2/components/Modal/styles/overlay.js +0 -4
  254. package/styles/v2/components/Popover/Popover.jsx +0 -28
  255. package/styles/v2/components/Popover/Popover.stories.js +0 -113
  256. package/styles/v2/components/Popover/PopoverArrow.jsx +0 -10
  257. package/styles/v2/components/Popover/PopoverCloseButton.jsx +0 -10
  258. package/styles/v2/components/Popover/PopoverContent.jsx +0 -41
  259. package/styles/v2/components/Popover/index.js +0 -3
  260. package/styles/v2/components/Popover/styles/index.js +0 -21
  261. package/styles/v2/components/Popover/styles/popover-arrow.js +0 -5
  262. package/styles/v2/components/Popover/styles/popover-body.js +0 -5
  263. package/styles/v2/components/Popover/styles/popover-close-button.js +0 -17
  264. package/styles/v2/components/Popover/styles/popover-content.js +0 -16
  265. package/styles/v2/components/Popover/styles/popover-header.js +0 -6
  266. package/styles/v2/components/Popover/styles/popper.js +0 -5
  267. package/styles/v2/components/Radio/Radio.jsx +0 -50
  268. package/styles/v2/components/Radio/Radio.stories.js +0 -155
  269. package/styles/v2/components/Radio/RadioGroup.jsx +0 -69
  270. package/styles/v2/components/Radio/index.js +0 -2
  271. package/styles/v2/components/Radio/styles/index.js +0 -52
  272. package/styles/v2/components/Select/Select.jsx +0 -62
  273. package/styles/v2/components/Select/Select.stories.js +0 -60
  274. package/styles/v2/components/Select/index.js +0 -1
  275. package/styles/v2/components/Select/styles/index.js +0 -29
  276. package/styles/v2/components/Skeleton/Skeleton.stories.jsx +0 -34
  277. package/styles/v2/components/Skeleton/Skeleton.styles.js +0 -3
  278. package/styles/v2/components/Skeleton/index.js +0 -1
  279. package/styles/v2/components/Spinner/Spinner.jsx +0 -40
  280. package/styles/v2/components/Spinner/Spinner.stories.js +0 -98
  281. package/styles/v2/components/Spinner/Spinner.styles.js +0 -57
  282. package/styles/v2/components/Switch/Switch.jsx +0 -52
  283. package/styles/v2/components/Switch/Switch.stories.js +0 -88
  284. package/styles/v2/components/Switch/index.js +0 -1
  285. package/styles/v2/components/Switch/styles/index.js +0 -17
  286. package/styles/v2/components/Table/Table.jsx +0 -1
  287. package/styles/v2/components/Table/Table.stories.js +0 -90
  288. package/styles/v2/components/Table/Table.styles.js +0 -66
  289. package/styles/v2/components/Table/index.js +0 -2
  290. package/styles/v2/components/Tabs/Tabs.jsx +0 -39
  291. package/styles/v2/components/Tabs/Tabs.stories.js +0 -47
  292. package/styles/v2/components/Tabs/combineSizeWithVariant.js +0 -29
  293. package/styles/v2/components/Tabs/index.js +0 -2
  294. package/styles/v2/components/Tabs/styles/index.js +0 -40
  295. package/styles/v2/components/Text/Text.jsx +0 -35
  296. package/styles/v2/components/Text/Text.stories.js +0 -47
  297. package/styles/v2/components/Text/Text.styles.js +0 -33
  298. package/styles/v2/components/Text/combineAsWithVariant.js +0 -106
  299. package/styles/v2/components/Text/options.js +0 -92
  300. package/styles/v2/components/ThemeProvider/ThemeProvider.jsx +0 -39
  301. package/styles/v2/components/ThemeProvider/ThemeProvider.stories.js +0 -85
  302. package/styles/v2/components/index.js +0 -70
  303. package/styles/v2/components/styles.js +0 -21
  304. package/styles/v2/theme/base/breakpoints.js +0 -16
  305. package/styles/v2/theme/base/colors.js +0 -136
  306. package/styles/v2/theme/base/index.js +0 -5
  307. package/styles/v2/theme/base/sizes.js +0 -48
  308. package/styles/v2/theme/base/typography.js +0 -24
  309. package/styles/v2/theme/base/zindices.js +0 -17
  310. package/styles/v2/theme/global.js +0 -118
  311. package/styles/v2/theme/index.js +0 -27
  312. package/styles/v2/utils/Spaces.js +0 -16
  313. package/v1/assets-manifest.json +0 -5
  314. package/v1/index.html +0 -1
  315. package/v1/index.js +0 -3
  316. package/v1/index.js.LICENSE.txt +0 -23
  317. package/v1/index.js.map +0 -1
@@ -1,315 +0,0 @@
1
- import isNumber from 'lodash/isNumber';
2
- import isString from 'lodash/isString';
3
- import React, {PureComponent} from 'react';
4
- import PropTypes from 'prop-types';
5
- import classNames from 'classnames';
6
- import IconChevronLeft from '@spothero/icons/chevron-left';
7
- import IconTimes from '@spothero/icons/times';
8
- import DOMUtils from '@spothero/utils/dom';
9
- import Button from 'v1/components/Button/Button';
10
- import Portal from '../../../Portal/Portal';
11
-
12
- export default class Modal extends PureComponent {
13
- static propTypes = {
14
- /** Additional class(es) to add to the component. */
15
- className: PropTypes.string,
16
- /** Whether to render the modal to the body tag (otherwise renders to current position in DOM). */
17
- renderInBody: PropTypes.bool,
18
- /** Whether to use the background shim. */
19
- useShim: PropTypes.bool,
20
- /** Whether to show the close button. */
21
- showClose: PropTypes.bool,
22
- /** Whether to animate the Modal showing. */
23
- animateOnShow: PropTypes.bool,
24
- /** Whether to close the Modal when the shim is clicked. */
25
- closeOnShimClick: PropTypes.bool,
26
- /** The title of the modal. If one isn't provided then the title won't render. */
27
- title: PropTypes.node,
28
- /** The width of the modal. (size string, pixel value [integer] or percentage ["100%"]) */
29
- width: PropTypes.oneOfType([
30
- PropTypes.oneOf([
31
- 'extra-slim',
32
- 'slim',
33
- 'normal',
34
- 'wide',
35
- 'extra-wide',
36
- ]),
37
- PropTypes.number,
38
- PropTypes.string,
39
- ]),
40
- /** A function to execute after the modal has been shown. */
41
- onShown: PropTypes.func,
42
- /**
43
- * A function to execute after the modal has been hidden. Use this to manage state in a parent component to remove the modal from the DOM (see examples).
44
- *
45
- * @param {*} args - Any arguments that were passed to `hide()` to retrieve in the callback.
46
- */
47
- onHidden: PropTypes.func,
48
- /** A function to execute when the close button or the shim is clicked. */
49
- onCloseClick: PropTypes.func,
50
- /** Markup to pass as children to the modal. Pass either one element or an array of elements. */
51
- children: PropTypes.oneOfType([
52
- PropTypes.element,
53
- PropTypes.arrayOf(PropTypes.element),
54
- PropTypes.node,
55
- ]).isRequired,
56
- /** Indicates the current index of the content being displayed. Manage this from the ModalContent (see examples) and in the parent component's state. */
57
- activeContentIndex: PropTypes.number,
58
- /** A function to execute that helps manage state in a parent component to determine which ModalContent to show. Required when multiple ModalContents are present in the parent. */
59
- onRemoveIndex: PropTypes.func,
60
- /** Optional Redux store to pass into the rendered Modal. Required if the Modal uses any data or actions from a Redux store. */
61
- store: PropTypes.object,
62
- /** A function to execute at the end of the constructor before the Modal is rendered. */
63
- onBeforeFirstRender: PropTypes.func,
64
- /** Whether to expand the Modal to full-width on mobile */
65
- fullScreenOnMobile: PropTypes.bool,
66
- /** Optional data-testid to aid with RTL tests */
67
- 'data-testid': PropTypes.string,
68
- };
69
- static defaultProps = {
70
- renderInBody: true,
71
- useShim: true,
72
- showClose: true,
73
- width: 'normal',
74
- activeContentIndex: 0,
75
- closeOnShimClick: true,
76
- animateOnShow: true,
77
- };
78
-
79
- constructor(props) {
80
- super(props);
81
-
82
- const {width, title, onBeforeFirstRender} = this.props;
83
-
84
- this._isDynamicWidth = isNumber(width) || width.indexOf('%') > 0;
85
- this._isAnimating = false;
86
- this._isTitleString = title ? isString(title) : false;
87
- this._childHistory = [];
88
-
89
- if (onBeforeFirstRender) {
90
- onBeforeFirstRender();
91
- }
92
- }
93
-
94
- componentDidMount() {
95
- const {width} = this.props;
96
-
97
- setTimeout(() => {
98
- // if ModalContent throws an error then the container will not be defined
99
- if (!this._container) {
100
- return;
101
- }
102
-
103
- if (this._isDynamicWidth) {
104
- const newWidth = isNumber(width)
105
- ? `${width}px` // numerical width, set accordingly
106
- : width; // percentage width, retain and set
107
-
108
- DOMUtils.addClass(this._container, 'Modal-container-custom');
109
-
110
- this._container.style.width = newWidth;
111
- }
112
- this._show();
113
- }, 0);
114
- }
115
-
116
- componentWillUnmount() {
117
- DOMUtils.removeClass('html', 'Modal-open');
118
- }
119
-
120
- _onCloseClick = evt => {
121
- if (this._isAnimating) {
122
- return;
123
- }
124
-
125
- const {onCloseClick} = this.props;
126
-
127
- this.hide();
128
-
129
- if (onCloseClick) {
130
- onCloseClick();
131
- }
132
- };
133
-
134
- _onShimClick = evt => {
135
- const {useShim, closeOnShimClick} = this.props;
136
-
137
- if (
138
- useShim &&
139
- closeOnShimClick &&
140
- DOMUtils.hasClass(evt.target, 'Modal-wrapper')
141
- ) {
142
- this._onCloseClick();
143
- }
144
- };
145
-
146
- _onBackClick = evt => {
147
- this.props.onRemoveIndex();
148
- };
149
-
150
- _show() {
151
- const {useShim, renderInBody, onShown, animateOnShow} = this.props;
152
- const node = useShim ? this._modal : this._container;
153
- const showClass = useShim ? 'Modal-showing' : 'Modal-container-showing';
154
-
155
- DOMUtils.addClass(node, showClass);
156
-
157
- if (renderInBody) {
158
- DOMUtils.addClass('html', 'Modal-open');
159
- }
160
-
161
- if (!useShim) {
162
- DOMUtils.addClass(this._modal, 'Modal-no-shim');
163
- }
164
-
165
- if (animateOnShow) {
166
- this._isAnimating = true;
167
-
168
- window.transitionEnd?.(node).bind(() => {
169
- window.transitionEnd(node).unbind();
170
-
171
- if (onShown) {
172
- onShown();
173
- }
174
-
175
- this._isAnimating = false;
176
- });
177
- } else {
178
- if (onShown) {
179
- onShown();
180
- }
181
- }
182
- }
183
-
184
- _renderModal() {
185
- const {
186
- className,
187
- renderInBody,
188
- useShim,
189
- title,
190
- showClose,
191
- children,
192
- width,
193
- animateOnShow,
194
- activeContentIndex,
195
- fullScreenOnMobile,
196
- 'data-testid': dataTestId,
197
- } = this.props;
198
- const classes = classNames(
199
- 'Modal',
200
- {'Modal-inline': !renderInBody},
201
- {'Modal-animated': animateOnShow},
202
- {'Modal-showing': useShim && !animateOnShow},
203
- className
204
- );
205
- const containerClasses = classNames(
206
- 'Modal-container',
207
- {[`Modal-container-${width}`]: !this._isDynamicWidth},
208
- {'Modal-container-animated': animateOnShow},
209
- {'Modal-container-showing': !useShim && !animateOnShow}
210
- );
211
- const wrapperClasses = classNames('Modal-wrapper', {
212
- 'Modal-wrapper-full': fullScreenOnMobile,
213
- });
214
-
215
- return (
216
- <div
217
- ref={node => {
218
- this._modal = node;
219
- }}
220
- className={classes}
221
- data-testid={dataTestId}
222
- >
223
- {useShim && <div className="Modal-shim" />}
224
- <div className={wrapperClasses} onClick={this._onShimClick}>
225
- <div
226
- ref={node => {
227
- this._container = node;
228
- }}
229
- className={containerClasses}
230
- >
231
- {title && (
232
- <div className="Modal-title">
233
- {this._isTitleString ? <h1>{title}</h1> : title}
234
- </div>
235
- )}
236
- <div className="Modal-ctas">
237
- {showClose && (
238
- <Button
239
- className="Modal-close"
240
- aria-label="Close Modal"
241
- onClick={this._onCloseClick}
242
- >
243
- <IconTimes />
244
- </Button>
245
- )}
246
- {activeContentIndex > 0 && (
247
- <Button
248
- className="Modal-back"
249
- aria-label="Go Back"
250
- onClick={this._onBackClick}
251
- >
252
- <IconChevronLeft />
253
- </Button>
254
- )}
255
- </div>
256
- {children}
257
- </div>
258
- </div>
259
- </div>
260
- );
261
- }
262
-
263
- /**
264
- * Hides the Modal programmatically.
265
- *
266
- * @public
267
- * @param {*} args - The arguments to pass to the onHidden callback in cases where you may need access to something not available in Modal itself.
268
- * @returns {void}
269
- */
270
- hide(...args) {
271
- this._isAnimating = true;
272
-
273
- const {useShim, renderInBody, onHidden, animateOnShow} = this.props;
274
- const node = useShim ? this._modal : this._container;
275
- const showClass = useShim ? 'Modal-showing' : 'Modal-container-showing';
276
-
277
- if (!animateOnShow) {
278
- DOMUtils.addClass(node, showClass.replace('showing', 'animated'));
279
- }
280
-
281
- if (!useShim) {
282
- DOMUtils.removeClass(this._modal, 'Modal-no-shim');
283
- }
284
-
285
- DOMUtils.removeClass(node, showClass);
286
-
287
- if (renderInBody) {
288
- DOMUtils.removeClass('html', 'Modal-open');
289
- }
290
-
291
- window.transitionEnd?.(node).bind(() => {
292
- window.transitionEnd(node).unbind();
293
-
294
- this._isAnimating = false;
295
-
296
- if (!animateOnShow) {
297
- DOMUtils.removeClass(node, `${showClass}-animated`);
298
- }
299
-
300
- if (onHidden) {
301
- onHidden(...args);
302
- }
303
- });
304
- }
305
-
306
- render() {
307
- const {renderInBody, store} = this.props;
308
-
309
- if (renderInBody) {
310
- return <Portal store={store}>{this._renderModal()}</Portal>;
311
- } else {
312
- return this._renderModal();
313
- }
314
- }
315
- }
@@ -1,293 +0,0 @@
1
- // THIS TEST HAS A TENDENCY TO FLAKE
2
-
3
- const animationTimeout = 300;
4
-
5
- // Do not run flaky tests.
6
- describe.skip('<Modal />', () => {
7
- context('Display', () => {
8
- context('Default', () => {
9
- beforeEach(() => {
10
- cy.visitStory('v1/Modal/Display', 'Default', {
11
- onBeforeLoad: contentWindow => {
12
- contentWindow.onModalShown = evt => {
13
- console.log('modal shown'); // eslint-disable-line no-console
14
- };
15
-
16
- contentWindow.onCloseClick = evt => {
17
- console.log('close clicked'); // eslint-disable-line no-console
18
- };
19
-
20
- cy.stub(contentWindow, 'onModalShown').as(
21
- 'onModalShown'
22
- );
23
-
24
- cy.stub(contentWindow, 'onCloseClick').as(
25
- 'onCloseClick'
26
- );
27
- },
28
- })
29
- .get('.Button')
30
- .click()
31
- .wait(animationTimeout);
32
- });
33
-
34
- it('Renders properly', () => {
35
- cy.get('@onModalShown')
36
- .should('be.called')
37
- .get('.Modal')
38
- .should('have.class', 'Modal-showing')
39
- // check to make sure the parent (2 elements up) is the body
40
- .parent()
41
- .parent()
42
- .then($el => {
43
- expect($el.prop('tagName').toLowerCase()).to.eq('body');
44
- })
45
- // confirm other default elements exist
46
- .get('.Modal-title')
47
- .get('.Modal-content')
48
- .get('.Modal-close')
49
- .get('html')
50
- .should('have.class', 'Modal-open');
51
- });
52
-
53
- it('Closes when close is clicked', () => {
54
- cy.get('.Modal-close')
55
- .click()
56
- .get('@onCloseClick')
57
- .should('be.called')
58
- .wait(animationTimeout)
59
- .get('.Modal')
60
- .should('not.exist');
61
- });
62
-
63
- it('Closes when shim is clicked', () => {
64
- cy.get('.Modal-wrapper')
65
- .click('topLeft')
66
- .get('@onCloseClick')
67
- .should('be.called')
68
- .wait(animationTimeout)
69
- .get('.Modal')
70
- .should('not.exist');
71
- });
72
- });
73
-
74
- context('Inside Element', () => {
75
- it('Renders inside of an element and not directly in the body', () => {
76
- cy.visitStory('v1/Modal/Display', 'InsideElement')
77
- .get('.Button')
78
- .click()
79
- .wait(animationTimeout)
80
- .get('.Modal')
81
- .parent()
82
- .should('have.class', 'ModalInElement-container');
83
- });
84
- });
85
-
86
- context('No Close', () => {
87
- it(`Does not render the close button`, () => {
88
- cy.visitStory('v1/Modal/Display', 'NoCloseButton')
89
- .get('.Button')
90
- .click()
91
- .wait(animationTimeout)
92
- .get('.Modal-close')
93
- .should('not.exist');
94
- });
95
- });
96
-
97
- context('No Title', () => {
98
- it(`Does not render the title if one isn't provided`, () => {
99
- cy.visitStory('v1/Modal/Display', 'NoTitle')
100
- .get('.Button')
101
- .click()
102
- .wait(animationTimeout)
103
- .get('.Modal-title')
104
- .should('not.exist');
105
- });
106
- });
107
-
108
- context('No Shim', () => {
109
- it(`Does not render the shim behind the modal`, () => {
110
- cy.visitStory('v1/Modal/Display', 'NoShim')
111
- .get('.Button')
112
- .click()
113
- .wait(animationTimeout)
114
- .get('.Modal-shim')
115
- .should('not.exist')
116
- // make sure close button still has pointer events and is clickable
117
- .get('.Modal-close')
118
- .click()
119
- .wait(animationTimeout)
120
- .get('.Modal')
121
- .should('not.exist');
122
- });
123
- });
124
-
125
- context('Redux', () => {
126
- it('Passes values through from a Redux store properly', () => {
127
- cy.visitStory('v1/Modal/Display', 'WithRedux')
128
- .get('.Button')
129
- .click()
130
- .wait(animationTimeout)
131
- .get('.Modal-content')
132
- .contains('Redux items here!');
133
- });
134
- });
135
-
136
- context('Mobile Fullscreen', () => {
137
- it('Renders fullscreen', () => {
138
- cy.visitStory('v1/Modal/Display', 'FullScreenOnMobile')
139
- .viewport('iphone-6')
140
- .wait(animationTimeout)
141
- .get('.Button')
142
- .click()
143
- .get('.Modal-wrapper')
144
- .should('have.class', 'Modal-wrapper-full');
145
- });
146
- });
147
- });
148
-
149
- context('Width', () => {
150
- context('Predefined Size', () => {
151
- it('Renders with the correct container size class', () => {
152
- cy.visitStory('v1/Modal/Width', 'SizeWidth')
153
- .get('.Button')
154
- .click()
155
- .wait(animationTimeout)
156
- .get('.Modal-container')
157
- .should('have.class', 'Modal-container-extra-wide');
158
- });
159
- });
160
-
161
- context('Custom Pixels', () => {
162
- it('Renders with the correct container size style', () => {
163
- cy.visitStory('v1/Modal/Width', 'PixelWidth')
164
- .get('.Button')
165
- .click()
166
- .wait(animationTimeout)
167
- .get('.Modal-container')
168
- .should('have.class', 'Modal-container-custom')
169
- .and('have.attr', 'style', 'width: 300px;');
170
- });
171
- });
172
-
173
- context('Percentage', () => {
174
- it('Renders with the correct container size as a percentage', () => {
175
- cy.visitStory('v1/Modal/Width', 'PercentageWidth')
176
- .get('.Button')
177
- .click()
178
- .wait(animationTimeout)
179
- .get('.Modal-container')
180
- .should('have.class', 'Modal-container-custom')
181
- .and('have.attr', 'style', 'width: 75%;');
182
- });
183
- });
184
- });
185
-
186
- context('Content', () => {
187
- context('No Padding', () => {
188
- it('Renders the content with no padding applied', () => {
189
- cy.visitStory('v1/Modal/Content', 'NoContentPadding')
190
- .get('.Button')
191
- .click()
192
- .wait(animationTimeout)
193
- .get('.Modal-content')
194
- .should('have.class', 'Modal-content-flush');
195
- });
196
- });
197
-
198
- context('Maximum Height', () => {
199
- it('Renders the content with a maximum height', () => {
200
- cy.visitStory('v1/Modal/Content', 'MaxHeight')
201
- .get('.Button')
202
- .click()
203
- .wait(animationTimeout)
204
- .get('.Modal-content')
205
- .should('have.attr', 'style', 'max-height: 400px;');
206
- });
207
- });
208
-
209
- context('Custom Height', () => {
210
- it('Renders the content with a custom height', () => {
211
- cy.visitStory('v1/Modal/Content', 'CustomHeight')
212
- .get('.Button')
213
- .click()
214
- .wait(animationTimeout)
215
- .get('.Modal-content')
216
- .should('have.class', 'Modal-content-with-height')
217
- .and('have.attr', 'style', 'max-height: 244px;'); // see component for proper calculation method for this
218
- });
219
- });
220
-
221
- context('Html Content', () => {
222
- it('Renders an HTML block in the content area', () => {
223
- cy.visitStory('v1/Modal/Content', 'HtmlContent')
224
- .get('.Button')
225
- .click()
226
- .wait(animationTimeout)
227
- .get('.Modal-content-wrapper div')
228
- .contains('This is some HTML modal content.');
229
- });
230
- });
231
-
232
- context('Html Content Error', () => {
233
- it('Does not render if both the html prop and children are present', async () => {
234
- await cy
235
- .visitStory('v1/Modal/Content', 'HtmlContentError')
236
- .get('.Button')
237
- .click()
238
- .wait(animationTimeout)
239
- .get('.Modal-content')
240
- .should('not.exist');
241
- });
242
- });
243
-
244
- context('Multiple', () => {
245
- it('Properly navigates between multiple content items', () => {
246
- cy.visitStory('v1/Modal/Content', 'MultipleModals')
247
- .get('.Button')
248
- .click()
249
- .wait(animationTimeout)
250
- .get('.Modal-content')
251
- .should('have.class', 'ModalContent-0')
252
- .get('.ModalContent-see-more')
253
- .click()
254
- .get('.Modal-content-wrapper')
255
- .contains('This is content index 1.')
256
- .get('.Modal-back')
257
- .click()
258
- .get('.Modal-content-wrapper')
259
- .contains('This is content index 0.');
260
- });
261
- });
262
-
263
- context('Start Index', () => {
264
- it('Displays the correct content item when set', () => {
265
- cy.visitStory('v1/Modal/Content', 'WithStartIndex')
266
- .get('.Button')
267
- .click()
268
- .wait(animationTimeout)
269
- .get('.Modal-content')
270
- .should('have.class', 'ModalContent-1')
271
- .get('.Modal-content-wrapper')
272
- .contains('This is content index 1.')
273
- .get('.Modal-back');
274
- });
275
- });
276
- });
277
-
278
- context('Methods', () => {
279
- context('Hide', () => {
280
- it('Calling hide() will hide the modal', () => {
281
- cy.visitStory('v1/Modal/Methods', 'OnHide')
282
- .get('.Button')
283
- .click()
284
- .wait(animationTimeout)
285
- .get('.ModalContent-hide')
286
- .click()
287
- .wait(animationTimeout)
288
- .get('.Modal')
289
- .should('not.exist');
290
- });
291
- });
292
- });
293
- });