@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,504 @@
1
+ import React, { useState, useEffect, useRef, } from 'react';
2
+ import {
3
+ Box,
4
+ Popover,
5
+ Pressable,
6
+ Row,
7
+ Text,
8
+ Tooltip,
9
+ } from 'native-base';
10
+ import {
11
+ UI_MODE_WEB,
12
+ } from '../../../../Constants/UiModes';
13
+ import UiConfig from '../../../../UiConfig';
14
+ import Input from '../Input';
15
+ import styles from '../../../../Constants/Styles';
16
+ import withData from '../../../Hoc/withData';
17
+ import withEvents from '../../../Hoc/withEvents';
18
+ import withSelection from '../../../Hoc/withSelection';
19
+ import withValue from '../../../Hoc/withValue';
20
+ import emptyFn from '../../../../Functions/emptyFn';
21
+ import { Grid } from '../../../Grid/Grid';
22
+ import IconButton from '../../../Buttons/IconButton';
23
+ import CaretDown from '../../../Icons/CaretDown';
24
+ import _ from 'lodash';
25
+
26
+ // Combo requires the use of HOC withSelection() whenever it's used.
27
+ // The default export is *with* the HOC. A separate *raw* component is
28
+ // exported which can be combined with many HOCs for various functionality.
29
+
30
+ export function Combo(props) {
31
+ const {
32
+ additionalButtons,
33
+ autoFocus = false,
34
+ forceSelection = true,
35
+ tooltipRef = null,
36
+ tooltip = null,
37
+ menuMinWidth = 150,
38
+ disableDirectEntry = false,
39
+ disablePagination = true,
40
+ _input = {},
41
+
42
+ // withValue
43
+ value,
44
+ setValue,
45
+
46
+ // withData
47
+ Repository,
48
+ data,
49
+ idIx,
50
+ displayIx,
51
+
52
+ // withEvents
53
+ onEvent,
54
+
55
+ // withSelection
56
+ selection,
57
+ setSelection,
58
+ selectionMode,
59
+ selectNext,
60
+ selectPrev,
61
+ getDisplayFromSelection,
62
+
63
+ tooltipPlacement = 'bottom',
64
+ } = props,
65
+ inputRef = useRef(),
66
+ triggerRef = useRef(),
67
+ menuRef = useRef(),
68
+ // isTyping = useRef(false),
69
+ // typingTimeout = useRef(),
70
+ [isMenuShown, setIsMenuShown] = useState(false),
71
+ [isRendered, setIsRendered] = useState(false),
72
+ [isManuallyEnteringText, setIsManuallyEnteringText] = useState(false), // when typing a value, not using trigger/grid
73
+ [textValue, setTextValue] = useState(''),
74
+ [width, setWidth] = useState(0),
75
+ [height, setHeight] = useState(null),
76
+ [top, setTop] = useState(0),
77
+ [left, setLeft] = useState(0),
78
+ showMenu = () => {
79
+ if (isMenuShown) {
80
+ return;
81
+ }
82
+ if (UiConfig.mode === UI_MODE_WEB && inputRef.current.getBoundingClientRect) {
83
+ // For web, ensure it's in the proper place
84
+ const
85
+ rect = inputRef.current.getBoundingClientRect(),
86
+ bodyRect = document.body.getBoundingClientRect(),
87
+ isUpper = rect.top < bodyRect.height / 2;
88
+
89
+ if (isUpper) {
90
+ // Menu is below the combo
91
+ const rectTop = rect.top + rect.height;
92
+ if (rectTop !== top) {
93
+ setTop(rectTop);
94
+ }
95
+ setHeight(null);
96
+ } else {
97
+ // Menu is above the combo
98
+
99
+ const rectTop = rect.top -200;
100
+ if (rectTop !== top) {
101
+ setTop(rectTop);
102
+ }
103
+
104
+ setHeight(200);
105
+ }
106
+ if (rect.left !== left) {
107
+ setLeft(rect.left);
108
+ }
109
+ if (rect.width !== width) {
110
+ setWidth(rect.width);
111
+ }
112
+ }
113
+ if (Repository && !Repository.isLoaded) {
114
+ Repository.reload();
115
+ }
116
+ setIsMenuShown(true);
117
+ },
118
+ hideMenu = () => {
119
+ if (!isMenuShown) {
120
+ return;
121
+ }
122
+ setIsMenuShown(false);
123
+ },
124
+ toggleMenu = () => {
125
+ setIsMenuShown(!isMenuShown);
126
+ },
127
+ onInputKeyPress = (e, inputValue) => {
128
+ if (disableDirectEntry) {
129
+ return;
130
+ }
131
+ switch(e.key) {
132
+ case 'Escape':
133
+ hideMenu();
134
+ break;
135
+ case 'Enter':
136
+ e.preventDefault();
137
+ if (_.isEmpty(inputValue) && !_.isNull(value)) {
138
+ // User pressed Enter on an empty text field, but value is set to something
139
+ // This means the user cleared the input and pressed enter, meaning he wants to clear the value
140
+
141
+ // clear the value
142
+ setValue(null);
143
+ if (isMenuShown) {
144
+ hideMenu();
145
+ }
146
+ } else {
147
+ toggleMenu();
148
+ }
149
+ break;
150
+ case 'ArrowDown':
151
+ e.preventDefault();
152
+ selectNext();
153
+ break;
154
+ case 'ArrowUp':
155
+ e.preventDefault();
156
+ selectPrev();
157
+ break;
158
+ default:
159
+ }
160
+ },
161
+ onInputChangeText = (value) => {
162
+ if (disableDirectEntry) {
163
+ return;
164
+ }
165
+ setTextValue(value);
166
+ // searchForMatches(value);
167
+ // setIsManuallyEnteringText(true);
168
+
169
+ // isTyping.current = true;
170
+ // if (typingTimeout.current) {
171
+ // clearTimeout(typingTimeout.current);
172
+ // }
173
+ // typingTimeout.current = setTimeout(() => {
174
+ // isTyping.current = false;
175
+ // }, 300);
176
+ },
177
+ onInputBlur = (e) => {
178
+ const {
179
+ relatedTarget
180
+ } = e;
181
+
182
+ // If user clicked on the menu or trigger, ignore this blur
183
+ if (menuRef.current?.contains(relatedTarget) || triggerRef.current.contains(relatedTarget)) {
184
+ return;
185
+ }
186
+
187
+ if (!relatedTarget ||
188
+ (!inputRef.current.contains(relatedTarget) && triggerRef.current !== relatedTarget && (!menuRef.current || !menuRef.current.contains(relatedTarget)))) {
189
+ hideMenu();
190
+ }
191
+ if (textValue === '') {
192
+ setSelection([]); // delete current selection
193
+
194
+ } else if (isManuallyEnteringText) {
195
+ if (forceSelection) {
196
+ setSelection([]); // delete current selection
197
+ hideMenu();
198
+ } else {
199
+ setValue(textValue);
200
+ }
201
+ }
202
+ if (_.isEmpty(selection)) {
203
+ setTextValue('');
204
+ }
205
+ },
206
+ onInputClick = (e) => {
207
+ if (!isRendered) {
208
+ return;
209
+ }
210
+ showMenu();
211
+ },
212
+ onTriggerPress = (e) => {
213
+ if (!isRendered) {
214
+ return;
215
+ }
216
+ if (isMenuShown) {
217
+ hideMenu();
218
+ } else {
219
+ showMenu();
220
+ }
221
+ inputRef.current.focus();
222
+ },
223
+ onTriggerBlur = (e) => {
224
+ if (!isMenuShown) {
225
+ return;
226
+ }
227
+ const {
228
+ relatedTarget
229
+ } = e;
230
+ if (!relatedTarget ||
231
+ (!inputRef.current.contains(relatedTarget) && triggerRef.current !== relatedTarget && !menuRef.current.contains(relatedTarget))) {
232
+ hideMenu();
233
+ }
234
+ },
235
+ searchForMatches = (value) => {
236
+
237
+ // Do a search for this value
238
+ // TODO: Do fuzzy seach for results
239
+ // Would have to do differently for remote repositories
240
+ // Narrow results in grid to those that match the filter.
241
+ // If filter is cleared, show original results.
242
+
243
+ let found;
244
+ if (Repository) {
245
+
246
+ debugger;
247
+
248
+ // Set filter
249
+ let filter = {};
250
+ if (value !== '') {
251
+
252
+ // TODO: Want to build a search functionality that shows results in combo grid
253
+
254
+ if (Repository.isRemote) {
255
+ // 'q' fuzzy search from server
256
+
257
+
258
+ } else {
259
+ // Fuzzy search with getBy filter function
260
+ filter = (entity) => {
261
+ const
262
+ displayValue = entity.displayValue,
263
+ regex = new RegExp('^' + value);
264
+ return displayValue.match(regex);
265
+ };
266
+ }
267
+ }
268
+ Repository.filter(filter);
269
+
270
+ // TODO: Auto-select if filter produces only one result
271
+
272
+ } else {
273
+ // Search through data
274
+ found = _.find(data, (item) => {
275
+ if (_.isString(item[displayIx]) && _.isString(value)) {
276
+ return item[displayIx].toLowerCase() === value.toLowerCase();
277
+ }
278
+ return item[displayIx] === value;
279
+ });
280
+ if (found) {
281
+ const
282
+ newSelection = [found],
283
+ newTextValue = getDisplayFromSelection(newSelection);
284
+
285
+ setTextValue(newTextValue);
286
+ setSelection(newSelection);
287
+ } else {
288
+ if (value === '') { // Text field was cleared, so clear selection
289
+ setSelection([]);
290
+ }
291
+ }
292
+ }
293
+ };
294
+
295
+ if (_.isUndefined(selection)) {
296
+ throw new Error('Combo must be used with withSelection hook!');
297
+ }
298
+
299
+ useEffect(() => {
300
+ // on render, focus the input
301
+ if (!isRendered) {
302
+ return () => {};
303
+ }
304
+ if (autoFocus && !inputRef.current.isFocused()) {
305
+ inputRef.current.focus();
306
+ }
307
+
308
+ }, [isRendered]);
309
+
310
+ useEffect(() => {
311
+ // Adjust text input to match selection
312
+ let localTextValue = getDisplayFromSelection(selection);
313
+ if (!_.isEqual(localTextValue, textValue)) {
314
+ setTextValue(localTextValue);
315
+ }
316
+ setIsManuallyEnteringText(false);
317
+ }, [selection]);
318
+
319
+
320
+ const refProps = {};
321
+ if (tooltipRef) {
322
+ refProps.ref = tooltipRef;
323
+ }
324
+
325
+ let comboComponent = <Row {...refProps} justifyContent="center" alignItems="center" h={styles.FORM_COMBO_HEIGHT} flex={1} onLayout={() => setIsRendered(true)}>
326
+ {disableDirectEntry ?
327
+ <Pressable
328
+ onPress={toggleMenu}
329
+ flex={1}
330
+ h="100%"
331
+ >
332
+ <Text
333
+ ref={inputRef}
334
+ onLayout={(e) => {
335
+ // On web, this is not needed, but on RN it might be, so leave it in for now
336
+ const {
337
+ height,
338
+ width,
339
+ top,
340
+ left,
341
+ } = e.nativeEvent.layout;
342
+ setWidth(width);
343
+ setTop(top + height);
344
+ setLeft(left);
345
+ }}
346
+ flex={1}
347
+ h="100%"
348
+ numberOfLines={1}
349
+ ellipsizeMode="head"
350
+ m={0}
351
+ p={2}
352
+ borderWidth={1}
353
+ borderColor="trueGray.400"
354
+ borderTopRightRadius={0}
355
+ borderBottomRightRadius={0}
356
+ fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
357
+ bg={styles.FORM_COMBO_INPUT_BG}
358
+ _focus={{
359
+ bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
360
+ }}
361
+ >{textValue}</Text>
362
+ </Pressable> :
363
+ <Input
364
+ ref={inputRef}
365
+ value={textValue}
366
+ autoSubmit={true}
367
+ onChangeValue={onInputChangeText}
368
+ onKeyPress={onInputKeyPress}
369
+ onBlur={onInputBlur}
370
+ onClick={onInputClick}
371
+ onLayout={(e) => {
372
+ // On web, this is not needed, but on RN it might be, so leave it in for now
373
+ const {
374
+ height,
375
+ width,
376
+ top,
377
+ left,
378
+ } = e.nativeEvent.layout;
379
+ setWidth(width);
380
+ setTop(top + height);
381
+ setLeft(left);
382
+ }}
383
+ // onFocus={(e) => {
384
+ // if (isBlocked.current) {
385
+ // return;
386
+ // }
387
+ // if (!isRendered) {
388
+ // return;
389
+ // }
390
+ // showMenu();
391
+ // }}
392
+ flex={1}
393
+ h="100%"
394
+ m={0}
395
+ borderTopRightRadius={0}
396
+ borderBottomRightRadius={0}
397
+ fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
398
+ bg={styles.FORM_COMBO_INPUT_BG}
399
+ _focus={{
400
+ bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
401
+ }}
402
+ {..._input}
403
+ />}
404
+ <IconButton
405
+ ref={triggerRef}
406
+ _icon={{
407
+ as: CaretDown,
408
+ color: 'primary.800',
409
+ size: 'sm',
410
+ }}
411
+ onPress={onTriggerPress}
412
+ onBlur={onTriggerBlur}
413
+ h="100%"
414
+ borderWidth={1}
415
+ borderColor="#bbb"
416
+ borderLeftWidth={0}
417
+ borderLeftRadius={0}
418
+ borderRightRadius="md"
419
+ bg={styles.FORM_COMBO_TRIGGER_BG}
420
+ _hover={{
421
+ bg: styles.FORM_COMBO_TRIGGER_HOVER_BG,
422
+ }}
423
+ />
424
+ {additionalButtons}
425
+ <Popover
426
+ isOpen={isMenuShown}
427
+ onClose={() => {
428
+ hideMenu();
429
+ }}
430
+ trigger={emptyFn}
431
+ trapFocus={false}
432
+ placement={'auto'}
433
+ // _fade={{
434
+ // entryDuration: 0, // Doesn't work, as Popover doesn't have animation controls like Modal does. See node_modules/native-base/src/components/composites/Popover/Popover.tsx line 99 (vs .../composites/Modal/Modal.tsx line 113 which has ..._fade) I added a feature request to NativeBase https://github.com/GeekyAnts/NativeBase/issues/5651
435
+ // }}
436
+ {...props}
437
+ >
438
+ <Popover.Content
439
+ position="absolute"
440
+ top={top + 'px'}
441
+ left={left + 'px'}
442
+ w={width + 'px'}
443
+ h={height ? height + 'px' : null}
444
+ minWidth={menuMinWidth}
445
+ overflow="scroll"
446
+ >
447
+ <Popover.Body
448
+ ref={menuRef}
449
+ maxHeight={200}
450
+ borderWidth={1}
451
+ borderColor='trueGray.400'
452
+ borderTopWidth={0}
453
+ p={0}
454
+ >
455
+ <Grid
456
+ showHeaders={false}
457
+ showHovers={true}
458
+ shadow={1}
459
+ getRowProps={() => {
460
+ return {
461
+ borderBottomWidth: 1,
462
+ borderBottomColor: 'trueGray.300',
463
+ py: 1,
464
+ pl: 4,
465
+ pr: 2,
466
+ };
467
+ }}
468
+ {...props}
469
+ disablePagination={disablePagination}
470
+ fireEvent={onEvent}
471
+ setSelection={(selection) => {
472
+ // Decorator fn to add local functionality
473
+ // Close the menu when row is selected on grid
474
+ setSelection(selection);
475
+ hideMenu();
476
+ }}
477
+ selectionMode={selectionMode}
478
+ setValue={(value) => {
479
+ setValue(value);
480
+ }}
481
+ />
482
+ </Popover.Body>
483
+ </Popover.Content>
484
+ </Popover>
485
+ </Row>;
486
+ if (tooltip) {
487
+ comboComponent = <Tooltip label={tooltip} placement={tooltipPlacement}>
488
+ {comboComponent}
489
+ </Tooltip>;
490
+ }
491
+
492
+ return comboComponent;
493
+ }
494
+
495
+ export default
496
+ // withEvents(
497
+ withData(
498
+ withValue(
499
+ withSelection(
500
+ Combo
501
+ )
502
+ )
503
+ );
504
+ // );
@@ -0,0 +1,22 @@
1
+ import withAlert from '../../../Hoc/withAlert';
2
+ import withData from '../../../Hoc/withData';
3
+ import withPresetButtons from '../../../Hoc/withPresetButtons';
4
+ import withSelection from '../../../Hoc/withSelection';
5
+ import withValue from '../../../Hoc/withValue';
6
+ import withWindowedEditor from '../../../Hoc/withWindowedEditor';
7
+ import { Combo } from './Combo';
8
+
9
+ export default
10
+ // withAlert(
11
+ withData(
12
+ withValue(
13
+ withSelection(
14
+ withWindowedEditor(
15
+ withPresetButtons(
16
+ Combo
17
+ )
18
+ )
19
+ )
20
+ )
21
+ );
22
+ //);
@@ -0,0 +1,18 @@
1
+ import ArrayCombo from './ArrayCombo';
2
+
3
+ const data = [
4
+ ['+1 day', 'Daily'],
5
+ ['+1 week', 'Weekly'],
6
+ ['+2 week', 'Bi-weekly'],
7
+ ['+1 month', 'Monthly'],
8
+ ['+3 month', 'Quarterly'],
9
+ ['+1 year', 'Yearly']
10
+ ];
11
+
12
+ export default function IntervalsCombo(props) {
13
+ return <ArrayCombo
14
+ data={data}
15
+ disableDirectEntry={true}
16
+ {...props}
17
+ />;
18
+ }
@@ -0,0 +1,24 @@
1
+ import ArrayCombo from './ArrayCombo';
2
+
3
+ const data = [
4
+ [ 1, 'January', ],
5
+ [ 2, 'February', ],
6
+ [ 3, 'March', ],
7
+ [ 4, 'April', ],
8
+ [ 5, 'May', ],
9
+ [ 6, 'June', ],
10
+ [ 7, 'July', ],
11
+ [ 8, 'August', ],
12
+ [ 9, 'September', ],
13
+ [ 10, 'October', ],
14
+ [ 11, 'November', ],
15
+ [ 12, 'December', ],
16
+ ];
17
+
18
+ export default function MonthsCombo(props) {
19
+ return <ArrayCombo
20
+ data={data}
21
+ disableDirectEntry={true}
22
+ {...props}
23
+ />;
24
+ }
@@ -0,0 +1,38 @@
1
+ import { useMemo, } from 'react';
2
+ import {
3
+ Row,
4
+ } from 'native-base';
5
+ import ArrayCombo from './ArrayCombo';
6
+
7
+ export default function PageSizeCombo(props) {
8
+ const {
9
+ Repository,
10
+ pageSize,
11
+ } = props;
12
+
13
+ return useMemo(() => {
14
+ return <Row
15
+ w="100px"
16
+ ml={2}
17
+ >
18
+ <ArrayCombo
19
+ data={[
20
+ // [ 1, '1/pg', ],
21
+ [ 5, '5/pg', ],
22
+ [ 10, '10/pg', ],
23
+ [ 20, '20pg', ],
24
+ [ 50, '50/pg', ],
25
+ [ 100, '100/pg', ],
26
+ ]}
27
+ value={pageSize}
28
+ onChangeValue={(value) => Repository.setPageSize(value)}
29
+ tooltip="Page Size"
30
+ allowNull={false}
31
+ disableDirectEntry={true}
32
+ />
33
+ </Row>;
34
+ }, [
35
+ Repository,
36
+ pageSize,
37
+ ]);
38
+ }
@@ -0,0 +1,12 @@
1
+ import {
2
+ SELECTION_MODE_MULTI,
3
+ } from '../../../../Constants/Selection';
4
+ import Combo from './Combo';
5
+
6
+ export default function Tag(props) {
7
+ return <Combo
8
+ selectionMode={SELECTION_MODE_MULTI}
9
+ disableDirectEntry={true}
10
+ {...props}
11
+ />;
12
+ }