@motech-development/breeze-ui 2.4.0 → 3.0.1

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