@onehat/ui 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/ckeditor5/LICENSE.md +49 -0
  2. package/ckeditor5/README.md +68 -0
  3. package/ckeditor5/build/ckeditor.js +6 -0
  4. package/ckeditor5/build/ckeditor.js.map +1 -0
  5. package/ckeditor5/build/translations/af.js +1 -0
  6. package/ckeditor5/build/translations/ar.js +1 -0
  7. package/ckeditor5/build/translations/ast.js +1 -0
  8. package/ckeditor5/build/translations/az.js +1 -0
  9. package/ckeditor5/build/translations/bg.js +1 -0
  10. package/ckeditor5/build/translations/bn.js +1 -0
  11. package/ckeditor5/build/translations/bs.js +1 -0
  12. package/ckeditor5/build/translations/ca.js +1 -0
  13. package/ckeditor5/build/translations/cs.js +1 -0
  14. package/ckeditor5/build/translations/da.js +1 -0
  15. package/ckeditor5/build/translations/de-ch.js +1 -0
  16. package/ckeditor5/build/translations/de.js +1 -0
  17. package/ckeditor5/build/translations/el.js +1 -0
  18. package/ckeditor5/build/translations/en-au.js +1 -0
  19. package/ckeditor5/build/translations/en-gb.js +1 -0
  20. package/ckeditor5/build/translations/eo.js +1 -0
  21. package/ckeditor5/build/translations/es-co.js +1 -0
  22. package/ckeditor5/build/translations/es.js +1 -0
  23. package/ckeditor5/build/translations/et.js +1 -0
  24. package/ckeditor5/build/translations/eu.js +1 -0
  25. package/ckeditor5/build/translations/fa.js +1 -0
  26. package/ckeditor5/build/translations/fi.js +1 -0
  27. package/ckeditor5/build/translations/fr.js +1 -0
  28. package/ckeditor5/build/translations/gl.js +1 -0
  29. package/ckeditor5/build/translations/gu.js +1 -0
  30. package/ckeditor5/build/translations/he.js +1 -0
  31. package/ckeditor5/build/translations/hi.js +1 -0
  32. package/ckeditor5/build/translations/hr.js +1 -0
  33. package/ckeditor5/build/translations/hu.js +1 -0
  34. package/ckeditor5/build/translations/id.js +1 -0
  35. package/ckeditor5/build/translations/it.js +1 -0
  36. package/ckeditor5/build/translations/ja.js +1 -0
  37. package/ckeditor5/build/translations/jv.js +1 -0
  38. package/ckeditor5/build/translations/kk.js +1 -0
  39. package/ckeditor5/build/translations/km.js +1 -0
  40. package/ckeditor5/build/translations/kn.js +1 -0
  41. package/ckeditor5/build/translations/ko.js +1 -0
  42. package/ckeditor5/build/translations/ku.js +1 -0
  43. package/ckeditor5/build/translations/lt.js +1 -0
  44. package/ckeditor5/build/translations/lv.js +1 -0
  45. package/ckeditor5/build/translations/ms.js +1 -0
  46. package/ckeditor5/build/translations/nb.js +1 -0
  47. package/ckeditor5/build/translations/ne.js +1 -0
  48. package/ckeditor5/build/translations/nl.js +1 -0
  49. package/ckeditor5/build/translations/no.js +1 -0
  50. package/ckeditor5/build/translations/oc.js +1 -0
  51. package/ckeditor5/build/translations/pl.js +1 -0
  52. package/ckeditor5/build/translations/pt-br.js +1 -0
  53. package/ckeditor5/build/translations/pt.js +1 -0
  54. package/ckeditor5/build/translations/ro.js +1 -0
  55. package/ckeditor5/build/translations/ru.js +1 -0
  56. package/ckeditor5/build/translations/si.js +1 -0
  57. package/ckeditor5/build/translations/sk.js +1 -0
  58. package/ckeditor5/build/translations/sl.js +1 -0
  59. package/ckeditor5/build/translations/sq.js +1 -0
  60. package/ckeditor5/build/translations/sr-latn.js +1 -0
  61. package/ckeditor5/build/translations/sr.js +1 -0
  62. package/ckeditor5/build/translations/sv.js +1 -0
  63. package/ckeditor5/build/translations/th.js +1 -0
  64. package/ckeditor5/build/translations/tk.js +1 -0
  65. package/ckeditor5/build/translations/tr.js +1 -0
  66. package/ckeditor5/build/translations/tt.js +1 -0
  67. package/ckeditor5/build/translations/ug.js +1 -0
  68. package/ckeditor5/build/translations/uk.js +1 -0
  69. package/ckeditor5/build/translations/ur.js +1 -0
  70. package/ckeditor5/build/translations/uz.js +1 -0
  71. package/ckeditor5/build/translations/vi.js +1 -0
  72. package/ckeditor5/build/translations/zh-cn.js +1 -0
  73. package/ckeditor5/build/translations/zh.js +1 -0
  74. package/ckeditor5/package.json +46 -0
  75. package/ckeditor5/sample/index.html +130 -0
  76. package/ckeditor5/sample/styles.css +496 -0
  77. package/ckeditor5/src/ckeditor.js +138 -0
  78. package/ckeditor5/webpack.config.js +96 -0
  79. package/package.json +19 -23
  80. package/src/Components/Accordion/Accordion.js +144 -0
  81. package/src/Components/Blank.js +14 -0
  82. package/src/Components/Buttons/BackButton.js +16 -0
  83. package/src/Components/Buttons/CartButtonWithBadge.js +25 -0
  84. package/src/Components/Buttons/IconButton.js +42 -0
  85. package/src/Components/Container/Container.js +178 -0
  86. package/src/Components/Container/Splitter.js +61 -0
  87. package/src/Components/Filter/DateRange.js +99 -0
  88. package/src/Components/Filter/NumberRange.js +96 -0
  89. package/src/Components/Form/Field/CKEditor/CKEditor.js +62 -0
  90. package/src/Components/Form/Field/CKEditor/styles.css +503 -0
  91. package/src/Components/Form/Field/CKEditor.js +12 -0
  92. package/src/Components/Form/Field/CheckboxGroup/ArrayCheckboxGroup.js +13 -0
  93. package/src/Components/Form/Field/CheckboxGroup/CheckboxGroup.js +61 -0
  94. package/src/Components/Form/Field/Color.js +226 -0
  95. package/src/Components/Form/Field/Combo/ArrayCombo.js +15 -0
  96. package/src/Components/Form/Field/Combo/BooleanCombo.js +23 -0
  97. package/src/Components/Form/Field/Combo/Combo.js +504 -0
  98. package/src/Components/Form/Field/Combo/ComboEditor.js +22 -0
  99. package/src/Components/Form/Field/Combo/IntervalsCombo.js +18 -0
  100. package/src/Components/Form/Field/Combo/MonthsCombo.js +24 -0
  101. package/src/Components/Form/Field/Combo/PageSizeCombo.js +38 -0
  102. package/src/Components/Form/Field/Combo/Tag.js +12 -0
  103. package/src/Components/Form/Field/Combo/TimezonesCombo.js +432 -0
  104. package/src/Components/Form/Field/Combo/YearsCombo.js +35 -0
  105. package/src/Components/Form/Field/Date.js +370 -0
  106. package/src/Components/Form/Field/DisplayField.js +28 -0
  107. package/src/Components/Form/Field/Field.js +14 -0
  108. package/src/Components/Form/Field/File.js +218 -0
  109. package/src/Components/Form/Field/Input.js +96 -0
  110. package/src/Components/Form/Field/Number.js +151 -0
  111. package/src/Components/Form/Field/RadioGroup/ArrayRadioGroup.js +13 -0
  112. package/src/Components/Form/Field/RadioGroup/RadioGroup.js +62 -0
  113. package/src/Components/Form/Field/Tag.js +11 -0
  114. package/src/Components/Form/Field/Text.js +28 -0
  115. package/src/Components/Form/Field/TextArea.js +26 -0
  116. package/src/Components/Form/Field/Toggle.js +39 -0
  117. package/src/Components/Form/Field/datetime.css +5 -0
  118. package/src/Components/Form/FieldSet.js +64 -0
  119. package/src/Components/Form/FiltersForm.js +66 -0
  120. package/src/Components/Form/Form.js +535 -0
  121. package/src/Components/Form/Label.js +24 -0
  122. package/src/Components/Grid/Grid.js +877 -0
  123. package/src/Components/Grid/GridHeaderRow.js +455 -0
  124. package/src/Components/Grid/GridRow.js +134 -0
  125. package/src/Components/Grid/HeaderReorderHandle.js +29 -0
  126. package/src/Components/Grid/HeaderResizeHandle.js +29 -0
  127. package/src/Components/Grid/NoRecordsFound.js +43 -0
  128. package/src/Components/Grid/ReactGrid.js +468 -0
  129. package/src/Components/Grid/SenchaGrid.js +421 -0
  130. package/src/Components/Grid/reactgrid.css +6 -0
  131. package/src/Components/Hoc/withAlert.js +176 -0
  132. package/src/Components/Hoc/withBlank.js +12 -0
  133. package/src/Components/Hoc/withCollapsible.js +20 -0
  134. package/src/Components/Hoc/withContextMenu.js +127 -0
  135. package/src/Components/Hoc/withData.js +85 -0
  136. package/src/Components/Hoc/withDraggable.js +259 -0
  137. package/src/Components/Hoc/withEditor.js +160 -0
  138. package/src/Components/Hoc/withEvents.js +12 -0
  139. package/src/Components/Hoc/withFilters.js +456 -0
  140. package/src/Components/Hoc/withInlineEditor.js +119 -0
  141. package/src/Components/Hoc/withMultiSelection.js +16 -0
  142. package/src/Components/Hoc/withPresetButtons.js +239 -0
  143. package/src/Components/Hoc/withSelection.js +332 -0
  144. package/src/Components/Hoc/withTooltip.js +21 -0
  145. package/src/Components/Hoc/withValue.js +87 -0
  146. package/src/Components/Hoc/withWindowedEditor.js +51 -0
  147. package/src/Components/Icons/AddressBook.js +14 -0
  148. package/src/Components/Icons/Alt.js +17 -0
  149. package/src/Components/Icons/AngleLeft.js +18 -0
  150. package/src/Components/Icons/AngleRight.js +18 -0
  151. package/src/Components/Icons/AnglesLeft.js +18 -0
  152. package/src/Components/Icons/AnglesRight.js +18 -0
  153. package/src/Components/Icons/Asterisk.js +14 -0
  154. package/src/Components/Icons/Ban.js +18 -0
  155. package/src/Components/Icons/Bars.js +14 -0
  156. package/src/Components/Icons/BigCircle.js +17 -0
  157. package/src/Components/Icons/Book.js +14 -0
  158. package/src/Components/Icons/BookOpen.js +14 -0
  159. package/src/Components/Icons/Bug.js +14 -0
  160. package/src/Components/Icons/Building.js +14 -0
  161. package/src/Components/Icons/Calendar.js +18 -0
  162. package/src/Components/Icons/Calendar2.js +18 -0
  163. package/src/Components/Icons/CalendarDays.js +18 -0
  164. package/src/Components/Icons/Camera.js +18 -0
  165. package/src/Components/Icons/CaretDown.js +18 -0
  166. package/src/Components/Icons/CaretUp.js +18 -0
  167. package/src/Components/Icons/CartPlus.js +14 -0
  168. package/src/Components/Icons/CartShopping.js +14 -0
  169. package/src/Components/Icons/CashRegister.js +14 -0
  170. package/src/Components/Icons/ChartLine.js +14 -0
  171. package/src/Components/Icons/Check.js +14 -0
  172. package/src/Components/Icons/CheckDouble.js +14 -0
  173. package/src/Components/Icons/ChevronDown.js +14 -0
  174. package/src/Components/Icons/ChevronLeft.js +14 -0
  175. package/src/Components/Icons/ChevronRight.js +14 -0
  176. package/src/Components/Icons/ChevronUp.js +14 -0
  177. package/src/Components/Icons/CircleArrowRight.js +14 -0
  178. package/src/Components/Icons/CircleExclamation.js +18 -0
  179. package/src/Components/Icons/CircleInfo.js +14 -0
  180. package/src/Components/Icons/CircleQuestion.js +14 -0
  181. package/src/Components/Icons/CircleXmark.js +14 -0
  182. package/src/Components/Icons/CircleXmarkRegular.js +14 -0
  183. package/src/Components/Icons/Clipboard.js +18 -0
  184. package/src/Components/Icons/Clock.js +14 -0
  185. package/src/Components/Icons/ClockRegular.js +14 -0
  186. package/src/Components/Icons/ClockRotateLeft.js +14 -0
  187. package/src/Components/Icons/Clone.js +14 -0
  188. package/src/Components/Icons/Comment.js +14 -0
  189. package/src/Components/Icons/CommentRegular.js +14 -0
  190. package/src/Components/Icons/Comments.js +14 -0
  191. package/src/Components/Icons/CommentsRegular.js +14 -0
  192. package/src/Components/Icons/Copyright.js +14 -0
  193. package/src/Components/Icons/Duplicate.js +18 -0
  194. package/src/Components/Icons/Edit.js +18 -0
  195. package/src/Components/Icons/EllipsisVertical.js +18 -0
  196. package/src/Components/Icons/Envelope.js +14 -0
  197. package/src/Components/Icons/EnvelopeRegular.js +14 -0
  198. package/src/Components/Icons/Exclamation.js +14 -0
  199. package/src/Components/Icons/Expand.js +14 -0
  200. package/src/Components/Icons/Eye.js +18 -0
  201. package/src/Components/Icons/File.js +18 -0
  202. package/src/Components/Icons/FloppyDiskRegular.js +14 -0
  203. package/src/Components/Icons/Gear.js +18 -0
  204. package/src/Components/Icons/Gift.js +14 -0
  205. package/src/Components/Icons/Grip.js +18 -0
  206. package/src/Components/Icons/GripLines.js +18 -0
  207. package/src/Components/Icons/GripLinesVertical.js +18 -0
  208. package/src/Components/Icons/GripVertical.js +18 -0
  209. package/src/Components/Icons/Hammer.js +14 -0
  210. package/src/Components/Icons/Hand.js +14 -0
  211. package/src/Components/Icons/House.js +14 -0
  212. package/src/Components/Icons/Info.js +14 -0
  213. package/src/Components/Icons/ItunesNote.js +14 -0
  214. package/src/Components/Icons/List.js +14 -0
  215. package/src/Components/Icons/ListCheck.js +14 -0
  216. package/src/Components/Icons/LocationDot.js +14 -0
  217. package/src/Components/Icons/Loop.js +17 -0
  218. package/src/Components/Icons/Loop1.js +18 -0
  219. package/src/Components/Icons/LoopAll.js +18 -0
  220. package/src/Components/Icons/Maximize.js +14 -0
  221. package/src/Components/Icons/Microphone.js +14 -0
  222. package/src/Components/Icons/Minimize.js +14 -0
  223. package/src/Components/Icons/Minus.js +18 -0
  224. package/src/Components/Icons/MobileScreenButton.js +14 -0
  225. package/src/Components/Icons/MoneyBill.js +14 -0
  226. package/src/Components/Icons/MoneyBillWave.js +14 -0
  227. package/src/Components/Icons/Mouth.js +24 -0
  228. package/src/Components/Icons/Music.js +14 -0
  229. package/src/Components/Icons/NoLoop.js +24 -0
  230. package/src/Components/Icons/NoReorderRows.js +25 -0
  231. package/src/Components/Icons/ObjectGroupRegular.js +14 -0
  232. package/src/Components/Icons/Pause.js +14 -0
  233. package/src/Components/Icons/Pencil.js +18 -0
  234. package/src/Components/Icons/Phone.js +14 -0
  235. package/src/Components/Icons/Play.js +14 -0
  236. package/src/Components/Icons/Plus.js +18 -0
  237. package/src/Components/Icons/Presentation.js +19 -0
  238. package/src/Components/Icons/Print.js +18 -0
  239. package/src/Components/Icons/Question.js +14 -0
  240. package/src/Components/Icons/Rate-.25x.js +20 -0
  241. package/src/Components/Icons/Rate-.5x.js +19 -0
  242. package/src/Components/Icons/Rate-.75x.js +19 -0
  243. package/src/Components/Icons/Rate-1.25x.js +20 -0
  244. package/src/Components/Icons/Rate-1.5x.js +19 -0
  245. package/src/Components/Icons/Rate-1.75x.js +19 -0
  246. package/src/Components/Icons/Rate-1x.js +19 -0
  247. package/src/Components/Icons/Rate-2x.js +19 -0
  248. package/src/Components/Icons/RateIcon-.25x.js +20 -0
  249. package/src/Components/Icons/RateIcon-.5x.js +19 -0
  250. package/src/Components/Icons/RateIcon-.75x.js +19 -0
  251. package/src/Components/Icons/RateIcon-1.25x.js +20 -0
  252. package/src/Components/Icons/RateIcon-1.5x.js +19 -0
  253. package/src/Components/Icons/RateIcon-1.75x.js +19 -0
  254. package/src/Components/Icons/RateIcon-1x.js +19 -0
  255. package/src/Components/Icons/RateIcon-2x.js +19 -0
  256. package/src/Components/Icons/RectangleXmark.js +14 -0
  257. package/src/Components/Icons/RectangleXmarkRegular.js +14 -0
  258. package/src/Components/Icons/ReorderRows.js +21 -0
  259. package/src/Components/Icons/RightFromBracket.js +14 -0
  260. package/src/Components/Icons/RightToBracket.js +14 -0
  261. package/src/Components/Icons/Rotate.js +18 -0
  262. package/src/Components/Icons/RotateLeft.js +14 -0
  263. package/src/Components/Icons/RotateRight.js +18 -0
  264. package/src/Components/Icons/ScrewdriverWrench.js +14 -0
  265. package/src/Components/Icons/Scroll.js +14 -0
  266. package/src/Components/Icons/Share.js +14 -0
  267. package/src/Components/Icons/Shop.js +14 -0
  268. package/src/Components/Icons/SortDown.js +18 -0
  269. package/src/Components/Icons/SortUp.js +18 -0
  270. package/src/Components/Icons/Square.js +14 -0
  271. package/src/Components/Icons/SquareCheck.js +14 -0
  272. package/src/Components/Icons/SquareCheckRegular.js +14 -0
  273. package/src/Components/Icons/SquareMinus.js +18 -0
  274. package/src/Components/Icons/SquareRegular.js +14 -0
  275. package/src/Components/Icons/Store.js +14 -0
  276. package/src/Components/Icons/ThumbsDown.js +14 -0
  277. package/src/Components/Icons/ThumbsDownRegular.js +14 -0
  278. package/src/Components/Icons/ThumbsUp.js +14 -0
  279. package/src/Components/Icons/ThumbsUpRegular.js +14 -0
  280. package/src/Components/Icons/Trash.js +18 -0
  281. package/src/Components/Icons/TrashCan.js +18 -0
  282. package/src/Components/Icons/TriangleExclamation.js +18 -0
  283. package/src/Components/Icons/Truck.js +14 -0
  284. package/src/Components/Icons/TruckFast.js +14 -0
  285. package/src/Components/Icons/User.js +14 -0
  286. package/src/Components/Icons/UserGroup.js +14 -0
  287. package/src/Components/Icons/UserSecret.js +14 -0
  288. package/src/Components/Icons/X.js +14 -0
  289. package/src/Components/Icons/Xmark.js +14 -0
  290. package/src/Components/Mask.js +11 -0
  291. package/src/Components/Messages/ConfirmationMessage.js +26 -0
  292. package/src/Components/Messages/ErrorMessage.js +15 -0
  293. package/src/Components/Messages/Loading.js +16 -0
  294. package/src/Components/Messages/OkMessage.js +24 -0
  295. package/src/Components/Messages/WaitMessage.js +18 -0
  296. package/src/Components/Panel/AccordionGridPanel.js +94 -0
  297. package/src/Components/Panel/Footer.js +20 -0
  298. package/src/Components/Panel/FormPanel.js +23 -0
  299. package/src/Components/Panel/GridPanel.js +45 -0
  300. package/src/Components/Panel/Header.js +107 -0
  301. package/src/Components/Panel/Panel.js +152 -0
  302. package/src/Components/Panel/TabPanel.js +331 -0
  303. package/src/Components/Panel/UploadDownload.js +10 -0
  304. package/src/Components/Picker/Picker.js +64 -0
  305. package/src/Components/ScreenContainer.js +71 -0
  306. package/src/Components/Screens/DataMgt.js +250 -0
  307. package/src/Components/Toolbar/FilterToolbar.js +20 -0
  308. package/src/Components/Toolbar/Pagination.js +146 -0
  309. package/src/Components/Toolbar/PaginationToolbar.js +22 -0
  310. package/src/Components/Toolbar/Toolbar.js +18 -0
  311. package/src/Components/WaitModal.js +31 -0
  312. package/src/Components/Window/Editor.js +19 -0
  313. package/src/Constants/Alert.js +3 -0
  314. package/src/Constants/Date.js +3 -0
  315. package/src/Constants/Directions.js +8 -0
  316. package/src/Constants/EditorTypes.js +4 -0
  317. package/src/Constants/File.js +2 -0
  318. package/src/Constants/Grid.js +4 -0
  319. package/src/Constants/Input.js +1 -0
  320. package/src/Constants/Selection.js +5 -0
  321. package/src/Constants/Styles.js +86 -0
  322. package/src/Constants/UiModes.js +2 -0
  323. package/src/Data/Hoc/withRedux.js +48 -0
  324. package/src/Data/useOneHatData.js +75 -0
  325. package/src/Functions/BankersRound.js +11 -0
  326. package/src/Functions/Timer.js +92 -0
  327. package/src/Functions/deleteSecure.js +6 -0
  328. package/src/Functions/emptyFn.js +1 -0
  329. package/src/Functions/getComponentFromType.js +106 -0
  330. package/src/Functions/getIsMobile.js +5 -0
  331. package/src/Functions/getPref.js +7 -0
  332. package/src/Functions/getSecure.js +21 -0
  333. package/src/Functions/getTokenHeaders.js +13 -0
  334. package/src/Functions/inArray.js +5 -0
  335. package/src/Functions/isJson.js +8 -0
  336. package/src/Functions/processImage.js +16 -0
  337. package/src/Functions/setPref.js +14 -0
  338. package/src/Functions/setProgress.js +49 -0
  339. package/src/Functions/setSecure.js +35 -0
  340. package/src/Functions/setUiMode.js +5 -0
  341. package/src/Functions/sleep.js +3 -0
  342. package/src/Functions/testProps.js +24 -0
  343. package/src/Functions/trackEngagementHit.js +11 -0
  344. package/src/Functions/verifyCompleted.js +18 -0
  345. package/src/Functions/waitFor.js +16 -0
  346. package/src/Hooks/useAppState.js +34 -0
  347. package/src/Hooks/useAsync.js +13 -0
  348. package/src/Hooks/useBlocking.js +18 -0
  349. package/src/Hooks/useCameraRoll.js +41 -0
  350. package/src/Hooks/useForceUpdate.js +14 -0
  351. package/src/Hooks/useIsMounted.js +14 -0
  352. package/src/Hooks/useNotifications.js +279 -0
  353. package/src/Styles/StyleSheets.js +14 -0
  354. package/src/Styles/ThemeOverrides.js +264 -0
  355. package/src/UiConfig.js +19 -0
@@ -0,0 +1,48 @@
1
+ import { bindActionCreators } from 'redux';
2
+ import { connect } from 'react-redux';
3
+ import actionCreators from '../../../Models/actions/ActionCreators';
4
+ import _ from 'lodash';
5
+
6
+ // Usage:
7
+ // At top of file:
8
+ // import withRedux from '../../OneHat/Data/hoc/WithData';
9
+ //
10
+ // At the bottom of your component that needs a CrudStore, do this:
11
+ // export default withRedux(MyComponent, ['Users', 'Equipment']);
12
+
13
+ export default function withRedux(WrappedComponent, properties = null) {
14
+
15
+ if (_.isString(properties)) {
16
+ properties = [properties];
17
+ }
18
+
19
+ function WrapperComponent(props) {
20
+ return <WrappedComponent {...props} />;
21
+ }
22
+
23
+ // What portion of the global Redux state should be routed to this component as props?
24
+ function mapStateToProps(state) {
25
+ let obj = {};
26
+ const reducers = _.keys(state);
27
+ _.forEach(properties, (property) => {
28
+ _.forEach(reducers, (reducer) => {
29
+ if (state[reducer].hasOwnProperty(property)) {
30
+ obj[property] = state[reducer][property];
31
+ }
32
+ });
33
+ });
34
+ return obj;
35
+ }
36
+
37
+ // Pass action creators down to a component as props,
38
+ // so the component doesn't have to directly make use of Redux or store.dispatch()
39
+ function mapDispatchToProps(dispatch) {
40
+ return {
41
+ actions: bindActionCreators(actionCreators, dispatch)
42
+ };
43
+ }
44
+
45
+ // Create "Reduxed" HOC so everything connects together correctly
46
+ return connect(mapStateToProps, mapDispatchToProps)( WrapperComponent );
47
+
48
+ }
@@ -0,0 +1,75 @@
1
+ import { useState, useEffect, useRef, } from 'react';
2
+ import oneHatData from '@onehat/data';
3
+ import _ from 'lodash';
4
+
5
+ /**
6
+ * NOTE: This file will *NOT* work as a direct import to your project,
7
+ * since 'React' is not in scope within the @onehat/data module.
8
+ * This file is provided as an example only!
9
+ * You will need to copy this file into your own project and import it from there.
10
+ */
11
+
12
+ /**
13
+ * Custom React Hook.
14
+ * Enables two-way communication between a React component and OneHatData.
15
+ * @param {[string|object]} config - The name of the Schema you want to use.
16
+ * Alternately, this can be a Repository config object, in which case a unique Repository will be created
17
+ * @param {boolean} uniqueRepository - Create and use a unique Repository
18
+ * for just this one component, or get the Repository bound to the supplied Schema?
19
+ * @return {array} [entities, repository] - *entities* contains the activeEntities
20
+ * of the repository. *repository* is the repository itself, which the component
21
+ * can use to call actions on the repository, like refresh() or sort() or filter()
22
+ */
23
+ export default function useOneHatData(config, uniqueRepository = false) {
24
+
25
+ const [entities, setEntities] = useState([]),
26
+ repository = useRef(), // use 'ref' instead of 'state' so onChangeData sees non-stale repository
27
+ setRepository = (r) => {
28
+ repository.current = r;
29
+ };
30
+
31
+ let schemaName;
32
+
33
+ // normalize config and schemaName
34
+ if (_.isString(config)) {
35
+ schemaName = config;
36
+ config = {
37
+ schema: config,
38
+ };
39
+ } else {
40
+ schemaName = config.id;
41
+ }
42
+
43
+ useEffect(() => {
44
+
45
+ const onChangeData = () => {
46
+ setEntities(repository.current.entities);
47
+ };
48
+
49
+ (async () => {
50
+
51
+ const repository = uniqueRepository ?
52
+ await oneHatData.createRepository(config) :
53
+ oneHatData.getRepository(schemaName);
54
+
55
+ setRepository(repository);
56
+ setEntities(repository.entities);
57
+
58
+ // Create & assign event handler for 'changeData'
59
+ repository.on('changeData', onChangeData);
60
+
61
+ })();
62
+
63
+ return () => {
64
+ if (repository.current) {
65
+ repository.current.off('changeData', onChangeData);
66
+ }
67
+ if (uniqueRepository) {
68
+ oneHatData.deleteRepository(schemaName);
69
+ }
70
+ };
71
+
72
+ }, []); // '[]' to make this effect run only once
73
+
74
+ return [entities, repository.current];
75
+ }
@@ -0,0 +1,11 @@
1
+ import round from 'locutus/php/math/round'; // Port of PHP functions to JS
2
+
3
+ // Rounds to the nearest EVEN integer. This means it is unbiased (doesn't always round up, doesn't always round down)
4
+ export function BankersRound($x) {
5
+ return round($x, 0, 'PHP_ROUND_HALF_EVEN');
6
+ }
7
+
8
+ // Rounds half-cent amounts to nearest cent, using algorithm similar to above
9
+ export default function BankersRoundCents($x) {
10
+ return round($x, 2, 'PHP_ROUND_HALF_EVEN');
11
+ }
@@ -0,0 +1,92 @@
1
+ import prettyMilliseconds from 'pretty-ms';
2
+
3
+ // From https://stackoverflow.com/a/57981688
4
+
5
+ // const timer = new Timer();
6
+ // timer.start();
7
+ // setInterval(() => {
8
+ // const timeInSeconds = Math.round(timer.getTime() / 1000);
9
+ // document.getElementById('time').innerText = timeInSeconds;
10
+ // }, 100)
11
+
12
+ export default class Timer {
13
+ constructor(echo = false) {
14
+ this.echo = echo;
15
+ this.isRunning = false;
16
+ this.startTime = 0;
17
+ this.overallTime = 0;
18
+ this.lapTime = 0;
19
+ }
20
+
21
+ _getTimeElapsedSinceLastStart() {
22
+ if (!this.startTime) {
23
+ return 0;
24
+ }
25
+
26
+ return Date.now() - this.startTime;
27
+ }
28
+
29
+ _getTimeElapsedSinceLastLap() {
30
+ if (!this.lapTime) {
31
+ return 0;
32
+ }
33
+
34
+ return Date.now() - this.lapTime;
35
+ }
36
+
37
+ start() {
38
+ if (this.isRunning) {
39
+ return console.error('Timer is already running');
40
+ }
41
+
42
+ this.isRunning = true;
43
+
44
+ this.startTime = Date.now();
45
+ }
46
+
47
+ stop() {
48
+ if (!this.isRunning) {
49
+ return console.error('Timer is already stopped');
50
+ }
51
+
52
+ this.isRunning = false;
53
+
54
+ this.overallTime = this.overallTime + this._getTimeElapsedSinceLastStart();
55
+ }
56
+
57
+ reset() {
58
+ this.overallTime = 0;
59
+
60
+ if (this.isRunning) {
61
+ this.startTime = Date.now();
62
+ return;
63
+ }
64
+
65
+ this.startTime = 0;
66
+ }
67
+
68
+ getTime() {
69
+ if (!this.startTime) {
70
+ return 0;
71
+ }
72
+
73
+ if (this.isRunning) {
74
+ return this.overallTime + this._getTimeElapsedSinceLastStart();
75
+ }
76
+
77
+ return this.overallTime;
78
+ }
79
+
80
+ lap(name) {
81
+ const lapTime = this._getTimeElapsedSinceLastLap();
82
+ this.lapTime = Date.now();
83
+ if (this.echo) {
84
+ console.log(name, prettyMilliseconds(lapTime), prettyMilliseconds(this._getTimeElapsedSinceLastStart()));
85
+ }
86
+ return lapTime;
87
+ }
88
+
89
+ prettify(ms) {
90
+ return
91
+ }
92
+ }
@@ -0,0 +1,6 @@
1
+ import oneHatData from '@onehat/data';
2
+
3
+ export default async function deleteSecure(key) {
4
+ const Secure = oneHatData.getRepository('Secure');
5
+ await Secure.deleteById(key);
6
+ }
@@ -0,0 +1 @@
1
+ export default function emptyFn() {}
@@ -0,0 +1,106 @@
1
+ import {
2
+ Column,
3
+ } from 'native-base';
4
+ // import AccordionGridPanel from '../Components/Panel/AccordionGridPanel';
5
+ import ArrayCheckboxGroup from '../Components/Form/Field/CheckboxGroup/ArrayCheckboxGroup';
6
+ import ArrayCombo from '../Components/Form/Field/Combo/ArrayCombo';
7
+ import ArrayRadioGroup from '../Components/Form/Field/RadioGroup/ArrayRadioGroup';
8
+ // import BackButton from '../Components/Buttons/BackButton';
9
+ import Blank from '../Components/Blank';
10
+ import BooleanCombo from '../Components/Form/Field/Combo/BooleanCombo';
11
+ // import CartButtonWithBadge from '../Components/Buttons/CartButtonWithBadge';
12
+ import CheckboxGroup from '../Components/Form/Field/CheckboxGroup/CheckboxGroup';
13
+ import CKEditor from '../Components/Form/Field/CKEditor/CKEditor';
14
+ import Color from '../Components/Form/Field/Color';
15
+ import Combo from '../Components/Form/Field/Combo/Combo';
16
+ // import ComboEditor from '../Components/Form/Field/Combo/ComboEditor';
17
+ import Container from '../Components/Container/Container';
18
+ import DataMgt from '../Components/Screens/DataMgt';
19
+ import Date from '../Components/Form/Field/Date';
20
+ import DateRange from '../Components/Filter/DateRange';
21
+ import DisplayField from '../Components/Form/Field/DisplayField';
22
+ import FieldSet from '../Components/Form/FieldSet';
23
+ import File from '../Components/Form/Field/File';
24
+ import FiltersForm from '../Components/Form/FiltersForm';
25
+ // import FiltersToolbar from '../Components/Toolbar/FiltersToolbar';
26
+ import Form from '../Components/Form/Form';
27
+ import Grid from '../Components/Grid/Grid';
28
+ import GridPanel from '../Components/Panel/GridPanel';
29
+ import IconButton from '../Components/Buttons/IconButton';
30
+ import Input from '../Components/Form/Field/Input';
31
+ import IntervalsCombo from '../Components/Form/Field/Combo/IntervalsCombo';
32
+ import Label from '../Components/Form/Label';
33
+ import MonthsCombo from '../Components/Form/Field/Combo/MonthsCombo';
34
+ import Number from '../Components/Form/Field/Number';
35
+ import NumberRange from '../Components/Filter/NumberRange';
36
+ import Panel from '../Components/Panel/Panel';
37
+ // import Picker from '../Components/Panel/Picker';
38
+ import RadioGroup from '../Components/Form/Field/RadioGroup/RadioGroup';
39
+ import TabPanel from '../Components/Panel/TabPanel';
40
+ import Tag from '../Components/Form/Field/Combo/Tag';
41
+ import TextArea from '../Components/Form/Field/TextArea';
42
+ import Text from '../Components/Form/Field/Text';
43
+ import TimezonesCombo from '../Components/Form/Field/Combo/TimezonesCombo';
44
+ import Toggle from '../Components/Form/Field/Toggle';
45
+ import Toolbar from '../Components/Toolbar/Toolbar';
46
+ import YearsCombo from '../Components/Form/Field/Combo/YearsCombo';
47
+ import _ from 'lodash';
48
+
49
+ const
50
+ mapping = {
51
+ // AccordionGridPanel,
52
+ ArrayCheckboxGroup,
53
+ ArrayCombo,
54
+ ArrayRadioGroup,
55
+ // BackButton,
56
+ Blank,
57
+ BooleanCombo,
58
+ // CartButtonWithBadge,
59
+ CheckboxGroup,
60
+ CKEditor,
61
+ Color,
62
+ Column,
63
+ Combo,
64
+ // ComboEditor,
65
+ Container,
66
+ DataMgt,
67
+ Date,
68
+ DateRange,
69
+ DisplayField,
70
+ FieldSet,
71
+ File,
72
+ FiltersForm,
73
+ // FiltersToolbar,
74
+ Form,
75
+ Grid,
76
+ GridPanel,
77
+ IconButton,
78
+ Input,
79
+ IntervalsCombo,
80
+ Label,
81
+ MonthsCombo,
82
+ Number,
83
+ NumberRange,
84
+ Panel,
85
+ // Picker,
86
+ RadioGroup,
87
+ TabPanel,
88
+ Tag,
89
+ Text,
90
+ TextArea,
91
+ TimezonesCombo,
92
+ Toggle,
93
+ Toolbar,
94
+ YearsCombo,
95
+ };
96
+
97
+ export default function getComponentFromType(type) {
98
+ if (_.isString(type)) {
99
+ return mapping[type];
100
+ }
101
+ return type;
102
+ }
103
+
104
+ export function registerComponents(newMapping) {
105
+ _.merge(mapping, newMapping);
106
+ }
@@ -0,0 +1,5 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ export default function getIsMobile() {
4
+ return Platform.OS === 'ios' || Platform.OS === 'android';
5
+ }
@@ -0,0 +1,7 @@
1
+ import oneHatData from '@onehat/data';
2
+
3
+ export default function getPref(key) {
4
+ const Prefs = oneHatData.getRepository('Prefs'),
5
+ pref = Prefs.getById(key);
6
+ return pref && pref.value;
7
+ }
@@ -0,0 +1,21 @@
1
+ import oneHatData from '@onehat/data';
2
+
3
+ export default async function getSecure(key) {
4
+ const Secure = oneHatData.getRepository('Secure'),
5
+ secure = Secure.getById(key);
6
+
7
+ if (!secure) {
8
+ return null;
9
+ }
10
+
11
+ let value = secure.value;
12
+
13
+ if (secure.isJson) {
14
+ value = JSON.parse(value);
15
+ if (secure.isOneBuild) {
16
+ const Repository = oneHatData.getRepository(secure.model);
17
+ value = await Repository.createStandaloneEntity(value);
18
+ }
19
+ }
20
+ return value;
21
+ }
@@ -0,0 +1,13 @@
1
+ import AppGlobals from '../../AppGlobals';
2
+
3
+ export default function(clearAll = false) {
4
+ const reduxState = AppGlobals.redux.getState();
5
+ if (!reduxState.App.user || (!reduxState.App.user.token && !reduxState.App.user.users__token)) {
6
+ return {};
7
+ }
8
+ const token = reduxState.App.user.token || reduxState.App.user.users__token;
9
+ return {
10
+ Authentication: clearAll ? null : `Token ${token}`,
11
+ // Cookie: null,
12
+ };
13
+ }
@@ -0,0 +1,5 @@
1
+ import _ from 'lodash';
2
+
3
+ export default function inArray(needle, haystack) {
4
+ return _.indexOf(haystack, needle) !== -1;
5
+ }
@@ -0,0 +1,8 @@
1
+ export default function isJson(value) {
2
+ try {
3
+ JSON.parse(value);
4
+ } catch (e) {
5
+ return false;
6
+ }
7
+ return true;
8
+ }
@@ -0,0 +1,16 @@
1
+ import * as ImageManipulator from 'expo-image-manipulator';
2
+
3
+ export default async function processImage(uri) {
4
+ const file = await ImageManipulator.manipulateAsync(uri,
5
+ [{
6
+ resize: {
7
+ width: 1000
8
+ }
9
+ }],
10
+ {
11
+ compress: 0.3,
12
+ format: ImageManipulator.SaveFormat.JPEG,
13
+ base64: true,
14
+ });
15
+ return file;
16
+ }
@@ -0,0 +1,14 @@
1
+ import oneHatData from '@onehat/data';
2
+
3
+ export default function setPref(key, value) {
4
+ const Prefs = oneHatData.getRepository('Prefs'),
5
+ pref = Prefs.getById(key);
6
+ if (pref) {
7
+ pref.properties.value.setValue(value);
8
+ } else {
9
+ Prefs.add({
10
+ key,
11
+ value,
12
+ });
13
+ }
14
+ }
@@ -0,0 +1,49 @@
1
+
2
+ import {
3
+ SET_PROGRESS_MESSAGE,
4
+ SET_PROGRESS_PERCENTAGE,
5
+ } from '../../Models/actions/AppActions';
6
+ import AppGlobals from '../../AppGlobals';
7
+
8
+ let totalSegments = 1,
9
+ currentSegment = 1;
10
+
11
+ function setTotalSegments(total) {
12
+ totalSegments = total;
13
+ }
14
+ function setCurrentSegment(segment) {
15
+ currentSegment = segment;
16
+ }
17
+
18
+
19
+ export function setProgressMessage(message, segments = 1) {
20
+ // Reset progress
21
+ setTotalSegments(segments);
22
+ setCurrentSegment(1);
23
+
24
+ const Store = AppGlobals.redux;
25
+ Store.dispatch({
26
+ type: SET_PROGRESS_MESSAGE,
27
+ message,
28
+ });
29
+ }
30
+
31
+ export function setProgressPercentage(percentage = 100, segment = null) {
32
+ if (segment !== null) {
33
+ setCurrentSegment(segment);
34
+ }
35
+
36
+ // Calculate the percentage of this segment
37
+ let totalPercentage = percentage;
38
+ if (totalSegments > 1) {
39
+ const progressPerSegment = 100 / totalSegments,
40
+ accumulatedProgress = (currentSegment - 1) * progressPerSegment;
41
+ totalPercentage = accumulatedProgress + (percentage * progressPerSegment);
42
+ }
43
+
44
+ const Store = AppGlobals.redux;
45
+ Store.dispatch({
46
+ type: SET_PROGRESS_PERCENTAGE,
47
+ percentage: totalPercentage,
48
+ });
49
+ }
@@ -0,0 +1,35 @@
1
+ import oneHatData from '@onehat/data';
2
+
3
+ export default async function setSecure(key, value) {
4
+ const Secure = oneHatData.getRepository('Secure'),
5
+ secure = Secure.getById(key);
6
+ let isOneBuild = false,
7
+ isJson = false,
8
+ model = null;
9
+ if (typeof value !== 'string') {
10
+ if (value.getDataForNewEntity) {
11
+ model = value.repository.name;
12
+ value = value.getDataForNewEntity();
13
+ isOneBuild = true;
14
+ }
15
+ value = JSON.stringify(value);
16
+ isJson = true;
17
+ }
18
+ if (secure) {
19
+ secure.setValues({
20
+ value,
21
+ isOneBuild,
22
+ isJson,
23
+ model,
24
+ });
25
+ await Secure.save(secure);
26
+ } else {
27
+ await Secure.add({
28
+ key,
29
+ value,
30
+ isOneBuild,
31
+ isJson,
32
+ model,
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,5 @@
1
+ import UiConfig from '../UiConfig';
2
+
3
+ export default function setUiMode(mode) {
4
+ UiConfig.mode = mode;
5
+ }
@@ -0,0 +1,3 @@
1
+ export default function(ms = 1000) {
2
+ return new Promise(resolve => setTimeout(resolve, ms));
3
+ }
@@ -0,0 +1,24 @@
1
+ import { Platform } from "react-native";
2
+
3
+ export default function testProps(id) {
4
+ if (typeof __DEV__ !== 'undefined' && !__DEV__) {
5
+ return {};
6
+ }
7
+ if (!window && Platform.OS === 'android') {
8
+ return {
9
+ accessibilityLabel: id,
10
+ accessible: true,
11
+ };
12
+ }
13
+ return {
14
+ testID: id,
15
+ };
16
+ }
17
+
18
+ export function pickerTestProps(id) {
19
+ return {
20
+ pickerProps: {...testProps(id + 'Picker')},
21
+ touchableWrapperProps: {...testProps(id + 'Trigger')},
22
+ touchableDoneProps: {...testProps(id + 'Done')},
23
+ };
24
+ }
@@ -0,0 +1,11 @@
1
+ export default function trackEngagementHit(repository, data) {
2
+ const method = 'POST',
3
+ url = 'Engagements/trackEngagementHit';
4
+
5
+ return repository._send(method, url, data)
6
+ .then((result) => {
7
+ if (repository.debugMode) {
8
+ console.log(url + ' result', result);
9
+ }
10
+ });
11
+ }
@@ -0,0 +1,18 @@
1
+ export default function verifyCompleted(completed, expectedNum, timeoutAfterTries = 60) {
2
+ let attempts = 0;
3
+ return new Promise((resolve, reject) => {
4
+ function check() {
5
+ if (attempts === timeoutAfterTries) {
6
+ reject(false);
7
+ return;
8
+ }
9
+ attempts++;
10
+ if (completed.length === expectedNum) {
11
+ resolve(true);
12
+ return;
13
+ }
14
+ setTimeout(check, 100);
15
+ }
16
+ check();
17
+ });
18
+ }
@@ -0,0 +1,16 @@
1
+ import sleep from './sleep';
2
+
3
+ export default async function waitFor(fn, pollingFrequencyMs = 1000, timeoutMs = null) {
4
+ let timeElapsed = 0;
5
+ const isTimedOut = () => {
6
+ if (!timeoutMs) {
7
+ return false;
8
+ }
9
+ timeElapsed += pollingFrequencyMs;
10
+ return timeElapsed > timeoutMs;
11
+ };
12
+ while(!fn() && !isTimedOut()) {
13
+ await sleep(pollingFrequencyMs);
14
+ }
15
+ return fn();
16
+ }
@@ -0,0 +1,34 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { AppState } from 'react-native';
3
+
4
+ // DEPRECATED: Use @react-native-community/Hooks instead.
5
+
6
+ // Copied from react-native-appstate-hook found here: https://github.com/amrlabib/react-native-appstate-hook
7
+ export default function useAppState(settings) {
8
+ const {
9
+ onChange,
10
+ onForeground,
11
+ onBackground } = settings || {},
12
+ [appState, setAppState] = useState(AppState.currentState);
13
+
14
+ useEffect(() => {
15
+ function handleAppStateChange(nextAppState) {
16
+ if (nextAppState === 'active' && appState !== 'active') {
17
+ isValidFunction(onForeground) && onForeground();
18
+ } else if (appState === 'active' && nextAppState.match(/inactive|background/)) {
19
+ isValidFunction(onBackground) && onBackground();
20
+ }
21
+ setAppState(nextAppState);
22
+ isValidFunction(onChange) && onChange(nextAppState);
23
+ }
24
+ AppState.addEventListener('change', handleAppStateChange);
25
+
26
+ return () => AppState.removeEventListener('change', handleAppStateChange);
27
+ }, [onChange, onForeground, onBackground, appState]);
28
+
29
+ // settings validation
30
+ function isValidFunction(func) {
31
+ return func && typeof func === 'function';
32
+ }
33
+ return { appState };
34
+ }
@@ -0,0 +1,13 @@
1
+ import { useEffect } from 'react';
2
+
3
+ // From https://stackoverflow.com/questions/53949393/cant-perform-a-react-state-update-on-an-unmounted-component
4
+
5
+ export default function useAsync(asyncFn, onSuccess) {
6
+ useEffect(() => {
7
+ let isActive = true;
8
+ asyncFn().then(data => {
9
+ if (isActive) onSuccess(data);
10
+ });
11
+ return () => { isActive = false };
12
+ }, [asyncFn, onSuccess]);
13
+ }