@sqrzro/admin 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/.eslintrc +4 -0
  2. package/.gitattributes +1 -0
  3. package/.prettierrc +9 -0
  4. package/.storybook/main.js +40 -0
  5. package/.storybook/manager.js +4 -0
  6. package/.storybook/postcss.config.js +3 -0
  7. package/.storybook/preview.js +11 -0
  8. package/.storybook/theme.js +7 -0
  9. package/.stylelintrc +9 -0
  10. package/LICENSE +5 -0
  11. package/README.md +9 -0
  12. package/__mocks__/squarezero-utility.ts +40 -0
  13. package/assets/logo-horizontal-dark.svg +21 -0
  14. package/assets/logo-horizontal-white.svg +21 -0
  15. package/assets/logo-vertical-dark.svg +21 -0
  16. package/assets/logo-vertical-white.svg +21 -0
  17. package/dist/index.css +3554 -0
  18. package/dist/index.js +5099 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/types/components/Alert/index.d.ts +10 -0
  21. package/dist/types/components/Allow/index.d.ts +13 -0
  22. package/dist/types/components/App/index.d.ts +19 -0
  23. package/dist/types/components/AutoSuggest/index.d.ts +60 -0
  24. package/dist/types/components/Button/index.d.ts +36 -0
  25. package/dist/types/components/CalendarInput/index.d.ts +10 -0
  26. package/dist/types/components/CheckboxList/index.d.ts +4 -0
  27. package/dist/types/components/ConnectedDropdown/index.d.ts +8 -0
  28. package/dist/types/components/ConnectedList/index.d.ts +4 -0
  29. package/dist/types/components/ConnectedScene/index.d.ts +11 -0
  30. package/dist/types/components/ConnectedTable/index.d.ts +4 -0
  31. package/dist/types/components/ContentBlock/index.d.ts +6 -0
  32. package/dist/types/components/DateInput/index.d.ts +7 -0
  33. package/dist/types/components/Document/index.d.ts +6 -0
  34. package/dist/types/components/Dropdown/index.d.ts +14 -0
  35. package/dist/types/components/Fieldset/index.d.ts +11 -0
  36. package/dist/types/components/FileInput/index.d.ts +4 -0
  37. package/dist/types/components/FilterLink/index.d.ts +7 -0
  38. package/dist/types/components/Form/index.d.ts +11 -0
  39. package/dist/types/components/FormActions/index.d.ts +9 -0
  40. package/dist/types/components/FormField/index.d.ts +27 -0
  41. package/dist/types/components/FormRepeater/index.d.ts +8 -0
  42. package/dist/types/components/ImageInput/index.d.ts +4 -0
  43. package/dist/types/components/InfoPanel/index.d.ts +8 -0
  44. package/dist/types/components/Link/__mocks__/index.d.ts +6 -0
  45. package/dist/types/components/Link/index.d.ts +13 -0
  46. package/dist/types/components/List/index.d.ts +23 -0
  47. package/dist/types/components/ListActions/index.d.ts +9 -0
  48. package/dist/types/components/LoginForm/index.d.ts +3 -0
  49. package/dist/types/components/Message/index.d.ts +7 -0
  50. package/dist/types/components/ModalActions/index.d.ts +11 -0
  51. package/dist/types/components/MoneyInput/index.d.ts +10 -0
  52. package/dist/types/components/PasswordForm/index.d.ts +3 -0
  53. package/dist/types/components/PasswordInput/index.d.ts +8 -0
  54. package/dist/types/components/RadioList/index.d.ts +4 -0
  55. package/dist/types/components/Scene/index.d.ts +10 -0
  56. package/dist/types/components/SummaryList/index.d.ts +8 -0
  57. package/dist/types/components/Switch/index.d.ts +9 -0
  58. package/dist/types/components/Table/index.d.ts +13 -0
  59. package/dist/types/components/Tag/index.d.ts +8 -0
  60. package/dist/types/components/TextArea/index.d.ts +4 -0
  61. package/dist/types/components/TextInput/index.d.ts +17 -0
  62. package/dist/types/components/WebsiteInput/index.d.ts +10 -0
  63. package/dist/types/components/WeekCalendar/index.d.ts +12 -0
  64. package/dist/types/core/AppHeader/index.d.ts +3 -0
  65. package/dist/types/core/AppLogo/index.d.ts +6 -0
  66. package/dist/types/core/AppLogoImage/index.d.ts +3 -0
  67. package/dist/types/core/AppLogoPlaceholder/index.d.ts +3 -0
  68. package/dist/types/core/Assistive/index.d.ts +6 -0
  69. package/dist/types/core/Banner/index.d.ts +3 -0
  70. package/dist/types/core/BuildModal/index.d.ts +3 -0
  71. package/dist/types/core/Calendar/index.d.ts +11 -0
  72. package/dist/types/core/CalendarDay/index.d.ts +16 -0
  73. package/dist/types/core/CalendarMonth/index.d.ts +12 -0
  74. package/dist/types/core/CalendarNavigation/index.d.ts +9 -0
  75. package/dist/types/core/CalendarWeek/index.d.ts +14 -0
  76. package/dist/types/core/ChkRad/index.d.ts +10 -0
  77. package/dist/types/core/ChkRadIcon/index.d.ts +7 -0
  78. package/dist/types/core/ChkRadList/index.d.ts +15 -0
  79. package/dist/types/core/CloseButton/index.d.ts +9 -0
  80. package/dist/types/core/ConfirmModal/index.d.ts +3 -0
  81. package/dist/types/core/ConnectedRepeater/index.d.ts +26 -0
  82. package/dist/types/core/ConnectedRepeaterComponent/index.d.ts +24 -0
  83. package/dist/types/core/Container/index.d.ts +7 -0
  84. package/dist/types/core/DropdownPanel/index.d.ts +18 -0
  85. package/dist/types/core/EmptyMessage/index.d.ts +12 -0
  86. package/dist/types/core/ErrorBoundary/index.d.ts +15 -0
  87. package/dist/types/core/ErrorMessage/index.d.ts +8 -0
  88. package/dist/types/core/FilterItem/index.d.ts +10 -0
  89. package/dist/types/core/Filters/index.d.ts +11 -0
  90. package/dist/types/core/FixedActions/index.d.ts +12 -0
  91. package/dist/types/core/FormError/index.d.ts +6 -0
  92. package/dist/types/core/FormLabel/index.d.ts +8 -0
  93. package/dist/types/core/FormLegend/index.d.ts +6 -0
  94. package/dist/types/core/Header/index.d.ts +8 -0
  95. package/dist/types/core/Icon/index.d.ts +7 -0
  96. package/dist/types/core/IconButton/Icon/index.d.ts +7 -0
  97. package/dist/types/core/IconButton/index.d.ts +11 -0
  98. package/dist/types/core/InputPanel/index.d.ts +8 -0
  99. package/dist/types/core/ListItem/index.d.ts +16 -0
  100. package/dist/types/core/ListItemAction/index.d.ts +4 -0
  101. package/dist/types/core/ListItemActions/index.d.ts +8 -0
  102. package/dist/types/core/ListItemMetaItem/index.d.ts +10 -0
  103. package/dist/types/core/ListItemTitle/index.d.ts +9 -0
  104. package/dist/types/core/Loader/index.d.ts +6 -0
  105. package/dist/types/core/MeActions/index.d.ts +3 -0
  106. package/dist/types/core/MePanel/index.d.ts +9 -0
  107. package/dist/types/core/Modal/index.d.ts +12 -0
  108. package/dist/types/core/Navigation/index.d.ts +3 -0
  109. package/dist/types/core/NavigationDivider/index.d.ts +3 -0
  110. package/dist/types/core/NavigationItem/index.d.ts +7 -0
  111. package/dist/types/core/Pagination/index.d.ts +7 -0
  112. package/dist/types/core/PaginationItem/index.d.ts +7 -0
  113. package/dist/types/core/Panel/index.d.ts +8 -0
  114. package/dist/types/core/RadialProgress/index.d.ts +8 -0
  115. package/dist/types/core/StaticTextInput/index.d.ts +12 -0
  116. package/dist/types/core/Styled/index.d.ts +6 -0
  117. package/dist/types/core/SummaryListItem/index.d.ts +15 -0
  118. package/dist/types/core/TableActionsCell/index.d.ts +8 -0
  119. package/dist/types/core/TableCell/index.d.ts +8 -0
  120. package/dist/types/core/TableHead/index.d.ts +8 -0
  121. package/dist/types/core/TableRow/index.d.ts +13 -0
  122. package/dist/types/core/Tabs/index.d.ts +11 -0
  123. package/dist/types/core/TextInputAncillary/index.d.ts +11 -0
  124. package/dist/types/core/Toast/index.d.ts +3 -0
  125. package/dist/types/core/WeekCalendarDay/index.d.ts +14 -0
  126. package/dist/types/filters/BooleanFilter/index.d.ts +5 -0
  127. package/dist/types/filters/DateFilter/index.d.ts +5 -0
  128. package/dist/types/filters/DropdownFilter/index.d.ts +5 -0
  129. package/dist/types/filters/QuickDateFilter/index.d.ts +5 -0
  130. package/dist/types/filters/interfaces.d.ts +36 -0
  131. package/dist/types/hooks/useAccessiblePanel.d.ts +13 -0
  132. package/dist/types/hooks/useAppContext.d.ts +37 -0
  133. package/dist/types/hooks/useClickOutside.d.ts +3 -0
  134. package/dist/types/hooks/useConnectedList.d.ts +7 -0
  135. package/dist/types/hooks/useFilters.d.ts +3 -0
  136. package/dist/types/hooks/useForm.d.ts +26 -0
  137. package/dist/types/hooks/useFormData.d.ts +9 -0
  138. package/dist/types/hooks/useLayout.d.ts +6 -0
  139. package/dist/types/hooks/useModal.d.ts +12 -0
  140. package/dist/types/hooks/useVariant.d.ts +6 -0
  141. package/dist/types/index.d.ts +187 -0
  142. package/dist/types/scenes/Error404Scene.d.ts +3 -0
  143. package/dist/types/services/BuildService.d.ts +5 -0
  144. package/dist/types/services/ConfirmService.d.ts +12 -0
  145. package/dist/types/services/DateService.d.ts +17 -0
  146. package/dist/types/services/DownloadService.d.ts +5 -0
  147. package/dist/types/services/FilterComponentService.d.ts +8 -0
  148. package/dist/types/services/FilterService.d.ts +13 -0
  149. package/dist/types/services/FormatService.d.ts +7 -0
  150. package/dist/types/services/ToastService.d.ts +5 -0
  151. package/dist/types/utility/MockRouter/index.d.ts +2 -0
  152. package/dist/types/utility/StorybookPanel/index.d.ts +7 -0
  153. package/dist/types/utility/TestChangeHandler/index.d.ts +8 -0
  154. package/dist/types/utility/create-app.d.ts +4 -0
  155. package/dist/types/utility/interfaces.d.ts +72 -0
  156. package/dist/types/utility/prop-types.d.ts +40 -0
  157. package/docs/guides/01-installation.story.mdx +33 -0
  158. package/docs/guides/02-configuration.story.mdx +80 -0
  159. package/docs/guides/03-pages.story.mdx +18 -0
  160. package/docs/guides/04-integration.story.mdx +33 -0
  161. package/docs/guides/a11y.story.mdx +7 -0
  162. package/docs/guides/theming.story.mdx +7 -0
  163. package/docs/introduction.story.mdx +17 -0
  164. package/jest.config.js +19 -0
  165. package/package.json +101 -0
  166. package/postcss.config.js +3 -0
  167. package/rollup.config.js +36 -0
  168. package/scripts/create-exports.js +74 -0
  169. package/scripts/update-license.js +8 -0
  170. package/squarezero.config.js +5 -0
  171. package/src/components/Alert/Alert.module.css +50 -0
  172. package/src/components/Alert/Alert.spec.tsx +63 -0
  173. package/src/components/Alert/Alert.story.tsx +23 -0
  174. package/src/components/Alert/index.tsx +67 -0
  175. package/src/components/Allow/Allow.spec.tsx +37 -0
  176. package/src/components/Allow/index.tsx +42 -0
  177. package/src/components/App/App.module.css +22 -0
  178. package/src/components/App/App.spec.tsx +128 -0
  179. package/src/components/App/index.tsx +108 -0
  180. package/src/components/AutoSuggest/AutoSuggest.module.css +8 -0
  181. package/src/components/AutoSuggest/AutoSuggest.spec.tsx +211 -0
  182. package/src/components/AutoSuggest/AutoSuggest.story.tsx +30 -0
  183. package/src/components/AutoSuggest/index.tsx +216 -0
  184. package/src/components/Button/Button.module.css +95 -0
  185. package/src/components/Button/Button.spec.tsx +69 -0
  186. package/src/components/Button/Button.story.tsx +39 -0
  187. package/src/components/Button/index.tsx +99 -0
  188. package/src/components/CalendarInput/CalendarInput.module.css +8 -0
  189. package/src/components/CalendarInput/CalendarInput.spec.tsx +206 -0
  190. package/src/components/CalendarInput/CalendarInput.story.tsx +62 -0
  191. package/src/components/CalendarInput/index.tsx +122 -0
  192. package/src/components/CheckboxList/CheckboxList.spec.tsx +83 -0
  193. package/src/components/CheckboxList/index.tsx +53 -0
  194. package/src/components/ConnectedDropdown/index.tsx +56 -0
  195. package/src/components/ConnectedList/index.tsx +15 -0
  196. package/src/components/ConnectedScene/index.tsx +95 -0
  197. package/src/components/ConnectedTable/index.tsx +17 -0
  198. package/src/components/ContentBlock/ContentBlock.module.css +8 -0
  199. package/src/components/ContentBlock/ContentBlock.spec.tsx +15 -0
  200. package/src/components/ContentBlock/index.tsx +16 -0
  201. package/src/components/DateInput/DateInput.module.css +15 -0
  202. package/src/components/DateInput/DateInput.spec.tsx +91 -0
  203. package/src/components/DateInput/index.tsx +149 -0
  204. package/src/components/Document/index.tsx +20 -0
  205. package/src/components/Dropdown/Dropdown.module.css +8 -0
  206. package/src/components/Dropdown/Dropdown.spec.tsx +286 -0
  207. package/src/components/Dropdown/Dropdown.story.tsx +53 -0
  208. package/src/components/Dropdown/index.tsx +224 -0
  209. package/src/components/Fieldset/Fieldset.spec.tsx +22 -0
  210. package/src/components/Fieldset/Fieldset.story.tsx +21 -0
  211. package/src/components/Fieldset/index.tsx +30 -0
  212. package/src/components/FileInput/FileInput.module.css +18 -0
  213. package/src/components/FileInput/FileInput.spec.tsx +42 -0
  214. package/src/components/FileInput/FileInput.story.tsx +6 -0
  215. package/src/components/FileInput/index.tsx +72 -0
  216. package/src/components/FilterLink/FilterLink.module.css +9 -0
  217. package/src/components/FilterLink/FilterLink.spec.tsx +20 -0
  218. package/src/components/FilterLink/index.tsx +31 -0
  219. package/src/components/Form/Form.spec.tsx +68 -0
  220. package/src/components/Form/index.tsx +87 -0
  221. package/src/components/FormActions/FormActions.spec.tsx +10 -0
  222. package/src/components/FormActions/FormActions.story.tsx +23 -0
  223. package/src/components/FormActions/index.tsx +31 -0
  224. package/src/components/FormField/FormField.module.css +71 -0
  225. package/src/components/FormField/FormField.spec.tsx +137 -0
  226. package/src/components/FormField/FormField.story.tsx +22 -0
  227. package/src/components/FormField/index.tsx +162 -0
  228. package/src/components/FormRepeater/FormRepeater.module.css +3 -0
  229. package/src/components/FormRepeater/FormRepeater.spec.tsx +127 -0
  230. package/src/components/FormRepeater/index.tsx +118 -0
  231. package/src/components/ImageInput/ImageInput.module.css +74 -0
  232. package/src/components/ImageInput/ImageInput.spec.tsx +45 -0
  233. package/src/components/ImageInput/ImageInput.story.tsx +6 -0
  234. package/src/components/ImageInput/index.tsx +91 -0
  235. package/src/components/InfoPanel/InfoPanel.module.css +18 -0
  236. package/src/components/InfoPanel/InfoPanel.spec.tsx +15 -0
  237. package/src/components/InfoPanel/InfoPanel.story.tsx +32 -0
  238. package/src/components/InfoPanel/index.tsx +25 -0
  239. package/src/components/Link/Link.spec.tsx +62 -0
  240. package/src/components/Link/__mocks__/index.tsx +24 -0
  241. package/src/components/Link/index.tsx +51 -0
  242. package/src/components/List/List.module.css +9 -0
  243. package/src/components/List/List.spec.tsx +311 -0
  244. package/src/components/List/List.story.tsx +92 -0
  245. package/src/components/List/index.tsx +79 -0
  246. package/src/components/ListActions/ListActions.spec.tsx +10 -0
  247. package/src/components/ListActions/ListActions.story.tsx +6 -0
  248. package/src/components/ListActions/index.tsx +31 -0
  249. package/src/components/LoginForm/LoginForm.module.css +21 -0
  250. package/src/components/LoginForm/LoginForm.spec.tsx +63 -0
  251. package/src/components/LoginForm/index.tsx +102 -0
  252. package/src/components/Message/Message.module.css +14 -0
  253. package/src/components/Message/Message.spec.tsx +20 -0
  254. package/src/components/Message/index.tsx +27 -0
  255. package/src/components/ModalActions/ModalActions.module.css +5 -0
  256. package/src/components/ModalActions/ModalActions.spec.tsx +53 -0
  257. package/src/components/ModalActions/ModalActions.story.tsx +6 -0
  258. package/src/components/ModalActions/index.tsx +47 -0
  259. package/src/components/MoneyInput/MoneyInput.spec.tsx +17 -0
  260. package/src/components/MoneyInput/MoneyInput.story.tsx +6 -0
  261. package/src/components/MoneyInput/index.tsx +16 -0
  262. package/src/components/PasswordForm/PasswordForm.module.css +21 -0
  263. package/src/components/PasswordForm/index.tsx +94 -0
  264. package/src/components/PasswordInput/PasswordInput.module.css +23 -0
  265. package/src/components/PasswordInput/PasswordInput.spec.tsx +31 -0
  266. package/src/components/PasswordInput/PasswordInput.story.tsx +16 -0
  267. package/src/components/PasswordInput/index.tsx +27 -0
  268. package/src/components/RadioList/RadioList.spec.tsx +45 -0
  269. package/src/components/RadioList/index.tsx +10 -0
  270. package/src/components/Scene/Scene.spec.tsx +123 -0
  271. package/src/components/Scene/Scene.story.tsx +6 -0
  272. package/src/components/Scene/index.tsx +58 -0
  273. package/src/components/SummaryList/SummaryList.module.css +16 -0
  274. package/src/components/SummaryList/SummaryList.spec.tsx +77 -0
  275. package/src/components/SummaryList/SummaryList.story.tsx +11 -0
  276. package/src/components/SummaryList/index.tsx +37 -0
  277. package/src/components/Switch/Switch.module.css +86 -0
  278. package/src/components/Switch/Switch.spec.tsx +64 -0
  279. package/src/components/Switch/index.tsx +85 -0
  280. package/src/components/Table/Table.module.css +14 -0
  281. package/src/components/Table/Table.spec.tsx +128 -0
  282. package/src/components/Table/Table.story.tsx +101 -0
  283. package/src/components/Table/index.tsx +114 -0
  284. package/src/components/Tag/Tag.module.css +37 -0
  285. package/src/components/Tag/Tag.spec.tsx +10 -0
  286. package/src/components/Tag/Tag.story.tsx +55 -0
  287. package/src/components/Tag/index.tsx +27 -0
  288. package/src/components/TextArea/TextArea.module.css +23 -0
  289. package/src/components/TextArea/TextArea.spec.tsx +77 -0
  290. package/src/components/TextArea/index.tsx +59 -0
  291. package/src/components/TextInput/TextInput.module.css +57 -0
  292. package/src/components/TextInput/TextInput.spec.tsx +134 -0
  293. package/src/components/TextInput/TextInput.story.tsx +24 -0
  294. package/src/components/TextInput/index.tsx +146 -0
  295. package/src/components/WebsiteInput/WebsiteInput.spec.tsx +17 -0
  296. package/src/components/WebsiteInput/index.tsx +16 -0
  297. package/src/components/WeekCalendar/WeekCalendar.module.css +19 -0
  298. package/src/components/WeekCalendar/index.tsx +80 -0
  299. package/src/core/AppHeader/index.tsx +23 -0
  300. package/src/core/AppLogo/AppLogo.module.css +19 -0
  301. package/src/core/AppLogo/index.tsx +33 -0
  302. package/src/core/AppLogoImage/index.tsx +19 -0
  303. package/src/core/AppLogoPlaceholder/index.tsx +26 -0
  304. package/src/core/Assistive/Assistive.module.css +10 -0
  305. package/src/core/Assistive/index.tsx +18 -0
  306. package/src/core/Banner/Banner.module.css +36 -0
  307. package/src/core/Banner/index.tsx +25 -0
  308. package/src/core/BuildModal/index.tsx +119 -0
  309. package/src/core/Calendar/index.tsx +116 -0
  310. package/src/core/CalendarDay/CalendarDay.module.css +61 -0
  311. package/src/core/CalendarDay/index.tsx +82 -0
  312. package/src/core/CalendarMonth/CalendarMonth.module.css +13 -0
  313. package/src/core/CalendarMonth/index.tsx +101 -0
  314. package/src/core/CalendarNavigation/CalendarNavigation.module.css +26 -0
  315. package/src/core/CalendarNavigation/index.tsx +56 -0
  316. package/src/core/CalendarWeek/index.tsx +95 -0
  317. package/src/core/ChkRad/ChkRad.module.css +31 -0
  318. package/src/core/ChkRad/ChkRad.spec.tsx +72 -0
  319. package/src/core/ChkRad/index.tsx +80 -0
  320. package/src/core/ChkRadIcon/ChkRadIcon.module.css +28 -0
  321. package/src/core/ChkRadIcon/index.tsx +33 -0
  322. package/src/core/ChkRadList/ChkRadList.module.css +10 -0
  323. package/src/core/ChkRadList/index.tsx +85 -0
  324. package/src/core/CloseButton/CloseButton.spec.tsx +36 -0
  325. package/src/core/CloseButton/index.tsx +31 -0
  326. package/src/core/ConfirmModal/ConfirmModal.spec.tsx +88 -0
  327. package/src/core/ConfirmModal/index.tsx +51 -0
  328. package/src/core/ConnectedRepeater/index.tsx +248 -0
  329. package/src/core/ConnectedRepeaterComponent/index.tsx +66 -0
  330. package/src/core/Container/Container.module.css +12 -0
  331. package/src/core/Container/index.tsx +35 -0
  332. package/src/core/DropdownPanel/DropdownPanel.module.css +68 -0
  333. package/src/core/DropdownPanel/index.tsx +92 -0
  334. package/src/core/EmptyMessage/EmptyMessage.module.css +18 -0
  335. package/src/core/EmptyMessage/index.tsx +31 -0
  336. package/src/core/ErrorBoundary/ErrorBoundary.spec.tsx +33 -0
  337. package/src/core/ErrorBoundary/index.tsx +42 -0
  338. package/src/core/ErrorMessage/ErrorMessage.module.css +25 -0
  339. package/src/core/ErrorMessage/ErrorMessage.spec.tsx +31 -0
  340. package/src/core/ErrorMessage/index.tsx +37 -0
  341. package/src/core/FilterItem/FilterItem.module.css +104 -0
  342. package/src/core/FilterItem/index.tsx +164 -0
  343. package/src/core/Filters/Filters.module.css +86 -0
  344. package/src/core/Filters/Filters.spec.tsx +533 -0
  345. package/src/core/Filters/index.tsx +158 -0
  346. package/src/core/FixedActions/FixedActions.module.css +24 -0
  347. package/src/core/FixedActions/index.tsx +52 -0
  348. package/src/core/FormError/FormError.module.css +7 -0
  349. package/src/core/FormError/index.tsx +18 -0
  350. package/src/core/FormLabel/FormLabel.module.css +15 -0
  351. package/src/core/FormLabel/index.tsx +25 -0
  352. package/src/core/FormLegend/FormLegend.module.css +13 -0
  353. package/src/core/FormLegend/index.tsx +18 -0
  354. package/src/core/Header/Header.module.css +35 -0
  355. package/src/core/Header/index.tsx +37 -0
  356. package/src/core/Icon/Icon.spec.tsx +31 -0
  357. package/src/core/Icon/index.tsx +64 -0
  358. package/src/core/IconButton/Icon/Icon.spec.tsx +31 -0
  359. package/src/core/IconButton/Icon/index.tsx +64 -0
  360. package/src/core/IconButton/IconButton.module.css +32 -0
  361. package/src/core/IconButton/index.tsx +55 -0
  362. package/src/core/InputPanel/InputPanel.module.css +70 -0
  363. package/src/core/InputPanel/index.tsx +28 -0
  364. package/src/core/ListItem/ListItem.module.css +28 -0
  365. package/src/core/ListItem/ListItem.story.tsx +28 -0
  366. package/src/core/ListItem/index.tsx +99 -0
  367. package/src/core/ListItemAction/ListItemAction.module.css +28 -0
  368. package/src/core/ListItemAction/index.tsx +30 -0
  369. package/src/core/ListItemActions/ListItemActions.module.css +94 -0
  370. package/src/core/ListItemActions/index.tsx +55 -0
  371. package/src/core/ListItemMetaItem/ListItemMetaItem.module.css +18 -0
  372. package/src/core/ListItemMetaItem/index.tsx +54 -0
  373. package/src/core/ListItemTitle/ListItemTitle.module.css +14 -0
  374. package/src/core/ListItemTitle/ListItemTitle.spec.tsx +33 -0
  375. package/src/core/ListItemTitle/index.tsx +72 -0
  376. package/src/core/Loader/Loader.module.css +57 -0
  377. package/src/core/Loader/Loader.story.tsx +8 -0
  378. package/src/core/Loader/index.tsx +27 -0
  379. package/src/core/MeActions/MeActions.module.css +45 -0
  380. package/src/core/MeActions/index.tsx +46 -0
  381. package/src/core/MePanel/MePanel.module.css +75 -0
  382. package/src/core/MePanel/index.tsx +45 -0
  383. package/src/core/Modal/Modal.module.css +84 -0
  384. package/src/core/Modal/Modal.spec.tsx +51 -0
  385. package/src/core/Modal/index.tsx +66 -0
  386. package/src/core/Navigation/Navigation.module.css +83 -0
  387. package/src/core/Navigation/Navigation.spec.tsx +101 -0
  388. package/src/core/Navigation/index.tsx +109 -0
  389. package/src/core/NavigationDivider/NavigationDivider.module.css +18 -0
  390. package/src/core/NavigationDivider/index.tsx +13 -0
  391. package/src/core/NavigationItem/NavigationItem.module.css +51 -0
  392. package/src/core/NavigationItem/index.tsx +59 -0
  393. package/src/core/Pagination/Pagination.module.css +15 -0
  394. package/src/core/Pagination/index.tsx +100 -0
  395. package/src/core/PaginationItem/PaginationItem.module.css +33 -0
  396. package/src/core/PaginationItem/index.tsx +46 -0
  397. package/src/core/Panel/Panel.module.css +15 -0
  398. package/src/core/Panel/index.tsx +31 -0
  399. package/src/core/RadialProgress/RadialProgress.module.css +78 -0
  400. package/src/core/RadialProgress/index.tsx +52 -0
  401. package/src/core/StaticTextInput/StaticTextInput.module.css +79 -0
  402. package/src/core/StaticTextInput/StaticTextInput.spec.tsx +133 -0
  403. package/src/core/StaticTextInput/index.tsx +114 -0
  404. package/src/core/Styled/Styled.spec.tsx +38 -0
  405. package/src/core/Styled/Styled.story.tsx +10 -0
  406. package/src/core/Styled/index.tsx +62 -0
  407. package/src/core/SummaryListItem/SummaryListItem.module.css +28 -0
  408. package/src/core/SummaryListItem/index.tsx +60 -0
  409. package/src/core/TableActionsCell/TableActionsCell.module.css +3 -0
  410. package/src/core/TableActionsCell/index.tsx +37 -0
  411. package/src/core/TableCell/TableCell.module.css +16 -0
  412. package/src/core/TableCell/index.tsx +39 -0
  413. package/src/core/TableHead/TableHead.module.css +12 -0
  414. package/src/core/TableHead/index.tsx +48 -0
  415. package/src/core/TableRow/index.tsx +64 -0
  416. package/src/core/Tabs/Tabs.module.css +50 -0
  417. package/src/core/Tabs/index.tsx +94 -0
  418. package/src/core/TextInputAncillary/TextInputAncillary.module.css +64 -0
  419. package/src/core/TextInputAncillary/index.tsx +72 -0
  420. package/src/core/Toast/Toast.module.css +55 -0
  421. package/src/core/Toast/Toast.spec.tsx +78 -0
  422. package/src/core/Toast/index.tsx +81 -0
  423. package/src/core/WeekCalendarDay/WeekCalendarDay.module.css +32 -0
  424. package/src/core/WeekCalendarDay/index.tsx +68 -0
  425. package/src/filters/BooleanFilter/index.tsx +46 -0
  426. package/src/filters/DateFilter/index.tsx +36 -0
  427. package/src/filters/DropdownFilter/index.tsx +53 -0
  428. package/src/filters/QuickDateFilter/index.tsx +74 -0
  429. package/src/filters/interfaces.ts +40 -0
  430. package/src/hooks/useAccessiblePanel.spec.tsx +88 -0
  431. package/src/hooks/useAccessiblePanel.ts +74 -0
  432. package/src/hooks/useAppContext.ts +77 -0
  433. package/src/hooks/useClickOutside.ts +49 -0
  434. package/src/hooks/useConnectedList.ts +26 -0
  435. package/src/hooks/useFilters.ts +26 -0
  436. package/src/hooks/useForm.spec.ts +126 -0
  437. package/src/hooks/useForm.ts +99 -0
  438. package/src/hooks/useFormData.spec.ts +40 -0
  439. package/src/hooks/useFormData.ts +27 -0
  440. package/src/hooks/useLayout.spec.ts +55 -0
  441. package/src/hooks/useLayout.ts +29 -0
  442. package/src/hooks/useModal.spec.tsx +63 -0
  443. package/src/hooks/useModal.ts +60 -0
  444. package/src/hooks/useVariant.spec.ts +14 -0
  445. package/src/hooks/useVariant.ts +34 -0
  446. package/src/index.ts +194 -0
  447. package/src/scenes/Error404Scene.tsx +5 -0
  448. package/src/services/BuildService.spec.ts +56 -0
  449. package/src/services/BuildService.ts +34 -0
  450. package/src/services/ConfirmService.ts +21 -0
  451. package/src/services/DateService.spec.ts +87 -0
  452. package/src/services/DateService.ts +137 -0
  453. package/src/services/DownloadService.spec.ts +29 -0
  454. package/src/services/DownloadService.ts +14 -0
  455. package/src/services/FilterComponentService.tsx +46 -0
  456. package/src/services/FilterService.spec.ts +87 -0
  457. package/src/services/FilterService.ts +58 -0
  458. package/src/services/FormatService.spec.ts +83 -0
  459. package/src/services/FormatService.ts +55 -0
  460. package/src/services/ToastService.spec.ts +44 -0
  461. package/src/services/ToastService.ts +19 -0
  462. package/src/styles/layout.css +64 -0
  463. package/src/styles/variables.css +85 -0
  464. package/src/typings.d.ts +4 -0
  465. package/src/utility/MockRouter/index.ts +45 -0
  466. package/src/utility/StorybookPanel/StorybookPanel.module.css +9 -0
  467. package/src/utility/StorybookPanel/index.tsx +25 -0
  468. package/src/utility/TestChangeHandler/TestChangeHandler.module.css +7 -0
  469. package/src/utility/TestChangeHandler/TestChangeHandler.spec.tsx +24 -0
  470. package/src/utility/TestChangeHandler/index.tsx +54 -0
  471. package/src/utility/create-app.tsx +29 -0
  472. package/src/utility/interfaces.ts +119 -0
  473. package/src/utility/prop-types.ts +67 -0
  474. package/tests/setupFilesAfterEnv.js +10 -0
  475. package/tsconfig.json +26 -0
  476. package/tsconfig.types.json +9 -0
@@ -0,0 +1,80 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks';
2
+
3
+ <Meta title="Guides/Configuration" />
4
+
5
+ # Configuration
6
+
7
+ The config file is located at `src/config/index.js`. Below is a full list of every configuration option available:
8
+
9
+ ## auth
10
+
11
+ ```jsx
12
+ auth: {
13
+ identifier?: string;
14
+ identifierLabel?: string;
15
+ tfa?: boolean;
16
+ } | null;
17
+ ```
18
+
19
+ By default, the login form uses a field name of `username` for the identifier. However, there might be situations where you would want to use `email` or something else. In that instance, you can set `auth.identifier` (the field name) and `auth.identifierLabel` (the field label) to set an alternative.
20
+
21
+ `tfa` (set to false by default) defines whether or not your backend API supports two-factor authentication.
22
+
23
+ ## Logo
24
+
25
+ ```jsx
26
+ Logo: React.ComponentType<{ isReverse?: boolean }> | null;
27
+ ```
28
+
29
+ If not null, `Logo` is a React component that returns an image. It has only one prop - `isReverse`. If this is set to true, the component should return a white image. This is used on the login and password reset forms. When `isReverse` is set to false, the component should return a dark image, which is used in the top corner of the internal pages. In both instances, the logo sits on top of the colour defined in the `style.brand` configuration option.
30
+
31
+ ## name
32
+
33
+ ```jsx
34
+ name: string;
35
+ ```
36
+
37
+ The name of the site. This is the only config option that is required, and is used in the page titles.
38
+
39
+ ## navigation
40
+
41
+ ```
42
+ navigation: (NavigationObject | string)[];
43
+ ```
44
+
45
+ An array of items that will be in the primary navigation of the site. The item can either be a ‘-’, in which case a divider will be rendered, or a `NavigationObject` which is defined as:
46
+
47
+ ```
48
+ NavigationObject {
49
+ label: string;
50
+ to?: string | null;
51
+ onClick?: MouseEventHandler<HTMLAnchorElement | HTMLButtonElement>;
52
+ permission?: string;
53
+ }
54
+ ```
55
+
56
+ Technically the only thing a `NavigationObject` requires is a `label`, which will be the text that is displayed on the link. The object will then need one of two things - a `to` value, which will point to the URL you would like the link to go, or a `onClick` value, which will define what function is triggered when the link is clicked. It is entirely possible to include both of these options.
57
+
58
+ `permission` controls which admin user can or can’t see the particular object. Permissions are explained in more detail on the [API Integration page](/story/guides-integration-with-api--page).
59
+
60
+ ## paths
61
+
62
+ ```
63
+ paths: { api?: string; app?: string };
64
+ ```
65
+
66
+ The `paths.api` defines where your backend API is located. As you can see from the config file, by default the API path is set to read from an ‘env.js’ file included in the root. This file is excluded from git, and allows you to define different backend URLs for the same admin panel in different environments. I.e. local, staging, and production versions can all point to different backend URLs.
67
+
68
+ The `paths.app` defines where your application itself is located, assuming it is not at the root of a domain. This can usually be omitted but if, for example, you would like your application to be hosted at https://example.com/admin/, you would define `paths.app` as `admin`. This would ensure all links and redirects within the app go to the right place.
69
+
70
+ ## style
71
+
72
+ ```
73
+ style: { brand?: string; layout?: string } | null;
74
+ ```
75
+
76
+ The `style.brand` value is simply a hexcode which defines the background colour for the logos throughout the site.
77
+
78
+ `style.layout` can either be omitted, or be defined as ‘topbar’. If omitted, the layout of the application will appear in a traditional dashboard way - with the navigation running vertically along the left hand side of the page, and the content to the right. If, however, it is defined as ‘topbar’, the navigation runs horizontally across the top of the page.
79
+
80
+ More style options may be added in future versions. However, it is an important tenet of Square Zero Admin that it does not offer too much customisation, in order to allow developers to focus on building pages rather than concerning themselves with style decisions.
@@ -0,0 +1,18 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks';
2
+
3
+ <Meta title="Guides/Pages & Routing" />
4
+
5
+ # Pages & Routing
6
+
7
+ As Square Zero Admin is built on top of Next.js, it uses the same method for routing. You can read the [full documentation for Next.js routing](https://nextjs.org/docs/basic-features/pages) here, but in essence, any `.tsx` file you place in the `src/pages` folder will become a route. For example, a file at `src/pages/lorem.tsx` will be accessible at `/lorem`. The most basic admin page would look something like this:
8
+
9
+ ```
10
+ import React from 'react';
11
+ import { Scene } from 'squarezero-admin';
12
+
13
+ const ExampleScene = () => (
14
+ <Scene title="Example Scene">Here is an example of some content</Scene>
15
+ );
16
+
17
+ export default ExampleScene;
18
+ ```
@@ -0,0 +1,33 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks';
2
+
3
+ <Meta title="Guides/Integration with API" />
4
+
5
+ # Integration with API
6
+
7
+ Although not required, in almost all circumstances Square Zero Admin is going to be interacting with a backend API. This guide explains what requests are sent to the API, and what responses are expected back. This should enable you to make sure your backend API will integrate smoothly with your admin system.
8
+
9
+ *Note: For simplicity, Square Zero Admin's request and response expectations are kept very opinionated, without much room for customisation. However, if this approach is deemed to restrictive to be useful for many projects, some more customisation options will be made available.*
10
+
11
+ ## Authentication
12
+
13
+ Square Zero Admin makes use of JSON Web Tokens (JWT) for Authentication. JWT are an open, industry standard (RFC 7519) method for representing claims securely between two parties. When an admin user successfully logs in, the backend should pass a token back in the response. Square Zero Admin then stores this, and passes it up as an `Authorization` header in the next request. The backend should then check this header, ensure the token is valid, and only then respond with the requested data. The response should also contain an `Authorization` header with a new token, which Square Zero Admin will store and use for the next request, and so on.
14
+
15
+ ### Login
16
+
17
+ In order to login, Square Zero Admin will expect to be able to `POST` to `/tokens` with the following parameters:
18
+
19
+ ```jsx
20
+ {"username": "lorem", "password": "ipsum"}
21
+ ```
22
+
23
+ If the user's details are correct, the backend should respond with a status of 200, and with a newly generated JWT:
24
+
25
+ ```jsx
26
+ { "token": "areallylongstringofcharacters" }
27
+ ```
28
+
29
+ If they are incorrect, the backend should respond with a status of 422, and an object of errors:
30
+
31
+ ```jsx
32
+ { "errors": { "email": "An error message" } }
33
+ ```
@@ -0,0 +1,7 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks';
2
+
3
+ <Meta title="Guides/Accessibility" />
4
+
5
+ # Accessibility
6
+
7
+ Coming soon...
@@ -0,0 +1,7 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks';
2
+
3
+ <Meta title="Guides/Theming" />
4
+
5
+ # Theming
6
+
7
+ Coming soon...
@@ -0,0 +1,17 @@
1
+ import { Meta } from '@storybook/addon-docs/blocks';
2
+
3
+ <Meta title="Overview/Introduction" />
4
+
5
+ <svg height="40" width="40"><rect fill="red" x="0" y="0" height="40" width="40" /></svg>
6
+
7
+ ---
8
+
9
+ # Introduction
10
+
11
+ Square Zero Admin is a collection of opinionated components, hooks, services and utilities that lets you very quickly build admin systems in React. This guide will help you setup an admin system, as well as acting as a comprehensive reference for all the elements available in the system.
12
+
13
+ [Click here to get started](/story/guides-installation--page)
14
+
15
+ ## A Note on Beta
16
+
17
+ Currently, the latest version of Square Zero Admin is `beta`. Although the package is well tested, and used on a number of production sites, with the current lack of documentation it would be unfair to describe it as ‘production-ready’, unless being used by the developers of the package. Work on complete documentation is underway and a true version `1.0.0` should be available in the near future.
package/jest.config.js ADDED
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ globals: {
3
+ 'ts-jest': { isolatedModules: true },
4
+ },
5
+ moduleNameMapper: {
6
+ '@components/(.*)': '<rootDir>/src/components/$1',
7
+ '@core/(.*)': '<rootDir>/src/core/$1',
8
+ '@filters/(.*)': '<rootDir>/src/filters/$1',
9
+ '@hooks/(.*)': '<rootDir>/src/hooks/$1',
10
+ '@services/(.*)': '<rootDir>/src/services/$1',
11
+ '@utility/(.*)': '<rootDir>/src/utility/$1',
12
+ '\\.css$': 'identity-obj-proxy',
13
+ 'modern-normalize': 'identity-obj-proxy',
14
+ },
15
+ preset: 'ts-jest',
16
+ setupFilesAfterEnv: ['<rootDir>/tests/setupFilesAfterEnv.js'],
17
+ testEnvironment: 'jsdom',
18
+ testMatch: ['**/?(*.)+(spec).ts?(x)'],
19
+ };
package/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "@sqrzro/admin",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Useful components, services, and tools for React projects",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/types/index.d.ts",
7
+ "module": "dist/index.js",
8
+ "exports": {
9
+ ".": "./dist/index.js",
10
+ "./index.css": "./dist/index.css"
11
+ },
12
+ "author": "Richard Carter",
13
+ "license": "ISC",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/sqrzro/squarezero-admin"
17
+ },
18
+ "scripts": {
19
+ "build:app": "rollup -c",
20
+ "build:docs": "build-storybook",
21
+ "build:license": "node ./scripts/update-license",
22
+ "build:exports": "node ./scripts/create-exports",
23
+ "build:types": "tsc --emitDeclarationOnly --project tsconfig.types.json && tsc-alias -p tsconfig.types.json",
24
+ "build": "yarn run build:exports && yarn run build:app && yarn run build:types && yarn run build:license",
25
+ "dev": "yarn run build:app --watch",
26
+ "docs": "start-storybook -p 6006",
27
+ "lint:css": "stylelint \"src/**/*.css\"",
28
+ "lint:ts": "eslint \"src/**/*.ts\" \"src/**/*.tsx\"",
29
+ "lint": "tsc --noEmit && yarn run lint:ts && yarn run lint:css",
30
+ "prepublish": "yarn run build",
31
+ "prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
32
+ "start": "yarn run dev",
33
+ "test": "jest --runInBand"
34
+ },
35
+ "dependencies": {
36
+ "@heroicons/react": "^1.0.4",
37
+ "@sqrzro/utility": "^1.0.1",
38
+ "classnames": "^2.3.1",
39
+ "date-fns": "^2.25.0",
40
+ "deepmerge": "^4.2.2",
41
+ "modern-normalize": "^1.1.0",
42
+ "next": "^12.0.8",
43
+ "prop-types": "^15.7.2",
44
+ "regenerator-runtime": "^0.13.9",
45
+ "use-deep-compare-effect": "^1.8.0"
46
+ },
47
+ "devDependencies": {
48
+ "@babel/core": "^7.15.8",
49
+ "@babel/plugin-proposal-class-properties": "^7.14.5",
50
+ "@babel/preset-env": "^7.15.8",
51
+ "@babel/preset-react": "^7.14.5",
52
+ "@rollup/plugin-node-resolve": "^13.0.5",
53
+ "@rollup/plugin-typescript": "^8.2.5",
54
+ "@sqrzro/eslint-plugin": "^1.1.0",
55
+ "@storybook/addon-actions": "^6.4.3",
56
+ "@storybook/addon-docs": "^6.4.3",
57
+ "@storybook/addon-essentials": "^6.4.3",
58
+ "@storybook/addon-links": "^6.4.3",
59
+ "@storybook/addon-postcss": "^2.0.0",
60
+ "@storybook/builder-webpack5": "^6.4.3",
61
+ "@storybook/manager-webpack5": "^6.4.3",
62
+ "@storybook/react": "^6.4.3",
63
+ "@storybook/theming": "^6.4.13",
64
+ "@testing-library/dom": "^8.11.1",
65
+ "@testing-library/jest-dom": "^5.15.1",
66
+ "@testing-library/react": "^12.1.2",
67
+ "@testing-library/react-hooks": "^7.0.2",
68
+ "@testing-library/user-event": "^13.5.0",
69
+ "@types/airbnb-prop-types": "^2.13.2",
70
+ "@types/jest": "^27.0.2",
71
+ "@types/prop-types": "^15.7.4",
72
+ "autoprefixer": "^10.3.7",
73
+ "babel-loader": "^8.2.2",
74
+ "babel-plugin-module-resolver": "^4.1.0",
75
+ "cors": "^2.8.5",
76
+ "css-loader": "^6.4.0",
77
+ "eslint": "^8.10.0",
78
+ "identity-obj-proxy": "^3.0.0",
79
+ "jest": "^27.2.5",
80
+ "jest-fetch-mock": "^3.0.3",
81
+ "mockdate": "^3.0.5",
82
+ "npm-run-all": "^4.1.5",
83
+ "postcss": "^8.3.9",
84
+ "postcss-loader": "^6.1.1",
85
+ "postcss-preset-env": "^7.0.0",
86
+ "prettier": "^2.5.0",
87
+ "react": "^17.0.2",
88
+ "react-dom": "^17.0.2",
89
+ "rollup": "^2.58.0",
90
+ "rollup-plugin-postcss": "^4.0.1",
91
+ "storybook": "^6.4.3",
92
+ "style-loader": "^3.3.0",
93
+ "stylelint": "^13.13.1",
94
+ "stylelint-config-standard": "^22.0.0",
95
+ "ts-jest": "^27.0.5",
96
+ "tsc-alias": "^1.5.0",
97
+ "tslib": "^2.3.1",
98
+ "typescript": "^4.4.3",
99
+ "webpack": "^5.58.2"
100
+ }
101
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ plugins: [require('postcss-preset-env')({ importFrom: 'src/styles/variables.css', stage: 1 })],
3
+ };
@@ -0,0 +1,36 @@
1
+ import postcss from 'rollup-plugin-postcss';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import typescript from '@rollup/plugin-typescript';
4
+
5
+ const globals = {
6
+ '@heroicons/react': '@heroicons/react',
7
+ '@sqrzro/utility': '@sqrzro/utility',
8
+ classnames: 'classNames',
9
+ 'date-fns': 'dateFns',
10
+ deepmerge: 'deepmerge',
11
+ 'next/app': 'NextApp',
12
+ 'next/document': 'NextDocument',
13
+ 'next/head': 'NextHead',
14
+ 'next/link': 'NextLink',
15
+ 'next/router': 'NextRouter',
16
+ 'prop-types': 'PropTypes',
17
+ react: 'React',
18
+ 'react-router': 'react-router',
19
+ 'regenerator-runtime': 'regeneratorRuntime',
20
+ 'use-deep-compare-effect': 'useDeepCompareEffect',
21
+ };
22
+
23
+ const config = {
24
+ input: 'src/index.ts',
25
+ output: {
26
+ file: 'dist/index.js',
27
+ format: 'umd',
28
+ globals,
29
+ name: 'squarezero-admin',
30
+ sourcemap: true,
31
+ },
32
+ external: Object.keys(globals),
33
+ plugins: [resolve(), typescript(), postcss({ extract: true })],
34
+ };
35
+
36
+ export default config;
@@ -0,0 +1,74 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const exportStrings = [];
5
+
6
+ const filterMocksAndSpecs = (files) =>
7
+ files.filter((file) => !file.match(/__mocks__/u) && !file.match(/\.spec\./u));
8
+
9
+ /*
10
+ * Utility
11
+ * Services from `@sqrzro/utility` should be imported and then immeadiately exported, so users
12
+ * can just import everything from `squarezero-admin`, without having to worry about where it's
13
+ * actually come from
14
+ */
15
+
16
+ const utilities = ['ApiService', 'AuthService', 'EventService', 'StorageService'];
17
+
18
+ exportStrings.push(`export { ${utilities.join(', ')} } from '@sqrzro/utility';`);
19
+
20
+ // Components
21
+
22
+ const components = fs.readdirSync(path.resolve(__dirname, '../src/components'));
23
+
24
+ components.forEach((file) => {
25
+ exportStrings.push(`export * from './components/${file}';`);
26
+ exportStrings.push(`export { default as ${file} } from './components/${file}';`);
27
+ });
28
+
29
+ // Core (Types Only)
30
+
31
+ const core = fs.readdirSync(path.resolve(__dirname, '../src/core'));
32
+
33
+ core.forEach((file) => {
34
+ exportStrings.push(`export * from './core/${file}';`);
35
+ });
36
+
37
+ // Hooks
38
+
39
+ const hooks = fs.readdirSync(path.resolve(__dirname, '../src/hooks'));
40
+
41
+ filterMocksAndSpecs(hooks).forEach((file) => {
42
+ const name = file.replace(/\.ts$/u, '');
43
+ exportStrings.push(`export * from './hooks/${name}';`);
44
+ exportStrings.push(`export { default as ${name} } from './hooks/${name}';`);
45
+ });
46
+
47
+ // Services
48
+
49
+ const services = fs.readdirSync(path.resolve(__dirname, '../src/services'));
50
+
51
+ filterMocksAndSpecs(services).forEach((file) => {
52
+ const name = file.replace(/\.tsx?$/u, '');
53
+ exportStrings.push(`export * from './services/${name}';`);
54
+ exportStrings.push(`export { default as ${name} } from './services/${name}';`);
55
+ });
56
+
57
+ // Write
58
+
59
+ const allExportStrings = exportStrings.join('\n');
60
+ const content = [
61
+ '/*',
62
+ " * This file has been generated by 'scripts/create-exports'.",
63
+ ' * Any changes made directly to this file will be overwritten.',
64
+ ' */',
65
+ '',
66
+ "import 'regenerator-runtime/runtime.js';",
67
+ '',
68
+ "export * from './utility/interfaces';",
69
+ "export { default as createApp } from './utility/create-app';",
70
+ '',
71
+ allExportStrings,
72
+ ].join('\n');
73
+
74
+ fs.writeFileSync(path.resolve(__dirname, '../src/index.ts'), `${content}\n`);
@@ -0,0 +1,8 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const license = path.resolve(__dirname, '../LICENSE');
5
+ const content = fs.readFileSync(license, 'utf8');
6
+ const updated = content.replace(/^Copyright \d{4}/u, `Copyright ${new Date().getFullYear()}`);
7
+
8
+ fs.writeFileSync(license, updated);
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ template: 'react',
3
+ styles: 'postcss',
4
+ ts: true,
5
+ };
@@ -0,0 +1,50 @@
1
+ .root {
2
+ bottom: 0;
3
+ left: 0;
4
+ position: fixed;
5
+ right: 0;
6
+ top: 0;
7
+ z-index: 10;
8
+ }
9
+
10
+ .overlay {
11
+ background-color: var(--clr-grey900);
12
+ bottom: 0;
13
+ left: 0;
14
+ position: absolute;
15
+ right: 0;
16
+ top: 0;
17
+ }
18
+
19
+ .panel {
20
+ left: calc(50% - 30rem);
21
+ position: absolute;
22
+ top: 15%;
23
+ width: 60rem;
24
+ }
25
+
26
+ .title {
27
+ border-bottom: .1rem var(--clr-grey300) solid;
28
+ color: var(--clr-grey600);
29
+ font-size: var(--fs-lrg);
30
+ font-weight: var(--fw-bold);
31
+ line-height: 1;
32
+ margin-bottom: 3rem;
33
+ margin-left: -.2rem;
34
+ margin-top: -.5rem;
35
+ padding-bottom: 2rem;
36
+ }
37
+
38
+ .actions {
39
+ border-top: .1rem var(--clr-grey300) solid;
40
+ display: flex;
41
+ flex-direction: row-reverse;
42
+ margin-bottom: -1rem;
43
+ margin-top: 3rem;
44
+ padding-top: 2rem;
45
+
46
+ & > * {
47
+ margin-left: 1rem;
48
+ width: auto;
49
+ }
50
+ }
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+
5
+ import Alert from './index';
6
+
7
+ describe('Alert', () => {
8
+ it('should render', () => {
9
+ render(<Alert title="Lorem">Lorem</Alert>);
10
+ });
11
+
12
+ it('should render defaults', () => {
13
+ render(<Alert title="Lorem">Lorem</Alert>);
14
+
15
+ const alert = screen.getByRole('alert');
16
+ const heading = screen.getByRole('heading');
17
+ const buttons = screen.queryAllByRole('button');
18
+
19
+ expect(heading).toHaveClass('title');
20
+ expect(heading).toHaveTextContent(/^Lorem$/u);
21
+
22
+ expect(alert).toHaveTextContent('LoremLorem');
23
+ expect(buttons).toHaveLength(0);
24
+ });
25
+
26
+ it('should render variant', () => {
27
+ render(
28
+ <Alert title="Lorem" variant="primary">
29
+ Lorem
30
+ </Alert>
31
+ );
32
+
33
+ const heading = screen.getByRole('heading');
34
+ expect(heading).toHaveClass('title titlePrimary');
35
+ });
36
+
37
+ it('should render actions', () => {
38
+ const mockFn = jest.fn();
39
+ const actions = [
40
+ { label: 'Lorem', onClick: mockFn },
41
+ { label: 'Ipsum', onClick: mockFn, variant: 'secondary' as const },
42
+ ];
43
+
44
+ render(
45
+ <Alert actions={actions} title="Lorem">
46
+ Lorem
47
+ </Alert>
48
+ );
49
+
50
+ const buttons = screen.queryAllByRole('button');
51
+
52
+ expect(buttons).toHaveLength(2);
53
+
54
+ expect(buttons[0]).toHaveTextContent(/^Lorem$/u);
55
+
56
+ expect(mockFn).toHaveBeenCalledTimes(0);
57
+ userEvent.click(buttons[0]);
58
+ expect(mockFn).toHaveBeenCalledTimes(1);
59
+
60
+ expect(buttons[1]).toHaveTextContent(/^Ipsum$/u);
61
+ expect(buttons[1]).toHaveClass('root rootSecondary');
62
+ });
63
+ });
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+
3
+ import StorybookPanel from '@utility/StorybookPanel';
4
+
5
+ import Alert from './index';
6
+
7
+ export default { title: 'Components/Alert', component: Alert };
8
+
9
+ const mockActions = [{ label: 'Lorem Ipsum', onClick: (): null => null }];
10
+
11
+ export const Default = (): React.ReactElement => (
12
+ <StorybookPanel>
13
+ <Alert title="Lorem">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Alert>
14
+ </StorybookPanel>
15
+ );
16
+
17
+ export const WithActions = (): React.ReactElement => (
18
+ <StorybookPanel>
19
+ <Alert actions={mockActions} title="Lorem">
20
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit
21
+ </Alert>
22
+ </StorybookPanel>
23
+ );
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import PropTypes from 'prop-types';
4
+
5
+ import { ucwords } from '@sqrzro/utility';
6
+
7
+ import Button from '@components/Button';
8
+ import Panel from '@core/Panel';
9
+
10
+ import type { SimpleAction, StyleVariant } from '@utility/interfaces';
11
+
12
+ import styles from './Alert.module.css';
13
+
14
+ interface AlertProps {
15
+ actions?: SimpleAction[];
16
+ children: React.ReactNode;
17
+ title: string;
18
+ variant?: StyleVariant;
19
+ }
20
+
21
+ const Alert: React.FunctionComponent<AlertProps> = ({ actions, children, title, variant }) => (
22
+ <div className={styles.root}>
23
+ <div className={styles.overlay} />
24
+ <aside className={styles.panel} role="alert">
25
+ <Panel isPadded>
26
+ <h3
27
+ className={classNames(
28
+ styles.title,
29
+ variant && styles[`title${ucwords(variant)}`]
30
+ )}
31
+ role="heading"
32
+ >
33
+ {title}
34
+ </h3>
35
+ {children}
36
+ {actions?.length ? (
37
+ <footer className={styles.actions}>
38
+ {actions.map((action) => (
39
+ <Button
40
+ key={action.label}
41
+ isDisabled={action.isDisabled}
42
+ onClick={action.onClick}
43
+ variant={action.variant}
44
+ >
45
+ {action.label}
46
+ </Button>
47
+ ))}
48
+ </footer>
49
+ ) : null}
50
+ </Panel>
51
+ </aside>
52
+ </div>
53
+ );
54
+
55
+ Alert.propTypes = {
56
+ children: PropTypes.node.isRequired,
57
+ title: PropTypes.string.isRequired,
58
+ actions: PropTypes.arrayOf(
59
+ PropTypes.shape({
60
+ label: PropTypes.string.isRequired,
61
+ onClick: PropTypes.func.isRequired,
62
+ }).isRequired
63
+ ),
64
+ variant: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'danger']),
65
+ };
66
+
67
+ export default Alert;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+
4
+ import type { Config } from '@hooks/useAppContext';
5
+
6
+ import Allow from './index';
7
+
8
+ jest.mock(
9
+ '@hooks/useAppContext',
10
+ () => (): Config => ({
11
+ me: { name: 'Lorem', permissions: ['lorem'] },
12
+ name: 'Lorem',
13
+ navigation: [],
14
+ paths: {},
15
+ })
16
+ );
17
+
18
+ describe('Allow', () => {
19
+ it('should render', () => {
20
+ render(<Allow>Lorem</Allow>);
21
+ });
22
+
23
+ it('should render defaults', () => {
24
+ render(<Allow>Lorem</Allow>);
25
+ expect(screen.getByText(/^Lorem$/u)).toBeInTheDocument();
26
+ });
27
+
28
+ it('should render with no permission', () => {
29
+ render(<Allow permission="ipsum">Lorem</Allow>);
30
+ expect(screen.queryByText(/^Lorem$/u)).not.toBeInTheDocument();
31
+ });
32
+
33
+ it('should render with permission', () => {
34
+ render(<Allow permission="lorem">Lorem</Allow>);
35
+ expect(screen.getByText(/^Lorem$/u)).toBeInTheDocument();
36
+ });
37
+ });