@draftbit/core 46.0.0 → 46.0.1-d651f1.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 (366) hide show
  1. package/lib/commonjs/Provider.js.map +1 -1
  2. package/lib/commonjs/components/ActionSheet/ActionSheetCancel.js.map +1 -1
  3. package/lib/commonjs/components/ActionSheet/ActionSheetItem.js.map +1 -1
  4. package/lib/commonjs/components/AnimatedCircularProgress.js.map +1 -1
  5. package/lib/commonjs/components/AspectRatio.js.map +1 -1
  6. package/lib/commonjs/components/AvatarEdit.js.map +1 -1
  7. package/lib/commonjs/components/Banner.js.map +1 -1
  8. package/lib/commonjs/components/Card.js.map +1 -1
  9. package/lib/commonjs/components/CardBlock.js.map +1 -1
  10. package/lib/commonjs/components/CardContainer.js.map +1 -1
  11. package/lib/commonjs/components/CardContainerRating.js.map +1 -1
  12. package/lib/commonjs/components/CardContainerShortImage.js.map +1 -1
  13. package/lib/commonjs/components/CardInline.js.map +1 -1
  14. package/lib/commonjs/components/Carousel.js.map +1 -1
  15. package/lib/commonjs/components/CircleImage.js.map +1 -1
  16. package/lib/commonjs/components/CircularProgress.js.map +1 -1
  17. package/lib/commonjs/components/Container.js.map +1 -1
  18. package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
  19. package/lib/commonjs/components/DatePicker/DatePickerComponent.js.map +1 -1
  20. package/lib/commonjs/components/DeprecatedButton.js +20 -4
  21. package/lib/commonjs/components/DeprecatedButton.js.map +1 -1
  22. package/lib/commonjs/components/DeprecatedCardWrapper.js +14 -2
  23. package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
  24. package/lib/commonjs/components/DeprecatedFAB.js.map +1 -1
  25. package/lib/commonjs/components/Divider.js.map +1 -1
  26. package/lib/commonjs/components/Elevation.js.map +1 -1
  27. package/lib/commonjs/components/FAB.js.map +1 -1
  28. package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
  29. package/lib/commonjs/components/Header.js.map +1 -1
  30. package/lib/commonjs/components/HeaderLarge.js.map +1 -1
  31. package/lib/commonjs/components/HeaderMedium.js.map +1 -1
  32. package/lib/commonjs/components/HeaderOverline.js.map +1 -1
  33. package/lib/commonjs/components/IconButton.js.map +1 -1
  34. package/lib/commonjs/components/Justification.js +3 -0
  35. package/lib/commonjs/components/Portal/Portal.js.map +1 -1
  36. package/lib/commonjs/components/ProgressCircle.js.map +1 -1
  37. package/lib/commonjs/components/ProgressIndicator.js.map +1 -1
  38. package/lib/commonjs/components/RadioButton/RadioButtonFieldGroup.js.map +1 -1
  39. package/lib/commonjs/components/ResizeMode.js +3 -0
  40. package/lib/commonjs/components/Row.js.map +1 -1
  41. package/lib/commonjs/components/RowBodyIcon.js.map +1 -1
  42. package/lib/commonjs/components/RowHeadlineImageCaption.js.map +1 -1
  43. package/lib/commonjs/components/RowHeadlineImageIcon.js.map +1 -1
  44. package/lib/commonjs/components/StarRating.js.map +1 -1
  45. package/lib/commonjs/components/Surface.js.map +1 -1
  46. package/lib/commonjs/components/Swiper/Swiper.js.map +1 -1
  47. package/lib/commonjs/components/ToggleButton.js.map +1 -1
  48. package/lib/commonjs/interfaces/Icon.js.map +1 -1
  49. package/lib/commonjs/mappings/KeyboardAvoidingView.js +2 -2
  50. package/lib/commonjs/mappings/KeyboardAvoidingView.js.map +1 -1
  51. package/lib/commonjs/mappings/RadioButtonGroup.js.map +1 -1
  52. package/lib/commonjs/mappings/RadioButtonRow.js.map +1 -1
  53. package/lib/module/Provider.js.map +1 -1
  54. package/lib/module/components/ActionSheet/ActionSheetCancel.js.map +1 -1
  55. package/lib/module/components/ActionSheet/ActionSheetItem.js.map +1 -1
  56. package/lib/module/components/AnimatedCircularProgress.js.map +1 -1
  57. package/lib/module/components/AspectRatio.js.map +1 -1
  58. package/lib/module/components/AvatarEdit.js.map +1 -1
  59. package/lib/module/components/Banner.js.map +1 -1
  60. package/lib/module/components/Card.js.map +1 -1
  61. package/lib/module/components/CardBlock.js.map +1 -1
  62. package/lib/module/components/CardContainer.js +15 -5
  63. package/lib/module/components/CardContainer.js.map +1 -1
  64. package/lib/module/components/CardContainerRating.js.map +1 -1
  65. package/lib/module/components/CardContainerShortImage.js.map +1 -1
  66. package/lib/module/components/CardInline.js.map +1 -1
  67. package/lib/module/components/Carousel.js.map +1 -1
  68. package/lib/module/components/CircleImage.js.map +1 -1
  69. package/lib/module/components/CircularProgress.js.map +1 -1
  70. package/lib/module/components/Container.js.map +1 -1
  71. package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
  72. package/lib/module/components/DatePicker/DatePickerComponent.js.map +1 -1
  73. package/lib/module/components/DeprecatedButton.js.map +1 -1
  74. package/lib/module/components/DeprecatedCardWrapper.js.map +1 -1
  75. package/lib/module/components/DeprecatedFAB.js.map +1 -1
  76. package/lib/module/components/Divider.js.map +1 -1
  77. package/lib/module/components/Elevation.js.map +1 -1
  78. package/lib/module/components/FAB.js.map +1 -1
  79. package/lib/module/components/FieldSearchBarFull.js.map +1 -1
  80. package/lib/module/components/Header.js.map +1 -1
  81. package/lib/module/components/HeaderLarge.js.map +1 -1
  82. package/lib/module/components/HeaderMedium.js.map +1 -1
  83. package/lib/module/components/HeaderOverline.js.map +1 -1
  84. package/lib/module/components/IconButton.js.map +1 -1
  85. package/lib/module/components/Justification.js +1 -1
  86. package/lib/module/components/Portal/Portal.js.map +1 -1
  87. package/lib/module/components/ProgressCircle.js.map +1 -1
  88. package/lib/module/components/ProgressIndicator.js.map +1 -1
  89. package/lib/module/components/RadioButton/RadioButtonFieldGroup.js.map +1 -1
  90. package/lib/module/components/ResizeMode.js +1 -1
  91. package/lib/module/components/Row.js.map +1 -1
  92. package/lib/module/components/RowBodyIcon.js.map +1 -1
  93. package/lib/module/components/RowHeadlineImageCaption.js.map +1 -1
  94. package/lib/module/components/RowHeadlineImageIcon.js.map +1 -1
  95. package/lib/module/components/StarRating.js.map +1 -1
  96. package/lib/module/components/Surface.js.map +1 -1
  97. package/lib/module/components/Swiper/Swiper.js.map +1 -1
  98. package/lib/module/components/ToggleButton.js.map +1 -1
  99. package/lib/module/interfaces/Icon.js.map +1 -1
  100. package/lib/module/mappings/KeyboardAvoidingView.js +2 -2
  101. package/lib/module/mappings/KeyboardAvoidingView.js.map +1 -1
  102. package/lib/typescript/src/components/Accordion/AccordionGroup.d.ts +2 -3022
  103. package/lib/typescript/src/components/Accordion/AccordionItem.d.ts +2 -3010
  104. package/lib/typescript/src/components/ActionSheet/ActionSheetCancel.d.ts +1 -1
  105. package/lib/typescript/src/components/ActionSheet/ActionSheetItem.d.ts +1 -1
  106. package/lib/typescript/src/components/AnimatedCircularProgress.d.ts +1 -1
  107. package/lib/typescript/src/components/AspectRatio.d.ts +1 -1
  108. package/lib/typescript/src/components/AvatarEdit.d.ts +2 -2
  109. package/lib/typescript/src/components/Banner.d.ts +2 -2
  110. package/lib/typescript/src/components/Card.d.ts +2 -2
  111. package/lib/typescript/src/components/CardBlock.d.ts +2 -2
  112. package/lib/typescript/src/components/CardContainer.d.ts +2 -2
  113. package/lib/typescript/src/components/CardContainerRating.d.ts +2 -2
  114. package/lib/typescript/src/components/CardContainerShortImage.d.ts +2 -2
  115. package/lib/typescript/src/components/CardInline.d.ts +2 -2
  116. package/lib/typescript/src/components/Carousel.d.ts +4 -7
  117. package/lib/typescript/src/components/CircleImage.d.ts +1 -1
  118. package/lib/typescript/src/components/Container.d.ts +2 -2
  119. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts +2 -2
  120. package/lib/typescript/src/components/DatePicker/DatePickerComponent.d.ts +1 -1
  121. package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
  122. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts +2 -2
  123. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  124. package/lib/typescript/src/components/Divider.d.ts +2 -2
  125. package/lib/typescript/src/components/Elevation.d.ts +2 -2
  126. package/lib/typescript/src/components/FAB.d.ts +2 -2
  127. package/lib/typescript/src/components/FieldSearchBarFull.d.ts +2 -2
  128. package/lib/typescript/src/components/Header.d.ts +2 -2
  129. package/lib/typescript/src/components/HeaderLarge.d.ts +2 -2
  130. package/lib/typescript/src/components/HeaderMedium.d.ts +2 -2
  131. package/lib/typescript/src/components/HeaderOverline.d.ts +2 -2
  132. package/lib/typescript/src/components/IconButton.d.ts +2 -2
  133. package/lib/typescript/src/components/ProgressCircle.d.ts +2 -2
  134. package/lib/typescript/src/components/ProgressIndicator.d.ts +2 -2
  135. package/lib/typescript/src/components/RadioButton/RadioButtonFieldGroup.d.ts +2 -2
  136. package/lib/typescript/src/components/Row.d.ts +2 -2
  137. package/lib/typescript/src/components/RowBodyIcon.d.ts +2 -2
  138. package/lib/typescript/src/components/RowHeadlineImageCaption.d.ts +2 -2
  139. package/lib/typescript/src/components/RowHeadlineImageIcon.d.ts +2 -2
  140. package/lib/typescript/src/components/Slider.d.ts +2 -3032
  141. package/lib/typescript/src/components/StarRating.d.ts +2 -2
  142. package/lib/typescript/src/components/Surface.d.ts +2 -2
  143. package/lib/typescript/src/components/Switch.d.ts +2 -3018
  144. package/lib/typescript/src/components/ToggleButton.d.ts +2 -2
  145. package/lib/typescript/src/interfaces/Icon.d.ts +1 -3
  146. package/package.json +4 -4
  147. package/src/Provider.js +9 -0
  148. package/src/Provider.tsx +1 -0
  149. package/src/components/Accordion/AccordionGroup.js +44 -0
  150. package/src/components/Accordion/AccordionItem.js +32 -0
  151. package/src/components/Accordion/index.js +2 -0
  152. package/src/components/ActionSheet/ActionSheet.js +45 -0
  153. package/src/components/ActionSheet/ActionSheetCancel.js +6 -0
  154. package/src/components/ActionSheet/ActionSheetCancel.tsx +1 -1
  155. package/src/components/ActionSheet/ActionSheetItem.js +30 -0
  156. package/src/components/ActionSheet/ActionSheetItem.tsx +6 -1
  157. package/src/components/ActionSheet/index.js +3 -0
  158. package/src/components/AnimatedCircularProgress.js +43 -0
  159. package/src/components/AnimatedCircularProgress.tsx +1 -1
  160. package/src/components/AspectRatio.js +18 -0
  161. package/src/components/AspectRatio.tsx +1 -1
  162. package/src/components/AvatarEdit.js +30 -0
  163. package/src/components/AvatarEdit.tsx +1 -1
  164. package/src/components/Banner.js +109 -0
  165. package/src/components/Banner.tsx +1 -1
  166. package/src/components/Button.js +112 -0
  167. package/src/components/Card.js +57 -0
  168. package/src/components/Card.tsx +1 -1
  169. package/src/components/CardBlock.js +54 -0
  170. package/src/components/CardBlock.tsx +1 -1
  171. package/src/components/CardContainer.js +69 -0
  172. package/src/components/CardContainer.tsx +1 -1
  173. package/src/components/CardContainerRating.js +79 -0
  174. package/src/components/CardContainerRating.tsx +1 -1
  175. package/src/components/CardContainerShortImage.js +33 -0
  176. package/src/components/CardContainerShortImage.tsx +1 -1
  177. package/src/components/CardInline.js +36 -0
  178. package/src/components/CardInline.tsx +1 -1
  179. package/src/components/Carousel.js +66 -0
  180. package/src/components/Carousel.tsx +2 -1
  181. package/src/components/Checkbox/Checkbox.js +63 -0
  182. package/src/components/Checkbox/CheckboxGroup.js +21 -0
  183. package/src/components/Checkbox/CheckboxGroupRow.js +77 -0
  184. package/src/components/Checkbox/CheckboxRow.js +78 -0
  185. package/src/components/Checkbox/context.js +14 -0
  186. package/src/components/Checkbox/index.js +3 -0
  187. package/src/components/CircleImage.js +8 -0
  188. package/src/components/CircleImage.tsx +1 -1
  189. package/src/components/CircularProgress.js +78 -0
  190. package/src/components/CircularProgress.tsx +1 -0
  191. package/src/components/Config.js +63 -0
  192. package/src/components/Container.js +43 -0
  193. package/src/components/Container.tsx +1 -1
  194. package/src/components/DatePicker/DatePicker.js +368 -0
  195. package/src/components/DatePicker/DatePicker.tsx +1 -1
  196. package/src/components/DatePicker/DatePickerComponent.js +13 -0
  197. package/src/components/DatePicker/DatePickerComponent.tsx +1 -1
  198. package/src/components/DatePicker/DatePickerComponent.web.js +30 -0
  199. package/src/components/DatePicker/DatePickerComponentType.js +1 -0
  200. package/src/components/DeprecatedButton.js +95 -0
  201. package/src/components/DeprecatedButton.tsx +1 -1
  202. package/src/components/DeprecatedCardWrapper.js +18 -0
  203. package/src/components/DeprecatedCardWrapper.tsx +1 -1
  204. package/src/components/DeprecatedFAB.js +115 -0
  205. package/src/components/DeprecatedFAB.tsx +1 -1
  206. package/src/components/Divider.js +13 -0
  207. package/src/components/Divider.tsx +1 -1
  208. package/src/components/Elevation.js +20 -0
  209. package/src/components/Elevation.tsx +6 -1
  210. package/src/components/FAB.js +46 -0
  211. package/src/components/FAB.tsx +1 -1
  212. package/src/components/FieldSearchBarFull.js +53 -0
  213. package/src/components/FieldSearchBarFull.tsx +1 -1
  214. package/src/components/FormRow.js +19 -0
  215. package/src/components/Header.js +44 -0
  216. package/src/components/Header.tsx +1 -1
  217. package/src/components/HeaderLarge.js +7 -0
  218. package/src/components/HeaderLarge.tsx +1 -1
  219. package/src/components/HeaderMedium.js +7 -0
  220. package/src/components/HeaderMedium.tsx +1 -1
  221. package/src/components/HeaderOverline.js +7 -0
  222. package/src/components/HeaderOverline.tsx +1 -1
  223. package/src/components/IconButton.js +35 -0
  224. package/src/components/IconButton.tsx +1 -1
  225. package/src/components/Image.js +47 -0
  226. package/src/components/Justification.js +1 -0
  227. package/src/components/Layout.js +50 -0
  228. package/src/components/NumberInput.js +49 -0
  229. package/src/components/Picker/Picker.js +266 -0
  230. package/src/components/Picker/PickerComponent.android.js +68 -0
  231. package/src/components/Picker/PickerComponent.ios.js +78 -0
  232. package/src/components/Picker/PickerComponent.web.js +69 -0
  233. package/src/components/Picker/PickerTypes.js +1 -0
  234. package/src/components/Portal/Portal.js +35 -0
  235. package/src/components/Portal/Portal.tsx +1 -0
  236. package/src/components/Portal/PortalConsumer.js +28 -0
  237. package/src/components/Portal/PortalHost.js +105 -0
  238. package/src/components/Portal/PortalManager.js +29 -0
  239. package/src/components/ProgressBar.js +118 -0
  240. package/src/components/ProgressCircle.js +13 -0
  241. package/src/components/ProgressCircle.tsx +2 -1
  242. package/src/components/ProgressIndicator.js +27 -0
  243. package/src/components/ProgressIndicator.tsx +1 -1
  244. package/src/components/RadioButton/RadioButton.js +17 -0
  245. package/src/components/RadioButton/RadioButtonFieldGroup.js +17 -0
  246. package/src/components/RadioButton/RadioButtonFieldGroup.tsx +1 -1
  247. package/src/components/RadioButton/RadioButtonGroup.js +43 -0
  248. package/src/components/RadioButton/RadioButtonRow.js +76 -0
  249. package/src/components/RadioButton/context.js +14 -0
  250. package/src/components/RadioButton/index.js +4 -0
  251. package/src/components/ResizeMode.js +1 -0
  252. package/src/components/Row.js +48 -0
  253. package/src/components/Row.tsx +1 -1
  254. package/src/components/RowBodyIcon.js +8 -0
  255. package/src/components/RowBodyIcon.tsx +1 -1
  256. package/src/components/RowHeadlineImageCaption.js +12 -0
  257. package/src/components/RowHeadlineImageCaption.tsx +1 -1
  258. package/src/components/RowHeadlineImageIcon.js +14 -0
  259. package/src/components/RowHeadlineImageIcon.tsx +1 -1
  260. package/src/components/ScreenContainer.js +34 -0
  261. package/src/components/Slider.js +63 -0
  262. package/src/components/StarRating.js +50 -0
  263. package/src/components/StarRating.tsx +2 -2
  264. package/src/components/StepIndicator.js +346 -0
  265. package/src/components/Stepper.js +39 -0
  266. package/src/components/Surface.js +32 -0
  267. package/src/components/Surface.tsx +1 -1
  268. package/src/components/Swiper/Swiper.js +29 -0
  269. package/src/components/Swiper/Swiper.tsx +1 -0
  270. package/src/components/Swiper/SwiperItem.js +9 -0
  271. package/src/components/Swiper/index.js +2 -0
  272. package/src/components/Switch.js +56 -0
  273. package/src/components/Text.js +28 -0
  274. package/src/components/TextField.js +420 -0
  275. package/src/components/ToggleButton.js +39 -0
  276. package/src/components/ToggleButton.tsx +1 -1
  277. package/src/components/Touchable.js +12 -0
  278. package/src/components/Touchable.web.js +2 -0
  279. package/src/components/Typography.js +36 -0
  280. package/src/components/useAuthState.js +31 -0
  281. package/src/constants.js +10 -0
  282. package/src/hooks.js +12 -0
  283. package/src/index.js +52 -0
  284. package/src/interfaces/Icon.js +8 -0
  285. package/src/interfaces/Icon.ts +1 -1
  286. package/src/mappings/Accordion.js +41 -0
  287. package/src/mappings/AccordionItem.js +16 -0
  288. package/src/mappings/ActionSheet.js +13 -0
  289. package/src/mappings/ActionSheetCancel.js +19 -0
  290. package/src/mappings/ActionSheetItem.js +23 -0
  291. package/src/mappings/ActivityIndicator.js +53 -0
  292. package/src/mappings/AudioPlayer.js +20 -0
  293. package/src/mappings/AvatarEdit.js +37 -0
  294. package/src/mappings/Banner.js +32 -0
  295. package/src/mappings/BlurView.js +41 -0
  296. package/src/mappings/Button.js +56 -0
  297. package/src/mappings/Card.js +52 -0
  298. package/src/mappings/CardBlock.js +122 -0
  299. package/src/mappings/CardContainer.js +102 -0
  300. package/src/mappings/CardContainerRating.js +124 -0
  301. package/src/mappings/CardContainerShortImage.js +118 -0
  302. package/src/mappings/CardInline.js +51 -0
  303. package/src/mappings/Carousel.js +18 -0
  304. package/src/mappings/Checkbox.js +45 -0
  305. package/src/mappings/CheckboxGroup.js +25 -0
  306. package/src/mappings/CheckboxRow.js +56 -0
  307. package/src/mappings/CircleImage.js +24 -0
  308. package/src/mappings/Container.js +29 -0
  309. package/src/mappings/CustomCode.js +8 -0
  310. package/src/mappings/DatePicker.js +147 -0
  311. package/src/mappings/Divider.js +26 -0
  312. package/src/mappings/FAB.js +36 -0
  313. package/src/mappings/Fetch.js +12 -0
  314. package/src/mappings/FieldSearchBarFull.js +49 -0
  315. package/src/mappings/FlatList.js +19 -0
  316. package/src/mappings/HeaderLarge.js +28 -0
  317. package/src/mappings/HeaderMedium.js +54 -0
  318. package/src/mappings/HeaderOverline.js +54 -0
  319. package/src/mappings/Icon.js +25 -0
  320. package/src/mappings/IconButton.js +30 -0
  321. package/src/mappings/Image.js +15 -0
  322. package/src/mappings/ImageBackground.js +28 -0
  323. package/src/mappings/KeyboardAvoidingView.js +40 -0
  324. package/src/mappings/KeyboardAvoidingView.ts +2 -2
  325. package/src/mappings/KeyboardAwareScrollView.js +49 -0
  326. package/src/mappings/Layout.js +195 -0
  327. package/src/mappings/LinearGradient.js +77 -0
  328. package/src/mappings/MapCallout.js +21 -0
  329. package/src/mappings/MapMarker.js +47 -0
  330. package/src/mappings/MapView.js +138 -0
  331. package/src/mappings/Modal.js +41 -0
  332. package/src/mappings/Picker.js +139 -0
  333. package/src/mappings/ProgressBar.js +100 -0
  334. package/src/mappings/ProgressCircle.js +108 -0
  335. package/src/mappings/ProgressIndicator.js +180 -0
  336. package/src/mappings/RadioButton.js +50 -0
  337. package/src/mappings/RadioButtonGroup.js +16 -0
  338. package/src/mappings/RadioButtonRow.js +37 -0
  339. package/src/mappings/RowBodyIcon.js +75 -0
  340. package/src/mappings/RowHeadlineImageCaption.js +167 -0
  341. package/src/mappings/RowHeadlineImageIcon.js +99 -0
  342. package/src/mappings/SafeAreaView.js +33 -0
  343. package/src/mappings/ScrollView.js +30 -0
  344. package/src/mappings/Slider.js +59 -0
  345. package/src/mappings/StarRating.js +42 -0
  346. package/src/mappings/Stepper.js +28 -0
  347. package/src/mappings/Surface.js +13 -0
  348. package/src/mappings/Swiper.js +60 -0
  349. package/src/mappings/SwiperItem.js +8 -0
  350. package/src/mappings/Switch.js +75 -0
  351. package/src/mappings/Text.js +232 -0
  352. package/src/mappings/TextArea.js +52 -0
  353. package/src/mappings/TextField.js +158 -0
  354. package/src/mappings/TextInput.js +208 -0
  355. package/src/mappings/ToggleButton.js +45 -0
  356. package/src/mappings/Touchable.js +12 -0
  357. package/src/mappings/Video.js +74 -0
  358. package/src/mappings/View.js +206 -0
  359. package/src/mappings/WebView.js +18 -0
  360. package/src/styles/DarkTheme.js +26 -0
  361. package/src/styles/DefaultTheme.js +111 -0
  362. package/src/styles/fonts.js +62 -0
  363. package/src/styles/overlay.js +60 -0
  364. package/src/styles/shadow.js +51 -0
  365. package/src/theming.js +3 -0
  366. package/src/utilities.js +102 -0
@@ -0,0 +1,266 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, Text, Platform, Dimensions, } from "react-native";
3
+ import { omit, pickBy, identity, isObject } from "lodash";
4
+ import { SafeAreaView } from "react-native-safe-area-context";
5
+ import { Picker as NativePicker } from "@react-native-picker/picker";
6
+ import { withTheme } from "../../theming";
7
+ import Portal from "../Portal/Portal";
8
+ import Button from "../DeprecatedButton";
9
+ import Touchable from "../Touchable";
10
+ import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames, } from "../../utilities";
11
+ function normalizeOptions(options) {
12
+ if (options.length === 0) {
13
+ return [];
14
+ }
15
+ if (typeof options[0] === ("string" || "number")) {
16
+ return options.map((option) => ({
17
+ label: String(option),
18
+ value: String(option),
19
+ }));
20
+ }
21
+ if (isObject(options[0]) &&
22
+ options[0].value !== null &&
23
+ options[0].label !== null) {
24
+ return options.map((option) => {
25
+ return {
26
+ label: String(option.label),
27
+ value: String(option.value),
28
+ };
29
+ });
30
+ }
31
+ throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
32
+ }
33
+ const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
34
+ const isIos = Platform.OS === "ios";
35
+ const unstyledColor = "rgba(165, 173, 183, 1)";
36
+ const disabledColor = "rgb(240, 240, 240)";
37
+ const errorColor = "rgba(255, 69, 100, 1)";
38
+ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, theme, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
39
+ const androidPickerRef = React.useRef(undefined);
40
+ const [internalValue, setInternalValue] = React.useState(value || defaultValue);
41
+ const [pickerVisible, setPickerVisible] = React.useState(false);
42
+ const togglePickerVisible = () => {
43
+ setPickerVisible(!pickerVisible);
44
+ };
45
+ React.useEffect(() => {
46
+ if (value != null) {
47
+ setInternalValue(value);
48
+ }
49
+ }, [value]);
50
+ React.useEffect(() => {
51
+ if (defaultValue != null) {
52
+ setInternalValue(defaultValue);
53
+ }
54
+ }, [defaultValue]);
55
+ React.useEffect(() => {
56
+ if (pickerVisible && androidPickerRef.current) {
57
+ androidPickerRef?.current?.focus();
58
+ }
59
+ }, [pickerVisible, androidPickerRef]);
60
+ const normalizedOptions = normalizeOptions(options);
61
+ const pickerOptions = placeholder
62
+ ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
63
+ : normalizedOptions;
64
+ const { colors } = theme;
65
+ const { viewStyles, textStyles } = extractStyles(style);
66
+ const additionalBorderStyles = ["backgroundColor"];
67
+ const additionalMarginStyles = [
68
+ "bottom",
69
+ "height",
70
+ "left",
71
+ "maxHeight",
72
+ "maxWidth",
73
+ "minHeight",
74
+ "minWidth",
75
+ "overflow",
76
+ "position",
77
+ "right",
78
+ "top",
79
+ "width",
80
+ "zIndex",
81
+ ];
82
+ const { borderStyles: extractedBorderStyles, marginStyles: extractedMarginStyles, } = extractBorderAndMarginStyles(viewStyles, additionalBorderStyles, additionalMarginStyles);
83
+ const borderStyles = {
84
+ ...{
85
+ ...(type === "solid"
86
+ ? {
87
+ borderTopLeftRadius: 5,
88
+ borderTopRightRadius: 5,
89
+ borderBottomRightRadius: 5,
90
+ borderBottomLeftRadius: 5,
91
+ borderTopWidth: 1,
92
+ borderRightWidth: 1,
93
+ borderLeftWidth: 1,
94
+ }
95
+ : {}),
96
+ borderBottomWidth: 1,
97
+ borderColor: unstyledColor,
98
+ borderStyle: "solid",
99
+ },
100
+ ...extractedBorderStyles,
101
+ ...(error ? { borderColor: errorColor } : {}),
102
+ ...(disabled
103
+ ? { borderColor: "transparent", backgroundColor: disabledColor }
104
+ : {}),
105
+ };
106
+ const marginStyles = {
107
+ height: 60,
108
+ ...extractedMarginStyles,
109
+ };
110
+ const stylesWithoutBordersAndMargins = omit(viewStyles, [
111
+ ...borderStyleNames,
112
+ ...marginStyleNames,
113
+ ...additionalBorderStyles,
114
+ ...additionalMarginStyles,
115
+ ]);
116
+ const selectedLabel = internalValue &&
117
+ (pickerOptions.find((option) => option.value === internalValue)?.label ??
118
+ internalValue);
119
+ const labelText = label ? (React.createElement(Text, { style: {
120
+ textAlign: textStyles.textAlign,
121
+ color: unstyledColor,
122
+ fontSize: 12,
123
+ paddingBottom: 4,
124
+ } }, label)) : null;
125
+ const leftIconOutset = leftIconMode === "outset";
126
+ const leftIcon = leftIconName ? (React.createElement(Icon, { name: leftIconName, color: disabled ? unstyledColor : iconColor, size: iconSize, style: {
127
+ marginRight: 4,
128
+ marginLeft: 4,
129
+ } })) : null;
130
+ const rightIcon = rightIconName ? (React.createElement(Icon, { name: rightIconName, color: disabled ? unstyledColor : iconColor, size: iconSize, style: {
131
+ marginRight: -10,
132
+ marginLeft: 8,
133
+ } })) : null;
134
+ const textAlign = textStyles?.textAlign;
135
+ const calculateLeftPadding = () => {
136
+ if (leftIconOutset) {
137
+ if (textAlign === "center") {
138
+ return iconSize - Math.abs(8 - iconSize);
139
+ }
140
+ return iconSize + 8;
141
+ }
142
+ return 0;
143
+ };
144
+ const assistiveTextLabel = assistiveText ? (React.createElement(Text, { style: {
145
+ textAlign,
146
+ width: "100%",
147
+ paddingLeft: calculateLeftPadding(),
148
+ color: unstyledColor,
149
+ fontSize: 12,
150
+ paddingTop: 4,
151
+ } }, assistiveText)) : null;
152
+ const primaryTextStyle = {
153
+ color: unstyledColor,
154
+ fontSize: 14,
155
+ ...pickBy(textStyles, identity),
156
+ ...(placeholder === internalValue ? { color: placeholderTextColor } : {}),
157
+ ...(disabled ? { color: unstyledColor } : {}),
158
+ };
159
+ const handleValueChange = (newValue, itemIndex) => {
160
+ if (!placeholder || itemIndex > 0) {
161
+ onValueChange?.(newValue, itemIndex);
162
+ }
163
+ setInternalValue(newValue);
164
+ };
165
+ return (
166
+ /* marginsContainer */
167
+ React.createElement(View, { style: [styles.marginsContainer, marginStyles] },
168
+ React.createElement(Touchable, { disabled: disabled, onPress: togglePickerVisible, style: styles.touchableContainer },
169
+ React.createElement(View, { pointerEvents: "none", style: [
170
+ styles.outsetContainer,
171
+ stylesWithoutBordersAndMargins,
172
+ !leftIconOutset ? borderStyles : {},
173
+ ] },
174
+ leftIcon,
175
+ React.createElement(View, { style: [
176
+ styles.insetContainer,
177
+ leftIconOutset ? borderStyles : {},
178
+ ] },
179
+ React.createElement(View, { style: styles.primaryTextContainer },
180
+ labelText,
181
+ React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel ?? placeholder))),
182
+ rightIcon)),
183
+ assistiveTextLabel),
184
+ isIos && pickerVisible ? (React.createElement(Portal, null,
185
+ React.createElement(View, { style: [
186
+ styles.iosPicker,
187
+ {
188
+ backgroundColor: colors.divider,
189
+ },
190
+ ] },
191
+ React.createElement(SafeAreaView, { style: styles.iosSafeArea },
192
+ React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
193
+ React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
194
+ !isIos && pickerVisible ? (React.createElement(NativePicker, { enabled: pickerVisible, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
195
+ };
196
+ export default withTheme(Picker);
197
+ const styles = StyleSheet.create({
198
+ marginsContainer: {
199
+ alignSelf: "stretch",
200
+ alignItems: "center",
201
+ width: "100%",
202
+ maxWidth: deviceWidth,
203
+ },
204
+ touchableContainer: {
205
+ flex: 1,
206
+ height: "100%",
207
+ width: "100%",
208
+ alignSelf: "stretch",
209
+ alignItems: "center",
210
+ },
211
+ outsetContainer: {
212
+ flex: 1,
213
+ height: "100%",
214
+ width: "100%",
215
+ flexDirection: "row",
216
+ alignItems: "center",
217
+ justifyContent: "space-between",
218
+ },
219
+ insetContainer: {
220
+ flex: 1,
221
+ height: "100%",
222
+ width: "100%",
223
+ flexDirection: "row",
224
+ alignItems: "center",
225
+ justifyContent: "space-between",
226
+ paddingLeft: 12,
227
+ paddingRight: 12,
228
+ },
229
+ primaryTextContainer: {
230
+ flex: 1,
231
+ },
232
+ iosPicker: {
233
+ position: "absolute",
234
+ bottom: 0,
235
+ left: 0,
236
+ right: 0,
237
+ flexDirection: "row",
238
+ justifyContent: "center",
239
+ width: "100%",
240
+ maxWidth: deviceWidth,
241
+ maxHeight: deviceHeight,
242
+ },
243
+ iosSafeArea: {
244
+ backgroundColor: "white",
245
+ flexDirection: "column",
246
+ width: "100%",
247
+ maxWidth: deviceWidth,
248
+ },
249
+ iosButton: {
250
+ alignSelf: "flex-end",
251
+ },
252
+ iosNativePicker: {
253
+ backgroundColor: "white",
254
+ },
255
+ nonIosPicker: {
256
+ opacity: 0,
257
+ position: "absolute",
258
+ top: 0,
259
+ left: 0,
260
+ right: 0,
261
+ bottom: 0,
262
+ width: "100%",
263
+ maxWidth: deviceWidth,
264
+ maxHeight: deviceHeight,
265
+ },
266
+ });
@@ -0,0 +1,68 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import omit from "lodash.omit";
4
+ import { withTheme } from "../../theming";
5
+ import { Picker as NativePicker } from "@react-native-picker/picker";
6
+ import { extractStyles } from "../../utilities";
7
+ import TextField from "../TextField";
8
+ import Touchable from "../Touchable";
9
+ const Picker = ({ style, options, placeholder, selectedValue, disabled = false, onValueChange: onValueChangeOverride = () => { }, ...props }) => {
10
+ const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
11
+ borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
12
+ borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
17
+ backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
18
+ padding, // eslint-disable-line @typescript-eslint/no-unused-vars
19
+ paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
20
+ paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
21
+ paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
22
+ paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
23
+ ...viewStyles }, } = extractStyles(style);
24
+ const textField = React.useRef(undefined);
25
+ const onValueChange = (itemValue, itemIndex) => {
26
+ toggleFocus();
27
+ onValueChangeOverride(itemValue, itemIndex);
28
+ };
29
+ const toggleFocus = () => {
30
+ if (!disabled) {
31
+ // @ts-ignore
32
+ textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
33
+ }
34
+ };
35
+ const stylesWithoutMargin = style &&
36
+ omit(StyleSheet.flatten(style), [
37
+ "margin",
38
+ "marginTop",
39
+ "marginRight",
40
+ "marginBottom",
41
+ "marginLeft",
42
+ ]);
43
+ const selectedLabel = selectedValue &&
44
+ (options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
45
+ return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
46
+ React.createElement(View, null,
47
+ React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: onValueChange, style: {
48
+ opacity: 0,
49
+ position: "absolute",
50
+ top: 0,
51
+ left: 0,
52
+ right: 0,
53
+ bottom: 0,
54
+ width: "100%",
55
+ } }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
56
+ React.createElement(View, { pointerEvents: "none" },
57
+ React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
58
+ // @ts-ignore
59
+ ref: textField, disabled: disabled,
60
+ // @ts-expect-error
61
+ style: stylesWithoutMargin })))));
62
+ };
63
+ const styles = StyleSheet.create({
64
+ container: {
65
+ alignSelf: "stretch",
66
+ },
67
+ });
68
+ export default withTheme(Picker);
@@ -0,0 +1,78 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
4
+ import omit from "lodash.omit";
5
+ import { Picker as NativePicker } from "@react-native-picker/picker";
6
+ import { withTheme } from "../../theming";
7
+ import Portal from "../Portal/Portal";
8
+ import Button from "../DeprecatedButton";
9
+ import TextField from "../TextField";
10
+ import Touchable from "../Touchable";
11
+ import { extractStyles } from "../../utilities";
12
+ const Picker = ({ Icon, style, options, placeholder, selectedValue, disabled = false, onValueChange = () => { }, theme: { colors }, ...props }) => {
13
+ const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
17
+ borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
18
+ borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
19
+ borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
20
+ backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
21
+ padding, // eslint-disable-line @typescript-eslint/no-unused-vars
22
+ paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
23
+ paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
24
+ paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
25
+ paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
26
+ ...viewStyles }, } = extractStyles(style);
27
+ const textField = React.useRef(undefined);
28
+ const [pickerVisible, setIsPickerVisible] = React.useState(false);
29
+ const toggleVisibility = () => {
30
+ setIsPickerVisible(!pickerVisible);
31
+ // @ts-ignore
32
+ textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
33
+ };
34
+ const stylesWithoutMargin = style &&
35
+ omit(StyleSheet.flatten(style), [
36
+ "margin",
37
+ "marginTop",
38
+ "marginRight",
39
+ "marginBottom",
40
+ "marginLeft",
41
+ ]);
42
+ const selectedLabel = selectedValue &&
43
+ (options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
44
+ return (React.createElement(View, { style: [styles.container, viewStyles] },
45
+ React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility },
46
+ React.createElement(TextField, { ...props, value: String(selectedLabel), placeholder: placeholder,
47
+ // @ts-ignore
48
+ ref: textField, disabled: disabled, pointerEvents: "none",
49
+ // @ts-expect-error
50
+ style: stylesWithoutMargin, Icon: Icon })),
51
+ pickerVisible && (React.createElement(Portal, null,
52
+ React.createElement(View, { style: [styles.picker, { backgroundColor: colors.divider }] },
53
+ React.createElement(SafeAreaView, { style: styles.pickerContainer },
54
+ React.createElement(Button, { Icon: Icon, type: "text", onPress: toggleVisibility, style: styles.closeButton }, "Close"),
55
+ React.createElement(NativePicker, { style: { backgroundColor: "white" }, selectedValue: selectedValue, onValueChange: onValueChange }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value }))))))))));
56
+ };
57
+ const styles = StyleSheet.create({
58
+ container: {
59
+ alignSelf: "stretch",
60
+ },
61
+ picker: {
62
+ position: "absolute",
63
+ bottom: 0,
64
+ left: 0,
65
+ right: 0,
66
+ flexDirection: "row",
67
+ justifyContent: "center",
68
+ },
69
+ pickerContainer: {
70
+ backgroundColor: "white",
71
+ flexDirection: "column",
72
+ width: "100%",
73
+ },
74
+ closeButton: {
75
+ alignSelf: "flex-end",
76
+ },
77
+ });
78
+ export default withTheme(Picker);
@@ -0,0 +1,69 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { Picker as NativePicker } from "@react-native-picker/picker";
4
+ import omit from "lodash.omit";
5
+ import { withTheme } from "../../theming";
6
+ import { extractStyles } from "../../utilities";
7
+ import TextField from "../TextField";
8
+ import Touchable from "../Touchable";
9
+ const Picker = ({ style, options, placeholder, selectedValue, disabled = false, onValueChange: onValueChangeOverride = () => { }, ...props }) => {
10
+ const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars
11
+ borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
12
+ borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
13
+ borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
14
+ borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars
16
+ borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars
17
+ backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars
18
+ padding, // eslint-disable-line @typescript-eslint/no-unused-vars
19
+ paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars
20
+ paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars
21
+ paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars
22
+ paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars
23
+ ...viewStyles }, } = extractStyles(style);
24
+ const textField = React.useRef(undefined);
25
+ const onValueChange = (itemValue, itemIndex) => {
26
+ toggleFocus();
27
+ onValueChangeOverride(itemValue, itemIndex);
28
+ };
29
+ const toggleFocus = () => {
30
+ if (!disabled) {
31
+ // @ts-ignore
32
+ textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
33
+ }
34
+ };
35
+ const stylesWithoutMargin = style &&
36
+ omit(StyleSheet.flatten(style), [
37
+ "margin",
38
+ "marginTop",
39
+ "marginRight",
40
+ "marginBottom",
41
+ "marginLeft",
42
+ ]);
43
+ const selectedLabel = selectedValue &&
44
+ (options.find((o) => o.value === selectedValue)?.label ?? selectedValue);
45
+ return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
46
+ React.createElement(View, null,
47
+ React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: onValueChange, style: {
48
+ flex: 1,
49
+ opacity: 0,
50
+ position: "absolute",
51
+ top: 0,
52
+ left: 0,
53
+ right: 0,
54
+ bottom: 0,
55
+ width: "100%",
56
+ } }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
57
+ React.createElement(View, { pointerEvents: "none" },
58
+ React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
59
+ // @ts-ignore
60
+ ref: textField, disabled: disabled,
61
+ // @ts-expect-error
62
+ style: stylesWithoutMargin })))));
63
+ };
64
+ const styles = StyleSheet.create({
65
+ container: {
66
+ alignSelf: "stretch",
67
+ },
68
+ });
69
+ export default withTheme(Picker);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import * as React from "react";
2
+ import PortalConsumer from "./PortalConsumer";
3
+ import PortalHost, { PortalContext } from "./PortalHost";
4
+ import { ThemeProvider, withTheme } from "../../theming";
5
+ /**
6
+ * Portal allows to render a component at a different place in the parent tree.
7
+ * You can use it to render content which should appear above other elements, similar to `Modal`.
8
+ * It requires a [`Portal.Host`](portal-host.html) component to be rendered somewhere in the parent tree.
9
+ *
10
+ * ## Usage
11
+ * ```js
12
+ * import * as React from 'react';
13
+ * import { Portal, Text } from 'react-native-paper';
14
+ *
15
+ * export default class MyComponent extends React.Component {
16
+ * render() {
17
+ * return (
18
+ * <Portal>
19
+ * <Text>This is rendered at a different place</Text>
20
+ * </Portal>
21
+ * );
22
+ * }
23
+ * }
24
+ * ```
25
+ */
26
+ class Portal extends React.Component {
27
+ // @component ./PortalHost.tsx
28
+ static Host = PortalHost;
29
+ render() {
30
+ const { children, theme } = this.props;
31
+ return (React.createElement(PortalContext.Consumer, null, (manager) => (React.createElement(PortalConsumer, { manager: manager },
32
+ React.createElement(ThemeProvider, { theme: theme }, children)))));
33
+ }
34
+ }
35
+ export default withTheme(Portal);
@@ -47,6 +47,7 @@ class Portal extends React.Component<Props> {
47
47
  <PortalContext.Consumer>
48
48
  {(manager) => (
49
49
  <PortalConsumer manager={manager as PortalMethods}>
50
+ {/* @ts-ignore */}
50
51
  <ThemeProvider theme={theme}>{children}</ThemeProvider>
51
52
  </PortalConsumer>
52
53
  )}
@@ -0,0 +1,28 @@
1
+ import * as React from "react";
2
+ export default class PortalConsumer extends React.Component {
3
+ async componentDidMount() {
4
+ this.checkManager();
5
+ // Delay updating to prevent React from going to infinite loop
6
+ await Promise.resolve();
7
+ this.key = this.props.manager.mount(this.props.children);
8
+ }
9
+ componentDidUpdate() {
10
+ this.checkManager();
11
+ this.props.manager.update(this.key, this.props.children);
12
+ }
13
+ componentWillUnmount() {
14
+ this.checkManager();
15
+ this.props.manager.unmount(this.key);
16
+ }
17
+ key;
18
+ checkManager() {
19
+ if (!this.props.manager) {
20
+ throw new Error("Looks like you forgot to wrap your root component with `Provider` component from `react-native-paper`.\n\n" +
21
+ "Please read our getting-started guide and make sure you've followed all the required steps.\n\n" +
22
+ "https://callstack.github.io/react-native-paper/getting-started.html");
23
+ }
24
+ }
25
+ render() {
26
+ return null;
27
+ }
28
+ }
@@ -0,0 +1,105 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import PortalManager from "./PortalManager";
4
+ export const PortalContext = React.createContext(null);
5
+ /**
6
+ * Portal host renders all of its children `Portal` elements.
7
+ * For example, you can wrap a screen in `Portal.Host` to render items above the screen.
8
+ * If you're using the `Provider` component, it already includes `Portal.Host`.
9
+ *
10
+ * ## Usage
11
+ * ```js
12
+ * import * as React from 'react';
13
+ * import { Text } from 'react-native';
14
+ * import { Portal } from 'react-native-paper';
15
+ *
16
+ * export default class MyComponent extends React.Component {
17
+ * render() {
18
+ * return (
19
+ * <Portal.Host>
20
+ * <Text>Content of the app</Text>
21
+ * </Portal.Host>
22
+ * );
23
+ * }
24
+ * }
25
+ * ```
26
+ *
27
+ * Here any `Portal` elements under `<App />` are rendered alongside `<App />` and will appear above `<App />` like a `Modal`.
28
+ */
29
+ export default class PortalHost extends React.Component {
30
+ static displayName = "Portal.Host";
31
+ componentDidMount() {
32
+ const manager = this.manager;
33
+ const queue = this.queue;
34
+ while (queue.length && manager) {
35
+ const action = queue.pop();
36
+ if (action) {
37
+ switch (action.type) {
38
+ case "mount":
39
+ manager.mount(action.key, action.children);
40
+ break;
41
+ case "update":
42
+ manager.update(action.key, action.children);
43
+ break;
44
+ case "unmount":
45
+ manager.unmount(action.key);
46
+ break;
47
+ }
48
+ }
49
+ }
50
+ }
51
+ setManager = (manager) => {
52
+ this.manager = manager;
53
+ };
54
+ mount = (children) => {
55
+ const key = this.nextKey++;
56
+ if (this.manager) {
57
+ this.manager.mount(key, children);
58
+ }
59
+ else {
60
+ this.queue.push({ type: "mount", key, children });
61
+ }
62
+ return key;
63
+ };
64
+ update = (key, children) => {
65
+ if (this.manager) {
66
+ this.manager.update(key, children);
67
+ }
68
+ else {
69
+ const op = { type: "mount", key, children };
70
+ const index = this.queue.findIndex((o) => o.type === "mount" || (o.type === "update" && o.key === key));
71
+ if (index > -1) {
72
+ // @ts-ignore
73
+ this.queue[index] = op;
74
+ }
75
+ else {
76
+ this.queue.push(op);
77
+ }
78
+ }
79
+ };
80
+ unmount = (key) => {
81
+ if (this.manager) {
82
+ this.manager.unmount(key);
83
+ }
84
+ else {
85
+ this.queue.push({ type: "unmount", key });
86
+ }
87
+ };
88
+ nextKey = 0;
89
+ queue = [];
90
+ manager;
91
+ render() {
92
+ return (React.createElement(PortalContext.Provider, { value: {
93
+ mount: this.mount,
94
+ update: this.update,
95
+ unmount: this.unmount,
96
+ } },
97
+ React.createElement(View, { style: styles.container, collapsable: false, pointerEvents: "box-none" }, this.props.children),
98
+ React.createElement(PortalManager, { ref: this.setManager })));
99
+ }
100
+ }
101
+ const styles = StyleSheet.create({
102
+ container: {
103
+ flex: 1,
104
+ },
105
+ });