@terreno/ui 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +160 -0
  3. package/dist/Accordion.d.ts +3 -0
  4. package/dist/Accordion.js +30 -0
  5. package/dist/Accordion.js.map +1 -0
  6. package/dist/ActionSheet.d.ts +169 -0
  7. package/dist/ActionSheet.js +637 -0
  8. package/dist/ActionSheet.js.map +1 -0
  9. package/dist/AddressField.d.ts +3 -0
  10. package/dist/AddressField.js +18 -0
  11. package/dist/AddressField.js.map +1 -0
  12. package/dist/Avatar.d.ts +3 -0
  13. package/dist/Avatar.js +189 -0
  14. package/dist/Avatar.js.map +1 -0
  15. package/dist/Badge.d.ts +3 -0
  16. package/dist/Badge.js +100 -0
  17. package/dist/Badge.js.map +1 -0
  18. package/dist/Banner.d.ts +4 -0
  19. package/dist/Banner.js +103 -0
  20. package/dist/Banner.js.map +1 -0
  21. package/dist/Body.d.ts +3 -0
  22. package/dist/Body.js +17 -0
  23. package/dist/Body.js.map +1 -0
  24. package/dist/BooleanField.d.ts +3 -0
  25. package/dist/BooleanField.js +89 -0
  26. package/dist/BooleanField.js.map +1 -0
  27. package/dist/Box.d.ts +3 -0
  28. package/dist/Box.js +289 -0
  29. package/dist/Box.js.map +1 -0
  30. package/dist/Button.d.ts +3 -0
  31. package/dist/Button.js +105 -0
  32. package/dist/Button.js.map +1 -0
  33. package/dist/Card.d.ts +2 -0
  34. package/dist/Card.js +18 -0
  35. package/dist/Card.js.map +1 -0
  36. package/dist/CheckBox.d.ts +3 -0
  37. package/dist/CheckBox.js +28 -0
  38. package/dist/CheckBox.js.map +1 -0
  39. package/dist/Common.d.ts +2325 -0
  40. package/dist/Common.js +47 -0
  41. package/dist/Common.js.map +1 -0
  42. package/dist/CommonIconTypes.d.ts +3 -0
  43. package/dist/CommonIconTypes.js +2 -0
  44. package/dist/CommonIconTypes.js.map +1 -0
  45. package/dist/Constants.d.ts +12685 -0
  46. package/dist/Constants.js +3310 -0
  47. package/dist/Constants.js.map +1 -0
  48. package/dist/CustomSelectField.d.ts +3 -0
  49. package/dist/CustomSelectField.js +59 -0
  50. package/dist/CustomSelectField.js.map +1 -0
  51. package/dist/DataTable.d.ts +3 -0
  52. package/dist/DataTable.js +190 -0
  53. package/dist/DataTable.js.map +1 -0
  54. package/dist/DateTimeActionSheet.d.ts +2 -0
  55. package/dist/DateTimeActionSheet.js +270 -0
  56. package/dist/DateTimeActionSheet.js.map +1 -0
  57. package/dist/DateTimeField.d.ts +3 -0
  58. package/dist/DateTimeField.js +514 -0
  59. package/dist/DateTimeField.js.map +1 -0
  60. package/dist/DateUtilities.d.ts +57 -0
  61. package/dist/DateUtilities.js +308 -0
  62. package/dist/DateUtilities.js.map +1 -0
  63. package/dist/DecimalRangeActionSheet.d.ts +6 -0
  64. package/dist/DecimalRangeActionSheet.js +45 -0
  65. package/dist/DecimalRangeActionSheet.js.map +1 -0
  66. package/dist/DismissButton.d.ts +3 -0
  67. package/dist/DismissButton.js +12 -0
  68. package/dist/DismissButton.js.map +1 -0
  69. package/dist/EmailField.d.ts +3 -0
  70. package/dist/EmailField.js +48 -0
  71. package/dist/EmailField.js.map +1 -0
  72. package/dist/EmojiSelector.d.ts +113 -0
  73. package/dist/EmojiSelector.js +322 -0
  74. package/dist/EmojiSelector.js.map +1 -0
  75. package/dist/ErrorBoundary.d.ts +19 -0
  76. package/dist/ErrorBoundary.js +30 -0
  77. package/dist/ErrorBoundary.js.map +1 -0
  78. package/dist/ErrorPage.d.ts +6 -0
  79. package/dist/ErrorPage.js +15 -0
  80. package/dist/ErrorPage.js.map +1 -0
  81. package/dist/Field.d.ts +3 -0
  82. package/dist/Field.js +80 -0
  83. package/dist/Field.js.map +1 -0
  84. package/dist/FlatList.d.ts +2 -0
  85. package/dist/FlatList.js +3 -0
  86. package/dist/FlatList.js.map +1 -0
  87. package/dist/Heading.d.ts +3 -0
  88. package/dist/Heading.js +43 -0
  89. package/dist/Heading.js.map +1 -0
  90. package/dist/HeightActionSheet.d.ts +11 -0
  91. package/dist/HeightActionSheet.js +46 -0
  92. package/dist/HeightActionSheet.js.map +1 -0
  93. package/dist/Hyperlink.d.ts +30 -0
  94. package/dist/Hyperlink.js +144 -0
  95. package/dist/Hyperlink.js.map +1 -0
  96. package/dist/Icon.d.ts +3 -0
  97. package/dist/Icon.js +15 -0
  98. package/dist/Icon.js.map +1 -0
  99. package/dist/IconButton.d.ts +3 -0
  100. package/dist/IconButton.js +111 -0
  101. package/dist/IconButton.js.map +1 -0
  102. package/dist/Image.d.ts +8 -0
  103. package/dist/Image.js +37 -0
  104. package/dist/Image.js.map +1 -0
  105. package/dist/ImageBackground.d.ts +10 -0
  106. package/dist/ImageBackground.js +9 -0
  107. package/dist/ImageBackground.js.map +1 -0
  108. package/dist/InfoModalIcon.d.ts +3 -0
  109. package/dist/InfoModalIcon.js +10 -0
  110. package/dist/InfoModalIcon.js.map +1 -0
  111. package/dist/InfoTooltipButton.d.ts +3 -0
  112. package/dist/InfoTooltipButton.js +6 -0
  113. package/dist/InfoTooltipButton.js.map +1 -0
  114. package/dist/Link.d.ts +3 -0
  115. package/dist/Link.js +10 -0
  116. package/dist/Link.js.map +1 -0
  117. package/dist/MarkdownView.d.ts +5 -0
  118. package/dist/MarkdownView.js +44 -0
  119. package/dist/MarkdownView.js.map +1 -0
  120. package/dist/MediaQuery.d.ts +4 -0
  121. package/dist/MediaQuery.js +52 -0
  122. package/dist/MediaQuery.js.map +1 -0
  123. package/dist/MobileAddressAutoComplete.d.ts +2 -0
  124. package/dist/MobileAddressAutoComplete.js +54 -0
  125. package/dist/MobileAddressAutoComplete.js.map +1 -0
  126. package/dist/Modal.d.ts +3 -0
  127. package/dist/Modal.js +127 -0
  128. package/dist/Modal.js.map +1 -0
  129. package/dist/ModalSheet.d.ts +6 -0
  130. package/dist/ModalSheet.js +42 -0
  131. package/dist/ModalSheet.js.map +1 -0
  132. package/dist/MultiselectField.d.ts +3 -0
  133. package/dist/MultiselectField.js +45 -0
  134. package/dist/MultiselectField.js.map +1 -0
  135. package/dist/NumberField.d.ts +3 -0
  136. package/dist/NumberField.js +60 -0
  137. package/dist/NumberField.js.map +1 -0
  138. package/dist/NumberPickerActionSheet.d.ts +7 -0
  139. package/dist/NumberPickerActionSheet.js +22 -0
  140. package/dist/NumberPickerActionSheet.js.map +1 -0
  141. package/dist/OpenAPIContext.d.ts +4 -0
  142. package/dist/OpenAPIContext.js +53 -0
  143. package/dist/OpenAPIContext.js.map +1 -0
  144. package/dist/Page.d.ts +7 -0
  145. package/dist/Page.js +24 -0
  146. package/dist/Page.js.map +1 -0
  147. package/dist/Pagination.d.ts +3 -0
  148. package/dist/Pagination.js +106 -0
  149. package/dist/Pagination.js.map +1 -0
  150. package/dist/PasswordField.d.ts +2 -0
  151. package/dist/PasswordField.js +6 -0
  152. package/dist/PasswordField.js.map +1 -0
  153. package/dist/Permissions.d.ts +2 -0
  154. package/dist/Permissions.js +35 -0
  155. package/dist/Permissions.js.map +1 -0
  156. package/dist/PhoneNumberField.d.ts +3 -0
  157. package/dist/PhoneNumberField.js +83 -0
  158. package/dist/PhoneNumberField.js.map +1 -0
  159. package/dist/PickerSelect.d.ts +46 -0
  160. package/dist/PickerSelect.js +306 -0
  161. package/dist/PickerSelect.js.map +1 -0
  162. package/dist/Radio.d.ts +3 -0
  163. package/dist/Radio.js +21 -0
  164. package/dist/Radio.js.map +1 -0
  165. package/dist/RadioField.d.ts +3 -0
  166. package/dist/RadioField.js +16 -0
  167. package/dist/RadioField.js.map +1 -0
  168. package/dist/ScrollView.d.ts +2 -0
  169. package/dist/ScrollView.js +3 -0
  170. package/dist/ScrollView.js.map +1 -0
  171. package/dist/SectionDivider.d.ts +2 -0
  172. package/dist/SectionDivider.js +12 -0
  173. package/dist/SectionDivider.js.map +1 -0
  174. package/dist/SegmentedControl.d.ts +3 -0
  175. package/dist/SegmentedControl.js +65 -0
  176. package/dist/SegmentedControl.js.map +1 -0
  177. package/dist/SelectBadge.d.ts +3 -0
  178. package/dist/SelectBadge.js +166 -0
  179. package/dist/SelectBadge.js.map +1 -0
  180. package/dist/SelectField.d.ts +3 -0
  181. package/dist/SelectField.js +16 -0
  182. package/dist/SelectField.js.map +1 -0
  183. package/dist/SideDrawer.d.ts +3 -0
  184. package/dist/SideDrawer.js +32 -0
  185. package/dist/SideDrawer.js.map +1 -0
  186. package/dist/Signature.d.ts +8 -0
  187. package/dist/Signature.js +21 -0
  188. package/dist/Signature.js.map +1 -0
  189. package/dist/Signature.native.d.ts +8 -0
  190. package/dist/Signature.native.js +26 -0
  191. package/dist/Signature.native.js.map +1 -0
  192. package/dist/SignatureField.d.ts +3 -0
  193. package/dist/SignatureField.js +42 -0
  194. package/dist/SignatureField.js.map +1 -0
  195. package/dist/Slider.d.ts +3 -0
  196. package/dist/Slider.js +78 -0
  197. package/dist/Slider.js.map +1 -0
  198. package/dist/Spinner.d.ts +3 -0
  199. package/dist/Spinner.js +33 -0
  200. package/dist/Spinner.js.map +1 -0
  201. package/dist/SplitPage.d.ts +2 -0
  202. package/dist/SplitPage.js +139 -0
  203. package/dist/SplitPage.js.map +1 -0
  204. package/dist/SplitPage.native.d.ts +2 -0
  205. package/dist/SplitPage.native.js +75 -0
  206. package/dist/SplitPage.native.js.map +1 -0
  207. package/dist/TapToEdit.d.ts +4 -0
  208. package/dist/TapToEdit.js +170 -0
  209. package/dist/TapToEdit.js.map +1 -0
  210. package/dist/TerrenoProvider.d.ts +6 -0
  211. package/dist/TerrenoProvider.js +10 -0
  212. package/dist/TerrenoProvider.js.map +1 -0
  213. package/dist/Text.d.ts +3 -0
  214. package/dist/Text.js +95 -0
  215. package/dist/Text.js.map +1 -0
  216. package/dist/TextArea.d.ts +3 -0
  217. package/dist/TextArea.js +6 -0
  218. package/dist/TextArea.js.map +1 -0
  219. package/dist/TextField.d.ts +3 -0
  220. package/dist/TextField.js +144 -0
  221. package/dist/TextField.js.map +1 -0
  222. package/dist/TextFieldNumberActionSheet.d.ts +7 -0
  223. package/dist/TextFieldNumberActionSheet.js +20 -0
  224. package/dist/TextFieldNumberActionSheet.js.map +1 -0
  225. package/dist/Theme.d.ts +96 -0
  226. package/dist/Theme.js +213 -0
  227. package/dist/Theme.js.map +1 -0
  228. package/dist/TimezonePicker.d.ts +11 -0
  229. package/dist/TimezonePicker.js +27 -0
  230. package/dist/TimezonePicker.js.map +1 -0
  231. package/dist/Toast.d.ts +23 -0
  232. package/dist/Toast.js +157 -0
  233. package/dist/Toast.js.map +1 -0
  234. package/dist/Tooltip.d.ts +3 -0
  235. package/dist/Tooltip.js +289 -0
  236. package/dist/Tooltip.js.map +1 -0
  237. package/dist/UnifiedAddressAutoComplete.d.ts +2 -0
  238. package/dist/UnifiedAddressAutoComplete.js +23 -0
  239. package/dist/UnifiedAddressAutoComplete.js.map +1 -0
  240. package/dist/Unifier.d.ts +43 -0
  241. package/dist/Unifier.js +154 -0
  242. package/dist/Unifier.js.map +1 -0
  243. package/dist/Utilities.d.ts +56 -0
  244. package/dist/Utilities.js +193 -0
  245. package/dist/Utilities.js.map +1 -0
  246. package/dist/WebAddressAutocomplete.d.ts +3 -0
  247. package/dist/WebAddressAutocomplete.js +61 -0
  248. package/dist/WebAddressAutocomplete.js.map +1 -0
  249. package/dist/fieldElements/FieldError.d.ts +6 -0
  250. package/dist/fieldElements/FieldError.js +9 -0
  251. package/dist/fieldElements/FieldError.js.map +1 -0
  252. package/dist/fieldElements/FieldHelperText.d.ts +6 -0
  253. package/dist/fieldElements/FieldHelperText.js +8 -0
  254. package/dist/fieldElements/FieldHelperText.js.map +1 -0
  255. package/dist/fieldElements/FieldTitle.d.ts +6 -0
  256. package/dist/fieldElements/FieldTitle.js +16 -0
  257. package/dist/fieldElements/FieldTitle.js.map +1 -0
  258. package/dist/fieldElements/index.d.ts +3 -0
  259. package/dist/fieldElements/index.js +4 -0
  260. package/dist/fieldElements/index.js.map +1 -0
  261. package/dist/icons/MobileIcon.d.ts +2 -0
  262. package/dist/icons/MobileIcon.js +18 -0
  263. package/dist/icons/MobileIcon.js.map +1 -0
  264. package/dist/icons/OfflineIcon.d.ts +2 -0
  265. package/dist/icons/OfflineIcon.js +18 -0
  266. package/dist/icons/OfflineIcon.js.map +1 -0
  267. package/dist/icons/OnlineIcon.d.ts +2 -0
  268. package/dist/icons/OnlineIcon.js +19 -0
  269. package/dist/icons/OnlineIcon.js.map +1 -0
  270. package/dist/icons/OutOfficeIcon.d.ts +2 -0
  271. package/dist/icons/OutOfficeIcon.js +18 -0
  272. package/dist/icons/OutOfficeIcon.js.map +1 -0
  273. package/dist/icons/index.d.ts +4 -0
  274. package/dist/icons/index.js +5 -0
  275. package/dist/icons/index.js.map +1 -0
  276. package/dist/index.d.ts +1328 -0
  277. package/dist/index.js +89 -0
  278. package/dist/index.js.map +1 -0
  279. package/dist/table/Table.d.ts +3 -0
  280. package/dist/table/Table.js +53 -0
  281. package/dist/table/Table.js.map +1 -0
  282. package/dist/table/TableBadge.d.ts +6 -0
  283. package/dist/table/TableBadge.js +23 -0
  284. package/dist/table/TableBadge.js.map +1 -0
  285. package/dist/table/TableBoolean.d.ts +6 -0
  286. package/dist/table/TableBoolean.js +37 -0
  287. package/dist/table/TableBoolean.js.map +1 -0
  288. package/dist/table/TableDate.d.ts +3 -0
  289. package/dist/table/TableDate.js +27 -0
  290. package/dist/table/TableDate.js.map +1 -0
  291. package/dist/table/TableHeader.d.ts +6 -0
  292. package/dist/table/TableHeader.js +10 -0
  293. package/dist/table/TableHeader.js.map +1 -0
  294. package/dist/table/TableHeaderCell.d.ts +6 -0
  295. package/dist/table/TableHeaderCell.js +54 -0
  296. package/dist/table/TableHeaderCell.js.map +1 -0
  297. package/dist/table/TableIconButton.d.ts +3 -0
  298. package/dist/table/TableIconButton.js +39 -0
  299. package/dist/table/TableIconButton.js.map +1 -0
  300. package/dist/table/TableNumber.d.ts +3 -0
  301. package/dist/table/TableNumber.js +18 -0
  302. package/dist/table/TableNumber.js.map +1 -0
  303. package/dist/table/TableRow.d.ts +6 -0
  304. package/dist/table/TableRow.js +22 -0
  305. package/dist/table/TableRow.js.map +1 -0
  306. package/dist/table/TableText.d.ts +3 -0
  307. package/dist/table/TableText.js +18 -0
  308. package/dist/table/TableText.js.map +1 -0
  309. package/dist/table/TableTitle.d.ts +3 -0
  310. package/dist/table/TableTitle.js +21 -0
  311. package/dist/table/TableTitle.js.map +1 -0
  312. package/dist/table/tableContext.d.ts +5 -0
  313. package/dist/table/tableContext.js +38 -0
  314. package/dist/table/tableContext.js.map +1 -0
  315. package/dist/useStoredState.d.ts +1 -0
  316. package/dist/useStoredState.js +49 -0
  317. package/dist/useStoredState.js.map +1 -0
  318. package/package.json +123 -0
  319. package/src/Accordion.test.tsx +104 -0
  320. package/src/Accordion.tsx +81 -0
  321. package/src/ActionSheet.tsx +881 -0
  322. package/src/AddressField.test.tsx +120 -0
  323. package/src/AddressField.tsx +122 -0
  324. package/src/Avatar.test.tsx +163 -0
  325. package/src/Avatar.tsx +298 -0
  326. package/src/Badge.test.tsx +116 -0
  327. package/src/Badge.tsx +136 -0
  328. package/src/Banner.tsx +200 -0
  329. package/src/Body.tsx +34 -0
  330. package/src/BooleanField.tsx +141 -0
  331. package/src/Box.test.tsx +662 -0
  332. package/src/Box.tsx +368 -0
  333. package/src/Button.tsx +196 -0
  334. package/src/Card.tsx +19 -0
  335. package/src/CheckBox.tsx +45 -0
  336. package/src/Common.ts +2787 -0
  337. package/src/CommonIconTypes.ts +2030 -0
  338. package/src/Constants.ts +3311 -0
  339. package/src/CustomSelectField.tsx +115 -0
  340. package/src/DataTable.tsx +674 -0
  341. package/src/DateTimeActionSheet.tsx +559 -0
  342. package/src/DateTimeField.test.tsx +393 -0
  343. package/src/DateTimeField.tsx +777 -0
  344. package/src/DateUtilities.test.ts +440 -0
  345. package/src/DateUtilities.tsx +370 -0
  346. package/src/DecimalRangeActionSheet.tsx +85 -0
  347. package/src/DismissButton.tsx +31 -0
  348. package/src/EmailField.tsx +66 -0
  349. package/src/EmojiSelector.test.tsx +61 -0
  350. package/src/EmojiSelector.tsx +510 -0
  351. package/src/ErrorBoundary.tsx +37 -0
  352. package/src/ErrorPage.tsx +41 -0
  353. package/src/Field.tsx +101 -0
  354. package/src/FlatList.tsx +2 -0
  355. package/src/Heading.tsx +66 -0
  356. package/src/HeightActionSheet.tsx +91 -0
  357. package/src/Hyperlink.tsx +179 -0
  358. package/src/Icon.tsx +36 -0
  359. package/src/IconButton.tsx +217 -0
  360. package/src/Image.tsx +51 -0
  361. package/src/ImageBackground.tsx +14 -0
  362. package/src/InfoModalIcon.tsx +42 -0
  363. package/src/InfoTooltipButton.tsx +16 -0
  364. package/src/Link.tsx +22 -0
  365. package/src/MarkdownView.tsx +67 -0
  366. package/src/MediaQuery.ts +46 -0
  367. package/src/MobileAddressAutoComplete.tsx +126 -0
  368. package/src/Modal.tsx +300 -0
  369. package/src/ModalSheet.tsx +58 -0
  370. package/src/MultiselectField.tsx +112 -0
  371. package/src/NumberField.tsx +67 -0
  372. package/src/NumberPickerActionSheet.tsx +51 -0
  373. package/src/OpenAPIContext.tsx +74 -0
  374. package/src/Page.tsx +105 -0
  375. package/src/Pagination.tsx +169 -0
  376. package/src/PasswordField.tsx +7 -0
  377. package/src/Permissions.ts +43 -0
  378. package/src/PhoneNumberField.tsx +109 -0
  379. package/src/PickerSelect.tsx +571 -0
  380. package/src/Radio.tsx +33 -0
  381. package/src/RadioField.tsx +43 -0
  382. package/src/ScrollView.tsx +2 -0
  383. package/src/SectionDivider.tsx +18 -0
  384. package/src/SegmentedControl.tsx +126 -0
  385. package/src/SelectBadge.tsx +280 -0
  386. package/src/SelectField.tsx +41 -0
  387. package/src/SideDrawer.tsx +56 -0
  388. package/src/Signature.native.tsx +57 -0
  389. package/src/Signature.tsx +44 -0
  390. package/src/SignatureField.tsx +92 -0
  391. package/src/Slider.tsx +199 -0
  392. package/src/Spinner.tsx +35 -0
  393. package/src/SplitPage.native.tsx +163 -0
  394. package/src/SplitPage.tsx +304 -0
  395. package/src/TapToEdit.tsx +292 -0
  396. package/src/TerrenoProvider.tsx +31 -0
  397. package/src/Text.tsx +123 -0
  398. package/src/TextArea.test.tsx +255 -0
  399. package/src/TextArea.tsx +8 -0
  400. package/src/TextField.test.tsx +487 -0
  401. package/src/TextField.tsx +260 -0
  402. package/src/TextFieldNumberActionSheet.tsx +46 -0
  403. package/src/Theme.tsx +248 -0
  404. package/src/TimezonePicker.tsx +45 -0
  405. package/src/Toast.tsx +234 -0
  406. package/src/Tooltip.tsx +407 -0
  407. package/src/UnifiedAddressAutoComplete.tsx +66 -0
  408. package/src/Unifier.ts +172 -0
  409. package/src/Utilities.tsx +329 -0
  410. package/src/WebAddressAutocomplete.tsx +84 -0
  411. package/src/__snapshots__/Accordion.test.tsx.snap +126 -0
  412. package/src/__snapshots__/AddressField.test.tsx.snap +1197 -0
  413. package/src/__snapshots__/Avatar.test.tsx.snap +57 -0
  414. package/src/__snapshots__/Badge.test.tsx.snap +55 -0
  415. package/src/__snapshots__/Box.test.tsx.snap +162 -0
  416. package/src/__snapshots__/EmojiSelector.test.tsx.snap +422 -0
  417. package/src/__snapshots__/TextArea.test.tsx.snap +521 -0
  418. package/src/__snapshots__/TextField.test.tsx.snap +569 -0
  419. package/src/bunSetup.ts +1235 -0
  420. package/src/fieldElements/FieldError.tsx +24 -0
  421. package/src/fieldElements/FieldHelperText.tsx +20 -0
  422. package/src/fieldElements/FieldTitle.tsx +31 -0
  423. package/src/fieldElements/index.tsx +3 -0
  424. package/src/icons/MobileIcon.tsx +40 -0
  425. package/src/icons/OfflineIcon.tsx +37 -0
  426. package/src/icons/OnlineIcon.tsx +39 -0
  427. package/src/icons/OutOfficeIcon.tsx +36 -0
  428. package/src/icons/index.ts +4 -0
  429. package/src/index.tsx +1375 -0
  430. package/src/polyfill.d.ts +11 -0
  431. package/src/table/Table.tsx +109 -0
  432. package/src/table/TableBadge.tsx +46 -0
  433. package/src/table/TableBoolean.tsx +70 -0
  434. package/src/table/TableDate.tsx +38 -0
  435. package/src/table/TableHeader.tsx +20 -0
  436. package/src/table/TableHeaderCell.tsx +94 -0
  437. package/src/table/TableIconButton.tsx +61 -0
  438. package/src/table/TableNumber.tsx +29 -0
  439. package/src/table/TableRow.tsx +67 -0
  440. package/src/table/TableText.tsx +29 -0
  441. package/src/table/TableTitle.tsx +31 -0
  442. package/src/table/tableContext.tsx +67 -0
  443. package/src/test-utils.tsx +27 -0
  444. package/src/types/react-native-swiper-flatlist.d.ts +56 -0
  445. package/src/useStoredState.test.tsx +143 -0
  446. package/src/useStoredState.ts +56 -0
@@ -0,0 +1,881 @@
1
+ import type React from "react";
2
+ import {Component, createRef} from "react";
3
+ import {
4
+ Animated,
5
+ Dimensions,
6
+ type EmitterSubscription,
7
+ FlatList,
8
+ findNodeHandle,
9
+ Keyboard,
10
+ type KeyboardEvent,
11
+ type LayoutChangeEvent,
12
+ Modal,
13
+ type NativeScrollEvent,
14
+ type NativeSyntheticEvent,
15
+ Platform,
16
+ Pressable,
17
+ SafeAreaView,
18
+ StatusBar,
19
+ StyleSheet,
20
+ TextInput,
21
+ UIManager,
22
+ View,
23
+ } from "react-native";
24
+
25
+ import type {ActionSheetProps} from "./Common";
26
+
27
+ export const styles = StyleSheet.create({
28
+ container: {
29
+ alignSelf: "center",
30
+ backgroundColor: "white",
31
+ width: "100%",
32
+ },
33
+ indicator: {
34
+ alignSelf: "center",
35
+ backgroundColor: "#f0f0f0",
36
+ borderRadius: 100,
37
+ height: 6,
38
+ marginVertical: 5,
39
+ width: 45,
40
+ },
41
+ parentContainer: {
42
+ alignItems: "center",
43
+ height: "100%",
44
+ justifyContent: "center",
45
+ width: "100%",
46
+ },
47
+ safearea: {
48
+ left: 999999,
49
+ position: "absolute",
50
+ top: 999999,
51
+ },
52
+ scrollView: {
53
+ backgroundColor: "transparent",
54
+ height: "100%",
55
+ width: "100%",
56
+ },
57
+ });
58
+
59
+ export function getDeviceHeight(statusBarTranslucent: boolean | undefined): number {
60
+ const height = Dimensions.get("window").height;
61
+
62
+ if (Platform.OS === "android" && !statusBarTranslucent) {
63
+ return StatusBar.currentHeight ? height - StatusBar.currentHeight : height;
64
+ }
65
+
66
+ return height;
67
+ }
68
+
69
+ export const getElevation = (elevation?: number) => {
70
+ if (!elevation) {
71
+ return {};
72
+ }
73
+ return {
74
+ boxShadow: `${0.3 * elevation}px ${0.5 * elevation}px ${0.7 * elevation}px rgba(0, 0, 0, 0.2)`,
75
+ elevation,
76
+ };
77
+ };
78
+
79
+ export const SUPPORTED_ORIENTATIONS: (
80
+ | "portrait"
81
+ | "portrait-upside-down"
82
+ | "landscape"
83
+ | "landscape-left"
84
+ | "landscape-right"
85
+ )[] = ["portrait", "portrait-upside-down", "landscape", "landscape-left", "landscape-right"];
86
+
87
+ export const waitAsync = (ms: number): Promise<null> =>
88
+ new Promise((resolve) => {
89
+ setTimeout(() => {
90
+ resolve(null);
91
+ }, ms);
92
+ });
93
+
94
+ const safeAreaInnerHeight = 0;
95
+ const dummyData = ["dummy"];
96
+ let safeAreaPaddingTop = Platform.OS === "android" ? StatusBar.currentHeight || 0 : 0;
97
+ let calculatedDeviceHeight = Dimensions.get("window").height;
98
+
99
+ type State = {
100
+ modalVisible: boolean;
101
+ scrollable: boolean;
102
+ layoutHasCalled: boolean;
103
+ keyboard: boolean;
104
+ deviceHeight: number;
105
+ deviceWidth: number;
106
+ portrait: boolean;
107
+ safeAreaInnerHeight: number;
108
+ paddingTop: number;
109
+ };
110
+
111
+ const defaultProps = {
112
+ animated: true,
113
+ bottomOffset: 0,
114
+ bounciness: 8,
115
+ closable: true,
116
+ closeAnimationDuration: 300,
117
+ closeOnPressBack: true,
118
+ closeOnTouchBackdrop: true,
119
+ defaultOverlayOpacity: 0.3,
120
+ delayActionSheetDrawTime: 0,
121
+ drawUnderStatusBar: true,
122
+ elevation: 5,
123
+ extraScroll: 0,
124
+ gestureEnabled: false,
125
+ indicatorColor: "#f0f0f0",
126
+ initialOffsetFromBottom: 1,
127
+ keyboardMode: "padding",
128
+ openAnimationSpeed: 12,
129
+ overlayColor: "black",
130
+ springOffset: 100,
131
+ statusBarTranslucent: true,
132
+ };
133
+
134
+ type Props = Partial<typeof defaultProps> & ActionSheetProps;
135
+
136
+ export class ActionSheet extends Component<Props, State, any> {
137
+ static defaultProps = defaultProps;
138
+
139
+ actionSheetHeight = 0;
140
+
141
+ keyboardDidShowListener: EmitterSubscription | null = null;
142
+
143
+ keyboardDidHideListener: EmitterSubscription | null = null;
144
+
145
+ prevScroll = 0;
146
+
147
+ timeout: any | null = null;
148
+
149
+ offsetY = 0;
150
+
151
+ currentOffsetFromBottom = 0;
152
+
153
+ scrollAnimationEndValue = 0;
154
+
155
+ hasBounced = false;
156
+
157
+ layoutHasCalled = false;
158
+
159
+ isClosing = false;
160
+
161
+ isRecoiling = false;
162
+
163
+ isReachedTop = false;
164
+
165
+ deviceLayoutCalled = false;
166
+
167
+ scrollViewRef: React.RefObject<any>;
168
+
169
+ safeAreaViewRef: React.RefObject<any>;
170
+
171
+ transformValue: Animated.Value;
172
+
173
+ opacityValue: Animated.Value;
174
+
175
+ borderRadius: Animated.Value;
176
+
177
+ underlayTranslateY: Animated.Value;
178
+
179
+ underlayScale: Animated.Value;
180
+
181
+ indicatorTranslateY: Animated.Value;
182
+
183
+ constructor(props: ActionSheetProps) {
184
+ super(props);
185
+ this.state = {
186
+ deviceHeight: calculatedDeviceHeight || getDeviceHeight(this.props.statusBarTranslucent),
187
+ deviceWidth: Dimensions.get("window").width,
188
+ keyboard: false,
189
+ layoutHasCalled: false,
190
+ modalVisible: false,
191
+ paddingTop: safeAreaPaddingTop,
192
+ portrait: true,
193
+ safeAreaInnerHeight,
194
+ scrollable: false,
195
+ };
196
+
197
+ this.actionSheetHeight = 0;
198
+ this.prevScroll = 0;
199
+ this.scrollAnimationEndValue = 0;
200
+ this.hasBounced = false;
201
+ this.scrollViewRef = createRef();
202
+ this.layoutHasCalled = false;
203
+ this.isClosing = false;
204
+ this.isRecoiling = false;
205
+ this.offsetY = 0;
206
+ this.safeAreaViewRef = createRef();
207
+ this.transformValue = new Animated.Value(0);
208
+ this.opacityValue = new Animated.Value(0);
209
+ this.borderRadius = new Animated.Value(10);
210
+ this.currentOffsetFromBottom = this.props.initialOffsetFromBottom as number;
211
+ this.underlayTranslateY = new Animated.Value(100);
212
+ this.underlayScale = new Animated.Value(1);
213
+ this.indicatorTranslateY = new Animated.Value(-this.state.paddingTop | 0);
214
+ this.isReachedTop = false;
215
+ this.deviceLayoutCalled = false;
216
+ this.timeout = null;
217
+ }
218
+
219
+ /**
220
+ * Snap ActionSheet to Offset
221
+ */
222
+
223
+ snapToOffset = (offset: number) => {
224
+ const correction = this.state.deviceHeight * 0.15;
225
+ const extraScroll = this.props.extraScroll || 0;
226
+ const scrollOffset = this.props.gestureEnabled
227
+ ? offset + correction + extraScroll
228
+ : offset + correction + extraScroll;
229
+ this.currentOffsetFromBottom = offset / this.actionSheetHeight;
230
+ this._scrollTo(scrollOffset);
231
+ this.updateActionSheetPosition(scrollOffset);
232
+ };
233
+
234
+ // Open the ActionSheet
235
+ show = () => {
236
+ this.setModalVisible(true);
237
+ };
238
+
239
+ // Close the ActionSheet
240
+ hide = () => {
241
+ this.setModalVisible(false);
242
+ };
243
+
244
+ /**
245
+ * Open/Close the ActionSheet
246
+ */
247
+ setModalVisible = (visible: boolean) => {
248
+ let modalVisible = this.state.modalVisible;
249
+ if (visible !== undefined) {
250
+ if (modalVisible === visible) {
251
+ return;
252
+ }
253
+ modalVisible = !visible;
254
+ }
255
+
256
+ if (!modalVisible) {
257
+ this.setState({
258
+ modalVisible: true,
259
+ scrollable: this.props.gestureEnabled || false,
260
+ });
261
+ } else {
262
+ this._hideModal();
263
+ }
264
+ };
265
+
266
+ _hideAnimation() {
267
+ const {
268
+ animated,
269
+ closeAnimationDuration,
270
+ bottomOffset,
271
+ initialOffsetFromBottom,
272
+ extraScroll,
273
+ closable,
274
+ } = this.props;
275
+
276
+ Animated.parallel([
277
+ Animated.timing(this.opacityValue, {
278
+ duration: animated ? closeAnimationDuration : 1,
279
+ toValue: closable ? 0 : 1,
280
+ useNativeDriver: true,
281
+ }),
282
+ Animated.timing(this.transformValue, {
283
+ duration: animated ? closeAnimationDuration : 1,
284
+ toValue: closable ? this.actionSheetHeight * 2 : 0,
285
+ useNativeDriver: true,
286
+ }),
287
+ ]).start();
288
+
289
+ void waitAsync((closeAnimationDuration as number) / 1.5).then(() => {
290
+ if (!closable) {
291
+ if (bottomOffset && bottomOffset > 0) {
292
+ this.snapToOffset(bottomOffset);
293
+ } else {
294
+ this._scrollTo(
295
+ ((this.actionSheetHeight * (initialOffsetFromBottom || 0)) as number) +
296
+ this.state.deviceHeight * 0.1 +
297
+ (extraScroll ?? 0),
298
+ true
299
+ );
300
+ this.currentOffsetFromBottom = initialOffsetFromBottom as number;
301
+ }
302
+
303
+ this.isClosing = false;
304
+ } else {
305
+ this._scrollTo(0, false);
306
+ this.currentOffsetFromBottom = initialOffsetFromBottom as number;
307
+ this.setState(
308
+ {
309
+ modalVisible: !closable,
310
+ },
311
+ () => {
312
+ this.isClosing = false;
313
+ this.isReachedTop = false;
314
+ this.props.onPositionChanged?.(false);
315
+ this.indicatorTranslateY.setValue(-this.state.paddingTop);
316
+ this.layoutHasCalled = false;
317
+ this.deviceLayoutCalled = false;
318
+ this.props.onClose?.();
319
+ }
320
+ );
321
+ }
322
+ });
323
+ }
324
+
325
+ _hideModal = () => {
326
+ if (this.isClosing) return;
327
+ this.isClosing = true;
328
+ this._hideAnimation();
329
+ };
330
+
331
+ measure = async (): Promise<number> => {
332
+ return new Promise((resolve) => {
333
+ setTimeout(() => {
334
+ UIManager.measureInWindow(
335
+ this.safeAreaViewRef.current._nativeTag,
336
+ (_x, _y, _width, height) => {
337
+ safeAreaPaddingTop = height;
338
+ resolve(height === 0 ? 20 : height);
339
+ }
340
+ );
341
+ }, 100);
342
+ });
343
+ };
344
+
345
+ _showModal = async (event: LayoutChangeEvent) => {
346
+ const {gestureEnabled, delayActionSheetDraw, delayActionSheetDrawTime} = this.props;
347
+
348
+ if (!event?.nativeEvent) return;
349
+ const height = event.nativeEvent.layout.height;
350
+ if (this.layoutHasCalled) {
351
+ this.actionSheetHeight = height;
352
+ this._returnToPrevScrollPosition(height);
353
+ return;
354
+ } else {
355
+ this.layoutHasCalled = true;
356
+ this.actionSheetHeight = height;
357
+ const scrollOffset = this.getInitialScrollPosition();
358
+ this.isRecoiling = false;
359
+ if (Platform.OS === "ios") {
360
+ await waitAsync(delayActionSheetDrawTime as number);
361
+ } else {
362
+ if (delayActionSheetDraw) {
363
+ await waitAsync(delayActionSheetDrawTime as number);
364
+ }
365
+ }
366
+ this._scrollTo(scrollOffset, false);
367
+ this.prevScroll = scrollOffset;
368
+ if (Platform.OS === "ios") {
369
+ await waitAsync(delayActionSheetDrawTime ?? 0 / 2);
370
+ } else {
371
+ if (delayActionSheetDraw) {
372
+ await waitAsync(delayActionSheetDrawTime ?? 0 / 2);
373
+ }
374
+ }
375
+ this._openAnimation(scrollOffset);
376
+ this.underlayScale.setValue(1);
377
+ this.underlayTranslateY.setValue(100);
378
+ if (!gestureEnabled) {
379
+ this.props.onPositionChanged?.(true);
380
+ }
381
+ this.updateActionSheetPosition(scrollOffset);
382
+ }
383
+ };
384
+
385
+ _openAnimation = (scrollOffset: number) => {
386
+ const {bounciness, bounceOnOpen, animated, openAnimationSpeed} = this.props;
387
+
388
+ if (animated) {
389
+ this.transformValue.setValue(scrollOffset);
390
+ Animated.parallel([
391
+ Animated.spring(this.transformValue, {
392
+ bounciness: bounceOnOpen ? bounciness : 1,
393
+ speed: openAnimationSpeed,
394
+ toValue: 0,
395
+ useNativeDriver: true,
396
+ }),
397
+ Animated.timing(this.opacityValue, {
398
+ duration: 150,
399
+ toValue: 1,
400
+ useNativeDriver: true,
401
+ }),
402
+ ]).start();
403
+ } else {
404
+ this.opacityValue.setValue(1);
405
+ }
406
+ };
407
+
408
+ _onScrollBegin = async () => {};
409
+
410
+ _onScrollBeginDrag = async (event: NativeSyntheticEvent<NativeScrollEvent>) => {
411
+ this.prevScroll = event.nativeEvent.contentOffset.y;
412
+ };
413
+
414
+ _applyHeightLimiter() {
415
+ if (this.actionSheetHeight > this.state.deviceHeight) {
416
+ this.actionSheetHeight =
417
+ this.actionSheetHeight - (this.actionSheetHeight - this.state.deviceHeight);
418
+ }
419
+ }
420
+
421
+ _onScrollEnd = async (event: NativeSyntheticEvent<NativeScrollEvent>) => {
422
+ const {springOffset, extraScroll} = this.props;
423
+ const verticalOffset = event.nativeEvent.contentOffset.y;
424
+
425
+ const correction = this.state.deviceHeight * 0.15;
426
+ if (this.isRecoiling) return;
427
+
428
+ if (this.prevScroll < verticalOffset) {
429
+ if (verticalOffset - this.prevScroll > (springOffset ?? 0) * 0.75) {
430
+ this.isRecoiling = true;
431
+
432
+ this._applyHeightLimiter();
433
+ this.currentOffsetFromBottom =
434
+ this.currentOffsetFromBottom < (this.props.initialOffsetFromBottom ?? 0)
435
+ ? (this.props.initialOffsetFromBottom as number)
436
+ : 1;
437
+ const scrollOffset =
438
+ this.actionSheetHeight * this.currentOffsetFromBottom + correction + (extraScroll ?? 0);
439
+
440
+ this._scrollTo(scrollOffset);
441
+ await waitAsync(300);
442
+ this.isRecoiling = false;
443
+ this.props.onPositionChanged?.(true);
444
+ } else {
445
+ this._returnToPrevScrollPosition(this.actionSheetHeight);
446
+ }
447
+ } else {
448
+ if (this.prevScroll - verticalOffset > (springOffset ?? 0)) {
449
+ this._hideModal();
450
+ } else {
451
+ if (this.isRecoiling) {
452
+ return;
453
+ }
454
+
455
+ this.isRecoiling = true;
456
+ this._returnToPrevScrollPosition(this.actionSheetHeight);
457
+ await waitAsync(300);
458
+ this.isRecoiling = false;
459
+ }
460
+ }
461
+ };
462
+
463
+ updateActionSheetPosition(scrollPosition: number) {
464
+ if (this.actionSheetHeight >= this.state.deviceHeight - 1) {
465
+ const correction = this.state.deviceHeight * 0.15;
466
+ const distanceFromTop = this.actionSheetHeight + correction - scrollPosition;
467
+ if (distanceFromTop < safeAreaPaddingTop) {
468
+ if (!this.props.drawUnderStatusBar) return;
469
+ this.indicatorTranslateY.setValue(0);
470
+ } else {
471
+ this.indicatorTranslateY.setValue(-safeAreaPaddingTop);
472
+ }
473
+ }
474
+ }
475
+
476
+ _returnToPrevScrollPosition(height: number) {
477
+ const correction = this.state.deviceHeight * 0.15;
478
+ const scrollOffset =
479
+ height * this.currentOffsetFromBottom + correction + (this.props.extraScroll ?? 0);
480
+
481
+ this.updateActionSheetPosition(scrollOffset);
482
+ this._scrollTo(scrollOffset);
483
+ }
484
+
485
+ _scrollTo = (y: number, animated = true) => {
486
+ this.scrollAnimationEndValue = y;
487
+ this.prevScroll = y;
488
+ this.scrollViewRef.current?._listRef._scrollRef.scrollTo({
489
+ animated,
490
+ x: 0,
491
+ y: this.scrollAnimationEndValue,
492
+ });
493
+ };
494
+
495
+ _onTouchMove = () => {
496
+ if (this.props.closeOnTouchBackdrop) {
497
+ this._hideModal();
498
+ }
499
+ this.setState({
500
+ scrollable: false,
501
+ });
502
+ };
503
+
504
+ _onTouchStart = () => {
505
+ if (this.props.closeOnTouchBackdrop) {
506
+ this._hideModal();
507
+ }
508
+ this.setState({
509
+ scrollable: false,
510
+ });
511
+ };
512
+
513
+ _onTouchEnd = () => {
514
+ this._returnToPrevScrollPosition(this.actionSheetHeight);
515
+ if (this.props.gestureEnabled) {
516
+ this.setState({
517
+ scrollable: true,
518
+ });
519
+ }
520
+ };
521
+
522
+ _onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
523
+ this.offsetY = event.nativeEvent.contentOffset.y;
524
+
525
+ const correction = this.state.deviceHeight * 0.15;
526
+ const distanceFromTop = this.actionSheetHeight + correction - this.offsetY;
527
+
528
+ if (this.actionSheetHeight < this.offsetY) {
529
+ if (!this.isReachedTop) {
530
+ this.isReachedTop = true;
531
+ this.props.onPositionChanged?.(true);
532
+ }
533
+ } else {
534
+ if (this.isReachedTop) {
535
+ this.isReachedTop = false;
536
+ this.props.onPositionChanged?.(false);
537
+ }
538
+ }
539
+
540
+ if (this.actionSheetHeight >= this.state.deviceHeight - 1) {
541
+ if (distanceFromTop < safeAreaPaddingTop) {
542
+ if (!this.props.drawUnderStatusBar) return;
543
+
544
+ this.indicatorTranslateY.setValue(
545
+ -this.state.paddingTop + (safeAreaPaddingTop - distanceFromTop)
546
+ );
547
+ } else {
548
+ this.indicatorTranslateY.setValue(-safeAreaPaddingTop);
549
+ }
550
+ }
551
+ };
552
+
553
+ _onRequestClose = () => {
554
+ if (this.props.closeOnPressBack) this._hideModal();
555
+ };
556
+
557
+ _onTouchBackdrop = () => {
558
+ if (this.props.closeOnTouchBackdrop) {
559
+ this._hideModal();
560
+ }
561
+ };
562
+
563
+ componentDidMount() {
564
+ this.keyboardDidShowListener = Keyboard.addListener(
565
+ Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow",
566
+ this._onKeyboardShow
567
+ );
568
+
569
+ this.keyboardDidHideListener = Keyboard.addListener(
570
+ Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide",
571
+ this._onKeyboardHide
572
+ );
573
+ }
574
+
575
+ _onKeyboardShow = (event: KeyboardEvent) => {
576
+ this.setState({
577
+ keyboard: true,
578
+ });
579
+ const ReactNativeVersion = require("react-native/Libraries/Core/ReactNativeVersion");
580
+
581
+ let v = ReactNativeVersion.version.major + ReactNativeVersion.version.minor;
582
+ v = parseInt(v, 10);
583
+
584
+ if (v >= 63 || Platform.OS === "ios") {
585
+ const keyboardHeight = event.endCoordinates.height;
586
+ const {height: windowHeight} = Dimensions.get("window");
587
+
588
+ const currentlyFocusedField = TextInput.State.currentlyFocusedField
589
+ ? findNodeHandle(TextInput.State.currentlyFocusedField())
590
+ : TextInput.State.currentlyFocusedField();
591
+
592
+ if (!currentlyFocusedField) {
593
+ return;
594
+ }
595
+
596
+ UIManager.measure(
597
+ currentlyFocusedField,
598
+ (_originX, _originY, _width, height, _pageX, pageY) => {
599
+ const fieldHeight = height;
600
+ const gap = windowHeight - keyboardHeight - (pageY + fieldHeight);
601
+ if (gap >= 0) {
602
+ return;
603
+ }
604
+ const toValue =
605
+ this.props.keyboardMode === "position" ? -(keyboardHeight + 15) : gap - 10;
606
+
607
+ Animated.timing(this.transformValue, {
608
+ duration: 250,
609
+ toValue,
610
+ useNativeDriver: true,
611
+ }).start();
612
+ }
613
+ );
614
+ } else {
615
+ Animated.timing(this.transformValue, {
616
+ duration: 250,
617
+ toValue: -10,
618
+ useNativeDriver: true,
619
+ }).start();
620
+ }
621
+ };
622
+
623
+ /**
624
+ * Attach this to any child ScrollView Component's onScrollEndDrag,
625
+ * onMomentumScrollEnd,onScrollAnimationEnd callbacks to handle the ActionSheet
626
+ * closing and bouncing back properly.
627
+ */
628
+
629
+ handleChildScrollEnd = async () => {
630
+ if (this.offsetY > this.prevScroll) return;
631
+ if (this.prevScroll - (this.props.springOffset ?? 0) > this.offsetY) {
632
+ const scrollOffset = this.getInitialScrollPosition();
633
+ if (this.offsetY > scrollOffset - 100) {
634
+ this.isRecoiling = true;
635
+ this._scrollTo(scrollOffset);
636
+ this.currentOffsetFromBottom = this.props.initialOffsetFromBottom ?? 0;
637
+ this.prevScroll = scrollOffset;
638
+ setTimeout(() => {
639
+ this.isRecoiling = false;
640
+ }, 500);
641
+ } else {
642
+ this._hideModal();
643
+ }
644
+ } else {
645
+ this.isRecoiling = true;
646
+ this._scrollTo(this.prevScroll, true);
647
+ setTimeout(() => {
648
+ this.isRecoiling = false;
649
+ }, 500);
650
+ }
651
+ };
652
+
653
+ _onKeyboardHide = () => {
654
+ this.setState({
655
+ keyboard: false,
656
+ });
657
+ this.opacityValue.setValue(1);
658
+ Animated.timing(this.transformValue, {
659
+ duration: 100,
660
+ toValue: 0,
661
+ useNativeDriver: true,
662
+ }).start();
663
+ };
664
+
665
+ componentWillUnmount() {
666
+ this.keyboardDidShowListener?.remove();
667
+ this.keyboardDidHideListener?.remove();
668
+ }
669
+
670
+ _onDeviceLayout = async (_event: any) => {
671
+ const event = {..._event};
672
+
673
+ if (this.timeout) {
674
+ clearTimeout(this.timeout);
675
+ }
676
+
677
+ this.timeout = setTimeout(async () => {
678
+ let safeMarginFromTop = 0;
679
+ const measuredPadding =
680
+ Platform.OS === "ios" ? await this.measure() : StatusBar.currentHeight;
681
+
682
+ if (!this.props.drawUnderStatusBar) {
683
+ if (Platform.OS === "android" && !this.props.statusBarTranslucent) return;
684
+ safeMarginFromTop = measuredPadding ?? 0;
685
+ this.indicatorTranslateY.setValue(-(measuredPadding as number));
686
+ } else {
687
+ this.updateActionSheetPosition(this.offsetY);
688
+ }
689
+ const height = event.nativeEvent.layout.height - safeMarginFromTop;
690
+ const width = Dimensions.get("window").width;
691
+ if (
692
+ height?.toFixed(0) === calculatedDeviceHeight?.toFixed(0) &&
693
+ width?.toFixed(0) === this.state.deviceWidth?.toFixed(0) &&
694
+ this.deviceLayoutCalled
695
+ )
696
+ return;
697
+ this.deviceLayoutCalled = true;
698
+ calculatedDeviceHeight = height;
699
+ this.setState({
700
+ deviceHeight: height,
701
+ deviceWidth: width,
702
+ paddingTop: measuredPadding ?? 0,
703
+ portrait: height > width,
704
+ });
705
+ }, 1);
706
+ };
707
+
708
+ getInitialScrollPosition() {
709
+ this._applyHeightLimiter();
710
+ const correction = this.state.deviceHeight * 0.15;
711
+ const scrollPosition = this.props.gestureEnabled
712
+ ? this.actionSheetHeight * (this.props.initialOffsetFromBottom ?? 0) +
713
+ correction +
714
+ (this.props.extraScroll ?? 0)
715
+ : this.actionSheetHeight + correction + (this.props.extraScroll ?? 0);
716
+ this.currentOffsetFromBottom = this.props.initialOffsetFromBottom ?? 0;
717
+ this.updateActionSheetPosition(scrollPosition);
718
+
719
+ return scrollPosition;
720
+ }
721
+
722
+ _keyExtractor = (item: any) => item;
723
+
724
+ render() {
725
+ const {scrollable, modalVisible, keyboard} = this.state;
726
+ const {
727
+ onOpen,
728
+ overlayColor,
729
+ gestureEnabled,
730
+ elevation,
731
+ indicatorColor,
732
+ defaultOverlayOpacity,
733
+ children,
734
+ containerStyle,
735
+ CustomHeaderComponent,
736
+ headerAlwaysVisible,
737
+ keyboardShouldPersistTaps,
738
+ statusBarTranslucent,
739
+ } = this.props;
740
+
741
+ return (
742
+ <Modal
743
+ animationType="none"
744
+ onRequestClose={this._onRequestClose}
745
+ // testID={testID}
746
+ onShow={onOpen}
747
+ statusBarTranslucent={statusBarTranslucent}
748
+ supportedOrientations={SUPPORTED_ORIENTATIONS}
749
+ transparent
750
+ visible={modalVisible}
751
+ >
752
+ <Animated.View
753
+ onLayout={this._onDeviceLayout}
754
+ style={[
755
+ styles.parentContainer,
756
+ {
757
+ opacity: this.opacityValue,
758
+ width: this.state.deviceWidth,
759
+ },
760
+ ]}
761
+ >
762
+ <SafeAreaView ref={this.safeAreaViewRef} style={styles.safearea}>
763
+ <View />
764
+ </SafeAreaView>
765
+ <FlatList
766
+ bounces={false}
767
+ contentContainerStyle={{
768
+ width: this.state.deviceWidth,
769
+ }}
770
+ data={dummyData}
771
+ keyboardShouldPersistTaps={keyboardShouldPersistTaps}
772
+ keyExtractor={this._keyExtractor}
773
+ onMomentumScrollBegin={this._onScrollBegin}
774
+ onMomentumScrollEnd={this._onScrollEnd}
775
+ onScroll={this._onScroll}
776
+ onScrollBeginDrag={this._onScrollBeginDrag}
777
+ onTouchEnd={this._onTouchEnd}
778
+ ref={this.scrollViewRef}
779
+ renderItem={() => (
780
+ <View
781
+ style={{
782
+ width: "100%",
783
+ }}
784
+ >
785
+ <Animated.View
786
+ onTouchEnd={this._onTouchBackdrop}
787
+ onTouchMove={this._onTouchBackdrop}
788
+ onTouchStart={this._onTouchBackdrop}
789
+ style={{
790
+ backgroundColor: overlayColor,
791
+ height: "100%",
792
+ opacity: defaultOverlayOpacity,
793
+ position: "absolute",
794
+ width: "100%",
795
+ zIndex: 1,
796
+ }}
797
+ />
798
+ <View
799
+ onTouchEnd={this._onTouchEnd}
800
+ onTouchMove={this._onTouchMove}
801
+ onTouchStart={this._onTouchStart}
802
+ style={{
803
+ height: this.state.deviceHeight * 1.15,
804
+ width: "100%",
805
+ zIndex: 10,
806
+ }}
807
+ >
808
+ <Pressable
809
+ aria-role="button"
810
+ onLongPress={this._onTouchBackdrop}
811
+ onPress={this._onTouchBackdrop}
812
+ style={{
813
+ height: this.state.deviceHeight * 1.15,
814
+ width: "100%",
815
+ }}
816
+ />
817
+ </View>
818
+
819
+ <Animated.View
820
+ onLayout={this._showModal}
821
+ style={[
822
+ styles.container,
823
+ {
824
+ borderRadius: 10,
825
+ },
826
+ containerStyle,
827
+ {
828
+ ...getElevation(elevation),
829
+ maxHeight: this.state.deviceHeight,
830
+ opacity: this.opacityValue,
831
+ transform: [
832
+ {
833
+ translateY: this.transformValue,
834
+ },
835
+ ],
836
+ zIndex: 11,
837
+ },
838
+ ]}
839
+ >
840
+ <Animated.View
841
+ style={{
842
+ marginTop: this.state.paddingTop,
843
+ maxHeight: this.state.deviceHeight,
844
+ transform: [
845
+ {
846
+ translateY: this.indicatorTranslateY,
847
+ },
848
+ ],
849
+ }}
850
+ >
851
+ {gestureEnabled || headerAlwaysVisible ? (
852
+ CustomHeaderComponent ? (
853
+ CustomHeaderComponent
854
+ ) : (
855
+ <Animated.View
856
+ style={[styles.indicator, {backgroundColor: indicatorColor}]}
857
+ />
858
+ )
859
+ ) : null}
860
+
861
+ {children}
862
+ </Animated.View>
863
+ </Animated.View>
864
+ </View>
865
+ )}
866
+ scrollEnabled={scrollable && !keyboard}
867
+ scrollEventThrottle={5}
868
+ scrollsToTop={false}
869
+ showsVerticalScrollIndicator={false}
870
+ style={[
871
+ styles.scrollView,
872
+ {
873
+ width: this.state.deviceWidth,
874
+ },
875
+ ]}
876
+ />
877
+ </Animated.View>
878
+ </Modal>
879
+ );
880
+ }
881
+ }