@motech-development/breeze-ui 2.3.1 → 3.0.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 (248) hide show
  1. package/dist/Cabin-LICENSE.txt +93 -0
  2. package/dist/assets/cabin-latin-wght-normal-DZW_uTKI.woff2 +0 -0
  3. package/dist/formatting/FormattedDateTime/FormattedDateTime.d.ts +17 -0
  4. package/dist/formatting/FormattedDateTime/FormattedDateTime.d.ts.map +1 -0
  5. package/dist/formatting/FormattedList/FormattedList.d.ts +17 -0
  6. package/dist/formatting/FormattedList/FormattedList.d.ts.map +1 -0
  7. package/dist/formatting/FormattedNumber/FormattedNumber.d.ts +17 -0
  8. package/dist/formatting/FormattedNumber/FormattedNumber.d.ts.map +1 -0
  9. package/dist/formatting/RelativeTime/RelativeTime.d.ts +21 -0
  10. package/dist/formatting/RelativeTime/RelativeTime.d.ts.map +1 -0
  11. package/dist/icons/index.d.ts +77 -0
  12. package/dist/icons/index.d.ts.map +1 -0
  13. package/dist/icons.js +27 -0
  14. package/dist/index.d.ts +100 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +5759 -0
  17. package/dist/internal/collections/VirtualizedCollection.d.ts +15 -0
  18. package/dist/internal/collections/VirtualizedCollection.d.ts.map +1 -0
  19. package/dist/internal/collections/useCollectionEmptyContent.d.ts +3 -0
  20. package/dist/internal/collections/useCollectionEmptyContent.d.ts.map +1 -0
  21. package/dist/internal/collections/useLoadMoreHandler.d.ts +7 -0
  22. package/dist/internal/collections/useLoadMoreHandler.d.ts.map +1 -0
  23. package/dist/internal/date/conversion.d.ts +16 -0
  24. package/dist/internal/date/conversion.d.ts.map +1 -0
  25. package/dist/internal/files/validation.d.ts +17 -0
  26. package/dist/internal/files/validation.d.ts.map +1 -0
  27. package/dist/internal/hooks/useForwardedRef.d.ts +3 -0
  28. package/dist/internal/hooks/useForwardedRef.d.ts.map +1 -0
  29. package/dist/internal/react-aria/DisclosureParts.d.ts +27 -0
  30. package/dist/internal/react-aria/DisclosureParts.d.ts.map +1 -0
  31. package/dist/internal/react-aria/OverlayParts.d.ts +55 -0
  32. package/dist/internal/react-aria/OverlayParts.d.ts.map +1 -0
  33. package/dist/internal/react-aria/renderNativeButton.d.ts +6 -0
  34. package/dist/internal/react-aria/renderNativeButton.d.ts.map +1 -0
  35. package/dist/internal/styling/actions.d.ts +72 -0
  36. package/dist/internal/styling/actions.d.ts.map +1 -0
  37. package/dist/internal/styling/formControls.d.ts +23 -0
  38. package/dist/internal/styling/formControls.d.ts.map +1 -0
  39. package/dist/internal/styling/layout.d.ts +108 -0
  40. package/dist/internal/styling/layout.d.ts.map +1 -0
  41. package/dist/internal/styling/responsive.d.ts +22 -0
  42. package/dist/internal/styling/responsive.d.ts.map +1 -0
  43. package/dist/internal/styling/visual.d.ts +7 -0
  44. package/dist/internal/styling/visual.d.ts.map +1 -0
  45. package/dist/internal/types/collection.d.ts +60 -0
  46. package/dist/internal/types/collection.d.ts.map +1 -0
  47. package/dist/internal/types/date.d.ts +8 -0
  48. package/dist/internal/types/date.d.ts.map +1 -0
  49. package/dist/internal/types/file.d.ts +21 -0
  50. package/dist/internal/types/file.d.ts.map +1 -0
  51. package/dist/internal/types/native.d.ts +8 -0
  52. package/dist/internal/types/native.d.ts.map +1 -0
  53. package/dist/patterns/ApplicationShell/ApplicationShell.d.ts +32 -0
  54. package/dist/patterns/ApplicationShell/ApplicationShell.d.ts.map +1 -0
  55. package/dist/patterns/ButtonGroup/ButtonGroup.d.ts +20 -0
  56. package/dist/patterns/ButtonGroup/ButtonGroup.d.ts.map +1 -0
  57. package/dist/patterns/ConfirmationDialog/ConfirmationDialog.d.ts +58 -0
  58. package/dist/patterns/ConfirmationDialog/ConfirmationDialog.d.ts.map +1 -0
  59. package/dist/patterns/ContextSwitcher/ContextSwitcher.d.ts +42 -0
  60. package/dist/patterns/ContextSwitcher/ContextSwitcher.d.ts.map +1 -0
  61. package/dist/patterns/FileAttachment/FileAttachment.d.ts +17 -0
  62. package/dist/patterns/FileAttachment/FileAttachment.d.ts.map +1 -0
  63. package/dist/patterns/FileUpload/FileUpload.d.ts +35 -0
  64. package/dist/patterns/FileUpload/FileUpload.d.ts.map +1 -0
  65. package/dist/patterns/FormActions/FormActions.d.ts +25 -0
  66. package/dist/patterns/FormActions/FormActions.d.ts.map +1 -0
  67. package/dist/patterns/FormSection/FormSection.d.ts +31 -0
  68. package/dist/patterns/FormSection/FormSection.d.ts.map +1 -0
  69. package/dist/patterns/MetricCard/MetricCard.d.ts +28 -0
  70. package/dist/patterns/MetricCard/MetricCard.d.ts.map +1 -0
  71. package/dist/patterns/NavigationSection/NavigationSection.d.ts +17 -0
  72. package/dist/patterns/NavigationSection/NavigationSection.d.ts.map +1 -0
  73. package/dist/patterns/PageHeader/PageHeader.d.ts +21 -0
  74. package/dist/patterns/PageHeader/PageHeader.d.ts.map +1 -0
  75. package/dist/patterns/Pagination/Pagination.d.ts +23 -0
  76. package/dist/patterns/Pagination/Pagination.d.ts.map +1 -0
  77. package/dist/patterns/PasswordField/PasswordField.d.ts +58 -0
  78. package/dist/patterns/PasswordField/PasswordField.d.ts.map +1 -0
  79. package/dist/patterns/SectionHeader/SectionHeader.d.ts +21 -0
  80. package/dist/patterns/SectionHeader/SectionHeader.d.ts.map +1 -0
  81. package/dist/patterns/SegmentedControl/SegmentedControl.d.ts +56 -0
  82. package/dist/patterns/SegmentedControl/SegmentedControl.d.ts.map +1 -0
  83. package/dist/patterns/StatePanel/StatePanel.d.ts +25 -0
  84. package/dist/patterns/StatePanel/StatePanel.d.ts.map +1 -0
  85. package/dist/patterns/UserMenu/UserMenu.d.ts +45 -0
  86. package/dist/patterns/UserMenu/UserMenu.d.ts.map +1 -0
  87. package/dist/primitives/Accordion/Accordion.d.ts +76 -0
  88. package/dist/primitives/Accordion/Accordion.d.ts.map +1 -0
  89. package/dist/primitives/Alert/Alert.d.ts +23 -0
  90. package/dist/primitives/Alert/Alert.d.ts.map +1 -0
  91. package/dist/primitives/AlertDialog/AlertDialog.d.ts +63 -0
  92. package/dist/primitives/AlertDialog/AlertDialog.d.ts.map +1 -0
  93. package/dist/primitives/Avatar/Avatar.d.ts +308 -0
  94. package/dist/primitives/Avatar/Avatar.d.ts.map +1 -0
  95. package/dist/primitives/Badge/Badge.d.ts +299 -0
  96. package/dist/primitives/Badge/Badge.d.ts.map +1 -0
  97. package/dist/primitives/Breadcrumbs/Breadcrumbs.d.ts +40 -0
  98. package/dist/primitives/Breadcrumbs/Breadcrumbs.d.ts.map +1 -0
  99. package/dist/primitives/Button/Button.d.ts +36 -0
  100. package/dist/primitives/Button/Button.d.ts.map +1 -0
  101. package/dist/primitives/Calendar/Calendar.d.ts +61 -0
  102. package/dist/primitives/Calendar/Calendar.d.ts.map +1 -0
  103. package/dist/primitives/Card/Card.d.ts +63 -0
  104. package/dist/primitives/Card/Card.d.ts.map +1 -0
  105. package/dist/primitives/Center/Center.d.ts +295 -0
  106. package/dist/primitives/Center/Center.d.ts.map +1 -0
  107. package/dist/primitives/Checkbox/Checkbox.d.ts +106 -0
  108. package/dist/primitives/Checkbox/Checkbox.d.ts.map +1 -0
  109. package/dist/primitives/CheckboxGroup/CheckboxGroup.d.ts +76 -0
  110. package/dist/primitives/CheckboxGroup/CheckboxGroup.d.ts.map +1 -0
  111. package/dist/primitives/ComboBox/ComboBox.d.ts +174 -0
  112. package/dist/primitives/ComboBox/ComboBox.d.ts.map +1 -0
  113. package/dist/primitives/Container/Container.d.ts +296 -0
  114. package/dist/primitives/Container/Container.d.ts.map +1 -0
  115. package/dist/primitives/DateField/DateField.d.ts +87 -0
  116. package/dist/primitives/DateField/DateField.d.ts.map +1 -0
  117. package/dist/primitives/DatePicker/DatePicker.d.ts +74 -0
  118. package/dist/primitives/DatePicker/DatePicker.d.ts.map +1 -0
  119. package/dist/primitives/DateRangePicker/DateRangePicker.d.ts +116 -0
  120. package/dist/primitives/DateRangePicker/DateRangePicker.d.ts.map +1 -0
  121. package/dist/primitives/DateTimePicker/DateTimePicker.d.ts +93 -0
  122. package/dist/primitives/DateTimePicker/DateTimePicker.d.ts.map +1 -0
  123. package/dist/primitives/DescriptionList/DescriptionList.d.ts +45 -0
  124. package/dist/primitives/DescriptionList/DescriptionList.d.ts.map +1 -0
  125. package/dist/primitives/Dialog/Dialog.d.ts +56 -0
  126. package/dist/primitives/Dialog/Dialog.d.ts.map +1 -0
  127. package/dist/primitives/Disclosure/Disclosure.d.ts +59 -0
  128. package/dist/primitives/Disclosure/Disclosure.d.ts.map +1 -0
  129. package/dist/primitives/Drawer/Drawer.d.ts +87 -0
  130. package/dist/primitives/Drawer/Drawer.d.ts.map +1 -0
  131. package/dist/primitives/DropZone/DropZone.d.ts +85 -0
  132. package/dist/primitives/DropZone/DropZone.d.ts.map +1 -0
  133. package/dist/primitives/Fieldset/Fieldset.d.ts +57 -0
  134. package/dist/primitives/Fieldset/Fieldset.d.ts.map +1 -0
  135. package/dist/primitives/FileTrigger/FileTrigger.d.ts +72 -0
  136. package/dist/primitives/FileTrigger/FileTrigger.d.ts.map +1 -0
  137. package/dist/primitives/Grid/Grid.d.ts +307 -0
  138. package/dist/primitives/Grid/Grid.d.ts.map +1 -0
  139. package/dist/primitives/GridList/GridList.d.ts +131 -0
  140. package/dist/primitives/GridList/GridList.d.ts.map +1 -0
  141. package/dist/primitives/IconButton/IconButton.d.ts +37 -0
  142. package/dist/primitives/IconButton/IconButton.d.ts.map +1 -0
  143. package/dist/primitives/IconTile/IconTile.d.ts +312 -0
  144. package/dist/primitives/IconTile/IconTile.d.ts.map +1 -0
  145. package/dist/primitives/Inline/Inline.d.ts +302 -0
  146. package/dist/primitives/Inline/Inline.d.ts.map +1 -0
  147. package/dist/primitives/InputGroup/InputGroup.d.ts +36 -0
  148. package/dist/primitives/InputGroup/InputGroup.d.ts.map +1 -0
  149. package/dist/primitives/Link/Link.d.ts +28 -0
  150. package/dist/primitives/Link/Link.d.ts.map +1 -0
  151. package/dist/primitives/LinkButton/LinkButton.d.ts +31 -0
  152. package/dist/primitives/LinkButton/LinkButton.d.ts.map +1 -0
  153. package/dist/primitives/List/List.d.ts +29 -0
  154. package/dist/primitives/List/List.d.ts.map +1 -0
  155. package/dist/primitives/ListBox/ListBox.d.ts +102 -0
  156. package/dist/primitives/ListBox/ListBox.d.ts.map +1 -0
  157. package/dist/primitives/Logo/Logo.d.ts +292 -0
  158. package/dist/primitives/Logo/Logo.d.ts.map +1 -0
  159. package/dist/primitives/Menu/Menu.d.ts +151 -0
  160. package/dist/primitives/Menu/Menu.d.ts.map +1 -0
  161. package/dist/primitives/Meter/Meter.d.ts +28 -0
  162. package/dist/primitives/Meter/Meter.d.ts.map +1 -0
  163. package/dist/primitives/NavigationList/NavigationList.d.ts +44 -0
  164. package/dist/primitives/NavigationList/NavigationList.d.ts.map +1 -0
  165. package/dist/primitives/NumberField/NumberField.d.ts +118 -0
  166. package/dist/primitives/NumberField/NumberField.d.ts.map +1 -0
  167. package/dist/primitives/Popover/Popover.d.ts +61 -0
  168. package/dist/primitives/Popover/Popover.d.ts.map +1 -0
  169. package/dist/primitives/ProgressBar/ProgressBar.d.ts +41 -0
  170. package/dist/primitives/ProgressBar/ProgressBar.d.ts.map +1 -0
  171. package/dist/primitives/RadioGroup/RadioGroup.d.ts +131 -0
  172. package/dist/primitives/RadioGroup/RadioGroup.d.ts.map +1 -0
  173. package/dist/primitives/RangeCalendar/RangeCalendar.d.ts +57 -0
  174. package/dist/primitives/RangeCalendar/RangeCalendar.d.ts.map +1 -0
  175. package/dist/primitives/SearchField/SearchField.d.ts +70 -0
  176. package/dist/primitives/SearchField/SearchField.d.ts.map +1 -0
  177. package/dist/primitives/Select/Select.d.ts +110 -0
  178. package/dist/primitives/Select/Select.d.ts.map +1 -0
  179. package/dist/primitives/Separator/Separator.d.ts +302 -0
  180. package/dist/primitives/Separator/Separator.d.ts.map +1 -0
  181. package/dist/primitives/Skeleton/Skeleton.d.ts +27 -0
  182. package/dist/primitives/Skeleton/Skeleton.d.ts.map +1 -0
  183. package/dist/primitives/SkipLink/SkipLink.d.ts +21 -0
  184. package/dist/primitives/SkipLink/SkipLink.d.ts.map +1 -0
  185. package/dist/primitives/Slider/Slider.d.ts +148 -0
  186. package/dist/primitives/Slider/Slider.d.ts.map +1 -0
  187. package/dist/primitives/Spinner/Spinner.d.ts +23 -0
  188. package/dist/primitives/Spinner/Spinner.d.ts.map +1 -0
  189. package/dist/primitives/Stack/Stack.d.ts +300 -0
  190. package/dist/primitives/Stack/Stack.d.ts.map +1 -0
  191. package/dist/primitives/Stepper/Stepper.d.ts +42 -0
  192. package/dist/primitives/Stepper/Stepper.d.ts.map +1 -0
  193. package/dist/primitives/Surface/Surface.d.ts +306 -0
  194. package/dist/primitives/Surface/Surface.d.ts.map +1 -0
  195. package/dist/primitives/Switch/Switch.d.ts +118 -0
  196. package/dist/primitives/Switch/Switch.d.ts.map +1 -0
  197. package/dist/primitives/Table/Table.d.ts +226 -0
  198. package/dist/primitives/Table/Table.d.ts.map +1 -0
  199. package/dist/primitives/Tabs/Tabs.d.ts +105 -0
  200. package/dist/primitives/Tabs/Tabs.d.ts.map +1 -0
  201. package/dist/primitives/Tag/Tag.d.ts +18 -0
  202. package/dist/primitives/Tag/Tag.d.ts.map +1 -0
  203. package/dist/primitives/TagGroup/TagGroup.d.ts +60 -0
  204. package/dist/primitives/TagGroup/TagGroup.d.ts.map +1 -0
  205. package/dist/primitives/TextArea/TextArea.d.ts +40 -0
  206. package/dist/primitives/TextArea/TextArea.d.ts.map +1 -0
  207. package/dist/primitives/TextField/TextField.d.ts +102 -0
  208. package/dist/primitives/TextField/TextField.d.ts.map +1 -0
  209. package/dist/primitives/TimeField/TimeField.d.ts +58 -0
  210. package/dist/primitives/TimeField/TimeField.d.ts.map +1 -0
  211. package/dist/primitives/Toast/Toast.d.ts +88 -0
  212. package/dist/primitives/Toast/Toast.d.ts.map +1 -0
  213. package/dist/primitives/ToggleButton/ToggleButton.d.ts +55 -0
  214. package/dist/primitives/ToggleButton/ToggleButton.d.ts.map +1 -0
  215. package/dist/primitives/ToggleGroup/ToggleGroup.d.ts +48 -0
  216. package/dist/primitives/ToggleGroup/ToggleGroup.d.ts.map +1 -0
  217. package/dist/primitives/Toolbar/Toolbar.d.ts +17 -0
  218. package/dist/primitives/Toolbar/Toolbar.d.ts.map +1 -0
  219. package/dist/primitives/Tooltip/Tooltip.d.ts +66 -0
  220. package/dist/primitives/Tooltip/Tooltip.d.ts.map +1 -0
  221. package/dist/primitives/Typography/Typography.d.ts +317 -0
  222. package/dist/primitives/Typography/Typography.d.ts.map +1 -0
  223. package/dist/primitives/VisuallyHidden/VisuallyHidden.d.ts +294 -0
  224. package/dist/primitives/VisuallyHidden/VisuallyHidden.d.ts.map +1 -0
  225. package/dist/primitives/date/CalendarParts.d.ts +26 -0
  226. package/dist/primitives/date/CalendarParts.d.ts.map +1 -0
  227. package/dist/primitives/date/DateInput.d.ts +9 -0
  228. package/dist/primitives/date/DateInput.d.ts.map +1 -0
  229. package/dist/primitives/date/PickerFieldParts.d.ts +11 -0
  230. package/dist/primitives/date/PickerFieldParts.d.ts.map +1 -0
  231. package/dist/primitives/date/PickerParts.d.ts +29 -0
  232. package/dist/primitives/date/PickerParts.d.ts.map +1 -0
  233. package/dist/primitives/file/FileFeedback.d.ts +14 -0
  234. package/dist/primitives/file/FileFeedback.d.ts.map +1 -0
  235. package/dist/provider/BreezeContext.d.ts +19 -0
  236. package/dist/provider/BreezeContext.d.ts.map +1 -0
  237. package/dist/provider/BreezeProvider.d.ts +30 -0
  238. package/dist/provider/BreezeProvider.d.ts.map +1 -0
  239. package/dist/provider/messages.d.ts +43 -0
  240. package/dist/provider/messages.d.ts.map +1 -0
  241. package/dist/reset.css +2 -0
  242. package/dist/styles.css +2 -0
  243. package/package.json +63 -91
  244. package/lib/index.cjs.js +0 -2900
  245. package/lib/index.cjs.js.map +0 -1
  246. package/lib/index.d.ts +0 -489
  247. package/lib/index.esm.js +0 -2846
  248. package/lib/index.esm.js.map +0 -1
package/lib/index.esm.js DELETED
@@ -1,2846 +0,0 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { faTimes, faAngleDoubleLeft, faAngleLeft, faAngleRight, faAngleDoubleRight, faExclamation, faCalendar, faBell, faAsterisk, faAngleDown, faExclamationCircle, faCheckCircle, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
3
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
- import { useRef, useState, useEffect, Suspense, Children, createContext, useContext, useCallback, useMemo } from 'react';
5
- import styled, { ThemeProvider, createGlobalStyle } from 'styled-components';
6
- import reset from 'styled-reset';
7
- import { darken, rgba } from 'polished';
8
- import { DateTime as DateTime$1, Info } from 'luxon';
9
- import { getIn, Field, Formik, Form as Form$1 } from 'formik';
10
- import { Manager, Reference, Popper, usePopper } from 'react-popper';
11
- import { Link as Link$1, useLocation } from 'react-router-dom';
12
- import { createPortal } from 'react-dom';
13
- import { PatternFormat, NumericFormat } from 'react-number-format';
14
-
15
- const alertTheme = {
16
- danger: {
17
- background: 'rgb(199,56,79)',
18
- colour: '#fff'
19
- },
20
- primary: {
21
- background: '#007fa8',
22
- colour: '#fff'
23
- },
24
- secondary: {
25
- background: '#f6f9fc',
26
- colour: '#333'
27
- },
28
- success: {
29
- background: 'rgb(0,128,93)',
30
- colour: '#fff'
31
- }
32
- };
33
- const BaseAlert = styled.div`
34
- ${({ $colour, $icon, $spacing, theme })=>`
35
- background-color: ${theme[$colour].background};
36
- color: ${theme[$colour].colour};
37
- margin-bottom: ${(()=>{
38
- switch($spacing){
39
- case 'lg':
40
- return '20px';
41
- case 'md':
42
- return '10px';
43
- default:
44
- return '5px';
45
- }
46
- })()};
47
- padding: 12px 56px 12px ${$icon ? '56px' : '20px'};
48
- position: relative;
49
- `}
50
- `;
51
- const AlertIconWrapper = styled.div`
52
- left: 20px;
53
- position: absolute;
54
- top: 12px;
55
- `;
56
- const AlertDismissButton = styled.button`
57
- ${({ $colour, theme })=>`
58
- appearance: none;
59
- background-color: ${theme[$colour].background};
60
- border: 0;
61
- color: ${theme[$colour].colour};
62
- cursor: pointer;
63
- font-size: inherit;
64
- margin: 0;
65
- padding: 0;
66
- position: absolute;
67
- right: 20px;
68
- top: 12px;
69
- `}
70
- `;
71
- const Alert = ({ colour = 'primary', dismissable = false, icon, message, spacing = 'md', onDismiss })=>{
72
- const renderCheck = process.env.NODE_ENV === 'development' ? 2 : 1;
73
- const renderCount = useRef(0);
74
- const [visible, setVisiblity] = useState(true);
75
- const dismiss = ()=>{
76
- setVisiblity(false);
77
- if (onDismiss) {
78
- onDismiss();
79
- }
80
- };
81
- useEffect(()=>{
82
- renderCount.current += 1;
83
- }, []);
84
- useEffect(()=>()=>{
85
- if (renderCount.current >= renderCheck) {
86
- setVisiblity(false);
87
- }
88
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
89
- []);
90
- useEffect(()=>{
91
- let timeout;
92
- if (typeof dismissable === 'number') {
93
- timeout = setTimeout(dismiss, dismissable);
94
- }
95
- return ()=>{
96
- if (timeout) {
97
- clearTimeout(timeout);
98
- }
99
- };
100
- // eslint-disable-next-line react-hooks/exhaustive-deps
101
- }, []);
102
- if (visible) {
103
- return /*#__PURE__*/ jsx(ThemeProvider, {
104
- theme: alertTheme,
105
- children: /*#__PURE__*/ jsxs(BaseAlert, {
106
- role: "alert",
107
- $colour: colour,
108
- $icon: !!icon,
109
- $spacing: spacing,
110
- children: [
111
- icon && /*#__PURE__*/ jsx(AlertIconWrapper, {
112
- children: icon
113
- }),
114
- message,
115
- dismissable && /*#__PURE__*/ jsx(AlertDismissButton, {
116
- type: "button",
117
- "aria-label": "Dismiss",
118
- $colour: colour,
119
- onClick: dismiss,
120
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
121
- icon: faTimes
122
- })
123
- })
124
- ]
125
- })
126
- });
127
- }
128
- return null;
129
- };
130
-
131
- const AppBarInner = styled.div`
132
- align-items: center;
133
- display: flex;
134
- min-height: 64px;
135
- padding: 0 1rem;
136
- `;
137
- const AppBarToolbar = styled.header`
138
- ${({ $colour, theme })=>`
139
- background-color: ${theme[$colour].background};
140
- border-bottom: 1px solid ${theme[$colour].border};
141
- box-sizing: border-box;
142
- color: ${theme[$colour].colour};
143
- display: flex;
144
- flex-direction: column;
145
- flex-shrink: 0;
146
- user-select: none;
147
- width: 100%;
148
- z-index: 1100;
149
- `}
150
- `;
151
- const appBarTheme = {
152
- primary: {
153
- background: '#161616',
154
- border: '#222',
155
- colour: '#fff'
156
- },
157
- secondary: {
158
- background: '#f6f9fc',
159
- border: '#ccc',
160
- colour: '#333'
161
- }
162
- };
163
- const AppBarBase = styled.div`
164
- ${({ $fixed })=>`
165
- box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 5px 8px 0 rgba(0, 0, 0, 0.14),
166
- 0 1px 14px 0 rgba(0, 0, 0, 0.12);
167
- flex-grow: 1;
168
- left: 0;
169
- position: ${$fixed ? 'fixed' : 'relative'};
170
- top: 0;
171
- width: 100%;
172
- z-index: 10;
173
- `}
174
- `;
175
- const AppBar = ({ children, colour = 'primary', element = 'header', fixed = false })=>/*#__PURE__*/ jsx(ThemeProvider, {
176
- theme: appBarTheme,
177
- children: /*#__PURE__*/ jsx(AppBarBase, {
178
- $fixed: fixed,
179
- children: /*#__PURE__*/ jsx(AppBarToolbar, {
180
- as: element,
181
- $colour: colour,
182
- children: /*#__PURE__*/ jsx(AppBarInner, {
183
- children: children
184
- })
185
- })
186
- })
187
- });
188
-
189
- const Image = styled.img`
190
- ${({ $width })=>`
191
- display: block;
192
- width: ${$width ? `${$width}px` : 'auto'};
193
- `}
194
- `;
195
- const Wrapper$5 = styled.div`
196
- ${({ $width })=>`
197
- border-radius: 50%;
198
- display: inline-block;
199
- overflow: hidden;
200
- width: ${$width ? `${$width}px` : 'auto'};
201
-
202
- ${$width ? `min-width: ${$width}px` : ''}
203
- `}
204
- `;
205
- const Avatar = ({ alt, src, width = 0 })=>/*#__PURE__*/ jsx(Wrapper$5, {
206
- $width: width,
207
- children: /*#__PURE__*/ jsx(Image, {
208
- alt: alt,
209
- src: src,
210
- $width: width
211
- })
212
- });
213
-
214
- const BaseStyles = createGlobalStyle`
215
- ${reset}
216
-
217
- body,
218
- html {
219
- background: #161616;
220
- color: #fff;
221
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
222
- }
223
-
224
- *,
225
- *:before,
226
- *:after {
227
- box-sizing: border-box;
228
- }
229
- `;
230
-
231
- const useWindowSize = ()=>{
232
- const getWindowSize = ()=>({
233
- height: window.innerHeight,
234
- width: window.innerWidth
235
- });
236
- const [windowSize, setWindowSize] = useState(getWindowSize);
237
- const handleResize = ()=>{
238
- setWindowSize(getWindowSize);
239
- };
240
- useEffect(()=>{
241
- window.addEventListener('resize', handleResize);
242
- return ()=>{
243
- window.removeEventListener('resize', handleResize);
244
- };
245
- // eslint-disable-next-line react-hooks/exhaustive-deps
246
- }, []);
247
- return windowSize;
248
- };
249
-
250
- const getBreakpoint = ()=>{
251
- const lg = window.matchMedia('(min-width: 992px)');
252
- const md = window.matchMedia('(min-width: 768px)');
253
- const sm = window.matchMedia('(min-width: 576px)');
254
- if (lg.matches) {
255
- return 'lg';
256
- }
257
- if (md.matches) {
258
- return 'md';
259
- }
260
- if (sm.matches) {
261
- return 'sm';
262
- }
263
- return 'xs';
264
- };
265
- const useBreakpoint = ()=>{
266
- const [breakpoint, setBreakpoint] = useState('xs');
267
- const { width } = useWindowSize();
268
- useEffect(()=>{
269
- setBreakpoint(getBreakpoint);
270
- }, [
271
- width
272
- ]);
273
- return breakpoint;
274
- };
275
-
276
- const Breakpoint = ({ children, lg = true, md = true, sm = true, xs = true })=>{
277
- const breakpoint = useBreakpoint();
278
- const matrix = {
279
- lg,
280
- md,
281
- sm,
282
- xs
283
- };
284
- if (matrix[breakpoint]) {
285
- return /*#__PURE__*/ jsx(Fragment, {
286
- children: children
287
- });
288
- }
289
- return null;
290
- };
291
-
292
- const buttonTheme = {
293
- danger: {
294
- background: 'rgb(199,56,79)',
295
- colour: '#fff'
296
- },
297
- primary: {
298
- background: '#007fa8',
299
- colour: '#fff'
300
- },
301
- secondary: {
302
- background: '#f6f9fc',
303
- colour: '#333'
304
- },
305
- success: {
306
- background: 'rgb(0,128,93)',
307
- colour: '#fff'
308
- }
309
- };
310
- const BaseButton = styled('button').withConfig({
311
- shouldForwardProp: (prop)=>![
312
- 'block',
313
- 'colour',
314
- 'size'
315
- ].includes(prop)
316
- })`
317
- ${({ block = false, colour = 'primary', size = 'md', theme })=>`
318
- appearance: none;
319
- background-color: ${theme[colour].background};
320
- border: 0;
321
- color: ${theme[colour].colour};
322
- cursor: pointer;
323
- font-family: 'Cabin', sans-serif;
324
- font-weight: 600;
325
- position: relative;
326
- vertical-align: middle;
327
- text-align: center;
328
- text-decoration: none;
329
- user-select: none;
330
- white-space: nowrap;
331
-
332
- ${block ? `
333
- display: block;
334
- width: 100%;
335
- ` : `
336
- display: inline-block;
337
- `}
338
-
339
- ${(()=>{
340
- switch(size){
341
- case 'sm':
342
- return `
343
- font-size: 16px;
344
- height: 32px;
345
- line-height: 32px;
346
- padding: ${block ? '0' : '0 16px'};
347
- `;
348
- case 'lg':
349
- return `
350
- font-size: 18px;
351
- height: 46px;
352
- line-height: 46px;
353
- padding: ${block ? '0' : '0 32px'};
354
- `;
355
- default:
356
- return `
357
- font-size: 16px;
358
- height: 40px;
359
- line-height: 40px;
360
- padding: ${block ? '0' : '0 24px'};
361
- `;
362
- }
363
- })()}
364
-
365
- :hover {
366
- background-color: ${darken(0.1, theme[colour].background ?? '')};
367
- }
368
-
369
- :disabled {
370
- background-color: ${theme[colour].background};
371
- opacity: .6;
372
- }
373
- `}
374
- `;
375
-
376
- const Circle = styled.circle`
377
- ${({ $colour })=>`
378
- animation: dash 1.5s ease-in-out infinite;
379
- stroke: ${$colour === 'default' ? '#007fa8' : '#fff'};
380
- stroke-linecap: round;
381
-
382
- @keyframes dash {
383
- 0% {
384
- stroke-dasharray: 1, 150;
385
- stroke-dashoffset: 0;
386
- }
387
- 50% {
388
- stroke-dasharray: 90, 150;
389
- stroke-dashoffset: -35;
390
- }
391
- 100% {
392
- stroke-dasharray: 90, 150;
393
- stroke-dashoffset: -124;
394
- }
395
- }
396
- `}
397
- `;
398
- const BaseLoader = styled.svg`
399
- animation: rotate 2s linear infinite;
400
- height: 50px;
401
- left: 50%;
402
- margin: -25px 0 0 -25px;
403
- position: absolute;
404
- top: 50%;
405
- width: 50px;
406
-
407
- @keyframes rotate {
408
- 100% {
409
- transform: rotate(360deg);
410
- }
411
- }
412
- `;
413
- const Loader = ({ colour = 'default', className = '' })=>/*#__PURE__*/ jsx(BaseLoader, {
414
- className: className,
415
- viewBox: "0 0 50 50",
416
- children: /*#__PURE__*/ jsx(Circle, {
417
- $colour: colour,
418
- cx: "25",
419
- cy: "25",
420
- r: "20",
421
- fill: "none",
422
- strokeWidth: "4"
423
- })
424
- });
425
-
426
- const loaderSizes = {
427
- lg: {
428
- height: '36px',
429
- margin: '-18px 0 0 -18px',
430
- width: '36px'
431
- },
432
- md: {
433
- height: '28px',
434
- margin: '-14px 0 0 -14px',
435
- width: '28px'
436
- },
437
- sm: {
438
- height: '20px',
439
- margin: '-10px 0 0 -10px',
440
- width: '20px'
441
- }
442
- };
443
- const ButtonLoader = styled(Loader)`
444
- ${({ $size })=>`
445
- height: ${loaderSizes[$size].height};
446
- margin: ${loaderSizes[$size].margin};
447
- width: ${loaderSizes[$size].width};
448
- `}
449
- `;
450
- const ButtonContainer = styled.span`
451
- ${({ $isLoading })=>`
452
- visibility: ${$isLoading ? 'hidden' : 'visible'};
453
- `}
454
- `;
455
- const Button = ({ block = false, children, colour = 'primary', disabled = false, loading = false, size = 'md', type = 'button', ...rest })=>{
456
- const loadingColour = colour === 'secondary' ? 'default' : 'secondary';
457
- return /*#__PURE__*/ jsx(ThemeProvider, {
458
- theme: buttonTheme,
459
- children: /*#__PURE__*/ jsxs(BaseButton, {
460
- block: block,
461
- colour: colour,
462
- type: type,
463
- size: size,
464
- disabled: disabled || loading,
465
- ...rest,
466
- children: [
467
- loading && /*#__PURE__*/ jsx(ButtonLoader, {
468
- colour: loadingColour,
469
- $size: size
470
- }),
471
- /*#__PURE__*/ jsx(ButtonContainer, {
472
- $isLoading: loading,
473
- children: children
474
- })
475
- ]
476
- })
477
- });
478
- };
479
-
480
- const BaseLink = styled.a`
481
- appearance: none;
482
- background: none;
483
- border: 0;
484
- color: #007aa3;
485
- cursor: pointer;
486
- font-weight: 600;
487
- font-size: inherit;
488
- margin: 0;
489
- padding: 0;
490
- text-decoration: underline;
491
-
492
- :hover {
493
- color: rgb(199, 56, 79);
494
- text-decoration: none;
495
- }
496
- `;
497
-
498
- const ButtonLink = (props)=>// eslint-disable-next-line react/jsx-props-no-spreading
499
- /*#__PURE__*/ jsx(BaseLink, {
500
- as: "button",
501
- ...props
502
- });
503
-
504
- const Wrapper$4 = styled.div`
505
- border-bottom: 2px solid #007fa8;
506
- display: block;
507
- overflow-x: auto;
508
- width: 100%;
509
- -webkit-overflow-scrolling: touch;
510
- -ms-overflow-style: -ms-autohiding-scrollbar;
511
- `;
512
- const BaseTable = styled.table`
513
- ${({ $fixed })=>`
514
- background-color: #fff;
515
- max-width: 100%;
516
- table-layout: ${$fixed ? 'fixed' : 'auto'};
517
- width: 100%;
518
- `}
519
- `;
520
- const Table = ({ children, fixed = false, ...rest })=>/*#__PURE__*/ jsx(Wrapper$4, {
521
- children: /*#__PURE__*/ jsx(BaseTable, {
522
- $fixed: fixed,
523
- ...rest,
524
- children: children
525
- })
526
- });
527
-
528
- const TableBody = styled.tbody`
529
- background-color: #fff;
530
- color: #000;
531
- `;
532
-
533
- const baseStyles = (noWrap, align = 'inherit')=>`
534
- padding: 10px;
535
- text-align: ${align};
536
- vertical-align: middle;
537
- ${noWrap ? 'white-space: nowrap;' : ''}
538
- `;
539
- const TableDataCell = styled.td`
540
- ${({ align, $noWrap })=>`
541
- ${baseStyles($noWrap, align)}
542
- font-weight: 300;
543
- `}
544
- `;
545
- const TableHeadCell = styled.th`
546
- ${({ align, $noWrap })=>`
547
- ${baseStyles($noWrap, align)}
548
- font-family: 'Cabin', sans-serif;
549
- font-weight: 600;
550
- `}
551
- `;
552
- const TableCell = ({ as = 'td', noWrap = true, ...rest })=>as === 'td' ? /*#__PURE__*/ jsx(TableDataCell, {
553
- $noWrap: noWrap,
554
- ...rest
555
- }) : /*#__PURE__*/ jsx(TableHeadCell, {
556
- $noWrap: noWrap,
557
- ...rest
558
- });
559
-
560
- const TableHead = styled.thead`
561
- font-weight: 600;
562
- `;
563
-
564
- const tableRowTheme = {
565
- default: {
566
- background: '#fff',
567
- border: '#eee',
568
- colour: '#000'
569
- },
570
- primary: {
571
- background: '#007fa8',
572
- border: darken(0.02, '#007fa8'),
573
- colour: '#fff'
574
- },
575
- secondary: {
576
- background: '#f6f9fc',
577
- border: '#eee',
578
- colour: '#333'
579
- }
580
- };
581
- const BaseTableRow = styled.tr`
582
- ${({ $colour, theme })=>`
583
- background-color: ${theme[$colour].background};
584
- border-bottom: 2px solid ${theme[$colour].border};
585
- color: ${theme[$colour].colour};
586
- `}
587
- `;
588
- const TableRow = ({ colour = 'default', ...rest })=>/*#__PURE__*/ jsx(ThemeProvider, {
589
- theme: tableRowTheme,
590
- children: /*#__PURE__*/ jsx(BaseTableRow, {
591
- $colour: colour,
592
- ...rest
593
- })
594
- });
595
-
596
- const margins = {
597
- lg: 1,
598
- md: 0.5,
599
- none: 0,
600
- sm: 0.25
601
- };
602
- const BaseTypography = styled.p`
603
- ${({ $align, $breakWord, $margin, $truncate, $variant })=>`
604
- margin: ${margins[$margin] ? `0 0 ${margins[$margin]}rem` : '0'};
605
- text-align: ${$align};
606
-
607
- ${$breakWord ? `
608
- hyphens: auto;
609
- overflow-wrap: break-word;
610
- word-wrap: break-word;
611
- word-break: break-all;
612
- word-break: break-word;
613
- ` : ''}
614
-
615
- ${$truncate ? `
616
- overflow: hidden;
617
- text-overflow: ellipsis;
618
- white-space: nowrap;
619
- ` : ''}
620
-
621
- ${(()=>{
622
- switch($variant){
623
- case 'p':
624
- return `
625
- color: inherit;
626
- line-height: 1.5;
627
- `;
628
- case 'lead':
629
- return `
630
- font-size: 1.25rem;
631
- font-weight: 300;
632
- line-height: 1.5;
633
- `;
634
- default:
635
- return `
636
- color: inherit;
637
- font-family: 'Cabin', sans-serif;
638
- font-size: ${(()=>{
639
- switch($variant){
640
- case 'h6':
641
- return '1rem';
642
- case 'h5':
643
- return '1.25rem';
644
- case 'h4':
645
- return '1.5rem';
646
- case 'h3':
647
- return '1.75rem';
648
- case 'h2':
649
- return '2rem';
650
- default:
651
- return '2.5rem';
652
- }
653
- })()};
654
- font-weight: 600;
655
- line-height: 1.2;
656
- `;
657
- }
658
- })()}
659
- `}
660
- `;
661
- const Line = styled.hr`
662
- ${({ $margin })=>`
663
- border: 0;
664
- border-top: 2.5px solid #007fa8;
665
- margin: ${margins[$margin] ? `${margins[$margin]}rem 0` : '0'};
666
- padding: 0;
667
-
668
- `}
669
- `;
670
- const Typography = ({ align = 'left', breakWord = false, children, className = '', component, id, margin = 'md', rule = false, truncate = false, variant })=>/*#__PURE__*/ jsxs(Fragment, {
671
- children: [
672
- /*#__PURE__*/ jsx(BaseTypography, {
673
- id: id,
674
- as: component,
675
- className: className,
676
- $align: align,
677
- $breakWord: breakWord,
678
- $margin: margin,
679
- $truncate: truncate,
680
- $variant: variant,
681
- children: children
682
- }),
683
- rule && /*#__PURE__*/ jsx(Line, {
684
- $margin: margin
685
- })
686
- ]
687
- });
688
-
689
- const Toolbar = styled.div`
690
- align-items: stretch;
691
- background-color: #007fa8;
692
- color: #fff;
693
- display: flex;
694
- flex-direction: row;
695
- `;
696
- const Title = styled(Typography)`
697
- flex-grow: 1;
698
- line-height: 40px;
699
- `;
700
- const CalendarButton = styled(Button)`
701
- ${({ $fixed = false })=>`
702
- ${$fixed ? 'width' : 'min-width'}: 40px;
703
- padding: 0;
704
- `}
705
- `;
706
- const Weekdays = ()=>{
707
- const short = Info.weekdays('short');
708
- const abbrs = Info.weekdays();
709
- return /*#__PURE__*/ jsx(TableHead, {
710
- children: /*#__PURE__*/ jsx(TableRow, {
711
- colour: "primary",
712
- children: short.map((day, i)=>/*#__PURE__*/ jsx(TableCell, {
713
- abbr: abbrs[i],
714
- as: "th",
715
- align: "center",
716
- scope: "col",
717
- children: day
718
- }, day))
719
- })
720
- });
721
- };
722
- const Dates = ({ date, id, onSelect, view })=>{
723
- const currentDay = parseInt(date.toFormat('dd'), 10);
724
- const { daysInMonth } = view;
725
- const firstDayOfMonth = parseInt(view.startOf('month').toFormat('c'), 10);
726
- const previousMonth = view.minus({
727
- months: 1
728
- });
729
- const lastDayOfPreviousMonth = parseInt(previousMonth.endOf('month').toFormat('dd'), 10);
730
- const nextMonth = view.plus({
731
- months: 1
732
- });
733
- const blanks = [
734
- ...Array(firstDayOfMonth - 1)
735
- ].map((_, i)=>{
736
- const day = lastDayOfPreviousMonth - i;
737
- const thisMonth = date.hasSame(previousMonth, 'month');
738
- let colour;
739
- if (thisMonth) {
740
- colour = day === currentDay ? 'primary' : 'secondary';
741
- } else {
742
- colour = 'secondary';
743
- }
744
- return /*#__PURE__*/ jsx(TableCell, {
745
- align: "center",
746
- children: /*#__PURE__*/ jsx(CalendarButton, {
747
- block: true,
748
- disabled: true,
749
- colour: colour,
750
- children: day
751
- })
752
- }, 0 - i);
753
- }).reverse();
754
- const days = [
755
- ...Array(daysInMonth)
756
- ].map((_, i)=>{
757
- const day = i + 1;
758
- const month = view.get('month');
759
- const year = view.get('year');
760
- const thisMonth = date.hasSame(view, 'month');
761
- let colour;
762
- if (thisMonth) {
763
- colour = day === currentDay ? 'primary' : 'secondary';
764
- } else {
765
- colour = 'secondary';
766
- }
767
- return /*#__PURE__*/ jsx(TableCell, {
768
- align: "center",
769
- children: /*#__PURE__*/ jsx(CalendarButton, {
770
- block: true,
771
- colour: colour,
772
- "data-testid": `calendar-day-${day}`,
773
- tabIndex: -1,
774
- onClick: ()=>onSelect(day, month, year),
775
- children: day
776
- })
777
- }, day);
778
- });
779
- const totalSlots = [
780
- ...blanks,
781
- ...days
782
- ];
783
- const rows = [];
784
- let cells = [];
785
- totalSlots.forEach((row, i)=>{
786
- if (i % 7 !== 0) {
787
- cells.push(row);
788
- } else {
789
- rows.push(cells);
790
- cells = [];
791
- cells.push(row);
792
- }
793
- if (i === totalSlots.length - 1) {
794
- const filler = [
795
- ...Array(7 - cells.length)
796
- ].map((_, fillerIndex)=>{
797
- const key = daysInMonth + fillerIndex + 1;
798
- const day = 1 + fillerIndex;
799
- const thisMonth = date.hasSame(nextMonth, 'month');
800
- let colour;
801
- if (thisMonth) {
802
- colour = day === currentDay ? 'primary' : 'secondary';
803
- } else {
804
- colour = 'secondary';
805
- }
806
- return /*#__PURE__*/ jsx(TableCell, {
807
- align: "center",
808
- children: /*#__PURE__*/ jsx(CalendarButton, {
809
- block: true,
810
- disabled: true,
811
- colour: colour,
812
- children: day
813
- })
814
- }, key);
815
- });
816
- rows.push([
817
- ...cells,
818
- ...filler
819
- ]);
820
- }
821
- });
822
- return /*#__PURE__*/ jsxs(Table, {
823
- id: id,
824
- role: "grid",
825
- children: [
826
- /*#__PURE__*/ jsx(Weekdays, {}),
827
- /*#__PURE__*/ jsx(TableBody, {
828
- children: rows.map((d, i)=>/*#__PURE__*/ jsx(TableRow, {
829
- children: d
830
- }, i))
831
- })
832
- ]
833
- });
834
- };
835
- const selectMoment = (start, date)=>date || start;
836
- const Calendar = ({ onDateChange, id, selectedDate = '' })=>{
837
- const [startDate] = useState(()=>{
838
- if (selectedDate !== '') {
839
- return DateTime$1.fromISO(selectedDate).toUTC();
840
- }
841
- return DateTime$1.utc();
842
- });
843
- const [date, setDate] = useState();
844
- const [view, setView] = useState();
845
- const [currentMonth, setCurrentMonth] = useState('');
846
- const [currentYear, setCurrentYear] = useState('');
847
- const selected = selectMoment(startDate, date);
848
- const selectedView = selectMoment(startDate, view);
849
- const grid = `${id}-calendar`;
850
- const label = `${id}-dialog-label`;
851
- const setDay = (day, month, year)=>{
852
- const updated = selected.set({
853
- day,
854
- month,
855
- year
856
- });
857
- setDate(updated);
858
- };
859
- const next = (unit)=>{
860
- const updated = selectedView.plus({
861
- [unit]: 1
862
- });
863
- setView(updated);
864
- };
865
- const previous = (unit)=>{
866
- const updated = selectedView.minus({
867
- [unit]: 1
868
- });
869
- setView(updated);
870
- };
871
- useEffect(()=>{
872
- setCurrentMonth(selectedView.toFormat('MMMM'));
873
- setCurrentYear(selectedView.toFormat('y'));
874
- }, [
875
- selectedView
876
- ]);
877
- useEffect(()=>{
878
- const isoDate = date?.toISO();
879
- if (isoDate) {
880
- onDateChange(isoDate);
881
- }
882
- // eslint-disable-next-line react-hooks/exhaustive-deps
883
- }, [
884
- date
885
- ]);
886
- return /*#__PURE__*/ jsxs(Fragment, {
887
- children: [
888
- /*#__PURE__*/ jsxs(Toolbar, {
889
- children: [
890
- /*#__PURE__*/ jsx(CalendarButton, {
891
- $fixed: true,
892
- block: true,
893
- "aria-label": "Previous year",
894
- onClick: ()=>previous('year'),
895
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
896
- icon: faAngleDoubleLeft
897
- })
898
- }),
899
- /*#__PURE__*/ jsx(CalendarButton, {
900
- $fixed: true,
901
- block: true,
902
- "aria-label": "Previous month",
903
- onClick: ()=>previous('month'),
904
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
905
- icon: faAngleLeft
906
- })
907
- }),
908
- /*#__PURE__*/ jsxs(Title, {
909
- id: label,
910
- component: "p",
911
- variant: "h6",
912
- align: "center",
913
- margin: "none",
914
- children: [
915
- currentMonth,
916
- " ",
917
- currentYear
918
- ]
919
- }),
920
- /*#__PURE__*/ jsx(CalendarButton, {
921
- $fixed: true,
922
- block: true,
923
- "aria-label": "Next month",
924
- onClick: ()=>next('month'),
925
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
926
- icon: faAngleRight
927
- })
928
- }),
929
- /*#__PURE__*/ jsx(CalendarButton, {
930
- $fixed: true,
931
- block: true,
932
- "aria-label": "Next year",
933
- onClick: ()=>next('year'),
934
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
935
- icon: faAngleDoubleRight
936
- })
937
- })
938
- ]
939
- }),
940
- /*#__PURE__*/ jsx(Dates, {
941
- id: grid,
942
- date: selected,
943
- view: selectedView,
944
- onSelect: setDay
945
- })
946
- ]
947
- });
948
- };
949
-
950
- const cardTheme = {
951
- lg: {
952
- padding: '20px'
953
- },
954
- md: {
955
- padding: '10px'
956
- },
957
- none: {
958
- padding: '0'
959
- },
960
- sm: {
961
- padding: '5px'
962
- }
963
- };
964
- const BaseCard = styled.div`
965
- ${({ $padding, theme })=>`
966
- background: #f8f8f8;
967
- color: #000;
968
- padding: ${theme[$padding].padding}
969
- `}
970
- `;
971
- const Card = ({ children, padding = 'md' })=>/*#__PURE__*/ jsx(ThemeProvider, {
972
- theme: cardTheme,
973
- children: /*#__PURE__*/ jsx(BaseCard, {
974
- $padding: padding,
975
- children: children
976
- })
977
- });
978
-
979
- const CheckableInput = styled.input`
980
- cursor: pointer;
981
- height: 100%;
982
- left: 0;
983
- margin: 0;
984
- padding: 0;
985
- position: absolute;
986
- opacity: 0;
987
- top: 0;
988
- width: 100%;
989
- z-index: 1;
990
- `;
991
-
992
- const helpTextSpacing = {
993
- lg: '20px',
994
- md: '10px',
995
- sm: '5px'
996
- };
997
- const HelpText = styled('p').withConfig({
998
- shouldForwardProp: (prop)=>![
999
- 'error',
1000
- 'spacing'
1001
- ].includes(prop)
1002
- })`
1003
- ${({ error, spacing })=>`
1004
- color: ${error ? 'rgb(199,56,79)' : '#727272'};
1005
- font-size: 0.75rem;
1006
- margin-bottom: ${helpTextSpacing[spacing]};
1007
- `}
1008
- `;
1009
-
1010
- const Wrapper$3 = styled.div`
1011
- background-color: rgb(199, 56, 79);
1012
- border-radius: 50%;
1013
- color: #fff;
1014
- cursor: pointer;
1015
- display: block;
1016
- height: 22px;
1017
- line-height: 22px;
1018
- text-align: center;
1019
- width: 22px;
1020
- `;
1021
- const InputAlert = ()=>/*#__PURE__*/ jsx(Wrapper$3, {
1022
- role: "alert",
1023
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
1024
- icon: faExclamation
1025
- })
1026
- });
1027
-
1028
- const tooltipTheme = {
1029
- danger: {
1030
- background: 'rgb(199,56,79)',
1031
- colour: '#fff'
1032
- },
1033
- primary: {
1034
- background: '#007fa8',
1035
- colour: '#fff'
1036
- },
1037
- secondary: {
1038
- background: '#f6f9fc',
1039
- colour: '#333'
1040
- },
1041
- success: {
1042
- background: 'rgb(0,128,93)',
1043
- colour: '#fff'
1044
- }
1045
- };
1046
- const TooltipArrow = styled.div`
1047
- ${({ $colour, $placement, theme })=>`
1048
- height: 0;
1049
- position: absolute;
1050
- width: 0;
1051
-
1052
- ${(()=>{
1053
- switch($placement){
1054
- case 'bottom':
1055
- return `
1056
- border-bottom: 5px solid ${theme[$colour].background};
1057
- border-left: 5px solid transparent;
1058
- border-right: 5px solid transparent;
1059
- top: -5px;
1060
- `;
1061
- case 'left':
1062
- return `
1063
- border-bottom: 5px solid transparent;
1064
- border-left: 5px solid ${theme[$colour].background};
1065
- border-top: 5px solid transparent;
1066
- right: -5px;
1067
- `;
1068
- case 'right':
1069
- return `
1070
- border-bottom: 5px solid transparent;
1071
- border-right: 5px solid ${theme[$colour].background};
1072
- border-top: 5px solid transparent;
1073
- left: -5px;
1074
- `;
1075
- case 'top':
1076
- return `
1077
- border-left: 5px solid transparent;
1078
- border-right: 5px solid transparent;
1079
- border-top: 5px solid ${theme[$colour].background};
1080
- bottom: -5px;
1081
- `;
1082
- default:
1083
- return '';
1084
- }
1085
- })()}
1086
- `}
1087
- `;
1088
- const TooltipWrapper = styled.div`
1089
- display: inline-block;
1090
- position: relative;
1091
- `;
1092
- const TooltipContent = styled.div`
1093
- ${({ $colour, $visible, theme })=>`
1094
- background-color: ${theme[$colour].background};
1095
- color: ${theme[$colour].colour};
1096
- font-size: 14px;
1097
- line-height: 22px;
1098
- padding: 0 5px;
1099
- visibility: ${$visible ? 'visible' : 'hidden'};
1100
- z-index: 10;
1101
- `}
1102
- `;
1103
- const Tooltip = ({ colour = 'primary', message, id, parent, placement })=>{
1104
- let timer;
1105
- const [visible, setVisibility] = useState(false);
1106
- const mounted = useRef(false);
1107
- const hideTooltip = ()=>{
1108
- timer = setTimeout(()=>{
1109
- if (mounted.current) {
1110
- setVisibility(false);
1111
- }
1112
- }, 1000);
1113
- };
1114
- const showTooltip = ()=>{
1115
- clearTimeout(timer);
1116
- setVisibility(true);
1117
- };
1118
- useEffect(()=>{
1119
- mounted.current = true;
1120
- return ()=>{
1121
- mounted.current = false;
1122
- };
1123
- });
1124
- return /*#__PURE__*/ jsx(ThemeProvider, {
1125
- theme: tooltipTheme,
1126
- children: /*#__PURE__*/ jsxs(Manager, {
1127
- children: [
1128
- /*#__PURE__*/ jsx(Reference, {
1129
- children: ({ ref })=>/*#__PURE__*/ jsx(TooltipWrapper, {
1130
- ref: ref,
1131
- onBlur: hideTooltip,
1132
- onFocus: showTooltip,
1133
- onMouseOver: showTooltip,
1134
- onMouseOut: hideTooltip,
1135
- children: parent
1136
- })
1137
- }),
1138
- /*#__PURE__*/ jsx(Popper, {
1139
- placement: placement,
1140
- strategy: "fixed",
1141
- modifiers: [
1142
- {
1143
- name: 'offset',
1144
- options: {
1145
- offset: [
1146
- 0,
1147
- 5
1148
- ]
1149
- }
1150
- }
1151
- ],
1152
- children: ({ arrowProps, placement: popperPlacement, ref, style })=>{
1153
- const placementToUse = process.env.NODE_ENV === 'test' ? placement : popperPlacement;
1154
- return /*#__PURE__*/ jsxs(TooltipContent, {
1155
- $placement: placementToUse,
1156
- $visible: visible,
1157
- id: id,
1158
- role: "tooltip",
1159
- ref: ref,
1160
- $colour: colour,
1161
- style: style,
1162
- children: [
1163
- message,
1164
- /*#__PURE__*/ jsx(TooltipArrow, {
1165
- $placement: placementToUse,
1166
- ref: arrowProps.ref,
1167
- $colour: colour,
1168
- style: arrowProps.style
1169
- })
1170
- ]
1171
- });
1172
- }
1173
- })
1174
- ]
1175
- })
1176
- });
1177
- };
1178
-
1179
- const ValidatorWrapper = styled.div`
1180
- margin-top: -11px;
1181
- position: absolute;
1182
- right: 8px;
1183
- top: 50%;
1184
- z-index: 1;
1185
- `;
1186
-
1187
- const BaseFieldSet = styled.fieldset`
1188
- padding-right: 38px;
1189
- position: relative;
1190
- `;
1191
- const FieldSet = ({ error, children, helpText = null, message, name, spacing })=>{
1192
- const describedBy = `${name}-error`;
1193
- return /*#__PURE__*/ jsxs(Fragment, {
1194
- children: [
1195
- /*#__PURE__*/ jsxs(BaseFieldSet, {
1196
- children: [
1197
- children,
1198
- /*#__PURE__*/ jsx(ValidatorWrapper, {
1199
- children: error && /*#__PURE__*/ jsx(Tooltip, {
1200
- id: describedBy,
1201
- parent: /*#__PURE__*/ jsx(InputAlert, {
1202
- message: message
1203
- }),
1204
- colour: "danger",
1205
- placement: "left",
1206
- message: message
1207
- })
1208
- })
1209
- ]
1210
- }),
1211
- helpText && /*#__PURE__*/ jsx(HelpText, {
1212
- error: error,
1213
- spacing: spacing,
1214
- children: helpText
1215
- })
1216
- ]
1217
- });
1218
- };
1219
-
1220
- const useInputValidation = (name, errors, touched)=>{
1221
- const [error, setError] = useState(false);
1222
- useEffect(()=>{
1223
- const touch = getIn(touched, name);
1224
- const err = getIn(errors, name);
1225
- setError(!!touch && !!err);
1226
- }, [
1227
- errors,
1228
- name,
1229
- touched
1230
- ]);
1231
- return error;
1232
- };
1233
-
1234
- const Legend = styled('legend').withConfig({
1235
- shouldForwardProp: (prop)=>![
1236
- 'error'
1237
- ].includes(prop)
1238
- })`
1239
- ${({ error })=>`
1240
- color: ${error ? 'rgb(199,56,79)' : '#007aa3'};
1241
- font-size: 16px;
1242
- margin-bottom: 10px;
1243
- `}
1244
- `;
1245
-
1246
- const BaseOptionLabel = styled.label`
1247
- ${({ $disabled, $selected })=>`
1248
- cursor: pointer;
1249
- display: inline-flex;
1250
- margin: 0 10px 10px 0;
1251
- padding: 0 8px;
1252
- position: relative;
1253
-
1254
- ${$disabled ? `
1255
- background: #fff;
1256
- border-bottom: 2px solid #eee;
1257
- color: #767676;
1258
- ` : `
1259
- background: ${$selected ? '#007fa8' : '#fff'};
1260
- border-bottom: 2px solid ${$selected ? darken(0.02, '#007fa8') : '#eee'};
1261
- color: ${$selected ? '#fff' : '#000'};
1262
- `}
1263
- `}
1264
- `;
1265
- const OptionLabel = ({ children, disabled, selected })=>/*#__PURE__*/ jsx(BaseOptionLabel, {
1266
- $disabled: disabled,
1267
- $selected: selected,
1268
- children: children
1269
- });
1270
-
1271
- const OptionLabelText = styled.div`
1272
- line-height: 44px;
1273
- `;
1274
-
1275
- const InternalCheckBox = ({ disabled, field, form, helpText, label, legend, onChange, readOnly, spacing })=>{
1276
- const { errors, handleChange, touched } = form;
1277
- const error = useInputValidation(field.name, errors, touched);
1278
- const markAsDisabled = disabled || readOnly;
1279
- const doChange = (e)=>{
1280
- handleChange(e);
1281
- if (onChange) {
1282
- onChange(e, form);
1283
- }
1284
- };
1285
- return /*#__PURE__*/ jsxs(FieldSet, {
1286
- error: error,
1287
- helpText: helpText,
1288
- message: getIn(errors, field.name),
1289
- name: field.name,
1290
- spacing: spacing,
1291
- children: [
1292
- /*#__PURE__*/ jsx(Legend, {
1293
- error: error,
1294
- children: legend
1295
- }),
1296
- /*#__PURE__*/ jsxs(OptionLabel, {
1297
- disabled: disabled,
1298
- selected: field.value,
1299
- children: [
1300
- /*#__PURE__*/ jsx(CheckableInput, {
1301
- ...field,
1302
- checked: field.value,
1303
- disabled: markAsDisabled,
1304
- readOnly: readOnly,
1305
- type: "checkbox",
1306
- onChange: doChange
1307
- }),
1308
- /*#__PURE__*/ jsx(OptionLabelText, {
1309
- children: label
1310
- })
1311
- ]
1312
- }),
1313
- readOnly && /*#__PURE__*/ jsx("input", {
1314
- type: "hidden",
1315
- ...field
1316
- })
1317
- ]
1318
- });
1319
- };
1320
- const CheckBox = ({ disabled = false, helpText = null, label, legend, name, onChange, readOnly = false, spacing = 'md' })=>/*#__PURE__*/ jsx(Field, {
1321
- id: name,
1322
- component: InternalCheckBox,
1323
- disabled: disabled,
1324
- helpText: helpText,
1325
- label: label,
1326
- legend: legend,
1327
- name: name,
1328
- onChange: onChange,
1329
- readOnly: readOnly,
1330
- spacing: spacing
1331
- });
1332
-
1333
- const ColContainer = styled.div`
1334
- ${({ $align, $lg, $lgOffset, $md, $mdOffset, $sm, $smOffset, $verticalAlign, $xs, $xsOffset })=>`
1335
- grid-column: ${$xsOffset > 0 ? `${$xsOffset} / span ${$xs}` : `span ${$xs}`};
1336
- position: relative;
1337
- text-align ${$align === 'centre' ? 'center' : $align};
1338
-
1339
- ${$verticalAlign ? `
1340
- align-items: center;
1341
- display: flex;
1342
- ` : ``}
1343
-
1344
- ${$sm ? `
1345
- @media (min-width: 576px) {
1346
- grid-column: ${$smOffset > 0 ? `${$smOffset} / span ${$sm}` : `span ${$sm}`};
1347
- }
1348
- ` : ''}
1349
-
1350
- ${$md ? `
1351
- @media (min-width: 768px) {
1352
- grid-column: ${$mdOffset > 0 ? `${$mdOffset} / span ${$md}` : `span ${$md}`};
1353
- }
1354
- ` : ''}
1355
-
1356
- ${$lg ? `
1357
- @media (min-width: 992px) {
1358
- grid-column: ${$lgOffset > 0 ? `${$lgOffset} / span ${$lg}` : `span ${$lg}`};
1359
- }
1360
- ` : ''}
1361
- `}
1362
- `;
1363
- const VericalAlignWrapper = styled.div`
1364
- flex: 1;
1365
- `;
1366
- const Col = ({ children, align = 'left', lg = 0, lgOffset = 0, md = 0, mdOffset = 0, sm = 0, smOffset = 0, verticalAlign = null, xs = 12, xsOffset = 0 })=>/*#__PURE__*/ jsx(ColContainer, {
1367
- $align: align,
1368
- $lg: lg,
1369
- $lgOffset: lgOffset,
1370
- $md: md,
1371
- $mdOffset: mdOffset,
1372
- $sm: sm,
1373
- $smOffset: smOffset,
1374
- $verticalAlign: !!verticalAlign,
1375
- $xs: xs,
1376
- $xsOffset: xsOffset,
1377
- children: verticalAlign ? /*#__PURE__*/ jsx(VericalAlignWrapper, {
1378
- children: children
1379
- }) : children
1380
- });
1381
-
1382
- const Wrapper$2 = styled.section`
1383
- background-color: #f8f8f8;
1384
- color: #000;
1385
- display: block;
1386
- padding: 1rem;
1387
- `;
1388
- const Content = ({ children })=>/*#__PURE__*/ jsx(Wrapper$2, {
1389
- children: children
1390
- });
1391
-
1392
- function DataTable({ header = null, items, noResults, row, theme = 'primary' }) {
1393
- if (items.length === 0) {
1394
- return /*#__PURE__*/ jsx(Fragment, {
1395
- children: noResults
1396
- });
1397
- }
1398
- return /*#__PURE__*/ jsxs(Table, {
1399
- children: [
1400
- header && /*#__PURE__*/ jsx(TableHead, {
1401
- children: /*#__PURE__*/ jsx(TableRow, {
1402
- colour: theme,
1403
- children: header
1404
- })
1405
- }),
1406
- /*#__PURE__*/ jsx(TableBody, {
1407
- children: items.map((item, i)=>// eslint-disable-next-line react/no-array-index-key
1408
- /*#__PURE__*/ jsx(TableRow, {
1409
- children: row(item)
1410
- }, i))
1411
- })
1412
- ]
1413
- });
1414
- }
1415
-
1416
- const defaultFormat = 'dd/MM/yyyy';
1417
- const formatDateTime = (value, format = defaultFormat)=>{
1418
- const date = typeof value === 'string' ? DateTime$1.fromISO(value) : DateTime$1.fromSeconds(value);
1419
- return {
1420
- ISOString: date.toUTC().toISO(),
1421
- formatted: date.toFormat(format)
1422
- };
1423
- };
1424
- const DateTime = ({ format = defaultFormat, value })=>{
1425
- const { ISOString, formatted } = formatDateTime(value, format);
1426
- return /*#__PURE__*/ jsx("time", {
1427
- dateTime: ISOString,
1428
- children: formatted
1429
- });
1430
- };
1431
-
1432
- const useOutsideClick = (ref, handler)=>{
1433
- useEffect(()=>{
1434
- const listener = (event)=>{
1435
- if (!ref || ref.contains(event.target)) {
1436
- return;
1437
- }
1438
- handler(event);
1439
- };
1440
- document.addEventListener('mousedown', listener);
1441
- document.addEventListener('touchstart', listener);
1442
- return ()=>{
1443
- document.removeEventListener('mousedown', listener);
1444
- document.removeEventListener('touchstart', listener);
1445
- };
1446
- }, [
1447
- handler,
1448
- ref
1449
- ]);
1450
- };
1451
-
1452
- const inputWrapperTheme = {
1453
- lg: {
1454
- spacing: '20px'
1455
- },
1456
- md: {
1457
- spacing: '10px'
1458
- },
1459
- sm: {
1460
- spacing: '5px'
1461
- }
1462
- };
1463
- const BaseInputWrapper = styled.div`
1464
- ${({ theme, $error, $spacing })=>`
1465
- background: #fff;
1466
- border-bottom: 2px solid ${$error ? 'rgb(199,56,79)' : '#eee'};
1467
- margin-bottom: ${theme[$spacing].spacing};
1468
- padding: 0 38px 0 8px;
1469
- position: relative;
1470
- `}
1471
- `;
1472
- const InputWrapper = ({ children, error, helpText = null, message, name, spacing })=>{
1473
- const describedBy = `${name}-error`;
1474
- return /*#__PURE__*/ jsxs(ThemeProvider, {
1475
- theme: inputWrapperTheme,
1476
- children: [
1477
- /*#__PURE__*/ jsxs(BaseInputWrapper, {
1478
- $error: error,
1479
- $spacing: helpText ? 'md' : spacing,
1480
- children: [
1481
- children,
1482
- /*#__PURE__*/ jsx(ValidatorWrapper, {
1483
- children: error && /*#__PURE__*/ jsx(Tooltip, {
1484
- id: describedBy,
1485
- parent: /*#__PURE__*/ jsx(InputAlert, {
1486
- message: message
1487
- }),
1488
- colour: "danger",
1489
- placement: "left",
1490
- message: message
1491
- })
1492
- })
1493
- ]
1494
- }),
1495
- helpText && /*#__PURE__*/ jsx(HelpText, {
1496
- error: error,
1497
- spacing: spacing,
1498
- children: helpText
1499
- })
1500
- ]
1501
- });
1502
- };
1503
-
1504
- const Label = styled('label').withConfig({
1505
- shouldForwardProp: (prop)=>![
1506
- 'active',
1507
- 'error'
1508
- ].includes(prop)
1509
- })`
1510
- ${({ active, error })=>`
1511
- color: ${(()=>{
1512
- if (error) {
1513
- return 'rgb(199,56,79)';
1514
- }
1515
- if (active) {
1516
- return '#007fa8';
1517
- }
1518
- return '#767676';
1519
- })()};
1520
- font-size: 16px;
1521
- pointer-events: none;
1522
- position: absolute;
1523
- transform: ${active ? 'translate(0,4px) scale(.75)' : 'translate(0,16px) scale(1)'};
1524
- transform-origin: top left;
1525
- transition: all .1s ease-in-out;
1526
- `}
1527
- `;
1528
-
1529
- const LikeInput = styled.div`
1530
- ${({ $disabled })=>`
1531
- background: #fff;
1532
- border: none;
1533
- color: ${$disabled ? '#767676' : '#333'};
1534
- font-size: 16px;
1535
- line-height: 18px;
1536
- outline: 0;
1537
- padding: 16px 0 10px;
1538
- width: 100%;
1539
- `}
1540
- `;
1541
-
1542
- const IconOuter$1 = styled.div`
1543
- margin-top: -21px;
1544
- position: absolute;
1545
- right: 38px;
1546
- top: 50%;
1547
- z-index: 1;
1548
- `;
1549
- const IconButton = styled.button`
1550
- appearance: none;
1551
- background-color: #fff;
1552
- border: 0;
1553
- color: #767676;
1554
- cursor: pointer;
1555
- display: block;
1556
- height: 42px;
1557
- line-height: 42px;
1558
- padding: 0;
1559
- text-align: center;
1560
- width: 42px;
1561
- `;
1562
- const DatePickerWrapper = styled.div`
1563
- position: relative;
1564
- `;
1565
- const CalendarWrapper = styled.div`
1566
- z-index: 1000;
1567
- `;
1568
- const InnerDatePicker = ({ disabled, field, form, helpText, label, readOnly, spacing })=>{
1569
- const [referenceElement, setReferenceElement] = useState(null);
1570
- const [popperElement, setPopperElement] = useState(null);
1571
- const { attributes, styles } = usePopper(referenceElement, popperElement, {
1572
- placement: 'bottom-end'
1573
- });
1574
- const [error, setError] = useState(false);
1575
- const [visible, setVisible] = useState(false);
1576
- const { name, value } = field;
1577
- const [date, setDate] = useState(()=>{
1578
- if (value === '') {
1579
- return DateTime$1.utc().toISO();
1580
- }
1581
- return DateTime$1.fromISO(value).toUTC().toISO();
1582
- });
1583
- const { errors, setFieldValue } = form;
1584
- const markAsDisabled = disabled || readOnly;
1585
- const describedBy = `${name}-error`;
1586
- const { formatted } = formatDateTime(value);
1587
- const selectDate = (d)=>{
1588
- setDate(d);
1589
- };
1590
- useEffect(()=>{
1591
- setFieldValue(name, date).catch(()=>{});
1592
- setVisible(false);
1593
- const err = getIn(errors, name);
1594
- setError(!!err);
1595
- }, [
1596
- date,
1597
- errors,
1598
- name,
1599
- setFieldValue
1600
- ]);
1601
- useOutsideClick(referenceElement, ()=>{
1602
- setVisible(false);
1603
- });
1604
- return /*#__PURE__*/ jsxs(DatePickerWrapper, {
1605
- ref: setReferenceElement,
1606
- children: [
1607
- /*#__PURE__*/ jsxs(InputWrapper, {
1608
- error: error,
1609
- helpText: helpText,
1610
- message: getIn(errors, name),
1611
- name: name,
1612
- spacing: spacing,
1613
- children: [
1614
- /*#__PURE__*/ jsx(Label, {
1615
- active: true,
1616
- htmlFor: name,
1617
- error: error,
1618
- children: label
1619
- }),
1620
- /*#__PURE__*/ jsx("input", {
1621
- hidden: true,
1622
- id: name,
1623
- disabled: disabled,
1624
- readOnly: readOnly,
1625
- ...field
1626
- }),
1627
- /*#__PURE__*/ jsx(LikeInput, {
1628
- "aria-describedby": error ? describedBy : undefined,
1629
- $disabled: disabled,
1630
- children: /*#__PURE__*/ jsx(DateTime, {
1631
- value: value
1632
- })
1633
- }),
1634
- /*#__PURE__*/ jsx(IconOuter$1, {
1635
- children: /*#__PURE__*/ jsx(IconButton, {
1636
- "data-testid": "date-picker",
1637
- disabled: markAsDisabled,
1638
- type: "button",
1639
- "aria-label": `Choose ${label}, selected date is ${formatted}`,
1640
- onClick: ()=>setVisible(!visible),
1641
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
1642
- icon: faCalendar
1643
- })
1644
- })
1645
- })
1646
- ]
1647
- }),
1648
- visible && /*#__PURE__*/ jsx(CalendarWrapper, {
1649
- ref: setPopperElement,
1650
- style: styles.popper,
1651
- ...attributes.popper,
1652
- children: /*#__PURE__*/ jsx(Calendar, {
1653
- id: name,
1654
- selectedDate: value,
1655
- onDateChange: selectDate
1656
- })
1657
- })
1658
- ]
1659
- });
1660
- };
1661
- const DatePicker = ({ disabled = false, helpText = null, label, name, readOnly = false, spacing = 'md' })=>/*#__PURE__*/ jsx(Field, {
1662
- component: InnerDatePicker,
1663
- disabled: disabled,
1664
- helpText: helpText,
1665
- id: name,
1666
- label: label,
1667
- name: name,
1668
- readOnly: readOnly,
1669
- spacing: spacing
1670
- });
1671
-
1672
- const UploadInput = styled.input`
1673
- ${({ $active })=>`
1674
- cursor: ${$active ? 'text' : 'pointer'};
1675
- height: 44px;
1676
- left: 0;
1677
- opacity: 0;
1678
- position: absolute;
1679
- top: 0;
1680
- width: 100%;
1681
- `}
1682
- `;
1683
- const InnerFileUpload = styled.div`
1684
- display: flex;
1685
- `;
1686
- const UploadButton = styled(Button)`
1687
- height: 44px;
1688
- `;
1689
- const InputContainer = styled.div`
1690
- flex-grow: 1;
1691
- position: relative;
1692
- `;
1693
- const InternalFileUpload = ({ accept, buttonText, disabled, field, form, helpText, label, loading, onSelect, spacing })=>{
1694
- const [active, setActive] = useState(false);
1695
- const { errors, touched } = form;
1696
- const { name } = field;
1697
- const [fileName, setFileName] = useState('');
1698
- const error = useInputValidation(name, errors, touched);
1699
- const onChange = (e)=>{
1700
- if (e.target.files && e.target.files.length > 0) {
1701
- const file = e.target.files[0];
1702
- setFileName(file.name);
1703
- Promise.resolve(onSelect(file, form)).then(async ()=>{
1704
- await form.setFieldTouched(name, true);
1705
- }).catch(()=>{});
1706
- }
1707
- };
1708
- const onClick = ()=>{
1709
- const input = document.getElementById(name);
1710
- input.click();
1711
- };
1712
- useEffect(()=>{
1713
- setActive(!!fileName);
1714
- }, [
1715
- fileName
1716
- ]);
1717
- return /*#__PURE__*/ jsx(InputWrapper, {
1718
- error: error,
1719
- helpText: helpText,
1720
- message: getIn(errors, name),
1721
- name: name,
1722
- spacing: spacing,
1723
- children: /*#__PURE__*/ jsxs(InnerFileUpload, {
1724
- children: [
1725
- /*#__PURE__*/ jsxs(InputContainer, {
1726
- children: [
1727
- /*#__PURE__*/ jsx(Label, {
1728
- htmlFor: name,
1729
- active: active,
1730
- error: error,
1731
- children: label
1732
- }),
1733
- /*#__PURE__*/ jsx(LikeInput, {
1734
- $disabled: disabled,
1735
- children: fileName
1736
- }),
1737
- /*#__PURE__*/ jsx(UploadInput, {
1738
- $active: active,
1739
- id: name,
1740
- disabled: disabled,
1741
- type: "file",
1742
- accept: accept,
1743
- onChange: onChange
1744
- }),
1745
- /*#__PURE__*/ jsx("input", {
1746
- ...field,
1747
- type: "hidden",
1748
- disabled: disabled
1749
- })
1750
- ]
1751
- }),
1752
- /*#__PURE__*/ jsx(UploadButton, {
1753
- colour: "secondary",
1754
- disabled: disabled,
1755
- loading: loading,
1756
- onClick: onClick,
1757
- children: buttonText
1758
- })
1759
- ]
1760
- })
1761
- });
1762
- };
1763
- const FileUpload = ({ accept, buttonText, disabled = false, helpText, label, loading = false, name, onSelect, spacing = 'md' })=>/*#__PURE__*/ jsx(Field, {
1764
- component: InternalFileUpload,
1765
- accept: accept,
1766
- buttonText: buttonText,
1767
- disabled: disabled,
1768
- helpText: helpText,
1769
- label: label,
1770
- loading: loading,
1771
- name: name,
1772
- onSelect: onSelect,
1773
- spacing: spacing
1774
- });
1775
-
1776
- const RowContainer = styled.div`
1777
- ${({ $columns, $gutter })=>`
1778
- display: grid;
1779
- gap: ${$gutter};
1780
- grid-template-columns: repeat(${$columns},1fr);
1781
- `}
1782
- `;
1783
- const Row = ({ children, columns = 12, gutter = '1rem' })=>/*#__PURE__*/ jsx(RowContainer, {
1784
- $columns: columns,
1785
- $gutter: gutter,
1786
- children: children
1787
- });
1788
-
1789
- const isObject = (value)=>typeof value === 'object' && !Array.isArray(value) && value !== null;
1790
- function encodeNullValues(values) {
1791
- const initialValues = {
1792
- ...values
1793
- };
1794
- return Object.keys(initialValues).reduce((aggregate, key)=>{
1795
- const value = initialValues[key];
1796
- if (value === null) {
1797
- return {
1798
- ...aggregate,
1799
- [key]: ''
1800
- };
1801
- }
1802
- if (isObject(value)) {
1803
- return {
1804
- ...aggregate,
1805
- [key]: encodeNullValues(value)
1806
- };
1807
- }
1808
- return {
1809
- ...aggregate,
1810
- [key]: value
1811
- };
1812
- }, {});
1813
- }
1814
- function formNormaliser(values) {
1815
- return encodeNullValues({
1816
- ...values
1817
- });
1818
- }
1819
- function Form({ children, cancel = null, initialValues, loading = false, onPreSubmit, onSubmit, submitLabel, validationSchema }) {
1820
- const doSubmit = async (values)=>{
1821
- const payload = onPreSubmit ? await Promise.resolve(onPreSubmit(values)) : values;
1822
- await Promise.resolve(onSubmit(payload));
1823
- };
1824
- return /*#__PURE__*/ jsx(Formik, {
1825
- validateOnMount: true,
1826
- initialValues: formNormaliser(initialValues),
1827
- validationSchema: validationSchema,
1828
- onSubmit: doSubmit,
1829
- children: ({ isValid })=>/*#__PURE__*/ jsx(Form$1, {
1830
- autoComplete: "off",
1831
- "aria-label": "form",
1832
- children: /*#__PURE__*/ jsxs(Row, {
1833
- children: [
1834
- /*#__PURE__*/ jsx(Col, {
1835
- children: children
1836
- }),
1837
- /*#__PURE__*/ jsx(Col, {
1838
- children: /*#__PURE__*/ jsxs(Row, {
1839
- children: [
1840
- /*#__PURE__*/ jsx(Col, {
1841
- xs: 12,
1842
- md: cancel ? 3 : 6,
1843
- mdOffset: 7,
1844
- children: /*#__PURE__*/ jsx(Button, {
1845
- block: true,
1846
- type: "submit",
1847
- colour: "success",
1848
- disabled: !isValid,
1849
- size: "lg",
1850
- loading: loading,
1851
- children: submitLabel
1852
- })
1853
- }),
1854
- cancel && /*#__PURE__*/ jsx(Col, {
1855
- xs: 12,
1856
- md: 3,
1857
- children: cancel
1858
- })
1859
- ]
1860
- })
1861
- })
1862
- ]
1863
- })
1864
- })
1865
- });
1866
- }
1867
-
1868
- const Link = (props)=>// eslint-disable-next-line react/jsx-props-no-spreading
1869
- /*#__PURE__*/ jsx(BaseLink, {
1870
- as: Link$1,
1871
- ...props
1872
- });
1873
-
1874
- const InternalLink = ({ className, colour, block, ...rest })=>// eslint-disable-next-line react/jsx-props-no-spreading
1875
- /*#__PURE__*/ jsx(Link$1, {
1876
- className: className,
1877
- ...rest
1878
- });
1879
- const LinkButton = ({ block = false, colour = 'primary', size = 'md', ...rest })=>/*#__PURE__*/ jsx(ThemeProvider, {
1880
- theme: buttonTheme,
1881
- children: /*#__PURE__*/ jsx(BaseButton, {
1882
- as: InternalLink,
1883
- block: block,
1884
- colour: colour,
1885
- size: size,
1886
- ...rest
1887
- })
1888
- });
1889
-
1890
- const MasonryItem = styled.div`
1891
- ${({ $gutter })=>`
1892
- margin-bottom: ${$gutter};
1893
- `}
1894
- `;
1895
- const calculateCols = (cols)=>12 / cols;
1896
- const Masonry = ({ children, gutter = '1rem', lg, md, sm, xs })=>{
1897
- const breakpoints = {
1898
- lg,
1899
- md,
1900
- sm,
1901
- xs
1902
- };
1903
- const breakpoint = useBreakpoint();
1904
- const columns = breakpoints[breakpoint];
1905
- const cols = Array.from(new Array(columns), ()=>[]);
1906
- const flat = Array.isArray(children) ? children.flat() : [
1907
- children
1908
- ];
1909
- flat.forEach((child, i)=>{
1910
- const colIndex = i % columns;
1911
- cols[colIndex].push(// eslint-disable-next-line react/no-array-index-key
1912
- /*#__PURE__*/ jsx(MasonryItem, {
1913
- $gutter: gutter,
1914
- children: child
1915
- }, i));
1916
- });
1917
- return /*#__PURE__*/ jsx(Row, {
1918
- gutter: gutter,
1919
- children: cols.map((_, i)=>/*#__PURE__*/ jsx(Col, {
1920
- xs: calculateCols(xs),
1921
- sm: calculateCols(sm),
1922
- md: calculateCols(md),
1923
- lg: calculateCols(lg),
1924
- children: cols[i]
1925
- }, i))
1926
- });
1927
- };
1928
-
1929
- const Overlay = styled.div`
1930
- background: rgba(0, 0, 0, 0.5);
1931
- bottom: 0;
1932
- left: 0;
1933
- position: fixed;
1934
- right: 0;
1935
- top: 0;
1936
- z-index: 1000;
1937
- `;
1938
-
1939
- const ModalOuter = styled.div`
1940
- bottom: 0;
1941
- left: 0;
1942
- outline: 0;
1943
- overflow-x: hidden;
1944
- overflow-y: auto;
1945
- position: fixed;
1946
- right: 0;
1947
- top: 0;
1948
- z-index: 1100;
1949
- `;
1950
- const ModalContent = styled.div`
1951
- outline: 0;
1952
- position: relative;
1953
- width: 100%;
1954
- pointer-events: auto;
1955
- `;
1956
- const ModalDialog = styled.div`
1957
- box-shadow:
1958
- 0 3px 5px -1px rgba(0, 0, 0, 0.2),
1959
- 0 5px 8px 0 rgba(0, 0, 0, 0.14),
1960
- 0 1px 14px 0 rgba(0, 0, 0, 0.12);
1961
- margin: 5rem auto;
1962
- max-width: ${({ size })=>size === 'sm' ? '500px' : '90vw'};
1963
- pointer-events: none;
1964
- position: relative;
1965
- `;
1966
- const Modal = ({ children, isOpen, onDismiss, size = 'sm', title })=>{
1967
- const doNotDismiss = (e)=>{
1968
- e.stopPropagation();
1969
- };
1970
- useEffect(()=>{
1971
- const keyboardEvent = (e)=>{
1972
- if (e.key === 'Escape') {
1973
- onDismiss();
1974
- }
1975
- };
1976
- document.addEventListener('keydown', keyboardEvent, false);
1977
- return ()=>{
1978
- document.body.style.removeProperty('overflow');
1979
- document.removeEventListener('keydown', keyboardEvent, false);
1980
- };
1981
- }, [
1982
- onDismiss
1983
- ]);
1984
- useEffect(()=>{
1985
- if (isOpen) {
1986
- document.body.style.overflow = 'hidden';
1987
- }
1988
- }, [
1989
- isOpen
1990
- ]);
1991
- if (isOpen) {
1992
- return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs(Suspense, {
1993
- fallback: /*#__PURE__*/ jsx(Loader, {}),
1994
- children: [
1995
- /*#__PURE__*/ jsx(ModalOuter, {
1996
- "aria-modal": true,
1997
- "aria-label": title,
1998
- role: "dialog",
1999
- tabIndex: -1,
2000
- onClick: onDismiss,
2001
- children: /*#__PURE__*/ jsx(ModalDialog, {
2002
- size: size,
2003
- role: "document",
2004
- children: /*#__PURE__*/ jsx(ModalContent, {
2005
- onClick: doNotDismiss,
2006
- children: /*#__PURE__*/ jsx(Card, {
2007
- padding: "lg",
2008
- children: children
2009
- })
2010
- })
2011
- })
2012
- }),
2013
- /*#__PURE__*/ jsx(Overlay, {})
2014
- ]
2015
- }), document.body);
2016
- }
2017
- return null;
2018
- };
2019
-
2020
- const NotificationArrow = styled.div`
2021
- height: 0;
2022
- position: absolute;
2023
- width: 0;
2024
- border-bottom: 5px solid #007fa8;
2025
- border-left: 5px solid transparent;
2026
- border-right: 5px solid transparent;
2027
- top: -5px;
2028
- `;
2029
- const NotificationButton = styled(Button)`
2030
- background: none;
2031
- color: inherit;
2032
-
2033
- :hover {
2034
- background: none;
2035
- color: inherit;
2036
- }
2037
- `;
2038
- const NotificationContainer = styled.div`
2039
- box-shadow:
2040
- 0 3px 5px -1px rgba(0, 0, 0, 0.2),
2041
- 0 5px 8px 0 rgba(0, 0, 0, 0.14),
2042
- 0 1px 14px 0 rgba(0, 0, 0, 0.12);
2043
- `;
2044
- const NotificationWrapper = styled.div`
2045
- position: relative;
2046
- `;
2047
- const AlertWrapper = styled.div`
2048
- background-color: rgb(199, 56, 79);
2049
- border-radius: 50%;
2050
- color: #fff;
2051
- padding: 5px;
2052
- pointer-events: none;
2053
- position: absolute;
2054
- right: 5px;
2055
- top: -5px;
2056
- transform: scale(0.5);
2057
- z-index: 1;
2058
- `;
2059
- const NotificationAlert = ()=>/*#__PURE__*/ jsx(AlertWrapper, {
2060
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
2061
- icon: faAsterisk
2062
- })
2063
- });
2064
- function Notifications({ alert, cols = 1, items, label, noResults, onClose, placement = 'bottom', row }) {
2065
- const isFirstRun = useRef(true);
2066
- const [visible, setVisible] = useState(false);
2067
- const [referenceElement, setReferenceElement] = useState(null);
2068
- const [arrowElement, setArrowElement] = useState(null);
2069
- const [popperElement, setPopperElement] = useState(null);
2070
- const { attributes, styles } = usePopper(referenceElement, popperElement, {
2071
- modifiers: [
2072
- {
2073
- name: 'arrow',
2074
- options: {
2075
- element: arrowElement
2076
- }
2077
- }
2078
- ],
2079
- placement,
2080
- strategy: 'fixed'
2081
- });
2082
- const toggleNotifications = ()=>{
2083
- setVisible(!visible);
2084
- };
2085
- useOutsideClick(referenceElement, ()=>{
2086
- setVisible(false);
2087
- });
2088
- useEffect(()=>{
2089
- if (isFirstRun.current) {
2090
- isFirstRun.current = false;
2091
- return;
2092
- }
2093
- if (!visible) {
2094
- Promise.resolve().then(onClose, ()=>{});
2095
- }
2096
- // eslint-disable-next-line react-hooks/exhaustive-deps
2097
- }, [
2098
- visible
2099
- ]);
2100
- return /*#__PURE__*/ jsxs(NotificationWrapper, {
2101
- ref: setReferenceElement,
2102
- children: [
2103
- alert && /*#__PURE__*/ jsx(NotificationAlert, {}),
2104
- /*#__PURE__*/ jsx(NotificationButton, {
2105
- "aria-label": label,
2106
- size: "sm",
2107
- onClick: toggleNotifications,
2108
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
2109
- icon: faBell
2110
- })
2111
- }),
2112
- visible && /*#__PURE__*/ jsxs(NotificationContainer, {
2113
- ref: setPopperElement,
2114
- style: styles.popper,
2115
- ...attributes.popper,
2116
- children: [
2117
- /*#__PURE__*/ jsx(DataTable, {
2118
- header: /*#__PURE__*/ jsx(TableCell, {
2119
- as: "th",
2120
- align: "left",
2121
- colSpan: cols,
2122
- children: label
2123
- }),
2124
- items: items,
2125
- noResults: noResults,
2126
- row: row
2127
- }),
2128
- /*#__PURE__*/ jsx(NotificationArrow, {
2129
- ref: setArrowElement,
2130
- style: styles.arrow
2131
- })
2132
- ]
2133
- })
2134
- ]
2135
- });
2136
- }
2137
-
2138
- const PageTitleTypography = styled(Typography)`
2139
- line-height: 1.4;
2140
- margin: 0 0 0.2rem;
2141
- `;
2142
- const TitleInner = styled.span`
2143
- background-color: #007fa8;
2144
- box-decoration-break: clone;
2145
- color: #fff;
2146
- display: inline;
2147
- padding: 0.25rem 0.5rem;
2148
- `;
2149
- const SubTitleInner = styled.span`
2150
- background-color: #f8f8f8;
2151
- box-decoration-break: clone;
2152
- color: #000;
2153
- display: inline;
2154
- padding: 0.25rem 0.5rem;
2155
- `;
2156
- const Split = styled.hr`
2157
- border: 0;
2158
- margin: 0;
2159
- padding: 0;
2160
- `;
2161
- const Wrapper$1 = styled.div`
2162
- margin-bottom: 1rem;
2163
- padding: 0 0.25rem 0 0;
2164
- `;
2165
- const PageTitle = ({ subTitle = null, title })=>/*#__PURE__*/ jsxs(Wrapper$1, {
2166
- children: [
2167
- /*#__PURE__*/ jsx(PageTitleTypography, {
2168
- component: "h2",
2169
- variant: "h2",
2170
- children: /*#__PURE__*/ jsx(TitleInner, {
2171
- children: title
2172
- })
2173
- }),
2174
- /*#__PURE__*/ jsx(Split, {}),
2175
- subTitle && /*#__PURE__*/ jsx(PageTitleTypography, {
2176
- component: "p",
2177
- variant: "lead",
2178
- margin: "none",
2179
- children: /*#__PURE__*/ jsx(SubTitleInner, {
2180
- children: subTitle
2181
- })
2182
- })
2183
- ]
2184
- });
2185
-
2186
- const ProgressBarInternal = styled.progress`
2187
- appearance: none;
2188
- background-color: ${rgba('#007fa8', 0.25)};
2189
- border: none;
2190
- height: 20px;
2191
- margin: 0;
2192
- padding: 0;
2193
- width: 100%;
2194
-
2195
- &::-webkit-progress-bar {
2196
- background-color: ${rgba('#007fa8', 0.25)};
2197
- height: 20px;
2198
- }
2199
-
2200
- &::-webkit-progress-value {
2201
- background-color: #007fa8;
2202
- height: 20px;
2203
- }
2204
-
2205
- &::-moz-progress-bar {
2206
- background-color: #007fa8;
2207
- height: 20px;
2208
- }
2209
- `;
2210
- const ProgressBar = ({ max = 100, progress })=>/*#__PURE__*/ jsx(ProgressBarInternal, {
2211
- max: max,
2212
- value: progress
2213
- });
2214
-
2215
- const InternalRadio = ({ disabled, field, form, helpText, label, onChange, options, readOnly, spacing })=>{
2216
- const { errors, handleChange, setFieldValue, touched } = form;
2217
- const error = useInputValidation(field.name, errors, touched);
2218
- const markAsDisabled = disabled || readOnly;
2219
- const doChange = (e, value)=>{
2220
- handleChange(e);
2221
- setFieldValue(field.name, value).catch(()=>{});
2222
- if (onChange) {
2223
- onChange(e, form);
2224
- }
2225
- };
2226
- return /*#__PURE__*/ jsxs(FieldSet, {
2227
- error: error,
2228
- helpText: helpText,
2229
- message: getIn(errors, field.name),
2230
- name: field.name,
2231
- spacing: spacing,
2232
- children: [
2233
- /*#__PURE__*/ jsx(Legend, {
2234
- error: error,
2235
- children: label
2236
- }),
2237
- options.map(({ name, value })=>/*#__PURE__*/ jsxs(OptionLabel, {
2238
- disabled: disabled,
2239
- selected: field.value === value,
2240
- children: [
2241
- /*#__PURE__*/ jsx(CheckableInput, {
2242
- ...field,
2243
- checked: field.value === value,
2244
- disabled: markAsDisabled,
2245
- readOnly: readOnly,
2246
- type: "radio",
2247
- value: value,
2248
- onChange: (e)=>doChange(e, value)
2249
- }),
2250
- /*#__PURE__*/ jsx(OptionLabelText, {
2251
- children: name
2252
- })
2253
- ]
2254
- }, value)),
2255
- readOnly && /*#__PURE__*/ jsx("input", {
2256
- type: "hidden",
2257
- ...field
2258
- })
2259
- ]
2260
- });
2261
- };
2262
- const Radio = ({ disabled = false, helpText = null, label, name, onChange, options, readOnly = false, spacing = 'md' })=>/*#__PURE__*/ jsx(Field, {
2263
- id: name,
2264
- component: InternalRadio,
2265
- disabled: disabled,
2266
- helpText: helpText,
2267
- name: name,
2268
- onChange: onChange,
2269
- options: options,
2270
- readOnly: readOnly,
2271
- label: label,
2272
- spacing: spacing
2273
- });
2274
-
2275
- const ScrollToTop = ()=>{
2276
- const { pathname } = useLocation();
2277
- useEffect(()=>{
2278
- window.scrollTo(0, 0);
2279
- }, [
2280
- pathname
2281
- ]);
2282
- return null;
2283
- };
2284
-
2285
- const BaseSelectInput = styled.select`
2286
- ${({ $active, $readOnly })=>`
2287
- appearance: none;
2288
- background: #fff;
2289
- border: none;
2290
- color: ${$active ? '#333' : '#fff'};
2291
- cursor: pointer;
2292
- font-size: 16px;
2293
- outline: 0;
2294
- padding: 16px 0 10px;
2295
- width: 100%;
2296
-
2297
- ${$readOnly ? `
2298
- :disabled {
2299
- color: ${$active ? '#333' : '#fff'};
2300
- }
2301
- ` : `
2302
- :disabled {
2303
- color: ${$active ? '#767676' : '#fff'};
2304
- }
2305
- `}
2306
- `}
2307
- `;
2308
- const SelectInput = ({ active, describedBy, errors, readOnly, ...rest })=>/*#__PURE__*/ jsx(BaseSelectInput, {
2309
- $active: active,
2310
- $readOnly: readOnly,
2311
- "aria-describedby": errors ? describedBy : undefined,
2312
- ...rest
2313
- });
2314
- const IconOuter = styled.div`
2315
- margin-top: -21px;
2316
- pointer-events: none;
2317
- position: absolute;
2318
- right: 38px;
2319
- top: 50%;
2320
- z-index: 1;
2321
- `;
2322
- const IconInner = styled.div`
2323
- color: #767676;
2324
- cursor: pointer;
2325
- display: block;
2326
- height: 42px;
2327
- line-height: 42px;
2328
- text-align: center;
2329
- width: 42px;
2330
- `;
2331
- const InternalSelect = ({ active, disabled, field, form, helpText, label, onChange, options, readOnly, placeholder, setFocus, spacing, ...props })=>{
2332
- useEffect(()=>{
2333
- const focus = !!field.value || field.value === 0;
2334
- setFocus(focus);
2335
- // eslint-disable-next-line react-hooks/exhaustive-deps
2336
- }, []);
2337
- const { onBlur, ...rest } = field;
2338
- const { errors, handleBlur, handleChange, touched } = form;
2339
- const error = useInputValidation(field.name, errors, touched);
2340
- const markAsDisabled = disabled || readOnly;
2341
- const describedBy = `${field.name}-error`;
2342
- const doBlur = (e)=>{
2343
- handleBlur(e);
2344
- if (!field.value && field.value !== 0) {
2345
- setFocus(false);
2346
- }
2347
- onBlur(e);
2348
- };
2349
- const doChange = (e)=>{
2350
- handleChange(e);
2351
- if (onChange) {
2352
- onChange(e, form);
2353
- }
2354
- };
2355
- const doFocus = ()=>{
2356
- if (!field.value && field.value !== 0) {
2357
- setFocus(true);
2358
- }
2359
- };
2360
- return /*#__PURE__*/ jsxs(InputWrapper, {
2361
- error: error,
2362
- helpText: helpText,
2363
- message: getIn(errors, field.name),
2364
- name: field.name,
2365
- spacing: spacing,
2366
- children: [
2367
- /*#__PURE__*/ jsx(Label, {
2368
- htmlFor: field.name,
2369
- active: active,
2370
- error: error,
2371
- children: label
2372
- }),
2373
- /*#__PURE__*/ jsxs(SelectInput, {
2374
- ...props,
2375
- ...rest,
2376
- active: active,
2377
- describedBy: describedBy,
2378
- disabled: markAsDisabled,
2379
- errors: error,
2380
- onBlur: doBlur,
2381
- onChange: doChange,
2382
- onFocus: doFocus,
2383
- readOnly: readOnly,
2384
- children: [
2385
- /*#__PURE__*/ jsx("option", {
2386
- disabled: true,
2387
- value: "",
2388
- children: placeholder
2389
- }),
2390
- options.map(({ name, value })=>/*#__PURE__*/ jsx("option", {
2391
- value: value,
2392
- children: name
2393
- }, value))
2394
- ]
2395
- }),
2396
- /*#__PURE__*/ jsx(IconOuter, {
2397
- children: /*#__PURE__*/ jsx(IconInner, {
2398
- children: /*#__PURE__*/ jsx(FontAwesomeIcon, {
2399
- icon: faAngleDown
2400
- })
2401
- })
2402
- }),
2403
- readOnly && /*#__PURE__*/ jsx("input", {
2404
- type: "hidden",
2405
- ...field
2406
- })
2407
- ]
2408
- });
2409
- };
2410
- const Select = ({ disabled = false, helpText = null, label, name, onChange, options, placeholder, readOnly = false, spacing = 'md' })=>{
2411
- const [focus, setFocus] = useState();
2412
- return /*#__PURE__*/ jsx(Field, {
2413
- id: name,
2414
- component: InternalSelect,
2415
- active: focus,
2416
- disabled: disabled,
2417
- helpText: helpText,
2418
- name: name,
2419
- onChange: onChange,
2420
- options: options,
2421
- placeholder: placeholder,
2422
- readOnly: readOnly,
2423
- setFocus: setFocus,
2424
- label: label,
2425
- spacing: spacing
2426
- });
2427
- };
2428
-
2429
- const Stepper = ({ children, enableNext = ()=>true, nextLabel, onComplete, onStart, previousLabel, start = 0 })=>{
2430
- const [step, setStep] = useState(start);
2431
- const activeStep = Children.toArray(children)[step];
2432
- const steps = Children.count(children) - 1;
2433
- const next = ()=>{
2434
- setStep(step + 1);
2435
- };
2436
- const showNext = step < steps;
2437
- const previous = ()=>{
2438
- setStep(step - 1);
2439
- };
2440
- const disablePrevious = step === 0;
2441
- const progress = step / steps * 100;
2442
- const showOnStart = disablePrevious && onStart;
2443
- return /*#__PURE__*/ jsxs(Row, {
2444
- children: [
2445
- /*#__PURE__*/ jsx(Col, {
2446
- children: activeStep
2447
- }),
2448
- /*#__PURE__*/ jsx(Col, {
2449
- children: /*#__PURE__*/ jsx(Row, {
2450
- children: /*#__PURE__*/ jsxs(Col, {
2451
- xs: 12,
2452
- md: 6,
2453
- mdOffset: 7,
2454
- children: [
2455
- /*#__PURE__*/ jsx(Card, {
2456
- padding: "none",
2457
- children: /*#__PURE__*/ jsx(ProgressBar, {
2458
- progress: progress
2459
- })
2460
- }),
2461
- /*#__PURE__*/ jsx(Card, {
2462
- padding: "lg",
2463
- children: /*#__PURE__*/ jsxs(Row, {
2464
- children: [
2465
- /*#__PURE__*/ jsxs(Col, {
2466
- xs: 12,
2467
- md: 6,
2468
- children: [
2469
- showOnStart && onStart,
2470
- !showOnStart && /*#__PURE__*/ jsx(Button, {
2471
- block: true,
2472
- disabled: disablePrevious,
2473
- size: "lg",
2474
- onClick: previous,
2475
- children: previousLabel
2476
- })
2477
- ]
2478
- }),
2479
- /*#__PURE__*/ jsxs(Col, {
2480
- xs: 12,
2481
- md: 6,
2482
- align: "right",
2483
- children: [
2484
- showNext && /*#__PURE__*/ jsx(Button, {
2485
- block: true,
2486
- disabled: !enableNext(step),
2487
- size: "lg",
2488
- onClick: next,
2489
- children: nextLabel
2490
- }),
2491
- !showNext && onComplete
2492
- ]
2493
- })
2494
- ]
2495
- })
2496
- })
2497
- ]
2498
- })
2499
- })
2500
- })
2501
- ]
2502
- });
2503
- };
2504
-
2505
- const BaseTextBox = styled.input`
2506
- ${({ $active })=>`
2507
- background: #fff;
2508
- border: none;
2509
- color: ${$active ? '#333' : '#fff'};
2510
- cursor: ${$active ? 'text' : 'pointer'};
2511
- font-size: 16px;
2512
- outline: 0;
2513
- padding: 16px 0 10px;
2514
- width: 100%;
2515
-
2516
- :disabled {
2517
- color: #767676;
2518
- }
2519
-
2520
- ::placeholder {
2521
- color: ${$active ? '#767676' : '#fff'};
2522
- }
2523
-
2524
- :-ms-input-placeholder {
2525
- color: ${$active ? '#767676' : '#fff'};
2526
- }
2527
-
2528
- ::-ms-input-placeholder {
2529
- color: ${$active ? '#767676' : '#fff'};
2530
- }
2531
-
2532
- ::-webkit-outer-spin-button,
2533
- ::-webkit-inner-spin-button {
2534
- -webkit-appearance: none;
2535
- margin: 0;
2536
- }
2537
-
2538
- [type="number"] {
2539
- -moz-appearance: textfield;
2540
- }
2541
- `}
2542
- `;
2543
- const Input = ({ active, describedBy, errors, ...rest })=>/*#__PURE__*/ jsx(BaseTextBox, {
2544
- $active: active,
2545
- "aria-describedby": errors ? describedBy : undefined,
2546
- ...rest
2547
- });
2548
- const InternalTextBox = ({ active, decimalScale, field, format, form, helpText, label, onChange, prefix, setFocus, spacing, suffix, ...props })=>{
2549
- useEffect(()=>{
2550
- const focus = !!field.value || field.value === 0;
2551
- setFocus(focus);
2552
- // eslint-disable-next-line react-hooks/exhaustive-deps
2553
- }, [
2554
- field.value
2555
- ]);
2556
- const { onBlur, ...rest } = field;
2557
- const { errors, handleBlur, handleChange, setFieldValue, touched } = form;
2558
- const error = useInputValidation(field.name, errors, touched);
2559
- const describedBy = `${field.name}-error`;
2560
- const useNumberFormat = Boolean(decimalScale || format || prefix || suffix);
2561
- const doBlur = (e)=>{
2562
- handleBlur(e);
2563
- if (!field.value && field.value !== 0) {
2564
- setFocus(false);
2565
- }
2566
- onBlur(e);
2567
- };
2568
- const doFocus = ()=>{
2569
- if (!field.value && field.value !== 0) {
2570
- setFocus(true);
2571
- }
2572
- };
2573
- const doValueChange = ({ floatValue, formattedValue })=>{
2574
- if (format) {
2575
- setFieldValue(field.name, formattedValue).catch(()=>{});
2576
- } else {
2577
- setFieldValue(field.name, floatValue).catch(()=>{});
2578
- }
2579
- };
2580
- const doChange = (e)=>{
2581
- if (!useNumberFormat) {
2582
- handleChange(e);
2583
- }
2584
- if (onChange) {
2585
- Promise.resolve(onChange(e, form)).catch(()=>{});
2586
- }
2587
- };
2588
- return /*#__PURE__*/ jsxs(InputWrapper, {
2589
- error: error,
2590
- helpText: helpText,
2591
- message: getIn(errors, field.name),
2592
- name: field.name,
2593
- spacing: spacing,
2594
- children: [
2595
- /*#__PURE__*/ jsx(Label, {
2596
- htmlFor: field.name,
2597
- active: active,
2598
- error: error,
2599
- children: label
2600
- }),
2601
- (()=>{
2602
- if (useNumberFormat) {
2603
- if (format) {
2604
- return /*#__PURE__*/ jsx(PatternFormat, {
2605
- ...props,
2606
- ...rest,
2607
- valueIsNumericString: Boolean(prefix || suffix),
2608
- customInput: Input,
2609
- format: format,
2610
- inputMode: "decimal",
2611
- prefix: prefix,
2612
- active: active,
2613
- describedBy: describedBy,
2614
- errors: error,
2615
- onBlur: doBlur,
2616
- onChange: doChange,
2617
- onFocus: doFocus,
2618
- onValueChange: doValueChange
2619
- });
2620
- }
2621
- return /*#__PURE__*/ jsx(NumericFormat, {
2622
- ...props,
2623
- ...rest,
2624
- valueIsNumericString: Boolean(prefix || suffix),
2625
- customInput: Input,
2626
- decimalScale: decimalScale,
2627
- fixedDecimalScale: !!decimalScale,
2628
- inputMode: "decimal",
2629
- prefix: prefix,
2630
- suffix: suffix,
2631
- active: active,
2632
- describedBy: describedBy,
2633
- errors: error,
2634
- onBlur: doBlur,
2635
- onChange: doChange,
2636
- onFocus: doFocus,
2637
- onValueChange: doValueChange
2638
- });
2639
- }
2640
- return /*#__PURE__*/ jsx(Input, {
2641
- ...props,
2642
- ...rest,
2643
- active: active,
2644
- describedBy: describedBy,
2645
- errors: error,
2646
- onBlur: doBlur,
2647
- onChange: doChange,
2648
- onFocus: doFocus
2649
- });
2650
- })()
2651
- ]
2652
- });
2653
- };
2654
- const TextBox = ({ decimalScale, disabled = false, format, helpText = null, label, name, onChange, placeholder = '', prefix, readOnly = false, spacing = 'md', suffix, type = 'text' })=>{
2655
- const [focus, setFocus] = useState();
2656
- return /*#__PURE__*/ jsx(Field, {
2657
- id: name,
2658
- component: InternalTextBox,
2659
- decimalScale: decimalScale,
2660
- disabled: disabled,
2661
- active: focus,
2662
- format: format,
2663
- helpText: helpText,
2664
- type: type,
2665
- name: name,
2666
- onChange: onChange,
2667
- placeholder: placeholder,
2668
- prefix: prefix,
2669
- readOnly: readOnly,
2670
- setFocus: setFocus,
2671
- suffix: suffix,
2672
- label: label,
2673
- spacing: spacing
2674
- });
2675
- };
2676
-
2677
- const ToastContainer = styled.div`
2678
- bottom: 0;
2679
- left: 1rem;
2680
- position: fixed;
2681
- right: 1rem;
2682
- z-index: 1800;
2683
- `;
2684
- const ToastContext = /*#__PURE__*/ createContext(null);
2685
- const useToast = ()=>useContext(ToastContext);
2686
- const generateId = ()=>{
2687
- const array = new Uint32Array(2);
2688
- const output = crypto.getRandomValues(array);
2689
- return output[0].toString(36).substring(2, 15) + output[1].toString(36).substring(2, 15);
2690
- };
2691
- const selectIcon = (alertType)=>{
2692
- switch(alertType){
2693
- case 'danger':
2694
- return faExclamationTriangle;
2695
- case 'success':
2696
- return faCheckCircle;
2697
- case 'primary':
2698
- case 'secondary':
2699
- default:
2700
- return faExclamationCircle;
2701
- }
2702
- };
2703
- const ToastProvider = ({ children })=>{
2704
- const [toasts, setToasts] = useState([]);
2705
- const add = useCallback(({ colour, message, onDismiss })=>{
2706
- const id = generateId();
2707
- setToasts([
2708
- ...toasts,
2709
- {
2710
- colour,
2711
- id,
2712
- message,
2713
- onDismiss
2714
- }
2715
- ]);
2716
- }, [
2717
- toasts
2718
- ]);
2719
- const remove = useCallback((id)=>{
2720
- setToasts((value)=>{
2721
- const item = value.findIndex((t)=>t.id === id);
2722
- if (value[item]?.onDismiss) {
2723
- value[item].onDismiss();
2724
- }
2725
- if (item !== -1) {
2726
- value.splice(item, 1);
2727
- }
2728
- return value;
2729
- });
2730
- }, []);
2731
- const value = useMemo(()=>({
2732
- add,
2733
- remove
2734
- }), [
2735
- add,
2736
- remove
2737
- ]);
2738
- return /*#__PURE__*/ jsxs(ToastContext.Provider, {
2739
- value: value,
2740
- children: [
2741
- children,
2742
- /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(ToastContainer, {
2743
- children: toasts.map(({ colour, id, message })=>/*#__PURE__*/ jsx(Alert, {
2744
- spacing: "lg",
2745
- dismissable: 5000,
2746
- icon: /*#__PURE__*/ jsx(FontAwesomeIcon, {
2747
- icon: selectIcon(colour)
2748
- }),
2749
- colour: colour,
2750
- message: message,
2751
- onDismiss: ()=>{
2752
- remove(id);
2753
- }
2754
- }, id))
2755
- }), document.body)
2756
- ]
2757
- });
2758
- };
2759
-
2760
- const TypeaheadWrapper = styled.div`
2761
- position: relative;
2762
- `;
2763
- const Suggestions = styled.div`
2764
- width: 100%;
2765
- z-index: 10;
2766
- `;
2767
- const Suggestion = styled(Button)`
2768
- padding-left: 8px;
2769
- padding-right: 8px;
2770
- text-align: left;
2771
- `;
2772
- const Typeahead = ({ suggestions, ...rest })=>{
2773
- const { name } = rest;
2774
- const [filteredSuggestions, setFilteredSuggestions] = useState(suggestions);
2775
- const [referenceElement, setReferenceElement] = useState(null);
2776
- const [popperElement, setPopperElement] = useState(null);
2777
- const [visible, setVisible] = useState(false);
2778
- const [form, setForm] = useState();
2779
- const { attributes, styles } = usePopper(referenceElement, popperElement, {
2780
- placement: 'bottom'
2781
- });
2782
- const setValue = (value)=>{
2783
- form.setFieldValue(name, value).catch(()=>{});
2784
- setVisible(false);
2785
- };
2786
- useOutsideClick(referenceElement, ()=>{
2787
- setVisible(false);
2788
- });
2789
- return /*#__PURE__*/ jsxs(TypeaheadWrapper, {
2790
- ref: setReferenceElement,
2791
- children: [
2792
- /*#__PURE__*/ jsx(TextBox, {
2793
- type: "text",
2794
- onChange: (e, context)=>{
2795
- if (!form) {
2796
- setForm(context);
2797
- }
2798
- const input = e.currentTarget.value;
2799
- const filter = suggestions.filter(({ name: suggestion })=>suggestion.toLowerCase().indexOf(input.toLowerCase()) > -1);
2800
- setFilteredSuggestions(filter);
2801
- if (visible) {
2802
- setVisible(!!input);
2803
- } else {
2804
- setVisible(true);
2805
- }
2806
- },
2807
- ...rest
2808
- }),
2809
- visible && /*#__PURE__*/ jsx(Suggestions, {
2810
- ref: setPopperElement,
2811
- style: styles.popper,
2812
- ...attributes.popper,
2813
- children: [
2814
- ...filteredSuggestions
2815
- ].sort((a, b)=>a.name.localeCompare(b.name)).map(({ name: suggestion, value })=>/*#__PURE__*/ jsx(Suggestion, {
2816
- block: true,
2817
- colour: "secondary",
2818
- size: "sm",
2819
- onClick: ()=>setValue(value),
2820
- children: suggestion
2821
- }, value))
2822
- })
2823
- ]
2824
- });
2825
- };
2826
-
2827
- const Wrapper = styled.div`
2828
- margin: 100px 0;
2829
- padding: 1rem;
2830
- `;
2831
- const Window = ({ children })=>/*#__PURE__*/ jsx(Wrapper, {
2832
- children: /*#__PURE__*/ jsx(Row, {
2833
- children: /*#__PURE__*/ jsx(Col, {
2834
- sm: 8,
2835
- smOffset: 3,
2836
- md: 6,
2837
- mdOffset: 4,
2838
- lg: 4,
2839
- lgOffset: 5,
2840
- children: children
2841
- })
2842
- })
2843
- });
2844
-
2845
- export { Alert, AppBar, Avatar, BaseStyles, Breakpoint, Button, ButtonLink, Calendar, Card, CheckBox, Col, Content, DataTable, DatePicker, DateTime, FileUpload, Form, Link, LinkButton, Loader, Masonry, Modal, Notifications, Overlay, PageTitle, ProgressBar, Radio, Row, ScrollToTop, Select, Stepper, Table, TableBody, TableCell, TableHead, TableRow, TextBox, ToastContext, ToastProvider, Tooltip, Typeahead, Typography, Window, formatDateTime, useBreakpoint, useOutsideClick, useToast, useWindowSize };
2846
- //# sourceMappingURL=index.esm.js.map